diff options
author | marha <marha@users.sourceforge.net> | 2011-06-06 10:36:17 +0200 |
---|---|---|
committer | marha <marha@users.sourceforge.net> | 2011-06-06 10:36:17 +0200 |
commit | 336e4aab196609a528213e9ecebcb30fce7aa654 (patch) | |
tree | c8a72cf42c0bbe281dffdac04d60e758aeea345f | |
parent | 097c0d8400d976c5c372db576a11764e87994c7f (diff) | |
parent | 416761431e76dcb053fa3447b6d53051579dad0a (diff) | |
download | vcxsrv-336e4aab196609a528213e9ecebcb30fce7aa654.tar.gz vcxsrv-336e4aab196609a528213e9ecebcb30fce7aa654.tar.bz2 vcxsrv-336e4aab196609a528213e9ecebcb30fce7aa654.zip |
Merge remote-tracking branch 'origin/released'
Conflicts:
xorg-server/hw/xquartz/GL/indirect.c
xorg-server/hw/xquartz/mach-startup/Makefile.am
xorg-server/test/xi2/protocol-common.c
xorg-server/xkb/xkbfmisc.c
-rw-r--r-- | mesalib/src/mesa/drivers/common/meta.c | 5864 | ||||
-rw-r--r-- | xorg-server/hw/kdrive/ephyr/man/Xephyr.man | 2 | ||||
-rw-r--r-- | xorg-server/hw/xquartz/GL/indirect.c | 1906 | ||||
-rw-r--r-- | xorg-server/hw/xquartz/mach-startup/Makefile.am | 1 | ||||
-rw-r--r-- | xorg-server/test/xi2/protocol-common.c | 2 | ||||
-rw-r--r-- | xorg-server/xkb/xkbfmisc.c | 41 |
6 files changed, 3857 insertions, 3959 deletions
diff --git a/mesalib/src/mesa/drivers/common/meta.c b/mesalib/src/mesa/drivers/common/meta.c index 06d4337f8..979926a7e 100644 --- a/mesalib/src/mesa/drivers/common/meta.c +++ b/mesalib/src/mesa/drivers/common/meta.c @@ -1,2924 +1,2940 @@ -/*
- * Mesa 3-D graphics library
- * Version: 7.6
- *
- * 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.
- */
-
-/**
- * Meta operations. Some GL operations can be expressed in terms of
- * other GL operations. For example, glBlitFramebuffer() can be done
- * with texture mapping and glClear() can be done with polygon rendering.
- *
- * \author Brian Paul
- */
-
-
-#include "main/glheader.h"
-#include "main/mtypes.h"
-#include "main/imports.h"
-#include "main/arbprogram.h"
-#include "main/arrayobj.h"
-#include "main/blend.h"
-#include "main/bufferobj.h"
-#include "main/buffers.h"
-#include "main/colortab.h"
-#include "main/condrender.h"
-#include "main/depth.h"
-#include "main/enable.h"
-#include "main/fbobject.h"
-#include "main/formats.h"
-#include "main/image.h"
-#include "main/macros.h"
-#include "main/matrix.h"
-#include "main/mipmap.h"
-#include "main/pbo.h"
-#include "main/polygon.h"
-#include "main/readpix.h"
-#include "main/scissor.h"
-#include "main/shaderapi.h"
-#include "main/shaderobj.h"
-#include "main/state.h"
-#include "main/stencil.h"
-#include "main/texobj.h"
-#include "main/texenv.h"
-#include "main/teximage.h"
-#include "main/texparam.h"
-#include "main/texstate.h"
-#include "main/varray.h"
-#include "main/viewport.h"
-#include "program/program.h"
-#include "swrast/swrast.h"
-#include "drivers/common/meta.h"
-
-
-/** Return offset in bytes of the field within a vertex struct */
-#define OFFSET(FIELD) ((void *) offsetof(struct vertex, FIELD))
-
-
-/**
- * Flags passed to _mesa_meta_begin().
- */
-/*@{*/
-#define META_ALL ~0x0
-#define META_ALPHA_TEST 0x1
-#define META_BLEND 0x2 /**< includes logicop */
-#define META_COLOR_MASK 0x4
-#define META_DEPTH_TEST 0x8
-#define META_FOG 0x10
-#define META_PIXEL_STORE 0x20
-#define META_PIXEL_TRANSFER 0x40
-#define META_RASTERIZATION 0x80
-#define META_SCISSOR 0x100
-#define META_SHADER 0x200
-#define META_STENCIL_TEST 0x400
-#define META_TRANSFORM 0x800 /**< modelview, projection, clip planes */
-#define META_TEXTURE 0x1000
-#define META_VERTEX 0x2000
-#define META_VIEWPORT 0x4000
-#define META_CLAMP_FRAGMENT_COLOR 0x8000
-#define META_CLAMP_VERTEX_COLOR 0x10000
-#define META_CONDITIONAL_RENDER 0x20000
-/*@}*/
-
-
-/**
- * State which we may save/restore across meta ops.
- * XXX this may be incomplete...
- */
-struct save_state
-{
- GLbitfield SavedState; /**< bitmask of META_* flags */
-
- /** META_ALPHA_TEST */
- GLboolean AlphaEnabled;
- GLenum AlphaFunc;
- GLclampf AlphaRef;
-
- /** META_BLEND */
- GLbitfield BlendEnabled;
- GLboolean ColorLogicOpEnabled;
-
- /** META_COLOR_MASK */
- GLubyte ColorMask[MAX_DRAW_BUFFERS][4];
-
- /** META_DEPTH_TEST */
- struct gl_depthbuffer_attrib Depth;
-
- /** META_FOG */
- GLboolean Fog;
-
- /** META_PIXEL_STORE */
- struct gl_pixelstore_attrib Pack, Unpack;
-
- /** META_PIXEL_TRANSFER */
- GLfloat RedBias, RedScale;
- GLfloat GreenBias, GreenScale;
- GLfloat BlueBias, BlueScale;
- GLfloat AlphaBias, AlphaScale;
- GLfloat DepthBias, DepthScale;
- GLboolean MapColorFlag;
-
- /** META_RASTERIZATION */
- GLenum FrontPolygonMode, BackPolygonMode;
- GLboolean PolygonOffset;
- GLboolean PolygonSmooth;
- GLboolean PolygonStipple;
- GLboolean PolygonCull;
-
- /** META_SCISSOR */
- struct gl_scissor_attrib Scissor;
-
- /** META_SHADER */
- GLboolean VertexProgramEnabled;
- struct gl_vertex_program *VertexProgram;
- GLboolean FragmentProgramEnabled;
- struct gl_fragment_program *FragmentProgram;
- struct gl_shader_program *VertexShader;
- struct gl_shader_program *GeometryShader;
- struct gl_shader_program *FragmentShader;
- struct gl_shader_program *ActiveShader;
-
- /** META_STENCIL_TEST */
- struct gl_stencil_attrib Stencil;
-
- /** META_TRANSFORM */
- GLenum MatrixMode;
- GLfloat ModelviewMatrix[16];
- GLfloat ProjectionMatrix[16];
- GLfloat TextureMatrix[16];
- GLbitfield ClipPlanesEnabled;
-
- /** META_TEXTURE */
- GLuint ActiveUnit;
- GLuint ClientActiveUnit;
- /** for unit[0] only */
- struct gl_texture_object *CurrentTexture[NUM_TEXTURE_TARGETS];
- /** mask of TEXTURE_2D_BIT, etc */
- GLbitfield TexEnabled[MAX_TEXTURE_UNITS];
- GLbitfield TexGenEnabled[MAX_TEXTURE_UNITS];
- GLuint EnvMode; /* unit[0] only */
-
- /** META_VERTEX */
- struct gl_array_object *ArrayObj;
- struct gl_buffer_object *ArrayBufferObj;
-
- /** META_VIEWPORT */
- GLint ViewportX, ViewportY, ViewportW, ViewportH;
- GLclampd DepthNear, DepthFar;
-
- /** META_CLAMP_FRAGMENT_COLOR */
- GLenum ClampFragmentColor;
-
- /** META_CLAMP_VERTEX_COLOR */
- GLenum ClampVertexColor;
-
- /** META_CONDITIONAL_RENDER */
- struct gl_query_object *CondRenderQuery;
- GLenum CondRenderMode;
-
- /** Miscellaneous (always disabled) */
- GLboolean Lighting;
-};
-
-
-/**
- * Temporary texture used for glBlitFramebuffer, glDrawPixels, etc.
- * This is currently shared by all the meta ops. But we could create a
- * separate one for each of glDrawPixel, glBlitFramebuffer, glCopyPixels, etc.
- */
-struct temp_texture
-{
- GLuint TexObj;
- GLenum Target; /**< GL_TEXTURE_2D or GL_TEXTURE_RECTANGLE */
- GLsizei MinSize; /**< Min texture size to allocate */
- GLsizei MaxSize; /**< Max possible texture size */
- GLboolean NPOT; /**< Non-power of two size OK? */
- GLsizei Width, Height; /**< Current texture size */
- GLenum IntFormat;
- GLfloat Sright, Ttop; /**< right, top texcoords */
-};
-
-
-/**
- * State for glBlitFramebufer()
- */
-struct blit_state
-{
- GLuint ArrayObj;
- GLuint VBO;
- GLuint DepthFP;
-};
-
-
-/**
- * State for glClear()
- */
-struct clear_state
-{
- GLuint ArrayObj;
- GLuint VBO;
-};
-
-
-/**
- * State for glCopyPixels()
- */
-struct copypix_state
-{
- GLuint ArrayObj;
- GLuint VBO;
-};
-
-
-/**
- * State for glDrawPixels()
- */
-struct drawpix_state
-{
- GLuint ArrayObj;
-
- GLuint StencilFP; /**< Fragment program for drawing stencil images */
- GLuint DepthFP; /**< Fragment program for drawing depth images */
-};
-
-
-/**
- * State for glBitmap()
- */
-struct bitmap_state
-{
- GLuint ArrayObj;
- GLuint VBO;
- struct temp_texture Tex; /**< separate texture from other meta ops */
-};
-
-
-/**
- * State for _mesa_meta_generate_mipmap()
- */
-struct gen_mipmap_state
-{
- GLuint ArrayObj;
- GLuint VBO;
- GLuint FBO;
-};
-
-#define MAX_META_OPS_DEPTH 2
-/**
- * All per-context meta state.
- */
-struct gl_meta_state
-{
- /** Stack of state saved during meta-ops */
- struct save_state Save[MAX_META_OPS_DEPTH];
- /** Save stack depth */
- GLuint SaveStackDepth;
-
- struct temp_texture TempTex;
-
- struct blit_state Blit; /**< For _mesa_meta_BlitFramebuffer() */
- struct clear_state Clear; /**< For _mesa_meta_Clear() */
- struct copypix_state CopyPix; /**< For _mesa_meta_CopyPixels() */
- struct drawpix_state DrawPix; /**< For _mesa_meta_DrawPixels() */
- struct bitmap_state Bitmap; /**< For _mesa_meta_Bitmap() */
- struct gen_mipmap_state Mipmap; /**< For _mesa_meta_GenerateMipmap() */
-};
-
-
-/**
- * Initialize meta-ops for a context.
- * To be called once during context creation.
- */
-void
-_mesa_meta_init(struct gl_context *ctx)
-{
- ASSERT(!ctx->Meta);
-
- ctx->Meta = CALLOC_STRUCT(gl_meta_state);
-}
-
-
-/**
- * Free context meta-op state.
- * To be called once during context destruction.
- */
-void
-_mesa_meta_free(struct gl_context *ctx)
-{
- /* Note: Any textures, VBOs, etc, that we allocate should get
- * freed by the normal context destruction code. But this would be
- * the place to free other meta data someday.
- */
- free(ctx->Meta);
- ctx->Meta = NULL;
-}
-
-
-/**
- * Enter meta state. This is like a light-weight version of glPushAttrib
- * but it also resets most GL state back to default values.
- *
- * \param state bitmask of META_* flags indicating which attribute groups
- * to save and reset to their defaults
- */
-static void
-_mesa_meta_begin(struct gl_context *ctx, GLbitfield state)
-{
- struct save_state *save;
-
- /* hope MAX_META_OPS_DEPTH is large enough */
- assert(ctx->Meta->SaveStackDepth < MAX_META_OPS_DEPTH);
-
- save = &ctx->Meta->Save[ctx->Meta->SaveStackDepth++];
- memset(save, 0, sizeof(*save));
- save->SavedState = state;
-
- if (state & META_ALPHA_TEST) {
- save->AlphaEnabled = ctx->Color.AlphaEnabled;
- save->AlphaFunc = ctx->Color.AlphaFunc;
- save->AlphaRef = ctx->Color.AlphaRef;
- if (ctx->Color.AlphaEnabled)
- _mesa_set_enable(ctx, GL_ALPHA_TEST, GL_FALSE);
- }
-
- if (state & META_BLEND) {
- save->BlendEnabled = ctx->Color.BlendEnabled;
- if (ctx->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, GL_FALSE);
- }
- }
- else {
- _mesa_set_enable(ctx, GL_BLEND, GL_FALSE);
- }
- }
- save->ColorLogicOpEnabled = ctx->Color.ColorLogicOpEnabled;
- if (ctx->Color.ColorLogicOpEnabled)
- _mesa_set_enable(ctx, GL_COLOR_LOGIC_OP, GL_FALSE);
- }
-
- if (state & META_COLOR_MASK) {
- memcpy(save->ColorMask, ctx->Color.ColorMask,
- sizeof(ctx->Color.ColorMask));
- if (!ctx->Color.ColorMask[0][0] ||
- !ctx->Color.ColorMask[0][1] ||
- !ctx->Color.ColorMask[0][2] ||
- !ctx->Color.ColorMask[0][3])
- _mesa_ColorMask(GL_TRUE, GL_TRUE, GL_TRUE, GL_TRUE);
- }
-
- if (state & META_DEPTH_TEST) {
- save->Depth = ctx->Depth; /* struct copy */
- if (ctx->Depth.Test)
- _mesa_set_enable(ctx, GL_DEPTH_TEST, GL_FALSE);
- }
-
- if (state & META_FOG) {
- save->Fog = ctx->Fog.Enabled;
- if (ctx->Fog.Enabled)
- _mesa_set_enable(ctx, GL_FOG, GL_FALSE);
- }
-
- if (state & META_PIXEL_STORE) {
- save->Pack = ctx->Pack;
- save->Unpack = ctx->Unpack;
- ctx->Pack = ctx->DefaultPacking;
- ctx->Unpack = ctx->DefaultPacking;
- }
-
- if (state & META_PIXEL_TRANSFER) {
- save->RedScale = ctx->Pixel.RedScale;
- save->RedBias = ctx->Pixel.RedBias;
- save->GreenScale = ctx->Pixel.GreenScale;
- save->GreenBias = ctx->Pixel.GreenBias;
- save->BlueScale = ctx->Pixel.BlueScale;
- save->BlueBias = ctx->Pixel.BlueBias;
- save->AlphaScale = ctx->Pixel.AlphaScale;
- save->AlphaBias = ctx->Pixel.AlphaBias;
- save->MapColorFlag = ctx->Pixel.MapColorFlag;
- 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;
- ctx->Pixel.MapColorFlag = GL_FALSE;
- /* XXX more state */
- ctx->NewState |=_NEW_PIXEL;
- }
-
- if (state & META_RASTERIZATION) {
- save->FrontPolygonMode = ctx->Polygon.FrontMode;
- save->BackPolygonMode = ctx->Polygon.BackMode;
- save->PolygonOffset = ctx->Polygon.OffsetFill;
- save->PolygonSmooth = ctx->Polygon.SmoothFlag;
- save->PolygonStipple = ctx->Polygon.StippleFlag;
- save->PolygonCull = ctx->Polygon.CullFlag;
- _mesa_PolygonMode(GL_FRONT_AND_BACK, GL_FILL);
- _mesa_set_enable(ctx, GL_POLYGON_OFFSET_FILL, GL_FALSE);
- _mesa_set_enable(ctx, GL_POLYGON_SMOOTH, GL_FALSE);
- _mesa_set_enable(ctx, GL_POLYGON_STIPPLE, GL_FALSE);
- _mesa_set_enable(ctx, GL_CULL_FACE, GL_FALSE);
- }
-
- if (state & META_SCISSOR) {
- save->Scissor = ctx->Scissor; /* struct copy */
- _mesa_set_enable(ctx, GL_SCISSOR_TEST, GL_FALSE);
- }
-
- if (state & META_SHADER) {
- if (ctx->Extensions.ARB_vertex_program) {
- save->VertexProgramEnabled = ctx->VertexProgram.Enabled;
- _mesa_reference_vertprog(ctx, &save->VertexProgram,
- ctx->VertexProgram.Current);
- _mesa_set_enable(ctx, GL_VERTEX_PROGRAM_ARB, GL_FALSE);
- }
-
- if (ctx->Extensions.ARB_fragment_program) {
- save->FragmentProgramEnabled = ctx->FragmentProgram.Enabled;
- _mesa_reference_fragprog(ctx, &save->FragmentProgram,
- ctx->FragmentProgram.Current);
- _mesa_set_enable(ctx, GL_FRAGMENT_PROGRAM_ARB, GL_FALSE);
- }
-
- if (ctx->Extensions.ARB_shader_objects) {
- _mesa_reference_shader_program(ctx, &save->VertexShader,
- ctx->Shader.CurrentVertexProgram);
- _mesa_reference_shader_program(ctx, &save->GeometryShader,
- ctx->Shader.CurrentGeometryProgram);
- _mesa_reference_shader_program(ctx, &save->FragmentShader,
- ctx->Shader.CurrentFragmentProgram);
- _mesa_reference_shader_program(ctx, &save->ActiveShader,
- ctx->Shader.CurrentFragmentProgram);
-
- _mesa_UseProgramObjectARB(0);
- }
- }
-
- if (state & META_STENCIL_TEST) {
- save->Stencil = ctx->Stencil; /* struct copy */
- if (ctx->Stencil.Enabled)
- _mesa_set_enable(ctx, GL_STENCIL_TEST, GL_FALSE);
- /* NOTE: other stencil state not reset */
- }
-
- if (state & META_TEXTURE) {
- GLuint u, tgt;
-
- save->ActiveUnit = ctx->Texture.CurrentUnit;
- save->ClientActiveUnit = ctx->Array.ActiveTexture;
- save->EnvMode = ctx->Texture.Unit[0].EnvMode;
-
- /* Disable all texture units */
- for (u = 0; u < ctx->Const.MaxTextureUnits; u++) {
- save->TexEnabled[u] = ctx->Texture.Unit[u].Enabled;
- save->TexGenEnabled[u] = ctx->Texture.Unit[u].TexGenEnabled;
- if (ctx->Texture.Unit[u].Enabled ||
- ctx->Texture.Unit[u].TexGenEnabled) {
- _mesa_ActiveTextureARB(GL_TEXTURE0 + u);
- _mesa_set_enable(ctx, GL_TEXTURE_1D, GL_FALSE);
- _mesa_set_enable(ctx, GL_TEXTURE_2D, GL_FALSE);
- _mesa_set_enable(ctx, GL_TEXTURE_3D, GL_FALSE);
- if (ctx->Extensions.ARB_texture_cube_map)
- _mesa_set_enable(ctx, GL_TEXTURE_CUBE_MAP, GL_FALSE);
- _mesa_set_enable(ctx, GL_TEXTURE_RECTANGLE, GL_FALSE);
- _mesa_set_enable(ctx, GL_TEXTURE_GEN_S, GL_FALSE);
- _mesa_set_enable(ctx, GL_TEXTURE_GEN_T, GL_FALSE);
- _mesa_set_enable(ctx, GL_TEXTURE_GEN_R, GL_FALSE);
- _mesa_set_enable(ctx, GL_TEXTURE_GEN_Q, GL_FALSE);
- }
- }
-
- /* save current texture objects for unit[0] only */
- for (tgt = 0; tgt < NUM_TEXTURE_TARGETS; tgt++) {
- _mesa_reference_texobj(&save->CurrentTexture[tgt],
- ctx->Texture.Unit[0].CurrentTex[tgt]);
- }
-
- /* set defaults for unit[0] */
- _mesa_ActiveTextureARB(GL_TEXTURE0);
- _mesa_ClientActiveTextureARB(GL_TEXTURE0);
- _mesa_TexEnvi(GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_REPLACE);
- }
-
- if (state & META_TRANSFORM) {
- GLuint activeTexture = ctx->Texture.CurrentUnit;
- memcpy(save->ModelviewMatrix, ctx->ModelviewMatrixStack.Top->m,
- 16 * sizeof(GLfloat));
- memcpy(save->ProjectionMatrix, ctx->ProjectionMatrixStack.Top->m,
- 16 * sizeof(GLfloat));
- memcpy(save->TextureMatrix, ctx->TextureMatrixStack[0].Top->m,
- 16 * sizeof(GLfloat));
- save->MatrixMode = ctx->Transform.MatrixMode;
- /* set 1:1 vertex:pixel coordinate transform */
- _mesa_ActiveTextureARB(GL_TEXTURE0);
- _mesa_MatrixMode(GL_TEXTURE);
- _mesa_LoadIdentity();
- _mesa_ActiveTextureARB(GL_TEXTURE0 + activeTexture);
- _mesa_MatrixMode(GL_MODELVIEW);
- _mesa_LoadIdentity();
- _mesa_MatrixMode(GL_PROJECTION);
- _mesa_LoadIdentity();
- _mesa_Ortho(0.0, ctx->DrawBuffer->Width,
- 0.0, ctx->DrawBuffer->Height,
- -1.0, 1.0);
- save->ClipPlanesEnabled = ctx->Transform.ClipPlanesEnabled;
- if (ctx->Transform.ClipPlanesEnabled) {
- GLuint i;
- for (i = 0; i < ctx->Const.MaxClipPlanes; i++) {
- _mesa_set_enable(ctx, GL_CLIP_PLANE0 + i, GL_FALSE);
- }
- }
- }
-
- if (state & META_VERTEX) {
- /* save vertex array object state */
- _mesa_reference_array_object(ctx, &save->ArrayObj,
- ctx->Array.ArrayObj);
- _mesa_reference_buffer_object(ctx, &save->ArrayBufferObj,
- ctx->Array.ArrayBufferObj);
- /* set some default state? */
- }
-
- if (state & META_VIEWPORT) {
- /* save viewport state */
- save->ViewportX = ctx->Viewport.X;
- save->ViewportY = ctx->Viewport.Y;
- save->ViewportW = ctx->Viewport.Width;
- save->ViewportH = ctx->Viewport.Height;
- /* set viewport to match window size */
- if (ctx->Viewport.X != 0 ||
- ctx->Viewport.Y != 0 ||
- ctx->Viewport.Width != ctx->DrawBuffer->Width ||
- ctx->Viewport.Height != ctx->DrawBuffer->Height) {
- _mesa_set_viewport(ctx, 0, 0,
- ctx->DrawBuffer->Width, ctx->DrawBuffer->Height);
- }
- /* save depth range state */
- save->DepthNear = ctx->Viewport.Near;
- save->DepthFar = ctx->Viewport.Far;
- /* set depth range to default */
- _mesa_DepthRange(0.0, 1.0);
- }
-
- if (state & META_CLAMP_FRAGMENT_COLOR) {
- save->ClampFragmentColor = ctx->Color.ClampFragmentColor;
-
- /* Generally in here we want to do clamping according to whether
- * it's for the pixel path (ClampFragmentColor is GL_TRUE),
- * regardless of the internal implementation of the metaops.
- */
- if (ctx->Color.ClampFragmentColor != GL_TRUE)
- _mesa_ClampColorARB(GL_CLAMP_FRAGMENT_COLOR, GL_FALSE);
- }
-
- if (state & META_CLAMP_VERTEX_COLOR) {
- save->ClampVertexColor = ctx->Light.ClampVertexColor;
-
- /* Generally in here we never want vertex color clamping --
- * result clamping is only dependent on fragment clamping.
- */
- _mesa_ClampColorARB(GL_CLAMP_VERTEX_COLOR, GL_FALSE);
- }
-
- if (state & META_CONDITIONAL_RENDER) {
- save->CondRenderQuery = ctx->Query.CondRenderQuery;
- save->CondRenderMode = ctx->Query.CondRenderMode;
-
- if (ctx->Query.CondRenderQuery)
- _mesa_EndConditionalRender();
- }
-
- /* misc */
- {
- save->Lighting = ctx->Light.Enabled;
- if (ctx->Light.Enabled)
- _mesa_set_enable(ctx, GL_LIGHTING, GL_FALSE);
- }
-}
-
-
-/**
- * Leave meta state. This is like a light-weight version of glPopAttrib().
- */
-static void
-_mesa_meta_end(struct gl_context *ctx)
-{
- struct save_state *save = &ctx->Meta->Save[--ctx->Meta->SaveStackDepth];
- const GLbitfield state = save->SavedState;
-
- if (state & META_ALPHA_TEST) {
- if (ctx->Color.AlphaEnabled != save->AlphaEnabled)
- _mesa_set_enable(ctx, GL_ALPHA_TEST, save->AlphaEnabled);
- _mesa_AlphaFunc(save->AlphaFunc, save->AlphaRef);
- }
-
- if (state & META_BLEND) {
- if (ctx->Color.BlendEnabled != save->BlendEnabled) {
- if (ctx->Extensions.EXT_draw_buffers2) {
- GLuint i;
- for (i = 0; i < ctx->Const.MaxDrawBuffers; i++) {
- _mesa_set_enablei(ctx, GL_BLEND, i, (save->BlendEnabled >> i) & 1);
- }
- }
- else {
- _mesa_set_enable(ctx, GL_BLEND, (save->BlendEnabled & 1));
- }
- }
- if (ctx->Color.ColorLogicOpEnabled != save->ColorLogicOpEnabled)
- _mesa_set_enable(ctx, GL_COLOR_LOGIC_OP, save->ColorLogicOpEnabled);
- }
-
- if (state & META_COLOR_MASK) {
- GLuint i;
- for (i = 0; i < ctx->Const.MaxDrawBuffers; i++) {
- if (!TEST_EQ_4V(ctx->Color.ColorMask[i], save->ColorMask[i])) {
- if (i == 0) {
- _mesa_ColorMask(save->ColorMask[i][0], save->ColorMask[i][1],
- save->ColorMask[i][2], save->ColorMask[i][3]);
- }
- else {
- _mesa_ColorMaskIndexed(i,
- save->ColorMask[i][0],
- save->ColorMask[i][1],
- save->ColorMask[i][2],
- save->ColorMask[i][3]);
- }
- }
- }
- }
-
- if (state & META_DEPTH_TEST) {
- if (ctx->Depth.Test != save->Depth.Test)
- _mesa_set_enable(ctx, GL_DEPTH_TEST, save->Depth.Test);
- _mesa_DepthFunc(save->Depth.Func);
- _mesa_DepthMask(save->Depth.Mask);
- }
-
- if (state & META_FOG) {
- _mesa_set_enable(ctx, GL_FOG, save->Fog);
- }
-
- if (state & META_PIXEL_STORE) {
- ctx->Pack = save->Pack;
- ctx->Unpack = save->Unpack;
- }
-
- if (state & META_PIXEL_TRANSFER) {
- ctx->Pixel.RedScale = save->RedScale;
- ctx->Pixel.RedBias = save->RedBias;
- ctx->Pixel.GreenScale = save->GreenScale;
- ctx->Pixel.GreenBias = save->GreenBias;
- ctx->Pixel.BlueScale = save->BlueScale;
- ctx->Pixel.BlueBias = save->BlueBias;
- ctx->Pixel.AlphaScale = save->AlphaScale;
- ctx->Pixel.AlphaBias = save->AlphaBias;
- ctx->Pixel.MapColorFlag = save->MapColorFlag;
- /* XXX more state */
- ctx->NewState |=_NEW_PIXEL;
- }
-
- if (state & META_RASTERIZATION) {
- _mesa_PolygonMode(GL_FRONT, save->FrontPolygonMode);
- _mesa_PolygonMode(GL_BACK, save->BackPolygonMode);
- _mesa_set_enable(ctx, GL_POLYGON_STIPPLE, save->PolygonStipple);
- _mesa_set_enable(ctx, GL_POLYGON_OFFSET_FILL, save->PolygonOffset);
- _mesa_set_enable(ctx, GL_POLYGON_SMOOTH, save->PolygonSmooth);
- _mesa_set_enable(ctx, GL_CULL_FACE, save->PolygonCull);
- }
-
- if (state & META_SCISSOR) {
- _mesa_set_enable(ctx, GL_SCISSOR_TEST, save->Scissor.Enabled);
- _mesa_Scissor(save->Scissor.X, save->Scissor.Y,
- save->Scissor.Width, save->Scissor.Height);
- }
-
- if (state & META_SHADER) {
- if (ctx->Extensions.ARB_vertex_program) {
- _mesa_set_enable(ctx, GL_VERTEX_PROGRAM_ARB,
- save->VertexProgramEnabled);
- _mesa_reference_vertprog(ctx, &ctx->VertexProgram.Current,
- save->VertexProgram);
- _mesa_reference_vertprog(ctx, &save->VertexProgram, NULL);
- }
-
- if (ctx->Extensions.ARB_fragment_program) {
- _mesa_set_enable(ctx, GL_FRAGMENT_PROGRAM_ARB,
- save->FragmentProgramEnabled);
- _mesa_reference_fragprog(ctx, &ctx->FragmentProgram.Current,
- save->FragmentProgram);
- _mesa_reference_fragprog(ctx, &save->FragmentProgram, NULL);
- }
-
- if (ctx->Extensions.ARB_vertex_shader)
- _mesa_use_shader_program(ctx, GL_VERTEX_SHADER, save->VertexShader);
-
- if (ctx->Extensions.ARB_geometry_shader4)
- _mesa_use_shader_program(ctx, GL_GEOMETRY_SHADER_ARB,
- save->GeometryShader);
-
- if (ctx->Extensions.ARB_fragment_shader)
- _mesa_use_shader_program(ctx, GL_FRAGMENT_SHADER,
- save->FragmentShader);
-
- _mesa_reference_shader_program(ctx, &ctx->Shader.ActiveProgram,
- save->ActiveShader);
- }
-
- if (state & META_STENCIL_TEST) {
- const struct gl_stencil_attrib *stencil = &save->Stencil;
-
- _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]);
- }
-
- if (state & META_TEXTURE) {
- GLuint u, tgt;
-
- ASSERT(ctx->Texture.CurrentUnit == 0);
-
- /* restore texenv for unit[0] */
- _mesa_TexEnvi(GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, save->EnvMode);
-
- /* restore texture objects for unit[0] only */
- for (tgt = 0; tgt < NUM_TEXTURE_TARGETS; tgt++) {
- _mesa_reference_texobj(&ctx->Texture.Unit[0].CurrentTex[tgt],
- save->CurrentTexture[tgt]);
- _mesa_reference_texobj(&save->CurrentTexture[tgt], NULL);
- }
-
- /* Re-enable textures, texgen */
- for (u = 0; u < ctx->Const.MaxTextureUnits; u++) {
- if (save->TexEnabled[u]) {
- _mesa_ActiveTextureARB(GL_TEXTURE0 + u);
-
- if (save->TexEnabled[u] & TEXTURE_1D_BIT)
- _mesa_set_enable(ctx, GL_TEXTURE_1D, GL_TRUE);
- if (save->TexEnabled[u] & TEXTURE_2D_BIT)
- _mesa_set_enable(ctx, GL_TEXTURE_2D, GL_TRUE);
- if (save->TexEnabled[u] & TEXTURE_3D_BIT)
- _mesa_set_enable(ctx, GL_TEXTURE_3D, GL_TRUE);
- if (save->TexEnabled[u] & TEXTURE_CUBE_BIT)
- _mesa_set_enable(ctx, GL_TEXTURE_CUBE_MAP, GL_TRUE);
- if (save->TexEnabled[u] & TEXTURE_RECT_BIT)
- _mesa_set_enable(ctx, GL_TEXTURE_RECTANGLE, GL_TRUE);
- }
-
- if (save->TexGenEnabled[u]) {
- _mesa_ActiveTextureARB(GL_TEXTURE0 + u);
-
- if (save->TexGenEnabled[u] & S_BIT)
- _mesa_set_enable(ctx, GL_TEXTURE_GEN_S, GL_TRUE);
- if (save->TexGenEnabled[u] & T_BIT)
- _mesa_set_enable(ctx, GL_TEXTURE_GEN_T, GL_TRUE);
- if (save->TexGenEnabled[u] & R_BIT)
- _mesa_set_enable(ctx, GL_TEXTURE_GEN_R, GL_TRUE);
- if (save->TexGenEnabled[u] & Q_BIT)
- _mesa_set_enable(ctx, GL_TEXTURE_GEN_Q, GL_TRUE);
- }
- }
-
- /* restore current unit state */
- _mesa_ActiveTextureARB(GL_TEXTURE0 + save->ActiveUnit);
- _mesa_ClientActiveTextureARB(GL_TEXTURE0 + save->ClientActiveUnit);
- }
-
- if (state & META_TRANSFORM) {
- GLuint activeTexture = ctx->Texture.CurrentUnit;
- _mesa_ActiveTextureARB(GL_TEXTURE0);
- _mesa_MatrixMode(GL_TEXTURE);
- _mesa_LoadMatrixf(save->TextureMatrix);
- _mesa_ActiveTextureARB(GL_TEXTURE0 + activeTexture);
-
- _mesa_MatrixMode(GL_MODELVIEW);
- _mesa_LoadMatrixf(save->ModelviewMatrix);
-
- _mesa_MatrixMode(GL_PROJECTION);
- _mesa_LoadMatrixf(save->ProjectionMatrix);
-
- _mesa_MatrixMode(save->MatrixMode);
-
- if (save->ClipPlanesEnabled) {
- GLuint i;
- for (i = 0; i < ctx->Const.MaxClipPlanes; i++) {
- if (save->ClipPlanesEnabled & (1 << i)) {
- _mesa_set_enable(ctx, GL_CLIP_PLANE0 + i, GL_TRUE);
- }
- }
- }
- }
-
- if (state & META_VERTEX) {
- /* restore vertex buffer object */
- _mesa_BindBufferARB(GL_ARRAY_BUFFER_ARB, save->ArrayBufferObj->Name);
- _mesa_reference_buffer_object(ctx, &save->ArrayBufferObj, NULL);
-
- /* restore vertex array object */
- _mesa_BindVertexArray(save->ArrayObj->Name);
- _mesa_reference_array_object(ctx, &save->ArrayObj, NULL);
- }
-
- if (state & META_VIEWPORT) {
- if (save->ViewportX != ctx->Viewport.X ||
- save->ViewportY != ctx->Viewport.Y ||
- save->ViewportW != ctx->Viewport.Width ||
- save->ViewportH != ctx->Viewport.Height) {
- _mesa_set_viewport(ctx, save->ViewportX, save->ViewportY,
- save->ViewportW, save->ViewportH);
- }
- _mesa_DepthRange(save->DepthNear, save->DepthFar);
- }
-
- if (state & META_CLAMP_FRAGMENT_COLOR) {
- _mesa_ClampColorARB(GL_CLAMP_FRAGMENT_COLOR, save->ClampFragmentColor);
- }
-
- if (state & META_CLAMP_VERTEX_COLOR) {
- _mesa_ClampColorARB(GL_CLAMP_VERTEX_COLOR, save->ClampVertexColor);
- }
-
- if (state & META_CONDITIONAL_RENDER) {
- if (save->CondRenderQuery)
- _mesa_BeginConditionalRender(save->CondRenderQuery->Id,
- save->CondRenderMode);
- }
-
- /* misc */
- if (save->Lighting) {
- _mesa_set_enable(ctx, GL_LIGHTING, GL_TRUE);
- }
-}
-
-
-/**
- * Convert Z from a normalized value in the range [0, 1] to an object-space
- * Z coordinate in [-1, +1] so that drawing at the new Z position with the
- * default/identity ortho projection results in the original Z value.
- * Used by the meta-Clear, Draw/CopyPixels and Bitmap functions where the Z
- * value comes from the clear value or raster position.
- */
-static INLINE GLfloat
-invert_z(GLfloat normZ)
-{
- GLfloat objZ = 1.0 - 2.0 * normZ;
- return objZ;
-}
-
-
-/**
- * One-time init for a temp_texture object.
- * Choose tex target, compute max tex size, etc.
- */
-static void
-init_temp_texture(struct gl_context *ctx, struct temp_texture *tex)
-{
- /* prefer texture rectangle */
- if (ctx->Extensions.NV_texture_rectangle) {
- tex->Target = GL_TEXTURE_RECTANGLE;
- tex->MaxSize = ctx->Const.MaxTextureRectSize;
- tex->NPOT = GL_TRUE;
- }
- else {
- /* use 2D texture, NPOT if possible */
- tex->Target = GL_TEXTURE_2D;
- tex->MaxSize = 1 << (ctx->Const.MaxTextureLevels - 1);
- tex->NPOT = ctx->Extensions.ARB_texture_non_power_of_two;
- }
- tex->MinSize = 16; /* 16 x 16 at least */
- assert(tex->MaxSize > 0);
-
- _mesa_GenTextures(1, &tex->TexObj);
-}
-
-
-/**
- * Return pointer to temp_texture info for non-bitmap ops.
- * This does some one-time init if needed.
- */
-static struct temp_texture *
-get_temp_texture(struct gl_context *ctx)
-{
- struct temp_texture *tex = &ctx->Meta->TempTex;
-
- if (!tex->TexObj) {
- init_temp_texture(ctx, tex);
- }
-
- return tex;
-}
-
-
-/**
- * Return pointer to temp_texture info for _mesa_meta_bitmap().
- * We use a separate texture for bitmaps to reduce texture
- * allocation/deallocation.
- */
-static struct temp_texture *
-get_bitmap_temp_texture(struct gl_context *ctx)
-{
- struct temp_texture *tex = &ctx->Meta->Bitmap.Tex;
-
- if (!tex->TexObj) {
- init_temp_texture(ctx, tex);
- }
-
- return tex;
-}
-
-
-/**
- * Compute the width/height of texture needed to draw an image of the
- * given size. Return a flag indicating whether the current texture
- * can be re-used (glTexSubImage2D) or if a new texture needs to be
- * allocated (glTexImage2D).
- * Also, compute s/t texcoords for drawing.
- *
- * \return GL_TRUE if new texture is needed, GL_FALSE otherwise
- */
-static GLboolean
-alloc_texture(struct temp_texture *tex,
- GLsizei width, GLsizei height, GLenum intFormat)
-{
- GLboolean newTex = GL_FALSE;
-
- ASSERT(width <= tex->MaxSize);
- ASSERT(height <= tex->MaxSize);
-
- if (width > tex->Width ||
- height > tex->Height ||
- intFormat != tex->IntFormat) {
- /* alloc new texture (larger or different format) */
-
- if (tex->NPOT) {
- /* use non-power of two size */
- tex->Width = MAX2(tex->MinSize, width);
- tex->Height = MAX2(tex->MinSize, height);
- }
- else {
- /* find power of two size */
- GLsizei w, h;
- w = h = tex->MinSize;
- while (w < width)
- w *= 2;
- while (h < height)
- h *= 2;
- tex->Width = w;
- tex->Height = h;
- }
-
- tex->IntFormat = intFormat;
-
- newTex = GL_TRUE;
- }
-
- /* compute texcoords */
- if (tex->Target == GL_TEXTURE_RECTANGLE) {
- tex->Sright = (GLfloat) width;
- tex->Ttop = (GLfloat) height;
- }
- else {
- tex->Sright = (GLfloat) width / tex->Width;
- tex->Ttop = (GLfloat) height / tex->Height;
- }
-
- return newTex;
-}
-
-
-/**
- * Setup/load texture for glCopyPixels or glBlitFramebuffer.
- */
-static void
-setup_copypix_texture(struct temp_texture *tex,
- GLboolean newTex,
- GLint srcX, GLint srcY,
- GLsizei width, GLsizei height, GLenum intFormat,
- GLenum filter)
-{
- _mesa_BindTexture(tex->Target, tex->TexObj);
- _mesa_TexParameteri(tex->Target, GL_TEXTURE_MIN_FILTER, filter);
- _mesa_TexParameteri(tex->Target, GL_TEXTURE_MAG_FILTER, filter);
- _mesa_TexEnvi(GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_REPLACE);
-
- /* copy framebuffer image to texture */
- if (newTex) {
- /* create new tex image */
- if (tex->Width == width && tex->Height == height) {
- /* create new tex with framebuffer data */
- _mesa_CopyTexImage2D(tex->Target, 0, tex->IntFormat,
- srcX, srcY, width, height, 0);
- }
- else {
- /* create empty texture */
- _mesa_TexImage2D(tex->Target, 0, tex->IntFormat,
- tex->Width, tex->Height, 0,
- intFormat, GL_UNSIGNED_BYTE, NULL);
- /* load image */
- _mesa_CopyTexSubImage2D(tex->Target, 0,
- 0, 0, srcX, srcY, width, height);
- }
- }
- else {
- /* replace existing tex image */
- _mesa_CopyTexSubImage2D(tex->Target, 0,
- 0, 0, srcX, srcY, width, height);
- }
-}
-
-
-/**
- * Setup/load texture for glDrawPixels.
- */
-static void
-setup_drawpix_texture(struct gl_context *ctx,
- struct temp_texture *tex,
- GLboolean newTex,
- GLenum texIntFormat,
- GLsizei width, GLsizei height,
- GLenum format, GLenum type,
- const GLvoid *pixels)
-{
- _mesa_BindTexture(tex->Target, tex->TexObj);
- _mesa_TexParameteri(tex->Target, GL_TEXTURE_MIN_FILTER, GL_NEAREST);
- _mesa_TexParameteri(tex->Target, GL_TEXTURE_MAG_FILTER, GL_NEAREST);
- _mesa_TexEnvi(GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_REPLACE);
-
- /* copy pixel data to texture */
- if (newTex) {
- /* create new tex image */
- if (tex->Width == width && tex->Height == height) {
- /* create new tex and load image data */
- _mesa_TexImage2D(tex->Target, 0, tex->IntFormat,
- tex->Width, tex->Height, 0, format, type, pixels);
- }
- else {
- struct gl_buffer_object *save_unpack_obj = NULL;
-
- _mesa_reference_buffer_object(ctx, &save_unpack_obj,
- ctx->Unpack.BufferObj);
- _mesa_BindBufferARB(GL_PIXEL_UNPACK_BUFFER_ARB, 0);
- /* create empty texture */
- _mesa_TexImage2D(tex->Target, 0, tex->IntFormat,
- tex->Width, tex->Height, 0, format, type, NULL);
- if (save_unpack_obj != NULL)
- _mesa_BindBufferARB(GL_PIXEL_UNPACK_BUFFER_ARB,
- save_unpack_obj->Name);
- /* load image */
- _mesa_TexSubImage2D(tex->Target, 0,
- 0, 0, width, height, format, type, pixels);
- }
- }
- else {
- /* replace existing tex image */
- _mesa_TexSubImage2D(tex->Target, 0,
- 0, 0, width, height, format, type, pixels);
- }
-}
-
-
-
-/**
- * One-time init for drawing depth pixels.
- */
-static void
-init_blit_depth_pixels(struct gl_context *ctx)
-{
- static const char *program =
- "!!ARBfp1.0\n"
- "TEX result.depth, fragment.texcoord[0], texture[0], %s; \n"
- "END \n";
- char program2[200];
- struct blit_state *blit = &ctx->Meta->Blit;
- struct temp_texture *tex = get_temp_texture(ctx);
- const char *texTarget;
-
- assert(blit->DepthFP == 0);
-
- /* replace %s with "RECT" or "2D" */
- assert(strlen(program) + 4 < sizeof(program2));
- if (tex->Target == GL_TEXTURE_RECTANGLE)
- texTarget = "RECT";
- else
- texTarget = "2D";
- _mesa_snprintf(program2, sizeof(program2), program, texTarget);
-
- _mesa_GenPrograms(1, &blit->DepthFP);
- _mesa_BindProgram(GL_FRAGMENT_PROGRAM_ARB, blit->DepthFP);
- _mesa_ProgramStringARB(GL_FRAGMENT_PROGRAM_ARB, GL_PROGRAM_FORMAT_ASCII_ARB,
- strlen(program2), (const GLubyte *) program2);
-}
-
-
-/**
- * Try to do a glBlitFramebuffer using no-copy texturing.
- * We can do this when the src renderbuffer is actually a texture.
- * But if the src buffer == dst buffer we cannot do this.
- *
- * \return new buffer mask indicating the buffers left to blit using the
- * normal path.
- */
-static GLbitfield
-blitframebuffer_texture(struct gl_context *ctx,
- GLint srcX0, GLint srcY0, GLint srcX1, GLint srcY1,
- GLint dstX0, GLint dstY0, GLint dstX1, GLint dstY1,
- GLbitfield mask, GLenum filter)
-{
- if (mask & GL_COLOR_BUFFER_BIT) {
- const struct gl_framebuffer *drawFb = ctx->DrawBuffer;
- const struct gl_framebuffer *readFb = ctx->ReadBuffer;
- const struct gl_renderbuffer_attachment *drawAtt =
- &drawFb->Attachment[drawFb->_ColorDrawBufferIndexes[0]];
- const struct gl_renderbuffer_attachment *readAtt =
- &readFb->Attachment[readFb->_ColorReadBufferIndex];
-
- if (readAtt && readAtt->Texture) {
- const struct gl_texture_object *texObj = readAtt->Texture;
- const GLuint srcLevel = readAtt->TextureLevel;
- const GLenum minFilterSave = texObj->Sampler.MinFilter;
- const GLenum magFilterSave = texObj->Sampler.MagFilter;
- const GLint baseLevelSave = texObj->BaseLevel;
- const GLint maxLevelSave = texObj->MaxLevel;
- const GLenum wrapSSave = texObj->Sampler.WrapS;
- const GLenum wrapTSave = texObj->Sampler.WrapT;
- const GLenum target = texObj->Target;
-
- if (drawAtt->Texture == readAtt->Texture) {
- /* Can't use same texture as both the source and dest. We need
- * to handle overlapping blits and besides, some hw may not
- * support this.
- */
- return mask;
- }
-
- if (target != GL_TEXTURE_2D && target != GL_TEXTURE_RECTANGLE_ARB) {
- /* Can't handle other texture types at this time */
- return mask;
- }
-
- /*
- printf("Blit from texture!\n");
- printf(" srcAtt %p dstAtt %p\n", readAtt, drawAtt);
- printf(" srcTex %p dstText %p\n", texObj, drawAtt->Texture);
- */
-
- /* Prepare src texture state */
- _mesa_BindTexture(target, texObj->Name);
- _mesa_TexParameteri(target, GL_TEXTURE_MIN_FILTER, filter);
- _mesa_TexParameteri(target, GL_TEXTURE_MAG_FILTER, filter);
- if (target != GL_TEXTURE_RECTANGLE_ARB) {
- _mesa_TexParameteri(target, GL_TEXTURE_BASE_LEVEL, srcLevel);
- _mesa_TexParameteri(target, GL_TEXTURE_MAX_LEVEL, srcLevel);
- }
- _mesa_TexParameteri(target, GL_TEXTURE_WRAP_S, GL_CLAMP_TO_EDGE);
- _mesa_TexParameteri(target, GL_TEXTURE_WRAP_T, GL_CLAMP_TO_EDGE);
- _mesa_TexEnvi(GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_REPLACE);
- _mesa_set_enable(ctx, target, GL_TRUE);
-
- /* Prepare vertex data (the VBO was previously created and bound) */
- {
- struct vertex {
- GLfloat x, y, s, t;
- };
- struct vertex verts[4];
- GLfloat s0, t0, s1, t1;
-
- if (target == GL_TEXTURE_2D) {
- const struct gl_texture_image *texImage
- = _mesa_select_tex_image(ctx, texObj, target, srcLevel);
- s0 = srcX0 / (float) texImage->Width;
- s1 = srcX1 / (float) texImage->Width;
- t0 = srcY0 / (float) texImage->Height;
- t1 = srcY1 / (float) texImage->Height;
- }
- else {
- assert(target == GL_TEXTURE_RECTANGLE_ARB);
- s0 = srcX0;
- s1 = srcX1;
- t0 = srcY0;
- t1 = srcY1;
- }
-
- verts[0].x = (GLfloat) dstX0;
- verts[0].y = (GLfloat) dstY0;
- verts[1].x = (GLfloat) dstX1;
- verts[1].y = (GLfloat) dstY0;
- verts[2].x = (GLfloat) dstX1;
- verts[2].y = (GLfloat) dstY1;
- verts[3].x = (GLfloat) dstX0;
- verts[3].y = (GLfloat) dstY1;
-
- verts[0].s = s0;
- verts[0].t = t0;
- verts[1].s = s1;
- verts[1].t = t0;
- verts[2].s = s1;
- verts[2].t = t1;
- verts[3].s = s0;
- verts[3].t = t1;
-
- _mesa_BufferSubDataARB(GL_ARRAY_BUFFER_ARB, 0, sizeof(verts), verts);
- }
-
- _mesa_DrawArrays(GL_TRIANGLE_FAN, 0, 4);
-
- /* Restore texture object state, the texture binding will
- * be restored by _mesa_meta_end().
- */
- _mesa_TexParameteri(target, GL_TEXTURE_MIN_FILTER, minFilterSave);
- _mesa_TexParameteri(target, GL_TEXTURE_MAG_FILTER, magFilterSave);
- if (target != GL_TEXTURE_RECTANGLE_ARB) {
- _mesa_TexParameteri(target, GL_TEXTURE_BASE_LEVEL, baseLevelSave);
- _mesa_TexParameteri(target, GL_TEXTURE_MAX_LEVEL, maxLevelSave);
- }
- _mesa_TexParameteri(target, GL_TEXTURE_WRAP_S, wrapSSave);
- _mesa_TexParameteri(target, GL_TEXTURE_WRAP_T, wrapTSave);
-
- /* Done with color buffer */
- mask &= ~GL_COLOR_BUFFER_BIT;
- }
- }
-
- return mask;
-}
-
-
-/**
- * Meta implementation of ctx->Driver.BlitFramebuffer() in terms
- * of texture mapping and polygon rendering.
- */
-void
-_mesa_meta_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)
-{
- struct blit_state *blit = &ctx->Meta->Blit;
- struct temp_texture *tex = get_temp_texture(ctx);
- const GLsizei maxTexSize = tex->MaxSize;
- const GLint srcX = MIN2(srcX0, srcX1);
- const GLint srcY = MIN2(srcY0, srcY1);
- const GLint srcW = abs(srcX1 - srcX0);
- const GLint srcH = abs(srcY1 - srcY0);
- const GLboolean srcFlipX = srcX1 < srcX0;
- const GLboolean srcFlipY = srcY1 < srcY0;
- struct vertex {
- GLfloat x, y, s, t;
- };
- struct vertex verts[4];
- GLboolean newTex;
-
- if (srcW > maxTexSize || srcH > maxTexSize) {
- /* XXX avoid this fallback */
- _swrast_BlitFramebuffer(ctx, srcX0, srcY0, srcX1, srcY1,
- dstX0, dstY0, dstX1, dstY1, mask, filter);
- return;
- }
-
- if (srcFlipX) {
- GLint tmp = dstX0;
- dstX0 = dstX1;
- dstX1 = tmp;
- }
-
- if (srcFlipY) {
- GLint tmp = dstY0;
- dstY0 = dstY1;
- dstY1 = tmp;
- }
-
- /* only scissor effects blit so save/clear all other relevant state */
- _mesa_meta_begin(ctx, ~META_SCISSOR);
-
- if (blit->ArrayObj == 0) {
- /* one-time setup */
-
- /* create vertex array object */
- _mesa_GenVertexArrays(1, &blit->ArrayObj);
- _mesa_BindVertexArray(blit->ArrayObj);
-
- /* create vertex array buffer */
- _mesa_GenBuffersARB(1, &blit->VBO);
- _mesa_BindBufferARB(GL_ARRAY_BUFFER_ARB, blit->VBO);
- _mesa_BufferDataARB(GL_ARRAY_BUFFER_ARB, sizeof(verts),
- NULL, GL_DYNAMIC_DRAW_ARB);
-
- /* setup vertex arrays */
- _mesa_VertexPointer(2, GL_FLOAT, sizeof(struct vertex), OFFSET(x));
- _mesa_TexCoordPointer(2, GL_FLOAT, sizeof(struct vertex), OFFSET(s));
- _mesa_EnableClientState(GL_VERTEX_ARRAY);
- _mesa_EnableClientState(GL_TEXTURE_COORD_ARRAY);
- }
- else {
- _mesa_BindVertexArray(blit->ArrayObj);
- _mesa_BindBufferARB(GL_ARRAY_BUFFER_ARB, blit->VBO);
- }
-
- /* Try faster, direct texture approach first */
- mask = blitframebuffer_texture(ctx, srcX0, srcY0, srcX1, srcY1,
- dstX0, dstY0, dstX1, dstY1, mask, filter);
- if (mask == 0x0) {
- _mesa_meta_end(ctx);
- return;
- }
-
- /* Continue with "normal" approach which involves copying the src rect
- * into a temporary texture and is "blitted" by drawing a textured quad.
- */
-
- newTex = alloc_texture(tex, srcW, srcH, GL_RGBA);
-
- /* vertex positions/texcoords (after texture allocation!) */
- {
- verts[0].x = (GLfloat) dstX0;
- verts[0].y = (GLfloat) dstY0;
- verts[1].x = (GLfloat) dstX1;
- verts[1].y = (GLfloat) dstY0;
- verts[2].x = (GLfloat) dstX1;
- verts[2].y = (GLfloat) dstY1;
- verts[3].x = (GLfloat) dstX0;
- verts[3].y = (GLfloat) dstY1;
-
- verts[0].s = 0.0F;
- verts[0].t = 0.0F;
- verts[1].s = tex->Sright;
- verts[1].t = 0.0F;
- verts[2].s = tex->Sright;
- verts[2].t = tex->Ttop;
- verts[3].s = 0.0F;
- verts[3].t = tex->Ttop;
-
- /* upload new vertex data */
- _mesa_BufferSubDataARB(GL_ARRAY_BUFFER_ARB, 0, sizeof(verts), verts);
- }
-
- _mesa_set_enable(ctx, tex->Target, GL_TRUE);
-
- if (mask & GL_COLOR_BUFFER_BIT) {
- setup_copypix_texture(tex, newTex, srcX, srcY, srcW, srcH,
- GL_RGBA, filter);
- _mesa_DrawArrays(GL_TRIANGLE_FAN, 0, 4);
- mask &= ~GL_COLOR_BUFFER_BIT;
- }
-
- if (mask & GL_DEPTH_BUFFER_BIT) {
- GLuint *tmp = (GLuint *) malloc(srcW * srcH * sizeof(GLuint));
- if (tmp) {
- if (!blit->DepthFP)
- init_blit_depth_pixels(ctx);
-
- /* maybe change tex format here */
- newTex = alloc_texture(tex, srcW, srcH, GL_DEPTH_COMPONENT);
-
- _mesa_ReadPixels(srcX, srcY, srcW, srcH,
- GL_DEPTH_COMPONENT, GL_UNSIGNED_INT, tmp);
-
- setup_drawpix_texture(ctx, tex, newTex, GL_DEPTH_COMPONENT, srcW, srcH,
- GL_DEPTH_COMPONENT, GL_UNSIGNED_INT, tmp);
-
- _mesa_BindProgram(GL_FRAGMENT_PROGRAM_ARB, blit->DepthFP);
- _mesa_set_enable(ctx, GL_FRAGMENT_PROGRAM_ARB, GL_TRUE);
- _mesa_ColorMask(GL_FALSE, GL_FALSE, GL_FALSE, GL_FALSE);
- _mesa_set_enable(ctx, GL_DEPTH_TEST, GL_TRUE);
- _mesa_DepthFunc(GL_ALWAYS);
- _mesa_DepthMask(GL_TRUE);
-
- _mesa_DrawArrays(GL_TRIANGLE_FAN, 0, 4);
- mask &= ~GL_DEPTH_BUFFER_BIT;
-
- free(tmp);
- }
- }
-
- if (mask & GL_STENCIL_BUFFER_BIT) {
- /* XXX can't easily do stencil */
- }
-
- _mesa_set_enable(ctx, tex->Target, GL_FALSE);
-
- _mesa_meta_end(ctx);
-
- if (mask) {
- _swrast_BlitFramebuffer(ctx, srcX0, srcY0, srcX1, srcY1,
- dstX0, dstY0, dstX1, dstY1, mask, filter);
- }
-}
-
-
-/**
- * Meta implementation of ctx->Driver.Clear() in terms of polygon rendering.
- */
-void
-_mesa_meta_Clear(struct gl_context *ctx, GLbitfield buffers)
-{
- struct clear_state *clear = &ctx->Meta->Clear;
- struct vertex {
- GLfloat x, y, z, r, g, b, a;
- };
- struct vertex verts[4];
- /* save all state but scissor, pixel pack/unpack */
- GLbitfield metaSave = (META_ALL -
- META_SCISSOR -
- META_PIXEL_STORE -
- META_CONDITIONAL_RENDER);
- const GLuint stencilMax = (1 << ctx->DrawBuffer->Visual.stencilBits) - 1;
-
- if (buffers & BUFFER_BITS_COLOR) {
- /* if clearing color buffers, don't save/restore colormask */
- metaSave -= META_COLOR_MASK;
- }
-
- _mesa_meta_begin(ctx, metaSave);
-
- if (clear->ArrayObj == 0) {
- /* one-time setup */
-
- /* create vertex array object */
- _mesa_GenVertexArrays(1, &clear->ArrayObj);
- _mesa_BindVertexArray(clear->ArrayObj);
-
- /* create vertex array buffer */
- _mesa_GenBuffersARB(1, &clear->VBO);
- _mesa_BindBufferARB(GL_ARRAY_BUFFER_ARB, clear->VBO);
-
- /* setup vertex arrays */
- _mesa_VertexPointer(3, GL_FLOAT, sizeof(struct vertex), OFFSET(x));
- _mesa_ColorPointer(4, GL_FLOAT, sizeof(struct vertex), OFFSET(r));
- _mesa_EnableClientState(GL_VERTEX_ARRAY);
- _mesa_EnableClientState(GL_COLOR_ARRAY);
- }
- else {
- _mesa_BindVertexArray(clear->ArrayObj);
- _mesa_BindBufferARB(GL_ARRAY_BUFFER_ARB, clear->VBO);
- }
-
- /* GL_COLOR_BUFFER_BIT */
- if (buffers & BUFFER_BITS_COLOR) {
- /* leave colormask, glDrawBuffer state as-is */
-
- /* Clears never have the color clamped. */
- _mesa_ClampColorARB(GL_CLAMP_FRAGMENT_COLOR, GL_FALSE);
- }
- else {
- ASSERT(metaSave & META_COLOR_MASK);
- _mesa_ColorMask(GL_FALSE, GL_FALSE, GL_FALSE, GL_FALSE);
- }
-
- /* GL_DEPTH_BUFFER_BIT */
- if (buffers & BUFFER_BIT_DEPTH) {
- _mesa_set_enable(ctx, GL_DEPTH_TEST, GL_TRUE);
- _mesa_DepthFunc(GL_ALWAYS);
- _mesa_DepthMask(GL_TRUE);
- }
- else {
- assert(!ctx->Depth.Test);
- }
-
- /* GL_STENCIL_BUFFER_BIT */
- if (buffers & BUFFER_BIT_STENCIL) {
- _mesa_set_enable(ctx, GL_STENCIL_TEST, GL_TRUE);
- _mesa_StencilOpSeparate(GL_FRONT_AND_BACK,
- GL_REPLACE, GL_REPLACE, GL_REPLACE);
- _mesa_StencilFuncSeparate(GL_FRONT_AND_BACK, GL_ALWAYS,
- ctx->Stencil.Clear & stencilMax,
- ctx->Stencil.WriteMask[0]);
- }
- else {
- assert(!ctx->Stencil.Enabled);
- }
-
- /* vertex positions/colors */
- {
- const GLfloat x0 = (GLfloat) ctx->DrawBuffer->_Xmin;
- const GLfloat y0 = (GLfloat) ctx->DrawBuffer->_Ymin;
- const GLfloat x1 = (GLfloat) ctx->DrawBuffer->_Xmax;
- const GLfloat y1 = (GLfloat) ctx->DrawBuffer->_Ymax;
- const GLfloat z = invert_z(ctx->Depth.Clear);
- GLuint i;
-
- verts[0].x = x0;
- verts[0].y = y0;
- verts[0].z = z;
- verts[1].x = x1;
- verts[1].y = y0;
- verts[1].z = z;
- verts[2].x = x1;
- verts[2].y = y1;
- verts[2].z = z;
- verts[3].x = x0;
- verts[3].y = y1;
- verts[3].z = z;
-
- /* vertex colors */
- for (i = 0; i < 4; i++) {
- verts[i].r = ctx->Color.ClearColorUnclamped[0];
- verts[i].g = ctx->Color.ClearColorUnclamped[1];
- verts[i].b = ctx->Color.ClearColorUnclamped[2];
- verts[i].a = ctx->Color.ClearColorUnclamped[3];
- }
-
- /* upload new vertex data */
- _mesa_BufferDataARB(GL_ARRAY_BUFFER_ARB, sizeof(verts), verts,
- GL_DYNAMIC_DRAW_ARB);
- }
-
- /* draw quad */
- _mesa_DrawArrays(GL_TRIANGLE_FAN, 0, 4);
-
- _mesa_meta_end(ctx);
-}
-
-
-/**
- * Meta implementation of ctx->Driver.CopyPixels() in terms
- * of texture mapping and polygon rendering.
- */
-void
-_mesa_meta_CopyPixels(struct gl_context *ctx, GLint srcX, GLint srcY,
- GLsizei width, GLsizei height,
- GLint dstX, GLint dstY, GLenum type)
-{
- struct copypix_state *copypix = &ctx->Meta->CopyPix;
- struct temp_texture *tex = get_temp_texture(ctx);
- struct vertex {
- GLfloat x, y, z, s, t;
- };
- struct vertex verts[4];
- GLboolean newTex;
- GLenum intFormat = GL_RGBA;
-
- if (type != GL_COLOR ||
- ctx->_ImageTransferState ||
- ctx->Fog.Enabled ||
- width > tex->MaxSize ||
- height > tex->MaxSize) {
- /* XXX avoid this fallback */
- _swrast_CopyPixels(ctx, srcX, srcY, width, height, dstX, dstY, type);
- return;
- }
-
- /* Most GL state applies to glCopyPixels, but a there's a few things
- * we need to override:
- */
- _mesa_meta_begin(ctx, (META_RASTERIZATION |
- META_SHADER |
- META_TEXTURE |
- META_TRANSFORM |
- META_VERTEX |
- META_VIEWPORT));
-
- if (copypix->ArrayObj == 0) {
- /* one-time setup */
-
- /* create vertex array object */
- _mesa_GenVertexArrays(1, ©pix->ArrayObj);
- _mesa_BindVertexArray(copypix->ArrayObj);
-
- /* create vertex array buffer */
- _mesa_GenBuffersARB(1, ©pix->VBO);
- _mesa_BindBufferARB(GL_ARRAY_BUFFER_ARB, copypix->VBO);
- _mesa_BufferDataARB(GL_ARRAY_BUFFER_ARB, sizeof(verts),
- NULL, GL_DYNAMIC_DRAW_ARB);
-
- /* setup vertex arrays */
- _mesa_VertexPointer(3, GL_FLOAT, sizeof(struct vertex), OFFSET(x));
- _mesa_TexCoordPointer(2, GL_FLOAT, sizeof(struct vertex), OFFSET(s));
- _mesa_EnableClientState(GL_VERTEX_ARRAY);
- _mesa_EnableClientState(GL_TEXTURE_COORD_ARRAY);
- }
- else {
- _mesa_BindVertexArray(copypix->ArrayObj);
- _mesa_BindBufferARB(GL_ARRAY_BUFFER_ARB, copypix->VBO);
- }
-
- newTex = alloc_texture(tex, width, height, intFormat);
-
- /* vertex positions, texcoords (after texture allocation!) */
- {
- const GLfloat dstX0 = (GLfloat) dstX;
- const GLfloat dstY0 = (GLfloat) dstY;
- const GLfloat dstX1 = dstX + width * ctx->Pixel.ZoomX;
- const GLfloat dstY1 = dstY + height * ctx->Pixel.ZoomY;
- const GLfloat z = invert_z(ctx->Current.RasterPos[2]);
-
- verts[0].x = dstX0;
- verts[0].y = dstY0;
- verts[0].z = z;
- verts[0].s = 0.0F;
- verts[0].t = 0.0F;
- verts[1].x = dstX1;
- verts[1].y = dstY0;
- verts[1].z = z;
- verts[1].s = tex->Sright;
- verts[1].t = 0.0F;
- verts[2].x = dstX1;
- verts[2].y = dstY1;
- verts[2].z = z;
- verts[2].s = tex->Sright;
- verts[2].t = tex->Ttop;
- verts[3].x = dstX0;
- verts[3].y = dstY1;
- verts[3].z = z;
- verts[3].s = 0.0F;
- verts[3].t = tex->Ttop;
-
- /* upload new vertex data */
- _mesa_BufferSubDataARB(GL_ARRAY_BUFFER_ARB, 0, sizeof(verts), verts);
- }
-
- /* Alloc/setup texture */
- setup_copypix_texture(tex, newTex, srcX, srcY, width, height,
- GL_RGBA, GL_NEAREST);
-
- _mesa_set_enable(ctx, tex->Target, GL_TRUE);
-
- /* draw textured quad */
- _mesa_DrawArrays(GL_TRIANGLE_FAN, 0, 4);
-
- _mesa_set_enable(ctx, tex->Target, GL_FALSE);
-
- _mesa_meta_end(ctx);
-}
-
-
-
-/**
- * When the glDrawPixels() image size is greater than the max rectangle
- * texture size we use this function to break the glDrawPixels() image
- * into tiles which fit into the max texture size.
- */
-static void
-tiled_draw_pixels(struct gl_context *ctx,
- GLint tileSize,
- GLint x, GLint y, GLsizei width, GLsizei height,
- GLenum format, GLenum type,
- const struct gl_pixelstore_attrib *unpack,
- const GLvoid *pixels)
-{
- struct gl_pixelstore_attrib tileUnpack = *unpack;
- GLint i, j;
-
- if (tileUnpack.RowLength == 0)
- tileUnpack.RowLength = width;
-
- for (i = 0; i < width; i += tileSize) {
- const GLint tileWidth = MIN2(tileSize, width - i);
- const GLint tileX = (GLint) (x + i * ctx->Pixel.ZoomX);
-
- tileUnpack.SkipPixels = unpack->SkipPixels + i;
-
- for (j = 0; j < height; j += tileSize) {
- const GLint tileHeight = MIN2(tileSize, height - j);
- const GLint tileY = (GLint) (y + j * ctx->Pixel.ZoomY);
-
- tileUnpack.SkipRows = unpack->SkipRows + j;
-
- _mesa_meta_DrawPixels(ctx, tileX, tileY, tileWidth, tileHeight,
- format, type, &tileUnpack, pixels);
- }
- }
-}
-
-
-/**
- * One-time init for drawing stencil pixels.
- */
-static void
-init_draw_stencil_pixels(struct gl_context *ctx)
-{
- /* This program is run eight times, once for each stencil bit.
- * The stencil values to draw are found in an 8-bit alpha texture.
- * We read the texture/stencil value and test if bit 'b' is set.
- * If the bit is not set, use KIL to kill the fragment.
- * Finally, we use the stencil test to update the stencil buffer.
- *
- * The basic algorithm for checking if a bit is set is:
- * if (is_odd(value / (1 << bit)))
- * result is one (or non-zero).
- * else
- * result is zero.
- * The program parameter contains three values:
- * parm.x = 255 / (1 << bit)
- * parm.y = 0.5
- * parm.z = 0.0
- */
- static const char *program =
- "!!ARBfp1.0\n"
- "PARAM parm = program.local[0]; \n"
- "TEMP t; \n"
- "TEX t, fragment.texcoord[0], texture[0], %s; \n" /* NOTE %s here! */
- "# t = t * 255 / bit \n"
- "MUL t.x, t.a, parm.x; \n"
- "# t = (int) t \n"
- "FRC t.y, t.x; \n"
- "SUB t.x, t.x, t.y; \n"
- "# t = t * 0.5 \n"
- "MUL t.x, t.x, parm.y; \n"
- "# t = fract(t.x) \n"
- "FRC t.x, t.x; # if t.x != 0, then the bit is set \n"
- "# t.x = (t.x == 0 ? 1 : 0) \n"
- "SGE t.x, -t.x, parm.z; \n"
- "KIL -t.x; \n"
- "# for debug only \n"
- "#MOV result.color, t.x; \n"
- "END \n";
- char program2[1000];
- struct drawpix_state *drawpix = &ctx->Meta->DrawPix;
- struct temp_texture *tex = get_temp_texture(ctx);
- const char *texTarget;
-
- assert(drawpix->StencilFP == 0);
-
- /* replace %s with "RECT" or "2D" */
- assert(strlen(program) + 4 < sizeof(program2));
- if (tex->Target == GL_TEXTURE_RECTANGLE)
- texTarget = "RECT";
- else
- texTarget = "2D";
- _mesa_snprintf(program2, sizeof(program2), program, texTarget);
-
- _mesa_GenPrograms(1, &drawpix->StencilFP);
- _mesa_BindProgram(GL_FRAGMENT_PROGRAM_ARB, drawpix->StencilFP);
- _mesa_ProgramStringARB(GL_FRAGMENT_PROGRAM_ARB, GL_PROGRAM_FORMAT_ASCII_ARB,
- strlen(program2), (const GLubyte *) program2);
-}
-
-
-/**
- * One-time init for drawing depth pixels.
- */
-static void
-init_draw_depth_pixels(struct gl_context *ctx)
-{
- static const char *program =
- "!!ARBfp1.0\n"
- "PARAM color = program.local[0]; \n"
- "TEX result.depth, fragment.texcoord[0], texture[0], %s; \n"
- "MOV result.color, color; \n"
- "END \n";
- char program2[200];
- struct drawpix_state *drawpix = &ctx->Meta->DrawPix;
- struct temp_texture *tex = get_temp_texture(ctx);
- const char *texTarget;
-
- assert(drawpix->DepthFP == 0);
-
- /* replace %s with "RECT" or "2D" */
- assert(strlen(program) + 4 < sizeof(program2));
- if (tex->Target == GL_TEXTURE_RECTANGLE)
- texTarget = "RECT";
- else
- texTarget = "2D";
- _mesa_snprintf(program2, sizeof(program2), program, texTarget);
-
- _mesa_GenPrograms(1, &drawpix->DepthFP);
- _mesa_BindProgram(GL_FRAGMENT_PROGRAM_ARB, drawpix->DepthFP);
- _mesa_ProgramStringARB(GL_FRAGMENT_PROGRAM_ARB, GL_PROGRAM_FORMAT_ASCII_ARB,
- strlen(program2), (const GLubyte *) program2);
-}
-
-
-/**
- * Meta implementation of ctx->Driver.DrawPixels() in terms
- * of texture mapping and polygon rendering.
- */
-void
-_mesa_meta_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)
-{
- struct drawpix_state *drawpix = &ctx->Meta->DrawPix;
- struct temp_texture *tex = get_temp_texture(ctx);
- const struct gl_pixelstore_attrib unpackSave = ctx->Unpack;
- const GLuint origStencilMask = ctx->Stencil.WriteMask[0];
- struct vertex {
- GLfloat x, y, z, s, t;
- };
- struct vertex verts[4];
- GLenum texIntFormat;
- GLboolean fallback, newTex;
- GLbitfield metaExtraSave = 0x0;
- GLuint vbo;
-
- /*
- * Determine if we can do the glDrawPixels with texture mapping.
- */
- fallback = GL_FALSE;
- if (ctx->_ImageTransferState ||
- ctx->Fog.Enabled) {
- fallback = GL_TRUE;
- }
-
- if (_mesa_is_color_format(format)) {
- /* use more compact format when possible */
- /* XXX disable special case for GL_LUMINANCE for now to work around
- * apparent i965 driver bug (see bug #23670).
- */
- if (/*format == GL_LUMINANCE ||*/ format == GL_LUMINANCE_ALPHA)
- texIntFormat = format;
- else
- texIntFormat = GL_RGBA;
-
- /* If we're not supposed to clamp the resulting color, then just
- * promote our texture to fully float. We could do better by
- * just going for the matching set of channels, in floating
- * point.
- */
- if (ctx->Color.ClampFragmentColor != GL_TRUE &&
- ctx->Extensions.ARB_texture_float)
- texIntFormat = GL_RGBA32F;
- }
- else if (_mesa_is_stencil_format(format)) {
- if (ctx->Extensions.ARB_fragment_program &&
- ctx->Pixel.IndexShift == 0 &&
- ctx->Pixel.IndexOffset == 0 &&
- type == GL_UNSIGNED_BYTE) {
- /* We'll store stencil as alpha. This only works for GLubyte
- * image data because of how incoming values are mapped to alpha
- * in [0,1].
- */
- texIntFormat = GL_ALPHA;
- metaExtraSave = (META_COLOR_MASK |
- META_DEPTH_TEST |
- META_SHADER |
- META_STENCIL_TEST);
- }
- else {
- fallback = GL_TRUE;
- }
- }
- else if (_mesa_is_depth_format(format)) {
- if (ctx->Extensions.ARB_depth_texture &&
- ctx->Extensions.ARB_fragment_program) {
- texIntFormat = GL_DEPTH_COMPONENT;
- metaExtraSave = (META_SHADER);
- }
- else {
- fallback = GL_TRUE;
- }
- }
- else {
- fallback = GL_TRUE;
- }
-
- if (fallback) {
- _swrast_DrawPixels(ctx, x, y, width, height,
- format, type, unpack, pixels);
- return;
- }
-
- /*
- * Check image size against max texture size, draw as tiles if needed.
- */
- if (width > tex->MaxSize || height > tex->MaxSize) {
- tiled_draw_pixels(ctx, tex->MaxSize, x, y, width, height,
- format, type, unpack, pixels);
- return;
- }
-
- /* Most GL state applies to glDrawPixels (like blending, stencil, etc),
- * but a there's a few things we need to override:
- */
- _mesa_meta_begin(ctx, (META_RASTERIZATION |
- META_SHADER |
- META_TEXTURE |
- META_TRANSFORM |
- META_VERTEX |
- META_VIEWPORT |
- META_CLAMP_FRAGMENT_COLOR |
- metaExtraSave));
-
- newTex = alloc_texture(tex, width, height, texIntFormat);
-
- /* vertex positions, texcoords (after texture allocation!) */
- {
- const GLfloat x0 = (GLfloat) x;
- const GLfloat y0 = (GLfloat) y;
- const GLfloat x1 = x + width * ctx->Pixel.ZoomX;
- const GLfloat y1 = y + height * ctx->Pixel.ZoomY;
- const GLfloat z = invert_z(ctx->Current.RasterPos[2]);
-
- verts[0].x = x0;
- verts[0].y = y0;
- verts[0].z = z;
- verts[0].s = 0.0F;
- verts[0].t = 0.0F;
- verts[1].x = x1;
- verts[1].y = y0;
- verts[1].z = z;
- verts[1].s = tex->Sright;
- verts[1].t = 0.0F;
- verts[2].x = x1;
- verts[2].y = y1;
- verts[2].z = z;
- verts[2].s = tex->Sright;
- verts[2].t = tex->Ttop;
- verts[3].x = x0;
- verts[3].y = y1;
- verts[3].z = z;
- verts[3].s = 0.0F;
- verts[3].t = tex->Ttop;
- }
-
- if (drawpix->ArrayObj == 0) {
- /* one-time setup: create vertex array object */
- _mesa_GenVertexArrays(1, &drawpix->ArrayObj);
- }
- _mesa_BindVertexArray(drawpix->ArrayObj);
-
- /* create vertex array buffer */
- _mesa_GenBuffersARB(1, &vbo);
- _mesa_BindBufferARB(GL_ARRAY_BUFFER_ARB, vbo);
- _mesa_BufferDataARB(GL_ARRAY_BUFFER_ARB, sizeof(verts),
- verts, GL_DYNAMIC_DRAW_ARB);
-
- /* setup vertex arrays */
- _mesa_VertexPointer(3, GL_FLOAT, sizeof(struct vertex), OFFSET(x));
- _mesa_TexCoordPointer(2, GL_FLOAT, sizeof(struct vertex), OFFSET(s));
- _mesa_EnableClientState(GL_VERTEX_ARRAY);
- _mesa_EnableClientState(GL_TEXTURE_COORD_ARRAY);
-
- /* set given unpack params */
- ctx->Unpack = *unpack;
-
- _mesa_set_enable(ctx, tex->Target, GL_TRUE);
-
- if (_mesa_is_stencil_format(format)) {
- /* Drawing stencil */
- GLint bit;
-
- if (!drawpix->StencilFP)
- init_draw_stencil_pixels(ctx);
-
- setup_drawpix_texture(ctx, tex, newTex, texIntFormat, width, height,
- GL_ALPHA, type, pixels);
-
- _mesa_ColorMask(GL_FALSE, GL_FALSE, GL_FALSE, GL_FALSE);
-
- _mesa_set_enable(ctx, GL_STENCIL_TEST, GL_TRUE);
-
- /* set all stencil bits to 0 */
- _mesa_StencilOp(GL_REPLACE, GL_REPLACE, GL_REPLACE);
- _mesa_StencilFunc(GL_ALWAYS, 0, 255);
- _mesa_DrawArrays(GL_TRIANGLE_FAN, 0, 4);
-
- /* set stencil bits to 1 where needed */
- _mesa_StencilOp(GL_KEEP, GL_KEEP, GL_REPLACE);
-
- _mesa_BindProgram(GL_FRAGMENT_PROGRAM_ARB, drawpix->StencilFP);
- _mesa_set_enable(ctx, GL_FRAGMENT_PROGRAM_ARB, GL_TRUE);
-
- for (bit = 0; bit < ctx->DrawBuffer->Visual.stencilBits; bit++) {
- const GLuint mask = 1 << bit;
- if (mask & origStencilMask) {
- _mesa_StencilFunc(GL_ALWAYS, mask, mask);
- _mesa_StencilMask(mask);
-
- _mesa_ProgramLocalParameter4fARB(GL_FRAGMENT_PROGRAM_ARB, 0,
- 255.0 / mask, 0.5, 0.0, 0.0);
-
- _mesa_DrawArrays(GL_TRIANGLE_FAN, 0, 4);
- }
- }
- }
- else if (_mesa_is_depth_format(format)) {
- /* Drawing depth */
- if (!drawpix->DepthFP)
- init_draw_depth_pixels(ctx);
-
- _mesa_BindProgram(GL_FRAGMENT_PROGRAM_ARB, drawpix->DepthFP);
- _mesa_set_enable(ctx, GL_FRAGMENT_PROGRAM_ARB, GL_TRUE);
-
- /* polygon color = current raster color */
- _mesa_ProgramLocalParameter4fvARB(GL_FRAGMENT_PROGRAM_ARB, 0,
- ctx->Current.RasterColor);
-
- setup_drawpix_texture(ctx, tex, newTex, texIntFormat, width, height,
- format, type, pixels);
-
- _mesa_DrawArrays(GL_TRIANGLE_FAN, 0, 4);
- }
- else {
- /* Drawing RGBA */
- setup_drawpix_texture(ctx, tex, newTex, texIntFormat, width, height,
- format, type, pixels);
- _mesa_DrawArrays(GL_TRIANGLE_FAN, 0, 4);
- }
-
- _mesa_set_enable(ctx, tex->Target, GL_FALSE);
-
- _mesa_DeleteBuffersARB(1, &vbo);
-
- /* restore unpack params */
- ctx->Unpack = unpackSave;
-
- _mesa_meta_end(ctx);
-}
-
-static GLboolean
-alpha_test_raster_color(struct gl_context *ctx)
-{
- GLfloat alpha = ctx->Current.RasterColor[ACOMP];
- GLfloat ref = ctx->Color.AlphaRef;
-
- switch (ctx->Color.AlphaFunc) {
- case GL_NEVER:
- return GL_FALSE;
- case GL_LESS:
- return alpha < ref;
- case GL_EQUAL:
- return alpha == ref;
- case GL_LEQUAL:
- return alpha <= ref;
- case GL_GREATER:
- return alpha > ref;
- case GL_NOTEQUAL:
- return alpha != ref;
- case GL_GEQUAL:
- return alpha >= ref;
- case GL_ALWAYS:
- return GL_TRUE;
- default:
- assert(0);
- return GL_FALSE;
- }
-}
-
-/**
- * Do glBitmap with a alpha texture quad. Use the alpha test to cull
- * the 'off' bits. A bitmap cache as in the gallium/mesa state
- * tracker would improve performance a lot.
- */
-void
-_mesa_meta_Bitmap(struct gl_context *ctx,
- GLint x, GLint y, GLsizei width, GLsizei height,
- const struct gl_pixelstore_attrib *unpack,
- const GLubyte *bitmap1)
-{
- struct bitmap_state *bitmap = &ctx->Meta->Bitmap;
- struct temp_texture *tex = get_bitmap_temp_texture(ctx);
- const GLenum texIntFormat = GL_ALPHA;
- const struct gl_pixelstore_attrib unpackSave = *unpack;
- GLubyte fg, bg;
- struct vertex {
- GLfloat x, y, z, s, t, r, g, b, a;
- };
- struct vertex verts[4];
- GLboolean newTex;
- GLubyte *bitmap8;
-
- /*
- * Check if swrast fallback is needed.
- */
- if (ctx->_ImageTransferState ||
- ctx->FragmentProgram._Enabled ||
- ctx->Fog.Enabled ||
- ctx->Texture._EnabledUnits ||
- width > tex->MaxSize ||
- height > tex->MaxSize) {
- _swrast_Bitmap(ctx, x, y, width, height, unpack, bitmap1);
- return;
- }
-
- if (ctx->Color.AlphaEnabled && !alpha_test_raster_color(ctx))
- return;
-
- /* Most GL state applies to glBitmap (like blending, stencil, etc),
- * but a there's a few things we need to override:
- */
- _mesa_meta_begin(ctx, (META_ALPHA_TEST |
- META_PIXEL_STORE |
- META_RASTERIZATION |
- META_SHADER |
- META_TEXTURE |
- META_TRANSFORM |
- META_VERTEX |
- META_VIEWPORT));
-
- if (bitmap->ArrayObj == 0) {
- /* one-time setup */
-
- /* create vertex array object */
- _mesa_GenVertexArraysAPPLE(1, &bitmap->ArrayObj);
- _mesa_BindVertexArrayAPPLE(bitmap->ArrayObj);
-
- /* create vertex array buffer */
- _mesa_GenBuffersARB(1, &bitmap->VBO);
- _mesa_BindBufferARB(GL_ARRAY_BUFFER_ARB, bitmap->VBO);
- _mesa_BufferDataARB(GL_ARRAY_BUFFER_ARB, sizeof(verts),
- NULL, GL_DYNAMIC_DRAW_ARB);
-
- /* setup vertex arrays */
- _mesa_VertexPointer(3, GL_FLOAT, sizeof(struct vertex), OFFSET(x));
- _mesa_TexCoordPointer(2, GL_FLOAT, sizeof(struct vertex), OFFSET(s));
- _mesa_ColorPointer(4, GL_FLOAT, sizeof(struct vertex), OFFSET(r));
- _mesa_EnableClientState(GL_VERTEX_ARRAY);
- _mesa_EnableClientState(GL_TEXTURE_COORD_ARRAY);
- _mesa_EnableClientState(GL_COLOR_ARRAY);
- }
- else {
- _mesa_BindVertexArray(bitmap->ArrayObj);
- _mesa_BindBufferARB(GL_ARRAY_BUFFER_ARB, bitmap->VBO);
- }
-
- newTex = alloc_texture(tex, width, height, texIntFormat);
-
- /* vertex positions, texcoords, colors (after texture allocation!) */
- {
- const GLfloat x0 = (GLfloat) x;
- const GLfloat y0 = (GLfloat) y;
- const GLfloat x1 = (GLfloat) (x + width);
- const GLfloat y1 = (GLfloat) (y + height);
- const GLfloat z = invert_z(ctx->Current.RasterPos[2]);
- GLuint i;
-
- verts[0].x = x0;
- verts[0].y = y0;
- verts[0].z = z;
- verts[0].s = 0.0F;
- verts[0].t = 0.0F;
- verts[1].x = x1;
- verts[1].y = y0;
- verts[1].z = z;
- verts[1].s = tex->Sright;
- verts[1].t = 0.0F;
- verts[2].x = x1;
- verts[2].y = y1;
- verts[2].z = z;
- verts[2].s = tex->Sright;
- verts[2].t = tex->Ttop;
- verts[3].x = x0;
- verts[3].y = y1;
- verts[3].z = z;
- verts[3].s = 0.0F;
- verts[3].t = tex->Ttop;
-
- for (i = 0; i < 4; i++) {
- verts[i].r = ctx->Current.RasterColor[0];
- verts[i].g = ctx->Current.RasterColor[1];
- verts[i].b = ctx->Current.RasterColor[2];
- verts[i].a = ctx->Current.RasterColor[3];
- }
-
- /* upload new vertex data */
- _mesa_BufferSubDataARB(GL_ARRAY_BUFFER_ARB, 0, sizeof(verts), verts);
- }
-
- /* choose different foreground/background alpha values */
- CLAMPED_FLOAT_TO_UBYTE(fg, ctx->Current.RasterColor[ACOMP]);
- bg = (fg > 127 ? 0 : 255);
-
- bitmap1 = _mesa_map_pbo_source(ctx, &unpackSave, bitmap1);
- if (!bitmap1) {
- _mesa_meta_end(ctx);
- return;
- }
-
- bitmap8 = (GLubyte *) malloc(width * height);
- if (bitmap8) {
- memset(bitmap8, bg, width * height);
- _mesa_expand_bitmap(width, height, &unpackSave, bitmap1,
- bitmap8, width, fg);
-
- _mesa_set_enable(ctx, tex->Target, GL_TRUE);
-
- _mesa_set_enable(ctx, GL_ALPHA_TEST, GL_TRUE);
- _mesa_AlphaFunc(GL_NOTEQUAL, UBYTE_TO_FLOAT(bg));
-
- setup_drawpix_texture(ctx, tex, newTex, texIntFormat, width, height,
- GL_ALPHA, GL_UNSIGNED_BYTE, bitmap8);
-
- _mesa_DrawArrays(GL_TRIANGLE_FAN, 0, 4);
-
- _mesa_set_enable(ctx, tex->Target, GL_FALSE);
-
- free(bitmap8);
- }
-
- _mesa_unmap_pbo_source(ctx, &unpackSave);
-
- _mesa_meta_end(ctx);
-}
-
-
-/**
- * Check if the call to _mesa_meta_GenerateMipmap() will require a
- * software fallback. The fallback path will require that the texture
- * images are mapped.
- * \return GL_TRUE if a fallback is needed, GL_FALSE otherwise
- */
-GLboolean
-_mesa_meta_check_generate_mipmap_fallback(struct gl_context *ctx, GLenum target,
- struct gl_texture_object *texObj)
-{
- const GLuint fboSave = ctx->DrawBuffer->Name;
- struct gen_mipmap_state *mipmap = &ctx->Meta->Mipmap;
- struct gl_texture_image *baseImage;
- GLuint srcLevel;
- GLenum status;
-
- /* check for fallbacks */
- if (!ctx->Extensions.EXT_framebuffer_object ||
- target == GL_TEXTURE_3D) {
- return GL_TRUE;
- }
-
- srcLevel = texObj->BaseLevel;
- baseImage = _mesa_select_tex_image(ctx, texObj, target, srcLevel);
- if (!baseImage || _mesa_is_format_compressed(baseImage->TexFormat)) {
- return GL_TRUE;
- }
-
- /*
- * Test that we can actually render in the texture's format.
- */
- if (!mipmap->FBO)
- _mesa_GenFramebuffersEXT(1, &mipmap->FBO);
- _mesa_BindFramebufferEXT(GL_FRAMEBUFFER_EXT, mipmap->FBO);
-
- if (target == GL_TEXTURE_1D) {
- _mesa_FramebufferTexture1DEXT(GL_FRAMEBUFFER_EXT,
- GL_COLOR_ATTACHMENT0_EXT,
- target, texObj->Name, srcLevel);
- }
-#if 0
- /* other work is needed to enable 3D mipmap generation */
- else if (target == GL_TEXTURE_3D) {
- GLint zoffset = 0;
- _mesa_FramebufferTexture3DEXT(GL_FRAMEBUFFER_EXT,
- GL_COLOR_ATTACHMENT0_EXT,
- target, texObj->Name, srcLevel, zoffset);
- }
-#endif
- else {
- /* 2D / cube */
- _mesa_FramebufferTexture2DEXT(GL_FRAMEBUFFER_EXT,
- GL_COLOR_ATTACHMENT0_EXT,
- target, texObj->Name, srcLevel);
- }
-
- status = _mesa_CheckFramebufferStatusEXT(GL_FRAMEBUFFER_EXT);
-
- _mesa_BindFramebufferEXT(GL_FRAMEBUFFER_EXT, fboSave);
-
- if (status != GL_FRAMEBUFFER_COMPLETE_EXT) {
- return GL_TRUE;
- }
-
- return GL_FALSE;
-}
-
-
-/**
- * Called via ctx->Driver.GenerateMipmap()
- * Note: texture borders and 3D texture support not yet complete.
- */
-void
-_mesa_meta_GenerateMipmap(struct gl_context *ctx, GLenum target,
- struct gl_texture_object *texObj)
-{
- struct gen_mipmap_state *mipmap = &ctx->Meta->Mipmap;
- struct vertex {
- GLfloat x, y, s, t, r;
- };
- struct vertex verts[4];
- const GLuint baseLevel = texObj->BaseLevel;
- const GLuint maxLevel = texObj->MaxLevel;
- const GLenum minFilterSave = texObj->Sampler.MinFilter;
- const GLenum magFilterSave = texObj->Sampler.MagFilter;
- const GLint maxLevelSave = texObj->MaxLevel;
- const GLboolean genMipmapSave = texObj->GenerateMipmap;
- const GLenum wrapSSave = texObj->Sampler.WrapS;
- const GLenum wrapTSave = texObj->Sampler.WrapT;
- const GLenum wrapRSave = texObj->Sampler.WrapR;
- const GLuint fboSave = ctx->DrawBuffer->Name;
- const GLuint original_active_unit = ctx->Texture.CurrentUnit;
- GLenum faceTarget;
- GLuint dstLevel;
- GLuint border = 0;
-
- if (_mesa_meta_check_generate_mipmap_fallback(ctx, target, texObj)) {
- _mesa_generate_mipmap(ctx, target, texObj);
- return;
- }
-
- if (target >= GL_TEXTURE_CUBE_MAP_POSITIVE_X &&
- target <= GL_TEXTURE_CUBE_MAP_NEGATIVE_Z) {
- faceTarget = target;
- target = GL_TEXTURE_CUBE_MAP;
- }
- else {
- faceTarget = target;
- }
-
- _mesa_meta_begin(ctx, META_ALL);
-
- if (original_active_unit != 0)
- _mesa_BindTexture(target, texObj->Name);
-
- if (mipmap->ArrayObj == 0) {
- /* one-time setup */
-
- /* create vertex array object */
- _mesa_GenVertexArraysAPPLE(1, &mipmap->ArrayObj);
- _mesa_BindVertexArrayAPPLE(mipmap->ArrayObj);
-
- /* create vertex array buffer */
- _mesa_GenBuffersARB(1, &mipmap->VBO);
- _mesa_BindBufferARB(GL_ARRAY_BUFFER_ARB, mipmap->VBO);
- _mesa_BufferDataARB(GL_ARRAY_BUFFER_ARB, sizeof(verts),
- NULL, GL_DYNAMIC_DRAW_ARB);
-
- /* setup vertex arrays */
- _mesa_VertexPointer(2, GL_FLOAT, sizeof(struct vertex), OFFSET(x));
- _mesa_TexCoordPointer(3, GL_FLOAT, sizeof(struct vertex), OFFSET(s));
- _mesa_EnableClientState(GL_VERTEX_ARRAY);
- _mesa_EnableClientState(GL_TEXTURE_COORD_ARRAY);
- }
- else {
- _mesa_BindVertexArray(mipmap->ArrayObj);
- _mesa_BindBufferARB(GL_ARRAY_BUFFER_ARB, mipmap->VBO);
- }
-
- if (!mipmap->FBO) {
- _mesa_GenFramebuffersEXT(1, &mipmap->FBO);
- }
- _mesa_BindFramebufferEXT(GL_FRAMEBUFFER_EXT, mipmap->FBO);
-
- _mesa_TexParameteri(target, GL_TEXTURE_MIN_FILTER, GL_LINEAR_MIPMAP_LINEAR);
- _mesa_TexParameteri(target, GL_TEXTURE_MAG_FILTER, GL_LINEAR);
- _mesa_TexParameteri(target, GL_GENERATE_MIPMAP, GL_FALSE);
- _mesa_TexParameteri(target, GL_TEXTURE_WRAP_S, GL_CLAMP_TO_EDGE);
- _mesa_TexParameteri(target, GL_TEXTURE_WRAP_T, GL_CLAMP_TO_EDGE);
- _mesa_TexParameteri(target, GL_TEXTURE_WRAP_R, GL_CLAMP_TO_EDGE);
-
- _mesa_set_enable(ctx, target, GL_TRUE);
-
- /* setup texcoords once (XXX what about border?) */
- switch (faceTarget) {
- case GL_TEXTURE_1D:
- case GL_TEXTURE_2D:
- verts[0].s = 0.0F;
- verts[0].t = 0.0F;
- verts[0].r = 0.0F;
- verts[1].s = 1.0F;
- verts[1].t = 0.0F;
- verts[1].r = 0.0F;
- verts[2].s = 1.0F;
- verts[2].t = 1.0F;
- verts[2].r = 0.0F;
- verts[3].s = 0.0F;
- verts[3].t = 1.0F;
- verts[3].r = 0.0F;
- break;
- case GL_TEXTURE_3D:
- abort();
- break;
- default:
- /* cube face */
- {
- static const GLfloat st[4][2] = {
- {0.0f, 0.0f}, {1.0f, 0.0f}, {1.0f, 1.0f}, {0.0f, 1.0f}
- };
- GLuint i;
-
- /* loop over quad verts */
- for (i = 0; i < 4; i++) {
- /* Compute sc = +/-scale and tc = +/-scale.
- * Not +/-1 to avoid cube face selection ambiguity near the edges,
- * though that can still sometimes happen with this scale factor...
- */
- const GLfloat scale = 0.9999f;
- const GLfloat sc = (2.0f * st[i][0] - 1.0f) * scale;
- const GLfloat tc = (2.0f * st[i][1] - 1.0f) * scale;
-
- switch (faceTarget) {
- case GL_TEXTURE_CUBE_MAP_POSITIVE_X:
- verts[i].s = 1.0f;
- verts[i].t = -tc;
- verts[i].r = -sc;
- break;
- case GL_TEXTURE_CUBE_MAP_NEGATIVE_X:
- verts[i].s = -1.0f;
- verts[i].t = -tc;
- verts[i].r = sc;
- break;
- case GL_TEXTURE_CUBE_MAP_POSITIVE_Y:
- verts[i].s = sc;
- verts[i].t = 1.0f;
- verts[i].r = tc;
- break;
- case GL_TEXTURE_CUBE_MAP_NEGATIVE_Y:
- verts[i].s = sc;
- verts[i].t = -1.0f;
- verts[i].r = -tc;
- break;
- case GL_TEXTURE_CUBE_MAP_POSITIVE_Z:
- verts[i].s = sc;
- verts[i].t = -tc;
- verts[i].r = 1.0f;
- break;
- case GL_TEXTURE_CUBE_MAP_NEGATIVE_Z:
- verts[i].s = -sc;
- verts[i].t = -tc;
- verts[i].r = -1.0f;
- break;
- default:
- assert(0);
- }
- }
- }
- }
-
- _mesa_set_enable(ctx, target, GL_TRUE);
-
- /* setup vertex positions */
- {
- verts[0].x = 0.0F;
- verts[0].y = 0.0F;
- verts[1].x = 1.0F;
- verts[1].y = 0.0F;
- verts[2].x = 1.0F;
- verts[2].y = 1.0F;
- verts[3].x = 0.0F;
- verts[3].y = 1.0F;
-
- /* upload new vertex data */
- _mesa_BufferSubDataARB(GL_ARRAY_BUFFER_ARB, 0, sizeof(verts), verts);
- }
-
- /* setup projection matrix */
- _mesa_MatrixMode(GL_PROJECTION);
- _mesa_LoadIdentity();
- _mesa_Ortho(0.0, 1.0, 0.0, 1.0, -1.0, 1.0);
-
- /* texture is already locked, unlock now */
- _mesa_unlock_texture(ctx, texObj);
-
- for (dstLevel = baseLevel + 1; dstLevel <= maxLevel; dstLevel++) {
- const struct gl_texture_image *srcImage;
- const GLuint srcLevel = dstLevel - 1;
- GLsizei srcWidth, srcHeight, srcDepth;
- GLsizei dstWidth, dstHeight, dstDepth;
- GLenum status;
-
- srcImage = _mesa_select_tex_image(ctx, texObj, faceTarget, srcLevel);
- assert(srcImage->Border == 0); /* XXX we can fix this */
-
- /* src size w/out border */
- srcWidth = srcImage->Width - 2 * border;
- srcHeight = srcImage->Height - 2 * border;
- srcDepth = srcImage->Depth - 2 * border;
-
- /* new dst size w/ border */
- dstWidth = MAX2(1, srcWidth / 2) + 2 * border;
- dstHeight = MAX2(1, srcHeight / 2) + 2 * border;
- dstDepth = MAX2(1, srcDepth / 2) + 2 * border;
-
- if (dstWidth == srcImage->Width &&
- dstHeight == srcImage->Height &&
- dstDepth == srcImage->Depth) {
- /* all done */
- break;
- }
-
- /* Set MaxLevel large enough to hold the new level when we allocate it */
- _mesa_TexParameteri(target, GL_TEXTURE_MAX_LEVEL, dstLevel);
-
- /* Create empty dest image */
- if (target == GL_TEXTURE_1D) {
- _mesa_TexImage1D(target, dstLevel, srcImage->InternalFormat,
- dstWidth, border,
- GL_RGBA, GL_UNSIGNED_BYTE, NULL);
- }
- else if (target == GL_TEXTURE_3D) {
- _mesa_TexImage3D(target, dstLevel, srcImage->InternalFormat,
- dstWidth, dstHeight, dstDepth, border,
- GL_RGBA, GL_UNSIGNED_BYTE, NULL);
- }
- else {
- /* 2D or cube */
- _mesa_TexImage2D(faceTarget, dstLevel, srcImage->InternalFormat,
- dstWidth, dstHeight, border,
- GL_RGBA, GL_UNSIGNED_BYTE, NULL);
-
- if (target == GL_TEXTURE_CUBE_MAP) {
- /* If texturing from a cube, we need to make sure all src faces
- * have been defined (even if we're not sampling from them.)
- * Otherwise the texture object will be 'incomplete' and
- * texturing from it will not be allowed.
- */
- GLuint face;
- for (face = 0; face < 6; face++) {
- if (!texObj->Image[face][srcLevel] ||
- texObj->Image[face][srcLevel]->Width != srcWidth) {
- _mesa_TexImage2D(GL_TEXTURE_CUBE_MAP_POSITIVE_X + face,
- srcLevel, srcImage->InternalFormat,
- srcWidth, srcHeight, border,
- GL_RGBA, GL_UNSIGNED_BYTE, NULL);
- }
- }
- }
- }
-
- /* limit minification to src level */
- _mesa_TexParameteri(target, GL_TEXTURE_MAX_LEVEL, srcLevel);
-
- /* Set to draw into the current dstLevel */
- if (target == GL_TEXTURE_1D) {
- _mesa_FramebufferTexture1DEXT(GL_FRAMEBUFFER_EXT,
- GL_COLOR_ATTACHMENT0_EXT,
- target,
- texObj->Name,
- dstLevel);
- }
- else if (target == GL_TEXTURE_3D) {
- GLint zoffset = 0; /* XXX unfinished */
- _mesa_FramebufferTexture3DEXT(GL_FRAMEBUFFER_EXT,
- GL_COLOR_ATTACHMENT0_EXT,
- target,
- texObj->Name,
- dstLevel, zoffset);
- }
- else {
- /* 2D / cube */
- _mesa_FramebufferTexture2DEXT(GL_FRAMEBUFFER_EXT,
- GL_COLOR_ATTACHMENT0_EXT,
- faceTarget,
- texObj->Name,
- dstLevel);
- }
-
- _mesa_DrawBuffer(GL_COLOR_ATTACHMENT0_EXT);
-
- /* sanity check */
- status = _mesa_CheckFramebufferStatusEXT(GL_FRAMEBUFFER_EXT);
- if (status != GL_FRAMEBUFFER_COMPLETE_EXT) {
- abort();
- break;
- }
-
- assert(dstWidth == ctx->DrawBuffer->Width);
- assert(dstHeight == ctx->DrawBuffer->Height);
-
- /* setup viewport */
- _mesa_set_viewport(ctx, 0, 0, dstWidth, dstHeight);
-
- _mesa_DrawArrays(GL_TRIANGLE_FAN, 0, 4);
- }
-
- _mesa_lock_texture(ctx, texObj); /* relock */
-
- _mesa_meta_end(ctx);
-
- _mesa_TexParameteri(target, GL_TEXTURE_MIN_FILTER, minFilterSave);
- _mesa_TexParameteri(target, GL_TEXTURE_MAG_FILTER, magFilterSave);
- _mesa_TexParameteri(target, GL_TEXTURE_MAX_LEVEL, maxLevelSave);
- _mesa_TexParameteri(target, GL_GENERATE_MIPMAP, genMipmapSave);
- _mesa_TexParameteri(target, GL_TEXTURE_WRAP_S, wrapSSave);
- _mesa_TexParameteri(target, GL_TEXTURE_WRAP_T, wrapTSave);
- _mesa_TexParameteri(target, GL_TEXTURE_WRAP_R, wrapRSave);
-
- _mesa_BindFramebufferEXT(GL_FRAMEBUFFER_EXT, fboSave);
-}
-
-
-/**
- * Determine the GL data type to use for the temporary image read with
- * ReadPixels() and passed to Tex[Sub]Image().
- */
-static GLenum
-get_temp_image_type(struct gl_context *ctx, GLenum baseFormat)
-{
- switch (baseFormat) {
- case GL_RGBA:
- case GL_RGB:
- case GL_ALPHA:
- case GL_LUMINANCE:
- case GL_LUMINANCE_ALPHA:
- case GL_INTENSITY:
- if (ctx->DrawBuffer->Visual.redBits <= 8)
- return GL_UNSIGNED_BYTE;
- else if (ctx->DrawBuffer->Visual.redBits <= 8)
- return GL_UNSIGNED_SHORT;
- else
- return GL_FLOAT;
- case GL_DEPTH_COMPONENT:
- return GL_UNSIGNED_INT;
- case GL_DEPTH_STENCIL:
- return GL_UNSIGNED_INT_24_8;
- default:
- _mesa_problem(ctx, "Unexpected format in get_temp_image_type()");
- return 0;
- }
-}
-
-
-/**
- * Helper for _mesa_meta_CopyTexImage1/2D() functions.
- * Have to be careful with locking and meta state for pixel transfer.
- */
-static void
-copy_tex_image(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;
- GLenum format, type;
- GLint bpp;
- void *buf;
-
- texObj = _mesa_get_current_tex_object(ctx, target);
- texImage = _mesa_get_tex_image(ctx, texObj, target, level);
-
- /* Choose format/type for temporary image buffer */
- format = _mesa_base_tex_format(ctx, internalFormat);
- type = get_temp_image_type(ctx, format);
- bpp = _mesa_bytes_per_pixel(format, type);
- if (bpp <= 0) {
- _mesa_problem(ctx, "Bad bpp in meta copy_tex_image()");
- return;
- }
-
- /*
- * Alloc image buffer (XXX could use a PBO)
- */
- buf = malloc(width * height * bpp);
- if (!buf) {
- _mesa_error(ctx, GL_OUT_OF_MEMORY, "glCopyTexImage%uD", dims);
- return;
- }
-
- _mesa_unlock_texture(ctx, texObj); /* need to unlock first */
-
- /*
- * Read image from framebuffer (disable pixel transfer ops)
- */
- _mesa_meta_begin(ctx, META_PIXEL_STORE | META_PIXEL_TRANSFER);
- ctx->Driver.ReadPixels(ctx, x, y, width, height,
- format, type, &ctx->Pack, buf);
- _mesa_meta_end(ctx);
-
- if (texImage->Data) {
- ctx->Driver.FreeTexImageData(ctx, texImage);
- }
-
- /* The texture's format was already chosen in _mesa_CopyTexImage() */
- ASSERT(texImage->TexFormat != MESA_FORMAT_NONE);
-
- /*
- * Store texture data (with pixel transfer ops)
- */
- _mesa_meta_begin(ctx, META_PIXEL_STORE);
-
- _mesa_update_state(ctx); /* to update pixel transfer state */
-
- if (target == GL_TEXTURE_1D) {
- ctx->Driver.TexImage1D(ctx, target, level, internalFormat,
- width, border, format, type,
- buf, &ctx->Unpack, texObj, texImage);
- }
- else {
- ctx->Driver.TexImage2D(ctx, target, level, internalFormat,
- width, height, border, format, type,
- buf, &ctx->Unpack, texObj, texImage);
- }
- _mesa_meta_end(ctx);
-
- _mesa_lock_texture(ctx, texObj); /* re-lock */
-
- free(buf);
-}
-
-
-void
-_mesa_meta_CopyTexImage1D(struct gl_context *ctx, GLenum target, GLint level,
- GLenum internalFormat, GLint x, GLint y,
- GLsizei width, GLint border)
-{
- copy_tex_image(ctx, 1, target, level, internalFormat, x, y,
- width, 1, border);
-}
-
-
-void
-_mesa_meta_CopyTexImage2D(struct gl_context *ctx, GLenum target, GLint level,
- GLenum internalFormat, GLint x, GLint y,
- GLsizei width, GLsizei height, GLint border)
-{
- copy_tex_image(ctx, 2, target, level, internalFormat, x, y,
- width, height, border);
-}
-
-
-
-/**
- * Helper for _mesa_meta_CopyTexSubImage1/2/3D() functions.
- * Have to be careful with locking and meta state for pixel transfer.
- */
-static void
-copy_tex_sub_image(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;
- GLenum format, type;
- GLint bpp;
- void *buf;
-
- texObj = _mesa_get_current_tex_object(ctx, target);
- texImage = _mesa_select_tex_image(ctx, texObj, target, level);
-
- /* Choose format/type for temporary image buffer */
- format = _mesa_get_format_base_format(texImage->TexFormat);
- type = get_temp_image_type(ctx, format);
- bpp = _mesa_bytes_per_pixel(format, type);
- if (bpp <= 0) {
- _mesa_problem(ctx, "Bad bpp in meta copy_tex_sub_image()");
- return;
- }
-
- /*
- * Alloc image buffer (XXX could use a PBO)
- */
- buf = malloc(width * height * bpp);
- if (!buf) {
- _mesa_error(ctx, GL_OUT_OF_MEMORY, "glCopyTexSubImage%uD", dims);
- return;
- }
-
- _mesa_unlock_texture(ctx, texObj); /* need to unlock first */
-
- /*
- * Read image from framebuffer (disable pixel transfer ops)
- */
- _mesa_meta_begin(ctx, META_PIXEL_STORE | META_PIXEL_TRANSFER);
- ctx->Driver.ReadPixels(ctx, x, y, width, height,
- format, type, &ctx->Pack, buf);
- _mesa_meta_end(ctx);
-
- _mesa_update_state(ctx); /* to update pixel transfer state */
-
- /*
- * Store texture data (with pixel transfer ops)
- */
- _mesa_meta_begin(ctx, META_PIXEL_STORE);
- if (target == GL_TEXTURE_1D) {
- ctx->Driver.TexSubImage1D(ctx, target, level, xoffset,
- width, format, type, buf,
- &ctx->Unpack, texObj, texImage);
- }
- else if (target == GL_TEXTURE_3D) {
- ctx->Driver.TexSubImage3D(ctx, target, level, xoffset, yoffset, zoffset,
- width, height, 1, format, type, buf,
- &ctx->Unpack, texObj, texImage);
- }
- else {
- ctx->Driver.TexSubImage2D(ctx, target, level, xoffset, yoffset,
- width, height, format, type, buf,
- &ctx->Unpack, texObj, texImage);
- }
- _mesa_meta_end(ctx);
-
- _mesa_lock_texture(ctx, texObj); /* re-lock */
-
- free(buf);
-}
-
-
-void
-_mesa_meta_CopyTexSubImage1D(struct gl_context *ctx, GLenum target, GLint level,
- GLint xoffset,
- GLint x, GLint y, GLsizei width)
-{
- copy_tex_sub_image(ctx, 1, target, level, xoffset, 0, 0,
- x, y, width, 1);
-}
-
-
-void
-_mesa_meta_CopyTexSubImage2D(struct gl_context *ctx, GLenum target, GLint level,
- GLint xoffset, GLint yoffset,
- GLint x, GLint y,
- GLsizei width, GLsizei height)
-{
- copy_tex_sub_image(ctx, 2, target, level, xoffset, yoffset, 0,
- x, y, width, height);
-}
-
-
-void
-_mesa_meta_CopyTexSubImage3D(struct gl_context *ctx, GLenum target, GLint level,
- GLint xoffset, GLint yoffset, GLint zoffset,
- GLint x, GLint y,
- GLsizei width, GLsizei height)
-{
- copy_tex_sub_image(ctx, 3, target, level, xoffset, yoffset, zoffset,
- x, y, width, height);
-}
-
-
-void
-_mesa_meta_CopyColorTable(struct gl_context *ctx,
- GLenum target, GLenum internalformat,
- GLint x, GLint y, GLsizei width)
-{
- GLfloat *buf;
-
- buf = (GLfloat *) malloc(width * 4 * sizeof(GLfloat));
- if (!buf) {
- _mesa_error(ctx, GL_OUT_OF_MEMORY, "glCopyColorTable");
- return;
- }
-
- /*
- * Read image from framebuffer (disable pixel transfer ops)
- */
- _mesa_meta_begin(ctx, META_PIXEL_STORE | META_PIXEL_TRANSFER);
- ctx->Driver.ReadPixels(ctx, x, y, width, 1,
- GL_RGBA, GL_FLOAT, &ctx->Pack, buf);
-
- _mesa_ColorTable(target, internalformat, width, GL_RGBA, GL_FLOAT, buf);
-
- _mesa_meta_end(ctx);
-
- free(buf);
-}
-
-
-void
-_mesa_meta_CopyColorSubTable(struct gl_context *ctx,GLenum target, GLsizei start,
- GLint x, GLint y, GLsizei width)
-{
- GLfloat *buf;
-
- buf = (GLfloat *) malloc(width * 4 * sizeof(GLfloat));
- if (!buf) {
- _mesa_error(ctx, GL_OUT_OF_MEMORY, "glCopyColorSubTable");
- return;
- }
-
- /*
- * Read image from framebuffer (disable pixel transfer ops)
- */
- _mesa_meta_begin(ctx, META_PIXEL_STORE | META_PIXEL_TRANSFER);
- ctx->Driver.ReadPixels(ctx, x, y, width, 1,
- GL_RGBA, GL_FLOAT, &ctx->Pack, buf);
-
- _mesa_ColorSubTable(target, start, width, GL_RGBA, GL_FLOAT, buf);
-
- _mesa_meta_end(ctx);
-
- free(buf);
-}
+/* + * Mesa 3-D graphics library + * Version: 7.6 + * + * 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. + */ + +/** + * Meta operations. Some GL operations can be expressed in terms of + * other GL operations. For example, glBlitFramebuffer() can be done + * with texture mapping and glClear() can be done with polygon rendering. + * + * \author Brian Paul + */ + + +#include "main/glheader.h" +#include "main/mtypes.h" +#include "main/imports.h" +#include "main/arbprogram.h" +#include "main/arrayobj.h" +#include "main/blend.h" +#include "main/bufferobj.h" +#include "main/buffers.h" +#include "main/colortab.h" +#include "main/condrender.h" +#include "main/depth.h" +#include "main/enable.h" +#include "main/fbobject.h" +#include "main/formats.h" +#include "main/image.h" +#include "main/macros.h" +#include "main/matrix.h" +#include "main/mipmap.h" +#include "main/pbo.h" +#include "main/polygon.h" +#include "main/readpix.h" +#include "main/scissor.h" +#include "main/shaderapi.h" +#include "main/shaderobj.h" +#include "main/state.h" +#include "main/stencil.h" +#include "main/texobj.h" +#include "main/texenv.h" +#include "main/teximage.h" +#include "main/texparam.h" +#include "main/texstate.h" +#include "main/varray.h" +#include "main/viewport.h" +#include "program/program.h" +#include "swrast/swrast.h" +#include "drivers/common/meta.h" + + +/** Return offset in bytes of the field within a vertex struct */ +#define OFFSET(FIELD) ((void *) offsetof(struct vertex, FIELD)) + + +/** + * Flags passed to _mesa_meta_begin(). + */ +/*@{*/ +#define META_ALL ~0x0 +#define META_ALPHA_TEST 0x1 +#define META_BLEND 0x2 /**< includes logicop */ +#define META_COLOR_MASK 0x4 +#define META_DEPTH_TEST 0x8 +#define META_FOG 0x10 +#define META_PIXEL_STORE 0x20 +#define META_PIXEL_TRANSFER 0x40 +#define META_RASTERIZATION 0x80 +#define META_SCISSOR 0x100 +#define META_SHADER 0x200 +#define META_STENCIL_TEST 0x400 +#define META_TRANSFORM 0x800 /**< modelview, projection, clip planes */ +#define META_TEXTURE 0x1000 +#define META_VERTEX 0x2000 +#define META_VIEWPORT 0x4000 +#define META_CLAMP_FRAGMENT_COLOR 0x8000 +#define META_CLAMP_VERTEX_COLOR 0x10000 +#define META_CONDITIONAL_RENDER 0x20000 +/*@}*/ + + +/** + * State which we may save/restore across meta ops. + * XXX this may be incomplete... + */ +struct save_state +{ + GLbitfield SavedState; /**< bitmask of META_* flags */ + + /** META_ALPHA_TEST */ + GLboolean AlphaEnabled; + GLenum AlphaFunc; + GLclampf AlphaRef; + + /** META_BLEND */ + GLbitfield BlendEnabled; + GLboolean ColorLogicOpEnabled; + + /** META_COLOR_MASK */ + GLubyte ColorMask[MAX_DRAW_BUFFERS][4]; + + /** META_DEPTH_TEST */ + struct gl_depthbuffer_attrib Depth; + + /** META_FOG */ + GLboolean Fog; + + /** META_PIXEL_STORE */ + struct gl_pixelstore_attrib Pack, Unpack; + + /** META_PIXEL_TRANSFER */ + GLfloat RedBias, RedScale; + GLfloat GreenBias, GreenScale; + GLfloat BlueBias, BlueScale; + GLfloat AlphaBias, AlphaScale; + GLfloat DepthBias, DepthScale; + GLboolean MapColorFlag; + + /** META_RASTERIZATION */ + GLenum FrontPolygonMode, BackPolygonMode; + GLboolean PolygonOffset; + GLboolean PolygonSmooth; + GLboolean PolygonStipple; + GLboolean PolygonCull; + + /** META_SCISSOR */ + struct gl_scissor_attrib Scissor; + + /** META_SHADER */ + GLboolean VertexProgramEnabled; + struct gl_vertex_program *VertexProgram; + GLboolean FragmentProgramEnabled; + struct gl_fragment_program *FragmentProgram; + struct gl_shader_program *VertexShader; + struct gl_shader_program *GeometryShader; + struct gl_shader_program *FragmentShader; + struct gl_shader_program *ActiveShader; + + /** META_STENCIL_TEST */ + struct gl_stencil_attrib Stencil; + + /** META_TRANSFORM */ + GLenum MatrixMode; + GLfloat ModelviewMatrix[16]; + GLfloat ProjectionMatrix[16]; + GLfloat TextureMatrix[16]; + GLbitfield ClipPlanesEnabled; + + /** META_TEXTURE */ + GLuint ActiveUnit; + GLuint ClientActiveUnit; + /** for unit[0] only */ + struct gl_texture_object *CurrentTexture[NUM_TEXTURE_TARGETS]; + /** mask of TEXTURE_2D_BIT, etc */ + GLbitfield TexEnabled[MAX_TEXTURE_UNITS]; + GLbitfield TexGenEnabled[MAX_TEXTURE_UNITS]; + GLuint EnvMode; /* unit[0] only */ + + /** META_VERTEX */ + struct gl_array_object *ArrayObj; + struct gl_buffer_object *ArrayBufferObj; + + /** META_VIEWPORT */ + GLint ViewportX, ViewportY, ViewportW, ViewportH; + GLclampd DepthNear, DepthFar; + + /** META_CLAMP_FRAGMENT_COLOR */ + GLenum ClampFragmentColor; + + /** META_CLAMP_VERTEX_COLOR */ + GLenum ClampVertexColor; + + /** META_CONDITIONAL_RENDER */ + struct gl_query_object *CondRenderQuery; + GLenum CondRenderMode; + + /** Miscellaneous (always disabled) */ + GLboolean Lighting; +}; + + +/** + * Temporary texture used for glBlitFramebuffer, glDrawPixels, etc. + * This is currently shared by all the meta ops. But we could create a + * separate one for each of glDrawPixel, glBlitFramebuffer, glCopyPixels, etc. + */ +struct temp_texture +{ + GLuint TexObj; + GLenum Target; /**< GL_TEXTURE_2D or GL_TEXTURE_RECTANGLE */ + GLsizei MinSize; /**< Min texture size to allocate */ + GLsizei MaxSize; /**< Max possible texture size */ + GLboolean NPOT; /**< Non-power of two size OK? */ + GLsizei Width, Height; /**< Current texture size */ + GLenum IntFormat; + GLfloat Sright, Ttop; /**< right, top texcoords */ +}; + + +/** + * State for glBlitFramebufer() + */ +struct blit_state +{ + GLuint ArrayObj; + GLuint VBO; + GLuint DepthFP; +}; + + +/** + * State for glClear() + */ +struct clear_state +{ + GLuint ArrayObj; + GLuint VBO; +}; + + +/** + * State for glCopyPixels() + */ +struct copypix_state +{ + GLuint ArrayObj; + GLuint VBO; +}; + + +/** + * State for glDrawPixels() + */ +struct drawpix_state +{ + GLuint ArrayObj; + + GLuint StencilFP; /**< Fragment program for drawing stencil images */ + GLuint DepthFP; /**< Fragment program for drawing depth images */ +}; + + +/** + * State for glBitmap() + */ +struct bitmap_state +{ + GLuint ArrayObj; + GLuint VBO; + struct temp_texture Tex; /**< separate texture from other meta ops */ +}; + + +/** + * State for _mesa_meta_generate_mipmap() + */ +struct gen_mipmap_state +{ + GLuint ArrayObj; + GLuint VBO; + GLuint FBO; +}; + +#define MAX_META_OPS_DEPTH 2 +/** + * All per-context meta state. + */ +struct gl_meta_state +{ + /** Stack of state saved during meta-ops */ + struct save_state Save[MAX_META_OPS_DEPTH]; + /** Save stack depth */ + GLuint SaveStackDepth; + + struct temp_texture TempTex; + + struct blit_state Blit; /**< For _mesa_meta_BlitFramebuffer() */ + struct clear_state Clear; /**< For _mesa_meta_Clear() */ + struct copypix_state CopyPix; /**< For _mesa_meta_CopyPixels() */ + struct drawpix_state DrawPix; /**< For _mesa_meta_DrawPixels() */ + struct bitmap_state Bitmap; /**< For _mesa_meta_Bitmap() */ + struct gen_mipmap_state Mipmap; /**< For _mesa_meta_GenerateMipmap() */ +}; + + +/** + * Initialize meta-ops for a context. + * To be called once during context creation. + */ +void +_mesa_meta_init(struct gl_context *ctx) +{ + ASSERT(!ctx->Meta); + + ctx->Meta = CALLOC_STRUCT(gl_meta_state); +} + + +/** + * Free context meta-op state. + * To be called once during context destruction. + */ +void +_mesa_meta_free(struct gl_context *ctx) +{ + /* Note: Any textures, VBOs, etc, that we allocate should get + * freed by the normal context destruction code. But this would be + * the place to free other meta data someday. + */ + free(ctx->Meta); + ctx->Meta = NULL; +} + + +/** + * Enter meta state. This is like a light-weight version of glPushAttrib + * but it also resets most GL state back to default values. + * + * \param state bitmask of META_* flags indicating which attribute groups + * to save and reset to their defaults + */ +static void +_mesa_meta_begin(struct gl_context *ctx, GLbitfield state) +{ + struct save_state *save; + + /* hope MAX_META_OPS_DEPTH is large enough */ + assert(ctx->Meta->SaveStackDepth < MAX_META_OPS_DEPTH); + + save = &ctx->Meta->Save[ctx->Meta->SaveStackDepth++]; + memset(save, 0, sizeof(*save)); + save->SavedState = state; + + if (state & META_ALPHA_TEST) { + save->AlphaEnabled = ctx->Color.AlphaEnabled; + save->AlphaFunc = ctx->Color.AlphaFunc; + save->AlphaRef = ctx->Color.AlphaRef; + if (ctx->Color.AlphaEnabled) + _mesa_set_enable(ctx, GL_ALPHA_TEST, GL_FALSE); + } + + if (state & META_BLEND) { + save->BlendEnabled = ctx->Color.BlendEnabled; + if (ctx->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, GL_FALSE); + } + } + else { + _mesa_set_enable(ctx, GL_BLEND, GL_FALSE); + } + } + save->ColorLogicOpEnabled = ctx->Color.ColorLogicOpEnabled; + if (ctx->Color.ColorLogicOpEnabled) + _mesa_set_enable(ctx, GL_COLOR_LOGIC_OP, GL_FALSE); + } + + if (state & META_COLOR_MASK) { + memcpy(save->ColorMask, ctx->Color.ColorMask, + sizeof(ctx->Color.ColorMask)); + if (!ctx->Color.ColorMask[0][0] || + !ctx->Color.ColorMask[0][1] || + !ctx->Color.ColorMask[0][2] || + !ctx->Color.ColorMask[0][3]) + _mesa_ColorMask(GL_TRUE, GL_TRUE, GL_TRUE, GL_TRUE); + } + + if (state & META_DEPTH_TEST) { + save->Depth = ctx->Depth; /* struct copy */ + if (ctx->Depth.Test) + _mesa_set_enable(ctx, GL_DEPTH_TEST, GL_FALSE); + } + + if (state & META_FOG) { + save->Fog = ctx->Fog.Enabled; + if (ctx->Fog.Enabled) + _mesa_set_enable(ctx, GL_FOG, GL_FALSE); + } + + if (state & META_PIXEL_STORE) { + save->Pack = ctx->Pack; + save->Unpack = ctx->Unpack; + ctx->Pack = ctx->DefaultPacking; + ctx->Unpack = ctx->DefaultPacking; + } + + if (state & META_PIXEL_TRANSFER) { + save->RedScale = ctx->Pixel.RedScale; + save->RedBias = ctx->Pixel.RedBias; + save->GreenScale = ctx->Pixel.GreenScale; + save->GreenBias = ctx->Pixel.GreenBias; + save->BlueScale = ctx->Pixel.BlueScale; + save->BlueBias = ctx->Pixel.BlueBias; + save->AlphaScale = ctx->Pixel.AlphaScale; + save->AlphaBias = ctx->Pixel.AlphaBias; + save->MapColorFlag = ctx->Pixel.MapColorFlag; + 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; + ctx->Pixel.MapColorFlag = GL_FALSE; + /* XXX more state */ + ctx->NewState |=_NEW_PIXEL; + } + + if (state & META_RASTERIZATION) { + save->FrontPolygonMode = ctx->Polygon.FrontMode; + save->BackPolygonMode = ctx->Polygon.BackMode; + save->PolygonOffset = ctx->Polygon.OffsetFill; + save->PolygonSmooth = ctx->Polygon.SmoothFlag; + save->PolygonStipple = ctx->Polygon.StippleFlag; + save->PolygonCull = ctx->Polygon.CullFlag; + _mesa_PolygonMode(GL_FRONT_AND_BACK, GL_FILL); + _mesa_set_enable(ctx, GL_POLYGON_OFFSET_FILL, GL_FALSE); + _mesa_set_enable(ctx, GL_POLYGON_SMOOTH, GL_FALSE); + _mesa_set_enable(ctx, GL_POLYGON_STIPPLE, GL_FALSE); + _mesa_set_enable(ctx, GL_CULL_FACE, GL_FALSE); + } + + if (state & META_SCISSOR) { + save->Scissor = ctx->Scissor; /* struct copy */ + _mesa_set_enable(ctx, GL_SCISSOR_TEST, GL_FALSE); + } + + if (state & META_SHADER) { + if (ctx->Extensions.ARB_vertex_program) { + save->VertexProgramEnabled = ctx->VertexProgram.Enabled; + _mesa_reference_vertprog(ctx, &save->VertexProgram, + ctx->VertexProgram.Current); + _mesa_set_enable(ctx, GL_VERTEX_PROGRAM_ARB, GL_FALSE); + } + + if (ctx->Extensions.ARB_fragment_program) { + save->FragmentProgramEnabled = ctx->FragmentProgram.Enabled; + _mesa_reference_fragprog(ctx, &save->FragmentProgram, + ctx->FragmentProgram.Current); + _mesa_set_enable(ctx, GL_FRAGMENT_PROGRAM_ARB, GL_FALSE); + } + + if (ctx->Extensions.ARB_shader_objects) { + _mesa_reference_shader_program(ctx, &save->VertexShader, + ctx->Shader.CurrentVertexProgram); + _mesa_reference_shader_program(ctx, &save->GeometryShader, + ctx->Shader.CurrentGeometryProgram); + _mesa_reference_shader_program(ctx, &save->FragmentShader, + ctx->Shader.CurrentFragmentProgram); + _mesa_reference_shader_program(ctx, &save->ActiveShader, + ctx->Shader.CurrentFragmentProgram); + + _mesa_UseProgramObjectARB(0); + } + } + + if (state & META_STENCIL_TEST) { + save->Stencil = ctx->Stencil; /* struct copy */ + if (ctx->Stencil.Enabled) + _mesa_set_enable(ctx, GL_STENCIL_TEST, GL_FALSE); + /* NOTE: other stencil state not reset */ + } + + if (state & META_TEXTURE) { + GLuint u, tgt; + + save->ActiveUnit = ctx->Texture.CurrentUnit; + save->ClientActiveUnit = ctx->Array.ActiveTexture; + save->EnvMode = ctx->Texture.Unit[0].EnvMode; + + /* Disable all texture units */ + for (u = 0; u < ctx->Const.MaxTextureUnits; u++) { + save->TexEnabled[u] = ctx->Texture.Unit[u].Enabled; + save->TexGenEnabled[u] = ctx->Texture.Unit[u].TexGenEnabled; + if (ctx->Texture.Unit[u].Enabled || + ctx->Texture.Unit[u].TexGenEnabled) { + _mesa_ActiveTextureARB(GL_TEXTURE0 + u); + _mesa_set_enable(ctx, GL_TEXTURE_1D, GL_FALSE); + _mesa_set_enable(ctx, GL_TEXTURE_2D, GL_FALSE); + _mesa_set_enable(ctx, GL_TEXTURE_3D, GL_FALSE); + if (ctx->Extensions.ARB_texture_cube_map) + _mesa_set_enable(ctx, GL_TEXTURE_CUBE_MAP, GL_FALSE); + _mesa_set_enable(ctx, GL_TEXTURE_RECTANGLE, GL_FALSE); + _mesa_set_enable(ctx, GL_TEXTURE_GEN_S, GL_FALSE); + _mesa_set_enable(ctx, GL_TEXTURE_GEN_T, GL_FALSE); + _mesa_set_enable(ctx, GL_TEXTURE_GEN_R, GL_FALSE); + _mesa_set_enable(ctx, GL_TEXTURE_GEN_Q, GL_FALSE); + } + } + + /* save current texture objects for unit[0] only */ + for (tgt = 0; tgt < NUM_TEXTURE_TARGETS; tgt++) { + _mesa_reference_texobj(&save->CurrentTexture[tgt], + ctx->Texture.Unit[0].CurrentTex[tgt]); + } + + /* set defaults for unit[0] */ + _mesa_ActiveTextureARB(GL_TEXTURE0); + _mesa_ClientActiveTextureARB(GL_TEXTURE0); + _mesa_TexEnvi(GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_REPLACE); + } + + if (state & META_TRANSFORM) { + GLuint activeTexture = ctx->Texture.CurrentUnit; + memcpy(save->ModelviewMatrix, ctx->ModelviewMatrixStack.Top->m, + 16 * sizeof(GLfloat)); + memcpy(save->ProjectionMatrix, ctx->ProjectionMatrixStack.Top->m, + 16 * sizeof(GLfloat)); + memcpy(save->TextureMatrix, ctx->TextureMatrixStack[0].Top->m, + 16 * sizeof(GLfloat)); + save->MatrixMode = ctx->Transform.MatrixMode; + /* set 1:1 vertex:pixel coordinate transform */ + _mesa_ActiveTextureARB(GL_TEXTURE0); + _mesa_MatrixMode(GL_TEXTURE); + _mesa_LoadIdentity(); + _mesa_ActiveTextureARB(GL_TEXTURE0 + activeTexture); + _mesa_MatrixMode(GL_MODELVIEW); + _mesa_LoadIdentity(); + _mesa_MatrixMode(GL_PROJECTION); + _mesa_LoadIdentity(); + _mesa_Ortho(0.0, ctx->DrawBuffer->Width, + 0.0, ctx->DrawBuffer->Height, + -1.0, 1.0); + save->ClipPlanesEnabled = ctx->Transform.ClipPlanesEnabled; + if (ctx->Transform.ClipPlanesEnabled) { + GLuint i; + for (i = 0; i < ctx->Const.MaxClipPlanes; i++) { + _mesa_set_enable(ctx, GL_CLIP_PLANE0 + i, GL_FALSE); + } + } + } + + if (state & META_VERTEX) { + /* save vertex array object state */ + _mesa_reference_array_object(ctx, &save->ArrayObj, + ctx->Array.ArrayObj); + _mesa_reference_buffer_object(ctx, &save->ArrayBufferObj, + ctx->Array.ArrayBufferObj); + /* set some default state? */ + } + + if (state & META_VIEWPORT) { + /* save viewport state */ + save->ViewportX = ctx->Viewport.X; + save->ViewportY = ctx->Viewport.Y; + save->ViewportW = ctx->Viewport.Width; + save->ViewportH = ctx->Viewport.Height; + /* set viewport to match window size */ + if (ctx->Viewport.X != 0 || + ctx->Viewport.Y != 0 || + ctx->Viewport.Width != ctx->DrawBuffer->Width || + ctx->Viewport.Height != ctx->DrawBuffer->Height) { + _mesa_set_viewport(ctx, 0, 0, + ctx->DrawBuffer->Width, ctx->DrawBuffer->Height); + } + /* save depth range state */ + save->DepthNear = ctx->Viewport.Near; + save->DepthFar = ctx->Viewport.Far; + /* set depth range to default */ + _mesa_DepthRange(0.0, 1.0); + } + + if (state & META_CLAMP_FRAGMENT_COLOR) { + save->ClampFragmentColor = ctx->Color.ClampFragmentColor; + + /* Generally in here we want to do clamping according to whether + * it's for the pixel path (ClampFragmentColor is GL_TRUE), + * regardless of the internal implementation of the metaops. + */ + if (ctx->Color.ClampFragmentColor != GL_TRUE) + _mesa_ClampColorARB(GL_CLAMP_FRAGMENT_COLOR, GL_FALSE); + } + + if (state & META_CLAMP_VERTEX_COLOR) { + save->ClampVertexColor = ctx->Light.ClampVertexColor; + + /* Generally in here we never want vertex color clamping -- + * result clamping is only dependent on fragment clamping. + */ + _mesa_ClampColorARB(GL_CLAMP_VERTEX_COLOR, GL_FALSE); + } + + if (state & META_CONDITIONAL_RENDER) { + save->CondRenderQuery = ctx->Query.CondRenderQuery; + save->CondRenderMode = ctx->Query.CondRenderMode; + + if (ctx->Query.CondRenderQuery) + _mesa_EndConditionalRender(); + } + + /* misc */ + { + save->Lighting = ctx->Light.Enabled; + if (ctx->Light.Enabled) + _mesa_set_enable(ctx, GL_LIGHTING, GL_FALSE); + } +} + + +/** + * Leave meta state. This is like a light-weight version of glPopAttrib(). + */ +static void +_mesa_meta_end(struct gl_context *ctx) +{ + struct save_state *save = &ctx->Meta->Save[--ctx->Meta->SaveStackDepth]; + const GLbitfield state = save->SavedState; + + if (state & META_ALPHA_TEST) { + if (ctx->Color.AlphaEnabled != save->AlphaEnabled) + _mesa_set_enable(ctx, GL_ALPHA_TEST, save->AlphaEnabled); + _mesa_AlphaFunc(save->AlphaFunc, save->AlphaRef); + } + + if (state & META_BLEND) { + if (ctx->Color.BlendEnabled != save->BlendEnabled) { + if (ctx->Extensions.EXT_draw_buffers2) { + GLuint i; + for (i = 0; i < ctx->Const.MaxDrawBuffers; i++) { + _mesa_set_enablei(ctx, GL_BLEND, i, (save->BlendEnabled >> i) & 1); + } + } + else { + _mesa_set_enable(ctx, GL_BLEND, (save->BlendEnabled & 1)); + } + } + if (ctx->Color.ColorLogicOpEnabled != save->ColorLogicOpEnabled) + _mesa_set_enable(ctx, GL_COLOR_LOGIC_OP, save->ColorLogicOpEnabled); + } + + if (state & META_COLOR_MASK) { + GLuint i; + for (i = 0; i < ctx->Const.MaxDrawBuffers; i++) { + if (!TEST_EQ_4V(ctx->Color.ColorMask[i], save->ColorMask[i])) { + if (i == 0) { + _mesa_ColorMask(save->ColorMask[i][0], save->ColorMask[i][1], + save->ColorMask[i][2], save->ColorMask[i][3]); + } + else { + _mesa_ColorMaskIndexed(i, + save->ColorMask[i][0], + save->ColorMask[i][1], + save->ColorMask[i][2], + save->ColorMask[i][3]); + } + } + } + } + + if (state & META_DEPTH_TEST) { + if (ctx->Depth.Test != save->Depth.Test) + _mesa_set_enable(ctx, GL_DEPTH_TEST, save->Depth.Test); + _mesa_DepthFunc(save->Depth.Func); + _mesa_DepthMask(save->Depth.Mask); + } + + if (state & META_FOG) { + _mesa_set_enable(ctx, GL_FOG, save->Fog); + } + + if (state & META_PIXEL_STORE) { + ctx->Pack = save->Pack; + ctx->Unpack = save->Unpack; + } + + if (state & META_PIXEL_TRANSFER) { + ctx->Pixel.RedScale = save->RedScale; + ctx->Pixel.RedBias = save->RedBias; + ctx->Pixel.GreenScale = save->GreenScale; + ctx->Pixel.GreenBias = save->GreenBias; + ctx->Pixel.BlueScale = save->BlueScale; + ctx->Pixel.BlueBias = save->BlueBias; + ctx->Pixel.AlphaScale = save->AlphaScale; + ctx->Pixel.AlphaBias = save->AlphaBias; + ctx->Pixel.MapColorFlag = save->MapColorFlag; + /* XXX more state */ + ctx->NewState |=_NEW_PIXEL; + } + + if (state & META_RASTERIZATION) { + _mesa_PolygonMode(GL_FRONT, save->FrontPolygonMode); + _mesa_PolygonMode(GL_BACK, save->BackPolygonMode); + _mesa_set_enable(ctx, GL_POLYGON_STIPPLE, save->PolygonStipple); + _mesa_set_enable(ctx, GL_POLYGON_OFFSET_FILL, save->PolygonOffset); + _mesa_set_enable(ctx, GL_POLYGON_SMOOTH, save->PolygonSmooth); + _mesa_set_enable(ctx, GL_CULL_FACE, save->PolygonCull); + } + + if (state & META_SCISSOR) { + _mesa_set_enable(ctx, GL_SCISSOR_TEST, save->Scissor.Enabled); + _mesa_Scissor(save->Scissor.X, save->Scissor.Y, + save->Scissor.Width, save->Scissor.Height); + } + + if (state & META_SHADER) { + if (ctx->Extensions.ARB_vertex_program) { + _mesa_set_enable(ctx, GL_VERTEX_PROGRAM_ARB, + save->VertexProgramEnabled); + _mesa_reference_vertprog(ctx, &ctx->VertexProgram.Current, + save->VertexProgram); + _mesa_reference_vertprog(ctx, &save->VertexProgram, NULL); + } + + if (ctx->Extensions.ARB_fragment_program) { + _mesa_set_enable(ctx, GL_FRAGMENT_PROGRAM_ARB, + save->FragmentProgramEnabled); + _mesa_reference_fragprog(ctx, &ctx->FragmentProgram.Current, + save->FragmentProgram); + _mesa_reference_fragprog(ctx, &save->FragmentProgram, NULL); + } + + if (ctx->Extensions.ARB_vertex_shader) + _mesa_use_shader_program(ctx, GL_VERTEX_SHADER, save->VertexShader); + + if (ctx->Extensions.ARB_geometry_shader4) + _mesa_use_shader_program(ctx, GL_GEOMETRY_SHADER_ARB, + save->GeometryShader); + + if (ctx->Extensions.ARB_fragment_shader) + _mesa_use_shader_program(ctx, GL_FRAGMENT_SHADER, + save->FragmentShader); + + _mesa_reference_shader_program(ctx, &ctx->Shader.ActiveProgram, + save->ActiveShader); + } + + if (state & META_STENCIL_TEST) { + const struct gl_stencil_attrib *stencil = &save->Stencil; + + _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]); + } + + if (state & META_TEXTURE) { + GLuint u, tgt; + + ASSERT(ctx->Texture.CurrentUnit == 0); + + /* restore texenv for unit[0] */ + _mesa_TexEnvi(GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, save->EnvMode); + + /* restore texture objects for unit[0] only */ + for (tgt = 0; tgt < NUM_TEXTURE_TARGETS; tgt++) { + _mesa_reference_texobj(&ctx->Texture.Unit[0].CurrentTex[tgt], + save->CurrentTexture[tgt]); + _mesa_reference_texobj(&save->CurrentTexture[tgt], NULL); + } + + /* Re-enable textures, texgen */ + for (u = 0; u < ctx->Const.MaxTextureUnits; u++) { + if (save->TexEnabled[u]) { + _mesa_ActiveTextureARB(GL_TEXTURE0 + u); + + if (save->TexEnabled[u] & TEXTURE_1D_BIT) + _mesa_set_enable(ctx, GL_TEXTURE_1D, GL_TRUE); + if (save->TexEnabled[u] & TEXTURE_2D_BIT) + _mesa_set_enable(ctx, GL_TEXTURE_2D, GL_TRUE); + if (save->TexEnabled[u] & TEXTURE_3D_BIT) + _mesa_set_enable(ctx, GL_TEXTURE_3D, GL_TRUE); + if (save->TexEnabled[u] & TEXTURE_CUBE_BIT) + _mesa_set_enable(ctx, GL_TEXTURE_CUBE_MAP, GL_TRUE); + if (save->TexEnabled[u] & TEXTURE_RECT_BIT) + _mesa_set_enable(ctx, GL_TEXTURE_RECTANGLE, GL_TRUE); + } + + if (save->TexGenEnabled[u]) { + _mesa_ActiveTextureARB(GL_TEXTURE0 + u); + + if (save->TexGenEnabled[u] & S_BIT) + _mesa_set_enable(ctx, GL_TEXTURE_GEN_S, GL_TRUE); + if (save->TexGenEnabled[u] & T_BIT) + _mesa_set_enable(ctx, GL_TEXTURE_GEN_T, GL_TRUE); + if (save->TexGenEnabled[u] & R_BIT) + _mesa_set_enable(ctx, GL_TEXTURE_GEN_R, GL_TRUE); + if (save->TexGenEnabled[u] & Q_BIT) + _mesa_set_enable(ctx, GL_TEXTURE_GEN_Q, GL_TRUE); + } + } + + /* restore current unit state */ + _mesa_ActiveTextureARB(GL_TEXTURE0 + save->ActiveUnit); + _mesa_ClientActiveTextureARB(GL_TEXTURE0 + save->ClientActiveUnit); + } + + if (state & META_TRANSFORM) { + GLuint activeTexture = ctx->Texture.CurrentUnit; + _mesa_ActiveTextureARB(GL_TEXTURE0); + _mesa_MatrixMode(GL_TEXTURE); + _mesa_LoadMatrixf(save->TextureMatrix); + _mesa_ActiveTextureARB(GL_TEXTURE0 + activeTexture); + + _mesa_MatrixMode(GL_MODELVIEW); + _mesa_LoadMatrixf(save->ModelviewMatrix); + + _mesa_MatrixMode(GL_PROJECTION); + _mesa_LoadMatrixf(save->ProjectionMatrix); + + _mesa_MatrixMode(save->MatrixMode); + + if (save->ClipPlanesEnabled) { + GLuint i; + for (i = 0; i < ctx->Const.MaxClipPlanes; i++) { + if (save->ClipPlanesEnabled & (1 << i)) { + _mesa_set_enable(ctx, GL_CLIP_PLANE0 + i, GL_TRUE); + } + } + } + } + + if (state & META_VERTEX) { + /* restore vertex buffer object */ + _mesa_BindBufferARB(GL_ARRAY_BUFFER_ARB, save->ArrayBufferObj->Name); + _mesa_reference_buffer_object(ctx, &save->ArrayBufferObj, NULL); + + /* restore vertex array object */ + _mesa_BindVertexArray(save->ArrayObj->Name); + _mesa_reference_array_object(ctx, &save->ArrayObj, NULL); + } + + if (state & META_VIEWPORT) { + if (save->ViewportX != ctx->Viewport.X || + save->ViewportY != ctx->Viewport.Y || + save->ViewportW != ctx->Viewport.Width || + save->ViewportH != ctx->Viewport.Height) { + _mesa_set_viewport(ctx, save->ViewportX, save->ViewportY, + save->ViewportW, save->ViewportH); + } + _mesa_DepthRange(save->DepthNear, save->DepthFar); + } + + if (state & META_CLAMP_FRAGMENT_COLOR) { + _mesa_ClampColorARB(GL_CLAMP_FRAGMENT_COLOR, save->ClampFragmentColor); + } + + if (state & META_CLAMP_VERTEX_COLOR) { + _mesa_ClampColorARB(GL_CLAMP_VERTEX_COLOR, save->ClampVertexColor); + } + + if (state & META_CONDITIONAL_RENDER) { + if (save->CondRenderQuery) + _mesa_BeginConditionalRender(save->CondRenderQuery->Id, + save->CondRenderMode); + } + + /* misc */ + if (save->Lighting) { + _mesa_set_enable(ctx, GL_LIGHTING, GL_TRUE); + } +} + + +/** + * Convert Z from a normalized value in the range [0, 1] to an object-space + * Z coordinate in [-1, +1] so that drawing at the new Z position with the + * default/identity ortho projection results in the original Z value. + * Used by the meta-Clear, Draw/CopyPixels and Bitmap functions where the Z + * value comes from the clear value or raster position. + */ +static INLINE GLfloat +invert_z(GLfloat normZ) +{ + GLfloat objZ = 1.0 - 2.0 * normZ; + return objZ; +} + + +/** + * One-time init for a temp_texture object. + * Choose tex target, compute max tex size, etc. + */ +static void +init_temp_texture(struct gl_context *ctx, struct temp_texture *tex) +{ + /* prefer texture rectangle */ + if (ctx->Extensions.NV_texture_rectangle) { + tex->Target = GL_TEXTURE_RECTANGLE; + tex->MaxSize = ctx->Const.MaxTextureRectSize; + tex->NPOT = GL_TRUE; + } + else { + /* use 2D texture, NPOT if possible */ + tex->Target = GL_TEXTURE_2D; + tex->MaxSize = 1 << (ctx->Const.MaxTextureLevels - 1); + tex->NPOT = ctx->Extensions.ARB_texture_non_power_of_two; + } + tex->MinSize = 16; /* 16 x 16 at least */ + assert(tex->MaxSize > 0); + + _mesa_GenTextures(1, &tex->TexObj); +} + + +/** + * Return pointer to temp_texture info for non-bitmap ops. + * This does some one-time init if needed. + */ +static struct temp_texture * +get_temp_texture(struct gl_context *ctx) +{ + struct temp_texture *tex = &ctx->Meta->TempTex; + + if (!tex->TexObj) { + init_temp_texture(ctx, tex); + } + + return tex; +} + + +/** + * Return pointer to temp_texture info for _mesa_meta_bitmap(). + * We use a separate texture for bitmaps to reduce texture + * allocation/deallocation. + */ +static struct temp_texture * +get_bitmap_temp_texture(struct gl_context *ctx) +{ + struct temp_texture *tex = &ctx->Meta->Bitmap.Tex; + + if (!tex->TexObj) { + init_temp_texture(ctx, tex); + } + + return tex; +} + + +/** + * Compute the width/height of texture needed to draw an image of the + * given size. Return a flag indicating whether the current texture + * can be re-used (glTexSubImage2D) or if a new texture needs to be + * allocated (glTexImage2D). + * Also, compute s/t texcoords for drawing. + * + * \return GL_TRUE if new texture is needed, GL_FALSE otherwise + */ +static GLboolean +alloc_texture(struct temp_texture *tex, + GLsizei width, GLsizei height, GLenum intFormat) +{ + GLboolean newTex = GL_FALSE; + + ASSERT(width <= tex->MaxSize); + ASSERT(height <= tex->MaxSize); + + if (width > tex->Width || + height > tex->Height || + intFormat != tex->IntFormat) { + /* alloc new texture (larger or different format) */ + + if (tex->NPOT) { + /* use non-power of two size */ + tex->Width = MAX2(tex->MinSize, width); + tex->Height = MAX2(tex->MinSize, height); + } + else { + /* find power of two size */ + GLsizei w, h; + w = h = tex->MinSize; + while (w < width) + w *= 2; + while (h < height) + h *= 2; + tex->Width = w; + tex->Height = h; + } + + tex->IntFormat = intFormat; + + newTex = GL_TRUE; + } + + /* compute texcoords */ + if (tex->Target == GL_TEXTURE_RECTANGLE) { + tex->Sright = (GLfloat) width; + tex->Ttop = (GLfloat) height; + } + else { + tex->Sright = (GLfloat) width / tex->Width; + tex->Ttop = (GLfloat) height / tex->Height; + } + + return newTex; +} + + +/** + * Setup/load texture for glCopyPixels or glBlitFramebuffer. + */ +static void +setup_copypix_texture(struct temp_texture *tex, + GLboolean newTex, + GLint srcX, GLint srcY, + GLsizei width, GLsizei height, GLenum intFormat, + GLenum filter) +{ + _mesa_BindTexture(tex->Target, tex->TexObj); + _mesa_TexParameteri(tex->Target, GL_TEXTURE_MIN_FILTER, filter); + _mesa_TexParameteri(tex->Target, GL_TEXTURE_MAG_FILTER, filter); + _mesa_TexEnvi(GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_REPLACE); + + /* copy framebuffer image to texture */ + if (newTex) { + /* create new tex image */ + if (tex->Width == width && tex->Height == height) { + /* create new tex with framebuffer data */ + _mesa_CopyTexImage2D(tex->Target, 0, tex->IntFormat, + srcX, srcY, width, height, 0); + } + else { + /* create empty texture */ + _mesa_TexImage2D(tex->Target, 0, tex->IntFormat, + tex->Width, tex->Height, 0, + intFormat, GL_UNSIGNED_BYTE, NULL); + /* load image */ + _mesa_CopyTexSubImage2D(tex->Target, 0, + 0, 0, srcX, srcY, width, height); + } + } + else { + /* replace existing tex image */ + _mesa_CopyTexSubImage2D(tex->Target, 0, + 0, 0, srcX, srcY, width, height); + } +} + + +/** + * Setup/load texture for glDrawPixels. + */ +static void +setup_drawpix_texture(struct gl_context *ctx, + struct temp_texture *tex, + GLboolean newTex, + GLenum texIntFormat, + GLsizei width, GLsizei height, + GLenum format, GLenum type, + const GLvoid *pixels) +{ + _mesa_BindTexture(tex->Target, tex->TexObj); + _mesa_TexParameteri(tex->Target, GL_TEXTURE_MIN_FILTER, GL_NEAREST); + _mesa_TexParameteri(tex->Target, GL_TEXTURE_MAG_FILTER, GL_NEAREST); + _mesa_TexEnvi(GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_REPLACE); + + /* copy pixel data to texture */ + if (newTex) { + /* create new tex image */ + if (tex->Width == width && tex->Height == height) { + /* create new tex and load image data */ + _mesa_TexImage2D(tex->Target, 0, tex->IntFormat, + tex->Width, tex->Height, 0, format, type, pixels); + } + else { + struct gl_buffer_object *save_unpack_obj = NULL; + + _mesa_reference_buffer_object(ctx, &save_unpack_obj, + ctx->Unpack.BufferObj); + _mesa_BindBufferARB(GL_PIXEL_UNPACK_BUFFER_ARB, 0); + /* create empty texture */ + _mesa_TexImage2D(tex->Target, 0, tex->IntFormat, + tex->Width, tex->Height, 0, format, type, NULL); + if (save_unpack_obj != NULL) + _mesa_BindBufferARB(GL_PIXEL_UNPACK_BUFFER_ARB, + save_unpack_obj->Name); + /* load image */ + _mesa_TexSubImage2D(tex->Target, 0, + 0, 0, width, height, format, type, pixels); + } + } + else { + /* replace existing tex image */ + _mesa_TexSubImage2D(tex->Target, 0, + 0, 0, width, height, format, type, pixels); + } +} + + + +/** + * One-time init for drawing depth pixels. + */ +static void +init_blit_depth_pixels(struct gl_context *ctx) +{ + static const char *program = + "!!ARBfp1.0\n" + "TEX result.depth, fragment.texcoord[0], texture[0], %s; \n" + "END \n"; + char program2[200]; + struct blit_state *blit = &ctx->Meta->Blit; + struct temp_texture *tex = get_temp_texture(ctx); + const char *texTarget; + + assert(blit->DepthFP == 0); + + /* replace %s with "RECT" or "2D" */ + assert(strlen(program) + 4 < sizeof(program2)); + if (tex->Target == GL_TEXTURE_RECTANGLE) + texTarget = "RECT"; + else + texTarget = "2D"; + _mesa_snprintf(program2, sizeof(program2), program, texTarget); + + _mesa_GenPrograms(1, &blit->DepthFP); + _mesa_BindProgram(GL_FRAGMENT_PROGRAM_ARB, blit->DepthFP); + _mesa_ProgramStringARB(GL_FRAGMENT_PROGRAM_ARB, GL_PROGRAM_FORMAT_ASCII_ARB, + strlen(program2), (const GLubyte *) program2); +} + + +/** + * Try to do a glBlitFramebuffer using no-copy texturing. + * We can do this when the src renderbuffer is actually a texture. + * But if the src buffer == dst buffer we cannot do this. + * + * \return new buffer mask indicating the buffers left to blit using the + * normal path. + */ +static GLbitfield +blitframebuffer_texture(struct gl_context *ctx, + GLint srcX0, GLint srcY0, GLint srcX1, GLint srcY1, + GLint dstX0, GLint dstY0, GLint dstX1, GLint dstY1, + GLbitfield mask, GLenum filter) +{ + if (mask & GL_COLOR_BUFFER_BIT) { + const struct gl_framebuffer *drawFb = ctx->DrawBuffer; + const struct gl_framebuffer *readFb = ctx->ReadBuffer; + const struct gl_renderbuffer_attachment *drawAtt = + &drawFb->Attachment[drawFb->_ColorDrawBufferIndexes[0]]; + const struct gl_renderbuffer_attachment *readAtt = + &readFb->Attachment[readFb->_ColorReadBufferIndex]; + + if (readAtt && readAtt->Texture) { + const struct gl_texture_object *texObj = readAtt->Texture; + const GLuint srcLevel = readAtt->TextureLevel; + const GLenum minFilterSave = texObj->Sampler.MinFilter; + const GLenum magFilterSave = texObj->Sampler.MagFilter; + const GLint baseLevelSave = texObj->BaseLevel; + const GLint maxLevelSave = texObj->MaxLevel; + const GLenum wrapSSave = texObj->Sampler.WrapS; + const GLenum wrapTSave = texObj->Sampler.WrapT; + const GLenum srgbSave = texObj->Sampler.sRGBDecode; + const GLenum fbo_srgb_save = ctx->Color.sRGBEnabled; + const GLenum target = texObj->Target; + + if (drawAtt->Texture == readAtt->Texture) { + /* Can't use same texture as both the source and dest. We need + * to handle overlapping blits and besides, some hw may not + * support this. + */ + return mask; + } + + if (target != GL_TEXTURE_2D && target != GL_TEXTURE_RECTANGLE_ARB) { + /* Can't handle other texture types at this time */ + return mask; + } + + /* + printf("Blit from texture!\n"); + printf(" srcAtt %p dstAtt %p\n", readAtt, drawAtt); + printf(" srcTex %p dstText %p\n", texObj, drawAtt->Texture); + */ + + /* Prepare src texture state */ + _mesa_BindTexture(target, texObj->Name); + _mesa_TexParameteri(target, GL_TEXTURE_MIN_FILTER, filter); + _mesa_TexParameteri(target, GL_TEXTURE_MAG_FILTER, filter); + if (target != GL_TEXTURE_RECTANGLE_ARB) { + _mesa_TexParameteri(target, GL_TEXTURE_BASE_LEVEL, srcLevel); + _mesa_TexParameteri(target, GL_TEXTURE_MAX_LEVEL, srcLevel); + } + _mesa_TexParameteri(target, GL_TEXTURE_WRAP_S, GL_CLAMP_TO_EDGE); + _mesa_TexParameteri(target, GL_TEXTURE_WRAP_T, GL_CLAMP_TO_EDGE); + + /* Always do our blits with no sRGB decode or encode.*/ + if (ctx->Extensions.EXT_texture_sRGB_decode) { + _mesa_TexParameteri(target, GL_TEXTURE_SRGB_DECODE_EXT, + GL_SKIP_DECODE_EXT); + } + _mesa_Disable(GL_FRAMEBUFFER_SRGB_EXT); + + _mesa_TexEnvi(GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_REPLACE); + _mesa_set_enable(ctx, target, GL_TRUE); + + /* Prepare vertex data (the VBO was previously created and bound) */ + { + struct vertex { + GLfloat x, y, s, t; + }; + struct vertex verts[4]; + GLfloat s0, t0, s1, t1; + + if (target == GL_TEXTURE_2D) { + const struct gl_texture_image *texImage + = _mesa_select_tex_image(ctx, texObj, target, srcLevel); + s0 = srcX0 / (float) texImage->Width; + s1 = srcX1 / (float) texImage->Width; + t0 = srcY0 / (float) texImage->Height; + t1 = srcY1 / (float) texImage->Height; + } + else { + assert(target == GL_TEXTURE_RECTANGLE_ARB); + s0 = srcX0; + s1 = srcX1; + t0 = srcY0; + t1 = srcY1; + } + + verts[0].x = (GLfloat) dstX0; + verts[0].y = (GLfloat) dstY0; + verts[1].x = (GLfloat) dstX1; + verts[1].y = (GLfloat) dstY0; + verts[2].x = (GLfloat) dstX1; + verts[2].y = (GLfloat) dstY1; + verts[3].x = (GLfloat) dstX0; + verts[3].y = (GLfloat) dstY1; + + verts[0].s = s0; + verts[0].t = t0; + verts[1].s = s1; + verts[1].t = t0; + verts[2].s = s1; + verts[2].t = t1; + verts[3].s = s0; + verts[3].t = t1; + + _mesa_BufferSubDataARB(GL_ARRAY_BUFFER_ARB, 0, sizeof(verts), verts); + } + + _mesa_DrawArrays(GL_TRIANGLE_FAN, 0, 4); + + /* Restore texture object state, the texture binding will + * be restored by _mesa_meta_end(). + */ + _mesa_TexParameteri(target, GL_TEXTURE_MIN_FILTER, minFilterSave); + _mesa_TexParameteri(target, GL_TEXTURE_MAG_FILTER, magFilterSave); + if (target != GL_TEXTURE_RECTANGLE_ARB) { + _mesa_TexParameteri(target, GL_TEXTURE_BASE_LEVEL, baseLevelSave); + _mesa_TexParameteri(target, GL_TEXTURE_MAX_LEVEL, maxLevelSave); + } + _mesa_TexParameteri(target, GL_TEXTURE_WRAP_S, wrapSSave); + _mesa_TexParameteri(target, GL_TEXTURE_WRAP_T, wrapTSave); + if (ctx->Extensions.EXT_texture_sRGB_decode) { + _mesa_TexParameteri(target, GL_TEXTURE_SRGB_DECODE_EXT, srgbSave); + } + if (ctx->Extensions.EXT_texture_sRGB_decode && fbo_srgb_save) { + _mesa_Enable(GL_FRAMEBUFFER_SRGB_EXT); + } + + /* Done with color buffer */ + mask &= ~GL_COLOR_BUFFER_BIT; + } + } + + return mask; +} + + +/** + * Meta implementation of ctx->Driver.BlitFramebuffer() in terms + * of texture mapping and polygon rendering. + */ +void +_mesa_meta_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) +{ + struct blit_state *blit = &ctx->Meta->Blit; + struct temp_texture *tex = get_temp_texture(ctx); + const GLsizei maxTexSize = tex->MaxSize; + const GLint srcX = MIN2(srcX0, srcX1); + const GLint srcY = MIN2(srcY0, srcY1); + const GLint srcW = abs(srcX1 - srcX0); + const GLint srcH = abs(srcY1 - srcY0); + const GLboolean srcFlipX = srcX1 < srcX0; + const GLboolean srcFlipY = srcY1 < srcY0; + struct vertex { + GLfloat x, y, s, t; + }; + struct vertex verts[4]; + GLboolean newTex; + + if (srcW > maxTexSize || srcH > maxTexSize) { + /* XXX avoid this fallback */ + _swrast_BlitFramebuffer(ctx, srcX0, srcY0, srcX1, srcY1, + dstX0, dstY0, dstX1, dstY1, mask, filter); + return; + } + + if (srcFlipX) { + GLint tmp = dstX0; + dstX0 = dstX1; + dstX1 = tmp; + } + + if (srcFlipY) { + GLint tmp = dstY0; + dstY0 = dstY1; + dstY1 = tmp; + } + + /* only scissor effects blit so save/clear all other relevant state */ + _mesa_meta_begin(ctx, ~META_SCISSOR); + + if (blit->ArrayObj == 0) { + /* one-time setup */ + + /* create vertex array object */ + _mesa_GenVertexArrays(1, &blit->ArrayObj); + _mesa_BindVertexArray(blit->ArrayObj); + + /* create vertex array buffer */ + _mesa_GenBuffersARB(1, &blit->VBO); + _mesa_BindBufferARB(GL_ARRAY_BUFFER_ARB, blit->VBO); + _mesa_BufferDataARB(GL_ARRAY_BUFFER_ARB, sizeof(verts), + NULL, GL_DYNAMIC_DRAW_ARB); + + /* setup vertex arrays */ + _mesa_VertexPointer(2, GL_FLOAT, sizeof(struct vertex), OFFSET(x)); + _mesa_TexCoordPointer(2, GL_FLOAT, sizeof(struct vertex), OFFSET(s)); + _mesa_EnableClientState(GL_VERTEX_ARRAY); + _mesa_EnableClientState(GL_TEXTURE_COORD_ARRAY); + } + else { + _mesa_BindVertexArray(blit->ArrayObj); + _mesa_BindBufferARB(GL_ARRAY_BUFFER_ARB, blit->VBO); + } + + /* Try faster, direct texture approach first */ + mask = blitframebuffer_texture(ctx, srcX0, srcY0, srcX1, srcY1, + dstX0, dstY0, dstX1, dstY1, mask, filter); + if (mask == 0x0) { + _mesa_meta_end(ctx); + return; + } + + /* Continue with "normal" approach which involves copying the src rect + * into a temporary texture and is "blitted" by drawing a textured quad. + */ + + newTex = alloc_texture(tex, srcW, srcH, GL_RGBA); + + /* vertex positions/texcoords (after texture allocation!) */ + { + verts[0].x = (GLfloat) dstX0; + verts[0].y = (GLfloat) dstY0; + verts[1].x = (GLfloat) dstX1; + verts[1].y = (GLfloat) dstY0; + verts[2].x = (GLfloat) dstX1; + verts[2].y = (GLfloat) dstY1; + verts[3].x = (GLfloat) dstX0; + verts[3].y = (GLfloat) dstY1; + + verts[0].s = 0.0F; + verts[0].t = 0.0F; + verts[1].s = tex->Sright; + verts[1].t = 0.0F; + verts[2].s = tex->Sright; + verts[2].t = tex->Ttop; + verts[3].s = 0.0F; + verts[3].t = tex->Ttop; + + /* upload new vertex data */ + _mesa_BufferSubDataARB(GL_ARRAY_BUFFER_ARB, 0, sizeof(verts), verts); + } + + _mesa_set_enable(ctx, tex->Target, GL_TRUE); + + if (mask & GL_COLOR_BUFFER_BIT) { + setup_copypix_texture(tex, newTex, srcX, srcY, srcW, srcH, + GL_RGBA, filter); + _mesa_DrawArrays(GL_TRIANGLE_FAN, 0, 4); + mask &= ~GL_COLOR_BUFFER_BIT; + } + + if (mask & GL_DEPTH_BUFFER_BIT) { + GLuint *tmp = (GLuint *) malloc(srcW * srcH * sizeof(GLuint)); + if (tmp) { + if (!blit->DepthFP) + init_blit_depth_pixels(ctx); + + /* maybe change tex format here */ + newTex = alloc_texture(tex, srcW, srcH, GL_DEPTH_COMPONENT); + + _mesa_ReadPixels(srcX, srcY, srcW, srcH, + GL_DEPTH_COMPONENT, GL_UNSIGNED_INT, tmp); + + setup_drawpix_texture(ctx, tex, newTex, GL_DEPTH_COMPONENT, srcW, srcH, + GL_DEPTH_COMPONENT, GL_UNSIGNED_INT, tmp); + + _mesa_BindProgram(GL_FRAGMENT_PROGRAM_ARB, blit->DepthFP); + _mesa_set_enable(ctx, GL_FRAGMENT_PROGRAM_ARB, GL_TRUE); + _mesa_ColorMask(GL_FALSE, GL_FALSE, GL_FALSE, GL_FALSE); + _mesa_set_enable(ctx, GL_DEPTH_TEST, GL_TRUE); + _mesa_DepthFunc(GL_ALWAYS); + _mesa_DepthMask(GL_TRUE); + + _mesa_DrawArrays(GL_TRIANGLE_FAN, 0, 4); + mask &= ~GL_DEPTH_BUFFER_BIT; + + free(tmp); + } + } + + if (mask & GL_STENCIL_BUFFER_BIT) { + /* XXX can't easily do stencil */ + } + + _mesa_set_enable(ctx, tex->Target, GL_FALSE); + + _mesa_meta_end(ctx); + + if (mask) { + _swrast_BlitFramebuffer(ctx, srcX0, srcY0, srcX1, srcY1, + dstX0, dstY0, dstX1, dstY1, mask, filter); + } +} + + +/** + * Meta implementation of ctx->Driver.Clear() in terms of polygon rendering. + */ +void +_mesa_meta_Clear(struct gl_context *ctx, GLbitfield buffers) +{ + struct clear_state *clear = &ctx->Meta->Clear; + struct vertex { + GLfloat x, y, z, r, g, b, a; + }; + struct vertex verts[4]; + /* save all state but scissor, pixel pack/unpack */ + GLbitfield metaSave = (META_ALL - + META_SCISSOR - + META_PIXEL_STORE - + META_CONDITIONAL_RENDER); + const GLuint stencilMax = (1 << ctx->DrawBuffer->Visual.stencilBits) - 1; + + if (buffers & BUFFER_BITS_COLOR) { + /* if clearing color buffers, don't save/restore colormask */ + metaSave -= META_COLOR_MASK; + } + + _mesa_meta_begin(ctx, metaSave); + + if (clear->ArrayObj == 0) { + /* one-time setup */ + + /* create vertex array object */ + _mesa_GenVertexArrays(1, &clear->ArrayObj); + _mesa_BindVertexArray(clear->ArrayObj); + + /* create vertex array buffer */ + _mesa_GenBuffersARB(1, &clear->VBO); + _mesa_BindBufferARB(GL_ARRAY_BUFFER_ARB, clear->VBO); + + /* setup vertex arrays */ + _mesa_VertexPointer(3, GL_FLOAT, sizeof(struct vertex), OFFSET(x)); + _mesa_ColorPointer(4, GL_FLOAT, sizeof(struct vertex), OFFSET(r)); + _mesa_EnableClientState(GL_VERTEX_ARRAY); + _mesa_EnableClientState(GL_COLOR_ARRAY); + } + else { + _mesa_BindVertexArray(clear->ArrayObj); + _mesa_BindBufferARB(GL_ARRAY_BUFFER_ARB, clear->VBO); + } + + /* GL_COLOR_BUFFER_BIT */ + if (buffers & BUFFER_BITS_COLOR) { + /* leave colormask, glDrawBuffer state as-is */ + + /* Clears never have the color clamped. */ + _mesa_ClampColorARB(GL_CLAMP_FRAGMENT_COLOR, GL_FALSE); + } + else { + ASSERT(metaSave & META_COLOR_MASK); + _mesa_ColorMask(GL_FALSE, GL_FALSE, GL_FALSE, GL_FALSE); + } + + /* GL_DEPTH_BUFFER_BIT */ + if (buffers & BUFFER_BIT_DEPTH) { + _mesa_set_enable(ctx, GL_DEPTH_TEST, GL_TRUE); + _mesa_DepthFunc(GL_ALWAYS); + _mesa_DepthMask(GL_TRUE); + } + else { + assert(!ctx->Depth.Test); + } + + /* GL_STENCIL_BUFFER_BIT */ + if (buffers & BUFFER_BIT_STENCIL) { + _mesa_set_enable(ctx, GL_STENCIL_TEST, GL_TRUE); + _mesa_StencilOpSeparate(GL_FRONT_AND_BACK, + GL_REPLACE, GL_REPLACE, GL_REPLACE); + _mesa_StencilFuncSeparate(GL_FRONT_AND_BACK, GL_ALWAYS, + ctx->Stencil.Clear & stencilMax, + ctx->Stencil.WriteMask[0]); + } + else { + assert(!ctx->Stencil.Enabled); + } + + /* vertex positions/colors */ + { + const GLfloat x0 = (GLfloat) ctx->DrawBuffer->_Xmin; + const GLfloat y0 = (GLfloat) ctx->DrawBuffer->_Ymin; + const GLfloat x1 = (GLfloat) ctx->DrawBuffer->_Xmax; + const GLfloat y1 = (GLfloat) ctx->DrawBuffer->_Ymax; + const GLfloat z = invert_z(ctx->Depth.Clear); + GLuint i; + + verts[0].x = x0; + verts[0].y = y0; + verts[0].z = z; + verts[1].x = x1; + verts[1].y = y0; + verts[1].z = z; + verts[2].x = x1; + verts[2].y = y1; + verts[2].z = z; + verts[3].x = x0; + verts[3].y = y1; + verts[3].z = z; + + /* vertex colors */ + for (i = 0; i < 4; i++) { + verts[i].r = ctx->Color.ClearColorUnclamped[0]; + verts[i].g = ctx->Color.ClearColorUnclamped[1]; + verts[i].b = ctx->Color.ClearColorUnclamped[2]; + verts[i].a = ctx->Color.ClearColorUnclamped[3]; + } + + /* upload new vertex data */ + _mesa_BufferDataARB(GL_ARRAY_BUFFER_ARB, sizeof(verts), verts, + GL_DYNAMIC_DRAW_ARB); + } + + /* draw quad */ + _mesa_DrawArrays(GL_TRIANGLE_FAN, 0, 4); + + _mesa_meta_end(ctx); +} + + +/** + * Meta implementation of ctx->Driver.CopyPixels() in terms + * of texture mapping and polygon rendering. + */ +void +_mesa_meta_CopyPixels(struct gl_context *ctx, GLint srcX, GLint srcY, + GLsizei width, GLsizei height, + GLint dstX, GLint dstY, GLenum type) +{ + struct copypix_state *copypix = &ctx->Meta->CopyPix; + struct temp_texture *tex = get_temp_texture(ctx); + struct vertex { + GLfloat x, y, z, s, t; + }; + struct vertex verts[4]; + GLboolean newTex; + GLenum intFormat = GL_RGBA; + + if (type != GL_COLOR || + ctx->_ImageTransferState || + ctx->Fog.Enabled || + width > tex->MaxSize || + height > tex->MaxSize) { + /* XXX avoid this fallback */ + _swrast_CopyPixels(ctx, srcX, srcY, width, height, dstX, dstY, type); + return; + } + + /* Most GL state applies to glCopyPixels, but a there's a few things + * we need to override: + */ + _mesa_meta_begin(ctx, (META_RASTERIZATION | + META_SHADER | + META_TEXTURE | + META_TRANSFORM | + META_VERTEX | + META_VIEWPORT)); + + if (copypix->ArrayObj == 0) { + /* one-time setup */ + + /* create vertex array object */ + _mesa_GenVertexArrays(1, ©pix->ArrayObj); + _mesa_BindVertexArray(copypix->ArrayObj); + + /* create vertex array buffer */ + _mesa_GenBuffersARB(1, ©pix->VBO); + _mesa_BindBufferARB(GL_ARRAY_BUFFER_ARB, copypix->VBO); + _mesa_BufferDataARB(GL_ARRAY_BUFFER_ARB, sizeof(verts), + NULL, GL_DYNAMIC_DRAW_ARB); + + /* setup vertex arrays */ + _mesa_VertexPointer(3, GL_FLOAT, sizeof(struct vertex), OFFSET(x)); + _mesa_TexCoordPointer(2, GL_FLOAT, sizeof(struct vertex), OFFSET(s)); + _mesa_EnableClientState(GL_VERTEX_ARRAY); + _mesa_EnableClientState(GL_TEXTURE_COORD_ARRAY); + } + else { + _mesa_BindVertexArray(copypix->ArrayObj); + _mesa_BindBufferARB(GL_ARRAY_BUFFER_ARB, copypix->VBO); + } + + newTex = alloc_texture(tex, width, height, intFormat); + + /* vertex positions, texcoords (after texture allocation!) */ + { + const GLfloat dstX0 = (GLfloat) dstX; + const GLfloat dstY0 = (GLfloat) dstY; + const GLfloat dstX1 = dstX + width * ctx->Pixel.ZoomX; + const GLfloat dstY1 = dstY + height * ctx->Pixel.ZoomY; + const GLfloat z = invert_z(ctx->Current.RasterPos[2]); + + verts[0].x = dstX0; + verts[0].y = dstY0; + verts[0].z = z; + verts[0].s = 0.0F; + verts[0].t = 0.0F; + verts[1].x = dstX1; + verts[1].y = dstY0; + verts[1].z = z; + verts[1].s = tex->Sright; + verts[1].t = 0.0F; + verts[2].x = dstX1; + verts[2].y = dstY1; + verts[2].z = z; + verts[2].s = tex->Sright; + verts[2].t = tex->Ttop; + verts[3].x = dstX0; + verts[3].y = dstY1; + verts[3].z = z; + verts[3].s = 0.0F; + verts[3].t = tex->Ttop; + + /* upload new vertex data */ + _mesa_BufferSubDataARB(GL_ARRAY_BUFFER_ARB, 0, sizeof(verts), verts); + } + + /* Alloc/setup texture */ + setup_copypix_texture(tex, newTex, srcX, srcY, width, height, + GL_RGBA, GL_NEAREST); + + _mesa_set_enable(ctx, tex->Target, GL_TRUE); + + /* draw textured quad */ + _mesa_DrawArrays(GL_TRIANGLE_FAN, 0, 4); + + _mesa_set_enable(ctx, tex->Target, GL_FALSE); + + _mesa_meta_end(ctx); +} + + + +/** + * When the glDrawPixels() image size is greater than the max rectangle + * texture size we use this function to break the glDrawPixels() image + * into tiles which fit into the max texture size. + */ +static void +tiled_draw_pixels(struct gl_context *ctx, + GLint tileSize, + GLint x, GLint y, GLsizei width, GLsizei height, + GLenum format, GLenum type, + const struct gl_pixelstore_attrib *unpack, + const GLvoid *pixels) +{ + struct gl_pixelstore_attrib tileUnpack = *unpack; + GLint i, j; + + if (tileUnpack.RowLength == 0) + tileUnpack.RowLength = width; + + for (i = 0; i < width; i += tileSize) { + const GLint tileWidth = MIN2(tileSize, width - i); + const GLint tileX = (GLint) (x + i * ctx->Pixel.ZoomX); + + tileUnpack.SkipPixels = unpack->SkipPixels + i; + + for (j = 0; j < height; j += tileSize) { + const GLint tileHeight = MIN2(tileSize, height - j); + const GLint tileY = (GLint) (y + j * ctx->Pixel.ZoomY); + + tileUnpack.SkipRows = unpack->SkipRows + j; + + _mesa_meta_DrawPixels(ctx, tileX, tileY, tileWidth, tileHeight, + format, type, &tileUnpack, pixels); + } + } +} + + +/** + * One-time init for drawing stencil pixels. + */ +static void +init_draw_stencil_pixels(struct gl_context *ctx) +{ + /* This program is run eight times, once for each stencil bit. + * The stencil values to draw are found in an 8-bit alpha texture. + * We read the texture/stencil value and test if bit 'b' is set. + * If the bit is not set, use KIL to kill the fragment. + * Finally, we use the stencil test to update the stencil buffer. + * + * The basic algorithm for checking if a bit is set is: + * if (is_odd(value / (1 << bit))) + * result is one (or non-zero). + * else + * result is zero. + * The program parameter contains three values: + * parm.x = 255 / (1 << bit) + * parm.y = 0.5 + * parm.z = 0.0 + */ + static const char *program = + "!!ARBfp1.0\n" + "PARAM parm = program.local[0]; \n" + "TEMP t; \n" + "TEX t, fragment.texcoord[0], texture[0], %s; \n" /* NOTE %s here! */ + "# t = t * 255 / bit \n" + "MUL t.x, t.a, parm.x; \n" + "# t = (int) t \n" + "FRC t.y, t.x; \n" + "SUB t.x, t.x, t.y; \n" + "# t = t * 0.5 \n" + "MUL t.x, t.x, parm.y; \n" + "# t = fract(t.x) \n" + "FRC t.x, t.x; # if t.x != 0, then the bit is set \n" + "# t.x = (t.x == 0 ? 1 : 0) \n" + "SGE t.x, -t.x, parm.z; \n" + "KIL -t.x; \n" + "# for debug only \n" + "#MOV result.color, t.x; \n" + "END \n"; + char program2[1000]; + struct drawpix_state *drawpix = &ctx->Meta->DrawPix; + struct temp_texture *tex = get_temp_texture(ctx); + const char *texTarget; + + assert(drawpix->StencilFP == 0); + + /* replace %s with "RECT" or "2D" */ + assert(strlen(program) + 4 < sizeof(program2)); + if (tex->Target == GL_TEXTURE_RECTANGLE) + texTarget = "RECT"; + else + texTarget = "2D"; + _mesa_snprintf(program2, sizeof(program2), program, texTarget); + + _mesa_GenPrograms(1, &drawpix->StencilFP); + _mesa_BindProgram(GL_FRAGMENT_PROGRAM_ARB, drawpix->StencilFP); + _mesa_ProgramStringARB(GL_FRAGMENT_PROGRAM_ARB, GL_PROGRAM_FORMAT_ASCII_ARB, + strlen(program2), (const GLubyte *) program2); +} + + +/** + * One-time init for drawing depth pixels. + */ +static void +init_draw_depth_pixels(struct gl_context *ctx) +{ + static const char *program = + "!!ARBfp1.0\n" + "PARAM color = program.local[0]; \n" + "TEX result.depth, fragment.texcoord[0], texture[0], %s; \n" + "MOV result.color, color; \n" + "END \n"; + char program2[200]; + struct drawpix_state *drawpix = &ctx->Meta->DrawPix; + struct temp_texture *tex = get_temp_texture(ctx); + const char *texTarget; + + assert(drawpix->DepthFP == 0); + + /* replace %s with "RECT" or "2D" */ + assert(strlen(program) + 4 < sizeof(program2)); + if (tex->Target == GL_TEXTURE_RECTANGLE) + texTarget = "RECT"; + else + texTarget = "2D"; + _mesa_snprintf(program2, sizeof(program2), program, texTarget); + + _mesa_GenPrograms(1, &drawpix->DepthFP); + _mesa_BindProgram(GL_FRAGMENT_PROGRAM_ARB, drawpix->DepthFP); + _mesa_ProgramStringARB(GL_FRAGMENT_PROGRAM_ARB, GL_PROGRAM_FORMAT_ASCII_ARB, + strlen(program2), (const GLubyte *) program2); +} + + +/** + * Meta implementation of ctx->Driver.DrawPixels() in terms + * of texture mapping and polygon rendering. + */ +void +_mesa_meta_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) +{ + struct drawpix_state *drawpix = &ctx->Meta->DrawPix; + struct temp_texture *tex = get_temp_texture(ctx); + const struct gl_pixelstore_attrib unpackSave = ctx->Unpack; + const GLuint origStencilMask = ctx->Stencil.WriteMask[0]; + struct vertex { + GLfloat x, y, z, s, t; + }; + struct vertex verts[4]; + GLenum texIntFormat; + GLboolean fallback, newTex; + GLbitfield metaExtraSave = 0x0; + GLuint vbo; + + /* + * Determine if we can do the glDrawPixels with texture mapping. + */ + fallback = GL_FALSE; + if (ctx->_ImageTransferState || + ctx->Fog.Enabled) { + fallback = GL_TRUE; + } + + if (_mesa_is_color_format(format)) { + /* use more compact format when possible */ + /* XXX disable special case for GL_LUMINANCE for now to work around + * apparent i965 driver bug (see bug #23670). + */ + if (/*format == GL_LUMINANCE ||*/ format == GL_LUMINANCE_ALPHA) + texIntFormat = format; + else + texIntFormat = GL_RGBA; + + /* If we're not supposed to clamp the resulting color, then just + * promote our texture to fully float. We could do better by + * just going for the matching set of channels, in floating + * point. + */ + if (ctx->Color.ClampFragmentColor != GL_TRUE && + ctx->Extensions.ARB_texture_float) + texIntFormat = GL_RGBA32F; + } + else if (_mesa_is_stencil_format(format)) { + if (ctx->Extensions.ARB_fragment_program && + ctx->Pixel.IndexShift == 0 && + ctx->Pixel.IndexOffset == 0 && + type == GL_UNSIGNED_BYTE) { + /* We'll store stencil as alpha. This only works for GLubyte + * image data because of how incoming values are mapped to alpha + * in [0,1]. + */ + texIntFormat = GL_ALPHA; + metaExtraSave = (META_COLOR_MASK | + META_DEPTH_TEST | + META_SHADER | + META_STENCIL_TEST); + } + else { + fallback = GL_TRUE; + } + } + else if (_mesa_is_depth_format(format)) { + if (ctx->Extensions.ARB_depth_texture && + ctx->Extensions.ARB_fragment_program) { + texIntFormat = GL_DEPTH_COMPONENT; + metaExtraSave = (META_SHADER); + } + else { + fallback = GL_TRUE; + } + } + else { + fallback = GL_TRUE; + } + + if (fallback) { + _swrast_DrawPixels(ctx, x, y, width, height, + format, type, unpack, pixels); + return; + } + + /* + * Check image size against max texture size, draw as tiles if needed. + */ + if (width > tex->MaxSize || height > tex->MaxSize) { + tiled_draw_pixels(ctx, tex->MaxSize, x, y, width, height, + format, type, unpack, pixels); + return; + } + + /* Most GL state applies to glDrawPixels (like blending, stencil, etc), + * but a there's a few things we need to override: + */ + _mesa_meta_begin(ctx, (META_RASTERIZATION | + META_SHADER | + META_TEXTURE | + META_TRANSFORM | + META_VERTEX | + META_VIEWPORT | + META_CLAMP_FRAGMENT_COLOR | + metaExtraSave)); + + newTex = alloc_texture(tex, width, height, texIntFormat); + + /* vertex positions, texcoords (after texture allocation!) */ + { + const GLfloat x0 = (GLfloat) x; + const GLfloat y0 = (GLfloat) y; + const GLfloat x1 = x + width * ctx->Pixel.ZoomX; + const GLfloat y1 = y + height * ctx->Pixel.ZoomY; + const GLfloat z = invert_z(ctx->Current.RasterPos[2]); + + verts[0].x = x0; + verts[0].y = y0; + verts[0].z = z; + verts[0].s = 0.0F; + verts[0].t = 0.0F; + verts[1].x = x1; + verts[1].y = y0; + verts[1].z = z; + verts[1].s = tex->Sright; + verts[1].t = 0.0F; + verts[2].x = x1; + verts[2].y = y1; + verts[2].z = z; + verts[2].s = tex->Sright; + verts[2].t = tex->Ttop; + verts[3].x = x0; + verts[3].y = y1; + verts[3].z = z; + verts[3].s = 0.0F; + verts[3].t = tex->Ttop; + } + + if (drawpix->ArrayObj == 0) { + /* one-time setup: create vertex array object */ + _mesa_GenVertexArrays(1, &drawpix->ArrayObj); + } + _mesa_BindVertexArray(drawpix->ArrayObj); + + /* create vertex array buffer */ + _mesa_GenBuffersARB(1, &vbo); + _mesa_BindBufferARB(GL_ARRAY_BUFFER_ARB, vbo); + _mesa_BufferDataARB(GL_ARRAY_BUFFER_ARB, sizeof(verts), + verts, GL_DYNAMIC_DRAW_ARB); + + /* setup vertex arrays */ + _mesa_VertexPointer(3, GL_FLOAT, sizeof(struct vertex), OFFSET(x)); + _mesa_TexCoordPointer(2, GL_FLOAT, sizeof(struct vertex), OFFSET(s)); + _mesa_EnableClientState(GL_VERTEX_ARRAY); + _mesa_EnableClientState(GL_TEXTURE_COORD_ARRAY); + + /* set given unpack params */ + ctx->Unpack = *unpack; + + _mesa_set_enable(ctx, tex->Target, GL_TRUE); + + if (_mesa_is_stencil_format(format)) { + /* Drawing stencil */ + GLint bit; + + if (!drawpix->StencilFP) + init_draw_stencil_pixels(ctx); + + setup_drawpix_texture(ctx, tex, newTex, texIntFormat, width, height, + GL_ALPHA, type, pixels); + + _mesa_ColorMask(GL_FALSE, GL_FALSE, GL_FALSE, GL_FALSE); + + _mesa_set_enable(ctx, GL_STENCIL_TEST, GL_TRUE); + + /* set all stencil bits to 0 */ + _mesa_StencilOp(GL_REPLACE, GL_REPLACE, GL_REPLACE); + _mesa_StencilFunc(GL_ALWAYS, 0, 255); + _mesa_DrawArrays(GL_TRIANGLE_FAN, 0, 4); + + /* set stencil bits to 1 where needed */ + _mesa_StencilOp(GL_KEEP, GL_KEEP, GL_REPLACE); + + _mesa_BindProgram(GL_FRAGMENT_PROGRAM_ARB, drawpix->StencilFP); + _mesa_set_enable(ctx, GL_FRAGMENT_PROGRAM_ARB, GL_TRUE); + + for (bit = 0; bit < ctx->DrawBuffer->Visual.stencilBits; bit++) { + const GLuint mask = 1 << bit; + if (mask & origStencilMask) { + _mesa_StencilFunc(GL_ALWAYS, mask, mask); + _mesa_StencilMask(mask); + + _mesa_ProgramLocalParameter4fARB(GL_FRAGMENT_PROGRAM_ARB, 0, + 255.0 / mask, 0.5, 0.0, 0.0); + + _mesa_DrawArrays(GL_TRIANGLE_FAN, 0, 4); + } + } + } + else if (_mesa_is_depth_format(format)) { + /* Drawing depth */ + if (!drawpix->DepthFP) + init_draw_depth_pixels(ctx); + + _mesa_BindProgram(GL_FRAGMENT_PROGRAM_ARB, drawpix->DepthFP); + _mesa_set_enable(ctx, GL_FRAGMENT_PROGRAM_ARB, GL_TRUE); + + /* polygon color = current raster color */ + _mesa_ProgramLocalParameter4fvARB(GL_FRAGMENT_PROGRAM_ARB, 0, + ctx->Current.RasterColor); + + setup_drawpix_texture(ctx, tex, newTex, texIntFormat, width, height, + format, type, pixels); + + _mesa_DrawArrays(GL_TRIANGLE_FAN, 0, 4); + } + else { + /* Drawing RGBA */ + setup_drawpix_texture(ctx, tex, newTex, texIntFormat, width, height, + format, type, pixels); + _mesa_DrawArrays(GL_TRIANGLE_FAN, 0, 4); + } + + _mesa_set_enable(ctx, tex->Target, GL_FALSE); + + _mesa_DeleteBuffersARB(1, &vbo); + + /* restore unpack params */ + ctx->Unpack = unpackSave; + + _mesa_meta_end(ctx); +} + +static GLboolean +alpha_test_raster_color(struct gl_context *ctx) +{ + GLfloat alpha = ctx->Current.RasterColor[ACOMP]; + GLfloat ref = ctx->Color.AlphaRef; + + switch (ctx->Color.AlphaFunc) { + case GL_NEVER: + return GL_FALSE; + case GL_LESS: + return alpha < ref; + case GL_EQUAL: + return alpha == ref; + case GL_LEQUAL: + return alpha <= ref; + case GL_GREATER: + return alpha > ref; + case GL_NOTEQUAL: + return alpha != ref; + case GL_GEQUAL: + return alpha >= ref; + case GL_ALWAYS: + return GL_TRUE; + default: + assert(0); + return GL_FALSE; + } +} + +/** + * Do glBitmap with a alpha texture quad. Use the alpha test to cull + * the 'off' bits. A bitmap cache as in the gallium/mesa state + * tracker would improve performance a lot. + */ +void +_mesa_meta_Bitmap(struct gl_context *ctx, + GLint x, GLint y, GLsizei width, GLsizei height, + const struct gl_pixelstore_attrib *unpack, + const GLubyte *bitmap1) +{ + struct bitmap_state *bitmap = &ctx->Meta->Bitmap; + struct temp_texture *tex = get_bitmap_temp_texture(ctx); + const GLenum texIntFormat = GL_ALPHA; + const struct gl_pixelstore_attrib unpackSave = *unpack; + GLubyte fg, bg; + struct vertex { + GLfloat x, y, z, s, t, r, g, b, a; + }; + struct vertex verts[4]; + GLboolean newTex; + GLubyte *bitmap8; + + /* + * Check if swrast fallback is needed. + */ + if (ctx->_ImageTransferState || + ctx->FragmentProgram._Enabled || + ctx->Fog.Enabled || + ctx->Texture._EnabledUnits || + width > tex->MaxSize || + height > tex->MaxSize) { + _swrast_Bitmap(ctx, x, y, width, height, unpack, bitmap1); + return; + } + + if (ctx->Color.AlphaEnabled && !alpha_test_raster_color(ctx)) + return; + + /* Most GL state applies to glBitmap (like blending, stencil, etc), + * but a there's a few things we need to override: + */ + _mesa_meta_begin(ctx, (META_ALPHA_TEST | + META_PIXEL_STORE | + META_RASTERIZATION | + META_SHADER | + META_TEXTURE | + META_TRANSFORM | + META_VERTEX | + META_VIEWPORT)); + + if (bitmap->ArrayObj == 0) { + /* one-time setup */ + + /* create vertex array object */ + _mesa_GenVertexArraysAPPLE(1, &bitmap->ArrayObj); + _mesa_BindVertexArrayAPPLE(bitmap->ArrayObj); + + /* create vertex array buffer */ + _mesa_GenBuffersARB(1, &bitmap->VBO); + _mesa_BindBufferARB(GL_ARRAY_BUFFER_ARB, bitmap->VBO); + _mesa_BufferDataARB(GL_ARRAY_BUFFER_ARB, sizeof(verts), + NULL, GL_DYNAMIC_DRAW_ARB); + + /* setup vertex arrays */ + _mesa_VertexPointer(3, GL_FLOAT, sizeof(struct vertex), OFFSET(x)); + _mesa_TexCoordPointer(2, GL_FLOAT, sizeof(struct vertex), OFFSET(s)); + _mesa_ColorPointer(4, GL_FLOAT, sizeof(struct vertex), OFFSET(r)); + _mesa_EnableClientState(GL_VERTEX_ARRAY); + _mesa_EnableClientState(GL_TEXTURE_COORD_ARRAY); + _mesa_EnableClientState(GL_COLOR_ARRAY); + } + else { + _mesa_BindVertexArray(bitmap->ArrayObj); + _mesa_BindBufferARB(GL_ARRAY_BUFFER_ARB, bitmap->VBO); + } + + newTex = alloc_texture(tex, width, height, texIntFormat); + + /* vertex positions, texcoords, colors (after texture allocation!) */ + { + const GLfloat x0 = (GLfloat) x; + const GLfloat y0 = (GLfloat) y; + const GLfloat x1 = (GLfloat) (x + width); + const GLfloat y1 = (GLfloat) (y + height); + const GLfloat z = invert_z(ctx->Current.RasterPos[2]); + GLuint i; + + verts[0].x = x0; + verts[0].y = y0; + verts[0].z = z; + verts[0].s = 0.0F; + verts[0].t = 0.0F; + verts[1].x = x1; + verts[1].y = y0; + verts[1].z = z; + verts[1].s = tex->Sright; + verts[1].t = 0.0F; + verts[2].x = x1; + verts[2].y = y1; + verts[2].z = z; + verts[2].s = tex->Sright; + verts[2].t = tex->Ttop; + verts[3].x = x0; + verts[3].y = y1; + verts[3].z = z; + verts[3].s = 0.0F; + verts[3].t = tex->Ttop; + + for (i = 0; i < 4; i++) { + verts[i].r = ctx->Current.RasterColor[0]; + verts[i].g = ctx->Current.RasterColor[1]; + verts[i].b = ctx->Current.RasterColor[2]; + verts[i].a = ctx->Current.RasterColor[3]; + } + + /* upload new vertex data */ + _mesa_BufferSubDataARB(GL_ARRAY_BUFFER_ARB, 0, sizeof(verts), verts); + } + + /* choose different foreground/background alpha values */ + CLAMPED_FLOAT_TO_UBYTE(fg, ctx->Current.RasterColor[ACOMP]); + bg = (fg > 127 ? 0 : 255); + + bitmap1 = _mesa_map_pbo_source(ctx, &unpackSave, bitmap1); + if (!bitmap1) { + _mesa_meta_end(ctx); + return; + } + + bitmap8 = (GLubyte *) malloc(width * height); + if (bitmap8) { + memset(bitmap8, bg, width * height); + _mesa_expand_bitmap(width, height, &unpackSave, bitmap1, + bitmap8, width, fg); + + _mesa_set_enable(ctx, tex->Target, GL_TRUE); + + _mesa_set_enable(ctx, GL_ALPHA_TEST, GL_TRUE); + _mesa_AlphaFunc(GL_NOTEQUAL, UBYTE_TO_FLOAT(bg)); + + setup_drawpix_texture(ctx, tex, newTex, texIntFormat, width, height, + GL_ALPHA, GL_UNSIGNED_BYTE, bitmap8); + + _mesa_DrawArrays(GL_TRIANGLE_FAN, 0, 4); + + _mesa_set_enable(ctx, tex->Target, GL_FALSE); + + free(bitmap8); + } + + _mesa_unmap_pbo_source(ctx, &unpackSave); + + _mesa_meta_end(ctx); +} + + +/** + * Check if the call to _mesa_meta_GenerateMipmap() will require a + * software fallback. The fallback path will require that the texture + * images are mapped. + * \return GL_TRUE if a fallback is needed, GL_FALSE otherwise + */ +GLboolean +_mesa_meta_check_generate_mipmap_fallback(struct gl_context *ctx, GLenum target, + struct gl_texture_object *texObj) +{ + const GLuint fboSave = ctx->DrawBuffer->Name; + struct gen_mipmap_state *mipmap = &ctx->Meta->Mipmap; + struct gl_texture_image *baseImage; + GLuint srcLevel; + GLenum status; + + /* check for fallbacks */ + if (!ctx->Extensions.EXT_framebuffer_object || + target == GL_TEXTURE_3D) { + return GL_TRUE; + } + + srcLevel = texObj->BaseLevel; + baseImage = _mesa_select_tex_image(ctx, texObj, target, srcLevel); + if (!baseImage || _mesa_is_format_compressed(baseImage->TexFormat)) { + return GL_TRUE; + } + + /* + * Test that we can actually render in the texture's format. + */ + if (!mipmap->FBO) + _mesa_GenFramebuffersEXT(1, &mipmap->FBO); + _mesa_BindFramebufferEXT(GL_FRAMEBUFFER_EXT, mipmap->FBO); + + if (target == GL_TEXTURE_1D) { + _mesa_FramebufferTexture1DEXT(GL_FRAMEBUFFER_EXT, + GL_COLOR_ATTACHMENT0_EXT, + target, texObj->Name, srcLevel); + } +#if 0 + /* other work is needed to enable 3D mipmap generation */ + else if (target == GL_TEXTURE_3D) { + GLint zoffset = 0; + _mesa_FramebufferTexture3DEXT(GL_FRAMEBUFFER_EXT, + GL_COLOR_ATTACHMENT0_EXT, + target, texObj->Name, srcLevel, zoffset); + } +#endif + else { + /* 2D / cube */ + _mesa_FramebufferTexture2DEXT(GL_FRAMEBUFFER_EXT, + GL_COLOR_ATTACHMENT0_EXT, + target, texObj->Name, srcLevel); + } + + status = _mesa_CheckFramebufferStatusEXT(GL_FRAMEBUFFER_EXT); + + _mesa_BindFramebufferEXT(GL_FRAMEBUFFER_EXT, fboSave); + + if (status != GL_FRAMEBUFFER_COMPLETE_EXT) { + return GL_TRUE; + } + + return GL_FALSE; +} + + +/** + * Called via ctx->Driver.GenerateMipmap() + * Note: texture borders and 3D texture support not yet complete. + */ +void +_mesa_meta_GenerateMipmap(struct gl_context *ctx, GLenum target, + struct gl_texture_object *texObj) +{ + struct gen_mipmap_state *mipmap = &ctx->Meta->Mipmap; + struct vertex { + GLfloat x, y, s, t, r; + }; + struct vertex verts[4]; + const GLuint baseLevel = texObj->BaseLevel; + const GLuint maxLevel = texObj->MaxLevel; + const GLenum minFilterSave = texObj->Sampler.MinFilter; + const GLenum magFilterSave = texObj->Sampler.MagFilter; + const GLint maxLevelSave = texObj->MaxLevel; + const GLboolean genMipmapSave = texObj->GenerateMipmap; + const GLenum wrapSSave = texObj->Sampler.WrapS; + const GLenum wrapTSave = texObj->Sampler.WrapT; + const GLenum wrapRSave = texObj->Sampler.WrapR; + const GLuint fboSave = ctx->DrawBuffer->Name; + const GLuint original_active_unit = ctx->Texture.CurrentUnit; + GLenum faceTarget; + GLuint dstLevel; + GLuint border = 0; + + if (_mesa_meta_check_generate_mipmap_fallback(ctx, target, texObj)) { + _mesa_generate_mipmap(ctx, target, texObj); + return; + } + + if (target >= GL_TEXTURE_CUBE_MAP_POSITIVE_X && + target <= GL_TEXTURE_CUBE_MAP_NEGATIVE_Z) { + faceTarget = target; + target = GL_TEXTURE_CUBE_MAP; + } + else { + faceTarget = target; + } + + _mesa_meta_begin(ctx, META_ALL); + + if (original_active_unit != 0) + _mesa_BindTexture(target, texObj->Name); + + if (mipmap->ArrayObj == 0) { + /* one-time setup */ + + /* create vertex array object */ + _mesa_GenVertexArraysAPPLE(1, &mipmap->ArrayObj); + _mesa_BindVertexArrayAPPLE(mipmap->ArrayObj); + + /* create vertex array buffer */ + _mesa_GenBuffersARB(1, &mipmap->VBO); + _mesa_BindBufferARB(GL_ARRAY_BUFFER_ARB, mipmap->VBO); + _mesa_BufferDataARB(GL_ARRAY_BUFFER_ARB, sizeof(verts), + NULL, GL_DYNAMIC_DRAW_ARB); + + /* setup vertex arrays */ + _mesa_VertexPointer(2, GL_FLOAT, sizeof(struct vertex), OFFSET(x)); + _mesa_TexCoordPointer(3, GL_FLOAT, sizeof(struct vertex), OFFSET(s)); + _mesa_EnableClientState(GL_VERTEX_ARRAY); + _mesa_EnableClientState(GL_TEXTURE_COORD_ARRAY); + } + else { + _mesa_BindVertexArray(mipmap->ArrayObj); + _mesa_BindBufferARB(GL_ARRAY_BUFFER_ARB, mipmap->VBO); + } + + if (!mipmap->FBO) { + _mesa_GenFramebuffersEXT(1, &mipmap->FBO); + } + _mesa_BindFramebufferEXT(GL_FRAMEBUFFER_EXT, mipmap->FBO); + + _mesa_TexParameteri(target, GL_TEXTURE_MIN_FILTER, GL_LINEAR_MIPMAP_LINEAR); + _mesa_TexParameteri(target, GL_TEXTURE_MAG_FILTER, GL_LINEAR); + _mesa_TexParameteri(target, GL_GENERATE_MIPMAP, GL_FALSE); + _mesa_TexParameteri(target, GL_TEXTURE_WRAP_S, GL_CLAMP_TO_EDGE); + _mesa_TexParameteri(target, GL_TEXTURE_WRAP_T, GL_CLAMP_TO_EDGE); + _mesa_TexParameteri(target, GL_TEXTURE_WRAP_R, GL_CLAMP_TO_EDGE); + + _mesa_set_enable(ctx, target, GL_TRUE); + + /* setup texcoords once (XXX what about border?) */ + switch (faceTarget) { + case GL_TEXTURE_1D: + case GL_TEXTURE_2D: + verts[0].s = 0.0F; + verts[0].t = 0.0F; + verts[0].r = 0.0F; + verts[1].s = 1.0F; + verts[1].t = 0.0F; + verts[1].r = 0.0F; + verts[2].s = 1.0F; + verts[2].t = 1.0F; + verts[2].r = 0.0F; + verts[3].s = 0.0F; + verts[3].t = 1.0F; + verts[3].r = 0.0F; + break; + case GL_TEXTURE_3D: + abort(); + break; + default: + /* cube face */ + { + static const GLfloat st[4][2] = { + {0.0f, 0.0f}, {1.0f, 0.0f}, {1.0f, 1.0f}, {0.0f, 1.0f} + }; + GLuint i; + + /* loop over quad verts */ + for (i = 0; i < 4; i++) { + /* Compute sc = +/-scale and tc = +/-scale. + * Not +/-1 to avoid cube face selection ambiguity near the edges, + * though that can still sometimes happen with this scale factor... + */ + const GLfloat scale = 0.9999f; + const GLfloat sc = (2.0f * st[i][0] - 1.0f) * scale; + const GLfloat tc = (2.0f * st[i][1] - 1.0f) * scale; + + switch (faceTarget) { + case GL_TEXTURE_CUBE_MAP_POSITIVE_X: + verts[i].s = 1.0f; + verts[i].t = -tc; + verts[i].r = -sc; + break; + case GL_TEXTURE_CUBE_MAP_NEGATIVE_X: + verts[i].s = -1.0f; + verts[i].t = -tc; + verts[i].r = sc; + break; + case GL_TEXTURE_CUBE_MAP_POSITIVE_Y: + verts[i].s = sc; + verts[i].t = 1.0f; + verts[i].r = tc; + break; + case GL_TEXTURE_CUBE_MAP_NEGATIVE_Y: + verts[i].s = sc; + verts[i].t = -1.0f; + verts[i].r = -tc; + break; + case GL_TEXTURE_CUBE_MAP_POSITIVE_Z: + verts[i].s = sc; + verts[i].t = -tc; + verts[i].r = 1.0f; + break; + case GL_TEXTURE_CUBE_MAP_NEGATIVE_Z: + verts[i].s = -sc; + verts[i].t = -tc; + verts[i].r = -1.0f; + break; + default: + assert(0); + } + } + } + } + + _mesa_set_enable(ctx, target, GL_TRUE); + + /* setup vertex positions */ + { + verts[0].x = 0.0F; + verts[0].y = 0.0F; + verts[1].x = 1.0F; + verts[1].y = 0.0F; + verts[2].x = 1.0F; + verts[2].y = 1.0F; + verts[3].x = 0.0F; + verts[3].y = 1.0F; + + /* upload new vertex data */ + _mesa_BufferSubDataARB(GL_ARRAY_BUFFER_ARB, 0, sizeof(verts), verts); + } + + /* setup projection matrix */ + _mesa_MatrixMode(GL_PROJECTION); + _mesa_LoadIdentity(); + _mesa_Ortho(0.0, 1.0, 0.0, 1.0, -1.0, 1.0); + + /* texture is already locked, unlock now */ + _mesa_unlock_texture(ctx, texObj); + + for (dstLevel = baseLevel + 1; dstLevel <= maxLevel; dstLevel++) { + const struct gl_texture_image *srcImage; + const GLuint srcLevel = dstLevel - 1; + GLsizei srcWidth, srcHeight, srcDepth; + GLsizei dstWidth, dstHeight, dstDepth; + GLenum status; + + srcImage = _mesa_select_tex_image(ctx, texObj, faceTarget, srcLevel); + assert(srcImage->Border == 0); /* XXX we can fix this */ + + /* src size w/out border */ + srcWidth = srcImage->Width - 2 * border; + srcHeight = srcImage->Height - 2 * border; + srcDepth = srcImage->Depth - 2 * border; + + /* new dst size w/ border */ + dstWidth = MAX2(1, srcWidth / 2) + 2 * border; + dstHeight = MAX2(1, srcHeight / 2) + 2 * border; + dstDepth = MAX2(1, srcDepth / 2) + 2 * border; + + if (dstWidth == srcImage->Width && + dstHeight == srcImage->Height && + dstDepth == srcImage->Depth) { + /* all done */ + break; + } + + /* Set MaxLevel large enough to hold the new level when we allocate it */ + _mesa_TexParameteri(target, GL_TEXTURE_MAX_LEVEL, dstLevel); + + /* Create empty dest image */ + if (target == GL_TEXTURE_1D) { + _mesa_TexImage1D(target, dstLevel, srcImage->InternalFormat, + dstWidth, border, + GL_RGBA, GL_UNSIGNED_BYTE, NULL); + } + else if (target == GL_TEXTURE_3D) { + _mesa_TexImage3D(target, dstLevel, srcImage->InternalFormat, + dstWidth, dstHeight, dstDepth, border, + GL_RGBA, GL_UNSIGNED_BYTE, NULL); + } + else { + /* 2D or cube */ + _mesa_TexImage2D(faceTarget, dstLevel, srcImage->InternalFormat, + dstWidth, dstHeight, border, + GL_RGBA, GL_UNSIGNED_BYTE, NULL); + + if (target == GL_TEXTURE_CUBE_MAP) { + /* If texturing from a cube, we need to make sure all src faces + * have been defined (even if we're not sampling from them.) + * Otherwise the texture object will be 'incomplete' and + * texturing from it will not be allowed. + */ + GLuint face; + for (face = 0; face < 6; face++) { + if (!texObj->Image[face][srcLevel] || + texObj->Image[face][srcLevel]->Width != srcWidth) { + _mesa_TexImage2D(GL_TEXTURE_CUBE_MAP_POSITIVE_X + face, + srcLevel, srcImage->InternalFormat, + srcWidth, srcHeight, border, + GL_RGBA, GL_UNSIGNED_BYTE, NULL); + } + } + } + } + + /* limit minification to src level */ + _mesa_TexParameteri(target, GL_TEXTURE_MAX_LEVEL, srcLevel); + + /* Set to draw into the current dstLevel */ + if (target == GL_TEXTURE_1D) { + _mesa_FramebufferTexture1DEXT(GL_FRAMEBUFFER_EXT, + GL_COLOR_ATTACHMENT0_EXT, + target, + texObj->Name, + dstLevel); + } + else if (target == GL_TEXTURE_3D) { + GLint zoffset = 0; /* XXX unfinished */ + _mesa_FramebufferTexture3DEXT(GL_FRAMEBUFFER_EXT, + GL_COLOR_ATTACHMENT0_EXT, + target, + texObj->Name, + dstLevel, zoffset); + } + else { + /* 2D / cube */ + _mesa_FramebufferTexture2DEXT(GL_FRAMEBUFFER_EXT, + GL_COLOR_ATTACHMENT0_EXT, + faceTarget, + texObj->Name, + dstLevel); + } + + _mesa_DrawBuffer(GL_COLOR_ATTACHMENT0_EXT); + + /* sanity check */ + status = _mesa_CheckFramebufferStatusEXT(GL_FRAMEBUFFER_EXT); + if (status != GL_FRAMEBUFFER_COMPLETE_EXT) { + abort(); + break; + } + + assert(dstWidth == ctx->DrawBuffer->Width); + assert(dstHeight == ctx->DrawBuffer->Height); + + /* setup viewport */ + _mesa_set_viewport(ctx, 0, 0, dstWidth, dstHeight); + + _mesa_DrawArrays(GL_TRIANGLE_FAN, 0, 4); + } + + _mesa_lock_texture(ctx, texObj); /* relock */ + + _mesa_meta_end(ctx); + + _mesa_TexParameteri(target, GL_TEXTURE_MIN_FILTER, minFilterSave); + _mesa_TexParameteri(target, GL_TEXTURE_MAG_FILTER, magFilterSave); + _mesa_TexParameteri(target, GL_TEXTURE_MAX_LEVEL, maxLevelSave); + _mesa_TexParameteri(target, GL_GENERATE_MIPMAP, genMipmapSave); + _mesa_TexParameteri(target, GL_TEXTURE_WRAP_S, wrapSSave); + _mesa_TexParameteri(target, GL_TEXTURE_WRAP_T, wrapTSave); + _mesa_TexParameteri(target, GL_TEXTURE_WRAP_R, wrapRSave); + + _mesa_BindFramebufferEXT(GL_FRAMEBUFFER_EXT, fboSave); +} + + +/** + * Determine the GL data type to use for the temporary image read with + * ReadPixels() and passed to Tex[Sub]Image(). + */ +static GLenum +get_temp_image_type(struct gl_context *ctx, GLenum baseFormat) +{ + switch (baseFormat) { + case GL_RGBA: + case GL_RGB: + case GL_ALPHA: + case GL_LUMINANCE: + case GL_LUMINANCE_ALPHA: + case GL_INTENSITY: + if (ctx->DrawBuffer->Visual.redBits <= 8) + return GL_UNSIGNED_BYTE; + else if (ctx->DrawBuffer->Visual.redBits <= 8) + return GL_UNSIGNED_SHORT; + else + return GL_FLOAT; + case GL_DEPTH_COMPONENT: + return GL_UNSIGNED_INT; + case GL_DEPTH_STENCIL: + return GL_UNSIGNED_INT_24_8; + default: + _mesa_problem(ctx, "Unexpected format in get_temp_image_type()"); + return 0; + } +} + + +/** + * Helper for _mesa_meta_CopyTexImage1/2D() functions. + * Have to be careful with locking and meta state for pixel transfer. + */ +static void +copy_tex_image(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; + GLenum format, type; + GLint bpp; + void *buf; + + texObj = _mesa_get_current_tex_object(ctx, target); + texImage = _mesa_get_tex_image(ctx, texObj, target, level); + + /* Choose format/type for temporary image buffer */ + format = _mesa_base_tex_format(ctx, internalFormat); + type = get_temp_image_type(ctx, format); + bpp = _mesa_bytes_per_pixel(format, type); + if (bpp <= 0) { + _mesa_problem(ctx, "Bad bpp in meta copy_tex_image()"); + return; + } + + /* + * Alloc image buffer (XXX could use a PBO) + */ + buf = malloc(width * height * bpp); + if (!buf) { + _mesa_error(ctx, GL_OUT_OF_MEMORY, "glCopyTexImage%uD", dims); + return; + } + + _mesa_unlock_texture(ctx, texObj); /* need to unlock first */ + + /* + * Read image from framebuffer (disable pixel transfer ops) + */ + _mesa_meta_begin(ctx, META_PIXEL_STORE | META_PIXEL_TRANSFER); + ctx->Driver.ReadPixels(ctx, x, y, width, height, + format, type, &ctx->Pack, buf); + _mesa_meta_end(ctx); + + if (texImage->Data) { + ctx->Driver.FreeTexImageData(ctx, texImage); + } + + /* The texture's format was already chosen in _mesa_CopyTexImage() */ + ASSERT(texImage->TexFormat != MESA_FORMAT_NONE); + + /* + * Store texture data (with pixel transfer ops) + */ + _mesa_meta_begin(ctx, META_PIXEL_STORE); + + _mesa_update_state(ctx); /* to update pixel transfer state */ + + if (target == GL_TEXTURE_1D) { + ctx->Driver.TexImage1D(ctx, target, level, internalFormat, + width, border, format, type, + buf, &ctx->Unpack, texObj, texImage); + } + else { + ctx->Driver.TexImage2D(ctx, target, level, internalFormat, + width, height, border, format, type, + buf, &ctx->Unpack, texObj, texImage); + } + _mesa_meta_end(ctx); + + _mesa_lock_texture(ctx, texObj); /* re-lock */ + + free(buf); +} + + +void +_mesa_meta_CopyTexImage1D(struct gl_context *ctx, GLenum target, GLint level, + GLenum internalFormat, GLint x, GLint y, + GLsizei width, GLint border) +{ + copy_tex_image(ctx, 1, target, level, internalFormat, x, y, + width, 1, border); +} + + +void +_mesa_meta_CopyTexImage2D(struct gl_context *ctx, GLenum target, GLint level, + GLenum internalFormat, GLint x, GLint y, + GLsizei width, GLsizei height, GLint border) +{ + copy_tex_image(ctx, 2, target, level, internalFormat, x, y, + width, height, border); +} + + + +/** + * Helper for _mesa_meta_CopyTexSubImage1/2/3D() functions. + * Have to be careful with locking and meta state for pixel transfer. + */ +static void +copy_tex_sub_image(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; + GLenum format, type; + GLint bpp; + void *buf; + + texObj = _mesa_get_current_tex_object(ctx, target); + texImage = _mesa_select_tex_image(ctx, texObj, target, level); + + /* Choose format/type for temporary image buffer */ + format = _mesa_get_format_base_format(texImage->TexFormat); + type = get_temp_image_type(ctx, format); + bpp = _mesa_bytes_per_pixel(format, type); + if (bpp <= 0) { + _mesa_problem(ctx, "Bad bpp in meta copy_tex_sub_image()"); + return; + } + + /* + * Alloc image buffer (XXX could use a PBO) + */ + buf = malloc(width * height * bpp); + if (!buf) { + _mesa_error(ctx, GL_OUT_OF_MEMORY, "glCopyTexSubImage%uD", dims); + return; + } + + _mesa_unlock_texture(ctx, texObj); /* need to unlock first */ + + /* + * Read image from framebuffer (disable pixel transfer ops) + */ + _mesa_meta_begin(ctx, META_PIXEL_STORE | META_PIXEL_TRANSFER); + ctx->Driver.ReadPixels(ctx, x, y, width, height, + format, type, &ctx->Pack, buf); + _mesa_meta_end(ctx); + + _mesa_update_state(ctx); /* to update pixel transfer state */ + + /* + * Store texture data (with pixel transfer ops) + */ + _mesa_meta_begin(ctx, META_PIXEL_STORE); + if (target == GL_TEXTURE_1D) { + ctx->Driver.TexSubImage1D(ctx, target, level, xoffset, + width, format, type, buf, + &ctx->Unpack, texObj, texImage); + } + else if (target == GL_TEXTURE_3D) { + ctx->Driver.TexSubImage3D(ctx, target, level, xoffset, yoffset, zoffset, + width, height, 1, format, type, buf, + &ctx->Unpack, texObj, texImage); + } + else { + ctx->Driver.TexSubImage2D(ctx, target, level, xoffset, yoffset, + width, height, format, type, buf, + &ctx->Unpack, texObj, texImage); + } + _mesa_meta_end(ctx); + + _mesa_lock_texture(ctx, texObj); /* re-lock */ + + free(buf); +} + + +void +_mesa_meta_CopyTexSubImage1D(struct gl_context *ctx, GLenum target, GLint level, + GLint xoffset, + GLint x, GLint y, GLsizei width) +{ + copy_tex_sub_image(ctx, 1, target, level, xoffset, 0, 0, + x, y, width, 1); +} + + +void +_mesa_meta_CopyTexSubImage2D(struct gl_context *ctx, GLenum target, GLint level, + GLint xoffset, GLint yoffset, + GLint x, GLint y, + GLsizei width, GLsizei height) +{ + copy_tex_sub_image(ctx, 2, target, level, xoffset, yoffset, 0, + x, y, width, height); +} + + +void +_mesa_meta_CopyTexSubImage3D(struct gl_context *ctx, GLenum target, GLint level, + GLint xoffset, GLint yoffset, GLint zoffset, + GLint x, GLint y, + GLsizei width, GLsizei height) +{ + copy_tex_sub_image(ctx, 3, target, level, xoffset, yoffset, zoffset, + x, y, width, height); +} + + +void +_mesa_meta_CopyColorTable(struct gl_context *ctx, + GLenum target, GLenum internalformat, + GLint x, GLint y, GLsizei width) +{ + GLfloat *buf; + + buf = (GLfloat *) malloc(width * 4 * sizeof(GLfloat)); + if (!buf) { + _mesa_error(ctx, GL_OUT_OF_MEMORY, "glCopyColorTable"); + return; + } + + /* + * Read image from framebuffer (disable pixel transfer ops) + */ + _mesa_meta_begin(ctx, META_PIXEL_STORE | META_PIXEL_TRANSFER); + ctx->Driver.ReadPixels(ctx, x, y, width, 1, + GL_RGBA, GL_FLOAT, &ctx->Pack, buf); + + _mesa_ColorTable(target, internalformat, width, GL_RGBA, GL_FLOAT, buf); + + _mesa_meta_end(ctx); + + free(buf); +} + + +void +_mesa_meta_CopyColorSubTable(struct gl_context *ctx,GLenum target, GLsizei start, + GLint x, GLint y, GLsizei width) +{ + GLfloat *buf; + + buf = (GLfloat *) malloc(width * 4 * sizeof(GLfloat)); + if (!buf) { + _mesa_error(ctx, GL_OUT_OF_MEMORY, "glCopyColorSubTable"); + return; + } + + /* + * Read image from framebuffer (disable pixel transfer ops) + */ + _mesa_meta_begin(ctx, META_PIXEL_STORE | META_PIXEL_TRANSFER); + ctx->Driver.ReadPixels(ctx, x, y, width, 1, + GL_RGBA, GL_FLOAT, &ctx->Pack, buf); + + _mesa_ColorSubTable(target, start, width, GL_RGBA, GL_FLOAT, buf); + + _mesa_meta_end(ctx); + + free(buf); +} diff --git a/xorg-server/hw/kdrive/ephyr/man/Xephyr.man b/xorg-server/hw/kdrive/ephyr/man/Xephyr.man index 8e7bfd550..12c9f58bc 100644 --- a/xorg-server/hw/kdrive/ephyr/man/Xephyr.man +++ b/xorg-server/hw/kdrive/ephyr/man/Xephyr.man @@ -39,6 +39,8 @@ uses the host X server window as "framebuffer" via fast SHM XImages. It also has support for "visually" debugging what the server is painting. .SH OPTIONS +The server accepts all the standard options of Xserver(__appmansuffix__) +and the following additional options: .TP 8 .BI -screen " width" x height sets the screen size. diff --git a/xorg-server/hw/xquartz/GL/indirect.c b/xorg-server/hw/xquartz/GL/indirect.c index 6d87b5fa4..ce49a9f95 100644 --- a/xorg-server/hw/xquartz/GL/indirect.c +++ b/xorg-server/hw/xquartz/GL/indirect.c @@ -2,7 +2,7 @@ * GLX implementation that uses Apple's OpenGL.framework
* (Indirect rendering path -- it's also used for some direct mode code too)
*
- * Copyright (c) 2007, 2008, 2009 Apple Inc.
+ * Copyright (c) 2007-2011 Apple Inc.
* Copyright (c) 2004 Torrey T. Lyons. All Rights Reserved.
* Copyright (c) 2002 Greg Parker. All Rights Reserved.
*
@@ -35,129 +35,34 @@ #include <dix-config.h>
#endif
-#include "dri.h"
-
#include <AvailabilityMacros.h>
-#define GL_GLEXT_WUNDEF_SUPPORT
+#include <dlfcn.h>
#include <OpenGL/OpenGL.h>
-#include <OpenGL/gl.h>
-#include <OpenGL/glext.h>
-#include <OpenGL/CGLContext.h>
-
-/* These next few GL_EXT pre-processing blocks are to explicitly define
- * these symbols to 0 if they are not set by OpenGL.framework. This
- * prevents the X11 glext.h from setting them to 1.
- */
-
-#ifndef GL_EXT_fragment_shader
-#define GL_EXT_fragment_shader 0
-#endif
-
-#ifndef GL_EXT_blend_equation_separate
-#define GL_EXT_blend_equation_separate 0
-#endif
-
-#ifndef GL_EXT_blend_func_separate
-#define GL_EXT_blend_func_separate 0
-#endif
-
-#ifndef GL_EXT_depth_bounds_test
-#define GL_EXT_depth_bounds_test 0
-#endif
-
-#ifndef GL_EXT_compiled_vertex_array
-#define GL_EXT_compiled_vertex_array 0
-#endif
-
-#ifndef GL_EXT_cull_vertex
-#define GL_EXT_cull_vertex 0
-#endif
-
-#ifndef GL_EXT_fog_coord
-#define GL_EXT_fog_coord 0
-#endif
-
-#ifndef GL_EXT_framebuffer_blit
-#define GL_EXT_framebuffer_blit 0
-#endif
-
-#ifndef GL_EXT_framebuffer_object
-#define GL_EXT_framebuffer_object 0
-#endif
-
-#ifndef GL_EXT_gpu_program_parameters
-#define GL_EXT_gpu_program_parameters 0
-#endif
-
-#ifndef GL_EXT_multi_draw_arrays
-#define GL_EXT_multi_draw_arrays 0
-#endif
-
-#ifndef GL_EXT_point_parameters
-#define GL_EXT_point_parameters 0
-#endif
-
-#ifndef GL_EXT_polygon_offset
-#define GL_EXT_polygon_offset 0
-#endif
-
-#ifndef GL_EXT_secondary_color
-#define GL_EXT_secondary_color 0
-#endif
-
-#ifndef GL_EXT_stencil_two_side
-#define GL_EXT_stencil_two_side 0
-#endif
-
-#ifndef GL_EXT_timer_query
-#define GL_EXT_timer_query 0
-#endif
-
-#ifndef GL_EXT_vertex_array
-#define GL_EXT_vertex_array 0
-#endif
-
-/* Tiger PPC doesn't have the associated symbols, but glext.h says it does. Liars!
- * http://trac.macports.org/ticket/20638
- */
-#if defined(__ppc__) && MAC_OS_X_VERSION_MIN_REQUIRED < 1050
-#undef GL_EXT_gpu_program_parameters
-#define GL_EXT_gpu_program_parameters 0
-#endif
+#include <OpenGL/gl.h> /* Just to prevent glxserver.h from loading mesa's and colliding with OpenGL.h */
+#include <X11/Xproto.h>
#include <GL/glxproto.h>
-#include <windowstr.h>
-#include <resource.h>
-#include <GL/glxint.h>
-#include <GL/glxtokens.h>
-#include <scrnintstr.h>
+
#include <glxserver.h>
-#include <glxscreens.h>
-#include <glxdrawable.h>
-#include <glxcontext.h>
-#include <glxext.h>
#include <glxutil.h>
-#include <GL/internal/glcore.h>
-#include "x-hash.h"
-#include "x-list.h"
-
-//#include "capabilities.h"
-#include "visualConfigs.h"
typedef unsigned long long GLuint64EXT;
typedef long long GLint64EXT;
#include <dispatch.h>
-#include <Xplugin.h>
#include <glapi.h>
-#include <glapitable.h>
-__GLXprovider * GlxGetDRISWrastProvider (void);
+#include "x-hash.h"
+
+#include "visualConfigs.h"
+#include "dri.h"
#include "darwin.h"
#define GLAQUA_DEBUG_MSG(msg, args...) ASL_LOG(ASL_LEVEL_DEBUG, "GLXAqua", msg, ##args)
+__GLXprovider * GlxGetDRISWrastProvider (void);
+
static void setup_dispatch_table(void);
GLuint __glFloorLog2(GLuint val);
void warn_func(void * p1, char *format, ...);
@@ -673,345 +578,345 @@ static void setup_dispatch_table(void) { assert(disp);
/* to update:
- * for f in $(grep 'define SET_' ../../../glx/dispatch.h | cut -f2 -d' ' | cut -f1 -d\( | sort -u); do grep -q $f indirect.c || echo $f ; done | grep -v by_offset | sed 's:SET_\(.*\)$:SET_\1(disp, gl\1)\;:' | pbcopy
+ * for f in $(grep 'define SET_' ../../../glx/dispatch.h | cut -f2 -d' ' | cut -f1 -d\( | sort -u); do grep -q $f indirect.c && echo $f ; done | grep -v by_offset | sed 's:SET_\(.*\)$:SET_\1(disp, dlsym(RTLD_DEFAULT, "gl\1"))\;:'
*/
- SET_Accum(disp, glAccum);
- SET_AlphaFunc(disp, glAlphaFunc);
- SET_AreTexturesResident(disp, glAreTexturesResident);
- SET_ArrayElement(disp, glArrayElement);
- SET_Begin(disp, glBegin);
- SET_BindTexture(disp, glBindTexture);
- SET_Bitmap(disp, glBitmap);
- SET_BlendColor(disp, glBlendColor);
- SET_BlendEquation(disp, glBlendEquation);
- SET_BlendFunc(disp, glBlendFunc);
- SET_CallList(disp, glCallList);
- SET_CallLists(disp, glCallLists);
- SET_Clear(disp, glClear);
- SET_ClearAccum(disp, glClearAccum);
- SET_ClearColor(disp, glClearColor);
- SET_ClearDepth(disp, glClearDepth);
- SET_ClearIndex(disp, glClearIndex);
- SET_ClearStencil(disp, glClearStencil);
- SET_ClipPlane(disp, glClipPlane);
- SET_Color3b(disp, glColor3b);
- SET_Color3bv(disp, glColor3bv);
- SET_Color3d(disp, glColor3d);
- SET_Color3dv(disp, glColor3dv);
- SET_Color3f(disp, glColor3f);
- SET_Color3fv(disp, glColor3fv);
- SET_Color3i(disp, glColor3i);
- SET_Color3iv(disp, glColor3iv);
- SET_Color3s(disp, glColor3s);
- SET_Color3sv(disp, glColor3sv);
- SET_Color3ub(disp, glColor3ub);
- SET_Color3ubv(disp, glColor3ubv);
- SET_Color3ui(disp, glColor3ui);
- SET_Color3uiv(disp, glColor3uiv);
- SET_Color3us(disp, glColor3us);
- SET_Color3usv(disp, glColor3usv);
- SET_Color4b(disp, glColor4b);
- SET_Color4bv(disp, glColor4bv);
- SET_Color4d(disp, glColor4d);
- SET_Color4dv(disp, glColor4dv);
- SET_Color4f(disp, glColor4f);
- SET_Color4fv(disp, glColor4fv);
- SET_Color4i(disp, glColor4i);
- SET_Color4iv(disp, glColor4iv);
- SET_Color4s(disp, glColor4s);
- SET_Color4sv(disp, glColor4sv);
- SET_Color4ub(disp, glColor4ub);
- SET_Color4ubv(disp, glColor4ubv);
- SET_Color4ui(disp, glColor4ui);
- SET_Color4uiv(disp, glColor4uiv);
- SET_Color4us(disp, glColor4us);
- SET_Color4usv(disp, glColor4usv);
- SET_ColorMask(disp, glColorMask);
- SET_ColorMaterial(disp, glColorMaterial);
- SET_ColorPointer(disp, glColorPointer);
- SET_ColorSubTable(disp, glColorSubTable);
- SET_ColorTable(disp, glColorTable);
- SET_ColorTableParameterfv(disp, glColorTableParameterfv);
- SET_ColorTableParameteriv(disp, glColorTableParameteriv);
- SET_ConvolutionFilter1D(disp, glConvolutionFilter1D);
- SET_ConvolutionFilter2D(disp, glConvolutionFilter2D);
- SET_ConvolutionParameterf(disp, glConvolutionParameterf);
- SET_ConvolutionParameterfv(disp, glConvolutionParameterfv);
- SET_ConvolutionParameteri(disp, glConvolutionParameteri);
- SET_ConvolutionParameteriv(disp, glConvolutionParameteriv);
- SET_CopyColorSubTable(disp, glCopyColorSubTable);
- SET_CopyColorTable(disp, glCopyColorTable);
- SET_CopyConvolutionFilter1D(disp, glCopyConvolutionFilter1D);
- SET_CopyConvolutionFilter2D(disp, glCopyConvolutionFilter2D);
- SET_CopyPixels(disp, glCopyPixels);
- SET_CopyTexImage1D(disp, glCopyTexImage1D);
- SET_CopyTexImage2D(disp, glCopyTexImage2D);
- SET_CopyTexSubImage1D(disp, glCopyTexSubImage1D);
- SET_CopyTexSubImage2D(disp, glCopyTexSubImage2D);
- SET_CopyTexSubImage3D(disp, glCopyTexSubImage3D);
- SET_CullFace(disp, glCullFace);
- SET_DeleteLists(disp, glDeleteLists);
- SET_DeleteTextures(disp, glDeleteTextures);
- SET_DepthFunc(disp, glDepthFunc);
- SET_DepthMask(disp, glDepthMask);
- SET_DepthRange(disp, glDepthRange);
- SET_Disable(disp, glDisable);
- SET_DisableClientState(disp, glDisableClientState);
- SET_DrawArrays(disp, glDrawArrays);
- SET_DrawBuffer(disp, glDrawBuffer);
- SET_DrawElements(disp, glDrawElements);
- SET_DrawPixels(disp, glDrawPixels);
- SET_DrawRangeElements(disp, glDrawRangeElements);
- SET_EdgeFlag(disp, glEdgeFlag);
- SET_EdgeFlagPointer(disp, glEdgeFlagPointer);
- SET_EdgeFlagv(disp, glEdgeFlagv);
- SET_Enable(disp, glEnable);
- SET_EnableClientState(disp, glEnableClientState);
- SET_End(disp, glEnd);
- SET_EndList(disp, glEndList);
- SET_EvalCoord1d(disp, glEvalCoord1d);
- SET_EvalCoord1dv(disp, glEvalCoord1dv);
- SET_EvalCoord1f(disp, glEvalCoord1f);
- SET_EvalCoord1fv(disp, glEvalCoord1fv);
- SET_EvalCoord2d(disp, glEvalCoord2d);
- SET_EvalCoord2dv(disp, glEvalCoord2dv);
- SET_EvalCoord2f(disp, glEvalCoord2f);
- SET_EvalCoord2fv(disp, glEvalCoord2fv);
- SET_EvalMesh1(disp, glEvalMesh1);
- SET_EvalMesh2(disp, glEvalMesh2);
- SET_EvalPoint1(disp, glEvalPoint1);
- SET_EvalPoint2(disp, glEvalPoint2);
- SET_FeedbackBuffer(disp, glFeedbackBuffer);
- SET_Finish(disp, glFinish);
- SET_Flush(disp, glFlush);
- SET_Fogf(disp, glFogf);
- SET_Fogfv(disp, glFogfv);
- SET_Fogi(disp, glFogi);
- SET_Fogiv(disp, glFogiv);
- SET_FrontFace(disp, glFrontFace);
- SET_Frustum(disp, glFrustum);
- SET_GenLists(disp, glGenLists);
- SET_GenTextures(disp, glGenTextures);
- SET_GetBooleanv(disp, glGetBooleanv);
- SET_GetClipPlane(disp, glGetClipPlane);
- SET_GetColorTable(disp, glGetColorTable);
- SET_GetColorTableParameterfv(disp, glGetColorTableParameterfv);
- SET_GetColorTableParameteriv(disp, glGetColorTableParameteriv);
- SET_GetConvolutionFilter(disp, glGetConvolutionFilter);
- SET_GetConvolutionParameterfv(disp, glGetConvolutionParameterfv);
- SET_GetConvolutionParameteriv(disp, glGetConvolutionParameteriv);
- SET_GetDoublev(disp, glGetDoublev);
- SET_GetError(disp, glGetError);
- SET_GetFloatv(disp, glGetFloatv);
- SET_GetHistogram(disp, glGetHistogram);
- SET_GetHistogramParameterfv(disp, glGetHistogramParameterfv);
- SET_GetHistogramParameteriv(disp, glGetHistogramParameteriv);
- SET_GetIntegerv(disp, glGetIntegerv);
- SET_GetLightfv(disp, glGetLightfv);
- SET_GetLightiv(disp, glGetLightiv);
- SET_GetMapdv(disp, glGetMapdv);
- SET_GetMapfv(disp, glGetMapfv);
- SET_GetMapiv(disp, glGetMapiv);
- SET_GetMaterialfv(disp, glGetMaterialfv);
- SET_GetMaterialiv(disp, glGetMaterialiv);
- SET_GetMinmax(disp, glGetMinmax);
- SET_GetMinmaxParameterfv(disp, glGetMinmaxParameterfv);
- SET_GetMinmaxParameteriv(disp, glGetMinmaxParameteriv);
- SET_GetPixelMapfv(disp, glGetPixelMapfv);
- SET_GetPixelMapuiv(disp, glGetPixelMapuiv);
- SET_GetPixelMapusv(disp, glGetPixelMapusv);
- SET_GetPointerv(disp, glGetPointerv);
- SET_GetPolygonStipple(disp, glGetPolygonStipple);
- SET_GetSeparableFilter(disp, glGetSeparableFilter);
- SET_GetString(disp, glGetString);
- SET_GetTexEnvfv(disp, glGetTexEnvfv);
- SET_GetTexEnviv(disp, glGetTexEnviv);
- SET_GetTexGendv(disp, glGetTexGendv);
- SET_GetTexGenfv(disp, glGetTexGenfv);
- SET_GetTexGeniv(disp, glGetTexGeniv);
- SET_GetTexImage(disp, glGetTexImage);
- SET_GetTexLevelParameterfv(disp, glGetTexLevelParameterfv);
- SET_GetTexLevelParameteriv(disp, glGetTexLevelParameteriv);
- SET_GetTexParameterfv(disp, glGetTexParameterfv);
- SET_GetTexParameteriv(disp, glGetTexParameteriv);
- SET_Hint(disp, glHint);
- SET_Histogram(disp, glHistogram);
- SET_IndexMask(disp, glIndexMask);
- SET_IndexPointer(disp, glIndexPointer);
- SET_Indexd(disp, glIndexd);
- SET_Indexdv(disp, glIndexdv);
- SET_Indexf(disp, glIndexf);
- SET_Indexfv(disp, glIndexfv);
- SET_Indexi(disp, glIndexi);
- SET_Indexiv(disp, glIndexiv);
- SET_Indexs(disp, glIndexs);
- SET_Indexsv(disp, glIndexsv);
- SET_Indexub(disp, glIndexub);
- SET_Indexubv(disp, glIndexubv);
- SET_InitNames(disp, glInitNames);
- SET_InterleavedArrays(disp, glInterleavedArrays);
- SET_IsEnabled(disp, glIsEnabled);
- SET_IsList(disp, glIsList);
- SET_IsTexture(disp, glIsTexture);
- SET_LightModelf(disp, glLightModelf);
- SET_LightModelfv(disp, glLightModelfv);
- SET_LightModeli(disp, glLightModeli);
- SET_LightModeliv(disp, glLightModeliv);
- SET_Lightf(disp, glLightf);
- SET_Lightfv(disp, glLightfv);
- SET_Lighti(disp, glLighti);
- SET_Lightiv(disp, glLightiv);
- SET_LineStipple(disp, glLineStipple);
- SET_LineWidth(disp, glLineWidth);
- SET_ListBase(disp, glListBase);
- SET_LoadIdentity(disp, glLoadIdentity);
- SET_LoadMatrixd(disp, glLoadMatrixd);
- SET_LoadMatrixf(disp, glLoadMatrixf);
- SET_LoadName(disp, glLoadName);
- SET_LogicOp(disp, glLogicOp);
- SET_Map1d(disp, glMap1d);
- SET_Map1f(disp, glMap1f);
- SET_Map2d(disp, glMap2d);
- SET_Map2f(disp, glMap2f);
- SET_MapGrid1d(disp, glMapGrid1d);
- SET_MapGrid1f(disp, glMapGrid1f);
- SET_MapGrid2d(disp, glMapGrid2d);
- SET_MapGrid2f(disp, glMapGrid2f);
- SET_Materialf(disp, glMaterialf);
- SET_Materialfv(disp, glMaterialfv);
- SET_Materiali(disp, glMateriali);
- SET_Materialiv(disp, glMaterialiv);
- SET_MatrixMode(disp, glMatrixMode);
- SET_Minmax(disp, glMinmax);
- SET_MultMatrixd(disp, glMultMatrixd);
- SET_MultMatrixf(disp, glMultMatrixf);
- SET_NewList(disp, glNewList);
- SET_Normal3b(disp, glNormal3b);
- SET_Normal3bv(disp, glNormal3bv);
- SET_Normal3d(disp, glNormal3d);
- SET_Normal3dv(disp, glNormal3dv);
- SET_Normal3f(disp, glNormal3f);
- SET_Normal3fv(disp, glNormal3fv);
- SET_Normal3i(disp, glNormal3i);
- SET_Normal3iv(disp, glNormal3iv);
- SET_Normal3s(disp, glNormal3s);
- SET_Normal3sv(disp, glNormal3sv);
- SET_NormalPointer(disp, glNormalPointer);
- SET_Ortho(disp, glOrtho);
- SET_PassThrough(disp, glPassThrough);
- SET_PixelMapfv(disp, glPixelMapfv);
- SET_PixelMapuiv(disp, glPixelMapuiv);
- SET_PixelMapusv(disp, glPixelMapusv);
- SET_PixelStoref(disp, glPixelStoref);
- SET_PixelStorei(disp, glPixelStorei);
- SET_PixelTransferf(disp, glPixelTransferf);
- SET_PixelTransferi(disp, glPixelTransferi);
- SET_PixelZoom(disp, glPixelZoom);
- SET_PointSize(disp, glPointSize);
- SET_PolygonMode(disp, glPolygonMode);
- SET_PolygonOffset(disp, glPolygonOffset);
- SET_PolygonStipple(disp, glPolygonStipple);
- SET_PopAttrib(disp, glPopAttrib);
- SET_PopClientAttrib(disp, glPopClientAttrib);
- SET_PopMatrix(disp, glPopMatrix);
- SET_PopName(disp, glPopName);
- SET_PrioritizeTextures(disp, glPrioritizeTextures);
- SET_PushAttrib(disp, glPushAttrib);
- SET_PushClientAttrib(disp, glPushClientAttrib);
- SET_PushMatrix(disp, glPushMatrix);
- SET_PushName(disp, glPushName);
- SET_RasterPos2d(disp, glRasterPos2d);
- SET_RasterPos2dv(disp, glRasterPos2dv);
- SET_RasterPos2f(disp, glRasterPos2f);
- SET_RasterPos2fv(disp, glRasterPos2fv);
- SET_RasterPos2i(disp, glRasterPos2i);
- SET_RasterPos2iv(disp, glRasterPos2iv);
- SET_RasterPos2s(disp, glRasterPos2s);
- SET_RasterPos2sv(disp, glRasterPos2sv);
- SET_RasterPos3d(disp, glRasterPos3d);
- SET_RasterPos3dv(disp, glRasterPos3dv);
- SET_RasterPos3f(disp, glRasterPos3f);
- SET_RasterPos3fv(disp, glRasterPos3fv);
- SET_RasterPos3i(disp, glRasterPos3i);
- SET_RasterPos3iv(disp, glRasterPos3iv);
- SET_RasterPos3s(disp, glRasterPos3s);
- SET_RasterPos3sv(disp, glRasterPos3sv);
- SET_RasterPos4d(disp, glRasterPos4d);
- SET_RasterPos4dv(disp, glRasterPos4dv);
- SET_RasterPos4f(disp, glRasterPos4f);
- SET_RasterPos4fv(disp, glRasterPos4fv);
- SET_RasterPos4i(disp, glRasterPos4i);
- SET_RasterPos4iv(disp, glRasterPos4iv);
- SET_RasterPos4s(disp, glRasterPos4s);
- SET_RasterPos4sv(disp, glRasterPos4sv);
- SET_ReadBuffer(disp, glReadBuffer);
- SET_ReadPixels(disp, glReadPixels);
- SET_Rectd(disp, glRectd);
- SET_Rectdv(disp, glRectdv);
- SET_Rectf(disp, glRectf);
- SET_Rectfv(disp, glRectfv);
- SET_Recti(disp, glRecti);
- SET_Rectiv(disp, glRectiv);
- SET_Rects(disp, glRects);
- SET_Rectsv(disp, glRectsv);
- SET_RenderMode(disp, glRenderMode);
- SET_ResetHistogram(disp, glResetHistogram);
- SET_ResetMinmax(disp, glResetMinmax);
- SET_Rotated(disp, glRotated);
- SET_Rotatef(disp, glRotatef);
- SET_Scaled(disp, glScaled);
- SET_Scalef(disp, glScalef);
- SET_Scissor(disp, glScissor);
- SET_SelectBuffer(disp, glSelectBuffer);
- SET_SeparableFilter2D(disp, glSeparableFilter2D);
- SET_ShadeModel(disp, glShadeModel);
- SET_StencilFunc(disp, glStencilFunc);
- SET_StencilMask(disp, glStencilMask);
- SET_StencilOp(disp, glStencilOp);
- SET_TexCoord1d(disp, glTexCoord1d);
- SET_TexCoord1dv(disp, glTexCoord1dv);
- SET_TexCoord1f(disp, glTexCoord1f);
- SET_TexCoord1fv(disp, glTexCoord1fv);
- SET_TexCoord1i(disp, glTexCoord1i);
- SET_TexCoord1iv(disp, glTexCoord1iv);
- SET_TexCoord1s(disp, glTexCoord1s);
- SET_TexCoord1sv(disp, glTexCoord1sv);
- SET_TexCoord2d(disp, glTexCoord2d);
- SET_TexCoord2dv(disp, glTexCoord2dv);
- SET_TexCoord2f(disp, glTexCoord2f);
- SET_TexCoord2fv(disp, glTexCoord2fv);
- SET_TexCoord2i(disp, glTexCoord2i);
- SET_TexCoord2iv(disp, glTexCoord2iv);
- SET_TexCoord2s(disp, glTexCoord2s);
- SET_TexCoord2sv(disp, glTexCoord2sv);
- SET_TexCoord3d(disp, glTexCoord3d);
- SET_TexCoord3dv(disp, glTexCoord3dv);
- SET_TexCoord3f(disp, glTexCoord3f);
- SET_TexCoord3fv(disp, glTexCoord3fv);
- SET_TexCoord3i(disp, glTexCoord3i);
- SET_TexCoord3iv(disp, glTexCoord3iv);
- SET_TexCoord3s(disp, glTexCoord3s);
- SET_TexCoord3sv(disp, glTexCoord3sv);
- SET_TexCoord4d(disp, glTexCoord4d);
- SET_TexCoord4dv(disp, glTexCoord4dv);
- SET_TexCoord4f(disp, glTexCoord4f);
- SET_TexCoord4fv(disp, glTexCoord4fv);
- SET_TexCoord4i(disp, glTexCoord4i);
- SET_TexCoord4iv(disp, glTexCoord4iv);
- SET_TexCoord4s(disp, glTexCoord4s);
- SET_TexCoord4sv(disp, glTexCoord4sv);
- SET_TexCoordPointer(disp, glTexCoordPointer);
- SET_TexEnvf(disp, glTexEnvf);
- SET_TexEnvfv(disp, glTexEnvfv);
- SET_TexEnvi(disp, glTexEnvi);
- SET_TexEnviv(disp, glTexEnviv);
- SET_TexGend(disp, glTexGend);
- SET_TexGendv(disp, glTexGendv);
- SET_TexGenf(disp, glTexGenf);
- SET_TexGenfv(disp, glTexGenfv);
- SET_TexGeni(disp, glTexGeni);
- SET_TexGeniv(disp, glTexGeniv);
+ SET_Accum(disp, dlsym(RTLD_DEFAULT, "glAccum"));
+ SET_AlphaFunc(disp, dlsym(RTLD_DEFAULT, "glAlphaFunc"));
+ SET_AreTexturesResident(disp, dlsym(RTLD_DEFAULT, "glAreTexturesResident"));
+ SET_ArrayElement(disp, dlsym(RTLD_DEFAULT, "glArrayElement"));
+ SET_Begin(disp, dlsym(RTLD_DEFAULT, "glBegin"));
+ SET_BindTexture(disp, dlsym(RTLD_DEFAULT, "glBindTexture"));
+ SET_Bitmap(disp, dlsym(RTLD_DEFAULT, "glBitmap"));
+ SET_BlendColor(disp, dlsym(RTLD_DEFAULT, "glBlendColor"));
+ SET_BlendEquation(disp, dlsym(RTLD_DEFAULT, "glBlendEquation"));
+ SET_BlendFunc(disp, dlsym(RTLD_DEFAULT, "glBlendFunc"));
+ SET_CallList(disp, dlsym(RTLD_DEFAULT, "glCallList"));
+ SET_CallLists(disp, dlsym(RTLD_DEFAULT, "glCallLists"));
+ SET_Clear(disp, dlsym(RTLD_DEFAULT, "glClear"));
+ SET_ClearAccum(disp, dlsym(RTLD_DEFAULT, "glClearAccum"));
+ SET_ClearColor(disp, dlsym(RTLD_DEFAULT, "glClearColor"));
+ SET_ClearDepth(disp, dlsym(RTLD_DEFAULT, "glClearDepth"));
+ SET_ClearIndex(disp, dlsym(RTLD_DEFAULT, "glClearIndex"));
+ SET_ClearStencil(disp, dlsym(RTLD_DEFAULT, "glClearStencil"));
+ SET_ClipPlane(disp, dlsym(RTLD_DEFAULT, "glClipPlane"));
+ SET_Color3b(disp, dlsym(RTLD_DEFAULT, "glColor3b"));
+ SET_Color3bv(disp, dlsym(RTLD_DEFAULT, "glColor3bv"));
+ SET_Color3d(disp, dlsym(RTLD_DEFAULT, "glColor3d"));
+ SET_Color3dv(disp, dlsym(RTLD_DEFAULT, "glColor3dv"));
+ SET_Color3f(disp, dlsym(RTLD_DEFAULT, "glColor3f"));
+ SET_Color3fv(disp, dlsym(RTLD_DEFAULT, "glColor3fv"));
+ SET_Color3i(disp, dlsym(RTLD_DEFAULT, "glColor3i"));
+ SET_Color3iv(disp, dlsym(RTLD_DEFAULT, "glColor3iv"));
+ SET_Color3s(disp, dlsym(RTLD_DEFAULT, "glColor3s"));
+ SET_Color3sv(disp, dlsym(RTLD_DEFAULT, "glColor3sv"));
+ SET_Color3ub(disp, dlsym(RTLD_DEFAULT, "glColor3ub"));
+ SET_Color3ubv(disp, dlsym(RTLD_DEFAULT, "glColor3ubv"));
+ SET_Color3ui(disp, dlsym(RTLD_DEFAULT, "glColor3ui"));
+ SET_Color3uiv(disp, dlsym(RTLD_DEFAULT, "glColor3uiv"));
+ SET_Color3us(disp, dlsym(RTLD_DEFAULT, "glColor3us"));
+ SET_Color3usv(disp, dlsym(RTLD_DEFAULT, "glColor3usv"));
+ SET_Color4b(disp, dlsym(RTLD_DEFAULT, "glColor4b"));
+ SET_Color4bv(disp, dlsym(RTLD_DEFAULT, "glColor4bv"));
+ SET_Color4d(disp, dlsym(RTLD_DEFAULT, "glColor4d"));
+ SET_Color4dv(disp, dlsym(RTLD_DEFAULT, "glColor4dv"));
+ SET_Color4f(disp, dlsym(RTLD_DEFAULT, "glColor4f"));
+ SET_Color4fv(disp, dlsym(RTLD_DEFAULT, "glColor4fv"));
+ SET_Color4i(disp, dlsym(RTLD_DEFAULT, "glColor4i"));
+ SET_Color4iv(disp, dlsym(RTLD_DEFAULT, "glColor4iv"));
+ SET_Color4s(disp, dlsym(RTLD_DEFAULT, "glColor4s"));
+ SET_Color4sv(disp, dlsym(RTLD_DEFAULT, "glColor4sv"));
+ SET_Color4ub(disp, dlsym(RTLD_DEFAULT, "glColor4ub"));
+ SET_Color4ubv(disp, dlsym(RTLD_DEFAULT, "glColor4ubv"));
+ SET_Color4ui(disp, dlsym(RTLD_DEFAULT, "glColor4ui"));
+ SET_Color4uiv(disp, dlsym(RTLD_DEFAULT, "glColor4uiv"));
+ SET_Color4us(disp, dlsym(RTLD_DEFAULT, "glColor4us"));
+ SET_Color4usv(disp, dlsym(RTLD_DEFAULT, "glColor4usv"));
+ SET_ColorMask(disp, dlsym(RTLD_DEFAULT, "glColorMask"));
+ SET_ColorMaterial(disp, dlsym(RTLD_DEFAULT, "glColorMaterial"));
+ SET_ColorPointer(disp, dlsym(RTLD_DEFAULT, "glColorPointer"));
+ SET_ColorSubTable(disp, dlsym(RTLD_DEFAULT, "glColorSubTable"));
+ SET_ColorTable(disp, dlsym(RTLD_DEFAULT, "glColorTable"));
+ SET_ColorTableParameterfv(disp, dlsym(RTLD_DEFAULT, "glColorTableParameterfv"));
+ SET_ColorTableParameteriv(disp, dlsym(RTLD_DEFAULT, "glColorTableParameteriv"));
+ SET_ConvolutionFilter1D(disp, dlsym(RTLD_DEFAULT, "glConvolutionFilter1D"));
+ SET_ConvolutionFilter2D(disp, dlsym(RTLD_DEFAULT, "glConvolutionFilter2D"));
+ SET_ConvolutionParameterf(disp, dlsym(RTLD_DEFAULT, "glConvolutionParameterf"));
+ SET_ConvolutionParameterfv(disp, dlsym(RTLD_DEFAULT, "glConvolutionParameterfv"));
+ SET_ConvolutionParameteri(disp, dlsym(RTLD_DEFAULT, "glConvolutionParameteri"));
+ SET_ConvolutionParameteriv(disp, dlsym(RTLD_DEFAULT, "glConvolutionParameteriv"));
+ SET_CopyColorSubTable(disp, dlsym(RTLD_DEFAULT, "glCopyColorSubTable"));
+ SET_CopyColorTable(disp, dlsym(RTLD_DEFAULT, "glCopyColorTable"));
+ SET_CopyConvolutionFilter1D(disp, dlsym(RTLD_DEFAULT, "glCopyConvolutionFilter1D"));
+ SET_CopyConvolutionFilter2D(disp, dlsym(RTLD_DEFAULT, "glCopyConvolutionFilter2D"));
+ SET_CopyPixels(disp, dlsym(RTLD_DEFAULT, "glCopyPixels"));
+ SET_CopyTexImage1D(disp, dlsym(RTLD_DEFAULT, "glCopyTexImage1D"));
+ SET_CopyTexImage2D(disp, dlsym(RTLD_DEFAULT, "glCopyTexImage2D"));
+ SET_CopyTexSubImage1D(disp, dlsym(RTLD_DEFAULT, "glCopyTexSubImage1D"));
+ SET_CopyTexSubImage2D(disp, dlsym(RTLD_DEFAULT, "glCopyTexSubImage2D"));
+ SET_CopyTexSubImage3D(disp, dlsym(RTLD_DEFAULT, "glCopyTexSubImage3D"));
+ SET_CullFace(disp, dlsym(RTLD_DEFAULT, "glCullFace"));
+ SET_DeleteLists(disp, dlsym(RTLD_DEFAULT, "glDeleteLists"));
+ SET_DeleteTextures(disp, dlsym(RTLD_DEFAULT, "glDeleteTextures"));
+ SET_DepthFunc(disp, dlsym(RTLD_DEFAULT, "glDepthFunc"));
+ SET_DepthMask(disp, dlsym(RTLD_DEFAULT, "glDepthMask"));
+ SET_DepthRange(disp, dlsym(RTLD_DEFAULT, "glDepthRange"));
+ SET_Disable(disp, dlsym(RTLD_DEFAULT, "glDisable"));
+ SET_DisableClientState(disp, dlsym(RTLD_DEFAULT, "glDisableClientState"));
+ SET_DrawArrays(disp, dlsym(RTLD_DEFAULT, "glDrawArrays"));
+ SET_DrawBuffer(disp, dlsym(RTLD_DEFAULT, "glDrawBuffer"));
+ SET_DrawElements(disp, dlsym(RTLD_DEFAULT, "glDrawElements"));
+ SET_DrawPixels(disp, dlsym(RTLD_DEFAULT, "glDrawPixels"));
+ SET_DrawRangeElements(disp, dlsym(RTLD_DEFAULT, "glDrawRangeElements"));
+ SET_EdgeFlag(disp, dlsym(RTLD_DEFAULT, "glEdgeFlag"));
+ SET_EdgeFlagPointer(disp, dlsym(RTLD_DEFAULT, "glEdgeFlagPointer"));
+ SET_EdgeFlagv(disp, dlsym(RTLD_DEFAULT, "glEdgeFlagv"));
+ SET_Enable(disp, dlsym(RTLD_DEFAULT, "glEnable"));
+ SET_EnableClientState(disp, dlsym(RTLD_DEFAULT, "glEnableClientState"));
+ SET_End(disp, dlsym(RTLD_DEFAULT, "glEnd"));
+ SET_EndList(disp, dlsym(RTLD_DEFAULT, "glEndList"));
+ SET_EvalCoord1d(disp, dlsym(RTLD_DEFAULT, "glEvalCoord1d"));
+ SET_EvalCoord1dv(disp, dlsym(RTLD_DEFAULT, "glEvalCoord1dv"));
+ SET_EvalCoord1f(disp, dlsym(RTLD_DEFAULT, "glEvalCoord1f"));
+ SET_EvalCoord1fv(disp, dlsym(RTLD_DEFAULT, "glEvalCoord1fv"));
+ SET_EvalCoord2d(disp, dlsym(RTLD_DEFAULT, "glEvalCoord2d"));
+ SET_EvalCoord2dv(disp, dlsym(RTLD_DEFAULT, "glEvalCoord2dv"));
+ SET_EvalCoord2f(disp, dlsym(RTLD_DEFAULT, "glEvalCoord2f"));
+ SET_EvalCoord2fv(disp, dlsym(RTLD_DEFAULT, "glEvalCoord2fv"));
+ SET_EvalMesh1(disp, dlsym(RTLD_DEFAULT, "glEvalMesh1"));
+ SET_EvalMesh2(disp, dlsym(RTLD_DEFAULT, "glEvalMesh2"));
+ SET_EvalPoint1(disp, dlsym(RTLD_DEFAULT, "glEvalPoint1"));
+ SET_EvalPoint2(disp, dlsym(RTLD_DEFAULT, "glEvalPoint2"));
+ SET_FeedbackBuffer(disp, dlsym(RTLD_DEFAULT, "glFeedbackBuffer"));
+ SET_Finish(disp, dlsym(RTLD_DEFAULT, "glFinish"));
+ SET_Flush(disp, dlsym(RTLD_DEFAULT, "glFlush"));
+ SET_Fogf(disp, dlsym(RTLD_DEFAULT, "glFogf"));
+ SET_Fogfv(disp, dlsym(RTLD_DEFAULT, "glFogfv"));
+ SET_Fogi(disp, dlsym(RTLD_DEFAULT, "glFogi"));
+ SET_Fogiv(disp, dlsym(RTLD_DEFAULT, "glFogiv"));
+ SET_FrontFace(disp, dlsym(RTLD_DEFAULT, "glFrontFace"));
+ SET_Frustum(disp, dlsym(RTLD_DEFAULT, "glFrustum"));
+ SET_GenLists(disp, dlsym(RTLD_DEFAULT, "glGenLists"));
+ SET_GenTextures(disp, dlsym(RTLD_DEFAULT, "glGenTextures"));
+ SET_GetBooleanv(disp, dlsym(RTLD_DEFAULT, "glGetBooleanv"));
+ SET_GetClipPlane(disp, dlsym(RTLD_DEFAULT, "glGetClipPlane"));
+ SET_GetColorTable(disp, dlsym(RTLD_DEFAULT, "glGetColorTable"));
+ SET_GetColorTableParameterfv(disp, dlsym(RTLD_DEFAULT, "glGetColorTableParameterfv"));
+ SET_GetColorTableParameteriv(disp, dlsym(RTLD_DEFAULT, "glGetColorTableParameteriv"));
+ SET_GetConvolutionFilter(disp, dlsym(RTLD_DEFAULT, "glGetConvolutionFilter"));
+ SET_GetConvolutionParameterfv(disp, dlsym(RTLD_DEFAULT, "glGetConvolutionParameterfv"));
+ SET_GetConvolutionParameteriv(disp, dlsym(RTLD_DEFAULT, "glGetConvolutionParameteriv"));
+ SET_GetDoublev(disp, dlsym(RTLD_DEFAULT, "glGetDoublev"));
+ SET_GetError(disp, dlsym(RTLD_DEFAULT, "glGetError"));
+ SET_GetFloatv(disp, dlsym(RTLD_DEFAULT, "glGetFloatv"));
+ SET_GetHistogram(disp, dlsym(RTLD_DEFAULT, "glGetHistogram"));
+ SET_GetHistogramParameterfv(disp, dlsym(RTLD_DEFAULT, "glGetHistogramParameterfv"));
+ SET_GetHistogramParameteriv(disp, dlsym(RTLD_DEFAULT, "glGetHistogramParameteriv"));
+ SET_GetIntegerv(disp, dlsym(RTLD_DEFAULT, "glGetIntegerv"));
+ SET_GetLightfv(disp, dlsym(RTLD_DEFAULT, "glGetLightfv"));
+ SET_GetLightiv(disp, dlsym(RTLD_DEFAULT, "glGetLightiv"));
+ SET_GetMapdv(disp, dlsym(RTLD_DEFAULT, "glGetMapdv"));
+ SET_GetMapfv(disp, dlsym(RTLD_DEFAULT, "glGetMapfv"));
+ SET_GetMapiv(disp, dlsym(RTLD_DEFAULT, "glGetMapiv"));
+ SET_GetMaterialfv(disp, dlsym(RTLD_DEFAULT, "glGetMaterialfv"));
+ SET_GetMaterialiv(disp, dlsym(RTLD_DEFAULT, "glGetMaterialiv"));
+ SET_GetMinmax(disp, dlsym(RTLD_DEFAULT, "glGetMinmax"));
+ SET_GetMinmaxParameterfv(disp, dlsym(RTLD_DEFAULT, "glGetMinmaxParameterfv"));
+ SET_GetMinmaxParameteriv(disp, dlsym(RTLD_DEFAULT, "glGetMinmaxParameteriv"));
+ SET_GetPixelMapfv(disp, dlsym(RTLD_DEFAULT, "glGetPixelMapfv"));
+ SET_GetPixelMapuiv(disp, dlsym(RTLD_DEFAULT, "glGetPixelMapuiv"));
+ SET_GetPixelMapusv(disp, dlsym(RTLD_DEFAULT, "glGetPixelMapusv"));
+ SET_GetPointerv(disp, dlsym(RTLD_DEFAULT, "glGetPointerv"));
+ SET_GetPolygonStipple(disp, dlsym(RTLD_DEFAULT, "glGetPolygonStipple"));
+ SET_GetSeparableFilter(disp, dlsym(RTLD_DEFAULT, "glGetSeparableFilter"));
+ SET_GetString(disp, dlsym(RTLD_DEFAULT, "glGetString"));
+ SET_GetTexEnvfv(disp, dlsym(RTLD_DEFAULT, "glGetTexEnvfv"));
+ SET_GetTexEnviv(disp, dlsym(RTLD_DEFAULT, "glGetTexEnviv"));
+ SET_GetTexGendv(disp, dlsym(RTLD_DEFAULT, "glGetTexGendv"));
+ SET_GetTexGenfv(disp, dlsym(RTLD_DEFAULT, "glGetTexGenfv"));
+ SET_GetTexGeniv(disp, dlsym(RTLD_DEFAULT, "glGetTexGeniv"));
+ SET_GetTexImage(disp, dlsym(RTLD_DEFAULT, "glGetTexImage"));
+ SET_GetTexLevelParameterfv(disp, dlsym(RTLD_DEFAULT, "glGetTexLevelParameterfv"));
+ SET_GetTexLevelParameteriv(disp, dlsym(RTLD_DEFAULT, "glGetTexLevelParameteriv"));
+ SET_GetTexParameterfv(disp, dlsym(RTLD_DEFAULT, "glGetTexParameterfv"));
+ SET_GetTexParameteriv(disp, dlsym(RTLD_DEFAULT, "glGetTexParameteriv"));
+ SET_Hint(disp, dlsym(RTLD_DEFAULT, "glHint"));
+ SET_Histogram(disp, dlsym(RTLD_DEFAULT, "glHistogram"));
+ SET_IndexMask(disp, dlsym(RTLD_DEFAULT, "glIndexMask"));
+ SET_IndexPointer(disp, dlsym(RTLD_DEFAULT, "glIndexPointer"));
+ SET_Indexd(disp, dlsym(RTLD_DEFAULT, "glIndexd"));
+ SET_Indexdv(disp, dlsym(RTLD_DEFAULT, "glIndexdv"));
+ SET_Indexf(disp, dlsym(RTLD_DEFAULT, "glIndexf"));
+ SET_Indexfv(disp, dlsym(RTLD_DEFAULT, "glIndexfv"));
+ SET_Indexi(disp, dlsym(RTLD_DEFAULT, "glIndexi"));
+ SET_Indexiv(disp, dlsym(RTLD_DEFAULT, "glIndexiv"));
+ SET_Indexs(disp, dlsym(RTLD_DEFAULT, "glIndexs"));
+ SET_Indexsv(disp, dlsym(RTLD_DEFAULT, "glIndexsv"));
+ SET_Indexub(disp, dlsym(RTLD_DEFAULT, "glIndexub"));
+ SET_Indexubv(disp, dlsym(RTLD_DEFAULT, "glIndexubv"));
+ SET_InitNames(disp, dlsym(RTLD_DEFAULT, "glInitNames"));
+ SET_InterleavedArrays(disp, dlsym(RTLD_DEFAULT, "glInterleavedArrays"));
+ SET_IsEnabled(disp, dlsym(RTLD_DEFAULT, "glIsEnabled"));
+ SET_IsList(disp, dlsym(RTLD_DEFAULT, "glIsList"));
+ SET_IsTexture(disp, dlsym(RTLD_DEFAULT, "glIsTexture"));
+ SET_LightModelf(disp, dlsym(RTLD_DEFAULT, "glLightModelf"));
+ SET_LightModelfv(disp, dlsym(RTLD_DEFAULT, "glLightModelfv"));
+ SET_LightModeli(disp, dlsym(RTLD_DEFAULT, "glLightModeli"));
+ SET_LightModeliv(disp, dlsym(RTLD_DEFAULT, "glLightModeliv"));
+ SET_Lightf(disp, dlsym(RTLD_DEFAULT, "glLightf"));
+ SET_Lightfv(disp, dlsym(RTLD_DEFAULT, "glLightfv"));
+ SET_Lighti(disp, dlsym(RTLD_DEFAULT, "glLighti"));
+ SET_Lightiv(disp, dlsym(RTLD_DEFAULT, "glLightiv"));
+ SET_LineStipple(disp, dlsym(RTLD_DEFAULT, "glLineStipple"));
+ SET_LineWidth(disp, dlsym(RTLD_DEFAULT, "glLineWidth"));
+ SET_ListBase(disp, dlsym(RTLD_DEFAULT, "glListBase"));
+ SET_LoadIdentity(disp, dlsym(RTLD_DEFAULT, "glLoadIdentity"));
+ SET_LoadMatrixd(disp, dlsym(RTLD_DEFAULT, "glLoadMatrixd"));
+ SET_LoadMatrixf(disp, dlsym(RTLD_DEFAULT, "glLoadMatrixf"));
+ SET_LoadName(disp, dlsym(RTLD_DEFAULT, "glLoadName"));
+ SET_LogicOp(disp, dlsym(RTLD_DEFAULT, "glLogicOp"));
+ SET_Map1d(disp, dlsym(RTLD_DEFAULT, "glMap1d"));
+ SET_Map1f(disp, dlsym(RTLD_DEFAULT, "glMap1f"));
+ SET_Map2d(disp, dlsym(RTLD_DEFAULT, "glMap2d"));
+ SET_Map2f(disp, dlsym(RTLD_DEFAULT, "glMap2f"));
+ SET_MapGrid1d(disp, dlsym(RTLD_DEFAULT, "glMapGrid1d"));
+ SET_MapGrid1f(disp, dlsym(RTLD_DEFAULT, "glMapGrid1f"));
+ SET_MapGrid2d(disp, dlsym(RTLD_DEFAULT, "glMapGrid2d"));
+ SET_MapGrid2f(disp, dlsym(RTLD_DEFAULT, "glMapGrid2f"));
+ SET_Materialf(disp, dlsym(RTLD_DEFAULT, "glMaterialf"));
+ SET_Materialfv(disp, dlsym(RTLD_DEFAULT, "glMaterialfv"));
+ SET_Materiali(disp, dlsym(RTLD_DEFAULT, "glMateriali"));
+ SET_Materialiv(disp, dlsym(RTLD_DEFAULT, "glMaterialiv"));
+ SET_MatrixMode(disp, dlsym(RTLD_DEFAULT, "glMatrixMode"));
+ SET_Minmax(disp, dlsym(RTLD_DEFAULT, "glMinmax"));
+ SET_MultMatrixd(disp, dlsym(RTLD_DEFAULT, "glMultMatrixd"));
+ SET_MultMatrixf(disp, dlsym(RTLD_DEFAULT, "glMultMatrixf"));
+ SET_NewList(disp, dlsym(RTLD_DEFAULT, "glNewList"));
+ SET_Normal3b(disp, dlsym(RTLD_DEFAULT, "glNormal3b"));
+ SET_Normal3bv(disp, dlsym(RTLD_DEFAULT, "glNormal3bv"));
+ SET_Normal3d(disp, dlsym(RTLD_DEFAULT, "glNormal3d"));
+ SET_Normal3dv(disp, dlsym(RTLD_DEFAULT, "glNormal3dv"));
+ SET_Normal3f(disp, dlsym(RTLD_DEFAULT, "glNormal3f"));
+ SET_Normal3fv(disp, dlsym(RTLD_DEFAULT, "glNormal3fv"));
+ SET_Normal3i(disp, dlsym(RTLD_DEFAULT, "glNormal3i"));
+ SET_Normal3iv(disp, dlsym(RTLD_DEFAULT, "glNormal3iv"));
+ SET_Normal3s(disp, dlsym(RTLD_DEFAULT, "glNormal3s"));
+ SET_Normal3sv(disp, dlsym(RTLD_DEFAULT, "glNormal3sv"));
+ SET_NormalPointer(disp, dlsym(RTLD_DEFAULT, "glNormalPointer"));
+ SET_Ortho(disp, dlsym(RTLD_DEFAULT, "glOrtho"));
+ SET_PassThrough(disp, dlsym(RTLD_DEFAULT, "glPassThrough"));
+ SET_PixelMapfv(disp, dlsym(RTLD_DEFAULT, "glPixelMapfv"));
+ SET_PixelMapuiv(disp, dlsym(RTLD_DEFAULT, "glPixelMapuiv"));
+ SET_PixelMapusv(disp, dlsym(RTLD_DEFAULT, "glPixelMapusv"));
+ SET_PixelStoref(disp, dlsym(RTLD_DEFAULT, "glPixelStoref"));
+ SET_PixelStorei(disp, dlsym(RTLD_DEFAULT, "glPixelStorei"));
+ SET_PixelTransferf(disp, dlsym(RTLD_DEFAULT, "glPixelTransferf"));
+ SET_PixelTransferi(disp, dlsym(RTLD_DEFAULT, "glPixelTransferi"));
+ SET_PixelZoom(disp, dlsym(RTLD_DEFAULT, "glPixelZoom"));
+ SET_PointSize(disp, dlsym(RTLD_DEFAULT, "glPointSize"));
+ SET_PolygonMode(disp, dlsym(RTLD_DEFAULT, "glPolygonMode"));
+ SET_PolygonOffset(disp, dlsym(RTLD_DEFAULT, "glPolygonOffset"));
+ SET_PolygonStipple(disp, dlsym(RTLD_DEFAULT, "glPolygonStipple"));
+ SET_PopAttrib(disp, dlsym(RTLD_DEFAULT, "glPopAttrib"));
+ SET_PopClientAttrib(disp, dlsym(RTLD_DEFAULT, "glPopClientAttrib"));
+ SET_PopMatrix(disp, dlsym(RTLD_DEFAULT, "glPopMatrix"));
+ SET_PopName(disp, dlsym(RTLD_DEFAULT, "glPopName"));
+ SET_PrioritizeTextures(disp, dlsym(RTLD_DEFAULT, "glPrioritizeTextures"));
+ SET_PushAttrib(disp, dlsym(RTLD_DEFAULT, "glPushAttrib"));
+ SET_PushClientAttrib(disp, dlsym(RTLD_DEFAULT, "glPushClientAttrib"));
+ SET_PushMatrix(disp, dlsym(RTLD_DEFAULT, "glPushMatrix"));
+ SET_PushName(disp, dlsym(RTLD_DEFAULT, "glPushName"));
+ SET_RasterPos2d(disp, dlsym(RTLD_DEFAULT, "glRasterPos2d"));
+ SET_RasterPos2dv(disp, dlsym(RTLD_DEFAULT, "glRasterPos2dv"));
+ SET_RasterPos2f(disp, dlsym(RTLD_DEFAULT, "glRasterPos2f"));
+ SET_RasterPos2fv(disp, dlsym(RTLD_DEFAULT, "glRasterPos2fv"));
+ SET_RasterPos2i(disp, dlsym(RTLD_DEFAULT, "glRasterPos2i"));
+ SET_RasterPos2iv(disp, dlsym(RTLD_DEFAULT, "glRasterPos2iv"));
+ SET_RasterPos2s(disp, dlsym(RTLD_DEFAULT, "glRasterPos2s"));
+ SET_RasterPos2sv(disp, dlsym(RTLD_DEFAULT, "glRasterPos2sv"));
+ SET_RasterPos3d(disp, dlsym(RTLD_DEFAULT, "glRasterPos3d"));
+ SET_RasterPos3dv(disp, dlsym(RTLD_DEFAULT, "glRasterPos3dv"));
+ SET_RasterPos3f(disp, dlsym(RTLD_DEFAULT, "glRasterPos3f"));
+ SET_RasterPos3fv(disp, dlsym(RTLD_DEFAULT, "glRasterPos3fv"));
+ SET_RasterPos3i(disp, dlsym(RTLD_DEFAULT, "glRasterPos3i"));
+ SET_RasterPos3iv(disp, dlsym(RTLD_DEFAULT, "glRasterPos3iv"));
+ SET_RasterPos3s(disp, dlsym(RTLD_DEFAULT, "glRasterPos3s"));
+ SET_RasterPos3sv(disp, dlsym(RTLD_DEFAULT, "glRasterPos3sv"));
+ SET_RasterPos4d(disp, dlsym(RTLD_DEFAULT, "glRasterPos4d"));
+ SET_RasterPos4dv(disp, dlsym(RTLD_DEFAULT, "glRasterPos4dv"));
+ SET_RasterPos4f(disp, dlsym(RTLD_DEFAULT, "glRasterPos4f"));
+ SET_RasterPos4fv(disp, dlsym(RTLD_DEFAULT, "glRasterPos4fv"));
+ SET_RasterPos4i(disp, dlsym(RTLD_DEFAULT, "glRasterPos4i"));
+ SET_RasterPos4iv(disp, dlsym(RTLD_DEFAULT, "glRasterPos4iv"));
+ SET_RasterPos4s(disp, dlsym(RTLD_DEFAULT, "glRasterPos4s"));
+ SET_RasterPos4sv(disp, dlsym(RTLD_DEFAULT, "glRasterPos4sv"));
+ SET_ReadBuffer(disp, dlsym(RTLD_DEFAULT, "glReadBuffer"));
+ SET_ReadPixels(disp, dlsym(RTLD_DEFAULT, "glReadPixels"));
+ SET_Rectd(disp, dlsym(RTLD_DEFAULT, "glRectd"));
+ SET_Rectdv(disp, dlsym(RTLD_DEFAULT, "glRectdv"));
+ SET_Rectf(disp, dlsym(RTLD_DEFAULT, "glRectf"));
+ SET_Rectfv(disp, dlsym(RTLD_DEFAULT, "glRectfv"));
+ SET_Recti(disp, dlsym(RTLD_DEFAULT, "glRecti"));
+ SET_Rectiv(disp, dlsym(RTLD_DEFAULT, "glRectiv"));
+ SET_Rects(disp, dlsym(RTLD_DEFAULT, "glRects"));
+ SET_Rectsv(disp, dlsym(RTLD_DEFAULT, "glRectsv"));
+ SET_RenderMode(disp, dlsym(RTLD_DEFAULT, "glRenderMode"));
+ SET_ResetHistogram(disp, dlsym(RTLD_DEFAULT, "glResetHistogram"));
+ SET_ResetMinmax(disp, dlsym(RTLD_DEFAULT, "glResetMinmax"));
+ SET_Rotated(disp, dlsym(RTLD_DEFAULT, "glRotated"));
+ SET_Rotatef(disp, dlsym(RTLD_DEFAULT, "glRotatef"));
+ SET_Scaled(disp, dlsym(RTLD_DEFAULT, "glScaled"));
+ SET_Scalef(disp, dlsym(RTLD_DEFAULT, "glScalef"));
+ SET_Scissor(disp, dlsym(RTLD_DEFAULT, "glScissor"));
+ SET_SelectBuffer(disp, dlsym(RTLD_DEFAULT, "glSelectBuffer"));
+ SET_SeparableFilter2D(disp, dlsym(RTLD_DEFAULT, "glSeparableFilter2D"));
+ SET_ShadeModel(disp, dlsym(RTLD_DEFAULT, "glShadeModel"));
+ SET_StencilFunc(disp, dlsym(RTLD_DEFAULT, "glStencilFunc"));
+ SET_StencilMask(disp, dlsym(RTLD_DEFAULT, "glStencilMask"));
+ SET_StencilOp(disp, dlsym(RTLD_DEFAULT, "glStencilOp"));
+ SET_TexCoord1d(disp, dlsym(RTLD_DEFAULT, "glTexCoord1d"));
+ SET_TexCoord1dv(disp, dlsym(RTLD_DEFAULT, "glTexCoord1dv"));
+ SET_TexCoord1f(disp, dlsym(RTLD_DEFAULT, "glTexCoord1f"));
+ SET_TexCoord1fv(disp, dlsym(RTLD_DEFAULT, "glTexCoord1fv"));
+ SET_TexCoord1i(disp, dlsym(RTLD_DEFAULT, "glTexCoord1i"));
+ SET_TexCoord1iv(disp, dlsym(RTLD_DEFAULT, "glTexCoord1iv"));
+ SET_TexCoord1s(disp, dlsym(RTLD_DEFAULT, "glTexCoord1s"));
+ SET_TexCoord1sv(disp, dlsym(RTLD_DEFAULT, "glTexCoord1sv"));
+ SET_TexCoord2d(disp, dlsym(RTLD_DEFAULT, "glTexCoord2d"));
+ SET_TexCoord2dv(disp, dlsym(RTLD_DEFAULT, "glTexCoord2dv"));
+ SET_TexCoord2f(disp, dlsym(RTLD_DEFAULT, "glTexCoord2f"));
+ SET_TexCoord2fv(disp, dlsym(RTLD_DEFAULT, "glTexCoord2fv"));
+ SET_TexCoord2i(disp, dlsym(RTLD_DEFAULT, "glTexCoord2i"));
+ SET_TexCoord2iv(disp, dlsym(RTLD_DEFAULT, "glTexCoord2iv"));
+ SET_TexCoord2s(disp, dlsym(RTLD_DEFAULT, "glTexCoord2s"));
+ SET_TexCoord2sv(disp, dlsym(RTLD_DEFAULT, "glTexCoord2sv"));
+ SET_TexCoord3d(disp, dlsym(RTLD_DEFAULT, "glTexCoord3d"));
+ SET_TexCoord3dv(disp, dlsym(RTLD_DEFAULT, "glTexCoord3dv"));
+ SET_TexCoord3f(disp, dlsym(RTLD_DEFAULT, "glTexCoord3f"));
+ SET_TexCoord3fv(disp, dlsym(RTLD_DEFAULT, "glTexCoord3fv"));
+ SET_TexCoord3i(disp, dlsym(RTLD_DEFAULT, "glTexCoord3i"));
+ SET_TexCoord3iv(disp, dlsym(RTLD_DEFAULT, "glTexCoord3iv"));
+ SET_TexCoord3s(disp, dlsym(RTLD_DEFAULT, "glTexCoord3s"));
+ SET_TexCoord3sv(disp, dlsym(RTLD_DEFAULT, "glTexCoord3sv"));
+ SET_TexCoord4d(disp, dlsym(RTLD_DEFAULT, "glTexCoord4d"));
+ SET_TexCoord4dv(disp, dlsym(RTLD_DEFAULT, "glTexCoord4dv"));
+ SET_TexCoord4f(disp, dlsym(RTLD_DEFAULT, "glTexCoord4f"));
+ SET_TexCoord4fv(disp, dlsym(RTLD_DEFAULT, "glTexCoord4fv"));
+ SET_TexCoord4i(disp, dlsym(RTLD_DEFAULT, "glTexCoord4i"));
+ SET_TexCoord4iv(disp, dlsym(RTLD_DEFAULT, "glTexCoord4iv"));
+ SET_TexCoord4s(disp, dlsym(RTLD_DEFAULT, "glTexCoord4s"));
+ SET_TexCoord4sv(disp, dlsym(RTLD_DEFAULT, "glTexCoord4sv"));
+ SET_TexCoordPointer(disp, dlsym(RTLD_DEFAULT, "glTexCoordPointer"));
+ SET_TexEnvf(disp, dlsym(RTLD_DEFAULT, "glTexEnvf"));
+ SET_TexEnvfv(disp, dlsym(RTLD_DEFAULT, "glTexEnvfv"));
+ SET_TexEnvi(disp, dlsym(RTLD_DEFAULT, "glTexEnvi"));
+ SET_TexEnviv(disp, dlsym(RTLD_DEFAULT, "glTexEnviv"));
+ SET_TexGend(disp, dlsym(RTLD_DEFAULT, "glTexGend"));
+ SET_TexGendv(disp, dlsym(RTLD_DEFAULT, "glTexGendv"));
+ SET_TexGenf(disp, dlsym(RTLD_DEFAULT, "glTexGenf"));
+ SET_TexGenfv(disp, dlsym(RTLD_DEFAULT, "glTexGenfv"));
+ SET_TexGeni(disp, dlsym(RTLD_DEFAULT, "glTexGeni"));
+ SET_TexGeniv(disp, dlsym(RTLD_DEFAULT, "glTexGeniv"));
/* Pointer Incompatability:
* internalformat is a GLenum according to /System/Library/Frameworks/OpenGL.framework/Headers/gl.h
@@ -1027,385 +932,363 @@ static void setup_dispatch_table(void) { * <rdar://problem/6953344> gl.h contains incorrect prototypes for glTexImage[123]D
*/
- SET_TexImage1D(disp, (void *)glTexImage1D);
- SET_TexImage2D(disp, (void *)glTexImage2D);
- SET_TexImage3D(disp, (void *)glTexImage3D);
- SET_TexParameterf(disp, glTexParameterf);
- SET_TexParameterfv(disp, glTexParameterfv);
- SET_TexParameteri(disp, glTexParameteri);
- SET_TexParameteriv(disp, glTexParameteriv);
- SET_TexSubImage1D(disp, glTexSubImage1D);
- SET_TexSubImage2D(disp, glTexSubImage2D);
- SET_TexSubImage3D(disp, glTexSubImage3D);
- SET_Translated(disp, glTranslated);
- SET_Translatef(disp, glTranslatef);
- SET_Vertex2d(disp, glVertex2d);
- SET_Vertex2dv(disp, glVertex2dv);
- SET_Vertex2f(disp, glVertex2f);
- SET_Vertex2fv(disp, glVertex2fv);
- SET_Vertex2i(disp, glVertex2i);
- SET_Vertex2iv(disp, glVertex2iv);
- SET_Vertex2s(disp, glVertex2s);
- SET_Vertex2sv(disp, glVertex2sv);
- SET_Vertex3d(disp, glVertex3d);
- SET_Vertex3dv(disp, glVertex3dv);
- SET_Vertex3f(disp, glVertex3f);
- SET_Vertex3fv(disp, glVertex3fv);
- SET_Vertex3i(disp, glVertex3i);
- SET_Vertex3iv(disp, glVertex3iv);
- SET_Vertex3s(disp, glVertex3s);
- SET_Vertex3sv(disp, glVertex3sv);
- SET_Vertex4d(disp, glVertex4d);
- SET_Vertex4dv(disp, glVertex4dv);
- SET_Vertex4f(disp, glVertex4f);
- SET_Vertex4fv(disp, glVertex4fv);
- SET_Vertex4i(disp, glVertex4i);
- SET_Vertex4iv(disp, glVertex4iv);
- SET_Vertex4s(disp, glVertex4s);
- SET_Vertex4sv(disp, glVertex4sv);
- SET_VertexPointer(disp, glVertexPointer);
- SET_Viewport(disp, glViewport);
-
-#if GL_VERSION_2_0
- SET_AttachShader(disp, glAttachShader);
- SET_DeleteShader(disp, glDeleteShader);
- SET_DetachShader(disp, glDetachShader);
- SET_GetAttachedShaders(disp, glGetAttachedShaders);
- SET_GetProgramInfoLog(disp, glGetProgramInfoLog);
- SET_GetShaderInfoLog(disp, glGetShaderInfoLog);
- SET_GetShaderiv(disp, glGetShaderiv);
- SET_IsShader(disp, glIsShader);
- SET_StencilFuncSeparate(disp, glStencilFuncSeparate);
- SET_StencilMaskSeparate(disp, glStencilMaskSeparate);
- SET_StencilOpSeparate(disp, glStencilOpSeparate);
-#endif
-
-#if GL_VERSION_2_1
- SET_UniformMatrix2x3fv(disp, glUniformMatrix2x3fv);
- SET_UniformMatrix2x4fv(disp, glUniformMatrix2x4fv);
- SET_UniformMatrix3x2fv(disp, glUniformMatrix3x2fv);
- SET_UniformMatrix3x4fv(disp, glUniformMatrix3x4fv);
- SET_UniformMatrix4x2fv(disp, glUniformMatrix4x2fv);
- SET_UniformMatrix4x3fv(disp, glUniformMatrix4x3fv);
-#endif
-
-#if GL_APPLE_vertex_array_object
- SET_BindVertexArrayAPPLE(disp, glBindVertexArrayAPPLE);
- SET_DeleteVertexArraysAPPLE(disp, glDeleteVertexArraysAPPLE);
- SET_GenVertexArraysAPPLE(disp, glGenVertexArraysAPPLE);
- SET_IsVertexArrayAPPLE(disp, glIsVertexArrayAPPLE);
-#endif
-
-#if GL_ARB_draw_buffers
- SET_DrawBuffersARB(disp, glDrawBuffersARB);
-#endif
-
-#if GL_ARB_multisample
- SET_SampleCoverageARB(disp, glSampleCoverageARB);
-#endif
-
-#if GL_ARB_multitexture
- SET_ActiveTextureARB(disp, glActiveTextureARB);
- SET_ClientActiveTextureARB(disp, glClientActiveTextureARB);
- SET_MultiTexCoord1dARB(disp, glMultiTexCoord1dARB);
- SET_MultiTexCoord1dvARB(disp, glMultiTexCoord1dvARB);
- SET_MultiTexCoord1fARB(disp, glMultiTexCoord1fARB);
- SET_MultiTexCoord1fvARB(disp, glMultiTexCoord1fvARB);
- SET_MultiTexCoord1iARB(disp, glMultiTexCoord1iARB);
- SET_MultiTexCoord1ivARB(disp, glMultiTexCoord1ivARB);
- SET_MultiTexCoord1sARB(disp, glMultiTexCoord1sARB);
- SET_MultiTexCoord1svARB(disp, glMultiTexCoord1svARB);
- SET_MultiTexCoord2dARB(disp, glMultiTexCoord2dARB);
- SET_MultiTexCoord2dvARB(disp, glMultiTexCoord2dvARB);
- SET_MultiTexCoord2fARB(disp, glMultiTexCoord2fARB);
- SET_MultiTexCoord2fvARB(disp, glMultiTexCoord2fvARB);
- SET_MultiTexCoord2iARB(disp, glMultiTexCoord2iARB);
- SET_MultiTexCoord2ivARB(disp, glMultiTexCoord2ivARB);
- SET_MultiTexCoord2sARB(disp, glMultiTexCoord2sARB);
- SET_MultiTexCoord2svARB(disp, glMultiTexCoord2svARB);
- SET_MultiTexCoord3dARB(disp, glMultiTexCoord3dARB);
- SET_MultiTexCoord3dvARB(disp, glMultiTexCoord3dvARB);
- SET_MultiTexCoord3fARB(disp, glMultiTexCoord3fARB);
- SET_MultiTexCoord3fvARB(disp, glMultiTexCoord3fvARB);
- SET_MultiTexCoord3iARB(disp, glMultiTexCoord3iARB);
- SET_MultiTexCoord3ivARB(disp, glMultiTexCoord3ivARB);
- SET_MultiTexCoord3sARB(disp, glMultiTexCoord3sARB);
- SET_MultiTexCoord3svARB(disp, glMultiTexCoord3svARB);
- SET_MultiTexCoord4dARB(disp, glMultiTexCoord4dARB);
- SET_MultiTexCoord4dvARB(disp, glMultiTexCoord4dvARB);
- SET_MultiTexCoord4fARB(disp, glMultiTexCoord4fARB);
- SET_MultiTexCoord4fvARB(disp, glMultiTexCoord4fvARB);
- SET_MultiTexCoord4iARB(disp, glMultiTexCoord4iARB);
- SET_MultiTexCoord4ivARB(disp, glMultiTexCoord4ivARB);
- SET_MultiTexCoord4sARB(disp, glMultiTexCoord4sARB);
- SET_MultiTexCoord4svARB(disp, glMultiTexCoord4svARB);
-#endif
-
-#if GL_ARB_occlusion_query
- SET_BeginQueryARB(disp, glBeginQueryARB);
- SET_DeleteQueriesARB(disp, glDeleteQueriesARB);
- SET_EndQueryARB(disp, glEndQueryARB);
- SET_GenQueriesARB(disp, glGenQueriesARB);
- SET_GetQueryObjectivARB(disp, glGetQueryObjectivARB);
- SET_GetQueryObjectuivARB(disp, glGetQueryObjectuivARB);
- SET_GetQueryivARB(disp, glGetQueryivARB);
- SET_IsQueryARB(disp, glIsQueryARB);
-#endif
-
-#if GL_ARB_shader_objects
- SET_AttachObjectARB(disp, glAttachObjectARB);
- SET_CompileShaderARB(disp, glCompileShaderARB);
- SET_DeleteObjectARB(disp, glDeleteObjectARB);
- SET_GetHandleARB(disp, glGetHandleARB);
- SET_DetachObjectARB(disp, glDetachObjectARB);
- SET_CreateProgramObjectARB(disp, glCreateProgramObjectARB);
- SET_CreateShaderObjectARB(disp, glCreateShaderObjectARB);
- SET_GetInfoLogARB(disp, glGetInfoLogARB);
- SET_GetActiveUniformARB(disp, glGetActiveUniformARB);
- SET_GetAttachedObjectsARB(disp, glGetAttachedObjectsARB);
- SET_GetObjectParameterfvARB(disp, glGetObjectParameterfvARB);
- SET_GetObjectParameterivARB(disp, glGetObjectParameterivARB);
- SET_GetShaderSourceARB(disp, glGetShaderSourceARB);
- SET_GetUniformLocationARB(disp, glGetUniformLocationARB);
- SET_GetUniformfvARB(disp, glGetUniformfvARB);
- SET_GetUniformivARB(disp, glGetUniformivARB);
- SET_LinkProgramARB(disp, glLinkProgramARB);
- SET_ShaderSourceARB(disp, glShaderSourceARB);
- SET_Uniform1fARB(disp, glUniform1fARB);
- SET_Uniform1fvARB(disp, glUniform1fvARB);
- SET_Uniform1iARB(disp, glUniform1iARB);
- SET_Uniform1ivARB(disp, glUniform1ivARB);
- SET_Uniform2fARB(disp, glUniform2fARB);
- SET_Uniform2fvARB(disp, glUniform2fvARB);
- SET_Uniform2iARB(disp, glUniform2iARB);
- SET_Uniform2ivARB(disp, glUniform2ivARB);
- SET_Uniform3fARB(disp, glUniform3fARB);
- SET_Uniform3fvARB(disp, glUniform3fvARB);
- SET_Uniform3iARB(disp, glUniform3iARB);
- SET_Uniform3ivARB(disp, glUniform3ivARB);
- SET_Uniform4fARB(disp, glUniform4fARB);
- SET_Uniform4fvARB(disp, glUniform4fvARB);
- SET_Uniform4iARB(disp, glUniform4iARB);
- SET_Uniform4ivARB(disp, glUniform4ivARB);
- SET_UniformMatrix2fvARB(disp, glUniformMatrix2fvARB);
- SET_UniformMatrix3fvARB(disp, glUniformMatrix3fvARB);
- SET_UniformMatrix4fvARB(disp, glUniformMatrix4fvARB);
- SET_UseProgramObjectARB(disp, glUseProgramObjectARB);
- SET_ValidateProgramARB(disp, glValidateProgramARB);
-#endif
-
-#if GL_ARB_texture_compression
- SET_CompressedTexImage1DARB(disp, glCompressedTexImage1DARB);
- SET_CompressedTexImage2DARB(disp, glCompressedTexImage2DARB);
- SET_CompressedTexImage3DARB(disp, glCompressedTexImage3DARB);
- SET_CompressedTexSubImage1DARB(disp, glCompressedTexSubImage1DARB);
- SET_CompressedTexSubImage2DARB(disp, glCompressedTexSubImage2DARB);
- SET_CompressedTexSubImage3DARB(disp, glCompressedTexSubImage3DARB);
- SET_GetCompressedTexImageARB(disp, glGetCompressedTexImageARB);
-#endif
-
-#if GL_ARB_transpose_matrix
- SET_LoadTransposeMatrixdARB(disp, glLoadTransposeMatrixdARB);
- SET_LoadTransposeMatrixfARB(disp, glLoadTransposeMatrixfARB);
- SET_MultTransposeMatrixdARB(disp, glMultTransposeMatrixdARB);
- SET_MultTransposeMatrixfARB(disp, glMultTransposeMatrixfARB);
-#endif
-
-#if GL_ARB_vertex_buffer_object
- SET_BindBufferARB(disp, glBindBufferARB);
- SET_BufferDataARB(disp, glBufferDataARB);
- SET_BufferSubDataARB(disp, glBufferSubDataARB);
- SET_DeleteBuffersARB(disp, glDeleteBuffersARB);
- SET_GenBuffersARB(disp, glGenBuffersARB);
- SET_GetBufferParameterivARB(disp, glGetBufferParameterivARB);
- SET_GetBufferPointervARB(disp, glGetBufferPointervARB);
- SET_GetBufferSubDataARB(disp, glGetBufferSubDataARB);
- SET_IsBufferARB(disp, glIsBufferARB);
- SET_MapBufferARB(disp, glMapBufferARB);
- SET_UnmapBufferARB(disp, glUnmapBufferARB);
-#endif
-
-#if GL_ARB_vertex_program
- SET_DisableVertexAttribArrayARB(disp, glDisableVertexAttribArrayARB);
- SET_EnableVertexAttribArrayARB(disp, glEnableVertexAttribArrayARB);
- SET_GetProgramEnvParameterdvARB(disp, glGetProgramEnvParameterdvARB);
- SET_GetProgramEnvParameterfvARB(disp, glGetProgramEnvParameterfvARB);
- SET_GetProgramLocalParameterdvARB(disp, glGetProgramLocalParameterdvARB);
- SET_GetProgramLocalParameterfvARB(disp, glGetProgramLocalParameterfvARB);
- SET_GetProgramStringARB(disp, glGetProgramStringARB);
- SET_GetProgramivARB(disp, glGetProgramivARB);
- SET_GetVertexAttribdvARB(disp, glGetVertexAttribdvARB);
- SET_GetVertexAttribfvARB(disp, glGetVertexAttribfvARB);
- SET_GetVertexAttribivARB(disp, glGetVertexAttribivARB);
- SET_ProgramEnvParameter4dARB(disp, glProgramEnvParameter4dARB);
- SET_ProgramEnvParameter4dvARB(disp, glProgramEnvParameter4dvARB);
- SET_ProgramEnvParameter4fARB(disp, glProgramEnvParameter4fARB);
- SET_ProgramEnvParameter4fvARB(disp, glProgramEnvParameter4fvARB);
- SET_ProgramLocalParameter4dARB(disp, glProgramLocalParameter4dARB);
- SET_ProgramLocalParameter4dvARB(disp, glProgramLocalParameter4dvARB);
- SET_ProgramLocalParameter4fARB(disp, glProgramLocalParameter4fARB);
- SET_ProgramLocalParameter4fvARB(disp, glProgramLocalParameter4fvARB);
- SET_ProgramStringARB(disp, glProgramStringARB);
- SET_VertexAttrib1dARB(disp, glVertexAttrib1dARB);
- SET_VertexAttrib1dvARB(disp, glVertexAttrib1dvARB);
- SET_VertexAttrib1fARB(disp, glVertexAttrib1fARB);
- SET_VertexAttrib1fvARB(disp, glVertexAttrib1fvARB);
- SET_VertexAttrib1sARB(disp, glVertexAttrib1sARB);
- SET_VertexAttrib1svARB(disp, glVertexAttrib1svARB);
- SET_VertexAttrib2dARB(disp, glVertexAttrib2dARB);
- SET_VertexAttrib2dvARB(disp, glVertexAttrib2dvARB);
- SET_VertexAttrib2fARB(disp, glVertexAttrib2fARB);
- SET_VertexAttrib2fvARB(disp, glVertexAttrib2fvARB);
- SET_VertexAttrib2sARB(disp, glVertexAttrib2sARB);
- SET_VertexAttrib2svARB(disp, glVertexAttrib2svARB);
- SET_VertexAttrib3dARB(disp, glVertexAttrib3dARB);
- SET_VertexAttrib3dvARB(disp, glVertexAttrib3dvARB);
- SET_VertexAttrib3fARB(disp, glVertexAttrib3fARB);
- SET_VertexAttrib3fvARB(disp, glVertexAttrib3fvARB);
- SET_VertexAttrib3sARB(disp, glVertexAttrib3sARB);
- SET_VertexAttrib3svARB(disp, glVertexAttrib3svARB);
- SET_VertexAttrib4NbvARB(disp, glVertexAttrib4NbvARB);
- SET_VertexAttrib4NivARB(disp, glVertexAttrib4NivARB);
- SET_VertexAttrib4NsvARB(disp, glVertexAttrib4NsvARB);
- SET_VertexAttrib4NubARB(disp, glVertexAttrib4NubARB);
- SET_VertexAttrib4NubvARB(disp, glVertexAttrib4NubvARB);
- SET_VertexAttrib4NuivARB(disp, glVertexAttrib4NuivARB);
- SET_VertexAttrib4NusvARB(disp, glVertexAttrib4NusvARB);
- SET_VertexAttrib4bvARB(disp, glVertexAttrib4bvARB);
- SET_VertexAttrib4dARB(disp, glVertexAttrib4dARB);
- SET_VertexAttrib4dvARB(disp, glVertexAttrib4dvARB);
- SET_VertexAttrib4fARB(disp, glVertexAttrib4fARB);
- SET_VertexAttrib4fvARB(disp, glVertexAttrib4fvARB);
- SET_VertexAttrib4ivARB(disp, glVertexAttrib4ivARB);
- SET_VertexAttrib4sARB(disp, glVertexAttrib4sARB);
- SET_VertexAttrib4svARB(disp, glVertexAttrib4svARB);
- SET_VertexAttrib4ubvARB(disp, glVertexAttrib4ubvARB);
- SET_VertexAttrib4uivARB(disp, glVertexAttrib4uivARB);
- SET_VertexAttrib4usvARB(disp, glVertexAttrib4usvARB);
- SET_VertexAttribPointerARB(disp, glVertexAttribPointerARB);
-#endif
-
-#if GL_ARB_vertex_shader
- SET_BindAttribLocationARB(disp, glBindAttribLocationARB);
- SET_GetActiveAttribARB(disp, glGetActiveAttribARB);
- SET_GetAttribLocationARB(disp, glGetAttribLocationARB);
-#endif
-
-#if GL_ARB_window_pos
- SET_WindowPos2dMESA(disp, glWindowPos2dARB);
- SET_WindowPos2dvMESA(disp, glWindowPos2dvARB);
- SET_WindowPos2fMESA(disp, glWindowPos2fARB);
- SET_WindowPos2fvMESA(disp, glWindowPos2fvARB);
- SET_WindowPos2iMESA(disp, glWindowPos2iARB);
- SET_WindowPos2ivMESA(disp, glWindowPos2ivARB);
- SET_WindowPos2sMESA(disp, glWindowPos2sARB);
- SET_WindowPos2svMESA(disp, glWindowPos2svARB);
- SET_WindowPos3dMESA(disp, glWindowPos3dARB);
- SET_WindowPos3dvMESA(disp, glWindowPos3dvARB);
- SET_WindowPos3fMESA(disp, glWindowPos3fARB);
- SET_WindowPos3fvMESA(disp, glWindowPos3fvARB);
- SET_WindowPos3iMESA(disp, glWindowPos3iARB);
- SET_WindowPos3ivMESA(disp, glWindowPos3ivARB);
- SET_WindowPos3sMESA(disp, glWindowPos3sARB);
- SET_WindowPos3svMESA(disp, glWindowPos3svARB);
-#endif
-
-#if GL_ATI_fragment_shader
- SET_AlphaFragmentOp1ATI(disp, glAlphaFragmentOp1ATI);
- SET_AlphaFragmentOp2ATI(disp, glAlphaFragmentOp2ATI);
- SET_AlphaFragmentOp3ATI(disp, glAlphaFragmentOp3ATI);
- SET_BeginFragmentShaderATI(disp, glBeginFragmentShaderATI);
- SET_BindFragmentShaderATI(disp, glBindFragmentShaderATI);
- SET_ColorFragmentOp1ATI(disp, glColorFragmentOp1ATI);
- SET_ColorFragmentOp2ATI(disp, glColorFragmentOp2ATI);
- SET_ColorFragmentOp3ATI(disp, glColorFragmentOp3ATI);
- SET_DeleteFragmentShaderATI(disp, glDeleteFragmentShaderATI);
- SET_EndFragmentShaderATI(disp, glEndFragmentShaderATI);
- SET_GenFragmentShadersATI(disp, glGenFragmentShadersATI);
- SET_PassTexCoordATI(disp, glPassTexCoordATI);
- SET_SampleMapATI(disp, glSampleMapATI);
- SET_SetFragmentShaderConstantATI(disp, glSetFragmentShaderConstantATI);
-#elif GL_EXT_fragment_shader
- SET_AlphaFragmentOp1ATI(disp, glAlphaFragmentOp1EXT);
- SET_AlphaFragmentOp2ATI(disp, glAlphaFragmentOp2EXT);
- SET_AlphaFragmentOp3ATI(disp, glAlphaFragmentOp3EXT);
- SET_BeginFragmentShaderATI(disp, glBeginFragmentShaderEXT);
- SET_BindFragmentShaderATI(disp, glBindFragmentShaderEXT);
- SET_ColorFragmentOp1ATI(disp, glColorFragmentOp1EXT);
- SET_ColorFragmentOp2ATI(disp, glColorFragmentOp2EXT);
- SET_ColorFragmentOp3ATI(disp, glColorFragmentOp3EXT);
- SET_DeleteFragmentShaderATI(disp, glDeleteFragmentShaderEXT);
- SET_EndFragmentShaderATI(disp, glEndFragmentShaderEXT);
- SET_GenFragmentShadersATI(disp, glGenFragmentShadersEXT);
- SET_PassTexCoordATI(disp, glPassTexCoordEXT);
- SET_SampleMapATI(disp, glSampleMapEXT);
- SET_SetFragmentShaderConstantATI(disp, glSetFragmentShaderConstantEXT);
-#endif
-
-#if GL_ATI_separate_stencil
- SET_StencilFuncSeparateATI(disp, glStencilFuncSeparateATI);
-#endif
-
-#if GL_EXT_blend_equation_separate
- SET_BlendEquationSeparateEXT(disp, glBlendEquationSeparateEXT);
-#endif
-
-#if GL_EXT_blend_func_separate
- SET_BlendFuncSeparateEXT(disp, glBlendFuncSeparateEXT);
-#endif
-
-#if GL_EXT_depth_bounds_test
- SET_DepthBoundsEXT(disp, glDepthBoundsEXT);
-#endif
-
-#if GL_EXT_compiled_vertex_array
- SET_LockArraysEXT(disp, glLockArraysEXT);
- SET_UnlockArraysEXT(disp, glUnlockArraysEXT);
-#endif
-
-#if GL_EXT_cull_vertex
- SET_CullParameterdvEXT(disp, glCullParameterdvEXT);
- SET_CullParameterfvEXT(disp, glCullParameterfvEXT);
-#endif
-
-#if GL_EXT_fog_coord
- SET_FogCoordPointerEXT(disp, glFogCoordPointerEXT);
- SET_FogCoorddEXT(disp, glFogCoorddEXT);
- SET_FogCoorddvEXT(disp, glFogCoorddvEXT);
- SET_FogCoordfEXT(disp, glFogCoordfEXT);
- SET_FogCoordfvEXT(disp, glFogCoordfvEXT);
-#endif
-
-#if GL_EXT_framebuffer_blit
- SET_BlitFramebufferEXT(disp, glBlitFramebufferEXT);
-#endif
-
-#if GL_EXT_framebuffer_object
- SET_BindFramebufferEXT(disp, glBindFramebufferEXT);
- SET_BindRenderbufferEXT(disp, glBindRenderbufferEXT);
- SET_CheckFramebufferStatusEXT(disp, glCheckFramebufferStatusEXT);
- SET_DeleteFramebuffersEXT(disp, glDeleteFramebuffersEXT);
- SET_DeleteRenderbuffersEXT(disp, glDeleteRenderbuffersEXT);
- SET_FramebufferRenderbufferEXT(disp, glFramebufferRenderbufferEXT);
- SET_FramebufferTexture1DEXT(disp, glFramebufferTexture1DEXT);
- SET_FramebufferTexture2DEXT(disp, glFramebufferTexture2DEXT);
- SET_FramebufferTexture3DEXT(disp, glFramebufferTexture3DEXT);
- SET_GenerateMipmapEXT(disp, glGenerateMipmapEXT);
- SET_GenFramebuffersEXT(disp, glGenFramebuffersEXT);
- SET_GenRenderbuffersEXT(disp, glGenRenderbuffersEXT);
- SET_GetFramebufferAttachmentParameterivEXT(disp, glGetFramebufferAttachmentParameterivEXT);
- SET_GetRenderbufferParameterivEXT(disp, glGetRenderbufferParameterivEXT);
- SET_IsFramebufferEXT(disp, glIsFramebufferEXT);
- SET_IsRenderbufferEXT(disp, glIsRenderbufferEXT);
- SET_RenderbufferStorageEXT(disp, glRenderbufferStorageEXT);
-#endif
+ SET_TexImage1D(disp, dlsym(RTLD_DEFAULT, "glTexImage1D"));
+ SET_TexImage2D(disp, dlsym(RTLD_DEFAULT, "glTexImage2D"));
+ SET_TexImage3D(disp, dlsym(RTLD_DEFAULT, "glTexImage3D"));
+ SET_TexParameterf(disp, dlsym(RTLD_DEFAULT, "glTexParameterf"));
+ SET_TexParameterfv(disp, dlsym(RTLD_DEFAULT, "glTexParameterfv"));
+ SET_TexParameteri(disp, dlsym(RTLD_DEFAULT, "glTexParameteri"));
+ SET_TexParameteriv(disp, dlsym(RTLD_DEFAULT, "glTexParameteriv"));
+ SET_TexSubImage1D(disp, dlsym(RTLD_DEFAULT, "glTexSubImage1D"));
+ SET_TexSubImage2D(disp, dlsym(RTLD_DEFAULT, "glTexSubImage2D"));
+ SET_TexSubImage3D(disp, dlsym(RTLD_DEFAULT, "glTexSubImage3D"));
+ SET_Translated(disp, dlsym(RTLD_DEFAULT, "glTranslated"));
+ SET_Translatef(disp, dlsym(RTLD_DEFAULT, "glTranslatef"));
+ SET_Vertex2d(disp, dlsym(RTLD_DEFAULT, "glVertex2d"));
+ SET_Vertex2dv(disp, dlsym(RTLD_DEFAULT, "glVertex2dv"));
+ SET_Vertex2f(disp, dlsym(RTLD_DEFAULT, "glVertex2f"));
+ SET_Vertex2fv(disp, dlsym(RTLD_DEFAULT, "glVertex2fv"));
+ SET_Vertex2i(disp, dlsym(RTLD_DEFAULT, "glVertex2i"));
+ SET_Vertex2iv(disp, dlsym(RTLD_DEFAULT, "glVertex2iv"));
+ SET_Vertex2s(disp, dlsym(RTLD_DEFAULT, "glVertex2s"));
+ SET_Vertex2sv(disp, dlsym(RTLD_DEFAULT, "glVertex2sv"));
+ SET_Vertex3d(disp, dlsym(RTLD_DEFAULT, "glVertex3d"));
+ SET_Vertex3dv(disp, dlsym(RTLD_DEFAULT, "glVertex3dv"));
+ SET_Vertex3f(disp, dlsym(RTLD_DEFAULT, "glVertex3f"));
+ SET_Vertex3fv(disp, dlsym(RTLD_DEFAULT, "glVertex3fv"));
+ SET_Vertex3i(disp, dlsym(RTLD_DEFAULT, "glVertex3i"));
+ SET_Vertex3iv(disp, dlsym(RTLD_DEFAULT, "glVertex3iv"));
+ SET_Vertex3s(disp, dlsym(RTLD_DEFAULT, "glVertex3s"));
+ SET_Vertex3sv(disp, dlsym(RTLD_DEFAULT, "glVertex3sv"));
+ SET_Vertex4d(disp, dlsym(RTLD_DEFAULT, "glVertex4d"));
+ SET_Vertex4dv(disp, dlsym(RTLD_DEFAULT, "glVertex4dv"));
+ SET_Vertex4f(disp, dlsym(RTLD_DEFAULT, "glVertex4f"));
+ SET_Vertex4fv(disp, dlsym(RTLD_DEFAULT, "glVertex4fv"));
+ SET_Vertex4i(disp, dlsym(RTLD_DEFAULT, "glVertex4i"));
+ SET_Vertex4iv(disp, dlsym(RTLD_DEFAULT, "glVertex4iv"));
+ SET_Vertex4s(disp, dlsym(RTLD_DEFAULT, "glVertex4s"));
+ SET_Vertex4sv(disp, dlsym(RTLD_DEFAULT, "glVertex4sv"));
+ SET_VertexPointer(disp, dlsym(RTLD_DEFAULT, "glVertexPointer"));
+ SET_Viewport(disp, dlsym(RTLD_DEFAULT, "glViewport"));
+
+ /* GL_VERSION_2_0 */
+ SET_AttachShader(disp, dlsym(RTLD_DEFAULT, "glAttachShader"));
+ SET_DeleteShader(disp, dlsym(RTLD_DEFAULT, "glDeleteShader"));
+ SET_DetachShader(disp, dlsym(RTLD_DEFAULT, "glDetachShader"));
+ SET_GetAttachedShaders(disp, dlsym(RTLD_DEFAULT, "glGetAttachedShaders"));
+ SET_GetProgramInfoLog(disp, dlsym(RTLD_DEFAULT, "glGetProgramInfoLog"));
+ SET_GetShaderInfoLog(disp, dlsym(RTLD_DEFAULT, "glGetShaderInfoLog"));
+ SET_GetShaderiv(disp, dlsym(RTLD_DEFAULT, "glGetShaderiv"));
+ SET_IsShader(disp, dlsym(RTLD_DEFAULT, "glIsShader"));
+ SET_StencilFuncSeparate(disp, dlsym(RTLD_DEFAULT, "glStencilFuncSeparate"));
+ SET_StencilMaskSeparate(disp, dlsym(RTLD_DEFAULT, "glStencilMaskSeparate"));
+ SET_StencilOpSeparate(disp, dlsym(RTLD_DEFAULT, "glStencilOpSeparate"));
+
+ /* GL_VERSION_2_1 */
+ SET_UniformMatrix2x3fv(disp, dlsym(RTLD_DEFAULT, "glUniformMatrix2x3fv"));
+ SET_UniformMatrix2x4fv(disp, dlsym(RTLD_DEFAULT, "glUniformMatrix2x4fv"));
+ SET_UniformMatrix3x2fv(disp, dlsym(RTLD_DEFAULT, "glUniformMatrix3x2fv"));
+ SET_UniformMatrix3x4fv(disp, dlsym(RTLD_DEFAULT, "glUniformMatrix3x4fv"));
+ SET_UniformMatrix4x2fv(disp, dlsym(RTLD_DEFAULT, "glUniformMatrix4x2fv"));
+ SET_UniformMatrix4x3fv(disp, dlsym(RTLD_DEFAULT, "glUniformMatrix4x3fv"));
+
+ /* GL_APPLE_vertex_array_object */
+ SET_BindVertexArrayAPPLE(disp, dlsym(RTLD_DEFAULT, "glBindVertexArrayAPPLE"));
+ SET_DeleteVertexArraysAPPLE(disp, dlsym(RTLD_DEFAULT, "glDeleteVertexArraysAPPLE"));
+ SET_GenVertexArraysAPPLE(disp, dlsym(RTLD_DEFAULT, "glGenVertexArraysAPPLE"));
+ SET_IsVertexArrayAPPLE(disp, dlsym(RTLD_DEFAULT, "glIsVertexArrayAPPLE"));
+
+ /* GL_ARB_draw_buffers */
+ SET_DrawBuffersARB(disp, dlsym(RTLD_DEFAULT, "glDrawBuffersARB"));
+
+ /* GL_ARB_multisample */
+ SET_SampleCoverageARB(disp, dlsym(RTLD_DEFAULT, "glSampleCoverageARB"));
+
+ /* GL_ARB_multitexture */
+ SET_ActiveTextureARB(disp, dlsym(RTLD_DEFAULT, "glActiveTextureARB"));
+ SET_ClientActiveTextureARB(disp, dlsym(RTLD_DEFAULT, "glClientActiveTextureARB"));
+ SET_MultiTexCoord1dARB(disp, dlsym(RTLD_DEFAULT, "glMultiTexCoord1dARB"));
+ SET_MultiTexCoord1dvARB(disp, dlsym(RTLD_DEFAULT, "glMultiTexCoord1dvARB"));
+ SET_MultiTexCoord1fARB(disp, dlsym(RTLD_DEFAULT, "glMultiTexCoord1fARB"));
+ SET_MultiTexCoord1fvARB(disp, dlsym(RTLD_DEFAULT, "glMultiTexCoord1fvARB"));
+ SET_MultiTexCoord1iARB(disp, dlsym(RTLD_DEFAULT, "glMultiTexCoord1iARB"));
+ SET_MultiTexCoord1ivARB(disp, dlsym(RTLD_DEFAULT, "glMultiTexCoord1ivARB"));
+ SET_MultiTexCoord1sARB(disp, dlsym(RTLD_DEFAULT, "glMultiTexCoord1sARB"));
+ SET_MultiTexCoord1svARB(disp, dlsym(RTLD_DEFAULT, "glMultiTexCoord1svARB"));
+ SET_MultiTexCoord2dARB(disp, dlsym(RTLD_DEFAULT, "glMultiTexCoord2dARB"));
+ SET_MultiTexCoord2dvARB(disp, dlsym(RTLD_DEFAULT, "glMultiTexCoord2dvARB"));
+ SET_MultiTexCoord2fARB(disp, dlsym(RTLD_DEFAULT, "glMultiTexCoord2fARB"));
+ SET_MultiTexCoord2fvARB(disp, dlsym(RTLD_DEFAULT, "glMultiTexCoord2fvARB"));
+ SET_MultiTexCoord2iARB(disp, dlsym(RTLD_DEFAULT, "glMultiTexCoord2iARB"));
+ SET_MultiTexCoord2ivARB(disp, dlsym(RTLD_DEFAULT, "glMultiTexCoord2ivARB"));
+ SET_MultiTexCoord2sARB(disp, dlsym(RTLD_DEFAULT, "glMultiTexCoord2sARB"));
+ SET_MultiTexCoord2svARB(disp, dlsym(RTLD_DEFAULT, "glMultiTexCoord2svARB"));
+ SET_MultiTexCoord3dARB(disp, dlsym(RTLD_DEFAULT, "glMultiTexCoord3dARB"));
+ SET_MultiTexCoord3dvARB(disp, dlsym(RTLD_DEFAULT, "glMultiTexCoord3dvARB"));
+ SET_MultiTexCoord3fARB(disp, dlsym(RTLD_DEFAULT, "glMultiTexCoord3fARB"));
+ SET_MultiTexCoord3fvARB(disp, dlsym(RTLD_DEFAULT, "glMultiTexCoord3fvARB"));
+ SET_MultiTexCoord3iARB(disp, dlsym(RTLD_DEFAULT, "glMultiTexCoord3iARB"));
+ SET_MultiTexCoord3ivARB(disp, dlsym(RTLD_DEFAULT, "glMultiTexCoord3ivARB"));
+ SET_MultiTexCoord3sARB(disp, dlsym(RTLD_DEFAULT, "glMultiTexCoord3sARB"));
+ SET_MultiTexCoord3svARB(disp, dlsym(RTLD_DEFAULT, "glMultiTexCoord3svARB"));
+ SET_MultiTexCoord4dARB(disp, dlsym(RTLD_DEFAULT, "glMultiTexCoord4dARB"));
+ SET_MultiTexCoord4dvARB(disp, dlsym(RTLD_DEFAULT, "glMultiTexCoord4dvARB"));
+ SET_MultiTexCoord4fARB(disp, dlsym(RTLD_DEFAULT, "glMultiTexCoord4fARB"));
+ SET_MultiTexCoord4fvARB(disp, dlsym(RTLD_DEFAULT, "glMultiTexCoord4fvARB"));
+ SET_MultiTexCoord4iARB(disp, dlsym(RTLD_DEFAULT, "glMultiTexCoord4iARB"));
+ SET_MultiTexCoord4ivARB(disp, dlsym(RTLD_DEFAULT, "glMultiTexCoord4ivARB"));
+ SET_MultiTexCoord4sARB(disp, dlsym(RTLD_DEFAULT, "glMultiTexCoord4sARB"));
+ SET_MultiTexCoord4svARB(disp, dlsym(RTLD_DEFAULT, "glMultiTexCoord4svARB"));
+
+ /* GL_ARB_occlusion_query */
+ SET_BeginQueryARB(disp, dlsym(RTLD_DEFAULT, "glBeginQueryARB"));
+ SET_DeleteQueriesARB(disp, dlsym(RTLD_DEFAULT, "glDeleteQueriesARB"));
+ SET_EndQueryARB(disp, dlsym(RTLD_DEFAULT, "glEndQueryARB"));
+ SET_GenQueriesARB(disp, dlsym(RTLD_DEFAULT, "glGenQueriesARB"));
+ SET_GetQueryObjectivARB(disp, dlsym(RTLD_DEFAULT, "glGetQueryObjectivARB"));
+ SET_GetQueryObjectuivARB(disp, dlsym(RTLD_DEFAULT, "glGetQueryObjectuivARB"));
+ SET_GetQueryivARB(disp, dlsym(RTLD_DEFAULT, "glGetQueryivARB"));
+ SET_IsQueryARB(disp, dlsym(RTLD_DEFAULT, "glIsQueryARB"));
+
+ /* GL_ARB_shader_objects */
+ SET_AttachObjectARB(disp, dlsym(RTLD_DEFAULT, "glAttachObjectARB"));
+ SET_CompileShaderARB(disp, dlsym(RTLD_DEFAULT, "glCompileShaderARB"));
+ SET_DeleteObjectARB(disp, dlsym(RTLD_DEFAULT, "glDeleteObjectARB"));
+ SET_GetHandleARB(disp, dlsym(RTLD_DEFAULT, "glGetHandleARB"));
+ SET_DetachObjectARB(disp, dlsym(RTLD_DEFAULT, "glDetachObjectARB"));
+ SET_CreateProgramObjectARB(disp, dlsym(RTLD_DEFAULT, "glCreateProgramObjectARB"));
+ SET_CreateShaderObjectARB(disp, dlsym(RTLD_DEFAULT, "glCreateShaderObjectARB"));
+ SET_GetInfoLogARB(disp, dlsym(RTLD_DEFAULT, "glGetInfoLogARB"));
+ SET_GetActiveUniformARB(disp, dlsym(RTLD_DEFAULT, "glGetActiveUniformARB"));
+ SET_GetAttachedObjectsARB(disp, dlsym(RTLD_DEFAULT, "glGetAttachedObjectsARB"));
+ SET_GetObjectParameterfvARB(disp, dlsym(RTLD_DEFAULT, "glGetObjectParameterfvARB"));
+ SET_GetObjectParameterivARB(disp, dlsym(RTLD_DEFAULT, "glGetObjectParameterivARB"));
+ SET_GetShaderSourceARB(disp, dlsym(RTLD_DEFAULT, "glGetShaderSourceARB"));
+ SET_GetUniformLocationARB(disp, dlsym(RTLD_DEFAULT, "glGetUniformLocationARB"));
+ SET_GetUniformfvARB(disp, dlsym(RTLD_DEFAULT, "glGetUniformfvARB"));
+ SET_GetUniformivARB(disp, dlsym(RTLD_DEFAULT, "glGetUniformivARB"));
+ SET_LinkProgramARB(disp, dlsym(RTLD_DEFAULT, "glLinkProgramARB"));
+ SET_ShaderSourceARB(disp, dlsym(RTLD_DEFAULT, "glShaderSourceARB"));
+ SET_Uniform1fARB(disp, dlsym(RTLD_DEFAULT, "glUniform1fARB"));
+ SET_Uniform1fvARB(disp, dlsym(RTLD_DEFAULT, "glUniform1fvARB"));
+ SET_Uniform1iARB(disp, dlsym(RTLD_DEFAULT, "glUniform1iARB"));
+ SET_Uniform1ivARB(disp, dlsym(RTLD_DEFAULT, "glUniform1ivARB"));
+ SET_Uniform2fARB(disp, dlsym(RTLD_DEFAULT, "glUniform2fARB"));
+ SET_Uniform2fvARB(disp, dlsym(RTLD_DEFAULT, "glUniform2fvARB"));
+ SET_Uniform2iARB(disp, dlsym(RTLD_DEFAULT, "glUniform2iARB"));
+ SET_Uniform2ivARB(disp, dlsym(RTLD_DEFAULT, "glUniform2ivARB"));
+ SET_Uniform3fARB(disp, dlsym(RTLD_DEFAULT, "glUniform3fARB"));
+ SET_Uniform3fvARB(disp, dlsym(RTLD_DEFAULT, "glUniform3fvARB"));
+ SET_Uniform3iARB(disp, dlsym(RTLD_DEFAULT, "glUniform3iARB"));
+ SET_Uniform3ivARB(disp, dlsym(RTLD_DEFAULT, "glUniform3ivARB"));
+ SET_Uniform4fARB(disp, dlsym(RTLD_DEFAULT, "glUniform4fARB"));
+ SET_Uniform4fvARB(disp, dlsym(RTLD_DEFAULT, "glUniform4fvARB"));
+ SET_Uniform4iARB(disp, dlsym(RTLD_DEFAULT, "glUniform4iARB"));
+ SET_Uniform4ivARB(disp, dlsym(RTLD_DEFAULT, "glUniform4ivARB"));
+ SET_UniformMatrix2fvARB(disp, dlsym(RTLD_DEFAULT, "glUniformMatrix2fvARB"));
+ SET_UniformMatrix3fvARB(disp, dlsym(RTLD_DEFAULT, "glUniformMatrix3fvARB"));
+ SET_UniformMatrix4fvARB(disp, dlsym(RTLD_DEFAULT, "glUniformMatrix4fvARB"));
+ SET_UseProgramObjectARB(disp, dlsym(RTLD_DEFAULT, "glUseProgramObjectARB"));
+ SET_ValidateProgramARB(disp, dlsym(RTLD_DEFAULT, "glValidateProgramARB"));
+
+ /* GL_ARB_texture_compression */
+ SET_CompressedTexImage1DARB(disp, dlsym(RTLD_DEFAULT, "glCompressedTexImage1DARB"));
+ SET_CompressedTexImage2DARB(disp, dlsym(RTLD_DEFAULT, "glCompressedTexImage2DARB"));
+ SET_CompressedTexImage3DARB(disp, dlsym(RTLD_DEFAULT, "glCompressedTexImage3DARB"));
+ SET_CompressedTexSubImage1DARB(disp, dlsym(RTLD_DEFAULT, "glCompressedTexSubImage1DARB"));
+ SET_CompressedTexSubImage2DARB(disp, dlsym(RTLD_DEFAULT, "glCompressedTexSubImage2DARB"));
+ SET_CompressedTexSubImage3DARB(disp, dlsym(RTLD_DEFAULT, "glCompressedTexSubImage3DARB"));
+ SET_GetCompressedTexImageARB(disp, dlsym(RTLD_DEFAULT, "glGetCompressedTexImageARB"));
+
+ /* GL_ARB_transpose_matrix */
+ SET_LoadTransposeMatrixdARB(disp, dlsym(RTLD_DEFAULT, "glLoadTransposeMatrixdARB"));
+ SET_LoadTransposeMatrixfARB(disp, dlsym(RTLD_DEFAULT, "glLoadTransposeMatrixfARB"));
+ SET_MultTransposeMatrixdARB(disp, dlsym(RTLD_DEFAULT, "glMultTransposeMatrixdARB"));
+ SET_MultTransposeMatrixfARB(disp, dlsym(RTLD_DEFAULT, "glMultTransposeMatrixfARB"));
+
+ /* GL_ARB_vertex_buffer_object */
+ SET_BindBufferARB(disp, dlsym(RTLD_DEFAULT, "glBindBufferARB"));
+ SET_BufferDataARB(disp, dlsym(RTLD_DEFAULT, "glBufferDataARB"));
+ SET_BufferSubDataARB(disp, dlsym(RTLD_DEFAULT, "glBufferSubDataARB"));
+ SET_DeleteBuffersARB(disp, dlsym(RTLD_DEFAULT, "glDeleteBuffersARB"));
+ SET_GenBuffersARB(disp, dlsym(RTLD_DEFAULT, "glGenBuffersARB"));
+ SET_GetBufferParameterivARB(disp, dlsym(RTLD_DEFAULT, "glGetBufferParameterivARB"));
+ SET_GetBufferPointervARB(disp, dlsym(RTLD_DEFAULT, "glGetBufferPointervARB"));
+ SET_GetBufferSubDataARB(disp, dlsym(RTLD_DEFAULT, "glGetBufferSubDataARB"));
+ SET_IsBufferARB(disp, dlsym(RTLD_DEFAULT, "glIsBufferARB"));
+ SET_MapBufferARB(disp, dlsym(RTLD_DEFAULT, "glMapBufferARB"));
+ SET_UnmapBufferARB(disp, dlsym(RTLD_DEFAULT, "glUnmapBufferARB"));
+
+ /* GL_ARB_vertex_program */
+ SET_DisableVertexAttribArrayARB(disp, dlsym(RTLD_DEFAULT, "glDisableVertexAttribArrayARB"));
+ SET_EnableVertexAttribArrayARB(disp, dlsym(RTLD_DEFAULT, "glEnableVertexAttribArrayARB"));
+ SET_GetProgramEnvParameterdvARB(disp, dlsym(RTLD_DEFAULT, "glGetProgramEnvParameterdvARB"));
+ SET_GetProgramEnvParameterfvARB(disp, dlsym(RTLD_DEFAULT, "glGetProgramEnvParameterfvARB"));
+ SET_GetProgramLocalParameterdvARB(disp, dlsym(RTLD_DEFAULT, "glGetProgramLocalParameterdvARB"));
+ SET_GetProgramLocalParameterfvARB(disp, dlsym(RTLD_DEFAULT, "glGetProgramLocalParameterfvARB"));
+ SET_GetProgramStringARB(disp, dlsym(RTLD_DEFAULT, "glGetProgramStringARB"));
+ SET_GetProgramivARB(disp, dlsym(RTLD_DEFAULT, "glGetProgramivARB"));
+ SET_GetVertexAttribdvARB(disp, dlsym(RTLD_DEFAULT, "glGetVertexAttribdvARB"));
+ SET_GetVertexAttribfvARB(disp, dlsym(RTLD_DEFAULT, "glGetVertexAttribfvARB"));
+ SET_GetVertexAttribivARB(disp, dlsym(RTLD_DEFAULT, "glGetVertexAttribivARB"));
+ SET_ProgramEnvParameter4dARB(disp, dlsym(RTLD_DEFAULT, "glProgramEnvParameter4dARB"));
+ SET_ProgramEnvParameter4dvARB(disp, dlsym(RTLD_DEFAULT, "glProgramEnvParameter4dvARB"));
+ SET_ProgramEnvParameter4fARB(disp, dlsym(RTLD_DEFAULT, "glProgramEnvParameter4fARB"));
+ SET_ProgramEnvParameter4fvARB(disp, dlsym(RTLD_DEFAULT, "glProgramEnvParameter4fvARB"));
+ SET_ProgramLocalParameter4dARB(disp, dlsym(RTLD_DEFAULT, "glProgramLocalParameter4dARB"));
+ SET_ProgramLocalParameter4dvARB(disp, dlsym(RTLD_DEFAULT, "glProgramLocalParameter4dvARB"));
+ SET_ProgramLocalParameter4fARB(disp, dlsym(RTLD_DEFAULT, "glProgramLocalParameter4fARB"));
+ SET_ProgramLocalParameter4fvARB(disp, dlsym(RTLD_DEFAULT, "glProgramLocalParameter4fvARB"));
+ SET_ProgramStringARB(disp, dlsym(RTLD_DEFAULT, "glProgramStringARB"));
+ SET_VertexAttrib1dARB(disp, dlsym(RTLD_DEFAULT, "glVertexAttrib1dARB"));
+ SET_VertexAttrib1dvARB(disp, dlsym(RTLD_DEFAULT, "glVertexAttrib1dvARB"));
+ SET_VertexAttrib1fARB(disp, dlsym(RTLD_DEFAULT, "glVertexAttrib1fARB"));
+ SET_VertexAttrib1fvARB(disp, dlsym(RTLD_DEFAULT, "glVertexAttrib1fvARB"));
+ SET_VertexAttrib1sARB(disp, dlsym(RTLD_DEFAULT, "glVertexAttrib1sARB"));
+ SET_VertexAttrib1svARB(disp, dlsym(RTLD_DEFAULT, "glVertexAttrib1svARB"));
+ SET_VertexAttrib2dARB(disp, dlsym(RTLD_DEFAULT, "glVertexAttrib2dARB"));
+ SET_VertexAttrib2dvARB(disp, dlsym(RTLD_DEFAULT, "glVertexAttrib2dvARB"));
+ SET_VertexAttrib2fARB(disp, dlsym(RTLD_DEFAULT, "glVertexAttrib2fARB"));
+ SET_VertexAttrib2fvARB(disp, dlsym(RTLD_DEFAULT, "glVertexAttrib2fvARB"));
+ SET_VertexAttrib2sARB(disp, dlsym(RTLD_DEFAULT, "glVertexAttrib2sARB"));
+ SET_VertexAttrib2svARB(disp, dlsym(RTLD_DEFAULT, "glVertexAttrib2svARB"));
+ SET_VertexAttrib3dARB(disp, dlsym(RTLD_DEFAULT, "glVertexAttrib3dARB"));
+ SET_VertexAttrib3dvARB(disp, dlsym(RTLD_DEFAULT, "glVertexAttrib3dvARB"));
+ SET_VertexAttrib3fARB(disp, dlsym(RTLD_DEFAULT, "glVertexAttrib3fARB"));
+ SET_VertexAttrib3fvARB(disp, dlsym(RTLD_DEFAULT, "glVertexAttrib3fvARB"));
+ SET_VertexAttrib3sARB(disp, dlsym(RTLD_DEFAULT, "glVertexAttrib3sARB"));
+ SET_VertexAttrib3svARB(disp, dlsym(RTLD_DEFAULT, "glVertexAttrib3svARB"));
+ SET_VertexAttrib4NbvARB(disp, dlsym(RTLD_DEFAULT, "glVertexAttrib4NbvARB"));
+ SET_VertexAttrib4NivARB(disp, dlsym(RTLD_DEFAULT, "glVertexAttrib4NivARB"));
+ SET_VertexAttrib4NsvARB(disp, dlsym(RTLD_DEFAULT, "glVertexAttrib4NsvARB"));
+ SET_VertexAttrib4NubARB(disp, dlsym(RTLD_DEFAULT, "glVertexAttrib4NubARB"));
+ SET_VertexAttrib4NubvARB(disp, dlsym(RTLD_DEFAULT, "glVertexAttrib4NubvARB"));
+ SET_VertexAttrib4NuivARB(disp, dlsym(RTLD_DEFAULT, "glVertexAttrib4NuivARB"));
+ SET_VertexAttrib4NusvARB(disp, dlsym(RTLD_DEFAULT, "glVertexAttrib4NusvARB"));
+ SET_VertexAttrib4bvARB(disp, dlsym(RTLD_DEFAULT, "glVertexAttrib4bvARB"));
+ SET_VertexAttrib4dARB(disp, dlsym(RTLD_DEFAULT, "glVertexAttrib4dARB"));
+ SET_VertexAttrib4dvARB(disp, dlsym(RTLD_DEFAULT, "glVertexAttrib4dvARB"));
+ SET_VertexAttrib4fARB(disp, dlsym(RTLD_DEFAULT, "glVertexAttrib4fARB"));
+ SET_VertexAttrib4fvARB(disp, dlsym(RTLD_DEFAULT, "glVertexAttrib4fvARB"));
+ SET_VertexAttrib4ivARB(disp, dlsym(RTLD_DEFAULT, "glVertexAttrib4ivARB"));
+ SET_VertexAttrib4sARB(disp, dlsym(RTLD_DEFAULT, "glVertexAttrib4sARB"));
+ SET_VertexAttrib4svARB(disp, dlsym(RTLD_DEFAULT, "glVertexAttrib4svARB"));
+ SET_VertexAttrib4ubvARB(disp, dlsym(RTLD_DEFAULT, "glVertexAttrib4ubvARB"));
+ SET_VertexAttrib4uivARB(disp, dlsym(RTLD_DEFAULT, "glVertexAttrib4uivARB"));
+ SET_VertexAttrib4usvARB(disp, dlsym(RTLD_DEFAULT, "glVertexAttrib4usvARB"));
+ SET_VertexAttribPointerARB(disp, dlsym(RTLD_DEFAULT, "glVertexAttribPointerARB"));
+
+ /* GL_ARB_vertex_shader */
+ SET_BindAttribLocationARB(disp, dlsym(RTLD_DEFAULT, "glBindAttribLocationARB"));
+ SET_GetActiveAttribARB(disp, dlsym(RTLD_DEFAULT, "glGetActiveAttribARB"));
+ SET_GetAttribLocationARB(disp, dlsym(RTLD_DEFAULT, "glGetAttribLocationARB"));
+
+ /* GL_ARB_window_pos */
+ SET_WindowPos2dMESA(disp, dlsym(RTLD_DEFAULT, "glWindowPos2dARB"));
+ SET_WindowPos2dvMESA(disp, dlsym(RTLD_DEFAULT, "glWindowPos2dvARB"));
+ SET_WindowPos2fMESA(disp, dlsym(RTLD_DEFAULT, "glWindowPos2fARB"));
+ SET_WindowPos2fvMESA(disp, dlsym(RTLD_DEFAULT, "glWindowPos2fvARB"));
+ SET_WindowPos2iMESA(disp, dlsym(RTLD_DEFAULT, "glWindowPos2iARB"));
+ SET_WindowPos2ivMESA(disp, dlsym(RTLD_DEFAULT, "glWindowPos2ivARB"));
+ SET_WindowPos2sMESA(disp, dlsym(RTLD_DEFAULT, "glWindowPos2sARB"));
+ SET_WindowPos2svMESA(disp, dlsym(RTLD_DEFAULT, "glWindowPos2svARB"));
+ SET_WindowPos3dMESA(disp, dlsym(RTLD_DEFAULT, "glWindowPos3dARB"));
+ SET_WindowPos3dvMESA(disp, dlsym(RTLD_DEFAULT, "glWindowPos3dvARB"));
+ SET_WindowPos3fMESA(disp, dlsym(RTLD_DEFAULT, "glWindowPos3fARB"));
+ SET_WindowPos3fvMESA(disp, dlsym(RTLD_DEFAULT, "glWindowPos3fvARB"));
+ SET_WindowPos3iMESA(disp, dlsym(RTLD_DEFAULT, "glWindowPos3iARB"));
+ SET_WindowPos3ivMESA(disp, dlsym(RTLD_DEFAULT, "glWindowPos3ivARB"));
+ SET_WindowPos3sMESA(disp, dlsym(RTLD_DEFAULT, "glWindowPos3sARB"));
+ SET_WindowPos3svMESA(disp, dlsym(RTLD_DEFAULT, "glWindowPos3svARB"));
+
+ /* GL_ATI_fragment_shader / GL_EXT_fragment_shader */
+ if(dlsym(RTLD_DEFAULT, "glAlphaFragmentOp1ATI")) {
+ /* GL_ATI_fragment_shader */
+ SET_AlphaFragmentOp1ATI(disp, dlsym(RTLD_DEFAULT, "glAlphaFragmentOp1ATI"));
+ SET_AlphaFragmentOp2ATI(disp, dlsym(RTLD_DEFAULT, "glAlphaFragmentOp2ATI"));
+ SET_AlphaFragmentOp3ATI(disp, dlsym(RTLD_DEFAULT, "glAlphaFragmentOp3ATI"));
+ SET_BeginFragmentShaderATI(disp, dlsym(RTLD_DEFAULT, "glBeginFragmentShaderATI"));
+ SET_BindFragmentShaderATI(disp, dlsym(RTLD_DEFAULT, "glBindFragmentShaderATI"));
+ SET_ColorFragmentOp1ATI(disp, dlsym(RTLD_DEFAULT, "glColorFragmentOp1ATI"));
+ SET_ColorFragmentOp2ATI(disp, dlsym(RTLD_DEFAULT, "glColorFragmentOp2ATI"));
+ SET_ColorFragmentOp3ATI(disp, dlsym(RTLD_DEFAULT, "glColorFragmentOp3ATI"));
+ SET_DeleteFragmentShaderATI(disp, dlsym(RTLD_DEFAULT, "glDeleteFragmentShaderATI"));
+ SET_EndFragmentShaderATI(disp, dlsym(RTLD_DEFAULT, "glEndFragmentShaderATI"));
+ SET_GenFragmentShadersATI(disp, dlsym(RTLD_DEFAULT, "glGenFragmentShadersATI"));
+ SET_PassTexCoordATI(disp, dlsym(RTLD_DEFAULT, "glPassTexCoordATI"));
+ SET_SampleMapATI(disp, dlsym(RTLD_DEFAULT, "glSampleMapATI"));
+ SET_SetFragmentShaderConstantATI(disp, dlsym(RTLD_DEFAULT, "glSetFragmentShaderConstantATI"));
+ } else {
+ /* GL_EXT_fragment_shader */
+ SET_AlphaFragmentOp1ATI(disp, dlsym(RTLD_DEFAULT, "glAlphaFragmentOp1EXT"));
+ SET_AlphaFragmentOp2ATI(disp, dlsym(RTLD_DEFAULT, "glAlphaFragmentOp2EXT"));
+ SET_AlphaFragmentOp3ATI(disp, dlsym(RTLD_DEFAULT, "glAlphaFragmentOp3EXT"));
+ SET_BeginFragmentShaderATI(disp, dlsym(RTLD_DEFAULT, "glBeginFragmentShaderEXT"));
+ SET_BindFragmentShaderATI(disp, dlsym(RTLD_DEFAULT, "glBindFragmentShaderEXT"));
+ SET_ColorFragmentOp1ATI(disp, dlsym(RTLD_DEFAULT, "glColorFragmentOp1EXT"));
+ SET_ColorFragmentOp2ATI(disp, dlsym(RTLD_DEFAULT, "glColorFragmentOp2EXT"));
+ SET_ColorFragmentOp3ATI(disp, dlsym(RTLD_DEFAULT, "glColorFragmentOp3EXT"));
+ SET_DeleteFragmentShaderATI(disp, dlsym(RTLD_DEFAULT, "glDeleteFragmentShaderEXT"));
+ SET_EndFragmentShaderATI(disp, dlsym(RTLD_DEFAULT, "glEndFragmentShaderEXT"));
+ SET_GenFragmentShadersATI(disp, dlsym(RTLD_DEFAULT, "glGenFragmentShadersEXT"));
+ SET_PassTexCoordATI(disp, dlsym(RTLD_DEFAULT, "glPassTexCoordEXT"));
+ SET_SampleMapATI(disp, dlsym(RTLD_DEFAULT, "glSampleMapEXT"));
+ SET_SetFragmentShaderConstantATI(disp, dlsym(RTLD_DEFAULT, "glSetFragmentShaderConstantEXT"));
+ }
-#if GL_EXT_gpu_program_parameters
- SET_ProgramEnvParameters4fvEXT(disp, glProgramEnvParameters4fvEXT);
- SET_ProgramLocalParameters4fvEXT(disp, glProgramLocalParameters4fvEXT);
-#endif
+ /* GL_ATI_separate_stencil */
+ SET_StencilFuncSeparateATI(disp, dlsym(RTLD_DEFAULT, "glStencilFuncSeparateATI"));
+
+ /* GL_EXT_blend_equation_separate */
+ SET_BlendEquationSeparateEXT(disp, dlsym(RTLD_DEFAULT, "glBlendEquationSeparateEXT"));
+
+ /* GL_EXT_blend_func_separate */
+ SET_BlendFuncSeparateEXT(disp, dlsym(RTLD_DEFAULT, "glBlendFuncSeparateEXT"));
+
+ /* GL_EXT_depth_bounds_test */
+ SET_DepthBoundsEXT(disp, dlsym(RTLD_DEFAULT, "glDepthBoundsEXT"));
+
+ /* GL_EXT_compiled_vertex_array */
+ SET_LockArraysEXT(disp, dlsym(RTLD_DEFAULT, "glLockArraysEXT"));
+ SET_UnlockArraysEXT(disp, dlsym(RTLD_DEFAULT, "glUnlockArraysEXT"));
+
+ /* GL_EXT_cull_vertex */
+ SET_CullParameterdvEXT(disp, dlsym(RTLD_DEFAULT, "glCullParameterdvEXT"));
+ SET_CullParameterfvEXT(disp, dlsym(RTLD_DEFAULT, "glCullParameterfvEXT"));
+
+ /* GL_EXT_fog_coord */
+ SET_FogCoordPointerEXT(disp, dlsym(RTLD_DEFAULT, "glFogCoordPointerEXT"));
+ SET_FogCoorddEXT(disp, dlsym(RTLD_DEFAULT, "glFogCoorddEXT"));
+ SET_FogCoorddvEXT(disp, dlsym(RTLD_DEFAULT, "glFogCoorddvEXT"));
+ SET_FogCoordfEXT(disp, dlsym(RTLD_DEFAULT, "glFogCoordfEXT"));
+ SET_FogCoordfvEXT(disp, dlsym(RTLD_DEFAULT, "glFogCoordfvEXT"));
+
+ /* GL_EXT_framebuffer_blit */
+ SET_BlitFramebufferEXT(disp, dlsym(RTLD_DEFAULT, "glBlitFramebufferEXT"));
+
+ /* GL_EXT_framebuffer_object */
+ SET_BindFramebufferEXT(disp, dlsym(RTLD_DEFAULT, "glBindFramebufferEXT"));
+ SET_BindRenderbufferEXT(disp, dlsym(RTLD_DEFAULT, "glBindRenderbufferEXT"));
+ SET_CheckFramebufferStatusEXT(disp, dlsym(RTLD_DEFAULT, "glCheckFramebufferStatusEXT"));
+ SET_DeleteFramebuffersEXT(disp, dlsym(RTLD_DEFAULT, "glDeleteFramebuffersEXT"));
+ SET_DeleteRenderbuffersEXT(disp, dlsym(RTLD_DEFAULT, "glDeleteRenderbuffersEXT"));
+ SET_FramebufferRenderbufferEXT(disp, dlsym(RTLD_DEFAULT, "glFramebufferRenderbufferEXT"));
+ SET_FramebufferTexture1DEXT(disp, dlsym(RTLD_DEFAULT, "glFramebufferTexture1DEXT"));
+ SET_FramebufferTexture2DEXT(disp, dlsym(RTLD_DEFAULT, "glFramebufferTexture2DEXT"));
+ SET_FramebufferTexture3DEXT(disp, dlsym(RTLD_DEFAULT, "glFramebufferTexture3DEXT"));
+ SET_GenerateMipmapEXT(disp, dlsym(RTLD_DEFAULT, "glGenerateMipmapEXT"));
+ SET_GenFramebuffersEXT(disp, dlsym(RTLD_DEFAULT, "glGenFramebuffersEXT"));
+ SET_GenRenderbuffersEXT(disp, dlsym(RTLD_DEFAULT, "glGenRenderbuffersEXT"));
+ SET_GetFramebufferAttachmentParameterivEXT(disp, dlsym(RTLD_DEFAULT, "glGetFramebufferAttachmentParameterivEXT"));
+ SET_GetRenderbufferParameterivEXT(disp, dlsym(RTLD_DEFAULT, "glGetRenderbufferParameterivEXT"));
+ SET_IsFramebufferEXT(disp, dlsym(RTLD_DEFAULT, "glIsFramebufferEXT"));
+ SET_IsRenderbufferEXT(disp, dlsym(RTLD_DEFAULT, "glIsRenderbufferEXT"));
+ SET_RenderbufferStorageEXT(disp, dlsym(RTLD_DEFAULT, "glRenderbufferStorageEXT"));
+
+ /* GL_EXT_gpu_program_parameters */
+ SET_ProgramEnvParameters4fvEXT(disp, dlsym(RTLD_DEFAULT, "glProgramEnvParameters4fvEXT"));
+ SET_ProgramLocalParameters4fvEXT(disp, dlsym(RTLD_DEFAULT, "glProgramLocalParameters4fvEXT"));
-#if GL_EXT_multi_draw_arrays
/* Pointer Incompatability:
* This warning can be safely ignored. OpenGL.framework adds const to the
* two pointers.
@@ -1414,206 +1297,193 @@ static void setup_dispatch_table(void) { *
* void ( * MultiDrawArraysEXT)(GLenum mode, GLint * first, GLsizei * count, GLsizei primcount);
*/
- SET_MultiDrawArraysEXT(disp, (void *)glMultiDrawArraysEXT);
- SET_MultiDrawElementsEXT(disp, glMultiDrawElementsEXT);
-#endif
-
-#if GL_EXT_point_parameters
- SET_PointParameterfEXT(disp, glPointParameterfEXT);
- SET_PointParameterfvEXT(disp, glPointParameterfvEXT);
-#elif GL_ARB_point_parameters
- SET_PointParameterfEXT(disp, glPointParameterfARB);
- SET_PointParameterfvEXT(disp, glPointParameterfvARB);
-#endif
-
-#if GL_EXT_polygon_offset
- SET_PolygonOffsetEXT(disp, glPolygonOffsetEXT);
-#endif
-
-#if GL_EXT_secondary_color
- SET_SecondaryColor3bEXT(disp, glSecondaryColor3bEXT);
- SET_SecondaryColor3bvEXT(disp, glSecondaryColor3bvEXT);
- SET_SecondaryColor3dEXT(disp, glSecondaryColor3dEXT);
- SET_SecondaryColor3dvEXT(disp, glSecondaryColor3dvEXT);
- SET_SecondaryColor3fEXT(disp, glSecondaryColor3fEXT);
- SET_SecondaryColor3fvEXT(disp, glSecondaryColor3fvEXT);
- SET_SecondaryColor3iEXT(disp, glSecondaryColor3iEXT);
- SET_SecondaryColor3ivEXT(disp, glSecondaryColor3ivEXT);
- SET_SecondaryColor3sEXT(disp, glSecondaryColor3sEXT);
- SET_SecondaryColor3svEXT(disp, glSecondaryColor3svEXT);
- SET_SecondaryColor3ubEXT(disp, glSecondaryColor3ubEXT);
- SET_SecondaryColor3ubvEXT(disp, glSecondaryColor3ubvEXT);
- SET_SecondaryColor3uiEXT(disp, glSecondaryColor3uiEXT);
- SET_SecondaryColor3uivEXT(disp, glSecondaryColor3uivEXT);
- SET_SecondaryColor3usEXT(disp, glSecondaryColor3usEXT);
- SET_SecondaryColor3usvEXT(disp, glSecondaryColor3usvEXT);
- SET_SecondaryColorPointerEXT(disp, glSecondaryColorPointerEXT);
-#endif
-
-#if GL_EXT_stencil_two_side
- SET_ActiveStencilFaceEXT(disp, glActiveStencilFaceEXT);
-#endif
-
-#if GL_EXT_timer_query
- SET_GetQueryObjecti64vEXT(disp, glGetQueryObjecti64vEXT);
- SET_GetQueryObjectui64vEXT(disp, glGetQueryObjectui64vEXT);
-#endif
-
-#if GL_EXT_vertex_array
- SET_ColorPointerEXT(disp, glColorPointerEXT);
- SET_EdgeFlagPointerEXT(disp, glEdgeFlagPointerEXT);
- SET_IndexPointerEXT(disp, glIndexPointerEXT);
- SET_NormalPointerEXT(disp, glNormalPointerEXT);
- SET_TexCoordPointerEXT(disp, glTexCoordPointerEXT);
- SET_VertexPointerEXT(disp, glVertexPointerEXT);
-#endif
-
-#if GL_IBM_multimode_draw_arrays
- SET_MultiModeDrawArraysIBM(disp, glMultiModeDrawArraysIBM);
- SET_MultiModeDrawElementsIBM(disp, glMultiModeDrawElementsIBM);
-#endif
-
-#if GL_MESA_resize_buffers
- SET_ResizeBuffersMESA(disp, glResizeBuffersMESA);
-#endif
-
-#if GL_MESA_window_pos
- SET_WindowPos4dMESA(disp, glWindowPos4dMESA);
- SET_WindowPos4dvMESA(disp, glWindowPos4dvMESA);
- SET_WindowPos4fMESA(disp, glWindowPos4fMESA);
- SET_WindowPos4fvMESA(disp, glWindowPos4fvMESA);
- SET_WindowPos4iMESA(disp, glWindowPos4iMESA);
- SET_WindowPos4ivMESA(disp, glWindowPos4ivMESA);
- SET_WindowPos4sMESA(disp, glWindowPos4sMESA);
- SET_WindowPos4svMESA(disp, glWindowPos4svMESA);
-#endif
-#if GL_NV_fence
- SET_DeleteFencesNV(disp, glDeleteFencesNV);
- SET_FinishFenceNV(disp, glFinishFenceNV);
- SET_GenFencesNV(disp, glGenFencesNV);
- SET_GetFenceivNV(disp, glGetFenceivNV);
- SET_IsFenceNV(disp, glIsFenceNV);
- SET_SetFenceNV(disp, glSetFenceNV);
- SET_TestFenceNV(disp, glTestFenceNV);
-#endif
-
-#if GL_NV_fragment_program
- SET_GetProgramNamedParameterdvNV(disp, glGetProgramNamedParameterdvNV);
- SET_GetProgramNamedParameterfvNV(disp, glGetProgramNamedParameterfvNV);
- SET_ProgramNamedParameter4dNV(disp, glProgramNamedParameter4dNV);
- SET_ProgramNamedParameter4dvNV(disp, glProgramNamedParameter4dvNV);
- SET_ProgramNamedParameter4fNV(disp, glProgramNamedParameter4fNV);
- SET_ProgramNamedParameter4fvNV(disp, glProgramNamedParameter4fvNV);
-#endif
-
-#if GL_NV_geometry_program4
- SET_FramebufferTextureLayerEXT(disp, glFramebufferTextureLayerEXT);
-#endif
-
-#if GL_NV_point_sprite
- SET_PointParameteriNV(disp, glPointParameteriNV);
- SET_PointParameterivNV(disp, glPointParameterivNV);
-#endif
-
-#if GL_NV_register_combiners
- SET_CombinerInputNV(disp, glCombinerInputNV);
- SET_CombinerOutputNV(disp, glCombinerOutputNV);
- SET_CombinerParameterfNV(disp, glCombinerParameterfNV);
- SET_CombinerParameterfvNV(disp, glCombinerParameterfvNV);
- SET_CombinerParameteriNV(disp, glCombinerParameteriNV);
- SET_CombinerParameterivNV(disp, glCombinerParameterivNV);
- SET_FinalCombinerInputNV(disp, glFinalCombinerInputNV);
- SET_GetCombinerInputParameterfvNV(disp, glGetCombinerInputParameterfvNV);
- SET_GetCombinerInputParameterivNV(disp, glGetCombinerInputParameterivNV);
- SET_GetCombinerOutputParameterfvNV(disp, glGetCombinerOutputParameterfvNV);
- SET_GetCombinerOutputParameterivNV(disp, glGetCombinerOutputParameterivNV);
- SET_GetFinalCombinerInputParameterfvNV(disp, glGetFinalCombinerInputParameterfvNV);
- SET_GetFinalCombinerInputParameterivNV(disp, glGetFinalCombinerInputParameterivNV);
-#endif
-
-#if GL_NV_vertex_array_range
- SET_FlushVertexArrayRangeNV(disp, glFlushVertexArrayRangeNV);
- SET_VertexArrayRangeNV(disp, glVertexArrayRangeNV);
-#endif
-
-#if GL_NV_vertex_program
- SET_AreProgramsResidentNV(disp, glAreProgramsResidentNV);
- SET_BindProgramNV(disp, glBindProgramNV);
- SET_DeleteProgramsNV(disp, glDeleteProgramsNV);
- SET_ExecuteProgramNV(disp, glExecuteProgramNV);
- SET_GenProgramsNV(disp, glGenProgramsNV);
- SET_GetProgramParameterdvNV(disp, glGetProgramParameterdvNV);
- SET_GetProgramParameterfvNV(disp, glGetProgramParameterfvNV);
- SET_GetProgramStringNV(disp, glGetProgramStringNV);
- SET_GetProgramivNV(disp, glGetProgramivNV);
- SET_GetTrackMatrixivNV(disp, glGetTrackMatrixivNV);
- SET_GetVertexAttribPointervNV(disp, glGetVertexAttribPointervNV);
- SET_GetVertexAttribdvNV(disp, glGetVertexAttribdvNV);
- SET_GetVertexAttribfvNV(disp, glGetVertexAttribfvNV);
- SET_GetVertexAttribivNV(disp, glGetVertexAttribivNV);
- SET_IsProgramNV(disp, glIsProgramNV);
- SET_LoadProgramNV(disp, glLoadProgramNV);
- SET_ProgramParameters4dvNV(disp, glProgramParameters4dvNV);
- SET_ProgramParameters4fvNV(disp, glProgramParameters4fvNV);
- SET_RequestResidentProgramsNV(disp, glRequestResidentProgramsNV);
- SET_TrackMatrixNV(disp, glTrackMatrixNV);
- SET_VertexAttrib1dNV(disp, glVertexAttrib1dNV)
- SET_VertexAttrib1dvNV(disp, glVertexAttrib1dvNV)
- SET_VertexAttrib1fNV(disp, glVertexAttrib1fNV)
- SET_VertexAttrib1fvNV(disp, glVertexAttrib1fvNV)
- SET_VertexAttrib1sNV(disp, glVertexAttrib1sNV)
- SET_VertexAttrib1svNV(disp, glVertexAttrib1svNV)
- SET_VertexAttrib2dNV(disp, glVertexAttrib2dNV)
- SET_VertexAttrib2dvNV(disp, glVertexAttrib2dvNV)
- SET_VertexAttrib2fNV(disp, glVertexAttrib2fNV)
- SET_VertexAttrib2fvNV(disp, glVertexAttrib2fvNV)
- SET_VertexAttrib2sNV(disp, glVertexAttrib2sNV)
- SET_VertexAttrib2svNV(disp, glVertexAttrib2svNV)
- SET_VertexAttrib3dNV(disp, glVertexAttrib3dNV)
- SET_VertexAttrib3dvNV(disp, glVertexAttrib3dvNV)
- SET_VertexAttrib3fNV(disp, glVertexAttrib3fNV)
- SET_VertexAttrib3fvNV(disp, glVertexAttrib3fvNV)
- SET_VertexAttrib3sNV(disp, glVertexAttrib3sNV)
- SET_VertexAttrib3svNV(disp, glVertexAttrib3svNV)
- SET_VertexAttrib4dNV(disp, glVertexAttrib4dNV)
- SET_VertexAttrib4dvNV(disp, glVertexAttrib4dvNV)
- SET_VertexAttrib4fNV(disp, glVertexAttrib4fNV)
- SET_VertexAttrib4fvNV(disp, glVertexAttrib4fvNV)
- SET_VertexAttrib4sNV(disp, glVertexAttrib4sNV)
- SET_VertexAttrib4svNV(disp, glVertexAttrib4svNV)
- SET_VertexAttrib4ubNV(disp, glVertexAttrib4ubNV)
- SET_VertexAttrib4ubvNV(disp, glVertexAttrib4ubvNV)
- SET_VertexAttribPointerNV(disp, glVertexAttribPointerNV)
- SET_VertexAttribs1dvNV(disp, glVertexAttribs1dvNV)
- SET_VertexAttribs1fvNV(disp, glVertexAttribs1fvNV)
- SET_VertexAttribs1svNV(disp, glVertexAttribs1svNV)
- SET_VertexAttribs2dvNV(disp, glVertexAttribs2dvNV)
- SET_VertexAttribs2fvNV(disp, glVertexAttribs2fvNV)
- SET_VertexAttribs2svNV(disp, glVertexAttribs2svNV)
- SET_VertexAttribs3dvNV(disp, glVertexAttribs3dvNV)
- SET_VertexAttribs3fvNV(disp, glVertexAttribs3fvNV)
- SET_VertexAttribs3svNV(disp, glVertexAttribs3svNV)
- SET_VertexAttribs4dvNV(disp, glVertexAttribs4dvNV)
- SET_VertexAttribs4fvNV(disp, glVertexAttribs4fvNV)
- SET_VertexAttribs4svNV(disp, glVertexAttribs4svNV)
- SET_VertexAttribs4ubvNV(disp, glVertexAttribs4ubvNV)
-#endif
-
-#if GL_SGIS_multisample
- SET_SampleMaskSGIS(disp, glSampleMaskSGIS);
- SET_SamplePatternSGIS(disp, glSamplePatternSGIS);
-#endif
+ /* GL_EXT_multi_draw_arrays */
+ SET_MultiDrawArraysEXT(disp, (void *)dlsym(RTLD_DEFAULT, "glMultiDrawArraysEXT"));
+ SET_MultiDrawElementsEXT(disp, dlsym(RTLD_DEFAULT, "glMultiDrawElementsEXT"));
+
+ /* GL_EXT_point_parameters / GL_ARB_point_parameters */
+ if(dlsym(RTLD_DEFAULT, "glPointParameterfEXT")) {
+ /* GL_EXT_point_parameters */
+ SET_PointParameterfEXT(disp, dlsym(RTLD_DEFAULT, "glPointParameterfEXT"));
+ SET_PointParameterfvEXT(disp, dlsym(RTLD_DEFAULT, "glPointParameterfvEXT"));
+ } else {
+ /* GL_ARB_point_parameters */
+ SET_PointParameterfEXT(disp, dlsym(RTLD_DEFAULT, "glPointParameterfARB"));
+ SET_PointParameterfvEXT(disp, dlsym(RTLD_DEFAULT, "glPointParameterfvARB"));
+ }
-#if GL_SGIS_pixel_texture
- SET_GetPixelTexGenParameterfvSGIS(disp, glGetPixelTexGenParameterfvSGIS);
- SET_GetPixelTexGenParameterivSGIS(disp, glGetPixelTexGenParameterivSGIS);
- SET_PixelTexGenParameterfSGIS(disp, glPixelTexGenParameterfSGIS);
- SET_PixelTexGenParameterfvSGIS(disp, glPixelTexGenParameterfvSGIS);
- SET_PixelTexGenParameteriSGIS(disp, glPixelTexGenParameteriSGIS);
- SET_PixelTexGenParameterivSGIS(disp, glPixelTexGenParameterivSGIS);
- SET_PixelTexGenSGIX(disp, glPixelTexGenSGIX);
-#endif
+ /* GL_EXT_polygon_offset */
+ SET_PolygonOffsetEXT(disp, dlsym(RTLD_DEFAULT, "glPolygonOffsetEXT"));
+
+ /* GL_EXT_secondary_color */
+ SET_SecondaryColor3bEXT(disp, dlsym(RTLD_DEFAULT, "glSecondaryColor3bEXT"));
+ SET_SecondaryColor3bvEXT(disp, dlsym(RTLD_DEFAULT, "glSecondaryColor3bvEXT"));
+ SET_SecondaryColor3dEXT(disp, dlsym(RTLD_DEFAULT, "glSecondaryColor3dEXT"));
+ SET_SecondaryColor3dvEXT(disp, dlsym(RTLD_DEFAULT, "glSecondaryColor3dvEXT"));
+ SET_SecondaryColor3fEXT(disp, dlsym(RTLD_DEFAULT, "glSecondaryColor3fEXT"));
+ SET_SecondaryColor3fvEXT(disp, dlsym(RTLD_DEFAULT, "glSecondaryColor3fvEXT"));
+ SET_SecondaryColor3iEXT(disp, dlsym(RTLD_DEFAULT, "glSecondaryColor3iEXT"));
+ SET_SecondaryColor3ivEXT(disp, dlsym(RTLD_DEFAULT, "glSecondaryColor3ivEXT"));
+ SET_SecondaryColor3sEXT(disp, dlsym(RTLD_DEFAULT, "glSecondaryColor3sEXT"));
+ SET_SecondaryColor3svEXT(disp, dlsym(RTLD_DEFAULT, "glSecondaryColor3svEXT"));
+ SET_SecondaryColor3ubEXT(disp, dlsym(RTLD_DEFAULT, "glSecondaryColor3ubEXT"));
+ SET_SecondaryColor3ubvEXT(disp, dlsym(RTLD_DEFAULT, "glSecondaryColor3ubvEXT"));
+ SET_SecondaryColor3uiEXT(disp, dlsym(RTLD_DEFAULT, "glSecondaryColor3uiEXT"));
+ SET_SecondaryColor3uivEXT(disp, dlsym(RTLD_DEFAULT, "glSecondaryColor3uivEXT"));
+ SET_SecondaryColor3usEXT(disp, dlsym(RTLD_DEFAULT, "glSecondaryColor3usEXT"));
+ SET_SecondaryColor3usvEXT(disp, dlsym(RTLD_DEFAULT, "glSecondaryColor3usvEXT"));
+ SET_SecondaryColorPointerEXT(disp, dlsym(RTLD_DEFAULT, "glSecondaryColorPointerEXT"));
+
+ /* GL_EXT_stencil_two_side */
+ SET_ActiveStencilFaceEXT(disp, dlsym(RTLD_DEFAULT, "glActiveStencilFaceEXT"));
+
+ /* GL_EXT_timer_query */
+ SET_GetQueryObjecti64vEXT(disp, dlsym(RTLD_DEFAULT, "glGetQueryObjecti64vEXT"));
+ SET_GetQueryObjectui64vEXT(disp, dlsym(RTLD_DEFAULT, "glGetQueryObjectui64vEXT"));
+
+ /* GL_EXT_vertex_array */
+ SET_ColorPointerEXT(disp, dlsym(RTLD_DEFAULT, "glColorPointerEXT"));
+ SET_EdgeFlagPointerEXT(disp, dlsym(RTLD_DEFAULT, "glEdgeFlagPointerEXT"));
+ SET_IndexPointerEXT(disp, dlsym(RTLD_DEFAULT, "glIndexPointerEXT"));
+ SET_NormalPointerEXT(disp, dlsym(RTLD_DEFAULT, "glNormalPointerEXT"));
+ SET_TexCoordPointerEXT(disp, dlsym(RTLD_DEFAULT, "glTexCoordPointerEXT"));
+ SET_VertexPointerEXT(disp, dlsym(RTLD_DEFAULT, "glVertexPointerEXT"));
+
+ /* GL_IBM_multimode_draw_arrays */
+ SET_MultiModeDrawArraysIBM(disp, dlsym(RTLD_DEFAULT, "glMultiModeDrawArraysIBM"));
+ SET_MultiModeDrawElementsIBM(disp, dlsym(RTLD_DEFAULT, "glMultiModeDrawElementsIBM"));
+
+ /* GL_MESA_resize_buffers */
+ SET_ResizeBuffersMESA(disp, dlsym(RTLD_DEFAULT, "glResizeBuffersMESA"));
+
+ /* GL_MESA_window_pos */
+ SET_WindowPos4dMESA(disp, dlsym(RTLD_DEFAULT, "glWindowPos4dMESA"));
+ SET_WindowPos4dvMESA(disp, dlsym(RTLD_DEFAULT, "glWindowPos4dvMESA"));
+ SET_WindowPos4fMESA(disp, dlsym(RTLD_DEFAULT, "glWindowPos4fMESA"));
+ SET_WindowPos4fvMESA(disp, dlsym(RTLD_DEFAULT, "glWindowPos4fvMESA"));
+ SET_WindowPos4iMESA(disp, dlsym(RTLD_DEFAULT, "glWindowPos4iMESA"));
+ SET_WindowPos4ivMESA(disp, dlsym(RTLD_DEFAULT, "glWindowPos4ivMESA"));
+ SET_WindowPos4sMESA(disp, dlsym(RTLD_DEFAULT, "glWindowPos4sMESA"));
+ SET_WindowPos4svMESA(disp, dlsym(RTLD_DEFAULT, "glWindowPos4svMESA"));
+
+ /* GL_NV_fence */
+ SET_DeleteFencesNV(disp, dlsym(RTLD_DEFAULT, "glDeleteFencesNV"));
+ SET_FinishFenceNV(disp, dlsym(RTLD_DEFAULT, "glFinishFenceNV"));
+ SET_GenFencesNV(disp, dlsym(RTLD_DEFAULT, "glGenFencesNV"));
+ SET_GetFenceivNV(disp, dlsym(RTLD_DEFAULT, "glGetFenceivNV"));
+ SET_IsFenceNV(disp, dlsym(RTLD_DEFAULT, "glIsFenceNV"));
+ SET_SetFenceNV(disp, dlsym(RTLD_DEFAULT, "glSetFenceNV"));
+ SET_TestFenceNV(disp, dlsym(RTLD_DEFAULT, "glTestFenceNV"));
+
+ /* GL_NV_fragment_program */
+ SET_GetProgramNamedParameterdvNV(disp, dlsym(RTLD_DEFAULT, "glGetProgramNamedParameterdvNV"));
+ SET_GetProgramNamedParameterfvNV(disp, dlsym(RTLD_DEFAULT, "glGetProgramNamedParameterfvNV"));
+ SET_ProgramNamedParameter4dNV(disp, dlsym(RTLD_DEFAULT, "glProgramNamedParameter4dNV"));
+ SET_ProgramNamedParameter4dvNV(disp, dlsym(RTLD_DEFAULT, "glProgramNamedParameter4dvNV"));
+ SET_ProgramNamedParameter4fNV(disp, dlsym(RTLD_DEFAULT, "glProgramNamedParameter4fNV"));
+ SET_ProgramNamedParameter4fvNV(disp, dlsym(RTLD_DEFAULT, "glProgramNamedParameter4fvNV"));
+
+ /* GL_NV_geometry_program4 */
+ SET_FramebufferTextureLayerEXT(disp, dlsym(RTLD_DEFAULT, "glFramebufferTextureLayerEXT"));
+
+ /* GL_NV_point_sprite */
+ SET_PointParameteriNV(disp, dlsym(RTLD_DEFAULT, "glPointParameteriNV"));
+ SET_PointParameterivNV(disp, dlsym(RTLD_DEFAULT, "glPointParameterivNV"));
+
+ /* GL_NV_register_combiners */
+ SET_CombinerInputNV(disp, dlsym(RTLD_DEFAULT, "glCombinerInputNV"));
+ SET_CombinerOutputNV(disp, dlsym(RTLD_DEFAULT, "glCombinerOutputNV"));
+ SET_CombinerParameterfNV(disp, dlsym(RTLD_DEFAULT, "glCombinerParameterfNV"));
+ SET_CombinerParameterfvNV(disp, dlsym(RTLD_DEFAULT, "glCombinerParameterfvNV"));
+ SET_CombinerParameteriNV(disp, dlsym(RTLD_DEFAULT, "glCombinerParameteriNV"));
+ SET_CombinerParameterivNV(disp, dlsym(RTLD_DEFAULT, "glCombinerParameterivNV"));
+ SET_FinalCombinerInputNV(disp, dlsym(RTLD_DEFAULT, "glFinalCombinerInputNV"));
+ SET_GetCombinerInputParameterfvNV(disp, dlsym(RTLD_DEFAULT, "glGetCombinerInputParameterfvNV"));
+ SET_GetCombinerInputParameterivNV(disp, dlsym(RTLD_DEFAULT, "glGetCombinerInputParameterivNV"));
+ SET_GetCombinerOutputParameterfvNV(disp, dlsym(RTLD_DEFAULT, "glGetCombinerOutputParameterfvNV"));
+ SET_GetCombinerOutputParameterivNV(disp, dlsym(RTLD_DEFAULT, "glGetCombinerOutputParameterivNV"));
+ SET_GetFinalCombinerInputParameterfvNV(disp, dlsym(RTLD_DEFAULT, "glGetFinalCombinerInputParameterfvNV"));
+ SET_GetFinalCombinerInputParameterivNV(disp, dlsym(RTLD_DEFAULT, "glGetFinalCombinerInputParameterivNV"));
+
+ /* GL_NV_vertex_array_range */
+ SET_FlushVertexArrayRangeNV(disp, dlsym(RTLD_DEFAULT, "glFlushVertexArrayRangeNV"));
+ SET_VertexArrayRangeNV(disp, dlsym(RTLD_DEFAULT, "glVertexArrayRangeNV"));
+
+ /* GL_NV_vertex_program */
+ SET_AreProgramsResidentNV(disp, dlsym(RTLD_DEFAULT, "glAreProgramsResidentNV"));
+ SET_BindProgramNV(disp, dlsym(RTLD_DEFAULT, "glBindProgramNV"));
+ SET_DeleteProgramsNV(disp, dlsym(RTLD_DEFAULT, "glDeleteProgramsNV"));
+ SET_ExecuteProgramNV(disp, dlsym(RTLD_DEFAULT, "glExecuteProgramNV"));
+ SET_GenProgramsNV(disp, dlsym(RTLD_DEFAULT, "glGenProgramsNV"));
+ SET_GetProgramParameterdvNV(disp, dlsym(RTLD_DEFAULT, "glGetProgramParameterdvNV"));
+ SET_GetProgramParameterfvNV(disp, dlsym(RTLD_DEFAULT, "glGetProgramParameterfvNV"));
+ SET_GetProgramStringNV(disp, dlsym(RTLD_DEFAULT, "glGetProgramStringNV"));
+ SET_GetProgramivNV(disp, dlsym(RTLD_DEFAULT, "glGetProgramivNV"));
+ SET_GetTrackMatrixivNV(disp, dlsym(RTLD_DEFAULT, "glGetTrackMatrixivNV"));
+ SET_GetVertexAttribPointervNV(disp, dlsym(RTLD_DEFAULT, "glGetVertexAttribPointervNV"));
+ SET_GetVertexAttribdvNV(disp, dlsym(RTLD_DEFAULT, "glGetVertexAttribdvNV"));
+ SET_GetVertexAttribfvNV(disp, dlsym(RTLD_DEFAULT, "glGetVertexAttribfvNV"));
+ SET_GetVertexAttribivNV(disp, dlsym(RTLD_DEFAULT, "glGetVertexAttribivNV"));
+ SET_IsProgramNV(disp, dlsym(RTLD_DEFAULT, "glIsProgramNV"));
+ SET_LoadProgramNV(disp, dlsym(RTLD_DEFAULT, "glLoadProgramNV"));
+ SET_ProgramParameters4dvNV(disp, dlsym(RTLD_DEFAULT, "glProgramParameters4dvNV"));
+ SET_ProgramParameters4fvNV(disp, dlsym(RTLD_DEFAULT, "glProgramParameters4fvNV"));
+ SET_RequestResidentProgramsNV(disp, dlsym(RTLD_DEFAULT, "glRequestResidentProgramsNV"));
+ SET_TrackMatrixNV(disp, dlsym(RTLD_DEFAULT, "glTrackMatrixNV"));
+ SET_VertexAttrib1dNV(disp, dlsym(RTLD_DEFAULT, "glVertexAttrib1dNV"));
+ SET_VertexAttrib1dvNV(disp, dlsym(RTLD_DEFAULT, "glVertexAttrib1dvNV"));
+ SET_VertexAttrib1fNV(disp, dlsym(RTLD_DEFAULT, "glVertexAttrib1fNV"));
+ SET_VertexAttrib1fvNV(disp, dlsym(RTLD_DEFAULT, "glVertexAttrib1fvNV"));
+ SET_VertexAttrib1sNV(disp, dlsym(RTLD_DEFAULT, "glVertexAttrib1sNV"));
+ SET_VertexAttrib1svNV(disp, dlsym(RTLD_DEFAULT, "glVertexAttrib1svNV"));
+ SET_VertexAttrib2dNV(disp, dlsym(RTLD_DEFAULT, "glVertexAttrib2dNV"));
+ SET_VertexAttrib2dvNV(disp, dlsym(RTLD_DEFAULT, "glVertexAttrib2dvNV"));
+ SET_VertexAttrib2fNV(disp, dlsym(RTLD_DEFAULT, "glVertexAttrib2fNV"));
+ SET_VertexAttrib2fvNV(disp, dlsym(RTLD_DEFAULT, "glVertexAttrib2fvNV"));
+ SET_VertexAttrib2sNV(disp, dlsym(RTLD_DEFAULT, "glVertexAttrib2sNV"));
+ SET_VertexAttrib2svNV(disp, dlsym(RTLD_DEFAULT, "glVertexAttrib2svNV"));
+ SET_VertexAttrib3dNV(disp, dlsym(RTLD_DEFAULT, "glVertexAttrib3dNV"));
+ SET_VertexAttrib3dvNV(disp, dlsym(RTLD_DEFAULT, "glVertexAttrib3dvNV"));
+ SET_VertexAttrib3fNV(disp, dlsym(RTLD_DEFAULT, "glVertexAttrib3fNV"));
+ SET_VertexAttrib3fvNV(disp, dlsym(RTLD_DEFAULT, "glVertexAttrib3fvNV"));
+ SET_VertexAttrib3sNV(disp, dlsym(RTLD_DEFAULT, "glVertexAttrib3sNV"));
+ SET_VertexAttrib3svNV(disp, dlsym(RTLD_DEFAULT, "glVertexAttrib3svNV"));
+ SET_VertexAttrib4dNV(disp, dlsym(RTLD_DEFAULT, "glVertexAttrib4dNV"));
+ SET_VertexAttrib4dvNV(disp, dlsym(RTLD_DEFAULT, "glVertexAttrib4dvNV"));
+ SET_VertexAttrib4fNV(disp, dlsym(RTLD_DEFAULT, "glVertexAttrib4fNV"));
+ SET_VertexAttrib4fvNV(disp, dlsym(RTLD_DEFAULT, "glVertexAttrib4fvNV"));
+ SET_VertexAttrib4sNV(disp, dlsym(RTLD_DEFAULT, "glVertexAttrib4sNV"));
+ SET_VertexAttrib4svNV(disp, dlsym(RTLD_DEFAULT, "glVertexAttrib4svNV"));
+ SET_VertexAttrib4ubNV(disp, dlsym(RTLD_DEFAULT, "glVertexAttrib4ubNV"));
+ SET_VertexAttrib4ubvNV(disp, dlsym(RTLD_DEFAULT, "glVertexAttrib4ubvNV"));
+ SET_VertexAttribPointerNV(disp, dlsym(RTLD_DEFAULT, "glVertexAttribPointerNV"));
+ SET_VertexAttribs1dvNV(disp, dlsym(RTLD_DEFAULT, "glVertexAttribs1dvNV"));
+ SET_VertexAttribs1fvNV(disp, dlsym(RTLD_DEFAULT, "glVertexAttribs1fvNV"));
+ SET_VertexAttribs1svNV(disp, dlsym(RTLD_DEFAULT, "glVertexAttribs1svNV"));
+ SET_VertexAttribs2dvNV(disp, dlsym(RTLD_DEFAULT, "glVertexAttribs2dvNV"));
+ SET_VertexAttribs2fvNV(disp, dlsym(RTLD_DEFAULT, "glVertexAttribs2fvNV"));
+ SET_VertexAttribs2svNV(disp, dlsym(RTLD_DEFAULT, "glVertexAttribs2svNV"));
+ SET_VertexAttribs3dvNV(disp, dlsym(RTLD_DEFAULT, "glVertexAttribs3dvNV"));
+ SET_VertexAttribs3fvNV(disp, dlsym(RTLD_DEFAULT, "glVertexAttribs3fvNV"));
+ SET_VertexAttribs3svNV(disp, dlsym(RTLD_DEFAULT, "glVertexAttribs3svNV"));
+ SET_VertexAttribs4dvNV(disp, dlsym(RTLD_DEFAULT, "glVertexAttribs4dvNV"));
+ SET_VertexAttribs4fvNV(disp, dlsym(RTLD_DEFAULT, "glVertexAttribs4fvNV"));
+ SET_VertexAttribs4svNV(disp, dlsym(RTLD_DEFAULT, "glVertexAttribs4svNV"));
+ SET_VertexAttribs4ubvNV(disp, dlsym(RTLD_DEFAULT, "glVertexAttribs4ubvNV"));
+
+ /* GL_SGIS_multisample */
+ SET_SampleMaskSGIS(disp, dlsym(RTLD_DEFAULT, "glSampleMaskSGIS"));
+ SET_SamplePatternSGIS(disp, dlsym(RTLD_DEFAULT, "glSamplePatternSGIS"));
+
+ /* GL_SGIS_pixel_texture */
+ SET_GetPixelTexGenParameterfvSGIS(disp, dlsym(RTLD_DEFAULT, "glGetPixelTexGenParameterfvSGIS"));
+ SET_GetPixelTexGenParameterivSGIS(disp, dlsym(RTLD_DEFAULT, "glGetPixelTexGenParameterivSGIS"));
+ SET_PixelTexGenParameterfSGIS(disp, dlsym(RTLD_DEFAULT, "glPixelTexGenParameterfSGIS"));
+ SET_PixelTexGenParameterfvSGIS(disp, dlsym(RTLD_DEFAULT, "glPixelTexGenParameterfvSGIS"));
+ SET_PixelTexGenParameteriSGIS(disp, dlsym(RTLD_DEFAULT, "glPixelTexGenParameteriSGIS"));
+ SET_PixelTexGenParameterivSGIS(disp, dlsym(RTLD_DEFAULT, "glPixelTexGenParameterivSGIS"));
+ SET_PixelTexGenSGIX(disp, dlsym(RTLD_DEFAULT, "glPixelTexGenSGIX"));
_glapi_set_dispatch(disp);
}
diff --git a/xorg-server/hw/xquartz/mach-startup/Makefile.am b/xorg-server/hw/xquartz/mach-startup/Makefile.am index 6b907ecf5..1b194f3aa 100644 --- a/xorg-server/hw/xquartz/mach-startup/Makefile.am +++ b/xorg-server/hw/xquartz/mach-startup/Makefile.am @@ -39,7 +39,6 @@ X11_bin_LDADD += \ $(top_builddir)/glx/libglx.la
X11_bin_LDFLAGS += \
- -L/System/Library/Frameworks/OpenGL.framework/Libraries -lGL \
-Wl,-framework,OpenGL
endif
diff --git a/xorg-server/test/xi2/protocol-common.c b/xorg-server/test/xi2/protocol-common.c index a414ad1fb..b6909f925 100644 --- a/xorg-server/test/xi2/protocol-common.c +++ b/xorg-server/test/xi2/protocol-common.c @@ -121,7 +121,7 @@ ClientRec init_client(int len, void *data) void init_window(WindowPtr window, WindowPtr parent, int id)
{
- memset(window, 0, sizeof(window));
+ memset(window, 0, sizeof(*window));
window->drawable.id = id;
if (parent)
diff --git a/xorg-server/xkb/xkbfmisc.c b/xorg-server/xkb/xkbfmisc.c index 42b73012c..0d95b17ff 100644 --- a/xorg-server/xkb/xkbfmisc.c +++ b/xorg-server/xkb/xkbfmisc.c @@ -99,23 +99,34 @@ unsigned set,rtrn; }
break;
case 18: /* latin 8 */
- if ((ks==XK_Babovedot)||
- ((ks>=XK_Dabovedot)&&(ks<=XK_Wacute))||
- ((ks>=XK_Ygrave)&&(ks<=XK_Fabovedot))||
- (ks==XK_Mabovedot)||
- (ks==XK_Pabovedot)||
- (ks==XK_Sabovedot)||
- (ks==XK_Wdiaeresis)||
- ((ks>=XK_Wcircumflex)&&(ks<=XK_Ycircumflex))) {
+ if ((ks==XK_Wcircumflex)||
+ (ks==XK_Ycircumflex)||
+ (ks==XK_Babovedot)||
+ (ks==XK_Dabovedot)||
+ (ks==XK_Fabovedot)||
+ (ks==XK_Mabovedot)||
+ (ks==XK_Pabovedot)||
+ (ks==XK_Sabovedot)||
+ (ks==XK_Tabovedot)||
+ (ks==XK_Wgrave)||
+ (ks==XK_Wacute)||
+ (ks==XK_Wdiaeresis)||
+ (ks==XK_Ygrave)) {
rtrn|= _XkbKSUpper;
}
- if ((ks==XK_babovedot)||
- (ks==XK_dabovedot)||
- (ks==XK_fabovedot)||
- (ks==XK_mabovedot)||
- ((ks>=XK_wgrave)&&(ks<=XK_wacute))||
- (ks==XK_ygrave)||
- ((ks>=XK_wdiaeresis)&&(ks<=XK_ycircumflex))) {
+ if ((ks==XK_wcircumflex)||
+ (ks==XK_ycircumflex)||
+ (ks==XK_babovedot)||
+ (ks==XK_dabovedot)||
+ (ks==XK_fabovedot)||
+ (ks==XK_mabovedot)||
+ (ks==XK_pabovedot)||
+ (ks==XK_sabovedot)||
+ (ks==XK_tabovedot)||
+ (ks==XK_wgrave)||
+ (ks==XK_wacute)||
+ (ks==XK_wdiaeresis)||
+ (ks==XK_ygrave)) {
rtrn|= _XkbKSLower;
}
break;
|