diff --git a/dll/opengl/mesa/CMakeLists.txt b/dll/opengl/mesa/CMakeLists.txt index 004d505e21b..20f8d31137c 100644 --- a/dll/opengl/mesa/CMakeLists.txt +++ b/dll/opengl/mesa/CMakeLists.txt @@ -1,36 +1,71 @@ include_directories(.) -# our DBG definitions conflict with mesa source code -remove_definitions(-DDBG=1 -DDBG=0) +add_definitions(-DFAST_MATH -DTHREADS) -add_definitions( - -DWIN32 - -D_WINDOWS - -D_DLL - -DFEATURE_GL=1 - -D_GDI32_ # prevent gl* being declared __declspec(dllimport) in MS headers - -DBUILD_GL32 # declare gl* as __declspec(dllexport) in Mesa headers - -D_GLAPI_NO_EXPORTS # prevent _glapi_* from being declared __declspec(dllimport) +if(ARCH STREQUAL "i386") + list(APPEND ASM_SOURCE asm-386.S) + add_definitions(-DUSE_ASM) +endif() + +add_asm_files(mesa_asm ${ASM_SOURCE}) + +list(APPEND SOURCE + accum.c + alpha.c + alphabuf.c + api.c + attrib.c + bitmap.c + blend.c + clip.c + colortab.c + context.c + copypix.c + depth.c + dlist.c + drawpix.c + enable.c + eval.c + feedback.c + fog.c + get.c + hash.c + image.c + light.c + lines.c + logic.c + masking.c + matrix.c + misc.c + mmath.c + pb.c + pixel.c + pointers.c + points.c + polygon.c + quads.c + rastpos.c + readpix.c + rect.c + scissor.c + shade.c + span.c + stencil.c + teximage.c + texobj.c + texstate.c + texture.c + triangle.c + varray.c + vb.c + vbfill.c + vbrender.c + vbxform.c + xform.c ) -if(OPENGL32_USE_TLS) - add_definitions(-DOPENGL32_USE_TLS) -endif() +add_library(mesa STATIC ${SOURCE} ${mesa_asm}) +add_dependencies(mesa psdk) -if((ARCH STREQUAL "i386") AND (NOT MSVC)) - add_definitions( - -DUSE_X86_ASM - -DUSE_MMX_ASM - -DUSE_3DNOW_ASM - -DUSE_SSE_ASM) - add_subdirectory(x86) -endif() - -add_subdirectory(drivers/common) -add_subdirectory(main) -add_subdirectory(math) -add_subdirectory(swrast) -add_subdirectory(swrast_setup) -add_subdirectory(tnl) -add_subdirectory(vbo) + diff --git a/dll/opengl/mesa/accum.c b/dll/opengl/mesa/accum.c new file mode 100644 index 00000000000..1d249024299 --- /dev/null +++ b/dll/opengl/mesa/accum.c @@ -0,0 +1,373 @@ +/* $Id: accum.c,v 1.5 1997/07/24 01:24:28 brianp Exp $ */ + +/* + * Mesa 3-D graphics library + * Version: 2.4 + * Copyright (C) 1995-1997 Brian Paul + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Library General Public + * License as published by the Free Software Foundation; either + * version 2 of the License, or (at your option) any later version. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Library General Public License for more details. + * + * You should have received a copy of the GNU Library General Public + * License along with this library; if not, write to the Free + * Software Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. + */ + + +/* + * $Log: accum.c,v $ + * Revision 1.5 1997/07/24 01:24:28 brianp + * changed precompiled header symbol from PCH to PC_HEADER + * + * Revision 1.4 1997/05/28 03:23:09 brianp + * added precompiled header (PCH) support + * + * Revision 1.3 1997/04/30 01:54:48 brianp + * call gl_warning() if calling gl_Accum w/out accum buffer + * + * Revision 1.2 1996/09/15 14:19:44 brianp + * now use GLframebuffer and GLvisual + * added gl_alloc_accum_buffer() + * + * Revision 1.1 1996/09/13 01:38:16 brianp + * Initial revision + * + */ + + +#ifdef PC_HEADER +#include "all.h" +#else +#include +#include +#include +#include "accum.h" +#include "context.h" +#include "dlist.h" +#include "macros.h" +#include "types.h" +#endif + + +void gl_alloc_accum_buffer( GLcontext *ctx ) +{ + GLint n; + + if (ctx->Buffer->Accum) { + free( ctx->Buffer->Accum ); + ctx->Buffer->Accum = NULL; + } + + /* allocate accumulation buffer if not already present */ + n = ctx->Buffer->Width * ctx->Buffer->Height * 4 * sizeof(GLaccum); + ctx->Buffer->Accum = (GLaccum *) malloc( n ); + if (!ctx->Buffer->Accum) { + /* unable to setup accumulation buffer */ + gl_error( ctx, GL_OUT_OF_MEMORY, "glAccum" ); + } +} + + + +void gl_ClearAccum( GLcontext *ctx, + GLfloat red, GLfloat green, GLfloat blue, GLfloat alpha ) +{ + if (INSIDE_BEGIN_END(ctx)) { + gl_error( ctx, GL_INVALID_OPERATION, "glAccum" ); + return; + } + ctx->Accum.ClearColor[0] = CLAMP( red, -1.0, 1.0 ); + ctx->Accum.ClearColor[1] = CLAMP( green, -1.0, 1.0 ); + ctx->Accum.ClearColor[2] = CLAMP( blue, -1.0, 1.0 ); + ctx->Accum.ClearColor[3] = CLAMP( alpha, -1.0, 1.0 ); +} + + + + +void gl_Accum( GLcontext *ctx, GLenum op, GLfloat value ) +{ + GLuint xpos, ypos, width, height; + GLfloat acc_scale; + + if (INSIDE_BEGIN_END(ctx)) { + gl_error( ctx, GL_INVALID_OPERATION, "glAccum" ); + return; + } + + if (ctx->Visual->AccumBits==0 || !ctx->Buffer->Accum) { + /* No accumulation buffer! */ + gl_warning(ctx, "Calling glAccum() without an accumulation buffer"); + return; + } + + if (sizeof(GLaccum)==1) { + acc_scale = 127.0; + } + else if (sizeof(GLaccum)==2) { + acc_scale = 32767.0; + } + else { + /* sizeof(GLaccum) > 2 (Cray) */ + acc_scale = (float) SHRT_MAX; + } + + /* Determine region to operate upon. */ + if (ctx->Scissor.Enabled) { + xpos = ctx->Scissor.X; + ypos = ctx->Scissor.Y; + width = ctx->Scissor.Width; + height = ctx->Scissor.Height; + } + else { + /* whole window */ + xpos = 0; + ypos = 0; + width = ctx->Buffer->Width; + height = ctx->Buffer->Height; + } + + switch (op) { + case GL_ADD: + { + GLaccum ival, *acc; + GLuint i, j; + + ival = (GLaccum) (value * acc_scale); + for (j=0;jBuffer->Accum + + (ypos * ctx->Buffer->Width + xpos) * 4; + for (i=0;iBuffer->Accum + + (ypos * ctx->Buffer->Width + xpos) * 4; + for (i=0;iDriver.SetBuffer)( ctx, ctx->Pixel.ReadBuffer ); + + /* Accumulate */ + rscale = value * acc_scale * ctx->Visual->InvRedScale; + gscale = value * acc_scale * ctx->Visual->InvGreenScale; + bscale = value * acc_scale * ctx->Visual->InvBlueScale; + ascale = value * acc_scale * ctx->Visual->InvAlphaScale; + for (j=0;jDriver.ReadColorSpan)( ctx, width, xpos, ypos, + red, green, blue, alpha); + acc = ctx->Buffer->Accum + + (ypos * ctx->Buffer->Width + xpos) * 4; + for (i=0;iDriver.SetBuffer)( ctx, ctx->Color.DrawBuffer ); + } + break; + case GL_LOAD: + { + GLaccum *acc; + GLubyte red[MAX_WIDTH], green[MAX_WIDTH]; + GLubyte blue[MAX_WIDTH], alpha[MAX_WIDTH]; + GLfloat rscale, gscale, bscale, ascale; + GLuint i, j; + + (void) (*ctx->Driver.SetBuffer)( ctx, ctx->Pixel.ReadBuffer ); + + /* Load accumulation buffer */ + rscale = value * acc_scale * ctx->Visual->InvRedScale; + gscale = value * acc_scale * ctx->Visual->InvGreenScale; + bscale = value * acc_scale * ctx->Visual->InvBlueScale; + ascale = value * acc_scale * ctx->Visual->InvAlphaScale; + for (j=0;jDriver.ReadColorSpan)( ctx, width, xpos, ypos, + red, green, blue, alpha); + acc = ctx->Buffer->Accum + + (ypos * ctx->Buffer->Width + xpos) * 4; + for (i=0;iDriver.SetBuffer)( ctx, ctx->Color.DrawBuffer ); + } + break; + case GL_RETURN: + { + GLubyte red[MAX_WIDTH], green[MAX_WIDTH]; + GLubyte blue[MAX_WIDTH], alpha[MAX_WIDTH]; + GLaccum *acc; + GLfloat rscale, gscale, bscale, ascale; + GLint rmax, gmax, bmax, amax; + GLuint i, j; + + rscale = value / acc_scale * ctx->Visual->RedScale; + gscale = value / acc_scale * ctx->Visual->GreenScale; + bscale = value / acc_scale * ctx->Visual->BlueScale; + ascale = value / acc_scale * ctx->Visual->AlphaScale; + rmax = (GLint) ctx->Visual->RedScale; + gmax = (GLint) ctx->Visual->GreenScale; + bmax = (GLint) ctx->Visual->BlueScale; + amax = (GLint) ctx->Visual->AlphaScale; + for (j=0;jBuffer->Accum + + (ypos * ctx->Buffer->Width + xpos) * 4; + for (i=0;iDriver.WriteColorSpan)( ctx, width, xpos, ypos, + red, green, blue, alpha, NULL ); + ypos++; + } + } + break; + default: + gl_error( ctx, GL_INVALID_ENUM, "glAccum" ); + } +} + + + + +/* + * Clear the accumulation Buffer-> + */ +void gl_clear_accum_buffer( GLcontext *ctx ) +{ + GLuint buffersize; + GLfloat acc_scale; + + if (ctx->Visual->AccumBits==0) { + /* No accumulation buffer! */ + return; + } + + if (sizeof(GLaccum)==1) { + acc_scale = 127.0; + } + else if (sizeof(GLaccum)==2) { + acc_scale = 32767.0; + } + else { + /* sizeof(GLaccum) > 2 (Cray) */ + acc_scale = (float) SHRT_MAX; + } + + /* number of pixels */ + buffersize = ctx->Buffer->Width * ctx->Buffer->Height; + + if (!ctx->Buffer->Accum) { + /* try to alloc accumulation buffer */ + ctx->Buffer->Accum = (GLaccum *) + malloc( buffersize * 4 * sizeof(GLaccum) ); + } + + if (ctx->Buffer->Accum) { + if (ctx->Scissor.Enabled) { + /* Limit clear to scissor box */ + GLaccum r, g, b, a; + GLint i, j; + GLint width, height; + GLaccum *row; + r = (GLaccum) (ctx->Accum.ClearColor[0] * acc_scale); + g = (GLaccum) (ctx->Accum.ClearColor[1] * acc_scale); + b = (GLaccum) (ctx->Accum.ClearColor[2] * acc_scale); + a = (GLaccum) (ctx->Accum.ClearColor[3] * acc_scale); + /* size of region to clear */ + width = 4 * (ctx->Buffer->Xmax - ctx->Buffer->Xmin + 1); + height = ctx->Buffer->Ymax - ctx->Buffer->Ymin + 1; + /* ptr to first element to clear */ + row = ctx->Buffer->Accum + + 4 * (ctx->Buffer->Ymin * ctx->Buffer->Width + + ctx->Buffer->Xmin); + for (j=0;jBuffer->Width; + } + } + else { + /* clear whole buffer */ + if (ctx->Accum.ClearColor[0]==0.0 && + ctx->Accum.ClearColor[1]==0.0 && + ctx->Accum.ClearColor[2]==0.0 && + ctx->Accum.ClearColor[3]==0.0) { + /* Black */ + MEMSET( ctx->Buffer->Accum, 0, buffersize * 4 * sizeof(GLaccum) ); + } + else { + /* Not black */ + GLaccum *acc, r, g, b, a; + GLuint i; + + acc = ctx->Buffer->Accum; + r = (GLaccum) (ctx->Accum.ClearColor[0] * acc_scale); + g = (GLaccum) (ctx->Accum.ClearColor[1] * acc_scale); + b = (GLaccum) (ctx->Accum.ClearColor[2] * acc_scale); + a = (GLaccum) (ctx->Accum.ClearColor[3] * acc_scale); + for (i=0;i headers take + * a *long* time to compile. + */ + + +#ifndef SRC_ALL_H +#define SRC_ALL_H + + +#ifndef PC_HEADER + This is an error. all.h should be included only if PC_HEADER is defined. +#endif + + +#include +#include +#include +#include +#include +#include +#include +#include "GL/gl.h" +#include "GL/osmesa.h" +#include "accum.h" +#include "alpha.h" +#include "alphabuf.h" +#include "api.h" +#include "asm-386.h" +#include "attrib.h" +#include "bitmap.h" +#include "blend.h" +#include "clip.h" +#include "colortab.h" +#include "context.h" +#include "config.h" +#include "copypix.h" +#include "dd.h" +#include "depth.h" +#include "dlist.h" +#include "drawpix.h" +#include "enable.h" +#include "eval.h" +#include "feedback.h" +#include "fixed.h" +#include "fog.h" +#include "get.h" +#include "hash.h" +#include "image.h" +#include "light.h" +#include "lines.h" +#include "logic.h" +#include "macros.h" +#include "masking.h" +#include "matrix.h" +#include "misc.h" +#include "mmath.h" +#include "pb.h" +#include "pixel.h" +#include "pointers.h" +#include "points.h" +#include "polygon.h" +#include "rastpos.h" +#include "readpix.h" +#include "rect.h" +#include "scissor.h" +#include "shade.h" +#include "span.h" +#include "stencil.h" +#include "teximage.h" +#include "texobj.h" +#include "texstate.h" +#include "texture.h" +#include "triangle.h" +#include "types.h" +#include "varray.h" +#include "vb.h" +#include "vbfill.h" +#include "vbrender.h" +#include "vbxform.h" +#include "winpos.h" +#include "xform.h" + + +#endif /*SRC_ALL_H*/ diff --git a/dll/opengl/mesa/alpha.c b/dll/opengl/mesa/alpha.c new file mode 100644 index 00000000000..c99a6d4450a --- /dev/null +++ b/dll/opengl/mesa/alpha.c @@ -0,0 +1,142 @@ +/* $Id: alpha.c,v 1.5 1997/07/24 01:24:28 brianp Exp $ */ + +/* + * Mesa 3-D graphics library + * Version: 2.4 + * Copyright (C) 1995-1997 Brian Paul + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Library General Public + * License as published by the Free Software Foundation; either + * version 2 of the License, or (at your option) any later version. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Library General Public License for more details. + * + * You should have received a copy of the GNU Library General Public + * License along with this library; if not, write to the Free + * Software Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. + */ + + +/* + * $Log: alpha.c,v $ + * Revision 1.5 1997/07/24 01:24:28 brianp + * changed precompiled header symbol from PCH to PC_HEADER + * + * Revision 1.4 1997/05/28 03:23:09 brianp + * added precompiled header (PCH) support + * + * Revision 1.3 1997/03/13 03:07:53 brianp + * optimized gl_alpha_test() by removing conditional from inside loops + * + * Revision 1.2 1996/09/15 14:15:54 brianp + * now use GLframebuffer and GLvisual + * + * Revision 1.1 1996/09/13 01:38:16 brianp + * Initial revision + * + */ + + +#ifdef PC_HEADER +#include "all.h" +#else +#include "alpha.h" +#include "context.h" +#include "types.h" +#include "dlist.h" +#include "macros.h" +#endif + + + +void gl_AlphaFunc( GLcontext* ctx, GLenum func, GLclampf ref ) +{ + if (INSIDE_BEGIN_END(ctx)) { + gl_error( ctx, GL_INVALID_OPERATION, "glAlphaFunc" ); + return; + } + switch (func) { + case GL_NEVER: + case GL_LESS: + case GL_EQUAL: + case GL_LEQUAL: + case GL_GREATER: + case GL_NOTEQUAL: + case GL_GEQUAL: + case GL_ALWAYS: + ctx->Color.AlphaFunc = func; + ctx->Color.AlphaRef = CLAMP( ref, 0.0F, 1.0F ); + ctx->Color.AlphaRefUbyte = (GLubyte) (ctx->Color.AlphaRef + * ctx->Visual->AlphaScale); + break; + default: + gl_error( ctx, GL_INVALID_ENUM, "glAlphaFunc(func)" ); + break; + } +} + + + + +/* + * Apply the alpha test to a span of pixels. + * In/Out: mask - current pixel mask. Pixels which fail the alpha test + * will set the corresponding mask flag to 0. + * Return: 0 = all pixels in the span failed the alpha test. + * 1 = one or more pixels passed the alpha test. + */ +GLint gl_alpha_test( GLcontext* ctx, + GLuint n, const GLubyte alpha[], GLubyte mask[] ) +{ + GLuint i; + GLubyte ref = ctx->Color.AlphaRefUbyte; + + /* switch cases ordered from most frequent to less frequent */ + switch (ctx->Color.AlphaFunc) { + case GL_LESS: + for (i=0;i= ref); + } + return 1; + case GL_GREATER: + for (i=0;i ref); + } + return 1; + case GL_NOTEQUAL: + for (i=0;i +#include +#include "alphabuf.h" +#include "context.h" +#include "macros.h" +#include "types.h" +#endif + + + +#define ALPHA_ADDR(X,Y) (ctx->Buffer->Alpha + (Y) * ctx->Buffer->Width + (X)) + + + +/* + * Allocate a new front and back alpha buffer. + */ +void gl_alloc_alpha_buffers( GLcontext* ctx ) +{ + GLint bytes = ctx->Buffer->Width * ctx->Buffer->Height * sizeof(GLubyte); + + if (ctx->Visual->FrontAlphaEnabled) { + if (ctx->Buffer->FrontAlpha) { + free( ctx->Buffer->FrontAlpha ); + } + ctx->Buffer->FrontAlpha = (GLubyte *) malloc( bytes ); + if (!ctx->Buffer->FrontAlpha) { + /* out of memory */ + gl_error( ctx, GL_OUT_OF_MEMORY, "Couldn't allocate front alpha buffer" ); + } + } + if (ctx->Visual->BackAlphaEnabled) { + if (ctx->Buffer->BackAlpha) { + free( ctx->Buffer->BackAlpha ); + } + ctx->Buffer->BackAlpha = (GLubyte *) malloc( bytes ); + if (!ctx->Buffer->BackAlpha) { + /* out of memory */ + gl_error( ctx, GL_OUT_OF_MEMORY, "Couldn't allocate back alpha buffer" ); + } + } + if (ctx->Color.DrawBuffer==GL_FRONT) { + ctx->Buffer->Alpha = ctx->Buffer->FrontAlpha; + } + if (ctx->Color.DrawBuffer==GL_BACK) { + ctx->Buffer->Alpha = ctx->Buffer->BackAlpha; + } +} + + + +/* + * Clear the front and/or back alpha planes. + */ +void gl_clear_alpha_buffers( GLcontext* ctx ) +{ + GLint buffer; + + /* Loop over front and back buffers */ + for (buffer=0;buffer<2;buffer++) { + + /* Get pointer to front or back buffer */ + GLubyte *abuffer = NULL; + if (buffer==0 + && ( ctx->Color.DrawBuffer==GL_FRONT + || ctx->Color.DrawBuffer==GL_FRONT_AND_BACK) + && ctx->Visual->FrontAlphaEnabled && ctx->Buffer->FrontAlpha) { + abuffer = ctx->Buffer->FrontAlpha; + } + else if (buffer==1 + && ( ctx->Color.DrawBuffer==GL_BACK + || ctx->Color.DrawBuffer==GL_FRONT_AND_BACK) + && ctx->Visual->BackAlphaEnabled && ctx->Buffer->BackAlpha) { + abuffer = ctx->Buffer->BackAlpha; + } + + /* Clear the alpha buffer */ + if (abuffer) { + GLubyte aclear = (GLint) (ctx->Color.ClearColor[3] + * ctx->Visual->AlphaScale); + if (ctx->Scissor.Enabled) { + /* clear scissor region */ + GLint i, j; + for (j=0;jScissor.Height;j++) { + GLubyte *aptr = ALPHA_ADDR(ctx->Buffer->Xmin, + ctx->Buffer->Ymin+j); + for (i=0;iScissor.Width;i++) { + *aptr++ = aclear; + } + } + } + else { + /* clear whole buffer */ + MEMSET( abuffer, aclear, ctx->Buffer->Width*ctx->Buffer->Height ); + } + } + } +} + + + +void gl_write_alpha_span( GLcontext* ctx, GLuint n, GLint x, GLint y, + GLubyte alpha[], GLubyte mask[] ) +{ + GLubyte *aptr = ALPHA_ADDR( x, y ); + GLuint i; + + if (mask) { + for (i=0;i +#include +#include "api.h" +#include "bitmap.h" +#include "context.h" + +#include "drawpix.h" + +#include "eval.h" +#include "image.h" +#include "macros.h" +#include "matrix.h" +#include "teximage.h" +#include "types.h" +#include "vb.h" +#endif + +void APIENTRY _mesa_Accum( GLenum op, GLfloat value ) +{ + GET_CONTEXT; + (*CC->API.Accum)(CC, op, value); +} + +void APIENTRY _mesa_AlphaFunc( GLenum func, GLclampf ref ) +{ + GET_CONTEXT; + (*CC->API.AlphaFunc)(CC, func, ref); +} + + +GLboolean APIENTRY _mesa_AreTexturesResident( GLsizei n, const GLuint *textures, + GLboolean *residences ) +{ + GET_CONTEXT; + return (*CC->API.AreTexturesResident)(CC, n, textures, residences); +} + +void APIENTRY _mesa_ArrayElement( GLint i ) +{ + GET_CONTEXT; + (*CC->API.ArrayElement)(CC, i); +} + + +void APIENTRY _mesa_Begin( GLenum mode ) +{ + GET_CONTEXT; + (*CC->API.Begin)( CC, mode ); +} + + +void APIENTRY _mesa_BindTexture( GLenum target, GLuint texture ) +{ + GET_CONTEXT; + (*CC->API.BindTexture)(CC, target, texture); +} + + +void APIENTRY _mesa_Bitmap( GLsizei width, GLsizei height, + GLfloat xorig, GLfloat yorig, + GLfloat xmove, GLfloat ymove, + const GLubyte *bitmap ) +{ + GET_CONTEXT; + if (!CC->CompileFlag) { + /* execute only, try optimized case where no unpacking needed */ + if ( CC->Unpack.LsbFirst==GL_FALSE + && CC->Unpack.Alignment==1 + && CC->Unpack.RowLength==0 + && CC->Unpack.SkipPixels==0 + && CC->Unpack.SkipRows==0) { + /* Special case: no unpacking needed */ + struct gl_image image; + image.Width = width; + image.Height = height; + image.Components = 0; + image.Type = GL_BITMAP; + image.Format = GL_COLOR_INDEX; + image.Data = (GLvoid *) bitmap; + (*CC->Exec.Bitmap)( CC, width, height, xorig, yorig, + xmove, ymove, &image ); + } + else { + struct gl_image *image; + image = gl_unpack_bitmap( CC, width, height, bitmap ); + (*CC->Exec.Bitmap)( CC, width, height, xorig, yorig, + xmove, ymove, image ); + if (image) { + gl_free_image( image ); + } + } + } + else { + /* compile and maybe execute */ + struct gl_image *image; + image = gl_unpack_bitmap( CC, width, height, bitmap ); + (*CC->API.Bitmap)(CC, width, height, xorig, yorig, xmove, ymove, image ); + } +} + + +void APIENTRY _mesa_BlendFunc( GLenum sfactor, GLenum dfactor ) +{ + GET_CONTEXT; + (*CC->API.BlendFunc)(CC, sfactor, dfactor); +} + + +void APIENTRY _mesa_CallList( GLuint list ) +{ + GET_CONTEXT; + (*CC->API.CallList)(CC, list); +} + + +void APIENTRY _mesa_CallLists( GLsizei n, GLenum type, const GLvoid *lists ) +{ + GET_CONTEXT; + (*CC->API.CallLists)(CC, n, type, lists); +} + + +void APIENTRY _mesa_Clear( GLbitfield mask ) +{ + GET_CONTEXT; + (*CC->API.Clear)(CC, mask); +} + + +void APIENTRY _mesa_ClearAccum( GLfloat red, GLfloat green, + GLfloat blue, GLfloat alpha ) +{ + GET_CONTEXT; + (*CC->API.ClearAccum)(CC, red, green, blue, alpha); +} + + + +void APIENTRY _mesa_ClearIndex( GLfloat c ) +{ + GET_CONTEXT; + (*CC->API.ClearIndex)(CC, c); +} + + +void APIENTRY _mesa_ClearColor( GLclampf red, + GLclampf green, + GLclampf blue, + GLclampf alpha ) +{ + GET_CONTEXT; + (*CC->API.ClearColor)(CC, red, green, blue, alpha); +} + + +void APIENTRY _mesa_ClearDepth( GLclampd depth ) +{ + GET_CONTEXT; + (*CC->API.ClearDepth)( CC, depth ); +} + + +void APIENTRY _mesa_ClearStencil( GLint s ) +{ + GET_CONTEXT; + (*CC->API.ClearStencil)(CC, s); +} + + +void APIENTRY _mesa_ClipPlane( GLenum plane, const GLdouble *equation ) +{ + GLfloat eq[4]; + GET_CONTEXT; + eq[0] = (GLfloat) equation[0]; + eq[1] = (GLfloat) equation[1]; + eq[2] = (GLfloat) equation[2]; + eq[3] = (GLfloat) equation[3]; + (*CC->API.ClipPlane)(CC, plane, eq ); +} + + +void APIENTRY _mesa_Color3b( GLbyte red, GLbyte green, GLbyte blue ) +{ + GET_CONTEXT; + (*CC->API.Color3f)( CC, BYTE_TO_FLOAT(red), BYTE_TO_FLOAT(green), + BYTE_TO_FLOAT(blue) ); +} + + +void APIENTRY _mesa_Color3d( GLdouble red, GLdouble green, GLdouble blue ) +{ + GET_CONTEXT; + (*CC->API.Color3f)( CC, (GLfloat) red, (GLfloat) green, (GLfloat) blue ); +} + + +void APIENTRY _mesa_Color3f( GLfloat red, GLfloat green, GLfloat blue ) +{ + GET_CONTEXT; + (*CC->API.Color3f)( CC, red, green, blue ); +} + + +void APIENTRY _mesa_Color3i( GLint red, GLint green, GLint blue ) +{ + GET_CONTEXT; + (*CC->API.Color3f)( CC, INT_TO_FLOAT(red), INT_TO_FLOAT(green), + INT_TO_FLOAT(blue) ); +} + + +void APIENTRY _mesa_Color3s( GLshort red, GLshort green, GLshort blue ) +{ + GET_CONTEXT; + (*CC->API.Color3f)( CC, SHORT_TO_FLOAT(red), SHORT_TO_FLOAT(green), + SHORT_TO_FLOAT(blue) ); +} + + +void APIENTRY _mesa_Color3ub( GLubyte red, GLubyte green, GLubyte blue ) +{ + GET_CONTEXT; + (*CC->API.Color4ub)( CC, red, green, blue, 255 ); +} + + +void APIENTRY _mesa_Color3ui( GLuint red, GLuint green, GLuint blue ) +{ + GET_CONTEXT; + (*CC->API.Color3f)( CC, UINT_TO_FLOAT(red), UINT_TO_FLOAT(green), + UINT_TO_FLOAT(blue) ); +} + + +void APIENTRY _mesa_Color3us( GLushort red, GLushort green, GLushort blue ) +{ + GET_CONTEXT; + (*CC->API.Color3f)( CC, USHORT_TO_FLOAT(red), USHORT_TO_FLOAT(green), + USHORT_TO_FLOAT(blue) ); +} + + +void APIENTRY _mesa_Color4b( GLbyte red, GLbyte green, GLbyte blue, GLbyte alpha ) +{ + GET_CONTEXT; + (*CC->API.Color4f)( CC, BYTE_TO_FLOAT(red), BYTE_TO_FLOAT(green), + BYTE_TO_FLOAT(blue), BYTE_TO_FLOAT(alpha) ); +} + + +void APIENTRY _mesa_Color4d( GLdouble red, GLdouble green, GLdouble blue, GLdouble alpha ) +{ + GET_CONTEXT; + (*CC->API.Color4f)( CC, (GLfloat) red, (GLfloat) green, + (GLfloat) blue, (GLfloat) alpha ); +} + + +void APIENTRY _mesa_Color4f( GLfloat red, GLfloat green, GLfloat blue, GLfloat alpha ) +{ + GET_CONTEXT; + (*CC->API.Color4f)( CC, red, green, blue, alpha ); +} + +void APIENTRY _mesa_Color4i( GLint red, GLint green, GLint blue, GLint alpha ) +{ + GET_CONTEXT; + (*CC->API.Color4f)( CC, INT_TO_FLOAT(red), INT_TO_FLOAT(green), + INT_TO_FLOAT(blue), INT_TO_FLOAT(alpha) ); +} + + +void APIENTRY _mesa_Color4s( GLshort red, GLshort green, GLshort blue, GLshort alpha ) +{ + GET_CONTEXT; + (*CC->API.Color4f)( CC, SHORT_TO_FLOAT(red), SHORT_TO_FLOAT(green), + SHORT_TO_FLOAT(blue), SHORT_TO_FLOAT(alpha) ); +} + +void APIENTRY _mesa_Color4ub( GLubyte red, GLubyte green, GLubyte blue, GLubyte alpha ) +{ + GET_CONTEXT; + (*CC->API.Color4ub)( CC, red, green, blue, alpha ); +} + +void APIENTRY _mesa_Color4ui( GLuint red, GLuint green, GLuint blue, GLuint alpha ) +{ + GET_CONTEXT; + (*CC->API.Color4f)( CC, UINT_TO_FLOAT(red), UINT_TO_FLOAT(green), + UINT_TO_FLOAT(blue), UINT_TO_FLOAT(alpha) ); +} + +void APIENTRY _mesa_Color4us( GLushort red, GLushort green, GLushort blue, GLushort alpha ) +{ + GET_CONTEXT; + (*CC->API.Color4f)( CC, USHORT_TO_FLOAT(red), USHORT_TO_FLOAT(green), + USHORT_TO_FLOAT(blue), USHORT_TO_FLOAT(alpha) ); +} + + +void APIENTRY _mesa_Color3bv( const GLbyte *v ) +{ + GET_CONTEXT; + (*CC->API.Color3f)( CC, BYTE_TO_FLOAT(v[0]), BYTE_TO_FLOAT(v[1]), + BYTE_TO_FLOAT(v[2]) ); +} + + +void APIENTRY _mesa_Color3dv( const GLdouble *v ) +{ + GET_CONTEXT; + (*CC->API.Color3f)( CC, (GLdouble) v[0], (GLdouble) v[1], (GLdouble) v[2] ); +} + + +void APIENTRY _mesa_Color3fv( const GLfloat *v ) +{ + GET_CONTEXT; + (*CC->API.Color3fv)( CC, v ); +} + + +void APIENTRY _mesa_Color3iv( const GLint *v ) +{ + GET_CONTEXT; + (*CC->API.Color3f)( CC, INT_TO_FLOAT(v[0]), INT_TO_FLOAT(v[1]), + INT_TO_FLOAT(v[2]) ); +} + + +void APIENTRY _mesa_Color3sv( const GLshort *v ) +{ + GET_CONTEXT; + (*CC->API.Color3f)( CC, SHORT_TO_FLOAT(v[0]), SHORT_TO_FLOAT(v[1]), + SHORT_TO_FLOAT(v[2]) ); +} + + +void APIENTRY _mesa_Color3ubv( const GLubyte *v ) +{ + GET_CONTEXT; + (*CC->API.Color4ub)( CC, v[0], v[1], v[2], 255 ); +} + + +void APIENTRY _mesa_Color3uiv( const GLuint *v ) +{ + GET_CONTEXT; + (*CC->API.Color3f)( CC, UINT_TO_FLOAT(v[0]), UINT_TO_FLOAT(v[1]), + UINT_TO_FLOAT(v[2]) ); +} + + +void APIENTRY _mesa_Color3usv( const GLushort *v ) +{ + GET_CONTEXT; + (*CC->API.Color3f)( CC, USHORT_TO_FLOAT(v[0]), USHORT_TO_FLOAT(v[1]), + USHORT_TO_FLOAT(v[2]) ); + +} + + +void APIENTRY _mesa_Color4bv( const GLbyte *v ) +{ + GET_CONTEXT; + (*CC->API.Color4f)( CC, BYTE_TO_FLOAT(v[0]), BYTE_TO_FLOAT(v[1]), + BYTE_TO_FLOAT(v[2]), BYTE_TO_FLOAT(v[3]) ); +} + + +void APIENTRY _mesa_Color4dv( const GLdouble *v ) +{ + GET_CONTEXT; + (*CC->API.Color4f)( CC, (GLdouble) v[0], (GLdouble) v[1], + (GLdouble) v[2], (GLdouble) v[3] ); +} + + +void APIENTRY _mesa_Color4fv( const GLfloat *v ) +{ + GET_CONTEXT; + (*CC->API.Color4f)( CC, v[0], v[1], v[2], v[3] ); +} + + +void APIENTRY _mesa_Color4iv( const GLint *v ) +{ + GET_CONTEXT; + (*CC->API.Color4f)( CC, INT_TO_FLOAT(v[0]), INT_TO_FLOAT(v[1]), + INT_TO_FLOAT(v[2]), INT_TO_FLOAT(v[3]) ); +} + + +void APIENTRY _mesa_Color4sv( const GLshort *v ) +{ + GET_CONTEXT; + (*CC->API.Color4f)( CC, SHORT_TO_FLOAT(v[0]), SHORT_TO_FLOAT(v[1]), + SHORT_TO_FLOAT(v[2]), SHORT_TO_FLOAT(v[3]) ); +} + + +void APIENTRY _mesa_Color4ubv( const GLubyte *v ) +{ + GET_CONTEXT; + (*CC->API.Color4ubv)( CC, v ); +} + + +void APIENTRY _mesa_Color4uiv( const GLuint *v ) +{ + GET_CONTEXT; + (*CC->API.Color4f)( CC, UINT_TO_FLOAT(v[0]), UINT_TO_FLOAT(v[1]), + UINT_TO_FLOAT(v[2]), UINT_TO_FLOAT(v[3]) ); +} + + +void APIENTRY _mesa_Color4usv( const GLushort *v ) +{ + GET_CONTEXT; + (*CC->API.Color4f)( CC, USHORT_TO_FLOAT(v[0]), USHORT_TO_FLOAT(v[1]), + USHORT_TO_FLOAT(v[2]), USHORT_TO_FLOAT(v[3]) ); +} + + +void APIENTRY _mesa_ColorMask( GLboolean red, GLboolean green, + GLboolean blue, GLboolean alpha ) +{ + GET_CONTEXT; + (*CC->API.ColorMask)(CC, red, green, blue, alpha); +} + + +void APIENTRY _mesa_ColorMaterial( GLenum face, GLenum mode ) +{ + GET_CONTEXT; + (*CC->API.ColorMaterial)(CC, face, mode); +} + + +void APIENTRY _mesa_ColorPointer( GLint size, GLenum type, GLsizei stride, + const GLvoid *ptr ) +{ + GET_CONTEXT; + (*CC->API.ColorPointer)(CC, size, type, stride, ptr); +} + + +void APIENTRY _mesa_CopyPixels( GLint x, GLint y, GLsizei width, GLsizei height, + GLenum type ) +{ + GET_CONTEXT; + (*CC->API.CopyPixels)(CC, x, y, width, height, type); +} + + +void APIENTRY _mesa_CopyTexImage1D( GLenum target, GLint level, + GLenum internalformat, + GLint x, GLint y, + GLsizei width, GLint border ) +{ + GET_CONTEXT; + (*CC->API.CopyTexImage1D)( CC, target, level, internalformat, + x, y, width, border ); +} + + +void APIENTRY _mesa_CopyTexImage2D( GLenum target, GLint level, + GLenum internalformat, + GLint x, GLint y, + GLsizei width, GLsizei height, GLint border ) +{ + GET_CONTEXT; + (*CC->API.CopyTexImage2D)( CC, target, level, internalformat, + x, y, width, height, border ); +} + + +void APIENTRY _mesa_CopyTexSubImage1D( GLenum target, GLint level, + GLint xoffset, GLint x, GLint y, + GLsizei width ) +{ + GET_CONTEXT; + (*CC->API.CopyTexSubImage1D)( CC, target, level, xoffset, x, y, width ); +} + + +void APIENTRY _mesa_CopyTexSubImage2D( GLenum target, GLint level, + GLint xoffset, GLint yoffset, + GLint x, GLint y, + GLsizei width, GLsizei height ) +{ + GET_CONTEXT; + (*CC->API.CopyTexSubImage2D)( CC, target, level, xoffset, yoffset, + x, y, width, height ); +} + + + +void APIENTRY _mesa_CullFace( GLenum mode ) +{ + GET_CONTEXT; + (*CC->API.CullFace)(CC, mode); +} + + +void APIENTRY _mesa_DepthFunc( GLenum func ) +{ + GET_CONTEXT; + (*CC->API.DepthFunc)( CC, func ); +} + + +void APIENTRY _mesa_DepthMask( GLboolean flag ) +{ + GET_CONTEXT; + (*CC->API.DepthMask)( CC, flag ); +} + + +void APIENTRY _mesa_DepthRange( GLclampd near_val, GLclampd far_val ) +{ + GET_CONTEXT; + (*CC->API.DepthRange)( CC, near_val, far_val ); +} + + +void APIENTRY _mesa_DeleteLists( GLuint list, GLsizei range ) +{ + GET_CONTEXT; + (*CC->API.DeleteLists)(CC, list, range); +} + + +void APIENTRY _mesa_DeleteTextures( GLsizei n, const GLuint *textures) +{ + GET_CONTEXT; + (*CC->API.DeleteTextures)(CC, n, textures); +} + + +void APIENTRY _mesa_Disable( GLenum cap ) +{ + GET_CONTEXT; + (*CC->API.Disable)( CC, cap ); +} + + +void APIENTRY _mesa_DisableClientState( GLenum cap ) +{ + GET_CONTEXT; + (*CC->API.DisableClientState)( CC, cap ); +} + + +void APIENTRY _mesa_DrawArrays( GLenum mode, GLint first, GLsizei count ) +{ + GET_CONTEXT; + (*CC->API.DrawArrays)(CC, mode, first, count); +} + + +void APIENTRY _mesa_DrawBuffer( GLenum mode ) +{ + GET_CONTEXT; + (*CC->API.DrawBuffer)(CC, mode); +} + + +void APIENTRY _mesa_DrawElements( GLenum mode, GLsizei count, + GLenum type, const GLvoid *indices ) +{ + GET_CONTEXT; + (*CC->API.DrawElements)( CC, mode, count, type, indices ); +} + + +void APIENTRY _mesa_DrawPixels( GLsizei width, GLsizei height, + GLenum format, GLenum type, const GLvoid *pixels ) +{ + GET_CONTEXT; + (*CC->API.DrawPixels)( CC, width, height, format, type, pixels ); +} + + +void APIENTRY _mesa_Enable( GLenum cap ) +{ + GET_CONTEXT; + (*CC->API.Enable)( CC, cap ); +} + + +void APIENTRY _mesa_EnableClientState( GLenum cap ) +{ + GET_CONTEXT; + (*CC->API.EnableClientState)( CC, cap ); +} + + +void APIENTRY _mesa_End( void ) +{ + GET_CONTEXT; + (*CC->API.End)( CC ); +} + + +void APIENTRY _mesa_EndList( void ) +{ + GET_CONTEXT; + (*CC->API.EndList)(CC); +} + + + + +void APIENTRY _mesa_EvalCoord1d( GLdouble u ) +{ + GET_CONTEXT; + (*CC->API.EvalCoord1f)( CC, (GLfloat) u ); +} + + +void APIENTRY _mesa_EvalCoord1f( GLfloat u ) +{ + GET_CONTEXT; + (*CC->API.EvalCoord1f)( CC, u ); +} + + +void APIENTRY _mesa_EvalCoord1dv( const GLdouble *u ) +{ + GET_CONTEXT; + (*CC->API.EvalCoord1f)( CC, (GLfloat) *u ); +} + + +void APIENTRY _mesa_EvalCoord1fv( const GLfloat *u ) +{ + GET_CONTEXT; + (*CC->API.EvalCoord1f)( CC, (GLfloat) *u ); +} + + +void APIENTRY _mesa_EvalCoord2d( GLdouble u, GLdouble v ) +{ + GET_CONTEXT; + (*CC->API.EvalCoord2f)( CC, (GLfloat) u, (GLfloat) v ); +} + + +void APIENTRY _mesa_EvalCoord2f( GLfloat u, GLfloat v ) +{ + GET_CONTEXT; + (*CC->API.EvalCoord2f)( CC, u, v ); +} + + +void APIENTRY _mesa_EvalCoord2dv( const GLdouble *u ) +{ + GET_CONTEXT; + (*CC->API.EvalCoord2f)( CC, (GLfloat) u[0], (GLfloat) u[1] ); +} + + +void APIENTRY _mesa_EvalCoord2fv( const GLfloat *u ) +{ + GET_CONTEXT; + (*CC->API.EvalCoord2f)( CC, u[0], u[1] ); +} + + +void APIENTRY _mesa_EvalPoint1( GLint i ) +{ + GET_CONTEXT; + (*CC->API.EvalPoint1)( CC, i ); +} + + +void APIENTRY _mesa_EvalPoint2( GLint i, GLint j ) +{ + GET_CONTEXT; + (*CC->API.EvalPoint2)( CC, i, j ); +} + + +void APIENTRY _mesa_EvalMesh1( GLenum mode, GLint i1, GLint i2 ) +{ + GET_CONTEXT; + (*CC->API.EvalMesh1)( CC, mode, i1, i2 ); +} + + +void APIENTRY _mesa_EdgeFlag( GLboolean flag ) +{ + GET_CONTEXT; + (*CC->API.EdgeFlag)(CC, flag); +} + + +void APIENTRY _mesa_EdgeFlagv( const GLboolean *flag ) +{ + GET_CONTEXT; + (*CC->API.EdgeFlag)(CC, *flag); +} + + +void APIENTRY _mesa_EdgeFlagPointer( GLsizei stride, const GLboolean *ptr ) +{ + GET_CONTEXT; + (*CC->API.EdgeFlagPointer)(CC, stride, ptr); +} + + +void APIENTRY _mesa_EvalMesh2( GLenum mode, GLint i1, GLint i2, GLint j1, GLint j2 ) +{ + GET_CONTEXT; + (*CC->API.EvalMesh2)( CC, mode, i1, i2, j1, j2 ); +} + + +void APIENTRY _mesa_FeedbackBuffer( GLsizei size, GLenum type, GLfloat *buffer ) +{ + GET_CONTEXT; + (*CC->API.FeedbackBuffer)(CC, size, type, buffer); +} + + +void APIENTRY _mesa_Finish( void ) +{ + GET_CONTEXT; + (*CC->API.Finish)(CC); +} + + +void APIENTRY _mesa_Flush( void ) +{ + GET_CONTEXT; + (*CC->API.Flush)(CC); +} + + +void APIENTRY _mesa_Fogf( GLenum pname, GLfloat param ) +{ + GET_CONTEXT; + (*CC->API.Fogfv)(CC, pname, ¶m); +} + + +void APIENTRY _mesa_Fogi( GLenum pname, GLint param ) +{ + GLfloat fparam = (GLfloat) param; + GET_CONTEXT; + (*CC->API.Fogfv)(CC, pname, &fparam); +} + + +void APIENTRY _mesa_Fogfv( GLenum pname, const GLfloat *params ) +{ + GET_CONTEXT; + (*CC->API.Fogfv)(CC, pname, params); +} + + +void APIENTRY _mesa_Fogiv( GLenum pname, const GLint *params ) +{ + GLfloat p[4]; + GET_CONTEXT; + + switch (pname) { + case GL_FOG_MODE: + case GL_FOG_DENSITY: + case GL_FOG_START: + case GL_FOG_END: + case GL_FOG_INDEX: + p[0] = (GLfloat) *params; + break; + case GL_FOG_COLOR: + p[0] = INT_TO_FLOAT( params[0] ); + p[1] = INT_TO_FLOAT( params[1] ); + p[2] = INT_TO_FLOAT( params[2] ); + p[3] = INT_TO_FLOAT( params[3] ); + break; + default: + /* Error will be caught later in gl_Fogfv */ + ; + } + (*CC->API.Fogfv)( CC, pname, p ); +} + + + +void APIENTRY _mesa_FrontFace( GLenum mode ) +{ + GET_CONTEXT; + (*CC->API.FrontFace)(CC, mode); +} + + +void APIENTRY _mesa_Frustum( GLdouble left, GLdouble right, + GLdouble bottom, GLdouble top, + GLdouble nearval, GLdouble farval ) +{ + GET_CONTEXT; + (*CC->API.Frustum)(CC, left, right, bottom, top, nearval, farval); +} + + +GLuint APIENTRY _mesa_GenLists( GLsizei range ) +{ + GET_CONTEXT; + return (*CC->API.GenLists)(CC, range); +} + + +void APIENTRY _mesa_GenTextures( GLsizei n, GLuint *textures ) +{ + GET_CONTEXT; + (*CC->API.GenTextures)(CC, n, textures); +} + + +void APIENTRY _mesa_GetBooleanv( GLenum pname, GLboolean *params ) +{ + GET_CONTEXT; + (*CC->API.GetBooleanv)(CC, pname, params); +} + + +void APIENTRY _mesa_GetClipPlane( GLenum plane, GLdouble *equation ) +{ + GET_CONTEXT; + (*CC->API.GetClipPlane)(CC, plane, equation); +} + +void APIENTRY _mesa_GetDoublev( GLenum pname, GLdouble *params ) +{ + GET_CONTEXT; + (*CC->API.GetDoublev)(CC, pname, params); +} + + +GLenum APIENTRY _mesa_GetError( void ) +{ + GET_CONTEXT; + if (!CC) { + /* No current context */ + return GL_NO_ERROR; + } + return (*CC->API.GetError)(CC); +} + + +void APIENTRY _mesa_GetFloatv( GLenum pname, GLfloat *params ) +{ + GET_CONTEXT; + (*CC->API.GetFloatv)(CC, pname, params); +} + + +void APIENTRY _mesa_GetIntegerv( GLenum pname, GLint *params ) +{ + GET_CONTEXT; + (*CC->API.GetIntegerv)(CC, pname, params); +} + + +void APIENTRY _mesa_GetLightfv( GLenum light, GLenum pname, GLfloat *params ) +{ + GET_CONTEXT; + (*CC->API.GetLightfv)(CC, light, pname, params); +} + + +void APIENTRY _mesa_GetLightiv( GLenum light, GLenum pname, GLint *params ) +{ + GET_CONTEXT; + (*CC->API.GetLightiv)(CC, light, pname, params); +} + + +void APIENTRY _mesa_GetMapdv( GLenum target, GLenum query, GLdouble *v ) +{ + GET_CONTEXT; + (*CC->API.GetMapdv)( CC, target, query, v ); +} + + +void APIENTRY _mesa_GetMapfv( GLenum target, GLenum query, GLfloat *v ) +{ + GET_CONTEXT; + (*CC->API.GetMapfv)( CC, target, query, v ); +} + + +void APIENTRY _mesa_GetMapiv( GLenum target, GLenum query, GLint *v ) +{ + GET_CONTEXT; + (*CC->API.GetMapiv)( CC, target, query, v ); +} + + +void APIENTRY _mesa_GetMaterialfv( GLenum face, GLenum pname, GLfloat *params ) +{ + GET_CONTEXT; + (*CC->API.GetMaterialfv)(CC, face, pname, params); +} + + +void APIENTRY _mesa_GetMaterialiv( GLenum face, GLenum pname, GLint *params ) +{ + GET_CONTEXT; + (*CC->API.GetMaterialiv)(CC, face, pname, params); +} + + +void APIENTRY _mesa_GetPixelMapfv( GLenum map, GLfloat *values ) +{ + GET_CONTEXT; + (*CC->API.GetPixelMapfv)(CC, map, values); +} + + +void APIENTRY _mesa_GetPixelMapuiv( GLenum map, GLuint *values ) +{ + GET_CONTEXT; + (*CC->API.GetPixelMapuiv)(CC, map, values); +} + + +void APIENTRY _mesa_GetPixelMapusv( GLenum map, GLushort *values ) +{ + GET_CONTEXT; + (*CC->API.GetPixelMapusv)(CC, map, values); +} + + +void APIENTRY _mesa_GetPointerv( GLenum pname, GLvoid **params ) +{ + GET_CONTEXT; + (*CC->API.GetPointerv)(CC, pname, params); +} + + +void APIENTRY _mesa_GetPolygonStipple( GLubyte *mask ) +{ + GET_CONTEXT; + (*CC->API.GetPolygonStipple)(CC, mask); +} + + +const GLubyte * APIENTRY _mesa_GetString( GLenum name ) +{ + GET_CONTEXT; + return (*CC->API.GetString)(CC, name); +} + + + +void APIENTRY _mesa_GetTexEnvfv( GLenum target, GLenum pname, GLfloat *params ) +{ + GET_CONTEXT; + (*CC->API.GetTexEnvfv)(CC, target, pname, params); +} + + +void APIENTRY _mesa_GetTexEnviv( GLenum target, GLenum pname, GLint *params ) +{ + GET_CONTEXT; + (*CC->API.GetTexEnviv)(CC, target, pname, params); +} + + +void APIENTRY _mesa_GetTexGeniv( GLenum coord, GLenum pname, GLint *params ) +{ + GET_CONTEXT; + (*CC->API.GetTexGeniv)(CC, coord, pname, params); +} + + +void APIENTRY _mesa_GetTexGendv( GLenum coord, GLenum pname, GLdouble *params ) +{ + GET_CONTEXT; + (*CC->API.GetTexGendv)(CC, coord, pname, params); +} + + +void APIENTRY _mesa_GetTexGenfv( GLenum coord, GLenum pname, GLfloat *params ) +{ + GET_CONTEXT; + (*CC->API.GetTexGenfv)(CC, coord, pname, params); +} + + + +void APIENTRY _mesa_GetTexImage( GLenum target, GLint level, GLenum format, + GLenum type, GLvoid *pixels ) +{ + GET_CONTEXT; + (*CC->API.GetTexImage)(CC, target, level, format, type, pixels); +} + + +void APIENTRY _mesa_GetTexLevelParameterfv( GLenum target, GLint level, + GLenum pname, GLfloat *params ) +{ + GET_CONTEXT; + (*CC->API.GetTexLevelParameterfv)(CC, target, level, pname, params); +} + + +void APIENTRY _mesa_GetTexLevelParameteriv( GLenum target, GLint level, + GLenum pname, GLint *params ) +{ + GET_CONTEXT; + (*CC->API.GetTexLevelParameteriv)(CC, target, level, pname, params); +} + + + + +void APIENTRY _mesa_GetTexParameterfv( GLenum target, GLenum pname, GLfloat *params) +{ + GET_CONTEXT; + (*CC->API.GetTexParameterfv)(CC, target, pname, params); +} + + +void APIENTRY _mesa_GetTexParameteriv( GLenum target, GLenum pname, GLint *params ) +{ + GET_CONTEXT; + (*CC->API.GetTexParameteriv)(CC, target, pname, params); +} + + +void APIENTRY _mesa_Hint( GLenum target, GLenum mode ) +{ + GET_CONTEXT; + (*CC->API.Hint)(CC, target, mode); +} + + +void APIENTRY _mesa_Indexd( GLdouble c ) +{ + GET_CONTEXT; + (*CC->API.Indexf)( CC, (GLfloat) c ); +} + + +void APIENTRY _mesa_Indexf( GLfloat c ) +{ + GET_CONTEXT; + (*CC->API.Indexf)( CC, c ); +} + + +void APIENTRY _mesa_Indexi( GLint c ) +{ + GET_CONTEXT; + (*CC->API.Indexi)( CC, c ); +} + + +void APIENTRY _mesa_Indexs( GLshort c ) +{ + GET_CONTEXT; + (*CC->API.Indexi)( CC, (GLint) c ); +} + + +#ifdef GL_VERSION_1_1 +void APIENTRY _mesa_Indexub( GLubyte c ) +{ + GET_CONTEXT; + (*CC->API.Indexi)( CC, (GLint) c ); +} +#endif + + +void APIENTRY _mesa_Indexdv( const GLdouble *c ) +{ + GET_CONTEXT; + (*CC->API.Indexf)( CC, (GLfloat) *c ); +} + + +void APIENTRY _mesa_Indexfv( const GLfloat *c ) +{ + GET_CONTEXT; + (*CC->API.Indexf)( CC, *c ); +} + + +void APIENTRY _mesa_Indexiv( const GLint *c ) +{ + GET_CONTEXT; + (*CC->API.Indexi)( CC, *c ); +} + + +void APIENTRY _mesa_Indexsv( const GLshort *c ) +{ + GET_CONTEXT; + (*CC->API.Indexi)( CC, (GLint) *c ); +} + + +#ifdef GL_VERSION_1_1 +void APIENTRY _mesa_Indexubv( const GLubyte *c ) +{ + GET_CONTEXT; + (*CC->API.Indexi)( CC, (GLint) *c ); +} +#endif + + +void APIENTRY _mesa_IndexMask( GLuint mask ) +{ + GET_CONTEXT; + (*CC->API.IndexMask)(CC, mask); +} + + +void APIENTRY _mesa_IndexPointer( GLenum type, GLsizei stride, const GLvoid *ptr ) +{ + GET_CONTEXT; + (*CC->API.IndexPointer)(CC, type, stride, ptr); +} + + +void APIENTRY _mesa_InterleavedArrays( GLenum format, GLsizei stride, + const GLvoid *pointer ) +{ + GET_CONTEXT; + (*CC->API.InterleavedArrays)( CC, format, stride, pointer ); +} + + +void APIENTRY _mesa_InitNames( void ) +{ + GET_CONTEXT; + (*CC->API.InitNames)(CC); +} + + +GLboolean APIENTRY _mesa_IsList( GLuint list ) +{ + GET_CONTEXT; + return (*CC->API.IsList)(CC, list); +} + + +GLboolean APIENTRY _mesa_IsTexture( GLuint texture ) +{ + GET_CONTEXT; + return (*CC->API.IsTexture)(CC, texture); +} + + +void APIENTRY _mesa_Lightf( GLenum light, GLenum pname, GLfloat param ) +{ + GET_CONTEXT; + (*CC->API.Lightfv)( CC, light, pname, ¶m, 1 ); +} + + + +void APIENTRY _mesa_Lighti( GLenum light, GLenum pname, GLint param ) +{ + GLfloat fparam = (GLfloat) param; + GET_CONTEXT; + (*CC->API.Lightfv)( CC, light, pname, &fparam, 1 ); +} + + + +void APIENTRY _mesa_Lightfv( GLenum light, GLenum pname, const GLfloat *params ) +{ + GET_CONTEXT; + (*CC->API.Lightfv)( CC, light, pname, params, 4 ); +} + + + +void APIENTRY _mesa_Lightiv( GLenum light, GLenum pname, const GLint *params ) +{ + GLfloat fparam[4]; + GET_CONTEXT; + + switch (pname) { + case GL_AMBIENT: + case GL_DIFFUSE: + case GL_SPECULAR: + fparam[0] = INT_TO_FLOAT( params[0] ); + fparam[1] = INT_TO_FLOAT( params[1] ); + fparam[2] = INT_TO_FLOAT( params[2] ); + fparam[3] = INT_TO_FLOAT( params[3] ); + break; + case GL_POSITION: + fparam[0] = (GLfloat) params[0]; + fparam[1] = (GLfloat) params[1]; + fparam[2] = (GLfloat) params[2]; + fparam[3] = (GLfloat) params[3]; + break; + case GL_SPOT_DIRECTION: + fparam[0] = (GLfloat) params[0]; + fparam[1] = (GLfloat) params[1]; + fparam[2] = (GLfloat) params[2]; + break; + case GL_SPOT_EXPONENT: + case GL_SPOT_CUTOFF: + case GL_CONSTANT_ATTENUATION: + case GL_LINEAR_ATTENUATION: + case GL_QUADRATIC_ATTENUATION: + fparam[0] = (GLfloat) params[0]; + break; + default: + /* error will be caught later in gl_Lightfv */ + ; + } + (*CC->API.Lightfv)( CC, light, pname, fparam, 4 ); +} + + + +void APIENTRY _mesa_LightModelf( GLenum pname, GLfloat param ) +{ + GET_CONTEXT; + (*CC->API.LightModelfv)( CC, pname, ¶m ); +} + + +void APIENTRY _mesa_LightModeli( GLenum pname, GLint param ) +{ + GLfloat fparam[4]; + GET_CONTEXT; + fparam[0] = (GLfloat) param; + (*CC->API.LightModelfv)( CC, pname, fparam ); +} + + +void APIENTRY _mesa_LightModelfv( GLenum pname, const GLfloat *params ) +{ + GET_CONTEXT; + (*CC->API.LightModelfv)( CC, pname, params ); +} + + +void APIENTRY _mesa_LightModeliv( GLenum pname, const GLint *params ) +{ + GLfloat fparam[4]; + GET_CONTEXT; + + switch (pname) { + case GL_LIGHT_MODEL_AMBIENT: + fparam[0] = INT_TO_FLOAT( params[0] ); + fparam[1] = INT_TO_FLOAT( params[1] ); + fparam[2] = INT_TO_FLOAT( params[2] ); + fparam[3] = INT_TO_FLOAT( params[3] ); + break; + case GL_LIGHT_MODEL_LOCAL_VIEWER: + case GL_LIGHT_MODEL_TWO_SIDE: + fparam[0] = (GLfloat) params[0]; + break; + default: + /* Error will be caught later in gl_LightModelfv */ + ; + } + (*CC->API.LightModelfv)( CC, pname, fparam ); +} + + +void APIENTRY _mesa_LineWidth( GLfloat width ) +{ + GET_CONTEXT; + (*CC->API.LineWidth)(CC, width); +} + + +void APIENTRY _mesa_LineStipple( GLint factor, GLushort pattern ) +{ + GET_CONTEXT; + (*CC->API.LineStipple)(CC, factor, pattern); +} + + +void APIENTRY _mesa_ListBase( GLuint base ) +{ + GET_CONTEXT; + (*CC->API.ListBase)(CC, base); +} + + +void APIENTRY _mesa_LoadIdentity( void ) +{ + GET_CONTEXT; + (*CC->API.LoadIdentity)( CC ); +} + + +void APIENTRY _mesa_LoadMatrixd( const GLdouble *m ) +{ + GLfloat fm[16]; + GLuint i; + GET_CONTEXT; + + for (i=0;i<16;i++) { + fm[i] = (GLfloat) m[i]; + } + + (*CC->API.LoadMatrixf)( CC, fm ); +} + + +void APIENTRY _mesa_LoadMatrixf( const GLfloat *m ) +{ + GET_CONTEXT; + (*CC->API.LoadMatrixf)( CC, m ); +} + + +void APIENTRY _mesa_LoadName( GLuint name ) +{ + GET_CONTEXT; + (*CC->API.LoadName)(CC, name); +} + + +void APIENTRY _mesa_LogicOp( GLenum opcode ) +{ + GET_CONTEXT; + (*CC->API.LogicOp)(CC, opcode); +} + + + +void APIENTRY _mesa_Map1d( GLenum target, GLdouble u1, GLdouble u2, GLint stride, + GLint order, const GLdouble *points ) +{ + GLfloat *pnts; + GLboolean retain; + GET_CONTEXT; + + pnts = gl_copy_map_points1d( target, stride, order, points ); + retain = CC->CompileFlag; + (*CC->API.Map1f)( CC, target, u1, u2, stride, order, pnts, retain ); +} + + +void APIENTRY _mesa_Map1f( GLenum target, GLfloat u1, GLfloat u2, GLint stride, + GLint order, const GLfloat *points ) +{ + GLfloat *pnts; + GLboolean retain; + GET_CONTEXT; + + pnts = gl_copy_map_points1f( target, stride, order, points ); + retain = CC->CompileFlag; + (*CC->API.Map1f)( CC, target, u1, u2, stride, order, pnts, retain ); +} + + +void APIENTRY _mesa_Map2d( GLenum target, + GLdouble u1, GLdouble u2, GLint ustride, GLint uorder, + GLdouble v1, GLdouble v2, GLint vstride, GLint vorder, + const GLdouble *points ) +{ + GLfloat *pnts; + GLboolean retain; + GET_CONTEXT; + + pnts = gl_copy_map_points2d( target, ustride, uorder, + vstride, vorder, points ); + retain = CC->CompileFlag; + (*CC->API.Map2f)( CC, target, u1, u2, ustride, uorder, + v1, v2, vstride, vorder, pnts, retain ); +} + + +void APIENTRY _mesa_Map2f( GLenum target, + GLfloat u1, GLfloat u2, GLint ustride, GLint uorder, + GLfloat v1, GLfloat v2, GLint vstride, GLint vorder, + const GLfloat *points ) +{ + GLfloat *pnts; + GLboolean retain; + GET_CONTEXT; + + pnts = gl_copy_map_points2f( target, ustride, uorder, + vstride, vorder, points ); + retain = CC->CompileFlag; + (*CC->API.Map2f)( CC, target, u1, u2, ustride, uorder, + v1, v2, vstride, vorder, pnts, retain ); +} + + +void APIENTRY _mesa_MapGrid1d( GLint un, GLdouble u1, GLdouble u2 ) +{ + GET_CONTEXT; + (*CC->API.MapGrid1f)( CC, un, (GLfloat) u1, (GLfloat) u2 ); +} + + +void APIENTRY _mesa_MapGrid1f( GLint un, GLfloat u1, GLfloat u2 ) +{ + GET_CONTEXT; + (*CC->API.MapGrid1f)( CC, un, u1, u2 ); +} + + +void APIENTRY _mesa_MapGrid2d( GLint un, GLdouble u1, GLdouble u2, + GLint vn, GLdouble v1, GLdouble v2 ) +{ + GET_CONTEXT; + (*CC->API.MapGrid2f)( CC, un, (GLfloat) u1, (GLfloat) u2, + vn, (GLfloat) v1, (GLfloat) v2 ); +} + + +void APIENTRY _mesa_MapGrid2f( GLint un, GLfloat u1, GLfloat u2, + GLint vn, GLfloat v1, GLfloat v2 ) +{ + GET_CONTEXT; + (*CC->API.MapGrid2f)( CC, un, u1, u2, vn, v1, v2 ); +} + + +void APIENTRY _mesa_Materialf( GLenum face, GLenum pname, GLfloat param ) +{ + GET_CONTEXT; + (*CC->API.Materialfv)( CC, face, pname, ¶m ); +} + + + +void APIENTRY _mesa_Materiali( GLenum face, GLenum pname, GLint param ) +{ + GLfloat fparam[4]; + GET_CONTEXT; + fparam[0] = (GLfloat) param; + (*CC->API.Materialfv)( CC, face, pname, fparam ); +} + + +void APIENTRY _mesa_Materialfv( GLenum face, GLenum pname, const GLfloat *params ) +{ + GET_CONTEXT; + (*CC->API.Materialfv)( CC, face, pname, params ); +} + + +void APIENTRY _mesa_Materialiv( GLenum face, GLenum pname, const GLint *params ) +{ + GLfloat fparam[4]; + GET_CONTEXT; + switch (pname) { + case GL_AMBIENT: + case GL_DIFFUSE: + case GL_SPECULAR: + case GL_EMISSION: + case GL_AMBIENT_AND_DIFFUSE: + fparam[0] = INT_TO_FLOAT( params[0] ); + fparam[1] = INT_TO_FLOAT( params[1] ); + fparam[2] = INT_TO_FLOAT( params[2] ); + fparam[3] = INT_TO_FLOAT( params[3] ); + break; + case GL_SHININESS: + fparam[0] = (GLfloat) params[0]; + break; + case GL_COLOR_INDEXES: + fparam[0] = (GLfloat) params[0]; + fparam[1] = (GLfloat) params[1]; + fparam[2] = (GLfloat) params[2]; + break; + default: + /* Error will be caught later in gl_Materialfv */ + ; + } + (*CC->API.Materialfv)( CC, face, pname, fparam ); +} + + +void APIENTRY _mesa_MatrixMode( GLenum mode ) +{ + GET_CONTEXT; + (*CC->API.MatrixMode)( CC, mode ); +} + + +void APIENTRY _mesa_MultMatrixd( const GLdouble *m ) +{ + GLfloat fm[16]; + GLuint i; + GET_CONTEXT; + + for (i=0;i<16;i++) { + fm[i] = (GLfloat) m[i]; + } + + (*CC->API.MultMatrixf)( CC, fm ); +} + + +void APIENTRY _mesa_MultMatrixf( const GLfloat *m ) +{ + GET_CONTEXT; + (*CC->API.MultMatrixf)( CC, m ); +} + + +void APIENTRY _mesa_NewList( GLuint list, GLenum mode ) +{ + GET_CONTEXT; + (*CC->API.NewList)(CC, list, mode); +} + +void APIENTRY _mesa_Normal3b( GLbyte nx, GLbyte ny, GLbyte nz ) +{ + GET_CONTEXT; + (*CC->API.Normal3f)( CC, BYTE_TO_FLOAT(nx), + BYTE_TO_FLOAT(ny), BYTE_TO_FLOAT(nz) ); +} + + +void APIENTRY _mesa_Normal3d( GLdouble nx, GLdouble ny, GLdouble nz ) +{ + GLfloat fx, fy, fz; + GET_CONTEXT; + if (ABSD(nx)<0.00001) fx = 0.0F; else fx = nx; + if (ABSD(ny)<0.00001) fy = 0.0F; else fy = ny; + if (ABSD(nz)<0.00001) fz = 0.0F; else fz = nz; + (*CC->API.Normal3f)( CC, fx, fy, fz ); +} + + +void APIENTRY _mesa_Normal3f( GLfloat nx, GLfloat ny, GLfloat nz ) +{ + GET_CONTEXT; +#ifdef SHORTCUT + if (CC->CompileFlag) { + (*CC->Save.Normal3f)( CC, nx, ny, nz ); + } + else { + /* Execute */ + CC->Current.Normal[0] = nx; + CC->Current.Normal[1] = ny; + CC->Current.Normal[2] = nz; + CC->VB->MonoNormal = GL_FALSE; + } +#else + (*CC->API.Normal3f)( CC, nx, ny, nz ); +#endif +} + + +void APIENTRY _mesa_Normal3i( GLint nx, GLint ny, GLint nz ) +{ + GET_CONTEXT; + (*CC->API.Normal3f)( CC, INT_TO_FLOAT(nx), + INT_TO_FLOAT(ny), INT_TO_FLOAT(nz) ); +} + + +void APIENTRY _mesa_Normal3s( GLshort nx, GLshort ny, GLshort nz ) +{ + GET_CONTEXT; + (*CC->API.Normal3f)( CC, SHORT_TO_FLOAT(nx), + SHORT_TO_FLOAT(ny), SHORT_TO_FLOAT(nz) ); +} + + +void APIENTRY _mesa_Normal3bv( const GLbyte *v ) +{ + GET_CONTEXT; + (*CC->API.Normal3f)( CC, BYTE_TO_FLOAT(v[0]), + BYTE_TO_FLOAT(v[1]), BYTE_TO_FLOAT(v[2]) ); +} + + +void APIENTRY _mesa_Normal3dv( const GLdouble *v ) +{ + GLfloat fx, fy, fz; + GET_CONTEXT; + if (ABSD(v[0])<0.00001) fx = 0.0F; else fx = v[0]; + if (ABSD(v[1])<0.00001) fy = 0.0F; else fy = v[1]; + if (ABSD(v[2])<0.00001) fz = 0.0F; else fz = v[2]; + (*CC->API.Normal3f)( CC, fx, fy, fz ); +} + + +void APIENTRY _mesa_Normal3fv( const GLfloat *v ) +{ + GET_CONTEXT; +#ifdef SHORTCUT + if (CC->CompileFlag) { + (*CC->Save.Normal3fv)( CC, v ); + } + else { + /* Execute */ + GLfloat *n = CC->Current.Normal; + n[0] = v[0]; + n[1] = v[1]; + n[2] = v[2]; + CC->VB->MonoNormal = GL_FALSE; + } +#else + (*CC->API.Normal3fv)( CC, v ); +#endif +} + + +void APIENTRY _mesa_Normal3iv( const GLint *v ) +{ + GET_CONTEXT; + (*CC->API.Normal3f)( CC, INT_TO_FLOAT(v[0]), + INT_TO_FLOAT(v[1]), INT_TO_FLOAT(v[2]) ); +} + + +void APIENTRY _mesa_Normal3sv( const GLshort *v ) +{ + GET_CONTEXT; + (*CC->API.Normal3f)( CC, SHORT_TO_FLOAT(v[0]), + SHORT_TO_FLOAT(v[1]), SHORT_TO_FLOAT(v[2]) ); +} + + +void APIENTRY _mesa_NormalPointer( GLenum type, GLsizei stride, const GLvoid *ptr ) +{ + GET_CONTEXT; + (*CC->API.NormalPointer)(CC, type, stride, ptr); +} +void APIENTRY _mesa_Ortho( GLdouble left, GLdouble right, + GLdouble bottom, GLdouble top, + GLdouble nearval, GLdouble farval ) +{ + GET_CONTEXT; + (*CC->API.Ortho)(CC, left, right, bottom, top, nearval, farval); +} + + +void APIENTRY _mesa_PassThrough( GLfloat token ) +{ + GET_CONTEXT; + (*CC->API.PassThrough)(CC, token); +} + + +void APIENTRY _mesa_PixelMapfv( GLenum map, GLint mapsize, const GLfloat *values ) +{ + GET_CONTEXT; + (*CC->API.PixelMapfv)( CC, map, mapsize, values ); +} + + +void APIENTRY _mesa_PixelMapuiv( GLenum map, GLint mapsize, const GLuint *values ) +{ + GLfloat fvalues[MAX_PIXEL_MAP_TABLE]; + GLuint i; + GET_CONTEXT; + + if (map==GL_PIXEL_MAP_I_TO_I || map==GL_PIXEL_MAP_S_TO_S) { + for (i=0;iAPI.PixelMapfv)( CC, map, mapsize, fvalues ); +} + + + +void APIENTRY _mesa_PixelMapusv( GLenum map, GLint mapsize, const GLushort *values ) +{ + GLfloat fvalues[MAX_PIXEL_MAP_TABLE]; + GLuint i; + GET_CONTEXT; + + if (map==GL_PIXEL_MAP_I_TO_I || map==GL_PIXEL_MAP_S_TO_S) { + for (i=0;iAPI.PixelMapfv)( CC, map, mapsize, fvalues ); +} + + +void APIENTRY _mesa_PixelStoref( GLenum pname, GLfloat param ) +{ + GET_CONTEXT; + (*CC->API.PixelStorei)( CC, pname, (GLint) param ); +} + + +void APIENTRY _mesa_PixelStorei( GLenum pname, GLint param ) +{ + GET_CONTEXT; + (*CC->API.PixelStorei)( CC, pname, param ); +} + + +void APIENTRY _mesa_PixelTransferf( GLenum pname, GLfloat param ) +{ + GET_CONTEXT; + (*CC->API.PixelTransferf)(CC, pname, param); +} + + +void APIENTRY _mesa_PixelTransferi( GLenum pname, GLint param ) +{ + GET_CONTEXT; + (*CC->API.PixelTransferf)(CC, pname, (GLfloat) param); +} + + +void APIENTRY _mesa_PixelZoom( GLfloat xfactor, GLfloat yfactor ) +{ + GET_CONTEXT; + (*CC->API.PixelZoom)(CC, xfactor, yfactor); +} + + +void APIENTRY _mesa_PointSize( GLfloat size ) +{ + GET_CONTEXT; + (*CC->API.PointSize)(CC, size); +} + + +void APIENTRY _mesa_PolygonMode( GLenum face, GLenum mode ) +{ + GET_CONTEXT; + (*CC->API.PolygonMode)(CC, face, mode); +} + + +void APIENTRY _mesa_PolygonOffset( GLfloat factor, GLfloat units ) +{ + GET_CONTEXT; + (*CC->API.PolygonOffset)( CC, factor, units ); +} + +void APIENTRY _mesa_PolygonStipple( const GLubyte *mask ) +{ + GET_CONTEXT; + (*CC->API.PolygonStipple)(CC, mask); +} + + +void APIENTRY _mesa_PopAttrib( void ) +{ + GET_CONTEXT; + (*CC->API.PopAttrib)(CC); +} + + +void APIENTRY _mesa_PopClientAttrib( void ) +{ + GET_CONTEXT; + (*CC->API.PopClientAttrib)(CC); +} + + +void APIENTRY _mesa_PopMatrix( void ) +{ + GET_CONTEXT; + (*CC->API.PopMatrix)( CC ); +} + + +void APIENTRY _mesa_PopName( void ) +{ + GET_CONTEXT; + (*CC->API.PopName)(CC); +} + + +void APIENTRY _mesa_PrioritizeTextures( GLsizei n, const GLuint *textures, + const GLclampf *priorities ) +{ + GET_CONTEXT; + (*CC->API.PrioritizeTextures)(CC, n, textures, priorities); +} + + +void APIENTRY _mesa_PushMatrix( void ) +{ + GET_CONTEXT; + (*CC->API.PushMatrix)( CC ); +} + + +void APIENTRY _mesa_RasterPos2d( GLdouble x, GLdouble y ) +{ + GET_CONTEXT; + (*CC->API.RasterPos4f)( CC, (GLfloat) x, (GLfloat) y, 0.0F, 1.0F ); +} + + +void APIENTRY _mesa_RasterPos2f( GLfloat x, GLfloat y ) +{ + GET_CONTEXT; + (*CC->API.RasterPos4f)( CC, (GLfloat) x, (GLfloat) y, 0.0F, 1.0F ); +} + + +void APIENTRY _mesa_RasterPos2i( GLint x, GLint y ) +{ + GET_CONTEXT; + (*CC->API.RasterPos4f)( CC, (GLfloat) x, (GLfloat) y, 0.0F, 1.0F ); +} + + +void APIENTRY _mesa_RasterPos2s( GLshort x, GLshort y ) +{ + GET_CONTEXT; + (*CC->API.RasterPos4f)( CC, (GLfloat) x, (GLfloat) y, 0.0F, 1.0F ); +} + + +void APIENTRY _mesa_RasterPos3d( GLdouble x, GLdouble y, GLdouble z ) +{ + GET_CONTEXT; + (*CC->API.RasterPos4f)( CC, (GLfloat) x, (GLfloat) y, (GLfloat) z, 1.0F ); +} + + +void APIENTRY _mesa_RasterPos3f( GLfloat x, GLfloat y, GLfloat z ) +{ + GET_CONTEXT; + (*CC->API.RasterPos4f)( CC, (GLfloat) x, (GLfloat) y, (GLfloat) z, 1.0F ); +} + + +void APIENTRY _mesa_RasterPos3i( GLint x, GLint y, GLint z ) +{ + GET_CONTEXT; + (*CC->API.RasterPos4f)( CC, (GLfloat) x, (GLfloat) y, (GLfloat) z, 1.0F ); +} + + +void APIENTRY _mesa_RasterPos3s( GLshort x, GLshort y, GLshort z ) +{ + GET_CONTEXT; + (*CC->API.RasterPos4f)( CC, (GLfloat) x, (GLfloat) y, (GLfloat) z, 1.0F ); +} + + +void APIENTRY _mesa_RasterPos4d( GLdouble x, GLdouble y, GLdouble z, GLdouble w ) +{ + GET_CONTEXT; + (*CC->API.RasterPos4f)( CC, (GLfloat) x, (GLfloat) y, + (GLfloat) z, (GLfloat) w ); +} + + +void APIENTRY _mesa_RasterPos4f( GLfloat x, GLfloat y, GLfloat z, GLfloat w ) +{ + GET_CONTEXT; + (*CC->API.RasterPos4f)( CC, x, y, z, w ); +} + + +void APIENTRY _mesa_RasterPos4i( GLint x, GLint y, GLint z, GLint w ) +{ + GET_CONTEXT; + (*CC->API.RasterPos4f)( CC, (GLfloat) x, (GLfloat) y, + (GLfloat) z, (GLfloat) w ); +} + + +void APIENTRY _mesa_RasterPos4s( GLshort x, GLshort y, GLshort z, GLshort w ) +{ + GET_CONTEXT; + (*CC->API.RasterPos4f)( CC, (GLfloat) x, (GLfloat) y, + (GLfloat) z, (GLfloat) w ); +} + + +void APIENTRY _mesa_RasterPos2dv( const GLdouble *v ) +{ + GET_CONTEXT; + (*CC->API.RasterPos4f)( CC, (GLfloat) v[0], (GLfloat) v[1], 0.0F, 1.0F ); +} + + +void APIENTRY _mesa_RasterPos2fv( const GLfloat *v ) +{ + GET_CONTEXT; + (*CC->API.RasterPos4f)( CC, (GLfloat) v[0], (GLfloat) v[1], 0.0F, 1.0F ); +} + + +void APIENTRY _mesa_RasterPos2iv( const GLint *v ) +{ + GET_CONTEXT; + (*CC->API.RasterPos4f)( CC, (GLfloat) v[0], (GLfloat) v[1], 0.0F, 1.0F ); +} + + +void APIENTRY _mesa_RasterPos2sv( const GLshort *v ) +{ + GET_CONTEXT; + (*CC->API.RasterPos4f)( CC, (GLfloat) v[0], (GLfloat) v[1], 0.0F, 1.0F ); +} + + +/*** 3 element vector ***/ + +void APIENTRY _mesa_RasterPos3dv( const GLdouble *v ) +{ + GET_CONTEXT; + (*CC->API.RasterPos4f)( CC, (GLfloat) v[0], (GLfloat) v[1], + (GLfloat) v[2], 1.0F ); +} + + +void APIENTRY _mesa_RasterPos3fv( const GLfloat *v ) +{ + GET_CONTEXT; + (*CC->API.RasterPos4f)( CC, (GLfloat) v[0], (GLfloat) v[1], + (GLfloat) v[2], 1.0F ); +} + + +void APIENTRY _mesa_RasterPos3iv( const GLint *v ) +{ + GET_CONTEXT; + (*CC->API.RasterPos4f)( CC, (GLfloat) v[0], (GLfloat) v[1], + (GLfloat) v[2], 1.0F ); +} + + +void APIENTRY _mesa_RasterPos3sv( const GLshort *v ) +{ + GET_CONTEXT; + (*CC->API.RasterPos4f)( CC, (GLfloat) v[0], (GLfloat) v[1], + (GLfloat) v[2], 1.0F ); +} + + +void APIENTRY _mesa_RasterPos4dv( const GLdouble *v ) +{ + GET_CONTEXT; + (*CC->API.RasterPos4f)( CC, (GLfloat) v[0], (GLfloat) v[1], + (GLfloat) v[2], (GLfloat) v[3] ); +} + + +void APIENTRY _mesa_RasterPos4fv( const GLfloat *v ) +{ + GET_CONTEXT; + (*CC->API.RasterPos4f)( CC, v[0], v[1], v[2], v[3] ); +} + + +void APIENTRY _mesa_RasterPos4iv( const GLint *v ) +{ + GET_CONTEXT; + (*CC->API.RasterPos4f)( CC, (GLfloat) v[0], (GLfloat) v[1], + (GLfloat) v[2], (GLfloat) v[3] ); +} + + +void APIENTRY _mesa_RasterPos4sv( const GLshort *v ) +{ + GET_CONTEXT; + (*CC->API.RasterPos4f)( CC, (GLfloat) v[0], (GLfloat) v[1], + (GLfloat) v[2], (GLfloat) v[3] ); +} + + +void APIENTRY _mesa_ReadBuffer( GLenum mode ) +{ + GET_CONTEXT; + (*CC->API.ReadBuffer)( CC, mode ); +} + + +void APIENTRY _mesa_ReadPixels( GLint x, GLint y, GLsizei width, GLsizei height, + GLenum format, GLenum type, GLvoid *pixels ) +{ + GET_CONTEXT; + (*CC->API.ReadPixels)( CC, x, y, width, height, format, type, pixels ); +} + + +void APIENTRY _mesa_Rectd( GLdouble x1, GLdouble y1, GLdouble x2, GLdouble y2 ) +{ + GET_CONTEXT; + (*CC->API.Rectf)( CC, (GLfloat) x1, (GLfloat) y1, + (GLfloat) x2, (GLfloat) y2 ); +} + + +void APIENTRY _mesa_Rectf( GLfloat x1, GLfloat y1, GLfloat x2, GLfloat y2 ) +{ + GET_CONTEXT; + (*CC->API.Rectf)( CC, x1, y1, x2, y2 ); +} + + +void APIENTRY _mesa_Recti( GLint x1, GLint y1, GLint x2, GLint y2 ) +{ + GET_CONTEXT; + (*CC->API.Rectf)( CC, (GLfloat) x1, (GLfloat) y1, + (GLfloat) x2, (GLfloat) y2 ); +} + + +void APIENTRY _mesa_Rects( GLshort x1, GLshort y1, GLshort x2, GLshort y2 ) +{ + GET_CONTEXT; + (*CC->API.Rectf)( CC, (GLfloat) x1, (GLfloat) y1, + (GLfloat) x2, (GLfloat) y2 ); +} + + +void APIENTRY _mesa_Rectdv( const GLdouble *v1, const GLdouble *v2 ) +{ + GET_CONTEXT; + (*CC->API.Rectf)(CC, (GLfloat) v1[0], (GLfloat) v1[1], + (GLfloat) v2[0], (GLfloat) v2[1]); +} + + +void APIENTRY _mesa_Rectfv( const GLfloat *v1, const GLfloat *v2 ) +{ + GET_CONTEXT; + (*CC->API.Rectf)(CC, v1[0], v1[1], v2[0], v2[1]); +} + + +void APIENTRY _mesa_Rectiv( const GLint *v1, const GLint *v2 ) +{ + GET_CONTEXT; + (*CC->API.Rectf)( CC, (GLfloat) v1[0], (GLfloat) v1[1], + (GLfloat) v2[0], (GLfloat) v2[1] ); +} + + +void APIENTRY _mesa_Rectsv( const GLshort *v1, const GLshort *v2 ) +{ + GET_CONTEXT; + (*CC->API.Rectf)(CC, (GLfloat) v1[0], (GLfloat) v1[1], + (GLfloat) v2[0], (GLfloat) v2[1]); +} + + +void APIENTRY _mesa_Scissor( GLint x, GLint y, GLsizei width, GLsizei height) +{ + GET_CONTEXT; + (*CC->API.Scissor)(CC, x, y, width, height); +} + + +GLboolean APIENTRY _mesa_IsEnabled( GLenum cap ) +{ + GET_CONTEXT; + return (*CC->API.IsEnabled)( CC, cap ); +} + + + +void APIENTRY _mesa_PushAttrib( GLbitfield mask ) +{ + GET_CONTEXT; + (*CC->API.PushAttrib)(CC, mask); +} + + +void APIENTRY _mesa_PushClientAttrib( GLbitfield mask ) +{ + GET_CONTEXT; + (*CC->API.PushClientAttrib)(CC, mask); +} + + +void APIENTRY _mesa_PushName( GLuint name ) +{ + GET_CONTEXT; + (*CC->API.PushName)(CC, name); +} + + +GLint APIENTRY _mesa_RenderMode( GLenum mode ) +{ + GET_CONTEXT; + return (*CC->API.RenderMode)(CC, mode); +} + + +void APIENTRY _mesa_Rotated( GLdouble angle, GLdouble x, GLdouble y, GLdouble z ) +{ + GET_CONTEXT; + (*CC->API.Rotatef)( CC, (GLfloat) angle, + (GLfloat) x, (GLfloat) y, (GLfloat) z ); +} + + +void APIENTRY _mesa_Rotatef( GLfloat angle, GLfloat x, GLfloat y, GLfloat z ) +{ + GET_CONTEXT; + (*CC->API.Rotatef)( CC, angle, x, y, z ); +} + + +void APIENTRY _mesa_SelectBuffer( GLsizei size, GLuint *buffer ) +{ + GET_CONTEXT; + (*CC->API.SelectBuffer)(CC, size, buffer); +} + + +void APIENTRY _mesa_Scaled( GLdouble x, GLdouble y, GLdouble z ) +{ + GET_CONTEXT; + (*CC->API.Scalef)( CC, (GLfloat) x, (GLfloat) y, (GLfloat) z ); +} + + +void APIENTRY _mesa_Scalef( GLfloat x, GLfloat y, GLfloat z ) +{ + GET_CONTEXT; + (*CC->API.Scalef)( CC, x, y, z ); +} + + +void APIENTRY _mesa_ShadeModel( GLenum mode ) +{ + GET_CONTEXT; + (*CC->API.ShadeModel)(CC, mode); +} + + +void APIENTRY _mesa_StencilFunc( GLenum func, GLint ref, GLuint mask ) +{ + GET_CONTEXT; + (*CC->API.StencilFunc)(CC, func, ref, mask); +} + + +void APIENTRY _mesa_StencilMask( GLuint mask ) +{ + GET_CONTEXT; + (*CC->API.StencilMask)(CC, mask); +} + + +void APIENTRY _mesa_StencilOp( GLenum fail, GLenum zfail, GLenum zpass ) +{ + GET_CONTEXT; + (*CC->API.StencilOp)(CC, fail, zfail, zpass); +} + + +void APIENTRY _mesa_TexCoord1d( GLdouble s ) +{ + GET_CONTEXT; + (*CC->API.TexCoord4f)( CC, (GLfloat) s, 0.0, 0.0, 1.0 ); +} + + +void APIENTRY _mesa_TexCoord1f( GLfloat s ) +{ + GET_CONTEXT; + (*CC->API.TexCoord4f)( CC, s, 0.0, 0.0, 1.0 ); +} + + +void APIENTRY _mesa_TexCoord1i( GLint s ) +{ + GET_CONTEXT; + (*CC->API.TexCoord4f)( CC, (GLfloat) s, 0.0, 0.0, 1.0 ); +} + + +void APIENTRY _mesa_TexCoord1s( GLshort s ) +{ + GET_CONTEXT; + (*CC->API.TexCoord4f)( CC, (GLfloat) s, 0.0, 0.0, 1.0 ); +} + + +void APIENTRY _mesa_TexCoord2d( GLdouble s, GLdouble t ) +{ + GET_CONTEXT; + (*CC->API.TexCoord2f)( CC, (GLfloat) s, (GLfloat) t ); +} + + +void APIENTRY _mesa_TexCoord2f( GLfloat s, GLfloat t ) +{ + GET_CONTEXT; + (*CC->API.TexCoord2f)( CC, s, t ); +} + + +void APIENTRY _mesa_TexCoord2i( GLint s, GLint t ) +{ + GET_CONTEXT; + (*CC->API.TexCoord2f)( CC, (GLfloat) s, (GLfloat) t ); +} + + +void APIENTRY _mesa_TexCoord2s( GLshort s, GLshort t ) +{ + GET_CONTEXT; + (*CC->API.TexCoord2f)( CC, (GLfloat) s, (GLfloat) t ); +} + + +void APIENTRY _mesa_TexCoord3d( GLdouble s, GLdouble t, GLdouble r ) +{ + GET_CONTEXT; + (*CC->API.TexCoord4f)( CC, (GLfloat) s, (GLfloat) t, (GLfloat) r, 1.0 ); +} + + +void APIENTRY _mesa_TexCoord3f( GLfloat s, GLfloat t, GLfloat r ) +{ + GET_CONTEXT; + (*CC->API.TexCoord4f)( CC, s, t, r, 1.0 ); +} + + +void APIENTRY _mesa_TexCoord3i( GLint s, GLint t, GLint r ) +{ + GET_CONTEXT; + (*CC->API.TexCoord4f)( CC, (GLfloat) s, (GLfloat) t, + (GLfloat) r, 1.0 ); +} + + +void APIENTRY _mesa_TexCoord3s( GLshort s, GLshort t, GLshort r ) +{ + GET_CONTEXT; + (*CC->API.TexCoord4f)( CC, (GLfloat) s, (GLfloat) t, + (GLfloat) r, 1.0 ); +} + + +void APIENTRY _mesa_TexCoord4d( GLdouble s, GLdouble t, GLdouble r, GLdouble q ) +{ + GET_CONTEXT; + (*CC->API.TexCoord4f)( CC, (GLfloat) s, (GLfloat) t, + (GLfloat) r, (GLfloat) q ); +} + + +void APIENTRY _mesa_TexCoord4f( GLfloat s, GLfloat t, GLfloat r, GLfloat q ) +{ + GET_CONTEXT; + (*CC->API.TexCoord4f)( CC, s, t, r, q ); +} + + +void APIENTRY _mesa_TexCoord4i( GLint s, GLint t, GLint r, GLint q ) +{ + GET_CONTEXT; + (*CC->API.TexCoord4f)( CC, (GLfloat) s, (GLfloat) t, + (GLfloat) r, (GLfloat) q ); +} + + +void APIENTRY _mesa_TexCoord4s( GLshort s, GLshort t, GLshort r, GLshort q ) +{ + GET_CONTEXT; + (*CC->API.TexCoord4f)( CC, (GLfloat) s, (GLfloat) t, + (GLfloat) r, (GLfloat) q ); +} + + +void APIENTRY _mesa_TexCoord1dv( const GLdouble *v ) +{ + GET_CONTEXT; + (*CC->API.TexCoord4f)( CC, (GLfloat) *v, 0.0, 0.0, 1.0 ); +} + + +void APIENTRY _mesa_TexCoord1fv( const GLfloat *v ) +{ + GET_CONTEXT; + (*CC->API.TexCoord4f)( CC, *v, 0.0, 0.0, 1.0 ); +} + + +void APIENTRY _mesa_TexCoord1iv( const GLint *v ) +{ + GET_CONTEXT; + (*CC->API.TexCoord4f)( CC, *v, 0.0, 0.0, 1.0 ); +} + + +void APIENTRY _mesa_TexCoord1sv( const GLshort *v ) +{ + GET_CONTEXT; + (*CC->API.TexCoord4f)( CC, (GLfloat) *v, 0.0, 0.0, 1.0 ); +} + + +void APIENTRY _mesa_TexCoord2dv( const GLdouble *v ) +{ + GET_CONTEXT; + (*CC->API.TexCoord2f)( CC, (GLfloat) v[0], (GLfloat) v[1] ); +} + + +void APIENTRY _mesa_TexCoord2fv( const GLfloat *v ) +{ + GET_CONTEXT; + (*CC->API.TexCoord2f)( CC, v[0], v[1] ); +} + + +void APIENTRY _mesa_TexCoord2iv( const GLint *v ) +{ + GET_CONTEXT; + (*CC->API.TexCoord2f)( CC, (GLfloat) v[0], (GLfloat) v[1] ); +} + + +void APIENTRY _mesa_TexCoord2sv( const GLshort *v ) +{ + GET_CONTEXT; + (*CC->API.TexCoord2f)( CC, (GLfloat) v[0], (GLfloat) v[1] ); +} + + +void APIENTRY _mesa_TexCoord3dv( const GLdouble *v ) +{ + GET_CONTEXT; + (*CC->API.TexCoord4f)( CC, (GLfloat) v[0], (GLfloat) v[1], + (GLfloat) v[2], 1.0 ); +} + + +void APIENTRY _mesa_TexCoord3fv( const GLfloat *v ) +{ + GET_CONTEXT; + (*CC->API.TexCoord4f)( CC, v[0], v[1], v[2], 1.0 ); +} + + +void APIENTRY _mesa_TexCoord3iv( const GLint *v ) +{ + GET_CONTEXT; + (*CC->API.TexCoord4f)( CC, (GLfloat) v[0], (GLfloat) v[1], + (GLfloat) v[2], 1.0 ); +} + + +void APIENTRY _mesa_TexCoord3sv( const GLshort *v ) +{ + GET_CONTEXT; + (*CC->API.TexCoord4f)( CC, (GLfloat) v[0], (GLfloat) v[1], + (GLfloat) v[2], 1.0 ); +} + + +void APIENTRY _mesa_TexCoord4dv( const GLdouble *v ) +{ + GET_CONTEXT; + (*CC->API.TexCoord4f)( CC, (GLfloat) v[0], (GLfloat) v[1], + (GLfloat) v[2], (GLfloat) v[3] ); +} + + +void APIENTRY _mesa_TexCoord4fv( const GLfloat *v ) +{ + GET_CONTEXT; + (*CC->API.TexCoord4f)( CC, v[0], v[1], v[2], v[3] ); +} + + +void APIENTRY _mesa_TexCoord4iv( const GLint *v ) +{ + GET_CONTEXT; + (*CC->API.TexCoord4f)( CC, (GLfloat) v[0], (GLfloat) v[1], + (GLfloat) v[2], (GLfloat) v[3] ); +} + + +void APIENTRY _mesa_TexCoord4sv( const GLshort *v ) +{ + GET_CONTEXT; + (*CC->API.TexCoord4f)( CC, (GLfloat) v[0], (GLfloat) v[1], + (GLfloat) v[2], (GLfloat) v[3] ); +} + + +void APIENTRY _mesa_TexCoordPointer( GLint size, GLenum type, GLsizei stride, + const GLvoid *ptr ) +{ + GET_CONTEXT; + (*CC->API.TexCoordPointer)(CC, size, type, stride, ptr); +} + + +void APIENTRY _mesa_TexGend( GLenum coord, GLenum pname, GLdouble param ) +{ + GLfloat p = (GLfloat) param; + GET_CONTEXT; + (*CC->API.TexGenfv)( CC, coord, pname, &p ); +} + + +void APIENTRY _mesa_TexGenf( GLenum coord, GLenum pname, GLfloat param ) +{ + GET_CONTEXT; + (*CC->API.TexGenfv)( CC, coord, pname, ¶m ); +} + + +void APIENTRY _mesa_TexGeni( GLenum coord, GLenum pname, GLint param ) +{ + GLfloat p = (GLfloat) param; + GET_CONTEXT; + (*CC->API.TexGenfv)( CC, coord, pname, &p ); +} + + +void APIENTRY _mesa_TexGendv( GLenum coord, GLenum pname, const GLdouble *params ) +{ + GLfloat p[4]; + GET_CONTEXT; + p[0] = params[0]; + p[1] = params[1]; + p[2] = params[2]; + p[3] = params[3]; + (*CC->API.TexGenfv)( CC, coord, pname, p ); +} + + +void APIENTRY _mesa_TexGeniv( GLenum coord, GLenum pname, const GLint *params ) +{ + GLfloat p[4]; + GET_CONTEXT; + p[0] = params[0]; + p[1] = params[1]; + p[2] = params[2]; + p[3] = params[3]; + (*CC->API.TexGenfv)( CC, coord, pname, p ); +} + + +void APIENTRY _mesa_TexGenfv( GLenum coord, GLenum pname, const GLfloat *params ) +{ + GET_CONTEXT; + (*CC->API.TexGenfv)( CC, coord, pname, params ); +} + + + + +void APIENTRY _mesa_TexEnvf( GLenum target, GLenum pname, GLfloat param ) +{ + GET_CONTEXT; + (*CC->API.TexEnvfv)( CC, target, pname, ¶m ); +} + + + +void APIENTRY _mesa_TexEnvi( GLenum target, GLenum pname, GLint param ) +{ + GLfloat p[4]; + GET_CONTEXT; + p[0] = (GLfloat) param; + p[1] = p[2] = p[3] = 0.0; + (*CC->API.TexEnvfv)( CC, target, pname, p ); +} + + + +void APIENTRY _mesa_TexEnvfv( GLenum target, GLenum pname, const GLfloat *param ) +{ + GET_CONTEXT; + (*CC->API.TexEnvfv)( CC, target, pname, param ); +} + + + +void APIENTRY _mesa_TexEnviv( GLenum target, GLenum pname, const GLint *param ) +{ + GLfloat p[4]; + GET_CONTEXT; + p[0] = INT_TO_FLOAT( param[0] ); + p[1] = INT_TO_FLOAT( param[1] ); + p[2] = INT_TO_FLOAT( param[2] ); + p[3] = INT_TO_FLOAT( param[3] ); + (*CC->API.TexEnvfv)( CC, target, pname, p ); +} + + +void APIENTRY _mesa_TexImage1D( GLenum target, GLint level, GLint internalformat, + GLsizei width, GLint border, + GLenum format, GLenum type, const GLvoid *pixels ) +{ + struct gl_image *teximage; + GET_CONTEXT; + teximage = gl_unpack_image( CC, width, 1, format, type, pixels ); + (*CC->API.TexImage1D)( CC, target, level, internalformat, + width, border, format, type, teximage ); +} + + + +void APIENTRY _mesa_TexImage2D( GLenum target, GLint level, GLint internalformat, + GLsizei width, GLsizei height, GLint border, + GLenum format, GLenum type, const GLvoid *pixels ) +{ + struct gl_image *teximage; + + GET_CONTEXT; + + teximage = gl_unpack_image( CC, width, height, format, type, pixels ); + (*CC->API.TexImage2D)( CC, target, level, internalformat, + width, height, border, format, type, teximage ); +} + + +void APIENTRY _mesa_TexParameterf( GLenum target, GLenum pname, GLfloat param ) +{ + GET_CONTEXT; + (*CC->API.TexParameterfv)( CC, target, pname, ¶m ); +} + + +void APIENTRY _mesa_TexParameteri( GLenum target, GLenum pname, GLint param ) +{ + GLfloat fparam[4]; + GET_CONTEXT; + fparam[0] = (GLfloat) param; + fparam[1] = fparam[2] = fparam[3] = 0.0; + (*CC->API.TexParameterfv)( CC, target, pname, fparam ); +} + + +void APIENTRY _mesa_TexParameterfv( GLenum target, GLenum pname, const GLfloat *params ) +{ + GET_CONTEXT; + (*CC->API.TexParameterfv)( CC, target, pname, params ); +} + + +void APIENTRY _mesa_TexParameteriv( GLenum target, GLenum pname, const GLint *params ) +{ + GLfloat p[4]; + GET_CONTEXT; + if (pname==GL_TEXTURE_BORDER_COLOR) { + p[0] = INT_TO_FLOAT( params[0] ); + p[1] = INT_TO_FLOAT( params[1] ); + p[2] = INT_TO_FLOAT( params[2] ); + p[3] = INT_TO_FLOAT( params[3] ); + } + else { + p[0] = (GLfloat) params[0]; + p[1] = (GLfloat) params[1]; + p[2] = (GLfloat) params[2]; + p[3] = (GLfloat) params[3]; + } + (*CC->API.TexParameterfv)( CC, target, pname, p ); +} + + +void APIENTRY _mesa_TexSubImage1D( GLenum target, GLint level, GLint xoffset, + GLsizei width, GLenum format, + GLenum type, const GLvoid *pixels ) +{ + struct gl_image *image; + GET_CONTEXT; + image = gl_unpack_texsubimage( CC, width, 1, format, type, pixels ); + (*CC->API.TexSubImage1D)( CC, target, level, xoffset, width, + format, type, image ); +} + + +void APIENTRY _mesa_TexSubImage2D( GLenum target, GLint level, + GLint xoffset, GLint yoffset, + GLsizei width, GLsizei height, + GLenum format, GLenum type, + const GLvoid *pixels ) +{ + struct gl_image *image; + GET_CONTEXT; + image = gl_unpack_texsubimage( CC, width, height, format, type, pixels ); + (*CC->API.TexSubImage2D)( CC, target, level, xoffset, yoffset, + width, height, format, type, image ); +} + + +void APIENTRY _mesa_Translated( GLdouble x, GLdouble y, GLdouble z ) +{ + GET_CONTEXT; + (*CC->API.Translatef)( CC, (GLfloat) x, (GLfloat) y, (GLfloat) z ); +} + + +void APIENTRY _mesa_Translatef( GLfloat x, GLfloat y, GLfloat z ) +{ + GET_CONTEXT; + (*CC->API.Translatef)( CC, x, y, z ); +} + + +void APIENTRY _mesa_Vertex2d( GLdouble x, GLdouble y ) +{ + GET_CONTEXT; + (*CC->API.Vertex2f)( CC, (GLfloat) x, (GLfloat) y ); +} + + +void APIENTRY _mesa_Vertex2f( GLfloat x, GLfloat y ) +{ + GET_CONTEXT; + (*CC->API.Vertex2f)( CC, x, y ); +} + + +void APIENTRY _mesa_Vertex2i( GLint x, GLint y ) +{ + GET_CONTEXT; + (*CC->API.Vertex2f)( CC, (GLfloat) x, (GLfloat) y ); +} + + +void APIENTRY _mesa_Vertex2s( GLshort x, GLshort y ) +{ + GET_CONTEXT; + (*CC->API.Vertex2f)( CC, (GLfloat) x, (GLfloat) y ); +} + + +void APIENTRY _mesa_Vertex3d( GLdouble x, GLdouble y, GLdouble z ) +{ + GET_CONTEXT; + (*CC->API.Vertex3f)( CC, (GLfloat) x, (GLfloat) y, (GLfloat) z ); +} + + +void APIENTRY _mesa_Vertex3f( GLfloat x, GLfloat y, GLfloat z ) +{ + GET_CONTEXT; + (*CC->API.Vertex3f)( CC, x, y, z ); +} + + +void APIENTRY _mesa_Vertex3i( GLint x, GLint y, GLint z ) +{ + GET_CONTEXT; + (*CC->API.Vertex3f)( CC, (GLfloat) x, (GLfloat) y, (GLfloat) z ); +} + + +void APIENTRY _mesa_Vertex3s( GLshort x, GLshort y, GLshort z ) +{ + GET_CONTEXT; + (*CC->API.Vertex3f)( CC, (GLfloat) x, (GLfloat) y, (GLfloat) z ); +} + + +void APIENTRY _mesa_Vertex4d( GLdouble x, GLdouble y, GLdouble z, GLdouble w ) +{ + GET_CONTEXT; + (*CC->API.Vertex4f)( CC, (GLfloat) x, (GLfloat) y, + (GLfloat) z, (GLfloat) w ); +} + + +void APIENTRY _mesa_Vertex4f( GLfloat x, GLfloat y, GLfloat z, GLfloat w ) +{ + GET_CONTEXT; + (*CC->API.Vertex4f)( CC, x, y, z, w ); +} + + +void APIENTRY _mesa_Vertex4i( GLint x, GLint y, GLint z, GLint w ) +{ + GET_CONTEXT; + (*CC->API.Vertex4f)( CC, (GLfloat) x, (GLfloat) y, + (GLfloat) z, (GLfloat) w ); +} + + +void APIENTRY _mesa_Vertex4s( GLshort x, GLshort y, GLshort z, GLshort w ) +{ + GET_CONTEXT; + (*CC->API.Vertex4f)( CC, (GLfloat) x, (GLfloat) y, + (GLfloat) z, (GLfloat) w ); +} + + +void APIENTRY _mesa_Vertex2dv( const GLdouble *v ) +{ + GET_CONTEXT; + (*CC->API.Vertex2f)( CC, (GLfloat) v[0], (GLfloat) v[1] ); +} + + +void APIENTRY _mesa_Vertex2fv( const GLfloat *v ) +{ + GET_CONTEXT; + (*CC->API.Vertex2f)( CC, v[0], v[1] ); +} + + +void APIENTRY _mesa_Vertex2iv( const GLint *v ) +{ + GET_CONTEXT; + (*CC->API.Vertex2f)( CC, (GLfloat) v[0], (GLfloat) v[1] ); +} + + +void APIENTRY _mesa_Vertex2sv( const GLshort *v ) +{ + GET_CONTEXT; + (*CC->API.Vertex2f)( CC, (GLfloat) v[0], (GLfloat) v[1] ); +} + + +void APIENTRY _mesa_Vertex3dv( const GLdouble *v ) +{ + GET_CONTEXT; + (*CC->API.Vertex3f)( CC, (GLfloat) v[0], (GLfloat) v[1], (GLfloat) v[2] ); +} + + +void APIENTRY _mesa_Vertex3fv( const GLfloat *v ) +{ + GET_CONTEXT; + (*CC->API.Vertex3fv)( CC, v ); +} + + +void APIENTRY _mesa_Vertex3iv( const GLint *v ) +{ + GET_CONTEXT; + (*CC->API.Vertex3f)( CC, (GLfloat) v[0], (GLfloat) v[1], (GLfloat) v[2] ); +} + + +void APIENTRY _mesa_Vertex3sv( const GLshort *v ) +{ + GET_CONTEXT; + (*CC->API.Vertex3f)( CC, (GLfloat) v[0], (GLfloat) v[1], (GLfloat) v[2] ); +} + + +void APIENTRY _mesa_Vertex4dv( const GLdouble *v ) +{ + GET_CONTEXT; + (*CC->API.Vertex4f)( CC, (GLfloat) v[0], (GLfloat) v[1], + (GLfloat) v[2], (GLfloat) v[3] ); +} + + +void APIENTRY _mesa_Vertex4fv( const GLfloat *v ) +{ + GET_CONTEXT; + (*CC->API.Vertex4f)( CC, v[0], v[1], v[2], v[3] ); +} + + +void APIENTRY _mesa_Vertex4iv( const GLint *v ) +{ + GET_CONTEXT; + (*CC->API.Vertex4f)( CC, (GLfloat) v[0], (GLfloat) v[1], + (GLfloat) v[2], (GLfloat) v[3] ); +} + + +void APIENTRY _mesa_Vertex4sv( const GLshort *v ) +{ + GET_CONTEXT; + (*CC->API.Vertex4f)( CC, (GLfloat) v[0], (GLfloat) v[1], + (GLfloat) v[2], (GLfloat) v[3] ); +} + + +void APIENTRY _mesa_VertexPointer( GLint size, GLenum type, GLsizei stride, + const GLvoid *ptr ) +{ + GET_CONTEXT; + (*CC->API.VertexPointer)(CC, size, type, stride, ptr); +} + + +void APIENTRY _mesa_Viewport( GLint x, GLint y, GLsizei width, GLsizei height ) +{ + GET_CONTEXT; + (*CC->API.Viewport)( CC, x, y, width, height ); +} + +/* GL_EXT_paletted_texture */ + +void APIENTRY _mesa_ColorTableEXT( GLenum target, GLenum internalFormat, + GLsizei width, GLenum format, GLenum type, + const GLvoid *table ) +{ + struct gl_image *image; + GET_CONTEXT; + image = gl_unpack_image( CC, width, 1, format, type, table ); + (*CC->API.ColorTable)( CC, target, internalFormat, image ); + if (image->RefCount == 0) + gl_free_image(image); +} + + +void APIENTRY _mesa_ColorSubTableEXT( GLenum target, GLsizei start, GLsizei count, + GLenum format, GLenum type, + const GLvoid *data ) +{ + struct gl_image *image; + GET_CONTEXT; + image = gl_unpack_image( CC, count, 1, format, type, data ); + (*CC->API.ColorSubTable)( CC, target, start, image ); + if (image->RefCount == 0) + gl_free_image(image); +} + +void APIENTRY _mesa_GetColorTableEXT( GLenum target, GLenum format, + GLenum type, GLvoid *table ) +{ + GET_CONTEXT; + (*CC->API.GetColorTable)(CC, target, format, type, table); +} + + +void APIENTRY _mesa_GetColorTableParameterivEXT( GLenum target, GLenum pname, + GLint *params ) +{ + GET_CONTEXT; + (*CC->API.GetColorTableParameteriv)(CC, target, pname, params); +} + + +void APIENTRY _mesa_GetColorTableParameterfvEXT( GLenum target, GLenum pname, + GLfloat *params ) +{ + GLint iparams; + _mesa_GetColorTableParameterivEXT( target, pname, &iparams ); + *params = (GLfloat) iparams; +} +/* End GL_EXT_paletted_texture */ diff --git a/dll/opengl/mesa/api.h b/dll/opengl/mesa/api.h new file mode 100644 index 00000000000..0d0064fa7cb --- /dev/null +++ b/dll/opengl/mesa/api.h @@ -0,0 +1,83 @@ +/* $Id: api.h,v 1.4 1998/02/04 00:38:24 brianp Exp $ */ + +/* + * Mesa 3-D graphics library + * Version: 2.4 + * Copyright (C) 1995-1997 Brian Paul + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Library General Public + * License as published by the Free Software Foundation; either + * version 2 of the License, or (at your option) any later version. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Library General Public License for more details. + * + * You should have received a copy of the GNU Library General Public + * License along with this library; if not, write to the Free + * Software Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. + */ + + +/* + * $Log: api.h,v $ + * Revision 1.4 1998/02/04 00:38:24 brianp + * WIN32 patch from Oleg Letsinsky + * + * Revision 1.3 1998/02/04 00:13:35 brianp + * updated for Cygnus (Stephane Rehel) + * + * Revision 1.2 1997/11/25 03:20:09 brianp + * simple clean-ups for multi-threading (John Stone) + * + * Revision 1.1 1997/08/22 01:42:26 brianp + * Initial revision + * + */ + + +/* + * The original api.c file has been split into two files: api1.c and api2.c + * because some compilers complained that api.c was too big. + * + * This header contains stuff only included by api1.c and api2.c + */ + + +#ifndef API_H +#define API_H + + +/* + * Single/multiple thread context selection. + */ +#ifdef THREADS + +/* Get the context associated with the calling thread */ +#define GET_CONTEXT GLcontext *CC = gl_get_thread_context() + +#else + +/* CC is a global pointer for all threads in the address space */ +#define GET_CONTEXT + +#endif /* THREADS */ + + +/* + * An optimization in a few performance-critical functions. + */ +#define SHORTCUT + + +/* + * Windows 95/NT DLL stuff. + */ +#if !defined(WIN32) && !defined(WINDOWS_NT) && !defined(__CYGWIN32__) +#define APIENTRY +#endif + + +#endif diff --git a/dll/opengl/mesa/asm-386.S b/dll/opengl/mesa/asm-386.S new file mode 100644 index 00000000000..c4979b8616d --- /dev/null +++ b/dll/opengl/mesa/asm-386.S @@ -0,0 +1,1644 @@ +/* $Id: asm-386.S,v 1.8 1997/12/17 00:50:51 brianp Exp $ */ + +/* + * asm-386.S - special (hopefully faster) transformation functions for x86 + * + * by Josh Vanderhoof + * + * This file is in the public domain. + */ + +/* + * $Log: asm-386.S,v $ + * Revision 1.8 1997/12/17 00:50:51 brianp + * applied Josh's patch to fix texture coordinate transformation bugs + * + * Revision 1.7 1997/12/17 00:27:11 brianp + * applied Josh's patch to fix bfris + * + * Revision 1.6 1997/12/01 01:02:41 brianp + * added FreeBSD patches (Daniel J. O'Connor) + * + * Revision 1.5 1997/11/19 23:52:17 brianp + * added missing "cld" instruction in asm_transform_points4_identity() + * + * Revision 1.4 1997/11/11 02:22:41 brianp + * small change per Josh to ensure U/V pairing + * + * Revision 1.3 1997/11/07 03:37:24 brianp + * added missing line from Stephane Rehel + * + * Revision 1.2 1997/11/07 03:30:37 brianp + * added Josh's 11-5-97 patches + * + * Revision 1.1 1997/10/30 06:00:33 brianp + * Initial revision + */ + +#include + +#define S(x) dword ptr [esi + 4*x] +#define D(x) dword ptr [edi + 4*x] +#define M(x, y) dword ptr [edx + 16*x + 4*y] + +.code + +/* + * void asm_transform_points3_general( GLuint n, GLfloat d[][4], + * GLfloat m[16], GLfloat s[][4] ); + */ +PUBLIC _asm_transform_points3_general +_asm_transform_points3_general: +.align 4 + push esi + push edi + + mov ecx, [esp + 12] /* ecx = n */ + mov edi, [esp + 16] /* edi = d */ + mov edx, [esp + 20] /* edx = m */ + mov esi, [esp + 24] /* esi = s */ + + test ecx, ecx + jz _asm_transform_points3_general_end + +.align 4 +_asm_transform_points3_general_loop: + fld S(0) + fmul M(0, 0) + fld S(0) + fmul M(0, 1) + fld S(0) + fmul M(0, 2) + fld S(0) + fmul M(0, 3) + + fld S(1) + fmul M(1, 0) + fld S(1) + fmul M(1, 1) + fld S(1) + fmul M(1, 2) + fld S(1) + fmul M(1, 3) + + /* + * The FPU stack should now look like this: + * + * st(7) = S(0) * M(0, 0) + * st(6) = S(0) * M(0, 1) + * st(5) = S(0) * M(0, 2) + * st(4) = S(0) * M(0, 3) + * st(3) = S(1) * M(1, 0) + * st(2) = S(1) * M(1, 1) + * st(1) = S(1) * M(1, 2) + * st(0) = S(1) * M(1, 3) + */ + + fxch st(3) /* 3 1 2 0 4 5 6 7 */ + faddp st(7), st /* 1 2 0 4 5 6 7 */ + fxch st(1) /* 2 1 0 4 5 6 7 */ + faddp st(5), st /* 1 0 4 5 6 7 */ + faddp st(3), st /* 0 4 5 6 7 */ + faddp st(1), st /* 4 5 6 7 */ + + /* + * st(3) = S(0) * M(0, 0) + S(1) * M(1, 0) + * st(2) = S(0) * M(0, 1) + S(1) * M(1, 1) + * st(1) = S(0) * M(0, 2) + S(1) * M(1, 2) + * st(0) = S(0) * M(0, 3) + S(1) * M(1, 3) + */ + + fld S(2) + fmul M(2, 0) + fld S(2) + fmul M(2, 1) + fld S(2) + fmul M(2, 2) + fld S(2) + fmul M(2, 3) + + /* + * st(7) = S(0) * M(0, 0) + S(1) * M(1, 0) + * st(6) = S(0) * M(0, 1) + S(1) * M(1, 1) + * st(5) = S(0) * M(0, 2) + S(1) * M(1, 2) + * st(4) = S(0) * M(0, 3) + S(1) * M(1, 3) + * st(3) = S(2) * M(2, 0) + * st(2) = S(2) * M(2, 1) + * st(1) = S(2) * M(2, 2) + * st(0) = S(2) * M(2, 3) + */ + + fxch st(3) /* 3 1 2 0 4 5 6 7 */ + faddp st(7), st /* 1 2 0 4 5 6 7 */ + fxch st(1) /* 2 1 0 4 5 6 7 */ + faddp st(5), st /* 1 0 4 5 6 7 */ + faddp st(3), st /* 0 4 5 6 7 */ + faddp st(1), st /* 4 5 6 7 */ + + /* + * st(3) = S(0) * M(0, 0) + S(1) * M(1, 0) + S(2) * M(2, 0) + * st(2) = S(0) * M(0, 1) + S(1) * M(1, 1) + S(2) * M(2, 1) + * st(1) = S(0) * M(0, 2) + S(1) * M(1, 2) + S(2) * M(2, 2) + * st(0) = S(0) * M(0, 3) + S(1) * M(1, 3) + S(2) * M(2, 3) + */ + + fxch st(3) /* 3 1 2 0 */ + fadd M(3, 0) + fxch st(2) /* 2 1 3 0 */ + fadd M(3, 1) + fxch st(1) /* 1 2 3 0 */ + fadd M(3, 2) + fxch st(3) /* 0 2 3 1 */ + fadd M(3, 3) + + /* + * st(3) = S(0) * M(0, 2) + S(1) * M(1, 2) + S(2) * M(2, 2) + M(3, 2) + * st(2) = S(0) * M(0, 0) + S(1) * M(1, 0) + S(2) * M(2, 0) + M(3, 0) + * st(1) = S(0) * M(0, 1) + S(1) * M(1, 1) + S(2) * M(2, 1) + M(3, 1) + * st(0) = S(0) * M(0, 3) + S(1) * M(1, 3) + S(2) * M(2, 3) + M(3, 3) + */ + + fxch st(3) /* 3 1 2 0 */ + fstp D(2) /* 1 2 0 */ + fxch st(1) /* 2 1 0 */ + fstp D(0) /* 1 0 */ + lea esi, S(4) + fstp D(1) /* 0 */ + dec ecx + fstp D(3) /* */ + + lea edi, D(4) + + jnz _asm_transform_points3_general_loop + +_asm_transform_points3_general_end: + pop edi + pop esi + ret + + +/* + * void asm_transform_points3_identity( GLuint n, GLfloat d[][4], + * GLfloat s[][4] ); + */ +PUBLIC _asm_transform_points3_identity +_asm_transform_points3_identity: +.align 4 + push esi + push edi + mov ecx, [esp + 12] /* ecx = n */ + mov edi, [esp + 16] /* edi = d */ + mov esi, [esp + 20] /* esi = s */ + push ebx + push ebp + + test ecx, ecx + jz _asm_transform_points3_identity_end + + mov ebp, HEX(3f800000) + +.align 4 +_asm_transform_points3_identity_loop: + mov eax, S(0) + mov edx, S(1) + mov ebx, S(2) + lea esi, S(4) + mov D(0), eax + mov D(1), edx + mov D(2), ebx + mov D(3), ebp + dec ecx + lea edi, D(4) + jnz _asm_transform_points3_identity_loop + +_asm_transform_points3_identity_end: + pop ebp + pop ebx + pop edi + pop esi + ret + + +/* + * void asm_transform_points3_2d( GLuint n, GLfloat d[][4], GLfloat m[16], + * GLfloat s[][4] ); + */ +PUBLIC _asm_transform_points3_2d +_asm_transform_points3_2d: +.align 4 + push esi + push edi + mov ecx, [esp + 12] /* ecx = n */ + mov edi, [esp + 16] /* edi = d */ + mov edx, [esp + 20] /* edx = m */ + mov esi, [esp + 24] /* esi = s */ + push ebp + + mov ebp, HEX(3f800000) + + test cl, DEC(1) + jz _asm_transform_points3_2d_step + + dec ecx + + fld S(0) + fmul M(0, 0) + fld S(0) + fmul M(0, 1) + fld S(1) + fmul M(1, 0) + fld S(1) + fmul M(1, 1) + + /* + * st(3) = S(0) * M(0, 0) + * st(2) = S(0) * M(0, 1) + * st(1) = S(1) * M(1, 0) + * st(0) = S(1) * M(1, 1) + */ + + fxch st(1) /* 1 0 2 3 */ + fadd M(3, 0) + fxch st(1) /* 0 1 2 3 */ + fadd M(3, 1) + fxch st(1) /* 1 0 2 3 */ + faddp st(3), st /* 0 2 3 */ + faddp st(1), st /* 2 3 */ + fstp D(1) /* 3 */ + fstp D(0) /* */ + mov eax, S(2) + lea esi, S(4) + mov D(3), ebp + mov D(2), eax + lea edi, D(4) + +_asm_transform_points3_2d_step: + test ecx, ecx + jz _asm_transform_points3_2d_end + +.align 4 +_asm_transform_points3_2d_loop: + fld S(0) + fmul M(0, 0) + fld S(0) + fmul M(0, 1) + fld S(4) + fmul M(0, 0) + fld S(4) + fmul M(0, 1) + fld S(1) + fmul M(1, 0) + fld S(1) + fmul M(1, 1) + fld S(5) + fmul M(1, 0) + fld S(5) + fmul M(1, 1) + + /* + * st(7) = S(0) * M(0, 0) + * st(6) = S(0) * M(0, 1) + * st(5) = S(4) * M(0, 0) + * st(4) = S(4) * M(0, 1) + * st(3) = S(1) * M(1, 0) + * st(2) = S(1) * M(1, 1) + * st(1) = S(5) * M(1, 0) + * st(0) = S(5) * M(1, 1) + */ + + fxch st(7) /* 7 1 2 3 4 5 6 0 */ + fadd M(3, 0) + fxch st(6) /* 6 1 2 3 4 5 7 0 */ + fadd M(3, 1) + fxch st(5) /* 5 1 2 3 4 6 7 0 */ + fadd M(3, 0) + fxch st(4) /* 4 1 2 3 5 6 7 0 */ + fadd M(3, 1) + + mov eax, S(2) + mov D(3), ebp + mov D(2), eax + mov eax, S(6) + mov D(7), ebp + mov D(6), eax + lea esi, S(8) + sub ecx, DEC(2) + + /* + * st(7) = S(5) * M(1, 1) + * st(6) = S(0) * M(0, 0) + M(3, 0) + * st(5) = S(0) * M(0, 1) + M(3, 1) + * st(4) = S(4) * M(0, 0) + M(3, 0) + * st(3) = S(1) * M(1, 0) + * st(2) = S(1) * M(1, 1) + * st(1) = S(5) * M(1, 0) + * st(0) = S(4) * M(0, 1) + M(3, 1) + */ + + faddp st(7), st /* 1 2 3 4 5 6 7 */ + faddp st(3), st /* 2 3 4 5 6 7 */ + faddp st(3), st /* 3 4 5 6 7 */ + faddp st(3), st /* 4 5 6 7 */ + fxch st(3) /* 7 5 6 4 */ + fstp D(5) /* 5 6 4 */ + fstp D(1) /* 6 4 */ + fstp D(0) /* 4 */ + fstp D(4) /* */ + + lea edi, D(8) + jnz _asm_transform_points3_2d_loop + +_asm_transform_points3_2d_end: + pop ebp + pop edi + pop esi + ret + + +/* + * void asm_transform_points3_2d_no_rot( GLuint n, GLfloat d[][4], + * GLfloat m[16], GLfloat s[][4] ); + * + */ +PUBLIC _asm_transform_points3_2d_no_rot +_asm_transform_points3_2d_no_rot: +.align 4 + push esi + push edi + mov ecx, [esp + 12] /* ecx = n */ + mov edi, [esp + 16] /* edi = d */ + mov edx, [esp + 20] /* edx = m */ + mov esi, [esp + 24] /* esi = s */ + push ebp + + test ecx, ecx + jz _asm_transform_points3_2d_no_rot_end + + mov ebp, HEX(3f800000) + +.align 4 +_asm_transform_points3_2d_no_rot_loop: + fld S(0) + fmul M(0, 0) + fld S(1) + fmul M(1, 1) + fxch st(1) + fadd M(3, 0) + fxch st(1) + fadd M(3, 1) + fxch st(1) + fstp D(0) + fstp D(1) + + mov eax, S(2) /* cycle 1: U pipe */ + mov D(3), ebp /* V pipe */ + mov D(2), eax /* cycle 2: U pipe */ + + dec ecx + lea esi, S(4) + lea edi, D(4) + jnz _asm_transform_points3_2d_no_rot_loop + +_asm_transform_points3_2d_no_rot_end: + pop ebp + pop edi + pop esi + ret + + + +/* + * void asm_transform_points3_3d( GLuint n, GLfloat d[][4], GLfloat m[16], + * GLfloat s[][4] ); + */ +PUBLIC _asm_transform_points3_3d +_asm_transform_points3_3d: +.align 4 + push esi + push edi + mov ecx, [esp + 12] /* ecx = n */ + mov edi, [esp + 16] /* edi = d */ + mov edx, [esp + 20] /* edx = m */ + mov esi, [esp + 24] /* esi = s */ + + test ecx, ecx + jz _asm_transform_points3_3d_end + + mov eax, HEX(3f800000) + +.align 4 +_asm_transform_points3_3d_loop: + fld S(0) + fmul M(0, 0) + fld S(0) + fmul M(0, 1) + fld S(0) + fmul M(0, 2) + + fld S(1) + fmul M(1, 0) + fld S(1) + fmul M(1, 1) + fld S(1) + fmul M(1, 2) + + /* + * st(5) = S(0) * M(0, 0) + * st(4) = S(0) * M(0, 1) + * st(3) = S(0) * M(0, 2) + * st(2) = S(1) * M(1, 0) + * st(1) = S(1) * M(1, 1) + * st(0) = S(1) * M(1, 2) + */ + + fxch st(2) /* 2 1 0 3 4 5 */ + faddp st(5), st /* 1 0 3 4 5 */ + faddp st(3), st /* 0 3 4 5 */ + faddp st(1), st /* 3 4 5 */ + + /* + * st(2) = S(0) * M(0, 0) + S(1) * M(1, 0) + * st(1) = S(0) * M(0, 1) + S(1) * M(1, 1) + * st(0) = S(0) * M(0, 2) + S(1) * M(1, 2) + */ + + fld S(2) + fmul M(2, 0) + fld S(2) + fmul M(2, 1) + fld S(2) + fmul M(2, 2) + + /* + * st(5) = S(0) * M(0, 0) + S(1) * M(1, 0) + * st(4) = S(0) * M(0, 1) + S(1) * M(1, 1) + * st(3) = S(0) * M(0, 2) + S(1) * M(1, 2) + * st(2) = S(2) * M(2, 0) + * st(1) = S(2) * M(2, 1) + * st(0) = S(2) * M(2, 2) + */ + + fxch st(2) /* 2 1 0 3 4 5 */ + faddp st(5), st /* 1 0 3 4 5 */ + faddp st(3), st /* 0 3 4 5 */ + faddp st(1), st /* 3 4 5 */ + + /* + * st(2) = S(0) * M(0, 0) + S(1) * M(1, 0) + S(2) * M(2, 0) + * st(1) = S(0) * M(0, 1) + S(1) * M(1, 1) + S(2) * M(2, 1) + * st(0) = S(0) * M(0, 2) + S(1) * M(1, 2) + S(2) * M(2, 2) + */ + + fxch st(2) /* 2 1 0 */ + fadd M(3, 0) + fxch st(1) /* 1 2 0 */ + fadd M(3, 1) + fxch st(2) /* 0 2 1 */ + fadd M(3, 2) + + fxch st(1) /* 2 0 1 */ + fstp D(0) /* 0 1 */ + fstp D(2) /* 1 */ + fstp D(1) /* */ + mov D(3), eax + + lea esi, S(4) + dec ecx + + lea edi, D(4) + + jnz _asm_transform_points3_3d_loop + +_asm_transform_points3_3d_end: + pop edi + pop esi + ret + + + +/* + * void asm_transform_points4_general( GLuint n, GLfloat d[][4], + * GLfloat m[16], GLfloat s[][4] ); + */ +PUBLIC _asm_transform_points4_general +_asm_transform_points4_general: +.align 4 + push esi + push edi + mov ecx, [esp + 12] /* ecx = n */ + mov edi, [esp + 16] /* edi = d */ + mov edx, [esp + 20] /* edx = m */ + mov esi, [esp + 24] /* esi = s */ + + test ecx, ecx + jz _asm_transform_points4_general_end + +.align 4 +_asm_transform_points4_general_loop: + fld S(0) + fmul M(0, 0) + fld S(0) + fmul M(0, 1) + fld S(0) + fmul M(0, 2) + fld S(0) + fmul M(0, 3) + + fld S(1) + fmul M(1, 0) + fld S(1) + fmul M(1, 1) + fld S(1) + fmul M(1, 2) + fld S(1) + fmul M(1, 3) + + /* + * st(7) = S(0) * M(0, 0) + * st(6) = S(0) * M(0, 1) + * st(5) = S(0) * M(0, 2) + * st(4) = S(0) * M(0, 3) + * st(3) = S(1) * M(1, 0) + * st(2) = S(1) * M(1, 1) + * st(1) = S(1) * M(1, 2) + * st(0) = S(1) * M(1, 3) + */ + + fxch st(3) /* 3 1 2 0 4 5 6 7 */ + faddp st(7), st /* 1 2 0 4 5 6 7 */ + fxch st(1) /* 2 1 0 4 5 6 7 */ + faddp st(5), st /* 1 0 4 5 6 7 */ + faddp st(3), st /* 0 4 5 6 7 */ + faddp st(1), st /* 4 5 6 7 */ + + /* + * st(3) = S(0) * M(0, 0) + S(1) * M(1, 0) + * st(2) = S(0) * M(0, 1) + S(1) * M(1, 1) + * st(1) = S(0) * M(0, 2) + S(1) * M(1, 2) + * st(0) = S(0) * M(0, 3) + S(1) * M(1, 3) + */ + + fld S(2) + fmul M(2, 0) + fld S(2) + fmul M(2, 1) + fld S(2) + fmul M(2, 2) + fld S(2) + fmul M(2, 3) + + /* + * st(7) = S(0) * M(0, 0) + S(1) * M(1, 0) + * st(6) = S(0) * M(0, 1) + S(1) * M(1, 1) + * st(5) = S(0) * M(0, 2) + S(1) * M(1, 2) + * st(4) = S(0) * M(0, 3) + S(1) * M(1, 3) + * st(3) = S(2) * M(2, 0) + * st(2) = S(2) * M(2, 1) + * st(1) = S(2) * M(2, 2) + * st(0) = S(2) * M(2, 3) + */ + + fxch st(3) /* 3 1 2 0 4 5 6 7 */ + faddp st(7), st /* 1 2 0 4 5 6 7 */ + fxch st(1) /* 2 1 0 4 5 6 7 */ + faddp st(5), st /* 1 0 4 5 6 7 */ + faddp st(3), st /* 0 4 5 6 7 */ + faddp st(1), st /* 4 5 6 7 */ + + /* + * st(3) = S(0) * M(0, 0) + S(1) * M(1, 0) + S(2) * M(2, 0) + * st(2) = S(0) * M(0, 1) + S(1) * M(1, 1) + S(2) * M(2, 1) + * st(1) = S(0) * M(0, 2) + S(1) * M(1, 2) + S(2) * M(2, 2) + * st(0) = S(0) * M(0, 3) + S(1) * M(1, 3) + S(2) * M(2, 3) + */ + + fld S(3) + fmul M(3, 0) + fld S(3) + fmul M(3, 1) + fld S(3) + fmul M(3, 2) + fld S(3) + fmul M(3, 3) + + /* + * st(7) = S(0) * M(0, 0) + S(1) * M(1, 0) + S(2) * M(2, 0) + * st(6) = S(0) * M(0, 1) + S(1) * M(1, 1) + S(2) * M(2, 1) + * st(5) = S(0) * M(0, 2) + S(1) * M(1, 2) + S(2) * M(2, 2) + * st(4) = S(0) * M(0, 3) + S(1) * M(1, 3) + S(2) * M(2, 3) + * st(3) = S(3) * M(3, 0) + * st(2) = S(3) * M(3, 1) + * st(1) = S(3) * M(3, 2) + * st(0) = S(3) * M(3, 3) + */ + + fxch st(3) /* 3 1 2 0 4 5 6 7 */ + faddp st(7), st /* 1 2 0 4 5 6 7 */ + fxch st(1) /* 2 1 0 4 5 6 7 */ + faddp st(5), st /* 1 0 4 5 6 7 */ + faddp st(3), st /* 0 4 5 6 7 */ + + lea esi, S(4) + dec ecx + + faddp st(1), st /* 4 5 6 7 */ + + /* + * st(3) = S(0) * M(0, 0) + S(1) * M(1, 0) + S(2) * M(2, 0) + S(3) * M(3, 0) + * st(2) = S(0) * M(0, 1) + S(1) * M(1, 1) + S(2) * M(2, 1) + S(3) * M(3, 1) + * st(1) = S(0) * M(0, 2) + S(1) * M(1, 2) + S(2) * M(2, 2) + S(3) * M(3, 2) + * st(0) = S(0) * M(0, 3) + S(1) * M(1, 3) + S(2) * M(2, 3) + S(3) * M(3, 3) + */ + + fxch st(3) /* 3 1 2 0 */ + fstp D(0) /* 1 2 0 */ + fxch st(1) /* 2 1 0 */ + fstp D(1) /* 1 0 */ + fstp D(2) /* 0 */ + fstp D(3) /* */ + + lea edi, D(4) + + jnz _asm_transform_points4_general_loop + +_asm_transform_points4_general_end: + pop edi + pop esi + ret + + + +/* + * void asm_transform_points4_identity( GLuint n, GLfloat d[][4], + * GLfloat s[][4] ); + */ +PUBLIC _asm_transform_points4_identity +_asm_transform_points4_identity: +.align 4 + push esi + push edi + mov ecx, [esp + 12] /* ecx = n */ + mov edi, [esp + 16] /* edi = d */ + mov esi, [esp + 20] /* esi = s */ + + lea ecx, [ecx * 4] + + cld + rep movsd + + pop edi + pop esi + ret + + + +/* + * void asm_transform_points4_2d( GLuint n, GLfloat d[][4], GLfloat m[16], + * GLfloat s[][4] ); + */ +PUBLIC _asm_transform_points4_2d +_asm_transform_points4_2d: +.align 4 + push esi + push edi + mov ecx, [esp + 12] /* ecx = n */ + mov edi, [esp + 16] /* edi = d */ + mov edx, [esp + 20] /* edx = m */ + mov esi, [esp + 24] /* esi = s */ + + test ecx, ecx + jz _asm_transform_points4_2d_end + + push ebx + +.align 4 +_asm_transform_points4_2d_loop: + fld S(0) + fmul M(0, 0) + fld S(0) + fmul M(0, 1) + fld S(1) + fmul M(1, 0) + fld S(1) + fmul M(1, 1) + fld S(3) + fmul M(3, 0) + fld S(3) + fmul M(3, 1) + + /* + * st(5) = S(0) * M(0, 0) + * st(4) = S(0) * M(0, 1) + * st(3) = S(1) * M(1, 0) + * st(2) = S(1) * M(1, 1) + * st(1) = S(3) * M(3, 0) + * st(0) = S(3) * M(3, 1) + */ + + mov eax, S(2) + mov ebx, S(3) + lea esi, S(4) + dec ecx + mov D(2), eax + mov D(3), ebx + faddp st(4), st + faddp st(4), st + faddp st(2), st + faddp st(2), st + fstp D(1) + fstp D(0) + lea edi, D(4) + jnz _asm_transform_points4_2d_loop + + pop ebx + +_asm_transform_points4_2d_end: + pop edi + pop esi + ret + + + +/* + * void asm_transform_points4_2d_no_rot( GLuint n, GLfloat d[][4], + * GLfloat m[16], GLfloat s[][4] ); + */ +PUBLIC _asm_transform_points4_2d_no_rot +_asm_transform_points4_2d_no_rot: +.align 4 + push esi + push edi + mov ecx, [esp + 12] /* ecx = n */ + mov edi, [esp + 16] /* edi = d */ + mov edx, [esp + 20] /* edx = m */ + mov esi, [esp + 24] /* esi = s */ + + test ecx, ecx + jz _asm_transform_points4_2d_no_rot_end + push ebx + +.align 4 +_asm_transform_points4_2d_no_rot_loop: + fld S(0) + fmul M(0, 0) + fld S(1) + fmul M(1, 1) + fld S(3) + fmul M(3, 0) + fld S(3) + fmul M(3, 1) + mov eax, S(2) + mov ebx, S(3) + lea esi, S(4) + dec ecx + mov D(2), eax + mov D(3), ebx + faddp st(2), st + faddp st(2), st + fstp D(1) + fstp D(0) + lea edi, D(4) + jnz _asm_transform_points4_2d_no_rot_loop + + pop ebx + +_asm_transform_points4_2d_no_rot_end: + pop edi + pop esi + ret + + + +/* + * void asm_transform_points4_3d( GLuint n, GLfloat d[][4], GLfloat m[16], + * GLfloat s[][4] ); + */ +PUBLIC _asm_transform_points4_3d +_asm_transform_points4_3d: +.align 4 + push esi + push edi + mov ecx, [esp + 12] /* ecx = n */ + mov edi, [esp + 16] /* edi = d */ + mov edx, [esp + 20] /* edx = m */ + mov esi, [esp + 24] /* esi = s */ + + test ecx, ecx + jz _asm_transform_points4_3d_end + +.align 4 +_asm_transform_points4_3d_loop: + fld S(3) + + fld S(0) + fmul M(0, 0) + fld S(0) + fmul M(0, 1) + fld S(0) + fmul M(0, 2) + + fld S(1) + fmul M(1, 0) + fld S(1) + fmul M(1, 1) + fld S(1) + fmul M(1, 2) + + /* + * st(5) = S(0) * M(0, 0) + * st(4) = S(0) * M(0, 1) + * st(3) = S(0) * M(0, 2) + * st(2) = S(1) * M(1, 0) + * st(1) = S(1) * M(1, 1) + * st(0) = S(1) * M(1, 2) + */ + + fxch st(2) /* 2 1 0 3 4 5 */ + faddp st(5), st /* 1 0 3 4 5 */ + faddp st(3), st /* 0 3 4 5 */ + faddp st(1), st /* 3 4 5 */ + + /* + * st(2) = S(0) * M(0, 0) + S(1) * M(1, 0) + * st(1) = S(0) * M(0, 1) + S(1) * M(1, 1) + * st(0) = S(0) * M(0, 2) + S(1) * M(1, 2) + */ + + fld S(2) + fmul M(2, 0) + fld S(2) + fmul M(2, 1) + fld S(2) + fmul M(2, 2) + + /* + * st(5) = S(0) * M(0, 0) + S(1) * M(1, 0) + * st(4) = S(0) * M(0, 1) + S(1) * M(1, 1) + * st(3) = S(0) * M(0, 2) + S(1) * M(1, 2) + * st(2) = S(2) * M(2, 0) + * st(1) = S(2) * M(2, 1) + * st(0) = S(2) * M(2, 2) + */ + + fxch st(2) /* 2 1 0 3 4 5 */ + faddp st(5), st /* 1 0 3 4 5 */ + faddp st(3), st /* 0 3 4 5 */ + faddp st(1), st /* 3 4 5 */ + + /* + * st(2) = S(0) * M(0, 0) + S(1) * M(1, 0) + S(2) * M(2, 0) + * st(1) = S(0) * M(0, 1) + S(1) * M(1, 1) + S(2) * M(2, 1) + * st(0) = S(0) * M(0, 2) + S(1) * M(1, 2) + S(2) * M(2, 2) + */ + + fld S(3) + fmul M(3, 0) + fld S(3) + fmul M(3, 1) + fld S(3) + fmul M(3, 2) + + /* + * st(5) = S(0) * M(0, 0) + S(1) * M(1, 0) + S(2) * M(2, 0) + * st(4) = S(0) * M(0, 1) + S(1) * M(1, 1) + S(2) * M(2, 1) + * st(3) = S(0) * M(0, 2) + S(1) * M(1, 2) + S(2) * M(2, 2) + * st(2) = S(3) * M(3, 0) + * st(1) = S(3) * M(3, 1) + * st(0) = S(3) * M(3, 2) + */ + + fxch st(2) /* 2 1 0 3 4 5 */ + faddp st(5), st /* 1 0 3 4 5 */ + faddp st(3), st /* 0 3 4 5 */ + + lea esi, S(4) + dec ecx + + faddp st(1), st /* 3 4 5 */ + + /* + * st(2) = S(0) * M(0, 0) + S(1) * M(1, 0) + S(2) * M(2, 0) + S(3) * M(3, 0) + * st(1) = S(0) * M(0, 1) + S(1) * M(1, 1) + S(2) * M(2, 1) + S(3) * M(3, 1) + * st(0) = S(0) * M(0, 2) + S(1) * M(1, 2) + S(2) * M(2, 2) + S(3) * M(3, 2) + */ + + fxch st(2) /* 2 1 0 */ + fstp D(0) /* 1 0 */ + fstp D(1) /* 0 */ + fstp D(2) /* */ + fstp D(3) + + lea edi, D(4) + + jnz _asm_transform_points4_3d_loop + +_asm_transform_points4_3d_end: + pop edi + pop esi + ret + +/* + * void asm_transform_points4_ortho( GLuint n, GLfloat d[][4], + * GLfloat m[16], GLfloat s[][4] ); + */ +PUBLIC _asm_transform_points4_ortho +_asm_transform_points4_ortho: +.align 4 + push esi + push edi + mov ecx, [esp + 12] /* ecx = n */ + mov edi, [esp + 16] /* edi = d */ + mov edx, [esp + 20] /* edx = m */ + mov esi, [esp + 24] /* esi = s */ + + test ecx, ecx + jz _asm_transform_points4_ortho_end + +.align 4 +_asm_transform_points4_ortho_loop: + fld S(0) + fmul M(0, 0) + fld S(1) + fmul M(1, 1) + fld S(2) + fmul M(2, 2) + + fld S(3) + fmul M(3, 0) + fld S(3) + fmul M(3, 1) + fld S(3) + fmul M(3, 2) + + mov eax, S(3) + lea esi, S(4) + dec ecx + mov D(3), eax + + faddp st(3), st + faddp st(3), st + faddp st(3), st + + fstp D(2) + fstp D(1) + fstp D(0) + + lea edi, D(4) + jnz _asm_transform_points4_ortho_loop + +_asm_transform_points4_ortho_end: + pop edi + pop esi + ret + +/* + * void asm_transform_points4_perspective( GLuint n, GLfloat d[][4], + * GLfloat m[16], GLfloat s[][4] ); + */ +PUBLIC _asm_transform_points4_perspective +_asm_transform_points4_perspective: +.align 4 + push esi + push edi + mov ecx, [esp + 12] /* ecx = n */ + mov edi, [esp + 16] /* edi = d */ + mov edx, [esp + 20] /* edx = m */ + mov esi, [esp + 24] /* esi = s */ + + test ecx, ecx + jz _asm_transform_points4_perspective_end + +.align 4 +_asm_transform_points4_perspective_loop: + fld S(0) + fmul M(0, 0) + fld S(1) + fmul M(1, 1) + fld S(2) + fmul M(2, 2) + + fld S(2) + fmul M(2, 0) + fld S(2) + fmul M(2, 1) + fld S(3) + fmul M(3, 2) + + mov eax, S(2) + lea esi, S(4) + xor eax, HEX(80000000) + dec ecx + + faddp st(3), st + faddp st(3), st + faddp st(3), st + + fstp D(2) + fstp D(1) + fstp D(0) + + mov D(3), eax + lea edi, D(4) + jnz _asm_transform_points4_perspective_loop + +_asm_transform_points4_perspective_end: + pop edi + pop esi + ret + + + +/* + * Table for clip test. + * + * bit6 = S(3) < 0 + * bit5 = S(2) < 0 + * bit4 = abs(S(2)) > abs(S(3)) + * bit3 = S(1) < 0 + * bit2 = abs(S(1)) > abs(S(3)) + * bit1 = S(0) < 0 + * bit0 = abs(S(0)) > abs(S(3)) + */ + +/* Vertex buffer clipping flags (from vb.h) */ +#if 0 + +#define CLIP_RIGHT_BIT 0x01 +#define CLIP_LEFT_BIT 0x02 +#define CLIP_TOP_BIT 0x04 +#define CLIP_BOTTOM_BIT 0x08 +#define CLIP_NEAR_BIT 0x10 +#define CLIP_FAR_BIT 0x20 +#define CLIP_USER_BIT 0x40 +#define CLIP_ALL_BITS 0x3f + +#define MAGN_X(i) (~(((i) & 1) - 1)) +#define SIGN_X(i) (~((((i) >> 1) & 1) - 1)) +#define MAGN_Y(i) (~((((i) >> 2) & 1) - 1)) +#define SIGN_Y(i) (~((((i) >> 3) & 1) - 1)) +#define MAGN_Z(i) (~((((i) >> 4) & 1) - 1)) +#define SIGN_Z(i) (~((((i) >> 5) & 1) - 1)) +#define SIGN_W(i) (~((((i) >> 6) & 1) - 1)) + +#define CLIP_VALUE(i) \ + (CLIP_RIGHT_BIT \ + & ((~SIGN_X(i) & SIGN_W(i)) \ + | (~SIGN_X(i) & ~SIGN_W(i) & MAGN_X(i)) \ + | (SIGN_X(i) & SIGN_W(i) & ~MAGN_X(i)))) \ + | (CLIP_LEFT_BIT \ + & ((SIGN_X(i) & SIGN_W(i)) \ + | (~SIGN_X(i) & SIGN_W(i) & ~MAGN_X(i)) \ + | (SIGN_X(i) & ~SIGN_W(i) & MAGN_X(i)))) \ + | (CLIP_TOP_BIT \ + & ((~SIGN_Y(i) & SIGN_W(i)) \ + | (~SIGN_Y(i) & ~SIGN_W(i) & MAGN_Y(i)) \ + | (SIGN_Y(i) & SIGN_W(i) & ~MAGN_Y(i)))) \ + | (CLIP_BOTTOM_BIT \ + & ((SIGN_Y(i) & SIGN_W(i)) \ + | (~SIGN_Y(i) & SIGN_W(i) & ~MAGN_Y(i)) \ + | (SIGN_Y(i) & ~SIGN_W(i) & MAGN_Y(i)))) \ + | (CLIP_FAR_BIT \ + & ((~SIGN_Z(i) & SIGN_W(i)) \ + | (~SIGN_Z(i) & ~SIGN_W(i) & MAGN_Z(i)) \ + | (SIGN_Z(i) & SIGN_W(i) & ~MAGN_Z(i)))) \ + | (CLIP_NEAR_BIT \ + & ((SIGN_Z(i) & SIGN_W(i)) \ + | (~SIGN_Z(i) & SIGN_W(i) & ~MAGN_Z(i)) \ + | (SIGN_Z(i) & ~SIGN_W(i) & MAGN_Z(i)))) + +#define CLIP_VALUE8(i) \ + CLIP_VALUE(i + 0), CLIP_VALUE(i + 1), CLIP_VALUE(i + 2), CLIP_VALUE(i + 3), \ + CLIP_VALUE(i + 4), CLIP_VALUE(i + 5), CLIP_VALUE(i + 6), CLIP_VALUE(i + 7) + +.rodata + +clip_table: + .byte CLIP_VALUE8(0x00) + .byte CLIP_VALUE8(0x08) + .byte CLIP_VALUE8(0x10) + .byte CLIP_VALUE8(0x18) + .byte CLIP_VALUE8(0x20) + .byte CLIP_VALUE8(0x28) + .byte CLIP_VALUE8(0x30) + .byte CLIP_VALUE8(0x38) + .byte CLIP_VALUE8(0x40) + .byte CLIP_VALUE8(0x48) + .byte CLIP_VALUE8(0x50) + .byte CLIP_VALUE8(0x58) + .byte CLIP_VALUE8(0x60) + .byte CLIP_VALUE8(0x68) + .byte CLIP_VALUE8(0x70) + .byte CLIP_VALUE8(0x78) +#else + +.const +ASSUME NOTHING + +clip_table: + .byte HEX(0), HEX(1), HEX(0), HEX(2), HEX(4), HEX(5), HEX(4), HEX(6) + .byte HEX(0), HEX(1), HEX(0), HEX(2), HEX(8), HEX(9), HEX(8), HEX(a) + .byte HEX(20), HEX(21), HEX(20), HEX(22), HEX(24), HEX(25), HEX(24), HEX(26) + .byte HEX(20), HEX(21), HEX(20), HEX(22), HEX(28), HEX(29), HEX(28), HEX(2a) + .byte HEX(0), HEX(1), HEX(0), HEX(2), HEX(4), HEX(5), HEX(4), HEX(6) + .byte HEX(0), HEX(1), HEX(0), HEX(2), HEX(8), HEX(9), HEX(8), HEX(a) + .byte HEX(10), HEX(11), HEX(10), HEX(12), HEX(14), HEX(15), HEX(14), HEX(16) + .byte HEX(10), HEX(11), HEX(10), HEX(12), HEX(18), HEX(19), HEX(18), HEX(1a) + .byte HEX(3f), HEX(3d), HEX(3f), HEX(3e), HEX(37), HEX(35), HEX(37), HEX(36) + .byte HEX(3f), HEX(3d), HEX(3f), HEX(3e), HEX(3b), HEX(39), HEX(3b), HEX(3a) + .byte HEX(2f), HEX(2d), HEX(2f), HEX(2e), HEX(27), HEX(25), HEX(27), HEX(26) + .byte HEX(2f), HEX(2d), HEX(2f), HEX(2e), HEX(2b), HEX(29), HEX(2b), HEX(2a) + .byte HEX(3f), HEX(3d), HEX(3f), HEX(3e), HEX(37), HEX(35), HEX(37), HEX(36) + .byte HEX(3f), HEX(3d), HEX(3f), HEX(3e), HEX(3b), HEX(39), HEX(3b), HEX(3a) + .byte HEX(1f), HEX(1d), HEX(1f), HEX(1e), HEX(17), HEX(15), HEX(17), HEX(16) + .byte HEX(1f), HEX(1d), HEX(1f), HEX(1e), HEX(1b), HEX(19), HEX(1b), HEX(1a) + +#endif + +.code + +/* + * cliptest - + * + * inputs: + * ecx = # points + * esi = points + * edi = clipmask[] + * + * inputs/outputs: + * al = ormask + * ah = andmask + */ + +cliptest: + test ecx, ecx + jz cliptest_end + + push ebp + push ebx + +.align 4 +cliptest_loop: + mov ebp, S(3) + mov ebx, S(2) + + xor edx, edx + add ebp, ebp /* %ebp = abs(S(3))*2 ; carry = sign of S(3) */ + + adc edx, edx + add ebx, ebx /* %ebx = abs(S(2))*2 ; carry = sign of S(2) */ + + adc edx, edx + cmp ebp, ebx /* carry = abs(S(2))*2 > abs(S(3))*2 */ + + adc edx, edx + mov ebx, S(1) + + add ebx, ebx /* %ebx = abs(S(1))*2 ; carry = sign of S(1) */ + + adc edx, edx + cmp ebp, ebx /* carry = abs(S(1))*2 > abs(S(3))*2 */ + + adc edx, edx + mov ebx, S(0) + + add ebx, ebx /* %ebx = abs(S(0))*2 ; carry = sign of S(0) */ + + adc edx, edx + cmp ebp, ebx /* carry = abs(S(0))*2 > abs(S(3))*2 */ + + adc edx, edx + + lea esi, S(4) + + mov bl, byte ptr [edi] + mov dl, byte ptr [clip_table + edx] + + or bl, dl + or al, dl + + and ah, dl + mov [edi], bl + + inc edi + dec ecx + + jnz cliptest_loop + + pop ebx + pop ebp +cliptest_end: + ret + +/* + * void asm_project_and_cliptest_general( GLuint n, GLfloat d[][4], GLfloat m[16], + * GLfloat s[][4], GLubyte clipmask[], + * GLubyte *ormask, GLubyte *andmask ); + */ +PUBLIC _asm_project_and_cliptest_general +_asm_project_and_cliptest_general: +.align 4 + push esi + push edi + mov ecx, [esp + 12] /* ecx = n */ + mov edi, [esp + 16] /* edi = d */ + mov edx, [esp + 20] /* edx = m */ + mov esi, [esp + 24] /* esi = s */ + + push esi + push edx + push edi + push ecx + call _asm_transform_points4_general + add esp, DEC(16) + + mov edi, [esp + 32] /* ormask */ + mov esi, [esp + 36] /* andmask */ + mov al, [edi] + mov ah, [esi] + + mov ecx, [esp + 12] /* ecx = n */ + mov edi, [esp + 28] /* edi = clipmask */ + mov esi, [esp + 16] /* esi = d */ + + call cliptest + + mov edi, [esp + 32] /* ormask */ + mov esi, [esp + 36] /* andmask */ + mov [edi], al + mov [esi], ah + + pop edi + pop esi + ret + + +/* + * void asm_project_and_cliptest_identity( GLuint n, GLfloat d[][4], + * GLfloat s[][4], GLubyte clipmask[], + * GLubyte *ormask, GLubyte *andmask ); + */ +PUBLIC _asm_project_and_cliptest_identity +_asm_project_and_cliptest_identity: +.align 4 + push esi + push edi + mov ecx, [esp + 12] /* ecx = n */ + mov edi, [esp + 16] /* edi = d */ + mov esi, [esp + 20] /* esi = s */ + + push esi + push edi + push ecx + + call _asm_transform_points4_identity + + add esp, DEC(12) + + mov edi, [esp + 28] /* ormask */ + mov esi, [esp + 32] /* andmask */ + mov al, [edi] + mov ah, [esi] + + mov ecx, [esp + 12] /* ecx = n */ + mov edi, [esp + 24] /* edi = clipmask */ + mov esi, [esp + 16] /* esi = d */ + + call cliptest + + mov edi, [esp + 28] /* ormask */ + mov esi, [esp + 32] /* andmask */ + mov [edi], al + mov [esi], ah + + pop edi + pop esi + ret + +/* + * void asm_project_and_cliptest_ortho( GLuint n, GLfloat d[][4], GLfloat m[16], + * GLfloat s[][4], GLubyte clipmask[], + * GLubyte *ormask, GLubyte *andmask ); + */ +PUBLIC _asm_project_and_cliptest_ortho +_asm_project_and_cliptest_ortho: +.align 4 + push esi + push edi + mov ecx, [esp + 12] /* ecx = n */ + mov edi, [esp + 16] /* edi = d */ + mov edx, [esp + 20] /* edx = m */ + mov esi, [esp + 24] /* esi = s */ + + push esi + push edx + push edi + push ecx + + call _asm_transform_points4_ortho + + add esp, DEC(16) + + mov edi, [esp + 32] /* ormask */ + mov esi, [esp + 36] /* andmask */ + mov al, [edi] + mov ah, [esi] + + mov ecx, [esp + 12] /* ecx = n */ + mov edi, [esp + 28] /* edi = clipmask */ + mov esi, [esp + 16] /* esi = d */ + + call cliptest + + mov edi, [esp + 32] /* ormask */ + mov esi, [esp + 36] /* andmask */ + mov [edi], al + mov [esi], ah + + pop edi + pop esi + ret + +/* + * void asm_project_and_cliptest_perspective( GLuint n, GLfloat d[][4], GLfloat m[16], + * GLfloat s[][4], GLubyte clipmask[], + * GLubyte *ormask, GLubyte *andmask ); + */ +PUBLIC _asm_project_and_cliptest_perspective +_asm_project_and_cliptest_perspective: +.align 4 + push esi + push edi + mov ecx, [esp + 12] /* ecx = n */ + mov edi, [esp + 16] /* edi = d */ + mov edx, [esp + 20] /* edx = m */ + mov esi, [esp + 24] /* esi = s */ + + push esi + push edx + push edi + push ecx + + call _asm_transform_points4_perspective + + add esp, DEC(16) + + mov edi, [esp + 32] /* ormask */ + mov esi, [esp + 36] /* andmask */ + mov al, [edi] + mov ah, [esi] + + mov ecx, [esp + 12] /* ecx = n */ + mov edi, [esp + 28] /* edi = clipmask */ + mov esi, [esp + 16] /* esi = d */ + + call cliptest + + mov edi, [esp + 32] /* ormask */ + mov esi, [esp + 36] /* andmask */ + mov byte ptr [edi], al + mov byte ptr [esi], ah + + pop edi + pop esi + ret + + +/* + * unsigned int inverse_nofp( float f ); + * + * Calculate the inverse of a float without using the FPU. + * This function returns a float in eax, so it's return + * type should be 'int' when called from C (and converted + * to float with pointer/union abuse). + */ +.align 4 +inverse_nofp: + + /* get mantissa in eax */ + mov ecx, [esp + 4] + and ecx, HEX(7fffff) + + /* set implicit integer */ + or ecx, HEX(800000) + + /* div 0x10000:0x00000000 by mantissa */ + xor eax, eax + mov edx, HEX(10000) + + div ecx + + /* round result */ + shr eax, DEC(1) + adc eax, DEC(0) + + /* get exponent in ecx */ + mov ecx, HEX(7f800000) + mov edx, [esp + 4] + and ecx, edx + + /* negate exponent and decrement it */ + mov edx, HEX(7E800000) + sub edx, ecx + + /* if bit 24 is set, shift and adjust exponent */ + test eax, HEX(1000000) + jz inverse_nofp_combine + + shr eax, HEX(1) + add edx, HEX(800000) + + /* combine mantissa and exponent, then set sign */ +inverse_nofp_combine: + and eax, HEX(7fffff) + mov ecx, [esp + 4] + or eax, edx + and ecx, HEX(80000000) + or eax, ecx + + ret + + +/* + * void gl_xform_normals_3fv( GLuint n, GLfloat d[][4], GLfloat m[16], + * GLfloat s[][4], GLboolean normalize ); + */ +PUBLIC _gl_xform_normals_3fv +_gl_xform_normals_3fv: +.align 4 + push esi + push edi + mov ecx, [esp + 12] /* ecx = n */ + mov edi, [esp + 16] /* edi = d */ + mov edx, [esp + 20] /* edx = m */ + mov esi, [esp + 24] /* esi = s */ + + test ecx, ecx + jz _gl_xform_normals_3fv_end + +.align 4 +_gl_xform_normals_3fv_loop: + fld S(0) + fmul M(0, 0) + fld S(0) + fmul M(1, 0) + fld S(0) + fmul M(2, 0) + + fld S(1) + fmul M(0, 1) + fld S(1) + fmul M(1, 1) + fld S(1) + fmul M(2, 1) + + /* + * st(5) = S(0) * M(0, 0) + * st(4) = S(0) * M(1, 0) + * st(3) = S(0) * M(2, 0) + * st(2) = S(1) * M(0, 1) + * st(1) = S(1) * M(1, 1) + * st(0) = S(1) * M(2, 1) + */ + + fxch st(2) /* 2 1 0 3 4 5 */ + faddp st(5), st /* 1 0 3 4 5 */ + faddp st(3), st /* 0 3 4 5 */ + faddp st(1), st /* 3 4 5 */ + + /* + * st(2) = S(0) * M(0, 0) + S(1) * M(0, 1) + * st(1) = S(0) * M(1, 0) + S(1) * M(1, 1) + * st(0) = S(0) * M(2, 0) + S(1) * M(2, 1) + */ + + fld S(2) + fmul M(0, 2) + fld S(2) + fmul M(1, 2) + fld S(2) + fmul M(2, 2) + + /* + * st(5) = S(0) * M(0, 0) + S(1) * M(0, 1) + * st(4) = S(0) * M(1, 0) + S(1) * M(1, 1) + * st(3) = S(0) * M(2, 0) + S(1) * M(2, 1) + * st(2) = S(2) * M(0, 2) + * st(1) = S(2) * M(1, 2) + * st(0) = S(2) * M(2, 2) + */ + + fxch st(2) /* 2 1 0 3 4 5 */ + faddp st(5), st /* 1 0 3 4 5 */ + faddp st(3), st /* 0 3 4 5 */ + faddp st(1), st /* 3 4 5 */ + + /* + * st(2) = S(0) * M(0, 0) + S(1) * M(0, 1) + S(2) * M(0, 2) + * st(1) = S(0) * M(1, 0) + S(1) * M(1, 1) + S(2) * M(1, 2) + * st(0) = S(0) * M(2, 0) + S(1) * M(2, 1) + S(2) * M(2, 2) + */ + + fxch st(2) /* 2 1 0 */ + fstp D(0) /* 1 0 */ + fstp D(1) /* 0 */ + fstp D(2) /* */ + + lea esi, S(3) + + dec ecx + lea edi, D(3) + + jnz _gl_xform_normals_3fv_loop + + /* + * Skip normalize if it isn't needed + */ + cmp dword ptr [esp + 28], DEC(0) + jz _gl_xform_normals_3fv_end + + /* Normalize required */ + + mov esi, [esp + 12] /* esi = n */ + mov edi, [esp + 16] /* edi = d */ + + sub esp, DEC(4) /* temp var for 1.0 / len */ + + /* + * (%esp) = length of first normal + */ + fld D(0) + fmul D(0) + fld D(1) + fmul D(1) + fld D(2) + fmul D(2) + fxch st(2) + faddp st(1), st + faddp st(1), st + fsqrt + fstp dword ptr [esp] + + jmp _gl_xform_normals_3fv_loop2_end + +.align 4 +_gl_xform_normals_3fv_loop2: + /* %st(0) = length of next normal */ + fld D(3) + fmul D(3) + fld D(4) + fmul D(4) + fld D(5) + fmul D(5) + fxch st(2) + faddp st(1), st + faddp st(1), st + fsqrt + + /* + * inverse the length of the current normal, which is + * already at (%esp). This should overlap the prev + * fsqrt nicely. + */ + call inverse_nofp + mov [esp], eax + + /* multiply normal by 1/len */ + fld D(0) + fmul dword ptr [esp] + fld D(1) + fmul dword ptr [esp] + fld D(2) + fmul dword ptr [esp] + fxch st(3) + fstp dword ptr [esp] /* store length of next normal */ + fstp D(1) + fstp D(0) + fstp D(2) + lea edi, D(3) + +_gl_xform_normals_3fv_loop2_end: + dec esi + jnz _gl_xform_normals_3fv_loop2 + + /* finish up the last normal */ + call inverse_nofp + mov [esp], eax + fld D(0) + fmul dword ptr [esp] + fld D(1) + fmul dword ptr [esp] + fld D(2) + fmul dword ptr [esp] + fxch st(2) + fstp D(0) + fstp D(1) + fstp D(2) + + add esp, DEC(4) + +_gl_xform_normals_3fv_end: + pop edi + pop esi + ret + +END diff --git a/dll/opengl/mesa/asm-386.h b/dll/opengl/mesa/asm-386.h new file mode 100644 index 00000000000..fa4ba51cc67 --- /dev/null +++ b/dll/opengl/mesa/asm-386.h @@ -0,0 +1,99 @@ +/* $Id: asm-386.h,v 1.1 1997/12/15 03:39:14 brianp Exp $ */ + +/* + * Mesa 3-D graphics library + * Version: 2.6 + * Copyright (C) 1995-1997 Brian Paul + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Library General Public + * License as published by the Free Software Foundation; either + * version 2 of the License, or (at your option) any later version. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Library General Public License for more details. + * + * You should have received a copy of the GNU Library General Public + * License along with this library; if not, write to the Free + * Software Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. + */ + + +/* + * $Log: asm-386.h,v $ + * Revision 1.1 1997/12/15 03:39:14 brianp + * Initial revision + * + */ + + +#ifndef ASM_386_H +#define ASM_386_H + + +#include "GL/gl.h" + + +/* + * Prototypes for assembly functions. + */ + + +extern void asm_transform_points3_general( GLuint n, GLfloat d[][4], + GLfloat m[16], GLfloat s[][4] ); + +extern void asm_transform_points3_identity( GLuint n, GLfloat d[][4], + GLfloat s[][4] ); + +extern void asm_transform_points3_2d( GLuint n, GLfloat d[][4], + GLfloat m[16], GLfloat s[][4] ); + +extern void asm_transform_points3_2d_no_rot( GLuint n, GLfloat d[][4], + GLfloat m[16], GLfloat s[][4] ); + +extern void asm_transform_points3_3d( GLuint n, GLfloat d[][4], GLfloat m[16], + GLfloat s[][4] ); + +extern void asm_transform_points4_general( GLuint n, GLfloat d[][4], + GLfloat m[16], GLfloat s[][4] ); + +extern void asm_transform_points4_identity( GLuint n, GLfloat d[][4], + GLfloat s[][4] ); + +extern void asm_transform_points4_2d( GLuint n, GLfloat d[][4], GLfloat m[16], + GLfloat s[][4] ); + +extern void asm_transform_points4_2d_no_rot( GLuint n, GLfloat d[][4], + GLfloat m[16], GLfloat s[][4] ); + +extern void asm_transform_points4_3d( GLuint n, GLfloat d[][4], GLfloat m[16], + GLfloat s[][4] ); + +extern void asm_transform_points4_ortho( GLuint n, GLfloat d[][4], + GLfloat m[16], GLfloat s[][4] ); + +extern void asm_transform_points4_perspective( GLuint n, GLfloat d[][4], + GLfloat m[16], GLfloat s[][4] ); + +extern void asm_project_and_cliptest_general( GLuint n, GLfloat d[][4], + GLfloat m[16], + GLfloat s[][4], GLubyte clipmask[], + GLubyte *ormask, GLubyte *andmask ); + +extern void asm_project_and_cliptest_identity( GLuint n, GLfloat d[][4], + GLfloat s[][4], GLubyte clipmask[], + GLubyte *ormask, GLubyte *andmask ); + +extern void asm_project_and_cliptest_ortho( GLuint n, GLfloat d[][4], + GLfloat m[16], + GLfloat s[][4], GLubyte clipmask[], + GLubyte *ormask, GLubyte *andmask ); + +extern void asm_project_and_cliptest_perspective( GLuint n, GLfloat d[][4], + GLfloat m[16], + GLfloat s[][4], GLubyte clipmask[], + GLubyte *ormask, GLubyte *andmask ); + +#endif diff --git a/dll/opengl/mesa/attrib.c b/dll/opengl/mesa/attrib.c new file mode 100644 index 00000000000..79cd928886c --- /dev/null +++ b/dll/opengl/mesa/attrib.c @@ -0,0 +1,624 @@ +/* $Id: attrib.c,v 1.9 1997/07/24 01:24:28 brianp Exp $ */ + +/* + * Mesa 3-D graphics library + * Version: 2.4 + * Copyright (C) 1995-1997 Brian Paul + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Library General Public + * License as published by the Free Software Foundation; either + * version 2 of the License, or (at your option) any later version. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Library General Public License for more details. + * + * You should have received a copy of the GNU Library General Public + * License along with this library; if not, write to the Free + * Software Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. + */ + + +/* + * $Log: attrib.c,v $ + * Revision 1.9 1997/07/24 01:24:28 brianp + * changed precompiled header symbol from PCH to PC_HEADER + * + * Revision 1.8 1997/05/28 03:23:09 brianp + * added precompiled header (PCH) support + * + * Revision 1.7 1997/04/20 19:49:57 brianp + * replaced abort() calls with gl_problem() + * + * Revision 1.6 1997/04/01 04:18:28 brianp + * removed #include "draw.h" + * + * Revision 1.5 1997/01/28 22:13:02 brianp + * now there's separate state for CI and RGBA logic op enabled + * + * Revision 1.4 1996/10/01 03:30:01 brianp + * added #include "misc.h" + * + * Revision 1.3 1996/09/30 23:55:06 brianp + * call gl_DrawBuffer() when glPopAttrib(GL_COLOR_BUFFER_BIT) + * + * Revision 1.2 1996/09/27 01:24:14 brianp + * removed unused variables + * + * Revision 1.1 1996/09/13 01:38:16 brianp + * Initial revision + * + */ + + +#ifdef PC_HEADER +#include "all.h" +#else +#include +#include +#include "attrib.h" +#include "context.h" +#include "dlist.h" +#include "macros.h" +#include "misc.h" +#include "types.h" +#endif + + +#define MALLOC_STRUCT(T) (struct T *) malloc( sizeof(struct T) ) + + + +static struct gl_attrib_node *new_attrib_node( GLbitfield kind ) +{ + struct gl_attrib_node *an; + + an = (struct gl_attrib_node *) malloc( sizeof(struct gl_attrib_node) ); + if (an) { + an->kind = kind; + } + return an; +} + + + +void gl_PushAttrib( GLcontext* ctx, GLbitfield mask ) +{ + struct gl_attrib_node *newnode; + struct gl_attrib_node *head; + + if (INSIDE_BEGIN_END(ctx)) { + gl_error( ctx, GL_INVALID_OPERATION, "glPushAttrib" ); + return; + } + + if (ctx->AttribStackDepth>=MAX_ATTRIB_STACK_DEPTH) { + gl_error( ctx, GL_STACK_OVERFLOW, "glPushAttrib" ); + return; + } + + /* Build linked list of attribute nodes which save all attribute */ + /* groups specified by the mask. */ + head = NULL; + + if (mask & GL_ACCUM_BUFFER_BIT) { + struct gl_accum_attrib *attr; + + attr = MALLOC_STRUCT( gl_accum_attrib ); + MEMCPY( attr, &ctx->Accum, sizeof(struct gl_accum_attrib) ); + newnode = new_attrib_node( GL_ACCUM_BUFFER_BIT ); + newnode->data = attr; + newnode->next = head; + head = newnode; + } + + if (mask & GL_COLOR_BUFFER_BIT) { + struct gl_colorbuffer_attrib *attr; + attr = MALLOC_STRUCT( gl_colorbuffer_attrib ); + MEMCPY( attr, &ctx->Color, sizeof(struct gl_colorbuffer_attrib) ); + newnode = new_attrib_node( GL_COLOR_BUFFER_BIT ); + newnode->data = attr; + newnode->next = head; + head = newnode; + } + + if (mask & GL_CURRENT_BIT) { + struct gl_current_attrib *attr; + attr = MALLOC_STRUCT( gl_current_attrib ); + MEMCPY( attr, &ctx->Current, sizeof(struct gl_current_attrib) ); + newnode = new_attrib_node( GL_CURRENT_BIT ); + newnode->data = attr; + newnode->next = head; + head = newnode; + } + + if (mask & GL_DEPTH_BUFFER_BIT) { + struct gl_depthbuffer_attrib *attr; + attr = MALLOC_STRUCT( gl_depthbuffer_attrib ); + MEMCPY( attr, &ctx->Depth, sizeof(struct gl_depthbuffer_attrib) ); + newnode = new_attrib_node( GL_DEPTH_BUFFER_BIT ); + newnode->data = attr; + newnode->next = head; + head = newnode; + } + + if (mask & GL_ENABLE_BIT) { + struct gl_enable_attrib *attr; + GLuint i; + attr = MALLOC_STRUCT( gl_enable_attrib ); + /* Copy enable flags from all other attributes into the enable struct. */ + attr->AlphaTest = ctx->Color.AlphaEnabled; + attr->AutoNormal = ctx->Eval.AutoNormal; + attr->Blend = ctx->Color.BlendEnabled; + for (i=0;iClipPlane[i] = ctx->Transform.ClipEnabled[i]; + } + attr->ColorMaterial = ctx->Light.ColorMaterialEnabled; + attr->CullFace = ctx->Polygon.CullFlag; + attr->DepthTest = ctx->Depth.Test; + attr->Dither = ctx->Color.DitherFlag; + attr->Fog = ctx->Fog.Enabled; + for (i=0;iLight[i] = ctx->Light.Light[i].Enabled; + } + attr->Lighting = ctx->Light.Enabled; + attr->LineSmooth = ctx->Line.SmoothFlag; + attr->LineStipple = ctx->Line.StippleFlag; + attr->IndexLogicOp = ctx->Color.IndexLogicOpEnabled; + attr->ColorLogicOp = ctx->Color.ColorLogicOpEnabled; + attr->Map1Color4 = ctx->Eval.Map1Color4; + attr->Map1Index = ctx->Eval.Map1Index; + attr->Map1Normal = ctx->Eval.Map1Normal; + attr->Map1TextureCoord1 = ctx->Eval.Map1TextureCoord1; + attr->Map1TextureCoord2 = ctx->Eval.Map1TextureCoord2; + attr->Map1TextureCoord3 = ctx->Eval.Map1TextureCoord3; + attr->Map1TextureCoord4 = ctx->Eval.Map1TextureCoord4; + attr->Map1Vertex3 = ctx->Eval.Map1Vertex3; + attr->Map1Vertex4 = ctx->Eval.Map1Vertex4; + attr->Map2Color4 = ctx->Eval.Map2Color4; + attr->Map2Index = ctx->Eval.Map2Index; + attr->Map2Normal = ctx->Eval.Map2Normal; + attr->Map2TextureCoord1 = ctx->Eval.Map2TextureCoord1; + attr->Map2TextureCoord2 = ctx->Eval.Map2TextureCoord2; + attr->Map2TextureCoord3 = ctx->Eval.Map2TextureCoord3; + attr->Map2TextureCoord4 = ctx->Eval.Map2TextureCoord4; + attr->Map2Vertex3 = ctx->Eval.Map2Vertex3; + attr->Map2Vertex4 = ctx->Eval.Map2Vertex4; + attr->Normalize = ctx->Transform.Normalize; + attr->PointSmooth = ctx->Point.SmoothFlag; + attr->PolygonOffsetPoint = ctx->Polygon.OffsetPoint; + attr->PolygonOffsetLine = ctx->Polygon.OffsetLine; + attr->PolygonOffsetFill = ctx->Polygon.OffsetFill; + attr->PolygonSmooth = ctx->Polygon.SmoothFlag; + attr->PolygonStipple = ctx->Polygon.StippleFlag; + attr->Scissor = ctx->Scissor.Enabled; + attr->Stencil = ctx->Stencil.Enabled; + attr->Texture = ctx->Texture.Enabled; + attr->TexGen = ctx->Texture.TexGenEnabled; + newnode = new_attrib_node( GL_ENABLE_BIT ); + newnode->data = attr; + newnode->next = head; + head = newnode; + } + + if (mask & GL_EVAL_BIT) { + struct gl_eval_attrib *attr; + attr = MALLOC_STRUCT( gl_eval_attrib ); + MEMCPY( attr, &ctx->Eval, sizeof(struct gl_eval_attrib) ); + newnode = new_attrib_node( GL_EVAL_BIT ); + newnode->data = attr; + newnode->next = head; + head = newnode; + } + + if (mask & GL_FOG_BIT) { + struct gl_fog_attrib *attr; + attr = MALLOC_STRUCT( gl_fog_attrib ); + MEMCPY( attr, &ctx->Fog, sizeof(struct gl_fog_attrib) ); + newnode = new_attrib_node( GL_FOG_BIT ); + newnode->data = attr; + newnode->next = head; + head = newnode; + } + + if (mask & GL_HINT_BIT) { + struct gl_hint_attrib *attr; + attr = MALLOC_STRUCT( gl_hint_attrib ); + MEMCPY( attr, &ctx->Hint, sizeof(struct gl_hint_attrib) ); + newnode = new_attrib_node( GL_HINT_BIT ); + newnode->data = attr; + newnode->next = head; + head = newnode; + } + + if (mask & GL_LIGHTING_BIT) { + struct gl_light_attrib *attr; + attr = MALLOC_STRUCT( gl_light_attrib ); + MEMCPY( attr, &ctx->Light, sizeof(struct gl_light_attrib) ); + newnode = new_attrib_node( GL_LIGHTING_BIT ); + newnode->data = attr; + newnode->next = head; + head = newnode; + } + + if (mask & GL_LINE_BIT) { + struct gl_line_attrib *attr; + attr = MALLOC_STRUCT( gl_line_attrib ); + MEMCPY( attr, &ctx->Line, sizeof(struct gl_line_attrib) ); + newnode = new_attrib_node( GL_LINE_BIT ); + newnode->data = attr; + newnode->next = head; + head = newnode; + } + + if (mask & GL_LIST_BIT) { + struct gl_list_attrib *attr; + attr = MALLOC_STRUCT( gl_list_attrib ); + MEMCPY( attr, &ctx->List, sizeof(struct gl_list_attrib) ); + newnode = new_attrib_node( GL_LIST_BIT ); + newnode->data = attr; + newnode->next = head; + head = newnode; + } + + if (mask & GL_PIXEL_MODE_BIT) { + struct gl_pixel_attrib *attr; + attr = MALLOC_STRUCT( gl_pixel_attrib ); + MEMCPY( attr, &ctx->Pixel, sizeof(struct gl_pixel_attrib) ); + newnode = new_attrib_node( GL_PIXEL_MODE_BIT ); + newnode->data = attr; + newnode->next = head; + head = newnode; + } + + if (mask & GL_POINT_BIT) { + struct gl_point_attrib *attr; + attr = MALLOC_STRUCT( gl_point_attrib ); + MEMCPY( attr, &ctx->Point, sizeof(struct gl_point_attrib) ); + newnode = new_attrib_node( GL_POINT_BIT ); + newnode->data = attr; + newnode->next = head; + head = newnode; + } + + if (mask & GL_POLYGON_BIT) { + struct gl_polygon_attrib *attr; + attr = MALLOC_STRUCT( gl_polygon_attrib ); + MEMCPY( attr, &ctx->Polygon, sizeof(struct gl_polygon_attrib) ); + newnode = new_attrib_node( GL_POLYGON_BIT ); + newnode->data = attr; + newnode->next = head; + head = newnode; + } + + if (mask & GL_POLYGON_STIPPLE_BIT) { + GLuint *stipple; + stipple = (GLuint *) malloc( 32*sizeof(GLuint) ); + MEMCPY( stipple, ctx->PolygonStipple, 32*sizeof(GLuint) ); + newnode = new_attrib_node( GL_POLYGON_STIPPLE_BIT ); + newnode->data = stipple; + newnode->next = head; + head = newnode; + } + + if (mask & GL_SCISSOR_BIT) { + struct gl_scissor_attrib *attr; + attr = MALLOC_STRUCT( gl_scissor_attrib ); + MEMCPY( attr, &ctx->Scissor, sizeof(struct gl_scissor_attrib) ); + newnode = new_attrib_node( GL_SCISSOR_BIT ); + newnode->data = attr; + newnode->next = head; + head = newnode; + } + + if (mask & GL_STENCIL_BUFFER_BIT) { + struct gl_stencil_attrib *attr; + attr = MALLOC_STRUCT( gl_stencil_attrib ); + MEMCPY( attr, &ctx->Stencil, sizeof(struct gl_stencil_attrib) ); + newnode = new_attrib_node( GL_STENCIL_BUFFER_BIT ); + newnode->data = attr; + newnode->next = head; + head = newnode; + } + + if (mask & GL_TEXTURE_BIT) { + struct gl_texture_attrib *attr; + attr = MALLOC_STRUCT( gl_texture_attrib ); + MEMCPY( attr, &ctx->Texture, sizeof(struct gl_texture_attrib) ); + newnode = new_attrib_node( GL_TEXTURE_BIT ); + newnode->data = attr; + newnode->next = head; + head = newnode; + } + + if (mask & GL_TRANSFORM_BIT) { + struct gl_transform_attrib *attr; + attr = MALLOC_STRUCT( gl_transform_attrib ); + MEMCPY( attr, &ctx->Transform, sizeof(struct gl_transform_attrib) ); + newnode = new_attrib_node( GL_TRANSFORM_BIT ); + newnode->data = attr; + newnode->next = head; + head = newnode; + } + + if (mask & GL_VIEWPORT_BIT) { + struct gl_viewport_attrib *attr; + attr = MALLOC_STRUCT( gl_viewport_attrib ); + MEMCPY( attr, &ctx->Viewport, sizeof(struct gl_viewport_attrib) ); + newnode = new_attrib_node( GL_VIEWPORT_BIT ); + newnode->data = attr; + newnode->next = head; + head = newnode; + } + + /* etc... */ + + ctx->AttribStack[ctx->AttribStackDepth] = head; + ctx->AttribStackDepth++; +} + + + +void gl_PopAttrib( GLcontext* ctx ) +{ + struct gl_attrib_node *attr, *next; + struct gl_enable_attrib *enable; + GLuint i, oldDrawBuffer; + + if (INSIDE_BEGIN_END(ctx)) { + gl_error( ctx, GL_INVALID_OPERATION, "glPopAttrib" ); + return; + } + + if (ctx->AttribStackDepth==0) { + gl_error( ctx, GL_STACK_UNDERFLOW, "glPopAttrib" ); + return; + } + + ctx->AttribStackDepth--; + attr = ctx->AttribStack[ctx->AttribStackDepth]; + + while (attr) { + switch (attr->kind) { + case GL_ACCUM_BUFFER_BIT: + MEMCPY( &ctx->Accum, attr->data, sizeof(struct gl_accum_attrib) ); + break; + case GL_COLOR_BUFFER_BIT: + oldDrawBuffer = ctx->Color.DrawBuffer; + MEMCPY( &ctx->Color, attr->data, + sizeof(struct gl_colorbuffer_attrib) ); + if (ctx->Color.DrawBuffer != oldDrawBuffer) { + gl_DrawBuffer(ctx, ctx->Color.DrawBuffer); + } + break; + case GL_CURRENT_BIT: + MEMCPY( &ctx->Current, attr->data, + sizeof(struct gl_current_attrib) ); + break; + case GL_DEPTH_BUFFER_BIT: + MEMCPY( &ctx->Depth, attr->data, + sizeof(struct gl_depthbuffer_attrib) ); + break; + case GL_ENABLE_BIT: + enable = (struct gl_enable_attrib *) attr->data; + ctx->Color.AlphaEnabled = enable->AlphaTest; + ctx->Transform.Normalize = enable->AutoNormal; + ctx->Color.BlendEnabled = enable->Blend; + for (i=0;iTransform.ClipEnabled[i] = enable->ClipPlane[i]; + } + ctx->Light.ColorMaterialEnabled = enable->ColorMaterial; + ctx->Polygon.CullFlag = enable->CullFace; + ctx->Depth.Test = enable->DepthTest; + ctx->Color.DitherFlag = enable->Dither; + ctx->Fog.Enabled = enable->Fog; + ctx->Light.Enabled = enable->Lighting; + ctx->Line.SmoothFlag = enable->LineSmooth; + ctx->Line.StippleFlag = enable->LineStipple; + ctx->Color.IndexLogicOpEnabled = enable->IndexLogicOp; + ctx->Color.ColorLogicOpEnabled = enable->ColorLogicOp; + ctx->Eval.Map1Color4 = enable->Map1Color4; + ctx->Eval.Map1Index = enable->Map1Index; + ctx->Eval.Map1Normal = enable->Map1Normal; + ctx->Eval.Map1TextureCoord1 = enable->Map1TextureCoord1; + ctx->Eval.Map1TextureCoord2 = enable->Map1TextureCoord2; + ctx->Eval.Map1TextureCoord3 = enable->Map1TextureCoord3; + ctx->Eval.Map1TextureCoord4 = enable->Map1TextureCoord4; + ctx->Eval.Map1Vertex3 = enable->Map1Vertex3; + ctx->Eval.Map1Vertex4 = enable->Map1Vertex4; + ctx->Eval.Map2Color4 = enable->Map2Color4; + ctx->Eval.Map2Index = enable->Map2Index; + ctx->Eval.Map2Normal = enable->Map2Normal; + ctx->Eval.Map2TextureCoord1 = enable->Map2TextureCoord1; + ctx->Eval.Map2TextureCoord2 = enable->Map2TextureCoord2; + ctx->Eval.Map2TextureCoord3 = enable->Map2TextureCoord3; + ctx->Eval.Map2TextureCoord4 = enable->Map2TextureCoord4; + ctx->Eval.Map2Vertex3 = enable->Map2Vertex3; + ctx->Eval.Map2Vertex4 = enable->Map2Vertex4; + ctx->Transform.Normalize = enable->Normalize; + ctx->Point.SmoothFlag = enable->PointSmooth; + ctx->Polygon.OffsetPoint = enable->PolygonOffsetPoint; + ctx->Polygon.OffsetLine = enable->PolygonOffsetLine; + ctx->Polygon.OffsetFill = enable->PolygonOffsetFill; + ctx->Polygon.OffsetAny = ctx->Polygon.OffsetPoint || + ctx->Polygon.OffsetLine || + ctx->Polygon.OffsetFill; + ctx->Polygon.SmoothFlag = enable->PolygonSmooth; + ctx->Polygon.StippleFlag = enable->PolygonStipple; + ctx->Scissor.Enabled = enable->Scissor; + ctx->Stencil.Enabled = enable->Stencil; + ctx->Texture.Enabled = enable->Texture; + ctx->Texture.TexGenEnabled = enable->TexGen; + break; + case GL_EVAL_BIT: + MEMCPY( &ctx->Eval, attr->data, sizeof(struct gl_eval_attrib) ); + break; + case GL_FOG_BIT: + MEMCPY( &ctx->Fog, attr->data, sizeof(struct gl_fog_attrib) ); + break; + case GL_HINT_BIT: + MEMCPY( &ctx->Hint, attr->data, sizeof(struct gl_hint_attrib) ); + break; + case GL_LIGHTING_BIT: + MEMCPY( &ctx->Light, attr->data, sizeof(struct gl_light_attrib) ); + break; + case GL_LINE_BIT: + MEMCPY( &ctx->Line, attr->data, sizeof(struct gl_line_attrib) ); + break; + case GL_LIST_BIT: + MEMCPY( &ctx->List, attr->data, sizeof(struct gl_list_attrib) ); + break; + case GL_PIXEL_MODE_BIT: + MEMCPY( &ctx->Pixel, attr->data, sizeof(struct gl_pixel_attrib) ); + break; + case GL_POINT_BIT: + MEMCPY( &ctx->Point, attr->data, sizeof(struct gl_point_attrib) ); + break; + case GL_POLYGON_BIT: + MEMCPY( &ctx->Polygon, attr->data, + sizeof(struct gl_polygon_attrib) ); + break; + case GL_POLYGON_STIPPLE_BIT: + MEMCPY( ctx->PolygonStipple, attr->data, 32*sizeof(GLuint) ); + break; + case GL_SCISSOR_BIT: + MEMCPY( &ctx->Scissor, attr->data, + sizeof(struct gl_scissor_attrib) ); + break; + case GL_STENCIL_BUFFER_BIT: + MEMCPY( &ctx->Stencil, attr->data, + sizeof(struct gl_stencil_attrib) ); + break; + case GL_TRANSFORM_BIT: + MEMCPY( &ctx->Transform, attr->data, + sizeof(struct gl_transform_attrib) ); + break; + case GL_TEXTURE_BIT: + MEMCPY( &ctx->Texture, attr->data, + sizeof(struct gl_texture_attrib) ); + break; + case GL_VIEWPORT_BIT: + MEMCPY( &ctx->Viewport, attr->data, + sizeof(struct gl_viewport_attrib) ); + break; + default: + gl_problem( ctx, "Bad attrib flag in PopAttrib"); + break; + } + + next = attr->next; + free( (void *) attr->data ); + free( (void *) attr ); + attr = next; + } + + ctx->NewState = NEW_ALL; +} + + +#define GL_CLIENT_PACK_BIT (1<<20) +#define GL_CLIENT_UNPACK_BIT (1<<21) + + +void gl_PushClientAttrib( GLcontext *ctx, GLbitfield mask ) +{ + struct gl_attrib_node *newnode; + struct gl_attrib_node *head; + + if (INSIDE_BEGIN_END(ctx)) { + gl_error( ctx, GL_INVALID_OPERATION, "glPushClientAttrib" ); + return; + } + + if (ctx->ClientAttribStackDepth>=MAX_CLIENT_ATTRIB_STACK_DEPTH) { + gl_error( ctx, GL_STACK_OVERFLOW, "glPushClientAttrib" ); + return; + } + + /* Build linked list of attribute nodes which save all attribute */ + /* groups specified by the mask. */ + head = NULL; + + if (mask & GL_CLIENT_PIXEL_STORE_BIT) { + struct gl_pixelstore_attrib *attr; + /* packing attribs */ + attr = MALLOC_STRUCT( gl_pixelstore_attrib ); + MEMCPY( attr, &ctx->Pack, sizeof(struct gl_pixelstore_attrib) ); + newnode = new_attrib_node( GL_CLIENT_PACK_BIT ); + newnode->data = attr; + newnode->next = head; + head = newnode; + /* unpacking attribs */ + attr = MALLOC_STRUCT( gl_pixelstore_attrib ); + MEMCPY( attr, &ctx->Unpack, sizeof(struct gl_pixelstore_attrib) ); + newnode = new_attrib_node( GL_CLIENT_UNPACK_BIT ); + newnode->data = attr; + newnode->next = head; + head = newnode; + } + if (mask & GL_CLIENT_VERTEX_ARRAY_BIT) { + struct gl_array_attrib *attr; + attr = MALLOC_STRUCT( gl_array_attrib ); + MEMCPY( attr, &ctx->Array, sizeof(struct gl_array_attrib) ); + newnode = new_attrib_node( GL_CLIENT_VERTEX_ARRAY_BIT ); + newnode->data = attr; + newnode->next = head; + head = newnode; + } + + /* etc... */ + + ctx->ClientAttribStack[ctx->ClientAttribStackDepth] = head; + ctx->ClientAttribStackDepth++; +} + + + + +void gl_PopClientAttrib( GLcontext *ctx ) +{ + struct gl_attrib_node *attr, *next; + + if (INSIDE_BEGIN_END(ctx)) { + gl_error( ctx, GL_INVALID_OPERATION, "glPopClientAttrib" ); + return; + } + + if (ctx->ClientAttribStackDepth==0) { + gl_error( ctx, GL_STACK_UNDERFLOW, "glPopClientAttrib" ); + return; + } + + ctx->ClientAttribStackDepth--; + attr = ctx->ClientAttribStack[ctx->ClientAttribStackDepth]; + + while (attr) { + switch (attr->kind) { + case GL_CLIENT_PACK_BIT: + MEMCPY( &ctx->Pack, attr->data, + sizeof(struct gl_pixelstore_attrib) ); + break; + case GL_CLIENT_UNPACK_BIT: + MEMCPY( &ctx->Unpack, attr->data, + sizeof(struct gl_pixelstore_attrib) ); + break; + case GL_CLIENT_VERTEX_ARRAY_BIT: + MEMCPY( &ctx->Array, attr->data, + sizeof(struct gl_array_attrib) ); + break; + default: + gl_problem( ctx, "Bad attrib flag in PopClientAttrib"); + break; + } + + next = attr->next; + free( (void *) attr->data ); + free( (void *) attr ); + attr = next; + } + + ctx->NewState = NEW_ALL; +} + diff --git a/dll/opengl/mesa/attrib.h b/dll/opengl/mesa/attrib.h new file mode 100644 index 00000000000..80df20e6fe6 --- /dev/null +++ b/dll/opengl/mesa/attrib.h @@ -0,0 +1,48 @@ +/* $Id: attrib.h,v 1.1 1996/09/13 01:38:16 brianp Exp $ */ + +/* + * Mesa 3-D graphics library + * Version: 2.0 + * Copyright (C) 1995-1996 Brian Paul + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Library General Public + * License as published by the Free Software Foundation; either + * version 2 of the License, or (at your option) any later version. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Library General Public License for more details. + * + * You should have received a copy of the GNU Library General Public + * License along with this library; if not, write to the Free + * Software Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. + */ + + +/* + * $Log: attrib.h,v $ + * Revision 1.1 1996/09/13 01:38:16 brianp + * Initial revision + * + */ + + +#ifndef ATTRIB_H +#define ATTRIB_h + + +#include "types.h" + + +extern void gl_PushAttrib( GLcontext* ctx, GLbitfield mask ); + +extern void gl_PopAttrib( GLcontext* ctx ); + +extern void gl_PushClientAttrib( GLcontext *ctx, GLbitfield mask ); + +extern void gl_PopClientAttrib( GLcontext *ctx ); + + +#endif diff --git a/dll/opengl/mesa/bitmap.c b/dll/opengl/mesa/bitmap.c new file mode 100644 index 00000000000..06e97072469 --- /dev/null +++ b/dll/opengl/mesa/bitmap.c @@ -0,0 +1,221 @@ +/* $Id: bitmap.c,v 1.9 1998/02/03 23:45:02 brianp Exp $ */ + +/* + * Mesa 3-D graphics library + * Version: 2.5 + * Copyright (C) 1995-1997 Brian Paul + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Library General Public + * License as published by the Free Software Foundation; either + * version 2 of the License, or (at your option) any later version. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Library General Public License for more details. + * + * You should have received a copy of the GNU Library General Public + * License along with this library; if not, write to the Free + * Software Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. + */ + + +/* + * $Log: bitmap.c,v $ + * Revision 1.9 1998/02/03 23:45:02 brianp + * added casts to prevent warnings with Amiga StormC compiler + * + * Revision 1.8 1997/10/02 03:06:42 brianp + * added #include + * + * Revision 1.7 1997/09/27 00:15:39 brianp + * changed parameters to gl_unpack_image() + * + * Revision 1.6 1997/07/24 01:24:45 brianp + * changed precompiled header symbol from PCH to PC_HEADER + * + * Revision 1.5 1997/06/20 02:18:09 brianp + * replaced Current.IntColor with Current.ByteColor + * + * Revision 1.4 1997/05/28 03:23:48 brianp + * added precompiled header (PCH) support + * + * Revision 1.3 1996/11/06 04:23:18 brianp + * replaced 0 with GL_COLOR_INDEX in gl_unpack_bitmap() + * + * Revision 1.2 1996/09/15 14:18:10 brianp + * now use GLframebuffer and GLvisual + * + * Revision 1.1 1996/09/13 01:38:16 brianp + * Initial revision + * + */ + + +#ifdef PC_HEADER +#include "all.h" +#else +#include +#include +#include +#include "bitmap.h" +#include "context.h" +#include "feedback.h" +#include "image.h" +#include "macros.h" +#include "pb.h" +#include "types.h" +#endif + + + +/* + * Unpack a bitmap image + */ +struct gl_image *gl_unpack_bitmap( GLcontext* ctx, + GLsizei width, GLsizei height, + const GLubyte *bitmap ) +{ + return gl_unpack_image( ctx, width, height, + GL_COLOR_INDEX, GL_BITMAP, bitmap ); +} + + + + +/* + * Do actual rendering of a bitmap. + */ +void gl_render_bitmap( GLcontext* ctx, + GLsizei width, GLsizei height, + GLfloat xorig, GLfloat yorig, + GLfloat xmove, GLfloat ymove, + const struct gl_image *bitmap ) +{ + struct pixel_buffer *PB = ctx->PB; + GLint bx, by; /* bitmap position */ + GLint px, py, pz; /* pixel position */ + GLubyte *ptr; + + assert(bitmap); + assert(bitmap->Type == GL_BITMAP); + assert(bitmap->Format == GL_COLOR_INDEX); + + if (ctx->NewState) { + gl_update_state(ctx); + PB_INIT( PB, GL_BITMAP ); + } + + if (ctx->Visual->RGBAflag) { + GLint r, g, b, a; + r = (GLint) (ctx->Current.RasterColor[0] * ctx->Visual->RedScale); + g = (GLint) (ctx->Current.RasterColor[1] * ctx->Visual->GreenScale); + b = (GLint) (ctx->Current.RasterColor[2] * ctx->Visual->BlueScale); + a = (GLint) (ctx->Current.RasterColor[3] * ctx->Visual->AlphaScale); + PB_SET_COLOR( ctx, PB, r, g, b, a ); + } + else { + PB_SET_INDEX( ctx, PB, ctx->Current.RasterIndex ); + } + + px = (GLint) ( (ctx->Current.RasterPos[0] - xorig) + 0.0F ); + py = (GLint) ( (ctx->Current.RasterPos[1] - yorig) + 0.0F ); + pz = (GLint) ( ctx->Current.RasterPos[2] * DEPTH_SCALE ); + ptr = (GLubyte *) bitmap->Data; + + for (by=0;by> 1; + if (bitmask==0) { + ptr++; + bitmask = 128; + } + } + + PB_CHECK_FLUSH( ctx, PB ) + + /* get ready for next row */ + if (bitmask!=128) ptr++; + } + + gl_flush_pb(ctx); +} + + + + +/* + * Execute a glBitmap command: + * 1. check for errors + * 2. feedback/render/select + * 3. advance raster position + */ +void gl_Bitmap( GLcontext* ctx, + GLsizei width, GLsizei height, + GLfloat xorig, GLfloat yorig, + GLfloat xmove, GLfloat ymove, + const struct gl_image *bitmap ) +{ + if (width<0 || height<0) { + gl_error( ctx, GL_INVALID_VALUE, "glBitmap" ); + return; + } + if (INSIDE_BEGIN_END(ctx)) { + gl_error( ctx, GL_INVALID_OPERATION, "glBitmap" ); + return; + } + if (ctx->Current.RasterPosValid==GL_FALSE) { + /* do nothing */ + return; + } + + if (ctx->RenderMode==GL_RENDER) { + GLboolean completed = GL_FALSE; + if (ctx->Driver.Bitmap) { + /* let device driver try to render the bitmap */ + completed = (*ctx->Driver.Bitmap)( ctx, width, height, xorig, yorig, + xmove, ymove, bitmap ); + } + if (!completed) { + /* use generic function */ + gl_render_bitmap( ctx, width, height, xorig, yorig, + xmove, ymove, bitmap ); + } + } + else if (ctx->RenderMode==GL_FEEDBACK) { + GLfloat color[4], texcoord[4], invq; + color[0] = ctx->Current.ByteColor[0] * ctx->Visual->InvRedScale; + color[1] = ctx->Current.ByteColor[1] * ctx->Visual->InvGreenScale; + color[2] = ctx->Current.ByteColor[2] * ctx->Visual->InvBlueScale; + color[3] = ctx->Current.ByteColor[3] * ctx->Visual->InvAlphaScale; + invq = 1.0F / ctx->Current.TexCoord[3]; + texcoord[0] = ctx->Current.TexCoord[0] * invq; + texcoord[1] = ctx->Current.TexCoord[1] * invq; + texcoord[2] = ctx->Current.TexCoord[2] * invq; + texcoord[3] = ctx->Current.TexCoord[3]; + FEEDBACK_TOKEN( ctx, (GLfloat) (GLint) GL_BITMAP_TOKEN ); + /* TODO: Verify XYZW values are correct: */ + gl_feedback_vertex( ctx, ctx->Current.RasterPos[0] - xorig, + ctx->Current.RasterPos[1] - yorig, + ctx->Current.RasterPos[2], + ctx->Current.RasterPos[3], + color, ctx->Current.Index, texcoord ); + } + else if (ctx->RenderMode==GL_SELECT) { + /* Bitmaps don't generate selection hits. See appendix B of 1.1 spec. */ + } + + /* update raster position */ + ctx->Current.RasterPos[0] += xmove; + ctx->Current.RasterPos[1] += ymove; +} + + diff --git a/dll/opengl/mesa/bitmap.h b/dll/opengl/mesa/bitmap.h new file mode 100644 index 00000000000..e0b0314e440 --- /dev/null +++ b/dll/opengl/mesa/bitmap.h @@ -0,0 +1,59 @@ +/* $Id: bitmap.h,v 1.1 1996/09/13 01:38:16 brianp Exp $ */ + +/* + * Mesa 3-D graphics library + * Version: 2.0 + * Copyright (C) 1995-1996 Brian Paul + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Library General Public + * License as published by the Free Software Foundation; either + * version 2 of the License, or (at your option) any later version. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Library General Public License for more details. + * + * You should have received a copy of the GNU Library General Public + * License along with this library; if not, write to the Free + * Software Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. + */ + + +/* + * $Log: bitmap.h,v $ + * Revision 1.1 1996/09/13 01:38:16 brianp + * Initial revision + * + */ + + +#ifndef BITMAP_H +#define BITMAP_H + + +#include "types.h" + + +extern struct gl_image *gl_unpack_bitmap( GLcontext* ctx, + GLsizei width, GLsizei height, + const GLubyte *bitmap ); + + + +extern void gl_render_bitmap( GLcontext* ctx, + GLsizei width, GLsizei height, + GLfloat xorig, GLfloat yorig, + GLfloat xmove, GLfloat ymove, + const struct gl_image *bitmap ); + + +extern void gl_Bitmap( GLcontext* ctx, + GLsizei width, GLsizei height, + GLfloat xorig, GLfloat yorig, + GLfloat xmove, GLfloat ymove, + const struct gl_image *bitmap ); + + +#endif diff --git a/dll/opengl/mesa/blend.c b/dll/opengl/mesa/blend.c new file mode 100644 index 00000000000..3cfe2c97489 --- /dev/null +++ b/dll/opengl/mesa/blend.c @@ -0,0 +1,547 @@ +/* $Id: blend.c,v 1.10 1998/01/27 03:42:40 brianp Exp $ */ + +/* + * Mesa 3-D graphics library + * Version: 2.6 + * Copyright (C) 1995-1997 Brian Paul + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Library General Public + * License as published by the Free Software Foundation; either + * version 2 of the License, or (at your option) any later version. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Library General Public License for more details. + * + * You should have received a copy of the GNU Library General Public + * License along with this library; if not, write to the Free + * Software Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. + */ + + +/* + * $Log: blend.c,v $ + * Revision 1.10 1998/01/27 03:42:40 brianp + * optimized more blending modes (Kai Schuetz) + * + * Revision 1.9 1997/07/24 01:24:45 brianp + * changed precompiled header symbol from PCH to PC_HEADER + * + * Revision 1.8 1997/05/28 03:23:48 brianp + * added precompiled header (PCH) support + * + * Revision 1.7 1997/04/20 19:51:57 brianp + * replaced abort() with gl_problem() + * + * Revision 1.6 1997/02/15 18:27:56 brianp + * fixed a few error messages + * + * Revision 1.5 1997/01/28 22:17:19 brianp + * moved logic op blending into logic.c + * + * Revision 1.4 1997/01/04 00:13:11 brianp + * was using ! instead of ~ to invert pixel bits (ugh!) + * + * Revision 1.3 1996/09/19 00:53:31 brianp + * added missing returns after some gl_error() calls + * + * Revision 1.2 1996/09/15 14:18:10 brianp + * now use GLframebuffer and GLvisual + * + * Revision 1.1 1996/09/13 01:38:16 brianp + * Initial revision + * + */ + + +#ifdef PC_HEADER +#include "all.h" +#else +#include +#include +#include "alphabuf.h" +#include "blend.h" +#include "context.h" +#include "dlist.h" +#include "macros.h" +#include "pb.h" +#include "span.h" +#include "types.h" +#endif + + + +void gl_BlendFunc( GLcontext* ctx, GLenum sfactor, GLenum dfactor ) +{ + if (INSIDE_BEGIN_END(ctx)) { + gl_error( ctx, GL_INVALID_OPERATION, "glBlendFunc" ); + return; + } + + switch (sfactor) { + case GL_ZERO: + case GL_ONE: + case GL_DST_COLOR: + case GL_ONE_MINUS_DST_COLOR: + case GL_SRC_ALPHA: + case GL_ONE_MINUS_SRC_ALPHA: + case GL_DST_ALPHA: + case GL_ONE_MINUS_DST_ALPHA: + case GL_SRC_ALPHA_SATURATE: + ctx->Color.BlendSrc = sfactor; + break; + default: + gl_error( ctx, GL_INVALID_ENUM, "glBlendFunc(sfactor)" ); + return; + } + + switch (dfactor) { + case GL_ZERO: + case GL_ONE: + case GL_SRC_COLOR: + case GL_ONE_MINUS_SRC_COLOR: + case GL_SRC_ALPHA: + case GL_ONE_MINUS_SRC_ALPHA: + case GL_DST_ALPHA: + case GL_ONE_MINUS_DST_ALPHA: + ctx->Color.BlendDst = dfactor; + break; + default: + gl_error( ctx, GL_INVALID_ENUM, "glBlendFunc(dfactor)" ); + } + + ctx->NewState |= NEW_RASTER_OPS; +} + + + +/* + * Do the real work of gl_blend_span() and gl_blend_pixels(). + * Input: n - number of pixels + * mask - the usual write mask + * In/Out: red, green, blue, alpha - the incoming and modified pixels + * Input: rdest, gdest, bdest, adest - the pixels from the dest color buffer + */ +static void do_blend( GLcontext* ctx, GLuint n, const GLubyte mask[], + GLubyte red[], GLubyte green[], + GLubyte blue[], GLubyte alpha[], + const GLubyte rdest[], const GLubyte gdest[], + const GLubyte bdest[], const GLubyte adest[] ) +{ + GLuint i; + + if (ctx->Color.BlendSrc==GL_SRC_ALPHA + && ctx->Color.BlendDst==GL_ONE_MINUS_SRC_ALPHA) { + /* Alpha blending */ + GLfloat ascale = 256.0f * ctx->Visual->InvAlphaScale; + GLint rmax = (GLint) ctx->Visual->RedScale; + GLint gmax = (GLint) ctx->Visual->GreenScale; + GLint bmax = (GLint) ctx->Visual->BlueScale; + GLint amax = (GLint) ctx->Visual->AlphaScale; + for (i=0;i> 8; + g = (green[i] * t + gdest[i] * s) >> 8; + b = (blue[i] * t + bdest[i] * s) >> 8; + a = (alpha[i] * t + adest[i] * s) >> 8; + + /* kai: I think the following clamping is not needed: */ + + red[i] = MIN2( r, rmax ); + green[i] = MIN2( g, gmax ); + blue[i] = MIN2( b, bmax ); + alpha[i] = MIN2( a, amax ); + } + } + } + else { + + /* clipped sum */ + if (ctx->Color.BlendSrc==GL_ONE + && ctx->Color.BlendDst==GL_ONE) { + GLint rmax = (GLint) ctx->Visual->RedScale; + GLint gmax = (GLint) ctx->Visual->GreenScale; + GLint bmax = (GLint) ctx->Visual->BlueScale; + GLint amax = (GLint) ctx->Visual->AlphaScale; + for (i=0; i < n; i++) { + if (mask[i]) { + red[i] = MIN2(rmax, red[i] + rdest[i]); + green[i] = MIN2(gmax, green[i] + gdest[i]); + blue[i] = MIN2(bmax, blue[i] + bdest[i]); + alpha[i] = MIN2(amax, alpha[i] + adest[i]); + } + } + } + + /* modulation */ + else if ((ctx->Color.BlendSrc==GL_ZERO && + ctx->Color.BlendDst==GL_SRC_COLOR) + || + (ctx->Color.BlendSrc==GL_DST_COLOR && + ctx->Color.BlendDst==GL_ZERO)) { + if (ctx->Visual->EightBitColor) { + for (i=0; i < n; i++) { + if (mask[i]) { + red[i] = (red[i] * rdest[i]) / 255; + green[i] = (green[i] * gdest[i]) / 255; + blue[i] = (blue[i] * bdest[i]) / 255; + alpha[i] = (alpha[i] * adest[i]) / 255; + } + } + } + else { + GLint rmax = (GLint) ctx->Visual->RedScale; + GLint gmax = (GLint) ctx->Visual->GreenScale; + GLint bmax = (GLint) ctx->Visual->BlueScale; + GLint amax = (GLint) ctx->Visual->AlphaScale; + for (i=0; i < n; i++) { + if (mask[i]) { + red[i] = (red[i] * rdest[i]) / rmax; + green[i] = (green[i] * gdest[i]) / gmax; + blue[i] = (blue[i] * bdest[i]) / bmax; + alpha[i] = (alpha[i] * adest[i]) / amax; + } + } + } + }else{ + + /* General cases: */ + + if (ctx->Visual->EightBitColor) { + for (i=0;iColor.BlendSrc) { + case GL_ZERO: + Rss = Gss = Bss = Ass = 0; + break; + case GL_ONE: + Rss = Rs * 255; + Gss = Gs * 255; + Bss = Bs * 255; + Ass = As * 255; + break; + case GL_DST_COLOR: + Rss = Rs * Rd; + Gss = Gs * Gd; + Bss = Bs * Bd; + Ass = As * Ad; + break; + case GL_ONE_MINUS_DST_COLOR: + Rss = Rs * (255 - Rd); + Gss = Gs * (255 - Gd); + Bss = Bs * (255 - Bd); + Ass = As * (255 - Ad); + break; + case GL_SRC_ALPHA: + Rss = Rs * As; + Gss = Gs * As; + Bss = Bs * As; + Ass = As * As; + break; + case GL_ONE_MINUS_SRC_ALPHA: + Rss = Rs * (255 - As); + Gss = Gs * (255 - As); + Bss = Bs * (255 - As); + Ass = As * (255 - As); + break; + case GL_DST_ALPHA: + Rss = Rs * Ad; + Gss = Gs * Ad; + Bss = Bs * Ad; + Ass = As * Ad; + break; + case GL_ONE_MINUS_DST_ALPHA: + Rss = Rs * (255 - Ad); + Gss = Gs * (255 - Ad); + Bss = Bs * (255 - Ad); + Ass = As * (255 - Ad); + break; + case GL_SRC_ALPHA_SATURATE: + { + GLint sA = MIN2(As, 255 - Ad); + Rss = Rs * sA; + Gss = Gs * sA; + Bss = Bs * sA; + Ass = As * 255; + break; + } + default: + /* this should never happen */ + gl_problem(ctx, "Bad blend source factor in do_blend"); + } + + /* Dest scaling */ + switch (ctx->Color.BlendDst) { + case GL_ZERO: + Rds = Gds = Bds = Ads = 0; + break; + case GL_ONE: + Rds = Rd * 255; + Gds = Gd * 255; + Bds = Bd * 255; + Ads = Ad * 255; + break; + case GL_SRC_COLOR: + Rds = Rd * Rs; + Gds = Gd * Gs; + Bds = Bd * Bs; + Ads = Ad * As; + break; + case GL_ONE_MINUS_SRC_COLOR: + Rds = Rs * (255 - Rs); + Gds = Gs * (255 - Gs); + Bds = Bs * (255 - Bs); + Ads = As * (255 - As); + break; + case GL_SRC_ALPHA: + Rds = Rd * As; + Gds = Gd * As; + Bds = Bd * As; + Ads = Ad * As; + break; + case GL_ONE_MINUS_SRC_ALPHA: + Rds = Rd * (255 - As); + Gds = Gd * (255 - As); + Bds = Bd * (255 - As); + Ads = Ad * (255 - As); + break; + case GL_DST_ALPHA: + Rds = Rd * Ad; + Gds = Gd * Ad; + Bds = Bd * Ad; + Ads = Ad * Ad; + break; + case GL_ONE_MINUS_DST_ALPHA: + Rds = Rd * (255 - Ad); + Gds = Gd * (255 - Ad); + Bds = Bd * (255 - Ad); + Ads = Ad * (255 - Ad); + break; + default: + /* this should never happen */ + gl_problem(ctx, "Bad blend dest factor in do_blend"); + } + + /* compute blended color */ + red[i] = MIN2((Rss + Rds) / 255, 255); + green[i] = MIN2((Gss + Gds) / 255, 255); + blue[i] = MIN2((Bss + Bds) / 255, 255); + alpha[i] = MIN2((Ass + Ads) / 255, 255); + } + } + }else{ /* !EightBitColor */ + GLfloat rmax = ctx->Visual->RedScale; + GLfloat gmax = ctx->Visual->GreenScale; + GLfloat bmax = ctx->Visual->BlueScale; + GLfloat amax = ctx->Visual->AlphaScale; + GLfloat rscale = 1.0f / rmax; + GLfloat gscale = 1.0f / gmax; + GLfloat bscale = 1.0f / bmax; + GLfloat ascale = 1.0f / amax; + + for (i=0;iColor.BlendSrc) { + case GL_ZERO: + sR = sG = sB = sA = 0.0F; + break; + case GL_ONE: + sR = sG = sB = sA = 1.0F; + break; + case GL_DST_COLOR: + sR = (GLfloat) Rd * rscale; + sG = (GLfloat) Gd * gscale; + sB = (GLfloat) Bd * bscale; + sA = (GLfloat) Ad * ascale; + break; + case GL_ONE_MINUS_DST_COLOR: + sR = 1.0F - (GLfloat) Rd * rscale; + sG = 1.0F - (GLfloat) Gd * gscale; + sB = 1.0F - (GLfloat) Bd * bscale; + sA = 1.0F - (GLfloat) Ad * ascale; + break; + case GL_SRC_ALPHA: + sR = sG = sB = sA = (GLfloat) As * ascale; + break; + case GL_ONE_MINUS_SRC_ALPHA: + sR = sG = sB = sA = (GLfloat) 1.0F - (GLfloat) As * ascale; + break; + case GL_DST_ALPHA: + sR = sG = sB = sA =(GLfloat) Ad * ascale; + break; + case GL_ONE_MINUS_DST_ALPHA: + sR = sG = sB = sA = 1.0F - (GLfloat) Ad * ascale; + break; + case GL_SRC_ALPHA_SATURATE: + if (As < 1.0F - (GLfloat) Ad * ascale) { + sR = sG = sB = (GLfloat) As * ascale; + } + else { + sR = sG = sB = 1.0F - (GLfloat) Ad * ascale; + } + sA = 1.0; + break; + default: + /* this should never happen */ + gl_problem(ctx, "Bad blend source factor in do_blend"); + } + + /* Dest scaling */ + switch (ctx->Color.BlendDst) { + case GL_ZERO: + dR = dG = dB = dA = 0.0F; + break; + case GL_ONE: + dR = dG = dB = dA = 1.0F; + break; + case GL_SRC_COLOR: + dR = (GLfloat) Rs * rscale; + dG = (GLfloat) Gs * gscale; + dB = (GLfloat) Bs * bscale; + dA = (GLfloat) As * ascale; + break; + case GL_ONE_MINUS_SRC_COLOR: + dR = 1.0F - (GLfloat) Rs * rscale; + dG = 1.0F - (GLfloat) Gs * gscale; + dB = 1.0F - (GLfloat) Bs * bscale; + dA = 1.0F - (GLfloat) As * ascale; + break; + case GL_SRC_ALPHA: + dR = dG = dB = dA = (GLfloat) As * ascale; + break; + case GL_ONE_MINUS_SRC_ALPHA: + dR = dG = dB = dA = (GLfloat) 1.0F - (GLfloat) As * ascale; + break; + case GL_DST_ALPHA: + dR = dG = dB = dA = (GLfloat) Ad * ascale; + break; + case GL_ONE_MINUS_DST_ALPHA: + dR = dG = dB = dA = 1.0F - (GLfloat) Ad * ascale; + break; + default: + /* this should never happen */ + gl_problem(ctx, "Bad blend dest factor in do_blend"); + } + +#ifdef DEBUG + assert( sR>= 0.0 && sR<=1.0 ); + assert( sG>= 0.0 && sG<=1.0 ); + assert( sB>= 0.0 && sB<=1.0 ); + assert( sA>= 0.0 && sA<=1.0 ); + assert( dR>= 0.0 && dR<=1.0 ); + assert( dG>= 0.0 && dG<=1.0 ); + assert( dB>= 0.0 && dB<=1.0 ); + assert( dA>= 0.0 && dA<=1.0 ); +#endif + + /* compute blended color */ + r = Rs * sR + Rd * dR; + g = Gs * sG + Gd * dG; + b = Bs * sB + Bd * dB; + a = As * sA + Ad * dA; + red[i] = (GLint) CLAMP( r, 0.0F, rmax ); + green[i] = (GLint) CLAMP( g, 0.0F, gmax ); + blue[i] = (GLint) CLAMP( b, 0.0F, bmax ); + alpha[i] = (GLint) CLAMP( a, 0.0F, amax ); + } + } + } + } + } + +} + + + + + +/* + * Apply the blending operator to a span of pixels. + * Input: n - number of pixels in span + * x, y - location of leftmost pixel in span in window coords. + * mask - boolean mask indicating which pixels to blend. + * In/Out: red, green, blue, alpha - pixel values + */ +void gl_blend_span( GLcontext* ctx, GLuint n, GLint x, GLint y, + GLubyte red[], GLubyte green[], + GLubyte blue[], GLubyte alpha[], + GLubyte mask[] ) +{ + GLubyte rdest[MAX_WIDTH], gdest[MAX_WIDTH]; + GLubyte bdest[MAX_WIDTH], adest[MAX_WIDTH]; + + /* Read span of current frame buffer pixels */ + gl_read_color_span( ctx, n, x, y, rdest, gdest, bdest, adest ); + + do_blend( ctx, n, mask, red, green, blue, alpha, rdest, gdest, bdest, adest ); +} + + + + + +/* + * Apply the blending operator to an array of pixels. + * Input: n - number of pixels in span + * x, y - array of pixel locations + * mask - boolean mask indicating which pixels to blend. + * In/Out: red, green, blue, alpha - array of pixel values + */ +void gl_blend_pixels( GLcontext* ctx, + GLuint n, const GLint x[], const GLint y[], + GLubyte red[], GLubyte green[], + GLubyte blue[], GLubyte alpha[], + GLubyte mask[] ) +{ + GLubyte rdest[PB_SIZE], gdest[PB_SIZE], bdest[PB_SIZE], adest[PB_SIZE]; + + /* Read pixels from current color buffer */ + (*ctx->Driver.ReadColorPixels)( ctx, n, x, y, rdest, gdest, bdest, adest, mask ); + if (ctx->RasterMask & ALPHABUF_BIT) { + gl_read_alpha_pixels( ctx, n, x, y, adest, mask ); + } + + do_blend( ctx, n, mask, red, green, blue, alpha, rdest, gdest, bdest, adest ); +} diff --git a/dll/opengl/mesa/blend.h b/dll/opengl/mesa/blend.h new file mode 100644 index 00000000000..b933c554d09 --- /dev/null +++ b/dll/opengl/mesa/blend.h @@ -0,0 +1,54 @@ +/* $Id: blend.h,v 1.1 1996/09/13 01:38:16 brianp Exp $ */ + +/* + * Mesa 3-D graphics library + * Version: 2.0 + * Copyright (C) 1995-1996 Brian Paul + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Library General Public + * License as published by the Free Software Foundation; either + * version 2 of the License, or (at your option) any later version. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Library General Public License for more details. + * + * You should have received a copy of the GNU Library General Public + * License along with this library; if not, write to the Free + * Software Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. + */ + + +/* + * $Log: blend.h,v $ + * Revision 1.1 1996/09/13 01:38:16 brianp + * Initial revision + * + */ + + +#ifndef BLEND_H +#define BLEND_H + + +#include "types.h" + + + +extern void gl_blend_span( GLcontext* ctx, GLuint n, GLint x, GLint y, + GLubyte red[], GLubyte green[], + GLubyte blue[], GLubyte alpha[], + GLubyte mask[] ); + + +extern void gl_blend_pixels( GLcontext* ctx, + GLuint n, const GLint x[], const GLint y[], + GLubyte red[], GLubyte green[], + GLubyte blue[], GLubyte alpha[], + GLubyte mask[] ); + +extern void gl_BlendFunc( GLcontext* ctx, GLenum sfactor, GLenum dfactor ); + +#endif diff --git a/dll/opengl/mesa/clip.c b/dll/opengl/mesa/clip.c new file mode 100644 index 00000000000..18dee9c16e8 --- /dev/null +++ b/dll/opengl/mesa/clip.c @@ -0,0 +1,1055 @@ +/* $Id: clip.c,v 1.16 1998/02/03 23:45:36 brianp Exp $ */ + +/* + * Mesa 3-D graphics library + * Version: 2.6 + * Copyright (C) 1995-1997 Brian Paul + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Library General Public + * License as published by the Free Software Foundation; either + * version 2 of the License, or (at your option) any later version. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Library General Public License for more details. + * + * You should have received a copy of the GNU Library General Public + * License along with this library; if not, write to the Free + * Software Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. + */ + + +/* + * $Log: clip.c,v $ + * Revision 1.16 1998/02/03 23:45:36 brianp + * added space parameter to clip interpolation functions + * + * Revision 1.15 1998/01/06 02:40:52 brianp + * added DavidB's clipping interpolation optimization + * + * Revision 1.14 1997/07/24 01:24:45 brianp + * changed precompiled header symbol from PCH to PC_HEADER + * + * Revision 1.13 1997/05/28 03:23:48 brianp + * added precompiled header (PCH) support + * + * Revision 1.12 1997/04/02 03:10:06 brianp + * call gl_analyze_modelview_matrix instead of gl_compute_modelview_inverse + * + * Revision 1.11 1997/02/13 21:16:09 brianp + * if too many vertices in polygon return VB_SIZE-1, not VB_SIZE + * + * Revision 1.10 1997/02/10 21:16:12 brianp + * added checks in polygon clippers to prevent array overflows + * + * Revision 1.9 1997/02/04 19:39:39 brianp + * changed size of vlist2[] arrays to VB_SIZE per Randy Frank + * + * Revision 1.8 1996/12/02 20:10:07 brianp + * changed the macros in gl_viewclip_polygon() to be like gl_viewclip_line() + * + * Revision 1.7 1996/10/29 02:55:02 brianp + * fixed duplicate vertex bug in gl_viewclip_polygon() + * + * Revision 1.6 1996/10/07 23:48:33 brianp + * changed temporaries to GLdouble in gl_viewclip_polygon() + * + * Revision 1.5 1996/10/03 01:43:45 brianp + * changed INSIDE() macro in gl_viewclip_polygon() to work like other macros + * + * Revision 1.4 1996/10/03 01:36:33 brianp + * changed COMPUTE_INTERSECTION macros in gl_viewclip_polygon to avoid + * potential roundoff errors + * + * Revision 1.3 1996/09/27 01:24:23 brianp + * removed unused variables + * + * Revision 1.2 1996/09/15 01:48:58 brianp + * removed #define NULL 0 + * + * Revision 1.1 1996/09/13 01:38:16 brianp + * Initial revision + * + */ + + +#ifdef PC_HEADER +#include "all.h" +#else +#include +#include "clip.h" +#include "context.h" +#include "dlist.h" +#include "macros.h" +#include "matrix.h" +#include "types.h" +#include "vb.h" +#include "xform.h" +#endif + + + + +/* Linear interpolation between A and B: */ +#define LINTERP( T, A, B ) ( (A) + (T) * ( (B) - (A) ) ) + + +/* Clipping coordinate spaces */ +#define EYE_SPACE 1 +#define CLIP_SPACE 2 + + + +/* + * This function is used to interpolate colors, indexes, and texture + * coordinates when clipping has to be done. In general, we compute + * aux[dst] = aux[in] + t * (aux[out] - aux[in]) + * where aux is the quantity to be interpolated. + * Input: space - either EYE_SPACE or CLIP_SPACE + * dst - index of array position to store interpolated value + * t - a value in [0,1] + * in - index of array position corresponding to 'inside' vertex + * out - index of array position corresponding to 'outside' vertex + */ +void interpolate_aux( GLcontext* ctx, GLuint space, + GLuint dst, GLfloat t, GLuint in, GLuint out ) +{ + struct vertex_buffer* VB = ctx->VB; + + if (ctx->ClipMask & CLIP_FCOLOR_BIT) { + VB->Fcolor[dst][0] = LINTERP( t, VB->Fcolor[in][0], VB->Fcolor[out][0] ); + VB->Fcolor[dst][1] = LINTERP( t, VB->Fcolor[in][1], VB->Fcolor[out][1] ); + VB->Fcolor[dst][2] = LINTERP( t, VB->Fcolor[in][2], VB->Fcolor[out][2] ); + VB->Fcolor[dst][3] = LINTERP( t, VB->Fcolor[in][3], VB->Fcolor[out][3] ); + } + else if (ctx->ClipMask & CLIP_FINDEX_BIT) { + VB->Findex[dst] = (GLuint) (GLint) LINTERP( t, (GLfloat) VB->Findex[in], + (GLfloat) VB->Findex[out] ); + } + + if (ctx->ClipMask & CLIP_BCOLOR_BIT) { + VB->Bcolor[dst][0] = LINTERP( t, VB->Bcolor[in][0], VB->Bcolor[out][0] ); + VB->Bcolor[dst][1] = LINTERP( t, VB->Bcolor[in][1], VB->Bcolor[out][1] ); + VB->Bcolor[dst][2] = LINTERP( t, VB->Bcolor[in][2], VB->Bcolor[out][2] ); + VB->Bcolor[dst][3] = LINTERP( t, VB->Bcolor[in][3], VB->Bcolor[out][3] ); + } + else if (ctx->ClipMask & CLIP_BINDEX_BIT) { + VB->Bindex[dst] = (GLuint) (GLint) LINTERP( t, (GLfloat) VB->Bindex[in], + (GLfloat) VB->Bindex[out] ); + } + + if (ctx->ClipMask & CLIP_TEXTURE_BIT) { + /* TODO: is more sophisticated texture coord interpolation needed?? */ + if (space==CLIP_SPACE) { + /* also interpolate eye Z component */ + VB->Eye[dst][2] = LINTERP( t, VB->Eye[in][2], VB->Eye[out][2] ); + } + VB->TexCoord[dst][0] = LINTERP(t,VB->TexCoord[in][0],VB->TexCoord[out][0]); + VB->TexCoord[dst][1] = LINTERP(t,VB->TexCoord[in][1],VB->TexCoord[out][1]); + VB->TexCoord[dst][2] = LINTERP(t,VB->TexCoord[in][2],VB->TexCoord[out][2]); + VB->TexCoord[dst][3] = LINTERP(t,VB->TexCoord[in][3],VB->TexCoord[out][3]); + } + +} + + +/* + * Some specialized version of the interpolate_aux + * + */ + +void interpolate_aux_color_tex2( GLcontext* ctx, GLuint space, + GLuint dst, GLfloat t, GLuint in, GLuint out ) +{ + struct vertex_buffer* VB = ctx->VB; + + VB->Fcolor[dst][0] = LINTERP( t, VB->Fcolor[in][0], VB->Fcolor[out][0] ); + VB->Fcolor[dst][1] = LINTERP( t, VB->Fcolor[in][1], VB->Fcolor[out][1] ); + VB->Fcolor[dst][2] = LINTERP( t, VB->Fcolor[in][2], VB->Fcolor[out][2] ); + VB->Fcolor[dst][3] = LINTERP( t, VB->Fcolor[in][3], VB->Fcolor[out][3] ); + + VB->Eye[dst][2] = LINTERP( t, VB->Eye[in][2], VB->Eye[out][2] ); + VB->TexCoord[dst][0] = LINTERP(t,VB->TexCoord[in][0],VB->TexCoord[out][0]); + VB->TexCoord[dst][1] = LINTERP(t,VB->TexCoord[in][1],VB->TexCoord[out][1]); +} + + +void interpolate_aux_tex2( GLcontext* ctx, GLuint space, + GLuint dst, GLfloat t, GLuint in, GLuint out ) +{ + struct vertex_buffer* VB = ctx->VB; + + VB->Eye[dst][2] = LINTERP( t, VB->Eye[in][2], VB->Eye[out][2] ); + VB->TexCoord[dst][0] = LINTERP(t,VB->TexCoord[in][0],VB->TexCoord[out][0]); + VB->TexCoord[dst][1] = LINTERP(t,VB->TexCoord[in][1],VB->TexCoord[out][1]); +} + + +void interpolate_aux_color( GLcontext* ctx, GLuint space, + GLuint dst, GLfloat t, GLuint in, GLuint out ) +{ + struct vertex_buffer* VB = ctx->VB; + + VB->Fcolor[dst][0] = LINTERP( t, VB->Fcolor[in][0], VB->Fcolor[out][0] ); + VB->Fcolor[dst][1] = LINTERP( t, VB->Fcolor[in][1], VB->Fcolor[out][1] ); + VB->Fcolor[dst][2] = LINTERP( t, VB->Fcolor[in][2], VB->Fcolor[out][2] ); + VB->Fcolor[dst][3] = LINTERP( t, VB->Fcolor[in][3], VB->Fcolor[out][3] ); +} + + + + +void gl_ClipPlane( GLcontext* ctx, GLenum plane, const GLfloat *equation ) +{ + GLint p; + + p = (GLint) plane - (GLint) GL_CLIP_PLANE0; + if (p<0 || p>=MAX_CLIP_PLANES) { + gl_error( ctx, GL_INVALID_ENUM, "glClipPlane" ); + return; + } + + /* + * The equation is transformed by the transpose of the inverse of the + * current modelview matrix and stored in the resulting eye coordinates. + */ + if (ctx->NewModelViewMatrix) { + gl_analyze_modelview_matrix(ctx); + } + gl_transform_vector( ctx->Transform.ClipEquation[p], equation, + ctx->ModelViewInv ); +} + + + +void gl_GetClipPlane( GLcontext* ctx, GLenum plane, GLdouble *equation ) +{ + GLint p; + + if (INSIDE_BEGIN_END(ctx)) { + gl_error( ctx, GL_INVALID_OPERATION, "glGetClipPlane" ); + return; + } + + p = (GLint) (plane - GL_CLIP_PLANE0); + if (p<0 || p>=MAX_CLIP_PLANES) { + gl_error( ctx, GL_INVALID_ENUM, "glGetClipPlane" ); + return; + } + + equation[0] = (GLdouble) ctx->Transform.ClipEquation[p][0]; + equation[1] = (GLdouble) ctx->Transform.ClipEquation[p][1]; + equation[2] = (GLdouble) ctx->Transform.ClipEquation[p][2]; + equation[3] = (GLdouble) ctx->Transform.ClipEquation[p][3]; +} + + + + +/**********************************************************************/ +/* View volume clipping. */ +/**********************************************************************/ + + +/* + * Clip a point against the view volume. + * Input: v - vertex-vector describing the point to clip + * Return: 0 = outside view volume + * 1 = inside view volume + */ +GLuint gl_viewclip_point( const GLfloat v[] ) +{ + if ( v[0] > v[3] || v[0] < -v[3] + || v[1] > v[3] || v[1] < -v[3] + || v[2] > v[3] || v[2] < -v[3] ) { + return 0; + } + else { + return 1; + } +} + + + + +/* + * Clip a line segment against the view volume defined by -w<=x,y,z<=w. + * Input: i, j - indexes into VB->V* of endpoints of the line + * Return: 0 = line completely outside of view + * 1 = line is inside view. + */ +GLuint gl_viewclip_line( GLcontext* ctx, GLuint *i, GLuint *j ) +{ + struct vertex_buffer* VB = ctx->VB; + GLfloat (*coord)[4] = VB->Clip; + + GLfloat t, dx, dy, dz, dw; + register GLuint ii, jj; + + ii = *i; + jj = *j; + +/* + * We use 6 instances of this code to clip agains the 6 planes. + * For each plane, we define the OUTSIDE and COMPUTE_INTERSECTION + * macros apprpriately. + */ +#define GENERAL_CLIP \ + if (OUTSIDE(ii)) { \ + if (OUTSIDE(jj)) { \ + /* both verts are outside ==> return 0 */ \ + return 0; \ + } \ + else { \ + /* ii is outside, jj is inside ==> clip */ \ + /* new vertex put in position VB->Free */ \ + COMPUTE_INTERSECTION( VB->Free, jj, ii ) \ + if (ctx->ClipMask) \ + ctx->ClipInterpAuxFunc( ctx, CLIP_SPACE, VB->Free, t, jj, ii );\ + ii = VB->Free; \ + VB->Free++; \ + if (VB->Free==VB_SIZE) VB->Free = 1; \ + } \ + } \ + else { \ + if (OUTSIDE(jj)) { \ + /* ii is inside, jj is outside ==> clip */ \ + /* new vertex put in position VB->Free */ \ + COMPUTE_INTERSECTION( VB->Free, ii, jj ); \ + if (ctx->ClipMask) \ + ctx->ClipInterpAuxFunc( ctx, CLIP_SPACE, VB->Free, t, ii, jj );\ + jj = VB->Free; \ + VB->Free++; \ + if (VB->Free==VB_SIZE) VB->Free = 1; \ + } \ + /* else both verts are inside ==> do nothing */ \ + } + + +#define X(I) coord[I][0] +#define Y(I) coord[I][1] +#define Z(I) coord[I][2] +#define W(I) coord[I][3] + +/* + * Begin clipping + */ + + /*** Clip against +X side ***/ +#define OUTSIDE(K) (X(K) > W(K)) +#define COMPUTE_INTERSECTION( new, in, out ) \ + dx = X(out) - X(in); \ + dw = W(out) - W(in); \ + t = (X(in) - W(in)) / (dw-dx); \ + X(new) = X(in) + t * dx; \ + Y(new) = Y(in) + t * (Y(out) - Y(in)); \ + Z(new) = Z(in) + t * (Z(out) - Z(in)); \ + W(new) = W(in) + t * dw; + + GENERAL_CLIP + +#undef OUTSIDE +#undef COMPUTE_INTERSECTION + + + /*** Clip against -X side ***/ +#define OUTSIDE(K) (X(K) < -W(K)) +#define COMPUTE_INTERSECTION( new, in, out ) \ + dx = X(out) - X(in); \ + dw = W(out) - W(in); \ + t = -(X(in) + W(in)) / (dw+dx); \ + X(new) = X(in) + t * dx; \ + Y(new) = Y(in) + t * (Y(out) - Y(in)); \ + Z(new) = Z(in) + t * (Z(out) - Z(in)); \ + W(new) = W(in) + t * dw; + + GENERAL_CLIP + +#undef OUTSIDE +#undef COMPUTE_INTERSECTION + + + /*** Clip against +Y side ***/ +#define OUTSIDE(K) (Y(K) > W(K)) +#define COMPUTE_INTERSECTION( new, in, out ) \ + dy = Y(out) - Y(in); \ + dw = W(out) - W(in); \ + t = (Y(in) - W(in)) / (dw-dy); \ + X(new) = X(in) + t * (X(out) - X(in)); \ + Y(new) = Y(in) + t * dy; \ + Z(new) = Z(in) + t * (Z(out) - Z(in)); \ + W(new) = W(in) + t * dw; + + GENERAL_CLIP + +#undef OUTSIDE +#undef COMPUTE_INTERSECTION + + + /*** Clip against -Y side ***/ +#define OUTSIDE(K) (Y(K) < -W(K)) +#define COMPUTE_INTERSECTION( new, in, out ) \ + dy = Y(out) - Y(in); \ + dw = W(out) - W(in); \ + t = -(Y(in) + W(in)) / (dw+dy); \ + X(new) = X(in) + t * (X(out) - X(in)); \ + Y(new) = Y(in) + t * dy; \ + Z(new) = Z(in) + t * (Z(out) - Z(in)); \ + W(new) = W(in) + t * dw; + + GENERAL_CLIP + +#undef OUTSIDE +#undef COMPUTE_INTERSECTION + + + /*** Clip against +Z side ***/ +#define OUTSIDE(K) (Z(K) > W(K)) +#define COMPUTE_INTERSECTION( new, in, out ) \ + dz = Z(out) - Z(in); \ + dw = W(out) - W(in); \ + t = (Z(in) - W(in)) / (dw-dz); \ + X(new) = X(in) + t * (X(out) - X(in)); \ + Y(new) = Y(in) + t * (Y(out) - Y(in)); \ + Z(new) = Z(in) + t * dz; \ + W(new) = W(in) + t * dw; + + GENERAL_CLIP + +#undef OUTSIDE +#undef COMPUTE_INTERSECTION + + + /*** Clip against -Z side ***/ +#define OUTSIDE(K) (Z(K) < -W(K)) +#define COMPUTE_INTERSECTION( new, in, out ) \ + dz = Z(out) - Z(in); \ + dw = W(out) - W(in); \ + t = -(Z(in) + W(in)) / (dw+dz); \ + X(new) = X(in) + t * (X(out) - X(in)); \ + Y(new) = Y(in) + t * (Y(out) - Y(in)); \ + Z(new) = Z(in) + t * dz; \ + W(new) = W(in) + t * dw; + + GENERAL_CLIP + +#undef OUTSIDE +#undef COMPUTE_INTERSECTION + +#undef GENERAL_CLIP + + *i = ii; + *j = jj; + return 1; +} + + + + +/* + * Clip a polygon against the view volume defined by -w<=x,y,z<=w. + * Input: n - number of vertices in input polygon. + * vlist - list of indexes into VB->V* of polygon to clip. + * Output: vlist - modified list of vertex indexes + * Return: number of vertices in resulting polygon + */ +GLuint gl_viewclip_polygon( GLcontext* ctx, GLuint n, GLuint vlist[] ) + +{ + struct vertex_buffer* VB = ctx->VB; + GLfloat (*coord)[4] = VB->Clip; + + GLuint previ, prevj; + GLuint curri, currj; + GLuint vlist2[VB_SIZE]; + GLuint n2; + GLdouble dx, dy, dz, dw, t, neww; + +/* + * We use 6 instances of this code to implement clipping against the + * 6 sides of the view volume. Prior to each we define the macros: + * INLIST = array which lists input vertices + * OUTLIST = array which lists output vertices + * INCOUNT = variable which is the number of vertices in INLIST[] + * OUTCOUNT = variable which is the number of vertices in OUTLIST[] + * INSIDE(i) = test if vertex v[i] is inside the view volume + * COMPUTE_INTERSECTION(in,out,new) = compute intersection of line + * from v[in] to v[out] with the clipping plane and store + * the result in v[new] + */ + +#define GENERAL_CLIP \ + if (INCOUNT<3) return 0; \ + previ = INCOUNT-1; /* let previous = last vertex */ \ + prevj = INLIST[previ]; \ + OUTCOUNT = 0; \ + for (curri=0;curri copy current to outlist */ \ + OUTLIST[OUTCOUNT] = currj; \ + OUTCOUNT++; \ + } \ + else { \ + /* current is inside and previous is outside ==> clip */ \ + COMPUTE_INTERSECTION( currj, prevj, VB->Free ) \ + /* if new point not coincident with previous point... */ \ + if (t>0.0) { \ + /* interpolate aux info using the value of t */ \ + if (ctx->ClipMask) \ + ctx->ClipInterpAuxFunc( ctx, CLIP_SPACE, VB->Free, t, currj, prevj ); \ + VB->Edgeflag[VB->Free] = VB->Edgeflag[prevj]; \ + /* output new point */ \ + OUTLIST[OUTCOUNT] = VB->Free; \ + VB->Free++; \ + if (VB->Free==VB_SIZE) VB->Free = 1; \ + OUTCOUNT++; \ + } \ + /* Output current */ \ + OUTLIST[OUTCOUNT] = currj; \ + OUTCOUNT++; \ + } \ + } \ + else { \ + if (INSIDE(prevj)) { \ + /* current is outside and previous is inside ==> clip */ \ + COMPUTE_INTERSECTION( prevj, currj, VB->Free ) \ + /* if new point not coincident with previous point... */ \ + if (t>0.0) { \ + /* interpolate aux info using the value of t */ \ + if (ctx->ClipMask) \ + ctx->ClipInterpAuxFunc( ctx, CLIP_SPACE, VB->Free, t, prevj, currj ); \ + VB->Edgeflag[VB->Free] = VB->Edgeflag[prevj]; \ + /* output new point */ \ + OUTLIST[OUTCOUNT] = VB->Free; \ + VB->Free++; \ + if (VB->Free==VB_SIZE) VB->Free = 1; \ + OUTCOUNT++; \ + } \ + } \ + /* else both verts are outside ==> do nothing */ \ + } \ + /* let previous = current */ \ + previ = curri; \ + prevj = currj; \ + /* check for overflowing vertex buffer */ \ + if (OUTCOUNT>=VB_SIZE-1) { \ + /* Too many vertices */ \ + if (OUTLIST==vlist2) { \ + /* copy OUTLIST[] to vlist[] */ \ + int i; \ + for (i=0;i= -W(K)) +#define COMPUTE_INTERSECTION( in, out, new ) \ + dx = X(out)-X(in); \ + dw = W(out)-W(in); \ + t = -(X(in)+W(in)) / (dw+dx); \ + neww = W(in) + t * dw; \ + X(new) = -neww; \ + Y(new) = Y(in) + t * (Y(out) - Y(in)); \ + Z(new) = Z(in) + t * (Z(out) - Z(in)); \ + W(new) = neww; + + GENERAL_CLIP + +#undef INCOUNT +#undef OUTCOUNT +#undef INLIST +#undef OUTLIST +#undef INSIDE +#undef COMPUTE_INTERSECTION + + +/* + * Clip against +Y + */ +#define INCOUNT n +#define OUTCOUNT n2 +#define INLIST vlist +#define OUTLIST vlist2 +#define INSIDE(K) (Y(K) <= W(K)) +#define COMPUTE_INTERSECTION( in, out, new ) \ + dy = Y(out)-Y(in); \ + dw = W(out)-W(in); \ + t = (Y(in)-W(in)) / (dw-dy); \ + neww = W(in) + t * dw; \ + X(new) = X(in) + t * (X(out) - X(in)); \ + Y(new) = neww; \ + Z(new) = Z(in) + t * (Z(out) - Z(in)); \ + W(new) = neww; + + GENERAL_CLIP + +#undef INCOUNT +#undef OUTCOUNT +#undef INLIST +#undef OUTLIST +#undef INSIDE +#undef COMPUTE_INTERSECTION + + +/* + * Clip against -Y + */ +#define INCOUNT n2 +#define OUTCOUNT n +#define INLIST vlist2 +#define OUTLIST vlist +#define INSIDE(K) (Y(K) >= -W(K)) +#define COMPUTE_INTERSECTION( in, out, new ) \ + dy = Y(out)-Y(in); \ + dw = W(out)-W(in); \ + t = -(Y(in)+W(in)) / (dw+dy); \ + neww = W(in) + t * dw; \ + X(new) = X(in) + t * (X(out) - X(in)); \ + Y(new) = -neww; \ + Z(new) = Z(in) + t * (Z(out) - Z(in)); \ + W(new) = neww; + + GENERAL_CLIP + +#undef INCOUNT +#undef OUTCOUNT +#undef INLIST +#undef OUTLIST +#undef INSIDE +#undef COMPUTE_INTERSECTION + + + +/* + * Clip against +Z + */ +#define INCOUNT n +#define OUTCOUNT n2 +#define INLIST vlist +#define OUTLIST vlist2 +#define INSIDE(K) (Z(K) <= W(K)) +#define COMPUTE_INTERSECTION( in, out, new ) \ + dz = Z(out)-Z(in); \ + dw = W(out)-W(in); \ + t = (Z(in)-W(in)) / (dw-dz); \ + neww = W(in) + t * dw; \ + X(new) = X(in) + t * (X(out) - X(in)); \ + Y(new) = Y(in) + t * (Y(out) - Y(in)); \ + Z(new) = neww; \ + W(new) = neww; + + GENERAL_CLIP + +#undef INCOUNT +#undef OUTCOUNT +#undef INLIST +#undef OUTLIST +#undef INSIDE +#undef COMPUTE_INTERSECTION + + +/* + * Clip against -Z + */ +#define INCOUNT n2 +#define OUTCOUNT n +#define INLIST vlist2 +#define OUTLIST vlist +#define INSIDE(K) (Z(K) >= -W(K)) +#define COMPUTE_INTERSECTION( in, out, new ) \ + dz = Z(out)-Z(in); \ + dw = W(out)-W(in); \ + t = -(Z(in)+W(in)) / (dw+dz); \ + neww = W(in) + t * dw; \ + X(new) = X(in) + t * (X(out) - X(in)); \ + Y(new) = Y(in) + t * (Y(out) - Y(in)); \ + Z(new) = -neww; \ + W(new) = neww; + + GENERAL_CLIP + +#undef INCOUNT +#undef INLIST +#undef OUTLIST +#undef INSIDE +#undef COMPUTE_INTERSECTION + + /* 'OUTCOUNT' clipped vertices are now back in v[] */ + return OUTCOUNT; + +#undef GENERAL_CLIP +#undef OUTCOUNT +} + + + + +/**********************************************************************/ +/* Clipping against user-defined clipping planes. */ +/**********************************************************************/ + + + +/* + * If the dot product of the eye coordinates of a vertex with the + * stored plane equation components is positive or zero, the vertex + * is in with respect to that clipping plane, otherwise it is out. + */ + + + +/* + * Clip a point against the user clipping planes. + * Input: v - vertex-vector describing the point to clip. + * Return: 0 = point was clipped + * 1 = point not clipped + */ +GLuint gl_userclip_point( GLcontext* ctx, const GLfloat v[] ) +{ + GLuint p; + + for (p=0;pTransform.ClipEnabled[p]) { + GLfloat dot = v[0] * ctx->Transform.ClipEquation[p][0] + + v[1] * ctx->Transform.ClipEquation[p][1] + + v[2] * ctx->Transform.ClipEquation[p][2] + + v[3] * ctx->Transform.ClipEquation[p][3]; + if (dot < 0.0F) { + return 0; + } + } + } + + return 1; +} + + +#define MAGIC_NUMBER -0.8e-03F + + +/* Test if VB->Eye[J] is inside the clipping plane defined by A,B,C,D */ +#define INSIDE( J, A, B, C, D ) \ + ( (VB->Eye[J][0] * A + VB->Eye[J][1] * B \ + + VB->Eye[J][2] * C + VB->Eye[J][3] * D) >= MAGIC_NUMBER ) + + +/* Test if VB->Eye[J] is outside the clipping plane defined by A,B,C,D */ +#define OUTSIDE( J, A, B, C, D ) \ + ( (VB->Eye[J][0] * A + VB->Eye[J][1] * B \ + + VB->Eye[J][2] * C + VB->Eye[J][3] * D) < MAGIC_NUMBER ) + + +/* + * Clip a line against the user clipping planes. + * Input: i, j - indexes into VB->V*[] of endpoints + * Output: i, j - indexes into VB->V*[] of (possibly clipped) endpoints + * Return: 0 = line completely clipped + * 1 = line is visible + */ +GLuint gl_userclip_line( GLcontext* ctx, GLuint *i, GLuint *j ) +{ + struct vertex_buffer* VB = ctx->VB; + + GLuint p, ii, jj; + + ii = *i; + jj = *j; + + for (p=0;pTransform.ClipEnabled[p]) { + register GLfloat a, b, c, d; + a = ctx->Transform.ClipEquation[p][0]; + b = ctx->Transform.ClipEquation[p][1]; + c = ctx->Transform.ClipEquation[p][2]; + d = ctx->Transform.ClipEquation[p][3]; + + if (OUTSIDE( ii, a,b,c,d )) { + if (OUTSIDE( jj, a,b,c,d )) { + /* ii and jj outside ==> quit */ + return 0; + } + else { + /* ii is outside, jj is inside ==> clip */ + GLfloat dx, dy, dz, dw, t, denom; + dx = VB->Eye[ii][0] - VB->Eye[jj][0]; + dy = VB->Eye[ii][1] - VB->Eye[jj][1]; + dz = VB->Eye[ii][2] - VB->Eye[jj][2]; + dw = VB->Eye[ii][3] - VB->Eye[jj][3]; + denom = dx*a + dy*b + dz*c + dw*d; + if (denom==0.0) { + t = 0.0; + } + else { + t = -(VB->Eye[jj][0]*a+VB->Eye[jj][1]*b + +VB->Eye[jj][2]*c+VB->Eye[jj][3]*d) / denom; + if (t>1.0F) t = 1.0F; + } + VB->Eye[VB->Free][0] = VB->Eye[jj][0] + t * dx; + VB->Eye[VB->Free][1] = VB->Eye[jj][1] + t * dy; + VB->Eye[VB->Free][2] = VB->Eye[jj][2] + t * dz; + VB->Eye[VB->Free][3] = VB->Eye[jj][3] + t * dw; + + /* Interpolate colors, indexes, and/or texture coords */ + if (ctx->ClipMask) + interpolate_aux( ctx, EYE_SPACE, VB->Free, t, jj, ii ); + + ii = VB->Free; + VB->Free++; + if (VB->Free==VB_SIZE) VB->Free = 1; + } + } + else { + if (OUTSIDE( jj, a,b,c,d )) { + /* ii is inside, jj is outside ==> clip */ + GLfloat dx, dy, dz, dw, t, denom; + dx = VB->Eye[jj][0] - VB->Eye[ii][0]; + dy = VB->Eye[jj][1] - VB->Eye[ii][1]; + dz = VB->Eye[jj][2] - VB->Eye[ii][2]; + dw = VB->Eye[jj][3] - VB->Eye[ii][3]; + denom = dx*a + dy*b + dz*c + dw*d; + if (denom==0.0) { + t = 0.0; + } + else { + t = -(VB->Eye[ii][0]*a+VB->Eye[ii][1]*b + +VB->Eye[ii][2]*c+VB->Eye[ii][3]*d) / denom; + if (t>1.0F) t = 1.0F; + } + VB->Eye[VB->Free][0] = VB->Eye[ii][0] + t * dx; + VB->Eye[VB->Free][1] = VB->Eye[ii][1] + t * dy; + VB->Eye[VB->Free][2] = VB->Eye[ii][2] + t * dz; + VB->Eye[VB->Free][3] = VB->Eye[ii][3] + t * dw; + + /* Interpolate colors, indexes, and/or texture coords */ + if (ctx->ClipMask) + interpolate_aux( ctx, EYE_SPACE, VB->Free, t, ii, jj ); + + jj = VB->Free; + VB->Free++; + if (VB->Free==VB_SIZE) VB->Free = 1; + } + else { + /* ii and jj inside ==> do nothing */ + } + } + } + } + + *i = ii; + *j = jj; + return 1; +} + + + + +/* + * Clip a polygon against the user clipping planes defined in eye coordinates. + * Input: n - number of vertices. + * vlist - list of vertices in input polygon. + * Output: vlist - list of vertices in output polygon. + * Return: number of vertices after clipping. + */ +GLuint gl_userclip_polygon( GLcontext* ctx, GLuint n, GLuint vlist[] ) +{ + struct vertex_buffer* VB = ctx->VB; + + GLuint vlist2[VB_SIZE]; + GLuint *inlist, *outlist; + GLuint incount, outcount; + GLuint curri, currj; + GLuint previ, prevj; + GLuint p; + + /* initialize input vertex list */ + incount = n; + inlist = vlist; + outlist = vlist2; + + for (p=0;pTransform.ClipEnabled[p]) { + register float a = ctx->Transform.ClipEquation[p][0]; + register float b = ctx->Transform.ClipEquation[p][1]; + register float c = ctx->Transform.ClipEquation[p][2]; + register float d = ctx->Transform.ClipEquation[p][3]; + + if (incount<3) return 0; + + /* initialize prev to be last in the input list */ + previ = incount - 1; + prevj = inlist[previ]; + + outcount = 0; + + for (curri=0;curri copy current to outlist */ + outlist[outcount++] = currj; + } + else { + /* current is inside and previous is outside ==> clip */ + GLfloat dx, dy, dz, dw, t, denom; + /* compute t */ + dx = VB->Eye[prevj][0] - VB->Eye[currj][0]; + dy = VB->Eye[prevj][1] - VB->Eye[currj][1]; + dz = VB->Eye[prevj][2] - VB->Eye[currj][2]; + dw = VB->Eye[prevj][3] - VB->Eye[currj][3]; + denom = dx*a + dy*b + dz*c + dw*d; + if (denom==0.0) { + t = 0.0; + } + else { + t = -(VB->Eye[currj][0]*a+VB->Eye[currj][1]*b + +VB->Eye[currj][2]*c+VB->Eye[currj][3]*d) / denom; + if (t>1.0F) { + t = 1.0F; + } + } + /* interpolate new vertex position */ + VB->Eye[VB->Free][0] = VB->Eye[currj][0] + t*dx; + VB->Eye[VB->Free][1] = VB->Eye[currj][1] + t*dy; + VB->Eye[VB->Free][2] = VB->Eye[currj][2] + t*dz; + VB->Eye[VB->Free][3] = VB->Eye[currj][3] + t*dw; + + /* interpolate color, index, and/or texture coord */ + if (ctx->ClipMask) { + interpolate_aux( ctx, EYE_SPACE, VB->Free, t, currj, prevj); + } + VB->Edgeflag[VB->Free] = VB->Edgeflag[prevj]; + + /* output new vertex */ + outlist[outcount++] = VB->Free; + VB->Free++; + if (VB->Free==VB_SIZE) VB->Free = 1; + /* output current vertex */ + outlist[outcount++] = currj; + } + } + else { + if (INSIDE(prevj, a,b,c,d)) { + /* current is outside and previous is inside ==> clip */ + GLfloat dx, dy, dz, dw, t, denom; + /* compute t */ + dx = VB->Eye[currj][0]-VB->Eye[prevj][0]; + dy = VB->Eye[currj][1]-VB->Eye[prevj][1]; + dz = VB->Eye[currj][2]-VB->Eye[prevj][2]; + dw = VB->Eye[currj][3]-VB->Eye[prevj][3]; + denom = dx*a + dy*b + dz*c + dw*d; + if (denom==0.0) { + t = 0.0; + } + else { + t = -(VB->Eye[prevj][0]*a+VB->Eye[prevj][1]*b + +VB->Eye[prevj][2]*c+VB->Eye[prevj][3]*d) / denom; + if (t>1.0F) { + t = 1.0F; + } + } + /* interpolate new vertex position */ + VB->Eye[VB->Free][0] = VB->Eye[prevj][0] + t*dx; + VB->Eye[VB->Free][1] = VB->Eye[prevj][1] + t*dy; + VB->Eye[VB->Free][2] = VB->Eye[prevj][2] + t*dz; + VB->Eye[VB->Free][3] = VB->Eye[prevj][3] + t*dw; + + /* interpolate color, index, and/or texture coord */ + if (ctx->ClipMask) { + interpolate_aux( ctx, EYE_SPACE, VB->Free, t, prevj, currj); + } + VB->Edgeflag[VB->Free] = VB->Edgeflag[prevj]; + + /* output new vertex */ + outlist[outcount++] = VB->Free; + VB->Free++; + if (VB->Free==VB_SIZE) VB->Free = 1; + } + /* else both verts are outside ==> do nothing */ + } + + previ = curri; + prevj = currj; + + /* check for overflowing vertex buffer */ + if (outcount>=VB_SIZE-1) { + /* Too many vertices */ + if (outlist!=vlist2) { + MEMCPY( vlist, vlist2, outcount * sizeof(GLuint) ); + } + return VB_SIZE-1; + } + + } /* for i */ + + /* swap inlist and outlist pointers */ + { + GLuint *tmp; + tmp = inlist; + inlist = outlist; + outlist = tmp; + incount = outcount; + } + + } /* if */ + } /* for p */ + + /* outlist points to the list of vertices resulting from the last */ + /* clipping. If outlist == vlist2 then we have to copy the vertices */ + /* back to vlist */ + if (outlist!=vlist2) { + MEMCPY( vlist, vlist2, outcount * sizeof(GLuint) ); + } + + return outcount; +} + diff --git a/dll/opengl/mesa/clip.h b/dll/opengl/mesa/clip.h new file mode 100644 index 00000000000..e51f03d8f6c --- /dev/null +++ b/dll/opengl/mesa/clip.h @@ -0,0 +1,98 @@ +/* $Id: clip.h,v 1.3 1998/02/03 23:45:36 brianp Exp $ */ + +/* + * Mesa 3-D graphics library + * Version: 2.6 + * Copyright (C) 1995-1996 Brian Paul + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Library General Public + * License as published by the Free Software Foundation; either + * version 2 of the License, or (at your option) any later version. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Library General Public License for more details. + * + * You should have received a copy of the GNU Library General Public + * License along with this library; if not, write to the Free + * Software Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. + */ + + +/* + * $Log: clip.h,v $ + * Revision 1.3 1998/02/03 23:45:36 brianp + * added space parameter to clip interpolation functions + * + * Revision 1.2 1998/01/06 02:40:52 brianp + * added DavidB's clipping interpolation optimization + * + * Revision 1.1 1996/09/13 01:38:16 brianp + * Initial revision + * + */ + + +#ifndef CLIP_H +#define CLIP_H + + +#include "types.h" + + + +#ifdef DEBUG +# define GL_VIEWCLIP_POINT( V ) gl_viewclip_point( V ) +#else +# define GL_VIEWCLIP_POINT( V ) \ + ( (V)[0] <= (V)[3] && (V)[0] >= -(V)[3] \ + && (V)[1] <= (V)[3] && (V)[1] >= -(V)[3] \ + && (V)[2] <= (V)[3] && (V)[2] >= -(V)[3] ) +#endif + + + + +extern GLuint gl_viewclip_point( const GLfloat v[] ); + +extern GLuint gl_viewclip_line( GLcontext* ctx, GLuint *i, GLuint *j ); + +extern GLuint gl_viewclip_polygon( GLcontext* ctx, GLuint n, GLuint vlist[] ); + + + +extern GLuint gl_userclip_point( GLcontext* ctx, const GLfloat v[] ); + +extern GLuint gl_userclip_line( GLcontext* ctx, GLuint *i, GLuint *j ); + +extern GLuint gl_userclip_polygon( GLcontext* ctx, GLuint n, GLuint vlist[] ); + + +extern void gl_ClipPlane( GLcontext* ctx, + GLenum plane, const GLfloat *equation ); + +extern void gl_GetClipPlane( GLcontext* ctx, + GLenum plane, GLdouble *equation ); + + +/* + * Clipping interpolation functions + */ + +extern void interpolate_aux( GLcontext *ctx, GLuint space, + GLuint dst, GLfloat t, GLuint in, GLuint out ); + +extern void interpolate_aux_color_tex2( GLcontext *ctx, GLuint space, + GLuint dst, GLfloat t, GLuint in, GLuint out ); + +extern void interpolate_aux_tex2( GLcontext *ctx, GLuint space, + GLuint dst, GLfloat t, GLuint in, GLuint out ); + +extern void interpolate_aux_color( GLcontext *ctx, GLuint space, + GLuint dst, GLfloat t, GLuint in, GLuint out ); + + +#endif + diff --git a/dll/opengl/mesa/colortab.c b/dll/opengl/mesa/colortab.c new file mode 100644 index 00000000000..4787ae665b9 --- /dev/null +++ b/dll/opengl/mesa/colortab.c @@ -0,0 +1,287 @@ +/* $Id: colortab.c,v 1.6 1997/10/16 02:26:18 brianp Exp $ */ + +/* + * Mesa 3-D graphics library + * Version: 2.5 + * Copyright (C) 1995-1997 Brian Paul + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Library General Public + * License as published by the Free Software Foundation; either + * version 2 of the License, or (at your option) any later version. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Library General Public License for more details. + * + * You should have received a copy of the GNU Library General Public + * License along with this library; if not, write to the Free + * Software Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. + */ + + +/* + * $Log: colortab.c,v $ + * Revision 1.6 1997/10/16 02:26:18 brianp + * call Driver.UpdateTexturePalette(ctx,NULL) when shared palette changed + * + * Revision 1.5 1997/10/16 01:59:08 brianp + * added GL_EXT_shared_texture_palette extension + * + * Revision 1.4 1997/10/15 23:37:05 brianp + * removed dirty flag stuff + * + * Revision 1.3 1997/10/13 23:50:03 brianp + * added call to Driver.UpdateTexturePalette + * + * Revision 1.2 1997/09/29 23:27:44 brianp + * updated for new device driver texture functions + * + * Revision 1.1 1997/09/27 00:12:46 brianp + * Initial revision + * + */ + + +#ifdef PC_HEADER +#include "all.h" +#else +#include "colortab.h" +#include "context.h" +#include "macros.h" +#endif + + + +/* + * Return GL_TRUE if k is a power of two, else return GL_FALSE. + */ +static GLboolean power_of_two( GLint k ) +{ + GLint i, m = 1; + for (i=0; i<32; i++) { + if (k == m) + return GL_TRUE; + m = m << 1; + } + return GL_FALSE; +} + + +static GLint decode_internal_format( GLint format ) +{ + switch (format) { + case GL_ALPHA: + case GL_ALPHA4: + case GL_ALPHA8: + case GL_ALPHA12: + case GL_ALPHA16: + return GL_ALPHA; + case 1: + case GL_LUMINANCE: + case GL_LUMINANCE4: + case GL_LUMINANCE8: + case GL_LUMINANCE12: + case GL_LUMINANCE16: + return GL_LUMINANCE; + case 2: + case GL_LUMINANCE_ALPHA: + case GL_LUMINANCE4_ALPHA4: + case GL_LUMINANCE6_ALPHA2: + case GL_LUMINANCE8_ALPHA8: + case GL_LUMINANCE12_ALPHA4: + case GL_LUMINANCE12_ALPHA12: + case GL_LUMINANCE16_ALPHA16: + return GL_LUMINANCE_ALPHA; + case GL_INTENSITY: + case GL_INTENSITY4: + case GL_INTENSITY8: + case GL_INTENSITY12: + case GL_INTENSITY16: + return GL_INTENSITY; + case 3: + case GL_RGB: + case GL_R3_G3_B2: + case GL_RGB4: + case GL_RGB5: + case GL_RGB8: + case GL_RGB10: + case GL_RGB12: + case GL_RGB16: + return GL_RGB; + case 4: + case GL_RGBA: + case GL_RGBA2: + case GL_RGBA4: + case GL_RGB5_A1: + case GL_RGBA8: + case GL_RGB10_A2: + case GL_RGBA12: + case GL_RGBA16: + return GL_RGBA; + default: + return -1; /* error */ + } +} + + +void gl_ColorTable( GLcontext *ctx, GLenum target, + GLenum internalFormat, struct gl_image *table ) +{ + struct gl_texture_object *texObj; + GLboolean proxy = GL_FALSE; + + if (INSIDE_BEGIN_END(ctx)) { + gl_error( ctx, GL_INVALID_OPERATION, "glGetBooleanv" ); + return; + } + + switch (target) { + case GL_TEXTURE_1D: + texObj = ctx->Texture.Current1D; + break; + case GL_TEXTURE_2D: + texObj = ctx->Texture.Current2D; + break; + case GL_PROXY_TEXTURE_1D: + texObj = ctx->Texture.Proxy1D; + proxy = GL_TRUE; + break; + case GL_PROXY_TEXTURE_2D: + texObj = ctx->Texture.Proxy2D; + proxy = GL_TRUE; + break; + default: + gl_error(ctx, GL_INVALID_ENUM, "glColorTableEXT(target)"); + return; + } + + /* internalformat = just like glTexImage */ + + if (table->Width < 1 || table->Width > MAX_TEXTURE_PALETTE_SIZE + || !power_of_two(table->Width)) { + gl_error(ctx, GL_INVALID_VALUE, "glColorTableEXT(width)"); + if (proxy) { + texObj->PaletteSize = 0; + texObj->PaletteIntFormat = 0; + texObj->PaletteFormat = 0; + } + return; + } + + /* per-texture object palette */ + texObj->PaletteSize = table->Width; + texObj->PaletteIntFormat = internalFormat; + texObj->PaletteFormat = decode_internal_format(internalFormat); + if (!proxy) { + MEMCPY(texObj->Palette, table->Data, table->Width*table->Components); + if (ctx->Driver.UpdateTexturePalette) { + (*ctx->Driver.UpdateTexturePalette)( ctx, texObj ); + } + } +} + + + +void gl_ColorSubTable( GLcontext *ctx, GLenum target, + GLsizei start, struct gl_image *data ) +{ + /* XXX TODO */ + gl_problem(ctx, "glColorSubTableEXT not implemented"); +} + + + +void gl_GetColorTable( GLcontext *ctx, GLenum target, GLenum format, + GLenum type, GLvoid *table ) +{ + if (INSIDE_BEGIN_END(ctx)) { + gl_error( ctx, GL_INVALID_OPERATION, "glGetBooleanv" ); + return; + } + + switch (target) { + case GL_TEXTURE_1D: + break; + case GL_TEXTURE_2D: + break; + case GL_TEXTURE_3D_EXT: + break; + default: + gl_error(ctx, GL_INVALID_ENUM, "glGetColorTableEXT(target)"); + return; + } + + gl_problem(ctx, "glGetColorTableEXT not implemented!"); +} + + + +void gl_GetColorTableParameterfv( GLcontext *ctx, GLenum target, + GLenum pname, GLfloat *params ) +{ + GLint iparams[10]; + + gl_GetColorTableParameteriv( ctx, target, pname, iparams ); + *params = (GLfloat) iparams[0]; +} + + + +void gl_GetColorTableParameteriv( GLcontext *ctx, GLenum target, + GLenum pname, GLint *params ) +{ + struct gl_texture_object *texObj; + + if (INSIDE_BEGIN_END(ctx)) { + gl_error( ctx, GL_INVALID_OPERATION, "glGetColorTableParameter" ); + return; + } + + switch (target) { + case GL_TEXTURE_1D: + texObj = ctx->Texture.Current1D; + break; + case GL_TEXTURE_2D: + texObj = ctx->Texture.Current2D; + break; + default: + gl_error(ctx, GL_INVALID_ENUM, "glGetColorTableParameter(target)"); + return; + } + + switch (pname) { + case GL_COLOR_TABLE_FORMAT_EXT: + if (texObj) + *params = texObj->PaletteIntFormat; + break; + case GL_COLOR_TABLE_WIDTH_EXT: + if (texObj) + *params = texObj->PaletteSize; + break; + case GL_COLOR_TABLE_RED_SIZE_EXT: + *params = 8; + break; + case GL_COLOR_TABLE_GREEN_SIZE_EXT: + *params = 8; + break; + case GL_COLOR_TABLE_BLUE_SIZE_EXT: + *params = 8; + break; + case GL_COLOR_TABLE_ALPHA_SIZE_EXT: + *params = 8; + break; + case GL_COLOR_TABLE_LUMINANCE_SIZE_EXT: + *params = 8; + break; + case GL_COLOR_TABLE_INTENSITY_SIZE_EXT: + *params = 8; + break; + default: + gl_error(ctx, GL_INVALID_ENUM, "glGetColorTableParameter" ); + return; + } +} + + diff --git a/dll/opengl/mesa/colortab.h b/dll/opengl/mesa/colortab.h new file mode 100644 index 00000000000..cc97e0b1f60 --- /dev/null +++ b/dll/opengl/mesa/colortab.h @@ -0,0 +1,65 @@ +/* $Id: colortab.h,v 1.1 1997/09/27 00:12:46 brianp Exp $ */ + +/* + * Mesa 3-D graphics library + * Version: 2.5 + * Copyright (C) 1995-1997 Brian Paul + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Library General Public + * License as published by the Free Software Foundation; either + * version 2 of the License, or (at your option) any later version. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Library General Public License for more details. + * + * You should have received a copy of the GNU Library General Public + * License along with this library; if not, write to the Free + * Software Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. + */ + + +/* + * $Log: colortab.h,v $ + * Revision 1.1 1997/09/27 00:12:46 brianp + * Initial revision + * + */ + + +#ifndef COLORTAB_H +#define COLORTAB_H + + +#include "types.h" + +#define GL_COLOR_TABLE_FORMAT_EXT 0x80D8 +#define GL_COLOR_TABLE_WIDTH_EXT 0x80D9 +#define GL_COLOR_TABLE_RED_SIZE_EXT 0x80DA +#define GL_COLOR_TABLE_GREEN_SIZE_EXT 0x80DB +#define GL_COLOR_TABLE_BLUE_SIZE_EXT 0x80DC +#define GL_COLOR_TABLE_ALPHA_SIZE_EXT 0x80DD +#define GL_COLOR_TABLE_LUMINANCE_SIZE_EXT 0x80DE +#define GL_COLOR_TABLE_INTENSITY_SIZE_EXT 0x80DF + + +extern void gl_ColorTable( GLcontext *ctx, GLenum target, + GLenum internalformat, + struct gl_image *table ); + +extern void gl_ColorSubTable( GLcontext *ctx, GLenum target, + GLsizei start, struct gl_image *data ); + +extern void gl_GetColorTable( GLcontext *ctx, GLenum target, GLenum format, + GLenum type, GLvoid *table ); + +extern void gl_GetColorTableParameterfv( GLcontext *ctx, GLenum target, + GLenum pname, GLfloat *params ); + +extern void gl_GetColorTableParameteriv( GLcontext *ctx, GLenum target, + GLenum pname, GLint *params ); + + +#endif diff --git a/dll/opengl/mesa/config.h b/dll/opengl/mesa/config.h new file mode 100644 index 00000000000..0c053331c29 --- /dev/null +++ b/dll/opengl/mesa/config.h @@ -0,0 +1,167 @@ +/* $Id: config.h,v 1.8 1997/09/27 00:13:44 brianp Exp $ */ + +/* + * Mesa 3-D graphics library + * Version: 2.5 + * Copyright (C) 1995-1997 Brian Paul + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Library General Public + * License as published by the Free Software Foundation; either + * version 2 of the License, or (at your option) any later version. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Library General Public License for more details. + * + * You should have received a copy of the GNU Library General Public + * License along with this library; if not, write to the Free + * Software Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. + */ + + +/* + * $Log: config.h,v $ + * Revision 1.8 1997/09/27 00:13:44 brianp + * added GL_EXT_paletted_texture extension + * + * Revision 1.7 1997/09/23 00:57:21 brianp + * removed MAX_DISPLAYLISTS + * + * Revision 1.6 1997/06/17 02:20:25 brianp + * changed MAX_WIDTH to 1600 and MAX_HEIGHT to 1200 + * + * Revision 1.5 1997/05/28 03:27:19 brianp + * set MAX_TEXTURE_LEVELS to 9 if compiling for 3Dfx driver (FX) + * + * Revision 1.4 1997/01/08 20:54:02 brianp + * added DITHER666 option from Michael Pichler + * + * Revision 1.3 1996/10/01 03:30:18 brianp + * changed MAX_DEPTH to 0x00ffffff for 32-bit depth buffer + * + * Revision 1.2 1996/09/15 01:49:26 brianp + * removed some junk + * + * Revision 1.1 1996/09/13 01:38:16 brianp + * Initial revision + * + */ + + + +/* + * Tunable configuration parameters. + */ + + + +#ifndef CONFIG_H +#define CONFIG_H + + + +/* Maximum modelview matrix stack depth: */ +#define MAX_MODELVIEW_STACK_DEPTH 32 + +/* Maximum projection matrix stack depth: */ +#define MAX_PROJECTION_STACK_DEPTH 32 + +/* Maximum texture matrix stack depth: */ +#define MAX_TEXTURE_STACK_DEPTH 10 + +/* Maximum attribute stack depth: */ +#define MAX_ATTRIB_STACK_DEPTH 16 + +/* Maximum client attribute stack depth: */ +#define MAX_CLIENT_ATTRIB_STACK_DEPTH 16 + +/* Maximum recursion depth of display list calls: */ +#define MAX_LIST_NESTING 64 + +/* Maximum number of lights: */ +#define MAX_LIGHTS 8 + +/* Maximum user-defined clipping planes: */ +#define MAX_CLIP_PLANES 6 + +/* Number of texture levels */ +#define MAX_TEXTURE_LEVELS 11 + +/* Max texture size */ +#define MAX_TEXTURE_SIZE (1 << (MAX_TEXTURE_LEVELS-1)) + +/* Maximum pixel map lookup table size: */ +#define MAX_PIXEL_MAP_TABLE 256 + +/* Number of auxillary color buffers: */ +#define NUM_AUX_BUFFERS 0 + +/* Maximum order (degree) of curves: */ +#ifdef AMIGA +# define MAX_EVAL_ORDER 12 +#else +# define MAX_EVAL_ORDER 30 +#endif + +/* Maximum Name stack depth */ +#define MAX_NAME_STACK_DEPTH 64 + +/* Min and Max point sizes and granularity */ +#define MIN_POINT_SIZE 1.0 +#define MAX_POINT_SIZE 10.0 +#define POINT_SIZE_GRANULARITY 0.1 + +/* Min and Max line widths and granularity */ +#define MIN_LINE_WIDTH 1.0 +#define MAX_LINE_WIDTH 10.0 +#define LINE_WIDTH_GRANULARITY 1.0 + +/* Max texture palette size */ +#define MAX_TEXTURE_PALETTE_SIZE 256 + + +/* Maximum viewport size: */ +#ifdef AMIGA +# define MAX_WIDTH 640 +# define MAX_HEIGHT 400 +#else +# define MAX_WIDTH 1600 +# define MAX_HEIGHT 1200 +#endif + + + +/* + * Bits per accumulation buffer color component: 8 or 16 + */ +#define ACCUM_BITS 16 + + +/* + * Bits per depth buffer value: 16 or 32 + */ +#define MAX_DEPTH 0x00ffffff +#define DEPTH_SCALE ((GLfloat) 0x00ffffff) + + +/* + * Bits per stencil value: 8 + */ +#define STENCIL_BITS 8 + + + +/*** + *** For X11 driver only: + ***/ + +/* + * When defined, use 6x6x6 dithering instead of 5x9x5. + * 5x9x5 better for general colors, 6x6x6 better for grayscale. + */ +/*#define DITHER666*/ + + +#endif diff --git a/dll/opengl/mesa/context.c b/dll/opengl/mesa/context.c new file mode 100644 index 00000000000..8d0e97a23f8 --- /dev/null +++ b/dll/opengl/mesa/context.c @@ -0,0 +1,1926 @@ +/* $Id: context.c,v 1.64 1998/02/05 00:34:56 brianp Exp $ */ + +/* + * Mesa 3-D graphics library + * Version: 2.6 + * Copyright (C) 1995-1997 Brian Paul + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Library General Public + * License as published by the Free Software Foundation; either + * version 2 of the License, or (at your option) any later version. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Library General Public License for more details. + * + * You should have received a copy of the GNU Library General Public + * License along with this library; if not, write to the Free + * Software Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. + */ + + +/* + * $Log: context.c,v $ + * Revision 1.64 1998/02/05 00:34:56 brianp + * added John Stone's initial thread modifications + * + * Revision 1.63 1998/01/06 02:40:52 brianp + * added DavidB's clipping interpolation optimization + * + * Revision 1.62 1997/12/31 06:10:03 brianp + * added Henk Kok's texture validation optimization (AnyDirty flag) + * + * Revision 1.61 1997/12/08 04:04:52 brianp + * changed gl_copy_context() to not use MEMCPY for PolygonStipple (John Stone) + * + * Revision 1.60 1997/12/06 18:06:50 brianp + * moved several static display list vars into GLcontext + * + * Revision 1.59 1997/11/25 03:37:53 brianp + * simple clean-ups for multi-threading (John Stone) + * + * Revision 1.58 1997/10/29 01:29:09 brianp + * added GL_EXT_point_parameters extension from Daniel Barrero + * + * Revision 1.57 1997/10/16 01:59:08 brianp + * added GL_EXT_shared_texture_palette extension + * + * Revision 1.56 1997/10/15 03:08:50 brianp + * don't clear depth buffer in gl_ResizeBuffersMESA() + * + * Revision 1.55 1997/09/29 22:25:28 brianp + * added const to a few function parameters + * + * Revision 1.54 1997/09/27 00:15:20 brianp + * added ctx->DirectContext flag + * + * Revision 1.53 1997/09/23 00:58:15 brianp + * now using hash table for texture objects + * + * Revision 1.52 1997/09/22 02:33:58 brianp + * display lists now implemented with hash table + * + * Revision 1.51 1997/09/17 01:39:11 brianp + * added update_clipmask() function from Michael Pichler + * + * Revision 1.50 1997/09/10 00:29:19 brianp + * set all NewState flags in gl_ResizeBuffersMESA() (Miklos Fazekas) + * + * Revision 1.49 1997/07/24 01:24:45 brianp + * changed precompiled header symbol from PCH to PC_HEADER + * + * Revision 1.48 1997/06/20 02:19:49 brianp + * replaced Current.IntColor with Current.ByteColor + * + * Revision 1.47 1997/06/20 01:57:28 brianp + * free_shared_state() didn't free display lists + * + * Revision 1.46 1997/05/31 16:57:14 brianp + * added MESA_NO_RASTER env var support + * + * Revision 1.45 1997/05/28 04:06:03 brianp + * implemented projection near/far value stack for Driver.NearFar() function + * + * Revision 1.44 1997/05/28 03:23:48 brianp + * added precompiled header (PCH) support + * + * Revision 1.43 1997/05/26 21:18:54 brianp + * better comments + * + * Revision 1.42 1997/05/26 21:14:13 brianp + * gl_create_visual() now takes red/green/blue/alpha_bits arguments + * + * Revision 1.41 1997/05/24 12:07:07 brianp + * removed unused vars + * + * Revision 1.40 1997/05/14 03:27:24 brianp + * miscellaneous alloc/free clean-ups + * + * Revision 1.39 1997/05/09 22:42:09 brianp + * replaced gl_init_vb() with gl_alloc_vb(), similarly for pb + * + * Revision 1.38 1997/05/01 02:07:35 brianp + * added shared state variable NextFreeTextureName + * + * Revision 1.37 1997/05/01 01:25:33 brianp + * added call to gl_init_math() + * + * Revision 1.36 1997/04/28 02:06:14 brianp + * also check if texturing enabled in the test for NeedNormals + * + * Revision 1.35 1997/04/26 04:34:43 brianp + * fixed problem with Depth/Accum/StencilBits initialization (Mark Kilgard) + * + * Revision 1.34 1997/04/24 01:49:02 brianp + * call gl_set_color_function() instead of directly setting pointers + * + * Revision 1.33 1997/04/24 00:18:10 brianp + * Proxy2D tex object was allocated twice. reported by Randy Frank. + * + * Revision 1.32 1997/04/16 23:55:06 brianp + * added gl_set_api_table() + * + * Revision 1.31 1997/04/14 02:01:03 brianp + * #include "texstate.h" instead of "texture.h" + * + * Revision 1.30 1997/04/12 17:11:38 brianp + * added gl_get_current_context() + * + * Revision 1.29 1997/04/12 16:54:05 brianp + * new NEW_POLYGON state flag + * + * Revision 1.28 1997/04/12 16:20:51 brianp + * added call to Driver.Dither() in gl_update_state() + * + * Revision 1.27 1997/04/12 12:25:37 brianp + * added Driver.QuadFunc and Driver.RectFunc + * + * Revision 1.26 1997/04/01 04:20:22 brianp + * added new matrix type code + * + * Revision 1.25 1997/03/14 00:24:37 brianp + * only print runtime warnings if MESA_DEBUG env var is set + * + * Revision 1.24 1997/03/13 03:06:14 brianp + * init AlphaRefUbyte to zero + * + * Revision 1.23 1997/03/08 01:59:00 brianp + * if RenderMode != GL_RENDER then don't enable ctx->DirectTriangles + * + * Revision 1.22 1997/02/27 19:57:38 brianp + * added gl_problem() function + * + * Revision 1.21 1997/02/10 19:49:50 brianp + * added gl_ResizeBuffersMESA() + * + * Revision 1.20 1997/02/10 19:22:47 brianp + * added device driver Error() function + * + * Revision 1.19 1997/02/09 18:50:05 brianp + * added GL_EXT_texture3D support + * + * Revision 1.18 1997/01/28 22:15:14 brianp + * now there's separate state for CI and RGBA logic op enabled + * + * Revision 1.17 1997/01/09 19:56:09 brianp + * new error message format in gl_error() + * + * Revision 1.16 1997/01/09 19:47:32 brianp + * better checking and handling of out-of-memory errors + * + * Revision 1.15 1996/12/18 20:00:12 brianp + * added code to initialize ColorMaterialBitmask + * + * Revision 1.14 1996/12/11 20:18:53 brianp + * changed formatting of messages in gl_warning() + * + * Revision 1.13 1996/11/08 02:20:52 brianp + * added check for MESA_NO_RASTER env var + * + * Revision 1.12 1996/11/04 02:18:47 brianp + * multiply Viewport.Sz and .Tz by DEPTH_SCALE + * + * Revision 1.11 1996/10/16 00:52:22 brianp + * gl_initialize_api_function_pointers() now gl_init_api_function_pointers() + * + * Revision 1.10 1996/10/11 03:41:28 brianp + * removed Polygon.OffsetBias initialization + * + * Revision 1.9 1996/10/11 00:26:34 brianp + * initialize Point/Line/PolygonZoffset to 0.0 + * + * Revision 1.8 1996/10/01 01:42:31 brianp + * moved device driver initialization into gl_update_state() + * + * Revision 1.7 1996/09/27 01:24:33 brianp + * removed unneeded set_thread_context(), added call to gl_init_vb() + * + * Revision 1.6 1996/09/25 03:22:53 brianp + * added NO_DRAW_BIT for glDrawBuffer(GL_NONE) + * + * Revision 1.5 1996/09/20 02:55:52 brianp + * fixed profiling bug + * + * Revision 1.4 1996/09/19 03:14:49 brianp + * now just one parameter for gl_create_framebuffer() + * + * Revision 1.3 1996/09/15 14:20:22 brianp + * added new functions for GLframebuffer and GLvisual support + * + * Revision 1.2 1996/09/14 20:12:05 brianp + * wasn't initializing a few pieces of context state + * + * Revision 1.1 1996/09/13 01:38:16 brianp + * Initial revision + * + */ + + +/* + * If multi-threading is enabled (-DTHREADS) then each thread has it's + * own rendering context. A thread obtains the pointer to its GLcontext + * with the gl_get_thread_context() function. Otherwise, the global + * pointer, CC, points to the current context used by all threads in + * the address space. + */ + + +#ifdef PC_HEADER +#include "all.h" +#else +#include +#include +#include +#include +#include +#include "accum.h" +#include "alphabuf.h" +#include "clip.h" +#include "context.h" +#include "depth.h" +#include "eval.h" +#include "hash.h" +#include "light.h" +#include "lines.h" +#include "dlist.h" +#include "macros.h" +#include "mmath.h" +#include "pb.h" +#include "points.h" +#include "pointers.h" +#include "quads.h" +#include "stencil.h" +#include "triangle.h" +#include "teximage.h" +#include "texobj.h" +#include "texstate.h" +#include "types.h" +#include "vb.h" +#include "vbfill.h" +#endif + +#include +WINE_DEFAULT_DEBUG_CHANNEL(opengl32); + + + +/**********************************************************************/ +/***** Context and Thread management *****/ +/**********************************************************************/ + + + + +/**********************************************************************/ +/***** Profiling functions *****/ +/**********************************************************************/ + +#ifdef PROFILE + +#include +#include + + +/* + * Return system time in seconds. + * NOTE: this implementation may not be very portable! + */ +GLdouble gl_time( void ) +{ + static GLdouble prev_time = 0.0; + static GLdouble time; + struct tms tm; + clock_t clk; + + clk = times(&tm); + +#ifdef CLK_TCK + time = (double)clk / (double)CLK_TCK; +#else + time = (double)clk / (double)HZ; +#endif + + if (time>prev_time) { + prev_time = time; + return time; + } + else { + return prev_time; + } +} + + + +/* + * Reset the timing/profiling counters + */ +static void init_timings( GLcontext *ctx ) +{ + ctx->BeginEndCount = 0; + ctx->BeginEndTime = 0.0; + ctx->VertexCount = 0; + ctx->VertexTime = 0.0; + ctx->PointCount = 0; + ctx->PointTime = 0.0; + ctx->LineCount = 0; + ctx->LineTime = 0.0; + ctx->PolygonCount = 0; + ctx->PolygonTime = 0.0; + ctx->ClearCount = 0; + ctx->ClearTime = 0.0; + ctx->SwapCount = 0; + ctx->SwapTime = 0.0; +} + + + +/* + * Print the accumulated timing/profiling data. + */ +static void print_timings( GLcontext *ctx ) +{ + GLdouble beginendrate; + GLdouble vertexrate; + GLdouble pointrate; + GLdouble linerate; + GLdouble polygonrate; + GLdouble overhead; + GLdouble clearrate; + GLdouble swaprate; + GLdouble avgvertices; + + if (ctx->BeginEndTime>0.0) { + beginendrate = ctx->BeginEndCount / ctx->BeginEndTime; + } + else { + beginendrate = 0.0; + } + if (ctx->VertexTime>0.0) { + vertexrate = ctx->VertexCount / ctx->VertexTime; + } + else { + vertexrate = 0.0; + } + if (ctx->PointTime>0.0) { + pointrate = ctx->PointCount / ctx->PointTime; + } + else { + pointrate = 0.0; + } + if (ctx->LineTime>0.0) { + linerate = ctx->LineCount / ctx->LineTime; + } + else { + linerate = 0.0; + } + if (ctx->PolygonTime>0.0) { + polygonrate = ctx->PolygonCount / ctx->PolygonTime; + } + else { + polygonrate = 0.0; + } + if (ctx->ClearTime>0.0) { + clearrate = ctx->ClearCount / ctx->ClearTime; + } + else { + clearrate = 0.0; + } + if (ctx->SwapTime>0.0) { + swaprate = ctx->SwapCount / ctx->SwapTime; + } + else { + swaprate = 0.0; + } + + if (ctx->BeginEndCount>0) { + avgvertices = (GLdouble) ctx->VertexCount / (GLdouble) ctx->BeginEndCount; + } + else { + avgvertices = 0.0; + } + + overhead = ctx->BeginEndTime - ctx->VertexTime - ctx->PointTime + - ctx->LineTime - ctx->PolygonTime; + + + printf(" Count Time (s) Rate (/s) \n"); + printf("--------------------------------------------------------\n"); + printf("glBegin/glEnd %7d %8.3f %10.3f\n", + ctx->BeginEndCount, ctx->BeginEndTime, beginendrate); + printf(" vertexes transformed %7d %8.3f %10.3f\n", + ctx->VertexCount, ctx->VertexTime, vertexrate ); + printf(" points rasterized %7d %8.3f %10.3f\n", + ctx->PointCount, ctx->PointTime, pointrate ); + printf(" lines rasterized %7d %8.3f %10.3f\n", + ctx->LineCount, ctx->LineTime, linerate ); + printf(" polygons rasterized %7d %8.3f %10.3f\n", + ctx->PolygonCount, ctx->PolygonTime, polygonrate ); + printf(" overhead %8.3f\n", overhead ); + printf("glClear %7d %8.3f %10.3f\n", + ctx->ClearCount, ctx->ClearTime, clearrate ); + printf("SwapBuffers %7d %8.3f %10.3f\n", + ctx->SwapCount, ctx->SwapTime, swaprate ); + printf("\n"); + + printf("Average number of vertices per begin/end: %8.3f\n", avgvertices ); +} +#endif + + + + + +/**********************************************************************/ +/***** Context allocation, initialization, destroying *****/ +/**********************************************************************/ + + +/* + * Allocate and initialize a shared context state structure. + */ +static struct gl_shared_state *alloc_shared_state( void ) +{ + struct gl_shared_state *ss; + + ss = (struct gl_shared_state*) calloc( 1, sizeof(struct gl_shared_state) ); + if (!ss) + return NULL; + + ss->DisplayList = NewHashTable(); + + ss->TexObjects = NewHashTable(); + + /* Default Texture objects */ + ss->Default1D = gl_alloc_texture_object(ss, 0, 1); + ss->Default2D = gl_alloc_texture_object(ss, 0, 2); + + if (!ss->DisplayList || !ss->TexObjects + || !ss->Default1D || !ss->Default2D) { + /* Ran out of memory at some point. Free everything and return NULL */ + if (!ss->DisplayList) + DeleteHashTable(ss->DisplayList); + if (!ss->TexObjects) + DeleteHashTable(ss->TexObjects); + if (!ss->Default1D) + gl_free_texture_object(ss, ss->Default1D); + if (!ss->Default2D) + gl_free_texture_object(ss, ss->Default2D); + free(ss); + return NULL; + } + else { + return ss; + } +} + + +/* + * Deallocate a shared state context and all children structures. + */ +static void free_shared_state( GLcontext *ctx, struct gl_shared_state *ss ) +{ + /* Free display lists */ + while (1) { + GLuint list = HashFirstEntry(ss->DisplayList); + if (list) { + gl_destroy_list(ctx, list); + } + else { + break; + } + } + DeleteHashTable(ss->DisplayList); + + /* Free texture objects */ + while (ss->TexObjectList) + { + /* this function removes from linked list too! */ + gl_free_texture_object(ss, ss->TexObjectList); + } + DeleteHashTable(ss->TexObjects); + + free(ss); +} + + + + +/* + * Initialize the nth light. Note that the defaults for light 0 are + * different than the other lights. + */ +static void init_light( struct gl_light *l, GLuint n ) +{ + ASSIGN_4V( l->Ambient, 0.0, 0.0, 0.0, 1.0 ); + if (n==0) { + ASSIGN_4V( l->Diffuse, 1.0, 1.0, 1.0, 1.0 ); + ASSIGN_4V( l->Specular, 1.0, 1.0, 1.0, 1.0 ); + } + else { + ASSIGN_4V( l->Diffuse, 0.0, 0.0, 0.0, 1.0 ); + ASSIGN_4V( l->Specular, 0.0, 0.0, 0.0, 1.0 ); + } + ASSIGN_4V( l->Position, 0.0, 0.0, 1.0, 0.0 ); + ASSIGN_3V( l->Direction, 0.0, 0.0, -1.0 ); + l->SpotExponent = 0.0; + gl_compute_spot_exp_table( l ); + l->SpotCutoff = 180.0; + l->CosCutoff = -1.0; + l->ConstantAttenuation = 1.0; + l->LinearAttenuation = 0.0; + l->QuadraticAttenuation = 0.0; + l->Enabled = GL_FALSE; +} + + + +static void init_lightmodel( struct gl_lightmodel *lm ) +{ + ASSIGN_4V( lm->Ambient, 0.2f, 0.2f, 0.2f, 1.0f ); + lm->LocalViewer = GL_FALSE; + lm->TwoSide = GL_FALSE; +} + + +static void init_material( struct gl_material *m ) +{ + ASSIGN_4V( m->Ambient, 0.2f, 0.2f, 0.2f, 1.0f ); + ASSIGN_4V( m->Diffuse, 0.8f, 0.8f, 0.8f, 1.0f ); + ASSIGN_4V( m->Specular, 0.0f, 0.0f, 0.0f, 1.0f ); + ASSIGN_4V( m->Emission, 0.0f, 0.0f, 0.0f, 1.0f ); + m->Shininess = 0.0; + m->AmbientIndex = 0; + m->DiffuseIndex = 1; + m->SpecularIndex = 1; + gl_compute_material_shine_table( m ); +} + + + +/* + * Initialize a gl_context structure to default values. + */ +static void initialize_context( GLcontext *ctx ) +{ + static GLfloat identity[16] = { + 1.0, 0.0, 0.0, 0.0, + 0.0, 1.0, 0.0, 0.0, + 0.0, 0.0, 1.0, 0.0, + 0.0, 0.0, 0.0, 1.0 + }; + GLuint i; + + if (ctx) { + /* Modelview matrix stuff */ + ctx->NewModelViewMatrix = GL_FALSE; + ctx->ModelViewMatrixType = MATRIX_IDENTITY; + MEMCPY( ctx->ModelViewMatrix, identity, 16*sizeof(GLfloat) ); + MEMCPY( ctx->ModelViewInv, identity, 16*sizeof(GLfloat) ); + ctx->ModelViewStackDepth = 0; + + /* Projection matrix stuff */ + ctx->NewProjectionMatrix = GL_FALSE; + ctx->ProjectionMatrixType = MATRIX_IDENTITY; + MEMCPY( ctx->ProjectionMatrix, identity, 16*sizeof(GLfloat) ); + ctx->ProjectionStackDepth = 0; + ctx->NearFarStack[0][0] = 1.0; /* These values seem weird by make */ + ctx->NearFarStack[0][1] = 0.0; /* sense mathematically. */ + + /* Texture matrix stuff */ + ctx->NewTextureMatrix = GL_FALSE; + ctx->TextureMatrixType = MATRIX_IDENTITY; + MEMCPY( ctx->TextureMatrix, identity, 16*sizeof(GLfloat) ); + ctx->TextureStackDepth = 0; + + /* Accumulate buffer group */ + ASSIGN_4V( ctx->Accum.ClearColor, 0.0, 0.0, 0.0, 0.0 ); + + /* Color buffer group */ + ctx->Color.IndexMask = 0xffffffff; + ctx->Color.ColorMask = 0xf; + ctx->Color.SWmasking = GL_FALSE; + ctx->Color.ClearIndex = 0; + ASSIGN_4V( ctx->Color.ClearColor, 0.0, 0.0, 0.0, 0.0 ); + ctx->Color.DrawBuffer = GL_FRONT; + ctx->Color.AlphaEnabled = GL_FALSE; + ctx->Color.AlphaFunc = GL_ALWAYS; + ctx->Color.AlphaRef = 0.0; + ctx->Color.AlphaRefUbyte = 0; + ctx->Color.BlendEnabled = GL_FALSE; + ctx->Color.BlendSrc = GL_ONE; + ctx->Color.BlendDst = GL_ZERO; + ctx->Color.IndexLogicOpEnabled = GL_FALSE; + ctx->Color.ColorLogicOpEnabled = GL_FALSE; + ctx->Color.SWLogicOpEnabled = GL_FALSE; + ctx->Color.LogicOp = GL_COPY; + ctx->Color.DitherFlag = GL_TRUE; + + /* Current group */ + ctx->Current.Index = 1; + ASSIGN_3V( ctx->Current.Normal, 0.0, 0.0, 1.0 ); + ctx->Current.ByteColor[0] = (GLint) ctx->Visual->RedScale; + ctx->Current.ByteColor[1] = (GLint) ctx->Visual->GreenScale; + ctx->Current.ByteColor[2] = (GLint) ctx->Visual->BlueScale; + ctx->Current.ByteColor[3] = (GLint) ctx->Visual->AlphaScale; + ASSIGN_4V( ctx->Current.RasterPos, 0.0, 0.0, 0.0, 1.0 ); + ctx->Current.RasterPosValid = GL_TRUE; + ctx->Current.RasterIndex = 1; + ASSIGN_4V( ctx->Current.TexCoord, 0.0, 0.0, 0.0, 1.0 ); + ASSIGN_4V( ctx->Current.RasterColor, 1.0, 1.0, 1.0, 1.0 ); + ctx->Current.EdgeFlag = GL_TRUE; + + /* Depth buffer group */ + ctx->Depth.Test = GL_FALSE; + ctx->Depth.Clear = 1.0; + ctx->Depth.Func = GL_LESS; + ctx->Depth.Mask = GL_TRUE; + + /* Evaluators group */ + ctx->Eval.Map1Color4 = GL_FALSE; + ctx->Eval.Map1Index = GL_FALSE; + ctx->Eval.Map1Normal = GL_FALSE; + ctx->Eval.Map1TextureCoord1 = GL_FALSE; + ctx->Eval.Map1TextureCoord2 = GL_FALSE; + ctx->Eval.Map1TextureCoord3 = GL_FALSE; + ctx->Eval.Map1TextureCoord4 = GL_FALSE; + ctx->Eval.Map1Vertex3 = GL_FALSE; + ctx->Eval.Map1Vertex4 = GL_FALSE; + ctx->Eval.Map2Color4 = GL_FALSE; + ctx->Eval.Map2Index = GL_FALSE; + ctx->Eval.Map2Normal = GL_FALSE; + ctx->Eval.Map2TextureCoord1 = GL_FALSE; + ctx->Eval.Map2TextureCoord2 = GL_FALSE; + ctx->Eval.Map2TextureCoord3 = GL_FALSE; + ctx->Eval.Map2TextureCoord4 = GL_FALSE; + ctx->Eval.Map2Vertex3 = GL_FALSE; + ctx->Eval.Map2Vertex4 = GL_FALSE; + ctx->Eval.AutoNormal = GL_FALSE; + ctx->Eval.MapGrid1un = 1; + ctx->Eval.MapGrid1u1 = 0.0; + ctx->Eval.MapGrid1u2 = 1.0; + ctx->Eval.MapGrid2un = 1; + ctx->Eval.MapGrid2vn = 1; + ctx->Eval.MapGrid2u1 = 0.0; + ctx->Eval.MapGrid2u2 = 1.0; + ctx->Eval.MapGrid2v1 = 0.0; + ctx->Eval.MapGrid2v2 = 1.0; + + /* Fog group */ + ctx->Fog.Enabled = GL_FALSE; + ctx->Fog.Mode = GL_EXP; + ASSIGN_4V( ctx->Fog.Color, 0.0, 0.0, 0.0, 0.0 ); + ctx->Fog.Index = 0.0; + ctx->Fog.Density = 1.0; + ctx->Fog.Start = 0.0; + ctx->Fog.End = 1.0; + + /* Hint group */ + ctx->Hint.PerspectiveCorrection = GL_DONT_CARE; + ctx->Hint.PointSmooth = GL_DONT_CARE; + ctx->Hint.LineSmooth = GL_DONT_CARE; + ctx->Hint.PolygonSmooth = GL_DONT_CARE; + ctx->Hint.Fog = GL_DONT_CARE; + + /* Lighting group */ + for (i=0;iLight.Light[i], i ); + } + init_lightmodel( &ctx->Light.Model ); + init_material( &ctx->Light.Material[0] ); + init_material( &ctx->Light.Material[1] ); + ctx->Light.ShadeModel = GL_SMOOTH; + ctx->Light.Enabled = GL_FALSE; + ctx->Light.ColorMaterialFace = GL_FRONT_AND_BACK; + ctx->Light.ColorMaterialMode = GL_AMBIENT_AND_DIFFUSE; + ctx->Light.ColorMaterialBitmask + = gl_material_bitmask( GL_FRONT_AND_BACK, GL_AMBIENT_AND_DIFFUSE ); + + ctx->Light.ColorMaterialEnabled = GL_FALSE; + + /* Line group */ + ctx->Line.SmoothFlag = GL_FALSE; + ctx->Line.StippleFlag = GL_FALSE; + ctx->Line.Width = 1.0; + ctx->Line.StipplePattern = 0xffff; + ctx->Line.StippleFactor = 1; + + /* Display List group */ + ctx->List.ListBase = 0; + + /* Pixel group */ + ctx->Pixel.RedBias = 0.0; + ctx->Pixel.RedScale = 1.0; + ctx->Pixel.GreenBias = 0.0; + ctx->Pixel.GreenScale = 1.0; + ctx->Pixel.BlueBias = 0.0; + ctx->Pixel.BlueScale = 1.0; + ctx->Pixel.AlphaBias = 0.0; + ctx->Pixel.AlphaScale = 1.0; + ctx->Pixel.DepthBias = 0.0; + ctx->Pixel.DepthScale = 1.0; + ctx->Pixel.IndexOffset = 0; + ctx->Pixel.IndexShift = 0; + ctx->Pixel.ZoomX = 1.0; + ctx->Pixel.ZoomY = 1.0; + ctx->Pixel.MapColorFlag = GL_FALSE; + ctx->Pixel.MapStencilFlag = GL_FALSE; + ctx->Pixel.MapStoSsize = 1; + ctx->Pixel.MapItoIsize = 1; + ctx->Pixel.MapItoRsize = 1; + ctx->Pixel.MapItoGsize = 1; + ctx->Pixel.MapItoBsize = 1; + ctx->Pixel.MapItoAsize = 1; + ctx->Pixel.MapRtoRsize = 1; + ctx->Pixel.MapGtoGsize = 1; + ctx->Pixel.MapBtoBsize = 1; + ctx->Pixel.MapAtoAsize = 1; + ctx->Pixel.MapStoS[0] = 0; + ctx->Pixel.MapItoI[0] = 0; + ctx->Pixel.MapItoR[0] = 0.0; + ctx->Pixel.MapItoG[0] = 0.0; + ctx->Pixel.MapItoB[0] = 0.0; + ctx->Pixel.MapItoA[0] = 0.0; + ctx->Pixel.MapRtoR[0] = 0.0; + ctx->Pixel.MapGtoG[0] = 0.0; + ctx->Pixel.MapBtoB[0] = 0.0; + ctx->Pixel.MapAtoA[0] = 0.0; + + /* Point group */ + ctx->Point.SmoothFlag = GL_FALSE; + ctx->Point.Size = 1.0; + + /* Polygon group */ + ctx->Polygon.CullFlag = GL_FALSE; + ctx->Polygon.CullFaceMode = GL_BACK; + ctx->Polygon.FrontFace = GL_CCW; + ctx->Polygon.FrontMode = GL_FILL; + ctx->Polygon.BackMode = GL_FILL; + ctx->Polygon.Unfilled = GL_FALSE; + ctx->Polygon.SmoothFlag = GL_FALSE; + ctx->Polygon.StippleFlag = GL_FALSE; + ctx->Polygon.OffsetFactor = 0.0F; + ctx->Polygon.OffsetUnits = 0.0F; + ctx->Polygon.OffsetPoint = GL_FALSE; + ctx->Polygon.OffsetLine = GL_FALSE; + ctx->Polygon.OffsetFill = GL_FALSE; + ctx->Polygon.OffsetAny = GL_FALSE; + + /* Polygon Stipple group */ + MEMSET( ctx->PolygonStipple, 0xff, 32*sizeof(GLuint) ); + + /* Scissor group */ + ctx->Scissor.Enabled = GL_FALSE; + ctx->Scissor.X = 0; + ctx->Scissor.Y = 0; + ctx->Scissor.Width = 0; + ctx->Scissor.Height = 0; + + /* Stencil group */ + ctx->Stencil.Enabled = GL_FALSE; + ctx->Stencil.Function = GL_ALWAYS; + ctx->Stencil.FailFunc = GL_KEEP; + ctx->Stencil.ZPassFunc = GL_KEEP; + ctx->Stencil.ZFailFunc = GL_KEEP; + ctx->Stencil.Ref = 0; + ctx->Stencil.ValueMask = 0xff; + ctx->Stencil.Clear = 0; + ctx->Stencil.WriteMask = 0xff; + + /* Texture group */ + ctx->Texture.Enabled = 0; + ctx->Texture.EnvMode = GL_MODULATE; + ASSIGN_4V( ctx->Texture.EnvColor, 0.0, 0.0, 0.0, 0.0 ); + ctx->Texture.TexGenEnabled = 0; + ctx->Texture.GenModeS = GL_EYE_LINEAR; + ctx->Texture.GenModeT = GL_EYE_LINEAR; + ctx->Texture.GenModeR = GL_EYE_LINEAR; + ctx->Texture.GenModeQ = GL_EYE_LINEAR; + ASSIGN_4V( ctx->Texture.ObjectPlaneS, 1.0, 0.0, 0.0, 0.0 ); + ASSIGN_4V( ctx->Texture.ObjectPlaneT, 0.0, 1.0, 0.0, 0.0 ); + ASSIGN_4V( ctx->Texture.ObjectPlaneR, 0.0, 0.0, 0.0, 0.0 ); + ASSIGN_4V( ctx->Texture.ObjectPlaneQ, 0.0, 0.0, 0.0, 0.0 ); + ASSIGN_4V( ctx->Texture.EyePlaneS, 1.0, 0.0, 0.0, 0.0 ); + ASSIGN_4V( ctx->Texture.EyePlaneT, 0.0, 1.0, 0.0, 0.0 ); + ASSIGN_4V( ctx->Texture.EyePlaneR, 0.0, 0.0, 0.0, 0.0 ); + ASSIGN_4V( ctx->Texture.EyePlaneQ, 0.0, 0.0, 0.0, 0.0 ); + + ctx->Texture.Current1D = ctx->Shared->Default1D; + ctx->Texture.Current2D = ctx->Shared->Default2D; + + ctx->Texture.AnyDirty = GL_FALSE; + + /* Transformation group */ + ctx->Transform.MatrixMode = GL_MODELVIEW; + ctx->Transform.Normalize = GL_FALSE; + for (i=0;iTransform.ClipEnabled[i] = GL_FALSE; + ASSIGN_4V( ctx->Transform.ClipEquation[i], 0.0, 0.0, 0.0, 0.0 ); + } + ctx->Transform.AnyClip = GL_FALSE; + + /* Viewport group */ + ctx->Viewport.X = 0; + ctx->Viewport.Y = 0; + ctx->Viewport.Width = 0; + ctx->Viewport.Height = 0; + ctx->Viewport.Near = 0.0; + ctx->Viewport.Far = 1.0; + ctx->Viewport.Sx = 0.0; /* Sx, Tx, Sy, Ty are computed later */ + ctx->Viewport.Tx = 0.0; + ctx->Viewport.Sy = 0.0; + ctx->Viewport.Ty = 0.0; + ctx->Viewport.Sz = 0.5 * DEPTH_SCALE; + ctx->Viewport.Tz = 0.5 * DEPTH_SCALE; + + /* Pixel transfer */ + ctx->Pack.Alignment = 4; + ctx->Pack.RowLength = 0; + ctx->Pack.SkipPixels = 0; + ctx->Pack.SkipRows = 0; + ctx->Pack.SwapBytes = GL_FALSE; + ctx->Pack.LsbFirst = GL_FALSE; + ctx->Unpack.Alignment = 4; + ctx->Unpack.RowLength = 0; + ctx->Unpack.SkipPixels = 0; + ctx->Unpack.SkipRows = 0; + ctx->Unpack.SwapBytes = GL_FALSE; + ctx->Unpack.LsbFirst = GL_FALSE; + + /* Feedback */ + ctx->Feedback.Type = GL_2D; /* TODO: verify */ + ctx->Feedback.Buffer = NULL; + ctx->Feedback.BufferSize = 0; + ctx->Feedback.Count = 0; + + /* Selection/picking */ + ctx->Select.Buffer = NULL; + ctx->Select.BufferSize = 0; + ctx->Select.BufferCount = 0; + ctx->Select.Hits = 0; + ctx->Select.NameStackDepth = 0; + + /* Renderer and client attribute stacks */ + ctx->AttribStackDepth = 0; + ctx->ClientAttribStackDepth = 0; + + /*** Miscellaneous ***/ + ctx->NewState = NEW_ALL; + ctx->RenderMode = GL_RENDER; + ctx->Primitive = GL_BITMAP; + + ctx->StippleCounter = 0; + ctx->NeedNormals = GL_FALSE; + + if ( ctx->Visual->RedScale==255.0F + && ctx->Visual->GreenScale==255.0F + && ctx->Visual->BlueScale==255.0F + && ctx->Visual->AlphaScale==255.0F) { + ctx->Visual->EightBitColor = GL_TRUE; + } + else { + ctx->Visual->EightBitColor = GL_FALSE; + } + ctx->FastDrawPixels = ctx->Visual->RGBAflag && ctx->Visual->EightBitColor; + +#if JUNK + ctx->PointsFunc = NULL; + ctx->LineFunc = NULL; + ctx->TriangleFunc = NULL; +#endif + + ctx->DirectContext = GL_TRUE; /* XXXX temp */ + + /* Display list */ + ctx->CallDepth = 0; + ctx->ExecuteFlag = GL_TRUE; + ctx->CompileFlag = GL_FALSE; + ctx->CurrentListPtr = NULL; + ctx->CurrentBlock = NULL; + ctx->CurrentListNum = 0; + ctx->CurrentPos = 0; + + ctx->ErrorValue = GL_NO_ERROR; + + /* For debug/development only */ + ctx->NoRaster = getenv("MESA_NO_RASTER") ? GL_TRUE : GL_FALSE; + + /* Dither disable */ + ctx->NoDither = getenv("MESA_NO_DITHER") ? GL_TRUE : GL_FALSE; + if (ctx->NoDither) { + TRACE("MESA_NO_DITHER set - dithering disabled\n"); + ctx->Color.DitherFlag = GL_FALSE; + } + } +} + + + +/* + * Allocate a new GLvisual object. + * Input: rgb_flag - GL_TRUE=RGB(A) mode, GL_FALSE=Color Index mode + * alpha_flag - alloc software alpha buffers? + * db_flag - double buffering? + * depth_bits - requested minimum bits per depth buffer value + * stencil_bits - requested minimum bits per stencil buffer value + * accum_bits - requested minimum bits per accum buffer component + * index_bits - number of bits per pixel if rgb_flag==GL_FALSE + * red/green/blue_scale - float-to-int color scaling + * alpha_scale - ignored if alpha_flag is true + * red/green/blue/alpha_bits - number of bits per color component + * in frame buffer for RGB(A) mode. + * Return: pointer to new GLvisual or NULL if requested parameters can't + * be met. + */ +GLvisual *gl_create_visual( GLboolean rgb_flag, + GLboolean alpha_flag, + GLboolean db_flag, + GLint depth_bits, + GLint stencil_bits, + GLint accum_bits, + GLint index_bits, + GLfloat red_scale, + GLfloat green_scale, + GLfloat blue_scale, + GLfloat alpha_scale, + GLint red_bits, + GLint green_bits, + GLint blue_bits, + GLint alpha_bits ) +{ + GLvisual *vis; + + /* Can't do better than 8-bit/channel color at this time */ + assert( red_scale<=255.0 ); + assert( green_scale<=255.0 ); + assert( blue_scale<=255.0 ); + assert( alpha_scale<=255.0 ); + + if (depth_bits > 8*sizeof(GLdepth)) { + /* can't meet depth buffer requirements */ + return NULL; + } + if (stencil_bits > 8*sizeof(GLstencil)) { + /* can't meet stencil buffer requirements */ + return NULL; + } + if (accum_bits > 8*sizeof(GLaccum)) { + /* can't meet accum buffer requirements */ + return NULL; + } + + vis = (GLvisual *) calloc( 1, sizeof(GLvisual) ); + if (!vis) { + return NULL; + } + + vis->RGBAflag = rgb_flag; + vis->DBflag = db_flag; + vis->RedScale = red_scale; + vis->GreenScale = green_scale; + vis->BlueScale = blue_scale; + vis->AlphaScale = alpha_scale; + if (red_scale) { + vis->InvRedScale = 1.0F / red_scale; + } + if (green_scale) { + vis->InvGreenScale = 1.0F / green_scale; + } + if (blue_scale) { + vis->InvBlueScale = 1.0F / blue_scale; + } + if (alpha_scale) { + vis->InvAlphaScale = 1.0F / alpha_scale; + } + + vis->RedBits = red_bits; + vis->GreenBits = green_bits; + vis->BlueBits = blue_bits; + vis->AlphaBits = alpha_flag ? 8*sizeof(GLubyte) : alpha_bits; + + vis->IndexBits = index_bits; + vis->DepthBits = (depth_bits>0) ? 8*sizeof(GLdepth) : 0; + vis->AccumBits = (accum_bits>0) ? 8*sizeof(GLaccum) : 0; + vis->StencilBits = (stencil_bits>0) ? 8*sizeof(GLstencil) : 0; + + if (red_scale==255.0F && green_scale==255.0F + && blue_scale==255.0F && alpha_scale==255.0F) { + vis->EightBitColor = GL_TRUE; + } + else { + vis->EightBitColor = GL_FALSE; + } + + /* software alpha buffers */ + if (alpha_flag) { + vis->FrontAlphaEnabled = GL_TRUE; + if (db_flag) { + vis->BackAlphaEnabled = GL_TRUE; + } + } + + return vis; +} + + + + +void gl_destroy_visual( GLvisual *vis ) +{ + free( vis ); +} + + + +/* + * Allocate the proxy textures. If we run out of memory part way through + * the allocations clean up and return GL_FALSE. + * Return: GL_TRUE=success, GL_FALSE=failure + */ +static GLboolean alloc_proxy_textures( GLcontext *ctx ) +{ + GLboolean out_of_memory; + GLint i; + + ctx->Texture.Proxy1D = gl_alloc_texture_object(NULL, 0, 1); + if (!ctx->Texture.Proxy1D) { + return GL_FALSE; + } + + ctx->Texture.Proxy2D = gl_alloc_texture_object(NULL, 0, 2); + if (!ctx->Texture.Proxy2D) { + gl_free_texture_object(NULL, ctx->Texture.Proxy1D); + return GL_FALSE; + } + + out_of_memory = GL_FALSE; + for (i=0;iTexture.Proxy1D->Image[i] = gl_alloc_texture_image(); + ctx->Texture.Proxy2D->Image[i] = gl_alloc_texture_image(); + if (!ctx->Texture.Proxy1D->Image[i] + || !ctx->Texture.Proxy2D->Image[i]) { + out_of_memory = GL_TRUE; + } + } + if (out_of_memory) { + for (i=0;iTexture.Proxy1D->Image[i]) { + gl_free_texture_image(ctx->Texture.Proxy1D->Image[i]); + } + if (ctx->Texture.Proxy2D->Image[i]) { + gl_free_texture_image(ctx->Texture.Proxy2D->Image[i]); + } + } + gl_free_texture_object(NULL, ctx->Texture.Proxy1D); + gl_free_texture_object(NULL, ctx->Texture.Proxy2D); + return GL_FALSE; + } + else { + return GL_TRUE; + } +} + + + +/* + * Allocate and initialize a GLcontext structure. + * Input: visual - a GLvisual pointer + * sharelist - another context to share display lists with or NULL + * driver_ctx - pointer to device driver's context state struct + * Return: pointer to a new gl_context struct or NULL if error. + */ +GLcontext *gl_create_context( GLvisual *visual, + GLcontext *share_list, + void *driver_ctx ) +{ + GLcontext *ctx; + + /* do some implementation tests */ + assert( sizeof(GLbyte) == 1 ); + assert( sizeof(GLshort) >= 2 ); + assert( sizeof(GLint) >= 4 ); + assert( sizeof(GLubyte) == 1 ); + assert( sizeof(GLushort) >= 2 ); + assert( sizeof(GLuint) >= 4 ); + + /* misc one-time initializations */ + gl_init_math(); + gl_init_lists(); + gl_init_eval(); + + ctx = (GLcontext *) calloc( 1, sizeof(GLcontext) ); + if (!ctx) { + return NULL; + } + + ctx->DriverCtx = driver_ctx; + ctx->Visual = visual; + ctx->Buffer = NULL; + + ctx->VB = gl_alloc_vb(); + if (!ctx->VB) { + free( ctx ); + return NULL; + } + + ctx->PB = gl_alloc_pb(); + if (!ctx->PB) { + free( ctx->VB ); + free( ctx ); + return NULL; + } + + if (share_list) { + /* share the group of display lists of another context */ + ctx->Shared = share_list->Shared; + } + else { + /* allocate new group of display lists */ + ctx->Shared = alloc_shared_state(); + if (!ctx->Shared) { + free(ctx->VB); + free(ctx->PB); + free(ctx); + return NULL; + } + } + ctx->Shared->RefCount++; + + initialize_context( ctx ); + + if (visual->DBflag) { + ctx->Color.DrawBuffer = GL_BACK; + ctx->Pixel.ReadBuffer = GL_BACK; + } + else { + ctx->Color.DrawBuffer = GL_FRONT; + ctx->Pixel.ReadBuffer = GL_FRONT; + } + +#ifdef PROFILE + init_timings( ctx ); +#endif + +#ifdef GL_VERSION_1_1 + if (!alloc_proxy_textures(ctx)) { + free_shared_state(ctx, ctx->Shared); + free(ctx->VB); + free(ctx->PB); + free(ctx); + return NULL; + } +#endif + + gl_init_api_function_pointers( ctx ); + ctx->API = ctx->Exec; /* GL_EXECUTE is default */ + + return ctx; +} + + + +/* + * Destroy a gl_context structure. + */ +void gl_destroy_context( GLcontext *ctx ) +{ + if (ctx) { + +#ifdef PROFILE + if (getenv("MESA_PROFILE")) { + print_timings( ctx ); + } +#endif + + free( ctx->PB ); + free( ctx->VB ); + + ctx->Shared->RefCount--; + assert(ctx->Shared->RefCount>=0); + if (ctx->Shared->RefCount==0) { + /* free shared state */ + free_shared_state( ctx, ctx->Shared ); + } + + /* Free proxy texture objects */ + gl_free_texture_object( NULL, ctx->Texture.Proxy1D ); + gl_free_texture_object( NULL, ctx->Texture.Proxy2D ); + + free( (void *) ctx ); + +#ifndef THREADS + if (ctx==CC) { + CC = NULL; + } +#endif + + } +} + + + +/* + * Create a new framebuffer. A GLframebuffer is a struct which + * encapsulates the depth, stencil and accum buffers and related + * parameters. + * Input: visual - a GLvisual pointer + * Return: pointer to new GLframebuffer struct or NULL if error. + */ +GLframebuffer *gl_create_framebuffer( GLvisual *visual ) +{ + GLframebuffer *buffer; + + buffer = (GLframebuffer *) calloc( 1, sizeof(GLframebuffer) ); + if (!buffer) { + return NULL; + } + + buffer->Visual = visual; + + return buffer; +} + + + +/* + * Free a framebuffer struct and its buffers. + */ +void gl_destroy_framebuffer( GLframebuffer *buffer ) +{ + if (buffer) { + if (buffer->Depth) { + free( buffer->Depth ); + } + if (buffer->Accum) { + free( buffer->Accum ); + } + if (buffer->Stencil) { + free( buffer->Stencil ); + } + if (buffer->FrontAlpha) { + free( buffer->FrontAlpha ); + } + if (buffer->BackAlpha) { + free( buffer->BackAlpha ); + } + free(buffer); + } +} + + + +/* + * Set the current context, binding the given frame buffer to the context. + */ +void gl_make_current( GLcontext *ctx, GLframebuffer *buffer ) +{ + if (ctx && buffer) { + /* TODO: check if ctx and buffer's visual match??? */ + ctx->Buffer = buffer; /* Bind the frame buffer to the context */ + ctx->NewState = NEW_ALL; /* just to be safe */ + gl_update_state( ctx ); + } +} + + +/* + * Copy attribute groups from one context to another. + * Input: src - source context + * dst - destination context + * mask - bitwise OR of GL_*_BIT flags + */ +void gl_copy_context( const GLcontext *src, GLcontext *dst, GLuint mask ) +{ + if (mask & GL_ACCUM_BUFFER_BIT) { + MEMCPY( &dst->Accum, &src->Accum, sizeof(struct gl_accum_attrib) ); + } + if (mask & GL_COLOR_BUFFER_BIT) { + MEMCPY( &dst->Color, &src->Color, sizeof(struct gl_colorbuffer_attrib) ); + } + if (mask & GL_CURRENT_BIT) { + MEMCPY( &dst->Current, &src->Current, sizeof(struct gl_current_attrib) ); + } + if (mask & GL_DEPTH_BUFFER_BIT) { + MEMCPY( &dst->Depth, &src->Depth, sizeof(struct gl_depthbuffer_attrib) ); + } + if (mask & GL_ENABLE_BIT) { + /* no op */ + } + if (mask & GL_EVAL_BIT) { + MEMCPY( &dst->Eval, &src->Eval, sizeof(struct gl_eval_attrib) ); + } + if (mask & GL_FOG_BIT) { + MEMCPY( &dst->Fog, &src->Fog, sizeof(struct gl_fog_attrib) ); + } + if (mask & GL_HINT_BIT) { + MEMCPY( &dst->Hint, &src->Hint, sizeof(struct gl_hint_attrib) ); + } + if (mask & GL_LIGHTING_BIT) { + MEMCPY( &dst->Light, &src->Light, sizeof(struct gl_light_attrib) ); + } + if (mask & GL_LINE_BIT) { + MEMCPY( &dst->Line, &src->Line, sizeof(struct gl_line_attrib) ); + } + if (mask & GL_LIST_BIT) { + MEMCPY( &dst->List, &src->List, sizeof(struct gl_list_attrib) ); + } + if (mask & GL_PIXEL_MODE_BIT) { + MEMCPY( &dst->Pixel, &src->Pixel, sizeof(struct gl_pixel_attrib) ); + } + if (mask & GL_POINT_BIT) { + MEMCPY( &dst->Point, &src->Point, sizeof(struct gl_point_attrib) ); + } + if (mask & GL_POLYGON_BIT) { + MEMCPY( &dst->Polygon, &src->Polygon, sizeof(struct gl_polygon_attrib) ); + } + if (mask & GL_POLYGON_STIPPLE_BIT) { + /* Use loop instead of MEMCPY due to problem with Portland Group's + * C compiler. Reported by John Stone. + */ + int i; + for (i=0;i<32;i++) { + dst->PolygonStipple[i] = src->PolygonStipple[i]; + } + } + if (mask & GL_SCISSOR_BIT) { + MEMCPY( &dst->Scissor, &src->Scissor, sizeof(struct gl_scissor_attrib) ); + } + if (mask & GL_STENCIL_BUFFER_BIT) { + MEMCPY( &dst->Stencil, &src->Stencil, sizeof(struct gl_stencil_attrib) ); + } + if (mask & GL_TEXTURE_BIT) { + MEMCPY( &dst->Texture, &src->Texture, sizeof(struct gl_texture_attrib) ); + } + if (mask & GL_TRANSFORM_BIT) { + MEMCPY( &dst->Transform, &src->Transform, sizeof(struct gl_transform_attrib) ); + } + if (mask & GL_VIEWPORT_BIT) { + MEMCPY( &dst->Viewport, &src->Viewport, sizeof(struct gl_viewport_attrib) ); + } +} + + + +/* + * Someday a GLS library or OpenGL-like debugger may call this function + * to register it's own set of API entry points. + * Input: ctx - the context to set API pointers for + * api - if NULL, restore original API pointers + * else, set API function table to this table. + */ +void gl_set_api_table( GLcontext *ctx, const struct gl_api_table *api ) +{ + if (api) { + MEMCPY( &ctx->API, api, sizeof(struct gl_api_table) ); + } + else { + MEMCPY( &ctx->API, &ctx->Exec, sizeof(struct gl_api_table) ); + } +} + + + + +/**********************************************************************/ +/***** Miscellaneous functions *****/ +/**********************************************************************/ + + +/* + * This function is called when the Mesa user has stumbled into a code + * path which may not be implemented fully or correctly. + */ +void gl_problem( const GLcontext *ctx, const char *s ) +{ + ERR("MESA ERROR : %s\n", wine_dbgstr_a(s)); +} + + + +/* + * This is called to inform the user that he or she has tried to do + * something illogical or if there's likely a bug in their program + * (like enabled depth testing without a depth buffer). + */ +void gl_warning( const GLcontext *ctx, const char *s ) +{ + WARN("MESA WARNING: %s\n", wine_dbgstr_a(s)); +} + + + +/* + * This is Mesa's error handler. Normally, all that's done is the updating + * of the current error value. If Mesa is compiled with -DDEBUG or if the + * environment variable "MESA_DEBUG" is defined then a real error message + * is printed to stderr. + * Input: error - the error value + * s - a diagnostic string + */ +void gl_error( GLcontext *ctx, GLenum error, const char *s ) +{ + GLboolean debug; + +#ifdef DEBUG + debug = GL_TRUE; +#else + if (getenv("MESA_DEBUG")) { + debug = GL_TRUE; + } + else { + debug = GL_FALSE; + } +#endif + + if (debug) { + char errstr[1000]; + + switch (error) { + case GL_NO_ERROR: + strcpy( errstr, "GL_NO_ERROR" ); + break; + case GL_INVALID_VALUE: + strcpy( errstr, "GL_INVALID_VALUE" ); + break; + case GL_INVALID_ENUM: + strcpy( errstr, "GL_INVALID_ENUM" ); + break; + case GL_INVALID_OPERATION: + strcpy( errstr, "GL_INVALID_OPERATION" ); + break; + case GL_STACK_OVERFLOW: + strcpy( errstr, "GL_STACK_OVERFLOW" ); + break; + case GL_STACK_UNDERFLOW: + strcpy( errstr, "GL_STACK_UNDERFLOW" ); + break; + case GL_OUT_OF_MEMORY: + strcpy( errstr, "GL_OUT_OF_MEMORY" ); + break; + default: + strcpy( errstr, "unknown" ); + break; + } + ERR("Mesa user error: %s in %s\n", wine_dbgstr_a(errstr), wine_dbgstr_a(s)); + } + + if (ctx->ErrorValue==GL_NO_ERROR) { + ctx->ErrorValue = error; + } + + /* Call device driver's error handler, if any. This is used on the Mac. */ + if (ctx->Driver.Error) { + (*ctx->Driver.Error)( ctx ); + } +} + + + + +GLenum gl_GetError( GLcontext *ctx ) +{ + GLenum e; + + if (INSIDE_BEGIN_END(ctx)) { + gl_error( ctx, GL_INVALID_OPERATION, "glGetError" ); + return GL_INVALID_OPERATION; + } + + e = ctx->ErrorValue; + ctx->ErrorValue = GL_NO_ERROR; + return e; +} + + + +void gl_ResizeBuffersMESA( GLcontext *ctx ) +{ + GLint newsize; + GLuint buf_width, buf_height; + + ctx->NewState |= NEW_ALL; /* just to be safe */ + + /* ask device driver for size of output buffer */ + (*ctx->Driver.GetBufferSize)( ctx, &buf_width, &buf_height ); + + /* see if size of device driver's color buffer (window) has changed */ + newsize = ctx->Buffer->Width!=buf_width || ctx->Buffer->Height!=buf_height; + + /* save buffer size */ + ctx->Buffer->Width = buf_width; + ctx->Buffer->Height = buf_height; + + /* Reallocate other buffers if needed. */ + if (newsize && ctx->Visual->DepthBits>0) { + /* reallocate depth buffer */ + (*ctx->Driver.AllocDepthBuffer)( ctx ); + /*** if scissoring enabled then clearing can cause a problem ***/ + /***(*ctx->Driver.ClearDepthBuffer)( ctx );***/ + } + if (newsize && ctx->Visual->StencilBits>0) { + /* reallocate stencil buffer */ + gl_alloc_stencil_buffer( ctx ); + } + if (newsize && ctx->Visual->AccumBits>0) { + /* reallocate accum buffer */ + gl_alloc_accum_buffer( ctx ); + } + if (newsize + && (ctx->Visual->FrontAlphaEnabled || ctx->Visual->BackAlphaEnabled)) { + gl_alloc_alpha_buffers( ctx ); + } +} + + + + +/**********************************************************************/ +/***** State update logic *****/ +/**********************************************************************/ + + +/* + * Since the device driver may or may not support pixel logic ops we + * have to make some extensive tests to determine whether or not + * software-implemented logic operations have to be used. + */ +static void update_pixel_logic( GLcontext *ctx ) +{ + if (ctx->Visual->RGBAflag) { + /* RGBA mode blending w/ Logic Op */ + if (ctx->Color.ColorLogicOpEnabled) { + if (ctx->Driver.LogicOp + && (*ctx->Driver.LogicOp)( ctx, ctx->Color.LogicOp )) { + /* Device driver can do logic, don't have to do it in software */ + ctx->Color.SWLogicOpEnabled = GL_FALSE; + } + else { + /* Device driver can't do logic op so we do it in software */ + ctx->Color.SWLogicOpEnabled = GL_TRUE; + } + } + else { + /* no logic op */ + if (ctx->Driver.LogicOp) { + (void) (*ctx->Driver.LogicOp)( ctx, GL_COPY ); + } + ctx->Color.SWLogicOpEnabled = GL_FALSE; + } + } + else { + /* CI mode Logic Op */ + if (ctx->Color.IndexLogicOpEnabled) { + if (ctx->Driver.LogicOp + && (*ctx->Driver.LogicOp)( ctx, ctx->Color.LogicOp )) { + /* Device driver can do logic, don't have to do it in software */ + ctx->Color.SWLogicOpEnabled = GL_FALSE; + } + else { + /* Device driver can't do logic op so we do it in software */ + ctx->Color.SWLogicOpEnabled = GL_TRUE; + } + } + else { + /* no logic op */ + if (ctx->Driver.LogicOp) { + (void) (*ctx->Driver.LogicOp)( ctx, GL_COPY ); + } + ctx->Color.SWLogicOpEnabled = GL_FALSE; + } + } +} + + + +/* + * Check if software implemented RGBA or Color Index masking is needed. + */ +static void update_pixel_masking( GLcontext *ctx ) +{ + if (ctx->Visual->RGBAflag) { + if (ctx->Color.ColorMask==0xf) { + /* disable masking */ + if (ctx->Driver.ColorMask) { + (void) (*ctx->Driver.ColorMask)( ctx, GL_TRUE, GL_TRUE, GL_TRUE, GL_TRUE ); + } + ctx->Color.SWmasking = GL_FALSE; + } + else { + /* Ask driver to do color masking, if it can't then + * do it in software + */ + GLboolean red = (ctx->Color.ColorMask & 8) ? GL_TRUE : GL_FALSE; + GLboolean green = (ctx->Color.ColorMask & 4) ? GL_TRUE : GL_FALSE; + GLboolean blue = (ctx->Color.ColorMask & 2) ? GL_TRUE : GL_FALSE; + GLboolean alpha = (ctx->Color.ColorMask & 1) ? GL_TRUE : GL_FALSE; + if (ctx->Driver.ColorMask + && (*ctx->Driver.ColorMask)( ctx, red, green, blue, alpha )) { + ctx->Color.SWmasking = GL_FALSE; + } + else { + ctx->Color.SWmasking = GL_TRUE; + } + } + } + else { + if (ctx->Color.IndexMask==0xffffffff) { + /* disable masking */ + if (ctx->Driver.IndexMask) { + (void) (*ctx->Driver.IndexMask)( ctx, 0xffffffff ); + } + ctx->Color.SWmasking = GL_FALSE; + } + else { + /* Ask driver to do index masking, if it can't then + * do it in software + */ + if (ctx->Driver.IndexMask + && (*ctx->Driver.IndexMask)( ctx, ctx->Color.IndexMask )) { + ctx->Color.SWmasking = GL_FALSE; + } + else { + ctx->Color.SWmasking = GL_TRUE; + } + } + } +} + + + +/* + * Recompute the value of ctx->RasterMask, etc. according to + * the current context. + */ +static void update_rasterflags( GLcontext *ctx ) +{ + ctx->RasterMask = 0; + + if (ctx->Color.AlphaEnabled) ctx->RasterMask |= ALPHATEST_BIT; + if (ctx->Color.BlendEnabled) ctx->RasterMask |= BLEND_BIT; + if (ctx->Depth.Test) ctx->RasterMask |= DEPTH_BIT; + if (ctx->Fog.Enabled) ctx->RasterMask |= FOG_BIT; + if (ctx->Color.SWLogicOpEnabled) ctx->RasterMask |= LOGIC_OP_BIT; + if (ctx->Scissor.Enabled) ctx->RasterMask |= SCISSOR_BIT; + if (ctx->Stencil.Enabled) ctx->RasterMask |= STENCIL_BIT; + if (ctx->Color.SWmasking) ctx->RasterMask |= MASKING_BIT; + if (ctx->Visual->FrontAlphaEnabled) ctx->RasterMask |= ALPHABUF_BIT; + if (ctx->Visual->BackAlphaEnabled) ctx->RasterMask |= ALPHABUF_BIT; + + if ( ctx->Viewport.X<0 + || ctx->Viewport.X + ctx->Viewport.Width > ctx->Buffer->Width + || ctx->Viewport.Y<0 + || ctx->Viewport.Y + ctx->Viewport.Height > ctx->Buffer->Height) { + ctx->RasterMask |= WINCLIP_BIT; + } + + /* check if drawing to front and back buffers */ + if (ctx->Color.DrawBuffer==GL_FRONT_AND_BACK) { + ctx->RasterMask |= FRONT_AND_BACK_BIT; + } + + /* check if writing to color buffer(s) is disabled */ + if (ctx->Color.DrawBuffer==GL_NONE) { + ctx->RasterMask |= NO_DRAW_BIT; + } + else if (ctx->Visual->RGBAflag && ctx->Color.ColorMask==0) { + ctx->RasterMask |= NO_DRAW_BIT; + } + else if (!ctx->Visual->RGBAflag && ctx->Color.IndexMask==0) { + ctx->RasterMask |= NO_DRAW_BIT; + } +} + + +/* + * Recompute the value of ctx->ClipMask according to the current context. + * ClipMask depends on Texturing and Lighting. + */ +static void update_clipmask(GLcontext *ctx) +{ + /* Recompute ClipMask (what has to be interpolated when clipping) */ + ctx->ClipMask = 0; + if (ctx->Texture.Enabled) { + ctx->ClipMask |= CLIP_TEXTURE_BIT; + } + if (ctx->Light.ShadeModel==GL_SMOOTH) { + if (ctx->Visual->RGBAflag) { + ctx->ClipMask |= CLIP_FCOLOR_BIT; + if (ctx->Light.Model.TwoSide) { + ctx->ClipMask |= CLIP_BCOLOR_BIT; + } + } + else { + ctx->ClipMask |= CLIP_FINDEX_BIT; + if (ctx->Light.Model.TwoSide) { + ctx->ClipMask |= CLIP_BINDEX_BIT; + } + } + } + + switch(ctx->ClipMask) { + case CLIP_FCOLOR_BIT|CLIP_TEXTURE_BIT: + if(ctx->VB->TexCoordSize==2) + ctx->ClipInterpAuxFunc = interpolate_aux_color_tex2; + else + ctx->ClipInterpAuxFunc = interpolate_aux; + break; + case CLIP_TEXTURE_BIT: + if(ctx->VB->TexCoordSize==2) + ctx->ClipInterpAuxFunc = interpolate_aux_tex2; + else + ctx->ClipInterpAuxFunc = interpolate_aux; + break; + case CLIP_FCOLOR_BIT: + ctx->ClipInterpAuxFunc = interpolate_aux_color; + break; + default: + ctx->ClipInterpAuxFunc = interpolate_aux; + } +} + + + +/* + * If ctx->NewState is non-zero then this function MUST be called before + * rendering any primitive. Basically, function pointers and miscellaneous + * flags are updated to reflect the current state of the state machine. + */ +void gl_update_state( GLcontext *ctx ) +{ + if (ctx->NewState & NEW_RASTER_OPS) { + update_pixel_logic(ctx); + update_pixel_masking(ctx); + update_rasterflags(ctx); + if (ctx->Driver.Dither) { + (*ctx->Driver.Dither)( ctx, ctx->Color.DitherFlag ); + } + } + + if (ctx->NewState & (NEW_RASTER_OPS | NEW_LIGHTING)) { + update_clipmask(ctx); + } + + if (ctx->NewState & NEW_LIGHTING) { + gl_update_lighting(ctx); + gl_set_color_function(ctx); + } + + if (ctx->NewState & NEW_TEXTURING) { + gl_update_texture_state(ctx); + } + + if (ctx->NewState & (NEW_LIGHTING | NEW_TEXTURING)) { + /* Check if normal vectors are needed */ + GLboolean sphereGen = ctx->Texture.Enabled + && ((ctx->Texture.GenModeS==GL_SPHERE_MAP + && (ctx->Texture.TexGenEnabled & S_BIT)) + || (ctx->Texture.GenModeT==GL_SPHERE_MAP + && (ctx->Texture.TexGenEnabled & T_BIT))); + if (ctx->Light.Enabled || sphereGen) { + ctx->NeedNormals = GL_TRUE; + } + else { + ctx->NeedNormals = GL_FALSE; + } + } + + if (ctx->NewState & NEW_RASTER_OPS) { + /* Check if incoming colors can be modified during rasterization */ + if (ctx->Fog.Enabled || + ctx->Texture.Enabled || + ctx->Color.BlendEnabled || + ctx->Color.SWmasking || + ctx->Color.SWLogicOpEnabled) { + ctx->MutablePixels = GL_TRUE; + } + else { + ctx->MutablePixels = GL_FALSE; + } + } + + if (ctx->NewState & (NEW_RASTER_OPS | NEW_LIGHTING)) { + /* Check if all pixels generated are likely to be the same color */ + if (ctx->Light.ShadeModel==GL_SMOOTH || + ctx->Light.Enabled || + ctx->Fog.Enabled || + ctx->Texture.Enabled || + ctx->Color.BlendEnabled || + ctx->Color.SWmasking || + ctx->Color.SWLogicOpEnabled) { + ctx->MonoPixels = GL_FALSE; /* pixels probably multicolored */ + } + else { + /* pixels will all be same color, + * only glColor() can invalidate this. + */ + ctx->MonoPixels = GL_TRUE; + } + } + + if (ctx->NewState & NEW_POLYGON) { + /* Setup CullBits bitmask */ + ctx->Polygon.CullBits = 0; + if (ctx->Polygon.CullFlag) { + if (ctx->Polygon.CullFaceMode==GL_FRONT || + ctx->Polygon.CullFaceMode==GL_FRONT_AND_BACK) { + ctx->Polygon.CullBits |= 1; + } + if (ctx->Polygon.CullFaceMode==GL_BACK || + ctx->Polygon.CullFaceMode==GL_FRONT_AND_BACK) { + ctx->Polygon.CullBits |= 2; + } + } + /* Any Polygon offsets enabled? */ + ctx->Polygon.OffsetAny = ctx->Polygon.OffsetPoint || + ctx->Polygon.OffsetLine || + ctx->Polygon.OffsetFill; + /* reset Z offsets now */ + ctx->PointZoffset = 0.0; + ctx->LineZoffset = 0.0; + ctx->PolygonZoffset = 0.0; + } + + if (ctx->NewState & (NEW_POLYGON | NEW_LIGHTING)) { + /* Determine if we can directly call the triangle rasterizer */ + if ( ctx->Polygon.Unfilled + || ctx->Polygon.OffsetAny + || ctx->Polygon.CullFlag + || ctx->Light.Model.TwoSide + || ctx->RenderMode!=GL_RENDER) { + ctx->DirectTriangles = GL_FALSE; + } + else { + ctx->DirectTriangles = GL_TRUE; + } + } + + /* update scissor region */ + ctx->Buffer->Xmin = 0; + ctx->Buffer->Ymin = 0; + ctx->Buffer->Xmax = ctx->Buffer->Width-1; + ctx->Buffer->Ymax = ctx->Buffer->Height-1; + if (ctx->Scissor.Enabled) { + if (ctx->Scissor.X > ctx->Buffer->Xmin) { + ctx->Buffer->Xmin = ctx->Scissor.X; + } + if (ctx->Scissor.Y > ctx->Buffer->Ymin) { + ctx->Buffer->Ymin = ctx->Scissor.Y; + } + if (ctx->Scissor.X + ctx->Scissor.Width - 1 < ctx->Buffer->Xmax) { + ctx->Buffer->Xmax = ctx->Scissor.X + ctx->Scissor.Width - 1; + } + if (ctx->Scissor.Y + ctx->Scissor.Height - 1 < ctx->Buffer->Ymax) { + ctx->Buffer->Ymax = ctx->Scissor.Y + ctx->Scissor.Height - 1; + } + } + + /* + * Update Device Driver interface + */ + if (ctx->NewState & NEW_RASTER_OPS) { + ctx->Driver.AllocDepthBuffer = gl_alloc_depth_buffer; + ctx->Driver.ClearDepthBuffer = gl_clear_depth_buffer; + if (ctx->Depth.Mask) { + switch (ctx->Depth.Func) { + case GL_LESS: + ctx->Driver.DepthTestSpan = gl_depth_test_span_less; + ctx->Driver.DepthTestPixels = gl_depth_test_pixels_less; + break; + case GL_GREATER: + ctx->Driver.DepthTestSpan = gl_depth_test_span_greater; + ctx->Driver.DepthTestPixels = gl_depth_test_pixels_greater; + break; + default: + ctx->Driver.DepthTestSpan = gl_depth_test_span_generic; + ctx->Driver.DepthTestPixels = gl_depth_test_pixels_generic; + } + } + else { + ctx->Driver.DepthTestSpan = gl_depth_test_span_generic; + ctx->Driver.DepthTestPixels = gl_depth_test_pixels_generic; + } + ctx->Driver.ReadDepthSpanFloat = gl_read_depth_span_float; + ctx->Driver.ReadDepthSpanInt = gl_read_depth_span_int; + } + + ctx->Driver.PointsFunc = NULL; + ctx->Driver.LineFunc = NULL; + ctx->Driver.TriangleFunc = NULL; + ctx->Driver.QuadFunc = NULL; + ctx->Driver.RectFunc = NULL; + + if (ctx->Driver.UpdateState) { + (*ctx->Driver.UpdateState)(ctx); + } + + gl_set_point_function(ctx); + gl_set_line_function(ctx); + gl_set_triangle_function(ctx); + gl_set_quad_function(ctx); + + gl_set_vertex_function(ctx); + + ctx->NewState = 0; +} + diff --git a/dll/opengl/mesa/context.h b/dll/opengl/mesa/context.h new file mode 100644 index 00000000000..191427cc8f6 --- /dev/null +++ b/dll/opengl/mesa/context.h @@ -0,0 +1,179 @@ +/* $Id: context.h,v 1.9 1997/09/29 22:25:28 brianp Exp $ */ + +/* + * Mesa 3-D graphics library + * Version: 2.5 + * Copyright (C) 1995-1997 Brian Paul + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Library General Public + * License as published by the Free Software Foundation; either + * version 2 of the License, or (at your option) any later version. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Library General Public License for more details. + * + * You should have received a copy of the GNU Library General Public + * License along with this library; if not, write to the Free + * Software Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. + */ + + +/* + * $Log: context.h,v $ + * Revision 1.9 1997/09/29 22:25:28 brianp + * added const to a few function parameters + * + * Revision 1.8 1997/05/26 21:14:13 brianp + * gl_create_visual() now takes red/green/blue/alpha_bits arguments + * + * Revision 1.7 1997/04/16 23:55:06 brianp + * added gl_set_api_table() + * + * Revision 1.6 1997/04/12 17:12:43 brianp + * added gl_get_current_context() + * + * Revision 1.5 1997/02/27 19:57:38 brianp + * added gl_problem() function + * + * Revision 1.4 1997/02/10 19:49:50 brianp + * added gl_ResizeBuffersMESA() + * + * Revision 1.3 1996/09/19 03:14:49 brianp + * now just one parameter for gl_create_framebuffer() + * + * Revision 1.2 1996/09/15 14:20:22 brianp + * added new functions for GLframebuffer and GLvisual support + * + * Revision 1.1 1996/09/13 01:38:16 brianp + * Initial revision + * + */ + + +#ifndef CONTEXT_H +#define CONTEXT_H + + +#include "types.h" + + + +#ifdef THREADS + /* + * A seperate GLcontext for each thread + */ + extern GLcontext *gl_get_thread_context( void ); +#else + /* + * All threads use same pointer to current context. + */ + extern GLcontext *CC; +#endif + + + +/* + * There are three Mesa datatypes which are meant to be used by device + * drivers: + * GLcontext: this contains the Mesa rendering state + * GLvisual: this describes the color buffer (rgb vs. ci), whether + * or not there's a depth buffer, stencil buffer, etc. + * GLframebuffer: contains pointers to the depth buffer, stencil + * buffer, accum buffer and alpha buffers. + * + * These types should be encapsulated by corresponding device driver + * datatypes. See xmesa.h and xmesaP.h for an example. + * + * The following functions create and destroy these datatypes. + */ + + +/* + * Create/destroy a GLvisual. A GLvisual is like a GLX visual. It describes + * the colorbuffer, depth buffer, stencil buffer and accum buffer which will + * be used by the GL context and framebuffer. + */ +extern GLvisual *gl_create_visual( GLboolean rgb_flag, + GLboolean alpha_flag, + GLboolean db_flag, + GLint depth_bits, + GLint stencil_bits, + GLint accum_bits, + GLint index_bits, + GLfloat red_scale, + GLfloat green_scale, + GLfloat blue_scale, + GLfloat alpha_scale, + GLint red_bits, + GLint green_bits, + GLint blue_bits, + GLint alpha_bits ); + +extern void gl_destroy_visual( GLvisual *vis ); + + +/* + * Create/destroy a GLcontext. A GLcontext is like a GLX context. It + * contains the rendering state. + */ +extern GLcontext *gl_create_context( GLvisual *visual, + GLcontext *share_list, + void *driver_ctx ); + +extern void gl_destroy_context( GLcontext *ctx ); + + +/* + * Create/destroy a GLframebuffer. A GLframebuffer is like a GLX drawable. + * It bundles up the depth buffer, stencil buffer and accum buffers into a + * single entity. + */ +extern GLframebuffer *gl_create_framebuffer( GLvisual *visual ); + +extern void gl_destroy_framebuffer( GLframebuffer *buffer ); + + + +extern void gl_make_current( GLcontext *ctx, GLframebuffer *buffer ); + +extern GLcontext *gl_get_current_context(void); + +extern void gl_copy_context(const GLcontext *src, GLcontext *dst, GLuint mask); + +extern void gl_set_api_table( GLcontext *ctx, const struct gl_api_table *api ); + + + +/* + * GL_MESA_resize_buffers extension + */ +extern void gl_ResizeBuffersMESA( GLcontext *ctx ); + + + +/* + * Miscellaneous + */ + +extern void gl_problem( const GLcontext *ctx, const char *s ); + +extern void gl_warning( const GLcontext *ctx, const char *s ); + +extern void gl_error( GLcontext *ctx, GLenum error, const char *s ); + +extern GLenum gl_GetError( GLcontext *ctx ); + + +extern void gl_update_state( GLcontext *ctx ); + + + +#ifdef PROFILE +extern GLdouble gl_time( void ); +#endif + + +#endif diff --git a/dll/opengl/mesa/copypix.c b/dll/opengl/mesa/copypix.c new file mode 100644 index 00000000000..0e698d164f3 --- /dev/null +++ b/dll/opengl/mesa/copypix.c @@ -0,0 +1,517 @@ +/* $Id: copypix.c,v 1.7 1998/02/03 23:45:02 brianp Exp $ */ + +/* + * Mesa 3-D graphics library + * Version: 2.4 + * Copyright (C) 1995-1996 Brian Paul + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Library General Public + * License as published by the Free Software Foundation; either + * version 2 of the License, or (at your option) any later version. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Library General Public License for more details. + * + * You should have received a copy of the GNU Library General Public + * License along with this library; if not, write to the Free + * Software Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. + */ + + +/* + * $Log: copypix.c,v $ + * Revision 1.7 1998/02/03 23:45:02 brianp + * added casts to prevent warnings with Amiga StormC compiler + * + * Revision 1.6 1997/07/24 01:24:45 brianp + * changed precompiled header symbol from PCH to PC_HEADER + * + * Revision 1.5 1997/06/20 02:20:04 brianp + * replaced Current.IntColor with Current.ByteColor + * + * Revision 1.4 1997/05/28 03:23:48 brianp + * added precompiled header (PCH) support + * + * Revision 1.3 1996/09/15 14:18:10 brianp + * now use GLframebuffer and GLvisual + * + * Revision 1.2 1996/09/15 01:48:58 brianp + * removed #define NULL 0 + * + * Revision 1.1 1996/09/13 01:38:16 brianp + * Initial revision + * + */ + + +#ifdef PC_HEADER +#include "all.h" +#else +#include +#include "context.h" +#include "copypix.h" +#include "depth.h" +#include "feedback.h" +#include "dlist.h" +#include "macros.h" +#include "pixel.h" +#include "span.h" +#include "stencil.h" +#include "types.h" +#endif + + + +static void copy_rgb_pixels( GLcontext* ctx, + GLint srcx, GLint srcy, GLint width, GLint height, + GLint destx, GLint desty ) +{ + DEFARRAY( GLdepth, zspan, MAX_WIDTH ); + DEFARRAY( GLubyte, red, MAX_WIDTH ); + DEFARRAY( GLubyte, green, MAX_WIDTH ); + DEFARRAY( GLubyte, blue, MAX_WIDTH ); + DEFARRAY( GLubyte, alpha, MAX_WIDTH ); + GLboolean scale_or_bias, quick_draw, zoom; + GLint sy, dy, stepy; + GLint i, j; + GLboolean setbuffer; + + if (ctx->Pixel.ZoomX==1.0F && ctx->Pixel.ZoomY==1.0F) { + zoom = GL_FALSE; + } + else { + zoom = GL_TRUE; + } + + /* Determine if copy should be done bottom-to-top or top-to-bottom */ + if (srcyPixel.RedScale!=1.0 || ctx->Pixel.RedBias!=0.0 + || ctx->Pixel.GreenScale!=1.0 || ctx->Pixel.GreenBias!=0.0 + || ctx->Pixel.BlueScale!=1.0 || ctx->Pixel.BlueBias!=0.0 + || ctx->Pixel.AlphaScale!=1.0 || ctx->Pixel.AlphaBias!=0.0; + + if (ctx->Depth.Test) { + /* fill in array of z values */ + GLint z = (GLint) (ctx->Current.RasterPos[2] * DEPTH_SCALE); + for (i=0;iRasterMask==0 && !zoom + && destx>=0 && destx+width<=ctx->Buffer->Width) { + quick_draw = GL_TRUE; + } + else { + quick_draw = GL_FALSE; + } + + /* If read and draw buffer are different we must do buffer switching */ + setbuffer = ctx->Pixel.ReadBuffer!=ctx->Color.DrawBuffer; + + for (j=0; jDriver.SetBuffer)( ctx, ctx->Pixel.ReadBuffer ); + } + gl_read_color_span( ctx, width, srcx, sy, red, green, blue, alpha ); + + if (scale_or_bias) { + GLfloat rbias = ctx->Pixel.RedBias * ctx->Visual->RedScale; + GLfloat gbias = ctx->Pixel.GreenBias * ctx->Visual->GreenScale; + GLfloat bbias = ctx->Pixel.BlueBias * ctx->Visual->BlueScale; + GLfloat abias = ctx->Pixel.AlphaBias * ctx->Visual->AlphaScale; + GLint rmax = (GLint) ctx->Visual->RedScale; + GLint gmax = (GLint) ctx->Visual->GreenScale; + GLint bmax = (GLint) ctx->Visual->BlueScale; + GLint amax = (GLint) ctx->Visual->AlphaScale; + for (i=0;iPixel.RedScale + rbias; + GLint g = green[i] * ctx->Pixel.GreenScale + gbias; + GLint b = blue[i] * ctx->Pixel.BlueScale + bbias; + GLint a = alpha[i] * ctx->Pixel.AlphaScale + abias; + red[i] = CLAMP( r, 0, rmax ); + green[i] = CLAMP( g, 0, gmax ); + blue[i] = CLAMP( b, 0, bmax ); + alpha[i] = CLAMP( a, 0, amax ); + } + } + + if (ctx->Pixel.MapColorFlag) { + GLfloat r = (ctx->Pixel.MapRtoRsize-1) * ctx->Visual->InvRedScale; + GLfloat g = (ctx->Pixel.MapGtoGsize-1) * ctx->Visual->InvGreenScale; + GLfloat b = (ctx->Pixel.MapBtoBsize-1) * ctx->Visual->InvBlueScale; + GLfloat a = (ctx->Pixel.MapAtoAsize-1) * ctx->Visual->InvAlphaScale; + for (i=0;iPixel.MapRtoR[ir]*ctx->Visual->RedScale); + green[i] = (GLint) (ctx->Pixel.MapGtoG[ig]*ctx->Visual->GreenScale); + blue[i] = (GLint) (ctx->Pixel.MapBtoB[ib]*ctx->Visual->BlueScale); + alpha[i] = (GLint) (ctx->Pixel.MapAtoA[ia]*ctx->Visual->AlphaScale); + } + } + + /* write */ + if (setbuffer) { + (*ctx->Driver.SetBuffer)( ctx, ctx->Color.DrawBuffer ); + } + if (quick_draw && dy>=0 && dyBuffer->Height) { + (*ctx->Driver.WriteColorSpan)( ctx, width, destx, dy, + red, green, blue, alpha, NULL); + } + else if (zoom) { + gl_write_zoomed_color_span( ctx, width, destx, dy, zspan, + red, green, blue, alpha, desty ); + } + else { + gl_write_color_span( ctx, width, destx, dy, zspan, + red, green, blue, alpha, GL_BITMAP ); + } + } + UNDEFARRAY( zspan ); + UNDEFARRAY( red ); + UNDEFARRAY( green ); + UNDEFARRAY( blue ); + UNDEFARRAY( alpha ); +} + + + +static void copy_ci_pixels( GLcontext* ctx, + GLint srcx, GLint srcy, GLint width, GLint height, + GLint destx, GLint desty ) +{ + GLdepth zspan[MAX_WIDTH]; + GLuint indx[MAX_WIDTH]; + GLint sy, dy, stepy; + GLint i, j; + GLboolean setbuffer, zoom; + + if (ctx->Pixel.ZoomX==1.0F && ctx->Pixel.ZoomY==1.0F) { + zoom = GL_FALSE; + } + else { + zoom = GL_TRUE; + } + + /* Determine if copy should be bottom-to-top or top-to-bottom */ + if (srcyDepth.Test) { + /* fill in array of z values */ + GLint z = (GLint) (ctx->Current.RasterPos[2] * DEPTH_SCALE); + for (i=0;iPixel.ReadBuffer!=ctx->Color.DrawBuffer; + + for (j=0; jDriver.SetBuffer)( ctx, ctx->Pixel.ReadBuffer ); + } + gl_read_index_span( ctx, width, srcx, sy, indx ); + + /* shift, offset */ + if (ctx->Pixel.IndexShift || ctx->Pixel.IndexOffset) { + if (ctx->Pixel.IndexShift<0) { + for (i=0;i> -ctx->Pixel.IndexShift) + + ctx->Pixel.IndexOffset; + } + } + else { + for (i=0;iPixel.IndexShift) + + ctx->Pixel.IndexOffset; + } + } + } + + /* mapping */ + if (ctx->Pixel.MapColorFlag) { + for (i=0;iPixel.MapItoIsize) { + indx[i] = ctx->Pixel.MapItoI[ indx[i] ]; + } + } + } + + /* write */ + if (setbuffer) { + (*ctx->Driver.SetBuffer)( ctx, ctx->Color.DrawBuffer ); + } + if (zoom) { + gl_write_zoomed_index_span( ctx, width, destx, dy, zspan, indx, desty ); + } + else { + gl_write_index_span( ctx, width, destx, dy, zspan, indx, GL_BITMAP ); + } + } +} + + + +/* + * TODO: Optimize!!!! + */ +static void copy_depth_pixels( GLcontext* ctx, GLint srcx, GLint srcy, + GLint width, GLint height, + GLint destx, GLint desty ) +{ + GLfloat depth[MAX_WIDTH]; + GLdepth zspan[MAX_WIDTH]; + GLuint indx[MAX_WIDTH]; + GLubyte red[MAX_WIDTH], green[MAX_WIDTH]; + GLubyte blue[MAX_WIDTH], alpha[MAX_WIDTH]; + GLint sy, dy, stepy; + GLint i, j; + GLboolean zoom; + + if (!ctx->Buffer->Depth) { + gl_error( ctx, GL_INVALID_OPERATION, "glCopyPixels" ); + return; + } + + if (ctx->Pixel.ZoomX==1.0F && ctx->Pixel.ZoomY==1.0F) { + zoom = GL_FALSE; + } + else { + zoom = GL_TRUE; + } + + /* Determine if copy should be bottom-to-top or top-to-bottom */ + if (srcyVisual->RGBAflag) { + GLubyte r, g, b, a; + r = ctx->Current.ByteColor[0]; + g = ctx->Current.ByteColor[1]; + b = ctx->Current.ByteColor[2]; + a = ctx->Current.ByteColor[3]; + MEMSET( red, (int) r, width ); + MEMSET( green, (int) g, width ); + MEMSET( blue, (int) b, width ); + MEMSET( alpha, (int) a, width ); + } + else { + for (i=0;iCurrent.Index; + } + } + + for (j=0; jDriver.ReadDepthSpanFloat)( ctx, width, srcx, sy, depth ); + /* scale, bias, clamp */ + for (i=0;iPixel.DepthScale + ctx->Pixel.DepthBias; + zspan[i] = (GLint) (CLAMP( d, 0.0, 1.0 ) * DEPTH_SCALE); + } + /* write */ + if (ctx->Visual->RGBAflag) { + if (zoom) { + gl_write_zoomed_color_span( ctx, width, destx, dy, zspan, + red, green, blue, alpha, desty ); + } + else { + gl_write_color_span( ctx, width, destx, dy, zspan, + red, green, blue, alpha, GL_BITMAP ); + } + } + else { + if (zoom) { + gl_write_zoomed_index_span( ctx, width, destx, dy, + zspan, indx, desty); + } + else { + gl_write_index_span( ctx, width, destx, dy, + zspan, indx, GL_BITMAP ); + } + } + } +} + + + +static void copy_stencil_pixels( GLcontext* ctx, GLint srcx, GLint srcy, + GLint width, GLint height, + GLint destx, GLint desty ) +{ + GLubyte stencil[MAX_WIDTH]; + GLint sy, dy, stepy; + GLint i, j; + GLboolean zoom; + + if (!ctx->Buffer->Stencil) { + gl_error( ctx, GL_INVALID_OPERATION, "glCopyPixels" ); + return; + } + + if (ctx->Pixel.ZoomX==1.0F && ctx->Pixel.ZoomY==1.0F) { + zoom = GL_FALSE; + } + else { + zoom = GL_TRUE; + } + + /* Determine if copy should be bottom-to-top or top-to-bottom */ + if (srcyPixel.IndexShift<0) { + for (i=0;i> -ctx->Pixel.IndexShift) + + ctx->Pixel.IndexOffset; + } + } + else { + for (i=0;iPixel.IndexShift) + + ctx->Pixel.IndexOffset; + } + } + /* mapping */ + if (ctx->Pixel.MapStencilFlag) { + for (i=0;iPixel.MapStoSsize) { + stencil[i] = ctx->Pixel.MapStoS[ stencil[i] ]; + } + } + } + /* write */ + if (zoom) { + gl_write_zoomed_stencil_span( ctx, width, destx, dy, stencil, desty ); + } + else { + gl_write_stencil_span( ctx, width, destx, dy, stencil ); + } + } +} + + + + +void gl_CopyPixels( GLcontext* ctx, GLint srcx, GLint srcy, GLsizei width, GLsizei height, + GLenum type ) +{ + GLint destx, desty; + + if (INSIDE_BEGIN_END(ctx)) { + gl_error( ctx, GL_INVALID_OPERATION, "glCopyPixels" ); + return; + } + + if (width<0 || height<0) { + gl_error( ctx, GL_INVALID_VALUE, "glCopyPixels" ); + return; + } + + if (ctx->NewState) { + gl_update_state(ctx); + } + + if (ctx->RenderMode==GL_RENDER) { + /* Destination of copy: */ + if (!ctx->Current.RasterPosValid) { + return; + } + destx = (GLint) (ctx->Current.RasterPos[0] + 0.5F); + desty = (GLint) (ctx->Current.RasterPos[1] + 0.5F); + + if (type==GL_COLOR && ctx->Visual->RGBAflag) { + copy_rgb_pixels( ctx, srcx, srcy, width, height, destx, desty ); + } + else if (type==GL_COLOR && !ctx->Visual->RGBAflag) { + copy_ci_pixels( ctx, srcx, srcy, width, height, destx, desty ); + } + else if (type==GL_DEPTH) { + copy_depth_pixels( ctx, srcx, srcy, width, height, destx, desty ); + } + else if (type==GL_STENCIL) { + copy_stencil_pixels( ctx, srcx, srcy, width, height, destx, desty ); + } + else { + gl_error( ctx, GL_INVALID_ENUM, "glCopyPixels" ); + } + } + else if (ctx->RenderMode==GL_FEEDBACK) { + GLfloat color[4]; + color[0] = ctx->Current.ByteColor[0] * ctx->Visual->InvRedScale; + color[1] = ctx->Current.ByteColor[1] * ctx->Visual->InvGreenScale; + color[2] = ctx->Current.ByteColor[2] * ctx->Visual->InvBlueScale; + color[3] = ctx->Current.ByteColor[3] * ctx->Visual->InvAlphaScale; + FEEDBACK_TOKEN( ctx, (GLfloat) (GLint) GL_COPY_PIXEL_TOKEN ); + gl_feedback_vertex( ctx, ctx->Current.RasterPos[0], + ctx->Current.RasterPos[1], + ctx->Current.RasterPos[2], + ctx->Current.RasterPos[3], + color, ctx->Current.Index, + ctx->Current.TexCoord ); + } + else if (ctx->RenderMode==GL_SELECT) { + gl_update_hitflag( ctx, ctx->Current.RasterPos[2] ); + } + +} + + diff --git a/dll/opengl/mesa/copypix.h b/dll/opengl/mesa/copypix.h new file mode 100644 index 00000000000..c16a587db23 --- /dev/null +++ b/dll/opengl/mesa/copypix.h @@ -0,0 +1,46 @@ +/* $Id: copypix.h,v 1.1 1996/09/13 01:38:16 brianp Exp $ */ + +/* + * Mesa 3-D graphics library + * Version: 2.0 + * Copyright (C) 1995-1996 Brian Paul + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Library General Public + * License as published by the Free Software Foundation; either + * version 2 of the License, or (at your option) any later version. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Library General Public License for more details. + * + * You should have received a copy of the GNU Library General Public + * License along with this library; if not, write to the Free + * Software Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. + */ + + +/* + * $Log: copypix.h,v $ + * Revision 1.1 1996/09/13 01:38:16 brianp + * Initial revision + * + */ + + +#ifndef COPYPIXELS_H +#define COPYPIXELS_H + + +#include "types.h" + + +extern void gl_CopyPixels( GLcontext* ctx, + GLint srcx, GLint srcy, + GLsizei width, GLsizei height, + GLenum type ); + + +#endif + diff --git a/dll/opengl/mesa/dd.h b/dll/opengl/mesa/dd.h new file mode 100644 index 00000000000..ed3f0394acb --- /dev/null +++ b/dll/opengl/mesa/dd.h @@ -0,0 +1,557 @@ +/* $Id: dd.h,v 1.15 1997/12/05 04:38:28 brianp Exp $ */ + +/* + * Mesa 3-D graphics library + * Version: 2.6 + * Copyright (C) 1995-1997 Brian Paul + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Library General Public + * License as published by the Free Software Foundation; either + * version 2 of the License, or (at your option) any later version. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Library General Public License for more details. + * + * You should have received a copy of the GNU Library General Public + * License along with this library; if not, write to the Free + * Software Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. + */ + + +/* + * $Log: dd.h,v $ + * Revision 1.15 1997/12/05 04:38:28 brianp + * added ClearColorAndDepth() function pointer (David Bucciarelli) + * + * Revision 1.14 1997/11/25 03:39:41 brianp + * added TexSubImage() function pointer (David Bucciarelli) + * + * Revision 1.13 1997/10/29 02:23:54 brianp + * added UseGlobalTexturePalette() dd function (David Bucciarelli v20 3dfx) + * + * Revision 1.12 1997/10/16 02:27:53 brianp + * more comments + * + * Revision 1.11 1997/10/14 00:07:40 brianp + * added DavidB's fxmesa v19 changes + * + * Revision 1.10 1997/09/29 23:26:50 brianp + * new texture functions + * + * Revision 1.9 1997/04/29 01:31:07 brianp + * added RasterSetup() function to device driver + * + * Revision 1.8 1997/04/20 19:47:27 brianp + * added RenderVB to device driver + * + * Revision 1.7 1997/04/20 16:31:08 brianp + * added NearFar device driver function + * + * Revision 1.6 1997/04/12 12:27:31 brianp + * added QuadFunc and RectFunc + * + * Revision 1.5 1997/03/21 01:57:07 brianp + * added RendererString() function + * + * Revision 1.4 1997/02/10 19:22:47 brianp + * added device driver Error() function + * + * Revision 1.3 1997/01/16 03:34:33 brianp + * added preliminary texture mapping functions and cleaned up documentation + * + * Revision 1.2 1996/11/13 03:51:59 brianp + * updated comments + * + * Revision 1.1 1996/09/13 01:38:16 brianp + * Initial revision + * + */ + + +#ifndef DD_INCLUDED +#define DD_INCLUDED + + +/* THIS FILE ONLY INCLUDED BY types.h !!!!! */ + + +/* + * Device Driver (DD) interface + * + * + * All device driver functions are accessed through pointers in the + * dd_function_table struct (defined below) which is stored in the GLcontext + * struct. Since the device driver is strictly accessed trough a table of + * function pointers we can: + * 1. switch between a number of different device drivers at runtime. + * 2. use optimized functions dependant on current rendering state or + * frame buffer configuration. + * + * The function pointers in the dd_function_table struct are divided into + * two groups: mandatory and optional. + * Mandatory functions have to be implemented by every device driver. + * Optional functions may or may not be implemented by the device driver. + * The optional functions provide ways to take advantage of special hardware + * or optimized algorithms. + * + * The function pointers in the dd_function_table struct are first + * initialized in the "MakeCurrent" function. The "MakeCurrent" function + * is a little different in each device driver. See the X/Mesa, GLX, or + * OS/Mesa drivers for examples. + * + * Later, Mesa may call the dd_function_table's UpdateState() function. + * This function should initialize the dd_function_table's pointers again. + * The UpdateState() function is called whenever the core (GL) rendering + * state is changed in a way which may effect rasterization. For example, + * the TriangleFunc() pointer may have to point to different functions + * depending on whether smooth or flat shading is enabled. + * + * Note that the first argument to every device driver function is a + * GLcontext *. In turn, the GLcontext->DriverCtx pointer points to + * the driver-specific context struct. See the X/Mesa or OS/Mesa interface + * for an example. + * + * For more information about writing a device driver see the ddsample.c + * file and other device drivers (xmesa[123].c, osmesa.c, etc) for examples. + * + * + * Look below in the dd_function_table struct definition for descriptions + * of each device driver function. + * + * + * In the future more function pointers may be added for glReadPixels + * glCopyPixels, etc. + * + * + * Notes: + * ------ + * RGBA = red/green/blue/alpha + * CI = color index (color mapped mode) + * mono = all pixels have the same color or index + * + * The write_ functions all take an array of mask flags which indicate + * whether or not the pixel should be written. One special case exists + * in the write_color_span function: if the mask array is NULL, then + * draw all pixels. This is an optimization used for glDrawPixels(). + * + * IN ALL CASES: + * X coordinates start at 0 at the left and increase to the right + * Y coordinates start at 0 at the bottom and increase upward + * + */ + + + + + +/* + * Device Driver function table. + */ +struct dd_function_table { + + /********************************************************************** + *** Mandatory functions: these functions must be implemented by *** + *** every device driver. *** + **********************************************************************/ + + const char * (*RendererString)(void); + /* + * Return a string which uniquely identifies this device driver. + * The string should contain no whitespace. Examples: "X11" "OffScreen" + * "MSWindows" "SVGA". + */ + + void (*UpdateState)( GLcontext *ctx ); + /* + * UpdateState() is called whenver Mesa thinks the device driver should + * update its state and/or the other pointers (such as PointsFunc, + * LineFunc, or TriangleFunc). + */ + + void (*ClearIndex)( GLcontext *ctx, GLuint index ); + /* + * Called whenever glClearIndex() is called. Set the index for clearing + * the color buffer. + */ + + void (*ClearColor)( GLcontext *ctx, GLubyte red, GLubyte green, + GLubyte blue, GLubyte alpha ); + /* + * Called whenever glClearColor() is called. Set the color for clearing + * the color buffer. + */ + + void (*Clear)( GLcontext *ctx, + GLboolean all, GLint x, GLint y, GLint width, GLint height ); + /* + * Clear the current color buffer. If 'all' is set the clear the whole + * buffer, else clear the region defined by (x,y,width,height). + */ + + void (*Index)( GLcontext *ctx, GLuint index ); + /* + * Sets current color index for drawing flat-shaded primitives. + */ + + void (*Color)( GLcontext *ctx, + GLubyte red, GLubyte green, GLubyte glue, GLubyte alpha ); + /* + * Sets current color for drawing flat-shaded primitives. + */ + + GLboolean (*SetBuffer)( GLcontext *ctx, GLenum mode ); + /* + * Selects either the front or back color buffer for reading and writing. + * mode is either GL_FRONT or GL_BACK. + */ + + void (*GetBufferSize)( GLcontext *ctx, + GLuint *width, GLuint *height ); + /* + * Returns the width and height of the current color buffer. + */ + + + /*** + *** Functions for writing pixels to the frame buffer: + ***/ + void (*WriteColorSpan)( GLcontext *ctx, + GLuint n, GLint x, GLint y, + const GLubyte red[], const GLubyte green[], + const GLubyte blue[], const GLubyte alpha[], + const GLubyte mask[] ); + /* + * Write a horizontal run of RGBA pixels. + */ + + void (*WriteMonocolorSpan)( GLcontext *ctx, + GLuint n, GLint x, GLint y, + const GLubyte mask[] ); + /* + * Write a horizontal run of mono-RGBA pixels. + */ + + void (*WriteColorPixels)( GLcontext *ctx, + GLuint n, const GLint x[], const GLint y[], + const GLubyte red[], const GLubyte green[], + const GLubyte blue[], const GLubyte alpha[], + const GLubyte mask[] ); + /* + * Write an array of RGBA pixels at random locations. + */ + + void (*WriteMonocolorPixels)( GLcontext *ctx, + GLuint n, const GLint x[], const GLint y[], + const GLubyte mask[] ); + /* + * Write an array of mono-RGBA pixels at random locations. + */ + + void (*WriteIndexSpan)( GLcontext *ctx, + GLuint n, GLint x, GLint y, const GLuint index[], + const GLubyte mask[] ); + /* + * Write a horizontal run of CI pixels. + */ + + void (*WriteMonoindexSpan)( GLcontext *ctx, + GLuint n, GLint x, GLint y, + const GLubyte mask[] ); + /* + * Write a horizontal run of mono-CI pixels. + */ + + void (*WriteIndexPixels)( GLcontext *ctx, + GLuint n, const GLint x[], const GLint y[], + const GLuint index[], const GLubyte mask[] ); + /* + * Write a random array of CI pixels. + */ + + void (*WriteMonoindexPixels)( GLcontext *ctx, + GLuint n, const GLint x[], const GLint y[], + const GLubyte mask[] ); + /* + * Write a random array of mono-CI pixels. + */ + + /*** + *** Functions to read pixels from frame buffer: + ***/ + void (*ReadIndexSpan)( GLcontext *ctx, + GLuint n, GLint x, GLint y, GLuint index[] ); + /* + * Read a horizontal run of color index pixels. + */ + + void (*ReadColorSpan)( GLcontext *ctx, + GLuint n, GLint x, GLint y, + GLubyte red[], GLubyte green[], + GLubyte blue[], GLubyte alpha[] ); + /* + * Read a horizontal run of RGBA pixels. + */ + + void (*ReadIndexPixels)( GLcontext *ctx, + GLuint n, const GLint x[], const GLint y[], + GLuint indx[], const GLubyte mask[] ); + /* + * Read a random array of CI pixels. + */ + + void (*ReadColorPixels)( GLcontext *ctx, + GLuint n, const GLint x[], const GLint y[], + GLubyte red[], GLubyte green[], + GLubyte blue[], GLubyte alpha[], + const GLubyte mask[] ); + /* + * Read a random array of RGBA pixels. + */ + + + /********************************************************************** + *** Optional functions: these functions may or may not be *** + *** implemented by the device driver. If the device driver *** + *** doesn't implement them it should never touch these pointers *** + *** since Mesa will either set them to NULL or point them at a *** + *** fall-back function. *** + **********************************************************************/ + + void (*Finish)( GLcontext *ctx ); + /* + * Called whenever glFinish() is called. + */ + + void (*Flush)( GLcontext *ctx ); + /* + * Called whenever glFlush() is called. + */ + + GLboolean (*IndexMask)( GLcontext *ctx, GLuint mask ); + /* + * Implements glIndexMask() if possible, else return GL_FALSE. + */ + + GLboolean (*ColorMask)( GLcontext *ctx, + GLboolean rmask, GLboolean gmask, + GLboolean bmask, GLboolean amask ); + /* + * Implements glColorMask() if possible, else return GL_FALSE. + */ + + GLboolean (*LogicOp)( GLcontext *ctx, GLenum op ); + /* + * Implements glLogicOp() if possible, else return GL_FALSE. + */ + + void (*Dither)( GLcontext *ctx, GLboolean enable ); + /* + * Enable/disable dithering. + */ + + void (*Error)( GLcontext *ctx ); + /* + * Called whenever an error is generated. ctx->ErrorValue contains + * the error value. + */ + + void (*NearFar)( GLcontext *ctx, GLfloat nearVal, GLfloat farVal ); + /* + * Called from glFrustum and glOrtho to tell device driver the + * near and far clipping plane Z values. The 3Dfx driver, for example, + * uses this. + */ + + + /*** + *** For supporting hardware Z buffers: + ***/ + + void (*AllocDepthBuffer)( GLcontext *ctx ); + /* + * Called when the depth buffer must be allocated or possibly resized. + */ + + void (*ClearDepthBuffer)( GLcontext *ctx ); + /* + * Clear the depth buffer to depth specified by CC.Depth.Clear value. + */ + + GLuint (*DepthTestSpan)( GLcontext *ctx, + GLuint n, GLint x, GLint y, const GLdepth z[], + GLubyte mask[] ); + void (*DepthTestPixels)( GLcontext *ctx, + GLuint n, const GLint x[], const GLint y[], + const GLdepth z[], GLubyte mask[] ); + /* + * Apply the depth buffer test to an span/array of pixels and return + * an updated pixel mask. This function is not used when accelerated + * point, line, polygon functions are used. + */ + + void (*ReadDepthSpanFloat)( GLcontext *ctx, + GLuint n, GLint x, GLint y, GLfloat depth[]); + void (*ReadDepthSpanInt)( GLcontext *ctx, + GLuint n, GLint x, GLint y, GLdepth depth[] ); + /* + * Return depth values as integers for glReadPixels. + * Floats should be returned in the range [0,1]. + * Ints (GLdepth) values should be in the range [0,MAXDEPTH]. + */ + + + void (*ClearColorAndDepth)( GLcontext *ctx, + GLboolean all, GLint x, GLint y, + GLint width, GLint height ); + /* + * If this function is implemented then it will be called when both the + * color and depth buffers are to be cleared. + */ + + + /*** + *** Accelerated point, line, polygon, glDrawPixels and glBitmap functions: + ***/ + + points_func PointsFunc; + /* + * Called to draw an array of points. + */ + + line_func LineFunc; + /* + * Called to draw a line segment. + */ + + triangle_func TriangleFunc; + /* + * Called to draw a filled triangle. + */ + + quad_func QuadFunc; + /* + * Called to draw a filled quadrilateral. + */ + + rect_func RectFunc; + /* + * Called to draw a filled, screen-aligned 2-D rectangle. + */ + + GLboolean (*DrawPixels)( GLcontext *ctx, + GLint x, GLint y, GLsizei width, GLsizei height, + GLenum format, GLenum type, GLboolean packed, + const GLvoid *pixels ); + /* + * Called from glDrawPixels(). + */ + + GLboolean (*Bitmap)( GLcontext *ctx, GLsizei width, GLsizei height, + GLfloat xorig, GLfloat yorig, + GLfloat xmove, GLfloat ymove, + const struct gl_image *bitmap ); + /* + * Called from glBitmap(). + */ + + void (*Begin)( GLcontext *ctx, GLenum mode ); + void (*End)( GLcontext *ctx ); + /* + * These are called whenever glBegin() or glEnd() are called. + * The device driver may do some sort of window locking/unlocking here. + */ + + + void (*RasterSetup)( GLcontext *ctx, GLuint start, GLuint end ); + /* + * This function, if not NULL, is called whenever new window coordinates + * are put in the vertex buffer. The vertices in question are those n + * such that start <= n < end. + * The device driver can convert the window coords to its own specialized + * format. The 3Dfx driver uses this. + */ + + GLboolean (*RenderVB)( GLcontext *ctx, GLboolean allDone ); + /* + * This function allows the device driver to rasterize an entire + * buffer of primitives at once. See the gl_render_vb() function + * in vbrender.c for more details. + * Return GL_TRUE if vertex buffer successfully rendered. + * Return GL_FALSE if failure, let core Mesa render the vertex buffer. + */ + + /*** + *** Texture mapping functions: + ***/ + + void (*TexEnv)( GLcontext *ctx, GLenum pname, const GLfloat *param ); + /* + * Called whenever glTexEnv*() is called. + * Pname will be one of GL_TEXTURE_ENV_MODE or GL_TEXTURE_ENV_COLOR. + * If pname is GL_TEXTURE_ENV_MODE then param will be one + * of GL_MODULATE, GL_BLEND, GL_DECAL, or GL_REPLACE. + */ + + void (*TexImage)( GLcontext *ctx, GLenum target, + struct gl_texture_object *tObj, GLint level, + GLint internalFormat, + const struct gl_texture_image *image ); + /* + * Called whenever a texture object's image is changed. + * texObject is the number of the texture object being changed. + * level indicates the mipmap level. + * internalFormat is the format in which the texture is to be stored. + * image is a pointer to a gl_texture_image struct which contains + * the actual image data. + */ + + void (*TexSubImage)( GLcontext *ctx, GLenum target, + struct gl_texture_object *tObj, GLint level, + GLint xoffset, GLint yoffset, + GLsizei width, GLsizei height, + GLint internalFormat, + const struct gl_texture_image *image ); + /* + * Called from glTexSubImage() to define a sub-region of a texture. + */ + + void (*TexParameter)( GLcontext *ctx, GLenum target, + struct gl_texture_object *tObj, + GLenum pname, const GLfloat *params ); + /* + * Called whenever glTexParameter*() is called. + * target is GL_TEXTURE_1D or GL_TEXTURE_2D + * texObject is the texture object to modify + * pname is one of GL_TEXTURE_MIN_FILTER, GL_TEXTURE_MAG_FILTER, + * GL_TEXTURE_WRAP_S, GL_TEXTURE_WRAP_T, or GL_TEXTURE_BORDER_COLOR. + * params is dependant on pname. See man glTexParameter. + */ + + void (*BindTexture)( GLcontext *ctx, GLenum target, + struct gl_texture_object *tObj ); + /* + * Called whenever glBindTexture() is called. This specifies which + * texture is to be the current one. + */ + + void (*DeleteTexture)( GLcontext *ctx, struct gl_texture_object *tObj ); + /* + * Called when a texture object can be deallocated. + */ + + void (*UpdateTexturePalette)( GLcontext *ctx, + struct gl_texture_object *tObj ); + /* + * Called when the texture's color lookup table is changed. + * If tObj is NULL then the shared texture palette ctx->Texture.Palette + * was changed. + */ +}; + + + +#endif + diff --git a/dll/opengl/mesa/depth.c b/dll/opengl/mesa/depth.c new file mode 100644 index 00000000000..e5cd4ece2c6 --- /dev/null +++ b/dll/opengl/mesa/depth.c @@ -0,0 +1,924 @@ +/* $Id: depth.c,v 1.11 1997/07/24 01:24:45 brianp Exp $ */ + +/* + * Mesa 3-D graphics library + * Version: 2.4 + * Copyright (C) 1995-1997 Brian Paul + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Library General Public + * License as published by the Free Software Foundation; either + * version 2 of the License, or (at your option) any later version. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Library General Public License for more details. + * + * You should have received a copy of the GNU Library General Public + * License along with this library; if not, write to the Free + * Software Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. + */ + + +/* + * $Log: depth.c,v $ + * Revision 1.11 1997/07/24 01:24:45 brianp + * changed precompiled header symbol from PCH to PC_HEADER + * + * Revision 1.10 1997/05/28 03:24:22 brianp + * added precompiled header (PCH) support + * + * Revision 1.9 1997/04/20 19:54:15 brianp + * replaced abort() with gl_problem() + * + * Revision 1.8 1997/02/27 19:58:52 brianp + * don't try to clear depth buffer if there isn't one + * + * Revision 1.7 1997/01/31 23:33:08 brianp + * replaced calloc with malloc in gl_alloc_depth_buffer() + * + * Revision 1.6 1996/11/04 01:42:07 brianp + * multiply Viewport.Sz and .Tz by DEPTH_SCALE + * + * Revision 1.5 1996/10/09 03:07:25 brianp + * replaced malloc with calloc in gl_alloc_depth_buffer() + * + * Revision 1.4 1996/09/27 01:24:58 brianp + * added missing default cases to switches + * + * Revision 1.3 1996/09/19 00:54:05 brianp + * added missing returns after some gl_error() calls + * + * Revision 1.2 1996/09/15 14:19:16 brianp + * now use GLframebuffer and GLvisual + * + * Revision 1.1 1996/09/13 01:38:16 brianp + * Initial revision + * + */ + + +/* + * Depth buffer functions + */ + + +#ifdef PC_HEADER +#include "all.h" +#else +#include +#include +#include "context.h" +#include "depth.h" +#include "dlist.h" +#include "macros.h" +#include "types.h" +#endif + + + +/**********************************************************************/ +/***** API Functions *****/ +/**********************************************************************/ + + + +void gl_ClearDepth( GLcontext* ctx, GLclampd depth ) +{ + if (INSIDE_BEGIN_END(ctx)) { + gl_error( ctx, GL_INVALID_OPERATION, "glClearDepth" ); + return; + } + ctx->Depth.Clear = (GLfloat) CLAMP( depth, 0.0, 1.0 ); +} + + + +void gl_DepthFunc( GLcontext* ctx, GLenum func ) +{ + if (INSIDE_BEGIN_END(ctx)) { + gl_error( ctx, GL_INVALID_OPERATION, "glDepthFunc" ); + return; + } + + switch (func) { + case GL_NEVER: + case GL_LESS: /* (default) pass if incoming z < stored z */ + case GL_GEQUAL: + case GL_LEQUAL: + case GL_GREATER: + case GL_NOTEQUAL: + case GL_EQUAL: + case GL_ALWAYS: + ctx->Depth.Func = func; + ctx->NewState |= NEW_RASTER_OPS; + break; + default: + gl_error( ctx, GL_INVALID_ENUM, "glDepth.Func" ); + } +} + + + +void gl_DepthMask( GLcontext* ctx, GLboolean flag ) +{ + if (INSIDE_BEGIN_END(ctx)) { + gl_error( ctx, GL_INVALID_OPERATION, "glDepthMask" ); + return; + } + + /* + * GL_TRUE indicates depth buffer writing is enabled (default) + * GL_FALSE indicates depth buffer writing is disabled + */ + ctx->Depth.Mask = flag; + ctx->NewState |= NEW_RASTER_OPS; +} + + + +void gl_DepthRange( GLcontext* ctx, GLclampd nearval, GLclampd farval ) +{ + /* + * nearval - specifies mapping of the near clipping plane to window + * coordinates, default is 0 + * farval - specifies mapping of the far clipping plane to window + * coordinates, default is 1 + * + * After clipping and div by w, z coords are in -1.0 to 1.0, + * corresponding to near and far clipping planes. glDepthRange + * specifies a linear mapping of the normalized z coords in + * this range to window z coords. + */ + + GLfloat n, f; + + if (INSIDE_BEGIN_END(ctx)) { + gl_error( ctx, GL_INVALID_OPERATION, "glDepthRange" ); + return; + } + + n = (GLfloat) CLAMP( nearval, 0.0, 1.0 ); + f = (GLfloat) CLAMP( farval, 0.0, 1.0 ); + + ctx->Viewport.Near = n; + ctx->Viewport.Far = f; + ctx->Viewport.Sz = DEPTH_SCALE * ((f - n) / 2.0); + ctx->Viewport.Tz = DEPTH_SCALE * ((f - n) / 2.0 + n); +} + + + +/**********************************************************************/ +/***** Depth Testing Functions *****/ +/**********************************************************************/ + + +/* + * Depth test horizontal spans of fragments. These functions are called + * via ctx->Driver.depth_test_span only. + * + * Input: n - number of pixels in the span + * x, y - location of leftmost pixel in span in window coords + * z - array [n] of integer depth values + * In/Out: mask - array [n] of flags (1=draw pixel, 0=don't draw) + * Return: number of pixels which passed depth test + */ + + +/* + * glDepthFunc( any ) and glDepthMask( GL_TRUE or GL_FALSE ). + */ +GLuint gl_depth_test_span_generic( GLcontext* ctx, + GLuint n, GLint x, GLint y, + const GLdepth z[], + GLubyte mask[] ) +{ + GLdepth *zptr = Z_ADDRESS( ctx, x, y ); + GLubyte *m = mask; + GLuint i; + GLuint passed = 0; + + /* switch cases ordered from most frequent to less frequent */ + switch (ctx->Depth.Func) { + case GL_LESS: + if (ctx->Depth.Mask) { + /* Update Z buffer */ + for (i=0; iDepth.Mask) { + /* Update Z buffer */ + for (i=0;iDepth.Mask) { + /* Update Z buffer */ + for (i=0;i= *zptr) { + *zptr = z[i]; + passed++; + } + else { + *m = 0; + } + } + } + } + else { + /* Don't update Z buffer */ + for (i=0;i= *zptr) { + /* pass */ + passed++; + } + else { + *m = 0; + } + } + } + } + break; + case GL_GREATER: + if (ctx->Depth.Mask) { + /* Update Z buffer */ + for (i=0;i *zptr) { + *zptr = z[i]; + passed++; + } + else { + *m = 0; + } + } + } + } + else { + /* Don't update Z buffer */ + for (i=0;i *zptr) { + /* pass */ + passed++; + } + else { + *m = 0; + } + } + } + } + break; + case GL_NOTEQUAL: + if (ctx->Depth.Mask) { + /* Update Z buffer */ + for (i=0;iDepth.Mask) { + /* Update Z buffer */ + for (i=0;iDepth.Mask) { + /* Update Z buffer */ + for (i=0;i zptr[i]) { + /* pass */ + zptr[i] = z[i]; + passed++; + } + else { + /* fail */ + mask[i] = 0; + } + } + } + return passed; +} + + + +/* + * Depth test an array of randomly positioned fragments. + */ + + +#define ZADDR_SETUP GLdepth *depthbuffer = ctx->Buffer->Depth; \ + GLint width = ctx->Buffer->Width; + +#define ZADDR( X, Y ) (depthbuffer + (Y) * width + (X) ) + + + +/* + * glDepthFunc( any ) and glDepthMask( GL_TRUE or GL_FALSE ). + */ +void gl_depth_test_pixels_generic( GLcontext* ctx, + GLuint n, const GLint x[], const GLint y[], + const GLdepth z[], GLubyte mask[] ) +{ + register GLdepth *zptr; + register GLuint i; + + /* switch cases ordered from most frequent to less frequent */ + switch (ctx->Depth.Func) { + case GL_LESS: + if (ctx->Depth.Mask) { + /* Update Z buffer */ + for (i=0; iDepth.Mask) { + /* Update Z buffer */ + for (i=0; iDepth.Mask) { + /* Update Z buffer */ + for (i=0; i= *zptr) { + /* pass */ + *zptr = z[i]; + } + else { + /* fail */ + mask[i] = 0; + } + } + } + } + else { + /* Don't update Z buffer */ + for (i=0; i= *zptr) { + /* pass */ + } + else { + /* fail */ + mask[i] = 0; + } + } + } + } + break; + case GL_GREATER: + if (ctx->Depth.Mask) { + /* Update Z buffer */ + for (i=0; i *zptr) { + /* pass */ + *zptr = z[i]; + } + else { + /* fail */ + mask[i] = 0; + } + } + } + } + else { + /* Don't update Z buffer */ + for (i=0; i *zptr) { + /* pass */ + } + else { + /* fail */ + mask[i] = 0; + } + } + } + } + break; + case GL_NOTEQUAL: + if (ctx->Depth.Mask) { + /* Update Z buffer */ + for (i=0; iDepth.Mask) { + /* Update Z buffer */ + for (i=0; iDepth.Mask) { + /* Update Z buffer */ + for (i=0; i *zptr) { + /* pass */ + *zptr = z[i]; + } + else { + /* fail */ + mask[i] = 0; + } + } + } +} + + + + +/**********************************************************************/ +/***** Read Depth Buffer *****/ +/**********************************************************************/ + + +/* + * Return a span of depth values from the depth buffer as floats in [0,1]. + * This function is only called through Driver.read_depth_span_float() + * Input: n - how many pixels + * x,y - location of first pixel + * Output: depth - the array of depth values + */ +void gl_read_depth_span_float( GLcontext* ctx, + GLuint n, GLint x, GLint y, GLfloat depth[] ) +{ + GLdepth *zptr; + GLfloat scale; + GLuint i; + + scale = 1.0F / DEPTH_SCALE; + + if (ctx->Buffer->Depth) { + zptr = Z_ADDRESS( ctx, x, y ); + for (i=0;iBuffer->Depth) { + GLdepth *zptr = Z_ADDRESS( ctx, x, y ); + MEMCPY( depth, zptr, n * sizeof(GLdepth) ); + } + else { + GLuint i; + for (i=0;iBuffer->Depth) { + free(ctx->Buffer->Depth); + ctx->Buffer->Depth = NULL; + } + + /* allocate new depth buffer, but don't initialize it */ + ctx->Buffer->Depth = (GLdepth *) malloc( ctx->Buffer->Width + * ctx->Buffer->Height + * sizeof(GLdepth) ); + if (!ctx->Buffer->Depth) { + /* out of memory */ + ctx->Depth.Test = GL_FALSE; + gl_error( ctx, GL_OUT_OF_MEMORY, "Couldn't allocate depth buffer" ); + } +} + + + + +/* + * Clear the depth buffer. If the depth buffer doesn't exist yet we'll + * allocate it now. + * This function is only called through Driver.clear_depth_buffer. + */ +void gl_clear_depth_buffer( GLcontext* ctx ) +{ + GLdepth clear_value = (GLdepth) (ctx->Depth.Clear * DEPTH_SCALE); + + if (ctx->Visual->DepthBits==0 || !ctx->Buffer->Depth) { + /* no depth buffer */ + return; + } + + /* The loops in this function have been written so the IRIX 5.3 + * C compiler can unroll them. Hopefully other compilers can too! + */ + + if (ctx->Scissor.Enabled) { + /* only clear scissor region */ + GLint y; + for (y=ctx->Buffer->Ymin; y<=ctx->Buffer->Ymax; y++) { + GLdepth *d = Z_ADDRESS( ctx, ctx->Buffer->Xmin, y ); + GLint n = ctx->Buffer->Xmax - ctx->Buffer->Xmin + 1; + do { + *d++ = clear_value; + n--; + } while (n); + } + } + else { + /* clear whole buffer */ + GLdepth *d = ctx->Buffer->Depth; + GLint n = ctx->Buffer->Width * ctx->Buffer->Height; + while (n>=16) { + d[0] = clear_value; d[1] = clear_value; + d[2] = clear_value; d[3] = clear_value; + d[4] = clear_value; d[5] = clear_value; + d[6] = clear_value; d[7] = clear_value; + d[8] = clear_value; d[9] = clear_value; + d[10] = clear_value; d[11] = clear_value; + d[12] = clear_value; d[13] = clear_value; + d[14] = clear_value; d[15] = clear_value; + d += 16; + n -= 16; + } + while (n>0) { + *d++ = clear_value; + n--; + } + } +} + + + diff --git a/dll/opengl/mesa/depth.h b/dll/opengl/mesa/depth.h new file mode 100644 index 00000000000..2d71018d585 --- /dev/null +++ b/dll/opengl/mesa/depth.h @@ -0,0 +1,101 @@ +/* $Id: depth.h,v 1.2 1996/09/15 14:19:16 brianp Exp $ */ + +/* + * Mesa 3-D graphics library + * Version: 2.0 + * Copyright (C) 1995-1996 Brian Paul + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Library General Public + * License as published by the Free Software Foundation; either + * version 2 of the License, or (at your option) any later version. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Library General Public License for more details. + * + * You should have received a copy of the GNU Library General Public + * License along with this library; if not, write to the Free + * Software Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. + */ + + +/* + * $Log: depth.h,v $ + * Revision 1.2 1996/09/15 14:19:16 brianp + * now use GLframebuffer and GLvisual + * + * Revision 1.1 1996/09/13 01:38:16 brianp + * Initial revision + * + */ + + +#ifndef DEPTH_H +#define DEPTH_H + + +#include "types.h" + + +/* + * Return the address of the Z-buffer value for window coordinate (x,y): + */ +#define Z_ADDRESS( CTX, X, Y ) \ + ((CTX)->Buffer->Depth + (CTX)->Buffer->Width * (Y) + (X)) + + + + +extern GLuint +gl_depth_test_span_generic( GLcontext* ctx, GLuint n, GLint x, GLint y, + const GLdepth z[], GLubyte mask[] ); + +extern GLuint +gl_depth_test_span_less( GLcontext* ctx, GLuint n, GLint x, GLint y, + const GLdepth z[], GLubyte mask[] ); + +extern GLuint +gl_depth_test_span_greater( GLcontext* ctx, GLuint n, GLint x, GLint y, + const GLdepth z[], GLubyte mask[] ); + + + +extern void +gl_depth_test_pixels_generic( GLcontext* ctx, + GLuint n, const GLint x[], const GLint y[], + const GLdepth z[], GLubyte mask[] ); + +extern void +gl_depth_test_pixels_less( GLcontext* ctx, + GLuint n, const GLint x[], const GLint y[], + const GLdepth z[], GLubyte mask[] ); + +extern void +gl_depth_test_pixels_greater( GLcontext* ctx, + GLuint n, const GLint x[], const GLint y[], + const GLdepth z[], GLubyte mask[] ); + + +extern void gl_read_depth_span_float( GLcontext* ctx, + GLuint n, GLint x, GLint y, + GLfloat depth[] ); + + +extern void gl_read_depth_span_int( GLcontext* ctx, GLuint n, GLint x, GLint y, + GLdepth depth[] ); + + +extern void gl_alloc_depth_buffer( GLcontext* ctx ); + + +extern void gl_clear_depth_buffer( GLcontext* ctx ); + + +extern void gl_ClearDepth( GLcontext* ctx, GLclampd depth ); +extern void gl_DepthFunc( GLcontext* ctx, GLenum func ); +extern void gl_DepthMask( GLcontext* ctx, GLboolean flag ); +extern void gl_DepthRange( GLcontext* ctx, GLclampd nearval, GLclampd farval ); + +#endif diff --git a/dll/opengl/mesa/dlist.c b/dll/opengl/mesa/dlist.c new file mode 100644 index 00000000000..14da6345514 --- /dev/null +++ b/dll/opengl/mesa/dlist.c @@ -0,0 +1,3096 @@ +/* $Id: dlist.c,v 1.37 1997/12/06 18:06:50 brianp Exp $ */ + +/* + * Mesa 3-D graphics library + * Version: 2.6 + * Copyright (C) 1995-1997 Brian Paul + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Library General Public + * License as published by the Free Software Foundation; either + * version 2 of the License, or (at your option) any later version. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Library General Public License for more details. + * + * You should have received a copy of the GNU Library General Public + * License along with this library; if not, write to the Free + * Software Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. + */ + + +/* + * $Log: dlist.c,v $ + * Revision 1.37 1997/12/06 18:06:50 brianp + * moved several static display list vars into GLcontext + * + * Revision 1.36 1997/11/25 03:20:09 brianp + * simple clean-ups for multi-threading (John Stone) + * + * Revision 1.35 1997/10/29 01:29:09 brianp + * added GL_EXT_point_parameters extension from Daniel Barrero + * + * Revision 1.34 1997/10/02 00:48:29 brianp + * removed the EXEC() macro stuff, it caused bugs in gl_save_Color*() + * + * Revision 1.33 1997/09/27 00:13:44 brianp + * added GL_EXT_paletted_texture extension + * + * Revision 1.32 1997/09/23 00:57:52 brianp + * removed list>MAX_DISPLAYLISTS test + * + * Revision 1.31 1997/09/22 02:33:58 brianp + * display lists now implemented with hash table + * + * Revision 1.30 1997/07/24 01:25:01 brianp + * changed precompiled header symbol from PCH to PC_HEADER + * + * Revision 1.29 1997/07/09 01:26:12 brianp + * fixed glDrawPixels() GL_COMPILE_AND_EXECUTE infinite loop (Renaud Cazoulat) + * + * Revision 1.28 1997/06/24 01:13:26 brianp + * initialize image RefCount to 1 for gl_save_TexSubImage[123]D() + * + * Revision 1.27 1997/06/20 01:57:57 brianp + * added gl_save_Color4ubv() + * + * Revision 1.26 1997/06/06 02:59:19 brianp + * renamed destroy_list() to gl_destroy_list() + * + * Revision 1.25 1997/05/28 03:24:22 brianp + * added precompiled header (PCH) support + * + * Revision 1.24 1997/05/27 03:13:41 brianp + * removed some debugging code + * + * Revision 1.23 1997/04/30 21:36:22 brianp + * added casts to gl_TexImage[123]D() calls + * + * Revision 1.22 1997/04/28 23:40:47 brianp + * added #include "rect.h" + * + * Revision 1.21 1997/04/24 01:50:53 brianp + * optimized glColor3f, glColor3fv, glColor4fv + * + * Revision 1.20 1997/04/24 00:30:17 brianp + * optimized glTexCoord2() code + * + * Revision 1.19 1997/04/21 01:21:33 brianp + * added gl_save_Rectf() + * + * Revision 1.18 1997/04/20 16:18:15 brianp + * added glOrtho and glFrustum API pointers + * + * Revision 1.17 1997/04/16 23:55:33 brianp + * added optimized glTexCoord2f code + * + * Revision 1.16 1997/04/14 22:18:23 brianp + * added optimized glVertex3fv code + * + * Revision 1.15 1997/04/14 02:00:39 brianp + * #include "texstate.h" instead of "texture.h" + * + * Revision 1.14 1997/04/07 02:58:49 brianp + * added gl_save_Vertex[23]f() and related code + * + * Revision 1.13 1997/04/01 04:26:02 brianp + * added code for glLoadIdentity(), changed #include's + * + * Revision 1.12 1997/02/27 19:58:08 brianp + * call gl_problem() instead of gl_warning() + * + * Revision 1.11 1997/02/09 18:50:18 brianp + * added GL_EXT_texture3D support + * + * Revision 1.10 1997/01/29 18:51:30 brianp + * small MEMCPY call change for Acorn compiler, per Graham Jones + * + * Revision 1.9 1997/01/09 21:25:28 brianp + * set reference count to one for texture images in display lists + * + * Revision 1.8 1996/12/11 20:19:11 brianp + * abort display list execution if invalid opcode found + * + * Revision 1.7 1996/12/09 21:39:23 brianp + * compare list to MAX_DISPLAYLISTS in gl_IsList() + * + * Revision 1.6 1996/12/04 22:14:27 brianp + * improved the mesa_print_display_list() debug function + * + * Revision 1.5 1996/11/07 04:12:45 brianp + * texture images are now gl_image structs, not gl_texture_image structs + * + * Revision 1.4 1996/10/16 00:59:12 brianp + * fixed bug in gl_save_Lightfv() + * execution of OPCODE_EDGE_FLAG used enum value instead of boolean + * + * Revision 1.3 1996/09/27 01:26:08 brianp + * removed unused variables + * + * Revision 1.2 1996/09/19 00:54:43 brianp + * fixed bug in gl_save_Rotatef() when in GL_COMPILE_AND_EXECUTE mode + * + * Revision 1.1 1996/09/13 01:38:16 brianp + * Initial revision + * + */ + + +#ifdef PC_HEADER +#include "all.h" +#else +#include +#include +#include +#include +#include "accum.h" +#include "alpha.h" +#include "attrib.h" +#include "bitmap.h" +#include "blend.h" +#include "clip.h" +#include "colortab.h" +#include "context.h" +#include "copypix.h" +#include "depth.h" +#include "drawpix.h" +#include "enable.h" +#include "eval.h" +#include "feedback.h" +#include "fog.h" +#include "hash.h" +#include "image.h" +#include "light.h" +#include "lines.h" +#include "dlist.h" +#include "logic.h" +#include "macros.h" +#include "masking.h" +#include "matrix.h" +#include "misc.h" +#include "pixel.h" +#include "points.h" +#include "polygon.h" +#include "rastpos.h" +#include "rect.h" +#include "scissor.h" +#include "stencil.h" +#include "texobj.h" +#include "teximage.h" +#include "texstate.h" +#include "types.h" +#include "vb.h" +#include "vbfill.h" +#endif + + + +/* +Functions which aren't compiled but executed immediately: + glIsList + glGenLists + glDeleteLists + glEndList + glFeedbackBuffer + glSelectBuffer + glRenderMode + glReadPixels + glPixelStore + glFlush + glFinish + glIsEnabled + glGet* + +Functions which cause errors if called while compiling a display list: + glNewList +*/ + + + +/* + * Display list instructions are stored as sequences of "nodes". Nodes + * are allocated in blocks. Each block has BLOCK_SIZE nodes. Blocks + * are linked together with a pointer. + */ + + +/* How many nodes to allocate at a time: */ +#define BLOCK_SIZE 500 + + +/* + * Display list opcodes. + * + * The fact that these identifiers are assigned consecutive + * integer values starting at 0 is very important, see InstSize array usage) + */ +typedef enum { + OPCODE_ACCUM, + OPCODE_ALPHA_FUNC, + OPCODE_BEGIN, + OPCODE_BIND_TEXTURE, + OPCODE_BITMAP, + OPCODE_BLEND_FUNC, + OPCODE_CALL_LIST, + OPCODE_CALL_LIST_OFFSET, + OPCODE_CLEAR, + OPCODE_CLEAR_ACCUM, + OPCODE_CLEAR_COLOR, + OPCODE_CLEAR_DEPTH, + OPCODE_CLEAR_INDEX, + OPCODE_CLEAR_STENCIL, + OPCODE_CLIP_PLANE, + OPCODE_COLOR_3F, + OPCODE_COLOR_4F, + OPCODE_COLOR_4UB, + OPCODE_COLOR_MASK, + OPCODE_COLOR_MATERIAL, + OPCODE_COLOR_TABLE, + OPCODE_COLOR_SUB_TABLE, + OPCODE_COPY_PIXELS, + OPCODE_COPY_TEX_IMAGE1D, + OPCODE_COPY_TEX_IMAGE2D, + OPCODE_COPY_TEX_IMAGE3D, + OPCODE_COPY_TEX_SUB_IMAGE1D, + OPCODE_COPY_TEX_SUB_IMAGE2D, + OPCODE_CULL_FACE, + OPCODE_DEPTH_FUNC, + OPCODE_DEPTH_MASK, + OPCODE_DEPTH_RANGE, + OPCODE_DISABLE, + OPCODE_DRAW_BUFFER, + OPCODE_DRAW_PIXELS, + OPCODE_EDGE_FLAG, + OPCODE_ENABLE, + OPCODE_END, + OPCODE_EVALCOORD1, + OPCODE_EVALCOORD2, + OPCODE_EVALMESH1, + OPCODE_EVALMESH2, + OPCODE_EVALPOINT1, + OPCODE_EVALPOINT2, + OPCODE_FOG, + OPCODE_FRONT_FACE, + OPCODE_FRUSTUM, + OPCODE_HINT, + OPCODE_INDEX, + OPCODE_INDEX_MASK, + OPCODE_INIT_NAMES, + OPCODE_LIGHT, + OPCODE_LIGHT_MODEL, + OPCODE_LINE_STIPPLE, + OPCODE_LINE_WIDTH, + OPCODE_LIST_BASE, + OPCODE_LOAD_IDENTITY, + OPCODE_LOAD_MATRIX, + OPCODE_LOAD_NAME, + OPCODE_LOGIC_OP, + OPCODE_MAP1, + OPCODE_MAP2, + OPCODE_MAPGRID1, + OPCODE_MAPGRID2, + OPCODE_MATERIAL, + OPCODE_MATRIX_MODE, + OPCODE_MULT_MATRIX, + OPCODE_NORMAL, + OPCODE_ORTHO, + OPCODE_PASSTHROUGH, + OPCODE_PIXEL_MAP, + OPCODE_PIXEL_TRANSFER, + OPCODE_PIXEL_ZOOM, + OPCODE_POINT_SIZE, + OPCODE_POLYGON_MODE, + OPCODE_POLYGON_STIPPLE, + OPCODE_POLYGON_OFFSET, + OPCODE_POP_ATTRIB, + OPCODE_POP_MATRIX, + OPCODE_POP_NAME, + OPCODE_PRIORITIZE_TEXTURE, + OPCODE_PUSH_ATTRIB, + OPCODE_PUSH_MATRIX, + OPCODE_PUSH_NAME, + OPCODE_RASTER_POS, + OPCODE_RECTF, + OPCODE_READ_BUFFER, + OPCODE_SCALE, + OPCODE_SCISSOR, + OPCODE_SHADE_MODEL, + OPCODE_STENCIL_FUNC, + OPCODE_STENCIL_MASK, + OPCODE_STENCIL_OP, + OPCODE_TEXCOORD2, + OPCODE_TEXCOORD4, + OPCODE_TEXENV, + OPCODE_TEXGEN, + OPCODE_TEXPARAMETER, + OPCODE_TEX_IMAGE1D, + OPCODE_TEX_IMAGE2D, + OPCODE_TEX_SUB_IMAGE1D, + OPCODE_TEX_SUB_IMAGE2D, + OPCODE_TRANSLATE, + OPCODE_VERTEX2, + OPCODE_VERTEX3, + OPCODE_VERTEX4, + OPCODE_VIEWPORT, + /* The following two are meta instructions */ + OPCODE_CONTINUE, + OPCODE_END_OF_LIST +} OpCode; + + +/* + * Each instruction in the display list is stored as a sequence of + * contiguous nodes in memory. + * Each node is the union of a variety of datatypes. + */ +union node { + OpCode opcode; + GLboolean b; + GLbitfield bf; + GLubyte ub; + GLshort s; + GLushort us; + GLint i; + GLuint ui; + GLenum e; + GLfloat f; + GLvoid *data; + void *next; /* If prev node's opcode==OPCODE_CONTINUE */ +}; + + + +/* Number of nodes of storage needed for each instruction: */ +static GLuint InstSize[ OPCODE_END_OF_LIST+1 ]; + + + +/**********************************************************************/ +/***** Private *****/ +/**********************************************************************/ + + +/* + * Allocate space for a display list instruction. + * Input: opcode - type of instruction + * argcount - number of arguments following the instruction + * Return: pointer to first node in the instruction + */ +static Node *alloc_instruction( GLcontext *ctx, OpCode opcode, GLint argcount ) +{ + Node *n, *newblock; + GLuint count = InstSize[opcode]; + + assert( count == argcount+1 ); + + if (ctx->CurrentPos + count + 2 > BLOCK_SIZE) { + /* This block is full. Allocate a new block and chain to it */ + n = ctx->CurrentBlock + ctx->CurrentPos; + n[0].opcode = OPCODE_CONTINUE; + newblock = (Node *) malloc( sizeof(Node) * BLOCK_SIZE ); + if (!newblock) { + gl_error( ctx, GL_OUT_OF_MEMORY, "Building display list" ); + return NULL; + } + n[1].next = (Node *) newblock; + ctx->CurrentBlock = newblock; + ctx->CurrentPos = 0; + } + + n = ctx->CurrentBlock + ctx->CurrentPos; + ctx->CurrentPos += count; + + n[0].opcode = opcode; + + return n; +} + + + +/* + * Make an empty display list. This is used by glGenLists() to + * reserver display list IDs. + */ +static Node *make_empty_list( void ) +{ + Node *n = (Node *) malloc( sizeof(Node) ); + n[0].opcode = OPCODE_END_OF_LIST; + return n; +} + + + +/* + * Destroy all nodes in a display list. + * Input: list - display list number + */ +void gl_destroy_list( GLcontext *ctx, GLuint list ) +{ + Node *n, *block; + GLboolean done; + + block = (Node *) HashLookup(ctx->Shared->DisplayList, list); + n = block; + + done = block ? GL_FALSE : GL_TRUE; + while (!done) { + switch (n[0].opcode) { + /* special cases first */ + case OPCODE_MAP1: + gl_free_control_points( ctx, n[1].e, (GLfloat *) n[6].data ); + n += InstSize[n[0].opcode]; + break; + case OPCODE_MAP2: + gl_free_control_points( ctx, n[1].e, (GLfloat *) n[10].data ); + n += InstSize[n[0].opcode]; + break; + case OPCODE_DRAW_PIXELS: + free( n[5].data ); + n += InstSize[n[0].opcode]; + break; + case OPCODE_BITMAP: + gl_free_image( (struct gl_image *) n[7].data ); + n += InstSize[n[0].opcode]; + break; + case OPCODE_COLOR_TABLE: + gl_free_image( (struct gl_image *) n[3].data ); + n += InstSize[n[0].opcode]; + break; + case OPCODE_COLOR_SUB_TABLE: + gl_free_image( (struct gl_image *) n[3].data ); + n += InstSize[n[0].opcode]; + break; + case OPCODE_POLYGON_STIPPLE: + free( n[1].data ); + n += InstSize[n[0].opcode]; + break; + case OPCODE_TEX_IMAGE1D: + gl_free_image( (struct gl_image *) n[8].data ); + n += InstSize[n[0].opcode]; + break; + case OPCODE_TEX_IMAGE2D: + gl_free_image( (struct gl_image *) n[9].data ); + n += InstSize[n[0].opcode]; + break; + case OPCODE_TEX_SUB_IMAGE1D: + { + struct gl_image *image; + image = (struct gl_image *) n[7].data; + gl_free_image( image ); + } + break; + case OPCODE_TEX_SUB_IMAGE2D: + { + struct gl_image *image; + image = (struct gl_image *) n[9].data; + gl_free_image( image ); + } + break; + case OPCODE_CONTINUE: + n = (Node *) n[1].next; + free( block ); + block = n; + break; + case OPCODE_END_OF_LIST: + free( block ); + done = GL_TRUE; + break; + default: + /* Most frequent case */ + n += InstSize[n[0].opcode]; + break; + } + } + + HashRemove(ctx->Shared->DisplayList, list); +} + + + +/* + * Translate the nth element of list from type to GLuint. + */ +static GLuint translate_id( GLsizei n, GLenum type, const GLvoid *list ) +{ + GLbyte *bptr; + GLubyte *ubptr; + GLshort *sptr; + GLushort *usptr; + GLint *iptr; + GLuint *uiptr; + GLfloat *fptr; + + switch (type) { + case GL_BYTE: + bptr = (GLbyte *) list; + return (GLuint) *(bptr+n); + case GL_UNSIGNED_BYTE: + ubptr = (GLubyte *) list; + return (GLuint) *(ubptr+n); + case GL_SHORT: + sptr = (GLshort *) list; + return (GLuint) *(sptr+n); + case GL_UNSIGNED_SHORT: + usptr = (GLushort *) list; + return (GLuint) *(usptr+n); + case GL_INT: + iptr = (GLint *) list; + return (GLuint) *(iptr+n); + case GL_UNSIGNED_INT: + uiptr = (GLuint *) list; + return (GLuint) *(uiptr+n); + case GL_FLOAT: + fptr = (GLfloat *) list; + return (GLuint) *(fptr+n); + case GL_2_BYTES: + ubptr = ((GLubyte *) list) + 2*n; + return (GLuint) *ubptr * 256 + (GLuint) *(ubptr+1); + case GL_3_BYTES: + ubptr = ((GLubyte *) list) + 3*n; + return (GLuint) *ubptr * 65536 + + (GLuint) *(ubptr+1) * 256 + + (GLuint) *(ubptr+2); + case GL_4_BYTES: + ubptr = ((GLubyte *) list) + 4*n; + return (GLuint) *ubptr * 16777216 + + (GLuint) *(ubptr+1) * 65536 + + (GLuint) *(ubptr+2) * 256 + + (GLuint) *(ubptr+3); + default: + return 0; + } +} + + + + +/**********************************************************************/ +/***** Public *****/ +/**********************************************************************/ + +void gl_init_lists( void ) +{ + static int init_flag = 0; + + if (init_flag==0) { + InstSize[OPCODE_ACCUM] = 3; + InstSize[OPCODE_ALPHA_FUNC] = 3; + InstSize[OPCODE_BEGIN] = 2; + InstSize[OPCODE_BIND_TEXTURE] = 3; + InstSize[OPCODE_BITMAP] = 8; + InstSize[OPCODE_BLEND_FUNC] = 3; + InstSize[OPCODE_CALL_LIST] = 2; + InstSize[OPCODE_CALL_LIST_OFFSET] = 2; + InstSize[OPCODE_CLEAR] = 2; + InstSize[OPCODE_CLEAR_ACCUM] = 5; + InstSize[OPCODE_CLEAR_COLOR] = 5; + InstSize[OPCODE_CLEAR_DEPTH] = 2; + InstSize[OPCODE_CLEAR_INDEX] = 2; + InstSize[OPCODE_CLEAR_STENCIL] = 2; + InstSize[OPCODE_CLIP_PLANE] = 6; + InstSize[OPCODE_COLOR_3F] = 4; + InstSize[OPCODE_COLOR_4F] = 5; + InstSize[OPCODE_COLOR_4UB] = 5; + InstSize[OPCODE_COLOR_MASK] = 5; + InstSize[OPCODE_COLOR_MATERIAL] = 3; + InstSize[OPCODE_COLOR_TABLE] = 4; + InstSize[OPCODE_COLOR_SUB_TABLE] = 4; + InstSize[OPCODE_COPY_PIXELS] = 6; + InstSize[OPCODE_COPY_TEX_IMAGE1D] = 8; + InstSize[OPCODE_COPY_TEX_IMAGE2D] = 9; + InstSize[OPCODE_COPY_TEX_SUB_IMAGE1D] = 7; + InstSize[OPCODE_COPY_TEX_SUB_IMAGE2D] = 9; + InstSize[OPCODE_CULL_FACE] = 2; + InstSize[OPCODE_DEPTH_FUNC] = 2; + InstSize[OPCODE_DEPTH_MASK] = 2; + InstSize[OPCODE_DEPTH_RANGE] = 3; + InstSize[OPCODE_DISABLE] = 2; + InstSize[OPCODE_DRAW_BUFFER] = 2; + InstSize[OPCODE_DRAW_PIXELS] = 6; + InstSize[OPCODE_ENABLE] = 2; + InstSize[OPCODE_EDGE_FLAG] = 2; + InstSize[OPCODE_END] = 1; + InstSize[OPCODE_EVALCOORD1] = 2; + InstSize[OPCODE_EVALCOORD2] = 3; + InstSize[OPCODE_EVALMESH1] = 4; + InstSize[OPCODE_EVALMESH2] = 6; + InstSize[OPCODE_EVALPOINT1] = 2; + InstSize[OPCODE_EVALPOINT2] = 3; + InstSize[OPCODE_FOG] = 6; + InstSize[OPCODE_FRONT_FACE] = 2; + InstSize[OPCODE_FRUSTUM] = 7; + InstSize[OPCODE_HINT] = 3; + InstSize[OPCODE_INDEX] = 2; + InstSize[OPCODE_INDEX_MASK] = 2; + InstSize[OPCODE_INIT_NAMES] = 1; + InstSize[OPCODE_LIGHT] = 7; + InstSize[OPCODE_LIGHT_MODEL] = 6; + InstSize[OPCODE_LINE_STIPPLE] = 3; + InstSize[OPCODE_LINE_WIDTH] = 2; + InstSize[OPCODE_LIST_BASE] = 2; + InstSize[OPCODE_LOAD_IDENTITY] = 1; + InstSize[OPCODE_LOAD_MATRIX] = 17; + InstSize[OPCODE_LOAD_NAME] = 2; + InstSize[OPCODE_LOGIC_OP] = 2; + InstSize[OPCODE_MAP1] = 7; + InstSize[OPCODE_MAP2] = 11; + InstSize[OPCODE_MAPGRID1] = 4; + InstSize[OPCODE_MAPGRID2] = 7; + InstSize[OPCODE_MATERIAL] = 7; + InstSize[OPCODE_MATRIX_MODE] = 2; + InstSize[OPCODE_MULT_MATRIX] = 17; + InstSize[OPCODE_NORMAL] = 4; + InstSize[OPCODE_ORTHO] = 7; + InstSize[OPCODE_PASSTHROUGH] = 2; + InstSize[OPCODE_PIXEL_MAP] = 4; + InstSize[OPCODE_PIXEL_TRANSFER] = 3; + InstSize[OPCODE_PIXEL_ZOOM] = 3; + InstSize[OPCODE_POINT_SIZE] = 2; + InstSize[OPCODE_POLYGON_MODE] = 3; + InstSize[OPCODE_POLYGON_STIPPLE] = 2; + InstSize[OPCODE_POLYGON_OFFSET] = 3; + InstSize[OPCODE_POP_ATTRIB] = 1; + InstSize[OPCODE_POP_MATRIX] = 1; + InstSize[OPCODE_POP_NAME] = 1; + InstSize[OPCODE_PRIORITIZE_TEXTURE] = 3; + InstSize[OPCODE_PUSH_ATTRIB] = 2; + InstSize[OPCODE_PUSH_MATRIX] = 1; + InstSize[OPCODE_PUSH_NAME] = 2; + InstSize[OPCODE_RASTER_POS] = 5; + InstSize[OPCODE_RECTF] = 5; + InstSize[OPCODE_READ_BUFFER] = 2; + InstSize[OPCODE_SCALE] = 4; + InstSize[OPCODE_SCISSOR] = 5; + InstSize[OPCODE_STENCIL_FUNC] = 4; + InstSize[OPCODE_STENCIL_MASK] = 2; + InstSize[OPCODE_STENCIL_OP] = 4; + InstSize[OPCODE_SHADE_MODEL] = 2; + InstSize[OPCODE_TEXCOORD2] = 3; + InstSize[OPCODE_TEXCOORD4] = 5; + InstSize[OPCODE_TEXENV] = 7; + InstSize[OPCODE_TEXGEN] = 7; + InstSize[OPCODE_TEXPARAMETER] = 7; + InstSize[OPCODE_TEX_IMAGE1D] = 9; + InstSize[OPCODE_TEX_IMAGE2D] = 10; + InstSize[OPCODE_TEX_SUB_IMAGE1D] = 8; + InstSize[OPCODE_TEX_SUB_IMAGE2D] = 10; + InstSize[OPCODE_TRANSLATE] = 4; + InstSize[OPCODE_VERTEX2] = 3; + InstSize[OPCODE_VERTEX3] = 4; + InstSize[OPCODE_VERTEX4] = 5; + InstSize[OPCODE_VIEWPORT] = 5; + InstSize[OPCODE_CONTINUE] = 2; + InstSize[OPCODE_END_OF_LIST] = 1; + } + init_flag = 1; +} + + +/* + * Display List compilation functions + */ + + +void gl_save_Accum( GLcontext *ctx, GLenum op, GLfloat value ) +{ + Node *n = alloc_instruction( ctx, OPCODE_ACCUM, 2 ); + if (n) { + n[1].e = op; + n[2].f = value; + } + if (ctx->ExecuteFlag) { + (*ctx->Exec.Accum)( ctx, op, value ); + } +} + + +void gl_save_AlphaFunc( GLcontext *ctx, GLenum func, GLclampf ref ) +{ + Node *n = alloc_instruction( ctx, OPCODE_ALPHA_FUNC, 2 ); + if (n) { + n[1].e = func; + n[2].f = (GLfloat) ref; + } + if (ctx->ExecuteFlag) { + (*ctx->Exec.AlphaFunc)( ctx, func, ref ); + } +} + + +void gl_save_Begin( GLcontext *ctx, GLenum mode ) +{ + Node *n = alloc_instruction( ctx, OPCODE_BEGIN, 1 ); + if (n) { + n[1].e = mode; + } + if (ctx->ExecuteFlag) { + (*ctx->Exec.Begin)( ctx, mode ); + } +} + + +void gl_save_BindTexture( GLcontext *ctx, GLenum target, GLuint texture ) +{ + Node *n = alloc_instruction( ctx, OPCODE_BIND_TEXTURE, 2 ); + if (n) { + n[1].e = target; + n[2].ui = texture; + } + if (ctx->ExecuteFlag) { + (*ctx->Exec.BindTexture)( ctx, target, texture ); + } +} + + +void gl_save_Bitmap( GLcontext *ctx, + GLsizei width, GLsizei height, + GLfloat xorig, GLfloat yorig, + GLfloat xmove, GLfloat ymove, + const struct gl_image *bitmap ) +{ + Node *n = alloc_instruction( ctx, OPCODE_BITMAP, 7 ); + if (n) { + n[1].i = (GLint) width; + n[2].i = (GLint) height; + n[3].f = xorig; + n[4].f = yorig; + n[5].f = xmove; + n[6].f = ymove; + n[7].data = (void *) bitmap; + } + if (ctx->ExecuteFlag) { + (*ctx->Exec.Bitmap)( ctx, width, height, + xorig, yorig, xmove, ymove, bitmap ); + } +} + + +void gl_save_BlendFunc( GLcontext *ctx, GLenum sfactor, GLenum dfactor ) +{ + Node *n = alloc_instruction( ctx, OPCODE_BLEND_FUNC, 2 ); + if (n) { + n[1].e = sfactor; + n[2].e = dfactor; + } + if (ctx->ExecuteFlag) { + (*ctx->Exec.BlendFunc)( ctx, sfactor, dfactor ); + } +} + + +void gl_save_CallList( GLcontext *ctx, GLuint list ) +{ + Node *n = alloc_instruction( ctx, OPCODE_CALL_LIST, 1 ); + if (n) { + n[1].ui = list; + } + if (ctx->ExecuteFlag) { + (*ctx->Exec.CallList)( ctx, list ); + } +} + + +void gl_save_CallLists( GLcontext *ctx, + GLsizei n, GLenum type, const GLvoid *lists ) +{ + GLuint i; + + for (i=0;iExecuteFlag) { + (*ctx->Exec.CallLists)( ctx, n, type, lists ); + } +} + + +void gl_save_Clear( GLcontext *ctx, GLbitfield mask ) +{ + Node *n = alloc_instruction( ctx, OPCODE_CLEAR, 1 ); + if (n) { + n[1].bf = mask; + } + if (ctx->ExecuteFlag) { + (*ctx->Exec.Clear)( ctx, mask ); + } +} + + +void gl_save_ClearAccum( GLcontext *ctx, GLfloat red, GLfloat green, + GLfloat blue, GLfloat alpha ) +{ + Node *n = alloc_instruction( ctx, OPCODE_CLEAR_ACCUM, 4 ); + if (n) { + n[1].f = red; + n[2].f = green; + n[3].f = blue; + n[4].f = alpha; + } + if (ctx->ExecuteFlag) { + (*ctx->Exec.ClearAccum)( ctx, red, green, blue, alpha ); + } +} + + +void gl_save_ClearColor( GLcontext *ctx, GLclampf red, GLclampf green, + GLclampf blue, GLclampf alpha ) +{ + Node *n = alloc_instruction( ctx, OPCODE_CLEAR_COLOR, 4 ); + if (n) { + n[1].f = red; + n[2].f = green; + n[3].f = blue; + n[4].f = alpha; + } + if (ctx->ExecuteFlag) { + (*ctx->Exec.ClearColor)( ctx, red, green, blue, alpha ); + } +} + + +void gl_save_ClearDepth( GLcontext *ctx, GLclampd depth ) +{ + Node *n = alloc_instruction( ctx, OPCODE_CLEAR_DEPTH, 1 ); + if (n) { + n[1].f = (GLfloat) depth; + } + if (ctx->ExecuteFlag) { + (*ctx->Exec.ClearDepth)( ctx, depth ); + } +} + + +void gl_save_ClearIndex( GLcontext *ctx, GLfloat c ) +{ + Node *n = alloc_instruction( ctx, OPCODE_CLEAR_INDEX, 1 ); + if (n) { + n[1].f = c; + } + if (ctx->ExecuteFlag) { + (*ctx->Exec.ClearIndex)( ctx, c ); + } +} + + +void gl_save_ClearStencil( GLcontext *ctx, GLint s ) +{ + Node *n = alloc_instruction( ctx, OPCODE_CLEAR_STENCIL, 1 ); + if (n) { + n[1].i = s; + } + if (ctx->ExecuteFlag) { + (*ctx->Exec.ClearStencil)( ctx, s ); + } +} + + +void gl_save_ClipPlane( GLcontext *ctx, GLenum plane, const GLfloat *equ ) +{ + Node *n = alloc_instruction( ctx, OPCODE_CLIP_PLANE, 5 ); + if (n) { + n[1].e = plane; + n[2].f = equ[0]; + n[3].f = equ[1]; + n[4].f = equ[2]; + n[5].f = equ[3]; + } + if (ctx->ExecuteFlag) { + (*ctx->Exec.ClipPlane)( ctx, plane, equ ); + } +} + + +void gl_save_Color3f( GLcontext *ctx, GLfloat r, GLfloat g, GLfloat b ) +{ + Node *n = alloc_instruction( ctx, OPCODE_COLOR_3F, 3 ); + if (n) { + n[1].f = r; + n[2].f = g; + n[3].f = b; + } + if (ctx->ExecuteFlag) { + (*ctx->Exec.Color3f)( ctx, r, g, b ); + } +} + + +void gl_save_Color3fv( GLcontext *ctx, const GLfloat *c ) +{ + Node *n = alloc_instruction( ctx, OPCODE_COLOR_3F, 3 ); + if (n) { + n[1].f = c[0]; + n[2].f = c[1]; + n[3].f = c[2]; + } + if (ctx->ExecuteFlag) { + (*ctx->Exec.Color3fv)( ctx, c ); + } +} + + +void gl_save_Color4f( GLcontext *ctx, GLfloat r, GLfloat g, + GLfloat b, GLfloat a ) +{ + Node *n = alloc_instruction( ctx, OPCODE_COLOR_4F, 4 ); + if (n) { + n[1].f = r; + n[2].f = g; + n[3].f = b; + n[4].f = a; + } + if (ctx->ExecuteFlag) { + (*ctx->Exec.Color4f)( ctx, r, g, b, a ); + } +} + + +void gl_save_Color4fv( GLcontext *ctx, const GLfloat *c ) +{ + Node *n = alloc_instruction( ctx, OPCODE_COLOR_4F, 4 ); + if (n) { + n[1].f = c[0]; + n[2].f = c[1]; + n[3].f = c[2]; + n[4].f = c[3]; + } + if (ctx->ExecuteFlag) { + (*ctx->Exec.Color4fv)( ctx, c ); + } +} + + +void gl_save_Color4ub( GLcontext *ctx, GLubyte r, GLubyte g, + GLubyte b, GLubyte a ) +{ + Node *n = alloc_instruction( ctx, OPCODE_COLOR_4UB, 4 ); + if (n) { + n[1].ub = r; + n[2].ub = g; + n[3].ub = b; + n[4].ub = a; + } + if (ctx->ExecuteFlag) { + (*ctx->Exec.Color4ub)( ctx, r, g, b, a ); + } +} + + +void gl_save_Color4ubv( GLcontext *ctx, const GLubyte *c ) +{ + Node *n = alloc_instruction( ctx, OPCODE_COLOR_4UB, 4 ); + if (n) { + n[1].ub = c[0]; + n[2].ub = c[1]; + n[3].ub = c[2]; + n[4].ub = c[3]; + } + if (ctx->ExecuteFlag) { + (*ctx->Exec.Color4ubv)( ctx, c ); + } +} + + +void gl_save_ColorMask( GLcontext *ctx, GLboolean red, GLboolean green, + GLboolean blue, GLboolean alpha ) +{ + Node *n = alloc_instruction( ctx, OPCODE_COLOR_MASK, 4 ); + if (n) { + n[1].b = red; + n[2].b = green; + n[3].b = blue; + n[4].b = alpha; + } + if (ctx->ExecuteFlag) { + (*ctx->Exec.ColorMask)( ctx, red, green, blue, alpha ); + } +} + + +void gl_save_ColorMaterial( GLcontext *ctx, GLenum face, GLenum mode ) +{ + Node *n = alloc_instruction( ctx, OPCODE_COLOR_MATERIAL, 2 ); + if (n) { + n[1].e = face; + n[2].e = mode; + } + if (ctx->ExecuteFlag) { + (*ctx->Exec.ColorMaterial)( ctx, face, mode ); + } +} + + +void gl_save_ColorTable( GLcontext *ctx, GLenum target, GLenum internalFormat, + struct gl_image *table ) +{ + Node *n = alloc_instruction( ctx, OPCODE_COLOR_TABLE, 3 ); + if (n) { + n[1].e = target; + n[2].e = internalFormat; + n[3].data = (GLvoid *) table; + if (table) { + /* must retain this image */ + table->RefCount = 1; + } + } + if (ctx->ExecuteFlag) { + (*ctx->Exec.ColorTable)( ctx, target, internalFormat, table ); + } +} + + +void gl_save_ColorSubTable( GLcontext *ctx, GLenum target, + GLsizei start, struct gl_image *data ) +{ + Node *n = alloc_instruction( ctx, OPCODE_COLOR_SUB_TABLE, 3 ); + if (n) { + n[1].e = target; + n[2].i = start; + n[3].data = (GLvoid *) data; + if (data) { + /* must retain this image */ + data->RefCount = 1; + } + } + if (ctx->ExecuteFlag) { + (*ctx->Exec.ColorSubTable)( ctx, target, start, data ); + } +} + + + +void gl_save_CopyPixels( GLcontext *ctx, GLint x, GLint y, + GLsizei width, GLsizei height, GLenum type ) +{ + Node *n = alloc_instruction( ctx, OPCODE_COPY_PIXELS, 5 ); + if (n) { + n[1].i = x; + n[2].i = y; + n[3].i = (GLint) width; + n[4].i = (GLint) height; + n[5].e = type; + } + if (ctx->ExecuteFlag) { + (*ctx->Exec.CopyPixels)( ctx, x, y, width, height, type ); + } +} + + + +void gl_save_CopyTexImage1D( GLcontext *ctx, + GLenum target, GLint level, + GLenum internalformat, + GLint x, GLint y, GLsizei width, + GLint border ) +{ + Node *n = alloc_instruction( ctx, OPCODE_COPY_TEX_IMAGE1D, 7 ); + if (n) { + n[1].e = target; + n[2].i = level; + n[3].e = internalformat; + n[4].i = x; + n[5].i = y; + n[6].i = width; + n[7].i = border; + } + if (ctx->ExecuteFlag) { + (*ctx->Exec.CopyTexImage1D)( ctx, target, level, internalformat, + x, y, width, border ); + } +} + + +void gl_save_CopyTexImage2D( GLcontext *ctx, + GLenum target, GLint level, + GLenum internalformat, + GLint x, GLint y, GLsizei width, + GLsizei height, GLint border ) +{ + Node *n = alloc_instruction( ctx, OPCODE_COPY_TEX_IMAGE2D, 8 ); + if (n) { + n[1].e = target; + n[2].i = level; + n[3].e = internalformat; + n[4].i = x; + n[5].i = y; + n[6].i = width; + n[7].i = height; + n[8].i = border; + } + if (ctx->ExecuteFlag) { + (*ctx->Exec.CopyTexImage2D)( ctx, target, level, internalformat, + x, y, width, height, border ); + } +} + + + +void gl_save_CopyTexSubImage1D( GLcontext *ctx, + GLenum target, GLint level, + GLint xoffset, GLint x, GLint y, + GLsizei width ) +{ + Node *n = alloc_instruction( ctx, OPCODE_COPY_TEX_SUB_IMAGE1D, 6 ); + if (n) { + n[1].e = target; + n[2].i = level; + n[3].i = xoffset; + n[4].i = x; + n[5].i = y; + n[6].i = width; + } + if (ctx->ExecuteFlag) { + (*ctx->Exec.CopyTexSubImage1D)( ctx, target, level, xoffset, x, y, width ); + } +} + + +void gl_save_CopyTexSubImage2D( GLcontext *ctx, + GLenum target, GLint level, + GLint xoffset, GLint yoffset, + GLint x, GLint y, + GLsizei width, GLint height ) +{ + Node *n = alloc_instruction( ctx, OPCODE_COPY_TEX_SUB_IMAGE2D, 8 ); + if (n) { + n[1].e = target; + n[2].i = level; + n[3].i = xoffset; + n[4].i = yoffset; + n[5].i = x; + n[6].i = y; + n[7].i = width; + n[8].i = height; + } + if (ctx->ExecuteFlag) { + (*ctx->Exec.CopyTexSubImage2D)( ctx, target, level, xoffset, yoffset, + x, y, width, height ); + } +} + +void gl_save_CullFace( GLcontext *ctx, GLenum mode ) +{ + Node *n = alloc_instruction( ctx, OPCODE_CULL_FACE, 1 ); + if (n) { + n[1].e = mode; + } + if (ctx->ExecuteFlag) { + (*ctx->Exec.CullFace)( ctx, mode ); + } +} + + +void gl_save_DepthFunc( GLcontext *ctx, GLenum func ) +{ + Node *n = alloc_instruction( ctx, OPCODE_DEPTH_FUNC, 1 ); + if (n) { + n[1].e = func; + } + if (ctx->ExecuteFlag) { + (*ctx->Exec.DepthFunc)( ctx, func ); + } +} + + +void gl_save_DepthMask( GLcontext *ctx, GLboolean mask ) +{ + Node *n = alloc_instruction( ctx, OPCODE_DEPTH_MASK, 1 ); + if (n) { + n[1].b = mask; + } + if (ctx->ExecuteFlag) { + (*ctx->Exec.DepthMask)( ctx, mask ); + } +} + + +void gl_save_DepthRange( GLcontext *ctx, GLclampd nearval, GLclampd farval ) +{ + Node *n = alloc_instruction( ctx, OPCODE_DEPTH_RANGE, 2 ); + if (n) { + n[1].f = (GLfloat) nearval; + n[2].f = (GLfloat) farval; + } + if (ctx->ExecuteFlag) { + (*ctx->Exec.DepthRange)( ctx, nearval, farval ); + } +} + + +void gl_save_Disable( GLcontext *ctx, GLenum cap ) +{ + Node *n = alloc_instruction( ctx, OPCODE_DISABLE, 1 ); + if (n) { + n[1].e = cap; + } + if (ctx->ExecuteFlag) { + (*ctx->Exec.Disable)( ctx, cap ); + } +} + + +void gl_save_DrawBuffer( GLcontext *ctx, GLenum mode ) +{ + Node *n = alloc_instruction( ctx, OPCODE_DRAW_BUFFER, 1 ); + if (n) { + n[1].e = mode; + } + if (ctx->ExecuteFlag) { + (*ctx->Exec.DrawBuffer)( ctx, mode ); + } +} + + +void gl_save_DrawPixels( GLcontext *ctx, GLsizei width, GLsizei height, + GLenum format, GLenum type, const GLvoid *pixels ) +{ + Node *n = alloc_instruction( ctx, OPCODE_DRAW_PIXELS, 5 ); + if (n) { + n[1].i = (GLint) width; + n[2].i = (GLint) height; + n[3].e = format; + n[4].e = type; + n[5].data = (GLvoid *) pixels; + } +/* Special case: gl_DrawPixels takes care of GL_COMPILE_AND_EXECUTE case! + if (ctx->ExecuteFlag) { + (*ctx->Exec.DrawPixels)( ctx, width, height, format, type, pixels ); + } +*/ +} + + +void gl_save_EdgeFlag( GLcontext *ctx, GLboolean flag ) +{ + Node *n = alloc_instruction( ctx, OPCODE_EDGE_FLAG, 1 ); + if (n) { + n[1].b = flag; + } + if (ctx->ExecuteFlag) { + (*ctx->Exec.EdgeFlag)( ctx, flag ); + } +} + + +void gl_save_Enable( GLcontext *ctx, GLenum cap ) +{ + Node *n = alloc_instruction( ctx, OPCODE_ENABLE, 1 ); + if (n) { + n[1].e = cap; + } + if (ctx->ExecuteFlag) { + (*ctx->Exec.Enable)( ctx, cap ); + } +} + + +void gl_save_End( GLcontext *ctx ) +{ + (void) alloc_instruction( ctx, OPCODE_END, 0 ); + if (ctx->ExecuteFlag) { + (*ctx->Exec.End)( ctx ); + } +} + + +void gl_save_EvalCoord1f( GLcontext *ctx, GLfloat u ) +{ + Node *n = alloc_instruction( ctx, OPCODE_EVALCOORD1, 1 ); + if (n) { + n[1].f = u; + } + if (ctx->ExecuteFlag) { + (*ctx->Exec.EvalCoord1f)( ctx, u ); + } +} + + +void gl_save_EvalCoord2f( GLcontext *ctx, GLfloat u, GLfloat v ) +{ + Node *n = alloc_instruction( ctx, OPCODE_EVALCOORD2, 2 ); + if (n) { + n[1].f = u; + n[2].f = v; + } + if (ctx->ExecuteFlag) { + (*ctx->Exec.EvalCoord2f)( ctx, u, v ); + } +} + + +void gl_save_EvalMesh1( GLcontext *ctx, + GLenum mode, GLint i1, GLint i2 ) +{ + Node *n = alloc_instruction( ctx, OPCODE_EVALMESH1, 3 ); + if (n) { + n[1].e = mode; + n[2].i = i1; + n[3].i = i2; + } + if (ctx->ExecuteFlag) { + (*ctx->Exec.EvalMesh1)( ctx, mode, i1, i2 ); + } +} + + +void gl_save_EvalMesh2( GLcontext *ctx, + GLenum mode, GLint i1, GLint i2, GLint j1, GLint j2 ) +{ + Node *n = alloc_instruction( ctx, OPCODE_EVALMESH2, 5 ); + if (n) { + n[1].e = mode; + n[2].i = i1; + n[3].i = i2; + n[4].i = j1; + n[5].i = j2; + } + if (ctx->ExecuteFlag) { + (*ctx->Exec.EvalMesh2)( ctx, mode, i1, i2, j1, j2 ); + } +} + + +void gl_save_EvalPoint1( GLcontext *ctx, GLint i ) +{ + Node *n = alloc_instruction( ctx, OPCODE_EVALPOINT1, 1 ); + if (n) { + n[1].i = i; + } + if (ctx->ExecuteFlag) { + (*ctx->Exec.EvalPoint1)( ctx, i ); + } +} + + +void gl_save_EvalPoint2( GLcontext *ctx, GLint i, GLint j ) +{ + Node *n = alloc_instruction( ctx, OPCODE_EVALPOINT2, 2 ); + if (n) { + n[1].i = i; + n[2].i = j; + } + if (ctx->ExecuteFlag) { + (*ctx->Exec.EvalPoint2)( ctx, i, j ); + } +} + + +void gl_save_Fogfv( GLcontext *ctx, GLenum pname, const GLfloat *params ) +{ + Node *n = alloc_instruction( ctx, OPCODE_FOG, 5 ); + if (n) { + n[1].e = pname; + n[2].f = params[0]; + n[3].f = params[1]; + n[4].f = params[2]; + n[5].f = params[3]; + } + if (ctx->ExecuteFlag) { + (*ctx->Exec.Fogfv)( ctx, pname, params ); + } +} + + +void gl_save_FrontFace( GLcontext *ctx, GLenum mode ) +{ + Node *n = alloc_instruction( ctx, OPCODE_FRONT_FACE, 1 ); + if (n) { + n[1].e = mode; + } + if (ctx->ExecuteFlag) { + (*ctx->Exec.FrontFace)( ctx, mode ); + } +} + + +void gl_save_Frustum( GLcontext *ctx, GLdouble left, GLdouble right, + GLdouble bottom, GLdouble top, + GLdouble nearval, GLdouble farval ) +{ + Node *n = alloc_instruction( ctx, OPCODE_FRUSTUM, 6 ); + if (n) { + n[1].f = left; + n[2].f = right; + n[3].f = bottom; + n[4].f = top; + n[5].f = nearval; + n[6].f = farval; + } + if (ctx->ExecuteFlag) { + (*ctx->Exec.Frustum)( ctx, left, right, bottom, top, nearval, farval ); + } +} + + +void gl_save_Hint( GLcontext *ctx, GLenum target, GLenum mode ) +{ + Node *n = alloc_instruction( ctx, OPCODE_HINT, 2 ); + if (n) { + n[1].e = target; + n[2].e = mode; + } + if (ctx->ExecuteFlag) { + (*ctx->Exec.Hint)( ctx, target, mode ); + } +} + + +void gl_save_Indexi( GLcontext *ctx, GLint index ) +{ + Node *n = alloc_instruction( ctx, OPCODE_INDEX, 1 ); + if (n) { + n[1].i = index; + } + if (ctx->ExecuteFlag) { + (*ctx->Exec.Indexi)( ctx, index ); + } +} + + +void gl_save_Indexf( GLcontext *ctx, GLfloat index ) +{ + Node *n = alloc_instruction( ctx, OPCODE_INDEX, 1 ); + if (n) { + n[1].i = (GLint) index; + } + if (ctx->ExecuteFlag) { + (*ctx->Exec.Indexf)( ctx,index ); + } +} + + +void gl_save_IndexMask( GLcontext *ctx, GLuint mask ) +{ + Node *n = alloc_instruction( ctx, OPCODE_INDEX_MASK, 1 ); + if (n) { + n[1].ui = mask; + } + if (ctx->ExecuteFlag) { + (*ctx->Exec.IndexMask)( ctx, mask ); + } +} + + +void gl_save_InitNames( GLcontext *ctx ) +{ + (void) alloc_instruction( ctx, OPCODE_INIT_NAMES, 0 ); + if (ctx->ExecuteFlag) { + (*ctx->Exec.InitNames)( ctx ); + } +} + + +void gl_save_Lightfv( GLcontext *ctx, GLenum light, GLenum pname, + const GLfloat *params, GLint numparams ) +{ + Node *n = alloc_instruction( ctx, OPCODE_LIGHT, 6 ); + if (OPCODE_LIGHT) { + GLint i; + n[1].e = light; + n[2].e = pname; + for (i=0;iExecuteFlag) { + (*ctx->Exec.Lightfv)( ctx, light, pname, params, numparams ); + } +} + + +void gl_save_LightModelfv( GLcontext *ctx, + GLenum pname, const GLfloat *params ) +{ + Node *n = alloc_instruction( ctx, OPCODE_LIGHT_MODEL, 5 ); + if (n) { + n[1].e = pname; + n[2].f = params[0]; + n[3].f = params[1]; + n[4].f = params[2]; + n[5].f = params[3]; + } + if (ctx->ExecuteFlag) { + (*ctx->Exec.LightModelfv)( ctx, pname, params ); + } +} + + +void gl_save_LineStipple( GLcontext *ctx, GLint factor, GLushort pattern ) +{ + Node *n = alloc_instruction( ctx, OPCODE_LINE_STIPPLE, 2 ); + if (n) { + n[1].i = factor; + n[2].us = pattern; + } + if (ctx->ExecuteFlag) { + (*ctx->Exec.LineStipple)( ctx, factor, pattern ); + } +} + + +void gl_save_LineWidth( GLcontext *ctx, GLfloat width ) +{ + Node *n = alloc_instruction( ctx, OPCODE_LINE_WIDTH, 1 ); + if (n) { + n[1].f = width; + } + if (ctx->ExecuteFlag) { + (*ctx->Exec.LineWidth)( ctx, width ); + } +} + + +void gl_save_ListBase( GLcontext *ctx, GLuint base ) +{ + Node *n = alloc_instruction( ctx, OPCODE_LIST_BASE, 1 ); + if (n) { + n[1].ui = base; + } + if (ctx->ExecuteFlag) { + (*ctx->Exec.ListBase)( ctx, base ); + } +} + + +void gl_save_LoadIdentity( GLcontext *ctx ) +{ + (void) alloc_instruction( ctx, OPCODE_LOAD_IDENTITY, 0 ); + if (ctx->ExecuteFlag) { + (*ctx->Exec.LoadIdentity)( ctx ); + } +} + + +void gl_save_LoadMatrixf( GLcontext *ctx, const GLfloat *m ) +{ + Node *n = alloc_instruction( ctx, OPCODE_LOAD_MATRIX, 16 ); + if (n) { + GLuint i; + for (i=0;i<16;i++) { + n[1+i].f = m[i]; + } + } + if (ctx->ExecuteFlag) { + (*ctx->Exec.LoadMatrixf)( ctx, m ); + } +} + + +void gl_save_LoadName( GLcontext *ctx, GLuint name ) +{ + Node *n = alloc_instruction( ctx, OPCODE_LOAD_NAME, 1 ); + if (n) { + n[1].ui = name; + } + if (ctx->ExecuteFlag) { + (*ctx->Exec.LoadName)( ctx, name ); + } +} + + +void gl_save_LogicOp( GLcontext *ctx, GLenum opcode ) +{ + Node *n = alloc_instruction( ctx, OPCODE_LOGIC_OP, 1 ); + if (n) { + n[1].e = opcode; + } + if (ctx->ExecuteFlag) { + (*ctx->Exec.LogicOp)( ctx, opcode ); + } +} + + +void gl_save_Map1f( GLcontext *ctx, + GLenum target, GLfloat u1, GLfloat u2, GLint stride, + GLint order, const GLfloat *points, GLboolean retain ) +{ + Node *n = alloc_instruction( ctx, OPCODE_MAP1, 6 ); + if (n) { + n[1].e = target; + n[2].f = u1; + n[3].f = u2; + n[4].i = stride; + n[5].i = order; + n[6].data = (void *) points; + } + if (ctx->ExecuteFlag) { + (*ctx->Exec.Map1f)( ctx, target, u1, u2, stride, order, points, GL_TRUE ); + } +} + + +void gl_save_Map2f( GLcontext *ctx, GLenum target, + GLfloat u1, GLfloat u2, GLint ustride, GLint uorder, + GLfloat v1, GLfloat v2, GLint vstride, GLint vorder, + const GLfloat *points, GLboolean retain ) +{ + Node *n = alloc_instruction( ctx, OPCODE_MAP2, 10 ); + if (n) { + n[1].e = target; + n[2].f = u1; + n[3].f = u2; + n[4].f = v1; + n[5].f = v2; + n[6].i = ustride; + n[7].i = vstride; + n[8].i = uorder; + n[9].i = vorder; + n[10].data = (void *) points; + } + if (ctx->ExecuteFlag) { + (*ctx->Exec.Map2f)( ctx, target, + u1, u2, ustride, uorder, + v1, v2, vstride, vorder, points, GL_TRUE ); + } +} + + +void gl_save_MapGrid1f( GLcontext *ctx, GLint un, GLfloat u1, GLfloat u2 ) +{ + Node *n = alloc_instruction( ctx, OPCODE_MAPGRID1, 3 ); + if (n) { + n[1].i = un; + n[2].f = u1; + n[3].f = u2; + } + if (ctx->ExecuteFlag) { + (*ctx->Exec.MapGrid1f)( ctx, un, u1, u2 ); + } +} + + +void gl_save_MapGrid2f( GLcontext *ctx, + GLint un, GLfloat u1, GLfloat u2, + GLint vn, GLfloat v1, GLfloat v2 ) +{ + Node *n = alloc_instruction( ctx, OPCODE_MAPGRID2, 6 ); + if (n) { + n[1].i = un; + n[2].f = u1; + n[3].f = u2; + n[4].i = vn; + n[5].f = v1; + n[6].f = v2; + } + if (ctx->ExecuteFlag) { + (*ctx->Exec.MapGrid2f)( ctx, un, u1, u2, vn, v1, v2 ); + } +} + + +void gl_save_Materialfv( GLcontext *ctx, + GLenum face, GLenum pname, const GLfloat *params ) +{ + Node *n = alloc_instruction( ctx, OPCODE_MATERIAL, 6 ); + if (n) { + n[1].e = face; + n[2].e = pname; + n[3].f = params[0]; + n[4].f = params[1]; + n[5].f = params[2]; + n[6].f = params[3]; + } + if (ctx->ExecuteFlag) { + (*ctx->Exec.Materialfv)( ctx, face, pname, params ); + } +} + + +void gl_save_MatrixMode( GLcontext *ctx, GLenum mode ) +{ + Node *n = alloc_instruction( ctx, OPCODE_MATRIX_MODE, 1 ); + if (n) { + n[1].e = mode; + } + if (ctx->ExecuteFlag) { + (*ctx->Exec.MatrixMode)( ctx, mode ); + } +} + + +void gl_save_MultMatrixf( GLcontext *ctx, const GLfloat *m ) +{ + Node *n = alloc_instruction( ctx, OPCODE_MULT_MATRIX, 16 ); + if (n) { + GLuint i; + for (i=0;i<16;i++) { + n[1+i].f = m[i]; + } + } + if (ctx->ExecuteFlag) { + (*ctx->Exec.MultMatrixf)( ctx, m ); + } +} + + +void gl_save_NewList( GLcontext *ctx, GLuint list, GLenum mode ) +{ + /* It's an error to call this function while building a display list */ + gl_error( ctx, GL_INVALID_OPERATION, "glNewList" ); +} + + +void gl_save_Normal3fv( GLcontext *ctx, const GLfloat norm[3] ) +{ + Node *n = alloc_instruction( ctx, OPCODE_NORMAL, 3 ); + if (n) { + n[1].f = norm[0]; + n[2].f = norm[1]; + n[3].f = norm[2]; + } + if (ctx->ExecuteFlag) { + (*ctx->Exec.Normal3fv)( ctx, norm ); + } +} + + +void gl_save_Normal3f( GLcontext *ctx, GLfloat nx, GLfloat ny, GLfloat nz ) +{ + Node *n = alloc_instruction( ctx, OPCODE_NORMAL, 3 ); + if (n) { + n[1].f = nx; + n[2].f = ny; + n[3].f = nz; + } + if (ctx->ExecuteFlag) { + (*ctx->Exec.Normal3f)( ctx, nx, ny, nz ); + } +} + + +void gl_save_Ortho( GLcontext *ctx, GLdouble left, GLdouble right, + GLdouble bottom, GLdouble top, + GLdouble nearval, GLdouble farval ) +{ + Node *n = alloc_instruction( ctx, OPCODE_ORTHO, 6 ); + if (n) { + n[1].f = left; + n[2].f = right; + n[3].f = bottom; + n[4].f = top; + n[5].f = nearval; + n[6].f = farval; + } + if (ctx->ExecuteFlag) { + (*ctx->Exec.Ortho)( ctx, left, right, bottom, top, nearval, farval ); + } +} + + +void gl_save_PixelMapfv( GLcontext *ctx, + GLenum map, GLint mapsize, const GLfloat *values ) +{ + Node *n = alloc_instruction( ctx, OPCODE_PIXEL_MAP, 3 ); + if (n) { + n[1].e = map; + n[2].i = mapsize; + n[3].data = (void *) malloc( mapsize * sizeof(GLfloat) ); + MEMCPY( n[3].data, (void *) values, mapsize * sizeof(GLfloat) ); + } + if (ctx->ExecuteFlag) { + (*ctx->Exec.PixelMapfv)( ctx, map, mapsize, values ); + } +} + + +void gl_save_PixelTransferf( GLcontext *ctx, GLenum pname, GLfloat param ) +{ + Node *n = alloc_instruction( ctx, OPCODE_PIXEL_TRANSFER, 2 ); + if (n) { + n[1].e = pname; + n[2].f = param; + } + if (ctx->ExecuteFlag) { + (*ctx->Exec.PixelTransferf)( ctx, pname, param ); + } +} + + +void gl_save_PixelZoom( GLcontext *ctx, GLfloat xfactor, GLfloat yfactor ) +{ + Node *n = alloc_instruction( ctx, OPCODE_PIXEL_ZOOM, 2 ); + if (n) { + n[1].f = xfactor; + n[2].f = yfactor; + } + if (ctx->ExecuteFlag) { + (*ctx->Exec.PixelZoom)( ctx, xfactor, yfactor ); + } +} + + +void gl_save_PointSize( GLcontext *ctx, GLfloat size ) +{ + Node *n = alloc_instruction( ctx, OPCODE_POINT_SIZE, 1 ); + if (n) { + n[1].f = size; + } + if (ctx->ExecuteFlag) { + (*ctx->Exec.PointSize)( ctx, size ); + } +} + + +void gl_save_PolygonMode( GLcontext *ctx, GLenum face, GLenum mode ) +{ + Node *n = alloc_instruction( ctx, OPCODE_POLYGON_MODE, 2 ); + if (n) { + n[1].e = face; + n[2].e = mode; + } + if (ctx->ExecuteFlag) { + (*ctx->Exec.PolygonMode)( ctx, face, mode ); + } +} + + +void gl_save_PolygonStipple( GLcontext *ctx, const GLubyte *mask ) +{ + Node *n = alloc_instruction( ctx, OPCODE_POLYGON_STIPPLE, 1 ); + if (n) { + void *data; + n[1].data = malloc( 32 * 4 ); + data = n[1].data; /* This needed for Acorn compiler */ + MEMCPY( data, mask, 32 * 4 ); + } + if (ctx->ExecuteFlag) { + (*ctx->Exec.PolygonStipple)( ctx, mask ); + } +} + + +void gl_save_PolygonOffset( GLcontext *ctx, GLfloat factor, GLfloat units ) +{ + Node *n = alloc_instruction( ctx, OPCODE_POLYGON_OFFSET, 2 ); + if (n) { + n[1].f = factor; + n[2].f = units; + } + if (ctx->ExecuteFlag) { + (*ctx->Exec.PolygonOffset)( ctx, factor, units ); + } +} + + +void gl_save_PopAttrib( GLcontext *ctx ) +{ + (void) alloc_instruction( ctx, OPCODE_POP_ATTRIB, 0 ); + if (ctx->ExecuteFlag) { + (*ctx->Exec.PopAttrib)( ctx ); + } +} + + +void gl_save_PopMatrix( GLcontext *ctx ) +{ + (void) alloc_instruction( ctx, OPCODE_POP_MATRIX, 0 ); + if (ctx->ExecuteFlag) { + (*ctx->Exec.PopMatrix)( ctx ); + } +} + + +void gl_save_PopName( GLcontext *ctx ) +{ + (void) alloc_instruction( ctx, OPCODE_POP_NAME, 0 ); + if (ctx->ExecuteFlag) { + (*ctx->Exec.PopName)( ctx ); + } +} + + +void gl_save_PrioritizeTextures( GLcontext *ctx, + GLsizei num, const GLuint *textures, + const GLclampf *priorities ) +{ + GLint i; + + for (i=0;iExecuteFlag) { + (*ctx->Exec.PrioritizeTextures)( ctx, num, textures, priorities ); + } +} + + +void gl_save_PushAttrib( GLcontext *ctx, GLbitfield mask ) +{ + Node *n = alloc_instruction( ctx, OPCODE_PUSH_ATTRIB, 1 ); + if (n) { + n[1].bf = mask; + } + if (ctx->ExecuteFlag) { + (*ctx->Exec.PushAttrib)( ctx, mask ); + } +} + + +void gl_save_PushMatrix( GLcontext *ctx ) +{ + (void) alloc_instruction( ctx, OPCODE_PUSH_MATRIX, 0 ); + if (ctx->ExecuteFlag) { + (*ctx->Exec.PushMatrix)( ctx ); + } +} + + +void gl_save_PushName( GLcontext *ctx, GLuint name ) +{ + Node *n = alloc_instruction( ctx, OPCODE_PUSH_NAME, 1 ); + if (n) { + n[1].ui = name; + } + if (ctx->ExecuteFlag) { + (*ctx->Exec.PushName)( ctx, name ); + } +} + + +void gl_save_RasterPos4f( GLcontext *ctx, + GLfloat x, GLfloat y, GLfloat z, GLfloat w ) +{ + Node *n = alloc_instruction( ctx, OPCODE_RASTER_POS, 4 ); + if (n) { + n[1].f = x; + n[2].f = y; + n[3].f = z; + n[4].f = w; + } + if (ctx->ExecuteFlag) { + (*ctx->Exec.RasterPos4f)( ctx, x, y, z, w ); + } +} + + +void gl_save_PassThrough( GLcontext *ctx, GLfloat token ) +{ + Node *n = alloc_instruction( ctx, OPCODE_PASSTHROUGH, 1 ); + if (n) { + n[1].f = token; + } + if (ctx->ExecuteFlag) { + (*ctx->Exec.PassThrough)( ctx, token ); + } +} + + +void gl_save_ReadBuffer( GLcontext *ctx, GLenum mode ) +{ + Node *n = alloc_instruction( ctx, OPCODE_READ_BUFFER, 1 ); + if (n) { + n[1].e = mode; + } + if (ctx->ExecuteFlag) { + (*ctx->Exec.ReadBuffer)( ctx, mode ); + } +} + + +void gl_save_Rectf( GLcontext *ctx, + GLfloat x1, GLfloat y1, GLfloat x2, GLfloat y2 ) +{ + Node *n = alloc_instruction( ctx, OPCODE_RECTF, 4 ); + if (n) { + n[1].f = x1; + n[2].f = y1; + n[3].f = x2; + n[4].f = y2; + } + if (ctx->ExecuteFlag) { + (*ctx->Exec.Rectf)( ctx, x1, y1, x2, y2 ); + } +} + + +void gl_save_Rotatef( GLcontext *ctx, GLfloat angle, + GLfloat x, GLfloat y, GLfloat z ) +{ + GLfloat m[16]; + gl_rotation_matrix( angle, x, y, z, m ); + gl_save_MultMatrixf( ctx, m ); /* save and maybe execute */ +} + + +void gl_save_Scalef( GLcontext *ctx, GLfloat x, GLfloat y, GLfloat z ) +{ + Node *n = alloc_instruction( ctx, OPCODE_SCALE, 3 ); + if (n) { + n[1].f = x; + n[2].f = y; + n[3].f = z; + } + if (ctx->ExecuteFlag) { + (*ctx->Exec.Scalef)( ctx, x, y, z ); + } +} + + +void gl_save_Scissor( GLcontext *ctx, + GLint x, GLint y, GLsizei width, GLsizei height ) +{ + Node *n = alloc_instruction( ctx, OPCODE_SCISSOR, 4 ); + if (n) { + n[1].i = x; + n[2].i = y; + n[3].i = width; + n[4].i = height; + } + if (ctx->ExecuteFlag) { + (*ctx->Exec.Scissor)( ctx, x, y, width, height ); + } +} + + +void gl_save_ShadeModel( GLcontext *ctx, GLenum mode ) +{ + Node *n = alloc_instruction( ctx, OPCODE_SHADE_MODEL, 1 ); + if (n) { + n[1].e = mode; + } + if (ctx->ExecuteFlag) { + (*ctx->Exec.ShadeModel)( ctx, mode ); + } +} + + +void gl_save_StencilFunc( GLcontext *ctx, GLenum func, GLint ref, GLuint mask ) +{ + Node *n = alloc_instruction( ctx, OPCODE_STENCIL_FUNC, 3 ); + if (n) { + n[1].e = func; + n[2].i = ref; + n[3].ui = mask; + } + if (ctx->ExecuteFlag) { + (*ctx->Exec.StencilFunc)( ctx, func, ref, mask ); + } +} + + +void gl_save_StencilMask( GLcontext *ctx, GLuint mask ) +{ + Node *n = alloc_instruction( ctx, OPCODE_STENCIL_MASK, 1 ); + if (n) { + n[1].ui = mask; + } + if (ctx->ExecuteFlag) { + (*ctx->Exec.StencilMask)( ctx, mask ); + } +} + + +void gl_save_StencilOp( GLcontext *ctx, + GLenum fail, GLenum zfail, GLenum zpass ) +{ + Node *n = alloc_instruction( ctx, OPCODE_STENCIL_OP, 3 ); + if (n) { + n[1].e = fail; + n[2].e = zfail; + n[3].e = zpass; + } + if (ctx->ExecuteFlag) { + (*ctx->Exec.StencilOp)( ctx, fail, zfail, zpass ); + } +} + + +void gl_save_TexCoord2f( GLcontext *ctx, GLfloat s, GLfloat t ) +{ + Node *n = alloc_instruction( ctx, OPCODE_TEXCOORD2, 2 ); + if (n) { + n[1].f = s; + n[2].f = t; + } + if (ctx->ExecuteFlag) { + (*ctx->Exec.TexCoord2f)( ctx, s, t ); + } +} + + +void gl_save_TexCoord4f( GLcontext *ctx, GLfloat s, GLfloat t, + GLfloat r, GLfloat q ) +{ + Node *n = alloc_instruction( ctx, OPCODE_TEXCOORD4, 4 ); + if (n) { + n[1].f = s; + n[2].f = t; + n[3].f = r; + n[4].f = q; + } + if (ctx->ExecuteFlag) { + (*ctx->Exec.TexCoord4f)( ctx, s, t, r, q ); + } +} + + +void gl_save_TexEnvfv( GLcontext *ctx, + GLenum target, GLenum pname, const GLfloat *params ) +{ + Node *n = alloc_instruction( ctx, OPCODE_TEXENV, 6 ); + if (n) { + n[1].e = target; + n[2].e = pname; + n[3].f = params[0]; + n[4].f = params[1]; + n[5].f = params[2]; + n[6].f = params[3]; + } + if (ctx->ExecuteFlag) { + (*ctx->Exec.TexEnvfv)( ctx, target, pname, params ); + } +} + + +void gl_save_TexGenfv( GLcontext *ctx, + GLenum coord, GLenum pname, const GLfloat *params ) +{ + Node *n = alloc_instruction( ctx, OPCODE_TEXGEN, 6 ); + if (n) { + n[1].e = coord; + n[2].e = pname; + n[3].f = params[0]; + n[4].f = params[1]; + n[5].f = params[2]; + n[6].f = params[3]; + } + if (ctx->ExecuteFlag) { + (*ctx->Exec.TexGenfv)( ctx, coord, pname, params ); + } +} + + +void gl_save_TexParameterfv( GLcontext *ctx, GLenum target, + GLenum pname, const GLfloat *params ) +{ + Node *n = alloc_instruction( ctx, OPCODE_TEXPARAMETER, 6 ); + if (n) { + n[1].e = target; + n[2].e = pname; + n[3].f = params[0]; + n[4].f = params[1]; + n[5].f = params[2]; + n[6].f = params[3]; + } + if (ctx->ExecuteFlag) { + (*ctx->Exec.TexParameterfv)( ctx, target, pname, params ); + } +} + + +void gl_save_TexImage1D( GLcontext *ctx, GLenum target, + GLint level, GLint components, + GLsizei width, GLint border, + GLenum format, GLenum type, + struct gl_image *teximage ) +{ + Node *n = alloc_instruction( ctx, OPCODE_TEX_IMAGE1D, 8 ); + if (n) { + n[1].e = target; + n[2].i = level; + n[3].i = components; + n[4].i = (GLint) width; + n[5].i = border; + n[6].e = format; + n[7].e = type; + n[8].data = teximage; + if (teximage) { + /* this prevents gl_TexImage2D() from freeing the image */ + teximage->RefCount = 1; + } + } + if (ctx->ExecuteFlag) { + (*ctx->Exec.TexImage1D)( ctx, target, level, components, width, + border, format, type, teximage ); + } +} + + +void gl_save_TexImage2D( GLcontext *ctx, GLenum target, + GLint level, GLint components, + GLsizei width, GLsizei height, GLint border, + GLenum format, GLenum type, + struct gl_image *teximage ) +{ + Node *n = alloc_instruction( ctx, OPCODE_TEX_IMAGE2D, 9 ); + if (n) { + n[1].e = target; + n[2].i = level; + n[3].i = components; + n[4].i = (GLint) width; + n[5].i = (GLint) height; + n[6].i = border; + n[7].e = format; + n[8].e = type; + n[9].data = teximage; + if (teximage) { + /* this prevents gl_TexImage2D() from freeing the image */ + teximage->RefCount = 1; + } + } + if (ctx->ExecuteFlag) { + (*ctx->Exec.TexImage2D)( ctx, target, level, components, width, + height, border, format, type, teximage ); + } +} + + +void gl_save_TexSubImage1D( GLcontext *ctx, + GLenum target, GLint level, GLint xoffset, + GLsizei width, GLenum format, GLenum type, + struct gl_image *image ) +{ + Node *n = alloc_instruction( ctx, OPCODE_TEX_SUB_IMAGE1D, 7 ); + if (n) { + n[1].e = target; + n[2].i = level; + n[3].i = xoffset; + n[4].i = (GLint) width; + n[5].e = format; + n[6].e = type; + n[7].data = image; + if (image) + image->RefCount = 1; + } + if (ctx->ExecuteFlag) { + (*ctx->Exec.TexSubImage1D)( ctx, target, level, xoffset, width, + format, type, image ); + } +} + + +void gl_save_TexSubImage2D( GLcontext *ctx, + GLenum target, GLint level, + GLint xoffset, GLint yoffset, + GLsizei width, GLsizei height, + GLenum format, GLenum type, + struct gl_image *image ) +{ + Node *n = alloc_instruction( ctx, OPCODE_TEX_SUB_IMAGE2D, 9 ); + if (n) { + n[1].e = target; + n[2].i = level; + n[3].i = xoffset; + n[4].i = yoffset; + n[5].i = (GLint) width; + n[6].i = (GLint) height; + n[7].e = format; + n[8].e = type; + n[9].data = image; + if (image) + image->RefCount = 1; + } + if (ctx->ExecuteFlag) { + (*ctx->Exec.TexSubImage2D)( ctx, target, level, xoffset, yoffset, + width, height, format, type, image ); + } +} + + +void gl_save_Translatef( GLcontext *ctx, GLfloat x, GLfloat y, GLfloat z ) +{ + Node *n = alloc_instruction( ctx, OPCODE_TRANSLATE, 3 ); + if (n) { + n[1].f = x; + n[2].f = y; + n[3].f = z; + } + if (ctx->ExecuteFlag) { + (*ctx->Exec.Translatef)( ctx, x, y, z ); + } +} + + +void gl_save_Vertex2f( GLcontext *ctx, GLfloat x, GLfloat y ) +{ + Node *n = alloc_instruction( ctx, OPCODE_VERTEX2, 2 ); + if (n) { + n[1].f = x; + n[2].f = y; + } + if (ctx->ExecuteFlag) { + (*ctx->Exec.Vertex2f)( ctx, x, y ); + } +} + + +void gl_save_Vertex3f( GLcontext *ctx, GLfloat x, GLfloat y, GLfloat z ) +{ + Node *n = alloc_instruction( ctx, OPCODE_VERTEX3, 3 ); + if (n) { + n[1].f = x; + n[2].f = y; + n[3].f = z; + } + if (ctx->ExecuteFlag) { + (*ctx->Exec.Vertex3f)( ctx, x, y, z ); + } +} + + +void gl_save_Vertex4f( GLcontext *ctx, + GLfloat x, GLfloat y, GLfloat z, GLfloat w ) +{ + Node *n = alloc_instruction( ctx, OPCODE_VERTEX4, 4 ); + if (n) { + n[1].f = x; + n[2].f = y; + n[3].f = z; + n[4].f = w; + } + if (ctx->ExecuteFlag) { + (*ctx->Exec.Vertex4f)( ctx, x, y, z, w ); + } +} + + +void gl_save_Vertex3fv( GLcontext *ctx, const GLfloat v[3] ) +{ + Node *n = alloc_instruction( ctx, OPCODE_VERTEX3, 3 ); + if (n) { + n[1].f = v[0]; + n[2].f = v[1]; + n[3].f = v[2]; + } + if (ctx->ExecuteFlag) { + (*ctx->Exec.Vertex3fv)( ctx, v ); + } +} + + +void gl_save_Viewport( GLcontext *ctx, + GLint x, GLint y, GLsizei width, GLsizei height ) +{ + Node *n = alloc_instruction( ctx, OPCODE_VIEWPORT, 4 ); + if (n) { + n[1].i = x; + n[2].i = y; + n[3].i = (GLint) width; + n[4].i = (GLint) height; + } + if (ctx->ExecuteFlag) { + (*ctx->Exec.Viewport)( ctx, x, y, width, height ); + } +} + + +/**********************************************************************/ +/* Display list execution */ +/**********************************************************************/ + + +/* + * Execute a display list. Note that the ListBase offset must have already + * been added before calling this function. I.e. the list argument is + * the absolute list number, not relative to ListBase. + * Input: list - display list number + */ +static void execute_list( GLcontext *ctx, GLuint list ) +{ + Node *n; + GLboolean done; + OpCode opcode; + + if (!gl_IsList(ctx,list)) + return; + + ctx->CallDepth++; + + n = (Node *) HashLookup(ctx->Shared->DisplayList, list); + + done = GL_FALSE; + while (!done) { + opcode = n[0].opcode; + + switch (opcode) { + /* Frequently called functions: */ + case OPCODE_VERTEX2: + (*ctx->Exec.Vertex2f)( ctx, n[1].f, n[2].f ); + break; + case OPCODE_VERTEX3: + (*ctx->Exec.Vertex3f)( ctx, n[1].f, n[2].f, n[3].f ); + break; + case OPCODE_VERTEX4: + (*ctx->Exec.Vertex4f)( ctx, n[1].f, n[2].f, n[3].f, n[4].f ); + break; + case OPCODE_NORMAL: + ctx->Current.Normal[0] = n[1].f; + ctx->Current.Normal[1] = n[2].f; + ctx->Current.Normal[2] = n[3].f; + ctx->VB->MonoNormal = GL_FALSE; + break; + case OPCODE_COLOR_4UB: + (*ctx->Exec.Color4ub)( ctx, n[1].ub, n[2].ub, n[3].ub, n[4].ub ); + break; + case OPCODE_COLOR_3F: + (*ctx->Exec.Color3f)( ctx, n[1].f, n[2].f, n[3].f ); + break; + case OPCODE_COLOR_4F: + (*ctx->Exec.Color4f)( ctx, n[1].f, n[2].f, n[3].f, n[4].f ); + break; + case OPCODE_INDEX: + ctx->Current.Index = n[1].ui; + ctx->VB->MonoColor = GL_FALSE; + break; + case OPCODE_BEGIN: + gl_Begin( ctx, n[1].e ); + break; + case OPCODE_END: + gl_End( ctx ); + break; + case OPCODE_TEXCOORD2: + ctx->Current.TexCoord[0] = n[1].f; + ctx->Current.TexCoord[1] = n[2].f; + if (ctx->VB->TexCoordSize==4) { + ctx->Current.TexCoord[2] = 0.0F; + ctx->Current.TexCoord[3] = 1.0F; + } + break; + case OPCODE_TEXCOORD4: + ctx->Current.TexCoord[0] = n[1].f; + ctx->Current.TexCoord[1] = n[2].f; + ctx->Current.TexCoord[2] = n[3].f; + ctx->Current.TexCoord[3] = n[4].f; + if (ctx->VB->TexCoordSize==2) { + /* Switch to 4-component texcoords */ + ctx->VB->TexCoordSize = 4; + gl_set_vertex_function(ctx); + } + break; + + /* Everything Else: */ + case OPCODE_ACCUM: + gl_Accum( ctx, n[1].e, n[2].f ); + break; + case OPCODE_ALPHA_FUNC: + gl_AlphaFunc( ctx, n[1].e, n[2].f ); + break; + case OPCODE_BIND_TEXTURE: + gl_BindTexture( ctx, n[1].e, n[2].ui ); + break; + case OPCODE_BITMAP: + gl_Bitmap( ctx, (GLsizei) n[1].i, (GLsizei) n[2].i, + n[3].f, n[4].f, + n[5].f, n[6].f, + (struct gl_image *) n[7].data ); + break; + case OPCODE_BLEND_FUNC: + gl_BlendFunc( ctx, n[1].e, n[2].e ); + break; + case OPCODE_CALL_LIST: + /* Generated by glCallList(), don't add ListBase */ + if (ctx->CallDepthCallDepthList.ListBase + n[1].ui ); + } + break; + case OPCODE_CLEAR: + gl_Clear( ctx, n[1].bf ); + break; + case OPCODE_CLEAR_COLOR: + gl_ClearColor( ctx, n[1].f, n[2].f, n[3].f, n[4].f ); + break; + case OPCODE_CLEAR_ACCUM: + gl_ClearAccum( ctx, n[1].f, n[2].f, n[3].f, n[4].f ); + break; + case OPCODE_CLEAR_DEPTH: + gl_ClearDepth( ctx, (GLclampd) n[1].f ); + break; + case OPCODE_CLEAR_INDEX: + gl_ClearIndex( ctx, n[1].ui ); + break; + case OPCODE_CLEAR_STENCIL: + gl_ClearStencil( ctx, n[1].i ); + break; + case OPCODE_CLIP_PLANE: + { + GLfloat equ[4]; + equ[0] = n[2].f; + equ[1] = n[3].f; + equ[2] = n[4].f; + equ[3] = n[5].f; + gl_ClipPlane( ctx, n[1].e, equ ); + } + break; + case OPCODE_COLOR_MASK: + gl_ColorMask( ctx, n[1].b, n[2].b, n[3].b, n[4].b ); + break; + case OPCODE_COLOR_MATERIAL: + gl_ColorMaterial( ctx, n[1].e, n[2].e ); + break; + case OPCODE_COLOR_TABLE: + gl_ColorTable( ctx, n[1].e, n[2].e, (struct gl_image *) n[3].data); + break; + case OPCODE_COLOR_SUB_TABLE: + gl_ColorSubTable( ctx, n[1].e, n[2].i, + (struct gl_image *) n[3].data); + break; + case OPCODE_COPY_PIXELS: + gl_CopyPixels( ctx, n[1].i, n[2].i, + (GLsizei) n[3].i, (GLsizei) n[4].i, n[5].e ); + break; + case OPCODE_COPY_TEX_IMAGE1D: + gl_CopyTexImage1D( ctx, n[1].e, n[2].i, n[3].e, n[4].i, + n[5].i, n[6].i, n[7].i ); + break; + case OPCODE_COPY_TEX_IMAGE2D: + gl_CopyTexImage2D( ctx, n[1].e, n[2].i, n[3].e, n[4].i, + n[5].i, n[6].i, n[7].i, n[8].i ); + break; + case OPCODE_COPY_TEX_SUB_IMAGE1D: + gl_CopyTexSubImage1D( ctx, n[1].e, n[2].i, n[3].i, n[4].i, + n[5].i, n[6].i ); + break; + case OPCODE_COPY_TEX_SUB_IMAGE2D: + gl_CopyTexSubImage2D( ctx, n[1].e, n[2].i, n[3].i, n[4].i, + n[5].i, n[6].i, n[7].i, n[8].i ); + break; + case OPCODE_CULL_FACE: + gl_CullFace( ctx, n[1].e ); + break; + case OPCODE_DEPTH_FUNC: + gl_DepthFunc( ctx, n[1].e ); + break; + case OPCODE_DEPTH_MASK: + gl_DepthMask( ctx, n[1].b ); + break; + case OPCODE_DEPTH_RANGE: + gl_DepthRange( ctx, (GLclampd) n[1].f, (GLclampd) n[2].f ); + break; + case OPCODE_DISABLE: + gl_Disable( ctx, n[1].e ); + break; + case OPCODE_DRAW_BUFFER: + gl_DrawBuffer( ctx, n[1].e ); + break; + case OPCODE_DRAW_PIXELS: + gl_DrawPixels( ctx, (GLsizei) n[1].i, (GLsizei) n[2].i, + n[3].e, n[4].e, n[5].data ); + break; + case OPCODE_EDGE_FLAG: + ctx->Current.EdgeFlag = n[1].b; + break; + case OPCODE_ENABLE: + gl_Enable( ctx, n[1].e ); + break; + case OPCODE_EVALCOORD1: + gl_EvalCoord1f( ctx, n[1].f ); + break; + case OPCODE_EVALCOORD2: + gl_EvalCoord2f( ctx, n[1].f, n[2].f ); + break; + case OPCODE_EVALMESH1: + gl_EvalMesh1( ctx, n[1].e, n[2].i, n[3].i ); + break; + case OPCODE_EVALMESH2: + gl_EvalMesh2( ctx, n[1].e, n[2].i, n[3].i, n[4].i, n[5].i ); + break; + case OPCODE_EVALPOINT1: + gl_EvalPoint1( ctx, n[1].i ); + break; + case OPCODE_EVALPOINT2: + gl_EvalPoint2( ctx, n[1].i, n[2].i ); + break; + case OPCODE_FOG: + { + GLfloat p[4]; + p[0] = n[2].f; + p[1] = n[3].f; + p[2] = n[4].f; + p[3] = n[5].f; + gl_Fogfv( ctx, n[1].e, p ); + } + break; + case OPCODE_FRONT_FACE: + gl_FrontFace( ctx, n[1].e ); + break; + case OPCODE_FRUSTUM: + gl_Frustum( ctx, n[1].f, n[2].f, n[3].f, n[4].f, n[5].f, n[6].f ); + break; + case OPCODE_HINT: + gl_Hint( ctx, n[1].e, n[2].e ); + break; + case OPCODE_INDEX_MASK: + gl_IndexMask( ctx, n[1].ui ); + break; + case OPCODE_INIT_NAMES: + gl_InitNames( ctx ); + break; + case OPCODE_LIGHT: + { + GLfloat p[4]; + p[0] = n[3].f; + p[1] = n[4].f; + p[2] = n[5].f; + p[3] = n[6].f; + gl_Lightfv( ctx, n[1].e, n[2].e, p, 4 ); + } + break; + case OPCODE_LIGHT_MODEL: + { + GLfloat p[4]; + p[0] = n[2].f; + p[1] = n[3].f; + p[2] = n[4].f; + p[3] = n[5].f; + gl_LightModelfv( ctx, n[1].e, p ); + } + break; + case OPCODE_LINE_STIPPLE: + gl_LineStipple( ctx, n[1].i, n[2].us ); + break; + case OPCODE_LINE_WIDTH: + gl_LineWidth( ctx, n[1].f ); + break; + case OPCODE_LIST_BASE: + gl_ListBase( ctx, n[1].ui ); + break; + case OPCODE_LOAD_IDENTITY: + gl_LoadIdentity( ctx ); + break; + case OPCODE_LOAD_MATRIX: + if (sizeof(Node)==sizeof(GLfloat)) { + gl_LoadMatrixf( ctx, &n[1].f ); + } + else { + GLfloat m[16]; + GLuint i; + for (i=0;i<16;i++) { + m[i] = n[1+i].f; + } + gl_LoadMatrixf( ctx, m ); + } + break; + case OPCODE_LOAD_NAME: + gl_LoadName( ctx, n[1].ui ); + break; + case OPCODE_LOGIC_OP: + gl_LogicOp( ctx, n[1].e ); + break; + case OPCODE_MAP1: + gl_Map1f( ctx, n[1].e, n[2].f, n[3].f, + n[4].i, n[5].i, (GLfloat *) n[6].data, GL_TRUE ); + break; + case OPCODE_MAP2: + gl_Map2f( ctx, n[1].e, + n[2].f, n[3].f, /* u1, u2 */ + n[6].i, n[8].i, /* ustride, uorder */ + n[4].f, n[5].f, /* v1, v2 */ + n[7].i, n[9].i, /* vstride, vorder */ + (GLfloat *) n[10].data, + GL_TRUE); + break; + case OPCODE_MAPGRID1: + gl_MapGrid1f( ctx, n[1].i, n[2].f, n[3].f ); + break; + case OPCODE_MAPGRID2: + gl_MapGrid2f( ctx, n[1].i, n[2].f, n[3].f, n[4].i, n[5].f, n[6].f); + break; + case OPCODE_MATERIAL: + { + GLfloat params[4]; + params[0] = n[3].f; + params[1] = n[4].f; + params[2] = n[5].f; + params[3] = n[6].f; + gl_Materialfv( ctx, n[1].e, n[2].e, params ); + } + break; + case OPCODE_MATRIX_MODE: + gl_MatrixMode( ctx, n[1].e ); + break; + case OPCODE_MULT_MATRIX: + if (sizeof(Node)==sizeof(GLfloat)) { + gl_MultMatrixf( ctx, &n[1].f ); + } + else { + GLfloat m[16]; + GLuint i; + for (i=0;i<16;i++) { + m[i] = n[1+i].f; + } + gl_MultMatrixf( ctx, m ); + } + break; + case OPCODE_ORTHO: + gl_Ortho( ctx, n[1].f, n[2].f, n[3].f, n[4].f, n[5].f, n[6].f ); + break; + case OPCODE_PASSTHROUGH: + gl_PassThrough( ctx, n[1].f ); + break; + case OPCODE_PIXEL_MAP: + gl_PixelMapfv( ctx, n[1].e, n[2].i, (GLfloat *) n[3].data ); + break; + case OPCODE_PIXEL_TRANSFER: + gl_PixelTransferf( ctx, n[1].e, n[2].f ); + break; + case OPCODE_PIXEL_ZOOM: + gl_PixelZoom( ctx, n[1].f, n[2].f ); + break; + case OPCODE_POINT_SIZE: + gl_PointSize( ctx, n[1].f ); + break; + case OPCODE_POLYGON_MODE: + gl_PolygonMode( ctx, n[1].e, n[2].e ); + break; + case OPCODE_POLYGON_STIPPLE: + gl_PolygonStipple( ctx, (GLubyte *) n[1].data ); + break; + case OPCODE_POLYGON_OFFSET: + gl_PolygonOffset( ctx, n[1].f, n[2].f ); + break; + case OPCODE_POP_ATTRIB: + gl_PopAttrib( ctx ); + break; + case OPCODE_POP_MATRIX: + gl_PopMatrix( ctx ); + break; + case OPCODE_POP_NAME: + gl_PopName( ctx ); + break; + case OPCODE_PRIORITIZE_TEXTURE: + gl_PrioritizeTextures( ctx, 1, &n[1].ui, &n[2].f ); + break; + case OPCODE_PUSH_ATTRIB: + gl_PushAttrib( ctx, n[1].bf ); + break; + case OPCODE_PUSH_MATRIX: + gl_PushMatrix( ctx ); + break; + case OPCODE_PUSH_NAME: + gl_PushName( ctx, n[1].ui ); + break; + case OPCODE_RASTER_POS: + gl_RasterPos4f( ctx, n[1].f, n[2].f, n[3].f, n[4].f ); + break; + case OPCODE_READ_BUFFER: + gl_ReadBuffer( ctx, n[1].e ); + break; + case OPCODE_RECTF: + gl_Rectf( ctx, n[1].f, n[2].f, n[3].f, n[4].f ); + break; + case OPCODE_SCALE: + gl_Scalef( ctx, n[1].f, n[2].f, n[3].f ); + break; + case OPCODE_SCISSOR: + gl_Scissor( ctx, n[1].i, n[2].i, n[3].i, n[4].i ); + break; + case OPCODE_SHADE_MODEL: + gl_ShadeModel( ctx, n[1].e ); + break; + case OPCODE_STENCIL_FUNC: + gl_StencilFunc( ctx, n[1].e, n[2].i, n[3].ui ); + break; + case OPCODE_STENCIL_MASK: + gl_StencilMask( ctx, n[1].ui ); + break; + case OPCODE_STENCIL_OP: + gl_StencilOp( ctx, n[1].e, n[2].e, n[3].e ); + break; + case OPCODE_TEXENV: + { + GLfloat params[4]; + params[0] = n[3].f; + params[1] = n[4].f; + params[2] = n[5].f; + params[3] = n[6].f; + gl_TexEnvfv( ctx, n[1].e, n[2].e, params ); + } + break; + case OPCODE_TEXGEN: + { + GLfloat params[4]; + params[0] = n[3].f; + params[1] = n[4].f; + params[2] = n[5].f; + params[3] = n[6].f; + gl_TexGenfv( ctx, n[1].e, n[2].e, params ); + } + break; + case OPCODE_TEXPARAMETER: + { + GLfloat params[4]; + params[0] = n[3].f; + params[1] = n[4].f; + params[2] = n[5].f; + params[3] = n[6].f; + gl_TexParameterfv( ctx, n[1].e, n[2].e, params ); + } + break; + case OPCODE_TEX_IMAGE1D: + gl_TexImage1D( ctx, + n[1].e, /* target */ + n[2].i, /* level */ + n[3].i, /* components */ + n[4].i, /* width */ + n[5].e, /* border */ + n[6].e, /* format */ + n[7].e, /* type */ + (struct gl_image *) n[8].data ); + break; + case OPCODE_TEX_IMAGE2D: + gl_TexImage2D( ctx, + n[1].e, /* target */ + n[2].i, /* level */ + n[3].i, /* components */ + n[4].i, /* width */ + n[5].i, /* height */ + n[6].e, /* border */ + n[7].e, /* format */ + n[8].e, /* type */ + (struct gl_image *) n[9].data ); + break; + case OPCODE_TEX_SUB_IMAGE1D: + gl_TexSubImage1D( ctx, n[1].e, n[2].i, n[3].i, n[4].i, n[5].e, + n[6].e, (struct gl_image *) n[7].data ); + break; + case OPCODE_TEX_SUB_IMAGE2D: + gl_TexSubImage2D( ctx, n[1].e, n[2].i, n[3].i, n[4].i, n[5].e, + n[6].i, n[7].e, n[8].e, + (struct gl_image *) n[9].data ); + break; + case OPCODE_TRANSLATE: + gl_Translatef( ctx, n[1].f, n[2].f, n[3].f ); + break; + case OPCODE_VIEWPORT: + gl_Viewport( ctx, + n[1].i, n[2].i, (GLsizei) n[3].i, (GLsizei) n[4].i ); + break; + case OPCODE_CONTINUE: + n = (Node *) n[1].next; + break; + case OPCODE_END_OF_LIST: + done = GL_TRUE; + break; + default: + { + char msg[1000]; + sprintf(msg, "Error in execute_list: opcode=%d", (int) opcode); + gl_problem( ctx, msg ); + } + done = GL_TRUE; + } + + /* increment n to point to next compiled command */ + if (opcode!=OPCODE_CONTINUE) { + n += InstSize[opcode]; + } + + } + ctx->CallDepth--; +} + + + +/**********************************************************************/ +/* GL functions */ +/**********************************************************************/ + + + +/* + * Test if a display list number is valid. + */ +GLboolean gl_IsList( GLcontext *ctx, GLuint list ) +{ + if (list > 0 && HashLookup(ctx->Shared->DisplayList, list)) { + return GL_TRUE; + } + else { + return GL_FALSE; + } +} + + + +/* + * Delete a sequence of consecutive display lists. + */ +void gl_DeleteLists( GLcontext *ctx, GLuint list, GLsizei range ) +{ + GLuint i; + + if (INSIDE_BEGIN_END(ctx)) { + gl_error( ctx, GL_INVALID_OPERATION, "glDeleteLists" ); + return; + } + if (range<0) { + gl_error( ctx, GL_INVALID_VALUE, "glDeleteLists" ); + return; + } + for (i=list;iShared->DisplayList, range); + if (base) { + /* reserve the list IDs by with empty/dummy lists */ + GLuint i; + for (i=0; iShared->DisplayList, base+i, make_empty_list()); + } + } + return base; +} + + + +/* + * Begin a new display list. + */ +void gl_NewList( GLcontext *ctx, GLuint list, GLenum mode ) +{ + if (INSIDE_BEGIN_END(ctx)) { + gl_error( ctx, GL_INVALID_OPERATION, "glNewList" ); + return; + } + if (list==0) { + gl_error( ctx, GL_INVALID_VALUE, "glNewList" ); + return; + } + if (mode!=GL_COMPILE && mode!=GL_COMPILE_AND_EXECUTE) { + gl_error( ctx, GL_INVALID_ENUM, "glNewList" ); + return; + } + if (ctx->CurrentListPtr) { + /* already compiling a display list */ + gl_error( ctx, GL_INVALID_OPERATION, "glNewList" ); + return; + } + + /* Allocate new display list */ + ctx->CurrentListNum = list; + ctx->CurrentListPtr = ctx->CurrentBlock = (Node *) malloc( sizeof(Node) * BLOCK_SIZE ); + ctx->CurrentPos = 0; + + ctx->CompileFlag = GL_TRUE; + if (mode==GL_COMPILE) { + ctx->ExecuteFlag = GL_FALSE; + } + else { + /* Compile and execute */ + ctx->ExecuteFlag = GL_TRUE; + } + + ctx->API = ctx->Save; /* Switch the API function pointers */ +} + + + +/* + * End definition of current display list. + */ +void gl_EndList( GLcontext *ctx ) +{ + Node *n; + + /* Check that a list is under construction */ + if (!ctx->CurrentListPtr) { + gl_error( ctx, GL_INVALID_OPERATION, "glEndList" ); + return; + } + + n = alloc_instruction( ctx, OPCODE_END_OF_LIST, 0 ); + (void)n; + + /* Destroy old list, if any */ + gl_destroy_list(ctx, ctx->CurrentListNum); + /* Install the list */ + HashInsert(ctx->Shared->DisplayList, ctx->CurrentListNum, ctx->CurrentListPtr); + + ctx->CurrentListNum = 0; + ctx->CurrentListPtr = NULL; + ctx->ExecuteFlag = GL_TRUE; + ctx->CompileFlag = GL_FALSE; + + ctx->API = ctx->Exec; /* Switch the API function pointers */ +} + + + +void gl_CallList( GLcontext *ctx, GLuint list ) +{ + /* VERY IMPORTANT: Save the CompileFlag status, turn it off, */ + /* execute the display list, and restore the CompileFlag. */ + GLboolean save_compile_flag; + save_compile_flag = ctx->CompileFlag; + ctx->CompileFlag = GL_FALSE; + execute_list( ctx, list ); + ctx->CompileFlag = save_compile_flag; +} + + + +/* + * Execute glCallLists: call multiple display lists. + */ +void gl_CallLists( GLcontext *ctx, + GLsizei n, GLenum type, const GLvoid *lists ) +{ + GLuint i, list; + GLboolean save_compile_flag; + + /* Save the CompileFlag status, turn it off, execute display list, + * and restore the CompileFlag. + */ + save_compile_flag = ctx->CompileFlag; + ctx->CompileFlag = GL_FALSE; + + for (i=0;iList.ListBase + list ); + } + + ctx->CompileFlag = save_compile_flag; +} + + + +/* + * Set the offset added to list numbers in glCallLists. + */ +void gl_ListBase( GLcontext *ctx, GLuint base ) +{ + if (INSIDE_BEGIN_END(ctx)) { + gl_error( ctx, GL_INVALID_OPERATION, "glListBase" ); + return; + } + ctx->List.ListBase = base; +} diff --git a/dll/opengl/mesa/dlist.h b/dll/opengl/mesa/dlist.h new file mode 100644 index 00000000000..4c920e80500 --- /dev/null +++ b/dll/opengl/mesa/dlist.h @@ -0,0 +1,432 @@ +/* $Id: dlist.h,v 1.15 1997/12/06 18:06:50 brianp Exp $ */ + +/* + * Mesa 3-D graphics library + * Version: 2.5 + * Copyright (C) 1995-1997 Brian Paul + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Library General Public + * License as published by the Free Software Foundation; either + * version 2 of the License, or (at your option) any later version. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Library General Public License for more details. + * + * You should have received a copy of the GNU Library General Public + * License along with this library; if not, write to the Free + * Software Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. + */ + + +/* + * $Log: dlist.h,v $ + * Revision 1.15 1997/12/06 18:06:50 brianp + * moved several static display list vars into GLcontext + * + * Revision 1.14 1997/10/29 01:29:09 brianp + * added GL_EXT_point_parameters extension from Daniel Barrero + * + * Revision 1.13 1997/09/27 00:13:44 brianp + * added GL_EXT_paletted_texture extension + * + * Revision 1.12 1997/06/20 01:57:57 brianp + * added gl_save_Color4ubv() + * + * Revision 1.11 1997/06/06 02:59:12 brianp + * added gl_destroy_list() + * + * Revision 1.10 1997/04/24 01:50:53 brianp + * optimized glColor3f, glColor3fv, glColor4fv + * + * Revision 1.9 1997/04/21 01:21:33 brianp + * added gl_save_Rectf() + * + * Revision 1.8 1997/04/20 16:18:15 brianp + * added glOrtho and glFrustum API pointers + * + * Revision 1.7 1997/04/16 23:55:33 brianp + * added optimized glTexCoord2f code + * + * Revision 1.6 1997/04/14 22:18:23 brianp + * added optimized glVertex3fv code + * + * Revision 1.5 1997/04/07 02:58:49 brianp + * added gl_save_Vertex[23]f() and related code + * + * Revision 1.4 1997/04/01 04:26:02 brianp + * added code for glLoadIdentity(), changed #include's + * + * Revision 1.3 1997/02/09 18:50:18 brianp + * added GL_EXT_texture3D support + * + * Revision 1.2 1996/11/07 04:12:45 brianp + * texture images are now gl_image structs, not gl_texture_image structs + * + * Revision 1.1 1996/09/13 01:38:16 brianp + * Initial revision + * + */ + + +#ifndef DLIST_H +#define DLIST_H + + +#include "types.h" + + + +extern void gl_init_lists( void ); + +extern void gl_destroy_list( GLcontext *ctx, GLuint list ); + + + +extern void gl_CallList( GLcontext *ctx, GLuint list ); + +extern void gl_CallLists( GLcontext *ctx, + GLsizei n, GLenum type, const GLvoid *lists ); + +extern void gl_DeleteLists( GLcontext *ctx, GLuint list, GLsizei range ); + +extern void gl_EndList( GLcontext *ctx ); + +extern GLuint gl_GenLists( GLcontext *ctx, GLsizei range ); + +extern GLboolean gl_IsList( GLcontext *ctx, GLuint list ); + +extern void gl_ListBase( GLcontext *ctx, GLuint base ); + +extern void gl_NewList( GLcontext *ctx, GLuint list, GLenum mode ); + + + + +extern void gl_save_Accum( GLcontext *ctx, GLenum op, GLfloat value ); + +extern void gl_save_AlphaFunc( GLcontext *ctx, GLenum func, GLclampf ref ); + +extern void gl_save_BlendFunc( GLcontext *ctx, + GLenum sfactor, GLenum dfactor ); + +extern void gl_save_Begin( GLcontext *ctx, GLenum mode ); + +extern void gl_save_BindTexture( GLcontext *ctx, + GLenum target, GLuint texture ); + +extern void gl_save_Bitmap( GLcontext *ctx, GLsizei width, GLsizei height, + GLfloat xorig, GLfloat yorig, + GLfloat xmove, GLfloat ymove, + const struct gl_image *bitmap ); + +extern void gl_save_CallList( GLcontext *ctx, GLuint list ); + +extern void gl_save_CallLists( GLcontext *ctx, + GLsizei n, GLenum type, const GLvoid *lists ); + +extern void gl_save_Clear( GLcontext *ctx, GLbitfield mask ); + +extern void gl_save_ClearAccum( GLcontext *ctx, GLfloat red, GLfloat green, + GLfloat blue, GLfloat alpha ); + +extern void gl_save_ClearColor( GLcontext *ctx, GLclampf red, GLclampf green, + GLclampf blue, GLclampf alpha ); + +extern void gl_save_ClearDepth( GLcontext *ctx, GLclampd depth ); + +extern void gl_save_ClearIndex( GLcontext *ctx, GLfloat c ); + +extern void gl_save_ClearStencil( GLcontext *ctx, GLint s ); + +extern void gl_save_ClipPlane( GLcontext *ctx, + GLenum plane, const GLfloat *equ ); + +extern void gl_save_Color3f( GLcontext *ctx, GLfloat r, GLfloat g, GLfloat b ); + +extern void gl_save_Color3fv( GLcontext *ctx, const GLfloat *c ); + +extern void gl_save_Color4f( GLcontext *ctx, GLfloat r, GLfloat g, + GLfloat b, GLfloat a ); + +extern void gl_save_Color4fv( GLcontext *ctx, const GLfloat *c ); + +extern void gl_save_Color4ub( GLcontext *ctx, GLubyte r, GLubyte g, + GLubyte b, GLubyte a ); + +extern void gl_save_Color4ubv( GLcontext *ctx, const GLubyte *c ); + +extern void gl_save_ColorMask( GLcontext *ctx, GLboolean red, GLboolean green, + GLboolean blue, GLboolean alpha ); + +extern void gl_save_ColorMaterial( GLcontext *ctx, GLenum face, GLenum mode ); + +extern void gl_save_ColorTable( GLcontext *ctx, GLenum target, + GLenum internalFormat, + struct gl_image *table ); + +extern void gl_save_ColorSubTable( GLcontext *ctx, GLenum target, + GLsizei start, struct gl_image *data ); + +extern void gl_save_CopyPixels( GLcontext *ctx, GLint x, GLint y, + GLsizei width, GLsizei height, GLenum type ); + +extern void gl_save_CopyTexImage1D( GLcontext *ctx, + GLenum target, GLint level, + GLenum internalformat, + GLint x, GLint y, GLsizei width, + GLint border ); + +extern void gl_save_CopyTexImage2D( GLcontext *ctx, + GLenum target, GLint level, + GLenum internalformat, + GLint x, GLint y, GLsizei width, + GLsizei height, GLint border ); + +extern void gl_save_CopyTexSubImage1D( GLcontext *ctx, + GLenum target, GLint level, + GLint xoffset, GLint x, GLint y, + GLsizei width ); + +extern void gl_save_CopyTexSubImage2D( GLcontext *ctx, + GLenum target, GLint level, + GLint xoffset, GLint yoffset, + GLint x, GLint y, + GLsizei width, GLint height ); + +extern void gl_save_CullFace( GLcontext *ctx, GLenum mode ); + +extern void gl_save_DepthFunc( GLcontext *ctx, GLenum func ); + +extern void gl_save_DepthMask( GLcontext *ctx, GLboolean mask ); + +extern void gl_save_DepthRange( GLcontext *ctx, + GLclampd nearval, GLclampd farval ); + +extern void gl_save_Disable( GLcontext *ctx, GLenum cap ); + +extern void gl_save_DrawBuffer( GLcontext *ctx, GLenum mode ); + +extern void gl_save_DrawPixels( GLcontext *ctx, + GLsizei width, GLsizei height, GLenum format, + GLenum type, const GLvoid *pixels ); + +extern void gl_save_EdgeFlag( GLcontext *ctx, GLboolean flag ); + +extern void gl_save_Enable( GLcontext *ctx, GLenum cap ); + +extern void gl_save_End( GLcontext *ctx ); + +extern void gl_save_EvalCoord1f( GLcontext *ctx, GLfloat u ); + +extern void gl_save_EvalCoord2f( GLcontext *ctx, GLfloat u, GLfloat v ); + +extern void gl_save_EvalMesh1( GLcontext *ctx, + GLenum mode, GLint i1, GLint i2 ); + +extern void gl_save_EvalMesh2( GLcontext *ctx, GLenum mode, GLint i1, GLint i2, + GLint j1, GLint j2 ); + +extern void gl_save_EvalPoint1( GLcontext *ctx, GLint i ); + +extern void gl_save_EvalPoint2( GLcontext *ctx, GLint i, GLint j ); + +extern void gl_save_Fogfv( GLcontext *ctx, + GLenum pname, const GLfloat *params ); + +extern void gl_save_FrontFace( GLcontext *ctx, GLenum mode ); + +extern void gl_save_Frustum( GLcontext *ctx, GLdouble left, GLdouble right, + GLdouble bottom, GLdouble top, + GLdouble nearval, GLdouble farval ); + +extern void gl_save_Hint( GLcontext *ctx, GLenum target, GLenum mode ); + +extern void gl_save_Indexf( GLcontext *ctx, GLfloat index ); + +extern void gl_save_Indexi( GLcontext *ctx, GLint index ); + +extern void gl_save_IndexMask( GLcontext *ctx, GLuint mask ); + +extern void gl_save_InitNames( GLcontext *ctx ); + +extern void gl_save_Lightfv( GLcontext *ctx, GLenum light, GLenum pname, + const GLfloat *params, GLint numparams ); + +extern void gl_save_LightModelfv( GLcontext *ctx, GLenum pname, + const GLfloat *params ); + +extern void gl_save_LineWidth( GLcontext *ctx, GLfloat width ); + +extern void gl_save_LineStipple( GLcontext *ctx, GLint factor, + GLushort pattern ); + +extern void gl_save_ListBase( GLcontext *ctx, GLuint base ); + +extern void gl_save_LoadIdentity( GLcontext *ctx ); + +extern void gl_save_LoadMatrixf( GLcontext *ctx, const GLfloat *m ); + +extern void gl_save_LoadName( GLcontext *ctx, GLuint name ); + +extern void gl_save_LogicOp( GLcontext *ctx, GLenum opcode ); + +extern void gl_save_Map1f( GLcontext *ctx, GLenum target, + GLfloat u1, GLfloat u2, GLint stride, + GLint order, const GLfloat *points, + GLboolean retain ); + +extern void gl_save_Map2f( GLcontext *ctx, GLenum target, + GLfloat u1, GLfloat u2, GLint ustride, GLint uorder, + GLfloat v1, GLfloat v2, GLint vstride, GLint vorder, + const GLfloat *points, + GLboolean retain ); + +extern void gl_save_MapGrid1f( GLcontext *ctx, GLint un, + GLfloat u1, GLfloat u2 ); + +extern void gl_save_MapGrid2f( GLcontext *ctx, + GLint un, GLfloat u1, GLfloat u2, + GLint vn, GLfloat v1, GLfloat v2 ); + +extern void gl_save_Materialfv( GLcontext *ctx, GLenum face, GLenum pname, + const GLfloat *params ); + +extern void gl_save_MatrixMode( GLcontext *ctx, GLenum mode ); + +extern void gl_save_MultMatrixf( GLcontext *ctx, const GLfloat *m ); + +extern void gl_save_NewList( GLcontext *ctx, GLuint list, GLenum mode ); + +extern void gl_save_Normal3fv( GLcontext *ctx, const GLfloat n[3] ); + +extern void gl_save_Normal3f( GLcontext *ctx, + GLfloat nx, GLfloat ny, GLfloat nz ); + +extern void gl_save_Ortho( GLcontext *ctx, GLdouble left, GLdouble right, + GLdouble bottom, GLdouble top, + GLdouble nearval, GLdouble farval ); + +extern void gl_save_PassThrough( GLcontext *ctx, GLfloat token ); + +extern void gl_save_PixelMapfv( GLcontext *ctx, GLenum map, GLint mapsize, + const GLfloat *values ); + +extern void gl_save_PixelTransferf( GLcontext *ctx, + GLenum pname, GLfloat param ); + +extern void gl_save_PixelZoom( GLcontext *ctx, + GLfloat xfactor, GLfloat yfactor ); + +extern void gl_save_PointSize( GLcontext *ctx, GLfloat size ); + +extern void gl_save_PolygonMode( GLcontext *ctx, GLenum face, GLenum mode ); + +extern void gl_save_PolygonStipple( GLcontext *ctx, const GLubyte *mask ); + +extern void gl_save_PolygonOffset( GLcontext *ctx, + GLfloat factor, GLfloat units ); + +extern void gl_save_PopAttrib( GLcontext *ctx ); + +extern void gl_save_PopMatrix( GLcontext *ctx ); + +extern void gl_save_PopName( GLcontext *ctx ); + +extern void gl_save_PrioritizeTextures( GLcontext *ctx, + GLsizei n, const GLuint *textures, + const GLclampf *priorities ); + +extern void gl_save_PushAttrib( GLcontext *ctx, GLbitfield mask ); + +extern void gl_save_PushMatrix( GLcontext *ctx ); + +extern void gl_save_PushName( GLcontext *ctx, GLuint name ); + +extern void gl_save_RasterPos4f( GLcontext *ctx, + GLfloat x, GLfloat y, GLfloat z, GLfloat w ); + +extern void gl_save_ReadBuffer( GLcontext *ctx, GLenum mode ); + +extern void gl_save_Rectf( GLcontext *ctx, + GLfloat x1, GLfloat y1, GLfloat x2, GLfloat y2 ); + +extern void gl_save_Rotatef( GLcontext *ctx, GLfloat angle, + GLfloat x, GLfloat y, GLfloat z ); + +extern void gl_save_Scalef( GLcontext *ctx, GLfloat x, GLfloat y, GLfloat z ); + +extern void gl_save_Scissor( GLcontext *ctx, + GLint x, GLint y, GLsizei width, GLsizei height ); + +extern void gl_save_ShadeModel( GLcontext *ctx, GLenum mode ); + +extern void gl_save_StencilFunc( GLcontext *ctx, + GLenum func, GLint ref, GLuint mask ); + +extern void gl_save_StencilMask( GLcontext *ctx, GLuint mask ); + +extern void gl_save_StencilOp( GLcontext *ctx, + GLenum fail, GLenum zfail, GLenum zpass ); + +extern void gl_save_TexCoord2f( GLcontext *ctx, GLfloat s, GLfloat t ); + +extern void gl_save_TexCoord4f( GLcontext *ctx, GLfloat s, GLfloat t, + GLfloat r, GLfloat q ); + +extern void gl_save_TexEnvfv( GLcontext *ctx, GLenum target, GLenum pname, + const GLfloat *params ); + +extern void gl_save_TexParameterfv( GLcontext *ctx, GLenum target, + GLenum pname, const GLfloat *params ); + +extern void gl_save_TexGenfv( GLcontext *ctx, GLenum coord, GLenum pname, + const GLfloat *params ); + +extern void gl_save_TexImage1D( GLcontext *ctx, GLenum target, + GLint level, GLint components, + GLsizei width, GLint border, + GLenum format, GLenum type, + struct gl_image *teximage ); + +extern void gl_save_TexImage2D( GLcontext *ctx, GLenum target, + GLint level, GLint components, + GLsizei width, GLsizei height, GLint border, + GLenum format, GLenum type, + struct gl_image *teximage ); + +extern void gl_save_TexSubImage1D( GLcontext *ctx, + GLenum target, GLint level, + GLint xoffset, GLsizei width, + GLenum format, GLenum type, + struct gl_image *image ); + + +extern void gl_save_TexSubImage2D( GLcontext *ctx, + GLenum target, GLint level, + GLint xoffset, GLint yoffset, + GLsizei width, GLsizei height, + GLenum format, GLenum type, + struct gl_image *image ); + +extern void gl_save_Translatef( GLcontext *ctx, + GLfloat x, GLfloat y, GLfloat z ); + +extern void gl_save_Vertex2f( GLcontext *ctx, + GLfloat x, GLfloat y ); + +extern void gl_save_Vertex3f( GLcontext *ctx, + GLfloat x, GLfloat y, GLfloat z ); + +extern void gl_save_Vertex4f( GLcontext *ctx, + GLfloat x, GLfloat y, GLfloat z, GLfloat w ); + +extern void gl_save_Vertex3fv( GLcontext *ctx, const GLfloat *v ); + +extern void gl_save_Viewport( GLcontext *ctx, GLint x, GLint y, + GLsizei width, GLsizei height ); + + +#endif diff --git a/dll/opengl/mesa/drawpix.c b/dll/opengl/mesa/drawpix.c new file mode 100644 index 00000000000..227c9df4ac0 --- /dev/null +++ b/dll/opengl/mesa/drawpix.c @@ -0,0 +1,1207 @@ +/* $Id: drawpix.c,v 1.16 1998/02/03 23:45:02 brianp Exp $ */ + +/* + * Mesa 3-D graphics library + * Version: 2.4 + * Copyright (C) 1995-1997 Brian Paul + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Library General Public + * License as published by the Free Software Foundation; either + * version 2 of the License, or (at your option) any later version. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Library General Public License for more details. + * + * You should have received a copy of the GNU Library General Public + * License along with this library; if not, write to the Free + * Software Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. + */ + + +/* + * $Log: drawpix.c,v $ + * Revision 1.16 1998/02/03 23:45:02 brianp + * added casts to prevent warnings with Amiga StormC compiler + * + * Revision 1.15 1997/08/26 02:10:11 brianp + * another bug fix related to glPixelStore() + * + * Revision 1.14 1997/08/24 02:31:23 brianp + * bug fix: glPixelStore() params weren't ignored during display list execute + * + * Revision 1.13 1997/07/24 01:25:01 brianp + * changed precompiled header symbol from PCH to PC_HEADER + * + * Revision 1.12 1997/06/20 02:18:23 brianp + * replaced Current.IntColor with Current.ByteColor + * + * Revision 1.11 1997/05/28 03:24:22 brianp + * added precompiled header (PCH) support + * + * Revision 1.10 1997/04/24 00:18:56 brianp + * added some missing UNDEFARRAY()s. Reported by Randy Frank. + * + * Revision 1.9 1997/04/20 20:28:49 brianp + * replaced abort() with gl_problem() + * + * Revision 1.8 1997/04/11 23:24:25 brianp + * move call to gl_update_state() into gl_DrawPixels() from drawpixels() + * + * Revision 1.7 1997/03/18 01:55:47 brianp + * only generate feedback/selection if raster position is valid + * + * Revision 1.6 1997/02/10 20:26:57 brianp + * fixed memory leak in quickdraw_rgb() + * + * Revision 1.5 1997/02/03 20:30:31 brianp + * added a few DEFARRAY macros for BeOS + * + * Revision 1.4 1996/10/16 00:58:53 brianp + * renamed gl_drawpixels() to drawpixels() + * + * Revision 1.3 1996/09/27 01:26:25 brianp + * added missing default cases to switches + * + * Revision 1.2 1996/09/15 14:17:30 brianp + * now use GLframebuffer and GLvisual + * + * Revision 1.1 1996/09/13 01:38:16 brianp + * Initial revision + * + */ + + +#ifdef PC_HEADER +#include "all.h" +#else +#include +#include +#include "context.h" +#include "drawpix.h" +#include "feedback.h" +#include "dlist.h" +#include "macros.h" +#include "pixel.h" +#include "span.h" +#include "stencil.h" +#include "types.h" +#endif + + + +/* TODO: apply texture mapping to fragments */ + + + +static void draw_index_pixels( GLcontext* ctx, GLsizei width, GLsizei height, + GLenum type, const GLvoid *pixels ) +{ + GLint x, y, desty; + GLuint i, j; + GLdepth zspan[MAX_WIDTH]; + GLboolean zoom; + + zoom = ctx->Pixel.ZoomX!=1.0 || ctx->Pixel.ZoomY!=1.0; + + /* Position, depth of pixels */ + x = (GLint) (ctx->Current.RasterPos[0] + 0.5F); + y = (GLint) (ctx->Current.RasterPos[1] + 0.5F); + desty = y; + if (ctx->Depth.Test) { + GLdepth zval = (GLdepth) (ctx->Current.RasterPos[2] * DEPTH_SCALE); + for (i=0;iPixel.IndexOffset || ctx->Pixel.IndexShift) { + if (ctx->Pixel.IndexShift>=0) { + for (j=0;jPixel.IndexShift) + + ctx->Pixel.IndexOffset; + } + } + else { + for (j=0;j> -ctx->Pixel.IndexShift) + + ctx->Pixel.IndexOffset; + } + } + } + + if (ctx->Visual->RGBAflag) { + /* Convert index to RGBA and write to frame buffer */ + GLubyte red[MAX_WIDTH], green[MAX_WIDTH]; + GLubyte blue[MAX_WIDTH], alpha[MAX_WIDTH]; + for (j=0;jPixel.MapItoR[ispan[j]] * ctx->Visual->RedScale); + green[j] = (GLint) (ctx->Pixel.MapItoG[ispan[j]] * ctx->Visual->GreenScale); + blue[j] = (GLint) (ctx->Pixel.MapItoB[ispan[j]] * ctx->Visual->BlueScale); + alpha[j] = (GLint) (ctx->Pixel.MapItoA[ispan[j]] * ctx->Visual->AlphaScale); + } + if (zoom) { + gl_write_zoomed_color_span( ctx, width, x, y, zspan, + red, green, blue, alpha, desty ); + } + else { + gl_write_color_span( ctx, width, x, y, zspan, + red, green, blue, alpha, GL_BITMAP ); + } + } + else { + /* optionally apply index map then write to frame buffer */ + if (ctx->Pixel.MapColorFlag) { + for (j=0;jPixel.MapItoI[ispan[j]]; + } + } + if (zoom) { + gl_write_zoomed_index_span( ctx, width, x, y, zspan, ispan, desty ); + } + else { + gl_write_index_span( ctx, width, x, y, zspan, ispan, GL_BITMAP ); + } + } + } + +} + + + +static void draw_stencil_pixels( GLcontext* ctx, GLsizei width, GLsizei height, + GLenum type, const GLvoid *pixels ) +{ + GLint x, y, desty; + GLuint i, j; + GLboolean zoom; + + zoom = ctx->Pixel.ZoomX!=1.0 || ctx->Pixel.ZoomY!=1.0; + + /* Position, depth of pixels */ + x = (GLint) (ctx->Current.RasterPos[0] + 0.5F); + y = (GLint) (ctx->Current.RasterPos[1] + 0.5F); + desty = y; + + /* process the image row by row */ + for (i=0;iPixel.IndexOffset || ctx->Pixel.IndexShift) { + if (ctx->Pixel.IndexShift>=0) { + for (j=0;jPixel.IndexShift) + + ctx->Pixel.IndexOffset; + } + } + else { + for (j=0;j> -ctx->Pixel.IndexShift) + + ctx->Pixel.IndexOffset; + } + } + } + + /* mapping */ + if (ctx->Pixel.MapStencilFlag) { + for (j=0;jPixel.MapStoS[ stencil[j] ]; + } + } + + /* write stencil values to stencil buffer */ + if (zoom) { + gl_write_zoomed_stencil_span( ctx, (GLuint) width, x, y, stencil, desty ); + } + else { + gl_write_stencil_span( ctx, (GLuint) width, x, y, stencil ); + } + } +} + + + +static void draw_depth_pixels( GLcontext* ctx, GLsizei width, GLsizei height, + GLenum type, const GLvoid *pixels ) +{ + GLint x, y, desty; + GLubyte red[MAX_WIDTH], green[MAX_WIDTH], blue[MAX_WIDTH], alpha[MAX_WIDTH]; + GLuint ispan[MAX_WIDTH]; + GLboolean bias_or_scale; + GLboolean zoom; + + bias_or_scale = ctx->Pixel.DepthBias!=0.0 || ctx->Pixel.DepthScale!=1.0; + zoom = ctx->Pixel.ZoomX!=1.0 || ctx->Pixel.ZoomY!=1.0; + + /* Position, depth of pixels */ + x = (GLint) (ctx->Current.RasterPos[0] + 0.5F); + y = (GLint) (ctx->Current.RasterPos[1] + 0.5F); + desty = y; + + /* Color or index */ + if (ctx->Visual->RGBAflag) { + GLint r, g, b, a; + r = (GLint) (ctx->Current.RasterColor[0] * ctx->Visual->RedScale); + g = (GLint) (ctx->Current.RasterColor[1] * ctx->Visual->GreenScale); + b = (GLint) (ctx->Current.RasterColor[2] * ctx->Visual->BlueScale); + a = (GLint) (ctx->Current.RasterColor[3] * ctx->Visual->AlphaScale); + MEMSET( red, r, width ); + MEMSET( green, g, width ); + MEMSET( blue, b, width ); + MEMSET( alpha, a, width ); + } + else { + GLuint i; + for (i=0;iCurrent.RasterIndex; + } + } + + if (type==GL_UNSIGNED_INT && !bias_or_scale && !zoom && ctx->Visual->RGBAflag) + { + /* Special case: directly write 32-bit depth values */ + GLuint i, j; + /* Compute shift value to scale 32-bit uints down to depth values. */ + GLuint shift = 0; + GLuint max = MAX_DEPTH; + while ((max&0x80000000)==0) { + max = max << 1; + shift++; + } + for (j=0;j> shift; + } + gl_write_color_span( ctx, width, x, y, zspan, + red, green, blue, alpha, GL_BITMAP ); + } + } + else { + /* General case (slower) */ + GLuint i, j; + + /* process image row by row */ + for (i=0;iPixel.DepthScale!=1.0 || ctx->Pixel.DepthBias!=0.0) { + for (j=0;jPixel.DepthScale + ctx->Pixel.DepthBias; + } + } + + /* clamp depth values to [0,1] and convert from floats to integers */ + for (j=0;jVisual->RGBAflag) { + if (zoom) { + gl_write_zoomed_color_span( ctx, width, x, y, zspan, + red, green, blue, alpha, desty ); + } + else { + gl_write_color_span( ctx, width, x, y, zspan, + red, green, blue, alpha, GL_BITMAP ); + } + } + else { + if (zoom) { + gl_write_zoomed_index_span( ctx, width, x, y, zspan, + ispan, GL_BITMAP ); + } + else { + gl_write_index_span( ctx, width, x, y, zspan, ispan, GL_BITMAP ); + } + } + + } + } +} + + + +static void draw_color_pixels(GLcontext* ctx, GLsizei width, GLsizei height, + GLenum format, GLenum type, const GLvoid *pixels) +{ + GLuint i, j; + GLint x, y, desty; + GLdepth zspan[MAX_WIDTH]; + GLboolean scale_or_bias, quick_draw; + GLboolean zoom; + + zoom = ctx->Pixel.ZoomX != 1.0 || ctx->Pixel.ZoomY != 1.0; + + /* Position, depth of pixels */ + x = (GLint) (ctx->Current.RasterPos[0] + 0.5F); + y = (GLint) (ctx->Current.RasterPos[1] + 0.5F); + desty = y; + if (ctx->Depth.Test) + { + /* fill in array of z values */ + GLdepth z = (GLdepth) (ctx->Current.RasterPos[2] * DEPTH_SCALE); + for (i = 0; i < width; i++) + { + zspan[i] = z; + } + } + + /* Determine if scaling and/or biasing is needed */ + if (ctx->Pixel.RedScale != 1.0F || ctx->Pixel.RedBias != 0.0F + || ctx->Pixel.GreenScale != 1.0F || ctx->Pixel.GreenBias != 0.0F + || ctx->Pixel.BlueScale != 1.0F || ctx->Pixel.BlueBias != 0.0F + || ctx->Pixel.AlphaScale != 1.0F || ctx->Pixel.AlphaBias != 0.0F) + { + scale_or_bias = GL_TRUE; + } + else + { + scale_or_bias = GL_FALSE; + } + + /* Determine if we can directly call the device driver function */ + if (ctx->RasterMask == 0 && !zoom && x >= 0 && y >= 0 + && x + width <= ctx->Buffer->Width + && y + height <= ctx->Buffer->Height) + { + quick_draw = GL_TRUE; + } + else + { + quick_draw = GL_FALSE; + } + + /* First check for common cases */ + if (type == GL_UNSIGNED_BYTE + && (format == GL_RGB || format == GL_LUMINANCE || format == GL_BGR_EXT) + && !ctx->Pixel.MapColorFlag + && !scale_or_bias && ctx->Visual->EightBitColor) + { + DEFARRAY(GLubyte, alpha, MAX_WIDTH); + GLubyte *src = (GLubyte *) pixels; + /* constant alpha */ + MEMSET(alpha, (GLint ) ctx->Visual->AlphaScale, width); + if (format == GL_RGB) + { + /* 8-bit RGB pixels */ + DEFARRAY(GLubyte, red, MAX_WIDTH); + DEFARRAY(GLubyte, green, MAX_WIDTH); + DEFARRAY(GLubyte, blue, MAX_WIDTH); + for (i = 0; i < height; i++, y++) + { + for (j = 0; j < width; j++) + { + red[j] = *src++; + green[j] = *src++; + blue[j] = *src++; + } + if (quick_draw) + { + (*ctx->Driver.WriteColorSpan)(ctx, width, x, y, red, green, + blue, alpha, NULL); + } + else if (zoom) + { + gl_write_zoomed_color_span(ctx, (GLuint) width, x, y, zspan, + red, green, blue, alpha, desty); + } + else + { + gl_write_color_span(ctx, (GLuint) width, x, y, zspan, red, + green, blue, alpha, GL_BITMAP); + } + } + UNDEFARRAY( red ); + UNDEFARRAY( green ); + UNDEFARRAY( blue ); + } + else if (format == GL_BGR_EXT) + { + /* 8-bit BGR pixels */ + DEFARRAY(GLubyte, red, MAX_WIDTH); + DEFARRAY(GLubyte, green, MAX_WIDTH); + DEFARRAY(GLubyte, blue, MAX_WIDTH); + for (i = 0; i < height; i++, y++) + { + for (j = 0; j < width; j++) + { + blue[j] = *src++; + green[j] = *src++; + red[j] = *src++; + } + if (quick_draw) + { + (*ctx->Driver.WriteColorSpan)(ctx, width, x, y, red, green, + blue, alpha, NULL); + } + else if (zoom) + { + gl_write_zoomed_color_span(ctx, (GLuint) width, x, y, zspan, + red, green, blue, alpha, desty); + } + else + { + gl_write_color_span(ctx, (GLuint) width, x, y, zspan, red, + green, blue, alpha, GL_BITMAP); + } + } + UNDEFARRAY( red ); + UNDEFARRAY( green ); + UNDEFARRAY( blue ); + } + else + { + /* 8-bit Luminance pixels */ + GLubyte *lum = (GLubyte *) pixels; + for (i = 0; i < height; i++, y++, lum += width) + { + if (quick_draw) + { + (*ctx->Driver.WriteColorSpan)(ctx, width, x, y, lum, lum, + lum, alpha, NULL); + } + else if (zoom) + { + gl_write_zoomed_color_span(ctx, (GLuint) width, x, y, zspan, + lum, lum, lum, alpha, desty); + } + else + { + gl_write_color_span(ctx, (GLuint) width, x, y, zspan, lum, + lum, lum, alpha, GL_BITMAP); + } + } + } + UNDEFARRAY( alpha ); + } + else + { + /* General solution */ + GLboolean r_flag, g_flag, b_flag, a_flag, l_flag; + GLuint components; + GLboolean is_bgr; + + r_flag = g_flag = b_flag = a_flag = l_flag = GL_FALSE; + is_bgr = GL_FALSE; + switch (format) + { + case GL_RED: + r_flag = GL_TRUE; + components = 1; + break; + case GL_GREEN: + g_flag = GL_TRUE; + components = 1; + break; + case GL_BLUE: + b_flag = GL_TRUE; + components = 1; + break; + case GL_ALPHA: + a_flag = GL_TRUE; + components = 1; + break; + case GL_RGB: + r_flag = g_flag = b_flag = GL_TRUE; + components = 3; + break; + case GL_BGR_EXT: + is_bgr = GL_TRUE; + r_flag = g_flag = b_flag = GL_TRUE; + components = 3; + break; + case GL_LUMINANCE: + l_flag = GL_TRUE; + components = 1; + break; + case GL_LUMINANCE_ALPHA: + l_flag = a_flag = GL_TRUE; + components = 2; + break; + case GL_RGBA: + r_flag = g_flag = b_flag = a_flag = GL_TRUE; + components = 4; + break; + case GL_BGRA_EXT: + is_bgr = GL_TRUE; + r_flag = g_flag = b_flag = a_flag = GL_TRUE; + components = 4; + break; + default: + gl_problem(ctx, "Bad type in draw_color_pixels"); + return; + } + + /* process the image row by row */ + for (i = 0; i < height; i++, y++) + { + DEFARRAY(GLfloat, rf, MAX_WIDTH); + DEFARRAY(GLfloat, gf, MAX_WIDTH); + DEFARRAY(GLfloat, bf, MAX_WIDTH); + DEFARRAY(GLfloat, af, MAX_WIDTH); + DEFARRAY(GLubyte, red, MAX_WIDTH); + DEFARRAY(GLubyte, green, MAX_WIDTH); + DEFARRAY(GLubyte, blue, MAX_WIDTH); + DEFARRAY(GLubyte, alpha, MAX_WIDTH); + + /* convert to floats */ + switch (type) + { + case GL_UNSIGNED_BYTE: + { + GLubyte *src = (GLubyte *) pixels + i * width * components; + for (j = 0; j < width; j++) + { + if (l_flag) + { + rf[j] = gf[j] = bf[j] = UBYTE_TO_FLOAT(*src++); + } + else if (is_bgr) + { + bf[j] = b_flag ? UBYTE_TO_FLOAT(*src++) : 0.0; + gf[j] = g_flag ? UBYTE_TO_FLOAT(*src++) : 0.0; + rf[j] = r_flag ? UBYTE_TO_FLOAT(*src++) : 0.0; + } + else + { + rf[j] = r_flag ? UBYTE_TO_FLOAT(*src++) : 0.0; + gf[j] = g_flag ? UBYTE_TO_FLOAT(*src++) : 0.0; + bf[j] = b_flag ? UBYTE_TO_FLOAT(*src++) : 0.0; + } + af[j] = a_flag ? UBYTE_TO_FLOAT(*src++) : 1.0; + } + } + break; + case GL_BYTE: + { + GLbyte *src = (GLbyte *) pixels + i * width * components; + for (j = 0; j < width; j++) + { + if (l_flag) + { + rf[j] = gf[j] = bf[j] = BYTE_TO_FLOAT(*src++); + } + else if (is_bgr) + { + bf[j] = b_flag ? BYTE_TO_FLOAT(*src++) : 0.0; + gf[j] = g_flag ? BYTE_TO_FLOAT(*src++) : 0.0; + rf[j] = r_flag ? BYTE_TO_FLOAT(*src++) : 0.0; + } + else + { + rf[j] = r_flag ? BYTE_TO_FLOAT(*src++) : 0.0; + gf[j] = g_flag ? BYTE_TO_FLOAT(*src++) : 0.0; + bf[j] = b_flag ? BYTE_TO_FLOAT(*src++) : 0.0; + } + af[j] = a_flag ? BYTE_TO_FLOAT(*src++) : 1.0; + } + } + break; + case GL_BITMAP: + /* special case */ + break; + case GL_UNSIGNED_SHORT: + { + GLushort *src = (GLushort *) pixels + i * width * components; + for (j = 0; j < width; j++) + { + if (l_flag) + { + rf[j] = gf[j] = bf[j] = USHORT_TO_FLOAT(*src++); + } + else if (is_bgr) + { + bf[j] = b_flag ? USHORT_TO_FLOAT(*src++) : 0.0; + gf[j] = g_flag ? USHORT_TO_FLOAT(*src++) : 0.0; + rf[j] = r_flag ? USHORT_TO_FLOAT(*src++) : 0.0; + } + else + { + rf[j] = r_flag ? USHORT_TO_FLOAT(*src++) : 0.0; + gf[j] = g_flag ? USHORT_TO_FLOAT(*src++) : 0.0; + bf[j] = b_flag ? USHORT_TO_FLOAT(*src++) : 0.0; + } + af[j] = a_flag ? USHORT_TO_FLOAT(*src++) : 1.0; + } + } + break; + case GL_SHORT: + { + GLshort *src = (GLshort *) pixels + i * width * components; + for (j = 0; j < width; j++) + { + if (l_flag) + { + rf[j] = gf[j] = bf[j] = SHORT_TO_FLOAT(*src++); + } + else if (is_bgr) + { + bf[j] = b_flag ? SHORT_TO_FLOAT(*src++) : 0.0; + gf[j] = g_flag ? SHORT_TO_FLOAT(*src++) : 0.0; + rf[j] = r_flag ? SHORT_TO_FLOAT(*src++) : 0.0; + } + else + { + rf[j] = r_flag ? SHORT_TO_FLOAT(*src++) : 0.0; + gf[j] = g_flag ? SHORT_TO_FLOAT(*src++) : 0.0; + bf[j] = b_flag ? SHORT_TO_FLOAT(*src++) : 0.0; + } + af[j] = a_flag ? SHORT_TO_FLOAT(*src++) : 1.0; + } + } + break; + case GL_UNSIGNED_INT: + { + GLuint *src = (GLuint *) pixels + i * width * components; + for (j = 0; j < width; j++) + { + if (l_flag) + { + rf[j] = gf[j] = bf[j] = UINT_TO_FLOAT(*src++); + } + else if (is_bgr) + { + bf[j] = b_flag ? UINT_TO_FLOAT(*src++) : 0.0; + gf[j] = g_flag ? UINT_TO_FLOAT(*src++) : 0.0; + rf[j] = r_flag ? UINT_TO_FLOAT(*src++) : 0.0; + } + else + { + rf[j] = r_flag ? UINT_TO_FLOAT(*src++) : 0.0; + gf[j] = g_flag ? UINT_TO_FLOAT(*src++) : 0.0; + bf[j] = b_flag ? UINT_TO_FLOAT(*src++) : 0.0; + } + af[j] = a_flag ? UINT_TO_FLOAT(*src++) : 1.0; + } + } + break; + case GL_INT: + { + GLint *src = (GLint *) pixels + i * width * components; + for (j = 0; j < width; j++) + { + if (l_flag) + { + rf[j] = gf[j] = bf[j] = INT_TO_FLOAT(*src++); + } + else if (is_bgr) + { + bf[j] = b_flag ? INT_TO_FLOAT(*src++) : 0.0; + gf[j] = g_flag ? INT_TO_FLOAT(*src++) : 0.0; + rf[j] = r_flag ? INT_TO_FLOAT(*src++) : 0.0; + } + else + { + rf[j] = r_flag ? INT_TO_FLOAT(*src++) : 0.0; + gf[j] = g_flag ? INT_TO_FLOAT(*src++) : 0.0; + bf[j] = b_flag ? INT_TO_FLOAT(*src++) : 0.0; + } + af[j] = a_flag ? INT_TO_FLOAT(*src++) : 1.0; + } + } + break; + case GL_FLOAT: + { + GLfloat *src = (GLfloat *) pixels + i * width * components; + for (j = 0; j < width; j++) + { + if (l_flag) + { + rf[j] = gf[j] = bf[j] = *src++; + } + else if (is_bgr) + { + bf[j] = b_flag ? *src++ : 0.0; + gf[j] = g_flag ? *src++ : 0.0; + rf[j] = r_flag ? *src++ : 0.0; + } + else + { + rf[j] = r_flag ? *src++ : 0.0; + gf[j] = g_flag ? *src++ : 0.0; + bf[j] = b_flag ? *src++ : 0.0; + } + af[j] = a_flag ? *src++ : 1.0; + } + } + break; + default: + gl_error(ctx, GL_INVALID_ENUM, "glDrawPixels"); + return; + } + + /* apply scale and bias */ + if (scale_or_bias) + { + for (j = 0; j < width; j++) + { + GLfloat r, g, b, a; + r = rf[j] * ctx->Pixel.RedScale + ctx->Pixel.RedBias; + g = gf[j] * ctx->Pixel.GreenScale + ctx->Pixel.GreenBias; + b = bf[j] * ctx->Pixel.BlueScale + ctx->Pixel.BlueBias; + a = af[j] * ctx->Pixel.AlphaScale + ctx->Pixel.AlphaBias; + rf[j] = CLAMP(r, 0.0, 1.0); + gf[j] = CLAMP(g, 0.0, 1.0); + bf[j] = CLAMP(b, 0.0, 1.0); + af[j] = CLAMP(a, 0.0, 1.0); + } + } + + /* apply pixel mappings */ + if (ctx->Pixel.MapColorFlag) + { + GLfloat rscale = ctx->Pixel.MapRtoRsize - 1; + GLfloat gscale = ctx->Pixel.MapGtoGsize - 1; + GLfloat bscale = ctx->Pixel.MapBtoBsize - 1; + GLfloat ascale = ctx->Pixel.MapAtoAsize - 1; + for (j = 0; j < width; j++) + { + rf[j] = ctx->Pixel.MapRtoR[(GLint) (rf[j] * rscale)]; + gf[j] = ctx->Pixel.MapGtoG[(GLint) (gf[j] * gscale)]; + bf[j] = ctx->Pixel.MapBtoB[(GLint) (bf[j] * bscale)]; + af[j] = ctx->Pixel.MapAtoA[(GLint) (af[j] * ascale)]; + } + } + + /* convert to integers */ + for (j = 0; j < width; j++) + { + red[j] = (GLint) (rf[j] * ctx->Visual->RedScale); + green[j] = (GLint) (gf[j] * ctx->Visual->GreenScale); + blue[j] = (GLint) (bf[j] * ctx->Visual->BlueScale); + alpha[j] = (GLint) (af[j] * ctx->Visual->AlphaScale); + } + + /* write to frame buffer */ + if (quick_draw) + { + (*ctx->Driver.WriteColorSpan)(ctx, width, x, y, red, green, + blue, alpha, NULL); + } + else if (zoom) + { + gl_write_zoomed_color_span(ctx, width, x, y, zspan, red, green, + blue, alpha, desty); + } + else + { + gl_write_color_span(ctx, (GLuint) width, x, y, zspan, red, + green, blue, alpha, GL_BITMAP); + } + + UNDEFARRAY(rf); + UNDEFARRAY(gf); + UNDEFARRAY(bf); + UNDEFARRAY(af); + UNDEFARRAY(red); + UNDEFARRAY(green); + UNDEFARRAY(blue); + UNDEFARRAY(alpha); + } + } + +} + + + +/* + * Do a glDrawPixels( w, h, GL_RGB, GL_UNSIGNED_BYTE, pixels ) optimized + * for the case of no pixel mapping, no scale, no bias, no zoom, default + * storage mode, no raster ops, and no pixel clipping. + * Return: GL_TRUE if success + * GL_FALSE if conditions weren't met for optimized drawing + */ +static GLboolean quickdraw_rgb( GLcontext* ctx, GLsizei width, GLsizei height, + const void *pixels ) +{ + DEFARRAY( GLubyte, red, MAX_WIDTH ); + DEFARRAY( GLubyte, green, MAX_WIDTH ); + DEFARRAY( GLubyte, blue, MAX_WIDTH ); + DEFARRAY( GLubyte, alpha, MAX_WIDTH ); + GLint i, j; + GLint x, y; + GLint bytes_per_row; + GLboolean result; + + bytes_per_row = width * 3 + (width % ctx->Unpack.Alignment); + + if (!ctx->Current.RasterPosValid) { + /* This is success, actually. */ + result = GL_TRUE; + } + else { + x = (GLint) (ctx->Current.RasterPos[0] + 0.5F); + y = (GLint) (ctx->Current.RasterPos[1] + 0.5F); + + if (x<0 || y<0 + || x+width>ctx->Buffer->Width || y+height>ctx->Buffer->Height) { + result = GL_FALSE; /* can't handle this situation */ + } + else { + /* constant alpha */ + for (j=0;jVisual->AlphaScale; + } + + /* write directly to device driver */ + for (i=0;iDriver.WriteColorSpan)( ctx, width, x, y+i, + red, green, blue, alpha, NULL); + } + result = GL_TRUE; + } + } + + UNDEFARRAY( red ); + UNDEFARRAY( green ); + UNDEFARRAY( blue ); + UNDEFARRAY( alpha ); + + return result; +} + + + +/* + * Implements general glDrawPixels operation. + */ +static void drawpixels( GLcontext* ctx, GLsizei width, GLsizei height, + GLenum format, GLenum type, const GLvoid *pixels ) +{ + if (INSIDE_BEGIN_END(ctx)) { + gl_error( ctx, GL_INVALID_OPERATION, "glDrawPixels" ); + return; + } + + if (ctx->RenderMode==GL_RENDER) { + if (!ctx->Current.RasterPosValid) { + return; + } + switch (format) { + case GL_COLOR_INDEX: + draw_index_pixels( ctx, width, height, type, pixels ); + break; + case GL_STENCIL_INDEX: + draw_stencil_pixels( ctx, width, height, type, pixels ); + break; + case GL_DEPTH_COMPONENT: + draw_depth_pixels( ctx, width, height, type, pixels ); + break; + case GL_RED: + case GL_GREEN: + case GL_BLUE: + case GL_ALPHA: + case GL_RGB: + case GL_BGR_EXT: + case GL_LUMINANCE: + case GL_LUMINANCE_ALPHA: + case GL_RGBA: + case GL_BGRA_EXT: + draw_color_pixels( ctx, width, height, format, type, pixels ); + break; + default: + gl_error( ctx, GL_INVALID_ENUM, "glDrawPixels" ); + } + } + else if (ctx->RenderMode==GL_FEEDBACK) { + if (ctx->Current.RasterPosValid) { + GLfloat color[4], texcoord[4], invq; + color[0] = ctx->Current.ByteColor[0] * ctx->Visual->InvRedScale; + color[1] = ctx->Current.ByteColor[1] * ctx->Visual->InvGreenScale; + color[2] = ctx->Current.ByteColor[2] * ctx->Visual->InvBlueScale; + color[3] = ctx->Current.ByteColor[3] * ctx->Visual->InvAlphaScale; + invq = 1.0F / ctx->Current.TexCoord[3]; + texcoord[0] = ctx->Current.TexCoord[0] * invq; + texcoord[1] = ctx->Current.TexCoord[1] * invq; + texcoord[2] = ctx->Current.TexCoord[2] * invq; + texcoord[3] = ctx->Current.TexCoord[3]; + FEEDBACK_TOKEN( ctx, (GLfloat) (GLint) GL_DRAW_PIXEL_TOKEN ); + gl_feedback_vertex( ctx, ctx->Current.RasterPos[0], + ctx->Current.RasterPos[1], + ctx->Current.RasterPos[2], + ctx->Current.RasterPos[3], + color, ctx->Current.Index, texcoord ); + } + } + else if (ctx->RenderMode==GL_SELECT) { + if (ctx->Current.RasterPosValid) { + gl_update_hitflag( ctx, ctx->Current.RasterPos[2] ); + } + } +} + + + +/* + * Compile OR Execute a glDrawPixels! + */ +void gl_DrawPixels( GLcontext* ctx, GLsizei width, GLsizei height, + GLenum format, GLenum type, const GLvoid *pixels ) +{ + GLvoid *image; + + if (width<0 || height<0) { + gl_error( ctx, GL_INVALID_VALUE, "glDrawPixels" ); + return; + } + + if (ctx->NewState) { + gl_update_state(ctx); + } + + /* Let the device driver take a crack at glDrawPixels */ + if (!ctx->CompileFlag && ctx->Driver.DrawPixels) { + GLint x = (GLint) (ctx->Current.RasterPos[0] + 0.5F); + GLint y = (GLint) (ctx->Current.RasterPos[1] + 0.5F); + if ((*ctx->Driver.DrawPixels)( ctx, x, y, width, height, + format, type, GL_FALSE, pixels )) { + /* Device driver did the job */ + return; + } + } + + if (format==GL_RGB && type==GL_UNSIGNED_BYTE && ctx->FastDrawPixels + && !ctx->CompileFlag && ctx->RenderMode==GL_RENDER + && ctx->RasterMask==0 && ctx->CallDepth==0) { + /* optimized path */ + if (quickdraw_rgb( ctx, width, height, pixels )) { + /* success */ + return; + } + } + + /* take the general path */ + + /* THIS IS A REAL HACK - FIX IN MESA 2.5 + * If we're inside glCallList then we don't have to unpack the pixels again. + */ + if (ctx->CallDepth == 0) { + image = gl_unpack_pixels( ctx, width, height, format, type, pixels ); + if (!image) { + gl_error( ctx, GL_OUT_OF_MEMORY, "glDrawPixels" ); + return; + } + } + else { + image = (GLvoid *) pixels; + } + + if (ctx->CompileFlag) { + gl_save_DrawPixels( ctx, width, height, format, type, image ); + } + if (ctx->ExecuteFlag) { + drawpixels( ctx, width, height, format, type, image ); + if (!ctx->CompileFlag) { + /* may discard unpacked image now */ + if (image!=pixels) + free( image ); + } + } +} diff --git a/dll/opengl/mesa/drawpix.h b/dll/opengl/mesa/drawpix.h new file mode 100644 index 00000000000..59f111c817f --- /dev/null +++ b/dll/opengl/mesa/drawpix.h @@ -0,0 +1,46 @@ +/* $Id: drawpix.h,v 1.2 1996/10/16 00:53:14 brianp Exp $ */ + +/* + * Mesa 3-D graphics library + * Version: 2.0 + * Copyright (C) 1995-1996 Brian Paul + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Library General Public + * License as published by the Free Software Foundation; either + * version 2 of the License, or (at your option) any later version. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Library General Public License for more details. + * + * You should have received a copy of the GNU Library General Public + * License along with this library; if not, write to the Free + * Software Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. + */ + + +/* + * $Log: drawpix.h,v $ + * Revision 1.2 1996/10/16 00:53:14 brianp + * removed gl_drawpixels() prototype + * + * Revision 1.1 1996/09/13 01:38:16 brianp + * Initial revision + * + */ + + +#ifndef DRAWPIXELS_H +#define DRAWPIXELS_H + + +#include "types.h" + + +extern void gl_DrawPixels( GLcontext* ctx, GLsizei width, GLsizei height, + GLenum format, GLenum type, const GLvoid *pixels ); + + +#endif diff --git a/dll/opengl/mesa/drivers/common/CMakeLists.txt b/dll/opengl/mesa/drivers/common/CMakeLists.txt deleted file mode 100644 index c38b5a9655d..00000000000 --- a/dll/opengl/mesa/drivers/common/CMakeLists.txt +++ /dev/null @@ -1,7 +0,0 @@ - -list(APPEND SOURCE - driverfuncs.c - meta.c) - -add_library(mesa_drv_common STATIC ${SOURCE}) -add_dependencies(mesa_drv_common xdk) diff --git a/dll/opengl/mesa/drivers/common/driverfuncs.c b/dll/opengl/mesa/drivers/common/driverfuncs.c deleted file mode 100644 index 361f7403bc8..00000000000 --- a/dll/opengl/mesa/drivers/common/driverfuncs.c +++ /dev/null @@ -1,163 +0,0 @@ -/* - * Mesa 3-D graphics library - * Version: 7.1 - * - * Copyright (C) 1999-2007 Brian Paul All Rights Reserved. - * - * Permission is hereby granted, free of charge, to any person obtaining a - * copy of this software and associated documentation files (the "Software"), - * to deal in the Software without restriction, including without limitation - * the rights to use, copy, modify, merge, publish, distribute, sublicense, - * and/or sell copies of the Software, and to permit persons to whom the - * Software is furnished to do so, subject to the following conditions: - * - * The above copyright notice and this permission notice shall be included - * in all copies or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS - * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL - * BRIAN PAUL BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN - * AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN - * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. - */ - - -#include "main/glheader.h" -#include "main/imports.h" -#include "main/accum.h" -#include "main/context.h" -#include "main/framebuffer.h" -#include "main/readpix.h" -#include "main/renderbuffer.h" -#include "main/texformat.h" -#include "main/texgetimage.h" -#include "main/teximage.h" -#include "main/texobj.h" -#include "main/texstore.h" -#include "main/bufferobj.h" - -#include "tnl/tnl.h" -#include "swrast/swrast.h" -#include "swrast/s_renderbuffer.h" - -#include "driverfuncs.h" -#include "meta.h" - - - -/** - * Plug in default functions for all pointers in the dd_function_table - * structure. - * Device drivers should call this function and then plug in any - * functions which it wants to override. - * Some functions (pointers) MUST be implemented by all drivers (REQUIRED). - * - * \param table the dd_function_table to initialize - */ -void -_mesa_init_driver_functions(struct dd_function_table *driver) -{ - memset(driver, 0, sizeof(*driver)); - - driver->GetString = NULL; /* REQUIRED! */ - driver->UpdateState = NULL; /* REQUIRED! */ - driver->GetBufferSize = NULL; /* REQUIRED! */ - driver->ResizeBuffers = _mesa_resize_framebuffer; - driver->Error = NULL; - - driver->Finish = NULL; - driver->Flush = NULL; - - /* framebuffer/image functions */ - driver->Clear = _swrast_Clear; - driver->Accum = _mesa_accum; - driver->RasterPos = _tnl_RasterPos; - driver->DrawPixels = _swrast_DrawPixels; - driver->ReadPixels = _mesa_readpixels; - driver->CopyPixels = _swrast_CopyPixels; - driver->Bitmap = _swrast_Bitmap; - - /* Texture functions */ - driver->ChooseTextureFormat = _mesa_choose_tex_format; - driver->TexImage1D = _mesa_store_teximage1d; - driver->TexImage2D = _mesa_store_teximage2d; - driver->TexSubImage1D = _mesa_store_texsubimage1d; - driver->TexSubImage2D = _mesa_store_texsubimage2d; - driver->GetTexImage = _mesa_get_teximage; - driver->CopyTexSubImage1D = _mesa_meta_CopyTexSubImage1D; - driver->CopyTexSubImage2D = _mesa_meta_CopyTexSubImage2D; - driver->TestProxyTexImage = _mesa_test_proxy_teximage; - driver->BindTexture = NULL; - driver->NewTextureObject = _mesa_new_texture_object; - driver->DeleteTexture = _mesa_delete_texture_object; - driver->NewTextureImage = _swrast_new_texture_image; - driver->DeleteTextureImage = _swrast_delete_texture_image; - driver->AllocTextureImageBuffer = _swrast_alloc_texture_image_buffer; - driver->FreeTextureImageBuffer = _swrast_free_texture_image_buffer; - driver->MapTextureImage = _swrast_map_teximage; - driver->UnmapTextureImage = _swrast_unmap_teximage; - - /* simple state commands */ - driver->AlphaFunc = NULL; - driver->ClearColor = NULL; - driver->ClearDepth = NULL; - driver->ClearStencil = NULL; - driver->ClipPlane = NULL; - driver->ColorMask = NULL; - driver->ColorMaterial = NULL; - driver->CullFace = NULL; - driver->DrawBuffer = NULL; - driver->FrontFace = NULL; - driver->DepthFunc = NULL; - driver->DepthMask = NULL; - driver->DepthRange = NULL; - driver->Enable = NULL; - driver->Fogfv = NULL; - driver->Hint = NULL; - driver->Lightfv = NULL; - driver->LightModelfv = NULL; - driver->LineStipple = NULL; - driver->LineWidth = NULL; - driver->LogicOpcode = NULL; - driver->PointParameterfv = NULL; - driver->PointSize = NULL; - driver->PolygonMode = NULL; - driver->PolygonOffset = NULL; - driver->PolygonStipple = NULL; - driver->ReadBuffer = NULL; - driver->RenderMode = NULL; - driver->Scissor = NULL; - driver->ShadeModel = NULL; - driver->TexGen = NULL; - driver->TexEnv = NULL; - driver->TexParameter = NULL; - driver->Viewport = NULL; - - /* buffer objects */ - _mesa_init_buffer_object_functions(driver); - - driver->MapRenderbuffer = _swrast_map_soft_renderbuffer; - driver->UnmapRenderbuffer = _swrast_unmap_soft_renderbuffer; - - /* T&L stuff */ - driver->CurrentExecPrimitive = 0; - driver->CurrentSavePrimitive = 0; - driver->NeedFlush = 0; - driver->SaveNeedFlush = 0; - - driver->FlushVertices = NULL; - driver->SaveFlushVertices = NULL; - driver->PrepareExecBegin = NULL; - driver->NotifySaveBegin = NULL; - driver->LightingSpaceChange = NULL; - - /* display list */ - driver->NewList = NULL; - driver->EndList = NULL; - driver->BeginCallList = NULL; - driver->EndCallList = NULL; - - /* GL_ARB_texture_storage */ - driver->AllocTextureStorage = _swrast_AllocTextureStorage; -} diff --git a/dll/opengl/mesa/drivers/common/driverfuncs.h b/dll/opengl/mesa/drivers/common/driverfuncs.h deleted file mode 100644 index 2a0d6ee25ac..00000000000 --- a/dll/opengl/mesa/drivers/common/driverfuncs.h +++ /dev/null @@ -1,33 +0,0 @@ -/* - * Mesa 3-D graphics library - * Version: 7.1 - * - * Copyright (C) 1999-2007 Brian Paul All Rights Reserved. - * - * Permission is hereby granted, free of charge, to any person obtaining a - * copy of this software and associated documentation files (the "Software"), - * to deal in the Software without restriction, including without limitation - * the rights to use, copy, modify, merge, publish, distribute, sublicense, - * and/or sell copies of the Software, and to permit persons to whom the - * Software is furnished to do so, subject to the following conditions: - * - * The above copyright notice and this permission notice shall be included - * in all copies or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS - * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL - * BRIAN PAUL BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN - * AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN - * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. - */ - - -#ifndef DRIVERFUNCS_H -#define DRIVERFUNCS_H - -extern void -_mesa_init_driver_functions(struct dd_function_table *driver); - - -#endif diff --git a/dll/opengl/mesa/drivers/common/meta.c b/dll/opengl/mesa/drivers/common/meta.c deleted file mode 100644 index e9b44f0914e..00000000000 --- a/dll/opengl/mesa/drivers/common/meta.c +++ /dev/null @@ -1,756 +0,0 @@ -/* - * 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/blend.h" -#include "main/bufferobj.h" -#include "main/buffers.h" -#include "main/context.h" -#include "main/depth.h" -#include "main/enable.h" -#include "main/feedback.h" -#include "main/formats.h" -#include "main/image.h" -#include "main/macros.h" -#include "main/matrix.h" -#include "main/pixel.h" -#include "main/polygon.h" -#include "main/readpix.h" -#include "main/scissor.h" -#include "main/state.h" -#include "main/stencil.h" -#include "main/texobj.h" -#include "main/texenv.h" -#include "main/texgetimage.h" -#include "main/teximage.h" -#include "main/texparam.h" -#include "main/texstate.h" -#include "main/varray.h" -#include "main/viewport.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)) - -/** - * State which we may save/restore across meta ops. - * XXX this may be incomplete... - */ -struct save_state -{ - GLbitfield SavedState; /**< bitmask of MESA_META_* flags */ - - /** MESA_META_ALPHA_TEST */ - GLboolean AlphaEnabled; - GLenum AlphaFunc; - GLclampf AlphaRef; - - /** MESA_META_BLEND */ - GLbitfield BlendEnabled; - GLboolean ColorLogicOpEnabled; - - /** MESA_META_COLOR_MASK */ - GLubyte ColorMask[4]; - - /** MESA_META_DEPTH_TEST */ - struct gl_depthbuffer_attrib Depth; - - /** MESA_META_FOG */ - GLboolean Fog; - - /** MESA_META_PIXEL_STORE */ - struct gl_pixelstore_attrib Pack, Unpack; - - /** MESA_META_PIXEL_TRANSFER */ - GLfloat RedBias, RedScale; - GLfloat GreenBias, GreenScale; - GLfloat BlueBias, BlueScale; - GLfloat AlphaBias, AlphaScale; - GLfloat DepthBias, DepthScale; - GLboolean MapColorFlag; - - /** MESA_META_RASTERIZATION */ - GLenum FrontPolygonMode, BackPolygonMode; - GLboolean PolygonOffset; - GLboolean PolygonSmooth; - GLboolean PolygonStipple; - GLboolean PolygonCull; - - /** MESA_META_SCISSOR */ - struct gl_scissor_attrib Scissor; - - /** MESA_META_STENCIL_TEST */ - struct gl_stencil_attrib Stencil; - - /** MESA_META_TRANSFORM */ - GLenum MatrixMode; - GLfloat ModelviewMatrix[16]; - GLfloat ProjectionMatrix[16]; - GLfloat TextureMatrix[16]; - - /** MESA_META_CLIP */ - GLbitfield ClipPlanesEnabled; - - /** MESA_META_TEXTURE */ - struct gl_texture_object *CurrentTexture[NUM_TEXTURE_TARGETS]; - /** mask of TEXTURE_2D_BIT, etc */ - GLbitfield TexEnabled; - GLbitfield TexGenEnabled; - GLuint EnvMode; /* unit[0] only */ - - /** MESA_META_VIEWPORT */ - GLint ViewportX, ViewportY, ViewportW, ViewportH; - GLclampd DepthNear, DepthFar; - - /** MESA_META_SELECT_FEEDBACK */ - GLenum RenderMode; - struct gl_selection Select; - struct gl_feedback Feedback; - - /** Miscellaneous (always disabled) */ - GLboolean Lighting; - GLboolean RasterDiscard; -}; - - -/** - * State for glBlitFramebufer() - */ -struct blit_state -{ - GLuint ArrayObj; - GLuint VBO; - GLuint DepthFP; -}; - - -/** - * State for glClear() - */ -struct clear_state -{ - GLuint ArrayObj; - GLuint VBO; - GLint ColorLocation; - - GLint IntegerColorLocation; -}; - - -/** - * State for glCopyPixels() - */ -struct copypix_state -{ - GLuint ArrayObj; - GLuint VBO; -}; - -#define MAX_META_OPS_DEPTH 8 -/** - * 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 copypix_state CopyPix; /**< For _mesa_meta_CopyPixels() */ -}; - -/** - * 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) -{ - GET_CURRENT_CONTEXT(old_context); - _mesa_make_current(ctx, NULL, NULL); - if (old_context) - _mesa_make_current(old_context, old_context->WinSysDrawBuffer, old_context->WinSysReadBuffer); - else - _mesa_make_current(NULL, NULL, NULL); - 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 MESA_META_* flags indicating which attribute groups - * to save and reset to their defaults - */ -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 & MESA_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 & MESA_META_BLEND) { - save->BlendEnabled = ctx->Color.BlendEnabled; - if (ctx->Color.BlendEnabled) { - _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 & MESA_META_COLOR_MASK) { - memcpy(save->ColorMask, ctx->Color.ColorMask, - sizeof(ctx->Color.ColorMask)); - if (!ctx->Color.ColorMask[0] || - !ctx->Color.ColorMask[1] || - !ctx->Color.ColorMask[2] || - !ctx->Color.ColorMask[3]) - _mesa_ColorMask(GL_TRUE, GL_TRUE, GL_TRUE, GL_TRUE); - } - - if (state & MESA_META_DEPTH_TEST) { - save->Depth = ctx->Depth; /* struct copy */ - if (ctx->Depth.Test) - _mesa_set_enable(ctx, GL_DEPTH_TEST, GL_FALSE); - } - - if (state & MESA_META_FOG) { - save->Fog = ctx->Fog.Enabled; - if (ctx->Fog.Enabled) - _mesa_set_enable(ctx, GL_FOG, GL_FALSE); - } - - if (state & MESA_META_PIXEL_STORE) { - save->Pack = ctx->Pack; - save->Unpack = ctx->Unpack; - ctx->Pack = ctx->DefaultPacking; - ctx->Unpack = ctx->DefaultPacking; - } - - if (state & MESA_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 & MESA_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 & MESA_META_SCISSOR) { - save->Scissor = ctx->Scissor; /* struct copy */ - _mesa_set_enable(ctx, GL_SCISSOR_TEST, GL_FALSE); - } - - if (state & MESA_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 & MESA_META_TEXTURE) { - GLuint tgt; - - save->EnvMode = ctx->Texture.Unit.EnvMode; - - /* Disable all texture units */ - save->TexEnabled = ctx->Texture.Unit.Enabled; - save->TexGenEnabled = ctx->Texture.Unit.TexGenEnabled; - if (ctx->Texture.Unit.Enabled || - ctx->Texture.Unit.TexGenEnabled) { - _mesa_set_enable(ctx, GL_TEXTURE_1D, GL_FALSE); - _mesa_set_enable(ctx, GL_TEXTURE_2D, 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_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.CurrentTex[tgt]); - } - _mesa_TexEnvi(GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_REPLACE); - } - - if (state & MESA_META_TRANSFORM) { - 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.Top->m, - 16 * sizeof(GLfloat)); - save->MatrixMode = ctx->Transform.MatrixMode; - /* set 1:1 vertex:pixel coordinate transform */ - _mesa_MatrixMode(GL_TEXTURE); - _mesa_LoadIdentity(); - _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); - } - - if (state & MESA_META_CLIP) { - 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 & MESA_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 & MESA_META_SELECT_FEEDBACK) { - save->RenderMode = ctx->RenderMode; - if (ctx->RenderMode == GL_SELECT) { - save->Select = ctx->Select; /* struct copy */ - _mesa_RenderMode(GL_RENDER); - } else if (ctx->RenderMode == GL_FEEDBACK) { - save->Feedback = ctx->Feedback; /* struct copy */ - _mesa_RenderMode(GL_RENDER); - } - } - - /* misc */ - { - save->Lighting = ctx->Light.Enabled; - if (ctx->Light.Enabled) - _mesa_set_enable(ctx, GL_LIGHTING, GL_FALSE); - save->RasterDiscard = ctx->RasterDiscard; - if (ctx->RasterDiscard) - _mesa_set_enable(ctx, GL_RASTERIZER_DISCARD, GL_FALSE); - } -} - - -/** - * Leave meta state. This is like a light-weight version of glPopAttrib(). - */ -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 & MESA_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 & MESA_META_BLEND) { - if (ctx->Color.BlendEnabled != save->BlendEnabled) { - _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 & MESA_META_COLOR_MASK) { - if (!TEST_EQ_4V(ctx->Color.ColorMask, save->ColorMask)) { - _mesa_ColorMask(save->ColorMask[0], save->ColorMask[1], - save->ColorMask[2], save->ColorMask[3]); - } - } - - if (state & MESA_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 & MESA_META_FOG) { - _mesa_set_enable(ctx, GL_FOG, save->Fog); - } - - if (state & MESA_META_PIXEL_STORE) { - ctx->Pack = save->Pack; - ctx->Unpack = save->Unpack; - } - - if (state & MESA_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 & MESA_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 & MESA_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 & MESA_META_STENCIL_TEST) { - const struct gl_stencil_attrib *stencil = &save->Stencil; - - _mesa_set_enable(ctx, GL_STENCIL_TEST, stencil->Enabled); - _mesa_ClearStencil(stencil->Clear); - _mesa_StencilFunc(stencil->Function, - stencil->Ref, - stencil->ValueMask); - _mesa_StencilMask(stencil->WriteMask); - _mesa_StencilOp(stencil->FailFunc, stencil->ZFailFunc, stencil->ZPassFunc); - } - - if (state & MESA_META_TEXTURE) { - GLuint tgt; - - /* 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++) { - if (ctx->Texture.Unit.CurrentTex[tgt] != save->CurrentTexture[tgt]) { - FLUSH_VERTICES(ctx, _NEW_TEXTURE); - _mesa_reference_texobj(&ctx->Texture.Unit.CurrentTex[tgt], - save->CurrentTexture[tgt]); - } - _mesa_reference_texobj(&save->CurrentTexture[tgt], NULL); - } - - /* Restore fixed function texture enables, texgen */ - if (ctx->Texture.Unit.Enabled != save->TexEnabled) { - FLUSH_VERTICES(ctx, _NEW_TEXTURE); - ctx->Texture.Unit.Enabled = save->TexEnabled; - } - - if (ctx->Texture.Unit.TexGenEnabled != save->TexGenEnabled) { - FLUSH_VERTICES(ctx, _NEW_TEXTURE); - ctx->Texture.Unit.TexGenEnabled = save->TexGenEnabled; - } - } - - if (state & MESA_META_TRANSFORM) { - _mesa_MatrixMode(GL_TEXTURE); - _mesa_LoadMatrixf(save->TextureMatrix); - - _mesa_MatrixMode(GL_MODELVIEW); - _mesa_LoadMatrixf(save->ModelviewMatrix); - - _mesa_MatrixMode(GL_PROJECTION); - _mesa_LoadMatrixf(save->ProjectionMatrix); - - _mesa_MatrixMode(save->MatrixMode); - } - - if (state & MESA_META_CLIP) { - 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 & MESA_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); - } - - /* misc */ - if (save->Lighting) { - _mesa_set_enable(ctx, GL_LIGHTING, GL_TRUE); - } - if (save->RasterDiscard) { - _mesa_set_enable(ctx, GL_RASTERIZER_DISCARD, GL_TRUE); - } -} - - -/** - * Determine whether Mesa is currently in a meta state. - */ -GLboolean -_mesa_meta_in_progress(struct gl_context *ctx) -{ - return ctx->Meta->SaveStackDepth != 0; -} - - -/** - * 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_RG: - case GL_RED: - 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 <= 16) - return GL_UNSIGNED_SHORT; - else - return GL_FLOAT; - case GL_DEPTH_COMPONENT: - return GL_UNSIGNED_INT; - default: - _mesa_problem(ctx, "Unexpected format %d in get_temp_image_type()", - baseFormat); - return 0; - } -} - - -/** - * 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, - struct gl_texture_image *texImage, - GLint xoffset, GLint yoffset, GLint zoffset, - struct gl_renderbuffer *rb, - GLint x, GLint y, - GLsizei width, GLsizei height) -{ - struct gl_texture_object *texObj = texImage->TexObject; - const GLenum target = texObj->Target; - GLenum format, type; - GLint bpp; - void *buf; - - /* Choose format/type for temporary image buffer */ - format = _mesa_get_format_base_format(texImage->TexFormat); - if (format == GL_LUMINANCE || - format == GL_LUMINANCE_ALPHA || - format == GL_INTENSITY) { - /* We don't want to use GL_LUMINANCE, GL_INTENSITY, etc. for the - * temp image buffer because glReadPixels will do L=R+G+B which is - * not what we want (should be L=R). - */ - format = GL_RGBA; - } - - if (_mesa_is_format_integer_color(texImage->TexFormat)) { - _mesa_problem(ctx, "unsupported integer color copyteximage"); - return; - } - - 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, MESA_META_PIXEL_STORE | MESA_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, MESA_META_PIXEL_STORE); - if (target == GL_TEXTURE_1D) { - ctx->Driver.TexSubImage1D(ctx, texImage, - xoffset, width, - format, type, buf, &ctx->Unpack); - } - else { - ctx->Driver.TexSubImage2D(ctx, texImage, - xoffset, yoffset, width, height, - format, type, buf, &ctx->Unpack); - } - _mesa_meta_end(ctx); - - _mesa_lock_texture(ctx, texObj); /* re-lock */ - - free(buf); -} - - -void -_mesa_meta_CopyTexSubImage1D(struct gl_context *ctx, - struct gl_texture_image *texImage, - GLint xoffset, - struct gl_renderbuffer *rb, - GLint x, GLint y, GLsizei width) -{ - copy_tex_sub_image(ctx, 1, texImage, xoffset, 0, 0, - rb, x, y, width, 1); -} - - -void -_mesa_meta_CopyTexSubImage2D(struct gl_context *ctx, - struct gl_texture_image *texImage, - GLint xoffset, GLint yoffset, - struct gl_renderbuffer *rb, - GLint x, GLint y, - GLsizei width, GLsizei height) -{ - copy_tex_sub_image(ctx, 2, texImage, xoffset, yoffset, 0, - rb, x, y, width, height); -} - diff --git a/dll/opengl/mesa/drivers/common/meta.h b/dll/opengl/mesa/drivers/common/meta.h deleted file mode 100644 index 677ed05d3ff..00000000000 --- a/dll/opengl/mesa/drivers/common/meta.h +++ /dev/null @@ -1,90 +0,0 @@ -/* - * 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. - */ - - -#ifndef META_H -#define META_H - -#include "main/mtypes.h" - -/** - * \name Flags for meta operations - * \{ - * - * These flags are passed to _mesa_meta_begin(). - */ -#define MESA_META_ALL ~0x0 -#define MESA_META_ALPHA_TEST 0x1 -#define MESA_META_BLEND 0x2 /**< includes logicop */ -#define MESA_META_COLOR_MASK 0x4 -#define MESA_META_DEPTH_TEST 0x8 -#define MESA_META_FOG 0x10 -#define MESA_META_PIXEL_STORE 0x20 -#define MESA_META_PIXEL_TRANSFER 0x40 -#define MESA_META_RASTERIZATION 0x80 -#define MESA_META_SCISSOR 0x100 -#define MESA_META_STENCIL_TEST 0x400 -#define MESA_META_TRANSFORM 0x800 /**< modelview/projection matrix state */ -#define MESA_META_TEXTURE 0x1000 -#define MESA_META_VIEWPORT 0x4000 -#define MESA_META_CLIP 0x8000 -#define MESA_META_SELECT_FEEDBACK 0x10000 -/**\}*/ - -extern void -_mesa_meta_init(struct gl_context *ctx); - -extern void -_mesa_meta_free(struct gl_context *ctx); - -extern void -_mesa_meta_begin(struct gl_context *ctx, GLbitfield state); - -extern void -_mesa_meta_end(struct gl_context *ctx); - -extern GLboolean -_mesa_meta_in_progress(struct gl_context *ctx); - -extern void -_mesa_meta_CopyPixels(struct gl_context *ctx, GLint srcx, GLint srcy, - GLsizei width, GLsizei height, - GLint dstx, GLint dsty, GLenum type); - -extern void -_mesa_meta_CopyTexSubImage1D(struct gl_context *ctx, - struct gl_texture_image *texImage, - GLint xoffset, - struct gl_renderbuffer *rb, - GLint x, GLint y, GLsizei width); - -extern void -_mesa_meta_CopyTexSubImage2D(struct gl_context *ctx, - struct gl_texture_image *texImage, - GLint xoffset, GLint yoffset, - struct gl_renderbuffer *rb, - GLint x, GLint y, - GLsizei width, GLsizei height); - -#endif /* META_H */ diff --git a/dll/opengl/mesa/enable.c b/dll/opengl/mesa/enable.c new file mode 100644 index 00000000000..c095e2fc805 --- /dev/null +++ b/dll/opengl/mesa/enable.c @@ -0,0 +1,652 @@ +/* $Id: enable.c,v 1.23 1997/10/29 02:23:54 brianp Exp $ */ + +/* + * Mesa 3-D graphics library + * Version: 2.5 + * Copyright (C) 1995-1997 Brian Paul + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Library General Public + * License as published by the Free Software Foundation; either + * version 2 of the License, or (at your option) any later version. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Library General Public License for more details. + * + * You should have received a copy of the GNU Library General Public + * License along with this library; if not, write to the Free + * Software Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. + */ + + +/* + * $Log: enable.c,v $ + * Revision 1.23 1997/10/29 02:23:54 brianp + * added UseGlobalTexturePalette() dd function (David Bucciarelli v20 3dfx) + * + * Revision 1.22 1997/10/16 01:59:08 brianp + * added GL_EXT_shared_texture_palette extension + * + * Revision 1.21 1997/07/24 01:25:01 brianp + * changed precompiled header symbol from PCH to PC_HEADER + * + * Revision 1.20 1997/06/20 02:20:32 brianp + * replaced Current.IntColor with Current.ByteColor + * + * Revision 1.19 1997/05/31 16:57:14 brianp + * added MESA_NO_RASTER env var support + * + * Revision 1.18 1997/05/28 03:24:22 brianp + * added precompiled header (PCH) support + * + * Revision 1.17 1997/04/24 01:49:30 brianp + * call gl_set_color_function() instead of directly setting pointers + * + * Revision 1.16 1997/04/12 16:54:05 brianp + * new NEW_POLYGON state flag + * + * Revision 1.15 1997/04/12 16:20:27 brianp + * removed call to Driver.Dither() + * + * Revision 1.14 1997/04/02 03:10:36 brianp + * changed some #include's + * + * Revision 1.13 1997/02/27 19:59:08 brianp + * issue a warning if enable depth or stencil test without such a buffer + * + * Revision 1.12 1997/02/09 19:53:43 brianp + * now use TEXTURE_xD enable constants + * + * Revision 1.11 1997/02/09 18:49:37 brianp + * added GL_EXT_texture3D support + * + * Revision 1.10 1997/01/28 22:13:42 brianp + * now there's separate state for CI and RGBA logic op enabled + * + * Revision 1.9 1996/12/18 20:00:57 brianp + * gl_set_material() now takes a bitmask instead of face and pname + * + * Revision 1.8 1996/12/11 20:16:49 brianp + * more work on the GL_COLOR_MATERIAL bug + * + * Revision 1.7 1996/12/09 22:51:51 brianp + * update API Color4f and Color4ub pointers for GL_COLOR_MATERIAL + * + * Revision 1.6 1996/12/07 10:21:07 brianp + * call gl_set_material() instead of gl_Materialfv() + * + * Revision 1.5 1996/11/09 03:11:18 brianp + * added missing GL_EXT_vertex_array caps to gl_enable() + * + * Revision 1.4 1996/10/11 03:44:09 brianp + * added comments for GL_POLYGON_OFFSET_EXT symbol + * + * Revision 1.3 1996/09/27 01:26:40 brianp + * removed unused variables + * + * Revision 1.2 1996/09/15 14:17:30 brianp + * now use GLframebuffer and GLvisual + * + * Revision 1.1 1996/09/13 01:38:16 brianp + * Initial revision + * + */ + + +#ifdef PC_HEADER +#include "all.h" +#else +#include +#include "context.h" +#include "depth.h" +#include "enable.h" +#include "light.h" +#include "dlist.h" +#include "macros.h" +#include "stencil.h" +#include "types.h" +#include "vbfill.h" +#endif + + + +/* + * Perform glEnable and glDisable calls. + */ +static void gl_enable( GLcontext* ctx, GLenum cap, GLboolean state ) +{ + GLuint p; + + if (INSIDE_BEGIN_END(ctx)) { + if (state) { + gl_error( ctx, GL_INVALID_OPERATION, "glEnable" ); + } + else { + gl_error( ctx, GL_INVALID_OPERATION, "glDisable" ); + } + return; + } + + switch (cap) { + case GL_ALPHA_TEST: + if (ctx->Color.AlphaEnabled!=state) { + ctx->Color.AlphaEnabled = state; + ctx->NewState |= NEW_RASTER_OPS; + } + break; + case GL_AUTO_NORMAL: + ctx->Eval.AutoNormal = state; + break; + case GL_BLEND: + if (ctx->Color.BlendEnabled!=state) { + ctx->Color.BlendEnabled = state; + /* The following needed to accomodate 1.0 RGB logic op blending */ + ctx->Color.ColorLogicOpEnabled = GL_FALSE; + ctx->NewState |= NEW_RASTER_OPS; + } + break; + case GL_CLIP_PLANE0: + case GL_CLIP_PLANE1: + case GL_CLIP_PLANE2: + case GL_CLIP_PLANE3: + case GL_CLIP_PLANE4: + case GL_CLIP_PLANE5: + ctx->Transform.ClipEnabled[cap-GL_CLIP_PLANE0] = state; + /* Check if any clip planes enabled */ + ctx->Transform.AnyClip = GL_FALSE; + for (p=0;pTransform.ClipEnabled[p]) { + ctx->Transform.AnyClip = GL_TRUE; + break; + } + } + break; + case GL_COLOR_MATERIAL: + if (ctx->Light.ColorMaterialEnabled!=state) { + ctx->Light.ColorMaterialEnabled = state; + if (state) { + GLfloat color[4]; + color[0] = ctx->Current.ByteColor[0] * ctx->Visual->InvRedScale; + color[1] = ctx->Current.ByteColor[1] * ctx->Visual->InvGreenScale; + color[2] = ctx->Current.ByteColor[2] * ctx->Visual->InvBlueScale; + color[3] = ctx->Current.ByteColor[3] * ctx->Visual->InvAlphaScale; + /* update material with current color */ + gl_set_material( ctx, ctx->Light.ColorMaterialBitmask, color ); + } + gl_set_color_function(ctx); + ctx->NewState |= NEW_LIGHTING; + } + break; + case GL_CULL_FACE: + if (ctx->Polygon.CullFlag!=state) { + ctx->Polygon.CullFlag = state; + ctx->NewState |= NEW_POLYGON; + } + break; + case GL_DEPTH_TEST: + if (state && ctx->Visual->DepthBits==0) { + gl_warning(ctx,"glEnable(GL_DEPTH_TEST) but no depth buffer"); + return; + } + if (ctx->Depth.Test!=state) { + ctx->Depth.Test = state; + ctx->NewState |= NEW_RASTER_OPS; + } + break; + case GL_DITHER: + if (ctx->NoDither) { + /* MESA_NO_DITHER env var */ + state = GL_FALSE; + } + if (ctx->Color.DitherFlag!=state) { + ctx->Color.DitherFlag = state; + ctx->NewState |= NEW_RASTER_OPS; + } + break; + case GL_FOG: + if (ctx->Fog.Enabled!=state) { + ctx->Fog.Enabled = state; + ctx->NewState |= NEW_RASTER_OPS; + } + break; + case GL_LIGHT0: + case GL_LIGHT1: + case GL_LIGHT2: + case GL_LIGHT3: + case GL_LIGHT4: + case GL_LIGHT5: + case GL_LIGHT6: + case GL_LIGHT7: + ctx->Light.Light[cap-GL_LIGHT0].Enabled = state; + ctx->NewState |= NEW_LIGHTING; + break; + case GL_LIGHTING: + if (ctx->Light.Enabled!=state) { + ctx->Light.Enabled = state; + ctx->NewState |= NEW_LIGHTING; + } + break; + case GL_LINE_SMOOTH: + if (ctx->Line.SmoothFlag!=state) { + ctx->Line.SmoothFlag = state; + ctx->NewState |= NEW_RASTER_OPS; + } + break; + case GL_LINE_STIPPLE: + if (ctx->Line.StippleFlag!=state) { + ctx->Line.StippleFlag = state; + ctx->NewState |= NEW_RASTER_OPS; + } + break; + case GL_INDEX_LOGIC_OP: + if (ctx->Color.IndexLogicOpEnabled!=state) { + ctx->NewState |= NEW_RASTER_OPS; + } + ctx->Color.IndexLogicOpEnabled = state; + break; + case GL_COLOR_LOGIC_OP: + if (ctx->Color.ColorLogicOpEnabled!=state) { + ctx->NewState |= NEW_RASTER_OPS; + } + ctx->Color.ColorLogicOpEnabled = state; + break; + case GL_MAP1_COLOR_4: + ctx->Eval.Map1Color4 = state; + break; + case GL_MAP1_INDEX: + ctx->Eval.Map1Index = state; + break; + case GL_MAP1_NORMAL: + ctx->Eval.Map1Normal = state; + break; + case GL_MAP1_TEXTURE_COORD_1: + ctx->Eval.Map1TextureCoord1 = state; + break; + case GL_MAP1_TEXTURE_COORD_2: + ctx->Eval.Map1TextureCoord2 = state; + break; + case GL_MAP1_TEXTURE_COORD_3: + ctx->Eval.Map1TextureCoord3 = state; + break; + case GL_MAP1_TEXTURE_COORD_4: + ctx->Eval.Map1TextureCoord4 = state; + break; + case GL_MAP1_VERTEX_3: + ctx->Eval.Map1Vertex3 = state; + break; + case GL_MAP1_VERTEX_4: + ctx->Eval.Map1Vertex4 = state; + break; + case GL_MAP2_COLOR_4: + ctx->Eval.Map2Color4 = state; + break; + case GL_MAP2_INDEX: + ctx->Eval.Map2Index = state; + break; + case GL_MAP2_NORMAL: + ctx->Eval.Map2Normal = state; + break; + case GL_MAP2_TEXTURE_COORD_1: + ctx->Eval.Map2TextureCoord1 = state; + break; + case GL_MAP2_TEXTURE_COORD_2: + ctx->Eval.Map2TextureCoord2 = state; + break; + case GL_MAP2_TEXTURE_COORD_3: + ctx->Eval.Map2TextureCoord3 = state; + break; + case GL_MAP2_TEXTURE_COORD_4: + ctx->Eval.Map2TextureCoord4 = state; + break; + case GL_MAP2_VERTEX_3: + ctx->Eval.Map2Vertex3 = state; + break; + case GL_MAP2_VERTEX_4: + ctx->Eval.Map2Vertex4 = state; + break; + case GL_NORMALIZE: + ctx->Transform.Normalize = state; + break; + case GL_POINT_SMOOTH: + if (ctx->Point.SmoothFlag!=state) { + ctx->Point.SmoothFlag = state; + ctx->NewState |= NEW_RASTER_OPS; + } + break; + case GL_POLYGON_SMOOTH: + if (ctx->Polygon.SmoothFlag!=state) { + ctx->Polygon.SmoothFlag = state; + ctx->NewState |= NEW_RASTER_OPS; + } + break; + case GL_POLYGON_STIPPLE: + if (ctx->Polygon.StippleFlag!=state) { + ctx->Polygon.StippleFlag = state; + ctx->NewState |= NEW_RASTER_OPS; + } + break; + case GL_POLYGON_OFFSET_POINT: + if (ctx->Polygon.OffsetPoint!=state) { + ctx->Polygon.OffsetPoint = state; + ctx->NewState |= NEW_POLYGON; + } + break; + case GL_POLYGON_OFFSET_LINE: + if (ctx->Polygon.OffsetLine!=state) { + ctx->Polygon.OffsetLine = state; + ctx->NewState |= NEW_POLYGON; + } + break; + case GL_POLYGON_OFFSET_FILL: + /*case GL_POLYGON_OFFSET_EXT:*/ + if (ctx->Polygon.OffsetFill!=state) { + ctx->Polygon.OffsetFill = state; + ctx->NewState |= NEW_POLYGON; + } + break; + case GL_SCISSOR_TEST: + if (ctx->Scissor.Enabled!=state) { + ctx->Scissor.Enabled = state; + ctx->NewState |= NEW_RASTER_OPS; + } + break; + case GL_STENCIL_TEST: + if (state && ctx->Visual->StencilBits==0) { + gl_warning(ctx, "glEnable(GL_STENCIL_TEST) but no stencil buffer"); + return; + } + if (ctx->Stencil.Enabled!=state) { + ctx->Stencil.Enabled = state; + ctx->NewState |= NEW_RASTER_OPS; + } + break; + case GL_TEXTURE_1D: + if (ctx->Visual->RGBAflag) { + /* texturing only works in RGB mode */ + if (state) { + ctx->Texture.Enabled |= TEXTURE_1D; + } + else { + ctx->Texture.Enabled &= (~TEXTURE_1D); + } + ctx->NewState |= (NEW_RASTER_OPS | NEW_TEXTURING); + } + break; + case GL_TEXTURE_2D: + if (ctx->Visual->RGBAflag) { + /* texturing only works in RGB mode */ + if (state) { + ctx->Texture.Enabled |= TEXTURE_2D; + } + else { + ctx->Texture.Enabled &= (~TEXTURE_2D); + } + ctx->NewState |= (NEW_RASTER_OPS | NEW_TEXTURING); + } + break; + case GL_TEXTURE_GEN_Q: + if (state) { + ctx->Texture.TexGenEnabled |= Q_BIT; + } + else { + ctx->Texture.TexGenEnabled &= ~Q_BIT; + } + ctx->NewState |= NEW_TEXTURING; + break; + case GL_TEXTURE_GEN_R: + if (state) { + ctx->Texture.TexGenEnabled |= R_BIT; + } + else { + ctx->Texture.TexGenEnabled &= ~R_BIT; + } + ctx->NewState |= NEW_TEXTURING; + break; + case GL_TEXTURE_GEN_S: + if (state) { + ctx->Texture.TexGenEnabled |= S_BIT; + } + else { + ctx->Texture.TexGenEnabled &= ~S_BIT; + } + ctx->NewState |= NEW_TEXTURING; + break; + case GL_TEXTURE_GEN_T: + if (state) { + ctx->Texture.TexGenEnabled |= T_BIT; + } + else { + ctx->Texture.TexGenEnabled &= ~T_BIT; + } + ctx->NewState |= NEW_TEXTURING; + break; + + /* + * CLIENT STATE!!! + */ + case GL_VERTEX_ARRAY: + ctx->Array.VertexEnabled = state; + break; + case GL_NORMAL_ARRAY: + ctx->Array.NormalEnabled = state; + break; + case GL_COLOR_ARRAY: + ctx->Array.ColorEnabled = state; + break; + case GL_INDEX_ARRAY: + ctx->Array.IndexEnabled = state; + break; + case GL_TEXTURE_COORD_ARRAY: + ctx->Array.TexCoordEnabled = state; + break; + case GL_EDGE_FLAG_ARRAY: + ctx->Array.EdgeFlagEnabled = state; + break; + + default: + if (state) { + gl_error( ctx, GL_INVALID_ENUM, "glEnable" ); + } + else { + gl_error( ctx, GL_INVALID_ENUM, "glDisable" ); + } + break; + } +} + + + + +void gl_Enable( GLcontext* ctx, GLenum cap ) +{ + gl_enable( ctx, cap, GL_TRUE ); +} + + + +void gl_Disable( GLcontext* ctx, GLenum cap ) +{ + gl_enable( ctx, cap, GL_FALSE ); +} + + + +GLboolean gl_IsEnabled( GLcontext* ctx, GLenum cap ) +{ + switch (cap) { + case GL_ALPHA_TEST: + return ctx->Color.AlphaEnabled; + case GL_AUTO_NORMAL: + return ctx->Eval.AutoNormal; + case GL_BLEND: + return ctx->Color.BlendEnabled; + case GL_CLIP_PLANE0: + case GL_CLIP_PLANE1: + case GL_CLIP_PLANE2: + case GL_CLIP_PLANE3: + case GL_CLIP_PLANE4: + case GL_CLIP_PLANE5: + return ctx->Transform.ClipEnabled[cap-GL_CLIP_PLANE0]; + case GL_COLOR_MATERIAL: + return ctx->Light.ColorMaterialEnabled; + case GL_CULL_FACE: + return ctx->Polygon.CullFlag; + case GL_DEPTH_TEST: + return ctx->Depth.Test; + case GL_DITHER: + return ctx->Color.DitherFlag; + case GL_FOG: + return ctx->Fog.Enabled; + case GL_LIGHTING: + return ctx->Light.Enabled; + case GL_LIGHT0: + case GL_LIGHT1: + case GL_LIGHT2: + case GL_LIGHT3: + case GL_LIGHT4: + case GL_LIGHT5: + case GL_LIGHT6: + case GL_LIGHT7: + return ctx->Light.Light[cap-GL_LIGHT0].Enabled; + case GL_LINE_SMOOTH: + return ctx->Line.SmoothFlag; + case GL_LINE_STIPPLE: + return ctx->Line.StippleFlag; + case GL_INDEX_LOGIC_OP: + return ctx->Color.IndexLogicOpEnabled; + case GL_COLOR_LOGIC_OP: + return ctx->Color.ColorLogicOpEnabled; + case GL_MAP1_COLOR_4: + return ctx->Eval.Map1Color4; + case GL_MAP1_INDEX: + return ctx->Eval.Map1Index; + case GL_MAP1_NORMAL: + return ctx->Eval.Map1Normal; + case GL_MAP1_TEXTURE_COORD_1: + return ctx->Eval.Map1TextureCoord1; + case GL_MAP1_TEXTURE_COORD_2: + return ctx->Eval.Map1TextureCoord2; + case GL_MAP1_TEXTURE_COORD_3: + return ctx->Eval.Map1TextureCoord3; + case GL_MAP1_TEXTURE_COORD_4: + return ctx->Eval.Map1TextureCoord4; + case GL_MAP1_VERTEX_3: + return ctx->Eval.Map1Vertex3; + case GL_MAP1_VERTEX_4: + return ctx->Eval.Map1Vertex4; + case GL_MAP2_COLOR_4: + return ctx->Eval.Map2Color4; + case GL_MAP2_INDEX: + return ctx->Eval.Map2Index; + case GL_MAP2_NORMAL: + return ctx->Eval.Map2Normal; + case GL_MAP2_TEXTURE_COORD_1: + return ctx->Eval.Map2TextureCoord1; + case GL_MAP2_TEXTURE_COORD_2: + return ctx->Eval.Map2TextureCoord2; + case GL_MAP2_TEXTURE_COORD_3: + return ctx->Eval.Map2TextureCoord3; + case GL_MAP2_TEXTURE_COORD_4: + return ctx->Eval.Map2TextureCoord4; + case GL_MAP2_VERTEX_3: + return ctx->Eval.Map2Vertex3; + case GL_MAP2_VERTEX_4: + return ctx->Eval.Map2Vertex4; + case GL_NORMALIZE: + return ctx->Transform.Normalize; + case GL_POINT_SMOOTH: + return ctx->Point.SmoothFlag; + case GL_POLYGON_SMOOTH: + return ctx->Polygon.SmoothFlag; + case GL_POLYGON_STIPPLE: + return ctx->Polygon.StippleFlag; + case GL_POLYGON_OFFSET_POINT: + return ctx->Polygon.OffsetPoint; + case GL_POLYGON_OFFSET_LINE: + return ctx->Polygon.OffsetLine; + case GL_POLYGON_OFFSET_FILL: + /*case GL_POLYGON_OFFSET_EXT:*/ + return ctx->Polygon.OffsetFill; + case GL_SCISSOR_TEST: + return ctx->Scissor.Enabled; + case GL_STENCIL_TEST: + return ctx->Stencil.Enabled; + case GL_TEXTURE_1D: + return (ctx->Texture.Enabled & TEXTURE_1D) ? GL_TRUE : GL_FALSE; + case GL_TEXTURE_2D: + return (ctx->Texture.Enabled & TEXTURE_2D) ? GL_TRUE : GL_FALSE; + case GL_TEXTURE_GEN_Q: + return (ctx->Texture.TexGenEnabled & Q_BIT) ? GL_TRUE : GL_FALSE; + case GL_TEXTURE_GEN_R: + return (ctx->Texture.TexGenEnabled & R_BIT) ? GL_TRUE : GL_FALSE; + case GL_TEXTURE_GEN_S: + return (ctx->Texture.TexGenEnabled & S_BIT) ? GL_TRUE : GL_FALSE; + case GL_TEXTURE_GEN_T: + return (ctx->Texture.TexGenEnabled & T_BIT) ? GL_TRUE : GL_FALSE; + + /* + * CLIENT STATE!!! + */ + case GL_VERTEX_ARRAY: + return ctx->Array.VertexEnabled; + case GL_NORMAL_ARRAY: + return ctx->Array.NormalEnabled; + case GL_COLOR_ARRAY: + return ctx->Array.ColorEnabled; + case GL_INDEX_ARRAY: + return ctx->Array.IndexEnabled; + case GL_TEXTURE_COORD_ARRAY: + return ctx->Array.TexCoordEnabled; + case GL_EDGE_FLAG_ARRAY: + return ctx->Array.EdgeFlagEnabled; + default: + gl_error( ctx, GL_INVALID_ENUM, "glIsEnabled" ); + return GL_FALSE; + } +} + + + + +void gl_client_state( GLcontext *ctx, GLenum cap, GLboolean state ) +{ + switch (cap) { + case GL_VERTEX_ARRAY: + ctx->Array.VertexEnabled = state; + break; + case GL_NORMAL_ARRAY: + ctx->Array.NormalEnabled = state; + break; + case GL_COLOR_ARRAY: + ctx->Array.ColorEnabled = state; + break; + case GL_INDEX_ARRAY: + ctx->Array.IndexEnabled = state; + break; + case GL_TEXTURE_COORD_ARRAY: + ctx->Array.TexCoordEnabled = state; + break; + case GL_EDGE_FLAG_ARRAY: + ctx->Array.EdgeFlagEnabled = state; + break; + default: + gl_error( ctx, GL_INVALID_ENUM, "glEnable/DisableClientState" ); + } +} + + + +void gl_EnableClientState( GLcontext *ctx, GLenum cap ) +{ + gl_client_state( ctx, cap, GL_TRUE ); +} + + + +void gl_DisableClientState( GLcontext *ctx, GLenum cap ) +{ + gl_client_state( ctx, cap, GL_FALSE ); +} + diff --git a/dll/opengl/mesa/enable.h b/dll/opengl/mesa/enable.h new file mode 100644 index 00000000000..722ea5de1dd --- /dev/null +++ b/dll/opengl/mesa/enable.h @@ -0,0 +1,50 @@ +/* $Id: enable.h,v 1.1 1996/09/13 01:38:16 brianp Exp $ */ + +/* + * Mesa 3-D graphics library + * Version: 2.0 + * Copyright (C) 1995-1996 Brian Paul + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Library General Public + * License as published by the Free Software Foundation; either + * version 2 of the License, or (at your option) any later version. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Library General Public License for more details. + * + * You should have received a copy of the GNU Library General Public + * License along with this library; if not, write to the Free + * Software Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. + */ + + +/* + * $Log: enable.h,v $ + * Revision 1.1 1996/09/13 01:38:16 brianp + * Initial revision + * + */ + + +#ifndef ENABLE_H +#define ENABLE_H + + +#include "types.h" + + +extern void gl_Disable( GLcontext* ctx, GLenum cap ); + +extern void gl_Enable( GLcontext* ctx, GLenum cap ); + +extern GLboolean gl_IsEnabled( GLcontext* ctx, GLenum cap ); + +extern void gl_EnableClientState( GLcontext *ctx, GLenum cap ); + +extern void gl_DisableClientState( GLcontext *ctx, GLenum cap ); + + +#endif diff --git a/dll/opengl/mesa/eval.c b/dll/opengl/mesa/eval.c new file mode 100644 index 00000000000..dbb34b031bb --- /dev/null +++ b/dll/opengl/mesa/eval.c @@ -0,0 +1,2466 @@ +/* $Id: eval.c,v 1.9 1998/02/03 00:53:51 brianp Exp $ */ + +/* + * Mesa 3-D graphics library + * Version: 2.6 + * Copyright (C) 1995-1997 Brian Paul + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Library General Public + * License as published by the Free Software Foundation; either + * version 2 of the License, or (at your option) any later version. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Library General Public License for more details. + * + * You should have received a copy of the GNU Library General Public + * License along with this library; if not, write to the Free + * Software Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. + */ + + +/* + * $Log: eval.c,v $ + * Revision 1.9 1998/02/03 00:53:51 brianp + * fixed bug in gl_copy_map_points*() functions (Sam Jordan) + * + * Revision 1.8 1997/07/24 01:25:01 brianp + * changed precompiled header symbol from PCH to PC_HEADER + * + * Revision 1.7 1997/06/20 01:58:47 brianp + * changed color components from GLfixed to GLubyte + * + * Revision 1.6 1997/05/28 03:24:22 brianp + * added precompiled header (PCH) support + * + * Revision 1.5 1997/05/14 03:27:04 brianp + * removed context argument from gl_init_eval() + * + * Revision 1.4 1997/05/01 01:38:38 brianp + * use NORMALIZE_3FV() from mmath.h instead of private NORMALIZE() macro + * + * Revision 1.3 1997/04/02 03:10:58 brianp + * changed some #include's + * + * Revision 1.2 1996/09/15 14:17:30 brianp + * now use GLframebuffer and GLvisual + * + * Revision 1.1 1996/09/13 01:38:16 brianp + * Initial revision + * + */ + + +/* + * eval.c was written by + * Bernd Barsuhn (bdbarsuh@cip.informatik.uni-erlangen.de) and + * Volker Weiss (vrweiss@cip.informatik.uni-erlangen.de). + * + * My original implementation of evaluators was simplistic and didn't + * compute surface normal vectors properly. Bernd and Volker applied + * used more sophisticated methods to get better results. + * + * Thanks guys! + */ + + +#ifdef PC_HEADER +#include "all.h" +#else +#include +#include +#include +#include "context.h" +#include "eval.h" +#include "dlist.h" +#include "macros.h" +#include "mmath.h" +#include "types.h" +#include "vbfill.h" +#endif + + + +/* + * Do one-time initialization for evaluators. + */ +void gl_init_eval( void ) +{ + static int init_flag = 0; + + /* Compute a table of nCr (combination) values used by the + * Bernstein polynomial generator. + */ + + if (init_flag==0) + { /* no initialization needed */ + } + + init_flag = 1; +} + + + +/* + * Horner scheme for Bezier curves + * + * Bezier curves can be computed via a Horner scheme. + * Horner is numerically less stable than the de Casteljau + * algorithm, but it is faster. For curves of degree n + * the complexity of Horner is O(n) and de Casteljau is O(n^2). + * Since stability is not important for displaying curve + * points I decided to use the Horner scheme. + * + * A cubic Bezier curve with control points b0, b1, b2, b3 can be + * written as + * + * (([3] [3] ) [3] ) [3] + * c(t) = (([0]*s*b0 + [1]*t*b1)*s + [2]*t^2*b2)*s + [3]*t^2*b3 + * + * [n] + * where s=1-t and the binomial coefficients [i]. These can + * be computed iteratively using the identity: + * + * [n] [n ] [n] + * [i] = (n-i+1)/i * [i-1] and [0] = 1 + */ + +static void +horner_bezier_curve(GLfloat *cp, GLfloat *out, GLfloat t, + GLuint dim, GLuint order) +{ + GLfloat s, powert; + GLuint i, k, bincoeff; + + if(order >= 2) + { + bincoeff = order-1; + s = 1.0-t; + + for(k=0; k constant curve */ + { + for(k=0; k uorder) + { + if(uorder >= 2) + { + GLfloat s, poweru; + GLuint j, k, bincoeff; + + /* Compute the control polygon for the surface-curve in u-direction */ + for(j=0; j cn defines a curve in v */ + horner_bezier_curve(cn, out, v, dim, vorder); + } + else /* vorder <= uorder */ + { + if(vorder > 1) + { + GLuint i; + + /* Compute the control polygon for the surface-curve in u-direction */ + for(i=0; i cn defines a curve in u */ + horner_bezier_curve(cn, out, u, dim, uorder); + } +} + +/* + * The direct de Casteljau algorithm is used when a point on the + * surface and the tangent directions spanning the tangent plane + * should be computed (this is needed to compute normals to the + * surface). In this case the de Casteljau algorithm approach is + * nicer because a point and the partial derivatives can be computed + * at the same time. To get the correct tangent length du and dv + * must be multiplied with the (u2-u1)/uorder-1 and (v2-v1)/vorder-1. + * Since only the directions are needed, this scaling step is omitted. + * + * De Casteljau needs additional storage for uorder*vorder + * values in the control net cn. + */ + +static void +de_casteljau_surf(GLfloat *cn, GLfloat *out, GLfloat *du, GLfloat *dv, + GLfloat u, GLfloat v, GLuint dim, + GLuint uorder, GLuint vorder) +{ + GLfloat *dcn = cn + uorder*vorder*dim; + GLfloat us = 1.0-u, vs = 1.0-v; + GLuint h, i, j, k; + GLuint minorder = uorder < vorder ? uorder : vorder; + GLuint uinc = vorder*dim; + GLuint dcuinc = vorder; + + /* Each component is evaluated separately to save buffer space */ + /* This does not drasticaly decrease the performance of the */ + /* algorithm. If additional storage for (uorder-1)*(vorder-1) */ + /* points would be available, the components could be accessed */ + /* in the innermost loop which could lead to less cache misses. */ + +#define CN(I,J,K) cn[(I)*uinc+(J)*dim+(K)] +#define DCN(I, J) dcn[(I)*dcuinc+(J)] + if(minorder < 3) + { + if(uorder==vorder) + { + for(k=0; k vorder ? uorder : vorder)*size; + + if(hsize>dsize) + buffer = (GLfloat *) malloc((uorder*vorder*size+hsize)*sizeof(GLfloat)); + else + buffer = (GLfloat *) malloc((uorder*vorder*size+dsize)*sizeof(GLfloat)); + + /* compute the increment value for the u-loop */ + uinc = ustride - vorder*vstride; + + if (buffer) + for (i=0, p=buffer; i vorder ? uorder : vorder)*size; + + if(hsize>dsize) + buffer = (GLfloat *) malloc((uorder*vorder*size+hsize)*sizeof(GLfloat)); + else + buffer = (GLfloat *) malloc((uorder*vorder*size+dsize)*sizeof(GLfloat)); + + /* compute the increment value for the u-loop */ + uinc = ustride - vorder*vstride; + + if (buffer) + for (i=0, p=buffer; iEvalMap.Map1Vertex3; + break; + case GL_MAP1_VERTEX_4: + map1 = &ctx->EvalMap.Map1Vertex4; + break; + case GL_MAP1_INDEX: + map1 = &ctx->EvalMap.Map1Index; + break; + case GL_MAP1_COLOR_4: + map1 = &ctx->EvalMap.Map1Color4; + break; + case GL_MAP1_NORMAL: + map1 = &ctx->EvalMap.Map1Normal; + break; + case GL_MAP1_TEXTURE_COORD_1: + map1 = &ctx->EvalMap.Map1Texture1; + break; + case GL_MAP1_TEXTURE_COORD_2: + map1 = &ctx->EvalMap.Map1Texture2; + break; + case GL_MAP1_TEXTURE_COORD_3: + map1 = &ctx->EvalMap.Map1Texture3; + break; + case GL_MAP1_TEXTURE_COORD_4: + map1 = &ctx->EvalMap.Map1Texture4; + break; + case GL_MAP2_VERTEX_3: + map2 = &ctx->EvalMap.Map2Vertex3; + break; + case GL_MAP2_VERTEX_4: + map2 = &ctx->EvalMap.Map2Vertex4; + break; + case GL_MAP2_INDEX: + map2 = &ctx->EvalMap.Map2Index; + break; + case GL_MAP2_COLOR_4: + map2 = &ctx->EvalMap.Map2Color4; + break; + case GL_MAP2_NORMAL: + map2 = &ctx->EvalMap.Map2Normal; + break; + case GL_MAP2_TEXTURE_COORD_1: + map2 = &ctx->EvalMap.Map2Texture1; + break; + case GL_MAP2_TEXTURE_COORD_2: + map2 = &ctx->EvalMap.Map2Texture2; + break; + case GL_MAP2_TEXTURE_COORD_3: + map2 = &ctx->EvalMap.Map2Texture3; + break; + case GL_MAP2_TEXTURE_COORD_4: + map2 = &ctx->EvalMap.Map2Texture4; + break; + default: + gl_error( ctx, GL_INVALID_ENUM, "gl_free_control_points" ); + return; + } + + if (map1) { + if (data==map1->Points) { + /* The control points in the display list are currently */ + /* being used so we can mark them as discard-able. */ + map1->Retain = GL_FALSE; + } + else { + /* The control points in the display list are not currently */ + /* being used. */ + free( data ); + } + } + if (map2) { + if (data==map2->Points) { + /* The control points in the display list are currently */ + /* being used so we can mark them as discard-able. */ + map2->Retain = GL_FALSE; + } + else { + /* The control points in the display list are not currently */ + /* being used. */ + free( data ); + } + } + +} + + + +/**********************************************************************/ +/*** API entry points ***/ +/**********************************************************************/ + + +/* + * Note that the array of control points must be 'unpacked' at this time. + * Input: retain - if TRUE, this control point data is also in a display + * list and can't be freed until the list is freed. + */ +void gl_Map1f( GLcontext* ctx, GLenum target, + GLfloat u1, GLfloat u2, GLint stride, + GLint order, const GLfloat *points, GLboolean retain ) +{ + GLuint k; + + if (!points) { + gl_error( ctx, GL_OUT_OF_MEMORY, "glMap1f" ); + return; + } + + /* may be a new stride after copying control points */ + stride = components( target ); + + if (INSIDE_BEGIN_END(ctx)) { + gl_error( ctx, GL_INVALID_OPERATION, "glMap1" ); + return; + } + + if (u1==u2) { + gl_error( ctx, GL_INVALID_VALUE, "glMap1(u1,u2)" ); + return; + } + + if (order<1 || order>MAX_EVAL_ORDER) { + gl_error( ctx, GL_INVALID_VALUE, "glMap1(order)" ); + return; + } + + k = components( target ); + if (k==0) { + gl_error( ctx, GL_INVALID_ENUM, "glMap1(target)" ); + } + + if (stride < k) { + gl_error( ctx, GL_INVALID_VALUE, "glMap1(stride)" ); + return; + } + + switch (target) { + case GL_MAP1_VERTEX_3: + ctx->EvalMap.Map1Vertex3.Order = order; + ctx->EvalMap.Map1Vertex3.u1 = u1; + ctx->EvalMap.Map1Vertex3.u2 = u2; + if (ctx->EvalMap.Map1Vertex3.Points + && !ctx->EvalMap.Map1Vertex3.Retain) { + free( ctx->EvalMap.Map1Vertex3.Points ); + } + ctx->EvalMap.Map1Vertex3.Points = (GLfloat *) points; + ctx->EvalMap.Map1Vertex3.Retain = retain; + break; + case GL_MAP1_VERTEX_4: + ctx->EvalMap.Map1Vertex4.Order = order; + ctx->EvalMap.Map1Vertex4.u1 = u1; + ctx->EvalMap.Map1Vertex4.u2 = u2; + if (ctx->EvalMap.Map1Vertex4.Points + && !ctx->EvalMap.Map1Vertex4.Retain) { + free( ctx->EvalMap.Map1Vertex4.Points ); + } + ctx->EvalMap.Map1Vertex4.Points = (GLfloat *) points; + ctx->EvalMap.Map1Vertex4.Retain = retain; + break; + case GL_MAP1_INDEX: + ctx->EvalMap.Map1Index.Order = order; + ctx->EvalMap.Map1Index.u1 = u1; + ctx->EvalMap.Map1Index.u2 = u2; + if (ctx->EvalMap.Map1Index.Points + && !ctx->EvalMap.Map1Index.Retain) { + free( ctx->EvalMap.Map1Index.Points ); + } + ctx->EvalMap.Map1Index.Points = (GLfloat *) points; + ctx->EvalMap.Map1Index.Retain = retain; + break; + case GL_MAP1_COLOR_4: + ctx->EvalMap.Map1Color4.Order = order; + ctx->EvalMap.Map1Color4.u1 = u1; + ctx->EvalMap.Map1Color4.u2 = u2; + if (ctx->EvalMap.Map1Color4.Points + && !ctx->EvalMap.Map1Color4.Retain) { + free( ctx->EvalMap.Map1Color4.Points ); + } + ctx->EvalMap.Map1Color4.Points = (GLfloat *) points; + ctx->EvalMap.Map1Color4.Retain = retain; + break; + case GL_MAP1_NORMAL: + ctx->EvalMap.Map1Normal.Order = order; + ctx->EvalMap.Map1Normal.u1 = u1; + ctx->EvalMap.Map1Normal.u2 = u2; + if (ctx->EvalMap.Map1Normal.Points + && !ctx->EvalMap.Map1Normal.Retain) { + free( ctx->EvalMap.Map1Normal.Points ); + } + ctx->EvalMap.Map1Normal.Points = (GLfloat *) points; + ctx->EvalMap.Map1Normal.Retain = retain; + break; + case GL_MAP1_TEXTURE_COORD_1: + ctx->EvalMap.Map1Texture1.Order = order; + ctx->EvalMap.Map1Texture1.u1 = u1; + ctx->EvalMap.Map1Texture1.u2 = u2; + if (ctx->EvalMap.Map1Texture1.Points + && !ctx->EvalMap.Map1Texture1.Retain) { + free( ctx->EvalMap.Map1Texture1.Points ); + } + ctx->EvalMap.Map1Texture1.Points = (GLfloat *) points; + ctx->EvalMap.Map1Texture1.Retain = retain; + break; + case GL_MAP1_TEXTURE_COORD_2: + ctx->EvalMap.Map1Texture2.Order = order; + ctx->EvalMap.Map1Texture2.u1 = u1; + ctx->EvalMap.Map1Texture2.u2 = u2; + if (ctx->EvalMap.Map1Texture2.Points + && !ctx->EvalMap.Map1Texture2.Retain) { + free( ctx->EvalMap.Map1Texture2.Points ); + } + ctx->EvalMap.Map1Texture2.Points = (GLfloat *) points; + ctx->EvalMap.Map1Texture2.Retain = retain; + break; + case GL_MAP1_TEXTURE_COORD_3: + ctx->EvalMap.Map1Texture3.Order = order; + ctx->EvalMap.Map1Texture3.u1 = u1; + ctx->EvalMap.Map1Texture3.u2 = u2; + if (ctx->EvalMap.Map1Texture3.Points + && !ctx->EvalMap.Map1Texture3.Retain) { + free( ctx->EvalMap.Map1Texture3.Points ); + } + ctx->EvalMap.Map1Texture3.Points = (GLfloat *) points; + ctx->EvalMap.Map1Texture3.Retain = retain; + break; + case GL_MAP1_TEXTURE_COORD_4: + ctx->EvalMap.Map1Texture4.Order = order; + ctx->EvalMap.Map1Texture4.u1 = u1; + ctx->EvalMap.Map1Texture4.u2 = u2; + if (ctx->EvalMap.Map1Texture4.Points + && !ctx->EvalMap.Map1Texture4.Retain) { + free( ctx->EvalMap.Map1Texture4.Points ); + } + ctx->EvalMap.Map1Texture4.Points = (GLfloat *) points; + ctx->EvalMap.Map1Texture4.Retain = retain; + break; + default: + gl_error( ctx, GL_INVALID_ENUM, "glMap1(target)" ); + } +} + + + + +/* + * Note that the array of control points must be 'unpacked' at this time. + * Input: retain - if TRUE, this control point data is also in a display + * list and can't be freed until the list is freed. + */ +void gl_Map2f( GLcontext* ctx, GLenum target, + GLfloat u1, GLfloat u2, GLint ustride, GLint uorder, + GLfloat v1, GLfloat v2, GLint vstride, GLint vorder, + const GLfloat *points, GLboolean retain ) +{ + GLuint k; + + if (INSIDE_BEGIN_END(ctx)) { + gl_error( ctx, GL_INVALID_OPERATION, "glMap2" ); + return; + } + + if (u1==u2) { + gl_error( ctx, GL_INVALID_VALUE, "glMap2(u1,u2)" ); + return; + } + + if (v1==v2) { + gl_error( ctx, GL_INVALID_VALUE, "glMap2(v1,v2)" ); + return; + } + + if (uorder<1 || uorder>MAX_EVAL_ORDER) { + gl_error( ctx, GL_INVALID_VALUE, "glMap2(uorder)" ); + return; + } + + if (vorder<1 || vorder>MAX_EVAL_ORDER) { + gl_error( ctx, GL_INVALID_VALUE, "glMap2(vorder)" ); + return; + } + + k = components( target ); + if (k==0) { + gl_error( ctx, GL_INVALID_ENUM, "glMap2(target)" ); + } + + if (ustride < k) { + gl_error( ctx, GL_INVALID_VALUE, "glMap2(ustride)" ); + return; + } + if (vstride < k) { + gl_error( ctx, GL_INVALID_VALUE, "glMap2(vstride)" ); + return; + } + + switch (target) { + case GL_MAP2_VERTEX_3: + ctx->EvalMap.Map2Vertex3.Uorder = uorder; + ctx->EvalMap.Map2Vertex3.u1 = u1; + ctx->EvalMap.Map2Vertex3.u2 = u2; + ctx->EvalMap.Map2Vertex3.Vorder = vorder; + ctx->EvalMap.Map2Vertex3.v1 = v1; + ctx->EvalMap.Map2Vertex3.v2 = v2; + if (ctx->EvalMap.Map2Vertex3.Points + && !ctx->EvalMap.Map2Vertex3.Retain) { + free( ctx->EvalMap.Map2Vertex3.Points ); + } + ctx->EvalMap.Map2Vertex3.Retain = retain; + ctx->EvalMap.Map2Vertex3.Points = (GLfloat *) points; + break; + case GL_MAP2_VERTEX_4: + ctx->EvalMap.Map2Vertex4.Uorder = uorder; + ctx->EvalMap.Map2Vertex4.u1 = u1; + ctx->EvalMap.Map2Vertex4.u2 = u2; + ctx->EvalMap.Map2Vertex4.Vorder = vorder; + ctx->EvalMap.Map2Vertex4.v1 = v1; + ctx->EvalMap.Map2Vertex4.v2 = v2; + if (ctx->EvalMap.Map2Vertex4.Points + && !ctx->EvalMap.Map2Vertex4.Retain) { + free( ctx->EvalMap.Map2Vertex4.Points ); + } + ctx->EvalMap.Map2Vertex4.Points = (GLfloat *) points; + ctx->EvalMap.Map2Vertex4.Retain = retain; + break; + case GL_MAP2_INDEX: + ctx->EvalMap.Map2Index.Uorder = uorder; + ctx->EvalMap.Map2Index.u1 = u1; + ctx->EvalMap.Map2Index.u2 = u2; + ctx->EvalMap.Map2Index.Vorder = vorder; + ctx->EvalMap.Map2Index.v1 = v1; + ctx->EvalMap.Map2Index.v2 = v2; + if (ctx->EvalMap.Map2Index.Points + && !ctx->EvalMap.Map2Index.Retain) { + free( ctx->EvalMap.Map2Index.Points ); + } + ctx->EvalMap.Map2Index.Retain = retain; + ctx->EvalMap.Map2Index.Points = (GLfloat *) points; + break; + case GL_MAP2_COLOR_4: + ctx->EvalMap.Map2Color4.Uorder = uorder; + ctx->EvalMap.Map2Color4.u1 = u1; + ctx->EvalMap.Map2Color4.u2 = u2; + ctx->EvalMap.Map2Color4.Vorder = vorder; + ctx->EvalMap.Map2Color4.v1 = v1; + ctx->EvalMap.Map2Color4.v2 = v2; + if (ctx->EvalMap.Map2Color4.Points + && !ctx->EvalMap.Map2Color4.Retain) { + free( ctx->EvalMap.Map2Color4.Points ); + } + ctx->EvalMap.Map2Color4.Retain = retain; + ctx->EvalMap.Map2Color4.Points = (GLfloat *) points; + break; + case GL_MAP2_NORMAL: + ctx->EvalMap.Map2Normal.Uorder = uorder; + ctx->EvalMap.Map2Normal.u1 = u1; + ctx->EvalMap.Map2Normal.u2 = u2; + ctx->EvalMap.Map2Normal.Vorder = vorder; + ctx->EvalMap.Map2Normal.v1 = v1; + ctx->EvalMap.Map2Normal.v2 = v2; + if (ctx->EvalMap.Map2Normal.Points + && !ctx->EvalMap.Map2Normal.Retain) { + free( ctx->EvalMap.Map2Normal.Points ); + } + ctx->EvalMap.Map2Normal.Retain = retain; + ctx->EvalMap.Map2Normal.Points = (GLfloat *) points; + break; + case GL_MAP2_TEXTURE_COORD_1: + ctx->EvalMap.Map2Texture1.Uorder = uorder; + ctx->EvalMap.Map2Texture1.u1 = u1; + ctx->EvalMap.Map2Texture1.u2 = u2; + ctx->EvalMap.Map2Texture1.Vorder = vorder; + ctx->EvalMap.Map2Texture1.v1 = v1; + ctx->EvalMap.Map2Texture1.v2 = v2; + if (ctx->EvalMap.Map2Texture1.Points + && !ctx->EvalMap.Map2Texture1.Retain) { + free( ctx->EvalMap.Map2Texture1.Points ); + } + ctx->EvalMap.Map2Texture1.Retain = retain; + ctx->EvalMap.Map2Texture1.Points = (GLfloat *) points; + break; + case GL_MAP2_TEXTURE_COORD_2: + ctx->EvalMap.Map2Texture2.Uorder = uorder; + ctx->EvalMap.Map2Texture2.u1 = u1; + ctx->EvalMap.Map2Texture2.u2 = u2; + ctx->EvalMap.Map2Texture2.Vorder = vorder; + ctx->EvalMap.Map2Texture2.v1 = v1; + ctx->EvalMap.Map2Texture2.v2 = v2; + if (ctx->EvalMap.Map2Texture2.Points + && !ctx->EvalMap.Map2Texture2.Retain) { + free( ctx->EvalMap.Map2Texture2.Points ); + } + ctx->EvalMap.Map2Texture2.Retain = retain; + ctx->EvalMap.Map2Texture2.Points = (GLfloat *) points; + break; + case GL_MAP2_TEXTURE_COORD_3: + ctx->EvalMap.Map2Texture3.Uorder = uorder; + ctx->EvalMap.Map2Texture3.u1 = u1; + ctx->EvalMap.Map2Texture3.u2 = u2; + ctx->EvalMap.Map2Texture3.Vorder = vorder; + ctx->EvalMap.Map2Texture3.v1 = v1; + ctx->EvalMap.Map2Texture3.v2 = v2; + if (ctx->EvalMap.Map2Texture3.Points + && !ctx->EvalMap.Map2Texture3.Retain) { + free( ctx->EvalMap.Map2Texture3.Points ); + } + ctx->EvalMap.Map2Texture3.Retain = retain; + ctx->EvalMap.Map2Texture3.Points = (GLfloat *) points; + break; + case GL_MAP2_TEXTURE_COORD_4: + ctx->EvalMap.Map2Texture4.Uorder = uorder; + ctx->EvalMap.Map2Texture4.u1 = u1; + ctx->EvalMap.Map2Texture4.u2 = u2; + ctx->EvalMap.Map2Texture4.Vorder = vorder; + ctx->EvalMap.Map2Texture4.v1 = v1; + ctx->EvalMap.Map2Texture4.v2 = v2; + if (ctx->EvalMap.Map2Texture4.Points + && !ctx->EvalMap.Map2Texture4.Retain) { + free( ctx->EvalMap.Map2Texture4.Points ); + } + ctx->EvalMap.Map2Texture4.Retain = retain; + ctx->EvalMap.Map2Texture4.Points = (GLfloat *) points; + break; + default: + gl_error( ctx, GL_INVALID_ENUM, "glMap2(target)" ); + } +} + + + + + +void gl_GetMapdv( GLcontext* ctx, GLenum target, GLenum query, GLdouble *v ) +{ + GLuint i, n; + GLfloat *data; + + switch (query) { + case GL_COEFF: + switch (target) { + case GL_MAP1_COLOR_4: + data = ctx->EvalMap.Map1Color4.Points; + n = ctx->EvalMap.Map1Color4.Order * 4; + break; + case GL_MAP1_INDEX: + data = ctx->EvalMap.Map1Index.Points; + n = ctx->EvalMap.Map1Index.Order; + break; + case GL_MAP1_NORMAL: + data = ctx->EvalMap.Map1Normal.Points; + n = ctx->EvalMap.Map1Normal.Order * 3; + break; + case GL_MAP1_TEXTURE_COORD_1: + data = ctx->EvalMap.Map1Texture1.Points; + n = ctx->EvalMap.Map1Texture1.Order * 1; + break; + case GL_MAP1_TEXTURE_COORD_2: + data = ctx->EvalMap.Map1Texture2.Points; + n = ctx->EvalMap.Map1Texture2.Order * 2; + break; + case GL_MAP1_TEXTURE_COORD_3: + data = ctx->EvalMap.Map1Texture3.Points; + n = ctx->EvalMap.Map1Texture3.Order * 3; + break; + case GL_MAP1_TEXTURE_COORD_4: + data = ctx->EvalMap.Map1Texture4.Points; + n = ctx->EvalMap.Map1Texture4.Order * 4; + break; + case GL_MAP1_VERTEX_3: + data = ctx->EvalMap.Map1Vertex3.Points; + n = ctx->EvalMap.Map1Vertex3.Order * 3; + break; + case GL_MAP1_VERTEX_4: + data = ctx->EvalMap.Map1Vertex4.Points; + n = ctx->EvalMap.Map1Vertex4.Order * 4; + break; + case GL_MAP2_COLOR_4: + data = ctx->EvalMap.Map2Color4.Points; + n = ctx->EvalMap.Map2Color4.Uorder + * ctx->EvalMap.Map2Color4.Vorder * 4; + break; + case GL_MAP2_INDEX: + data = ctx->EvalMap.Map2Index.Points; + n = ctx->EvalMap.Map2Index.Uorder + * ctx->EvalMap.Map2Index.Vorder; + break; + case GL_MAP2_NORMAL: + data = ctx->EvalMap.Map2Normal.Points; + n = ctx->EvalMap.Map2Normal.Uorder + * ctx->EvalMap.Map2Normal.Vorder * 3; + break; + case GL_MAP2_TEXTURE_COORD_1: + data = ctx->EvalMap.Map2Texture1.Points; + n = ctx->EvalMap.Map2Texture1.Uorder + * ctx->EvalMap.Map2Texture1.Vorder * 1; + break; + case GL_MAP2_TEXTURE_COORD_2: + data = ctx->EvalMap.Map2Texture2.Points; + n = ctx->EvalMap.Map2Texture2.Uorder + * ctx->EvalMap.Map2Texture2.Vorder * 2; + break; + case GL_MAP2_TEXTURE_COORD_3: + data = ctx->EvalMap.Map2Texture3.Points; + n = ctx->EvalMap.Map2Texture3.Uorder + * ctx->EvalMap.Map2Texture3.Vorder * 3; + break; + case GL_MAP2_TEXTURE_COORD_4: + data = ctx->EvalMap.Map2Texture4.Points; + n = ctx->EvalMap.Map2Texture4.Uorder + * ctx->EvalMap.Map2Texture4.Vorder * 4; + break; + case GL_MAP2_VERTEX_3: + data = ctx->EvalMap.Map2Vertex3.Points; + n = ctx->EvalMap.Map2Vertex3.Uorder + * ctx->EvalMap.Map2Vertex3.Vorder * 3; + break; + case GL_MAP2_VERTEX_4: + data = ctx->EvalMap.Map2Vertex4.Points; + n = ctx->EvalMap.Map2Vertex4.Uorder + * ctx->EvalMap.Map2Vertex4.Vorder * 4; + break; + default: + gl_error( ctx, GL_INVALID_ENUM, "glGetMapdv(target)" ); + } + if (data) { + for (i=0;iEvalMap.Map1Color4.Order; + break; + case GL_MAP1_INDEX: + *v = ctx->EvalMap.Map1Index.Order; + break; + case GL_MAP1_NORMAL: + *v = ctx->EvalMap.Map1Normal.Order; + break; + case GL_MAP1_TEXTURE_COORD_1: + *v = ctx->EvalMap.Map1Texture1.Order; + break; + case GL_MAP1_TEXTURE_COORD_2: + *v = ctx->EvalMap.Map1Texture2.Order; + break; + case GL_MAP1_TEXTURE_COORD_3: + *v = ctx->EvalMap.Map1Texture3.Order; + break; + case GL_MAP1_TEXTURE_COORD_4: + *v = ctx->EvalMap.Map1Texture4.Order; + break; + case GL_MAP1_VERTEX_3: + *v = ctx->EvalMap.Map1Vertex3.Order; + break; + case GL_MAP1_VERTEX_4: + *v = ctx->EvalMap.Map1Vertex4.Order; + break; + case GL_MAP2_COLOR_4: + v[0] = ctx->EvalMap.Map2Color4.Uorder; + v[1] = ctx->EvalMap.Map2Color4.Vorder; + break; + case GL_MAP2_INDEX: + v[0] = ctx->EvalMap.Map2Index.Uorder; + v[1] = ctx->EvalMap.Map2Index.Vorder; + break; + case GL_MAP2_NORMAL: + v[0] = ctx->EvalMap.Map2Normal.Uorder; + v[1] = ctx->EvalMap.Map2Normal.Vorder; + break; + case GL_MAP2_TEXTURE_COORD_1: + v[0] = ctx->EvalMap.Map2Texture1.Uorder; + v[1] = ctx->EvalMap.Map2Texture1.Vorder; + break; + case GL_MAP2_TEXTURE_COORD_2: + v[0] = ctx->EvalMap.Map2Texture2.Uorder; + v[1] = ctx->EvalMap.Map2Texture2.Vorder; + break; + case GL_MAP2_TEXTURE_COORD_3: + v[0] = ctx->EvalMap.Map2Texture3.Uorder; + v[1] = ctx->EvalMap.Map2Texture3.Vorder; + break; + case GL_MAP2_TEXTURE_COORD_4: + v[0] = ctx->EvalMap.Map2Texture4.Uorder; + v[1] = ctx->EvalMap.Map2Texture4.Vorder; + break; + case GL_MAP2_VERTEX_3: + v[0] = ctx->EvalMap.Map2Vertex3.Uorder; + v[1] = ctx->EvalMap.Map2Vertex3.Vorder; + break; + case GL_MAP2_VERTEX_4: + v[0] = ctx->EvalMap.Map2Vertex4.Uorder; + v[1] = ctx->EvalMap.Map2Vertex4.Vorder; + break; + default: + gl_error( ctx, GL_INVALID_ENUM, "glGetMapdv(target)" ); + } + break; + case GL_DOMAIN: + switch (target) { + case GL_MAP1_COLOR_4: + v[0] = ctx->EvalMap.Map1Color4.u1; + v[1] = ctx->EvalMap.Map1Color4.u2; + break; + case GL_MAP1_INDEX: + v[0] = ctx->EvalMap.Map1Index.u1; + v[1] = ctx->EvalMap.Map1Index.u2; + break; + case GL_MAP1_NORMAL: + v[0] = ctx->EvalMap.Map1Normal.u1; + v[1] = ctx->EvalMap.Map1Normal.u2; + break; + case GL_MAP1_TEXTURE_COORD_1: + v[0] = ctx->EvalMap.Map1Texture1.u1; + v[1] = ctx->EvalMap.Map1Texture1.u2; + break; + case GL_MAP1_TEXTURE_COORD_2: + v[0] = ctx->EvalMap.Map1Texture2.u1; + v[1] = ctx->EvalMap.Map1Texture2.u2; + break; + case GL_MAP1_TEXTURE_COORD_3: + v[0] = ctx->EvalMap.Map1Texture3.u1; + v[1] = ctx->EvalMap.Map1Texture3.u2; + break; + case GL_MAP1_TEXTURE_COORD_4: + v[0] = ctx->EvalMap.Map1Texture4.u1; + v[1] = ctx->EvalMap.Map1Texture4.u2; + break; + case GL_MAP1_VERTEX_3: + v[0] = ctx->EvalMap.Map1Vertex3.u1; + v[1] = ctx->EvalMap.Map1Vertex3.u2; + break; + case GL_MAP1_VERTEX_4: + v[0] = ctx->EvalMap.Map1Vertex4.u1; + v[1] = ctx->EvalMap.Map1Vertex4.u2; + break; + case GL_MAP2_COLOR_4: + v[0] = ctx->EvalMap.Map2Color4.u1; + v[1] = ctx->EvalMap.Map2Color4.u2; + v[2] = ctx->EvalMap.Map2Color4.v1; + v[3] = ctx->EvalMap.Map2Color4.v2; + break; + case GL_MAP2_INDEX: + v[0] = ctx->EvalMap.Map2Index.u1; + v[1] = ctx->EvalMap.Map2Index.u2; + v[2] = ctx->EvalMap.Map2Index.v1; + v[3] = ctx->EvalMap.Map2Index.v2; + break; + case GL_MAP2_NORMAL: + v[0] = ctx->EvalMap.Map2Normal.u1; + v[1] = ctx->EvalMap.Map2Normal.u2; + v[2] = ctx->EvalMap.Map2Normal.v1; + v[3] = ctx->EvalMap.Map2Normal.v2; + break; + case GL_MAP2_TEXTURE_COORD_1: + v[0] = ctx->EvalMap.Map2Texture1.u1; + v[1] = ctx->EvalMap.Map2Texture1.u2; + v[2] = ctx->EvalMap.Map2Texture1.v1; + v[3] = ctx->EvalMap.Map2Texture1.v2; + break; + case GL_MAP2_TEXTURE_COORD_2: + v[0] = ctx->EvalMap.Map2Texture2.u1; + v[1] = ctx->EvalMap.Map2Texture2.u2; + v[2] = ctx->EvalMap.Map2Texture2.v1; + v[3] = ctx->EvalMap.Map2Texture2.v2; + break; + case GL_MAP2_TEXTURE_COORD_3: + v[0] = ctx->EvalMap.Map2Texture3.u1; + v[1] = ctx->EvalMap.Map2Texture3.u2; + v[2] = ctx->EvalMap.Map2Texture3.v1; + v[3] = ctx->EvalMap.Map2Texture3.v2; + break; + case GL_MAP2_TEXTURE_COORD_4: + v[0] = ctx->EvalMap.Map2Texture4.u1; + v[1] = ctx->EvalMap.Map2Texture4.u2; + v[2] = ctx->EvalMap.Map2Texture4.v1; + v[3] = ctx->EvalMap.Map2Texture4.v2; + break; + case GL_MAP2_VERTEX_3: + v[0] = ctx->EvalMap.Map2Vertex3.u1; + v[1] = ctx->EvalMap.Map2Vertex3.u2; + v[2] = ctx->EvalMap.Map2Vertex3.v1; + v[3] = ctx->EvalMap.Map2Vertex3.v2; + break; + case GL_MAP2_VERTEX_4: + v[0] = ctx->EvalMap.Map2Vertex4.u1; + v[1] = ctx->EvalMap.Map2Vertex4.u2; + v[2] = ctx->EvalMap.Map2Vertex4.v1; + v[3] = ctx->EvalMap.Map2Vertex4.v2; + break; + default: + gl_error( ctx, GL_INVALID_ENUM, "glGetMapdv(target)" ); + } + break; + default: + gl_error( ctx, GL_INVALID_ENUM, "glGetMapdv(query)" ); + } +} + + +void gl_GetMapfv( GLcontext* ctx, GLenum target, GLenum query, GLfloat *v ) +{ + GLuint i, n; + GLfloat *data; + + switch (query) { + case GL_COEFF: + switch (target) { + case GL_MAP1_COLOR_4: + data = ctx->EvalMap.Map1Color4.Points; + n = ctx->EvalMap.Map1Color4.Order * 4; + break; + case GL_MAP1_INDEX: + data = ctx->EvalMap.Map1Index.Points; + n = ctx->EvalMap.Map1Index.Order; + break; + case GL_MAP1_NORMAL: + data = ctx->EvalMap.Map1Normal.Points; + n = ctx->EvalMap.Map1Normal.Order * 3; + break; + case GL_MAP1_TEXTURE_COORD_1: + data = ctx->EvalMap.Map1Texture1.Points; + n = ctx->EvalMap.Map1Texture1.Order * 1; + break; + case GL_MAP1_TEXTURE_COORD_2: + data = ctx->EvalMap.Map1Texture2.Points; + n = ctx->EvalMap.Map1Texture2.Order * 2; + break; + case GL_MAP1_TEXTURE_COORD_3: + data = ctx->EvalMap.Map1Texture3.Points; + n = ctx->EvalMap.Map1Texture3.Order * 3; + break; + case GL_MAP1_TEXTURE_COORD_4: + data = ctx->EvalMap.Map1Texture4.Points; + n = ctx->EvalMap.Map1Texture4.Order * 4; + break; + case GL_MAP1_VERTEX_3: + data = ctx->EvalMap.Map1Vertex3.Points; + n = ctx->EvalMap.Map1Vertex3.Order * 3; + break; + case GL_MAP1_VERTEX_4: + data = ctx->EvalMap.Map1Vertex4.Points; + n = ctx->EvalMap.Map1Vertex4.Order * 4; + break; + case GL_MAP2_COLOR_4: + data = ctx->EvalMap.Map2Color4.Points; + n = ctx->EvalMap.Map2Color4.Uorder + * ctx->EvalMap.Map2Color4.Vorder * 4; + break; + case GL_MAP2_INDEX: + data = ctx->EvalMap.Map2Index.Points; + n = ctx->EvalMap.Map2Index.Uorder + * ctx->EvalMap.Map2Index.Vorder; + break; + case GL_MAP2_NORMAL: + data = ctx->EvalMap.Map2Normal.Points; + n = ctx->EvalMap.Map2Normal.Uorder + * ctx->EvalMap.Map2Normal.Vorder * 3; + break; + case GL_MAP2_TEXTURE_COORD_1: + data = ctx->EvalMap.Map2Texture1.Points; + n = ctx->EvalMap.Map2Texture1.Uorder + * ctx->EvalMap.Map2Texture1.Vorder * 1; + break; + case GL_MAP2_TEXTURE_COORD_2: + data = ctx->EvalMap.Map2Texture2.Points; + n = ctx->EvalMap.Map2Texture2.Uorder + * ctx->EvalMap.Map2Texture2.Vorder * 2; + break; + case GL_MAP2_TEXTURE_COORD_3: + data = ctx->EvalMap.Map2Texture3.Points; + n = ctx->EvalMap.Map2Texture3.Uorder + * ctx->EvalMap.Map2Texture3.Vorder * 3; + break; + case GL_MAP2_TEXTURE_COORD_4: + data = ctx->EvalMap.Map2Texture4.Points; + n = ctx->EvalMap.Map2Texture4.Uorder + * ctx->EvalMap.Map2Texture4.Vorder * 4; + break; + case GL_MAP2_VERTEX_3: + data = ctx->EvalMap.Map2Vertex3.Points; + n = ctx->EvalMap.Map2Vertex3.Uorder + * ctx->EvalMap.Map2Vertex3.Vorder * 3; + break; + case GL_MAP2_VERTEX_4: + data = ctx->EvalMap.Map2Vertex4.Points; + n = ctx->EvalMap.Map2Vertex4.Uorder + * ctx->EvalMap.Map2Vertex4.Vorder * 4; + break; + default: + gl_error( ctx, GL_INVALID_ENUM, "glGetMapfv(target)" ); + } + if (data) { + for (i=0;iEvalMap.Map1Color4.Order; + break; + case GL_MAP1_INDEX: + *v = ctx->EvalMap.Map1Index.Order; + break; + case GL_MAP1_NORMAL: + *v = ctx->EvalMap.Map1Normal.Order; + break; + case GL_MAP1_TEXTURE_COORD_1: + *v = ctx->EvalMap.Map1Texture1.Order; + break; + case GL_MAP1_TEXTURE_COORD_2: + *v = ctx->EvalMap.Map1Texture2.Order; + break; + case GL_MAP1_TEXTURE_COORD_3: + *v = ctx->EvalMap.Map1Texture3.Order; + break; + case GL_MAP1_TEXTURE_COORD_4: + *v = ctx->EvalMap.Map1Texture4.Order; + break; + case GL_MAP1_VERTEX_3: + *v = ctx->EvalMap.Map1Vertex3.Order; + break; + case GL_MAP1_VERTEX_4: + *v = ctx->EvalMap.Map1Vertex4.Order; + break; + case GL_MAP2_COLOR_4: + v[0] = ctx->EvalMap.Map2Color4.Uorder; + v[1] = ctx->EvalMap.Map2Color4.Vorder; + break; + case GL_MAP2_INDEX: + v[0] = ctx->EvalMap.Map2Index.Uorder; + v[1] = ctx->EvalMap.Map2Index.Vorder; + break; + case GL_MAP2_NORMAL: + v[0] = ctx->EvalMap.Map2Normal.Uorder; + v[1] = ctx->EvalMap.Map2Normal.Vorder; + break; + case GL_MAP2_TEXTURE_COORD_1: + v[0] = ctx->EvalMap.Map2Texture1.Uorder; + v[1] = ctx->EvalMap.Map2Texture1.Vorder; + break; + case GL_MAP2_TEXTURE_COORD_2: + v[0] = ctx->EvalMap.Map2Texture2.Uorder; + v[1] = ctx->EvalMap.Map2Texture2.Vorder; + break; + case GL_MAP2_TEXTURE_COORD_3: + v[0] = ctx->EvalMap.Map2Texture3.Uorder; + v[1] = ctx->EvalMap.Map2Texture3.Vorder; + break; + case GL_MAP2_TEXTURE_COORD_4: + v[0] = ctx->EvalMap.Map2Texture4.Uorder; + v[1] = ctx->EvalMap.Map2Texture4.Vorder; + break; + case GL_MAP2_VERTEX_3: + v[0] = ctx->EvalMap.Map2Vertex3.Uorder; + v[1] = ctx->EvalMap.Map2Vertex3.Vorder; + break; + case GL_MAP2_VERTEX_4: + v[0] = ctx->EvalMap.Map2Vertex4.Uorder; + v[1] = ctx->EvalMap.Map2Vertex4.Vorder; + break; + default: + gl_error( ctx, GL_INVALID_ENUM, "glGetMapfv(target)" ); + } + break; + case GL_DOMAIN: + switch (target) { + case GL_MAP1_COLOR_4: + v[0] = ctx->EvalMap.Map1Color4.u1; + v[1] = ctx->EvalMap.Map1Color4.u2; + break; + case GL_MAP1_INDEX: + v[0] = ctx->EvalMap.Map1Index.u1; + v[1] = ctx->EvalMap.Map1Index.u2; + break; + case GL_MAP1_NORMAL: + v[0] = ctx->EvalMap.Map1Normal.u1; + v[1] = ctx->EvalMap.Map1Normal.u2; + break; + case GL_MAP1_TEXTURE_COORD_1: + v[0] = ctx->EvalMap.Map1Texture1.u1; + v[1] = ctx->EvalMap.Map1Texture1.u2; + break; + case GL_MAP1_TEXTURE_COORD_2: + v[0] = ctx->EvalMap.Map1Texture2.u1; + v[1] = ctx->EvalMap.Map1Texture2.u2; + break; + case GL_MAP1_TEXTURE_COORD_3: + v[0] = ctx->EvalMap.Map1Texture3.u1; + v[1] = ctx->EvalMap.Map1Texture3.u2; + break; + case GL_MAP1_TEXTURE_COORD_4: + v[0] = ctx->EvalMap.Map1Texture4.u1; + v[1] = ctx->EvalMap.Map1Texture4.u2; + break; + case GL_MAP1_VERTEX_3: + v[0] = ctx->EvalMap.Map1Vertex3.u1; + v[1] = ctx->EvalMap.Map1Vertex3.u2; + break; + case GL_MAP1_VERTEX_4: + v[0] = ctx->EvalMap.Map1Vertex4.u1; + v[1] = ctx->EvalMap.Map1Vertex4.u2; + break; + case GL_MAP2_COLOR_4: + v[0] = ctx->EvalMap.Map2Color4.u1; + v[1] = ctx->EvalMap.Map2Color4.u2; + v[2] = ctx->EvalMap.Map2Color4.v1; + v[3] = ctx->EvalMap.Map2Color4.v2; + break; + case GL_MAP2_INDEX: + v[0] = ctx->EvalMap.Map2Index.u1; + v[1] = ctx->EvalMap.Map2Index.u2; + v[2] = ctx->EvalMap.Map2Index.v1; + v[3] = ctx->EvalMap.Map2Index.v2; + break; + case GL_MAP2_NORMAL: + v[0] = ctx->EvalMap.Map2Normal.u1; + v[1] = ctx->EvalMap.Map2Normal.u2; + v[2] = ctx->EvalMap.Map2Normal.v1; + v[3] = ctx->EvalMap.Map2Normal.v2; + break; + case GL_MAP2_TEXTURE_COORD_1: + v[0] = ctx->EvalMap.Map2Texture1.u1; + v[1] = ctx->EvalMap.Map2Texture1.u2; + v[2] = ctx->EvalMap.Map2Texture1.v1; + v[3] = ctx->EvalMap.Map2Texture1.v2; + break; + case GL_MAP2_TEXTURE_COORD_2: + v[0] = ctx->EvalMap.Map2Texture2.u1; + v[1] = ctx->EvalMap.Map2Texture2.u2; + v[2] = ctx->EvalMap.Map2Texture2.v1; + v[3] = ctx->EvalMap.Map2Texture2.v2; + break; + case GL_MAP2_TEXTURE_COORD_3: + v[0] = ctx->EvalMap.Map2Texture3.u1; + v[1] = ctx->EvalMap.Map2Texture3.u2; + v[2] = ctx->EvalMap.Map2Texture3.v1; + v[3] = ctx->EvalMap.Map2Texture3.v2; + break; + case GL_MAP2_TEXTURE_COORD_4: + v[0] = ctx->EvalMap.Map2Texture4.u1; + v[1] = ctx->EvalMap.Map2Texture4.u2; + v[2] = ctx->EvalMap.Map2Texture4.v1; + v[3] = ctx->EvalMap.Map2Texture4.v2; + break; + case GL_MAP2_VERTEX_3: + v[0] = ctx->EvalMap.Map2Vertex3.u1; + v[1] = ctx->EvalMap.Map2Vertex3.u2; + v[2] = ctx->EvalMap.Map2Vertex3.v1; + v[3] = ctx->EvalMap.Map2Vertex3.v2; + break; + case GL_MAP2_VERTEX_4: + v[0] = ctx->EvalMap.Map2Vertex4.u1; + v[1] = ctx->EvalMap.Map2Vertex4.u2; + v[2] = ctx->EvalMap.Map2Vertex4.v1; + v[3] = ctx->EvalMap.Map2Vertex4.v2; + break; + default: + gl_error( ctx, GL_INVALID_ENUM, "glGetMapfv(target)" ); + } + break; + default: + gl_error( ctx, GL_INVALID_ENUM, "glGetMapfv(query)" ); + } +} + + +void gl_GetMapiv( GLcontext* ctx, GLenum target, GLenum query, GLint *v ) +{ + GLuint i, n; + GLfloat *data; + + switch (query) { + case GL_COEFF: + switch (target) { + case GL_MAP1_COLOR_4: + data = ctx->EvalMap.Map1Color4.Points; + n = ctx->EvalMap.Map1Color4.Order * 4; + break; + case GL_MAP1_INDEX: + data = ctx->EvalMap.Map1Index.Points; + n = ctx->EvalMap.Map1Index.Order; + break; + case GL_MAP1_NORMAL: + data = ctx->EvalMap.Map1Normal.Points; + n = ctx->EvalMap.Map1Normal.Order * 3; + break; + case GL_MAP1_TEXTURE_COORD_1: + data = ctx->EvalMap.Map1Texture1.Points; + n = ctx->EvalMap.Map1Texture1.Order * 1; + break; + case GL_MAP1_TEXTURE_COORD_2: + data = ctx->EvalMap.Map1Texture2.Points; + n = ctx->EvalMap.Map1Texture2.Order * 2; + break; + case GL_MAP1_TEXTURE_COORD_3: + data = ctx->EvalMap.Map1Texture3.Points; + n = ctx->EvalMap.Map1Texture3.Order * 3; + break; + case GL_MAP1_TEXTURE_COORD_4: + data = ctx->EvalMap.Map1Texture4.Points; + n = ctx->EvalMap.Map1Texture4.Order * 4; + break; + case GL_MAP1_VERTEX_3: + data = ctx->EvalMap.Map1Vertex3.Points; + n = ctx->EvalMap.Map1Vertex3.Order * 3; + break; + case GL_MAP1_VERTEX_4: + data = ctx->EvalMap.Map1Vertex4.Points; + n = ctx->EvalMap.Map1Vertex4.Order * 4; + break; + case GL_MAP2_COLOR_4: + data = ctx->EvalMap.Map2Color4.Points; + n = ctx->EvalMap.Map2Color4.Uorder + * ctx->EvalMap.Map2Color4.Vorder * 4; + break; + case GL_MAP2_INDEX: + data = ctx->EvalMap.Map2Index.Points; + n = ctx->EvalMap.Map2Index.Uorder + * ctx->EvalMap.Map2Index.Vorder; + break; + case GL_MAP2_NORMAL: + data = ctx->EvalMap.Map2Normal.Points; + n = ctx->EvalMap.Map2Normal.Uorder + * ctx->EvalMap.Map2Normal.Vorder * 3; + break; + case GL_MAP2_TEXTURE_COORD_1: + data = ctx->EvalMap.Map2Texture1.Points; + n = ctx->EvalMap.Map2Texture1.Uorder + * ctx->EvalMap.Map2Texture1.Vorder * 1; + break; + case GL_MAP2_TEXTURE_COORD_2: + data = ctx->EvalMap.Map2Texture2.Points; + n = ctx->EvalMap.Map2Texture2.Uorder + * ctx->EvalMap.Map2Texture2.Vorder * 2; + break; + case GL_MAP2_TEXTURE_COORD_3: + data = ctx->EvalMap.Map2Texture3.Points; + n = ctx->EvalMap.Map2Texture3.Uorder + * ctx->EvalMap.Map2Texture3.Vorder * 3; + break; + case GL_MAP2_TEXTURE_COORD_4: + data = ctx->EvalMap.Map2Texture4.Points; + n = ctx->EvalMap.Map2Texture4.Uorder + * ctx->EvalMap.Map2Texture4.Vorder * 4; + break; + case GL_MAP2_VERTEX_3: + data = ctx->EvalMap.Map2Vertex3.Points; + n = ctx->EvalMap.Map2Vertex3.Uorder + * ctx->EvalMap.Map2Vertex3.Vorder * 3; + break; + case GL_MAP2_VERTEX_4: + data = ctx->EvalMap.Map2Vertex4.Points; + n = ctx->EvalMap.Map2Vertex4.Uorder + * ctx->EvalMap.Map2Vertex4.Vorder * 4; + break; + default: + gl_error( ctx, GL_INVALID_ENUM, "glGetMapiv(target)" ); + } + if (data) { + for (i=0;iEvalMap.Map1Color4.Order; + break; + case GL_MAP1_INDEX: + *v = ctx->EvalMap.Map1Index.Order; + break; + case GL_MAP1_NORMAL: + *v = ctx->EvalMap.Map1Normal.Order; + break; + case GL_MAP1_TEXTURE_COORD_1: + *v = ctx->EvalMap.Map1Texture1.Order; + break; + case GL_MAP1_TEXTURE_COORD_2: + *v = ctx->EvalMap.Map1Texture2.Order; + break; + case GL_MAP1_TEXTURE_COORD_3: + *v = ctx->EvalMap.Map1Texture3.Order; + break; + case GL_MAP1_TEXTURE_COORD_4: + *v = ctx->EvalMap.Map1Texture4.Order; + break; + case GL_MAP1_VERTEX_3: + *v = ctx->EvalMap.Map1Vertex3.Order; + break; + case GL_MAP1_VERTEX_4: + *v = ctx->EvalMap.Map1Vertex4.Order; + break; + case GL_MAP2_COLOR_4: + v[0] = ctx->EvalMap.Map2Color4.Uorder; + v[1] = ctx->EvalMap.Map2Color4.Vorder; + break; + case GL_MAP2_INDEX: + v[0] = ctx->EvalMap.Map2Index.Uorder; + v[1] = ctx->EvalMap.Map2Index.Vorder; + break; + case GL_MAP2_NORMAL: + v[0] = ctx->EvalMap.Map2Normal.Uorder; + v[1] = ctx->EvalMap.Map2Normal.Vorder; + break; + case GL_MAP2_TEXTURE_COORD_1: + v[0] = ctx->EvalMap.Map2Texture1.Uorder; + v[1] = ctx->EvalMap.Map2Texture1.Vorder; + break; + case GL_MAP2_TEXTURE_COORD_2: + v[0] = ctx->EvalMap.Map2Texture2.Uorder; + v[1] = ctx->EvalMap.Map2Texture2.Vorder; + break; + case GL_MAP2_TEXTURE_COORD_3: + v[0] = ctx->EvalMap.Map2Texture3.Uorder; + v[1] = ctx->EvalMap.Map2Texture3.Vorder; + break; + case GL_MAP2_TEXTURE_COORD_4: + v[0] = ctx->EvalMap.Map2Texture4.Uorder; + v[1] = ctx->EvalMap.Map2Texture4.Vorder; + break; + case GL_MAP2_VERTEX_3: + v[0] = ctx->EvalMap.Map2Vertex3.Uorder; + v[1] = ctx->EvalMap.Map2Vertex3.Vorder; + break; + case GL_MAP2_VERTEX_4: + v[0] = ctx->EvalMap.Map2Vertex4.Uorder; + v[1] = ctx->EvalMap.Map2Vertex4.Vorder; + break; + default: + gl_error( ctx, GL_INVALID_ENUM, "glGetMapiv(target)" ); + } + break; + case GL_DOMAIN: + switch (target) { + case GL_MAP1_COLOR_4: + v[0] = ROUNDF(ctx->EvalMap.Map1Color4.u1); + v[1] = ROUNDF(ctx->EvalMap.Map1Color4.u2); + break; + case GL_MAP1_INDEX: + v[0] = ROUNDF(ctx->EvalMap.Map1Index.u1); + v[1] = ROUNDF(ctx->EvalMap.Map1Index.u2); + break; + case GL_MAP1_NORMAL: + v[0] = ROUNDF(ctx->EvalMap.Map1Normal.u1); + v[1] = ROUNDF(ctx->EvalMap.Map1Normal.u2); + break; + case GL_MAP1_TEXTURE_COORD_1: + v[0] = ROUNDF(ctx->EvalMap.Map1Texture1.u1); + v[1] = ROUNDF(ctx->EvalMap.Map1Texture1.u2); + break; + case GL_MAP1_TEXTURE_COORD_2: + v[0] = ROUNDF(ctx->EvalMap.Map1Texture2.u1); + v[1] = ROUNDF(ctx->EvalMap.Map1Texture2.u2); + break; + case GL_MAP1_TEXTURE_COORD_3: + v[0] = ROUNDF(ctx->EvalMap.Map1Texture3.u1); + v[1] = ROUNDF(ctx->EvalMap.Map1Texture3.u2); + break; + case GL_MAP1_TEXTURE_COORD_4: + v[0] = ROUNDF(ctx->EvalMap.Map1Texture4.u1); + v[1] = ROUNDF(ctx->EvalMap.Map1Texture4.u2); + break; + case GL_MAP1_VERTEX_3: + v[0] = ROUNDF(ctx->EvalMap.Map1Vertex3.u1); + v[1] = ROUNDF(ctx->EvalMap.Map1Vertex3.u2); + break; + case GL_MAP1_VERTEX_4: + v[0] = ROUNDF(ctx->EvalMap.Map1Vertex4.u1); + v[1] = ROUNDF(ctx->EvalMap.Map1Vertex4.u2); + break; + case GL_MAP2_COLOR_4: + v[0] = ROUNDF(ctx->EvalMap.Map2Color4.u1); + v[1] = ROUNDF(ctx->EvalMap.Map2Color4.u2); + v[2] = ROUNDF(ctx->EvalMap.Map2Color4.v1); + v[3] = ROUNDF(ctx->EvalMap.Map2Color4.v2); + break; + case GL_MAP2_INDEX: + v[0] = ROUNDF(ctx->EvalMap.Map2Index.u1); + v[1] = ROUNDF(ctx->EvalMap.Map2Index.u2); + v[2] = ROUNDF(ctx->EvalMap.Map2Index.v1); + v[3] = ROUNDF(ctx->EvalMap.Map2Index.v2); + break; + case GL_MAP2_NORMAL: + v[0] = ROUNDF(ctx->EvalMap.Map2Normal.u1); + v[1] = ROUNDF(ctx->EvalMap.Map2Normal.u2); + v[2] = ROUNDF(ctx->EvalMap.Map2Normal.v1); + v[3] = ROUNDF(ctx->EvalMap.Map2Normal.v2); + break; + case GL_MAP2_TEXTURE_COORD_1: + v[0] = ROUNDF(ctx->EvalMap.Map2Texture1.u1); + v[1] = ROUNDF(ctx->EvalMap.Map2Texture1.u2); + v[2] = ROUNDF(ctx->EvalMap.Map2Texture1.v1); + v[3] = ROUNDF(ctx->EvalMap.Map2Texture1.v2); + break; + case GL_MAP2_TEXTURE_COORD_2: + v[0] = ROUNDF(ctx->EvalMap.Map2Texture2.u1); + v[1] = ROUNDF(ctx->EvalMap.Map2Texture2.u2); + v[2] = ROUNDF(ctx->EvalMap.Map2Texture2.v1); + v[3] = ROUNDF(ctx->EvalMap.Map2Texture2.v2); + break; + case GL_MAP2_TEXTURE_COORD_3: + v[0] = ROUNDF(ctx->EvalMap.Map2Texture3.u1); + v[1] = ROUNDF(ctx->EvalMap.Map2Texture3.u2); + v[2] = ROUNDF(ctx->EvalMap.Map2Texture3.v1); + v[3] = ROUNDF(ctx->EvalMap.Map2Texture3.v2); + break; + case GL_MAP2_TEXTURE_COORD_4: + v[0] = ROUNDF(ctx->EvalMap.Map2Texture4.u1); + v[1] = ROUNDF(ctx->EvalMap.Map2Texture4.u2); + v[2] = ROUNDF(ctx->EvalMap.Map2Texture4.v1); + v[3] = ROUNDF(ctx->EvalMap.Map2Texture4.v2); + break; + case GL_MAP2_VERTEX_3: + v[0] = ROUNDF(ctx->EvalMap.Map2Vertex3.u1); + v[1] = ROUNDF(ctx->EvalMap.Map2Vertex3.u2); + v[2] = ROUNDF(ctx->EvalMap.Map2Vertex3.v1); + v[3] = ROUNDF(ctx->EvalMap.Map2Vertex3.v2); + break; + case GL_MAP2_VERTEX_4: + v[0] = ROUNDF(ctx->EvalMap.Map2Vertex4.u1); + v[1] = ROUNDF(ctx->EvalMap.Map2Vertex4.u2); + v[2] = ROUNDF(ctx->EvalMap.Map2Vertex4.v1); + v[3] = ROUNDF(ctx->EvalMap.Map2Vertex4.v2); + break; + default: + gl_error( ctx, GL_INVALID_ENUM, "glGetMapiv(target)" ); + } + break; + default: + gl_error( ctx, GL_INVALID_ENUM, "glGetMapiv(query)" ); + } +} + + + +void gl_EvalCoord1f(GLcontext* ctx, GLfloat u) +{ + GLfloat vertex[4]; + GLfloat normal[3]; + GLfloat fcolor[4]; + GLubyte icolor[4]; + GLubyte *colorptr; + GLfloat texcoord[4]; + GLuint index; + register GLfloat uu; + + /** Vertex **/ + if (ctx->Eval.Map1Vertex4) + { + struct gl_1d_map *map = &ctx->EvalMap.Map1Vertex4; + uu = (u - map->u1) / (map->u2 - map->u1); + horner_bezier_curve(map->Points, vertex, uu, 4, map->Order); + } + else if (ctx->Eval.Map1Vertex3) + { + struct gl_1d_map *map = &ctx->EvalMap.Map1Vertex3; + uu = (u - map->u1) / (map->u2 - map->u1); + horner_bezier_curve(map->Points, vertex, uu, 3, map->Order); + vertex[3] = 1.0; + } + + /** Color Index **/ + if (ctx->Eval.Map1Index) + { + struct gl_1d_map *map = &ctx->EvalMap.Map1Index; + GLfloat findex; + uu = (u - map->u1) / (map->u2 - map->u1); + horner_bezier_curve(map->Points, &findex, uu, 1, map->Order); + index = (GLuint) (GLint) findex; + } + else { + index = ctx->Current.Index; + } + + /** Color **/ + if (ctx->Eval.Map1Color4) { + struct gl_1d_map *map = &ctx->EvalMap.Map1Color4; + uu = (u - map->u1) / (map->u2 - map->u1); + horner_bezier_curve(map->Points, fcolor, uu, 4, map->Order); + icolor[0] = (GLint) (fcolor[0] * ctx->Visual->RedScale); + icolor[1] = (GLint) (fcolor[1] * ctx->Visual->GreenScale); + icolor[2] = (GLint) (fcolor[2] * ctx->Visual->BlueScale); + icolor[3] = (GLint) (fcolor[3] * ctx->Visual->AlphaScale); + colorptr = icolor; + } + else { + GLubyte col[4]; + COPY_4V(col, ctx->Current.ByteColor ); + colorptr = col; + } + + /** Normal Vector **/ + if (ctx->Eval.Map1Normal) { + struct gl_1d_map *map = &ctx->EvalMap.Map1Normal; + uu = (u - map->u1) / (map->u2 - map->u1); + horner_bezier_curve(map->Points, normal, uu, 3, map->Order); + } + else { + normal[0] = ctx->Current.Normal[0]; + normal[1] = ctx->Current.Normal[1]; + normal[2] = ctx->Current.Normal[2]; + } + + /** Texture Coordinates **/ + if (ctx->Eval.Map1TextureCoord4) { + struct gl_1d_map *map = &ctx->EvalMap.Map1Texture4; + uu = (u - map->u1) / (map->u2 - map->u1); + horner_bezier_curve(map->Points, texcoord, uu, 4, map->Order); + } + else if (ctx->Eval.Map1TextureCoord3) { + struct gl_1d_map *map = &ctx->EvalMap.Map1Texture3; + uu = (u - map->u1) / (map->u2 - map->u1); + horner_bezier_curve(map->Points, texcoord, uu, 3, map->Order); + texcoord[3] = 1.0; + } + else if (ctx->Eval.Map1TextureCoord2) { + struct gl_1d_map *map = &ctx->EvalMap.Map1Texture2; + uu = (u - map->u1) / (map->u2 - map->u1); + horner_bezier_curve(map->Points, texcoord, uu, 2, map->Order); + texcoord[2] = 0.0; + texcoord[3] = 1.0; + } + else if (ctx->Eval.Map1TextureCoord1) { + struct gl_1d_map *map = &ctx->EvalMap.Map1Texture1; + uu = (u - map->u1) / (map->u2 - map->u1); + horner_bezier_curve(map->Points, texcoord, uu, 1, map->Order); + texcoord[1] = 0.0; + texcoord[2] = 0.0; + texcoord[3] = 1.0; + } + else { + texcoord[0] = ctx->Current.TexCoord[0]; + texcoord[1] = ctx->Current.TexCoord[1]; + texcoord[2] = ctx->Current.TexCoord[2]; + texcoord[3] = ctx->Current.TexCoord[3]; + } + + gl_eval_vertex( ctx, vertex, normal, colorptr, index, texcoord ); +} + + +void gl_EvalCoord2f( GLcontext* ctx, GLfloat u, GLfloat v ) +{ + GLfloat vertex[4]; + GLfloat normal[3]; + GLfloat fcolor[4]; + GLubyte icolor[4]; + GLubyte *colorptr; + GLfloat texcoord[4]; + GLuint index; + register GLfloat uu, vv; + +#define CROSS_PROD(n, u, v) \ + (n)[0] = (u)[1]*(v)[2] - (u)[2]*(v)[1]; \ + (n)[1] = (u)[2]*(v)[0] - (u)[0]*(v)[2]; \ + (n)[2] = (u)[0]*(v)[1] - (u)[1]*(v)[0] + + /** Vertex **/ + if(ctx->Eval.Map2Vertex4) { + struct gl_2d_map *map = &ctx->EvalMap.Map2Vertex4; + uu = (u - map->u1) / (map->u2 - map->u1); + vv = (v - map->v1) / (map->v2 - map->v1); + + if (ctx->Eval.AutoNormal) { + GLfloat du[4], dv[4]; + + de_casteljau_surf(map->Points, vertex, du, dv, uu, vv, 4, + map->Uorder, map->Vorder); + + CROSS_PROD(normal, du, dv); + NORMALIZE_3FV(normal); + } + else { + horner_bezier_surf(map->Points, vertex, uu, vv, 4, + map->Uorder, map->Vorder); + } + } + else if (ctx->Eval.Map2Vertex3) { + struct gl_2d_map *map = &ctx->EvalMap.Map2Vertex3; + uu = (u - map->u1) / (map->u2 - map->u1); + vv = (v - map->v1) / (map->v2 - map->v1); + if (ctx->Eval.AutoNormal) { + GLfloat du[3], dv[3]; + de_casteljau_surf(map->Points, vertex, du, dv, uu, vv, 3, + map->Uorder, map->Vorder); + CROSS_PROD(normal, du, dv); + NORMALIZE_3FV(normal); + } + else { + horner_bezier_surf(map->Points, vertex, uu, vv, 3, + map->Uorder, map->Vorder); + } + vertex[3] = 1.0; + } +#undef CROSS_PROD + + /** Color Index **/ + if (ctx->Eval.Map2Index) { + GLfloat findex; + struct gl_2d_map *map = &ctx->EvalMap.Map2Index; + uu = (u - map->u1) / (map->u2 - map->u1); + vv = (v - map->v1) / (map->v2 - map->v1); + horner_bezier_surf(map->Points, &findex, uu, vv, 1, + map->Uorder, map->Vorder); + index = (GLuint) (GLint) findex; + } + else { + index = ctx->Current.Index; + } + + /** Color **/ + if (ctx->Eval.Map2Color4) { + struct gl_2d_map *map = &ctx->EvalMap.Map2Color4; + uu = (u - map->u1) / (map->u2 - map->u1); + vv = (v - map->v1) / (map->v2 - map->v1); + horner_bezier_surf(map->Points, fcolor, uu, vv, 4, + map->Uorder, map->Vorder); + icolor[0] = (GLint) (fcolor[0] * ctx->Visual->RedScale); + icolor[1] = (GLint) (fcolor[1] * ctx->Visual->GreenScale); + icolor[2] = (GLint) (fcolor[2] * ctx->Visual->BlueScale); + icolor[3] = (GLint) (fcolor[3] * ctx->Visual->AlphaScale); + colorptr = icolor; + } + else { + GLubyte col[4]; + COPY_4V(col, ctx->Current.ByteColor ); + colorptr = col; + } + + /** Normal **/ + if (!ctx->Eval.AutoNormal + || (!ctx->Eval.Map2Vertex3 && !ctx->Eval.Map2Vertex4)) { + if (ctx->Eval.Map2Normal) { + struct gl_2d_map *map = &ctx->EvalMap.Map2Normal; + uu = (u - map->u1) / (map->u2 - map->u1); + vv = (v - map->v1) / (map->v2 - map->v1); + horner_bezier_surf(map->Points, normal, uu, vv, 3, + map->Uorder, map->Vorder); + } + else { + normal[0] = ctx->Current.Normal[0]; + normal[1] = ctx->Current.Normal[1]; + normal[2] = ctx->Current.Normal[2]; + } + } + + /** Texture Coordinates **/ + if (ctx->Eval.Map2TextureCoord4) { + struct gl_2d_map *map = &ctx->EvalMap.Map2Texture4; + uu = (u - map->u1) / (map->u2 - map->u1); + vv = (v - map->v1) / (map->v2 - map->v1); + horner_bezier_surf(map->Points, texcoord, uu, vv, 4, + map->Uorder, map->Vorder); + } + else if (ctx->Eval.Map2TextureCoord3) { + struct gl_2d_map *map = &ctx->EvalMap.Map2Texture3; + uu = (u - map->u1) / (map->u2 - map->u1); + vv = (v - map->v1) / (map->v2 - map->v1); + horner_bezier_surf(map->Points, texcoord, uu, vv, 3, + map->Uorder, map->Vorder); + texcoord[3] = 1.0; + } + else if (ctx->Eval.Map2TextureCoord2) { + struct gl_2d_map *map = &ctx->EvalMap.Map2Texture2; + uu = (u - map->u1) / (map->u2 - map->u1); + vv = (v - map->v1) / (map->v2 - map->v1); + horner_bezier_surf(map->Points, texcoord, uu, vv, 2, + map->Uorder, map->Vorder); + texcoord[2] = 0.0; + texcoord[3] = 1.0; + } + else if (ctx->Eval.Map2TextureCoord1) { + struct gl_2d_map *map = &ctx->EvalMap.Map2Texture1; + uu = (u - map->u1) / (map->u2 - map->u1); + vv = (v - map->v1) / (map->v2 - map->v1); + horner_bezier_surf(map->Points, texcoord, uu, vv, 1, + map->Uorder, map->Vorder); + texcoord[1] = 0.0; + texcoord[2] = 0.0; + texcoord[3] = 1.0; + } + else + { + texcoord[0] = ctx->Current.TexCoord[0]; + texcoord[1] = ctx->Current.TexCoord[1]; + texcoord[2] = ctx->Current.TexCoord[2]; + texcoord[3] = ctx->Current.TexCoord[3]; + } + + gl_eval_vertex( ctx, vertex, normal, colorptr, index, texcoord ); +} + + +void gl_MapGrid1f( GLcontext* ctx, GLint un, GLfloat u1, GLfloat u2 ) +{ + if (INSIDE_BEGIN_END(ctx)) { + gl_error( ctx, GL_INVALID_OPERATION, "glMapGrid1f" ); + return; + } + if (un<1) { + gl_error( ctx, GL_INVALID_VALUE, "glMapGrid1f" ); + return; + } + ctx->Eval.MapGrid1un = un; + ctx->Eval.MapGrid1u1 = u1; + ctx->Eval.MapGrid1u2 = u2; +} + + +void gl_MapGrid2f( GLcontext* ctx, GLint un, GLfloat u1, GLfloat u2, + GLint vn, GLfloat v1, GLfloat v2 ) +{ + if (INSIDE_BEGIN_END(ctx)) { + gl_error( ctx, GL_INVALID_OPERATION, "glMapGrid2f" ); + return; + } + if (un<1) { + gl_error( ctx, GL_INVALID_VALUE, "glMapGrid2f(un)" ); + return; + } + if (vn<1) { + gl_error( ctx, GL_INVALID_VALUE, "glMapGrid2f(vn)" ); + return; + } + ctx->Eval.MapGrid2un = un; + ctx->Eval.MapGrid2u1 = u1; + ctx->Eval.MapGrid2u2 = u2; + ctx->Eval.MapGrid2vn = vn; + ctx->Eval.MapGrid2v1 = v1; + ctx->Eval.MapGrid2v2 = v2; +} + + +void gl_EvalPoint1( GLcontext* ctx, GLint i ) +{ + GLfloat u, du; + + if (i==0) { + u = ctx->Eval.MapGrid1u1; + } + else if (i==ctx->Eval.MapGrid1un) { + u = ctx->Eval.MapGrid1u2; + } + else { + du = (ctx->Eval.MapGrid1u2 - ctx->Eval.MapGrid1u1) + / (GLfloat) ctx->Eval.MapGrid1un; + u = i * du + ctx->Eval.MapGrid1u1; + } + gl_EvalCoord1f( ctx, u ); +} + + + +void gl_EvalPoint2( GLcontext* ctx, GLint i, GLint j ) +{ + GLfloat u, du; + GLfloat v, dv; + + if (i==0) { + u = ctx->Eval.MapGrid2u1; + } + else if (i==ctx->Eval.MapGrid2un) { + u = ctx->Eval.MapGrid2u2; + } + else { + du = (ctx->Eval.MapGrid2u2 - ctx->Eval.MapGrid2u1) + / (GLfloat) ctx->Eval.MapGrid2un; + u = i * du + ctx->Eval.MapGrid2u1; + } + + if (j==0) { + v = ctx->Eval.MapGrid2v1; + } + else if (j==ctx->Eval.MapGrid2vn) { + v = ctx->Eval.MapGrid2v2; + } + else { + dv = (ctx->Eval.MapGrid2v2 - ctx->Eval.MapGrid2v1) + / (GLfloat) ctx->Eval.MapGrid2vn; + v = j * dv + ctx->Eval.MapGrid2v1; + } + + gl_EvalCoord2f( ctx, u, v ); +} + + + +void gl_EvalMesh1( GLcontext* ctx, GLenum mode, GLint i1, GLint i2 ) +{ + GLint i; + GLfloat u, du; + GLenum prim; + + if (INSIDE_BEGIN_END(ctx)) { + gl_error( ctx, GL_INVALID_OPERATION, "glEvalMesh1" ); + return; + } + + switch (mode) { + case GL_POINT: + prim = GL_POINTS; + break; + case GL_LINE: + prim = GL_LINE_STRIP; + break; + default: + gl_error( ctx, GL_INVALID_ENUM, "glEvalMesh1(mode)" ); + return; + } + + du = (ctx->Eval.MapGrid1u2 - ctx->Eval.MapGrid1u1) + / (GLfloat) ctx->Eval.MapGrid1un; + + gl_Begin( ctx, prim ); + for (i=i1;i<=i2;i++) { + if (i==0) { + u = ctx->Eval.MapGrid1u1; + } + else if (i==ctx->Eval.MapGrid1un) { + u = ctx->Eval.MapGrid1u2; + } + else { + u = i * du + ctx->Eval.MapGrid1u1; + } + gl_EvalCoord1f( ctx, u ); + } + gl_End(ctx); +} + + + +void gl_EvalMesh2( GLcontext* ctx, GLenum mode, GLint i1, GLint i2, GLint j1, GLint j2 ) +{ + GLint i, j; + GLfloat u, du, v, dv, v1, v2; + + if (INSIDE_BEGIN_END(ctx)) { + gl_error( ctx, GL_INVALID_OPERATION, "glEvalMesh2" ); + return; + } + + du = (ctx->Eval.MapGrid2u2 - ctx->Eval.MapGrid2u1) + / (GLfloat) ctx->Eval.MapGrid2un; + dv = (ctx->Eval.MapGrid2v2 - ctx->Eval.MapGrid2v1) + / (GLfloat) ctx->Eval.MapGrid2vn; + +#define I_TO_U( I, U ) \ + if ((I)==0) { \ + U = ctx->Eval.MapGrid2u1; \ + } \ + else if ((I)==ctx->Eval.MapGrid2un) { \ + U = ctx->Eval.MapGrid2u2; \ + } \ + else { \ + U = (I) * du + ctx->Eval.MapGrid2u1;\ + } + +#define J_TO_V( J, V ) \ + if ((J)==0) { \ + V = ctx->Eval.MapGrid2v1; \ + } \ + else if ((J)==ctx->Eval.MapGrid2vn) { \ + V = ctx->Eval.MapGrid2v2; \ + } \ + else { \ + V = (J) * dv + ctx->Eval.MapGrid2v1;\ + } + + switch (mode) { + case GL_POINT: + gl_Begin( ctx, GL_POINTS ); + for (j=j1;j<=j2;j++) { + J_TO_V( j, v ); + for (i=i1;i<=i2;i++) { + I_TO_U( i, u ); + gl_EvalCoord2f( ctx, u, v ); + } + } + gl_End(ctx); + break; + case GL_LINE: + for (j=j1;j<=j2;j++) { + J_TO_V( j, v ); + gl_Begin( ctx, GL_LINE_STRIP ); + for (i=i1;i<=i2;i++) { + I_TO_U( i, u ); + gl_EvalCoord2f( ctx, u, v ); + } + gl_End(ctx); + } + for (i=i1;i<=i2;i++) { + I_TO_U( i, u ); + gl_Begin( ctx, GL_LINE_STRIP ); + for (j=j1;j<=j2;j++) { + J_TO_V( j, v ); + gl_EvalCoord2f( ctx, u, v ); + } + gl_End(ctx); + } + break; + case GL_FILL: + for (j=j1;j +#include +#include "context.h" +#include "feedback.h" +#include "dlist.h" +#include "macros.h" +#include "types.h" +#endif + + + +#define FB_3D 0x01 +#define FB_4D 0x02 +#define FB_INDEX 0x04 +#define FB_COLOR 0x08 +#define FB_TEXTURE 0X10 + + + +void +gl_FeedbackBuffer( GLcontext *ctx, GLsizei size, GLenum type, GLfloat *buffer ) +{ + if (ctx->RenderMode==GL_FEEDBACK || INSIDE_BEGIN_END(ctx)) { + gl_error( ctx, GL_INVALID_OPERATION, "glFeedbackBuffer" ); + return; + } + + if (size<0) { + gl_error( ctx, GL_INVALID_VALUE, "glFeedbackBuffer(size<0)" ); + return; + } + if (!buffer) { + gl_error( ctx, GL_INVALID_VALUE, "glFeedbackBuffer(buffer==NULL)" ); + ctx->Feedback.BufferSize = 0; + return; + } + + switch (type) { + case GL_2D: + ctx->Feedback.Mask = 0; + ctx->Feedback.Type = type; + break; + case GL_3D: + ctx->Feedback.Mask = FB_3D; + ctx->Feedback.Type = type; + break; + case GL_3D_COLOR: + ctx->Feedback.Mask = FB_3D + | (ctx->Visual->RGBAflag ? FB_COLOR : FB_INDEX); + ctx->Feedback.Type = type; + break; + case GL_3D_COLOR_TEXTURE: + ctx->Feedback.Mask = FB_3D + | (ctx->Visual->RGBAflag ? FB_COLOR : FB_INDEX) + | FB_TEXTURE; + ctx->Feedback.Type = type; + break; + case GL_4D_COLOR_TEXTURE: + ctx->Feedback.Mask = FB_3D | FB_4D + | (ctx->Visual->RGBAflag ? FB_COLOR : FB_INDEX) + | FB_TEXTURE; + ctx->Feedback.Type = type; + break; + default: + ctx->Feedback.Mask = 0; + gl_error( ctx, GL_INVALID_ENUM, "glFeedbackBuffer" ); + } + + ctx->Feedback.BufferSize = size; + ctx->Feedback.Buffer = buffer; + ctx->Feedback.Count = 0; +} + + + +void gl_PassThrough( GLcontext *ctx, GLfloat token ) +{ + if (INSIDE_BEGIN_END(ctx)) { + gl_error( ctx, GL_INVALID_OPERATION, "glPassThrough" ); + return; + } + + if (ctx->RenderMode==GL_FEEDBACK) { + FEEDBACK_TOKEN( ctx, (GLfloat) (GLint) GL_PASS_THROUGH_TOKEN ); + FEEDBACK_TOKEN( ctx, token ); + } +} + + + +/* + * Put a vertex into the feedback buffer. + */ +void gl_feedback_vertex( GLcontext *ctx, + GLfloat x, GLfloat y, GLfloat z, GLfloat w, + const GLfloat color[4], GLfloat index, + const GLfloat texcoord[4] ) +{ + FEEDBACK_TOKEN( ctx, x ); + FEEDBACK_TOKEN( ctx, y ); + if (ctx->Feedback.Mask & FB_3D) { + FEEDBACK_TOKEN( ctx, z ); + } + if (ctx->Feedback.Mask & FB_4D) { + FEEDBACK_TOKEN( ctx, w ); + } + if (ctx->Feedback.Mask & FB_INDEX) { + FEEDBACK_TOKEN( ctx, index ); + } + if (ctx->Feedback.Mask & FB_COLOR) { + FEEDBACK_TOKEN( ctx, color[0] ); + FEEDBACK_TOKEN( ctx, color[1] ); + FEEDBACK_TOKEN( ctx, color[2] ); + FEEDBACK_TOKEN( ctx, color[3] ); + } + if (ctx->Feedback.Mask & FB_TEXTURE) { + FEEDBACK_TOKEN( ctx, texcoord[0] ); + FEEDBACK_TOKEN( ctx, texcoord[1] ); + FEEDBACK_TOKEN( ctx, texcoord[2] ); + FEEDBACK_TOKEN( ctx, texcoord[3] ); + } +} + + + +/**********************************************************************/ +/* Selection */ +/**********************************************************************/ + + +/* + * NOTE: this function can't be put in a display list. + */ +void gl_SelectBuffer( GLcontext *ctx, GLsizei size, GLuint *buffer ) +{ + if (INSIDE_BEGIN_END(ctx)) { + gl_error( ctx, GL_INVALID_OPERATION, "glSelectBuffer" ); + } + if (ctx->RenderMode==GL_SELECT) { + gl_error( ctx, GL_INVALID_OPERATION, "glSelectBuffer" ); + } + ctx->Select.Buffer = buffer; + ctx->Select.BufferSize = size; + ctx->Select.BufferCount = 0; + + ctx->Select.HitFlag = GL_FALSE; + ctx->Select.HitMinZ = 1.0; + ctx->Select.HitMaxZ = 0.0; +} + + +void gl_InitNames( GLcontext *ctx ) +{ + if (INSIDE_BEGIN_END(ctx)) { + gl_error( ctx, GL_INVALID_OPERATION, "glInitNames" ); + } + ctx->Select.NameStackDepth = 0; + ctx->Select.HitFlag = GL_FALSE; + ctx->Select.HitMinZ = 1.0; + ctx->Select.HitMaxZ = 0.0; +} + + + +#define WRITE_RECORD( CTX, V ) \ + if (CTX->Select.BufferCount < CTX->Select.BufferSize) { \ + CTX->Select.Buffer[CTX->Select.BufferCount] = (V); \ + } \ + CTX->Select.BufferCount++; + + + +void gl_update_hitflag( GLcontext *ctx, GLfloat z ) +{ + ctx->Select.HitFlag = GL_TRUE; + if (z < ctx->Select.HitMinZ) { + ctx->Select.HitMinZ = z; + } + if (z > ctx->Select.HitMaxZ) { + ctx->Select.HitMaxZ = z; + } +} + + + +static void write_hit_record( GLcontext *ctx ) +{ + GLuint i; + GLuint zmin, zmax, zscale = (~0u); + + /* HitMinZ and HitMaxZ are in [0,1]. Multiply these values by */ + /* 2^32-1 and round to nearest unsigned integer. */ + + assert( ctx != NULL ); /* this line magically fixes a SunOS 5.x/gcc bug */ + zmin = (GLuint) ((GLfloat) zscale * ctx->Select.HitMinZ); + zmax = (GLuint) ((GLfloat) zscale * ctx->Select.HitMaxZ); + + WRITE_RECORD( ctx, ctx->Select.NameStackDepth ); + WRITE_RECORD( ctx, zmin ); + WRITE_RECORD( ctx, zmax ); + for (i=0;iSelect.NameStackDepth;i++) { + WRITE_RECORD( ctx, ctx->Select.NameStack[i] ); + } + + ctx->Select.Hits++; + ctx->Select.HitFlag = GL_FALSE; + ctx->Select.HitMinZ = 1.0; + ctx->Select.HitMaxZ = -1.0; +} + + + +void gl_LoadName( GLcontext *ctx, GLuint name ) +{ + if (INSIDE_BEGIN_END(ctx)) { + gl_error( ctx, GL_INVALID_OPERATION, "glLoadName" ); + return; + } + if (ctx->RenderMode!=GL_SELECT) { + return; + } + if (ctx->Select.NameStackDepth==0) { + gl_error( ctx, GL_INVALID_OPERATION, "glLoadName" ); + return; + } + if (ctx->Select.HitFlag) { + write_hit_record( ctx ); + } + if (ctx->Select.NameStackDepthSelect.NameStack[ctx->Select.NameStackDepth-1] = name; + } + else { + ctx->Select.NameStack[MAX_NAME_STACK_DEPTH-1] = name; + } +} + + +void gl_PushName( GLcontext *ctx, GLuint name ) +{ + if (INSIDE_BEGIN_END(ctx)) { + gl_error( ctx, GL_INVALID_OPERATION, "glPushName" ); + return; + } + if (ctx->RenderMode!=GL_SELECT) { + return; + } + if (ctx->Select.HitFlag) { + write_hit_record( ctx ); + } + if (ctx->Select.NameStackDepthSelect.NameStack[ctx->Select.NameStackDepth++] = name; + } + else { + gl_error( ctx, GL_STACK_OVERFLOW, "glPushName" ); + } +} + + + +void gl_PopName( GLcontext *ctx ) +{ + if (INSIDE_BEGIN_END(ctx)) { + gl_error( ctx, GL_INVALID_OPERATION, "glPopName" ); + return; + } + if (ctx->RenderMode!=GL_SELECT) { + return; + } + if (ctx->Select.HitFlag) { + write_hit_record( ctx ); + } + if (ctx->Select.NameStackDepth>0) { + ctx->Select.NameStackDepth--; + } + else { + gl_error( ctx, GL_STACK_UNDERFLOW, "glPopName" ); + } +} + + + +/**********************************************************************/ +/* Render Mode */ +/**********************************************************************/ + + + +/* + * NOTE: this function can't be put in a display list. + */ +GLint gl_RenderMode( GLcontext *ctx, GLenum mode ) +{ + GLint result; + + if (INSIDE_BEGIN_END(ctx)) { + gl_error( ctx, GL_INVALID_OPERATION, "glRenderMode" ); + } + + switch (ctx->RenderMode) { + case GL_RENDER: + result = 0; + break; + case GL_SELECT: + if (ctx->Select.HitFlag) { + write_hit_record( ctx ); + } + if (ctx->Select.BufferCount > ctx->Select.BufferSize) { + /* overflow */ +#ifdef DEBUG + gl_warning(ctx, "Feedback buffer overflow"); +#endif + result = -1; + } + else { + result = ctx->Select.Hits; + } + ctx->Select.BufferCount = 0; + ctx->Select.Hits = 0; + ctx->Select.NameStackDepth = 0; + break; + case GL_FEEDBACK: + if (ctx->Feedback.Count > ctx->Feedback.BufferSize) { + /* overflow */ + result = -1; + } + else { + result = ctx->Feedback.Count; + } + ctx->Feedback.Count = 0; + break; + default: + gl_error( ctx, GL_INVALID_ENUM, "glRenderMode" ); + return 0; + } + + switch (mode) { + case GL_RENDER: + break; + case GL_SELECT: + if (ctx->Select.BufferSize==0) { + /* haven't called glSelectBuffer yet */ + gl_error( ctx, GL_INVALID_OPERATION, "glRenderMode" ); + } + break; + case GL_FEEDBACK: + if (ctx->Feedback.BufferSize==0) { + /* haven't called glFeedbackBuffer yet */ + gl_error( ctx, GL_INVALID_OPERATION, "glRenderMode" ); + } + break; + default: + gl_error( ctx, GL_INVALID_ENUM, "glRenderMode" ); + return 0; + } + + ctx->RenderMode = mode; + ctx->NewState |= NEW_ALL; + + return result; +} + diff --git a/dll/opengl/mesa/feedback.h b/dll/opengl/mesa/feedback.h new file mode 100644 index 00000000000..daa545a4800 --- /dev/null +++ b/dll/opengl/mesa/feedback.h @@ -0,0 +1,75 @@ +/* $Id: feedback.h,v 1.1 1996/09/13 01:38:16 brianp Exp $ */ + +/* + * Mesa 3-D graphics library + * Version: 2.0 + * Copyright (C) 1995-1996 Brian Paul + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Library General Public + * License as published by the Free Software Foundation; either + * version 2 of the License, or (at your option) any later version. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Library General Public License for more details. + * + * You should have received a copy of the GNU Library General Public + * License along with this library; if not, write to the Free + * Software Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. + */ + + +/* + * $Log: feedback.h,v $ + * Revision 1.1 1996/09/13 01:38:16 brianp + * Initial revision + * + */ + + +#ifndef FEEDBACK_H +#define FEEDBACK_H + + +#include "types.h" + + +#define FEEDBACK_TOKEN( CTX, T ) \ + if (CTX->Feedback.Count < CTX->Feedback.BufferSize) { \ + CTX->Feedback.Buffer[CTX->Feedback.Count] = (T); \ + } \ + CTX->Feedback.Count++; + + +extern void gl_feedback_vertex( GLcontext *ctx, + GLfloat x, GLfloat y, GLfloat z, GLfloat w, + const GLfloat color[4], GLfloat index, + const GLfloat texcoord[4] ); + + +extern void gl_update_hitflag( GLcontext *ctx, GLfloat z ); + + +extern void gl_PassThrough( GLcontext *ctx, GLfloat token ); + +extern void gl_FeedbackBuffer( GLcontext *ctx, GLsizei size, + GLenum type, GLfloat *buffer ); + +extern void gl_SelectBuffer( GLcontext *ctx, GLsizei size, GLuint *buffer ); + +extern void gl_InitNames( GLcontext *ctx ); + +extern void gl_LoadName( GLcontext *ctx, GLuint name ); + +extern void gl_PushName( GLcontext *ctx, GLuint name ); + +extern void gl_PopName( GLcontext *ctx ); + +extern GLint gl_RenderMode( GLcontext *ctx, GLenum mode ); + + + +#endif + diff --git a/dll/opengl/mesa/fixed.h b/dll/opengl/mesa/fixed.h new file mode 100644 index 00000000000..6bc820a9cea --- /dev/null +++ b/dll/opengl/mesa/fixed.h @@ -0,0 +1,57 @@ +/* $Id: fixed.h,v 1.2 1996/10/01 03:31:04 brianp Exp $ */ + +/* + * Mesa 3-D graphics library + * Version: 2.0 + * Copyright (C) 1995-1996 Brian Paul + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Library General Public + * License as published by the Free Software Foundation; either + * version 2 of the License, or (at your option) any later version. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Library General Public License for more details. + * + * You should have received a copy of the GNU Library General Public + * License along with this library; if not, write to the Free + * Software Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. + */ + + +/* + * + * Revision 1.1 1996/09/13 01:38:16 brianp + * Initial revision + * + */ + + +#ifndef FIXED_H +#define FIXED_H + + +typedef int GLfixed; + +#define FIXED_ONE 0x00000800 +#define FIXED_HALF 0x00000400 +#define FIXED_FRAC_MASK 0x000007FF +#define FIXED_INT_MASK (~FIXED_FRAC_MASK) +#define FIXED_EPSILON 1 +#define FIXED_SCALE 2048.0f +#define FIXED_SHIFT 11 +#define FloatToFixed(X) ((GLfixed) ((X) * FIXED_SCALE)) +#define IntToFixed(I) ((I) << FIXED_SHIFT) +#define FixedToInt(X) ((X) >> FIXED_SHIFT) +#define FixedToUns(X) (((unsigned int)(X)) >> 11) +#define FixedCeil(X) (((X) + FIXED_ONE - FIXED_EPSILON) & FIXED_INT_MASK) +#define FixedFloor(X) ((X) & FIXED_INT_MASK) +/* 0.00048828125 = 1/FIXED_SCALE */ +#define FixedToFloat(X) ((X) * 0.00048828125f) +#define PosFloatToFixed(X) FloatToFixed(X) +#define SignedFloatToFixed(X) FloatToFixed(X) + + +#endif diff --git a/dll/opengl/mesa/fog.c b/dll/opengl/mesa/fog.c new file mode 100644 index 00000000000..6e75a77f84f --- /dev/null +++ b/dll/opengl/mesa/fog.c @@ -0,0 +1,389 @@ +/* $Id: fog.c,v 1.9 1997/07/24 01:25:01 brianp Exp $ */ + +/* + * Mesa 3-D graphics library + * Version: 2.4 + * Copyright (C) 1995-1996 Brian Paul + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Library General Public + * License as published by the Free Software Foundation; either + * version 2 of the License, or (at your option) any later version. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Library General Public License for more details. + * + * You should have received a copy of the GNU Library General Public + * License along with this library; if not, write to the Free + * Software Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. + */ + + +/* + * $Log: fog.c,v $ + * Revision 1.9 1997/07/24 01:25:01 brianp + * changed precompiled header symbol from PCH to PC_HEADER + * + * Revision 1.8 1997/06/20 04:14:47 brianp + * changed color components from GLfixed to GLubyte + * + * Revision 1.7 1997/05/28 03:24:54 brianp + * added precompiled header (PCH) support + * + * Revision 1.6 1997/05/22 03:03:47 brianp + * don't apply fog to alpha values + * + * Revision 1.5 1997/04/20 20:28:49 brianp + * replaced abort() with gl_problem() + * + * Revision 1.4 1996/11/04 02:30:15 brianp + * optimized gl_fog_color_pixels() and gl_fog_index_pixels() + * + * Revision 1.3 1996/09/27 01:26:52 brianp + * added missing default cases to switches + * + * Revision 1.2 1996/09/15 14:17:30 brianp + * now use GLframebuffer and GLvisual + * + * Revision 1.1 1996/09/13 01:38:16 brianp + * Initial revision + * + */ + + +#ifdef PC_HEADER +#include "all.h" +#else +#include +#include +#include "context.h" +#include "fog.h" +#include "dlist.h" +#include "macros.h" +#include "types.h" +#endif + + + +void gl_Fogfv( GLcontext *ctx, GLenum pname, const GLfloat *params ) +{ + GLenum m; + + switch (pname) { + case GL_FOG_MODE: + m = (GLenum) (GLint) *params; + if (m==GL_LINEAR || m==GL_EXP || m==GL_EXP2) { + ctx->Fog.Mode = m; + } + else { + gl_error( ctx, GL_INVALID_ENUM, "glFog" ); + } + break; + case GL_FOG_DENSITY: + if (*params<0.0) { + gl_error( ctx, GL_INVALID_VALUE, "glFog" ); + } + else { + ctx->Fog.Density = *params; + } + break; + case GL_FOG_START: +#ifndef GL_VERSION_1_1 + if (*params<0.0F) { + gl_error( ctx, GL_INVALID_VALUE, "glFog(GL_FOG_START)" ); + return; + } +#endif + ctx->Fog.Start = *params; + break; + case GL_FOG_END: +#ifndef GL_VERSION_1_1 + if (*params<0.0F) { + gl_error( ctx, GL_INVALID_VALUE, "glFog(GL_FOG_END)" ); + return; + } +#endif + ctx->Fog.End = *params; + break; + case GL_FOG_INDEX: + ctx->Fog.Index = *params; + break; + case GL_FOG_COLOR: + ctx->Fog.Color[0] = params[0]; + ctx->Fog.Color[1] = params[1]; + ctx->Fog.Color[2] = params[2]; + ctx->Fog.Color[3] = params[3]; + break; + default: + gl_error( ctx, GL_INVALID_ENUM, "glFog" ); + } +} + + + + +/* + * Compute the fogged color for an array of vertices. + * Input: n - number of vertices + * v - array of vertices + * color - the original vertex colors + * Output: color - the fogged colors + */ +void gl_fog_color_vertices( GLcontext *ctx, + GLuint n, GLfloat v[][4], GLubyte color[][4] ) +{ + GLuint i; + GLfloat d; + GLfloat fogr = ctx->Fog.Color[0] * ctx->Visual->RedScale; + GLfloat fogg = ctx->Fog.Color[1] * ctx->Visual->GreenScale; + GLfloat fogb = ctx->Fog.Color[2] * ctx->Visual->BlueScale; + GLfloat end = ctx->Fog.End; + + switch (ctx->Fog.Mode) { + case GL_LINEAR: + d = 1.0F / (ctx->Fog.End - ctx->Fog.Start); + for (i=0;iFog.Density; + for (i=0;iFog.Density*ctx->Fog.Density); + for (i=0;iFog.Mode) { + case GL_LINEAR: + { + GLfloat d = 1.0F / (ctx->Fog.End - ctx->Fog.Start); + GLfloat fogindex = ctx->Fog.Index; + GLfloat fogend = ctx->Fog.End; + GLuint i; + for (i=0;iFog.Density; + GLfloat fogindex = ctx->Fog.Index; + GLuint i; + for (i=0;iFog.Density*ctx->Fog.Density); + GLfloat fogindex = ctx->Fog.Index; + GLuint i; + for (i=0;iProjectionMatrix[10]; + GLfloat d = ctx->ProjectionMatrix[14]; + GLuint i; + + GLfloat fog_red = ctx->Fog.Color[0] * ctx->Visual->RedScale; + GLfloat fog_green = ctx->Fog.Color[1] * ctx->Visual->GreenScale; + GLfloat fog_blue = ctx->Fog.Color[2] * ctx->Visual->BlueScale; + + GLfloat tz = ctx->Viewport.Tz; + GLfloat szInv = 1.0F / ctx->Viewport.Sz; + + switch (ctx->Fog.Mode) { + case GL_LINEAR: + { + GLfloat fogEnd = ctx->Fog.End; + GLfloat fogScale = 1.0F / (ctx->Fog.End - ctx->Fog.Start); + for (i=0;iFog.Density * eyez ); + f = CLAMP( f, 0.0F, 1.0F ); + g = 1.0F - f; + red[i] = (GLint) (f * (GLfloat) red[i] + g * fog_red); + green[i] = (GLint) (f * (GLfloat) green[i] + g * fog_green); + blue[i] = (GLint) (f * (GLfloat) blue[i] + g * fog_blue); + } + break; + case GL_EXP2: + { + GLfloat negDensitySquared = -ctx->Fog.Density * ctx->Fog.Density; + for (i=0;iProjectionMatrix[10]; + GLfloat d = ctx->ProjectionMatrix[14]; + GLuint i; + + GLfloat tz = ctx->Viewport.Tz; + GLfloat szInv = 1.0F / ctx->Viewport.Sz; + + switch (ctx->Fog.Mode) { + case GL_LINEAR: + { + GLfloat fogEnd = ctx->Fog.End; + GLfloat fogScale = 1.0F / (ctx->Fog.End - ctx->Fog.Start); + for (i=0;iFog.Index); + } + } + break; + case GL_EXP: + for (i=0;iFog.Density * eyez ); + f = CLAMP( f, 0.0F, 1.0F ); + index[i] = (GLuint) ((GLfloat) index[i] + (1.0F-f) * ctx->Fog.Index); + } + break; + case GL_EXP2: + { + GLfloat negDensitySquared = -ctx->Fog.Density * ctx->Fog.Density; + for (i=0;iFog.Index); + } + } + break; + default: + gl_problem(ctx, "Bad fog mode in gl_fog_index_pixels"); + return; + } +} + diff --git a/dll/opengl/mesa/fog.h b/dll/opengl/mesa/fog.h new file mode 100644 index 00000000000..8d3278fd316 --- /dev/null +++ b/dll/opengl/mesa/fog.h @@ -0,0 +1,62 @@ +/* $Id: fog.h,v 1.2 1997/06/20 04:14:47 brianp Exp $ */ + +/* + * Mesa 3-D graphics library + * Version: 2.3 + * Copyright (C) 1995-1996 Brian Paul + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Library General Public + * License as published by the Free Software Foundation; either + * version 2 of the License, or (at your option) any later version. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Library General Public License for more details. + * + * You should have received a copy of the GNU Library General Public + * License along with this library; if not, write to the Free + * Software Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. + */ + + +/* + * $Log: fog.h,v $ + * Revision 1.2 1997/06/20 04:14:47 brianp + * changed color components from GLfixed to GLubyte + * + * Revision 1.1 1996/09/13 01:38:16 brianp + * Initial revision + * + */ + + + +#ifndef FOG_H +#define FOG_H + + +#include "types.h" + + +extern void gl_Fogfv( GLcontext *ctx, GLenum pname, const GLfloat *params ); + + +extern void gl_fog_color_vertices( GLcontext *ctx, GLuint n, + GLfloat v[][4], GLubyte color[][4] ); + +extern void gl_fog_index_vertices( GLcontext *ctx, GLuint n, + GLfloat v[][4], GLuint indx[] ); + + +extern void gl_fog_color_pixels( GLcontext *ctx, + GLuint n, const GLdepth z[], + GLubyte red[], GLubyte green[], + GLubyte blue[], GLubyte alpha[] ); + +extern void gl_fog_index_pixels( GLcontext *ctx, + GLuint n, const GLdepth z[], GLuint indx[] ); + + +#endif diff --git a/dll/opengl/mesa/get.c b/dll/opengl/mesa/get.c new file mode 100644 index 00000000000..7d268adc1af --- /dev/null +++ b/dll/opengl/mesa/get.c @@ -0,0 +1,3198 @@ +/* $Id: get.c,v 1.19 1998/02/04 05:00:28 brianp Exp $ */ + +/* + * Mesa 3-D graphics library + * Version: 2.6 + * Copyright (C) 1995-1997 Brian Paul + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Library General Public + * License as published by the Free Software Foundation; either + * version 2 of the License, or (at your option) any later version. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Library General Public License for more details. + * + * You should have received a copy of the GNU Library General Public + * License along with this library; if not, write to the Free + * Software Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. + */ + + +/* + * $Log: get.c,v $ + * Revision 1.19 1998/02/04 05:00:28 brianp + * more casts for Amiga StormC + * + * Revision 1.18 1998/02/03 23:45:02 brianp + * added casts to prevent warnings with Amiga StormC compiler + * + * Revision 1.17 1997/12/06 18:06:50 brianp + * moved several static display list vars into GLcontext + * + * Revision 1.16 1997/10/29 01:29:09 brianp + * added GL_EXT_point_parameters extension from Daniel Barrero + * + * Revision 1.15 1997/10/16 01:59:08 brianp + * added GL_EXT_shared_texture_palette extension + * + * Revision 1.14 1997/07/24 01:25:18 brianp + * changed precompiled header symbol from PCH to PC_HEADER + * + * Revision 1.13 1997/06/20 02:00:27 brianp + * replaced Current.IntColor with Current.ByteColor + * + * Revision 1.12 1997/05/28 03:24:54 brianp + * added precompiled header (PCH) support + * + * Revision 1.11 1997/05/26 21:13:42 brianp + * rewrite code for GL_RED/GREEN/BLUE/ALPHA_BITS + * + * Revision 1.10 1997/04/26 04:33:11 brianp + * glGet(accum, stencil, depth bits) always returned non-zero values- wrong + * + * Revision 1.9 1997/03/11 00:57:38 brianp + * removed redundant GL_POLYGON_OFFSET_FACTOR_EXT cases + * + * Revision 1.8 1997/02/10 21:15:59 brianp + * renamed GL_TEXTURE_BINDING_3D_EXT to GL_TEXTURE_3D_BINDING_EXT + * + * Revision 1.7 1997/02/09 19:53:43 brianp + * now use TEXTURE_xD enable constants + * + * Revision 1.6 1997/02/09 18:49:23 brianp + * added GL_EXT_texture3D support + * + * Revision 1.5 1997/01/30 21:05:20 brianp + * moved in gl_GetPointerv() from varray.c + * added some missing GLenums to the glGet*() functions + * + * Revision 1.4 1997/01/28 22:13:42 brianp + * now there's separate state for CI and RGBA logic op enabled + * + * Revision 1.3 1996/10/11 03:43:34 brianp + * replaced old texture _EXT symbols + * added GL_EXT_polygon_offset stuff + * + * Revision 1.2 1996/09/15 14:17:30 brianp + * now use GLframebuffer and GLvisual + * + * Revision 1.1 1996/09/13 01:38:16 brianp + * Initial revision + * + */ + + +#ifdef PC_HEADER +#include "all.h" +#else +#include +#include "context.h" +#include "get.h" +#include "dlist.h" +#include "macros.h" +#include "types.h" +#endif + + + +#define FLOAT_TO_BOOL(X) ( (X)==0.0F ? GL_FALSE : GL_TRUE ) +#define INT_TO_BOOL(I) ( (I)==0 ? GL_FALSE : GL_TRUE ) +#define ENUM_TO_BOOL(E) ( (E)==0 ? GL_FALSE : GL_TRUE ) + +#ifdef SPECIALCAST +/* Needed for an Amiga compiler */ +#define ENUM_TO_FLOAT(X) ((GLfloat)(GLint)(X)) +#define ENUM_TO_DOUBLE(X) ((GLdouble)(GLint)(X)) +#else +/* all other compilers */ +#define ENUM_TO_FLOAT(X) ((GLfloat)(X)) +#define ENUM_TO_DOUBLE(X) ((GLdouble)(X)) +#endif + + + +void gl_GetBooleanv( GLcontext *ctx, GLenum pname, GLboolean *params ) +{ + GLuint i; + + if (INSIDE_BEGIN_END(ctx)) { + gl_error( ctx, GL_INVALID_OPERATION, "glGetBooleanv" ); + return; + } + + switch (pname) { + case GL_ACCUM_RED_BITS: + case GL_ACCUM_GREEN_BITS: + case GL_ACCUM_BLUE_BITS: + case GL_ACCUM_ALPHA_BITS: + *params = INT_TO_BOOL(ctx->Visual->AccumBits); + break; + case GL_ACCUM_CLEAR_VALUE: + params[0] = FLOAT_TO_BOOL(ctx->Accum.ClearColor[0]); + params[1] = FLOAT_TO_BOOL(ctx->Accum.ClearColor[1]); + params[2] = FLOAT_TO_BOOL(ctx->Accum.ClearColor[2]); + params[3] = FLOAT_TO_BOOL(ctx->Accum.ClearColor[3]); + break; + case GL_ALPHA_BIAS: + *params = FLOAT_TO_BOOL(ctx->Pixel.AlphaBias); + break; + case GL_ALPHA_BITS: + *params = INT_TO_BOOL(ctx->Visual->AlphaBits); + break; + case GL_ALPHA_SCALE: + *params = FLOAT_TO_BOOL(ctx->Pixel.AlphaScale); + break; + case GL_ALPHA_TEST: + *params = ctx->Color.AlphaEnabled; + break; + case GL_ALPHA_TEST_FUNC: + *params = ENUM_TO_BOOL(ctx->Color.AlphaFunc); + break; + case GL_ALPHA_TEST_REF: + *params = FLOAT_TO_BOOL(ctx->Color.AlphaRef); + break; + case GL_ATTRIB_STACK_DEPTH: + *params = INT_TO_BOOL(ctx->AttribStackDepth); + break; + case GL_AUTO_NORMAL: + *params = ctx->Eval.AutoNormal; + break; + case GL_AUX_BUFFERS: + *params = (NUM_AUX_BUFFERS) ? GL_TRUE : GL_FALSE; + break; + case GL_BLEND: + *params = ctx->Color.BlendEnabled; + break; + case GL_BLEND_DST: + *params = ENUM_TO_BOOL(ctx->Color.BlendDst); + break; + case GL_BLEND_SRC: + *params = ENUM_TO_BOOL(ctx->Color.BlendSrc); + break; + case GL_BLUE_BIAS: + *params = FLOAT_TO_BOOL(ctx->Pixel.BlueBias); + break; + case GL_BLUE_BITS: + *params = INT_TO_BOOL( ctx->Visual->BlueBits ); + break; + case GL_BLUE_SCALE: + *params = FLOAT_TO_BOOL(ctx->Pixel.BlueScale); + break; + case GL_CLIENT_ATTRIB_STACK_DEPTH: + *params = INT_TO_BOOL(ctx->ClientAttribStackDepth); + break; + case GL_CLIP_PLANE0: + case GL_CLIP_PLANE1: + case GL_CLIP_PLANE2: + case GL_CLIP_PLANE3: + case GL_CLIP_PLANE4: + case GL_CLIP_PLANE5: + *params = ctx->Transform.ClipEnabled[pname-GL_CLIP_PLANE0]; + break; + case GL_COLOR_CLEAR_VALUE: + params[0] = FLOAT_TO_BOOL(ctx->Color.ClearColor[0]); + params[1] = FLOAT_TO_BOOL(ctx->Color.ClearColor[1]); + params[2] = FLOAT_TO_BOOL(ctx->Color.ClearColor[2]); + params[3] = FLOAT_TO_BOOL(ctx->Color.ClearColor[3]); + break; + case GL_COLOR_MATERIAL: + *params = ctx->Light.ColorMaterialEnabled; + break; + case GL_COLOR_MATERIAL_FACE: + *params = ENUM_TO_BOOL(ctx->Light.ColorMaterialFace); + break; + case GL_COLOR_MATERIAL_PARAMETER: + *params = ENUM_TO_BOOL(ctx->Light.ColorMaterialMode); + break; + case GL_COLOR_WRITEMASK: + params[0] = (ctx->Color.ColorMask & 8) ? GL_TRUE : GL_FALSE; + params[1] = (ctx->Color.ColorMask & 4) ? GL_TRUE : GL_FALSE; + params[2] = (ctx->Color.ColorMask & 2) ? GL_TRUE : GL_FALSE; + params[3] = (ctx->Color.ColorMask & 1) ? GL_TRUE : GL_FALSE; + break; + case GL_CULL_FACE: + *params = ctx->Polygon.CullFlag; + break; + case GL_CULL_FACE_MODE: + *params = ENUM_TO_BOOL(ctx->Polygon.CullFaceMode); + break; + case GL_CURRENT_COLOR: + params[0] = INT_TO_BOOL(ctx->Current.ByteColor[0]); + params[1] = INT_TO_BOOL(ctx->Current.ByteColor[1]); + params[2] = INT_TO_BOOL(ctx->Current.ByteColor[2]); + params[3] = INT_TO_BOOL(ctx->Current.ByteColor[3]); + break; + case GL_CURRENT_INDEX: + *params = INT_TO_BOOL(ctx->Current.Index); + break; + case GL_CURRENT_NORMAL: + params[0] = FLOAT_TO_BOOL(ctx->Current.Normal[0]); + params[1] = FLOAT_TO_BOOL(ctx->Current.Normal[1]); + params[2] = FLOAT_TO_BOOL(ctx->Current.Normal[2]); + break; + case GL_CURRENT_RASTER_COLOR: + params[0] = FLOAT_TO_BOOL(ctx->Current.RasterColor[0]); + params[1] = FLOAT_TO_BOOL(ctx->Current.RasterColor[1]); + params[2] = FLOAT_TO_BOOL(ctx->Current.RasterColor[2]); + params[3] = FLOAT_TO_BOOL(ctx->Current.RasterColor[3]); + break; + case GL_CURRENT_RASTER_DISTANCE: + *params = FLOAT_TO_BOOL(ctx->Current.RasterDistance); + break; + case GL_CURRENT_RASTER_INDEX: + *params = FLOAT_TO_BOOL(ctx->Current.RasterIndex); + break; + case GL_CURRENT_RASTER_POSITION: + params[0] = FLOAT_TO_BOOL(ctx->Current.RasterPos[0]); + params[1] = FLOAT_TO_BOOL(ctx->Current.RasterPos[1]); + params[2] = FLOAT_TO_BOOL(ctx->Current.RasterPos[2]); + params[3] = FLOAT_TO_BOOL(ctx->Current.RasterPos[3]); + break; + case GL_CURRENT_RASTER_TEXTURE_COORDS: + params[0] = FLOAT_TO_BOOL(ctx->Current.RasterTexCoord[0]); + params[1] = FLOAT_TO_BOOL(ctx->Current.RasterTexCoord[1]); + params[2] = FLOAT_TO_BOOL(ctx->Current.RasterTexCoord[2]); + params[3] = FLOAT_TO_BOOL(ctx->Current.RasterTexCoord[3]); + break; + case GL_CURRENT_RASTER_POSITION_VALID: + *params = ctx->Current.RasterPosValid; + break; + case GL_CURRENT_TEXTURE_COORDS: + params[0] = FLOAT_TO_BOOL(ctx->Current.TexCoord[0]); + params[1] = FLOAT_TO_BOOL(ctx->Current.TexCoord[1]); + params[2] = FLOAT_TO_BOOL(ctx->Current.TexCoord[2]); + params[3] = FLOAT_TO_BOOL(ctx->Current.TexCoord[3]); + break; + case GL_DEPTH_BIAS: + *params = FLOAT_TO_BOOL(ctx->Pixel.DepthBias); + break; + case GL_DEPTH_BITS: + *params = INT_TO_BOOL(ctx->Visual->DepthBits); + break; + case GL_DEPTH_CLEAR_VALUE: + *params = FLOAT_TO_BOOL(ctx->Depth.Clear); + break; + case GL_DEPTH_FUNC: + *params = ENUM_TO_BOOL(ctx->Depth.Func); + break; + case GL_DEPTH_RANGE: + params[0] = FLOAT_TO_BOOL(ctx->Viewport.Near); + params[1] = FLOAT_TO_BOOL(ctx->Viewport.Far); + break; + case GL_DEPTH_SCALE: + *params = FLOAT_TO_BOOL(ctx->Pixel.DepthScale); + break; + case GL_DEPTH_TEST: + *params = ctx->Depth.Test; + break; + case GL_DEPTH_WRITEMASK: + *params = ctx->Depth.Mask; + break; + case GL_DITHER: + *params = ctx->Color.DitherFlag; + break; + case GL_DOUBLEBUFFER: + *params = ctx->Visual->DBflag; + break; + case GL_DRAW_BUFFER: + *params = ENUM_TO_BOOL(ctx->Color.DrawBuffer); + break; + case GL_EDGE_FLAG: + *params = ctx->Current.EdgeFlag; + break; + case GL_FEEDBACK_BUFFER_SIZE: + /* TODO: is this right? Or, return number of entries in buffer? */ + *params = INT_TO_BOOL(ctx->Feedback.BufferSize); + break; + case GL_FEEDBACK_BUFFER_TYPE: + *params = INT_TO_BOOL(ctx->Feedback.Type); + break; + case GL_FOG: + *params = ctx->Fog.Enabled; + break; + case GL_FOG_COLOR: + params[0] = FLOAT_TO_BOOL(ctx->Fog.Color[0]); + params[1] = FLOAT_TO_BOOL(ctx->Fog.Color[1]); + params[2] = FLOAT_TO_BOOL(ctx->Fog.Color[2]); + params[3] = FLOAT_TO_BOOL(ctx->Fog.Color[3]); + break; + case GL_FOG_DENSITY: + *params = FLOAT_TO_BOOL(ctx->Fog.Density); + break; + case GL_FOG_END: + *params = FLOAT_TO_BOOL(ctx->Fog.End); + break; + case GL_FOG_HINT: + *params = ENUM_TO_BOOL(ctx->Hint.Fog); + break; + case GL_FOG_INDEX: + *params = FLOAT_TO_BOOL(ctx->Fog.Index); + break; + case GL_FOG_MODE: + *params = ENUM_TO_BOOL(ctx->Fog.Mode); + break; + case GL_FOG_START: + *params = FLOAT_TO_BOOL(ctx->Fog.End); + break; + case GL_FRONT_FACE: + *params = ENUM_TO_BOOL(ctx->Polygon.FrontFace); + break; + case GL_GREEN_BIAS: + *params = FLOAT_TO_BOOL(ctx->Pixel.GreenBias); + break; + case GL_GREEN_BITS: + *params = INT_TO_BOOL( ctx->Visual->GreenBits ); + break; + case GL_GREEN_SCALE: + *params = FLOAT_TO_BOOL(ctx->Pixel.GreenScale); + break; + case GL_INDEX_BITS: + *params = INT_TO_BOOL( ctx->Visual->IndexBits ); + break; + case GL_INDEX_CLEAR_VALUE: + *params = INT_TO_BOOL(ctx->Color.ClearIndex); + break; + case GL_INDEX_MODE: + *params = ctx->Visual->RGBAflag ? GL_FALSE : GL_TRUE; + break; + case GL_INDEX_OFFSET: + *params = INT_TO_BOOL(ctx->Pixel.IndexOffset); + break; + case GL_INDEX_SHIFT: + *params = INT_TO_BOOL(ctx->Pixel.IndexShift); + break; + case GL_INDEX_WRITEMASK: + *params = INT_TO_BOOL(ctx->Color.IndexMask); + break; + case GL_LIGHT0: + case GL_LIGHT1: + case GL_LIGHT2: + case GL_LIGHT3: + case GL_LIGHT4: + case GL_LIGHT5: + case GL_LIGHT6: + case GL_LIGHT7: + *params = ctx->Light.Light[pname-GL_LIGHT0].Enabled; + break; + case GL_LIGHTING: + *params = ctx->Light.Enabled; + break; + case GL_LIGHT_MODEL_AMBIENT: + params[0] = FLOAT_TO_BOOL(ctx->Light.Model.Ambient[0]); + params[1] = FLOAT_TO_BOOL(ctx->Light.Model.Ambient[1]); + params[2] = FLOAT_TO_BOOL(ctx->Light.Model.Ambient[2]); + params[3] = FLOAT_TO_BOOL(ctx->Light.Model.Ambient[3]); + break; + case GL_LIGHT_MODEL_LOCAL_VIEWER: + *params = ctx->Light.Model.LocalViewer; + break; + case GL_LIGHT_MODEL_TWO_SIDE: + *params = ctx->Light.Model.TwoSide; + break; + case GL_LINE_SMOOTH: + *params = ctx->Line.SmoothFlag; + break; + case GL_LINE_SMOOTH_HINT: + *params = ENUM_TO_BOOL(ctx->Hint.LineSmooth); + break; + case GL_LINE_STIPPLE: + *params = ctx->Line.StippleFlag; + break; + case GL_LINE_STIPPLE_PATTERN: + *params = INT_TO_BOOL(ctx->Line.StipplePattern); + break; + case GL_LINE_STIPPLE_REPEAT: + *params = INT_TO_BOOL(ctx->Line.StippleFactor); + break; + case GL_LINE_WIDTH: + *params = FLOAT_TO_BOOL(ctx->Line.Width); + break; + case GL_LINE_WIDTH_GRANULARITY: + *params = FLOAT_TO_BOOL(LINE_WIDTH_GRANULARITY); + break; + case GL_LINE_WIDTH_RANGE: + params[0] = FLOAT_TO_BOOL(MIN_LINE_WIDTH); + params[1] = FLOAT_TO_BOOL(MAX_LINE_WIDTH); + break; + case GL_LIST_BASE: + *params = INT_TO_BOOL(ctx->List.ListBase); + break; + case GL_LIST_INDEX: + *params = INT_TO_BOOL( ctx->CurrentListNum ); + break; + case GL_LIST_MODE: + *params = ENUM_TO_BOOL( ctx->ExecuteFlag + ? GL_COMPILE_AND_EXECUTE : GL_COMPILE ); + break; + case GL_INDEX_LOGIC_OP: + *params = ctx->Color.IndexLogicOpEnabled; + break; + case GL_COLOR_LOGIC_OP: + *params = ctx->Color.ColorLogicOpEnabled; + break; + case GL_LOGIC_OP_MODE: + *params = ENUM_TO_BOOL(ctx->Color.LogicOp); + break; + case GL_MAP1_COLOR_4: + *params = ctx->Eval.Map1Color4; + break; + case GL_MAP1_GRID_DOMAIN: + params[0] = FLOAT_TO_BOOL(ctx->Eval.MapGrid1u1); + params[1] = FLOAT_TO_BOOL(ctx->Eval.MapGrid1u2); + break; + case GL_MAP1_GRID_SEGMENTS: + *params = INT_TO_BOOL(ctx->Eval.MapGrid1un); + break; + case GL_MAP1_INDEX: + *params = ctx->Eval.Map1Index; + break; + case GL_MAP1_NORMAL: + *params = ctx->Eval.Map1Normal; + break; + case GL_MAP1_TEXTURE_COORD_1: + *params = ctx->Eval.Map1TextureCoord1; + break; + case GL_MAP1_TEXTURE_COORD_2: + *params = ctx->Eval.Map1TextureCoord2; + break; + case GL_MAP1_TEXTURE_COORD_3: + *params = ctx->Eval.Map1TextureCoord3; + break; + case GL_MAP1_TEXTURE_COORD_4: + *params = ctx->Eval.Map1TextureCoord4; + break; + case GL_MAP1_VERTEX_3: + *params = ctx->Eval.Map1Vertex3; + break; + case GL_MAP1_VERTEX_4: + *params = ctx->Eval.Map1Vertex4; + break; + case GL_MAP2_COLOR_4: + *params = ctx->Eval.Map2Color4; + break; + case GL_MAP2_GRID_DOMAIN: + params[0] = FLOAT_TO_BOOL(ctx->Eval.MapGrid2u1); + params[1] = FLOAT_TO_BOOL(ctx->Eval.MapGrid2u2); + params[2] = FLOAT_TO_BOOL(ctx->Eval.MapGrid2v1); + params[3] = FLOAT_TO_BOOL(ctx->Eval.MapGrid2v2); + break; + case GL_MAP2_GRID_SEGMENTS: + params[0] = INT_TO_BOOL(ctx->Eval.MapGrid2un); + params[1] = INT_TO_BOOL(ctx->Eval.MapGrid2vn); + break; + case GL_MAP2_INDEX: + *params = ctx->Eval.Map2Index; + break; + case GL_MAP2_NORMAL: + *params = ctx->Eval.Map2Normal; + break; + case GL_MAP2_TEXTURE_COORD_1: + *params = ctx->Eval.Map2TextureCoord1; + break; + case GL_MAP2_TEXTURE_COORD_2: + *params = ctx->Eval.Map2TextureCoord2; + break; + case GL_MAP2_TEXTURE_COORD_3: + *params = ctx->Eval.Map2TextureCoord3; + break; + case GL_MAP2_TEXTURE_COORD_4: + *params = ctx->Eval.Map2TextureCoord4; + break; + case GL_MAP2_VERTEX_3: + *params = ctx->Eval.Map2Vertex3; + break; + case GL_MAP2_VERTEX_4: + *params = ctx->Eval.Map2Vertex4; + break; + case GL_MAP_COLOR: + *params = ctx->Pixel.MapColorFlag; + break; + case GL_MAP_STENCIL: + *params = ctx->Pixel.MapStencilFlag; + break; + case GL_MATRIX_MODE: + *params = ENUM_TO_BOOL( ctx->Transform.MatrixMode ); + break; + case GL_MAX_ATTRIB_STACK_DEPTH: + *params = INT_TO_BOOL(MAX_ATTRIB_STACK_DEPTH); + break; + case GL_MAX_CLIENT_ATTRIB_STACK_DEPTH: + *params = INT_TO_BOOL( MAX_CLIENT_ATTRIB_STACK_DEPTH); + break; + case GL_MAX_CLIP_PLANES: + *params = INT_TO_BOOL(MAX_CLIP_PLANES); + break; + case GL_MAX_EVAL_ORDER: + *params = INT_TO_BOOL(MAX_EVAL_ORDER); + break; + case GL_MAX_LIGHTS: + *params = INT_TO_BOOL(MAX_LIGHTS); + break; + case GL_MAX_LIST_NESTING: + *params = INT_TO_BOOL(MAX_LIST_NESTING); + break; + case GL_MAX_MODELVIEW_STACK_DEPTH: + *params = INT_TO_BOOL(MAX_MODELVIEW_STACK_DEPTH); + break; + case GL_MAX_NAME_STACK_DEPTH: + *params = INT_TO_BOOL(MAX_NAME_STACK_DEPTH); + break; + case GL_MAX_PIXEL_MAP_TABLE: + *params = INT_TO_BOOL(MAX_PIXEL_MAP_TABLE); + break; + case GL_MAX_PROJECTION_STACK_DEPTH: + *params = INT_TO_BOOL(MAX_PROJECTION_STACK_DEPTH); + break; + case GL_MAX_TEXTURE_SIZE: + *params = INT_TO_BOOL(MAX_TEXTURE_SIZE); + break; + case GL_MAX_TEXTURE_STACK_DEPTH: + *params = INT_TO_BOOL(MAX_TEXTURE_STACK_DEPTH); + break; + case GL_MAX_VIEWPORT_DIMS: + params[0] = INT_TO_BOOL(MAX_WIDTH); + params[1] = INT_TO_BOOL(MAX_HEIGHT); + break; + case GL_MODELVIEW_MATRIX: + for (i=0;i<16;i++) { + params[i] = FLOAT_TO_BOOL(ctx->ModelViewMatrix[i]); + } + break; + case GL_MODELVIEW_STACK_DEPTH: + *params = INT_TO_BOOL(ctx->ModelViewStackDepth); + break; + case GL_NAME_STACK_DEPTH: + *params = INT_TO_BOOL(ctx->Select.NameStackDepth); + break; + case GL_NORMALIZE: + *params = ctx->Transform.Normalize; + break; + case GL_PACK_ALIGNMENT: + *params = INT_TO_BOOL(ctx->Pack.Alignment); + break; + case GL_PACK_LSB_FIRST: + *params = ctx->Pack.LsbFirst; + break; + case GL_PACK_ROW_LENGTH: + *params = INT_TO_BOOL(ctx->Pack.RowLength); + break; + case GL_PACK_SKIP_PIXELS: + *params = INT_TO_BOOL(ctx->Pack.SkipPixels); + break; + case GL_PACK_SKIP_ROWS: + *params = INT_TO_BOOL(ctx->Pack.SkipRows); + break; + case GL_PACK_SWAP_BYTES: + *params = ctx->Pack.SwapBytes; + break; + case GL_PERSPECTIVE_CORRECTION_HINT: + *params = ENUM_TO_BOOL(ctx->Hint.PerspectiveCorrection); + break; + case GL_PIXEL_MAP_A_TO_A_SIZE: + *params = INT_TO_BOOL(ctx->Pixel.MapAtoAsize); + break; + case GL_PIXEL_MAP_B_TO_B_SIZE: + *params = INT_TO_BOOL(ctx->Pixel.MapBtoBsize); + break; + case GL_PIXEL_MAP_G_TO_G_SIZE: + *params = INT_TO_BOOL(ctx->Pixel.MapGtoGsize); + break; + case GL_PIXEL_MAP_I_TO_A_SIZE: + *params = INT_TO_BOOL(ctx->Pixel.MapItoAsize); + break; + case GL_PIXEL_MAP_I_TO_B_SIZE: + *params = INT_TO_BOOL(ctx->Pixel.MapItoBsize); + break; + case GL_PIXEL_MAP_I_TO_G_SIZE: + *params = INT_TO_BOOL(ctx->Pixel.MapItoGsize); + break; + case GL_PIXEL_MAP_I_TO_I_SIZE: + *params = INT_TO_BOOL(ctx->Pixel.MapItoIsize); + break; + case GL_PIXEL_MAP_I_TO_R_SIZE: + *params = INT_TO_BOOL(ctx->Pixel.MapItoRsize); + break; + case GL_PIXEL_MAP_R_TO_R_SIZE: + *params = INT_TO_BOOL(ctx->Pixel.MapRtoRsize); + break; + case GL_PIXEL_MAP_S_TO_S_SIZE: + *params = INT_TO_BOOL(ctx->Pixel.MapStoSsize); + break; + case GL_POINT_SIZE: + *params = FLOAT_TO_BOOL(ctx->Point.Size ); + break; + case GL_POINT_SIZE_GRANULARITY: + *params = FLOAT_TO_BOOL(POINT_SIZE_GRANULARITY ); + break; + case GL_POINT_SIZE_RANGE: + params[0] = FLOAT_TO_BOOL(MIN_POINT_SIZE ); + params[1] = FLOAT_TO_BOOL(MAX_POINT_SIZE ); + break; + case GL_POINT_SMOOTH: + *params = ctx->Point.SmoothFlag; + break; + case GL_POINT_SMOOTH_HINT: + *params = ENUM_TO_BOOL(ctx->Hint.PointSmooth); + break; + case GL_POLYGON_MODE: + params[0] = ENUM_TO_BOOL(ctx->Polygon.FrontMode); + params[1] = ENUM_TO_BOOL(ctx->Polygon.BackMode); + break; +#ifdef GL_EXT_polygon_offset + case GL_POLYGON_OFFSET_BIAS_EXT: + *params = FLOAT_TO_BOOL( ctx->Polygon.OffsetUnits ); + break; +#endif + case GL_POLYGON_OFFSET_FACTOR: + *params = FLOAT_TO_BOOL( ctx->Polygon.OffsetFactor ); + break; + case GL_POLYGON_OFFSET_UNITS: + *params = FLOAT_TO_BOOL( ctx->Polygon.OffsetUnits ); + break; + case GL_POLYGON_SMOOTH: + *params = ctx->Polygon.SmoothFlag; + break; + case GL_POLYGON_SMOOTH_HINT: + *params = ENUM_TO_BOOL(ctx->Hint.PolygonSmooth); + break; + case GL_POLYGON_STIPPLE: + *params = ctx->Polygon.StippleFlag; + break; + case GL_PROJECTION_MATRIX: + for (i=0;i<16;i++) { + params[i] = FLOAT_TO_BOOL(ctx->ProjectionMatrix[i]); + } + break; + case GL_PROJECTION_STACK_DEPTH: + *params = INT_TO_BOOL(ctx->ProjectionStackDepth); + break; + case GL_READ_BUFFER: + *params = ENUM_TO_BOOL(ctx->Pixel.ReadBuffer); + break; + case GL_RED_BIAS: + *params = FLOAT_TO_BOOL(ctx->Pixel.RedBias); + break; + case GL_RED_BITS: + *params = INT_TO_BOOL( ctx->Visual->RedBits ); + break; + case GL_RED_SCALE: + *params = FLOAT_TO_BOOL(ctx->Pixel.RedScale); + break; + case GL_RENDER_MODE: + *params = ENUM_TO_BOOL(ctx->RenderMode); + break; + case GL_RGBA_MODE: + *params = ctx->Visual->RGBAflag; + break; + case GL_SCISSOR_BOX: + params[0] = INT_TO_BOOL(ctx->Scissor.X); + params[1] = INT_TO_BOOL(ctx->Scissor.Y); + params[2] = INT_TO_BOOL(ctx->Scissor.Width); + params[3] = INT_TO_BOOL(ctx->Scissor.Height); + break; + case GL_SCISSOR_TEST: + *params = ctx->Scissor.Enabled; + break; + case GL_SHADE_MODEL: + *params = ENUM_TO_BOOL(ctx->Light.ShadeModel); + break; + case GL_STENCIL_BITS: + *params = INT_TO_BOOL(ctx->Visual->StencilBits); + break; + case GL_STENCIL_CLEAR_VALUE: + *params = INT_TO_BOOL(ctx->Stencil.Clear); + break; + case GL_STENCIL_FAIL: + *params = ENUM_TO_BOOL(ctx->Stencil.FailFunc); + break; + case GL_STENCIL_FUNC: + *params = ENUM_TO_BOOL(ctx->Stencil.Function); + break; + case GL_STENCIL_PASS_DEPTH_FAIL: + *params = ENUM_TO_BOOL(ctx->Stencil.ZFailFunc); + break; + case GL_STENCIL_PASS_DEPTH_PASS: + *params = ENUM_TO_BOOL(ctx->Stencil.ZPassFunc); + break; + case GL_STENCIL_REF: + *params = INT_TO_BOOL(ctx->Stencil.Ref); + break; + case GL_STENCIL_TEST: + *params = ctx->Stencil.Enabled; + break; + case GL_STENCIL_VALUE_MASK: + *params = INT_TO_BOOL(ctx->Stencil.ValueMask); + break; + case GL_STENCIL_WRITEMASK: + *params = INT_TO_BOOL(ctx->Stencil.WriteMask); + break; + case GL_STEREO: + *params = GL_FALSE; /* TODO */ + break; + case GL_SUBPIXEL_BITS: + *params = INT_TO_BOOL(0); /* TODO */ + break; + case GL_TEXTURE_1D: + *params = (ctx->Texture.Enabled & TEXTURE_1D) ? GL_TRUE : GL_FALSE; + break; + case GL_TEXTURE_2D: + *params = (ctx->Texture.Enabled & TEXTURE_2D) ? GL_TRUE : GL_FALSE; + break; + case GL_TEXTURE_ENV_COLOR: + params[0] = FLOAT_TO_BOOL(ctx->Texture.EnvColor[0]); + params[1] = FLOAT_TO_BOOL(ctx->Texture.EnvColor[1]); + params[2] = FLOAT_TO_BOOL(ctx->Texture.EnvColor[2]); + params[3] = FLOAT_TO_BOOL(ctx->Texture.EnvColor[3]); + break; + case GL_TEXTURE_ENV_MODE: + *params = ENUM_TO_BOOL(ctx->Texture.EnvMode); + break; + case GL_TEXTURE_GEN_S: + *params = (ctx->Texture.TexGenEnabled & S_BIT) ? GL_TRUE : GL_FALSE; + break; + case GL_TEXTURE_GEN_T: + *params = (ctx->Texture.TexGenEnabled & T_BIT) ? GL_TRUE : GL_FALSE; + break; + case GL_TEXTURE_GEN_R: + *params = (ctx->Texture.TexGenEnabled & R_BIT) ? GL_TRUE : GL_FALSE; + break; + case GL_TEXTURE_GEN_Q: + *params = (ctx->Texture.TexGenEnabled & Q_BIT) ? GL_TRUE : GL_FALSE; + break; + case GL_TEXTURE_MATRIX: + for (i=0;i<16;i++) { + params[i] = FLOAT_TO_BOOL(ctx->TextureMatrix[i]); + } + break; + case GL_TEXTURE_STACK_DEPTH: + *params = INT_TO_BOOL(ctx->TextureStackDepth); + break; + case GL_UNPACK_ALIGNMENT: + *params = INT_TO_BOOL(ctx->Unpack.Alignment); + break; + case GL_UNPACK_LSB_FIRST: + *params = ctx->Unpack.LsbFirst; + break; + case GL_UNPACK_ROW_LENGTH: + *params = INT_TO_BOOL(ctx->Unpack.RowLength); + break; + case GL_UNPACK_SKIP_PIXELS: + *params = INT_TO_BOOL(ctx->Unpack.SkipPixels); + break; + case GL_UNPACK_SKIP_ROWS: + *params = INT_TO_BOOL(ctx->Unpack.SkipRows); + break; + case GL_UNPACK_SWAP_BYTES: + *params = ctx->Unpack.SwapBytes; + break; + case GL_VIEWPORT: + params[0] = INT_TO_BOOL(ctx->Viewport.X); + params[1] = INT_TO_BOOL(ctx->Viewport.Y); + params[2] = INT_TO_BOOL(ctx->Viewport.Width); + params[3] = INT_TO_BOOL(ctx->Viewport.Height); + break; + case GL_ZOOM_X: + *params = FLOAT_TO_BOOL(ctx->Pixel.ZoomX); + break; + case GL_ZOOM_Y: + *params = FLOAT_TO_BOOL(ctx->Pixel.ZoomY); + break; + case GL_VERTEX_ARRAY_SIZE: + *params = INT_TO_BOOL(ctx->Array.VertexSize); + break; + case GL_VERTEX_ARRAY_TYPE: + *params = ENUM_TO_BOOL(ctx->Array.VertexType); + break; + case GL_VERTEX_ARRAY_STRIDE: + *params = INT_TO_BOOL(ctx->Array.VertexStride); + break; + case GL_VERTEX_ARRAY_COUNT_EXT: + *params = INT_TO_BOOL(0); + break; + case GL_NORMAL_ARRAY_TYPE: + *params = ENUM_TO_BOOL(ctx->Array.NormalType); + break; + case GL_NORMAL_ARRAY_STRIDE: + *params = INT_TO_BOOL(ctx->Array.NormalStride); + break; + case GL_NORMAL_ARRAY_COUNT_EXT: + *params = INT_TO_BOOL(0); + break; + case GL_COLOR_ARRAY_SIZE: + *params = INT_TO_BOOL(ctx->Array.ColorSize); + break; + case GL_COLOR_ARRAY_TYPE: + *params = ENUM_TO_BOOL(ctx->Array.ColorType); + break; + case GL_COLOR_ARRAY_STRIDE: + *params = INT_TO_BOOL(ctx->Array.ColorStride); + break; + case GL_COLOR_ARRAY_COUNT_EXT: + *params = INT_TO_BOOL(0); + break; + case GL_INDEX_ARRAY_TYPE: + *params = ENUM_TO_BOOL(ctx->Array.IndexType); + break; + case GL_INDEX_ARRAY_STRIDE: + *params = INT_TO_BOOL(ctx->Array.IndexStride); + break; + case GL_INDEX_ARRAY_COUNT_EXT: + *params = INT_TO_BOOL(0); + break; + case GL_TEXTURE_COORD_ARRAY_SIZE: + *params = INT_TO_BOOL(ctx->Array.TexCoordSize); + break; + case GL_TEXTURE_COORD_ARRAY_TYPE: + *params = ENUM_TO_BOOL(ctx->Array.TexCoordType); + break; + case GL_TEXTURE_COORD_ARRAY_STRIDE: + *params = INT_TO_BOOL(ctx->Array.TexCoordStride); + break; + case GL_TEXTURE_COORD_ARRAY_COUNT_EXT: + *params = INT_TO_BOOL(0); + break; + case GL_EDGE_FLAG_ARRAY_STRIDE: + *params = INT_TO_BOOL(ctx->Array.EdgeFlagStride); + break; + case GL_EDGE_FLAG_ARRAY_EXT: + *params = INT_TO_BOOL(0); + break; + case GL_TEXTURE_BINDING_1D: + *params = INT_TO_BOOL(ctx->Texture.Current1D->Name); + break; + case GL_TEXTURE_BINDING_2D: + *params = INT_TO_BOOL(ctx->Texture.Current2D->Name); + break; + case GL_TEXTURE_3D_BINDING_EXT: + *params = INT_TO_BOOL(ctx->Texture.Current2D->Name); + break; + default: + gl_error( ctx, GL_INVALID_ENUM, "glGetBooleanv" ); + } +} + + + + +void gl_GetDoublev( GLcontext *ctx, GLenum pname, GLdouble *params ) +{ + GLuint i; + + if (INSIDE_BEGIN_END(ctx)) { + gl_error( ctx, GL_INVALID_OPERATION, "glGetDoublev" ); + return; + } + + switch (pname) { + case GL_ACCUM_RED_BITS: + case GL_ACCUM_GREEN_BITS: + case GL_ACCUM_BLUE_BITS: + case GL_ACCUM_ALPHA_BITS: + *params = (GLdouble) ctx->Visual->AccumBits; + break; + case GL_ACCUM_CLEAR_VALUE: + params[0] = (GLdouble) ctx->Accum.ClearColor[0]; + params[1] = (GLdouble) ctx->Accum.ClearColor[1]; + params[2] = (GLdouble) ctx->Accum.ClearColor[2]; + params[3] = (GLdouble) ctx->Accum.ClearColor[3]; + break; + case GL_ALPHA_BIAS: + *params = (GLdouble) ctx->Pixel.AlphaBias; + break; + case GL_ALPHA_BITS: + *params = (GLdouble) ctx->Visual->AlphaBits; + break; + case GL_ALPHA_SCALE: + *params = (GLdouble) ctx->Pixel.AlphaScale; + break; + case GL_ALPHA_TEST: + *params = (GLdouble) ctx->Color.AlphaEnabled; + break; + case GL_ALPHA_TEST_FUNC: + *params = ENUM_TO_DOUBLE(ctx->Color.AlphaFunc); + break; + case GL_ALPHA_TEST_REF: + *params = (GLdouble) ctx->Color.AlphaRef; + break; + case GL_ATTRIB_STACK_DEPTH: + *params = (GLdouble ) ctx->AttribStackDepth; + break; + case GL_AUTO_NORMAL: + *params = (GLdouble) ctx->Eval.AutoNormal; + break; + case GL_AUX_BUFFERS: + *params = (GLdouble) NUM_AUX_BUFFERS; + break; + case GL_BLEND: + *params = (GLdouble) ctx->Color.BlendEnabled; + break; + case GL_BLEND_DST: + *params = ENUM_TO_DOUBLE(ctx->Color.BlendDst); + break; + case GL_BLEND_SRC: + *params = ENUM_TO_DOUBLE(ctx->Color.BlendSrc); + break; + case GL_BLUE_BIAS: + *params = (GLdouble) ctx->Pixel.BlueBias; + break; + case GL_BLUE_BITS: + *params = (GLdouble) ctx->Visual->BlueBits; + break; + case GL_BLUE_SCALE: + *params = (GLdouble) ctx->Pixel.BlueScale; + break; + case GL_CLIENT_ATTRIB_STACK_DEPTH: + *params = (GLdouble) ctx->ClientAttribStackDepth; + break; + case GL_CLIP_PLANE0: + case GL_CLIP_PLANE1: + case GL_CLIP_PLANE2: + case GL_CLIP_PLANE3: + case GL_CLIP_PLANE4: + case GL_CLIP_PLANE5: + *params = (GLdouble) ctx->Transform.ClipEnabled[pname-GL_CLIP_PLANE0]; + break; + case GL_COLOR_CLEAR_VALUE: + params[0] = (GLdouble) ctx->Color.ClearColor[0]; + params[1] = (GLdouble) ctx->Color.ClearColor[1]; + params[2] = (GLdouble) ctx->Color.ClearColor[2]; + params[3] = (GLdouble) ctx->Color.ClearColor[3]; + break; + case GL_COLOR_MATERIAL: + *params = (GLdouble) ctx->Light.ColorMaterialEnabled; + break; + case GL_COLOR_MATERIAL_FACE: + *params = ENUM_TO_DOUBLE(ctx->Light.ColorMaterialFace); + break; + case GL_COLOR_MATERIAL_PARAMETER: + *params = ENUM_TO_DOUBLE(ctx->Light.ColorMaterialMode); + break; + case GL_COLOR_WRITEMASK: + params[0] = (ctx->Color.ColorMask & 8) ? 1.0 : 0.0; + params[1] = (ctx->Color.ColorMask & 4) ? 1.0 : 0.0; + params[2] = (ctx->Color.ColorMask & 2) ? 1.0 : 0.0; + params[3] = (ctx->Color.ColorMask & 1) ? 1.0 : 0.0; + break; + case GL_CULL_FACE: + *params = (GLdouble) ctx->Polygon.CullFlag; + break; + case GL_CULL_FACE_MODE: + *params = ENUM_TO_DOUBLE(ctx->Polygon.CullFaceMode); + break; + case GL_CURRENT_COLOR: + params[0] = ctx->Current.ByteColor[0] * ctx->Visual->InvRedScale; + params[1] = ctx->Current.ByteColor[1] * ctx->Visual->InvGreenScale; + params[2] = ctx->Current.ByteColor[2] * ctx->Visual->InvBlueScale; + params[3] = ctx->Current.ByteColor[3] * ctx->Visual->InvAlphaScale; + break; + case GL_CURRENT_INDEX: + *params = (GLdouble) ctx->Current.Index; + break; + case GL_CURRENT_NORMAL: + params[0] = (GLdouble) ctx->Current.Normal[0]; + params[1] = (GLdouble) ctx->Current.Normal[1]; + params[2] = (GLdouble) ctx->Current.Normal[2]; + break; + case GL_CURRENT_RASTER_COLOR: + params[0] = (GLdouble) ctx->Current.RasterColor[0]; + params[1] = (GLdouble) ctx->Current.RasterColor[1]; + params[2] = (GLdouble) ctx->Current.RasterColor[2]; + params[3] = (GLdouble) ctx->Current.RasterColor[3]; + break; + case GL_CURRENT_RASTER_DISTANCE: + params[0] = (GLdouble) ctx->Current.RasterDistance; + break; + case GL_CURRENT_RASTER_INDEX: + *params = (GLdouble) ctx->Current.RasterIndex; + break; + case GL_CURRENT_RASTER_POSITION: + params[0] = (GLdouble) ctx->Current.RasterPos[0]; + params[1] = (GLdouble) ctx->Current.RasterPos[1]; + params[2] = (GLdouble) ctx->Current.RasterPos[2]; + params[3] = (GLdouble) ctx->Current.RasterPos[3]; + break; + case GL_CURRENT_RASTER_TEXTURE_COORDS: + params[0] = (GLdouble) ctx->Current.RasterTexCoord[0]; + params[1] = (GLdouble) ctx->Current.RasterTexCoord[1]; + params[2] = (GLdouble) ctx->Current.RasterTexCoord[2]; + params[3] = (GLdouble) ctx->Current.RasterTexCoord[3]; + break; + case GL_CURRENT_RASTER_POSITION_VALID: + *params = (GLdouble) ctx->Current.RasterPosValid; + break; + case GL_CURRENT_TEXTURE_COORDS: + params[0] = (GLdouble) ctx->Current.TexCoord[0]; + params[1] = (GLdouble) ctx->Current.TexCoord[1]; + params[2] = (GLdouble) ctx->Current.TexCoord[2]; + params[3] = (GLdouble) ctx->Current.TexCoord[3]; + break; + case GL_DEPTH_BIAS: + *params = (GLdouble) ctx->Pixel.DepthBias; + break; + case GL_DEPTH_BITS: + *params = (GLdouble) ctx->Visual->DepthBits; + break; + case GL_DEPTH_CLEAR_VALUE: + *params = (GLdouble) ctx->Depth.Clear; + break; + case GL_DEPTH_FUNC: + *params = ENUM_TO_DOUBLE(ctx->Depth.Func); + break; + case GL_DEPTH_RANGE: + params[0] = (GLdouble) ctx->Viewport.Near; + params[1] = (GLdouble) ctx->Viewport.Far; + break; + case GL_DEPTH_SCALE: + *params = (GLdouble) ctx->Pixel.DepthScale; + break; + case GL_DEPTH_TEST: + *params = (GLdouble) ctx->Depth.Test; + break; + case GL_DEPTH_WRITEMASK: + *params = (GLdouble) ctx->Depth.Mask; + break; + case GL_DITHER: + *params = (GLdouble) ctx->Color.DitherFlag; + break; + case GL_DOUBLEBUFFER: + *params = (GLdouble) ctx->Visual->DBflag; + break; + case GL_DRAW_BUFFER: + *params = ENUM_TO_DOUBLE(ctx->Color.DrawBuffer); + break; + case GL_EDGE_FLAG: + *params = (GLdouble) ctx->Current.EdgeFlag; + break; + case GL_FEEDBACK_BUFFER_SIZE: + /* TODO: is this right? Or, return number of entries in buffer? */ + *params = (GLdouble) ctx->Feedback.BufferSize; + break; + case GL_FEEDBACK_BUFFER_TYPE: + *params = ENUM_TO_DOUBLE(ctx->Feedback.Type); + break; + case GL_FOG: + *params = (GLdouble) ctx->Fog.Enabled; + break; + case GL_FOG_COLOR: + params[0] = (GLdouble) ctx->Fog.Color[0]; + params[1] = (GLdouble) ctx->Fog.Color[1]; + params[2] = (GLdouble) ctx->Fog.Color[2]; + params[3] = (GLdouble) ctx->Fog.Color[3]; + break; + case GL_FOG_DENSITY: + *params = (GLdouble) ctx->Fog.Density; + break; + case GL_FOG_END: + *params = (GLdouble) ctx->Fog.End; + break; + case GL_FOG_HINT: + *params = ENUM_TO_DOUBLE(ctx->Hint.Fog); + break; + case GL_FOG_INDEX: + *params = (GLdouble) ctx->Fog.Index; + break; + case GL_FOG_MODE: + *params = ENUM_TO_DOUBLE(ctx->Fog.Mode); + break; + case GL_FOG_START: + *params = (GLdouble) ctx->Fog.Start; + break; + case GL_FRONT_FACE: + *params = ENUM_TO_DOUBLE(ctx->Polygon.FrontFace); + break; + case GL_GREEN_BIAS: + *params = (GLdouble) ctx->Pixel.GreenBias; + break; + case GL_GREEN_BITS: + *params = (GLdouble) ctx->Visual->GreenBits; + break; + case GL_GREEN_SCALE: + *params = (GLdouble) ctx->Pixel.GreenScale; + break; + case GL_INDEX_BITS: + *params = (GLdouble) ctx->Visual->IndexBits; + break; + case GL_INDEX_CLEAR_VALUE: + *params = (GLdouble) ctx->Color.ClearIndex; + break; + case GL_INDEX_MODE: + *params = ctx->Visual->RGBAflag ? 0.0 : 1.0; + break; + case GL_INDEX_OFFSET: + *params = (GLdouble) ctx->Pixel.IndexOffset; + break; + case GL_INDEX_SHIFT: + *params = (GLdouble) ctx->Pixel.IndexShift; + break; + case GL_INDEX_WRITEMASK: + *params = (GLdouble) ctx->Color.IndexMask; + break; + case GL_LIGHT0: + case GL_LIGHT1: + case GL_LIGHT2: + case GL_LIGHT3: + case GL_LIGHT4: + case GL_LIGHT5: + case GL_LIGHT6: + case GL_LIGHT7: + *params = (GLdouble) ctx->Light.Light[pname-GL_LIGHT0].Enabled; + break; + case GL_LIGHTING: + *params = (GLdouble) ctx->Light.Enabled; + break; + case GL_LIGHT_MODEL_AMBIENT: + params[0] = (GLdouble) ctx->Light.Model.Ambient[0]; + params[1] = (GLdouble) ctx->Light.Model.Ambient[1]; + params[2] = (GLdouble) ctx->Light.Model.Ambient[2]; + params[3] = (GLdouble) ctx->Light.Model.Ambient[3]; + break; + case GL_LIGHT_MODEL_LOCAL_VIEWER: + *params = (GLdouble) ctx->Light.Model.LocalViewer; + break; + case GL_LIGHT_MODEL_TWO_SIDE: + *params = (GLdouble) ctx->Light.Model.TwoSide; + break; + case GL_LINE_SMOOTH: + *params = (GLdouble) ctx->Line.SmoothFlag; + break; + case GL_LINE_SMOOTH_HINT: + *params = ENUM_TO_DOUBLE(ctx->Hint.LineSmooth); + break; + case GL_LINE_STIPPLE: + *params = (GLdouble) ctx->Line.StippleFlag; + break; + case GL_LINE_STIPPLE_PATTERN: + *params = (GLdouble) ctx->Line.StipplePattern; + break; + case GL_LINE_STIPPLE_REPEAT: + *params = (GLdouble) ctx->Line.StippleFactor; + break; + case GL_LINE_WIDTH: + *params = (GLdouble) ctx->Line.Width; + break; + case GL_LINE_WIDTH_GRANULARITY: + *params = (GLdouble) LINE_WIDTH_GRANULARITY; + break; + case GL_LINE_WIDTH_RANGE: + params[0] = (GLdouble) MIN_LINE_WIDTH; + params[1] = (GLdouble) MAX_LINE_WIDTH; + break; + case GL_LIST_BASE: + *params = (GLdouble) ctx->List.ListBase; + break; + case GL_LIST_INDEX: + *params = (GLdouble) ctx->CurrentListNum; + break; + case GL_LIST_MODE: + *params = ctx->ExecuteFlag ? ENUM_TO_DOUBLE(GL_COMPILE_AND_EXECUTE) + : ENUM_TO_DOUBLE(GL_COMPILE); + break; + case GL_INDEX_LOGIC_OP: + *params = (GLdouble) ctx->Color.IndexLogicOpEnabled; + break; + case GL_COLOR_LOGIC_OP: + *params = (GLdouble) ctx->Color.ColorLogicOpEnabled; + break; + case GL_LOGIC_OP_MODE: + *params = ENUM_TO_DOUBLE(ctx->Color.LogicOp); + break; + case GL_MAP1_COLOR_4: + *params = (GLdouble) ctx->Eval.Map1Color4; + break; + case GL_MAP1_GRID_DOMAIN: + params[0] = (GLdouble) ctx->Eval.MapGrid1u1; + params[1] = (GLdouble) ctx->Eval.MapGrid1u2; + break; + case GL_MAP1_GRID_SEGMENTS: + *params = (GLdouble) ctx->Eval.MapGrid1un; + break; + case GL_MAP1_INDEX: + *params = (GLdouble) ctx->Eval.Map1Index; + break; + case GL_MAP1_NORMAL: + *params = (GLdouble) ctx->Eval.Map1Normal; + break; + case GL_MAP1_TEXTURE_COORD_1: + *params = (GLdouble) ctx->Eval.Map1TextureCoord1; + break; + case GL_MAP1_TEXTURE_COORD_2: + *params = (GLdouble) ctx->Eval.Map1TextureCoord2; + break; + case GL_MAP1_TEXTURE_COORD_3: + *params = (GLdouble) ctx->Eval.Map1TextureCoord3; + break; + case GL_MAP1_TEXTURE_COORD_4: + *params = (GLdouble) ctx->Eval.Map1TextureCoord4; + break; + case GL_MAP1_VERTEX_3: + *params = (GLdouble) ctx->Eval.Map1Vertex3; + break; + case GL_MAP1_VERTEX_4: + *params = (GLdouble) ctx->Eval.Map1Vertex4; + break; + case GL_MAP2_COLOR_4: + *params = (GLdouble) ctx->Eval.Map2Color4; + break; + case GL_MAP2_GRID_DOMAIN: + params[0] = (GLdouble) ctx->Eval.MapGrid2u1; + params[1] = (GLdouble) ctx->Eval.MapGrid2u2; + params[2] = (GLdouble) ctx->Eval.MapGrid2v1; + params[3] = (GLdouble) ctx->Eval.MapGrid2v2; + break; + case GL_MAP2_GRID_SEGMENTS: + params[0] = (GLdouble) ctx->Eval.MapGrid2un; + params[1] = (GLdouble) ctx->Eval.MapGrid2vn; + break; + case GL_MAP2_INDEX: + *params = (GLdouble) ctx->Eval.Map2Index; + break; + case GL_MAP2_NORMAL: + *params = (GLdouble) ctx->Eval.Map2Normal; + break; + case GL_MAP2_TEXTURE_COORD_1: + *params = (GLdouble) ctx->Eval.Map2TextureCoord1; + break; + case GL_MAP2_TEXTURE_COORD_2: + *params = (GLdouble) ctx->Eval.Map2TextureCoord2; + break; + case GL_MAP2_TEXTURE_COORD_3: + *params = (GLdouble) ctx->Eval.Map2TextureCoord3; + break; + case GL_MAP2_TEXTURE_COORD_4: + *params = (GLdouble) ctx->Eval.Map2TextureCoord4; + break; + case GL_MAP2_VERTEX_3: + *params = (GLdouble) ctx->Eval.Map2Vertex3; + break; + case GL_MAP2_VERTEX_4: + *params = (GLdouble) ctx->Eval.Map2Vertex4; + break; + case GL_MAP_COLOR: + *params = (GLdouble) ctx->Pixel.MapColorFlag; + break; + case GL_MAP_STENCIL: + *params = (GLdouble) ctx->Pixel.MapStencilFlag; + break; + case GL_MATRIX_MODE: + *params = ENUM_TO_DOUBLE(ctx->Transform.MatrixMode); + break; + case GL_MAX_ATTRIB_STACK_DEPTH: + *params = (GLdouble) MAX_ATTRIB_STACK_DEPTH; + break; + case GL_MAX_CLIENT_ATTRIB_STACK_DEPTH: + *params = (GLdouble) MAX_CLIENT_ATTRIB_STACK_DEPTH; + break; + case GL_MAX_CLIP_PLANES: + *params = (GLdouble) MAX_CLIP_PLANES; + break; + case GL_MAX_EVAL_ORDER: + *params = (GLdouble) MAX_EVAL_ORDER; + break; + case GL_MAX_LIGHTS: + *params = (GLdouble) MAX_LIGHTS; + break; + case GL_MAX_LIST_NESTING: + *params = (GLdouble) MAX_LIST_NESTING; + break; + case GL_MAX_MODELVIEW_STACK_DEPTH: + *params = (GLdouble) MAX_MODELVIEW_STACK_DEPTH; + break; + case GL_MAX_NAME_STACK_DEPTH: + *params = (GLdouble) MAX_NAME_STACK_DEPTH; + break; + case GL_MAX_PIXEL_MAP_TABLE: + *params = (GLdouble) MAX_PIXEL_MAP_TABLE; + break; + case GL_MAX_PROJECTION_STACK_DEPTH: + *params = (GLdouble) MAX_PROJECTION_STACK_DEPTH; + break; + case GL_MAX_TEXTURE_SIZE: + *params = (GLdouble) MAX_TEXTURE_SIZE; + break; + case GL_MAX_TEXTURE_STACK_DEPTH: + *params = (GLdouble) MAX_TEXTURE_STACK_DEPTH; + break; + case GL_MAX_VIEWPORT_DIMS: + params[0] = (GLdouble) MAX_WIDTH; + params[1] = (GLdouble) MAX_HEIGHT; + break; + case GL_MODELVIEW_MATRIX: + for (i=0;i<16;i++) { + params[i] = (GLdouble) ctx->ModelViewMatrix[i]; + } + break; + case GL_MODELVIEW_STACK_DEPTH: + *params = (GLdouble) ctx->ModelViewStackDepth; + break; + case GL_NAME_STACK_DEPTH: + *params = (GLdouble) ctx->Select.NameStackDepth; + break; + case GL_NORMALIZE: + *params = (GLdouble) ctx->Transform.Normalize; + break; + case GL_PACK_ALIGNMENT: + *params = (GLdouble) ctx->Pack.Alignment; + break; + case GL_PACK_LSB_FIRST: + *params = (GLdouble) ctx->Pack.LsbFirst; + break; + case GL_PACK_ROW_LENGTH: + *params = (GLdouble) ctx->Pack.RowLength; + break; + case GL_PACK_SKIP_PIXELS: + *params = (GLdouble) ctx->Pack.SkipPixels; + break; + case GL_PACK_SKIP_ROWS: + *params = (GLdouble) ctx->Pack.SkipRows; + break; + case GL_PACK_SWAP_BYTES: + *params = (GLdouble) ctx->Pack.SwapBytes; + break; + case GL_PERSPECTIVE_CORRECTION_HINT: + *params = ENUM_TO_DOUBLE(ctx->Hint.PerspectiveCorrection); + break; + case GL_PIXEL_MAP_A_TO_A_SIZE: + *params = (GLdouble) ctx->Pixel.MapAtoAsize; + break; + case GL_PIXEL_MAP_B_TO_B_SIZE: + *params = (GLdouble) ctx->Pixel.MapBtoBsize; + break; + case GL_PIXEL_MAP_G_TO_G_SIZE: + *params = (GLdouble) ctx->Pixel.MapGtoGsize; + break; + case GL_PIXEL_MAP_I_TO_A_SIZE: + *params = (GLdouble) ctx->Pixel.MapItoAsize; + break; + case GL_PIXEL_MAP_I_TO_B_SIZE: + *params = (GLdouble) ctx->Pixel.MapItoBsize; + break; + case GL_PIXEL_MAP_I_TO_G_SIZE: + *params = (GLdouble) ctx->Pixel.MapItoGsize; + break; + case GL_PIXEL_MAP_I_TO_I_SIZE: + *params = (GLdouble) ctx->Pixel.MapItoIsize; + break; + case GL_PIXEL_MAP_I_TO_R_SIZE: + *params = (GLdouble) ctx->Pixel.MapItoRsize; + break; + case GL_PIXEL_MAP_R_TO_R_SIZE: + *params = (GLdouble) ctx->Pixel.MapRtoRsize; + break; + case GL_PIXEL_MAP_S_TO_S_SIZE: + *params = (GLdouble) ctx->Pixel.MapStoSsize; + break; + case GL_POINT_SIZE: + *params = (GLdouble) ctx->Point.Size; + break; + case GL_POINT_SIZE_GRANULARITY: + *params = (GLdouble) POINT_SIZE_GRANULARITY; + break; + case GL_POINT_SIZE_RANGE: + params[0] = (GLdouble) MIN_POINT_SIZE; + params[1] = (GLdouble) MAX_POINT_SIZE; + break; + case GL_POINT_SMOOTH: + *params = (GLdouble) ctx->Point.SmoothFlag; + break; + case GL_POINT_SMOOTH_HINT: + *params = ENUM_TO_DOUBLE(ctx->Hint.PointSmooth); + break; + case GL_POLYGON_MODE: + params[0] = ENUM_TO_DOUBLE(ctx->Polygon.FrontMode); + params[1] = ENUM_TO_DOUBLE(ctx->Polygon.BackMode); + break; +#ifdef GL_EXT_polygon_offset + case GL_POLYGON_OFFSET_BIAS_EXT: + *params = (GLdouble) ctx->Polygon.OffsetUnits; + break; +#endif + case GL_POLYGON_OFFSET_FACTOR: + *params = (GLdouble) ctx->Polygon.OffsetFactor; + break; + case GL_POLYGON_OFFSET_UNITS: + *params = (GLdouble) ctx->Polygon.OffsetUnits; + break; + case GL_POLYGON_SMOOTH: + *params = (GLdouble) ctx->Polygon.SmoothFlag; + break; + case GL_POLYGON_SMOOTH_HINT: + *params = ENUM_TO_DOUBLE(ctx->Hint.PolygonSmooth); + break; + case GL_POLYGON_STIPPLE: + for (i=0;i<32;i++) { /* RIGHT? */ + params[i] = (GLdouble) ctx->PolygonStipple[i]; + } + break; + case GL_PROJECTION_MATRIX: + for (i=0;i<16;i++) { + params[i] = (GLdouble) ctx->ProjectionMatrix[i]; + } + break; + case GL_PROJECTION_STACK_DEPTH: + *params = (GLdouble) ctx->ProjectionStackDepth; + break; + case GL_READ_BUFFER: + *params = ENUM_TO_DOUBLE(ctx->Pixel.ReadBuffer); + break; + case GL_RED_BIAS: + *params = (GLdouble) ctx->Pixel.RedBias; + break; + case GL_RED_BITS: + *params = (GLdouble) ctx->Visual->RedBits; + break; + case GL_RED_SCALE: + *params = (GLdouble) ctx->Pixel.RedScale; + break; + case GL_RENDER_MODE: + *params = ENUM_TO_DOUBLE(ctx->RenderMode); + break; + case GL_RGBA_MODE: + *params = (GLdouble) ctx->Visual->RGBAflag; + break; + case GL_SCISSOR_BOX: + params[0] = (GLdouble) ctx->Scissor.X; + params[1] = (GLdouble) ctx->Scissor.Y; + params[2] = (GLdouble) ctx->Scissor.Width; + params[3] = (GLdouble) ctx->Scissor.Height; + break; + case GL_SCISSOR_TEST: + *params = (GLdouble) ctx->Scissor.Enabled; + break; + case GL_SHADE_MODEL: + *params = ENUM_TO_DOUBLE(ctx->Light.ShadeModel); + break; + case GL_STENCIL_BITS: + *params = (GLdouble) ctx->Visual->StencilBits; + break; + case GL_STENCIL_CLEAR_VALUE: + *params = (GLdouble) ctx->Stencil.Clear; + break; + case GL_STENCIL_FAIL: + *params = ENUM_TO_DOUBLE(ctx->Stencil.FailFunc); + break; + case GL_STENCIL_FUNC: + *params = ENUM_TO_DOUBLE(ctx->Stencil.Function); + break; + case GL_STENCIL_PASS_DEPTH_FAIL: + *params = ENUM_TO_DOUBLE(ctx->Stencil.ZFailFunc); + break; + case GL_STENCIL_PASS_DEPTH_PASS: + *params = ENUM_TO_DOUBLE(ctx->Stencil.ZPassFunc); + break; + case GL_STENCIL_REF: + *params = (GLdouble) ctx->Stencil.Ref; + break; + case GL_STENCIL_TEST: + *params = (GLdouble) ctx->Stencil.Enabled; + break; + case GL_STENCIL_VALUE_MASK: + *params = (GLdouble) ctx->Stencil.ValueMask; + break; + case GL_STENCIL_WRITEMASK: + *params = (GLdouble) ctx->Stencil.WriteMask; + break; + case GL_STEREO: + *params = 0.0; /* TODO */ + break; + case GL_SUBPIXEL_BITS: + *params = 0.0; /* TODO */ + break; + case GL_TEXTURE_1D: + *params = (ctx->Texture.Enabled & TEXTURE_1D) ? 1.0 : 0.0; + break; + case GL_TEXTURE_2D: + *params = (ctx->Texture.Enabled & TEXTURE_2D) ? 1.0 : 0.0; + break; + case GL_TEXTURE_ENV_COLOR: + params[0] = (GLdouble) ctx->Texture.EnvColor[0]; + params[1] = (GLdouble) ctx->Texture.EnvColor[1]; + params[2] = (GLdouble) ctx->Texture.EnvColor[2]; + params[3] = (GLdouble) ctx->Texture.EnvColor[3]; + break; + case GL_TEXTURE_ENV_MODE: + *params = ENUM_TO_DOUBLE(ctx->Texture.EnvMode); + break; + case GL_TEXTURE_GEN_S: + *params = (ctx->Texture.TexGenEnabled & S_BIT) ? 1.0 : 0.0; + break; + case GL_TEXTURE_GEN_T: + *params = (ctx->Texture.TexGenEnabled & T_BIT) ? 1.0 : 0.0; + break; + case GL_TEXTURE_GEN_R: + *params = (ctx->Texture.TexGenEnabled & R_BIT) ? 1.0 : 0.0; + break; + case GL_TEXTURE_GEN_Q: + *params = (ctx->Texture.TexGenEnabled & Q_BIT) ? 1.0 : 0.0; + break; + case GL_TEXTURE_MATRIX: + for (i=0;i<16;i++) { + params[i] = (GLdouble) ctx->TextureMatrix[i]; + } + break; + case GL_TEXTURE_STACK_DEPTH: + *params = (GLdouble) ctx->TextureStackDepth; + break; + case GL_UNPACK_ALIGNMENT: + *params = (GLdouble) ctx->Unpack.Alignment; + break; + case GL_UNPACK_LSB_FIRST: + *params = (GLdouble) ctx->Unpack.LsbFirst; + break; + case GL_UNPACK_ROW_LENGTH: + *params = (GLdouble) ctx->Unpack.RowLength; + break; + case GL_UNPACK_SKIP_PIXELS: + *params = (GLdouble) ctx->Unpack.SkipPixels; + break; + case GL_UNPACK_SKIP_ROWS: + *params = (GLdouble) ctx->Unpack.SkipRows; + break; + case GL_UNPACK_SWAP_BYTES: + *params = (GLdouble) ctx->Unpack.SwapBytes; + break; + case GL_VIEWPORT: + params[0] = (GLdouble) ctx->Viewport.X; + params[1] = (GLdouble) ctx->Viewport.Y; + params[2] = (GLdouble) ctx->Viewport.Width; + params[3] = (GLdouble) ctx->Viewport.Height; + break; + case GL_ZOOM_X: + *params = (GLdouble) ctx->Pixel.ZoomX; + break; + case GL_ZOOM_Y: + *params = (GLdouble) ctx->Pixel.ZoomY; + break; + case GL_VERTEX_ARRAY_SIZE: + *params = (GLdouble) ctx->Array.VertexSize; + break; + case GL_VERTEX_ARRAY_TYPE: + *params = ENUM_TO_DOUBLE(ctx->Array.VertexType); + break; + case GL_VERTEX_ARRAY_STRIDE: + *params = (GLdouble) ctx->Array.VertexStride; + break; + case GL_VERTEX_ARRAY_COUNT_EXT: + *params = 0.0; + break; + case GL_NORMAL_ARRAY_TYPE: + *params = ENUM_TO_DOUBLE(ctx->Array.NormalType); + break; + case GL_NORMAL_ARRAY_STRIDE: + *params = (GLdouble) ctx->Array.NormalStride; + break; + case GL_NORMAL_ARRAY_COUNT_EXT: + *params = 0.0; + break; + case GL_COLOR_ARRAY_SIZE: + *params = (GLdouble) ctx->Array.ColorSize; + break; + case GL_COLOR_ARRAY_TYPE: + *params = ENUM_TO_DOUBLE(ctx->Array.ColorType); + break; + case GL_COLOR_ARRAY_STRIDE: + *params = (GLdouble) ctx->Array.ColorStride; + break; + case GL_COLOR_ARRAY_COUNT_EXT: + *params = 0.0; + break; + case GL_INDEX_ARRAY_TYPE: + *params = ENUM_TO_DOUBLE(ctx->Array.IndexType); + break; + case GL_INDEX_ARRAY_STRIDE: + *params = (GLdouble) ctx->Array.IndexStride; + break; + case GL_INDEX_ARRAY_COUNT_EXT: + *params = 0.0; + break; + case GL_TEXTURE_COORD_ARRAY_SIZE: + *params = (GLdouble) ctx->Array.TexCoordSize; + break; + case GL_TEXTURE_COORD_ARRAY_TYPE: + *params = ENUM_TO_DOUBLE(ctx->Array.TexCoordType); + break; + case GL_TEXTURE_COORD_ARRAY_STRIDE: + *params = (GLdouble) ctx->Array.TexCoordStride; + break; + case GL_TEXTURE_COORD_ARRAY_COUNT_EXT: + *params = 0.0; + break; + case GL_EDGE_FLAG_ARRAY_STRIDE: + *params = (GLdouble) ctx->Array.EdgeFlagStride; + break; + case GL_EDGE_FLAG_ARRAY_COUNT_EXT: + *params = 0.0; + break; + case GL_TEXTURE_BINDING_1D: + *params = (GLdouble) ctx->Texture.Current1D->Name; + break; + case GL_TEXTURE_BINDING_2D: + *params = (GLdouble) ctx->Texture.Current2D->Name; + break; + + default: + gl_error( ctx, GL_INVALID_ENUM, "glGetDoublev" ); + } +} + + + + +void gl_GetFloatv( GLcontext *ctx, GLenum pname, GLfloat *params ) +{ + GLuint i; + + if (INSIDE_BEGIN_END(ctx)) { + gl_error( ctx, GL_INVALID_OPERATION, "glGetFloatv" ); + return; + } + switch (pname) { + case GL_ACCUM_RED_BITS: + case GL_ACCUM_GREEN_BITS: + case GL_ACCUM_BLUE_BITS: + case GL_ACCUM_ALPHA_BITS: + *params = (GLfloat) ctx->Visual->AccumBits; + break; + case GL_ACCUM_CLEAR_VALUE: + params[0] = ctx->Accum.ClearColor[0]; + params[1] = ctx->Accum.ClearColor[1]; + params[2] = ctx->Accum.ClearColor[2]; + params[3] = ctx->Accum.ClearColor[3]; + break; + case GL_ALPHA_BIAS: + *params = ctx->Pixel.AlphaBias; + break; + case GL_ALPHA_BITS: + *params = (GLfloat) ctx->Visual->AlphaBits; + break; + case GL_ALPHA_SCALE: + *params = ctx->Pixel.AlphaScale; + break; + case GL_ALPHA_TEST: + *params = (GLfloat) ctx->Color.AlphaEnabled; + break; + case GL_ALPHA_TEST_FUNC: + *params = ENUM_TO_FLOAT(ctx->Color.AlphaFunc); + break; + case GL_ALPHA_TEST_REF: + *params = (GLfloat) ctx->Color.AlphaRef; + break; + case GL_ATTRIB_STACK_DEPTH: + *params = (GLfloat ) ctx->AttribStackDepth; + break; + case GL_AUTO_NORMAL: + *params = (GLfloat) ctx->Eval.AutoNormal; + break; + case GL_AUX_BUFFERS: + *params = (GLfloat) NUM_AUX_BUFFERS; + break; + case GL_BLEND: + *params = (GLfloat) ctx->Color.BlendEnabled; + break; + case GL_BLEND_DST: + *params = ENUM_TO_FLOAT(ctx->Color.BlendDst); + break; + case GL_BLEND_SRC: + *params = ENUM_TO_FLOAT(ctx->Color.BlendSrc); + break; + case GL_BLUE_BIAS: + *params = ctx->Pixel.BlueBias; + break; + case GL_BLUE_BITS: + *params = (GLfloat) ctx->Visual->BlueBits; + break; + case GL_BLUE_SCALE: + *params = ctx->Pixel.BlueScale; + break; + case GL_CLIENT_ATTRIB_STACK_DEPTH: + *params = (GLfloat) ctx->ClientAttribStackDepth; + break; + case GL_CLIP_PLANE0: + case GL_CLIP_PLANE1: + case GL_CLIP_PLANE2: + case GL_CLIP_PLANE3: + case GL_CLIP_PLANE4: + case GL_CLIP_PLANE5: + *params = (GLfloat) ctx->Transform.ClipEnabled[pname-GL_CLIP_PLANE0]; + break; + case GL_COLOR_CLEAR_VALUE: + params[0] = (GLfloat) ctx->Color.ClearColor[0]; + params[1] = (GLfloat) ctx->Color.ClearColor[1]; + params[2] = (GLfloat) ctx->Color.ClearColor[2]; + params[3] = (GLfloat) ctx->Color.ClearColor[3]; + break; + case GL_COLOR_MATERIAL: + *params = (GLfloat) ctx->Light.ColorMaterialEnabled; + break; + case GL_COLOR_MATERIAL_FACE: + *params = ENUM_TO_FLOAT(ctx->Light.ColorMaterialFace); + break; + case GL_COLOR_MATERIAL_PARAMETER: + *params = ENUM_TO_FLOAT(ctx->Light.ColorMaterialMode); + break; + case GL_COLOR_WRITEMASK: + params[0] = (ctx->Color.ColorMask & 8) ? 1.0F : 0.0F; + params[1] = (ctx->Color.ColorMask & 4) ? 1.0F : 0.0F; + params[2] = (ctx->Color.ColorMask & 2) ? 1.0F : 0.0F; + params[3] = (ctx->Color.ColorMask & 1) ? 1.0F : 0.0F; + break; + case GL_CULL_FACE: + *params = (GLfloat) ctx->Polygon.CullFlag; + break; + case GL_CULL_FACE_MODE: + *params = ENUM_TO_FLOAT(ctx->Polygon.CullFaceMode); + break; + case GL_CURRENT_COLOR: + params[0] = ctx->Current.ByteColor[0] * ctx->Visual->InvRedScale; + params[1] = ctx->Current.ByteColor[1] * ctx->Visual->InvGreenScale; + params[2] = ctx->Current.ByteColor[2] * ctx->Visual->InvBlueScale; + params[3] = ctx->Current.ByteColor[3] * ctx->Visual->InvAlphaScale; + break; + case GL_CURRENT_INDEX: + *params = (GLfloat) ctx->Current.Index; + break; + case GL_CURRENT_NORMAL: + params[0] = ctx->Current.Normal[0]; + params[1] = ctx->Current.Normal[1]; + params[2] = ctx->Current.Normal[2]; + break; + case GL_CURRENT_RASTER_COLOR: + params[0] = ctx->Current.RasterColor[0]; + params[1] = ctx->Current.RasterColor[1]; + params[2] = ctx->Current.RasterColor[2]; + params[3] = ctx->Current.RasterColor[3]; + break; + case GL_CURRENT_RASTER_DISTANCE: + params[0] = ctx->Current.RasterDistance; + break; + case GL_CURRENT_RASTER_INDEX: + *params = (GLfloat) ctx->Current.RasterIndex; + break; + case GL_CURRENT_RASTER_POSITION: + params[0] = ctx->Current.RasterPos[0]; + params[1] = ctx->Current.RasterPos[1]; + params[2] = ctx->Current.RasterPos[2]; + params[3] = ctx->Current.RasterPos[3]; + break; + case GL_CURRENT_RASTER_TEXTURE_COORDS: + params[0] = ctx->Current.RasterTexCoord[0]; + params[1] = ctx->Current.RasterTexCoord[1]; + params[2] = ctx->Current.RasterTexCoord[2]; + params[3] = ctx->Current.RasterTexCoord[3]; + break; + case GL_CURRENT_RASTER_POSITION_VALID: + *params = (GLfloat) ctx->Current.RasterPosValid; + break; + case GL_CURRENT_TEXTURE_COORDS: + params[0] = (GLfloat) ctx->Current.TexCoord[0]; + params[1] = (GLfloat) ctx->Current.TexCoord[1]; + params[2] = (GLfloat) ctx->Current.TexCoord[2]; + params[3] = (GLfloat) ctx->Current.TexCoord[3]; + break; + case GL_DEPTH_BIAS: + *params = (GLfloat) ctx->Pixel.DepthBias; + break; + case GL_DEPTH_BITS: + *params = (GLfloat) ctx->Visual->DepthBits; + break; + case GL_DEPTH_CLEAR_VALUE: + *params = (GLfloat) ctx->Depth.Clear; + break; + case GL_DEPTH_FUNC: + *params = ENUM_TO_FLOAT(ctx->Depth.Func); + break; + case GL_DEPTH_RANGE: + params[0] = (GLfloat) ctx->Viewport.Near; + params[1] = (GLfloat) ctx->Viewport.Far; + break; + case GL_DEPTH_SCALE: + *params = (GLfloat) ctx->Pixel.DepthScale; + break; + case GL_DEPTH_TEST: + *params = (GLfloat) ctx->Depth.Test; + break; + case GL_DEPTH_WRITEMASK: + *params = (GLfloat) ctx->Depth.Mask; + break; + case GL_DITHER: + *params = (GLfloat) ctx->Color.DitherFlag; + break; + case GL_DOUBLEBUFFER: + *params = (GLfloat) ctx->Visual->DBflag; + break; + case GL_DRAW_BUFFER: + *params = ENUM_TO_FLOAT(ctx->Color.DrawBuffer); + break; + case GL_EDGE_FLAG: + *params = (GLfloat) ctx->Current.EdgeFlag; + break; + case GL_FEEDBACK_BUFFER_SIZE: + /* TODO: is this right? Or, return number of entries in buffer? */ + *params = (GLfloat) ctx->Feedback.BufferSize; + break; + case GL_FEEDBACK_BUFFER_TYPE: + *params = ENUM_TO_FLOAT(ctx->Feedback.Type); + break; + case GL_FOG: + *params = (GLfloat) ctx->Fog.Enabled; + break; + case GL_FOG_COLOR: + params[0] = ctx->Fog.Color[0]; + params[1] = ctx->Fog.Color[1]; + params[2] = ctx->Fog.Color[2]; + params[3] = ctx->Fog.Color[3]; + break; + case GL_FOG_DENSITY: + *params = ctx->Fog.Density; + break; + case GL_FOG_END: + *params = ctx->Fog.End; + break; + case GL_FOG_HINT: + *params = ENUM_TO_FLOAT(ctx->Hint.Fog); + break; + case GL_FOG_INDEX: + *params = ctx->Fog.Index; + break; + case GL_FOG_MODE: + *params = ENUM_TO_FLOAT(ctx->Fog.Mode); + break; + case GL_FOG_START: + *params = ctx->Fog.Start; + break; + case GL_FRONT_FACE: + *params = ENUM_TO_FLOAT(ctx->Polygon.FrontFace); + break; + case GL_GREEN_BIAS: + *params = (GLfloat) ctx->Pixel.GreenBias; + break; + case GL_GREEN_BITS: + *params = (GLfloat) ctx->Visual->GreenBits; + break; + case GL_GREEN_SCALE: + *params = (GLfloat) ctx->Pixel.GreenScale; + break; + case GL_INDEX_BITS: + *params = (GLfloat) ctx->Visual->IndexBits; + break; + case GL_INDEX_CLEAR_VALUE: + *params = (GLfloat) ctx->Color.ClearIndex; + break; + case GL_INDEX_MODE: + *params = ctx->Visual->RGBAflag ? 0.0F : 1.0F; + break; + case GL_INDEX_OFFSET: + *params = (GLfloat) ctx->Pixel.IndexOffset; + break; + case GL_INDEX_SHIFT: + *params = (GLfloat) ctx->Pixel.IndexShift; + break; + case GL_INDEX_WRITEMASK: + *params = (GLfloat) ctx->Color.IndexMask; + break; + case GL_LIGHT0: + case GL_LIGHT1: + case GL_LIGHT2: + case GL_LIGHT3: + case GL_LIGHT4: + case GL_LIGHT5: + case GL_LIGHT6: + case GL_LIGHT7: + *params = (GLfloat) ctx->Light.Light[pname-GL_LIGHT0].Enabled; + break; + case GL_LIGHTING: + *params = (GLfloat) ctx->Light.Enabled; + break; + case GL_LIGHT_MODEL_AMBIENT: + params[0] = ctx->Light.Model.Ambient[0]; + params[1] = ctx->Light.Model.Ambient[1]; + params[2] = ctx->Light.Model.Ambient[2]; + params[3] = ctx->Light.Model.Ambient[3]; + break; + case GL_LIGHT_MODEL_LOCAL_VIEWER: + *params = (GLfloat) ctx->Light.Model.LocalViewer; + break; + case GL_LIGHT_MODEL_TWO_SIDE: + *params = (GLfloat) ctx->Light.Model.TwoSide; + break; + case GL_LINE_SMOOTH: + *params = (GLfloat) ctx->Line.SmoothFlag; + break; + case GL_LINE_SMOOTH_HINT: + *params = ENUM_TO_FLOAT(ctx->Hint.LineSmooth); + break; + case GL_LINE_STIPPLE: + *params = (GLfloat) ctx->Line.StippleFlag; + break; + case GL_LINE_STIPPLE_PATTERN: + *params = (GLfloat) ctx->Line.StipplePattern; + break; + case GL_LINE_STIPPLE_REPEAT: + *params = (GLfloat) ctx->Line.StippleFactor; + break; + case GL_LINE_WIDTH: + *params = (GLfloat) ctx->Line.Width; + break; + case GL_LINE_WIDTH_GRANULARITY: + *params = (GLfloat) LINE_WIDTH_GRANULARITY; + break; + case GL_LINE_WIDTH_RANGE: + params[0] = (GLfloat) MIN_LINE_WIDTH; + params[1] = (GLfloat) MAX_LINE_WIDTH; + break; + case GL_LIST_BASE: + *params = (GLfloat) ctx->List.ListBase; + break; + case GL_LIST_INDEX: + *params = (GLfloat) ctx->CurrentListNum; + break; + case GL_LIST_MODE: + *params = ctx->ExecuteFlag ? ENUM_TO_FLOAT(GL_COMPILE_AND_EXECUTE) + : ENUM_TO_FLOAT(GL_COMPILE); + break; + case GL_INDEX_LOGIC_OP: + *params = (GLfloat) ctx->Color.IndexLogicOpEnabled; + break; + case GL_COLOR_LOGIC_OP: + *params = (GLfloat) ctx->Color.ColorLogicOpEnabled; + break; + case GL_LOGIC_OP_MODE: + *params = ENUM_TO_FLOAT(ctx->Color.LogicOp); + break; + case GL_MAP1_COLOR_4: + *params = (GLfloat) ctx->Eval.Map1Color4; + break; + case GL_MAP1_GRID_DOMAIN: + params[0] = ctx->Eval.MapGrid1u1; + params[1] = ctx->Eval.MapGrid1u2; + break; + case GL_MAP1_GRID_SEGMENTS: + *params = (GLfloat) ctx->Eval.MapGrid1un; + break; + case GL_MAP1_INDEX: + *params = (GLfloat) ctx->Eval.Map1Index; + break; + case GL_MAP1_NORMAL: + *params = (GLfloat) ctx->Eval.Map1Normal; + break; + case GL_MAP1_TEXTURE_COORD_1: + *params = (GLfloat) ctx->Eval.Map1TextureCoord1; + break; + case GL_MAP1_TEXTURE_COORD_2: + *params = (GLfloat) ctx->Eval.Map1TextureCoord2; + break; + case GL_MAP1_TEXTURE_COORD_3: + *params = (GLfloat) ctx->Eval.Map1TextureCoord3; + break; + case GL_MAP1_TEXTURE_COORD_4: + *params = (GLfloat) ctx->Eval.Map1TextureCoord4; + break; + case GL_MAP1_VERTEX_3: + *params = (GLfloat) ctx->Eval.Map1Vertex3; + break; + case GL_MAP1_VERTEX_4: + *params = (GLfloat) ctx->Eval.Map1Vertex4; + break; + case GL_MAP2_COLOR_4: + *params = (GLfloat) ctx->Eval.Map2Color4; + break; + case GL_MAP2_GRID_DOMAIN: + params[0] = ctx->Eval.MapGrid2u1; + params[1] = ctx->Eval.MapGrid2u2; + params[2] = ctx->Eval.MapGrid2v1; + params[3] = ctx->Eval.MapGrid2v2; + break; + case GL_MAP2_GRID_SEGMENTS: + params[0] = (GLfloat) ctx->Eval.MapGrid2un; + params[1] = (GLfloat) ctx->Eval.MapGrid2vn; + break; + case GL_MAP2_INDEX: + *params = (GLfloat) ctx->Eval.Map2Index; + break; + case GL_MAP2_NORMAL: + *params = (GLfloat) ctx->Eval.Map2Normal; + break; + case GL_MAP2_TEXTURE_COORD_1: + *params = ctx->Eval.Map2TextureCoord1; + break; + case GL_MAP2_TEXTURE_COORD_2: + *params = ctx->Eval.Map2TextureCoord2; + break; + case GL_MAP2_TEXTURE_COORD_3: + *params = ctx->Eval.Map2TextureCoord3; + break; + case GL_MAP2_TEXTURE_COORD_4: + *params = ctx->Eval.Map2TextureCoord4; + break; + case GL_MAP2_VERTEX_3: + *params = (GLfloat) ctx->Eval.Map2Vertex3; + break; + case GL_MAP2_VERTEX_4: + *params = (GLfloat) ctx->Eval.Map2Vertex4; + break; + case GL_MAP_COLOR: + *params = (GLfloat) ctx->Pixel.MapColorFlag; + break; + case GL_MAP_STENCIL: + *params = (GLfloat) ctx->Pixel.MapStencilFlag; + break; + case GL_MATRIX_MODE: + *params = ENUM_TO_FLOAT(ctx->Transform.MatrixMode); + break; + case GL_MAX_ATTRIB_STACK_DEPTH: + *params = (GLfloat) MAX_ATTRIB_STACK_DEPTH; + break; + case GL_MAX_CLIENT_ATTRIB_STACK_DEPTH: + *params = (GLfloat) MAX_CLIENT_ATTRIB_STACK_DEPTH; + break; + case GL_MAX_CLIP_PLANES: + *params = (GLfloat) MAX_CLIP_PLANES; + break; + case GL_MAX_EVAL_ORDER: + *params = (GLfloat) MAX_EVAL_ORDER; + break; + case GL_MAX_LIGHTS: + *params = (GLfloat) MAX_LIGHTS; + break; + case GL_MAX_LIST_NESTING: + *params = (GLfloat) MAX_LIST_NESTING; + break; + case GL_MAX_MODELVIEW_STACK_DEPTH: + *params = (GLfloat) MAX_MODELVIEW_STACK_DEPTH; + break; + case GL_MAX_NAME_STACK_DEPTH: + *params = (GLfloat) MAX_NAME_STACK_DEPTH; + break; + case GL_MAX_PIXEL_MAP_TABLE: + *params = (GLfloat) MAX_PIXEL_MAP_TABLE; + break; + case GL_MAX_PROJECTION_STACK_DEPTH: + *params = (GLfloat) MAX_PROJECTION_STACK_DEPTH; + break; + case GL_MAX_TEXTURE_SIZE: + *params = (GLfloat) MAX_TEXTURE_SIZE; + break; + case GL_MAX_TEXTURE_STACK_DEPTH: + *params = (GLfloat) MAX_TEXTURE_STACK_DEPTH; + break; + case GL_MAX_VIEWPORT_DIMS: + params[0] = (GLfloat) MAX_WIDTH; + params[1] = (GLfloat) MAX_HEIGHT; + break; + case GL_MODELVIEW_MATRIX: + for (i=0;i<16;i++) { + params[i] = ctx->ModelViewMatrix[i]; + } + break; + case GL_MODELVIEW_STACK_DEPTH: + *params = (GLfloat) ctx->ModelViewStackDepth; + break; + case GL_NAME_STACK_DEPTH: + *params = (GLfloat) ctx->Select.NameStackDepth; + break; + case GL_NORMALIZE: + *params = (GLfloat) ctx->Transform.Normalize; + break; + case GL_PACK_ALIGNMENT: + *params = (GLfloat) ctx->Pack.Alignment; + break; + case GL_PACK_LSB_FIRST: + *params = (GLfloat) ctx->Pack.LsbFirst; + break; + case GL_PACK_ROW_LENGTH: + *params = (GLfloat) ctx->Pack.RowLength; + break; + case GL_PACK_SKIP_PIXELS: + *params = (GLfloat) ctx->Pack.SkipPixels; + break; + case GL_PACK_SKIP_ROWS: + *params = (GLfloat) ctx->Pack.SkipRows; + break; + case GL_PACK_SWAP_BYTES: + *params = (GLfloat) ctx->Pack.SwapBytes; + break; + case GL_PERSPECTIVE_CORRECTION_HINT: + *params = ENUM_TO_FLOAT(ctx->Hint.PerspectiveCorrection); + break; + case GL_PIXEL_MAP_A_TO_A_SIZE: + *params = (GLfloat) ctx->Pixel.MapAtoAsize; + break; + case GL_PIXEL_MAP_B_TO_B_SIZE: + *params = (GLfloat) ctx->Pixel.MapBtoBsize; + break; + case GL_PIXEL_MAP_G_TO_G_SIZE: + *params = (GLfloat) ctx->Pixel.MapGtoGsize; + break; + case GL_PIXEL_MAP_I_TO_A_SIZE: + *params = (GLfloat) ctx->Pixel.MapItoAsize; + break; + case GL_PIXEL_MAP_I_TO_B_SIZE: + *params = (GLfloat) ctx->Pixel.MapItoBsize; + break; + case GL_PIXEL_MAP_I_TO_G_SIZE: + *params = (GLfloat) ctx->Pixel.MapItoGsize; + break; + case GL_PIXEL_MAP_I_TO_I_SIZE: + *params = (GLfloat) ctx->Pixel.MapItoIsize; + break; + case GL_PIXEL_MAP_I_TO_R_SIZE: + *params = (GLfloat) ctx->Pixel.MapItoRsize; + break; + case GL_PIXEL_MAP_R_TO_R_SIZE: + *params = (GLfloat) ctx->Pixel.MapRtoRsize; + break; + case GL_PIXEL_MAP_S_TO_S_SIZE: + *params = (GLfloat) ctx->Pixel.MapStoSsize; + break; + case GL_POINT_SIZE: + *params = (GLfloat) ctx->Point.Size; + break; + case GL_POINT_SIZE_GRANULARITY: + *params = (GLfloat) POINT_SIZE_GRANULARITY; + break; + case GL_POINT_SIZE_RANGE: + params[0] = (GLfloat) MIN_POINT_SIZE; + params[1] = (GLfloat) MAX_POINT_SIZE; + break; + case GL_POINT_SMOOTH: + *params = (GLfloat) ctx->Point.SmoothFlag; + break; + case GL_POINT_SMOOTH_HINT: + *params = ENUM_TO_FLOAT(ctx->Hint.PointSmooth); + break; + case GL_POLYGON_MODE: + params[0] = ENUM_TO_FLOAT(ctx->Polygon.FrontMode); + params[1] = ENUM_TO_FLOAT(ctx->Polygon.BackMode); + break; +#ifdef GL_EXT_polygon_offset + case GL_POLYGON_OFFSET_BIAS_EXT: + *params = ctx->Polygon.OffsetUnits; + break; +#endif + case GL_POLYGON_OFFSET_FACTOR: + *params = ctx->Polygon.OffsetFactor; + break; + case GL_POLYGON_OFFSET_UNITS: + *params = ctx->Polygon.OffsetUnits; + break; + case GL_POLYGON_SMOOTH: + *params = (GLfloat) ctx->Polygon.SmoothFlag; + break; + case GL_POLYGON_SMOOTH_HINT: + *params = ENUM_TO_FLOAT(ctx->Hint.PolygonSmooth); + break; + case GL_POLYGON_STIPPLE: + for (i=0;i<32;i++) { /* RIGHT? */ + params[i] = (GLfloat) ctx->PolygonStipple[i]; + } + break; + case GL_PROJECTION_MATRIX: + for (i=0;i<16;i++) { + params[i] = ctx->ProjectionMatrix[i]; + } + break; + case GL_PROJECTION_STACK_DEPTH: + *params = (GLfloat) ctx->ProjectionStackDepth; + break; + case GL_READ_BUFFER: + *params = ENUM_TO_FLOAT(ctx->Pixel.ReadBuffer); + break; + case GL_RED_BIAS: + *params = ctx->Pixel.RedBias; + break; + case GL_RED_BITS: + *params = (GLfloat) ctx->Visual->RedBits; + break; + case GL_RED_SCALE: + *params = ctx->Pixel.RedScale; + break; + case GL_RENDER_MODE: + *params = ENUM_TO_FLOAT(ctx->RenderMode); + break; + case GL_RGBA_MODE: + *params = (GLfloat) ctx->Visual->RGBAflag; + break; + case GL_SCISSOR_BOX: + params[0] = (GLfloat) ctx->Scissor.X; + params[1] = (GLfloat) ctx->Scissor.Y; + params[2] = (GLfloat) ctx->Scissor.Width; + params[3] = (GLfloat) ctx->Scissor.Height; + break; + case GL_SCISSOR_TEST: + *params = (GLfloat) ctx->Scissor.Enabled; + break; + case GL_SHADE_MODEL: + *params = ENUM_TO_FLOAT(ctx->Light.ShadeModel); + break; + case GL_STENCIL_BITS: + *params = (GLfloat) ctx->Visual->StencilBits; + break; + case GL_STENCIL_CLEAR_VALUE: + *params = (GLfloat) ctx->Stencil.Clear; + break; + case GL_STENCIL_FAIL: + *params = ENUM_TO_FLOAT(ctx->Stencil.FailFunc); + break; + case GL_STENCIL_FUNC: + *params = ENUM_TO_FLOAT(ctx->Stencil.Function); + break; + case GL_STENCIL_PASS_DEPTH_FAIL: + *params = ENUM_TO_FLOAT(ctx->Stencil.ZFailFunc); + break; + case GL_STENCIL_PASS_DEPTH_PASS: + *params = ENUM_TO_FLOAT(ctx->Stencil.ZPassFunc); + break; + case GL_STENCIL_REF: + *params = (GLfloat) ctx->Stencil.Ref; + break; + case GL_STENCIL_TEST: + *params = (GLfloat) ctx->Stencil.Enabled; + break; + case GL_STENCIL_VALUE_MASK: + *params = (GLfloat) ctx->Stencil.ValueMask; + break; + case GL_STENCIL_WRITEMASK: + *params = (GLfloat) ctx->Stencil.WriteMask; + break; + case GL_STEREO: + *params = 0.0F; /* TODO */ + break; + case GL_SUBPIXEL_BITS: + *params = 0.0F; /* TODO */ + break; + case GL_TEXTURE_1D: + *params = (ctx->Texture.Enabled & TEXTURE_1D) ? 1.0 : 0.0; + break; + case GL_TEXTURE_2D: + *params = (ctx->Texture.Enabled & TEXTURE_2D) ? 1.0 : 0.0; + break; + case GL_TEXTURE_ENV_COLOR: + params[0] = ctx->Texture.EnvColor[0]; + params[1] = ctx->Texture.EnvColor[1]; + params[2] = ctx->Texture.EnvColor[2]; + params[3] = ctx->Texture.EnvColor[3]; + break; + case GL_TEXTURE_ENV_MODE: + *params = ENUM_TO_FLOAT(ctx->Texture.EnvMode); + break; + case GL_TEXTURE_GEN_S: + *params = (ctx->Texture.TexGenEnabled & S_BIT) ? 1.0 : 0.0; + break; + case GL_TEXTURE_GEN_T: + *params = (ctx->Texture.TexGenEnabled & T_BIT) ? 1.0 : 0.0; + break; + case GL_TEXTURE_GEN_R: + *params = (ctx->Texture.TexGenEnabled & R_BIT) ? 1.0 : 0.0; + break; + case GL_TEXTURE_GEN_Q: + *params = (ctx->Texture.TexGenEnabled & Q_BIT) ? 1.0 : 0.0; + break; + case GL_TEXTURE_MATRIX: + for (i=0;i<16;i++) { + params[i] = ctx->TextureMatrix[i]; + } + break; + case GL_TEXTURE_STACK_DEPTH: + *params = (GLfloat) ctx->TextureStackDepth; + break; + case GL_UNPACK_ALIGNMENT: + *params = (GLfloat) ctx->Unpack.Alignment; + break; + case GL_UNPACK_LSB_FIRST: + *params = (GLfloat) ctx->Unpack.LsbFirst; + break; + case GL_UNPACK_ROW_LENGTH: + *params = (GLfloat) ctx->Unpack.RowLength; + break; + case GL_UNPACK_SKIP_PIXELS: + *params = (GLfloat) ctx->Unpack.SkipPixels; + break; + case GL_UNPACK_SKIP_ROWS: + *params = (GLfloat) ctx->Unpack.SkipRows; + break; + case GL_UNPACK_SWAP_BYTES: + *params = (GLfloat) ctx->Unpack.SwapBytes; + break; + case GL_VIEWPORT: + params[0] = (GLfloat) ctx->Viewport.X; + params[1] = (GLfloat) ctx->Viewport.Y; + params[2] = (GLfloat) ctx->Viewport.Width; + params[3] = (GLfloat) ctx->Viewport.Height; + break; + case GL_ZOOM_X: + *params = (GLfloat) ctx->Pixel.ZoomX; + break; + case GL_ZOOM_Y: + *params = (GLfloat) ctx->Pixel.ZoomY; + break; + case GL_VERTEX_ARRAY_SIZE: + *params = (GLfloat) ctx->Array.VertexSize; + break; + case GL_VERTEX_ARRAY_TYPE: + *params = ENUM_TO_FLOAT(ctx->Array.VertexType); + break; + case GL_VERTEX_ARRAY_STRIDE: + *params = (GLfloat) ctx->Array.VertexStride; + break; + case GL_VERTEX_ARRAY_COUNT_EXT: + *params = 0.0; + break; + case GL_NORMAL_ARRAY_TYPE: + *params = ENUM_TO_FLOAT(ctx->Array.NormalType); + break; + case GL_NORMAL_ARRAY_STRIDE: + *params = (GLfloat) ctx->Array.NormalStride; + break; + case GL_NORMAL_ARRAY_COUNT_EXT: + *params = 0.0; + break; + case GL_COLOR_ARRAY_SIZE: + *params = (GLfloat) ctx->Array.ColorSize; + break; + case GL_COLOR_ARRAY_TYPE: + *params = ENUM_TO_FLOAT(ctx->Array.ColorType); + break; + case GL_COLOR_ARRAY_STRIDE: + *params = (GLfloat) ctx->Array.ColorStride; + break; + case GL_COLOR_ARRAY_COUNT_EXT: + *params = 0.0; + break; + case GL_INDEX_ARRAY_TYPE: + *params = ENUM_TO_FLOAT(ctx->Array.IndexType); + break; + case GL_INDEX_ARRAY_STRIDE: + *params = (GLfloat) ctx->Array.IndexStride; + break; + case GL_INDEX_ARRAY_COUNT_EXT: + *params = 0.0; + break; + case GL_TEXTURE_COORD_ARRAY_SIZE: + *params = (GLfloat) ctx->Array.TexCoordSize; + break; + case GL_TEXTURE_COORD_ARRAY_TYPE: + *params = ENUM_TO_FLOAT(ctx->Array.TexCoordType); + break; + case GL_TEXTURE_COORD_ARRAY_STRIDE: + *params = (GLfloat) ctx->Array.TexCoordStride; + break; + case GL_TEXTURE_COORD_ARRAY_COUNT_EXT: + *params = 0.0; + break; + case GL_EDGE_FLAG_ARRAY_STRIDE: + *params = (GLfloat) ctx->Array.EdgeFlagStride; + break; + case GL_EDGE_FLAG_ARRAY_COUNT_EXT: + *params = 0.0; + break; + case GL_TEXTURE_BINDING_1D: + *params = (GLfloat) ctx->Texture.Current1D->Name; + break; + case GL_TEXTURE_BINDING_2D: + *params = (GLfloat) ctx->Texture.Current2D->Name; + break; + case GL_TEXTURE_3D_BINDING_EXT: + *params = (GLfloat) ctx->Texture.Current2D->Name; + break; + + default: + gl_error( ctx, GL_INVALID_ENUM, "glGetFloatv" ); + } +} + + + + +void gl_GetIntegerv( GLcontext *ctx, GLenum pname, GLint *params ) +{ + GLuint i; + + if (INSIDE_BEGIN_END(ctx)) { + gl_error( ctx, GL_INVALID_OPERATION, "glGetIntegerv" ); + return; + } + switch (pname) { + case GL_ACCUM_RED_BITS: + case GL_ACCUM_GREEN_BITS: + case GL_ACCUM_BLUE_BITS: + case GL_ACCUM_ALPHA_BITS: + *params = (GLint) ctx->Visual->AccumBits; + break; + case GL_ACCUM_CLEAR_VALUE: + params[0] = FLOAT_TO_INT( ctx->Accum.ClearColor[0] ); + params[1] = FLOAT_TO_INT( ctx->Accum.ClearColor[1] ); + params[2] = FLOAT_TO_INT( ctx->Accum.ClearColor[2] ); + params[3] = FLOAT_TO_INT( ctx->Accum.ClearColor[3] ); + break; + case GL_ALPHA_BIAS: + *params = (GLint) ctx->Pixel.AlphaBias; + break; + case GL_ALPHA_BITS: + *params = ctx->Visual->AlphaBits; + break; + case GL_ALPHA_SCALE: + *params = (GLint) ctx->Pixel.AlphaScale; + break; + case GL_ALPHA_TEST: + *params = (GLint) ctx->Color.AlphaEnabled; + break; + case GL_ALPHA_TEST_REF: + *params = FLOAT_TO_INT( ctx->Color.AlphaRef ); + break; + case GL_ALPHA_TEST_FUNC: + *params = (GLint) ctx->Color.AlphaFunc; + break; + case GL_ATTRIB_STACK_DEPTH: + *params = (GLint) ctx->AttribStackDepth; + break; + case GL_AUTO_NORMAL: + *params = (GLint) ctx->Eval.AutoNormal; + break; + case GL_AUX_BUFFERS: + *params = (GLint) NUM_AUX_BUFFERS; + break; + case GL_BLEND: + *params = (GLint) ctx->Color.BlendEnabled; + break; + case GL_BLEND_DST: + *params = (GLint) ctx->Color.BlendDst; + break; + case GL_BLEND_SRC: + *params = (GLint) ctx->Color.BlendSrc; + break; + case GL_BLUE_BIAS: + *params = (GLint) ctx->Pixel.BlueBias; + break; + case GL_BLUE_BITS: + *params = (GLint) ctx->Visual->BlueBits; + break; + case GL_BLUE_SCALE: + *params = (GLint) ctx->Pixel.BlueScale; + break; + case GL_CLIENT_ATTRIB_STACK_DEPTH: + *params = ctx->ClientAttribStackDepth; + break; + case GL_CLIP_PLANE0: + case GL_CLIP_PLANE1: + case GL_CLIP_PLANE2: + case GL_CLIP_PLANE3: + case GL_CLIP_PLANE4: + case GL_CLIP_PLANE5: + i = (GLint) (pname - GL_CLIP_PLANE0); + *params = (GLint) ctx->Transform.ClipEnabled[i]; + break; + case GL_COLOR_CLEAR_VALUE: + params[0] = FLOAT_TO_INT( ctx->Color.ClearColor[0] ); + params[1] = FLOAT_TO_INT( ctx->Color.ClearColor[1] ); + params[2] = FLOAT_TO_INT( ctx->Color.ClearColor[2] ); + params[3] = FLOAT_TO_INT( ctx->Color.ClearColor[3] ); + break; + case GL_COLOR_MATERIAL: + *params = (GLint) ctx->Light.ColorMaterialEnabled; + break; + case GL_COLOR_MATERIAL_FACE: + *params = (GLint) ctx->Light.ColorMaterialFace; + break; + case GL_COLOR_MATERIAL_PARAMETER: + *params = (GLint) ctx->Light.ColorMaterialMode; + break; + case GL_COLOR_WRITEMASK: + params[0] = (ctx->Color.ColorMask & 8) ? 1 : 0; + params[1] = (ctx->Color.ColorMask & 4) ? 1 : 0; + params[2] = (ctx->Color.ColorMask & 2) ? 1 : 0; + params[3] = (ctx->Color.ColorMask & 1) ? 1 : 0; + break; + case GL_CULL_FACE: + *params = (GLint) ctx->Polygon.CullFlag; + break; + case GL_CULL_FACE_MODE: + *params = (GLint) ctx->Polygon.CullFaceMode; + break; + case GL_CURRENT_COLOR: + params[0] = FLOAT_TO_INT( (ctx->Current.ByteColor[0]*ctx->Visual->InvRedScale) ); + params[1] = FLOAT_TO_INT( (ctx->Current.ByteColor[1]*ctx->Visual->InvGreenScale) ); + params[2] = FLOAT_TO_INT( (ctx->Current.ByteColor[2]*ctx->Visual->InvBlueScale) ); + params[3] = FLOAT_TO_INT( (ctx->Current.ByteColor[3]*ctx->Visual->InvAlphaScale) ); + break; + case GL_CURRENT_INDEX: + *params = (GLint) ctx->Current.Index; + break; + case GL_CURRENT_NORMAL: + params[0] = FLOAT_TO_INT( ctx->Current.Normal[0] ); + params[1] = FLOAT_TO_INT( ctx->Current.Normal[1] ); + params[2] = FLOAT_TO_INT( ctx->Current.Normal[2] ); + break; + case GL_CURRENT_RASTER_COLOR: + params[0] = FLOAT_TO_INT( ctx->Current.RasterColor[0] ); + params[1] = FLOAT_TO_INT( ctx->Current.RasterColor[1] ); + params[2] = FLOAT_TO_INT( ctx->Current.RasterColor[2] ); + params[3] = FLOAT_TO_INT( ctx->Current.RasterColor[3] ); + break; + case GL_CURRENT_RASTER_DISTANCE: + params[0] = (GLint) ctx->Current.RasterDistance; + break; + case GL_CURRENT_RASTER_INDEX: + *params = (GLint) ctx->Current.RasterIndex; + break; + case GL_CURRENT_RASTER_POSITION: + params[0] = (GLint) ctx->Current.RasterPos[0]; + params[1] = (GLint) ctx->Current.RasterPos[1]; + params[2] = (GLint) ctx->Current.RasterPos[2]; + params[3] = (GLint) ctx->Current.RasterPos[3]; + break; + case GL_CURRENT_RASTER_TEXTURE_COORDS: + params[0] = (GLint) ctx->Current.RasterTexCoord[0]; + params[1] = (GLint) ctx->Current.RasterTexCoord[1]; + params[2] = (GLint) ctx->Current.RasterTexCoord[2]; + params[3] = (GLint) ctx->Current.RasterTexCoord[3]; + break; + case GL_CURRENT_RASTER_POSITION_VALID: + *params = (GLint) ctx->Current.RasterPosValid; + break; + case GL_CURRENT_TEXTURE_COORDS: + params[0] = (GLint) ctx->Current.TexCoord[0]; + params[1] = (GLint) ctx->Current.TexCoord[1]; + params[2] = (GLint) ctx->Current.TexCoord[2]; + params[3] = (GLint) ctx->Current.TexCoord[3]; + break; + case GL_DEPTH_BIAS: + *params = (GLint) ctx->Pixel.DepthBias; + break; + case GL_DEPTH_BITS: + *params = ctx->Visual->DepthBits; + break; + case GL_DEPTH_CLEAR_VALUE: + *params = (GLint) ctx->Depth.Clear; + break; + case GL_DEPTH_FUNC: + *params = (GLint) ctx->Depth.Func; + break; + case GL_DEPTH_RANGE: + params[0] = (GLint) ctx->Viewport.Near; + params[1] = (GLint) ctx->Viewport.Far; + break; + case GL_DEPTH_SCALE: + *params = (GLint) ctx->Pixel.DepthScale; + break; + case GL_DEPTH_TEST: + *params = (GLint) ctx->Depth.Test; + break; + case GL_DEPTH_WRITEMASK: + *params = (GLint) ctx->Depth.Mask; + break; + case GL_DITHER: + *params = (GLint) ctx->Color.DitherFlag; + break; + case GL_DOUBLEBUFFER: + *params = (GLint) ctx->Visual->DBflag; + break; + case GL_DRAW_BUFFER: + *params = (GLint) ctx->Color.DrawBuffer; + break; + case GL_EDGE_FLAG: + *params = (GLint) ctx->Current.EdgeFlag; + break; + case GL_FEEDBACK_BUFFER_SIZE: + /* TODO: is this right? Or, return number of entries in buffer? */ + *params = ctx->Feedback.BufferSize; + break; + case GL_FEEDBACK_BUFFER_TYPE: + *params = ctx->Feedback.Type; + break; + case GL_FOG: + *params = (GLint) ctx->Fog.Enabled; + break; + case GL_FOG_COLOR: + params[0] = FLOAT_TO_INT( ctx->Fog.Color[0] ); + params[1] = FLOAT_TO_INT( ctx->Fog.Color[1] ); + params[2] = FLOAT_TO_INT( ctx->Fog.Color[2] ); + params[3] = FLOAT_TO_INT( ctx->Fog.Color[3] ); + break; + case GL_FOG_DENSITY: + *params = (GLint) ctx->Fog.Density; + break; + case GL_FOG_END: + *params = (GLint) ctx->Fog.End; + break; + case GL_FOG_HINT: + *params = (GLint) ctx->Hint.Fog; + break; + case GL_FOG_INDEX: + *params = (GLint) ctx->Fog.Index; + break; + case GL_FOG_MODE: + *params = (GLint) ctx->Fog.Mode; + break; + case GL_FOG_START: + *params = (GLint) ctx->Fog.Start; + break; + case GL_FRONT_FACE: + *params = (GLint) ctx->Polygon.FrontFace; + break; + case GL_GREEN_BIAS: + *params = (GLint) ctx->Pixel.GreenBias; + break; + case GL_GREEN_BITS: + *params = (GLint) ctx->Visual->GreenBits; + break; + case GL_GREEN_SCALE: + *params = (GLint) ctx->Pixel.GreenScale; + break; + case GL_INDEX_BITS: + *params = (GLint) ctx->Visual->IndexBits; + break; + case GL_INDEX_CLEAR_VALUE: + *params = (GLint) ctx->Color.ClearIndex; + break; + case GL_INDEX_MODE: + *params = ctx->Visual->RGBAflag ? 0 : 1; + break; + case GL_INDEX_OFFSET: + *params = ctx->Pixel.IndexOffset; + break; + case GL_INDEX_SHIFT: + *params = ctx->Pixel.IndexShift; + break; + case GL_INDEX_WRITEMASK: + *params = (GLint) ctx->Color.IndexMask; + break; + case GL_LIGHT0: + case GL_LIGHT1: + case GL_LIGHT2: + case GL_LIGHT3: + case GL_LIGHT4: + case GL_LIGHT5: + case GL_LIGHT6: + case GL_LIGHT7: + *params = (GLint) ctx->Light.Light[pname-GL_LIGHT0].Enabled; + break; + case GL_LIGHTING: + *params = (GLint) ctx->Light.Enabled; + break; + case GL_LIGHT_MODEL_AMBIENT: + params[0] = FLOAT_TO_INT( ctx->Light.Model.Ambient[0] ); + params[1] = FLOAT_TO_INT( ctx->Light.Model.Ambient[1] ); + params[2] = FLOAT_TO_INT( ctx->Light.Model.Ambient[2] ); + params[3] = FLOAT_TO_INT( ctx->Light.Model.Ambient[3] ); + break; + case GL_LIGHT_MODEL_LOCAL_VIEWER: + *params = (GLint) ctx->Light.Model.LocalViewer; + break; + case GL_LIGHT_MODEL_TWO_SIDE: + *params = (GLint) ctx->Light.Model.TwoSide; + break; + case GL_LINE_SMOOTH: + *params = (GLint) ctx->Line.SmoothFlag; + break; + case GL_LINE_SMOOTH_HINT: + *params = (GLint) ctx->Hint.LineSmooth; + break; + case GL_LINE_STIPPLE: + *params = (GLint) ctx->Line.StippleFlag; + break; + case GL_LINE_STIPPLE_PATTERN: + *params = (GLint) ctx->Line.StipplePattern; + break; + case GL_LINE_STIPPLE_REPEAT: + *params = (GLint) ctx->Line.StippleFactor; + break; + case GL_LINE_WIDTH: + *params = (GLint) ctx->Line.Width; + break; + case GL_LINE_WIDTH_GRANULARITY: + *params = (GLint) LINE_WIDTH_GRANULARITY; + break; + case GL_LINE_WIDTH_RANGE: + params[0] = (GLint) MIN_LINE_WIDTH; + params[1] = (GLint) MAX_LINE_WIDTH; + break; + case GL_LIST_BASE: + *params = (GLint) ctx->List.ListBase; + break; + case GL_LIST_INDEX: + *params = (GLint) ctx->CurrentListNum; + break; + case GL_LIST_MODE: + *params = ctx->ExecuteFlag ? (GLint) GL_COMPILE_AND_EXECUTE + : (GLint) GL_COMPILE; + break; + case GL_INDEX_LOGIC_OP: + *params = (GLint) ctx->Color.IndexLogicOpEnabled; + break; + case GL_COLOR_LOGIC_OP: + *params = (GLint) ctx->Color.ColorLogicOpEnabled; + break; + case GL_LOGIC_OP_MODE: + *params = (GLint) ctx->Color.LogicOp; + break; + case GL_MAP1_COLOR_4: + *params = (GLint) ctx->Eval.Map1Color4; + break; + case GL_MAP1_GRID_DOMAIN: + params[0] = (GLint) ctx->Eval.MapGrid1u1; + params[1] = (GLint) ctx->Eval.MapGrid1u2; + break; + case GL_MAP1_GRID_SEGMENTS: + *params = (GLint) ctx->Eval.MapGrid1un; + break; + case GL_MAP1_INDEX: + *params = (GLint) ctx->Eval.Map1Index; + break; + case GL_MAP1_NORMAL: + *params = (GLint) ctx->Eval.Map1Normal; + break; + case GL_MAP1_TEXTURE_COORD_1: + *params = (GLint) ctx->Eval.Map1TextureCoord1; + break; + case GL_MAP1_TEXTURE_COORD_2: + *params = (GLint) ctx->Eval.Map1TextureCoord2; + break; + case GL_MAP1_TEXTURE_COORD_3: + *params = (GLint) ctx->Eval.Map1TextureCoord3; + break; + case GL_MAP1_TEXTURE_COORD_4: + *params = (GLint) ctx->Eval.Map1TextureCoord4; + break; + case GL_MAP1_VERTEX_3: + *params = (GLint) ctx->Eval.Map1Vertex3; + break; + case GL_MAP1_VERTEX_4: + *params = (GLint) ctx->Eval.Map1Vertex4; + break; + case GL_MAP2_COLOR_4: + *params = (GLint) ctx->Eval.Map2Color4; + break; + case GL_MAP2_GRID_DOMAIN: + params[0] = (GLint) ctx->Eval.MapGrid2u1; + params[1] = (GLint) ctx->Eval.MapGrid2u2; + params[2] = (GLint) ctx->Eval.MapGrid2v1; + params[3] = (GLint) ctx->Eval.MapGrid2v2; + break; + case GL_MAP2_GRID_SEGMENTS: + params[0] = (GLint) ctx->Eval.MapGrid2un; + params[1] = (GLint) ctx->Eval.MapGrid2vn; + break; + case GL_MAP2_INDEX: + *params = (GLint) ctx->Eval.Map2Index; + break; + case GL_MAP2_NORMAL: + *params = (GLint) ctx->Eval.Map2Normal; + break; + case GL_MAP2_TEXTURE_COORD_1: + *params = (GLint) ctx->Eval.Map2TextureCoord1; + break; + case GL_MAP2_TEXTURE_COORD_2: + *params = (GLint) ctx->Eval.Map2TextureCoord2; + break; + case GL_MAP2_TEXTURE_COORD_3: + *params = (GLint) ctx->Eval.Map2TextureCoord3; + break; + case GL_MAP2_TEXTURE_COORD_4: + *params = (GLint) ctx->Eval.Map2TextureCoord4; + break; + case GL_MAP2_VERTEX_3: + *params = (GLint) ctx->Eval.Map2Vertex3; + break; + case GL_MAP2_VERTEX_4: + *params = (GLint) ctx->Eval.Map2Vertex4; + break; + case GL_MAP_COLOR: + *params = (GLint) ctx->Pixel.MapColorFlag; + break; + case GL_MAP_STENCIL: + *params = (GLint) ctx->Pixel.MapStencilFlag; + break; + case GL_MATRIX_MODE: + *params = (GLint) ctx->Transform.MatrixMode; + break; + case GL_MAX_ATTRIB_STACK_DEPTH: + *params = (GLint) MAX_ATTRIB_STACK_DEPTH; + break; + case GL_MAX_CLIENT_ATTRIB_STACK_DEPTH: + *params = (GLint) MAX_CLIENT_ATTRIB_STACK_DEPTH; + break; + case GL_MAX_CLIP_PLANES: + *params = (GLint) MAX_CLIP_PLANES; + break; + case GL_MAX_EVAL_ORDER: + *params = (GLint) MAX_EVAL_ORDER; + break; + case GL_MAX_LIGHTS: + *params = (GLint) MAX_LIGHTS; + break; + case GL_MAX_LIST_NESTING: + *params = (GLint) MAX_LIST_NESTING; + break; + case GL_MAX_MODELVIEW_STACK_DEPTH: + *params = (GLint) MAX_MODELVIEW_STACK_DEPTH; + break; + case GL_MAX_NAME_STACK_DEPTH: + *params = (GLint) MAX_NAME_STACK_DEPTH; + break; + case GL_MAX_PIXEL_MAP_TABLE: + *params = (GLint) MAX_PIXEL_MAP_TABLE; + break; + case GL_MAX_PROJECTION_STACK_DEPTH: + *params = (GLint) MAX_PROJECTION_STACK_DEPTH; + break; + case GL_MAX_TEXTURE_SIZE: + *params = (GLint) MAX_TEXTURE_SIZE; + break; + case GL_MAX_TEXTURE_STACK_DEPTH: + *params = (GLint) MAX_TEXTURE_STACK_DEPTH; + break; + case GL_MAX_VIEWPORT_DIMS: + params[0] = (GLint) MAX_WIDTH; + params[1] = (GLint) MAX_HEIGHT; + break; + case GL_MODELVIEW_MATRIX: + for (i=0;i<16;i++) { + params[i] = (GLint) ctx->ModelViewMatrix[i]; + } + break; + case GL_MODELVIEW_STACK_DEPTH: + *params = (GLint) ctx->ModelViewStackDepth; + break; + case GL_NAME_STACK_DEPTH: + *params = (GLint) ctx->Select.NameStackDepth; + break; + case GL_NORMALIZE: + *params = (GLint) ctx->Transform.Normalize; + break; + case GL_PACK_ALIGNMENT: + *params = ctx->Pack.Alignment; + break; + case GL_PACK_LSB_FIRST: + *params = (GLint) ctx->Pack.LsbFirst; + break; + case GL_PACK_ROW_LENGTH: + *params = ctx->Pack.RowLength; + break; + case GL_PACK_SKIP_PIXELS: + *params = ctx->Pack.SkipPixels; + break; + case GL_PACK_SKIP_ROWS: + *params = ctx->Pack.SkipRows; + break; + case GL_PACK_SWAP_BYTES: + *params = (GLint) ctx->Pack.SwapBytes; + break; + case GL_PERSPECTIVE_CORRECTION_HINT: + *params = (GLint) ctx->Hint.PerspectiveCorrection; + break; + case GL_PIXEL_MAP_A_TO_A_SIZE: + *params = ctx->Pixel.MapAtoAsize; + break; + case GL_PIXEL_MAP_B_TO_B_SIZE: + *params = ctx->Pixel.MapBtoBsize; + break; + case GL_PIXEL_MAP_G_TO_G_SIZE: + *params = ctx->Pixel.MapGtoGsize; + break; + case GL_PIXEL_MAP_I_TO_A_SIZE: + *params = ctx->Pixel.MapItoAsize; + break; + case GL_PIXEL_MAP_I_TO_B_SIZE: + *params = ctx->Pixel.MapItoBsize; + break; + case GL_PIXEL_MAP_I_TO_G_SIZE: + *params = ctx->Pixel.MapItoGsize; + break; + case GL_PIXEL_MAP_I_TO_I_SIZE: + *params = ctx->Pixel.MapItoIsize; + break; + case GL_PIXEL_MAP_I_TO_R_SIZE: + *params = ctx->Pixel.MapItoRsize; + break; + case GL_PIXEL_MAP_R_TO_R_SIZE: + *params = ctx->Pixel.MapRtoRsize; + break; + case GL_PIXEL_MAP_S_TO_S_SIZE: + *params = ctx->Pixel.MapStoSsize; + break; + case GL_POINT_SIZE: + *params = (GLint) ctx->Point.Size; + break; + case GL_POINT_SIZE_GRANULARITY: + *params = (GLint) POINT_SIZE_GRANULARITY; + break; + case GL_POINT_SIZE_RANGE: + params[0] = (GLint) MIN_POINT_SIZE; + params[1] = (GLint) MAX_POINT_SIZE; + break; + case GL_POINT_SMOOTH: + *params = (GLint) ctx->Point.SmoothFlag; + break; + case GL_POINT_SMOOTH_HINT: + *params = (GLint) ctx->Hint.PointSmooth; + break; + case GL_POLYGON_MODE: + params[0] = (GLint) ctx->Polygon.FrontMode; + params[1] = (GLint) ctx->Polygon.BackMode; + break; +#ifdef GL_EXT_polygon_offset + case GL_POLYGON_OFFSET_BIAS_EXT: + *params = (GLint) ctx->Polygon.OffsetUnits; + break; +#endif + case GL_POLYGON_OFFSET_FACTOR: + *params = (GLint) ctx->Polygon.OffsetFactor; + break; + case GL_POLYGON_OFFSET_UNITS: + *params = (GLint) ctx->Polygon.OffsetUnits; + break; + case GL_POLYGON_SMOOTH: + *params = (GLint) ctx->Polygon.SmoothFlag; + break; + case GL_POLYGON_SMOOTH_HINT: + *params = (GLint) ctx->Hint.PolygonSmooth; + break; + case GL_POLYGON_STIPPLE: + for (i=0;i<32;i++) { /* RIGHT? */ + params[i] = (GLint) ctx->PolygonStipple[i]; + } + break; + case GL_PROJECTION_MATRIX: + for (i=0;i<16;i++) { + params[i] = (GLint) ctx->ProjectionMatrix[i]; + } + break; + case GL_PROJECTION_STACK_DEPTH: + *params = (GLint) ctx->ProjectionStackDepth; + break; + case GL_READ_BUFFER: + *params = (GLint) ctx->Pixel.ReadBuffer; + break; + case GL_RED_BIAS: + *params = (GLint) ctx->Pixel.RedBias; + break; + case GL_RED_BITS: + *params = (GLint) ctx->Visual->RedBits; + break; + case GL_RED_SCALE: + *params = (GLint) ctx->Pixel.RedScale; + break; + case GL_RENDER_MODE: + *params = (GLint) ctx->RenderMode; + break; + case GL_RGBA_MODE: + *params = (GLint) ctx->Visual->RGBAflag; + break; + case GL_SCISSOR_BOX: + params[0] = (GLint) ctx->Scissor.X; + params[1] = (GLint) ctx->Scissor.Y; + params[2] = (GLint) ctx->Scissor.Width; + params[3] = (GLint) ctx->Scissor.Height; + break; + case GL_SCISSOR_TEST: + *params = (GLint) ctx->Scissor.Enabled; + break; + case GL_SHADE_MODEL: + *params = (GLint) ctx->Light.ShadeModel; + break; + case GL_STENCIL_BITS: + *params = ctx->Visual->StencilBits; + break; + case GL_STENCIL_CLEAR_VALUE: + *params = (GLint) ctx->Stencil.Clear; + break; + case GL_STENCIL_FAIL: + *params = (GLint) ctx->Stencil.FailFunc; + break; + case GL_STENCIL_FUNC: + *params = (GLint) ctx->Stencil.Function; + break; + case GL_STENCIL_PASS_DEPTH_FAIL: + *params = (GLint) ctx->Stencil.ZFailFunc; + break; + case GL_STENCIL_PASS_DEPTH_PASS: + *params = (GLint) ctx->Stencil.ZPassFunc; + break; + case GL_STENCIL_REF: + *params = (GLint) ctx->Stencil.Ref; + break; + case GL_STENCIL_TEST: + *params = (GLint) ctx->Stencil.Enabled; + break; + case GL_STENCIL_VALUE_MASK: + *params = (GLint) ctx->Stencil.ValueMask; + break; + case GL_STENCIL_WRITEMASK: + *params = (GLint) ctx->Stencil.WriteMask; + break; + case GL_STEREO: + *params = 0; /* TODO */ + break; + case GL_SUBPIXEL_BITS: + *params = 0; /* TODO */ + break; + case GL_TEXTURE_1D: + *params = (ctx->Texture.Enabled & TEXTURE_1D) ? 1.0 : 0.0; + break; + case GL_TEXTURE_2D: + *params = (ctx->Texture.Enabled & TEXTURE_2D) ? 1.0 : 0.0; + break; + case GL_TEXTURE_ENV_COLOR: + params[0] = FLOAT_TO_INT( ctx->Texture.EnvColor[0] ); + params[1] = FLOAT_TO_INT( ctx->Texture.EnvColor[1] ); + params[2] = FLOAT_TO_INT( ctx->Texture.EnvColor[2] ); + params[3] = FLOAT_TO_INT( ctx->Texture.EnvColor[3] ); + break; + case GL_TEXTURE_ENV_MODE: + *params = (GLint) ctx->Texture.EnvMode; + break; + case GL_TEXTURE_GEN_S: + *params = (ctx->Texture.TexGenEnabled & S_BIT) ? 1 : 0; + break; + case GL_TEXTURE_GEN_T: + *params = (ctx->Texture.TexGenEnabled & T_BIT) ? 1 : 0; + break; + case GL_TEXTURE_GEN_R: + *params = (ctx->Texture.TexGenEnabled & R_BIT) ? 1 : 0; + break; + case GL_TEXTURE_GEN_Q: + *params = (ctx->Texture.TexGenEnabled & Q_BIT) ? 1 : 0; + break; + case GL_TEXTURE_MATRIX: + for (i=0;i<16;i++) { + params[i] = (GLint) ctx->TextureMatrix[i]; + } + break; + case GL_TEXTURE_STACK_DEPTH: + *params = (GLint) ctx->TextureStackDepth; + break; + case GL_UNPACK_ALIGNMENT: + *params = ctx->Unpack.Alignment; + break; + case GL_UNPACK_LSB_FIRST: + *params = (GLint) ctx->Unpack.LsbFirst; + break; + case GL_UNPACK_ROW_LENGTH: + *params = ctx->Unpack.RowLength; + break; + case GL_UNPACK_SKIP_PIXELS: + *params = ctx->Unpack.SkipPixels; + break; + case GL_UNPACK_SKIP_ROWS: + *params = ctx->Unpack.SkipRows; + break; + case GL_UNPACK_SWAP_BYTES: + *params = (GLint) ctx->Unpack.SwapBytes; + break; + case GL_VIEWPORT: + params[0] = (GLint) ctx->Viewport.X; + params[1] = (GLint) ctx->Viewport.Y; + params[2] = (GLint) ctx->Viewport.Width; + params[3] = (GLint) ctx->Viewport.Height; + break; + case GL_ZOOM_X: + *params = (GLint) ctx->Pixel.ZoomX; + break; + case GL_ZOOM_Y: + *params = (GLint) ctx->Pixel.ZoomY; + break; + case GL_VERTEX_ARRAY_SIZE: + *params = ctx->Array.VertexSize; + break; + case GL_VERTEX_ARRAY_TYPE: + *params = ctx->Array.VertexType; + break; + case GL_VERTEX_ARRAY_STRIDE: + *params = ctx->Array.VertexStride; + break; + case GL_VERTEX_ARRAY_COUNT_EXT: + *params = 0; + break; + case GL_NORMAL_ARRAY_TYPE: + *params = ctx->Array.NormalType; + break; + case GL_NORMAL_ARRAY_STRIDE: + *params = ctx->Array.NormalStride; + break; + case GL_NORMAL_ARRAY_COUNT_EXT: + *params = 0; + break; + case GL_COLOR_ARRAY_SIZE: + *params = ctx->Array.ColorSize; + break; + case GL_COLOR_ARRAY_TYPE: + *params = ctx->Array.ColorType; + break; + case GL_COLOR_ARRAY_STRIDE: + *params = ctx->Array.ColorStride; + break; + case GL_COLOR_ARRAY_COUNT_EXT: + *params = 0; + break; + case GL_INDEX_ARRAY_TYPE: + *params = ctx->Array.IndexType; + break; + case GL_INDEX_ARRAY_STRIDE: + *params = ctx->Array.IndexStride; + break; + case GL_INDEX_ARRAY_COUNT_EXT: + *params = 0; + break; + case GL_TEXTURE_COORD_ARRAY_SIZE: + *params = ctx->Array.TexCoordSize; + break; + case GL_TEXTURE_COORD_ARRAY_TYPE: + *params = ctx->Array.TexCoordType; + break; + case GL_TEXTURE_COORD_ARRAY_STRIDE: + *params = ctx->Array.TexCoordStride; + break; + case GL_TEXTURE_COORD_ARRAY_COUNT_EXT: + *params = 0; + break; + case GL_EDGE_FLAG_ARRAY_STRIDE: + *params = ctx->Array.EdgeFlagStride; + break; + case GL_EDGE_FLAG_ARRAY_COUNT_EXT: + *params = 0; + break; + case GL_TEXTURE_BINDING_1D: + *params = ctx->Texture.Current1D->Name; + break; + case GL_TEXTURE_BINDING_2D: + *params = ctx->Texture.Current2D->Name; + break; + + default: + gl_error( ctx, GL_INVALID_ENUM, "glGetIntegerv" ); + } +} + + + +void gl_GetPointerv( GLcontext *ctx, GLenum pname, GLvoid **params ) +{ + switch (pname) { + case GL_VERTEX_ARRAY_POINTER: + *params = ctx->Array.VertexPtr; + break; + case GL_NORMAL_ARRAY_POINTER: + *params = ctx->Array.NormalPtr; + break; + case GL_COLOR_ARRAY_POINTER: + *params = ctx->Array.ColorPtr; + break; + case GL_INDEX_ARRAY_POINTER: + *params = ctx->Array.IndexPtr; + break; + case GL_TEXTURE_COORD_ARRAY_POINTER: + *params = ctx->Array.TexCoordPtr; + break; + case GL_EDGE_FLAG_ARRAY_POINTER: + *params = ctx->Array.EdgeFlagPtr; + break; + case GL_FEEDBACK_BUFFER_POINTER: + *params = ctx->Feedback.Buffer; + break; + default: + gl_error( ctx, GL_INVALID_ENUM, "glGetPointerv" ); + return; + } +} diff --git a/dll/opengl/mesa/get.h b/dll/opengl/mesa/get.h new file mode 100644 index 00000000000..f1bd98dd270 --- /dev/null +++ b/dll/opengl/mesa/get.h @@ -0,0 +1,49 @@ +/* $Id: get.h,v 1.1 1996/09/13 01:38:16 brianp Exp $ */ + +/* + * Mesa 3-D graphics library + * Version: 2.0 + * Copyright (C) 1995-1996 Brian Paul + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Library General Public + * License as published by the Free Software Foundation; either + * version 2 of the License, or (at your option) any later version. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Library General Public License for more details. + * + * You should have received a copy of the GNU Library General Public + * License along with this library; if not, write to the Free + * Software Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. + */ + + +/* + * $Log: get.h,v $ + * Revision 1.1 1996/09/13 01:38:16 brianp + * Initial revision + * + */ + + +#ifndef GET_H +#define GET_H + + +#include "types.h" + + +extern void gl_GetBooleanv( GLcontext *ctx, GLenum pname, GLboolean *params ); + +extern void gl_GetDoublev( GLcontext *ctx, GLenum pname, GLdouble *params ); + +extern void gl_GetFloatv( GLcontext *ctx, GLenum pname, GLfloat *params ); + +extern void gl_GetIntegerv( GLcontext *ctx, GLenum pname, GLint *params ); + + +#endif + diff --git a/dll/opengl/mesa/hash.c b/dll/opengl/mesa/hash.c new file mode 100644 index 00000000000..4bae7f25630 --- /dev/null +++ b/dll/opengl/mesa/hash.c @@ -0,0 +1,302 @@ +/* $Id: hash.c,v 1.4 1998/02/07 14:25:12 brianp Exp $ */ + +/* + * Mesa 3-D graphics library + * Version: 2.5 + * Copyright (C) 1995-1997 Brian Paul + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Library General Public + * License as published by the Free Software Foundation; either + * version 2 of the License, or (at your option) any later version. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Library General Public License for more details. + * + * You should have received a copy of the GNU Library General Public + * License along with this library; if not, write to the Free + * Software Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. + */ + + +/* + * $Log: hash.c,v $ + * Revision 1.4 1998/02/07 14:25:12 brianp + * fixed small Sun compiler warning (John Stone) + * + * Revision 1.3 1997/09/22 02:33:07 brianp + * added HashRemove() and HashFirstEntry() + * + * Revision 1.2 1997/09/03 13:13:45 brianp + * added a few pointer casts + * + * Revision 1.1 1997/08/22 01:15:10 brianp + * Initial revision + * + */ + + +#ifdef PC_HEADER +#include "all.h" +#else +#include +#include +#include +#include "hash.h" +#endif + + +/* + * Generic hash table. Only dependency is the GLuint datatype. + * + * This is used to implement display list and texture object lookup. + * NOTE: key=0 is illegal. + */ + + +#define TABLE_SIZE 1001 + +struct HashEntry { + GLuint Key; + void *Data; + struct HashEntry *Next; +}; + +struct HashTable { + struct HashEntry *Table[TABLE_SIZE]; + GLuint MaxKey; +}; + + + +/* + * Return pointer to a new, empty hash table. + */ +struct HashTable *NewHashTable(void) +{ + return (struct HashTable *) calloc(sizeof (struct HashTable), 1); +} + + + +/* + * Delete a hash table. + */ +void DeleteHashTable(struct HashTable *table) +{ + GLuint i; + assert(table); + for (i=0;iTable[i]; + while (entry) { + struct HashEntry *next = entry->Next; + free(entry); + entry = next; + } + } + free(table); +} + + + +/* + * Lookup an entry in the hash table. + * Input: table - the hash table + * key - the key + * Return: user data pointer or NULL if key not in table + */ +void *HashLookup(const struct HashTable *table, GLuint key) +{ + GLuint pos; + struct HashEntry *entry; + + assert(table); + assert(key); + + pos = key % TABLE_SIZE; + entry = table->Table[pos]; + while (entry) { + if (entry->Key == key) { + return entry->Data; + } + entry = entry->Next; + } + return NULL; +} + + + +/* + * Insert into the hash table. If an entry with this key already exists + * we'll replace the existing entry. + * Input: table - the hash table + * key - the key (not zero) + * data - pointer to user data + */ +void HashInsert(struct HashTable *table, GLuint key, void *data) +{ + /* search for existing entry with this key */ + GLuint pos; + struct HashEntry *entry; + + assert(table); + assert(key); + + if (key > table->MaxKey) + table->MaxKey = key; + + pos = key % TABLE_SIZE; + entry = table->Table[pos]; + while (entry) { + if (entry->Key == key) { + /* replace entry's data */ + entry->Data = data; + return; + } + entry = entry->Next; + } + + /* alloc and insert new table entry */ + entry = (struct HashEntry *) calloc(sizeof(struct HashEntry), 1); + entry->Key = key; + entry->Data = data; + entry->Next = table->Table[pos]; + table->Table[pos] = entry; +} + + + +/* + * Remove an entry from the hash table. + * Input: table - the hash table + * key - key of entry to remove + */ +void HashRemove(struct HashTable *table, GLuint key) +{ + GLuint pos; + struct HashEntry *entry, *prev; + + assert(table); + assert(key); + + pos = key % TABLE_SIZE; + prev = NULL; + entry = table->Table[pos]; + while (entry) { + if (entry->Key == key) { + /* found it! */ + if (prev) { + prev->Next = entry->Next; + } + else { + table->Table[pos] = entry->Next; + } + free(entry); + return; + } + prev = entry; + entry = entry->Next; + } +} + + + +/* + * Return the key of the "first" entry in the hash table. + * By calling this function until zero is returned we can get + * the keys of all entries in the table. + */ +GLuint HashFirstEntry(const struct HashTable *table) +{ + GLuint pos; + assert(table); + for (pos=0; pos < TABLE_SIZE; pos++) { + if (table->Table[pos]) + return table->Table[pos]->Key; + } + return 0; +} + + + +/* + * Dump contents of hash table for debugging. + */ +void HashPrint(const struct HashTable *table) +{ + GLuint i; + assert(table); + for (i=0;iTable[i]; + while (entry) { + printf("%u %p\n", entry->Key, entry->Data); + entry = entry->Next; + } + } +} + + + +/* + * Find a block of 'numKeys' adjacent unused hash keys. + * Input: table - the hash table + * numKeys - number of keys needed + * Return: startint key of free block or 0 if failure + */ +GLuint HashFindFreeKeyBlock(const struct HashTable *table, GLuint numKeys) +{ + GLuint maxKey = ~((GLuint) 0); + if (maxKey - numKeys > table->MaxKey) { + /* the quick solution */ + return table->MaxKey + 1; + } + else { + /* the slow solution */ + GLuint freeCount = 0; + GLuint freeStart = 0; + GLuint key; + for (key=0; key!=maxKey; key++) { + if (HashLookup(table, key)) { + /* darn, this key is already in use */ + freeCount = 0; + freeStart = key+1; + } + else { + /* this key not in use, check if we've found enough */ + freeCount++; + if (freeCount == numKeys) { + return freeStart; + } + } + } + /* cannot allocate a block of numKeys consecutive keys */ + return 0; + } +} + + + +#ifdef HASH_TEST_HARNESS +int main(int argc, char *argv[]) +{ + int a, b, c; + struct HashTable *t; + + printf("&a = %p\n", &a); + printf("&b = %p\n", &b); + + t = NewHashTable(); + HashInsert(t, 501, &a); + HashInsert(t, 10, &c); + HashInsert(t, 0xfffffff8, &b); + HashPrint(t); + printf("Find 501: %p\n", HashLookup(t,501)); + printf("Find 1313: %p\n", HashLookup(t,1313)); + printf("Find block of 100: %d\n", HashFindFreeKeyBlock(t, 100)); + DeleteHashTable(t); + + return 0; +} +#endif diff --git a/dll/opengl/mesa/hash.h b/dll/opengl/mesa/hash.h new file mode 100644 index 00000000000..487ac544396 --- /dev/null +++ b/dll/opengl/mesa/hash.h @@ -0,0 +1,63 @@ +/* $Id: hash.h,v 1.2 1997/09/22 02:33:07 brianp Exp $ */ + +/* + * Mesa 3-D graphics library + * Version: 2.5 + * Copyright (C) 1995-1997 Brian Paul + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Library General Public + * License as published by the Free Software Foundation; either + * version 2 of the License, or (at your option) any later version. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Library General Public License for more details. + * + * You should have received a copy of the GNU Library General Public + * License along with this library; if not, write to the Free + * Software Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. + */ + + +/* + * $Log: hash.h,v $ + * Revision 1.2 1997/09/22 02:33:07 brianp + * added HashRemove() and HashFirstEntry() + * + * Revision 1.1 1997/08/22 01:15:10 brianp + * Initial revision + * + */ + + +#ifndef HASH_H +#define HASH_H + + +#include "GL/gl.h" + + +struct HashTable; + + + +extern struct HashTable *NewHashTable(void); + +extern void DeleteHashTable(struct HashTable *table); + +extern void *HashLookup(const struct HashTable *table, GLuint key); + +extern void HashInsert(struct HashTable *table, GLuint key, void *data); + +extern void HashRemove(struct HashTable *table, GLuint key); + +extern GLuint HashFirstEntry(const struct HashTable *table); + +extern void HashPrint(const struct HashTable *table); + +extern GLuint HashFindFreeKeyBlock(const struct HashTable *table, GLuint numKeys); + + +#endif diff --git a/dll/opengl/mesa/image.c b/dll/opengl/mesa/image.c new file mode 100644 index 00000000000..fe381e029a2 --- /dev/null +++ b/dll/opengl/mesa/image.c @@ -0,0 +1,667 @@ +/* $Id: image.c,v 1.19 1997/11/07 03:49:04 brianp Exp $ */ + +/* + * Mesa 3-D graphics library + * Version: 2.5 + * Copyright (C) 1995-1997 Brian Paul + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Library General Public + * License as published by the Free Software Foundation; either + * version 2 of the License, or (at your option) any later version. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Library General Public License for more details. + * + * You should have received a copy of the GNU Library General Public + * License along with this library; if not, write to the Free + * Software Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. + */ + + +/* + * $Log: image.c,v $ + * Revision 1.19 1997/11/07 03:49:04 brianp + * more error checking work (but more to be done) + * + * Revision 1.18 1997/11/02 20:19:47 brianp + * added more error checking to gl_unpack_image3D() + * + * Revision 1.17 1997/10/16 01:04:51 brianp + * added code to normalize color, depth values in gl_unpack_image3d() + * + * Revision 1.16 1997/09/27 00:15:39 brianp + * changed parameters to gl_unpack_image() + * + * Revision 1.15 1997/08/11 01:23:10 brianp + * added a pointer cast + * + * Revision 1.14 1997/07/24 01:25:18 brianp + * changed precompiled header symbol from PCH to PC_HEADER + * + * Revision 1.13 1997/05/28 03:25:26 brianp + * added precompiled header (PCH) support + * + * Revision 1.12 1997/04/29 01:26:25 brianp + * added #include "context.h" + * + * Revision 1.11 1997/04/20 20:28:49 brianp + * replaced abort() with gl_problem() + * + * Revision 1.10 1997/04/06 17:49:32 brianp + * image reference count wasn't always initialized to zero (Christopher Lloyd) + * + * Revision 1.9 1997/02/09 20:05:03 brianp + * new arguments for gl_pixel_addr_in_image() + * + * Revision 1.8 1997/02/09 18:52:53 brianp + * added GL_EXT_texture3D support + * + * Revision 1.7 1997/01/09 21:25:54 brianp + * initialize image reference count to zero + * + * Revision 1.6 1996/11/13 03:58:31 brianp + * fixed undefined "format" variable in gl_unpack_image() + * + * Revision 1.5 1996/11/10 17:48:03 brianp + * check if format is GL_DEPTH_COMPONENT or GL_STENCIL_COMPONENT + * + * Revision 1.4 1996/11/06 04:23:01 brianp + * changed gl_unpack_image() components argument to srcFormat + * + * Revision 1.3 1996/09/27 01:27:10 brianp + * removed unused variables + * + * Revision 1.2 1996/09/26 22:35:10 brianp + * fixed a few compiler warnings from IRIX 6 -n32 and -64 compiler + * + * Revision 1.1 1996/09/13 01:38:16 brianp + * Initial revision + * + */ + + +#ifdef PC_HEADER +#include "all.h" +#else +#include +#include +#include +#include +#include "context.h" +#include "image.h" +#include "macros.h" +#include "pixel.h" +#include "types.h" +#endif + + + +/* + * Flip the 8 bits in each byte of the given array. + */ +void gl_flip_bytes( GLubyte *p, GLuint n ) +{ + register GLuint i, a, b; + + for (i=0;i> 1) | + ((b & 0x20) >> 3) | + ((b & 0x40) >> 5) | + ((b & 0x80) >> 7); + p[i] = (GLubyte) a; + } +} + + +/* + * Flip the order of the 2 bytes in each word in the given array. + */ +void gl_swap2( GLushort *p, GLuint n ) +{ + register GLuint i; + + for (i=0;i> 8) | ((p[i] << 8) & 0xff00); + } +} + + + +/* + * Flip the order of the 4 bytes in each word in the given array. + */ +void gl_swap4( GLuint *p, GLuint n ) +{ + register GLuint i, a, b; + + for (i=0;i> 24) + | ((b >> 8) & 0xff00) + | ((b << 8) & 0xff0000) + | ((b << 24) & 0xff000000); + p[i] = a; + } +} + + + + +/* + * Return the size, in bytes, of the given GL datatype. + * Return 0 if GL_BITMAP. + * Return -1 if invalid type enum. + */ +GLint gl_sizeof_type( GLenum type ) +{ + switch (type) { + case GL_BITMAP: + return 0; + case GL_UNSIGNED_BYTE: + return sizeof(GLubyte); + case GL_BYTE: + return sizeof(GLbyte); + case GL_UNSIGNED_SHORT: + return sizeof(GLushort); + case GL_SHORT: + return sizeof(GLshort); + case GL_UNSIGNED_INT: + return sizeof(GLuint); + case GL_INT: + return sizeof(GLint); + case GL_FLOAT: + return sizeof(GLfloat); + default: + return -1; + } +} + + + +/* + * Return the number of components in a GL enum pixel type. + * Return -1 if bad format. + */ +GLint gl_components_in_format( GLenum format ) +{ + switch (format) { + case GL_COLOR_INDEX: + case GL_STENCIL_INDEX: + case GL_DEPTH_COMPONENT: + case GL_RED: + case GL_GREEN: + case GL_BLUE: + case GL_ALPHA: + case GL_LUMINANCE: + return 1; + case GL_LUMINANCE_ALPHA: + return 2; + case GL_RGB: + case GL_BGR_EXT: + return 3; + case GL_RGBA: + case GL_BGRA_EXT: + return 4; + default: + return -1; + } +} + + +/* + * Return the address of a pixel in an image (actually a volume). + * Pixel unpacking/packing parameters are observed according to 'packing'. + * Input: image - start of image data + * width, height - size of image + * format - image format + * type - pixel component type + * packing - GL_TRUE = use packing params + * GL_FALSE = use unpacking params. + * img - which image in the volume (0 for 2-D images) + * row, column - location of pixel in the image + * Return: address of pixel at (image,row,column) in image or NULL if error. + */ +GLvoid *gl_pixel_addr_in_image( struct gl_pixelstore_attrib *packing, + const GLvoid *image, GLsizei width, + GLsizei height, GLenum format, GLenum type, + GLint row) +{ + GLint bytes_per_comp; /* bytes per component */ + GLint comp_per_pixel; /* components per pixel */ + GLint comps_per_row; /* components per row */ + GLint pixels_per_row; /* pixels per row */ + GLint alignment; /* 1, 2 or 4 */ + GLint skiprows; + GLint skippixels; + GLubyte *pixel_addr; + + /* Compute bytes per component */ + bytes_per_comp = gl_sizeof_type( type ); + if (bytes_per_comp<0) { + return NULL; + } + + /* Compute number of components per pixel */ + comp_per_pixel = gl_components_in_format( format ); + if (comp_per_pixel<0) { + return NULL; + } + + alignment = packing->Alignment; + if (packing->RowLength>0) { + pixels_per_row = packing->RowLength; + } + else { + pixels_per_row = width; + } + skiprows = packing->SkipRows; + skippixels = packing->SkipPixels; + + if (type==GL_BITMAP) { + /* BITMAP data */ + GLint bytes_per_row; + + bytes_per_row = alignment + * CEILING( comp_per_pixel*pixels_per_row, 8*alignment ); + + pixel_addr = (GLubyte *) image + + (skiprows + row) * bytes_per_row + + (skippixels) / 8; + } + else { + /* Non-BITMAP data */ + + if (bytes_per_comp>=alignment) { + comps_per_row = comp_per_pixel * pixels_per_row; + } + else { + GLint bytes_per_row = bytes_per_comp * comp_per_pixel + * pixels_per_row; + + comps_per_row = alignment / bytes_per_comp + * CEILING( bytes_per_row, alignment ); + } + + /* Copy/unpack pixel data to buffer */ + pixel_addr = (GLubyte *) image + + (skiprows + row) * bytes_per_comp * comps_per_row + + (skippixels) * bytes_per_comp * comp_per_pixel; + } + + return (GLvoid *) pixel_addr; +} + + + +/* + * Unpack a 2-D image from user-supplied address, returning a pointer to + * a new gl_image struct. + * + * Input: width, height - size in pixels + * srcFormat - format of incoming pixel data, ignored if + * srcType BITMAP. + * srcType - GL_UNSIGNED_BYTE .. GL_FLOAT + * pixels - pointer to unpacked image in client memory space. + */ +struct gl_image *gl_unpack_image( GLcontext *ctx, + GLint width, GLint height, + GLenum srcFormat, GLenum srcType, + const GLvoid *pixels ) +{ + GLint components; + GLenum destType; + + if (srcType==GL_UNSIGNED_BYTE) { + destType = GL_UNSIGNED_BYTE; + } + else if (srcType==GL_BITMAP) { + destType = GL_BITMAP; + } + else { + destType = GL_FLOAT; + } + + components = gl_components_in_format( srcFormat ); + + if (components < 0) + return NULL; + + if (srcType==GL_BITMAP || destType==GL_BITMAP) { + struct gl_image *image; + GLint bytes, i, width_in_bytes; + GLubyte *buffer, *dst; + assert( srcType==GL_BITMAP ); + assert( destType==GL_BITMAP ); + + /* Alloc dest storage */ + if (width > 0 && height > 0) + bytes = ((width+7)/8 * height); + else + bytes = 0; + if (bytes>0 && pixels!=NULL) { + buffer = (GLubyte *) malloc( bytes ); + if (!buffer) { + return NULL; + } + /* Copy/unpack pixel data to buffer */ + width_in_bytes = CEILING( width, 8 ); + dst = buffer; + for (i=0; iUnpack, pixels, + width, height, + GL_COLOR_INDEX, srcType, + i); + if (!src) { + free(buffer); + return NULL; + } + MEMCPY( dst, src, width_in_bytes ); + dst += width_in_bytes; + } + /* Bit flipping */ + if (ctx->Unpack.LsbFirst) { + gl_flip_bytes( buffer, bytes ); + } + } + else { + /* a 'null' bitmap */ + buffer = NULL; + } + + image = (struct gl_image *) malloc( sizeof(struct gl_image) ); + if (image) { + image->Width = width; + image->Height = height; + image->Components = 0; + image->Format = GL_COLOR_INDEX; + image->Type = GL_BITMAP; + image->Data = buffer; + image->RefCount = 0; + } + else { + if (buffer) + free( buffer ); + return NULL; + } + return image; + } + else if (srcFormat==GL_DEPTH_COMPONENT) { + /* TODO: pack as GLdepth values (GLushort or GLuint) */ + + } + else if (srcFormat==GL_STENCIL_INDEX) { + /* TODO: pack as GLstencil (GLubyte or GLushort) */ + + } + else if (destType==GL_UNSIGNED_BYTE) { + struct gl_image *image; + GLint width_in_bytes; + GLubyte *buffer, *dst; + GLint i; + assert( srcType==GL_UNSIGNED_BYTE ); + + width_in_bytes = width * components * sizeof(GLubyte); + buffer = (GLubyte *) malloc( height * width_in_bytes ); + if (!buffer) { + return NULL; + } + /* Copy/unpack pixel data to buffer */ + dst = buffer; + for (i=0;iUnpack, + pixels, width, height, srcFormat, srcType, i); + if (!src) { + free(buffer); + return NULL; + } + MEMCPY( dst, src, width_in_bytes ); + dst += width_in_bytes; + } + + if (ctx->Unpack.LsbFirst) { + gl_flip_bytes( buffer, height * width_in_bytes ); + } + + image = (struct gl_image *) malloc( sizeof(struct gl_image) ); + if (image) { + image->Width = width; + image->Height = height; + image->Components = components; + image->Format = srcFormat; + image->Type = GL_UNSIGNED_BYTE; + image->Data = buffer; + image->RefCount = 0; + } + else { + free( buffer ); + return NULL; + } + return image; + } + else if (destType==GL_FLOAT) { + struct gl_image *image; + GLfloat *buffer, *dst; + GLint elems_per_row; + GLint i, j; + GLboolean normalize; + elems_per_row = width * components; + buffer = (GLfloat *) malloc( height * elems_per_row * sizeof(GLfloat)); + if (!buffer) { + return NULL; + } + + normalize = (srcFormat != GL_COLOR_INDEX) + && (srcFormat != GL_STENCIL_INDEX); + + dst = buffer; + /** img_pixels= pixels;*/ + for (i=0;iUnpack, pixels, + width, height, + srcFormat, srcType, + i); + if (!src) { + free(buffer); + return NULL; + } + + switch (srcType) { + case GL_UNSIGNED_BYTE: + if (normalize) { + for (j=0;jUnpack.SwapBytes) { + for (j=0;j> 8) & 0xff) | ((value&0xff) << 8); + if (normalize) { + *dst++ = USHORT_TO_FLOAT(value); + } + else { + *dst++ = (GLfloat) value; + } + } + } + else { + if (normalize) { + for (j=0;jUnpack.SwapBytes) { + for (j=0;j> 8) & 0xff) | ((value&0xff) << 8); + if (normalize) { + *dst++ = SHORT_TO_FLOAT(value); + } + else { + *dst++ = (GLfloat) value; + } + } + } + else { + if (normalize) { + for (j=0;jUnpack.SwapBytes) { + GLuint value; + for (j=0;j> 24) + | ((value & 0x00ff0000) >> 8) + | ((value & 0x0000ff00) << 8) + | ((value & 0x000000ff) << 24); + if (normalize) { + *dst++ = UINT_TO_FLOAT(value); + } + else { + *dst++ = (GLfloat) value; + } + } + } + else { + if (normalize) { + for (j=0;jUnpack.SwapBytes) { + GLint value; + for (j=0;j> 24) + | ((value & 0x00ff0000) >> 8) + | ((value & 0x0000ff00) << 8) + | ((value & 0x000000ff) << 24); + if (normalize) { + *dst++ = INT_TO_FLOAT(value); + } + else { + *dst++ = (GLfloat) value; + } + } + } + else { + if (normalize) { + for (j=0;jUnpack.SwapBytes) { + GLint value; + for (j=0;j> 24) + | ((value & 0x00ff0000) >> 8) + | ((value & 0x0000ff00) << 8) + | ((value & 0x000000ff) << 24); + *dst++ = *((GLfloat*) &value); + } + } + else { + MEMCPY( dst, src, elems_per_row*sizeof(GLfloat) ); + dst += elems_per_row; + } + break; + default: + gl_problem(ctx, "Bad type in gl_unpack_image3D"); + return NULL; + } /*switch*/ + } /* for height */ + + image = (struct gl_image *) malloc( sizeof(struct gl_image) ); + if (image) { + image->Width = width; + image->Height = height; + image->Components = components; + image->Format = srcFormat; + image->Type = GL_FLOAT; + image->Data = buffer; + image->RefCount = 0; + } + else { + free( buffer ); + return NULL; + } + return image; + } + else { + gl_problem(ctx, "Bad dest type in gl_unpack_image3D"); + return NULL; + } + return NULL; /* never get here */ +} + + + +void gl_free_image( struct gl_image *image ) +{ + if (image->Data) { + free(image->Data); + } + free(image); +} diff --git a/dll/opengl/mesa/image.h b/dll/opengl/mesa/image.h new file mode 100644 index 00000000000..475b78ea066 --- /dev/null +++ b/dll/opengl/mesa/image.h @@ -0,0 +1,80 @@ +/* $Id: image.h,v 1.5 1997/09/27 00:15:39 brianp Exp $ */ + +/* + * Mesa 3-D graphics library + * Version: 2.5 + * Copyright (C) 1995-1997 Brian Paul + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Library General Public + * License as published by the Free Software Foundation; either + * version 2 of the License, or (at your option) any later version. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Library General Public License for more details. + * + * You should have received a copy of the GNU Library General Public + * License along with this library; if not, write to the Free + * Software Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. + */ + + +/* + * $Log: image.h,v $ + * Revision 1.5 1997/09/27 00:15:39 brianp + * changed parameters to gl_unpack_image() + * + * Revision 1.4 1997/02/09 20:05:03 brianp + * new arguments for gl_pixel_addr_in_image() + * + * Revision 1.3 1997/02/09 18:52:53 brianp + * added GL_EXT_texture3D support + * + * Revision 1.2 1996/11/06 04:22:23 brianp + * changed gl_unpack_image() components argument to srcFormat + * + * Revision 1.1 1996/09/13 01:38:16 brianp + * Initial revision + * + */ + + +#ifndef IMAGE_H +#define IMAGE_H + + +#include "types.h" + + +extern void gl_flip_bytes( GLubyte *p, GLuint n ); + + +extern void gl_swap2( GLushort *p, GLuint n ); + +extern void gl_swap4( GLuint *p, GLuint n ); + + +extern GLint gl_sizeof_type( GLenum type ); + + +extern GLint gl_components_in_format( GLenum format ); + + +extern GLvoid *gl_pixel_addr_in_image( struct gl_pixelstore_attrib *packing, + const GLvoid *image, GLsizei width, + GLsizei height, GLenum format, GLenum type, + GLint row); + + +extern struct gl_image *gl_unpack_image( GLcontext *ctx, + GLint width, GLint height, + GLenum srcFormat, GLenum srcType, + const GLvoid *pixels ); + + +extern void gl_free_image( struct gl_image *image ); + + +#endif diff --git a/dll/opengl/mesa/light.c b/dll/opengl/mesa/light.c new file mode 100644 index 00000000000..eedee92c8c1 --- /dev/null +++ b/dll/opengl/mesa/light.c @@ -0,0 +1,888 @@ +/* $Id: light.c,v 1.14 1997/07/24 01:24:11 brianp Exp $ */ + +/* + * Mesa 3-D graphics library + * Version: 2.4 + * Copyright (C) 1995-1997 Brian Paul + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Library General Public + * License as published by the Free Software Foundation; either + * version 2 of the License, or (at your option) any later version. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Library General Public License for more details. + * + * You should have received a copy of the GNU Library General Public + * License along with this library; if not, write to the Free + * Software Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. + */ + + +/* + * $Log: light.c,v $ + * Revision 1.14 1997/07/24 01:24:11 brianp + * changed precompiled header symbol from PCH to PC_HEADER + * + * Revision 1.13 1997/06/20 04:15:43 brianp + * optimized changing of SHININESS (Henk Kok) + * + * Revision 1.12 1997/05/28 03:25:26 brianp + * added precompiled header (PCH) support + * + * Revision 1.11 1997/05/01 01:38:57 brianp + * now use NORMALIZE_3FV() macro from mmath.h + * + * Revision 1.10 1997/04/20 20:28:49 brianp + * replaced abort() with gl_problem() + * + * Revision 1.9 1997/04/07 02:59:17 brianp + * small optimization to setting of shininess and spot exponent + * + * Revision 1.8 1997/04/01 04:09:31 brianp + * misc code clean-ups. moved shading code to shade.c + * + * Revision 1.7 1997/03/11 00:37:39 brianp + * spotlight factor now effects ambient lighting + * + * Revision 1.6 1996/12/18 20:02:07 brianp + * glColorMaterial() and glMaterial() should finally work right! + * + * Revision 1.5 1996/12/07 10:22:41 brianp + * gl_Materialfv() now calls gl_set_material() if GL_COLOR_MATERIAL disabled + * implemented gl_GetLightiv() + * + * Revision 1.4 1996/11/08 04:39:23 brianp + * new gl_compute_spot_exp_table() contributed by Randy Frank + * + * Revision 1.3 1996/09/27 01:27:55 brianp + * removed unused variables + * + * Revision 1.2 1996/09/15 14:18:10 brianp + * now use GLframebuffer and GLvisual + * + * Revision 1.1 1996/09/13 01:38:16 brianp + * Initial revision + * + */ + + +#ifdef PC_HEADER +#include "all.h" +#else +#include +#include +#include +#include +#include "context.h" +#include "light.h" +#include "dlist.h" +#include "macros.h" +#include "matrix.h" +#include "mmath.h" +#include "types.h" +#include "vb.h" +#include "xform.h" +#endif + + + +void gl_ShadeModel( GLcontext *ctx, GLenum mode ) +{ + if (INSIDE_BEGIN_END(ctx)) { + gl_error( ctx, GL_INVALID_OPERATION, "glShadeModel" ); + return; + } + + switch (mode) { + case GL_FLAT: + case GL_SMOOTH: + if (ctx->Light.ShadeModel!=mode) { + ctx->Light.ShadeModel = mode; + ctx->NewState |= NEW_RASTER_OPS; + } + break; + default: + gl_error( ctx, GL_INVALID_ENUM, "glShadeModel" ); + } +} + + + +void gl_Lightfv( GLcontext *ctx, + GLenum light, GLenum pname, const GLfloat *params, + GLint nparams ) +{ + GLint l; + + if (INSIDE_BEGIN_END(ctx)) { + gl_error( ctx, GL_INVALID_OPERATION, "glShadeModel" ); + return; + } + + l = (GLint) (light - GL_LIGHT0); + + if (l<0 || l>=MAX_LIGHTS) { + gl_error( ctx, GL_INVALID_ENUM, "glLight" ); + return; + } + + switch (pname) { + case GL_AMBIENT: + COPY_4V( ctx->Light.Light[l].Ambient, params ); + break; + case GL_DIFFUSE: + COPY_4V( ctx->Light.Light[l].Diffuse, params ); + break; + case GL_SPECULAR: + COPY_4V( ctx->Light.Light[l].Specular, params ); + break; + case GL_POSITION: + /* transform position by ModelView matrix */ + TRANSFORM_POINT( ctx->Light.Light[l].Position, ctx->ModelViewMatrix, + params ); + break; + case GL_SPOT_DIRECTION: + /* transform direction by inverse modelview */ + { + GLfloat direction[4]; + direction[0] = params[0]; + direction[1] = params[1]; + direction[2] = params[2]; + direction[3] = 0.0; + if (ctx->NewModelViewMatrix) { + gl_analyze_modelview_matrix( ctx ); + } + gl_transform_vector( ctx->Light.Light[l].Direction, + direction, ctx->ModelViewInv); + } + break; + case GL_SPOT_EXPONENT: + if (params[0]<0.0 || params[0]>128.0) { + gl_error( ctx, GL_INVALID_VALUE, "glLight" ); + return; + } + if (ctx->Light.Light[l].SpotExponent != params[0]) { + ctx->Light.Light[l].SpotExponent = params[0]; + gl_compute_spot_exp_table( &ctx->Light.Light[l] ); + } + break; + case GL_SPOT_CUTOFF: + if ((params[0]<0.0 || params[0]>90.0) && params[0]!=180.0) { + gl_error( ctx, GL_INVALID_VALUE, "glLight" ); + return; + } + ctx->Light.Light[l].SpotCutoff = params[0]; + ctx->Light.Light[l].CosCutoff = cos(params[0]*DEG2RAD); + break; + case GL_CONSTANT_ATTENUATION: + if (params[0]<0.0) { + gl_error( ctx, GL_INVALID_VALUE, "glLight" ); + return; + } + ctx->Light.Light[l].ConstantAttenuation = params[0]; + break; + case GL_LINEAR_ATTENUATION: + if (params[0]<0.0) { + gl_error( ctx, GL_INVALID_VALUE, "glLight" ); + return; + } + ctx->Light.Light[l].LinearAttenuation = params[0]; + break; + case GL_QUADRATIC_ATTENUATION: + if (params[0]<0.0) { + gl_error( ctx, GL_INVALID_VALUE, "glLight" ); + return; + } + ctx->Light.Light[l].QuadraticAttenuation = params[0]; + break; + default: + gl_error( ctx, GL_INVALID_ENUM, "glLight" ); + break; + } + + ctx->NewState |= NEW_LIGHTING; +} + + + +void gl_GetLightfv( GLcontext *ctx, + GLenum light, GLenum pname, GLfloat *params ) +{ + GLint l = (GLint) (light - GL_LIGHT0); + + if (l<0 || l>=MAX_LIGHTS) { + gl_error( ctx, GL_INVALID_ENUM, "glGetLightfv" ); + return; + } + + switch (pname) { + case GL_AMBIENT: + COPY_4V( params, ctx->Light.Light[l].Ambient ); + break; + case GL_DIFFUSE: + COPY_4V( params, ctx->Light.Light[l].Diffuse ); + break; + case GL_SPECULAR: + COPY_4V( params, ctx->Light.Light[l].Specular ); + break; + case GL_POSITION: + COPY_4V( params, ctx->Light.Light[l].Position ); + break; + case GL_SPOT_DIRECTION: + COPY_3V( params, ctx->Light.Light[l].Direction ); + break; + case GL_SPOT_EXPONENT: + params[0] = ctx->Light.Light[l].SpotExponent; + break; + case GL_SPOT_CUTOFF: + params[0] = ctx->Light.Light[l].SpotCutoff; + break; + case GL_CONSTANT_ATTENUATION: + params[0] = ctx->Light.Light[l].ConstantAttenuation; + break; + case GL_LINEAR_ATTENUATION: + params[0] = ctx->Light.Light[l].LinearAttenuation; + break; + case GL_QUADRATIC_ATTENUATION: + params[0] = ctx->Light.Light[l].QuadraticAttenuation; + break; + default: + gl_error( ctx, GL_INVALID_ENUM, "glGetLightfv" ); + break; + } +} + + + +void gl_GetLightiv( GLcontext *ctx, GLenum light, GLenum pname, GLint *params ) +{ + GLint l = (GLint) (light - GL_LIGHT0); + + if (l<0 || l>=MAX_LIGHTS) { + gl_error( ctx, GL_INVALID_ENUM, "glGetLightiv" ); + return; + } + + switch (pname) { + case GL_AMBIENT: + params[0] = FLOAT_TO_INT(ctx->Light.Light[l].Ambient[0]); + params[1] = FLOAT_TO_INT(ctx->Light.Light[l].Ambient[1]); + params[2] = FLOAT_TO_INT(ctx->Light.Light[l].Ambient[2]); + params[3] = FLOAT_TO_INT(ctx->Light.Light[l].Ambient[3]); + break; + case GL_DIFFUSE: + params[0] = FLOAT_TO_INT(ctx->Light.Light[l].Diffuse[0]); + params[1] = FLOAT_TO_INT(ctx->Light.Light[l].Diffuse[1]); + params[2] = FLOAT_TO_INT(ctx->Light.Light[l].Diffuse[2]); + params[3] = FLOAT_TO_INT(ctx->Light.Light[l].Diffuse[3]); + break; + case GL_SPECULAR: + params[0] = FLOAT_TO_INT(ctx->Light.Light[l].Specular[0]); + params[1] = FLOAT_TO_INT(ctx->Light.Light[l].Specular[1]); + params[2] = FLOAT_TO_INT(ctx->Light.Light[l].Specular[2]); + params[3] = FLOAT_TO_INT(ctx->Light.Light[l].Specular[3]); + break; + case GL_POSITION: + params[0] = ctx->Light.Light[l].Position[0]; + params[1] = ctx->Light.Light[l].Position[1]; + params[2] = ctx->Light.Light[l].Position[2]; + params[3] = ctx->Light.Light[l].Position[3]; + break; + case GL_SPOT_DIRECTION: + params[0] = ctx->Light.Light[l].Direction[0]; + params[1] = ctx->Light.Light[l].Direction[1]; + params[2] = ctx->Light.Light[l].Direction[2]; + break; + case GL_SPOT_EXPONENT: + params[0] = ctx->Light.Light[l].SpotExponent; + break; + case GL_SPOT_CUTOFF: + params[0] = ctx->Light.Light[l].SpotCutoff; + break; + case GL_CONSTANT_ATTENUATION: + params[0] = ctx->Light.Light[l].ConstantAttenuation; + break; + case GL_LINEAR_ATTENUATION: + params[0] = ctx->Light.Light[l].LinearAttenuation; + break; + case GL_QUADRATIC_ATTENUATION: + params[0] = ctx->Light.Light[l].QuadraticAttenuation; + break; + default: + gl_error( ctx, GL_INVALID_ENUM, "glGetLightiv" ); + break; + } +} + + + +/**********************************************************************/ +/*** Light Model ***/ +/**********************************************************************/ + + +void gl_LightModelfv( GLcontext *ctx, GLenum pname, const GLfloat *params ) +{ + switch (pname) { + case GL_LIGHT_MODEL_AMBIENT: + COPY_4V( ctx->Light.Model.Ambient, params ); + break; + case GL_LIGHT_MODEL_LOCAL_VIEWER: + if (params[0]==0.0) + ctx->Light.Model.LocalViewer = GL_FALSE; + else + ctx->Light.Model.LocalViewer = GL_TRUE; + break; + case GL_LIGHT_MODEL_TWO_SIDE: + if (params[0]==0.0) + ctx->Light.Model.TwoSide = GL_FALSE; + else + ctx->Light.Model.TwoSide = GL_TRUE; + break; + default: + gl_error( ctx, GL_INVALID_ENUM, "glLightModel" ); + break; + } + ctx->NewState |= NEW_LIGHTING; +} + + + + +/********** MATERIAL **********/ + + +/* + * Given a face and pname value (ala glColorMaterial), compute a bitmask + * of the targeted material values. + */ +GLuint gl_material_bitmask( GLenum face, GLenum pname ) +{ + GLuint bitmask = 0; + + /* Make a bitmask indicating what material attribute(s) we're updating */ + switch (pname) { + case GL_EMISSION: + bitmask |= FRONT_EMISSION_BIT | BACK_EMISSION_BIT; + break; + case GL_AMBIENT: + bitmask |= FRONT_AMBIENT_BIT | BACK_AMBIENT_BIT; + break; + case GL_DIFFUSE: + bitmask |= FRONT_DIFFUSE_BIT | BACK_DIFFUSE_BIT; + break; + case GL_SPECULAR: + bitmask |= FRONT_SPECULAR_BIT | BACK_SPECULAR_BIT; + break; + case GL_SHININESS: + bitmask |= FRONT_SHININESS_BIT | BACK_SHININESS_BIT; + break; + case GL_AMBIENT_AND_DIFFUSE: + bitmask |= FRONT_AMBIENT_BIT | BACK_AMBIENT_BIT; + bitmask |= FRONT_DIFFUSE_BIT | BACK_DIFFUSE_BIT; + break; + case GL_COLOR_INDEXES: + bitmask |= FRONT_INDEXES_BIT | BACK_INDEXES_BIT; + break; + default: + gl_problem(NULL, "Bad param in gl_material_bitmask"); + return 0; + } + + ASSERT( face==GL_FRONT || face==GL_BACK || face==GL_FRONT_AND_BACK ); + + if (face==GL_FRONT) { + bitmask &= FRONT_MATERIAL_BITS; + } + else if (face==GL_BACK) { + bitmask &= BACK_MATERIAL_BITS; + } + + return bitmask; +} + + + +/* + * This is called by glColor() when GL_COLOR_MATERIAL is enabled and + * called by glMaterial() when GL_COLOR_MATERIAL is disabled. + */ +void gl_set_material( GLcontext *ctx, GLuint bitmask, const GLfloat *params ) +{ + struct gl_material *mat; + + if (INSIDE_BEGIN_END(ctx)) { + struct vertex_buffer *VB = ctx->VB; + /* Save per-vertex material changes in the Vertex Buffer. + * The update_material function will eventually update the global + * ctx->Light.Material values. + */ + mat = VB->Material[VB->Count]; + VB->MaterialMask[VB->Count] |= bitmask; + VB->MonoMaterial = GL_FALSE; + } + else { + /* just update the global material property */ + mat = ctx->Light.Material; + ctx->NewState |= NEW_LIGHTING; + } + + if (bitmask & FRONT_AMBIENT_BIT) { + COPY_4V( mat[0].Ambient, params ); + } + if (bitmask & BACK_AMBIENT_BIT) { + COPY_4V( mat[1].Ambient, params ); + } + if (bitmask & FRONT_DIFFUSE_BIT) { + COPY_4V( mat[0].Diffuse, params ); + } + if (bitmask & BACK_DIFFUSE_BIT) { + COPY_4V( mat[1].Diffuse, params ); + } + if (bitmask & FRONT_SPECULAR_BIT) { + COPY_4V( mat[0].Specular, params ); + } + if (bitmask & BACK_SPECULAR_BIT) { + COPY_4V( mat[1].Specular, params ); + } + if (bitmask & FRONT_EMISSION_BIT) { + COPY_4V( mat[0].Emission, params ); + } + if (bitmask & BACK_EMISSION_BIT) { + COPY_4V( mat[1].Emission, params ); + } + if (bitmask & FRONT_SHININESS_BIT) { + GLfloat shininess = CLAMP( params[0], 0.0F, 128.0F ); + if (mat[0].Shininess != shininess) { + mat[0].Shininess = shininess; + gl_compute_material_shine_table( &mat[0] ); + } + } + if (bitmask & BACK_SHININESS_BIT) { + GLfloat shininess = CLAMP( params[0], 0.0F, 128.0F ); + if (mat[1].Shininess != shininess) { + mat[1].Shininess = shininess; + gl_compute_material_shine_table( &mat[1] ); + } + } + if (bitmask & FRONT_INDEXES_BIT) { + mat[0].AmbientIndex = params[0]; + mat[0].DiffuseIndex = params[1]; + mat[0].SpecularIndex = params[2]; + } + if (bitmask & BACK_INDEXES_BIT) { + mat[1].AmbientIndex = params[0]; + mat[1].DiffuseIndex = params[1]; + mat[1].SpecularIndex = params[2]; + } +} + + + +void gl_ColorMaterial( GLcontext *ctx, GLenum face, GLenum mode ) +{ + if (INSIDE_BEGIN_END(ctx)) { + gl_error( ctx, GL_INVALID_OPERATION, "glColorMaterial" ); + return; + } + switch (face) { + case GL_FRONT: + case GL_BACK: + case GL_FRONT_AND_BACK: + ctx->Light.ColorMaterialFace = face; + break; + default: + gl_error( ctx, GL_INVALID_ENUM, "glColorMaterial(face)" ); + return; + } + switch (mode) { + case GL_EMISSION: + case GL_AMBIENT: + case GL_DIFFUSE: + case GL_SPECULAR: + case GL_AMBIENT_AND_DIFFUSE: + ctx->Light.ColorMaterialMode = mode; + break; + default: + gl_error( ctx, GL_INVALID_ENUM, "glColorMaterial(mode)" ); + return; + } + + ctx->Light.ColorMaterialBitmask = gl_material_bitmask( face, mode ); +} + + + +/* + * This is only called via the api_function_table struct or by the + * display list executor. + */ +void gl_Materialfv( GLcontext *ctx, + GLenum face, GLenum pname, const GLfloat *params ) +{ + GLuint bitmask; + + /* error checking */ + if (face!=GL_FRONT && face!=GL_BACK && face!=GL_FRONT_AND_BACK) { + gl_error( ctx, GL_INVALID_ENUM, "glMaterial(face)" ); + return; + } + switch (pname) { + case GL_EMISSION: + case GL_AMBIENT: + case GL_DIFFUSE: + case GL_SPECULAR: + case GL_SHININESS: + case GL_AMBIENT_AND_DIFFUSE: + case GL_COLOR_INDEXES: + /* OK */ + break; + default: + gl_error( ctx, GL_INVALID_ENUM, "glMaterial(pname)" ); + return; + } + + /* convert face and pname to a bitmask */ + bitmask = gl_material_bitmask( face, pname ); + + if (ctx->Light.ColorMaterialEnabled) { + /* The material values specified by glColorMaterial() can't be */ + /* updated by glMaterial() while GL_COLOR_MATERIAL is enabled! */ + bitmask &= ~ctx->Light.ColorMaterialBitmask; + } + + gl_set_material( ctx, bitmask, params ); +} + + + + +void gl_GetMaterialfv( GLcontext *ctx, + GLenum face, GLenum pname, GLfloat *params ) +{ + GLuint f; + + if (INSIDE_BEGIN_END(ctx)) { + gl_error( ctx, GL_INVALID_OPERATION, "glGetMaterialfv" ); + return; + } + if (face==GL_FRONT) { + f = 0; + } + else if (face==GL_BACK) { + f = 1; + } + else { + gl_error( ctx, GL_INVALID_ENUM, "glGetMaterialfv(face)" ); + return; + } + switch (pname) { + case GL_AMBIENT: + COPY_4V( params, ctx->Light.Material[f].Ambient ); + break; + case GL_DIFFUSE: + COPY_4V( params, ctx->Light.Material[f].Diffuse ); + break; + case GL_SPECULAR: + COPY_4V( params, ctx->Light.Material[f].Specular ); + break; + case GL_EMISSION: + COPY_4V( params, ctx->Light.Material[f].Emission ); + break; + case GL_SHININESS: + *params = ctx->Light.Material[f].Shininess; + break; + case GL_COLOR_INDEXES: + params[0] = ctx->Light.Material[f].AmbientIndex; + params[1] = ctx->Light.Material[f].DiffuseIndex; + params[2] = ctx->Light.Material[f].SpecularIndex; + break; + default: + gl_error( ctx, GL_INVALID_ENUM, "glGetMaterialfv(pname)" ); + } +} + + + +void gl_GetMaterialiv( GLcontext *ctx, + GLenum face, GLenum pname, GLint *params ) +{ + GLuint f; + + if (INSIDE_BEGIN_END(ctx)) { + gl_error( ctx, GL_INVALID_OPERATION, "glGetMaterialiv" ); + return; + } + if (face==GL_FRONT) { + f = 0; + } + else if (face==GL_BACK) { + f = 1; + } + else { + gl_error( ctx, GL_INVALID_ENUM, "glGetMaterialiv(face)" ); + return; + } + switch (pname) { + case GL_AMBIENT: + params[0] = FLOAT_TO_INT( ctx->Light.Material[f].Ambient[0] ); + params[1] = FLOAT_TO_INT( ctx->Light.Material[f].Ambient[1] ); + params[2] = FLOAT_TO_INT( ctx->Light.Material[f].Ambient[2] ); + params[3] = FLOAT_TO_INT( ctx->Light.Material[f].Ambient[3] ); + break; + case GL_DIFFUSE: + params[0] = FLOAT_TO_INT( ctx->Light.Material[f].Diffuse[0] ); + params[1] = FLOAT_TO_INT( ctx->Light.Material[f].Diffuse[1] ); + params[2] = FLOAT_TO_INT( ctx->Light.Material[f].Diffuse[2] ); + params[3] = FLOAT_TO_INT( ctx->Light.Material[f].Diffuse[3] ); + break; + case GL_SPECULAR: + params[0] = FLOAT_TO_INT( ctx->Light.Material[f].Specular[0] ); + params[1] = FLOAT_TO_INT( ctx->Light.Material[f].Specular[1] ); + params[2] = FLOAT_TO_INT( ctx->Light.Material[f].Specular[2] ); + params[3] = FLOAT_TO_INT( ctx->Light.Material[f].Specular[3] ); + break; + case GL_EMISSION: + params[0] = FLOAT_TO_INT( ctx->Light.Material[f].Emission[0] ); + params[1] = FLOAT_TO_INT( ctx->Light.Material[f].Emission[1] ); + params[2] = FLOAT_TO_INT( ctx->Light.Material[f].Emission[2] ); + params[3] = FLOAT_TO_INT( ctx->Light.Material[f].Emission[3] ); + break; + case GL_SHININESS: + *params = ROUNDF( ctx->Light.Material[f].Shininess ); + break; + case GL_COLOR_INDEXES: + params[0] = ROUNDF( ctx->Light.Material[f].AmbientIndex ); + params[1] = ROUNDF( ctx->Light.Material[f].DiffuseIndex ); + params[2] = ROUNDF( ctx->Light.Material[f].SpecularIndex ); + break; + default: + gl_error( ctx, GL_INVALID_ENUM, "glGetMaterialfv(pname)" ); + } +} + + + + +/**********************************************************************/ +/***** Lighting computation *****/ +/**********************************************************************/ + + +/* + * Notes: + * When two-sided lighting is enabled we compute the color (or index) + * for both the front and back side of the primitive. Then, when the + * orientation of the facet is later learned, we can determine which + * color (or index) to use for rendering. + * + * Variables: + * n = normal vector + * V = vertex position + * P = light source position + * Pe = (0,0,0,1) + * + * Precomputed: + * IF P[3]==0 THEN + * // light at infinity + * IF local_viewer THEN + * VP_inf_norm = unit vector from V to P // Precompute + * ELSE + * // eye at infinity + * h_inf_norm = Normalize( VP + <0,0,1> ) // Precompute + * ENDIF + * ENDIF + * + * Functions: + * Normalize( v ) = normalized vector v + * Magnitude( v ) = length of vector v + */ + + + +/* + * Whenever the spotlight exponent for a light changes we must call + * this function to recompute the exponent lookup table. + */ +void gl_compute_spot_exp_table( struct gl_light *l ) +{ + int i; + double exponent = l->SpotExponent; + double tmp; + int clamp = 0; + + l->SpotExpTable[0][0] = 0.0; + + for (i=EXP_TABLE_SIZE-1;i>0;i--) { + if (clamp == 0) { + tmp = pow(i/(double)(EXP_TABLE_SIZE-1), exponent); + if (tmp < FLT_MIN*100.0) { + tmp = 0.0; + clamp = 1; + } + } + l->SpotExpTable[i][0] = tmp; + } + for (i=0;iSpotExpTable[i][1] = l->SpotExpTable[i+1][0] - l->SpotExpTable[i][0]; + } + l->SpotExpTable[EXP_TABLE_SIZE-1][1] = 0.0; +} + + + +/* + * Whenever the shininess of a material changes we must call this + * function to recompute the exponential lookup table. + */ +void gl_compute_material_shine_table( struct gl_material *m ) +{ + int i; + + m->ShineTable[0] = 0.0F; + for (i=1;iShineTable[i] = 0.0F; + } + else { + m->ShineTable[i] = x; + } +#else + /* just invalidate the table */ + m->ShineTable[i] = -1.0; +#endif + } +} + + + +/* + * Examine current lighting parameters to determine if the optimized lighting + * function can be used. + * Also, precompute some lighting values such as the products of light + * source and material ambient, diffuse and specular coefficients. + */ +void gl_update_lighting( GLcontext *ctx ) +{ + GLint i, side; + struct gl_light *prev_enabled, *light; + + if (!ctx->Light.Enabled) { + /* If lighting is not enabled, we can skip all this. */ + return; + } + + /* Setup linked list of enabled light sources */ + prev_enabled = NULL; + ctx->Light.FirstEnabled = NULL; + for (i=0;iLight.Light[i].NextEnabled = NULL; + if (ctx->Light.Light[i].Enabled) { + if (prev_enabled) { + prev_enabled->NextEnabled = &ctx->Light.Light[i]; + } + else { + ctx->Light.FirstEnabled = &ctx->Light.Light[i]; + } + prev_enabled = &ctx->Light.Light[i]; + } + } + + /* base color = material_emission + global_ambient * material_ambient */ + for (side=0; side<2; side++) { + ctx->Light.BaseColor[side][0] = ctx->Light.Material[side].Emission[0] + + ctx->Light.Model.Ambient[0] * ctx->Light.Material[side].Ambient[0]; + ctx->Light.BaseColor[side][1] = ctx->Light.Material[side].Emission[1] + + ctx->Light.Model.Ambient[1] * ctx->Light.Material[side].Ambient[1]; + ctx->Light.BaseColor[side][2] = ctx->Light.Material[side].Emission[2] + + ctx->Light.Model.Ambient[2] * ctx->Light.Material[side].Ambient[2]; + ctx->Light.BaseColor[side][3] + = MIN2( ctx->Light.Material[side].Diffuse[3], 1.0F ); + } + + + /* Precompute some lighting stuff */ + for (light = ctx->Light.FirstEnabled; light; light = light->NextEnabled) { + for (side=0; side<2; side++) { + struct gl_material *mat = &ctx->Light.Material[side]; + /* Add each light's ambient component to base color */ + ctx->Light.BaseColor[side][0] += light->Ambient[0] * mat->Ambient[0]; + ctx->Light.BaseColor[side][1] += light->Ambient[1] * mat->Ambient[1]; + ctx->Light.BaseColor[side][2] += light->Ambient[2] * mat->Ambient[2]; + /* compute product of light's ambient with front material ambient */ + light->MatAmbient[side][0] = light->Ambient[0] * mat->Ambient[0]; + light->MatAmbient[side][1] = light->Ambient[1] * mat->Ambient[1]; + light->MatAmbient[side][2] = light->Ambient[2] * mat->Ambient[2]; + /* compute product of light's diffuse with front material diffuse */ + light->MatDiffuse[side][0] = light->Diffuse[0] * mat->Diffuse[0]; + light->MatDiffuse[side][1] = light->Diffuse[1] * mat->Diffuse[1]; + light->MatDiffuse[side][2] = light->Diffuse[2] * mat->Diffuse[2]; + /* compute product of light's specular with front material specular */ + light->MatSpecular[side][0] = light->Specular[0] * mat->Specular[0]; + light->MatSpecular[side][1] = light->Specular[1] * mat->Specular[1]; + light->MatSpecular[side][2] = light->Specular[2] * mat->Specular[2]; + + /* VP (VP) = Normalize( Position ) */ + COPY_3V( light->VP_inf_norm, light->Position ); + NORMALIZE_3FV( light->VP_inf_norm ); + + /* h_inf_norm = Normalize( V_to_P + <0,0,1> ) */ + COPY_3V( light->h_inf_norm, light->VP_inf_norm ); + light->h_inf_norm[2] += 1.0F; + NORMALIZE_3FV( light->h_inf_norm ); + + COPY_3V( light->NormDirection, light->Direction ); + NORMALIZE_3FV( light->NormDirection ); + + /* Compute color index diffuse and specular light intensities */ + light->dli = 0.30F * light->Diffuse[0] + + 0.59F * light->Diffuse[1] + + 0.11F * light->Diffuse[2]; + light->sli = 0.30F * light->Specular[0] + + 0.59F * light->Specular[1] + + 0.11F * light->Specular[2]; + + } /* loop over materials */ + } /* loop over lights */ + + /* Determine if the fast lighting function can be used */ + ctx->Light.Fast = GL_TRUE; + if ( ctx->Light.BaseColor[0][0]<0.0F + || ctx->Light.BaseColor[0][1]<0.0F + || ctx->Light.BaseColor[0][2]<0.0F + || ctx->Light.BaseColor[0][3]<0.0F + || ctx->Light.BaseColor[1][0]<0.0F + || ctx->Light.BaseColor[1][1]<0.0F + || ctx->Light.BaseColor[1][2]<0.0F + || ctx->Light.BaseColor[1][3]<0.0F + || ctx->Light.Model.LocalViewer + || ctx->Light.ColorMaterialEnabled) { + ctx->Light.Fast = GL_FALSE; + } + else { + for (light=ctx->Light.FirstEnabled; light; light=light->NextEnabled) { + if ( light->Position[3]!=0.0F + || light->SpotCutoff!=180.0F + || light->MatDiffuse[0][0]<0.0F + || light->MatDiffuse[0][1]<0.0F + || light->MatDiffuse[0][2]<0.0F + || light->MatSpecular[0][0]<0.0F + || light->MatSpecular[0][1]<0.0F + || light->MatSpecular[0][2]<0.0F + || light->MatDiffuse[1][0]<0.0F + || light->MatDiffuse[1][1]<0.0F + || light->MatDiffuse[1][2]<0.0F + || light->MatSpecular[1][0]<0.0F + || light->MatSpecular[1][1]<0.0F + || light->MatSpecular[1][2]<0.0F) { + ctx->Light.Fast = GL_FALSE; + break; + } + } + } +} diff --git a/dll/opengl/mesa/light.h b/dll/opengl/mesa/light.h new file mode 100644 index 00000000000..236cb91eeb9 --- /dev/null +++ b/dll/opengl/mesa/light.h @@ -0,0 +1,93 @@ +/* $Id: light.h,v 1.4 1997/04/01 04:09:16 brianp Exp $ */ + +/* + * Mesa 3-D graphics library + * Version: 2.3 + * Copyright (C) 1995-1997 Brian Paul + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Library General Public + * License as published by the Free Software Foundation; either + * version 2 of the License, or (at your option) any later version. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Library General Public License for more details. + * + * You should have received a copy of the GNU Library General Public + * License along with this library; if not, write to the Free + * Software Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. + */ + + +/* + * $Log: light.h,v $ + * Revision 1.4 1997/04/01 04:09:16 brianp + * removed shading functions + * + * Revision 1.3 1996/12/18 20:03:01 brianp + * gl_set_material() now takes a bitmask instead of face and pname + * added gl_material_bitmask() + * + * Revision 1.2 1996/12/07 10:21:58 brianp + * added gl_set_material() + * + * Revision 1.1 1996/09/13 01:38:16 brianp + * Initial revision + * + */ + + +#ifndef LIGHT_H +#define LIGHT_H + + +#include "types.h" + + +extern void gl_ShadeModel( GLcontext *ctx, GLenum mode ); + +extern void gl_ColorMaterial( GLcontext *ctx, GLenum face, GLenum mode ); + +extern void gl_Lightfv( GLcontext *ctx, + GLenum light, GLenum pname, const GLfloat *params, + GLint nparams ); + +extern void gl_LightModelfv( GLcontext *ctx, + GLenum pname, const GLfloat *params ); + + +extern GLuint gl_material_bitmask( GLenum face, GLenum pname ); + +extern void gl_set_material( GLcontext *ctx, GLuint bitmask, + const GLfloat *params); + +extern void gl_Materialfv( GLcontext *ctx, + GLenum face, GLenum pname, const GLfloat *params ); + + + +extern void gl_GetLightfv( GLcontext *ctx, + GLenum light, GLenum pname, GLfloat *params ); + +extern void gl_GetLightiv( GLcontext *ctx, + GLenum light, GLenum pname, GLint *params ); + + +extern void gl_GetMaterialfv( GLcontext *ctx, + GLenum face, GLenum pname, GLfloat *params ); + +extern void gl_GetMaterialiv( GLcontext *ctx, + GLenum face, GLenum pname, GLint *params ); + + +extern void gl_compute_spot_exp_table( struct gl_light *l ); + +extern void gl_compute_material_shine_table( struct gl_material *m ); + +extern void gl_update_lighting( GLcontext *ctx ); + + +#endif + diff --git a/dll/opengl/mesa/lines.c b/dll/opengl/mesa/lines.c new file mode 100644 index 00000000000..2cff0230b14 --- /dev/null +++ b/dll/opengl/mesa/lines.c @@ -0,0 +1,978 @@ +/* $Id: lines.c,v 1.19 1998/02/03 23:46:00 brianp Exp $ */ + +/* + * Mesa 3-D graphics library + * Version: 2.4 + * Copyright (C) 1995-1997 Brian Paul + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Library General Public + * License as published by the Free Software Foundation; either + * version 2 of the License, or (at your option) any later version. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Library General Public License for more details. + * + * You should have received a copy of the GNU Library General Public + * License along with this library; if not, write to the Free + * Software Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. + */ + + +/* + * $Log: lines.c,v $ + * Revision 1.19 1998/02/03 23:46:00 brianp + * fixed a few problems with condition expressions for Amiga StormC compiler + * + * Revision 1.18 1997/07/24 01:24:11 brianp + * changed precompiled header symbol from PCH to PC_HEADER + * + * Revision 1.17 1997/07/05 16:03:51 brianp + * fixed PB overflow problem + * + * Revision 1.16 1997/06/20 02:01:49 brianp + * changed color components from GLfixed to GLubyte + * + * Revision 1.15 1997/06/03 01:38:22 brianp + * fixed divide by zero problem in feedback function (William Mitchell) + * + * Revision 1.14 1997/05/28 03:25:26 brianp + * added precompiled header (PCH) support + * + * Revision 1.13 1997/05/03 00:51:02 brianp + * removed calls to gl_texturing_enabled() + * + * Revision 1.12 1997/04/14 02:00:39 brianp + * #include "texstate.h" instead of "texture.h" + * + * Revision 1.11 1997/04/12 12:25:01 brianp + * replaced ctx->LineFunc with ctx->Driver.LineFunc, fixed PB->count bug + * + * Revision 1.10 1997/03/16 02:07:31 brianp + * now use linetemp.h in line drawing functions + * + * Revision 1.9 1997/03/08 02:04:27 brianp + * better implementation of feedback function + * + * Revision 1.8 1997/02/09 18:44:20 brianp + * added GL_EXT_texture3D support + * + * Revision 1.7 1997/01/09 19:48:00 brianp + * now call gl_texturing_enabled() + * + * Revision 1.6 1996/11/08 02:21:21 brianp + * added null drawing function for GL_NO_RASTER + * + * Revision 1.5 1996/09/27 01:28:56 brianp + * removed unused variables + * + * Revision 1.4 1996/09/25 02:01:54 brianp + * new texture coord interpolation + * + * Revision 1.3 1996/09/15 14:18:10 brianp + * now use GLframebuffer and GLvisual + * + * Revision 1.2 1996/09/15 01:48:58 brianp + * removed #define NULL 0 + * + * Revision 1.1 1996/09/13 01:38:16 brianp + * Initial revision + * + */ + + +#ifdef PC_HEADER +#include "all.h" +#else +#include "context.h" +#include "depth.h" +#include "feedback.h" +#include "lines.h" +#include "dlist.h" +#include "macros.h" +#include "pb.h" +#include "texstate.h" +#include "types.h" +#include "vb.h" +#include +#endif + +WINE_DEFAULT_DEBUG_CHANNEL(opengl32); + +void gl_LineWidth( GLcontext *ctx, GLfloat width ) +{ + if (width<=0.0) { + gl_error( ctx, GL_INVALID_VALUE, "glLineWidth" ); + return; + } + if (INSIDE_BEGIN_END(ctx)) { + gl_error( ctx, GL_INVALID_OPERATION, "glLineWidth" ); + return; + } + ctx->Line.Width = width; + ctx->NewState |= NEW_RASTER_OPS; +} + + + +void gl_LineStipple( GLcontext *ctx, GLint factor, GLushort pattern ) +{ + if (INSIDE_BEGIN_END(ctx)) { + gl_error( ctx, GL_INVALID_OPERATION, "glLineStipple" ); + return; + } + ctx->Line.StippleFactor = CLAMP( factor, 1, 256 ); + ctx->Line.StipplePattern = pattern; + ctx->NewState |= NEW_RASTER_OPS; +} + + + +/**********************************************************************/ +/***** Rasterization *****/ +/**********************************************************************/ + + +/* + * There are 4 pairs (RGBA, CI) of line drawing functions: + * 1. simple: width=1 and no special rasterization functions (fastest) + * 2. flat: width=1, non-stippled, flat-shaded, any raster operations + * 3. smooth: width=1, non-stippled, smooth-shaded, any raster operations + * 4. general: any other kind of line (slowest) + */ + + +/* + * All line drawing functions have the same arguments: + * v1, v2 - indexes of first and second endpoints into vertex buffer arrays + * pv - provoking vertex: which vertex color/index to use for flat shading. + */ + + + +static void feedback_line( GLcontext *ctx, GLuint v1, GLuint v2, GLuint pv ) +{ + struct vertex_buffer *VB = ctx->VB; + GLfloat x1, y1, z1, w1; + GLfloat x2, y2, z2, w2; + GLfloat tex1[4], tex2[4], invq; + GLfloat invRedScale = ctx->Visual->InvRedScale; + GLfloat invGreenScale = ctx->Visual->InvGreenScale; + GLfloat invBlueScale = ctx->Visual->InvBlueScale; + GLfloat invAlphaScale = ctx->Visual->InvAlphaScale; + + x1 = VB->Win[v1][0]; + y1 = VB->Win[v1][1]; + z1 = VB->Win[v1][2] / DEPTH_SCALE; + w1 = VB->Clip[v1][3]; + + x2 = VB->Win[v2][0]; + y2 = VB->Win[v2][1]; + z2 = VB->Win[v2][2] / DEPTH_SCALE; + w2 = VB->Clip[v2][3]; + + invq = (VB->TexCoord[v1][3]==0.0) ? 1.0 : (1.0F / VB->TexCoord[v1][3]); + tex1[0] = VB->TexCoord[v1][0] * invq; + tex1[1] = VB->TexCoord[v1][1] * invq; + tex1[2] = VB->TexCoord[v1][2] * invq; + tex1[3] = VB->TexCoord[v1][3]; + invq = (VB->TexCoord[v2][3]==0.0) ? 1.0 : (1.0F / VB->TexCoord[v2][3]); + tex2[0] = VB->TexCoord[v2][0] * invq; + tex2[1] = VB->TexCoord[v2][1] * invq; + tex2[2] = VB->TexCoord[v2][2] * invq; + tex2[3] = VB->TexCoord[v2][3]; + + if (ctx->StippleCounter==0) { + FEEDBACK_TOKEN( ctx, (GLfloat) (GLint) GL_LINE_RESET_TOKEN ); + } + else { + FEEDBACK_TOKEN( ctx, (GLfloat) (GLint) GL_LINE_TOKEN ); + } + + { + GLfloat color[4]; + /* convert color from integer to a float in [0,1] */ + color[0] = (GLfloat) VB->Color[pv][0] * invRedScale; + color[1] = (GLfloat) VB->Color[pv][1] * invGreenScale; + color[2] = (GLfloat) VB->Color[pv][2] * invBlueScale; + color[3] = (GLfloat) VB->Color[pv][3] * invAlphaScale; + gl_feedback_vertex( ctx, x1,y1,z1,w1, color, + (GLfloat) VB->Index[pv], tex1 ); + gl_feedback_vertex( ctx, x2,y2,z2,w2, color, + (GLfloat) VB->Index[pv], tex2 ); + } + + ctx->StippleCounter++; +} + + + +static void select_line( GLcontext *ctx, GLuint v1, GLuint v2, GLuint pv ) +{ + gl_update_hitflag( ctx, ctx->VB->Win[v1][2] / DEPTH_SCALE ); + gl_update_hitflag( ctx, ctx->VB->Win[v2][2] / DEPTH_SCALE ); +} + + + +#if MAX_WIDTH > MAX_HEIGHT +# define MAXPOINTS MAX_WIDTH +#else +# define MAXPOINTS MAX_HEIGHT +#endif + + +/* Flat, color index line */ +static void flat_ci_line( GLcontext *ctx, + GLuint vert0, GLuint vert1, GLuint pvert ) +{ + GLint count; + GLint *pbx = ctx->PB->x; + GLint *pby = ctx->PB->y; + PB_SET_INDEX( ctx, ctx->PB, ctx->VB->Index[pvert] ); + count = ctx->PB->count; + +#define INTERP_XY 1 + +#define PLOT(X,Y) \ + pbx[count] = X; \ + pby[count] = Y; \ + count++; + +#include "linetemp.h" + + ctx->PB->count = count; + PB_CHECK_FLUSH( ctx, ctx->PB ); +} + + + +/* Flat, color index line with Z interpolation/testing */ +static void flat_ci_z_line( GLcontext *ctx, + GLuint vert0, GLuint vert1, GLuint pvert ) +{ + GLint count; + GLint *pbx = ctx->PB->x; + GLint *pby = ctx->PB->y; + GLdepth *pbz = ctx->PB->z; + PB_SET_INDEX( ctx, ctx->PB, ctx->VB->Index[pvert] ); + count = ctx->PB->count; + +#define INTERP_XY 1 +#define INTERP_Z 1 + +#define PLOT(X,Y) \ + pbx[count] = X; \ + pby[count] = Y; \ + pbz[count] = Z; \ + count++; + +#include "linetemp.h" + + ctx->PB->count = count; + PB_CHECK_FLUSH( ctx, ctx->PB ); +} + + + +/* Flat-shaded, RGBA line */ +static void flat_rgba_line( GLcontext *ctx, + GLuint vert0, GLuint vert1, GLuint pvert ) +{ + GLint count; + GLint *pbx = ctx->PB->x; + GLint *pby = ctx->PB->y; + GLubyte *color = ctx->VB->Color[pvert]; + PB_SET_COLOR( ctx, ctx->PB, color[0], color[1], color[2], color[3] ); + count = ctx->PB->count; + +#define INTERP_XY 1 + +#define PLOT(X,Y) \ + pbx[count] = X; \ + pby[count] = Y; \ + count++; + +#include "linetemp.h" + + ctx->PB->count = count; + PB_CHECK_FLUSH( ctx, ctx->PB ); +} + + + +/* Flat-shaded, RGBA line with Z interpolation/testing */ +static void flat_rgba_z_line( GLcontext *ctx, + GLuint vert0, GLuint vert1, GLuint pvert ) +{ + GLint count; + GLint *pbx = ctx->PB->x; + GLint *pby = ctx->PB->y; + GLdepth *pbz = ctx->PB->z; + GLubyte *color = ctx->VB->Color[pvert]; + PB_SET_COLOR( ctx, ctx->PB, color[0], color[1], color[2], color[3] ); + count = ctx->PB->count; + +#define INTERP_XY 1 +#define INTERP_Z 1 + +#define PLOT(X,Y) \ + pbx[count] = X; \ + pby[count] = Y; \ + pbz[count] = Z; \ + count++; + +#include "linetemp.h" + + ctx->PB->count = count; + PB_CHECK_FLUSH( ctx, ctx->PB ); +} + + + +/* Smooth shaded, color index line */ +static void smooth_ci_line( GLcontext *ctx, + GLuint vert0, GLuint vert1, GLuint pvert ) +{ + GLint count = ctx->PB->count; + GLint *pbx = ctx->PB->x; + GLint *pby = ctx->PB->y; + GLuint *pbi = ctx->PB->i; + +#define INTERP_XY 1 +#define INTERP_INDEX 1 + +#define PLOT(X,Y) \ + pbx[count] = X; \ + pby[count] = Y; \ + pbi[count] = I; \ + count++; + +#include "linetemp.h" + + ctx->PB->count = count; + PB_CHECK_FLUSH( ctx, ctx->PB ); +} + + + +/* Smooth shaded, color index line with Z interpolation/testing */ +static void smooth_ci_z_line( GLcontext *ctx, + GLuint vert0, GLuint vert1, GLuint pvert ) +{ + GLint count = ctx->PB->count; + GLint *pbx = ctx->PB->x; + GLint *pby = ctx->PB->y; + GLdepth *pbz = ctx->PB->z; + GLuint *pbi = ctx->PB->i; + +#define INTERP_XY 1 +#define INTERP_Z 1 +#define INTERP_INDEX 1 + +#define PLOT(X,Y) \ + pbx[count] = X; \ + pby[count] = Y; \ + pbz[count] = Z; \ + pbi[count] = I; \ + count++; + +#include "linetemp.h" + + ctx->PB->count = count; + PB_CHECK_FLUSH( ctx, ctx->PB ); +} + + + +/* Smooth-shaded, RGBA line */ +static void smooth_rgba_line( GLcontext *ctx, + GLuint vert0, GLuint vert1, GLuint pvert ) +{ + GLint count = ctx->PB->count; + GLint *pbx = ctx->PB->x; + GLint *pby = ctx->PB->y; + GLubyte *pbr = ctx->PB->r; + GLubyte *pbg = ctx->PB->g; + GLubyte *pbb = ctx->PB->b; + GLubyte *pba = ctx->PB->a; + +#define INTERP_XY 1 +#define INTERP_RGB 1 +#define INTERP_ALPHA 1 + +#define PLOT(X,Y) \ + pbx[count] = X; \ + pby[count] = Y; \ + pbr[count] = FixedToInt(r0); \ + pbg[count] = FixedToInt(g0); \ + pbb[count] = FixedToInt(b0); \ + pba[count] = FixedToInt(a0); \ + count++; + +#include "linetemp.h" + + ctx->PB->count = count; + PB_CHECK_FLUSH( ctx, ctx->PB ); +} + + + +/* Smooth-shaded, RGBA line with Z interpolation/testing */ +static void smooth_rgba_z_line( GLcontext *ctx, + GLuint vert0, GLuint vert1, GLuint pvert ) +{ + GLint count = ctx->PB->count; + GLint *pbx = ctx->PB->x; + GLint *pby = ctx->PB->y; + GLdepth *pbz = ctx->PB->z; + GLubyte *pbr = ctx->PB->r; + GLubyte *pbg = ctx->PB->g; + GLubyte *pbb = ctx->PB->b; + GLubyte *pba = ctx->PB->a; + +#define INTERP_XY 1 +#define INTERP_Z 1 +#define INTERP_RGB 1 +#define INTERP_ALPHA 1 + +#define PLOT(X,Y) \ + pbx[count] = X; \ + pby[count] = Y; \ + pbz[count] = Z; \ + pbr[count] = FixedToInt(r0); \ + pbg[count] = FixedToInt(g0); \ + pbb[count] = FixedToInt(b0); \ + pba[count] = FixedToInt(a0); \ + count++; + +#include "linetemp.h" + + ctx->PB->count = count; + PB_CHECK_FLUSH( ctx, ctx->PB ); +} + + +#define CHECK_FULL(count) \ + if (count >= PB_SIZE-MAX_WIDTH) { \ + ctx->PB->count = count; \ + gl_flush_pb(ctx); \ + count = ctx->PB->count; \ + } + + + +/* Smooth shaded, color index, any width, maybe stippled */ +static void general_smooth_ci_line( GLcontext *ctx, + GLuint vert0, GLuint vert1, GLuint pvert ) +{ + GLint count = ctx->PB->count; + GLint *pbx = ctx->PB->x; + GLint *pby = ctx->PB->y; + GLdepth *pbz = ctx->PB->z; + GLuint *pbi = ctx->PB->i; + + if (ctx->Line.StippleFlag) { + /* stippled */ +#define INTERP_XY 1 +#define INTERP_Z 1 +#define INTERP_INDEX 1 +#define WIDE 1 +#define STIPPLE 1 +#define PLOT(X,Y) \ + pbx[count] = X; \ + pby[count] = Y; \ + pbz[count] = Z; \ + pbi[count] = I; \ + count++; \ + CHECK_FULL(count); +#include "linetemp.h" + } + else { + /* unstippled */ + if (ctx->Line.Width==2.0F) { + /* special case: unstippled and width=2 */ +#define INTERP_XY 1 +#define INTERP_Z 1 +#define INTERP_INDEX 1 +#define XMAJOR_PLOT(X,Y) \ + pbx[count] = X; pbx[count+1] = X; \ + pby[count] = Y; pby[count+1] = Y+1; \ + pbz[count] = Z; pbz[count+1] = Z; \ + pbi[count] = I; pbi[count+1] = I; \ + count += 2; +#define YMAJOR_PLOT(X,Y) \ + pbx[count] = X; pbx[count+1] = X+1; \ + pby[count] = Y; pby[count+1] = Y; \ + pbz[count] = Z; pbz[count+1] = Z; \ + pbi[count] = I; pbi[count+1] = I; \ + count += 2; +#include "linetemp.h" + } + else { + /* unstippled, any width */ +#define INTERP_XY 1 +#define INTERP_Z 1 +#define INTERP_INDEX 1 +#define WIDE 1 +#define PLOT(X,Y) \ + pbx[count] = X; \ + pby[count] = Y; \ + pbz[count] = Z; \ + pbi[count] = I; \ + count++; \ + CHECK_FULL(count); +#include "linetemp.h" + } + } + + ctx->PB->count = count; + PB_CHECK_FLUSH( ctx, ctx->PB ); +} + + +/* Flat shaded, color index, any width, maybe stippled */ +static void general_flat_ci_line( GLcontext *ctx, + GLuint vert0, GLuint vert1, GLuint pvert ) +{ + GLint count; + GLint *pbx = ctx->PB->x; + GLint *pby = ctx->PB->y; + GLdepth *pbz = ctx->PB->z; + PB_SET_INDEX( ctx, ctx->PB, ctx->VB->Index[pvert] ); + count = ctx->PB->count; + + if (ctx->Line.StippleFlag) { + /* stippled, any width */ +#define INTERP_XY 1 +#define INTERP_Z 1 +#define WIDE 1 +#define STIPPLE 1 +#define PLOT(X,Y) \ + pbx[count] = X; \ + pby[count] = Y; \ + pbz[count] = Z; \ + count++; \ + CHECK_FULL(count); +#include "linetemp.h" + } + else { + /* unstippled */ + if (ctx->Line.Width==2.0F) { + /* special case: unstippled and width=2 */ +#define INTERP_XY 1 +#define INTERP_Z 1 +#define XMAJOR_PLOT(X,Y) \ + pbx[count] = X; pbx[count+1] = X; \ + pby[count] = Y; pby[count+1] = Y+1; \ + pbz[count] = Z; pbz[count+1] = Z; \ + count += 2; +#define YMAJOR_PLOT(X,Y) \ + pbx[count] = X; pbx[count+1] = X+1; \ + pby[count] = Y; pby[count+1] = Y; \ + pbz[count] = Z; pbz[count+1] = Z; \ + count += 2; +#include "linetemp.h" + } + else { + /* unstippled, any width */ +#define INTERP_XY 1 +#define INTERP_Z 1 +#define WIDE 1 +#define PLOT(X,Y) \ + pbx[count] = X; \ + pby[count] = Y; \ + pbz[count] = Z; \ + count++; \ + CHECK_FULL(count); +#include "linetemp.h" + } + } + + ctx->PB->count = count; + PB_CHECK_FLUSH( ctx, ctx->PB ); +} + + + +static void general_smooth_rgba_line( GLcontext *ctx, + GLuint vert0, GLuint vert1, GLuint pvert) +{ + GLint count = ctx->PB->count; + GLint *pbx = ctx->PB->x; + GLint *pby = ctx->PB->y; + GLdepth *pbz = ctx->PB->z; + GLubyte *pbr = ctx->PB->r; + GLubyte *pbg = ctx->PB->g; + GLubyte *pbb = ctx->PB->b; + GLubyte *pba = ctx->PB->a; + + TRACE("Line %3.1f, %3.1f, %3.1f (r%u, g%u, b%u) --> %3.1f, %3.1f, %3.1f (r%u, g%u, b%u)\n", + ctx->VB->Win[vert0][0], ctx->VB->Win[vert0][1], ctx->VB->Win[vert0][2], ctx->VB->Color[vert0][0], ctx->VB->Color[vert0][1], ctx->VB->Color[vert0][2], + ctx->VB->Win[vert1][0], ctx->VB->Win[vert1][1], ctx->VB->Win[vert1][2], ctx->VB->Color[vert1][0], ctx->VB->Color[vert1][1], ctx->VB->Color[vert1][2]); + + if (ctx->Line.StippleFlag) { + /* stippled */ +#define INTERP_XY 1 +#define INTERP_Z 1 +#define INTERP_RGB 1 +#define INTERP_ALPHA 1 +#define WIDE 1 +#define STIPPLE 1 +#define PLOT(X,Y) \ + pbx[count] = X; \ + pby[count] = Y; \ + pbz[count] = Z; \ + pbr[count] = FixedToInt(r0); \ + pbg[count] = FixedToInt(g0); \ + pbb[count] = FixedToInt(b0); \ + pba[count] = FixedToInt(a0); \ + count++; \ + CHECK_FULL(count); +#include "linetemp.h" + } + else { + /* unstippled */ + if (ctx->Line.Width==2.0F) { + /* special case: unstippled and width=2 */ +#define INTERP_XY 1 +#define INTERP_Z 1 +#define INTERP_RGB 1 +#define INTERP_ALPHA 1 +#define XMAJOR_PLOT(X,Y) \ + pbx[count] = X; pbx[count+1] = X; \ + pby[count] = Y; pby[count+1] = Y+1; \ + pbz[count] = Z; pbz[count+1] = Z; \ + pbr[count] = FixedToInt(r0); pbr[count+1] = FixedToInt(r0); \ + pbg[count] = FixedToInt(g0); pbg[count+1] = FixedToInt(g0); \ + pbb[count] = FixedToInt(b0); pbb[count+1] = FixedToInt(b0); \ + pba[count] = FixedToInt(a0); pba[count+1] = FixedToInt(a0); \ + count += 2; +#define YMAJOR_PLOT(X,Y) \ + pbx[count] = X; pbx[count+1] = X+1; \ + pby[count] = Y; pby[count+1] = Y; \ + pbz[count] = Z; pbz[count+1] = Z; \ + pbr[count] = FixedToInt(r0); pbr[count+1] = FixedToInt(r0); \ + pbg[count] = FixedToInt(g0); pbg[count+1] = FixedToInt(g0); \ + pbb[count] = FixedToInt(b0); pbb[count+1] = FixedToInt(b0); \ + pba[count] = FixedToInt(a0); pba[count+1] = FixedToInt(a0); \ + count += 2; +#include "linetemp.h" + } + else { + /* unstippled, any width */ +#define INTERP_XY 1 +#define INTERP_Z 1 +#define INTERP_RGB 1 +#define INTERP_ALPHA 1 +#define WIDE 1 +#define PLOT(X,Y) \ + pbx[count] = X; \ + pby[count] = Y; \ + pbz[count] = Z; \ + pbr[count] = FixedToInt(r0); \ + pbg[count] = FixedToInt(g0); \ + pbb[count] = FixedToInt(b0); \ + pba[count] = FixedToInt(a0); \ + count++; \ + CHECK_FULL(count); +#include "linetemp.h" + } + } + + ctx->PB->count = count; + PB_CHECK_FLUSH( ctx, ctx->PB ); +} + + +static void general_flat_rgba_line( GLcontext *ctx, + GLuint vert0, GLuint vert1, GLuint pvert ) +{ + GLint count; + GLint *pbx = ctx->PB->x; + GLint *pby = ctx->PB->y; + GLdepth *pbz = ctx->PB->z; + GLubyte *color = ctx->VB->Color[pvert]; + PB_SET_COLOR( ctx, ctx->PB, color[0], color[1], color[2], color[3] ); + count = ctx->PB->count; + + if (ctx->Line.StippleFlag) { + /* stippled */ +#define INTERP_XY 1 +#define INTERP_Z 1 +#define WIDE 1 +#define STIPPLE 1 +#define PLOT(X,Y) \ + pbx[count] = X; \ + pby[count] = Y; \ + pbz[count] = Z; \ + count++; \ + CHECK_FULL(count); +#include "linetemp.h" + } + else { + /* unstippled */ + if (ctx->Line.Width==2.0F) { + /* special case: unstippled and width=2 */ +#define INTERP_XY 1 +#define INTERP_Z 1 +#define XMAJOR_PLOT(X,Y) \ + pbx[count] = X; pbx[count+1] = X; \ + pby[count] = Y; pby[count+1] = Y+1; \ + pbz[count] = Z; pbz[count+1] = Z; \ + count += 2; +#define YMAJOR_PLOT(X,Y) \ + pbx[count] = X; pbx[count+1] = X+1; \ + pby[count] = Y; pby[count+1] = Y; \ + pbz[count] = Z; pbz[count+1] = Z; \ + count += 2; +#include "linetemp.h" + } + else { + /* unstippled, any width */ +#define INTERP_XY 1 +#define INTERP_Z 1 +#define WIDE 1 +#define PLOT(X,Y) \ + pbx[count] = X; \ + pby[count] = Y; \ + pbz[count] = Z; \ + count++; \ + CHECK_FULL(count); +#include "linetemp.h" + } + } + + ctx->PB->count = count; + PB_CHECK_FLUSH( ctx, ctx->PB ); +} + + + +/* Flat-shaded, textured, any width, maybe stippled */ +static void flat_textured_line( GLcontext *ctx, + GLuint vert0, GLuint vert1, GLuint pv ) +{ + GLint count; + GLint *pbx = ctx->PB->x; + GLint *pby = ctx->PB->y; + GLdepth *pbz = ctx->PB->z; + GLfloat *pbs = ctx->PB->s; + GLfloat *pbt = ctx->PB->t; + GLfloat *pbu = ctx->PB->u; + GLubyte *color = ctx->VB->Color[pv]; + PB_SET_COLOR( ctx, ctx->PB, color[0], color[1], color[2], color[3] ); + count = ctx->PB->count; + + if (ctx->Line.StippleFlag) { + /* stippled */ +#define INTERP_XY 1 +#define INTERP_Z 1 +#define INTERP_STW 1 +#define INTERP_UV 1 +#define WIDE 1 +#define STIPPLE 1 +#define PLOT(X,Y) \ + pbx[count] = X; \ + pby[count] = Y; \ + pbz[count] = Z; \ + pbs[count] = s0 / w0; \ + pbt[count] = t0 / w0; \ + pbu[count] = u0 / w0; \ + count++; \ + CHECK_FULL(count); +#include "linetemp.h" + } + else { + /* unstippled */ +#define INTERP_XY 1 +#define INTERP_Z 1 +#define INTERP_STW 1 +#define INTERP_UV 1 +#define WIDE 1 +#define PLOT(X,Y) \ + pbx[count] = X; \ + pby[count] = Y; \ + pbz[count] = Z; \ + pbs[count] = s0 / w0; \ + pbt[count] = t0 / w0; \ + pbu[count] = u0 / w0; \ + count++; \ + CHECK_FULL(count); +#include "linetemp.h" + } + + ctx->PB->count = count; + PB_CHECK_FLUSH( ctx, ctx->PB ); +} + + + +/* Smooth-shaded, textured, any width, maybe stippled */ +static void smooth_textured_line( GLcontext *ctx, + GLuint vert0, GLuint vert1, GLuint pv ) +{ + GLint count = ctx->PB->count; + GLint *pbx = ctx->PB->x; + GLint *pby = ctx->PB->y; + GLdepth *pbz = ctx->PB->z; + GLfloat *pbs = ctx->PB->s; + GLfloat *pbt = ctx->PB->t; + GLfloat *pbu = ctx->PB->u; + GLubyte *pbr = ctx->PB->r; + GLubyte *pbg = ctx->PB->g; + GLubyte *pbb = ctx->PB->b; + GLubyte *pba = ctx->PB->a; + + if (ctx->Line.StippleFlag) { + /* stippled */ +#define INTERP_XY 1 +#define INTERP_Z 1 +#define INTERP_RGB 1 +#define INTERP_ALPHA 1 +#define INTERP_STW 1 +#define INTERP_UV 1 +#define WIDE 1 +#define STIPPLE 1 +#define PLOT(X,Y) \ + pbx[count] = X; \ + pby[count] = Y; \ + pbz[count] = Z; \ + pbs[count] = s0 / w0; \ + pbt[count] = t0 / w0; \ + pbu[count] = u0 / w0; \ + pbr[count] = FixedToInt(r0); \ + pbg[count] = FixedToInt(g0); \ + pbb[count] = FixedToInt(b0); \ + pba[count] = FixedToInt(a0); \ + count++; \ + CHECK_FULL(count); +#include "linetemp.h" + } + else { + /* unstippled */ +#define INTERP_XY 1 +#define INTERP_Z 1 +#define INTERP_RGB 1 +#define INTERP_ALPHA 1 +#define INTERP_STW 1 +#define INTERP_UV 1 +#define WIDE 1 +#define PLOT(X,Y) \ + pbx[count] = X; \ + pby[count] = Y; \ + pbz[count] = Z; \ + pbs[count] = s0 / w0; \ + pbt[count] = t0 / w0; \ + pbu[count] = u0 / w0; \ + pbr[count] = FixedToInt(r0); \ + pbg[count] = FixedToInt(g0); \ + pbb[count] = FixedToInt(b0); \ + pba[count] = FixedToInt(a0); \ + count++; \ + CHECK_FULL(count); +#include "linetemp.h" + } + + ctx->PB->count = count; + PB_CHECK_FLUSH( ctx, ctx->PB ); +} + + + +/* + * Null rasterizer for measuring transformation speed. + */ +static void null_line( GLcontext *ctx, GLuint v1, GLuint v2, GLuint pv ) +{ +} + + + +/* + * Determine which line drawing function to use given the current + * rendering context. + */ +void gl_set_line_function( GLcontext *ctx ) +{ + GLboolean rgbmode = ctx->Visual->RGBAflag; + /* TODO: antialiased lines */ + + if (ctx->RenderMode==GL_RENDER) { + if (ctx->NoRaster) { + ctx->Driver.LineFunc = null_line; + return; + } + if (ctx->Driver.LineFunc) { + /* Device driver will draw lines. */ + ctx->Driver.LineFunc = ctx->Driver.LineFunc; + } + else if (ctx->Texture.Enabled) { + if (ctx->Light.ShadeModel==GL_SMOOTH) { + ctx->Driver.LineFunc = smooth_textured_line; + } + else { + ctx->Driver.LineFunc = flat_textured_line; + } + } + else if (ctx->Line.Width!=1.0 || ctx->Line.StippleFlag + || ctx->Line.SmoothFlag || ctx->Texture.Enabled) { + if (ctx->Light.ShadeModel==GL_SMOOTH) { + if (rgbmode) + ctx->Driver.LineFunc = general_smooth_rgba_line; + else + ctx->Driver.LineFunc = general_smooth_ci_line; + } + else { + if (rgbmode) + ctx->Driver.LineFunc = general_flat_rgba_line; + else + ctx->Driver.LineFunc = general_flat_ci_line; + } + } + else { + if (ctx->Light.ShadeModel==GL_SMOOTH) { + /* Width==1, non-stippled, smooth-shaded */ + if (ctx->Depth.Test + || (ctx->Fog.Enabled && ctx->Hint.Fog==GL_NICEST)) { + if (rgbmode) + ctx->Driver.LineFunc = smooth_rgba_z_line; + else + ctx->Driver.LineFunc = smooth_ci_z_line; + } + else { + if (rgbmode) + ctx->Driver.LineFunc = smooth_rgba_line; + else + ctx->Driver.LineFunc = smooth_ci_line; + } + } + else { + /* Width==1, non-stippled, flat-shaded */ + if (ctx->Depth.Test + || (ctx->Fog.Enabled && ctx->Hint.Fog==GL_NICEST)) { + if (rgbmode) + ctx->Driver.LineFunc = flat_rgba_z_line; + else + ctx->Driver.LineFunc = flat_ci_z_line; + } + else { + if (rgbmode) + ctx->Driver.LineFunc = flat_rgba_line; + else + ctx->Driver.LineFunc = flat_ci_line; + } + } + } + } + else if (ctx->RenderMode==GL_FEEDBACK) { + ctx->Driver.LineFunc = feedback_line; + } + else { + /* GL_SELECT mode */ + ctx->Driver.LineFunc = select_line; + } +} + diff --git a/dll/opengl/mesa/lines.h b/dll/opengl/mesa/lines.h new file mode 100644 index 00000000000..48161b9f9c8 --- /dev/null +++ b/dll/opengl/mesa/lines.h @@ -0,0 +1,46 @@ +/* $Id: lines.h,v 1.1 1996/09/13 01:38:16 brianp Exp $ */ + +/* + * Mesa 3-D graphics library + * Version: 2.0 + * Copyright (C) 1995-1996 Brian Paul + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Library General Public + * License as published by the Free Software Foundation; either + * version 2 of the License, or (at your option) any later version. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Library General Public License for more details. + * + * You should have received a copy of the GNU Library General Public + * License along with this library; if not, write to the Free + * Software Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. + */ + + +/* + * $Log: lines.h,v $ + * Revision 1.1 1996/09/13 01:38:16 brianp + * Initial revision + * + */ + + +#ifndef LINES_H +#define LINES_H + + +#include "types.h" + + +extern void gl_LineWidth( GLcontext *ctx, GLfloat width ); + +extern void gl_LineStipple( GLcontext *ctx, GLint factor, GLushort pattern ); + +extern void gl_set_line_function( GLcontext *ctx ); + + +#endif diff --git a/dll/opengl/mesa/linetemp.h b/dll/opengl/mesa/linetemp.h new file mode 100644 index 00000000000..4c3b1b3ae09 --- /dev/null +++ b/dll/opengl/mesa/linetemp.h @@ -0,0 +1,502 @@ +/* $Id: linetemp.h,v 1.4 1998/01/16 03:46:07 brianp Exp $ */ + +/* + * Mesa 3-D graphics library + * Version: 2.6 + * Copyright (C) 1995-1997 Brian Paul + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Library General Public + * License as published by the Free Software Foundation; either + * version 2 of the License, or (at your option) any later version. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Library General Public License for more details. + * + * You should have received a copy of the GNU Library General Public + * License along with this library; if not, write to the Free + * Software Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. + */ + + +/* + * $Log: linetemp.h,v $ + * Revision 1.4 1998/01/16 03:46:07 brianp + * fixed a few Windows compilation warnings (Theodore Jump) + * + * Revision 1.3 1997/06/20 02:49:53 brianp + * changed color components from GLfixed to GLubyte + * + * Revision 1.2 1997/05/16 01:54:54 brianp + * zPtrYstep calculation was negated! + * + * Revision 1.1 1997/03/16 02:07:56 brianp + * Initial revision + * + */ + + +/* + * Line Rasterizer Template + * + * This file is #include'd to generate custom line rasterizers. + * + * The following macros may be defined to indicate what auxillary information + * must be interplated along the line: + * INTERP_Z - if defined, interpolate Z values + * INTERP_RGB - if defined, interpolate RGB values + * INTERP_ALPHA - if defined, interpolate Alpha values + * INTERP_INDEX - if defined, interpolate color index values + * INTERP_ST - if defined, interpolate integer ST texcoords + * (fast, simple 2-D texture mapping) + * INTERP_STW - if defined, interpolate float ST texcoords and W + * (2-D texture maps with perspective correction) + * INTERP_UV - if defined, interpolate float UV texcoords too + * (for 3-D, 4-D? texture maps) + * + * When one can directly address pixels in the color buffer the following + * macros can be defined and used to directly compute pixel addresses during + * rasterization (see pixelPtr): + * PIXEL_TYPE - the datatype of a pixel (GLubyte, GLushort, GLuint) + * BYTES_PER_ROW - number of bytes per row in the color buffer + * PIXEL_ADDRESS(X,Y) - returns the address of pixel at (X,Y) where + * Y==0 at bottom of screen and increases upward. + * + * Optionally, one may provide one-time setup code + * SETUP_CODE - code which is to be executed once per line + * + * To enable line stippling define STIPPLE = 1 + * To enable wide lines define WIDE = 1 + * + * To actually "plot" each pixel either the PLOT macro or + * (XMAJOR_PLOT and YMAJOR_PLOT macros) must be defined... + * PLOT(X,Y) - code to plot a pixel. Example: + * if (Z < *zPtr) { + * *zPtr = Z; + * color = pack_rgb( FixedToInt(r0), FixedToInt(g0), + * FixedToInt(b0) ); + * put_pixel( X, Y, color ); + * } + * + * This code was designed for the origin to be in the lower-left corner. + * + */ + + +/*void line( GLcontext *ctx, GLuint vert0, GLuint vert1, GLuint pvert )*/ +{ + struct vertex_buffer *VB = ctx->VB; +/* + GLint x0 = (GLint) VB->Win[vert0][0], dx = (GLint) VB->Win[vert1][0] - x0; + GLint y0 = (GLint) VB->Win[vert0][1], dy = (GLint) VB->Win[vert1][1] - y0; +*/ + GLint x0 = (GLint) VB->Win[vert0][0], x1 = (GLint) VB->Win[vert1][0]; + GLint y0 = (GLint) VB->Win[vert0][1], y1 = (GLint) VB->Win[vert1][1]; + GLint dx, dy; +#if INTERP_XY + GLint xstep, ystep; +#endif +#if INTERP_Z + GLint z0, z1, dz, zPtrXstep, zPtrYstep; + GLdepth *zPtr; +#endif +#if INTERP_RGB + GLfixed r0 = IntToFixed(VB->Color[vert0][0]); + GLfixed dr = IntToFixed(VB->Color[vert1][0]) - r0; + GLfixed g0 = IntToFixed(VB->Color[vert0][1]); + GLfixed dg = IntToFixed(VB->Color[vert1][1]) - g0; + GLfixed b0 = IntToFixed(VB->Color[vert0][2]); + GLfixed db = IntToFixed(VB->Color[vert1][2]) - b0; +#endif +#if INTERP_ALPHA + GLfixed a0 = IntToFixed(VB->Color[vert0][3]); + GLfixed da = IntToFixed(VB->Color[vert1][3]) - a0; +#endif +#if INTERP_INDEX + GLint i0 = VB->Index[vert0] << 8, di = (GLint) (VB->Index[vert1] << 8)-i0; +#endif +#if INTERP_ST + GLfixed s0 = FloatToFixed(VB->TexCoord[vert0][0] * S_SCALE); + GLfixed ds = FloatToFixed(VB->TexCoord[vert1][0] * S_SCALE) - s0; + GLfixed t0 = FloatToFixed(VB->TexCoord[vert0][1] * T_SCALE); + GLfixed dt = FloatToFixed(VB->TexCoord[vert1][1] * T_SCALE) - t0; +#endif +#if INTERP_STW + GLfloat s0 = VB->TexCoord[vert0][0], ds = VB->TexCoord[vert1][0] - s0; + GLfloat t0 = VB->TexCoord[vert0][1], dt = VB->TexCoord[vert1][1] - t0; + GLfloat w0 = 1.0F / VB->Clip[vert0][3], dw = 1.0F / VB->Clip[vert1][3] - w0; +#endif +#if INTERP_UV + GLfloat u0 = VB->TexCoord[vert0][2], du = VB->TexCoord[vert1][2] - u0; + GLfloat v0 = VB->TexCoord[vert0][3], dv = VB->TexCoord[vert1][3] - v0; +#endif +#ifdef PIXEL_ADDRESS + PIXEL_TYPE *pixelPtr; + GLint pixelXstep, pixelYstep; +#endif + +#if WIDE + GLint width, min, max; + width = (GLint) CLAMP( ctx->Line.Width, MIN_LINE_WIDTH, MAX_LINE_WIDTH ); + min = -width / 2; + max = min + width - 1; +#endif + +/* + * Despite being clipped to the view volume, the line's window coordinates + * may just lie outside the window bounds. That is, if the legal window + * coordinates are [0,W-1][0,H-1], it's possible for x==W and/or y==H. + * This quick and dirty code nudges the endpoints inside the window if + * necessary. + */ +#if CLIP_HACK + { + GLint w = ctx->Buffer->Width; + GLint h = ctx->Buffer->Height; + if ((x0==w) | (x1==w)) { + if ((x0==w) & (x1==w)) + return; + x0 -= x0==w; + x1 -= x1==w; + } + if ((y0==h) | (y1==h)) { + if ((y0==h) & (y1==h)) + return; + y0 -= y0==h; + y1 -= y1==h; + } + } +#endif + dx = x1 - x0; + dy = y1 - y0; + if (dx==0 && dy==0) { + return; + } + + /* + * Setup + */ +#ifdef SETUP_CODE + SETUP_CODE +#endif + +#if INTERP_Z + zPtr = Z_ADDRESS(ctx,x0,y0); + z0 = (int) VB->Win[vert0][2]; + z1 = (int) VB->Win[vert1][2]; +#endif +#ifdef PIXEL_ADDRESS + pixelPtr = (PIXEL_TYPE *) PIXEL_ADDRESS(x0,y0); +#endif + + if (dx<0) { + dx = -dx; /* make positive */ +#if INTERP_XY + xstep = -1; +#endif +#ifdef INTERP_Z + zPtrXstep = -((GLint)sizeof(GLdepth)); +#endif +#ifdef PIXEL_ADDRESS + pixelXstep = -sizeof(PIXEL_TYPE); +#endif + } + else { +#if INTERP_XY + xstep = 1; +#endif +#if INTERP_Z + zPtrXstep = sizeof(GLdepth); +#endif +#ifdef PIXEL_ADDRESS + pixelXstep = sizeof(PIXEL_TYPE); +#endif + } + + if (dy<0) { + dy = -dy; /* make positive */ +#if INTERP_XY + ystep = -1; +#endif +#if INTERP_Z + zPtrYstep = -ctx->Buffer->Width * sizeof(GLdepth); +#endif +#ifdef PIXEL_ADDRESS + pixelYstep = BYTES_PER_ROW; +#endif + } + else { +#if INTERP_XY + ystep = 1; +#endif +#if INTERP_Z + zPtrYstep = ctx->Buffer->Width * sizeof(GLdepth); +#endif +#ifdef PIXEL_ADDRESS + pixelYstep = -(BYTES_PER_ROW); +#endif + } + + /* + * Draw + */ + + if (dx>dy) { + /* + * X-major line + */ + GLint i; + GLint errorInc = dy+dy; + GLint error = errorInc-dx; + GLint errorDec = error-dx; +#if INTERP_Z + dz = (z1-z0) / dx; +#endif +#if INTERP_RGB + dr /= dx; /* convert from whole line delta to per-pixel delta */ + dg /= dx; + db /= dx; +#endif +#if INTERP_ALPHA + da /= dx; +#endif +#if INTERP_INDEX + di /= dx; +#endif +#if INTERP_ST + ds /= dx; + dt /= dx; +#endif +#if INTERP_STW + { + GLfloat fdxinv = 1.0F / (GLfloat) dx; + ds *= fdxinv; + dt *= fdxinv; + dw *= fdxinv; +#if INTERP_UV + du *= fdxinv; + dv *= fdxinv; +#endif + } +#endif + for (i=0;iStippleCounter/ctx->Line.StippleFactor) & 0xf); + if (ctx->Line.StipplePattern & m) { +#endif +#if INTERP_Z + GLdepth Z = z0; +#endif +#if INTERP_INDEX + GLint I = i0 >> 8; +#endif +#if WIDE + GLint yy; + GLint ymin = y0 + min; + GLint ymax = y0 + max; + for (yy=ymin;yy<=ymax;yy++) { + PLOT( x0, yy ); + } +#else +# ifdef XMAJOR_PLOT + XMAJOR_PLOT( x0, y0 ); +# else + PLOT( x0, y0 ); +# endif +#endif /*WIDE*/ +#if STIPPLE + } + ctx->StippleCounter++; +#endif +#if INTERP_XY + x0 += xstep; +#endif +#if INTERP_Z + zPtr = (GLdepth *) ((GLubyte*) zPtr + zPtrXstep); + z0 += dz; +#endif +#if INTERP_RGB + r0 += dr; + g0 += dg; + b0 += db; +#endif +#if INTERP_ALPHA + a0 += da; +#endif +#if INTERP_INDEX + i0 += di; +#endif +#if INTERP_ST + s0 += ds; + t0 += dt; +#endif +#if INTERP_STW + s0 += ds; + t0 += dt; + w0 += dw; +#endif +#if INTERP_UV + u0 += du; + v0 += dv; +#endif +#ifdef PIXEL_ADDRESS + pixelPtr = (PIXEL_TYPE*) ((GLubyte*) pixelPtr + pixelXstep); +#endif + if (error<0) { + error += errorInc; + } + else { + error += errorDec; +#if INTERP_XY + y0 += ystep; +#endif +#if INTERP_Z + zPtr = (GLdepth *) ((GLubyte*) zPtr + zPtrYstep); +#endif +#ifdef PIXEL_ADDRESS + pixelPtr = (PIXEL_TYPE*) ((GLubyte*) pixelPtr + pixelYstep); +#endif + } + } + } + else { + /* + * Y-major line + */ + GLint i; + GLint errorInc = dx+dx; + GLint error = errorInc-dy; + GLint errorDec = error-dy; +#if INTERP_Z + dz = (z1-z0) / dy; +#endif +#if INTERP_RGB + dr /= dy; /* convert from whole line delta to per-pixel delta */ + dg /= dy; + db /= dy; +#endif +#if INTERP_ALPHA + da /= dy; +#endif +#if INTERP_INDEX + di /= dy; +#endif +#if INTERP_ST + ds /= dy; + dt /= dy; +#endif +#if INTERP_STW + { + GLfloat fdyinv = 1.0F / (GLfloat) dy; + ds *= fdyinv; + dt *= fdyinv; + dw *= fdyinv; +#if INTERP_UV + du *= fdyinv; + dv *= fdyinv; +#endif + } +#endif + for (i=0;iStippleCounter/ctx->Line.StippleFactor) & 0xf); + if (ctx->Line.StipplePattern & m) { +#endif +#if INTERP_Z + GLdepth Z = z0; +#endif +#if INTERP_INDEX + GLint I = i0 >> 8; +#endif +#if WIDE + GLint xx; + GLint xmin = x0 + min; + GLint xmax = x0 + max; + for (xx=xmin;xx<=xmax;xx++) { + PLOT( xx, y0 ); + } +#else +# ifdef YMAJOR_PLOT + YMAJOR_PLOT( x0, y0 ); +# else + PLOT( x0, y0 ); +# endif +#endif /*WIDE*/ +#if STIPPLE + } + ctx->StippleCounter++; +#endif +#if INTERP_XY + y0 += ystep; +#endif +#if INTERP_Z + zPtr = (GLdepth *) ((GLubyte*) zPtr + zPtrYstep); + z0 += dz; +#endif +#if INTERP_RGB + r0 += dr; + g0 += dg; + b0 += db; +#endif +#if INTERP_ALPHA + a0 += da; +#endif +#if INTERP_INDEX + i0 += di; +#endif +#if INTERP_ST + s0 += ds; + t0 += dt; +#endif +#if INTERP_STW + s0 += ds; + t0 += dt; + w0 += dw; +#endif +#if INTERP_UV + u0 += du; + v0 += dv; +#endif +#ifdef PIXEL_ADDRESS + pixelPtr = (PIXEL_TYPE*) ((GLubyte*) pixelPtr + pixelYstep); +#endif + if (error<0) { + error += errorInc; + } + else { + error += errorDec; +#if INTERP_XY + x0 += xstep; +#endif +#if INTERP_Z + zPtr = (GLdepth *) ((GLubyte*) zPtr + zPtrXstep); +#endif +#ifdef PIXEL_ADDRESS + pixelPtr = (PIXEL_TYPE*) ((GLubyte*) pixelPtr + pixelXstep); +#endif + } + } + } + +} + + +#undef INTERP_XY +#undef INTERP_Z +#undef INTERP_RGB +#undef INTERP_ALPHA +#undef INTERP_INDEX +#undef PIXEL_ADDRESS +#undef PIXEL_TYPE +#undef BYTES_PER_ROW +#undef SETUP_CODE +#undef PLOT +#undef XMAJOR_PLOT +#undef YMAJOR_PLOT +#undef CLIP_HACK +#undef STIPPLE +#undef WIDE diff --git a/dll/opengl/mesa/logic.c b/dll/opengl/mesa/logic.c new file mode 100644 index 00000000000..e49a3d31586 --- /dev/null +++ b/dll/opengl/mesa/logic.c @@ -0,0 +1,726 @@ +/* $Id: logic.c,v 1.7 1997/07/24 01:24:11 brianp Exp $ */ + +/* + * Mesa 3-D graphics library + * Version: 2.4 + * Copyright (C) 1995-1997 Brian Paul + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Library General Public + * License as published by the Free Software Foundation; either + * version 2 of the License, or (at your option) any later version. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Library General Public License for more details. + * + * You should have received a copy of the GNU Library General Public + * License along with this library; if not, write to the Free + * Software Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. + */ + + +/* + * $Log: logic.c,v $ + * Revision 1.7 1997/07/24 01:24:11 brianp + * changed precompiled header symbol from PCH to PC_HEADER + * + * Revision 1.6 1997/05/28 03:25:26 brianp + * added precompiled header (PCH) support + * + * Revision 1.5 1997/04/20 20:28:49 brianp + * replaced abort() with gl_problem() + * + * Revision 1.4 1997/03/04 18:56:57 brianp + * added #include for abort() + * + * Revision 1.3 1997/01/28 22:16:31 brianp + * added gl_logicop_rgba_span() and gl_logicop_rgba_pixels() + * + * Revision 1.2 1997/01/04 00:13:11 brianp + * was using ! instead of ~ to invert pixel bits (ugh!) + * + * Revision 1.1 1996/09/13 01:38:16 brianp + * Initial revision + * + */ + + +#ifdef PC_HEADER +#include "all.h" +#else +#include +#include "alphabuf.h" +#include "context.h" +#include "dlist.h" +#include "logic.h" +#include "macros.h" +#include "pb.h" +#include "span.h" +#include "types.h" +#endif + + + +void gl_LogicOp( GLcontext *ctx, GLenum opcode ) +{ + if (INSIDE_BEGIN_END(ctx)) { + gl_error( ctx, GL_INVALID_OPERATION, "glLogicOp" ); + return; + } + switch (opcode) { + case GL_CLEAR: + case GL_SET: + case GL_COPY: + case GL_COPY_INVERTED: + case GL_NOOP: + case GL_INVERT: + case GL_AND: + case GL_NAND: + case GL_OR: + case GL_NOR: + case GL_XOR: + case GL_EQUIV: + case GL_AND_REVERSE: + case GL_AND_INVERTED: + case GL_OR_REVERSE: + case GL_OR_INVERTED: + ctx->Color.LogicOp = opcode; + ctx->NewState |= NEW_RASTER_OPS; + return; + default: + gl_error( ctx, GL_INVALID_ENUM, "glLogicOp" ); + return; + } +} + + + + +/* + * Apply the current logic operator to a span of CI pixels. This is only + * used if the device driver can't do logic ops. + */ +void gl_logicop_ci_span( GLcontext *ctx, GLuint n, GLint x, GLint y, + GLuint index[], GLubyte mask[] ) +{ + GLuint dest[MAX_WIDTH]; + GLuint i; + + /* Read dest values from frame buffer */ + (*ctx->Driver.ReadIndexSpan)( ctx, n, x, y, dest ); + + switch (ctx->Color.LogicOp) { + case GL_CLEAR: + for (i=0;iDriver.ReadIndexPixels)( ctx, n, x, y, dest, mask ); + + switch (ctx->Color.LogicOp) { + case GL_CLEAR: + for (i=0;iColor.LogicOp) { + case GL_CLEAR: + for (i=0;iVisual->RedScale; + GLubyte g = (GLint) ctx->Visual->GreenScale; + GLubyte b = (GLint) ctx->Visual->BlueScale; + GLubyte a = (GLint) ctx->Visual->AlphaScale; + for (i=0;iDriver.ReadColorPixels)( ctx, n, x, y, rdest, gdest, bdest, adest, mask ); + if (ctx->RasterMask & ALPHABUF_BIT) { + gl_read_alpha_pixels( ctx, n, x, y, adest, mask ); + } + + /* apply logic op */ + switch (ctx->Color.LogicOp) { + case GL_CLEAR: + for (i=0;iVisual->RedScale; + GLubyte g = (GLint) ctx->Visual->GreenScale; + GLubyte b = (GLint) ctx->Visual->BlueScale; + GLubyte a = (GLint) ctx->Visual->AlphaScale; + for (i=0;i +#include + + +#ifdef DEBUG +# include +# define ASSERT(X) assert(X) +#else +# define ASSERT(X) +#endif + + +/* Limits: */ +#define MAX_GLUSHORT 0xffff +#define MAX_GLUINT 0xffffffff + + + +/* Copy short vectors: */ + +#define COPY_2V( DST, SRC ) DST[0] = SRC[0]; \ + DST[1] = SRC[1]; + +#define COPY_3V( DST, SRC ) DST[0] = SRC[0]; \ + DST[1] = SRC[1]; \ + DST[2] = SRC[2]; + +#define COPY_4V( DST, SRC ) DST[0] = SRC[0]; \ + DST[1] = SRC[1]; \ + DST[2] = SRC[2]; \ + DST[3] = SRC[3]; + +/* + * Copy a vector of 4 GLubytes from SRC to DST. + */ +#define COPY_4UBV(DST, SRC) \ + if (sizeof(GLuint)==4*sizeof(GLubyte)) { \ + *((GLuint*)(DST)) = *((GLuint*)(SRC)); \ + } \ + else { \ + (DST)[0] = (SRC)[0]; \ + (DST)[1] = (SRC)[1]; \ + (DST)[2] = (SRC)[2]; \ + (DST)[3] = (SRC)[3]; \ + } + + + +/* Assign scalers to short vectors: */ +#define ASSIGN_2V( V, V0, V1 ) V[0] = V0; V[1] = V1; + +#define ASSIGN_3V( V, V0, V1, V2 ) V[0] = V0; V[1] = V1; V[2] = V2; + +#define ASSIGN_4V( V, V0, V1, V2, V3 ) V[0] = V0; \ + V[1] = V1; \ + V[2] = V2; \ + V[3] = V3; + + +/* Test if we're inside a glBegin / glEnd pair: */ +#define INSIDE_BEGIN_END(CTX) ((CTX)->Primitive!=GL_BITMAP) + + + +/* Absolute value (for Int, Float, Double): */ +#define ABSI(X) ((X) < 0 ? -(X) : (X)) +#define ABSF(X) ((X) < 0.0F ? -(X) : (X)) +#define ABSD(X) ((X) < 0.0 ? -(X) : (X)) + + + +/* Round a floating-point value to the nearest integer: */ +#define ROUNDF(X) ( (X)<0.0F ? ((GLint) ((X)-0.5F)) : ((GLint) ((X)+0.5F)) ) + + +/* Compute ceiling of integer quotient of A divided by B: */ +#define CEILING( A, B ) ( (A) % (B) == 0 ? (A)/(B) : (A)/(B)+1 ) + + +/* Clamp X to [MIN,MAX]: */ +#define CLAMP( X, MIN, MAX ) ( (X)<(MIN) ? (MIN) : ((X)>(MAX) ? (MAX) : (X)) ) + + +/* Min of two values: */ +#define MIN2( A, B ) ( (A)<(B) ? (A) : (B) ) + + +/* MAX of two values: */ +#define MAX2( A, B ) ( (A)>(B) ? (A) : (B) ) + + +/* Dot product of two 3-element vectors */ +#define DOT3( a, b ) ( a[0]*b[0] + a[1]*b[1] + a[2]*b[2] ) + + +/* Dot product of two 4-element vectors */ +#define DOT4( a, b ) ( a[0]*b[0] + a[1]*b[1] + a[2]*b[2] + a[3]*b[3] ) + + + +/* + * Integer / float conversion for colors, normals, etc. + */ + +/* Convert GLubyte in [0,255] to GLfloat in [0.0,1.0] */ +#define UBYTE_TO_FLOAT(B) ((GLfloat) (B) * (1.0F / 255.0F)) + +/* Convert GLfloat in [0.0,1.0] to GLubyte in [0,255] */ +#define FLOAT_TO_UBYTE(X) ((GLubyte) (GLint) (((X)) * 255.0F)) + + +/* Convert GLbyte in [-128,127] to GLfloat in [-1.0,1.0] */ +#define BYTE_TO_FLOAT(B) ((2.0F * (B) + 1.0F) * (1.0F/255.0F)) + +/* Convert GLfloat in [-1.0,1.0] to GLbyte in [-128,127] */ +#define FLOAT_TO_BYTE(X) ( (((GLint) (255.0F * (X))) - 1) / 2 ) + + +/* Convert GLushort in [0,65536] to GLfloat in [0.0,1.0] */ +#define USHORT_TO_FLOAT(S) ((GLfloat) (S) * (1.0F / 65535.0F)) + +/* Convert GLfloat in [0.0,1.0] to GLushort in [0,65536] */ +#define FLOAT_TO_USHORT(X) ((GLushort) (GLint) ((X) * 65535.0F)) + + +/* Convert GLshort in [-32768,32767] to GLfloat in [-1.0,1.0] */ +#define SHORT_TO_FLOAT(S) ((2.0F * (S) + 1.0F) * (1.0F/65535.0F)) + +/* Convert GLfloat in [0.0,1.0] to GLshort in [-32768,32767] */ +#define FLOAT_TO_SHORT(X) ( (((GLint) (65535.0F * (X))) - 1) / 2 ) + + +/* Convert GLuint in [0,4294967295] to GLfloat in [0.0,1.0] */ +#define UINT_TO_FLOAT(U) ((GLfloat) (U) * (1.0F / 4294967295.0F)) + +/* Convert GLfloat in [0.0,1.0] to GLuint in [0,4294967295] */ +#define FLOAT_TO_UINT(X) ((GLuint) ((X) * 4294967295.0)) + + +/* Convert GLint in [-2147483648,2147483647] to GLfloat in [-1.0,1.0] */ +#define INT_TO_FLOAT(I) ((2.0F * (I) + 1.0F) * (1.0F/4294967294.0F)) + +/* Convert GLfloat in [-1.0,1.0] to GLint in [-2147483648,2147483647] */ +/* causes overflow: +#define FLOAT_TO_INT(X) ( (((GLint) (4294967294.0F * (X))) - 1) / 2 ) +*/ +/* a close approximation: */ +#define FLOAT_TO_INT(X) ( (GLint) (2147483647.0 * (X)) ) + + + +/* Memory copy: */ +#ifdef SUNOS4 +#define MEMCPY( DST, SRC, BYTES) \ + memcpy( (char *) (DST), (char *) (SRC), (int) (BYTES) ) +#else +#define MEMCPY( DST, SRC, BYTES) \ + memcpy( (void *) (DST), (void *) (SRC), (size_t) (BYTES) ) +#endif + + +/* Memory set: */ +#ifdef SUNOS4 +#define MEMSET( DST, VAL, N ) \ + memset( (char *) (DST), (int) (VAL), (int) (N) ) +#else +#define MEMSET( DST, VAL, N ) \ + memset( (void *) (DST), (int) (VAL), (size_t) (N) ) +#endif + + +/* MACs and BeOS don't support static larger than 32kb, so... */ +#if defined(macintosh) && !defined(__MRC__) + extern char *AGLAlloc(int size); + extern void AGLFree(char* ptr); +# define DEFARRAY(TYPE,NAME,SIZE) TYPE *NAME = (TYPE*)AGLAlloc(sizeof(TYPE)*(SIZE)) +# define UNDEFARRAY(NAME) AGLFree((char*)NAME) +#elif defined(__BEOS__) +# define DEFARRAY(TYPE,NAME,SIZE) TYPE *NAME = (TYPE*)malloc(sizeof(TYPE)*(SIZE)) +# define UNDEFARRAY(NAME) free(NAME) +#else +# define DEFARRAY(TYPE,NAME,SIZE) TYPE NAME[SIZE] +# define UNDEFARRAY(NAME) +#endif + + +/* Pi */ +#ifndef M_PI +#define M_PI (3.1415926) +#endif + + +/* Degrees to radians conversion: */ +#define DEG2RAD (M_PI/180.0) + + +#ifndef NULL +#define NULL 0 +#endif + + + +#endif /*MACROS_H*/ diff --git a/dll/opengl/mesa/main/CMakeLists.txt b/dll/opengl/mesa/main/CMakeLists.txt deleted file mode 100644 index bb93340fb44..00000000000 --- a/dll/opengl/mesa/main/CMakeLists.txt +++ /dev/null @@ -1,81 +0,0 @@ - -list(APPEND SOURCE - api_arrayelt.c - api_exec.c - api_loopback.c - api_validate.c - accum.c - attrib.c - blend.c - bufferobj.c - buffers.c - clear.c - clip.c - context.c - cpuinfo.c - depth.c - dlist.c - dlopen.c - drawpix.c - enable.c - enums.c - eval.c - execmem.c - extensions.c - feedback.c - fog.c - formats.c - format_pack.c - format_unpack.c - framebuffer.c - get.c - getstring.c - hash.c - hint.c - image.c - imports.c - light.c - lines.c - matrix.c - mm.c - multisample.c - pack.c - pixel.c - pixelstore.c - pixeltransfer.c - points.c - polygon.c - rastpos.c - readpix.c - renderbuffer.c - scissor.c - shared.c - state.c - stencil.c - texenv.c - texformat.c - texgen.c - texgetimage.c - teximage.c - texobj.c - #texpal.c - texparam.c - texstate.c - texstorage.c - texstore.c - varray.c - version.c - viewport.c - vtxfmt.c - precomp.h) - -add_library(mesa_main STATIC ${SOURCE}) -add_dependencies(mesa_main xdk) -add_pch(mesa_main precomp.h SOURCE) - -if(NOT MSVC) - add_target_compile_flags(mesa_main "-Wno-type-limits") -elseif(USE_CLANG_CL) - add_target_compile_flags(mesa_main "-Wno-cast-calling-convention -Wno-unused-local-typedef") - add_target_compile_flags(mesa_main "-Wno-tautological-unsigned-zero-compare -Wno-constant-conversion") -endif() diff --git a/dll/opengl/mesa/main/accum.c b/dll/opengl/mesa/main/accum.c deleted file mode 100644 index fff26075372..00000000000 --- a/dll/opengl/mesa/main/accum.c +++ /dev/null @@ -1,481 +0,0 @@ -/* - * Mesa 3-D graphics library - * Version: 6.5 - * - * Copyright (C) 1999-2005 Brian Paul All Rights Reserved. - * - * Permission is hereby granted, free of charge, to any person obtaining a - * copy of this software and associated documentation files (the "Software"), - * to deal in the Software without restriction, including without limitation - * the rights to use, copy, modify, merge, publish, distribute, sublicense, - * and/or sell copies of the Software, and to permit persons to whom the - * Software is furnished to do so, subject to the following conditions: - * - * The above copyright notice and this permission notice shall be included - * in all copies or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS - * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL - * BRIAN PAUL BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN - * AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN - * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. - */ - -#include - -#if FEATURE_accum - - -void GLAPIENTRY -_mesa_ClearAccum( GLfloat red, GLfloat green, GLfloat blue, GLfloat alpha ) -{ - GLfloat tmp[4]; - GET_CURRENT_CONTEXT(ctx); - ASSERT_OUTSIDE_BEGIN_END(ctx); - - tmp[0] = CLAMP( red, -1.0F, 1.0F ); - tmp[1] = CLAMP( green, -1.0F, 1.0F ); - tmp[2] = CLAMP( blue, -1.0F, 1.0F ); - tmp[3] = CLAMP( alpha, -1.0F, 1.0F ); - - if (TEST_EQ_4V(tmp, ctx->Accum.ClearColor)) - return; - - COPY_4FV( ctx->Accum.ClearColor, tmp ); -} - - -static void GLAPIENTRY -_mesa_Accum( GLenum op, GLfloat value ) -{ - GET_CURRENT_CONTEXT(ctx); - ASSERT_OUTSIDE_BEGIN_END_AND_FLUSH(ctx); - - switch (op) { - case GL_ADD: - case GL_MULT: - case GL_ACCUM: - case GL_LOAD: - case GL_RETURN: - /* OK */ - break; - default: - _mesa_error(ctx, GL_INVALID_ENUM, "glAccum(op)"); - return; - } - - if (ctx->DrawBuffer->Visual.haveAccumBuffer == 0) { - _mesa_error(ctx, GL_INVALID_OPERATION, "glAccum(no accum buffer)"); - return; - } - - if (ctx->DrawBuffer != ctx->ReadBuffer) { - /* See GLX_SGI_make_current_read or WGL_ARB_make_current_read, - * or GL_EXT_framebuffer_blit. - */ - _mesa_error(ctx, GL_INVALID_OPERATION, - "glAccum(different read/draw buffers)"); - return; - } - - if (ctx->NewState) - _mesa_update_state(ctx); - - if (ctx->RasterDiscard) - return; - - if (ctx->RenderMode == GL_RENDER) { - _mesa_accum(ctx, op, value); - } -} - - -void -_mesa_init_accum_dispatch(struct _glapi_table *disp) -{ - SET_Accum(disp, _mesa_Accum); - SET_ClearAccum(disp, _mesa_ClearAccum); -} - - -/** - * Clear the accumulation buffer by mapping the renderbuffer and - * writing the clear color to it. Called by the driver's implementation - * of the glClear function. - */ -void -_mesa_clear_accum_buffer(struct gl_context *ctx) -{ - GLuint x, y, width, height; - GLubyte *accMap; - GLint accRowStride; - struct gl_renderbuffer *accRb; - - if (!ctx->DrawBuffer) - return; - - accRb = ctx->DrawBuffer->Attachment[BUFFER_ACCUM].Renderbuffer; - if (!accRb) - return; /* missing accum buffer, not an error */ - - /* bounds, with scissor */ - x = ctx->DrawBuffer->_Xmin; - y = ctx->DrawBuffer->_Ymin; - width = ctx->DrawBuffer->_Xmax - ctx->DrawBuffer->_Xmin; - height = ctx->DrawBuffer->_Ymax - ctx->DrawBuffer->_Ymin; - - ctx->Driver.MapRenderbuffer(ctx, accRb, x, y, width, height, - GL_MAP_WRITE_BIT, &accMap, &accRowStride); - - if (!accMap) { - _mesa_error(ctx, GL_OUT_OF_MEMORY, "glAccum"); - return; - } - - if (accRb->Format == MESA_FORMAT_SIGNED_RGBA_16) { - const GLshort clearR = FLOAT_TO_SHORT(ctx->Accum.ClearColor[0]); - const GLshort clearG = FLOAT_TO_SHORT(ctx->Accum.ClearColor[1]); - const GLshort clearB = FLOAT_TO_SHORT(ctx->Accum.ClearColor[2]); - const GLshort clearA = FLOAT_TO_SHORT(ctx->Accum.ClearColor[3]); - GLuint i, j; - - for (j = 0; j < height; j++) { - GLshort *row = (GLshort *) accMap; - - for (i = 0; i < width; i++) { - row[i * 4 + 0] = clearR; - row[i * 4 + 1] = clearG; - row[i * 4 + 2] = clearB; - row[i * 4 + 3] = clearA; - } - accMap += accRowStride; - } - } - else { - /* other types someday? */ - _mesa_warning(ctx, "unexpected accum buffer type"); - } - - ctx->Driver.UnmapRenderbuffer(ctx, accRb); -} - - -/** - * if (bias) - * Accum += value - * else - * Accum *= value - */ -static void -accum_scale_or_bias(struct gl_context *ctx, GLfloat value, - GLint xpos, GLint ypos, GLint width, GLint height, - GLboolean bias) -{ - struct gl_renderbuffer *accRb = - ctx->DrawBuffer->Attachment[BUFFER_ACCUM].Renderbuffer; - GLubyte *accMap; - GLint accRowStride; - - assert(accRb); - - ctx->Driver.MapRenderbuffer(ctx, accRb, xpos, ypos, width, height, - GL_MAP_READ_BIT | GL_MAP_WRITE_BIT, - &accMap, &accRowStride); - - if (!accMap) { - _mesa_error(ctx, GL_OUT_OF_MEMORY, "glAccum"); - return; - } - - if (accRb->Format == MESA_FORMAT_SIGNED_RGBA_16) { - const GLshort incr = (GLshort) (value * 32767.0f); - GLuint i, j; - if (bias) { - for (j = 0; j < height; j++) { - GLshort *acc = (GLshort *) accMap; - for (i = 0; i < 4 * width; i++) { - acc[i] += incr; - } - accMap += accRowStride; - } - } - else { - /* scale */ - for (j = 0; j < height; j++) { - GLshort *acc = (GLshort *) accMap; - for (i = 0; i < 4 * width; i++) { - acc[i] = (GLshort) (acc[i] * value); - } - accMap += accRowStride; - } - } - } - else { - /* other types someday? */ - } - - ctx->Driver.UnmapRenderbuffer(ctx, accRb); -} - - -/** - * if (load) - * Accum = ColorBuf * value - * else - * Accum += ColorBuf * value - */ -static void -accum_or_load(struct gl_context *ctx, GLfloat value, - GLint xpos, GLint ypos, GLint width, GLint height, - GLboolean load) -{ - struct gl_renderbuffer *accRb = - ctx->DrawBuffer->Attachment[BUFFER_ACCUM].Renderbuffer; - struct gl_renderbuffer *colorRb = ctx->ReadBuffer->_ColorReadBuffer; - GLubyte *accMap, *colorMap; - GLint accRowStride, colorRowStride; - GLbitfield mappingFlags; - - if (!colorRb) { - /* no read buffer - OK */ - return; - } - - assert(accRb); - - mappingFlags = GL_MAP_WRITE_BIT; - if (!load) /* if we're accumulating */ - mappingFlags |= GL_MAP_READ_BIT; - - /* Map accum buffer */ - ctx->Driver.MapRenderbuffer(ctx, accRb, xpos, ypos, width, height, - mappingFlags, &accMap, &accRowStride); - if (!accMap) { - _mesa_error(ctx, GL_OUT_OF_MEMORY, "glAccum"); - return; - } - - /* Map color buffer */ - ctx->Driver.MapRenderbuffer(ctx, colorRb, xpos, ypos, width, height, - GL_MAP_READ_BIT, - &colorMap, &colorRowStride); - if (!colorMap) { - ctx->Driver.UnmapRenderbuffer(ctx, accRb); - _mesa_error(ctx, GL_OUT_OF_MEMORY, "glAccum"); - return; - } - - if (accRb->Format == MESA_FORMAT_SIGNED_RGBA_16) { - const GLfloat scale = value * 32767.0f; - GLuint i, j; - GLfloat (*rgba)[4]; - - rgba = (GLfloat (*)[4]) malloc(width * 4 * sizeof(GLfloat)); - if (rgba) { - for (j = 0; j < height; j++) { - GLshort *acc = (GLshort *) accMap; - - /* read colors from source color buffer */ - _mesa_unpack_rgba_row(colorRb->Format, width, colorMap, rgba); - - if (load) { - for (i = 0; i < width; i++) { - acc[i * 4 + 0] = (GLshort) (rgba[i][RCOMP] * scale); - acc[i * 4 + 1] = (GLshort) (rgba[i][GCOMP] * scale); - acc[i * 4 + 2] = (GLshort) (rgba[i][BCOMP] * scale); - acc[i * 4 + 3] = (GLshort) (rgba[i][ACOMP] * scale); - } - } - else { - /* accumulate */ - for (i = 0; i < width; i++) { - acc[i * 4 + 0] += (GLshort) (rgba[i][RCOMP] * scale); - acc[i * 4 + 1] += (GLshort) (rgba[i][GCOMP] * scale); - acc[i * 4 + 2] += (GLshort) (rgba[i][BCOMP] * scale); - acc[i * 4 + 3] += (GLshort) (rgba[i][ACOMP] * scale); - } - } - - colorMap += colorRowStride; - accMap += accRowStride; - } - - free(rgba); - } - else { - _mesa_error(ctx, GL_OUT_OF_MEMORY, "glAccum"); - } - } - else { - /* other types someday? */ - } - - ctx->Driver.UnmapRenderbuffer(ctx, accRb); - ctx->Driver.UnmapRenderbuffer(ctx, colorRb); -} - - -/** - * ColorBuffer = Accum * value - */ -static void -accum_return(struct gl_context *ctx, GLfloat value, - GLint xpos, GLint ypos, GLint width, GLint height) -{ - struct gl_framebuffer *fb = ctx->DrawBuffer; - struct gl_renderbuffer *accRb = fb->Attachment[BUFFER_ACCUM].Renderbuffer; - GLubyte *accMap, *colorMap; - GLint accRowStride, colorRowStride; - struct gl_renderbuffer *colorRb = fb->_ColorDrawBuffer; - const GLboolean masking = (!ctx->Color.ColorMask[RCOMP] || - !ctx->Color.ColorMask[GCOMP] || - !ctx->Color.ColorMask[BCOMP] || - !ctx->Color.ColorMask[ACOMP]); - GLbitfield mappingFlags = GL_MAP_WRITE_BIT; - - /* Map accum buffer */ - ctx->Driver.MapRenderbuffer(ctx, accRb, xpos, ypos, width, height, - GL_MAP_READ_BIT, - &accMap, &accRowStride); - if (!accMap) { - _mesa_error(ctx, GL_OUT_OF_MEMORY, "glAccum"); - return; - } - - if (masking) - mappingFlags |= GL_MAP_READ_BIT; - - /* Map color buffer */ - ctx->Driver.MapRenderbuffer(ctx, colorRb, xpos, ypos, width, height, - mappingFlags, &colorMap, &colorRowStride); - if (!colorMap) { - _mesa_error(ctx, GL_OUT_OF_MEMORY, "glAccum"); - ctx->Driver.UnmapRenderbuffer(ctx, accRb); - return; - } - - if (accRb->Format == MESA_FORMAT_SIGNED_RGBA_16) { - const GLfloat scale = value / 32767.0f; - GLint i, j; - GLfloat (*rgba)[4], (*dest)[4]; - - rgba = (GLfloat (*)[4]) malloc(width * 4 * sizeof(GLfloat)); - dest = (GLfloat (*)[4]) malloc(width * 4 * sizeof(GLfloat)); - - if (rgba && dest) { - for (j = 0; j < height; j++) { - GLshort *acc = (GLshort *) accMap; - - for (i = 0; i < width; i++) { - rgba[i][0] = acc[i * 4 + 0] * scale; - rgba[i][1] = acc[i * 4 + 1] * scale; - rgba[i][2] = acc[i * 4 + 2] * scale; - rgba[i][3] = acc[i * 4 + 3] * scale; - } - - if (masking) { - - /* get existing colors from dest buffer */ - _mesa_unpack_rgba_row(colorRb->Format, width, colorMap, dest); - - /* use the dest colors where mask[channel] = 0 */ - if (ctx->Color.ColorMask[RCOMP] == 0) { - for (i = 0; i < width; i++) - rgba[i][RCOMP] = dest[i][RCOMP]; - } - if (ctx->Color.ColorMask[GCOMP] == 0) { - for (i = 0; i < width; i++) - rgba[i][GCOMP] = dest[i][GCOMP]; - } - if (ctx->Color.ColorMask[BCOMP] == 0) { - for (i = 0; i < width; i++) - rgba[i][BCOMP] = dest[i][BCOMP]; - } - if (ctx->Color.ColorMask[ACOMP] == 0) { - for (i = 0; i < width; i++) - rgba[i][ACOMP] = dest[i][ACOMP]; - } - } - - _mesa_pack_float_rgba_row(colorRb->Format, width, - (const GLfloat (*)[4]) rgba, colorMap); - - accMap += accRowStride; - colorMap += colorRowStride; - } - } - else { - _mesa_error(ctx, GL_OUT_OF_MEMORY, "glAccum"); - } - free(rgba); - free(dest); - } - else { - /* other types someday? */ - } - - ctx->Driver.UnmapRenderbuffer(ctx, colorRb); - ctx->Driver.UnmapRenderbuffer(ctx, accRb); -} - - - -/** - * Software fallback for glAccum. A hardware driver that supports - * signed 16-bit color channels could implement hardware accumulation - * operations, but no driver does so at this time. - */ -void -_mesa_accum(struct gl_context *ctx, GLenum op, GLfloat value) -{ - GLint xpos, ypos, width, height; - - if (!ctx->DrawBuffer->Attachment[BUFFER_ACCUM].Renderbuffer) { - _mesa_warning(ctx, "Calling glAccum() without an accumulation buffer"); - return; - } - - xpos = ctx->DrawBuffer->_Xmin; - ypos = ctx->DrawBuffer->_Ymin; - width = ctx->DrawBuffer->_Xmax - ctx->DrawBuffer->_Xmin; - height = ctx->DrawBuffer->_Ymax - ctx->DrawBuffer->_Ymin; - - switch (op) { - case GL_ADD: - if (value != 0.0F) { - accum_scale_or_bias(ctx, value, xpos, ypos, width, height, GL_TRUE); - } - break; - case GL_MULT: - if (value != 1.0F) { - accum_scale_or_bias(ctx, value, xpos, ypos, width, height, GL_FALSE); - } - break; - case GL_ACCUM: - if (value != 0.0F) { - accum_or_load(ctx, value, xpos, ypos, width, height, GL_FALSE); - } - break; - case GL_LOAD: - accum_or_load(ctx, value, xpos, ypos, width, height, GL_TRUE); - break; - case GL_RETURN: - accum_return(ctx, value, xpos, ypos, width, height); - break; - default: - _mesa_problem(ctx, "invalid mode in _mesa_accum()"); - break; - } -} - - -#endif /* FEATURE_accum */ - - -void -_mesa_init_accum( struct gl_context *ctx ) -{ - /* Accumulate buffer group */ - ASSIGN_4V( ctx->Accum.ClearColor, 0.0, 0.0, 0.0, 0.0 ); -} diff --git a/dll/opengl/mesa/main/accum.h b/dll/opengl/mesa/main/accum.h deleted file mode 100644 index 5b3f06aa9f1..00000000000 --- a/dll/opengl/mesa/main/accum.h +++ /dev/null @@ -1,93 +0,0 @@ -/** - * \file accum.h - * Accumulation buffer operations. - * - * \if subset - * (No-op) - * - * \endif - */ - -/* - * Mesa 3-D graphics library - * Version: 3.5 - * - * Copyright (C) 1999-2001 Brian Paul All Rights Reserved. - * - * Permission is hereby granted, free of charge, to any person obtaining a - * copy of this software and associated documentation files (the "Software"), - * to deal in the Software without restriction, including without limitation - * the rights to use, copy, modify, merge, publish, distribute, sublicense, - * and/or sell copies of the Software, and to permit persons to whom the - * Software is furnished to do so, subject to the following conditions: - * - * The above copyright notice and this permission notice shall be included - * in all copies or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS - * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL - * BRIAN PAUL BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN - * AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN - * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. - */ - - - -#ifndef ACCUM_H -#define ACCUM_H - -#include "main/glheader.h" -#include "main/mfeatures.h" - -struct _glapi_table; -struct gl_context; -struct gl_renderbuffer; - -#if FEATURE_accum - -extern void GLAPIENTRY -_mesa_ClearAccum( GLfloat red, GLfloat green, GLfloat blue, GLfloat alpha ); - -extern void -_mesa_init_accum_dispatch(struct _glapi_table *disp); - -extern void -_mesa_accum(struct gl_context *ctx, GLenum op, GLfloat value); - -extern void -_mesa_clear_accum_buffer(struct gl_context *ctx); - -#else /* FEATURE_accum */ - -#include "main/compiler.h" - -static inline void -_mesa_ClearAccum( GLfloat red, GLfloat green, GLfloat blue, GLfloat alpha ) -{ - /* this is used in _mesa_PopAttrib */ - ASSERT_NO_FEATURE(); -} - -static inline void -_mesa_init_accum_dispatch(struct _glapi_table *disp) -{ -} - -static inline void -_mesa_accum(struct gl_context *ctx, GLenum op, GLfloat value) -{ -} - -static inline void -_mesa_clear_accum_buffer(struct gl_context *ctx) -{ -} - - -#endif /* FEATURE_accum */ - -extern void -_mesa_init_accum( struct gl_context *ctx ); - -#endif /* ACCUM_H */ diff --git a/dll/opengl/mesa/main/api_arrayelt.c b/dll/opengl/mesa/main/api_arrayelt.c deleted file mode 100644 index 1fa1d41b67d..00000000000 --- a/dll/opengl/mesa/main/api_arrayelt.c +++ /dev/null @@ -1,910 +0,0 @@ -/* - * Mesa 3-D graphics library - * Version: 6.5.1 - * - * Copyright (C) 1999-2006 Brian Paul All Rights Reserved. - * - * Permission is hereby granted, free of charge, to any person obtaining a - * copy of this software and associated documentation files (the "Software"), - * to deal in the Software without restriction, including without limitation - * the rights to use, copy, modify, merge, publish, distribute, sublicense, - * and/or sell copies of the Software, and to permit persons to whom the - * Software is furnished to do so, subject to the following conditions: - * - * The above copyright notice and this permission notice shall be included - * in all copies or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS - * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL - * BRIAN PAUL BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN - * AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN - * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. - */ - -/** - * This file implements the glArrayElement() function. - * It involves looking at the format/type of all the enabled vertex arrays - * and emitting a list of pointers to functions which set the per-vertex - * state for the element/index. - */ - - -/* Author: - * Keith Whitwell - */ - -#include - -typedef void (GLAPIENTRY *array_func)( const void * ); - -typedef struct { - const struct gl_client_array *array; - int offset; -} AEarray; - -typedef void (GLAPIENTRY *attrib_func)( GLuint indx, const void *data ); - -typedef struct { - const struct gl_client_array *array; - attrib_func func; - GLuint index; -} AEattrib; - -typedef struct { - AEarray arrays[32]; - AEattrib attribs[VERT_ATTRIB_MAX + 1]; - GLuint NewState; - - struct gl_buffer_object *vbo[VERT_ATTRIB_MAX]; - GLuint nr_vbos; - GLboolean mapped_vbos; - -} AEcontext; - -#define AE_CONTEXT(ctx) ((AEcontext *)(ctx)->aelt_context) - - -/* - * Convert GL_BYTE, GL_UNSIGNED_BYTE, .. GL_DOUBLE into an integer - * in the range [0, 7]. Luckily these type tokens are sequentially - * numbered in gl.h, except for GL_DOUBLE. - */ -#define TYPE_IDX(t) ( (t) == GL_DOUBLE ? 7 : (t) & 7 ) - -#define NUM_TYPES 8 - - -#if FEATURE_arrayelt - - -static const int ColorFuncs[2][NUM_TYPES] = { - { - _gloffset_Color3bv, - _gloffset_Color3ubv, - _gloffset_Color3sv, - _gloffset_Color3usv, - _gloffset_Color3iv, - _gloffset_Color3uiv, - _gloffset_Color3fv, - _gloffset_Color3dv, - }, - { - _gloffset_Color4bv, - _gloffset_Color4ubv, - _gloffset_Color4sv, - _gloffset_Color4usv, - _gloffset_Color4iv, - _gloffset_Color4uiv, - _gloffset_Color4fv, - _gloffset_Color4dv, - }, -}; - -static const int VertexFuncs[3][NUM_TYPES] = { - { - -1, - -1, - _gloffset_Vertex2sv, - -1, - _gloffset_Vertex2iv, - -1, - _gloffset_Vertex2fv, - _gloffset_Vertex2dv, - }, - { - -1, - -1, - _gloffset_Vertex3sv, - -1, - _gloffset_Vertex3iv, - -1, - _gloffset_Vertex3fv, - _gloffset_Vertex3dv, - }, - { - -1, - -1, - _gloffset_Vertex4sv, - -1, - _gloffset_Vertex4iv, - -1, - _gloffset_Vertex4fv, - _gloffset_Vertex4dv, - }, -}; - -static const int IndexFuncs[NUM_TYPES] = { - -1, - _gloffset_Indexubv, - _gloffset_Indexsv, - -1, - _gloffset_Indexiv, - -1, - _gloffset_Indexfv, - _gloffset_Indexdv, -}; - -static const int NormalFuncs[NUM_TYPES] = { - _gloffset_Normal3bv, - -1, - _gloffset_Normal3sv, - -1, - _gloffset_Normal3iv, - -1, - _gloffset_Normal3fv, - _gloffset_Normal3dv, -}; - -/* Note: _gloffset_* for these may not be a compile-time constant. */ -static int FogCoordFuncs[NUM_TYPES]; - - -/** - ** GL_NV_vertex_program - **/ - -/* GL_BYTE attributes */ - -static void GLAPIENTRY -VertexAttrib1NbvNV(GLuint index, const GLbyte *v) -{ - CALL_VertexAttrib1fNV(GET_DISPATCH(), (index, BYTE_TO_FLOAT(v[0]))); -} - -static void GLAPIENTRY -VertexAttrib1bvNV(GLuint index, const GLbyte *v) -{ - CALL_VertexAttrib1fNV(GET_DISPATCH(), (index, (GLfloat)v[0])); -} - -static void GLAPIENTRY -VertexAttrib2NbvNV(GLuint index, const GLbyte *v) -{ - CALL_VertexAttrib2fNV(GET_DISPATCH(), (index, BYTE_TO_FLOAT(v[0]), BYTE_TO_FLOAT(v[1]))); -} - -static void GLAPIENTRY -VertexAttrib2bvNV(GLuint index, const GLbyte *v) -{ - CALL_VertexAttrib2fNV(GET_DISPATCH(), (index, (GLfloat)v[0], (GLfloat)v[1])); -} - -static void GLAPIENTRY -VertexAttrib3NbvNV(GLuint index, const GLbyte *v) -{ - CALL_VertexAttrib3fNV(GET_DISPATCH(), (index, BYTE_TO_FLOAT(v[0]), - BYTE_TO_FLOAT(v[1]), - BYTE_TO_FLOAT(v[2]))); -} - -static void GLAPIENTRY -VertexAttrib3bvNV(GLuint index, const GLbyte *v) -{ - CALL_VertexAttrib3fNV(GET_DISPATCH(), (index, (GLfloat)v[0], (GLfloat)v[1], (GLfloat)v[2])); -} - -static void GLAPIENTRY -VertexAttrib4NbvNV(GLuint index, const GLbyte *v) -{ - CALL_VertexAttrib4fNV(GET_DISPATCH(), (index, BYTE_TO_FLOAT(v[0]), - BYTE_TO_FLOAT(v[1]), - BYTE_TO_FLOAT(v[2]), - BYTE_TO_FLOAT(v[3]))); -} - -static void GLAPIENTRY -VertexAttrib4bvNV(GLuint index, const GLbyte *v) -{ - CALL_VertexAttrib4fNV(GET_DISPATCH(), (index, (GLfloat)v[0], (GLfloat)v[1], (GLfloat)v[2], (GLfloat)v[3])); -} - -/* GL_UNSIGNED_BYTE attributes */ - -static void GLAPIENTRY -VertexAttrib1NubvNV(GLuint index, const GLubyte *v) -{ - CALL_VertexAttrib1fNV(GET_DISPATCH(), (index, UBYTE_TO_FLOAT(v[0]))); -} - -static void GLAPIENTRY -VertexAttrib1ubvNV(GLuint index, const GLubyte *v) -{ - CALL_VertexAttrib1fNV(GET_DISPATCH(), (index, (GLfloat)v[0])); -} - -static void GLAPIENTRY -VertexAttrib2NubvNV(GLuint index, const GLubyte *v) -{ - CALL_VertexAttrib2fNV(GET_DISPATCH(), (index, UBYTE_TO_FLOAT(v[0]), - UBYTE_TO_FLOAT(v[1]))); -} - -static void GLAPIENTRY -VertexAttrib2ubvNV(GLuint index, const GLubyte *v) -{ - CALL_VertexAttrib2fNV(GET_DISPATCH(), (index, (GLfloat)v[0], (GLfloat)v[1])); -} - -static void GLAPIENTRY -VertexAttrib3NubvNV(GLuint index, const GLubyte *v) -{ - CALL_VertexAttrib3fNV(GET_DISPATCH(), (index, UBYTE_TO_FLOAT(v[0]), - UBYTE_TO_FLOAT(v[1]), - UBYTE_TO_FLOAT(v[2]))); -} -static void GLAPIENTRY -VertexAttrib3ubvNV(GLuint index, const GLubyte *v) -{ - CALL_VertexAttrib3fNV(GET_DISPATCH(), (index, (GLfloat)v[0], - (GLfloat)v[1], (GLfloat)v[2])); -} - -static void GLAPIENTRY -VertexAttrib4NubvNV(GLuint index, const GLubyte *v) -{ - CALL_VertexAttrib4fNV(GET_DISPATCH(), (index, UBYTE_TO_FLOAT(v[0]), - UBYTE_TO_FLOAT(v[1]), - UBYTE_TO_FLOAT(v[2]), - UBYTE_TO_FLOAT(v[3]))); -} - -static void GLAPIENTRY -VertexAttrib4ubvNV(GLuint index, const GLubyte *v) -{ - CALL_VertexAttrib4fNV(GET_DISPATCH(), (index, (GLfloat)v[0], - (GLfloat)v[1], (GLfloat)v[2], - (GLfloat)v[3])); -} - -/* GL_SHORT attributes */ - -static void GLAPIENTRY -VertexAttrib1NsvNV(GLuint index, const GLshort *v) -{ - CALL_VertexAttrib1fNV(GET_DISPATCH(), (index, SHORT_TO_FLOAT(v[0]))); -} - -static void GLAPIENTRY -VertexAttrib1svNV(GLuint index, const GLshort *v) -{ - CALL_VertexAttrib1fNV(GET_DISPATCH(), (index, (GLfloat)v[0])); -} - -static void GLAPIENTRY -VertexAttrib2NsvNV(GLuint index, const GLshort *v) -{ - CALL_VertexAttrib2fNV(GET_DISPATCH(), (index, SHORT_TO_FLOAT(v[0]), - SHORT_TO_FLOAT(v[1]))); -} - -static void GLAPIENTRY -VertexAttrib2svNV(GLuint index, const GLshort *v) -{ - CALL_VertexAttrib2fNV(GET_DISPATCH(), (index, (GLfloat)v[0], (GLfloat)v[1])); -} - -static void GLAPIENTRY -VertexAttrib3NsvNV(GLuint index, const GLshort *v) -{ - CALL_VertexAttrib3fNV(GET_DISPATCH(), (index, SHORT_TO_FLOAT(v[0]), - SHORT_TO_FLOAT(v[1]), - SHORT_TO_FLOAT(v[2]))); -} - -static void GLAPIENTRY -VertexAttrib3svNV(GLuint index, const GLshort *v) -{ - CALL_VertexAttrib3fNV(GET_DISPATCH(), (index, (GLfloat)v[0], (GLfloat)v[1], - (GLfloat)v[2])); -} - -static void GLAPIENTRY -VertexAttrib4NsvNV(GLuint index, const GLshort *v) -{ - CALL_VertexAttrib4fNV(GET_DISPATCH(), (index, SHORT_TO_FLOAT(v[0]), - SHORT_TO_FLOAT(v[1]), - SHORT_TO_FLOAT(v[2]), - SHORT_TO_FLOAT(v[3]))); -} - -static void GLAPIENTRY -VertexAttrib4svNV(GLuint index, const GLshort *v) -{ - CALL_VertexAttrib4fNV(GET_DISPATCH(), (index, (GLfloat)v[0], (GLfloat)v[1], - (GLfloat)v[2], (GLfloat)v[3])); -} - -/* GL_UNSIGNED_SHORT attributes */ - -static void GLAPIENTRY -VertexAttrib1NusvNV(GLuint index, const GLushort *v) -{ - CALL_VertexAttrib1fNV(GET_DISPATCH(), (index, USHORT_TO_FLOAT(v[0]))); -} - -static void GLAPIENTRY -VertexAttrib1usvNV(GLuint index, const GLushort *v) -{ - CALL_VertexAttrib1fNV(GET_DISPATCH(), (index, (GLfloat)v[0])); -} - -static void GLAPIENTRY -VertexAttrib2NusvNV(GLuint index, const GLushort *v) -{ - CALL_VertexAttrib2fNV(GET_DISPATCH(), (index, USHORT_TO_FLOAT(v[0]), - USHORT_TO_FLOAT(v[1]))); -} - -static void GLAPIENTRY -VertexAttrib2usvNV(GLuint index, const GLushort *v) -{ - CALL_VertexAttrib2fNV(GET_DISPATCH(), (index, (GLfloat)v[0], - (GLfloat)v[1])); -} - -static void GLAPIENTRY -VertexAttrib3NusvNV(GLuint index, const GLushort *v) -{ - CALL_VertexAttrib3fNV(GET_DISPATCH(), (index, USHORT_TO_FLOAT(v[0]), - USHORT_TO_FLOAT(v[1]), - USHORT_TO_FLOAT(v[2]))); -} - -static void GLAPIENTRY -VertexAttrib3usvNV(GLuint index, const GLushort *v) -{ - CALL_VertexAttrib3fNV(GET_DISPATCH(), (index, (GLfloat)v[0], (GLfloat)v[1], - (GLfloat)v[2])); -} - -static void GLAPIENTRY -VertexAttrib4NusvNV(GLuint index, const GLushort *v) -{ - CALL_VertexAttrib4fNV(GET_DISPATCH(), (index, USHORT_TO_FLOAT(v[0]), - USHORT_TO_FLOAT(v[1]), - USHORT_TO_FLOAT(v[2]), - USHORT_TO_FLOAT(v[3]))); -} - -static void GLAPIENTRY -VertexAttrib4usvNV(GLuint index, const GLushort *v) -{ - CALL_VertexAttrib4fNV(GET_DISPATCH(), (index, (GLfloat)v[0], (GLfloat)v[1], - (GLfloat)v[2], (GLfloat)v[3])); -} - -/* GL_INT attributes */ - -static void GLAPIENTRY -VertexAttrib1NivNV(GLuint index, const GLint *v) -{ - CALL_VertexAttrib1fNV(GET_DISPATCH(), (index, INT_TO_FLOAT(v[0]))); -} - -static void GLAPIENTRY -VertexAttrib1ivNV(GLuint index, const GLint *v) -{ - CALL_VertexAttrib1fNV(GET_DISPATCH(), (index, (GLfloat)v[0])); -} - -static void GLAPIENTRY -VertexAttrib2NivNV(GLuint index, const GLint *v) -{ - CALL_VertexAttrib2fNV(GET_DISPATCH(), (index, INT_TO_FLOAT(v[0]), - INT_TO_FLOAT(v[1]))); -} - -static void GLAPIENTRY -VertexAttrib2ivNV(GLuint index, const GLint *v) -{ - CALL_VertexAttrib2fNV(GET_DISPATCH(), (index, (GLfloat)v[0], (GLfloat)v[1])); -} - -static void GLAPIENTRY -VertexAttrib3NivNV(GLuint index, const GLint *v) -{ - CALL_VertexAttrib3fNV(GET_DISPATCH(), (index, INT_TO_FLOAT(v[0]), - INT_TO_FLOAT(v[1]), - INT_TO_FLOAT(v[2]))); -} - -static void GLAPIENTRY -VertexAttrib3ivNV(GLuint index, const GLint *v) -{ - CALL_VertexAttrib3fNV(GET_DISPATCH(), (index, (GLfloat)v[0], (GLfloat)v[1], - (GLfloat)v[2])); -} - -static void GLAPIENTRY -VertexAttrib4NivNV(GLuint index, const GLint *v) -{ - CALL_VertexAttrib4fNV(GET_DISPATCH(), (index, INT_TO_FLOAT(v[0]), - INT_TO_FLOAT(v[1]), - INT_TO_FLOAT(v[2]), - INT_TO_FLOAT(v[3]))); -} - -static void GLAPIENTRY -VertexAttrib4ivNV(GLuint index, const GLint *v) -{ - CALL_VertexAttrib4fNV(GET_DISPATCH(), (index, (GLfloat)v[0], (GLfloat)v[1], - (GLfloat)v[2], (GLfloat)v[3])); -} - -/* GL_UNSIGNED_INT attributes */ - -static void GLAPIENTRY -VertexAttrib1NuivNV(GLuint index, const GLuint *v) -{ - CALL_VertexAttrib1fNV(GET_DISPATCH(), (index, UINT_TO_FLOAT(v[0]))); -} - -static void GLAPIENTRY -VertexAttrib1uivNV(GLuint index, const GLuint *v) -{ - CALL_VertexAttrib1fNV(GET_DISPATCH(), (index, (GLfloat)v[0])); -} - -static void GLAPIENTRY -VertexAttrib2NuivNV(GLuint index, const GLuint *v) -{ - CALL_VertexAttrib2fNV(GET_DISPATCH(), (index, UINT_TO_FLOAT(v[0]), - UINT_TO_FLOAT(v[1]))); -} - -static void GLAPIENTRY -VertexAttrib2uivNV(GLuint index, const GLuint *v) -{ - CALL_VertexAttrib2fNV(GET_DISPATCH(), (index, (GLfloat)v[0], - (GLfloat)v[1])); -} - -static void GLAPIENTRY -VertexAttrib3NuivNV(GLuint index, const GLuint *v) -{ - CALL_VertexAttrib3fNV(GET_DISPATCH(), (index, UINT_TO_FLOAT(v[0]), - UINT_TO_FLOAT(v[1]), - UINT_TO_FLOAT(v[2]))); -} - -static void GLAPIENTRY -VertexAttrib3uivNV(GLuint index, const GLuint *v) -{ - CALL_VertexAttrib3fNV(GET_DISPATCH(), (index, (GLfloat)v[0], (GLfloat)v[1], - (GLfloat)v[2])); -} - -static void GLAPIENTRY -VertexAttrib4NuivNV(GLuint index, const GLuint *v) -{ - CALL_VertexAttrib4fNV(GET_DISPATCH(), (index, UINT_TO_FLOAT(v[0]), - UINT_TO_FLOAT(v[1]), - UINT_TO_FLOAT(v[2]), - UINT_TO_FLOAT(v[3]))); -} - -static void GLAPIENTRY -VertexAttrib4uivNV(GLuint index, const GLuint *v) -{ - CALL_VertexAttrib4fNV(GET_DISPATCH(), (index, (GLfloat)v[0], (GLfloat)v[1], - (GLfloat)v[2], (GLfloat)v[3])); -} - -/* GL_FLOAT attributes */ - -static void GLAPIENTRY -VertexAttrib1fvNV(GLuint index, const GLfloat *v) -{ - CALL_VertexAttrib1fvNV(GET_DISPATCH(), (index, v)); -} - -static void GLAPIENTRY -VertexAttrib2fvNV(GLuint index, const GLfloat *v) -{ - CALL_VertexAttrib2fvNV(GET_DISPATCH(), (index, v)); -} - -static void GLAPIENTRY -VertexAttrib3fvNV(GLuint index, const GLfloat *v) -{ - CALL_VertexAttrib3fvNV(GET_DISPATCH(), (index, v)); -} - -static void GLAPIENTRY -VertexAttrib4fvNV(GLuint index, const GLfloat *v) -{ - CALL_VertexAttrib4fvNV(GET_DISPATCH(), (index, v)); -} - -/* GL_DOUBLE attributes */ - -static void GLAPIENTRY -VertexAttrib1dvNV(GLuint index, const GLdouble *v) -{ - CALL_VertexAttrib1dvNV(GET_DISPATCH(), (index, v)); -} - -static void GLAPIENTRY -VertexAttrib2dvNV(GLuint index, const GLdouble *v) -{ - CALL_VertexAttrib2dvNV(GET_DISPATCH(), (index, v)); -} - -static void GLAPIENTRY -VertexAttrib3dvNV(GLuint index, const GLdouble *v) -{ - CALL_VertexAttrib3dvNV(GET_DISPATCH(), (index, v)); -} - -static void GLAPIENTRY -VertexAttrib4dvNV(GLuint index, const GLdouble *v) -{ - CALL_VertexAttrib4dvNV(GET_DISPATCH(), (index, v)); -} - - -/* - * Array [size][type] of VertexAttrib functions - */ -static attrib_func AttribFuncsNV[2][4][NUM_TYPES] = { - { - /* non-normalized */ - { - /* size 1 */ - (attrib_func) VertexAttrib1bvNV, - (attrib_func) VertexAttrib1ubvNV, - (attrib_func) VertexAttrib1svNV, - (attrib_func) VertexAttrib1usvNV, - (attrib_func) VertexAttrib1ivNV, - (attrib_func) VertexAttrib1uivNV, - (attrib_func) VertexAttrib1fvNV, - (attrib_func) VertexAttrib1dvNV - }, - { - /* size 2 */ - (attrib_func) VertexAttrib2bvNV, - (attrib_func) VertexAttrib2ubvNV, - (attrib_func) VertexAttrib2svNV, - (attrib_func) VertexAttrib2usvNV, - (attrib_func) VertexAttrib2ivNV, - (attrib_func) VertexAttrib2uivNV, - (attrib_func) VertexAttrib2fvNV, - (attrib_func) VertexAttrib2dvNV - }, - { - /* size 3 */ - (attrib_func) VertexAttrib3bvNV, - (attrib_func) VertexAttrib3ubvNV, - (attrib_func) VertexAttrib3svNV, - (attrib_func) VertexAttrib3usvNV, - (attrib_func) VertexAttrib3ivNV, - (attrib_func) VertexAttrib3uivNV, - (attrib_func) VertexAttrib3fvNV, - (attrib_func) VertexAttrib3dvNV - }, - { - /* size 4 */ - (attrib_func) VertexAttrib4bvNV, - (attrib_func) VertexAttrib4ubvNV, - (attrib_func) VertexAttrib4svNV, - (attrib_func) VertexAttrib4usvNV, - (attrib_func) VertexAttrib4ivNV, - (attrib_func) VertexAttrib4uivNV, - (attrib_func) VertexAttrib4fvNV, - (attrib_func) VertexAttrib4dvNV - } - }, - { - /* normalized (except for float/double) */ - { - /* size 1 */ - (attrib_func) VertexAttrib1NbvNV, - (attrib_func) VertexAttrib1NubvNV, - (attrib_func) VertexAttrib1NsvNV, - (attrib_func) VertexAttrib1NusvNV, - (attrib_func) VertexAttrib1NivNV, - (attrib_func) VertexAttrib1NuivNV, - (attrib_func) VertexAttrib1fvNV, - (attrib_func) VertexAttrib1dvNV - }, - { - /* size 2 */ - (attrib_func) VertexAttrib2NbvNV, - (attrib_func) VertexAttrib2NubvNV, - (attrib_func) VertexAttrib2NsvNV, - (attrib_func) VertexAttrib2NusvNV, - (attrib_func) VertexAttrib2NivNV, - (attrib_func) VertexAttrib2NuivNV, - (attrib_func) VertexAttrib2fvNV, - (attrib_func) VertexAttrib2dvNV - }, - { - /* size 3 */ - (attrib_func) VertexAttrib3NbvNV, - (attrib_func) VertexAttrib3NubvNV, - (attrib_func) VertexAttrib3NsvNV, - (attrib_func) VertexAttrib3NusvNV, - (attrib_func) VertexAttrib3NivNV, - (attrib_func) VertexAttrib3NuivNV, - (attrib_func) VertexAttrib3fvNV, - (attrib_func) VertexAttrib3dvNV - }, - { - /* size 4 */ - (attrib_func) VertexAttrib4NbvNV, - (attrib_func) VertexAttrib4NubvNV, - (attrib_func) VertexAttrib4NsvNV, - (attrib_func) VertexAttrib4NusvNV, - (attrib_func) VertexAttrib4NivNV, - (attrib_func) VertexAttrib4NuivNV, - (attrib_func) VertexAttrib4fvNV, - (attrib_func) VertexAttrib4dvNV - } - } -}; - -/**********************************************************************/ - - -GLboolean _ae_create_context( struct gl_context *ctx ) -{ - if (ctx->aelt_context) - return GL_TRUE; - - FogCoordFuncs[0] = -1; - FogCoordFuncs[1] = -1; - FogCoordFuncs[2] = -1; - FogCoordFuncs[3] = -1; - FogCoordFuncs[4] = -1; - FogCoordFuncs[5] = -1; - FogCoordFuncs[6] = _gloffset_FogCoordfvEXT; - FogCoordFuncs[7] = _gloffset_FogCoorddvEXT; - - ctx->aelt_context = CALLOC( sizeof(AEcontext) ); - if (!ctx->aelt_context) - return GL_FALSE; - - AE_CONTEXT(ctx)->NewState = ~0; - return GL_TRUE; -} - - -void _ae_destroy_context( struct gl_context *ctx ) -{ - if ( AE_CONTEXT( ctx ) ) { - FREE( ctx->aelt_context ); - ctx->aelt_context = NULL; - } -} - -static void check_vbo( AEcontext *actx, - struct gl_buffer_object *vbo ) -{ - if (_mesa_is_bufferobj(vbo) && !_mesa_bufferobj_mapped(vbo)) { - GLuint i; - for (i = 0; i < actx->nr_vbos; i++) - if (actx->vbo[i] == vbo) - return; - assert(actx->nr_vbos < VERT_ATTRIB_MAX); - actx->vbo[actx->nr_vbos++] = vbo; - } -} - - -/** - * Make a list of per-vertex functions to call for each glArrayElement call. - * These functions access the array data (i.e. glVertex, glColor, glNormal, - * etc). - * Note: this may be called during display list construction. - */ -static void _ae_update_state( struct gl_context *ctx ) -{ - AEcontext *actx = AE_CONTEXT(ctx); - AEarray *aa = actx->arrays; - AEattrib *at = actx->attribs; - - actx->nr_vbos = 0; - - /* conventional vertex arrays */ - if (ctx->Array.VertexAttrib[VERT_ATTRIB_COLOR_INDEX].Enabled) { - aa->array = &ctx->Array.VertexAttrib[VERT_ATTRIB_COLOR_INDEX]; - aa->offset = IndexFuncs[TYPE_IDX(aa->array->Type)]; - check_vbo(actx, aa->array->BufferObj); - aa++; - } - if (ctx->Array.VertexAttrib[VERT_ATTRIB_EDGEFLAG].Enabled) { - aa->array = &ctx->Array.VertexAttrib[VERT_ATTRIB_EDGEFLAG]; - aa->offset = _gloffset_EdgeFlagv; - check_vbo(actx, aa->array->BufferObj); - aa++; - } - if (ctx->Array.VertexAttrib[VERT_ATTRIB_NORMAL].Enabled) { - aa->array = &ctx->Array.VertexAttrib[VERT_ATTRIB_NORMAL]; - aa->offset = NormalFuncs[TYPE_IDX(aa->array->Type)]; - check_vbo(actx, aa->array->BufferObj); - aa++; - } - if (ctx->Array.VertexAttrib[VERT_ATTRIB_COLOR].Enabled) { - aa->array = &ctx->Array.VertexAttrib[VERT_ATTRIB_COLOR]; - aa->offset = ColorFuncs[aa->array->Size-3][TYPE_IDX(aa->array->Type)]; - check_vbo(actx, aa->array->BufferObj); - aa++; - } - if (ctx->Array.VertexAttrib[VERT_ATTRIB_FOG].Enabled) { - aa->array = &ctx->Array.VertexAttrib[VERT_ATTRIB_FOG]; - aa->offset = FogCoordFuncs[TYPE_IDX(aa->array->Type)]; - check_vbo(actx, aa->array->BufferObj); - aa++; - } - { - struct gl_client_array *attribArray = &ctx->Array.VertexAttrib[VERT_ATTRIB_TEX]; - if (attribArray->Enabled) { - /* NOTE: we use generic glVertexAttribNV functions here. - * If we ever remove GL_NV_vertex_program this will have to change. - */ - at->array = attribArray; - ASSERT(!at->array->Normalized); - at->func = AttribFuncsNV[at->array->Normalized] - [at->array->Size-1] - [TYPE_IDX(at->array->Type)]; - at->index = VERT_ATTRIB_TEX; - check_vbo(actx, at->array->BufferObj); - at++; - } - } - - /* finally, vertex position */ - if (ctx->Array.VertexAttrib[VERT_ATTRIB_POS].Enabled) { - aa->array = &ctx->Array.VertexAttrib[VERT_ATTRIB_POS]; - aa->offset = VertexFuncs[aa->array->Size-2][TYPE_IDX(aa->array->Type)]; - check_vbo(actx, aa->array->BufferObj); - aa++; - } - - check_vbo(actx, ctx->Array.ElementArrayBufferObj); - - ASSERT(at - actx->attribs <= VERT_ATTRIB_MAX); - ASSERT(aa - actx->arrays < 32); - at->func = NULL; /* terminate the list */ - aa->offset = -1; /* terminate the list */ - - actx->NewState = 0; -} - -void _ae_map_vbos( struct gl_context *ctx ) -{ - AEcontext *actx = AE_CONTEXT(ctx); - GLuint i; - - if (actx->mapped_vbos) - return; - - if (actx->NewState) - _ae_update_state(ctx); - - for (i = 0; i < actx->nr_vbos; i++) - ctx->Driver.MapBufferRange(ctx, 0, - actx->vbo[i]->Size, - GL_MAP_READ_BIT, - actx->vbo[i]); - - if (actx->nr_vbos) - actx->mapped_vbos = GL_TRUE; -} - -void _ae_unmap_vbos( struct gl_context *ctx ) -{ - AEcontext *actx = AE_CONTEXT(ctx); - GLuint i; - - if (!actx->mapped_vbos) - return; - - assert (!actx->NewState); - - for (i = 0; i < actx->nr_vbos; i++) - ctx->Driver.UnmapBuffer(ctx, actx->vbo[i]); - - actx->mapped_vbos = GL_FALSE; -} - - -/** - * Called via glArrayElement() and glDrawArrays(). - * Issue the glNormal, glVertex, glColor, glVertexAttrib, etc functions - * for all enabled vertex arrays (for elt-th element). - * Note: this may be called during display list construction. - */ -void GLAPIENTRY _ae_ArrayElement( GLint elt ) -{ - GET_CURRENT_CONTEXT(ctx); - const AEcontext *actx = AE_CONTEXT(ctx); - const AEarray *aa; - const AEattrib *at; - const struct _glapi_table * const disp = GET_DISPATCH(); - GLboolean do_map; - - if (actx->NewState) { - assert(!actx->mapped_vbos); - _ae_update_state( ctx ); - } - - /* Determine if we need to map/unmap VBOs */ - do_map = actx->nr_vbos && !actx->mapped_vbos; - - if (do_map) - _ae_map_vbos(ctx); - - /* emit generic attribute elements */ - for (at = actx->attribs; at->func; at++) { - const GLubyte *src - = ADD_POINTERS(at->array->BufferObj->Pointer, at->array->Ptr) - + elt * at->array->StrideB; - at->func( at->index, src ); - } - - /* emit conventional arrays elements */ - for (aa = actx->arrays; aa->offset != -1 ; aa++) { - const GLubyte *src - = ADD_POINTERS(aa->array->BufferObj->Pointer, aa->array->Ptr) - + elt * aa->array->StrideB; - CALL_by_offset( disp, (array_func), aa->offset, - ((const void *) src) ); - } - - if (do_map) - _ae_unmap_vbos(ctx); -} - - -void _ae_invalidate_state( struct gl_context *ctx, GLuint new_state ) -{ - AEcontext *actx = AE_CONTEXT(ctx); - - - /* Only interested in this subset of mesa state. Need to prune - * this down as both tnl/ and the drivers can raise statechanges - * for arcane reasons in the middle of seemingly atomic operations - * like DrawElements, over which we'd like to keep a known set of - * arrays and vbo's mapped. - * - * Luckily, neither the drivers nor tnl muck with the state that - * concerns us here: - */ - new_state &= _NEW_ARRAY; - if (new_state) { - assert(!actx->mapped_vbos); - actx->NewState |= new_state; - } -} - - -void _mesa_install_arrayelt_vtxfmt(struct _glapi_table *disp, - const GLvertexformat *vfmt) -{ - SET_ArrayElement(disp, vfmt->ArrayElement); -} - - -#endif /* FEATURE_arrayelt */ diff --git a/dll/opengl/mesa/main/api_arrayelt.h b/dll/opengl/mesa/main/api_arrayelt.h deleted file mode 100644 index 03810c69b5e..00000000000 --- a/dll/opengl/mesa/main/api_arrayelt.h +++ /dev/null @@ -1,84 +0,0 @@ - -/* - * Mesa 3-D graphics library - * Version: 3.5 - * - * Copyright (C) 1999-2001 Brian Paul All Rights Reserved. - * - * Permission is hereby granted, free of charge, to any person obtaining a - * copy of this software and associated documentation files (the "Software"), - * to deal in the Software without restriction, including without limitation - * the rights to use, copy, modify, merge, publish, distribute, sublicense, - * and/or sell copies of the Software, and to permit persons to whom the - * Software is furnished to do so, subject to the following conditions: - * - * The above copyright notice and this permission notice shall be included - * in all copies or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS - * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL - * BRIAN PAUL BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN - * AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN - * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. - */ - - -#ifndef API_ARRAYELT_H -#define API_ARRAYELT_H - - -#include "main/mfeatures.h" -#include "main/mtypes.h" - -#if FEATURE_arrayelt - -#define _MESA_INIT_ARRAYELT_VTXFMT(vfmt, impl) \ - do { \ - (vfmt)->ArrayElement = impl ## ArrayElement; \ - } while (0) - -extern GLboolean _ae_create_context( struct gl_context *ctx ); -extern void _ae_destroy_context( struct gl_context *ctx ); -extern void _ae_invalidate_state( struct gl_context *ctx, GLuint new_state ); -extern void GLAPIENTRY _ae_ArrayElement( GLint elt ); - -/* May optionally be called before a batch of element calls: - */ -extern void _ae_map_vbos( struct gl_context *ctx ); -extern void _ae_unmap_vbos( struct gl_context *ctx ); - -extern void -_mesa_install_arrayelt_vtxfmt(struct _glapi_table *disp, - const GLvertexformat *vfmt); - -#else /* FEATURE_arrayelt */ - -#define _MESA_INIT_ARRAYELT_VTXFMT(vfmt, impl) do { } while (0) - -static inline GLboolean -_ae_create_context( struct gl_context *ctx ) -{ - return GL_TRUE; -} - -static inline void -_ae_destroy_context( struct gl_context *ctx ) -{ -} - -static inline void -_ae_invalidate_state( struct gl_context *ctx, GLuint new_state ) -{ -} - -static inline void -_mesa_install_arrayelt_vtxfmt(struct _glapi_table *disp, - const GLvertexformat *vfmt) -{ -} - -#endif /* FEATURE_arrayelt */ - - -#endif /* API_ARRAYELT_H */ diff --git a/dll/opengl/mesa/main/api_exec.c b/dll/opengl/mesa/main/api_exec.c deleted file mode 100644 index 3e597024e94..00000000000 --- a/dll/opengl/mesa/main/api_exec.c +++ /dev/null @@ -1,306 +0,0 @@ -/* - * Mesa 3-D graphics library - * Version: 7.1 - * - * Copyright (C) 1999-2008 Brian Paul All Rights Reserved. - * - * Permission is hereby granted, free of charge, to any person obtaining a - * copy of this software and associated documentation files (the "Software"), - * to deal in the Software without restriction, including without limitation - * the rights to use, copy, modify, merge, publish, distribute, sublicense, - * and/or sell copies of the Software, and to permit persons to whom the - * Software is furnished to do so, subject to the following conditions: - * - * The above copyright notice and this permission notice shall be included - * in all copies or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS - * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL - * BRIAN PAUL BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN - * AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN - * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. - */ - - -/** - * \file api_exec.c - * Initialize dispatch table with the immidiate mode functions. - */ - -#include - -#if FEATURE_GL - - -/** - * Initialize a dispatch table with pointers to Mesa's immediate-mode - * commands. - * - * Pointers to glBegin()/glEnd() object commands and a few others - * are provided via the GLvertexformat interface. - * - * \param ctx GL context to which \c exec belongs. - * \param exec dispatch table. - */ -struct _glapi_table * -_mesa_create_exec_table(void) -{ - struct _glapi_table *exec; - - exec = _mesa_alloc_dispatch_table(_gloffset_COUNT); - if (exec == NULL) - return NULL; - -#if _HAVE_FULL_GL - _mesa_loopback_init_api_table( exec ); -#endif - - /* load the dispatch slots we understand */ - SET_AlphaFunc(exec, _mesa_AlphaFunc); - SET_BlendFunc(exec, _mesa_BlendFunc); - SET_Clear(exec, _mesa_Clear); - SET_ClearColor(exec, _mesa_ClearColor); - SET_ClearStencil(exec, _mesa_ClearStencil); - SET_ColorMask(exec, _mesa_ColorMask); - SET_CullFace(exec, _mesa_CullFace); - SET_Disable(exec, _mesa_Disable); -#if FEATURE_draw_read_buffer - SET_DrawBuffer(exec, _mesa_DrawBuffer); - SET_ReadBuffer(exec, _mesa_ReadBuffer); -#endif - SET_Enable(exec, _mesa_Enable); - SET_Finish(exec, _mesa_Finish); - SET_Flush(exec, _mesa_Flush); - SET_FrontFace(exec, _mesa_FrontFace); - SET_Frustum(exec, _mesa_Frustum); - SET_GetError(exec, _mesa_GetError); - SET_GetFloatv(exec, _mesa_GetFloatv); - SET_GetString(exec, _mesa_GetString); - SET_LineStipple(exec, _mesa_LineStipple); - SET_LineWidth(exec, _mesa_LineWidth); - SET_LoadIdentity(exec, _mesa_LoadIdentity); - SET_LoadMatrixf(exec, _mesa_LoadMatrixf); - SET_LogicOp(exec, _mesa_LogicOp); - SET_MatrixMode(exec, _mesa_MatrixMode); - SET_MultMatrixf(exec, _mesa_MultMatrixf); - SET_Ortho(exec, _mesa_Ortho); - SET_PixelStorei(exec, _mesa_PixelStorei); - SET_PopMatrix(exec, _mesa_PopMatrix); - SET_PushMatrix(exec, _mesa_PushMatrix); - SET_Rotatef(exec, _mesa_Rotatef); - SET_Scalef(exec, _mesa_Scalef); - SET_Scissor(exec, _mesa_Scissor); - SET_ShadeModel(exec, _mesa_ShadeModel); - SET_StencilFunc(exec, _mesa_StencilFunc); - SET_StencilMask(exec, _mesa_StencilMask); - SET_StencilOp(exec, _mesa_StencilOp); - SET_TexEnvfv(exec, _mesa_TexEnvfv); - SET_TexEnvi(exec, _mesa_TexEnvi); - SET_TexImage2D(exec, _mesa_TexImage2D); - SET_TexParameteri(exec, _mesa_TexParameteri); - SET_Translatef(exec, _mesa_Translatef); - SET_Viewport(exec, _mesa_Viewport); - - _mesa_init_accum_dispatch(exec); - _mesa_init_dlist_dispatch(exec); - - SET_ClearDepth(exec, _mesa_ClearDepth); - SET_ClearIndex(exec, _mesa_ClearIndex); - SET_ClipPlane(exec, _mesa_ClipPlane); - SET_ColorMaterial(exec, _mesa_ColorMaterial); - SET_DepthFunc(exec, _mesa_DepthFunc); - SET_DepthMask(exec, _mesa_DepthMask); - SET_DepthRange(exec, _mesa_DepthRange); - - _mesa_init_drawpix_dispatch(exec); - _mesa_init_feedback_dispatch(exec); - - SET_FogCoordPointerEXT(exec, _mesa_FogCoordPointerEXT); - SET_Fogf(exec, _mesa_Fogf); - SET_Fogfv(exec, _mesa_Fogfv); - SET_Fogi(exec, _mesa_Fogi); - SET_Fogiv(exec, _mesa_Fogiv); - SET_GetClipPlane(exec, _mesa_GetClipPlane); - SET_GetBooleanv(exec, _mesa_GetBooleanv); - SET_GetDoublev(exec, _mesa_GetDoublev); - SET_GetIntegerv(exec, _mesa_GetIntegerv); - SET_GetLightfv(exec, _mesa_GetLightfv); - SET_GetLightiv(exec, _mesa_GetLightiv); - SET_GetMaterialfv(exec, _mesa_GetMaterialfv); - SET_GetMaterialiv(exec, _mesa_GetMaterialiv); - SET_GetPolygonStipple(exec, _mesa_GetPolygonStipple); - SET_GetTexEnvfv(exec, _mesa_GetTexEnvfv); - SET_GetTexEnviv(exec, _mesa_GetTexEnviv); - SET_GetTexLevelParameterfv(exec, _mesa_GetTexLevelParameterfv); - SET_GetTexLevelParameteriv(exec, _mesa_GetTexLevelParameteriv); - SET_GetTexParameterfv(exec, _mesa_GetTexParameterfv); - SET_GetTexParameteriv(exec, _mesa_GetTexParameteriv); - SET_GetTexImage(exec, _mesa_GetTexImage); - SET_Hint(exec, _mesa_Hint); - SET_IndexMask(exec, _mesa_IndexMask); - SET_IsEnabled(exec, _mesa_IsEnabled); - SET_LightModelf(exec, _mesa_LightModelf); - SET_LightModelfv(exec, _mesa_LightModelfv); - SET_LightModeli(exec, _mesa_LightModeli); - SET_LightModeliv(exec, _mesa_LightModeliv); - SET_Lightf(exec, _mesa_Lightf); - SET_Lightfv(exec, _mesa_Lightfv); - SET_Lighti(exec, _mesa_Lighti); - SET_Lightiv(exec, _mesa_Lightiv); - SET_LoadMatrixd(exec, _mesa_LoadMatrixd); - - _mesa_init_eval_dispatch(exec); - - SET_MultMatrixd(exec, _mesa_MultMatrixd); - - _mesa_init_pixel_dispatch(exec); - - SET_PixelStoref(exec, _mesa_PixelStoref); - SET_PointSize(exec, _mesa_PointSize); - SET_PolygonMode(exec, _mesa_PolygonMode); - SET_PolygonOffset(exec, _mesa_PolygonOffset); - SET_PolygonStipple(exec, _mesa_PolygonStipple); - - _mesa_init_attrib_dispatch(exec); - _mesa_init_rastpos_dispatch(exec); - - SET_ReadPixels(exec, _mesa_ReadPixels); - SET_Rotated(exec, _mesa_Rotated); - SET_Scaled(exec, _mesa_Scaled); - SET_TexEnvf(exec, _mesa_TexEnvf); - SET_TexEnviv(exec, _mesa_TexEnviv); - - _mesa_init_texgen_dispatch(exec); - - SET_TexImage1D(exec, _mesa_TexImage1D); - SET_TexParameterf(exec, _mesa_TexParameterf); - SET_TexParameterfv(exec, _mesa_TexParameterfv); - SET_TexParameteriv(exec, _mesa_TexParameteriv); - SET_Translated(exec, _mesa_Translated); - - /* 1.1 */ - SET_BindTexture(exec, _mesa_BindTexture); - SET_DeleteTextures(exec, _mesa_DeleteTextures); - SET_GenTextures(exec, _mesa_GenTextures); -#if _HAVE_FULL_GL - SET_AreTexturesResident(exec, _mesa_AreTexturesResident); - SET_ColorPointer(exec, _mesa_ColorPointer); - SET_CopyTexImage1D(exec, _mesa_CopyTexImage1D); - SET_CopyTexImage2D(exec, _mesa_CopyTexImage2D); - SET_CopyTexSubImage1D(exec, _mesa_CopyTexSubImage1D); - SET_CopyTexSubImage2D(exec, _mesa_CopyTexSubImage2D); - SET_DisableClientState(exec, _mesa_DisableClientState); - SET_EdgeFlagPointer(exec, _mesa_EdgeFlagPointer); - SET_EnableClientState(exec, _mesa_EnableClientState); - SET_GetPointerv(exec, _mesa_GetPointerv); - SET_IndexPointer(exec, _mesa_IndexPointer); - SET_InterleavedArrays(exec, _mesa_InterleavedArrays); - SET_IsTexture(exec, _mesa_IsTexture); - SET_NormalPointer(exec, _mesa_NormalPointer); - SET_PrioritizeTextures(exec, _mesa_PrioritizeTextures); - SET_TexCoordPointer(exec, _mesa_TexCoordPointer); - SET_TexSubImage1D(exec, _mesa_TexSubImage1D); - SET_TexSubImage2D(exec, _mesa_TexSubImage2D); - SET_VertexPointer(exec, _mesa_VertexPointer); -#endif - - /* 3. GL_EXT_polygon_offset */ -#if _HAVE_FULL_GL - SET_PolygonOffsetEXT(exec, _mesa_PolygonOffsetEXT); -#endif - - /* 30. GL_EXT_vertex_array */ -#if _HAVE_FULL_GL - SET_ColorPointerEXT(exec, _mesa_ColorPointerEXT); - SET_EdgeFlagPointerEXT(exec, _mesa_EdgeFlagPointerEXT); - SET_IndexPointerEXT(exec, _mesa_IndexPointerEXT); - SET_NormalPointerEXT(exec, _mesa_NormalPointerEXT); - SET_TexCoordPointerEXT(exec, _mesa_TexCoordPointerEXT); - SET_VertexPointerEXT(exec, _mesa_VertexPointerEXT); -#endif - - /* 54. GL_EXT_point_parameters */ -#if _HAVE_FULL_GL - SET_PointParameterfEXT(exec, _mesa_PointParameterf); - SET_PointParameterfvEXT(exec, _mesa_PointParameterfv); -#endif - - /* 97. GL_EXT_compiled_vertex_array */ -#if _HAVE_FULL_GL - SET_LockArraysEXT(exec, _mesa_LockArraysEXT); - SET_UnlockArraysEXT(exec, _mesa_UnlockArraysEXT); -#endif - - /* 197. GL_MESA_window_pos */ - /* part of _mesa_init_rastpos_dispatch(exec); */ - - /* 200. GL_IBM_multimode_draw_arrays */ -#if _HAVE_FULL_GL - SET_MultiModeDrawArraysIBM(exec, _mesa_MultiModeDrawArraysIBM); - SET_MultiModeDrawElementsIBM(exec, _mesa_MultiModeDrawElementsIBM); -#endif - - /* 262. GL_NV_point_sprite */ -#if _HAVE_FULL_GL - SET_PointParameteriNV(exec, _mesa_PointParameteri); - SET_PointParameterivNV(exec, _mesa_PointParameteriv); -#endif - - /* ???. GL_EXT_depth_bounds_test */ - SET_DepthBoundsEXT(exec, _mesa_DepthBoundsEXT); - - /* ARB 3. GL_ARB_transpose_matrix */ -#if _HAVE_FULL_GL - SET_LoadTransposeMatrixdARB(exec, _mesa_LoadTransposeMatrixdARB); - SET_LoadTransposeMatrixfARB(exec, _mesa_LoadTransposeMatrixfARB); - SET_MultTransposeMatrixdARB(exec, _mesa_MultTransposeMatrixdARB); - SET_MultTransposeMatrixfARB(exec, _mesa_MultTransposeMatrixfARB); -#endif - - /* ARB 5. GL_ARB_multisample */ -#if _HAVE_FULL_GL - SET_SampleCoverageARB(exec, _mesa_SampleCoverageARB); -#endif - - /* ARB 14. GL_ARB_point_parameters */ - /* reuse EXT_point_parameters functions */ - - /* ARB 28. GL_ARB_vertex_buffer_object */ - SET_BindBufferARB(exec, _mesa_BindBufferARB); - SET_BufferDataARB(exec, _mesa_BufferDataARB); - SET_BufferSubDataARB(exec, _mesa_BufferSubDataARB); - SET_DeleteBuffersARB(exec, _mesa_DeleteBuffersARB); - SET_GenBuffersARB(exec, _mesa_GenBuffersARB); - SET_GetBufferParameterivARB(exec, _mesa_GetBufferParameterivARB); - SET_GetBufferPointervARB(exec, _mesa_GetBufferPointervARB); - SET_GetBufferSubDataARB(exec, _mesa_GetBufferSubDataARB); - SET_IsBufferARB(exec, _mesa_IsBufferARB); - SET_MapBufferARB(exec, _mesa_MapBufferARB); - SET_UnmapBufferARB(exec, _mesa_UnmapBufferARB); - -#if FEATURE_ARB_map_buffer_range - SET_MapBufferRange(exec, _mesa_MapBufferRange); - SET_FlushMappedBufferRange(exec, _mesa_FlushMappedBufferRange); -#endif - - /* GL_EXT_texture_integer */ - SET_ClearColorIiEXT(exec, _mesa_ClearColorIiEXT); - SET_ClearColorIuiEXT(exec, _mesa_ClearColorIuiEXT); - SET_GetTexParameterIivEXT(exec, _mesa_GetTexParameterIiv); - SET_GetTexParameterIuivEXT(exec, _mesa_GetTexParameterIuiv); - SET_TexParameterIivEXT(exec, _mesa_TexParameterIiv); - SET_TexParameterIuivEXT(exec, _mesa_TexParameterIuiv); - - /* GL_ARB_texture_storage */ - SET_TexStorage1D(exec, _mesa_TexStorage1D); - SET_TexStorage2D(exec, _mesa_TexStorage2D); - SET_TexStorage3D(exec, _mesa_TexStorage3D); - SET_TextureStorage1DEXT(exec, _mesa_TextureStorage1DEXT); - SET_TextureStorage2DEXT(exec, _mesa_TextureStorage2DEXT); - SET_TextureStorage3DEXT(exec, _mesa_TextureStorage3DEXT); - - return exec; -} - -#endif /* FEATURE_GL */ diff --git a/dll/opengl/mesa/main/api_exec.h b/dll/opengl/mesa/main/api_exec.h deleted file mode 100644 index 29c953f31be..00000000000 --- a/dll/opengl/mesa/main/api_exec.h +++ /dev/null @@ -1,45 +0,0 @@ -/* - * Mesa 3-D graphics library - * Version: 7.1 - * - * Copyright (C) 1999-2008 Brian Paul All Rights Reserved. - * - * Permission is hereby granted, free of charge, to any person obtaining a - * copy of this software and associated documentation files (the "Software"), - * to deal in the Software without restriction, including without limitation - * the rights to use, copy, modify, merge, publish, distribute, sublicense, - * and/or sell copies of the Software, and to permit persons to whom the - * Software is furnished to do so, subject to the following conditions: - * - * The above copyright notice and this permission notice shall be included - * in all copies or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS - * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL - * BRIAN PAUL BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN - * AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN - * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. - */ - - -#ifndef API_EXEC_H -#define API_EXEC_H - - -struct _glapi_table; - -extern struct _glapi_table * -_mesa_alloc_dispatch_table(int size); - -extern struct _glapi_table * -_mesa_create_exec_table(void); - -extern struct _glapi_table * -_mesa_create_exec_table_es1(void); - -extern struct _glapi_table * -_mesa_create_exec_table_es2(void); - - -#endif diff --git a/dll/opengl/mesa/main/api_loopback.c b/dll/opengl/mesa/main/api_loopback.c deleted file mode 100644 index 35e289356c6..00000000000 --- a/dll/opengl/mesa/main/api_loopback.c +++ /dev/null @@ -1,1022 +0,0 @@ -/** - * \file api_loopback.c - * - * \author Keith Whitwell - */ - -/* - * Mesa 3-D graphics library - * Version: 6.3 - * - * Copyright (C) 1999-2004 Brian Paul All Rights Reserved. - * - * Permission is hereby granted, free of charge, to any person obtaining a - * copy of this software and associated documentation files (the "Software"), - * to deal in the Software without restriction, including without limitation - * the rights to use, copy, modify, merge, publish, distribute, sublicense, - * and/or sell copies of the Software, and to permit persons to whom the - * Software is furnished to do so, subject to the following conditions: - * - * The above copyright notice and this permission notice shall be included - * in all copies or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS - * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL - * BRIAN PAUL BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN - * AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN - * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. - */ - -#include - -/* KW: A set of functions to convert unusual Color/Normal/Vertex/etc - * calls to a smaller set of driver-provided formats. Currently just - * go back to dispatch to find these (eg. call glNormal3f directly), - * hence 'loopback'. - * - * The driver must supply all of the remaining entry points, which are - * listed in dd.h. The easiest way for a driver to do this is to - * install the supplied software t&l module. - */ -#define COLORF(r,g,b,a) CALL_Color4f(GET_DISPATCH(), (r,g,b,a)) -#define VERTEX2(x,y) CALL_Vertex2f(GET_DISPATCH(), (x,y)) -#define VERTEX3(x,y,z) CALL_Vertex3f(GET_DISPATCH(), (x,y,z)) -#define VERTEX4(x,y,z,w) CALL_Vertex4f(GET_DISPATCH(), (x,y,z,w)) -#define NORMAL(x,y,z) CALL_Normal3f(GET_DISPATCH(), (x,y,z)) -#define TEXCOORD1(s) CALL_TexCoord1f(GET_DISPATCH(), (s)) -#define TEXCOORD2(s,t) CALL_TexCoord2f(GET_DISPATCH(), (s,t)) -#define TEXCOORD3(s,t,u) CALL_TexCoord3f(GET_DISPATCH(), (s,t,u)) -#define TEXCOORD4(s,t,u,v) CALL_TexCoord4f(GET_DISPATCH(), (s,t,u,v)) -#define INDEX(c) CALL_Indexf(GET_DISPATCH(), (c)) -#define EVALCOORD1(x) CALL_EvalCoord1f(GET_DISPATCH(), (x)) -#define EVALCOORD2(x,y) CALL_EvalCoord2f(GET_DISPATCH(), (x,y)) -#define MATERIALFV(a,b,c) CALL_Materialfv(GET_DISPATCH(), (a,b,c)) -#define RECTF(a,b,c,d) CALL_Rectf(GET_DISPATCH(), (a,b,c,d)) - -#define FOGCOORDF(x) CALL_FogCoordfEXT(GET_DISPATCH(), (x)) - -#define ATTRIB1NV(index,x) CALL_VertexAttrib1fNV(GET_DISPATCH(), (index,x)) -#define ATTRIB2NV(index,x,y) CALL_VertexAttrib2fNV(GET_DISPATCH(), (index,x,y)) -#define ATTRIB3NV(index,x,y,z) CALL_VertexAttrib3fNV(GET_DISPATCH(), (index,x,y,z)) -#define ATTRIB4NV(index,x,y,z,w) CALL_VertexAttrib4fNV(GET_DISPATCH(), (index,x,y,z,w)) - - -#if FEATURE_beginend - - -static void GLAPIENTRY -loopback_Color3b_f( GLbyte red, GLbyte green, GLbyte blue ) -{ - COLORF( BYTE_TO_FLOAT(red), - BYTE_TO_FLOAT(green), - BYTE_TO_FLOAT(blue), - 1.0 ); -} - -static void GLAPIENTRY -loopback_Color3d_f( GLdouble red, GLdouble green, GLdouble blue ) -{ - COLORF( (GLfloat) red, (GLfloat) green, (GLfloat) blue, 1.0 ); -} - -static void GLAPIENTRY -loopback_Color3i_f( GLint red, GLint green, GLint blue ) -{ - COLORF( INT_TO_FLOAT(red), INT_TO_FLOAT(green), - INT_TO_FLOAT(blue), 1.0); -} - -static void GLAPIENTRY -loopback_Color3s_f( GLshort red, GLshort green, GLshort blue ) -{ - COLORF( SHORT_TO_FLOAT(red), SHORT_TO_FLOAT(green), - SHORT_TO_FLOAT(blue), 1.0); -} - -static void GLAPIENTRY -loopback_Color3ui_f( GLuint red, GLuint green, GLuint blue ) -{ - COLORF( UINT_TO_FLOAT(red), UINT_TO_FLOAT(green), - UINT_TO_FLOAT(blue), 1.0 ); -} - -static void GLAPIENTRY -loopback_Color3us_f( GLushort red, GLushort green, GLushort blue ) -{ - COLORF( USHORT_TO_FLOAT(red), USHORT_TO_FLOAT(green), - USHORT_TO_FLOAT(blue), 1.0 ); -} - -static void GLAPIENTRY -loopback_Color3ub_f( GLubyte red, GLubyte green, GLubyte blue ) -{ - COLORF( UBYTE_TO_FLOAT(red), UBYTE_TO_FLOAT(green), - UBYTE_TO_FLOAT(blue), 1.0 ); -} - - -static void GLAPIENTRY -loopback_Color3bv_f( const GLbyte *v ) -{ - COLORF( BYTE_TO_FLOAT(v[0]), BYTE_TO_FLOAT(v[1]), - BYTE_TO_FLOAT(v[2]), 1.0 ); -} - -static void GLAPIENTRY -loopback_Color3dv_f( const GLdouble *v ) -{ - COLORF( (GLfloat) v[0], (GLfloat) v[1], (GLfloat) v[2], 1.0 ); -} - -static void GLAPIENTRY -loopback_Color3iv_f( const GLint *v ) -{ - COLORF( INT_TO_FLOAT(v[0]), INT_TO_FLOAT(v[1]), - INT_TO_FLOAT(v[2]), 1.0 ); -} - -static void GLAPIENTRY -loopback_Color3sv_f( const GLshort *v ) -{ - COLORF( SHORT_TO_FLOAT(v[0]), SHORT_TO_FLOAT(v[1]), - SHORT_TO_FLOAT(v[2]), 1.0 ); -} - -static void GLAPIENTRY -loopback_Color3uiv_f( const GLuint *v ) -{ - COLORF( UINT_TO_FLOAT(v[0]), UINT_TO_FLOAT(v[1]), - UINT_TO_FLOAT(v[2]), 1.0 ); -} - -static void GLAPIENTRY -loopback_Color3usv_f( const GLushort *v ) -{ - COLORF( USHORT_TO_FLOAT(v[0]), USHORT_TO_FLOAT(v[1]), - USHORT_TO_FLOAT(v[2]), 1.0 ); -} - -static void GLAPIENTRY -loopback_Color3ubv_f( const GLubyte *v ) -{ - COLORF( UBYTE_TO_FLOAT(v[0]), UBYTE_TO_FLOAT(v[1]), - UBYTE_TO_FLOAT(v[2]), 1.0 ); -} - - -static void GLAPIENTRY -loopback_Color4b_f( GLbyte red, GLbyte green, GLbyte blue, - GLbyte alpha ) -{ - COLORF( BYTE_TO_FLOAT(red), BYTE_TO_FLOAT(green), - BYTE_TO_FLOAT(blue), BYTE_TO_FLOAT(alpha) ); -} - -static void GLAPIENTRY -loopback_Color4d_f( GLdouble red, GLdouble green, GLdouble blue, - GLdouble alpha ) -{ - COLORF( (GLfloat) red, (GLfloat) green, (GLfloat) blue, (GLfloat) alpha ); -} - -static void GLAPIENTRY -loopback_Color4i_f( GLint red, GLint green, GLint blue, GLint alpha ) -{ - COLORF( INT_TO_FLOAT(red), INT_TO_FLOAT(green), - INT_TO_FLOAT(blue), INT_TO_FLOAT(alpha) ); -} - -static void GLAPIENTRY -loopback_Color4s_f( GLshort red, GLshort green, GLshort blue, - GLshort alpha ) -{ - COLORF( SHORT_TO_FLOAT(red), SHORT_TO_FLOAT(green), - SHORT_TO_FLOAT(blue), SHORT_TO_FLOAT(alpha) ); -} - -static void GLAPIENTRY -loopback_Color4ui_f( GLuint red, GLuint green, GLuint blue, GLuint alpha ) -{ - COLORF( UINT_TO_FLOAT(red), UINT_TO_FLOAT(green), - UINT_TO_FLOAT(blue), UINT_TO_FLOAT(alpha) ); -} - -static void GLAPIENTRY -loopback_Color4us_f( GLushort red, GLushort green, GLushort blue, GLushort alpha ) -{ - COLORF( USHORT_TO_FLOAT(red), USHORT_TO_FLOAT(green), - USHORT_TO_FLOAT(blue), USHORT_TO_FLOAT(alpha) ); -} - -static void GLAPIENTRY -loopback_Color4ub_f( GLubyte red, GLubyte green, GLubyte blue, GLubyte alpha ) -{ - COLORF( UBYTE_TO_FLOAT(red), UBYTE_TO_FLOAT(green), - UBYTE_TO_FLOAT(blue), UBYTE_TO_FLOAT(alpha) ); -} - - -static void GLAPIENTRY -loopback_Color4iv_f( const GLint *v ) -{ - COLORF( INT_TO_FLOAT(v[0]), INT_TO_FLOAT(v[1]), - INT_TO_FLOAT(v[2]), INT_TO_FLOAT(v[3]) ); -} - - -static void GLAPIENTRY -loopback_Color4bv_f( const GLbyte *v ) -{ - COLORF( BYTE_TO_FLOAT(v[0]), BYTE_TO_FLOAT(v[1]), - BYTE_TO_FLOAT(v[2]), BYTE_TO_FLOAT(v[3]) ); -} - -static void GLAPIENTRY -loopback_Color4dv_f( const GLdouble *v ) -{ - COLORF( (GLfloat) v[0], (GLfloat) v[1], (GLfloat) v[2], (GLfloat) v[3] ); -} - - -static void GLAPIENTRY -loopback_Color4sv_f( const GLshort *v) -{ - COLORF( SHORT_TO_FLOAT(v[0]), SHORT_TO_FLOAT(v[1]), - SHORT_TO_FLOAT(v[2]), SHORT_TO_FLOAT(v[3]) ); -} - - -static void GLAPIENTRY -loopback_Color4uiv_f( const GLuint *v) -{ - COLORF( UINT_TO_FLOAT(v[0]), UINT_TO_FLOAT(v[1]), - UINT_TO_FLOAT(v[2]), UINT_TO_FLOAT(v[3]) ); -} - -static void GLAPIENTRY -loopback_Color4usv_f( const GLushort *v) -{ - COLORF( USHORT_TO_FLOAT(v[0]), USHORT_TO_FLOAT(v[1]), - USHORT_TO_FLOAT(v[2]), USHORT_TO_FLOAT(v[3]) ); -} - -static void GLAPIENTRY -loopback_Color4ubv_f( const GLubyte *v) -{ - COLORF( UBYTE_TO_FLOAT(v[0]), UBYTE_TO_FLOAT(v[1]), - UBYTE_TO_FLOAT(v[2]), UBYTE_TO_FLOAT(v[3]) ); -} - - -static void GLAPIENTRY -loopback_FogCoorddEXT( GLdouble d ) -{ - FOGCOORDF( (GLfloat) d ); -} - -static void GLAPIENTRY -loopback_FogCoorddvEXT( const GLdouble *v ) -{ - FOGCOORDF( (GLfloat) *v ); -} - - -static void GLAPIENTRY -loopback_Indexd( GLdouble c ) -{ - INDEX( (GLfloat) c ); -} - -static void GLAPIENTRY -loopback_Indexi( GLint c ) -{ - INDEX( (GLfloat) c ); -} - -static void GLAPIENTRY -loopback_Indexs( GLshort c ) -{ - INDEX( (GLfloat) c ); -} - -static void GLAPIENTRY -loopback_Indexub( GLubyte c ) -{ - INDEX( (GLfloat) c ); -} - -static void GLAPIENTRY -loopback_Indexdv( const GLdouble *c ) -{ - INDEX( (GLfloat) *c ); -} - -static void GLAPIENTRY -loopback_Indexiv( const GLint *c ) -{ - INDEX( (GLfloat) *c ); -} - -static void GLAPIENTRY -loopback_Indexsv( const GLshort *c ) -{ - INDEX( (GLfloat) *c ); -} - -static void GLAPIENTRY -loopback_Indexubv( const GLubyte *c ) -{ - INDEX( (GLfloat) *c ); -} - - -static void GLAPIENTRY -loopback_EdgeFlagv(const GLboolean *flag) -{ - CALL_EdgeFlag(GET_DISPATCH(), (*flag)); -} - - -static void GLAPIENTRY -loopback_Normal3b( GLbyte nx, GLbyte ny, GLbyte nz ) -{ - NORMAL( BYTE_TO_FLOAT(nx), BYTE_TO_FLOAT(ny), BYTE_TO_FLOAT(nz) ); -} - -static void GLAPIENTRY -loopback_Normal3d( GLdouble nx, GLdouble ny, GLdouble nz ) -{ - NORMAL((GLfloat) nx, (GLfloat) ny, (GLfloat) nz); -} - -static void GLAPIENTRY -loopback_Normal3i( GLint nx, GLint ny, GLint nz ) -{ - NORMAL( INT_TO_FLOAT(nx), INT_TO_FLOAT(ny), INT_TO_FLOAT(nz) ); -} - -static void GLAPIENTRY -loopback_Normal3s( GLshort nx, GLshort ny, GLshort nz ) -{ - NORMAL( SHORT_TO_FLOAT(nx), SHORT_TO_FLOAT(ny), SHORT_TO_FLOAT(nz) ); -} - -static void GLAPIENTRY -loopback_Normal3bv( const GLbyte *v ) -{ - NORMAL( BYTE_TO_FLOAT(v[0]), BYTE_TO_FLOAT(v[1]), BYTE_TO_FLOAT(v[2]) ); -} - -static void GLAPIENTRY -loopback_Normal3dv( const GLdouble *v ) -{ - NORMAL( (GLfloat) v[0], (GLfloat) v[1], (GLfloat) v[2] ); -} - -static void GLAPIENTRY -loopback_Normal3iv( const GLint *v ) -{ - NORMAL( INT_TO_FLOAT(v[0]), INT_TO_FLOAT(v[1]), INT_TO_FLOAT(v[2]) ); -} - -static void GLAPIENTRY -loopback_Normal3sv( const GLshort *v ) -{ - NORMAL( SHORT_TO_FLOAT(v[0]), SHORT_TO_FLOAT(v[1]), SHORT_TO_FLOAT(v[2]) ); -} - -static void GLAPIENTRY -loopback_TexCoord1d( GLdouble s ) -{ - TEXCOORD1((GLfloat) s); -} - -static void GLAPIENTRY -loopback_TexCoord1i( GLint s ) -{ - TEXCOORD1((GLfloat) s); -} - -static void GLAPIENTRY -loopback_TexCoord1s( GLshort s ) -{ - TEXCOORD1((GLfloat) s); -} - -static void GLAPIENTRY -loopback_TexCoord2d( GLdouble s, GLdouble t ) -{ - TEXCOORD2((GLfloat) s,(GLfloat) t); -} - -static void GLAPIENTRY -loopback_TexCoord2s( GLshort s, GLshort t ) -{ - TEXCOORD2((GLfloat) s,(GLfloat) t); -} - -static void GLAPIENTRY -loopback_TexCoord2i( GLint s, GLint t ) -{ - TEXCOORD2((GLfloat) s,(GLfloat) t); -} - -static void GLAPIENTRY -loopback_TexCoord3d( GLdouble s, GLdouble t, GLdouble r ) -{ - TEXCOORD3((GLfloat) s,(GLfloat) t,(GLfloat) r); -} - -static void GLAPIENTRY -loopback_TexCoord3i( GLint s, GLint t, GLint r ) -{ - TEXCOORD3((GLfloat) s,(GLfloat) t,(GLfloat) r); -} - -static void GLAPIENTRY -loopback_TexCoord3s( GLshort s, GLshort t, GLshort r ) -{ - TEXCOORD3((GLfloat) s,(GLfloat) t,(GLfloat) r); -} - -static void GLAPIENTRY -loopback_TexCoord4d( GLdouble s, GLdouble t, GLdouble r, GLdouble q ) -{ - TEXCOORD4((GLfloat) s,(GLfloat) t,(GLfloat) r,(GLfloat) q); -} - -static void GLAPIENTRY -loopback_TexCoord4i( GLint s, GLint t, GLint r, GLint q ) -{ - TEXCOORD4((GLfloat) s,(GLfloat) t,(GLfloat) r,(GLfloat) q); -} - -static void GLAPIENTRY -loopback_TexCoord4s( GLshort s, GLshort t, GLshort r, GLshort q ) -{ - TEXCOORD4((GLfloat) s,(GLfloat) t,(GLfloat) r,(GLfloat) q); -} - -static void GLAPIENTRY -loopback_TexCoord1dv( const GLdouble *v ) -{ - TEXCOORD1((GLfloat) v[0]); -} - -static void GLAPIENTRY -loopback_TexCoord1iv( const GLint *v ) -{ - TEXCOORD1((GLfloat) v[0]); -} - -static void GLAPIENTRY -loopback_TexCoord1sv( const GLshort *v ) -{ - TEXCOORD1((GLfloat) v[0]); -} - -static void GLAPIENTRY -loopback_TexCoord2dv( const GLdouble *v ) -{ - TEXCOORD2((GLfloat) v[0],(GLfloat) v[1]); -} - -static void GLAPIENTRY -loopback_TexCoord2iv( const GLint *v ) -{ - TEXCOORD2((GLfloat) v[0],(GLfloat) v[1]); -} - -static void GLAPIENTRY -loopback_TexCoord2sv( const GLshort *v ) -{ - TEXCOORD2((GLfloat) v[0],(GLfloat) v[1]); -} - -static void GLAPIENTRY -loopback_TexCoord3dv( const GLdouble *v ) -{ - TEXCOORD3((GLfloat) v[0],(GLfloat) v[1],(GLfloat) v[2]); -} - -static void GLAPIENTRY -loopback_TexCoord3iv( const GLint *v ) -{ - TEXCOORD3((GLfloat) v[0],(GLfloat) v[1],(GLfloat) v[2]); -} - -static void GLAPIENTRY -loopback_TexCoord3sv( const GLshort *v ) -{ - TEXCOORD3((GLfloat) v[0],(GLfloat) v[1],(GLfloat) v[2]); -} - -static void GLAPIENTRY -loopback_TexCoord4dv( const GLdouble *v ) -{ - TEXCOORD4((GLfloat) v[0],(GLfloat) v[1],(GLfloat) v[2],(GLfloat) v[3]); -} - -static void GLAPIENTRY -loopback_TexCoord4iv( const GLint *v ) -{ - TEXCOORD4((GLfloat) v[0],(GLfloat) v[1],(GLfloat) v[2],(GLfloat) v[3]); -} - -static void GLAPIENTRY -loopback_TexCoord4sv( const GLshort *v ) -{ - TEXCOORD4((GLfloat) v[0],(GLfloat) v[1],(GLfloat) v[2],(GLfloat) v[3]); -} - -static void GLAPIENTRY -loopback_Vertex2d( GLdouble x, GLdouble y ) -{ - VERTEX2( (GLfloat) x, (GLfloat) y ); -} - -static void GLAPIENTRY -loopback_Vertex2i( GLint x, GLint y ) -{ - VERTEX2( (GLfloat) x, (GLfloat) y ); -} - -static void GLAPIENTRY -loopback_Vertex2s( GLshort x, GLshort y ) -{ - VERTEX2( (GLfloat) x, (GLfloat) y ); -} - -static void GLAPIENTRY -loopback_Vertex3d( GLdouble x, GLdouble y, GLdouble z ) -{ - VERTEX3( (GLfloat) x, (GLfloat) y, (GLfloat) z ); -} - -static void GLAPIENTRY -loopback_Vertex3i( GLint x, GLint y, GLint z ) -{ - VERTEX3( (GLfloat) x, (GLfloat) y, (GLfloat) z ); -} - -static void GLAPIENTRY -loopback_Vertex3s( GLshort x, GLshort y, GLshort z ) -{ - VERTEX3( (GLfloat) x, (GLfloat) y, (GLfloat) z ); -} - -static void GLAPIENTRY -loopback_Vertex4d( GLdouble x, GLdouble y, GLdouble z, GLdouble w ) -{ - VERTEX4( (GLfloat) x, (GLfloat) y, (GLfloat) z, (GLfloat) w ); -} - -static void GLAPIENTRY -loopback_Vertex4i( GLint x, GLint y, GLint z, GLint w ) -{ - VERTEX4( (GLfloat) x, (GLfloat) y, (GLfloat) z, (GLfloat) w ); -} - -static void GLAPIENTRY -loopback_Vertex4s( GLshort x, GLshort y, GLshort z, GLshort w ) -{ - VERTEX4( (GLfloat) x, (GLfloat) y, (GLfloat) z, (GLfloat) w ); -} - -static void GLAPIENTRY -loopback_Vertex2dv( const GLdouble *v ) -{ - VERTEX2( (GLfloat) v[0], (GLfloat) v[1] ); -} - -static void GLAPIENTRY -loopback_Vertex2iv( const GLint *v ) -{ - VERTEX2( (GLfloat) v[0], (GLfloat) v[1] ); -} - -static void GLAPIENTRY -loopback_Vertex2sv( const GLshort *v ) -{ - VERTEX2( (GLfloat) v[0], (GLfloat) v[1] ); -} - -static void GLAPIENTRY -loopback_Vertex3dv( const GLdouble *v ) -{ - VERTEX3( (GLfloat) v[0], (GLfloat) v[1], (GLfloat) v[2] ); -} - -static void GLAPIENTRY -loopback_Vertex3iv( const GLint *v ) -{ - VERTEX3( (GLfloat) v[0], (GLfloat) v[1], (GLfloat) v[2] ); -} - -static void GLAPIENTRY -loopback_Vertex3sv( const GLshort *v ) -{ - VERTEX3( (GLfloat) v[0], (GLfloat) v[1], (GLfloat) v[2] ); -} - -static void GLAPIENTRY -loopback_Vertex4dv( const GLdouble *v ) -{ - VERTEX4( (GLfloat) v[0], (GLfloat) v[1], - (GLfloat) v[2], (GLfloat) v[3] ); -} - -static void GLAPIENTRY -loopback_Vertex4iv( const GLint *v ) -{ - VERTEX4( (GLfloat) v[0], (GLfloat) v[1], - (GLfloat) v[2], (GLfloat) v[3] ); -} - -static void GLAPIENTRY -loopback_Vertex4sv( const GLshort *v ) -{ - VERTEX4( (GLfloat) v[0], (GLfloat) v[1], - (GLfloat) v[2], (GLfloat) v[3] ); -} - -static void GLAPIENTRY -loopback_EvalCoord2dv( const GLdouble *u ) -{ - EVALCOORD2( (GLfloat) u[0], (GLfloat) u[1] ); -} - -static void GLAPIENTRY -loopback_EvalCoord2fv( const GLfloat *u ) -{ - EVALCOORD2( u[0], u[1] ); -} - -static void GLAPIENTRY -loopback_EvalCoord2d( GLdouble u, GLdouble v ) -{ - EVALCOORD2( (GLfloat) u, (GLfloat) v ); -} - -static void GLAPIENTRY -loopback_EvalCoord1dv( const GLdouble *u ) -{ - EVALCOORD1( (GLfloat) *u ); -} - -static void GLAPIENTRY -loopback_EvalCoord1fv( const GLfloat *u ) -{ - EVALCOORD1( (GLfloat) *u ); -} - -static void GLAPIENTRY -loopback_EvalCoord1d( GLdouble u ) -{ - EVALCOORD1( (GLfloat) u ); -} - -static void GLAPIENTRY -loopback_Materialf( GLenum face, GLenum pname, GLfloat param ) -{ - GLfloat fparam[4]; - fparam[0] = param; - MATERIALFV( face, pname, fparam ); -} - -static void GLAPIENTRY -loopback_Materiali(GLenum face, GLenum pname, GLint param ) -{ - GLfloat p = (GLfloat) param; - MATERIALFV(face, pname, &p); -} - -static void GLAPIENTRY -loopback_Materialiv(GLenum face, GLenum pname, const GLint *params ) -{ - GLfloat fparam[4]; - switch (pname) { - case GL_AMBIENT: - case GL_DIFFUSE: - case GL_SPECULAR: - case GL_EMISSION: - case GL_AMBIENT_AND_DIFFUSE: - fparam[0] = INT_TO_FLOAT( params[0] ); - fparam[1] = INT_TO_FLOAT( params[1] ); - fparam[2] = INT_TO_FLOAT( params[2] ); - fparam[3] = INT_TO_FLOAT( params[3] ); - break; - case GL_SHININESS: - fparam[0] = (GLfloat) params[0]; - break; - case GL_COLOR_INDEXES: - fparam[0] = (GLfloat) params[0]; - fparam[1] = (GLfloat) params[1]; - fparam[2] = (GLfloat) params[2]; - break; - default: - ; - } - MATERIALFV(face, pname, fparam); -} - - -static void GLAPIENTRY -loopback_Rectd(GLdouble x1, GLdouble y1, GLdouble x2, GLdouble y2) -{ - RECTF((GLfloat) x1, (GLfloat) y1, (GLfloat) x2, (GLfloat) y2); -} - -static void GLAPIENTRY -loopback_Rectdv(const GLdouble *v1, const GLdouble *v2) -{ - RECTF((GLfloat) v1[0], (GLfloat) v1[1], (GLfloat) v2[0], (GLfloat) v2[1]); -} - -static void GLAPIENTRY -loopback_Rectfv(const GLfloat *v1, const GLfloat *v2) -{ - RECTF(v1[0], v1[1], v2[0], v2[1]); -} - -static void GLAPIENTRY -loopback_Recti(GLint x1, GLint y1, GLint x2, GLint y2) -{ - RECTF((GLfloat) x1, (GLfloat) y1, (GLfloat) x2, (GLfloat) y2); -} - -static void GLAPIENTRY -loopback_Rectiv(const GLint *v1, const GLint *v2) -{ - RECTF((GLfloat) v1[0], (GLfloat) v1[1], (GLfloat) v2[0], (GLfloat) v2[1]); -} - -static void GLAPIENTRY -loopback_Rects(GLshort x1, GLshort y1, GLshort x2, GLshort y2) -{ - RECTF((GLfloat) x1, (GLfloat) y1, (GLfloat) x2, (GLfloat) y2); -} - -static void GLAPIENTRY -loopback_Rectsv(const GLshort *v1, const GLshort *v2) -{ - RECTF((GLfloat) v1[0], (GLfloat) v1[1], (GLfloat) v2[0], (GLfloat) v2[1]); -} - - -/* - * GL_NV_vertex_program: - * Always loop-back to one of the VertexAttrib[1234]f[v]NV functions. - * Note that attribute indexes DO alias conventional vertex attributes. - */ - -static void GLAPIENTRY -loopback_VertexAttrib1sNV(GLuint index, GLshort x) -{ - ATTRIB1NV(index, (GLfloat) x); -} - -static void GLAPIENTRY -loopback_VertexAttrib1dNV(GLuint index, GLdouble x) -{ - ATTRIB1NV(index, (GLfloat) x); -} - -static void GLAPIENTRY -loopback_VertexAttrib2sNV(GLuint index, GLshort x, GLshort y) -{ - ATTRIB2NV(index, (GLfloat) x, y); -} - -static void GLAPIENTRY -loopback_VertexAttrib2dNV(GLuint index, GLdouble x, GLdouble y) -{ - ATTRIB2NV(index, (GLfloat) x, (GLfloat) y); -} - -static void GLAPIENTRY -loopback_VertexAttrib3sNV(GLuint index, GLshort x, GLshort y, GLshort z) -{ - ATTRIB3NV(index, (GLfloat) x, (GLfloat) y, (GLfloat) z); -} - -static void GLAPIENTRY -loopback_VertexAttrib3dNV(GLuint index, GLdouble x, GLdouble y, GLdouble z) -{ - ATTRIB4NV(index, (GLfloat) x, (GLfloat) y, (GLfloat) z, 1.0F); -} - -static void GLAPIENTRY -loopback_VertexAttrib4sNV(GLuint index, GLshort x, GLshort y, GLshort z, GLshort w) -{ - ATTRIB4NV(index, (GLfloat) x, (GLfloat) y, (GLfloat) z, (GLfloat) w); -} - -static void GLAPIENTRY -loopback_VertexAttrib4dNV(GLuint index, GLdouble x, GLdouble y, GLdouble z, GLdouble w) -{ - ATTRIB4NV(index, (GLfloat) x, (GLfloat) y, (GLfloat) z, (GLfloat) w); -} - -static void GLAPIENTRY -loopback_VertexAttrib4ubNV(GLuint index, GLubyte x, GLubyte y, GLubyte z, GLubyte w) -{ - ATTRIB4NV(index, UBYTE_TO_FLOAT(x), UBYTE_TO_FLOAT(y), - UBYTE_TO_FLOAT(z), UBYTE_TO_FLOAT(w)); -} - -static void GLAPIENTRY -loopback_VertexAttrib1svNV(GLuint index, const GLshort *v) -{ - ATTRIB1NV(index, (GLfloat) v[0]); -} - -static void GLAPIENTRY -loopback_VertexAttrib1dvNV(GLuint index, const GLdouble *v) -{ - ATTRIB1NV(index, (GLfloat) v[0]); -} - -static void GLAPIENTRY -loopback_VertexAttrib2svNV(GLuint index, const GLshort *v) -{ - ATTRIB2NV(index, (GLfloat) v[0], (GLfloat) v[1]); -} - -static void GLAPIENTRY -loopback_VertexAttrib2dvNV(GLuint index, const GLdouble *v) -{ - ATTRIB2NV(index, (GLfloat) v[0], (GLfloat) v[1]); -} - -static void GLAPIENTRY -loopback_VertexAttrib3svNV(GLuint index, const GLshort *v) -{ - ATTRIB3NV(index, (GLfloat) v[0], (GLfloat) v[1], (GLfloat) v[2]); -} - -static void GLAPIENTRY -loopback_VertexAttrib3dvNV(GLuint index, const GLdouble *v) -{ - ATTRIB3NV(index, (GLfloat) v[0], (GLfloat) v[1], (GLfloat) v[2]); -} - -static void GLAPIENTRY -loopback_VertexAttrib4svNV(GLuint index, const GLshort *v) -{ - ATTRIB4NV(index, (GLfloat) v[0], (GLfloat) v[1], (GLfloat) v[2], - (GLfloat)v[3]); -} - -static void GLAPIENTRY -loopback_VertexAttrib4dvNV(GLuint index, const GLdouble *v) -{ - ATTRIB4NV(index, (GLfloat) v[0], (GLfloat) v[1], (GLfloat) v[2], (GLfloat) v[3]); -} - -static void GLAPIENTRY -loopback_VertexAttrib4ubvNV(GLuint index, const GLubyte *v) -{ - ATTRIB4NV(index, UBYTE_TO_FLOAT(v[0]), UBYTE_TO_FLOAT(v[1]), - UBYTE_TO_FLOAT(v[2]), UBYTE_TO_FLOAT(v[3])); -} - - -/* - * This code never registers handlers for any of the entry points - * listed in vtxfmt.h. - */ -void -_mesa_loopback_init_api_table( struct _glapi_table *dest ) -{ - SET_Color3b(dest, loopback_Color3b_f); - SET_Color3d(dest, loopback_Color3d_f); - SET_Color3i(dest, loopback_Color3i_f); - SET_Color3s(dest, loopback_Color3s_f); - SET_Color3ui(dest, loopback_Color3ui_f); - SET_Color3us(dest, loopback_Color3us_f); - SET_Color3ub(dest, loopback_Color3ub_f); - SET_Color4b(dest, loopback_Color4b_f); - SET_Color4d(dest, loopback_Color4d_f); - SET_Color4i(dest, loopback_Color4i_f); - SET_Color4s(dest, loopback_Color4s_f); - SET_Color4ui(dest, loopback_Color4ui_f); - SET_Color4us(dest, loopback_Color4us_f); - SET_Color4ub(dest, loopback_Color4ub_f); - SET_Color3bv(dest, loopback_Color3bv_f); - SET_Color3dv(dest, loopback_Color3dv_f); - SET_Color3iv(dest, loopback_Color3iv_f); - SET_Color3sv(dest, loopback_Color3sv_f); - SET_Color3uiv(dest, loopback_Color3uiv_f); - SET_Color3usv(dest, loopback_Color3usv_f); - SET_Color3ubv(dest, loopback_Color3ubv_f); - SET_Color4bv(dest, loopback_Color4bv_f); - SET_Color4dv(dest, loopback_Color4dv_f); - SET_Color4iv(dest, loopback_Color4iv_f); - SET_Color4sv(dest, loopback_Color4sv_f); - SET_Color4uiv(dest, loopback_Color4uiv_f); - SET_Color4usv(dest, loopback_Color4usv_f); - SET_Color4ubv(dest, loopback_Color4ubv_f); - - SET_EdgeFlagv(dest, loopback_EdgeFlagv); - - SET_Indexd(dest, loopback_Indexd); - SET_Indexi(dest, loopback_Indexi); - SET_Indexs(dest, loopback_Indexs); - SET_Indexub(dest, loopback_Indexub); - SET_Indexdv(dest, loopback_Indexdv); - SET_Indexiv(dest, loopback_Indexiv); - SET_Indexsv(dest, loopback_Indexsv); - SET_Indexubv(dest, loopback_Indexubv); - SET_Normal3b(dest, loopback_Normal3b); - SET_Normal3d(dest, loopback_Normal3d); - SET_Normal3i(dest, loopback_Normal3i); - SET_Normal3s(dest, loopback_Normal3s); - SET_Normal3bv(dest, loopback_Normal3bv); - SET_Normal3dv(dest, loopback_Normal3dv); - SET_Normal3iv(dest, loopback_Normal3iv); - SET_Normal3sv(dest, loopback_Normal3sv); - SET_TexCoord1d(dest, loopback_TexCoord1d); - SET_TexCoord1i(dest, loopback_TexCoord1i); - SET_TexCoord1s(dest, loopback_TexCoord1s); - SET_TexCoord2d(dest, loopback_TexCoord2d); - SET_TexCoord2s(dest, loopback_TexCoord2s); - SET_TexCoord2i(dest, loopback_TexCoord2i); - SET_TexCoord3d(dest, loopback_TexCoord3d); - SET_TexCoord3i(dest, loopback_TexCoord3i); - SET_TexCoord3s(dest, loopback_TexCoord3s); - SET_TexCoord4d(dest, loopback_TexCoord4d); - SET_TexCoord4i(dest, loopback_TexCoord4i); - SET_TexCoord4s(dest, loopback_TexCoord4s); - SET_TexCoord1dv(dest, loopback_TexCoord1dv); - SET_TexCoord1iv(dest, loopback_TexCoord1iv); - SET_TexCoord1sv(dest, loopback_TexCoord1sv); - SET_TexCoord2dv(dest, loopback_TexCoord2dv); - SET_TexCoord2iv(dest, loopback_TexCoord2iv); - SET_TexCoord2sv(dest, loopback_TexCoord2sv); - SET_TexCoord3dv(dest, loopback_TexCoord3dv); - SET_TexCoord3iv(dest, loopback_TexCoord3iv); - SET_TexCoord3sv(dest, loopback_TexCoord3sv); - SET_TexCoord4dv(dest, loopback_TexCoord4dv); - SET_TexCoord4iv(dest, loopback_TexCoord4iv); - SET_TexCoord4sv(dest, loopback_TexCoord4sv); - SET_Vertex2d(dest, loopback_Vertex2d); - SET_Vertex2i(dest, loopback_Vertex2i); - SET_Vertex2s(dest, loopback_Vertex2s); - SET_Vertex3d(dest, loopback_Vertex3d); - SET_Vertex3i(dest, loopback_Vertex3i); - SET_Vertex3s(dest, loopback_Vertex3s); - SET_Vertex4d(dest, loopback_Vertex4d); - SET_Vertex4i(dest, loopback_Vertex4i); - SET_Vertex4s(dest, loopback_Vertex4s); - SET_Vertex2dv(dest, loopback_Vertex2dv); - SET_Vertex2iv(dest, loopback_Vertex2iv); - SET_Vertex2sv(dest, loopback_Vertex2sv); - SET_Vertex3dv(dest, loopback_Vertex3dv); - SET_Vertex3iv(dest, loopback_Vertex3iv); - SET_Vertex3sv(dest, loopback_Vertex3sv); - SET_Vertex4dv(dest, loopback_Vertex4dv); - SET_Vertex4iv(dest, loopback_Vertex4iv); - SET_Vertex4sv(dest, loopback_Vertex4sv); - SET_EvalCoord2dv(dest, loopback_EvalCoord2dv); - SET_EvalCoord2fv(dest, loopback_EvalCoord2fv); - SET_EvalCoord2d(dest, loopback_EvalCoord2d); - SET_EvalCoord1dv(dest, loopback_EvalCoord1dv); - SET_EvalCoord1fv(dest, loopback_EvalCoord1fv); - SET_EvalCoord1d(dest, loopback_EvalCoord1d); - SET_Materialf(dest, loopback_Materialf); - SET_Materiali(dest, loopback_Materiali); - SET_Materialiv(dest, loopback_Materialiv); - SET_Rectd(dest, loopback_Rectd); - SET_Rectdv(dest, loopback_Rectdv); - SET_Rectfv(dest, loopback_Rectfv); - SET_Recti(dest, loopback_Recti); - SET_Rectiv(dest, loopback_Rectiv); - SET_Rects(dest, loopback_Rects); - SET_Rectsv(dest, loopback_Rectsv); - SET_FogCoorddEXT(dest, loopback_FogCoorddEXT); - SET_FogCoorddvEXT(dest, loopback_FogCoorddvEXT); - - SET_VertexAttrib1sNV(dest, loopback_VertexAttrib1sNV); - SET_VertexAttrib1dNV(dest, loopback_VertexAttrib1dNV); - SET_VertexAttrib2sNV(dest, loopback_VertexAttrib2sNV); - SET_VertexAttrib2dNV(dest, loopback_VertexAttrib2dNV); - SET_VertexAttrib3sNV(dest, loopback_VertexAttrib3sNV); - SET_VertexAttrib3dNV(dest, loopback_VertexAttrib3dNV); - SET_VertexAttrib4sNV(dest, loopback_VertexAttrib4sNV); - SET_VertexAttrib4dNV(dest, loopback_VertexAttrib4dNV); - SET_VertexAttrib4ubNV(dest, loopback_VertexAttrib4ubNV); - SET_VertexAttrib1svNV(dest, loopback_VertexAttrib1svNV); - SET_VertexAttrib1dvNV(dest, loopback_VertexAttrib1dvNV); - SET_VertexAttrib2svNV(dest, loopback_VertexAttrib2svNV); - SET_VertexAttrib2dvNV(dest, loopback_VertexAttrib2dvNV); - SET_VertexAttrib3svNV(dest, loopback_VertexAttrib3svNV); - SET_VertexAttrib3dvNV(dest, loopback_VertexAttrib3dvNV); - SET_VertexAttrib4svNV(dest, loopback_VertexAttrib4svNV); - SET_VertexAttrib4dvNV(dest, loopback_VertexAttrib4dvNV); - SET_VertexAttrib4ubvNV(dest, loopback_VertexAttrib4ubvNV); -} - - -#endif /* FEATURE_beginend */ diff --git a/dll/opengl/mesa/main/api_loopback.h b/dll/opengl/mesa/main/api_loopback.h deleted file mode 100644 index f53b9028096..00000000000 --- a/dll/opengl/mesa/main/api_loopback.h +++ /dev/null @@ -1,48 +0,0 @@ -/* - * Mesa 3-D graphics library - * Version: 3.5 - * - * Copyright (C) 1999-2001 Brian Paul All Rights Reserved. - * - * Permission is hereby granted, free of charge, to any person obtaining a - * copy of this software and associated documentation files (the "Software"), - * to deal in the Software without restriction, including without limitation - * the rights to use, copy, modify, merge, publish, distribute, sublicense, - * and/or sell copies of the Software, and to permit persons to whom the - * Software is furnished to do so, subject to the following conditions: - * - * The above copyright notice and this permission notice shall be included - * in all copies or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS - * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL - * BRIAN PAUL BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN - * AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN - * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. - */ - - - -#ifndef API_LOOPBACK_H -#define API_LOOPBACK_H - -#include "main/compiler.h" -#include "main/mfeatures.h" - -struct _glapi_table; - -#if FEATURE_beginend - -extern void _mesa_loopback_init_api_table( struct _glapi_table *dest ); - -#else /* FEATURE_beginend */ - -static inline void -_mesa_loopback_init_api_table( struct _glapi_table *dest ) -{ -} - -#endif /* FEATURE_beginend */ - -#endif /* API_LOOPBACK_H */ diff --git a/dll/opengl/mesa/main/api_validate.c b/dll/opengl/mesa/main/api_validate.c deleted file mode 100644 index 88345803435..00000000000 --- a/dll/opengl/mesa/main/api_validate.c +++ /dev/null @@ -1,252 +0,0 @@ -/* - * Mesa 3-D graphics library - * Version: 7.1 - * - * Copyright (C) 1999-2007 Brian Paul All Rights Reserved. - * - * Permission is hereby granted, free of charge, to any person obtaining a - * copy of this software and associated documentation files (the "Software"), - * to deal in the Software without restriction, including without limitation - * the rights to use, copy, modify, merge, publish, distribute, sublicense, - * and/or sell copies of the Software, and to permit persons to whom the - * Software is furnished to do so, subject to the following conditions: - * - * The above copyright notice and this permission notice shall be included - * in all copies or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS - * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL - * BRIAN PAUL BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN - * AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN - * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. - */ - -#include - -/** - * \return number of bytes in array [count] of type. - */ -static GLsizei -index_bytes(GLenum type, GLsizei count) -{ - if (type == GL_UNSIGNED_INT) { - return count * sizeof(GLuint); - } - else if (type == GL_UNSIGNED_BYTE) { - return count * sizeof(GLubyte); - } - else { - ASSERT(type == GL_UNSIGNED_SHORT); - return count * sizeof(GLushort); - } -} - - -/** - * Find the max index in the given element/index buffer - */ -GLuint -_mesa_max_buffer_index(struct gl_context *ctx, GLuint count, GLenum type, - const void *indices, - struct gl_buffer_object *elementBuf) -{ - const GLubyte *map = NULL; - GLuint max = 0; - GLuint i; - - if (_mesa_is_bufferobj(elementBuf)) { - /* elements are in a user-defined buffer object. need to map it */ - map = ctx->Driver.MapBufferRange(ctx, 0, elementBuf->Size, - GL_MAP_READ_BIT, elementBuf); - /* Actual address is the sum of pointers */ - indices = (const GLvoid *) ADD_POINTERS(map, (const GLubyte *) indices); - } - - if (type == GL_UNSIGNED_INT) { - for (i = 0; i < count; i++) - if (((GLuint *) indices)[i] > max) - max = ((GLuint *) indices)[i]; - } - else if (type == GL_UNSIGNED_SHORT) { - for (i = 0; i < count; i++) - if (((GLushort *) indices)[i] > max) - max = ((GLushort *) indices)[i]; - } - else { - ASSERT(type == GL_UNSIGNED_BYTE); - for (i = 0; i < count; i++) - if (((GLubyte *) indices)[i] > max) - max = ((GLubyte *) indices)[i]; - } - - if (map) { - ctx->Driver.UnmapBuffer(ctx, elementBuf); - } - - return max; -} - - -/** - * Check if OK to draw arrays/elements. - */ -static GLboolean -check_valid_to_render(struct gl_context *ctx, const char *function) -{ - if (!_mesa_valid_to_render(ctx, function)) { - return GL_FALSE; - } - - /* Draw if we have vertex positions (GL_VERTEX_ARRAY or generic - * array [0]). - */ - return ctx->Array.VertexAttrib[VERT_ATTRIB_POS].Enabled; -} - - -/** - * Do bounds checking on array element indexes. Check that the vertices - * pointed to by the indices don't lie outside buffer object bounds. - * \return GL_TRUE if OK, GL_FALSE if any indexed vertex goes is out of bounds - */ -static GLboolean -check_index_bounds(struct gl_context *ctx, GLsizei count, GLenum type, - const GLvoid *indices) -{ - struct _mesa_prim prim; - struct _mesa_index_buffer ib; - GLuint min, max; - - /* Only the X Server needs to do this -- otherwise, accessing outside - * array/BO bounds allows application termination. - */ - if (!ctx->Const.CheckArrayBounds) - return GL_TRUE; - - memset(&prim, 0, sizeof(prim)); - prim.count = count; - - memset(&ib, 0, sizeof(ib)); - ib.type = type; - ib.ptr = indices; - ib.obj = ctx->Array.ElementArrayBufferObj; - - vbo_get_minmax_index(ctx, &prim, &ib, &min, &max); - - if (max >= ctx->Array._MaxElement) { - /* the max element is out of bounds of one or more enabled arrays */ - _mesa_warning(ctx, "glDrawElements() index=%u is out of bounds (max=%u)", - max, ctx->Array._MaxElement); - return GL_FALSE; - } - - return GL_TRUE; -} - - -/** - * Is 'mode' a valid value for glBegin(), glDrawArrays(), glDrawElements(), - * etc? The set of legal values depends on whether geometry shaders/programs - * are supported. - */ -GLboolean -_mesa_valid_prim_mode(const struct gl_context *ctx, GLenum mode) -{ - if (mode > GL_POLYGON) { - return GL_FALSE; - } - else { - return GL_TRUE; - } -} - - -/** - * Error checking for glDrawElements(). Includes parameter checking - * and VBO bounds checking. - * \return GL_TRUE if OK to render, GL_FALSE if error found - */ -GLboolean -_mesa_validate_DrawElements(struct gl_context *ctx, - GLenum mode, GLsizei count, GLenum type, - const GLvoid *indices) -{ - ASSERT_OUTSIDE_BEGIN_END_WITH_RETVAL(ctx, GL_FALSE); - - if (count <= 0) { - if (count < 0) - _mesa_error(ctx, GL_INVALID_VALUE, "glDrawElements(count)" ); - return GL_FALSE; - } - - if (!_mesa_valid_prim_mode(ctx, mode)) { - _mesa_error(ctx, GL_INVALID_ENUM, "glDrawElements(mode)" ); - return GL_FALSE; - } - - if (type != GL_UNSIGNED_INT && - type != GL_UNSIGNED_BYTE && - type != GL_UNSIGNED_SHORT) - { - _mesa_error(ctx, GL_INVALID_ENUM, "glDrawElements(type)" ); - return GL_FALSE; - } - - if (!check_valid_to_render(ctx, "glDrawElements")) - return GL_FALSE; - - /* Vertex buffer object tests */ - if (_mesa_is_bufferobj(ctx->Array.ElementArrayBufferObj)) { - /* use indices in the buffer object */ - /* make sure count doesn't go outside buffer bounds */ - if (index_bytes(type, count) > ctx->Array.ElementArrayBufferObj->Size) { - _mesa_warning(ctx, "glDrawElements index out of buffer bounds"); - return GL_FALSE; - } - } - else { - /* not using a VBO */ - if (!indices) - return GL_FALSE; - } - - if (!check_index_bounds(ctx, count, type, indices)) - return GL_FALSE; - - return GL_TRUE; -} - - -/** - * Called from the tnl module to error check the function parameters and - * verify that we really can draw something. - * \return GL_TRUE if OK to render, GL_FALSE if error found - */ -GLboolean -_mesa_validate_DrawArrays(struct gl_context *ctx, - GLenum mode, GLint start, GLsizei count) -{ - ASSERT_OUTSIDE_BEGIN_END_WITH_RETVAL(ctx, GL_FALSE); - - if (count <= 0) { - if (count < 0) - _mesa_error(ctx, GL_INVALID_VALUE, "glDrawArrays(count)" ); - return GL_FALSE; - } - - if (!_mesa_valid_prim_mode(ctx, mode)) { - _mesa_error(ctx, GL_INVALID_ENUM, "glDrawArrays(mode)" ); - return GL_FALSE; - } - - if (!check_valid_to_render(ctx, "glDrawArrays")) - return GL_FALSE; - - if (ctx->Const.CheckArrayBounds) { - if (start + count > (GLint) ctx->Array._MaxElement) - return GL_FALSE; - } - - return GL_TRUE; -} diff --git a/dll/opengl/mesa/main/api_validate.h b/dll/opengl/mesa/main/api_validate.h deleted file mode 100644 index 69be15625e7..00000000000 --- a/dll/opengl/mesa/main/api_validate.h +++ /dev/null @@ -1,58 +0,0 @@ - -/* - * Mesa 3-D graphics library - * Version: 3.5 - * - * Copyright (C) 1999-2001 Brian Paul All Rights Reserved. - * - * Permission is hereby granted, free of charge, to any person obtaining a - * copy of this software and associated documentation files (the "Software"), - * to deal in the Software without restriction, including without limitation - * the rights to use, copy, modify, merge, publish, distribute, sublicense, - * and/or sell copies of the Software, and to permit persons to whom the - * Software is furnished to do so, subject to the following conditions: - * - * The above copyright notice and this permission notice shall be included - * in all copies or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS - * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL - * BRIAN PAUL BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN - * AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN - * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. - */ - - -#ifndef API_VALIDATE_H -#define API_VALIDATE_H - - -#include "glheader.h" -#include "mfeatures.h" - -struct gl_buffer_object; -struct gl_context; -struct gl_transform_feedback_object; - - -extern GLuint -_mesa_max_buffer_index(struct gl_context *ctx, GLuint count, GLenum type, - const void *indices, - struct gl_buffer_object *elementBuf); - - -extern GLboolean -_mesa_valid_prim_mode(const struct gl_context *ctx, GLenum mode); - - -extern GLboolean -_mesa_validate_DrawArrays(struct gl_context *ctx, - GLenum mode, GLint start, GLsizei count); - -extern GLboolean -_mesa_validate_DrawElements(struct gl_context *ctx, - GLenum mode, GLsizei count, GLenum type, - const GLvoid *indices); - -#endif diff --git a/dll/opengl/mesa/main/attrib.c b/dll/opengl/mesa/main/attrib.c deleted file mode 100644 index d5df1dc7b75..00000000000 --- a/dll/opengl/mesa/main/attrib.c +++ /dev/null @@ -1,1268 +0,0 @@ -/* - * Mesa 3-D graphics library - * Version: 7.6 - * - * Copyright (C) 1999-2008 Brian Paul All Rights Reserved. - * Copyright (C) 2009 VMware, Inc. All Rights Reserved. - * - * Permission is hereby granted, free of charge, to any person obtaining a - * copy of this software and associated documentation files (the "Software"), - * to deal in the Software without restriction, including without limitation - * the rights to use, copy, modify, merge, publish, distribute, sublicense, - * and/or sell copies of the Software, and to permit persons to whom the - * Software is furnished to do so, subject to the following conditions: - * - * The above copyright notice and this permission notice shall be included - * in all copies or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS - * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL - * BRIAN PAUL BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN - * AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN - * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. - */ - -#include - -/** - * glEnable()/glDisable() attribute group (GL_ENABLE_BIT). - */ -struct gl_enable_attrib -{ - GLboolean AlphaTest; - GLboolean AutoNormal; - GLboolean Blend; - GLbitfield ClipPlanes; - GLboolean ColorMaterial; - GLboolean CullFace; - GLboolean DepthTest; - GLboolean Dither; - GLboolean Fog; - GLboolean Light[MAX_LIGHTS]; - GLboolean Lighting; - GLboolean LineSmooth; - GLboolean LineStipple; - GLboolean IndexLogicOp; - GLboolean ColorLogicOp; - - GLboolean Map1Color4; - GLboolean Map1Index; - GLboolean Map1Normal; - GLboolean Map1TextureCoord1; - GLboolean Map1TextureCoord2; - GLboolean Map1TextureCoord3; - GLboolean Map1TextureCoord4; - GLboolean Map1Vertex3; - GLboolean Map1Vertex4; - GLboolean Map2Color4; - GLboolean Map2Index; - GLboolean Map2Normal; - GLboolean Map2TextureCoord1; - GLboolean Map2TextureCoord2; - GLboolean Map2TextureCoord3; - GLboolean Map2TextureCoord4; - GLboolean Map2Vertex3; - GLboolean Map2Vertex4; - - GLboolean Normalize; - GLboolean PixelTexture; - GLboolean PointSmooth; - GLboolean PolygonOffsetPoint; - GLboolean PolygonOffsetLine; - GLboolean PolygonOffsetFill; - GLboolean PolygonSmooth; - GLboolean PolygonStipple; - GLboolean RescaleNormals; - GLboolean Scissor; - GLboolean Stencil; - GLboolean MultisampleEnabled; /* GL_ARB_multisample */ - GLboolean SampleAlphaToCoverage; /* GL_ARB_multisample */ - GLboolean SampleAlphaToOne; /* GL_ARB_multisample */ - GLboolean SampleCoverage; /* GL_ARB_multisample */ - GLboolean RasterPositionUnclipped; /* GL_IBM_rasterpos_clip */ - - GLbitfield Texture; - GLbitfield TexGen; - - /* GL_ARB_point_sprite / GL_NV_point_sprite */ - GLboolean PointSprite; -}; - - -/** - * Node for the attribute stack. - */ -struct gl_attrib_node -{ - GLbitfield kind; - void *data; - struct gl_attrib_node *next; -}; - - - -/** - * Special struct for saving/restoring texture state (GL_TEXTURE_BIT) - */ -struct texture_state -{ - struct gl_texture_attrib Texture; /**< The usual context state */ - - /** to save per texture object state (wrap modes, filters, etc): */ - struct gl_texture_object SavedObj[NUM_TEXTURE_TARGETS]; - - /** - * To save references to texture objects (so they don't get accidentally - * deleted while saved in the attribute stack). - */ - struct gl_texture_object *SavedTexRef[NUM_TEXTURE_TARGETS]; - - /* We need to keep a reference to the shared state. That's where the - * default texture objects are kept. We don't want that state to be - * freed while the attribute stack contains pointers to any default - * texture objects. - */ - struct gl_shared_state *SharedRef; -}; - - -#if FEATURE_attrib_stack - - -/** - * Allocate new attribute node of given type/kind. Attach payload data. - * Insert it into the linked list named by 'head'. - */ -static void -save_attrib_data(struct gl_attrib_node **head, - GLbitfield kind, void *payload) -{ - struct gl_attrib_node *n = MALLOC_STRUCT(gl_attrib_node); - if (n) { - n->kind = kind; - n->data = payload; - /* insert at head */ - n->next = *head; - *head = n; - } - else { - /* out of memory! */ - } -} - - -void GLAPIENTRY -_mesa_PushAttrib(GLbitfield mask) -{ - struct gl_attrib_node *head; - - GET_CURRENT_CONTEXT(ctx); - ASSERT_OUTSIDE_BEGIN_END(ctx); - - if (MESA_VERBOSE & VERBOSE_API) - _mesa_debug(ctx, "glPushAttrib %x\n", (int) mask); - - if (ctx->AttribStackDepth >= MAX_ATTRIB_STACK_DEPTH) { - _mesa_error( ctx, GL_STACK_OVERFLOW, "glPushAttrib" ); - return; - } - - /* Build linked list of attribute nodes which save all attribute */ - /* groups specified by the mask. */ - head = NULL; - - if (mask & GL_ACCUM_BUFFER_BIT) { - struct gl_accum_attrib *attr; - attr = MALLOC_STRUCT( gl_accum_attrib ); - memcpy( attr, &ctx->Accum, sizeof(struct gl_accum_attrib) ); - save_attrib_data(&head, GL_ACCUM_BUFFER_BIT, attr); - } - - if (mask & GL_COLOR_BUFFER_BIT) { - struct gl_colorbuffer_attrib *attr; - attr = MALLOC_STRUCT( gl_colorbuffer_attrib ); - memcpy( attr, &ctx->Color, sizeof(struct gl_colorbuffer_attrib) ); - /* push the Draw FBO's DrawBuffer[] state, not ctx->Color.DrawBuffer[] */ - attr->DrawBuffer = ctx->DrawBuffer->ColorDrawBuffer; - save_attrib_data(&head, GL_COLOR_BUFFER_BIT, attr); - } - - if (mask & GL_CURRENT_BIT) { - struct gl_current_attrib *attr; - FLUSH_CURRENT( ctx, 0 ); - attr = MALLOC_STRUCT( gl_current_attrib ); - memcpy( attr, &ctx->Current, sizeof(struct gl_current_attrib) ); - save_attrib_data(&head, GL_CURRENT_BIT, attr); - } - - if (mask & GL_DEPTH_BUFFER_BIT) { - struct gl_depthbuffer_attrib *attr; - attr = MALLOC_STRUCT( gl_depthbuffer_attrib ); - memcpy( attr, &ctx->Depth, sizeof(struct gl_depthbuffer_attrib) ); - save_attrib_data(&head, GL_DEPTH_BUFFER_BIT, attr); - } - - if (mask & GL_ENABLE_BIT) { - struct gl_enable_attrib *attr; - GLuint i; - attr = MALLOC_STRUCT( gl_enable_attrib ); - /* Copy enable flags from all other attributes into the enable struct. */ - attr->AlphaTest = ctx->Color.AlphaEnabled; - attr->AutoNormal = ctx->Eval.AutoNormal; - attr->Blend = ctx->Color.BlendEnabled; - attr->ClipPlanes = ctx->Transform.ClipPlanesEnabled; - attr->ColorMaterial = ctx->Light.ColorMaterialEnabled; - attr->CullFace = ctx->Polygon.CullFlag; - attr->DepthTest = ctx->Depth.Test; - attr->Dither = ctx->Color.DitherFlag; - attr->Fog = ctx->Fog.Enabled; - for (i = 0; i < ctx->Const.MaxLights; i++) { - attr->Light[i] = ctx->Light.Light[i].Enabled; - } - attr->Lighting = ctx->Light.Enabled; - attr->LineSmooth = ctx->Line.SmoothFlag; - attr->LineStipple = ctx->Line.StippleFlag; - attr->IndexLogicOp = ctx->Color.IndexLogicOpEnabled; - attr->ColorLogicOp = ctx->Color.ColorLogicOpEnabled; - attr->Map1Color4 = ctx->Eval.Map1Color4; - attr->Map1Index = ctx->Eval.Map1Index; - attr->Map1Normal = ctx->Eval.Map1Normal; - attr->Map1TextureCoord1 = ctx->Eval.Map1TextureCoord1; - attr->Map1TextureCoord2 = ctx->Eval.Map1TextureCoord2; - attr->Map1TextureCoord3 = ctx->Eval.Map1TextureCoord3; - attr->Map1TextureCoord4 = ctx->Eval.Map1TextureCoord4; - attr->Map1Vertex3 = ctx->Eval.Map1Vertex3; - attr->Map1Vertex4 = ctx->Eval.Map1Vertex4; - attr->Map2Color4 = ctx->Eval.Map2Color4; - attr->Map2Index = ctx->Eval.Map2Index; - attr->Map2Normal = ctx->Eval.Map2Normal; - attr->Map2TextureCoord1 = ctx->Eval.Map2TextureCoord1; - attr->Map2TextureCoord2 = ctx->Eval.Map2TextureCoord2; - attr->Map2TextureCoord3 = ctx->Eval.Map2TextureCoord3; - attr->Map2TextureCoord4 = ctx->Eval.Map2TextureCoord4; - attr->Map2Vertex3 = ctx->Eval.Map2Vertex3; - attr->Map2Vertex4 = ctx->Eval.Map2Vertex4; - attr->Normalize = ctx->Transform.Normalize; - attr->RasterPositionUnclipped = ctx->Transform.RasterPositionUnclipped; - attr->PointSmooth = ctx->Point.SmoothFlag; - attr->PointSprite = ctx->Point.PointSprite; - attr->PolygonOffsetPoint = ctx->Polygon.OffsetPoint; - attr->PolygonOffsetLine = ctx->Polygon.OffsetLine; - attr->PolygonOffsetFill = ctx->Polygon.OffsetFill; - attr->PolygonSmooth = ctx->Polygon.SmoothFlag; - attr->PolygonStipple = ctx->Polygon.StippleFlag; - attr->RescaleNormals = ctx->Transform.RescaleNormals; - attr->Scissor = ctx->Scissor.Enabled; - attr->Stencil = ctx->Stencil.Enabled; - attr->MultisampleEnabled = ctx->Multisample.Enabled; - attr->SampleAlphaToCoverage = ctx->Multisample.SampleAlphaToCoverage; - attr->SampleAlphaToOne = ctx->Multisample.SampleAlphaToOne; - attr->SampleCoverage = ctx->Multisample.SampleCoverage; - attr->Texture = ctx->Texture.Unit.Enabled; - attr->TexGen = ctx->Texture.Unit.TexGenEnabled; - save_attrib_data(&head, GL_ENABLE_BIT, attr); - } - - if (mask & GL_EVAL_BIT) { - struct gl_eval_attrib *attr; - attr = MALLOC_STRUCT( gl_eval_attrib ); - memcpy( attr, &ctx->Eval, sizeof(struct gl_eval_attrib) ); - save_attrib_data(&head, GL_EVAL_BIT, attr); - } - - if (mask & GL_FOG_BIT) { - struct gl_fog_attrib *attr; - attr = MALLOC_STRUCT( gl_fog_attrib ); - memcpy( attr, &ctx->Fog, sizeof(struct gl_fog_attrib) ); - save_attrib_data(&head, GL_FOG_BIT, attr); - } - - if (mask & GL_HINT_BIT) { - struct gl_hint_attrib *attr; - attr = MALLOC_STRUCT( gl_hint_attrib ); - memcpy( attr, &ctx->Hint, sizeof(struct gl_hint_attrib) ); - save_attrib_data(&head, GL_HINT_BIT, attr); - } - - if (mask & GL_LIGHTING_BIT) { - struct gl_light_attrib *attr; - FLUSH_CURRENT(ctx, 0); /* flush material changes */ - attr = MALLOC_STRUCT( gl_light_attrib ); - memcpy( attr, &ctx->Light, sizeof(struct gl_light_attrib) ); - save_attrib_data(&head, GL_LIGHTING_BIT, attr); - } - - if (mask & GL_LINE_BIT) { - struct gl_line_attrib *attr; - attr = MALLOC_STRUCT( gl_line_attrib ); - memcpy( attr, &ctx->Line, sizeof(struct gl_line_attrib) ); - save_attrib_data(&head, GL_LINE_BIT, attr); - } - - if (mask & GL_LIST_BIT) { - struct gl_list_attrib *attr; - attr = MALLOC_STRUCT( gl_list_attrib ); - memcpy( attr, &ctx->List, sizeof(struct gl_list_attrib) ); - save_attrib_data(&head, GL_LIST_BIT, attr); - } - - if (mask & GL_PIXEL_MODE_BIT) { - struct gl_pixel_attrib *attr; - attr = MALLOC_STRUCT( gl_pixel_attrib ); - memcpy( attr, &ctx->Pixel, sizeof(struct gl_pixel_attrib) ); - /* push the Read FBO's ReadBuffer state, not ctx->Pixel.ReadBuffer */ - attr->ReadBuffer = ctx->ReadBuffer->ColorReadBuffer; - save_attrib_data(&head, GL_PIXEL_MODE_BIT, attr); - } - - if (mask & GL_POINT_BIT) { - struct gl_point_attrib *attr; - attr = MALLOC_STRUCT( gl_point_attrib ); - memcpy( attr, &ctx->Point, sizeof(struct gl_point_attrib) ); - save_attrib_data(&head, GL_POINT_BIT, attr); - } - - if (mask & GL_POLYGON_BIT) { - struct gl_polygon_attrib *attr; - attr = MALLOC_STRUCT( gl_polygon_attrib ); - memcpy( attr, &ctx->Polygon, sizeof(struct gl_polygon_attrib) ); - save_attrib_data(&head, GL_POLYGON_BIT, attr); - } - - if (mask & GL_POLYGON_STIPPLE_BIT) { - GLuint *stipple; - stipple = (GLuint *) MALLOC( 32*sizeof(GLuint) ); - memcpy( stipple, ctx->PolygonStipple, 32*sizeof(GLuint) ); - save_attrib_data(&head, GL_POLYGON_STIPPLE_BIT, stipple); - } - - if (mask & GL_SCISSOR_BIT) { - struct gl_scissor_attrib *attr; - attr = MALLOC_STRUCT( gl_scissor_attrib ); - memcpy( attr, &ctx->Scissor, sizeof(struct gl_scissor_attrib) ); - save_attrib_data(&head, GL_SCISSOR_BIT, attr); - } - - if (mask & GL_STENCIL_BUFFER_BIT) { - struct gl_stencil_attrib *attr; - attr = MALLOC_STRUCT( gl_stencil_attrib ); - memcpy( attr, &ctx->Stencil, sizeof(struct gl_stencil_attrib) ); - save_attrib_data(&head, GL_STENCIL_BUFFER_BIT, attr); - } - - if (mask & GL_TEXTURE_BIT) { - struct texture_state *texstate = CALLOC_STRUCT(texture_state); - GLuint tex; - - if (!texstate) { - _mesa_error(ctx, GL_OUT_OF_MEMORY, "glPushAttrib(GL_TEXTURE_BIT)"); - goto end; - } - - _mesa_lock_context_textures(ctx); - - /* copy/save the bulk of texture state here */ - memcpy(&texstate->Texture, &ctx->Texture, sizeof(ctx->Texture)); - - /* Save references to the currently bound texture objects so they don't - * accidentally get deleted while referenced in the attribute stack. - */ - for (tex = 0; tex < NUM_TEXTURE_TARGETS; tex++) { - _mesa_reference_texobj(&texstate->SavedTexRef[tex], - ctx->Texture.Unit.CurrentTex[tex]); - } - - /* copy state/contents of the currently bound texture objects */ - for (tex = 0; tex < NUM_TEXTURE_TARGETS; tex++) { - _mesa_copy_texture_object(&texstate->SavedObj[tex], - ctx->Texture.Unit.CurrentTex[tex]); - } - - _mesa_reference_shared_state(ctx, &texstate->SharedRef, ctx->Shared); - - _mesa_unlock_context_textures(ctx); - - save_attrib_data(&head, GL_TEXTURE_BIT, texstate); - } - - if (mask & GL_TRANSFORM_BIT) { - struct gl_transform_attrib *attr; - attr = MALLOC_STRUCT( gl_transform_attrib ); - memcpy( attr, &ctx->Transform, sizeof(struct gl_transform_attrib) ); - save_attrib_data(&head, GL_TRANSFORM_BIT, attr); - } - - if (mask & GL_VIEWPORT_BIT) { - struct gl_viewport_attrib *attr; - attr = MALLOC_STRUCT( gl_viewport_attrib ); - memcpy( attr, &ctx->Viewport, sizeof(struct gl_viewport_attrib) ); - save_attrib_data(&head, GL_VIEWPORT_BIT, attr); - } - - /* GL_ARB_multisample */ - if (mask & GL_MULTISAMPLE_BIT_ARB) { - struct gl_multisample_attrib *attr; - attr = MALLOC_STRUCT( gl_multisample_attrib ); - memcpy( attr, &ctx->Multisample, sizeof(struct gl_multisample_attrib) ); - save_attrib_data(&head, GL_MULTISAMPLE_BIT_ARB, attr); - } - -end: - ctx->AttribStack[ctx->AttribStackDepth] = head; - ctx->AttribStackDepth++; -} - - - -static void -pop_enable_group(struct gl_context *ctx, const struct gl_enable_attrib *enable) -{ - GLuint i; - -#define TEST_AND_UPDATE(VALUE, NEWVALUE, ENUM) \ - if ((VALUE) != (NEWVALUE)) { \ - _mesa_set_enable( ctx, ENUM, (NEWVALUE) ); \ - } - - TEST_AND_UPDATE(ctx->Color.AlphaEnabled, enable->AlphaTest, GL_ALPHA_TEST); - if (ctx->Color.BlendEnabled != enable->Blend) { - _mesa_set_enable(ctx, GL_BLEND, (enable->Blend & 1)); - } - - for (i=0;iConst.MaxClipPlanes;i++) { - const GLuint mask = 1 << i; - if ((ctx->Transform.ClipPlanesEnabled & mask) != (enable->ClipPlanes & mask)) - _mesa_set_enable(ctx, (GLenum) (GL_CLIP_PLANE0 + i), - !!(enable->ClipPlanes & mask)); - } - - TEST_AND_UPDATE(ctx->Light.ColorMaterialEnabled, enable->ColorMaterial, - GL_COLOR_MATERIAL); - TEST_AND_UPDATE(ctx->Polygon.CullFlag, enable->CullFace, GL_CULL_FACE); - TEST_AND_UPDATE(ctx->Depth.Test, enable->DepthTest, GL_DEPTH_TEST); - TEST_AND_UPDATE(ctx->Color.DitherFlag, enable->Dither, GL_DITHER); - TEST_AND_UPDATE(ctx->Fog.Enabled, enable->Fog, GL_FOG); - TEST_AND_UPDATE(ctx->Light.Enabled, enable->Lighting, GL_LIGHTING); - TEST_AND_UPDATE(ctx->Line.SmoothFlag, enable->LineSmooth, GL_LINE_SMOOTH); - TEST_AND_UPDATE(ctx->Line.StippleFlag, enable->LineStipple, - GL_LINE_STIPPLE); - TEST_AND_UPDATE(ctx->Color.IndexLogicOpEnabled, enable->IndexLogicOp, - GL_INDEX_LOGIC_OP); - TEST_AND_UPDATE(ctx->Color.ColorLogicOpEnabled, enable->ColorLogicOp, - GL_COLOR_LOGIC_OP); - - TEST_AND_UPDATE(ctx->Eval.Map1Color4, enable->Map1Color4, GL_MAP1_COLOR_4); - TEST_AND_UPDATE(ctx->Eval.Map1Index, enable->Map1Index, GL_MAP1_INDEX); - TEST_AND_UPDATE(ctx->Eval.Map1Normal, enable->Map1Normal, GL_MAP1_NORMAL); - TEST_AND_UPDATE(ctx->Eval.Map1TextureCoord1, enable->Map1TextureCoord1, - GL_MAP1_TEXTURE_COORD_1); - TEST_AND_UPDATE(ctx->Eval.Map1TextureCoord2, enable->Map1TextureCoord2, - GL_MAP1_TEXTURE_COORD_2); - TEST_AND_UPDATE(ctx->Eval.Map1TextureCoord3, enable->Map1TextureCoord3, - GL_MAP1_TEXTURE_COORD_3); - TEST_AND_UPDATE(ctx->Eval.Map1TextureCoord4, enable->Map1TextureCoord4, - GL_MAP1_TEXTURE_COORD_4); - TEST_AND_UPDATE(ctx->Eval.Map1Vertex3, enable->Map1Vertex3, - GL_MAP1_VERTEX_3); - TEST_AND_UPDATE(ctx->Eval.Map1Vertex4, enable->Map1Vertex4, - GL_MAP1_VERTEX_4); - - TEST_AND_UPDATE(ctx->Eval.Map2Color4, enable->Map2Color4, GL_MAP2_COLOR_4); - TEST_AND_UPDATE(ctx->Eval.Map2Index, enable->Map2Index, GL_MAP2_INDEX); - TEST_AND_UPDATE(ctx->Eval.Map2Normal, enable->Map2Normal, GL_MAP2_NORMAL); - TEST_AND_UPDATE(ctx->Eval.Map2TextureCoord1, enable->Map2TextureCoord1, - GL_MAP2_TEXTURE_COORD_1); - TEST_AND_UPDATE(ctx->Eval.Map2TextureCoord2, enable->Map2TextureCoord2, - GL_MAP2_TEXTURE_COORD_2); - TEST_AND_UPDATE(ctx->Eval.Map2TextureCoord3, enable->Map2TextureCoord3, - GL_MAP2_TEXTURE_COORD_3); - TEST_AND_UPDATE(ctx->Eval.Map2TextureCoord4, enable->Map2TextureCoord4, - GL_MAP2_TEXTURE_COORD_4); - TEST_AND_UPDATE(ctx->Eval.Map2Vertex3, enable->Map2Vertex3, - GL_MAP2_VERTEX_3); - TEST_AND_UPDATE(ctx->Eval.Map2Vertex4, enable->Map2Vertex4, - GL_MAP2_VERTEX_4); - - TEST_AND_UPDATE(ctx->Eval.AutoNormal, enable->AutoNormal, GL_AUTO_NORMAL); - TEST_AND_UPDATE(ctx->Transform.Normalize, enable->Normalize, GL_NORMALIZE); - TEST_AND_UPDATE(ctx->Transform.RescaleNormals, enable->RescaleNormals, - GL_RESCALE_NORMAL_EXT); - TEST_AND_UPDATE(ctx->Transform.RasterPositionUnclipped, - enable->RasterPositionUnclipped, - GL_RASTER_POSITION_UNCLIPPED_IBM); - TEST_AND_UPDATE(ctx->Point.SmoothFlag, enable->PointSmooth, - GL_POINT_SMOOTH); - if (ctx->Extensions.NV_point_sprite || ctx->Extensions.ARB_point_sprite) { - TEST_AND_UPDATE(ctx->Point.PointSprite, enable->PointSprite, - GL_POINT_SPRITE_NV); - } - TEST_AND_UPDATE(ctx->Polygon.OffsetPoint, enable->PolygonOffsetPoint, - GL_POLYGON_OFFSET_POINT); - TEST_AND_UPDATE(ctx->Polygon.OffsetLine, enable->PolygonOffsetLine, - GL_POLYGON_OFFSET_LINE); - TEST_AND_UPDATE(ctx->Polygon.OffsetFill, enable->PolygonOffsetFill, - GL_POLYGON_OFFSET_FILL); - TEST_AND_UPDATE(ctx->Polygon.SmoothFlag, enable->PolygonSmooth, - GL_POLYGON_SMOOTH); - TEST_AND_UPDATE(ctx->Polygon.StippleFlag, enable->PolygonStipple, - GL_POLYGON_STIPPLE); - TEST_AND_UPDATE(ctx->Scissor.Enabled, enable->Scissor, GL_SCISSOR_TEST); - TEST_AND_UPDATE(ctx->Stencil.Enabled, enable->Stencil, GL_STENCIL_TEST); - TEST_AND_UPDATE(ctx->Multisample.Enabled, enable->MultisampleEnabled, - GL_MULTISAMPLE_ARB); - TEST_AND_UPDATE(ctx->Multisample.SampleAlphaToCoverage, - enable->SampleAlphaToCoverage, - GL_SAMPLE_ALPHA_TO_COVERAGE_ARB); - TEST_AND_UPDATE(ctx->Multisample.SampleAlphaToOne, - enable->SampleAlphaToOne, - GL_SAMPLE_ALPHA_TO_ONE_ARB); - TEST_AND_UPDATE(ctx->Multisample.SampleCoverage, - enable->SampleCoverage, - GL_SAMPLE_COVERAGE_ARB); - - /* texture unit enables */ - { - const GLbitfield enabled = enable->Texture; - const GLbitfield genEnabled = enable->TexGen; - - if (ctx->Texture.Unit.Enabled != enabled) { - _mesa_set_enable(ctx, GL_TEXTURE_1D, !!(enabled & TEXTURE_1D_BIT)); - _mesa_set_enable(ctx, GL_TEXTURE_2D, !!(enabled & TEXTURE_2D_BIT)); - if (ctx->Extensions.ARB_texture_cube_map) { - _mesa_set_enable(ctx, GL_TEXTURE_CUBE_MAP, - !!(enabled & TEXTURE_CUBE_BIT)); - } - } - - if (ctx->Texture.Unit.TexGenEnabled != genEnabled) { - _mesa_set_enable(ctx, GL_TEXTURE_GEN_S, !!(genEnabled & S_BIT)); - _mesa_set_enable(ctx, GL_TEXTURE_GEN_T, !!(genEnabled & T_BIT)); - _mesa_set_enable(ctx, GL_TEXTURE_GEN_R, !!(genEnabled & R_BIT)); - _mesa_set_enable(ctx, GL_TEXTURE_GEN_Q, !!(genEnabled & Q_BIT)); - } - } -} - - -/** - * Pop/restore texture attribute/group state. - */ -static void -pop_texture_group(struct gl_context *ctx, struct texture_state *texstate) -{ - const struct gl_texture_unit *unit; - GLuint tgt; - - _mesa_lock_context_textures(ctx); - - unit = &texstate->Texture.Unit; - - _mesa_set_enable(ctx, GL_TEXTURE_1D, !!(unit->Enabled & TEXTURE_1D_BIT)); - _mesa_set_enable(ctx, GL_TEXTURE_2D, !!(unit->Enabled & TEXTURE_2D_BIT)); - - _mesa_TexEnvi(GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, unit->EnvMode); - _mesa_TexEnvfv(GL_TEXTURE_ENV, GL_TEXTURE_ENV_COLOR, unit->EnvColor); - _mesa_TexGeni(GL_S, GL_TEXTURE_GEN_MODE, unit->GenS.Mode); - _mesa_TexGeni(GL_T, GL_TEXTURE_GEN_MODE, unit->GenT.Mode); - _mesa_TexGeni(GL_R, GL_TEXTURE_GEN_MODE, unit->GenR.Mode); - _mesa_TexGeni(GL_Q, GL_TEXTURE_GEN_MODE, unit->GenQ.Mode); - _mesa_TexGenfv(GL_S, GL_OBJECT_PLANE, unit->GenS.ObjectPlane); - _mesa_TexGenfv(GL_T, GL_OBJECT_PLANE, unit->GenT.ObjectPlane); - _mesa_TexGenfv(GL_R, GL_OBJECT_PLANE, unit->GenR.ObjectPlane); - _mesa_TexGenfv(GL_Q, GL_OBJECT_PLANE, unit->GenQ.ObjectPlane); - /* Eye plane done differently to avoid re-transformation */ - { - struct gl_texture_unit *destUnit = &ctx->Texture.Unit; - COPY_4FV(destUnit->GenS.EyePlane, unit->GenS.EyePlane); - COPY_4FV(destUnit->GenT.EyePlane, unit->GenT.EyePlane); - COPY_4FV(destUnit->GenR.EyePlane, unit->GenR.EyePlane); - COPY_4FV(destUnit->GenQ.EyePlane, unit->GenQ.EyePlane); - if (ctx->Driver.TexGen) { - ctx->Driver.TexGen(ctx, GL_S, GL_EYE_PLANE, unit->GenS.EyePlane); - ctx->Driver.TexGen(ctx, GL_T, GL_EYE_PLANE, unit->GenT.EyePlane); - ctx->Driver.TexGen(ctx, GL_R, GL_EYE_PLANE, unit->GenR.EyePlane); - ctx->Driver.TexGen(ctx, GL_Q, GL_EYE_PLANE, unit->GenQ.EyePlane); - } - } - _mesa_set_enable(ctx, GL_TEXTURE_GEN_S, !!(unit->TexGenEnabled & S_BIT)); - _mesa_set_enable(ctx, GL_TEXTURE_GEN_T, !!(unit->TexGenEnabled & T_BIT)); - _mesa_set_enable(ctx, GL_TEXTURE_GEN_R, !!(unit->TexGenEnabled & R_BIT)); - _mesa_set_enable(ctx, GL_TEXTURE_GEN_Q, !!(unit->TexGenEnabled & Q_BIT)); - _mesa_TexEnvf(GL_TEXTURE_FILTER_CONTROL, GL_TEXTURE_LOD_BIAS, - unit->LodBias); - _mesa_TexEnvi(GL_TEXTURE_ENV, GL_COMBINE_RGB, - unit->Combine.ModeRGB); - _mesa_TexEnvi(GL_TEXTURE_ENV, GL_COMBINE_ALPHA, - unit->Combine.ModeA); - { - const GLuint n = ctx->Extensions.NV_texture_env_combine4 ? 4 : 3; - GLuint i; - for (i = 0; i < n; i++) { - _mesa_TexEnvi(GL_TEXTURE_ENV, GL_SOURCE0_RGB + i, - unit->Combine.SourceRGB[i]); - _mesa_TexEnvi(GL_TEXTURE_ENV, GL_SOURCE0_ALPHA + i, - unit->Combine.SourceA[i]); - _mesa_TexEnvi(GL_TEXTURE_ENV, GL_OPERAND0_RGB + i, - unit->Combine.OperandRGB[i]); - _mesa_TexEnvi(GL_TEXTURE_ENV, GL_OPERAND0_ALPHA + i, - unit->Combine.OperandA[i]); - } - } - _mesa_TexEnvi(GL_TEXTURE_ENV, GL_RGB_SCALE, 1 << unit->Combine.ScaleShiftRGB); - _mesa_TexEnvi(GL_TEXTURE_ENV, GL_ALPHA_SCALE, 1 << unit->Combine.ScaleShiftA); - - /* Restore texture object state for each target */ - for (tgt = 0; tgt < NUM_TEXTURE_TARGETS; tgt++) { - const struct gl_texture_object *obj = NULL; - const struct gl_sampler_object *samp; - GLenum target; - - obj = &texstate->SavedObj[tgt]; - - /* don't restore state for unsupported targets to prevent - * raising GL errors. - */ - if (obj->Target == GL_TEXTURE_CUBE_MAP_ARB && - !ctx->Extensions.ARB_texture_cube_map) { - continue; - } - - target = obj->Target; - - _mesa_BindTexture(target, obj->Name); - - samp = &obj->Sampler; - - _mesa_TexParameterfv(target, GL_TEXTURE_BORDER_COLOR, samp->BorderColor.f); - _mesa_TexParameteri(target, GL_TEXTURE_WRAP_S, samp->WrapS); - _mesa_TexParameteri(target, GL_TEXTURE_WRAP_T, samp->WrapT); - _mesa_TexParameteri(target, GL_TEXTURE_WRAP_R, samp->WrapR); - _mesa_TexParameteri(target, GL_TEXTURE_MIN_FILTER, samp->MinFilter); - _mesa_TexParameteri(target, GL_TEXTURE_MAG_FILTER, samp->MagFilter); - _mesa_TexParameterf(target, GL_TEXTURE_PRIORITY, obj->Priority); - if (ctx->Extensions.EXT_texture_filter_anisotropic) { - _mesa_TexParameterf(target, GL_TEXTURE_MAX_ANISOTROPY_EXT, - samp->MaxAnisotropy); - } - } - - /* remove saved references to the texture objects */ - for (tgt = 0; tgt < NUM_TEXTURE_TARGETS; tgt++) { - _mesa_reference_texobj(&texstate->SavedTexRef[tgt], NULL); - } - - _mesa_reference_shared_state(ctx, &texstate->SharedRef, NULL); - - _mesa_unlock_context_textures(ctx); -} - - -/* - * This function is kind of long just because we have to call a lot - * of device driver functions to update device driver state. - * - * XXX As it is now, most of the pop-code calls immediate-mode Mesa functions - * in order to restore GL state. This isn't terribly efficient but it - * ensures that dirty flags and any derived state gets updated correctly. - * We could at least check if the value to restore equals the current value - * and then skip the Mesa call. - */ -void GLAPIENTRY -_mesa_PopAttrib(void) -{ - struct gl_attrib_node *attr, *next; - GET_CURRENT_CONTEXT(ctx); - ASSERT_OUTSIDE_BEGIN_END_AND_FLUSH(ctx); - - if (ctx->AttribStackDepth == 0) { - _mesa_error( ctx, GL_STACK_UNDERFLOW, "glPopAttrib" ); - return; - } - - ctx->AttribStackDepth--; - attr = ctx->AttribStack[ctx->AttribStackDepth]; - - while (attr) { - - if (MESA_VERBOSE & VERBOSE_API) { - _mesa_debug(ctx, "glPopAttrib %s\n", - _mesa_lookup_enum_by_nr(attr->kind)); - } - - switch (attr->kind) { - case GL_ACCUM_BUFFER_BIT: - { - const struct gl_accum_attrib *accum; - accum = (const struct gl_accum_attrib *) attr->data; - _mesa_ClearAccum(accum->ClearColor[0], - accum->ClearColor[1], - accum->ClearColor[2], - accum->ClearColor[3]); - } - break; - case GL_COLOR_BUFFER_BIT: - { - const struct gl_colorbuffer_attrib *color; - - color = (const struct gl_colorbuffer_attrib *) attr->data; - _mesa_ClearIndex((GLfloat) color->ClearIndex); - _mesa_ClearColor(color->ClearColor.f[0], - color->ClearColor.f[1], - color->ClearColor.f[2], - color->ClearColor.f[3]); - _mesa_IndexMask(color->IndexMask); - _mesa_ColorMask((GLboolean) (color->ColorMask[0] != 0), - (GLboolean) (color->ColorMask[1] != 0), - (GLboolean) (color->ColorMask[2] != 0), - (GLboolean) (color->ColorMask[3] != 0)); - _mesa_DrawBuffer(color->DrawBuffer); - _mesa_set_enable(ctx, GL_ALPHA_TEST, color->AlphaEnabled); - _mesa_AlphaFunc(color->AlphaFunc, color->AlphaRef); - if (ctx->Color.BlendEnabled != color->BlendEnabled) { - _mesa_set_enable(ctx, GL_BLEND, (color->BlendEnabled & 1)); - } - /* set same blend modes for all buffers */ - _mesa_BlendFunc(color->SrcFactor, color->DstFactor); - _mesa_LogicOp(color->LogicOp); - _mesa_set_enable(ctx, GL_COLOR_LOGIC_OP, - color->ColorLogicOpEnabled); - _mesa_set_enable(ctx, GL_INDEX_LOGIC_OP, - color->IndexLogicOpEnabled); - _mesa_set_enable(ctx, GL_DITHER, color->DitherFlag); - } - break; - case GL_CURRENT_BIT: - FLUSH_CURRENT( ctx, 0 ); - memcpy( &ctx->Current, attr->data, - sizeof(struct gl_current_attrib) ); - break; - case GL_DEPTH_BUFFER_BIT: - { - const struct gl_depthbuffer_attrib *depth; - depth = (const struct gl_depthbuffer_attrib *) attr->data; - _mesa_DepthFunc(depth->Func); - _mesa_ClearDepth(depth->Clear); - _mesa_set_enable(ctx, GL_DEPTH_TEST, depth->Test); - _mesa_DepthMask(depth->Mask); - } - break; - case GL_ENABLE_BIT: - { - const struct gl_enable_attrib *enable; - enable = (const struct gl_enable_attrib *) attr->data; - pop_enable_group(ctx, enable); - ctx->NewState |= _NEW_ALL; - } - break; - case GL_EVAL_BIT: - memcpy( &ctx->Eval, attr->data, sizeof(struct gl_eval_attrib) ); - ctx->NewState |= _NEW_EVAL; - break; - case GL_FOG_BIT: - { - const struct gl_fog_attrib *fog; - fog = (const struct gl_fog_attrib *) attr->data; - _mesa_set_enable(ctx, GL_FOG, fog->Enabled); - _mesa_Fogfv(GL_FOG_COLOR, fog->Color); - _mesa_Fogf(GL_FOG_DENSITY, fog->Density); - _mesa_Fogf(GL_FOG_START, fog->Start); - _mesa_Fogf(GL_FOG_END, fog->End); - _mesa_Fogf(GL_FOG_INDEX, fog->Index); - _mesa_Fogi(GL_FOG_MODE, fog->Mode); - } - break; - case GL_HINT_BIT: - { - const struct gl_hint_attrib *hint; - hint = (const struct gl_hint_attrib *) attr->data; - _mesa_Hint(GL_PERSPECTIVE_CORRECTION_HINT, - hint->PerspectiveCorrection ); - _mesa_Hint(GL_POINT_SMOOTH_HINT, hint->PointSmooth); - _mesa_Hint(GL_LINE_SMOOTH_HINT, hint->LineSmooth); - _mesa_Hint(GL_POLYGON_SMOOTH_HINT, hint->PolygonSmooth); - _mesa_Hint(GL_FOG_HINT, hint->Fog); - _mesa_Hint(GL_CLIP_VOLUME_CLIPPING_HINT_EXT, - hint->ClipVolumeClipping); - } - break; - case GL_LIGHTING_BIT: - { - GLuint i; - const struct gl_light_attrib *light; - light = (const struct gl_light_attrib *) attr->data; - /* lighting enable */ - _mesa_set_enable(ctx, GL_LIGHTING, light->Enabled); - /* per-light state */ - if (_math_matrix_is_dirty(ctx->ModelviewMatrixStack.Top)) - _math_matrix_analyse( ctx->ModelviewMatrixStack.Top ); - - for (i = 0; i < ctx->Const.MaxLights; i++) { - const struct gl_light *l = &light->Light[i]; - _mesa_set_enable(ctx, GL_LIGHT0 + i, l->Enabled); - _mesa_light(ctx, i, GL_AMBIENT, l->Ambient); - _mesa_light(ctx, i, GL_DIFFUSE, l->Diffuse); - _mesa_light(ctx, i, GL_SPECULAR, l->Specular ); - _mesa_light(ctx, i, GL_POSITION, l->EyePosition); - _mesa_light(ctx, i, GL_SPOT_DIRECTION, l->SpotDirection); - { - GLfloat p[4] = { 0 }; - p[0] = l->SpotExponent; - _mesa_light(ctx, i, GL_SPOT_EXPONENT, p); - } - { - GLfloat p[4] = { 0 }; - p[0] = l->SpotCutoff; - _mesa_light(ctx, i, GL_SPOT_CUTOFF, p); - } - { - GLfloat p[4] = { 0 }; - p[0] = l->ConstantAttenuation; - _mesa_light(ctx, i, GL_CONSTANT_ATTENUATION, p); - } - { - GLfloat p[4] = { 0 }; - p[0] = l->LinearAttenuation; - _mesa_light(ctx, i, GL_LINEAR_ATTENUATION, p); - } - { - GLfloat p[4] = { 0 }; - p[0] = l->QuadraticAttenuation; - _mesa_light(ctx, i, GL_QUADRATIC_ATTENUATION, p); - } - } - /* light model */ - _mesa_LightModelfv(GL_LIGHT_MODEL_AMBIENT, - light->Model.Ambient); - _mesa_LightModelf(GL_LIGHT_MODEL_LOCAL_VIEWER, - (GLfloat) light->Model.LocalViewer); - _mesa_LightModelf(GL_LIGHT_MODEL_TWO_SIDE, - (GLfloat) light->Model.TwoSide); - /* shade model */ - _mesa_ShadeModel(light->ShadeModel); - /* color material */ - _mesa_ColorMaterial(light->ColorMaterialFace, - light->ColorMaterialMode); - _mesa_set_enable(ctx, GL_COLOR_MATERIAL, - light->ColorMaterialEnabled); - /* materials */ - memcpy(&ctx->Light.Material, &light->Material, - sizeof(struct gl_material)); - } - break; - case GL_LINE_BIT: - { - const struct gl_line_attrib *line; - line = (const struct gl_line_attrib *) attr->data; - _mesa_set_enable(ctx, GL_LINE_SMOOTH, line->SmoothFlag); - _mesa_set_enable(ctx, GL_LINE_STIPPLE, line->StippleFlag); - _mesa_LineStipple(line->StippleFactor, line->StipplePattern); - _mesa_LineWidth(line->Width); - } - break; - case GL_LIST_BIT: - memcpy( &ctx->List, attr->data, sizeof(struct gl_list_attrib) ); - break; - case GL_PIXEL_MODE_BIT: - memcpy( &ctx->Pixel, attr->data, sizeof(struct gl_pixel_attrib) ); - /* XXX what other pixel state needs to be set by function calls? */ - _mesa_ReadBuffer(ctx->Pixel.ReadBuffer); - ctx->NewState |= _NEW_PIXEL; - break; - case GL_POINT_BIT: - { - const struct gl_point_attrib *point; - point = (const struct gl_point_attrib *) attr->data; - _mesa_PointSize(point->Size); - _mesa_set_enable(ctx, GL_POINT_SMOOTH, point->SmoothFlag); - } - break; - case GL_POLYGON_BIT: - { - const struct gl_polygon_attrib *polygon; - polygon = (const struct gl_polygon_attrib *) attr->data; - _mesa_CullFace(polygon->CullFaceMode); - _mesa_FrontFace(polygon->FrontFace); - _mesa_PolygonMode(GL_FRONT, polygon->FrontMode); - _mesa_PolygonMode(GL_BACK, polygon->BackMode); - _mesa_PolygonOffset(polygon->OffsetFactor, - polygon->OffsetUnits); - _mesa_set_enable(ctx, GL_POLYGON_SMOOTH, polygon->SmoothFlag); - _mesa_set_enable(ctx, GL_POLYGON_STIPPLE, polygon->StippleFlag); - _mesa_set_enable(ctx, GL_CULL_FACE, polygon->CullFlag); - _mesa_set_enable(ctx, GL_POLYGON_OFFSET_POINT, - polygon->OffsetPoint); - _mesa_set_enable(ctx, GL_POLYGON_OFFSET_LINE, - polygon->OffsetLine); - _mesa_set_enable(ctx, GL_POLYGON_OFFSET_FILL, - polygon->OffsetFill); - } - break; - case GL_POLYGON_STIPPLE_BIT: - memcpy( ctx->PolygonStipple, attr->data, 32*sizeof(GLuint) ); - ctx->NewState |= _NEW_POLYGONSTIPPLE; - if (ctx->Driver.PolygonStipple) - ctx->Driver.PolygonStipple( ctx, (const GLubyte *) attr->data ); - break; - case GL_SCISSOR_BIT: - { - const struct gl_scissor_attrib *scissor; - scissor = (const struct gl_scissor_attrib *) attr->data; - _mesa_Scissor(scissor->X, scissor->Y, - scissor->Width, scissor->Height); - _mesa_set_enable(ctx, GL_SCISSOR_TEST, scissor->Enabled); - } - break; - case GL_STENCIL_BUFFER_BIT: - { - const struct gl_stencil_attrib *stencil; - stencil = (const struct gl_stencil_attrib *) attr->data; - _mesa_set_enable(ctx, GL_STENCIL_TEST, stencil->Enabled); - _mesa_ClearStencil(stencil->Clear); - _mesa_StencilFunc(stencil->Function, - stencil->Ref, - stencil->ValueMask); - _mesa_StencilMask(stencil->WriteMask); - _mesa_StencilOp(stencil->FailFunc, - stencil->ZFailFunc, - stencil->ZPassFunc); - } - break; - case GL_TRANSFORM_BIT: - { - GLuint i; - const struct gl_transform_attrib *xform; - xform = (const struct gl_transform_attrib *) attr->data; - _mesa_MatrixMode(xform->MatrixMode); - if (_math_matrix_is_dirty(ctx->ProjectionMatrixStack.Top)) - _math_matrix_analyse( ctx->ProjectionMatrixStack.Top ); - - /* restore clip planes */ - for (i = 0; i < ctx->Const.MaxClipPlanes; i++) { - const GLuint mask = 1 << i; - const GLfloat *eyePlane = xform->EyeUserPlane[i]; - COPY_4V(ctx->Transform.EyeUserPlane[i], eyePlane); - _mesa_set_enable(ctx, GL_CLIP_PLANE0 + i, - !!(xform->ClipPlanesEnabled & mask)); - if (ctx->Driver.ClipPlane) - ctx->Driver.ClipPlane( ctx, GL_CLIP_PLANE0 + i, eyePlane ); - } - - /* normalize/rescale */ - if (xform->Normalize != ctx->Transform.Normalize) - _mesa_set_enable(ctx, GL_NORMALIZE,ctx->Transform.Normalize); - if (xform->RescaleNormals != ctx->Transform.RescaleNormals) - _mesa_set_enable(ctx, GL_RESCALE_NORMAL_EXT, - ctx->Transform.RescaleNormals); - } - break; - case GL_TEXTURE_BIT: - /* Take care of texture object reference counters */ - { - struct texture_state *texstate - = (struct texture_state *) attr->data; - pop_texture_group(ctx, texstate); - ctx->NewState |= _NEW_TEXTURE; - } - break; - case GL_VIEWPORT_BIT: - { - const struct gl_viewport_attrib *vp; - vp = (const struct gl_viewport_attrib *) attr->data; - _mesa_Viewport(vp->X, vp->Y, vp->Width, vp->Height); - _mesa_DepthRange(vp->Near, vp->Far); - } - break; - case GL_MULTISAMPLE_BIT_ARB: - { - const struct gl_multisample_attrib *ms; - ms = (const struct gl_multisample_attrib *) attr->data; - - TEST_AND_UPDATE(ctx->Multisample.Enabled, - ms->Enabled, - GL_MULTISAMPLE); - - TEST_AND_UPDATE(ctx->Multisample.SampleCoverage, - ms->SampleCoverage, - GL_SAMPLE_COVERAGE); - - TEST_AND_UPDATE(ctx->Multisample.SampleAlphaToCoverage, - ms->SampleAlphaToCoverage, - GL_SAMPLE_ALPHA_TO_COVERAGE); - - TEST_AND_UPDATE(ctx->Multisample.SampleAlphaToOne, - ms->SampleAlphaToOne, - GL_SAMPLE_ALPHA_TO_ONE); - - _mesa_SampleCoverageARB(ms->SampleCoverageValue, - ms->SampleCoverageInvert); - } - break; - - default: - _mesa_problem( ctx, "Bad attrib flag in PopAttrib"); - break; - } - - next = attr->next; - FREE( attr->data ); - FREE( attr ); - attr = next; - } -} - - -/** - * Copy gl_pixelstore_attrib from src to dst, updating buffer - * object refcounts. - */ -static void -copy_pixelstore(struct gl_context *ctx, - struct gl_pixelstore_attrib *dst, - const struct gl_pixelstore_attrib *src) -{ - dst->Alignment = src->Alignment; - dst->RowLength = src->RowLength; - dst->SkipPixels = src->SkipPixels; - dst->SkipRows = src->SkipRows; - dst->ImageHeight = src->ImageHeight; - dst->SkipImages = src->SkipImages; - dst->SwapBytes = src->SwapBytes; - dst->LsbFirst = src->LsbFirst; - dst->Invert = src->Invert; -} - - -#define GL_CLIENT_PACK_BIT (1<<20) -#define GL_CLIENT_UNPACK_BIT (1<<21) - -/** - * Copy gl_array_attrib from src to dest. - * 'dest' must be in an initialized state. - */ -static void -copy_array_attrib(struct gl_context *ctx, - struct gl_array_attrib *dest, - struct gl_array_attrib *src) -{ - GLuint i; - - /* skip ArrayObj */ - /* skip DefaultArrayObj, Objects */ - dest->LockFirst = src->LockFirst; - dest->LockCount = src->LockCount; - /* skip NewState */ - /* skip RebindArrays */ - - - /* skip Name */ - /* skip RefCount */ - - for (i = 0; i < Elements(src->VertexAttrib); i++) - _mesa_copy_client_array(ctx, &dest->VertexAttrib[i], &src->VertexAttrib[i]); - - /* _Enabled must be the same than on push */ - dest->_Enabled = src->_Enabled; - dest->_MaxElement = src->_MaxElement; - - /* skip ArrayBufferObj */ - /* skip ElementArrayBufferObj */ -} - -/** - * Save the content of src to dest. - */ -static void -save_array_attrib(struct gl_context *ctx, - struct gl_array_attrib *dest, - struct gl_array_attrib *src) -{ - /* And copy all of the rest. */ - copy_array_attrib(ctx, dest, src); - - /* Just reference them here */ - _mesa_reference_buffer_object(ctx, &dest->ElementArrayBufferObj, - src->ElementArrayBufferObj); -} - -/** - * Restore the content of src to dest. - */ -static void -restore_array_attrib(struct gl_context *ctx, - struct gl_array_attrib *dest, - struct gl_array_attrib *src) -{ - copy_array_attrib(ctx, dest, src); - - if (src->ElementArrayBufferObj->Name == 0 - || _mesa_IsBufferARB(src->ElementArrayBufferObj->Name)) - _mesa_BindBufferARB(GL_ELEMENT_ARRAY_BUFFER_ARB, - src->ElementArrayBufferObj->Name); - - /* Better safe than sorry?! */ - dest->RebindArrays = GL_TRUE; - - /* FIXME: Should some bits in ctx->Array->NewState also be set - * FIXME: here? It seems like it should be set to inclusive-or - * FIXME: of the old ArrayObj->_Enabled and the new _Enabled. - * ... just do it. - */ - dest->NewState |= src->_Enabled | dest->_Enabled; -} - - -void GLAPIENTRY -_mesa_PushClientAttrib(GLbitfield mask) -{ - struct gl_attrib_node *head; - - GET_CURRENT_CONTEXT(ctx); - ASSERT_OUTSIDE_BEGIN_END(ctx); - - if (ctx->ClientAttribStackDepth >= MAX_CLIENT_ATTRIB_STACK_DEPTH) { - _mesa_error( ctx, GL_STACK_OVERFLOW, "glPushClientAttrib" ); - return; - } - - /* Build linked list of attribute nodes which save all attribute - * groups specified by the mask. - */ - head = NULL; - - if (mask & GL_CLIENT_PIXEL_STORE_BIT) { - struct gl_pixelstore_attrib *attr; - /* packing attribs */ - attr = CALLOC_STRUCT( gl_pixelstore_attrib ); - copy_pixelstore(ctx, attr, &ctx->Pack); - save_attrib_data(&head, GL_CLIENT_PACK_BIT, attr); - /* unpacking attribs */ - attr = CALLOC_STRUCT( gl_pixelstore_attrib ); - copy_pixelstore(ctx, attr, &ctx->Unpack); - save_attrib_data(&head, GL_CLIENT_UNPACK_BIT, attr); - } - - if (mask & GL_CLIENT_VERTEX_ARRAY_BIT) { - struct gl_array_attrib *attr; - attr = CALLOC_STRUCT( gl_array_attrib ); - _mesa_init_varray(ctx, attr); - save_array_attrib(ctx, attr, &ctx->Array); - save_attrib_data(&head, GL_CLIENT_VERTEX_ARRAY_BIT, attr); - } - - ctx->ClientAttribStack[ctx->ClientAttribStackDepth] = head; - ctx->ClientAttribStackDepth++; -} - - - - -void GLAPIENTRY -_mesa_PopClientAttrib(void) -{ - struct gl_attrib_node *node, *next; - - GET_CURRENT_CONTEXT(ctx); - ASSERT_OUTSIDE_BEGIN_END_AND_FLUSH(ctx); - - if (ctx->ClientAttribStackDepth == 0) { - _mesa_error( ctx, GL_STACK_UNDERFLOW, "glPopClientAttrib" ); - return; - } - - ctx->ClientAttribStackDepth--; - node = ctx->ClientAttribStack[ctx->ClientAttribStackDepth]; - - while (node) { - switch (node->kind) { - case GL_CLIENT_PACK_BIT: - { - struct gl_pixelstore_attrib *store = - (struct gl_pixelstore_attrib *) node->data; - copy_pixelstore(ctx, &ctx->Pack, store); - } - ctx->NewState |= _NEW_PACKUNPACK; - break; - case GL_CLIENT_UNPACK_BIT: - { - struct gl_pixelstore_attrib *store = - (struct gl_pixelstore_attrib *) node->data; - copy_pixelstore(ctx, &ctx->Unpack, store); - } - ctx->NewState |= _NEW_PACKUNPACK; - break; - case GL_CLIENT_VERTEX_ARRAY_BIT: { - struct gl_array_attrib * attr = - (struct gl_array_attrib *) node->data; - restore_array_attrib(ctx, &ctx->Array, attr); - _mesa_free_varray_data(ctx, attr); - ctx->NewState |= _NEW_ARRAY; - break; - } - default: - _mesa_problem( ctx, "Bad attrib flag in PopClientAttrib"); - break; - } - - next = node->next; - FREE( node->data ); - FREE( node ); - node = next; - } -} - - -void -_mesa_init_attrib_dispatch(struct _glapi_table *disp) -{ - SET_PopAttrib(disp, _mesa_PopAttrib); - SET_PushAttrib(disp, _mesa_PushAttrib); - SET_PopClientAttrib(disp, _mesa_PopClientAttrib); - SET_PushClientAttrib(disp, _mesa_PushClientAttrib); -} - - -#endif /* FEATURE_attrib_stack */ - - -/** - * Free any attribute state data that might be attached to the context. - */ -void -_mesa_free_attrib_data(struct gl_context *ctx) -{ - while (ctx->AttribStackDepth > 0) { - struct gl_attrib_node *attr, *next; - - ctx->AttribStackDepth--; - attr = ctx->AttribStack[ctx->AttribStackDepth]; - - while (attr) { - if (attr->kind == GL_TEXTURE_BIT) { - struct texture_state *texstate = (struct texture_state*)attr->data; - GLuint tgt; - /* clear references to the saved texture objects */ - for (tgt = 0; tgt < NUM_TEXTURE_TARGETS; tgt++) { - _mesa_reference_texobj(&texstate->SavedTexRef[tgt], NULL); - } - _mesa_reference_shared_state(ctx, &texstate->SharedRef, NULL); - } - else { - /* any other chunks of state that requires special handling? */ - } - - next = attr->next; - free(attr->data); - free(attr); - attr = next; - } - } -} - - -void _mesa_init_attrib( struct gl_context *ctx ) -{ - /* Renderer and client attribute stacks */ - ctx->AttribStackDepth = 0; - ctx->ClientAttribStackDepth = 0; -} diff --git a/dll/opengl/mesa/main/attrib.h b/dll/opengl/mesa/main/attrib.h deleted file mode 100644 index 6809311cfdb..00000000000 --- a/dll/opengl/mesa/main/attrib.h +++ /dev/null @@ -1,80 +0,0 @@ -/* - * Mesa 3-D graphics library - * Version: 7.1 - * - * Copyright (C) 1999-2007 Brian Paul All Rights Reserved. - * - * Permission is hereby granted, free of charge, to any person obtaining a - * copy of this software and associated documentation files (the "Software"), - * to deal in the Software without restriction, including without limitation - * the rights to use, copy, modify, merge, publish, distribute, sublicense, - * and/or sell copies of the Software, and to permit persons to whom the - * Software is furnished to do so, subject to the following conditions: - * - * The above copyright notice and this permission notice shall be included - * in all copies or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS - * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL - * BRIAN PAUL BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN - * AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN - * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. - */ - -#ifndef ATTRIB_H -#define ATTRIB_H - - -#include "compiler.h" -#include "glheader.h" -#include "mfeatures.h" - -struct _glapi_table; -struct gl_context; - -#if FEATURE_attrib_stack - -extern void GLAPIENTRY -_mesa_PushAttrib( GLbitfield mask ); - -extern void GLAPIENTRY -_mesa_PopAttrib( void ); - -extern void GLAPIENTRY -_mesa_PushClientAttrib( GLbitfield mask ); - -extern void GLAPIENTRY -_mesa_PopClientAttrib( void ); - -extern void -_mesa_init_attrib_dispatch(struct _glapi_table *disp); - -#else /* FEATURE_attrib_stack */ - -static inline void -_mesa_PushClientAttrib( GLbitfield mask ) -{ - ASSERT_NO_FEATURE(); -} - -static inline void -_mesa_PopClientAttrib( void ) -{ - ASSERT_NO_FEATURE(); -} - -static inline void -_mesa_init_attrib_dispatch(struct _glapi_table *disp) -{ -} - -#endif /* FEATURE_attrib_stack */ - -extern void -_mesa_init_attrib( struct gl_context *ctx ); - -extern void -_mesa_free_attrib_data( struct gl_context *ctx ); - -#endif /* ATTRIB_H */ diff --git a/dll/opengl/mesa/main/bitset.h b/dll/opengl/mesa/main/bitset.h deleted file mode 100644 index c27b4c474e0..00000000000 --- a/dll/opengl/mesa/main/bitset.h +++ /dev/null @@ -1,160 +0,0 @@ -/* - * Mesa 3-D graphics library - * Version: 6.5 - * - * Copyright (C) 2006 Brian Paul All Rights Reserved. - * - * Permission is hereby granted, free of charge, to any person obtaining a - * copy of this software and associated documentation files (the "Software"), - * to deal in the Software without restriction, including without limitation - * the rights to use, copy, modify, merge, publish, distribute, sublicense, - * and/or sell copies of the Software, and to permit persons to whom the - * Software is furnished to do so, subject to the following conditions: - * - * The above copyright notice and this permission notice shall be included - * in all copies or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS - * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL - * BRIAN PAUL BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN - * AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN - * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. - */ - -/** - * \file bitset.h - * \brief Bitset of arbitrary size definitions. - * \author Michal Krol - */ - -#ifndef BITSET_H -#define BITSET_H - -#include "imports.h" - -/**************************************************************************** - * generic bitset implementation - */ - -#define BITSET_WORD GLuint -#define BITSET_WORDBITS (sizeof (BITSET_WORD) * 8) - -/* bitset declarations - */ -#define BITSET_DECLARE(name, size) \ - BITSET_WORD name[((size) + BITSET_WORDBITS - 1) / BITSET_WORDBITS] - -/* bitset operations - */ -#define BITSET_COPY(x, y) memcpy( (x), (y), sizeof (x) ) -#define BITSET_EQUAL(x, y) (memcmp( (x), (y), sizeof (x) ) == 0) -#define BITSET_ZERO(x) memset( (x), 0, sizeof (x) ) -#define BITSET_ONES(x) memset( (x), 0xff, sizeof (x) ) - -#define BITSET_BITWORD(b) ((b) / BITSET_WORDBITS) -#define BITSET_BIT(b) (1 << ((b) % BITSET_WORDBITS)) - -/* single bit operations - */ -#define BITSET_TEST(x, b) ((x)[BITSET_BITWORD(b)] & BITSET_BIT(b)) -#define BITSET_SET(x, b) ((x)[BITSET_BITWORD(b)] |= BITSET_BIT(b)) -#define BITSET_CLEAR(x, b) ((x)[BITSET_BITWORD(b)] &= ~BITSET_BIT(b)) - -#define BITSET_MASK(b) ((b) == BITSET_WORDBITS ? ~0 : BITSET_BIT(b) - 1) -#define BITSET_RANGE(b, e) (BITSET_MASK((e) + 1) & ~BITSET_MASK(b)) - -/* bit range operations - */ -#define BITSET_TEST_RANGE(x, b, e) \ - (BITSET_BITWORD(b) == BITSET_BITWORD(e) ? \ - ((x)[BITSET_BITWORD(b)] & BITSET_RANGE(b, e)) : \ - (assert (!"BITSET_TEST_RANGE: bit range crosses word boundary"), 0)) -#define BITSET_SET_RANGE(x, b, e) \ - (BITSET_BITWORD(b) == BITSET_BITWORD(e) ? \ - ((x)[BITSET_BITWORD(b)] |= BITSET_RANGE(b, e)) : \ - (assert (!"BITSET_SET_RANGE: bit range crosses word boundary"), 0)) -#define BITSET_CLEAR_RANGE(x, b, e) \ - (BITSET_BITWORD(b) == BITSET_BITWORD(e) ? \ - ((x)[BITSET_BITWORD(b)] &= ~BITSET_RANGE(b, e)) : \ - (assert (!"BITSET_CLEAR_RANGE: bit range crosses word boundary"), 0)) - -/* Get first bit set in a bitset. - */ -static inline int -__bitset_ffs(const BITSET_WORD *x, int n) -{ - int i; - - for (i = 0; i < n; i++) { - if (x[i]) - return _mesa_ffs(x[i]) + BITSET_WORDBITS * i; - } - - return 0; -} - -#define BITSET_FFS(x) __bitset_ffs(x, Elements(x)) - -/**************************************************************************** - * 64-bit bitset implementation - */ - -#define BITSET64_WORD GLuint -#define BITSET64_WORDBITS (sizeof (BITSET64_WORD) * 8) - -/* bitset declarations - */ -#define BITSET64_DECLARE(name, size) \ - GLuint name[2] - -/* bitset operations - */ -#define BITSET64_COPY(x, y) do { (x)[0] = (y)[0]; (x)[1] = (y)[1]; } while (0) -#define BITSET64_EQUAL(x, y) ( (x)[0] == (y)[0] && (x)[1] == (y)[1] ) -#define BITSET64_ZERO(x) do { (x)[0] = 0; (x)[1] = 0; } while (0) -#define BITSET64_ONES(x) do { (x)[0] = 0xFF; (x)[1] = 0xFF; } while (0) - -#define BITSET64_BITWORD(b) ((b) / BITSET64_WORDBITS) -#define BITSET64_BIT(b) (1 << ((b) % BITSET64_WORDBITS)) - -/* single bit operations - */ -#define BITSET64_TEST(x, b) ((x)[BITSET64_BITWORD(b)] & BITSET64_BIT(b)) -#define BITSET64_SET(x, b) ((x)[BITSET64_BITWORD(b)] |= BITSET64_BIT(b)) -#define BITSET64_CLEAR(x, b) ((x)[BITSET64_BITWORD(b)] &= ~BITSET64_BIT(b)) - -#define BITSET64_MASK(b) ((b) == BITSET64_WORDBITS ? ~0 : BITSET64_BIT(b) - 1) -#define BITSET64_RANGE(b, e) (BITSET64_MASK((e) + 1) & ~BITSET64_MASK(b)) - -/* bit range operations - */ -#define BITSET64_TEST_SUBRANGE(x, b, e) \ - (BITSET64_BITWORD(b) == BITSET64_BITWORD(e) ? \ - ((x)[BITSET64_BITWORD(b)] & BITSET64_RANGE(b, e)) : \ - (assert (!"BITSET64_TEST_RANGE: bit range crosses word boundary"), 0)) -#define BITSET64_TEST_RANGE(x, b, e) \ - (BITSET64_BITWORD(b) == BITSET64_BITWORD(e) ? \ - (BITSET64_TEST_SUBRANGE(x, b, e)) : \ - (BITSET64_TEST_SUBRANGE(x, b, BITSET64_WORDBITS - 1) | \ - BITSET64_TEST_SUBRANGE(x, BITSET64_WORDBITS, e))) -#define BITSET64_SET_SUBRANGE(x, b, e) \ - (BITSET64_BITWORD(b) == BITSET64_BITWORD(e) ? \ - ((x)[BITSET64_BITWORD(b)] |= BITSET64_RANGE(b, e)) : \ - (assert (!"BITSET64_SET_RANGE: bit range crosses word boundary"), 0)) -#define BITSET64_SET_RANGE(x, b, e) \ - (BITSET64_BITWORD(b) == BITSET64_BITWORD(e) ? \ - (BITSET64_SET_SUBRANGE(x, b, e)) : \ - (BITSET64_SET_SUBRANGE(x, b, BITSET64_WORDBITS - 1) | \ - BITSET64_SET_SUBRANGE(x, BITSET64_WORDBITS, e))) -#define BITSET64_CLEAR_SUBRANGE(x, b, e) \ - (BITSET64_BITWORD(b) == BITSET64_BITWORD(e) ? \ - ((x)[BITSET64_BITWORD(b)] &= ~BITSET64_RANGE(b, e)) : \ - (assert (!"BITSET64_CLEAR_RANGE: bit range crosses word boundary"), 0)) -#define BITSET64_CLEAR_RANGE(x, b, e) \ - (BITSET64_BITWORD(b) == BITSET64_BITWORD(e) ? \ - (BITSET64_CLEAR_SUBRANGE(x, b, e)) : \ - (BITSET64_CLEAR_SUBRANGE(x, b, BITSET64_WORDBITS - 1) | \ - BITSET64_CLEAR_SUBRANGE(x, BITSET64_WORDBITS, e))) - -#endif diff --git a/dll/opengl/mesa/main/blend.c b/dll/opengl/mesa/main/blend.c deleted file mode 100644 index 4094518d8f8..00000000000 --- a/dll/opengl/mesa/main/blend.c +++ /dev/null @@ -1,352 +0,0 @@ -/** - * \file blend.c - * Blending operations. - */ - -/* - * Mesa 3-D graphics library - * Version: 6.5.1 - * - * Copyright (C) 1999-2006 Brian Paul All Rights Reserved. - * - * Permission is hereby granted, free of charge, to any person obtaining a - * copy of this software and associated documentation files (the "Software"), - * to deal in the Software without restriction, including without limitation - * the rights to use, copy, modify, merge, publish, distribute, sublicense, - * and/or sell copies of the Software, and to permit persons to whom the - * Software is furnished to do so, subject to the following conditions: - * - * The above copyright notice and this permission notice shall be included - * in all copies or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS - * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL - * BRIAN PAUL BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN - * AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN - * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. - */ - -#include - -/** - * Check if given blend source factor is legal. - * \return GL_TRUE if legal, GL_FALSE otherwise. - */ -static GLboolean -legal_src_factor(const struct gl_context *ctx, GLenum factor) -{ - switch (factor) { - case GL_SRC_COLOR: - case GL_ONE_MINUS_SRC_COLOR: - return ctx->Extensions.NV_blend_square; - case GL_ZERO: - case GL_ONE: - case GL_DST_COLOR: - case GL_ONE_MINUS_DST_COLOR: - case GL_SRC_ALPHA: - case GL_ONE_MINUS_SRC_ALPHA: - case GL_DST_ALPHA: - case GL_ONE_MINUS_DST_ALPHA: - case GL_SRC_ALPHA_SATURATE: - case GL_CONSTANT_COLOR: - case GL_ONE_MINUS_CONSTANT_COLOR: - case GL_CONSTANT_ALPHA: - case GL_ONE_MINUS_CONSTANT_ALPHA: - return GL_TRUE; - default: - return GL_FALSE; - } -} - - -/** - * Check if given blend destination factor is legal. - * \return GL_TRUE if legal, GL_FALSE otherwise. - */ -static GLboolean -legal_dst_factor(const struct gl_context *ctx, GLenum factor) -{ - switch (factor) { - case GL_DST_COLOR: - case GL_ONE_MINUS_DST_COLOR: - return ctx->Extensions.NV_blend_square; - case GL_ZERO: - case GL_ONE: - case GL_SRC_COLOR: - case GL_ONE_MINUS_SRC_COLOR: - case GL_SRC_ALPHA: - case GL_ONE_MINUS_SRC_ALPHA: - case GL_DST_ALPHA: - case GL_ONE_MINUS_DST_ALPHA: - case GL_CONSTANT_COLOR: - case GL_ONE_MINUS_CONSTANT_COLOR: - case GL_CONSTANT_ALPHA: - case GL_ONE_MINUS_CONSTANT_ALPHA: - return GL_TRUE; - default: - return GL_FALSE; - } -} - - -/** - * Check if src/dest RGB/A blend factors are legal. If not generate - * a GL error. - * \return GL_TRUE if factors are legal, GL_FALSE otherwise. - */ -static GLboolean -validate_blend_factors(struct gl_context *ctx, const char *func, - GLenum srcfactor, GLenum dstfactor) -{ - if (!legal_src_factor(ctx, srcfactor)) { - _mesa_error(ctx, GL_INVALID_ENUM, - "%s(sfactorRGB = %s)", func, - _mesa_lookup_enum_by_nr(srcfactor)); - return GL_FALSE; - } - - if (!legal_dst_factor(ctx, dstfactor)) { - _mesa_error(ctx, GL_INVALID_ENUM, - "%s(dfactorRGB = %s)", func, - _mesa_lookup_enum_by_nr(dstfactor)); - return GL_FALSE; - } - - return GL_TRUE; -} - - -/** - * Specify the blending operation. - * - * \param sfactor source factor operator. - * \param dfactor destination factor operator. - * - * \sa glBlendFunc - */ -void GLAPIENTRY -_mesa_BlendFunc( GLenum sfactor, GLenum dfactor ) -{ - GET_CURRENT_CONTEXT(ctx); - ASSERT_OUTSIDE_BEGIN_END(ctx); - - if (MESA_VERBOSE & VERBOSE_API) - _mesa_debug(ctx, "glBlendFunc %s %s\n", - _mesa_lookup_enum_by_nr(sfactor), - _mesa_lookup_enum_by_nr(dfactor)); - - if (!validate_blend_factors(ctx, "glBlendFunc", sfactor, dfactor)) { - return; - } - - if (ctx->Color.SrcFactor == sfactor && - ctx->Color.DstFactor == dfactor) { - return; - } - - FLUSH_VERTICES(ctx, _NEW_COLOR); - - ctx->Color.SrcFactor = sfactor; - ctx->Color.DstFactor = dfactor; -} - - -/** - * Specify the alpha test function. - * - * \param func alpha comparison function. - * \param ref reference value. - * - * Verifies the parameters and updates gl_colorbuffer_attrib. - * On a change, flushes the vertices and notifies the driver via - * dd_function_table::AlphaFunc callback. - */ -void GLAPIENTRY -_mesa_AlphaFunc( GLenum func, GLclampf ref ) -{ - GET_CURRENT_CONTEXT(ctx); - ASSERT_OUTSIDE_BEGIN_END(ctx); - - if (MESA_VERBOSE & VERBOSE_API) - _mesa_debug(ctx, "glAlphaFunc(%s, %f)\n", - _mesa_lookup_enum_by_nr(func), ref); - - switch (func) { - case GL_NEVER: - case GL_LESS: - case GL_EQUAL: - case GL_LEQUAL: - case GL_GREATER: - case GL_NOTEQUAL: - case GL_GEQUAL: - case GL_ALWAYS: - if (ctx->Color.AlphaFunc == func && ctx->Color.AlphaRef == ref) - return; /* no change */ - - FLUSH_VERTICES(ctx, _NEW_COLOR); - ctx->Color.AlphaFunc = func; - ctx->Color.AlphaRef = ref; - - if (ctx->Driver.AlphaFunc) - ctx->Driver.AlphaFunc(ctx, func, ctx->Color.AlphaRef); - return; - - default: - _mesa_error( ctx, GL_INVALID_ENUM, "glAlphaFunc(func)" ); - return; - } -} - - -/** - * Specify a logic pixel operation for color index rendering. - * - * \param opcode operation. - * - * Verifies that \p opcode is a valid enum and updates -gl_colorbuffer_attrib::LogicOp. - * On a change, flushes the vertices and notifies the driver via the - * dd_function_table::LogicOpcode callback. - */ -void GLAPIENTRY -_mesa_LogicOp( GLenum opcode ) -{ - GET_CURRENT_CONTEXT(ctx); - ASSERT_OUTSIDE_BEGIN_END(ctx); - - if (MESA_VERBOSE & VERBOSE_API) - _mesa_debug(ctx, "glLogicOp(%s)\n", _mesa_lookup_enum_by_nr(opcode)); - - switch (opcode) { - case GL_CLEAR: - case GL_SET: - case GL_COPY: - case GL_COPY_INVERTED: - case GL_NOOP: - case GL_INVERT: - case GL_AND: - case GL_NAND: - case GL_OR: - case GL_NOR: - case GL_XOR: - case GL_EQUIV: - case GL_AND_REVERSE: - case GL_AND_INVERTED: - case GL_OR_REVERSE: - case GL_OR_INVERTED: - break; - default: - _mesa_error( ctx, GL_INVALID_ENUM, "glLogicOp" ); - return; - } - - if (ctx->Color.LogicOp == opcode) - return; - - FLUSH_VERTICES(ctx, _NEW_COLOR); - ctx->Color.LogicOp = opcode; - - if (ctx->Driver.LogicOpcode) - ctx->Driver.LogicOpcode( ctx, opcode ); -} - -#if _HAVE_FULL_GL -void GLAPIENTRY -_mesa_IndexMask( GLuint mask ) -{ - GET_CURRENT_CONTEXT(ctx); - ASSERT_OUTSIDE_BEGIN_END(ctx); - - if (ctx->Color.IndexMask == mask) - return; - - FLUSH_VERTICES(ctx, _NEW_COLOR); - ctx->Color.IndexMask = mask; -} -#endif - - -/** - * Enable or disable writing of frame buffer color components. - * - * \param red whether to mask writing of the red color component. - * \param green whether to mask writing of the green color component. - * \param blue whether to mask writing of the blue color component. - * \param alpha whether to mask writing of the alpha color component. - * - * \sa glColorMask(). - * - * Sets the appropriate value of gl_colorbuffer_attrib::ColorMask. On a - * change, flushes the vertices and notifies the driver via the - * dd_function_table::ColorMask callback. - */ -void GLAPIENTRY -_mesa_ColorMask( GLboolean red, GLboolean green, - GLboolean blue, GLboolean alpha ) -{ - GET_CURRENT_CONTEXT(ctx); - GLubyte tmp[4]; - ASSERT_OUTSIDE_BEGIN_END(ctx); - - if (MESA_VERBOSE & VERBOSE_API) - _mesa_debug(ctx, "glColorMask(%d, %d, %d, %d)\n", - red, green, blue, alpha); - - /* Shouldn't have any information about channel depth in core mesa - * -- should probably store these as the native booleans: - */ - tmp[RCOMP] = red ? 0xff : 0x0; - tmp[GCOMP] = green ? 0xff : 0x0; - tmp[BCOMP] = blue ? 0xff : 0x0; - tmp[ACOMP] = alpha ? 0xff : 0x0; - - if (!TEST_EQ_4V(tmp, ctx->Color.ColorMask)) { - FLUSH_VERTICES(ctx, _NEW_COLOR); - COPY_4UBV(ctx->Color.ColorMask, tmp); - } - - if (ctx->Driver.ColorMask) - ctx->Driver.ColorMask( ctx, red, green, blue, alpha ); -} - - -/**********************************************************************/ -/** \name Initialization */ -/*@{*/ - -/** - * Initialization of the context's Color attribute group. - * - * \param ctx GL context. - * - * Initializes the related fields in the context color attribute group, - * __struct gl_contextRec::Color. - */ -void _mesa_init_color( struct gl_context * ctx ) -{ - /* Color buffer group */ - ctx->Color.IndexMask = ~0u; - memset(ctx->Color.ColorMask, 0xff, sizeof(ctx->Color.ColorMask)); - ctx->Color.ClearIndex = 0; - ASSIGN_4V( ctx->Color.ClearColor.f, 0, 0, 0, 0 ); - ctx->Color.AlphaEnabled = GL_FALSE; - ctx->Color.AlphaFunc = GL_ALWAYS; - ctx->Color.AlphaRef = 0; - ctx->Color.BlendEnabled = 0x0; - ctx->Color.SrcFactor = GL_ONE; - ctx->Color.DstFactor = GL_ZERO; - ctx->Color.IndexLogicOpEnabled = GL_FALSE; - ctx->Color.ColorLogicOpEnabled = GL_FALSE; - ctx->Color.LogicOp = GL_COPY; - ctx->Color.DitherFlag = GL_TRUE; - - if (ctx->Visual.doubleBufferMode) { - ctx->Color.DrawBuffer = GL_BACK; - } - else { - ctx->Color.DrawBuffer = GL_FRONT; - } -} - -/*@}*/ diff --git a/dll/opengl/mesa/main/blend.h b/dll/opengl/mesa/main/blend.h deleted file mode 100644 index 66452957165..00000000000 --- a/dll/opengl/mesa/main/blend.h +++ /dev/null @@ -1,64 +0,0 @@ -/** - * \file blend.h - * Blending functions operations. - */ - -/* - * Mesa 3-D graphics library - * Version: 6.5.2 - * - * Copyright (C) 1999-2006 Brian Paul All Rights Reserved. - * - * Permission is hereby granted, free of charge, to any person obtaining a - * copy of this software and associated documentation files (the "Software"), - * to deal in the Software without restriction, including without limitation - * the rights to use, copy, modify, merge, publish, distribute, sublicense, - * and/or sell copies of the Software, and to permit persons to whom the - * Software is furnished to do so, subject to the following conditions: - * - * The above copyright notice and this permission notice shall be included - * in all copies or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS - * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL - * BRIAN PAUL BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN - * AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN - * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. - */ - - - -#ifndef BLEND_H -#define BLEND_H - - -#include "glheader.h" - -struct gl_context; - - -extern void GLAPIENTRY -_mesa_BlendFunc( GLenum sfactor, GLenum dfactor ); - - -extern void GLAPIENTRY -_mesa_AlphaFunc( GLenum func, GLclampf ref ); - - -extern void GLAPIENTRY -_mesa_LogicOp( GLenum opcode ); - - -extern void GLAPIENTRY -_mesa_IndexMask( GLuint mask ); - -extern void GLAPIENTRY -_mesa_ColorMask( GLboolean red, GLboolean green, - GLboolean blue, GLboolean alpha ); - - -extern void -_mesa_init_color( struct gl_context * ctx ); - -#endif diff --git a/dll/opengl/mesa/main/bufferobj.c b/dll/opengl/mesa/main/bufferobj.c deleted file mode 100644 index 883aee9af8a..00000000000 --- a/dll/opengl/mesa/main/bufferobj.c +++ /dev/null @@ -1,1312 +0,0 @@ -/* - * Mesa 3-D graphics library - * Version: 7.6 - * - * Copyright (C) 1999-2008 Brian Paul All Rights Reserved. - * Copyright (C) 2009 VMware, Inc. All Rights Reserved. - * - * Permission is hereby granted, free of charge, to any person obtaining a - * copy of this software and associated documentation files (the "Software"), - * to deal in the Software without restriction, including without limitation - * the rights to use, copy, modify, merge, publish, distribute, sublicense, - * and/or sell copies of the Software, and to permit persons to whom the - * Software is furnished to do so, subject to the following conditions: - * - * The above copyright notice and this permission notice shall be included - * in all copies or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS - * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL - * BRIAN PAUL BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN - * AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN - * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. - */ - - -/** - * \file bufferobj.c - * \brief Functions for the GL_ARB_vertex/pixel_buffer_object extensions. - * \author Brian Paul, Ian Romanick - */ - -#include - -/* Debug flags */ -/*#define VBO_DEBUG*/ -/*#define BOUNDS_CHECK*/ - - -/** - * Used as a placeholder for buffer objects between glGenBuffers() and - * glBindBuffer() so that glIsBuffer() can work correctly. - */ -static struct gl_buffer_object DummyBufferObject; - - -/** - * Return pointer to address of a buffer object target. - * \param ctx the GL context - * \param target the buffer object target to be retrieved. - * \return pointer to pointer to the buffer object bound to \c target in the - * specified context or \c NULL if \c target is invalid. - */ -static inline struct gl_buffer_object ** -get_buffer_target(struct gl_context *ctx, GLenum target) -{ - switch (target) { - case GL_ELEMENT_ARRAY_BUFFER_ARB: - return &ctx->Array.ElementArrayBufferObj; - default: - return NULL; - } - return NULL; -} - - -/** - * Get the buffer object bound to the specified target in a GL context. - * \param ctx the GL context - * \param target the buffer object target to be retrieved. - * \return pointer to the buffer object bound to \c target in the - * specified context or \c NULL if \c target is invalid. - */ -static inline struct gl_buffer_object * -get_buffer(struct gl_context *ctx, const char *func, GLenum target) -{ - struct gl_buffer_object **bufObj = get_buffer_target(ctx, target); - - if (!bufObj) { - _mesa_error(ctx, GL_INVALID_ENUM, "%s(target)", func); - return NULL; - } - - if (!_mesa_is_bufferobj(*bufObj)) { - _mesa_error(ctx, GL_INVALID_OPERATION, "%s(buffer 0)", func); - return NULL; - } - - return *bufObj; -} - - -static inline GLenum -default_access_mode(const struct gl_context *ctx) -{ - (void)ctx; - return GL_MAP_READ_BIT | GL_MAP_WRITE_BIT; -} - - -/** - * Convert a GLbitfield describing the mapped buffer access flags - * into one of GL_READ_WRITE, GL_READ_ONLY, or GL_WRITE_ONLY. - */ -static GLenum -simplified_access_mode(GLbitfield access) -{ - const GLbitfield rwFlags = GL_MAP_READ_BIT | GL_MAP_WRITE_BIT; - if ((access & rwFlags) == rwFlags) - return GL_READ_WRITE; - if ((access & GL_MAP_READ_BIT) == GL_MAP_READ_BIT) - return GL_READ_ONLY; - if ((access & GL_MAP_WRITE_BIT) == GL_MAP_WRITE_BIT) - return GL_WRITE_ONLY; - return GL_READ_WRITE; /* this should never happen, but no big deal */ -} - - -/** - * Tests the subdata range parameters and sets the GL error code for - * \c glBufferSubDataARB and \c glGetBufferSubDataARB. - * - * \param ctx GL context. - * \param target Buffer object target on which to operate. - * \param offset Offset of the first byte of the subdata range. - * \param size Size, in bytes, of the subdata range. - * \param caller Name of calling function for recording errors. - * \return A pointer to the buffer object bound to \c target in the - * specified context or \c NULL if any of the parameter or state - * conditions for \c glBufferSubDataARB or \c glGetBufferSubDataARB - * are invalid. - * - * \sa glBufferSubDataARB, glGetBufferSubDataARB - */ -static struct gl_buffer_object * -buffer_object_subdata_range_good( struct gl_context * ctx, GLenum target, - GLintptrARB offset, GLsizeiptrARB size, - const char *caller ) -{ - struct gl_buffer_object *bufObj; - - if (size < 0) { - _mesa_error(ctx, GL_INVALID_VALUE, "%s(size < 0)", caller); - return NULL; - } - - if (offset < 0) { - _mesa_error(ctx, GL_INVALID_VALUE, "%s(offset < 0)", caller); - return NULL; - } - - bufObj = get_buffer(ctx, caller, target); - if (!bufObj) - return NULL; - - if (offset + size > bufObj->Size) { - _mesa_error(ctx, GL_INVALID_VALUE, - "%s(offset %lu + size %lu > buffer size %lu)", caller, - (unsigned long) offset, - (unsigned long) size, - (unsigned long) bufObj->Size); - return NULL; - } - if (_mesa_bufferobj_mapped(bufObj)) { - /* Buffer is currently mapped */ - _mesa_error(ctx, GL_INVALID_OPERATION, "%s", caller); - return NULL; - } - - return bufObj; -} - - -/** - * Allocate and initialize a new buffer object. - * - * Default callback for the \c dd_function_table::NewBufferObject() hook. - */ -static struct gl_buffer_object * -_mesa_new_buffer_object( struct gl_context *ctx, GLuint name, GLenum target ) -{ - struct gl_buffer_object *obj; - - (void) ctx; - - obj = MALLOC_STRUCT(gl_buffer_object); - _mesa_initialize_buffer_object(ctx, obj, name, target); - return obj; -} - - -/** - * Delete a buffer object. - * - * Default callback for the \c dd_function_table::DeleteBuffer() hook. - */ -static void -_mesa_delete_buffer_object(struct gl_context *ctx, - struct gl_buffer_object *bufObj) -{ - (void) ctx; - - if (bufObj->Data) - free(bufObj->Data); - - /* assign strange values here to help w/ debugging */ - bufObj->RefCount = -1000; - bufObj->Name = ~0; - - _glthread_DESTROY_MUTEX(bufObj->Mutex); - free(bufObj); -} - - - -/** - * Set ptr to bufObj w/ reference counting. - * This is normally only called from the _mesa_reference_buffer_object() macro - * when there's a real pointer change. - */ -void -_mesa_reference_buffer_object_(struct gl_context *ctx, - struct gl_buffer_object **ptr, - struct gl_buffer_object *bufObj) -{ - if (*ptr) { - /* Unreference the old buffer */ - GLboolean deleteFlag = GL_FALSE; - struct gl_buffer_object *oldObj = *ptr; - - _glthread_LOCK_MUTEX(oldObj->Mutex); - ASSERT(oldObj->RefCount > 0); - oldObj->RefCount--; -#if 0 - printf("BufferObj %p %d DECR to %d\n", - (void *) oldObj, oldObj->Name, oldObj->RefCount); -#endif - deleteFlag = (oldObj->RefCount == 0); - _glthread_UNLOCK_MUTEX(oldObj->Mutex); - - if (deleteFlag) { - - /* some sanity checking: don't delete a buffer still in use */ -#if 0 - /* unfortunately, these tests are invalid during context tear-down */ - ASSERT(ctx->Array.ArrayBufferObj != bufObj); - ASSERT(ctx->Array.ArrayObj->ElementArrayBufferObj != bufObj); - ASSERT(ctx->Array.ArrayObj->Vertex.BufferObj != bufObj); -#endif - - ASSERT(ctx->Driver.DeleteBuffer); - ctx->Driver.DeleteBuffer(ctx, oldObj); - } - - *ptr = NULL; - } - ASSERT(!*ptr); - - if (bufObj) { - /* reference new buffer */ - _glthread_LOCK_MUTEX(bufObj->Mutex); - if (bufObj->RefCount == 0) { - /* this buffer's being deleted (look just above) */ - /* Not sure this can every really happen. Warn if it does. */ - _mesa_problem(NULL, "referencing deleted buffer object"); - *ptr = NULL; - } - else { - bufObj->RefCount++; -#if 0 - printf("BufferObj %p %d INCR to %d\n", - (void *) bufObj, bufObj->Name, bufObj->RefCount); -#endif - *ptr = bufObj; - } - _glthread_UNLOCK_MUTEX(bufObj->Mutex); - } -} - - -/** - * Initialize a buffer object to default values. - */ -void -_mesa_initialize_buffer_object( struct gl_context *ctx, - struct gl_buffer_object *obj, - GLuint name, GLenum target ) -{ - (void) target; - - memset(obj, 0, sizeof(struct gl_buffer_object)); - _glthread_INIT_MUTEX(obj->Mutex); - obj->RefCount = 1; - obj->Name = name; - obj->Usage = GL_STATIC_DRAW_ARB; - obj->AccessFlags = default_access_mode(ctx); -} - - -/** - * Allocate space for and store data in a buffer object. Any data that was - * previously stored in the buffer object is lost. If \c data is \c NULL, - * memory will be allocated, but no copy will occur. - * - * This is the default callback for \c dd_function_table::BufferData() - * Note that all GL error checking will have been done already. - * - * \param ctx GL context. - * \param target Buffer object target on which to operate. - * \param size Size, in bytes, of the new data store. - * \param data Pointer to the data to store in the buffer object. This - * pointer may be \c NULL. - * \param usage Hints about how the data will be used. - * \param bufObj Object to be used. - * - * \return GL_TRUE for success, GL_FALSE for failure - * \sa glBufferDataARB, dd_function_table::BufferData. - */ -static GLboolean -_mesa_buffer_data( struct gl_context *ctx, GLenum target, GLsizeiptrARB size, - const GLvoid * data, GLenum usage, - struct gl_buffer_object * bufObj ) -{ - void * new_data; - - (void) ctx; (void) target; - - new_data = _mesa_realloc( bufObj->Data, bufObj->Size, size ); - if (new_data) { - bufObj->Data = (GLubyte *) new_data; - bufObj->Size = size; - bufObj->Usage = usage; - - if (data) { - memcpy( bufObj->Data, data, size ); - } - - return GL_TRUE; - } - else { - return GL_FALSE; - } -} - - -/** - * Replace data in a subrange of buffer object. If the data range - * specified by \c size + \c offset extends beyond the end of the buffer or - * if \c data is \c NULL, no copy is performed. - * - * This is the default callback for \c dd_function_table::BufferSubData() - * Note that all GL error checking will have been done already. - * - * \param ctx GL context. - * \param target Buffer object target on which to operate. - * \param offset Offset of the first byte to be modified. - * \param size Size, in bytes, of the data range. - * \param data Pointer to the data to store in the buffer object. - * \param bufObj Object to be used. - * - * \sa glBufferSubDataARB, dd_function_table::BufferSubData. - */ -static void -_mesa_buffer_subdata( struct gl_context *ctx, GLintptrARB offset, - GLsizeiptrARB size, const GLvoid * data, - struct gl_buffer_object * bufObj ) -{ - (void) ctx; - - /* this should have been caught in _mesa_BufferSubData() */ - ASSERT(size + offset <= bufObj->Size); - - if (bufObj->Data) { - memcpy( (GLubyte *) bufObj->Data + offset, data, size ); - } -} - - -/** - * Retrieve data from a subrange of buffer object. If the data range - * specified by \c size + \c offset extends beyond the end of the buffer or - * if \c data is \c NULL, no copy is performed. - * - * This is the default callback for \c dd_function_table::GetBufferSubData() - * Note that all GL error checking will have been done already. - * - * \param ctx GL context. - * \param target Buffer object target on which to operate. - * \param offset Offset of the first byte to be fetched. - * \param size Size, in bytes, of the data range. - * \param data Destination for data - * \param bufObj Object to be used. - * - * \sa glBufferGetSubDataARB, dd_function_table::GetBufferSubData. - */ -static void -_mesa_buffer_get_subdata( struct gl_context *ctx, GLintptrARB offset, - GLsizeiptrARB size, GLvoid * data, - struct gl_buffer_object * bufObj ) -{ - (void) ctx; - - if (bufObj->Data && ((GLsizeiptrARB) (size + offset) <= bufObj->Size)) { - memcpy( data, (GLubyte *) bufObj->Data + offset, size ); - } -} - - -/** - * Default fallback for \c dd_function_table::MapBufferRange(). - * Called via glMapBufferRange(). - */ -static void * -_mesa_buffer_map_range( struct gl_context *ctx, GLintptr offset, - GLsizeiptr length, GLbitfield access, - struct gl_buffer_object *bufObj ) -{ - (void) ctx; - assert(!_mesa_bufferobj_mapped(bufObj)); - /* Just return a direct pointer to the data */ - bufObj->Pointer = bufObj->Data + offset; - bufObj->Length = length; - bufObj->Offset = offset; - bufObj->AccessFlags = access; - return bufObj->Pointer; -} - - -/** - * Default fallback for \c dd_function_table::FlushMappedBufferRange(). - * Called via glFlushMappedBufferRange(). - */ -static void -_mesa_buffer_flush_mapped_range( struct gl_context *ctx, - GLintptr offset, GLsizeiptr length, - struct gl_buffer_object *obj ) -{ - (void) ctx; - (void) offset; - (void) length; - (void) obj; - /* no-op */ -} - - -/** - * Default callback for \c dd_function_table::MapBuffer(). - * - * The input parameters will have been already tested for errors. - * - * \sa glUnmapBufferARB, dd_function_table::UnmapBuffer - */ -static GLboolean -_mesa_buffer_unmap( struct gl_context *ctx, struct gl_buffer_object *bufObj ) -{ - (void) ctx; - /* XXX we might assert here that bufObj->Pointer is non-null */ - bufObj->Pointer = NULL; - bufObj->Length = 0; - bufObj->Offset = 0; - bufObj->AccessFlags = 0x0; - return GL_TRUE; -} - - -/** - * Initialize the state associated with buffer objects - */ -void -_mesa_init_buffer_objects( struct gl_context *ctx ) -{ - memset(&DummyBufferObject, 0, sizeof(DummyBufferObject)); - _glthread_INIT_MUTEX(DummyBufferObject.Mutex); - DummyBufferObject.RefCount = 1000*1000*1000; /* never delete */ -} - - -/** - * Bind the specified target to buffer for the specified context. - * Called by glBindBuffer() and other functions. - */ -static void -bind_buffer_object(struct gl_context *ctx, GLenum target, GLuint buffer) -{ - struct gl_buffer_object *oldBufObj; - struct gl_buffer_object *newBufObj = NULL; - struct gl_buffer_object **bindTarget = NULL; - - bindTarget = get_buffer_target(ctx, target); - if (!bindTarget) { - _mesa_error(ctx, GL_INVALID_ENUM, "glBindBufferARB(target 0x%x)", target); - return; - } - - /* Get pointer to old buffer object (to be unbound) */ - oldBufObj = *bindTarget; - if (oldBufObj && oldBufObj->Name == buffer && !oldBufObj->DeletePending) - return; /* rebinding the same buffer object- no change */ - - /* - * Get pointer to new buffer object (newBufObj) - */ - if (buffer == 0) { - /* The spec says there's not a buffer object named 0, but we use - * one internally because it simplifies things. - */ - newBufObj = ctx->Shared->NullBufferObj; - } - else { - /* non-default buffer object */ - newBufObj = _mesa_lookup_bufferobj(ctx, buffer); - if (!newBufObj || newBufObj == &DummyBufferObject) { - /* If this is a new buffer object id, or one which was generated but - * never used before, allocate a buffer object now. - */ - ASSERT(ctx->Driver.NewBufferObject); - newBufObj = ctx->Driver.NewBufferObject(ctx, buffer, target); - if (!newBufObj) { - _mesa_error(ctx, GL_OUT_OF_MEMORY, "glBindBufferARB"); - return; - } - _mesa_HashInsert(ctx->Shared->BufferObjects, buffer, newBufObj); - } - } - - /* bind new buffer */ - _mesa_reference_buffer_object(ctx, bindTarget, newBufObj); - - /* Pass BindBuffer call to device driver */ - if (ctx->Driver.BindBuffer) - ctx->Driver.BindBuffer( ctx, target, newBufObj ); -} - - -/** - * Update the default buffer objects in the given context to reference those - * specified in the shared state and release those referencing the old - * shared state. - */ -void -_mesa_update_default_objects_buffer_objects(struct gl_context *ctx) -{ - /* Bind the NullBufferObj to remove references to those - * in the shared context hash table. - */ - bind_buffer_object( ctx, GL_ARRAY_BUFFER_ARB, 0); - bind_buffer_object( ctx, GL_ELEMENT_ARRAY_BUFFER_ARB, 0); -} - - - -/** - * Return the gl_buffer_object for the given ID. - * Always return NULL for ID 0. - */ -struct gl_buffer_object * -_mesa_lookup_bufferobj(struct gl_context *ctx, GLuint buffer) -{ - if (buffer == 0) - return NULL; - else - return (struct gl_buffer_object *) - _mesa_HashLookup(ctx->Shared->BufferObjects, buffer); -} - - -/** - * If *ptr points to obj, set ptr = the Null/default buffer object. - * This is a helper for buffer object deletion. - * The GL spec says that deleting a buffer object causes it to get - * unbound from all arrays in the current context. - */ -static void -unbind(struct gl_context *ctx, - struct gl_buffer_object **ptr, - struct gl_buffer_object *obj) -{ - if (*ptr == obj) { - _mesa_reference_buffer_object(ctx, ptr, ctx->Shared->NullBufferObj); - } -} - - -/** - * Plug default/fallback buffer object functions into the device - * driver hooks. - */ -void -_mesa_init_buffer_object_functions(struct dd_function_table *driver) -{ - /* GL_ARB_vertex/pixel_buffer_object */ - driver->NewBufferObject = _mesa_new_buffer_object; - driver->DeleteBuffer = _mesa_delete_buffer_object; - driver->BindBuffer = NULL; - driver->BufferData = _mesa_buffer_data; - driver->BufferSubData = _mesa_buffer_subdata; - driver->GetBufferSubData = _mesa_buffer_get_subdata; - driver->UnmapBuffer = _mesa_buffer_unmap; - - /* GL_ARB_map_buffer_range */ - driver->MapBufferRange = _mesa_buffer_map_range; - driver->FlushMappedBufferRange = _mesa_buffer_flush_mapped_range; -} - - - -/**********************************************************************/ -/* API Functions */ -/**********************************************************************/ - -void GLAPIENTRY -_mesa_BindBufferARB(GLenum target, GLuint buffer) -{ - GET_CURRENT_CONTEXT(ctx); - ASSERT_OUTSIDE_BEGIN_END(ctx); - - if (MESA_VERBOSE & VERBOSE_API) - _mesa_debug(ctx, "glBindBuffer(%s, %u)\n", - _mesa_lookup_enum_by_nr(target), buffer); - - bind_buffer_object(ctx, target, buffer); -} - - -/** - * Delete a set of buffer objects. - * - * \param n Number of buffer objects to delete. - * \param ids Array of \c n buffer object IDs. - */ -void GLAPIENTRY -_mesa_DeleteBuffersARB(GLsizei n, const GLuint *ids) -{ - GET_CURRENT_CONTEXT(ctx); - GLsizei i; - ASSERT_OUTSIDE_BEGIN_END(ctx); - FLUSH_VERTICES(ctx, 0); - - if (n < 0) { - _mesa_error(ctx, GL_INVALID_VALUE, "glDeleteBuffersARB(n)"); - return; - } - - _glthread_LOCK_MUTEX(ctx->Shared->Mutex); - - for (i = 0; i < n; i++) { - struct gl_buffer_object *bufObj = _mesa_lookup_bufferobj(ctx, ids[i]); - if (bufObj) { - GLuint j; - - ASSERT(bufObj->Name == ids[i] || bufObj == &DummyBufferObject); - - if (_mesa_bufferobj_mapped(bufObj)) { - /* if mapped, unmap it now */ - ctx->Driver.UnmapBuffer(ctx, bufObj); - bufObj->AccessFlags = default_access_mode(ctx); - bufObj->Pointer = NULL; - } - - /* unbind any vertex pointers bound to this buffer */ - for (j = 0; j < Elements(ctx->Array.VertexAttrib); j++) { - unbind(ctx, &ctx->Array.VertexAttrib[j].BufferObj, bufObj); - } - - if (ctx->Array.ElementArrayBufferObj == bufObj) { - _mesa_BindBufferARB( GL_ELEMENT_ARRAY_BUFFER_ARB, 0 ); - } - - /* The ID is immediately freed for re-use */ - _mesa_HashRemove(ctx->Shared->BufferObjects, ids[i]); - /* Make sure we do not run into the classic ABA problem on bind. - * We don't want to allow re-binding a buffer object that's been - * "deleted" by glDeleteBuffers(). - * - * The explicit rebinding to the default object in the current context - * prevents the above in the current context, but another context - * sharing the same objects might suffer from this problem. - * The alternative would be to do the hash lookup in any case on bind - * which would introduce more runtime overhead than this. - */ - bufObj->DeletePending = GL_TRUE; - _mesa_reference_buffer_object(ctx, &bufObj, NULL); - } - } - - _glthread_UNLOCK_MUTEX(ctx->Shared->Mutex); -} - - -/** - * Generate a set of unique buffer object IDs and store them in \c buffer. - * - * \param n Number of IDs to generate. - * \param buffer Array of \c n locations to store the IDs. - */ -void GLAPIENTRY -_mesa_GenBuffersARB(GLsizei n, GLuint *buffer) -{ - GET_CURRENT_CONTEXT(ctx); - GLuint first; - GLint i; - ASSERT_OUTSIDE_BEGIN_END(ctx); - - if (MESA_VERBOSE & VERBOSE_API) - _mesa_debug(ctx, "glGenBuffers(%d)\n", n); - - if (n < 0) { - _mesa_error(ctx, GL_INVALID_VALUE, "glGenBuffersARB"); - return; - } - - if (!buffer) { - return; - } - - /* - * This must be atomic (generation and allocation of buffer object IDs) - */ - _glthread_LOCK_MUTEX(ctx->Shared->Mutex); - - first = _mesa_HashFindFreeKeyBlock(ctx->Shared->BufferObjects, n); - - /* Insert the ID and pointer to dummy buffer object into hash table */ - for (i = 0; i < n; i++) { - _mesa_HashInsert(ctx->Shared->BufferObjects, first + i, - &DummyBufferObject); - buffer[i] = first + i; - } - - _glthread_UNLOCK_MUTEX(ctx->Shared->Mutex); -} - - -/** - * Determine if ID is the name of a buffer object. - * - * \param id ID of the potential buffer object. - * \return \c GL_TRUE if \c id is the name of a buffer object, - * \c GL_FALSE otherwise. - */ -GLboolean GLAPIENTRY -_mesa_IsBufferARB(GLuint id) -{ - struct gl_buffer_object *bufObj; - GET_CURRENT_CONTEXT(ctx); - ASSERT_OUTSIDE_BEGIN_END_WITH_RETVAL(ctx, GL_FALSE); - - _glthread_LOCK_MUTEX(ctx->Shared->Mutex); - bufObj = _mesa_lookup_bufferobj(ctx, id); - _glthread_UNLOCK_MUTEX(ctx->Shared->Mutex); - - return bufObj && bufObj != &DummyBufferObject; -} - - -void GLAPIENTRY -_mesa_BufferDataARB(GLenum target, GLsizeiptrARB size, - const GLvoid * data, GLenum usage) -{ - GET_CURRENT_CONTEXT(ctx); - struct gl_buffer_object *bufObj; - ASSERT_OUTSIDE_BEGIN_END(ctx); - - if (MESA_VERBOSE & VERBOSE_API) - _mesa_debug(ctx, "glBufferData(%s, %ld, %p, %s)\n", - _mesa_lookup_enum_by_nr(target), - (long int) size, data, - _mesa_lookup_enum_by_nr(usage)); - - if (size < 0) { - _mesa_error(ctx, GL_INVALID_VALUE, "glBufferDataARB(size < 0)"); - return; - } - - switch (usage) { - case GL_STREAM_DRAW_ARB: - case GL_STREAM_READ_ARB: - case GL_STREAM_COPY_ARB: - case GL_STATIC_DRAW_ARB: - case GL_STATIC_READ_ARB: - case GL_STATIC_COPY_ARB: - case GL_DYNAMIC_DRAW_ARB: - case GL_DYNAMIC_READ_ARB: - case GL_DYNAMIC_COPY_ARB: - /* OK */ - break; - default: - _mesa_error(ctx, GL_INVALID_ENUM, "glBufferDataARB(usage)"); - return; - } - - bufObj = get_buffer(ctx, "glBufferDataARB", target); - if (!bufObj) - return; - - if (_mesa_bufferobj_mapped(bufObj)) { - /* Unmap the existing buffer. We'll replace it now. Not an error. */ - ctx->Driver.UnmapBuffer(ctx, bufObj); - bufObj->AccessFlags = default_access_mode(ctx); - ASSERT(bufObj->Pointer == NULL); - } - - FLUSH_VERTICES(ctx, _NEW_BUFFER_OBJECT); - - bufObj->Written = GL_TRUE; - -#ifdef VBO_DEBUG - printf("glBufferDataARB(%u, sz %ld, from %p, usage 0x%x)\n", - bufObj->Name, size, data, usage); -#endif - -#ifdef BOUNDS_CHECK - size += 100; -#endif - - ASSERT(ctx->Driver.BufferData); - if (!ctx->Driver.BufferData( ctx, target, size, data, usage, bufObj )) { - _mesa_error(ctx, GL_OUT_OF_MEMORY, "glBufferDataARB()"); - } -} - - -void GLAPIENTRY -_mesa_BufferSubDataARB(GLenum target, GLintptrARB offset, - GLsizeiptrARB size, const GLvoid * data) -{ - GET_CURRENT_CONTEXT(ctx); - struct gl_buffer_object *bufObj; - ASSERT_OUTSIDE_BEGIN_END(ctx); - - bufObj = buffer_object_subdata_range_good( ctx, target, offset, size, - "glBufferSubDataARB" ); - if (!bufObj) { - /* error already recorded */ - return; - } - - if (size == 0) - return; - - bufObj->Written = GL_TRUE; - - ASSERT(ctx->Driver.BufferSubData); - ctx->Driver.BufferSubData( ctx, offset, size, data, bufObj ); -} - - -void GLAPIENTRY -_mesa_GetBufferSubDataARB(GLenum target, GLintptrARB offset, - GLsizeiptrARB size, void * data) -{ - GET_CURRENT_CONTEXT(ctx); - struct gl_buffer_object *bufObj; - ASSERT_OUTSIDE_BEGIN_END(ctx); - - bufObj = buffer_object_subdata_range_good( ctx, target, offset, size, - "glGetBufferSubDataARB" ); - if (!bufObj) { - /* error already recorded */ - return; - } - - ASSERT(ctx->Driver.GetBufferSubData); - ctx->Driver.GetBufferSubData( ctx, offset, size, data, bufObj ); -} - - -void * GLAPIENTRY -_mesa_MapBufferARB(GLenum target, GLenum access) -{ - GET_CURRENT_CONTEXT(ctx); - struct gl_buffer_object * bufObj; - GLbitfield accessFlags; - void *map; - - ASSERT_OUTSIDE_BEGIN_END_WITH_RETVAL(ctx, NULL); - - switch (access) { - case GL_READ_ONLY_ARB: - accessFlags = GL_MAP_READ_BIT; - break; - case GL_WRITE_ONLY_ARB: - accessFlags = GL_MAP_WRITE_BIT; - break; - case GL_READ_WRITE_ARB: - accessFlags = GL_MAP_READ_BIT | GL_MAP_WRITE_BIT; - break; - default: - _mesa_error(ctx, GL_INVALID_ENUM, "glMapBufferARB(access)"); - return NULL; - } - - bufObj = get_buffer(ctx, "glMapBufferARB", target); - if (!bufObj) - return NULL; - - if (_mesa_bufferobj_mapped(bufObj)) { - _mesa_error(ctx, GL_INVALID_OPERATION, "glMapBufferARB(already mapped)"); - return NULL; - } - - if (!bufObj->Size) { - _mesa_error(ctx, GL_OUT_OF_MEMORY, - "glMapBuffer(buffer size = 0)"); - return NULL; - } - - ASSERT(ctx->Driver.MapBufferRange); - map = ctx->Driver.MapBufferRange(ctx, 0, bufObj->Size, accessFlags, bufObj); - if (!map) { - _mesa_error(ctx, GL_OUT_OF_MEMORY, "glMapBufferARB(map failed)"); - return NULL; - } - else { - /* The driver callback should have set these fields. - * This is important because other modules (like VBO) might call - * the driver function directly. - */ - ASSERT(bufObj->Pointer == map); - ASSERT(bufObj->Length == bufObj->Size); - ASSERT(bufObj->Offset == 0); - bufObj->AccessFlags = accessFlags; - } - - if (access == GL_WRITE_ONLY_ARB || access == GL_READ_WRITE_ARB) - bufObj->Written = GL_TRUE; - -#ifdef VBO_DEBUG - printf("glMapBufferARB(%u, sz %ld, access 0x%x)\n", - bufObj->Name, bufObj->Size, access); - if (access == GL_WRITE_ONLY_ARB) { - GLuint i; - GLubyte *b = (GLubyte *) bufObj->Pointer; - for (i = 0; i < bufObj->Size; i++) - b[i] = i & 0xff; - } -#endif - -#ifdef BOUNDS_CHECK - { - GLubyte *buf = (GLubyte *) bufObj->Pointer; - GLuint i; - /* buffer is 100 bytes larger than requested, fill with magic value */ - for (i = 0; i < 100; i++) { - buf[bufObj->Size - i - 1] = 123; - } - } -#endif - - return bufObj->Pointer; -} - - -GLboolean GLAPIENTRY -_mesa_UnmapBufferARB(GLenum target) -{ - GET_CURRENT_CONTEXT(ctx); - struct gl_buffer_object *bufObj; - GLboolean status = GL_TRUE; - ASSERT_OUTSIDE_BEGIN_END_WITH_RETVAL(ctx, GL_FALSE); - - bufObj = get_buffer(ctx, "glUnmapBufferARB", target); - if (!bufObj) - return GL_FALSE; - - if (!_mesa_bufferobj_mapped(bufObj)) { - _mesa_error(ctx, GL_INVALID_OPERATION, "glUnmapBufferARB"); - return GL_FALSE; - } - -#ifdef BOUNDS_CHECK - if (bufObj->Access != GL_READ_ONLY_ARB) { - GLubyte *buf = (GLubyte *) bufObj->Pointer; - GLuint i; - /* check that last 100 bytes are still = magic value */ - for (i = 0; i < 100; i++) { - GLuint pos = bufObj->Size - i - 1; - if (buf[pos] != 123) { - _mesa_warning(ctx, "Out of bounds buffer object write detected" - " at position %d (value = %u)\n", - pos, buf[pos]); - } - } - } -#endif - -#ifdef VBO_DEBUG - if (bufObj->AccessFlags & GL_MAP_WRITE_BIT) { - GLuint i, unchanged = 0; - GLubyte *b = (GLubyte *) bufObj->Pointer; - GLint pos = -1; - /* check which bytes changed */ - for (i = 0; i < bufObj->Size - 1; i++) { - if (b[i] == (i & 0xff) && b[i+1] == ((i+1) & 0xff)) { - unchanged++; - if (pos == -1) - pos = i; - } - } - if (unchanged) { - printf("glUnmapBufferARB(%u): %u of %ld unchanged, starting at %d\n", - bufObj->Name, unchanged, bufObj->Size, pos); - } - } -#endif - - status = ctx->Driver.UnmapBuffer( ctx, bufObj ); - bufObj->AccessFlags = default_access_mode(ctx); - ASSERT(bufObj->Pointer == NULL); - ASSERT(bufObj->Offset == 0); - ASSERT(bufObj->Length == 0); - - return status; -} - - -void GLAPIENTRY -_mesa_GetBufferParameterivARB(GLenum target, GLenum pname, GLint *params) -{ - GET_CURRENT_CONTEXT(ctx); - struct gl_buffer_object *bufObj; - ASSERT_OUTSIDE_BEGIN_END(ctx); - - bufObj = get_buffer(ctx, "glGetBufferParameterivARB", target); - if (!bufObj) - return; - - switch (pname) { - case GL_BUFFER_SIZE_ARB: - *params = (GLint) bufObj->Size; - return; - case GL_BUFFER_USAGE_ARB: - *params = bufObj->Usage; - return; - case GL_BUFFER_ACCESS_ARB: - *params = simplified_access_mode(bufObj->AccessFlags); - return; - case GL_BUFFER_MAPPED_ARB: - *params = _mesa_bufferobj_mapped(bufObj); - return; - case GL_BUFFER_ACCESS_FLAGS: - if (!ctx->Extensions.ARB_map_buffer_range) - goto invalid_pname; - *params = bufObj->AccessFlags; - return; - case GL_BUFFER_MAP_OFFSET: - if (!ctx->Extensions.ARB_map_buffer_range) - goto invalid_pname; - *params = (GLint) bufObj->Offset; - return; - case GL_BUFFER_MAP_LENGTH: - if (!ctx->Extensions.ARB_map_buffer_range) - goto invalid_pname; - *params = (GLint) bufObj->Length; - return; - default: - ; /* fall-through */ - } - -invalid_pname: - _mesa_error(ctx, GL_INVALID_ENUM, "glGetBufferParameterivARB(pname=%s)", - _mesa_lookup_enum_by_nr(pname)); -} - - -/** - * New in GL 3.2 - * This is pretty much a duplicate of GetBufferParameteriv() but the - * GL_BUFFER_SIZE_ARB attribute will be 64-bits on a 64-bit system. - */ -void GLAPIENTRY -_mesa_GetBufferParameteri64v(GLenum target, GLenum pname, GLint64 *params) -{ - GET_CURRENT_CONTEXT(ctx); - struct gl_buffer_object *bufObj; - ASSERT_OUTSIDE_BEGIN_END(ctx); - - bufObj = get_buffer(ctx, "glGetBufferParameteri64v", target); - if (!bufObj) - return; - - switch (pname) { - case GL_BUFFER_SIZE_ARB: - *params = bufObj->Size; - return; - case GL_BUFFER_USAGE_ARB: - *params = bufObj->Usage; - return; - case GL_BUFFER_ACCESS_ARB: - *params = simplified_access_mode(bufObj->AccessFlags); - return; - case GL_BUFFER_ACCESS_FLAGS: - if (!ctx->Extensions.ARB_map_buffer_range) - goto invalid_pname; - *params = bufObj->AccessFlags; - return; - case GL_BUFFER_MAPPED_ARB: - *params = _mesa_bufferobj_mapped(bufObj); - return; - case GL_BUFFER_MAP_OFFSET: - if (!ctx->Extensions.ARB_map_buffer_range) - goto invalid_pname; - *params = bufObj->Offset; - return; - case GL_BUFFER_MAP_LENGTH: - if (!ctx->Extensions.ARB_map_buffer_range) - goto invalid_pname; - *params = bufObj->Length; - return; - default: - ; /* fall-through */ - } - -invalid_pname: - _mesa_error(ctx, GL_INVALID_ENUM, "glGetBufferParameteri64v(pname=%s)", - _mesa_lookup_enum_by_nr(pname)); -} - - -void GLAPIENTRY -_mesa_GetBufferPointervARB(GLenum target, GLenum pname, GLvoid **params) -{ - GET_CURRENT_CONTEXT(ctx); - struct gl_buffer_object * bufObj; - ASSERT_OUTSIDE_BEGIN_END(ctx); - - if (pname != GL_BUFFER_MAP_POINTER_ARB) { - _mesa_error(ctx, GL_INVALID_ENUM, "glGetBufferPointervARB(pname)"); - return; - } - - bufObj = get_buffer(ctx, "glGetBufferPointervARB", target); - if (!bufObj) - return; - - *params = bufObj->Pointer; -} - -/** - * See GL_ARB_map_buffer_range spec - */ -void * GLAPIENTRY -_mesa_MapBufferRange(GLenum target, GLintptr offset, GLsizeiptr length, - GLbitfield access) -{ - GET_CURRENT_CONTEXT(ctx); - struct gl_buffer_object *bufObj; - void *map; - - ASSERT_OUTSIDE_BEGIN_END_WITH_RETVAL(ctx, NULL); - - if (!ctx->Extensions.ARB_map_buffer_range) { - _mesa_error(ctx, GL_INVALID_OPERATION, - "glMapBufferRange(extension not supported)"); - return NULL; - } - - if (offset < 0) { - _mesa_error(ctx, GL_INVALID_VALUE, - "glMapBufferRange(offset = %ld)", (long)offset); - return NULL; - } - - if (length < 0) { - _mesa_error(ctx, GL_INVALID_VALUE, - "glMapBufferRange(length = %ld)", (long)length); - return NULL; - } - - if (access & ~(GL_MAP_READ_BIT | - GL_MAP_WRITE_BIT | - GL_MAP_INVALIDATE_RANGE_BIT | - GL_MAP_INVALIDATE_BUFFER_BIT | - GL_MAP_FLUSH_EXPLICIT_BIT | - GL_MAP_UNSYNCHRONIZED_BIT)) { - /* generate an error if any undefind bit is set */ - _mesa_error(ctx, GL_INVALID_VALUE, "glMapBufferRange(access)"); - return NULL; - } - - if ((access & (GL_MAP_READ_BIT | GL_MAP_WRITE_BIT)) == 0) { - _mesa_error(ctx, GL_INVALID_OPERATION, - "glMapBufferRange(access indicates neither read or write)"); - return NULL; - } - - if ((access & GL_MAP_READ_BIT) && - (access & (GL_MAP_INVALIDATE_RANGE_BIT | - GL_MAP_INVALIDATE_BUFFER_BIT | - GL_MAP_UNSYNCHRONIZED_BIT))) { - _mesa_error(ctx, GL_INVALID_OPERATION, - "glMapBufferRange(invalid access flags)"); - return NULL; - } - - if ((access & GL_MAP_FLUSH_EXPLICIT_BIT) && - ((access & GL_MAP_WRITE_BIT) == 0)) { - _mesa_error(ctx, GL_INVALID_OPERATION, - "glMapBufferRange(invalid access flags)"); - return NULL; - } - - bufObj = get_buffer(ctx, "glMapBufferRange", target); - if (!bufObj) - return NULL; - - if (offset + length > bufObj->Size) { - _mesa_error(ctx, GL_INVALID_VALUE, - "glMapBufferRange(offset + length > size)"); - return NULL; - } - - if (_mesa_bufferobj_mapped(bufObj)) { - _mesa_error(ctx, GL_INVALID_OPERATION, - "glMapBufferRange(buffer already mapped)"); - return NULL; - } - - if (!bufObj->Size) { - _mesa_error(ctx, GL_OUT_OF_MEMORY, - "glMapBufferRange(buffer size = 0)"); - return NULL; - } - - /* Mapping zero bytes should return a non-null pointer. */ - if (!length) { - static long dummy = 0; - bufObj->Pointer = &dummy; - bufObj->Length = length; - bufObj->Offset = offset; - bufObj->AccessFlags = access; - return bufObj->Pointer; - } - - ASSERT(ctx->Driver.MapBufferRange); - map = ctx->Driver.MapBufferRange(ctx, offset, length, access, bufObj); - if (!map) { - _mesa_error(ctx, GL_OUT_OF_MEMORY, "glMapBufferARB(map failed)"); - } - else { - /* The driver callback should have set all these fields. - * This is important because other modules (like VBO) might call - * the driver function directly. - */ - ASSERT(bufObj->Pointer == map); - ASSERT(bufObj->Length == length); - ASSERT(bufObj->Offset == offset); - ASSERT(bufObj->AccessFlags == access); - } - - return map; -} - - -/** - * See GL_ARB_map_buffer_range spec - */ -void GLAPIENTRY -_mesa_FlushMappedBufferRange(GLenum target, GLintptr offset, GLsizeiptr length) -{ - GET_CURRENT_CONTEXT(ctx); - struct gl_buffer_object *bufObj; - ASSERT_OUTSIDE_BEGIN_END(ctx); - - if (!ctx->Extensions.ARB_map_buffer_range) { - _mesa_error(ctx, GL_INVALID_OPERATION, - "glFlushMappedBufferRange(extension not supported)"); - return; - } - - if (offset < 0) { - _mesa_error(ctx, GL_INVALID_VALUE, - "glFlushMappedBufferRange(offset = %ld)", (long)offset); - return; - } - - if (length < 0) { - _mesa_error(ctx, GL_INVALID_VALUE, - "glFlushMappedBufferRange(length = %ld)", (long)length); - return; - } - - bufObj = get_buffer(ctx, "glFlushMappedBufferRange", target); - if (!bufObj) - return; - - if (!_mesa_bufferobj_mapped(bufObj)) { - /* buffer is not mapped */ - _mesa_error(ctx, GL_INVALID_OPERATION, - "glFlushMappedBufferRange(buffer is not mapped)"); - return; - } - - if ((bufObj->AccessFlags & GL_MAP_FLUSH_EXPLICIT_BIT) == 0) { - _mesa_error(ctx, GL_INVALID_OPERATION, - "glFlushMappedBufferRange(GL_MAP_FLUSH_EXPLICIT_BIT not set)"); - return; - } - - if (offset + length > bufObj->Length) { - _mesa_error(ctx, GL_INVALID_VALUE, - "glFlushMappedBufferRange(offset %ld + length %ld > mapped length %ld)", - (long)offset, (long)length, (long)bufObj->Length); - return; - } - - ASSERT(bufObj->AccessFlags & GL_MAP_WRITE_BIT); - - if (ctx->Driver.FlushMappedBufferRange) - ctx->Driver.FlushMappedBufferRange(ctx, offset, length, bufObj); -} - diff --git a/dll/opengl/mesa/main/bufferobj.h b/dll/opengl/mesa/main/bufferobj.h deleted file mode 100644 index dbfd8e7a0d8..00000000000 --- a/dll/opengl/mesa/main/bufferobj.h +++ /dev/null @@ -1,155 +0,0 @@ -/* - * Mesa 3-D graphics library - * Version: 7.6 - * - * Copyright (C) 1999-2008 Brian Paul All Rights Reserved. - * Copyright (C) 2009 VMware, Inc. All Rights Reserved. - * - * Permission is hereby granted, free of charge, to any person obtaining a - * copy of this software and associated documentation files (the "Software"), - * to deal in the Software without restriction, including without limitation - * the rights to use, copy, modify, merge, publish, distribute, sublicense, - * and/or sell copies of the Software, and to permit persons to whom the - * Software is furnished to do so, subject to the following conditions: - * - * The above copyright notice and this permission notice shall be included - * in all copies or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS - * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL - * BRIAN PAUL BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN - * AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN - * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. - */ - - - -#ifndef BUFFEROBJ_H -#define BUFFEROBJ_H - - -#include "mfeatures.h" -#include "mtypes.h" - - -/* - * Internal functions - */ - - -/** Is the given buffer object currently mapped? */ -static inline GLboolean -_mesa_bufferobj_mapped(const struct gl_buffer_object *obj) -{ - return obj->Pointer != NULL; -} - -/** - * Is the given buffer object a user-created buffer object? - * Mesa uses default buffer objects in several places. Default buffers - * always have Name==0. User created buffers have Name!=0. - */ -static inline GLboolean -_mesa_is_bufferobj(const struct gl_buffer_object *obj) -{ - return obj != NULL && obj->Name != 0; -} - - -extern void -_mesa_init_buffer_objects( struct gl_context *ctx ); - -extern void -_mesa_free_buffer_objects( struct gl_context *ctx ); - -extern void -_mesa_update_default_objects_buffer_objects(struct gl_context *ctx); - - -extern struct gl_buffer_object * -_mesa_lookup_bufferobj(struct gl_context *ctx, GLuint buffer); - -extern void -_mesa_initialize_buffer_object( struct gl_context *ctx, - struct gl_buffer_object *obj, - GLuint name, GLenum target ); - -extern void -_mesa_reference_buffer_object_(struct gl_context *ctx, - struct gl_buffer_object **ptr, - struct gl_buffer_object *bufObj); - -static inline void -_mesa_reference_buffer_object(struct gl_context *ctx, - struct gl_buffer_object **ptr, - struct gl_buffer_object *bufObj) -{ - if (*ptr != bufObj) - _mesa_reference_buffer_object_(ctx, ptr, bufObj); -} - - -extern void -_mesa_init_buffer_object_functions(struct dd_function_table *driver); - - -/* - * API functions - */ - -extern void GLAPIENTRY -_mesa_BindBufferARB(GLenum target, GLuint buffer); - -extern void GLAPIENTRY -_mesa_DeleteBuffersARB(GLsizei n, const GLuint * buffer); - -extern void GLAPIENTRY -_mesa_GenBuffersARB(GLsizei n, GLuint * buffer); - -extern GLboolean GLAPIENTRY -_mesa_IsBufferARB(GLuint buffer); - -extern void GLAPIENTRY -_mesa_BufferDataARB(GLenum target, GLsizeiptrARB size, const GLvoid * data, GLenum usage); - -extern void GLAPIENTRY -_mesa_BufferSubDataARB(GLenum target, GLintptrARB offset, GLsizeiptrARB size, const GLvoid * data); - -extern void GLAPIENTRY -_mesa_GetBufferSubDataARB(GLenum target, GLintptrARB offset, GLsizeiptrARB size, void * data); - -extern void * GLAPIENTRY -_mesa_MapBufferARB(GLenum target, GLenum access); - -extern GLboolean GLAPIENTRY -_mesa_UnmapBufferARB(GLenum target); - -extern void GLAPIENTRY -_mesa_GetBufferParameterivARB(GLenum target, GLenum pname, GLint *params); - -extern void GLAPIENTRY -_mesa_GetBufferParameteri64v(GLenum target, GLenum pname, GLint64 *params); - -extern void GLAPIENTRY -_mesa_GetBufferPointervARB(GLenum target, GLenum pname, GLvoid **params); - -extern void * GLAPIENTRY -_mesa_MapBufferRange(GLenum target, GLintptr offset, GLsizeiptr length, - GLbitfield access); - -extern void GLAPIENTRY -_mesa_FlushMappedBufferRange(GLenum target, GLintptr offset, GLsizeiptr length); - -#if FEATURE_APPLE_object_purgeable -extern GLenum GLAPIENTRY -_mesa_ObjectPurgeableAPPLE(GLenum objectType, GLuint name, GLenum option); - -extern GLenum GLAPIENTRY -_mesa_ObjectUnpurgeableAPPLE(GLenum objectType, GLuint name, GLenum option); - -extern void GLAPIENTRY -_mesa_GetObjectParameterivAPPLE(GLenum objectType, GLuint name, GLenum pname, GLint* params); -#endif - -#endif diff --git a/dll/opengl/mesa/main/buffers.c b/dll/opengl/mesa/main/buffers.c deleted file mode 100644 index a634a870d02..00000000000 --- a/dll/opengl/mesa/main/buffers.c +++ /dev/null @@ -1,347 +0,0 @@ -/* - * Mesa 3-D graphics library - * Version: 7.1 - * - * Copyright (C) 1999-2007 Brian Paul All Rights Reserved. - * - * Permission is hereby granted, free of charge, to any person obtaining a - * copy of this software and associated documentation files (the "Software"), - * to deal in the Software without restriction, including without limitation - * the rights to use, copy, modify, merge, publish, distribute, sublicense, - * and/or sell copies of the Software, and to permit persons to whom the - * Software is furnished to do so, subject to the following conditions: - * - * The above copyright notice and this permission notice shall be included - * in all copies or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS - * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL - * BRIAN PAUL BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN - * AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN - * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. - */ - -/** - * \file buffers.c - * glReadBuffer, DrawBuffer functions. - */ - -#include - -#define BAD_MASK ~0u - -/** - * Return bitmask of BUFFER_BIT_* flags indicating which color buffers are - * available to the rendering context (for drawing or reading). - * This depends on the type of framebuffer. For window system framebuffers - * we look at the framebuffer's visual. But for user-create framebuffers we - * look at the number of supported color attachments. - * \param fb the framebuffer to draw to, or read from - * \return bitmask of BUFFER_BIT_* flags - */ -static GLbitfield -supported_buffer_bitmask(const struct gl_context *ctx, const struct gl_framebuffer *fb) -{ - GLbitfield mask = 0x0; - - /* A window system framebuffer */ - GLint i; - mask = BUFFER_BIT_FRONT_LEFT; /* always have this */ - if (fb->Visual.stereoMode) { - mask |= BUFFER_BIT_FRONT_RIGHT; - if (fb->Visual.doubleBufferMode) { - mask |= BUFFER_BIT_BACK_LEFT | BUFFER_BIT_BACK_RIGHT; - } - } - else if (fb->Visual.doubleBufferMode) { - mask |= BUFFER_BIT_BACK_LEFT; - } - - for (i = 0; i < fb->Visual.numAuxBuffers; i++) { - mask |= (BUFFER_BIT_AUX0 << i); - } - - return mask; -} - - -/** - * Helper routine used by glDrawBuffer and glDrawBuffersARB. - * Given a GLenum naming one or more color buffers (such as - * GL_FRONT_AND_BACK), return the corresponding bitmask of BUFFER_BIT_* flags. - */ -static GLbitfield -draw_buffer_enum_to_bitmask(GLenum buffer) -{ - switch (buffer) { - case GL_NONE: - return 0; - case GL_FRONT: - return BUFFER_BIT_FRONT_LEFT | BUFFER_BIT_FRONT_RIGHT; - case GL_BACK: - return BUFFER_BIT_BACK_LEFT | BUFFER_BIT_BACK_RIGHT; - case GL_RIGHT: - return BUFFER_BIT_FRONT_RIGHT | BUFFER_BIT_BACK_RIGHT; - case GL_FRONT_RIGHT: - return BUFFER_BIT_FRONT_RIGHT; - case GL_BACK_RIGHT: - return BUFFER_BIT_BACK_RIGHT; - case GL_BACK_LEFT: - return BUFFER_BIT_BACK_LEFT; - case GL_FRONT_AND_BACK: - return BUFFER_BIT_FRONT_LEFT | BUFFER_BIT_BACK_LEFT - | BUFFER_BIT_FRONT_RIGHT | BUFFER_BIT_BACK_RIGHT; - case GL_LEFT: - return BUFFER_BIT_FRONT_LEFT | BUFFER_BIT_BACK_LEFT; - case GL_FRONT_LEFT: - return BUFFER_BIT_FRONT_LEFT; - case GL_AUX0: - return BUFFER_BIT_AUX0; - case GL_AUX1: - case GL_AUX2: - case GL_AUX3: - return 1 << BUFFER_COUNT; /* invalid, but not BAD_MASK */ - default: - /* error */ - return BAD_MASK; - } -} - - -/** - * Helper routine used by glReadBuffer. - * Given a GLenum naming a color buffer, return the index of the corresponding - * renderbuffer (a BUFFER_* value). - * return -1 for an invalid buffer. - */ -static GLint -read_buffer_enum_to_index(GLenum buffer) -{ - switch (buffer) { - case GL_FRONT: - return BUFFER_FRONT_LEFT; - case GL_BACK: - return BUFFER_BACK_LEFT; - case GL_RIGHT: - return BUFFER_FRONT_RIGHT; - case GL_FRONT_RIGHT: - return BUFFER_FRONT_RIGHT; - case GL_BACK_RIGHT: - return BUFFER_BACK_RIGHT; - case GL_BACK_LEFT: - return BUFFER_BACK_LEFT; - case GL_LEFT: - return BUFFER_FRONT_LEFT; - case GL_FRONT_LEFT: - return BUFFER_FRONT_LEFT; - case GL_AUX0: - return BUFFER_AUX0; - case GL_AUX1: - case GL_AUX2: - case GL_AUX3: - return BUFFER_COUNT; /* invalid, but not -1 */ - default: - /* error */ - return -1; - } -} - - -/** - * Called by glDrawBuffer(). - * Specify which renderbuffer(s) to draw into for the first color output. - * can name zero, one, two or four renderbuffers! - * \sa _mesa_DrawBuffersARB - * - * \param buffer buffer token such as GL_LEFT or GL_FRONT_AND_BACK, etc. - * - * Note that the behaviour of this function depends on whether the - * current ctx->DrawBuffer is a window-system framebuffer (Name=0) or - * a user-created framebuffer object (Name!=0). - * In the former case, we update the per-context ctx->Color.DrawBuffer - * state var _and_ the FB's ColorDrawBuffer state. - * In the later case, we update the FB's ColorDrawBuffer state only. - * - * Furthermore, upon a MakeCurrent() or BindFramebuffer() call, if the - * new FB is a window system FB, we need to re-update the FB's - * ColorDrawBuffer state to match the context. This is handled in - * _mesa_update_framebuffer(). - * - * See the GL_EXT_framebuffer_object spec for more info. - */ -void GLAPIENTRY -_mesa_DrawBuffer(GLenum buffer) -{ - GLbitfield destMask; - GET_CURRENT_CONTEXT(ctx); - ASSERT_OUTSIDE_BEGIN_END_AND_FLUSH(ctx); /* too complex... */ - - if (MESA_VERBOSE & VERBOSE_API) { - _mesa_debug(ctx, "glDrawBuffer %s\n", _mesa_lookup_enum_by_nr(buffer)); - } - - if (buffer == GL_NONE) { - destMask = 0x0; - } - else { - const GLbitfield supportedMask - = supported_buffer_bitmask(ctx, ctx->DrawBuffer); - destMask = draw_buffer_enum_to_bitmask(buffer); - if (destMask == BAD_MASK) { - /* totally bogus buffer */ - _mesa_error(ctx, GL_INVALID_ENUM, "glDrawBuffer(buffer=0x%x)", buffer); - return; - } - destMask &= supportedMask; - if (destMask == 0x0) { - /* none of the named color buffers exist! */ - _mesa_error(ctx, GL_INVALID_OPERATION, - "glDrawBuffer(buffer=0x%x)", buffer); - return; - } - } - - /* if we get here, there's no error so set new state */ - _mesa_drawbuffer(ctx, buffer, destMask); - - /* - * Call device driver function. - */ - if (ctx->Driver.DrawBuffer) - ctx->Driver.DrawBuffer(ctx, buffer); -} - -/** - * Performs necessary state updates when _mesa_drawbuffers makes an - * actual change. - */ -static void -updated_drawbuffers(struct gl_context *ctx) -{ - FLUSH_VERTICES(ctx, _NEW_BUFFERS); -} - -/** - * Helper function to set the GL_DRAW_BUFFER state in the context and - * current FBO. Called via glDrawBuffer(), glDrawBuffersARB() - * - * All error checking will have been done prior to calling this function - * so nothing should go wrong at this point. - * - * \param ctx current context - * \param n number of color outputs to set - * \param buffers array[n] of colorbuffer names, like GL_LEFT. - * \param destMask array[n] of BUFFER_BIT_* bitmasks which correspond to the - * colorbuffer names. (i.e. GL_FRONT_AND_BACK => - * BUFFER_BIT_FRONT_LEFT | BUFFER_BIT_BACK_LEFT). - */ -void -_mesa_drawbuffer(struct gl_context *ctx, const GLenum buffers, GLbitfield destMask) -{ - struct gl_framebuffer *fb = ctx->DrawBuffer; - GLint bufIndex; - - if (!destMask) { - /* compute destMask values now */ - const GLbitfield supportedMask = supported_buffer_bitmask(ctx, fb); - destMask = draw_buffer_enum_to_bitmask(buffers); - ASSERT(destmask != BAD_MASK); - destMask &= supportedMask; - } - - bufIndex = _mesa_ffs(destMask) - 1; - - if (fb->_ColorDrawBufferIndex != bufIndex) { - updated_drawbuffers(ctx); - fb->_ColorDrawBufferIndex = bufIndex; - } - fb->ColorDrawBuffer = buffers; - - if (ctx->Color.DrawBuffer != fb->ColorDrawBuffer) { - updated_drawbuffers(ctx); - ctx->Color.DrawBuffer = fb->ColorDrawBuffer; - } -} - - -/** - * Update the current drawbuffer's _ColorDrawBufferIndex[] list, etc. - * from the context's Color.DrawBuffer[] state. - * Use when changing contexts. - */ -void -_mesa_update_draw_buffer(struct gl_context *ctx) -{ - _mesa_drawbuffer(ctx, ctx->Color.DrawBuffer, 0); -} - - -/** - * Like \sa _mesa_drawbuffers(), this is a helper function for setting - * GL_READ_BUFFER state in the context and current FBO. - * \param ctx the rendering context - * \param buffer GL_FRONT, GL_BACK, GL_COLOR_ATTACHMENT0, etc. - * \param bufferIndex the numerical index corresponding to 'buffer' - */ -void -_mesa_readbuffer(struct gl_context *ctx, GLenum buffer, GLint bufferIndex) -{ - struct gl_framebuffer *fb = ctx->ReadBuffer; - - ctx->Pixel.ReadBuffer = buffer; - - fb->ColorReadBuffer = buffer; - fb->_ColorReadBufferIndex = bufferIndex; - - ctx->NewState |= _NEW_BUFFERS; -} - - - -/** - * Called by glReadBuffer to set the source renderbuffer for reading pixels. - * \param mode color buffer such as GL_FRONT, GL_BACK, etc. - */ -void GLAPIENTRY -_mesa_ReadBuffer(GLenum buffer) -{ - struct gl_framebuffer *fb; - GLbitfield supportedMask; - GLint srcBuffer; - GET_CURRENT_CONTEXT(ctx); - ASSERT_OUTSIDE_BEGIN_END_AND_FLUSH(ctx); - - if (MESA_VERBOSE & VERBOSE_API) - _mesa_debug(ctx, "glReadBuffer %s\n", _mesa_lookup_enum_by_nr(buffer)); - - fb = ctx->ReadBuffer; - - if (MESA_VERBOSE & VERBOSE_API) - _mesa_debug(ctx, "glReadBuffer %s\n", _mesa_lookup_enum_by_nr(buffer)); - - /* general case / window-system framebuffer */ - srcBuffer = read_buffer_enum_to_index(buffer); - if (srcBuffer == -1) { - _mesa_error(ctx, GL_INVALID_ENUM, - "glReadBuffer(buffer=0x%x)", buffer); - return; - } - supportedMask = supported_buffer_bitmask(ctx, fb); - if (((1 << srcBuffer) & supportedMask) == 0) { - _mesa_error(ctx, GL_INVALID_OPERATION, - "glReadBuffer(buffer=0x%x)", buffer); - return; - } - - /* OK, all error checking has been completed now */ - - _mesa_readbuffer(ctx, buffer, srcBuffer); - ctx->NewState |= _NEW_BUFFERS; - - /* - * Call device driver function. - */ - if (ctx->Driver.ReadBuffer) - (*ctx->Driver.ReadBuffer)(ctx, buffer); -} diff --git a/dll/opengl/mesa/main/buffers.h b/dll/opengl/mesa/main/buffers.h deleted file mode 100644 index c0b431a6543..00000000000 --- a/dll/opengl/mesa/main/buffers.h +++ /dev/null @@ -1,57 +0,0 @@ -/** - * \file buffers.h - * Frame buffer management functions declarations. - */ - -/* - * Mesa 3-D graphics library - * Version: 7.1 - * - * Copyright (C) 1999-2007 Brian Paul All Rights Reserved. - * - * Permission is hereby granted, free of charge, to any person obtaining a - * copy of this software and associated documentation files (the "Software"), - * to deal in the Software without restriction, including without limitation - * the rights to use, copy, modify, merge, publish, distribute, sublicense, - * and/or sell copies of the Software, and to permit persons to whom the - * Software is furnished to do so, subject to the following conditions: - * - * The above copyright notice and this permission notice shall be included - * in all copies or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS - * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL - * BRIAN PAUL BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN - * AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN - * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. - */ - - - -#ifndef BUFFERS_H -#define BUFFERS_H - - -#include "glheader.h" - -struct gl_context; - -extern void GLAPIENTRY -_mesa_DrawBuffer( GLenum mode ); - -extern void -_mesa_drawbuffer(struct gl_context *ctx, const GLenum buffers, GLbitfield destMask); - -extern void -_mesa_readbuffer(struct gl_context *ctx, GLenum buffer, GLint bufferIndex); - -extern void -_mesa_update_draw_buffer(struct gl_context *ctx); - - -extern void GLAPIENTRY -_mesa_ReadBuffer( GLenum mode ); - - -#endif diff --git a/dll/opengl/mesa/main/clear.c b/dll/opengl/mesa/main/clear.c deleted file mode 100644 index 0c8515650a6..00000000000 --- a/dll/opengl/mesa/main/clear.c +++ /dev/null @@ -1,223 +0,0 @@ -/* - * Mesa 3-D graphics library - * Version: 7.1 - * - * Copyright (C) 1999-2007 Brian Paul All Rights Reserved. - * - * Permission is hereby granted, free of charge, to any person obtaining a - * copy of this software and associated documentation files (the "Software"), - * to deal in the Software without restriction, including without limitation - * the rights to use, copy, modify, merge, publish, distribute, sublicense, - * and/or sell copies of the Software, and to permit persons to whom the - * Software is furnished to do so, subject to the following conditions: - * - * The above copyright notice and this permission notice shall be included - * in all copies or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS - * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL - * BRIAN PAUL BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN - * AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN - * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. - */ - -/** - * \file clear.c - * glClearColor, glClearIndex, glClear() functions. - */ - -#include - -#if _HAVE_FULL_GL -void GLAPIENTRY -_mesa_ClearIndex( GLfloat c ) -{ - GET_CURRENT_CONTEXT(ctx); - ASSERT_OUTSIDE_BEGIN_END(ctx); - - if (ctx->Color.ClearIndex == (GLuint) c) - return; - - FLUSH_VERTICES(ctx, _NEW_COLOR); - ctx->Color.ClearIndex = (GLuint) c; -} -#endif - - -/** - * Specify the clear values for the color buffers. - * - * \param red red color component. - * \param green green color component. - * \param blue blue color component. - * \param alpha alpha component. - * - * \sa glClearColor(). - * - * Clamps the parameters and updates gl_colorbuffer_attrib::ClearColor. On a - * change, flushes the vertices and notifies the driver via the - * dd_function_table::ClearColor callback. - */ -void GLAPIENTRY -_mesa_ClearColor( GLclampf red, GLclampf green, GLclampf blue, GLclampf alpha ) -{ - GLfloat tmp[4]; - GET_CURRENT_CONTEXT(ctx); - ASSERT_OUTSIDE_BEGIN_END(ctx); - - tmp[0] = red; - tmp[1] = green; - tmp[2] = blue; - tmp[3] = alpha; - - if (TEST_EQ_4V(tmp, ctx->Color.ClearColor.f)) - return; /* no change */ - - FLUSH_VERTICES(ctx, _NEW_COLOR); - COPY_4V(ctx->Color.ClearColor.f, tmp); - - if (ctx->Driver.ClearColor) { - /* it's OK to call glClearColor in CI mode but it should be a NOP */ - /* we pass the clamped color, since all drivers that need this don't - * support GL_ARB_color_buffer_float - */ - (*ctx->Driver.ClearColor)(ctx, ctx->Color.ClearColor); - } -} - - -/** - * GL_EXT_texture_integer - */ -void GLAPIENTRY -_mesa_ClearColorIiEXT(GLint r, GLint g, GLint b, GLint a) -{ - GLint tmp[4]; - GET_CURRENT_CONTEXT(ctx); - ASSERT_OUTSIDE_BEGIN_END(ctx); - - tmp[0] = r; - tmp[1] = g; - tmp[2] = b; - tmp[3] = a; - - if (TEST_EQ_4V(tmp, ctx->Color.ClearColor.i)) - return; /* no change */ - - FLUSH_VERTICES(ctx, _NEW_COLOR); - COPY_4V(ctx->Color.ClearColor.i, tmp); - - /* these should be NOP calls for drivers supporting EXT_texture_integer */ - if (ctx->Driver.ClearColor) { - ctx->Driver.ClearColor(ctx, ctx->Color.ClearColor); - } -} - - -/** - * GL_EXT_texture_integer - */ -void GLAPIENTRY -_mesa_ClearColorIuiEXT(GLuint r, GLuint g, GLuint b, GLuint a) -{ - GLuint tmp[4]; - GET_CURRENT_CONTEXT(ctx); - ASSERT_OUTSIDE_BEGIN_END(ctx); - - tmp[0] = r; - tmp[1] = g; - tmp[2] = b; - tmp[3] = a; - - if (TEST_EQ_4V(tmp, ctx->Color.ClearColor.ui)) - return; /* no change */ - - FLUSH_VERTICES(ctx, _NEW_COLOR); - COPY_4V(ctx->Color.ClearColor.ui, tmp); - - /* these should be NOP calls for drivers supporting EXT_texture_integer */ - if (ctx->Driver.ClearColor) { - ctx->Driver.ClearColor(ctx, ctx->Color.ClearColor); - } -} - - -/** - * Clear buffers. - * - * \param mask bit-mask indicating the buffers to be cleared. - * - * Flushes the vertices and verifies the parameter. If __struct gl_contextRec::NewState - * is set then calls _mesa_update_state() to update gl_frame_buffer::_Xmin, - * etc. If the rasterization mode is set to GL_RENDER then requests the driver - * to clear the buffers, via the dd_function_table::Clear callback. - */ -void GLAPIENTRY -_mesa_Clear( GLbitfield mask ) -{ - GET_CURRENT_CONTEXT(ctx); - ASSERT_OUTSIDE_BEGIN_END_AND_FLUSH(ctx); - - FLUSH_CURRENT(ctx, 0); - - if (MESA_VERBOSE & VERBOSE_API) - _mesa_debug(ctx, "glClear 0x%x\n", mask); - - if (mask & ~(GL_COLOR_BUFFER_BIT | - GL_DEPTH_BUFFER_BIT | - GL_STENCIL_BUFFER_BIT | - GL_ACCUM_BUFFER_BIT)) { - /* invalid bit set */ - _mesa_error( ctx, GL_INVALID_VALUE, "glClear(0x%x)", mask); - return; - } - - if (ctx->NewState) { - _mesa_update_state( ctx ); /* update _Xmin, etc */ - } - - if (ctx->DrawBuffer->Width == 0 || ctx->DrawBuffer->Height == 0 || - ctx->DrawBuffer->_Xmin >= ctx->DrawBuffer->_Xmax || - ctx->DrawBuffer->_Ymin >= ctx->DrawBuffer->_Ymax) - return; - - if (ctx->RasterDiscard) - return; - - if (ctx->RenderMode == GL_RENDER) { - GLbitfield bufferMask; - - /* don't clear depth buffer if depth writing disabled */ - if (!ctx->Depth.Mask) - mask &= ~GL_DEPTH_BUFFER_BIT; - - /* Build the bitmask to send to device driver's Clear function. - * Note that the GL_COLOR_BUFFER_BIT flag will expand to 0, 1, 2 or 4 - * of the BUFFER_BIT_FRONT/BACK_LEFT/RIGHT flags, or one of the - * BUFFER_BIT_COLORn flags. - */ - bufferMask = 0; - if (mask & GL_COLOR_BUFFER_BIT) { - bufferMask |= (1 << ctx->DrawBuffer->_ColorDrawBufferIndex); - } - - if ((mask & GL_DEPTH_BUFFER_BIT) - && ctx->DrawBuffer->Visual.haveDepthBuffer) { - bufferMask |= BUFFER_BIT_DEPTH; - } - - if ((mask & GL_STENCIL_BUFFER_BIT) - && ctx->DrawBuffer->Visual.haveStencilBuffer) { - bufferMask |= BUFFER_BIT_STENCIL; - } - - if ((mask & GL_ACCUM_BUFFER_BIT) - && ctx->DrawBuffer->Visual.haveAccumBuffer) { - bufferMask |= BUFFER_BIT_ACCUM; - } - - ASSERT(ctx->Driver.Clear); - ctx->Driver.Clear(ctx, bufferMask); - } -} diff --git a/dll/opengl/mesa/main/clear.h b/dll/opengl/mesa/main/clear.h deleted file mode 100644 index b9965915a27..00000000000 --- a/dll/opengl/mesa/main/clear.h +++ /dev/null @@ -1,51 +0,0 @@ -/* - * Mesa 3-D graphics library - * Version: 7.1 - * - * Copyright (C) 1999-2007 Brian Paul All Rights Reserved. - * - * Permission is hereby granted, free of charge, to any person obtaining a - * copy of this software and associated documentation files (the "Software"), - * to deal in the Software without restriction, including without limitation - * the rights to use, copy, modify, merge, publish, distribute, sublicense, - * and/or sell copies of the Software, and to permit persons to whom the - * Software is furnished to do so, subject to the following conditions: - * - * The above copyright notice and this permission notice shall be included - * in all copies or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS - * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL - * BRIAN PAUL BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN - * AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN - * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. - */ - - -#ifndef CLEAR_H -#define CLEAR_H - - -#include "glheader.h" - - -extern void GLAPIENTRY -_mesa_ClearIndex( GLfloat c ); - -extern void GLAPIENTRY -_mesa_ClearColor( GLclampf red, GLclampf green, - GLclampf blue, GLclampf alpha ); - -extern void GLAPIENTRY -_mesa_ClearColorIiEXT(GLint r, GLint g, GLint b, GLint a); - -extern void GLAPIENTRY -_mesa_ClearColorIuiEXT(GLuint r, GLuint g, GLuint b, GLuint a); - - -extern void GLAPIENTRY -_mesa_Clear( GLbitfield mask ); - - -#endif diff --git a/dll/opengl/mesa/main/clip.c b/dll/opengl/mesa/main/clip.c deleted file mode 100644 index 331856060f9..00000000000 --- a/dll/opengl/mesa/main/clip.c +++ /dev/null @@ -1,108 +0,0 @@ -/* - * Mesa 3-D graphics library - * Version: 6.3 - * - * Copyright (C) 1999-2005 Brian Paul All Rights Reserved. - * - * Permission is hereby granted, free of charge, to any person obtaining a - * copy of this software and associated documentation files (the "Software"), - * to deal in the Software without restriction, including without limitation - * the rights to use, copy, modify, merge, publish, distribute, sublicense, - * and/or sell copies of the Software, and to permit persons to whom the - * Software is furnished to do so, subject to the following conditions: - * - * The above copyright notice and this permission notice shall be included - * in all copies or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS - * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL - * BRIAN PAUL BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN - * AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN - * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. - */ - -#include - -/** - * Update derived clip plane state. - */ -void -_mesa_update_clip_plane(struct gl_context *ctx, GLuint plane) -{ - if (_math_matrix_is_dirty(ctx->ProjectionMatrixStack.Top)) - _math_matrix_analyse( ctx->ProjectionMatrixStack.Top ); - - /* Clip-Space Plane = Eye-Space Plane * Projection Matrix */ - _mesa_transform_vector(ctx->Transform._ClipUserPlane[plane], - ctx->Transform.EyeUserPlane[plane], - ctx->ProjectionMatrixStack.Top->inv); -} - - -void GLAPIENTRY -_mesa_ClipPlane( GLenum plane, const GLdouble *eq ) -{ - GET_CURRENT_CONTEXT(ctx); - GLint p; - GLfloat equation[4]; - ASSERT_OUTSIDE_BEGIN_END(ctx); - - p = (GLint) plane - (GLint) GL_CLIP_PLANE0; - if (p < 0 || p >= (GLint) ctx->Const.MaxClipPlanes) { - _mesa_error( ctx, GL_INVALID_ENUM, "glClipPlane" ); - return; - } - - equation[0] = (GLfloat) eq[0]; - equation[1] = (GLfloat) eq[1]; - equation[2] = (GLfloat) eq[2]; - equation[3] = (GLfloat) eq[3]; - - /* - * The equation is transformed by the transpose of the inverse of the - * current modelview matrix and stored in the resulting eye coordinates. - * - * KW: Eqn is then transformed to the current clip space, where user - * clipping now takes place. The clip-space equations are recalculated - * whenever the projection matrix changes. - */ - if (_math_matrix_is_dirty(ctx->ModelviewMatrixStack.Top)) - _math_matrix_analyse( ctx->ModelviewMatrixStack.Top ); - - _mesa_transform_vector( equation, equation, - ctx->ModelviewMatrixStack.Top->inv ); - - if (TEST_EQ_4V(ctx->Transform.EyeUserPlane[p], equation)) - return; - - FLUSH_VERTICES(ctx, _NEW_TRANSFORM); - COPY_4FV(ctx->Transform.EyeUserPlane[p], equation); - - if (ctx->Transform.ClipPlanesEnabled & (1 << p)) { - _mesa_update_clip_plane(ctx, p); - } - - if (ctx->Driver.ClipPlane) - ctx->Driver.ClipPlane( ctx, plane, equation ); -} - - -void GLAPIENTRY -_mesa_GetClipPlane( GLenum plane, GLdouble *equation ) -{ - GET_CURRENT_CONTEXT(ctx); - GLint p; - ASSERT_OUTSIDE_BEGIN_END(ctx); - - p = (GLint) (plane - GL_CLIP_PLANE0); - if (p < 0 || p >= (GLint) ctx->Const.MaxClipPlanes) { - _mesa_error( ctx, GL_INVALID_ENUM, "glGetClipPlane" ); - return; - } - - equation[0] = (GLdouble) ctx->Transform.EyeUserPlane[p][0]; - equation[1] = (GLdouble) ctx->Transform.EyeUserPlane[p][1]; - equation[2] = (GLdouble) ctx->Transform.EyeUserPlane[p][2]; - equation[3] = (GLdouble) ctx->Transform.EyeUserPlane[p][3]; -} diff --git a/dll/opengl/mesa/main/clip.h b/dll/opengl/mesa/main/clip.h deleted file mode 100644 index a8e6d768758..00000000000 --- a/dll/opengl/mesa/main/clip.h +++ /dev/null @@ -1,47 +0,0 @@ -/** - * \file clip.h - */ - -/* - * Mesa 3-D graphics library - * Version: 3.5 - * - * Copyright (C) 1999-2001 Brian Paul All Rights Reserved. - * - * Permission is hereby granted, free of charge, to any person obtaining a - * copy of this software and associated documentation files (the "Software"), - * to deal in the Software without restriction, including without limitation - * the rights to use, copy, modify, merge, publish, distribute, sublicense, - * and/or sell copies of the Software, and to permit persons to whom the - * Software is furnished to do so, subject to the following conditions: - * - * The above copyright notice and this permission notice shall be included - * in all copies or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS - * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL - * BRIAN PAUL BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN - * AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN - * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. - */ - - - -#ifndef CLIP_H -#define CLIP_H - -#include "glheader.h" - -struct gl_context; - -extern void -_mesa_update_clip_plane(struct gl_context *ctx, GLuint plane); - -extern void GLAPIENTRY -_mesa_ClipPlane( GLenum plane, const GLdouble *equation ); - -extern void GLAPIENTRY -_mesa_GetClipPlane( GLenum plane, GLdouble *equation ); - -#endif diff --git a/dll/opengl/mesa/main/colormac.h b/dll/opengl/mesa/main/colormac.h deleted file mode 100644 index 4294f323991..00000000000 --- a/dll/opengl/mesa/main/colormac.h +++ /dev/null @@ -1,125 +0,0 @@ -/* - * Mesa 3-D graphics library - * Version: 7.3 - * - * Copyright (C) 1999-2008 Brian Paul All Rights Reserved. - * - * Permission is hereby granted, free of charge, to any person obtaining a - * copy of this software and associated documentation files (the "Software"), - * to deal in the Software without restriction, including without limitation - * the rights to use, copy, modify, merge, publish, distribute, sublicense, - * and/or sell copies of the Software, and to permit persons to whom the - * Software is furnished to do so, subject to the following conditions: - * - * The above copyright notice and this permission notice shall be included - * in all copies or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS - * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL - * BRIAN PAUL BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN - * AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN - * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. - */ - - -/** - * \file colormac.h - * Color-related macros - */ - - -#ifndef COLORMAC_H -#define COLORMAC_H - - -#include "config.h" -#include "macros.h" -#include "mtypes.h" - - -/** - * Convert four float values in [0,1] to ubytes in [0,255] with clamping. - */ -static inline void -_mesa_unclamped_float_rgba_to_ubyte(GLubyte dst[4], const GLfloat src[4]) -{ - int i; - for (i = 0; i < 4; i++) - UNCLAMPED_FLOAT_TO_UBYTE(dst[i], src[i]); -} - - -/** - * \name Generic color packing macros. All inputs should be GLubytes. - * - * \todo We may move these into texstore.h at some point. - */ -/*@{*/ - -#define PACK_COLOR_8888( X, Y, Z, W ) \ - (((X) << 24) | ((Y) << 16) | ((Z) << 8) | (W)) - -#define PACK_COLOR_8888_REV( X, Y, Z, W ) \ - (((W) << 24) | ((Z) << 16) | ((Y) << 8) | (X)) - -#define PACK_COLOR_888( X, Y, Z ) \ - (((X) << 16) | ((Y) << 8) | (Z)) - -#define PACK_COLOR_565( X, Y, Z ) \ - ((((X) & 0xf8) << 8) | (((Y) & 0xfc) << 3) | (((Z) & 0xf8) >> 3)) - -#define PACK_COLOR_565_REV( X, Y, Z ) \ - (((X) & 0xf8) | ((Y) & 0xe0) >> 5 | (((Y) & 0x1c) << 11) | (((Z) & 0xf8) << 5)) - -#define PACK_COLOR_5551( R, G, B, A ) \ - ((((R) & 0xf8) << 8) | (((G) & 0xf8) << 3) | (((B) & 0xf8) >> 2) | \ - ((A) >> 7)) - -#define PACK_COLOR_1555( A, B, G, R ) \ - ((((B) & 0xf8) << 7) | (((G) & 0xf8) << 2) | (((R) & 0xf8) >> 3) | \ - (((A) & 0x80) << 8)) - -#define PACK_COLOR_1555_REV( A, B, G, R ) \ - ((((B) & 0xf8) >> 1) | (((G) & 0xc0) >> 6) | (((G) & 0x38) << 10) | (((R) & 0xf8) << 5) | \ - ((A) ? 0x80 : 0)) - -#define PACK_COLOR_2101010_UB( A, B, G, R ) \ - (((B) << 22) | ((G) << 12) | ((R) << 2) | \ - (((A) & 0xc0) << 24)) - -#define PACK_COLOR_2101010_US( A, B, G, R ) \ - ((((B) >> 6) << 20) | (((G) >> 6) << 10) | ((R) >> 6) | \ - (((A) >> 14) << 30)) - -#define PACK_COLOR_4444( R, G, B, A ) \ - ((((R) & 0xf0) << 8) | (((G) & 0xf0) << 4) | ((B) & 0xf0) | ((A) >> 4)) - -#define PACK_COLOR_4444_REV( R, G, B, A ) \ - ((((B) & 0xf0) << 8) | (((A) & 0xf0) << 4) | ((R) & 0xf0) | ((G) >> 4)) - -#define PACK_COLOR_44( L, A ) \ - (((L) & 0xf0) | (((A) & 0xf0) >> 4)) - -#define PACK_COLOR_88( L, A ) \ - (((L) << 8) | (A)) - -#define PACK_COLOR_88_REV( L, A ) \ - (((A) << 8) | (L)) - -#define PACK_COLOR_1616( L, A ) \ - (((L) << 16) | (A)) - -#define PACK_COLOR_1616_REV( L, A ) \ - (((A) << 16) | (L)) - -#define PACK_COLOR_332( R, G, B ) \ - (((R) & 0xe0) | (((G) & 0xe0) >> 3) | (((B) & 0xc0) >> 6)) - -#define PACK_COLOR_233( B, G, R ) \ - (((B) & 0xc0) | (((G) & 0xe0) >> 2) | (((R) & 0xe0) >> 5)) - -/*@}*/ - - -#endif /* COLORMAC_H */ diff --git a/dll/opengl/mesa/main/compiler.h b/dll/opengl/mesa/main/compiler.h deleted file mode 100644 index 25d9810538a..00000000000 --- a/dll/opengl/mesa/main/compiler.h +++ /dev/null @@ -1,506 +0,0 @@ -/* - * Mesa 3-D graphics library - * Version: 7.5 - * - * Copyright (C) 1999-2008 Brian Paul All Rights Reserved. - * Copyright (C) 2009 VMware, Inc. All Rights Reserved. - * - * Permission is hereby granted, free of charge, to any person obtaining a - * copy of this software and associated documentation files (the "Software"), - * to deal in the Software without restriction, including without limitation - * the rights to use, copy, modify, merge, publish, distribute, sublicense, - * and/or sell copies of the Software, and to permit persons to whom the - * Software is furnished to do so, subject to the following conditions: - * - * The above copyright notice and this permission notice shall be included - * in all copies or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS - * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL - * BRIAN PAUL BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN - * AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN - * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. - */ - - -/** - * \file compiler.h - * Compiler-related stuff. - */ - - -#ifndef COMPILER_H -#define COMPILER_H - - -#include -#include -#if defined(__alpha__) && defined(CCPML) -#include /* use Compaq's Fast Math Library on Alpha */ -#else -#include -#endif -#include -#include -#include -#include -#include -#include - - -#ifdef __cplusplus -extern "C" { -#endif - - -/** - * Get standard integer types - */ -#include - - -/** - * Sun compilers define __i386 instead of the gcc-style __i386__ - */ -#ifdef __SUNPRO_C -# if !defined(__i386__) && defined(__i386) -# define __i386__ -# elif !defined(__amd64__) && defined(__amd64) -# define __amd64__ -# elif !defined(__sparc__) && defined(__sparc) -# define __sparc__ -# endif -# if !defined(__volatile) -# define __volatile volatile -# endif -#endif - - -/** - * finite macro. - */ -#if defined(_MSC_VER) -# define finite _finite -#elif defined(__WATCOMC__) -# define finite _finite -#endif - - -/** - * Disable assorted warnings - */ -#if !defined(OPENSTEP) && (defined(__WIN32__) && !defined(__CYGWIN__)) && !defined(BUILD_FOR_SNAP) -# if !defined(__GNUC__) /* mingw environment */ -# pragma warning( disable : 4068 ) /* unknown pragma */ -# pragma warning( disable : 4710 ) /* function 'foo' not inlined */ -# pragma warning( disable : 4711 ) /* function 'foo' selected for automatic inline expansion */ -# pragma warning( disable : 4127 ) /* conditional expression is constant */ -# if defined(MESA_MINWARN) -# pragma warning( disable : 4244 ) /* '=' : conversion from 'const double ' to 'float ', possible loss of data */ -# pragma warning( disable : 4018 ) /* '<' : signed/unsigned mismatch */ -# pragma warning( disable : 4305 ) /* '=' : truncation from 'const double ' to 'float ' */ -# pragma warning( disable : 4550 ) /* 'function' undefined; assuming extern returning int */ -# pragma warning( disable : 4761 ) /* integral size mismatch in argument; conversion supplied */ -# endif -# endif -#endif -#if defined(__WATCOMC__) -# pragma disable_message(201) /* Disable unreachable code warnings */ -#endif - - - -/** - * Function inlining - */ -#ifndef inline -# ifdef __cplusplus - /* C++ supports inline keyword */ -# elif defined(__GNUC__) -# define inline __inline__ -# elif defined(_MSC_VER) -# define inline __inline -# elif defined(__ICL) -# define inline __inline -# elif defined(__INTEL_COMPILER) - /* Intel compiler supports inline keyword */ -# elif defined(__WATCOMC__) && (__WATCOMC__ >= 1100) -# define inline __inline -# elif defined(__SUNPRO_C) && defined(__C99FEATURES__) - /* C99 supports inline keyword */ -# elif (__STDC_VERSION__ >= 199901L) - /* C99 supports inline keyword */ -# else -# define inline -# endif -#endif -#ifndef INLINE -# define INLINE inline -#endif - - -/** - * PUBLIC/USED macros - * - * If we build the library with gcc's -fvisibility=hidden flag, we'll - * use the PUBLIC macro to mark functions that are to be exported. - * - * We also need to define a USED attribute, so the optimizer doesn't - * inline a static function that we later use in an alias. - ajax - */ -#ifndef PUBLIC -# if (defined(__GNUC__) && __GNUC__ >= 4) || (defined(__SUNPRO_C) && (__SUNPRO_C >= 0x590)) -# define PUBLIC __attribute__((visibility("default"))) -# define USED __attribute__((used)) -# else -# define PUBLIC -# define USED -# endif -#endif - - -/** - * Some compilers don't like some of Mesa's const usage. In those places use - * CONST instead of const. Pass -DNO_CONST to compilers where this matters. - */ -#ifdef NO_CONST -# define CONST -#else -# define CONST const -#endif - - -/** - * __builtin_expect macros - */ -#if !defined(__GNUC__) -# define __builtin_expect(x, y) (x) -#endif - -#ifndef likely -# ifdef __GNUC__ -# define likely(x) __builtin_expect(!!(x), 1) -# define unlikely(x) __builtin_expect(!!(x), 0) -# else -# define likely(x) (x) -# define unlikely(x) (x) -# endif -#endif - -/** - * The __FUNCTION__ gcc variable is generally only used for debugging. - * If we're not using gcc, define __FUNCTION__ as a cpp symbol here. - * Don't define it if using a newer Windows compiler. - */ -#ifndef __FUNCTION__ -# if defined(__VMS) -# define __FUNCTION__ "VMS$NL:" -# elif !defined(__GNUC__) && !defined(__xlC__) && \ - (!defined(_MSC_VER) || _MSC_VER < 1300) -# if (__STDC_VERSION__ >= 199901L) /* C99 */ || \ - (defined(__SUNPRO_C) && defined(__C99FEATURES__)) -# define __FUNCTION__ __func__ -# else -# define __FUNCTION__ "" -# endif -# endif -#endif -#ifndef __func__ -# if (__STDC_VERSION__ >= 199901L) || \ - (defined(__SUNPRO_C) && defined(__C99FEATURES__)) - /* __func__ is part of C99 */ -# elif defined(_MSC_VER) -# if _MSC_VER >= 1300 -# define __func__ __FUNCTION__ -# else -# define __func__ "" -# endif -# endif -#endif - - -/** - * Either define MESA_BIG_ENDIAN or MESA_LITTLE_ENDIAN, and CPU_TO_LE32. - * Do not use these unless absolutely necessary! - * Try to use a runtime test instead. - * For now, only used by some DRI hardware drivers for color/texel packing. - */ -#if defined(BYTE_ORDER) && defined(BIG_ENDIAN) && BYTE_ORDER == BIG_ENDIAN -#if defined(__linux__) -#include -#define CPU_TO_LE32( x ) bswap_32( x ) -#elif defined(__APPLE__) -#include -#define CPU_TO_LE32( x ) CFSwapInt32HostToLittle( x ) -#elif (defined(_AIX) || defined(__blrts)) -static INLINE GLuint CPU_TO_LE32(GLuint x) -{ - return (((x & 0x000000ff) << 24) | - ((x & 0x0000ff00) << 8) | - ((x & 0x00ff0000) >> 8) | - ((x & 0xff000000) >> 24)); -} -#else /*__linux__ */ -#include -#define CPU_TO_LE32( x ) bswap32( x ) -#endif /*__linux__*/ -#define MESA_BIG_ENDIAN 1 -#else -#define CPU_TO_LE32( x ) ( x ) -#define MESA_LITTLE_ENDIAN 1 -#endif -#define LE32_TO_CPU( x ) CPU_TO_LE32( x ) - - - -#if !defined(CAPI) && defined(WIN32) && !defined(BUILD_FOR_SNAP) -#define CAPI _cdecl -#endif - - -/** - * Create a macro so that asm functions can be linked into compilers other - * than GNU C - */ -#ifndef _ASMAPI -#if defined(WIN32) && !defined(BUILD_FOR_SNAP)/* was: !defined( __GNUC__ ) && !defined( VMS ) && !defined( __INTEL_COMPILER )*/ -#define _ASMAPI __cdecl -#else -#define _ASMAPI -#endif -#ifdef PTR_DECL_IN_FRONT -#define _ASMAPIP * _ASMAPI -#else -#define _ASMAPIP _ASMAPI * -#endif -#endif - -#ifdef USE_X86_ASM -#define _NORMAPI _ASMAPI -#define _NORMAPIP _ASMAPIP -#else -#define _NORMAPI -#define _NORMAPIP * -#endif - - -/* This is a macro on IRIX */ -#ifdef _P -#undef _P -#endif - - -/* Turn off macro checking systems used by other libraries */ -#ifdef CHECK -#undef CHECK -#endif - - -/** - * ASSERT macro - */ -#if !defined(_WIN32_WCE) -#if defined(BUILD_FOR_SNAP) && defined(CHECKED) -# define ASSERT(X) _CHECK(X) -#elif defined(DEBUG) -# define ASSERT(X) assert(X) -#else -# define ASSERT(X) -#endif -#endif - - -/** - * Static (compile-time) assertion. - * Basically, use COND to dimension an array. If COND is false/zero the - * array size will be -1 and we'll get a compilation error. - */ -#define STATIC_ASSERT(COND) \ - do { \ - typedef int static_assertion_failed[(!!(COND))*2-1]; \ - } while (0) - - -#if (__GNUC__ >= 3) -#define PRINTFLIKE(f, a) __attribute__ ((format(__printf__, f, a))) -#else -#define PRINTFLIKE(f, a) -#endif - -#ifndef NULL -#define NULL 0 -#endif - - -/** - * LONGSTRING macro - * gcc -pedantic warns about long string literals, LONGSTRING silences that. - */ -#if !defined(__GNUC__) -# define LONGSTRING -#else -# define LONGSTRING __extension__ -#endif - - -#ifndef M_PI -#define M_PI (3.14159265358979323846) -#endif - -#ifndef M_E -#define M_E (2.7182818284590452354) -#endif - -#ifndef M_LOG2E -#define M_LOG2E (1.4426950408889634074) -#endif - -#ifndef ONE_DIV_SQRT_LN2 -#define ONE_DIV_SQRT_LN2 (1.201122408786449815) -#endif - -#ifndef FLT_MAX_EXP -#define FLT_MAX_EXP 128 -#endif - - -/** - * USE_IEEE: Determine if we're using IEEE floating point - */ -#if defined(__i386__) || defined(__386__) || defined(__sparc__) || \ - defined(__s390x__) || defined(__powerpc__) || \ - defined(__x86_64__) || \ - defined(ia64) || defined(__ia64__) || \ - defined(__hppa__) || defined(hpux) || \ - defined(__mips) || defined(_MIPS_ARCH) || \ - defined(__arm__) || \ - defined(__sh__) || defined(__m32r__) || \ - (defined(__sun) && defined(_IEEE_754)) || \ - (defined(__alpha__) && (defined(__IEEE_FLOAT) || !defined(VMS))) -#define USE_IEEE -#define IEEE_ONE 0x3f800000 -#endif - - -/** - * START/END_FAST_MATH macros: - * - * START_FAST_MATH: Set x86 FPU to faster, 32-bit precision mode (and save - * original mode to a temporary). - * END_FAST_MATH: Restore x86 FPU to original mode. - */ -#if defined(__GNUC__) && defined(__i386__) -/* - * Set the x86 FPU control word to guarentee only 32 bits of precision - * are stored in registers. Allowing the FPU to store more introduces - * differences between situations where numbers are pulled out of memory - * vs. situations where the compiler is able to optimize register usage. - * - * In the worst case, we force the compiler to use a memory access to - * truncate the float, by specifying the 'volatile' keyword. - */ -/* Hardware default: All exceptions masked, extended double precision, - * round to nearest (IEEE compliant): - */ -#define DEFAULT_X86_FPU 0x037f -/* All exceptions masked, single precision, round to nearest: - */ -#define FAST_X86_FPU 0x003f -/* The fldcw instruction will cause any pending FP exceptions to be - * raised prior to entering the block, and we clear any pending - * exceptions before exiting the block. Hence, asm code has free - * reign over the FPU while in the fast math block. - */ -#if defined(NO_FAST_MATH) -#define START_FAST_MATH(x) \ -do { \ - static GLuint mask = DEFAULT_X86_FPU; \ - __asm__ ( "fnstcw %0" : "=m" (*&(x)) ); \ - __asm__ ( "fldcw %0" : : "m" (mask) ); \ -} while (0) -#else -#define START_FAST_MATH(x) \ -do { \ - static GLuint mask = FAST_X86_FPU; \ - __asm__ ( "fnstcw %0" : "=m" (*&(x)) ); \ - __asm__ ( "fldcw %0" : : "m" (mask) ); \ -} while (0) -#endif -/* Restore original FPU mode, and clear any exceptions that may have - * occurred in the FAST_MATH block. - */ -#define END_FAST_MATH(x) \ -do { \ - __asm__ ( "fnclex ; fldcw %0" : : "m" (*&(x)) ); \ -} while (0) - -#elif defined(__WATCOMC__) && defined(__386__) -#define DEFAULT_X86_FPU 0x037f /* See GCC comments above */ -#define FAST_X86_FPU 0x003f /* See GCC comments above */ -void _watcom_start_fast_math(unsigned short *x,unsigned short *mask); -#pragma aux _watcom_start_fast_math = \ - "fnstcw word ptr [eax]" \ - "fldcw word ptr [ecx]" \ - parm [eax] [ecx] \ - modify exact []; -void _watcom_end_fast_math(unsigned short *x); -#pragma aux _watcom_end_fast_math = \ - "fnclex" \ - "fldcw word ptr [eax]" \ - parm [eax] \ - modify exact []; -#if defined(NO_FAST_MATH) -#define START_FAST_MATH(x) \ -do { \ - static GLushort mask = DEFAULT_X86_FPU; \ - _watcom_start_fast_math(&x,&mask); \ -} while (0) -#else -#define START_FAST_MATH(x) \ -do { \ - static GLushort mask = FAST_X86_FPU; \ - _watcom_start_fast_math(&x,&mask); \ -} while (0) -#endif -#define END_FAST_MATH(x) _watcom_end_fast_math(&x) - -#elif defined(_MSC_VER) && defined(_M_IX86) -#define DEFAULT_X86_FPU 0x037f /* See GCC comments above */ -#define FAST_X86_FPU 0x003f /* See GCC comments above */ -#if defined(NO_FAST_MATH) -#define START_FAST_MATH(x) do {\ - static GLuint mask = DEFAULT_X86_FPU;\ - __asm fnstcw word ptr [x]\ - __asm fldcw word ptr [mask]\ -} while(0) -#else -#define START_FAST_MATH(x) do {\ - static GLuint mask = FAST_X86_FPU;\ - __asm fnstcw word ptr [x]\ - __asm fldcw word ptr [mask]\ -} while(0) -#endif -#define END_FAST_MATH(x) do {\ - __asm fnclex\ - __asm fldcw word ptr [x]\ -} while(0) - -#else -#define START_FAST_MATH(x) x = 0 -#define END_FAST_MATH(x) (void)(x) -#endif - - -#ifndef Elements -#define Elements(x) (sizeof(x)/sizeof(*(x))) -#endif - - - -#ifdef __cplusplus -} -#endif - - -#endif /* COMPILER_H */ diff --git a/dll/opengl/mesa/main/config.h b/dll/opengl/mesa/main/config.h deleted file mode 100644 index 4f5f18ecf39..00000000000 --- a/dll/opengl/mesa/main/config.h +++ /dev/null @@ -1,228 +0,0 @@ -/* - * Mesa 3-D graphics library - * Version: 7.5 - * - * Copyright (C) 1999-2007 Brian Paul All Rights Reserved. - * Copyright (C) 2008 VMware, Inc. All Rights Reserved. - * - * Permission is hereby granted, free of charge, to any person obtaining a - * copy of this software and associated documentation files (the "Software"), - * to deal in the Software without restriction, including without limitation - * the rights to use, copy, modify, merge, publish, distribute, sublicense, - * and/or sell copies of the Software, and to permit persons to whom the - * Software is furnished to do so, subject to the following conditions: - * - * The above copyright notice and this permission notice shall be included - * in all copies or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS - * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL - * BRIAN PAUL BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN - * AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN - * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. - */ - -/** - * \file config.h - * Tunable configuration parameters. - */ - -#ifndef MESA_CONFIG_H_INCLUDED -#define MESA_CONFIG_H_INCLUDED - - -/** - * \name OpenGL implementation limits - */ -/*@{*/ - -/** Maximum modelview matrix stack depth */ -#define MAX_MODELVIEW_STACK_DEPTH 32 - -/** Maximum projection matrix stack depth */ -#define MAX_PROJECTION_STACK_DEPTH 32 - -/** Maximum texture matrix stack depth */ -#define MAX_TEXTURE_STACK_DEPTH 10 - -/** Maximum color matrix stack depth */ -#define MAX_COLOR_STACK_DEPTH 4 - -/** Maximum attribute stack depth */ -#define MAX_ATTRIB_STACK_DEPTH 16 - -/** Maximum client attribute stack depth */ -#define MAX_CLIENT_ATTRIB_STACK_DEPTH 16 - -/** Maximum recursion depth of display list calls */ -#define MAX_LIST_NESTING 64 - -/** Maximum number of lights */ -#define MAX_LIGHTS 8 - -/** - * Maximum number of user-defined clipping planes supported by any driver in - * Mesa. This is used to size arrays. - */ -#define MAX_CLIP_PLANES 8 - -/** Maximum pixel map lookup table size */ -#define MAX_PIXEL_MAP_TABLE 256 - -/** Maximum number of auxillary color buffers */ -#define MAX_AUX_BUFFERS 1 - -/** Maximum order (degree) of curves */ -#ifdef AMIGA -# define MAX_EVAL_ORDER 12 -#else -# define MAX_EVAL_ORDER 30 -#endif - -/** Maximum Name stack depth */ -#define MAX_NAME_STACK_DEPTH 64 - -/** Minimum point size */ -#define MIN_POINT_SIZE 1.0 -/** Maximum point size */ -#define MAX_POINT_SIZE 60.0 -/** Point size granularity */ -#define POINT_SIZE_GRANULARITY 0.1 - -/** Minimum line width */ -#define MIN_LINE_WIDTH 1.0 -/** Maximum line width */ -#define MAX_LINE_WIDTH 10.0 -/** Line width granularity */ -#define LINE_WIDTH_GRANULARITY 0.1 - -/** Max memory to allow for a single texture image (in megabytes) */ -#define MAX_TEXTURE_MBYTES 1024 - -/** Number of 1D/2D texture mipmap levels */ -#define MAX_TEXTURE_LEVELS 15 - -/** Number of 3D texture mipmap levels */ -#define MAX_3D_TEXTURE_LEVELS 15 - -/** Number of cube texture mipmap levels - GL_ARB_texture_cube_map */ -#define MAX_CUBE_TEXTURE_LEVELS 15 - - -/** - * Maximum viewport/image width. Must accomodate all texture sizes too. - */ - -#ifndef MAX_WIDTH -# define MAX_WIDTH 16384 -#endif -/** Maximum viewport/image height */ -#ifndef MAX_HEIGHT -# define MAX_HEIGHT 16384 -#endif - -/* XXX: hack to prevent stack overflow on windows until all temporary arrays - * [MAX_WIDTH] are allocated from the heap */ -#ifdef WIN32 -#undef MAX_TEXTURE_LEVELS -#undef MAX_3D_TEXTURE_LEVELS -#undef MAX_CUBE_TEXTURE_LEVELS -#undef MAX_TEXTURE_RECT_SIZE -#undef MAX_WIDTH -#undef MAX_HEIGHT -#define MAX_TEXTURE_LEVELS 13 -#define MAX_CUBE_TEXTURE_LEVELS 13 -#define MAX_WIDTH 4096 -#define MAX_HEIGHT 4096 -#endif - -/** Maxmimum size for CVA. May be overridden by the drivers. */ -#define MAX_ARRAY_LOCK_SIZE 3000 - -/** Subpixel precision for antialiasing, window coordinate snapping */ -#define SUB_PIXEL_BITS 4 - -/** Size of histogram tables */ -#define HISTOGRAM_TABLE_SIZE 256 - -/** Max convolution filter width */ -#define MAX_CONVOLUTION_WIDTH 9 -/** Max convolution filter height */ -#define MAX_CONVOLUTION_HEIGHT 9 - -/** For GL_EXT_texture_filter_anisotropic */ -#define MAX_TEXTURE_MAX_ANISOTROPY 16.0 - -#define MAX_NV_VERTEX_PROGRAM_INPUTS 16 - - -/** For GL_EXT_framebuffer_object */ -/*@{*/ -#define MAX_COLOR_ATTACHMENTS 8 -/*@}*/ - -/** For GL_ATI_envmap_bump - support bump mapping on first 8 units */ -#define SUPPORTED_ATI_BUMP_UNITS 0xff - - -/** - * \name Mesa-specific parameters - */ -/*@{*/ - - -/** - * If non-zero use GLdouble for walking triangle edges, for better accuracy. - */ -#define TRIANGLE_WALK_DOUBLE 0 - - -/** - * Bits per depth buffer value (max is 32). - */ -#ifndef DEFAULT_SOFTWARE_DEPTH_BITS -#define DEFAULT_SOFTWARE_DEPTH_BITS 16 -#endif -/** Depth buffer data type */ -#if DEFAULT_SOFTWARE_DEPTH_BITS <= 16 -#define DEFAULT_SOFTWARE_DEPTH_TYPE GLushort -#else -#define DEFAULT_SOFTWARE_DEPTH_TYPE GLuint -#endif - - -/** - * Bits per stencil value: 8 - */ -#define STENCIL_BITS 8 - - -/** - * For swrast, bits per color channel: 8, 16 or 32 - */ -#ifndef CHAN_BITS -#define CHAN_BITS 8 -#endif - - -/* - * Color channel component order - * - * \note Changes will almost certainly cause problems at this time. - */ -#define RCOMP 0 -#define GCOMP 1 -#define BCOMP 2 -#define ACOMP 3 - - -/** - * Maximum number of temporary vertices required for clipping. - * - * Used in array_cache and tnl modules. - */ -#define MAX_CLIPPED_VERTICES ((2 * (6 + MAX_CLIP_PLANES))+1) - - -#endif /* MESA_CONFIG_H_INCLUDED */ diff --git a/dll/opengl/mesa/main/context.c b/dll/opengl/mesa/main/context.c deleted file mode 100644 index 8c4056fcc74..00000000000 --- a/dll/opengl/mesa/main/context.c +++ /dev/null @@ -1,1321 +0,0 @@ -/* - * Mesa 3-D graphics library - * Version: 7.3 - * - * Copyright (C) 1999-2007 Brian Paul All Rights Reserved. - * Copyright (C) 2008 VMware, Inc. All Rights Reserved. - * - * Permission is hereby granted, free of charge, to any person obtaining a - * copy of this software and associated documentation files (the "Software"), - * to deal in the Software without restriction, including without limitation - * the rights to use, copy, modify, merge, publish, distribute, sublicense, - * and/or sell copies of the Software, and to permit persons to whom the - * Software is furnished to do so, subject to the following conditions: - * - * The above copyright notice and this permission notice shall be included - * in all copies or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS - * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL - * BRIAN PAUL BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN - * AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN - * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. - */ - -/** - * \file context.c - * Mesa context/visual/framebuffer management functions. - * \author Brian Paul - */ - -/** - * \mainpage Mesa Main Module - * - * \section MainIntroduction Introduction - * - * The Mesa Main module consists of all the files in the main/ directory. - * Among the features of this module are: - *
    - *
  • Structures to represent most GL state
  • - *
  • State set/get functions
  • - *
  • Display lists
  • - *
  • Texture unit, object and image handling
  • - *
  • Matrix and attribute stacks
  • - *
- * - * Other modules are responsible for API dispatch, vertex transformation, - * point/line/triangle setup, rasterization, vertex array caching, - * vertex/fragment programs/shaders, etc. - * - * - * \section AboutDoxygen About Doxygen - * - * If you're viewing this information as Doxygen-generated HTML you'll - * see the documentation index at the top of this page. - * - * The first line lists the Mesa source code modules. - * The second line lists the indexes available for viewing the documentation - * for each module. - * - * Selecting the Main page link will display a summary of the module - * (this page). - * - * Selecting Data Structures will list all C structures. - * - * Selecting the File List link will list all the source files in - * the module. - * Selecting a filename will show a list of all functions defined in that file. - * - * Selecting the Data Fields link will display a list of all - * documented structure members. - * - * Selecting the Globals link will display a list - * of all functions, structures, global variables and macros in the module. - * - */ - -#include - -#ifdef USE_SPARC_ASM -#include "sparc/sparc.h" -#endif - - -#ifndef MESA_VERBOSE -int MESA_VERBOSE = 0; -#endif - -#ifndef MESA_DEBUG_FLAGS -int MESA_DEBUG_FLAGS = 0; -#endif - - -/* ubyte -> float conversion */ -GLfloat _mesa_ubyte_to_float_color_tab[256]; - - - -/** - * Swap buffers notification callback. - * - * \param ctx GL context. - * - * Called by window system just before swapping buffers. - * We have to finish any pending rendering. - */ -void -_mesa_notifySwapBuffers(struct gl_context *ctx) -{ - if (MESA_VERBOSE & VERBOSE_SWAPBUFFERS) - _mesa_debug(ctx, "SwapBuffers\n"); - FLUSH_CURRENT( ctx, 0 ); - if (ctx->Driver.Flush) { - ctx->Driver.Flush(ctx); - } -} - - -/**********************************************************************/ -/** \name GL Visual allocation/destruction */ -/**********************************************************************/ -/*@{*/ - -/** - * Allocates a struct gl_config structure and initializes it via - * _mesa_initialize_visual(). - * - * \param dbFlag double buffering - * \param stereoFlag stereo buffer - * \param depthBits requested bits per depth buffer value. Any value in [0, 32] - * is acceptable but the actual depth type will be GLushort or GLuint as - * needed. - * \param stencilBits requested minimum bits per stencil buffer value - * \param accumRedBits, accumGreenBits, accumBlueBits, accumAlphaBits number - * of bits per color component in accum buffer. - * \param indexBits number of bits per pixel if \p rgbFlag is GL_FALSE - * \param redBits number of bits per color component in frame buffer for RGB(A) - * mode. We always use 8 in core Mesa though. - * \param greenBits same as above. - * \param blueBits same as above. - * \param alphaBits same as above. - * - * \return pointer to new struct gl_config or NULL if requested parameters - * can't be met. - * - * \note Need to add params for level and numAuxBuffers (at least) - */ -struct gl_config * -_mesa_create_visual( GLboolean dbFlag, - GLboolean stereoFlag, - GLint redBits, - GLint greenBits, - GLint blueBits, - GLint alphaBits, - GLint depthBits, - GLint stencilBits, - GLint accumRedBits, - GLint accumGreenBits, - GLint accumBlueBits, - GLint accumAlphaBits) -{ - struct gl_config *vis = CALLOC_STRUCT(gl_config); - if (vis) { - if (!_mesa_initialize_visual(vis, dbFlag, stereoFlag, - redBits, greenBits, blueBits, alphaBits, - depthBits, stencilBits, - accumRedBits, accumGreenBits, - accumBlueBits, accumAlphaBits)) { - free(vis); - return NULL; - } - } - return vis; -} - - -/** - * Makes some sanity checks and fills in the fields of the struct - * gl_config object with the given parameters. If the caller needs to - * set additional fields, he should just probably init the whole - * gl_config object himself. - * - * \return GL_TRUE on success, or GL_FALSE on failure. - * - * \sa _mesa_create_visual() above for the parameter description. - */ -GLboolean -_mesa_initialize_visual( struct gl_config *vis, - GLboolean dbFlag, - GLboolean stereoFlag, - GLint redBits, - GLint greenBits, - GLint blueBits, - GLint alphaBits, - GLint depthBits, - GLint stencilBits, - GLint accumRedBits, - GLint accumGreenBits, - GLint accumBlueBits, - GLint accumAlphaBits) -{ - assert(vis); - - if (depthBits < 0 || depthBits > 32) { - return GL_FALSE; - } - if (stencilBits < 0 || stencilBits > STENCIL_BITS) { - return GL_FALSE; - } - assert(accumRedBits >= 0); - assert(accumGreenBits >= 0); - assert(accumBlueBits >= 0); - assert(accumAlphaBits >= 0); - - vis->rgbMode = GL_TRUE; - vis->doubleBufferMode = dbFlag; - vis->stereoMode = stereoFlag; - - vis->redBits = redBits; - vis->greenBits = greenBits; - vis->blueBits = blueBits; - vis->alphaBits = alphaBits; - vis->rgbBits = redBits + greenBits + blueBits; - - vis->indexBits = 0; - vis->depthBits = depthBits; - vis->stencilBits = stencilBits; - - vis->accumRedBits = accumRedBits; - vis->accumGreenBits = accumGreenBits; - vis->accumBlueBits = accumBlueBits; - vis->accumAlphaBits = accumAlphaBits; - - vis->haveAccumBuffer = accumRedBits > 0; - vis->haveDepthBuffer = depthBits > 0; - vis->haveStencilBuffer = stencilBits > 0; - - vis->numAuxBuffers = 0; - vis->level = 0; - - return GL_TRUE; -} - - -/** - * Destroy a visual and free its memory. - * - * \param vis visual. - * - * Frees the visual structure. - */ -void -_mesa_destroy_visual( struct gl_config *vis ) -{ - free(vis); -} - -/*@}*/ - - -/**********************************************************************/ -/** \name Context allocation, initialization, destroying - * - * The purpose of the most initialization functions here is to provide the - * default state values according to the OpenGL specification. - */ -/**********************************************************************/ -/*@{*/ - - -/** - * This is lame. gdb only seems to recognize enum types that are - * actually used somewhere. We want to be able to print/use enum - * values such as TEXTURE_2D_INDEX in gdb. But we don't actually use - * the gl_texture_index type anywhere. Thus, this lame function. - */ -static void -dummy_enum_func(void) -{ - gl_buffer_index bi = BUFFER_FRONT_LEFT; - gl_face_index fi = FACE_POS_X; - gl_frag_attrib fa = FRAG_ATTRIB_WPOS; - gl_vert_attrib va = VERT_ATTRIB_POS; - - (void) bi; - (void) fi; - (void) fa; - (void) va; -} - - -/** - * One-time initialization mutex lock. - * - * \sa Used by one_time_init(). - */ -_glthread_DECLARE_STATIC_MUTEX(OneTimeLock); - - - -/** - * Calls all the various one-time-init functions in Mesa. - * - * While holding a global mutex lock, calls several initialization functions, - * and sets the glapi callbacks if the \c MESA_DEBUG environment variable is - * defined. - * - * \sa _math_init(). - */ -static void -one_time_init( struct gl_context *ctx ) -{ - static GLboolean api_init = GL_FALSE; - - _glthread_LOCK_MUTEX(OneTimeLock); - - /* truly one-time init */ - if (!api_init) { - GLuint i; - - /* do some implementation tests */ - assert( sizeof(GLbyte) == 1 ); - assert( sizeof(GLubyte) == 1 ); - assert( sizeof(GLshort) == 2 ); - assert( sizeof(GLushort) == 2 ); - assert( sizeof(GLint) == 4 ); - assert( sizeof(GLuint) == 4 ); - - _mesa_get_cpu_features(); - - _mesa_init_sqrt_table(); - - /* context dependence is never a one-time thing... */ - _mesa_init_get_hash(ctx); - - for (i = 0; i < 256; i++) { - _mesa_ubyte_to_float_color_tab[i] = (float) i / 255.0F; - } - -#if defined(DEBUG) && defined(__DATE__) && defined(__TIME__) - if (MESA_VERBOSE != 0) { - _mesa_debug(ctx, "Mesa %s DEBUG build %s %s\n", - MESA_VERSION_STRING, __DATE__, __TIME__); - } -#endif - -#ifdef DEBUG - _mesa_test_formats(); -#endif - } - - api_init = GL_TRUE; - - _glthread_UNLOCK_MUTEX(OneTimeLock); - - dummy_enum_func(); -} - - -/** - * Initialize fields of gl_current_attrib (aka ctx->Current.*) - */ -static void -_mesa_init_current(struct gl_context *ctx) -{ - GLuint i; - - /* Init all to (0,0,0,1) */ - for (i = 0; i < Elements(ctx->Current.Attrib); i++) { - ASSIGN_4V( ctx->Current.Attrib[i], 0.0, 0.0, 0.0, 1.0 ); - } - - /* redo special cases: */ - ASSIGN_4V( ctx->Current.Attrib[VERT_ATTRIB_WEIGHT], 1.0, 0.0, 0.0, 0.0 ); - ASSIGN_4V( ctx->Current.Attrib[VERT_ATTRIB_NORMAL], 0.0, 0.0, 1.0, 1.0 ); - ASSIGN_4V( ctx->Current.Attrib[VERT_ATTRIB_COLOR], 1.0, 1.0, 1.0, 1.0 ); - ASSIGN_4V( ctx->Current.Attrib[VERT_ATTRIB_COLOR_INDEX], 1.0, 0.0, 0.0, 1.0 ); - ASSIGN_4V( ctx->Current.Attrib[VERT_ATTRIB_EDGEFLAG], 1.0, 0.0, 0.0, 1.0 ); -} - -/** - * Initialize fields of gl_constants (aka ctx->Const.*). - * Use defaults from config.h. The device drivers will often override - * some of these values (such as number of texture units). - */ -static void -_mesa_init_constants(struct gl_context *ctx) -{ - assert(ctx); - - /* Constants, may be overriden (usually only reduced) by device drivers */ - ctx->Const.MaxTextureMbytes = MAX_TEXTURE_MBYTES; - ctx->Const.MaxTextureLevels = MAX_TEXTURE_LEVELS; - ctx->Const.MaxCubeTextureLevels = MAX_CUBE_TEXTURE_LEVELS; - ctx->Const.MaxTextureMaxAnisotropy = MAX_TEXTURE_MAX_ANISOTROPY; - ctx->Const.MaxArrayLockSize = MAX_ARRAY_LOCK_SIZE; - ctx->Const.SubPixelBits = SUB_PIXEL_BITS; - ctx->Const.MinPointSize = MIN_POINT_SIZE; - ctx->Const.MaxPointSize = MAX_POINT_SIZE; - ctx->Const.MinPointSizeAA = MIN_POINT_SIZE; - ctx->Const.MaxPointSizeAA = MAX_POINT_SIZE; - ctx->Const.PointSizeGranularity = (GLfloat) POINT_SIZE_GRANULARITY; - ctx->Const.MinLineWidth = MIN_LINE_WIDTH; - ctx->Const.MaxLineWidth = MAX_LINE_WIDTH; - ctx->Const.MinLineWidthAA = MIN_LINE_WIDTH; - ctx->Const.MaxLineWidthAA = MAX_LINE_WIDTH; - ctx->Const.LineWidthGranularity = (GLfloat) LINE_WIDTH_GRANULARITY; - ctx->Const.MaxClipPlanes = 6; - ctx->Const.MaxLights = MAX_LIGHTS; - ctx->Const.MaxShininess = 128.0; - ctx->Const.MaxSpotExponent = 128.0; - ctx->Const.MaxViewportWidth = MAX_WIDTH; - ctx->Const.MaxViewportHeight = MAX_HEIGHT; - - /* CheckArrayBounds is overriden by drivers/x11 for X server */ - ctx->Const.CheckArrayBounds = GL_FALSE; - - /* GL 3.2: hard-coded for now: */ - ctx->Const.ProfileMask = GL_CONTEXT_COMPATIBILITY_PROFILE_BIT; -} - - -/** - * Do some sanity checks on the limits/constants for the given context. - * Only called the first time a context is bound. - */ -static void -check_context_limits(struct gl_context *ctx) -{ - /* Texture size checks */ - assert(ctx->Const.MaxTextureLevels <= MAX_TEXTURE_LEVELS); - assert(ctx->Const.Max3DTextureLevels <= MAX_3D_TEXTURE_LEVELS); - assert(ctx->Const.MaxCubeTextureLevels <= MAX_CUBE_TEXTURE_LEVELS); - - /* make sure largest texture image is <= MAX_WIDTH in size */ - assert((1 << (ctx->Const.MaxTextureLevels - 1)) <= MAX_WIDTH); - assert((1 << (ctx->Const.MaxCubeTextureLevels - 1)) <= MAX_WIDTH); - assert((1 << (ctx->Const.Max3DTextureLevels - 1)) <= MAX_WIDTH); - - /* Texture level checks */ - assert(MAX_TEXTURE_LEVELS >= MAX_3D_TEXTURE_LEVELS); - assert(MAX_TEXTURE_LEVELS >= MAX_CUBE_TEXTURE_LEVELS); - - /* Max texture size should be <= max viewport size (render to texture) */ - assert((1 << (MAX_TEXTURE_LEVELS - 1)) <= MAX_WIDTH); - - assert(ctx->Const.MaxViewportWidth <= MAX_WIDTH); - assert(ctx->Const.MaxViewportHeight <= MAX_WIDTH); -} - - -/** - * Initialize the attribute groups in a GL context. - * - * \param ctx GL context. - * - * Initializes all the attributes, calling the respective init* - * functions for the more complex data structures. - */ -static GLboolean -init_attrib_groups(struct gl_context *ctx) -{ - assert(ctx); - - /* Constants */ - _mesa_init_constants( ctx ); - - /* Extensions */ - _mesa_init_extensions( ctx ); - - /* Attribute Groups */ - _mesa_init_accum( ctx ); - _mesa_init_attrib( ctx ); - _mesa_init_buffer_objects( ctx ); - _mesa_init_color( ctx ); - _mesa_init_current( ctx ); - _mesa_init_depth( ctx ); - _mesa_init_display_list( ctx ); - _mesa_init_eval( ctx ); - _mesa_init_feedback( ctx ); - _mesa_init_fog( ctx ); - _mesa_init_hint( ctx ); - _mesa_init_line( ctx ); - _mesa_init_lighting( ctx ); - _mesa_init_matrix( ctx ); - _mesa_init_multisample( ctx ); - _mesa_init_pixel( ctx ); - _mesa_init_pixelstore( ctx ); - _mesa_init_point( ctx ); - _mesa_init_polygon( ctx ); - _mesa_init_rastpos( ctx ); - _mesa_init_scissor( ctx ); - _mesa_init_stencil( ctx ); - _mesa_init_transform( ctx ); - _mesa_init_varray(ctx, &ctx->Array); - _mesa_init_viewport( ctx ); - - if (!_mesa_init_texture( ctx )) - return GL_FALSE; - - /* Miscellaneous */ - ctx->NewState = _NEW_ALL; - ctx->ErrorValue = (GLenum) GL_NO_ERROR; - - return GL_TRUE; -} - - -/** - * Update default objects in a GL context with respect to shared state. - * - * \param ctx GL context. - * - * Removes references to old default objects, (texture objects, program - * objects, etc.) and changes to reference those from the current shared - * state. - */ -static GLboolean -update_default_objects(struct gl_context *ctx) -{ - assert(ctx); - - _mesa_update_default_objects_texture(ctx); - _mesa_update_default_objects_buffer_objects(ctx); - - return GL_TRUE; -} - - -/** - * This is the default function we plug into all dispatch table slots - * This helps prevents a segfault when someone calls a GL function without - * first checking if the extension's supported. - */ -static int -generic_nop(void) -{ - _mesa_warning(NULL, "User called no-op dispatch function (an unsupported extension function?)"); - return 0; -} - - -/** - * Allocate and initialize a new dispatch table. - */ -struct _glapi_table * -_mesa_alloc_dispatch_table(int size) -{ - /* Find the larger of Mesa's dispatch table and libGL's dispatch table. - * In practice, this'll be the same for stand-alone Mesa. But for DRI - * Mesa we do this to accomodate different versions of libGL and various - * DRI drivers. - */ - GLint numEntries = MAX2(_glapi_get_dispatch_table_size(), _gloffset_COUNT); - struct _glapi_table *table; - - /* should never happen, but just in case */ - numEntries = MAX2(numEntries, size); - - table = (struct _glapi_table *) malloc(numEntries * sizeof(_glapi_proc)); - if (table) { - _glapi_proc *entry = (_glapi_proc *) table; - GLint i; - for (i = 0; i < numEntries; i++) { - entry[i] = (_glapi_proc) generic_nop; - } - } - return table; -} - - -/** - * Initialize a struct gl_context struct (rendering context). - * - * This includes allocating all the other structs and arrays which hang off of - * the context by pointers. - * Note that the driver needs to pass in its dd_function_table here since - * we need to at least call driverFunctions->NewTextureObject to create the - * default texture objects. - * - * Called by _mesa_create_context(). - * - * Performs the imports and exports callback tables initialization, and - * miscellaneous one-time initializations. If no shared context is supplied one - * is allocated, and increase its reference count. Setups the GL API dispatch - * tables. Initialize the TNL module. Sets the maximum Z buffer depth. - * Finally queries the \c MESA_DEBUG and \c MESA_VERBOSE environment variables - * for debug flags. - * - * \param ctx the context to initialize - * \param api the GL API type to create the context for - * \param visual describes the visual attributes for this context - * \param share_list points to context to share textures, display lists, - * etc with, or NULL - * \param driverFunctions table of device driver functions for this context - * to use - * \param driverContext pointer to driver-specific context data - */ -GLboolean -_mesa_initialize_context(struct gl_context *ctx, - const struct gl_config *visual, - struct gl_context *share_list, - const struct dd_function_table *driverFunctions, - void *driverContext) -{ - struct gl_shared_state *shared; - - /*ASSERT(driverContext);*/ - assert(driverFunctions->NewTextureObject); - assert(driverFunctions->FreeTextureImageBuffer); - - ctx->Visual = *visual; - ctx->DrawBuffer = NULL; - ctx->ReadBuffer = NULL; - ctx->WinSysDrawBuffer = NULL; - ctx->WinSysReadBuffer = NULL; - - /* misc one-time initializations */ - one_time_init(ctx); - - /* Plug in driver functions and context pointer here. - * This is important because when we call alloc_shared_state() below - * we'll call ctx->Driver.NewTextureObject() to create the default - * textures. - */ - ctx->Driver = *driverFunctions; - ctx->DriverCtx = driverContext; - - if (share_list) { - /* share state with another context */ - shared = share_list->Shared; - } - else { - /* allocate new, unshared state */ - shared = _mesa_alloc_shared_state(ctx); - if (!shared) - return GL_FALSE; - } - - _mesa_reference_shared_state(ctx, &ctx->Shared, shared); - - if (!init_attrib_groups( ctx )) { - _mesa_reference_shared_state(ctx, &ctx->Shared, NULL); - return GL_FALSE; - } - - ctx->Exec = _mesa_create_exec_table(); - - if (!ctx->Exec) { - _mesa_reference_shared_state(ctx, &ctx->Shared, NULL); - return GL_FALSE; - } - ctx->CurrentDispatch = ctx->Exec; - - /* Mesa core handles all the formats that mesa core knows about. - * Drivers will want to override this list with just the formats - * they can handle, and confirm that appropriate fallbacks exist in - * _mesa_choose_tex_format(). - */ - memset(&ctx->TextureFormatSupported, GL_TRUE, - sizeof(ctx->TextureFormatSupported)); - - ctx->Save = _mesa_create_save_table(); - if (!ctx->Save) { - _mesa_reference_shared_state(ctx, &ctx->Shared, NULL); - free(ctx->Exec); - return GL_FALSE; - } - - _mesa_install_save_vtxfmt( ctx, &ctx->ListState.ListVtxfmt ); - - ctx->FirstTimeCurrent = GL_TRUE; - - return GL_TRUE; -} - - -/** - * Allocate and initialize a struct gl_context structure. - * Note that the driver needs to pass in its dd_function_table here since - * we need to at least call driverFunctions->NewTextureObject to initialize - * the rendering context. - * - * \param api the GL API type to create the context for - * \param visual a struct gl_config pointer (we copy the struct contents) - * \param share_list another context to share display lists with or NULL - * \param driverFunctions points to the dd_function_table into which the - * driver has plugged in all its special functions. - * \param driverContext points to the device driver's private context state - * - * \return pointer to a new __struct gl_contextRec or NULL if error. - */ -struct gl_context * -_mesa_create_context(const struct gl_config *visual, - struct gl_context *share_list, - const struct dd_function_table *driverFunctions, - void *driverContext) -{ - struct gl_context *ctx; - - ASSERT(visual); - /*ASSERT(driverContext);*/ - - ctx = (struct gl_context *) calloc(1, sizeof(struct gl_context)); - if (!ctx) - return NULL; - - if (_mesa_initialize_context(ctx, visual, share_list, - driverFunctions, driverContext)) { - return ctx; - } - else { - free(ctx); - return NULL; - } -} - - -/** - * Free the data associated with the given context. - * - * But doesn't free the struct gl_context struct itself. - * - * \sa _mesa_initialize_context() and init_attrib_groups(). - */ -void -_mesa_free_context_data( struct gl_context *ctx ) -{ - if (!_mesa_get_current_context()){ - /* No current context, but we may need one in order to delete - * texture objs, etc. So temporarily bind the context now. - */ - _mesa_make_current(ctx, NULL, NULL); - } - - /* unreference WinSysDraw/Read buffers */ - _mesa_reference_framebuffer(&ctx->WinSysDrawBuffer, NULL); - _mesa_reference_framebuffer(&ctx->WinSysReadBuffer, NULL); - _mesa_reference_framebuffer(&ctx->DrawBuffer, NULL); - _mesa_reference_framebuffer(&ctx->ReadBuffer, NULL); - - _mesa_free_attrib_data(ctx); - _mesa_free_lighting_data( ctx ); - _mesa_free_eval_data( ctx ); - _mesa_free_texture_data( ctx ); - _mesa_free_matrix_data( ctx ); - _mesa_free_viewport_data( ctx ); - _mesa_free_varray_data(ctx, &ctx->Array); - - /* free dispatch tables */ - free(ctx->Exec); - free(ctx->Save); - - /* Shared context state (display lists, textures, etc) */ - _mesa_reference_shared_state(ctx, &ctx->Shared, NULL); - - /* needs to be after freeing shared state */ - _mesa_free_display_list_data(ctx); - - if (ctx->Extensions.String) - free((void *) ctx->Extensions.String); - - if (ctx->VersionString) - free(ctx->VersionString); - - /* unbind the context if it's currently bound */ - if (ctx == _mesa_get_current_context()) { - _mesa_make_current(NULL, NULL, NULL); - } -} - - -/** - * Destroy a struct gl_context structure. - * - * \param ctx GL context. - * - * Calls _mesa_free_context_data() and frees the gl_context object itself. - */ -void -_mesa_destroy_context( struct gl_context *ctx ) -{ - if (ctx) { - _mesa_free_context_data(ctx); - free( (void *) ctx ); - } -} - - -#if _HAVE_FULL_GL -/** - * Copy attribute groups from one context to another. - * - * \param src source context - * \param dst destination context - * \param mask bitwise OR of GL_*_BIT flags - * - * According to the bits specified in \p mask, copies the corresponding - * attributes from \p src into \p dst. For many of the attributes a simple \c - * memcpy is not enough due to the existence of internal pointers in their data - * structures. - */ -void -_mesa_copy_context( const struct gl_context *src, struct gl_context *dst, - GLuint mask ) -{ - if (mask & GL_ACCUM_BUFFER_BIT) { - /* OK to memcpy */ - dst->Accum = src->Accum; - } - if (mask & GL_COLOR_BUFFER_BIT) { - /* OK to memcpy */ - dst->Color = src->Color; - } - if (mask & GL_CURRENT_BIT) { - /* OK to memcpy */ - dst->Current = src->Current; - } - if (mask & GL_DEPTH_BUFFER_BIT) { - /* OK to memcpy */ - dst->Depth = src->Depth; - } - if (mask & GL_ENABLE_BIT) { - /* no op */ - } - if (mask & GL_EVAL_BIT) { - /* OK to memcpy */ - dst->Eval = src->Eval; - } - if (mask & GL_FOG_BIT) { - /* OK to memcpy */ - dst->Fog = src->Fog; - } - if (mask & GL_HINT_BIT) { - /* OK to memcpy */ - dst->Hint = src->Hint; - } - if (mask & GL_LIGHTING_BIT) { - GLuint i; - /* begin with memcpy */ - dst->Light = src->Light; - /* fixup linked lists to prevent pointer insanity */ - make_empty_list( &(dst->Light.EnabledList) ); - for (i = 0; i < MAX_LIGHTS; i++) { - if (dst->Light.Light[i].Enabled) { - insert_at_tail(&(dst->Light.EnabledList), &(dst->Light.Light[i])); - } - } - } - if (mask & GL_LINE_BIT) { - /* OK to memcpy */ - dst->Line = src->Line; - } - if (mask & GL_LIST_BIT) { - /* OK to memcpy */ - dst->List = src->List; - } - if (mask & GL_PIXEL_MODE_BIT) { - /* OK to memcpy */ - dst->Pixel = src->Pixel; - } - if (mask & GL_POINT_BIT) { - /* OK to memcpy */ - dst->Point = src->Point; - } - if (mask & GL_POLYGON_BIT) { - /* OK to memcpy */ - dst->Polygon = src->Polygon; - } - if (mask & GL_POLYGON_STIPPLE_BIT) { - /* Use loop instead of memcpy due to problem with Portland Group's - * C compiler. Reported by John Stone. - */ - GLuint i; - for (i = 0; i < 32; i++) { - dst->PolygonStipple[i] = src->PolygonStipple[i]; - } - } - if (mask & GL_SCISSOR_BIT) { - /* OK to memcpy */ - dst->Scissor = src->Scissor; - } - if (mask & GL_STENCIL_BUFFER_BIT) { - /* OK to memcpy */ - dst->Stencil = src->Stencil; - } - if (mask & GL_TEXTURE_BIT) { - /* Cannot memcpy because of pointers */ - _mesa_copy_texture_state(src, dst); - } - if (mask & GL_TRANSFORM_BIT) { - /* OK to memcpy */ - dst->Transform = src->Transform; - } - if (mask & GL_VIEWPORT_BIT) { - /* Cannot use memcpy, because of pointers in GLmatrix _WindowMap */ - dst->Viewport.X = src->Viewport.X; - dst->Viewport.Y = src->Viewport.Y; - dst->Viewport.Width = src->Viewport.Width; - dst->Viewport.Height = src->Viewport.Height; - dst->Viewport.Near = src->Viewport.Near; - dst->Viewport.Far = src->Viewport.Far; - _math_matrix_copy(&dst->Viewport._WindowMap, &src->Viewport._WindowMap); - } - - /* XXX FIXME: Call callbacks? - */ - dst->NewState = _NEW_ALL; -} -#endif - - -/** - * Check if the given context can render into the given framebuffer - * by checking visual attributes. - * - * Most of these tests could go away because Mesa is now pretty flexible - * in terms of mixing rendering contexts with framebuffers. As long - * as RGB vs. CI mode agree, we're probably good. - * - * \return GL_TRUE if compatible, GL_FALSE otherwise. - */ -static GLboolean -check_compatible(const struct gl_context *ctx, - const struct gl_framebuffer *buffer) -{ - const struct gl_config *ctxvis = &ctx->Visual; - const struct gl_config *bufvis = &buffer->Visual; - -#if 0 - /* disabling this fixes the fgl_glxgears pbuffer demo */ - if (ctxvis->doubleBufferMode && !bufvis->doubleBufferMode) - return GL_FALSE; -#endif - if (ctxvis->stereoMode && !bufvis->stereoMode) - return GL_FALSE; - if (ctxvis->haveAccumBuffer && !bufvis->haveAccumBuffer) - return GL_FALSE; - if (ctxvis->haveDepthBuffer && !bufvis->haveDepthBuffer) - return GL_FALSE; - if (ctxvis->haveStencilBuffer && !bufvis->haveStencilBuffer) - return GL_FALSE; - if (ctxvis->redMask && ctxvis->redMask != bufvis->redMask) - return GL_FALSE; - if (ctxvis->greenMask && ctxvis->greenMask != bufvis->greenMask) - return GL_FALSE; - if (ctxvis->blueMask && ctxvis->blueMask != bufvis->blueMask) - return GL_FALSE; -#if 0 - /* disabled (see bug 11161) */ - if (ctxvis->depthBits && ctxvis->depthBits != bufvis->depthBits) - return GL_FALSE; -#endif - if (ctxvis->stencilBits && ctxvis->stencilBits != bufvis->stencilBits) - return GL_FALSE; - - return GL_TRUE; -} - - -/** - * Do one-time initialization for the given framebuffer. Specifically, - * ask the driver for the window's current size and update the framebuffer - * object to match. - * Really, the device driver should totally take care of this. - */ -static void -initialize_framebuffer_size(struct gl_context *ctx, struct gl_framebuffer *fb) -{ - GLuint width, height; - if (ctx->Driver.GetBufferSize) { - ctx->Driver.GetBufferSize(fb, &width, &height); - if (ctx->Driver.ResizeBuffers) - ctx->Driver.ResizeBuffers(ctx, fb, width, height); - fb->Initialized = GL_TRUE; - } -} - - -/** - * Check if the viewport/scissor size has not yet been initialized. - * Initialize the size if the given width and height are non-zero. - */ -void -_mesa_check_init_viewport(struct gl_context *ctx, GLuint width, GLuint height) -{ - if (!ctx->ViewportInitialized && width > 0 && height > 0) { - /* Note: set flag here, before calling _mesa_set_viewport(), to prevent - * potential infinite recursion. - */ - ctx->ViewportInitialized = GL_TRUE; - _mesa_set_viewport(ctx, 0, 0, width, height); - _mesa_set_scissor(ctx, 0, 0, width, height); - } -} - - -/** - * Bind the given context to the given drawBuffer and readBuffer and - * make it the current context for the calling thread. - * We'll render into the drawBuffer and read pixels from the - * readBuffer (i.e. glRead/CopyPixels, glCopyTexImage, etc). - * - * We check that the context's and framebuffer's visuals are compatible - * and return immediately if they're not. - * - * \param newCtx the new GL context. If NULL then there will be no current GL - * context. - * \param drawBuffer the drawing framebuffer - * \param readBuffer the reading framebuffer - */ -GLboolean -_mesa_make_current( struct gl_context *newCtx, - struct gl_framebuffer *drawBuffer, - struct gl_framebuffer *readBuffer ) -{ - GET_CURRENT_CONTEXT(curCtx); - - if (MESA_VERBOSE & VERBOSE_API) - _mesa_debug(newCtx, "_mesa_make_current()\n"); - - /* Check that the context's and framebuffer's visuals are compatible. - */ - if (newCtx && drawBuffer && newCtx->WinSysDrawBuffer != drawBuffer) { - if (!check_compatible(newCtx, drawBuffer)) { - _mesa_warning(newCtx, - "MakeCurrent: incompatible visuals for context and drawbuffer"); - return GL_FALSE; - } - } - if (newCtx && readBuffer && newCtx->WinSysReadBuffer != readBuffer) { - if (!check_compatible(newCtx, readBuffer)) { - _mesa_warning(newCtx, - "MakeCurrent: incompatible visuals for context and readbuffer"); - return GL_FALSE; - } - } - - if (curCtx && - (curCtx->WinSysDrawBuffer || curCtx->WinSysReadBuffer) && - /* make sure this context is valid for flushing */ - curCtx != newCtx) - _mesa_flush(curCtx); - - /* We used to call _glapi_check_multithread() here. Now do it in drivers */ - _glapi_set_context((void *) newCtx); - ASSERT(_mesa_get_current_context() == newCtx); - - if (!newCtx) { - _glapi_set_dispatch(NULL); /* none current */ - } - else { - _glapi_set_dispatch(newCtx->CurrentDispatch); - - if (drawBuffer && readBuffer) { - ASSERT(drawBuffer->Name == 0); - ASSERT(readBuffer->Name == 0); - _mesa_reference_framebuffer(&newCtx->WinSysDrawBuffer, drawBuffer); - _mesa_reference_framebuffer(&newCtx->WinSysReadBuffer, readBuffer); - - /* - * Only set the context's Draw/ReadBuffer fields if they're NULL - * or not bound to a user-created FBO. - */ - _mesa_reference_framebuffer(&newCtx->DrawBuffer, drawBuffer); - /* Update the FBO's list of drawbuffers/renderbuffers. - * For winsys FBOs this comes from the GL state (which may have - * changed since the last time this FBO was bound). - */ - _mesa_update_draw_buffer(newCtx); - - _mesa_reference_framebuffer(&newCtx->ReadBuffer, readBuffer); - - /* XXX only set this flag if we're really changing the draw/read - * framebuffer bindings. - */ - newCtx->NewState |= _NEW_BUFFERS; - -#if 1 - /* We want to get rid of these lines: */ - -#if _HAVE_FULL_GL - if (!drawBuffer->Initialized) { - initialize_framebuffer_size(newCtx, drawBuffer); - } - if (readBuffer != drawBuffer && !readBuffer->Initialized) { - initialize_framebuffer_size(newCtx, readBuffer); - } - - _mesa_resizebuffers(newCtx); -#endif - -#else - /* We want the drawBuffer and readBuffer to be initialized by - * the driver. - * This generally means the Width and Height match the actual - * window size and the renderbuffers (both hardware and software - * based) are allocated to match. The later can generally be - * done with a call to _mesa_resize_framebuffer(). - * - * It's theoretically possible for a buffer to have zero width - * or height, but for now, assert check that the driver did what's - * expected of it. - */ - ASSERT(drawBuffer->Width > 0); - ASSERT(drawBuffer->Height > 0); -#endif - - if (drawBuffer) { - _mesa_check_init_viewport(newCtx, - drawBuffer->Width, drawBuffer->Height); - } - } - - if (newCtx->FirstTimeCurrent) { - _mesa_compute_version(newCtx); - - newCtx->Extensions.String = _mesa_make_extension_string(newCtx); - - check_context_limits(newCtx); - - newCtx->FirstTimeCurrent = GL_FALSE; - } - } - - return GL_TRUE; -} - - -/** - * Make context 'ctx' share the display lists, textures and programs - * that are associated with 'ctxToShare'. - * Any display lists, textures or programs associated with 'ctx' will - * be deleted if nobody else is sharing them. - */ -GLboolean -_mesa_share_state(struct gl_context *ctx, struct gl_context *ctxToShare) -{ - if (ctx && ctxToShare && ctx->Shared && ctxToShare->Shared) { - struct gl_shared_state *oldShared = NULL; - - /* save ref to old state to prevent it from being deleted immediately */ - _mesa_reference_shared_state(ctx, &oldShared, ctx->Shared); - - /* update ctx's Shared pointer */ - _mesa_reference_shared_state(ctx, &ctx->Shared, ctxToShare->Shared); - - update_default_objects(ctx); - - /* release the old shared state */ - _mesa_reference_shared_state(ctx, &oldShared, NULL); - - return GL_TRUE; - } - else { - return GL_FALSE; - } -} - - - -/** - * \return pointer to the current GL context for this thread. - * - * Calls _glapi_get_context(). This isn't the fastest way to get the current - * context. If you need speed, see the #GET_CURRENT_CONTEXT macro in - * context.h. - */ -struct gl_context * -_mesa_get_current_context( void ) -{ - return (struct gl_context *) _glapi_get_context(); -} - - -/** - * Get context's current API dispatch table. - * - * It'll either be the immediate-mode execute dispatcher or the display list - * compile dispatcher. - * - * \param ctx GL context. - * - * \return pointer to dispatch_table. - * - * Simply returns __struct gl_contextRec::CurrentDispatch. - */ -struct _glapi_table * -_mesa_get_dispatch(struct gl_context *ctx) -{ - return ctx->CurrentDispatch; -} - -/*@}*/ - - -/**********************************************************************/ -/** \name Miscellaneous functions */ -/**********************************************************************/ -/*@{*/ - -/** - * Record an error. - * - * \param ctx GL context. - * \param error error code. - * - * Records the given error code and call the driver's dd_function_table::Error - * function if defined. - * - * \sa - * This is called via _mesa_error(). - */ -void -_mesa_record_error(struct gl_context *ctx, GLenum error) -{ - if (!ctx) - return; - - if (ctx->ErrorValue == GL_NO_ERROR) { - ctx->ErrorValue = error; - } - - /* Call device driver's error handler, if any. This is used on the Mac. */ - if (ctx->Driver.Error) { - ctx->Driver.Error(ctx); - } -} - - -/** - * Flush commands and wait for completion. - */ -void -_mesa_finish(struct gl_context *ctx) -{ - FLUSH_CURRENT( ctx, 0 ); - if (ctx->Driver.Finish) { - ctx->Driver.Finish(ctx); - } -} - - -/** - * Flush commands. - */ -void -_mesa_flush(struct gl_context *ctx) -{ - FLUSH_CURRENT( ctx, 0 ); - if (ctx->Driver.Flush) { - ctx->Driver.Flush(ctx); - } -} - - - -/** - * Execute glFinish(). - * - * Calls the #ASSERT_OUTSIDE_BEGIN_END_AND_FLUSH macro and the - * dd_function_table::Finish driver callback, if not NULL. - */ -void GLAPIENTRY -_mesa_Finish(void) -{ - GET_CURRENT_CONTEXT(ctx); - ASSERT_OUTSIDE_BEGIN_END_AND_FLUSH(ctx); - _mesa_finish(ctx); -} - - -/** - * Execute glFlush(). - * - * Calls the #ASSERT_OUTSIDE_BEGIN_END_AND_FLUSH macro and the - * dd_function_table::Flush driver callback, if not NULL. - */ -void GLAPIENTRY -_mesa_Flush(void) -{ - GET_CURRENT_CONTEXT(ctx); - ASSERT_OUTSIDE_BEGIN_END_AND_FLUSH(ctx); - _mesa_flush(ctx); -} - - -/** - * Set mvp_with_dp4 flag. If a driver has a preference for DP4 over - * MUL/MAD, or vice versa, call this function to register that. - * Otherwise we default to MUL/MAD. - */ -void -_mesa_set_mvp_with_dp4( struct gl_context *ctx, - GLboolean flag ) -{ - ctx->mvp_with_dp4 = flag; -} - - - -/** - * Prior to drawing anything with glBegin, glDrawArrays, etc. this function - * is called to see if it's valid to render. This involves checking that - * the current shader is valid and the framebuffer is complete. - * If an error is detected it'll be recorded here. - * \return GL_TRUE if OK to render, GL_FALSE if not - */ -GLboolean -_mesa_valid_to_render(struct gl_context *ctx, const char *where) -{ - /* This depends on having up to date derived state (shaders) */ - if (ctx->NewState) - _mesa_update_state(ctx); - - - return GL_TRUE; -} - - -/*@}*/ diff --git a/dll/opengl/mesa/main/context.h b/dll/opengl/mesa/main/context.h deleted file mode 100644 index f9d3b3f7f86..00000000000 --- a/dll/opengl/mesa/main/context.h +++ /dev/null @@ -1,294 +0,0 @@ -/* - * Mesa 3-D graphics library - * Version: 6.5.1 - * - * Copyright (C) 1999-2006 Brian Paul All Rights Reserved. - * - * Permission is hereby granted, free of charge, to any person obtaining a - * copy of this software and associated documentation files (the "Software"), - * to deal in the Software without restriction, including without limitation - * the rights to use, copy, modify, merge, publish, distribute, sublicense, - * and/or sell copies of the Software, and to permit persons to whom the - * Software is furnished to do so, subject to the following conditions: - * - * The above copyright notice and this permission notice shall be included - * in all copies or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS - * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL - * BRIAN PAUL BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN - * AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN - * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. - */ - - -/** - * \file context.h - * Mesa context and visual-related functions. - * - * There are three large Mesa data types/classes which are meant to be - * used by device drivers: - * - struct gl_context: this contains the Mesa rendering state - * - struct gl_config: this describes the color buffer (RGB vs. ci), whether - * or not there's a depth buffer, stencil buffer, etc. - * - struct gl_framebuffer: contains pointers to the depth buffer, stencil - * buffer, accum buffer and alpha buffers. - * - * These types should be encapsulated by corresponding device driver - * data types. See xmesa.h and xmesaP.h for an example. - * - * In OOP terms, struct gl_context, struct gl_config, and struct gl_framebuffer - * are base classes which the device driver must derive from. - * - * The following functions create and destroy these data types. - */ - - -#ifndef CONTEXT_H -#define CONTEXT_H - - -#include "imports.h" -#include "mtypes.h" - - -#ifdef __cplusplus -extern "C" { -#endif - - -struct _glapi_table; - - -/** \name Visual-related functions */ -/*@{*/ - -extern struct gl_config * -_mesa_create_visual( GLboolean dbFlag, - GLboolean stereoFlag, - GLint redBits, - GLint greenBits, - GLint blueBits, - GLint alphaBits, - GLint depthBits, - GLint stencilBits, - GLint accumRedBits, - GLint accumGreenBits, - GLint accumBlueBits, - GLint accumAlphaBits); - -extern GLboolean -_mesa_initialize_visual( struct gl_config *v, - GLboolean dbFlag, - GLboolean stereoFlag, - GLint redBits, - GLint greenBits, - GLint blueBits, - GLint alphaBits, - GLint depthBits, - GLint stencilBits, - GLint accumRedBits, - GLint accumGreenBits, - GLint accumBlueBits, - GLint accumAlphaBits); - -extern void -_mesa_destroy_visual( struct gl_config *vis ); - -/*@}*/ - - -/** \name Context-related functions */ -/*@{*/ - -extern GLboolean -_mesa_initialize_context( struct gl_context *ctx, - const struct gl_config *visual, - struct gl_context *share_list, - const struct dd_function_table *driverFunctions, - void *driverContext ); - -extern struct gl_context * -_mesa_create_context(const struct gl_config *visual, - struct gl_context *share_list, - const struct dd_function_table *driverFunctions, - void *driverContext); - -extern void -_mesa_free_context_data( struct gl_context *ctx ); - -extern void -_mesa_destroy_context( struct gl_context *ctx ); - - -extern void -_mesa_copy_context(const struct gl_context *src, struct gl_context *dst, GLuint mask); - - -extern void -_mesa_check_init_viewport(struct gl_context *ctx, GLuint width, GLuint height); - -extern GLboolean -_mesa_make_current( struct gl_context *ctx, struct gl_framebuffer *drawBuffer, - struct gl_framebuffer *readBuffer ); - -extern GLboolean -_mesa_share_state(struct gl_context *ctx, struct gl_context *ctxToShare); - -extern struct gl_context * -_mesa_get_current_context(void); - -/*@}*/ - -extern void -_mesa_init_get_hash(struct gl_context *ctx); - -extern void -_mesa_notifySwapBuffers(struct gl_context *gc); - - -extern struct _glapi_table * -_mesa_get_dispatch(struct gl_context *ctx); - - -void -_mesa_set_mvp_with_dp4( struct gl_context *ctx, - GLboolean flag ); - - -extern GLboolean -_mesa_valid_to_render(struct gl_context *ctx, const char *where); - - - -/** \name Miscellaneous */ -/*@{*/ - -extern void -_mesa_record_error( struct gl_context *ctx, GLenum error ); - - -extern void -_mesa_finish(struct gl_context *ctx); - -extern void -_mesa_flush(struct gl_context *ctx); - - -extern void GLAPIENTRY -_mesa_Finish( void ); - -extern void GLAPIENTRY -_mesa_Flush( void ); - -/*@}*/ - - -/** - * \name Macros for flushing buffered rendering commands before state changes, - * checking if inside glBegin/glEnd, etc. - */ -/*@{*/ - -/** - * Flush vertices. - * - * \param ctx GL context. - * \param newstate new state. - * - * Checks if dd_function_table::NeedFlush is marked to flush stored vertices, - * and calls dd_function_table::FlushVertices if so. Marks - * __struct gl_contextRec::NewState with \p newstate. - */ -#define FLUSH_VERTICES(ctx, newstate) \ -do { \ - if (MESA_VERBOSE & VERBOSE_STATE) \ - _mesa_debug(ctx, "FLUSH_VERTICES in %s\n", MESA_FUNCTION);\ - if (ctx->Driver.NeedFlush & FLUSH_STORED_VERTICES) \ - ctx->Driver.FlushVertices(ctx, FLUSH_STORED_VERTICES); \ - ctx->NewState |= newstate; \ -} while (0) - -/** - * Flush current state. - * - * \param ctx GL context. - * \param newstate new state. - * - * Checks if dd_function_table::NeedFlush is marked to flush current state, - * and calls dd_function_table::FlushVertices if so. Marks - * __struct gl_contextRec::NewState with \p newstate. - */ -#define FLUSH_CURRENT(ctx, newstate) \ -do { \ - if (MESA_VERBOSE & VERBOSE_STATE) \ - _mesa_debug(ctx, "FLUSH_CURRENT in %s\n", MESA_FUNCTION); \ - if (ctx->Driver.NeedFlush & FLUSH_UPDATE_CURRENT) \ - ctx->Driver.FlushVertices(ctx, FLUSH_UPDATE_CURRENT); \ - ctx->NewState |= newstate; \ -} while (0) - -/** - * Macro to assert that the API call was made outside the - * glBegin()/glEnd() pair, with return value. - * - * \param ctx GL context. - * \param retval value to return in case the assertion fails. - */ -#define ASSERT_OUTSIDE_BEGIN_END_WITH_RETVAL(ctx, retval) \ -do { \ - if (ctx->Driver.CurrentExecPrimitive != PRIM_OUTSIDE_BEGIN_END) { \ - _mesa_error(ctx, GL_INVALID_OPERATION, "Inside glBegin/glEnd"); \ - return retval; \ - } \ -} while (0) - -/** - * Macro to assert that the API call was made outside the - * glBegin()/glEnd() pair. - * - * \param ctx GL context. - */ -#define ASSERT_OUTSIDE_BEGIN_END(ctx) \ -do { \ - if (ctx->Driver.CurrentExecPrimitive != PRIM_OUTSIDE_BEGIN_END) { \ - _mesa_error(ctx, GL_INVALID_OPERATION, "Inside glBegin/glEnd"); \ - return; \ - } \ -} while (0) - -/** - * Macro to assert that the API call was made outside the - * glBegin()/glEnd() pair and flush the vertices. - * - * \param ctx GL context. - */ -#define ASSERT_OUTSIDE_BEGIN_END_AND_FLUSH(ctx) \ -do { \ - ASSERT_OUTSIDE_BEGIN_END(ctx); \ - FLUSH_VERTICES(ctx, 0); \ -} while (0) - -/** - * Macro to assert that the API call was made outside the - * glBegin()/glEnd() pair and flush the vertices, with return value. - * - * \param ctx GL context. - * \param retval value to return in case the assertion fails. - */ -#define ASSERT_OUTSIDE_BEGIN_END_AND_FLUSH_WITH_RETVAL(ctx, retval) \ -do { \ - ASSERT_OUTSIDE_BEGIN_END_WITH_RETVAL(ctx, retval); \ - FLUSH_VERTICES(ctx, 0); \ -} while (0) - -/*@}*/ - - -#ifdef __cplusplus -} -#endif - - -#endif /* CONTEXT_H */ diff --git a/dll/opengl/mesa/main/core.h b/dll/opengl/mesa/main/core.h deleted file mode 100644 index c28a8af53e3..00000000000 --- a/dll/opengl/mesa/main/core.h +++ /dev/null @@ -1,55 +0,0 @@ -/* - * Mesa 3-D graphics library - * Version: 7.9 - * - * Copyright (C) 2010 LunarG Inc. - * - * Permission is hereby granted, free of charge, to any person obtaining a - * copy of this software and associated documentation files (the "Software"), - * to deal in the Software without restriction, including without limitation - * the rights to use, copy, modify, merge, publish, distribute, sublicense, - * and/or sell copies of the Software, and to permit persons to whom the - * Software is furnished to do so, subject to the following conditions: - * - * The above copyright notice and this permission notice shall be included - * in all copies or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR - * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL - * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER - * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING - * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER - * DEALINGS IN THE SOFTWARE. - * - * Authors: - * Chia-I Wu - */ - - -/** - * \file core.h - * The public header of core mesa. - * - * This file is the (only) public header of core mesa. It is supposed to be - * used by GLX, WGL, and GLSL. It is important that headers directly or - * indirectly included here do not perform feature tests (#if FEATURE_xxx). - */ - - -#ifndef CORE_H -#define CORE_H - - -#include "main/glheader.h" -#include "main/compiler.h" -#include "main/imports.h" -#include "main/macros.h" - -#include "main/mtypes.h" - -/* for GLSL */ -#include "program/prog_parameter.h" - - -#endif /* CORE_H */ diff --git a/dll/opengl/mesa/main/cpuinfo.c b/dll/opengl/mesa/main/cpuinfo.c deleted file mode 100644 index f70905bedf1..00000000000 --- a/dll/opengl/mesa/main/cpuinfo.c +++ /dev/null @@ -1,106 +0,0 @@ -/* - * Mesa 3-D graphics library - * Version: 7.5 - * - * Copyright (C) 2009 VMware, Inc. All Rights Reserved. - * - * Permission is hereby granted, free of charge, to any person obtaining a - * copy of this software and associated documentation files (the "Software"), - * to deal in the Software without restriction, including without limitation - * the rights to use, copy, modify, merge, publish, distribute, sublicense, - * and/or sell copies of the Software, and to permit persons to whom the - * Software is furnished to do so, subject to the following conditions: - * - * The above copyright notice and this permission notice shall be included - * in all copies or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS - * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL - * BRIAN PAUL BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN - * AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN - * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. - */ - -#include - -/** - * This function should be called before the various "cpu_has_foo" macros - * are used. - */ -void -_mesa_get_cpu_features(void) -{ -#ifdef USE_X86_ASM - _mesa_get_x86_features(); -#endif -} - - -/** - * Return a string describing the CPU architexture and extensions that - * Mesa is using (such as SSE or Altivec). - * \return information string, free it with free() - */ -char * -_mesa_get_cpu_string(void) -{ -#define MAX_STRING 50 - char *buffer; - - buffer = (char *) malloc(MAX_STRING); - if (!buffer) - return NULL; - - buffer[0] = 0; - -#ifdef USE_X86_ASM - - if (_mesa_x86_cpu_features) { - strcat(buffer, "x86"); - } - -# ifdef USE_MMX_ASM - if (cpu_has_mmx) { - strcat(buffer, (cpu_has_mmxext) ? "/MMX+" : "/MMX"); - } -# endif -# ifdef USE_3DNOW_ASM - if (cpu_has_3dnow) { - strcat(buffer, (cpu_has_3dnowext) ? "/3DNow!+" : "/3DNow!"); - } -# endif -# ifdef USE_SSE_ASM - if (cpu_has_xmm) { - strcat(buffer, (cpu_has_xmm2) ? "/SSE2" : "/SSE"); - } -# endif - -#elif defined(USE_SPARC_ASM) - - strcat(buffer, "SPARC"); - -#elif defined(USE_PPC_ASM) - - if (_mesa_ppc_cpu_features) { - strcat(buffer, (cpu_has_64) ? "PowerPC 64" : "PowerPC"); - } - -# ifdef USE_VMX_ASM - - if (cpu_has_vmx) { - strcat(buffer, "/Altivec"); - } - -# endif - - if (! cpu_has_fpu) { - strcat(buffer, "/No FPU"); - } - -#endif - - assert(strlen(buffer) < MAX_STRING); - - return buffer; -} diff --git a/dll/opengl/mesa/main/cpuinfo.h b/dll/opengl/mesa/main/cpuinfo.h deleted file mode 100644 index c41a90b075a..00000000000 --- a/dll/opengl/mesa/main/cpuinfo.h +++ /dev/null @@ -1,47 +0,0 @@ -/* - * Mesa 3-D graphics library - * Version: 7.5 - * - * Copyright (C) 2009 VMware, Inc. All Rights Reserved. - * - * Permission is hereby granted, free of charge, to any person obtaining a - * copy of this software and associated documentation files (the "Software"), - * to deal in the Software without restriction, including without limitation - * the rights to use, copy, modify, merge, publish, distribute, sublicense, - * and/or sell copies of the Software, and to permit persons to whom the - * Software is furnished to do so, subject to the following conditions: - * - * The above copyright notice and this permission notice shall be included - * in all copies or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS - * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL - * BRIAN PAUL BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN - * AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN - * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. - */ - - -#ifndef CPUINFO_H -#define CPUINFO_H - - -#if defined(USE_X86_ASM) -#include "x86/common_x86_asm.h" -#endif - -#if defined(USE_PPC_ASM) -#include "ppc/common_ppc_features.h" -#endif - - -extern void -_mesa_get_cpu_features(void); - - -extern char * -_mesa_get_cpu_string(void); - - -#endif /* CPUINFO_H */ diff --git a/dll/opengl/mesa/main/dd.h b/dll/opengl/mesa/main/dd.h deleted file mode 100644 index ba4403eb205..00000000000 --- a/dll/opengl/mesa/main/dd.h +++ /dev/null @@ -1,768 +0,0 @@ -/** - * \file dd.h - * Device driver interfaces. - */ - -/* - * Mesa 3-D graphics library - * Version: 6.5.2 - * - * Copyright (C) 1999-2006 Brian Paul All Rights Reserved. - * - * Permission is hereby granted, free of charge, to any person obtaining a - * copy of this software and associated documentation files (the "Software"), - * to deal in the Software without restriction, including without limitation - * the rights to use, copy, modify, merge, publish, distribute, sublicense, - * and/or sell copies of the Software, and to permit persons to whom the - * Software is furnished to do so, subject to the following conditions: - * - * The above copyright notice and this permission notice shall be included - * in all copies or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS - * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL - * BRIAN PAUL BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN - * AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN - * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. - */ - - -#ifndef DD_INCLUDED -#define DD_INCLUDED - -/* THIS FILE ONLY INCLUDED BY mtypes.h !!!!! */ - -#include "glheader.h" - -struct gl_buffer_object; -struct gl_context; -struct gl_display_list; -struct gl_framebuffer; -struct gl_pixelstore_attrib; -struct gl_renderbuffer; -struct gl_renderbuffer_attachment; -struct gl_texture_image; -struct gl_texture_object; - -/* GL_ARB_vertex_buffer_object */ -/* Modifies GL_MAP_UNSYNCHRONIZED_BIT to allow driver to fail (return - * NULL) if buffer is unavailable for immediate mapping. - * - * Does GL_MAP_INVALIDATE_RANGE_BIT do this? It seems so, but it - * would require more book-keeping in the driver than seems necessary - * at this point. - * - * Does GL_MAP_INVALDIATE_BUFFER_BIT do this? Not really -- we don't - * want to provoke the driver to throw away the old storage, we will - * respect the contents of already referenced data. - */ -#define MESA_MAP_NOWAIT_BIT 0x0040 - - -/** - * Device driver function table. - * Core Mesa uses these function pointers to call into device drivers. - * Most of these functions directly correspond to OpenGL state commands. - * Core Mesa will call these functions after error checking has been done - * so that the drivers don't have to worry about error testing. - * - * Vertex transformation/clipping/lighting is patched into the T&L module. - * Rasterization functions are patched into the swrast module. - * - * Note: when new functions are added here, the drivers/common/driverfuncs.c - * file should be updated too!!! - */ -struct dd_function_table { - /** - * Return a string as needed by glGetString(). - * Only the GL_RENDERER query must be implemented. Otherwise, NULL can be - * returned. - */ - const GLubyte * (*GetString)( struct gl_context *ctx, GLenum name ); - - /** - * Notify the driver after Mesa has made some internal state changes. - * - * This is in addition to any state change callbacks Mesa may already have - * made. - */ - void (*UpdateState)( struct gl_context *ctx, GLbitfield new_state ); - - /** - * Get the width and height of the named buffer/window. - * - * Mesa uses this to determine when the driver's window size has changed. - * XXX OBSOLETE: this function will be removed in the future. - */ - void (*GetBufferSize)( struct gl_framebuffer *buffer, - GLuint *width, GLuint *height ); - - /** - * Resize the given framebuffer to the given size. - * XXX OBSOLETE: this function will be removed in the future. - */ - void (*ResizeBuffers)( struct gl_context *ctx, struct gl_framebuffer *fb, - GLuint width, GLuint height); - - /** - * Called whenever an error is generated. - * __struct gl_contextRec::ErrorValue contains the error value. - */ - void (*Error)( struct gl_context *ctx ); - - /** - * This is called whenever glFinish() is called. - */ - void (*Finish)( struct gl_context *ctx ); - - /** - * This is called whenever glFlush() is called. - */ - void (*Flush)( struct gl_context *ctx ); - - /** - * Clear the color/depth/stencil/accum buffer(s). - * \param buffers a bitmask of BUFFER_BIT_* flags indicating which - * renderbuffers need to be cleared. - */ - void (*Clear)( struct gl_context *ctx, GLbitfield buffers ); - - /** - * Execute glAccum command. - */ - void (*Accum)( struct gl_context *ctx, GLenum op, GLfloat value ); - - - /** - * Execute glRasterPos, updating the ctx->Current.Raster fields - */ - void (*RasterPos)( struct gl_context *ctx, const GLfloat v[4] ); - - /** - * \name Image-related functions - */ - /*@{*/ - - /** - * Called by glDrawPixels(). - * \p unpack describes how to unpack the source image data. - */ - void (*DrawPixels)( struct gl_context *ctx, - GLint x, GLint y, GLsizei width, GLsizei height, - GLenum format, GLenum type, - const struct gl_pixelstore_attrib *unpack, - const GLvoid *pixels ); - - /** - * Called by glReadPixels(). - */ - void (*ReadPixels)( struct gl_context *ctx, - GLint x, GLint y, GLsizei width, GLsizei height, - GLenum format, GLenum type, - const struct gl_pixelstore_attrib *unpack, - GLvoid *dest ); - - /** - * Called by glCopyPixels(). - */ - void (*CopyPixels)( struct gl_context *ctx, GLint srcx, GLint srcy, - GLsizei width, GLsizei height, - GLint dstx, GLint dsty, GLenum type ); - - /** - * Called by glBitmap(). - */ - void (*Bitmap)( struct gl_context *ctx, - GLint x, GLint y, GLsizei width, GLsizei height, - const struct gl_pixelstore_attrib *unpack, - const GLubyte *bitmap ); - /*@}*/ - - - /** - * \name Texture image functions - */ - /*@{*/ - - /** - * Choose actual hardware texture format given the user-provided source - * image format and type and the desired internal format. In some - * cases, srcFormat and srcType can be GL_NONE. - * Called by glTexImage(), etc. - */ - gl_format (*ChooseTextureFormat)( struct gl_context *ctx, GLint internalFormat, - GLenum srcFormat, GLenum srcType ); - - /** - * Called by glTexImage1D(). Simply copy the source texture data into the - * destination texture memory. The gl_texture_image fields, etc. will be - * fully initialized. - * The parameters are the same as glTexImage1D(), plus: - * \param packing describes how to unpack the source data. - * \param texImage is the destination texture image. - */ - void (*TexImage1D)(struct gl_context *ctx, - struct gl_texture_image *texImage, - GLint internalFormat, - GLint width, GLint border, - GLenum format, GLenum type, const GLvoid *pixels, - const struct gl_pixelstore_attrib *packing); - - /** - * Called by glTexImage2D(). - * - * \sa dd_function_table::TexImage1D. - */ - void (*TexImage2D)(struct gl_context *ctx, - struct gl_texture_image *texImage, - GLint internalFormat, - GLint width, GLint height, GLint border, - GLenum format, GLenum type, const GLvoid *pixels, - const struct gl_pixelstore_attrib *packing); - - /** - * Called by glTexSubImage1D(). Replace a subset of the target texture - * with new texel data. - * \sa dd_function_table::TexImage1D. - */ - void (*TexSubImage1D)(struct gl_context *ctx, - struct gl_texture_image *texImage, - GLint xoffset, GLsizei width, - GLenum format, GLenum type, - const GLvoid *pixels, - const struct gl_pixelstore_attrib *packing); - - /** - * Called by glTexSubImage2D(). - * - * \sa dd_function_table::TexSubImage1D. - */ - void (*TexSubImage2D)(struct gl_context *ctx, - struct gl_texture_image *texImage, - GLint xoffset, GLint yoffset, - GLsizei width, GLsizei height, - GLenum format, GLenum type, - const GLvoid *pixels, - const struct gl_pixelstore_attrib *packing); - - - /** - * Called by glGetTexImage(). - */ - void (*GetTexImage)( struct gl_context *ctx, - GLenum format, GLenum type, GLvoid *pixels, - struct gl_texture_image *texImage ); - - /** - * Called by glCopyTexSubImage1D() and glCopyTexImage1D(). - */ - void (*CopyTexSubImage1D)(struct gl_context *ctx, - struct gl_texture_image *texImage, - GLint xoffset, - struct gl_renderbuffer *rb, - GLint x, GLint y, GLsizei width); - - /** - * Called by glCopyTexSubImage2D() and glCopyTexImage2D(). - */ - void (*CopyTexSubImage2D)(struct gl_context *ctx, - struct gl_texture_image *texImage, - GLint xoffset, GLint yoffset, - struct gl_renderbuffer *rb, - GLint x, GLint y, - GLsizei width, GLsizei height); - - /** - * Called by glTexImage[123]D when user specifies a proxy texture - * target. - * - * \return GL_TRUE if the proxy test passes, or GL_FALSE if the test fails. - */ - GLboolean (*TestProxyTexImage)(struct gl_context *ctx, GLenum target, - GLint level, GLint internalFormat, - GLenum format, GLenum type, - GLint width, GLint height, - GLint depth, GLint border); - /*@}*/ - - - /** - * \name Compressed texture functions - */ - /*@{*/ - - /** - * Called by glCompressedTexImage1D(). - * The parameters are the same as for glCompressedTexImage1D(), plus a - * pointer to the destination texure image. - */ - void (*CompressedTexImage1D)(struct gl_context *ctx, - struct gl_texture_image *texImage, - GLint internalFormat, - GLsizei width, GLint border, - GLsizei imageSize, const GLvoid *data); - /** - * Called by glCompressedTexImage2D(). - * - * \sa dd_function_table::CompressedTexImage1D. - */ - void (*CompressedTexImage2D)(struct gl_context *ctx, - struct gl_texture_image *texImage, - GLint internalFormat, - GLsizei width, GLsizei height, GLint border, - GLsizei imageSize, const GLvoid *data); - - /** - * Called by glCompressedTexSubImage1D(). - */ - void (*CompressedTexSubImage1D)(struct gl_context *ctx, - struct gl_texture_image *texImage, - GLint xoffset, GLsizei width, - GLenum format, - GLsizei imageSize, const GLvoid *data); - - /** - * Called by glCompressedTexSubImage2D(). - */ - void (*CompressedTexSubImage2D)(struct gl_context *ctx, - struct gl_texture_image *texImage, - GLint xoffset, GLint yoffset, - GLsizei width, GLint height, - GLenum format, - GLsizei imageSize, const GLvoid *data); - /*@}*/ - - /** - * \name Texture object / image functions - */ - /*@{*/ - - /** - * Called by glBindTexture(). - */ - void (*BindTexture)( struct gl_context *ctx, GLenum target, - struct gl_texture_object *tObj ); - - /** - * Called to allocate a new texture object. Drivers will usually - * allocate/return a subclass of gl_texture_object. - */ - struct gl_texture_object * (*NewTextureObject)(struct gl_context *ctx, - GLuint name, GLenum target); - /** - * Called to delete/free a texture object. Drivers should free the - * object and any image data it contains. - */ - void (*DeleteTexture)(struct gl_context *ctx, - struct gl_texture_object *texObj); - - /** Called to allocate a new texture image object. */ - struct gl_texture_image * (*NewTextureImage)(struct gl_context *ctx); - - /** Called to free a texture image object returned by NewTextureImage() */ - void (*DeleteTextureImage)(struct gl_context *ctx, - struct gl_texture_image *); - - /** Called to allocate memory for a single texture image */ - GLboolean (*AllocTextureImageBuffer)(struct gl_context *ctx, - struct gl_texture_image *texImage, - gl_format format, GLsizei width, - GLsizei height, GLsizei depth); - - /** Free the memory for a single texture image */ - void (*FreeTextureImageBuffer)(struct gl_context *ctx, - struct gl_texture_image *texImage); - - /** Map a slice of a texture image into user space. - * Note: for GL_TEXTURE_1D_ARRAY, height must be 1, y must be 0 and slice - * indicates the 1D array index. - * \param texImage the texture image - * \param slice the 3D image slice or array texture slice - * \param x, y, w, h region of interest - * \param mode bitmask of GL_MAP_READ_BIT, GL_MAP_WRITE_BIT and - * GL_MAP_INVALIDATE_RANGE_BIT (if writing) - * \param mapOut returns start of mapping of region of interest - * \param rowStrideOut returns row stride (in bytes) - */ - void (*MapTextureImage)(struct gl_context *ctx, - struct gl_texture_image *texImage, - GLuint slice, - GLuint x, GLuint y, GLuint w, GLuint h, - GLbitfield mode, - GLubyte **mapOut, GLint *rowStrideOut); - - void (*UnmapTextureImage)(struct gl_context *ctx, - struct gl_texture_image *texImage, - GLuint slice); - - /** For GL_ARB_texture_storage. Allocate memory for whole mipmap stack. - * All the gl_texture_images in the texture object will have their - * dimensions, format, etc. initialized already. - */ - GLboolean (*AllocTextureStorage)(struct gl_context *ctx, - struct gl_texture_object *texObj, - GLsizei levels, GLsizei width, - GLsizei height, GLsizei depth); - - /** - * Map a renderbuffer into user space. - * \param mode bitmask of GL_MAP_READ_BIT, GL_MAP_WRITE_BIT and - * GL_MAP_INVALIDATE_RANGE_BIT (if writing) - */ - void (*MapRenderbuffer)(struct gl_context *ctx, - struct gl_renderbuffer *rb, - GLuint x, GLuint y, GLuint w, GLuint h, - GLbitfield mode, - GLubyte **mapOut, GLint *rowStrideOut); - - void (*UnmapRenderbuffer)(struct gl_context *ctx, - struct gl_renderbuffer *rb); - - /*@}*/ - - /** - * \name State-changing functions. - * - * \note drawing functions are above. - * - * These functions are called by their corresponding OpenGL API functions. - * They are \e also called by the gl_PopAttrib() function!!! - * May add more functions like these to the device driver in the future. - */ - /*@{*/ - /** Specify the alpha test function */ - void (*AlphaFunc)(struct gl_context *ctx, GLenum func, GLfloat ref); - /** Specify clear values for the color buffers */ - void (*ClearColor)(struct gl_context *ctx, - const union gl_color_union color); - /** Specify the clear value for the depth buffer */ - void (*ClearDepth)(struct gl_context *ctx, GLclampd d); - /** Specify the clear value for the stencil buffer */ - void (*ClearStencil)(struct gl_context *ctx, GLint s); - /** Specify a plane against which all geometry is clipped */ - void (*ClipPlane)(struct gl_context *ctx, GLenum plane, const GLfloat *equation ); - /** Enable and disable writing of frame buffer color components */ - void (*ColorMask)(struct gl_context *ctx, GLboolean rmask, GLboolean gmask, - GLboolean bmask, GLboolean amask ); - /** Cause a material color to track the current color */ - void (*ColorMaterial)(struct gl_context *ctx, GLenum face, GLenum mode); - /** Specify whether front- or back-facing facets can be culled */ - void (*CullFace)(struct gl_context *ctx, GLenum mode); - /** Define front- and back-facing polygons */ - void (*FrontFace)(struct gl_context *ctx, GLenum mode); - /** Specify the value used for depth buffer comparisons */ - void (*DepthFunc)(struct gl_context *ctx, GLenum func); - /** Enable or disable writing into the depth buffer */ - void (*DepthMask)(struct gl_context *ctx, GLboolean flag); - /** Specify mapping of depth values from NDC to window coordinates */ - void (*DepthRange)(struct gl_context *ctx, GLclampd nearval, GLclampd farval); - /** Specify the current buffer for writing */ - void (*DrawBuffer)( struct gl_context *ctx, GLenum buffer ); - /** Enable or disable server-side gl capabilities */ - void (*Enable)(struct gl_context *ctx, GLenum cap, GLboolean state); - /** Specify fog parameters */ - void (*Fogfv)(struct gl_context *ctx, GLenum pname, const GLfloat *params); - /** Specify implementation-specific hints */ - void (*Hint)(struct gl_context *ctx, GLenum target, GLenum mode); - /** Set light source parameters. - * Note: for GL_POSITION and GL_SPOT_DIRECTION, params will have already - * been transformed to eye-space. - */ - void (*Lightfv)(struct gl_context *ctx, GLenum light, - GLenum pname, const GLfloat *params ); - /** Set the lighting model parameters */ - void (*LightModelfv)(struct gl_context *ctx, GLenum pname, const GLfloat *params); - /** Specify the line stipple pattern */ - void (*LineStipple)(struct gl_context *ctx, GLint factor, GLushort pattern ); - /** Specify the width of rasterized lines */ - void (*LineWidth)(struct gl_context *ctx, GLfloat width); - /** Specify a logical pixel operation for color index rendering */ - void (*LogicOpcode)(struct gl_context *ctx, GLenum opcode); - void (*PointParameterfv)(struct gl_context *ctx, GLenum pname, - const GLfloat *params); - /** Specify the diameter of rasterized points */ - void (*PointSize)(struct gl_context *ctx, GLfloat size); - /** Select a polygon rasterization mode */ - void (*PolygonMode)(struct gl_context *ctx, GLenum face, GLenum mode); - /** Set the scale and units used to calculate depth values */ - void (*PolygonOffset)(struct gl_context *ctx, GLfloat factor, GLfloat units); - /** Set the polygon stippling pattern */ - void (*PolygonStipple)(struct gl_context *ctx, const GLubyte *mask ); - /* Specifies the current buffer for reading */ - void (*ReadBuffer)( struct gl_context *ctx, GLenum buffer ); - /** Set rasterization mode */ - void (*RenderMode)(struct gl_context *ctx, GLenum mode ); - /** Define the scissor box */ - void (*Scissor)(struct gl_context *ctx, GLint x, GLint y, GLsizei w, GLsizei h); - /** Select flat or smooth shading */ - void (*ShadeModel)(struct gl_context *ctx, GLenum mode); - /** Control the generation of texture coordinates */ - void (*TexGen)(struct gl_context *ctx, GLenum coord, GLenum pname, - const GLfloat *params); - /** Set texture environment parameters */ - void (*TexEnv)(struct gl_context *ctx, GLenum target, GLenum pname, - const GLfloat *param); - /** Set texture parameters */ - void (*TexParameter)(struct gl_context *ctx, GLenum target, - struct gl_texture_object *texObj, - GLenum pname, const GLfloat *params); - /** Set the viewport */ - void (*Viewport)(struct gl_context *ctx, GLint x, GLint y, GLsizei w, GLsizei h); - /*@}*/ - - - /** - * \name Vertex/pixel buffer object functions - */ - /*@{*/ - void (*BindBuffer)( struct gl_context *ctx, GLenum target, - struct gl_buffer_object *obj ); - - struct gl_buffer_object * (*NewBufferObject)( struct gl_context *ctx, GLuint buffer, - GLenum target ); - - void (*DeleteBuffer)( struct gl_context *ctx, struct gl_buffer_object *obj ); - - GLboolean (*BufferData)( struct gl_context *ctx, GLenum target, GLsizeiptrARB size, - const GLvoid *data, GLenum usage, - struct gl_buffer_object *obj ); - - void (*BufferSubData)( struct gl_context *ctx, GLintptrARB offset, - GLsizeiptrARB size, const GLvoid *data, - struct gl_buffer_object *obj ); - - void (*GetBufferSubData)( struct gl_context *ctx, - GLintptrARB offset, GLsizeiptrARB size, - GLvoid *data, struct gl_buffer_object *obj ); - - /* May return NULL if MESA_MAP_NOWAIT_BIT is set in access: - */ - void * (*MapBufferRange)( struct gl_context *ctx, GLintptr offset, - GLsizeiptr length, GLbitfield access, - struct gl_buffer_object *obj); - - void (*FlushMappedBufferRange)(struct gl_context *ctx, - GLintptr offset, GLsizeiptr length, - struct gl_buffer_object *obj); - - GLboolean (*UnmapBuffer)( struct gl_context *ctx, - struct gl_buffer_object *obj ); - /*@}*/ - - - /** - * \name Support for multiple T&L engines - */ - /*@{*/ - - /** - * Set by the driver-supplied T&L engine. - * - * Set to PRIM_OUTSIDE_BEGIN_END when outside glBegin()/glEnd(). - */ - GLuint CurrentExecPrimitive; - - /** - * Current state of an in-progress compilation. - * - * May take on any of the additional values PRIM_OUTSIDE_BEGIN_END, - * PRIM_INSIDE_UNKNOWN_PRIM or PRIM_UNKNOWN defined above. - */ - GLuint CurrentSavePrimitive; - - -#define FLUSH_STORED_VERTICES 0x1 -#define FLUSH_UPDATE_CURRENT 0x2 - /** - * Set by the driver-supplied T&L engine whenever vertices are buffered - * between glBegin()/glEnd() objects or __struct gl_contextRec::Current is not - * updated. - * - * The dd_function_table::FlushVertices call below may be used to resolve - * these conditions. - */ - GLuint NeedFlush; - GLuint SaveNeedFlush; - - - /* Called prior to any of the GLvertexformat functions being - * called. Paired with Driver.FlushVertices(). - */ - void (*BeginVertices)( struct gl_context *ctx ); - - /** - * If inside glBegin()/glEnd(), it should ASSERT(0). Otherwise, if - * FLUSH_STORED_VERTICES bit in \p flags is set flushes any buffered - * vertices, if FLUSH_UPDATE_CURRENT bit is set updates - * __struct gl_contextRec::Current and gl_light_attrib::Material - * - * Note that the default T&L engine never clears the - * FLUSH_UPDATE_CURRENT bit, even after performing the update. - */ - void (*FlushVertices)( struct gl_context *ctx, GLuint flags ); - void (*SaveFlushVertices)( struct gl_context *ctx ); - - /** - * \brief Hook for drivers to prepare for a glBegin/glEnd block - * - * This hook is called in vbo_exec_Begin() before any action, including - * state updates, occurs. - */ - void (*PrepareExecBegin)( struct gl_context *ctx ); - - /** - * Give the driver the opportunity to hook in its own vtxfmt for - * compiling optimized display lists. This is called on each valid - * glBegin() during list compilation. - */ - GLboolean (*NotifySaveBegin)( struct gl_context *ctx, GLenum mode ); - - /** - * Notify driver that the special derived value _NeedEyeCoords has - * changed. - */ - void (*LightingSpaceChange)( struct gl_context *ctx ); - - /** - * Called by glNewList(). - * - * Let the T&L component know what is going on with display lists - * in time to make changes to dispatch tables, etc. - */ - void (*NewList)( struct gl_context *ctx, GLuint list, GLenum mode ); - /** - * Called by glEndList(). - * - * \sa dd_function_table::NewList. - */ - void (*EndList)( struct gl_context *ctx ); - - /** - * Called by glCallList(s). - * - * Notify the T&L component before and after calling a display list. - */ - void (*BeginCallList)( struct gl_context *ctx, - struct gl_display_list *dlist ); - /** - * Called by glEndCallList(). - * - * \sa dd_function_table::BeginCallList. - */ - void (*EndCallList)( struct gl_context *ctx ); - - /**@}*/ -}; - - -/** - * Transform/Clip/Lighting interface - * - * Drivers present a reduced set of the functions possible in - * glBegin()/glEnd() objects. Core mesa provides translation stubs for the - * remaining functions to map down to these entry points. - * - * These are the initial values to be installed into dispatch by - * mesa. If the T&L driver wants to modify the dispatch table - * while installed, it must do so itself. It would be possible for - * the vertexformat to install its own initial values for these - * functions, but this way there is an obvious list of what is - * expected of the driver. - * - * If the driver wants to hook in entry points other than those - * listed, it must restore them to their original values in - * the disable() callback, below. - */ -typedef struct { - /** - * \name Vertex - */ - /*@{*/ - void (GLAPIENTRYP ArrayElement)( GLint ); - void (GLAPIENTRYP Color3f)( GLfloat, GLfloat, GLfloat ); - void (GLAPIENTRYP Color3fv)( const GLfloat * ); - void (GLAPIENTRYP Color4f)( GLfloat, GLfloat, GLfloat, GLfloat ); - void (GLAPIENTRYP Color4fv)( const GLfloat * ); - void (GLAPIENTRYP EdgeFlag)( GLboolean ); - void (GLAPIENTRYP EvalCoord1f)( GLfloat ); - void (GLAPIENTRYP EvalCoord1fv)( const GLfloat * ); - void (GLAPIENTRYP EvalCoord2f)( GLfloat, GLfloat ); - void (GLAPIENTRYP EvalCoord2fv)( const GLfloat * ); - void (GLAPIENTRYP EvalPoint1)( GLint ); - void (GLAPIENTRYP EvalPoint2)( GLint, GLint ); - void (GLAPIENTRYP FogCoordfEXT)( GLfloat ); - void (GLAPIENTRYP FogCoordfvEXT)( const GLfloat * ); - void (GLAPIENTRYP Indexf)( GLfloat ); - void (GLAPIENTRYP Indexfv)( const GLfloat * ); - void (GLAPIENTRYP Materialfv)( GLenum face, GLenum pname, const GLfloat * ); - void (GLAPIENTRYP MultiTexCoord1fARB)( GLenum, GLfloat ); - void (GLAPIENTRYP MultiTexCoord1fvARB)( GLenum, const GLfloat * ); - void (GLAPIENTRYP MultiTexCoord2fARB)( GLenum, GLfloat, GLfloat ); - void (GLAPIENTRYP MultiTexCoord2fvARB)( GLenum, const GLfloat * ); - void (GLAPIENTRYP MultiTexCoord3fARB)( GLenum, GLfloat, GLfloat, GLfloat ); - void (GLAPIENTRYP MultiTexCoord3fvARB)( GLenum, const GLfloat * ); - void (GLAPIENTRYP MultiTexCoord4fARB)( GLenum, GLfloat, GLfloat, GLfloat, GLfloat ); - void (GLAPIENTRYP MultiTexCoord4fvARB)( GLenum, const GLfloat * ); - void (GLAPIENTRYP Normal3f)( GLfloat, GLfloat, GLfloat ); - void (GLAPIENTRYP Normal3fv)( const GLfloat * ); - void (GLAPIENTRYP TexCoord1f)( GLfloat ); - void (GLAPIENTRYP TexCoord1fv)( const GLfloat * ); - void (GLAPIENTRYP TexCoord2f)( GLfloat, GLfloat ); - void (GLAPIENTRYP TexCoord2fv)( const GLfloat * ); - void (GLAPIENTRYP TexCoord3f)( GLfloat, GLfloat, GLfloat ); - void (GLAPIENTRYP TexCoord3fv)( const GLfloat * ); - void (GLAPIENTRYP TexCoord4f)( GLfloat, GLfloat, GLfloat, GLfloat ); - void (GLAPIENTRYP TexCoord4fv)( const GLfloat * ); - void (GLAPIENTRYP Vertex2f)( GLfloat, GLfloat ); - void (GLAPIENTRYP Vertex2fv)( const GLfloat * ); - void (GLAPIENTRYP Vertex3f)( GLfloat, GLfloat, GLfloat ); - void (GLAPIENTRYP Vertex3fv)( const GLfloat * ); - void (GLAPIENTRYP Vertex4f)( GLfloat, GLfloat, GLfloat, GLfloat ); - void (GLAPIENTRYP Vertex4fv)( const GLfloat * ); - void (GLAPIENTRYP CallList)( GLuint ); - void (GLAPIENTRYP CallLists)( GLsizei, GLenum, const GLvoid * ); - void (GLAPIENTRYP Begin)( GLenum ); - void (GLAPIENTRYP End)( void ); - /* GL_NV_vertex_program */ - void (GLAPIENTRYP VertexAttrib1fNV)( GLuint index, GLfloat x ); - void (GLAPIENTRYP VertexAttrib1fvNV)( GLuint index, const GLfloat *v ); - void (GLAPIENTRYP VertexAttrib2fNV)( GLuint index, GLfloat x, GLfloat y ); - void (GLAPIENTRYP VertexAttrib2fvNV)( GLuint index, const GLfloat *v ); - void (GLAPIENTRYP VertexAttrib3fNV)( GLuint index, GLfloat x, GLfloat y, GLfloat z ); - void (GLAPIENTRYP VertexAttrib3fvNV)( GLuint index, const GLfloat *v ); - void (GLAPIENTRYP VertexAttrib4fNV)( GLuint index, GLfloat x, GLfloat y, GLfloat z, GLfloat w ); - void (GLAPIENTRYP VertexAttrib4fvNV)( GLuint index, const GLfloat *v ); - - /*@}*/ - - void (GLAPIENTRYP Rectf)( GLfloat, GLfloat, GLfloat, GLfloat ); - - /** - * \name Array - */ - /*@{*/ - void (GLAPIENTRYP DrawArrays)( GLenum mode, GLint start, GLsizei count ); - void (GLAPIENTRYP DrawElements)( GLenum mode, GLsizei count, GLenum type, - const GLvoid *indices ); - /*@}*/ - - /** - * \name Eval - * - * If you don't support eval, fallback to the default vertex format - * on receiving an eval call and use the pipeline mechanism to - * provide partial T&L acceleration. - * - * Mesa will provide a set of helper functions to do eval within - * accelerated vertex formats, eventually... - */ - /*@{*/ - void (GLAPIENTRYP EvalMesh1)( GLenum mode, GLint i1, GLint i2 ); - void (GLAPIENTRYP EvalMesh2)( GLenum mode, GLint i1, GLint i2, GLint j1, GLint j2 ); - /*@}*/ - -} GLvertexformat; - - -#endif /* DD_INCLUDED */ diff --git a/dll/opengl/mesa/main/depth.c b/dll/opengl/mesa/main/depth.c deleted file mode 100644 index f25faa4cc48..00000000000 --- a/dll/opengl/mesa/main/depth.c +++ /dev/null @@ -1,159 +0,0 @@ -/* - * Mesa 3-D graphics library - * Version: 7.1 - * - * Copyright (C) 1999-2007 Brian Paul All Rights Reserved. - * - * Permission is hereby granted, free of charge, to any person obtaining a - * copy of this software and associated documentation files (the "Software"), - * to deal in the Software without restriction, including without limitation - * the rights to use, copy, modify, merge, publish, distribute, sublicense, - * and/or sell copies of the Software, and to permit persons to whom the - * Software is furnished to do so, subject to the following conditions: - * - * The above copyright notice and this permission notice shall be included - * in all copies or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS - * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL - * BRIAN PAUL BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN - * AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN - * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. - */ - -#include - -/**********************************************************************/ -/***** API Functions *****/ -/**********************************************************************/ - - - -void GLAPIENTRY -_mesa_ClearDepth( GLclampd depth ) -{ - GET_CURRENT_CONTEXT(ctx); - ASSERT_OUTSIDE_BEGIN_END(ctx); - - if (MESA_VERBOSE & VERBOSE_API) - _mesa_debug(ctx, "glClearDepth(%f)\n", depth); - - depth = CLAMP( depth, 0.0, 1.0 ); - - if (ctx->Depth.Clear == depth) - return; - - FLUSH_VERTICES(ctx, _NEW_DEPTH); - ctx->Depth.Clear = depth; - if (ctx->Driver.ClearDepth) - (*ctx->Driver.ClearDepth)( ctx, ctx->Depth.Clear ); -} - - -void GLAPIENTRY -_mesa_DepthFunc( GLenum func ) -{ - GET_CURRENT_CONTEXT(ctx); - ASSERT_OUTSIDE_BEGIN_END(ctx); - - if (MESA_VERBOSE & VERBOSE_API) - _mesa_debug(ctx, "glDepthFunc %s\n", _mesa_lookup_enum_by_nr(func)); - - switch (func) { - case GL_LESS: /* (default) pass if incoming z < stored z */ - case GL_GEQUAL: - case GL_LEQUAL: - case GL_GREATER: - case GL_NOTEQUAL: - case GL_EQUAL: - case GL_ALWAYS: - case GL_NEVER: - break; - default: - _mesa_error( ctx, GL_INVALID_ENUM, "glDepth.Func" ); - return; - } - - if (ctx->Depth.Func == func) - return; - - FLUSH_VERTICES(ctx, _NEW_DEPTH); - ctx->Depth.Func = func; - - if (ctx->Driver.DepthFunc) - ctx->Driver.DepthFunc( ctx, func ); -} - - - -void GLAPIENTRY -_mesa_DepthMask( GLboolean flag ) -{ - GET_CURRENT_CONTEXT(ctx); - ASSERT_OUTSIDE_BEGIN_END(ctx); - - if (MESA_VERBOSE & VERBOSE_API) - _mesa_debug(ctx, "glDepthMask %d\n", flag); - - /* - * GL_TRUE indicates depth buffer writing is enabled (default) - * GL_FALSE indicates depth buffer writing is disabled - */ - if (ctx->Depth.Mask == flag) - return; - - FLUSH_VERTICES(ctx, _NEW_DEPTH); - ctx->Depth.Mask = flag; - - if (ctx->Driver.DepthMask) - ctx->Driver.DepthMask( ctx, flag ); -} - - - -/** - * Specified by the GL_EXT_depth_bounds_test extension. - */ -void GLAPIENTRY -_mesa_DepthBoundsEXT( GLclampd zmin, GLclampd zmax ) -{ - GET_CURRENT_CONTEXT(ctx); - ASSERT_OUTSIDE_BEGIN_END(ctx); - - if (MESA_VERBOSE & VERBOSE_API) - _mesa_debug(ctx, "glDepthBounds(%f, %f)\n", zmin, zmax); - - if (zmin > zmax) { - _mesa_error(ctx, GL_INVALID_VALUE, "glDepthBoundsEXT(zmin > zmax)"); - return; - } - - zmin = CLAMP(zmin, 0.0, 1.0); - zmax = CLAMP(zmax, 0.0, 1.0); - - if (ctx->Depth.BoundsMin == zmin && ctx->Depth.BoundsMax == zmax) - return; - - FLUSH_VERTICES(ctx, _NEW_DEPTH); - ctx->Depth.BoundsMin = (GLfloat) zmin; - ctx->Depth.BoundsMax = (GLfloat) zmax; -} - - -/**********************************************************************/ -/***** Initialization *****/ -/**********************************************************************/ - - -/** - * Initialize the depth buffer attribute group in the given context. - */ -void -_mesa_init_depth(struct gl_context *ctx) -{ - ctx->Depth.Test = GL_FALSE; - ctx->Depth.Clear = 1.0; - ctx->Depth.Func = GL_LESS; - ctx->Depth.Mask = GL_TRUE; -} diff --git a/dll/opengl/mesa/main/depth.h b/dll/opengl/mesa/main/depth.h deleted file mode 100644 index b498a471534..00000000000 --- a/dll/opengl/mesa/main/depth.h +++ /dev/null @@ -1,65 +0,0 @@ -/** - * \file depth.h - * Depth buffer operations. - */ - -/* - * Mesa 3-D graphics library - * Version: 6.3 - * - * Copyright (C) 1999-2005 Brian Paul All Rights Reserved. - * - * Permission is hereby granted, free of charge, to any person obtaining a - * copy of this software and associated documentation files (the "Software"), - * to deal in the Software without restriction, including without limitation - * the rights to use, copy, modify, merge, publish, distribute, sublicense, - * and/or sell copies of the Software, and to permit persons to whom the - * Software is furnished to do so, subject to the following conditions: - * - * The above copyright notice and this permission notice shall be included - * in all copies or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS - * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL - * BRIAN PAUL BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN - * AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN - * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. - */ - - -#ifndef DEPTH_H -#define DEPTH_H - - -#include "glheader.h" -#include "mfeatures.h" - -struct gl_context; - - -#if _HAVE_FULL_GL - -extern void GLAPIENTRY -_mesa_ClearDepth( GLclampd depth ); - -extern void GLAPIENTRY -_mesa_DepthFunc( GLenum func ); - -extern void GLAPIENTRY -_mesa_DepthMask( GLboolean flag ); - -extern void GLAPIENTRY -_mesa_DepthBoundsEXT( GLclampd zmin, GLclampd zmax ); - -extern void -_mesa_init_depth( struct gl_context * ctx ); - -#else - -/** No-op */ -#define _mesa_init_depth( c ) ((void)0) - -#endif - -#endif diff --git a/dll/opengl/mesa/main/dispatch.h b/dll/opengl/mesa/main/dispatch.h deleted file mode 100644 index 049585ba5ae..00000000000 --- a/dll/opengl/mesa/main/dispatch.h +++ /dev/null @@ -1,5833 +0,0 @@ -/* DO NOT EDIT - This file generated automatically by gl_table.py (from Mesa) script */ - -/* - * (C) Copyright IBM Corporation 2005 - * All Rights Reserved. - * - * Permission is hereby granted, free of charge, to any person obtaining a - * copy of this software and associated documentation files (the "Software"), - * to deal in the Software without restriction, including without limitation - * the rights to use, copy, modify, merge, publish, distribute, sub license, - * and/or sell copies of the Software, and to permit persons to whom the - * Software is furnished to do so, subject to the following conditions: - * - * The above copyright notice and this permission notice (including the next - * paragraph) shall be included in all copies or substantial portions of the - * Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR - * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT. IN NO EVENT SHALL - * IBM, - * AND/OR THEIR SUPPLIERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, - * WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF - * OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE - * SOFTWARE. - */ - -#if !defined( _DISPATCH_H_ ) -# define _DISPATCH_H_ - -typedef PROC _glapi_proc; - - -/** - * \file main/dispatch.h - * Macros for handling GL dispatch tables. - * - * For each known GL function, there are 3 macros in this file. The first - * macro is named CALL_FuncName and is used to call that GL function using - * the specified dispatch table. The other 2 macros, called GET_FuncName - * can SET_FuncName, are used to get and set the dispatch pointer for the - * named function in the specified dispatch table. - */ - -/* GLXEXT is defined when building the GLX extension in the xserver. - */ -#if !defined(GLXEXT) -#include "main/mfeatures.h" -#endif - -#define CALL_by_offset(disp, cast, offset, parameters) \ - (*(cast (GET_by_offset(disp, offset)))) parameters -#define GET_by_offset(disp, offset) \ - (offset >= 0) ? (((_glapi_proc *)(disp))[offset]) : NULL -#define SET_by_offset(disp, offset, fn) \ - do { \ - if ( (offset) < 0 ) { \ - /* fprintf( stderr, "[%s:%u] SET_by_offset(%p, %d, %s)!\n", */ \ - /* __func__, __LINE__, disp, offset, # fn); */ \ - /* abort(); */ \ - } \ - else { \ - ( (_glapi_proc *) (disp) )[offset] = (_glapi_proc) fn; \ - } \ - } while(0) - -/* total number of offsets below */ -#define _gloffset_COUNT 973 - -#define _gloffset_NewList 0 -#define _gloffset_EndList 1 -#define _gloffset_CallList 2 -#define _gloffset_CallLists 3 -#define _gloffset_DeleteLists 4 -#define _gloffset_GenLists 5 -#define _gloffset_ListBase 6 -#define _gloffset_Begin 7 -#define _gloffset_Bitmap 8 -#define _gloffset_Color3b 9 -#define _gloffset_Color3bv 10 -#define _gloffset_Color3d 11 -#define _gloffset_Color3dv 12 -#define _gloffset_Color3f 13 -#define _gloffset_Color3fv 14 -#define _gloffset_Color3i 15 -#define _gloffset_Color3iv 16 -#define _gloffset_Color3s 17 -#define _gloffset_Color3sv 18 -#define _gloffset_Color3ub 19 -#define _gloffset_Color3ubv 20 -#define _gloffset_Color3ui 21 -#define _gloffset_Color3uiv 22 -#define _gloffset_Color3us 23 -#define _gloffset_Color3usv 24 -#define _gloffset_Color4b 25 -#define _gloffset_Color4bv 26 -#define _gloffset_Color4d 27 -#define _gloffset_Color4dv 28 -#define _gloffset_Color4f 29 -#define _gloffset_Color4fv 30 -#define _gloffset_Color4i 31 -#define _gloffset_Color4iv 32 -#define _gloffset_Color4s 33 -#define _gloffset_Color4sv 34 -#define _gloffset_Color4ub 35 -#define _gloffset_Color4ubv 36 -#define _gloffset_Color4ui 37 -#define _gloffset_Color4uiv 38 -#define _gloffset_Color4us 39 -#define _gloffset_Color4usv 40 -#define _gloffset_EdgeFlag 41 -#define _gloffset_EdgeFlagv 42 -#define _gloffset_End 43 -#define _gloffset_Indexd 44 -#define _gloffset_Indexdv 45 -#define _gloffset_Indexf 46 -#define _gloffset_Indexfv 47 -#define _gloffset_Indexi 48 -#define _gloffset_Indexiv 49 -#define _gloffset_Indexs 50 -#define _gloffset_Indexsv 51 -#define _gloffset_Normal3b 52 -#define _gloffset_Normal3bv 53 -#define _gloffset_Normal3d 54 -#define _gloffset_Normal3dv 55 -#define _gloffset_Normal3f 56 -#define _gloffset_Normal3fv 57 -#define _gloffset_Normal3i 58 -#define _gloffset_Normal3iv 59 -#define _gloffset_Normal3s 60 -#define _gloffset_Normal3sv 61 -#define _gloffset_RasterPos2d 62 -#define _gloffset_RasterPos2dv 63 -#define _gloffset_RasterPos2f 64 -#define _gloffset_RasterPos2fv 65 -#define _gloffset_RasterPos2i 66 -#define _gloffset_RasterPos2iv 67 -#define _gloffset_RasterPos2s 68 -#define _gloffset_RasterPos2sv 69 -#define _gloffset_RasterPos3d 70 -#define _gloffset_RasterPos3dv 71 -#define _gloffset_RasterPos3f 72 -#define _gloffset_RasterPos3fv 73 -#define _gloffset_RasterPos3i 74 -#define _gloffset_RasterPos3iv 75 -#define _gloffset_RasterPos3s 76 -#define _gloffset_RasterPos3sv 77 -#define _gloffset_RasterPos4d 78 -#define _gloffset_RasterPos4dv 79 -#define _gloffset_RasterPos4f 80 -#define _gloffset_RasterPos4fv 81 -#define _gloffset_RasterPos4i 82 -#define _gloffset_RasterPos4iv 83 -#define _gloffset_RasterPos4s 84 -#define _gloffset_RasterPos4sv 85 -#define _gloffset_Rectd 86 -#define _gloffset_Rectdv 87 -#define _gloffset_Rectf 88 -#define _gloffset_Rectfv 89 -#define _gloffset_Recti 90 -#define _gloffset_Rectiv 91 -#define _gloffset_Rects 92 -#define _gloffset_Rectsv 93 -#define _gloffset_TexCoord1d 94 -#define _gloffset_TexCoord1dv 95 -#define _gloffset_TexCoord1f 96 -#define _gloffset_TexCoord1fv 97 -#define _gloffset_TexCoord1i 98 -#define _gloffset_TexCoord1iv 99 -#define _gloffset_TexCoord1s 100 -#define _gloffset_TexCoord1sv 101 -#define _gloffset_TexCoord2d 102 -#define _gloffset_TexCoord2dv 103 -#define _gloffset_TexCoord2f 104 -#define _gloffset_TexCoord2fv 105 -#define _gloffset_TexCoord2i 106 -#define _gloffset_TexCoord2iv 107 -#define _gloffset_TexCoord2s 108 -#define _gloffset_TexCoord2sv 109 -#define _gloffset_TexCoord3d 110 -#define _gloffset_TexCoord3dv 111 -#define _gloffset_TexCoord3f 112 -#define _gloffset_TexCoord3fv 113 -#define _gloffset_TexCoord3i 114 -#define _gloffset_TexCoord3iv 115 -#define _gloffset_TexCoord3s 116 -#define _gloffset_TexCoord3sv 117 -#define _gloffset_TexCoord4d 118 -#define _gloffset_TexCoord4dv 119 -#define _gloffset_TexCoord4f 120 -#define _gloffset_TexCoord4fv 121 -#define _gloffset_TexCoord4i 122 -#define _gloffset_TexCoord4iv 123 -#define _gloffset_TexCoord4s 124 -#define _gloffset_TexCoord4sv 125 -#define _gloffset_Vertex2d 126 -#define _gloffset_Vertex2dv 127 -#define _gloffset_Vertex2f 128 -#define _gloffset_Vertex2fv 129 -#define _gloffset_Vertex2i 130 -#define _gloffset_Vertex2iv 131 -#define _gloffset_Vertex2s 132 -#define _gloffset_Vertex2sv 133 -#define _gloffset_Vertex3d 134 -#define _gloffset_Vertex3dv 135 -#define _gloffset_Vertex3f 136 -#define _gloffset_Vertex3fv 137 -#define _gloffset_Vertex3i 138 -#define _gloffset_Vertex3iv 139 -#define _gloffset_Vertex3s 140 -#define _gloffset_Vertex3sv 141 -#define _gloffset_Vertex4d 142 -#define _gloffset_Vertex4dv 143 -#define _gloffset_Vertex4f 144 -#define _gloffset_Vertex4fv 145 -#define _gloffset_Vertex4i 146 -#define _gloffset_Vertex4iv 147 -#define _gloffset_Vertex4s 148 -#define _gloffset_Vertex4sv 149 -#define _gloffset_ClipPlane 150 -#define _gloffset_ColorMaterial 151 -#define _gloffset_CullFace 152 -#define _gloffset_Fogf 153 -#define _gloffset_Fogfv 154 -#define _gloffset_Fogi 155 -#define _gloffset_Fogiv 156 -#define _gloffset_FrontFace 157 -#define _gloffset_Hint 158 -#define _gloffset_Lightf 159 -#define _gloffset_Lightfv 160 -#define _gloffset_Lighti 161 -#define _gloffset_Lightiv 162 -#define _gloffset_LightModelf 163 -#define _gloffset_LightModelfv 164 -#define _gloffset_LightModeli 165 -#define _gloffset_LightModeliv 166 -#define _gloffset_LineStipple 167 -#define _gloffset_LineWidth 168 -#define _gloffset_Materialf 169 -#define _gloffset_Materialfv 170 -#define _gloffset_Materiali 171 -#define _gloffset_Materialiv 172 -#define _gloffset_PointSize 173 -#define _gloffset_PolygonMode 174 -#define _gloffset_PolygonStipple 175 -#define _gloffset_Scissor 176 -#define _gloffset_ShadeModel 177 -#define _gloffset_TexParameterf 178 -#define _gloffset_TexParameterfv 179 -#define _gloffset_TexParameteri 180 -#define _gloffset_TexParameteriv 181 -#define _gloffset_TexImage1D 182 -#define _gloffset_TexImage2D 183 -#define _gloffset_TexEnvf 184 -#define _gloffset_TexEnvfv 185 -#define _gloffset_TexEnvi 186 -#define _gloffset_TexEnviv 187 -#define _gloffset_TexGend 188 -#define _gloffset_TexGendv 189 -#define _gloffset_TexGenf 190 -#define _gloffset_TexGenfv 191 -#define _gloffset_TexGeni 192 -#define _gloffset_TexGeniv 193 -#define _gloffset_FeedbackBuffer 194 -#define _gloffset_SelectBuffer 195 -#define _gloffset_RenderMode 196 -#define _gloffset_InitNames 197 -#define _gloffset_LoadName 198 -#define _gloffset_PassThrough 199 -#define _gloffset_PopName 200 -#define _gloffset_PushName 201 -#define _gloffset_DrawBuffer 202 -#define _gloffset_Clear 203 -#define _gloffset_ClearAccum 204 -#define _gloffset_ClearIndex 205 -#define _gloffset_ClearColor 206 -#define _gloffset_ClearStencil 207 -#define _gloffset_ClearDepth 208 -#define _gloffset_StencilMask 209 -#define _gloffset_ColorMask 210 -#define _gloffset_DepthMask 211 -#define _gloffset_IndexMask 212 -#define _gloffset_Accum 213 -#define _gloffset_Disable 214 -#define _gloffset_Enable 215 -#define _gloffset_Finish 216 -#define _gloffset_Flush 217 -#define _gloffset_PopAttrib 218 -#define _gloffset_PushAttrib 219 -#define _gloffset_Map1d 220 -#define _gloffset_Map1f 221 -#define _gloffset_Map2d 222 -#define _gloffset_Map2f 223 -#define _gloffset_MapGrid1d 224 -#define _gloffset_MapGrid1f 225 -#define _gloffset_MapGrid2d 226 -#define _gloffset_MapGrid2f 227 -#define _gloffset_EvalCoord1d 228 -#define _gloffset_EvalCoord1dv 229 -#define _gloffset_EvalCoord1f 230 -#define _gloffset_EvalCoord1fv 231 -#define _gloffset_EvalCoord2d 232 -#define _gloffset_EvalCoord2dv 233 -#define _gloffset_EvalCoord2f 234 -#define _gloffset_EvalCoord2fv 235 -#define _gloffset_EvalMesh1 236 -#define _gloffset_EvalPoint1 237 -#define _gloffset_EvalMesh2 238 -#define _gloffset_EvalPoint2 239 -#define _gloffset_AlphaFunc 240 -#define _gloffset_BlendFunc 241 -#define _gloffset_LogicOp 242 -#define _gloffset_StencilFunc 243 -#define _gloffset_StencilOp 244 -#define _gloffset_DepthFunc 245 -#define _gloffset_PixelZoom 246 -#define _gloffset_PixelTransferf 247 -#define _gloffset_PixelTransferi 248 -#define _gloffset_PixelStoref 249 -#define _gloffset_PixelStorei 250 -#define _gloffset_PixelMapfv 251 -#define _gloffset_PixelMapuiv 252 -#define _gloffset_PixelMapusv 253 -#define _gloffset_ReadBuffer 254 -#define _gloffset_CopyPixels 255 -#define _gloffset_ReadPixels 256 -#define _gloffset_DrawPixels 257 -#define _gloffset_GetBooleanv 258 -#define _gloffset_GetClipPlane 259 -#define _gloffset_GetDoublev 260 -#define _gloffset_GetError 261 -#define _gloffset_GetFloatv 262 -#define _gloffset_GetIntegerv 263 -#define _gloffset_GetLightfv 264 -#define _gloffset_GetLightiv 265 -#define _gloffset_GetMapdv 266 -#define _gloffset_GetMapfv 267 -#define _gloffset_GetMapiv 268 -#define _gloffset_GetMaterialfv 269 -#define _gloffset_GetMaterialiv 270 -#define _gloffset_GetPixelMapfv 271 -#define _gloffset_GetPixelMapuiv 272 -#define _gloffset_GetPixelMapusv 273 -#define _gloffset_GetPolygonStipple 274 -#define _gloffset_GetString 275 -#define _gloffset_GetTexEnvfv 276 -#define _gloffset_GetTexEnviv 277 -#define _gloffset_GetTexGendv 278 -#define _gloffset_GetTexGenfv 279 -#define _gloffset_GetTexGeniv 280 -#define _gloffset_GetTexImage 281 -#define _gloffset_GetTexParameterfv 282 -#define _gloffset_GetTexParameteriv 283 -#define _gloffset_GetTexLevelParameterfv 284 -#define _gloffset_GetTexLevelParameteriv 285 -#define _gloffset_IsEnabled 286 -#define _gloffset_IsList 287 -#define _gloffset_DepthRange 288 -#define _gloffset_Frustum 289 -#define _gloffset_LoadIdentity 290 -#define _gloffset_LoadMatrixf 291 -#define _gloffset_LoadMatrixd 292 -#define _gloffset_MatrixMode 293 -#define _gloffset_MultMatrixf 294 -#define _gloffset_MultMatrixd 295 -#define _gloffset_Ortho 296 -#define _gloffset_PopMatrix 297 -#define _gloffset_PushMatrix 298 -#define _gloffset_Rotated 299 -#define _gloffset_Rotatef 300 -#define _gloffset_Scaled 301 -#define _gloffset_Scalef 302 -#define _gloffset_Translated 303 -#define _gloffset_Translatef 304 -#define _gloffset_Viewport 305 -#define _gloffset_ArrayElement 306 -#define _gloffset_BindTexture 307 -#define _gloffset_ColorPointer 308 -#define _gloffset_DisableClientState 309 -#define _gloffset_DrawArrays 310 -#define _gloffset_DrawElements 311 -#define _gloffset_EdgeFlagPointer 312 -#define _gloffset_EnableClientState 313 -#define _gloffset_IndexPointer 314 -#define _gloffset_Indexub 315 -#define _gloffset_Indexubv 316 -#define _gloffset_InterleavedArrays 317 -#define _gloffset_NormalPointer 318 -#define _gloffset_PolygonOffset 319 -#define _gloffset_TexCoordPointer 320 -#define _gloffset_VertexPointer 321 -#define _gloffset_AreTexturesResident 322 -#define _gloffset_CopyTexImage1D 323 -#define _gloffset_CopyTexImage2D 324 -#define _gloffset_CopyTexSubImage1D 325 -#define _gloffset_CopyTexSubImage2D 326 -#define _gloffset_DeleteTextures 327 -#define _gloffset_GenTextures 328 -#define _gloffset_GetPointerv 329 -#define _gloffset_IsTexture 330 -#define _gloffset_PrioritizeTextures 331 -#define _gloffset_TexSubImage1D 332 -#define _gloffset_TexSubImage2D 333 -#define _gloffset_PopClientAttrib 334 -#define _gloffset_PushClientAttrib 335 - -#define _gloffset_GetBufferParameteri64v 438 -#define _gloffset_GetInteger64i_v 439 -#define _gloffset_LoadTransposeMatrixdARB 441 -#define _gloffset_LoadTransposeMatrixfARB 442 -#define _gloffset_MultTransposeMatrixdARB 443 -#define _gloffset_MultTransposeMatrixfARB 444 -#define _gloffset_SampleCoverageARB 445 -#define _gloffset_BindBufferARB 510 -#define _gloffset_BufferDataARB 511 -#define _gloffset_BufferSubDataARB 512 -#define _gloffset_DeleteBuffersARB 513 -#define _gloffset_GenBuffersARB 514 -#define _gloffset_GetBufferParameterivARB 515 -#define _gloffset_GetBufferPointervARB 516 -#define _gloffset_GetBufferSubDataARB 517 -#define _gloffset_IsBufferARB 518 -#define _gloffset_MapBufferARB 519 -#define _gloffset_UnmapBufferARB 520 -#define _gloffset_AttachObjectARB 529 -#define _gloffset_DeleteObjectARB 533 -#define _gloffset_DetachObjectARB 534 -#define _gloffset_GetAttachedObjectsARB 536 -#define _gloffset_GetHandleARB 537 -#define _gloffset_GetInfoLogARB 538 -#define _gloffset_GetObjectParameterfvARB 539 -#define _gloffset_GetObjectParameterivARB 540 -#define _gloffset_GetActiveAttribARB 569 -#define _gloffset_FlushMappedBufferRange 580 -#define _gloffset_MapBufferRange 581 -#define _gloffset_TexStorage1D 685 -#define _gloffset_TexStorage2D 686 -#define _gloffset_TexStorage3D 687 -#define _gloffset_TextureStorage1DEXT 688 -#define _gloffset_TextureStorage2DEXT 689 -#define _gloffset_TextureStorage3DEXT 690 -#define _gloffset_PolygonOffsetEXT 691 -#define _gloffset_SampleMaskSGIS 698 -#define _gloffset_SamplePatternSGIS 699 -#define _gloffset_ColorPointerEXT 700 -#define _gloffset_EdgeFlagPointerEXT 701 -#define _gloffset_IndexPointerEXT 702 -#define _gloffset_NormalPointerEXT 703 -#define _gloffset_TexCoordPointerEXT 704 -#define _gloffset_VertexPointerEXT 705 -#define _gloffset_PointParameterfEXT 706 -#define _gloffset_PointParameterfvEXT 707 -#define _gloffset_LockArraysEXT 708 -#define _gloffset_UnlockArraysEXT 709 -#define _gloffset_FogCoordPointerEXT 729 -#define _gloffset_FogCoorddEXT 730 -#define _gloffset_FogCoorddvEXT 731 -#define _gloffset_FogCoordfEXT 732 -#define _gloffset_FogCoordfvEXT 733 -#define _gloffset_PixelTexGenSGIX 734 -#define _gloffset_FlushVertexArrayRangeNV 736 -#define _gloffset_VertexArrayRangeNV 737 -#define _gloffset_CombinerInputNV 738 -#define _gloffset_CombinerOutputNV 739 -#define _gloffset_CombinerParameterfNV 740 -#define _gloffset_CombinerParameterfvNV 741 -#define _gloffset_CombinerParameteriNV 742 -#define _gloffset_CombinerParameterivNV 743 -#define _gloffset_FinalCombinerInputNV 744 -#define _gloffset_GetCombinerInputParameterfvNV 745 -#define _gloffset_GetCombinerInputParameterivNV 746 -#define _gloffset_GetCombinerOutputParameterfvNV 747 -#define _gloffset_GetCombinerOutputParameterivNV 748 -#define _gloffset_GetFinalCombinerInputParameterfvNV 749 -#define _gloffset_GetFinalCombinerInputParameterivNV 750 -#define _gloffset_WindowPos2dMESA 752 -#define _gloffset_WindowPos2dvMESA 753 -#define _gloffset_WindowPos2fMESA 754 -#define _gloffset_WindowPos2fvMESA 755 -#define _gloffset_WindowPos2iMESA 756 -#define _gloffset_WindowPos2ivMESA 757 -#define _gloffset_WindowPos2sMESA 758 -#define _gloffset_WindowPos2svMESA 759 -#define _gloffset_WindowPos3dMESA 760 -#define _gloffset_WindowPos3dvMESA 761 -#define _gloffset_WindowPos3fMESA 762 -#define _gloffset_WindowPos3fvMESA 763 -#define _gloffset_WindowPos3iMESA 764 -#define _gloffset_WindowPos3ivMESA 765 -#define _gloffset_WindowPos3sMESA 766 -#define _gloffset_WindowPos3svMESA 767 -#define _gloffset_WindowPos4dMESA 768 -#define _gloffset_WindowPos4dvMESA 769 -#define _gloffset_WindowPos4fMESA 770 -#define _gloffset_WindowPos4fvMESA 771 -#define _gloffset_WindowPos4iMESA 772 -#define _gloffset_WindowPos4ivMESA 773 -#define _gloffset_WindowPos4sMESA 774 -#define _gloffset_WindowPos4svMESA 775 -#define _gloffset_MultiModeDrawArraysIBM 776 -#define _gloffset_MultiModeDrawElementsIBM 777 -#define _gloffset_DeleteFencesNV 778 -#define _gloffset_FinishFenceNV 779 -#define _gloffset_GenFencesNV 780 -#define _gloffset_GetFenceivNV 781 -#define _gloffset_IsFenceNV 782 -#define _gloffset_SetFenceNV 783 -#define _gloffset_TestFenceNV 784 -#define _gloffset_VertexAttrib1dNV 805 -#define _gloffset_VertexAttrib1dvNV 806 -#define _gloffset_VertexAttrib1fNV 807 -#define _gloffset_VertexAttrib1fvNV 808 -#define _gloffset_VertexAttrib1sNV 809 -#define _gloffset_VertexAttrib1svNV 810 -#define _gloffset_VertexAttrib2dNV 811 -#define _gloffset_VertexAttrib2dvNV 812 -#define _gloffset_VertexAttrib2fNV 813 -#define _gloffset_VertexAttrib2fvNV 814 -#define _gloffset_VertexAttrib2sNV 815 -#define _gloffset_VertexAttrib2svNV 816 -#define _gloffset_VertexAttrib3dNV 817 -#define _gloffset_VertexAttrib3dvNV 818 -#define _gloffset_VertexAttrib3fNV 819 -#define _gloffset_VertexAttrib3fvNV 820 -#define _gloffset_VertexAttrib3sNV 821 -#define _gloffset_VertexAttrib3svNV 822 -#define _gloffset_VertexAttrib4dNV 823 -#define _gloffset_VertexAttrib4dvNV 824 -#define _gloffset_VertexAttrib4fNV 825 -#define _gloffset_VertexAttrib4fvNV 826 -#define _gloffset_VertexAttrib4sNV 827 -#define _gloffset_VertexAttrib4svNV 828 -#define _gloffset_VertexAttrib4ubNV 829 -#define _gloffset_VertexAttrib4ubvNV 830 -#define _gloffset_PointParameteriNV 863 -#define _gloffset_PointParameterivNV 864 -#define _gloffset_ActiveStencilFaceEXT 865 -#define _gloffset_DepthBoundsEXT 878 -#define _gloffset_BufferParameteriAPPLE 898 -#define _gloffset_FlushMappedBufferRangeAPPLE 899 -#define _gloffset_BindFragDataLocationEXT 900 -#define _gloffset_GetFragDataLocationEXT 901 -#define _gloffset_ClearColorIiEXT 941 -#define _gloffset_ClearColorIuiEXT 942 -#define _gloffset_GetTexParameterIivEXT 943 -#define _gloffset_GetTexParameterIuivEXT 944 -#define _gloffset_TexParameterIivEXT 945 -#define _gloffset_TexParameterIuivEXT 946 -#define _gloffset_GetTexParameterPointervAPPLE 957 -#define _gloffset_TextureRangeAPPLE 958 - -typedef void (GLAPIENTRYP _glptr_NewList)(GLuint, GLenum); -#define CALL_NewList(disp, parameters) \ - (* GET_NewList(disp)) parameters -static inline _glptr_NewList GET_NewList(struct _glapi_table *disp) { - return (_glptr_NewList) (GET_by_offset(disp, _gloffset_NewList)); -} - -static inline void SET_NewList(struct _glapi_table *disp, void (GLAPIENTRYP fn)(GLuint, GLenum)) { - SET_by_offset(disp, _gloffset_NewList, fn); -} - -typedef void (GLAPIENTRYP _glptr_EndList)(void); -#define CALL_EndList(disp, parameters) \ - (* GET_EndList(disp)) parameters -static inline _glptr_EndList GET_EndList(struct _glapi_table *disp) { - return (_glptr_EndList) (GET_by_offset(disp, _gloffset_EndList)); -} - -static inline void SET_EndList(struct _glapi_table *disp, void (GLAPIENTRYP fn)(void)) { - SET_by_offset(disp, _gloffset_EndList, fn); -} - -typedef void (GLAPIENTRYP _glptr_CallList)(GLuint); -#define CALL_CallList(disp, parameters) \ - (* GET_CallList(disp)) parameters -static inline _glptr_CallList GET_CallList(struct _glapi_table *disp) { - return (_glptr_CallList) (GET_by_offset(disp, _gloffset_CallList)); -} - -static inline void SET_CallList(struct _glapi_table *disp, void (GLAPIENTRYP fn)(GLuint)) { - SET_by_offset(disp, _gloffset_CallList, fn); -} - -typedef void (GLAPIENTRYP _glptr_CallLists)(GLsizei, GLenum, const GLvoid *); -#define CALL_CallLists(disp, parameters) \ - (* GET_CallLists(disp)) parameters -static inline _glptr_CallLists GET_CallLists(struct _glapi_table *disp) { - return (_glptr_CallLists) (GET_by_offset(disp, _gloffset_CallLists)); -} - -static inline void SET_CallLists(struct _glapi_table *disp, void (GLAPIENTRYP fn)(GLsizei, GLenum, const GLvoid *)) { - SET_by_offset(disp, _gloffset_CallLists, fn); -} - -typedef void (GLAPIENTRYP _glptr_DeleteLists)(GLuint, GLsizei); -#define CALL_DeleteLists(disp, parameters) \ - (* GET_DeleteLists(disp)) parameters -static inline _glptr_DeleteLists GET_DeleteLists(struct _glapi_table *disp) { - return (_glptr_DeleteLists) (GET_by_offset(disp, _gloffset_DeleteLists)); -} - -static inline void SET_DeleteLists(struct _glapi_table *disp, void (GLAPIENTRYP fn)(GLuint, GLsizei)) { - SET_by_offset(disp, _gloffset_DeleteLists, fn); -} - -typedef GLuint (GLAPIENTRYP _glptr_GenLists)(GLsizei); -#define CALL_GenLists(disp, parameters) \ - (* GET_GenLists(disp)) parameters -static inline _glptr_GenLists GET_GenLists(struct _glapi_table *disp) { - return (_glptr_GenLists) (GET_by_offset(disp, _gloffset_GenLists)); -} - -static inline void SET_GenLists(struct _glapi_table *disp, GLuint (GLAPIENTRYP fn)(GLsizei)) { - SET_by_offset(disp, _gloffset_GenLists, fn); -} - -typedef void (GLAPIENTRYP _glptr_ListBase)(GLuint); -#define CALL_ListBase(disp, parameters) \ - (* GET_ListBase(disp)) parameters -static inline _glptr_ListBase GET_ListBase(struct _glapi_table *disp) { - return (_glptr_ListBase) (GET_by_offset(disp, _gloffset_ListBase)); -} - -static inline void SET_ListBase(struct _glapi_table *disp, void (GLAPIENTRYP fn)(GLuint)) { - SET_by_offset(disp, _gloffset_ListBase, fn); -} - -typedef void (GLAPIENTRYP _glptr_Begin)(GLenum); -#define CALL_Begin(disp, parameters) \ - (* GET_Begin(disp)) parameters -static inline _glptr_Begin GET_Begin(struct _glapi_table *disp) { - return (_glptr_Begin) (GET_by_offset(disp, _gloffset_Begin)); -} - -static inline void SET_Begin(struct _glapi_table *disp, void (GLAPIENTRYP fn)(GLenum)) { - SET_by_offset(disp, _gloffset_Begin, fn); -} - -typedef void (GLAPIENTRYP _glptr_Bitmap)(GLsizei, GLsizei, GLfloat, GLfloat, GLfloat, GLfloat, const GLubyte *); -#define CALL_Bitmap(disp, parameters) \ - (* GET_Bitmap(disp)) parameters -static inline _glptr_Bitmap GET_Bitmap(struct _glapi_table *disp) { - return (_glptr_Bitmap) (GET_by_offset(disp, _gloffset_Bitmap)); -} - -static inline void SET_Bitmap(struct _glapi_table *disp, void (GLAPIENTRYP fn)(GLsizei, GLsizei, GLfloat, GLfloat, GLfloat, GLfloat, const GLubyte *)) { - SET_by_offset(disp, _gloffset_Bitmap, fn); -} - -typedef void (GLAPIENTRYP _glptr_Color3b)(GLbyte, GLbyte, GLbyte); -#define CALL_Color3b(disp, parameters) \ - (* GET_Color3b(disp)) parameters -static inline _glptr_Color3b GET_Color3b(struct _glapi_table *disp) { - return (_glptr_Color3b) (GET_by_offset(disp, _gloffset_Color3b)); -} - -static inline void SET_Color3b(struct _glapi_table *disp, void (GLAPIENTRYP fn)(GLbyte, GLbyte, GLbyte)) { - SET_by_offset(disp, _gloffset_Color3b, fn); -} - -typedef void (GLAPIENTRYP _glptr_Color3bv)(const GLbyte *); -#define CALL_Color3bv(disp, parameters) \ - (* GET_Color3bv(disp)) parameters -static inline _glptr_Color3bv GET_Color3bv(struct _glapi_table *disp) { - return (_glptr_Color3bv) (GET_by_offset(disp, _gloffset_Color3bv)); -} - -static inline void SET_Color3bv(struct _glapi_table *disp, void (GLAPIENTRYP fn)(const GLbyte *)) { - SET_by_offset(disp, _gloffset_Color3bv, fn); -} - -typedef void (GLAPIENTRYP _glptr_Color3d)(GLdouble, GLdouble, GLdouble); -#define CALL_Color3d(disp, parameters) \ - (* GET_Color3d(disp)) parameters -static inline _glptr_Color3d GET_Color3d(struct _glapi_table *disp) { - return (_glptr_Color3d) (GET_by_offset(disp, _gloffset_Color3d)); -} - -static inline void SET_Color3d(struct _glapi_table *disp, void (GLAPIENTRYP fn)(GLdouble, GLdouble, GLdouble)) { - SET_by_offset(disp, _gloffset_Color3d, fn); -} - -typedef void (GLAPIENTRYP _glptr_Color3dv)(const GLdouble *); -#define CALL_Color3dv(disp, parameters) \ - (* GET_Color3dv(disp)) parameters -static inline _glptr_Color3dv GET_Color3dv(struct _glapi_table *disp) { - return (_glptr_Color3dv) (GET_by_offset(disp, _gloffset_Color3dv)); -} - -static inline void SET_Color3dv(struct _glapi_table *disp, void (GLAPIENTRYP fn)(const GLdouble *)) { - SET_by_offset(disp, _gloffset_Color3dv, fn); -} - -typedef void (GLAPIENTRYP _glptr_Color3f)(GLfloat, GLfloat, GLfloat); -#define CALL_Color3f(disp, parameters) \ - (* GET_Color3f(disp)) parameters -static inline _glptr_Color3f GET_Color3f(struct _glapi_table *disp) { - return (_glptr_Color3f) (GET_by_offset(disp, _gloffset_Color3f)); -} - -static inline void SET_Color3f(struct _glapi_table *disp, void (GLAPIENTRYP fn)(GLfloat, GLfloat, GLfloat)) { - SET_by_offset(disp, _gloffset_Color3f, fn); -} - -typedef void (GLAPIENTRYP _glptr_Color3fv)(const GLfloat *); -#define CALL_Color3fv(disp, parameters) \ - (* GET_Color3fv(disp)) parameters -static inline _glptr_Color3fv GET_Color3fv(struct _glapi_table *disp) { - return (_glptr_Color3fv) (GET_by_offset(disp, _gloffset_Color3fv)); -} - -static inline void SET_Color3fv(struct _glapi_table *disp, void (GLAPIENTRYP fn)(const GLfloat *)) { - SET_by_offset(disp, _gloffset_Color3fv, fn); -} - -typedef void (GLAPIENTRYP _glptr_Color3i)(GLint, GLint, GLint); -#define CALL_Color3i(disp, parameters) \ - (* GET_Color3i(disp)) parameters -static inline _glptr_Color3i GET_Color3i(struct _glapi_table *disp) { - return (_glptr_Color3i) (GET_by_offset(disp, _gloffset_Color3i)); -} - -static inline void SET_Color3i(struct _glapi_table *disp, void (GLAPIENTRYP fn)(GLint, GLint, GLint)) { - SET_by_offset(disp, _gloffset_Color3i, fn); -} - -typedef void (GLAPIENTRYP _glptr_Color3iv)(const GLint *); -#define CALL_Color3iv(disp, parameters) \ - (* GET_Color3iv(disp)) parameters -static inline _glptr_Color3iv GET_Color3iv(struct _glapi_table *disp) { - return (_glptr_Color3iv) (GET_by_offset(disp, _gloffset_Color3iv)); -} - -static inline void SET_Color3iv(struct _glapi_table *disp, void (GLAPIENTRYP fn)(const GLint *)) { - SET_by_offset(disp, _gloffset_Color3iv, fn); -} - -typedef void (GLAPIENTRYP _glptr_Color3s)(GLshort, GLshort, GLshort); -#define CALL_Color3s(disp, parameters) \ - (* GET_Color3s(disp)) parameters -static inline _glptr_Color3s GET_Color3s(struct _glapi_table *disp) { - return (_glptr_Color3s) (GET_by_offset(disp, _gloffset_Color3s)); -} - -static inline void SET_Color3s(struct _glapi_table *disp, void (GLAPIENTRYP fn)(GLshort, GLshort, GLshort)) { - SET_by_offset(disp, _gloffset_Color3s, fn); -} - -typedef void (GLAPIENTRYP _glptr_Color3sv)(const GLshort *); -#define CALL_Color3sv(disp, parameters) \ - (* GET_Color3sv(disp)) parameters -static inline _glptr_Color3sv GET_Color3sv(struct _glapi_table *disp) { - return (_glptr_Color3sv) (GET_by_offset(disp, _gloffset_Color3sv)); -} - -static inline void SET_Color3sv(struct _glapi_table *disp, void (GLAPIENTRYP fn)(const GLshort *)) { - SET_by_offset(disp, _gloffset_Color3sv, fn); -} - -typedef void (GLAPIENTRYP _glptr_Color3ub)(GLubyte, GLubyte, GLubyte); -#define CALL_Color3ub(disp, parameters) \ - (* GET_Color3ub(disp)) parameters -static inline _glptr_Color3ub GET_Color3ub(struct _glapi_table *disp) { - return (_glptr_Color3ub) (GET_by_offset(disp, _gloffset_Color3ub)); -} - -static inline void SET_Color3ub(struct _glapi_table *disp, void (GLAPIENTRYP fn)(GLubyte, GLubyte, GLubyte)) { - SET_by_offset(disp, _gloffset_Color3ub, fn); -} - -typedef void (GLAPIENTRYP _glptr_Color3ubv)(const GLubyte *); -#define CALL_Color3ubv(disp, parameters) \ - (* GET_Color3ubv(disp)) parameters -static inline _glptr_Color3ubv GET_Color3ubv(struct _glapi_table *disp) { - return (_glptr_Color3ubv) (GET_by_offset(disp, _gloffset_Color3ubv)); -} - -static inline void SET_Color3ubv(struct _glapi_table *disp, void (GLAPIENTRYP fn)(const GLubyte *)) { - SET_by_offset(disp, _gloffset_Color3ubv, fn); -} - -typedef void (GLAPIENTRYP _glptr_Color3ui)(GLuint, GLuint, GLuint); -#define CALL_Color3ui(disp, parameters) \ - (* GET_Color3ui(disp)) parameters -static inline _glptr_Color3ui GET_Color3ui(struct _glapi_table *disp) { - return (_glptr_Color3ui) (GET_by_offset(disp, _gloffset_Color3ui)); -} - -static inline void SET_Color3ui(struct _glapi_table *disp, void (GLAPIENTRYP fn)(GLuint, GLuint, GLuint)) { - SET_by_offset(disp, _gloffset_Color3ui, fn); -} - -typedef void (GLAPIENTRYP _glptr_Color3uiv)(const GLuint *); -#define CALL_Color3uiv(disp, parameters) \ - (* GET_Color3uiv(disp)) parameters -static inline _glptr_Color3uiv GET_Color3uiv(struct _glapi_table *disp) { - return (_glptr_Color3uiv) (GET_by_offset(disp, _gloffset_Color3uiv)); -} - -static inline void SET_Color3uiv(struct _glapi_table *disp, void (GLAPIENTRYP fn)(const GLuint *)) { - SET_by_offset(disp, _gloffset_Color3uiv, fn); -} - -typedef void (GLAPIENTRYP _glptr_Color3us)(GLushort, GLushort, GLushort); -#define CALL_Color3us(disp, parameters) \ - (* GET_Color3us(disp)) parameters -static inline _glptr_Color3us GET_Color3us(struct _glapi_table *disp) { - return (_glptr_Color3us) (GET_by_offset(disp, _gloffset_Color3us)); -} - -static inline void SET_Color3us(struct _glapi_table *disp, void (GLAPIENTRYP fn)(GLushort, GLushort, GLushort)) { - SET_by_offset(disp, _gloffset_Color3us, fn); -} - -typedef void (GLAPIENTRYP _glptr_Color3usv)(const GLushort *); -#define CALL_Color3usv(disp, parameters) \ - (* GET_Color3usv(disp)) parameters -static inline _glptr_Color3usv GET_Color3usv(struct _glapi_table *disp) { - return (_glptr_Color3usv) (GET_by_offset(disp, _gloffset_Color3usv)); -} - -static inline void SET_Color3usv(struct _glapi_table *disp, void (GLAPIENTRYP fn)(const GLushort *)) { - SET_by_offset(disp, _gloffset_Color3usv, fn); -} - -typedef void (GLAPIENTRYP _glptr_Color4b)(GLbyte, GLbyte, GLbyte, GLbyte); -#define CALL_Color4b(disp, parameters) \ - (* GET_Color4b(disp)) parameters -static inline _glptr_Color4b GET_Color4b(struct _glapi_table *disp) { - return (_glptr_Color4b) (GET_by_offset(disp, _gloffset_Color4b)); -} - -static inline void SET_Color4b(struct _glapi_table *disp, void (GLAPIENTRYP fn)(GLbyte, GLbyte, GLbyte, GLbyte)) { - SET_by_offset(disp, _gloffset_Color4b, fn); -} - -typedef void (GLAPIENTRYP _glptr_Color4bv)(const GLbyte *); -#define CALL_Color4bv(disp, parameters) \ - (* GET_Color4bv(disp)) parameters -static inline _glptr_Color4bv GET_Color4bv(struct _glapi_table *disp) { - return (_glptr_Color4bv) (GET_by_offset(disp, _gloffset_Color4bv)); -} - -static inline void SET_Color4bv(struct _glapi_table *disp, void (GLAPIENTRYP fn)(const GLbyte *)) { - SET_by_offset(disp, _gloffset_Color4bv, fn); -} - -typedef void (GLAPIENTRYP _glptr_Color4d)(GLdouble, GLdouble, GLdouble, GLdouble); -#define CALL_Color4d(disp, parameters) \ - (* GET_Color4d(disp)) parameters -static inline _glptr_Color4d GET_Color4d(struct _glapi_table *disp) { - return (_glptr_Color4d) (GET_by_offset(disp, _gloffset_Color4d)); -} - -static inline void SET_Color4d(struct _glapi_table *disp, void (GLAPIENTRYP fn)(GLdouble, GLdouble, GLdouble, GLdouble)) { - SET_by_offset(disp, _gloffset_Color4d, fn); -} - -typedef void (GLAPIENTRYP _glptr_Color4dv)(const GLdouble *); -#define CALL_Color4dv(disp, parameters) \ - (* GET_Color4dv(disp)) parameters -static inline _glptr_Color4dv GET_Color4dv(struct _glapi_table *disp) { - return (_glptr_Color4dv) (GET_by_offset(disp, _gloffset_Color4dv)); -} - -static inline void SET_Color4dv(struct _glapi_table *disp, void (GLAPIENTRYP fn)(const GLdouble *)) { - SET_by_offset(disp, _gloffset_Color4dv, fn); -} - -typedef void (GLAPIENTRYP _glptr_Color4f)(GLfloat, GLfloat, GLfloat, GLfloat); -#define CALL_Color4f(disp, parameters) \ - (* GET_Color4f(disp)) parameters -static inline _glptr_Color4f GET_Color4f(struct _glapi_table *disp) { - return (_glptr_Color4f) (GET_by_offset(disp, _gloffset_Color4f)); -} - -static inline void SET_Color4f(struct _glapi_table *disp, void (GLAPIENTRYP fn)(GLfloat, GLfloat, GLfloat, GLfloat)) { - SET_by_offset(disp, _gloffset_Color4f, fn); -} - -typedef void (GLAPIENTRYP _glptr_Color4fv)(const GLfloat *); -#define CALL_Color4fv(disp, parameters) \ - (* GET_Color4fv(disp)) parameters -static inline _glptr_Color4fv GET_Color4fv(struct _glapi_table *disp) { - return (_glptr_Color4fv) (GET_by_offset(disp, _gloffset_Color4fv)); -} - -static inline void SET_Color4fv(struct _glapi_table *disp, void (GLAPIENTRYP fn)(const GLfloat *)) { - SET_by_offset(disp, _gloffset_Color4fv, fn); -} - -typedef void (GLAPIENTRYP _glptr_Color4i)(GLint, GLint, GLint, GLint); -#define CALL_Color4i(disp, parameters) \ - (* GET_Color4i(disp)) parameters -static inline _glptr_Color4i GET_Color4i(struct _glapi_table *disp) { - return (_glptr_Color4i) (GET_by_offset(disp, _gloffset_Color4i)); -} - -static inline void SET_Color4i(struct _glapi_table *disp, void (GLAPIENTRYP fn)(GLint, GLint, GLint, GLint)) { - SET_by_offset(disp, _gloffset_Color4i, fn); -} - -typedef void (GLAPIENTRYP _glptr_Color4iv)(const GLint *); -#define CALL_Color4iv(disp, parameters) \ - (* GET_Color4iv(disp)) parameters -static inline _glptr_Color4iv GET_Color4iv(struct _glapi_table *disp) { - return (_glptr_Color4iv) (GET_by_offset(disp, _gloffset_Color4iv)); -} - -static inline void SET_Color4iv(struct _glapi_table *disp, void (GLAPIENTRYP fn)(const GLint *)) { - SET_by_offset(disp, _gloffset_Color4iv, fn); -} - -typedef void (GLAPIENTRYP _glptr_Color4s)(GLshort, GLshort, GLshort, GLshort); -#define CALL_Color4s(disp, parameters) \ - (* GET_Color4s(disp)) parameters -static inline _glptr_Color4s GET_Color4s(struct _glapi_table *disp) { - return (_glptr_Color4s) (GET_by_offset(disp, _gloffset_Color4s)); -} - -static inline void SET_Color4s(struct _glapi_table *disp, void (GLAPIENTRYP fn)(GLshort, GLshort, GLshort, GLshort)) { - SET_by_offset(disp, _gloffset_Color4s, fn); -} - -typedef void (GLAPIENTRYP _glptr_Color4sv)(const GLshort *); -#define CALL_Color4sv(disp, parameters) \ - (* GET_Color4sv(disp)) parameters -static inline _glptr_Color4sv GET_Color4sv(struct _glapi_table *disp) { - return (_glptr_Color4sv) (GET_by_offset(disp, _gloffset_Color4sv)); -} - -static inline void SET_Color4sv(struct _glapi_table *disp, void (GLAPIENTRYP fn)(const GLshort *)) { - SET_by_offset(disp, _gloffset_Color4sv, fn); -} - -typedef void (GLAPIENTRYP _glptr_Color4ub)(GLubyte, GLubyte, GLubyte, GLubyte); -#define CALL_Color4ub(disp, parameters) \ - (* GET_Color4ub(disp)) parameters -static inline _glptr_Color4ub GET_Color4ub(struct _glapi_table *disp) { - return (_glptr_Color4ub) (GET_by_offset(disp, _gloffset_Color4ub)); -} - -static inline void SET_Color4ub(struct _glapi_table *disp, void (GLAPIENTRYP fn)(GLubyte, GLubyte, GLubyte, GLubyte)) { - SET_by_offset(disp, _gloffset_Color4ub, fn); -} - -typedef void (GLAPIENTRYP _glptr_Color4ubv)(const GLubyte *); -#define CALL_Color4ubv(disp, parameters) \ - (* GET_Color4ubv(disp)) parameters -static inline _glptr_Color4ubv GET_Color4ubv(struct _glapi_table *disp) { - return (_glptr_Color4ubv) (GET_by_offset(disp, _gloffset_Color4ubv)); -} - -static inline void SET_Color4ubv(struct _glapi_table *disp, void (GLAPIENTRYP fn)(const GLubyte *)) { - SET_by_offset(disp, _gloffset_Color4ubv, fn); -} - -typedef void (GLAPIENTRYP _glptr_Color4ui)(GLuint, GLuint, GLuint, GLuint); -#define CALL_Color4ui(disp, parameters) \ - (* GET_Color4ui(disp)) parameters -static inline _glptr_Color4ui GET_Color4ui(struct _glapi_table *disp) { - return (_glptr_Color4ui) (GET_by_offset(disp, _gloffset_Color4ui)); -} - -static inline void SET_Color4ui(struct _glapi_table *disp, void (GLAPIENTRYP fn)(GLuint, GLuint, GLuint, GLuint)) { - SET_by_offset(disp, _gloffset_Color4ui, fn); -} - -typedef void (GLAPIENTRYP _glptr_Color4uiv)(const GLuint *); -#define CALL_Color4uiv(disp, parameters) \ - (* GET_Color4uiv(disp)) parameters -static inline _glptr_Color4uiv GET_Color4uiv(struct _glapi_table *disp) { - return (_glptr_Color4uiv) (GET_by_offset(disp, _gloffset_Color4uiv)); -} - -static inline void SET_Color4uiv(struct _glapi_table *disp, void (GLAPIENTRYP fn)(const GLuint *)) { - SET_by_offset(disp, _gloffset_Color4uiv, fn); -} - -typedef void (GLAPIENTRYP _glptr_Color4us)(GLushort, GLushort, GLushort, GLushort); -#define CALL_Color4us(disp, parameters) \ - (* GET_Color4us(disp)) parameters -static inline _glptr_Color4us GET_Color4us(struct _glapi_table *disp) { - return (_glptr_Color4us) (GET_by_offset(disp, _gloffset_Color4us)); -} - -static inline void SET_Color4us(struct _glapi_table *disp, void (GLAPIENTRYP fn)(GLushort, GLushort, GLushort, GLushort)) { - SET_by_offset(disp, _gloffset_Color4us, fn); -} - -typedef void (GLAPIENTRYP _glptr_Color4usv)(const GLushort *); -#define CALL_Color4usv(disp, parameters) \ - (* GET_Color4usv(disp)) parameters -static inline _glptr_Color4usv GET_Color4usv(struct _glapi_table *disp) { - return (_glptr_Color4usv) (GET_by_offset(disp, _gloffset_Color4usv)); -} - -static inline void SET_Color4usv(struct _glapi_table *disp, void (GLAPIENTRYP fn)(const GLushort *)) { - SET_by_offset(disp, _gloffset_Color4usv, fn); -} - -typedef void (GLAPIENTRYP _glptr_EdgeFlag)(GLboolean); -#define CALL_EdgeFlag(disp, parameters) \ - (* GET_EdgeFlag(disp)) parameters -static inline _glptr_EdgeFlag GET_EdgeFlag(struct _glapi_table *disp) { - return (_glptr_EdgeFlag) (GET_by_offset(disp, _gloffset_EdgeFlag)); -} - -static inline void SET_EdgeFlag(struct _glapi_table *disp, void (GLAPIENTRYP fn)(GLboolean)) { - SET_by_offset(disp, _gloffset_EdgeFlag, fn); -} - -typedef void (GLAPIENTRYP _glptr_EdgeFlagv)(const GLboolean *); -#define CALL_EdgeFlagv(disp, parameters) \ - (* GET_EdgeFlagv(disp)) parameters -static inline _glptr_EdgeFlagv GET_EdgeFlagv(struct _glapi_table *disp) { - return (_glptr_EdgeFlagv) (GET_by_offset(disp, _gloffset_EdgeFlagv)); -} - -static inline void SET_EdgeFlagv(struct _glapi_table *disp, void (GLAPIENTRYP fn)(const GLboolean *)) { - SET_by_offset(disp, _gloffset_EdgeFlagv, fn); -} - -typedef void (GLAPIENTRYP _glptr_End)(void); -#define CALL_End(disp, parameters) \ - (* GET_End(disp)) parameters -static inline _glptr_End GET_End(struct _glapi_table *disp) { - return (_glptr_End) (GET_by_offset(disp, _gloffset_End)); -} - -static inline void SET_End(struct _glapi_table *disp, void (GLAPIENTRYP fn)(void)) { - SET_by_offset(disp, _gloffset_End, fn); -} - -typedef void (GLAPIENTRYP _glptr_Indexd)(GLdouble); -#define CALL_Indexd(disp, parameters) \ - (* GET_Indexd(disp)) parameters -static inline _glptr_Indexd GET_Indexd(struct _glapi_table *disp) { - return (_glptr_Indexd) (GET_by_offset(disp, _gloffset_Indexd)); -} - -static inline void SET_Indexd(struct _glapi_table *disp, void (GLAPIENTRYP fn)(GLdouble)) { - SET_by_offset(disp, _gloffset_Indexd, fn); -} - -typedef void (GLAPIENTRYP _glptr_Indexdv)(const GLdouble *); -#define CALL_Indexdv(disp, parameters) \ - (* GET_Indexdv(disp)) parameters -static inline _glptr_Indexdv GET_Indexdv(struct _glapi_table *disp) { - return (_glptr_Indexdv) (GET_by_offset(disp, _gloffset_Indexdv)); -} - -static inline void SET_Indexdv(struct _glapi_table *disp, void (GLAPIENTRYP fn)(const GLdouble *)) { - SET_by_offset(disp, _gloffset_Indexdv, fn); -} - -typedef void (GLAPIENTRYP _glptr_Indexf)(GLfloat); -#define CALL_Indexf(disp, parameters) \ - (* GET_Indexf(disp)) parameters -static inline _glptr_Indexf GET_Indexf(struct _glapi_table *disp) { - return (_glptr_Indexf) (GET_by_offset(disp, _gloffset_Indexf)); -} - -static inline void SET_Indexf(struct _glapi_table *disp, void (GLAPIENTRYP fn)(GLfloat)) { - SET_by_offset(disp, _gloffset_Indexf, fn); -} - -typedef void (GLAPIENTRYP _glptr_Indexfv)(const GLfloat *); -#define CALL_Indexfv(disp, parameters) \ - (* GET_Indexfv(disp)) parameters -static inline _glptr_Indexfv GET_Indexfv(struct _glapi_table *disp) { - return (_glptr_Indexfv) (GET_by_offset(disp, _gloffset_Indexfv)); -} - -static inline void SET_Indexfv(struct _glapi_table *disp, void (GLAPIENTRYP fn)(const GLfloat *)) { - SET_by_offset(disp, _gloffset_Indexfv, fn); -} - -typedef void (GLAPIENTRYP _glptr_Indexi)(GLint); -#define CALL_Indexi(disp, parameters) \ - (* GET_Indexi(disp)) parameters -static inline _glptr_Indexi GET_Indexi(struct _glapi_table *disp) { - return (_glptr_Indexi) (GET_by_offset(disp, _gloffset_Indexi)); -} - -static inline void SET_Indexi(struct _glapi_table *disp, void (GLAPIENTRYP fn)(GLint)) { - SET_by_offset(disp, _gloffset_Indexi, fn); -} - -typedef void (GLAPIENTRYP _glptr_Indexiv)(const GLint *); -#define CALL_Indexiv(disp, parameters) \ - (* GET_Indexiv(disp)) parameters -static inline _glptr_Indexiv GET_Indexiv(struct _glapi_table *disp) { - return (_glptr_Indexiv) (GET_by_offset(disp, _gloffset_Indexiv)); -} - -static inline void SET_Indexiv(struct _glapi_table *disp, void (GLAPIENTRYP fn)(const GLint *)) { - SET_by_offset(disp, _gloffset_Indexiv, fn); -} - -typedef void (GLAPIENTRYP _glptr_Indexs)(GLshort); -#define CALL_Indexs(disp, parameters) \ - (* GET_Indexs(disp)) parameters -static inline _glptr_Indexs GET_Indexs(struct _glapi_table *disp) { - return (_glptr_Indexs) (GET_by_offset(disp, _gloffset_Indexs)); -} - -static inline void SET_Indexs(struct _glapi_table *disp, void (GLAPIENTRYP fn)(GLshort)) { - SET_by_offset(disp, _gloffset_Indexs, fn); -} - -typedef void (GLAPIENTRYP _glptr_Indexsv)(const GLshort *); -#define CALL_Indexsv(disp, parameters) \ - (* GET_Indexsv(disp)) parameters -static inline _glptr_Indexsv GET_Indexsv(struct _glapi_table *disp) { - return (_glptr_Indexsv) (GET_by_offset(disp, _gloffset_Indexsv)); -} - -static inline void SET_Indexsv(struct _glapi_table *disp, void (GLAPIENTRYP fn)(const GLshort *)) { - SET_by_offset(disp, _gloffset_Indexsv, fn); -} - -typedef void (GLAPIENTRYP _glptr_Normal3b)(GLbyte, GLbyte, GLbyte); -#define CALL_Normal3b(disp, parameters) \ - (* GET_Normal3b(disp)) parameters -static inline _glptr_Normal3b GET_Normal3b(struct _glapi_table *disp) { - return (_glptr_Normal3b) (GET_by_offset(disp, _gloffset_Normal3b)); -} - -static inline void SET_Normal3b(struct _glapi_table *disp, void (GLAPIENTRYP fn)(GLbyte, GLbyte, GLbyte)) { - SET_by_offset(disp, _gloffset_Normal3b, fn); -} - -typedef void (GLAPIENTRYP _glptr_Normal3bv)(const GLbyte *); -#define CALL_Normal3bv(disp, parameters) \ - (* GET_Normal3bv(disp)) parameters -static inline _glptr_Normal3bv GET_Normal3bv(struct _glapi_table *disp) { - return (_glptr_Normal3bv) (GET_by_offset(disp, _gloffset_Normal3bv)); -} - -static inline void SET_Normal3bv(struct _glapi_table *disp, void (GLAPIENTRYP fn)(const GLbyte *)) { - SET_by_offset(disp, _gloffset_Normal3bv, fn); -} - -typedef void (GLAPIENTRYP _glptr_Normal3d)(GLdouble, GLdouble, GLdouble); -#define CALL_Normal3d(disp, parameters) \ - (* GET_Normal3d(disp)) parameters -static inline _glptr_Normal3d GET_Normal3d(struct _glapi_table *disp) { - return (_glptr_Normal3d) (GET_by_offset(disp, _gloffset_Normal3d)); -} - -static inline void SET_Normal3d(struct _glapi_table *disp, void (GLAPIENTRYP fn)(GLdouble, GLdouble, GLdouble)) { - SET_by_offset(disp, _gloffset_Normal3d, fn); -} - -typedef void (GLAPIENTRYP _glptr_Normal3dv)(const GLdouble *); -#define CALL_Normal3dv(disp, parameters) \ - (* GET_Normal3dv(disp)) parameters -static inline _glptr_Normal3dv GET_Normal3dv(struct _glapi_table *disp) { - return (_glptr_Normal3dv) (GET_by_offset(disp, _gloffset_Normal3dv)); -} - -static inline void SET_Normal3dv(struct _glapi_table *disp, void (GLAPIENTRYP fn)(const GLdouble *)) { - SET_by_offset(disp, _gloffset_Normal3dv, fn); -} - -typedef void (GLAPIENTRYP _glptr_Normal3f)(GLfloat, GLfloat, GLfloat); -#define CALL_Normal3f(disp, parameters) \ - (* GET_Normal3f(disp)) parameters -static inline _glptr_Normal3f GET_Normal3f(struct _glapi_table *disp) { - return (_glptr_Normal3f) (GET_by_offset(disp, _gloffset_Normal3f)); -} - -static inline void SET_Normal3f(struct _glapi_table *disp, void (GLAPIENTRYP fn)(GLfloat, GLfloat, GLfloat)) { - SET_by_offset(disp, _gloffset_Normal3f, fn); -} - -typedef void (GLAPIENTRYP _glptr_Normal3fv)(const GLfloat *); -#define CALL_Normal3fv(disp, parameters) \ - (* GET_Normal3fv(disp)) parameters -static inline _glptr_Normal3fv GET_Normal3fv(struct _glapi_table *disp) { - return (_glptr_Normal3fv) (GET_by_offset(disp, _gloffset_Normal3fv)); -} - -static inline void SET_Normal3fv(struct _glapi_table *disp, void (GLAPIENTRYP fn)(const GLfloat *)) { - SET_by_offset(disp, _gloffset_Normal3fv, fn); -} - -typedef void (GLAPIENTRYP _glptr_Normal3i)(GLint, GLint, GLint); -#define CALL_Normal3i(disp, parameters) \ - (* GET_Normal3i(disp)) parameters -static inline _glptr_Normal3i GET_Normal3i(struct _glapi_table *disp) { - return (_glptr_Normal3i) (GET_by_offset(disp, _gloffset_Normal3i)); -} - -static inline void SET_Normal3i(struct _glapi_table *disp, void (GLAPIENTRYP fn)(GLint, GLint, GLint)) { - SET_by_offset(disp, _gloffset_Normal3i, fn); -} - -typedef void (GLAPIENTRYP _glptr_Normal3iv)(const GLint *); -#define CALL_Normal3iv(disp, parameters) \ - (* GET_Normal3iv(disp)) parameters -static inline _glptr_Normal3iv GET_Normal3iv(struct _glapi_table *disp) { - return (_glptr_Normal3iv) (GET_by_offset(disp, _gloffset_Normal3iv)); -} - -static inline void SET_Normal3iv(struct _glapi_table *disp, void (GLAPIENTRYP fn)(const GLint *)) { - SET_by_offset(disp, _gloffset_Normal3iv, fn); -} - -typedef void (GLAPIENTRYP _glptr_Normal3s)(GLshort, GLshort, GLshort); -#define CALL_Normal3s(disp, parameters) \ - (* GET_Normal3s(disp)) parameters -static inline _glptr_Normal3s GET_Normal3s(struct _glapi_table *disp) { - return (_glptr_Normal3s) (GET_by_offset(disp, _gloffset_Normal3s)); -} - -static inline void SET_Normal3s(struct _glapi_table *disp, void (GLAPIENTRYP fn)(GLshort, GLshort, GLshort)) { - SET_by_offset(disp, _gloffset_Normal3s, fn); -} - -typedef void (GLAPIENTRYP _glptr_Normal3sv)(const GLshort *); -#define CALL_Normal3sv(disp, parameters) \ - (* GET_Normal3sv(disp)) parameters -static inline _glptr_Normal3sv GET_Normal3sv(struct _glapi_table *disp) { - return (_glptr_Normal3sv) (GET_by_offset(disp, _gloffset_Normal3sv)); -} - -static inline void SET_Normal3sv(struct _glapi_table *disp, void (GLAPIENTRYP fn)(const GLshort *)) { - SET_by_offset(disp, _gloffset_Normal3sv, fn); -} - -typedef void (GLAPIENTRYP _glptr_RasterPos2d)(GLdouble, GLdouble); -#define CALL_RasterPos2d(disp, parameters) \ - (* GET_RasterPos2d(disp)) parameters -static inline _glptr_RasterPos2d GET_RasterPos2d(struct _glapi_table *disp) { - return (_glptr_RasterPos2d) (GET_by_offset(disp, _gloffset_RasterPos2d)); -} - -static inline void SET_RasterPos2d(struct _glapi_table *disp, void (GLAPIENTRYP fn)(GLdouble, GLdouble)) { - SET_by_offset(disp, _gloffset_RasterPos2d, fn); -} - -typedef void (GLAPIENTRYP _glptr_RasterPos2dv)(const GLdouble *); -#define CALL_RasterPos2dv(disp, parameters) \ - (* GET_RasterPos2dv(disp)) parameters -static inline _glptr_RasterPos2dv GET_RasterPos2dv(struct _glapi_table *disp) { - return (_glptr_RasterPos2dv) (GET_by_offset(disp, _gloffset_RasterPos2dv)); -} - -static inline void SET_RasterPos2dv(struct _glapi_table *disp, void (GLAPIENTRYP fn)(const GLdouble *)) { - SET_by_offset(disp, _gloffset_RasterPos2dv, fn); -} - -typedef void (GLAPIENTRYP _glptr_RasterPos2f)(GLfloat, GLfloat); -#define CALL_RasterPos2f(disp, parameters) \ - (* GET_RasterPos2f(disp)) parameters -static inline _glptr_RasterPos2f GET_RasterPos2f(struct _glapi_table *disp) { - return (_glptr_RasterPos2f) (GET_by_offset(disp, _gloffset_RasterPos2f)); -} - -static inline void SET_RasterPos2f(struct _glapi_table *disp, void (GLAPIENTRYP fn)(GLfloat, GLfloat)) { - SET_by_offset(disp, _gloffset_RasterPos2f, fn); -} - -typedef void (GLAPIENTRYP _glptr_RasterPos2fv)(const GLfloat *); -#define CALL_RasterPos2fv(disp, parameters) \ - (* GET_RasterPos2fv(disp)) parameters -static inline _glptr_RasterPos2fv GET_RasterPos2fv(struct _glapi_table *disp) { - return (_glptr_RasterPos2fv) (GET_by_offset(disp, _gloffset_RasterPos2fv)); -} - -static inline void SET_RasterPos2fv(struct _glapi_table *disp, void (GLAPIENTRYP fn)(const GLfloat *)) { - SET_by_offset(disp, _gloffset_RasterPos2fv, fn); -} - -typedef void (GLAPIENTRYP _glptr_RasterPos2i)(GLint, GLint); -#define CALL_RasterPos2i(disp, parameters) \ - (* GET_RasterPos2i(disp)) parameters -static inline _glptr_RasterPos2i GET_RasterPos2i(struct _glapi_table *disp) { - return (_glptr_RasterPos2i) (GET_by_offset(disp, _gloffset_RasterPos2i)); -} - -static inline void SET_RasterPos2i(struct _glapi_table *disp, void (GLAPIENTRYP fn)(GLint, GLint)) { - SET_by_offset(disp, _gloffset_RasterPos2i, fn); -} - -typedef void (GLAPIENTRYP _glptr_RasterPos2iv)(const GLint *); -#define CALL_RasterPos2iv(disp, parameters) \ - (* GET_RasterPos2iv(disp)) parameters -static inline _glptr_RasterPos2iv GET_RasterPos2iv(struct _glapi_table *disp) { - return (_glptr_RasterPos2iv) (GET_by_offset(disp, _gloffset_RasterPos2iv)); -} - -static inline void SET_RasterPos2iv(struct _glapi_table *disp, void (GLAPIENTRYP fn)(const GLint *)) { - SET_by_offset(disp, _gloffset_RasterPos2iv, fn); -} - -typedef void (GLAPIENTRYP _glptr_RasterPos2s)(GLshort, GLshort); -#define CALL_RasterPos2s(disp, parameters) \ - (* GET_RasterPos2s(disp)) parameters -static inline _glptr_RasterPos2s GET_RasterPos2s(struct _glapi_table *disp) { - return (_glptr_RasterPos2s) (GET_by_offset(disp, _gloffset_RasterPos2s)); -} - -static inline void SET_RasterPos2s(struct _glapi_table *disp, void (GLAPIENTRYP fn)(GLshort, GLshort)) { - SET_by_offset(disp, _gloffset_RasterPos2s, fn); -} - -typedef void (GLAPIENTRYP _glptr_RasterPos2sv)(const GLshort *); -#define CALL_RasterPos2sv(disp, parameters) \ - (* GET_RasterPos2sv(disp)) parameters -static inline _glptr_RasterPos2sv GET_RasterPos2sv(struct _glapi_table *disp) { - return (_glptr_RasterPos2sv) (GET_by_offset(disp, _gloffset_RasterPos2sv)); -} - -static inline void SET_RasterPos2sv(struct _glapi_table *disp, void (GLAPIENTRYP fn)(const GLshort *)) { - SET_by_offset(disp, _gloffset_RasterPos2sv, fn); -} - -typedef void (GLAPIENTRYP _glptr_RasterPos3d)(GLdouble, GLdouble, GLdouble); -#define CALL_RasterPos3d(disp, parameters) \ - (* GET_RasterPos3d(disp)) parameters -static inline _glptr_RasterPos3d GET_RasterPos3d(struct _glapi_table *disp) { - return (_glptr_RasterPos3d) (GET_by_offset(disp, _gloffset_RasterPos3d)); -} - -static inline void SET_RasterPos3d(struct _glapi_table *disp, void (GLAPIENTRYP fn)(GLdouble, GLdouble, GLdouble)) { - SET_by_offset(disp, _gloffset_RasterPos3d, fn); -} - -typedef void (GLAPIENTRYP _glptr_RasterPos3dv)(const GLdouble *); -#define CALL_RasterPos3dv(disp, parameters) \ - (* GET_RasterPos3dv(disp)) parameters -static inline _glptr_RasterPos3dv GET_RasterPos3dv(struct _glapi_table *disp) { - return (_glptr_RasterPos3dv) (GET_by_offset(disp, _gloffset_RasterPos3dv)); -} - -static inline void SET_RasterPos3dv(struct _glapi_table *disp, void (GLAPIENTRYP fn)(const GLdouble *)) { - SET_by_offset(disp, _gloffset_RasterPos3dv, fn); -} - -typedef void (GLAPIENTRYP _glptr_RasterPos3f)(GLfloat, GLfloat, GLfloat); -#define CALL_RasterPos3f(disp, parameters) \ - (* GET_RasterPos3f(disp)) parameters -static inline _glptr_RasterPos3f GET_RasterPos3f(struct _glapi_table *disp) { - return (_glptr_RasterPos3f) (GET_by_offset(disp, _gloffset_RasterPos3f)); -} - -static inline void SET_RasterPos3f(struct _glapi_table *disp, void (GLAPIENTRYP fn)(GLfloat, GLfloat, GLfloat)) { - SET_by_offset(disp, _gloffset_RasterPos3f, fn); -} - -typedef void (GLAPIENTRYP _glptr_RasterPos3fv)(const GLfloat *); -#define CALL_RasterPos3fv(disp, parameters) \ - (* GET_RasterPos3fv(disp)) parameters -static inline _glptr_RasterPos3fv GET_RasterPos3fv(struct _glapi_table *disp) { - return (_glptr_RasterPos3fv) (GET_by_offset(disp, _gloffset_RasterPos3fv)); -} - -static inline void SET_RasterPos3fv(struct _glapi_table *disp, void (GLAPIENTRYP fn)(const GLfloat *)) { - SET_by_offset(disp, _gloffset_RasterPos3fv, fn); -} - -typedef void (GLAPIENTRYP _glptr_RasterPos3i)(GLint, GLint, GLint); -#define CALL_RasterPos3i(disp, parameters) \ - (* GET_RasterPos3i(disp)) parameters -static inline _glptr_RasterPos3i GET_RasterPos3i(struct _glapi_table *disp) { - return (_glptr_RasterPos3i) (GET_by_offset(disp, _gloffset_RasterPos3i)); -} - -static inline void SET_RasterPos3i(struct _glapi_table *disp, void (GLAPIENTRYP fn)(GLint, GLint, GLint)) { - SET_by_offset(disp, _gloffset_RasterPos3i, fn); -} - -typedef void (GLAPIENTRYP _glptr_RasterPos3iv)(const GLint *); -#define CALL_RasterPos3iv(disp, parameters) \ - (* GET_RasterPos3iv(disp)) parameters -static inline _glptr_RasterPos3iv GET_RasterPos3iv(struct _glapi_table *disp) { - return (_glptr_RasterPos3iv) (GET_by_offset(disp, _gloffset_RasterPos3iv)); -} - -static inline void SET_RasterPos3iv(struct _glapi_table *disp, void (GLAPIENTRYP fn)(const GLint *)) { - SET_by_offset(disp, _gloffset_RasterPos3iv, fn); -} - -typedef void (GLAPIENTRYP _glptr_RasterPos3s)(GLshort, GLshort, GLshort); -#define CALL_RasterPos3s(disp, parameters) \ - (* GET_RasterPos3s(disp)) parameters -static inline _glptr_RasterPos3s GET_RasterPos3s(struct _glapi_table *disp) { - return (_glptr_RasterPos3s) (GET_by_offset(disp, _gloffset_RasterPos3s)); -} - -static inline void SET_RasterPos3s(struct _glapi_table *disp, void (GLAPIENTRYP fn)(GLshort, GLshort, GLshort)) { - SET_by_offset(disp, _gloffset_RasterPos3s, fn); -} - -typedef void (GLAPIENTRYP _glptr_RasterPos3sv)(const GLshort *); -#define CALL_RasterPos3sv(disp, parameters) \ - (* GET_RasterPos3sv(disp)) parameters -static inline _glptr_RasterPos3sv GET_RasterPos3sv(struct _glapi_table *disp) { - return (_glptr_RasterPos3sv) (GET_by_offset(disp, _gloffset_RasterPos3sv)); -} - -static inline void SET_RasterPos3sv(struct _glapi_table *disp, void (GLAPIENTRYP fn)(const GLshort *)) { - SET_by_offset(disp, _gloffset_RasterPos3sv, fn); -} - -typedef void (GLAPIENTRYP _glptr_RasterPos4d)(GLdouble, GLdouble, GLdouble, GLdouble); -#define CALL_RasterPos4d(disp, parameters) \ - (* GET_RasterPos4d(disp)) parameters -static inline _glptr_RasterPos4d GET_RasterPos4d(struct _glapi_table *disp) { - return (_glptr_RasterPos4d) (GET_by_offset(disp, _gloffset_RasterPos4d)); -} - -static inline void SET_RasterPos4d(struct _glapi_table *disp, void (GLAPIENTRYP fn)(GLdouble, GLdouble, GLdouble, GLdouble)) { - SET_by_offset(disp, _gloffset_RasterPos4d, fn); -} - -typedef void (GLAPIENTRYP _glptr_RasterPos4dv)(const GLdouble *); -#define CALL_RasterPos4dv(disp, parameters) \ - (* GET_RasterPos4dv(disp)) parameters -static inline _glptr_RasterPos4dv GET_RasterPos4dv(struct _glapi_table *disp) { - return (_glptr_RasterPos4dv) (GET_by_offset(disp, _gloffset_RasterPos4dv)); -} - -static inline void SET_RasterPos4dv(struct _glapi_table *disp, void (GLAPIENTRYP fn)(const GLdouble *)) { - SET_by_offset(disp, _gloffset_RasterPos4dv, fn); -} - -typedef void (GLAPIENTRYP _glptr_RasterPos4f)(GLfloat, GLfloat, GLfloat, GLfloat); -#define CALL_RasterPos4f(disp, parameters) \ - (* GET_RasterPos4f(disp)) parameters -static inline _glptr_RasterPos4f GET_RasterPos4f(struct _glapi_table *disp) { - return (_glptr_RasterPos4f) (GET_by_offset(disp, _gloffset_RasterPos4f)); -} - -static inline void SET_RasterPos4f(struct _glapi_table *disp, void (GLAPIENTRYP fn)(GLfloat, GLfloat, GLfloat, GLfloat)) { - SET_by_offset(disp, _gloffset_RasterPos4f, fn); -} - -typedef void (GLAPIENTRYP _glptr_RasterPos4fv)(const GLfloat *); -#define CALL_RasterPos4fv(disp, parameters) \ - (* GET_RasterPos4fv(disp)) parameters -static inline _glptr_RasterPos4fv GET_RasterPos4fv(struct _glapi_table *disp) { - return (_glptr_RasterPos4fv) (GET_by_offset(disp, _gloffset_RasterPos4fv)); -} - -static inline void SET_RasterPos4fv(struct _glapi_table *disp, void (GLAPIENTRYP fn)(const GLfloat *)) { - SET_by_offset(disp, _gloffset_RasterPos4fv, fn); -} - -typedef void (GLAPIENTRYP _glptr_RasterPos4i)(GLint, GLint, GLint, GLint); -#define CALL_RasterPos4i(disp, parameters) \ - (* GET_RasterPos4i(disp)) parameters -static inline _glptr_RasterPos4i GET_RasterPos4i(struct _glapi_table *disp) { - return (_glptr_RasterPos4i) (GET_by_offset(disp, _gloffset_RasterPos4i)); -} - -static inline void SET_RasterPos4i(struct _glapi_table *disp, void (GLAPIENTRYP fn)(GLint, GLint, GLint, GLint)) { - SET_by_offset(disp, _gloffset_RasterPos4i, fn); -} - -typedef void (GLAPIENTRYP _glptr_RasterPos4iv)(const GLint *); -#define CALL_RasterPos4iv(disp, parameters) \ - (* GET_RasterPos4iv(disp)) parameters -static inline _glptr_RasterPos4iv GET_RasterPos4iv(struct _glapi_table *disp) { - return (_glptr_RasterPos4iv) (GET_by_offset(disp, _gloffset_RasterPos4iv)); -} - -static inline void SET_RasterPos4iv(struct _glapi_table *disp, void (GLAPIENTRYP fn)(const GLint *)) { - SET_by_offset(disp, _gloffset_RasterPos4iv, fn); -} - -typedef void (GLAPIENTRYP _glptr_RasterPos4s)(GLshort, GLshort, GLshort, GLshort); -#define CALL_RasterPos4s(disp, parameters) \ - (* GET_RasterPos4s(disp)) parameters -static inline _glptr_RasterPos4s GET_RasterPos4s(struct _glapi_table *disp) { - return (_glptr_RasterPos4s) (GET_by_offset(disp, _gloffset_RasterPos4s)); -} - -static inline void SET_RasterPos4s(struct _glapi_table *disp, void (GLAPIENTRYP fn)(GLshort, GLshort, GLshort, GLshort)) { - SET_by_offset(disp, _gloffset_RasterPos4s, fn); -} - -typedef void (GLAPIENTRYP _glptr_RasterPos4sv)(const GLshort *); -#define CALL_RasterPos4sv(disp, parameters) \ - (* GET_RasterPos4sv(disp)) parameters -static inline _glptr_RasterPos4sv GET_RasterPos4sv(struct _glapi_table *disp) { - return (_glptr_RasterPos4sv) (GET_by_offset(disp, _gloffset_RasterPos4sv)); -} - -static inline void SET_RasterPos4sv(struct _glapi_table *disp, void (GLAPIENTRYP fn)(const GLshort *)) { - SET_by_offset(disp, _gloffset_RasterPos4sv, fn); -} - -typedef void (GLAPIENTRYP _glptr_Rectd)(GLdouble, GLdouble, GLdouble, GLdouble); -#define CALL_Rectd(disp, parameters) \ - (* GET_Rectd(disp)) parameters -static inline _glptr_Rectd GET_Rectd(struct _glapi_table *disp) { - return (_glptr_Rectd) (GET_by_offset(disp, _gloffset_Rectd)); -} - -static inline void SET_Rectd(struct _glapi_table *disp, void (GLAPIENTRYP fn)(GLdouble, GLdouble, GLdouble, GLdouble)) { - SET_by_offset(disp, _gloffset_Rectd, fn); -} - -typedef void (GLAPIENTRYP _glptr_Rectdv)(const GLdouble *, const GLdouble *); -#define CALL_Rectdv(disp, parameters) \ - (* GET_Rectdv(disp)) parameters -static inline _glptr_Rectdv GET_Rectdv(struct _glapi_table *disp) { - return (_glptr_Rectdv) (GET_by_offset(disp, _gloffset_Rectdv)); -} - -static inline void SET_Rectdv(struct _glapi_table *disp, void (GLAPIENTRYP fn)(const GLdouble *, const GLdouble *)) { - SET_by_offset(disp, _gloffset_Rectdv, fn); -} - -typedef void (GLAPIENTRYP _glptr_Rectf)(GLfloat, GLfloat, GLfloat, GLfloat); -#define CALL_Rectf(disp, parameters) \ - (* GET_Rectf(disp)) parameters -static inline _glptr_Rectf GET_Rectf(struct _glapi_table *disp) { - return (_glptr_Rectf) (GET_by_offset(disp, _gloffset_Rectf)); -} - -static inline void SET_Rectf(struct _glapi_table *disp, void (GLAPIENTRYP fn)(GLfloat, GLfloat, GLfloat, GLfloat)) { - SET_by_offset(disp, _gloffset_Rectf, fn); -} - -typedef void (GLAPIENTRYP _glptr_Rectfv)(const GLfloat *, const GLfloat *); -#define CALL_Rectfv(disp, parameters) \ - (* GET_Rectfv(disp)) parameters -static inline _glptr_Rectfv GET_Rectfv(struct _glapi_table *disp) { - return (_glptr_Rectfv) (GET_by_offset(disp, _gloffset_Rectfv)); -} - -static inline void SET_Rectfv(struct _glapi_table *disp, void (GLAPIENTRYP fn)(const GLfloat *, const GLfloat *)) { - SET_by_offset(disp, _gloffset_Rectfv, fn); -} - -typedef void (GLAPIENTRYP _glptr_Recti)(GLint, GLint, GLint, GLint); -#define CALL_Recti(disp, parameters) \ - (* GET_Recti(disp)) parameters -static inline _glptr_Recti GET_Recti(struct _glapi_table *disp) { - return (_glptr_Recti) (GET_by_offset(disp, _gloffset_Recti)); -} - -static inline void SET_Recti(struct _glapi_table *disp, void (GLAPIENTRYP fn)(GLint, GLint, GLint, GLint)) { - SET_by_offset(disp, _gloffset_Recti, fn); -} - -typedef void (GLAPIENTRYP _glptr_Rectiv)(const GLint *, const GLint *); -#define CALL_Rectiv(disp, parameters) \ - (* GET_Rectiv(disp)) parameters -static inline _glptr_Rectiv GET_Rectiv(struct _glapi_table *disp) { - return (_glptr_Rectiv) (GET_by_offset(disp, _gloffset_Rectiv)); -} - -static inline void SET_Rectiv(struct _glapi_table *disp, void (GLAPIENTRYP fn)(const GLint *, const GLint *)) { - SET_by_offset(disp, _gloffset_Rectiv, fn); -} - -typedef void (GLAPIENTRYP _glptr_Rects)(GLshort, GLshort, GLshort, GLshort); -#define CALL_Rects(disp, parameters) \ - (* GET_Rects(disp)) parameters -static inline _glptr_Rects GET_Rects(struct _glapi_table *disp) { - return (_glptr_Rects) (GET_by_offset(disp, _gloffset_Rects)); -} - -static inline void SET_Rects(struct _glapi_table *disp, void (GLAPIENTRYP fn)(GLshort, GLshort, GLshort, GLshort)) { - SET_by_offset(disp, _gloffset_Rects, fn); -} - -typedef void (GLAPIENTRYP _glptr_Rectsv)(const GLshort *, const GLshort *); -#define CALL_Rectsv(disp, parameters) \ - (* GET_Rectsv(disp)) parameters -static inline _glptr_Rectsv GET_Rectsv(struct _glapi_table *disp) { - return (_glptr_Rectsv) (GET_by_offset(disp, _gloffset_Rectsv)); -} - -static inline void SET_Rectsv(struct _glapi_table *disp, void (GLAPIENTRYP fn)(const GLshort *, const GLshort *)) { - SET_by_offset(disp, _gloffset_Rectsv, fn); -} - -typedef void (GLAPIENTRYP _glptr_TexCoord1d)(GLdouble); -#define CALL_TexCoord1d(disp, parameters) \ - (* GET_TexCoord1d(disp)) parameters -static inline _glptr_TexCoord1d GET_TexCoord1d(struct _glapi_table *disp) { - return (_glptr_TexCoord1d) (GET_by_offset(disp, _gloffset_TexCoord1d)); -} - -static inline void SET_TexCoord1d(struct _glapi_table *disp, void (GLAPIENTRYP fn)(GLdouble)) { - SET_by_offset(disp, _gloffset_TexCoord1d, fn); -} - -typedef void (GLAPIENTRYP _glptr_TexCoord1dv)(const GLdouble *); -#define CALL_TexCoord1dv(disp, parameters) \ - (* GET_TexCoord1dv(disp)) parameters -static inline _glptr_TexCoord1dv GET_TexCoord1dv(struct _glapi_table *disp) { - return (_glptr_TexCoord1dv) (GET_by_offset(disp, _gloffset_TexCoord1dv)); -} - -static inline void SET_TexCoord1dv(struct _glapi_table *disp, void (GLAPIENTRYP fn)(const GLdouble *)) { - SET_by_offset(disp, _gloffset_TexCoord1dv, fn); -} - -typedef void (GLAPIENTRYP _glptr_TexCoord1f)(GLfloat); -#define CALL_TexCoord1f(disp, parameters) \ - (* GET_TexCoord1f(disp)) parameters -static inline _glptr_TexCoord1f GET_TexCoord1f(struct _glapi_table *disp) { - return (_glptr_TexCoord1f) (GET_by_offset(disp, _gloffset_TexCoord1f)); -} - -static inline void SET_TexCoord1f(struct _glapi_table *disp, void (GLAPIENTRYP fn)(GLfloat)) { - SET_by_offset(disp, _gloffset_TexCoord1f, fn); -} - -typedef void (GLAPIENTRYP _glptr_TexCoord1fv)(const GLfloat *); -#define CALL_TexCoord1fv(disp, parameters) \ - (* GET_TexCoord1fv(disp)) parameters -static inline _glptr_TexCoord1fv GET_TexCoord1fv(struct _glapi_table *disp) { - return (_glptr_TexCoord1fv) (GET_by_offset(disp, _gloffset_TexCoord1fv)); -} - -static inline void SET_TexCoord1fv(struct _glapi_table *disp, void (GLAPIENTRYP fn)(const GLfloat *)) { - SET_by_offset(disp, _gloffset_TexCoord1fv, fn); -} - -typedef void (GLAPIENTRYP _glptr_TexCoord1i)(GLint); -#define CALL_TexCoord1i(disp, parameters) \ - (* GET_TexCoord1i(disp)) parameters -static inline _glptr_TexCoord1i GET_TexCoord1i(struct _glapi_table *disp) { - return (_glptr_TexCoord1i) (GET_by_offset(disp, _gloffset_TexCoord1i)); -} - -static inline void SET_TexCoord1i(struct _glapi_table *disp, void (GLAPIENTRYP fn)(GLint)) { - SET_by_offset(disp, _gloffset_TexCoord1i, fn); -} - -typedef void (GLAPIENTRYP _glptr_TexCoord1iv)(const GLint *); -#define CALL_TexCoord1iv(disp, parameters) \ - (* GET_TexCoord1iv(disp)) parameters -static inline _glptr_TexCoord1iv GET_TexCoord1iv(struct _glapi_table *disp) { - return (_glptr_TexCoord1iv) (GET_by_offset(disp, _gloffset_TexCoord1iv)); -} - -static inline void SET_TexCoord1iv(struct _glapi_table *disp, void (GLAPIENTRYP fn)(const GLint *)) { - SET_by_offset(disp, _gloffset_TexCoord1iv, fn); -} - -typedef void (GLAPIENTRYP _glptr_TexCoord1s)(GLshort); -#define CALL_TexCoord1s(disp, parameters) \ - (* GET_TexCoord1s(disp)) parameters -static inline _glptr_TexCoord1s GET_TexCoord1s(struct _glapi_table *disp) { - return (_glptr_TexCoord1s) (GET_by_offset(disp, _gloffset_TexCoord1s)); -} - -static inline void SET_TexCoord1s(struct _glapi_table *disp, void (GLAPIENTRYP fn)(GLshort)) { - SET_by_offset(disp, _gloffset_TexCoord1s, fn); -} - -typedef void (GLAPIENTRYP _glptr_TexCoord1sv)(const GLshort *); -#define CALL_TexCoord1sv(disp, parameters) \ - (* GET_TexCoord1sv(disp)) parameters -static inline _glptr_TexCoord1sv GET_TexCoord1sv(struct _glapi_table *disp) { - return (_glptr_TexCoord1sv) (GET_by_offset(disp, _gloffset_TexCoord1sv)); -} - -static inline void SET_TexCoord1sv(struct _glapi_table *disp, void (GLAPIENTRYP fn)(const GLshort *)) { - SET_by_offset(disp, _gloffset_TexCoord1sv, fn); -} - -typedef void (GLAPIENTRYP _glptr_TexCoord2d)(GLdouble, GLdouble); -#define CALL_TexCoord2d(disp, parameters) \ - (* GET_TexCoord2d(disp)) parameters -static inline _glptr_TexCoord2d GET_TexCoord2d(struct _glapi_table *disp) { - return (_glptr_TexCoord2d) (GET_by_offset(disp, _gloffset_TexCoord2d)); -} - -static inline void SET_TexCoord2d(struct _glapi_table *disp, void (GLAPIENTRYP fn)(GLdouble, GLdouble)) { - SET_by_offset(disp, _gloffset_TexCoord2d, fn); -} - -typedef void (GLAPIENTRYP _glptr_TexCoord2dv)(const GLdouble *); -#define CALL_TexCoord2dv(disp, parameters) \ - (* GET_TexCoord2dv(disp)) parameters -static inline _glptr_TexCoord2dv GET_TexCoord2dv(struct _glapi_table *disp) { - return (_glptr_TexCoord2dv) (GET_by_offset(disp, _gloffset_TexCoord2dv)); -} - -static inline void SET_TexCoord2dv(struct _glapi_table *disp, void (GLAPIENTRYP fn)(const GLdouble *)) { - SET_by_offset(disp, _gloffset_TexCoord2dv, fn); -} - -typedef void (GLAPIENTRYP _glptr_TexCoord2f)(GLfloat, GLfloat); -#define CALL_TexCoord2f(disp, parameters) \ - (* GET_TexCoord2f(disp)) parameters -static inline _glptr_TexCoord2f GET_TexCoord2f(struct _glapi_table *disp) { - return (_glptr_TexCoord2f) (GET_by_offset(disp, _gloffset_TexCoord2f)); -} - -static inline void SET_TexCoord2f(struct _glapi_table *disp, void (GLAPIENTRYP fn)(GLfloat, GLfloat)) { - SET_by_offset(disp, _gloffset_TexCoord2f, fn); -} - -typedef void (GLAPIENTRYP _glptr_TexCoord2fv)(const GLfloat *); -#define CALL_TexCoord2fv(disp, parameters) \ - (* GET_TexCoord2fv(disp)) parameters -static inline _glptr_TexCoord2fv GET_TexCoord2fv(struct _glapi_table *disp) { - return (_glptr_TexCoord2fv) (GET_by_offset(disp, _gloffset_TexCoord2fv)); -} - -static inline void SET_TexCoord2fv(struct _glapi_table *disp, void (GLAPIENTRYP fn)(const GLfloat *)) { - SET_by_offset(disp, _gloffset_TexCoord2fv, fn); -} - -typedef void (GLAPIENTRYP _glptr_TexCoord2i)(GLint, GLint); -#define CALL_TexCoord2i(disp, parameters) \ - (* GET_TexCoord2i(disp)) parameters -static inline _glptr_TexCoord2i GET_TexCoord2i(struct _glapi_table *disp) { - return (_glptr_TexCoord2i) (GET_by_offset(disp, _gloffset_TexCoord2i)); -} - -static inline void SET_TexCoord2i(struct _glapi_table *disp, void (GLAPIENTRYP fn)(GLint, GLint)) { - SET_by_offset(disp, _gloffset_TexCoord2i, fn); -} - -typedef void (GLAPIENTRYP _glptr_TexCoord2iv)(const GLint *); -#define CALL_TexCoord2iv(disp, parameters) \ - (* GET_TexCoord2iv(disp)) parameters -static inline _glptr_TexCoord2iv GET_TexCoord2iv(struct _glapi_table *disp) { - return (_glptr_TexCoord2iv) (GET_by_offset(disp, _gloffset_TexCoord2iv)); -} - -static inline void SET_TexCoord2iv(struct _glapi_table *disp, void (GLAPIENTRYP fn)(const GLint *)) { - SET_by_offset(disp, _gloffset_TexCoord2iv, fn); -} - -typedef void (GLAPIENTRYP _glptr_TexCoord2s)(GLshort, GLshort); -#define CALL_TexCoord2s(disp, parameters) \ - (* GET_TexCoord2s(disp)) parameters -static inline _glptr_TexCoord2s GET_TexCoord2s(struct _glapi_table *disp) { - return (_glptr_TexCoord2s) (GET_by_offset(disp, _gloffset_TexCoord2s)); -} - -static inline void SET_TexCoord2s(struct _glapi_table *disp, void (GLAPIENTRYP fn)(GLshort, GLshort)) { - SET_by_offset(disp, _gloffset_TexCoord2s, fn); -} - -typedef void (GLAPIENTRYP _glptr_TexCoord2sv)(const GLshort *); -#define CALL_TexCoord2sv(disp, parameters) \ - (* GET_TexCoord2sv(disp)) parameters -static inline _glptr_TexCoord2sv GET_TexCoord2sv(struct _glapi_table *disp) { - return (_glptr_TexCoord2sv) (GET_by_offset(disp, _gloffset_TexCoord2sv)); -} - -static inline void SET_TexCoord2sv(struct _glapi_table *disp, void (GLAPIENTRYP fn)(const GLshort *)) { - SET_by_offset(disp, _gloffset_TexCoord2sv, fn); -} - -typedef void (GLAPIENTRYP _glptr_TexCoord3d)(GLdouble, GLdouble, GLdouble); -#define CALL_TexCoord3d(disp, parameters) \ - (* GET_TexCoord3d(disp)) parameters -static inline _glptr_TexCoord3d GET_TexCoord3d(struct _glapi_table *disp) { - return (_glptr_TexCoord3d) (GET_by_offset(disp, _gloffset_TexCoord3d)); -} - -static inline void SET_TexCoord3d(struct _glapi_table *disp, void (GLAPIENTRYP fn)(GLdouble, GLdouble, GLdouble)) { - SET_by_offset(disp, _gloffset_TexCoord3d, fn); -} - -typedef void (GLAPIENTRYP _glptr_TexCoord3dv)(const GLdouble *); -#define CALL_TexCoord3dv(disp, parameters) \ - (* GET_TexCoord3dv(disp)) parameters -static inline _glptr_TexCoord3dv GET_TexCoord3dv(struct _glapi_table *disp) { - return (_glptr_TexCoord3dv) (GET_by_offset(disp, _gloffset_TexCoord3dv)); -} - -static inline void SET_TexCoord3dv(struct _glapi_table *disp, void (GLAPIENTRYP fn)(const GLdouble *)) { - SET_by_offset(disp, _gloffset_TexCoord3dv, fn); -} - -typedef void (GLAPIENTRYP _glptr_TexCoord3f)(GLfloat, GLfloat, GLfloat); -#define CALL_TexCoord3f(disp, parameters) \ - (* GET_TexCoord3f(disp)) parameters -static inline _glptr_TexCoord3f GET_TexCoord3f(struct _glapi_table *disp) { - return (_glptr_TexCoord3f) (GET_by_offset(disp, _gloffset_TexCoord3f)); -} - -static inline void SET_TexCoord3f(struct _glapi_table *disp, void (GLAPIENTRYP fn)(GLfloat, GLfloat, GLfloat)) { - SET_by_offset(disp, _gloffset_TexCoord3f, fn); -} - -typedef void (GLAPIENTRYP _glptr_TexCoord3fv)(const GLfloat *); -#define CALL_TexCoord3fv(disp, parameters) \ - (* GET_TexCoord3fv(disp)) parameters -static inline _glptr_TexCoord3fv GET_TexCoord3fv(struct _glapi_table *disp) { - return (_glptr_TexCoord3fv) (GET_by_offset(disp, _gloffset_TexCoord3fv)); -} - -static inline void SET_TexCoord3fv(struct _glapi_table *disp, void (GLAPIENTRYP fn)(const GLfloat *)) { - SET_by_offset(disp, _gloffset_TexCoord3fv, fn); -} - -typedef void (GLAPIENTRYP _glptr_TexCoord3i)(GLint, GLint, GLint); -#define CALL_TexCoord3i(disp, parameters) \ - (* GET_TexCoord3i(disp)) parameters -static inline _glptr_TexCoord3i GET_TexCoord3i(struct _glapi_table *disp) { - return (_glptr_TexCoord3i) (GET_by_offset(disp, _gloffset_TexCoord3i)); -} - -static inline void SET_TexCoord3i(struct _glapi_table *disp, void (GLAPIENTRYP fn)(GLint, GLint, GLint)) { - SET_by_offset(disp, _gloffset_TexCoord3i, fn); -} - -typedef void (GLAPIENTRYP _glptr_TexCoord3iv)(const GLint *); -#define CALL_TexCoord3iv(disp, parameters) \ - (* GET_TexCoord3iv(disp)) parameters -static inline _glptr_TexCoord3iv GET_TexCoord3iv(struct _glapi_table *disp) { - return (_glptr_TexCoord3iv) (GET_by_offset(disp, _gloffset_TexCoord3iv)); -} - -static inline void SET_TexCoord3iv(struct _glapi_table *disp, void (GLAPIENTRYP fn)(const GLint *)) { - SET_by_offset(disp, _gloffset_TexCoord3iv, fn); -} - -typedef void (GLAPIENTRYP _glptr_TexCoord3s)(GLshort, GLshort, GLshort); -#define CALL_TexCoord3s(disp, parameters) \ - (* GET_TexCoord3s(disp)) parameters -static inline _glptr_TexCoord3s GET_TexCoord3s(struct _glapi_table *disp) { - return (_glptr_TexCoord3s) (GET_by_offset(disp, _gloffset_TexCoord3s)); -} - -static inline void SET_TexCoord3s(struct _glapi_table *disp, void (GLAPIENTRYP fn)(GLshort, GLshort, GLshort)) { - SET_by_offset(disp, _gloffset_TexCoord3s, fn); -} - -typedef void (GLAPIENTRYP _glptr_TexCoord3sv)(const GLshort *); -#define CALL_TexCoord3sv(disp, parameters) \ - (* GET_TexCoord3sv(disp)) parameters -static inline _glptr_TexCoord3sv GET_TexCoord3sv(struct _glapi_table *disp) { - return (_glptr_TexCoord3sv) (GET_by_offset(disp, _gloffset_TexCoord3sv)); -} - -static inline void SET_TexCoord3sv(struct _glapi_table *disp, void (GLAPIENTRYP fn)(const GLshort *)) { - SET_by_offset(disp, _gloffset_TexCoord3sv, fn); -} - -typedef void (GLAPIENTRYP _glptr_TexCoord4d)(GLdouble, GLdouble, GLdouble, GLdouble); -#define CALL_TexCoord4d(disp, parameters) \ - (* GET_TexCoord4d(disp)) parameters -static inline _glptr_TexCoord4d GET_TexCoord4d(struct _glapi_table *disp) { - return (_glptr_TexCoord4d) (GET_by_offset(disp, _gloffset_TexCoord4d)); -} - -static inline void SET_TexCoord4d(struct _glapi_table *disp, void (GLAPIENTRYP fn)(GLdouble, GLdouble, GLdouble, GLdouble)) { - SET_by_offset(disp, _gloffset_TexCoord4d, fn); -} - -typedef void (GLAPIENTRYP _glptr_TexCoord4dv)(const GLdouble *); -#define CALL_TexCoord4dv(disp, parameters) \ - (* GET_TexCoord4dv(disp)) parameters -static inline _glptr_TexCoord4dv GET_TexCoord4dv(struct _glapi_table *disp) { - return (_glptr_TexCoord4dv) (GET_by_offset(disp, _gloffset_TexCoord4dv)); -} - -static inline void SET_TexCoord4dv(struct _glapi_table *disp, void (GLAPIENTRYP fn)(const GLdouble *)) { - SET_by_offset(disp, _gloffset_TexCoord4dv, fn); -} - -typedef void (GLAPIENTRYP _glptr_TexCoord4f)(GLfloat, GLfloat, GLfloat, GLfloat); -#define CALL_TexCoord4f(disp, parameters) \ - (* GET_TexCoord4f(disp)) parameters -static inline _glptr_TexCoord4f GET_TexCoord4f(struct _glapi_table *disp) { - return (_glptr_TexCoord4f) (GET_by_offset(disp, _gloffset_TexCoord4f)); -} - -static inline void SET_TexCoord4f(struct _glapi_table *disp, void (GLAPIENTRYP fn)(GLfloat, GLfloat, GLfloat, GLfloat)) { - SET_by_offset(disp, _gloffset_TexCoord4f, fn); -} - -typedef void (GLAPIENTRYP _glptr_TexCoord4fv)(const GLfloat *); -#define CALL_TexCoord4fv(disp, parameters) \ - (* GET_TexCoord4fv(disp)) parameters -static inline _glptr_TexCoord4fv GET_TexCoord4fv(struct _glapi_table *disp) { - return (_glptr_TexCoord4fv) (GET_by_offset(disp, _gloffset_TexCoord4fv)); -} - -static inline void SET_TexCoord4fv(struct _glapi_table *disp, void (GLAPIENTRYP fn)(const GLfloat *)) { - SET_by_offset(disp, _gloffset_TexCoord4fv, fn); -} - -typedef void (GLAPIENTRYP _glptr_TexCoord4i)(GLint, GLint, GLint, GLint); -#define CALL_TexCoord4i(disp, parameters) \ - (* GET_TexCoord4i(disp)) parameters -static inline _glptr_TexCoord4i GET_TexCoord4i(struct _glapi_table *disp) { - return (_glptr_TexCoord4i) (GET_by_offset(disp, _gloffset_TexCoord4i)); -} - -static inline void SET_TexCoord4i(struct _glapi_table *disp, void (GLAPIENTRYP fn)(GLint, GLint, GLint, GLint)) { - SET_by_offset(disp, _gloffset_TexCoord4i, fn); -} - -typedef void (GLAPIENTRYP _glptr_TexCoord4iv)(const GLint *); -#define CALL_TexCoord4iv(disp, parameters) \ - (* GET_TexCoord4iv(disp)) parameters -static inline _glptr_TexCoord4iv GET_TexCoord4iv(struct _glapi_table *disp) { - return (_glptr_TexCoord4iv) (GET_by_offset(disp, _gloffset_TexCoord4iv)); -} - -static inline void SET_TexCoord4iv(struct _glapi_table *disp, void (GLAPIENTRYP fn)(const GLint *)) { - SET_by_offset(disp, _gloffset_TexCoord4iv, fn); -} - -typedef void (GLAPIENTRYP _glptr_TexCoord4s)(GLshort, GLshort, GLshort, GLshort); -#define CALL_TexCoord4s(disp, parameters) \ - (* GET_TexCoord4s(disp)) parameters -static inline _glptr_TexCoord4s GET_TexCoord4s(struct _glapi_table *disp) { - return (_glptr_TexCoord4s) (GET_by_offset(disp, _gloffset_TexCoord4s)); -} - -static inline void SET_TexCoord4s(struct _glapi_table *disp, void (GLAPIENTRYP fn)(GLshort, GLshort, GLshort, GLshort)) { - SET_by_offset(disp, _gloffset_TexCoord4s, fn); -} - -typedef void (GLAPIENTRYP _glptr_TexCoord4sv)(const GLshort *); -#define CALL_TexCoord4sv(disp, parameters) \ - (* GET_TexCoord4sv(disp)) parameters -static inline _glptr_TexCoord4sv GET_TexCoord4sv(struct _glapi_table *disp) { - return (_glptr_TexCoord4sv) (GET_by_offset(disp, _gloffset_TexCoord4sv)); -} - -static inline void SET_TexCoord4sv(struct _glapi_table *disp, void (GLAPIENTRYP fn)(const GLshort *)) { - SET_by_offset(disp, _gloffset_TexCoord4sv, fn); -} - -typedef void (GLAPIENTRYP _glptr_Vertex2d)(GLdouble, GLdouble); -#define CALL_Vertex2d(disp, parameters) \ - (* GET_Vertex2d(disp)) parameters -static inline _glptr_Vertex2d GET_Vertex2d(struct _glapi_table *disp) { - return (_glptr_Vertex2d) (GET_by_offset(disp, _gloffset_Vertex2d)); -} - -static inline void SET_Vertex2d(struct _glapi_table *disp, void (GLAPIENTRYP fn)(GLdouble, GLdouble)) { - SET_by_offset(disp, _gloffset_Vertex2d, fn); -} - -typedef void (GLAPIENTRYP _glptr_Vertex2dv)(const GLdouble *); -#define CALL_Vertex2dv(disp, parameters) \ - (* GET_Vertex2dv(disp)) parameters -static inline _glptr_Vertex2dv GET_Vertex2dv(struct _glapi_table *disp) { - return (_glptr_Vertex2dv) (GET_by_offset(disp, _gloffset_Vertex2dv)); -} - -static inline void SET_Vertex2dv(struct _glapi_table *disp, void (GLAPIENTRYP fn)(const GLdouble *)) { - SET_by_offset(disp, _gloffset_Vertex2dv, fn); -} - -typedef void (GLAPIENTRYP _glptr_Vertex2f)(GLfloat, GLfloat); -#define CALL_Vertex2f(disp, parameters) \ - (* GET_Vertex2f(disp)) parameters -static inline _glptr_Vertex2f GET_Vertex2f(struct _glapi_table *disp) { - return (_glptr_Vertex2f) (GET_by_offset(disp, _gloffset_Vertex2f)); -} - -static inline void SET_Vertex2f(struct _glapi_table *disp, void (GLAPIENTRYP fn)(GLfloat, GLfloat)) { - SET_by_offset(disp, _gloffset_Vertex2f, fn); -} - -typedef void (GLAPIENTRYP _glptr_Vertex2fv)(const GLfloat *); -#define CALL_Vertex2fv(disp, parameters) \ - (* GET_Vertex2fv(disp)) parameters -static inline _glptr_Vertex2fv GET_Vertex2fv(struct _glapi_table *disp) { - return (_glptr_Vertex2fv) (GET_by_offset(disp, _gloffset_Vertex2fv)); -} - -static inline void SET_Vertex2fv(struct _glapi_table *disp, void (GLAPIENTRYP fn)(const GLfloat *)) { - SET_by_offset(disp, _gloffset_Vertex2fv, fn); -} - -typedef void (GLAPIENTRYP _glptr_Vertex2i)(GLint, GLint); -#define CALL_Vertex2i(disp, parameters) \ - (* GET_Vertex2i(disp)) parameters -static inline _glptr_Vertex2i GET_Vertex2i(struct _glapi_table *disp) { - return (_glptr_Vertex2i) (GET_by_offset(disp, _gloffset_Vertex2i)); -} - -static inline void SET_Vertex2i(struct _glapi_table *disp, void (GLAPIENTRYP fn)(GLint, GLint)) { - SET_by_offset(disp, _gloffset_Vertex2i, fn); -} - -typedef void (GLAPIENTRYP _glptr_Vertex2iv)(const GLint *); -#define CALL_Vertex2iv(disp, parameters) \ - (* GET_Vertex2iv(disp)) parameters -static inline _glptr_Vertex2iv GET_Vertex2iv(struct _glapi_table *disp) { - return (_glptr_Vertex2iv) (GET_by_offset(disp, _gloffset_Vertex2iv)); -} - -static inline void SET_Vertex2iv(struct _glapi_table *disp, void (GLAPIENTRYP fn)(const GLint *)) { - SET_by_offset(disp, _gloffset_Vertex2iv, fn); -} - -typedef void (GLAPIENTRYP _glptr_Vertex2s)(GLshort, GLshort); -#define CALL_Vertex2s(disp, parameters) \ - (* GET_Vertex2s(disp)) parameters -static inline _glptr_Vertex2s GET_Vertex2s(struct _glapi_table *disp) { - return (_glptr_Vertex2s) (GET_by_offset(disp, _gloffset_Vertex2s)); -} - -static inline void SET_Vertex2s(struct _glapi_table *disp, void (GLAPIENTRYP fn)(GLshort, GLshort)) { - SET_by_offset(disp, _gloffset_Vertex2s, fn); -} - -typedef void (GLAPIENTRYP _glptr_Vertex2sv)(const GLshort *); -#define CALL_Vertex2sv(disp, parameters) \ - (* GET_Vertex2sv(disp)) parameters -static inline _glptr_Vertex2sv GET_Vertex2sv(struct _glapi_table *disp) { - return (_glptr_Vertex2sv) (GET_by_offset(disp, _gloffset_Vertex2sv)); -} - -static inline void SET_Vertex2sv(struct _glapi_table *disp, void (GLAPIENTRYP fn)(const GLshort *)) { - SET_by_offset(disp, _gloffset_Vertex2sv, fn); -} - -typedef void (GLAPIENTRYP _glptr_Vertex3d)(GLdouble, GLdouble, GLdouble); -#define CALL_Vertex3d(disp, parameters) \ - (* GET_Vertex3d(disp)) parameters -static inline _glptr_Vertex3d GET_Vertex3d(struct _glapi_table *disp) { - return (_glptr_Vertex3d) (GET_by_offset(disp, _gloffset_Vertex3d)); -} - -static inline void SET_Vertex3d(struct _glapi_table *disp, void (GLAPIENTRYP fn)(GLdouble, GLdouble, GLdouble)) { - SET_by_offset(disp, _gloffset_Vertex3d, fn); -} - -typedef void (GLAPIENTRYP _glptr_Vertex3dv)(const GLdouble *); -#define CALL_Vertex3dv(disp, parameters) \ - (* GET_Vertex3dv(disp)) parameters -static inline _glptr_Vertex3dv GET_Vertex3dv(struct _glapi_table *disp) { - return (_glptr_Vertex3dv) (GET_by_offset(disp, _gloffset_Vertex3dv)); -} - -static inline void SET_Vertex3dv(struct _glapi_table *disp, void (GLAPIENTRYP fn)(const GLdouble *)) { - SET_by_offset(disp, _gloffset_Vertex3dv, fn); -} - -typedef void (GLAPIENTRYP _glptr_Vertex3f)(GLfloat, GLfloat, GLfloat); -#define CALL_Vertex3f(disp, parameters) \ - (* GET_Vertex3f(disp)) parameters -static inline _glptr_Vertex3f GET_Vertex3f(struct _glapi_table *disp) { - return (_glptr_Vertex3f) (GET_by_offset(disp, _gloffset_Vertex3f)); -} - -static inline void SET_Vertex3f(struct _glapi_table *disp, void (GLAPIENTRYP fn)(GLfloat, GLfloat, GLfloat)) { - SET_by_offset(disp, _gloffset_Vertex3f, fn); -} - -typedef void (GLAPIENTRYP _glptr_Vertex3fv)(const GLfloat *); -#define CALL_Vertex3fv(disp, parameters) \ - (* GET_Vertex3fv(disp)) parameters -static inline _glptr_Vertex3fv GET_Vertex3fv(struct _glapi_table *disp) { - return (_glptr_Vertex3fv) (GET_by_offset(disp, _gloffset_Vertex3fv)); -} - -static inline void SET_Vertex3fv(struct _glapi_table *disp, void (GLAPIENTRYP fn)(const GLfloat *)) { - SET_by_offset(disp, _gloffset_Vertex3fv, fn); -} - -typedef void (GLAPIENTRYP _glptr_Vertex3i)(GLint, GLint, GLint); -#define CALL_Vertex3i(disp, parameters) \ - (* GET_Vertex3i(disp)) parameters -static inline _glptr_Vertex3i GET_Vertex3i(struct _glapi_table *disp) { - return (_glptr_Vertex3i) (GET_by_offset(disp, _gloffset_Vertex3i)); -} - -static inline void SET_Vertex3i(struct _glapi_table *disp, void (GLAPIENTRYP fn)(GLint, GLint, GLint)) { - SET_by_offset(disp, _gloffset_Vertex3i, fn); -} - -typedef void (GLAPIENTRYP _glptr_Vertex3iv)(const GLint *); -#define CALL_Vertex3iv(disp, parameters) \ - (* GET_Vertex3iv(disp)) parameters -static inline _glptr_Vertex3iv GET_Vertex3iv(struct _glapi_table *disp) { - return (_glptr_Vertex3iv) (GET_by_offset(disp, _gloffset_Vertex3iv)); -} - -static inline void SET_Vertex3iv(struct _glapi_table *disp, void (GLAPIENTRYP fn)(const GLint *)) { - SET_by_offset(disp, _gloffset_Vertex3iv, fn); -} - -typedef void (GLAPIENTRYP _glptr_Vertex3s)(GLshort, GLshort, GLshort); -#define CALL_Vertex3s(disp, parameters) \ - (* GET_Vertex3s(disp)) parameters -static inline _glptr_Vertex3s GET_Vertex3s(struct _glapi_table *disp) { - return (_glptr_Vertex3s) (GET_by_offset(disp, _gloffset_Vertex3s)); -} - -static inline void SET_Vertex3s(struct _glapi_table *disp, void (GLAPIENTRYP fn)(GLshort, GLshort, GLshort)) { - SET_by_offset(disp, _gloffset_Vertex3s, fn); -} - -typedef void (GLAPIENTRYP _glptr_Vertex3sv)(const GLshort *); -#define CALL_Vertex3sv(disp, parameters) \ - (* GET_Vertex3sv(disp)) parameters -static inline _glptr_Vertex3sv GET_Vertex3sv(struct _glapi_table *disp) { - return (_glptr_Vertex3sv) (GET_by_offset(disp, _gloffset_Vertex3sv)); -} - -static inline void SET_Vertex3sv(struct _glapi_table *disp, void (GLAPIENTRYP fn)(const GLshort *)) { - SET_by_offset(disp, _gloffset_Vertex3sv, fn); -} - -typedef void (GLAPIENTRYP _glptr_Vertex4d)(GLdouble, GLdouble, GLdouble, GLdouble); -#define CALL_Vertex4d(disp, parameters) \ - (* GET_Vertex4d(disp)) parameters -static inline _glptr_Vertex4d GET_Vertex4d(struct _glapi_table *disp) { - return (_glptr_Vertex4d) (GET_by_offset(disp, _gloffset_Vertex4d)); -} - -static inline void SET_Vertex4d(struct _glapi_table *disp, void (GLAPIENTRYP fn)(GLdouble, GLdouble, GLdouble, GLdouble)) { - SET_by_offset(disp, _gloffset_Vertex4d, fn); -} - -typedef void (GLAPIENTRYP _glptr_Vertex4dv)(const GLdouble *); -#define CALL_Vertex4dv(disp, parameters) \ - (* GET_Vertex4dv(disp)) parameters -static inline _glptr_Vertex4dv GET_Vertex4dv(struct _glapi_table *disp) { - return (_glptr_Vertex4dv) (GET_by_offset(disp, _gloffset_Vertex4dv)); -} - -static inline void SET_Vertex4dv(struct _glapi_table *disp, void (GLAPIENTRYP fn)(const GLdouble *)) { - SET_by_offset(disp, _gloffset_Vertex4dv, fn); -} - -typedef void (GLAPIENTRYP _glptr_Vertex4f)(GLfloat, GLfloat, GLfloat, GLfloat); -#define CALL_Vertex4f(disp, parameters) \ - (* GET_Vertex4f(disp)) parameters -static inline _glptr_Vertex4f GET_Vertex4f(struct _glapi_table *disp) { - return (_glptr_Vertex4f) (GET_by_offset(disp, _gloffset_Vertex4f)); -} - -static inline void SET_Vertex4f(struct _glapi_table *disp, void (GLAPIENTRYP fn)(GLfloat, GLfloat, GLfloat, GLfloat)) { - SET_by_offset(disp, _gloffset_Vertex4f, fn); -} - -typedef void (GLAPIENTRYP _glptr_Vertex4fv)(const GLfloat *); -#define CALL_Vertex4fv(disp, parameters) \ - (* GET_Vertex4fv(disp)) parameters -static inline _glptr_Vertex4fv GET_Vertex4fv(struct _glapi_table *disp) { - return (_glptr_Vertex4fv) (GET_by_offset(disp, _gloffset_Vertex4fv)); -} - -static inline void SET_Vertex4fv(struct _glapi_table *disp, void (GLAPIENTRYP fn)(const GLfloat *)) { - SET_by_offset(disp, _gloffset_Vertex4fv, fn); -} - -typedef void (GLAPIENTRYP _glptr_Vertex4i)(GLint, GLint, GLint, GLint); -#define CALL_Vertex4i(disp, parameters) \ - (* GET_Vertex4i(disp)) parameters -static inline _glptr_Vertex4i GET_Vertex4i(struct _glapi_table *disp) { - return (_glptr_Vertex4i) (GET_by_offset(disp, _gloffset_Vertex4i)); -} - -static inline void SET_Vertex4i(struct _glapi_table *disp, void (GLAPIENTRYP fn)(GLint, GLint, GLint, GLint)) { - SET_by_offset(disp, _gloffset_Vertex4i, fn); -} - -typedef void (GLAPIENTRYP _glptr_Vertex4iv)(const GLint *); -#define CALL_Vertex4iv(disp, parameters) \ - (* GET_Vertex4iv(disp)) parameters -static inline _glptr_Vertex4iv GET_Vertex4iv(struct _glapi_table *disp) { - return (_glptr_Vertex4iv) (GET_by_offset(disp, _gloffset_Vertex4iv)); -} - -static inline void SET_Vertex4iv(struct _glapi_table *disp, void (GLAPIENTRYP fn)(const GLint *)) { - SET_by_offset(disp, _gloffset_Vertex4iv, fn); -} - -typedef void (GLAPIENTRYP _glptr_Vertex4s)(GLshort, GLshort, GLshort, GLshort); -#define CALL_Vertex4s(disp, parameters) \ - (* GET_Vertex4s(disp)) parameters -static inline _glptr_Vertex4s GET_Vertex4s(struct _glapi_table *disp) { - return (_glptr_Vertex4s) (GET_by_offset(disp, _gloffset_Vertex4s)); -} - -static inline void SET_Vertex4s(struct _glapi_table *disp, void (GLAPIENTRYP fn)(GLshort, GLshort, GLshort, GLshort)) { - SET_by_offset(disp, _gloffset_Vertex4s, fn); -} - -typedef void (GLAPIENTRYP _glptr_Vertex4sv)(const GLshort *); -#define CALL_Vertex4sv(disp, parameters) \ - (* GET_Vertex4sv(disp)) parameters -static inline _glptr_Vertex4sv GET_Vertex4sv(struct _glapi_table *disp) { - return (_glptr_Vertex4sv) (GET_by_offset(disp, _gloffset_Vertex4sv)); -} - -static inline void SET_Vertex4sv(struct _glapi_table *disp, void (GLAPIENTRYP fn)(const GLshort *)) { - SET_by_offset(disp, _gloffset_Vertex4sv, fn); -} - -typedef void (GLAPIENTRYP _glptr_ClipPlane)(GLenum, const GLdouble *); -#define CALL_ClipPlane(disp, parameters) \ - (* GET_ClipPlane(disp)) parameters -static inline _glptr_ClipPlane GET_ClipPlane(struct _glapi_table *disp) { - return (_glptr_ClipPlane) (GET_by_offset(disp, _gloffset_ClipPlane)); -} - -static inline void SET_ClipPlane(struct _glapi_table *disp, void (GLAPIENTRYP fn)(GLenum, const GLdouble *)) { - SET_by_offset(disp, _gloffset_ClipPlane, fn); -} - -typedef void (GLAPIENTRYP _glptr_ColorMaterial)(GLenum, GLenum); -#define CALL_ColorMaterial(disp, parameters) \ - (* GET_ColorMaterial(disp)) parameters -static inline _glptr_ColorMaterial GET_ColorMaterial(struct _glapi_table *disp) { - return (_glptr_ColorMaterial) (GET_by_offset(disp, _gloffset_ColorMaterial)); -} - -static inline void SET_ColorMaterial(struct _glapi_table *disp, void (GLAPIENTRYP fn)(GLenum, GLenum)) { - SET_by_offset(disp, _gloffset_ColorMaterial, fn); -} - -typedef void (GLAPIENTRYP _glptr_CullFace)(GLenum); -#define CALL_CullFace(disp, parameters) \ - (* GET_CullFace(disp)) parameters -static inline _glptr_CullFace GET_CullFace(struct _glapi_table *disp) { - return (_glptr_CullFace) (GET_by_offset(disp, _gloffset_CullFace)); -} - -static inline void SET_CullFace(struct _glapi_table *disp, void (GLAPIENTRYP fn)(GLenum)) { - SET_by_offset(disp, _gloffset_CullFace, fn); -} - -typedef void (GLAPIENTRYP _glptr_Fogf)(GLenum, GLfloat); -#define CALL_Fogf(disp, parameters) \ - (* GET_Fogf(disp)) parameters -static inline _glptr_Fogf GET_Fogf(struct _glapi_table *disp) { - return (_glptr_Fogf) (GET_by_offset(disp, _gloffset_Fogf)); -} - -static inline void SET_Fogf(struct _glapi_table *disp, void (GLAPIENTRYP fn)(GLenum, GLfloat)) { - SET_by_offset(disp, _gloffset_Fogf, fn); -} - -typedef void (GLAPIENTRYP _glptr_Fogfv)(GLenum, const GLfloat *); -#define CALL_Fogfv(disp, parameters) \ - (* GET_Fogfv(disp)) parameters -static inline _glptr_Fogfv GET_Fogfv(struct _glapi_table *disp) { - return (_glptr_Fogfv) (GET_by_offset(disp, _gloffset_Fogfv)); -} - -static inline void SET_Fogfv(struct _glapi_table *disp, void (GLAPIENTRYP fn)(GLenum, const GLfloat *)) { - SET_by_offset(disp, _gloffset_Fogfv, fn); -} - -typedef void (GLAPIENTRYP _glptr_Fogi)(GLenum, GLint); -#define CALL_Fogi(disp, parameters) \ - (* GET_Fogi(disp)) parameters -static inline _glptr_Fogi GET_Fogi(struct _glapi_table *disp) { - return (_glptr_Fogi) (GET_by_offset(disp, _gloffset_Fogi)); -} - -static inline void SET_Fogi(struct _glapi_table *disp, void (GLAPIENTRYP fn)(GLenum, GLint)) { - SET_by_offset(disp, _gloffset_Fogi, fn); -} - -typedef void (GLAPIENTRYP _glptr_Fogiv)(GLenum, const GLint *); -#define CALL_Fogiv(disp, parameters) \ - (* GET_Fogiv(disp)) parameters -static inline _glptr_Fogiv GET_Fogiv(struct _glapi_table *disp) { - return (_glptr_Fogiv) (GET_by_offset(disp, _gloffset_Fogiv)); -} - -static inline void SET_Fogiv(struct _glapi_table *disp, void (GLAPIENTRYP fn)(GLenum, const GLint *)) { - SET_by_offset(disp, _gloffset_Fogiv, fn); -} - -typedef void (GLAPIENTRYP _glptr_FrontFace)(GLenum); -#define CALL_FrontFace(disp, parameters) \ - (* GET_FrontFace(disp)) parameters -static inline _glptr_FrontFace GET_FrontFace(struct _glapi_table *disp) { - return (_glptr_FrontFace) (GET_by_offset(disp, _gloffset_FrontFace)); -} - -static inline void SET_FrontFace(struct _glapi_table *disp, void (GLAPIENTRYP fn)(GLenum)) { - SET_by_offset(disp, _gloffset_FrontFace, fn); -} - -typedef void (GLAPIENTRYP _glptr_Hint)(GLenum, GLenum); -#define CALL_Hint(disp, parameters) \ - (* GET_Hint(disp)) parameters -static inline _glptr_Hint GET_Hint(struct _glapi_table *disp) { - return (_glptr_Hint) (GET_by_offset(disp, _gloffset_Hint)); -} - -static inline void SET_Hint(struct _glapi_table *disp, void (GLAPIENTRYP fn)(GLenum, GLenum)) { - SET_by_offset(disp, _gloffset_Hint, fn); -} - -typedef void (GLAPIENTRYP _glptr_Lightf)(GLenum, GLenum, GLfloat); -#define CALL_Lightf(disp, parameters) \ - (* GET_Lightf(disp)) parameters -static inline _glptr_Lightf GET_Lightf(struct _glapi_table *disp) { - return (_glptr_Lightf) (GET_by_offset(disp, _gloffset_Lightf)); -} - -static inline void SET_Lightf(struct _glapi_table *disp, void (GLAPIENTRYP fn)(GLenum, GLenum, GLfloat)) { - SET_by_offset(disp, _gloffset_Lightf, fn); -} - -typedef void (GLAPIENTRYP _glptr_Lightfv)(GLenum, GLenum, const GLfloat *); -#define CALL_Lightfv(disp, parameters) \ - (* GET_Lightfv(disp)) parameters -static inline _glptr_Lightfv GET_Lightfv(struct _glapi_table *disp) { - return (_glptr_Lightfv) (GET_by_offset(disp, _gloffset_Lightfv)); -} - -static inline void SET_Lightfv(struct _glapi_table *disp, void (GLAPIENTRYP fn)(GLenum, GLenum, const GLfloat *)) { - SET_by_offset(disp, _gloffset_Lightfv, fn); -} - -typedef void (GLAPIENTRYP _glptr_Lighti)(GLenum, GLenum, GLint); -#define CALL_Lighti(disp, parameters) \ - (* GET_Lighti(disp)) parameters -static inline _glptr_Lighti GET_Lighti(struct _glapi_table *disp) { - return (_glptr_Lighti) (GET_by_offset(disp, _gloffset_Lighti)); -} - -static inline void SET_Lighti(struct _glapi_table *disp, void (GLAPIENTRYP fn)(GLenum, GLenum, GLint)) { - SET_by_offset(disp, _gloffset_Lighti, fn); -} - -typedef void (GLAPIENTRYP _glptr_Lightiv)(GLenum, GLenum, const GLint *); -#define CALL_Lightiv(disp, parameters) \ - (* GET_Lightiv(disp)) parameters -static inline _glptr_Lightiv GET_Lightiv(struct _glapi_table *disp) { - return (_glptr_Lightiv) (GET_by_offset(disp, _gloffset_Lightiv)); -} - -static inline void SET_Lightiv(struct _glapi_table *disp, void (GLAPIENTRYP fn)(GLenum, GLenum, const GLint *)) { - SET_by_offset(disp, _gloffset_Lightiv, fn); -} - -typedef void (GLAPIENTRYP _glptr_LightModelf)(GLenum, GLfloat); -#define CALL_LightModelf(disp, parameters) \ - (* GET_LightModelf(disp)) parameters -static inline _glptr_LightModelf GET_LightModelf(struct _glapi_table *disp) { - return (_glptr_LightModelf) (GET_by_offset(disp, _gloffset_LightModelf)); -} - -static inline void SET_LightModelf(struct _glapi_table *disp, void (GLAPIENTRYP fn)(GLenum, GLfloat)) { - SET_by_offset(disp, _gloffset_LightModelf, fn); -} - -typedef void (GLAPIENTRYP _glptr_LightModelfv)(GLenum, const GLfloat *); -#define CALL_LightModelfv(disp, parameters) \ - (* GET_LightModelfv(disp)) parameters -static inline _glptr_LightModelfv GET_LightModelfv(struct _glapi_table *disp) { - return (_glptr_LightModelfv) (GET_by_offset(disp, _gloffset_LightModelfv)); -} - -static inline void SET_LightModelfv(struct _glapi_table *disp, void (GLAPIENTRYP fn)(GLenum, const GLfloat *)) { - SET_by_offset(disp, _gloffset_LightModelfv, fn); -} - -typedef void (GLAPIENTRYP _glptr_LightModeli)(GLenum, GLint); -#define CALL_LightModeli(disp, parameters) \ - (* GET_LightModeli(disp)) parameters -static inline _glptr_LightModeli GET_LightModeli(struct _glapi_table *disp) { - return (_glptr_LightModeli) (GET_by_offset(disp, _gloffset_LightModeli)); -} - -static inline void SET_LightModeli(struct _glapi_table *disp, void (GLAPIENTRYP fn)(GLenum, GLint)) { - SET_by_offset(disp, _gloffset_LightModeli, fn); -} - -typedef void (GLAPIENTRYP _glptr_LightModeliv)(GLenum, const GLint *); -#define CALL_LightModeliv(disp, parameters) \ - (* GET_LightModeliv(disp)) parameters -static inline _glptr_LightModeliv GET_LightModeliv(struct _glapi_table *disp) { - return (_glptr_LightModeliv) (GET_by_offset(disp, _gloffset_LightModeliv)); -} - -static inline void SET_LightModeliv(struct _glapi_table *disp, void (GLAPIENTRYP fn)(GLenum, const GLint *)) { - SET_by_offset(disp, _gloffset_LightModeliv, fn); -} - -typedef void (GLAPIENTRYP _glptr_LineStipple)(GLint, GLushort); -#define CALL_LineStipple(disp, parameters) \ - (* GET_LineStipple(disp)) parameters -static inline _glptr_LineStipple GET_LineStipple(struct _glapi_table *disp) { - return (_glptr_LineStipple) (GET_by_offset(disp, _gloffset_LineStipple)); -} - -static inline void SET_LineStipple(struct _glapi_table *disp, void (GLAPIENTRYP fn)(GLint, GLushort)) { - SET_by_offset(disp, _gloffset_LineStipple, fn); -} - -typedef void (GLAPIENTRYP _glptr_LineWidth)(GLfloat); -#define CALL_LineWidth(disp, parameters) \ - (* GET_LineWidth(disp)) parameters -static inline _glptr_LineWidth GET_LineWidth(struct _glapi_table *disp) { - return (_glptr_LineWidth) (GET_by_offset(disp, _gloffset_LineWidth)); -} - -static inline void SET_LineWidth(struct _glapi_table *disp, void (GLAPIENTRYP fn)(GLfloat)) { - SET_by_offset(disp, _gloffset_LineWidth, fn); -} - -typedef void (GLAPIENTRYP _glptr_Materialf)(GLenum, GLenum, GLfloat); -#define CALL_Materialf(disp, parameters) \ - (* GET_Materialf(disp)) parameters -static inline _glptr_Materialf GET_Materialf(struct _glapi_table *disp) { - return (_glptr_Materialf) (GET_by_offset(disp, _gloffset_Materialf)); -} - -static inline void SET_Materialf(struct _glapi_table *disp, void (GLAPIENTRYP fn)(GLenum, GLenum, GLfloat)) { - SET_by_offset(disp, _gloffset_Materialf, fn); -} - -typedef void (GLAPIENTRYP _glptr_Materialfv)(GLenum, GLenum, const GLfloat *); -#define CALL_Materialfv(disp, parameters) \ - (* GET_Materialfv(disp)) parameters -static inline _glptr_Materialfv GET_Materialfv(struct _glapi_table *disp) { - return (_glptr_Materialfv) (GET_by_offset(disp, _gloffset_Materialfv)); -} - -static inline void SET_Materialfv(struct _glapi_table *disp, void (GLAPIENTRYP fn)(GLenum, GLenum, const GLfloat *)) { - SET_by_offset(disp, _gloffset_Materialfv, fn); -} - -typedef void (GLAPIENTRYP _glptr_Materiali)(GLenum, GLenum, GLint); -#define CALL_Materiali(disp, parameters) \ - (* GET_Materiali(disp)) parameters -static inline _glptr_Materiali GET_Materiali(struct _glapi_table *disp) { - return (_glptr_Materiali) (GET_by_offset(disp, _gloffset_Materiali)); -} - -static inline void SET_Materiali(struct _glapi_table *disp, void (GLAPIENTRYP fn)(GLenum, GLenum, GLint)) { - SET_by_offset(disp, _gloffset_Materiali, fn); -} - -typedef void (GLAPIENTRYP _glptr_Materialiv)(GLenum, GLenum, const GLint *); -#define CALL_Materialiv(disp, parameters) \ - (* GET_Materialiv(disp)) parameters -static inline _glptr_Materialiv GET_Materialiv(struct _glapi_table *disp) { - return (_glptr_Materialiv) (GET_by_offset(disp, _gloffset_Materialiv)); -} - -static inline void SET_Materialiv(struct _glapi_table *disp, void (GLAPIENTRYP fn)(GLenum, GLenum, const GLint *)) { - SET_by_offset(disp, _gloffset_Materialiv, fn); -} - -typedef void (GLAPIENTRYP _glptr_PointSize)(GLfloat); -#define CALL_PointSize(disp, parameters) \ - (* GET_PointSize(disp)) parameters -static inline _glptr_PointSize GET_PointSize(struct _glapi_table *disp) { - return (_glptr_PointSize) (GET_by_offset(disp, _gloffset_PointSize)); -} - -static inline void SET_PointSize(struct _glapi_table *disp, void (GLAPIENTRYP fn)(GLfloat)) { - SET_by_offset(disp, _gloffset_PointSize, fn); -} - -typedef void (GLAPIENTRYP _glptr_PolygonMode)(GLenum, GLenum); -#define CALL_PolygonMode(disp, parameters) \ - (* GET_PolygonMode(disp)) parameters -static inline _glptr_PolygonMode GET_PolygonMode(struct _glapi_table *disp) { - return (_glptr_PolygonMode) (GET_by_offset(disp, _gloffset_PolygonMode)); -} - -static inline void SET_PolygonMode(struct _glapi_table *disp, void (GLAPIENTRYP fn)(GLenum, GLenum)) { - SET_by_offset(disp, _gloffset_PolygonMode, fn); -} - -typedef void (GLAPIENTRYP _glptr_PolygonStipple)(const GLubyte *); -#define CALL_PolygonStipple(disp, parameters) \ - (* GET_PolygonStipple(disp)) parameters -static inline _glptr_PolygonStipple GET_PolygonStipple(struct _glapi_table *disp) { - return (_glptr_PolygonStipple) (GET_by_offset(disp, _gloffset_PolygonStipple)); -} - -static inline void SET_PolygonStipple(struct _glapi_table *disp, void (GLAPIENTRYP fn)(const GLubyte *)) { - SET_by_offset(disp, _gloffset_PolygonStipple, fn); -} - -typedef void (GLAPIENTRYP _glptr_Scissor)(GLint, GLint, GLsizei, GLsizei); -#define CALL_Scissor(disp, parameters) \ - (* GET_Scissor(disp)) parameters -static inline _glptr_Scissor GET_Scissor(struct _glapi_table *disp) { - return (_glptr_Scissor) (GET_by_offset(disp, _gloffset_Scissor)); -} - -static inline void SET_Scissor(struct _glapi_table *disp, void (GLAPIENTRYP fn)(GLint, GLint, GLsizei, GLsizei)) { - SET_by_offset(disp, _gloffset_Scissor, fn); -} - -typedef void (GLAPIENTRYP _glptr_ShadeModel)(GLenum); -#define CALL_ShadeModel(disp, parameters) \ - (* GET_ShadeModel(disp)) parameters -static inline _glptr_ShadeModel GET_ShadeModel(struct _glapi_table *disp) { - return (_glptr_ShadeModel) (GET_by_offset(disp, _gloffset_ShadeModel)); -} - -static inline void SET_ShadeModel(struct _glapi_table *disp, void (GLAPIENTRYP fn)(GLenum)) { - SET_by_offset(disp, _gloffset_ShadeModel, fn); -} - -typedef void (GLAPIENTRYP _glptr_TexParameterf)(GLenum, GLenum, GLfloat); -#define CALL_TexParameterf(disp, parameters) \ - (* GET_TexParameterf(disp)) parameters -static inline _glptr_TexParameterf GET_TexParameterf(struct _glapi_table *disp) { - return (_glptr_TexParameterf) (GET_by_offset(disp, _gloffset_TexParameterf)); -} - -static inline void SET_TexParameterf(struct _glapi_table *disp, void (GLAPIENTRYP fn)(GLenum, GLenum, GLfloat)) { - SET_by_offset(disp, _gloffset_TexParameterf, fn); -} - -typedef void (GLAPIENTRYP _glptr_TexParameterfv)(GLenum, GLenum, const GLfloat *); -#define CALL_TexParameterfv(disp, parameters) \ - (* GET_TexParameterfv(disp)) parameters -static inline _glptr_TexParameterfv GET_TexParameterfv(struct _glapi_table *disp) { - return (_glptr_TexParameterfv) (GET_by_offset(disp, _gloffset_TexParameterfv)); -} - -static inline void SET_TexParameterfv(struct _glapi_table *disp, void (GLAPIENTRYP fn)(GLenum, GLenum, const GLfloat *)) { - SET_by_offset(disp, _gloffset_TexParameterfv, fn); -} - -typedef void (GLAPIENTRYP _glptr_TexParameteri)(GLenum, GLenum, GLint); -#define CALL_TexParameteri(disp, parameters) \ - (* GET_TexParameteri(disp)) parameters -static inline _glptr_TexParameteri GET_TexParameteri(struct _glapi_table *disp) { - return (_glptr_TexParameteri) (GET_by_offset(disp, _gloffset_TexParameteri)); -} - -static inline void SET_TexParameteri(struct _glapi_table *disp, void (GLAPIENTRYP fn)(GLenum, GLenum, GLint)) { - SET_by_offset(disp, _gloffset_TexParameteri, fn); -} - -typedef void (GLAPIENTRYP _glptr_TexParameteriv)(GLenum, GLenum, const GLint *); -#define CALL_TexParameteriv(disp, parameters) \ - (* GET_TexParameteriv(disp)) parameters -static inline _glptr_TexParameteriv GET_TexParameteriv(struct _glapi_table *disp) { - return (_glptr_TexParameteriv) (GET_by_offset(disp, _gloffset_TexParameteriv)); -} - -static inline void SET_TexParameteriv(struct _glapi_table *disp, void (GLAPIENTRYP fn)(GLenum, GLenum, const GLint *)) { - SET_by_offset(disp, _gloffset_TexParameteriv, fn); -} - -typedef void (GLAPIENTRYP _glptr_TexImage1D)(GLenum, GLint, GLint, GLsizei, GLint, GLenum, GLenum, const GLvoid *); -#define CALL_TexImage1D(disp, parameters) \ - (* GET_TexImage1D(disp)) parameters -static inline _glptr_TexImage1D GET_TexImage1D(struct _glapi_table *disp) { - return (_glptr_TexImage1D) (GET_by_offset(disp, _gloffset_TexImage1D)); -} - -static inline void SET_TexImage1D(struct _glapi_table *disp, void (GLAPIENTRYP fn)(GLenum, GLint, GLint, GLsizei, GLint, GLenum, GLenum, const GLvoid *)) { - SET_by_offset(disp, _gloffset_TexImage1D, fn); -} - -typedef void (GLAPIENTRYP _glptr_TexImage2D)(GLenum, GLint, GLint, GLsizei, GLsizei, GLint, GLenum, GLenum, const GLvoid *); -#define CALL_TexImage2D(disp, parameters) \ - (* GET_TexImage2D(disp)) parameters -static inline _glptr_TexImage2D GET_TexImage2D(struct _glapi_table *disp) { - return (_glptr_TexImage2D) (GET_by_offset(disp, _gloffset_TexImage2D)); -} - -static inline void SET_TexImage2D(struct _glapi_table *disp, void (GLAPIENTRYP fn)(GLenum, GLint, GLint, GLsizei, GLsizei, GLint, GLenum, GLenum, const GLvoid *)) { - SET_by_offset(disp, _gloffset_TexImage2D, fn); -} - -typedef void (GLAPIENTRYP _glptr_TexEnvf)(GLenum, GLenum, GLfloat); -#define CALL_TexEnvf(disp, parameters) \ - (* GET_TexEnvf(disp)) parameters -static inline _glptr_TexEnvf GET_TexEnvf(struct _glapi_table *disp) { - return (_glptr_TexEnvf) (GET_by_offset(disp, _gloffset_TexEnvf)); -} - -static inline void SET_TexEnvf(struct _glapi_table *disp, void (GLAPIENTRYP fn)(GLenum, GLenum, GLfloat)) { - SET_by_offset(disp, _gloffset_TexEnvf, fn); -} - -typedef void (GLAPIENTRYP _glptr_TexEnvfv)(GLenum, GLenum, const GLfloat *); -#define CALL_TexEnvfv(disp, parameters) \ - (* GET_TexEnvfv(disp)) parameters -static inline _glptr_TexEnvfv GET_TexEnvfv(struct _glapi_table *disp) { - return (_glptr_TexEnvfv) (GET_by_offset(disp, _gloffset_TexEnvfv)); -} - -static inline void SET_TexEnvfv(struct _glapi_table *disp, void (GLAPIENTRYP fn)(GLenum, GLenum, const GLfloat *)) { - SET_by_offset(disp, _gloffset_TexEnvfv, fn); -} - -typedef void (GLAPIENTRYP _glptr_TexEnvi)(GLenum, GLenum, GLint); -#define CALL_TexEnvi(disp, parameters) \ - (* GET_TexEnvi(disp)) parameters -static inline _glptr_TexEnvi GET_TexEnvi(struct _glapi_table *disp) { - return (_glptr_TexEnvi) (GET_by_offset(disp, _gloffset_TexEnvi)); -} - -static inline void SET_TexEnvi(struct _glapi_table *disp, void (GLAPIENTRYP fn)(GLenum, GLenum, GLint)) { - SET_by_offset(disp, _gloffset_TexEnvi, fn); -} - -typedef void (GLAPIENTRYP _glptr_TexEnviv)(GLenum, GLenum, const GLint *); -#define CALL_TexEnviv(disp, parameters) \ - (* GET_TexEnviv(disp)) parameters -static inline _glptr_TexEnviv GET_TexEnviv(struct _glapi_table *disp) { - return (_glptr_TexEnviv) (GET_by_offset(disp, _gloffset_TexEnviv)); -} - -static inline void SET_TexEnviv(struct _glapi_table *disp, void (GLAPIENTRYP fn)(GLenum, GLenum, const GLint *)) { - SET_by_offset(disp, _gloffset_TexEnviv, fn); -} - -typedef void (GLAPIENTRYP _glptr_TexGend)(GLenum, GLenum, GLdouble); -#define CALL_TexGend(disp, parameters) \ - (* GET_TexGend(disp)) parameters -static inline _glptr_TexGend GET_TexGend(struct _glapi_table *disp) { - return (_glptr_TexGend) (GET_by_offset(disp, _gloffset_TexGend)); -} - -static inline void SET_TexGend(struct _glapi_table *disp, void (GLAPIENTRYP fn)(GLenum, GLenum, GLdouble)) { - SET_by_offset(disp, _gloffset_TexGend, fn); -} - -typedef void (GLAPIENTRYP _glptr_TexGendv)(GLenum, GLenum, const GLdouble *); -#define CALL_TexGendv(disp, parameters) \ - (* GET_TexGendv(disp)) parameters -static inline _glptr_TexGendv GET_TexGendv(struct _glapi_table *disp) { - return (_glptr_TexGendv) (GET_by_offset(disp, _gloffset_TexGendv)); -} - -static inline void SET_TexGendv(struct _glapi_table *disp, void (GLAPIENTRYP fn)(GLenum, GLenum, const GLdouble *)) { - SET_by_offset(disp, _gloffset_TexGendv, fn); -} - -typedef void (GLAPIENTRYP _glptr_TexGenf)(GLenum, GLenum, GLfloat); -#define CALL_TexGenf(disp, parameters) \ - (* GET_TexGenf(disp)) parameters -static inline _glptr_TexGenf GET_TexGenf(struct _glapi_table *disp) { - return (_glptr_TexGenf) (GET_by_offset(disp, _gloffset_TexGenf)); -} - -static inline void SET_TexGenf(struct _glapi_table *disp, void (GLAPIENTRYP fn)(GLenum, GLenum, GLfloat)) { - SET_by_offset(disp, _gloffset_TexGenf, fn); -} - -typedef void (GLAPIENTRYP _glptr_TexGenfv)(GLenum, GLenum, const GLfloat *); -#define CALL_TexGenfv(disp, parameters) \ - (* GET_TexGenfv(disp)) parameters -static inline _glptr_TexGenfv GET_TexGenfv(struct _glapi_table *disp) { - return (_glptr_TexGenfv) (GET_by_offset(disp, _gloffset_TexGenfv)); -} - -static inline void SET_TexGenfv(struct _glapi_table *disp, void (GLAPIENTRYP fn)(GLenum, GLenum, const GLfloat *)) { - SET_by_offset(disp, _gloffset_TexGenfv, fn); -} - -typedef void (GLAPIENTRYP _glptr_TexGeni)(GLenum, GLenum, GLint); -#define CALL_TexGeni(disp, parameters) \ - (* GET_TexGeni(disp)) parameters -static inline _glptr_TexGeni GET_TexGeni(struct _glapi_table *disp) { - return (_glptr_TexGeni) (GET_by_offset(disp, _gloffset_TexGeni)); -} - -static inline void SET_TexGeni(struct _glapi_table *disp, void (GLAPIENTRYP fn)(GLenum, GLenum, GLint)) { - SET_by_offset(disp, _gloffset_TexGeni, fn); -} - -typedef void (GLAPIENTRYP _glptr_TexGeniv)(GLenum, GLenum, const GLint *); -#define CALL_TexGeniv(disp, parameters) \ - (* GET_TexGeniv(disp)) parameters -static inline _glptr_TexGeniv GET_TexGeniv(struct _glapi_table *disp) { - return (_glptr_TexGeniv) (GET_by_offset(disp, _gloffset_TexGeniv)); -} - -static inline void SET_TexGeniv(struct _glapi_table *disp, void (GLAPIENTRYP fn)(GLenum, GLenum, const GLint *)) { - SET_by_offset(disp, _gloffset_TexGeniv, fn); -} - -typedef void (GLAPIENTRYP _glptr_FeedbackBuffer)(GLsizei, GLenum, GLfloat *); -#define CALL_FeedbackBuffer(disp, parameters) \ - (* GET_FeedbackBuffer(disp)) parameters -static inline _glptr_FeedbackBuffer GET_FeedbackBuffer(struct _glapi_table *disp) { - return (_glptr_FeedbackBuffer) (GET_by_offset(disp, _gloffset_FeedbackBuffer)); -} - -static inline void SET_FeedbackBuffer(struct _glapi_table *disp, void (GLAPIENTRYP fn)(GLsizei, GLenum, GLfloat *)) { - SET_by_offset(disp, _gloffset_FeedbackBuffer, fn); -} - -typedef void (GLAPIENTRYP _glptr_SelectBuffer)(GLsizei, GLuint *); -#define CALL_SelectBuffer(disp, parameters) \ - (* GET_SelectBuffer(disp)) parameters -static inline _glptr_SelectBuffer GET_SelectBuffer(struct _glapi_table *disp) { - return (_glptr_SelectBuffer) (GET_by_offset(disp, _gloffset_SelectBuffer)); -} - -static inline void SET_SelectBuffer(struct _glapi_table *disp, void (GLAPIENTRYP fn)(GLsizei, GLuint *)) { - SET_by_offset(disp, _gloffset_SelectBuffer, fn); -} - -typedef GLint (GLAPIENTRYP _glptr_RenderMode)(GLenum); -#define CALL_RenderMode(disp, parameters) \ - (* GET_RenderMode(disp)) parameters -static inline _glptr_RenderMode GET_RenderMode(struct _glapi_table *disp) { - return (_glptr_RenderMode) (GET_by_offset(disp, _gloffset_RenderMode)); -} - -static inline void SET_RenderMode(struct _glapi_table *disp, GLint (GLAPIENTRYP fn)(GLenum)) { - SET_by_offset(disp, _gloffset_RenderMode, fn); -} - -typedef void (GLAPIENTRYP _glptr_InitNames)(void); -#define CALL_InitNames(disp, parameters) \ - (* GET_InitNames(disp)) parameters -static inline _glptr_InitNames GET_InitNames(struct _glapi_table *disp) { - return (_glptr_InitNames) (GET_by_offset(disp, _gloffset_InitNames)); -} - -static inline void SET_InitNames(struct _glapi_table *disp, void (GLAPIENTRYP fn)(void)) { - SET_by_offset(disp, _gloffset_InitNames, fn); -} - -typedef void (GLAPIENTRYP _glptr_LoadName)(GLuint); -#define CALL_LoadName(disp, parameters) \ - (* GET_LoadName(disp)) parameters -static inline _glptr_LoadName GET_LoadName(struct _glapi_table *disp) { - return (_glptr_LoadName) (GET_by_offset(disp, _gloffset_LoadName)); -} - -static inline void SET_LoadName(struct _glapi_table *disp, void (GLAPIENTRYP fn)(GLuint)) { - SET_by_offset(disp, _gloffset_LoadName, fn); -} - -typedef void (GLAPIENTRYP _glptr_PassThrough)(GLfloat); -#define CALL_PassThrough(disp, parameters) \ - (* GET_PassThrough(disp)) parameters -static inline _glptr_PassThrough GET_PassThrough(struct _glapi_table *disp) { - return (_glptr_PassThrough) (GET_by_offset(disp, _gloffset_PassThrough)); -} - -static inline void SET_PassThrough(struct _glapi_table *disp, void (GLAPIENTRYP fn)(GLfloat)) { - SET_by_offset(disp, _gloffset_PassThrough, fn); -} - -typedef void (GLAPIENTRYP _glptr_PopName)(void); -#define CALL_PopName(disp, parameters) \ - (* GET_PopName(disp)) parameters -static inline _glptr_PopName GET_PopName(struct _glapi_table *disp) { - return (_glptr_PopName) (GET_by_offset(disp, _gloffset_PopName)); -} - -static inline void SET_PopName(struct _glapi_table *disp, void (GLAPIENTRYP fn)(void)) { - SET_by_offset(disp, _gloffset_PopName, fn); -} - -typedef void (GLAPIENTRYP _glptr_PushName)(GLuint); -#define CALL_PushName(disp, parameters) \ - (* GET_PushName(disp)) parameters -static inline _glptr_PushName GET_PushName(struct _glapi_table *disp) { - return (_glptr_PushName) (GET_by_offset(disp, _gloffset_PushName)); -} - -static inline void SET_PushName(struct _glapi_table *disp, void (GLAPIENTRYP fn)(GLuint)) { - SET_by_offset(disp, _gloffset_PushName, fn); -} - -typedef void (GLAPIENTRYP _glptr_DrawBuffer)(GLenum); -#define CALL_DrawBuffer(disp, parameters) \ - (* GET_DrawBuffer(disp)) parameters -static inline _glptr_DrawBuffer GET_DrawBuffer(struct _glapi_table *disp) { - return (_glptr_DrawBuffer) (GET_by_offset(disp, _gloffset_DrawBuffer)); -} - -static inline void SET_DrawBuffer(struct _glapi_table *disp, void (GLAPIENTRYP fn)(GLenum)) { - SET_by_offset(disp, _gloffset_DrawBuffer, fn); -} - -typedef void (GLAPIENTRYP _glptr_Clear)(GLbitfield); -#define CALL_Clear(disp, parameters) \ - (* GET_Clear(disp)) parameters -static inline _glptr_Clear GET_Clear(struct _glapi_table *disp) { - return (_glptr_Clear) (GET_by_offset(disp, _gloffset_Clear)); -} - -static inline void SET_Clear(struct _glapi_table *disp, void (GLAPIENTRYP fn)(GLbitfield)) { - SET_by_offset(disp, _gloffset_Clear, fn); -} - -typedef void (GLAPIENTRYP _glptr_ClearAccum)(GLfloat, GLfloat, GLfloat, GLfloat); -#define CALL_ClearAccum(disp, parameters) \ - (* GET_ClearAccum(disp)) parameters -static inline _glptr_ClearAccum GET_ClearAccum(struct _glapi_table *disp) { - return (_glptr_ClearAccum) (GET_by_offset(disp, _gloffset_ClearAccum)); -} - -static inline void SET_ClearAccum(struct _glapi_table *disp, void (GLAPIENTRYP fn)(GLfloat, GLfloat, GLfloat, GLfloat)) { - SET_by_offset(disp, _gloffset_ClearAccum, fn); -} - -typedef void (GLAPIENTRYP _glptr_ClearIndex)(GLfloat); -#define CALL_ClearIndex(disp, parameters) \ - (* GET_ClearIndex(disp)) parameters -static inline _glptr_ClearIndex GET_ClearIndex(struct _glapi_table *disp) { - return (_glptr_ClearIndex) (GET_by_offset(disp, _gloffset_ClearIndex)); -} - -static inline void SET_ClearIndex(struct _glapi_table *disp, void (GLAPIENTRYP fn)(GLfloat)) { - SET_by_offset(disp, _gloffset_ClearIndex, fn); -} - -typedef void (GLAPIENTRYP _glptr_ClearColor)(GLclampf, GLclampf, GLclampf, GLclampf); -#define CALL_ClearColor(disp, parameters) \ - (* GET_ClearColor(disp)) parameters -static inline _glptr_ClearColor GET_ClearColor(struct _glapi_table *disp) { - return (_glptr_ClearColor) (GET_by_offset(disp, _gloffset_ClearColor)); -} - -static inline void SET_ClearColor(struct _glapi_table *disp, void (GLAPIENTRYP fn)(GLclampf, GLclampf, GLclampf, GLclampf)) { - SET_by_offset(disp, _gloffset_ClearColor, fn); -} - -typedef void (GLAPIENTRYP _glptr_ClearStencil)(GLint); -#define CALL_ClearStencil(disp, parameters) \ - (* GET_ClearStencil(disp)) parameters -static inline _glptr_ClearStencil GET_ClearStencil(struct _glapi_table *disp) { - return (_glptr_ClearStencil) (GET_by_offset(disp, _gloffset_ClearStencil)); -} - -static inline void SET_ClearStencil(struct _glapi_table *disp, void (GLAPIENTRYP fn)(GLint)) { - SET_by_offset(disp, _gloffset_ClearStencil, fn); -} - -typedef void (GLAPIENTRYP _glptr_ClearDepth)(GLclampd); -#define CALL_ClearDepth(disp, parameters) \ - (* GET_ClearDepth(disp)) parameters -static inline _glptr_ClearDepth GET_ClearDepth(struct _glapi_table *disp) { - return (_glptr_ClearDepth) (GET_by_offset(disp, _gloffset_ClearDepth)); -} - -static inline void SET_ClearDepth(struct _glapi_table *disp, void (GLAPIENTRYP fn)(GLclampd)) { - SET_by_offset(disp, _gloffset_ClearDepth, fn); -} - -typedef void (GLAPIENTRYP _glptr_StencilMask)(GLuint); -#define CALL_StencilMask(disp, parameters) \ - (* GET_StencilMask(disp)) parameters -static inline _glptr_StencilMask GET_StencilMask(struct _glapi_table *disp) { - return (_glptr_StencilMask) (GET_by_offset(disp, _gloffset_StencilMask)); -} - -static inline void SET_StencilMask(struct _glapi_table *disp, void (GLAPIENTRYP fn)(GLuint)) { - SET_by_offset(disp, _gloffset_StencilMask, fn); -} - -typedef void (GLAPIENTRYP _glptr_ColorMask)(GLboolean, GLboolean, GLboolean, GLboolean); -#define CALL_ColorMask(disp, parameters) \ - (* GET_ColorMask(disp)) parameters -static inline _glptr_ColorMask GET_ColorMask(struct _glapi_table *disp) { - return (_glptr_ColorMask) (GET_by_offset(disp, _gloffset_ColorMask)); -} - -static inline void SET_ColorMask(struct _glapi_table *disp, void (GLAPIENTRYP fn)(GLboolean, GLboolean, GLboolean, GLboolean)) { - SET_by_offset(disp, _gloffset_ColorMask, fn); -} - -typedef void (GLAPIENTRYP _glptr_DepthMask)(GLboolean); -#define CALL_DepthMask(disp, parameters) \ - (* GET_DepthMask(disp)) parameters -static inline _glptr_DepthMask GET_DepthMask(struct _glapi_table *disp) { - return (_glptr_DepthMask) (GET_by_offset(disp, _gloffset_DepthMask)); -} - -static inline void SET_DepthMask(struct _glapi_table *disp, void (GLAPIENTRYP fn)(GLboolean)) { - SET_by_offset(disp, _gloffset_DepthMask, fn); -} - -typedef void (GLAPIENTRYP _glptr_IndexMask)(GLuint); -#define CALL_IndexMask(disp, parameters) \ - (* GET_IndexMask(disp)) parameters -static inline _glptr_IndexMask GET_IndexMask(struct _glapi_table *disp) { - return (_glptr_IndexMask) (GET_by_offset(disp, _gloffset_IndexMask)); -} - -static inline void SET_IndexMask(struct _glapi_table *disp, void (GLAPIENTRYP fn)(GLuint)) { - SET_by_offset(disp, _gloffset_IndexMask, fn); -} - -typedef void (GLAPIENTRYP _glptr_Accum)(GLenum, GLfloat); -#define CALL_Accum(disp, parameters) \ - (* GET_Accum(disp)) parameters -static inline _glptr_Accum GET_Accum(struct _glapi_table *disp) { - return (_glptr_Accum) (GET_by_offset(disp, _gloffset_Accum)); -} - -static inline void SET_Accum(struct _glapi_table *disp, void (GLAPIENTRYP fn)(GLenum, GLfloat)) { - SET_by_offset(disp, _gloffset_Accum, fn); -} - -typedef void (GLAPIENTRYP _glptr_Disable)(GLenum); -#define CALL_Disable(disp, parameters) \ - (* GET_Disable(disp)) parameters -static inline _glptr_Disable GET_Disable(struct _glapi_table *disp) { - return (_glptr_Disable) (GET_by_offset(disp, _gloffset_Disable)); -} - -static inline void SET_Disable(struct _glapi_table *disp, void (GLAPIENTRYP fn)(GLenum)) { - SET_by_offset(disp, _gloffset_Disable, fn); -} - -typedef void (GLAPIENTRYP _glptr_Enable)(GLenum); -#define CALL_Enable(disp, parameters) \ - (* GET_Enable(disp)) parameters -static inline _glptr_Enable GET_Enable(struct _glapi_table *disp) { - return (_glptr_Enable) (GET_by_offset(disp, _gloffset_Enable)); -} - -static inline void SET_Enable(struct _glapi_table *disp, void (GLAPIENTRYP fn)(GLenum)) { - SET_by_offset(disp, _gloffset_Enable, fn); -} - -typedef void (GLAPIENTRYP _glptr_Finish)(void); -#define CALL_Finish(disp, parameters) \ - (* GET_Finish(disp)) parameters -static inline _glptr_Finish GET_Finish(struct _glapi_table *disp) { - return (_glptr_Finish) (GET_by_offset(disp, _gloffset_Finish)); -} - -static inline void SET_Finish(struct _glapi_table *disp, void (GLAPIENTRYP fn)(void)) { - SET_by_offset(disp, _gloffset_Finish, fn); -} - -typedef void (GLAPIENTRYP _glptr_Flush)(void); -#define CALL_Flush(disp, parameters) \ - (* GET_Flush(disp)) parameters -static inline _glptr_Flush GET_Flush(struct _glapi_table *disp) { - return (_glptr_Flush) (GET_by_offset(disp, _gloffset_Flush)); -} - -static inline void SET_Flush(struct _glapi_table *disp, void (GLAPIENTRYP fn)(void)) { - SET_by_offset(disp, _gloffset_Flush, fn); -} - -typedef void (GLAPIENTRYP _glptr_PopAttrib)(void); -#define CALL_PopAttrib(disp, parameters) \ - (* GET_PopAttrib(disp)) parameters -static inline _glptr_PopAttrib GET_PopAttrib(struct _glapi_table *disp) { - return (_glptr_PopAttrib) (GET_by_offset(disp, _gloffset_PopAttrib)); -} - -static inline void SET_PopAttrib(struct _glapi_table *disp, void (GLAPIENTRYP fn)(void)) { - SET_by_offset(disp, _gloffset_PopAttrib, fn); -} - -typedef void (GLAPIENTRYP _glptr_PushAttrib)(GLbitfield); -#define CALL_PushAttrib(disp, parameters) \ - (* GET_PushAttrib(disp)) parameters -static inline _glptr_PushAttrib GET_PushAttrib(struct _glapi_table *disp) { - return (_glptr_PushAttrib) (GET_by_offset(disp, _gloffset_PushAttrib)); -} - -static inline void SET_PushAttrib(struct _glapi_table *disp, void (GLAPIENTRYP fn)(GLbitfield)) { - SET_by_offset(disp, _gloffset_PushAttrib, fn); -} - -typedef void (GLAPIENTRYP _glptr_Map1d)(GLenum, GLdouble, GLdouble, GLint, GLint, const GLdouble *); -#define CALL_Map1d(disp, parameters) \ - (* GET_Map1d(disp)) parameters -static inline _glptr_Map1d GET_Map1d(struct _glapi_table *disp) { - return (_glptr_Map1d) (GET_by_offset(disp, _gloffset_Map1d)); -} - -static inline void SET_Map1d(struct _glapi_table *disp, void (GLAPIENTRYP fn)(GLenum, GLdouble, GLdouble, GLint, GLint, const GLdouble *)) { - SET_by_offset(disp, _gloffset_Map1d, fn); -} - -typedef void (GLAPIENTRYP _glptr_Map1f)(GLenum, GLfloat, GLfloat, GLint, GLint, const GLfloat *); -#define CALL_Map1f(disp, parameters) \ - (* GET_Map1f(disp)) parameters -static inline _glptr_Map1f GET_Map1f(struct _glapi_table *disp) { - return (_glptr_Map1f) (GET_by_offset(disp, _gloffset_Map1f)); -} - -static inline void SET_Map1f(struct _glapi_table *disp, void (GLAPIENTRYP fn)(GLenum, GLfloat, GLfloat, GLint, GLint, const GLfloat *)) { - SET_by_offset(disp, _gloffset_Map1f, fn); -} - -typedef void (GLAPIENTRYP _glptr_Map2d)(GLenum, GLdouble, GLdouble, GLint, GLint, GLdouble, GLdouble, GLint, GLint, const GLdouble *); -#define CALL_Map2d(disp, parameters) \ - (* GET_Map2d(disp)) parameters -static inline _glptr_Map2d GET_Map2d(struct _glapi_table *disp) { - return (_glptr_Map2d) (GET_by_offset(disp, _gloffset_Map2d)); -} - -static inline void SET_Map2d(struct _glapi_table *disp, void (GLAPIENTRYP fn)(GLenum, GLdouble, GLdouble, GLint, GLint, GLdouble, GLdouble, GLint, GLint, const GLdouble *)) { - SET_by_offset(disp, _gloffset_Map2d, fn); -} - -typedef void (GLAPIENTRYP _glptr_Map2f)(GLenum, GLfloat, GLfloat, GLint, GLint, GLfloat, GLfloat, GLint, GLint, const GLfloat *); -#define CALL_Map2f(disp, parameters) \ - (* GET_Map2f(disp)) parameters -static inline _glptr_Map2f GET_Map2f(struct _glapi_table *disp) { - return (_glptr_Map2f) (GET_by_offset(disp, _gloffset_Map2f)); -} - -static inline void SET_Map2f(struct _glapi_table *disp, void (GLAPIENTRYP fn)(GLenum, GLfloat, GLfloat, GLint, GLint, GLfloat, GLfloat, GLint, GLint, const GLfloat *)) { - SET_by_offset(disp, _gloffset_Map2f, fn); -} - -typedef void (GLAPIENTRYP _glptr_MapGrid1d)(GLint, GLdouble, GLdouble); -#define CALL_MapGrid1d(disp, parameters) \ - (* GET_MapGrid1d(disp)) parameters -static inline _glptr_MapGrid1d GET_MapGrid1d(struct _glapi_table *disp) { - return (_glptr_MapGrid1d) (GET_by_offset(disp, _gloffset_MapGrid1d)); -} - -static inline void SET_MapGrid1d(struct _glapi_table *disp, void (GLAPIENTRYP fn)(GLint, GLdouble, GLdouble)) { - SET_by_offset(disp, _gloffset_MapGrid1d, fn); -} - -typedef void (GLAPIENTRYP _glptr_MapGrid1f)(GLint, GLfloat, GLfloat); -#define CALL_MapGrid1f(disp, parameters) \ - (* GET_MapGrid1f(disp)) parameters -static inline _glptr_MapGrid1f GET_MapGrid1f(struct _glapi_table *disp) { - return (_glptr_MapGrid1f) (GET_by_offset(disp, _gloffset_MapGrid1f)); -} - -static inline void SET_MapGrid1f(struct _glapi_table *disp, void (GLAPIENTRYP fn)(GLint, GLfloat, GLfloat)) { - SET_by_offset(disp, _gloffset_MapGrid1f, fn); -} - -typedef void (GLAPIENTRYP _glptr_MapGrid2d)(GLint, GLdouble, GLdouble, GLint, GLdouble, GLdouble); -#define CALL_MapGrid2d(disp, parameters) \ - (* GET_MapGrid2d(disp)) parameters -static inline _glptr_MapGrid2d GET_MapGrid2d(struct _glapi_table *disp) { - return (_glptr_MapGrid2d) (GET_by_offset(disp, _gloffset_MapGrid2d)); -} - -static inline void SET_MapGrid2d(struct _glapi_table *disp, void (GLAPIENTRYP fn)(GLint, GLdouble, GLdouble, GLint, GLdouble, GLdouble)) { - SET_by_offset(disp, _gloffset_MapGrid2d, fn); -} - -typedef void (GLAPIENTRYP _glptr_MapGrid2f)(GLint, GLfloat, GLfloat, GLint, GLfloat, GLfloat); -#define CALL_MapGrid2f(disp, parameters) \ - (* GET_MapGrid2f(disp)) parameters -static inline _glptr_MapGrid2f GET_MapGrid2f(struct _glapi_table *disp) { - return (_glptr_MapGrid2f) (GET_by_offset(disp, _gloffset_MapGrid2f)); -} - -static inline void SET_MapGrid2f(struct _glapi_table *disp, void (GLAPIENTRYP fn)(GLint, GLfloat, GLfloat, GLint, GLfloat, GLfloat)) { - SET_by_offset(disp, _gloffset_MapGrid2f, fn); -} - -typedef void (GLAPIENTRYP _glptr_EvalCoord1d)(GLdouble); -#define CALL_EvalCoord1d(disp, parameters) \ - (* GET_EvalCoord1d(disp)) parameters -static inline _glptr_EvalCoord1d GET_EvalCoord1d(struct _glapi_table *disp) { - return (_glptr_EvalCoord1d) (GET_by_offset(disp, _gloffset_EvalCoord1d)); -} - -static inline void SET_EvalCoord1d(struct _glapi_table *disp, void (GLAPIENTRYP fn)(GLdouble)) { - SET_by_offset(disp, _gloffset_EvalCoord1d, fn); -} - -typedef void (GLAPIENTRYP _glptr_EvalCoord1dv)(const GLdouble *); -#define CALL_EvalCoord1dv(disp, parameters) \ - (* GET_EvalCoord1dv(disp)) parameters -static inline _glptr_EvalCoord1dv GET_EvalCoord1dv(struct _glapi_table *disp) { - return (_glptr_EvalCoord1dv) (GET_by_offset(disp, _gloffset_EvalCoord1dv)); -} - -static inline void SET_EvalCoord1dv(struct _glapi_table *disp, void (GLAPIENTRYP fn)(const GLdouble *)) { - SET_by_offset(disp, _gloffset_EvalCoord1dv, fn); -} - -typedef void (GLAPIENTRYP _glptr_EvalCoord1f)(GLfloat); -#define CALL_EvalCoord1f(disp, parameters) \ - (* GET_EvalCoord1f(disp)) parameters -static inline _glptr_EvalCoord1f GET_EvalCoord1f(struct _glapi_table *disp) { - return (_glptr_EvalCoord1f) (GET_by_offset(disp, _gloffset_EvalCoord1f)); -} - -static inline void SET_EvalCoord1f(struct _glapi_table *disp, void (GLAPIENTRYP fn)(GLfloat)) { - SET_by_offset(disp, _gloffset_EvalCoord1f, fn); -} - -typedef void (GLAPIENTRYP _glptr_EvalCoord1fv)(const GLfloat *); -#define CALL_EvalCoord1fv(disp, parameters) \ - (* GET_EvalCoord1fv(disp)) parameters -static inline _glptr_EvalCoord1fv GET_EvalCoord1fv(struct _glapi_table *disp) { - return (_glptr_EvalCoord1fv) (GET_by_offset(disp, _gloffset_EvalCoord1fv)); -} - -static inline void SET_EvalCoord1fv(struct _glapi_table *disp, void (GLAPIENTRYP fn)(const GLfloat *)) { - SET_by_offset(disp, _gloffset_EvalCoord1fv, fn); -} - -typedef void (GLAPIENTRYP _glptr_EvalCoord2d)(GLdouble, GLdouble); -#define CALL_EvalCoord2d(disp, parameters) \ - (* GET_EvalCoord2d(disp)) parameters -static inline _glptr_EvalCoord2d GET_EvalCoord2d(struct _glapi_table *disp) { - return (_glptr_EvalCoord2d) (GET_by_offset(disp, _gloffset_EvalCoord2d)); -} - -static inline void SET_EvalCoord2d(struct _glapi_table *disp, void (GLAPIENTRYP fn)(GLdouble, GLdouble)) { - SET_by_offset(disp, _gloffset_EvalCoord2d, fn); -} - -typedef void (GLAPIENTRYP _glptr_EvalCoord2dv)(const GLdouble *); -#define CALL_EvalCoord2dv(disp, parameters) \ - (* GET_EvalCoord2dv(disp)) parameters -static inline _glptr_EvalCoord2dv GET_EvalCoord2dv(struct _glapi_table *disp) { - return (_glptr_EvalCoord2dv) (GET_by_offset(disp, _gloffset_EvalCoord2dv)); -} - -static inline void SET_EvalCoord2dv(struct _glapi_table *disp, void (GLAPIENTRYP fn)(const GLdouble *)) { - SET_by_offset(disp, _gloffset_EvalCoord2dv, fn); -} - -typedef void (GLAPIENTRYP _glptr_EvalCoord2f)(GLfloat, GLfloat); -#define CALL_EvalCoord2f(disp, parameters) \ - (* GET_EvalCoord2f(disp)) parameters -static inline _glptr_EvalCoord2f GET_EvalCoord2f(struct _glapi_table *disp) { - return (_glptr_EvalCoord2f) (GET_by_offset(disp, _gloffset_EvalCoord2f)); -} - -static inline void SET_EvalCoord2f(struct _glapi_table *disp, void (GLAPIENTRYP fn)(GLfloat, GLfloat)) { - SET_by_offset(disp, _gloffset_EvalCoord2f, fn); -} - -typedef void (GLAPIENTRYP _glptr_EvalCoord2fv)(const GLfloat *); -#define CALL_EvalCoord2fv(disp, parameters) \ - (* GET_EvalCoord2fv(disp)) parameters -static inline _glptr_EvalCoord2fv GET_EvalCoord2fv(struct _glapi_table *disp) { - return (_glptr_EvalCoord2fv) (GET_by_offset(disp, _gloffset_EvalCoord2fv)); -} - -static inline void SET_EvalCoord2fv(struct _glapi_table *disp, void (GLAPIENTRYP fn)(const GLfloat *)) { - SET_by_offset(disp, _gloffset_EvalCoord2fv, fn); -} - -typedef void (GLAPIENTRYP _glptr_EvalMesh1)(GLenum, GLint, GLint); -#define CALL_EvalMesh1(disp, parameters) \ - (* GET_EvalMesh1(disp)) parameters -static inline _glptr_EvalMesh1 GET_EvalMesh1(struct _glapi_table *disp) { - return (_glptr_EvalMesh1) (GET_by_offset(disp, _gloffset_EvalMesh1)); -} - -static inline void SET_EvalMesh1(struct _glapi_table *disp, void (GLAPIENTRYP fn)(GLenum, GLint, GLint)) { - SET_by_offset(disp, _gloffset_EvalMesh1, fn); -} - -typedef void (GLAPIENTRYP _glptr_EvalPoint1)(GLint); -#define CALL_EvalPoint1(disp, parameters) \ - (* GET_EvalPoint1(disp)) parameters -static inline _glptr_EvalPoint1 GET_EvalPoint1(struct _glapi_table *disp) { - return (_glptr_EvalPoint1) (GET_by_offset(disp, _gloffset_EvalPoint1)); -} - -static inline void SET_EvalPoint1(struct _glapi_table *disp, void (GLAPIENTRYP fn)(GLint)) { - SET_by_offset(disp, _gloffset_EvalPoint1, fn); -} - -typedef void (GLAPIENTRYP _glptr_EvalMesh2)(GLenum, GLint, GLint, GLint, GLint); -#define CALL_EvalMesh2(disp, parameters) \ - (* GET_EvalMesh2(disp)) parameters -static inline _glptr_EvalMesh2 GET_EvalMesh2(struct _glapi_table *disp) { - return (_glptr_EvalMesh2) (GET_by_offset(disp, _gloffset_EvalMesh2)); -} - -static inline void SET_EvalMesh2(struct _glapi_table *disp, void (GLAPIENTRYP fn)(GLenum, GLint, GLint, GLint, GLint)) { - SET_by_offset(disp, _gloffset_EvalMesh2, fn); -} - -typedef void (GLAPIENTRYP _glptr_EvalPoint2)(GLint, GLint); -#define CALL_EvalPoint2(disp, parameters) \ - (* GET_EvalPoint2(disp)) parameters -static inline _glptr_EvalPoint2 GET_EvalPoint2(struct _glapi_table *disp) { - return (_glptr_EvalPoint2) (GET_by_offset(disp, _gloffset_EvalPoint2)); -} - -static inline void SET_EvalPoint2(struct _glapi_table *disp, void (GLAPIENTRYP fn)(GLint, GLint)) { - SET_by_offset(disp, _gloffset_EvalPoint2, fn); -} - -typedef void (GLAPIENTRYP _glptr_AlphaFunc)(GLenum, GLclampf); -#define CALL_AlphaFunc(disp, parameters) \ - (* GET_AlphaFunc(disp)) parameters -static inline _glptr_AlphaFunc GET_AlphaFunc(struct _glapi_table *disp) { - return (_glptr_AlphaFunc) (GET_by_offset(disp, _gloffset_AlphaFunc)); -} - -static inline void SET_AlphaFunc(struct _glapi_table *disp, void (GLAPIENTRYP fn)(GLenum, GLclampf)) { - SET_by_offset(disp, _gloffset_AlphaFunc, fn); -} - -typedef void (GLAPIENTRYP _glptr_BlendFunc)(GLenum, GLenum); -#define CALL_BlendFunc(disp, parameters) \ - (* GET_BlendFunc(disp)) parameters -static inline _glptr_BlendFunc GET_BlendFunc(struct _glapi_table *disp) { - return (_glptr_BlendFunc) (GET_by_offset(disp, _gloffset_BlendFunc)); -} - -static inline void SET_BlendFunc(struct _glapi_table *disp, void (GLAPIENTRYP fn)(GLenum, GLenum)) { - SET_by_offset(disp, _gloffset_BlendFunc, fn); -} - -typedef void (GLAPIENTRYP _glptr_LogicOp)(GLenum); -#define CALL_LogicOp(disp, parameters) \ - (* GET_LogicOp(disp)) parameters -static inline _glptr_LogicOp GET_LogicOp(struct _glapi_table *disp) { - return (_glptr_LogicOp) (GET_by_offset(disp, _gloffset_LogicOp)); -} - -static inline void SET_LogicOp(struct _glapi_table *disp, void (GLAPIENTRYP fn)(GLenum)) { - SET_by_offset(disp, _gloffset_LogicOp, fn); -} - -typedef void (GLAPIENTRYP _glptr_StencilFunc)(GLenum, GLint, GLuint); -#define CALL_StencilFunc(disp, parameters) \ - (* GET_StencilFunc(disp)) parameters -static inline _glptr_StencilFunc GET_StencilFunc(struct _glapi_table *disp) { - return (_glptr_StencilFunc) (GET_by_offset(disp, _gloffset_StencilFunc)); -} - -static inline void SET_StencilFunc(struct _glapi_table *disp, void (GLAPIENTRYP fn)(GLenum, GLint, GLuint)) { - SET_by_offset(disp, _gloffset_StencilFunc, fn); -} - -typedef void (GLAPIENTRYP _glptr_StencilOp)(GLenum, GLenum, GLenum); -#define CALL_StencilOp(disp, parameters) \ - (* GET_StencilOp(disp)) parameters -static inline _glptr_StencilOp GET_StencilOp(struct _glapi_table *disp) { - return (_glptr_StencilOp) (GET_by_offset(disp, _gloffset_StencilOp)); -} - -static inline void SET_StencilOp(struct _glapi_table *disp, void (GLAPIENTRYP fn)(GLenum, GLenum, GLenum)) { - SET_by_offset(disp, _gloffset_StencilOp, fn); -} - -typedef void (GLAPIENTRYP _glptr_DepthFunc)(GLenum); -#define CALL_DepthFunc(disp, parameters) \ - (* GET_DepthFunc(disp)) parameters -static inline _glptr_DepthFunc GET_DepthFunc(struct _glapi_table *disp) { - return (_glptr_DepthFunc) (GET_by_offset(disp, _gloffset_DepthFunc)); -} - -static inline void SET_DepthFunc(struct _glapi_table *disp, void (GLAPIENTRYP fn)(GLenum)) { - SET_by_offset(disp, _gloffset_DepthFunc, fn); -} - -typedef void (GLAPIENTRYP _glptr_PixelZoom)(GLfloat, GLfloat); -#define CALL_PixelZoom(disp, parameters) \ - (* GET_PixelZoom(disp)) parameters -static inline _glptr_PixelZoom GET_PixelZoom(struct _glapi_table *disp) { - return (_glptr_PixelZoom) (GET_by_offset(disp, _gloffset_PixelZoom)); -} - -static inline void SET_PixelZoom(struct _glapi_table *disp, void (GLAPIENTRYP fn)(GLfloat, GLfloat)) { - SET_by_offset(disp, _gloffset_PixelZoom, fn); -} - -typedef void (GLAPIENTRYP _glptr_PixelTransferf)(GLenum, GLfloat); -#define CALL_PixelTransferf(disp, parameters) \ - (* GET_PixelTransferf(disp)) parameters -static inline _glptr_PixelTransferf GET_PixelTransferf(struct _glapi_table *disp) { - return (_glptr_PixelTransferf) (GET_by_offset(disp, _gloffset_PixelTransferf)); -} - -static inline void SET_PixelTransferf(struct _glapi_table *disp, void (GLAPIENTRYP fn)(GLenum, GLfloat)) { - SET_by_offset(disp, _gloffset_PixelTransferf, fn); -} - -typedef void (GLAPIENTRYP _glptr_PixelTransferi)(GLenum, GLint); -#define CALL_PixelTransferi(disp, parameters) \ - (* GET_PixelTransferi(disp)) parameters -static inline _glptr_PixelTransferi GET_PixelTransferi(struct _glapi_table *disp) { - return (_glptr_PixelTransferi) (GET_by_offset(disp, _gloffset_PixelTransferi)); -} - -static inline void SET_PixelTransferi(struct _glapi_table *disp, void (GLAPIENTRYP fn)(GLenum, GLint)) { - SET_by_offset(disp, _gloffset_PixelTransferi, fn); -} - -typedef void (GLAPIENTRYP _glptr_PixelStoref)(GLenum, GLfloat); -#define CALL_PixelStoref(disp, parameters) \ - (* GET_PixelStoref(disp)) parameters -static inline _glptr_PixelStoref GET_PixelStoref(struct _glapi_table *disp) { - return (_glptr_PixelStoref) (GET_by_offset(disp, _gloffset_PixelStoref)); -} - -static inline void SET_PixelStoref(struct _glapi_table *disp, void (GLAPIENTRYP fn)(GLenum, GLfloat)) { - SET_by_offset(disp, _gloffset_PixelStoref, fn); -} - -typedef void (GLAPIENTRYP _glptr_PixelStorei)(GLenum, GLint); -#define CALL_PixelStorei(disp, parameters) \ - (* GET_PixelStorei(disp)) parameters -static inline _glptr_PixelStorei GET_PixelStorei(struct _glapi_table *disp) { - return (_glptr_PixelStorei) (GET_by_offset(disp, _gloffset_PixelStorei)); -} - -static inline void SET_PixelStorei(struct _glapi_table *disp, void (GLAPIENTRYP fn)(GLenum, GLint)) { - SET_by_offset(disp, _gloffset_PixelStorei, fn); -} - -typedef void (GLAPIENTRYP _glptr_PixelMapfv)(GLenum, GLsizei, const GLfloat *); -#define CALL_PixelMapfv(disp, parameters) \ - (* GET_PixelMapfv(disp)) parameters -static inline _glptr_PixelMapfv GET_PixelMapfv(struct _glapi_table *disp) { - return (_glptr_PixelMapfv) (GET_by_offset(disp, _gloffset_PixelMapfv)); -} - -static inline void SET_PixelMapfv(struct _glapi_table *disp, void (GLAPIENTRYP fn)(GLenum, GLsizei, const GLfloat *)) { - SET_by_offset(disp, _gloffset_PixelMapfv, fn); -} - -typedef void (GLAPIENTRYP _glptr_PixelMapuiv)(GLenum, GLsizei, const GLuint *); -#define CALL_PixelMapuiv(disp, parameters) \ - (* GET_PixelMapuiv(disp)) parameters -static inline _glptr_PixelMapuiv GET_PixelMapuiv(struct _glapi_table *disp) { - return (_glptr_PixelMapuiv) (GET_by_offset(disp, _gloffset_PixelMapuiv)); -} - -static inline void SET_PixelMapuiv(struct _glapi_table *disp, void (GLAPIENTRYP fn)(GLenum, GLsizei, const GLuint *)) { - SET_by_offset(disp, _gloffset_PixelMapuiv, fn); -} - -typedef void (GLAPIENTRYP _glptr_PixelMapusv)(GLenum, GLsizei, const GLushort *); -#define CALL_PixelMapusv(disp, parameters) \ - (* GET_PixelMapusv(disp)) parameters -static inline _glptr_PixelMapusv GET_PixelMapusv(struct _glapi_table *disp) { - return (_glptr_PixelMapusv) (GET_by_offset(disp, _gloffset_PixelMapusv)); -} - -static inline void SET_PixelMapusv(struct _glapi_table *disp, void (GLAPIENTRYP fn)(GLenum, GLsizei, const GLushort *)) { - SET_by_offset(disp, _gloffset_PixelMapusv, fn); -} - -typedef void (GLAPIENTRYP _glptr_ReadBuffer)(GLenum); -#define CALL_ReadBuffer(disp, parameters) \ - (* GET_ReadBuffer(disp)) parameters -static inline _glptr_ReadBuffer GET_ReadBuffer(struct _glapi_table *disp) { - return (_glptr_ReadBuffer) (GET_by_offset(disp, _gloffset_ReadBuffer)); -} - -static inline void SET_ReadBuffer(struct _glapi_table *disp, void (GLAPIENTRYP fn)(GLenum)) { - SET_by_offset(disp, _gloffset_ReadBuffer, fn); -} - -typedef void (GLAPIENTRYP _glptr_CopyPixels)(GLint, GLint, GLsizei, GLsizei, GLenum); -#define CALL_CopyPixels(disp, parameters) \ - (* GET_CopyPixels(disp)) parameters -static inline _glptr_CopyPixels GET_CopyPixels(struct _glapi_table *disp) { - return (_glptr_CopyPixels) (GET_by_offset(disp, _gloffset_CopyPixels)); -} - -static inline void SET_CopyPixels(struct _glapi_table *disp, void (GLAPIENTRYP fn)(GLint, GLint, GLsizei, GLsizei, GLenum)) { - SET_by_offset(disp, _gloffset_CopyPixels, fn); -} - -typedef void (GLAPIENTRYP _glptr_ReadPixels)(GLint, GLint, GLsizei, GLsizei, GLenum, GLenum, GLvoid *); -#define CALL_ReadPixels(disp, parameters) \ - (* GET_ReadPixels(disp)) parameters -static inline _glptr_ReadPixels GET_ReadPixels(struct _glapi_table *disp) { - return (_glptr_ReadPixels) (GET_by_offset(disp, _gloffset_ReadPixels)); -} - -static inline void SET_ReadPixels(struct _glapi_table *disp, void (GLAPIENTRYP fn)(GLint, GLint, GLsizei, GLsizei, GLenum, GLenum, GLvoid *)) { - SET_by_offset(disp, _gloffset_ReadPixels, fn); -} - -typedef void (GLAPIENTRYP _glptr_DrawPixels)(GLsizei, GLsizei, GLenum, GLenum, const GLvoid *); -#define CALL_DrawPixels(disp, parameters) \ - (* GET_DrawPixels(disp)) parameters -static inline _glptr_DrawPixels GET_DrawPixels(struct _glapi_table *disp) { - return (_glptr_DrawPixels) (GET_by_offset(disp, _gloffset_DrawPixels)); -} - -static inline void SET_DrawPixels(struct _glapi_table *disp, void (GLAPIENTRYP fn)(GLsizei, GLsizei, GLenum, GLenum, const GLvoid *)) { - SET_by_offset(disp, _gloffset_DrawPixels, fn); -} - -typedef void (GLAPIENTRYP _glptr_GetBooleanv)(GLenum, GLboolean *); -#define CALL_GetBooleanv(disp, parameters) \ - (* GET_GetBooleanv(disp)) parameters -static inline _glptr_GetBooleanv GET_GetBooleanv(struct _glapi_table *disp) { - return (_glptr_GetBooleanv) (GET_by_offset(disp, _gloffset_GetBooleanv)); -} - -static inline void SET_GetBooleanv(struct _glapi_table *disp, void (GLAPIENTRYP fn)(GLenum, GLboolean *)) { - SET_by_offset(disp, _gloffset_GetBooleanv, fn); -} - -typedef void (GLAPIENTRYP _glptr_GetClipPlane)(GLenum, GLdouble *); -#define CALL_GetClipPlane(disp, parameters) \ - (* GET_GetClipPlane(disp)) parameters -static inline _glptr_GetClipPlane GET_GetClipPlane(struct _glapi_table *disp) { - return (_glptr_GetClipPlane) (GET_by_offset(disp, _gloffset_GetClipPlane)); -} - -static inline void SET_GetClipPlane(struct _glapi_table *disp, void (GLAPIENTRYP fn)(GLenum, GLdouble *)) { - SET_by_offset(disp, _gloffset_GetClipPlane, fn); -} - -typedef void (GLAPIENTRYP _glptr_GetDoublev)(GLenum, GLdouble *); -#define CALL_GetDoublev(disp, parameters) \ - (* GET_GetDoublev(disp)) parameters -static inline _glptr_GetDoublev GET_GetDoublev(struct _glapi_table *disp) { - return (_glptr_GetDoublev) (GET_by_offset(disp, _gloffset_GetDoublev)); -} - -static inline void SET_GetDoublev(struct _glapi_table *disp, void (GLAPIENTRYP fn)(GLenum, GLdouble *)) { - SET_by_offset(disp, _gloffset_GetDoublev, fn); -} - -typedef GLenum (GLAPIENTRYP _glptr_GetError)(void); -#define CALL_GetError(disp, parameters) \ - (* GET_GetError(disp)) parameters -static inline _glptr_GetError GET_GetError(struct _glapi_table *disp) { - return (_glptr_GetError) (GET_by_offset(disp, _gloffset_GetError)); -} - -static inline void SET_GetError(struct _glapi_table *disp, GLenum (GLAPIENTRYP fn)(void)) { - SET_by_offset(disp, _gloffset_GetError, fn); -} - -typedef void (GLAPIENTRYP _glptr_GetFloatv)(GLenum, GLfloat *); -#define CALL_GetFloatv(disp, parameters) \ - (* GET_GetFloatv(disp)) parameters -static inline _glptr_GetFloatv GET_GetFloatv(struct _glapi_table *disp) { - return (_glptr_GetFloatv) (GET_by_offset(disp, _gloffset_GetFloatv)); -} - -static inline void SET_GetFloatv(struct _glapi_table *disp, void (GLAPIENTRYP fn)(GLenum, GLfloat *)) { - SET_by_offset(disp, _gloffset_GetFloatv, fn); -} - -typedef void (GLAPIENTRYP _glptr_GetIntegerv)(GLenum, GLint *); -#define CALL_GetIntegerv(disp, parameters) \ - (* GET_GetIntegerv(disp)) parameters -static inline _glptr_GetIntegerv GET_GetIntegerv(struct _glapi_table *disp) { - return (_glptr_GetIntegerv) (GET_by_offset(disp, _gloffset_GetIntegerv)); -} - -static inline void SET_GetIntegerv(struct _glapi_table *disp, void (GLAPIENTRYP fn)(GLenum, GLint *)) { - SET_by_offset(disp, _gloffset_GetIntegerv, fn); -} - -typedef void (GLAPIENTRYP _glptr_GetLightfv)(GLenum, GLenum, GLfloat *); -#define CALL_GetLightfv(disp, parameters) \ - (* GET_GetLightfv(disp)) parameters -static inline _glptr_GetLightfv GET_GetLightfv(struct _glapi_table *disp) { - return (_glptr_GetLightfv) (GET_by_offset(disp, _gloffset_GetLightfv)); -} - -static inline void SET_GetLightfv(struct _glapi_table *disp, void (GLAPIENTRYP fn)(GLenum, GLenum, GLfloat *)) { - SET_by_offset(disp, _gloffset_GetLightfv, fn); -} - -typedef void (GLAPIENTRYP _glptr_GetLightiv)(GLenum, GLenum, GLint *); -#define CALL_GetLightiv(disp, parameters) \ - (* GET_GetLightiv(disp)) parameters -static inline _glptr_GetLightiv GET_GetLightiv(struct _glapi_table *disp) { - return (_glptr_GetLightiv) (GET_by_offset(disp, _gloffset_GetLightiv)); -} - -static inline void SET_GetLightiv(struct _glapi_table *disp, void (GLAPIENTRYP fn)(GLenum, GLenum, GLint *)) { - SET_by_offset(disp, _gloffset_GetLightiv, fn); -} - -typedef void (GLAPIENTRYP _glptr_GetMapdv)(GLenum, GLenum, GLdouble *); -#define CALL_GetMapdv(disp, parameters) \ - (* GET_GetMapdv(disp)) parameters -static inline _glptr_GetMapdv GET_GetMapdv(struct _glapi_table *disp) { - return (_glptr_GetMapdv) (GET_by_offset(disp, _gloffset_GetMapdv)); -} - -static inline void SET_GetMapdv(struct _glapi_table *disp, void (GLAPIENTRYP fn)(GLenum, GLenum, GLdouble *)) { - SET_by_offset(disp, _gloffset_GetMapdv, fn); -} - -typedef void (GLAPIENTRYP _glptr_GetMapfv)(GLenum, GLenum, GLfloat *); -#define CALL_GetMapfv(disp, parameters) \ - (* GET_GetMapfv(disp)) parameters -static inline _glptr_GetMapfv GET_GetMapfv(struct _glapi_table *disp) { - return (_glptr_GetMapfv) (GET_by_offset(disp, _gloffset_GetMapfv)); -} - -static inline void SET_GetMapfv(struct _glapi_table *disp, void (GLAPIENTRYP fn)(GLenum, GLenum, GLfloat *)) { - SET_by_offset(disp, _gloffset_GetMapfv, fn); -} - -typedef void (GLAPIENTRYP _glptr_GetMapiv)(GLenum, GLenum, GLint *); -#define CALL_GetMapiv(disp, parameters) \ - (* GET_GetMapiv(disp)) parameters -static inline _glptr_GetMapiv GET_GetMapiv(struct _glapi_table *disp) { - return (_glptr_GetMapiv) (GET_by_offset(disp, _gloffset_GetMapiv)); -} - -static inline void SET_GetMapiv(struct _glapi_table *disp, void (GLAPIENTRYP fn)(GLenum, GLenum, GLint *)) { - SET_by_offset(disp, _gloffset_GetMapiv, fn); -} - -typedef void (GLAPIENTRYP _glptr_GetMaterialfv)(GLenum, GLenum, GLfloat *); -#define CALL_GetMaterialfv(disp, parameters) \ - (* GET_GetMaterialfv(disp)) parameters -static inline _glptr_GetMaterialfv GET_GetMaterialfv(struct _glapi_table *disp) { - return (_glptr_GetMaterialfv) (GET_by_offset(disp, _gloffset_GetMaterialfv)); -} - -static inline void SET_GetMaterialfv(struct _glapi_table *disp, void (GLAPIENTRYP fn)(GLenum, GLenum, GLfloat *)) { - SET_by_offset(disp, _gloffset_GetMaterialfv, fn); -} - -typedef void (GLAPIENTRYP _glptr_GetMaterialiv)(GLenum, GLenum, GLint *); -#define CALL_GetMaterialiv(disp, parameters) \ - (* GET_GetMaterialiv(disp)) parameters -static inline _glptr_GetMaterialiv GET_GetMaterialiv(struct _glapi_table *disp) { - return (_glptr_GetMaterialiv) (GET_by_offset(disp, _gloffset_GetMaterialiv)); -} - -static inline void SET_GetMaterialiv(struct _glapi_table *disp, void (GLAPIENTRYP fn)(GLenum, GLenum, GLint *)) { - SET_by_offset(disp, _gloffset_GetMaterialiv, fn); -} - -typedef void (GLAPIENTRYP _glptr_GetPixelMapfv)(GLenum, GLfloat *); -#define CALL_GetPixelMapfv(disp, parameters) \ - (* GET_GetPixelMapfv(disp)) parameters -static inline _glptr_GetPixelMapfv GET_GetPixelMapfv(struct _glapi_table *disp) { - return (_glptr_GetPixelMapfv) (GET_by_offset(disp, _gloffset_GetPixelMapfv)); -} - -static inline void SET_GetPixelMapfv(struct _glapi_table *disp, void (GLAPIENTRYP fn)(GLenum, GLfloat *)) { - SET_by_offset(disp, _gloffset_GetPixelMapfv, fn); -} - -typedef void (GLAPIENTRYP _glptr_GetPixelMapuiv)(GLenum, GLuint *); -#define CALL_GetPixelMapuiv(disp, parameters) \ - (* GET_GetPixelMapuiv(disp)) parameters -static inline _glptr_GetPixelMapuiv GET_GetPixelMapuiv(struct _glapi_table *disp) { - return (_glptr_GetPixelMapuiv) (GET_by_offset(disp, _gloffset_GetPixelMapuiv)); -} - -static inline void SET_GetPixelMapuiv(struct _glapi_table *disp, void (GLAPIENTRYP fn)(GLenum, GLuint *)) { - SET_by_offset(disp, _gloffset_GetPixelMapuiv, fn); -} - -typedef void (GLAPIENTRYP _glptr_GetPixelMapusv)(GLenum, GLushort *); -#define CALL_GetPixelMapusv(disp, parameters) \ - (* GET_GetPixelMapusv(disp)) parameters -static inline _glptr_GetPixelMapusv GET_GetPixelMapusv(struct _glapi_table *disp) { - return (_glptr_GetPixelMapusv) (GET_by_offset(disp, _gloffset_GetPixelMapusv)); -} - -static inline void SET_GetPixelMapusv(struct _glapi_table *disp, void (GLAPIENTRYP fn)(GLenum, GLushort *)) { - SET_by_offset(disp, _gloffset_GetPixelMapusv, fn); -} - -typedef void (GLAPIENTRYP _glptr_GetPolygonStipple)(GLubyte *); -#define CALL_GetPolygonStipple(disp, parameters) \ - (* GET_GetPolygonStipple(disp)) parameters -static inline _glptr_GetPolygonStipple GET_GetPolygonStipple(struct _glapi_table *disp) { - return (_glptr_GetPolygonStipple) (GET_by_offset(disp, _gloffset_GetPolygonStipple)); -} - -static inline void SET_GetPolygonStipple(struct _glapi_table *disp, void (GLAPIENTRYP fn)(GLubyte *)) { - SET_by_offset(disp, _gloffset_GetPolygonStipple, fn); -} - -typedef const GLubyte * (GLAPIENTRYP _glptr_GetString)(GLenum); -#define CALL_GetString(disp, parameters) \ - (* GET_GetString(disp)) parameters -static inline _glptr_GetString GET_GetString(struct _glapi_table *disp) { - return (_glptr_GetString) (GET_by_offset(disp, _gloffset_GetString)); -} - -static inline void SET_GetString(struct _glapi_table *disp, const GLubyte * (GLAPIENTRYP fn)(GLenum)) { - SET_by_offset(disp, _gloffset_GetString, fn); -} - -typedef void (GLAPIENTRYP _glptr_GetTexEnvfv)(GLenum, GLenum, GLfloat *); -#define CALL_GetTexEnvfv(disp, parameters) \ - (* GET_GetTexEnvfv(disp)) parameters -static inline _glptr_GetTexEnvfv GET_GetTexEnvfv(struct _glapi_table *disp) { - return (_glptr_GetTexEnvfv) (GET_by_offset(disp, _gloffset_GetTexEnvfv)); -} - -static inline void SET_GetTexEnvfv(struct _glapi_table *disp, void (GLAPIENTRYP fn)(GLenum, GLenum, GLfloat *)) { - SET_by_offset(disp, _gloffset_GetTexEnvfv, fn); -} - -typedef void (GLAPIENTRYP _glptr_GetTexEnviv)(GLenum, GLenum, GLint *); -#define CALL_GetTexEnviv(disp, parameters) \ - (* GET_GetTexEnviv(disp)) parameters -static inline _glptr_GetTexEnviv GET_GetTexEnviv(struct _glapi_table *disp) { - return (_glptr_GetTexEnviv) (GET_by_offset(disp, _gloffset_GetTexEnviv)); -} - -static inline void SET_GetTexEnviv(struct _glapi_table *disp, void (GLAPIENTRYP fn)(GLenum, GLenum, GLint *)) { - SET_by_offset(disp, _gloffset_GetTexEnviv, fn); -} - -typedef void (GLAPIENTRYP _glptr_GetTexGendv)(GLenum, GLenum, GLdouble *); -#define CALL_GetTexGendv(disp, parameters) \ - (* GET_GetTexGendv(disp)) parameters -static inline _glptr_GetTexGendv GET_GetTexGendv(struct _glapi_table *disp) { - return (_glptr_GetTexGendv) (GET_by_offset(disp, _gloffset_GetTexGendv)); -} - -static inline void SET_GetTexGendv(struct _glapi_table *disp, void (GLAPIENTRYP fn)(GLenum, GLenum, GLdouble *)) { - SET_by_offset(disp, _gloffset_GetTexGendv, fn); -} - -typedef void (GLAPIENTRYP _glptr_GetTexGenfv)(GLenum, GLenum, GLfloat *); -#define CALL_GetTexGenfv(disp, parameters) \ - (* GET_GetTexGenfv(disp)) parameters -static inline _glptr_GetTexGenfv GET_GetTexGenfv(struct _glapi_table *disp) { - return (_glptr_GetTexGenfv) (GET_by_offset(disp, _gloffset_GetTexGenfv)); -} - -static inline void SET_GetTexGenfv(struct _glapi_table *disp, void (GLAPIENTRYP fn)(GLenum, GLenum, GLfloat *)) { - SET_by_offset(disp, _gloffset_GetTexGenfv, fn); -} - -typedef void (GLAPIENTRYP _glptr_GetTexGeniv)(GLenum, GLenum, GLint *); -#define CALL_GetTexGeniv(disp, parameters) \ - (* GET_GetTexGeniv(disp)) parameters -static inline _glptr_GetTexGeniv GET_GetTexGeniv(struct _glapi_table *disp) { - return (_glptr_GetTexGeniv) (GET_by_offset(disp, _gloffset_GetTexGeniv)); -} - -static inline void SET_GetTexGeniv(struct _glapi_table *disp, void (GLAPIENTRYP fn)(GLenum, GLenum, GLint *)) { - SET_by_offset(disp, _gloffset_GetTexGeniv, fn); -} - -typedef void (GLAPIENTRYP _glptr_GetTexImage)(GLenum, GLint, GLenum, GLenum, GLvoid *); -#define CALL_GetTexImage(disp, parameters) \ - (* GET_GetTexImage(disp)) parameters -static inline _glptr_GetTexImage GET_GetTexImage(struct _glapi_table *disp) { - return (_glptr_GetTexImage) (GET_by_offset(disp, _gloffset_GetTexImage)); -} - -static inline void SET_GetTexImage(struct _glapi_table *disp, void (GLAPIENTRYP fn)(GLenum, GLint, GLenum, GLenum, GLvoid *)) { - SET_by_offset(disp, _gloffset_GetTexImage, fn); -} - -typedef void (GLAPIENTRYP _glptr_GetTexParameterfv)(GLenum, GLenum, GLfloat *); -#define CALL_GetTexParameterfv(disp, parameters) \ - (* GET_GetTexParameterfv(disp)) parameters -static inline _glptr_GetTexParameterfv GET_GetTexParameterfv(struct _glapi_table *disp) { - return (_glptr_GetTexParameterfv) (GET_by_offset(disp, _gloffset_GetTexParameterfv)); -} - -static inline void SET_GetTexParameterfv(struct _glapi_table *disp, void (GLAPIENTRYP fn)(GLenum, GLenum, GLfloat *)) { - SET_by_offset(disp, _gloffset_GetTexParameterfv, fn); -} - -typedef void (GLAPIENTRYP _glptr_GetTexParameteriv)(GLenum, GLenum, GLint *); -#define CALL_GetTexParameteriv(disp, parameters) \ - (* GET_GetTexParameteriv(disp)) parameters -static inline _glptr_GetTexParameteriv GET_GetTexParameteriv(struct _glapi_table *disp) { - return (_glptr_GetTexParameteriv) (GET_by_offset(disp, _gloffset_GetTexParameteriv)); -} - -static inline void SET_GetTexParameteriv(struct _glapi_table *disp, void (GLAPIENTRYP fn)(GLenum, GLenum, GLint *)) { - SET_by_offset(disp, _gloffset_GetTexParameteriv, fn); -} - -typedef void (GLAPIENTRYP _glptr_GetTexLevelParameterfv)(GLenum, GLint, GLenum, GLfloat *); -#define CALL_GetTexLevelParameterfv(disp, parameters) \ - (* GET_GetTexLevelParameterfv(disp)) parameters -static inline _glptr_GetTexLevelParameterfv GET_GetTexLevelParameterfv(struct _glapi_table *disp) { - return (_glptr_GetTexLevelParameterfv) (GET_by_offset(disp, _gloffset_GetTexLevelParameterfv)); -} - -static inline void SET_GetTexLevelParameterfv(struct _glapi_table *disp, void (GLAPIENTRYP fn)(GLenum, GLint, GLenum, GLfloat *)) { - SET_by_offset(disp, _gloffset_GetTexLevelParameterfv, fn); -} - -typedef void (GLAPIENTRYP _glptr_GetTexLevelParameteriv)(GLenum, GLint, GLenum, GLint *); -#define CALL_GetTexLevelParameteriv(disp, parameters) \ - (* GET_GetTexLevelParameteriv(disp)) parameters -static inline _glptr_GetTexLevelParameteriv GET_GetTexLevelParameteriv(struct _glapi_table *disp) { - return (_glptr_GetTexLevelParameteriv) (GET_by_offset(disp, _gloffset_GetTexLevelParameteriv)); -} - -static inline void SET_GetTexLevelParameteriv(struct _glapi_table *disp, void (GLAPIENTRYP fn)(GLenum, GLint, GLenum, GLint *)) { - SET_by_offset(disp, _gloffset_GetTexLevelParameteriv, fn); -} - -typedef GLboolean (GLAPIENTRYP _glptr_IsEnabled)(GLenum); -#define CALL_IsEnabled(disp, parameters) \ - (* GET_IsEnabled(disp)) parameters -static inline _glptr_IsEnabled GET_IsEnabled(struct _glapi_table *disp) { - return (_glptr_IsEnabled) (GET_by_offset(disp, _gloffset_IsEnabled)); -} - -static inline void SET_IsEnabled(struct _glapi_table *disp, GLboolean (GLAPIENTRYP fn)(GLenum)) { - SET_by_offset(disp, _gloffset_IsEnabled, fn); -} - -typedef GLboolean (GLAPIENTRYP _glptr_IsList)(GLuint); -#define CALL_IsList(disp, parameters) \ - (* GET_IsList(disp)) parameters -static inline _glptr_IsList GET_IsList(struct _glapi_table *disp) { - return (_glptr_IsList) (GET_by_offset(disp, _gloffset_IsList)); -} - -static inline void SET_IsList(struct _glapi_table *disp, GLboolean (GLAPIENTRYP fn)(GLuint)) { - SET_by_offset(disp, _gloffset_IsList, fn); -} - -typedef void (GLAPIENTRYP _glptr_DepthRange)(GLclampd, GLclampd); -#define CALL_DepthRange(disp, parameters) \ - (* GET_DepthRange(disp)) parameters -static inline _glptr_DepthRange GET_DepthRange(struct _glapi_table *disp) { - return (_glptr_DepthRange) (GET_by_offset(disp, _gloffset_DepthRange)); -} - -static inline void SET_DepthRange(struct _glapi_table *disp, void (GLAPIENTRYP fn)(GLclampd, GLclampd)) { - SET_by_offset(disp, _gloffset_DepthRange, fn); -} - -typedef void (GLAPIENTRYP _glptr_Frustum)(GLdouble, GLdouble, GLdouble, GLdouble, GLdouble, GLdouble); -#define CALL_Frustum(disp, parameters) \ - (* GET_Frustum(disp)) parameters -static inline _glptr_Frustum GET_Frustum(struct _glapi_table *disp) { - return (_glptr_Frustum) (GET_by_offset(disp, _gloffset_Frustum)); -} - -static inline void SET_Frustum(struct _glapi_table *disp, void (GLAPIENTRYP fn)(GLdouble, GLdouble, GLdouble, GLdouble, GLdouble, GLdouble)) { - SET_by_offset(disp, _gloffset_Frustum, fn); -} - -typedef void (GLAPIENTRYP _glptr_LoadIdentity)(void); -#define CALL_LoadIdentity(disp, parameters) \ - (* GET_LoadIdentity(disp)) parameters -static inline _glptr_LoadIdentity GET_LoadIdentity(struct _glapi_table *disp) { - return (_glptr_LoadIdentity) (GET_by_offset(disp, _gloffset_LoadIdentity)); -} - -static inline void SET_LoadIdentity(struct _glapi_table *disp, void (GLAPIENTRYP fn)(void)) { - SET_by_offset(disp, _gloffset_LoadIdentity, fn); -} - -typedef void (GLAPIENTRYP _glptr_LoadMatrixf)(const GLfloat *); -#define CALL_LoadMatrixf(disp, parameters) \ - (* GET_LoadMatrixf(disp)) parameters -static inline _glptr_LoadMatrixf GET_LoadMatrixf(struct _glapi_table *disp) { - return (_glptr_LoadMatrixf) (GET_by_offset(disp, _gloffset_LoadMatrixf)); -} - -static inline void SET_LoadMatrixf(struct _glapi_table *disp, void (GLAPIENTRYP fn)(const GLfloat *)) { - SET_by_offset(disp, _gloffset_LoadMatrixf, fn); -} - -typedef void (GLAPIENTRYP _glptr_LoadMatrixd)(const GLdouble *); -#define CALL_LoadMatrixd(disp, parameters) \ - (* GET_LoadMatrixd(disp)) parameters -static inline _glptr_LoadMatrixd GET_LoadMatrixd(struct _glapi_table *disp) { - return (_glptr_LoadMatrixd) (GET_by_offset(disp, _gloffset_LoadMatrixd)); -} - -static inline void SET_LoadMatrixd(struct _glapi_table *disp, void (GLAPIENTRYP fn)(const GLdouble *)) { - SET_by_offset(disp, _gloffset_LoadMatrixd, fn); -} - -typedef void (GLAPIENTRYP _glptr_MatrixMode)(GLenum); -#define CALL_MatrixMode(disp, parameters) \ - (* GET_MatrixMode(disp)) parameters -static inline _glptr_MatrixMode GET_MatrixMode(struct _glapi_table *disp) { - return (_glptr_MatrixMode) (GET_by_offset(disp, _gloffset_MatrixMode)); -} - -static inline void SET_MatrixMode(struct _glapi_table *disp, void (GLAPIENTRYP fn)(GLenum)) { - SET_by_offset(disp, _gloffset_MatrixMode, fn); -} - -typedef void (GLAPIENTRYP _glptr_MultMatrixf)(const GLfloat *); -#define CALL_MultMatrixf(disp, parameters) \ - (* GET_MultMatrixf(disp)) parameters -static inline _glptr_MultMatrixf GET_MultMatrixf(struct _glapi_table *disp) { - return (_glptr_MultMatrixf) (GET_by_offset(disp, _gloffset_MultMatrixf)); -} - -static inline void SET_MultMatrixf(struct _glapi_table *disp, void (GLAPIENTRYP fn)(const GLfloat *)) { - SET_by_offset(disp, _gloffset_MultMatrixf, fn); -} - -typedef void (GLAPIENTRYP _glptr_MultMatrixd)(const GLdouble *); -#define CALL_MultMatrixd(disp, parameters) \ - (* GET_MultMatrixd(disp)) parameters -static inline _glptr_MultMatrixd GET_MultMatrixd(struct _glapi_table *disp) { - return (_glptr_MultMatrixd) (GET_by_offset(disp, _gloffset_MultMatrixd)); -} - -static inline void SET_MultMatrixd(struct _glapi_table *disp, void (GLAPIENTRYP fn)(const GLdouble *)) { - SET_by_offset(disp, _gloffset_MultMatrixd, fn); -} - -typedef void (GLAPIENTRYP _glptr_Ortho)(GLdouble, GLdouble, GLdouble, GLdouble, GLdouble, GLdouble); -#define CALL_Ortho(disp, parameters) \ - (* GET_Ortho(disp)) parameters -static inline _glptr_Ortho GET_Ortho(struct _glapi_table *disp) { - return (_glptr_Ortho) (GET_by_offset(disp, _gloffset_Ortho)); -} - -static inline void SET_Ortho(struct _glapi_table *disp, void (GLAPIENTRYP fn)(GLdouble, GLdouble, GLdouble, GLdouble, GLdouble, GLdouble)) { - SET_by_offset(disp, _gloffset_Ortho, fn); -} - -typedef void (GLAPIENTRYP _glptr_PopMatrix)(void); -#define CALL_PopMatrix(disp, parameters) \ - (* GET_PopMatrix(disp)) parameters -static inline _glptr_PopMatrix GET_PopMatrix(struct _glapi_table *disp) { - return (_glptr_PopMatrix) (GET_by_offset(disp, _gloffset_PopMatrix)); -} - -static inline void SET_PopMatrix(struct _glapi_table *disp, void (GLAPIENTRYP fn)(void)) { - SET_by_offset(disp, _gloffset_PopMatrix, fn); -} - -typedef void (GLAPIENTRYP _glptr_PushMatrix)(void); -#define CALL_PushMatrix(disp, parameters) \ - (* GET_PushMatrix(disp)) parameters -static inline _glptr_PushMatrix GET_PushMatrix(struct _glapi_table *disp) { - return (_glptr_PushMatrix) (GET_by_offset(disp, _gloffset_PushMatrix)); -} - -static inline void SET_PushMatrix(struct _glapi_table *disp, void (GLAPIENTRYP fn)(void)) { - SET_by_offset(disp, _gloffset_PushMatrix, fn); -} - -typedef void (GLAPIENTRYP _glptr_Rotated)(GLdouble, GLdouble, GLdouble, GLdouble); -#define CALL_Rotated(disp, parameters) \ - (* GET_Rotated(disp)) parameters -static inline _glptr_Rotated GET_Rotated(struct _glapi_table *disp) { - return (_glptr_Rotated) (GET_by_offset(disp, _gloffset_Rotated)); -} - -static inline void SET_Rotated(struct _glapi_table *disp, void (GLAPIENTRYP fn)(GLdouble, GLdouble, GLdouble, GLdouble)) { - SET_by_offset(disp, _gloffset_Rotated, fn); -} - -typedef void (GLAPIENTRYP _glptr_Rotatef)(GLfloat, GLfloat, GLfloat, GLfloat); -#define CALL_Rotatef(disp, parameters) \ - (* GET_Rotatef(disp)) parameters -static inline _glptr_Rotatef GET_Rotatef(struct _glapi_table *disp) { - return (_glptr_Rotatef) (GET_by_offset(disp, _gloffset_Rotatef)); -} - -static inline void SET_Rotatef(struct _glapi_table *disp, void (GLAPIENTRYP fn)(GLfloat, GLfloat, GLfloat, GLfloat)) { - SET_by_offset(disp, _gloffset_Rotatef, fn); -} - -typedef void (GLAPIENTRYP _glptr_Scaled)(GLdouble, GLdouble, GLdouble); -#define CALL_Scaled(disp, parameters) \ - (* GET_Scaled(disp)) parameters -static inline _glptr_Scaled GET_Scaled(struct _glapi_table *disp) { - return (_glptr_Scaled) (GET_by_offset(disp, _gloffset_Scaled)); -} - -static inline void SET_Scaled(struct _glapi_table *disp, void (GLAPIENTRYP fn)(GLdouble, GLdouble, GLdouble)) { - SET_by_offset(disp, _gloffset_Scaled, fn); -} - -typedef void (GLAPIENTRYP _glptr_Scalef)(GLfloat, GLfloat, GLfloat); -#define CALL_Scalef(disp, parameters) \ - (* GET_Scalef(disp)) parameters -static inline _glptr_Scalef GET_Scalef(struct _glapi_table *disp) { - return (_glptr_Scalef) (GET_by_offset(disp, _gloffset_Scalef)); -} - -static inline void SET_Scalef(struct _glapi_table *disp, void (GLAPIENTRYP fn)(GLfloat, GLfloat, GLfloat)) { - SET_by_offset(disp, _gloffset_Scalef, fn); -} - -typedef void (GLAPIENTRYP _glptr_Translated)(GLdouble, GLdouble, GLdouble); -#define CALL_Translated(disp, parameters) \ - (* GET_Translated(disp)) parameters -static inline _glptr_Translated GET_Translated(struct _glapi_table *disp) { - return (_glptr_Translated) (GET_by_offset(disp, _gloffset_Translated)); -} - -static inline void SET_Translated(struct _glapi_table *disp, void (GLAPIENTRYP fn)(GLdouble, GLdouble, GLdouble)) { - SET_by_offset(disp, _gloffset_Translated, fn); -} - -typedef void (GLAPIENTRYP _glptr_Translatef)(GLfloat, GLfloat, GLfloat); -#define CALL_Translatef(disp, parameters) \ - (* GET_Translatef(disp)) parameters -static inline _glptr_Translatef GET_Translatef(struct _glapi_table *disp) { - return (_glptr_Translatef) (GET_by_offset(disp, _gloffset_Translatef)); -} - -static inline void SET_Translatef(struct _glapi_table *disp, void (GLAPIENTRYP fn)(GLfloat, GLfloat, GLfloat)) { - SET_by_offset(disp, _gloffset_Translatef, fn); -} - -typedef void (GLAPIENTRYP _glptr_Viewport)(GLint, GLint, GLsizei, GLsizei); -#define CALL_Viewport(disp, parameters) \ - (* GET_Viewport(disp)) parameters -static inline _glptr_Viewport GET_Viewport(struct _glapi_table *disp) { - return (_glptr_Viewport) (GET_by_offset(disp, _gloffset_Viewport)); -} - -static inline void SET_Viewport(struct _glapi_table *disp, void (GLAPIENTRYP fn)(GLint, GLint, GLsizei, GLsizei)) { - SET_by_offset(disp, _gloffset_Viewport, fn); -} - -typedef void (GLAPIENTRYP _glptr_ArrayElement)(GLint); -#define CALL_ArrayElement(disp, parameters) \ - (* GET_ArrayElement(disp)) parameters -static inline _glptr_ArrayElement GET_ArrayElement(struct _glapi_table *disp) { - return (_glptr_ArrayElement) (GET_by_offset(disp, _gloffset_ArrayElement)); -} - -static inline void SET_ArrayElement(struct _glapi_table *disp, void (GLAPIENTRYP fn)(GLint)) { - SET_by_offset(disp, _gloffset_ArrayElement, fn); -} - -typedef void (GLAPIENTRYP _glptr_BindTexture)(GLenum, GLuint); -#define CALL_BindTexture(disp, parameters) \ - (* GET_BindTexture(disp)) parameters -static inline _glptr_BindTexture GET_BindTexture(struct _glapi_table *disp) { - return (_glptr_BindTexture) (GET_by_offset(disp, _gloffset_BindTexture)); -} - -static inline void SET_BindTexture(struct _glapi_table *disp, void (GLAPIENTRYP fn)(GLenum, GLuint)) { - SET_by_offset(disp, _gloffset_BindTexture, fn); -} - -typedef void (GLAPIENTRYP _glptr_ColorPointer)(GLint, GLenum, GLsizei, const GLvoid *); -#define CALL_ColorPointer(disp, parameters) \ - (* GET_ColorPointer(disp)) parameters -static inline _glptr_ColorPointer GET_ColorPointer(struct _glapi_table *disp) { - return (_glptr_ColorPointer) (GET_by_offset(disp, _gloffset_ColorPointer)); -} - -static inline void SET_ColorPointer(struct _glapi_table *disp, void (GLAPIENTRYP fn)(GLint, GLenum, GLsizei, const GLvoid *)) { - SET_by_offset(disp, _gloffset_ColorPointer, fn); -} - -typedef void (GLAPIENTRYP _glptr_DisableClientState)(GLenum); -#define CALL_DisableClientState(disp, parameters) \ - (* GET_DisableClientState(disp)) parameters -static inline _glptr_DisableClientState GET_DisableClientState(struct _glapi_table *disp) { - return (_glptr_DisableClientState) (GET_by_offset(disp, _gloffset_DisableClientState)); -} - -static inline void SET_DisableClientState(struct _glapi_table *disp, void (GLAPIENTRYP fn)(GLenum)) { - SET_by_offset(disp, _gloffset_DisableClientState, fn); -} - -typedef void (GLAPIENTRYP _glptr_DrawArrays)(GLenum, GLint, GLsizei); -#define CALL_DrawArrays(disp, parameters) \ - (* GET_DrawArrays(disp)) parameters -static inline _glptr_DrawArrays GET_DrawArrays(struct _glapi_table *disp) { - return (_glptr_DrawArrays) (GET_by_offset(disp, _gloffset_DrawArrays)); -} - -static inline void SET_DrawArrays(struct _glapi_table *disp, void (GLAPIENTRYP fn)(GLenum, GLint, GLsizei)) { - SET_by_offset(disp, _gloffset_DrawArrays, fn); -} - -typedef void (GLAPIENTRYP _glptr_DrawElements)(GLenum, GLsizei, GLenum, const GLvoid *); -#define CALL_DrawElements(disp, parameters) \ - (* GET_DrawElements(disp)) parameters -static inline _glptr_DrawElements GET_DrawElements(struct _glapi_table *disp) { - return (_glptr_DrawElements) (GET_by_offset(disp, _gloffset_DrawElements)); -} - -static inline void SET_DrawElements(struct _glapi_table *disp, void (GLAPIENTRYP fn)(GLenum, GLsizei, GLenum, const GLvoid *)) { - SET_by_offset(disp, _gloffset_DrawElements, fn); -} - -typedef void (GLAPIENTRYP _glptr_EdgeFlagPointer)(GLsizei, const GLvoid *); -#define CALL_EdgeFlagPointer(disp, parameters) \ - (* GET_EdgeFlagPointer(disp)) parameters -static inline _glptr_EdgeFlagPointer GET_EdgeFlagPointer(struct _glapi_table *disp) { - return (_glptr_EdgeFlagPointer) (GET_by_offset(disp, _gloffset_EdgeFlagPointer)); -} - -static inline void SET_EdgeFlagPointer(struct _glapi_table *disp, void (GLAPIENTRYP fn)(GLsizei, const GLvoid *)) { - SET_by_offset(disp, _gloffset_EdgeFlagPointer, fn); -} - -typedef void (GLAPIENTRYP _glptr_EnableClientState)(GLenum); -#define CALL_EnableClientState(disp, parameters) \ - (* GET_EnableClientState(disp)) parameters -static inline _glptr_EnableClientState GET_EnableClientState(struct _glapi_table *disp) { - return (_glptr_EnableClientState) (GET_by_offset(disp, _gloffset_EnableClientState)); -} - -static inline void SET_EnableClientState(struct _glapi_table *disp, void (GLAPIENTRYP fn)(GLenum)) { - SET_by_offset(disp, _gloffset_EnableClientState, fn); -} - -typedef void (GLAPIENTRYP _glptr_IndexPointer)(GLenum, GLsizei, const GLvoid *); -#define CALL_IndexPointer(disp, parameters) \ - (* GET_IndexPointer(disp)) parameters -static inline _glptr_IndexPointer GET_IndexPointer(struct _glapi_table *disp) { - return (_glptr_IndexPointer) (GET_by_offset(disp, _gloffset_IndexPointer)); -} - -static inline void SET_IndexPointer(struct _glapi_table *disp, void (GLAPIENTRYP fn)(GLenum, GLsizei, const GLvoid *)) { - SET_by_offset(disp, _gloffset_IndexPointer, fn); -} - -typedef void (GLAPIENTRYP _glptr_Indexub)(GLubyte); -#define CALL_Indexub(disp, parameters) \ - (* GET_Indexub(disp)) parameters -static inline _glptr_Indexub GET_Indexub(struct _glapi_table *disp) { - return (_glptr_Indexub) (GET_by_offset(disp, _gloffset_Indexub)); -} - -static inline void SET_Indexub(struct _glapi_table *disp, void (GLAPIENTRYP fn)(GLubyte)) { - SET_by_offset(disp, _gloffset_Indexub, fn); -} - -typedef void (GLAPIENTRYP _glptr_Indexubv)(const GLubyte *); -#define CALL_Indexubv(disp, parameters) \ - (* GET_Indexubv(disp)) parameters -static inline _glptr_Indexubv GET_Indexubv(struct _glapi_table *disp) { - return (_glptr_Indexubv) (GET_by_offset(disp, _gloffset_Indexubv)); -} - -static inline void SET_Indexubv(struct _glapi_table *disp, void (GLAPIENTRYP fn)(const GLubyte *)) { - SET_by_offset(disp, _gloffset_Indexubv, fn); -} - -typedef void (GLAPIENTRYP _glptr_InterleavedArrays)(GLenum, GLsizei, const GLvoid *); -#define CALL_InterleavedArrays(disp, parameters) \ - (* GET_InterleavedArrays(disp)) parameters -static inline _glptr_InterleavedArrays GET_InterleavedArrays(struct _glapi_table *disp) { - return (_glptr_InterleavedArrays) (GET_by_offset(disp, _gloffset_InterleavedArrays)); -} - -static inline void SET_InterleavedArrays(struct _glapi_table *disp, void (GLAPIENTRYP fn)(GLenum, GLsizei, const GLvoid *)) { - SET_by_offset(disp, _gloffset_InterleavedArrays, fn); -} - -typedef void (GLAPIENTRYP _glptr_NormalPointer)(GLenum, GLsizei, const GLvoid *); -#define CALL_NormalPointer(disp, parameters) \ - (* GET_NormalPointer(disp)) parameters -static inline _glptr_NormalPointer GET_NormalPointer(struct _glapi_table *disp) { - return (_glptr_NormalPointer) (GET_by_offset(disp, _gloffset_NormalPointer)); -} - -static inline void SET_NormalPointer(struct _glapi_table *disp, void (GLAPIENTRYP fn)(GLenum, GLsizei, const GLvoid *)) { - SET_by_offset(disp, _gloffset_NormalPointer, fn); -} - -typedef void (GLAPIENTRYP _glptr_PolygonOffset)(GLfloat, GLfloat); -#define CALL_PolygonOffset(disp, parameters) \ - (* GET_PolygonOffset(disp)) parameters -static inline _glptr_PolygonOffset GET_PolygonOffset(struct _glapi_table *disp) { - return (_glptr_PolygonOffset) (GET_by_offset(disp, _gloffset_PolygonOffset)); -} - -static inline void SET_PolygonOffset(struct _glapi_table *disp, void (GLAPIENTRYP fn)(GLfloat, GLfloat)) { - SET_by_offset(disp, _gloffset_PolygonOffset, fn); -} - -typedef void (GLAPIENTRYP _glptr_TexCoordPointer)(GLint, GLenum, GLsizei, const GLvoid *); -#define CALL_TexCoordPointer(disp, parameters) \ - (* GET_TexCoordPointer(disp)) parameters -static inline _glptr_TexCoordPointer GET_TexCoordPointer(struct _glapi_table *disp) { - return (_glptr_TexCoordPointer) (GET_by_offset(disp, _gloffset_TexCoordPointer)); -} - -static inline void SET_TexCoordPointer(struct _glapi_table *disp, void (GLAPIENTRYP fn)(GLint, GLenum, GLsizei, const GLvoid *)) { - SET_by_offset(disp, _gloffset_TexCoordPointer, fn); -} - -typedef void (GLAPIENTRYP _glptr_VertexPointer)(GLint, GLenum, GLsizei, const GLvoid *); -#define CALL_VertexPointer(disp, parameters) \ - (* GET_VertexPointer(disp)) parameters -static inline _glptr_VertexPointer GET_VertexPointer(struct _glapi_table *disp) { - return (_glptr_VertexPointer) (GET_by_offset(disp, _gloffset_VertexPointer)); -} - -static inline void SET_VertexPointer(struct _glapi_table *disp, void (GLAPIENTRYP fn)(GLint, GLenum, GLsizei, const GLvoid *)) { - SET_by_offset(disp, _gloffset_VertexPointer, fn); -} - -typedef GLboolean (GLAPIENTRYP _glptr_AreTexturesResident)(GLsizei, const GLuint *, GLboolean *); -#define CALL_AreTexturesResident(disp, parameters) \ - (* GET_AreTexturesResident(disp)) parameters -static inline _glptr_AreTexturesResident GET_AreTexturesResident(struct _glapi_table *disp) { - return (_glptr_AreTexturesResident) (GET_by_offset(disp, _gloffset_AreTexturesResident)); -} - -static inline void SET_AreTexturesResident(struct _glapi_table *disp, GLboolean (GLAPIENTRYP fn)(GLsizei, const GLuint *, GLboolean *)) { - SET_by_offset(disp, _gloffset_AreTexturesResident, fn); -} - -typedef void (GLAPIENTRYP _glptr_CopyTexImage1D)(GLenum, GLint, GLenum, GLint, GLint, GLsizei, GLint); -#define CALL_CopyTexImage1D(disp, parameters) \ - (* GET_CopyTexImage1D(disp)) parameters -static inline _glptr_CopyTexImage1D GET_CopyTexImage1D(struct _glapi_table *disp) { - return (_glptr_CopyTexImage1D) (GET_by_offset(disp, _gloffset_CopyTexImage1D)); -} - -static inline void SET_CopyTexImage1D(struct _glapi_table *disp, void (GLAPIENTRYP fn)(GLenum, GLint, GLenum, GLint, GLint, GLsizei, GLint)) { - SET_by_offset(disp, _gloffset_CopyTexImage1D, fn); -} - -typedef void (GLAPIENTRYP _glptr_CopyTexImage2D)(GLenum, GLint, GLenum, GLint, GLint, GLsizei, GLsizei, GLint); -#define CALL_CopyTexImage2D(disp, parameters) \ - (* GET_CopyTexImage2D(disp)) parameters -static inline _glptr_CopyTexImage2D GET_CopyTexImage2D(struct _glapi_table *disp) { - return (_glptr_CopyTexImage2D) (GET_by_offset(disp, _gloffset_CopyTexImage2D)); -} - -static inline void SET_CopyTexImage2D(struct _glapi_table *disp, void (GLAPIENTRYP fn)(GLenum, GLint, GLenum, GLint, GLint, GLsizei, GLsizei, GLint)) { - SET_by_offset(disp, _gloffset_CopyTexImage2D, fn); -} - -typedef void (GLAPIENTRYP _glptr_CopyTexSubImage1D)(GLenum, GLint, GLint, GLint, GLint, GLsizei); -#define CALL_CopyTexSubImage1D(disp, parameters) \ - (* GET_CopyTexSubImage1D(disp)) parameters -static inline _glptr_CopyTexSubImage1D GET_CopyTexSubImage1D(struct _glapi_table *disp) { - return (_glptr_CopyTexSubImage1D) (GET_by_offset(disp, _gloffset_CopyTexSubImage1D)); -} - -static inline void SET_CopyTexSubImage1D(struct _glapi_table *disp, void (GLAPIENTRYP fn)(GLenum, GLint, GLint, GLint, GLint, GLsizei)) { - SET_by_offset(disp, _gloffset_CopyTexSubImage1D, fn); -} - -typedef void (GLAPIENTRYP _glptr_CopyTexSubImage2D)(GLenum, GLint, GLint, GLint, GLint, GLint, GLsizei, GLsizei); -#define CALL_CopyTexSubImage2D(disp, parameters) \ - (* GET_CopyTexSubImage2D(disp)) parameters -static inline _glptr_CopyTexSubImage2D GET_CopyTexSubImage2D(struct _glapi_table *disp) { - return (_glptr_CopyTexSubImage2D) (GET_by_offset(disp, _gloffset_CopyTexSubImage2D)); -} - -static inline void SET_CopyTexSubImage2D(struct _glapi_table *disp, void (GLAPIENTRYP fn)(GLenum, GLint, GLint, GLint, GLint, GLint, GLsizei, GLsizei)) { - SET_by_offset(disp, _gloffset_CopyTexSubImage2D, fn); -} - -typedef void (GLAPIENTRYP _glptr_DeleteTextures)(GLsizei, const GLuint *); -#define CALL_DeleteTextures(disp, parameters) \ - (* GET_DeleteTextures(disp)) parameters -static inline _glptr_DeleteTextures GET_DeleteTextures(struct _glapi_table *disp) { - return (_glptr_DeleteTextures) (GET_by_offset(disp, _gloffset_DeleteTextures)); -} - -static inline void SET_DeleteTextures(struct _glapi_table *disp, void (GLAPIENTRYP fn)(GLsizei, const GLuint *)) { - SET_by_offset(disp, _gloffset_DeleteTextures, fn); -} - -typedef void (GLAPIENTRYP _glptr_GenTextures)(GLsizei, GLuint *); -#define CALL_GenTextures(disp, parameters) \ - (* GET_GenTextures(disp)) parameters -static inline _glptr_GenTextures GET_GenTextures(struct _glapi_table *disp) { - return (_glptr_GenTextures) (GET_by_offset(disp, _gloffset_GenTextures)); -} - -static inline void SET_GenTextures(struct _glapi_table *disp, void (GLAPIENTRYP fn)(GLsizei, GLuint *)) { - SET_by_offset(disp, _gloffset_GenTextures, fn); -} - -typedef void (GLAPIENTRYP _glptr_GetPointerv)(GLenum, GLvoid **); -#define CALL_GetPointerv(disp, parameters) \ - (* GET_GetPointerv(disp)) parameters -static inline _glptr_GetPointerv GET_GetPointerv(struct _glapi_table *disp) { - return (_glptr_GetPointerv) (GET_by_offset(disp, _gloffset_GetPointerv)); -} - -static inline void SET_GetPointerv(struct _glapi_table *disp, void (GLAPIENTRYP fn)(GLenum, GLvoid **)) { - SET_by_offset(disp, _gloffset_GetPointerv, fn); -} - -typedef GLboolean (GLAPIENTRYP _glptr_IsTexture)(GLuint); -#define CALL_IsTexture(disp, parameters) \ - (* GET_IsTexture(disp)) parameters -static inline _glptr_IsTexture GET_IsTexture(struct _glapi_table *disp) { - return (_glptr_IsTexture) (GET_by_offset(disp, _gloffset_IsTexture)); -} - -static inline void SET_IsTexture(struct _glapi_table *disp, GLboolean (GLAPIENTRYP fn)(GLuint)) { - SET_by_offset(disp, _gloffset_IsTexture, fn); -} - -typedef void (GLAPIENTRYP _glptr_PrioritizeTextures)(GLsizei, const GLuint *, const GLclampf *); -#define CALL_PrioritizeTextures(disp, parameters) \ - (* GET_PrioritizeTextures(disp)) parameters -static inline _glptr_PrioritizeTextures GET_PrioritizeTextures(struct _glapi_table *disp) { - return (_glptr_PrioritizeTextures) (GET_by_offset(disp, _gloffset_PrioritizeTextures)); -} - -static inline void SET_PrioritizeTextures(struct _glapi_table *disp, void (GLAPIENTRYP fn)(GLsizei, const GLuint *, const GLclampf *)) { - SET_by_offset(disp, _gloffset_PrioritizeTextures, fn); -} - -typedef void (GLAPIENTRYP _glptr_TexSubImage1D)(GLenum, GLint, GLint, GLsizei, GLenum, GLenum, const GLvoid *); -#define CALL_TexSubImage1D(disp, parameters) \ - (* GET_TexSubImage1D(disp)) parameters -static inline _glptr_TexSubImage1D GET_TexSubImage1D(struct _glapi_table *disp) { - return (_glptr_TexSubImage1D) (GET_by_offset(disp, _gloffset_TexSubImage1D)); -} - -static inline void SET_TexSubImage1D(struct _glapi_table *disp, void (GLAPIENTRYP fn)(GLenum, GLint, GLint, GLsizei, GLenum, GLenum, const GLvoid *)) { - SET_by_offset(disp, _gloffset_TexSubImage1D, fn); -} - -typedef void (GLAPIENTRYP _glptr_TexSubImage2D)(GLenum, GLint, GLint, GLint, GLsizei, GLsizei, GLenum, GLenum, const GLvoid *); -#define CALL_TexSubImage2D(disp, parameters) \ - (* GET_TexSubImage2D(disp)) parameters -static inline _glptr_TexSubImage2D GET_TexSubImage2D(struct _glapi_table *disp) { - return (_glptr_TexSubImage2D) (GET_by_offset(disp, _gloffset_TexSubImage2D)); -} - -static inline void SET_TexSubImage2D(struct _glapi_table *disp, void (GLAPIENTRYP fn)(GLenum, GLint, GLint, GLint, GLsizei, GLsizei, GLenum, GLenum, const GLvoid *)) { - SET_by_offset(disp, _gloffset_TexSubImage2D, fn); -} - -typedef void (GLAPIENTRYP _glptr_PopClientAttrib)(void); -#define CALL_PopClientAttrib(disp, parameters) \ - (* GET_PopClientAttrib(disp)) parameters -static inline _glptr_PopClientAttrib GET_PopClientAttrib(struct _glapi_table *disp) { - return (_glptr_PopClientAttrib) (GET_by_offset(disp, _gloffset_PopClientAttrib)); -} - -static inline void SET_PopClientAttrib(struct _glapi_table *disp, void (GLAPIENTRYP fn)(void)) { - SET_by_offset(disp, _gloffset_PopClientAttrib, fn); -} - -typedef void (GLAPIENTRYP _glptr_PushClientAttrib)(GLbitfield); -#define CALL_PushClientAttrib(disp, parameters) \ - (* GET_PushClientAttrib(disp)) parameters -static inline _glptr_PushClientAttrib GET_PushClientAttrib(struct _glapi_table *disp) { - return (_glptr_PushClientAttrib) (GET_by_offset(disp, _gloffset_PushClientAttrib)); -} - -static inline void SET_PushClientAttrib(struct _glapi_table *disp, void (GLAPIENTRYP fn)(GLbitfield)) { - SET_by_offset(disp, _gloffset_PushClientAttrib, fn); -} - -typedef void (GLAPIENTRYP _glptr_GetBufferParameteri64v)(GLenum, GLenum, GLint64 *); -#define CALL_GetBufferParameteri64v(disp, parameters) \ - (* GET_GetBufferParameteri64v(disp)) parameters -static inline _glptr_GetBufferParameteri64v GET_GetBufferParameteri64v(struct _glapi_table *disp) { - return (_glptr_GetBufferParameteri64v) (GET_by_offset(disp, _gloffset_GetBufferParameteri64v)); -} - -static inline void SET_GetBufferParameteri64v(struct _glapi_table *disp, void (GLAPIENTRYP fn)(GLenum, GLenum, GLint64 *)) { - SET_by_offset(disp, _gloffset_GetBufferParameteri64v, fn); -} - -typedef void (GLAPIENTRYP _glptr_GetInteger64i_v)(GLenum, GLuint, GLint64 *); -#define CALL_GetInteger64i_v(disp, parameters) \ - (* GET_GetInteger64i_v(disp)) parameters -static inline _glptr_GetInteger64i_v GET_GetInteger64i_v(struct _glapi_table *disp) { - return (_glptr_GetInteger64i_v) (GET_by_offset(disp, _gloffset_GetInteger64i_v)); -} - -static inline void SET_GetInteger64i_v(struct _glapi_table *disp, void (GLAPIENTRYP fn)(GLenum, GLuint, GLint64 *)) { - SET_by_offset(disp, _gloffset_GetInteger64i_v, fn); -} - -typedef void (GLAPIENTRYP _glptr_LoadTransposeMatrixdARB)(const GLdouble *); -#define CALL_LoadTransposeMatrixdARB(disp, parameters) \ - (* GET_LoadTransposeMatrixdARB(disp)) parameters -static inline _glptr_LoadTransposeMatrixdARB GET_LoadTransposeMatrixdARB(struct _glapi_table *disp) { - return (_glptr_LoadTransposeMatrixdARB) (GET_by_offset(disp, _gloffset_LoadTransposeMatrixdARB)); -} - -static inline void SET_LoadTransposeMatrixdARB(struct _glapi_table *disp, void (GLAPIENTRYP fn)(const GLdouble *)) { - SET_by_offset(disp, _gloffset_LoadTransposeMatrixdARB, fn); -} - -typedef void (GLAPIENTRYP _glptr_LoadTransposeMatrixfARB)(const GLfloat *); -#define CALL_LoadTransposeMatrixfARB(disp, parameters) \ - (* GET_LoadTransposeMatrixfARB(disp)) parameters -static inline _glptr_LoadTransposeMatrixfARB GET_LoadTransposeMatrixfARB(struct _glapi_table *disp) { - return (_glptr_LoadTransposeMatrixfARB) (GET_by_offset(disp, _gloffset_LoadTransposeMatrixfARB)); -} - -static inline void SET_LoadTransposeMatrixfARB(struct _glapi_table *disp, void (GLAPIENTRYP fn)(const GLfloat *)) { - SET_by_offset(disp, _gloffset_LoadTransposeMatrixfARB, fn); -} - -typedef void (GLAPIENTRYP _glptr_MultTransposeMatrixdARB)(const GLdouble *); -#define CALL_MultTransposeMatrixdARB(disp, parameters) \ - (* GET_MultTransposeMatrixdARB(disp)) parameters -static inline _glptr_MultTransposeMatrixdARB GET_MultTransposeMatrixdARB(struct _glapi_table *disp) { - return (_glptr_MultTransposeMatrixdARB) (GET_by_offset(disp, _gloffset_MultTransposeMatrixdARB)); -} - -static inline void SET_MultTransposeMatrixdARB(struct _glapi_table *disp, void (GLAPIENTRYP fn)(const GLdouble *)) { - SET_by_offset(disp, _gloffset_MultTransposeMatrixdARB, fn); -} - -typedef void (GLAPIENTRYP _glptr_MultTransposeMatrixfARB)(const GLfloat *); -#define CALL_MultTransposeMatrixfARB(disp, parameters) \ - (* GET_MultTransposeMatrixfARB(disp)) parameters -static inline _glptr_MultTransposeMatrixfARB GET_MultTransposeMatrixfARB(struct _glapi_table *disp) { - return (_glptr_MultTransposeMatrixfARB) (GET_by_offset(disp, _gloffset_MultTransposeMatrixfARB)); -} - -static inline void SET_MultTransposeMatrixfARB(struct _glapi_table *disp, void (GLAPIENTRYP fn)(const GLfloat *)) { - SET_by_offset(disp, _gloffset_MultTransposeMatrixfARB, fn); -} - -typedef void (GLAPIENTRYP _glptr_SampleCoverageARB)(GLclampf, GLboolean); -#define CALL_SampleCoverageARB(disp, parameters) \ - (* GET_SampleCoverageARB(disp)) parameters -static inline _glptr_SampleCoverageARB GET_SampleCoverageARB(struct _glapi_table *disp) { - return (_glptr_SampleCoverageARB) (GET_by_offset(disp, _gloffset_SampleCoverageARB)); -} - -static inline void SET_SampleCoverageARB(struct _glapi_table *disp, void (GLAPIENTRYP fn)(GLclampf, GLboolean)) { - SET_by_offset(disp, _gloffset_SampleCoverageARB, fn); -} - -typedef void (GLAPIENTRYP _glptr_BindBufferARB)(GLenum, GLuint); -#define CALL_BindBufferARB(disp, parameters) \ - (* GET_BindBufferARB(disp)) parameters -static inline _glptr_BindBufferARB GET_BindBufferARB(struct _glapi_table *disp) { - return (_glptr_BindBufferARB) (GET_by_offset(disp, _gloffset_BindBufferARB)); -} - -static inline void SET_BindBufferARB(struct _glapi_table *disp, void (GLAPIENTRYP fn)(GLenum, GLuint)) { - SET_by_offset(disp, _gloffset_BindBufferARB, fn); -} - -typedef void (GLAPIENTRYP _glptr_BufferDataARB)(GLenum, GLsizeiptrARB, const GLvoid *, GLenum); -#define CALL_BufferDataARB(disp, parameters) \ - (* GET_BufferDataARB(disp)) parameters -static inline _glptr_BufferDataARB GET_BufferDataARB(struct _glapi_table *disp) { - return (_glptr_BufferDataARB) (GET_by_offset(disp, _gloffset_BufferDataARB)); -} - -static inline void SET_BufferDataARB(struct _glapi_table *disp, void (GLAPIENTRYP fn)(GLenum, GLsizeiptrARB, const GLvoid *, GLenum)) { - SET_by_offset(disp, _gloffset_BufferDataARB, fn); -} - -typedef void (GLAPIENTRYP _glptr_BufferSubDataARB)(GLenum, GLintptrARB, GLsizeiptrARB, const GLvoid *); -#define CALL_BufferSubDataARB(disp, parameters) \ - (* GET_BufferSubDataARB(disp)) parameters -static inline _glptr_BufferSubDataARB GET_BufferSubDataARB(struct _glapi_table *disp) { - return (_glptr_BufferSubDataARB) (GET_by_offset(disp, _gloffset_BufferSubDataARB)); -} - -static inline void SET_BufferSubDataARB(struct _glapi_table *disp, void (GLAPIENTRYP fn)(GLenum, GLintptrARB, GLsizeiptrARB, const GLvoid *)) { - SET_by_offset(disp, _gloffset_BufferSubDataARB, fn); -} - -typedef void (GLAPIENTRYP _glptr_DeleteBuffersARB)(GLsizei, const GLuint *); -#define CALL_DeleteBuffersARB(disp, parameters) \ - (* GET_DeleteBuffersARB(disp)) parameters -static inline _glptr_DeleteBuffersARB GET_DeleteBuffersARB(struct _glapi_table *disp) { - return (_glptr_DeleteBuffersARB) (GET_by_offset(disp, _gloffset_DeleteBuffersARB)); -} - -static inline void SET_DeleteBuffersARB(struct _glapi_table *disp, void (GLAPIENTRYP fn)(GLsizei, const GLuint *)) { - SET_by_offset(disp, _gloffset_DeleteBuffersARB, fn); -} - -typedef void (GLAPIENTRYP _glptr_GenBuffersARB)(GLsizei, GLuint *); -#define CALL_GenBuffersARB(disp, parameters) \ - (* GET_GenBuffersARB(disp)) parameters -static inline _glptr_GenBuffersARB GET_GenBuffersARB(struct _glapi_table *disp) { - return (_glptr_GenBuffersARB) (GET_by_offset(disp, _gloffset_GenBuffersARB)); -} - -static inline void SET_GenBuffersARB(struct _glapi_table *disp, void (GLAPIENTRYP fn)(GLsizei, GLuint *)) { - SET_by_offset(disp, _gloffset_GenBuffersARB, fn); -} - -typedef void (GLAPIENTRYP _glptr_GetBufferParameterivARB)(GLenum, GLenum, GLint *); -#define CALL_GetBufferParameterivARB(disp, parameters) \ - (* GET_GetBufferParameterivARB(disp)) parameters -static inline _glptr_GetBufferParameterivARB GET_GetBufferParameterivARB(struct _glapi_table *disp) { - return (_glptr_GetBufferParameterivARB) (GET_by_offset(disp, _gloffset_GetBufferParameterivARB)); -} - -static inline void SET_GetBufferParameterivARB(struct _glapi_table *disp, void (GLAPIENTRYP fn)(GLenum, GLenum, GLint *)) { - SET_by_offset(disp, _gloffset_GetBufferParameterivARB, fn); -} - -typedef void (GLAPIENTRYP _glptr_GetBufferPointervARB)(GLenum, GLenum, GLvoid **); -#define CALL_GetBufferPointervARB(disp, parameters) \ - (* GET_GetBufferPointervARB(disp)) parameters -static inline _glptr_GetBufferPointervARB GET_GetBufferPointervARB(struct _glapi_table *disp) { - return (_glptr_GetBufferPointervARB) (GET_by_offset(disp, _gloffset_GetBufferPointervARB)); -} - -static inline void SET_GetBufferPointervARB(struct _glapi_table *disp, void (GLAPIENTRYP fn)(GLenum, GLenum, GLvoid **)) { - SET_by_offset(disp, _gloffset_GetBufferPointervARB, fn); -} - -typedef void (GLAPIENTRYP _glptr_GetBufferSubDataARB)(GLenum, GLintptrARB, GLsizeiptrARB, GLvoid *); -#define CALL_GetBufferSubDataARB(disp, parameters) \ - (* GET_GetBufferSubDataARB(disp)) parameters -static inline _glptr_GetBufferSubDataARB GET_GetBufferSubDataARB(struct _glapi_table *disp) { - return (_glptr_GetBufferSubDataARB) (GET_by_offset(disp, _gloffset_GetBufferSubDataARB)); -} - -static inline void SET_GetBufferSubDataARB(struct _glapi_table *disp, void (GLAPIENTRYP fn)(GLenum, GLintptrARB, GLsizeiptrARB, GLvoid *)) { - SET_by_offset(disp, _gloffset_GetBufferSubDataARB, fn); -} - -typedef GLboolean (GLAPIENTRYP _glptr_IsBufferARB)(GLuint); -#define CALL_IsBufferARB(disp, parameters) \ - (* GET_IsBufferARB(disp)) parameters -static inline _glptr_IsBufferARB GET_IsBufferARB(struct _glapi_table *disp) { - return (_glptr_IsBufferARB) (GET_by_offset(disp, _gloffset_IsBufferARB)); -} - -static inline void SET_IsBufferARB(struct _glapi_table *disp, GLboolean (GLAPIENTRYP fn)(GLuint)) { - SET_by_offset(disp, _gloffset_IsBufferARB, fn); -} - -typedef GLvoid * (GLAPIENTRYP _glptr_MapBufferARB)(GLenum, GLenum); -#define CALL_MapBufferARB(disp, parameters) \ - (* GET_MapBufferARB(disp)) parameters -static inline _glptr_MapBufferARB GET_MapBufferARB(struct _glapi_table *disp) { - return (_glptr_MapBufferARB) (GET_by_offset(disp, _gloffset_MapBufferARB)); -} - -static inline void SET_MapBufferARB(struct _glapi_table *disp, GLvoid * (GLAPIENTRYP fn)(GLenum, GLenum)) { - SET_by_offset(disp, _gloffset_MapBufferARB, fn); -} - -typedef GLboolean (GLAPIENTRYP _glptr_UnmapBufferARB)(GLenum); -#define CALL_UnmapBufferARB(disp, parameters) \ - (* GET_UnmapBufferARB(disp)) parameters -static inline _glptr_UnmapBufferARB GET_UnmapBufferARB(struct _glapi_table *disp) { - return (_glptr_UnmapBufferARB) (GET_by_offset(disp, _gloffset_UnmapBufferARB)); -} - -static inline void SET_UnmapBufferARB(struct _glapi_table *disp, GLboolean (GLAPIENTRYP fn)(GLenum)) { - SET_by_offset(disp, _gloffset_UnmapBufferARB, fn); -} - -typedef void (GLAPIENTRYP _glptr_AttachObjectARB)(GLhandleARB, GLhandleARB); -#define CALL_AttachObjectARB(disp, parameters) \ - (* GET_AttachObjectARB(disp)) parameters -static inline _glptr_AttachObjectARB GET_AttachObjectARB(struct _glapi_table *disp) { - return (_glptr_AttachObjectARB) (GET_by_offset(disp, _gloffset_AttachObjectARB)); -} - -static inline void SET_AttachObjectARB(struct _glapi_table *disp, void (GLAPIENTRYP fn)(GLhandleARB, GLhandleARB)) { - SET_by_offset(disp, _gloffset_AttachObjectARB, fn); -} - -typedef void (GLAPIENTRYP _glptr_DeleteObjectARB)(GLhandleARB); -#define CALL_DeleteObjectARB(disp, parameters) \ - (* GET_DeleteObjectARB(disp)) parameters -static inline _glptr_DeleteObjectARB GET_DeleteObjectARB(struct _glapi_table *disp) { - return (_glptr_DeleteObjectARB) (GET_by_offset(disp, _gloffset_DeleteObjectARB)); -} - -static inline void SET_DeleteObjectARB(struct _glapi_table *disp, void (GLAPIENTRYP fn)(GLhandleARB)) { - SET_by_offset(disp, _gloffset_DeleteObjectARB, fn); -} - -typedef void (GLAPIENTRYP _glptr_DetachObjectARB)(GLhandleARB, GLhandleARB); -#define CALL_DetachObjectARB(disp, parameters) \ - (* GET_DetachObjectARB(disp)) parameters -static inline _glptr_DetachObjectARB GET_DetachObjectARB(struct _glapi_table *disp) { - return (_glptr_DetachObjectARB) (GET_by_offset(disp, _gloffset_DetachObjectARB)); -} - -static inline void SET_DetachObjectARB(struct _glapi_table *disp, void (GLAPIENTRYP fn)(GLhandleARB, GLhandleARB)) { - SET_by_offset(disp, _gloffset_DetachObjectARB, fn); -} - -typedef void (GLAPIENTRYP _glptr_GetAttachedObjectsARB)(GLhandleARB, GLsizei, GLsizei *, GLhandleARB *); -#define CALL_GetAttachedObjectsARB(disp, parameters) \ - (* GET_GetAttachedObjectsARB(disp)) parameters -static inline _glptr_GetAttachedObjectsARB GET_GetAttachedObjectsARB(struct _glapi_table *disp) { - return (_glptr_GetAttachedObjectsARB) (GET_by_offset(disp, _gloffset_GetAttachedObjectsARB)); -} - -static inline void SET_GetAttachedObjectsARB(struct _glapi_table *disp, void (GLAPIENTRYP fn)(GLhandleARB, GLsizei, GLsizei *, GLhandleARB *)) { - SET_by_offset(disp, _gloffset_GetAttachedObjectsARB, fn); -} - -typedef GLhandleARB (GLAPIENTRYP _glptr_GetHandleARB)(GLenum); -#define CALL_GetHandleARB(disp, parameters) \ - (* GET_GetHandleARB(disp)) parameters -static inline _glptr_GetHandleARB GET_GetHandleARB(struct _glapi_table *disp) { - return (_glptr_GetHandleARB) (GET_by_offset(disp, _gloffset_GetHandleARB)); -} - -static inline void SET_GetHandleARB(struct _glapi_table *disp, GLhandleARB (GLAPIENTRYP fn)(GLenum)) { - SET_by_offset(disp, _gloffset_GetHandleARB, fn); -} - -typedef void (GLAPIENTRYP _glptr_GetInfoLogARB)(GLhandleARB, GLsizei, GLsizei *, GLcharARB *); -#define CALL_GetInfoLogARB(disp, parameters) \ - (* GET_GetInfoLogARB(disp)) parameters -static inline _glptr_GetInfoLogARB GET_GetInfoLogARB(struct _glapi_table *disp) { - return (_glptr_GetInfoLogARB) (GET_by_offset(disp, _gloffset_GetInfoLogARB)); -} - -static inline void SET_GetInfoLogARB(struct _glapi_table *disp, void (GLAPIENTRYP fn)(GLhandleARB, GLsizei, GLsizei *, GLcharARB *)) { - SET_by_offset(disp, _gloffset_GetInfoLogARB, fn); -} - -typedef void (GLAPIENTRYP _glptr_GetObjectParameterfvARB)(GLhandleARB, GLenum, GLfloat *); -#define CALL_GetObjectParameterfvARB(disp, parameters) \ - (* GET_GetObjectParameterfvARB(disp)) parameters -static inline _glptr_GetObjectParameterfvARB GET_GetObjectParameterfvARB(struct _glapi_table *disp) { - return (_glptr_GetObjectParameterfvARB) (GET_by_offset(disp, _gloffset_GetObjectParameterfvARB)); -} - -static inline void SET_GetObjectParameterfvARB(struct _glapi_table *disp, void (GLAPIENTRYP fn)(GLhandleARB, GLenum, GLfloat *)) { - SET_by_offset(disp, _gloffset_GetObjectParameterfvARB, fn); -} - -typedef void (GLAPIENTRYP _glptr_GetObjectParameterivARB)(GLhandleARB, GLenum, GLint *); -#define CALL_GetObjectParameterivARB(disp, parameters) \ - (* GET_GetObjectParameterivARB(disp)) parameters -static inline _glptr_GetObjectParameterivARB GET_GetObjectParameterivARB(struct _glapi_table *disp) { - return (_glptr_GetObjectParameterivARB) (GET_by_offset(disp, _gloffset_GetObjectParameterivARB)); -} - -static inline void SET_GetObjectParameterivARB(struct _glapi_table *disp, void (GLAPIENTRYP fn)(GLhandleARB, GLenum, GLint *)) { - SET_by_offset(disp, _gloffset_GetObjectParameterivARB, fn); -} - -typedef void (GLAPIENTRYP _glptr_GetActiveAttribARB)(GLhandleARB, GLuint, GLsizei, GLsizei *, GLint *, GLenum *, GLcharARB *); -#define CALL_GetActiveAttribARB(disp, parameters) \ - (* GET_GetActiveAttribARB(disp)) parameters -static inline _glptr_GetActiveAttribARB GET_GetActiveAttribARB(struct _glapi_table *disp) { - return (_glptr_GetActiveAttribARB) (GET_by_offset(disp, _gloffset_GetActiveAttribARB)); -} - -static inline void SET_GetActiveAttribARB(struct _glapi_table *disp, void (GLAPIENTRYP fn)(GLhandleARB, GLuint, GLsizei, GLsizei *, GLint *, GLenum *, GLcharARB *)) { - SET_by_offset(disp, _gloffset_GetActiveAttribARB, fn); -} - -typedef void (GLAPIENTRYP _glptr_FlushMappedBufferRange)(GLenum, GLintptr, GLsizeiptr); -#define CALL_FlushMappedBufferRange(disp, parameters) \ - (* GET_FlushMappedBufferRange(disp)) parameters -static inline _glptr_FlushMappedBufferRange GET_FlushMappedBufferRange(struct _glapi_table *disp) { - return (_glptr_FlushMappedBufferRange) (GET_by_offset(disp, _gloffset_FlushMappedBufferRange)); -} - -static inline void SET_FlushMappedBufferRange(struct _glapi_table *disp, void (GLAPIENTRYP fn)(GLenum, GLintptr, GLsizeiptr)) { - SET_by_offset(disp, _gloffset_FlushMappedBufferRange, fn); -} - -typedef GLvoid * (GLAPIENTRYP _glptr_MapBufferRange)(GLenum, GLintptr, GLsizeiptr, GLbitfield); -#define CALL_MapBufferRange(disp, parameters) \ - (* GET_MapBufferRange(disp)) parameters -static inline _glptr_MapBufferRange GET_MapBufferRange(struct _glapi_table *disp) { - return (_glptr_MapBufferRange) (GET_by_offset(disp, _gloffset_MapBufferRange)); -} - -static inline void SET_MapBufferRange(struct _glapi_table *disp, GLvoid * (GLAPIENTRYP fn)(GLenum, GLintptr, GLsizeiptr, GLbitfield)) { - SET_by_offset(disp, _gloffset_MapBufferRange, fn); -} - -typedef void (GLAPIENTRYP _glptr_TexStorage1D)(GLenum, GLsizei, GLenum, GLsizei); -#define CALL_TexStorage1D(disp, parameters) \ - (* GET_TexStorage1D(disp)) parameters -static inline _glptr_TexStorage1D GET_TexStorage1D(struct _glapi_table *disp) { - return (_glptr_TexStorage1D) (GET_by_offset(disp, _gloffset_TexStorage1D)); -} - -static inline void SET_TexStorage1D(struct _glapi_table *disp, void (GLAPIENTRYP fn)(GLenum, GLsizei, GLenum, GLsizei)) { - SET_by_offset(disp, _gloffset_TexStorage1D, fn); -} - -typedef void (GLAPIENTRYP _glptr_TexStorage2D)(GLenum, GLsizei, GLenum, GLsizei, GLsizei); -#define CALL_TexStorage2D(disp, parameters) \ - (* GET_TexStorage2D(disp)) parameters -static inline _glptr_TexStorage2D GET_TexStorage2D(struct _glapi_table *disp) { - return (_glptr_TexStorage2D) (GET_by_offset(disp, _gloffset_TexStorage2D)); -} - -static inline void SET_TexStorage2D(struct _glapi_table *disp, void (GLAPIENTRYP fn)(GLenum, GLsizei, GLenum, GLsizei, GLsizei)) { - SET_by_offset(disp, _gloffset_TexStorage2D, fn); -} - -typedef void (GLAPIENTRYP _glptr_TexStorage3D)(GLenum, GLsizei, GLenum, GLsizei, GLsizei, GLsizei); -#define CALL_TexStorage3D(disp, parameters) \ - (* GET_TexStorage3D(disp)) parameters -static inline _glptr_TexStorage3D GET_TexStorage3D(struct _glapi_table *disp) { - return (_glptr_TexStorage3D) (GET_by_offset(disp, _gloffset_TexStorage3D)); -} - -static inline void SET_TexStorage3D(struct _glapi_table *disp, void (GLAPIENTRYP fn)(GLenum, GLsizei, GLenum, GLsizei, GLsizei, GLsizei)) { - SET_by_offset(disp, _gloffset_TexStorage3D, fn); -} - -typedef void (GLAPIENTRYP _glptr_TextureStorage1DEXT)(GLuint, GLenum, GLsizei, GLenum, GLsizei); -#define CALL_TextureStorage1DEXT(disp, parameters) \ - (* GET_TextureStorage1DEXT(disp)) parameters -static inline _glptr_TextureStorage1DEXT GET_TextureStorage1DEXT(struct _glapi_table *disp) { - return (_glptr_TextureStorage1DEXT) (GET_by_offset(disp, _gloffset_TextureStorage1DEXT)); -} - -static inline void SET_TextureStorage1DEXT(struct _glapi_table *disp, void (GLAPIENTRYP fn)(GLuint, GLenum, GLsizei, GLenum, GLsizei)) { - SET_by_offset(disp, _gloffset_TextureStorage1DEXT, fn); -} - -typedef void (GLAPIENTRYP _glptr_TextureStorage2DEXT)(GLuint, GLenum, GLsizei, GLenum, GLsizei, GLsizei); -#define CALL_TextureStorage2DEXT(disp, parameters) \ - (* GET_TextureStorage2DEXT(disp)) parameters -static inline _glptr_TextureStorage2DEXT GET_TextureStorage2DEXT(struct _glapi_table *disp) { - return (_glptr_TextureStorage2DEXT) (GET_by_offset(disp, _gloffset_TextureStorage2DEXT)); -} - -static inline void SET_TextureStorage2DEXT(struct _glapi_table *disp, void (GLAPIENTRYP fn)(GLuint, GLenum, GLsizei, GLenum, GLsizei, GLsizei)) { - SET_by_offset(disp, _gloffset_TextureStorage2DEXT, fn); -} - -typedef void (GLAPIENTRYP _glptr_TextureStorage3DEXT)(GLuint, GLenum, GLsizei, GLenum, GLsizei, GLsizei, GLsizei); -#define CALL_TextureStorage3DEXT(disp, parameters) \ - (* GET_TextureStorage3DEXT(disp)) parameters -static inline _glptr_TextureStorage3DEXT GET_TextureStorage3DEXT(struct _glapi_table *disp) { - return (_glptr_TextureStorage3DEXT) (GET_by_offset(disp, _gloffset_TextureStorage3DEXT)); -} - -static inline void SET_TextureStorage3DEXT(struct _glapi_table *disp, void (GLAPIENTRYP fn)(GLuint, GLenum, GLsizei, GLenum, GLsizei, GLsizei, GLsizei)) { - SET_by_offset(disp, _gloffset_TextureStorage3DEXT, fn); -} - -typedef void (GLAPIENTRYP _glptr_PolygonOffsetEXT)(GLfloat, GLfloat); -#define CALL_PolygonOffsetEXT(disp, parameters) \ - (* GET_PolygonOffsetEXT(disp)) parameters -static inline _glptr_PolygonOffsetEXT GET_PolygonOffsetEXT(struct _glapi_table *disp) { - return (_glptr_PolygonOffsetEXT) (GET_by_offset(disp, _gloffset_PolygonOffsetEXT)); -} - -static inline void SET_PolygonOffsetEXT(struct _glapi_table *disp, void (GLAPIENTRYP fn)(GLfloat, GLfloat)) { - SET_by_offset(disp, _gloffset_PolygonOffsetEXT, fn); -} - -typedef void (GLAPIENTRYP _glptr_SampleMaskSGIS)(GLclampf, GLboolean); -#define CALL_SampleMaskSGIS(disp, parameters) \ - (* GET_SampleMaskSGIS(disp)) parameters -static inline _glptr_SampleMaskSGIS GET_SampleMaskSGIS(struct _glapi_table *disp) { - return (_glptr_SampleMaskSGIS) (GET_by_offset(disp, _gloffset_SampleMaskSGIS)); -} - -static inline void SET_SampleMaskSGIS(struct _glapi_table *disp, void (GLAPIENTRYP fn)(GLclampf, GLboolean)) { - SET_by_offset(disp, _gloffset_SampleMaskSGIS, fn); -} - -typedef void (GLAPIENTRYP _glptr_SamplePatternSGIS)(GLenum); -#define CALL_SamplePatternSGIS(disp, parameters) \ - (* GET_SamplePatternSGIS(disp)) parameters -static inline _glptr_SamplePatternSGIS GET_SamplePatternSGIS(struct _glapi_table *disp) { - return (_glptr_SamplePatternSGIS) (GET_by_offset(disp, _gloffset_SamplePatternSGIS)); -} - -static inline void SET_SamplePatternSGIS(struct _glapi_table *disp, void (GLAPIENTRYP fn)(GLenum)) { - SET_by_offset(disp, _gloffset_SamplePatternSGIS, fn); -} - -typedef void (GLAPIENTRYP _glptr_ColorPointerEXT)(GLint, GLenum, GLsizei, GLsizei, const GLvoid *); -#define CALL_ColorPointerEXT(disp, parameters) \ - (* GET_ColorPointerEXT(disp)) parameters -static inline _glptr_ColorPointerEXT GET_ColorPointerEXT(struct _glapi_table *disp) { - return (_glptr_ColorPointerEXT) (GET_by_offset(disp, _gloffset_ColorPointerEXT)); -} - -static inline void SET_ColorPointerEXT(struct _glapi_table *disp, void (GLAPIENTRYP fn)(GLint, GLenum, GLsizei, GLsizei, const GLvoid *)) { - SET_by_offset(disp, _gloffset_ColorPointerEXT, fn); -} - -typedef void (GLAPIENTRYP _glptr_EdgeFlagPointerEXT)(GLsizei, GLsizei, const GLboolean *); -#define CALL_EdgeFlagPointerEXT(disp, parameters) \ - (* GET_EdgeFlagPointerEXT(disp)) parameters -static inline _glptr_EdgeFlagPointerEXT GET_EdgeFlagPointerEXT(struct _glapi_table *disp) { - return (_glptr_EdgeFlagPointerEXT) (GET_by_offset(disp, _gloffset_EdgeFlagPointerEXT)); -} - -static inline void SET_EdgeFlagPointerEXT(struct _glapi_table *disp, void (GLAPIENTRYP fn)(GLsizei, GLsizei, const GLboolean *)) { - SET_by_offset(disp, _gloffset_EdgeFlagPointerEXT, fn); -} - -typedef void (GLAPIENTRYP _glptr_IndexPointerEXT)(GLenum, GLsizei, GLsizei, const GLvoid *); -#define CALL_IndexPointerEXT(disp, parameters) \ - (* GET_IndexPointerEXT(disp)) parameters -static inline _glptr_IndexPointerEXT GET_IndexPointerEXT(struct _glapi_table *disp) { - return (_glptr_IndexPointerEXT) (GET_by_offset(disp, _gloffset_IndexPointerEXT)); -} - -static inline void SET_IndexPointerEXT(struct _glapi_table *disp, void (GLAPIENTRYP fn)(GLenum, GLsizei, GLsizei, const GLvoid *)) { - SET_by_offset(disp, _gloffset_IndexPointerEXT, fn); -} - -typedef void (GLAPIENTRYP _glptr_NormalPointerEXT)(GLenum, GLsizei, GLsizei, const GLvoid *); -#define CALL_NormalPointerEXT(disp, parameters) \ - (* GET_NormalPointerEXT(disp)) parameters -static inline _glptr_NormalPointerEXT GET_NormalPointerEXT(struct _glapi_table *disp) { - return (_glptr_NormalPointerEXT) (GET_by_offset(disp, _gloffset_NormalPointerEXT)); -} - -static inline void SET_NormalPointerEXT(struct _glapi_table *disp, void (GLAPIENTRYP fn)(GLenum, GLsizei, GLsizei, const GLvoid *)) { - SET_by_offset(disp, _gloffset_NormalPointerEXT, fn); -} - -typedef void (GLAPIENTRYP _glptr_TexCoordPointerEXT)(GLint, GLenum, GLsizei, GLsizei, const GLvoid *); -#define CALL_TexCoordPointerEXT(disp, parameters) \ - (* GET_TexCoordPointerEXT(disp)) parameters -static inline _glptr_TexCoordPointerEXT GET_TexCoordPointerEXT(struct _glapi_table *disp) { - return (_glptr_TexCoordPointerEXT) (GET_by_offset(disp, _gloffset_TexCoordPointerEXT)); -} - -static inline void SET_TexCoordPointerEXT(struct _glapi_table *disp, void (GLAPIENTRYP fn)(GLint, GLenum, GLsizei, GLsizei, const GLvoid *)) { - SET_by_offset(disp, _gloffset_TexCoordPointerEXT, fn); -} - -typedef void (GLAPIENTRYP _glptr_VertexPointerEXT)(GLint, GLenum, GLsizei, GLsizei, const GLvoid *); -#define CALL_VertexPointerEXT(disp, parameters) \ - (* GET_VertexPointerEXT(disp)) parameters -static inline _glptr_VertexPointerEXT GET_VertexPointerEXT(struct _glapi_table *disp) { - return (_glptr_VertexPointerEXT) (GET_by_offset(disp, _gloffset_VertexPointerEXT)); -} - -static inline void SET_VertexPointerEXT(struct _glapi_table *disp, void (GLAPIENTRYP fn)(GLint, GLenum, GLsizei, GLsizei, const GLvoid *)) { - SET_by_offset(disp, _gloffset_VertexPointerEXT, fn); -} - -typedef void (GLAPIENTRYP _glptr_PointParameterfEXT)(GLenum, GLfloat); -#define CALL_PointParameterfEXT(disp, parameters) \ - (* GET_PointParameterfEXT(disp)) parameters -static inline _glptr_PointParameterfEXT GET_PointParameterfEXT(struct _glapi_table *disp) { - return (_glptr_PointParameterfEXT) (GET_by_offset(disp, _gloffset_PointParameterfEXT)); -} - -static inline void SET_PointParameterfEXT(struct _glapi_table *disp, void (GLAPIENTRYP fn)(GLenum, GLfloat)) { - SET_by_offset(disp, _gloffset_PointParameterfEXT, fn); -} - -typedef void (GLAPIENTRYP _glptr_PointParameterfvEXT)(GLenum, const GLfloat *); -#define CALL_PointParameterfvEXT(disp, parameters) \ - (* GET_PointParameterfvEXT(disp)) parameters -static inline _glptr_PointParameterfvEXT GET_PointParameterfvEXT(struct _glapi_table *disp) { - return (_glptr_PointParameterfvEXT) (GET_by_offset(disp, _gloffset_PointParameterfvEXT)); -} - -static inline void SET_PointParameterfvEXT(struct _glapi_table *disp, void (GLAPIENTRYP fn)(GLenum, const GLfloat *)) { - SET_by_offset(disp, _gloffset_PointParameterfvEXT, fn); -} - -typedef void (GLAPIENTRYP _glptr_LockArraysEXT)(GLint, GLsizei); -#define CALL_LockArraysEXT(disp, parameters) \ - (* GET_LockArraysEXT(disp)) parameters -static inline _glptr_LockArraysEXT GET_LockArraysEXT(struct _glapi_table *disp) { - return (_glptr_LockArraysEXT) (GET_by_offset(disp, _gloffset_LockArraysEXT)); -} - -static inline void SET_LockArraysEXT(struct _glapi_table *disp, void (GLAPIENTRYP fn)(GLint, GLsizei)) { - SET_by_offset(disp, _gloffset_LockArraysEXT, fn); -} - -typedef void (GLAPIENTRYP _glptr_UnlockArraysEXT)(void); -#define CALL_UnlockArraysEXT(disp, parameters) \ - (* GET_UnlockArraysEXT(disp)) parameters -static inline _glptr_UnlockArraysEXT GET_UnlockArraysEXT(struct _glapi_table *disp) { - return (_glptr_UnlockArraysEXT) (GET_by_offset(disp, _gloffset_UnlockArraysEXT)); -} - -static inline void SET_UnlockArraysEXT(struct _glapi_table *disp, void (GLAPIENTRYP fn)(void)) { - SET_by_offset(disp, _gloffset_UnlockArraysEXT, fn); -} - -typedef void (GLAPIENTRYP _glptr_FogCoordPointerEXT)(GLenum, GLsizei, const GLvoid *); -#define CALL_FogCoordPointerEXT(disp, parameters) \ - (* GET_FogCoordPointerEXT(disp)) parameters -static inline _glptr_FogCoordPointerEXT GET_FogCoordPointerEXT(struct _glapi_table *disp) { - return (_glptr_FogCoordPointerEXT) (GET_by_offset(disp, _gloffset_FogCoordPointerEXT)); -} - -static inline void SET_FogCoordPointerEXT(struct _glapi_table *disp, void (GLAPIENTRYP fn)(GLenum, GLsizei, const GLvoid *)) { - SET_by_offset(disp, _gloffset_FogCoordPointerEXT, fn); -} - -typedef void (GLAPIENTRYP _glptr_FogCoorddEXT)(GLdouble); -#define CALL_FogCoorddEXT(disp, parameters) \ - (* GET_FogCoorddEXT(disp)) parameters -static inline _glptr_FogCoorddEXT GET_FogCoorddEXT(struct _glapi_table *disp) { - return (_glptr_FogCoorddEXT) (GET_by_offset(disp, _gloffset_FogCoorddEXT)); -} - -static inline void SET_FogCoorddEXT(struct _glapi_table *disp, void (GLAPIENTRYP fn)(GLdouble)) { - SET_by_offset(disp, _gloffset_FogCoorddEXT, fn); -} - -typedef void (GLAPIENTRYP _glptr_FogCoorddvEXT)(const GLdouble *); -#define CALL_FogCoorddvEXT(disp, parameters) \ - (* GET_FogCoorddvEXT(disp)) parameters -static inline _glptr_FogCoorddvEXT GET_FogCoorddvEXT(struct _glapi_table *disp) { - return (_glptr_FogCoorddvEXT) (GET_by_offset(disp, _gloffset_FogCoorddvEXT)); -} - -static inline void SET_FogCoorddvEXT(struct _glapi_table *disp, void (GLAPIENTRYP fn)(const GLdouble *)) { - SET_by_offset(disp, _gloffset_FogCoorddvEXT, fn); -} - -typedef void (GLAPIENTRYP _glptr_FogCoordfEXT)(GLfloat); -#define CALL_FogCoordfEXT(disp, parameters) \ - (* GET_FogCoordfEXT(disp)) parameters -static inline _glptr_FogCoordfEXT GET_FogCoordfEXT(struct _glapi_table *disp) { - return (_glptr_FogCoordfEXT) (GET_by_offset(disp, _gloffset_FogCoordfEXT)); -} - -static inline void SET_FogCoordfEXT(struct _glapi_table *disp, void (GLAPIENTRYP fn)(GLfloat)) { - SET_by_offset(disp, _gloffset_FogCoordfEXT, fn); -} - -typedef void (GLAPIENTRYP _glptr_FogCoordfvEXT)(const GLfloat *); -#define CALL_FogCoordfvEXT(disp, parameters) \ - (* GET_FogCoordfvEXT(disp)) parameters -static inline _glptr_FogCoordfvEXT GET_FogCoordfvEXT(struct _glapi_table *disp) { - return (_glptr_FogCoordfvEXT) (GET_by_offset(disp, _gloffset_FogCoordfvEXT)); -} - -static inline void SET_FogCoordfvEXT(struct _glapi_table *disp, void (GLAPIENTRYP fn)(const GLfloat *)) { - SET_by_offset(disp, _gloffset_FogCoordfvEXT, fn); -} - -typedef void (GLAPIENTRYP _glptr_PixelTexGenSGIX)(GLenum); -#define CALL_PixelTexGenSGIX(disp, parameters) \ - (* GET_PixelTexGenSGIX(disp)) parameters -static inline _glptr_PixelTexGenSGIX GET_PixelTexGenSGIX(struct _glapi_table *disp) { - return (_glptr_PixelTexGenSGIX) (GET_by_offset(disp, _gloffset_PixelTexGenSGIX)); -} - -static inline void SET_PixelTexGenSGIX(struct _glapi_table *disp, void (GLAPIENTRYP fn)(GLenum)) { - SET_by_offset(disp, _gloffset_PixelTexGenSGIX, fn); -} - -typedef void (GLAPIENTRYP _glptr_FlushVertexArrayRangeNV)(void); -#define CALL_FlushVertexArrayRangeNV(disp, parameters) \ - (* GET_FlushVertexArrayRangeNV(disp)) parameters -static inline _glptr_FlushVertexArrayRangeNV GET_FlushVertexArrayRangeNV(struct _glapi_table *disp) { - return (_glptr_FlushVertexArrayRangeNV) (GET_by_offset(disp, _gloffset_FlushVertexArrayRangeNV)); -} - -static inline void SET_FlushVertexArrayRangeNV(struct _glapi_table *disp, void (GLAPIENTRYP fn)(void)) { - SET_by_offset(disp, _gloffset_FlushVertexArrayRangeNV, fn); -} - -typedef void (GLAPIENTRYP _glptr_VertexArrayRangeNV)(GLsizei, const GLvoid *); -#define CALL_VertexArrayRangeNV(disp, parameters) \ - (* GET_VertexArrayRangeNV(disp)) parameters -static inline _glptr_VertexArrayRangeNV GET_VertexArrayRangeNV(struct _glapi_table *disp) { - return (_glptr_VertexArrayRangeNV) (GET_by_offset(disp, _gloffset_VertexArrayRangeNV)); -} - -static inline void SET_VertexArrayRangeNV(struct _glapi_table *disp, void (GLAPIENTRYP fn)(GLsizei, const GLvoid *)) { - SET_by_offset(disp, _gloffset_VertexArrayRangeNV, fn); -} - -typedef void (GLAPIENTRYP _glptr_CombinerInputNV)(GLenum, GLenum, GLenum, GLenum, GLenum, GLenum); -#define CALL_CombinerInputNV(disp, parameters) \ - (* GET_CombinerInputNV(disp)) parameters -static inline _glptr_CombinerInputNV GET_CombinerInputNV(struct _glapi_table *disp) { - return (_glptr_CombinerInputNV) (GET_by_offset(disp, _gloffset_CombinerInputNV)); -} - -static inline void SET_CombinerInputNV(struct _glapi_table *disp, void (GLAPIENTRYP fn)(GLenum, GLenum, GLenum, GLenum, GLenum, GLenum)) { - SET_by_offset(disp, _gloffset_CombinerInputNV, fn); -} - -typedef void (GLAPIENTRYP _glptr_CombinerOutputNV)(GLenum, GLenum, GLenum, GLenum, GLenum, GLenum, GLenum, GLboolean, GLboolean, GLboolean); -#define CALL_CombinerOutputNV(disp, parameters) \ - (* GET_CombinerOutputNV(disp)) parameters -static inline _glptr_CombinerOutputNV GET_CombinerOutputNV(struct _glapi_table *disp) { - return (_glptr_CombinerOutputNV) (GET_by_offset(disp, _gloffset_CombinerOutputNV)); -} - -static inline void SET_CombinerOutputNV(struct _glapi_table *disp, void (GLAPIENTRYP fn)(GLenum, GLenum, GLenum, GLenum, GLenum, GLenum, GLenum, GLboolean, GLboolean, GLboolean)) { - SET_by_offset(disp, _gloffset_CombinerOutputNV, fn); -} - -typedef void (GLAPIENTRYP _glptr_CombinerParameterfNV)(GLenum, GLfloat); -#define CALL_CombinerParameterfNV(disp, parameters) \ - (* GET_CombinerParameterfNV(disp)) parameters -static inline _glptr_CombinerParameterfNV GET_CombinerParameterfNV(struct _glapi_table *disp) { - return (_glptr_CombinerParameterfNV) (GET_by_offset(disp, _gloffset_CombinerParameterfNV)); -} - -static inline void SET_CombinerParameterfNV(struct _glapi_table *disp, void (GLAPIENTRYP fn)(GLenum, GLfloat)) { - SET_by_offset(disp, _gloffset_CombinerParameterfNV, fn); -} - -typedef void (GLAPIENTRYP _glptr_CombinerParameterfvNV)(GLenum, const GLfloat *); -#define CALL_CombinerParameterfvNV(disp, parameters) \ - (* GET_CombinerParameterfvNV(disp)) parameters -static inline _glptr_CombinerParameterfvNV GET_CombinerParameterfvNV(struct _glapi_table *disp) { - return (_glptr_CombinerParameterfvNV) (GET_by_offset(disp, _gloffset_CombinerParameterfvNV)); -} - -static inline void SET_CombinerParameterfvNV(struct _glapi_table *disp, void (GLAPIENTRYP fn)(GLenum, const GLfloat *)) { - SET_by_offset(disp, _gloffset_CombinerParameterfvNV, fn); -} - -typedef void (GLAPIENTRYP _glptr_CombinerParameteriNV)(GLenum, GLint); -#define CALL_CombinerParameteriNV(disp, parameters) \ - (* GET_CombinerParameteriNV(disp)) parameters -static inline _glptr_CombinerParameteriNV GET_CombinerParameteriNV(struct _glapi_table *disp) { - return (_glptr_CombinerParameteriNV) (GET_by_offset(disp, _gloffset_CombinerParameteriNV)); -} - -static inline void SET_CombinerParameteriNV(struct _glapi_table *disp, void (GLAPIENTRYP fn)(GLenum, GLint)) { - SET_by_offset(disp, _gloffset_CombinerParameteriNV, fn); -} - -typedef void (GLAPIENTRYP _glptr_CombinerParameterivNV)(GLenum, const GLint *); -#define CALL_CombinerParameterivNV(disp, parameters) \ - (* GET_CombinerParameterivNV(disp)) parameters -static inline _glptr_CombinerParameterivNV GET_CombinerParameterivNV(struct _glapi_table *disp) { - return (_glptr_CombinerParameterivNV) (GET_by_offset(disp, _gloffset_CombinerParameterivNV)); -} - -static inline void SET_CombinerParameterivNV(struct _glapi_table *disp, void (GLAPIENTRYP fn)(GLenum, const GLint *)) { - SET_by_offset(disp, _gloffset_CombinerParameterivNV, fn); -} - -typedef void (GLAPIENTRYP _glptr_FinalCombinerInputNV)(GLenum, GLenum, GLenum, GLenum); -#define CALL_FinalCombinerInputNV(disp, parameters) \ - (* GET_FinalCombinerInputNV(disp)) parameters -static inline _glptr_FinalCombinerInputNV GET_FinalCombinerInputNV(struct _glapi_table *disp) { - return (_glptr_FinalCombinerInputNV) (GET_by_offset(disp, _gloffset_FinalCombinerInputNV)); -} - -static inline void SET_FinalCombinerInputNV(struct _glapi_table *disp, void (GLAPIENTRYP fn)(GLenum, GLenum, GLenum, GLenum)) { - SET_by_offset(disp, _gloffset_FinalCombinerInputNV, fn); -} - -typedef void (GLAPIENTRYP _glptr_GetCombinerInputParameterfvNV)(GLenum, GLenum, GLenum, GLenum, GLfloat *); -#define CALL_GetCombinerInputParameterfvNV(disp, parameters) \ - (* GET_GetCombinerInputParameterfvNV(disp)) parameters -static inline _glptr_GetCombinerInputParameterfvNV GET_GetCombinerInputParameterfvNV(struct _glapi_table *disp) { - return (_glptr_GetCombinerInputParameterfvNV) (GET_by_offset(disp, _gloffset_GetCombinerInputParameterfvNV)); -} - -static inline void SET_GetCombinerInputParameterfvNV(struct _glapi_table *disp, void (GLAPIENTRYP fn)(GLenum, GLenum, GLenum, GLenum, GLfloat *)) { - SET_by_offset(disp, _gloffset_GetCombinerInputParameterfvNV, fn); -} - -typedef void (GLAPIENTRYP _glptr_GetCombinerInputParameterivNV)(GLenum, GLenum, GLenum, GLenum, GLint *); -#define CALL_GetCombinerInputParameterivNV(disp, parameters) \ - (* GET_GetCombinerInputParameterivNV(disp)) parameters -static inline _glptr_GetCombinerInputParameterivNV GET_GetCombinerInputParameterivNV(struct _glapi_table *disp) { - return (_glptr_GetCombinerInputParameterivNV) (GET_by_offset(disp, _gloffset_GetCombinerInputParameterivNV)); -} - -static inline void SET_GetCombinerInputParameterivNV(struct _glapi_table *disp, void (GLAPIENTRYP fn)(GLenum, GLenum, GLenum, GLenum, GLint *)) { - SET_by_offset(disp, _gloffset_GetCombinerInputParameterivNV, fn); -} - -typedef void (GLAPIENTRYP _glptr_GetCombinerOutputParameterfvNV)(GLenum, GLenum, GLenum, GLfloat *); -#define CALL_GetCombinerOutputParameterfvNV(disp, parameters) \ - (* GET_GetCombinerOutputParameterfvNV(disp)) parameters -static inline _glptr_GetCombinerOutputParameterfvNV GET_GetCombinerOutputParameterfvNV(struct _glapi_table *disp) { - return (_glptr_GetCombinerOutputParameterfvNV) (GET_by_offset(disp, _gloffset_GetCombinerOutputParameterfvNV)); -} - -static inline void SET_GetCombinerOutputParameterfvNV(struct _glapi_table *disp, void (GLAPIENTRYP fn)(GLenum, GLenum, GLenum, GLfloat *)) { - SET_by_offset(disp, _gloffset_GetCombinerOutputParameterfvNV, fn); -} - -typedef void (GLAPIENTRYP _glptr_GetCombinerOutputParameterivNV)(GLenum, GLenum, GLenum, GLint *); -#define CALL_GetCombinerOutputParameterivNV(disp, parameters) \ - (* GET_GetCombinerOutputParameterivNV(disp)) parameters -static inline _glptr_GetCombinerOutputParameterivNV GET_GetCombinerOutputParameterivNV(struct _glapi_table *disp) { - return (_glptr_GetCombinerOutputParameterivNV) (GET_by_offset(disp, _gloffset_GetCombinerOutputParameterivNV)); -} - -static inline void SET_GetCombinerOutputParameterivNV(struct _glapi_table *disp, void (GLAPIENTRYP fn)(GLenum, GLenum, GLenum, GLint *)) { - SET_by_offset(disp, _gloffset_GetCombinerOutputParameterivNV, fn); -} - -typedef void (GLAPIENTRYP _glptr_GetFinalCombinerInputParameterfvNV)(GLenum, GLenum, GLfloat *); -#define CALL_GetFinalCombinerInputParameterfvNV(disp, parameters) \ - (* GET_GetFinalCombinerInputParameterfvNV(disp)) parameters -static inline _glptr_GetFinalCombinerInputParameterfvNV GET_GetFinalCombinerInputParameterfvNV(struct _glapi_table *disp) { - return (_glptr_GetFinalCombinerInputParameterfvNV) (GET_by_offset(disp, _gloffset_GetFinalCombinerInputParameterfvNV)); -} - -static inline void SET_GetFinalCombinerInputParameterfvNV(struct _glapi_table *disp, void (GLAPIENTRYP fn)(GLenum, GLenum, GLfloat *)) { - SET_by_offset(disp, _gloffset_GetFinalCombinerInputParameterfvNV, fn); -} - -typedef void (GLAPIENTRYP _glptr_GetFinalCombinerInputParameterivNV)(GLenum, GLenum, GLint *); -#define CALL_GetFinalCombinerInputParameterivNV(disp, parameters) \ - (* GET_GetFinalCombinerInputParameterivNV(disp)) parameters -static inline _glptr_GetFinalCombinerInputParameterivNV GET_GetFinalCombinerInputParameterivNV(struct _glapi_table *disp) { - return (_glptr_GetFinalCombinerInputParameterivNV) (GET_by_offset(disp, _gloffset_GetFinalCombinerInputParameterivNV)); -} - -static inline void SET_GetFinalCombinerInputParameterivNV(struct _glapi_table *disp, void (GLAPIENTRYP fn)(GLenum, GLenum, GLint *)) { - SET_by_offset(disp, _gloffset_GetFinalCombinerInputParameterivNV, fn); -} - -typedef void (GLAPIENTRYP _glptr_WindowPos2dMESA)(GLdouble, GLdouble); -#define CALL_WindowPos2dMESA(disp, parameters) \ - (* GET_WindowPos2dMESA(disp)) parameters -static inline _glptr_WindowPos2dMESA GET_WindowPos2dMESA(struct _glapi_table *disp) { - return (_glptr_WindowPos2dMESA) (GET_by_offset(disp, _gloffset_WindowPos2dMESA)); -} - -static inline void SET_WindowPos2dMESA(struct _glapi_table *disp, void (GLAPIENTRYP fn)(GLdouble, GLdouble)) { - SET_by_offset(disp, _gloffset_WindowPos2dMESA, fn); -} - -typedef void (GLAPIENTRYP _glptr_WindowPos2dvMESA)(const GLdouble *); -#define CALL_WindowPos2dvMESA(disp, parameters) \ - (* GET_WindowPos2dvMESA(disp)) parameters -static inline _glptr_WindowPos2dvMESA GET_WindowPos2dvMESA(struct _glapi_table *disp) { - return (_glptr_WindowPos2dvMESA) (GET_by_offset(disp, _gloffset_WindowPos2dvMESA)); -} - -static inline void SET_WindowPos2dvMESA(struct _glapi_table *disp, void (GLAPIENTRYP fn)(const GLdouble *)) { - SET_by_offset(disp, _gloffset_WindowPos2dvMESA, fn); -} - -typedef void (GLAPIENTRYP _glptr_WindowPos2fMESA)(GLfloat, GLfloat); -#define CALL_WindowPos2fMESA(disp, parameters) \ - (* GET_WindowPos2fMESA(disp)) parameters -static inline _glptr_WindowPos2fMESA GET_WindowPos2fMESA(struct _glapi_table *disp) { - return (_glptr_WindowPos2fMESA) (GET_by_offset(disp, _gloffset_WindowPos2fMESA)); -} - -static inline void SET_WindowPos2fMESA(struct _glapi_table *disp, void (GLAPIENTRYP fn)(GLfloat, GLfloat)) { - SET_by_offset(disp, _gloffset_WindowPos2fMESA, fn); -} - -typedef void (GLAPIENTRYP _glptr_WindowPos2fvMESA)(const GLfloat *); -#define CALL_WindowPos2fvMESA(disp, parameters) \ - (* GET_WindowPos2fvMESA(disp)) parameters -static inline _glptr_WindowPos2fvMESA GET_WindowPos2fvMESA(struct _glapi_table *disp) { - return (_glptr_WindowPos2fvMESA) (GET_by_offset(disp, _gloffset_WindowPos2fvMESA)); -} - -static inline void SET_WindowPos2fvMESA(struct _glapi_table *disp, void (GLAPIENTRYP fn)(const GLfloat *)) { - SET_by_offset(disp, _gloffset_WindowPos2fvMESA, fn); -} - -typedef void (GLAPIENTRYP _glptr_WindowPos2iMESA)(GLint, GLint); -#define CALL_WindowPos2iMESA(disp, parameters) \ - (* GET_WindowPos2iMESA(disp)) parameters -static inline _glptr_WindowPos2iMESA GET_WindowPos2iMESA(struct _glapi_table *disp) { - return (_glptr_WindowPos2iMESA) (GET_by_offset(disp, _gloffset_WindowPos2iMESA)); -} - -static inline void SET_WindowPos2iMESA(struct _glapi_table *disp, void (GLAPIENTRYP fn)(GLint, GLint)) { - SET_by_offset(disp, _gloffset_WindowPos2iMESA, fn); -} - -typedef void (GLAPIENTRYP _glptr_WindowPos2ivMESA)(const GLint *); -#define CALL_WindowPos2ivMESA(disp, parameters) \ - (* GET_WindowPos2ivMESA(disp)) parameters -static inline _glptr_WindowPos2ivMESA GET_WindowPos2ivMESA(struct _glapi_table *disp) { - return (_glptr_WindowPos2ivMESA) (GET_by_offset(disp, _gloffset_WindowPos2ivMESA)); -} - -static inline void SET_WindowPos2ivMESA(struct _glapi_table *disp, void (GLAPIENTRYP fn)(const GLint *)) { - SET_by_offset(disp, _gloffset_WindowPos2ivMESA, fn); -} - -typedef void (GLAPIENTRYP _glptr_WindowPos2sMESA)(GLshort, GLshort); -#define CALL_WindowPos2sMESA(disp, parameters) \ - (* GET_WindowPos2sMESA(disp)) parameters -static inline _glptr_WindowPos2sMESA GET_WindowPos2sMESA(struct _glapi_table *disp) { - return (_glptr_WindowPos2sMESA) (GET_by_offset(disp, _gloffset_WindowPos2sMESA)); -} - -static inline void SET_WindowPos2sMESA(struct _glapi_table *disp, void (GLAPIENTRYP fn)(GLshort, GLshort)) { - SET_by_offset(disp, _gloffset_WindowPos2sMESA, fn); -} - -typedef void (GLAPIENTRYP _glptr_WindowPos2svMESA)(const GLshort *); -#define CALL_WindowPos2svMESA(disp, parameters) \ - (* GET_WindowPos2svMESA(disp)) parameters -static inline _glptr_WindowPos2svMESA GET_WindowPos2svMESA(struct _glapi_table *disp) { - return (_glptr_WindowPos2svMESA) (GET_by_offset(disp, _gloffset_WindowPos2svMESA)); -} - -static inline void SET_WindowPos2svMESA(struct _glapi_table *disp, void (GLAPIENTRYP fn)(const GLshort *)) { - SET_by_offset(disp, _gloffset_WindowPos2svMESA, fn); -} - -typedef void (GLAPIENTRYP _glptr_WindowPos3dMESA)(GLdouble, GLdouble, GLdouble); -#define CALL_WindowPos3dMESA(disp, parameters) \ - (* GET_WindowPos3dMESA(disp)) parameters -static inline _glptr_WindowPos3dMESA GET_WindowPos3dMESA(struct _glapi_table *disp) { - return (_glptr_WindowPos3dMESA) (GET_by_offset(disp, _gloffset_WindowPos3dMESA)); -} - -static inline void SET_WindowPos3dMESA(struct _glapi_table *disp, void (GLAPIENTRYP fn)(GLdouble, GLdouble, GLdouble)) { - SET_by_offset(disp, _gloffset_WindowPos3dMESA, fn); -} - -typedef void (GLAPIENTRYP _glptr_WindowPos3dvMESA)(const GLdouble *); -#define CALL_WindowPos3dvMESA(disp, parameters) \ - (* GET_WindowPos3dvMESA(disp)) parameters -static inline _glptr_WindowPos3dvMESA GET_WindowPos3dvMESA(struct _glapi_table *disp) { - return (_glptr_WindowPos3dvMESA) (GET_by_offset(disp, _gloffset_WindowPos3dvMESA)); -} - -static inline void SET_WindowPos3dvMESA(struct _glapi_table *disp, void (GLAPIENTRYP fn)(const GLdouble *)) { - SET_by_offset(disp, _gloffset_WindowPos3dvMESA, fn); -} - -typedef void (GLAPIENTRYP _glptr_WindowPos3fMESA)(GLfloat, GLfloat, GLfloat); -#define CALL_WindowPos3fMESA(disp, parameters) \ - (* GET_WindowPos3fMESA(disp)) parameters -static inline _glptr_WindowPos3fMESA GET_WindowPos3fMESA(struct _glapi_table *disp) { - return (_glptr_WindowPos3fMESA) (GET_by_offset(disp, _gloffset_WindowPos3fMESA)); -} - -static inline void SET_WindowPos3fMESA(struct _glapi_table *disp, void (GLAPIENTRYP fn)(GLfloat, GLfloat, GLfloat)) { - SET_by_offset(disp, _gloffset_WindowPos3fMESA, fn); -} - -typedef void (GLAPIENTRYP _glptr_WindowPos3fvMESA)(const GLfloat *); -#define CALL_WindowPos3fvMESA(disp, parameters) \ - (* GET_WindowPos3fvMESA(disp)) parameters -static inline _glptr_WindowPos3fvMESA GET_WindowPos3fvMESA(struct _glapi_table *disp) { - return (_glptr_WindowPos3fvMESA) (GET_by_offset(disp, _gloffset_WindowPos3fvMESA)); -} - -static inline void SET_WindowPos3fvMESA(struct _glapi_table *disp, void (GLAPIENTRYP fn)(const GLfloat *)) { - SET_by_offset(disp, _gloffset_WindowPos3fvMESA, fn); -} - -typedef void (GLAPIENTRYP _glptr_WindowPos3iMESA)(GLint, GLint, GLint); -#define CALL_WindowPos3iMESA(disp, parameters) \ - (* GET_WindowPos3iMESA(disp)) parameters -static inline _glptr_WindowPos3iMESA GET_WindowPos3iMESA(struct _glapi_table *disp) { - return (_glptr_WindowPos3iMESA) (GET_by_offset(disp, _gloffset_WindowPos3iMESA)); -} - -static inline void SET_WindowPos3iMESA(struct _glapi_table *disp, void (GLAPIENTRYP fn)(GLint, GLint, GLint)) { - SET_by_offset(disp, _gloffset_WindowPos3iMESA, fn); -} - -typedef void (GLAPIENTRYP _glptr_WindowPos3ivMESA)(const GLint *); -#define CALL_WindowPos3ivMESA(disp, parameters) \ - (* GET_WindowPos3ivMESA(disp)) parameters -static inline _glptr_WindowPos3ivMESA GET_WindowPos3ivMESA(struct _glapi_table *disp) { - return (_glptr_WindowPos3ivMESA) (GET_by_offset(disp, _gloffset_WindowPos3ivMESA)); -} - -static inline void SET_WindowPos3ivMESA(struct _glapi_table *disp, void (GLAPIENTRYP fn)(const GLint *)) { - SET_by_offset(disp, _gloffset_WindowPos3ivMESA, fn); -} - -typedef void (GLAPIENTRYP _glptr_WindowPos3sMESA)(GLshort, GLshort, GLshort); -#define CALL_WindowPos3sMESA(disp, parameters) \ - (* GET_WindowPos3sMESA(disp)) parameters -static inline _glptr_WindowPos3sMESA GET_WindowPos3sMESA(struct _glapi_table *disp) { - return (_glptr_WindowPos3sMESA) (GET_by_offset(disp, _gloffset_WindowPos3sMESA)); -} - -static inline void SET_WindowPos3sMESA(struct _glapi_table *disp, void (GLAPIENTRYP fn)(GLshort, GLshort, GLshort)) { - SET_by_offset(disp, _gloffset_WindowPos3sMESA, fn); -} - -typedef void (GLAPIENTRYP _glptr_WindowPos3svMESA)(const GLshort *); -#define CALL_WindowPos3svMESA(disp, parameters) \ - (* GET_WindowPos3svMESA(disp)) parameters -static inline _glptr_WindowPos3svMESA GET_WindowPos3svMESA(struct _glapi_table *disp) { - return (_glptr_WindowPos3svMESA) (GET_by_offset(disp, _gloffset_WindowPos3svMESA)); -} - -static inline void SET_WindowPos3svMESA(struct _glapi_table *disp, void (GLAPIENTRYP fn)(const GLshort *)) { - SET_by_offset(disp, _gloffset_WindowPos3svMESA, fn); -} - -typedef void (GLAPIENTRYP _glptr_WindowPos4dMESA)(GLdouble, GLdouble, GLdouble, GLdouble); -#define CALL_WindowPos4dMESA(disp, parameters) \ - (* GET_WindowPos4dMESA(disp)) parameters -static inline _glptr_WindowPos4dMESA GET_WindowPos4dMESA(struct _glapi_table *disp) { - return (_glptr_WindowPos4dMESA) (GET_by_offset(disp, _gloffset_WindowPos4dMESA)); -} - -static inline void SET_WindowPos4dMESA(struct _glapi_table *disp, void (GLAPIENTRYP fn)(GLdouble, GLdouble, GLdouble, GLdouble)) { - SET_by_offset(disp, _gloffset_WindowPos4dMESA, fn); -} - -typedef void (GLAPIENTRYP _glptr_WindowPos4dvMESA)(const GLdouble *); -#define CALL_WindowPos4dvMESA(disp, parameters) \ - (* GET_WindowPos4dvMESA(disp)) parameters -static inline _glptr_WindowPos4dvMESA GET_WindowPos4dvMESA(struct _glapi_table *disp) { - return (_glptr_WindowPos4dvMESA) (GET_by_offset(disp, _gloffset_WindowPos4dvMESA)); -} - -static inline void SET_WindowPos4dvMESA(struct _glapi_table *disp, void (GLAPIENTRYP fn)(const GLdouble *)) { - SET_by_offset(disp, _gloffset_WindowPos4dvMESA, fn); -} - -typedef void (GLAPIENTRYP _glptr_WindowPos4fMESA)(GLfloat, GLfloat, GLfloat, GLfloat); -#define CALL_WindowPos4fMESA(disp, parameters) \ - (* GET_WindowPos4fMESA(disp)) parameters -static inline _glptr_WindowPos4fMESA GET_WindowPos4fMESA(struct _glapi_table *disp) { - return (_glptr_WindowPos4fMESA) (GET_by_offset(disp, _gloffset_WindowPos4fMESA)); -} - -static inline void SET_WindowPos4fMESA(struct _glapi_table *disp, void (GLAPIENTRYP fn)(GLfloat, GLfloat, GLfloat, GLfloat)) { - SET_by_offset(disp, _gloffset_WindowPos4fMESA, fn); -} - -typedef void (GLAPIENTRYP _glptr_WindowPos4fvMESA)(const GLfloat *); -#define CALL_WindowPos4fvMESA(disp, parameters) \ - (* GET_WindowPos4fvMESA(disp)) parameters -static inline _glptr_WindowPos4fvMESA GET_WindowPos4fvMESA(struct _glapi_table *disp) { - return (_glptr_WindowPos4fvMESA) (GET_by_offset(disp, _gloffset_WindowPos4fvMESA)); -} - -static inline void SET_WindowPos4fvMESA(struct _glapi_table *disp, void (GLAPIENTRYP fn)(const GLfloat *)) { - SET_by_offset(disp, _gloffset_WindowPos4fvMESA, fn); -} - -typedef void (GLAPIENTRYP _glptr_WindowPos4iMESA)(GLint, GLint, GLint, GLint); -#define CALL_WindowPos4iMESA(disp, parameters) \ - (* GET_WindowPos4iMESA(disp)) parameters -static inline _glptr_WindowPos4iMESA GET_WindowPos4iMESA(struct _glapi_table *disp) { - return (_glptr_WindowPos4iMESA) (GET_by_offset(disp, _gloffset_WindowPos4iMESA)); -} - -static inline void SET_WindowPos4iMESA(struct _glapi_table *disp, void (GLAPIENTRYP fn)(GLint, GLint, GLint, GLint)) { - SET_by_offset(disp, _gloffset_WindowPos4iMESA, fn); -} - -typedef void (GLAPIENTRYP _glptr_WindowPos4ivMESA)(const GLint *); -#define CALL_WindowPos4ivMESA(disp, parameters) \ - (* GET_WindowPos4ivMESA(disp)) parameters -static inline _glptr_WindowPos4ivMESA GET_WindowPos4ivMESA(struct _glapi_table *disp) { - return (_glptr_WindowPos4ivMESA) (GET_by_offset(disp, _gloffset_WindowPos4ivMESA)); -} - -static inline void SET_WindowPos4ivMESA(struct _glapi_table *disp, void (GLAPIENTRYP fn)(const GLint *)) { - SET_by_offset(disp, _gloffset_WindowPos4ivMESA, fn); -} - -typedef void (GLAPIENTRYP _glptr_WindowPos4sMESA)(GLshort, GLshort, GLshort, GLshort); -#define CALL_WindowPos4sMESA(disp, parameters) \ - (* GET_WindowPos4sMESA(disp)) parameters -static inline _glptr_WindowPos4sMESA GET_WindowPos4sMESA(struct _glapi_table *disp) { - return (_glptr_WindowPos4sMESA) (GET_by_offset(disp, _gloffset_WindowPos4sMESA)); -} - -static inline void SET_WindowPos4sMESA(struct _glapi_table *disp, void (GLAPIENTRYP fn)(GLshort, GLshort, GLshort, GLshort)) { - SET_by_offset(disp, _gloffset_WindowPos4sMESA, fn); -} - -typedef void (GLAPIENTRYP _glptr_WindowPos4svMESA)(const GLshort *); -#define CALL_WindowPos4svMESA(disp, parameters) \ - (* GET_WindowPos4svMESA(disp)) parameters -static inline _glptr_WindowPos4svMESA GET_WindowPos4svMESA(struct _glapi_table *disp) { - return (_glptr_WindowPos4svMESA) (GET_by_offset(disp, _gloffset_WindowPos4svMESA)); -} - -static inline void SET_WindowPos4svMESA(struct _glapi_table *disp, void (GLAPIENTRYP fn)(const GLshort *)) { - SET_by_offset(disp, _gloffset_WindowPos4svMESA, fn); -} - -typedef void (GLAPIENTRYP _glptr_MultiModeDrawArraysIBM)(const GLenum *, const GLint *, const GLsizei *, GLsizei, GLint); -#define CALL_MultiModeDrawArraysIBM(disp, parameters) \ - (* GET_MultiModeDrawArraysIBM(disp)) parameters -static inline _glptr_MultiModeDrawArraysIBM GET_MultiModeDrawArraysIBM(struct _glapi_table *disp) { - return (_glptr_MultiModeDrawArraysIBM) (GET_by_offset(disp, _gloffset_MultiModeDrawArraysIBM)); -} - -static inline void SET_MultiModeDrawArraysIBM(struct _glapi_table *disp, void (GLAPIENTRYP fn)(const GLenum *, const GLint *, const GLsizei *, GLsizei, GLint)) { - SET_by_offset(disp, _gloffset_MultiModeDrawArraysIBM, fn); -} - -typedef void (GLAPIENTRYP _glptr_MultiModeDrawElementsIBM)(const GLenum *, const GLsizei *, GLenum, const GLvoid * const *, GLsizei, GLint); -#define CALL_MultiModeDrawElementsIBM(disp, parameters) \ - (* GET_MultiModeDrawElementsIBM(disp)) parameters -static inline _glptr_MultiModeDrawElementsIBM GET_MultiModeDrawElementsIBM(struct _glapi_table *disp) { - return (_glptr_MultiModeDrawElementsIBM) (GET_by_offset(disp, _gloffset_MultiModeDrawElementsIBM)); -} - -static inline void SET_MultiModeDrawElementsIBM(struct _glapi_table *disp, void (GLAPIENTRYP fn)(const GLenum *, const GLsizei *, GLenum, const GLvoid * const *, GLsizei, GLint)) { - SET_by_offset(disp, _gloffset_MultiModeDrawElementsIBM, fn); -} - -typedef void (GLAPIENTRYP _glptr_DeleteFencesNV)(GLsizei, const GLuint *); -#define CALL_DeleteFencesNV(disp, parameters) \ - (* GET_DeleteFencesNV(disp)) parameters -static inline _glptr_DeleteFencesNV GET_DeleteFencesNV(struct _glapi_table *disp) { - return (_glptr_DeleteFencesNV) (GET_by_offset(disp, _gloffset_DeleteFencesNV)); -} - -static inline void SET_DeleteFencesNV(struct _glapi_table *disp, void (GLAPIENTRYP fn)(GLsizei, const GLuint *)) { - SET_by_offset(disp, _gloffset_DeleteFencesNV, fn); -} - -typedef void (GLAPIENTRYP _glptr_FinishFenceNV)(GLuint); -#define CALL_FinishFenceNV(disp, parameters) \ - (* GET_FinishFenceNV(disp)) parameters -static inline _glptr_FinishFenceNV GET_FinishFenceNV(struct _glapi_table *disp) { - return (_glptr_FinishFenceNV) (GET_by_offset(disp, _gloffset_FinishFenceNV)); -} - -static inline void SET_FinishFenceNV(struct _glapi_table *disp, void (GLAPIENTRYP fn)(GLuint)) { - SET_by_offset(disp, _gloffset_FinishFenceNV, fn); -} - -typedef void (GLAPIENTRYP _glptr_GenFencesNV)(GLsizei, GLuint *); -#define CALL_GenFencesNV(disp, parameters) \ - (* GET_GenFencesNV(disp)) parameters -static inline _glptr_GenFencesNV GET_GenFencesNV(struct _glapi_table *disp) { - return (_glptr_GenFencesNV) (GET_by_offset(disp, _gloffset_GenFencesNV)); -} - -static inline void SET_GenFencesNV(struct _glapi_table *disp, void (GLAPIENTRYP fn)(GLsizei, GLuint *)) { - SET_by_offset(disp, _gloffset_GenFencesNV, fn); -} - -typedef void (GLAPIENTRYP _glptr_GetFenceivNV)(GLuint, GLenum, GLint *); -#define CALL_GetFenceivNV(disp, parameters) \ - (* GET_GetFenceivNV(disp)) parameters -static inline _glptr_GetFenceivNV GET_GetFenceivNV(struct _glapi_table *disp) { - return (_glptr_GetFenceivNV) (GET_by_offset(disp, _gloffset_GetFenceivNV)); -} - -static inline void SET_GetFenceivNV(struct _glapi_table *disp, void (GLAPIENTRYP fn)(GLuint, GLenum, GLint *)) { - SET_by_offset(disp, _gloffset_GetFenceivNV, fn); -} - -typedef GLboolean (GLAPIENTRYP _glptr_IsFenceNV)(GLuint); -#define CALL_IsFenceNV(disp, parameters) \ - (* GET_IsFenceNV(disp)) parameters -static inline _glptr_IsFenceNV GET_IsFenceNV(struct _glapi_table *disp) { - return (_glptr_IsFenceNV) (GET_by_offset(disp, _gloffset_IsFenceNV)); -} - -static inline void SET_IsFenceNV(struct _glapi_table *disp, GLboolean (GLAPIENTRYP fn)(GLuint)) { - SET_by_offset(disp, _gloffset_IsFenceNV, fn); -} - -typedef void (GLAPIENTRYP _glptr_SetFenceNV)(GLuint, GLenum); -#define CALL_SetFenceNV(disp, parameters) \ - (* GET_SetFenceNV(disp)) parameters -static inline _glptr_SetFenceNV GET_SetFenceNV(struct _glapi_table *disp) { - return (_glptr_SetFenceNV) (GET_by_offset(disp, _gloffset_SetFenceNV)); -} - -static inline void SET_SetFenceNV(struct _glapi_table *disp, void (GLAPIENTRYP fn)(GLuint, GLenum)) { - SET_by_offset(disp, _gloffset_SetFenceNV, fn); -} - -typedef GLboolean (GLAPIENTRYP _glptr_TestFenceNV)(GLuint); -#define CALL_TestFenceNV(disp, parameters) \ - (* GET_TestFenceNV(disp)) parameters -static inline _glptr_TestFenceNV GET_TestFenceNV(struct _glapi_table *disp) { - return (_glptr_TestFenceNV) (GET_by_offset(disp, _gloffset_TestFenceNV)); -} - -static inline void SET_TestFenceNV(struct _glapi_table *disp, GLboolean (GLAPIENTRYP fn)(GLuint)) { - SET_by_offset(disp, _gloffset_TestFenceNV, fn); -} - -typedef void (GLAPIENTRYP _glptr_VertexAttrib1dNV)(GLuint, GLdouble); -#define CALL_VertexAttrib1dNV(disp, parameters) \ - (* GET_VertexAttrib1dNV(disp)) parameters -static inline _glptr_VertexAttrib1dNV GET_VertexAttrib1dNV(struct _glapi_table *disp) { - return (_glptr_VertexAttrib1dNV) (GET_by_offset(disp, _gloffset_VertexAttrib1dNV)); -} - -static inline void SET_VertexAttrib1dNV(struct _glapi_table *disp, void (GLAPIENTRYP fn)(GLuint, GLdouble)) { - SET_by_offset(disp, _gloffset_VertexAttrib1dNV, fn); -} - -typedef void (GLAPIENTRYP _glptr_VertexAttrib1dvNV)(GLuint, const GLdouble *); -#define CALL_VertexAttrib1dvNV(disp, parameters) \ - (* GET_VertexAttrib1dvNV(disp)) parameters -static inline _glptr_VertexAttrib1dvNV GET_VertexAttrib1dvNV(struct _glapi_table *disp) { - return (_glptr_VertexAttrib1dvNV) (GET_by_offset(disp, _gloffset_VertexAttrib1dvNV)); -} - -static inline void SET_VertexAttrib1dvNV(struct _glapi_table *disp, void (GLAPIENTRYP fn)(GLuint, const GLdouble *)) { - SET_by_offset(disp, _gloffset_VertexAttrib1dvNV, fn); -} - -typedef void (GLAPIENTRYP _glptr_VertexAttrib1fNV)(GLuint, GLfloat); -#define CALL_VertexAttrib1fNV(disp, parameters) \ - (* GET_VertexAttrib1fNV(disp)) parameters -static inline _glptr_VertexAttrib1fNV GET_VertexAttrib1fNV(struct _glapi_table *disp) { - return (_glptr_VertexAttrib1fNV) (GET_by_offset(disp, _gloffset_VertexAttrib1fNV)); -} - -static inline void SET_VertexAttrib1fNV(struct _glapi_table *disp, void (GLAPIENTRYP fn)(GLuint, GLfloat)) { - SET_by_offset(disp, _gloffset_VertexAttrib1fNV, fn); -} - -typedef void (GLAPIENTRYP _glptr_VertexAttrib1fvNV)(GLuint, const GLfloat *); -#define CALL_VertexAttrib1fvNV(disp, parameters) \ - (* GET_VertexAttrib1fvNV(disp)) parameters -static inline _glptr_VertexAttrib1fvNV GET_VertexAttrib1fvNV(struct _glapi_table *disp) { - return (_glptr_VertexAttrib1fvNV) (GET_by_offset(disp, _gloffset_VertexAttrib1fvNV)); -} - -static inline void SET_VertexAttrib1fvNV(struct _glapi_table *disp, void (GLAPIENTRYP fn)(GLuint, const GLfloat *)) { - SET_by_offset(disp, _gloffset_VertexAttrib1fvNV, fn); -} - -typedef void (GLAPIENTRYP _glptr_VertexAttrib1sNV)(GLuint, GLshort); -#define CALL_VertexAttrib1sNV(disp, parameters) \ - (* GET_VertexAttrib1sNV(disp)) parameters -static inline _glptr_VertexAttrib1sNV GET_VertexAttrib1sNV(struct _glapi_table *disp) { - return (_glptr_VertexAttrib1sNV) (GET_by_offset(disp, _gloffset_VertexAttrib1sNV)); -} - -static inline void SET_VertexAttrib1sNV(struct _glapi_table *disp, void (GLAPIENTRYP fn)(GLuint, GLshort)) { - SET_by_offset(disp, _gloffset_VertexAttrib1sNV, fn); -} - -typedef void (GLAPIENTRYP _glptr_VertexAttrib1svNV)(GLuint, const GLshort *); -#define CALL_VertexAttrib1svNV(disp, parameters) \ - (* GET_VertexAttrib1svNV(disp)) parameters -static inline _glptr_VertexAttrib1svNV GET_VertexAttrib1svNV(struct _glapi_table *disp) { - return (_glptr_VertexAttrib1svNV) (GET_by_offset(disp, _gloffset_VertexAttrib1svNV)); -} - -static inline void SET_VertexAttrib1svNV(struct _glapi_table *disp, void (GLAPIENTRYP fn)(GLuint, const GLshort *)) { - SET_by_offset(disp, _gloffset_VertexAttrib1svNV, fn); -} - -typedef void (GLAPIENTRYP _glptr_VertexAttrib2dNV)(GLuint, GLdouble, GLdouble); -#define CALL_VertexAttrib2dNV(disp, parameters) \ - (* GET_VertexAttrib2dNV(disp)) parameters -static inline _glptr_VertexAttrib2dNV GET_VertexAttrib2dNV(struct _glapi_table *disp) { - return (_glptr_VertexAttrib2dNV) (GET_by_offset(disp, _gloffset_VertexAttrib2dNV)); -} - -static inline void SET_VertexAttrib2dNV(struct _glapi_table *disp, void (GLAPIENTRYP fn)(GLuint, GLdouble, GLdouble)) { - SET_by_offset(disp, _gloffset_VertexAttrib2dNV, fn); -} - -typedef void (GLAPIENTRYP _glptr_VertexAttrib2dvNV)(GLuint, const GLdouble *); -#define CALL_VertexAttrib2dvNV(disp, parameters) \ - (* GET_VertexAttrib2dvNV(disp)) parameters -static inline _glptr_VertexAttrib2dvNV GET_VertexAttrib2dvNV(struct _glapi_table *disp) { - return (_glptr_VertexAttrib2dvNV) (GET_by_offset(disp, _gloffset_VertexAttrib2dvNV)); -} - -static inline void SET_VertexAttrib2dvNV(struct _glapi_table *disp, void (GLAPIENTRYP fn)(GLuint, const GLdouble *)) { - SET_by_offset(disp, _gloffset_VertexAttrib2dvNV, fn); -} - -typedef void (GLAPIENTRYP _glptr_VertexAttrib2fNV)(GLuint, GLfloat, GLfloat); -#define CALL_VertexAttrib2fNV(disp, parameters) \ - (* GET_VertexAttrib2fNV(disp)) parameters -static inline _glptr_VertexAttrib2fNV GET_VertexAttrib2fNV(struct _glapi_table *disp) { - return (_glptr_VertexAttrib2fNV) (GET_by_offset(disp, _gloffset_VertexAttrib2fNV)); -} - -static inline void SET_VertexAttrib2fNV(struct _glapi_table *disp, void (GLAPIENTRYP fn)(GLuint, GLfloat, GLfloat)) { - SET_by_offset(disp, _gloffset_VertexAttrib2fNV, fn); -} - -typedef void (GLAPIENTRYP _glptr_VertexAttrib2fvNV)(GLuint, const GLfloat *); -#define CALL_VertexAttrib2fvNV(disp, parameters) \ - (* GET_VertexAttrib2fvNV(disp)) parameters -static inline _glptr_VertexAttrib2fvNV GET_VertexAttrib2fvNV(struct _glapi_table *disp) { - return (_glptr_VertexAttrib2fvNV) (GET_by_offset(disp, _gloffset_VertexAttrib2fvNV)); -} - -static inline void SET_VertexAttrib2fvNV(struct _glapi_table *disp, void (GLAPIENTRYP fn)(GLuint, const GLfloat *)) { - SET_by_offset(disp, _gloffset_VertexAttrib2fvNV, fn); -} - -typedef void (GLAPIENTRYP _glptr_VertexAttrib2sNV)(GLuint, GLshort, GLshort); -#define CALL_VertexAttrib2sNV(disp, parameters) \ - (* GET_VertexAttrib2sNV(disp)) parameters -static inline _glptr_VertexAttrib2sNV GET_VertexAttrib2sNV(struct _glapi_table *disp) { - return (_glptr_VertexAttrib2sNV) (GET_by_offset(disp, _gloffset_VertexAttrib2sNV)); -} - -static inline void SET_VertexAttrib2sNV(struct _glapi_table *disp, void (GLAPIENTRYP fn)(GLuint, GLshort, GLshort)) { - SET_by_offset(disp, _gloffset_VertexAttrib2sNV, fn); -} - -typedef void (GLAPIENTRYP _glptr_VertexAttrib2svNV)(GLuint, const GLshort *); -#define CALL_VertexAttrib2svNV(disp, parameters) \ - (* GET_VertexAttrib2svNV(disp)) parameters -static inline _glptr_VertexAttrib2svNV GET_VertexAttrib2svNV(struct _glapi_table *disp) { - return (_glptr_VertexAttrib2svNV) (GET_by_offset(disp, _gloffset_VertexAttrib2svNV)); -} - -static inline void SET_VertexAttrib2svNV(struct _glapi_table *disp, void (GLAPIENTRYP fn)(GLuint, const GLshort *)) { - SET_by_offset(disp, _gloffset_VertexAttrib2svNV, fn); -} - -typedef void (GLAPIENTRYP _glptr_VertexAttrib3dNV)(GLuint, GLdouble, GLdouble, GLdouble); -#define CALL_VertexAttrib3dNV(disp, parameters) \ - (* GET_VertexAttrib3dNV(disp)) parameters -static inline _glptr_VertexAttrib3dNV GET_VertexAttrib3dNV(struct _glapi_table *disp) { - return (_glptr_VertexAttrib3dNV) (GET_by_offset(disp, _gloffset_VertexAttrib3dNV)); -} - -static inline void SET_VertexAttrib3dNV(struct _glapi_table *disp, void (GLAPIENTRYP fn)(GLuint, GLdouble, GLdouble, GLdouble)) { - SET_by_offset(disp, _gloffset_VertexAttrib3dNV, fn); -} - -typedef void (GLAPIENTRYP _glptr_VertexAttrib3dvNV)(GLuint, const GLdouble *); -#define CALL_VertexAttrib3dvNV(disp, parameters) \ - (* GET_VertexAttrib3dvNV(disp)) parameters -static inline _glptr_VertexAttrib3dvNV GET_VertexAttrib3dvNV(struct _glapi_table *disp) { - return (_glptr_VertexAttrib3dvNV) (GET_by_offset(disp, _gloffset_VertexAttrib3dvNV)); -} - -static inline void SET_VertexAttrib3dvNV(struct _glapi_table *disp, void (GLAPIENTRYP fn)(GLuint, const GLdouble *)) { - SET_by_offset(disp, _gloffset_VertexAttrib3dvNV, fn); -} - -typedef void (GLAPIENTRYP _glptr_VertexAttrib3fNV)(GLuint, GLfloat, GLfloat, GLfloat); -#define CALL_VertexAttrib3fNV(disp, parameters) \ - (* GET_VertexAttrib3fNV(disp)) parameters -static inline _glptr_VertexAttrib3fNV GET_VertexAttrib3fNV(struct _glapi_table *disp) { - return (_glptr_VertexAttrib3fNV) (GET_by_offset(disp, _gloffset_VertexAttrib3fNV)); -} - -static inline void SET_VertexAttrib3fNV(struct _glapi_table *disp, void (GLAPIENTRYP fn)(GLuint, GLfloat, GLfloat, GLfloat)) { - SET_by_offset(disp, _gloffset_VertexAttrib3fNV, fn); -} - -typedef void (GLAPIENTRYP _glptr_VertexAttrib3fvNV)(GLuint, const GLfloat *); -#define CALL_VertexAttrib3fvNV(disp, parameters) \ - (* GET_VertexAttrib3fvNV(disp)) parameters -static inline _glptr_VertexAttrib3fvNV GET_VertexAttrib3fvNV(struct _glapi_table *disp) { - return (_glptr_VertexAttrib3fvNV) (GET_by_offset(disp, _gloffset_VertexAttrib3fvNV)); -} - -static inline void SET_VertexAttrib3fvNV(struct _glapi_table *disp, void (GLAPIENTRYP fn)(GLuint, const GLfloat *)) { - SET_by_offset(disp, _gloffset_VertexAttrib3fvNV, fn); -} - -typedef void (GLAPIENTRYP _glptr_VertexAttrib3sNV)(GLuint, GLshort, GLshort, GLshort); -#define CALL_VertexAttrib3sNV(disp, parameters) \ - (* GET_VertexAttrib3sNV(disp)) parameters -static inline _glptr_VertexAttrib3sNV GET_VertexAttrib3sNV(struct _glapi_table *disp) { - return (_glptr_VertexAttrib3sNV) (GET_by_offset(disp, _gloffset_VertexAttrib3sNV)); -} - -static inline void SET_VertexAttrib3sNV(struct _glapi_table *disp, void (GLAPIENTRYP fn)(GLuint, GLshort, GLshort, GLshort)) { - SET_by_offset(disp, _gloffset_VertexAttrib3sNV, fn); -} - -typedef void (GLAPIENTRYP _glptr_VertexAttrib3svNV)(GLuint, const GLshort *); -#define CALL_VertexAttrib3svNV(disp, parameters) \ - (* GET_VertexAttrib3svNV(disp)) parameters -static inline _glptr_VertexAttrib3svNV GET_VertexAttrib3svNV(struct _glapi_table *disp) { - return (_glptr_VertexAttrib3svNV) (GET_by_offset(disp, _gloffset_VertexAttrib3svNV)); -} - -static inline void SET_VertexAttrib3svNV(struct _glapi_table *disp, void (GLAPIENTRYP fn)(GLuint, const GLshort *)) { - SET_by_offset(disp, _gloffset_VertexAttrib3svNV, fn); -} - -typedef void (GLAPIENTRYP _glptr_VertexAttrib4dNV)(GLuint, GLdouble, GLdouble, GLdouble, GLdouble); -#define CALL_VertexAttrib4dNV(disp, parameters) \ - (* GET_VertexAttrib4dNV(disp)) parameters -static inline _glptr_VertexAttrib4dNV GET_VertexAttrib4dNV(struct _glapi_table *disp) { - return (_glptr_VertexAttrib4dNV) (GET_by_offset(disp, _gloffset_VertexAttrib4dNV)); -} - -static inline void SET_VertexAttrib4dNV(struct _glapi_table *disp, void (GLAPIENTRYP fn)(GLuint, GLdouble, GLdouble, GLdouble, GLdouble)) { - SET_by_offset(disp, _gloffset_VertexAttrib4dNV, fn); -} - -typedef void (GLAPIENTRYP _glptr_VertexAttrib4dvNV)(GLuint, const GLdouble *); -#define CALL_VertexAttrib4dvNV(disp, parameters) \ - (* GET_VertexAttrib4dvNV(disp)) parameters -static inline _glptr_VertexAttrib4dvNV GET_VertexAttrib4dvNV(struct _glapi_table *disp) { - return (_glptr_VertexAttrib4dvNV) (GET_by_offset(disp, _gloffset_VertexAttrib4dvNV)); -} - -static inline void SET_VertexAttrib4dvNV(struct _glapi_table *disp, void (GLAPIENTRYP fn)(GLuint, const GLdouble *)) { - SET_by_offset(disp, _gloffset_VertexAttrib4dvNV, fn); -} - -typedef void (GLAPIENTRYP _glptr_VertexAttrib4fNV)(GLuint, GLfloat, GLfloat, GLfloat, GLfloat); -#define CALL_VertexAttrib4fNV(disp, parameters) \ - (* GET_VertexAttrib4fNV(disp)) parameters -static inline _glptr_VertexAttrib4fNV GET_VertexAttrib4fNV(struct _glapi_table *disp) { - return (_glptr_VertexAttrib4fNV) (GET_by_offset(disp, _gloffset_VertexAttrib4fNV)); -} - -static inline void SET_VertexAttrib4fNV(struct _glapi_table *disp, void (GLAPIENTRYP fn)(GLuint, GLfloat, GLfloat, GLfloat, GLfloat)) { - SET_by_offset(disp, _gloffset_VertexAttrib4fNV, fn); -} - -typedef void (GLAPIENTRYP _glptr_VertexAttrib4fvNV)(GLuint, const GLfloat *); -#define CALL_VertexAttrib4fvNV(disp, parameters) \ - (* GET_VertexAttrib4fvNV(disp)) parameters -static inline _glptr_VertexAttrib4fvNV GET_VertexAttrib4fvNV(struct _glapi_table *disp) { - return (_glptr_VertexAttrib4fvNV) (GET_by_offset(disp, _gloffset_VertexAttrib4fvNV)); -} - -static inline void SET_VertexAttrib4fvNV(struct _glapi_table *disp, void (GLAPIENTRYP fn)(GLuint, const GLfloat *)) { - SET_by_offset(disp, _gloffset_VertexAttrib4fvNV, fn); -} - -typedef void (GLAPIENTRYP _glptr_VertexAttrib4sNV)(GLuint, GLshort, GLshort, GLshort, GLshort); -#define CALL_VertexAttrib4sNV(disp, parameters) \ - (* GET_VertexAttrib4sNV(disp)) parameters -static inline _glptr_VertexAttrib4sNV GET_VertexAttrib4sNV(struct _glapi_table *disp) { - return (_glptr_VertexAttrib4sNV) (GET_by_offset(disp, _gloffset_VertexAttrib4sNV)); -} - -static inline void SET_VertexAttrib4sNV(struct _glapi_table *disp, void (GLAPIENTRYP fn)(GLuint, GLshort, GLshort, GLshort, GLshort)) { - SET_by_offset(disp, _gloffset_VertexAttrib4sNV, fn); -} - -typedef void (GLAPIENTRYP _glptr_VertexAttrib4svNV)(GLuint, const GLshort *); -#define CALL_VertexAttrib4svNV(disp, parameters) \ - (* GET_VertexAttrib4svNV(disp)) parameters -static inline _glptr_VertexAttrib4svNV GET_VertexAttrib4svNV(struct _glapi_table *disp) { - return (_glptr_VertexAttrib4svNV) (GET_by_offset(disp, _gloffset_VertexAttrib4svNV)); -} - -static inline void SET_VertexAttrib4svNV(struct _glapi_table *disp, void (GLAPIENTRYP fn)(GLuint, const GLshort *)) { - SET_by_offset(disp, _gloffset_VertexAttrib4svNV, fn); -} - -typedef void (GLAPIENTRYP _glptr_VertexAttrib4ubNV)(GLuint, GLubyte, GLubyte, GLubyte, GLubyte); -#define CALL_VertexAttrib4ubNV(disp, parameters) \ - (* GET_VertexAttrib4ubNV(disp)) parameters -static inline _glptr_VertexAttrib4ubNV GET_VertexAttrib4ubNV(struct _glapi_table *disp) { - return (_glptr_VertexAttrib4ubNV) (GET_by_offset(disp, _gloffset_VertexAttrib4ubNV)); -} - -static inline void SET_VertexAttrib4ubNV(struct _glapi_table *disp, void (GLAPIENTRYP fn)(GLuint, GLubyte, GLubyte, GLubyte, GLubyte)) { - SET_by_offset(disp, _gloffset_VertexAttrib4ubNV, fn); -} - -typedef void (GLAPIENTRYP _glptr_VertexAttrib4ubvNV)(GLuint, const GLubyte *); -#define CALL_VertexAttrib4ubvNV(disp, parameters) \ - (* GET_VertexAttrib4ubvNV(disp)) parameters -static inline _glptr_VertexAttrib4ubvNV GET_VertexAttrib4ubvNV(struct _glapi_table *disp) { - return (_glptr_VertexAttrib4ubvNV) (GET_by_offset(disp, _gloffset_VertexAttrib4ubvNV)); -} - -static inline void SET_VertexAttrib4ubvNV(struct _glapi_table *disp, void (GLAPIENTRYP fn)(GLuint, const GLubyte *)) { - SET_by_offset(disp, _gloffset_VertexAttrib4ubvNV, fn); -} - -typedef void (GLAPIENTRYP _glptr_PointParameteriNV)(GLenum, GLint); -#define CALL_PointParameteriNV(disp, parameters) \ - (* GET_PointParameteriNV(disp)) parameters -static inline _glptr_PointParameteriNV GET_PointParameteriNV(struct _glapi_table *disp) { - return (_glptr_PointParameteriNV) (GET_by_offset(disp, _gloffset_PointParameteriNV)); -} - -static inline void SET_PointParameteriNV(struct _glapi_table *disp, void (GLAPIENTRYP fn)(GLenum, GLint)) { - SET_by_offset(disp, _gloffset_PointParameteriNV, fn); -} - -typedef void (GLAPIENTRYP _glptr_PointParameterivNV)(GLenum, const GLint *); -#define CALL_PointParameterivNV(disp, parameters) \ - (* GET_PointParameterivNV(disp)) parameters -static inline _glptr_PointParameterivNV GET_PointParameterivNV(struct _glapi_table *disp) { - return (_glptr_PointParameterivNV) (GET_by_offset(disp, _gloffset_PointParameterivNV)); -} - -static inline void SET_PointParameterivNV(struct _glapi_table *disp, void (GLAPIENTRYP fn)(GLenum, const GLint *)) { - SET_by_offset(disp, _gloffset_PointParameterivNV, fn); -} - -typedef void (GLAPIENTRYP _glptr_ActiveStencilFaceEXT)(GLenum); -#define CALL_ActiveStencilFaceEXT(disp, parameters) \ - (* GET_ActiveStencilFaceEXT(disp)) parameters -static inline _glptr_ActiveStencilFaceEXT GET_ActiveStencilFaceEXT(struct _glapi_table *disp) { - return (_glptr_ActiveStencilFaceEXT) (GET_by_offset(disp, _gloffset_ActiveStencilFaceEXT)); -} - -static inline void SET_ActiveStencilFaceEXT(struct _glapi_table *disp, void (GLAPIENTRYP fn)(GLenum)) { - SET_by_offset(disp, _gloffset_ActiveStencilFaceEXT, fn); -} - -typedef void (GLAPIENTRYP _glptr_DepthBoundsEXT)(GLclampd, GLclampd); -#define CALL_DepthBoundsEXT(disp, parameters) \ - (* GET_DepthBoundsEXT(disp)) parameters -static inline _glptr_DepthBoundsEXT GET_DepthBoundsEXT(struct _glapi_table *disp) { - return (_glptr_DepthBoundsEXT) (GET_by_offset(disp, _gloffset_DepthBoundsEXT)); -} - -static inline void SET_DepthBoundsEXT(struct _glapi_table *disp, void (GLAPIENTRYP fn)(GLclampd, GLclampd)) { - SET_by_offset(disp, _gloffset_DepthBoundsEXT, fn); -} - -typedef void (GLAPIENTRYP _glptr_BufferParameteriAPPLE)(GLenum, GLenum, GLint); -#define CALL_BufferParameteriAPPLE(disp, parameters) \ - (* GET_BufferParameteriAPPLE(disp)) parameters -static inline _glptr_BufferParameteriAPPLE GET_BufferParameteriAPPLE(struct _glapi_table *disp) { - return (_glptr_BufferParameteriAPPLE) (GET_by_offset(disp, _gloffset_BufferParameteriAPPLE)); -} - -static inline void SET_BufferParameteriAPPLE(struct _glapi_table *disp, void (GLAPIENTRYP fn)(GLenum, GLenum, GLint)) { - SET_by_offset(disp, _gloffset_BufferParameteriAPPLE, fn); -} - -typedef void (GLAPIENTRYP _glptr_FlushMappedBufferRangeAPPLE)(GLenum, GLintptr, GLsizeiptr); -#define CALL_FlushMappedBufferRangeAPPLE(disp, parameters) \ - (* GET_FlushMappedBufferRangeAPPLE(disp)) parameters -static inline _glptr_FlushMappedBufferRangeAPPLE GET_FlushMappedBufferRangeAPPLE(struct _glapi_table *disp) { - return (_glptr_FlushMappedBufferRangeAPPLE) (GET_by_offset(disp, _gloffset_FlushMappedBufferRangeAPPLE)); -} - -static inline void SET_FlushMappedBufferRangeAPPLE(struct _glapi_table *disp, void (GLAPIENTRYP fn)(GLenum, GLintptr, GLsizeiptr)) { - SET_by_offset(disp, _gloffset_FlushMappedBufferRangeAPPLE, fn); -} - -typedef void (GLAPIENTRYP _glptr_BindFragDataLocationEXT)(GLuint, GLuint, const GLchar *); -#define CALL_BindFragDataLocationEXT(disp, parameters) \ - (* GET_BindFragDataLocationEXT(disp)) parameters -static inline _glptr_BindFragDataLocationEXT GET_BindFragDataLocationEXT(struct _glapi_table *disp) { - return (_glptr_BindFragDataLocationEXT) (GET_by_offset(disp, _gloffset_BindFragDataLocationEXT)); -} - -static inline void SET_BindFragDataLocationEXT(struct _glapi_table *disp, void (GLAPIENTRYP fn)(GLuint, GLuint, const GLchar *)) { - SET_by_offset(disp, _gloffset_BindFragDataLocationEXT, fn); -} - -typedef GLint (GLAPIENTRYP _glptr_GetFragDataLocationEXT)(GLuint, const GLchar *); -#define CALL_GetFragDataLocationEXT(disp, parameters) \ - (* GET_GetFragDataLocationEXT(disp)) parameters -static inline _glptr_GetFragDataLocationEXT GET_GetFragDataLocationEXT(struct _glapi_table *disp) { - return (_glptr_GetFragDataLocationEXT) (GET_by_offset(disp, _gloffset_GetFragDataLocationEXT)); -} - -static inline void SET_GetFragDataLocationEXT(struct _glapi_table *disp, GLint (GLAPIENTRYP fn)(GLuint, const GLchar *)) { - SET_by_offset(disp, _gloffset_GetFragDataLocationEXT, fn); -} - -typedef void (GLAPIENTRYP _glptr_ClearColorIiEXT)(GLint, GLint, GLint, GLint); -#define CALL_ClearColorIiEXT(disp, parameters) \ - (* GET_ClearColorIiEXT(disp)) parameters -static inline _glptr_ClearColorIiEXT GET_ClearColorIiEXT(struct _glapi_table *disp) { - return (_glptr_ClearColorIiEXT) (GET_by_offset(disp, _gloffset_ClearColorIiEXT)); -} - -static inline void SET_ClearColorIiEXT(struct _glapi_table *disp, void (GLAPIENTRYP fn)(GLint, GLint, GLint, GLint)) { - SET_by_offset(disp, _gloffset_ClearColorIiEXT, fn); -} - -typedef void (GLAPIENTRYP _glptr_ClearColorIuiEXT)(GLuint, GLuint, GLuint, GLuint); -#define CALL_ClearColorIuiEXT(disp, parameters) \ - (* GET_ClearColorIuiEXT(disp)) parameters -static inline _glptr_ClearColorIuiEXT GET_ClearColorIuiEXT(struct _glapi_table *disp) { - return (_glptr_ClearColorIuiEXT) (GET_by_offset(disp, _gloffset_ClearColorIuiEXT)); -} - -static inline void SET_ClearColorIuiEXT(struct _glapi_table *disp, void (GLAPIENTRYP fn)(GLuint, GLuint, GLuint, GLuint)) { - SET_by_offset(disp, _gloffset_ClearColorIuiEXT, fn); -} - -typedef void (GLAPIENTRYP _glptr_GetTexParameterIivEXT)(GLenum, GLenum, GLint *); -#define CALL_GetTexParameterIivEXT(disp, parameters) \ - (* GET_GetTexParameterIivEXT(disp)) parameters -static inline _glptr_GetTexParameterIivEXT GET_GetTexParameterIivEXT(struct _glapi_table *disp) { - return (_glptr_GetTexParameterIivEXT) (GET_by_offset(disp, _gloffset_GetTexParameterIivEXT)); -} - -static inline void SET_GetTexParameterIivEXT(struct _glapi_table *disp, void (GLAPIENTRYP fn)(GLenum, GLenum, GLint *)) { - SET_by_offset(disp, _gloffset_GetTexParameterIivEXT, fn); -} - -typedef void (GLAPIENTRYP _glptr_GetTexParameterIuivEXT)(GLenum, GLenum, GLuint *); -#define CALL_GetTexParameterIuivEXT(disp, parameters) \ - (* GET_GetTexParameterIuivEXT(disp)) parameters -static inline _glptr_GetTexParameterIuivEXT GET_GetTexParameterIuivEXT(struct _glapi_table *disp) { - return (_glptr_GetTexParameterIuivEXT) (GET_by_offset(disp, _gloffset_GetTexParameterIuivEXT)); -} - -static inline void SET_GetTexParameterIuivEXT(struct _glapi_table *disp, void (GLAPIENTRYP fn)(GLenum, GLenum, GLuint *)) { - SET_by_offset(disp, _gloffset_GetTexParameterIuivEXT, fn); -} - -typedef void (GLAPIENTRYP _glptr_TexParameterIivEXT)(GLenum, GLenum, const GLint *); -#define CALL_TexParameterIivEXT(disp, parameters) \ - (* GET_TexParameterIivEXT(disp)) parameters -static inline _glptr_TexParameterIivEXT GET_TexParameterIivEXT(struct _glapi_table *disp) { - return (_glptr_TexParameterIivEXT) (GET_by_offset(disp, _gloffset_TexParameterIivEXT)); -} - -static inline void SET_TexParameterIivEXT(struct _glapi_table *disp, void (GLAPIENTRYP fn)(GLenum, GLenum, const GLint *)) { - SET_by_offset(disp, _gloffset_TexParameterIivEXT, fn); -} - -typedef void (GLAPIENTRYP _glptr_TexParameterIuivEXT)(GLenum, GLenum, const GLuint *); -#define CALL_TexParameterIuivEXT(disp, parameters) \ - (* GET_TexParameterIuivEXT(disp)) parameters -static inline _glptr_TexParameterIuivEXT GET_TexParameterIuivEXT(struct _glapi_table *disp) { - return (_glptr_TexParameterIuivEXT) (GET_by_offset(disp, _gloffset_TexParameterIuivEXT)); -} - -static inline void SET_TexParameterIuivEXT(struct _glapi_table *disp, void (GLAPIENTRYP fn)(GLenum, GLenum, const GLuint *)) { - SET_by_offset(disp, _gloffset_TexParameterIuivEXT, fn); -} - -typedef void (GLAPIENTRYP _glptr_GetTexParameterPointervAPPLE)(GLenum, GLenum, GLvoid **); -#define CALL_GetTexParameterPointervAPPLE(disp, parameters) \ - (* GET_GetTexParameterPointervAPPLE(disp)) parameters -static inline _glptr_GetTexParameterPointervAPPLE GET_GetTexParameterPointervAPPLE(struct _glapi_table *disp) { - return (_glptr_GetTexParameterPointervAPPLE) (GET_by_offset(disp, _gloffset_GetTexParameterPointervAPPLE)); -} - -static inline void SET_GetTexParameterPointervAPPLE(struct _glapi_table *disp, void (GLAPIENTRYP fn)(GLenum, GLenum, GLvoid **)) { - SET_by_offset(disp, _gloffset_GetTexParameterPointervAPPLE, fn); -} - -typedef void (GLAPIENTRYP _glptr_TextureRangeAPPLE)(GLenum, GLsizei, GLvoid *); -#define CALL_TextureRangeAPPLE(disp, parameters) \ - (* GET_TextureRangeAPPLE(disp)) parameters -static inline _glptr_TextureRangeAPPLE GET_TextureRangeAPPLE(struct _glapi_table *disp) { - return (_glptr_TextureRangeAPPLE) (GET_by_offset(disp, _gloffset_TextureRangeAPPLE)); -} - -static inline void SET_TextureRangeAPPLE(struct _glapi_table *disp, void (GLAPIENTRYP fn)(GLenum, GLsizei, GLvoid *)) { - SET_by_offset(disp, _gloffset_TextureRangeAPPLE, fn); -} - - -#endif /* !defined( _DISPATCH_H_ ) */ diff --git a/dll/opengl/mesa/main/dlist.c b/dll/opengl/mesa/main/dlist.c deleted file mode 100644 index ee3a7ade5cc..00000000000 --- a/dll/opengl/mesa/main/dlist.c +++ /dev/null @@ -1,6206 +0,0 @@ -/* - * Mesa 3-D graphics library - * Version: 7.7 - * - * Copyright (C) 1999-2008 Brian Paul All Rights Reserved. - * Copyright (C) 2009 VMware, Inc. All Rights Reserved. - * - * Permission is hereby granted, free of charge, to any person obtaining a - * copy of this software and associated documentation files (the "Software"), - * to deal in the Software without restriction, including without limitation - * the rights to use, copy, modify, merge, publish, distribute, sublicense, - * and/or sell copies of the Software, and to permit persons to whom the - * Software is furnished to do so, subject to the following conditions: - * - * The above copyright notice and this permission notice shall be included - * in all copies or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS - * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL - * BRIAN PAUL BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN - * AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN - * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. - */ - - -/** - * \file dlist.c - * Display lists management functions. - */ - -#include - -#include "config.h" - -/** - * Other parts of Mesa (such as the VBO module) can plug into the display - * list system. This structure describes new display list instructions. - */ -struct gl_list_instruction -{ - GLuint Size; - void (*Execute)( struct gl_context *ctx, void *data ); - void (*Destroy)( struct gl_context *ctx, void *data ); - void (*Print)( struct gl_context *ctx, void *data ); -}; - - -#define MAX_DLIST_EXT_OPCODES 16 - -/** - * Used by device drivers to hook new commands into display lists. - */ -struct gl_list_extensions -{ - struct gl_list_instruction Opcode[MAX_DLIST_EXT_OPCODES]; - GLuint NumOpcodes; -}; - - - -/** - * Flush vertices. - * - * \param ctx GL context. - * - * Checks if dd_function_table::SaveNeedFlush is marked to flush - * stored (save) vertices, and calls - * dd_function_table::SaveFlushVertices if so. - */ -#define SAVE_FLUSH_VERTICES(ctx) \ -do { \ - if (ctx->Driver.SaveNeedFlush) \ - ctx->Driver.SaveFlushVertices(ctx); \ -} while (0) - - -/** - * Macro to assert that the API call was made outside the - * glBegin()/glEnd() pair, with return value. - * - * \param ctx GL context. - * \param retval value to return value in case the assertion fails. - */ -#define ASSERT_OUTSIDE_SAVE_BEGIN_END_WITH_RETVAL(ctx, retval) \ -do { \ - if (ctx->Driver.CurrentSavePrimitive <= GL_POLYGON || \ - ctx->Driver.CurrentSavePrimitive == PRIM_INSIDE_UNKNOWN_PRIM) { \ - _mesa_compile_error( ctx, GL_INVALID_OPERATION, "begin/end" ); \ - return retval; \ - } \ -} while (0) - -/** - * Macro to assert that the API call was made outside the - * glBegin()/glEnd() pair. - * - * \param ctx GL context. - */ -#define ASSERT_OUTSIDE_SAVE_BEGIN_END(ctx) \ -do { \ - if (ctx->Driver.CurrentSavePrimitive <= GL_POLYGON || \ - ctx->Driver.CurrentSavePrimitive == PRIM_INSIDE_UNKNOWN_PRIM) { \ - _mesa_compile_error( ctx, GL_INVALID_OPERATION, "begin/end" ); \ - return; \ - } \ -} while (0) - -/** - * Macro to assert that the API call was made outside the - * glBegin()/glEnd() pair and flush the vertices. - * - * \param ctx GL context. - */ -#define ASSERT_OUTSIDE_SAVE_BEGIN_END_AND_FLUSH(ctx) \ -do { \ - ASSERT_OUTSIDE_SAVE_BEGIN_END(ctx); \ - SAVE_FLUSH_VERTICES(ctx); \ -} while (0) - -/** - * Macro to assert that the API call was made outside the - * glBegin()/glEnd() pair and flush the vertices, with return value. - * - * \param ctx GL context. - * \param retval value to return value in case the assertion fails. - */ -#define ASSERT_OUTSIDE_SAVE_BEGIN_END_AND_FLUSH_WITH_RETVAL(ctx, retval)\ -do { \ - ASSERT_OUTSIDE_SAVE_BEGIN_END_WITH_RETVAL(ctx, retval); \ - SAVE_FLUSH_VERTICES(ctx); \ -} while (0) - - - -/** - * Display list opcodes. - * - * The fact that these identifiers are assigned consecutive - * integer values starting at 0 is very important, see InstSize array usage) - */ -typedef enum -{ - OPCODE_INVALID = -1, /* Force signed enum */ - OPCODE_ACCUM, - OPCODE_ALPHA_FUNC, - OPCODE_BIND_TEXTURE, - OPCODE_BITMAP, - OPCODE_BLEND_FUNC, - - OPCODE_CALL_LIST, - OPCODE_CALL_LIST_OFFSET, - OPCODE_CLEAR, - OPCODE_CLEAR_ACCUM, - OPCODE_CLEAR_COLOR, - OPCODE_CLEAR_DEPTH, - OPCODE_CLEAR_INDEX, - OPCODE_CLEAR_STENCIL, - OPCODE_CLIP_PLANE, - OPCODE_COLOR_MASK, - OPCODE_COLOR_MATERIAL, - OPCODE_COPY_PIXELS, - OPCODE_COPY_TEX_IMAGE1D, - OPCODE_COPY_TEX_IMAGE2D, - OPCODE_COPY_TEX_SUB_IMAGE1D, - OPCODE_COPY_TEX_SUB_IMAGE2D, - OPCODE_CULL_FACE, - OPCODE_DEPTH_FUNC, - OPCODE_DEPTH_MASK, - OPCODE_DEPTH_RANGE, - OPCODE_DISABLE, - OPCODE_DRAW_BUFFER, - OPCODE_DRAW_PIXELS, - OPCODE_ENABLE, - OPCODE_EVALMESH1, - OPCODE_EVALMESH2, - OPCODE_FOG, - OPCODE_FRONT_FACE, - OPCODE_FRUSTUM, - OPCODE_HINT, - OPCODE_INDEX_MASK, - OPCODE_INIT_NAMES, - OPCODE_LIGHT, - OPCODE_LIGHT_MODEL, - OPCODE_LINE_STIPPLE, - OPCODE_LINE_WIDTH, - OPCODE_LIST_BASE, - OPCODE_LOAD_IDENTITY, - OPCODE_LOAD_MATRIX, - OPCODE_LOAD_NAME, - OPCODE_LOGIC_OP, - OPCODE_MAP1, - OPCODE_MAP2, - OPCODE_MAPGRID1, - OPCODE_MAPGRID2, - OPCODE_MATRIX_MODE, - OPCODE_MULT_MATRIX, - OPCODE_ORTHO, - OPCODE_PASSTHROUGH, - OPCODE_PIXEL_MAP, - OPCODE_PIXEL_TRANSFER, - OPCODE_PIXEL_ZOOM, - OPCODE_POINT_SIZE, - OPCODE_POINT_PARAMETERS, - OPCODE_POLYGON_MODE, - OPCODE_POLYGON_STIPPLE, - OPCODE_POLYGON_OFFSET, - OPCODE_POP_ATTRIB, - OPCODE_POP_MATRIX, - OPCODE_POP_NAME, - OPCODE_PRIORITIZE_TEXTURE, - OPCODE_PUSH_ATTRIB, - OPCODE_PUSH_MATRIX, - OPCODE_PUSH_NAME, - OPCODE_RASTER_POS, - OPCODE_READ_BUFFER, - OPCODE_ROTATE, - OPCODE_SCALE, - OPCODE_SCISSOR, - OPCODE_SELECT_TEXTURE_SGIS, - OPCODE_SELECT_TEXTURE_COORD_SET, - OPCODE_SHADE_MODEL, - OPCODE_STENCIL_FUNC, - OPCODE_STENCIL_MASK, - OPCODE_STENCIL_OP, - OPCODE_TEXENV, - OPCODE_TEXGEN, - OPCODE_TEXPARAMETER, - OPCODE_TEX_IMAGE1D, - OPCODE_TEX_IMAGE2D, - OPCODE_TEX_SUB_IMAGE1D, - OPCODE_TEX_SUB_IMAGE2D, - OPCODE_TRANSLATE, - OPCODE_VIEWPORT, - OPCODE_WINDOW_POS, - /* GL_ARB_multisample */ - OPCODE_SAMPLE_COVERAGE, - /* GL_ARB_window_pos */ - OPCODE_WINDOW_POS_ARB, - /* GL_EXT_depth_bounds_test */ - OPCODE_DEPTH_BOUNDS_EXT, - - /* Vertex attributes -- fallback for when optimized display - * list build isn't active. - */ - OPCODE_ATTR_1F_NV, - OPCODE_ATTR_2F_NV, - OPCODE_ATTR_3F_NV, - OPCODE_ATTR_4F_NV, - OPCODE_MATERIAL, - OPCODE_BEGIN, - OPCODE_END, - OPCODE_RECTF, - OPCODE_EVAL_C1, - OPCODE_EVAL_C2, - OPCODE_EVAL_P1, - OPCODE_EVAL_P2, - - /* GL_EXT_texture_integer */ - OPCODE_CLEARCOLOR_I, - OPCODE_CLEARCOLOR_UI, - OPCODE_TEXPARAMETER_I, - OPCODE_TEXPARAMETER_UI, - - /* The following three are meta instructions */ - OPCODE_ERROR, /* raise compiled-in error */ - OPCODE_CONTINUE, - OPCODE_END_OF_LIST, - OPCODE_EXT_0 -} OpCode; - - - -/** - * Display list node. - * - * Display list instructions are stored as sequences of "nodes". Nodes - * are allocated in blocks. Each block has BLOCK_SIZE nodes. Blocks - * are linked together with a pointer. - * - * Each instruction in the display list is stored as a sequence of - * contiguous nodes in memory. - * Each node is the union of a variety of data types. - */ -union gl_dlist_node -{ - OpCode opcode; - GLboolean b; - GLbitfield bf; - GLubyte ub; - GLshort s; - GLushort us; - GLint i; - GLuint ui; - GLenum e; - GLfloat f; - GLvoid *data; - void *next; /* If prev node's opcode==OPCODE_CONTINUE */ -}; - - -typedef union gl_dlist_node Node; - - -/** - * Used to store a 64-bit uint in a pair of "Nodes" for the sake of 32-bit - * environment. In 64-bit env, sizeof(Node)==8 anyway. - */ -union uint64_pair -{ - GLuint64 uint64; - GLuint uint32[2]; -}; - - -/** - * How many nodes to allocate at a time. - * - * \note Reduced now that we hold vertices etc. elsewhere. - */ -#define BLOCK_SIZE 256 - - - -/** - * Number of nodes of storage needed for each instruction. - * Sizes for dynamically allocated opcodes are stored in the context struct. - */ -static GLuint InstSize[OPCODE_END_OF_LIST + 1]; - - -#if FEATURE_dlist - - -void mesa_print_display_list(GLuint list); - - -/**********************************************************************/ -/***** Private *****/ -/**********************************************************************/ - - -/** - * Make an empty display list. This is used by glGenLists() to - * reserve display list IDs. - */ -static struct gl_display_list * -make_list(GLuint name, GLuint count) -{ - struct gl_display_list *dlist = CALLOC_STRUCT(gl_display_list); - dlist->Name = name; - dlist->Head = (Node *) malloc(sizeof(Node) * count); - dlist->Head[0].opcode = OPCODE_END_OF_LIST; - return dlist; -} - - -/** - * Lookup function to just encapsulate casting. - */ -static inline struct gl_display_list * -lookup_list(struct gl_context *ctx, GLuint list) -{ - return (struct gl_display_list *) - _mesa_HashLookup(ctx->Shared->DisplayList, list); -} - - -/** Is the given opcode an extension code? */ -static inline GLboolean -is_ext_opcode(OpCode opcode) -{ - return (opcode >= OPCODE_EXT_0); -} - - -/** Destroy an extended opcode instruction */ -static GLint -ext_opcode_destroy(struct gl_context *ctx, Node *node) -{ - const GLint i = node[0].opcode - OPCODE_EXT_0; - GLint step; - ctx->ListExt->Opcode[i].Destroy(ctx, &node[1]); - step = ctx->ListExt->Opcode[i].Size; - return step; -} - - -/** Execute an extended opcode instruction */ -static GLint -ext_opcode_execute(struct gl_context *ctx, Node *node) -{ - const GLint i = node[0].opcode - OPCODE_EXT_0; - GLint step; - ctx->ListExt->Opcode[i].Execute(ctx, &node[1]); - step = ctx->ListExt->Opcode[i].Size; - return step; -} - - -/** Print an extended opcode instruction */ -static GLint -ext_opcode_print(struct gl_context *ctx, Node *node) -{ - const GLint i = node[0].opcode - OPCODE_EXT_0; - GLint step; - ctx->ListExt->Opcode[i].Print(ctx, &node[1]); - step = ctx->ListExt->Opcode[i].Size; - return step; -} - - -/** - * Delete the named display list, but don't remove from hash table. - * \param dlist - display list pointer - */ -void -_mesa_delete_list(struct gl_context *ctx, struct gl_display_list *dlist) -{ - Node *n, *block; - GLboolean done; - - n = block = dlist->Head; - - done = block ? GL_FALSE : GL_TRUE; - while (!done) { - const OpCode opcode = n[0].opcode; - - /* check for extension opcodes first */ - if (is_ext_opcode(opcode)) { - n += ext_opcode_destroy(ctx, n); - } - else { - switch (opcode) { - /* for some commands, we need to free malloc'd memory */ - case OPCODE_MAP1: - free(n[6].data); - n += InstSize[n[0].opcode]; - break; - case OPCODE_MAP2: - free(n[10].data); - n += InstSize[n[0].opcode]; - break; - case OPCODE_DRAW_PIXELS: - free(n[5].data); - n += InstSize[n[0].opcode]; - break; - case OPCODE_BITMAP: - free(n[7].data); - n += InstSize[n[0].opcode]; - break; - case OPCODE_POLYGON_STIPPLE: - free(n[1].data); - n += InstSize[n[0].opcode]; - break; - case OPCODE_TEX_IMAGE1D: - free(n[8].data); - n += InstSize[n[0].opcode]; - break; - case OPCODE_TEX_IMAGE2D: - free(n[9].data); - n += InstSize[n[0].opcode]; - break; - case OPCODE_TEX_SUB_IMAGE1D: - free(n[7].data); - n += InstSize[n[0].opcode]; - break; - case OPCODE_TEX_SUB_IMAGE2D: - free(n[9].data); - n += InstSize[n[0].opcode]; - break; - case OPCODE_CONTINUE: - n = (Node *) n[1].next; - free(block); - block = n; - break; - case OPCODE_END_OF_LIST: - free(block); - done = GL_TRUE; - break; - default: - /* Most frequent case */ - n += InstSize[n[0].opcode]; - break; - } - } - } - - free(dlist); -} - - -/** - * Destroy a display list and remove from hash table. - * \param list - display list number - */ -static void -destroy_list(struct gl_context *ctx, GLuint list) -{ - struct gl_display_list *dlist; - - if (list == 0) - return; - - dlist = lookup_list(ctx, list); - if (!dlist) - return; - - _mesa_delete_list(ctx, dlist); - _mesa_HashRemove(ctx->Shared->DisplayList, list); -} - - -/* - * Translate the nth element of list from to GLint. - */ -static GLint -translate_id(GLsizei n, GLenum type, const GLvoid * list) -{ - GLbyte *bptr; - GLubyte *ubptr; - GLshort *sptr; - GLushort *usptr; - GLint *iptr; - GLuint *uiptr; - GLfloat *fptr; - - switch (type) { - case GL_BYTE: - bptr = (GLbyte *) list; - return (GLint) bptr[n]; - case GL_UNSIGNED_BYTE: - ubptr = (GLubyte *) list; - return (GLint) ubptr[n]; - case GL_SHORT: - sptr = (GLshort *) list; - return (GLint) sptr[n]; - case GL_UNSIGNED_SHORT: - usptr = (GLushort *) list; - return (GLint) usptr[n]; - case GL_INT: - iptr = (GLint *) list; - return iptr[n]; - case GL_UNSIGNED_INT: - uiptr = (GLuint *) list; - return (GLint) uiptr[n]; - case GL_FLOAT: - fptr = (GLfloat *) list; - return (GLint) FLOORF(fptr[n]); - case GL_2_BYTES: - ubptr = ((GLubyte *) list) + 2 * n; - return (GLint) ubptr[0] * 256 - + (GLint) ubptr[1]; - case GL_3_BYTES: - ubptr = ((GLubyte *) list) + 3 * n; - return (GLint) ubptr[0] * 65536 - + (GLint) ubptr[1] * 256 - + (GLint) ubptr[2]; - case GL_4_BYTES: - ubptr = ((GLubyte *) list) + 4 * n; - return (GLint) ubptr[0] * 16777216 - + (GLint) ubptr[1] * 65536 - + (GLint) ubptr[2] * 256 - + (GLint) ubptr[3]; - default: - return 0; - } -} - - - - -/**********************************************************************/ -/***** Public *****/ -/**********************************************************************/ - -/** - * Wrapper for _mesa_unpack_image/bitmap() that handles pixel buffer objects. - * If width < 0 or height < 0 or format or type are invalid we'll just - * return NULL. We will not generate an error since OpenGL command - * arguments aren't error-checked until the command is actually executed - * (not when they're compiled). - * But if we run out of memory, GL_OUT_OF_MEMORY will be recorded. - */ -static GLvoid * -unpack_image(struct gl_context *ctx, GLuint dimensions, - GLsizei width, GLsizei height, GLsizei depth, - GLenum format, GLenum type, const GLvoid * pixels, - const struct gl_pixelstore_attrib *unpack) -{ - GLvoid *image; - - if (width <= 0 || height <= 0) { - return NULL; - } - - if (_mesa_bytes_per_pixel(format, type) < 0) { - /* bad format and/or type */ - return NULL; - } - - if (type == GL_BITMAP) - image = _mesa_unpack_bitmap(width, height, pixels, unpack); - else - image = _mesa_unpack_image(dimensions, width, height, depth, - format, type, pixels, unpack); - if (pixels && !image) { - _mesa_error(ctx, GL_OUT_OF_MEMORY, "display list construction"); - } - return image; -} - -/** - * Allocate space for a display list instruction (opcode + payload space). - * \param opcode the instruction opcode (OPCODE_* value) - * \param bytes instruction payload size (not counting opcode) - * \return pointer to allocated memory (the opcode space) - */ -static Node * -dlist_alloc(struct gl_context *ctx, OpCode opcode, GLuint bytes) -{ - const GLuint numNodes = 1 + (bytes + sizeof(Node) - 1) / sizeof(Node); - Node *n; - - if (opcode < (GLuint) OPCODE_EXT_0) { - if (InstSize[opcode] == 0) { - /* save instruction size now */ - InstSize[opcode] = numNodes; - } - else { - /* make sure instruction size agrees */ - ASSERT(numNodes == InstSize[opcode]); - } - } - - if (ctx->ListState.CurrentPos + numNodes + 2 > BLOCK_SIZE) { - /* This block is full. Allocate a new block and chain to it */ - Node *newblock; - n = ctx->ListState.CurrentBlock + ctx->ListState.CurrentPos; - n[0].opcode = OPCODE_CONTINUE; - newblock = (Node *) malloc(sizeof(Node) * BLOCK_SIZE); - if (!newblock) { - _mesa_error(ctx, GL_OUT_OF_MEMORY, "Building display list"); - return NULL; - } - n[1].next = (Node *) newblock; - ctx->ListState.CurrentBlock = newblock; - ctx->ListState.CurrentPos = 0; - } - - n = ctx->ListState.CurrentBlock + ctx->ListState.CurrentPos; - ctx->ListState.CurrentPos += numNodes; - - n[0].opcode = opcode; - - return n; -} - - - -/** - * Allocate space for a display list instruction. Used by callers outside - * this file for things like VBO vertex data. - * - * \param opcode the instruction opcode (OPCODE_* value) - * \param bytes instruction size in bytes, not counting opcode. - * \return pointer to the usable data area (not including the internal - * opcode). - */ -void * -_mesa_dlist_alloc(struct gl_context *ctx, GLuint opcode, GLuint bytes) -{ - Node *n = dlist_alloc(ctx, (OpCode) opcode, bytes); - if (n) - return n + 1; /* return pointer to payload area, after opcode */ - else - return NULL; -} - - -/** - * This function allows modules and drivers to get their own opcodes - * for extending display list functionality. - * \param ctx the rendering context - * \param size number of bytes for storing the new display list command - * \param execute function to execute the new display list command - * \param destroy function to destroy the new display list command - * \param print function to print the new display list command - * \return the new opcode number or -1 if error - */ -GLint -_mesa_dlist_alloc_opcode(struct gl_context *ctx, - GLuint size, - void (*execute) (struct gl_context *, void *), - void (*destroy) (struct gl_context *, void *), - void (*print) (struct gl_context *, void *)) -{ - if (ctx->ListExt->NumOpcodes < MAX_DLIST_EXT_OPCODES) { - const GLuint i = ctx->ListExt->NumOpcodes++; - ctx->ListExt->Opcode[i].Size = - 1 + (size + sizeof(Node) - 1) / sizeof(Node); - ctx->ListExt->Opcode[i].Execute = execute; - ctx->ListExt->Opcode[i].Destroy = destroy; - ctx->ListExt->Opcode[i].Print = print; - return i + OPCODE_EXT_0; - } - return -1; -} - - -/** - * Allocate space for a display list instruction. The space is basically - * an array of Nodes where node[0] holds the opcode, node[1] is the first - * function parameter, node[2] is the second parameter, etc. - * - * \param opcode one of OPCODE_x - * \param nparams number of function parameters - * \return pointer to start of instruction space - */ -static inline Node * -alloc_instruction(struct gl_context *ctx, OpCode opcode, GLuint nparams) -{ - return dlist_alloc(ctx, opcode, nparams * sizeof(Node)); -} - - - -/* - * Display List compilation functions - */ -static void GLAPIENTRY -save_Accum(GLenum op, GLfloat value) -{ - GET_CURRENT_CONTEXT(ctx); - Node *n; - ASSERT_OUTSIDE_SAVE_BEGIN_END_AND_FLUSH(ctx); - n = alloc_instruction(ctx, OPCODE_ACCUM, 2); - if (n) { - n[1].e = op; - n[2].f = value; - } - if (ctx->ExecuteFlag) { - CALL_Accum(ctx->Exec, (op, value)); - } -} - - -static void GLAPIENTRY -save_AlphaFunc(GLenum func, GLclampf ref) -{ - GET_CURRENT_CONTEXT(ctx); - Node *n; - ASSERT_OUTSIDE_SAVE_BEGIN_END_AND_FLUSH(ctx); - n = alloc_instruction(ctx, OPCODE_ALPHA_FUNC, 2); - if (n) { - n[1].e = func; - n[2].f = (GLfloat) ref; - } - if (ctx->ExecuteFlag) { - CALL_AlphaFunc(ctx->Exec, (func, ref)); - } -} - - -static void GLAPIENTRY -save_BindTexture(GLenum target, GLuint texture) -{ - GET_CURRENT_CONTEXT(ctx); - Node *n; - ASSERT_OUTSIDE_SAVE_BEGIN_END_AND_FLUSH(ctx); - n = alloc_instruction(ctx, OPCODE_BIND_TEXTURE, 2); - if (n) { - n[1].e = target; - n[2].ui = texture; - } - if (ctx->ExecuteFlag) { - CALL_BindTexture(ctx->Exec, (target, texture)); - } -} - - -static void GLAPIENTRY -save_Bitmap(GLsizei width, GLsizei height, - GLfloat xorig, GLfloat yorig, - GLfloat xmove, GLfloat ymove, const GLubyte * pixels) -{ - GET_CURRENT_CONTEXT(ctx); - Node *n; - ASSERT_OUTSIDE_SAVE_BEGIN_END_AND_FLUSH(ctx); - n = alloc_instruction(ctx, OPCODE_BITMAP, 7); - if (n) { - n[1].i = (GLint) width; - n[2].i = (GLint) height; - n[3].f = xorig; - n[4].f = yorig; - n[5].f = xmove; - n[6].f = ymove; - n[7].data = unpack_image(ctx, 2, width, height, 1, GL_COLOR_INDEX, - GL_BITMAP, pixels, &ctx->Unpack); - } - if (ctx->ExecuteFlag) { - CALL_Bitmap(ctx->Exec, (width, height, - xorig, yorig, xmove, ymove, pixels)); - } -} - - -static void GLAPIENTRY -save_BlendFunc(GLenum srcfactor, GLenum dstfactor) -{ - GET_CURRENT_CONTEXT(ctx); - Node *n; - ASSERT_OUTSIDE_SAVE_BEGIN_END_AND_FLUSH(ctx); - n = alloc_instruction(ctx, OPCODE_BLEND_FUNC, 2); - if (n) { - n[1].e = srcfactor; - n[2].e = dstfactor; - } - if (ctx->ExecuteFlag) { - CALL_BlendFunc(ctx->Exec, (srcfactor, dstfactor)); - } -} - - -static void invalidate_saved_current_state( struct gl_context *ctx ) -{ - GLint i; - - for (i = 0; i < VERT_ATTRIB_MAX; i++) - ctx->ListState.ActiveAttribSize[i] = 0; - - for (i = 0; i < MAT_ATTRIB_MAX; i++) - ctx->ListState.ActiveMaterialSize[i] = 0; - - memset(&ctx->ListState.Current, 0, sizeof ctx->ListState.Current); - - ctx->Driver.CurrentSavePrimitive = PRIM_UNKNOWN; -} - -static void GLAPIENTRY -save_CallList(GLuint list) -{ - GET_CURRENT_CONTEXT(ctx); - Node *n; - SAVE_FLUSH_VERTICES(ctx); - - n = alloc_instruction(ctx, OPCODE_CALL_LIST, 1); - if (n) { - n[1].ui = list; - } - - /* After this, we don't know what state we're in. Invalidate all - * cached information previously gathered: - */ - invalidate_saved_current_state( ctx ); - - if (ctx->ExecuteFlag) { - _mesa_CallList(list); - } -} - - -static void GLAPIENTRY -save_CallLists(GLsizei num, GLenum type, const GLvoid * lists) -{ - GET_CURRENT_CONTEXT(ctx); - GLint i; - GLboolean typeErrorFlag; - - SAVE_FLUSH_VERTICES(ctx); - - switch (type) { - case GL_BYTE: - case GL_UNSIGNED_BYTE: - case GL_SHORT: - case GL_UNSIGNED_SHORT: - case GL_INT: - case GL_UNSIGNED_INT: - case GL_FLOAT: - case GL_2_BYTES: - case GL_3_BYTES: - case GL_4_BYTES: - typeErrorFlag = GL_FALSE; - break; - default: - typeErrorFlag = GL_TRUE; - } - - for (i = 0; i < num; i++) { - GLint list = translate_id(i, type, lists); - Node *n = alloc_instruction(ctx, OPCODE_CALL_LIST_OFFSET, 2); - if (n) { - n[1].i = list; - n[2].b = typeErrorFlag; - } - } - - /* After this, we don't know what state we're in. Invalidate all - * cached information previously gathered: - */ - invalidate_saved_current_state( ctx ); - - if (ctx->ExecuteFlag) { - CALL_CallLists(ctx->Exec, (num, type, lists)); - } -} - - -static void GLAPIENTRY -save_Clear(GLbitfield mask) -{ - GET_CURRENT_CONTEXT(ctx); - Node *n; - ASSERT_OUTSIDE_SAVE_BEGIN_END_AND_FLUSH(ctx); - n = alloc_instruction(ctx, OPCODE_CLEAR, 1); - if (n) { - n[1].bf = mask; - } - if (ctx->ExecuteFlag) { - CALL_Clear(ctx->Exec, (mask)); - } -} - - -static void GLAPIENTRY -save_ClearAccum(GLfloat red, GLfloat green, GLfloat blue, GLfloat alpha) -{ - GET_CURRENT_CONTEXT(ctx); - Node *n; - ASSERT_OUTSIDE_SAVE_BEGIN_END_AND_FLUSH(ctx); - n = alloc_instruction(ctx, OPCODE_CLEAR_ACCUM, 4); - if (n) { - n[1].f = red; - n[2].f = green; - n[3].f = blue; - n[4].f = alpha; - } - if (ctx->ExecuteFlag) { - CALL_ClearAccum(ctx->Exec, (red, green, blue, alpha)); - } -} - - -static void GLAPIENTRY -save_ClearColor(GLclampf red, GLclampf green, GLclampf blue, GLclampf alpha) -{ - GET_CURRENT_CONTEXT(ctx); - Node *n; - ASSERT_OUTSIDE_SAVE_BEGIN_END_AND_FLUSH(ctx); - n = alloc_instruction(ctx, OPCODE_CLEAR_COLOR, 4); - if (n) { - n[1].f = red; - n[2].f = green; - n[3].f = blue; - n[4].f = alpha; - } - if (ctx->ExecuteFlag) { - CALL_ClearColor(ctx->Exec, (red, green, blue, alpha)); - } -} - - -static void GLAPIENTRY -save_ClearDepth(GLclampd depth) -{ - GET_CURRENT_CONTEXT(ctx); - Node *n; - ASSERT_OUTSIDE_SAVE_BEGIN_END_AND_FLUSH(ctx); - n = alloc_instruction(ctx, OPCODE_CLEAR_DEPTH, 1); - if (n) { - n[1].f = (GLfloat) depth; - } - if (ctx->ExecuteFlag) { - CALL_ClearDepth(ctx->Exec, (depth)); - } -} - - -static void GLAPIENTRY -save_ClearIndex(GLfloat c) -{ - GET_CURRENT_CONTEXT(ctx); - Node *n; - ASSERT_OUTSIDE_SAVE_BEGIN_END_AND_FLUSH(ctx); - n = alloc_instruction(ctx, OPCODE_CLEAR_INDEX, 1); - if (n) { - n[1].f = c; - } - if (ctx->ExecuteFlag) { - CALL_ClearIndex(ctx->Exec, (c)); - } -} - - -static void GLAPIENTRY -save_ClearStencil(GLint s) -{ - GET_CURRENT_CONTEXT(ctx); - Node *n; - ASSERT_OUTSIDE_SAVE_BEGIN_END_AND_FLUSH(ctx); - n = alloc_instruction(ctx, OPCODE_CLEAR_STENCIL, 1); - if (n) { - n[1].i = s; - } - if (ctx->ExecuteFlag) { - CALL_ClearStencil(ctx->Exec, (s)); - } -} - - -static void GLAPIENTRY -save_ClipPlane(GLenum plane, const GLdouble * equ) -{ - GET_CURRENT_CONTEXT(ctx); - Node *n; - ASSERT_OUTSIDE_SAVE_BEGIN_END_AND_FLUSH(ctx); - n = alloc_instruction(ctx, OPCODE_CLIP_PLANE, 5); - if (n) { - n[1].e = plane; - n[2].f = (GLfloat) equ[0]; - n[3].f = (GLfloat) equ[1]; - n[4].f = (GLfloat) equ[2]; - n[5].f = (GLfloat) equ[3]; - } - if (ctx->ExecuteFlag) { - CALL_ClipPlane(ctx->Exec, (plane, equ)); - } -} - - - -static void GLAPIENTRY -save_ColorMask(GLboolean red, GLboolean green, - GLboolean blue, GLboolean alpha) -{ - GET_CURRENT_CONTEXT(ctx); - Node *n; - ASSERT_OUTSIDE_SAVE_BEGIN_END_AND_FLUSH(ctx); - n = alloc_instruction(ctx, OPCODE_COLOR_MASK, 4); - if (n) { - n[1].b = red; - n[2].b = green; - n[3].b = blue; - n[4].b = alpha; - } - if (ctx->ExecuteFlag) { - CALL_ColorMask(ctx->Exec, (red, green, blue, alpha)); - } -} - - -static void GLAPIENTRY -save_ColorMaterial(GLenum face, GLenum mode) -{ - GET_CURRENT_CONTEXT(ctx); - Node *n; - ASSERT_OUTSIDE_SAVE_BEGIN_END_AND_FLUSH(ctx); - - n = alloc_instruction(ctx, OPCODE_COLOR_MATERIAL, 2); - if (n) { - n[1].e = face; - n[2].e = mode; - } - if (ctx->ExecuteFlag) { - CALL_ColorMaterial(ctx->Exec, (face, mode)); - } -} - - -static void GLAPIENTRY -save_CopyPixels(GLint x, GLint y, GLsizei width, GLsizei height, GLenum type) -{ - GET_CURRENT_CONTEXT(ctx); - Node *n; - ASSERT_OUTSIDE_SAVE_BEGIN_END_AND_FLUSH(ctx); - n = alloc_instruction(ctx, OPCODE_COPY_PIXELS, 5); - if (n) { - n[1].i = x; - n[2].i = y; - n[3].i = (GLint) width; - n[4].i = (GLint) height; - n[5].e = type; - } - if (ctx->ExecuteFlag) { - CALL_CopyPixels(ctx->Exec, (x, y, width, height, type)); - } -} - - - -static void GLAPIENTRY -save_CopyTexImage1D(GLenum target, GLint level, GLenum internalformat, - GLint x, GLint y, GLsizei width, GLint border) -{ - GET_CURRENT_CONTEXT(ctx); - Node *n; - ASSERT_OUTSIDE_SAVE_BEGIN_END_AND_FLUSH(ctx); - n = alloc_instruction(ctx, OPCODE_COPY_TEX_IMAGE1D, 7); - if (n) { - n[1].e = target; - n[2].i = level; - n[3].e = internalformat; - n[4].i = x; - n[5].i = y; - n[6].i = width; - n[7].i = border; - } - if (ctx->ExecuteFlag) { - CALL_CopyTexImage1D(ctx->Exec, (target, level, internalformat, - x, y, width, border)); - } -} - - -static void GLAPIENTRY -save_CopyTexImage2D(GLenum target, GLint level, - GLenum internalformat, - GLint x, GLint y, GLsizei width, - GLsizei height, GLint border) -{ - GET_CURRENT_CONTEXT(ctx); - Node *n; - ASSERT_OUTSIDE_SAVE_BEGIN_END_AND_FLUSH(ctx); - n = alloc_instruction(ctx, OPCODE_COPY_TEX_IMAGE2D, 8); - if (n) { - n[1].e = target; - n[2].i = level; - n[3].e = internalformat; - n[4].i = x; - n[5].i = y; - n[6].i = width; - n[7].i = height; - n[8].i = border; - } - if (ctx->ExecuteFlag) { - CALL_CopyTexImage2D(ctx->Exec, (target, level, internalformat, - x, y, width, height, border)); - } -} - - - -static void GLAPIENTRY -save_CopyTexSubImage1D(GLenum target, GLint level, - GLint xoffset, GLint x, GLint y, GLsizei width) -{ - GET_CURRENT_CONTEXT(ctx); - Node *n; - ASSERT_OUTSIDE_SAVE_BEGIN_END_AND_FLUSH(ctx); - n = alloc_instruction(ctx, OPCODE_COPY_TEX_SUB_IMAGE1D, 6); - if (n) { - n[1].e = target; - n[2].i = level; - n[3].i = xoffset; - n[4].i = x; - n[5].i = y; - n[6].i = width; - } - if (ctx->ExecuteFlag) { - CALL_CopyTexSubImage1D(ctx->Exec, - (target, level, xoffset, x, y, width)); - } -} - - -static void GLAPIENTRY -save_CopyTexSubImage2D(GLenum target, GLint level, - GLint xoffset, GLint yoffset, - GLint x, GLint y, GLsizei width, GLint height) -{ - GET_CURRENT_CONTEXT(ctx); - Node *n; - ASSERT_OUTSIDE_SAVE_BEGIN_END_AND_FLUSH(ctx); - n = alloc_instruction(ctx, OPCODE_COPY_TEX_SUB_IMAGE2D, 8); - if (n) { - n[1].e = target; - n[2].i = level; - n[3].i = xoffset; - n[4].i = yoffset; - n[5].i = x; - n[6].i = y; - n[7].i = width; - n[8].i = height; - } - if (ctx->ExecuteFlag) { - CALL_CopyTexSubImage2D(ctx->Exec, (target, level, xoffset, yoffset, - x, y, width, height)); - } -} - - -static void GLAPIENTRY -save_CullFace(GLenum mode) -{ - GET_CURRENT_CONTEXT(ctx); - Node *n; - ASSERT_OUTSIDE_SAVE_BEGIN_END_AND_FLUSH(ctx); - n = alloc_instruction(ctx, OPCODE_CULL_FACE, 1); - if (n) { - n[1].e = mode; - } - if (ctx->ExecuteFlag) { - CALL_CullFace(ctx->Exec, (mode)); - } -} - - -static void GLAPIENTRY -save_DepthFunc(GLenum func) -{ - GET_CURRENT_CONTEXT(ctx); - Node *n; - ASSERT_OUTSIDE_SAVE_BEGIN_END_AND_FLUSH(ctx); - n = alloc_instruction(ctx, OPCODE_DEPTH_FUNC, 1); - if (n) { - n[1].e = func; - } - if (ctx->ExecuteFlag) { - CALL_DepthFunc(ctx->Exec, (func)); - } -} - - -static void GLAPIENTRY -save_DepthMask(GLboolean mask) -{ - GET_CURRENT_CONTEXT(ctx); - Node *n; - ASSERT_OUTSIDE_SAVE_BEGIN_END_AND_FLUSH(ctx); - n = alloc_instruction(ctx, OPCODE_DEPTH_MASK, 1); - if (n) { - n[1].b = mask; - } - if (ctx->ExecuteFlag) { - CALL_DepthMask(ctx->Exec, (mask)); - } -} - - -static void GLAPIENTRY -save_DepthRange(GLclampd nearval, GLclampd farval) -{ - GET_CURRENT_CONTEXT(ctx); - Node *n; - ASSERT_OUTSIDE_SAVE_BEGIN_END_AND_FLUSH(ctx); - n = alloc_instruction(ctx, OPCODE_DEPTH_RANGE, 2); - if (n) { - n[1].f = (GLfloat) nearval; - n[2].f = (GLfloat) farval; - } - if (ctx->ExecuteFlag) { - CALL_DepthRange(ctx->Exec, (nearval, farval)); - } -} - - -static void GLAPIENTRY -save_Disable(GLenum cap) -{ - GET_CURRENT_CONTEXT(ctx); - Node *n; - ASSERT_OUTSIDE_SAVE_BEGIN_END_AND_FLUSH(ctx); - n = alloc_instruction(ctx, OPCODE_DISABLE, 1); - if (n) { - n[1].e = cap; - } - if (ctx->ExecuteFlag) { - CALL_Disable(ctx->Exec, (cap)); - } -} - - -static void GLAPIENTRY -save_DrawBuffer(GLenum mode) -{ - GET_CURRENT_CONTEXT(ctx); - Node *n; - ASSERT_OUTSIDE_SAVE_BEGIN_END_AND_FLUSH(ctx); - n = alloc_instruction(ctx, OPCODE_DRAW_BUFFER, 1); - if (n) { - n[1].e = mode; - } - if (ctx->ExecuteFlag) { - CALL_DrawBuffer(ctx->Exec, (mode)); - } -} - - -static void GLAPIENTRY -save_DrawPixels(GLsizei width, GLsizei height, - GLenum format, GLenum type, const GLvoid * pixels) -{ - GET_CURRENT_CONTEXT(ctx); - Node *n; - - ASSERT_OUTSIDE_SAVE_BEGIN_END_AND_FLUSH(ctx); - - n = alloc_instruction(ctx, OPCODE_DRAW_PIXELS, 5); - if (n) { - n[1].i = width; - n[2].i = height; - n[3].e = format; - n[4].e = type; - n[5].data = unpack_image(ctx, 2, width, height, 1, format, type, - pixels, &ctx->Unpack); - } - if (ctx->ExecuteFlag) { - CALL_DrawPixels(ctx->Exec, (width, height, format, type, pixels)); - } -} - - - -static void GLAPIENTRY -save_Enable(GLenum cap) -{ - GET_CURRENT_CONTEXT(ctx); - Node *n; - ASSERT_OUTSIDE_SAVE_BEGIN_END_AND_FLUSH(ctx); - n = alloc_instruction(ctx, OPCODE_ENABLE, 1); - if (n) { - n[1].e = cap; - } - if (ctx->ExecuteFlag) { - CALL_Enable(ctx->Exec, (cap)); - } -} - - - -static void GLAPIENTRY -save_EvalMesh1(GLenum mode, GLint i1, GLint i2) -{ - GET_CURRENT_CONTEXT(ctx); - Node *n; - ASSERT_OUTSIDE_SAVE_BEGIN_END_AND_FLUSH(ctx); - n = alloc_instruction(ctx, OPCODE_EVALMESH1, 3); - if (n) { - n[1].e = mode; - n[2].i = i1; - n[3].i = i2; - } - if (ctx->ExecuteFlag) { - CALL_EvalMesh1(ctx->Exec, (mode, i1, i2)); - } -} - - -static void GLAPIENTRY -save_EvalMesh2(GLenum mode, GLint i1, GLint i2, GLint j1, GLint j2) -{ - GET_CURRENT_CONTEXT(ctx); - Node *n; - ASSERT_OUTSIDE_SAVE_BEGIN_END_AND_FLUSH(ctx); - n = alloc_instruction(ctx, OPCODE_EVALMESH2, 5); - if (n) { - n[1].e = mode; - n[2].i = i1; - n[3].i = i2; - n[4].i = j1; - n[5].i = j2; - } - if (ctx->ExecuteFlag) { - CALL_EvalMesh2(ctx->Exec, (mode, i1, i2, j1, j2)); - } -} - - - - -static void GLAPIENTRY -save_Fogfv(GLenum pname, const GLfloat *params) -{ - GET_CURRENT_CONTEXT(ctx); - Node *n; - ASSERT_OUTSIDE_SAVE_BEGIN_END_AND_FLUSH(ctx); - n = alloc_instruction(ctx, OPCODE_FOG, 5); - if (n) { - n[1].e = pname; - n[2].f = params[0]; - n[3].f = params[1]; - n[4].f = params[2]; - n[5].f = params[3]; - } - if (ctx->ExecuteFlag) { - CALL_Fogfv(ctx->Exec, (pname, params)); - } -} - - -static void GLAPIENTRY -save_Fogf(GLenum pname, GLfloat param) -{ - GLfloat parray[4]; - parray[0] = param; - parray[1] = parray[2] = parray[3] = 0.0F; - save_Fogfv(pname, parray); -} - - -static void GLAPIENTRY -save_Fogiv(GLenum pname, const GLint *params) -{ - GLfloat p[4]; - switch (pname) { - case GL_FOG_MODE: - case GL_FOG_DENSITY: - case GL_FOG_START: - case GL_FOG_END: - case GL_FOG_INDEX: - p[0] = (GLfloat) *params; - p[1] = 0.0f; - p[2] = 0.0f; - p[3] = 0.0f; - break; - case GL_FOG_COLOR: - p[0] = INT_TO_FLOAT(params[0]); - p[1] = INT_TO_FLOAT(params[1]); - p[2] = INT_TO_FLOAT(params[2]); - p[3] = INT_TO_FLOAT(params[3]); - break; - default: - /* Error will be caught later in gl_Fogfv */ - ASSIGN_4V(p, 0.0F, 0.0F, 0.0F, 0.0F); - } - save_Fogfv(pname, p); -} - - -static void GLAPIENTRY -save_Fogi(GLenum pname, GLint param) -{ - GLint parray[4]; - parray[0] = param; - parray[1] = parray[2] = parray[3] = 0; - save_Fogiv(pname, parray); -} - - -static void GLAPIENTRY -save_FrontFace(GLenum mode) -{ - GET_CURRENT_CONTEXT(ctx); - Node *n; - ASSERT_OUTSIDE_SAVE_BEGIN_END_AND_FLUSH(ctx); - n = alloc_instruction(ctx, OPCODE_FRONT_FACE, 1); - if (n) { - n[1].e = mode; - } - if (ctx->ExecuteFlag) { - CALL_FrontFace(ctx->Exec, (mode)); - } -} - - -static void GLAPIENTRY -save_Frustum(GLdouble left, GLdouble right, - GLdouble bottom, GLdouble top, GLdouble nearval, GLdouble farval) -{ - GET_CURRENT_CONTEXT(ctx); - Node *n; - ASSERT_OUTSIDE_SAVE_BEGIN_END_AND_FLUSH(ctx); - n = alloc_instruction(ctx, OPCODE_FRUSTUM, 6); - if (n) { - n[1].f = (GLfloat) left; - n[2].f = (GLfloat) right; - n[3].f = (GLfloat) bottom; - n[4].f = (GLfloat) top; - n[5].f = (GLfloat) nearval; - n[6].f = (GLfloat) farval; - } - if (ctx->ExecuteFlag) { - CALL_Frustum(ctx->Exec, (left, right, bottom, top, nearval, farval)); - } -} - - -static void GLAPIENTRY -save_Hint(GLenum target, GLenum mode) -{ - GET_CURRENT_CONTEXT(ctx); - Node *n; - ASSERT_OUTSIDE_SAVE_BEGIN_END_AND_FLUSH(ctx); - n = alloc_instruction(ctx, OPCODE_HINT, 2); - if (n) { - n[1].e = target; - n[2].e = mode; - } - if (ctx->ExecuteFlag) { - CALL_Hint(ctx->Exec, (target, mode)); - } -} - - -static void GLAPIENTRY -save_IndexMask(GLuint mask) -{ - GET_CURRENT_CONTEXT(ctx); - Node *n; - ASSERT_OUTSIDE_SAVE_BEGIN_END_AND_FLUSH(ctx); - n = alloc_instruction(ctx, OPCODE_INDEX_MASK, 1); - if (n) { - n[1].ui = mask; - } - if (ctx->ExecuteFlag) { - CALL_IndexMask(ctx->Exec, (mask)); - } -} - - -static void GLAPIENTRY -save_InitNames(void) -{ - GET_CURRENT_CONTEXT(ctx); - ASSERT_OUTSIDE_SAVE_BEGIN_END_AND_FLUSH(ctx); - (void) alloc_instruction(ctx, OPCODE_INIT_NAMES, 0); - if (ctx->ExecuteFlag) { - CALL_InitNames(ctx->Exec, ()); - } -} - - -static void GLAPIENTRY -save_Lightfv(GLenum light, GLenum pname, const GLfloat *params) -{ - GET_CURRENT_CONTEXT(ctx); - Node *n; - ASSERT_OUTSIDE_SAVE_BEGIN_END_AND_FLUSH(ctx); - n = alloc_instruction(ctx, OPCODE_LIGHT, 6); - if (n) { - GLint i, nParams; - n[1].e = light; - n[2].e = pname; - switch (pname) { - case GL_AMBIENT: - nParams = 4; - break; - case GL_DIFFUSE: - nParams = 4; - break; - case GL_SPECULAR: - nParams = 4; - break; - case GL_POSITION: - nParams = 4; - break; - case GL_SPOT_DIRECTION: - nParams = 3; - break; - case GL_SPOT_EXPONENT: - nParams = 1; - break; - case GL_SPOT_CUTOFF: - nParams = 1; - break; - case GL_CONSTANT_ATTENUATION: - nParams = 1; - break; - case GL_LINEAR_ATTENUATION: - nParams = 1; - break; - case GL_QUADRATIC_ATTENUATION: - nParams = 1; - break; - default: - nParams = 0; - } - for (i = 0; i < nParams; i++) { - n[3 + i].f = params[i]; - } - } - if (ctx->ExecuteFlag) { - CALL_Lightfv(ctx->Exec, (light, pname, params)); - } -} - - -static void GLAPIENTRY -save_Lightf(GLenum light, GLenum pname, GLfloat param) -{ - GLfloat parray[4]; - parray[0] = param; - parray[1] = parray[2] = parray[3] = 0.0F; - save_Lightfv(light, pname, parray); -} - - -static void GLAPIENTRY -save_Lightiv(GLenum light, GLenum pname, const GLint *params) -{ - GLfloat fparam[4]; - switch (pname) { - case GL_AMBIENT: - case GL_DIFFUSE: - case GL_SPECULAR: - fparam[0] = INT_TO_FLOAT(params[0]); - fparam[1] = INT_TO_FLOAT(params[1]); - fparam[2] = INT_TO_FLOAT(params[2]); - fparam[3] = INT_TO_FLOAT(params[3]); - break; - case GL_POSITION: - fparam[0] = (GLfloat) params[0]; - fparam[1] = (GLfloat) params[1]; - fparam[2] = (GLfloat) params[2]; - fparam[3] = (GLfloat) params[3]; - break; - case GL_SPOT_DIRECTION: - fparam[0] = (GLfloat) params[0]; - fparam[1] = (GLfloat) params[1]; - fparam[2] = (GLfloat) params[2]; - break; - case GL_SPOT_EXPONENT: - case GL_SPOT_CUTOFF: - case GL_CONSTANT_ATTENUATION: - case GL_LINEAR_ATTENUATION: - case GL_QUADRATIC_ATTENUATION: - fparam[0] = (GLfloat) params[0]; - break; - default: - /* error will be caught later in gl_Lightfv */ - ; - } - save_Lightfv(light, pname, fparam); -} - - -static void GLAPIENTRY -save_Lighti(GLenum light, GLenum pname, GLint param) -{ - GLint parray[4]; - parray[0] = param; - parray[1] = parray[2] = parray[3] = 0; - save_Lightiv(light, pname, parray); -} - - -static void GLAPIENTRY -save_LightModelfv(GLenum pname, const GLfloat *params) -{ - GET_CURRENT_CONTEXT(ctx); - Node *n; - ASSERT_OUTSIDE_SAVE_BEGIN_END_AND_FLUSH(ctx); - n = alloc_instruction(ctx, OPCODE_LIGHT_MODEL, 5); - if (n) { - n[1].e = pname; - n[2].f = params[0]; - n[3].f = params[1]; - n[4].f = params[2]; - n[5].f = params[3]; - } - if (ctx->ExecuteFlag) { - CALL_LightModelfv(ctx->Exec, (pname, params)); - } -} - - -static void GLAPIENTRY -save_LightModelf(GLenum pname, GLfloat param) -{ - GLfloat parray[4]; - parray[0] = param; - parray[1] = parray[2] = parray[3] = 0.0F; - save_LightModelfv(pname, parray); -} - - -static void GLAPIENTRY -save_LightModeliv(GLenum pname, const GLint *params) -{ - GLfloat fparam[4]; - switch (pname) { - case GL_LIGHT_MODEL_AMBIENT: - fparam[0] = INT_TO_FLOAT(params[0]); - fparam[1] = INT_TO_FLOAT(params[1]); - fparam[2] = INT_TO_FLOAT(params[2]); - fparam[3] = INT_TO_FLOAT(params[3]); - break; - case GL_LIGHT_MODEL_LOCAL_VIEWER: - case GL_LIGHT_MODEL_TWO_SIDE: - case GL_LIGHT_MODEL_COLOR_CONTROL: - fparam[0] = (GLfloat) params[0]; - fparam[1] = 0.0F; - fparam[2] = 0.0F; - fparam[3] = 0.0F; - break; - default: - /* Error will be caught later in gl_LightModelfv */ - ASSIGN_4V(fparam, 0.0F, 0.0F, 0.0F, 0.0F); - } - save_LightModelfv(pname, fparam); -} - - -static void GLAPIENTRY -save_LightModeli(GLenum pname, GLint param) -{ - GLint parray[4]; - parray[0] = param; - parray[1] = parray[2] = parray[3] = 0; - save_LightModeliv(pname, parray); -} - - -static void GLAPIENTRY -save_LineStipple(GLint factor, GLushort pattern) -{ - GET_CURRENT_CONTEXT(ctx); - Node *n; - ASSERT_OUTSIDE_SAVE_BEGIN_END_AND_FLUSH(ctx); - n = alloc_instruction(ctx, OPCODE_LINE_STIPPLE, 2); - if (n) { - n[1].i = factor; - n[2].us = pattern; - } - if (ctx->ExecuteFlag) { - CALL_LineStipple(ctx->Exec, (factor, pattern)); - } -} - - -static void GLAPIENTRY -save_LineWidth(GLfloat width) -{ - GET_CURRENT_CONTEXT(ctx); - Node *n; - ASSERT_OUTSIDE_SAVE_BEGIN_END_AND_FLUSH(ctx); - n = alloc_instruction(ctx, OPCODE_LINE_WIDTH, 1); - if (n) { - n[1].f = width; - } - if (ctx->ExecuteFlag) { - CALL_LineWidth(ctx->Exec, (width)); - } -} - - -static void GLAPIENTRY -save_ListBase(GLuint base) -{ - GET_CURRENT_CONTEXT(ctx); - Node *n; - ASSERT_OUTSIDE_SAVE_BEGIN_END_AND_FLUSH(ctx); - n = alloc_instruction(ctx, OPCODE_LIST_BASE, 1); - if (n) { - n[1].ui = base; - } - if (ctx->ExecuteFlag) { - CALL_ListBase(ctx->Exec, (base)); - } -} - - -static void GLAPIENTRY -save_LoadIdentity(void) -{ - GET_CURRENT_CONTEXT(ctx); - ASSERT_OUTSIDE_SAVE_BEGIN_END_AND_FLUSH(ctx); - (void) alloc_instruction(ctx, OPCODE_LOAD_IDENTITY, 0); - if (ctx->ExecuteFlag) { - CALL_LoadIdentity(ctx->Exec, ()); - } -} - - -static void GLAPIENTRY -save_LoadMatrixf(const GLfloat * m) -{ - GET_CURRENT_CONTEXT(ctx); - Node *n; - ASSERT_OUTSIDE_SAVE_BEGIN_END_AND_FLUSH(ctx); - n = alloc_instruction(ctx, OPCODE_LOAD_MATRIX, 16); - if (n) { - GLuint i; - for (i = 0; i < 16; i++) { - n[1 + i].f = m[i]; - } - } - if (ctx->ExecuteFlag) { - CALL_LoadMatrixf(ctx->Exec, (m)); - } -} - - -static void GLAPIENTRY -save_LoadMatrixd(const GLdouble * m) -{ - GLfloat f[16]; - GLint i; - for (i = 0; i < 16; i++) { - f[i] = (GLfloat) m[i]; - } - save_LoadMatrixf(f); -} - - -static void GLAPIENTRY -save_LoadName(GLuint name) -{ - GET_CURRENT_CONTEXT(ctx); - Node *n; - ASSERT_OUTSIDE_SAVE_BEGIN_END_AND_FLUSH(ctx); - n = alloc_instruction(ctx, OPCODE_LOAD_NAME, 1); - if (n) { - n[1].ui = name; - } - if (ctx->ExecuteFlag) { - CALL_LoadName(ctx->Exec, (name)); - } -} - - -static void GLAPIENTRY -save_LogicOp(GLenum opcode) -{ - GET_CURRENT_CONTEXT(ctx); - Node *n; - ASSERT_OUTSIDE_SAVE_BEGIN_END_AND_FLUSH(ctx); - n = alloc_instruction(ctx, OPCODE_LOGIC_OP, 1); - if (n) { - n[1].e = opcode; - } - if (ctx->ExecuteFlag) { - CALL_LogicOp(ctx->Exec, (opcode)); - } -} - - -static void GLAPIENTRY -save_Map1d(GLenum target, GLdouble u1, GLdouble u2, GLint stride, - GLint order, const GLdouble * points) -{ - GET_CURRENT_CONTEXT(ctx); - Node *n; - ASSERT_OUTSIDE_SAVE_BEGIN_END_AND_FLUSH(ctx); - n = alloc_instruction(ctx, OPCODE_MAP1, 6); - if (n) { - GLfloat *pnts = _mesa_copy_map_points1d(target, stride, order, points); - n[1].e = target; - n[2].f = (GLfloat) u1; - n[3].f = (GLfloat) u2; - n[4].i = _mesa_evaluator_components(target); /* stride */ - n[5].i = order; - n[6].data = (void *) pnts; - } - if (ctx->ExecuteFlag) { - CALL_Map1d(ctx->Exec, (target, u1, u2, stride, order, points)); - } -} - -static void GLAPIENTRY -save_Map1f(GLenum target, GLfloat u1, GLfloat u2, GLint stride, - GLint order, const GLfloat * points) -{ - GET_CURRENT_CONTEXT(ctx); - Node *n; - ASSERT_OUTSIDE_SAVE_BEGIN_END_AND_FLUSH(ctx); - n = alloc_instruction(ctx, OPCODE_MAP1, 6); - if (n) { - GLfloat *pnts = _mesa_copy_map_points1f(target, stride, order, points); - n[1].e = target; - n[2].f = u1; - n[3].f = u2; - n[4].i = _mesa_evaluator_components(target); /* stride */ - n[5].i = order; - n[6].data = (void *) pnts; - } - if (ctx->ExecuteFlag) { - CALL_Map1f(ctx->Exec, (target, u1, u2, stride, order, points)); - } -} - - -static void GLAPIENTRY -save_Map2d(GLenum target, - GLdouble u1, GLdouble u2, GLint ustride, GLint uorder, - GLdouble v1, GLdouble v2, GLint vstride, GLint vorder, - const GLdouble * points) -{ - GET_CURRENT_CONTEXT(ctx); - Node *n; - ASSERT_OUTSIDE_SAVE_BEGIN_END_AND_FLUSH(ctx); - n = alloc_instruction(ctx, OPCODE_MAP2, 10); - if (n) { - GLfloat *pnts = _mesa_copy_map_points2d(target, ustride, uorder, - vstride, vorder, points); - n[1].e = target; - n[2].f = (GLfloat) u1; - n[3].f = (GLfloat) u2; - n[4].f = (GLfloat) v1; - n[5].f = (GLfloat) v2; - /* XXX verify these strides are correct */ - n[6].i = _mesa_evaluator_components(target) * vorder; /*ustride */ - n[7].i = _mesa_evaluator_components(target); /*vstride */ - n[8].i = uorder; - n[9].i = vorder; - n[10].data = (void *) pnts; - } - if (ctx->ExecuteFlag) { - CALL_Map2d(ctx->Exec, (target, - u1, u2, ustride, uorder, - v1, v2, vstride, vorder, points)); - } -} - - -static void GLAPIENTRY -save_Map2f(GLenum target, - GLfloat u1, GLfloat u2, GLint ustride, GLint uorder, - GLfloat v1, GLfloat v2, GLint vstride, GLint vorder, - const GLfloat * points) -{ - GET_CURRENT_CONTEXT(ctx); - Node *n; - ASSERT_OUTSIDE_SAVE_BEGIN_END_AND_FLUSH(ctx); - n = alloc_instruction(ctx, OPCODE_MAP2, 10); - if (n) { - GLfloat *pnts = _mesa_copy_map_points2f(target, ustride, uorder, - vstride, vorder, points); - n[1].e = target; - n[2].f = u1; - n[3].f = u2; - n[4].f = v1; - n[5].f = v2; - /* XXX verify these strides are correct */ - n[6].i = _mesa_evaluator_components(target) * vorder; /*ustride */ - n[7].i = _mesa_evaluator_components(target); /*vstride */ - n[8].i = uorder; - n[9].i = vorder; - n[10].data = (void *) pnts; - } - if (ctx->ExecuteFlag) { - CALL_Map2f(ctx->Exec, (target, u1, u2, ustride, uorder, - v1, v2, vstride, vorder, points)); - } -} - - -static void GLAPIENTRY -save_MapGrid1f(GLint un, GLfloat u1, GLfloat u2) -{ - GET_CURRENT_CONTEXT(ctx); - Node *n; - ASSERT_OUTSIDE_SAVE_BEGIN_END_AND_FLUSH(ctx); - n = alloc_instruction(ctx, OPCODE_MAPGRID1, 3); - if (n) { - n[1].i = un; - n[2].f = u1; - n[3].f = u2; - } - if (ctx->ExecuteFlag) { - CALL_MapGrid1f(ctx->Exec, (un, u1, u2)); - } -} - - -static void GLAPIENTRY -save_MapGrid1d(GLint un, GLdouble u1, GLdouble u2) -{ - save_MapGrid1f(un, (GLfloat) u1, (GLfloat) u2); -} - - -static void GLAPIENTRY -save_MapGrid2f(GLint un, GLfloat u1, GLfloat u2, - GLint vn, GLfloat v1, GLfloat v2) -{ - GET_CURRENT_CONTEXT(ctx); - Node *n; - ASSERT_OUTSIDE_SAVE_BEGIN_END_AND_FLUSH(ctx); - n = alloc_instruction(ctx, OPCODE_MAPGRID2, 6); - if (n) { - n[1].i = un; - n[2].f = u1; - n[3].f = u2; - n[4].i = vn; - n[5].f = v1; - n[6].f = v2; - } - if (ctx->ExecuteFlag) { - CALL_MapGrid2f(ctx->Exec, (un, u1, u2, vn, v1, v2)); - } -} - - - -static void GLAPIENTRY -save_MapGrid2d(GLint un, GLdouble u1, GLdouble u2, - GLint vn, GLdouble v1, GLdouble v2) -{ - save_MapGrid2f(un, (GLfloat) u1, (GLfloat) u2, - vn, (GLfloat) v1, (GLfloat) v2); -} - - -static void GLAPIENTRY -save_MatrixMode(GLenum mode) -{ - GET_CURRENT_CONTEXT(ctx); - Node *n; - ASSERT_OUTSIDE_SAVE_BEGIN_END_AND_FLUSH(ctx); - n = alloc_instruction(ctx, OPCODE_MATRIX_MODE, 1); - if (n) { - n[1].e = mode; - } - if (ctx->ExecuteFlag) { - CALL_MatrixMode(ctx->Exec, (mode)); - } -} - - -static void GLAPIENTRY -save_MultMatrixf(const GLfloat * m) -{ - GET_CURRENT_CONTEXT(ctx); - Node *n; - ASSERT_OUTSIDE_SAVE_BEGIN_END_AND_FLUSH(ctx); - n = alloc_instruction(ctx, OPCODE_MULT_MATRIX, 16); - if (n) { - GLuint i; - for (i = 0; i < 16; i++) { - n[1 + i].f = m[i]; - } - } - if (ctx->ExecuteFlag) { - CALL_MultMatrixf(ctx->Exec, (m)); - } -} - - -static void GLAPIENTRY -save_MultMatrixd(const GLdouble * m) -{ - GLfloat f[16]; - GLint i; - for (i = 0; i < 16; i++) { - f[i] = (GLfloat) m[i]; - } - save_MultMatrixf(f); -} - - -static void GLAPIENTRY -save_NewList(GLuint name, GLenum mode) -{ - GET_CURRENT_CONTEXT(ctx); - /* It's an error to call this function while building a display list */ - _mesa_error(ctx, GL_INVALID_OPERATION, "glNewList"); - (void) name; - (void) mode; -} - - - -static void GLAPIENTRY -save_Ortho(GLdouble left, GLdouble right, - GLdouble bottom, GLdouble top, GLdouble nearval, GLdouble farval) -{ - GET_CURRENT_CONTEXT(ctx); - Node *n; - ASSERT_OUTSIDE_SAVE_BEGIN_END_AND_FLUSH(ctx); - n = alloc_instruction(ctx, OPCODE_ORTHO, 6); - if (n) { - n[1].f = (GLfloat) left; - n[2].f = (GLfloat) right; - n[3].f = (GLfloat) bottom; - n[4].f = (GLfloat) top; - n[5].f = (GLfloat) nearval; - n[6].f = (GLfloat) farval; - } - if (ctx->ExecuteFlag) { - CALL_Ortho(ctx->Exec, (left, right, bottom, top, nearval, farval)); - } -} - - -static void GLAPIENTRY -save_PixelMapfv(GLenum map, GLint mapsize, const GLfloat *values) -{ - GET_CURRENT_CONTEXT(ctx); - Node *n; - ASSERT_OUTSIDE_SAVE_BEGIN_END_AND_FLUSH(ctx); - n = alloc_instruction(ctx, OPCODE_PIXEL_MAP, 3); - if (n) { - n[1].e = map; - n[2].i = mapsize; - n[3].data = (void *) malloc(mapsize * sizeof(GLfloat)); - memcpy(n[3].data, (void *) values, mapsize * sizeof(GLfloat)); - } - if (ctx->ExecuteFlag) { - CALL_PixelMapfv(ctx->Exec, (map, mapsize, values)); - } -} - - -static void GLAPIENTRY -save_PixelMapuiv(GLenum map, GLint mapsize, const GLuint *values) -{ - GLfloat fvalues[MAX_PIXEL_MAP_TABLE]; - GLint i; - if (map == GL_PIXEL_MAP_I_TO_I || map == GL_PIXEL_MAP_S_TO_S) { - for (i = 0; i < mapsize; i++) { - fvalues[i] = (GLfloat) values[i]; - } - } - else { - for (i = 0; i < mapsize; i++) { - fvalues[i] = UINT_TO_FLOAT(values[i]); - } - } - save_PixelMapfv(map, mapsize, fvalues); -} - - -static void GLAPIENTRY -save_PixelMapusv(GLenum map, GLint mapsize, const GLushort *values) -{ - GLfloat fvalues[MAX_PIXEL_MAP_TABLE]; - GLint i; - if (map == GL_PIXEL_MAP_I_TO_I || map == GL_PIXEL_MAP_S_TO_S) { - for (i = 0; i < mapsize; i++) { - fvalues[i] = (GLfloat) values[i]; - } - } - else { - for (i = 0; i < mapsize; i++) { - fvalues[i] = USHORT_TO_FLOAT(values[i]); - } - } - save_PixelMapfv(map, mapsize, fvalues); -} - - -static void GLAPIENTRY -save_PixelTransferf(GLenum pname, GLfloat param) -{ - GET_CURRENT_CONTEXT(ctx); - Node *n; - ASSERT_OUTSIDE_SAVE_BEGIN_END_AND_FLUSH(ctx); - n = alloc_instruction(ctx, OPCODE_PIXEL_TRANSFER, 2); - if (n) { - n[1].e = pname; - n[2].f = param; - } - if (ctx->ExecuteFlag) { - CALL_PixelTransferf(ctx->Exec, (pname, param)); - } -} - - -static void GLAPIENTRY -save_PixelTransferi(GLenum pname, GLint param) -{ - save_PixelTransferf(pname, (GLfloat) param); -} - - -static void GLAPIENTRY -save_PixelZoom(GLfloat xfactor, GLfloat yfactor) -{ - GET_CURRENT_CONTEXT(ctx); - Node *n; - ASSERT_OUTSIDE_SAVE_BEGIN_END_AND_FLUSH(ctx); - n = alloc_instruction(ctx, OPCODE_PIXEL_ZOOM, 2); - if (n) { - n[1].f = xfactor; - n[2].f = yfactor; - } - if (ctx->ExecuteFlag) { - CALL_PixelZoom(ctx->Exec, (xfactor, yfactor)); - } -} - - -static void GLAPIENTRY -save_PointParameterfvEXT(GLenum pname, const GLfloat *params) -{ - GET_CURRENT_CONTEXT(ctx); - Node *n; - ASSERT_OUTSIDE_SAVE_BEGIN_END_AND_FLUSH(ctx); - n = alloc_instruction(ctx, OPCODE_POINT_PARAMETERS, 4); - if (n) { - n[1].e = pname; - n[2].f = params[0]; - n[3].f = params[1]; - n[4].f = params[2]; - } - if (ctx->ExecuteFlag) { - CALL_PointParameterfvEXT(ctx->Exec, (pname, params)); - } -} - - -static void GLAPIENTRY -save_PointParameterfEXT(GLenum pname, GLfloat param) -{ - GLfloat parray[3]; - parray[0] = param; - parray[1] = parray[2] = 0.0F; - save_PointParameterfvEXT(pname, parray); -} - -static void GLAPIENTRY -save_PointParameteriNV(GLenum pname, GLint param) -{ - GLfloat parray[3]; - parray[0] = (GLfloat) param; - parray[1] = parray[2] = 0.0F; - save_PointParameterfvEXT(pname, parray); -} - -static void GLAPIENTRY -save_PointParameterivNV(GLenum pname, const GLint * param) -{ - GLfloat parray[3]; - parray[0] = (GLfloat) param[0]; - parray[1] = parray[2] = 0.0F; - save_PointParameterfvEXT(pname, parray); -} - - -static void GLAPIENTRY -save_PointSize(GLfloat size) -{ - GET_CURRENT_CONTEXT(ctx); - Node *n; - ASSERT_OUTSIDE_SAVE_BEGIN_END_AND_FLUSH(ctx); - n = alloc_instruction(ctx, OPCODE_POINT_SIZE, 1); - if (n) { - n[1].f = size; - } - if (ctx->ExecuteFlag) { - CALL_PointSize(ctx->Exec, (size)); - } -} - - -static void GLAPIENTRY -save_PolygonMode(GLenum face, GLenum mode) -{ - GET_CURRENT_CONTEXT(ctx); - Node *n; - ASSERT_OUTSIDE_SAVE_BEGIN_END_AND_FLUSH(ctx); - n = alloc_instruction(ctx, OPCODE_POLYGON_MODE, 2); - if (n) { - n[1].e = face; - n[2].e = mode; - } - if (ctx->ExecuteFlag) { - CALL_PolygonMode(ctx->Exec, (face, mode)); - } -} - - -static void GLAPIENTRY -save_PolygonStipple(const GLubyte * pattern) -{ - GET_CURRENT_CONTEXT(ctx); - Node *n; - - ASSERT_OUTSIDE_SAVE_BEGIN_END_AND_FLUSH(ctx); - - n = alloc_instruction(ctx, OPCODE_POLYGON_STIPPLE, 1); - if (n) { - n[1].data = unpack_image(ctx, 2, 32, 32, 1, GL_COLOR_INDEX, GL_BITMAP, - pattern, &ctx->Unpack); - } - if (ctx->ExecuteFlag) { - CALL_PolygonStipple(ctx->Exec, ((GLubyte *) pattern)); - } -} - - -static void GLAPIENTRY -save_PolygonOffset(GLfloat factor, GLfloat units) -{ - GET_CURRENT_CONTEXT(ctx); - Node *n; - ASSERT_OUTSIDE_SAVE_BEGIN_END_AND_FLUSH(ctx); - n = alloc_instruction(ctx, OPCODE_POLYGON_OFFSET, 2); - if (n) { - n[1].f = factor; - n[2].f = units; - } - if (ctx->ExecuteFlag) { - CALL_PolygonOffset(ctx->Exec, (factor, units)); - } -} - - -static void GLAPIENTRY -save_PolygonOffsetEXT(GLfloat factor, GLfloat bias) -{ - GET_CURRENT_CONTEXT(ctx); - /* XXX mult by DepthMaxF here??? */ - save_PolygonOffset(factor, ctx->DrawBuffer->_DepthMaxF * bias); -} - - -static void GLAPIENTRY -save_PopAttrib(void) -{ - GET_CURRENT_CONTEXT(ctx); - ASSERT_OUTSIDE_SAVE_BEGIN_END_AND_FLUSH(ctx); - (void) alloc_instruction(ctx, OPCODE_POP_ATTRIB, 0); - if (ctx->ExecuteFlag) { - CALL_PopAttrib(ctx->Exec, ()); - } -} - - -static void GLAPIENTRY -save_PopMatrix(void) -{ - GET_CURRENT_CONTEXT(ctx); - ASSERT_OUTSIDE_SAVE_BEGIN_END_AND_FLUSH(ctx); - (void) alloc_instruction(ctx, OPCODE_POP_MATRIX, 0); - if (ctx->ExecuteFlag) { - CALL_PopMatrix(ctx->Exec, ()); - } -} - - -static void GLAPIENTRY -save_PopName(void) -{ - GET_CURRENT_CONTEXT(ctx); - ASSERT_OUTSIDE_SAVE_BEGIN_END_AND_FLUSH(ctx); - (void) alloc_instruction(ctx, OPCODE_POP_NAME, 0); - if (ctx->ExecuteFlag) { - CALL_PopName(ctx->Exec, ()); - } -} - - -static void GLAPIENTRY -save_PrioritizeTextures(GLsizei num, const GLuint * textures, - const GLclampf * priorities) -{ - GET_CURRENT_CONTEXT(ctx); - GLint i; - ASSERT_OUTSIDE_SAVE_BEGIN_END_AND_FLUSH(ctx); - - for (i = 0; i < num; i++) { - Node *n; - n = alloc_instruction(ctx, OPCODE_PRIORITIZE_TEXTURE, 2); - if (n) { - n[1].ui = textures[i]; - n[2].f = priorities[i]; - } - } - if (ctx->ExecuteFlag) { - CALL_PrioritizeTextures(ctx->Exec, (num, textures, priorities)); - } -} - - -static void GLAPIENTRY -save_PushAttrib(GLbitfield mask) -{ - GET_CURRENT_CONTEXT(ctx); - Node *n; - ASSERT_OUTSIDE_SAVE_BEGIN_END_AND_FLUSH(ctx); - n = alloc_instruction(ctx, OPCODE_PUSH_ATTRIB, 1); - if (n) { - n[1].bf = mask; - } - if (ctx->ExecuteFlag) { - CALL_PushAttrib(ctx->Exec, (mask)); - } -} - - -static void GLAPIENTRY -save_PushMatrix(void) -{ - GET_CURRENT_CONTEXT(ctx); - ASSERT_OUTSIDE_SAVE_BEGIN_END_AND_FLUSH(ctx); - (void) alloc_instruction(ctx, OPCODE_PUSH_MATRIX, 0); - if (ctx->ExecuteFlag) { - CALL_PushMatrix(ctx->Exec, ()); - } -} - - -static void GLAPIENTRY -save_PushName(GLuint name) -{ - GET_CURRENT_CONTEXT(ctx); - Node *n; - ASSERT_OUTSIDE_SAVE_BEGIN_END_AND_FLUSH(ctx); - n = alloc_instruction(ctx, OPCODE_PUSH_NAME, 1); - if (n) { - n[1].ui = name; - } - if (ctx->ExecuteFlag) { - CALL_PushName(ctx->Exec, (name)); - } -} - - -static void GLAPIENTRY -save_RasterPos4f(GLfloat x, GLfloat y, GLfloat z, GLfloat w) -{ - GET_CURRENT_CONTEXT(ctx); - Node *n; - ASSERT_OUTSIDE_SAVE_BEGIN_END_AND_FLUSH(ctx); - n = alloc_instruction(ctx, OPCODE_RASTER_POS, 4); - if (n) { - n[1].f = x; - n[2].f = y; - n[3].f = z; - n[4].f = w; - } - if (ctx->ExecuteFlag) { - CALL_RasterPos4f(ctx->Exec, (x, y, z, w)); - } -} - -static void GLAPIENTRY -save_RasterPos2d(GLdouble x, GLdouble y) -{ - save_RasterPos4f((GLfloat) x, (GLfloat) y, 0.0F, 1.0F); -} - -static void GLAPIENTRY -save_RasterPos2f(GLfloat x, GLfloat y) -{ - save_RasterPos4f(x, y, 0.0F, 1.0F); -} - -static void GLAPIENTRY -save_RasterPos2i(GLint x, GLint y) -{ - save_RasterPos4f((GLfloat) x, (GLfloat) y, 0.0F, 1.0F); -} - -static void GLAPIENTRY -save_RasterPos2s(GLshort x, GLshort y) -{ - save_RasterPos4f(x, y, 0.0F, 1.0F); -} - -static void GLAPIENTRY -save_RasterPos3d(GLdouble x, GLdouble y, GLdouble z) -{ - save_RasterPos4f((GLfloat) x, (GLfloat) y, (GLfloat) z, 1.0F); -} - -static void GLAPIENTRY -save_RasterPos3f(GLfloat x, GLfloat y, GLfloat z) -{ - save_RasterPos4f(x, y, z, 1.0F); -} - -static void GLAPIENTRY -save_RasterPos3i(GLint x, GLint y, GLint z) -{ - save_RasterPos4f((GLfloat) x, (GLfloat) y, (GLfloat) z, 1.0F); -} - -static void GLAPIENTRY -save_RasterPos3s(GLshort x, GLshort y, GLshort z) -{ - save_RasterPos4f(x, y, z, 1.0F); -} - -static void GLAPIENTRY -save_RasterPos4d(GLdouble x, GLdouble y, GLdouble z, GLdouble w) -{ - save_RasterPos4f((GLfloat) x, (GLfloat) y, (GLfloat) z, (GLfloat) w); -} - -static void GLAPIENTRY -save_RasterPos4i(GLint x, GLint y, GLint z, GLint w) -{ - save_RasterPos4f((GLfloat) x, (GLfloat) y, (GLfloat) z, (GLfloat) w); -} - -static void GLAPIENTRY -save_RasterPos4s(GLshort x, GLshort y, GLshort z, GLshort w) -{ - save_RasterPos4f(x, y, z, w); -} - -static void GLAPIENTRY -save_RasterPos2dv(const GLdouble * v) -{ - save_RasterPos4f((GLfloat) v[0], (GLfloat) v[1], 0.0F, 1.0F); -} - -static void GLAPIENTRY -save_RasterPos2fv(const GLfloat * v) -{ - save_RasterPos4f(v[0], v[1], 0.0F, 1.0F); -} - -static void GLAPIENTRY -save_RasterPos2iv(const GLint * v) -{ - save_RasterPos4f((GLfloat) v[0], (GLfloat) v[1], 0.0F, 1.0F); -} - -static void GLAPIENTRY -save_RasterPos2sv(const GLshort * v) -{ - save_RasterPos4f(v[0], v[1], 0.0F, 1.0F); -} - -static void GLAPIENTRY -save_RasterPos3dv(const GLdouble * v) -{ - save_RasterPos4f((GLfloat) v[0], (GLfloat) v[1], (GLfloat) v[2], 1.0F); -} - -static void GLAPIENTRY -save_RasterPos3fv(const GLfloat * v) -{ - save_RasterPos4f(v[0], v[1], v[2], 1.0F); -} - -static void GLAPIENTRY -save_RasterPos3iv(const GLint * v) -{ - save_RasterPos4f((GLfloat) v[0], (GLfloat) v[1], (GLfloat) v[2], 1.0F); -} - -static void GLAPIENTRY -save_RasterPos3sv(const GLshort * v) -{ - save_RasterPos4f(v[0], v[1], v[2], 1.0F); -} - -static void GLAPIENTRY -save_RasterPos4dv(const GLdouble * v) -{ - save_RasterPos4f((GLfloat) v[0], (GLfloat) v[1], - (GLfloat) v[2], (GLfloat) v[3]); -} - -static void GLAPIENTRY -save_RasterPos4fv(const GLfloat * v) -{ - save_RasterPos4f(v[0], v[1], v[2], v[3]); -} - -static void GLAPIENTRY -save_RasterPos4iv(const GLint * v) -{ - save_RasterPos4f((GLfloat) v[0], (GLfloat) v[1], - (GLfloat) v[2], (GLfloat) v[3]); -} - -static void GLAPIENTRY -save_RasterPos4sv(const GLshort * v) -{ - save_RasterPos4f(v[0], v[1], v[2], v[3]); -} - - -static void GLAPIENTRY -save_PassThrough(GLfloat token) -{ - GET_CURRENT_CONTEXT(ctx); - Node *n; - ASSERT_OUTSIDE_SAVE_BEGIN_END_AND_FLUSH(ctx); - n = alloc_instruction(ctx, OPCODE_PASSTHROUGH, 1); - if (n) { - n[1].f = token; - } - if (ctx->ExecuteFlag) { - CALL_PassThrough(ctx->Exec, (token)); - } -} - - -static void GLAPIENTRY -save_ReadBuffer(GLenum mode) -{ - GET_CURRENT_CONTEXT(ctx); - Node *n; - ASSERT_OUTSIDE_SAVE_BEGIN_END_AND_FLUSH(ctx); - n = alloc_instruction(ctx, OPCODE_READ_BUFFER, 1); - if (n) { - n[1].e = mode; - } - if (ctx->ExecuteFlag) { - CALL_ReadBuffer(ctx->Exec, (mode)); - } -} - - -static void GLAPIENTRY -save_Rotatef(GLfloat angle, GLfloat x, GLfloat y, GLfloat z) -{ - GET_CURRENT_CONTEXT(ctx); - Node *n; - ASSERT_OUTSIDE_SAVE_BEGIN_END_AND_FLUSH(ctx); - n = alloc_instruction(ctx, OPCODE_ROTATE, 4); - if (n) { - n[1].f = angle; - n[2].f = x; - n[3].f = y; - n[4].f = z; - } - if (ctx->ExecuteFlag) { - CALL_Rotatef(ctx->Exec, (angle, x, y, z)); - } -} - - -static void GLAPIENTRY -save_Rotated(GLdouble angle, GLdouble x, GLdouble y, GLdouble z) -{ - save_Rotatef((GLfloat) angle, (GLfloat) x, (GLfloat) y, (GLfloat) z); -} - - -static void GLAPIENTRY -save_Scalef(GLfloat x, GLfloat y, GLfloat z) -{ - GET_CURRENT_CONTEXT(ctx); - Node *n; - ASSERT_OUTSIDE_SAVE_BEGIN_END_AND_FLUSH(ctx); - n = alloc_instruction(ctx, OPCODE_SCALE, 3); - if (n) { - n[1].f = x; - n[2].f = y; - n[3].f = z; - } - if (ctx->ExecuteFlag) { - CALL_Scalef(ctx->Exec, (x, y, z)); - } -} - - -static void GLAPIENTRY -save_Scaled(GLdouble x, GLdouble y, GLdouble z) -{ - save_Scalef((GLfloat) x, (GLfloat) y, (GLfloat) z); -} - - -static void GLAPIENTRY -save_Scissor(GLint x, GLint y, GLsizei width, GLsizei height) -{ - GET_CURRENT_CONTEXT(ctx); - Node *n; - ASSERT_OUTSIDE_SAVE_BEGIN_END_AND_FLUSH(ctx); - n = alloc_instruction(ctx, OPCODE_SCISSOR, 4); - if (n) { - n[1].i = x; - n[2].i = y; - n[3].i = width; - n[4].i = height; - } - if (ctx->ExecuteFlag) { - CALL_Scissor(ctx->Exec, (x, y, width, height)); - } -} - - -static void GLAPIENTRY -save_ShadeModel(GLenum mode) -{ - GET_CURRENT_CONTEXT(ctx); - Node *n; - ASSERT_OUTSIDE_SAVE_BEGIN_END(ctx); - - if (ctx->ExecuteFlag) { - CALL_ShadeModel(ctx->Exec, (mode)); - } - - if (ctx->ListState.Current.ShadeModel == mode) - return; - - SAVE_FLUSH_VERTICES(ctx); - - /* Only save the value if we know the statechange will take effect: - */ - if (ctx->Driver.CurrentSavePrimitive == PRIM_OUTSIDE_BEGIN_END) - ctx->ListState.Current.ShadeModel = mode; - - n = alloc_instruction(ctx, OPCODE_SHADE_MODEL, 1); - if (n) { - n[1].e = mode; - } -} - - -static void GLAPIENTRY -save_StencilFunc(GLenum func, GLint ref, GLuint mask) -{ - GET_CURRENT_CONTEXT(ctx); - Node *n; - ASSERT_OUTSIDE_SAVE_BEGIN_END_AND_FLUSH(ctx); - n = alloc_instruction(ctx, OPCODE_STENCIL_FUNC, 3); - if (n) { - n[1].e = func; - n[2].i = ref; - n[3].ui = mask; - } - if (ctx->ExecuteFlag) { - CALL_StencilFunc(ctx->Exec, (func, ref, mask)); - } -} - - -static void GLAPIENTRY -save_StencilMask(GLuint mask) -{ - GET_CURRENT_CONTEXT(ctx); - Node *n; - ASSERT_OUTSIDE_SAVE_BEGIN_END_AND_FLUSH(ctx); - n = alloc_instruction(ctx, OPCODE_STENCIL_MASK, 1); - if (n) { - n[1].ui = mask; - } - if (ctx->ExecuteFlag) { - CALL_StencilMask(ctx->Exec, (mask)); - } -} - - -static void GLAPIENTRY -save_StencilOp(GLenum fail, GLenum zfail, GLenum zpass) -{ - GET_CURRENT_CONTEXT(ctx); - Node *n; - ASSERT_OUTSIDE_SAVE_BEGIN_END_AND_FLUSH(ctx); - n = alloc_instruction(ctx, OPCODE_STENCIL_OP, 3); - if (n) { - n[1].e = fail; - n[2].e = zfail; - n[3].e = zpass; - } - if (ctx->ExecuteFlag) { - CALL_StencilOp(ctx->Exec, (fail, zfail, zpass)); - } -} - - -static void GLAPIENTRY -save_TexEnvfv(GLenum target, GLenum pname, const GLfloat *params) -{ - GET_CURRENT_CONTEXT(ctx); - Node *n; - ASSERT_OUTSIDE_SAVE_BEGIN_END_AND_FLUSH(ctx); - n = alloc_instruction(ctx, OPCODE_TEXENV, 6); - if (n) { - n[1].e = target; - n[2].e = pname; - if (pname == GL_TEXTURE_ENV_COLOR) { - n[3].f = params[0]; - n[4].f = params[1]; - n[5].f = params[2]; - n[6].f = params[3]; - } - else { - n[3].f = params[0]; - n[4].f = n[5].f = n[6].f = 0.0F; - } - } - if (ctx->ExecuteFlag) { - CALL_TexEnvfv(ctx->Exec, (target, pname, params)); - } -} - - -static void GLAPIENTRY -save_TexEnvf(GLenum target, GLenum pname, GLfloat param) -{ - GLfloat parray[4]; - parray[0] = (GLfloat) param; - parray[1] = parray[2] = parray[3] = 0.0F; - save_TexEnvfv(target, pname, parray); -} - - -static void GLAPIENTRY -save_TexEnvi(GLenum target, GLenum pname, GLint param) -{ - GLfloat p[4]; - p[0] = (GLfloat) param; - p[1] = p[2] = p[3] = 0.0F; - save_TexEnvfv(target, pname, p); -} - - -static void GLAPIENTRY -save_TexEnviv(GLenum target, GLenum pname, const GLint * param) -{ - GLfloat p[4]; - if (pname == GL_TEXTURE_ENV_COLOR) { - p[0] = INT_TO_FLOAT(param[0]); - p[1] = INT_TO_FLOAT(param[1]); - p[2] = INT_TO_FLOAT(param[2]); - p[3] = INT_TO_FLOAT(param[3]); - } - else { - p[0] = (GLfloat) param[0]; - p[1] = p[2] = p[3] = 0.0F; - } - save_TexEnvfv(target, pname, p); -} - - -static void GLAPIENTRY -save_TexGenfv(GLenum coord, GLenum pname, const GLfloat *params) -{ - GET_CURRENT_CONTEXT(ctx); - Node *n; - ASSERT_OUTSIDE_SAVE_BEGIN_END_AND_FLUSH(ctx); - n = alloc_instruction(ctx, OPCODE_TEXGEN, 6); - if (n) { - n[1].e = coord; - n[2].e = pname; - n[3].f = params[0]; - n[4].f = params[1]; - n[5].f = params[2]; - n[6].f = params[3]; - } - if (ctx->ExecuteFlag) { - CALL_TexGenfv(ctx->Exec, (coord, pname, params)); - } -} - - -static void GLAPIENTRY -save_TexGeniv(GLenum coord, GLenum pname, const GLint *params) -{ - GLfloat p[4]; - p[0] = (GLfloat) params[0]; - p[1] = (GLfloat) params[1]; - p[2] = (GLfloat) params[2]; - p[3] = (GLfloat) params[3]; - save_TexGenfv(coord, pname, p); -} - - -static void GLAPIENTRY -save_TexGend(GLenum coord, GLenum pname, GLdouble param) -{ - GLfloat parray[4]; - parray[0] = (GLfloat) param; - parray[1] = parray[2] = parray[3] = 0.0F; - save_TexGenfv(coord, pname, parray); -} - - -static void GLAPIENTRY -save_TexGendv(GLenum coord, GLenum pname, const GLdouble *params) -{ - GLfloat p[4]; - p[0] = (GLfloat) params[0]; - p[1] = (GLfloat) params[1]; - p[2] = (GLfloat) params[2]; - p[3] = (GLfloat) params[3]; - save_TexGenfv(coord, pname, p); -} - - -static void GLAPIENTRY -save_TexGenf(GLenum coord, GLenum pname, GLfloat param) -{ - GLfloat parray[4]; - parray[0] = param; - parray[1] = parray[2] = parray[3] = 0.0F; - save_TexGenfv(coord, pname, parray); -} - - -static void GLAPIENTRY -save_TexGeni(GLenum coord, GLenum pname, GLint param) -{ - GLint parray[4]; - parray[0] = param; - parray[1] = parray[2] = parray[3] = 0; - save_TexGeniv(coord, pname, parray); -} - - -static void GLAPIENTRY -save_TexParameterfv(GLenum target, GLenum pname, const GLfloat *params) -{ - GET_CURRENT_CONTEXT(ctx); - Node *n; - ASSERT_OUTSIDE_SAVE_BEGIN_END_AND_FLUSH(ctx); - n = alloc_instruction(ctx, OPCODE_TEXPARAMETER, 6); - if (n) { - n[1].e = target; - n[2].e = pname; - n[3].f = params[0]; - n[4].f = params[1]; - n[5].f = params[2]; - n[6].f = params[3]; - } - if (ctx->ExecuteFlag) { - CALL_TexParameterfv(ctx->Exec, (target, pname, params)); - } -} - - -static void GLAPIENTRY -save_TexParameterf(GLenum target, GLenum pname, GLfloat param) -{ - GLfloat parray[4]; - parray[0] = param; - parray[1] = parray[2] = parray[3] = 0.0F; - save_TexParameterfv(target, pname, parray); -} - - -static void GLAPIENTRY -save_TexParameteri(GLenum target, GLenum pname, GLint param) -{ - GLfloat fparam[4]; - fparam[0] = (GLfloat) param; - fparam[1] = fparam[2] = fparam[3] = 0.0F; - save_TexParameterfv(target, pname, fparam); -} - - -static void GLAPIENTRY -save_TexParameteriv(GLenum target, GLenum pname, const GLint *params) -{ - GLfloat fparam[4]; - fparam[0] = (GLfloat) params[0]; - fparam[1] = fparam[2] = fparam[3] = 0.0F; - save_TexParameterfv(target, pname, fparam); -} - - -static void GLAPIENTRY -save_TexImage1D(GLenum target, - GLint level, GLint components, - GLsizei width, GLint border, - GLenum format, GLenum type, const GLvoid * pixels) -{ - GET_CURRENT_CONTEXT(ctx); - if (target == GL_PROXY_TEXTURE_1D) { - /* don't compile, execute immediately */ - CALL_TexImage1D(ctx->Exec, (target, level, components, width, - border, format, type, pixels)); - } - else { - Node *n; - ASSERT_OUTSIDE_SAVE_BEGIN_END_AND_FLUSH(ctx); - n = alloc_instruction(ctx, OPCODE_TEX_IMAGE1D, 8); - if (n) { - n[1].e = target; - n[2].i = level; - n[3].i = components; - n[4].i = (GLint) width; - n[5].i = border; - n[6].e = format; - n[7].e = type; - n[8].data = unpack_image(ctx, 1, width, 1, 1, format, type, - pixels, &ctx->Unpack); - } - if (ctx->ExecuteFlag) { - CALL_TexImage1D(ctx->Exec, (target, level, components, width, - border, format, type, pixels)); - } - } -} - - -static void GLAPIENTRY -save_TexImage2D(GLenum target, - GLint level, GLint components, - GLsizei width, GLsizei height, GLint border, - GLenum format, GLenum type, const GLvoid * pixels) -{ - GET_CURRENT_CONTEXT(ctx); - if (target == GL_PROXY_TEXTURE_2D) { - /* don't compile, execute immediately */ - CALL_TexImage2D(ctx->Exec, (target, level, components, width, - height, border, format, type, pixels)); - } - else { - Node *n; - ASSERT_OUTSIDE_SAVE_BEGIN_END_AND_FLUSH(ctx); - n = alloc_instruction(ctx, OPCODE_TEX_IMAGE2D, 9); - if (n) { - n[1].e = target; - n[2].i = level; - n[3].i = components; - n[4].i = (GLint) width; - n[5].i = (GLint) height; - n[6].i = border; - n[7].e = format; - n[8].e = type; - n[9].data = unpack_image(ctx, 2, width, height, 1, format, type, - pixels, &ctx->Unpack); - } - if (ctx->ExecuteFlag) { - CALL_TexImage2D(ctx->Exec, (target, level, components, width, - height, border, format, type, pixels)); - } - } -} - - -static void GLAPIENTRY -save_TexSubImage1D(GLenum target, GLint level, GLint xoffset, - GLsizei width, GLenum format, GLenum type, - const GLvoid * pixels) -{ - GET_CURRENT_CONTEXT(ctx); - Node *n; - - ASSERT_OUTSIDE_SAVE_BEGIN_END_AND_FLUSH(ctx); - - n = alloc_instruction(ctx, OPCODE_TEX_SUB_IMAGE1D, 7); - if (n) { - n[1].e = target; - n[2].i = level; - n[3].i = xoffset; - n[4].i = (GLint) width; - n[5].e = format; - n[6].e = type; - n[7].data = unpack_image(ctx, 1, width, 1, 1, format, type, - pixels, &ctx->Unpack); - } - if (ctx->ExecuteFlag) { - CALL_TexSubImage1D(ctx->Exec, (target, level, xoffset, width, - format, type, pixels)); - } -} - - -static void GLAPIENTRY -save_TexSubImage2D(GLenum target, GLint level, - GLint xoffset, GLint yoffset, - GLsizei width, GLsizei height, - GLenum format, GLenum type, const GLvoid * pixels) -{ - GET_CURRENT_CONTEXT(ctx); - Node *n; - - ASSERT_OUTSIDE_SAVE_BEGIN_END_AND_FLUSH(ctx); - - n = alloc_instruction(ctx, OPCODE_TEX_SUB_IMAGE2D, 9); - if (n) { - n[1].e = target; - n[2].i = level; - n[3].i = xoffset; - n[4].i = yoffset; - n[5].i = (GLint) width; - n[6].i = (GLint) height; - n[7].e = format; - n[8].e = type; - n[9].data = unpack_image(ctx, 2, width, height, 1, format, type, - pixels, &ctx->Unpack); - } - if (ctx->ExecuteFlag) { - CALL_TexSubImage2D(ctx->Exec, (target, level, xoffset, yoffset, - width, height, format, type, pixels)); - } -} - - -static void GLAPIENTRY -save_Translatef(GLfloat x, GLfloat y, GLfloat z) -{ - GET_CURRENT_CONTEXT(ctx); - Node *n; - ASSERT_OUTSIDE_SAVE_BEGIN_END_AND_FLUSH(ctx); - n = alloc_instruction(ctx, OPCODE_TRANSLATE, 3); - if (n) { - n[1].f = x; - n[2].f = y; - n[3].f = z; - } - if (ctx->ExecuteFlag) { - CALL_Translatef(ctx->Exec, (x, y, z)); - } -} - - -static void GLAPIENTRY -save_Translated(GLdouble x, GLdouble y, GLdouble z) -{ - save_Translatef((GLfloat) x, (GLfloat) y, (GLfloat) z); -} - - - -static void GLAPIENTRY -save_Viewport(GLint x, GLint y, GLsizei width, GLsizei height) -{ - GET_CURRENT_CONTEXT(ctx); - Node *n; - ASSERT_OUTSIDE_SAVE_BEGIN_END_AND_FLUSH(ctx); - n = alloc_instruction(ctx, OPCODE_VIEWPORT, 4); - if (n) { - n[1].i = x; - n[2].i = y; - n[3].i = (GLint) width; - n[4].i = (GLint) height; - } - if (ctx->ExecuteFlag) { - CALL_Viewport(ctx->Exec, (x, y, width, height)); - } -} - - -static void GLAPIENTRY -save_WindowPos4fMESA(GLfloat x, GLfloat y, GLfloat z, GLfloat w) -{ - GET_CURRENT_CONTEXT(ctx); - Node *n; - ASSERT_OUTSIDE_SAVE_BEGIN_END_AND_FLUSH(ctx); - n = alloc_instruction(ctx, OPCODE_WINDOW_POS, 4); - if (n) { - n[1].f = x; - n[2].f = y; - n[3].f = z; - n[4].f = w; - } - if (ctx->ExecuteFlag) { - CALL_WindowPos4fMESA(ctx->Exec, (x, y, z, w)); - } -} - -static void GLAPIENTRY -save_WindowPos2dMESA(GLdouble x, GLdouble y) -{ - save_WindowPos4fMESA((GLfloat) x, (GLfloat) y, 0.0F, 1.0F); -} - -static void GLAPIENTRY -save_WindowPos2fMESA(GLfloat x, GLfloat y) -{ - save_WindowPos4fMESA(x, y, 0.0F, 1.0F); -} - -static void GLAPIENTRY -save_WindowPos2iMESA(GLint x, GLint y) -{ - save_WindowPos4fMESA((GLfloat) x, (GLfloat) y, 0.0F, 1.0F); -} - -static void GLAPIENTRY -save_WindowPos2sMESA(GLshort x, GLshort y) -{ - save_WindowPos4fMESA(x, y, 0.0F, 1.0F); -} - -static void GLAPIENTRY -save_WindowPos3dMESA(GLdouble x, GLdouble y, GLdouble z) -{ - save_WindowPos4fMESA((GLfloat) x, (GLfloat) y, (GLfloat) z, 1.0F); -} - -static void GLAPIENTRY -save_WindowPos3fMESA(GLfloat x, GLfloat y, GLfloat z) -{ - save_WindowPos4fMESA(x, y, z, 1.0F); -} - -static void GLAPIENTRY -save_WindowPos3iMESA(GLint x, GLint y, GLint z) -{ - save_WindowPos4fMESA((GLfloat) x, (GLfloat) y, (GLfloat) z, 1.0F); -} - -static void GLAPIENTRY -save_WindowPos3sMESA(GLshort x, GLshort y, GLshort z) -{ - save_WindowPos4fMESA(x, y, z, 1.0F); -} - -static void GLAPIENTRY -save_WindowPos4dMESA(GLdouble x, GLdouble y, GLdouble z, GLdouble w) -{ - save_WindowPos4fMESA((GLfloat) x, (GLfloat) y, (GLfloat) z, (GLfloat) w); -} - -static void GLAPIENTRY -save_WindowPos4iMESA(GLint x, GLint y, GLint z, GLint w) -{ - save_WindowPos4fMESA((GLfloat) x, (GLfloat) y, (GLfloat) z, (GLfloat) w); -} - -static void GLAPIENTRY -save_WindowPos4sMESA(GLshort x, GLshort y, GLshort z, GLshort w) -{ - save_WindowPos4fMESA(x, y, z, w); -} - -static void GLAPIENTRY -save_WindowPos2dvMESA(const GLdouble * v) -{ - save_WindowPos4fMESA((GLfloat) v[0], (GLfloat) v[1], 0.0F, 1.0F); -} - -static void GLAPIENTRY -save_WindowPos2fvMESA(const GLfloat * v) -{ - save_WindowPos4fMESA(v[0], v[1], 0.0F, 1.0F); -} - -static void GLAPIENTRY -save_WindowPos2ivMESA(const GLint * v) -{ - save_WindowPos4fMESA((GLfloat) v[0], (GLfloat) v[1], 0.0F, 1.0F); -} - -static void GLAPIENTRY -save_WindowPos2svMESA(const GLshort * v) -{ - save_WindowPos4fMESA(v[0], v[1], 0.0F, 1.0F); -} - -static void GLAPIENTRY -save_WindowPos3dvMESA(const GLdouble * v) -{ - save_WindowPos4fMESA((GLfloat) v[0], (GLfloat) v[1], (GLfloat) v[2], 1.0F); -} - -static void GLAPIENTRY -save_WindowPos3fvMESA(const GLfloat * v) -{ - save_WindowPos4fMESA(v[0], v[1], v[2], 1.0F); -} - -static void GLAPIENTRY -save_WindowPos3ivMESA(const GLint * v) -{ - save_WindowPos4fMESA((GLfloat) v[0], (GLfloat) v[1], (GLfloat) v[2], 1.0F); -} - -static void GLAPIENTRY -save_WindowPos3svMESA(const GLshort * v) -{ - save_WindowPos4fMESA(v[0], v[1], v[2], 1.0F); -} - -static void GLAPIENTRY -save_WindowPos4dvMESA(const GLdouble * v) -{ - save_WindowPos4fMESA((GLfloat) v[0], (GLfloat) v[1], - (GLfloat) v[2], (GLfloat) v[3]); -} - -static void GLAPIENTRY -save_WindowPos4fvMESA(const GLfloat * v) -{ - save_WindowPos4fMESA(v[0], v[1], v[2], v[3]); -} - -static void GLAPIENTRY -save_WindowPos4ivMESA(const GLint * v) -{ - save_WindowPos4fMESA((GLfloat) v[0], (GLfloat) v[1], - (GLfloat) v[2], (GLfloat) v[3]); -} - -static void GLAPIENTRY -save_WindowPos4svMESA(const GLshort * v) -{ - save_WindowPos4fMESA(v[0], v[1], v[2], v[3]); -} - - -/* GL_ARB_transpose_matrix */ - -static void GLAPIENTRY -save_LoadTransposeMatrixdARB(const GLdouble m[16]) -{ - GLfloat tm[16]; - _math_transposefd(tm, m); - save_LoadMatrixf(tm); -} - - -static void GLAPIENTRY -save_LoadTransposeMatrixfARB(const GLfloat m[16]) -{ - GLfloat tm[16]; - _math_transposef(tm, m); - save_LoadMatrixf(tm); -} - - -static void GLAPIENTRY -save_MultTransposeMatrixdARB(const GLdouble m[16]) -{ - GLfloat tm[16]; - _math_transposefd(tm, m); - save_MultMatrixf(tm); -} - - -static void GLAPIENTRY -save_MultTransposeMatrixfARB(const GLfloat m[16]) -{ - GLfloat tm[16]; - _math_transposef(tm, m); - save_MultMatrixf(tm); -} - - -/* GL_ARB_multisample */ -static void GLAPIENTRY -save_SampleCoverageARB(GLclampf value, GLboolean invert) -{ - GET_CURRENT_CONTEXT(ctx); - Node *n; - ASSERT_OUTSIDE_SAVE_BEGIN_END_AND_FLUSH(ctx); - n = alloc_instruction(ctx, OPCODE_SAMPLE_COVERAGE, 2); - if (n) { - n[1].f = value; - n[2].b = invert; - } - if (ctx->ExecuteFlag) { - CALL_SampleCoverageARB(ctx->Exec, (value, invert)); - } -} - - -/* GL_EXT_depth_bounds_test */ -static void GLAPIENTRY -save_DepthBoundsEXT(GLclampd zmin, GLclampd zmax) -{ - GET_CURRENT_CONTEXT(ctx); - Node *n; - ASSERT_OUTSIDE_SAVE_BEGIN_END_AND_FLUSH(ctx); - n = alloc_instruction(ctx, OPCODE_DEPTH_BOUNDS_EXT, 2); - if (n) { - n[1].f = (GLfloat) zmin; - n[2].f = (GLfloat) zmax; - } - if (ctx->ExecuteFlag) { - CALL_DepthBoundsEXT(ctx->Exec, (zmin, zmax)); - } -} - -static void GLAPIENTRY -save_Attr1fNV(GLenum attr, GLfloat x) -{ - GET_CURRENT_CONTEXT(ctx); - Node *n; - SAVE_FLUSH_VERTICES(ctx); - n = alloc_instruction(ctx, OPCODE_ATTR_1F_NV, 2); - if (n) { - n[1].e = attr; - n[2].f = x; - } - - ASSERT(attr < MAX_VERTEX_GENERIC_ATTRIBS); - ctx->ListState.ActiveAttribSize[attr] = 1; - ASSIGN_4V(ctx->ListState.CurrentAttrib[attr], x, 0, 0, 1); - - if (ctx->ExecuteFlag) { - CALL_VertexAttrib1fNV(ctx->Exec, (attr, x)); - } -} - -static void GLAPIENTRY -save_Attr2fNV(GLenum attr, GLfloat x, GLfloat y) -{ - GET_CURRENT_CONTEXT(ctx); - Node *n; - SAVE_FLUSH_VERTICES(ctx); - n = alloc_instruction(ctx, OPCODE_ATTR_2F_NV, 3); - if (n) { - n[1].e = attr; - n[2].f = x; - n[3].f = y; - } - - ASSERT(attr < MAX_VERTEX_GENERIC_ATTRIBS); - ctx->ListState.ActiveAttribSize[attr] = 2; - ASSIGN_4V(ctx->ListState.CurrentAttrib[attr], x, y, 0, 1); - - if (ctx->ExecuteFlag) { - CALL_VertexAttrib2fNV(ctx->Exec, (attr, x, y)); - } -} - -static void GLAPIENTRY -save_Attr3fNV(GLenum attr, GLfloat x, GLfloat y, GLfloat z) -{ - GET_CURRENT_CONTEXT(ctx); - Node *n; - SAVE_FLUSH_VERTICES(ctx); - n = alloc_instruction(ctx, OPCODE_ATTR_3F_NV, 4); - if (n) { - n[1].e = attr; - n[2].f = x; - n[3].f = y; - n[4].f = z; - } - - ASSERT(attr < MAX_VERTEX_GENERIC_ATTRIBS); - ctx->ListState.ActiveAttribSize[attr] = 3; - ASSIGN_4V(ctx->ListState.CurrentAttrib[attr], x, y, z, 1); - - if (ctx->ExecuteFlag) { - CALL_VertexAttrib3fNV(ctx->Exec, (attr, x, y, z)); - } -} - -static void GLAPIENTRY -save_Attr4fNV(GLenum attr, GLfloat x, GLfloat y, GLfloat z, GLfloat w) -{ - GET_CURRENT_CONTEXT(ctx); - Node *n; - SAVE_FLUSH_VERTICES(ctx); - n = alloc_instruction(ctx, OPCODE_ATTR_4F_NV, 5); - if (n) { - n[1].e = attr; - n[2].f = x; - n[3].f = y; - n[4].f = z; - n[5].f = w; - } - - ASSERT(attr < MAX_VERTEX_GENERIC_ATTRIBS); - ctx->ListState.ActiveAttribSize[attr] = 4; - ASSIGN_4V(ctx->ListState.CurrentAttrib[attr], x, y, z, w); - - if (ctx->ExecuteFlag) { - CALL_VertexAttrib4fNV(ctx->Exec, (attr, x, y, z, w)); - } -} - -static void GLAPIENTRY -save_EvalCoord1f(GLfloat x) -{ - GET_CURRENT_CONTEXT(ctx); - Node *n; - SAVE_FLUSH_VERTICES(ctx); - n = alloc_instruction(ctx, OPCODE_EVAL_C1, 1); - if (n) { - n[1].f = x; - } - if (ctx->ExecuteFlag) { - CALL_EvalCoord1f(ctx->Exec, (x)); - } -} - -static void GLAPIENTRY -save_EvalCoord1fv(const GLfloat * v) -{ - save_EvalCoord1f(v[0]); -} - -static void GLAPIENTRY -save_EvalCoord2f(GLfloat x, GLfloat y) -{ - GET_CURRENT_CONTEXT(ctx); - Node *n; - SAVE_FLUSH_VERTICES(ctx); - n = alloc_instruction(ctx, OPCODE_EVAL_C2, 2); - if (n) { - n[1].f = x; - n[2].f = y; - } - if (ctx->ExecuteFlag) { - CALL_EvalCoord2f(ctx->Exec, (x, y)); - } -} - -static void GLAPIENTRY -save_EvalCoord2fv(const GLfloat * v) -{ - save_EvalCoord2f(v[0], v[1]); -} - - -static void GLAPIENTRY -save_EvalPoint1(GLint x) -{ - GET_CURRENT_CONTEXT(ctx); - Node *n; - SAVE_FLUSH_VERTICES(ctx); - n = alloc_instruction(ctx, OPCODE_EVAL_P1, 1); - if (n) { - n[1].i = x; - } - if (ctx->ExecuteFlag) { - CALL_EvalPoint1(ctx->Exec, (x)); - } -} - -static void GLAPIENTRY -save_EvalPoint2(GLint x, GLint y) -{ - GET_CURRENT_CONTEXT(ctx); - Node *n; - SAVE_FLUSH_VERTICES(ctx); - n = alloc_instruction(ctx, OPCODE_EVAL_P2, 2); - if (n) { - n[1].i = x; - n[2].i = y; - } - if (ctx->ExecuteFlag) { - CALL_EvalPoint2(ctx->Exec, (x, y)); - } -} - -static void GLAPIENTRY -save_Indexf(GLfloat x) -{ - save_Attr1fNV(VERT_ATTRIB_COLOR_INDEX, x); -} - -static void GLAPIENTRY -save_Indexfv(const GLfloat * v) -{ - save_Attr1fNV(VERT_ATTRIB_COLOR_INDEX, v[0]); -} - -static void GLAPIENTRY -save_EdgeFlag(GLboolean x) -{ - save_Attr1fNV(VERT_ATTRIB_EDGEFLAG, x ? (GLfloat)1.0 : (GLfloat)0.0); -} - -static inline GLboolean compare4fv( const GLfloat *a, - const GLfloat *b, - GLuint count ) -{ - return memcmp( a, b, count * sizeof(GLfloat) ) == 0; -} - - -static void GLAPIENTRY -save_Materialfv(GLenum face, GLenum pname, const GLfloat * param) -{ - GET_CURRENT_CONTEXT(ctx); - Node *n; - int args, i; - GLuint bitmask; - - switch (face) { - case GL_BACK: - case GL_FRONT: - case GL_FRONT_AND_BACK: - break; - default: - _mesa_compile_error(ctx, GL_INVALID_ENUM, "material(face)"); - return; - } - - switch (pname) { - case GL_EMISSION: - case GL_AMBIENT: - case GL_DIFFUSE: - case GL_SPECULAR: - case GL_AMBIENT_AND_DIFFUSE: - args = 4; - break; - case GL_SHININESS: - args = 1; - break; - case GL_COLOR_INDEXES: - args = 3; - break; - default: - _mesa_compile_error(ctx, GL_INVALID_ENUM, "material(pname)"); - return; - } - - if (ctx->ExecuteFlag) { - CALL_Materialfv(ctx->Exec, (face, pname, param)); - } - - bitmask = _mesa_material_bitmask(ctx, face, pname, ~0, NULL); - - /* Try to eliminate redundant statechanges. Because it is legal to - * call glMaterial even inside begin/end calls, don't need to worry - * about ctx->Driver.CurrentSavePrimitive here. - */ - for (i = 0; i < MAT_ATTRIB_MAX; i++) { - if (bitmask & (1 << i)) { - if (ctx->ListState.ActiveMaterialSize[i] == args && - compare4fv(ctx->ListState.CurrentMaterial[i], param, args)) { - bitmask &= ~(1 << i); - } - else { - ctx->ListState.ActiveMaterialSize[i] = args; - COPY_SZ_4V(ctx->ListState.CurrentMaterial[i], args, param); - } - } - } - - /* If this call has effect, return early: - */ - if (bitmask == 0) - return; - - SAVE_FLUSH_VERTICES(ctx); - - n = alloc_instruction(ctx, OPCODE_MATERIAL, 6); - if (n) { - n[1].e = face; - n[2].e = pname; - for (i = 0; i < args; i++) - n[3 + i].f = param[i]; - } -} - -static void GLAPIENTRY -save_Begin(GLenum mode) -{ - GET_CURRENT_CONTEXT(ctx); - Node *n; - GLboolean error = GL_FALSE; - - if (!_mesa_valid_prim_mode(ctx, mode)) { - _mesa_compile_error(ctx, GL_INVALID_ENUM, "glBegin(mode)"); - error = GL_TRUE; - } - else if (ctx->Driver.CurrentSavePrimitive == PRIM_UNKNOWN) { - /* Typically the first begin. This may raise an error on - * playback, depending on whether CallList is issued from inside - * a begin/end or not. - */ - ctx->Driver.CurrentSavePrimitive = PRIM_INSIDE_UNKNOWN_PRIM; - } - else if (ctx->Driver.CurrentSavePrimitive == PRIM_OUTSIDE_BEGIN_END) { - ctx->Driver.CurrentSavePrimitive = mode; - } - else { - _mesa_compile_error(ctx, GL_INVALID_OPERATION, "recursive begin"); - error = GL_TRUE; - } - - if (!error) { - /* Give the driver an opportunity to hook in an optimized - * display list compiler. - */ - if (ctx->Driver.NotifySaveBegin(ctx, mode)) - return; - - SAVE_FLUSH_VERTICES(ctx); - n = alloc_instruction(ctx, OPCODE_BEGIN, 1); - if (n) { - n[1].e = mode; - } - } - - if (ctx->ExecuteFlag) { - CALL_Begin(ctx->Exec, (mode)); - } -} - -static void GLAPIENTRY -save_End(void) -{ - GET_CURRENT_CONTEXT(ctx); - SAVE_FLUSH_VERTICES(ctx); - (void) alloc_instruction(ctx, OPCODE_END, 0); - ctx->Driver.CurrentSavePrimitive = PRIM_OUTSIDE_BEGIN_END; - if (ctx->ExecuteFlag) { - CALL_End(ctx->Exec, ()); - } -} - -static void GLAPIENTRY -save_Rectf(GLfloat a, GLfloat b, GLfloat c, GLfloat d) -{ - GET_CURRENT_CONTEXT(ctx); - Node *n; - SAVE_FLUSH_VERTICES(ctx); - n = alloc_instruction(ctx, OPCODE_RECTF, 4); - if (n) { - n[1].f = a; - n[2].f = b; - n[3].f = c; - n[4].f = d; - } - if (ctx->ExecuteFlag) { - CALL_Rectf(ctx->Exec, (a, b, c, d)); - } -} - - -static void GLAPIENTRY -save_Vertex2f(GLfloat x, GLfloat y) -{ - save_Attr2fNV(VERT_ATTRIB_POS, x, y); -} - -static void GLAPIENTRY -save_Vertex2fv(const GLfloat * v) -{ - save_Attr2fNV(VERT_ATTRIB_POS, v[0], v[1]); -} - -static void GLAPIENTRY -save_Vertex3f(GLfloat x, GLfloat y, GLfloat z) -{ - save_Attr3fNV(VERT_ATTRIB_POS, x, y, z); -} - -static void GLAPIENTRY -save_Vertex3fv(const GLfloat * v) -{ - save_Attr3fNV(VERT_ATTRIB_POS, v[0], v[1], v[2]); -} - -static void GLAPIENTRY -save_Vertex4f(GLfloat x, GLfloat y, GLfloat z, GLfloat w) -{ - save_Attr4fNV(VERT_ATTRIB_POS, x, y, z, w); -} - -static void GLAPIENTRY -save_Vertex4fv(const GLfloat * v) -{ - save_Attr4fNV(VERT_ATTRIB_POS, v[0], v[1], v[2], v[3]); -} - -static void GLAPIENTRY -save_TexCoord1f(GLfloat x) -{ - save_Attr1fNV(VERT_ATTRIB_TEX, x); -} - -static void GLAPIENTRY -save_TexCoord1fv(const GLfloat * v) -{ - save_Attr1fNV(VERT_ATTRIB_TEX, v[0]); -} - -static void GLAPIENTRY -save_TexCoord2f(GLfloat x, GLfloat y) -{ - save_Attr2fNV(VERT_ATTRIB_TEX, x, y); -} - -static void GLAPIENTRY -save_TexCoord2fv(const GLfloat * v) -{ - save_Attr2fNV(VERT_ATTRIB_TEX, v[0], v[1]); -} - -static void GLAPIENTRY -save_TexCoord3f(GLfloat x, GLfloat y, GLfloat z) -{ - save_Attr3fNV(VERT_ATTRIB_TEX, x, y, z); -} - -static void GLAPIENTRY -save_TexCoord3fv(const GLfloat * v) -{ - save_Attr3fNV(VERT_ATTRIB_TEX, v[0], v[1], v[2]); -} - -static void GLAPIENTRY -save_TexCoord4f(GLfloat x, GLfloat y, GLfloat z, GLfloat w) -{ - save_Attr4fNV(VERT_ATTRIB_TEX, x, y, z, w); -} - -static void GLAPIENTRY -save_TexCoord4fv(const GLfloat * v) -{ - save_Attr4fNV(VERT_ATTRIB_TEX, v[0], v[1], v[2], v[3]); -} - -static void GLAPIENTRY -save_Normal3f(GLfloat x, GLfloat y, GLfloat z) -{ - save_Attr3fNV(VERT_ATTRIB_NORMAL, x, y, z); -} - -static void GLAPIENTRY -save_Normal3fv(const GLfloat * v) -{ - save_Attr3fNV(VERT_ATTRIB_NORMAL, v[0], v[1], v[2]); -} - -static void GLAPIENTRY -save_FogCoordfEXT(GLfloat x) -{ - save_Attr1fNV(VERT_ATTRIB_FOG, x); -} - -static void GLAPIENTRY -save_FogCoordfvEXT(const GLfloat * v) -{ - save_Attr1fNV(VERT_ATTRIB_FOG, v[0]); -} - -static void GLAPIENTRY -save_Color3f(GLfloat x, GLfloat y, GLfloat z) -{ - save_Attr3fNV(VERT_ATTRIB_COLOR, x, y, z); -} - -static void GLAPIENTRY -save_Color3fv(const GLfloat * v) -{ - save_Attr3fNV(VERT_ATTRIB_COLOR, v[0], v[1], v[2]); -} - -static void GLAPIENTRY -save_Color4f(GLfloat x, GLfloat y, GLfloat z, GLfloat w) -{ - save_Attr4fNV(VERT_ATTRIB_COLOR, x, y, z, w); -} - -static void GLAPIENTRY -save_Color4fv(const GLfloat * v) -{ - save_Attr4fNV(VERT_ATTRIB_COLOR, v[0], v[1], v[2], v[3]); -} - - -/** - * Record a GL_INVALID_VALUE error when a invalid vertex attribute - * index is found. - */ -static void -index_error(void) -{ - GET_CURRENT_CONTEXT(ctx); - _mesa_error(ctx, GL_INVALID_VALUE, "VertexAttribf(index)"); -} - - -/* First level for NV_vertex_program: - * - * Check for errors at compile time?. - */ -static void GLAPIENTRY -save_VertexAttrib1fNV(GLuint index, GLfloat x) -{ - if (index < MAX_NV_VERTEX_PROGRAM_INPUTS) - save_Attr1fNV(index, x); - else - index_error(); -} - -static void GLAPIENTRY -save_VertexAttrib1fvNV(GLuint index, const GLfloat * v) -{ - if (index < MAX_NV_VERTEX_PROGRAM_INPUTS) - save_Attr1fNV(index, v[0]); - else - index_error(); -} - -static void GLAPIENTRY -save_VertexAttrib2fNV(GLuint index, GLfloat x, GLfloat y) -{ - if (index < MAX_NV_VERTEX_PROGRAM_INPUTS) - save_Attr2fNV(index, x, y); - else - index_error(); -} - -static void GLAPIENTRY -save_VertexAttrib2fvNV(GLuint index, const GLfloat * v) -{ - if (index < MAX_NV_VERTEX_PROGRAM_INPUTS) - save_Attr2fNV(index, v[0], v[1]); - else - index_error(); -} - -static void GLAPIENTRY -save_VertexAttrib3fNV(GLuint index, GLfloat x, GLfloat y, GLfloat z) -{ - if (index < MAX_NV_VERTEX_PROGRAM_INPUTS) - save_Attr3fNV(index, x, y, z); - else - index_error(); -} - -static void GLAPIENTRY -save_VertexAttrib3fvNV(GLuint index, const GLfloat * v) -{ - if (index < MAX_NV_VERTEX_PROGRAM_INPUTS) - save_Attr3fNV(index, v[0], v[1], v[2]); - else - index_error(); -} - -static void GLAPIENTRY -save_VertexAttrib4fNV(GLuint index, GLfloat x, GLfloat y, - GLfloat z, GLfloat w) -{ - if (index < MAX_NV_VERTEX_PROGRAM_INPUTS) - save_Attr4fNV(index, x, y, z, w); - else - index_error(); -} - -static void GLAPIENTRY -save_VertexAttrib4fvNV(GLuint index, const GLfloat * v) -{ - if (index < MAX_NV_VERTEX_PROGRAM_INPUTS) - save_Attr4fNV(index, v[0], v[1], v[2], v[3]); - else - index_error(); -} - - -/** GL_EXT_texture_integer */ -static void GLAPIENTRY -save_ClearColorIi(GLint red, GLint green, GLint blue, GLint alpha) -{ - GET_CURRENT_CONTEXT(ctx); - Node *n; - ASSERT_OUTSIDE_SAVE_BEGIN_END_AND_FLUSH(ctx); - n = alloc_instruction(ctx, OPCODE_CLEARCOLOR_I, 4); - if (n) { - n[1].i = red; - n[2].i = green; - n[3].i = blue; - n[4].i = alpha; - } - if (ctx->ExecuteFlag) { - CALL_ClearColorIiEXT(ctx->Exec, (red, green, blue, alpha)); - } -} - -/** GL_EXT_texture_integer */ -static void GLAPIENTRY -save_ClearColorIui(GLuint red, GLuint green, GLuint blue, GLuint alpha) -{ - GET_CURRENT_CONTEXT(ctx); - Node *n; - ASSERT_OUTSIDE_SAVE_BEGIN_END_AND_FLUSH(ctx); - n = alloc_instruction(ctx, OPCODE_CLEARCOLOR_UI, 4); - if (n) { - n[1].ui = red; - n[2].ui = green; - n[3].ui = blue; - n[4].ui = alpha; - } - if (ctx->ExecuteFlag) { - CALL_ClearColorIuiEXT(ctx->Exec, (red, green, blue, alpha)); - } -} - -/** GL_EXT_texture_integer */ -static void GLAPIENTRY -save_TexParameterIiv(GLenum target, GLenum pname, const GLint *params) -{ - GET_CURRENT_CONTEXT(ctx); - Node *n; - ASSERT_OUTSIDE_SAVE_BEGIN_END_AND_FLUSH(ctx); - n = alloc_instruction(ctx, OPCODE_TEXPARAMETER_I, 6); - if (n) { - n[1].e = target; - n[2].e = pname; - n[3].i = params[0]; - n[4].i = params[1]; - n[5].i = params[2]; - n[6].i = params[3]; - } - if (ctx->ExecuteFlag) { - CALL_TexParameterIivEXT(ctx->Exec, (target, pname, params)); - } -} - -/** GL_EXT_texture_integer */ -static void GLAPIENTRY -save_TexParameterIuiv(GLenum target, GLenum pname, const GLuint *params) -{ - GET_CURRENT_CONTEXT(ctx); - Node *n; - ASSERT_OUTSIDE_SAVE_BEGIN_END_AND_FLUSH(ctx); - n = alloc_instruction(ctx, OPCODE_TEXPARAMETER_UI, 6); - if (n) { - n[1].e = target; - n[2].e = pname; - n[3].ui = params[0]; - n[4].ui = params[1]; - n[5].ui = params[2]; - n[6].ui = params[3]; - } - if (ctx->ExecuteFlag) { - CALL_TexParameterIuivEXT(ctx->Exec, (target, pname, params)); - } -} - -/** GL_EXT_texture_integer */ -static void GLAPIENTRY -exec_GetTexParameterIiv(GLenum target, GLenum pname, GLint *params) -{ - GET_CURRENT_CONTEXT(ctx); - FLUSH_VERTICES(ctx, 0); - CALL_GetTexParameterIivEXT(ctx->Exec, (target, pname, params)); -} - -/** GL_EXT_texture_integer */ -static void GLAPIENTRY -exec_GetTexParameterIuiv(GLenum target, GLenum pname, GLuint *params) -{ - GET_CURRENT_CONTEXT(ctx); - FLUSH_VERTICES(ctx, 0); - CALL_GetTexParameterIuivEXT(ctx->Exec, (target, pname, params)); -} - -/** - * Save an error-generating command into display list. - * - * KW: Will appear in the list before the vertex buffer containing the - * command that provoked the error. I don't see this as a problem. - */ -static void -save_error(struct gl_context *ctx, GLenum error, const char *s) -{ - Node *n; - n = alloc_instruction(ctx, OPCODE_ERROR, 2); - if (n) { - n[1].e = error; - n[2].data = (void *) s; - } -} - - -/** - * Compile an error into current display list. - */ -void -_mesa_compile_error(struct gl_context *ctx, GLenum error, const char *s) -{ - if (ctx->CompileFlag) - save_error(ctx, error, s); - if (ctx->ExecuteFlag) - _mesa_error(ctx, error, "%s", s); -} - - -/** - * Test if ID names a display list. - */ -static GLboolean -islist(struct gl_context *ctx, GLuint list) -{ - if (list > 0 && lookup_list(ctx, list)) { - return GL_TRUE; - } - else { - return GL_FALSE; - } -} - - - -/**********************************************************************/ -/* Display list execution */ -/**********************************************************************/ - - -/* - * Execute a display list. Note that the ListBase offset must have already - * been added before calling this function. I.e. the list argument is - * the absolute list number, not relative to ListBase. - * \param list - display list number - */ -static void -execute_list(struct gl_context *ctx, GLuint list) -{ - struct gl_display_list *dlist; - Node *n; - GLboolean done; - - if (list == 0 || !islist(ctx, list)) - return; - - if (ctx->ListState.CallDepth == MAX_LIST_NESTING) { - /* raise an error? */ - return; - } - - dlist = lookup_list(ctx, list); - if (!dlist) - return; - - ctx->ListState.CallDepth++; - - if (ctx->Driver.BeginCallList) - ctx->Driver.BeginCallList(ctx, dlist); - - n = dlist->Head; - - done = GL_FALSE; - while (!done) { - const OpCode opcode = n[0].opcode; - - if (is_ext_opcode(opcode)) { - n += ext_opcode_execute(ctx, n); - } - else { - switch (opcode) { - case OPCODE_ERROR: - _mesa_error(ctx, n[1].e, "%s", (const char *) n[2].data); - break; - case OPCODE_ACCUM: - CALL_Accum(ctx->Exec, (n[1].e, n[2].f)); - break; - case OPCODE_ALPHA_FUNC: - CALL_AlphaFunc(ctx->Exec, (n[1].e, n[2].f)); - break; - case OPCODE_BIND_TEXTURE: - CALL_BindTexture(ctx->Exec, (n[1].e, n[2].ui)); - break; - case OPCODE_BITMAP: - { - const struct gl_pixelstore_attrib save = ctx->Unpack; - ctx->Unpack = ctx->DefaultPacking; - CALL_Bitmap(ctx->Exec, ((GLsizei) n[1].i, (GLsizei) n[2].i, - n[3].f, n[4].f, n[5].f, n[6].f, - (const GLubyte *) n[7].data)); - ctx->Unpack = save; /* restore */ - } - break; - case OPCODE_BLEND_FUNC: - CALL_BlendFunc(ctx->Exec, (n[1].e, n[2].e)); - break; - case OPCODE_CALL_LIST: - /* Generated by glCallList(), don't add ListBase */ - if (ctx->ListState.CallDepth < MAX_LIST_NESTING) { - execute_list(ctx, n[1].ui); - } - break; - case OPCODE_CALL_LIST_OFFSET: - /* Generated by glCallLists() so we must add ListBase */ - if (n[2].b) { - /* user specified a bad data type at compile time */ - _mesa_error(ctx, GL_INVALID_ENUM, "glCallLists(type)"); - } - else if (ctx->ListState.CallDepth < MAX_LIST_NESTING) { - GLuint list = (GLuint) (ctx->List.ListBase + n[1].i); - execute_list(ctx, list); - } - break; - case OPCODE_CLEAR: - CALL_Clear(ctx->Exec, (n[1].bf)); - break; - case OPCODE_CLEAR_COLOR: - CALL_ClearColor(ctx->Exec, (n[1].f, n[2].f, n[3].f, n[4].f)); - break; - case OPCODE_CLEAR_ACCUM: - CALL_ClearAccum(ctx->Exec, (n[1].f, n[2].f, n[3].f, n[4].f)); - break; - case OPCODE_CLEAR_DEPTH: - CALL_ClearDepth(ctx->Exec, ((GLclampd) n[1].f)); - break; - case OPCODE_CLEAR_INDEX: - CALL_ClearIndex(ctx->Exec, ((GLfloat) n[1].ui)); - break; - case OPCODE_CLEAR_STENCIL: - CALL_ClearStencil(ctx->Exec, (n[1].i)); - break; - case OPCODE_CLIP_PLANE: - { - GLdouble eq[4]; - eq[0] = n[2].f; - eq[1] = n[3].f; - eq[2] = n[4].f; - eq[3] = n[5].f; - CALL_ClipPlane(ctx->Exec, (n[1].e, eq)); - } - break; - case OPCODE_COLOR_MASK: - CALL_ColorMask(ctx->Exec, (n[1].b, n[2].b, n[3].b, n[4].b)); - break; - case OPCODE_COLOR_MATERIAL: - CALL_ColorMaterial(ctx->Exec, (n[1].e, n[2].e)); - break; - case OPCODE_COPY_PIXELS: - CALL_CopyPixels(ctx->Exec, (n[1].i, n[2].i, - (GLsizei) n[3].i, (GLsizei) n[4].i, - n[5].e)); - break; - case OPCODE_COPY_TEX_IMAGE1D: - CALL_CopyTexImage1D(ctx->Exec, (n[1].e, n[2].i, n[3].e, n[4].i, - n[5].i, n[6].i, n[7].i)); - break; - case OPCODE_COPY_TEX_IMAGE2D: - CALL_CopyTexImage2D(ctx->Exec, (n[1].e, n[2].i, n[3].e, n[4].i, - n[5].i, n[6].i, n[7].i, n[8].i)); - break; - case OPCODE_COPY_TEX_SUB_IMAGE1D: - CALL_CopyTexSubImage1D(ctx->Exec, (n[1].e, n[2].i, n[3].i, - n[4].i, n[5].i, n[6].i)); - break; - case OPCODE_COPY_TEX_SUB_IMAGE2D: - CALL_CopyTexSubImage2D(ctx->Exec, (n[1].e, n[2].i, n[3].i, - n[4].i, n[5].i, n[6].i, n[7].i, - n[8].i)); - break; - case OPCODE_CULL_FACE: - CALL_CullFace(ctx->Exec, (n[1].e)); - break; - case OPCODE_DEPTH_FUNC: - CALL_DepthFunc(ctx->Exec, (n[1].e)); - break; - case OPCODE_DEPTH_MASK: - CALL_DepthMask(ctx->Exec, (n[1].b)); - break; - case OPCODE_DEPTH_RANGE: - CALL_DepthRange(ctx->Exec, - ((GLclampd) n[1].f, (GLclampd) n[2].f)); - break; - case OPCODE_DISABLE: - CALL_Disable(ctx->Exec, (n[1].e)); - break; - case OPCODE_DRAW_BUFFER: - CALL_DrawBuffer(ctx->Exec, (n[1].e)); - break; - case OPCODE_DRAW_PIXELS: - { - const struct gl_pixelstore_attrib save = ctx->Unpack; - ctx->Unpack = ctx->DefaultPacking; - CALL_DrawPixels(ctx->Exec, (n[1].i, n[2].i, n[3].e, n[4].e, - n[5].data)); - ctx->Unpack = save; /* restore */ - } - break; - case OPCODE_ENABLE: - CALL_Enable(ctx->Exec, (n[1].e)); - break; - case OPCODE_EVALMESH1: - CALL_EvalMesh1(ctx->Exec, (n[1].e, n[2].i, n[3].i)); - break; - case OPCODE_EVALMESH2: - CALL_EvalMesh2(ctx->Exec, - (n[1].e, n[2].i, n[3].i, n[4].i, n[5].i)); - break; - case OPCODE_FOG: - { - GLfloat p[4]; - p[0] = n[2].f; - p[1] = n[3].f; - p[2] = n[4].f; - p[3] = n[5].f; - CALL_Fogfv(ctx->Exec, (n[1].e, p)); - } - break; - case OPCODE_FRONT_FACE: - CALL_FrontFace(ctx->Exec, (n[1].e)); - break; - case OPCODE_FRUSTUM: - CALL_Frustum(ctx->Exec, - (n[1].f, n[2].f, n[3].f, n[4].f, n[5].f, n[6].f)); - break; - case OPCODE_HINT: - CALL_Hint(ctx->Exec, (n[1].e, n[2].e)); - break; - case OPCODE_INDEX_MASK: - CALL_IndexMask(ctx->Exec, (n[1].ui)); - break; - case OPCODE_INIT_NAMES: - CALL_InitNames(ctx->Exec, ()); - break; - case OPCODE_LIGHT: - { - GLfloat p[4]; - p[0] = n[3].f; - p[1] = n[4].f; - p[2] = n[5].f; - p[3] = n[6].f; - CALL_Lightfv(ctx->Exec, (n[1].e, n[2].e, p)); - } - break; - case OPCODE_LIGHT_MODEL: - { - GLfloat p[4]; - p[0] = n[2].f; - p[1] = n[3].f; - p[2] = n[4].f; - p[3] = n[5].f; - CALL_LightModelfv(ctx->Exec, (n[1].e, p)); - } - break; - case OPCODE_LINE_STIPPLE: - CALL_LineStipple(ctx->Exec, (n[1].i, n[2].us)); - break; - case OPCODE_LINE_WIDTH: - CALL_LineWidth(ctx->Exec, (n[1].f)); - break; - case OPCODE_LIST_BASE: - CALL_ListBase(ctx->Exec, (n[1].ui)); - break; - case OPCODE_LOAD_IDENTITY: - CALL_LoadIdentity(ctx->Exec, ()); - break; - case OPCODE_LOAD_MATRIX: - if (sizeof(Node) == sizeof(GLfloat)) { - CALL_LoadMatrixf(ctx->Exec, (&n[1].f)); - } - else { - GLfloat m[16]; - GLuint i; - for (i = 0; i < 16; i++) { - m[i] = n[1 + i].f; - } - CALL_LoadMatrixf(ctx->Exec, (m)); - } - break; - case OPCODE_LOAD_NAME: - CALL_LoadName(ctx->Exec, (n[1].ui)); - break; - case OPCODE_LOGIC_OP: - CALL_LogicOp(ctx->Exec, (n[1].e)); - break; - case OPCODE_MAP1: - { - GLenum target = n[1].e; - GLint ustride = _mesa_evaluator_components(target); - GLint uorder = n[5].i; - GLfloat u1 = n[2].f; - GLfloat u2 = n[3].f; - CALL_Map1f(ctx->Exec, (target, u1, u2, ustride, uorder, - (GLfloat *) n[6].data)); - } - break; - case OPCODE_MAP2: - { - GLenum target = n[1].e; - GLfloat u1 = n[2].f; - GLfloat u2 = n[3].f; - GLfloat v1 = n[4].f; - GLfloat v2 = n[5].f; - GLint ustride = n[6].i; - GLint vstride = n[7].i; - GLint uorder = n[8].i; - GLint vorder = n[9].i; - CALL_Map2f(ctx->Exec, (target, u1, u2, ustride, uorder, - v1, v2, vstride, vorder, - (GLfloat *) n[10].data)); - } - break; - case OPCODE_MAPGRID1: - CALL_MapGrid1f(ctx->Exec, (n[1].i, n[2].f, n[3].f)); - break; - case OPCODE_MAPGRID2: - CALL_MapGrid2f(ctx->Exec, - (n[1].i, n[2].f, n[3].f, n[4].i, n[5].f, n[6].f)); - break; - case OPCODE_MATRIX_MODE: - CALL_MatrixMode(ctx->Exec, (n[1].e)); - break; - case OPCODE_MULT_MATRIX: - if (sizeof(Node) == sizeof(GLfloat)) { - CALL_MultMatrixf(ctx->Exec, (&n[1].f)); - } - else { - GLfloat m[16]; - GLuint i; - for (i = 0; i < 16; i++) { - m[i] = n[1 + i].f; - } - CALL_MultMatrixf(ctx->Exec, (m)); - } - break; - case OPCODE_ORTHO: - CALL_Ortho(ctx->Exec, - (n[1].f, n[2].f, n[3].f, n[4].f, n[5].f, n[6].f)); - break; - case OPCODE_PASSTHROUGH: - CALL_PassThrough(ctx->Exec, (n[1].f)); - break; - case OPCODE_PIXEL_MAP: - CALL_PixelMapfv(ctx->Exec, - (n[1].e, n[2].i, (GLfloat *) n[3].data)); - break; - case OPCODE_PIXEL_TRANSFER: - CALL_PixelTransferf(ctx->Exec, (n[1].e, n[2].f)); - break; - case OPCODE_PIXEL_ZOOM: - CALL_PixelZoom(ctx->Exec, (n[1].f, n[2].f)); - break; - case OPCODE_POINT_SIZE: - CALL_PointSize(ctx->Exec, (n[1].f)); - break; - case OPCODE_POINT_PARAMETERS: - { - GLfloat params[3]; - params[0] = n[2].f; - params[1] = n[3].f; - params[2] = n[4].f; - CALL_PointParameterfvEXT(ctx->Exec, (n[1].e, params)); - } - break; - case OPCODE_POLYGON_MODE: - CALL_PolygonMode(ctx->Exec, (n[1].e, n[2].e)); - break; - case OPCODE_POLYGON_STIPPLE: - { - const struct gl_pixelstore_attrib save = ctx->Unpack; - ctx->Unpack = ctx->DefaultPacking; - CALL_PolygonStipple(ctx->Exec, ((GLubyte *) n[1].data)); - ctx->Unpack = save; /* restore */ - } - break; - case OPCODE_POLYGON_OFFSET: - CALL_PolygonOffset(ctx->Exec, (n[1].f, n[2].f)); - break; - case OPCODE_POP_ATTRIB: - CALL_PopAttrib(ctx->Exec, ()); - break; - case OPCODE_POP_MATRIX: - CALL_PopMatrix(ctx->Exec, ()); - break; - case OPCODE_POP_NAME: - CALL_PopName(ctx->Exec, ()); - break; - case OPCODE_PRIORITIZE_TEXTURE: - CALL_PrioritizeTextures(ctx->Exec, (1, &n[1].ui, &n[2].f)); - break; - case OPCODE_PUSH_ATTRIB: - CALL_PushAttrib(ctx->Exec, (n[1].bf)); - break; - case OPCODE_PUSH_MATRIX: - CALL_PushMatrix(ctx->Exec, ()); - break; - case OPCODE_PUSH_NAME: - CALL_PushName(ctx->Exec, (n[1].ui)); - break; - case OPCODE_RASTER_POS: - CALL_RasterPos4f(ctx->Exec, (n[1].f, n[2].f, n[3].f, n[4].f)); - break; - case OPCODE_READ_BUFFER: - CALL_ReadBuffer(ctx->Exec, (n[1].e)); - break; - case OPCODE_ROTATE: - CALL_Rotatef(ctx->Exec, (n[1].f, n[2].f, n[3].f, n[4].f)); - break; - case OPCODE_SCALE: - CALL_Scalef(ctx->Exec, (n[1].f, n[2].f, n[3].f)); - break; - case OPCODE_SCISSOR: - CALL_Scissor(ctx->Exec, (n[1].i, n[2].i, n[3].i, n[4].i)); - break; - case OPCODE_SHADE_MODEL: - CALL_ShadeModel(ctx->Exec, (n[1].e)); - break; - case OPCODE_STENCIL_FUNC: - CALL_StencilFunc(ctx->Exec, (n[1].e, n[2].i, n[3].ui)); - break; - case OPCODE_STENCIL_MASK: - CALL_StencilMask(ctx->Exec, (n[1].ui)); - break; - case OPCODE_STENCIL_OP: - CALL_StencilOp(ctx->Exec, (n[1].e, n[2].e, n[3].e)); - break; - case OPCODE_TEXENV: - { - GLfloat params[4]; - params[0] = n[3].f; - params[1] = n[4].f; - params[2] = n[5].f; - params[3] = n[6].f; - CALL_TexEnvfv(ctx->Exec, (n[1].e, n[2].e, params)); - } - break; - case OPCODE_TEXGEN: - { - GLfloat params[4]; - params[0] = n[3].f; - params[1] = n[4].f; - params[2] = n[5].f; - params[3] = n[6].f; - CALL_TexGenfv(ctx->Exec, (n[1].e, n[2].e, params)); - } - break; - case OPCODE_TEXPARAMETER: - { - GLfloat params[4]; - params[0] = n[3].f; - params[1] = n[4].f; - params[2] = n[5].f; - params[3] = n[6].f; - CALL_TexParameterfv(ctx->Exec, (n[1].e, n[2].e, params)); - } - break; - case OPCODE_TEX_IMAGE1D: - { - const struct gl_pixelstore_attrib save = ctx->Unpack; - ctx->Unpack = ctx->DefaultPacking; - CALL_TexImage1D(ctx->Exec, (n[1].e, /* target */ - n[2].i, /* level */ - n[3].i, /* components */ - n[4].i, /* width */ - n[5].e, /* border */ - n[6].e, /* format */ - n[7].e, /* type */ - n[8].data)); - ctx->Unpack = save; /* restore */ - } - break; - case OPCODE_TEX_IMAGE2D: - { - const struct gl_pixelstore_attrib save = ctx->Unpack; - ctx->Unpack = ctx->DefaultPacking; - CALL_TexImage2D(ctx->Exec, (n[1].e, /* target */ - n[2].i, /* level */ - n[3].i, /* components */ - n[4].i, /* width */ - n[5].i, /* height */ - n[6].e, /* border */ - n[7].e, /* format */ - n[8].e, /* type */ - n[9].data)); - ctx->Unpack = save; /* restore */ - } - break; - case OPCODE_TEX_SUB_IMAGE1D: - { - const struct gl_pixelstore_attrib save = ctx->Unpack; - ctx->Unpack = ctx->DefaultPacking; - CALL_TexSubImage1D(ctx->Exec, (n[1].e, n[2].i, n[3].i, - n[4].i, n[5].e, - n[6].e, n[7].data)); - ctx->Unpack = save; /* restore */ - } - break; - case OPCODE_TEX_SUB_IMAGE2D: - { - const struct gl_pixelstore_attrib save = ctx->Unpack; - ctx->Unpack = ctx->DefaultPacking; - CALL_TexSubImage2D(ctx->Exec, (n[1].e, n[2].i, n[3].i, - n[4].i, n[5].e, - n[6].i, n[7].e, n[8].e, - n[9].data)); - ctx->Unpack = save; /* restore */ - } - break; - case OPCODE_TRANSLATE: - CALL_Translatef(ctx->Exec, (n[1].f, n[2].f, n[3].f)); - break; - case OPCODE_VIEWPORT: - CALL_Viewport(ctx->Exec, (n[1].i, n[2].i, - (GLsizei) n[3].i, (GLsizei) n[4].i)); - break; - case OPCODE_WINDOW_POS: - CALL_WindowPos4fMESA(ctx->Exec, (n[1].f, n[2].f, n[3].f, n[4].f)); - break; - case OPCODE_SAMPLE_COVERAGE: /* GL_ARB_multisample */ - CALL_SampleCoverageARB(ctx->Exec, (n[1].f, n[2].b)); - break; - case OPCODE_WINDOW_POS_ARB: /* GL_ARB_window_pos */ - CALL_WindowPos3fMESA(ctx->Exec, (n[1].f, n[2].f, n[3].f)); - break; - - case OPCODE_DEPTH_BOUNDS_EXT: - CALL_DepthBoundsEXT(ctx->Exec, (n[1].f, n[2].f)); - break; - - case OPCODE_ATTR_1F_NV: - CALL_VertexAttrib1fNV(ctx->Exec, (n[1].e, n[2].f)); - break; - case OPCODE_ATTR_2F_NV: - /* Really shouldn't have to do this - the Node structure - * is convenient, but it would be better to store the data - * packed appropriately so that it can be sent directly - * on. With x86_64 becoming common, this will start to - * matter more. - */ - if (sizeof(Node) == sizeof(GLfloat)) - CALL_VertexAttrib2fvNV(ctx->Exec, (n[1].e, &n[2].f)); - else - CALL_VertexAttrib2fNV(ctx->Exec, (n[1].e, n[2].f, n[3].f)); - break; - case OPCODE_ATTR_3F_NV: - if (sizeof(Node) == sizeof(GLfloat)) - CALL_VertexAttrib3fvNV(ctx->Exec, (n[1].e, &n[2].f)); - else - CALL_VertexAttrib3fNV(ctx->Exec, (n[1].e, n[2].f, n[3].f, - n[4].f)); - break; - case OPCODE_ATTR_4F_NV: - if (sizeof(Node) == sizeof(GLfloat)) - CALL_VertexAttrib4fvNV(ctx->Exec, (n[1].e, &n[2].f)); - else - CALL_VertexAttrib4fNV(ctx->Exec, (n[1].e, n[2].f, n[3].f, - n[4].f, n[5].f)); - break; - case OPCODE_MATERIAL: - { - GLfloat f[4]; - f[0] = n[3].f; - f[1] = n[4].f; - f[2] = n[5].f; - f[3] = n[6].f; - CALL_Materialfv(ctx->Exec, (n[1].e, n[2].e, f)); - } - break; - case OPCODE_BEGIN: - CALL_Begin(ctx->Exec, (n[1].e)); - break; - case OPCODE_END: - CALL_End(ctx->Exec, ()); - break; - case OPCODE_RECTF: - CALL_Rectf(ctx->Exec, (n[1].f, n[2].f, n[3].f, n[4].f)); - break; - case OPCODE_EVAL_C1: - CALL_EvalCoord1f(ctx->Exec, (n[1].f)); - break; - case OPCODE_EVAL_C2: - CALL_EvalCoord2f(ctx->Exec, (n[1].f, n[2].f)); - break; - case OPCODE_EVAL_P1: - CALL_EvalPoint1(ctx->Exec, (n[1].i)); - break; - case OPCODE_EVAL_P2: - CALL_EvalPoint2(ctx->Exec, (n[1].i, n[2].i)); - break; - - /* GL_EXT_texture_integer */ - case OPCODE_CLEARCOLOR_I: - CALL_ClearColorIiEXT(ctx->Exec, (n[1].i, n[2].i, n[3].i, n[4].i)); - break; - case OPCODE_CLEARCOLOR_UI: - CALL_ClearColorIuiEXT(ctx->Exec, - (n[1].ui, n[2].ui, n[3].ui, n[4].ui)); - break; - case OPCODE_TEXPARAMETER_I: - { - GLint params[4]; - params[0] = n[3].i; - params[1] = n[4].i; - params[2] = n[5].i; - params[3] = n[6].i; - CALL_TexParameterIivEXT(ctx->Exec, (n[1].e, n[2].e, params)); - } - break; - case OPCODE_TEXPARAMETER_UI: - { - GLuint params[4]; - params[0] = n[3].ui; - params[1] = n[4].ui; - params[2] = n[5].ui; - params[3] = n[6].ui; - CALL_TexParameterIuivEXT(ctx->Exec, (n[1].e, n[2].e, params)); - } - break; - - case OPCODE_CONTINUE: - n = (Node *) n[1].next; - break; - case OPCODE_END_OF_LIST: - done = GL_TRUE; - break; - default: - { - char msg[1000]; - _mesa_snprintf(msg, sizeof(msg), "Error in execute_list: opcode=%d", - (int) opcode); - _mesa_problem(ctx, "%s", msg); - } - done = GL_TRUE; - } - - /* increment n to point to next compiled command */ - if (opcode != OPCODE_CONTINUE) { - n += InstSize[opcode]; - } - } - } - - if (ctx->Driver.EndCallList) - ctx->Driver.EndCallList(ctx); - - ctx->ListState.CallDepth--; -} - - - -/**********************************************************************/ -/* GL functions */ -/**********************************************************************/ - -/** - * Test if a display list number is valid. - */ -static GLboolean GLAPIENTRY -_mesa_IsList(GLuint list) -{ - GET_CURRENT_CONTEXT(ctx); - FLUSH_VERTICES(ctx, 0); /* must be called before assert */ - ASSERT_OUTSIDE_BEGIN_END_WITH_RETVAL(ctx, GL_FALSE); - return islist(ctx, list); -} - - -/** - * Delete a sequence of consecutive display lists. - */ -static void GLAPIENTRY -_mesa_DeleteLists(GLuint list, GLsizei range) -{ - GET_CURRENT_CONTEXT(ctx); - GLuint i; - FLUSH_VERTICES(ctx, 0); /* must be called before assert */ - ASSERT_OUTSIDE_BEGIN_END(ctx); - - if (range < 0) { - _mesa_error(ctx, GL_INVALID_VALUE, "glDeleteLists"); - return; - } - for (i = list; i < list + range; i++) { - destroy_list(ctx, i); - } -} - - -/** - * Return a display list number, n, such that lists n through n+range-1 - * are free. - */ -static GLuint GLAPIENTRY -_mesa_GenLists(GLsizei range) -{ - GET_CURRENT_CONTEXT(ctx); - GLuint base; - FLUSH_VERTICES(ctx, 0); /* must be called before assert */ - ASSERT_OUTSIDE_BEGIN_END_WITH_RETVAL(ctx, 0); - - if (range < 0) { - _mesa_error(ctx, GL_INVALID_VALUE, "glGenLists"); - return 0; - } - if (range == 0) { - return 0; - } - - /* - * Make this an atomic operation - */ - _glthread_LOCK_MUTEX(ctx->Shared->Mutex); - - base = _mesa_HashFindFreeKeyBlock(ctx->Shared->DisplayList, range); - if (base) { - /* reserve the list IDs by with empty/dummy lists */ - GLint i; - for (i = 0; i < range; i++) { - _mesa_HashInsert(ctx->Shared->DisplayList, base + i, - make_list(base + i, 1)); - } - } - - _glthread_UNLOCK_MUTEX(ctx->Shared->Mutex); - - return base; -} - - -/** - * Begin a new display list. - */ -static void GLAPIENTRY -_mesa_NewList(GLuint name, GLenum mode) -{ - GET_CURRENT_CONTEXT(ctx); - - FLUSH_CURRENT(ctx, 0); /* must be called before assert */ - ASSERT_OUTSIDE_BEGIN_END(ctx); - - if (MESA_VERBOSE & VERBOSE_API) - _mesa_debug(ctx, "glNewList %u %s\n", name, - _mesa_lookup_enum_by_nr(mode)); - - if (name == 0) { - _mesa_error(ctx, GL_INVALID_VALUE, "glNewList"); - return; - } - - if (mode != GL_COMPILE && mode != GL_COMPILE_AND_EXECUTE) { - _mesa_error(ctx, GL_INVALID_ENUM, "glNewList"); - return; - } - - if (ctx->ListState.CurrentList) { - /* already compiling a display list */ - _mesa_error(ctx, GL_INVALID_OPERATION, "glNewList"); - return; - } - - ctx->CompileFlag = GL_TRUE; - ctx->ExecuteFlag = (mode == GL_COMPILE_AND_EXECUTE); - - /* Reset acumulated list state: - */ - invalidate_saved_current_state( ctx ); - - /* Allocate new display list */ - ctx->ListState.CurrentList = make_list(name, BLOCK_SIZE); - ctx->ListState.CurrentBlock = ctx->ListState.CurrentList->Head; - ctx->ListState.CurrentPos = 0; - - ctx->Driver.NewList(ctx, name, mode); - - ctx->CurrentDispatch = ctx->Save; - _glapi_set_dispatch(ctx->CurrentDispatch); -} - - -/** - * End definition of current display list. - */ -static void GLAPIENTRY -_mesa_EndList(void) -{ - GET_CURRENT_CONTEXT(ctx); - SAVE_FLUSH_VERTICES(ctx); - ASSERT_OUTSIDE_BEGIN_END_AND_FLUSH(ctx); - - if (MESA_VERBOSE & VERBOSE_API) - _mesa_debug(ctx, "glEndList\n"); - - /* Check that a list is under construction */ - if (!ctx->ListState.CurrentList) { - _mesa_error(ctx, GL_INVALID_OPERATION, "glEndList"); - return; - } - - /* Call before emitting END_OF_LIST, in case the driver wants to - * emit opcodes itself. - */ - ctx->Driver.EndList(ctx); - - (void) alloc_instruction(ctx, OPCODE_END_OF_LIST, 0); - - /* Destroy old list, if any */ - destroy_list(ctx, ctx->ListState.CurrentList->Name); - - /* Install the new list */ - _mesa_HashInsert(ctx->Shared->DisplayList, - ctx->ListState.CurrentList->Name, - ctx->ListState.CurrentList); - - - if (MESA_VERBOSE & VERBOSE_DISPLAY_LIST) - mesa_print_display_list(ctx->ListState.CurrentList->Name); - - ctx->ListState.CurrentList = NULL; - ctx->ExecuteFlag = GL_TRUE; - ctx->CompileFlag = GL_FALSE; - - ctx->CurrentDispatch = ctx->Exec; - _glapi_set_dispatch(ctx->CurrentDispatch); -} - - -void GLAPIENTRY -_mesa_CallList(GLuint list) -{ - GLboolean save_compile_flag; - GET_CURRENT_CONTEXT(ctx); - FLUSH_CURRENT(ctx, 0); - - if (MESA_VERBOSE & VERBOSE_API) - _mesa_debug(ctx, "glCallList %d\n", list); - - if (list == 0) { - _mesa_error(ctx, GL_INVALID_VALUE, "glCallList(list==0)"); - return; - } - - if (0) - mesa_print_display_list( list ); - - /* VERY IMPORTANT: Save the CompileFlag status, turn it off, - * execute the display list, and restore the CompileFlag. - */ - save_compile_flag = ctx->CompileFlag; - if (save_compile_flag) { - ctx->CompileFlag = GL_FALSE; - } - - execute_list(ctx, list); - ctx->CompileFlag = save_compile_flag; - - /* also restore API function pointers to point to "save" versions */ - if (save_compile_flag) { - ctx->CurrentDispatch = ctx->Save; - _glapi_set_dispatch(ctx->CurrentDispatch); - } -} - - -/** - * Execute glCallLists: call multiple display lists. - */ -void GLAPIENTRY -_mesa_CallLists(GLsizei n, GLenum type, const GLvoid * lists) -{ - GET_CURRENT_CONTEXT(ctx); - GLint i; - GLboolean save_compile_flag; - - if (MESA_VERBOSE & VERBOSE_API) - _mesa_debug(ctx, "glCallLists %d\n", n); - - switch (type) { - case GL_BYTE: - case GL_UNSIGNED_BYTE: - case GL_SHORT: - case GL_UNSIGNED_SHORT: - case GL_INT: - case GL_UNSIGNED_INT: - case GL_FLOAT: - case GL_2_BYTES: - case GL_3_BYTES: - case GL_4_BYTES: - /* OK */ - break; - default: - _mesa_error(ctx, GL_INVALID_ENUM, "glCallLists(type)"); - return; - } - - /* Save the CompileFlag status, turn it off, execute display list, - * and restore the CompileFlag. - */ - save_compile_flag = ctx->CompileFlag; - ctx->CompileFlag = GL_FALSE; - - for (i = 0; i < n; i++) { - GLuint list = (GLuint) (ctx->List.ListBase + translate_id(i, type, lists)); - execute_list(ctx, list); - } - - ctx->CompileFlag = save_compile_flag; - - /* also restore API function pointers to point to "save" versions */ - if (save_compile_flag) { - ctx->CurrentDispatch = ctx->Save; - _glapi_set_dispatch(ctx->CurrentDispatch); - } -} - - -/** - * Set the offset added to list numbers in glCallLists. - */ -static void GLAPIENTRY -_mesa_ListBase(GLuint base) -{ - GET_CURRENT_CONTEXT(ctx); - FLUSH_VERTICES(ctx, 0); /* must be called before assert */ - ASSERT_OUTSIDE_BEGIN_END(ctx); - ctx->List.ListBase = base; -} - - -/* Can no longer assume ctx->Exec->Func is equal to _mesa_Func. - */ -static void GLAPIENTRY -exec_Finish(void) -{ - GET_CURRENT_CONTEXT(ctx); - FLUSH_VERTICES(ctx, 0); - CALL_Finish(ctx->Exec, ()); -} - -static void GLAPIENTRY -exec_Flush(void) -{ - GET_CURRENT_CONTEXT(ctx); - FLUSH_VERTICES(ctx, 0); - CALL_Flush(ctx->Exec, ()); -} - -static void GLAPIENTRY -exec_GetBooleanv(GLenum pname, GLboolean *params) -{ - GET_CURRENT_CONTEXT(ctx); - FLUSH_VERTICES(ctx, 0); - CALL_GetBooleanv(ctx->Exec, (pname, params)); -} - -static void GLAPIENTRY -exec_GetClipPlane(GLenum plane, GLdouble * equation) -{ - GET_CURRENT_CONTEXT(ctx); - FLUSH_VERTICES(ctx, 0); - CALL_GetClipPlane(ctx->Exec, (plane, equation)); -} - -static void GLAPIENTRY -exec_GetDoublev(GLenum pname, GLdouble *params) -{ - GET_CURRENT_CONTEXT(ctx); - FLUSH_VERTICES(ctx, 0); - CALL_GetDoublev(ctx->Exec, (pname, params)); -} - -static GLenum GLAPIENTRY -exec_GetError(void) -{ - GET_CURRENT_CONTEXT(ctx); - FLUSH_VERTICES(ctx, 0); - return CALL_GetError(ctx->Exec, ()); -} - -static void GLAPIENTRY -exec_GetFloatv(GLenum pname, GLfloat *params) -{ - GET_CURRENT_CONTEXT(ctx); - FLUSH_VERTICES(ctx, 0); - CALL_GetFloatv(ctx->Exec, (pname, params)); -} - -static void GLAPIENTRY -exec_GetIntegerv(GLenum pname, GLint *params) -{ - GET_CURRENT_CONTEXT(ctx); - FLUSH_VERTICES(ctx, 0); - CALL_GetIntegerv(ctx->Exec, (pname, params)); -} - -static void GLAPIENTRY -exec_GetLightfv(GLenum light, GLenum pname, GLfloat *params) -{ - GET_CURRENT_CONTEXT(ctx); - FLUSH_VERTICES(ctx, 0); - CALL_GetLightfv(ctx->Exec, (light, pname, params)); -} - -static void GLAPIENTRY -exec_GetLightiv(GLenum light, GLenum pname, GLint *params) -{ - GET_CURRENT_CONTEXT(ctx); - FLUSH_VERTICES(ctx, 0); - CALL_GetLightiv(ctx->Exec, (light, pname, params)); -} - -static void GLAPIENTRY -exec_GetMapdv(GLenum target, GLenum query, GLdouble * v) -{ - GET_CURRENT_CONTEXT(ctx); - FLUSH_VERTICES(ctx, 0); - CALL_GetMapdv(ctx->Exec, (target, query, v)); -} - -static void GLAPIENTRY -exec_GetMapfv(GLenum target, GLenum query, GLfloat * v) -{ - GET_CURRENT_CONTEXT(ctx); - FLUSH_VERTICES(ctx, 0); - CALL_GetMapfv(ctx->Exec, (target, query, v)); -} - -static void GLAPIENTRY -exec_GetMapiv(GLenum target, GLenum query, GLint * v) -{ - GET_CURRENT_CONTEXT(ctx); - FLUSH_VERTICES(ctx, 0); - CALL_GetMapiv(ctx->Exec, (target, query, v)); -} - -static void GLAPIENTRY -exec_GetMaterialfv(GLenum face, GLenum pname, GLfloat *params) -{ - GET_CURRENT_CONTEXT(ctx); - FLUSH_VERTICES(ctx, 0); - CALL_GetMaterialfv(ctx->Exec, (face, pname, params)); -} - -static void GLAPIENTRY -exec_GetMaterialiv(GLenum face, GLenum pname, GLint *params) -{ - GET_CURRENT_CONTEXT(ctx); - FLUSH_VERTICES(ctx, 0); - CALL_GetMaterialiv(ctx->Exec, (face, pname, params)); -} - -static void GLAPIENTRY -exec_GetPixelMapfv(GLenum map, GLfloat *values) -{ - GET_CURRENT_CONTEXT(ctx); - FLUSH_VERTICES(ctx, 0); - CALL_GetPixelMapfv(ctx->Exec, (map, values)); -} - -static void GLAPIENTRY -exec_GetPixelMapuiv(GLenum map, GLuint *values) -{ - GET_CURRENT_CONTEXT(ctx); - FLUSH_VERTICES(ctx, 0); - CALL_GetPixelMapuiv(ctx->Exec, (map, values)); -} - -static void GLAPIENTRY -exec_GetPixelMapusv(GLenum map, GLushort *values) -{ - GET_CURRENT_CONTEXT(ctx); - FLUSH_VERTICES(ctx, 0); - CALL_GetPixelMapusv(ctx->Exec, (map, values)); -} - -static void GLAPIENTRY -exec_GetPolygonStipple(GLubyte * dest) -{ - GET_CURRENT_CONTEXT(ctx); - FLUSH_VERTICES(ctx, 0); - CALL_GetPolygonStipple(ctx->Exec, (dest)); -} - -static const GLubyte *GLAPIENTRY -exec_GetString(GLenum name) -{ - GET_CURRENT_CONTEXT(ctx); - FLUSH_VERTICES(ctx, 0); - return CALL_GetString(ctx->Exec, (name)); -} - -static void GLAPIENTRY -exec_GetTexEnvfv(GLenum target, GLenum pname, GLfloat *params) -{ - GET_CURRENT_CONTEXT(ctx); - FLUSH_VERTICES(ctx, 0); - CALL_GetTexEnvfv(ctx->Exec, (target, pname, params)); -} - -static void GLAPIENTRY -exec_GetTexEnviv(GLenum target, GLenum pname, GLint *params) -{ - GET_CURRENT_CONTEXT(ctx); - FLUSH_VERTICES(ctx, 0); - CALL_GetTexEnviv(ctx->Exec, (target, pname, params)); -} - -static void GLAPIENTRY -exec_GetTexGendv(GLenum coord, GLenum pname, GLdouble *params) -{ - GET_CURRENT_CONTEXT(ctx); - FLUSH_VERTICES(ctx, 0); - CALL_GetTexGendv(ctx->Exec, (coord, pname, params)); -} - -static void GLAPIENTRY -exec_GetTexGenfv(GLenum coord, GLenum pname, GLfloat *params) -{ - GET_CURRENT_CONTEXT(ctx); - FLUSH_VERTICES(ctx, 0); - CALL_GetTexGenfv(ctx->Exec, (coord, pname, params)); -} - -static void GLAPIENTRY -exec_GetTexGeniv(GLenum coord, GLenum pname, GLint *params) -{ - GET_CURRENT_CONTEXT(ctx); - FLUSH_VERTICES(ctx, 0); - CALL_GetTexGeniv(ctx->Exec, (coord, pname, params)); -} - -static void GLAPIENTRY -exec_GetTexImage(GLenum target, GLint level, GLenum format, - GLenum type, GLvoid * pixels) -{ - GET_CURRENT_CONTEXT(ctx); - FLUSH_VERTICES(ctx, 0); - CALL_GetTexImage(ctx->Exec, (target, level, format, type, pixels)); -} - -static void GLAPIENTRY -exec_GetTexLevelParameterfv(GLenum target, GLint level, - GLenum pname, GLfloat *params) -{ - GET_CURRENT_CONTEXT(ctx); - FLUSH_VERTICES(ctx, 0); - CALL_GetTexLevelParameterfv(ctx->Exec, (target, level, pname, params)); -} - -static void GLAPIENTRY -exec_GetTexLevelParameteriv(GLenum target, GLint level, - GLenum pname, GLint *params) -{ - GET_CURRENT_CONTEXT(ctx); - FLUSH_VERTICES(ctx, 0); - CALL_GetTexLevelParameteriv(ctx->Exec, (target, level, pname, params)); -} - -static void GLAPIENTRY -exec_GetTexParameterfv(GLenum target, GLenum pname, GLfloat *params) -{ - GET_CURRENT_CONTEXT(ctx); - FLUSH_VERTICES(ctx, 0); - CALL_GetTexParameterfv(ctx->Exec, (target, pname, params)); -} - -static void GLAPIENTRY -exec_GetTexParameteriv(GLenum target, GLenum pname, GLint *params) -{ - GET_CURRENT_CONTEXT(ctx); - FLUSH_VERTICES(ctx, 0); - CALL_GetTexParameteriv(ctx->Exec, (target, pname, params)); -} - -static GLboolean GLAPIENTRY -exec_IsEnabled(GLenum cap) -{ - GET_CURRENT_CONTEXT(ctx); - FLUSH_VERTICES(ctx, 0); - return CALL_IsEnabled(ctx->Exec, (cap)); -} - -static void GLAPIENTRY -exec_PixelStoref(GLenum pname, GLfloat param) -{ - GET_CURRENT_CONTEXT(ctx); - FLUSH_VERTICES(ctx, 0); - CALL_PixelStoref(ctx->Exec, (pname, param)); -} - -static void GLAPIENTRY -exec_PixelStorei(GLenum pname, GLint param) -{ - GET_CURRENT_CONTEXT(ctx); - FLUSH_VERTICES(ctx, 0); - CALL_PixelStorei(ctx->Exec, (pname, param)); -} - -static void GLAPIENTRY -exec_ReadPixels(GLint x, GLint y, GLsizei width, GLsizei height, - GLenum format, GLenum type, GLvoid * pixels) -{ - GET_CURRENT_CONTEXT(ctx); - FLUSH_VERTICES(ctx, 0); - CALL_ReadPixels(ctx->Exec, (x, y, width, height, format, type, pixels)); -} - -static GLint GLAPIENTRY -exec_RenderMode(GLenum mode) -{ - GET_CURRENT_CONTEXT(ctx); - FLUSH_VERTICES(ctx, 0); - return CALL_RenderMode(ctx->Exec, (mode)); -} - -static void GLAPIENTRY -exec_FeedbackBuffer(GLsizei size, GLenum type, GLfloat * buffer) -{ - GET_CURRENT_CONTEXT(ctx); - FLUSH_VERTICES(ctx, 0); - CALL_FeedbackBuffer(ctx->Exec, (size, type, buffer)); -} - -static void GLAPIENTRY -exec_SelectBuffer(GLsizei size, GLuint * buffer) -{ - GET_CURRENT_CONTEXT(ctx); - FLUSH_VERTICES(ctx, 0); - CALL_SelectBuffer(ctx->Exec, (size, buffer)); -} - -static GLboolean GLAPIENTRY -exec_AreTexturesResident(GLsizei n, const GLuint * texName, - GLboolean * residences) -{ - GET_CURRENT_CONTEXT(ctx); - FLUSH_VERTICES(ctx, 0); - return CALL_AreTexturesResident(ctx->Exec, (n, texName, residences)); -} - -static void GLAPIENTRY -exec_ColorPointer(GLint size, GLenum type, GLsizei stride, const GLvoid *ptr) -{ - GET_CURRENT_CONTEXT(ctx); - FLUSH_VERTICES(ctx, 0); - CALL_ColorPointer(ctx->Exec, (size, type, stride, ptr)); -} - -static void GLAPIENTRY -exec_DeleteTextures(GLsizei n, const GLuint * texName) -{ - GET_CURRENT_CONTEXT(ctx); - FLUSH_VERTICES(ctx, 0); - CALL_DeleteTextures(ctx->Exec, (n, texName)); -} - -static void GLAPIENTRY -exec_DisableClientState(GLenum cap) -{ - GET_CURRENT_CONTEXT(ctx); - FLUSH_VERTICES(ctx, 0); - CALL_DisableClientState(ctx->Exec, (cap)); -} - -static void GLAPIENTRY -exec_EdgeFlagPointer(GLsizei stride, const GLvoid * vptr) -{ - GET_CURRENT_CONTEXT(ctx); - FLUSH_VERTICES(ctx, 0); - CALL_EdgeFlagPointer(ctx->Exec, (stride, vptr)); -} - -static void GLAPIENTRY -exec_EnableClientState(GLenum cap) -{ - GET_CURRENT_CONTEXT(ctx); - FLUSH_VERTICES(ctx, 0); - CALL_EnableClientState(ctx->Exec, (cap)); -} - -static void GLAPIENTRY -exec_GenTextures(GLsizei n, GLuint * texName) -{ - GET_CURRENT_CONTEXT(ctx); - FLUSH_VERTICES(ctx, 0); - CALL_GenTextures(ctx->Exec, (n, texName)); -} - -static void GLAPIENTRY -exec_GetPointerv(GLenum pname, GLvoid **params) -{ - GET_CURRENT_CONTEXT(ctx); - FLUSH_VERTICES(ctx, 0); - CALL_GetPointerv(ctx->Exec, (pname, params)); -} - -static void GLAPIENTRY -exec_IndexPointer(GLenum type, GLsizei stride, const GLvoid *ptr) -{ - GET_CURRENT_CONTEXT(ctx); - FLUSH_VERTICES(ctx, 0); - CALL_IndexPointer(ctx->Exec, (type, stride, ptr)); -} - -static void GLAPIENTRY -exec_InterleavedArrays(GLenum format, GLsizei stride, const GLvoid * pointer) -{ - GET_CURRENT_CONTEXT(ctx); - FLUSH_VERTICES(ctx, 0); - CALL_InterleavedArrays(ctx->Exec, (format, stride, pointer)); -} - -static GLboolean GLAPIENTRY -exec_IsTexture(GLuint texture) -{ - GET_CURRENT_CONTEXT(ctx); - FLUSH_VERTICES(ctx, 0); - return CALL_IsTexture(ctx->Exec, (texture)); -} - -static void GLAPIENTRY -exec_NormalPointer(GLenum type, GLsizei stride, const GLvoid *ptr) -{ - GET_CURRENT_CONTEXT(ctx); - FLUSH_VERTICES(ctx, 0); - CALL_NormalPointer(ctx->Exec, (type, stride, ptr)); -} - -static void GLAPIENTRY -exec_PopClientAttrib(void) -{ - GET_CURRENT_CONTEXT(ctx); - FLUSH_VERTICES(ctx, 0); - CALL_PopClientAttrib(ctx->Exec, ()); -} - -static void GLAPIENTRY -exec_PushClientAttrib(GLbitfield mask) -{ - GET_CURRENT_CONTEXT(ctx); - FLUSH_VERTICES(ctx, 0); - CALL_PushClientAttrib(ctx->Exec, (mask)); -} - -static void GLAPIENTRY -exec_TexCoordPointer(GLint size, GLenum type, GLsizei stride, - const GLvoid *ptr) -{ - GET_CURRENT_CONTEXT(ctx); - FLUSH_VERTICES(ctx, 0); - CALL_TexCoordPointer(ctx->Exec, (size, type, stride, ptr)); -} - -static void GLAPIENTRY -exec_VertexPointer(GLint size, GLenum type, GLsizei stride, - const GLvoid *ptr) -{ - GET_CURRENT_CONTEXT(ctx); - FLUSH_VERTICES(ctx, 0); - CALL_VertexPointer(ctx->Exec, (size, type, stride, ptr)); -} - -static void GLAPIENTRY -exec_ColorPointerEXT(GLint size, GLenum type, GLsizei stride, - GLsizei count, const GLvoid *ptr) -{ - GET_CURRENT_CONTEXT(ctx); - FLUSH_VERTICES(ctx, 0); - CALL_ColorPointerEXT(ctx->Exec, (size, type, stride, count, ptr)); -} - -static void GLAPIENTRY -exec_EdgeFlagPointerEXT(GLsizei stride, GLsizei count, const GLboolean *ptr) -{ - GET_CURRENT_CONTEXT(ctx); - FLUSH_VERTICES(ctx, 0); - CALL_EdgeFlagPointerEXT(ctx->Exec, (stride, count, ptr)); -} - -static void GLAPIENTRY -exec_IndexPointerEXT(GLenum type, GLsizei stride, GLsizei count, - const GLvoid *ptr) -{ - GET_CURRENT_CONTEXT(ctx); - FLUSH_VERTICES(ctx, 0); - CALL_IndexPointerEXT(ctx->Exec, (type, stride, count, ptr)); -} - -static void GLAPIENTRY -exec_NormalPointerEXT(GLenum type, GLsizei stride, GLsizei count, - const GLvoid *ptr) -{ - GET_CURRENT_CONTEXT(ctx); - FLUSH_VERTICES(ctx, 0); - CALL_NormalPointerEXT(ctx->Exec, (type, stride, count, ptr)); -} - -static void GLAPIENTRY -exec_TexCoordPointerEXT(GLint size, GLenum type, GLsizei stride, - GLsizei count, const GLvoid *ptr) -{ - GET_CURRENT_CONTEXT(ctx); - FLUSH_VERTICES(ctx, 0); - CALL_TexCoordPointerEXT(ctx->Exec, (size, type, stride, count, ptr)); -} - -static void GLAPIENTRY -exec_VertexPointerEXT(GLint size, GLenum type, GLsizei stride, - GLsizei count, const GLvoid *ptr) -{ - GET_CURRENT_CONTEXT(ctx); - FLUSH_VERTICES(ctx, 0); - CALL_VertexPointerEXT(ctx->Exec, (size, type, stride, count, ptr)); -} - -static void GLAPIENTRY -exec_LockArraysEXT(GLint first, GLsizei count) -{ - GET_CURRENT_CONTEXT(ctx); - FLUSH_VERTICES(ctx, 0); - CALL_LockArraysEXT(ctx->Exec, (first, count)); -} - -static void GLAPIENTRY -exec_UnlockArraysEXT(void) -{ - GET_CURRENT_CONTEXT(ctx); - FLUSH_VERTICES(ctx, 0); - CALL_UnlockArraysEXT(ctx->Exec, ()); -} - -static void GLAPIENTRY -exec_FogCoordPointerEXT(GLenum type, GLsizei stride, const GLvoid *ptr) -{ - GET_CURRENT_CONTEXT(ctx); - FLUSH_VERTICES(ctx, 0); - CALL_FogCoordPointerEXT(ctx->Exec, (type, stride, ptr)); -} - -/* GL_IBM_multimode_draw_arrays */ -static void GLAPIENTRY -exec_MultiModeDrawArraysIBM(const GLenum * mode, const GLint * first, - const GLsizei * count, GLsizei primcount, - GLint modestride) -{ - GET_CURRENT_CONTEXT(ctx); - FLUSH_VERTICES(ctx, 0); - CALL_MultiModeDrawArraysIBM(ctx->Exec, - (mode, first, count, primcount, modestride)); -} - -/* GL_IBM_multimode_draw_arrays */ -static void GLAPIENTRY -exec_MultiModeDrawElementsIBM(const GLenum * mode, - const GLsizei * count, - GLenum type, - const GLvoid * const *indices, - GLsizei primcount, GLint modestride) -{ - GET_CURRENT_CONTEXT(ctx); - FLUSH_VERTICES(ctx, 0); - CALL_MultiModeDrawElementsIBM(ctx->Exec, - (mode, count, type, indices, primcount, - modestride)); -} - -/** - * Setup the given dispatch table to point to Mesa's display list - * building functions. - * - * This does not include any of the tnl functions - they are - * initialized from _mesa_init_api_defaults and from the active vtxfmt - * struct. - */ -struct _glapi_table * -_mesa_create_save_table(void) -{ - struct _glapi_table *table; - - table = _mesa_alloc_dispatch_table(_gloffset_COUNT); - if (table == NULL) - return NULL; - - _mesa_loopback_init_api_table(table); - - /* GL 1.0 */ - SET_Accum(table, save_Accum); - SET_AlphaFunc(table, save_AlphaFunc); - SET_Bitmap(table, save_Bitmap); - SET_BlendFunc(table, save_BlendFunc); - SET_CallList(table, save_CallList); - SET_CallLists(table, save_CallLists); - SET_Clear(table, save_Clear); - SET_ClearAccum(table, save_ClearAccum); - SET_ClearColor(table, save_ClearColor); - SET_ClearDepth(table, save_ClearDepth); - SET_ClearIndex(table, save_ClearIndex); - SET_ClearStencil(table, save_ClearStencil); - SET_ClipPlane(table, save_ClipPlane); - SET_ColorMask(table, save_ColorMask); - SET_ColorMaterial(table, save_ColorMaterial); - SET_CopyPixels(table, save_CopyPixels); - SET_CullFace(table, save_CullFace); - SET_DeleteLists(table, _mesa_DeleteLists); - SET_DepthFunc(table, save_DepthFunc); - SET_DepthMask(table, save_DepthMask); - SET_DepthRange(table, save_DepthRange); - SET_Disable(table, save_Disable); - SET_DrawBuffer(table, save_DrawBuffer); - SET_DrawPixels(table, save_DrawPixels); - SET_Enable(table, save_Enable); - SET_EndList(table, _mesa_EndList); - SET_EvalMesh1(table, save_EvalMesh1); - SET_EvalMesh2(table, save_EvalMesh2); - SET_Finish(table, exec_Finish); - SET_Flush(table, exec_Flush); - SET_Fogf(table, save_Fogf); - SET_Fogfv(table, save_Fogfv); - SET_Fogi(table, save_Fogi); - SET_Fogiv(table, save_Fogiv); - SET_FrontFace(table, save_FrontFace); - SET_Frustum(table, save_Frustum); - SET_GenLists(table, _mesa_GenLists); - SET_GetBooleanv(table, exec_GetBooleanv); - SET_GetClipPlane(table, exec_GetClipPlane); - SET_GetDoublev(table, exec_GetDoublev); - SET_GetError(table, exec_GetError); - SET_GetFloatv(table, exec_GetFloatv); - SET_GetIntegerv(table, exec_GetIntegerv); - SET_GetLightfv(table, exec_GetLightfv); - SET_GetLightiv(table, exec_GetLightiv); - SET_GetMapdv(table, exec_GetMapdv); - SET_GetMapfv(table, exec_GetMapfv); - SET_GetMapiv(table, exec_GetMapiv); - SET_GetMaterialfv(table, exec_GetMaterialfv); - SET_GetMaterialiv(table, exec_GetMaterialiv); - SET_GetPixelMapfv(table, exec_GetPixelMapfv); - SET_GetPixelMapuiv(table, exec_GetPixelMapuiv); - SET_GetPixelMapusv(table, exec_GetPixelMapusv); - SET_GetPolygonStipple(table, exec_GetPolygonStipple); - SET_GetString(table, exec_GetString); - SET_GetTexEnvfv(table, exec_GetTexEnvfv); - SET_GetTexEnviv(table, exec_GetTexEnviv); - SET_GetTexGendv(table, exec_GetTexGendv); - SET_GetTexGenfv(table, exec_GetTexGenfv); - SET_GetTexGeniv(table, exec_GetTexGeniv); - SET_GetTexImage(table, exec_GetTexImage); - SET_GetTexLevelParameterfv(table, exec_GetTexLevelParameterfv); - SET_GetTexLevelParameteriv(table, exec_GetTexLevelParameteriv); - SET_GetTexParameterfv(table, exec_GetTexParameterfv); - SET_GetTexParameteriv(table, exec_GetTexParameteriv); - SET_Hint(table, save_Hint); - SET_IndexMask(table, save_IndexMask); - SET_InitNames(table, save_InitNames); - SET_IsEnabled(table, exec_IsEnabled); - SET_IsList(table, _mesa_IsList); - SET_LightModelf(table, save_LightModelf); - SET_LightModelfv(table, save_LightModelfv); - SET_LightModeli(table, save_LightModeli); - SET_LightModeliv(table, save_LightModeliv); - SET_Lightf(table, save_Lightf); - SET_Lightfv(table, save_Lightfv); - SET_Lighti(table, save_Lighti); - SET_Lightiv(table, save_Lightiv); - SET_LineStipple(table, save_LineStipple); - SET_LineWidth(table, save_LineWidth); - SET_ListBase(table, save_ListBase); - SET_LoadIdentity(table, save_LoadIdentity); - SET_LoadMatrixd(table, save_LoadMatrixd); - SET_LoadMatrixf(table, save_LoadMatrixf); - SET_LoadName(table, save_LoadName); - SET_LogicOp(table, save_LogicOp); - SET_Map1d(table, save_Map1d); - SET_Map1f(table, save_Map1f); - SET_Map2d(table, save_Map2d); - SET_Map2f(table, save_Map2f); - SET_MapGrid1d(table, save_MapGrid1d); - SET_MapGrid1f(table, save_MapGrid1f); - SET_MapGrid2d(table, save_MapGrid2d); - SET_MapGrid2f(table, save_MapGrid2f); - SET_MatrixMode(table, save_MatrixMode); - SET_MultMatrixd(table, save_MultMatrixd); - SET_MultMatrixf(table, save_MultMatrixf); - SET_NewList(table, save_NewList); - SET_Ortho(table, save_Ortho); - SET_PassThrough(table, save_PassThrough); - SET_PixelMapfv(table, save_PixelMapfv); - SET_PixelMapuiv(table, save_PixelMapuiv); - SET_PixelMapusv(table, save_PixelMapusv); - SET_PixelStoref(table, exec_PixelStoref); - SET_PixelStorei(table, exec_PixelStorei); - SET_PixelTransferf(table, save_PixelTransferf); - SET_PixelTransferi(table, save_PixelTransferi); - SET_PixelZoom(table, save_PixelZoom); - SET_PointSize(table, save_PointSize); - SET_PolygonMode(table, save_PolygonMode); - SET_PolygonOffset(table, save_PolygonOffset); - SET_PolygonStipple(table, save_PolygonStipple); - SET_PopAttrib(table, save_PopAttrib); - SET_PopMatrix(table, save_PopMatrix); - SET_PopName(table, save_PopName); - SET_PushAttrib(table, save_PushAttrib); - SET_PushMatrix(table, save_PushMatrix); - SET_PushName(table, save_PushName); - SET_RasterPos2d(table, save_RasterPos2d); - SET_RasterPos2dv(table, save_RasterPos2dv); - SET_RasterPos2f(table, save_RasterPos2f); - SET_RasterPos2fv(table, save_RasterPos2fv); - SET_RasterPos2i(table, save_RasterPos2i); - SET_RasterPos2iv(table, save_RasterPos2iv); - SET_RasterPos2s(table, save_RasterPos2s); - SET_RasterPos2sv(table, save_RasterPos2sv); - SET_RasterPos3d(table, save_RasterPos3d); - SET_RasterPos3dv(table, save_RasterPos3dv); - SET_RasterPos3f(table, save_RasterPos3f); - SET_RasterPos3fv(table, save_RasterPos3fv); - SET_RasterPos3i(table, save_RasterPos3i); - SET_RasterPos3iv(table, save_RasterPos3iv); - SET_RasterPos3s(table, save_RasterPos3s); - SET_RasterPos3sv(table, save_RasterPos3sv); - SET_RasterPos4d(table, save_RasterPos4d); - SET_RasterPos4dv(table, save_RasterPos4dv); - SET_RasterPos4f(table, save_RasterPos4f); - SET_RasterPos4fv(table, save_RasterPos4fv); - SET_RasterPos4i(table, save_RasterPos4i); - SET_RasterPos4iv(table, save_RasterPos4iv); - SET_RasterPos4s(table, save_RasterPos4s); - SET_RasterPos4sv(table, save_RasterPos4sv); - SET_ReadBuffer(table, save_ReadBuffer); - SET_ReadPixels(table, exec_ReadPixels); - SET_RenderMode(table, exec_RenderMode); - SET_Rotated(table, save_Rotated); - SET_Rotatef(table, save_Rotatef); - SET_Scaled(table, save_Scaled); - SET_Scalef(table, save_Scalef); - SET_Scissor(table, save_Scissor); - SET_FeedbackBuffer(table, exec_FeedbackBuffer); - SET_SelectBuffer(table, exec_SelectBuffer); - SET_ShadeModel(table, save_ShadeModel); - SET_StencilFunc(table, save_StencilFunc); - SET_StencilMask(table, save_StencilMask); - SET_StencilOp(table, save_StencilOp); - SET_TexEnvf(table, save_TexEnvf); - SET_TexEnvfv(table, save_TexEnvfv); - SET_TexEnvi(table, save_TexEnvi); - SET_TexEnviv(table, save_TexEnviv); - SET_TexGend(table, save_TexGend); - SET_TexGendv(table, save_TexGendv); - SET_TexGenf(table, save_TexGenf); - SET_TexGenfv(table, save_TexGenfv); - SET_TexGeni(table, save_TexGeni); - SET_TexGeniv(table, save_TexGeniv); - SET_TexImage1D(table, save_TexImage1D); - SET_TexImage2D(table, save_TexImage2D); - SET_TexParameterf(table, save_TexParameterf); - SET_TexParameterfv(table, save_TexParameterfv); - SET_TexParameteri(table, save_TexParameteri); - SET_TexParameteriv(table, save_TexParameteriv); - SET_Translated(table, save_Translated); - SET_Translatef(table, save_Translatef); - SET_Viewport(table, save_Viewport); - - /* GL 1.1 */ - SET_AreTexturesResident(table, exec_AreTexturesResident); - SET_BindTexture(table, save_BindTexture); - SET_ColorPointer(table, exec_ColorPointer); - SET_CopyTexImage1D(table, save_CopyTexImage1D); - SET_CopyTexImage2D(table, save_CopyTexImage2D); - SET_CopyTexSubImage1D(table, save_CopyTexSubImage1D); - SET_CopyTexSubImage2D(table, save_CopyTexSubImage2D); - SET_DeleteTextures(table, exec_DeleteTextures); - SET_DisableClientState(table, exec_DisableClientState); - SET_EdgeFlagPointer(table, exec_EdgeFlagPointer); - SET_EnableClientState(table, exec_EnableClientState); - SET_GenTextures(table, exec_GenTextures); - SET_GetPointerv(table, exec_GetPointerv); - SET_IndexPointer(table, exec_IndexPointer); - SET_InterleavedArrays(table, exec_InterleavedArrays); - SET_IsTexture(table, exec_IsTexture); - SET_NormalPointer(table, exec_NormalPointer); - SET_PopClientAttrib(table, exec_PopClientAttrib); - SET_PrioritizeTextures(table, save_PrioritizeTextures); - SET_PushClientAttrib(table, exec_PushClientAttrib); - SET_TexCoordPointer(table, exec_TexCoordPointer); - SET_TexSubImage1D(table, save_TexSubImage1D); - SET_TexSubImage2D(table, save_TexSubImage2D); - SET_VertexPointer(table, exec_VertexPointer); - - /* 3. GL_EXT_polygon_offset */ - SET_PolygonOffsetEXT(table, save_PolygonOffsetEXT); - - /* 30. GL_EXT_vertex_array */ - SET_ColorPointerEXT(table, exec_ColorPointerEXT); - SET_EdgeFlagPointerEXT(table, exec_EdgeFlagPointerEXT); - SET_IndexPointerEXT(table, exec_IndexPointerEXT); - SET_NormalPointerEXT(table, exec_NormalPointerEXT); - SET_TexCoordPointerEXT(table, exec_TexCoordPointerEXT); - SET_VertexPointerEXT(table, exec_VertexPointerEXT); - - /* 54. GL_EXT_point_parameters */ - SET_PointParameterfEXT(table, save_PointParameterfEXT); - SET_PointParameterfvEXT(table, save_PointParameterfvEXT); - - /* 97. GL_EXT_compiled_vertex_array */ - SET_LockArraysEXT(table, exec_LockArraysEXT); - SET_UnlockArraysEXT(table, exec_UnlockArraysEXT); - - /* 149. GL_EXT_fog_coord */ - SET_FogCoordPointerEXT(table, exec_FogCoordPointerEXT); - - /* 197. GL_MESA_window_pos */ - SET_WindowPos2dMESA(table, save_WindowPos2dMESA); - SET_WindowPos2dvMESA(table, save_WindowPos2dvMESA); - SET_WindowPos2fMESA(table, save_WindowPos2fMESA); - SET_WindowPos2fvMESA(table, save_WindowPos2fvMESA); - SET_WindowPos2iMESA(table, save_WindowPos2iMESA); - SET_WindowPos2ivMESA(table, save_WindowPos2ivMESA); - SET_WindowPos2sMESA(table, save_WindowPos2sMESA); - SET_WindowPos2svMESA(table, save_WindowPos2svMESA); - SET_WindowPos3dMESA(table, save_WindowPos3dMESA); - SET_WindowPos3dvMESA(table, save_WindowPos3dvMESA); - SET_WindowPos3fMESA(table, save_WindowPos3fMESA); - SET_WindowPos3fvMESA(table, save_WindowPos3fvMESA); - SET_WindowPos3iMESA(table, save_WindowPos3iMESA); - SET_WindowPos3ivMESA(table, save_WindowPos3ivMESA); - SET_WindowPos3sMESA(table, save_WindowPos3sMESA); - SET_WindowPos3svMESA(table, save_WindowPos3svMESA); - SET_WindowPos4dMESA(table, save_WindowPos4dMESA); - SET_WindowPos4dvMESA(table, save_WindowPos4dvMESA); - SET_WindowPos4fMESA(table, save_WindowPos4fMESA); - SET_WindowPos4fvMESA(table, save_WindowPos4fvMESA); - SET_WindowPos4iMESA(table, save_WindowPos4iMESA); - SET_WindowPos4ivMESA(table, save_WindowPos4ivMESA); - SET_WindowPos4sMESA(table, save_WindowPos4sMESA); - SET_WindowPos4svMESA(table, save_WindowPos4svMESA); - - /* 200. GL_IBM_multimode_draw_arrays */ - SET_MultiModeDrawArraysIBM(table, exec_MultiModeDrawArraysIBM); - SET_MultiModeDrawElementsIBM(table, exec_MultiModeDrawElementsIBM); - - /* 262. GL_NV_point_sprite */ - SET_PointParameteriNV(table, save_PointParameteriNV); - SET_PointParameterivNV(table, save_PointParameterivNV); - - /* ???. GL_EXT_depth_bounds_test */ - SET_DepthBoundsEXT(table, save_DepthBoundsEXT); - - /* ARB 3. GL_ARB_transpose_matrix */ - SET_LoadTransposeMatrixdARB(table, save_LoadTransposeMatrixdARB); - SET_LoadTransposeMatrixfARB(table, save_LoadTransposeMatrixfARB); - SET_MultTransposeMatrixdARB(table, save_MultTransposeMatrixdARB); - SET_MultTransposeMatrixfARB(table, save_MultTransposeMatrixfARB); - - /* ARB 5. GL_ARB_multisample */ - SET_SampleCoverageARB(table, save_SampleCoverageARB); - - /* ARB 28. GL_ARB_vertex_buffer_object */ - /* None of the extension's functions get compiled */ - SET_BindBufferARB(table, _mesa_BindBufferARB); - SET_BufferDataARB(table, _mesa_BufferDataARB); - SET_BufferSubDataARB(table, _mesa_BufferSubDataARB); - SET_DeleteBuffersARB(table, _mesa_DeleteBuffersARB); - SET_GenBuffersARB(table, _mesa_GenBuffersARB); - SET_GetBufferParameterivARB(table, _mesa_GetBufferParameterivARB); - SET_GetBufferPointervARB(table, _mesa_GetBufferPointervARB); - SET_GetBufferSubDataARB(table, _mesa_GetBufferSubDataARB); - SET_IsBufferARB(table, _mesa_IsBufferARB); - SET_MapBufferARB(table, _mesa_MapBufferARB); - SET_UnmapBufferARB(table, _mesa_UnmapBufferARB); - - /* ARB 50. GL_ARB_map_buffer_range */ -#if FEATURE_ARB_map_buffer_range - SET_MapBufferRange(table, _mesa_MapBufferRange); /* no dlist save */ - SET_FlushMappedBufferRange(table, _mesa_FlushMappedBufferRange); /* no dl */ -#endif - - /* GL_EXT_texture_integer */ - SET_ClearColorIiEXT(table, save_ClearColorIi); - SET_ClearColorIuiEXT(table, save_ClearColorIui); - SET_TexParameterIivEXT(table, save_TexParameterIiv); - SET_TexParameterIuivEXT(table, save_TexParameterIuiv); - SET_GetTexParameterIivEXT(table, exec_GetTexParameterIiv); - SET_GetTexParameterIuivEXT(table, exec_GetTexParameterIuiv); - - /* GL_ARB_texture_storage (no dlist support) */ - SET_TexStorage1D(table, _mesa_TexStorage1D); - SET_TexStorage2D(table, _mesa_TexStorage2D); - SET_TexStorage3D(table, _mesa_TexStorage3D); - SET_TextureStorage1DEXT(table, _mesa_TextureStorage1DEXT); - SET_TextureStorage2DEXT(table, _mesa_TextureStorage2DEXT); - SET_TextureStorage3DEXT(table, _mesa_TextureStorage3DEXT); - - return table; -} - - - -static const char * -enum_string(GLenum k) -{ - return _mesa_lookup_enum_by_nr(k); -} - - -/** - * Print the commands in a display list. For debugging only. - * TODO: many commands aren't handled yet. - */ -static void GLAPIENTRY -print_list(struct gl_context *ctx, GLuint list) -{ - struct gl_display_list *dlist; - Node *n; - GLboolean done; - - if (!islist(ctx, list)) { - printf("%u is not a display list ID\n", list); - return; - } - - dlist = lookup_list(ctx, list); - if (!dlist) - return; - - n = dlist->Head; - - printf("START-LIST %u, address %p\n", list, (void *) n); - - done = n ? GL_FALSE : GL_TRUE; - while (!done) { - const OpCode opcode = n[0].opcode; - - if (is_ext_opcode(opcode)) { - n += ext_opcode_print(ctx, n); - } - else { - switch (opcode) { - case OPCODE_ACCUM: - printf("Accum %s %g\n", enum_string(n[1].e), n[2].f); - break; - case OPCODE_BITMAP: - printf("Bitmap %d %d %g %g %g %g %p\n", n[1].i, n[2].i, - n[3].f, n[4].f, n[5].f, n[6].f, (void *) n[7].data); - break; - case OPCODE_CALL_LIST: - printf("CallList %d\n", (int) n[1].ui); - break; - case OPCODE_CALL_LIST_OFFSET: - printf("CallList %d + offset %u = %u\n", (int) n[1].ui, - ctx->List.ListBase, ctx->List.ListBase + n[1].ui); - break; - case OPCODE_DISABLE: - printf("Disable %s\n", enum_string(n[1].e)); - break; - case OPCODE_ENABLE: - printf("Enable %s\n", enum_string(n[1].e)); - break; - case OPCODE_FRUSTUM: - printf("Frustum %g %g %g %g %g %g\n", - n[1].f, n[2].f, n[3].f, n[4].f, n[5].f, n[6].f); - break; - case OPCODE_LINE_STIPPLE: - printf("LineStipple %d %x\n", n[1].i, (int) n[2].us); - break; - case OPCODE_LOAD_IDENTITY: - printf("LoadIdentity\n"); - break; - case OPCODE_LOAD_MATRIX: - printf("LoadMatrix\n"); - printf(" %8f %8f %8f %8f\n", - n[1].f, n[5].f, n[9].f, n[13].f); - printf(" %8f %8f %8f %8f\n", - n[2].f, n[6].f, n[10].f, n[14].f); - printf(" %8f %8f %8f %8f\n", - n[3].f, n[7].f, n[11].f, n[15].f); - printf(" %8f %8f %8f %8f\n", - n[4].f, n[8].f, n[12].f, n[16].f); - break; - case OPCODE_MULT_MATRIX: - printf("MultMatrix (or Rotate)\n"); - printf(" %8f %8f %8f %8f\n", - n[1].f, n[5].f, n[9].f, n[13].f); - printf(" %8f %8f %8f %8f\n", - n[2].f, n[6].f, n[10].f, n[14].f); - printf(" %8f %8f %8f %8f\n", - n[3].f, n[7].f, n[11].f, n[15].f); - printf(" %8f %8f %8f %8f\n", - n[4].f, n[8].f, n[12].f, n[16].f); - break; - case OPCODE_ORTHO: - printf("Ortho %g %g %g %g %g %g\n", - n[1].f, n[2].f, n[3].f, n[4].f, n[5].f, n[6].f); - break; - case OPCODE_POP_ATTRIB: - printf("PopAttrib\n"); - break; - case OPCODE_POP_MATRIX: - printf("PopMatrix\n"); - break; - case OPCODE_POP_NAME: - printf("PopName\n"); - break; - case OPCODE_PUSH_ATTRIB: - printf("PushAttrib %x\n", n[1].bf); - break; - case OPCODE_PUSH_MATRIX: - printf("PushMatrix\n"); - break; - case OPCODE_PUSH_NAME: - printf("PushName %d\n", (int) n[1].ui); - break; - case OPCODE_RASTER_POS: - printf("RasterPos %g %g %g %g\n", - n[1].f, n[2].f, n[3].f, n[4].f); - break; - case OPCODE_ROTATE: - printf("Rotate %g %g %g %g\n", - n[1].f, n[2].f, n[3].f, n[4].f); - break; - case OPCODE_SCALE: - printf("Scale %g %g %g\n", n[1].f, n[2].f, n[3].f); - break; - case OPCODE_TRANSLATE: - printf("Translate %g %g %g\n", n[1].f, n[2].f, n[3].f); - break; - case OPCODE_BIND_TEXTURE: - printf("BindTexture %s %d\n", - _mesa_lookup_enum_by_nr(n[1].ui), n[2].ui); - break; - case OPCODE_SHADE_MODEL: - printf("ShadeModel %s\n", _mesa_lookup_enum_by_nr(n[1].ui)); - break; - case OPCODE_MAP1: - printf("Map1 %s %.3f %.3f %d %d\n", - _mesa_lookup_enum_by_nr(n[1].ui), - n[2].f, n[3].f, n[4].i, n[5].i); - break; - case OPCODE_MAP2: - printf("Map2 %s %.3f %.3f %.3f %.3f %d %d %d %d\n", - _mesa_lookup_enum_by_nr(n[1].ui), - n[2].f, n[3].f, n[4].f, n[5].f, - n[6].i, n[7].i, n[8].i, n[9].i); - break; - case OPCODE_MAPGRID1: - printf("MapGrid1 %d %.3f %.3f\n", n[1].i, n[2].f, n[3].f); - break; - case OPCODE_MAPGRID2: - printf("MapGrid2 %d %.3f %.3f, %d %.3f %.3f\n", - n[1].i, n[2].f, n[3].f, n[4].i, n[5].f, n[6].f); - break; - case OPCODE_EVALMESH1: - printf("EvalMesh1 %d %d\n", n[1].i, n[2].i); - break; - case OPCODE_EVALMESH2: - printf("EvalMesh2 %d %d %d %d\n", - n[1].i, n[2].i, n[3].i, n[4].i); - break; - - case OPCODE_ATTR_1F_NV: - printf("ATTR_1F_NV attr %d: %f\n", n[1].i, n[2].f); - break; - case OPCODE_ATTR_2F_NV: - printf("ATTR_2F_NV attr %d: %f %f\n", - n[1].i, n[2].f, n[3].f); - break; - case OPCODE_ATTR_3F_NV: - printf("ATTR_3F_NV attr %d: %f %f %f\n", - n[1].i, n[2].f, n[3].f, n[4].f); - break; - case OPCODE_ATTR_4F_NV: - printf("ATTR_4F_NV attr %d: %f %f %f %f\n", - n[1].i, n[2].f, n[3].f, n[4].f, n[5].f); - break; - - case OPCODE_MATERIAL: - printf("MATERIAL %x %x: %f %f %f %f\n", - n[1].i, n[2].i, n[3].f, n[4].f, n[5].f, n[6].f); - break; - case OPCODE_BEGIN: - printf("BEGIN %x\n", n[1].i); - break; - case OPCODE_END: - printf("END\n"); - break; - case OPCODE_RECTF: - printf("RECTF %f %f %f %f\n", n[1].f, n[2].f, n[3].f, - n[4].f); - break; - case OPCODE_EVAL_C1: - printf("EVAL_C1 %f\n", n[1].f); - break; - case OPCODE_EVAL_C2: - printf("EVAL_C2 %f %f\n", n[1].f, n[2].f); - break; - case OPCODE_EVAL_P1: - printf("EVAL_P1 %d\n", n[1].i); - break; - case OPCODE_EVAL_P2: - printf("EVAL_P2 %d %d\n", n[1].i, n[2].i); - break; - - /* - * meta opcodes/commands - */ - case OPCODE_ERROR: - printf("Error: %s %s\n", - enum_string(n[1].e), (const char *) n[2].data); - break; - case OPCODE_CONTINUE: - printf("DISPLAY-LIST-CONTINUE\n"); - n = (Node *) n[1].next; - break; - case OPCODE_END_OF_LIST: - printf("END-LIST %u\n", list); - done = GL_TRUE; - break; - default: - if (opcode < 0 || opcode > OPCODE_END_OF_LIST) { - printf - ("ERROR IN DISPLAY LIST: opcode = %d, address = %p\n", - opcode, (void *) n); - return; - } - else { - printf("command %d, %u operands\n", opcode, - InstSize[opcode]); - } - } - /* increment n to point to next compiled command */ - if (opcode != OPCODE_CONTINUE) { - n += InstSize[opcode]; - } - } - } -} - - - -/** - * Clients may call this function to help debug display list problems. - * This function is _ONLY_FOR_DEBUGGING_PURPOSES_. It may be removed, - * changed, or break in the future without notice. - */ -void -mesa_print_display_list(GLuint list) -{ - GET_CURRENT_CONTEXT(ctx); - print_list(ctx, list); -} - - -/**********************************************************************/ -/***** Initialization *****/ -/**********************************************************************/ - -void -_mesa_save_vtxfmt_init(GLvertexformat * vfmt) -{ - _MESA_INIT_ARRAYELT_VTXFMT(vfmt, _ae_); - - vfmt->Begin = save_Begin; - - _MESA_INIT_DLIST_VTXFMT(vfmt, save_); - - vfmt->Color3f = save_Color3f; - vfmt->Color3fv = save_Color3fv; - vfmt->Color4f = save_Color4f; - vfmt->Color4fv = save_Color4fv; - vfmt->EdgeFlag = save_EdgeFlag; - vfmt->End = save_End; - - _MESA_INIT_EVAL_VTXFMT(vfmt, save_); - - vfmt->FogCoordfEXT = save_FogCoordfEXT; - vfmt->FogCoordfvEXT = save_FogCoordfvEXT; - vfmt->Indexf = save_Indexf; - vfmt->Indexfv = save_Indexfv; - vfmt->Materialfv = save_Materialfv; - vfmt->Normal3f = save_Normal3f; - vfmt->Normal3fv = save_Normal3fv; - vfmt->TexCoord1f = save_TexCoord1f; - vfmt->TexCoord1fv = save_TexCoord1fv; - vfmt->TexCoord2f = save_TexCoord2f; - vfmt->TexCoord2fv = save_TexCoord2fv; - vfmt->TexCoord3f = save_TexCoord3f; - vfmt->TexCoord3fv = save_TexCoord3fv; - vfmt->TexCoord4f = save_TexCoord4f; - vfmt->TexCoord4fv = save_TexCoord4fv; - vfmt->Vertex2f = save_Vertex2f; - vfmt->Vertex2fv = save_Vertex2fv; - vfmt->Vertex3f = save_Vertex3f; - vfmt->Vertex3fv = save_Vertex3fv; - vfmt->Vertex4f = save_Vertex4f; - vfmt->Vertex4fv = save_Vertex4fv; - vfmt->VertexAttrib1fNV = save_VertexAttrib1fNV; - vfmt->VertexAttrib1fvNV = save_VertexAttrib1fvNV; - vfmt->VertexAttrib2fNV = save_VertexAttrib2fNV; - vfmt->VertexAttrib2fvNV = save_VertexAttrib2fvNV; - vfmt->VertexAttrib3fNV = save_VertexAttrib3fNV; - vfmt->VertexAttrib3fvNV = save_VertexAttrib3fvNV; - vfmt->VertexAttrib4fNV = save_VertexAttrib4fNV; - vfmt->VertexAttrib4fvNV = save_VertexAttrib4fvNV; - - vfmt->Rectf = save_Rectf; - - /* The driver is required to implement these as - * 1) They can probably do a better job. - * 2) A lot of new mechanisms would have to be added to this module - * to support it. That code would probably never get used, - * because of (1). - */ -#if 0 - vfmt->DrawArrays = 0; - vfmt->DrawElements = 0; -#endif -} - - -void -_mesa_install_dlist_vtxfmt(struct _glapi_table *disp, - const GLvertexformat *vfmt) -{ - SET_CallList(disp, vfmt->CallList); - SET_CallLists(disp, vfmt->CallLists); -} - - -void _mesa_init_dlist_dispatch(struct _glapi_table *disp) -{ - SET_CallList(disp, _mesa_CallList); - SET_CallLists(disp, _mesa_CallLists); - - SET_DeleteLists(disp, _mesa_DeleteLists); - SET_EndList(disp, _mesa_EndList); - SET_GenLists(disp, _mesa_GenLists); - SET_IsList(disp, _mesa_IsList); - SET_ListBase(disp, _mesa_ListBase); - SET_NewList(disp, _mesa_NewList); -} - - -#endif /* FEATURE_dlist */ - - -/** - * Initialize display list state for given context. - */ -void -_mesa_init_display_list(struct gl_context *ctx) -{ - static GLboolean tableInitialized = GL_FALSE; - - /* zero-out the instruction size table, just once */ - if (!tableInitialized) { - memset(InstSize, 0, sizeof(InstSize)); - tableInitialized = GL_TRUE; - } - - /* extension info */ - ctx->ListExt = CALLOC_STRUCT(gl_list_extensions); - - /* Display list */ - ctx->ListState.CallDepth = 0; - ctx->ExecuteFlag = GL_TRUE; - ctx->CompileFlag = GL_FALSE; - ctx->ListState.CurrentBlock = NULL; - ctx->ListState.CurrentPos = 0; - - /* Display List group */ - ctx->List.ListBase = 0; - -#if FEATURE_dlist - _mesa_save_vtxfmt_init(&ctx->ListState.ListVtxfmt); -#endif -} - - -void -_mesa_free_display_list_data(struct gl_context *ctx) -{ - free(ctx->ListExt); - ctx->ListExt = NULL; -} diff --git a/dll/opengl/mesa/main/dlist.h b/dll/opengl/mesa/main/dlist.h deleted file mode 100644 index 89008431a88..00000000000 --- a/dll/opengl/mesa/main/dlist.h +++ /dev/null @@ -1,104 +0,0 @@ -/** - * \file dlist.h - * Display lists management. - */ - -/* - * Mesa 3-D graphics library - * Version: 6.5.1 - * - * Copyright (C) 1999-2006 Brian Paul All Rights Reserved. - * - * Permission is hereby granted, free of charge, to any person obtaining a - * copy of this software and associated documentation files (the "Software"), - * to deal in the Software without restriction, including without limitation - * the rights to use, copy, modify, merge, publish, distribute, sublicense, - * and/or sell copies of the Software, and to permit persons to whom the - * Software is furnished to do so, subject to the following conditions: - * - * The above copyright notice and this permission notice shall be included - * in all copies or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS - * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL - * BRIAN PAUL BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN - * AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN - * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. - */ - - - -#ifndef DLIST_H -#define DLIST_H - - -#include "main/mfeatures.h" -#include "main/mtypes.h" - - -#if FEATURE_dlist - -#define _MESA_INIT_DLIST_VTXFMT(vfmt, impl) \ - do { \ - (vfmt)->CallList = impl ## CallList; \ - (vfmt)->CallLists = impl ## CallLists; \ - } while (0) - -extern void GLAPIENTRY _mesa_CallList( GLuint list ); - -extern void GLAPIENTRY _mesa_CallLists( GLsizei n, GLenum type, const GLvoid *lists ); - - -extern void _mesa_compile_error( struct gl_context *ctx, GLenum error, const char *s ); - -extern void *_mesa_dlist_alloc(struct gl_context *ctx, GLuint opcode, GLuint sz); - -extern GLint _mesa_dlist_alloc_opcode( struct gl_context *ctx, GLuint sz, - void (*execute)( struct gl_context *, void * ), - void (*destroy)( struct gl_context *, void * ), - void (*print)( struct gl_context *, void * ) ); - -extern void _mesa_delete_list(struct gl_context *ctx, struct gl_display_list *dlist); - -extern void _mesa_save_vtxfmt_init( GLvertexformat *vfmt ); - -extern struct _glapi_table *_mesa_create_save_table(void); - -extern void _mesa_install_dlist_vtxfmt(struct _glapi_table *disp, - const GLvertexformat *vfmt); - -extern void _mesa_init_dlist_dispatch(struct _glapi_table *disp); - -#else /* FEATURE_dlist */ - -#include "main/compiler.h" - -#define _MESA_INIT_DLIST_VTXFMT(vfmt, impl) do { } while (0) - -static inline void -_mesa_delete_list(struct gl_context *ctx, struct gl_display_list *dlist) -{ - /* there should be no list to delete */ - ASSERT_NO_FEATURE(); -} - -static inline void -_mesa_install_dlist_vtxfmt(struct _glapi_table *disp, - const GLvertexformat *vfmt) -{ -} - -static inline void -_mesa_init_dlist_dispatch(struct _glapi_table *disp) -{ -} - -#endif /* FEATURE_dlist */ - -extern void _mesa_init_display_list( struct gl_context * ctx ); - -extern void _mesa_free_display_list_data(struct gl_context *ctx); - - -#endif /* DLIST_H */ diff --git a/dll/opengl/mesa/main/dlopen.c b/dll/opengl/mesa/main/dlopen.c deleted file mode 100644 index 7d2f4214b35..00000000000 --- a/dll/opengl/mesa/main/dlopen.c +++ /dev/null @@ -1,113 +0,0 @@ -/* - * Mesa 3-D graphics library - * - * Copyright (C) 1999-2008 Brian Paul All Rights Reserved. - * - * Permission is hereby granted, free of charge, to any person obtaining a - * copy of this software and associated documentation files (the "Software"), - * to deal in the Software without restriction, including without limitation - * the rights to use, copy, modify, merge, publish, distribute, sublicense, - * and/or sell copies of the Software, and to permit persons to whom the - * Software is furnished to do so, subject to the following conditions: - * - * The above copyright notice and this permission notice shall be included - * in all copies or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS - * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL - * BRIAN PAUL BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN - * AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN - * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. - */ - -/** - * Wrapper functions for dlopen(), dlsym(), dlclose(). - * Note that the #ifdef tests for various environments should be expanded. - */ - -#include - -#include "dlopen.h" - -#if defined(_GNU_SOURCE) && !defined(__MINGW32__) && !defined(__blrts) -#include -#endif -#if defined(_WIN32) -//#include -#include -#include -#endif - - -/** - * Wrapper for dlopen(). - * Note that 'flags' isn't used at this time. - */ -void * -_mesa_dlopen(const char *libname, int flags) -{ -#if defined(__blrts) - return NULL; -#elif defined(_GNU_SOURCE) - flags = RTLD_LAZY | RTLD_GLOBAL; /* Overriding flags at this time */ - return dlopen(libname, flags); -#elif defined(__MINGW32__) - return LoadLibraryA(libname); -#else - return NULL; -#endif -} - - -/** - * Wrapper for dlsym() that does a cast to a generic function type, - * rather than a void *. This reduces the number of warnings that are - * generated. - */ -GenericFunc -_mesa_dlsym(void *handle, const char *fname) -{ - union { - void *v; - GenericFunc f; - } u; -#if defined(__blrts) - u.v = NULL; -#elif defined(__DJGPP__) - /* need '_' prefix on symbol names */ - char fname2[1000]; - fname2[0] = '_'; - strncpy(fname2 + 1, fname, 998); - fname2[999] = 0; - u.v = dlsym(handle, fname2); -#elif defined(_GNU_SOURCE) - u.v = dlsym(handle, fname); -#elif defined(__MINGW32__) - u.v = (void *) GetProcAddress(handle, fname); -#else - u.v = NULL; -#endif - return u.f; -} - - -/** - * Wrapper for dlclose(). - */ -void -_mesa_dlclose(void *handle) -{ -#if defined(__blrts) - (void) handle; -#elif defined(_GNU_SOURCE) - dlclose(handle); -#elif defined(__MINGW32__) - FreeLibrary(handle); -#else - (void) handle; -#endif -} - - - diff --git a/dll/opengl/mesa/main/dlopen.h b/dll/opengl/mesa/main/dlopen.h deleted file mode 100644 index 9895a22549a..00000000000 --- a/dll/opengl/mesa/main/dlopen.h +++ /dev/null @@ -1,42 +0,0 @@ -/* - * Mesa 3-D graphics library - * - * Copyright (C) 1999-2008 Brian Paul All Rights Reserved. - * - * Permission is hereby granted, free of charge, to any person obtaining a - * copy of this software and associated documentation files (the "Software"), - * to deal in the Software without restriction, including without limitation - * the rights to use, copy, modify, merge, publish, distribute, sublicense, - * and/or sell copies of the Software, and to permit persons to whom the - * Software is furnished to do so, subject to the following conditions: - * - * The above copyright notice and this permission notice shall be included - * in all copies or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS - * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL - * BRIAN PAUL BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN - * AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN - * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. - */ - - -#ifndef DLOPEN_H -#define DLOPEN_H - - -typedef void (*GenericFunc)(void); - - -extern void * -_mesa_dlopen(const char *libname, int flags); - -extern GenericFunc -_mesa_dlsym(void *handle, const char *fname); - -extern void -_mesa_dlclose(void *handle); - - -#endif diff --git a/dll/opengl/mesa/main/drawpix.c b/dll/opengl/mesa/main/drawpix.c deleted file mode 100644 index a92a403f4a2..00000000000 --- a/dll/opengl/mesa/main/drawpix.c +++ /dev/null @@ -1,260 +0,0 @@ -/* - * Mesa 3-D graphics library - * Version: 7.1 - * - * Copyright (C) 1999-2008 Brian Paul All Rights Reserved. - * - * Permission is hereby granted, free of charge, to any person obtaining a - * copy of this software and associated documentation files (the "Software"), - * to deal in the Software without restriction, including without limitation - * the rights to use, copy, modify, merge, publish, distribute, sublicense, - * and/or sell copies of the Software, and to permit persons to whom the - * Software is furnished to do so, subject to the following conditions: - * - * The above copyright notice and this permission notice shall be included - * in all copies or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS - * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL - * BRIAN PAUL BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN - * AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN - * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. - */ - -#include - -#if FEATURE_drawpix - - -/* - * Execute glDrawPixels - */ -static void GLAPIENTRY -_mesa_DrawPixels( GLsizei width, GLsizei height, - GLenum format, GLenum type, const GLvoid *pixels ) -{ - GET_CURRENT_CONTEXT(ctx); - ASSERT_OUTSIDE_BEGIN_END_AND_FLUSH(ctx); - - if (MESA_VERBOSE & VERBOSE_API) - _mesa_debug(ctx, "glDrawPixels(%d, %d, %s, %s, %p) // to %s at %d, %d\n", - width, height, - _mesa_lookup_enum_by_nr(format), - _mesa_lookup_enum_by_nr(type), - pixels, - _mesa_lookup_enum_by_nr(ctx->DrawBuffer->ColorDrawBuffer), - IROUND(ctx->Current.RasterPos[0]), - IROUND(ctx->Current.RasterPos[1])); - - - if (width < 0 || height < 0) { - _mesa_error( ctx, GL_INVALID_VALUE, "glDrawPixels(width or height < 0)" ); - return; - } - - /* Note: this call does state validation */ - if (!_mesa_valid_to_render(ctx, "glDrawPixels")) { - return; /* the error code was recorded */ - } - - /* GL 3.0 introduced a new restriction on glDrawPixels() over what was in - * GL_EXT_texture_integer. From section 3.7.4 ("Rasterization of Pixel - * Rectangles) on page 151 of the GL 3.0 specification: - * - * "If format contains integer components, as shown in table 3.6, an - * INVALID OPERATION error is generated." - * - * Since DrawPixels rendering would be merely undefined if not an error (due - * to a lack of defined mapping from integer data to gl_Color fragment shader - * input), NVIDIA's implementation also just returns this error despite - * exposing GL_EXT_texture_integer, just return an error regardless. - */ - if (_mesa_is_integer_format(format)) { - _mesa_error(ctx, GL_INVALID_OPERATION, "glDrawPixels(integer format)"); - return; - } - - if (_mesa_error_check_format_type(ctx, format, type, GL_TRUE)) { - return; /* the error code was recorded */ - } - - if (ctx->RasterDiscard) { - return; - } - - if (!ctx->Current.RasterPosValid) { - return; /* no-op, not an error */ - } - - if (ctx->RenderMode == GL_RENDER) { - if (width > 0 && height > 0) { - /* Round, to satisfy conformance tests (matches SGI's OpenGL) */ - GLint x = IROUND(ctx->Current.RasterPos[0]); - GLint y = IROUND(ctx->Current.RasterPos[1]); - - ctx->Driver.DrawPixels(ctx, x, y, width, height, format, type, - &ctx->Unpack, pixels); - } - } - else if (ctx->RenderMode == GL_FEEDBACK) { - /* Feedback the current raster pos info */ - FLUSH_CURRENT( ctx, 0 ); - _mesa_feedback_token( ctx, (GLfloat) (GLint) GL_DRAW_PIXEL_TOKEN ); - _mesa_feedback_vertex( ctx, - ctx->Current.RasterPos, - ctx->Current.RasterColor, - ctx->Current.RasterTexCoords ); - } - else { - ASSERT(ctx->RenderMode == GL_SELECT); - /* Do nothing. See OpenGL Spec, Appendix B, Corollary 6. */ - } -} - - -static void GLAPIENTRY -_mesa_CopyPixels( GLint srcx, GLint srcy, GLsizei width, GLsizei height, - GLenum type ) -{ - GET_CURRENT_CONTEXT(ctx); - ASSERT_OUTSIDE_BEGIN_END_AND_FLUSH(ctx); - - if (MESA_VERBOSE & VERBOSE_API) - _mesa_debug(ctx, - "glCopyPixels(%d, %d, %d, %d, %s) // from %s to %s at %d, %d\n", - srcx, srcy, width, height, - _mesa_lookup_enum_by_nr(type), - _mesa_lookup_enum_by_nr(ctx->ReadBuffer->ColorReadBuffer), - _mesa_lookup_enum_by_nr(ctx->DrawBuffer->ColorDrawBuffer), - IROUND(ctx->Current.RasterPos[0]), - IROUND(ctx->Current.RasterPos[1])); - - if (width < 0 || height < 0) { - _mesa_error(ctx, GL_INVALID_VALUE, "glCopyPixels(width or height < 0)"); - return; - } - - /* Note: more detailed 'type' checking is done by the - * _mesa_source/dest_buffer_exists() calls below. That's where we - * check if the stencil buffer exists, etc. - */ - if (type != GL_COLOR && - type != GL_DEPTH && - type != GL_STENCIL) { - _mesa_error(ctx, GL_INVALID_ENUM, "glCopyPixels(type=%s)", - _mesa_lookup_enum_by_nr(type)); - return; - } - - /* Note: this call does state validation */ - if (!_mesa_valid_to_render(ctx, "glCopyPixels")) { - return; /* the error code was recorded */ - } - - if (!_mesa_source_buffer_exists(ctx, type) || - !_mesa_dest_buffer_exists(ctx, type)) { - _mesa_error(ctx, GL_INVALID_OPERATION, - "glCopyPixels(missing source or dest buffer)"); - return; - } - - if (ctx->RasterDiscard) { - return; - } - - if (!ctx->Current.RasterPosValid || width == 0 || height == 0) { - return; /* no-op, not an error */ - } - - if (ctx->RenderMode == GL_RENDER) { - /* Round to satisfy conformance tests (matches SGI's OpenGL) */ - if (width > 0 && height > 0) { - GLint destx = IROUND(ctx->Current.RasterPos[0]); - GLint desty = IROUND(ctx->Current.RasterPos[1]); - ctx->Driver.CopyPixels( ctx, srcx, srcy, width, height, destx, desty, - type ); - } - } - else if (ctx->RenderMode == GL_FEEDBACK) { - FLUSH_CURRENT( ctx, 0 ); - _mesa_feedback_token( ctx, (GLfloat) (GLint) GL_COPY_PIXEL_TOKEN ); - _mesa_feedback_vertex( ctx, - ctx->Current.RasterPos, - ctx->Current.RasterColor, - ctx->Current.RasterTexCoords ); - } - else { - ASSERT(ctx->RenderMode == GL_SELECT); - /* Do nothing. See OpenGL Spec, Appendix B, Corollary 6. */ - } -} - - -static void GLAPIENTRY -_mesa_Bitmap( GLsizei width, GLsizei height, - GLfloat xorig, GLfloat yorig, GLfloat xmove, GLfloat ymove, - const GLubyte *bitmap ) -{ - GET_CURRENT_CONTEXT(ctx); - ASSERT_OUTSIDE_BEGIN_END_AND_FLUSH(ctx); - - if (width < 0 || height < 0) { - _mesa_error( ctx, GL_INVALID_VALUE, "glBitmap(width or height < 0)" ); - return; - } - - if (!ctx->Current.RasterPosValid) { - return; /* do nothing */ - } - - /* Note: this call does state validation */ - if (!_mesa_valid_to_render(ctx, "glBitmap")) { - /* the error code was recorded */ - return; - } - - if (ctx->RasterDiscard) - return; - - if (ctx->RenderMode == GL_RENDER) { - /* Truncate, to satisfy conformance tests (matches SGI's OpenGL). */ - if (width > 0 && height > 0) { - const GLfloat epsilon = 0.0001F; - GLint x = IFLOOR(ctx->Current.RasterPos[0] + epsilon - xorig); - GLint y = IFLOOR(ctx->Current.RasterPos[1] + epsilon - yorig); - - ctx->Driver.Bitmap( ctx, x, y, width, height, &ctx->Unpack, bitmap ); - } - } -#if _HAVE_FULL_GL - else if (ctx->RenderMode == GL_FEEDBACK) { - FLUSH_CURRENT(ctx, 0); - _mesa_feedback_token( ctx, (GLfloat) (GLint) GL_BITMAP_TOKEN ); - _mesa_feedback_vertex( ctx, - ctx->Current.RasterPos, - ctx->Current.RasterColor, - ctx->Current.RasterTexCoords ); - } - else { - ASSERT(ctx->RenderMode == GL_SELECT); - /* Do nothing. See OpenGL Spec, Appendix B, Corollary 6. */ - } -#endif - - /* update raster position */ - ctx->Current.RasterPos[0] += xmove; - ctx->Current.RasterPos[1] += ymove; -} - - -void -_mesa_init_drawpix_dispatch(struct _glapi_table *disp) -{ - SET_Bitmap(disp, _mesa_Bitmap); - SET_CopyPixels(disp, _mesa_CopyPixels); - SET_DrawPixels(disp, _mesa_DrawPixels); -} - - -#endif /* FEATURE_drawpix */ diff --git a/dll/opengl/mesa/main/drawpix.h b/dll/opengl/mesa/main/drawpix.h deleted file mode 100644 index 13efba5f8ff..00000000000 --- a/dll/opengl/mesa/main/drawpix.h +++ /dev/null @@ -1,50 +0,0 @@ -/* - * Mesa 3-D graphics library - * Version: 7.1 - * - * Copyright (C) 1999-2008 Brian Paul All Rights Reserved. - * - * Permission is hereby granted, free of charge, to any person obtaining a - * copy of this software and associated documentation files (the "Software"), - * to deal in the Software without restriction, including without limitation - * the rights to use, copy, modify, merge, publish, distribute, sublicense, - * and/or sell copies of the Software, and to permit persons to whom the - * Software is furnished to do so, subject to the following conditions: - * - * The above copyright notice and this permission notice shall be included - * in all copies or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS - * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL - * BRIAN PAUL BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN - * AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN - * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. - */ - -#ifndef DRAWPIX_H -#define DRAWPIX_H - - -#include "compiler.h" -#include "mfeatures.h" - -struct _glapi_table; - - -#if FEATURE_drawpix - -extern void -_mesa_init_drawpix_dispatch(struct _glapi_table *disp); - -#else /* FEATURE_drawpix */ - -static inline void -_mesa_init_drawpix_dispatch(struct _glapi_table *disp) -{ -} - -#endif /* FEATURE_drawpix */ - - -#endif /* DRAWPIX_H */ diff --git a/dll/opengl/mesa/main/enable.c b/dll/opengl/mesa/main/enable.c deleted file mode 100644 index 8ba5a5e732d..00000000000 --- a/dll/opengl/mesa/main/enable.c +++ /dev/null @@ -1,931 +0,0 @@ -/** - * \file enable.c - * Enable/disable/query GL capabilities. - */ - -/* - * Mesa 3-D graphics library - * - * Copyright (C) 1999-2007 Brian Paul All Rights Reserved. - * - * Permission is hereby granted, free of charge, to any person obtaining a - * copy of this software and associated documentation files (the "Software"), - * to deal in the Software without restriction, including without limitation - * the rights to use, copy, modify, merge, publish, distribute, sublicense, - * and/or sell copies of the Software, and to permit persons to whom the - * Software is furnished to do so, subject to the following conditions: - * - * The above copyright notice and this permission notice shall be included - * in all copies or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS - * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL - * BRIAN PAUL BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN - * AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN - * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. - */ - - -#include - -#define CHECK_EXTENSION(EXTNAME, CAP) \ - if (!ctx->Extensions.EXTNAME) { \ - goto invalid_enum_error; \ - } - - -/** - * Helper to enable/disable client-side state. - */ -static void -client_state(struct gl_context *ctx, GLenum cap, GLboolean state) -{ - GLbitfield64 flag; - GLboolean *var; - - switch (cap) { - case GL_VERTEX_ARRAY: - var = &ctx->Array.VertexAttrib[VERT_ATTRIB_POS].Enabled; - flag = VERT_BIT_POS; - break; - case GL_NORMAL_ARRAY: - var = &ctx->Array.VertexAttrib[VERT_ATTRIB_NORMAL].Enabled; - flag = VERT_BIT_NORMAL; - break; - case GL_COLOR_ARRAY: - var = &ctx->Array.VertexAttrib[VERT_ATTRIB_COLOR].Enabled; - flag = VERT_BIT_COLOR; - break; - case GL_INDEX_ARRAY: - var = &ctx->Array.VertexAttrib[VERT_ATTRIB_COLOR_INDEX].Enabled; - flag = VERT_BIT_COLOR_INDEX; - break; - case GL_TEXTURE_COORD_ARRAY: - var = &ctx->Array.VertexAttrib[VERT_ATTRIB_TEX].Enabled; - flag = VERT_BIT_TEX; - break; - case GL_EDGE_FLAG_ARRAY: - var = &ctx->Array.VertexAttrib[VERT_ATTRIB_EDGEFLAG].Enabled; - flag = VERT_BIT_EDGEFLAG; - break; - case GL_FOG_COORDINATE_ARRAY_EXT: - var = &ctx->Array.VertexAttrib[VERT_ATTRIB_FOG].Enabled; - flag = VERT_BIT_FOG; - break; - - default: - goto invalid_enum_error; - } - - if (*var == state) - return; - - FLUSH_VERTICES(ctx, _NEW_ARRAY); - ctx->Array.NewState |= flag; - - _ae_invalidate_state(ctx, _NEW_ARRAY); - - *var = state; - - if (state) - ctx->Array._Enabled |= flag; - else - ctx->Array._Enabled &= ~flag; - - if (ctx->Driver.Enable) { - ctx->Driver.Enable( ctx, cap, state ); - } - - return; - -invalid_enum_error: - _mesa_error(ctx, GL_INVALID_ENUM, "gl%sClientState(0x%x)", - state ? "Enable" : "Disable", cap); -} - - -/** - * Enable GL capability. - * \param cap state to enable/disable. - * - * Get's the current context, assures that we're outside glBegin()/glEnd() and - * calls client_state(). - */ -void GLAPIENTRY -_mesa_EnableClientState( GLenum cap ) -{ - GET_CURRENT_CONTEXT(ctx); - ASSERT_OUTSIDE_BEGIN_END(ctx); - client_state( ctx, cap, GL_TRUE ); -} - - -/** - * Disable GL capability. - * \param cap state to enable/disable. - * - * Get's the current context, assures that we're outside glBegin()/glEnd() and - * calls client_state(). - */ -void GLAPIENTRY -_mesa_DisableClientState( GLenum cap ) -{ - GET_CURRENT_CONTEXT(ctx); - ASSERT_OUTSIDE_BEGIN_END(ctx); - client_state( ctx, cap, GL_FALSE ); -} - - -#undef CHECK_EXTENSION -#define CHECK_EXTENSION(EXTNAME, CAP) \ - if (!ctx->Extensions.EXTNAME) { \ - goto invalid_enum_error; \ - } - -#define CHECK_EXTENSION2(EXT1, EXT2, CAP) \ - if (!ctx->Extensions.EXT1 && !ctx->Extensions.EXT2) { \ - goto invalid_enum_error; \ - } - - - -/** - * Return pointer to current texture unit for setting/getting coordinate - * state. - * Note that we'll set GL_INVALID_OPERATION and return NULL if the active - * texture unit is higher than the number of supported coordinate units. - */ -static inline struct gl_texture_unit * -get_texcoord_unit(struct gl_context *ctx) -{ - return &ctx->Texture.Unit; -} - - -/** - * Helper function to enable or disable a texture target. - * \param bit one of the TEXTURE_x_BIT values - * \return GL_TRUE if state is changing or GL_FALSE if no change - */ -static GLboolean -enable_texture(struct gl_context *ctx, GLboolean state, GLbitfield texBit) -{ - struct gl_texture_unit *texUnit = &ctx->Texture.Unit; - const GLbitfield newenabled = state - ? (texUnit->Enabled | texBit) : (texUnit->Enabled & ~texBit); - - if (texUnit->Enabled == newenabled) - return GL_FALSE; - - FLUSH_VERTICES(ctx, _NEW_TEXTURE); - texUnit->Enabled = newenabled; - return GL_TRUE; -} - - -/** - * Helper function to enable or disable state. - * - * \param ctx GL context. - * \param cap the state to enable/disable - * \param state whether to enable or disable the specified capability. - * - * Updates the current context and flushes the vertices as needed. For - * capabilities associated with extensions it verifies that those extensions - * are effectivly present before updating. Notifies the driver via - * dd_function_table::Enable. - */ -void -_mesa_set_enable(struct gl_context *ctx, GLenum cap, GLboolean state) -{ - if (MESA_VERBOSE & VERBOSE_API) - _mesa_debug(ctx, "%s %s (newstate is %x)\n", - state ? "glEnable" : "glDisable", - _mesa_lookup_enum_by_nr(cap), - ctx->NewState); - - switch (cap) { - case GL_ALPHA_TEST: - if (ctx->Color.AlphaEnabled == state) - return; - FLUSH_VERTICES(ctx, _NEW_COLOR); - ctx->Color.AlphaEnabled = state; - break; - case GL_AUTO_NORMAL: - if (ctx->Eval.AutoNormal == state) - return; - FLUSH_VERTICES(ctx, _NEW_EVAL); - ctx->Eval.AutoNormal = state; - break; - case GL_BLEND: - { - if (state != ctx->Color.BlendEnabled) { - FLUSH_VERTICES(ctx, _NEW_COLOR); - ctx->Color.BlendEnabled = state; - } - } - break; -#if FEATURE_userclip - case GL_CLIP_DISTANCE0: - case GL_CLIP_DISTANCE1: - case GL_CLIP_DISTANCE2: - case GL_CLIP_DISTANCE3: - case GL_CLIP_DISTANCE4: - case GL_CLIP_DISTANCE5: - case GL_CLIP_DISTANCE6: - case GL_CLIP_DISTANCE7: - { - const GLuint p = cap - GL_CLIP_DISTANCE0; - - if (p >= ctx->Const.MaxClipPlanes) - goto invalid_enum_error; - - if ((ctx->Transform.ClipPlanesEnabled & (1 << p)) - == ((GLuint) state << p)) - return; - - FLUSH_VERTICES(ctx, _NEW_TRANSFORM); - - if (state) { - ctx->Transform.ClipPlanesEnabled |= (1 << p); - _mesa_update_clip_plane(ctx, p); - } - else { - ctx->Transform.ClipPlanesEnabled &= ~(1 << p); - } - } - break; -#endif - case GL_COLOR_MATERIAL: - if (ctx->Light.ColorMaterialEnabled == state) - return; - FLUSH_VERTICES(ctx, _NEW_LIGHT); - FLUSH_CURRENT(ctx, 0); - ctx->Light.ColorMaterialEnabled = state; - if (state) { - _mesa_update_color_material( ctx, - ctx->Current.Attrib[VERT_ATTRIB_COLOR] ); - } - break; - case GL_CULL_FACE: - if (ctx->Polygon.CullFlag == state) - return; - FLUSH_VERTICES(ctx, _NEW_POLYGON); - ctx->Polygon.CullFlag = state; - break; - case GL_DEPTH_TEST: - if (ctx->Depth.Test == state) - return; - FLUSH_VERTICES(ctx, _NEW_DEPTH); - ctx->Depth.Test = state; - break; - case GL_DITHER: - if (ctx->Color.DitherFlag == state) - return; - FLUSH_VERTICES(ctx, _NEW_COLOR); - ctx->Color.DitherFlag = state; - break; - case GL_FOG: - if (ctx->Fog.Enabled == state) - return; - FLUSH_VERTICES(ctx, _NEW_FOG); - ctx->Fog.Enabled = state; - break; - case GL_LIGHT0: - case GL_LIGHT1: - case GL_LIGHT2: - case GL_LIGHT3: - case GL_LIGHT4: - case GL_LIGHT5: - case GL_LIGHT6: - case GL_LIGHT7: - if (ctx->Light.Light[cap-GL_LIGHT0].Enabled == state) - return; - FLUSH_VERTICES(ctx, _NEW_LIGHT); - ctx->Light.Light[cap-GL_LIGHT0].Enabled = state; - if (state) { - insert_at_tail(&ctx->Light.EnabledList, - &ctx->Light.Light[cap-GL_LIGHT0]); - } - else { - remove_from_list(&ctx->Light.Light[cap-GL_LIGHT0]); - } - break; - case GL_LIGHTING: - if (ctx->Light.Enabled == state) - return; - FLUSH_VERTICES(ctx, _NEW_LIGHT); - ctx->Light.Enabled = state; - if (ctx->Light.Enabled && ctx->Light.Model.TwoSide) - ctx->_TriangleCaps |= DD_TRI_LIGHT_TWOSIDE; - else - ctx->_TriangleCaps &= ~DD_TRI_LIGHT_TWOSIDE; - break; - case GL_LINE_SMOOTH: - if (ctx->Line.SmoothFlag == state) - return; - FLUSH_VERTICES(ctx, _NEW_LINE); - ctx->Line.SmoothFlag = state; - ctx->_TriangleCaps ^= DD_LINE_SMOOTH; - break; - case GL_LINE_STIPPLE: - if (ctx->Line.StippleFlag == state) - return; - FLUSH_VERTICES(ctx, _NEW_LINE); - ctx->Line.StippleFlag = state; - ctx->_TriangleCaps ^= DD_LINE_STIPPLE; - break; - case GL_INDEX_LOGIC_OP: - if (ctx->Color.IndexLogicOpEnabled == state) - return; - FLUSH_VERTICES(ctx, _NEW_COLOR); - ctx->Color.IndexLogicOpEnabled = state; - break; - case GL_COLOR_LOGIC_OP: - if (ctx->Color.ColorLogicOpEnabled == state) - return; - FLUSH_VERTICES(ctx, _NEW_COLOR); - ctx->Color.ColorLogicOpEnabled = state; - break; - case GL_MAP1_COLOR_4: - if (ctx->Eval.Map1Color4 == state) - return; - FLUSH_VERTICES(ctx, _NEW_EVAL); - ctx->Eval.Map1Color4 = state; - break; - case GL_MAP1_INDEX: - if (ctx->Eval.Map1Index == state) - return; - FLUSH_VERTICES(ctx, _NEW_EVAL); - ctx->Eval.Map1Index = state; - break; - case GL_MAP1_NORMAL: - if (ctx->Eval.Map1Normal == state) - return; - FLUSH_VERTICES(ctx, _NEW_EVAL); - ctx->Eval.Map1Normal = state; - break; - case GL_MAP1_TEXTURE_COORD_1: - if (ctx->Eval.Map1TextureCoord1 == state) - return; - FLUSH_VERTICES(ctx, _NEW_EVAL); - ctx->Eval.Map1TextureCoord1 = state; - break; - case GL_MAP1_TEXTURE_COORD_2: - if (ctx->Eval.Map1TextureCoord2 == state) - return; - FLUSH_VERTICES(ctx, _NEW_EVAL); - ctx->Eval.Map1TextureCoord2 = state; - break; - case GL_MAP1_TEXTURE_COORD_3: - if (ctx->Eval.Map1TextureCoord3 == state) - return; - FLUSH_VERTICES(ctx, _NEW_EVAL); - ctx->Eval.Map1TextureCoord3 = state; - break; - case GL_MAP1_TEXTURE_COORD_4: - if (ctx->Eval.Map1TextureCoord4 == state) - return; - FLUSH_VERTICES(ctx, _NEW_EVAL); - ctx->Eval.Map1TextureCoord4 = state; - break; - case GL_MAP1_VERTEX_3: - if (ctx->Eval.Map1Vertex3 == state) - return; - FLUSH_VERTICES(ctx, _NEW_EVAL); - ctx->Eval.Map1Vertex3 = state; - break; - case GL_MAP1_VERTEX_4: - if (ctx->Eval.Map1Vertex4 == state) - return; - FLUSH_VERTICES(ctx, _NEW_EVAL); - ctx->Eval.Map1Vertex4 = state; - break; - case GL_MAP2_COLOR_4: - if (ctx->Eval.Map2Color4 == state) - return; - FLUSH_VERTICES(ctx, _NEW_EVAL); - ctx->Eval.Map2Color4 = state; - break; - case GL_MAP2_INDEX: - if (ctx->Eval.Map2Index == state) - return; - FLUSH_VERTICES(ctx, _NEW_EVAL); - ctx->Eval.Map2Index = state; - break; - case GL_MAP2_NORMAL: - if (ctx->Eval.Map2Normal == state) - return; - FLUSH_VERTICES(ctx, _NEW_EVAL); - ctx->Eval.Map2Normal = state; - break; - case GL_MAP2_TEXTURE_COORD_1: - if (ctx->Eval.Map2TextureCoord1 == state) - return; - FLUSH_VERTICES(ctx, _NEW_EVAL); - ctx->Eval.Map2TextureCoord1 = state; - break; - case GL_MAP2_TEXTURE_COORD_2: - if (ctx->Eval.Map2TextureCoord2 == state) - return; - FLUSH_VERTICES(ctx, _NEW_EVAL); - ctx->Eval.Map2TextureCoord2 = state; - break; - case GL_MAP2_TEXTURE_COORD_3: - if (ctx->Eval.Map2TextureCoord3 == state) - return; - FLUSH_VERTICES(ctx, _NEW_EVAL); - ctx->Eval.Map2TextureCoord3 = state; - break; - case GL_MAP2_TEXTURE_COORD_4: - if (ctx->Eval.Map2TextureCoord4 == state) - return; - FLUSH_VERTICES(ctx, _NEW_EVAL); - ctx->Eval.Map2TextureCoord4 = state; - break; - case GL_MAP2_VERTEX_3: - if (ctx->Eval.Map2Vertex3 == state) - return; - FLUSH_VERTICES(ctx, _NEW_EVAL); - ctx->Eval.Map2Vertex3 = state; - break; - case GL_MAP2_VERTEX_4: - if (ctx->Eval.Map2Vertex4 == state) - return; - FLUSH_VERTICES(ctx, _NEW_EVAL); - ctx->Eval.Map2Vertex4 = state; - break; - case GL_NORMALIZE: - if (ctx->Transform.Normalize == state) - return; - FLUSH_VERTICES(ctx, _NEW_TRANSFORM); - ctx->Transform.Normalize = state; - break; - case GL_POINT_SMOOTH: - if (ctx->Point.SmoothFlag == state) - return; - FLUSH_VERTICES(ctx, _NEW_POINT); - ctx->Point.SmoothFlag = state; - ctx->_TriangleCaps ^= DD_POINT_SMOOTH; - break; - case GL_POLYGON_SMOOTH: - if (ctx->Polygon.SmoothFlag == state) - return; - FLUSH_VERTICES(ctx, _NEW_POLYGON); - ctx->Polygon.SmoothFlag = state; - ctx->_TriangleCaps ^= DD_TRI_SMOOTH; - break; - case GL_POLYGON_STIPPLE: - if (ctx->Polygon.StippleFlag == state) - return; - FLUSH_VERTICES(ctx, _NEW_POLYGON); - ctx->Polygon.StippleFlag = state; - ctx->_TriangleCaps ^= DD_TRI_STIPPLE; - break; - case GL_POLYGON_OFFSET_POINT: - if (ctx->Polygon.OffsetPoint == state) - return; - FLUSH_VERTICES(ctx, _NEW_POLYGON); - ctx->Polygon.OffsetPoint = state; - break; - case GL_POLYGON_OFFSET_LINE: - if (ctx->Polygon.OffsetLine == state) - return; - FLUSH_VERTICES(ctx, _NEW_POLYGON); - ctx->Polygon.OffsetLine = state; - break; - case GL_POLYGON_OFFSET_FILL: - if (ctx->Polygon.OffsetFill == state) - return; - FLUSH_VERTICES(ctx, _NEW_POLYGON); - ctx->Polygon.OffsetFill = state; - break; - case GL_RESCALE_NORMAL_EXT: - if (ctx->Transform.RescaleNormals == state) - return; - FLUSH_VERTICES(ctx, _NEW_TRANSFORM); - ctx->Transform.RescaleNormals = state; - break; - case GL_SCISSOR_TEST: - if (ctx->Scissor.Enabled == state) - return; - FLUSH_VERTICES(ctx, _NEW_SCISSOR); - ctx->Scissor.Enabled = state; - break; - case GL_STENCIL_TEST: - if (ctx->Stencil.Enabled == state) - return; - FLUSH_VERTICES(ctx, _NEW_STENCIL); - ctx->Stencil.Enabled = state; - break; - case GL_TEXTURE_1D: - if (!enable_texture(ctx, state, TEXTURE_1D_BIT)) { - return; - } - break; - case GL_TEXTURE_2D: - if (!enable_texture(ctx, state, TEXTURE_2D_BIT)) { - return; - } - break; - case GL_TEXTURE_GEN_S: - case GL_TEXTURE_GEN_T: - case GL_TEXTURE_GEN_R: - case GL_TEXTURE_GEN_Q: - { - struct gl_texture_unit *texUnit = get_texcoord_unit(ctx); - if (texUnit) { - GLbitfield coordBit = S_BIT << (cap - GL_TEXTURE_GEN_S); - GLbitfield newenabled = texUnit->TexGenEnabled & ~coordBit; - if (state) - newenabled |= coordBit; - if (texUnit->TexGenEnabled == newenabled) - return; - FLUSH_VERTICES(ctx, _NEW_TEXTURE); - texUnit->TexGenEnabled = newenabled; - } - } - break; - -#if FEATURE_ES1 - case GL_TEXTURE_GEN_STR_OES: - /* disable S, T, and R at the same time */ - { - struct gl_texture_unit *texUnit = get_texcoord_unit(ctx); - if (texUnit) { - GLuint newenabled = - texUnit->TexGenEnabled & ~STR_BITS; - if (state) - newenabled |= STR_BITS; - if (texUnit->TexGenEnabled == newenabled) - return; - FLUSH_VERTICES(ctx, _NEW_TEXTURE); - texUnit->TexGenEnabled = newenabled; - } - } - break; -#endif - - /* client-side state */ - case GL_VERTEX_ARRAY: - case GL_NORMAL_ARRAY: - case GL_COLOR_ARRAY: - case GL_INDEX_ARRAY: - case GL_TEXTURE_COORD_ARRAY: - case GL_EDGE_FLAG_ARRAY: - case GL_FOG_COORDINATE_ARRAY_EXT: - case GL_SECONDARY_COLOR_ARRAY_EXT: - case GL_POINT_SIZE_ARRAY_OES: - client_state( ctx, cap, state ); - return; - - /* GL_ARB_texture_cube_map */ - case GL_TEXTURE_CUBE_MAP_ARB: - CHECK_EXTENSION(ARB_texture_cube_map, cap); - if (!enable_texture(ctx, state, TEXTURE_CUBE_BIT)) { - return; - } - break; - - /* GL_ARB_multisample */ - case GL_MULTISAMPLE_ARB: - if (ctx->Multisample.Enabled == state) - return; - FLUSH_VERTICES(ctx, _NEW_MULTISAMPLE); - ctx->Multisample.Enabled = state; - break; - case GL_SAMPLE_ALPHA_TO_COVERAGE_ARB: - if (ctx->Multisample.SampleAlphaToCoverage == state) - return; - FLUSH_VERTICES(ctx, _NEW_MULTISAMPLE); - ctx->Multisample.SampleAlphaToCoverage = state; - break; - case GL_SAMPLE_ALPHA_TO_ONE_ARB: - if (ctx->Multisample.SampleAlphaToOne == state) - return; - FLUSH_VERTICES(ctx, _NEW_MULTISAMPLE); - ctx->Multisample.SampleAlphaToOne = state; - break; - case GL_SAMPLE_COVERAGE_ARB: - if (ctx->Multisample.SampleCoverage == state) - return; - FLUSH_VERTICES(ctx, _NEW_MULTISAMPLE); - ctx->Multisample.SampleCoverage = state; - break; - case GL_SAMPLE_COVERAGE_INVERT_ARB: - if (ctx->Multisample.SampleCoverageInvert == state) - return; - FLUSH_VERTICES(ctx, _NEW_MULTISAMPLE); - ctx->Multisample.SampleCoverageInvert = state; - break; - - /* GL_IBM_rasterpos_clip */ - case GL_RASTER_POSITION_UNCLIPPED_IBM: - CHECK_EXTENSION(IBM_rasterpos_clip, cap); - if (ctx->Transform.RasterPositionUnclipped == state) - return; - FLUSH_VERTICES(ctx, _NEW_TRANSFORM); - ctx->Transform.RasterPositionUnclipped = state; - break; - - /* GL_NV_point_sprite */ - case GL_POINT_SPRITE_NV: - CHECK_EXTENSION2(NV_point_sprite, ARB_point_sprite, cap); - if (ctx->Point.PointSprite == state) - return; - FLUSH_VERTICES(ctx, _NEW_POINT); - ctx->Point.PointSprite = state; - break; - - /* GL_EXT_depth_bounds_test */ - case GL_DEPTH_BOUNDS_TEST_EXT: - CHECK_EXTENSION(EXT_depth_bounds_test, cap); - if (ctx->Depth.BoundsTest == state) - return; - FLUSH_VERTICES(ctx, _NEW_DEPTH); - ctx->Depth.BoundsTest = state; - break; - - default: - goto invalid_enum_error; - } - - if (ctx->Driver.Enable) { - ctx->Driver.Enable( ctx, cap, state ); - } - - return; - -invalid_enum_error: - _mesa_error(ctx, GL_INVALID_ENUM, "gl%s(0x%x)", - state ? "Enable" : "Disable", cap); -} - - -/** - * Enable GL capability. Called by glEnable() - * \param cap state to enable. - */ -void GLAPIENTRY -_mesa_Enable( GLenum cap ) -{ - GET_CURRENT_CONTEXT(ctx); - ASSERT_OUTSIDE_BEGIN_END(ctx); - - _mesa_set_enable( ctx, cap, GL_TRUE ); -} - - -/** - * Disable GL capability. Called by glDisable() - * \param cap state to disable. - */ -void GLAPIENTRY -_mesa_Disable( GLenum cap ) -{ - GET_CURRENT_CONTEXT(ctx); - ASSERT_OUTSIDE_BEGIN_END(ctx); - - _mesa_set_enable( ctx, cap, GL_FALSE ); -} - - -#undef CHECK_EXTENSION -#define CHECK_EXTENSION(EXTNAME) \ - if (!ctx->Extensions.EXTNAME) { \ - goto invalid_enum_error; \ - } - -#undef CHECK_EXTENSION2 -#define CHECK_EXTENSION2(EXT1, EXT2) \ - if (!ctx->Extensions.EXT1 && !ctx->Extensions.EXT2) { \ - goto invalid_enum_error; \ - } - - -/** - * Helper function to determine whether a texture target is enabled. - */ -static GLboolean -is_texture_enabled(struct gl_context *ctx, GLbitfield bit) -{ - const struct gl_texture_unit *const texUnit = - &ctx->Texture.Unit; - return (texUnit->Enabled & bit) ? GL_TRUE : GL_FALSE; -} - - -/** - * Return simple enable/disable state. - * - * \param cap state variable to query. - * - * Returns the state of the specified capability from the current GL context. - * For the capabilities associated with extensions verifies that those - * extensions are effectively present before reporting. - */ -GLboolean GLAPIENTRY -_mesa_IsEnabled( GLenum cap ) -{ - GET_CURRENT_CONTEXT(ctx); - ASSERT_OUTSIDE_BEGIN_END_WITH_RETVAL(ctx, 0); - - switch (cap) { - case GL_ALPHA_TEST: - return ctx->Color.AlphaEnabled; - case GL_AUTO_NORMAL: - return ctx->Eval.AutoNormal; - case GL_BLEND: - return ctx->Color.BlendEnabled & 1; /* return state for buffer[0] */ - case GL_CLIP_DISTANCE0: - case GL_CLIP_DISTANCE1: - case GL_CLIP_DISTANCE2: - case GL_CLIP_DISTANCE3: - case GL_CLIP_DISTANCE4: - case GL_CLIP_DISTANCE5: - case GL_CLIP_DISTANCE6: - case GL_CLIP_DISTANCE7: { - const GLuint p = cap - GL_CLIP_DISTANCE0; - - if (p >= ctx->Const.MaxClipPlanes) - goto invalid_enum_error; - - return (ctx->Transform.ClipPlanesEnabled >> p) & 1; - } - case GL_COLOR_MATERIAL: - return ctx->Light.ColorMaterialEnabled; - case GL_CULL_FACE: - return ctx->Polygon.CullFlag; - case GL_DEPTH_TEST: - return ctx->Depth.Test; - case GL_DITHER: - return ctx->Color.DitherFlag; - case GL_FOG: - return ctx->Fog.Enabled; - case GL_LIGHTING: - return ctx->Light.Enabled; - case GL_LIGHT0: - case GL_LIGHT1: - case GL_LIGHT2: - case GL_LIGHT3: - case GL_LIGHT4: - case GL_LIGHT5: - case GL_LIGHT6: - case GL_LIGHT7: - return ctx->Light.Light[cap-GL_LIGHT0].Enabled; - case GL_LINE_SMOOTH: - return ctx->Line.SmoothFlag; - case GL_LINE_STIPPLE: - return ctx->Line.StippleFlag; - case GL_INDEX_LOGIC_OP: - return ctx->Color.IndexLogicOpEnabled; - case GL_COLOR_LOGIC_OP: - return ctx->Color.ColorLogicOpEnabled; - case GL_MAP1_COLOR_4: - return ctx->Eval.Map1Color4; - case GL_MAP1_INDEX: - return ctx->Eval.Map1Index; - case GL_MAP1_NORMAL: - return ctx->Eval.Map1Normal; - case GL_MAP1_TEXTURE_COORD_1: - return ctx->Eval.Map1TextureCoord1; - case GL_MAP1_TEXTURE_COORD_2: - return ctx->Eval.Map1TextureCoord2; - case GL_MAP1_TEXTURE_COORD_3: - return ctx->Eval.Map1TextureCoord3; - case GL_MAP1_TEXTURE_COORD_4: - return ctx->Eval.Map1TextureCoord4; - case GL_MAP1_VERTEX_3: - return ctx->Eval.Map1Vertex3; - case GL_MAP1_VERTEX_4: - return ctx->Eval.Map1Vertex4; - case GL_MAP2_COLOR_4: - return ctx->Eval.Map2Color4; - case GL_MAP2_INDEX: - return ctx->Eval.Map2Index; - case GL_MAP2_NORMAL: - return ctx->Eval.Map2Normal; - case GL_MAP2_TEXTURE_COORD_1: - return ctx->Eval.Map2TextureCoord1; - case GL_MAP2_TEXTURE_COORD_2: - return ctx->Eval.Map2TextureCoord2; - case GL_MAP2_TEXTURE_COORD_3: - return ctx->Eval.Map2TextureCoord3; - case GL_MAP2_TEXTURE_COORD_4: - return ctx->Eval.Map2TextureCoord4; - case GL_MAP2_VERTEX_3: - return ctx->Eval.Map2Vertex3; - case GL_MAP2_VERTEX_4: - return ctx->Eval.Map2Vertex4; - case GL_NORMALIZE: - return ctx->Transform.Normalize; - case GL_POINT_SMOOTH: - return ctx->Point.SmoothFlag; - case GL_POLYGON_SMOOTH: - return ctx->Polygon.SmoothFlag; - case GL_POLYGON_STIPPLE: - return ctx->Polygon.StippleFlag; - case GL_POLYGON_OFFSET_POINT: - return ctx->Polygon.OffsetPoint; - case GL_POLYGON_OFFSET_LINE: - return ctx->Polygon.OffsetLine; - case GL_POLYGON_OFFSET_FILL: - return ctx->Polygon.OffsetFill; - case GL_RESCALE_NORMAL_EXT: - return ctx->Transform.RescaleNormals; - case GL_SCISSOR_TEST: - return ctx->Scissor.Enabled; - case GL_STENCIL_TEST: - return ctx->Stencil.Enabled; - case GL_TEXTURE_1D: - return is_texture_enabled(ctx, TEXTURE_1D_BIT); - case GL_TEXTURE_2D: - return is_texture_enabled(ctx, TEXTURE_2D_BIT); - case GL_TEXTURE_GEN_S: - case GL_TEXTURE_GEN_T: - case GL_TEXTURE_GEN_R: - case GL_TEXTURE_GEN_Q: - { - const struct gl_texture_unit *texUnit = get_texcoord_unit(ctx); - if (texUnit) { - GLbitfield coordBit = S_BIT << (cap - GL_TEXTURE_GEN_S); - return (texUnit->TexGenEnabled & coordBit) ? GL_TRUE : GL_FALSE; - } - } - return GL_FALSE; -#if FEATURE_ES1 - case GL_TEXTURE_GEN_STR_OES: - { - const struct gl_texture_unit *texUnit = get_texcoord_unit(ctx); - if (texUnit) { - return (texUnit->TexGenEnabled & STR_BITS) == STR_BITS - ? GL_TRUE : GL_FALSE; - } - } -#endif - - /* client-side state */ - case GL_VERTEX_ARRAY: - return (ctx->Array.VertexAttrib[VERT_ATTRIB_POS].Enabled != 0); - case GL_NORMAL_ARRAY: - return (ctx->Array.VertexAttrib[VERT_ATTRIB_NORMAL].Enabled != 0); - case GL_COLOR_ARRAY: - return (ctx->Array.VertexAttrib[VERT_ATTRIB_COLOR].Enabled != 0); - case GL_INDEX_ARRAY: - return (ctx->Array.VertexAttrib[VERT_ATTRIB_COLOR_INDEX].Enabled != 0); - case GL_TEXTURE_COORD_ARRAY: - return (ctx->Array.VertexAttrib[VERT_ATTRIB_TEX] - .Enabled != 0); - case GL_EDGE_FLAG_ARRAY: - return (ctx->Array.VertexAttrib[VERT_ATTRIB_EDGEFLAG].Enabled != 0); - case GL_FOG_COORDINATE_ARRAY_EXT: - CHECK_EXTENSION(EXT_fog_coord); - return (ctx->Array.VertexAttrib[VERT_ATTRIB_FOG].Enabled != 0); -#if FEATURE_point_size_array - case GL_POINT_SIZE_ARRAY_OES: - return (ctx->Array.ArrayObj->VertexAttrib[VERT_ATTRIB_POINT_SIZE].Enabled != 0); -#endif - - /* GL_ARB_texture_cube_map */ - case GL_TEXTURE_CUBE_MAP_ARB: - CHECK_EXTENSION(ARB_texture_cube_map); - return is_texture_enabled(ctx, TEXTURE_CUBE_BIT); - - /* GL_ARB_multisample */ - case GL_MULTISAMPLE_ARB: - return ctx->Multisample.Enabled; - case GL_SAMPLE_ALPHA_TO_COVERAGE_ARB: - return ctx->Multisample.SampleAlphaToCoverage; - case GL_SAMPLE_ALPHA_TO_ONE_ARB: - return ctx->Multisample.SampleAlphaToOne; - case GL_SAMPLE_COVERAGE_ARB: - return ctx->Multisample.SampleCoverage; - case GL_SAMPLE_COVERAGE_INVERT_ARB: - return ctx->Multisample.SampleCoverageInvert; - - /* GL_IBM_rasterpos_clip */ - case GL_RASTER_POSITION_UNCLIPPED_IBM: - CHECK_EXTENSION(IBM_rasterpos_clip); - return ctx->Transform.RasterPositionUnclipped; - - /* GL_NV_point_sprite */ - case GL_POINT_SPRITE_NV: - CHECK_EXTENSION2(NV_point_sprite, ARB_point_sprite) - return ctx->Point.PointSprite; - - /* GL_EXT_depth_bounds_test */ - case GL_DEPTH_BOUNDS_TEST_EXT: - CHECK_EXTENSION(EXT_depth_bounds_test); - return ctx->Depth.BoundsTest; - - default: - goto invalid_enum_error; - } - - return GL_FALSE; - -invalid_enum_error: - _mesa_error(ctx, GL_INVALID_ENUM, "glIsEnabled(0x%x)", (int) cap); - return GL_FALSE; -} diff --git a/dll/opengl/mesa/main/enable.h b/dll/opengl/mesa/main/enable.h deleted file mode 100644 index 7fe88732647..00000000000 --- a/dll/opengl/mesa/main/enable.h +++ /dev/null @@ -1,59 +0,0 @@ -/** - * \file enable.h - * Enable/disable/query GL capabilities. - */ - -/* - * Mesa 3-D graphics library - * Version: 3.5 - * - * Copyright (C) 1999-2001 Brian Paul All Rights Reserved. - * - * Permission is hereby granted, free of charge, to any person obtaining a - * copy of this software and associated documentation files (the "Software"), - * to deal in the Software without restriction, including without limitation - * the rights to use, copy, modify, merge, publish, distribute, sublicense, - * and/or sell copies of the Software, and to permit persons to whom the - * Software is furnished to do so, subject to the following conditions: - * - * The above copyright notice and this permission notice shall be included - * in all copies or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS - * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL - * BRIAN PAUL BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN - * AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN - * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. - */ - - -#ifndef ENABLE_H -#define ENABLE_H - - -#include "glheader.h" - -struct gl_context; - - -extern void -_mesa_set_enable( struct gl_context* ctx, GLenum cap, GLboolean state ); - -extern void GLAPIENTRY -_mesa_Disable( GLenum cap ); - -extern void GLAPIENTRY -_mesa_Enable( GLenum cap ); - -extern GLboolean GLAPIENTRY -_mesa_IsEnabled( GLenum cap ); - -extern void GLAPIENTRY -_mesa_EnableClientState( GLenum cap ); - -extern void GLAPIENTRY -_mesa_DisableClientState( GLenum cap ); - - -#endif diff --git a/dll/opengl/mesa/main/enums.c b/dll/opengl/mesa/main/enums.c deleted file mode 100644 index 13587fe7064..00000000000 --- a/dll/opengl/mesa/main/enums.c +++ /dev/null @@ -1,6399 +0,0 @@ -/* DO NOT EDIT - This file generated automatically by gl_enums.py (from Mesa) script */ - -/* - * Copyright (C) 1999-2005 Brian Paul All Rights Reserved. - * All Rights Reserved. - * - * Permission is hereby granted, free of charge, to any person obtaining a - * copy of this software and associated documentation files (the "Software"), - * to deal in the Software without restriction, including without limitation - * the rights to use, copy, modify, merge, publish, distribute, sub license, - * and/or sell copies of the Software, and to permit persons to whom the - * Software is furnished to do so, subject to the following conditions: - * - * The above copyright notice and this permission notice (including the next - * paragraph) shall be included in all copies or substantial portions of the - * Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR - * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT. IN NO EVENT SHALL - * BRIAN PAUL, - * AND/OR THEIR SUPPLIERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, - * WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF - * OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE - * SOFTWARE. - */ - -#include - -typedef struct { - size_t offset; - int n; -} enum_elt; - -LONGSTRING static const char enum_string_table[] = - "GL_2D\0" - "GL_2_BYTES\0" - "GL_3D\0" - "GL_3D_COLOR\0" - "GL_3D_COLOR_TEXTURE\0" - "GL_3_BYTES\0" - "GL_4D_COLOR_TEXTURE\0" - "GL_4_BYTES\0" - "GL_ACCUM\0" - "GL_ACCUM_ALPHA_BITS\0" - "GL_ACCUM_BLUE_BITS\0" - "GL_ACCUM_BUFFER_BIT\0" - "GL_ACCUM_CLEAR_VALUE\0" - "GL_ACCUM_GREEN_BITS\0" - "GL_ACCUM_RED_BITS\0" - "GL_ACTIVE_ATTRIBUTES\0" - "GL_ACTIVE_ATTRIBUTE_MAX_LENGTH\0" - "GL_ACTIVE_PROGRAM_EXT\0" - "GL_ACTIVE_STENCIL_FACE_EXT\0" - "GL_ACTIVE_TEXTURE\0" - "GL_ACTIVE_TEXTURE_ARB\0" - "GL_ACTIVE_UNIFORMS\0" - "GL_ACTIVE_UNIFORM_MAX_LENGTH\0" - "GL_ACTIVE_VERTEX_UNITS_ARB\0" - "GL_ADD\0" - "GL_ADD_SIGNED\0" - "GL_ADD_SIGNED_ARB\0" - "GL_ADD_SIGNED_EXT\0" - "GL_ALIASED_LINE_WIDTH_RANGE\0" - "GL_ALIASED_POINT_SIZE_RANGE\0" - "GL_ALL_ATTRIB_BITS\0" - "GL_ALL_CLIENT_ATTRIB_BITS\0" - "GL_ALPHA\0" - "GL_ALPHA12\0" - "GL_ALPHA12_EXT\0" - "GL_ALPHA16\0" - "GL_ALPHA16I_EXT\0" - "GL_ALPHA16UI_EXT\0" - "GL_ALPHA16_EXT\0" - "GL_ALPHA32I_EXT\0" - "GL_ALPHA32UI_EXT\0" - "GL_ALPHA4\0" - "GL_ALPHA4_EXT\0" - "GL_ALPHA8\0" - "GL_ALPHA8I_EXT\0" - "GL_ALPHA8UI_EXT\0" - "GL_ALPHA8_EXT\0" - "GL_ALPHA_BIAS\0" - "GL_ALPHA_BITS\0" - "GL_ALPHA_INTEGER_EXT\0" - "GL_ALPHA_SCALE\0" - "GL_ALPHA_TEST\0" - "GL_ALPHA_TEST_FUNC\0" - "GL_ALPHA_TEST_REF\0" - "GL_ALREADY_SIGNALED\0" - "GL_ALWAYS\0" - "GL_AMBIENT\0" - "GL_AMBIENT_AND_DIFFUSE\0" - "GL_AND\0" - "GL_AND_INVERTED\0" - "GL_AND_REVERSE\0" - "GL_ARRAY_BUFFER\0" - "GL_ARRAY_BUFFER_BINDING\0" - "GL_ARRAY_BUFFER_BINDING_ARB\0" - "GL_ATTACHED_SHADERS\0" - "GL_ATTRIB_ARRAY_POINTER_NV\0" - "GL_ATTRIB_ARRAY_SIZE_NV\0" - "GL_ATTRIB_ARRAY_STRIDE_NV\0" - "GL_ATTRIB_ARRAY_TYPE_NV\0" - "GL_ATTRIB_STACK_DEPTH\0" - "GL_AUTO_NORMAL\0" - "GL_AUX0\0" - "GL_AUX1\0" - "GL_AUX2\0" - "GL_AUX3\0" - "GL_AUX_BUFFERS\0" - "GL_BACK\0" - "GL_BACK_LEFT\0" - "GL_BACK_RIGHT\0" - "GL_BGR\0" - "GL_BGRA\0" - "GL_BGRA_EXT\0" - "GL_BGRA_INTEGER\0" - "GL_BGRA_INTEGER_EXT\0" - "GL_BGR_INTEGER\0" - "GL_BGR_INTEGER_EXT\0" - "GL_BITMAP\0" - "GL_BITMAP_TOKEN\0" - "GL_BLEND\0" - "GL_BLEND_COLOR\0" - "GL_BLEND_COLOR_EXT\0" - "GL_BLEND_DST\0" - "GL_BLEND_DST_ALPHA\0" - "GL_BLEND_DST_ALPHA_OES\0" - "GL_BLEND_DST_RGB\0" - "GL_BLEND_DST_RGB_OES\0" - "GL_BLEND_EQUATION\0" - "GL_BLEND_EQUATION_ALPHA\0" - "GL_BLEND_EQUATION_ALPHA_EXT\0" - "GL_BLEND_EQUATION_ALPHA_OES\0" - "GL_BLEND_EQUATION_EXT\0" - "GL_BLEND_EQUATION_OES\0" - "GL_BLEND_EQUATION_RGB\0" - "GL_BLEND_EQUATION_RGB_EXT\0" - "GL_BLEND_EQUATION_RGB_OES\0" - "GL_BLEND_SRC\0" - "GL_BLEND_SRC_ALPHA\0" - "GL_BLEND_SRC_ALPHA_OES\0" - "GL_BLEND_SRC_RGB\0" - "GL_BLEND_SRC_RGB_OES\0" - "GL_BLUE\0" - "GL_BLUE_BIAS\0" - "GL_BLUE_BITS\0" - "GL_BLUE_INTEGER\0" - "GL_BLUE_INTEGER_EXT\0" - "GL_BLUE_SCALE\0" - "GL_BOOL\0" - "GL_BOOL_ARB\0" - "GL_BOOL_VEC2\0" - "GL_BOOL_VEC2_ARB\0" - "GL_BOOL_VEC3\0" - "GL_BOOL_VEC3_ARB\0" - "GL_BOOL_VEC4\0" - "GL_BOOL_VEC4_ARB\0" - "GL_BUFFER_ACCESS\0" - "GL_BUFFER_ACCESS_ARB\0" - "GL_BUFFER_ACCESS_FLAGS\0" - "GL_BUFFER_ACCESS_OES\0" - "GL_BUFFER_FLUSHING_UNMAP_APPLE\0" - "GL_BUFFER_MAPPED\0" - "GL_BUFFER_MAPPED_ARB\0" - "GL_BUFFER_MAPPED_OES\0" - "GL_BUFFER_MAP_LENGTH\0" - "GL_BUFFER_MAP_OFFSET\0" - "GL_BUFFER_MAP_POINTER\0" - "GL_BUFFER_MAP_POINTER_ARB\0" - "GL_BUFFER_MAP_POINTER_OES\0" - "GL_BUFFER_OBJECT_APPLE\0" - "GL_BUFFER_SERIALIZED_MODIFY_APPLE\0" - "GL_BUFFER_SIZE\0" - "GL_BUFFER_SIZE_ARB\0" - "GL_BUFFER_USAGE\0" - "GL_BUFFER_USAGE_ARB\0" - "GL_BUMP_ENVMAP_ATI\0" - "GL_BUMP_NUM_TEX_UNITS_ATI\0" - "GL_BUMP_ROT_MATRIX_ATI\0" - "GL_BUMP_ROT_MATRIX_SIZE_ATI\0" - "GL_BUMP_TARGET_ATI\0" - "GL_BUMP_TEX_UNITS_ATI\0" - "GL_BYTE\0" - "GL_C3F_V3F\0" - "GL_C4F_N3F_V3F\0" - "GL_C4UB_V2F\0" - "GL_C4UB_V3F\0" - "GL_CCW\0" - "GL_CLAMP\0" - "GL_CLAMP_FRAGMENT_COLOR_ARB\0" - "GL_CLAMP_READ_COLOR\0" - "GL_CLAMP_READ_COLOR_ARB\0" - "GL_CLAMP_TO_BORDER\0" - "GL_CLAMP_TO_BORDER_ARB\0" - "GL_CLAMP_TO_BORDER_SGIS\0" - "GL_CLAMP_TO_EDGE\0" - "GL_CLAMP_TO_EDGE_SGIS\0" - "GL_CLAMP_VERTEX_COLOR_ARB\0" - "GL_CLEAR\0" - "GL_CLIENT_ACTIVE_TEXTURE\0" - "GL_CLIENT_ACTIVE_TEXTURE_ARB\0" - "GL_CLIENT_ALL_ATTRIB_BITS\0" - "GL_CLIENT_ATTRIB_STACK_DEPTH\0" - "GL_CLIENT_PIXEL_STORE_BIT\0" - "GL_CLIENT_VERTEX_ARRAY_BIT\0" - "GL_CLIP_DISTANCE0\0" - "GL_CLIP_DISTANCE1\0" - "GL_CLIP_DISTANCE2\0" - "GL_CLIP_DISTANCE3\0" - "GL_CLIP_DISTANCE4\0" - "GL_CLIP_DISTANCE5\0" - "GL_CLIP_DISTANCE6\0" - "GL_CLIP_DISTANCE7\0" - "GL_CLIP_PLANE0\0" - "GL_CLIP_PLANE1\0" - "GL_CLIP_PLANE2\0" - "GL_CLIP_PLANE3\0" - "GL_CLIP_PLANE4\0" - "GL_CLIP_PLANE5\0" - "GL_CLIP_VOLUME_CLIPPING_HINT_EXT\0" - "GL_COEFF\0" - "GL_COLOR\0" - "GL_COLOR_ARRAY\0" - "GL_COLOR_ARRAY_BUFFER_BINDING\0" - "GL_COLOR_ARRAY_BUFFER_BINDING_ARB\0" - "GL_COLOR_ARRAY_POINTER\0" - "GL_COLOR_ARRAY_SIZE\0" - "GL_COLOR_ARRAY_STRIDE\0" - "GL_COLOR_ARRAY_TYPE\0" - "GL_COLOR_ATTACHMENT0\0" - "GL_COLOR_ATTACHMENT0_EXT\0" - "GL_COLOR_ATTACHMENT0_OES\0" - "GL_COLOR_ATTACHMENT1\0" - "GL_COLOR_ATTACHMENT10\0" - "GL_COLOR_ATTACHMENT10_EXT\0" - "GL_COLOR_ATTACHMENT11\0" - "GL_COLOR_ATTACHMENT11_EXT\0" - "GL_COLOR_ATTACHMENT12\0" - "GL_COLOR_ATTACHMENT12_EXT\0" - "GL_COLOR_ATTACHMENT13\0" - "GL_COLOR_ATTACHMENT13_EXT\0" - "GL_COLOR_ATTACHMENT14\0" - "GL_COLOR_ATTACHMENT14_EXT\0" - "GL_COLOR_ATTACHMENT15\0" - "GL_COLOR_ATTACHMENT15_EXT\0" - "GL_COLOR_ATTACHMENT1_EXT\0" - "GL_COLOR_ATTACHMENT2\0" - "GL_COLOR_ATTACHMENT2_EXT\0" - "GL_COLOR_ATTACHMENT3\0" - "GL_COLOR_ATTACHMENT3_EXT\0" - "GL_COLOR_ATTACHMENT4\0" - "GL_COLOR_ATTACHMENT4_EXT\0" - "GL_COLOR_ATTACHMENT5\0" - "GL_COLOR_ATTACHMENT5_EXT\0" - "GL_COLOR_ATTACHMENT6\0" - "GL_COLOR_ATTACHMENT6_EXT\0" - "GL_COLOR_ATTACHMENT7\0" - "GL_COLOR_ATTACHMENT7_EXT\0" - "GL_COLOR_ATTACHMENT8\0" - "GL_COLOR_ATTACHMENT8_EXT\0" - "GL_COLOR_ATTACHMENT9\0" - "GL_COLOR_ATTACHMENT9_EXT\0" - "GL_COLOR_BUFFER_BIT\0" - "GL_COLOR_CLEAR_VALUE\0" - "GL_COLOR_INDEX\0" - "GL_COLOR_INDEXES\0" - "GL_COLOR_LOGIC_OP\0" - "GL_COLOR_MATERIAL\0" - "GL_COLOR_MATERIAL_FACE\0" - "GL_COLOR_MATERIAL_PARAMETER\0" - "GL_COLOR_MATRIX\0" - "GL_COLOR_MATRIX_SGI\0" - "GL_COLOR_MATRIX_STACK_DEPTH\0" - "GL_COLOR_MATRIX_STACK_DEPTH_SGI\0" - "GL_COLOR_SUM\0" - "GL_COLOR_SUM_ARB\0" - "GL_COLOR_TABLE\0" - "GL_COLOR_TABLE_ALPHA_SIZE\0" - "GL_COLOR_TABLE_ALPHA_SIZE_EXT\0" - "GL_COLOR_TABLE_ALPHA_SIZE_SGI\0" - "GL_COLOR_TABLE_BIAS\0" - "GL_COLOR_TABLE_BIAS_SGI\0" - "GL_COLOR_TABLE_BLUE_SIZE\0" - "GL_COLOR_TABLE_BLUE_SIZE_EXT\0" - "GL_COLOR_TABLE_BLUE_SIZE_SGI\0" - "GL_COLOR_TABLE_FORMAT\0" - "GL_COLOR_TABLE_FORMAT_EXT\0" - "GL_COLOR_TABLE_FORMAT_SGI\0" - "GL_COLOR_TABLE_GREEN_SIZE\0" - "GL_COLOR_TABLE_GREEN_SIZE_EXT\0" - "GL_COLOR_TABLE_GREEN_SIZE_SGI\0" - "GL_COLOR_TABLE_INTENSITY_SIZE\0" - "GL_COLOR_TABLE_INTENSITY_SIZE_EXT\0" - "GL_COLOR_TABLE_INTENSITY_SIZE_SGI\0" - "GL_COLOR_TABLE_LUMINANCE_SIZE\0" - "GL_COLOR_TABLE_LUMINANCE_SIZE_EXT\0" - "GL_COLOR_TABLE_LUMINANCE_SIZE_SGI\0" - "GL_COLOR_TABLE_RED_SIZE\0" - "GL_COLOR_TABLE_RED_SIZE_EXT\0" - "GL_COLOR_TABLE_RED_SIZE_SGI\0" - "GL_COLOR_TABLE_SCALE\0" - "GL_COLOR_TABLE_SCALE_SGI\0" - "GL_COLOR_TABLE_WIDTH\0" - "GL_COLOR_TABLE_WIDTH_EXT\0" - "GL_COLOR_TABLE_WIDTH_SGI\0" - "GL_COLOR_WRITEMASK\0" - "GL_COMBINE\0" - "GL_COMBINE4\0" - "GL_COMBINE_ALPHA\0" - "GL_COMBINE_ALPHA_ARB\0" - "GL_COMBINE_ALPHA_EXT\0" - "GL_COMBINE_ARB\0" - "GL_COMBINE_EXT\0" - "GL_COMBINE_RGB\0" - "GL_COMBINE_RGB_ARB\0" - "GL_COMBINE_RGB_EXT\0" - "GL_COMPARE_REF_DEPTH_TO_TEXTURE_EXT\0" - "GL_COMPARE_REF_TO_TEXTURE\0" - "GL_COMPARE_R_TO_TEXTURE\0" - "GL_COMPARE_R_TO_TEXTURE_ARB\0" - "GL_COMPILE\0" - "GL_COMPILE_AND_EXECUTE\0" - "GL_COMPILE_STATUS\0" - "GL_COMPRESSED_ALPHA\0" - "GL_COMPRESSED_ALPHA_ARB\0" - "GL_COMPRESSED_INTENSITY\0" - "GL_COMPRESSED_INTENSITY_ARB\0" - "GL_COMPRESSED_LUMINANCE\0" - "GL_COMPRESSED_LUMINANCE_ALPHA\0" - "GL_COMPRESSED_LUMINANCE_ALPHA_ARB\0" - "GL_COMPRESSED_LUMINANCE_ARB\0" - "GL_COMPRESSED_RED\0" - "GL_COMPRESSED_RG\0" - "GL_COMPRESSED_RGB\0" - "GL_COMPRESSED_RGBA\0" - "GL_COMPRESSED_RGBA_ARB\0" - "GL_COMPRESSED_RGBA_FXT1_3DFX\0" - "GL_COMPRESSED_RGBA_S3TC_DXT1_EXT\0" - "GL_COMPRESSED_RGBA_S3TC_DXT3_EXT\0" - "GL_COMPRESSED_RGBA_S3TC_DXT5_EXT\0" - "GL_COMPRESSED_RGB_ARB\0" - "GL_COMPRESSED_RGB_FXT1_3DFX\0" - "GL_COMPRESSED_RGB_S3TC_DXT1_EXT\0" - "GL_COMPRESSED_SLUMINANCE\0" - "GL_COMPRESSED_SLUMINANCE_ALPHA\0" - "GL_COMPRESSED_SRGB\0" - "GL_COMPRESSED_SRGB_ALPHA\0" - "GL_COMPRESSED_TEXTURE_FORMATS\0" - "GL_CONDITION_SATISFIED\0" - "GL_CONSTANT\0" - "GL_CONSTANT_ALPHA\0" - "GL_CONSTANT_ALPHA_EXT\0" - "GL_CONSTANT_ARB\0" - "GL_CONSTANT_ATTENUATION\0" - "GL_CONSTANT_BORDER_HP\0" - "GL_CONSTANT_COLOR\0" - "GL_CONSTANT_COLOR_EXT\0" - "GL_CONSTANT_EXT\0" - "GL_CONTEXT_COMPATIBILITY_PROFILE_BIT\0" - "GL_CONTEXT_CORE_PROFILE_BIT\0" - "GL_CONTEXT_FLAGS\0" - "GL_CONTEXT_FLAG_FORWARD_COMPATIBLE_BIT\0" - "GL_CONTEXT_FLAG_ROBUST_ACCESS_BIT_ARB\0" - "GL_CONTEXT_PROFILE_MASK\0" - "GL_CONVOLUTION_1D\0" - "GL_CONVOLUTION_2D\0" - "GL_CONVOLUTION_BORDER_COLOR\0" - "GL_CONVOLUTION_BORDER_COLOR_HP\0" - "GL_CONVOLUTION_BORDER_MODE\0" - "GL_CONVOLUTION_BORDER_MODE_EXT\0" - "GL_CONVOLUTION_FILTER_BIAS\0" - "GL_CONVOLUTION_FILTER_BIAS_EXT\0" - "GL_CONVOLUTION_FILTER_SCALE\0" - "GL_CONVOLUTION_FILTER_SCALE_EXT\0" - "GL_CONVOLUTION_FORMAT\0" - "GL_CONVOLUTION_FORMAT_EXT\0" - "GL_CONVOLUTION_HEIGHT\0" - "GL_CONVOLUTION_HEIGHT_EXT\0" - "GL_CONVOLUTION_WIDTH\0" - "GL_CONVOLUTION_WIDTH_EXT\0" - "GL_COORD_REPLACE\0" - "GL_COORD_REPLACE_ARB\0" - "GL_COORD_REPLACE_NV\0" - "GL_COORD_REPLACE_OES\0" - "GL_COPY\0" - "GL_COPY_INVERTED\0" - "GL_COPY_PIXEL_TOKEN\0" - "GL_COPY_READ_BUFFER\0" - "GL_COPY_WRITE_BUFFER\0" - "GL_CULL_FACE\0" - "GL_CULL_FACE_MODE\0" - "GL_CULL_VERTEX_EXT\0" - "GL_CULL_VERTEX_EYE_POSITION_EXT\0" - "GL_CULL_VERTEX_OBJECT_POSITION_EXT\0" - "GL_CURRENT_ATTRIB_NV\0" - "GL_CURRENT_BIT\0" - "GL_CURRENT_COLOR\0" - "GL_CURRENT_FOG_COORD\0" - "GL_CURRENT_FOG_COORDINATE\0" - "GL_CURRENT_INDEX\0" - "GL_CURRENT_MATRIX_ARB\0" - "GL_CURRENT_MATRIX_INDEX_ARB\0" - "GL_CURRENT_MATRIX_NV\0" - "GL_CURRENT_MATRIX_STACK_DEPTH_ARB\0" - "GL_CURRENT_MATRIX_STACK_DEPTH_NV\0" - "GL_CURRENT_NORMAL\0" - "GL_CURRENT_PALETTE_MATRIX_ARB\0" - "GL_CURRENT_PALETTE_MATRIX_OES\0" - "GL_CURRENT_PROGRAM\0" - "GL_CURRENT_QUERY\0" - "GL_CURRENT_QUERY_ARB\0" - "GL_CURRENT_RASTER_COLOR\0" - "GL_CURRENT_RASTER_DISTANCE\0" - "GL_CURRENT_RASTER_INDEX\0" - "GL_CURRENT_RASTER_POSITION\0" - "GL_CURRENT_RASTER_POSITION_VALID\0" - "GL_CURRENT_RASTER_SECONDARY_COLOR\0" - "GL_CURRENT_RASTER_TEXTURE_COORDS\0" - "GL_CURRENT_SECONDARY_COLOR\0" - "GL_CURRENT_TEXTURE_COORDS\0" - "GL_CURRENT_VERTEX_ATTRIB\0" - "GL_CURRENT_VERTEX_ATTRIB_ARB\0" - "GL_CURRENT_WEIGHT_ARB\0" - "GL_CW\0" - "GL_DEBUG_ASSERT_MESA\0" - "GL_DEBUG_OBJECT_MESA\0" - "GL_DEBUG_PRINT_MESA\0" - "GL_DECAL\0" - "GL_DECR\0" - "GL_DECR_WRAP\0" - "GL_DECR_WRAP_EXT\0" - "GL_DELETE_STATUS\0" - "GL_DEPTH\0" - "GL_DEPTH24_STENCIL8\0" - "GL_DEPTH24_STENCIL8_EXT\0" - "GL_DEPTH24_STENCIL8_OES\0" - "GL_DEPTH_ATTACHMENT\0" - "GL_DEPTH_ATTACHMENT_EXT\0" - "GL_DEPTH_ATTACHMENT_OES\0" - "GL_DEPTH_BIAS\0" - "GL_DEPTH_BITS\0" - "GL_DEPTH_BOUNDS_EXT\0" - "GL_DEPTH_BOUNDS_TEST_EXT\0" - "GL_DEPTH_BUFFER\0" - "GL_DEPTH_BUFFER_BIT\0" - "GL_DEPTH_CLAMP\0" - "GL_DEPTH_CLAMP_NV\0" - "GL_DEPTH_CLEAR_VALUE\0" - "GL_DEPTH_COMPONENT\0" - "GL_DEPTH_COMPONENT16\0" - "GL_DEPTH_COMPONENT16_ARB\0" - "GL_DEPTH_COMPONENT16_OES\0" - "GL_DEPTH_COMPONENT16_SGIX\0" - "GL_DEPTH_COMPONENT24\0" - "GL_DEPTH_COMPONENT24_ARB\0" - "GL_DEPTH_COMPONENT24_OES\0" - "GL_DEPTH_COMPONENT24_SGIX\0" - "GL_DEPTH_COMPONENT32\0" - "GL_DEPTH_COMPONENT32_ARB\0" - "GL_DEPTH_COMPONENT32_OES\0" - "GL_DEPTH_COMPONENT32_SGIX\0" - "GL_DEPTH_FUNC\0" - "GL_DEPTH_RANGE\0" - "GL_DEPTH_SCALE\0" - "GL_DEPTH_STENCIL\0" - "GL_DEPTH_STENCIL_ATTACHMENT\0" - "GL_DEPTH_STENCIL_EXT\0" - "GL_DEPTH_STENCIL_NV\0" - "GL_DEPTH_STENCIL_OES\0" - "GL_DEPTH_STENCIL_TO_BGRA_NV\0" - "GL_DEPTH_STENCIL_TO_RGBA_NV\0" - "GL_DEPTH_TEST\0" - "GL_DEPTH_TEXTURE_MODE\0" - "GL_DEPTH_TEXTURE_MODE_ARB\0" - "GL_DEPTH_WRITEMASK\0" - "GL_DIFFUSE\0" - "GL_DITHER\0" - "GL_DOMAIN\0" - "GL_DONT_CARE\0" - "GL_DOT3_RGB\0" - "GL_DOT3_RGBA\0" - "GL_DOT3_RGBA_ARB\0" - "GL_DOT3_RGBA_EXT\0" - "GL_DOT3_RGB_ARB\0" - "GL_DOT3_RGB_EXT\0" - "GL_DOUBLE\0" - "GL_DOUBLEBUFFER\0" - "GL_DRAW_BUFFER\0" - "GL_DRAW_BUFFER0\0" - "GL_DRAW_BUFFER0_ARB\0" - "GL_DRAW_BUFFER0_ATI\0" - "GL_DRAW_BUFFER0_NV\0" - "GL_DRAW_BUFFER1\0" - "GL_DRAW_BUFFER10\0" - "GL_DRAW_BUFFER10_ARB\0" - "GL_DRAW_BUFFER10_ATI\0" - "GL_DRAW_BUFFER10_NV\0" - "GL_DRAW_BUFFER11\0" - "GL_DRAW_BUFFER11_ARB\0" - "GL_DRAW_BUFFER11_ATI\0" - "GL_DRAW_BUFFER11_NV\0" - "GL_DRAW_BUFFER12\0" - "GL_DRAW_BUFFER12_ARB\0" - "GL_DRAW_BUFFER12_ATI\0" - "GL_DRAW_BUFFER12_NV\0" - "GL_DRAW_BUFFER13\0" - "GL_DRAW_BUFFER13_ARB\0" - "GL_DRAW_BUFFER13_ATI\0" - "GL_DRAW_BUFFER13_NV\0" - "GL_DRAW_BUFFER14\0" - "GL_DRAW_BUFFER14_ARB\0" - "GL_DRAW_BUFFER14_ATI\0" - "GL_DRAW_BUFFER14_NV\0" - "GL_DRAW_BUFFER15\0" - "GL_DRAW_BUFFER15_ARB\0" - "GL_DRAW_BUFFER15_ATI\0" - "GL_DRAW_BUFFER15_NV\0" - "GL_DRAW_BUFFER1_ARB\0" - "GL_DRAW_BUFFER1_ATI\0" - "GL_DRAW_BUFFER1_NV\0" - "GL_DRAW_BUFFER2\0" - "GL_DRAW_BUFFER2_ARB\0" - "GL_DRAW_BUFFER2_ATI\0" - "GL_DRAW_BUFFER2_NV\0" - "GL_DRAW_BUFFER3\0" - "GL_DRAW_BUFFER3_ARB\0" - "GL_DRAW_BUFFER3_ATI\0" - "GL_DRAW_BUFFER3_NV\0" - "GL_DRAW_BUFFER4\0" - "GL_DRAW_BUFFER4_ARB\0" - "GL_DRAW_BUFFER4_ATI\0" - "GL_DRAW_BUFFER4_NV\0" - "GL_DRAW_BUFFER5\0" - "GL_DRAW_BUFFER5_ARB\0" - "GL_DRAW_BUFFER5_ATI\0" - "GL_DRAW_BUFFER5_NV\0" - "GL_DRAW_BUFFER6\0" - "GL_DRAW_BUFFER6_ARB\0" - "GL_DRAW_BUFFER6_ATI\0" - "GL_DRAW_BUFFER6_NV\0" - "GL_DRAW_BUFFER7\0" - "GL_DRAW_BUFFER7_ARB\0" - "GL_DRAW_BUFFER7_ATI\0" - "GL_DRAW_BUFFER7_NV\0" - "GL_DRAW_BUFFER8\0" - "GL_DRAW_BUFFER8_ARB\0" - "GL_DRAW_BUFFER8_ATI\0" - "GL_DRAW_BUFFER8_NV\0" - "GL_DRAW_BUFFER9\0" - "GL_DRAW_BUFFER9_ARB\0" - "GL_DRAW_BUFFER9_ATI\0" - "GL_DRAW_BUFFER9_NV\0" - "GL_DRAW_FRAMEBUFFER\0" - "GL_DRAW_FRAMEBUFFER_BINDING\0" - "GL_DRAW_FRAMEBUFFER_BINDING_EXT\0" - "GL_DRAW_FRAMEBUFFER_EXT\0" - "GL_DRAW_PIXEL_TOKEN\0" - "GL_DST_ALPHA\0" - "GL_DST_COLOR\0" - "GL_DU8DV8_ATI\0" - "GL_DUDV_ATI\0" - "GL_DYNAMIC_COPY\0" - "GL_DYNAMIC_COPY_ARB\0" - "GL_DYNAMIC_DRAW\0" - "GL_DYNAMIC_DRAW_ARB\0" - "GL_DYNAMIC_READ\0" - "GL_DYNAMIC_READ_ARB\0" - "GL_EDGE_FLAG\0" - "GL_EDGE_FLAG_ARRAY\0" - "GL_EDGE_FLAG_ARRAY_BUFFER_BINDING\0" - "GL_EDGE_FLAG_ARRAY_BUFFER_BINDING_ARB\0" - "GL_EDGE_FLAG_ARRAY_POINTER\0" - "GL_EDGE_FLAG_ARRAY_STRIDE\0" - "GL_ELEMENT_ARRAY_BUFFER\0" - "GL_ELEMENT_ARRAY_BUFFER_BINDING\0" - "GL_ELEMENT_ARRAY_BUFFER_BINDING_ARB\0" - "GL_EMISSION\0" - "GL_ENABLE_BIT\0" - "GL_EQUAL\0" - "GL_EQUIV\0" - "GL_ETC1_RGB8_OES\0" - "GL_EVAL_BIT\0" - "GL_EXP\0" - "GL_EXP2\0" - "GL_EXTENSIONS\0" - "GL_EYE_LINEAR\0" - "GL_EYE_PLANE\0" - "GL_EYE_PLANE_ABSOLUTE_NV\0" - "GL_EYE_RADIAL_NV\0" - "GL_FALSE\0" - "GL_FASTEST\0" - "GL_FEEDBACK\0" - "GL_FEEDBACK_BUFFER_POINTER\0" - "GL_FEEDBACK_BUFFER_SIZE\0" - "GL_FEEDBACK_BUFFER_TYPE\0" - "GL_FILL\0" - "GL_FIRST_VERTEX_CONVENTION\0" - "GL_FIRST_VERTEX_CONVENTION_EXT\0" - "GL_FIXED\0" - "GL_FIXED_OES\0" - "GL_FIXED_ONLY\0" - "GL_FIXED_ONLY_ARB\0" - "GL_FLAT\0" - "GL_FLOAT\0" - "GL_FLOAT_MAT2\0" - "GL_FLOAT_MAT2_ARB\0" - "GL_FLOAT_MAT2x3\0" - "GL_FLOAT_MAT2x4\0" - "GL_FLOAT_MAT3\0" - "GL_FLOAT_MAT3_ARB\0" - "GL_FLOAT_MAT3x2\0" - "GL_FLOAT_MAT3x4\0" - "GL_FLOAT_MAT4\0" - "GL_FLOAT_MAT4_ARB\0" - "GL_FLOAT_MAT4x2\0" - "GL_FLOAT_MAT4x3\0" - "GL_FLOAT_VEC2\0" - "GL_FLOAT_VEC2_ARB\0" - "GL_FLOAT_VEC3\0" - "GL_FLOAT_VEC3_ARB\0" - "GL_FLOAT_VEC4\0" - "GL_FLOAT_VEC4_ARB\0" - "GL_FOG\0" - "GL_FOG_BIT\0" - "GL_FOG_COLOR\0" - "GL_FOG_COORD\0" - "GL_FOG_COORDINATE\0" - "GL_FOG_COORDINATE_ARRAY\0" - "GL_FOG_COORDINATE_ARRAY_BUFFER_BINDING\0" - "GL_FOG_COORDINATE_ARRAY_BUFFER_BINDING_ARB\0" - "GL_FOG_COORDINATE_ARRAY_POINTER\0" - "GL_FOG_COORDINATE_ARRAY_STRIDE\0" - "GL_FOG_COORDINATE_ARRAY_TYPE\0" - "GL_FOG_COORDINATE_SOURCE\0" - "GL_FOG_COORD_ARRAY\0" - "GL_FOG_COORD_ARRAY_BUFFER_BINDING\0" - "GL_FOG_COORD_ARRAY_POINTER\0" - "GL_FOG_COORD_ARRAY_STRIDE\0" - "GL_FOG_COORD_ARRAY_TYPE\0" - "GL_FOG_COORD_SRC\0" - "GL_FOG_DENSITY\0" - "GL_FOG_DISTANCE_MODE_NV\0" - "GL_FOG_END\0" - "GL_FOG_HINT\0" - "GL_FOG_INDEX\0" - "GL_FOG_MODE\0" - "GL_FOG_OFFSET_SGIX\0" - "GL_FOG_OFFSET_VALUE_SGIX\0" - "GL_FOG_START\0" - "GL_FRAGMENT_DEPTH\0" - "GL_FRAGMENT_PROGRAM_ARB\0" - "GL_FRAGMENT_SHADER\0" - "GL_FRAGMENT_SHADER_ARB\0" - "GL_FRAGMENT_SHADER_DERIVATIVE_HINT\0" - "GL_FRAGMENT_SHADER_DERIVATIVE_HINT_OES\0" - "GL_FRAMEBUFFER\0" - "GL_FRAMEBUFFER_ATTACHMENT_ALPHA_SIZE\0" - "GL_FRAMEBUFFER_ATTACHMENT_BLUE_SIZE\0" - "GL_FRAMEBUFFER_ATTACHMENT_COLOR_ENCODING\0" - "GL_FRAMEBUFFER_ATTACHMENT_COMPONENT_TYPE\0" - "GL_FRAMEBUFFER_ATTACHMENT_DEPTH_SIZE\0" - "GL_FRAMEBUFFER_ATTACHMENT_GREEN_SIZE\0" - "GL_FRAMEBUFFER_ATTACHMENT_LAYERED\0" - "GL_FRAMEBUFFER_ATTACHMENT_LAYERED_ARB\0" - "GL_FRAMEBUFFER_ATTACHMENT_OBJECT_NAME\0" - "GL_FRAMEBUFFER_ATTACHMENT_OBJECT_NAME_EXT\0" - "GL_FRAMEBUFFER_ATTACHMENT_OBJECT_NAME_OES\0" - "GL_FRAMEBUFFER_ATTACHMENT_OBJECT_TYPE\0" - "GL_FRAMEBUFFER_ATTACHMENT_OBJECT_TYPE_EXT\0" - "GL_FRAMEBUFFER_ATTACHMENT_OBJECT_TYPE_OES\0" - "GL_FRAMEBUFFER_ATTACHMENT_RED_SIZE\0" - "GL_FRAMEBUFFER_ATTACHMENT_STENCIL_SIZE\0" - "GL_FRAMEBUFFER_ATTACHMENT_TEXTURE_3D_ZOFFSET_EXT\0" - "GL_FRAMEBUFFER_ATTACHMENT_TEXTURE_3D_ZOFFSET_OES\0" - "GL_FRAMEBUFFER_ATTACHMENT_TEXTURE_CUBE_MAP_FACE\0" - "GL_FRAMEBUFFER_ATTACHMENT_TEXTURE_CUBE_MAP_FACE_EXT\0" - "GL_FRAMEBUFFER_ATTACHMENT_TEXTURE_CUBE_MAP_FACE_OES\0" - "GL_FRAMEBUFFER_ATTACHMENT_TEXTURE_LAYER\0" - "GL_FRAMEBUFFER_ATTACHMENT_TEXTURE_LAYER_EXT\0" - "GL_FRAMEBUFFER_ATTACHMENT_TEXTURE_LEVEL\0" - "GL_FRAMEBUFFER_ATTACHMENT_TEXTURE_LEVEL_EXT\0" - "GL_FRAMEBUFFER_ATTACHMENT_TEXTURE_LEVEL_OES\0" - "GL_FRAMEBUFFER_BINDING\0" - "GL_FRAMEBUFFER_BINDING_EXT\0" - "GL_FRAMEBUFFER_BINDING_OES\0" - "GL_FRAMEBUFFER_COMPLETE\0" - "GL_FRAMEBUFFER_COMPLETE_EXT\0" - "GL_FRAMEBUFFER_COMPLETE_OES\0" - "GL_FRAMEBUFFER_DEFAULT\0" - "GL_FRAMEBUFFER_EXT\0" - "GL_FRAMEBUFFER_INCOMPLETE_ATTACHMENT\0" - "GL_FRAMEBUFFER_INCOMPLETE_ATTACHMENT_EXT\0" - "GL_FRAMEBUFFER_INCOMPLETE_ATTACHMENT_OES\0" - "GL_FRAMEBUFFER_INCOMPLETE_DIMENSIONS\0" - "GL_FRAMEBUFFER_INCOMPLETE_DIMENSIONS_EXT\0" - "GL_FRAMEBUFFER_INCOMPLETE_DIMENSIONS_OES\0" - "GL_FRAMEBUFFER_INCOMPLETE_DRAW_BUFFER\0" - "GL_FRAMEBUFFER_INCOMPLETE_DRAW_BUFFER_EXT\0" - "GL_FRAMEBUFFER_INCOMPLETE_DRAW_BUFFER_OES\0" - "GL_FRAMEBUFFER_INCOMPLETE_DUPLICATE_ATTACHMENT_EXT\0" - "GL_FRAMEBUFFER_INCOMPLETE_FORMATS_EXT\0" - "GL_FRAMEBUFFER_INCOMPLETE_FORMATS_OES\0" - "GL_FRAMEBUFFER_INCOMPLETE_LAYER_COUNT_ARB\0" - "GL_FRAMEBUFFER_INCOMPLETE_LAYER_TARGETS\0" - "GL_FRAMEBUFFER_INCOMPLETE_LAYER_TARGETS_ARB\0" - "GL_FRAMEBUFFER_INCOMPLETE_MISSING_ATTACHMENT\0" - "GL_FRAMEBUFFER_INCOMPLETE_MISSING_ATTACHMENT_EXT\0" - "GL_FRAMEBUFFER_INCOMPLETE_MISSING_ATTACHMENT_OES\0" - "GL_FRAMEBUFFER_INCOMPLETE_MULTISAMPLE\0" - "GL_FRAMEBUFFER_INCOMPLETE_MULTISAMPLE_EXT\0" - "GL_FRAMEBUFFER_INCOMPLETE_READ_BUFFER\0" - "GL_FRAMEBUFFER_INCOMPLETE_READ_BUFFER_EXT\0" - "GL_FRAMEBUFFER_INCOMPLETE_READ_BUFFER_OES\0" - "GL_FRAMEBUFFER_OES\0" - "GL_FRAMEBUFFER_STATUS_ERROR_EXT\0" - "GL_FRAMEBUFFER_UNDEFINED\0" - "GL_FRAMEBUFFER_UNSUPPORTED\0" - "GL_FRAMEBUFFER_UNSUPPORTED_EXT\0" - "GL_FRAMEBUFFER_UNSUPPORTED_OES\0" - "GL_FRONT\0" - "GL_FRONT_AND_BACK\0" - "GL_FRONT_FACE\0" - "GL_FRONT_LEFT\0" - "GL_FRONT_RIGHT\0" - "GL_FUNC_ADD\0" - "GL_FUNC_ADD_EXT\0" - "GL_FUNC_ADD_OES\0" - "GL_FUNC_REVERSE_SUBTRACT\0" - "GL_FUNC_REVERSE_SUBTRACT_EXT\0" - "GL_FUNC_REVERSE_SUBTRACT_OES\0" - "GL_FUNC_SUBTRACT\0" - "GL_FUNC_SUBTRACT_EXT\0" - "GL_FUNC_SUBTRACT_OES\0" - "GL_GENERATE_MIPMAP\0" - "GL_GENERATE_MIPMAP_HINT\0" - "GL_GENERATE_MIPMAP_HINT_SGIS\0" - "GL_GENERATE_MIPMAP_SGIS\0" - "GL_GEOMETRY_INPUT_TYPE\0" - "GL_GEOMETRY_INPUT_TYPE_ARB\0" - "GL_GEOMETRY_OUTPUT_TYPE\0" - "GL_GEOMETRY_OUTPUT_TYPE_ARB\0" - "GL_GEOMETRY_SHADER\0" - "GL_GEOMETRY_SHADER_ARB\0" - "GL_GEOMETRY_VERTICES_OUT\0" - "GL_GEOMETRY_VERTICES_OUT_ARB\0" - "GL_GEQUAL\0" - "GL_GL_TEXTURE_IMMUTABLE_FORMAT\0" - "GL_GREATER\0" - "GL_GREEN\0" - "GL_GREEN_BIAS\0" - "GL_GREEN_BITS\0" - "GL_GREEN_INTEGER\0" - "GL_GREEN_INTEGER_EXT\0" - "GL_GREEN_SCALE\0" - "GL_GUILTY_CONTEXT_RESET_ARB\0" - "GL_HALF_FLOAT\0" - "GL_HALF_FLOAT_OES\0" - "GL_HIGH_FLOAT\0" - "GL_HIGH_INT\0" - "GL_HINT_BIT\0" - "GL_HISTOGRAM\0" - "GL_HISTOGRAM_ALPHA_SIZE\0" - "GL_HISTOGRAM_ALPHA_SIZE_EXT\0" - "GL_HISTOGRAM_BLUE_SIZE\0" - "GL_HISTOGRAM_BLUE_SIZE_EXT\0" - "GL_HISTOGRAM_EXT\0" - "GL_HISTOGRAM_FORMAT\0" - "GL_HISTOGRAM_FORMAT_EXT\0" - "GL_HISTOGRAM_GREEN_SIZE\0" - "GL_HISTOGRAM_GREEN_SIZE_EXT\0" - "GL_HISTOGRAM_LUMINANCE_SIZE\0" - "GL_HISTOGRAM_LUMINANCE_SIZE_EXT\0" - "GL_HISTOGRAM_RED_SIZE\0" - "GL_HISTOGRAM_RED_SIZE_EXT\0" - "GL_HISTOGRAM_SINK\0" - "GL_HISTOGRAM_SINK_EXT\0" - "GL_HISTOGRAM_WIDTH\0" - "GL_HISTOGRAM_WIDTH_EXT\0" - "GL_IDENTITY_NV\0" - "GL_IGNORE_BORDER_HP\0" - "GL_IMPLEMENTATION_COLOR_READ_FORMAT\0" - "GL_IMPLEMENTATION_COLOR_READ_FORMAT_OES\0" - "GL_IMPLEMENTATION_COLOR_READ_TYPE\0" - "GL_IMPLEMENTATION_COLOR_READ_TYPE_OES\0" - "GL_INCR\0" - "GL_INCR_WRAP\0" - "GL_INCR_WRAP_EXT\0" - "GL_INDEX\0" - "GL_INDEX_ARRAY\0" - "GL_INDEX_ARRAY_BUFFER_BINDING\0" - "GL_INDEX_ARRAY_BUFFER_BINDING_ARB\0" - "GL_INDEX_ARRAY_POINTER\0" - "GL_INDEX_ARRAY_STRIDE\0" - "GL_INDEX_ARRAY_TYPE\0" - "GL_INDEX_BITS\0" - "GL_INDEX_CLEAR_VALUE\0" - "GL_INDEX_LOGIC_OP\0" - "GL_INDEX_MODE\0" - "GL_INDEX_OFFSET\0" - "GL_INDEX_SHIFT\0" - "GL_INDEX_WRITEMASK\0" - "GL_INFO_LOG_LENGTH\0" - "GL_INNOCENT_CONTEXT_RESET_ARB\0" - "GL_INT\0" - "GL_INTENSITY\0" - "GL_INTENSITY12\0" - "GL_INTENSITY12_EXT\0" - "GL_INTENSITY16\0" - "GL_INTENSITY16I_EXT\0" - "GL_INTENSITY16UI_EXT\0" - "GL_INTENSITY16_EXT\0" - "GL_INTENSITY32I_EXT\0" - "GL_INTENSITY32UI_EXT\0" - "GL_INTENSITY4\0" - "GL_INTENSITY4_EXT\0" - "GL_INTENSITY8\0" - "GL_INTENSITY8I_EXT\0" - "GL_INTENSITY8UI_EXT\0" - "GL_INTENSITY8_EXT\0" - "GL_INTENSITY_EXT\0" - "GL_INTERLEAVED_ATTRIBS\0" - "GL_INTERLEAVED_ATTRIBS_EXT\0" - "GL_INTERPOLATE\0" - "GL_INTERPOLATE_ARB\0" - "GL_INTERPOLATE_EXT\0" - "GL_INT_10_10_10_2_OES\0" - "GL_INT_2_10_10_10_REV\0" - "GL_INT_SAMPLER_1D\0" - "GL_INT_SAMPLER_1D_ARRAY\0" - "GL_INT_SAMPLER_1D_ARRAY_EXT\0" - "GL_INT_SAMPLER_1D_EXT\0" - "GL_INT_SAMPLER_2D\0" - "GL_INT_SAMPLER_2D_ARRAY\0" - "GL_INT_SAMPLER_2D_ARRAY_EXT\0" - "GL_INT_SAMPLER_2D_EXT\0" - "GL_INT_SAMPLER_2D_RECT\0" - "GL_INT_SAMPLER_2D_RECT_EXT\0" - "GL_INT_SAMPLER_3D\0" - "GL_INT_SAMPLER_3D_EXT\0" - "GL_INT_SAMPLER_BUFFER\0" - "GL_INT_SAMPLER_BUFFER_EXT\0" - "GL_INT_SAMPLER_CUBE\0" - "GL_INT_SAMPLER_CUBE_EXT\0" - "GL_INT_VEC2\0" - "GL_INT_VEC2_ARB\0" - "GL_INT_VEC3\0" - "GL_INT_VEC3_ARB\0" - "GL_INT_VEC4\0" - "GL_INT_VEC4_ARB\0" - "GL_INVALID_ENUM\0" - "GL_INVALID_FRAMEBUFFER_OPERATION\0" - "GL_INVALID_FRAMEBUFFER_OPERATION_EXT\0" - "GL_INVALID_FRAMEBUFFER_OPERATION_OES\0" - "GL_INVALID_OPERATION\0" - "GL_INVALID_VALUE\0" - "GL_INVERSE_NV\0" - "GL_INVERSE_TRANSPOSE_NV\0" - "GL_INVERT\0" - "GL_KEEP\0" - "GL_LAST_VERTEX_CONVENTION\0" - "GL_LAST_VERTEX_CONVENTION_EXT\0" - "GL_LEFT\0" - "GL_LEQUAL\0" - "GL_LESS\0" - "GL_LIGHT0\0" - "GL_LIGHT1\0" - "GL_LIGHT2\0" - "GL_LIGHT3\0" - "GL_LIGHT4\0" - "GL_LIGHT5\0" - "GL_LIGHT6\0" - "GL_LIGHT7\0" - "GL_LIGHTING\0" - "GL_LIGHTING_BIT\0" - "GL_LIGHT_MODEL_AMBIENT\0" - "GL_LIGHT_MODEL_COLOR_CONTROL\0" - "GL_LIGHT_MODEL_COLOR_CONTROL_EXT\0" - "GL_LIGHT_MODEL_LOCAL_VIEWER\0" - "GL_LIGHT_MODEL_TWO_SIDE\0" - "GL_LINE\0" - "GL_LINEAR\0" - "GL_LINEAR_ATTENUATION\0" - "GL_LINEAR_CLIPMAP_LINEAR_SGIX\0" - "GL_LINEAR_CLIPMAP_NEAREST_SGIX\0" - "GL_LINEAR_MIPMAP_LINEAR\0" - "GL_LINEAR_MIPMAP_NEAREST\0" - "GL_LINES\0" - "GL_LINES_ADJACENCY\0" - "GL_LINES_ADJACENCY_ARB\0" - "GL_LINE_BIT\0" - "GL_LINE_LOOP\0" - "GL_LINE_RESET_TOKEN\0" - "GL_LINE_SMOOTH\0" - "GL_LINE_SMOOTH_HINT\0" - "GL_LINE_STIPPLE\0" - "GL_LINE_STIPPLE_PATTERN\0" - "GL_LINE_STIPPLE_REPEAT\0" - "GL_LINE_STRIP\0" - "GL_LINE_STRIP_ADJACENCY\0" - "GL_LINE_STRIP_ADJACENCY_ARB\0" - "GL_LINE_TOKEN\0" - "GL_LINE_WIDTH\0" - "GL_LINE_WIDTH_GRANULARITY\0" - "GL_LINE_WIDTH_RANGE\0" - "GL_LINK_STATUS\0" - "GL_LIST_BASE\0" - "GL_LIST_BIT\0" - "GL_LIST_INDEX\0" - "GL_LIST_MODE\0" - "GL_LOAD\0" - "GL_LOGIC_OP\0" - "GL_LOGIC_OP_MODE\0" - "GL_LOSE_CONTEXT_ON_RESET_ARB\0" - "GL_LOWER_LEFT\0" - "GL_LOW_FLOAT\0" - "GL_LOW_INT\0" - "GL_LUMINANCE\0" - "GL_LUMINANCE12\0" - "GL_LUMINANCE12_ALPHA12\0" - "GL_LUMINANCE12_ALPHA12_EXT\0" - "GL_LUMINANCE12_ALPHA4\0" - "GL_LUMINANCE12_ALPHA4_EXT\0" - "GL_LUMINANCE12_EXT\0" - "GL_LUMINANCE16\0" - "GL_LUMINANCE16I_EXT\0" - "GL_LUMINANCE16UI_EXT\0" - "GL_LUMINANCE16_ALPHA16\0" - "GL_LUMINANCE16_ALPHA16_EXT\0" - "GL_LUMINANCE16_EXT\0" - "GL_LUMINANCE32I_EXT\0" - "GL_LUMINANCE32UI_EXT\0" - "GL_LUMINANCE4\0" - "GL_LUMINANCE4_ALPHA4\0" - "GL_LUMINANCE4_ALPHA4_EXT\0" - "GL_LUMINANCE4_EXT\0" - "GL_LUMINANCE6_ALPHA2\0" - "GL_LUMINANCE6_ALPHA2_EXT\0" - "GL_LUMINANCE8\0" - "GL_LUMINANCE8I_EXT\0" - "GL_LUMINANCE8UI_EXT\0" - "GL_LUMINANCE8_ALPHA8\0" - "GL_LUMINANCE8_ALPHA8_EXT\0" - "GL_LUMINANCE8_EXT\0" - "GL_LUMINANCE_ALPHA\0" - "GL_LUMINANCE_ALPHA16I_EXT\0" - "GL_LUMINANCE_ALPHA16UI_EXT\0" - "GL_LUMINANCE_ALPHA32I_EXT\0" - "GL_LUMINANCE_ALPHA32UI_EXT\0" - "GL_LUMINANCE_ALPHA8I_EXT\0" - "GL_LUMINANCE_ALPHA8UI_EXT\0" - "GL_LUMINANCE_ALPHA_INTEGER_EXT\0" - "GL_LUMINANCE_INTEGER_EXT\0" - "GL_MAJOR_VERSION\0" - "GL_MAP1_COLOR_4\0" - "GL_MAP1_GRID_DOMAIN\0" - "GL_MAP1_GRID_SEGMENTS\0" - "GL_MAP1_INDEX\0" - "GL_MAP1_NORMAL\0" - "GL_MAP1_TEXTURE_COORD_1\0" - "GL_MAP1_TEXTURE_COORD_2\0" - "GL_MAP1_TEXTURE_COORD_3\0" - "GL_MAP1_TEXTURE_COORD_4\0" - "GL_MAP1_VERTEX_3\0" - "GL_MAP1_VERTEX_4\0" - "GL_MAP1_VERTEX_ATTRIB0_4_NV\0" - "GL_MAP1_VERTEX_ATTRIB10_4_NV\0" - "GL_MAP1_VERTEX_ATTRIB11_4_NV\0" - "GL_MAP1_VERTEX_ATTRIB12_4_NV\0" - "GL_MAP1_VERTEX_ATTRIB13_4_NV\0" - "GL_MAP1_VERTEX_ATTRIB14_4_NV\0" - "GL_MAP1_VERTEX_ATTRIB15_4_NV\0" - "GL_MAP1_VERTEX_ATTRIB1_4_NV\0" - "GL_MAP1_VERTEX_ATTRIB2_4_NV\0" - "GL_MAP1_VERTEX_ATTRIB3_4_NV\0" - "GL_MAP1_VERTEX_ATTRIB4_4_NV\0" - "GL_MAP1_VERTEX_ATTRIB5_4_NV\0" - "GL_MAP1_VERTEX_ATTRIB6_4_NV\0" - "GL_MAP1_VERTEX_ATTRIB7_4_NV\0" - "GL_MAP1_VERTEX_ATTRIB8_4_NV\0" - "GL_MAP1_VERTEX_ATTRIB9_4_NV\0" - "GL_MAP2_COLOR_4\0" - "GL_MAP2_GRID_DOMAIN\0" - "GL_MAP2_GRID_SEGMENTS\0" - "GL_MAP2_INDEX\0" - "GL_MAP2_NORMAL\0" - "GL_MAP2_TEXTURE_COORD_1\0" - "GL_MAP2_TEXTURE_COORD_2\0" - "GL_MAP2_TEXTURE_COORD_3\0" - "GL_MAP2_TEXTURE_COORD_4\0" - "GL_MAP2_VERTEX_3\0" - "GL_MAP2_VERTEX_4\0" - "GL_MAP2_VERTEX_ATTRIB0_4_NV\0" - "GL_MAP2_VERTEX_ATTRIB10_4_NV\0" - "GL_MAP2_VERTEX_ATTRIB11_4_NV\0" - "GL_MAP2_VERTEX_ATTRIB12_4_NV\0" - "GL_MAP2_VERTEX_ATTRIB13_4_NV\0" - "GL_MAP2_VERTEX_ATTRIB14_4_NV\0" - "GL_MAP2_VERTEX_ATTRIB15_4_NV\0" - "GL_MAP2_VERTEX_ATTRIB1_4_NV\0" - "GL_MAP2_VERTEX_ATTRIB2_4_NV\0" - "GL_MAP2_VERTEX_ATTRIB3_4_NV\0" - "GL_MAP2_VERTEX_ATTRIB4_4_NV\0" - "GL_MAP2_VERTEX_ATTRIB5_4_NV\0" - "GL_MAP2_VERTEX_ATTRIB6_4_NV\0" - "GL_MAP2_VERTEX_ATTRIB7_4_NV\0" - "GL_MAP2_VERTEX_ATTRIB8_4_NV\0" - "GL_MAP2_VERTEX_ATTRIB9_4_NV\0" - "GL_MAP_COLOR\0" - "GL_MAP_FLUSH_EXPLICIT_BIT\0" - "GL_MAP_INVALIDATE_BUFFER_BIT\0" - "GL_MAP_INVALIDATE_RANGE_BIT\0" - "GL_MAP_READ_BIT\0" - "GL_MAP_STENCIL\0" - "GL_MAP_UNSYNCHRONIZED_BIT\0" - "GL_MAP_WRITE_BIT\0" - "GL_MATRIX0_ARB\0" - "GL_MATRIX0_NV\0" - "GL_MATRIX10_ARB\0" - "GL_MATRIX11_ARB\0" - "GL_MATRIX12_ARB\0" - "GL_MATRIX13_ARB\0" - "GL_MATRIX14_ARB\0" - "GL_MATRIX15_ARB\0" - "GL_MATRIX16_ARB\0" - "GL_MATRIX17_ARB\0" - "GL_MATRIX18_ARB\0" - "GL_MATRIX19_ARB\0" - "GL_MATRIX1_ARB\0" - "GL_MATRIX1_NV\0" - "GL_MATRIX20_ARB\0" - "GL_MATRIX21_ARB\0" - "GL_MATRIX22_ARB\0" - "GL_MATRIX23_ARB\0" - "GL_MATRIX24_ARB\0" - "GL_MATRIX25_ARB\0" - "GL_MATRIX26_ARB\0" - "GL_MATRIX27_ARB\0" - "GL_MATRIX28_ARB\0" - "GL_MATRIX29_ARB\0" - "GL_MATRIX2_ARB\0" - "GL_MATRIX2_NV\0" - "GL_MATRIX30_ARB\0" - "GL_MATRIX31_ARB\0" - "GL_MATRIX3_ARB\0" - "GL_MATRIX3_NV\0" - "GL_MATRIX4_ARB\0" - "GL_MATRIX4_NV\0" - "GL_MATRIX5_ARB\0" - "GL_MATRIX5_NV\0" - "GL_MATRIX6_ARB\0" - "GL_MATRIX6_NV\0" - "GL_MATRIX7_ARB\0" - "GL_MATRIX7_NV\0" - "GL_MATRIX8_ARB\0" - "GL_MATRIX9_ARB\0" - "GL_MATRIX_INDEX_ARRAY_ARB\0" - "GL_MATRIX_INDEX_ARRAY_BUFFER_BINDING_OES\0" - "GL_MATRIX_INDEX_ARRAY_OES\0" - "GL_MATRIX_INDEX_ARRAY_POINTER_ARB\0" - "GL_MATRIX_INDEX_ARRAY_POINTER_OES\0" - "GL_MATRIX_INDEX_ARRAY_SIZE_ARB\0" - "GL_MATRIX_INDEX_ARRAY_SIZE_OES\0" - "GL_MATRIX_INDEX_ARRAY_STRIDE_ARB\0" - "GL_MATRIX_INDEX_ARRAY_STRIDE_OES\0" - "GL_MATRIX_INDEX_ARRAY_TYPE_ARB\0" - "GL_MATRIX_INDEX_ARRAY_TYPE_OES\0" - "GL_MATRIX_MODE\0" - "GL_MATRIX_PALETTE_ARB\0" - "GL_MATRIX_PALETTE_OES\0" - "GL_MAX\0" - "GL_MAX_3D_TEXTURE_SIZE\0" - "GL_MAX_3D_TEXTURE_SIZE_OES\0" - "GL_MAX_ARRAY_TEXTURE_LAYERS\0" - "GL_MAX_ARRAY_TEXTURE_LAYERS_EXT\0" - "GL_MAX_ATTRIB_STACK_DEPTH\0" - "GL_MAX_CLIENT_ATTRIB_STACK_DEPTH\0" - "GL_MAX_CLIPMAP_DEPTH_SGIX\0" - "GL_MAX_CLIPMAP_VIRTUAL_DEPTH_SGIX\0" - "GL_MAX_CLIP_DISTANCES\0" - "GL_MAX_CLIP_PLANES\0" - "GL_MAX_COLOR_ATTACHMENTS\0" - "GL_MAX_COLOR_ATTACHMENTS_EXT\0" - "GL_MAX_COLOR_MATRIX_STACK_DEPTH\0" - "GL_MAX_COLOR_MATRIX_STACK_DEPTH_SGI\0" - "GL_MAX_COMBINED_TEXTURE_IMAGE_UNITS\0" - "GL_MAX_COMBINED_TEXTURE_IMAGE_UNITS_ARB\0" - "GL_MAX_CONVOLUTION_HEIGHT\0" - "GL_MAX_CONVOLUTION_HEIGHT_EXT\0" - "GL_MAX_CONVOLUTION_WIDTH\0" - "GL_MAX_CONVOLUTION_WIDTH_EXT\0" - "GL_MAX_CUBE_MAP_TEXTURE_SIZE\0" - "GL_MAX_CUBE_MAP_TEXTURE_SIZE_ARB\0" - "GL_MAX_CUBE_MAP_TEXTURE_SIZE_OES\0" - "GL_MAX_DRAW_BUFFERS\0" - "GL_MAX_DRAW_BUFFERS_ARB\0" - "GL_MAX_DRAW_BUFFERS_ATI\0" - "GL_MAX_DRAW_BUFFERS_NV\0" - "GL_MAX_ELEMENTS_INDICES\0" - "GL_MAX_ELEMENTS_VERTICES\0" - "GL_MAX_EVAL_ORDER\0" - "GL_MAX_EXT\0" - "GL_MAX_FRAGMENT_INPUT_COMPONENTS\0" - "GL_MAX_FRAGMENT_UNIFORM_COMPONENTS\0" - "GL_MAX_FRAGMENT_UNIFORM_COMPONENTS_ARB\0" - "GL_MAX_FRAGMENT_UNIFORM_VECTORS\0" - "GL_MAX_GEOMETRY_INPUT_COMPONENTS\0" - "GL_MAX_GEOMETRY_OUTPUT_COMPONENTS\0" - "GL_MAX_GEOMETRY_OUTPUT_VERTICES\0" - "GL_MAX_GEOMETRY_OUTPUT_VERTICES_ARB\0" - "GL_MAX_GEOMETRY_TEXTURE_IMAGE_UNITS\0" - "GL_MAX_GEOMETRY_TEXTURE_IMAGE_UNITS_ARB\0" - "GL_MAX_GEOMETRY_TOTAL_OUTPUT_COMPONENTS\0" - "GL_MAX_GEOMETRY_TOTAL_OUTPUT_COMPONENTS_ARB\0" - "GL_MAX_GEOMETRY_UNIFORM_COMPONENTS\0" - "GL_MAX_GEOMETRY_UNIFORM_COMPONENTS_ARB\0" - "GL_MAX_GEOMETRY_VARYING_COMPONENTS_ARB\0" - "GL_MAX_LIGHTS\0" - "GL_MAX_LIST_NESTING\0" - "GL_MAX_MATRIX_PALETTE_STACK_DEPTH_ARB\0" - "GL_MAX_MODELVIEW_STACK_DEPTH\0" - "GL_MAX_NAME_STACK_DEPTH\0" - "GL_MAX_PALETTE_MATRICES_ARB\0" - "GL_MAX_PALETTE_MATRICES_OES\0" - "GL_MAX_PIXEL_MAP_TABLE\0" - "GL_MAX_PROGRAM_ADDRESS_REGISTERS_ARB\0" - "GL_MAX_PROGRAM_ALU_INSTRUCTIONS_ARB\0" - "GL_MAX_PROGRAM_ATTRIBS_ARB\0" - "GL_MAX_PROGRAM_CALL_DEPTH_NV\0" - "GL_MAX_PROGRAM_ENV_PARAMETERS_ARB\0" - "GL_MAX_PROGRAM_EXEC_INSTRUCTIONS_NV\0" - "GL_MAX_PROGRAM_IF_DEPTH_NV\0" - "GL_MAX_PROGRAM_INSTRUCTIONS_ARB\0" - "GL_MAX_PROGRAM_LOCAL_PARAMETERS_ARB\0" - "GL_MAX_PROGRAM_LOOP_COUNT_NV\0" - "GL_MAX_PROGRAM_LOOP_DEPTH_NV\0" - "GL_MAX_PROGRAM_MATRICES_ARB\0" - "GL_MAX_PROGRAM_MATRIX_STACK_DEPTH_ARB\0" - "GL_MAX_PROGRAM_NATIVE_ADDRESS_REGISTERS_ARB\0" - "GL_MAX_PROGRAM_NATIVE_ALU_INSTRUCTIONS_ARB\0" - "GL_MAX_PROGRAM_NATIVE_ATTRIBS_ARB\0" - "GL_MAX_PROGRAM_NATIVE_INSTRUCTIONS_ARB\0" - "GL_MAX_PROGRAM_NATIVE_PARAMETERS_ARB\0" - "GL_MAX_PROGRAM_NATIVE_TEMPORARIES_ARB\0" - "GL_MAX_PROGRAM_NATIVE_TEX_INDIRECTIONS_ARB\0" - "GL_MAX_PROGRAM_NATIVE_TEX_INSTRUCTIONS_ARB\0" - "GL_MAX_PROGRAM_PARAMETERS_ARB\0" - "GL_MAX_PROGRAM_TEMPORARIES_ARB\0" - "GL_MAX_PROGRAM_TEXEL_OFFSET\0" - "GL_MAX_PROGRAM_TEX_INDIRECTIONS_ARB\0" - "GL_MAX_PROGRAM_TEX_INSTRUCTIONS_ARB\0" - "GL_MAX_PROJECTION_STACK_DEPTH\0" - "GL_MAX_RECTANGLE_TEXTURE_SIZE\0" - "GL_MAX_RECTANGLE_TEXTURE_SIZE_ARB\0" - "GL_MAX_RECTANGLE_TEXTURE_SIZE_NV\0" - "GL_MAX_RENDERBUFFER_SIZE\0" - "GL_MAX_RENDERBUFFER_SIZE_EXT\0" - "GL_MAX_RENDERBUFFER_SIZE_OES\0" - "GL_MAX_SAMPLES\0" - "GL_MAX_SAMPLES_EXT\0" - "GL_MAX_SERVER_WAIT_TIMEOUT\0" - "GL_MAX_SHININESS_NV\0" - "GL_MAX_SPOT_EXPONENT_NV\0" - "GL_MAX_TEXTURE_BUFFER_SIZE\0" - "GL_MAX_TEXTURE_BUFFER_SIZE_ARB\0" - "GL_MAX_TEXTURE_COORDS\0" - "GL_MAX_TEXTURE_COORDS_ARB\0" - "GL_MAX_TEXTURE_IMAGE_UNITS\0" - "GL_MAX_TEXTURE_IMAGE_UNITS_ARB\0" - "GL_MAX_TEXTURE_LOD_BIAS\0" - "GL_MAX_TEXTURE_LOD_BIAS_EXT\0" - "GL_MAX_TEXTURE_MAX_ANISOTROPY_EXT\0" - "GL_MAX_TEXTURE_SIZE\0" - "GL_MAX_TEXTURE_STACK_DEPTH\0" - "GL_MAX_TEXTURE_UNITS\0" - "GL_MAX_TEXTURE_UNITS_ARB\0" - "GL_MAX_TRACK_MATRICES_NV\0" - "GL_MAX_TRACK_MATRIX_STACK_DEPTH_NV\0" - "GL_MAX_TRANSFORM_FEEDBACK_INTERLEAVED_COMPONENTS\0" - "GL_MAX_TRANSFORM_FEEDBACK_INTERLEAVED_COMPONENTS_EXT\0" - "GL_MAX_TRANSFORM_FEEDBACK_SEPARATE_ATTRIBS\0" - "GL_MAX_TRANSFORM_FEEDBACK_SEPARATE_ATTRIBS_EXT\0" - "GL_MAX_TRANSFORM_FEEDBACK_SEPARATE_COMPONENTS\0" - "GL_MAX_TRANSFORM_FEEDBACK_SEPARATE_COMPONENTS_EXT\0" - "GL_MAX_VARYING_COMPONENTS\0" - "GL_MAX_VARYING_FLOATS\0" - "GL_MAX_VARYING_FLOATS_ARB\0" - "GL_MAX_VARYING_VECTORS\0" - "GL_MAX_VERTEX_ATTRIBS\0" - "GL_MAX_VERTEX_ATTRIBS_ARB\0" - "GL_MAX_VERTEX_OUTPUT_COMPONENTS\0" - "GL_MAX_VERTEX_TEXTURE_IMAGE_UNITS\0" - "GL_MAX_VERTEX_TEXTURE_IMAGE_UNITS_ARB\0" - "GL_MAX_VERTEX_UNIFORM_COMPONENTS\0" - "GL_MAX_VERTEX_UNIFORM_COMPONENTS_ARB\0" - "GL_MAX_VERTEX_UNIFORM_VECTORS\0" - "GL_MAX_VERTEX_UNITS_ARB\0" - "GL_MAX_VERTEX_UNITS_OES\0" - "GL_MAX_VERTEX_VARYING_COMPONENTS_ARB\0" - "GL_MAX_VIEWPORT_DIMS\0" - "GL_MEDIUM_FLOAT\0" - "GL_MEDIUM_INT\0" - "GL_MIN\0" - "GL_MINMAX\0" - "GL_MINMAX_EXT\0" - "GL_MINMAX_FORMAT\0" - "GL_MINMAX_FORMAT_EXT\0" - "GL_MINMAX_SINK\0" - "GL_MINMAX_SINK_EXT\0" - "GL_MINOR_VERSION\0" - "GL_MIN_EXT\0" - "GL_MIN_PROGRAM_TEXEL_OFFSET\0" - "GL_MIRRORED_REPEAT\0" - "GL_MIRRORED_REPEAT_ARB\0" - "GL_MIRRORED_REPEAT_IBM\0" - "GL_MIRROR_CLAMP_ATI\0" - "GL_MIRROR_CLAMP_EXT\0" - "GL_MIRROR_CLAMP_TO_BORDER_EXT\0" - "GL_MIRROR_CLAMP_TO_EDGE_ATI\0" - "GL_MIRROR_CLAMP_TO_EDGE_EXT\0" - "GL_MODELVIEW\0" - "GL_MODELVIEW0_ARB\0" - "GL_MODELVIEW10_ARB\0" - "GL_MODELVIEW11_ARB\0" - "GL_MODELVIEW12_ARB\0" - "GL_MODELVIEW13_ARB\0" - "GL_MODELVIEW14_ARB\0" - "GL_MODELVIEW15_ARB\0" - "GL_MODELVIEW16_ARB\0" - "GL_MODELVIEW17_ARB\0" - "GL_MODELVIEW18_ARB\0" - "GL_MODELVIEW19_ARB\0" - "GL_MODELVIEW1_ARB\0" - "GL_MODELVIEW20_ARB\0" - "GL_MODELVIEW21_ARB\0" - "GL_MODELVIEW22_ARB\0" - "GL_MODELVIEW23_ARB\0" - "GL_MODELVIEW24_ARB\0" - "GL_MODELVIEW25_ARB\0" - "GL_MODELVIEW26_ARB\0" - "GL_MODELVIEW27_ARB\0" - "GL_MODELVIEW28_ARB\0" - "GL_MODELVIEW29_ARB\0" - "GL_MODELVIEW2_ARB\0" - "GL_MODELVIEW30_ARB\0" - "GL_MODELVIEW31_ARB\0" - "GL_MODELVIEW3_ARB\0" - "GL_MODELVIEW4_ARB\0" - "GL_MODELVIEW5_ARB\0" - "GL_MODELVIEW6_ARB\0" - "GL_MODELVIEW7_ARB\0" - "GL_MODELVIEW8_ARB\0" - "GL_MODELVIEW9_ARB\0" - "GL_MODELVIEW_MATRIX\0" - "GL_MODELVIEW_MATRIX_FLOAT_AS_INT_BITS_OES\0" - "GL_MODELVIEW_PROJECTION_NV\0" - "GL_MODELVIEW_STACK_DEPTH\0" - "GL_MODULATE\0" - "GL_MODULATE_ADD_ATI\0" - "GL_MODULATE_SIGNED_ADD_ATI\0" - "GL_MODULATE_SUBTRACT_ATI\0" - "GL_MULT\0" - "GL_MULTISAMPLE\0" - "GL_MULTISAMPLE_3DFX\0" - "GL_MULTISAMPLE_ARB\0" - "GL_MULTISAMPLE_BIT\0" - "GL_MULTISAMPLE_BIT_3DFX\0" - "GL_MULTISAMPLE_BIT_ARB\0" - "GL_MULTISAMPLE_FILTER_HINT_NV\0" - "GL_N3F_V3F\0" - "GL_NAME_STACK_DEPTH\0" - "GL_NAND\0" - "GL_NEAREST\0" - "GL_NEAREST_CLIPMAP_LINEAR_SGIX\0" - "GL_NEAREST_CLIPMAP_NEAREST_SGIX\0" - "GL_NEAREST_MIPMAP_LINEAR\0" - "GL_NEAREST_MIPMAP_NEAREST\0" - "GL_NEVER\0" - "GL_NICEST\0" - "GL_NONE\0" - "GL_NONE_OES\0" - "GL_NOOP\0" - "GL_NOR\0" - "GL_NORMALIZE\0" - "GL_NORMAL_ARRAY\0" - "GL_NORMAL_ARRAY_BUFFER_BINDING\0" - "GL_NORMAL_ARRAY_BUFFER_BINDING_ARB\0" - "GL_NORMAL_ARRAY_POINTER\0" - "GL_NORMAL_ARRAY_STRIDE\0" - "GL_NORMAL_ARRAY_TYPE\0" - "GL_NORMAL_MAP\0" - "GL_NORMAL_MAP_ARB\0" - "GL_NORMAL_MAP_NV\0" - "GL_NORMAL_MAP_OES\0" - "GL_NOTEQUAL\0" - "GL_NO_ERROR\0" - "GL_NO_RESET_NOTIFICATION_ARB\0" - "GL_NUM_COMPRESSED_TEXTURE_FORMATS\0" - "GL_NUM_COMPRESSED_TEXTURE_FORMATS_ARB\0" - "GL_NUM_EXTENSIONS\0" - "GL_NUM_PROGRAM_BINARY_FORMATS\0" - "GL_NUM_PROGRAM_BINARY_FORMATS_OES\0" - "GL_NUM_SHADER_BINARY_FORMATS\0" - "GL_OBJECT_ACTIVE_ATTRIBUTES_ARB\0" - "GL_OBJECT_ACTIVE_ATTRIBUTE_MAX_LENGTH_ARB\0" - "GL_OBJECT_ACTIVE_UNIFORMS_ARB\0" - "GL_OBJECT_ACTIVE_UNIFORM_MAX_LENGTH_ARB\0" - "GL_OBJECT_ATTACHED_OBJECTS_ARB\0" - "GL_OBJECT_COMPILE_STATUS_ARB\0" - "GL_OBJECT_DELETE_STATUS_ARB\0" - "GL_OBJECT_INFO_LOG_LENGTH_ARB\0" - "GL_OBJECT_LINEAR\0" - "GL_OBJECT_LINK_STATUS_ARB\0" - "GL_OBJECT_PLANE\0" - "GL_OBJECT_SHADER_SOURCE_LENGTH_ARB\0" - "GL_OBJECT_SUBTYPE_ARB\0" - "GL_OBJECT_TYPE\0" - "GL_OBJECT_TYPE_ARB\0" - "GL_OBJECT_VALIDATE_STATUS_ARB\0" - "GL_OCCLUSION_TEST_HP\0" - "GL_OCCLUSION_TEST_RESULT_HP\0" - "GL_ONE\0" - "GL_ONE_MINUS_CONSTANT_ALPHA\0" - "GL_ONE_MINUS_CONSTANT_ALPHA_EXT\0" - "GL_ONE_MINUS_CONSTANT_COLOR\0" - "GL_ONE_MINUS_CONSTANT_COLOR_EXT\0" - "GL_ONE_MINUS_DST_ALPHA\0" - "GL_ONE_MINUS_DST_COLOR\0" - "GL_ONE_MINUS_SRC_ALPHA\0" - "GL_ONE_MINUS_SRC_COLOR\0" - "GL_OPERAND0_ALPHA\0" - "GL_OPERAND0_ALPHA_ARB\0" - "GL_OPERAND0_ALPHA_EXT\0" - "GL_OPERAND0_RGB\0" - "GL_OPERAND0_RGB_ARB\0" - "GL_OPERAND0_RGB_EXT\0" - "GL_OPERAND1_ALPHA\0" - "GL_OPERAND1_ALPHA_ARB\0" - "GL_OPERAND1_ALPHA_EXT\0" - "GL_OPERAND1_RGB\0" - "GL_OPERAND1_RGB_ARB\0" - "GL_OPERAND1_RGB_EXT\0" - "GL_OPERAND2_ALPHA\0" - "GL_OPERAND2_ALPHA_ARB\0" - "GL_OPERAND2_ALPHA_EXT\0" - "GL_OPERAND2_RGB\0" - "GL_OPERAND2_RGB_ARB\0" - "GL_OPERAND2_RGB_EXT\0" - "GL_OPERAND3_ALPHA_NV\0" - "GL_OPERAND3_RGB_NV\0" - "GL_OR\0" - "GL_ORDER\0" - "GL_OR_INVERTED\0" - "GL_OR_REVERSE\0" - "GL_OUT_OF_MEMORY\0" - "GL_PACK_ALIGNMENT\0" - "GL_PACK_IMAGE_HEIGHT\0" - "GL_PACK_INVERT_MESA\0" - "GL_PACK_LSB_FIRST\0" - "GL_PACK_ROW_LENGTH\0" - "GL_PACK_SKIP_IMAGES\0" - "GL_PACK_SKIP_PIXELS\0" - "GL_PACK_SKIP_ROWS\0" - "GL_PACK_SWAP_BYTES\0" - "GL_PALETTE4_R5_G6_B5_OES\0" - "GL_PALETTE4_RGB5_A1_OES\0" - "GL_PALETTE4_RGB8_OES\0" - "GL_PALETTE4_RGBA4_OES\0" - "GL_PALETTE4_RGBA8_OES\0" - "GL_PALETTE8_R5_G6_B5_OES\0" - "GL_PALETTE8_RGB5_A1_OES\0" - "GL_PALETTE8_RGB8_OES\0" - "GL_PALETTE8_RGBA4_OES\0" - "GL_PALETTE8_RGBA8_OES\0" - "GL_PASS_THROUGH_TOKEN\0" - "GL_PERSPECTIVE_CORRECTION_HINT\0" - "GL_PIXEL_MAP_A_TO_A\0" - "GL_PIXEL_MAP_A_TO_A_SIZE\0" - "GL_PIXEL_MAP_B_TO_B\0" - "GL_PIXEL_MAP_B_TO_B_SIZE\0" - "GL_PIXEL_MAP_G_TO_G\0" - "GL_PIXEL_MAP_G_TO_G_SIZE\0" - "GL_PIXEL_MAP_I_TO_A\0" - "GL_PIXEL_MAP_I_TO_A_SIZE\0" - "GL_PIXEL_MAP_I_TO_B\0" - "GL_PIXEL_MAP_I_TO_B_SIZE\0" - "GL_PIXEL_MAP_I_TO_G\0" - "GL_PIXEL_MAP_I_TO_G_SIZE\0" - "GL_PIXEL_MAP_I_TO_I\0" - "GL_PIXEL_MAP_I_TO_I_SIZE\0" - "GL_PIXEL_MAP_I_TO_R\0" - "GL_PIXEL_MAP_I_TO_R_SIZE\0" - "GL_PIXEL_MAP_R_TO_R\0" - "GL_PIXEL_MAP_R_TO_R_SIZE\0" - "GL_PIXEL_MAP_S_TO_S\0" - "GL_PIXEL_MAP_S_TO_S_SIZE\0" - "GL_PIXEL_MODE_BIT\0" - "GL_PIXEL_PACK_BUFFER\0" - "GL_PIXEL_PACK_BUFFER_BINDING\0" - "GL_PIXEL_PACK_BUFFER_BINDING_EXT\0" - "GL_PIXEL_PACK_BUFFER_EXT\0" - "GL_PIXEL_UNPACK_BUFFER\0" - "GL_PIXEL_UNPACK_BUFFER_BINDING\0" - "GL_PIXEL_UNPACK_BUFFER_BINDING_EXT\0" - "GL_PIXEL_UNPACK_BUFFER_EXT\0" - "GL_POINT\0" - "GL_POINTS\0" - "GL_POINT_BIT\0" - "GL_POINT_DISTANCE_ATTENUATION\0" - "GL_POINT_DISTANCE_ATTENUATION_ARB\0" - "GL_POINT_DISTANCE_ATTENUATION_EXT\0" - "GL_POINT_DISTANCE_ATTENUATION_SGIS\0" - "GL_POINT_FADE_THRESHOLD_SIZE\0" - "GL_POINT_FADE_THRESHOLD_SIZE_ARB\0" - "GL_POINT_FADE_THRESHOLD_SIZE_EXT\0" - "GL_POINT_FADE_THRESHOLD_SIZE_SGIS\0" - "GL_POINT_SIZE\0" - "GL_POINT_SIZE_ARRAY_BUFFER_BINDING_OES\0" - "GL_POINT_SIZE_ARRAY_OES\0" - "GL_POINT_SIZE_ARRAY_POINTER_OES\0" - "GL_POINT_SIZE_ARRAY_STRIDE_OES\0" - "GL_POINT_SIZE_ARRAY_TYPE_OES\0" - "GL_POINT_SIZE_GRANULARITY\0" - "GL_POINT_SIZE_MAX\0" - "GL_POINT_SIZE_MAX_ARB\0" - "GL_POINT_SIZE_MAX_EXT\0" - "GL_POINT_SIZE_MAX_SGIS\0" - "GL_POINT_SIZE_MIN\0" - "GL_POINT_SIZE_MIN_ARB\0" - "GL_POINT_SIZE_MIN_EXT\0" - "GL_POINT_SIZE_MIN_SGIS\0" - "GL_POINT_SIZE_RANGE\0" - "GL_POINT_SMOOTH\0" - "GL_POINT_SMOOTH_HINT\0" - "GL_POINT_SPRITE\0" - "GL_POINT_SPRITE_ARB\0" - "GL_POINT_SPRITE_COORD_ORIGIN\0" - "GL_POINT_SPRITE_NV\0" - "GL_POINT_SPRITE_OES\0" - "GL_POINT_SPRITE_R_MODE_NV\0" - "GL_POINT_TOKEN\0" - "GL_POLYGON\0" - "GL_POLYGON_BIT\0" - "GL_POLYGON_MODE\0" - "GL_POLYGON_OFFSET_BIAS\0" - "GL_POLYGON_OFFSET_FACTOR\0" - "GL_POLYGON_OFFSET_FILL\0" - "GL_POLYGON_OFFSET_LINE\0" - "GL_POLYGON_OFFSET_POINT\0" - "GL_POLYGON_OFFSET_UNITS\0" - "GL_POLYGON_SMOOTH\0" - "GL_POLYGON_SMOOTH_HINT\0" - "GL_POLYGON_STIPPLE\0" - "GL_POLYGON_STIPPLE_BIT\0" - "GL_POLYGON_TOKEN\0" - "GL_POSITION\0" - "GL_POST_COLOR_MATRIX_ALPHA_BIAS\0" - "GL_POST_COLOR_MATRIX_ALPHA_BIAS_SGI\0" - "GL_POST_COLOR_MATRIX_ALPHA_SCALE\0" - "GL_POST_COLOR_MATRIX_ALPHA_SCALE_SGI\0" - "GL_POST_COLOR_MATRIX_BLUE_BIAS\0" - "GL_POST_COLOR_MATRIX_BLUE_BIAS_SGI\0" - "GL_POST_COLOR_MATRIX_BLUE_SCALE\0" - "GL_POST_COLOR_MATRIX_BLUE_SCALE_SGI\0" - "GL_POST_COLOR_MATRIX_COLOR_TABLE\0" - "GL_POST_COLOR_MATRIX_GREEN_BIAS\0" - "GL_POST_COLOR_MATRIX_GREEN_BIAS_SGI\0" - "GL_POST_COLOR_MATRIX_GREEN_SCALE\0" - "GL_POST_COLOR_MATRIX_GREEN_SCALE_SGI\0" - "GL_POST_COLOR_MATRIX_RED_BIAS\0" - "GL_POST_COLOR_MATRIX_RED_BIAS_SGI\0" - "GL_POST_COLOR_MATRIX_RED_SCALE\0" - "GL_POST_COLOR_MATRIX_RED_SCALE_SGI\0" - "GL_POST_CONVOLUTION_ALPHA_BIAS\0" - "GL_POST_CONVOLUTION_ALPHA_BIAS_EXT\0" - "GL_POST_CONVOLUTION_ALPHA_SCALE\0" - "GL_POST_CONVOLUTION_ALPHA_SCALE_EXT\0" - "GL_POST_CONVOLUTION_BLUE_BIAS\0" - "GL_POST_CONVOLUTION_BLUE_BIAS_EXT\0" - "GL_POST_CONVOLUTION_BLUE_SCALE\0" - "GL_POST_CONVOLUTION_BLUE_SCALE_EXT\0" - "GL_POST_CONVOLUTION_COLOR_TABLE\0" - "GL_POST_CONVOLUTION_GREEN_BIAS\0" - "GL_POST_CONVOLUTION_GREEN_BIAS_EXT\0" - "GL_POST_CONVOLUTION_GREEN_SCALE\0" - "GL_POST_CONVOLUTION_GREEN_SCALE_EXT\0" - "GL_POST_CONVOLUTION_RED_BIAS\0" - "GL_POST_CONVOLUTION_RED_BIAS_EXT\0" - "GL_POST_CONVOLUTION_RED_SCALE\0" - "GL_POST_CONVOLUTION_RED_SCALE_EXT\0" - "GL_POST_TEXTURE_FILTER_BIAS_RANGE_SGIX\0" - "GL_POST_TEXTURE_FILTER_BIAS_SGIX\0" - "GL_POST_TEXTURE_FILTER_SCALE_RANGE_SGIX\0" - "GL_POST_TEXTURE_FILTER_SCALE_SGIX\0" - "GL_PREVIOUS\0" - "GL_PREVIOUS_ARB\0" - "GL_PREVIOUS_EXT\0" - "GL_PRIMARY_COLOR\0" - "GL_PRIMARY_COLOR_ARB\0" - "GL_PRIMARY_COLOR_EXT\0" - "GL_PRIMITIVES_GENERATED\0" - "GL_PRIMITIVES_GENERATED_EXT\0" - "GL_PRIMITIVE_RESTART\0" - "GL_PRIMITIVE_RESTART_INDEX\0" - "GL_PRIMITIVE_RESTART_INDEX_NV\0" - "GL_PRIMITIVE_RESTART_NV\0" - "GL_PROGRAM_ADDRESS_REGISTERS_ARB\0" - "GL_PROGRAM_ALU_INSTRUCTIONS_ARB\0" - "GL_PROGRAM_ATTRIBS_ARB\0" - "GL_PROGRAM_BINARY_FORMATS\0" - "GL_PROGRAM_BINARY_FORMATS_OES\0" - "GL_PROGRAM_BINARY_LENGTH\0" - "GL_PROGRAM_BINARY_LENGTH_OES\0" - "GL_PROGRAM_BINARY_RETRIEVABLE_HINT\0" - "GL_PROGRAM_BINDING_ARB\0" - "GL_PROGRAM_ERROR_POSITION_ARB\0" - "GL_PROGRAM_ERROR_POSITION_NV\0" - "GL_PROGRAM_ERROR_STRING_ARB\0" - "GL_PROGRAM_FORMAT_ARB\0" - "GL_PROGRAM_FORMAT_ASCII_ARB\0" - "GL_PROGRAM_INSTRUCTIONS_ARB\0" - "GL_PROGRAM_LENGTH_ARB\0" - "GL_PROGRAM_LENGTH_NV\0" - "GL_PROGRAM_NATIVE_ADDRESS_REGISTERS_ARB\0" - "GL_PROGRAM_NATIVE_ALU_INSTRUCTIONS_ARB\0" - "GL_PROGRAM_NATIVE_ATTRIBS_ARB\0" - "GL_PROGRAM_NATIVE_INSTRUCTIONS_ARB\0" - "GL_PROGRAM_NATIVE_PARAMETERS_ARB\0" - "GL_PROGRAM_NATIVE_TEMPORARIES_ARB\0" - "GL_PROGRAM_NATIVE_TEX_INDIRECTIONS_ARB\0" - "GL_PROGRAM_NATIVE_TEX_INSTRUCTIONS_ARB\0" - "GL_PROGRAM_OBJECT_ARB\0" - "GL_PROGRAM_PARAMETERS_ARB\0" - "GL_PROGRAM_PARAMETER_NV\0" - "GL_PROGRAM_POINT_SIZE\0" - "GL_PROGRAM_POINT_SIZE_ARB\0" - "GL_PROGRAM_RESIDENT_NV\0" - "GL_PROGRAM_STRING_ARB\0" - "GL_PROGRAM_STRING_NV\0" - "GL_PROGRAM_TARGET_NV\0" - "GL_PROGRAM_TEMPORARIES_ARB\0" - "GL_PROGRAM_TEX_INDIRECTIONS_ARB\0" - "GL_PROGRAM_TEX_INSTRUCTIONS_ARB\0" - "GL_PROGRAM_UNDER_NATIVE_LIMITS_ARB\0" - "GL_PROJECTION\0" - "GL_PROJECTION_MATRIX\0" - "GL_PROJECTION_MATRIX_FLOAT_AS_INT_BITS_OES\0" - "GL_PROJECTION_STACK_DEPTH\0" - "GL_PROVOKING_VERTEX\0" - "GL_PROVOKING_VERTEX_EXT\0" - "GL_PROXY_COLOR_TABLE\0" - "GL_PROXY_HISTOGRAM\0" - "GL_PROXY_HISTOGRAM_EXT\0" - "GL_PROXY_POST_COLOR_MATRIX_COLOR_TABLE\0" - "GL_PROXY_POST_CONVOLUTION_COLOR_TABLE\0" - "GL_PROXY_TEXTURE_1D\0" - "GL_PROXY_TEXTURE_1D_ARRAY\0" - "GL_PROXY_TEXTURE_1D_ARRAY_EXT\0" - "GL_PROXY_TEXTURE_1D_EXT\0" - "GL_PROXY_TEXTURE_2D\0" - "GL_PROXY_TEXTURE_2D_ARRAY\0" - "GL_PROXY_TEXTURE_2D_ARRAY_EXT\0" - "GL_PROXY_TEXTURE_2D_EXT\0" - "GL_PROXY_TEXTURE_3D\0" - "GL_PROXY_TEXTURE_COLOR_TABLE_SGI\0" - "GL_PROXY_TEXTURE_CUBE_MAP\0" - "GL_PROXY_TEXTURE_CUBE_MAP_ARB\0" - "GL_PROXY_TEXTURE_RECTANGLE\0" - "GL_PROXY_TEXTURE_RECTANGLE_ARB\0" - "GL_PROXY_TEXTURE_RECTANGLE_NV\0" - "GL_PURGEABLE_APPLE\0" - "GL_Q\0" - "GL_QUADRATIC_ATTENUATION\0" - "GL_QUADS\0" - "GL_QUADS_FOLLOW_PROVOKING_VERTEX_CONVENTION\0" - "GL_QUADS_FOLLOW_PROVOKING_VERTEX_CONVENTION_EXT\0" - "GL_QUAD_MESH_SUN\0" - "GL_QUAD_STRIP\0" - "GL_QUERY_BY_REGION_NO_WAIT\0" - "GL_QUERY_BY_REGION_NO_WAIT_NV\0" - "GL_QUERY_BY_REGION_WAIT\0" - "GL_QUERY_BY_REGION_WAIT_NV\0" - "GL_QUERY_COUNTER_BITS\0" - "GL_QUERY_COUNTER_BITS_ARB\0" - "GL_QUERY_NO_WAIT\0" - "GL_QUERY_NO_WAIT_NV\0" - "GL_QUERY_RESULT\0" - "GL_QUERY_RESULT_ARB\0" - "GL_QUERY_RESULT_AVAILABLE\0" - "GL_QUERY_RESULT_AVAILABLE_ARB\0" - "GL_QUERY_WAIT\0" - "GL_QUERY_WAIT_NV\0" - "GL_R\0" - "GL_R11F_G11F_B10F\0" - "GL_R16_SNORM\0" - "GL_R3_G3_B2\0" - "GL_R8_SNORM\0" - "GL_RASTERIZER_DISCARD\0" - "GL_RASTERIZER_DISCARD_EXT\0" - "GL_RASTER_POSITION_UNCLIPPED_IBM\0" - "GL_READ_BUFFER\0" - "GL_READ_FRAMEBUFFER\0" - "GL_READ_FRAMEBUFFER_BINDING\0" - "GL_READ_FRAMEBUFFER_BINDING_EXT\0" - "GL_READ_FRAMEBUFFER_EXT\0" - "GL_READ_ONLY\0" - "GL_READ_ONLY_ARB\0" - "GL_READ_WRITE\0" - "GL_READ_WRITE_ARB\0" - "GL_RED\0" - "GL_REDUCE\0" - "GL_REDUCE_EXT\0" - "GL_RED_BIAS\0" - "GL_RED_BITS\0" - "GL_RED_INTEGER\0" - "GL_RED_INTEGER_EXT\0" - "GL_RED_SCALE\0" - "GL_RED_SNORM\0" - "GL_REFLECTION_MAP\0" - "GL_REFLECTION_MAP_ARB\0" - "GL_REFLECTION_MAP_NV\0" - "GL_REFLECTION_MAP_OES\0" - "GL_RELEASED_APPLE\0" - "GL_RENDER\0" - "GL_RENDERBUFFER\0" - "GL_RENDERBUFFER_ALPHA_SIZE\0" - "GL_RENDERBUFFER_ALPHA_SIZE_OES\0" - "GL_RENDERBUFFER_BINDING\0" - "GL_RENDERBUFFER_BINDING_EXT\0" - "GL_RENDERBUFFER_BINDING_OES\0" - "GL_RENDERBUFFER_BLUE_SIZE\0" - "GL_RENDERBUFFER_BLUE_SIZE_OES\0" - "GL_RENDERBUFFER_DEPTH_SIZE\0" - "GL_RENDERBUFFER_DEPTH_SIZE_OES\0" - "GL_RENDERBUFFER_EXT\0" - "GL_RENDERBUFFER_GREEN_SIZE\0" - "GL_RENDERBUFFER_GREEN_SIZE_OES\0" - "GL_RENDERBUFFER_HEIGHT\0" - "GL_RENDERBUFFER_HEIGHT_EXT\0" - "GL_RENDERBUFFER_HEIGHT_OES\0" - "GL_RENDERBUFFER_INTERNAL_FORMAT\0" - "GL_RENDERBUFFER_INTERNAL_FORMAT_EXT\0" - "GL_RENDERBUFFER_INTERNAL_FORMAT_OES\0" - "GL_RENDERBUFFER_OES\0" - "GL_RENDERBUFFER_RED_SIZE\0" - "GL_RENDERBUFFER_RED_SIZE_OES\0" - "GL_RENDERBUFFER_SAMPLES\0" - "GL_RENDERBUFFER_SAMPLES_EXT\0" - "GL_RENDERBUFFER_STENCIL_SIZE\0" - "GL_RENDERBUFFER_STENCIL_SIZE_OES\0" - "GL_RENDERBUFFER_WIDTH\0" - "GL_RENDERBUFFER_WIDTH_EXT\0" - "GL_RENDERBUFFER_WIDTH_OES\0" - "GL_RENDERER\0" - "GL_RENDER_MODE\0" - "GL_REPEAT\0" - "GL_REPLACE\0" - "GL_REPLACE_EXT\0" - "GL_REPLICATE_BORDER_HP\0" - "GL_REQUIRED_TEXTURE_IMAGE_UNITS_OES\0" - "GL_RESCALE_NORMAL\0" - "GL_RESCALE_NORMAL_EXT\0" - "GL_RESET_NOTIFICATION_STRATEGY_ARB\0" - "GL_RETAINED_APPLE\0" - "GL_RETURN\0" - "GL_RG16_SNORM\0" - "GL_RG8_SNORM\0" - "GL_RGB\0" - "GL_RGB10\0" - "GL_RGB10_A2\0" - "GL_RGB10_A2UI\0" - "GL_RGB10_A2_EXT\0" - "GL_RGB10_EXT\0" - "GL_RGB12\0" - "GL_RGB12_EXT\0" - "GL_RGB16\0" - "GL_RGB16F\0" - "GL_RGB16I\0" - "GL_RGB16I_EXT\0" - "GL_RGB16UI\0" - "GL_RGB16UI_EXT\0" - "GL_RGB16_EXT\0" - "GL_RGB16_SNORM\0" - "GL_RGB2_EXT\0" - "GL_RGB32F\0" - "GL_RGB32I\0" - "GL_RGB32I_EXT\0" - "GL_RGB32UI\0" - "GL_RGB32UI_EXT\0" - "GL_RGB4\0" - "GL_RGB4_EXT\0" - "GL_RGB4_S3TC\0" - "GL_RGB5\0" - "GL_RGB565\0" - "GL_RGB565_OES\0" - "GL_RGB5_A1\0" - "GL_RGB5_A1_EXT\0" - "GL_RGB5_A1_OES\0" - "GL_RGB5_EXT\0" - "GL_RGB8\0" - "GL_RGB8I\0" - "GL_RGB8I_EXT\0" - "GL_RGB8UI\0" - "GL_RGB8UI_EXT\0" - "GL_RGB8_EXT\0" - "GL_RGB8_OES\0" - "GL_RGB8_SNORM\0" - "GL_RGB9_E5\0" - "GL_RGBA\0" - "GL_RGBA12\0" - "GL_RGBA12_EXT\0" - "GL_RGBA16\0" - "GL_RGBA16F\0" - "GL_RGBA16I\0" - "GL_RGBA16I_EXT\0" - "GL_RGBA16UI\0" - "GL_RGBA16UI_EXT\0" - "GL_RGBA16_EXT\0" - "GL_RGBA16_SNORM\0" - "GL_RGBA2\0" - "GL_RGBA2_EXT\0" - "GL_RGBA32F\0" - "GL_RGBA32I\0" - "GL_RGBA32I_EXT\0" - "GL_RGBA32UI\0" - "GL_RGBA32UI_EXT\0" - "GL_RGBA4\0" - "GL_RGBA4_DXT5_S3TC\0" - "GL_RGBA4_EXT\0" - "GL_RGBA4_OES\0" - "GL_RGBA4_S3TC\0" - "GL_RGBA8\0" - "GL_RGBA8I\0" - "GL_RGBA8I_EXT\0" - "GL_RGBA8UI\0" - "GL_RGBA8UI_EXT\0" - "GL_RGBA8_EXT\0" - "GL_RGBA8_OES\0" - "GL_RGBA8_SNORM\0" - "GL_RGBA_DXT5_S3TC\0" - "GL_RGBA_FLOAT_MODE_ARB\0" - "GL_RGBA_INTEGER\0" - "GL_RGBA_INTEGER_EXT\0" - "GL_RGBA_INTEGER_MODE_EXT\0" - "GL_RGBA_MODE\0" - "GL_RGBA_S3TC\0" - "GL_RGBA_SNORM\0" - "GL_RGB_INTEGER\0" - "GL_RGB_INTEGER_EXT\0" - "GL_RGB_S3TC\0" - "GL_RGB_SCALE\0" - "GL_RGB_SCALE_ARB\0" - "GL_RGB_SCALE_EXT\0" - "GL_RGB_SNORM\0" - "GL_RG_SNORM\0" - "GL_RIGHT\0" - "GL_S\0" - "GL_SAMPLER_1D\0" - "GL_SAMPLER_1D_ARRAY\0" - "GL_SAMPLER_1D_ARRAY_EXT\0" - "GL_SAMPLER_1D_ARRAY_SHADOW\0" - "GL_SAMPLER_1D_ARRAY_SHADOW_EXT\0" - "GL_SAMPLER_1D_SHADOW\0" - "GL_SAMPLER_2D\0" - "GL_SAMPLER_2D_ARRAY\0" - "GL_SAMPLER_2D_ARRAY_EXT\0" - "GL_SAMPLER_2D_ARRAY_SHADOW\0" - "GL_SAMPLER_2D_ARRAY_SHADOW_EXT\0" - "GL_SAMPLER_2D_RECT\0" - "GL_SAMPLER_2D_RECT_SHADOW\0" - "GL_SAMPLER_2D_SHADOW\0" - "GL_SAMPLER_3D\0" - "GL_SAMPLER_3D_OES\0" - "GL_SAMPLER_BINDING\0" - "GL_SAMPLER_BUFFER\0" - "GL_SAMPLER_BUFFER_EXT\0" - "GL_SAMPLER_CUBE\0" - "GL_SAMPLER_CUBE_SHADOW\0" - "GL_SAMPLER_CUBE_SHADOW_EXT\0" - "GL_SAMPLER_EXTERNAL_OES\0" - "GL_SAMPLES\0" - "GL_SAMPLES_3DFX\0" - "GL_SAMPLES_ARB\0" - "GL_SAMPLES_PASSED\0" - "GL_SAMPLES_PASSED_ARB\0" - "GL_SAMPLE_ALPHA_TO_COVERAGE\0" - "GL_SAMPLE_ALPHA_TO_COVERAGE_ARB\0" - "GL_SAMPLE_ALPHA_TO_ONE\0" - "GL_SAMPLE_ALPHA_TO_ONE_ARB\0" - "GL_SAMPLE_BUFFERS\0" - "GL_SAMPLE_BUFFERS_3DFX\0" - "GL_SAMPLE_BUFFERS_ARB\0" - "GL_SAMPLE_COVERAGE\0" - "GL_SAMPLE_COVERAGE_ARB\0" - "GL_SAMPLE_COVERAGE_INVERT\0" - "GL_SAMPLE_COVERAGE_INVERT_ARB\0" - "GL_SAMPLE_COVERAGE_VALUE\0" - "GL_SAMPLE_COVERAGE_VALUE_ARB\0" - "GL_SCISSOR_BIT\0" - "GL_SCISSOR_BOX\0" - "GL_SCISSOR_TEST\0" - "GL_SECONDARY_COLOR_ARRAY\0" - "GL_SECONDARY_COLOR_ARRAY_BUFFER_BINDING\0" - "GL_SECONDARY_COLOR_ARRAY_BUFFER_BINDING_ARB\0" - "GL_SECONDARY_COLOR_ARRAY_POINTER\0" - "GL_SECONDARY_COLOR_ARRAY_SIZE\0" - "GL_SECONDARY_COLOR_ARRAY_STRIDE\0" - "GL_SECONDARY_COLOR_ARRAY_TYPE\0" - "GL_SELECT\0" - "GL_SELECTION_BUFFER_POINTER\0" - "GL_SELECTION_BUFFER_SIZE\0" - "GL_SEPARABLE_2D\0" - "GL_SEPARATE_ATTRIBS\0" - "GL_SEPARATE_ATTRIBS_EXT\0" - "GL_SEPARATE_SPECULAR_COLOR\0" - "GL_SEPARATE_SPECULAR_COLOR_EXT\0" - "GL_SET\0" - "GL_SHADER_BINARY_FORMATS\0" - "GL_SHADER_COMPILER\0" - "GL_SHADER_OBJECT_ARB\0" - "GL_SHADER_SOURCE_LENGTH\0" - "GL_SHADER_TYPE\0" - "GL_SHADE_MODEL\0" - "GL_SHADING_LANGUAGE_VERSION\0" - "GL_SHADOW_AMBIENT_SGIX\0" - "GL_SHARED_TEXTURE_PALETTE_EXT\0" - "GL_SHININESS\0" - "GL_SHORT\0" - "GL_SIGNALED\0" - "GL_SIGNED_NORMALIZED\0" - "GL_SINGLE_COLOR\0" - "GL_SINGLE_COLOR_EXT\0" - "GL_SLICE_ACCUM_SUN\0" - "GL_SLUMINANCE\0" - "GL_SLUMINANCE8\0" - "GL_SLUMINANCE8_ALPHA8\0" - "GL_SLUMINANCE_ALPHA\0" - "GL_SMOOTH\0" - "GL_SMOOTH_LINE_WIDTH_GRANULARITY\0" - "GL_SMOOTH_LINE_WIDTH_RANGE\0" - "GL_SMOOTH_POINT_SIZE_GRANULARITY\0" - "GL_SMOOTH_POINT_SIZE_RANGE\0" - "GL_SOURCE0_ALPHA\0" - "GL_SOURCE0_ALPHA_ARB\0" - "GL_SOURCE0_ALPHA_EXT\0" - "GL_SOURCE0_RGB\0" - "GL_SOURCE0_RGB_ARB\0" - "GL_SOURCE0_RGB_EXT\0" - "GL_SOURCE1_ALPHA\0" - "GL_SOURCE1_ALPHA_ARB\0" - "GL_SOURCE1_ALPHA_EXT\0" - "GL_SOURCE1_RGB\0" - "GL_SOURCE1_RGB_ARB\0" - "GL_SOURCE1_RGB_EXT\0" - "GL_SOURCE2_ALPHA\0" - "GL_SOURCE2_ALPHA_ARB\0" - "GL_SOURCE2_ALPHA_EXT\0" - "GL_SOURCE2_RGB\0" - "GL_SOURCE2_RGB_ARB\0" - "GL_SOURCE2_RGB_EXT\0" - "GL_SOURCE3_ALPHA_NV\0" - "GL_SOURCE3_RGB_NV\0" - "GL_SPECULAR\0" - "GL_SPHERE_MAP\0" - "GL_SPOT_CUTOFF\0" - "GL_SPOT_DIRECTION\0" - "GL_SPOT_EXPONENT\0" - "GL_SRC0_ALPHA\0" - "GL_SRC0_RGB\0" - "GL_SRC1_ALPHA\0" - "GL_SRC1_RGB\0" - "GL_SRC2_ALPHA\0" - "GL_SRC2_RGB\0" - "GL_SRC_ALPHA\0" - "GL_SRC_ALPHA_SATURATE\0" - "GL_SRC_COLOR\0" - "GL_SRGB\0" - "GL_SRGB8\0" - "GL_SRGB8_ALPHA8\0" - "GL_SRGB_ALPHA\0" - "GL_STACK_OVERFLOW\0" - "GL_STACK_UNDERFLOW\0" - "GL_STATIC_COPY\0" - "GL_STATIC_COPY_ARB\0" - "GL_STATIC_DRAW\0" - "GL_STATIC_DRAW_ARB\0" - "GL_STATIC_READ\0" - "GL_STATIC_READ_ARB\0" - "GL_STENCIL\0" - "GL_STENCIL_ATTACHMENT\0" - "GL_STENCIL_ATTACHMENT_EXT\0" - "GL_STENCIL_ATTACHMENT_OES\0" - "GL_STENCIL_BACK_FAIL\0" - "GL_STENCIL_BACK_FAIL_ATI\0" - "GL_STENCIL_BACK_FUNC\0" - "GL_STENCIL_BACK_FUNC_ATI\0" - "GL_STENCIL_BACK_PASS_DEPTH_FAIL\0" - "GL_STENCIL_BACK_PASS_DEPTH_FAIL_ATI\0" - "GL_STENCIL_BACK_PASS_DEPTH_PASS\0" - "GL_STENCIL_BACK_PASS_DEPTH_PASS_ATI\0" - "GL_STENCIL_BACK_REF\0" - "GL_STENCIL_BACK_VALUE_MASK\0" - "GL_STENCIL_BACK_WRITEMASK\0" - "GL_STENCIL_BITS\0" - "GL_STENCIL_BUFFER\0" - "GL_STENCIL_BUFFER_BIT\0" - "GL_STENCIL_CLEAR_VALUE\0" - "GL_STENCIL_FAIL\0" - "GL_STENCIL_FUNC\0" - "GL_STENCIL_INDEX\0" - "GL_STENCIL_INDEX1\0" - "GL_STENCIL_INDEX16\0" - "GL_STENCIL_INDEX16_EXT\0" - "GL_STENCIL_INDEX1_EXT\0" - "GL_STENCIL_INDEX1_OES\0" - "GL_STENCIL_INDEX4\0" - "GL_STENCIL_INDEX4_EXT\0" - "GL_STENCIL_INDEX4_OES\0" - "GL_STENCIL_INDEX8\0" - "GL_STENCIL_INDEX8_EXT\0" - "GL_STENCIL_INDEX8_OES\0" - "GL_STENCIL_INDEX_EXT\0" - "GL_STENCIL_PASS_DEPTH_FAIL\0" - "GL_STENCIL_PASS_DEPTH_PASS\0" - "GL_STENCIL_REF\0" - "GL_STENCIL_TEST\0" - "GL_STENCIL_TEST_TWO_SIDE_EXT\0" - "GL_STENCIL_VALUE_MASK\0" - "GL_STENCIL_WRITEMASK\0" - "GL_STEREO\0" - "GL_STORAGE_CACHED_APPLE\0" - "GL_STORAGE_PRIVATE_APPLE\0" - "GL_STORAGE_SHARED_APPLE\0" - "GL_STREAM_COPY\0" - "GL_STREAM_COPY_ARB\0" - "GL_STREAM_DRAW\0" - "GL_STREAM_DRAW_ARB\0" - "GL_STREAM_READ\0" - "GL_STREAM_READ_ARB\0" - "GL_SUBPIXEL_BITS\0" - "GL_SUBTRACT\0" - "GL_SUBTRACT_ARB\0" - "GL_SYNC_CONDITION\0" - "GL_SYNC_FENCE\0" - "GL_SYNC_FLAGS\0" - "GL_SYNC_FLUSH_COMMANDS_BIT\0" - "GL_SYNC_GPU_COMMANDS_COMPLETE\0" - "GL_SYNC_STATUS\0" - "GL_T\0" - "GL_T2F_C3F_V3F\0" - "GL_T2F_C4F_N3F_V3F\0" - "GL_T2F_C4UB_V3F\0" - "GL_T2F_N3F_V3F\0" - "GL_T2F_V3F\0" - "GL_T4F_C4F_N3F_V4F\0" - "GL_T4F_V4F\0" - "GL_TABLE_TOO_LARGE_EXT\0" - "GL_TEXTURE\0" - "GL_TEXTURE0\0" - "GL_TEXTURE0_ARB\0" - "GL_TEXTURE1\0" - "GL_TEXTURE10\0" - "GL_TEXTURE10_ARB\0" - "GL_TEXTURE11\0" - "GL_TEXTURE11_ARB\0" - "GL_TEXTURE12\0" - "GL_TEXTURE12_ARB\0" - "GL_TEXTURE13\0" - "GL_TEXTURE13_ARB\0" - "GL_TEXTURE14\0" - "GL_TEXTURE14_ARB\0" - "GL_TEXTURE15\0" - "GL_TEXTURE15_ARB\0" - "GL_TEXTURE16\0" - "GL_TEXTURE16_ARB\0" - "GL_TEXTURE17\0" - "GL_TEXTURE17_ARB\0" - "GL_TEXTURE18\0" - "GL_TEXTURE18_ARB\0" - "GL_TEXTURE19\0" - "GL_TEXTURE19_ARB\0" - "GL_TEXTURE1_ARB\0" - "GL_TEXTURE2\0" - "GL_TEXTURE20\0" - "GL_TEXTURE20_ARB\0" - "GL_TEXTURE21\0" - "GL_TEXTURE21_ARB\0" - "GL_TEXTURE22\0" - "GL_TEXTURE22_ARB\0" - "GL_TEXTURE23\0" - "GL_TEXTURE23_ARB\0" - "GL_TEXTURE24\0" - "GL_TEXTURE24_ARB\0" - "GL_TEXTURE25\0" - "GL_TEXTURE25_ARB\0" - "GL_TEXTURE26\0" - "GL_TEXTURE26_ARB\0" - "GL_TEXTURE27\0" - "GL_TEXTURE27_ARB\0" - "GL_TEXTURE28\0" - "GL_TEXTURE28_ARB\0" - "GL_TEXTURE29\0" - "GL_TEXTURE29_ARB\0" - "GL_TEXTURE2_ARB\0" - "GL_TEXTURE3\0" - "GL_TEXTURE30\0" - "GL_TEXTURE30_ARB\0" - "GL_TEXTURE31\0" - "GL_TEXTURE31_ARB\0" - "GL_TEXTURE3_ARB\0" - "GL_TEXTURE4\0" - "GL_TEXTURE4_ARB\0" - "GL_TEXTURE5\0" - "GL_TEXTURE5_ARB\0" - "GL_TEXTURE6\0" - "GL_TEXTURE6_ARB\0" - "GL_TEXTURE7\0" - "GL_TEXTURE7_ARB\0" - "GL_TEXTURE8\0" - "GL_TEXTURE8_ARB\0" - "GL_TEXTURE9\0" - "GL_TEXTURE9_ARB\0" - "GL_TEXTURE_1D\0" - "GL_TEXTURE_1D_ARRAY\0" - "GL_TEXTURE_1D_ARRAY_EXT\0" - "GL_TEXTURE_2D\0" - "GL_TEXTURE_2D_ARRAY\0" - "GL_TEXTURE_2D_ARRAY_EXT\0" - "GL_TEXTURE_3D\0" - "GL_TEXTURE_3D_OES\0" - "GL_TEXTURE_ALPHA_SIZE\0" - "GL_TEXTURE_ALPHA_SIZE_EXT\0" - "GL_TEXTURE_BASE_LEVEL\0" - "GL_TEXTURE_BINDING_1D\0" - "GL_TEXTURE_BINDING_1D_ARRAY\0" - "GL_TEXTURE_BINDING_1D_ARRAY_EXT\0" - "GL_TEXTURE_BINDING_2D\0" - "GL_TEXTURE_BINDING_2D_ARRAY\0" - "GL_TEXTURE_BINDING_2D_ARRAY_EXT\0" - "GL_TEXTURE_BINDING_3D\0" - "GL_TEXTURE_BINDING_3D_OES\0" - "GL_TEXTURE_BINDING_BUFFER\0" - "GL_TEXTURE_BINDING_BUFFER_ARB\0" - "GL_TEXTURE_BINDING_CUBE_MAP\0" - "GL_TEXTURE_BINDING_CUBE_MAP_ARB\0" - "GL_TEXTURE_BINDING_CUBE_MAP_OES\0" - "GL_TEXTURE_BINDING_EXTERNAL_OES\0" - "GL_TEXTURE_BINDING_RECTANGLE\0" - "GL_TEXTURE_BINDING_RECTANGLE_ARB\0" - "GL_TEXTURE_BINDING_RECTANGLE_NV\0" - "GL_TEXTURE_BIT\0" - "GL_TEXTURE_BLUE_SIZE\0" - "GL_TEXTURE_BLUE_SIZE_EXT\0" - "GL_TEXTURE_BORDER\0" - "GL_TEXTURE_BORDER_COLOR\0" - "GL_TEXTURE_BUFFER\0" - "GL_TEXTURE_BUFFER_ARB\0" - "GL_TEXTURE_BUFFER_DATA_STORE_BINDING\0" - "GL_TEXTURE_BUFFER_DATA_STORE_BINDING_ARB\0" - "GL_TEXTURE_BUFFER_FORMAT\0" - "GL_TEXTURE_BUFFER_FORMAT_ARB\0" - "GL_TEXTURE_CLIPMAP_CENTER_SGIX\0" - "GL_TEXTURE_CLIPMAP_DEPTH_SGIX\0" - "GL_TEXTURE_CLIPMAP_FRAME_SGIX\0" - "GL_TEXTURE_CLIPMAP_LOD_OFFSET_SGIX\0" - "GL_TEXTURE_CLIPMAP_OFFSET_SGIX\0" - "GL_TEXTURE_CLIPMAP_VIRTUAL_DEPTH_SGIX\0" - "GL_TEXTURE_COLOR_TABLE_SGI\0" - "GL_TEXTURE_COLOR_WRITEMASK_SGIS\0" - "GL_TEXTURE_COMPARE_FAIL_VALUE_ARB\0" - "GL_TEXTURE_COMPARE_FUNC\0" - "GL_TEXTURE_COMPARE_FUNC_ARB\0" - "GL_TEXTURE_COMPARE_MODE\0" - "GL_TEXTURE_COMPARE_MODE_ARB\0" - "GL_TEXTURE_COMPARE_OPERATOR_SGIX\0" - "GL_TEXTURE_COMPARE_SGIX\0" - "GL_TEXTURE_COMPONENTS\0" - "GL_TEXTURE_COMPRESSED\0" - "GL_TEXTURE_COMPRESSED_ARB\0" - "GL_TEXTURE_COMPRESSED_FORMATS_ARB\0" - "GL_TEXTURE_COMPRESSED_IMAGE_SIZE\0" - "GL_TEXTURE_COMPRESSED_IMAGE_SIZE_ARB\0" - "GL_TEXTURE_COMPRESSION_HINT\0" - "GL_TEXTURE_COMPRESSION_HINT_ARB\0" - "GL_TEXTURE_COORD_ARRAY\0" - "GL_TEXTURE_COORD_ARRAY_BUFFER_BINDING\0" - "GL_TEXTURE_COORD_ARRAY_BUFFER_BINDING_ARB\0" - "GL_TEXTURE_COORD_ARRAY_POINTER\0" - "GL_TEXTURE_COORD_ARRAY_SIZE\0" - "GL_TEXTURE_COORD_ARRAY_STRIDE\0" - "GL_TEXTURE_COORD_ARRAY_TYPE\0" - "GL_TEXTURE_CROP_RECT_OES\0" - "GL_TEXTURE_CUBE_MAP\0" - "GL_TEXTURE_CUBE_MAP_ARB\0" - "GL_TEXTURE_CUBE_MAP_NEGATIVE_X\0" - "GL_TEXTURE_CUBE_MAP_NEGATIVE_X_ARB\0" - "GL_TEXTURE_CUBE_MAP_NEGATIVE_X_OES\0" - "GL_TEXTURE_CUBE_MAP_NEGATIVE_Y\0" - "GL_TEXTURE_CUBE_MAP_NEGATIVE_Y_ARB\0" - "GL_TEXTURE_CUBE_MAP_NEGATIVE_Y_OES\0" - "GL_TEXTURE_CUBE_MAP_NEGATIVE_Z\0" - "GL_TEXTURE_CUBE_MAP_NEGATIVE_Z_ARB\0" - "GL_TEXTURE_CUBE_MAP_NEGATIVE_Z_OES\0" - "GL_TEXTURE_CUBE_MAP_OES\0" - "GL_TEXTURE_CUBE_MAP_POSITIVE_X\0" - "GL_TEXTURE_CUBE_MAP_POSITIVE_X_ARB\0" - "GL_TEXTURE_CUBE_MAP_POSITIVE_X_OES\0" - "GL_TEXTURE_CUBE_MAP_POSITIVE_Y\0" - "GL_TEXTURE_CUBE_MAP_POSITIVE_Y_ARB\0" - "GL_TEXTURE_CUBE_MAP_POSITIVE_Y_OES\0" - "GL_TEXTURE_CUBE_MAP_POSITIVE_Z\0" - "GL_TEXTURE_CUBE_MAP_POSITIVE_Z_ARB\0" - "GL_TEXTURE_CUBE_MAP_POSITIVE_Z_OES\0" - "GL_TEXTURE_CUBE_MAP_SEAMLESS\0" - "GL_TEXTURE_DEPTH\0" - "GL_TEXTURE_DEPTH_SIZE\0" - "GL_TEXTURE_DEPTH_SIZE_ARB\0" - "GL_TEXTURE_ENV\0" - "GL_TEXTURE_ENV_COLOR\0" - "GL_TEXTURE_ENV_MODE\0" - "GL_TEXTURE_EXTERNAL_OES\0" - "GL_TEXTURE_FILTER_CONTROL\0" - "GL_TEXTURE_FILTER_CONTROL_EXT\0" - "GL_TEXTURE_GEN_MODE\0" - "GL_TEXTURE_GEN_MODE_OES\0" - "GL_TEXTURE_GEN_Q\0" - "GL_TEXTURE_GEN_R\0" - "GL_TEXTURE_GEN_S\0" - "GL_TEXTURE_GEN_STR_OES\0" - "GL_TEXTURE_GEN_T\0" - "GL_TEXTURE_GEQUAL_R_SGIX\0" - "GL_TEXTURE_GREEN_SIZE\0" - "GL_TEXTURE_GREEN_SIZE_EXT\0" - "GL_TEXTURE_HEIGHT\0" - "GL_TEXTURE_INDEX_SIZE_EXT\0" - "GL_TEXTURE_INTENSITY_SIZE\0" - "GL_TEXTURE_INTENSITY_SIZE_EXT\0" - "GL_TEXTURE_INTERNAL_FORMAT\0" - "GL_TEXTURE_LEQUAL_R_SGIX\0" - "GL_TEXTURE_LOD_BIAS\0" - "GL_TEXTURE_LOD_BIAS_EXT\0" - "GL_TEXTURE_LOD_BIAS_R_SGIX\0" - "GL_TEXTURE_LOD_BIAS_S_SGIX\0" - "GL_TEXTURE_LOD_BIAS_T_SGIX\0" - "GL_TEXTURE_LUMINANCE_SIZE\0" - "GL_TEXTURE_LUMINANCE_SIZE_EXT\0" - "GL_TEXTURE_MAG_FILTER\0" - "GL_TEXTURE_MATRIX\0" - "GL_TEXTURE_MATRIX_FLOAT_AS_INT_BITS_OES\0" - "GL_TEXTURE_MAX_ANISOTROPY_EXT\0" - "GL_TEXTURE_MAX_CLAMP_R_SGIX\0" - "GL_TEXTURE_MAX_CLAMP_S_SGIX\0" - "GL_TEXTURE_MAX_CLAMP_T_SGIX\0" - "GL_TEXTURE_MAX_LEVEL\0" - "GL_TEXTURE_MAX_LOD\0" - "GL_TEXTURE_MIN_FILTER\0" - "GL_TEXTURE_MIN_LOD\0" - "GL_TEXTURE_PRIORITY\0" - "GL_TEXTURE_RANGE_LENGTH_APPLE\0" - "GL_TEXTURE_RANGE_POINTER_APPLE\0" - "GL_TEXTURE_RECTANGLE\0" - "GL_TEXTURE_RECTANGLE_ARB\0" - "GL_TEXTURE_RECTANGLE_NV\0" - "GL_TEXTURE_RED_SIZE\0" - "GL_TEXTURE_RED_SIZE_EXT\0" - "GL_TEXTURE_RESIDENT\0" - "GL_TEXTURE_SHARED_SIZE\0" - "GL_TEXTURE_STACK_DEPTH\0" - "GL_TEXTURE_STENCIL_SIZE\0" - "GL_TEXTURE_STENCIL_SIZE_EXT\0" - "GL_TEXTURE_STORAGE_HINT_APPLE\0" - "GL_TEXTURE_TOO_LARGE_EXT\0" - "GL_TEXTURE_UNSIGNED_REMAP_MODE_NV\0" - "GL_TEXTURE_WIDTH\0" - "GL_TEXTURE_WRAP_R\0" - "GL_TEXTURE_WRAP_R_OES\0" - "GL_TEXTURE_WRAP_S\0" - "GL_TEXTURE_WRAP_T\0" - "GL_TIMEOUT_EXPIRED\0" - "GL_TIME_ELAPSED_EXT\0" - "GL_TRACK_MATRIX_NV\0" - "GL_TRACK_MATRIX_TRANSFORM_NV\0" - "GL_TRANSFORM_BIT\0" - "GL_TRANSFORM_FEEDBACK\0" - "GL_TRANSFORM_FEEDBACK_BINDING\0" - "GL_TRANSFORM_FEEDBACK_BUFFER\0" - "GL_TRANSFORM_FEEDBACK_BUFFER_ACTIVE\0" - "GL_TRANSFORM_FEEDBACK_BUFFER_BINDING\0" - "GL_TRANSFORM_FEEDBACK_BUFFER_BINDING_EXT\0" - "GL_TRANSFORM_FEEDBACK_BUFFER_EXT\0" - "GL_TRANSFORM_FEEDBACK_BUFFER_MODE\0" - "GL_TRANSFORM_FEEDBACK_BUFFER_MODE_EXT\0" - "GL_TRANSFORM_FEEDBACK_BUFFER_PAUSED\0" - "GL_TRANSFORM_FEEDBACK_BUFFER_SIZE\0" - "GL_TRANSFORM_FEEDBACK_BUFFER_SIZE_EXT\0" - "GL_TRANSFORM_FEEDBACK_BUFFER_START\0" - "GL_TRANSFORM_FEEDBACK_BUFFER_START_EXT\0" - "GL_TRANSFORM_FEEDBACK_PRIMITIVES_WRITTEN\0" - "GL_TRANSFORM_FEEDBACK_PRIMITIVES_WRITTEN_EXT\0" - "GL_TRANSFORM_FEEDBACK_VARYINGS\0" - "GL_TRANSFORM_FEEDBACK_VARYINGS_EXT\0" - "GL_TRANSFORM_FEEDBACK_VARYING_MAX_LENGTH\0" - "GL_TRANSFORM_FEEDBACK_VARYING_MAX_LENGTH_EXT\0" - "GL_TRANSPOSE_COLOR_MATRIX\0" - "GL_TRANSPOSE_COLOR_MATRIX_ARB\0" - "GL_TRANSPOSE_CURRENT_MATRIX_ARB\0" - "GL_TRANSPOSE_MODELVIEW_MATRIX\0" - "GL_TRANSPOSE_MODELVIEW_MATRIX_ARB\0" - "GL_TRANSPOSE_NV\0" - "GL_TRANSPOSE_PROJECTION_MATRIX\0" - "GL_TRANSPOSE_PROJECTION_MATRIX_ARB\0" - "GL_TRANSPOSE_TEXTURE_MATRIX\0" - "GL_TRANSPOSE_TEXTURE_MATRIX_ARB\0" - "GL_TRIANGLES\0" - "GL_TRIANGLES_ADJACENCY\0" - "GL_TRIANGLES_ADJACENCY_ARB\0" - "GL_TRIANGLE_FAN\0" - "GL_TRIANGLE_MESH_SUN\0" - "GL_TRIANGLE_STRIP\0" - "GL_TRIANGLE_STRIP_ADJACENCY\0" - "GL_TRIANGLE_STRIP_ADJACENCY_ARB\0" - "GL_TRUE\0" - "GL_UNDEFINED_APPLE\0" - "GL_UNKNOWN_CONTEXT_RESET_ARB\0" - "GL_UNPACK_ALIGNMENT\0" - "GL_UNPACK_IMAGE_HEIGHT\0" - "GL_UNPACK_LSB_FIRST\0" - "GL_UNPACK_ROW_LENGTH\0" - "GL_UNPACK_SKIP_IMAGES\0" - "GL_UNPACK_SKIP_PIXELS\0" - "GL_UNPACK_SKIP_ROWS\0" - "GL_UNPACK_SWAP_BYTES\0" - "GL_UNSIGNALED\0" - "GL_UNSIGNED_BYTE\0" - "GL_UNSIGNED_BYTE_2_3_3_REV\0" - "GL_UNSIGNED_BYTE_3_3_2\0" - "GL_UNSIGNED_INT\0" - "GL_UNSIGNED_INT_10F_11F_11F_REV\0" - "GL_UNSIGNED_INT_10_10_10_2\0" - "GL_UNSIGNED_INT_10_10_10_2_OES\0" - "GL_UNSIGNED_INT_24_8\0" - "GL_UNSIGNED_INT_24_8_EXT\0" - "GL_UNSIGNED_INT_24_8_NV\0" - "GL_UNSIGNED_INT_24_8_OES\0" - "GL_UNSIGNED_INT_2_10_10_10_REV\0" - "GL_UNSIGNED_INT_2_10_10_10_REV_EXT\0" - "GL_UNSIGNED_INT_5_9_9_9_REV\0" - "GL_UNSIGNED_INT_8_8_8_8\0" - "GL_UNSIGNED_INT_8_8_8_8_REV\0" - "GL_UNSIGNED_INT_SAMPLER_1D\0" - "GL_UNSIGNED_INT_SAMPLER_1D_ARRAY\0" - "GL_UNSIGNED_INT_SAMPLER_1D_ARRAY_EXT\0" - "GL_UNSIGNED_INT_SAMPLER_1D_EXT\0" - "GL_UNSIGNED_INT_SAMPLER_2D\0" - "GL_UNSIGNED_INT_SAMPLER_2D_ARRAY\0" - "GL_UNSIGNED_INT_SAMPLER_2D_ARRAY_EXT\0" - "GL_UNSIGNED_INT_SAMPLER_2D_EXT\0" - "GL_UNSIGNED_INT_SAMPLER_2D_RECT\0" - "GL_UNSIGNED_INT_SAMPLER_2D_RECT_EXT\0" - "GL_UNSIGNED_INT_SAMPLER_3D\0" - "GL_UNSIGNED_INT_SAMPLER_3D_EXT\0" - "GL_UNSIGNED_INT_SAMPLER_BUFFER\0" - "GL_UNSIGNED_INT_SAMPLER_BUFFER_EXT\0" - "GL_UNSIGNED_INT_SAMPLER_CUBE\0" - "GL_UNSIGNED_INT_SAMPLER_CUBE_EXT\0" - "GL_UNSIGNED_INT_VEC2\0" - "GL_UNSIGNED_INT_VEC2_EXT\0" - "GL_UNSIGNED_INT_VEC3\0" - "GL_UNSIGNED_INT_VEC3_EXT\0" - "GL_UNSIGNED_INT_VEC4\0" - "GL_UNSIGNED_INT_VEC4_EXT\0" - "GL_UNSIGNED_NORMALIZED\0" - "GL_UNSIGNED_SHORT\0" - "GL_UNSIGNED_SHORT_1_5_5_5_REV\0" - "GL_UNSIGNED_SHORT_1_5_5_5_REV_EXT\0" - "GL_UNSIGNED_SHORT_4_4_4_4\0" - "GL_UNSIGNED_SHORT_4_4_4_4_REV\0" - "GL_UNSIGNED_SHORT_4_4_4_4_REV_EXT\0" - "GL_UNSIGNED_SHORT_5_5_5_1\0" - "GL_UNSIGNED_SHORT_5_6_5\0" - "GL_UNSIGNED_SHORT_5_6_5_REV\0" - "GL_UNSIGNED_SHORT_8_8_APPLE\0" - "GL_UNSIGNED_SHORT_8_8_MESA\0" - "GL_UNSIGNED_SHORT_8_8_REV_APPLE\0" - "GL_UNSIGNED_SHORT_8_8_REV_MESA\0" - "GL_UPPER_LEFT\0" - "GL_V2F\0" - "GL_V3F\0" - "GL_VALIDATE_STATUS\0" - "GL_VENDOR\0" - "GL_VERSION\0" - "GL_VERTEX_ARRAY\0" - "GL_VERTEX_ARRAY_BINDING\0" - "GL_VERTEX_ARRAY_BINDING_APPLE\0" - "GL_VERTEX_ARRAY_BUFFER_BINDING\0" - "GL_VERTEX_ARRAY_BUFFER_BINDING_ARB\0" - "GL_VERTEX_ARRAY_POINTER\0" - "GL_VERTEX_ARRAY_SIZE\0" - "GL_VERTEX_ARRAY_STRIDE\0" - "GL_VERTEX_ARRAY_TYPE\0" - "GL_VERTEX_ATTRIB_ARRAY0_NV\0" - "GL_VERTEX_ATTRIB_ARRAY10_NV\0" - "GL_VERTEX_ATTRIB_ARRAY11_NV\0" - "GL_VERTEX_ATTRIB_ARRAY12_NV\0" - "GL_VERTEX_ATTRIB_ARRAY13_NV\0" - "GL_VERTEX_ATTRIB_ARRAY14_NV\0" - "GL_VERTEX_ATTRIB_ARRAY15_NV\0" - "GL_VERTEX_ATTRIB_ARRAY1_NV\0" - "GL_VERTEX_ATTRIB_ARRAY2_NV\0" - "GL_VERTEX_ATTRIB_ARRAY3_NV\0" - "GL_VERTEX_ATTRIB_ARRAY4_NV\0" - "GL_VERTEX_ATTRIB_ARRAY5_NV\0" - "GL_VERTEX_ATTRIB_ARRAY6_NV\0" - "GL_VERTEX_ATTRIB_ARRAY7_NV\0" - "GL_VERTEX_ATTRIB_ARRAY8_NV\0" - "GL_VERTEX_ATTRIB_ARRAY9_NV\0" - "GL_VERTEX_ATTRIB_ARRAY_BUFFER_BINDING\0" - "GL_VERTEX_ATTRIB_ARRAY_BUFFER_BINDING_ARB\0" - "GL_VERTEX_ATTRIB_ARRAY_DIVISOR_ARB\0" - "GL_VERTEX_ATTRIB_ARRAY_ENABLED\0" - "GL_VERTEX_ATTRIB_ARRAY_ENABLED_ARB\0" - "GL_VERTEX_ATTRIB_ARRAY_INTEGER\0" - "GL_VERTEX_ATTRIB_ARRAY_INTEGER_EXT\0" - "GL_VERTEX_ATTRIB_ARRAY_NORMALIZED\0" - "GL_VERTEX_ATTRIB_ARRAY_NORMALIZED_ARB\0" - "GL_VERTEX_ATTRIB_ARRAY_POINTER\0" - "GL_VERTEX_ATTRIB_ARRAY_POINTER_ARB\0" - "GL_VERTEX_ATTRIB_ARRAY_SIZE\0" - "GL_VERTEX_ATTRIB_ARRAY_SIZE_ARB\0" - "GL_VERTEX_ATTRIB_ARRAY_STRIDE\0" - "GL_VERTEX_ATTRIB_ARRAY_STRIDE_ARB\0" - "GL_VERTEX_ATTRIB_ARRAY_TYPE\0" - "GL_VERTEX_ATTRIB_ARRAY_TYPE_ARB\0" - "GL_VERTEX_BLEND_ARB\0" - "GL_VERTEX_PROGRAM_ARB\0" - "GL_VERTEX_PROGRAM_BINDING_NV\0" - "GL_VERTEX_PROGRAM_NV\0" - "GL_VERTEX_PROGRAM_POINT_SIZE\0" - "GL_VERTEX_PROGRAM_POINT_SIZE_ARB\0" - "GL_VERTEX_PROGRAM_POINT_SIZE_NV\0" - "GL_VERTEX_PROGRAM_TWO_SIDE\0" - "GL_VERTEX_PROGRAM_TWO_SIDE_ARB\0" - "GL_VERTEX_PROGRAM_TWO_SIDE_NV\0" - "GL_VERTEX_SHADER\0" - "GL_VERTEX_SHADER_ARB\0" - "GL_VERTEX_STATE_PROGRAM_NV\0" - "GL_VIEWPORT\0" - "GL_VIEWPORT_BIT\0" - "GL_VOLATILE_APPLE\0" - "GL_WAIT_FAILED\0" - "GL_WEIGHT_ARRAY_ARB\0" - "GL_WEIGHT_ARRAY_BUFFER_BINDING\0" - "GL_WEIGHT_ARRAY_BUFFER_BINDING_ARB\0" - "GL_WEIGHT_ARRAY_BUFFER_BINDING_OES\0" - "GL_WEIGHT_ARRAY_OES\0" - "GL_WEIGHT_ARRAY_POINTER_ARB\0" - "GL_WEIGHT_ARRAY_POINTER_OES\0" - "GL_WEIGHT_ARRAY_SIZE_ARB\0" - "GL_WEIGHT_ARRAY_SIZE_OES\0" - "GL_WEIGHT_ARRAY_STRIDE_ARB\0" - "GL_WEIGHT_ARRAY_STRIDE_OES\0" - "GL_WEIGHT_ARRAY_TYPE_ARB\0" - "GL_WEIGHT_ARRAY_TYPE_OES\0" - "GL_WEIGHT_SUM_UNITY_ARB\0" - "GL_WRAP_BORDER_SUN\0" - "GL_WRITE_ONLY\0" - "GL_WRITE_ONLY_ARB\0" - "GL_WRITE_ONLY_OES\0" - "GL_XOR\0" - "GL_YCBCR_422_APPLE\0" - "GL_YCBCR_MESA\0" - "GL_ZERO\0" - "GL_ZOOM_X\0" - "GL_ZOOM_Y\0" - ; - -static const enum_elt all_enums[2340] = -{ - { 0, 0x00000600 }, /* GL_2D */ - { 6, 0x00001407 }, /* GL_2_BYTES */ - { 17, 0x00000601 }, /* GL_3D */ - { 23, 0x00000602 }, /* GL_3D_COLOR */ - { 35, 0x00000603 }, /* GL_3D_COLOR_TEXTURE */ - { 55, 0x00001408 }, /* GL_3_BYTES */ - { 66, 0x00000604 }, /* GL_4D_COLOR_TEXTURE */ - { 86, 0x00001409 }, /* GL_4_BYTES */ - { 97, 0x00000100 }, /* GL_ACCUM */ - { 106, 0x00000D5B }, /* GL_ACCUM_ALPHA_BITS */ - { 126, 0x00000D5A }, /* GL_ACCUM_BLUE_BITS */ - { 145, 0x00000200 }, /* GL_ACCUM_BUFFER_BIT */ - { 165, 0x00000B80 }, /* GL_ACCUM_CLEAR_VALUE */ - { 186, 0x00000D59 }, /* GL_ACCUM_GREEN_BITS */ - { 206, 0x00000D58 }, /* GL_ACCUM_RED_BITS */ - { 224, 0x00008B89 }, /* GL_ACTIVE_ATTRIBUTES */ - { 245, 0x00008B8A }, /* GL_ACTIVE_ATTRIBUTE_MAX_LENGTH */ - { 276, 0x00008B8D }, /* GL_ACTIVE_PROGRAM_EXT */ - { 298, 0x00008911 }, /* GL_ACTIVE_STENCIL_FACE_EXT */ - { 325, 0x000084E0 }, /* GL_ACTIVE_TEXTURE */ - { 343, 0x000084E0 }, /* GL_ACTIVE_TEXTURE_ARB */ - { 365, 0x00008B86 }, /* GL_ACTIVE_UNIFORMS */ - { 384, 0x00008B87 }, /* GL_ACTIVE_UNIFORM_MAX_LENGTH */ - { 413, 0x000086A5 }, /* GL_ACTIVE_VERTEX_UNITS_ARB */ - { 440, 0x00000104 }, /* GL_ADD */ - { 447, 0x00008574 }, /* GL_ADD_SIGNED */ - { 461, 0x00008574 }, /* GL_ADD_SIGNED_ARB */ - { 479, 0x00008574 }, /* GL_ADD_SIGNED_EXT */ - { 497, 0x0000846E }, /* GL_ALIASED_LINE_WIDTH_RANGE */ - { 525, 0x0000846D }, /* GL_ALIASED_POINT_SIZE_RANGE */ - { 553, 0x000FFFFF }, /* GL_ALL_ATTRIB_BITS */ - { 572, 0xFFFFFFFF }, /* GL_ALL_CLIENT_ATTRIB_BITS */ - { 598, 0x00001906 }, /* GL_ALPHA */ - { 607, 0x0000803D }, /* GL_ALPHA12 */ - { 618, 0x0000803D }, /* GL_ALPHA12_EXT */ - { 633, 0x0000803E }, /* GL_ALPHA16 */ - { 644, 0x00008D8A }, /* GL_ALPHA16I_EXT */ - { 660, 0x00008D78 }, /* GL_ALPHA16UI_EXT */ - { 677, 0x0000803E }, /* GL_ALPHA16_EXT */ - { 692, 0x00008D84 }, /* GL_ALPHA32I_EXT */ - { 708, 0x00008D72 }, /* GL_ALPHA32UI_EXT */ - { 725, 0x0000803B }, /* GL_ALPHA4 */ - { 735, 0x0000803B }, /* GL_ALPHA4_EXT */ - { 749, 0x0000803C }, /* GL_ALPHA8 */ - { 759, 0x00008D90 }, /* GL_ALPHA8I_EXT */ - { 774, 0x00008D7E }, /* GL_ALPHA8UI_EXT */ - { 790, 0x0000803C }, /* GL_ALPHA8_EXT */ - { 804, 0x00000D1D }, /* GL_ALPHA_BIAS */ - { 818, 0x00000D55 }, /* GL_ALPHA_BITS */ - { 832, 0x00008D97 }, /* GL_ALPHA_INTEGER_EXT */ - { 853, 0x00000D1C }, /* GL_ALPHA_SCALE */ - { 868, 0x00000BC0 }, /* GL_ALPHA_TEST */ - { 882, 0x00000BC1 }, /* GL_ALPHA_TEST_FUNC */ - { 901, 0x00000BC2 }, /* GL_ALPHA_TEST_REF */ - { 919, 0x0000911A }, /* GL_ALREADY_SIGNALED */ - { 939, 0x00000207 }, /* GL_ALWAYS */ - { 949, 0x00001200 }, /* GL_AMBIENT */ - { 960, 0x00001602 }, /* GL_AMBIENT_AND_DIFFUSE */ - { 983, 0x00001501 }, /* GL_AND */ - { 990, 0x00001504 }, /* GL_AND_INVERTED */ - { 1006, 0x00001502 }, /* GL_AND_REVERSE */ - { 1021, 0x00008892 }, /* GL_ARRAY_BUFFER */ - { 1037, 0x00008894 }, /* GL_ARRAY_BUFFER_BINDING */ - { 1061, 0x00008894 }, /* GL_ARRAY_BUFFER_BINDING_ARB */ - { 1089, 0x00008B85 }, /* GL_ATTACHED_SHADERS */ - { 1109, 0x00008645 }, /* GL_ATTRIB_ARRAY_POINTER_NV */ - { 1136, 0x00008623 }, /* GL_ATTRIB_ARRAY_SIZE_NV */ - { 1160, 0x00008624 }, /* GL_ATTRIB_ARRAY_STRIDE_NV */ - { 1186, 0x00008625 }, /* GL_ATTRIB_ARRAY_TYPE_NV */ - { 1210, 0x00000BB0 }, /* GL_ATTRIB_STACK_DEPTH */ - { 1232, 0x00000D80 }, /* GL_AUTO_NORMAL */ - { 1247, 0x00000409 }, /* GL_AUX0 */ - { 1255, 0x0000040A }, /* GL_AUX1 */ - { 1263, 0x0000040B }, /* GL_AUX2 */ - { 1271, 0x0000040C }, /* GL_AUX3 */ - { 1279, 0x00000C00 }, /* GL_AUX_BUFFERS */ - { 1294, 0x00000405 }, /* GL_BACK */ - { 1302, 0x00000402 }, /* GL_BACK_LEFT */ - { 1315, 0x00000403 }, /* GL_BACK_RIGHT */ - { 1329, 0x000080E0 }, /* GL_BGR */ - { 1336, 0x000080E1 }, /* GL_BGRA */ - { 1344, 0x000080E1 }, /* GL_BGRA_EXT */ - { 1356, 0x00008D9B }, /* GL_BGRA_INTEGER */ - { 1372, 0x00008D9B }, /* GL_BGRA_INTEGER_EXT */ - { 1392, 0x00008D9A }, /* GL_BGR_INTEGER */ - { 1407, 0x00008D9A }, /* GL_BGR_INTEGER_EXT */ - { 1426, 0x00001A00 }, /* GL_BITMAP */ - { 1436, 0x00000704 }, /* GL_BITMAP_TOKEN */ - { 1452, 0x00000BE2 }, /* GL_BLEND */ - { 1461, 0x00008005 }, /* GL_BLEND_COLOR */ - { 1476, 0x00008005 }, /* GL_BLEND_COLOR_EXT */ - { 1495, 0x00000BE0 }, /* GL_BLEND_DST */ - { 1508, 0x000080CA }, /* GL_BLEND_DST_ALPHA */ - { 1527, 0x000080CA }, /* GL_BLEND_DST_ALPHA_OES */ - { 1550, 0x000080C8 }, /* GL_BLEND_DST_RGB */ - { 1567, 0x000080C8 }, /* GL_BLEND_DST_RGB_OES */ - { 1588, 0x00008009 }, /* GL_BLEND_EQUATION */ - { 1606, 0x0000883D }, /* GL_BLEND_EQUATION_ALPHA */ - { 1630, 0x0000883D }, /* GL_BLEND_EQUATION_ALPHA_EXT */ - { 1658, 0x0000883D }, /* GL_BLEND_EQUATION_ALPHA_OES */ - { 1686, 0x00008009 }, /* GL_BLEND_EQUATION_EXT */ - { 1708, 0x00008009 }, /* GL_BLEND_EQUATION_OES */ - { 1730, 0x00008009 }, /* GL_BLEND_EQUATION_RGB */ - { 1752, 0x00008009 }, /* GL_BLEND_EQUATION_RGB_EXT */ - { 1778, 0x00008009 }, /* GL_BLEND_EQUATION_RGB_OES */ - { 1804, 0x00000BE1 }, /* GL_BLEND_SRC */ - { 1817, 0x000080CB }, /* GL_BLEND_SRC_ALPHA */ - { 1836, 0x000080CB }, /* GL_BLEND_SRC_ALPHA_OES */ - { 1859, 0x000080C9 }, /* GL_BLEND_SRC_RGB */ - { 1876, 0x000080C9 }, /* GL_BLEND_SRC_RGB_OES */ - { 1897, 0x00001905 }, /* GL_BLUE */ - { 1905, 0x00000D1B }, /* GL_BLUE_BIAS */ - { 1918, 0x00000D54 }, /* GL_BLUE_BITS */ - { 1931, 0x00008D96 }, /* GL_BLUE_INTEGER */ - { 1947, 0x00008D96 }, /* GL_BLUE_INTEGER_EXT */ - { 1967, 0x00000D1A }, /* GL_BLUE_SCALE */ - { 1981, 0x00008B56 }, /* GL_BOOL */ - { 1989, 0x00008B56 }, /* GL_BOOL_ARB */ - { 2001, 0x00008B57 }, /* GL_BOOL_VEC2 */ - { 2014, 0x00008B57 }, /* GL_BOOL_VEC2_ARB */ - { 2031, 0x00008B58 }, /* GL_BOOL_VEC3 */ - { 2044, 0x00008B58 }, /* GL_BOOL_VEC3_ARB */ - { 2061, 0x00008B59 }, /* GL_BOOL_VEC4 */ - { 2074, 0x00008B59 }, /* GL_BOOL_VEC4_ARB */ - { 2091, 0x000088BB }, /* GL_BUFFER_ACCESS */ - { 2108, 0x000088BB }, /* GL_BUFFER_ACCESS_ARB */ - { 2129, 0x0000911F }, /* GL_BUFFER_ACCESS_FLAGS */ - { 2152, 0x000088BB }, /* GL_BUFFER_ACCESS_OES */ - { 2173, 0x00008A13 }, /* GL_BUFFER_FLUSHING_UNMAP_APPLE */ - { 2204, 0x000088BC }, /* GL_BUFFER_MAPPED */ - { 2221, 0x000088BC }, /* GL_BUFFER_MAPPED_ARB */ - { 2242, 0x000088BC }, /* GL_BUFFER_MAPPED_OES */ - { 2263, 0x00009120 }, /* GL_BUFFER_MAP_LENGTH */ - { 2284, 0x00009121 }, /* GL_BUFFER_MAP_OFFSET */ - { 2305, 0x000088BD }, /* GL_BUFFER_MAP_POINTER */ - { 2327, 0x000088BD }, /* GL_BUFFER_MAP_POINTER_ARB */ - { 2353, 0x000088BD }, /* GL_BUFFER_MAP_POINTER_OES */ - { 2379, 0x000085B3 }, /* GL_BUFFER_OBJECT_APPLE */ - { 2402, 0x00008A12 }, /* GL_BUFFER_SERIALIZED_MODIFY_APPLE */ - { 2436, 0x00008764 }, /* GL_BUFFER_SIZE */ - { 2451, 0x00008764 }, /* GL_BUFFER_SIZE_ARB */ - { 2470, 0x00008765 }, /* GL_BUFFER_USAGE */ - { 2486, 0x00008765 }, /* GL_BUFFER_USAGE_ARB */ - { 2506, 0x0000877B }, /* GL_BUMP_ENVMAP_ATI */ - { 2525, 0x00008777 }, /* GL_BUMP_NUM_TEX_UNITS_ATI */ - { 2551, 0x00008775 }, /* GL_BUMP_ROT_MATRIX_ATI */ - { 2574, 0x00008776 }, /* GL_BUMP_ROT_MATRIX_SIZE_ATI */ - { 2602, 0x0000877C }, /* GL_BUMP_TARGET_ATI */ - { 2621, 0x00008778 }, /* GL_BUMP_TEX_UNITS_ATI */ - { 2643, 0x00001400 }, /* GL_BYTE */ - { 2651, 0x00002A24 }, /* GL_C3F_V3F */ - { 2662, 0x00002A26 }, /* GL_C4F_N3F_V3F */ - { 2677, 0x00002A22 }, /* GL_C4UB_V2F */ - { 2689, 0x00002A23 }, /* GL_C4UB_V3F */ - { 2701, 0x00000901 }, /* GL_CCW */ - { 2708, 0x00002900 }, /* GL_CLAMP */ - { 2717, 0x0000891B }, /* GL_CLAMP_FRAGMENT_COLOR_ARB */ - { 2745, 0x0000891C }, /* GL_CLAMP_READ_COLOR */ - { 2765, 0x0000891C }, /* GL_CLAMP_READ_COLOR_ARB */ - { 2789, 0x0000812D }, /* GL_CLAMP_TO_BORDER */ - { 2808, 0x0000812D }, /* GL_CLAMP_TO_BORDER_ARB */ - { 2831, 0x0000812D }, /* GL_CLAMP_TO_BORDER_SGIS */ - { 2855, 0x0000812F }, /* GL_CLAMP_TO_EDGE */ - { 2872, 0x0000812F }, /* GL_CLAMP_TO_EDGE_SGIS */ - { 2894, 0x0000891A }, /* GL_CLAMP_VERTEX_COLOR_ARB */ - { 2920, 0x00001500 }, /* GL_CLEAR */ - { 2929, 0x000084E1 }, /* GL_CLIENT_ACTIVE_TEXTURE */ - { 2954, 0x000084E1 }, /* GL_CLIENT_ACTIVE_TEXTURE_ARB */ - { 2983, 0xFFFFFFFF }, /* GL_CLIENT_ALL_ATTRIB_BITS */ - { 3009, 0x00000BB1 }, /* GL_CLIENT_ATTRIB_STACK_DEPTH */ - { 3038, 0x00000001 }, /* GL_CLIENT_PIXEL_STORE_BIT */ - { 3064, 0x00000002 }, /* GL_CLIENT_VERTEX_ARRAY_BIT */ - { 3091, 0x00003000 }, /* GL_CLIP_DISTANCE0 */ - { 3109, 0x00003001 }, /* GL_CLIP_DISTANCE1 */ - { 3127, 0x00003002 }, /* GL_CLIP_DISTANCE2 */ - { 3145, 0x00003003 }, /* GL_CLIP_DISTANCE3 */ - { 3163, 0x00003004 }, /* GL_CLIP_DISTANCE4 */ - { 3181, 0x00003005 }, /* GL_CLIP_DISTANCE5 */ - { 3199, 0x00003006 }, /* GL_CLIP_DISTANCE6 */ - { 3217, 0x00003007 }, /* GL_CLIP_DISTANCE7 */ - { 3235, 0x00003000 }, /* GL_CLIP_PLANE0 */ - { 3250, 0x00003001 }, /* GL_CLIP_PLANE1 */ - { 3265, 0x00003002 }, /* GL_CLIP_PLANE2 */ - { 3280, 0x00003003 }, /* GL_CLIP_PLANE3 */ - { 3295, 0x00003004 }, /* GL_CLIP_PLANE4 */ - { 3310, 0x00003005 }, /* GL_CLIP_PLANE5 */ - { 3325, 0x000080F0 }, /* GL_CLIP_VOLUME_CLIPPING_HINT_EXT */ - { 3358, 0x00000A00 }, /* GL_COEFF */ - { 3367, 0x00001800 }, /* GL_COLOR */ - { 3376, 0x00008076 }, /* GL_COLOR_ARRAY */ - { 3391, 0x00008898 }, /* GL_COLOR_ARRAY_BUFFER_BINDING */ - { 3421, 0x00008898 }, /* GL_COLOR_ARRAY_BUFFER_BINDING_ARB */ - { 3455, 0x00008090 }, /* GL_COLOR_ARRAY_POINTER */ - { 3478, 0x00008081 }, /* GL_COLOR_ARRAY_SIZE */ - { 3498, 0x00008083 }, /* GL_COLOR_ARRAY_STRIDE */ - { 3520, 0x00008082 }, /* GL_COLOR_ARRAY_TYPE */ - { 3540, 0x00008CE0 }, /* GL_COLOR_ATTACHMENT0 */ - { 3561, 0x00008CE0 }, /* GL_COLOR_ATTACHMENT0_EXT */ - { 3586, 0x00008CE0 }, /* GL_COLOR_ATTACHMENT0_OES */ - { 3611, 0x00008CE1 }, /* GL_COLOR_ATTACHMENT1 */ - { 3632, 0x00008CEA }, /* GL_COLOR_ATTACHMENT10 */ - { 3654, 0x00008CEA }, /* GL_COLOR_ATTACHMENT10_EXT */ - { 3680, 0x00008CEB }, /* GL_COLOR_ATTACHMENT11 */ - { 3702, 0x00008CEB }, /* GL_COLOR_ATTACHMENT11_EXT */ - { 3728, 0x00008CEC }, /* GL_COLOR_ATTACHMENT12 */ - { 3750, 0x00008CEC }, /* GL_COLOR_ATTACHMENT12_EXT */ - { 3776, 0x00008CED }, /* GL_COLOR_ATTACHMENT13 */ - { 3798, 0x00008CED }, /* GL_COLOR_ATTACHMENT13_EXT */ - { 3824, 0x00008CEE }, /* GL_COLOR_ATTACHMENT14 */ - { 3846, 0x00008CEE }, /* GL_COLOR_ATTACHMENT14_EXT */ - { 3872, 0x00008CEF }, /* GL_COLOR_ATTACHMENT15 */ - { 3894, 0x00008CEF }, /* GL_COLOR_ATTACHMENT15_EXT */ - { 3920, 0x00008CE1 }, /* GL_COLOR_ATTACHMENT1_EXT */ - { 3945, 0x00008CE2 }, /* GL_COLOR_ATTACHMENT2 */ - { 3966, 0x00008CE2 }, /* GL_COLOR_ATTACHMENT2_EXT */ - { 3991, 0x00008CE3 }, /* GL_COLOR_ATTACHMENT3 */ - { 4012, 0x00008CE3 }, /* GL_COLOR_ATTACHMENT3_EXT */ - { 4037, 0x00008CE4 }, /* GL_COLOR_ATTACHMENT4 */ - { 4058, 0x00008CE4 }, /* GL_COLOR_ATTACHMENT4_EXT */ - { 4083, 0x00008CE5 }, /* GL_COLOR_ATTACHMENT5 */ - { 4104, 0x00008CE5 }, /* GL_COLOR_ATTACHMENT5_EXT */ - { 4129, 0x00008CE6 }, /* GL_COLOR_ATTACHMENT6 */ - { 4150, 0x00008CE6 }, /* GL_COLOR_ATTACHMENT6_EXT */ - { 4175, 0x00008CE7 }, /* GL_COLOR_ATTACHMENT7 */ - { 4196, 0x00008CE7 }, /* GL_COLOR_ATTACHMENT7_EXT */ - { 4221, 0x00008CE8 }, /* GL_COLOR_ATTACHMENT8 */ - { 4242, 0x00008CE8 }, /* GL_COLOR_ATTACHMENT8_EXT */ - { 4267, 0x00008CE9 }, /* GL_COLOR_ATTACHMENT9 */ - { 4288, 0x00008CE9 }, /* GL_COLOR_ATTACHMENT9_EXT */ - { 4313, 0x00004000 }, /* GL_COLOR_BUFFER_BIT */ - { 4333, 0x00000C22 }, /* GL_COLOR_CLEAR_VALUE */ - { 4354, 0x00001900 }, /* GL_COLOR_INDEX */ - { 4369, 0x00001603 }, /* GL_COLOR_INDEXES */ - { 4386, 0x00000BF2 }, /* GL_COLOR_LOGIC_OP */ - { 4404, 0x00000B57 }, /* GL_COLOR_MATERIAL */ - { 4422, 0x00000B55 }, /* GL_COLOR_MATERIAL_FACE */ - { 4445, 0x00000B56 }, /* GL_COLOR_MATERIAL_PARAMETER */ - { 4473, 0x000080B1 }, /* GL_COLOR_MATRIX */ - { 4489, 0x000080B1 }, /* GL_COLOR_MATRIX_SGI */ - { 4509, 0x000080B2 }, /* GL_COLOR_MATRIX_STACK_DEPTH */ - { 4537, 0x000080B2 }, /* GL_COLOR_MATRIX_STACK_DEPTH_SGI */ - { 4569, 0x00008458 }, /* GL_COLOR_SUM */ - { 4582, 0x00008458 }, /* GL_COLOR_SUM_ARB */ - { 4599, 0x000080D0 }, /* GL_COLOR_TABLE */ - { 4614, 0x000080DD }, /* GL_COLOR_TABLE_ALPHA_SIZE */ - { 4640, 0x000080DD }, /* GL_COLOR_TABLE_ALPHA_SIZE_EXT */ - { 4670, 0x000080DD }, /* GL_COLOR_TABLE_ALPHA_SIZE_SGI */ - { 4700, 0x000080D7 }, /* GL_COLOR_TABLE_BIAS */ - { 4720, 0x000080D7 }, /* GL_COLOR_TABLE_BIAS_SGI */ - { 4744, 0x000080DC }, /* GL_COLOR_TABLE_BLUE_SIZE */ - { 4769, 0x000080DC }, /* GL_COLOR_TABLE_BLUE_SIZE_EXT */ - { 4798, 0x000080DC }, /* GL_COLOR_TABLE_BLUE_SIZE_SGI */ - { 4827, 0x000080D8 }, /* GL_COLOR_TABLE_FORMAT */ - { 4849, 0x000080D8 }, /* GL_COLOR_TABLE_FORMAT_EXT */ - { 4875, 0x000080D8 }, /* GL_COLOR_TABLE_FORMAT_SGI */ - { 4901, 0x000080DB }, /* GL_COLOR_TABLE_GREEN_SIZE */ - { 4927, 0x000080DB }, /* GL_COLOR_TABLE_GREEN_SIZE_EXT */ - { 4957, 0x000080DB }, /* GL_COLOR_TABLE_GREEN_SIZE_SGI */ - { 4987, 0x000080DF }, /* GL_COLOR_TABLE_INTENSITY_SIZE */ - { 5017, 0x000080DF }, /* GL_COLOR_TABLE_INTENSITY_SIZE_EXT */ - { 5051, 0x000080DF }, /* GL_COLOR_TABLE_INTENSITY_SIZE_SGI */ - { 5085, 0x000080DE }, /* GL_COLOR_TABLE_LUMINANCE_SIZE */ - { 5115, 0x000080DE }, /* GL_COLOR_TABLE_LUMINANCE_SIZE_EXT */ - { 5149, 0x000080DE }, /* GL_COLOR_TABLE_LUMINANCE_SIZE_SGI */ - { 5183, 0x000080DA }, /* GL_COLOR_TABLE_RED_SIZE */ - { 5207, 0x000080DA }, /* GL_COLOR_TABLE_RED_SIZE_EXT */ - { 5235, 0x000080DA }, /* GL_COLOR_TABLE_RED_SIZE_SGI */ - { 5263, 0x000080D6 }, /* GL_COLOR_TABLE_SCALE */ - { 5284, 0x000080D6 }, /* GL_COLOR_TABLE_SCALE_SGI */ - { 5309, 0x000080D9 }, /* GL_COLOR_TABLE_WIDTH */ - { 5330, 0x000080D9 }, /* GL_COLOR_TABLE_WIDTH_EXT */ - { 5355, 0x000080D9 }, /* GL_COLOR_TABLE_WIDTH_SGI */ - { 5380, 0x00000C23 }, /* GL_COLOR_WRITEMASK */ - { 5399, 0x00008570 }, /* GL_COMBINE */ - { 5410, 0x00008503 }, /* GL_COMBINE4 */ - { 5422, 0x00008572 }, /* GL_COMBINE_ALPHA */ - { 5439, 0x00008572 }, /* GL_COMBINE_ALPHA_ARB */ - { 5460, 0x00008572 }, /* GL_COMBINE_ALPHA_EXT */ - { 5481, 0x00008570 }, /* GL_COMBINE_ARB */ - { 5496, 0x00008570 }, /* GL_COMBINE_EXT */ - { 5511, 0x00008571 }, /* GL_COMBINE_RGB */ - { 5526, 0x00008571 }, /* GL_COMBINE_RGB_ARB */ - { 5545, 0x00008571 }, /* GL_COMBINE_RGB_EXT */ - { 5564, 0x0000884E }, /* GL_COMPARE_REF_DEPTH_TO_TEXTURE_EXT */ - { 5600, 0x0000884E }, /* GL_COMPARE_REF_TO_TEXTURE */ - { 5626, 0x0000884E }, /* GL_COMPARE_R_TO_TEXTURE */ - { 5650, 0x0000884E }, /* GL_COMPARE_R_TO_TEXTURE_ARB */ - { 5678, 0x00001300 }, /* GL_COMPILE */ - { 5689, 0x00001301 }, /* GL_COMPILE_AND_EXECUTE */ - { 5712, 0x00008B81 }, /* GL_COMPILE_STATUS */ - { 5730, 0x000084E9 }, /* GL_COMPRESSED_ALPHA */ - { 5750, 0x000084E9 }, /* GL_COMPRESSED_ALPHA_ARB */ - { 5774, 0x000084EC }, /* GL_COMPRESSED_INTENSITY */ - { 5798, 0x000084EC }, /* GL_COMPRESSED_INTENSITY_ARB */ - { 5826, 0x000084EA }, /* GL_COMPRESSED_LUMINANCE */ - { 5850, 0x000084EB }, /* GL_COMPRESSED_LUMINANCE_ALPHA */ - { 5880, 0x000084EB }, /* GL_COMPRESSED_LUMINANCE_ALPHA_ARB */ - { 5914, 0x000084EA }, /* GL_COMPRESSED_LUMINANCE_ARB */ - { 5942, 0x00008225 }, /* GL_COMPRESSED_RED */ - { 5960, 0x00008226 }, /* GL_COMPRESSED_RG */ - { 5977, 0x000084ED }, /* GL_COMPRESSED_RGB */ - { 5995, 0x000084EE }, /* GL_COMPRESSED_RGBA */ - { 6014, 0x000084EE }, /* GL_COMPRESSED_RGBA_ARB */ - { 6037, 0x000086B1 }, /* GL_COMPRESSED_RGBA_FXT1_3DFX */ - { 6066, 0x000083F1 }, /* GL_COMPRESSED_RGBA_S3TC_DXT1_EXT */ - { 6099, 0x000083F2 }, /* GL_COMPRESSED_RGBA_S3TC_DXT3_EXT */ - { 6132, 0x000083F3 }, /* GL_COMPRESSED_RGBA_S3TC_DXT5_EXT */ - { 6165, 0x000084ED }, /* GL_COMPRESSED_RGB_ARB */ - { 6187, 0x000086B0 }, /* GL_COMPRESSED_RGB_FXT1_3DFX */ - { 6215, 0x000083F0 }, /* GL_COMPRESSED_RGB_S3TC_DXT1_EXT */ - { 6247, 0x00008C4A }, /* GL_COMPRESSED_SLUMINANCE */ - { 6272, 0x00008C4B }, /* GL_COMPRESSED_SLUMINANCE_ALPHA */ - { 6303, 0x00008C48 }, /* GL_COMPRESSED_SRGB */ - { 6322, 0x00008C49 }, /* GL_COMPRESSED_SRGB_ALPHA */ - { 6347, 0x000086A3 }, /* GL_COMPRESSED_TEXTURE_FORMATS */ - { 6377, 0x0000911C }, /* GL_CONDITION_SATISFIED */ - { 6400, 0x00008576 }, /* GL_CONSTANT */ - { 6412, 0x00008003 }, /* GL_CONSTANT_ALPHA */ - { 6430, 0x00008003 }, /* GL_CONSTANT_ALPHA_EXT */ - { 6452, 0x00008576 }, /* GL_CONSTANT_ARB */ - { 6468, 0x00001207 }, /* GL_CONSTANT_ATTENUATION */ - { 6492, 0x00008151 }, /* GL_CONSTANT_BORDER_HP */ - { 6514, 0x00008001 }, /* GL_CONSTANT_COLOR */ - { 6532, 0x00008001 }, /* GL_CONSTANT_COLOR_EXT */ - { 6554, 0x00008576 }, /* GL_CONSTANT_EXT */ - { 6570, 0x00000002 }, /* GL_CONTEXT_COMPATIBILITY_PROFILE_BIT */ - { 6607, 0x00000001 }, /* GL_CONTEXT_CORE_PROFILE_BIT */ - { 6635, 0x0000821E }, /* GL_CONTEXT_FLAGS */ - { 6652, 0x00000001 }, /* GL_CONTEXT_FLAG_FORWARD_COMPATIBLE_BIT */ - { 6691, 0x00000004 }, /* GL_CONTEXT_FLAG_ROBUST_ACCESS_BIT_ARB */ - { 6729, 0x00009126 }, /* GL_CONTEXT_PROFILE_MASK */ - { 6753, 0x00008010 }, /* GL_CONVOLUTION_1D */ - { 6771, 0x00008011 }, /* GL_CONVOLUTION_2D */ - { 6789, 0x00008154 }, /* GL_CONVOLUTION_BORDER_COLOR */ - { 6817, 0x00008154 }, /* GL_CONVOLUTION_BORDER_COLOR_HP */ - { 6848, 0x00008013 }, /* GL_CONVOLUTION_BORDER_MODE */ - { 6875, 0x00008013 }, /* GL_CONVOLUTION_BORDER_MODE_EXT */ - { 6906, 0x00008015 }, /* GL_CONVOLUTION_FILTER_BIAS */ - { 6933, 0x00008015 }, /* GL_CONVOLUTION_FILTER_BIAS_EXT */ - { 6964, 0x00008014 }, /* GL_CONVOLUTION_FILTER_SCALE */ - { 6992, 0x00008014 }, /* GL_CONVOLUTION_FILTER_SCALE_EXT */ - { 7024, 0x00008017 }, /* GL_CONVOLUTION_FORMAT */ - { 7046, 0x00008017 }, /* GL_CONVOLUTION_FORMAT_EXT */ - { 7072, 0x00008019 }, /* GL_CONVOLUTION_HEIGHT */ - { 7094, 0x00008019 }, /* GL_CONVOLUTION_HEIGHT_EXT */ - { 7120, 0x00008018 }, /* GL_CONVOLUTION_WIDTH */ - { 7141, 0x00008018 }, /* GL_CONVOLUTION_WIDTH_EXT */ - { 7166, 0x00008862 }, /* GL_COORD_REPLACE */ - { 7183, 0x00008862 }, /* GL_COORD_REPLACE_ARB */ - { 7204, 0x00008862 }, /* GL_COORD_REPLACE_NV */ - { 7224, 0x00008862 }, /* GL_COORD_REPLACE_OES */ - { 7245, 0x00001503 }, /* GL_COPY */ - { 7253, 0x0000150C }, /* GL_COPY_INVERTED */ - { 7270, 0x00000706 }, /* GL_COPY_PIXEL_TOKEN */ - { 7290, 0x00008F36 }, /* GL_COPY_READ_BUFFER */ - { 7310, 0x00008F37 }, /* GL_COPY_WRITE_BUFFER */ - { 7331, 0x00000B44 }, /* GL_CULL_FACE */ - { 7344, 0x00000B45 }, /* GL_CULL_FACE_MODE */ - { 7362, 0x000081AA }, /* GL_CULL_VERTEX_EXT */ - { 7381, 0x000081AC }, /* GL_CULL_VERTEX_EYE_POSITION_EXT */ - { 7413, 0x000081AB }, /* GL_CULL_VERTEX_OBJECT_POSITION_EXT */ - { 7448, 0x00008626 }, /* GL_CURRENT_ATTRIB_NV */ - { 7469, 0x00000001 }, /* GL_CURRENT_BIT */ - { 7484, 0x00000B00 }, /* GL_CURRENT_COLOR */ - { 7501, 0x00008453 }, /* GL_CURRENT_FOG_COORD */ - { 7522, 0x00008453 }, /* GL_CURRENT_FOG_COORDINATE */ - { 7548, 0x00000B01 }, /* GL_CURRENT_INDEX */ - { 7565, 0x00008641 }, /* GL_CURRENT_MATRIX_ARB */ - { 7587, 0x00008845 }, /* GL_CURRENT_MATRIX_INDEX_ARB */ - { 7615, 0x00008641 }, /* GL_CURRENT_MATRIX_NV */ - { 7636, 0x00008640 }, /* GL_CURRENT_MATRIX_STACK_DEPTH_ARB */ - { 7670, 0x00008640 }, /* GL_CURRENT_MATRIX_STACK_DEPTH_NV */ - { 7703, 0x00000B02 }, /* GL_CURRENT_NORMAL */ - { 7721, 0x00008843 }, /* GL_CURRENT_PALETTE_MATRIX_ARB */ - { 7751, 0x00008843 }, /* GL_CURRENT_PALETTE_MATRIX_OES */ - { 7781, 0x00008B8D }, /* GL_CURRENT_PROGRAM */ - { 7800, 0x00008865 }, /* GL_CURRENT_QUERY */ - { 7817, 0x00008865 }, /* GL_CURRENT_QUERY_ARB */ - { 7838, 0x00000B04 }, /* GL_CURRENT_RASTER_COLOR */ - { 7862, 0x00000B09 }, /* GL_CURRENT_RASTER_DISTANCE */ - { 7889, 0x00000B05 }, /* GL_CURRENT_RASTER_INDEX */ - { 7913, 0x00000B07 }, /* GL_CURRENT_RASTER_POSITION */ - { 7940, 0x00000B08 }, /* GL_CURRENT_RASTER_POSITION_VALID */ - { 7973, 0x0000845F }, /* GL_CURRENT_RASTER_SECONDARY_COLOR */ - { 8007, 0x00000B06 }, /* GL_CURRENT_RASTER_TEXTURE_COORDS */ - { 8040, 0x00008459 }, /* GL_CURRENT_SECONDARY_COLOR */ - { 8067, 0x00000B03 }, /* GL_CURRENT_TEXTURE_COORDS */ - { 8093, 0x00008626 }, /* GL_CURRENT_VERTEX_ATTRIB */ - { 8118, 0x00008626 }, /* GL_CURRENT_VERTEX_ATTRIB_ARB */ - { 8147, 0x000086A8 }, /* GL_CURRENT_WEIGHT_ARB */ - { 8169, 0x00000900 }, /* GL_CW */ - { 8175, 0x0000875B }, /* GL_DEBUG_ASSERT_MESA */ - { 8196, 0x00008759 }, /* GL_DEBUG_OBJECT_MESA */ - { 8217, 0x0000875A }, /* GL_DEBUG_PRINT_MESA */ - { 8237, 0x00002101 }, /* GL_DECAL */ - { 8246, 0x00001E03 }, /* GL_DECR */ - { 8254, 0x00008508 }, /* GL_DECR_WRAP */ - { 8267, 0x00008508 }, /* GL_DECR_WRAP_EXT */ - { 8284, 0x00008B80 }, /* GL_DELETE_STATUS */ - { 8301, 0x00001801 }, /* GL_DEPTH */ - { 8310, 0x000088F0 }, /* GL_DEPTH24_STENCIL8 */ - { 8330, 0x000088F0 }, /* GL_DEPTH24_STENCIL8_EXT */ - { 8354, 0x000088F0 }, /* GL_DEPTH24_STENCIL8_OES */ - { 8378, 0x00008D00 }, /* GL_DEPTH_ATTACHMENT */ - { 8398, 0x00008D00 }, /* GL_DEPTH_ATTACHMENT_EXT */ - { 8422, 0x00008D00 }, /* GL_DEPTH_ATTACHMENT_OES */ - { 8446, 0x00000D1F }, /* GL_DEPTH_BIAS */ - { 8460, 0x00000D56 }, /* GL_DEPTH_BITS */ - { 8474, 0x00008891 }, /* GL_DEPTH_BOUNDS_EXT */ - { 8494, 0x00008890 }, /* GL_DEPTH_BOUNDS_TEST_EXT */ - { 8519, 0x00008223 }, /* GL_DEPTH_BUFFER */ - { 8535, 0x00000100 }, /* GL_DEPTH_BUFFER_BIT */ - { 8555, 0x0000864F }, /* GL_DEPTH_CLAMP */ - { 8570, 0x0000864F }, /* GL_DEPTH_CLAMP_NV */ - { 8588, 0x00000B73 }, /* GL_DEPTH_CLEAR_VALUE */ - { 8609, 0x00001902 }, /* GL_DEPTH_COMPONENT */ - { 8628, 0x000081A5 }, /* GL_DEPTH_COMPONENT16 */ - { 8649, 0x000081A5 }, /* GL_DEPTH_COMPONENT16_ARB */ - { 8674, 0x000081A5 }, /* GL_DEPTH_COMPONENT16_OES */ - { 8699, 0x000081A5 }, /* GL_DEPTH_COMPONENT16_SGIX */ - { 8725, 0x000081A6 }, /* GL_DEPTH_COMPONENT24 */ - { 8746, 0x000081A6 }, /* GL_DEPTH_COMPONENT24_ARB */ - { 8771, 0x000081A6 }, /* GL_DEPTH_COMPONENT24_OES */ - { 8796, 0x000081A6 }, /* GL_DEPTH_COMPONENT24_SGIX */ - { 8822, 0x000081A7 }, /* GL_DEPTH_COMPONENT32 */ - { 8843, 0x000081A7 }, /* GL_DEPTH_COMPONENT32_ARB */ - { 8868, 0x000081A7 }, /* GL_DEPTH_COMPONENT32_OES */ - { 8893, 0x000081A7 }, /* GL_DEPTH_COMPONENT32_SGIX */ - { 8919, 0x00000B74 }, /* GL_DEPTH_FUNC */ - { 8933, 0x00000B70 }, /* GL_DEPTH_RANGE */ - { 8948, 0x00000D1E }, /* GL_DEPTH_SCALE */ - { 8963, 0x000084F9 }, /* GL_DEPTH_STENCIL */ - { 8980, 0x0000821A }, /* GL_DEPTH_STENCIL_ATTACHMENT */ - { 9008, 0x000084F9 }, /* GL_DEPTH_STENCIL_EXT */ - { 9029, 0x000084F9 }, /* GL_DEPTH_STENCIL_NV */ - { 9049, 0x000084F9 }, /* GL_DEPTH_STENCIL_OES */ - { 9070, 0x0000886F }, /* GL_DEPTH_STENCIL_TO_BGRA_NV */ - { 9098, 0x0000886E }, /* GL_DEPTH_STENCIL_TO_RGBA_NV */ - { 9126, 0x00000B71 }, /* GL_DEPTH_TEST */ - { 9140, 0x0000884B }, /* GL_DEPTH_TEXTURE_MODE */ - { 9162, 0x0000884B }, /* GL_DEPTH_TEXTURE_MODE_ARB */ - { 9188, 0x00000B72 }, /* GL_DEPTH_WRITEMASK */ - { 9207, 0x00001201 }, /* GL_DIFFUSE */ - { 9218, 0x00000BD0 }, /* GL_DITHER */ - { 9228, 0x00000A02 }, /* GL_DOMAIN */ - { 9238, 0x00001100 }, /* GL_DONT_CARE */ - { 9251, 0x000086AE }, /* GL_DOT3_RGB */ - { 9263, 0x000086AF }, /* GL_DOT3_RGBA */ - { 9276, 0x000086AF }, /* GL_DOT3_RGBA_ARB */ - { 9293, 0x00008741 }, /* GL_DOT3_RGBA_EXT */ - { 9310, 0x000086AE }, /* GL_DOT3_RGB_ARB */ - { 9326, 0x00008740 }, /* GL_DOT3_RGB_EXT */ - { 9342, 0x0000140A }, /* GL_DOUBLE */ - { 9352, 0x00000C32 }, /* GL_DOUBLEBUFFER */ - { 9368, 0x00000C01 }, /* GL_DRAW_BUFFER */ - { 9383, 0x00008825 }, /* GL_DRAW_BUFFER0 */ - { 9399, 0x00008825 }, /* GL_DRAW_BUFFER0_ARB */ - { 9419, 0x00008825 }, /* GL_DRAW_BUFFER0_ATI */ - { 9439, 0x00008825 }, /* GL_DRAW_BUFFER0_NV */ - { 9458, 0x00008826 }, /* GL_DRAW_BUFFER1 */ - { 9474, 0x0000882F }, /* GL_DRAW_BUFFER10 */ - { 9491, 0x0000882F }, /* GL_DRAW_BUFFER10_ARB */ - { 9512, 0x0000882F }, /* GL_DRAW_BUFFER10_ATI */ - { 9533, 0x0000882F }, /* GL_DRAW_BUFFER10_NV */ - { 9553, 0x00008830 }, /* GL_DRAW_BUFFER11 */ - { 9570, 0x00008830 }, /* GL_DRAW_BUFFER11_ARB */ - { 9591, 0x00008830 }, /* GL_DRAW_BUFFER11_ATI */ - { 9612, 0x00008830 }, /* GL_DRAW_BUFFER11_NV */ - { 9632, 0x00008831 }, /* GL_DRAW_BUFFER12 */ - { 9649, 0x00008831 }, /* GL_DRAW_BUFFER12_ARB */ - { 9670, 0x00008831 }, /* GL_DRAW_BUFFER12_ATI */ - { 9691, 0x00008831 }, /* GL_DRAW_BUFFER12_NV */ - { 9711, 0x00008832 }, /* GL_DRAW_BUFFER13 */ - { 9728, 0x00008832 }, /* GL_DRAW_BUFFER13_ARB */ - { 9749, 0x00008832 }, /* GL_DRAW_BUFFER13_ATI */ - { 9770, 0x00008832 }, /* GL_DRAW_BUFFER13_NV */ - { 9790, 0x00008833 }, /* GL_DRAW_BUFFER14 */ - { 9807, 0x00008833 }, /* GL_DRAW_BUFFER14_ARB */ - { 9828, 0x00008833 }, /* GL_DRAW_BUFFER14_ATI */ - { 9849, 0x00008833 }, /* GL_DRAW_BUFFER14_NV */ - { 9869, 0x00008834 }, /* GL_DRAW_BUFFER15 */ - { 9886, 0x00008834 }, /* GL_DRAW_BUFFER15_ARB */ - { 9907, 0x00008834 }, /* GL_DRAW_BUFFER15_ATI */ - { 9928, 0x00008834 }, /* GL_DRAW_BUFFER15_NV */ - { 9948, 0x00008826 }, /* GL_DRAW_BUFFER1_ARB */ - { 9968, 0x00008826 }, /* GL_DRAW_BUFFER1_ATI */ - { 9988, 0x00008826 }, /* GL_DRAW_BUFFER1_NV */ - { 10007, 0x00008827 }, /* GL_DRAW_BUFFER2 */ - { 10023, 0x00008827 }, /* GL_DRAW_BUFFER2_ARB */ - { 10043, 0x00008827 }, /* GL_DRAW_BUFFER2_ATI */ - { 10063, 0x00008827 }, /* GL_DRAW_BUFFER2_NV */ - { 10082, 0x00008828 }, /* GL_DRAW_BUFFER3 */ - { 10098, 0x00008828 }, /* GL_DRAW_BUFFER3_ARB */ - { 10118, 0x00008828 }, /* GL_DRAW_BUFFER3_ATI */ - { 10138, 0x00008828 }, /* GL_DRAW_BUFFER3_NV */ - { 10157, 0x00008829 }, /* GL_DRAW_BUFFER4 */ - { 10173, 0x00008829 }, /* GL_DRAW_BUFFER4_ARB */ - { 10193, 0x00008829 }, /* GL_DRAW_BUFFER4_ATI */ - { 10213, 0x00008829 }, /* GL_DRAW_BUFFER4_NV */ - { 10232, 0x0000882A }, /* GL_DRAW_BUFFER5 */ - { 10248, 0x0000882A }, /* GL_DRAW_BUFFER5_ARB */ - { 10268, 0x0000882A }, /* GL_DRAW_BUFFER5_ATI */ - { 10288, 0x0000882A }, /* GL_DRAW_BUFFER5_NV */ - { 10307, 0x0000882B }, /* GL_DRAW_BUFFER6 */ - { 10323, 0x0000882B }, /* GL_DRAW_BUFFER6_ARB */ - { 10343, 0x0000882B }, /* GL_DRAW_BUFFER6_ATI */ - { 10363, 0x0000882B }, /* GL_DRAW_BUFFER6_NV */ - { 10382, 0x0000882C }, /* GL_DRAW_BUFFER7 */ - { 10398, 0x0000882C }, /* GL_DRAW_BUFFER7_ARB */ - { 10418, 0x0000882C }, /* GL_DRAW_BUFFER7_ATI */ - { 10438, 0x0000882C }, /* GL_DRAW_BUFFER7_NV */ - { 10457, 0x0000882D }, /* GL_DRAW_BUFFER8 */ - { 10473, 0x0000882D }, /* GL_DRAW_BUFFER8_ARB */ - { 10493, 0x0000882D }, /* GL_DRAW_BUFFER8_ATI */ - { 10513, 0x0000882D }, /* GL_DRAW_BUFFER8_NV */ - { 10532, 0x0000882E }, /* GL_DRAW_BUFFER9 */ - { 10548, 0x0000882E }, /* GL_DRAW_BUFFER9_ARB */ - { 10568, 0x0000882E }, /* GL_DRAW_BUFFER9_ATI */ - { 10588, 0x0000882E }, /* GL_DRAW_BUFFER9_NV */ - { 10607, 0x00008CA9 }, /* GL_DRAW_FRAMEBUFFER */ - { 10627, 0x00008CA6 }, /* GL_DRAW_FRAMEBUFFER_BINDING */ - { 10655, 0x00008CA6 }, /* GL_DRAW_FRAMEBUFFER_BINDING_EXT */ - { 10687, 0x00008CA9 }, /* GL_DRAW_FRAMEBUFFER_EXT */ - { 10711, 0x00000705 }, /* GL_DRAW_PIXEL_TOKEN */ - { 10731, 0x00000304 }, /* GL_DST_ALPHA */ - { 10744, 0x00000306 }, /* GL_DST_COLOR */ - { 10757, 0x0000877A }, /* GL_DU8DV8_ATI */ - { 10771, 0x00008779 }, /* GL_DUDV_ATI */ - { 10783, 0x000088EA }, /* GL_DYNAMIC_COPY */ - { 10799, 0x000088EA }, /* GL_DYNAMIC_COPY_ARB */ - { 10819, 0x000088E8 }, /* GL_DYNAMIC_DRAW */ - { 10835, 0x000088E8 }, /* GL_DYNAMIC_DRAW_ARB */ - { 10855, 0x000088E9 }, /* GL_DYNAMIC_READ */ - { 10871, 0x000088E9 }, /* GL_DYNAMIC_READ_ARB */ - { 10891, 0x00000B43 }, /* GL_EDGE_FLAG */ - { 10904, 0x00008079 }, /* GL_EDGE_FLAG_ARRAY */ - { 10923, 0x0000889B }, /* GL_EDGE_FLAG_ARRAY_BUFFER_BINDING */ - { 10957, 0x0000889B }, /* GL_EDGE_FLAG_ARRAY_BUFFER_BINDING_ARB */ - { 10995, 0x00008093 }, /* GL_EDGE_FLAG_ARRAY_POINTER */ - { 11022, 0x0000808C }, /* GL_EDGE_FLAG_ARRAY_STRIDE */ - { 11048, 0x00008893 }, /* GL_ELEMENT_ARRAY_BUFFER */ - { 11072, 0x00008895 }, /* GL_ELEMENT_ARRAY_BUFFER_BINDING */ - { 11104, 0x00008895 }, /* GL_ELEMENT_ARRAY_BUFFER_BINDING_ARB */ - { 11140, 0x00001600 }, /* GL_EMISSION */ - { 11152, 0x00002000 }, /* GL_ENABLE_BIT */ - { 11166, 0x00000202 }, /* GL_EQUAL */ - { 11175, 0x00001509 }, /* GL_EQUIV */ - { 11184, 0x00008D64 }, /* GL_ETC1_RGB8_OES */ - { 11201, 0x00010000 }, /* GL_EVAL_BIT */ - { 11213, 0x00000800 }, /* GL_EXP */ - { 11220, 0x00000801 }, /* GL_EXP2 */ - { 11228, 0x00001F03 }, /* GL_EXTENSIONS */ - { 11242, 0x00002400 }, /* GL_EYE_LINEAR */ - { 11256, 0x00002502 }, /* GL_EYE_PLANE */ - { 11269, 0x0000855C }, /* GL_EYE_PLANE_ABSOLUTE_NV */ - { 11294, 0x0000855B }, /* GL_EYE_RADIAL_NV */ - { 11311, 0x00000000 }, /* GL_FALSE */ - { 11320, 0x00001101 }, /* GL_FASTEST */ - { 11331, 0x00001C01 }, /* GL_FEEDBACK */ - { 11343, 0x00000DF0 }, /* GL_FEEDBACK_BUFFER_POINTER */ - { 11370, 0x00000DF1 }, /* GL_FEEDBACK_BUFFER_SIZE */ - { 11394, 0x00000DF2 }, /* GL_FEEDBACK_BUFFER_TYPE */ - { 11418, 0x00001B02 }, /* GL_FILL */ - { 11426, 0x00008E4D }, /* GL_FIRST_VERTEX_CONVENTION */ - { 11453, 0x00008E4D }, /* GL_FIRST_VERTEX_CONVENTION_EXT */ - { 11484, 0x0000140C }, /* GL_FIXED */ - { 11493, 0x0000140C }, /* GL_FIXED_OES */ - { 11506, 0x0000891D }, /* GL_FIXED_ONLY */ - { 11520, 0x0000891D }, /* GL_FIXED_ONLY_ARB */ - { 11538, 0x00001D00 }, /* GL_FLAT */ - { 11546, 0x00001406 }, /* GL_FLOAT */ - { 11555, 0x00008B5A }, /* GL_FLOAT_MAT2 */ - { 11569, 0x00008B5A }, /* GL_FLOAT_MAT2_ARB */ - { 11587, 0x00008B65 }, /* GL_FLOAT_MAT2x3 */ - { 11603, 0x00008B66 }, /* GL_FLOAT_MAT2x4 */ - { 11619, 0x00008B5B }, /* GL_FLOAT_MAT3 */ - { 11633, 0x00008B5B }, /* GL_FLOAT_MAT3_ARB */ - { 11651, 0x00008B67 }, /* GL_FLOAT_MAT3x2 */ - { 11667, 0x00008B68 }, /* GL_FLOAT_MAT3x4 */ - { 11683, 0x00008B5C }, /* GL_FLOAT_MAT4 */ - { 11697, 0x00008B5C }, /* GL_FLOAT_MAT4_ARB */ - { 11715, 0x00008B69 }, /* GL_FLOAT_MAT4x2 */ - { 11731, 0x00008B6A }, /* GL_FLOAT_MAT4x3 */ - { 11747, 0x00008B50 }, /* GL_FLOAT_VEC2 */ - { 11761, 0x00008B50 }, /* GL_FLOAT_VEC2_ARB */ - { 11779, 0x00008B51 }, /* GL_FLOAT_VEC3 */ - { 11793, 0x00008B51 }, /* GL_FLOAT_VEC3_ARB */ - { 11811, 0x00008B52 }, /* GL_FLOAT_VEC4 */ - { 11825, 0x00008B52 }, /* GL_FLOAT_VEC4_ARB */ - { 11843, 0x00000B60 }, /* GL_FOG */ - { 11850, 0x00000080 }, /* GL_FOG_BIT */ - { 11861, 0x00000B66 }, /* GL_FOG_COLOR */ - { 11874, 0x00008451 }, /* GL_FOG_COORD */ - { 11887, 0x00008451 }, /* GL_FOG_COORDINATE */ - { 11905, 0x00008457 }, /* GL_FOG_COORDINATE_ARRAY */ - { 11929, 0x0000889D }, /* GL_FOG_COORDINATE_ARRAY_BUFFER_BINDING */ - { 11968, 0x0000889D }, /* GL_FOG_COORDINATE_ARRAY_BUFFER_BINDING_ARB */ - { 12011, 0x00008456 }, /* GL_FOG_COORDINATE_ARRAY_POINTER */ - { 12043, 0x00008455 }, /* GL_FOG_COORDINATE_ARRAY_STRIDE */ - { 12074, 0x00008454 }, /* GL_FOG_COORDINATE_ARRAY_TYPE */ - { 12103, 0x00008450 }, /* GL_FOG_COORDINATE_SOURCE */ - { 12128, 0x00008457 }, /* GL_FOG_COORD_ARRAY */ - { 12147, 0x0000889D }, /* GL_FOG_COORD_ARRAY_BUFFER_BINDING */ - { 12181, 0x00008456 }, /* GL_FOG_COORD_ARRAY_POINTER */ - { 12208, 0x00008455 }, /* GL_FOG_COORD_ARRAY_STRIDE */ - { 12234, 0x00008454 }, /* GL_FOG_COORD_ARRAY_TYPE */ - { 12258, 0x00008450 }, /* GL_FOG_COORD_SRC */ - { 12275, 0x00000B62 }, /* GL_FOG_DENSITY */ - { 12290, 0x0000855A }, /* GL_FOG_DISTANCE_MODE_NV */ - { 12314, 0x00000B64 }, /* GL_FOG_END */ - { 12325, 0x00000C54 }, /* GL_FOG_HINT */ - { 12337, 0x00000B61 }, /* GL_FOG_INDEX */ - { 12350, 0x00000B65 }, /* GL_FOG_MODE */ - { 12362, 0x00008198 }, /* GL_FOG_OFFSET_SGIX */ - { 12381, 0x00008199 }, /* GL_FOG_OFFSET_VALUE_SGIX */ - { 12406, 0x00000B63 }, /* GL_FOG_START */ - { 12419, 0x00008452 }, /* GL_FRAGMENT_DEPTH */ - { 12437, 0x00008804 }, /* GL_FRAGMENT_PROGRAM_ARB */ - { 12461, 0x00008B30 }, /* GL_FRAGMENT_SHADER */ - { 12480, 0x00008B30 }, /* GL_FRAGMENT_SHADER_ARB */ - { 12503, 0x00008B8B }, /* GL_FRAGMENT_SHADER_DERIVATIVE_HINT */ - { 12538, 0x00008B8B }, /* GL_FRAGMENT_SHADER_DERIVATIVE_HINT_OES */ - { 12577, 0x00008D40 }, /* GL_FRAMEBUFFER */ - { 12592, 0x00008215 }, /* GL_FRAMEBUFFER_ATTACHMENT_ALPHA_SIZE */ - { 12629, 0x00008214 }, /* GL_FRAMEBUFFER_ATTACHMENT_BLUE_SIZE */ - { 12665, 0x00008210 }, /* GL_FRAMEBUFFER_ATTACHMENT_COLOR_ENCODING */ - { 12706, 0x00008211 }, /* GL_FRAMEBUFFER_ATTACHMENT_COMPONENT_TYPE */ - { 12747, 0x00008216 }, /* GL_FRAMEBUFFER_ATTACHMENT_DEPTH_SIZE */ - { 12784, 0x00008213 }, /* GL_FRAMEBUFFER_ATTACHMENT_GREEN_SIZE */ - { 12821, 0x00008DA7 }, /* GL_FRAMEBUFFER_ATTACHMENT_LAYERED */ - { 12855, 0x00008DA7 }, /* GL_FRAMEBUFFER_ATTACHMENT_LAYERED_ARB */ - { 12893, 0x00008CD1 }, /* GL_FRAMEBUFFER_ATTACHMENT_OBJECT_NAME */ - { 12931, 0x00008CD1 }, /* GL_FRAMEBUFFER_ATTACHMENT_OBJECT_NAME_EXT */ - { 12973, 0x00008CD1 }, /* GL_FRAMEBUFFER_ATTACHMENT_OBJECT_NAME_OES */ - { 13015, 0x00008CD0 }, /* GL_FRAMEBUFFER_ATTACHMENT_OBJECT_TYPE */ - { 13053, 0x00008CD0 }, /* GL_FRAMEBUFFER_ATTACHMENT_OBJECT_TYPE_EXT */ - { 13095, 0x00008CD0 }, /* GL_FRAMEBUFFER_ATTACHMENT_OBJECT_TYPE_OES */ - { 13137, 0x00008212 }, /* GL_FRAMEBUFFER_ATTACHMENT_RED_SIZE */ - { 13172, 0x00008217 }, /* GL_FRAMEBUFFER_ATTACHMENT_STENCIL_SIZE */ - { 13211, 0x00008CD4 }, /* GL_FRAMEBUFFER_ATTACHMENT_TEXTURE_3D_ZOFFSET_EXT */ - { 13260, 0x00008CD4 }, /* GL_FRAMEBUFFER_ATTACHMENT_TEXTURE_3D_ZOFFSET_OES */ - { 13309, 0x00008CD3 }, /* GL_FRAMEBUFFER_ATTACHMENT_TEXTURE_CUBE_MAP_FACE */ - { 13357, 0x00008CD3 }, /* GL_FRAMEBUFFER_ATTACHMENT_TEXTURE_CUBE_MAP_FACE_EXT */ - { 13409, 0x00008CD3 }, /* GL_FRAMEBUFFER_ATTACHMENT_TEXTURE_CUBE_MAP_FACE_OES */ - { 13461, 0x00008CD4 }, /* GL_FRAMEBUFFER_ATTACHMENT_TEXTURE_LAYER */ - { 13501, 0x00008CD4 }, /* GL_FRAMEBUFFER_ATTACHMENT_TEXTURE_LAYER_EXT */ - { 13545, 0x00008CD2 }, /* GL_FRAMEBUFFER_ATTACHMENT_TEXTURE_LEVEL */ - { 13585, 0x00008CD2 }, /* GL_FRAMEBUFFER_ATTACHMENT_TEXTURE_LEVEL_EXT */ - { 13629, 0x00008CD2 }, /* GL_FRAMEBUFFER_ATTACHMENT_TEXTURE_LEVEL_OES */ - { 13673, 0x00008CA6 }, /* GL_FRAMEBUFFER_BINDING */ - { 13696, 0x00008CA6 }, /* GL_FRAMEBUFFER_BINDING_EXT */ - { 13723, 0x00008CA6 }, /* GL_FRAMEBUFFER_BINDING_OES */ - { 13750, 0x00008CD5 }, /* GL_FRAMEBUFFER_COMPLETE */ - { 13774, 0x00008CD5 }, /* GL_FRAMEBUFFER_COMPLETE_EXT */ - { 13802, 0x00008CD5 }, /* GL_FRAMEBUFFER_COMPLETE_OES */ - { 13830, 0x00008218 }, /* GL_FRAMEBUFFER_DEFAULT */ - { 13853, 0x00008D40 }, /* GL_FRAMEBUFFER_EXT */ - { 13872, 0x00008CD6 }, /* GL_FRAMEBUFFER_INCOMPLETE_ATTACHMENT */ - { 13909, 0x00008CD6 }, /* GL_FRAMEBUFFER_INCOMPLETE_ATTACHMENT_EXT */ - { 13950, 0x00008CD6 }, /* GL_FRAMEBUFFER_INCOMPLETE_ATTACHMENT_OES */ - { 13991, 0x00008CD9 }, /* GL_FRAMEBUFFER_INCOMPLETE_DIMENSIONS */ - { 14028, 0x00008CD9 }, /* GL_FRAMEBUFFER_INCOMPLETE_DIMENSIONS_EXT */ - { 14069, 0x00008CD9 }, /* GL_FRAMEBUFFER_INCOMPLETE_DIMENSIONS_OES */ - { 14110, 0x00008CDB }, /* GL_FRAMEBUFFER_INCOMPLETE_DRAW_BUFFER */ - { 14148, 0x00008CDB }, /* GL_FRAMEBUFFER_INCOMPLETE_DRAW_BUFFER_EXT */ - { 14190, 0x00008CDB }, /* GL_FRAMEBUFFER_INCOMPLETE_DRAW_BUFFER_OES */ - { 14232, 0x00008CD8 }, /* GL_FRAMEBUFFER_INCOMPLETE_DUPLICATE_ATTACHMENT_EXT */ - { 14283, 0x00008CDA }, /* GL_FRAMEBUFFER_INCOMPLETE_FORMATS_EXT */ - { 14321, 0x00008CDA }, /* GL_FRAMEBUFFER_INCOMPLETE_FORMATS_OES */ - { 14359, 0x00008DA9 }, /* GL_FRAMEBUFFER_INCOMPLETE_LAYER_COUNT_ARB */ - { 14401, 0x00008DA8 }, /* GL_FRAMEBUFFER_INCOMPLETE_LAYER_TARGETS */ - { 14441, 0x00008DA8 }, /* GL_FRAMEBUFFER_INCOMPLETE_LAYER_TARGETS_ARB */ - { 14485, 0x00008CD7 }, /* GL_FRAMEBUFFER_INCOMPLETE_MISSING_ATTACHMENT */ - { 14530, 0x00008CD7 }, /* GL_FRAMEBUFFER_INCOMPLETE_MISSING_ATTACHMENT_EXT */ - { 14579, 0x00008CD7 }, /* GL_FRAMEBUFFER_INCOMPLETE_MISSING_ATTACHMENT_OES */ - { 14628, 0x00008D56 }, /* GL_FRAMEBUFFER_INCOMPLETE_MULTISAMPLE */ - { 14666, 0x00008D56 }, /* GL_FRAMEBUFFER_INCOMPLETE_MULTISAMPLE_EXT */ - { 14708, 0x00008CDC }, /* GL_FRAMEBUFFER_INCOMPLETE_READ_BUFFER */ - { 14746, 0x00008CDC }, /* GL_FRAMEBUFFER_INCOMPLETE_READ_BUFFER_EXT */ - { 14788, 0x00008CDC }, /* GL_FRAMEBUFFER_INCOMPLETE_READ_BUFFER_OES */ - { 14830, 0x00008D40 }, /* GL_FRAMEBUFFER_OES */ - { 14849, 0x00008CDE }, /* GL_FRAMEBUFFER_STATUS_ERROR_EXT */ - { 14881, 0x00008219 }, /* GL_FRAMEBUFFER_UNDEFINED */ - { 14906, 0x00008CDD }, /* GL_FRAMEBUFFER_UNSUPPORTED */ - { 14933, 0x00008CDD }, /* GL_FRAMEBUFFER_UNSUPPORTED_EXT */ - { 14964, 0x00008CDD }, /* GL_FRAMEBUFFER_UNSUPPORTED_OES */ - { 14995, 0x00000404 }, /* GL_FRONT */ - { 15004, 0x00000408 }, /* GL_FRONT_AND_BACK */ - { 15022, 0x00000B46 }, /* GL_FRONT_FACE */ - { 15036, 0x00000400 }, /* GL_FRONT_LEFT */ - { 15050, 0x00000401 }, /* GL_FRONT_RIGHT */ - { 15065, 0x00008006 }, /* GL_FUNC_ADD */ - { 15077, 0x00008006 }, /* GL_FUNC_ADD_EXT */ - { 15093, 0x00008006 }, /* GL_FUNC_ADD_OES */ - { 15109, 0x0000800B }, /* GL_FUNC_REVERSE_SUBTRACT */ - { 15134, 0x0000800B }, /* GL_FUNC_REVERSE_SUBTRACT_EXT */ - { 15163, 0x0000800B }, /* GL_FUNC_REVERSE_SUBTRACT_OES */ - { 15192, 0x0000800A }, /* GL_FUNC_SUBTRACT */ - { 15209, 0x0000800A }, /* GL_FUNC_SUBTRACT_EXT */ - { 15230, 0x0000800A }, /* GL_FUNC_SUBTRACT_OES */ - { 15251, 0x00008191 }, /* GL_GENERATE_MIPMAP */ - { 15270, 0x00008192 }, /* GL_GENERATE_MIPMAP_HINT */ - { 15294, 0x00008192 }, /* GL_GENERATE_MIPMAP_HINT_SGIS */ - { 15323, 0x00008191 }, /* GL_GENERATE_MIPMAP_SGIS */ - { 15347, 0x00008917 }, /* GL_GEOMETRY_INPUT_TYPE */ - { 15370, 0x00008DDB }, /* GL_GEOMETRY_INPUT_TYPE_ARB */ - { 15397, 0x00008918 }, /* GL_GEOMETRY_OUTPUT_TYPE */ - { 15421, 0x00008DDC }, /* GL_GEOMETRY_OUTPUT_TYPE_ARB */ - { 15449, 0x00008DD9 }, /* GL_GEOMETRY_SHADER */ - { 15468, 0x00008DD9 }, /* GL_GEOMETRY_SHADER_ARB */ - { 15491, 0x00008916 }, /* GL_GEOMETRY_VERTICES_OUT */ - { 15516, 0x00008DDA }, /* GL_GEOMETRY_VERTICES_OUT_ARB */ - { 15545, 0x00000206 }, /* GL_GEQUAL */ - { 15555, 0x0000912F }, /* GL_GL_TEXTURE_IMMUTABLE_FORMAT */ - { 15586, 0x00000204 }, /* GL_GREATER */ - { 15597, 0x00001904 }, /* GL_GREEN */ - { 15606, 0x00000D19 }, /* GL_GREEN_BIAS */ - { 15620, 0x00000D53 }, /* GL_GREEN_BITS */ - { 15634, 0x00008D95 }, /* GL_GREEN_INTEGER */ - { 15651, 0x00008D95 }, /* GL_GREEN_INTEGER_EXT */ - { 15672, 0x00000D18 }, /* GL_GREEN_SCALE */ - { 15687, 0x00008253 }, /* GL_GUILTY_CONTEXT_RESET_ARB */ - { 15715, 0x0000140B }, /* GL_HALF_FLOAT */ - { 15729, 0x00008D61 }, /* GL_HALF_FLOAT_OES */ - { 15747, 0x00008DF2 }, /* GL_HIGH_FLOAT */ - { 15761, 0x00008DF5 }, /* GL_HIGH_INT */ - { 15773, 0x00008000 }, /* GL_HINT_BIT */ - { 15785, 0x00008024 }, /* GL_HISTOGRAM */ - { 15798, 0x0000802B }, /* GL_HISTOGRAM_ALPHA_SIZE */ - { 15822, 0x0000802B }, /* GL_HISTOGRAM_ALPHA_SIZE_EXT */ - { 15850, 0x0000802A }, /* GL_HISTOGRAM_BLUE_SIZE */ - { 15873, 0x0000802A }, /* GL_HISTOGRAM_BLUE_SIZE_EXT */ - { 15900, 0x00008024 }, /* GL_HISTOGRAM_EXT */ - { 15917, 0x00008027 }, /* GL_HISTOGRAM_FORMAT */ - { 15937, 0x00008027 }, /* GL_HISTOGRAM_FORMAT_EXT */ - { 15961, 0x00008029 }, /* GL_HISTOGRAM_GREEN_SIZE */ - { 15985, 0x00008029 }, /* GL_HISTOGRAM_GREEN_SIZE_EXT */ - { 16013, 0x0000802C }, /* GL_HISTOGRAM_LUMINANCE_SIZE */ - { 16041, 0x0000802C }, /* GL_HISTOGRAM_LUMINANCE_SIZE_EXT */ - { 16073, 0x00008028 }, /* GL_HISTOGRAM_RED_SIZE */ - { 16095, 0x00008028 }, /* GL_HISTOGRAM_RED_SIZE_EXT */ - { 16121, 0x0000802D }, /* GL_HISTOGRAM_SINK */ - { 16139, 0x0000802D }, /* GL_HISTOGRAM_SINK_EXT */ - { 16161, 0x00008026 }, /* GL_HISTOGRAM_WIDTH */ - { 16180, 0x00008026 }, /* GL_HISTOGRAM_WIDTH_EXT */ - { 16203, 0x0000862A }, /* GL_IDENTITY_NV */ - { 16218, 0x00008150 }, /* GL_IGNORE_BORDER_HP */ - { 16238, 0x00008B9B }, /* GL_IMPLEMENTATION_COLOR_READ_FORMAT */ - { 16274, 0x00008B9B }, /* GL_IMPLEMENTATION_COLOR_READ_FORMAT_OES */ - { 16314, 0x00008B9A }, /* GL_IMPLEMENTATION_COLOR_READ_TYPE */ - { 16348, 0x00008B9A }, /* GL_IMPLEMENTATION_COLOR_READ_TYPE_OES */ - { 16386, 0x00001E02 }, /* GL_INCR */ - { 16394, 0x00008507 }, /* GL_INCR_WRAP */ - { 16407, 0x00008507 }, /* GL_INCR_WRAP_EXT */ - { 16424, 0x00008222 }, /* GL_INDEX */ - { 16433, 0x00008077 }, /* GL_INDEX_ARRAY */ - { 16448, 0x00008899 }, /* GL_INDEX_ARRAY_BUFFER_BINDING */ - { 16478, 0x00008899 }, /* GL_INDEX_ARRAY_BUFFER_BINDING_ARB */ - { 16512, 0x00008091 }, /* GL_INDEX_ARRAY_POINTER */ - { 16535, 0x00008086 }, /* GL_INDEX_ARRAY_STRIDE */ - { 16557, 0x00008085 }, /* GL_INDEX_ARRAY_TYPE */ - { 16577, 0x00000D51 }, /* GL_INDEX_BITS */ - { 16591, 0x00000C20 }, /* GL_INDEX_CLEAR_VALUE */ - { 16612, 0x00000BF1 }, /* GL_INDEX_LOGIC_OP */ - { 16630, 0x00000C30 }, /* GL_INDEX_MODE */ - { 16644, 0x00000D13 }, /* GL_INDEX_OFFSET */ - { 16660, 0x00000D12 }, /* GL_INDEX_SHIFT */ - { 16675, 0x00000C21 }, /* GL_INDEX_WRITEMASK */ - { 16694, 0x00008B84 }, /* GL_INFO_LOG_LENGTH */ - { 16713, 0x00008254 }, /* GL_INNOCENT_CONTEXT_RESET_ARB */ - { 16743, 0x00001404 }, /* GL_INT */ - { 16750, 0x00008049 }, /* GL_INTENSITY */ - { 16763, 0x0000804C }, /* GL_INTENSITY12 */ - { 16778, 0x0000804C }, /* GL_INTENSITY12_EXT */ - { 16797, 0x0000804D }, /* GL_INTENSITY16 */ - { 16812, 0x00008D8B }, /* GL_INTENSITY16I_EXT */ - { 16832, 0x00008D79 }, /* GL_INTENSITY16UI_EXT */ - { 16853, 0x0000804D }, /* GL_INTENSITY16_EXT */ - { 16872, 0x00008D85 }, /* GL_INTENSITY32I_EXT */ - { 16892, 0x00008D73 }, /* GL_INTENSITY32UI_EXT */ - { 16913, 0x0000804A }, /* GL_INTENSITY4 */ - { 16927, 0x0000804A }, /* GL_INTENSITY4_EXT */ - { 16945, 0x0000804B }, /* GL_INTENSITY8 */ - { 16959, 0x00008D91 }, /* GL_INTENSITY8I_EXT */ - { 16978, 0x00008D7F }, /* GL_INTENSITY8UI_EXT */ - { 16998, 0x0000804B }, /* GL_INTENSITY8_EXT */ - { 17016, 0x00008049 }, /* GL_INTENSITY_EXT */ - { 17033, 0x00008C8C }, /* GL_INTERLEAVED_ATTRIBS */ - { 17056, 0x00008C8C }, /* GL_INTERLEAVED_ATTRIBS_EXT */ - { 17083, 0x00008575 }, /* GL_INTERPOLATE */ - { 17098, 0x00008575 }, /* GL_INTERPOLATE_ARB */ - { 17117, 0x00008575 }, /* GL_INTERPOLATE_EXT */ - { 17136, 0x00008DF7 }, /* GL_INT_10_10_10_2_OES */ - { 17158, 0x00008D9F }, /* GL_INT_2_10_10_10_REV */ - { 17180, 0x00008DC9 }, /* GL_INT_SAMPLER_1D */ - { 17198, 0x00008DCE }, /* GL_INT_SAMPLER_1D_ARRAY */ - { 17222, 0x00008DCE }, /* GL_INT_SAMPLER_1D_ARRAY_EXT */ - { 17250, 0x00008DC9 }, /* GL_INT_SAMPLER_1D_EXT */ - { 17272, 0x00008DCA }, /* GL_INT_SAMPLER_2D */ - { 17290, 0x00008DCF }, /* GL_INT_SAMPLER_2D_ARRAY */ - { 17314, 0x00008DCF }, /* GL_INT_SAMPLER_2D_ARRAY_EXT */ - { 17342, 0x00008DCA }, /* GL_INT_SAMPLER_2D_EXT */ - { 17364, 0x00008DCD }, /* GL_INT_SAMPLER_2D_RECT */ - { 17387, 0x00008DCD }, /* GL_INT_SAMPLER_2D_RECT_EXT */ - { 17414, 0x00008DCB }, /* GL_INT_SAMPLER_3D */ - { 17432, 0x00008DCB }, /* GL_INT_SAMPLER_3D_EXT */ - { 17454, 0x00008DD0 }, /* GL_INT_SAMPLER_BUFFER */ - { 17476, 0x00008DD0 }, /* GL_INT_SAMPLER_BUFFER_EXT */ - { 17502, 0x00008DCC }, /* GL_INT_SAMPLER_CUBE */ - { 17522, 0x00008DCC }, /* GL_INT_SAMPLER_CUBE_EXT */ - { 17546, 0x00008B53 }, /* GL_INT_VEC2 */ - { 17558, 0x00008B53 }, /* GL_INT_VEC2_ARB */ - { 17574, 0x00008B54 }, /* GL_INT_VEC3 */ - { 17586, 0x00008B54 }, /* GL_INT_VEC3_ARB */ - { 17602, 0x00008B55 }, /* GL_INT_VEC4 */ - { 17614, 0x00008B55 }, /* GL_INT_VEC4_ARB */ - { 17630, 0x00000500 }, /* GL_INVALID_ENUM */ - { 17646, 0x00000506 }, /* GL_INVALID_FRAMEBUFFER_OPERATION */ - { 17679, 0x00000506 }, /* GL_INVALID_FRAMEBUFFER_OPERATION_EXT */ - { 17716, 0x00000506 }, /* GL_INVALID_FRAMEBUFFER_OPERATION_OES */ - { 17753, 0x00000502 }, /* GL_INVALID_OPERATION */ - { 17774, 0x00000501 }, /* GL_INVALID_VALUE */ - { 17791, 0x0000862B }, /* GL_INVERSE_NV */ - { 17805, 0x0000862D }, /* GL_INVERSE_TRANSPOSE_NV */ - { 17829, 0x0000150A }, /* GL_INVERT */ - { 17839, 0x00001E00 }, /* GL_KEEP */ - { 17847, 0x00008E4E }, /* GL_LAST_VERTEX_CONVENTION */ - { 17873, 0x00008E4E }, /* GL_LAST_VERTEX_CONVENTION_EXT */ - { 17903, 0x00000406 }, /* GL_LEFT */ - { 17911, 0x00000203 }, /* GL_LEQUAL */ - { 17921, 0x00000201 }, /* GL_LESS */ - { 17929, 0x00004000 }, /* GL_LIGHT0 */ - { 17939, 0x00004001 }, /* GL_LIGHT1 */ - { 17949, 0x00004002 }, /* GL_LIGHT2 */ - { 17959, 0x00004003 }, /* GL_LIGHT3 */ - { 17969, 0x00004004 }, /* GL_LIGHT4 */ - { 17979, 0x00004005 }, /* GL_LIGHT5 */ - { 17989, 0x00004006 }, /* GL_LIGHT6 */ - { 17999, 0x00004007 }, /* GL_LIGHT7 */ - { 18009, 0x00000B50 }, /* GL_LIGHTING */ - { 18021, 0x00000040 }, /* GL_LIGHTING_BIT */ - { 18037, 0x00000B53 }, /* GL_LIGHT_MODEL_AMBIENT */ - { 18060, 0x000081F8 }, /* GL_LIGHT_MODEL_COLOR_CONTROL */ - { 18089, 0x000081F8 }, /* GL_LIGHT_MODEL_COLOR_CONTROL_EXT */ - { 18122, 0x00000B51 }, /* GL_LIGHT_MODEL_LOCAL_VIEWER */ - { 18150, 0x00000B52 }, /* GL_LIGHT_MODEL_TWO_SIDE */ - { 18174, 0x00001B01 }, /* GL_LINE */ - { 18182, 0x00002601 }, /* GL_LINEAR */ - { 18192, 0x00001208 }, /* GL_LINEAR_ATTENUATION */ - { 18214, 0x00008170 }, /* GL_LINEAR_CLIPMAP_LINEAR_SGIX */ - { 18244, 0x0000844F }, /* GL_LINEAR_CLIPMAP_NEAREST_SGIX */ - { 18275, 0x00002703 }, /* GL_LINEAR_MIPMAP_LINEAR */ - { 18299, 0x00002701 }, /* GL_LINEAR_MIPMAP_NEAREST */ - { 18324, 0x00000001 }, /* GL_LINES */ - { 18333, 0x0000000A }, /* GL_LINES_ADJACENCY */ - { 18352, 0x0000000A }, /* GL_LINES_ADJACENCY_ARB */ - { 18375, 0x00000004 }, /* GL_LINE_BIT */ - { 18387, 0x00000002 }, /* GL_LINE_LOOP */ - { 18400, 0x00000707 }, /* GL_LINE_RESET_TOKEN */ - { 18420, 0x00000B20 }, /* GL_LINE_SMOOTH */ - { 18435, 0x00000C52 }, /* GL_LINE_SMOOTH_HINT */ - { 18455, 0x00000B24 }, /* GL_LINE_STIPPLE */ - { 18471, 0x00000B25 }, /* GL_LINE_STIPPLE_PATTERN */ - { 18495, 0x00000B26 }, /* GL_LINE_STIPPLE_REPEAT */ - { 18518, 0x00000003 }, /* GL_LINE_STRIP */ - { 18532, 0x0000000B }, /* GL_LINE_STRIP_ADJACENCY */ - { 18556, 0x0000000B }, /* GL_LINE_STRIP_ADJACENCY_ARB */ - { 18584, 0x00000702 }, /* GL_LINE_TOKEN */ - { 18598, 0x00000B21 }, /* GL_LINE_WIDTH */ - { 18612, 0x00000B23 }, /* GL_LINE_WIDTH_GRANULARITY */ - { 18638, 0x00000B22 }, /* GL_LINE_WIDTH_RANGE */ - { 18658, 0x00008B82 }, /* GL_LINK_STATUS */ - { 18673, 0x00000B32 }, /* GL_LIST_BASE */ - { 18686, 0x00020000 }, /* GL_LIST_BIT */ - { 18698, 0x00000B33 }, /* GL_LIST_INDEX */ - { 18712, 0x00000B30 }, /* GL_LIST_MODE */ - { 18725, 0x00000101 }, /* GL_LOAD */ - { 18733, 0x00000BF1 }, /* GL_LOGIC_OP */ - { 18745, 0x00000BF0 }, /* GL_LOGIC_OP_MODE */ - { 18762, 0x00008252 }, /* GL_LOSE_CONTEXT_ON_RESET_ARB */ - { 18791, 0x00008CA1 }, /* GL_LOWER_LEFT */ - { 18805, 0x00008DF0 }, /* GL_LOW_FLOAT */ - { 18818, 0x00008DF3 }, /* GL_LOW_INT */ - { 18829, 0x00001909 }, /* GL_LUMINANCE */ - { 18842, 0x00008041 }, /* GL_LUMINANCE12 */ - { 18857, 0x00008047 }, /* GL_LUMINANCE12_ALPHA12 */ - { 18880, 0x00008047 }, /* GL_LUMINANCE12_ALPHA12_EXT */ - { 18907, 0x00008046 }, /* GL_LUMINANCE12_ALPHA4 */ - { 18929, 0x00008046 }, /* GL_LUMINANCE12_ALPHA4_EXT */ - { 18955, 0x00008041 }, /* GL_LUMINANCE12_EXT */ - { 18974, 0x00008042 }, /* GL_LUMINANCE16 */ - { 18989, 0x00008D8C }, /* GL_LUMINANCE16I_EXT */ - { 19009, 0x00008D7A }, /* GL_LUMINANCE16UI_EXT */ - { 19030, 0x00008048 }, /* GL_LUMINANCE16_ALPHA16 */ - { 19053, 0x00008048 }, /* GL_LUMINANCE16_ALPHA16_EXT */ - { 19080, 0x00008042 }, /* GL_LUMINANCE16_EXT */ - { 19099, 0x00008D86 }, /* GL_LUMINANCE32I_EXT */ - { 19119, 0x00008D74 }, /* GL_LUMINANCE32UI_EXT */ - { 19140, 0x0000803F }, /* GL_LUMINANCE4 */ - { 19154, 0x00008043 }, /* GL_LUMINANCE4_ALPHA4 */ - { 19175, 0x00008043 }, /* GL_LUMINANCE4_ALPHA4_EXT */ - { 19200, 0x0000803F }, /* GL_LUMINANCE4_EXT */ - { 19218, 0x00008044 }, /* GL_LUMINANCE6_ALPHA2 */ - { 19239, 0x00008044 }, /* GL_LUMINANCE6_ALPHA2_EXT */ - { 19264, 0x00008040 }, /* GL_LUMINANCE8 */ - { 19278, 0x00008D92 }, /* GL_LUMINANCE8I_EXT */ - { 19297, 0x00008D80 }, /* GL_LUMINANCE8UI_EXT */ - { 19317, 0x00008045 }, /* GL_LUMINANCE8_ALPHA8 */ - { 19338, 0x00008045 }, /* GL_LUMINANCE8_ALPHA8_EXT */ - { 19363, 0x00008040 }, /* GL_LUMINANCE8_EXT */ - { 19381, 0x0000190A }, /* GL_LUMINANCE_ALPHA */ - { 19400, 0x00008D8D }, /* GL_LUMINANCE_ALPHA16I_EXT */ - { 19426, 0x00008D7B }, /* GL_LUMINANCE_ALPHA16UI_EXT */ - { 19453, 0x00008D87 }, /* GL_LUMINANCE_ALPHA32I_EXT */ - { 19479, 0x00008D75 }, /* GL_LUMINANCE_ALPHA32UI_EXT */ - { 19506, 0x00008D93 }, /* GL_LUMINANCE_ALPHA8I_EXT */ - { 19531, 0x00008D81 }, /* GL_LUMINANCE_ALPHA8UI_EXT */ - { 19557, 0x00008D9D }, /* GL_LUMINANCE_ALPHA_INTEGER_EXT */ - { 19588, 0x00008D9C }, /* GL_LUMINANCE_INTEGER_EXT */ - { 19613, 0x0000821B }, /* GL_MAJOR_VERSION */ - { 19630, 0x00000D90 }, /* GL_MAP1_COLOR_4 */ - { 19646, 0x00000DD0 }, /* GL_MAP1_GRID_DOMAIN */ - { 19666, 0x00000DD1 }, /* GL_MAP1_GRID_SEGMENTS */ - { 19688, 0x00000D91 }, /* GL_MAP1_INDEX */ - { 19702, 0x00000D92 }, /* GL_MAP1_NORMAL */ - { 19717, 0x00000D93 }, /* GL_MAP1_TEXTURE_COORD_1 */ - { 19741, 0x00000D94 }, /* GL_MAP1_TEXTURE_COORD_2 */ - { 19765, 0x00000D95 }, /* GL_MAP1_TEXTURE_COORD_3 */ - { 19789, 0x00000D96 }, /* GL_MAP1_TEXTURE_COORD_4 */ - { 19813, 0x00000D97 }, /* GL_MAP1_VERTEX_3 */ - { 19830, 0x00000D98 }, /* GL_MAP1_VERTEX_4 */ - { 19847, 0x00008660 }, /* GL_MAP1_VERTEX_ATTRIB0_4_NV */ - { 19875, 0x0000866A }, /* GL_MAP1_VERTEX_ATTRIB10_4_NV */ - { 19904, 0x0000866B }, /* GL_MAP1_VERTEX_ATTRIB11_4_NV */ - { 19933, 0x0000866C }, /* GL_MAP1_VERTEX_ATTRIB12_4_NV */ - { 19962, 0x0000866D }, /* GL_MAP1_VERTEX_ATTRIB13_4_NV */ - { 19991, 0x0000866E }, /* GL_MAP1_VERTEX_ATTRIB14_4_NV */ - { 20020, 0x0000866F }, /* GL_MAP1_VERTEX_ATTRIB15_4_NV */ - { 20049, 0x00008661 }, /* GL_MAP1_VERTEX_ATTRIB1_4_NV */ - { 20077, 0x00008662 }, /* GL_MAP1_VERTEX_ATTRIB2_4_NV */ - { 20105, 0x00008663 }, /* GL_MAP1_VERTEX_ATTRIB3_4_NV */ - { 20133, 0x00008664 }, /* GL_MAP1_VERTEX_ATTRIB4_4_NV */ - { 20161, 0x00008665 }, /* GL_MAP1_VERTEX_ATTRIB5_4_NV */ - { 20189, 0x00008666 }, /* GL_MAP1_VERTEX_ATTRIB6_4_NV */ - { 20217, 0x00008667 }, /* GL_MAP1_VERTEX_ATTRIB7_4_NV */ - { 20245, 0x00008668 }, /* GL_MAP1_VERTEX_ATTRIB8_4_NV */ - { 20273, 0x00008669 }, /* GL_MAP1_VERTEX_ATTRIB9_4_NV */ - { 20301, 0x00000DB0 }, /* GL_MAP2_COLOR_4 */ - { 20317, 0x00000DD2 }, /* GL_MAP2_GRID_DOMAIN */ - { 20337, 0x00000DD3 }, /* GL_MAP2_GRID_SEGMENTS */ - { 20359, 0x00000DB1 }, /* GL_MAP2_INDEX */ - { 20373, 0x00000DB2 }, /* GL_MAP2_NORMAL */ - { 20388, 0x00000DB3 }, /* GL_MAP2_TEXTURE_COORD_1 */ - { 20412, 0x00000DB4 }, /* GL_MAP2_TEXTURE_COORD_2 */ - { 20436, 0x00000DB5 }, /* GL_MAP2_TEXTURE_COORD_3 */ - { 20460, 0x00000DB6 }, /* GL_MAP2_TEXTURE_COORD_4 */ - { 20484, 0x00000DB7 }, /* GL_MAP2_VERTEX_3 */ - { 20501, 0x00000DB8 }, /* GL_MAP2_VERTEX_4 */ - { 20518, 0x00008670 }, /* GL_MAP2_VERTEX_ATTRIB0_4_NV */ - { 20546, 0x0000867A }, /* GL_MAP2_VERTEX_ATTRIB10_4_NV */ - { 20575, 0x0000867B }, /* GL_MAP2_VERTEX_ATTRIB11_4_NV */ - { 20604, 0x0000867C }, /* GL_MAP2_VERTEX_ATTRIB12_4_NV */ - { 20633, 0x0000867D }, /* GL_MAP2_VERTEX_ATTRIB13_4_NV */ - { 20662, 0x0000867E }, /* GL_MAP2_VERTEX_ATTRIB14_4_NV */ - { 20691, 0x0000867F }, /* GL_MAP2_VERTEX_ATTRIB15_4_NV */ - { 20720, 0x00008671 }, /* GL_MAP2_VERTEX_ATTRIB1_4_NV */ - { 20748, 0x00008672 }, /* GL_MAP2_VERTEX_ATTRIB2_4_NV */ - { 20776, 0x00008673 }, /* GL_MAP2_VERTEX_ATTRIB3_4_NV */ - { 20804, 0x00008674 }, /* GL_MAP2_VERTEX_ATTRIB4_4_NV */ - { 20832, 0x00008675 }, /* GL_MAP2_VERTEX_ATTRIB5_4_NV */ - { 20860, 0x00008676 }, /* GL_MAP2_VERTEX_ATTRIB6_4_NV */ - { 20888, 0x00008677 }, /* GL_MAP2_VERTEX_ATTRIB7_4_NV */ - { 20916, 0x00008678 }, /* GL_MAP2_VERTEX_ATTRIB8_4_NV */ - { 20944, 0x00008679 }, /* GL_MAP2_VERTEX_ATTRIB9_4_NV */ - { 20972, 0x00000D10 }, /* GL_MAP_COLOR */ - { 20985, 0x00000010 }, /* GL_MAP_FLUSH_EXPLICIT_BIT */ - { 21011, 0x00000008 }, /* GL_MAP_INVALIDATE_BUFFER_BIT */ - { 21040, 0x00000004 }, /* GL_MAP_INVALIDATE_RANGE_BIT */ - { 21068, 0x00000001 }, /* GL_MAP_READ_BIT */ - { 21084, 0x00000D11 }, /* GL_MAP_STENCIL */ - { 21099, 0x00000020 }, /* GL_MAP_UNSYNCHRONIZED_BIT */ - { 21125, 0x00000002 }, /* GL_MAP_WRITE_BIT */ - { 21142, 0x000088C0 }, /* GL_MATRIX0_ARB */ - { 21157, 0x00008630 }, /* GL_MATRIX0_NV */ - { 21171, 0x000088CA }, /* GL_MATRIX10_ARB */ - { 21187, 0x000088CB }, /* GL_MATRIX11_ARB */ - { 21203, 0x000088CC }, /* GL_MATRIX12_ARB */ - { 21219, 0x000088CD }, /* GL_MATRIX13_ARB */ - { 21235, 0x000088CE }, /* GL_MATRIX14_ARB */ - { 21251, 0x000088CF }, /* GL_MATRIX15_ARB */ - { 21267, 0x000088D0 }, /* GL_MATRIX16_ARB */ - { 21283, 0x000088D1 }, /* GL_MATRIX17_ARB */ - { 21299, 0x000088D2 }, /* GL_MATRIX18_ARB */ - { 21315, 0x000088D3 }, /* GL_MATRIX19_ARB */ - { 21331, 0x000088C1 }, /* GL_MATRIX1_ARB */ - { 21346, 0x00008631 }, /* GL_MATRIX1_NV */ - { 21360, 0x000088D4 }, /* GL_MATRIX20_ARB */ - { 21376, 0x000088D5 }, /* GL_MATRIX21_ARB */ - { 21392, 0x000088D6 }, /* GL_MATRIX22_ARB */ - { 21408, 0x000088D7 }, /* GL_MATRIX23_ARB */ - { 21424, 0x000088D8 }, /* GL_MATRIX24_ARB */ - { 21440, 0x000088D9 }, /* GL_MATRIX25_ARB */ - { 21456, 0x000088DA }, /* GL_MATRIX26_ARB */ - { 21472, 0x000088DB }, /* GL_MATRIX27_ARB */ - { 21488, 0x000088DC }, /* GL_MATRIX28_ARB */ - { 21504, 0x000088DD }, /* GL_MATRIX29_ARB */ - { 21520, 0x000088C2 }, /* GL_MATRIX2_ARB */ - { 21535, 0x00008632 }, /* GL_MATRIX2_NV */ - { 21549, 0x000088DE }, /* GL_MATRIX30_ARB */ - { 21565, 0x000088DF }, /* GL_MATRIX31_ARB */ - { 21581, 0x000088C3 }, /* GL_MATRIX3_ARB */ - { 21596, 0x00008633 }, /* GL_MATRIX3_NV */ - { 21610, 0x000088C4 }, /* GL_MATRIX4_ARB */ - { 21625, 0x00008634 }, /* GL_MATRIX4_NV */ - { 21639, 0x000088C5 }, /* GL_MATRIX5_ARB */ - { 21654, 0x00008635 }, /* GL_MATRIX5_NV */ - { 21668, 0x000088C6 }, /* GL_MATRIX6_ARB */ - { 21683, 0x00008636 }, /* GL_MATRIX6_NV */ - { 21697, 0x000088C7 }, /* GL_MATRIX7_ARB */ - { 21712, 0x00008637 }, /* GL_MATRIX7_NV */ - { 21726, 0x000088C8 }, /* GL_MATRIX8_ARB */ - { 21741, 0x000088C9 }, /* GL_MATRIX9_ARB */ - { 21756, 0x00008844 }, /* GL_MATRIX_INDEX_ARRAY_ARB */ - { 21782, 0x00008B9E }, /* GL_MATRIX_INDEX_ARRAY_BUFFER_BINDING_OES */ - { 21823, 0x00008844 }, /* GL_MATRIX_INDEX_ARRAY_OES */ - { 21849, 0x00008849 }, /* GL_MATRIX_INDEX_ARRAY_POINTER_ARB */ - { 21883, 0x00008849 }, /* GL_MATRIX_INDEX_ARRAY_POINTER_OES */ - { 21917, 0x00008846 }, /* GL_MATRIX_INDEX_ARRAY_SIZE_ARB */ - { 21948, 0x00008846 }, /* GL_MATRIX_INDEX_ARRAY_SIZE_OES */ - { 21979, 0x00008848 }, /* GL_MATRIX_INDEX_ARRAY_STRIDE_ARB */ - { 22012, 0x00008848 }, /* GL_MATRIX_INDEX_ARRAY_STRIDE_OES */ - { 22045, 0x00008847 }, /* GL_MATRIX_INDEX_ARRAY_TYPE_ARB */ - { 22076, 0x00008847 }, /* GL_MATRIX_INDEX_ARRAY_TYPE_OES */ - { 22107, 0x00000BA0 }, /* GL_MATRIX_MODE */ - { 22122, 0x00008840 }, /* GL_MATRIX_PALETTE_ARB */ - { 22144, 0x00008840 }, /* GL_MATRIX_PALETTE_OES */ - { 22166, 0x00008008 }, /* GL_MAX */ - { 22173, 0x00008073 }, /* GL_MAX_3D_TEXTURE_SIZE */ - { 22196, 0x00008073 }, /* GL_MAX_3D_TEXTURE_SIZE_OES */ - { 22223, 0x000088FF }, /* GL_MAX_ARRAY_TEXTURE_LAYERS */ - { 22251, 0x000088FF }, /* GL_MAX_ARRAY_TEXTURE_LAYERS_EXT */ - { 22283, 0x00000D35 }, /* GL_MAX_ATTRIB_STACK_DEPTH */ - { 22309, 0x00000D3B }, /* GL_MAX_CLIENT_ATTRIB_STACK_DEPTH */ - { 22342, 0x00008177 }, /* GL_MAX_CLIPMAP_DEPTH_SGIX */ - { 22368, 0x00008178 }, /* GL_MAX_CLIPMAP_VIRTUAL_DEPTH_SGIX */ - { 22402, 0x00000D32 }, /* GL_MAX_CLIP_DISTANCES */ - { 22424, 0x00000D32 }, /* GL_MAX_CLIP_PLANES */ - { 22443, 0x00008CDF }, /* GL_MAX_COLOR_ATTACHMENTS */ - { 22468, 0x00008CDF }, /* GL_MAX_COLOR_ATTACHMENTS_EXT */ - { 22497, 0x000080B3 }, /* GL_MAX_COLOR_MATRIX_STACK_DEPTH */ - { 22529, 0x000080B3 }, /* GL_MAX_COLOR_MATRIX_STACK_DEPTH_SGI */ - { 22565, 0x00008B4D }, /* GL_MAX_COMBINED_TEXTURE_IMAGE_UNITS */ - { 22601, 0x00008B4D }, /* GL_MAX_COMBINED_TEXTURE_IMAGE_UNITS_ARB */ - { 22641, 0x0000801B }, /* GL_MAX_CONVOLUTION_HEIGHT */ - { 22667, 0x0000801B }, /* GL_MAX_CONVOLUTION_HEIGHT_EXT */ - { 22697, 0x0000801A }, /* GL_MAX_CONVOLUTION_WIDTH */ - { 22722, 0x0000801A }, /* GL_MAX_CONVOLUTION_WIDTH_EXT */ - { 22751, 0x0000851C }, /* GL_MAX_CUBE_MAP_TEXTURE_SIZE */ - { 22780, 0x0000851C }, /* GL_MAX_CUBE_MAP_TEXTURE_SIZE_ARB */ - { 22813, 0x0000851C }, /* GL_MAX_CUBE_MAP_TEXTURE_SIZE_OES */ - { 22846, 0x00008824 }, /* GL_MAX_DRAW_BUFFERS */ - { 22866, 0x00008824 }, /* GL_MAX_DRAW_BUFFERS_ARB */ - { 22890, 0x00008824 }, /* GL_MAX_DRAW_BUFFERS_ATI */ - { 22914, 0x00008824 }, /* GL_MAX_DRAW_BUFFERS_NV */ - { 22937, 0x000080E9 }, /* GL_MAX_ELEMENTS_INDICES */ - { 22961, 0x000080E8 }, /* GL_MAX_ELEMENTS_VERTICES */ - { 22986, 0x00000D30 }, /* GL_MAX_EVAL_ORDER */ - { 23004, 0x00008008 }, /* GL_MAX_EXT */ - { 23015, 0x00009125 }, /* GL_MAX_FRAGMENT_INPUT_COMPONENTS */ - { 23048, 0x00008B49 }, /* GL_MAX_FRAGMENT_UNIFORM_COMPONENTS */ - { 23083, 0x00008B49 }, /* GL_MAX_FRAGMENT_UNIFORM_COMPONENTS_ARB */ - { 23122, 0x00008DFD }, /* GL_MAX_FRAGMENT_UNIFORM_VECTORS */ - { 23154, 0x00009123 }, /* GL_MAX_GEOMETRY_INPUT_COMPONENTS */ - { 23187, 0x00009124 }, /* GL_MAX_GEOMETRY_OUTPUT_COMPONENTS */ - { 23221, 0x00008DE0 }, /* GL_MAX_GEOMETRY_OUTPUT_VERTICES */ - { 23253, 0x00008DE0 }, /* GL_MAX_GEOMETRY_OUTPUT_VERTICES_ARB */ - { 23289, 0x00008C29 }, /* GL_MAX_GEOMETRY_TEXTURE_IMAGE_UNITS */ - { 23325, 0x00008C29 }, /* GL_MAX_GEOMETRY_TEXTURE_IMAGE_UNITS_ARB */ - { 23365, 0x00008DE1 }, /* GL_MAX_GEOMETRY_TOTAL_OUTPUT_COMPONENTS */ - { 23405, 0x00008DE1 }, /* GL_MAX_GEOMETRY_TOTAL_OUTPUT_COMPONENTS_ARB */ - { 23449, 0x00008DDF }, /* GL_MAX_GEOMETRY_UNIFORM_COMPONENTS */ - { 23484, 0x00008DDF }, /* GL_MAX_GEOMETRY_UNIFORM_COMPONENTS_ARB */ - { 23523, 0x00008DDD }, /* GL_MAX_GEOMETRY_VARYING_COMPONENTS_ARB */ - { 23562, 0x00000D31 }, /* GL_MAX_LIGHTS */ - { 23576, 0x00000B31 }, /* GL_MAX_LIST_NESTING */ - { 23596, 0x00008841 }, /* GL_MAX_MATRIX_PALETTE_STACK_DEPTH_ARB */ - { 23634, 0x00000D36 }, /* GL_MAX_MODELVIEW_STACK_DEPTH */ - { 23663, 0x00000D37 }, /* GL_MAX_NAME_STACK_DEPTH */ - { 23687, 0x00008842 }, /* GL_MAX_PALETTE_MATRICES_ARB */ - { 23715, 0x00008842 }, /* GL_MAX_PALETTE_MATRICES_OES */ - { 23743, 0x00000D34 }, /* GL_MAX_PIXEL_MAP_TABLE */ - { 23766, 0x000088B1 }, /* GL_MAX_PROGRAM_ADDRESS_REGISTERS_ARB */ - { 23803, 0x0000880B }, /* GL_MAX_PROGRAM_ALU_INSTRUCTIONS_ARB */ - { 23839, 0x000088AD }, /* GL_MAX_PROGRAM_ATTRIBS_ARB */ - { 23866, 0x000088F5 }, /* GL_MAX_PROGRAM_CALL_DEPTH_NV */ - { 23895, 0x000088B5 }, /* GL_MAX_PROGRAM_ENV_PARAMETERS_ARB */ - { 23929, 0x000088F4 }, /* GL_MAX_PROGRAM_EXEC_INSTRUCTIONS_NV */ - { 23965, 0x000088F6 }, /* GL_MAX_PROGRAM_IF_DEPTH_NV */ - { 23992, 0x000088A1 }, /* GL_MAX_PROGRAM_INSTRUCTIONS_ARB */ - { 24024, 0x000088B4 }, /* GL_MAX_PROGRAM_LOCAL_PARAMETERS_ARB */ - { 24060, 0x000088F8 }, /* GL_MAX_PROGRAM_LOOP_COUNT_NV */ - { 24089, 0x000088F7 }, /* GL_MAX_PROGRAM_LOOP_DEPTH_NV */ - { 24118, 0x0000862F }, /* GL_MAX_PROGRAM_MATRICES_ARB */ - { 24146, 0x0000862E }, /* GL_MAX_PROGRAM_MATRIX_STACK_DEPTH_ARB */ - { 24184, 0x000088B3 }, /* GL_MAX_PROGRAM_NATIVE_ADDRESS_REGISTERS_ARB */ - { 24228, 0x0000880E }, /* GL_MAX_PROGRAM_NATIVE_ALU_INSTRUCTIONS_ARB */ - { 24271, 0x000088AF }, /* GL_MAX_PROGRAM_NATIVE_ATTRIBS_ARB */ - { 24305, 0x000088A3 }, /* GL_MAX_PROGRAM_NATIVE_INSTRUCTIONS_ARB */ - { 24344, 0x000088AB }, /* GL_MAX_PROGRAM_NATIVE_PARAMETERS_ARB */ - { 24381, 0x000088A7 }, /* GL_MAX_PROGRAM_NATIVE_TEMPORARIES_ARB */ - { 24419, 0x00008810 }, /* GL_MAX_PROGRAM_NATIVE_TEX_INDIRECTIONS_ARB */ - { 24462, 0x0000880F }, /* GL_MAX_PROGRAM_NATIVE_TEX_INSTRUCTIONS_ARB */ - { 24505, 0x000088A9 }, /* GL_MAX_PROGRAM_PARAMETERS_ARB */ - { 24535, 0x000088A5 }, /* GL_MAX_PROGRAM_TEMPORARIES_ARB */ - { 24566, 0x00008905 }, /* GL_MAX_PROGRAM_TEXEL_OFFSET */ - { 24594, 0x0000880D }, /* GL_MAX_PROGRAM_TEX_INDIRECTIONS_ARB */ - { 24630, 0x0000880C }, /* GL_MAX_PROGRAM_TEX_INSTRUCTIONS_ARB */ - { 24666, 0x00000D38 }, /* GL_MAX_PROJECTION_STACK_DEPTH */ - { 24696, 0x000084F8 }, /* GL_MAX_RECTANGLE_TEXTURE_SIZE */ - { 24726, 0x000084F8 }, /* GL_MAX_RECTANGLE_TEXTURE_SIZE_ARB */ - { 24760, 0x000084F8 }, /* GL_MAX_RECTANGLE_TEXTURE_SIZE_NV */ - { 24793, 0x000084E8 }, /* GL_MAX_RENDERBUFFER_SIZE */ - { 24818, 0x000084E8 }, /* GL_MAX_RENDERBUFFER_SIZE_EXT */ - { 24847, 0x000084E8 }, /* GL_MAX_RENDERBUFFER_SIZE_OES */ - { 24876, 0x00008D57 }, /* GL_MAX_SAMPLES */ - { 24891, 0x00008D57 }, /* GL_MAX_SAMPLES_EXT */ - { 24910, 0x00009111 }, /* GL_MAX_SERVER_WAIT_TIMEOUT */ - { 24937, 0x00008504 }, /* GL_MAX_SHININESS_NV */ - { 24957, 0x00008505 }, /* GL_MAX_SPOT_EXPONENT_NV */ - { 24981, 0x00008C2B }, /* GL_MAX_TEXTURE_BUFFER_SIZE */ - { 25008, 0x00008C2B }, /* GL_MAX_TEXTURE_BUFFER_SIZE_ARB */ - { 25039, 0x00008871 }, /* GL_MAX_TEXTURE_COORDS */ - { 25061, 0x00008871 }, /* GL_MAX_TEXTURE_COORDS_ARB */ - { 25087, 0x00008872 }, /* GL_MAX_TEXTURE_IMAGE_UNITS */ - { 25114, 0x00008872 }, /* GL_MAX_TEXTURE_IMAGE_UNITS_ARB */ - { 25145, 0x000084FD }, /* GL_MAX_TEXTURE_LOD_BIAS */ - { 25169, 0x000084FD }, /* GL_MAX_TEXTURE_LOD_BIAS_EXT */ - { 25197, 0x000084FF }, /* GL_MAX_TEXTURE_MAX_ANISOTROPY_EXT */ - { 25231, 0x00000D33 }, /* GL_MAX_TEXTURE_SIZE */ - { 25251, 0x00000D39 }, /* GL_MAX_TEXTURE_STACK_DEPTH */ - { 25278, 0x000084E2 }, /* GL_MAX_TEXTURE_UNITS */ - { 25299, 0x000084E2 }, /* GL_MAX_TEXTURE_UNITS_ARB */ - { 25324, 0x0000862F }, /* GL_MAX_TRACK_MATRICES_NV */ - { 25349, 0x0000862E }, /* GL_MAX_TRACK_MATRIX_STACK_DEPTH_NV */ - { 25384, 0x00008C8A }, /* GL_MAX_TRANSFORM_FEEDBACK_INTERLEAVED_COMPONENTS */ - { 25433, 0x00008C8A }, /* GL_MAX_TRANSFORM_FEEDBACK_INTERLEAVED_COMPONENTS_EXT */ - { 25486, 0x00008C8B }, /* GL_MAX_TRANSFORM_FEEDBACK_SEPARATE_ATTRIBS */ - { 25529, 0x00008C8B }, /* GL_MAX_TRANSFORM_FEEDBACK_SEPARATE_ATTRIBS_EXT */ - { 25576, 0x00008C80 }, /* GL_MAX_TRANSFORM_FEEDBACK_SEPARATE_COMPONENTS */ - { 25622, 0x00008C80 }, /* GL_MAX_TRANSFORM_FEEDBACK_SEPARATE_COMPONENTS_EXT */ - { 25672, 0x00008B4B }, /* GL_MAX_VARYING_COMPONENTS */ - { 25698, 0x00008B4B }, /* GL_MAX_VARYING_FLOATS */ - { 25720, 0x00008B4B }, /* GL_MAX_VARYING_FLOATS_ARB */ - { 25746, 0x00008DFC }, /* GL_MAX_VARYING_VECTORS */ - { 25769, 0x00008869 }, /* GL_MAX_VERTEX_ATTRIBS */ - { 25791, 0x00008869 }, /* GL_MAX_VERTEX_ATTRIBS_ARB */ - { 25817, 0x00009122 }, /* GL_MAX_VERTEX_OUTPUT_COMPONENTS */ - { 25849, 0x00008B4C }, /* GL_MAX_VERTEX_TEXTURE_IMAGE_UNITS */ - { 25883, 0x00008B4C }, /* GL_MAX_VERTEX_TEXTURE_IMAGE_UNITS_ARB */ - { 25921, 0x00008B4A }, /* GL_MAX_VERTEX_UNIFORM_COMPONENTS */ - { 25954, 0x00008B4A }, /* GL_MAX_VERTEX_UNIFORM_COMPONENTS_ARB */ - { 25991, 0x00008DFB }, /* GL_MAX_VERTEX_UNIFORM_VECTORS */ - { 26021, 0x000086A4 }, /* GL_MAX_VERTEX_UNITS_ARB */ - { 26045, 0x000086A4 }, /* GL_MAX_VERTEX_UNITS_OES */ - { 26069, 0x00008DDE }, /* GL_MAX_VERTEX_VARYING_COMPONENTS_ARB */ - { 26106, 0x00000D3A }, /* GL_MAX_VIEWPORT_DIMS */ - { 26127, 0x00008DF1 }, /* GL_MEDIUM_FLOAT */ - { 26143, 0x00008DF4 }, /* GL_MEDIUM_INT */ - { 26157, 0x00008007 }, /* GL_MIN */ - { 26164, 0x0000802E }, /* GL_MINMAX */ - { 26174, 0x0000802E }, /* GL_MINMAX_EXT */ - { 26188, 0x0000802F }, /* GL_MINMAX_FORMAT */ - { 26205, 0x0000802F }, /* GL_MINMAX_FORMAT_EXT */ - { 26226, 0x00008030 }, /* GL_MINMAX_SINK */ - { 26241, 0x00008030 }, /* GL_MINMAX_SINK_EXT */ - { 26260, 0x0000821C }, /* GL_MINOR_VERSION */ - { 26277, 0x00008007 }, /* GL_MIN_EXT */ - { 26288, 0x00008904 }, /* GL_MIN_PROGRAM_TEXEL_OFFSET */ - { 26316, 0x00008370 }, /* GL_MIRRORED_REPEAT */ - { 26335, 0x00008370 }, /* GL_MIRRORED_REPEAT_ARB */ - { 26358, 0x00008370 }, /* GL_MIRRORED_REPEAT_IBM */ - { 26381, 0x00008742 }, /* GL_MIRROR_CLAMP_ATI */ - { 26401, 0x00008742 }, /* GL_MIRROR_CLAMP_EXT */ - { 26421, 0x00008912 }, /* GL_MIRROR_CLAMP_TO_BORDER_EXT */ - { 26451, 0x00008743 }, /* GL_MIRROR_CLAMP_TO_EDGE_ATI */ - { 26479, 0x00008743 }, /* GL_MIRROR_CLAMP_TO_EDGE_EXT */ - { 26507, 0x00001700 }, /* GL_MODELVIEW */ - { 26520, 0x00001700 }, /* GL_MODELVIEW0_ARB */ - { 26538, 0x0000872A }, /* GL_MODELVIEW10_ARB */ - { 26557, 0x0000872B }, /* GL_MODELVIEW11_ARB */ - { 26576, 0x0000872C }, /* GL_MODELVIEW12_ARB */ - { 26595, 0x0000872D }, /* GL_MODELVIEW13_ARB */ - { 26614, 0x0000872E }, /* GL_MODELVIEW14_ARB */ - { 26633, 0x0000872F }, /* GL_MODELVIEW15_ARB */ - { 26652, 0x00008730 }, /* GL_MODELVIEW16_ARB */ - { 26671, 0x00008731 }, /* GL_MODELVIEW17_ARB */ - { 26690, 0x00008732 }, /* GL_MODELVIEW18_ARB */ - { 26709, 0x00008733 }, /* GL_MODELVIEW19_ARB */ - { 26728, 0x0000850A }, /* GL_MODELVIEW1_ARB */ - { 26746, 0x00008734 }, /* GL_MODELVIEW20_ARB */ - { 26765, 0x00008735 }, /* GL_MODELVIEW21_ARB */ - { 26784, 0x00008736 }, /* GL_MODELVIEW22_ARB */ - { 26803, 0x00008737 }, /* GL_MODELVIEW23_ARB */ - { 26822, 0x00008738 }, /* GL_MODELVIEW24_ARB */ - { 26841, 0x00008739 }, /* GL_MODELVIEW25_ARB */ - { 26860, 0x0000873A }, /* GL_MODELVIEW26_ARB */ - { 26879, 0x0000873B }, /* GL_MODELVIEW27_ARB */ - { 26898, 0x0000873C }, /* GL_MODELVIEW28_ARB */ - { 26917, 0x0000873D }, /* GL_MODELVIEW29_ARB */ - { 26936, 0x00008722 }, /* GL_MODELVIEW2_ARB */ - { 26954, 0x0000873E }, /* GL_MODELVIEW30_ARB */ - { 26973, 0x0000873F }, /* GL_MODELVIEW31_ARB */ - { 26992, 0x00008723 }, /* GL_MODELVIEW3_ARB */ - { 27010, 0x00008724 }, /* GL_MODELVIEW4_ARB */ - { 27028, 0x00008725 }, /* GL_MODELVIEW5_ARB */ - { 27046, 0x00008726 }, /* GL_MODELVIEW6_ARB */ - { 27064, 0x00008727 }, /* GL_MODELVIEW7_ARB */ - { 27082, 0x00008728 }, /* GL_MODELVIEW8_ARB */ - { 27100, 0x00008729 }, /* GL_MODELVIEW9_ARB */ - { 27118, 0x00000BA6 }, /* GL_MODELVIEW_MATRIX */ - { 27138, 0x0000898D }, /* GL_MODELVIEW_MATRIX_FLOAT_AS_INT_BITS_OES */ - { 27180, 0x00008629 }, /* GL_MODELVIEW_PROJECTION_NV */ - { 27207, 0x00000BA3 }, /* GL_MODELVIEW_STACK_DEPTH */ - { 27232, 0x00002100 }, /* GL_MODULATE */ - { 27244, 0x00008744 }, /* GL_MODULATE_ADD_ATI */ - { 27264, 0x00008745 }, /* GL_MODULATE_SIGNED_ADD_ATI */ - { 27291, 0x00008746 }, /* GL_MODULATE_SUBTRACT_ATI */ - { 27316, 0x00000103 }, /* GL_MULT */ - { 27324, 0x0000809D }, /* GL_MULTISAMPLE */ - { 27339, 0x000086B2 }, /* GL_MULTISAMPLE_3DFX */ - { 27359, 0x0000809D }, /* GL_MULTISAMPLE_ARB */ - { 27378, 0x20000000 }, /* GL_MULTISAMPLE_BIT */ - { 27397, 0x20000000 }, /* GL_MULTISAMPLE_BIT_3DFX */ - { 27421, 0x20000000 }, /* GL_MULTISAMPLE_BIT_ARB */ - { 27444, 0x00008534 }, /* GL_MULTISAMPLE_FILTER_HINT_NV */ - { 27474, 0x00002A25 }, /* GL_N3F_V3F */ - { 27485, 0x00000D70 }, /* GL_NAME_STACK_DEPTH */ - { 27505, 0x0000150E }, /* GL_NAND */ - { 27513, 0x00002600 }, /* GL_NEAREST */ - { 27524, 0x0000844E }, /* GL_NEAREST_CLIPMAP_LINEAR_SGIX */ - { 27555, 0x0000844D }, /* GL_NEAREST_CLIPMAP_NEAREST_SGIX */ - { 27587, 0x00002702 }, /* GL_NEAREST_MIPMAP_LINEAR */ - { 27612, 0x00002700 }, /* GL_NEAREST_MIPMAP_NEAREST */ - { 27638, 0x00000200 }, /* GL_NEVER */ - { 27647, 0x00001102 }, /* GL_NICEST */ - { 27657, 0x00000000 }, /* GL_NONE */ - { 27665, 0x00000000 }, /* GL_NONE_OES */ - { 27677, 0x00001505 }, /* GL_NOOP */ - { 27685, 0x00001508 }, /* GL_NOR */ - { 27692, 0x00000BA1 }, /* GL_NORMALIZE */ - { 27705, 0x00008075 }, /* GL_NORMAL_ARRAY */ - { 27721, 0x00008897 }, /* GL_NORMAL_ARRAY_BUFFER_BINDING */ - { 27752, 0x00008897 }, /* GL_NORMAL_ARRAY_BUFFER_BINDING_ARB */ - { 27787, 0x0000808F }, /* GL_NORMAL_ARRAY_POINTER */ - { 27811, 0x0000807F }, /* GL_NORMAL_ARRAY_STRIDE */ - { 27834, 0x0000807E }, /* GL_NORMAL_ARRAY_TYPE */ - { 27855, 0x00008511 }, /* GL_NORMAL_MAP */ - { 27869, 0x00008511 }, /* GL_NORMAL_MAP_ARB */ - { 27887, 0x00008511 }, /* GL_NORMAL_MAP_NV */ - { 27904, 0x00008511 }, /* GL_NORMAL_MAP_OES */ - { 27922, 0x00000205 }, /* GL_NOTEQUAL */ - { 27934, 0x00000000 }, /* GL_NO_ERROR */ - { 27946, 0x00008261 }, /* GL_NO_RESET_NOTIFICATION_ARB */ - { 27975, 0x000086A2 }, /* GL_NUM_COMPRESSED_TEXTURE_FORMATS */ - { 28009, 0x000086A2 }, /* GL_NUM_COMPRESSED_TEXTURE_FORMATS_ARB */ - { 28047, 0x0000821D }, /* GL_NUM_EXTENSIONS */ - { 28065, 0x000087FE }, /* GL_NUM_PROGRAM_BINARY_FORMATS */ - { 28095, 0x000087FE }, /* GL_NUM_PROGRAM_BINARY_FORMATS_OES */ - { 28129, 0x00008DF9 }, /* GL_NUM_SHADER_BINARY_FORMATS */ - { 28158, 0x00008B89 }, /* GL_OBJECT_ACTIVE_ATTRIBUTES_ARB */ - { 28190, 0x00008B8A }, /* GL_OBJECT_ACTIVE_ATTRIBUTE_MAX_LENGTH_ARB */ - { 28232, 0x00008B86 }, /* GL_OBJECT_ACTIVE_UNIFORMS_ARB */ - { 28262, 0x00008B87 }, /* GL_OBJECT_ACTIVE_UNIFORM_MAX_LENGTH_ARB */ - { 28302, 0x00008B85 }, /* GL_OBJECT_ATTACHED_OBJECTS_ARB */ - { 28333, 0x00008B81 }, /* GL_OBJECT_COMPILE_STATUS_ARB */ - { 28362, 0x00008B80 }, /* GL_OBJECT_DELETE_STATUS_ARB */ - { 28390, 0x00008B84 }, /* GL_OBJECT_INFO_LOG_LENGTH_ARB */ - { 28420, 0x00002401 }, /* GL_OBJECT_LINEAR */ - { 28437, 0x00008B82 }, /* GL_OBJECT_LINK_STATUS_ARB */ - { 28463, 0x00002501 }, /* GL_OBJECT_PLANE */ - { 28479, 0x00008B88 }, /* GL_OBJECT_SHADER_SOURCE_LENGTH_ARB */ - { 28514, 0x00008B4F }, /* GL_OBJECT_SUBTYPE_ARB */ - { 28536, 0x00009112 }, /* GL_OBJECT_TYPE */ - { 28551, 0x00008B4E }, /* GL_OBJECT_TYPE_ARB */ - { 28570, 0x00008B83 }, /* GL_OBJECT_VALIDATE_STATUS_ARB */ - { 28600, 0x00008165 }, /* GL_OCCLUSION_TEST_HP */ - { 28621, 0x00008166 }, /* GL_OCCLUSION_TEST_RESULT_HP */ - { 28649, 0x00000001 }, /* GL_ONE */ - { 28656, 0x00008004 }, /* GL_ONE_MINUS_CONSTANT_ALPHA */ - { 28684, 0x00008004 }, /* GL_ONE_MINUS_CONSTANT_ALPHA_EXT */ - { 28716, 0x00008002 }, /* GL_ONE_MINUS_CONSTANT_COLOR */ - { 28744, 0x00008002 }, /* GL_ONE_MINUS_CONSTANT_COLOR_EXT */ - { 28776, 0x00000305 }, /* GL_ONE_MINUS_DST_ALPHA */ - { 28799, 0x00000307 }, /* GL_ONE_MINUS_DST_COLOR */ - { 28822, 0x00000303 }, /* GL_ONE_MINUS_SRC_ALPHA */ - { 28845, 0x00000301 }, /* GL_ONE_MINUS_SRC_COLOR */ - { 28868, 0x00008598 }, /* GL_OPERAND0_ALPHA */ - { 28886, 0x00008598 }, /* GL_OPERAND0_ALPHA_ARB */ - { 28908, 0x00008598 }, /* GL_OPERAND0_ALPHA_EXT */ - { 28930, 0x00008590 }, /* GL_OPERAND0_RGB */ - { 28946, 0x00008590 }, /* GL_OPERAND0_RGB_ARB */ - { 28966, 0x00008590 }, /* GL_OPERAND0_RGB_EXT */ - { 28986, 0x00008599 }, /* GL_OPERAND1_ALPHA */ - { 29004, 0x00008599 }, /* GL_OPERAND1_ALPHA_ARB */ - { 29026, 0x00008599 }, /* GL_OPERAND1_ALPHA_EXT */ - { 29048, 0x00008591 }, /* GL_OPERAND1_RGB */ - { 29064, 0x00008591 }, /* GL_OPERAND1_RGB_ARB */ - { 29084, 0x00008591 }, /* GL_OPERAND1_RGB_EXT */ - { 29104, 0x0000859A }, /* GL_OPERAND2_ALPHA */ - { 29122, 0x0000859A }, /* GL_OPERAND2_ALPHA_ARB */ - { 29144, 0x0000859A }, /* GL_OPERAND2_ALPHA_EXT */ - { 29166, 0x00008592 }, /* GL_OPERAND2_RGB */ - { 29182, 0x00008592 }, /* GL_OPERAND2_RGB_ARB */ - { 29202, 0x00008592 }, /* GL_OPERAND2_RGB_EXT */ - { 29222, 0x0000859B }, /* GL_OPERAND3_ALPHA_NV */ - { 29243, 0x00008593 }, /* GL_OPERAND3_RGB_NV */ - { 29262, 0x00001507 }, /* GL_OR */ - { 29268, 0x00000A01 }, /* GL_ORDER */ - { 29277, 0x0000150D }, /* GL_OR_INVERTED */ - { 29292, 0x0000150B }, /* GL_OR_REVERSE */ - { 29306, 0x00000505 }, /* GL_OUT_OF_MEMORY */ - { 29323, 0x00000D05 }, /* GL_PACK_ALIGNMENT */ - { 29341, 0x0000806C }, /* GL_PACK_IMAGE_HEIGHT */ - { 29362, 0x00008758 }, /* GL_PACK_INVERT_MESA */ - { 29382, 0x00000D01 }, /* GL_PACK_LSB_FIRST */ - { 29400, 0x00000D02 }, /* GL_PACK_ROW_LENGTH */ - { 29419, 0x0000806B }, /* GL_PACK_SKIP_IMAGES */ - { 29439, 0x00000D04 }, /* GL_PACK_SKIP_PIXELS */ - { 29459, 0x00000D03 }, /* GL_PACK_SKIP_ROWS */ - { 29477, 0x00000D00 }, /* GL_PACK_SWAP_BYTES */ - { 29496, 0x00008B92 }, /* GL_PALETTE4_R5_G6_B5_OES */ - { 29521, 0x00008B94 }, /* GL_PALETTE4_RGB5_A1_OES */ - { 29545, 0x00008B90 }, /* GL_PALETTE4_RGB8_OES */ - { 29566, 0x00008B93 }, /* GL_PALETTE4_RGBA4_OES */ - { 29588, 0x00008B91 }, /* GL_PALETTE4_RGBA8_OES */ - { 29610, 0x00008B97 }, /* GL_PALETTE8_R5_G6_B5_OES */ - { 29635, 0x00008B99 }, /* GL_PALETTE8_RGB5_A1_OES */ - { 29659, 0x00008B95 }, /* GL_PALETTE8_RGB8_OES */ - { 29680, 0x00008B98 }, /* GL_PALETTE8_RGBA4_OES */ - { 29702, 0x00008B96 }, /* GL_PALETTE8_RGBA8_OES */ - { 29724, 0x00000700 }, /* GL_PASS_THROUGH_TOKEN */ - { 29746, 0x00000C50 }, /* GL_PERSPECTIVE_CORRECTION_HINT */ - { 29777, 0x00000C79 }, /* GL_PIXEL_MAP_A_TO_A */ - { 29797, 0x00000CB9 }, /* GL_PIXEL_MAP_A_TO_A_SIZE */ - { 29822, 0x00000C78 }, /* GL_PIXEL_MAP_B_TO_B */ - { 29842, 0x00000CB8 }, /* GL_PIXEL_MAP_B_TO_B_SIZE */ - { 29867, 0x00000C77 }, /* GL_PIXEL_MAP_G_TO_G */ - { 29887, 0x00000CB7 }, /* GL_PIXEL_MAP_G_TO_G_SIZE */ - { 29912, 0x00000C75 }, /* GL_PIXEL_MAP_I_TO_A */ - { 29932, 0x00000CB5 }, /* GL_PIXEL_MAP_I_TO_A_SIZE */ - { 29957, 0x00000C74 }, /* GL_PIXEL_MAP_I_TO_B */ - { 29977, 0x00000CB4 }, /* GL_PIXEL_MAP_I_TO_B_SIZE */ - { 30002, 0x00000C73 }, /* GL_PIXEL_MAP_I_TO_G */ - { 30022, 0x00000CB3 }, /* GL_PIXEL_MAP_I_TO_G_SIZE */ - { 30047, 0x00000C70 }, /* GL_PIXEL_MAP_I_TO_I */ - { 30067, 0x00000CB0 }, /* GL_PIXEL_MAP_I_TO_I_SIZE */ - { 30092, 0x00000C72 }, /* GL_PIXEL_MAP_I_TO_R */ - { 30112, 0x00000CB2 }, /* GL_PIXEL_MAP_I_TO_R_SIZE */ - { 30137, 0x00000C76 }, /* GL_PIXEL_MAP_R_TO_R */ - { 30157, 0x00000CB6 }, /* GL_PIXEL_MAP_R_TO_R_SIZE */ - { 30182, 0x00000C71 }, /* GL_PIXEL_MAP_S_TO_S */ - { 30202, 0x00000CB1 }, /* GL_PIXEL_MAP_S_TO_S_SIZE */ - { 30227, 0x00000020 }, /* GL_PIXEL_MODE_BIT */ - { 30245, 0x000088EB }, /* GL_PIXEL_PACK_BUFFER */ - { 30266, 0x000088ED }, /* GL_PIXEL_PACK_BUFFER_BINDING */ - { 30295, 0x000088ED }, /* GL_PIXEL_PACK_BUFFER_BINDING_EXT */ - { 30328, 0x000088EB }, /* GL_PIXEL_PACK_BUFFER_EXT */ - { 30353, 0x000088EC }, /* GL_PIXEL_UNPACK_BUFFER */ - { 30376, 0x000088EF }, /* GL_PIXEL_UNPACK_BUFFER_BINDING */ - { 30407, 0x000088EF }, /* GL_PIXEL_UNPACK_BUFFER_BINDING_EXT */ - { 30442, 0x000088EC }, /* GL_PIXEL_UNPACK_BUFFER_EXT */ - { 30469, 0x00001B00 }, /* GL_POINT */ - { 30478, 0x00000000 }, /* GL_POINTS */ - { 30488, 0x00000002 }, /* GL_POINT_BIT */ - { 30501, 0x00008129 }, /* GL_POINT_DISTANCE_ATTENUATION */ - { 30531, 0x00008129 }, /* GL_POINT_DISTANCE_ATTENUATION_ARB */ - { 30565, 0x00008129 }, /* GL_POINT_DISTANCE_ATTENUATION_EXT */ - { 30599, 0x00008129 }, /* GL_POINT_DISTANCE_ATTENUATION_SGIS */ - { 30634, 0x00008128 }, /* GL_POINT_FADE_THRESHOLD_SIZE */ - { 30663, 0x00008128 }, /* GL_POINT_FADE_THRESHOLD_SIZE_ARB */ - { 30696, 0x00008128 }, /* GL_POINT_FADE_THRESHOLD_SIZE_EXT */ - { 30729, 0x00008128 }, /* GL_POINT_FADE_THRESHOLD_SIZE_SGIS */ - { 30763, 0x00000B11 }, /* GL_POINT_SIZE */ - { 30777, 0x00008B9F }, /* GL_POINT_SIZE_ARRAY_BUFFER_BINDING_OES */ - { 30816, 0x00008B9C }, /* GL_POINT_SIZE_ARRAY_OES */ - { 30840, 0x0000898C }, /* GL_POINT_SIZE_ARRAY_POINTER_OES */ - { 30872, 0x0000898B }, /* GL_POINT_SIZE_ARRAY_STRIDE_OES */ - { 30903, 0x0000898A }, /* GL_POINT_SIZE_ARRAY_TYPE_OES */ - { 30932, 0x00000B13 }, /* GL_POINT_SIZE_GRANULARITY */ - { 30958, 0x00008127 }, /* GL_POINT_SIZE_MAX */ - { 30976, 0x00008127 }, /* GL_POINT_SIZE_MAX_ARB */ - { 30998, 0x00008127 }, /* GL_POINT_SIZE_MAX_EXT */ - { 31020, 0x00008127 }, /* GL_POINT_SIZE_MAX_SGIS */ - { 31043, 0x00008126 }, /* GL_POINT_SIZE_MIN */ - { 31061, 0x00008126 }, /* GL_POINT_SIZE_MIN_ARB */ - { 31083, 0x00008126 }, /* GL_POINT_SIZE_MIN_EXT */ - { 31105, 0x00008126 }, /* GL_POINT_SIZE_MIN_SGIS */ - { 31128, 0x00000B12 }, /* GL_POINT_SIZE_RANGE */ - { 31148, 0x00000B10 }, /* GL_POINT_SMOOTH */ - { 31164, 0x00000C51 }, /* GL_POINT_SMOOTH_HINT */ - { 31185, 0x00008861 }, /* GL_POINT_SPRITE */ - { 31201, 0x00008861 }, /* GL_POINT_SPRITE_ARB */ - { 31221, 0x00008CA0 }, /* GL_POINT_SPRITE_COORD_ORIGIN */ - { 31250, 0x00008861 }, /* GL_POINT_SPRITE_NV */ - { 31269, 0x00008861 }, /* GL_POINT_SPRITE_OES */ - { 31289, 0x00008863 }, /* GL_POINT_SPRITE_R_MODE_NV */ - { 31315, 0x00000701 }, /* GL_POINT_TOKEN */ - { 31330, 0x00000009 }, /* GL_POLYGON */ - { 31341, 0x00000008 }, /* GL_POLYGON_BIT */ - { 31356, 0x00000B40 }, /* GL_POLYGON_MODE */ - { 31372, 0x00008039 }, /* GL_POLYGON_OFFSET_BIAS */ - { 31395, 0x00008038 }, /* GL_POLYGON_OFFSET_FACTOR */ - { 31420, 0x00008037 }, /* GL_POLYGON_OFFSET_FILL */ - { 31443, 0x00002A02 }, /* GL_POLYGON_OFFSET_LINE */ - { 31466, 0x00002A01 }, /* GL_POLYGON_OFFSET_POINT */ - { 31490, 0x00002A00 }, /* GL_POLYGON_OFFSET_UNITS */ - { 31514, 0x00000B41 }, /* GL_POLYGON_SMOOTH */ - { 31532, 0x00000C53 }, /* GL_POLYGON_SMOOTH_HINT */ - { 31555, 0x00000B42 }, /* GL_POLYGON_STIPPLE */ - { 31574, 0x00000010 }, /* GL_POLYGON_STIPPLE_BIT */ - { 31597, 0x00000703 }, /* GL_POLYGON_TOKEN */ - { 31614, 0x00001203 }, /* GL_POSITION */ - { 31626, 0x000080BB }, /* GL_POST_COLOR_MATRIX_ALPHA_BIAS */ - { 31658, 0x000080BB }, /* GL_POST_COLOR_MATRIX_ALPHA_BIAS_SGI */ - { 31694, 0x000080B7 }, /* GL_POST_COLOR_MATRIX_ALPHA_SCALE */ - { 31727, 0x000080B7 }, /* GL_POST_COLOR_MATRIX_ALPHA_SCALE_SGI */ - { 31764, 0x000080BA }, /* GL_POST_COLOR_MATRIX_BLUE_BIAS */ - { 31795, 0x000080BA }, /* GL_POST_COLOR_MATRIX_BLUE_BIAS_SGI */ - { 31830, 0x000080B6 }, /* GL_POST_COLOR_MATRIX_BLUE_SCALE */ - { 31862, 0x000080B6 }, /* GL_POST_COLOR_MATRIX_BLUE_SCALE_SGI */ - { 31898, 0x000080D2 }, /* GL_POST_COLOR_MATRIX_COLOR_TABLE */ - { 31931, 0x000080B9 }, /* GL_POST_COLOR_MATRIX_GREEN_BIAS */ - { 31963, 0x000080B9 }, /* GL_POST_COLOR_MATRIX_GREEN_BIAS_SGI */ - { 31999, 0x000080B5 }, /* GL_POST_COLOR_MATRIX_GREEN_SCALE */ - { 32032, 0x000080B5 }, /* GL_POST_COLOR_MATRIX_GREEN_SCALE_SGI */ - { 32069, 0x000080B8 }, /* GL_POST_COLOR_MATRIX_RED_BIAS */ - { 32099, 0x000080B8 }, /* GL_POST_COLOR_MATRIX_RED_BIAS_SGI */ - { 32133, 0x000080B4 }, /* GL_POST_COLOR_MATRIX_RED_SCALE */ - { 32164, 0x000080B4 }, /* GL_POST_COLOR_MATRIX_RED_SCALE_SGI */ - { 32199, 0x00008023 }, /* GL_POST_CONVOLUTION_ALPHA_BIAS */ - { 32230, 0x00008023 }, /* GL_POST_CONVOLUTION_ALPHA_BIAS_EXT */ - { 32265, 0x0000801F }, /* GL_POST_CONVOLUTION_ALPHA_SCALE */ - { 32297, 0x0000801F }, /* GL_POST_CONVOLUTION_ALPHA_SCALE_EXT */ - { 32333, 0x00008022 }, /* GL_POST_CONVOLUTION_BLUE_BIAS */ - { 32363, 0x00008022 }, /* GL_POST_CONVOLUTION_BLUE_BIAS_EXT */ - { 32397, 0x0000801E }, /* GL_POST_CONVOLUTION_BLUE_SCALE */ - { 32428, 0x0000801E }, /* GL_POST_CONVOLUTION_BLUE_SCALE_EXT */ - { 32463, 0x000080D1 }, /* GL_POST_CONVOLUTION_COLOR_TABLE */ - { 32495, 0x00008021 }, /* GL_POST_CONVOLUTION_GREEN_BIAS */ - { 32526, 0x00008021 }, /* GL_POST_CONVOLUTION_GREEN_BIAS_EXT */ - { 32561, 0x0000801D }, /* GL_POST_CONVOLUTION_GREEN_SCALE */ - { 32593, 0x0000801D }, /* GL_POST_CONVOLUTION_GREEN_SCALE_EXT */ - { 32629, 0x00008020 }, /* GL_POST_CONVOLUTION_RED_BIAS */ - { 32658, 0x00008020 }, /* GL_POST_CONVOLUTION_RED_BIAS_EXT */ - { 32691, 0x0000801C }, /* GL_POST_CONVOLUTION_RED_SCALE */ - { 32721, 0x0000801C }, /* GL_POST_CONVOLUTION_RED_SCALE_EXT */ - { 32755, 0x0000817B }, /* GL_POST_TEXTURE_FILTER_BIAS_RANGE_SGIX */ - { 32794, 0x00008179 }, /* GL_POST_TEXTURE_FILTER_BIAS_SGIX */ - { 32827, 0x0000817C }, /* GL_POST_TEXTURE_FILTER_SCALE_RANGE_SGIX */ - { 32867, 0x0000817A }, /* GL_POST_TEXTURE_FILTER_SCALE_SGIX */ - { 32901, 0x00008578 }, /* GL_PREVIOUS */ - { 32913, 0x00008578 }, /* GL_PREVIOUS_ARB */ - { 32929, 0x00008578 }, /* GL_PREVIOUS_EXT */ - { 32945, 0x00008577 }, /* GL_PRIMARY_COLOR */ - { 32962, 0x00008577 }, /* GL_PRIMARY_COLOR_ARB */ - { 32983, 0x00008577 }, /* GL_PRIMARY_COLOR_EXT */ - { 33004, 0x00008C87 }, /* GL_PRIMITIVES_GENERATED */ - { 33028, 0x00008C87 }, /* GL_PRIMITIVES_GENERATED_EXT */ - { 33056, 0x00008F9D }, /* GL_PRIMITIVE_RESTART */ - { 33077, 0x00008F9E }, /* GL_PRIMITIVE_RESTART_INDEX */ - { 33104, 0x00008559 }, /* GL_PRIMITIVE_RESTART_INDEX_NV */ - { 33134, 0x00008558 }, /* GL_PRIMITIVE_RESTART_NV */ - { 33158, 0x000088B0 }, /* GL_PROGRAM_ADDRESS_REGISTERS_ARB */ - { 33191, 0x00008805 }, /* GL_PROGRAM_ALU_INSTRUCTIONS_ARB */ - { 33223, 0x000088AC }, /* GL_PROGRAM_ATTRIBS_ARB */ - { 33246, 0x000087FF }, /* GL_PROGRAM_BINARY_FORMATS */ - { 33272, 0x000087FF }, /* GL_PROGRAM_BINARY_FORMATS_OES */ - { 33302, 0x00008741 }, /* GL_PROGRAM_BINARY_LENGTH */ - { 33327, 0x00008741 }, /* GL_PROGRAM_BINARY_LENGTH_OES */ - { 33356, 0x00008257 }, /* GL_PROGRAM_BINARY_RETRIEVABLE_HINT */ - { 33391, 0x00008677 }, /* GL_PROGRAM_BINDING_ARB */ - { 33414, 0x0000864B }, /* GL_PROGRAM_ERROR_POSITION_ARB */ - { 33444, 0x0000864B }, /* GL_PROGRAM_ERROR_POSITION_NV */ - { 33473, 0x00008874 }, /* GL_PROGRAM_ERROR_STRING_ARB */ - { 33501, 0x00008876 }, /* GL_PROGRAM_FORMAT_ARB */ - { 33523, 0x00008875 }, /* GL_PROGRAM_FORMAT_ASCII_ARB */ - { 33551, 0x000088A0 }, /* GL_PROGRAM_INSTRUCTIONS_ARB */ - { 33579, 0x00008627 }, /* GL_PROGRAM_LENGTH_ARB */ - { 33601, 0x00008627 }, /* GL_PROGRAM_LENGTH_NV */ - { 33622, 0x000088B2 }, /* GL_PROGRAM_NATIVE_ADDRESS_REGISTERS_ARB */ - { 33662, 0x00008808 }, /* GL_PROGRAM_NATIVE_ALU_INSTRUCTIONS_ARB */ - { 33701, 0x000088AE }, /* GL_PROGRAM_NATIVE_ATTRIBS_ARB */ - { 33731, 0x000088A2 }, /* GL_PROGRAM_NATIVE_INSTRUCTIONS_ARB */ - { 33766, 0x000088AA }, /* GL_PROGRAM_NATIVE_PARAMETERS_ARB */ - { 33799, 0x000088A6 }, /* GL_PROGRAM_NATIVE_TEMPORARIES_ARB */ - { 33833, 0x0000880A }, /* GL_PROGRAM_NATIVE_TEX_INDIRECTIONS_ARB */ - { 33872, 0x00008809 }, /* GL_PROGRAM_NATIVE_TEX_INSTRUCTIONS_ARB */ - { 33911, 0x00008B40 }, /* GL_PROGRAM_OBJECT_ARB */ - { 33933, 0x000088A8 }, /* GL_PROGRAM_PARAMETERS_ARB */ - { 33959, 0x00008644 }, /* GL_PROGRAM_PARAMETER_NV */ - { 33983, 0x00008642 }, /* GL_PROGRAM_POINT_SIZE */ - { 34005, 0x00008642 }, /* GL_PROGRAM_POINT_SIZE_ARB */ - { 34031, 0x00008647 }, /* GL_PROGRAM_RESIDENT_NV */ - { 34054, 0x00008628 }, /* GL_PROGRAM_STRING_ARB */ - { 34076, 0x00008628 }, /* GL_PROGRAM_STRING_NV */ - { 34097, 0x00008646 }, /* GL_PROGRAM_TARGET_NV */ - { 34118, 0x000088A4 }, /* GL_PROGRAM_TEMPORARIES_ARB */ - { 34145, 0x00008807 }, /* GL_PROGRAM_TEX_INDIRECTIONS_ARB */ - { 34177, 0x00008806 }, /* GL_PROGRAM_TEX_INSTRUCTIONS_ARB */ - { 34209, 0x000088B6 }, /* GL_PROGRAM_UNDER_NATIVE_LIMITS_ARB */ - { 34244, 0x00001701 }, /* GL_PROJECTION */ - { 34258, 0x00000BA7 }, /* GL_PROJECTION_MATRIX */ - { 34279, 0x0000898E }, /* GL_PROJECTION_MATRIX_FLOAT_AS_INT_BITS_OES */ - { 34322, 0x00000BA4 }, /* GL_PROJECTION_STACK_DEPTH */ - { 34348, 0x00008E4F }, /* GL_PROVOKING_VERTEX */ - { 34368, 0x00008E4F }, /* GL_PROVOKING_VERTEX_EXT */ - { 34392, 0x000080D3 }, /* GL_PROXY_COLOR_TABLE */ - { 34413, 0x00008025 }, /* GL_PROXY_HISTOGRAM */ - { 34432, 0x00008025 }, /* GL_PROXY_HISTOGRAM_EXT */ - { 34455, 0x000080D5 }, /* GL_PROXY_POST_COLOR_MATRIX_COLOR_TABLE */ - { 34494, 0x000080D4 }, /* GL_PROXY_POST_CONVOLUTION_COLOR_TABLE */ - { 34532, 0x00008063 }, /* GL_PROXY_TEXTURE_1D */ - { 34552, 0x00008C19 }, /* GL_PROXY_TEXTURE_1D_ARRAY */ - { 34578, 0x00008C19 }, /* GL_PROXY_TEXTURE_1D_ARRAY_EXT */ - { 34608, 0x00008063 }, /* GL_PROXY_TEXTURE_1D_EXT */ - { 34632, 0x00008064 }, /* GL_PROXY_TEXTURE_2D */ - { 34652, 0x00008C1B }, /* GL_PROXY_TEXTURE_2D_ARRAY */ - { 34678, 0x00008C1B }, /* GL_PROXY_TEXTURE_2D_ARRAY_EXT */ - { 34708, 0x00008064 }, /* GL_PROXY_TEXTURE_2D_EXT */ - { 34732, 0x00008070 }, /* GL_PROXY_TEXTURE_3D */ - { 34752, 0x000080BD }, /* GL_PROXY_TEXTURE_COLOR_TABLE_SGI */ - { 34785, 0x0000851B }, /* GL_PROXY_TEXTURE_CUBE_MAP */ - { 34811, 0x0000851B }, /* GL_PROXY_TEXTURE_CUBE_MAP_ARB */ - { 34841, 0x000084F7 }, /* GL_PROXY_TEXTURE_RECTANGLE */ - { 34868, 0x000084F7 }, /* GL_PROXY_TEXTURE_RECTANGLE_ARB */ - { 34899, 0x000084F7 }, /* GL_PROXY_TEXTURE_RECTANGLE_NV */ - { 34929, 0x00008A1D }, /* GL_PURGEABLE_APPLE */ - { 34948, 0x00002003 }, /* GL_Q */ - { 34953, 0x00001209 }, /* GL_QUADRATIC_ATTENUATION */ - { 34978, 0x00000007 }, /* GL_QUADS */ - { 34987, 0x00008E4C }, /* GL_QUADS_FOLLOW_PROVOKING_VERTEX_CONVENTION */ - { 35031, 0x00008E4C }, /* GL_QUADS_FOLLOW_PROVOKING_VERTEX_CONVENTION_EXT */ - { 35079, 0x00008614 }, /* GL_QUAD_MESH_SUN */ - { 35096, 0x00000008 }, /* GL_QUAD_STRIP */ - { 35110, 0x00008E16 }, /* GL_QUERY_BY_REGION_NO_WAIT */ - { 35137, 0x00008E16 }, /* GL_QUERY_BY_REGION_NO_WAIT_NV */ - { 35167, 0x00008E15 }, /* GL_QUERY_BY_REGION_WAIT */ - { 35191, 0x00008E15 }, /* GL_QUERY_BY_REGION_WAIT_NV */ - { 35218, 0x00008864 }, /* GL_QUERY_COUNTER_BITS */ - { 35240, 0x00008864 }, /* GL_QUERY_COUNTER_BITS_ARB */ - { 35266, 0x00008E14 }, /* GL_QUERY_NO_WAIT */ - { 35283, 0x00008E14 }, /* GL_QUERY_NO_WAIT_NV */ - { 35303, 0x00008866 }, /* GL_QUERY_RESULT */ - { 35319, 0x00008866 }, /* GL_QUERY_RESULT_ARB */ - { 35339, 0x00008867 }, /* GL_QUERY_RESULT_AVAILABLE */ - { 35365, 0x00008867 }, /* GL_QUERY_RESULT_AVAILABLE_ARB */ - { 35395, 0x00008E13 }, /* GL_QUERY_WAIT */ - { 35409, 0x00008E13 }, /* GL_QUERY_WAIT_NV */ - { 35426, 0x00002002 }, /* GL_R */ - { 35431, 0x00008C3A }, /* GL_R11F_G11F_B10F */ - { 35449, 0x00008F98 }, /* GL_R16_SNORM */ - { 35462, 0x00002A10 }, /* GL_R3_G3_B2 */ - { 35474, 0x00008F94 }, /* GL_R8_SNORM */ - { 35486, 0x00008C89 }, /* GL_RASTERIZER_DISCARD */ - { 35508, 0x00008C89 }, /* GL_RASTERIZER_DISCARD_EXT */ - { 35534, 0x00019262 }, /* GL_RASTER_POSITION_UNCLIPPED_IBM */ - { 35567, 0x00000C02 }, /* GL_READ_BUFFER */ - { 35582, 0x00008CA8 }, /* GL_READ_FRAMEBUFFER */ - { 35602, 0x00008CAA }, /* GL_READ_FRAMEBUFFER_BINDING */ - { 35630, 0x00008CAA }, /* GL_READ_FRAMEBUFFER_BINDING_EXT */ - { 35662, 0x00008CA8 }, /* GL_READ_FRAMEBUFFER_EXT */ - { 35686, 0x000088B8 }, /* GL_READ_ONLY */ - { 35699, 0x000088B8 }, /* GL_READ_ONLY_ARB */ - { 35716, 0x000088BA }, /* GL_READ_WRITE */ - { 35730, 0x000088BA }, /* GL_READ_WRITE_ARB */ - { 35748, 0x00001903 }, /* GL_RED */ - { 35755, 0x00008016 }, /* GL_REDUCE */ - { 35765, 0x00008016 }, /* GL_REDUCE_EXT */ - { 35779, 0x00000D15 }, /* GL_RED_BIAS */ - { 35791, 0x00000D52 }, /* GL_RED_BITS */ - { 35803, 0x00008D94 }, /* GL_RED_INTEGER */ - { 35818, 0x00008D94 }, /* GL_RED_INTEGER_EXT */ - { 35837, 0x00000D14 }, /* GL_RED_SCALE */ - { 35850, 0x00008F90 }, /* GL_RED_SNORM */ - { 35863, 0x00008512 }, /* GL_REFLECTION_MAP */ - { 35881, 0x00008512 }, /* GL_REFLECTION_MAP_ARB */ - { 35903, 0x00008512 }, /* GL_REFLECTION_MAP_NV */ - { 35924, 0x00008512 }, /* GL_REFLECTION_MAP_OES */ - { 35946, 0x00008A19 }, /* GL_RELEASED_APPLE */ - { 35964, 0x00001C00 }, /* GL_RENDER */ - { 35974, 0x00008D41 }, /* GL_RENDERBUFFER */ - { 35990, 0x00008D53 }, /* GL_RENDERBUFFER_ALPHA_SIZE */ - { 36017, 0x00008D53 }, /* GL_RENDERBUFFER_ALPHA_SIZE_OES */ - { 36048, 0x00008CA7 }, /* GL_RENDERBUFFER_BINDING */ - { 36072, 0x00008CA7 }, /* GL_RENDERBUFFER_BINDING_EXT */ - { 36100, 0x00008CA7 }, /* GL_RENDERBUFFER_BINDING_OES */ - { 36128, 0x00008D52 }, /* GL_RENDERBUFFER_BLUE_SIZE */ - { 36154, 0x00008D52 }, /* GL_RENDERBUFFER_BLUE_SIZE_OES */ - { 36184, 0x00008D54 }, /* GL_RENDERBUFFER_DEPTH_SIZE */ - { 36211, 0x00008D54 }, /* GL_RENDERBUFFER_DEPTH_SIZE_OES */ - { 36242, 0x00008D41 }, /* GL_RENDERBUFFER_EXT */ - { 36262, 0x00008D51 }, /* GL_RENDERBUFFER_GREEN_SIZE */ - { 36289, 0x00008D51 }, /* GL_RENDERBUFFER_GREEN_SIZE_OES */ - { 36320, 0x00008D43 }, /* GL_RENDERBUFFER_HEIGHT */ - { 36343, 0x00008D43 }, /* GL_RENDERBUFFER_HEIGHT_EXT */ - { 36370, 0x00008D43 }, /* GL_RENDERBUFFER_HEIGHT_OES */ - { 36397, 0x00008D44 }, /* GL_RENDERBUFFER_INTERNAL_FORMAT */ - { 36429, 0x00008D44 }, /* GL_RENDERBUFFER_INTERNAL_FORMAT_EXT */ - { 36465, 0x00008D44 }, /* GL_RENDERBUFFER_INTERNAL_FORMAT_OES */ - { 36501, 0x00008D41 }, /* GL_RENDERBUFFER_OES */ - { 36521, 0x00008D50 }, /* GL_RENDERBUFFER_RED_SIZE */ - { 36546, 0x00008D50 }, /* GL_RENDERBUFFER_RED_SIZE_OES */ - { 36575, 0x00008CAB }, /* GL_RENDERBUFFER_SAMPLES */ - { 36599, 0x00008CAB }, /* GL_RENDERBUFFER_SAMPLES_EXT */ - { 36627, 0x00008D55 }, /* GL_RENDERBUFFER_STENCIL_SIZE */ - { 36656, 0x00008D55 }, /* GL_RENDERBUFFER_STENCIL_SIZE_OES */ - { 36689, 0x00008D42 }, /* GL_RENDERBUFFER_WIDTH */ - { 36711, 0x00008D42 }, /* GL_RENDERBUFFER_WIDTH_EXT */ - { 36737, 0x00008D42 }, /* GL_RENDERBUFFER_WIDTH_OES */ - { 36763, 0x00001F01 }, /* GL_RENDERER */ - { 36775, 0x00000C40 }, /* GL_RENDER_MODE */ - { 36790, 0x00002901 }, /* GL_REPEAT */ - { 36800, 0x00001E01 }, /* GL_REPLACE */ - { 36811, 0x00008062 }, /* GL_REPLACE_EXT */ - { 36826, 0x00008153 }, /* GL_REPLICATE_BORDER_HP */ - { 36849, 0x00008D68 }, /* GL_REQUIRED_TEXTURE_IMAGE_UNITS_OES */ - { 36885, 0x0000803A }, /* GL_RESCALE_NORMAL */ - { 36903, 0x0000803A }, /* GL_RESCALE_NORMAL_EXT */ - { 36925, 0x00008256 }, /* GL_RESET_NOTIFICATION_STRATEGY_ARB */ - { 36960, 0x00008A1B }, /* GL_RETAINED_APPLE */ - { 36978, 0x00000102 }, /* GL_RETURN */ - { 36988, 0x00008F99 }, /* GL_RG16_SNORM */ - { 37002, 0x00008F95 }, /* GL_RG8_SNORM */ - { 37015, 0x00001907 }, /* GL_RGB */ - { 37022, 0x00008052 }, /* GL_RGB10 */ - { 37031, 0x00008059 }, /* GL_RGB10_A2 */ - { 37043, 0x0000906F }, /* GL_RGB10_A2UI */ - { 37057, 0x00008059 }, /* GL_RGB10_A2_EXT */ - { 37073, 0x00008052 }, /* GL_RGB10_EXT */ - { 37086, 0x00008053 }, /* GL_RGB12 */ - { 37095, 0x00008053 }, /* GL_RGB12_EXT */ - { 37108, 0x00008054 }, /* GL_RGB16 */ - { 37117, 0x0000881B }, /* GL_RGB16F */ - { 37127, 0x00008D89 }, /* GL_RGB16I */ - { 37137, 0x00008D89 }, /* GL_RGB16I_EXT */ - { 37151, 0x00008D77 }, /* GL_RGB16UI */ - { 37162, 0x00008D77 }, /* GL_RGB16UI_EXT */ - { 37177, 0x00008054 }, /* GL_RGB16_EXT */ - { 37190, 0x00008F9A }, /* GL_RGB16_SNORM */ - { 37205, 0x0000804E }, /* GL_RGB2_EXT */ - { 37217, 0x00008815 }, /* GL_RGB32F */ - { 37227, 0x00008D83 }, /* GL_RGB32I */ - { 37237, 0x00008D83 }, /* GL_RGB32I_EXT */ - { 37251, 0x00008D71 }, /* GL_RGB32UI */ - { 37262, 0x00008D71 }, /* GL_RGB32UI_EXT */ - { 37277, 0x0000804F }, /* GL_RGB4 */ - { 37285, 0x0000804F }, /* GL_RGB4_EXT */ - { 37297, 0x000083A1 }, /* GL_RGB4_S3TC */ - { 37310, 0x00008050 }, /* GL_RGB5 */ - { 37318, 0x00008D62 }, /* GL_RGB565 */ - { 37328, 0x00008D62 }, /* GL_RGB565_OES */ - { 37342, 0x00008057 }, /* GL_RGB5_A1 */ - { 37353, 0x00008057 }, /* GL_RGB5_A1_EXT */ - { 37368, 0x00008057 }, /* GL_RGB5_A1_OES */ - { 37383, 0x00008050 }, /* GL_RGB5_EXT */ - { 37395, 0x00008051 }, /* GL_RGB8 */ - { 37403, 0x00008D8F }, /* GL_RGB8I */ - { 37412, 0x00008D8F }, /* GL_RGB8I_EXT */ - { 37425, 0x00008D7D }, /* GL_RGB8UI */ - { 37435, 0x00008D7D }, /* GL_RGB8UI_EXT */ - { 37449, 0x00008051 }, /* GL_RGB8_EXT */ - { 37461, 0x00008051 }, /* GL_RGB8_OES */ - { 37473, 0x00008F96 }, /* GL_RGB8_SNORM */ - { 37487, 0x00008C3D }, /* GL_RGB9_E5 */ - { 37498, 0x00001908 }, /* GL_RGBA */ - { 37506, 0x0000805A }, /* GL_RGBA12 */ - { 37516, 0x0000805A }, /* GL_RGBA12_EXT */ - { 37530, 0x0000805B }, /* GL_RGBA16 */ - { 37540, 0x0000881A }, /* GL_RGBA16F */ - { 37551, 0x00008D88 }, /* GL_RGBA16I */ - { 37562, 0x00008D88 }, /* GL_RGBA16I_EXT */ - { 37577, 0x00008D76 }, /* GL_RGBA16UI */ - { 37589, 0x00008D76 }, /* GL_RGBA16UI_EXT */ - { 37605, 0x0000805B }, /* GL_RGBA16_EXT */ - { 37619, 0x00008F9B }, /* GL_RGBA16_SNORM */ - { 37635, 0x00008055 }, /* GL_RGBA2 */ - { 37644, 0x00008055 }, /* GL_RGBA2_EXT */ - { 37657, 0x00008814 }, /* GL_RGBA32F */ - { 37668, 0x00008D82 }, /* GL_RGBA32I */ - { 37679, 0x00008D82 }, /* GL_RGBA32I_EXT */ - { 37694, 0x00008D70 }, /* GL_RGBA32UI */ - { 37706, 0x00008D70 }, /* GL_RGBA32UI_EXT */ - { 37722, 0x00008056 }, /* GL_RGBA4 */ - { 37731, 0x000083A5 }, /* GL_RGBA4_DXT5_S3TC */ - { 37750, 0x00008056 }, /* GL_RGBA4_EXT */ - { 37763, 0x00008056 }, /* GL_RGBA4_OES */ - { 37776, 0x000083A3 }, /* GL_RGBA4_S3TC */ - { 37790, 0x00008058 }, /* GL_RGBA8 */ - { 37799, 0x00008D8E }, /* GL_RGBA8I */ - { 37809, 0x00008D8E }, /* GL_RGBA8I_EXT */ - { 37823, 0x00008D7C }, /* GL_RGBA8UI */ - { 37834, 0x00008D7C }, /* GL_RGBA8UI_EXT */ - { 37849, 0x00008058 }, /* GL_RGBA8_EXT */ - { 37862, 0x00008058 }, /* GL_RGBA8_OES */ - { 37875, 0x00008F97 }, /* GL_RGBA8_SNORM */ - { 37890, 0x000083A4 }, /* GL_RGBA_DXT5_S3TC */ - { 37908, 0x00008820 }, /* GL_RGBA_FLOAT_MODE_ARB */ - { 37931, 0x00008D99 }, /* GL_RGBA_INTEGER */ - { 37947, 0x00008D99 }, /* GL_RGBA_INTEGER_EXT */ - { 37967, 0x00008D9E }, /* GL_RGBA_INTEGER_MODE_EXT */ - { 37992, 0x00000C31 }, /* GL_RGBA_MODE */ - { 38005, 0x000083A2 }, /* GL_RGBA_S3TC */ - { 38018, 0x00008F93 }, /* GL_RGBA_SNORM */ - { 38032, 0x00008D98 }, /* GL_RGB_INTEGER */ - { 38047, 0x00008D98 }, /* GL_RGB_INTEGER_EXT */ - { 38066, 0x000083A0 }, /* GL_RGB_S3TC */ - { 38078, 0x00008573 }, /* GL_RGB_SCALE */ - { 38091, 0x00008573 }, /* GL_RGB_SCALE_ARB */ - { 38108, 0x00008573 }, /* GL_RGB_SCALE_EXT */ - { 38125, 0x00008F92 }, /* GL_RGB_SNORM */ - { 38138, 0x00008F91 }, /* GL_RG_SNORM */ - { 38150, 0x00000407 }, /* GL_RIGHT */ - { 38159, 0x00002000 }, /* GL_S */ - { 38164, 0x00008B5D }, /* GL_SAMPLER_1D */ - { 38178, 0x00008DC0 }, /* GL_SAMPLER_1D_ARRAY */ - { 38198, 0x00008DC0 }, /* GL_SAMPLER_1D_ARRAY_EXT */ - { 38222, 0x00008DC3 }, /* GL_SAMPLER_1D_ARRAY_SHADOW */ - { 38249, 0x00008DC3 }, /* GL_SAMPLER_1D_ARRAY_SHADOW_EXT */ - { 38280, 0x00008B61 }, /* GL_SAMPLER_1D_SHADOW */ - { 38301, 0x00008B5E }, /* GL_SAMPLER_2D */ - { 38315, 0x00008DC1 }, /* GL_SAMPLER_2D_ARRAY */ - { 38335, 0x00008DC1 }, /* GL_SAMPLER_2D_ARRAY_EXT */ - { 38359, 0x00008DC4 }, /* GL_SAMPLER_2D_ARRAY_SHADOW */ - { 38386, 0x00008DC4 }, /* GL_SAMPLER_2D_ARRAY_SHADOW_EXT */ - { 38417, 0x00008B63 }, /* GL_SAMPLER_2D_RECT */ - { 38436, 0x00008B64 }, /* GL_SAMPLER_2D_RECT_SHADOW */ - { 38462, 0x00008B62 }, /* GL_SAMPLER_2D_SHADOW */ - { 38483, 0x00008B5F }, /* GL_SAMPLER_3D */ - { 38497, 0x00008B5F }, /* GL_SAMPLER_3D_OES */ - { 38515, 0x00008919 }, /* GL_SAMPLER_BINDING */ - { 38534, 0x00008DC2 }, /* GL_SAMPLER_BUFFER */ - { 38552, 0x00008DC2 }, /* GL_SAMPLER_BUFFER_EXT */ - { 38574, 0x00008B60 }, /* GL_SAMPLER_CUBE */ - { 38590, 0x00008DC5 }, /* GL_SAMPLER_CUBE_SHADOW */ - { 38613, 0x00008DC5 }, /* GL_SAMPLER_CUBE_SHADOW_EXT */ - { 38640, 0x00008D66 }, /* GL_SAMPLER_EXTERNAL_OES */ - { 38664, 0x000080A9 }, /* GL_SAMPLES */ - { 38675, 0x000086B4 }, /* GL_SAMPLES_3DFX */ - { 38691, 0x000080A9 }, /* GL_SAMPLES_ARB */ - { 38706, 0x00008914 }, /* GL_SAMPLES_PASSED */ - { 38724, 0x00008914 }, /* GL_SAMPLES_PASSED_ARB */ - { 38746, 0x0000809E }, /* GL_SAMPLE_ALPHA_TO_COVERAGE */ - { 38774, 0x0000809E }, /* GL_SAMPLE_ALPHA_TO_COVERAGE_ARB */ - { 38806, 0x0000809F }, /* GL_SAMPLE_ALPHA_TO_ONE */ - { 38829, 0x0000809F }, /* GL_SAMPLE_ALPHA_TO_ONE_ARB */ - { 38856, 0x000080A8 }, /* GL_SAMPLE_BUFFERS */ - { 38874, 0x000086B3 }, /* GL_SAMPLE_BUFFERS_3DFX */ - { 38897, 0x000080A8 }, /* GL_SAMPLE_BUFFERS_ARB */ - { 38919, 0x000080A0 }, /* GL_SAMPLE_COVERAGE */ - { 38938, 0x000080A0 }, /* GL_SAMPLE_COVERAGE_ARB */ - { 38961, 0x000080AB }, /* GL_SAMPLE_COVERAGE_INVERT */ - { 38987, 0x000080AB }, /* GL_SAMPLE_COVERAGE_INVERT_ARB */ - { 39017, 0x000080AA }, /* GL_SAMPLE_COVERAGE_VALUE */ - { 39042, 0x000080AA }, /* GL_SAMPLE_COVERAGE_VALUE_ARB */ - { 39071, 0x00080000 }, /* GL_SCISSOR_BIT */ - { 39086, 0x00000C10 }, /* GL_SCISSOR_BOX */ - { 39101, 0x00000C11 }, /* GL_SCISSOR_TEST */ - { 39117, 0x0000845E }, /* GL_SECONDARY_COLOR_ARRAY */ - { 39142, 0x0000889C }, /* GL_SECONDARY_COLOR_ARRAY_BUFFER_BINDING */ - { 39182, 0x0000889C }, /* GL_SECONDARY_COLOR_ARRAY_BUFFER_BINDING_ARB */ - { 39226, 0x0000845D }, /* GL_SECONDARY_COLOR_ARRAY_POINTER */ - { 39259, 0x0000845A }, /* GL_SECONDARY_COLOR_ARRAY_SIZE */ - { 39289, 0x0000845C }, /* GL_SECONDARY_COLOR_ARRAY_STRIDE */ - { 39321, 0x0000845B }, /* GL_SECONDARY_COLOR_ARRAY_TYPE */ - { 39351, 0x00001C02 }, /* GL_SELECT */ - { 39361, 0x00000DF3 }, /* GL_SELECTION_BUFFER_POINTER */ - { 39389, 0x00000DF4 }, /* GL_SELECTION_BUFFER_SIZE */ - { 39414, 0x00008012 }, /* GL_SEPARABLE_2D */ - { 39430, 0x00008C8D }, /* GL_SEPARATE_ATTRIBS */ - { 39450, 0x00008C8D }, /* GL_SEPARATE_ATTRIBS_EXT */ - { 39474, 0x000081FA }, /* GL_SEPARATE_SPECULAR_COLOR */ - { 39501, 0x000081FA }, /* GL_SEPARATE_SPECULAR_COLOR_EXT */ - { 39532, 0x0000150F }, /* GL_SET */ - { 39539, 0x00008DF8 }, /* GL_SHADER_BINARY_FORMATS */ - { 39564, 0x00008DFA }, /* GL_SHADER_COMPILER */ - { 39583, 0x00008B48 }, /* GL_SHADER_OBJECT_ARB */ - { 39604, 0x00008B88 }, /* GL_SHADER_SOURCE_LENGTH */ - { 39628, 0x00008B4F }, /* GL_SHADER_TYPE */ - { 39643, 0x00000B54 }, /* GL_SHADE_MODEL */ - { 39658, 0x00008B8C }, /* GL_SHADING_LANGUAGE_VERSION */ - { 39686, 0x000080BF }, /* GL_SHADOW_AMBIENT_SGIX */ - { 39709, 0x000081FB }, /* GL_SHARED_TEXTURE_PALETTE_EXT */ - { 39739, 0x00001601 }, /* GL_SHININESS */ - { 39752, 0x00001402 }, /* GL_SHORT */ - { 39761, 0x00009119 }, /* GL_SIGNALED */ - { 39773, 0x00008F9C }, /* GL_SIGNED_NORMALIZED */ - { 39794, 0x000081F9 }, /* GL_SINGLE_COLOR */ - { 39810, 0x000081F9 }, /* GL_SINGLE_COLOR_EXT */ - { 39830, 0x000085CC }, /* GL_SLICE_ACCUM_SUN */ - { 39849, 0x00008C46 }, /* GL_SLUMINANCE */ - { 39863, 0x00008C47 }, /* GL_SLUMINANCE8 */ - { 39878, 0x00008C45 }, /* GL_SLUMINANCE8_ALPHA8 */ - { 39900, 0x00008C44 }, /* GL_SLUMINANCE_ALPHA */ - { 39920, 0x00001D01 }, /* GL_SMOOTH */ - { 39930, 0x00000B23 }, /* GL_SMOOTH_LINE_WIDTH_GRANULARITY */ - { 39963, 0x00000B22 }, /* GL_SMOOTH_LINE_WIDTH_RANGE */ - { 39990, 0x00000B13 }, /* GL_SMOOTH_POINT_SIZE_GRANULARITY */ - { 40023, 0x00000B12 }, /* GL_SMOOTH_POINT_SIZE_RANGE */ - { 40050, 0x00008588 }, /* GL_SOURCE0_ALPHA */ - { 40067, 0x00008588 }, /* GL_SOURCE0_ALPHA_ARB */ - { 40088, 0x00008588 }, /* GL_SOURCE0_ALPHA_EXT */ - { 40109, 0x00008580 }, /* GL_SOURCE0_RGB */ - { 40124, 0x00008580 }, /* GL_SOURCE0_RGB_ARB */ - { 40143, 0x00008580 }, /* GL_SOURCE0_RGB_EXT */ - { 40162, 0x00008589 }, /* GL_SOURCE1_ALPHA */ - { 40179, 0x00008589 }, /* GL_SOURCE1_ALPHA_ARB */ - { 40200, 0x00008589 }, /* GL_SOURCE1_ALPHA_EXT */ - { 40221, 0x00008581 }, /* GL_SOURCE1_RGB */ - { 40236, 0x00008581 }, /* GL_SOURCE1_RGB_ARB */ - { 40255, 0x00008581 }, /* GL_SOURCE1_RGB_EXT */ - { 40274, 0x0000858A }, /* GL_SOURCE2_ALPHA */ - { 40291, 0x0000858A }, /* GL_SOURCE2_ALPHA_ARB */ - { 40312, 0x0000858A }, /* GL_SOURCE2_ALPHA_EXT */ - { 40333, 0x00008582 }, /* GL_SOURCE2_RGB */ - { 40348, 0x00008582 }, /* GL_SOURCE2_RGB_ARB */ - { 40367, 0x00008582 }, /* GL_SOURCE2_RGB_EXT */ - { 40386, 0x0000858B }, /* GL_SOURCE3_ALPHA_NV */ - { 40406, 0x00008583 }, /* GL_SOURCE3_RGB_NV */ - { 40424, 0x00001202 }, /* GL_SPECULAR */ - { 40436, 0x00002402 }, /* GL_SPHERE_MAP */ - { 40450, 0x00001206 }, /* GL_SPOT_CUTOFF */ - { 40465, 0x00001204 }, /* GL_SPOT_DIRECTION */ - { 40483, 0x00001205 }, /* GL_SPOT_EXPONENT */ - { 40500, 0x00008588 }, /* GL_SRC0_ALPHA */ - { 40514, 0x00008580 }, /* GL_SRC0_RGB */ - { 40526, 0x00008589 }, /* GL_SRC1_ALPHA */ - { 40540, 0x00008581 }, /* GL_SRC1_RGB */ - { 40552, 0x0000858A }, /* GL_SRC2_ALPHA */ - { 40566, 0x00008582 }, /* GL_SRC2_RGB */ - { 40578, 0x00000302 }, /* GL_SRC_ALPHA */ - { 40591, 0x00000308 }, /* GL_SRC_ALPHA_SATURATE */ - { 40613, 0x00000300 }, /* GL_SRC_COLOR */ - { 40626, 0x00008C40 }, /* GL_SRGB */ - { 40634, 0x00008C41 }, /* GL_SRGB8 */ - { 40643, 0x00008C43 }, /* GL_SRGB8_ALPHA8 */ - { 40659, 0x00008C42 }, /* GL_SRGB_ALPHA */ - { 40673, 0x00000503 }, /* GL_STACK_OVERFLOW */ - { 40691, 0x00000504 }, /* GL_STACK_UNDERFLOW */ - { 40710, 0x000088E6 }, /* GL_STATIC_COPY */ - { 40725, 0x000088E6 }, /* GL_STATIC_COPY_ARB */ - { 40744, 0x000088E4 }, /* GL_STATIC_DRAW */ - { 40759, 0x000088E4 }, /* GL_STATIC_DRAW_ARB */ - { 40778, 0x000088E5 }, /* GL_STATIC_READ */ - { 40793, 0x000088E5 }, /* GL_STATIC_READ_ARB */ - { 40812, 0x00001802 }, /* GL_STENCIL */ - { 40823, 0x00008D20 }, /* GL_STENCIL_ATTACHMENT */ - { 40845, 0x00008D20 }, /* GL_STENCIL_ATTACHMENT_EXT */ - { 40871, 0x00008D20 }, /* GL_STENCIL_ATTACHMENT_OES */ - { 40897, 0x00008801 }, /* GL_STENCIL_BACK_FAIL */ - { 40918, 0x00008801 }, /* GL_STENCIL_BACK_FAIL_ATI */ - { 40943, 0x00008800 }, /* GL_STENCIL_BACK_FUNC */ - { 40964, 0x00008800 }, /* GL_STENCIL_BACK_FUNC_ATI */ - { 40989, 0x00008802 }, /* GL_STENCIL_BACK_PASS_DEPTH_FAIL */ - { 41021, 0x00008802 }, /* GL_STENCIL_BACK_PASS_DEPTH_FAIL_ATI */ - { 41057, 0x00008803 }, /* GL_STENCIL_BACK_PASS_DEPTH_PASS */ - { 41089, 0x00008803 }, /* GL_STENCIL_BACK_PASS_DEPTH_PASS_ATI */ - { 41125, 0x00008CA3 }, /* GL_STENCIL_BACK_REF */ - { 41145, 0x00008CA4 }, /* GL_STENCIL_BACK_VALUE_MASK */ - { 41172, 0x00008CA5 }, /* GL_STENCIL_BACK_WRITEMASK */ - { 41198, 0x00000D57 }, /* GL_STENCIL_BITS */ - { 41214, 0x00008224 }, /* GL_STENCIL_BUFFER */ - { 41232, 0x00000400 }, /* GL_STENCIL_BUFFER_BIT */ - { 41254, 0x00000B91 }, /* GL_STENCIL_CLEAR_VALUE */ - { 41277, 0x00000B94 }, /* GL_STENCIL_FAIL */ - { 41293, 0x00000B92 }, /* GL_STENCIL_FUNC */ - { 41309, 0x00001901 }, /* GL_STENCIL_INDEX */ - { 41326, 0x00008D46 }, /* GL_STENCIL_INDEX1 */ - { 41344, 0x00008D49 }, /* GL_STENCIL_INDEX16 */ - { 41363, 0x00008D49 }, /* GL_STENCIL_INDEX16_EXT */ - { 41386, 0x00008D46 }, /* GL_STENCIL_INDEX1_EXT */ - { 41408, 0x00008D46 }, /* GL_STENCIL_INDEX1_OES */ - { 41430, 0x00008D47 }, /* GL_STENCIL_INDEX4 */ - { 41448, 0x00008D47 }, /* GL_STENCIL_INDEX4_EXT */ - { 41470, 0x00008D47 }, /* GL_STENCIL_INDEX4_OES */ - { 41492, 0x00008D48 }, /* GL_STENCIL_INDEX8 */ - { 41510, 0x00008D48 }, /* GL_STENCIL_INDEX8_EXT */ - { 41532, 0x00008D48 }, /* GL_STENCIL_INDEX8_OES */ - { 41554, 0x00008D45 }, /* GL_STENCIL_INDEX_EXT */ - { 41575, 0x00000B95 }, /* GL_STENCIL_PASS_DEPTH_FAIL */ - { 41602, 0x00000B96 }, /* GL_STENCIL_PASS_DEPTH_PASS */ - { 41629, 0x00000B97 }, /* GL_STENCIL_REF */ - { 41644, 0x00000B90 }, /* GL_STENCIL_TEST */ - { 41660, 0x00008910 }, /* GL_STENCIL_TEST_TWO_SIDE_EXT */ - { 41689, 0x00000B93 }, /* GL_STENCIL_VALUE_MASK */ - { 41711, 0x00000B98 }, /* GL_STENCIL_WRITEMASK */ - { 41732, 0x00000C33 }, /* GL_STEREO */ - { 41742, 0x000085BE }, /* GL_STORAGE_CACHED_APPLE */ - { 41766, 0x000085BD }, /* GL_STORAGE_PRIVATE_APPLE */ - { 41791, 0x000085BF }, /* GL_STORAGE_SHARED_APPLE */ - { 41815, 0x000088E2 }, /* GL_STREAM_COPY */ - { 41830, 0x000088E2 }, /* GL_STREAM_COPY_ARB */ - { 41849, 0x000088E0 }, /* GL_STREAM_DRAW */ - { 41864, 0x000088E0 }, /* GL_STREAM_DRAW_ARB */ - { 41883, 0x000088E1 }, /* GL_STREAM_READ */ - { 41898, 0x000088E1 }, /* GL_STREAM_READ_ARB */ - { 41917, 0x00000D50 }, /* GL_SUBPIXEL_BITS */ - { 41934, 0x000084E7 }, /* GL_SUBTRACT */ - { 41946, 0x000084E7 }, /* GL_SUBTRACT_ARB */ - { 41962, 0x00009113 }, /* GL_SYNC_CONDITION */ - { 41980, 0x00009116 }, /* GL_SYNC_FENCE */ - { 41994, 0x00009115 }, /* GL_SYNC_FLAGS */ - { 42008, 0x00000001 }, /* GL_SYNC_FLUSH_COMMANDS_BIT */ - { 42035, 0x00009117 }, /* GL_SYNC_GPU_COMMANDS_COMPLETE */ - { 42065, 0x00009114 }, /* GL_SYNC_STATUS */ - { 42080, 0x00002001 }, /* GL_T */ - { 42085, 0x00002A2A }, /* GL_T2F_C3F_V3F */ - { 42100, 0x00002A2C }, /* GL_T2F_C4F_N3F_V3F */ - { 42119, 0x00002A29 }, /* GL_T2F_C4UB_V3F */ - { 42135, 0x00002A2B }, /* GL_T2F_N3F_V3F */ - { 42150, 0x00002A27 }, /* GL_T2F_V3F */ - { 42161, 0x00002A2D }, /* GL_T4F_C4F_N3F_V4F */ - { 42180, 0x00002A28 }, /* GL_T4F_V4F */ - { 42191, 0x00008031 }, /* GL_TABLE_TOO_LARGE_EXT */ - { 42214, 0x00001702 }, /* GL_TEXTURE */ - { 42225, 0x000084C0 }, /* GL_TEXTURE0 */ - { 42237, 0x000084C0 }, /* GL_TEXTURE0_ARB */ - { 42253, 0x000084C1 }, /* GL_TEXTURE1 */ - { 42265, 0x000084CA }, /* GL_TEXTURE10 */ - { 42278, 0x000084CA }, /* GL_TEXTURE10_ARB */ - { 42295, 0x000084CB }, /* GL_TEXTURE11 */ - { 42308, 0x000084CB }, /* GL_TEXTURE11_ARB */ - { 42325, 0x000084CC }, /* GL_TEXTURE12 */ - { 42338, 0x000084CC }, /* GL_TEXTURE12_ARB */ - { 42355, 0x000084CD }, /* GL_TEXTURE13 */ - { 42368, 0x000084CD }, /* GL_TEXTURE13_ARB */ - { 42385, 0x000084CE }, /* GL_TEXTURE14 */ - { 42398, 0x000084CE }, /* GL_TEXTURE14_ARB */ - { 42415, 0x000084CF }, /* GL_TEXTURE15 */ - { 42428, 0x000084CF }, /* GL_TEXTURE15_ARB */ - { 42445, 0x000084D0 }, /* GL_TEXTURE16 */ - { 42458, 0x000084D0 }, /* GL_TEXTURE16_ARB */ - { 42475, 0x000084D1 }, /* GL_TEXTURE17 */ - { 42488, 0x000084D1 }, /* GL_TEXTURE17_ARB */ - { 42505, 0x000084D2 }, /* GL_TEXTURE18 */ - { 42518, 0x000084D2 }, /* GL_TEXTURE18_ARB */ - { 42535, 0x000084D3 }, /* GL_TEXTURE19 */ - { 42548, 0x000084D3 }, /* GL_TEXTURE19_ARB */ - { 42565, 0x000084C1 }, /* GL_TEXTURE1_ARB */ - { 42581, 0x000084C2 }, /* GL_TEXTURE2 */ - { 42593, 0x000084D4 }, /* GL_TEXTURE20 */ - { 42606, 0x000084D4 }, /* GL_TEXTURE20_ARB */ - { 42623, 0x000084D5 }, /* GL_TEXTURE21 */ - { 42636, 0x000084D5 }, /* GL_TEXTURE21_ARB */ - { 42653, 0x000084D6 }, /* GL_TEXTURE22 */ - { 42666, 0x000084D6 }, /* GL_TEXTURE22_ARB */ - { 42683, 0x000084D7 }, /* GL_TEXTURE23 */ - { 42696, 0x000084D7 }, /* GL_TEXTURE23_ARB */ - { 42713, 0x000084D8 }, /* GL_TEXTURE24 */ - { 42726, 0x000084D8 }, /* GL_TEXTURE24_ARB */ - { 42743, 0x000084D9 }, /* GL_TEXTURE25 */ - { 42756, 0x000084D9 }, /* GL_TEXTURE25_ARB */ - { 42773, 0x000084DA }, /* GL_TEXTURE26 */ - { 42786, 0x000084DA }, /* GL_TEXTURE26_ARB */ - { 42803, 0x000084DB }, /* GL_TEXTURE27 */ - { 42816, 0x000084DB }, /* GL_TEXTURE27_ARB */ - { 42833, 0x000084DC }, /* GL_TEXTURE28 */ - { 42846, 0x000084DC }, /* GL_TEXTURE28_ARB */ - { 42863, 0x000084DD }, /* GL_TEXTURE29 */ - { 42876, 0x000084DD }, /* GL_TEXTURE29_ARB */ - { 42893, 0x000084C2 }, /* GL_TEXTURE2_ARB */ - { 42909, 0x000084C3 }, /* GL_TEXTURE3 */ - { 42921, 0x000084DE }, /* GL_TEXTURE30 */ - { 42934, 0x000084DE }, /* GL_TEXTURE30_ARB */ - { 42951, 0x000084DF }, /* GL_TEXTURE31 */ - { 42964, 0x000084DF }, /* GL_TEXTURE31_ARB */ - { 42981, 0x000084C3 }, /* GL_TEXTURE3_ARB */ - { 42997, 0x000084C4 }, /* GL_TEXTURE4 */ - { 43009, 0x000084C4 }, /* GL_TEXTURE4_ARB */ - { 43025, 0x000084C5 }, /* GL_TEXTURE5 */ - { 43037, 0x000084C5 }, /* GL_TEXTURE5_ARB */ - { 43053, 0x000084C6 }, /* GL_TEXTURE6 */ - { 43065, 0x000084C6 }, /* GL_TEXTURE6_ARB */ - { 43081, 0x000084C7 }, /* GL_TEXTURE7 */ - { 43093, 0x000084C7 }, /* GL_TEXTURE7_ARB */ - { 43109, 0x000084C8 }, /* GL_TEXTURE8 */ - { 43121, 0x000084C8 }, /* GL_TEXTURE8_ARB */ - { 43137, 0x000084C9 }, /* GL_TEXTURE9 */ - { 43149, 0x000084C9 }, /* GL_TEXTURE9_ARB */ - { 43165, 0x00000DE0 }, /* GL_TEXTURE_1D */ - { 43179, 0x00008C18 }, /* GL_TEXTURE_1D_ARRAY */ - { 43199, 0x00008C18 }, /* GL_TEXTURE_1D_ARRAY_EXT */ - { 43223, 0x00000DE1 }, /* GL_TEXTURE_2D */ - { 43237, 0x00008C1A }, /* GL_TEXTURE_2D_ARRAY */ - { 43257, 0x00008C1A }, /* GL_TEXTURE_2D_ARRAY_EXT */ - { 43281, 0x0000806F }, /* GL_TEXTURE_3D */ - { 43295, 0x0000806F }, /* GL_TEXTURE_3D_OES */ - { 43313, 0x0000805F }, /* GL_TEXTURE_ALPHA_SIZE */ - { 43335, 0x0000805F }, /* GL_TEXTURE_ALPHA_SIZE_EXT */ - { 43361, 0x0000813C }, /* GL_TEXTURE_BASE_LEVEL */ - { 43383, 0x00008068 }, /* GL_TEXTURE_BINDING_1D */ - { 43405, 0x00008C1C }, /* GL_TEXTURE_BINDING_1D_ARRAY */ - { 43433, 0x00008C1C }, /* GL_TEXTURE_BINDING_1D_ARRAY_EXT */ - { 43465, 0x00008069 }, /* GL_TEXTURE_BINDING_2D */ - { 43487, 0x00008C1D }, /* GL_TEXTURE_BINDING_2D_ARRAY */ - { 43515, 0x00008C1D }, /* GL_TEXTURE_BINDING_2D_ARRAY_EXT */ - { 43547, 0x0000806A }, /* GL_TEXTURE_BINDING_3D */ - { 43569, 0x0000806A }, /* GL_TEXTURE_BINDING_3D_OES */ - { 43595, 0x00008C2C }, /* GL_TEXTURE_BINDING_BUFFER */ - { 43621, 0x00008C2C }, /* GL_TEXTURE_BINDING_BUFFER_ARB */ - { 43651, 0x00008514 }, /* GL_TEXTURE_BINDING_CUBE_MAP */ - { 43679, 0x00008514 }, /* GL_TEXTURE_BINDING_CUBE_MAP_ARB */ - { 43711, 0x00008514 }, /* GL_TEXTURE_BINDING_CUBE_MAP_OES */ - { 43743, 0x00008D67 }, /* GL_TEXTURE_BINDING_EXTERNAL_OES */ - { 43775, 0x000084F6 }, /* GL_TEXTURE_BINDING_RECTANGLE */ - { 43804, 0x000084F6 }, /* GL_TEXTURE_BINDING_RECTANGLE_ARB */ - { 43837, 0x000084F6 }, /* GL_TEXTURE_BINDING_RECTANGLE_NV */ - { 43869, 0x00040000 }, /* GL_TEXTURE_BIT */ - { 43884, 0x0000805E }, /* GL_TEXTURE_BLUE_SIZE */ - { 43905, 0x0000805E }, /* GL_TEXTURE_BLUE_SIZE_EXT */ - { 43930, 0x00001005 }, /* GL_TEXTURE_BORDER */ - { 43948, 0x00001004 }, /* GL_TEXTURE_BORDER_COLOR */ - { 43972, 0x00008C2A }, /* GL_TEXTURE_BUFFER */ - { 43990, 0x00008C2A }, /* GL_TEXTURE_BUFFER_ARB */ - { 44012, 0x00008C2D }, /* GL_TEXTURE_BUFFER_DATA_STORE_BINDING */ - { 44049, 0x00008C2D }, /* GL_TEXTURE_BUFFER_DATA_STORE_BINDING_ARB */ - { 44090, 0x00008C2E }, /* GL_TEXTURE_BUFFER_FORMAT */ - { 44115, 0x00008C2E }, /* GL_TEXTURE_BUFFER_FORMAT_ARB */ - { 44144, 0x00008171 }, /* GL_TEXTURE_CLIPMAP_CENTER_SGIX */ - { 44175, 0x00008176 }, /* GL_TEXTURE_CLIPMAP_DEPTH_SGIX */ - { 44205, 0x00008172 }, /* GL_TEXTURE_CLIPMAP_FRAME_SGIX */ - { 44235, 0x00008175 }, /* GL_TEXTURE_CLIPMAP_LOD_OFFSET_SGIX */ - { 44270, 0x00008173 }, /* GL_TEXTURE_CLIPMAP_OFFSET_SGIX */ - { 44301, 0x00008174 }, /* GL_TEXTURE_CLIPMAP_VIRTUAL_DEPTH_SGIX */ - { 44339, 0x000080BC }, /* GL_TEXTURE_COLOR_TABLE_SGI */ - { 44366, 0x000081EF }, /* GL_TEXTURE_COLOR_WRITEMASK_SGIS */ - { 44398, 0x000080BF }, /* GL_TEXTURE_COMPARE_FAIL_VALUE_ARB */ - { 44432, 0x0000884D }, /* GL_TEXTURE_COMPARE_FUNC */ - { 44456, 0x0000884D }, /* GL_TEXTURE_COMPARE_FUNC_ARB */ - { 44484, 0x0000884C }, /* GL_TEXTURE_COMPARE_MODE */ - { 44508, 0x0000884C }, /* GL_TEXTURE_COMPARE_MODE_ARB */ - { 44536, 0x0000819B }, /* GL_TEXTURE_COMPARE_OPERATOR_SGIX */ - { 44569, 0x0000819A }, /* GL_TEXTURE_COMPARE_SGIX */ - { 44593, 0x00001003 }, /* GL_TEXTURE_COMPONENTS */ - { 44615, 0x000086A1 }, /* GL_TEXTURE_COMPRESSED */ - { 44637, 0x000086A1 }, /* GL_TEXTURE_COMPRESSED_ARB */ - { 44663, 0x000086A3 }, /* GL_TEXTURE_COMPRESSED_FORMATS_ARB */ - { 44697, 0x000086A0 }, /* GL_TEXTURE_COMPRESSED_IMAGE_SIZE */ - { 44730, 0x000086A0 }, /* GL_TEXTURE_COMPRESSED_IMAGE_SIZE_ARB */ - { 44767, 0x000084EF }, /* GL_TEXTURE_COMPRESSION_HINT */ - { 44795, 0x000084EF }, /* GL_TEXTURE_COMPRESSION_HINT_ARB */ - { 44827, 0x00008078 }, /* GL_TEXTURE_COORD_ARRAY */ - { 44850, 0x0000889A }, /* GL_TEXTURE_COORD_ARRAY_BUFFER_BINDING */ - { 44888, 0x0000889A }, /* GL_TEXTURE_COORD_ARRAY_BUFFER_BINDING_ARB */ - { 44930, 0x00008092 }, /* GL_TEXTURE_COORD_ARRAY_POINTER */ - { 44961, 0x00008088 }, /* GL_TEXTURE_COORD_ARRAY_SIZE */ - { 44989, 0x0000808A }, /* GL_TEXTURE_COORD_ARRAY_STRIDE */ - { 45019, 0x00008089 }, /* GL_TEXTURE_COORD_ARRAY_TYPE */ - { 45047, 0x00008B9D }, /* GL_TEXTURE_CROP_RECT_OES */ - { 45072, 0x00008513 }, /* GL_TEXTURE_CUBE_MAP */ - { 45092, 0x00008513 }, /* GL_TEXTURE_CUBE_MAP_ARB */ - { 45116, 0x00008516 }, /* GL_TEXTURE_CUBE_MAP_NEGATIVE_X */ - { 45147, 0x00008516 }, /* GL_TEXTURE_CUBE_MAP_NEGATIVE_X_ARB */ - { 45182, 0x00008516 }, /* GL_TEXTURE_CUBE_MAP_NEGATIVE_X_OES */ - { 45217, 0x00008518 }, /* GL_TEXTURE_CUBE_MAP_NEGATIVE_Y */ - { 45248, 0x00008518 }, /* GL_TEXTURE_CUBE_MAP_NEGATIVE_Y_ARB */ - { 45283, 0x00008518 }, /* GL_TEXTURE_CUBE_MAP_NEGATIVE_Y_OES */ - { 45318, 0x0000851A }, /* GL_TEXTURE_CUBE_MAP_NEGATIVE_Z */ - { 45349, 0x0000851A }, /* GL_TEXTURE_CUBE_MAP_NEGATIVE_Z_ARB */ - { 45384, 0x0000851A }, /* GL_TEXTURE_CUBE_MAP_NEGATIVE_Z_OES */ - { 45419, 0x00008513 }, /* GL_TEXTURE_CUBE_MAP_OES */ - { 45443, 0x00008515 }, /* GL_TEXTURE_CUBE_MAP_POSITIVE_X */ - { 45474, 0x00008515 }, /* GL_TEXTURE_CUBE_MAP_POSITIVE_X_ARB */ - { 45509, 0x00008515 }, /* GL_TEXTURE_CUBE_MAP_POSITIVE_X_OES */ - { 45544, 0x00008517 }, /* GL_TEXTURE_CUBE_MAP_POSITIVE_Y */ - { 45575, 0x00008517 }, /* GL_TEXTURE_CUBE_MAP_POSITIVE_Y_ARB */ - { 45610, 0x00008517 }, /* GL_TEXTURE_CUBE_MAP_POSITIVE_Y_OES */ - { 45645, 0x00008519 }, /* GL_TEXTURE_CUBE_MAP_POSITIVE_Z */ - { 45676, 0x00008519 }, /* GL_TEXTURE_CUBE_MAP_POSITIVE_Z_ARB */ - { 45711, 0x00008519 }, /* GL_TEXTURE_CUBE_MAP_POSITIVE_Z_OES */ - { 45746, 0x000088F4 }, /* GL_TEXTURE_CUBE_MAP_SEAMLESS */ - { 45775, 0x00008071 }, /* GL_TEXTURE_DEPTH */ - { 45792, 0x0000884A }, /* GL_TEXTURE_DEPTH_SIZE */ - { 45814, 0x0000884A }, /* GL_TEXTURE_DEPTH_SIZE_ARB */ - { 45840, 0x00002300 }, /* GL_TEXTURE_ENV */ - { 45855, 0x00002201 }, /* GL_TEXTURE_ENV_COLOR */ - { 45876, 0x00002200 }, /* GL_TEXTURE_ENV_MODE */ - { 45896, 0x00008D65 }, /* GL_TEXTURE_EXTERNAL_OES */ - { 45920, 0x00008500 }, /* GL_TEXTURE_FILTER_CONTROL */ - { 45946, 0x00008500 }, /* GL_TEXTURE_FILTER_CONTROL_EXT */ - { 45976, 0x00002500 }, /* GL_TEXTURE_GEN_MODE */ - { 45996, 0x00002500 }, /* GL_TEXTURE_GEN_MODE_OES */ - { 46020, 0x00000C63 }, /* GL_TEXTURE_GEN_Q */ - { 46037, 0x00000C62 }, /* GL_TEXTURE_GEN_R */ - { 46054, 0x00000C60 }, /* GL_TEXTURE_GEN_S */ - { 46071, 0x00008D60 }, /* GL_TEXTURE_GEN_STR_OES */ - { 46094, 0x00000C61 }, /* GL_TEXTURE_GEN_T */ - { 46111, 0x0000819D }, /* GL_TEXTURE_GEQUAL_R_SGIX */ - { 46136, 0x0000805D }, /* GL_TEXTURE_GREEN_SIZE */ - { 46158, 0x0000805D }, /* GL_TEXTURE_GREEN_SIZE_EXT */ - { 46184, 0x00001001 }, /* GL_TEXTURE_HEIGHT */ - { 46202, 0x000080ED }, /* GL_TEXTURE_INDEX_SIZE_EXT */ - { 46228, 0x00008061 }, /* GL_TEXTURE_INTENSITY_SIZE */ - { 46254, 0x00008061 }, /* GL_TEXTURE_INTENSITY_SIZE_EXT */ - { 46284, 0x00001003 }, /* GL_TEXTURE_INTERNAL_FORMAT */ - { 46311, 0x0000819C }, /* GL_TEXTURE_LEQUAL_R_SGIX */ - { 46336, 0x00008501 }, /* GL_TEXTURE_LOD_BIAS */ - { 46356, 0x00008501 }, /* GL_TEXTURE_LOD_BIAS_EXT */ - { 46380, 0x00008190 }, /* GL_TEXTURE_LOD_BIAS_R_SGIX */ - { 46407, 0x0000818E }, /* GL_TEXTURE_LOD_BIAS_S_SGIX */ - { 46434, 0x0000818F }, /* GL_TEXTURE_LOD_BIAS_T_SGIX */ - { 46461, 0x00008060 }, /* GL_TEXTURE_LUMINANCE_SIZE */ - { 46487, 0x00008060 }, /* GL_TEXTURE_LUMINANCE_SIZE_EXT */ - { 46517, 0x00002800 }, /* GL_TEXTURE_MAG_FILTER */ - { 46539, 0x00000BA8 }, /* GL_TEXTURE_MATRIX */ - { 46557, 0x0000898F }, /* GL_TEXTURE_MATRIX_FLOAT_AS_INT_BITS_OES */ - { 46597, 0x000084FE }, /* GL_TEXTURE_MAX_ANISOTROPY_EXT */ - { 46627, 0x0000836B }, /* GL_TEXTURE_MAX_CLAMP_R_SGIX */ - { 46655, 0x00008369 }, /* GL_TEXTURE_MAX_CLAMP_S_SGIX */ - { 46683, 0x0000836A }, /* GL_TEXTURE_MAX_CLAMP_T_SGIX */ - { 46711, 0x0000813D }, /* GL_TEXTURE_MAX_LEVEL */ - { 46732, 0x0000813B }, /* GL_TEXTURE_MAX_LOD */ - { 46751, 0x00002801 }, /* GL_TEXTURE_MIN_FILTER */ - { 46773, 0x0000813A }, /* GL_TEXTURE_MIN_LOD */ - { 46792, 0x00008066 }, /* GL_TEXTURE_PRIORITY */ - { 46812, 0x000085B7 }, /* GL_TEXTURE_RANGE_LENGTH_APPLE */ - { 46842, 0x000085B8 }, /* GL_TEXTURE_RANGE_POINTER_APPLE */ - { 46873, 0x000084F5 }, /* GL_TEXTURE_RECTANGLE */ - { 46894, 0x000084F5 }, /* GL_TEXTURE_RECTANGLE_ARB */ - { 46919, 0x000084F5 }, /* GL_TEXTURE_RECTANGLE_NV */ - { 46943, 0x0000805C }, /* GL_TEXTURE_RED_SIZE */ - { 46963, 0x0000805C }, /* GL_TEXTURE_RED_SIZE_EXT */ - { 46987, 0x00008067 }, /* GL_TEXTURE_RESIDENT */ - { 47007, 0x00008C3F }, /* GL_TEXTURE_SHARED_SIZE */ - { 47030, 0x00000BA5 }, /* GL_TEXTURE_STACK_DEPTH */ - { 47053, 0x000088F1 }, /* GL_TEXTURE_STENCIL_SIZE */ - { 47077, 0x000088F1 }, /* GL_TEXTURE_STENCIL_SIZE_EXT */ - { 47105, 0x000085BC }, /* GL_TEXTURE_STORAGE_HINT_APPLE */ - { 47135, 0x00008065 }, /* GL_TEXTURE_TOO_LARGE_EXT */ - { 47160, 0x0000888F }, /* GL_TEXTURE_UNSIGNED_REMAP_MODE_NV */ - { 47194, 0x00001000 }, /* GL_TEXTURE_WIDTH */ - { 47211, 0x00008072 }, /* GL_TEXTURE_WRAP_R */ - { 47229, 0x00008072 }, /* GL_TEXTURE_WRAP_R_OES */ - { 47251, 0x00002802 }, /* GL_TEXTURE_WRAP_S */ - { 47269, 0x00002803 }, /* GL_TEXTURE_WRAP_T */ - { 47287, 0x0000911B }, /* GL_TIMEOUT_EXPIRED */ - { 47306, 0x000088BF }, /* GL_TIME_ELAPSED_EXT */ - { 47326, 0x00008648 }, /* GL_TRACK_MATRIX_NV */ - { 47345, 0x00008649 }, /* GL_TRACK_MATRIX_TRANSFORM_NV */ - { 47374, 0x00001000 }, /* GL_TRANSFORM_BIT */ - { 47391, 0x00008E22 }, /* GL_TRANSFORM_FEEDBACK */ - { 47413, 0x00008E25 }, /* GL_TRANSFORM_FEEDBACK_BINDING */ - { 47443, 0x00008C8E }, /* GL_TRANSFORM_FEEDBACK_BUFFER */ - { 47472, 0x00008E24 }, /* GL_TRANSFORM_FEEDBACK_BUFFER_ACTIVE */ - { 47508, 0x00008C8F }, /* GL_TRANSFORM_FEEDBACK_BUFFER_BINDING */ - { 47545, 0x00008C8F }, /* GL_TRANSFORM_FEEDBACK_BUFFER_BINDING_EXT */ - { 47586, 0x00008C8E }, /* GL_TRANSFORM_FEEDBACK_BUFFER_EXT */ - { 47619, 0x00008C7F }, /* GL_TRANSFORM_FEEDBACK_BUFFER_MODE */ - { 47653, 0x00008C7F }, /* GL_TRANSFORM_FEEDBACK_BUFFER_MODE_EXT */ - { 47691, 0x00008E23 }, /* GL_TRANSFORM_FEEDBACK_BUFFER_PAUSED */ - { 47727, 0x00008C85 }, /* GL_TRANSFORM_FEEDBACK_BUFFER_SIZE */ - { 47761, 0x00008C85 }, /* GL_TRANSFORM_FEEDBACK_BUFFER_SIZE_EXT */ - { 47799, 0x00008C84 }, /* GL_TRANSFORM_FEEDBACK_BUFFER_START */ - { 47834, 0x00008C84 }, /* GL_TRANSFORM_FEEDBACK_BUFFER_START_EXT */ - { 47873, 0x00008C88 }, /* GL_TRANSFORM_FEEDBACK_PRIMITIVES_WRITTEN */ - { 47914, 0x00008C88 }, /* GL_TRANSFORM_FEEDBACK_PRIMITIVES_WRITTEN_EXT */ - { 47959, 0x00008C83 }, /* GL_TRANSFORM_FEEDBACK_VARYINGS */ - { 47990, 0x00008C83 }, /* GL_TRANSFORM_FEEDBACK_VARYINGS_EXT */ - { 48025, 0x00008C76 }, /* GL_TRANSFORM_FEEDBACK_VARYING_MAX_LENGTH */ - { 48066, 0x00008C76 }, /* GL_TRANSFORM_FEEDBACK_VARYING_MAX_LENGTH_EXT */ - { 48111, 0x000084E6 }, /* GL_TRANSPOSE_COLOR_MATRIX */ - { 48137, 0x000084E6 }, /* GL_TRANSPOSE_COLOR_MATRIX_ARB */ - { 48167, 0x000088B7 }, /* GL_TRANSPOSE_CURRENT_MATRIX_ARB */ - { 48199, 0x000084E3 }, /* GL_TRANSPOSE_MODELVIEW_MATRIX */ - { 48229, 0x000084E3 }, /* GL_TRANSPOSE_MODELVIEW_MATRIX_ARB */ - { 48263, 0x0000862C }, /* GL_TRANSPOSE_NV */ - { 48279, 0x000084E4 }, /* GL_TRANSPOSE_PROJECTION_MATRIX */ - { 48310, 0x000084E4 }, /* GL_TRANSPOSE_PROJECTION_MATRIX_ARB */ - { 48345, 0x000084E5 }, /* GL_TRANSPOSE_TEXTURE_MATRIX */ - { 48373, 0x000084E5 }, /* GL_TRANSPOSE_TEXTURE_MATRIX_ARB */ - { 48405, 0x00000004 }, /* GL_TRIANGLES */ - { 48418, 0x0000000C }, /* GL_TRIANGLES_ADJACENCY */ - { 48441, 0x0000000C }, /* GL_TRIANGLES_ADJACENCY_ARB */ - { 48468, 0x00000006 }, /* GL_TRIANGLE_FAN */ - { 48484, 0x00008615 }, /* GL_TRIANGLE_MESH_SUN */ - { 48505, 0x00000005 }, /* GL_TRIANGLE_STRIP */ - { 48523, 0x0000000D }, /* GL_TRIANGLE_STRIP_ADJACENCY */ - { 48551, 0x0000000D }, /* GL_TRIANGLE_STRIP_ADJACENCY_ARB */ - { 48583, 0x00000001 }, /* GL_TRUE */ - { 48591, 0x00008A1C }, /* GL_UNDEFINED_APPLE */ - { 48610, 0x00008255 }, /* GL_UNKNOWN_CONTEXT_RESET_ARB */ - { 48639, 0x00000CF5 }, /* GL_UNPACK_ALIGNMENT */ - { 48659, 0x0000806E }, /* GL_UNPACK_IMAGE_HEIGHT */ - { 48682, 0x00000CF1 }, /* GL_UNPACK_LSB_FIRST */ - { 48702, 0x00000CF2 }, /* GL_UNPACK_ROW_LENGTH */ - { 48723, 0x0000806D }, /* GL_UNPACK_SKIP_IMAGES */ - { 48745, 0x00000CF4 }, /* GL_UNPACK_SKIP_PIXELS */ - { 48767, 0x00000CF3 }, /* GL_UNPACK_SKIP_ROWS */ - { 48787, 0x00000CF0 }, /* GL_UNPACK_SWAP_BYTES */ - { 48808, 0x00009118 }, /* GL_UNSIGNALED */ - { 48822, 0x00001401 }, /* GL_UNSIGNED_BYTE */ - { 48839, 0x00008362 }, /* GL_UNSIGNED_BYTE_2_3_3_REV */ - { 48866, 0x00008032 }, /* GL_UNSIGNED_BYTE_3_3_2 */ - { 48889, 0x00001405 }, /* GL_UNSIGNED_INT */ - { 48905, 0x00008C3B }, /* GL_UNSIGNED_INT_10F_11F_11F_REV */ - { 48937, 0x00008036 }, /* GL_UNSIGNED_INT_10_10_10_2 */ - { 48964, 0x00008DF6 }, /* GL_UNSIGNED_INT_10_10_10_2_OES */ - { 48995, 0x000084FA }, /* GL_UNSIGNED_INT_24_8 */ - { 49016, 0x000084FA }, /* GL_UNSIGNED_INT_24_8_EXT */ - { 49041, 0x000084FA }, /* GL_UNSIGNED_INT_24_8_NV */ - { 49065, 0x000084FA }, /* GL_UNSIGNED_INT_24_8_OES */ - { 49090, 0x00008368 }, /* GL_UNSIGNED_INT_2_10_10_10_REV */ - { 49121, 0x00008368 }, /* GL_UNSIGNED_INT_2_10_10_10_REV_EXT */ - { 49156, 0x00008C3E }, /* GL_UNSIGNED_INT_5_9_9_9_REV */ - { 49184, 0x00008035 }, /* GL_UNSIGNED_INT_8_8_8_8 */ - { 49208, 0x00008367 }, /* GL_UNSIGNED_INT_8_8_8_8_REV */ - { 49236, 0x00008DD1 }, /* GL_UNSIGNED_INT_SAMPLER_1D */ - { 49263, 0x00008DD6 }, /* GL_UNSIGNED_INT_SAMPLER_1D_ARRAY */ - { 49296, 0x00008DD6 }, /* GL_UNSIGNED_INT_SAMPLER_1D_ARRAY_EXT */ - { 49333, 0x00008DD1 }, /* GL_UNSIGNED_INT_SAMPLER_1D_EXT */ - { 49364, 0x00008DD2 }, /* GL_UNSIGNED_INT_SAMPLER_2D */ - { 49391, 0x00008DD7 }, /* GL_UNSIGNED_INT_SAMPLER_2D_ARRAY */ - { 49424, 0x00008DD7 }, /* GL_UNSIGNED_INT_SAMPLER_2D_ARRAY_EXT */ - { 49461, 0x00008DD2 }, /* GL_UNSIGNED_INT_SAMPLER_2D_EXT */ - { 49492, 0x00008DD5 }, /* GL_UNSIGNED_INT_SAMPLER_2D_RECT */ - { 49524, 0x00008DD5 }, /* GL_UNSIGNED_INT_SAMPLER_2D_RECT_EXT */ - { 49560, 0x00008DD3 }, /* GL_UNSIGNED_INT_SAMPLER_3D */ - { 49587, 0x00008DD3 }, /* GL_UNSIGNED_INT_SAMPLER_3D_EXT */ - { 49618, 0x00008DD8 }, /* GL_UNSIGNED_INT_SAMPLER_BUFFER */ - { 49649, 0x00008DD8 }, /* GL_UNSIGNED_INT_SAMPLER_BUFFER_EXT */ - { 49684, 0x00008DD4 }, /* GL_UNSIGNED_INT_SAMPLER_CUBE */ - { 49713, 0x00008DD4 }, /* GL_UNSIGNED_INT_SAMPLER_CUBE_EXT */ - { 49746, 0x00008DC6 }, /* GL_UNSIGNED_INT_VEC2 */ - { 49767, 0x00008DC6 }, /* GL_UNSIGNED_INT_VEC2_EXT */ - { 49792, 0x00008DC7 }, /* GL_UNSIGNED_INT_VEC3 */ - { 49813, 0x00008DC7 }, /* GL_UNSIGNED_INT_VEC3_EXT */ - { 49838, 0x00008DC8 }, /* GL_UNSIGNED_INT_VEC4 */ - { 49859, 0x00008DC8 }, /* GL_UNSIGNED_INT_VEC4_EXT */ - { 49884, 0x00008C17 }, /* GL_UNSIGNED_NORMALIZED */ - { 49907, 0x00001403 }, /* GL_UNSIGNED_SHORT */ - { 49925, 0x00008366 }, /* GL_UNSIGNED_SHORT_1_5_5_5_REV */ - { 49955, 0x00008366 }, /* GL_UNSIGNED_SHORT_1_5_5_5_REV_EXT */ - { 49989, 0x00008033 }, /* GL_UNSIGNED_SHORT_4_4_4_4 */ - { 50015, 0x00008365 }, /* GL_UNSIGNED_SHORT_4_4_4_4_REV */ - { 50045, 0x00008365 }, /* GL_UNSIGNED_SHORT_4_4_4_4_REV_EXT */ - { 50079, 0x00008034 }, /* GL_UNSIGNED_SHORT_5_5_5_1 */ - { 50105, 0x00008363 }, /* GL_UNSIGNED_SHORT_5_6_5 */ - { 50129, 0x00008364 }, /* GL_UNSIGNED_SHORT_5_6_5_REV */ - { 50157, 0x000085BA }, /* GL_UNSIGNED_SHORT_8_8_APPLE */ - { 50185, 0x000085BA }, /* GL_UNSIGNED_SHORT_8_8_MESA */ - { 50212, 0x000085BB }, /* GL_UNSIGNED_SHORT_8_8_REV_APPLE */ - { 50244, 0x000085BB }, /* GL_UNSIGNED_SHORT_8_8_REV_MESA */ - { 50275, 0x00008CA2 }, /* GL_UPPER_LEFT */ - { 50289, 0x00002A20 }, /* GL_V2F */ - { 50296, 0x00002A21 }, /* GL_V3F */ - { 50303, 0x00008B83 }, /* GL_VALIDATE_STATUS */ - { 50322, 0x00001F00 }, /* GL_VENDOR */ - { 50332, 0x00001F02 }, /* GL_VERSION */ - { 50343, 0x00008074 }, /* GL_VERTEX_ARRAY */ - { 50359, 0x000085B5 }, /* GL_VERTEX_ARRAY_BINDING */ - { 50383, 0x000085B5 }, /* GL_VERTEX_ARRAY_BINDING_APPLE */ - { 50413, 0x00008896 }, /* GL_VERTEX_ARRAY_BUFFER_BINDING */ - { 50444, 0x00008896 }, /* GL_VERTEX_ARRAY_BUFFER_BINDING_ARB */ - { 50479, 0x0000808E }, /* GL_VERTEX_ARRAY_POINTER */ - { 50503, 0x0000807A }, /* GL_VERTEX_ARRAY_SIZE */ - { 50524, 0x0000807C }, /* GL_VERTEX_ARRAY_STRIDE */ - { 50547, 0x0000807B }, /* GL_VERTEX_ARRAY_TYPE */ - { 50568, 0x00008650 }, /* GL_VERTEX_ATTRIB_ARRAY0_NV */ - { 50595, 0x0000865A }, /* GL_VERTEX_ATTRIB_ARRAY10_NV */ - { 50623, 0x0000865B }, /* GL_VERTEX_ATTRIB_ARRAY11_NV */ - { 50651, 0x0000865C }, /* GL_VERTEX_ATTRIB_ARRAY12_NV */ - { 50679, 0x0000865D }, /* GL_VERTEX_ATTRIB_ARRAY13_NV */ - { 50707, 0x0000865E }, /* GL_VERTEX_ATTRIB_ARRAY14_NV */ - { 50735, 0x0000865F }, /* GL_VERTEX_ATTRIB_ARRAY15_NV */ - { 50763, 0x00008651 }, /* GL_VERTEX_ATTRIB_ARRAY1_NV */ - { 50790, 0x00008652 }, /* GL_VERTEX_ATTRIB_ARRAY2_NV */ - { 50817, 0x00008653 }, /* GL_VERTEX_ATTRIB_ARRAY3_NV */ - { 50844, 0x00008654 }, /* GL_VERTEX_ATTRIB_ARRAY4_NV */ - { 50871, 0x00008655 }, /* GL_VERTEX_ATTRIB_ARRAY5_NV */ - { 50898, 0x00008656 }, /* GL_VERTEX_ATTRIB_ARRAY6_NV */ - { 50925, 0x00008657 }, /* GL_VERTEX_ATTRIB_ARRAY7_NV */ - { 50952, 0x00008658 }, /* GL_VERTEX_ATTRIB_ARRAY8_NV */ - { 50979, 0x00008659 }, /* GL_VERTEX_ATTRIB_ARRAY9_NV */ - { 51006, 0x0000889F }, /* GL_VERTEX_ATTRIB_ARRAY_BUFFER_BINDING */ - { 51044, 0x0000889F }, /* GL_VERTEX_ATTRIB_ARRAY_BUFFER_BINDING_ARB */ - { 51086, 0x000088FE }, /* GL_VERTEX_ATTRIB_ARRAY_DIVISOR_ARB */ - { 51121, 0x00008622 }, /* GL_VERTEX_ATTRIB_ARRAY_ENABLED */ - { 51152, 0x00008622 }, /* GL_VERTEX_ATTRIB_ARRAY_ENABLED_ARB */ - { 51187, 0x000088FD }, /* GL_VERTEX_ATTRIB_ARRAY_INTEGER */ - { 51218, 0x000088FD }, /* GL_VERTEX_ATTRIB_ARRAY_INTEGER_EXT */ - { 51253, 0x0000886A }, /* GL_VERTEX_ATTRIB_ARRAY_NORMALIZED */ - { 51287, 0x0000886A }, /* GL_VERTEX_ATTRIB_ARRAY_NORMALIZED_ARB */ - { 51325, 0x00008645 }, /* GL_VERTEX_ATTRIB_ARRAY_POINTER */ - { 51356, 0x00008645 }, /* GL_VERTEX_ATTRIB_ARRAY_POINTER_ARB */ - { 51391, 0x00008623 }, /* GL_VERTEX_ATTRIB_ARRAY_SIZE */ - { 51419, 0x00008623 }, /* GL_VERTEX_ATTRIB_ARRAY_SIZE_ARB */ - { 51451, 0x00008624 }, /* GL_VERTEX_ATTRIB_ARRAY_STRIDE */ - { 51481, 0x00008624 }, /* GL_VERTEX_ATTRIB_ARRAY_STRIDE_ARB */ - { 51515, 0x00008625 }, /* GL_VERTEX_ATTRIB_ARRAY_TYPE */ - { 51543, 0x00008625 }, /* GL_VERTEX_ATTRIB_ARRAY_TYPE_ARB */ - { 51575, 0x000086A7 }, /* GL_VERTEX_BLEND_ARB */ - { 51595, 0x00008620 }, /* GL_VERTEX_PROGRAM_ARB */ - { 51617, 0x0000864A }, /* GL_VERTEX_PROGRAM_BINDING_NV */ - { 51646, 0x00008620 }, /* GL_VERTEX_PROGRAM_NV */ - { 51667, 0x00008642 }, /* GL_VERTEX_PROGRAM_POINT_SIZE */ - { 51696, 0x00008642 }, /* GL_VERTEX_PROGRAM_POINT_SIZE_ARB */ - { 51729, 0x00008642 }, /* GL_VERTEX_PROGRAM_POINT_SIZE_NV */ - { 51761, 0x00008643 }, /* GL_VERTEX_PROGRAM_TWO_SIDE */ - { 51788, 0x00008643 }, /* GL_VERTEX_PROGRAM_TWO_SIDE_ARB */ - { 51819, 0x00008643 }, /* GL_VERTEX_PROGRAM_TWO_SIDE_NV */ - { 51849, 0x00008B31 }, /* GL_VERTEX_SHADER */ - { 51866, 0x00008B31 }, /* GL_VERTEX_SHADER_ARB */ - { 51887, 0x00008621 }, /* GL_VERTEX_STATE_PROGRAM_NV */ - { 51914, 0x00000BA2 }, /* GL_VIEWPORT */ - { 51926, 0x00000800 }, /* GL_VIEWPORT_BIT */ - { 51942, 0x00008A1A }, /* GL_VOLATILE_APPLE */ - { 51960, 0x0000911D }, /* GL_WAIT_FAILED */ - { 51975, 0x000086AD }, /* GL_WEIGHT_ARRAY_ARB */ - { 51995, 0x0000889E }, /* GL_WEIGHT_ARRAY_BUFFER_BINDING */ - { 52026, 0x0000889E }, /* GL_WEIGHT_ARRAY_BUFFER_BINDING_ARB */ - { 52061, 0x0000889E }, /* GL_WEIGHT_ARRAY_BUFFER_BINDING_OES */ - { 52096, 0x000086AD }, /* GL_WEIGHT_ARRAY_OES */ - { 52116, 0x000086AC }, /* GL_WEIGHT_ARRAY_POINTER_ARB */ - { 52144, 0x000086AC }, /* GL_WEIGHT_ARRAY_POINTER_OES */ - { 52172, 0x000086AB }, /* GL_WEIGHT_ARRAY_SIZE_ARB */ - { 52197, 0x000086AB }, /* GL_WEIGHT_ARRAY_SIZE_OES */ - { 52222, 0x000086AA }, /* GL_WEIGHT_ARRAY_STRIDE_ARB */ - { 52249, 0x000086AA }, /* GL_WEIGHT_ARRAY_STRIDE_OES */ - { 52276, 0x000086A9 }, /* GL_WEIGHT_ARRAY_TYPE_ARB */ - { 52301, 0x000086A9 }, /* GL_WEIGHT_ARRAY_TYPE_OES */ - { 52326, 0x000086A6 }, /* GL_WEIGHT_SUM_UNITY_ARB */ - { 52350, 0x000081D4 }, /* GL_WRAP_BORDER_SUN */ - { 52369, 0x000088B9 }, /* GL_WRITE_ONLY */ - { 52383, 0x000088B9 }, /* GL_WRITE_ONLY_ARB */ - { 52401, 0x000088B9 }, /* GL_WRITE_ONLY_OES */ - { 52419, 0x00001506 }, /* GL_XOR */ - { 52426, 0x000085B9 }, /* GL_YCBCR_422_APPLE */ - { 52445, 0x00008757 }, /* GL_YCBCR_MESA */ - { 52459, 0x00000000 }, /* GL_ZERO */ - { 52467, 0x00000D16 }, /* GL_ZOOM_X */ - { 52477, 0x00000D17 }, /* GL_ZOOM_Y */ -}; - -static const unsigned reduced_enums[1571] = -{ - 556, /* GL_FALSE */ - 853, /* GL_LINES */ - 857, /* GL_LINE_LOOP */ - 864, /* GL_LINE_STRIP */ - 2179, /* GL_TRIANGLES */ - 2184, /* GL_TRIANGLE_STRIP */ - 2182, /* GL_TRIANGLE_FAN */ - 1539, /* GL_QUADS */ - 1543, /* GL_QUAD_STRIP */ - 1407, /* GL_POLYGON */ - 854, /* GL_LINES_ADJACENCY */ - 865, /* GL_LINE_STRIP_ADJACENCY */ - 2180, /* GL_TRIANGLES_ADJACENCY */ - 2185, /* GL_TRIANGLE_STRIP_ADJACENCY */ - 1419, /* GL_POLYGON_STIPPLE_BIT */ - 1362, /* GL_PIXEL_MODE_BIT */ - 840, /* GL_LIGHTING_BIT */ - 590, /* GL_FOG_BIT */ - 8, /* GL_ACCUM */ - 876, /* GL_LOAD */ - 1630, /* GL_RETURN */ - 1227, /* GL_MULT */ - 24, /* GL_ADD */ - 1243, /* GL_NEVER */ - 830, /* GL_LESS */ - 545, /* GL_EQUAL */ - 829, /* GL_LEQUAL */ - 714, /* GL_GREATER */ - 1260, /* GL_NOTEQUAL */ - 712, /* GL_GEQUAL */ - 55, /* GL_ALWAYS */ - 1841, /* GL_SRC_COLOR */ - 1295, /* GL_ONE_MINUS_SRC_COLOR */ - 1839, /* GL_SRC_ALPHA */ - 1294, /* GL_ONE_MINUS_SRC_ALPHA */ - 524, /* GL_DST_ALPHA */ - 1292, /* GL_ONE_MINUS_DST_ALPHA */ - 525, /* GL_DST_COLOR */ - 1293, /* GL_ONE_MINUS_DST_COLOR */ - 1840, /* GL_SRC_ALPHA_SATURATE */ - 689, /* GL_FRONT_LEFT */ - 690, /* GL_FRONT_RIGHT */ - 77, /* GL_BACK_LEFT */ - 78, /* GL_BACK_RIGHT */ - 686, /* GL_FRONT */ - 76, /* GL_BACK */ - 828, /* GL_LEFT */ - 1721, /* GL_RIGHT */ - 687, /* GL_FRONT_AND_BACK */ - 71, /* GL_AUX0 */ - 72, /* GL_AUX1 */ - 73, /* GL_AUX2 */ - 74, /* GL_AUX3 */ - 816, /* GL_INVALID_ENUM */ - 821, /* GL_INVALID_VALUE */ - 820, /* GL_INVALID_OPERATION */ - 1846, /* GL_STACK_OVERFLOW */ - 1847, /* GL_STACK_UNDERFLOW */ - 1320, /* GL_OUT_OF_MEMORY */ - 817, /* GL_INVALID_FRAMEBUFFER_OPERATION */ - 0, /* GL_2D */ - 2, /* GL_3D */ - 3, /* GL_3D_COLOR */ - 4, /* GL_3D_COLOR_TEXTURE */ - 6, /* GL_4D_COLOR_TEXTURE */ - 1340, /* GL_PASS_THROUGH_TOKEN */ - 1406, /* GL_POINT_TOKEN */ - 867, /* GL_LINE_TOKEN */ - 1420, /* GL_POLYGON_TOKEN */ - 87, /* GL_BITMAP_TOKEN */ - 523, /* GL_DRAW_PIXEL_TOKEN */ - 353, /* GL_COPY_PIXEL_TOKEN */ - 858, /* GL_LINE_RESET_TOKEN */ - 549, /* GL_EXP */ - 550, /* GL_EXP2 */ - 390, /* GL_CW */ - 154, /* GL_CCW */ - 187, /* GL_COEFF */ - 1317, /* GL_ORDER */ - 444, /* GL_DOMAIN */ - 363, /* GL_CURRENT_COLOR */ - 366, /* GL_CURRENT_INDEX */ - 372, /* GL_CURRENT_NORMAL */ - 386, /* GL_CURRENT_TEXTURE_COORDS */ - 378, /* GL_CURRENT_RASTER_COLOR */ - 380, /* GL_CURRENT_RASTER_INDEX */ - 384, /* GL_CURRENT_RASTER_TEXTURE_COORDS */ - 381, /* GL_CURRENT_RASTER_POSITION */ - 382, /* GL_CURRENT_RASTER_POSITION_VALID */ - 379, /* GL_CURRENT_RASTER_DISTANCE */ - 1398, /* GL_POINT_SMOOTH */ - 1382, /* GL_POINT_SIZE */ - 1397, /* GL_POINT_SIZE_RANGE */ - 1388, /* GL_POINT_SIZE_GRANULARITY */ - 859, /* GL_LINE_SMOOTH */ - 868, /* GL_LINE_WIDTH */ - 870, /* GL_LINE_WIDTH_RANGE */ - 869, /* GL_LINE_WIDTH_GRANULARITY */ - 861, /* GL_LINE_STIPPLE */ - 862, /* GL_LINE_STIPPLE_PATTERN */ - 863, /* GL_LINE_STIPPLE_REPEAT */ - 875, /* GL_LIST_MODE */ - 1084, /* GL_MAX_LIST_NESTING */ - 872, /* GL_LIST_BASE */ - 874, /* GL_LIST_INDEX */ - 1409, /* GL_POLYGON_MODE */ - 1416, /* GL_POLYGON_SMOOTH */ - 1418, /* GL_POLYGON_STIPPLE */ - 534, /* GL_EDGE_FLAG */ - 356, /* GL_CULL_FACE */ - 357, /* GL_CULL_FACE_MODE */ - 688, /* GL_FRONT_FACE */ - 839, /* GL_LIGHTING */ - 844, /* GL_LIGHT_MODEL_LOCAL_VIEWER */ - 845, /* GL_LIGHT_MODEL_TWO_SIDE */ - 841, /* GL_LIGHT_MODEL_AMBIENT */ - 1788, /* GL_SHADE_MODEL */ - 235, /* GL_COLOR_MATERIAL_FACE */ - 236, /* GL_COLOR_MATERIAL_PARAMETER */ - 234, /* GL_COLOR_MATERIAL */ - 589, /* GL_FOG */ - 611, /* GL_FOG_INDEX */ - 607, /* GL_FOG_DENSITY */ - 615, /* GL_FOG_START */ - 609, /* GL_FOG_END */ - 612, /* GL_FOG_MODE */ - 591, /* GL_FOG_COLOR */ - 429, /* GL_DEPTH_RANGE */ - 438, /* GL_DEPTH_TEST */ - 441, /* GL_DEPTH_WRITEMASK */ - 414, /* GL_DEPTH_CLEAR_VALUE */ - 428, /* GL_DEPTH_FUNC */ - 12, /* GL_ACCUM_CLEAR_VALUE */ - 1891, /* GL_STENCIL_TEST */ - 1872, /* GL_STENCIL_CLEAR_VALUE */ - 1874, /* GL_STENCIL_FUNC */ - 1893, /* GL_STENCIL_VALUE_MASK */ - 1873, /* GL_STENCIL_FAIL */ - 1888, /* GL_STENCIL_PASS_DEPTH_FAIL */ - 1889, /* GL_STENCIL_PASS_DEPTH_PASS */ - 1890, /* GL_STENCIL_REF */ - 1894, /* GL_STENCIL_WRITEMASK */ - 1033, /* GL_MATRIX_MODE */ - 1249, /* GL_NORMALIZE */ - 2312, /* GL_VIEWPORT */ - 1222, /* GL_MODELVIEW_STACK_DEPTH */ - 1513, /* GL_PROJECTION_STACK_DEPTH */ - 2133, /* GL_TEXTURE_STACK_DEPTH */ - 1219, /* GL_MODELVIEW_MATRIX */ - 1511, /* GL_PROJECTION_MATRIX */ - 2113, /* GL_TEXTURE_MATRIX */ - 69, /* GL_ATTRIB_STACK_DEPTH */ - 169, /* GL_CLIENT_ATTRIB_STACK_DEPTH */ - 51, /* GL_ALPHA_TEST */ - 52, /* GL_ALPHA_TEST_FUNC */ - 53, /* GL_ALPHA_TEST_REF */ - 443, /* GL_DITHER */ - 91, /* GL_BLEND_DST */ - 105, /* GL_BLEND_SRC */ - 88, /* GL_BLEND */ - 878, /* GL_LOGIC_OP_MODE */ - 763, /* GL_INDEX_LOGIC_OP */ - 233, /* GL_COLOR_LOGIC_OP */ - 75, /* GL_AUX_BUFFERS */ - 454, /* GL_DRAW_BUFFER */ - 1566, /* GL_READ_BUFFER */ - 1765, /* GL_SCISSOR_BOX */ - 1766, /* GL_SCISSOR_TEST */ - 762, /* GL_INDEX_CLEAR_VALUE */ - 767, /* GL_INDEX_WRITEMASK */ - 230, /* GL_COLOR_CLEAR_VALUE */ - 272, /* GL_COLOR_WRITEMASK */ - 764, /* GL_INDEX_MODE */ - 1710, /* GL_RGBA_MODE */ - 453, /* GL_DOUBLEBUFFER */ - 1895, /* GL_STEREO */ - 1620, /* GL_RENDER_MODE */ - 1341, /* GL_PERSPECTIVE_CORRECTION_HINT */ - 1399, /* GL_POINT_SMOOTH_HINT */ - 860, /* GL_LINE_SMOOTH_HINT */ - 1417, /* GL_POLYGON_SMOOTH_HINT */ - 610, /* GL_FOG_HINT */ - 2093, /* GL_TEXTURE_GEN_S */ - 2095, /* GL_TEXTURE_GEN_T */ - 2092, /* GL_TEXTURE_GEN_R */ - 2091, /* GL_TEXTURE_GEN_Q */ - 1354, /* GL_PIXEL_MAP_I_TO_I */ - 1360, /* GL_PIXEL_MAP_S_TO_S */ - 1356, /* GL_PIXEL_MAP_I_TO_R */ - 1352, /* GL_PIXEL_MAP_I_TO_G */ - 1350, /* GL_PIXEL_MAP_I_TO_B */ - 1348, /* GL_PIXEL_MAP_I_TO_A */ - 1358, /* GL_PIXEL_MAP_R_TO_R */ - 1346, /* GL_PIXEL_MAP_G_TO_G */ - 1344, /* GL_PIXEL_MAP_B_TO_B */ - 1342, /* GL_PIXEL_MAP_A_TO_A */ - 1355, /* GL_PIXEL_MAP_I_TO_I_SIZE */ - 1361, /* GL_PIXEL_MAP_S_TO_S_SIZE */ - 1357, /* GL_PIXEL_MAP_I_TO_R_SIZE */ - 1353, /* GL_PIXEL_MAP_I_TO_G_SIZE */ - 1351, /* GL_PIXEL_MAP_I_TO_B_SIZE */ - 1349, /* GL_PIXEL_MAP_I_TO_A_SIZE */ - 1359, /* GL_PIXEL_MAP_R_TO_R_SIZE */ - 1347, /* GL_PIXEL_MAP_G_TO_G_SIZE */ - 1345, /* GL_PIXEL_MAP_B_TO_B_SIZE */ - 1343, /* GL_PIXEL_MAP_A_TO_A_SIZE */ - 2197, /* GL_UNPACK_SWAP_BYTES */ - 2192, /* GL_UNPACK_LSB_FIRST */ - 2193, /* GL_UNPACK_ROW_LENGTH */ - 2196, /* GL_UNPACK_SKIP_ROWS */ - 2195, /* GL_UNPACK_SKIP_PIXELS */ - 2190, /* GL_UNPACK_ALIGNMENT */ - 1329, /* GL_PACK_SWAP_BYTES */ - 1324, /* GL_PACK_LSB_FIRST */ - 1325, /* GL_PACK_ROW_LENGTH */ - 1328, /* GL_PACK_SKIP_ROWS */ - 1327, /* GL_PACK_SKIP_PIXELS */ - 1321, /* GL_PACK_ALIGNMENT */ - 974, /* GL_MAP_COLOR */ - 979, /* GL_MAP_STENCIL */ - 766, /* GL_INDEX_SHIFT */ - 765, /* GL_INDEX_OFFSET */ - 1582, /* GL_RED_SCALE */ - 1578, /* GL_RED_BIAS */ - 2338, /* GL_ZOOM_X */ - 2339, /* GL_ZOOM_Y */ - 720, /* GL_GREEN_SCALE */ - 716, /* GL_GREEN_BIAS */ - 115, /* GL_BLUE_SCALE */ - 111, /* GL_BLUE_BIAS */ - 50, /* GL_ALPHA_SCALE */ - 47, /* GL_ALPHA_BIAS */ - 430, /* GL_DEPTH_SCALE */ - 406, /* GL_DEPTH_BIAS */ - 1066, /* GL_MAX_EVAL_ORDER */ - 1083, /* GL_MAX_LIGHTS */ - 1045, /* GL_MAX_CLIP_DISTANCES */ - 1138, /* GL_MAX_TEXTURE_SIZE */ - 1090, /* GL_MAX_PIXEL_MAP_TABLE */ - 1041, /* GL_MAX_ATTRIB_STACK_DEPTH */ - 1086, /* GL_MAX_MODELVIEW_STACK_DEPTH */ - 1087, /* GL_MAX_NAME_STACK_DEPTH */ - 1117, /* GL_MAX_PROJECTION_STACK_DEPTH */ - 1139, /* GL_MAX_TEXTURE_STACK_DEPTH */ - 1165, /* GL_MAX_VIEWPORT_DIMS */ - 1042, /* GL_MAX_CLIENT_ATTRIB_STACK_DEPTH */ - 1905, /* GL_SUBPIXEL_BITS */ - 761, /* GL_INDEX_BITS */ - 1579, /* GL_RED_BITS */ - 717, /* GL_GREEN_BITS */ - 112, /* GL_BLUE_BITS */ - 48, /* GL_ALPHA_BITS */ - 407, /* GL_DEPTH_BITS */ - 1869, /* GL_STENCIL_BITS */ - 14, /* GL_ACCUM_RED_BITS */ - 13, /* GL_ACCUM_GREEN_BITS */ - 10, /* GL_ACCUM_BLUE_BITS */ - 9, /* GL_ACCUM_ALPHA_BITS */ - 1236, /* GL_NAME_STACK_DEPTH */ - 70, /* GL_AUTO_NORMAL */ - 920, /* GL_MAP1_COLOR_4 */ - 923, /* GL_MAP1_INDEX */ - 924, /* GL_MAP1_NORMAL */ - 925, /* GL_MAP1_TEXTURE_COORD_1 */ - 926, /* GL_MAP1_TEXTURE_COORD_2 */ - 927, /* GL_MAP1_TEXTURE_COORD_3 */ - 928, /* GL_MAP1_TEXTURE_COORD_4 */ - 929, /* GL_MAP1_VERTEX_3 */ - 930, /* GL_MAP1_VERTEX_4 */ - 947, /* GL_MAP2_COLOR_4 */ - 950, /* GL_MAP2_INDEX */ - 951, /* GL_MAP2_NORMAL */ - 952, /* GL_MAP2_TEXTURE_COORD_1 */ - 953, /* GL_MAP2_TEXTURE_COORD_2 */ - 954, /* GL_MAP2_TEXTURE_COORD_3 */ - 955, /* GL_MAP2_TEXTURE_COORD_4 */ - 956, /* GL_MAP2_VERTEX_3 */ - 957, /* GL_MAP2_VERTEX_4 */ - 921, /* GL_MAP1_GRID_DOMAIN */ - 922, /* GL_MAP1_GRID_SEGMENTS */ - 948, /* GL_MAP2_GRID_DOMAIN */ - 949, /* GL_MAP2_GRID_SEGMENTS */ - 1988, /* GL_TEXTURE_1D */ - 1991, /* GL_TEXTURE_2D */ - 559, /* GL_FEEDBACK_BUFFER_POINTER */ - 560, /* GL_FEEDBACK_BUFFER_SIZE */ - 561, /* GL_FEEDBACK_BUFFER_TYPE */ - 1775, /* GL_SELECTION_BUFFER_POINTER */ - 1776, /* GL_SELECTION_BUFFER_SIZE */ - 2139, /* GL_TEXTURE_WIDTH */ - 2099, /* GL_TEXTURE_HEIGHT */ - 2042, /* GL_TEXTURE_COMPONENTS */ - 2020, /* GL_TEXTURE_BORDER_COLOR */ - 2019, /* GL_TEXTURE_BORDER */ - 445, /* GL_DONT_CARE */ - 557, /* GL_FASTEST */ - 1244, /* GL_NICEST */ - 56, /* GL_AMBIENT */ - 442, /* GL_DIFFUSE */ - 1828, /* GL_SPECULAR */ - 1421, /* GL_POSITION */ - 1831, /* GL_SPOT_DIRECTION */ - 1832, /* GL_SPOT_EXPONENT */ - 1830, /* GL_SPOT_CUTOFF */ - 320, /* GL_CONSTANT_ATTENUATION */ - 848, /* GL_LINEAR_ATTENUATION */ - 1538, /* GL_QUADRATIC_ATTENUATION */ - 287, /* GL_COMPILE */ - 288, /* GL_COMPILE_AND_EXECUTE */ - 149, /* GL_BYTE */ - 2199, /* GL_UNSIGNED_BYTE */ - 1793, /* GL_SHORT */ - 2238, /* GL_UNSIGNED_SHORT */ - 770, /* GL_INT */ - 2202, /* GL_UNSIGNED_INT */ - 570, /* GL_FLOAT */ - 1, /* GL_2_BYTES */ - 5, /* GL_3_BYTES */ - 7, /* GL_4_BYTES */ - 452, /* GL_DOUBLE */ - 722, /* GL_HALF_FLOAT */ - 565, /* GL_FIXED */ - 165, /* GL_CLEAR */ - 58, /* GL_AND */ - 60, /* GL_AND_REVERSE */ - 351, /* GL_COPY */ - 59, /* GL_AND_INVERTED */ - 1247, /* GL_NOOP */ - 2334, /* GL_XOR */ - 1316, /* GL_OR */ - 1248, /* GL_NOR */ - 546, /* GL_EQUIV */ - 824, /* GL_INVERT */ - 1319, /* GL_OR_REVERSE */ - 352, /* GL_COPY_INVERTED */ - 1318, /* GL_OR_INVERTED */ - 1237, /* GL_NAND */ - 1782, /* GL_SET */ - 543, /* GL_EMISSION */ - 1792, /* GL_SHININESS */ - 57, /* GL_AMBIENT_AND_DIFFUSE */ - 232, /* GL_COLOR_INDEXES */ - 1186, /* GL_MODELVIEW */ - 1510, /* GL_PROJECTION */ - 1923, /* GL_TEXTURE */ - 188, /* GL_COLOR */ - 399, /* GL_DEPTH */ - 1854, /* GL_STENCIL */ - 231, /* GL_COLOR_INDEX */ - 1875, /* GL_STENCIL_INDEX */ - 415, /* GL_DEPTH_COMPONENT */ - 1575, /* GL_RED */ - 715, /* GL_GREEN */ - 110, /* GL_BLUE */ - 32, /* GL_ALPHA */ - 1633, /* GL_RGB */ - 1674, /* GL_RGBA */ - 883, /* GL_LUMINANCE */ - 910, /* GL_LUMINANCE_ALPHA */ - 86, /* GL_BITMAP */ - 1371, /* GL_POINT */ - 846, /* GL_LINE */ - 562, /* GL_FILL */ - 1589, /* GL_RENDER */ - 558, /* GL_FEEDBACK */ - 1774, /* GL_SELECT */ - 569, /* GL_FLAT */ - 1803, /* GL_SMOOTH */ - 825, /* GL_KEEP */ - 1622, /* GL_REPLACE */ - 751, /* GL_INCR */ - 395, /* GL_DECR */ - 2255, /* GL_VENDOR */ - 1619, /* GL_RENDERER */ - 2256, /* GL_VERSION */ - 551, /* GL_EXTENSIONS */ - 1722, /* GL_S */ - 1914, /* GL_T */ - 1558, /* GL_R */ - 1537, /* GL_Q */ - 1223, /* GL_MODULATE */ - 394, /* GL_DECAL */ - 2085, /* GL_TEXTURE_ENV_MODE */ - 2084, /* GL_TEXTURE_ENV_COLOR */ - 2083, /* GL_TEXTURE_ENV */ - 552, /* GL_EYE_LINEAR */ - 1277, /* GL_OBJECT_LINEAR */ - 1829, /* GL_SPHERE_MAP */ - 2089, /* GL_TEXTURE_GEN_MODE */ - 1279, /* GL_OBJECT_PLANE */ - 553, /* GL_EYE_PLANE */ - 1238, /* GL_NEAREST */ - 847, /* GL_LINEAR */ - 1242, /* GL_NEAREST_MIPMAP_NEAREST */ - 852, /* GL_LINEAR_MIPMAP_NEAREST */ - 1241, /* GL_NEAREST_MIPMAP_LINEAR */ - 851, /* GL_LINEAR_MIPMAP_LINEAR */ - 2112, /* GL_TEXTURE_MAG_FILTER */ - 2121, /* GL_TEXTURE_MIN_FILTER */ - 2142, /* GL_TEXTURE_WRAP_S */ - 2143, /* GL_TEXTURE_WRAP_T */ - 155, /* GL_CLAMP */ - 1621, /* GL_REPEAT */ - 1415, /* GL_POLYGON_OFFSET_UNITS */ - 1414, /* GL_POLYGON_OFFSET_POINT */ - 1413, /* GL_POLYGON_OFFSET_LINE */ - 1561, /* GL_R3_G3_B2 */ - 2252, /* GL_V2F */ - 2253, /* GL_V3F */ - 152, /* GL_C4UB_V2F */ - 153, /* GL_C4UB_V3F */ - 150, /* GL_C3F_V3F */ - 1235, /* GL_N3F_V3F */ - 151, /* GL_C4F_N3F_V3F */ - 1919, /* GL_T2F_V3F */ - 1921, /* GL_T4F_V4F */ - 1917, /* GL_T2F_C4UB_V3F */ - 1915, /* GL_T2F_C3F_V3F */ - 1918, /* GL_T2F_N3F_V3F */ - 1916, /* GL_T2F_C4F_N3F_V3F */ - 1920, /* GL_T4F_C4F_N3F_V4F */ - 172, /* GL_CLIP_DISTANCE0 */ - 173, /* GL_CLIP_DISTANCE1 */ - 174, /* GL_CLIP_DISTANCE2 */ - 175, /* GL_CLIP_DISTANCE3 */ - 176, /* GL_CLIP_DISTANCE4 */ - 177, /* GL_CLIP_DISTANCE5 */ - 178, /* GL_CLIP_DISTANCE6 */ - 179, /* GL_CLIP_DISTANCE7 */ - 831, /* GL_LIGHT0 */ - 832, /* GL_LIGHT1 */ - 833, /* GL_LIGHT2 */ - 834, /* GL_LIGHT3 */ - 835, /* GL_LIGHT4 */ - 836, /* GL_LIGHT5 */ - 837, /* GL_LIGHT6 */ - 838, /* GL_LIGHT7 */ - 726, /* GL_HINT_BIT */ - 322, /* GL_CONSTANT_COLOR */ - 1290, /* GL_ONE_MINUS_CONSTANT_COLOR */ - 317, /* GL_CONSTANT_ALPHA */ - 1288, /* GL_ONE_MINUS_CONSTANT_ALPHA */ - 89, /* GL_BLEND_COLOR */ - 691, /* GL_FUNC_ADD */ - 1168, /* GL_MIN */ - 1036, /* GL_MAX */ - 96, /* GL_BLEND_EQUATION */ - 697, /* GL_FUNC_SUBTRACT */ - 694, /* GL_FUNC_REVERSE_SUBTRACT */ - 331, /* GL_CONVOLUTION_1D */ - 332, /* GL_CONVOLUTION_2D */ - 1777, /* GL_SEPARABLE_2D */ - 335, /* GL_CONVOLUTION_BORDER_MODE */ - 339, /* GL_CONVOLUTION_FILTER_SCALE */ - 337, /* GL_CONVOLUTION_FILTER_BIAS */ - 1576, /* GL_REDUCE */ - 341, /* GL_CONVOLUTION_FORMAT */ - 345, /* GL_CONVOLUTION_WIDTH */ - 343, /* GL_CONVOLUTION_HEIGHT */ - 1055, /* GL_MAX_CONVOLUTION_WIDTH */ - 1053, /* GL_MAX_CONVOLUTION_HEIGHT */ - 1454, /* GL_POST_CONVOLUTION_RED_SCALE */ - 1450, /* GL_POST_CONVOLUTION_GREEN_SCALE */ - 1445, /* GL_POST_CONVOLUTION_BLUE_SCALE */ - 1441, /* GL_POST_CONVOLUTION_ALPHA_SCALE */ - 1452, /* GL_POST_CONVOLUTION_RED_BIAS */ - 1448, /* GL_POST_CONVOLUTION_GREEN_BIAS */ - 1443, /* GL_POST_CONVOLUTION_BLUE_BIAS */ - 1439, /* GL_POST_CONVOLUTION_ALPHA_BIAS */ - 727, /* GL_HISTOGRAM */ - 1517, /* GL_PROXY_HISTOGRAM */ - 743, /* GL_HISTOGRAM_WIDTH */ - 733, /* GL_HISTOGRAM_FORMAT */ - 739, /* GL_HISTOGRAM_RED_SIZE */ - 735, /* GL_HISTOGRAM_GREEN_SIZE */ - 730, /* GL_HISTOGRAM_BLUE_SIZE */ - 728, /* GL_HISTOGRAM_ALPHA_SIZE */ - 737, /* GL_HISTOGRAM_LUMINANCE_SIZE */ - 741, /* GL_HISTOGRAM_SINK */ - 1169, /* GL_MINMAX */ - 1171, /* GL_MINMAX_FORMAT */ - 1173, /* GL_MINMAX_SINK */ - 1922, /* GL_TABLE_TOO_LARGE_EXT */ - 2201, /* GL_UNSIGNED_BYTE_3_3_2 */ - 2241, /* GL_UNSIGNED_SHORT_4_4_4_4 */ - 2244, /* GL_UNSIGNED_SHORT_5_5_5_1 */ - 2213, /* GL_UNSIGNED_INT_8_8_8_8 */ - 2204, /* GL_UNSIGNED_INT_10_10_10_2 */ - 1412, /* GL_POLYGON_OFFSET_FILL */ - 1411, /* GL_POLYGON_OFFSET_FACTOR */ - 1410, /* GL_POLYGON_OFFSET_BIAS */ - 1626, /* GL_RESCALE_NORMAL */ - 41, /* GL_ALPHA4 */ - 43, /* GL_ALPHA8 */ - 33, /* GL_ALPHA12 */ - 35, /* GL_ALPHA16 */ - 898, /* GL_LUMINANCE4 */ - 904, /* GL_LUMINANCE8 */ - 884, /* GL_LUMINANCE12 */ - 890, /* GL_LUMINANCE16 */ - 899, /* GL_LUMINANCE4_ALPHA4 */ - 902, /* GL_LUMINANCE6_ALPHA2 */ - 907, /* GL_LUMINANCE8_ALPHA8 */ - 887, /* GL_LUMINANCE12_ALPHA4 */ - 885, /* GL_LUMINANCE12_ALPHA12 */ - 893, /* GL_LUMINANCE16_ALPHA16 */ - 771, /* GL_INTENSITY */ - 780, /* GL_INTENSITY4 */ - 782, /* GL_INTENSITY8 */ - 772, /* GL_INTENSITY12 */ - 774, /* GL_INTENSITY16 */ - 1649, /* GL_RGB2_EXT */ - 1655, /* GL_RGB4 */ - 1658, /* GL_RGB5 */ - 1665, /* GL_RGB8 */ - 1634, /* GL_RGB10 */ - 1639, /* GL_RGB12 */ - 1641, /* GL_RGB16 */ - 1685, /* GL_RGBA2 */ - 1692, /* GL_RGBA4 */ - 1661, /* GL_RGB5_A1 */ - 1697, /* GL_RGBA8 */ - 1635, /* GL_RGB10_A2 */ - 1675, /* GL_RGBA12 */ - 1677, /* GL_RGBA16 */ - 2129, /* GL_TEXTURE_RED_SIZE */ - 2097, /* GL_TEXTURE_GREEN_SIZE */ - 2017, /* GL_TEXTURE_BLUE_SIZE */ - 1996, /* GL_TEXTURE_ALPHA_SIZE */ - 2110, /* GL_TEXTURE_LUMINANCE_SIZE */ - 2101, /* GL_TEXTURE_INTENSITY_SIZE */ - 1623, /* GL_REPLACE_EXT */ - 1521, /* GL_PROXY_TEXTURE_1D */ - 1525, /* GL_PROXY_TEXTURE_2D */ - 2137, /* GL_TEXTURE_TOO_LARGE_EXT */ - 2123, /* GL_TEXTURE_PRIORITY */ - 2131, /* GL_TEXTURE_RESIDENT */ - 1999, /* GL_TEXTURE_BINDING_1D */ - 2002, /* GL_TEXTURE_BINDING_2D */ - 2005, /* GL_TEXTURE_BINDING_3D */ - 1326, /* GL_PACK_SKIP_IMAGES */ - 1322, /* GL_PACK_IMAGE_HEIGHT */ - 2194, /* GL_UNPACK_SKIP_IMAGES */ - 2191, /* GL_UNPACK_IMAGE_HEIGHT */ - 1994, /* GL_TEXTURE_3D */ - 1529, /* GL_PROXY_TEXTURE_3D */ - 2080, /* GL_TEXTURE_DEPTH */ - 2140, /* GL_TEXTURE_WRAP_R */ - 1037, /* GL_MAX_3D_TEXTURE_SIZE */ - 2257, /* GL_VERTEX_ARRAY */ - 1250, /* GL_NORMAL_ARRAY */ - 189, /* GL_COLOR_ARRAY */ - 755, /* GL_INDEX_ARRAY */ - 2050, /* GL_TEXTURE_COORD_ARRAY */ - 535, /* GL_EDGE_FLAG_ARRAY */ - 2263, /* GL_VERTEX_ARRAY_SIZE */ - 2265, /* GL_VERTEX_ARRAY_TYPE */ - 2264, /* GL_VERTEX_ARRAY_STRIDE */ - 1255, /* GL_NORMAL_ARRAY_TYPE */ - 1254, /* GL_NORMAL_ARRAY_STRIDE */ - 193, /* GL_COLOR_ARRAY_SIZE */ - 195, /* GL_COLOR_ARRAY_TYPE */ - 194, /* GL_COLOR_ARRAY_STRIDE */ - 760, /* GL_INDEX_ARRAY_TYPE */ - 759, /* GL_INDEX_ARRAY_STRIDE */ - 2054, /* GL_TEXTURE_COORD_ARRAY_SIZE */ - 2056, /* GL_TEXTURE_COORD_ARRAY_TYPE */ - 2055, /* GL_TEXTURE_COORD_ARRAY_STRIDE */ - 539, /* GL_EDGE_FLAG_ARRAY_STRIDE */ - 2262, /* GL_VERTEX_ARRAY_POINTER */ - 1253, /* GL_NORMAL_ARRAY_POINTER */ - 192, /* GL_COLOR_ARRAY_POINTER */ - 758, /* GL_INDEX_ARRAY_POINTER */ - 2053, /* GL_TEXTURE_COORD_ARRAY_POINTER */ - 538, /* GL_EDGE_FLAG_ARRAY_POINTER */ - 1228, /* GL_MULTISAMPLE */ - 1751, /* GL_SAMPLE_ALPHA_TO_COVERAGE */ - 1753, /* GL_SAMPLE_ALPHA_TO_ONE */ - 1758, /* GL_SAMPLE_COVERAGE */ - 1755, /* GL_SAMPLE_BUFFERS */ - 1746, /* GL_SAMPLES */ - 1762, /* GL_SAMPLE_COVERAGE_VALUE */ - 1760, /* GL_SAMPLE_COVERAGE_INVERT */ - 237, /* GL_COLOR_MATRIX */ - 239, /* GL_COLOR_MATRIX_STACK_DEPTH */ - 1049, /* GL_MAX_COLOR_MATRIX_STACK_DEPTH */ - 1437, /* GL_POST_COLOR_MATRIX_RED_SCALE */ - 1433, /* GL_POST_COLOR_MATRIX_GREEN_SCALE */ - 1428, /* GL_POST_COLOR_MATRIX_BLUE_SCALE */ - 1424, /* GL_POST_COLOR_MATRIX_ALPHA_SCALE */ - 1435, /* GL_POST_COLOR_MATRIX_RED_BIAS */ - 1431, /* GL_POST_COLOR_MATRIX_GREEN_BIAS */ - 1426, /* GL_POST_COLOR_MATRIX_BLUE_BIAS */ - 1422, /* GL_POST_COLOR_MATRIX_ALPHA_BIAS */ - 2033, /* GL_TEXTURE_COLOR_TABLE_SGI */ - 1530, /* GL_PROXY_TEXTURE_COLOR_TABLE_SGI */ - 2035, /* GL_TEXTURE_COMPARE_FAIL_VALUE_ARB */ - 94, /* GL_BLEND_DST_RGB */ - 108, /* GL_BLEND_SRC_RGB */ - 92, /* GL_BLEND_DST_ALPHA */ - 106, /* GL_BLEND_SRC_ALPHA */ - 243, /* GL_COLOR_TABLE */ - 1447, /* GL_POST_CONVOLUTION_COLOR_TABLE */ - 1430, /* GL_POST_COLOR_MATRIX_COLOR_TABLE */ - 1516, /* GL_PROXY_COLOR_TABLE */ - 1520, /* GL_PROXY_POST_CONVOLUTION_COLOR_TABLE */ - 1519, /* GL_PROXY_POST_COLOR_MATRIX_COLOR_TABLE */ - 267, /* GL_COLOR_TABLE_SCALE */ - 247, /* GL_COLOR_TABLE_BIAS */ - 252, /* GL_COLOR_TABLE_FORMAT */ - 269, /* GL_COLOR_TABLE_WIDTH */ - 264, /* GL_COLOR_TABLE_RED_SIZE */ - 255, /* GL_COLOR_TABLE_GREEN_SIZE */ - 249, /* GL_COLOR_TABLE_BLUE_SIZE */ - 244, /* GL_COLOR_TABLE_ALPHA_SIZE */ - 261, /* GL_COLOR_TABLE_LUMINANCE_SIZE */ - 258, /* GL_COLOR_TABLE_INTENSITY_SIZE */ - 79, /* GL_BGR */ - 80, /* GL_BGRA */ - 1065, /* GL_MAX_ELEMENTS_VERTICES */ - 1064, /* GL_MAX_ELEMENTS_INDICES */ - 2100, /* GL_TEXTURE_INDEX_SIZE_EXT */ - 186, /* GL_CLIP_VOLUME_CLIPPING_HINT_EXT */ - 1393, /* GL_POINT_SIZE_MIN */ - 1389, /* GL_POINT_SIZE_MAX */ - 1378, /* GL_POINT_FADE_THRESHOLD_SIZE */ - 1374, /* GL_POINT_DISTANCE_ATTENUATION */ - 159, /* GL_CLAMP_TO_BORDER */ - 162, /* GL_CLAMP_TO_EDGE */ - 2122, /* GL_TEXTURE_MIN_LOD */ - 2120, /* GL_TEXTURE_MAX_LOD */ - 1998, /* GL_TEXTURE_BASE_LEVEL */ - 2119, /* GL_TEXTURE_MAX_LEVEL */ - 746, /* GL_IGNORE_BORDER_HP */ - 321, /* GL_CONSTANT_BORDER_HP */ - 1624, /* GL_REPLICATE_BORDER_HP */ - 333, /* GL_CONVOLUTION_BORDER_COLOR */ - 1285, /* GL_OCCLUSION_TEST_HP */ - 1286, /* GL_OCCLUSION_TEST_RESULT_HP */ - 849, /* GL_LINEAR_CLIPMAP_LINEAR_SGIX */ - 2027, /* GL_TEXTURE_CLIPMAP_CENTER_SGIX */ - 2029, /* GL_TEXTURE_CLIPMAP_FRAME_SGIX */ - 2031, /* GL_TEXTURE_CLIPMAP_OFFSET_SGIX */ - 2032, /* GL_TEXTURE_CLIPMAP_VIRTUAL_DEPTH_SGIX */ - 2030, /* GL_TEXTURE_CLIPMAP_LOD_OFFSET_SGIX */ - 2028, /* GL_TEXTURE_CLIPMAP_DEPTH_SGIX */ - 1043, /* GL_MAX_CLIPMAP_DEPTH_SGIX */ - 1044, /* GL_MAX_CLIPMAP_VIRTUAL_DEPTH_SGIX */ - 1457, /* GL_POST_TEXTURE_FILTER_BIAS_SGIX */ - 1459, /* GL_POST_TEXTURE_FILTER_SCALE_SGIX */ - 1456, /* GL_POST_TEXTURE_FILTER_BIAS_RANGE_SGIX */ - 1458, /* GL_POST_TEXTURE_FILTER_SCALE_RANGE_SGIX */ - 2108, /* GL_TEXTURE_LOD_BIAS_S_SGIX */ - 2109, /* GL_TEXTURE_LOD_BIAS_T_SGIX */ - 2107, /* GL_TEXTURE_LOD_BIAS_R_SGIX */ - 700, /* GL_GENERATE_MIPMAP */ - 701, /* GL_GENERATE_MIPMAP_HINT */ - 613, /* GL_FOG_OFFSET_SGIX */ - 614, /* GL_FOG_OFFSET_VALUE_SGIX */ - 2041, /* GL_TEXTURE_COMPARE_SGIX */ - 2040, /* GL_TEXTURE_COMPARE_OPERATOR_SGIX */ - 2104, /* GL_TEXTURE_LEQUAL_R_SGIX */ - 2096, /* GL_TEXTURE_GEQUAL_R_SGIX */ - 416, /* GL_DEPTH_COMPONENT16 */ - 420, /* GL_DEPTH_COMPONENT24 */ - 424, /* GL_DEPTH_COMPONENT32 */ - 358, /* GL_CULL_VERTEX_EXT */ - 360, /* GL_CULL_VERTEX_OBJECT_POSITION_EXT */ - 359, /* GL_CULL_VERTEX_EYE_POSITION_EXT */ - 2330, /* GL_WRAP_BORDER_SUN */ - 2034, /* GL_TEXTURE_COLOR_WRITEMASK_SGIS */ - 842, /* GL_LIGHT_MODEL_COLOR_CONTROL */ - 1796, /* GL_SINGLE_COLOR */ - 1780, /* GL_SEPARATE_SPECULAR_COLOR */ - 1791, /* GL_SHARED_TEXTURE_PALETTE_EXT */ - 625, /* GL_FRAMEBUFFER_ATTACHMENT_COLOR_ENCODING */ - 626, /* GL_FRAMEBUFFER_ATTACHMENT_COMPONENT_TYPE */ - 637, /* GL_FRAMEBUFFER_ATTACHMENT_RED_SIZE */ - 628, /* GL_FRAMEBUFFER_ATTACHMENT_GREEN_SIZE */ - 624, /* GL_FRAMEBUFFER_ATTACHMENT_BLUE_SIZE */ - 623, /* GL_FRAMEBUFFER_ATTACHMENT_ALPHA_SIZE */ - 627, /* GL_FRAMEBUFFER_ATTACHMENT_DEPTH_SIZE */ - 638, /* GL_FRAMEBUFFER_ATTACHMENT_STENCIL_SIZE */ - 655, /* GL_FRAMEBUFFER_DEFAULT */ - 682, /* GL_FRAMEBUFFER_UNDEFINED */ - 432, /* GL_DEPTH_STENCIL_ATTACHMENT */ - 919, /* GL_MAJOR_VERSION */ - 1175, /* GL_MINOR_VERSION */ - 1265, /* GL_NUM_EXTENSIONS */ - 327, /* GL_CONTEXT_FLAGS */ - 754, /* GL_INDEX */ - 410, /* GL_DEPTH_BUFFER */ - 1870, /* GL_STENCIL_BUFFER */ - 298, /* GL_COMPRESSED_RED */ - 299, /* GL_COMPRESSED_RG */ - 879, /* GL_LOSE_CONTEXT_ON_RESET_ARB */ - 721, /* GL_GUILTY_CONTEXT_RESET_ARB */ - 769, /* GL_INNOCENT_CONTEXT_RESET_ARB */ - 2189, /* GL_UNKNOWN_CONTEXT_RESET_ARB */ - 1628, /* GL_RESET_NOTIFICATION_STRATEGY_ARB */ - 1479, /* GL_PROGRAM_BINARY_RETRIEVABLE_HINT */ - 1262, /* GL_NO_RESET_NOTIFICATION_ARB */ - 2200, /* GL_UNSIGNED_BYTE_2_3_3_REV */ - 2245, /* GL_UNSIGNED_SHORT_5_6_5 */ - 2246, /* GL_UNSIGNED_SHORT_5_6_5_REV */ - 2242, /* GL_UNSIGNED_SHORT_4_4_4_4_REV */ - 2239, /* GL_UNSIGNED_SHORT_1_5_5_5_REV */ - 2214, /* GL_UNSIGNED_INT_8_8_8_8_REV */ - 2210, /* GL_UNSIGNED_INT_2_10_10_10_REV */ - 2117, /* GL_TEXTURE_MAX_CLAMP_S_SGIX */ - 2118, /* GL_TEXTURE_MAX_CLAMP_T_SGIX */ - 2116, /* GL_TEXTURE_MAX_CLAMP_R_SGIX */ - 1178, /* GL_MIRRORED_REPEAT */ - 1715, /* GL_RGB_S3TC */ - 1657, /* GL_RGB4_S3TC */ - 1711, /* GL_RGBA_S3TC */ - 1696, /* GL_RGBA4_S3TC */ - 1705, /* GL_RGBA_DXT5_S3TC */ - 1693, /* GL_RGBA4_DXT5_S3TC */ - 309, /* GL_COMPRESSED_RGB_S3TC_DXT1_EXT */ - 304, /* GL_COMPRESSED_RGBA_S3TC_DXT1_EXT */ - 305, /* GL_COMPRESSED_RGBA_S3TC_DXT3_EXT */ - 306, /* GL_COMPRESSED_RGBA_S3TC_DXT5_EXT */ - 1240, /* GL_NEAREST_CLIPMAP_NEAREST_SGIX */ - 1239, /* GL_NEAREST_CLIPMAP_LINEAR_SGIX */ - 850, /* GL_LINEAR_CLIPMAP_NEAREST_SGIX */ - 600, /* GL_FOG_COORDINATE_SOURCE */ - 592, /* GL_FOG_COORD */ - 616, /* GL_FRAGMENT_DEPTH */ - 364, /* GL_CURRENT_FOG_COORD */ - 599, /* GL_FOG_COORDINATE_ARRAY_TYPE */ - 598, /* GL_FOG_COORDINATE_ARRAY_STRIDE */ - 597, /* GL_FOG_COORDINATE_ARRAY_POINTER */ - 594, /* GL_FOG_COORDINATE_ARRAY */ - 241, /* GL_COLOR_SUM */ - 385, /* GL_CURRENT_SECONDARY_COLOR */ - 1771, /* GL_SECONDARY_COLOR_ARRAY_SIZE */ - 1773, /* GL_SECONDARY_COLOR_ARRAY_TYPE */ - 1772, /* GL_SECONDARY_COLOR_ARRAY_STRIDE */ - 1770, /* GL_SECONDARY_COLOR_ARRAY_POINTER */ - 1767, /* GL_SECONDARY_COLOR_ARRAY */ - 383, /* GL_CURRENT_RASTER_SECONDARY_COLOR */ - 29, /* GL_ALIASED_POINT_SIZE_RANGE */ - 28, /* GL_ALIASED_LINE_WIDTH_RANGE */ - 1924, /* GL_TEXTURE0 */ - 1926, /* GL_TEXTURE1 */ - 1948, /* GL_TEXTURE2 */ - 1970, /* GL_TEXTURE3 */ - 1976, /* GL_TEXTURE4 */ - 1978, /* GL_TEXTURE5 */ - 1980, /* GL_TEXTURE6 */ - 1982, /* GL_TEXTURE7 */ - 1984, /* GL_TEXTURE8 */ - 1986, /* GL_TEXTURE9 */ - 1927, /* GL_TEXTURE10 */ - 1929, /* GL_TEXTURE11 */ - 1931, /* GL_TEXTURE12 */ - 1933, /* GL_TEXTURE13 */ - 1935, /* GL_TEXTURE14 */ - 1937, /* GL_TEXTURE15 */ - 1939, /* GL_TEXTURE16 */ - 1941, /* GL_TEXTURE17 */ - 1943, /* GL_TEXTURE18 */ - 1945, /* GL_TEXTURE19 */ - 1949, /* GL_TEXTURE20 */ - 1951, /* GL_TEXTURE21 */ - 1953, /* GL_TEXTURE22 */ - 1955, /* GL_TEXTURE23 */ - 1957, /* GL_TEXTURE24 */ - 1959, /* GL_TEXTURE25 */ - 1961, /* GL_TEXTURE26 */ - 1963, /* GL_TEXTURE27 */ - 1965, /* GL_TEXTURE28 */ - 1967, /* GL_TEXTURE29 */ - 1971, /* GL_TEXTURE30 */ - 1973, /* GL_TEXTURE31 */ - 19, /* GL_ACTIVE_TEXTURE */ - 166, /* GL_CLIENT_ACTIVE_TEXTURE */ - 1140, /* GL_MAX_TEXTURE_UNITS */ - 2172, /* GL_TRANSPOSE_MODELVIEW_MATRIX */ - 2175, /* GL_TRANSPOSE_PROJECTION_MATRIX */ - 2177, /* GL_TRANSPOSE_TEXTURE_MATRIX */ - 2169, /* GL_TRANSPOSE_COLOR_MATRIX */ - 1906, /* GL_SUBTRACT */ - 1121, /* GL_MAX_RENDERBUFFER_SIZE */ - 290, /* GL_COMPRESSED_ALPHA */ - 294, /* GL_COMPRESSED_LUMINANCE */ - 295, /* GL_COMPRESSED_LUMINANCE_ALPHA */ - 292, /* GL_COMPRESSED_INTENSITY */ - 300, /* GL_COMPRESSED_RGB */ - 301, /* GL_COMPRESSED_RGBA */ - 2048, /* GL_TEXTURE_COMPRESSION_HINT */ - 2126, /* GL_TEXTURE_RECTANGLE */ - 2013, /* GL_TEXTURE_BINDING_RECTANGLE */ - 1533, /* GL_PROXY_TEXTURE_RECTANGLE */ - 1118, /* GL_MAX_RECTANGLE_TEXTURE_SIZE */ - 431, /* GL_DEPTH_STENCIL */ - 2206, /* GL_UNSIGNED_INT_24_8 */ - 1135, /* GL_MAX_TEXTURE_LOD_BIAS */ - 2115, /* GL_TEXTURE_MAX_ANISOTROPY_EXT */ - 1137, /* GL_MAX_TEXTURE_MAX_ANISOTROPY_EXT */ - 2087, /* GL_TEXTURE_FILTER_CONTROL */ - 2105, /* GL_TEXTURE_LOD_BIAS */ - 274, /* GL_COMBINE4 */ - 1127, /* GL_MAX_SHININESS_NV */ - 1128, /* GL_MAX_SPOT_EXPONENT_NV */ - 752, /* GL_INCR_WRAP */ - 396, /* GL_DECR_WRAP */ - 1198, /* GL_MODELVIEW1_ARB */ - 1256, /* GL_NORMAL_MAP */ - 1584, /* GL_REFLECTION_MAP */ - 2058, /* GL_TEXTURE_CUBE_MAP */ - 2009, /* GL_TEXTURE_BINDING_CUBE_MAP */ - 2070, /* GL_TEXTURE_CUBE_MAP_POSITIVE_X */ - 2060, /* GL_TEXTURE_CUBE_MAP_NEGATIVE_X */ - 2073, /* GL_TEXTURE_CUBE_MAP_POSITIVE_Y */ - 2063, /* GL_TEXTURE_CUBE_MAP_NEGATIVE_Y */ - 2076, /* GL_TEXTURE_CUBE_MAP_POSITIVE_Z */ - 2066, /* GL_TEXTURE_CUBE_MAP_NEGATIVE_Z */ - 1531, /* GL_PROXY_TEXTURE_CUBE_MAP */ - 1057, /* GL_MAX_CUBE_MAP_TEXTURE_SIZE */ - 1234, /* GL_MULTISAMPLE_FILTER_HINT_NV */ - 1471, /* GL_PRIMITIVE_RESTART_NV */ - 1470, /* GL_PRIMITIVE_RESTART_INDEX_NV */ - 608, /* GL_FOG_DISTANCE_MODE_NV */ - 555, /* GL_EYE_RADIAL_NV */ - 554, /* GL_EYE_PLANE_ABSOLUTE_NV */ - 273, /* GL_COMBINE */ - 280, /* GL_COMBINE_RGB */ - 275, /* GL_COMBINE_ALPHA */ - 1716, /* GL_RGB_SCALE */ - 25, /* GL_ADD_SIGNED */ - 789, /* GL_INTERPOLATE */ - 316, /* GL_CONSTANT */ - 1463, /* GL_PRIMARY_COLOR */ - 1460, /* GL_PREVIOUS */ - 1811, /* GL_SOURCE0_RGB */ - 1817, /* GL_SOURCE1_RGB */ - 1823, /* GL_SOURCE2_RGB */ - 1827, /* GL_SOURCE3_RGB_NV */ - 1808, /* GL_SOURCE0_ALPHA */ - 1814, /* GL_SOURCE1_ALPHA */ - 1820, /* GL_SOURCE2_ALPHA */ - 1826, /* GL_SOURCE3_ALPHA_NV */ - 1299, /* GL_OPERAND0_RGB */ - 1305, /* GL_OPERAND1_RGB */ - 1311, /* GL_OPERAND2_RGB */ - 1315, /* GL_OPERAND3_RGB_NV */ - 1296, /* GL_OPERAND0_ALPHA */ - 1302, /* GL_OPERAND1_ALPHA */ - 1308, /* GL_OPERAND2_ALPHA */ - 1314, /* GL_OPERAND3_ALPHA_NV */ - 137, /* GL_BUFFER_OBJECT_APPLE */ - 2258, /* GL_VERTEX_ARRAY_BINDING */ - 2124, /* GL_TEXTURE_RANGE_LENGTH_APPLE */ - 2125, /* GL_TEXTURE_RANGE_POINTER_APPLE */ - 2335, /* GL_YCBCR_422_APPLE */ - 2247, /* GL_UNSIGNED_SHORT_8_8_APPLE */ - 2249, /* GL_UNSIGNED_SHORT_8_8_REV_APPLE */ - 2136, /* GL_TEXTURE_STORAGE_HINT_APPLE */ - 1897, /* GL_STORAGE_PRIVATE_APPLE */ - 1896, /* GL_STORAGE_CACHED_APPLE */ - 1898, /* GL_STORAGE_SHARED_APPLE */ - 1798, /* GL_SLICE_ACCUM_SUN */ - 1542, /* GL_QUAD_MESH_SUN */ - 2183, /* GL_TRIANGLE_MESH_SUN */ - 2300, /* GL_VERTEX_PROGRAM_ARB */ - 2311, /* GL_VERTEX_STATE_PROGRAM_NV */ - 2285, /* GL_VERTEX_ATTRIB_ARRAY_ENABLED */ - 2293, /* GL_VERTEX_ATTRIB_ARRAY_SIZE */ - 2295, /* GL_VERTEX_ATTRIB_ARRAY_STRIDE */ - 2297, /* GL_VERTEX_ATTRIB_ARRAY_TYPE */ - 387, /* GL_CURRENT_VERTEX_ATTRIB */ - 1487, /* GL_PROGRAM_LENGTH_ARB */ - 1503, /* GL_PROGRAM_STRING_ARB */ - 1221, /* GL_MODELVIEW_PROJECTION_NV */ - 745, /* GL_IDENTITY_NV */ - 822, /* GL_INVERSE_NV */ - 2174, /* GL_TRANSPOSE_NV */ - 823, /* GL_INVERSE_TRANSPOSE_NV */ - 1103, /* GL_MAX_PROGRAM_MATRIX_STACK_DEPTH_ARB */ - 1102, /* GL_MAX_PROGRAM_MATRICES_ARB */ - 983, /* GL_MATRIX0_NV */ - 995, /* GL_MATRIX1_NV */ - 1007, /* GL_MATRIX2_NV */ - 1011, /* GL_MATRIX3_NV */ - 1013, /* GL_MATRIX4_NV */ - 1015, /* GL_MATRIX5_NV */ - 1017, /* GL_MATRIX6_NV */ - 1019, /* GL_MATRIX7_NV */ - 370, /* GL_CURRENT_MATRIX_STACK_DEPTH_ARB */ - 367, /* GL_CURRENT_MATRIX_ARB */ - 1500, /* GL_PROGRAM_POINT_SIZE */ - 2306, /* GL_VERTEX_PROGRAM_TWO_SIDE */ - 1499, /* GL_PROGRAM_PARAMETER_NV */ - 2291, /* GL_VERTEX_ATTRIB_ARRAY_POINTER */ - 1505, /* GL_PROGRAM_TARGET_NV */ - 1502, /* GL_PROGRAM_RESIDENT_NV */ - 2146, /* GL_TRACK_MATRIX_NV */ - 2147, /* GL_TRACK_MATRIX_TRANSFORM_NV */ - 2301, /* GL_VERTEX_PROGRAM_BINDING_NV */ - 1481, /* GL_PROGRAM_ERROR_POSITION_ARB */ - 412, /* GL_DEPTH_CLAMP */ - 2266, /* GL_VERTEX_ATTRIB_ARRAY0_NV */ - 2273, /* GL_VERTEX_ATTRIB_ARRAY1_NV */ - 2274, /* GL_VERTEX_ATTRIB_ARRAY2_NV */ - 2275, /* GL_VERTEX_ATTRIB_ARRAY3_NV */ - 2276, /* GL_VERTEX_ATTRIB_ARRAY4_NV */ - 2277, /* GL_VERTEX_ATTRIB_ARRAY5_NV */ - 2278, /* GL_VERTEX_ATTRIB_ARRAY6_NV */ - 2279, /* GL_VERTEX_ATTRIB_ARRAY7_NV */ - 2280, /* GL_VERTEX_ATTRIB_ARRAY8_NV */ - 2281, /* GL_VERTEX_ATTRIB_ARRAY9_NV */ - 2267, /* GL_VERTEX_ATTRIB_ARRAY10_NV */ - 2268, /* GL_VERTEX_ATTRIB_ARRAY11_NV */ - 2269, /* GL_VERTEX_ATTRIB_ARRAY12_NV */ - 2270, /* GL_VERTEX_ATTRIB_ARRAY13_NV */ - 2271, /* GL_VERTEX_ATTRIB_ARRAY14_NV */ - 2272, /* GL_VERTEX_ATTRIB_ARRAY15_NV */ - 931, /* GL_MAP1_VERTEX_ATTRIB0_4_NV */ - 938, /* GL_MAP1_VERTEX_ATTRIB1_4_NV */ - 939, /* GL_MAP1_VERTEX_ATTRIB2_4_NV */ - 940, /* GL_MAP1_VERTEX_ATTRIB3_4_NV */ - 941, /* GL_MAP1_VERTEX_ATTRIB4_4_NV */ - 942, /* GL_MAP1_VERTEX_ATTRIB5_4_NV */ - 943, /* GL_MAP1_VERTEX_ATTRIB6_4_NV */ - 944, /* GL_MAP1_VERTEX_ATTRIB7_4_NV */ - 945, /* GL_MAP1_VERTEX_ATTRIB8_4_NV */ - 946, /* GL_MAP1_VERTEX_ATTRIB9_4_NV */ - 932, /* GL_MAP1_VERTEX_ATTRIB10_4_NV */ - 933, /* GL_MAP1_VERTEX_ATTRIB11_4_NV */ - 934, /* GL_MAP1_VERTEX_ATTRIB12_4_NV */ - 935, /* GL_MAP1_VERTEX_ATTRIB13_4_NV */ - 936, /* GL_MAP1_VERTEX_ATTRIB14_4_NV */ - 937, /* GL_MAP1_VERTEX_ATTRIB15_4_NV */ - 958, /* GL_MAP2_VERTEX_ATTRIB0_4_NV */ - 965, /* GL_MAP2_VERTEX_ATTRIB1_4_NV */ - 966, /* GL_MAP2_VERTEX_ATTRIB2_4_NV */ - 967, /* GL_MAP2_VERTEX_ATTRIB3_4_NV */ - 968, /* GL_MAP2_VERTEX_ATTRIB4_4_NV */ - 969, /* GL_MAP2_VERTEX_ATTRIB5_4_NV */ - 970, /* GL_MAP2_VERTEX_ATTRIB6_4_NV */ - 1480, /* GL_PROGRAM_BINDING_ARB */ - 972, /* GL_MAP2_VERTEX_ATTRIB8_4_NV */ - 973, /* GL_MAP2_VERTEX_ATTRIB9_4_NV */ - 959, /* GL_MAP2_VERTEX_ATTRIB10_4_NV */ - 960, /* GL_MAP2_VERTEX_ATTRIB11_4_NV */ - 961, /* GL_MAP2_VERTEX_ATTRIB12_4_NV */ - 962, /* GL_MAP2_VERTEX_ATTRIB13_4_NV */ - 963, /* GL_MAP2_VERTEX_ATTRIB14_4_NV */ - 964, /* GL_MAP2_VERTEX_ATTRIB15_4_NV */ - 2046, /* GL_TEXTURE_COMPRESSED_IMAGE_SIZE */ - 2043, /* GL_TEXTURE_COMPRESSED */ - 1263, /* GL_NUM_COMPRESSED_TEXTURE_FORMATS */ - 314, /* GL_COMPRESSED_TEXTURE_FORMATS */ - 1162, /* GL_MAX_VERTEX_UNITS_ARB */ - 23, /* GL_ACTIVE_VERTEX_UNITS_ARB */ - 2329, /* GL_WEIGHT_SUM_UNITY_ARB */ - 2299, /* GL_VERTEX_BLEND_ARB */ - 389, /* GL_CURRENT_WEIGHT_ARB */ - 2327, /* GL_WEIGHT_ARRAY_TYPE_ARB */ - 2325, /* GL_WEIGHT_ARRAY_STRIDE_ARB */ - 2323, /* GL_WEIGHT_ARRAY_SIZE_ARB */ - 2321, /* GL_WEIGHT_ARRAY_POINTER_ARB */ - 2316, /* GL_WEIGHT_ARRAY_ARB */ - 446, /* GL_DOT3_RGB */ - 447, /* GL_DOT3_RGBA */ - 308, /* GL_COMPRESSED_RGB_FXT1_3DFX */ - 303, /* GL_COMPRESSED_RGBA_FXT1_3DFX */ - 1229, /* GL_MULTISAMPLE_3DFX */ - 1756, /* GL_SAMPLE_BUFFERS_3DFX */ - 1747, /* GL_SAMPLES_3DFX */ - 1209, /* GL_MODELVIEW2_ARB */ - 1212, /* GL_MODELVIEW3_ARB */ - 1213, /* GL_MODELVIEW4_ARB */ - 1214, /* GL_MODELVIEW5_ARB */ - 1215, /* GL_MODELVIEW6_ARB */ - 1216, /* GL_MODELVIEW7_ARB */ - 1217, /* GL_MODELVIEW8_ARB */ - 1218, /* GL_MODELVIEW9_ARB */ - 1188, /* GL_MODELVIEW10_ARB */ - 1189, /* GL_MODELVIEW11_ARB */ - 1190, /* GL_MODELVIEW12_ARB */ - 1191, /* GL_MODELVIEW13_ARB */ - 1192, /* GL_MODELVIEW14_ARB */ - 1193, /* GL_MODELVIEW15_ARB */ - 1194, /* GL_MODELVIEW16_ARB */ - 1195, /* GL_MODELVIEW17_ARB */ - 1196, /* GL_MODELVIEW18_ARB */ - 1197, /* GL_MODELVIEW19_ARB */ - 1199, /* GL_MODELVIEW20_ARB */ - 1200, /* GL_MODELVIEW21_ARB */ - 1201, /* GL_MODELVIEW22_ARB */ - 1202, /* GL_MODELVIEW23_ARB */ - 1203, /* GL_MODELVIEW24_ARB */ - 1204, /* GL_MODELVIEW25_ARB */ - 1205, /* GL_MODELVIEW26_ARB */ - 1206, /* GL_MODELVIEW27_ARB */ - 1207, /* GL_MODELVIEW28_ARB */ - 1208, /* GL_MODELVIEW29_ARB */ - 1210, /* GL_MODELVIEW30_ARB */ - 1211, /* GL_MODELVIEW31_ARB */ - 451, /* GL_DOT3_RGB_EXT */ - 1477, /* GL_PROGRAM_BINARY_LENGTH */ - 1182, /* GL_MIRROR_CLAMP_EXT */ - 1185, /* GL_MIRROR_CLAMP_TO_EDGE_EXT */ - 1224, /* GL_MODULATE_ADD_ATI */ - 1225, /* GL_MODULATE_SIGNED_ADD_ATI */ - 1226, /* GL_MODULATE_SUBTRACT_ATI */ - 2336, /* GL_YCBCR_MESA */ - 1323, /* GL_PACK_INVERT_MESA */ - 392, /* GL_DEBUG_OBJECT_MESA */ - 393, /* GL_DEBUG_PRINT_MESA */ - 391, /* GL_DEBUG_ASSERT_MESA */ - 139, /* GL_BUFFER_SIZE */ - 141, /* GL_BUFFER_USAGE */ - 145, /* GL_BUMP_ROT_MATRIX_ATI */ - 146, /* GL_BUMP_ROT_MATRIX_SIZE_ATI */ - 144, /* GL_BUMP_NUM_TEX_UNITS_ATI */ - 148, /* GL_BUMP_TEX_UNITS_ATI */ - 527, /* GL_DUDV_ATI */ - 526, /* GL_DU8DV8_ATI */ - 143, /* GL_BUMP_ENVMAP_ATI */ - 147, /* GL_BUMP_TARGET_ATI */ - 1266, /* GL_NUM_PROGRAM_BINARY_FORMATS */ - 1475, /* GL_PROGRAM_BINARY_FORMATS */ - 1860, /* GL_STENCIL_BACK_FUNC */ - 1858, /* GL_STENCIL_BACK_FAIL */ - 1862, /* GL_STENCIL_BACK_PASS_DEPTH_FAIL */ - 1864, /* GL_STENCIL_BACK_PASS_DEPTH_PASS */ - 617, /* GL_FRAGMENT_PROGRAM_ARB */ - 1473, /* GL_PROGRAM_ALU_INSTRUCTIONS_ARB */ - 1508, /* GL_PROGRAM_TEX_INSTRUCTIONS_ARB */ - 1507, /* GL_PROGRAM_TEX_INDIRECTIONS_ARB */ - 1490, /* GL_PROGRAM_NATIVE_ALU_INSTRUCTIONS_ARB */ - 1496, /* GL_PROGRAM_NATIVE_TEX_INSTRUCTIONS_ARB */ - 1495, /* GL_PROGRAM_NATIVE_TEX_INDIRECTIONS_ARB */ - 1092, /* GL_MAX_PROGRAM_ALU_INSTRUCTIONS_ARB */ - 1116, /* GL_MAX_PROGRAM_TEX_INSTRUCTIONS_ARB */ - 1115, /* GL_MAX_PROGRAM_TEX_INDIRECTIONS_ARB */ - 1105, /* GL_MAX_PROGRAM_NATIVE_ALU_INSTRUCTIONS_ARB */ - 1111, /* GL_MAX_PROGRAM_NATIVE_TEX_INSTRUCTIONS_ARB */ - 1110, /* GL_MAX_PROGRAM_NATIVE_TEX_INDIRECTIONS_ARB */ - 1687, /* GL_RGBA32F */ - 1650, /* GL_RGB32F */ - 1678, /* GL_RGBA16F */ - 1642, /* GL_RGB16F */ - 1706, /* GL_RGBA_FLOAT_MODE_ARB */ - 1060, /* GL_MAX_DRAW_BUFFERS */ - 455, /* GL_DRAW_BUFFER0 */ - 459, /* GL_DRAW_BUFFER1 */ - 487, /* GL_DRAW_BUFFER2 */ - 491, /* GL_DRAW_BUFFER3 */ - 495, /* GL_DRAW_BUFFER4 */ - 499, /* GL_DRAW_BUFFER5 */ - 503, /* GL_DRAW_BUFFER6 */ - 507, /* GL_DRAW_BUFFER7 */ - 511, /* GL_DRAW_BUFFER8 */ - 515, /* GL_DRAW_BUFFER9 */ - 460, /* GL_DRAW_BUFFER10 */ - 464, /* GL_DRAW_BUFFER11 */ - 468, /* GL_DRAW_BUFFER12 */ - 472, /* GL_DRAW_BUFFER13 */ - 476, /* GL_DRAW_BUFFER14 */ - 480, /* GL_DRAW_BUFFER15 */ - 97, /* GL_BLEND_EQUATION_ALPHA */ - 1034, /* GL_MATRIX_PALETTE_ARB */ - 1085, /* GL_MAX_MATRIX_PALETTE_STACK_DEPTH_ARB */ - 1088, /* GL_MAX_PALETTE_MATRICES_ARB */ - 373, /* GL_CURRENT_PALETTE_MATRIX_ARB */ - 1022, /* GL_MATRIX_INDEX_ARRAY_ARB */ - 368, /* GL_CURRENT_MATRIX_INDEX_ARB */ - 1027, /* GL_MATRIX_INDEX_ARRAY_SIZE_ARB */ - 1031, /* GL_MATRIX_INDEX_ARRAY_TYPE_ARB */ - 1029, /* GL_MATRIX_INDEX_ARRAY_STRIDE_ARB */ - 1025, /* GL_MATRIX_INDEX_ARRAY_POINTER_ARB */ - 2081, /* GL_TEXTURE_DEPTH_SIZE */ - 439, /* GL_DEPTH_TEXTURE_MODE */ - 2038, /* GL_TEXTURE_COMPARE_MODE */ - 2036, /* GL_TEXTURE_COMPARE_FUNC */ - 284, /* GL_COMPARE_REF_TO_TEXTURE */ - 1400, /* GL_POINT_SPRITE */ - 347, /* GL_COORD_REPLACE */ - 1405, /* GL_POINT_SPRITE_R_MODE_NV */ - 1548, /* GL_QUERY_COUNTER_BITS */ - 376, /* GL_CURRENT_QUERY */ - 1552, /* GL_QUERY_RESULT */ - 1554, /* GL_QUERY_RESULT_AVAILABLE */ - 1154, /* GL_MAX_VERTEX_ATTRIBS */ - 2289, /* GL_VERTEX_ATTRIB_ARRAY_NORMALIZED */ - 437, /* GL_DEPTH_STENCIL_TO_RGBA_NV */ - 436, /* GL_DEPTH_STENCIL_TO_BGRA_NV */ - 1131, /* GL_MAX_TEXTURE_COORDS */ - 1133, /* GL_MAX_TEXTURE_IMAGE_UNITS */ - 1483, /* GL_PROGRAM_ERROR_STRING_ARB */ - 1485, /* GL_PROGRAM_FORMAT_ASCII_ARB */ - 1484, /* GL_PROGRAM_FORMAT_ARB */ - 2138, /* GL_TEXTURE_UNSIGNED_REMAP_MODE_NV */ - 409, /* GL_DEPTH_BOUNDS_TEST_EXT */ - 408, /* GL_DEPTH_BOUNDS_EXT */ - 61, /* GL_ARRAY_BUFFER */ - 540, /* GL_ELEMENT_ARRAY_BUFFER */ - 62, /* GL_ARRAY_BUFFER_BINDING */ - 541, /* GL_ELEMENT_ARRAY_BUFFER_BINDING */ - 2260, /* GL_VERTEX_ARRAY_BUFFER_BINDING */ - 1251, /* GL_NORMAL_ARRAY_BUFFER_BINDING */ - 190, /* GL_COLOR_ARRAY_BUFFER_BINDING */ - 756, /* GL_INDEX_ARRAY_BUFFER_BINDING */ - 2051, /* GL_TEXTURE_COORD_ARRAY_BUFFER_BINDING */ - 536, /* GL_EDGE_FLAG_ARRAY_BUFFER_BINDING */ - 1768, /* GL_SECONDARY_COLOR_ARRAY_BUFFER_BINDING */ - 595, /* GL_FOG_COORDINATE_ARRAY_BUFFER_BINDING */ - 2317, /* GL_WEIGHT_ARRAY_BUFFER_BINDING */ - 2282, /* GL_VERTEX_ATTRIB_ARRAY_BUFFER_BINDING */ - 1486, /* GL_PROGRAM_INSTRUCTIONS_ARB */ - 1098, /* GL_MAX_PROGRAM_INSTRUCTIONS_ARB */ - 1492, /* GL_PROGRAM_NATIVE_INSTRUCTIONS_ARB */ - 1107, /* GL_MAX_PROGRAM_NATIVE_INSTRUCTIONS_ARB */ - 1506, /* GL_PROGRAM_TEMPORARIES_ARB */ - 1113, /* GL_MAX_PROGRAM_TEMPORARIES_ARB */ - 1494, /* GL_PROGRAM_NATIVE_TEMPORARIES_ARB */ - 1109, /* GL_MAX_PROGRAM_NATIVE_TEMPORARIES_ARB */ - 1498, /* GL_PROGRAM_PARAMETERS_ARB */ - 1112, /* GL_MAX_PROGRAM_PARAMETERS_ARB */ - 1493, /* GL_PROGRAM_NATIVE_PARAMETERS_ARB */ - 1108, /* GL_MAX_PROGRAM_NATIVE_PARAMETERS_ARB */ - 1474, /* GL_PROGRAM_ATTRIBS_ARB */ - 1093, /* GL_MAX_PROGRAM_ATTRIBS_ARB */ - 1491, /* GL_PROGRAM_NATIVE_ATTRIBS_ARB */ - 1106, /* GL_MAX_PROGRAM_NATIVE_ATTRIBS_ARB */ - 1472, /* GL_PROGRAM_ADDRESS_REGISTERS_ARB */ - 1091, /* GL_MAX_PROGRAM_ADDRESS_REGISTERS_ARB */ - 1489, /* GL_PROGRAM_NATIVE_ADDRESS_REGISTERS_ARB */ - 1104, /* GL_MAX_PROGRAM_NATIVE_ADDRESS_REGISTERS_ARB */ - 1099, /* GL_MAX_PROGRAM_LOCAL_PARAMETERS_ARB */ - 1095, /* GL_MAX_PROGRAM_ENV_PARAMETERS_ARB */ - 1509, /* GL_PROGRAM_UNDER_NATIVE_LIMITS_ARB */ - 2171, /* GL_TRANSPOSE_CURRENT_MATRIX_ARB */ - 1571, /* GL_READ_ONLY */ - 2331, /* GL_WRITE_ONLY */ - 1573, /* GL_READ_WRITE */ - 124, /* GL_BUFFER_ACCESS */ - 129, /* GL_BUFFER_MAPPED */ - 134, /* GL_BUFFER_MAP_POINTER */ - 2145, /* GL_TIME_ELAPSED_EXT */ - 982, /* GL_MATRIX0_ARB */ - 994, /* GL_MATRIX1_ARB */ - 1006, /* GL_MATRIX2_ARB */ - 1010, /* GL_MATRIX3_ARB */ - 1012, /* GL_MATRIX4_ARB */ - 1014, /* GL_MATRIX5_ARB */ - 1016, /* GL_MATRIX6_ARB */ - 1018, /* GL_MATRIX7_ARB */ - 1020, /* GL_MATRIX8_ARB */ - 1021, /* GL_MATRIX9_ARB */ - 984, /* GL_MATRIX10_ARB */ - 985, /* GL_MATRIX11_ARB */ - 986, /* GL_MATRIX12_ARB */ - 987, /* GL_MATRIX13_ARB */ - 988, /* GL_MATRIX14_ARB */ - 989, /* GL_MATRIX15_ARB */ - 990, /* GL_MATRIX16_ARB */ - 991, /* GL_MATRIX17_ARB */ - 992, /* GL_MATRIX18_ARB */ - 993, /* GL_MATRIX19_ARB */ - 996, /* GL_MATRIX20_ARB */ - 997, /* GL_MATRIX21_ARB */ - 998, /* GL_MATRIX22_ARB */ - 999, /* GL_MATRIX23_ARB */ - 1000, /* GL_MATRIX24_ARB */ - 1001, /* GL_MATRIX25_ARB */ - 1002, /* GL_MATRIX26_ARB */ - 1003, /* GL_MATRIX27_ARB */ - 1004, /* GL_MATRIX28_ARB */ - 1005, /* GL_MATRIX29_ARB */ - 1008, /* GL_MATRIX30_ARB */ - 1009, /* GL_MATRIX31_ARB */ - 1901, /* GL_STREAM_DRAW */ - 1903, /* GL_STREAM_READ */ - 1899, /* GL_STREAM_COPY */ - 1850, /* GL_STATIC_DRAW */ - 1852, /* GL_STATIC_READ */ - 1848, /* GL_STATIC_COPY */ - 530, /* GL_DYNAMIC_DRAW */ - 532, /* GL_DYNAMIC_READ */ - 528, /* GL_DYNAMIC_COPY */ - 1363, /* GL_PIXEL_PACK_BUFFER */ - 1367, /* GL_PIXEL_UNPACK_BUFFER */ - 1364, /* GL_PIXEL_PACK_BUFFER_BINDING */ - 1368, /* GL_PIXEL_UNPACK_BUFFER_BINDING */ - 400, /* GL_DEPTH24_STENCIL8 */ - 2134, /* GL_TEXTURE_STENCIL_SIZE */ - 2079, /* GL_TEXTURE_CUBE_MAP_SEAMLESS */ - 1094, /* GL_MAX_PROGRAM_CALL_DEPTH_NV */ - 1097, /* GL_MAX_PROGRAM_IF_DEPTH_NV */ - 1101, /* GL_MAX_PROGRAM_LOOP_DEPTH_NV */ - 1100, /* GL_MAX_PROGRAM_LOOP_COUNT_NV */ - 2287, /* GL_VERTEX_ATTRIB_ARRAY_INTEGER */ - 2284, /* GL_VERTEX_ATTRIB_ARRAY_DIVISOR_ARB */ - 1039, /* GL_MAX_ARRAY_TEXTURE_LAYERS */ - 1177, /* GL_MIN_PROGRAM_TEXEL_OFFSET */ - 1114, /* GL_MAX_PROGRAM_TEXEL_OFFSET */ - 1892, /* GL_STENCIL_TEST_TWO_SIDE_EXT */ - 18, /* GL_ACTIVE_STENCIL_FACE_EXT */ - 1183, /* GL_MIRROR_CLAMP_TO_BORDER_EXT */ - 1749, /* GL_SAMPLES_PASSED */ - 710, /* GL_GEOMETRY_VERTICES_OUT */ - 704, /* GL_GEOMETRY_INPUT_TYPE */ - 706, /* GL_GEOMETRY_OUTPUT_TYPE */ - 1739, /* GL_SAMPLER_BINDING */ - 164, /* GL_CLAMP_VERTEX_COLOR_ARB */ - 156, /* GL_CLAMP_FRAGMENT_COLOR_ARB */ - 157, /* GL_CLAMP_READ_COLOR */ - 567, /* GL_FIXED_ONLY */ - 1387, /* GL_POINT_SIZE_ARRAY_TYPE_OES */ - 1386, /* GL_POINT_SIZE_ARRAY_STRIDE_OES */ - 1385, /* GL_POINT_SIZE_ARRAY_POINTER_OES */ - 1220, /* GL_MODELVIEW_MATRIX_FLOAT_AS_INT_BITS_OES */ - 1512, /* GL_PROJECTION_MATRIX_FLOAT_AS_INT_BITS_OES */ - 2114, /* GL_TEXTURE_MATRIX_FLOAT_AS_INT_BITS_OES */ - 138, /* GL_BUFFER_SERIALIZED_MODIFY_APPLE */ - 128, /* GL_BUFFER_FLUSHING_UNMAP_APPLE */ - 1588, /* GL_RELEASED_APPLE */ - 2314, /* GL_VOLATILE_APPLE */ - 1629, /* GL_RETAINED_APPLE */ - 2188, /* GL_UNDEFINED_APPLE */ - 1536, /* GL_PURGEABLE_APPLE */ - 618, /* GL_FRAGMENT_SHADER */ - 2309, /* GL_VERTEX_SHADER */ - 1497, /* GL_PROGRAM_OBJECT_ARB */ - 1785, /* GL_SHADER_OBJECT_ARB */ - 1069, /* GL_MAX_FRAGMENT_UNIFORM_COMPONENTS */ - 1159, /* GL_MAX_VERTEX_UNIFORM_COMPONENTS */ - 1150, /* GL_MAX_VARYING_COMPONENTS */ - 1157, /* GL_MAX_VERTEX_TEXTURE_IMAGE_UNITS */ - 1051, /* GL_MAX_COMBINED_TEXTURE_IMAGE_UNITS */ - 1283, /* GL_OBJECT_TYPE_ARB */ - 1787, /* GL_SHADER_TYPE */ - 583, /* GL_FLOAT_VEC2 */ - 585, /* GL_FLOAT_VEC3 */ - 587, /* GL_FLOAT_VEC4 */ - 810, /* GL_INT_VEC2 */ - 812, /* GL_INT_VEC3 */ - 814, /* GL_INT_VEC4 */ - 116, /* GL_BOOL */ - 118, /* GL_BOOL_VEC2 */ - 120, /* GL_BOOL_VEC3 */ - 122, /* GL_BOOL_VEC4 */ - 571, /* GL_FLOAT_MAT2 */ - 575, /* GL_FLOAT_MAT3 */ - 579, /* GL_FLOAT_MAT4 */ - 1723, /* GL_SAMPLER_1D */ - 1729, /* GL_SAMPLER_2D */ - 1737, /* GL_SAMPLER_3D */ - 1742, /* GL_SAMPLER_CUBE */ - 1728, /* GL_SAMPLER_1D_SHADOW */ - 1736, /* GL_SAMPLER_2D_SHADOW */ - 1734, /* GL_SAMPLER_2D_RECT */ - 1735, /* GL_SAMPLER_2D_RECT_SHADOW */ - 573, /* GL_FLOAT_MAT2x3 */ - 574, /* GL_FLOAT_MAT2x4 */ - 577, /* GL_FLOAT_MAT3x2 */ - 578, /* GL_FLOAT_MAT3x4 */ - 581, /* GL_FLOAT_MAT4x2 */ - 582, /* GL_FLOAT_MAT4x3 */ - 398, /* GL_DELETE_STATUS */ - 289, /* GL_COMPILE_STATUS */ - 871, /* GL_LINK_STATUS */ - 2254, /* GL_VALIDATE_STATUS */ - 768, /* GL_INFO_LOG_LENGTH */ - 64, /* GL_ATTACHED_SHADERS */ - 21, /* GL_ACTIVE_UNIFORMS */ - 22, /* GL_ACTIVE_UNIFORM_MAX_LENGTH */ - 1786, /* GL_SHADER_SOURCE_LENGTH */ - 15, /* GL_ACTIVE_ATTRIBUTES */ - 16, /* GL_ACTIVE_ATTRIBUTE_MAX_LENGTH */ - 620, /* GL_FRAGMENT_SHADER_DERIVATIVE_HINT */ - 1789, /* GL_SHADING_LANGUAGE_VERSION */ - 375, /* GL_CURRENT_PROGRAM */ - 1332, /* GL_PALETTE4_RGB8_OES */ - 1334, /* GL_PALETTE4_RGBA8_OES */ - 1330, /* GL_PALETTE4_R5_G6_B5_OES */ - 1333, /* GL_PALETTE4_RGBA4_OES */ - 1331, /* GL_PALETTE4_RGB5_A1_OES */ - 1337, /* GL_PALETTE8_RGB8_OES */ - 1339, /* GL_PALETTE8_RGBA8_OES */ - 1335, /* GL_PALETTE8_R5_G6_B5_OES */ - 1338, /* GL_PALETTE8_RGBA4_OES */ - 1336, /* GL_PALETTE8_RGB5_A1_OES */ - 749, /* GL_IMPLEMENTATION_COLOR_READ_TYPE */ - 747, /* GL_IMPLEMENTATION_COLOR_READ_FORMAT */ - 1384, /* GL_POINT_SIZE_ARRAY_OES */ - 2057, /* GL_TEXTURE_CROP_RECT_OES */ - 1023, /* GL_MATRIX_INDEX_ARRAY_BUFFER_BINDING_OES */ - 1383, /* GL_POINT_SIZE_ARRAY_BUFFER_BINDING_OES */ - 2237, /* GL_UNSIGNED_NORMALIZED */ - 1989, /* GL_TEXTURE_1D_ARRAY */ - 1522, /* GL_PROXY_TEXTURE_1D_ARRAY */ - 1992, /* GL_TEXTURE_2D_ARRAY */ - 1526, /* GL_PROXY_TEXTURE_2D_ARRAY */ - 2000, /* GL_TEXTURE_BINDING_1D_ARRAY */ - 2003, /* GL_TEXTURE_BINDING_2D_ARRAY */ - 1076, /* GL_MAX_GEOMETRY_TEXTURE_IMAGE_UNITS */ - 2021, /* GL_TEXTURE_BUFFER */ - 1129, /* GL_MAX_TEXTURE_BUFFER_SIZE */ - 2007, /* GL_TEXTURE_BINDING_BUFFER */ - 2023, /* GL_TEXTURE_BUFFER_DATA_STORE_BINDING */ - 2025, /* GL_TEXTURE_BUFFER_FORMAT */ - 1559, /* GL_R11F_G11F_B10F */ - 2203, /* GL_UNSIGNED_INT_10F_11F_11F_REV */ - 1673, /* GL_RGB9_E5 */ - 2212, /* GL_UNSIGNED_INT_5_9_9_9_REV */ - 2132, /* GL_TEXTURE_SHARED_SIZE */ - 1842, /* GL_SRGB */ - 1843, /* GL_SRGB8 */ - 1845, /* GL_SRGB_ALPHA */ - 1844, /* GL_SRGB8_ALPHA8 */ - 1802, /* GL_SLUMINANCE_ALPHA */ - 1801, /* GL_SLUMINANCE8_ALPHA8 */ - 1799, /* GL_SLUMINANCE */ - 1800, /* GL_SLUMINANCE8 */ - 312, /* GL_COMPRESSED_SRGB */ - 313, /* GL_COMPRESSED_SRGB_ALPHA */ - 310, /* GL_COMPRESSED_SLUMINANCE */ - 311, /* GL_COMPRESSED_SLUMINANCE_ALPHA */ - 2167, /* GL_TRANSFORM_FEEDBACK_VARYING_MAX_LENGTH */ - 2156, /* GL_TRANSFORM_FEEDBACK_BUFFER_MODE */ - 1148, /* GL_MAX_TRANSFORM_FEEDBACK_SEPARATE_COMPONENTS */ - 2165, /* GL_TRANSFORM_FEEDBACK_VARYINGS */ - 2161, /* GL_TRANSFORM_FEEDBACK_BUFFER_START */ - 2159, /* GL_TRANSFORM_FEEDBACK_BUFFER_SIZE */ - 1466, /* GL_PRIMITIVES_GENERATED */ - 2163, /* GL_TRANSFORM_FEEDBACK_PRIMITIVES_WRITTEN */ - 1563, /* GL_RASTERIZER_DISCARD */ - 1144, /* GL_MAX_TRANSFORM_FEEDBACK_INTERLEAVED_COMPONENTS */ - 1146, /* GL_MAX_TRANSFORM_FEEDBACK_SEPARATE_ATTRIBS */ - 787, /* GL_INTERLEAVED_ATTRIBS */ - 1778, /* GL_SEPARATE_ATTRIBS */ - 2151, /* GL_TRANSFORM_FEEDBACK_BUFFER */ - 2153, /* GL_TRANSFORM_FEEDBACK_BUFFER_BINDING */ - 1402, /* GL_POINT_SPRITE_COORD_ORIGIN */ - 880, /* GL_LOWER_LEFT */ - 2251, /* GL_UPPER_LEFT */ - 1866, /* GL_STENCIL_BACK_REF */ - 1867, /* GL_STENCIL_BACK_VALUE_MASK */ - 1868, /* GL_STENCIL_BACK_WRITEMASK */ - 520, /* GL_DRAW_FRAMEBUFFER_BINDING */ - 1593, /* GL_RENDERBUFFER_BINDING */ - 1567, /* GL_READ_FRAMEBUFFER */ - 519, /* GL_DRAW_FRAMEBUFFER */ - 1568, /* GL_READ_FRAMEBUFFER_BINDING */ - 1612, /* GL_RENDERBUFFER_SAMPLES */ - 634, /* GL_FRAMEBUFFER_ATTACHMENT_OBJECT_TYPE */ - 631, /* GL_FRAMEBUFFER_ATTACHMENT_OBJECT_NAME */ - 646, /* GL_FRAMEBUFFER_ATTACHMENT_TEXTURE_LEVEL */ - 641, /* GL_FRAMEBUFFER_ATTACHMENT_TEXTURE_CUBE_MAP_FACE */ - 644, /* GL_FRAMEBUFFER_ATTACHMENT_TEXTURE_LAYER */ - 652, /* GL_FRAMEBUFFER_COMPLETE */ - 657, /* GL_FRAMEBUFFER_INCOMPLETE_ATTACHMENT */ - 672, /* GL_FRAMEBUFFER_INCOMPLETE_MISSING_ATTACHMENT */ - 666, /* GL_FRAMEBUFFER_INCOMPLETE_DUPLICATE_ATTACHMENT_EXT */ - 661, /* GL_FRAMEBUFFER_INCOMPLETE_DIMENSIONS_EXT */ - 667, /* GL_FRAMEBUFFER_INCOMPLETE_FORMATS_EXT */ - 663, /* GL_FRAMEBUFFER_INCOMPLETE_DRAW_BUFFER */ - 677, /* GL_FRAMEBUFFER_INCOMPLETE_READ_BUFFER */ - 683, /* GL_FRAMEBUFFER_UNSUPPORTED */ - 681, /* GL_FRAMEBUFFER_STATUS_ERROR_EXT */ - 1047, /* GL_MAX_COLOR_ATTACHMENTS */ - 196, /* GL_COLOR_ATTACHMENT0 */ - 199, /* GL_COLOR_ATTACHMENT1 */ - 213, /* GL_COLOR_ATTACHMENT2 */ - 215, /* GL_COLOR_ATTACHMENT3 */ - 217, /* GL_COLOR_ATTACHMENT4 */ - 219, /* GL_COLOR_ATTACHMENT5 */ - 221, /* GL_COLOR_ATTACHMENT6 */ - 223, /* GL_COLOR_ATTACHMENT7 */ - 225, /* GL_COLOR_ATTACHMENT8 */ - 227, /* GL_COLOR_ATTACHMENT9 */ - 200, /* GL_COLOR_ATTACHMENT10 */ - 202, /* GL_COLOR_ATTACHMENT11 */ - 204, /* GL_COLOR_ATTACHMENT12 */ - 206, /* GL_COLOR_ATTACHMENT13 */ - 208, /* GL_COLOR_ATTACHMENT14 */ - 210, /* GL_COLOR_ATTACHMENT15 */ - 403, /* GL_DEPTH_ATTACHMENT */ - 1855, /* GL_STENCIL_ATTACHMENT */ - 622, /* GL_FRAMEBUFFER */ - 1590, /* GL_RENDERBUFFER */ - 1616, /* GL_RENDERBUFFER_WIDTH */ - 1603, /* GL_RENDERBUFFER_HEIGHT */ - 1606, /* GL_RENDERBUFFER_INTERNAL_FORMAT */ - 1887, /* GL_STENCIL_INDEX_EXT */ - 1876, /* GL_STENCIL_INDEX1 */ - 1881, /* GL_STENCIL_INDEX4 */ - 1884, /* GL_STENCIL_INDEX8 */ - 1877, /* GL_STENCIL_INDEX16 */ - 1610, /* GL_RENDERBUFFER_RED_SIZE */ - 1601, /* GL_RENDERBUFFER_GREEN_SIZE */ - 1596, /* GL_RENDERBUFFER_BLUE_SIZE */ - 1591, /* GL_RENDERBUFFER_ALPHA_SIZE */ - 1598, /* GL_RENDERBUFFER_DEPTH_SIZE */ - 1614, /* GL_RENDERBUFFER_STENCIL_SIZE */ - 675, /* GL_FRAMEBUFFER_INCOMPLETE_MULTISAMPLE */ - 1124, /* GL_MAX_SAMPLES */ - 2094, /* GL_TEXTURE_GEN_STR_OES */ - 723, /* GL_HALF_FLOAT_OES */ - 1659, /* GL_RGB565 */ - 547, /* GL_ETC1_RGB8_OES */ - 2086, /* GL_TEXTURE_EXTERNAL_OES */ - 1745, /* GL_SAMPLER_EXTERNAL_OES */ - 2012, /* GL_TEXTURE_BINDING_EXTERNAL_OES */ - 1625, /* GL_REQUIRED_TEXTURE_IMAGE_UNITS_OES */ - 1690, /* GL_RGBA32UI */ - 1653, /* GL_RGB32UI */ - 40, /* GL_ALPHA32UI_EXT */ - 779, /* GL_INTENSITY32UI_EXT */ - 897, /* GL_LUMINANCE32UI_EXT */ - 914, /* GL_LUMINANCE_ALPHA32UI_EXT */ - 1681, /* GL_RGBA16UI */ - 1645, /* GL_RGB16UI */ - 37, /* GL_ALPHA16UI_EXT */ - 776, /* GL_INTENSITY16UI_EXT */ - 892, /* GL_LUMINANCE16UI_EXT */ - 912, /* GL_LUMINANCE_ALPHA16UI_EXT */ - 1700, /* GL_RGBA8UI */ - 1668, /* GL_RGB8UI */ - 45, /* GL_ALPHA8UI_EXT */ - 784, /* GL_INTENSITY8UI_EXT */ - 906, /* GL_LUMINANCE8UI_EXT */ - 916, /* GL_LUMINANCE_ALPHA8UI_EXT */ - 1688, /* GL_RGBA32I */ - 1651, /* GL_RGB32I */ - 39, /* GL_ALPHA32I_EXT */ - 778, /* GL_INTENSITY32I_EXT */ - 896, /* GL_LUMINANCE32I_EXT */ - 913, /* GL_LUMINANCE_ALPHA32I_EXT */ - 1679, /* GL_RGBA16I */ - 1643, /* GL_RGB16I */ - 36, /* GL_ALPHA16I_EXT */ - 775, /* GL_INTENSITY16I_EXT */ - 891, /* GL_LUMINANCE16I_EXT */ - 911, /* GL_LUMINANCE_ALPHA16I_EXT */ - 1698, /* GL_RGBA8I */ - 1666, /* GL_RGB8I */ - 44, /* GL_ALPHA8I_EXT */ - 783, /* GL_INTENSITY8I_EXT */ - 905, /* GL_LUMINANCE8I_EXT */ - 915, /* GL_LUMINANCE_ALPHA8I_EXT */ - 1580, /* GL_RED_INTEGER */ - 718, /* GL_GREEN_INTEGER */ - 113, /* GL_BLUE_INTEGER */ - 49, /* GL_ALPHA_INTEGER_EXT */ - 1713, /* GL_RGB_INTEGER */ - 1707, /* GL_RGBA_INTEGER */ - 84, /* GL_BGR_INTEGER */ - 82, /* GL_BGRA_INTEGER */ - 918, /* GL_LUMINANCE_INTEGER_EXT */ - 917, /* GL_LUMINANCE_ALPHA_INTEGER_EXT */ - 1709, /* GL_RGBA_INTEGER_MODE_EXT */ - 793, /* GL_INT_2_10_10_10_REV */ - 629, /* GL_FRAMEBUFFER_ATTACHMENT_LAYERED */ - 670, /* GL_FRAMEBUFFER_INCOMPLETE_LAYER_TARGETS */ - 669, /* GL_FRAMEBUFFER_INCOMPLETE_LAYER_COUNT_ARB */ - 1724, /* GL_SAMPLER_1D_ARRAY */ - 1730, /* GL_SAMPLER_2D_ARRAY */ - 1740, /* GL_SAMPLER_BUFFER */ - 1726, /* GL_SAMPLER_1D_ARRAY_SHADOW */ - 1732, /* GL_SAMPLER_2D_ARRAY_SHADOW */ - 1743, /* GL_SAMPLER_CUBE_SHADOW */ - 2231, /* GL_UNSIGNED_INT_VEC2 */ - 2233, /* GL_UNSIGNED_INT_VEC3 */ - 2235, /* GL_UNSIGNED_INT_VEC4 */ - 794, /* GL_INT_SAMPLER_1D */ - 798, /* GL_INT_SAMPLER_2D */ - 804, /* GL_INT_SAMPLER_3D */ - 808, /* GL_INT_SAMPLER_CUBE */ - 802, /* GL_INT_SAMPLER_2D_RECT */ - 795, /* GL_INT_SAMPLER_1D_ARRAY */ - 799, /* GL_INT_SAMPLER_2D_ARRAY */ - 806, /* GL_INT_SAMPLER_BUFFER */ - 2215, /* GL_UNSIGNED_INT_SAMPLER_1D */ - 2219, /* GL_UNSIGNED_INT_SAMPLER_2D */ - 2225, /* GL_UNSIGNED_INT_SAMPLER_3D */ - 2229, /* GL_UNSIGNED_INT_SAMPLER_CUBE */ - 2223, /* GL_UNSIGNED_INT_SAMPLER_2D_RECT */ - 2216, /* GL_UNSIGNED_INT_SAMPLER_1D_ARRAY */ - 2220, /* GL_UNSIGNED_INT_SAMPLER_2D_ARRAY */ - 2227, /* GL_UNSIGNED_INT_SAMPLER_BUFFER */ - 708, /* GL_GEOMETRY_SHADER */ - 711, /* GL_GEOMETRY_VERTICES_OUT_ARB */ - 705, /* GL_GEOMETRY_INPUT_TYPE_ARB */ - 707, /* GL_GEOMETRY_OUTPUT_TYPE_ARB */ - 1082, /* GL_MAX_GEOMETRY_VARYING_COMPONENTS_ARB */ - 1164, /* GL_MAX_VERTEX_VARYING_COMPONENTS_ARB */ - 1080, /* GL_MAX_GEOMETRY_UNIFORM_COMPONENTS */ - 1074, /* GL_MAX_GEOMETRY_OUTPUT_VERTICES */ - 1078, /* GL_MAX_GEOMETRY_TOTAL_OUTPUT_COMPONENTS */ - 881, /* GL_LOW_FLOAT */ - 1166, /* GL_MEDIUM_FLOAT */ - 724, /* GL_HIGH_FLOAT */ - 882, /* GL_LOW_INT */ - 1167, /* GL_MEDIUM_INT */ - 725, /* GL_HIGH_INT */ - 2205, /* GL_UNSIGNED_INT_10_10_10_2_OES */ - 792, /* GL_INT_10_10_10_2_OES */ - 1783, /* GL_SHADER_BINARY_FORMATS */ - 1268, /* GL_NUM_SHADER_BINARY_FORMATS */ - 1784, /* GL_SHADER_COMPILER */ - 1161, /* GL_MAX_VERTEX_UNIFORM_VECTORS */ - 1153, /* GL_MAX_VARYING_VECTORS */ - 1071, /* GL_MAX_FRAGMENT_UNIFORM_VECTORS */ - 1556, /* GL_QUERY_WAIT */ - 1550, /* GL_QUERY_NO_WAIT */ - 1546, /* GL_QUERY_BY_REGION_WAIT */ - 1544, /* GL_QUERY_BY_REGION_NO_WAIT */ - 2149, /* GL_TRANSFORM_FEEDBACK */ - 2158, /* GL_TRANSFORM_FEEDBACK_BUFFER_PAUSED */ - 2152, /* GL_TRANSFORM_FEEDBACK_BUFFER_ACTIVE */ - 2150, /* GL_TRANSFORM_FEEDBACK_BINDING */ - 1540, /* GL_QUADS_FOLLOW_PROVOKING_VERTEX_CONVENTION */ - 563, /* GL_FIRST_VERTEX_CONVENTION */ - 826, /* GL_LAST_VERTEX_CONVENTION */ - 1514, /* GL_PROVOKING_VERTEX */ - 354, /* GL_COPY_READ_BUFFER */ - 355, /* GL_COPY_WRITE_BUFFER */ - 1583, /* GL_RED_SNORM */ - 1720, /* GL_RG_SNORM */ - 1719, /* GL_RGB_SNORM */ - 1712, /* GL_RGBA_SNORM */ - 1562, /* GL_R8_SNORM */ - 1632, /* GL_RG8_SNORM */ - 1672, /* GL_RGB8_SNORM */ - 1704, /* GL_RGBA8_SNORM */ - 1560, /* GL_R16_SNORM */ - 1631, /* GL_RG16_SNORM */ - 1648, /* GL_RGB16_SNORM */ - 1684, /* GL_RGBA16_SNORM */ - 1795, /* GL_SIGNED_NORMALIZED */ - 1468, /* GL_PRIMITIVE_RESTART */ - 1469, /* GL_PRIMITIVE_RESTART_INDEX */ - 1636, /* GL_RGB10_A2UI */ - 1126, /* GL_MAX_SERVER_WAIT_TIMEOUT */ - 1282, /* GL_OBJECT_TYPE */ - 1908, /* GL_SYNC_CONDITION */ - 1913, /* GL_SYNC_STATUS */ - 1910, /* GL_SYNC_FLAGS */ - 1909, /* GL_SYNC_FENCE */ - 1912, /* GL_SYNC_GPU_COMMANDS_COMPLETE */ - 2198, /* GL_UNSIGNALED */ - 1794, /* GL_SIGNALED */ - 54, /* GL_ALREADY_SIGNALED */ - 2144, /* GL_TIMEOUT_EXPIRED */ - 315, /* GL_CONDITION_SATISFIED */ - 2315, /* GL_WAIT_FAILED */ - 126, /* GL_BUFFER_ACCESS_FLAGS */ - 132, /* GL_BUFFER_MAP_LENGTH */ - 133, /* GL_BUFFER_MAP_OFFSET */ - 1156, /* GL_MAX_VERTEX_OUTPUT_COMPONENTS */ - 1072, /* GL_MAX_GEOMETRY_INPUT_COMPONENTS */ - 1073, /* GL_MAX_GEOMETRY_OUTPUT_COMPONENTS */ - 1068, /* GL_MAX_FRAGMENT_INPUT_COMPONENTS */ - 330, /* GL_CONTEXT_PROFILE_MASK */ - 713, /* GL_GL_TEXTURE_IMMUTABLE_FORMAT */ - 548, /* GL_EVAL_BIT */ - 1565, /* GL_RASTER_POSITION_UNCLIPPED_IBM */ - 873, /* GL_LIST_BIT */ - 2016, /* GL_TEXTURE_BIT */ - 1764, /* GL_SCISSOR_BIT */ - 30, /* GL_ALL_ATTRIB_BITS */ - 1231, /* GL_MULTISAMPLE_BIT */ - 31, /* GL_ALL_CLIENT_ATTRIB_BITS */ -}; - -typedef int (*cfunc)(const void *, const void *); - -/** - * Compare a key name to an element in the \c all_enums array. - * - * \c bsearch always passes the key as the first parameter and the pointer - * to the array element as the second parameter. We can elimiate some - * extra work by taking advantage of that fact. - * - * \param a Pointer to the desired enum name. - * \param b Pointer to an element of the \c all_enums array. - */ -static int compar_name( const char *a, const enum_elt *b ) -{ - return strcmp( a, & enum_string_table[ b->offset ] ); -} - -/** - * Compare a key enum value to an element in the \c all_enums array. - * - * \c bsearch always passes the key as the first parameter and the pointer - * to the array element as the second parameter. We can elimiate some - * extra work by taking advantage of that fact. - * - * \param a Pointer to the desired enum name. - * \param b Pointer to an index into the \c all_enums array. - */ -static int compar_nr( const int *a, const unsigned *b ) -{ - return a[0] - all_enums[*b].n; -} - - -static char token_tmp[20]; - -const char *_mesa_lookup_enum_by_nr( int nr ) -{ - unsigned * i; - - i = (unsigned *) _mesa_bsearch(& nr, reduced_enums, - Elements(reduced_enums), - sizeof(reduced_enums[0]), - (cfunc) compar_nr); - - if ( i != NULL ) { - return & enum_string_table[ all_enums[ *i ].offset ]; - } - else { - /* this is not re-entrant safe, no big deal here */ - _mesa_snprintf(token_tmp, sizeof(token_tmp) - 1, "0x%x", nr); - token_tmp[sizeof(token_tmp) - 1] = '\0'; - return token_tmp; - } -} - -/** - * Primitive names - */ -static const char *prim_names[PRIM_UNKNOWN + 1] = { - "GL_POINTS", - "GL_LINES", - "GL_LINE_LOOP", - "GL_LINE_STRIP", - "GL_TRIANGLES", - "GL_TRIANGLE_STRIP", - "GL_TRIANGLE_FAN", - "GL_QUADS", - "GL_QUAD_STRIP", - "GL_POLYGON", - "outside begin/end", - "inside unknown primitive", - "unknown state" -}; - - -/* Get the name of an enum given that it is a primitive type. Avoids - * GL_FALSE/GL_POINTS ambiguity and others. - */ -const char * -_mesa_lookup_prim_by_nr(GLuint nr) -{ - if (nr < Elements(prim_names)) - return prim_names[nr]; - else - return "invalid mode"; -} - - -int _mesa_lookup_enum_by_name( const char *symbol ) -{ - enum_elt * f = NULL; - - if ( symbol != NULL ) { - f = (enum_elt *) _mesa_bsearch(symbol, all_enums, - Elements(all_enums), - sizeof( enum_elt ), - (cfunc) compar_name); - } - - return (f != NULL) ? f->n : -1; -} - - diff --git a/dll/opengl/mesa/main/enums.h b/dll/opengl/mesa/main/enums.h deleted file mode 100644 index 7733df22f91..00000000000 --- a/dll/opengl/mesa/main/enums.h +++ /dev/null @@ -1,62 +0,0 @@ -/** - * \file enums.h - * Enumeration name/number lookup functions. - * - * \if subset - * (No-op) - * - * \endif - */ - -/* - * Mesa 3-D graphics library - * Version: 6.5.1 - * - * Copyright (C) 1999-2006 Brian Paul All Rights Reserved. - * - * Permission is hereby granted, free of charge, to any person obtaining a - * copy of this software and associated documentation files (the "Software"), - * to deal in the Software without restriction, including without limitation - * the rights to use, copy, modify, merge, publish, distribute, sublicense, - * and/or sell copies of the Software, and to permit persons to whom the - * Software is furnished to do so, subject to the following conditions: - * - * The above copyright notice and this permission notice shall be included - * in all copies or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS - * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL - * BRIAN PAUL BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN - * AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN - * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. - */ - - -#ifndef _ENUMS_H_ -#define _ENUMS_H_ - -#include "mfeatures.h" - -#if defined(_HAVE_FULL_GL) && _HAVE_FULL_GL - -extern const char *_mesa_lookup_enum_by_nr( int nr ); - -/* Get the name of an enum given that it is a primitive type. Avoids - * GL_FALSE/GL_POINTS ambiguity and others. - */ -const char *_mesa_lookup_prim_by_nr( unsigned nr ); - -extern int _mesa_lookup_enum_by_name( const char *symbol ); - -#else - -/** No-op */ -#define _mesa_lookup_enum_by_name( s ) 0 - -/** No-op */ -#define _mesa_lookup_enum_by_nr( n ) "unknown" - -#endif - -#endif diff --git a/dll/opengl/mesa/main/eval.c b/dll/opengl/mesa/main/eval.c deleted file mode 100644 index f15521d6465..00000000000 --- a/dll/opengl/mesa/main/eval.c +++ /dev/null @@ -1,928 +0,0 @@ - -/* - * Mesa 3-D graphics library - * Version: 5.1 - * - * Copyright (C) 1999-2003 Brian Paul All Rights Reserved. - * - * Permission is hereby granted, free of charge, to any person obtaining a - * copy of this software and associated documentation files (the "Software"), - * to deal in the Software without restriction, including without limitation - * the rights to use, copy, modify, merge, publish, distribute, sublicense, - * and/or sell copies of the Software, and to permit persons to whom the - * Software is furnished to do so, subject to the following conditions: - * - * The above copyright notice and this permission notice shall be included - * in all copies or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS - * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL - * BRIAN PAUL BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN - * AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN - * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. - */ - -/* - * eval.c was written by - * Bernd Barsuhn (bdbarsuh@cip.informatik.uni-erlangen.de) and - * Volker Weiss (vrweiss@cip.informatik.uni-erlangen.de). - * - * My original implementation of evaluators was simplistic and didn't - * compute surface normal vectors properly. Bernd and Volker applied - * used more sophisticated methods to get better results. - * - * Thanks guys! - */ - -#include - -#if FEATURE_evaluators - - -/* - * Return the number of components per control point for any type of - * evaluator. Return 0 if bad target. - * See table 5.1 in the OpenGL 1.2 spec. - */ -GLuint _mesa_evaluator_components( GLenum target ) -{ - switch (target) { - case GL_MAP1_VERTEX_3: return 3; - case GL_MAP1_VERTEX_4: return 4; - case GL_MAP1_INDEX: return 1; - case GL_MAP1_COLOR_4: return 4; - case GL_MAP1_NORMAL: return 3; - case GL_MAP1_TEXTURE_COORD_1: return 1; - case GL_MAP1_TEXTURE_COORD_2: return 2; - case GL_MAP1_TEXTURE_COORD_3: return 3; - case GL_MAP1_TEXTURE_COORD_4: return 4; - case GL_MAP2_VERTEX_3: return 3; - case GL_MAP2_VERTEX_4: return 4; - case GL_MAP2_INDEX: return 1; - case GL_MAP2_COLOR_4: return 4; - case GL_MAP2_NORMAL: return 3; - case GL_MAP2_TEXTURE_COORD_1: return 1; - case GL_MAP2_TEXTURE_COORD_2: return 2; - case GL_MAP2_TEXTURE_COORD_3: return 3; - case GL_MAP2_TEXTURE_COORD_4: return 4; - default: break; - } - - /* XXX need to check for the vertex program extension - if (!ctx->Extensions.NV_vertex_program) - return 0; - */ - - if (target >= GL_MAP1_VERTEX_ATTRIB0_4_NV && - target <= GL_MAP1_VERTEX_ATTRIB15_4_NV) - return 4; - - if (target >= GL_MAP2_VERTEX_ATTRIB0_4_NV && - target <= GL_MAP2_VERTEX_ATTRIB15_4_NV) - return 4; - - return 0; -} - - -/* - * Return pointer to the gl_1d_map struct for the named target. - */ -static struct gl_1d_map * -get_1d_map( struct gl_context *ctx, GLenum target ) -{ - switch (target) { - case GL_MAP1_VERTEX_3: - return &ctx->EvalMap.Map1Vertex3; - case GL_MAP1_VERTEX_4: - return &ctx->EvalMap.Map1Vertex4; - case GL_MAP1_INDEX: - return &ctx->EvalMap.Map1Index; - case GL_MAP1_COLOR_4: - return &ctx->EvalMap.Map1Color4; - case GL_MAP1_NORMAL: - return &ctx->EvalMap.Map1Normal; - case GL_MAP1_TEXTURE_COORD_1: - return &ctx->EvalMap.Map1Texture1; - case GL_MAP1_TEXTURE_COORD_2: - return &ctx->EvalMap.Map1Texture2; - case GL_MAP1_TEXTURE_COORD_3: - return &ctx->EvalMap.Map1Texture3; - case GL_MAP1_TEXTURE_COORD_4: - return &ctx->EvalMap.Map1Texture4; - default: - return NULL; - } -} - - -/* - * Return pointer to the gl_2d_map struct for the named target. - */ -static struct gl_2d_map * -get_2d_map( struct gl_context *ctx, GLenum target ) -{ - switch (target) { - case GL_MAP2_VERTEX_3: - return &ctx->EvalMap.Map2Vertex3; - case GL_MAP2_VERTEX_4: - return &ctx->EvalMap.Map2Vertex4; - case GL_MAP2_INDEX: - return &ctx->EvalMap.Map2Index; - case GL_MAP2_COLOR_4: - return &ctx->EvalMap.Map2Color4; - case GL_MAP2_NORMAL: - return &ctx->EvalMap.Map2Normal; - case GL_MAP2_TEXTURE_COORD_1: - return &ctx->EvalMap.Map2Texture1; - case GL_MAP2_TEXTURE_COORD_2: - return &ctx->EvalMap.Map2Texture2; - case GL_MAP2_TEXTURE_COORD_3: - return &ctx->EvalMap.Map2Texture3; - case GL_MAP2_TEXTURE_COORD_4: - return &ctx->EvalMap.Map2Texture4; - default: - return NULL; - } -} - - -/**********************************************************************/ -/*** Copy and deallocate control points ***/ -/**********************************************************************/ - - -/* - * Copy 1-parametric evaluator control points from user-specified - * memory space to a buffer of contiguous control points. - * \param see glMap1f for details - * \return pointer to buffer of contiguous control points or NULL if out - * of memory. - */ -GLfloat *_mesa_copy_map_points1f( GLenum target, GLint ustride, GLint uorder, - const GLfloat *points ) -{ - GLfloat *buffer, *p; - GLint i, k, size = _mesa_evaluator_components(target); - - if (!points || !size) - return NULL; - - buffer = (GLfloat *) MALLOC(uorder * size * sizeof(GLfloat)); - - if (buffer) - for (i = 0, p = buffer; i < uorder; i++, points += ustride) - for (k = 0; k < size; k++) - *p++ = points[k]; - - return buffer; -} - - - -/* - * Same as above but convert doubles to floats. - */ -GLfloat *_mesa_copy_map_points1d( GLenum target, GLint ustride, GLint uorder, - const GLdouble *points ) -{ - GLfloat *buffer, *p; - GLint i, k, size = _mesa_evaluator_components(target); - - if (!points || !size) - return NULL; - - buffer = (GLfloat *) MALLOC(uorder * size * sizeof(GLfloat)); - - if (buffer) - for (i = 0, p = buffer; i < uorder; i++, points += ustride) - for (k = 0; k < size; k++) - *p++ = (GLfloat) points[k]; - - return buffer; -} - - - -/* - * Copy 2-parametric evaluator control points from user-specified - * memory space to a buffer of contiguous control points. - * Additional memory is allocated to be used by the horner and - * de Casteljau evaluation schemes. - * - * \param see glMap2f for details - * \return pointer to buffer of contiguous control points or NULL if out - * of memory. - */ -GLfloat *_mesa_copy_map_points2f( GLenum target, - GLint ustride, GLint uorder, - GLint vstride, GLint vorder, - const GLfloat *points ) -{ - GLfloat *buffer, *p; - GLint i, j, k, size, dsize, hsize; - GLint uinc; - - size = _mesa_evaluator_components(target); - - if (!points || size==0) { - return NULL; - } - - /* max(uorder, vorder) additional points are used in */ - /* horner evaluation and uorder*vorder additional */ - /* values are needed for de Casteljau */ - dsize = (uorder == 2 && vorder == 2)? 0 : uorder*vorder; - hsize = (uorder > vorder ? uorder : vorder)*size; - - if(hsize>dsize) - buffer = (GLfloat *) MALLOC((uorder*vorder*size+hsize)*sizeof(GLfloat)); - else - buffer = (GLfloat *) MALLOC((uorder*vorder*size+dsize)*sizeof(GLfloat)); - - /* compute the increment value for the u-loop */ - uinc = ustride - vorder*vstride; - - if (buffer) - for (i=0, p=buffer; i vorder ? uorder : vorder)*size; - - if(hsize>dsize) - buffer = (GLfloat *) MALLOC((uorder*vorder*size+hsize)*sizeof(GLfloat)); - else - buffer = (GLfloat *) MALLOC((uorder*vorder*size+dsize)*sizeof(GLfloat)); - - /* compute the increment value for the u-loop */ - uinc = ustride - vorder*vstride; - - if (buffer) - for (i=0, p=buffer; i MAX_EVAL_ORDER) { - _mesa_error( ctx, GL_INVALID_VALUE, "glMap1(order)" ); - return; - } - if (!points) { - _mesa_error( ctx, GL_INVALID_VALUE, "glMap1(points)" ); - return; - } - - k = _mesa_evaluator_components( target ); - if (k == 0) { - _mesa_error( ctx, GL_INVALID_ENUM, "glMap1(target)" ); - } - - if (ustride < k) { - _mesa_error( ctx, GL_INVALID_VALUE, "glMap1(stride)" ); - return; - } - - map = get_1d_map(ctx, target); - if (!map) { - _mesa_error( ctx, GL_INVALID_ENUM, "glMap1(target)" ); - return; - } - - /* make copy of the control points */ - if (type == GL_FLOAT) - pnts = _mesa_copy_map_points1f(target, ustride, uorder, (GLfloat*) points); - else - pnts = _mesa_copy_map_points1d(target, ustride, uorder, (GLdouble*) points); - - - FLUSH_VERTICES(ctx, _NEW_EVAL); - map->Order = uorder; - map->u1 = u1; - map->u2 = u2; - map->du = 1.0F / (u2 - u1); - if (map->Points) - FREE( map->Points ); - map->Points = pnts; -} - - - -static void GLAPIENTRY -_mesa_Map1f( GLenum target, GLfloat u1, GLfloat u2, GLint stride, - GLint order, const GLfloat *points ) -{ - map1(target, u1, u2, stride, order, points, GL_FLOAT); -} - - -static void GLAPIENTRY -_mesa_Map1d( GLenum target, GLdouble u1, GLdouble u2, GLint stride, - GLint order, const GLdouble *points ) -{ - map1(target, (GLfloat) u1, (GLfloat) u2, stride, order, points, GL_DOUBLE); -} - - -static void -map2( GLenum target, GLfloat u1, GLfloat u2, GLint ustride, GLint uorder, - GLfloat v1, GLfloat v2, GLint vstride, GLint vorder, - const GLvoid *points, GLenum type ) -{ - GET_CURRENT_CONTEXT(ctx); - GLint k; - GLfloat *pnts; - struct gl_2d_map *map = NULL; - - ASSERT_OUTSIDE_BEGIN_END(ctx); - ASSERT(type == GL_FLOAT || type == GL_DOUBLE); - - if (u1==u2) { - _mesa_error( ctx, GL_INVALID_VALUE, "glMap2(u1,u2)" ); - return; - } - - if (v1==v2) { - _mesa_error( ctx, GL_INVALID_VALUE, "glMap2(v1,v2)" ); - return; - } - - if (uorder<1 || uorder>MAX_EVAL_ORDER) { - _mesa_error( ctx, GL_INVALID_VALUE, "glMap2(uorder)" ); - return; - } - - if (vorder<1 || vorder>MAX_EVAL_ORDER) { - _mesa_error( ctx, GL_INVALID_VALUE, "glMap2(vorder)" ); - return; - } - - k = _mesa_evaluator_components( target ); - if (k==0) { - _mesa_error( ctx, GL_INVALID_ENUM, "glMap2(target)" ); - } - - if (ustride < k) { - _mesa_error( ctx, GL_INVALID_VALUE, "glMap2(ustride)" ); - return; - } - if (vstride < k) { - _mesa_error( ctx, GL_INVALID_VALUE, "glMap2(vstride)" ); - return; - } - - map = get_2d_map(ctx, target); - if (!map) { - _mesa_error( ctx, GL_INVALID_ENUM, "glMap2(target)" ); - return; - } - - /* make copy of the control points */ - if (type == GL_FLOAT) - pnts = _mesa_copy_map_points2f(target, ustride, uorder, - vstride, vorder, (GLfloat*) points); - else - pnts = _mesa_copy_map_points2d(target, ustride, uorder, - vstride, vorder, (GLdouble*) points); - - - FLUSH_VERTICES(ctx, _NEW_EVAL); - map->Uorder = uorder; - map->u1 = u1; - map->u2 = u2; - map->du = 1.0F / (u2 - u1); - map->Vorder = vorder; - map->v1 = v1; - map->v2 = v2; - map->dv = 1.0F / (v2 - v1); - if (map->Points) - FREE( map->Points ); - map->Points = pnts; -} - - -static void GLAPIENTRY -_mesa_Map2f( GLenum target, - GLfloat u1, GLfloat u2, GLint ustride, GLint uorder, - GLfloat v1, GLfloat v2, GLint vstride, GLint vorder, - const GLfloat *points) -{ - map2(target, u1, u2, ustride, uorder, v1, v2, vstride, vorder, - points, GL_FLOAT); -} - - -static void GLAPIENTRY -_mesa_Map2d( GLenum target, - GLdouble u1, GLdouble u2, GLint ustride, GLint uorder, - GLdouble v1, GLdouble v2, GLint vstride, GLint vorder, - const GLdouble *points ) -{ - map2(target, (GLfloat) u1, (GLfloat) u2, ustride, uorder, - (GLfloat) v1, (GLfloat) v2, vstride, vorder, points, GL_DOUBLE); -} - - - -static void GLAPIENTRY -_mesa_GetMapdv( GLenum target, GLenum query, GLdouble *v ) -{ - GET_CURRENT_CONTEXT(ctx); - struct gl_1d_map *map1d; - struct gl_2d_map *map2d; - GLint i, n; - GLfloat *data; - GLuint comps; - - ASSERT_OUTSIDE_BEGIN_END(ctx); - - comps = _mesa_evaluator_components(target); - if (!comps) { - _mesa_error( ctx, GL_INVALID_ENUM, "glGetMapdv(target)" ); - return; - } - - map1d = get_1d_map(ctx, target); - map2d = get_2d_map(ctx, target); - ASSERT(map1d || map2d); - - switch (query) { - case GL_COEFF: - if (map1d) { - data = map1d->Points; - n = map1d->Order * comps; - } - else { - data = map2d->Points; - n = map2d->Uorder * map2d->Vorder * comps; - } - if (data) { - for (i=0;iOrder; - } - else { - v[0] = (GLdouble) map2d->Uorder; - v[1] = (GLdouble) map2d->Vorder; - } - break; - case GL_DOMAIN: - if (map1d) { - v[0] = (GLdouble) map1d->u1; - v[1] = (GLdouble) map1d->u2; - } - else { - v[0] = (GLdouble) map2d->u1; - v[1] = (GLdouble) map2d->u2; - v[2] = (GLdouble) map2d->v1; - v[3] = (GLdouble) map2d->v2; - } - break; - default: - _mesa_error( ctx, GL_INVALID_ENUM, "glGetMapdv(query)" ); - } - return; -} - -static void GLAPIENTRY -_mesa_GetMapfv( GLenum target, GLenum query, GLfloat *v ) -{ - GET_CURRENT_CONTEXT(ctx); - struct gl_1d_map *map1d; - struct gl_2d_map *map2d; - GLint i, n; - GLfloat *data; - GLuint comps; - - ASSERT_OUTSIDE_BEGIN_END(ctx); - - comps = _mesa_evaluator_components(target); - if (!comps) { - _mesa_error( ctx, GL_INVALID_ENUM, "glGetMapfv(target)" ); - return; - } - - map1d = get_1d_map(ctx, target); - map2d = get_2d_map(ctx, target); - ASSERT(map1d || map2d); - - switch (query) { - case GL_COEFF: - if (map1d) { - data = map1d->Points; - n = map1d->Order * comps; - } - else { - data = map2d->Points; - n = map2d->Uorder * map2d->Vorder * comps; - } - if (data) { - for (i=0;iOrder; - } - else { - v[0] = (GLfloat) map2d->Uorder; - v[1] = (GLfloat) map2d->Vorder; - } - break; - case GL_DOMAIN: - if (map1d) { - v[0] = map1d->u1; - v[1] = map1d->u2; - } - else { - v[0] = map2d->u1; - v[1] = map2d->u2; - v[2] = map2d->v1; - v[3] = map2d->v2; - } - break; - default: - _mesa_error( ctx, GL_INVALID_ENUM, "glGetMapfv(query)" ); - } - return; -} - - -static void GLAPIENTRY -_mesa_GetMapiv( GLenum target, GLenum query, GLint *v ) -{ - GET_CURRENT_CONTEXT(ctx); - struct gl_1d_map *map1d; - struct gl_2d_map *map2d; - GLuint i, n; - GLfloat *data; - GLuint comps; - - ASSERT_OUTSIDE_BEGIN_END(ctx); - - comps = _mesa_evaluator_components(target); - if (!comps) { - _mesa_error( ctx, GL_INVALID_ENUM, "glGetMapiv(target)" ); - return; - } - - map1d = get_1d_map(ctx, target); - map2d = get_2d_map(ctx, target); - ASSERT(map1d || map2d); - - switch (query) { - case GL_COEFF: - if (map1d) { - data = map1d->Points; - n = map1d->Order * comps; - } - else { - data = map2d->Points; - n = map2d->Uorder * map2d->Vorder * comps; - } - if (data) { - for (i=0;iOrder; - } - else { - v[0] = map2d->Uorder; - v[1] = map2d->Vorder; - } - break; - case GL_DOMAIN: - if (map1d) { - v[0] = IROUND(map1d->u1); - v[1] = IROUND(map1d->u2); - } - else { - v[0] = IROUND(map2d->u1); - v[1] = IROUND(map2d->u2); - v[2] = IROUND(map2d->v1); - v[3] = IROUND(map2d->v2); - } - break; - default: - _mesa_error( ctx, GL_INVALID_ENUM, "glGetMapiv(query)" ); - } - return; -} - - -static void GLAPIENTRY -_mesa_MapGrid1f( GLint un, GLfloat u1, GLfloat u2 ) -{ - GET_CURRENT_CONTEXT(ctx); - ASSERT_OUTSIDE_BEGIN_END(ctx); - - if (un<1) { - _mesa_error( ctx, GL_INVALID_VALUE, "glMapGrid1f" ); - return; - } - FLUSH_VERTICES(ctx, _NEW_EVAL); - ctx->Eval.MapGrid1un = un; - ctx->Eval.MapGrid1u1 = u1; - ctx->Eval.MapGrid1u2 = u2; - ctx->Eval.MapGrid1du = (u2 - u1) / (GLfloat) un; -} - - -static void GLAPIENTRY -_mesa_MapGrid1d( GLint un, GLdouble u1, GLdouble u2 ) -{ - _mesa_MapGrid1f( un, (GLfloat) u1, (GLfloat) u2 ); -} - - -static void GLAPIENTRY -_mesa_MapGrid2f( GLint un, GLfloat u1, GLfloat u2, - GLint vn, GLfloat v1, GLfloat v2 ) -{ - GET_CURRENT_CONTEXT(ctx); - ASSERT_OUTSIDE_BEGIN_END(ctx); - - if (un<1) { - _mesa_error( ctx, GL_INVALID_VALUE, "glMapGrid2f(un)" ); - return; - } - if (vn<1) { - _mesa_error( ctx, GL_INVALID_VALUE, "glMapGrid2f(vn)" ); - return; - } - - FLUSH_VERTICES(ctx, _NEW_EVAL); - ctx->Eval.MapGrid2un = un; - ctx->Eval.MapGrid2u1 = u1; - ctx->Eval.MapGrid2u2 = u2; - ctx->Eval.MapGrid2du = (u2 - u1) / (GLfloat) un; - ctx->Eval.MapGrid2vn = vn; - ctx->Eval.MapGrid2v1 = v1; - ctx->Eval.MapGrid2v2 = v2; - ctx->Eval.MapGrid2dv = (v2 - v1) / (GLfloat) vn; -} - - -static void GLAPIENTRY -_mesa_MapGrid2d( GLint un, GLdouble u1, GLdouble u2, - GLint vn, GLdouble v1, GLdouble v2 ) -{ - _mesa_MapGrid2f( un, (GLfloat) u1, (GLfloat) u2, - vn, (GLfloat) v1, (GLfloat) v2 ); -} - - -void -_mesa_install_eval_vtxfmt(struct _glapi_table *disp, - const GLvertexformat *vfmt) -{ - SET_EvalCoord1f(disp, vfmt->EvalCoord1f); - SET_EvalCoord1fv(disp, vfmt->EvalCoord1fv); - SET_EvalCoord2f(disp, vfmt->EvalCoord2f); - SET_EvalCoord2fv(disp, vfmt->EvalCoord2fv); - SET_EvalPoint1(disp, vfmt->EvalPoint1); - SET_EvalPoint2(disp, vfmt->EvalPoint2); - - SET_EvalMesh1(disp, vfmt->EvalMesh1); - SET_EvalMesh2(disp, vfmt->EvalMesh2); -} - - -void -_mesa_init_eval_dispatch(struct _glapi_table *disp) -{ - SET_GetMapdv(disp, _mesa_GetMapdv); - SET_GetMapfv(disp, _mesa_GetMapfv); - SET_GetMapiv(disp, _mesa_GetMapiv); - SET_Map1d(disp, _mesa_Map1d); - SET_Map1f(disp, _mesa_Map1f); - SET_Map2d(disp, _mesa_Map2d); - SET_Map2f(disp, _mesa_Map2f); - SET_MapGrid1d(disp, _mesa_MapGrid1d); - SET_MapGrid1f(disp, _mesa_MapGrid1f); - SET_MapGrid2d(disp, _mesa_MapGrid2d); - SET_MapGrid2f(disp, _mesa_MapGrid2f); -} - - -#endif /* FEATURE_evaluators */ - - -/**********************************************************************/ -/***** Initialization *****/ -/**********************************************************************/ - -/** - * Initialize a 1-D evaluator map. - */ -static void -init_1d_map( struct gl_1d_map *map, int n, const float *initial ) -{ - map->Order = 1; - map->u1 = 0.0; - map->u2 = 1.0; - map->Points = (GLfloat *) MALLOC(n * sizeof(GLfloat)); - if (map->Points) { - GLint i; - for (i=0;iPoints[i] = initial[i]; - } -} - - -/** - * Initialize a 2-D evaluator map - */ -static void -init_2d_map( struct gl_2d_map *map, int n, const float *initial ) -{ - map->Uorder = 1; - map->Vorder = 1; - map->u1 = 0.0; - map->u2 = 1.0; - map->v1 = 0.0; - map->v2 = 1.0; - map->Points = (GLfloat *) MALLOC(n * sizeof(GLfloat)); - if (map->Points) { - GLint i; - for (i=0;iPoints[i] = initial[i]; - } -} - - -void _mesa_init_eval( struct gl_context *ctx ) -{ - - /* Evaluators group */ - ctx->Eval.Map1Color4 = GL_FALSE; - ctx->Eval.Map1Index = GL_FALSE; - ctx->Eval.Map1Normal = GL_FALSE; - ctx->Eval.Map1TextureCoord1 = GL_FALSE; - ctx->Eval.Map1TextureCoord2 = GL_FALSE; - ctx->Eval.Map1TextureCoord3 = GL_FALSE; - ctx->Eval.Map1TextureCoord4 = GL_FALSE; - ctx->Eval.Map1Vertex3 = GL_FALSE; - ctx->Eval.Map1Vertex4 = GL_FALSE; - ctx->Eval.Map2Color4 = GL_FALSE; - ctx->Eval.Map2Index = GL_FALSE; - ctx->Eval.Map2Normal = GL_FALSE; - ctx->Eval.Map2TextureCoord1 = GL_FALSE; - ctx->Eval.Map2TextureCoord2 = GL_FALSE; - ctx->Eval.Map2TextureCoord3 = GL_FALSE; - ctx->Eval.Map2TextureCoord4 = GL_FALSE; - ctx->Eval.Map2Vertex3 = GL_FALSE; - ctx->Eval.Map2Vertex4 = GL_FALSE; - ctx->Eval.AutoNormal = GL_FALSE; - ctx->Eval.MapGrid1un = 1; - ctx->Eval.MapGrid1u1 = 0.0; - ctx->Eval.MapGrid1u2 = 1.0; - ctx->Eval.MapGrid2un = 1; - ctx->Eval.MapGrid2vn = 1; - ctx->Eval.MapGrid2u1 = 0.0; - ctx->Eval.MapGrid2u2 = 1.0; - ctx->Eval.MapGrid2v1 = 0.0; - ctx->Eval.MapGrid2v2 = 1.0; - - /* Evaluator data */ - { - static GLfloat vertex[4] = { 0.0, 0.0, 0.0, 1.0 }; - static GLfloat normal[3] = { 0.0, 0.0, 1.0 }; - static GLfloat index[1] = { 1.0 }; - static GLfloat color[4] = { 1.0, 1.0, 1.0, 1.0 }; - static GLfloat texcoord[4] = { 0.0, 0.0, 0.0, 1.0 }; - - init_1d_map( &ctx->EvalMap.Map1Vertex3, 3, vertex ); - init_1d_map( &ctx->EvalMap.Map1Vertex4, 4, vertex ); - init_1d_map( &ctx->EvalMap.Map1Index, 1, index ); - init_1d_map( &ctx->EvalMap.Map1Color4, 4, color ); - init_1d_map( &ctx->EvalMap.Map1Normal, 3, normal ); - init_1d_map( &ctx->EvalMap.Map1Texture1, 1, texcoord ); - init_1d_map( &ctx->EvalMap.Map1Texture2, 2, texcoord ); - init_1d_map( &ctx->EvalMap.Map1Texture3, 3, texcoord ); - init_1d_map( &ctx->EvalMap.Map1Texture4, 4, texcoord ); - - init_2d_map( &ctx->EvalMap.Map2Vertex3, 3, vertex ); - init_2d_map( &ctx->EvalMap.Map2Vertex4, 4, vertex ); - init_2d_map( &ctx->EvalMap.Map2Index, 1, index ); - init_2d_map( &ctx->EvalMap.Map2Color4, 4, color ); - init_2d_map( &ctx->EvalMap.Map2Normal, 3, normal ); - init_2d_map( &ctx->EvalMap.Map2Texture1, 1, texcoord ); - init_2d_map( &ctx->EvalMap.Map2Texture2, 2, texcoord ); - init_2d_map( &ctx->EvalMap.Map2Texture3, 3, texcoord ); - init_2d_map( &ctx->EvalMap.Map2Texture4, 4, texcoord ); - } -} - - -void _mesa_free_eval_data( struct gl_context *ctx ) -{ - /* Free evaluator data */ - if (ctx->EvalMap.Map1Vertex3.Points) - FREE( ctx->EvalMap.Map1Vertex3.Points ); - if (ctx->EvalMap.Map1Vertex4.Points) - FREE( ctx->EvalMap.Map1Vertex4.Points ); - if (ctx->EvalMap.Map1Index.Points) - FREE( ctx->EvalMap.Map1Index.Points ); - if (ctx->EvalMap.Map1Color4.Points) - FREE( ctx->EvalMap.Map1Color4.Points ); - if (ctx->EvalMap.Map1Normal.Points) - FREE( ctx->EvalMap.Map1Normal.Points ); - if (ctx->EvalMap.Map1Texture1.Points) - FREE( ctx->EvalMap.Map1Texture1.Points ); - if (ctx->EvalMap.Map1Texture2.Points) - FREE( ctx->EvalMap.Map1Texture2.Points ); - if (ctx->EvalMap.Map1Texture3.Points) - FREE( ctx->EvalMap.Map1Texture3.Points ); - if (ctx->EvalMap.Map1Texture4.Points) - FREE( ctx->EvalMap.Map1Texture4.Points ); - - if (ctx->EvalMap.Map2Vertex3.Points) - FREE( ctx->EvalMap.Map2Vertex3.Points ); - if (ctx->EvalMap.Map2Vertex4.Points) - FREE( ctx->EvalMap.Map2Vertex4.Points ); - if (ctx->EvalMap.Map2Index.Points) - FREE( ctx->EvalMap.Map2Index.Points ); - if (ctx->EvalMap.Map2Color4.Points) - FREE( ctx->EvalMap.Map2Color4.Points ); - if (ctx->EvalMap.Map2Normal.Points) - FREE( ctx->EvalMap.Map2Normal.Points ); - if (ctx->EvalMap.Map2Texture1.Points) - FREE( ctx->EvalMap.Map2Texture1.Points ); - if (ctx->EvalMap.Map2Texture2.Points) - FREE( ctx->EvalMap.Map2Texture2.Points ); - if (ctx->EvalMap.Map2Texture3.Points) - FREE( ctx->EvalMap.Map2Texture3.Points ); - if (ctx->EvalMap.Map2Texture4.Points) - FREE( ctx->EvalMap.Map2Texture4.Points ); -} diff --git a/dll/opengl/mesa/main/eval.h b/dll/opengl/mesa/main/eval.h deleted file mode 100644 index c07d4d53298..00000000000 --- a/dll/opengl/mesa/main/eval.h +++ /dev/null @@ -1,107 +0,0 @@ -/** - * \file eval.h - * Eval operations. - * - * \if subset - * (No-op) - * - * \endif - */ - -/* - * Mesa 3-D graphics library - * Version: 3.5 - * - * Copyright (C) 1999-2001 Brian Paul All Rights Reserved. - * - * Permission is hereby granted, free of charge, to any person obtaining a - * copy of this software and associated documentation files (the "Software"), - * to deal in the Software without restriction, including without limitation - * the rights to use, copy, modify, merge, publish, distribute, sublicense, - * and/or sell copies of the Software, and to permit persons to whom the - * Software is furnished to do so, subject to the following conditions: - * - * The above copyright notice and this permission notice shall be included - * in all copies or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS - * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL - * BRIAN PAUL BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN - * AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN - * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. - */ - - -#ifndef EVAL_H -#define EVAL_H - - -#include "main/mfeatures.h" -#include "main/mtypes.h" - - -#if FEATURE_evaluators - -#define _MESA_INIT_EVAL_VTXFMT(vfmt, impl) \ - do { \ - (vfmt)->EvalCoord1f = impl ## EvalCoord1f; \ - (vfmt)->EvalCoord1fv = impl ## EvalCoord1fv; \ - (vfmt)->EvalCoord2f = impl ## EvalCoord2f; \ - (vfmt)->EvalCoord2fv = impl ## EvalCoord2fv; \ - (vfmt)->EvalPoint1 = impl ## EvalPoint1; \ - (vfmt)->EvalPoint2 = impl ## EvalPoint2; \ - (vfmt)->EvalMesh1 = impl ## EvalMesh1; \ - (vfmt)->EvalMesh2 = impl ## EvalMesh2; \ - } while (0) - -extern GLuint _mesa_evaluator_components( GLenum target ); - - -extern GLfloat *_mesa_copy_map_points1f( GLenum target, - GLint ustride, GLint uorder, - const GLfloat *points ); - -extern GLfloat *_mesa_copy_map_points1d( GLenum target, - GLint ustride, GLint uorder, - const GLdouble *points ); - -extern GLfloat *_mesa_copy_map_points2f( GLenum target, - GLint ustride, GLint uorder, - GLint vstride, GLint vorder, - const GLfloat *points ); - -extern GLfloat *_mesa_copy_map_points2d(GLenum target, - GLint ustride, GLint uorder, - GLint vstride, GLint vorder, - const GLdouble *points ); - -extern void -_mesa_install_eval_vtxfmt(struct _glapi_table *disp, - const GLvertexformat *vfmt); - -extern void -_mesa_init_eval_dispatch(struct _glapi_table *disp); - -#else /* FEATURE_evaluators */ - -#define _MESA_INIT_EVAL_VTXFMT(vfmt, impl) do { } while (0) - -static inline void -_mesa_install_eval_vtxfmt(struct _glapi_table *disp, - const GLvertexformat *vfmt) -{ -} - -static inline void -_mesa_init_eval_dispatch(struct _glapi_table *disp) -{ -} - -#endif /* FEATURE_evaluators */ - -extern void _mesa_init_eval( struct gl_context *ctx ); -extern void _mesa_free_eval_data( struct gl_context *ctx ); - - -#endif /* EVAL_H */ diff --git a/dll/opengl/mesa/main/execmem.c b/dll/opengl/mesa/main/execmem.c deleted file mode 100644 index 4034bd27664..00000000000 --- a/dll/opengl/mesa/main/execmem.c +++ /dev/null @@ -1,149 +0,0 @@ -/* - * Mesa 3-D graphics library - * Version: 6.5 - * - * Copyright (C) 1999-2005 Brian Paul All Rights Reserved. - * - * Permission is hereby granted, free of charge, to any person obtaining a - * copy of this software and associated documentation files (the "Software"), - * to deal in the Software without restriction, including without limitation - * the rights to use, copy, modify, merge, publish, distribute, sublicense, - * and/or sell copies of the Software, and to permit persons to whom the - * Software is furnished to do so, subject to the following conditions: - * - * The above copyright notice and this permission notice shall be included - * in all copies or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS - * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL - * BRIAN PAUL BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN - * AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN - * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. - */ - - -/** - * \file execmem.c - * Functions for allocating executable memory. - * - * \author Keith Whitwell - */ - -#include - -#if defined(__linux__) || defined(__OpenBSD__) || defined(_NetBSD__) || defined(__sun) - -/* - * Allocate a large block of memory which can hold code then dole it out - * in pieces by means of the generic memory manager code. -*/ - -#include -#include - -#ifdef MESA_SELINUX -#include -#endif - - -#ifndef MAP_ANONYMOUS -#define MAP_ANONYMOUS MAP_ANON -#endif - - -#define EXEC_HEAP_SIZE (10*1024*1024) - -_glthread_DECLARE_STATIC_MUTEX(exec_mutex); - -static struct mem_block *exec_heap = NULL; -static unsigned char *exec_mem = NULL; - - -static int -init_heap(void) -{ -#ifdef MESA_SELINUX - if (is_selinux_enabled()) { - if (!security_get_boolean_active("allow_execmem") || - !security_get_boolean_pending("allow_execmem")) - return 0; - } -#endif - - if (!exec_heap) - exec_heap = mmInit( 0, EXEC_HEAP_SIZE ); - - if (!exec_mem) - exec_mem = mmap(NULL, EXEC_HEAP_SIZE, PROT_EXEC | PROT_READ | PROT_WRITE, - MAP_PRIVATE | MAP_ANONYMOUS, -1, 0); - - return (exec_mem != MAP_FAILED); -} - - -void * -_mesa_exec_malloc(GLuint size) -{ - struct mem_block *block = NULL; - void *addr = NULL; - - _glthread_LOCK_MUTEX(exec_mutex); - - if (!init_heap()) - goto bail; - - if (exec_heap) { - size = (size + 31) & ~31; - block = mmAllocMem( exec_heap, size, 32, 0 ); - } - - if (block) - addr = exec_mem + block->ofs; - else - printf("_mesa_exec_malloc failed\n"); - -bail: - _glthread_UNLOCK_MUTEX(exec_mutex); - - return addr; -} - - -void -_mesa_exec_free(void *addr) -{ - _glthread_LOCK_MUTEX(exec_mutex); - - if (exec_heap) { - struct mem_block *block = mmFindBlock(exec_heap, (unsigned char *)addr - exec_mem); - - if (block) - mmFreeMem(block); - } - - _glthread_UNLOCK_MUTEX(exec_mutex); -} - - -#else - -/* - * Just use regular memory. - */ - -void * -_mesa_exec_malloc(GLuint size) -{ - return malloc( size ); -} - - -void -_mesa_exec_free(void *addr) -{ - free(addr); -} - - -#endif diff --git a/dll/opengl/mesa/main/extensions.c b/dll/opengl/mesa/main/extensions.c deleted file mode 100644 index 9a933cd816f..00000000000 --- a/dll/opengl/mesa/main/extensions.c +++ /dev/null @@ -1,623 +0,0 @@ -/* - * Mesa 3-D graphics library - * Version: 7.6 - * - * Copyright (C) 1999-2008 Brian Paul All Rights Reserved. - * Copyright (C) 2009 VMware, Inc. All Rights Reserved. - * - * Permission is hereby granted, free of charge, to any person obtaining a - * copy of this software and associated documentation files (the "Software"), - * to deal in the Software without restriction, including without limitation - * the rights to use, copy, modify, merge, publish, distribute, sublicense, - * and/or sell copies of the Software, and to permit persons to whom the - * Software is furnished to do so, subject to the following conditions: - * - * The above copyright notice and this permission notice shall be included - * in all copies or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS - * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL - * BRIAN PAUL BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN - * AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN - * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. - */ - - -/** - * \file - * \brief Extension handling - */ - -#include - -#define ALIGN(value, alignment) (((value) + alignment - 1) & ~(alignment - 1)) - -/** - * \brief An element of the \c extension_table. - */ -struct extension { - /** Name of extension, such as "GL_ARB_depth_clamp". */ - const char *name; - - /** Offset (in bytes) of the corresponding member in struct gl_extensions. */ - size_t offset; - - /** Year the extension was proposed or approved. Used to sort the - * extension string chronologically. */ - uint16_t year; -}; - - -/** - * Given a member \c x of struct gl_extensions, return offset of - * \c x in bytes. - */ -#define o(x) offsetof(struct gl_extensions, x) - - -/** - * \brief Table of supported OpenGL extensions for all API's. - */ -static const struct extension extension_table[] = { - /* ARB Extensions */ - { "GL_ARB_map_buffer_range", o(ARB_map_buffer_range), 2008 }, - { "GL_ARB_multisample", o(dummy_true), 1994 }, - { "GL_ARB_point_parameters", o(EXT_point_parameters), 1997 }, - { "GL_ARB_point_sprite", o(ARB_point_sprite), 2003 }, - { "GL_ARB_texture_cube_map", o(ARB_texture_cube_map), 1999 }, - { "GL_ARB_texture_env_add", o(dummy_true), 1999 }, - { "GL_ARB_texture_env_combine", o(ARB_texture_env_combine), 2001 }, - { "GL_ARB_texture_env_crossbar", o(ARB_texture_env_crossbar), 2001 }, - { "GL_ARB_texture_env_dot3", o(ARB_texture_env_dot3), 2001 }, - { "GL_ARB_texture_mirrored_repeat", o(dummy_true), 2001 }, - { "GL_ARB_texture_storage", o(ARB_texture_storage), 2011 }, - { "GL_ARB_transpose_matrix", o(ARB_transpose_matrix), 1999 }, - { "GL_ARB_vertex_buffer_object", o(dummy_true), 2003 }, - { "GL_ARB_window_pos", o(ARB_window_pos), 2001 }, - /* EXT extensions */ - { "GL_EXT_abgr", o(dummy_true), 1995 }, - { "GL_EXT_bgra", o(dummy_true), 1995 }, - { "GL_EXT_blend_color", o(EXT_blend_color), 1995 }, - { "GL_EXT_blend_equation_separate", o(EXT_blend_equation_separate), 2003 }, - { "GL_EXT_blend_func_separate", o(EXT_blend_func_separate), 1999 }, - { "GL_EXT_blend_minmax", o(EXT_blend_minmax), 1995 }, - { "GL_EXT_blend_subtract", o(dummy_true), 1995 }, - { "GL_EXT_clip_volume_hint", o(EXT_clip_volume_hint), 1996 }, - { "GL_EXT_compiled_vertex_array", o(EXT_compiled_vertex_array), 1996 }, - { "GL_EXT_copy_texture", o(dummy_true), 1995 }, - { "GL_EXT_depth_bounds_test", o(EXT_depth_bounds_test), 2002 }, - { "GL_EXT_draw_range_elements", o(EXT_draw_range_elements), 1997 }, - { "GL_EXT_fog_coord", o(EXT_fog_coord), 1999 }, - { "GL_EXT_packed_pixels", o(EXT_packed_pixels), 1997 }, - { "GL_EXT_point_parameters", o(EXT_point_parameters), 1997 }, - { "GL_EXT_polygon_offset", o(dummy_true), 1995 }, - { "GL_EXT_rescale_normal", o(EXT_rescale_normal), 1997 }, - { "GL_EXT_secondary_color", o(EXT_secondary_color), 1999 }, - { "GL_EXT_separate_shader_objects", o(EXT_separate_shader_objects), 2008 }, - { "GL_EXT_separate_specular_color", o(EXT_separate_specular_color), 1997 }, - { "GL_EXT_shadow_funcs", o(EXT_shadow_funcs), 2002 }, - { "GL_EXT_stencil_wrap", o(dummy_true), 2002 }, - { "GL_EXT_subtexture", o(dummy_true), 1995 }, - { "GL_EXT_texture_cube_map", o(ARB_texture_cube_map), 2001 }, - { "GL_EXT_texture_env_add", o(dummy_true), 1999 }, - { "GL_EXT_texture_env_combine", o(dummy_true), 2000 }, - { "GL_EXT_texture_env_dot3", o(EXT_texture_env_dot3), 2000 }, - { "GL_EXT_texture_filter_anisotropic", o(EXT_texture_filter_anisotropic), 1999 }, - { "GL_EXT_texture_integer", o(EXT_texture_integer), 2006 }, - { "GL_EXT_texture_object", o(dummy_true), 1995 }, - { "GL_EXT_texture", o(dummy_true), 1996 }, - { "GL_EXT_vertex_array", o(dummy_true), 1995 }, - - /* Vendor extensions */ - { "GL_APPLE_packed_pixels", o(APPLE_packed_pixels), 2002 }, - { "GL_ATI_blend_equation_separate", o(EXT_blend_equation_separate), 2003 }, - { "GL_ATI_texture_env_combine3", o(ATI_texture_env_combine3), 2002 }, - { "GL_IBM_multimode_draw_arrays", o(IBM_multimode_draw_arrays), 1998 }, - { "GL_IBM_rasterpos_clip", o(IBM_rasterpos_clip), 1996 }, - { "GL_IBM_texture_mirrored_repeat", o(dummy_true), 1998 }, - { "GL_INGR_blend_func_separate", o(EXT_blend_func_separate), 1999 }, - { "GL_MESA_pack_invert", o(MESA_pack_invert), 2002 }, - { "GL_MESA_resize_buffers", o(MESA_resize_buffers), 1999 }, - { "GL_MESA_window_pos", o(ARB_window_pos), 2000 }, - { "GL_MESA_ycbcr_texture", o(MESA_ycbcr_texture), 2002 }, - { "GL_NV_blend_square", o(NV_blend_square), 1999 }, - { "GL_NV_fog_distance", o(NV_fog_distance), 2001 }, - { "GL_NV_light_max_exponent", o(NV_light_max_exponent), 1999 }, - { "GL_NV_point_sprite", o(NV_point_sprite), 2001 }, - { "GL_NV_texgen_reflection", o(NV_texgen_reflection), 1999 }, - { "GL_NV_texture_env_combine4", o(NV_texture_env_combine4), 1999 }, - - { 0, 0, 0}, -}; - - -/** - * Given an extension name, lookup up the corresponding member of struct - * gl_extensions and return that member's offset (in bytes). If the name is - * not found in the \c extension_table, return 0. - * - * \param name Name of extension. - * \return Offset of member in struct gl_extensions. - */ -static size_t -name_to_offset(const char* name) -{ - const struct extension *i; - - if (name == 0) - return 0; - - for (i = extension_table; i->name != 0; ++i) { - if (strcmp(name, i->name) == 0) - return i->offset; - } - - return 0; -} - - -/** - * \brief Extensions enabled by default. - * - * These extensions are enabled by _mesa_init_extensions(). - * - * XXX: Should these defaults also apply to GLES? - */ -static const size_t default_extensions[] = { - o(ARB_transpose_matrix), - o(ARB_window_pos), - - o(EXT_compiled_vertex_array), - o(EXT_draw_range_elements), - o(EXT_packed_pixels), - o(EXT_rescale_normal), - o(EXT_separate_specular_color), - - /* Vendor Extensions */ - o(APPLE_packed_pixels), - o(IBM_multimode_draw_arrays), - o(IBM_rasterpos_clip), - o(NV_light_max_exponent), - o(NV_texgen_reflection), - - 0, -}; - - -/** - * Enable all extensions suitable for a software-only renderer. - * This is a convenience function used by the XMesa, OSMesa, GGI drivers, etc. - */ -void -_mesa_enable_sw_extensions(struct gl_context *ctx) -{ - ctx->Extensions.ARB_map_buffer_range = GL_TRUE; - ctx->Extensions.ARB_point_sprite = GL_TRUE; - ctx->Extensions.ARB_texture_cube_map = GL_TRUE; - ctx->Extensions.ARB_texture_env_combine = GL_TRUE; - ctx->Extensions.ARB_texture_env_crossbar = GL_TRUE; - ctx->Extensions.ARB_texture_env_dot3 = GL_TRUE; - /*ctx->Extensions.ARB_texture_float = GL_TRUE;*/ - ctx->Extensions.ARB_texture_storage = GL_TRUE; - ctx->Extensions.ATI_texture_env_combine3 = GL_TRUE; - ctx->Extensions.EXT_blend_color = GL_TRUE; - ctx->Extensions.EXT_blend_equation_separate = GL_TRUE; - ctx->Extensions.EXT_blend_func_separate = GL_TRUE; - ctx->Extensions.EXT_blend_minmax = GL_TRUE; - ctx->Extensions.EXT_depth_bounds_test = GL_TRUE; - ctx->Extensions.EXT_fog_coord = GL_TRUE; - ctx->Extensions.EXT_point_parameters = GL_TRUE; - ctx->Extensions.EXT_shadow_funcs = GL_TRUE; - ctx->Extensions.EXT_secondary_color = GL_TRUE; - ctx->Extensions.EXT_texture_env_dot3 = GL_TRUE; - ctx->Extensions.EXT_texture_filter_anisotropic = GL_TRUE; - /*ctx->Extensions.IBM_multimode_draw_arrays = GL_TRUE;*/ - ctx->Extensions.MESA_pack_invert = GL_TRUE; - ctx->Extensions.MESA_resize_buffers = GL_TRUE; - ctx->Extensions.MESA_ycbcr_texture = GL_TRUE; - ctx->Extensions.NV_blend_square = GL_TRUE; - /*ctx->Extensions.NV_light_max_exponent = GL_TRUE;*/ - ctx->Extensions.NV_point_sprite = GL_TRUE; - ctx->Extensions.NV_texture_env_combine4 = GL_TRUE; - /*ctx->Extensions.NV_texgen_reflection = GL_TRUE;*/ -} - - -/** - * Enable all OpenGL 1.3 features and extensions. - * A convenience function to be called by drivers. - */ -void -_mesa_enable_1_3_extensions(struct gl_context *ctx) -{ - ctx->Extensions.ARB_texture_cube_map = GL_TRUE; - ctx->Extensions.ARB_texture_env_combine = GL_TRUE; - ctx->Extensions.ARB_texture_env_dot3 = GL_TRUE; - /*ctx->Extensions.ARB_transpose_matrix = GL_TRUE;*/ -} - - - -/** - * Enable all OpenGL 1.4 features and extensions. - * A convenience function to be called by drivers. - */ -void -_mesa_enable_1_4_extensions(struct gl_context *ctx) -{ - ctx->Extensions.ARB_texture_env_crossbar = GL_TRUE; - ctx->Extensions.ARB_window_pos = GL_TRUE; - ctx->Extensions.EXT_blend_color = GL_TRUE; - ctx->Extensions.EXT_blend_func_separate = GL_TRUE; - ctx->Extensions.EXT_blend_minmax = GL_TRUE; - ctx->Extensions.EXT_fog_coord = GL_TRUE; - ctx->Extensions.EXT_point_parameters = GL_TRUE; - ctx->Extensions.EXT_secondary_color = GL_TRUE; -} - - -/** - * Enable all OpenGL 1.5 features and extensions. - * A convenience function to be called by drivers. - */ -void -_mesa_enable_1_5_extensions(struct gl_context *ctx) -{ - ctx->Extensions.EXT_shadow_funcs = GL_TRUE; -} - - -/** - * Enable all OpenGL 2.0 features and extensions. - * A convenience function to be called by drivers. - */ -void -_mesa_enable_2_0_extensions(struct gl_context *ctx) -{ - ctx->Extensions.ARB_point_sprite = GL_TRUE; - ctx->Extensions.EXT_blend_equation_separate = GL_TRUE; -} - - -/** - * Enable all OpenGL 2.1 features and extensions. - * A convenience function to be called by drivers. - */ -void -_mesa_enable_2_1_extensions(struct gl_context *ctx) -{ -} - - -/** - * Either enable or disable the named extension. - * \return GL_TRUE for success, GL_FALSE if invalid extension name - */ -static GLboolean -set_extension( struct gl_context *ctx, const char *name, GLboolean state ) -{ - size_t offset; - - if (ctx->Extensions.String) { - /* The string was already queried - can't change it now! */ - _mesa_problem(ctx, "Trying to enable/disable extension after glGetString(GL_EXTENSIONS): %s", name); - return GL_FALSE; - } - - offset = name_to_offset(name); - if (offset == 0) { - _mesa_problem(ctx, "Trying to enable/disable unknown extension %s", - name); - return GL_FALSE; - } else if (offset == o(dummy_true) && state == GL_FALSE) { - _mesa_problem(ctx, "Trying to disable a permanently enabled extension: " - "%s", name); - return GL_FALSE; - } else { - GLboolean *base = (GLboolean *) &ctx->Extensions; - base[offset] = state; - return GL_TRUE; - } -} - - -/** - * Enable the named extension. - * Typically called by drivers. - */ -void -_mesa_enable_extension( struct gl_context *ctx, const char *name ) -{ - if (!set_extension(ctx, name, GL_TRUE)) - _mesa_problem(ctx, "Trying to enable unknown extension: %s", name); -} - - -/** - * Disable the named extension. - * XXX is this really needed??? - */ -void -_mesa_disable_extension( struct gl_context *ctx, const char *name ) -{ - if (!set_extension(ctx, name, GL_FALSE)) - _mesa_problem(ctx, "Trying to disable unknown extension: %s", name); -} - - -/** - * Test if the named extension is enabled in this context. - */ -GLboolean -_mesa_extension_is_enabled( struct gl_context *ctx, const char *name ) -{ - size_t offset; - GLboolean *base; - - if (name == 0) - return GL_FALSE; - - offset = name_to_offset(name); - if (offset == 0) - return GL_FALSE; - base = (GLboolean *) &ctx->Extensions; - return base[offset]; -} - - -/** - * \brief Apply the \c MESA_EXTENSION_OVERRIDE environment variable. - * - * \c MESA_EXTENSION_OVERRIDE is a space-separated list of extensions to - * enable or disable. The list is processed thus: - * - Enable recognized extension names that are prefixed with '+'. - * - Disable recognized extension names that are prefixed with '-'. - * - Enable recognized extension names that are not prefixed. - * - Collect unrecognized extension names in a new string. - * - * \return Space-separated list of unrecognized extension names (which must - * be freed). Does not return \c NULL. - */ -static char * -get_extension_override( struct gl_context *ctx ) -{ - const char *env_const = _mesa_getenv("MESA_EXTENSION_OVERRIDE"); - char *env; - char *ext; - char *extra_exts; - int len; - - if (env_const == NULL) { - /* Return the empty string rather than NULL. This simplifies the logic - * of client functions. */ - return calloc(4, sizeof(char)); - } - - /* extra_exts: List of unrecognized extensions. */ - extra_exts = calloc(ALIGN(strlen(env_const) + 2, 4), sizeof(char)); - - /* Copy env_const because strtok() is destructive. */ - env = _strdup(env_const); - for (ext = strtok(env, " "); ext != NULL; ext = strtok(NULL, " ")) { - int enable; - int recognized; - switch (ext[0]) { - case '+': - enable = 1; - ++ext; - break; - case '-': - enable = 0; - ++ext; - break; - default: - enable = 1; - break; - } - recognized = set_extension(ctx, ext, enable); - if (!recognized) { - strcat(extra_exts, ext); - strcat(extra_exts, " "); - } - } - - free(env); - - /* Remove trailing space. */ - len = strlen(extra_exts); - if (extra_exts[len - 1] == ' ') - extra_exts[len - 1] = '\0'; - - return extra_exts; -} - - -/** - * \brief Initialize extension tables and enable default extensions. - * - * This should be called during context initialization. - * Note: Sets gl_extensions.dummy_true to true. - */ -void -_mesa_init_extensions( struct gl_context *ctx ) -{ - GLboolean *base = (GLboolean *) &ctx->Extensions; - GLboolean *sentinel = base + o(extension_sentinel); - GLboolean *i; - const size_t *j; - - /* First, turn all extensions off. */ - for (i = base; i != sentinel; ++i) - *i = GL_FALSE; - - /* Then, selectively turn default extensions on. */ - ctx->Extensions.dummy_true = GL_TRUE; - for (j = default_extensions; *j != 0; ++j) - base[*j] = GL_TRUE; -} - - -typedef unsigned short extension_index; - - -/** - * Compare two entries of the extensions table. Sorts first by year, - * then by name. - * - * Arguments are indices into extension_table. - */ -static int -extension_compare(const void *p1, const void *p2) -{ - extension_index i1 = * (const extension_index *) p1; - extension_index i2 = * (const extension_index *) p2; - const struct extension *e1 = &extension_table[i1]; - const struct extension *e2 = &extension_table[i2]; - int res; - - res = (int)e1->year - (int)e2->year; - - if (res == 0) { - res = strcmp(e1->name, e2->name); - } - - return res; -} - - -/** - * Construct the GL_EXTENSIONS string. Called the first time that - * glGetString(GL_EXTENSIONS) is called. - */ -GLubyte* -_mesa_make_extension_string(struct gl_context *ctx) -{ - /* The extension string. */ - char *exts = 0; - /* Length of extension string. */ - size_t length = 0; - /* Number of extensions */ - unsigned count; - /* Indices of the extensions sorted by year */ - extension_index *extension_indices; - /* String of extra extensions. */ - char *extra_extensions = get_extension_override(ctx); - GLboolean *base = (GLboolean *) &ctx->Extensions; - const struct extension *i; - unsigned j; - unsigned maxYear = ~0; - - /* Check if the MESA_EXTENSION_MAX_YEAR env var is set */ - { - const char *env = getenv("MESA_EXTENSION_MAX_YEAR"); - if (env) { - maxYear = atoi(env); - _mesa_debug(ctx, "Note: limiting GL extensions to %u or earlier\n", - maxYear); - } - } - - /* Compute length of the extension string. */ - count = 0; - for (i = extension_table; i->name != 0; ++i) { - if (base[i->offset] && - i->year <= maxYear) { - length += strlen(i->name) + 1; /* +1 for space */ - ++count; - } - } - if (extra_extensions != NULL) - length += 1 + strlen(extra_extensions); /* +1 for space */ - - exts = (char *) calloc(ALIGN(length + 1, 4), sizeof(char)); - if (exts == NULL) { - free(extra_extensions); - return NULL; - } - - extension_indices = malloc(count * sizeof(extension_index)); - if (extension_indices == NULL) { - free(exts); - free(extra_extensions); - return NULL; - } - - /* Sort extensions in chronological order because certain old applications (e.g., - * Quake3 demo) store the extension list in a static size buffer so chronologically - * order ensure that the extensions that such applications expect will fit into - * that buffer. - */ - j = 0; - for (i = extension_table; i->name != 0; ++i) { - if (base[i->offset] && - i->year <= maxYear) { - extension_indices[j++] = i - extension_table; - } - } - assert(j == count); - qsort(extension_indices, count, sizeof *extension_indices, extension_compare); - - /* Build the extension string.*/ - for (j = 0; j < count; ++j) { - i = &extension_table[extension_indices[j]]; - assert(base[i->offset]); - strcat(exts, i->name); - strcat(exts, " "); - } - free(extension_indices); - if (extra_extensions != 0) { - strcat(exts, extra_extensions); - free(extra_extensions); - } - - return (GLubyte *) exts; -} - -/** - * Return number of enabled extensions. - */ -GLuint -_mesa_get_extension_count(struct gl_context *ctx) -{ - GLboolean *base; - const struct extension *i; - - /* only count once */ - if (ctx->Extensions.Count != 0) - return ctx->Extensions.Count; - - base = (GLboolean *) &ctx->Extensions; - for (i = extension_table; i->name != 0; ++i) { - if (base[i->offset]) { - ctx->Extensions.Count++; - } - } - return ctx->Extensions.Count; -} - -/** - * Return name of i-th enabled extension - */ -const GLubyte * -_mesa_get_enabled_extension(struct gl_context *ctx, GLuint index) -{ - const GLboolean *base; - size_t n; - const struct extension *i; - - if (index < 0) - return NULL; - - base = (GLboolean*) &ctx->Extensions; - n = 0; - for (i = extension_table; i->name != 0; ++i) { - if (n == index && base[i->offset]) { - return (GLubyte*) i->name; - } else if (base[i->offset]) { - ++n; - } - } - - return NULL; -} diff --git a/dll/opengl/mesa/main/extensions.h b/dll/opengl/mesa/main/extensions.h deleted file mode 100644 index 712c6e94da3..00000000000 --- a/dll/opengl/mesa/main/extensions.h +++ /dev/null @@ -1,91 +0,0 @@ -/** - * \file extensions.h - * Extension handling. - * - * \if subset - * (No-op) - * - * \endif - */ - -/* - * Mesa 3-D graphics library - * Version: 6.5.1 - * - * Copyright (C) 1999-2006 Brian Paul All Rights Reserved. - * - * Permission is hereby granted, free of charge, to any person obtaining a - * copy of this software and associated documentation files (the "Software"), - * to deal in the Software without restriction, including without limitation - * the rights to use, copy, modify, merge, publish, distribute, sublicense, - * and/or sell copies of the Software, and to permit persons to whom the - * Software is furnished to do so, subject to the following conditions: - * - * The above copyright notice and this permission notice shall be included - * in all copies or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS - * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL - * BRIAN PAUL BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN - * AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN - * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. - */ - - -#ifndef _EXTENSIONS_H_ -#define _EXTENSIONS_H_ - -#include "glheader.h" -#include "mfeatures.h" - -struct gl_context; - -#if _HAVE_FULL_GL - -extern void _mesa_enable_sw_extensions(struct gl_context *ctx); - -extern void _mesa_enable_1_3_extensions(struct gl_context *ctx); - -extern void _mesa_enable_1_4_extensions(struct gl_context *ctx); - -extern void _mesa_enable_1_5_extensions(struct gl_context *ctx); - -extern void _mesa_enable_2_0_extensions(struct gl_context *ctx); - -extern void _mesa_enable_2_1_extensions(struct gl_context *ctx); - -extern void _mesa_enable_extension(struct gl_context *ctx, const char *name); - -extern void _mesa_disable_extension(struct gl_context *ctx, const char *name); - -extern GLboolean _mesa_extension_is_enabled(struct gl_context *ctx, const char *name); - -extern void _mesa_init_extensions(struct gl_context *ctx); - -extern GLubyte *_mesa_make_extension_string(struct gl_context *ctx); - -extern GLuint -_mesa_get_extension_count(struct gl_context *ctx); - -extern const GLubyte * -_mesa_get_enabled_extension(struct gl_context *ctx, GLuint index); - - -#else - -/** No-op */ -#define _mesa_extensions_dtr( ctx ) ((void)0) - -/** No-op */ -#define _mesa_extensions_ctr( ctx ) ((void)0) - -/** No-op */ -#define _mesa_extensions_get_string( ctx ) "GL_EXT_texture_object" - -/** No-op */ -#define _mesa_enable_extension( c, n ) ((void)0) - -#endif - -#endif diff --git a/dll/opengl/mesa/main/feedback.c b/dll/opengl/mesa/main/feedback.c deleted file mode 100644 index 55a43c02be2..00000000000 --- a/dll/opengl/mesa/main/feedback.c +++ /dev/null @@ -1,537 +0,0 @@ -/* - * Mesa 3-D graphics library - * Version: 7.5 - * - * Copyright (C) 1999-2008 Brian Paul All Rights Reserved. - * Copyright (C) 2009 VMware, Inc. All Rights Reserved. - * - * Permission is hereby granted, free of charge, to any person obtaining a - * copy of this software and associated documentation files (the "Software"), - * to deal in the Software without restriction, including without limitation - * the rights to use, copy, modify, merge, publish, distribute, sublicense, - * and/or sell copies of the Software, and to permit persons to whom the - * Software is furnished to do so, subject to the following conditions: - * - * The above copyright notice and this permission notice shall be included - * in all copies or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS - * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL - * BRIAN PAUL BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN - * AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN - * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. - */ - -/** - * \file feedback.c - * Selection and feedback modes functions. - */ - -#include - -#if FEATURE_feedback - - -#define FB_3D 0x01 -#define FB_4D 0x02 -#define FB_COLOR 0x04 -#define FB_TEXTURE 0X08 - - - -static void GLAPIENTRY -_mesa_FeedbackBuffer( GLsizei size, GLenum type, GLfloat *buffer ) -{ - GET_CURRENT_CONTEXT(ctx); - ASSERT_OUTSIDE_BEGIN_END(ctx); - - if (ctx->RenderMode==GL_FEEDBACK) { - _mesa_error( ctx, GL_INVALID_OPERATION, "glFeedbackBuffer" ); - return; - } - if (size<0) { - _mesa_error( ctx, GL_INVALID_VALUE, "glFeedbackBuffer(size<0)" ); - return; - } - if (!buffer && size > 0) { - _mesa_error( ctx, GL_INVALID_VALUE, "glFeedbackBuffer(buffer==NULL)" ); - ctx->Feedback.BufferSize = 0; - return; - } - - switch (type) { - case GL_2D: - ctx->Feedback._Mask = 0; - break; - case GL_3D: - ctx->Feedback._Mask = FB_3D; - break; - case GL_3D_COLOR: - ctx->Feedback._Mask = (FB_3D | FB_COLOR); - break; - case GL_3D_COLOR_TEXTURE: - ctx->Feedback._Mask = (FB_3D | FB_COLOR | FB_TEXTURE); - break; - case GL_4D_COLOR_TEXTURE: - ctx->Feedback._Mask = (FB_3D | FB_4D | FB_COLOR | FB_TEXTURE); - break; - default: - _mesa_error( ctx, GL_INVALID_ENUM, "glFeedbackBuffer" ); - return; - } - - FLUSH_VERTICES(ctx, _NEW_RENDERMODE); /* Always flush */ - ctx->Feedback.Type = type; - ctx->Feedback.BufferSize = size; - ctx->Feedback.Buffer = buffer; - ctx->Feedback.Count = 0; /* Becaues of this. */ -} - - -static void GLAPIENTRY -_mesa_PassThrough( GLfloat token ) -{ - GET_CURRENT_CONTEXT(ctx); - ASSERT_OUTSIDE_BEGIN_END(ctx); - - if (ctx->RenderMode==GL_FEEDBACK) { - FLUSH_VERTICES(ctx, 0); - _mesa_feedback_token( ctx, (GLfloat) (GLint) GL_PASS_THROUGH_TOKEN ); - _mesa_feedback_token( ctx, token ); - } -} - - -/** - * Put a vertex into the feedback buffer. - */ -void -_mesa_feedback_vertex(struct gl_context *ctx, - const GLfloat win[4], - const GLfloat color[4], - const GLfloat texcoord[4]) -{ - _mesa_feedback_token( ctx, win[0] ); - _mesa_feedback_token( ctx, win[1] ); - if (ctx->Feedback._Mask & FB_3D) { - _mesa_feedback_token( ctx, win[2] ); - } - if (ctx->Feedback._Mask & FB_4D) { - _mesa_feedback_token( ctx, win[3] ); - } - if (ctx->Feedback._Mask & FB_COLOR) { - _mesa_feedback_token( ctx, color[0] ); - _mesa_feedback_token( ctx, color[1] ); - _mesa_feedback_token( ctx, color[2] ); - _mesa_feedback_token( ctx, color[3] ); - } - if (ctx->Feedback._Mask & FB_TEXTURE) { - _mesa_feedback_token( ctx, texcoord[0] ); - _mesa_feedback_token( ctx, texcoord[1] ); - _mesa_feedback_token( ctx, texcoord[2] ); - _mesa_feedback_token( ctx, texcoord[3] ); - } -} - - -/**********************************************************************/ -/** \name Selection */ -/*@{*/ - -/** - * Establish a buffer for selection mode values. - * - * \param size buffer size. - * \param buffer buffer. - * - * \sa glSelectBuffer(). - * - * \note this function can't be put in a display list. - * - * Verifies we're not in selection mode, flushes the vertices and initialize - * the fields in __struct gl_contextRec::Select with the given buffer. - */ -static void GLAPIENTRY -_mesa_SelectBuffer( GLsizei size, GLuint *buffer ) -{ - GET_CURRENT_CONTEXT(ctx); - ASSERT_OUTSIDE_BEGIN_END(ctx); - - if (size < 0) { - _mesa_error(ctx, GL_INVALID_VALUE, "glSelectBuffer(size)"); - return; - } - - if (ctx->RenderMode==GL_SELECT) { - _mesa_error( ctx, GL_INVALID_OPERATION, "glSelectBuffer" ); - return; /* KW: added return */ - } - - FLUSH_VERTICES(ctx, _NEW_RENDERMODE); - ctx->Select.Buffer = buffer; - ctx->Select.BufferSize = size; - ctx->Select.BufferCount = 0; - ctx->Select.HitFlag = GL_FALSE; - ctx->Select.HitMinZ = 1.0; - ctx->Select.HitMaxZ = 0.0; -} - - -/** - * Write a value of a record into the selection buffer. - * - * \param ctx GL context. - * \param value value. - * - * Verifies there is free space in the buffer to write the value and - * increments the pointer. - */ -static inline void -write_record(struct gl_context *ctx, GLuint value) -{ - if (ctx->Select.BufferCount < ctx->Select.BufferSize) { - ctx->Select.Buffer[ctx->Select.BufferCount] = value; - } - ctx->Select.BufferCount++; -} - - -/** - * Update the hit flag and the maximum and minimum depth values. - * - * \param ctx GL context. - * \param z depth. - * - * Sets gl_selection::HitFlag and updates gl_selection::HitMinZ and - * gl_selection::HitMaxZ. - */ -void -_mesa_update_hitflag(struct gl_context *ctx, GLfloat z) -{ - ctx->Select.HitFlag = GL_TRUE; - if (z < ctx->Select.HitMinZ) { - ctx->Select.HitMinZ = z; - } - if (z > ctx->Select.HitMaxZ) { - ctx->Select.HitMaxZ = z; - } -} - - -/** - * Write the hit record. - * - * \param ctx GL context. - * - * Write the hit record, i.e., the number of names in the stack, the minimum and - * maximum depth values and the number of names in the name stack at the time - * of the event. Resets the hit flag. - * - * \sa gl_selection. - */ -static void -write_hit_record(struct gl_context *ctx) -{ - GLuint i; - GLuint zmin, zmax, zscale = (~0u); - - /* HitMinZ and HitMaxZ are in [0,1]. Multiply these values by */ - /* 2^32-1 and round to nearest unsigned integer. */ - - assert( ctx != NULL ); /* this line magically fixes a SunOS 5.x/gcc bug */ - zmin = (GLuint) ((GLfloat) zscale * ctx->Select.HitMinZ); - zmax = (GLuint) ((GLfloat) zscale * ctx->Select.HitMaxZ); - - write_record( ctx, ctx->Select.NameStackDepth ); - write_record( ctx, zmin ); - write_record( ctx, zmax ); - for (i = 0; i < ctx->Select.NameStackDepth; i++) { - write_record( ctx, ctx->Select.NameStack[i] ); - } - - ctx->Select.Hits++; - ctx->Select.HitFlag = GL_FALSE; - ctx->Select.HitMinZ = 1.0; - ctx->Select.HitMaxZ = -1.0; -} - - -/** - * Initialize the name stack. - * - * Verifies we are in select mode and resets the name stack depth and resets - * the hit record data in gl_selection. Marks new render mode in - * __struct gl_contextRec::NewState. - */ -static void GLAPIENTRY -_mesa_InitNames( void ) -{ - GET_CURRENT_CONTEXT(ctx); - ASSERT_OUTSIDE_BEGIN_END_AND_FLUSH(ctx); - - /* Record the hit before the HitFlag is wiped out again. */ - if (ctx->RenderMode == GL_SELECT) { - if (ctx->Select.HitFlag) { - write_hit_record( ctx ); - } - } - ctx->Select.NameStackDepth = 0; - ctx->Select.HitFlag = GL_FALSE; - ctx->Select.HitMinZ = 1.0; - ctx->Select.HitMaxZ = 0.0; - ctx->NewState |= _NEW_RENDERMODE; -} - - -/** - * Load the top-most name of the name stack. - * - * \param name name. - * - * Verifies we are in selection mode and that the name stack is not empty. - * Flushes vertices. If there is a hit flag writes it (via write_hit_record()), - * and replace the top-most name in the stack. - * - * sa __struct gl_contextRec::Select. - */ -static void GLAPIENTRY -_mesa_LoadName( GLuint name ) -{ - GET_CURRENT_CONTEXT(ctx); - ASSERT_OUTSIDE_BEGIN_END(ctx); - - if (ctx->RenderMode != GL_SELECT) { - return; - } - if (ctx->Select.NameStackDepth == 0) { - _mesa_error( ctx, GL_INVALID_OPERATION, "glLoadName" ); - return; - } - - FLUSH_VERTICES(ctx, _NEW_RENDERMODE); - - if (ctx->Select.HitFlag) { - write_hit_record( ctx ); - } - if (ctx->Select.NameStackDepth < MAX_NAME_STACK_DEPTH) { - ctx->Select.NameStack[ctx->Select.NameStackDepth-1] = name; - } - else { - ctx->Select.NameStack[MAX_NAME_STACK_DEPTH-1] = name; - } -} - - -/** - * Push a name into the name stack. - * - * \param name name. - * - * Verifies we are in selection mode and that the name stack is not full. - * Flushes vertices. If there is a hit flag writes it (via write_hit_record()), - * and adds the name to the top of the name stack. - * - * sa __struct gl_contextRec::Select. - */ -static void GLAPIENTRY -_mesa_PushName( GLuint name ) -{ - GET_CURRENT_CONTEXT(ctx); - ASSERT_OUTSIDE_BEGIN_END(ctx); - - if (ctx->RenderMode != GL_SELECT) { - return; - } - - FLUSH_VERTICES(ctx, _NEW_RENDERMODE); - if (ctx->Select.HitFlag) { - write_hit_record( ctx ); - } - if (ctx->Select.NameStackDepth >= MAX_NAME_STACK_DEPTH) { - _mesa_error( ctx, GL_STACK_OVERFLOW, "glPushName" ); - } - else - ctx->Select.NameStack[ctx->Select.NameStackDepth++] = name; -} - - -/** - * Pop a name into the name stack. - * - * Verifies we are in selection mode and that the name stack is not empty. - * Flushes vertices. If there is a hit flag writes it (via write_hit_record()), - * and removes top-most name in the name stack. - * - * sa __struct gl_contextRec::Select. - */ -static void GLAPIENTRY -_mesa_PopName( void ) -{ - GET_CURRENT_CONTEXT(ctx); - ASSERT_OUTSIDE_BEGIN_END(ctx); - - if (ctx->RenderMode != GL_SELECT) { - return; - } - - FLUSH_VERTICES(ctx, _NEW_RENDERMODE); - if (ctx->Select.HitFlag) { - write_hit_record( ctx ); - } - if (ctx->Select.NameStackDepth == 0) { - _mesa_error( ctx, GL_STACK_UNDERFLOW, "glPopName" ); - } - else - ctx->Select.NameStackDepth--; -} - -/*@}*/ - - -/**********************************************************************/ -/** \name Render Mode */ -/*@{*/ - -/** - * Set rasterization mode. - * - * \param mode rasterization mode. - * - * \note this function can't be put in a display list. - * - * \sa glRenderMode(). - * - * Flushes the vertices and do the necessary cleanup according to the previous - * rasterization mode, such as writing the hit record or resent the select - * buffer index when exiting the select mode. Updates - * __struct gl_contextRec::RenderMode and notifies the driver via the - * dd_function_table::RenderMode callback. - */ -GLint GLAPIENTRY -_mesa_RenderMode( GLenum mode ) -{ - GET_CURRENT_CONTEXT(ctx); - GLint result; - ASSERT_OUTSIDE_BEGIN_END_WITH_RETVAL(ctx, 0); - - if (MESA_VERBOSE & VERBOSE_API) - _mesa_debug(ctx, "glRenderMode %s\n", _mesa_lookup_enum_by_nr(mode)); - - FLUSH_VERTICES(ctx, _NEW_RENDERMODE); - - switch (ctx->RenderMode) { - case GL_RENDER: - result = 0; - break; - case GL_SELECT: - if (ctx->Select.HitFlag) { - write_hit_record( ctx ); - } - if (ctx->Select.BufferCount > ctx->Select.BufferSize) { - /* overflow */ -#ifdef DEBUG - _mesa_warning(ctx, "Feedback buffer overflow"); -#endif - result = -1; - } - else { - result = ctx->Select.Hits; - } - ctx->Select.BufferCount = 0; - ctx->Select.Hits = 0; - ctx->Select.NameStackDepth = 0; - break; -#if _HAVE_FULL_GL - case GL_FEEDBACK: - if (ctx->Feedback.Count > ctx->Feedback.BufferSize) { - /* overflow */ - result = -1; - } - else { - result = ctx->Feedback.Count; - } - ctx->Feedback.Count = 0; - break; -#endif - default: - _mesa_error( ctx, GL_INVALID_ENUM, "glRenderMode" ); - return 0; - } - - switch (mode) { - case GL_RENDER: - break; - case GL_SELECT: - if (ctx->Select.BufferSize==0) { - /* haven't called glSelectBuffer yet */ - _mesa_error( ctx, GL_INVALID_OPERATION, "glRenderMode" ); - } - break; -#if _HAVE_FULL_GL - case GL_FEEDBACK: - if (ctx->Feedback.BufferSize==0) { - /* haven't called glFeedbackBuffer yet */ - _mesa_error( ctx, GL_INVALID_OPERATION, "glRenderMode" ); - } - break; -#endif - default: - _mesa_error( ctx, GL_INVALID_ENUM, "glRenderMode" ); - return 0; - } - - ctx->RenderMode = mode; - if (ctx->Driver.RenderMode) - ctx->Driver.RenderMode( ctx, mode ); - - return result; -} - -/*@}*/ - - -void -_mesa_init_feedback_dispatch(struct _glapi_table *disp) -{ - SET_InitNames(disp, _mesa_InitNames); - SET_FeedbackBuffer(disp, _mesa_FeedbackBuffer); - SET_LoadName(disp, _mesa_LoadName); - SET_PassThrough(disp, _mesa_PassThrough); - SET_PopName(disp, _mesa_PopName); - SET_PushName(disp, _mesa_PushName); - SET_SelectBuffer(disp, _mesa_SelectBuffer); - SET_RenderMode(disp, _mesa_RenderMode); -} - - -#endif /* FEATURE_feedback */ - - -/**********************************************************************/ -/** \name Initialization */ -/*@{*/ - -/** - * Initialize context feedback data. - */ -void _mesa_init_feedback( struct gl_context * ctx ) -{ - /* Feedback */ - ctx->Feedback.Type = GL_2D; /* TODO: verify */ - ctx->Feedback.Buffer = NULL; - ctx->Feedback.BufferSize = 0; - ctx->Feedback.Count = 0; - - /* Selection/picking */ - ctx->Select.Buffer = NULL; - ctx->Select.BufferSize = 0; - ctx->Select.BufferCount = 0; - ctx->Select.Hits = 0; - ctx->Select.NameStackDepth = 0; - - /* Miscellaneous */ - ctx->RenderMode = GL_RENDER; -} - -/*@}*/ diff --git a/dll/opengl/mesa/main/feedback.h b/dll/opengl/mesa/main/feedback.h deleted file mode 100644 index c64db31344a..00000000000 --- a/dll/opengl/mesa/main/feedback.h +++ /dev/null @@ -1,102 +0,0 @@ -/* - * Mesa 3-D graphics library - * Version: 7.5 - * - * Copyright (C) 1999-2008 Brian Paul All Rights Reserved. - * Copyright (C) 2009 VMware, Inc. All Rights Reserved. - * - * Permission is hereby granted, free of charge, to any person obtaining a - * copy of this software and associated documentation files (the "Software"), - * to deal in the Software without restriction, including without limitation - * the rights to use, copy, modify, merge, publish, distribute, sublicense, - * and/or sell copies of the Software, and to permit persons to whom the - * Software is furnished to do so, subject to the following conditions: - * - * The above copyright notice and this permission notice shall be included - * in all copies or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS - * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL - * BRIAN PAUL BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN - * AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN - * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. - */ - -#ifndef FEEDBACK_H -#define FEEDBACK_H - - -#include "main/mfeatures.h" -#include "main/mtypes.h" - - -#if FEATURE_feedback - -extern GLint GLAPIENTRY -_mesa_RenderMode( GLenum mode ); - -extern void -_mesa_feedback_vertex( struct gl_context *ctx, - const GLfloat win[4], - const GLfloat color[4], - const GLfloat texcoord[4] ); - - -static inline void -_mesa_feedback_token( struct gl_context *ctx, GLfloat token ) -{ - if (ctx->Feedback.Count < ctx->Feedback.BufferSize) { - ctx->Feedback.Buffer[ctx->Feedback.Count] = token; - } - ctx->Feedback.Count++; -} - - -extern void -_mesa_update_hitflag( struct gl_context *ctx, GLfloat z ); - - -extern void -_mesa_init_feedback_dispatch(struct _glapi_table *disp); - -#else /* FEATURE_feedback */ - -#include "main/compiler.h" - -static inline void -_mesa_feedback_vertex( struct gl_context *ctx, - const GLfloat win[4], - const GLfloat color[4], - const GLfloat texcoord[4] ) -{ - /* render mode is always GL_RENDER */ - ASSERT_NO_FEATURE(); -} - - -static inline void -_mesa_feedback_token( struct gl_context *ctx, GLfloat token ) -{ - /* render mode is always GL_RENDER */ - ASSERT_NO_FEATURE(); -} - -static inline void -_mesa_update_hitflag( struct gl_context *ctx, GLfloat z ) -{ - /* render mode is always GL_RENDER */ - ASSERT_NO_FEATURE(); -} - -static inline void -_mesa_init_feedback_dispatch(struct _glapi_table *disp) -{ -} - -#endif /* FEATURE_feedback */ - -extern void -_mesa_init_feedback( struct gl_context *ctx ); - -#endif /* FEEDBACK_H */ diff --git a/dll/opengl/mesa/main/fog.c b/dll/opengl/mesa/main/fog.c deleted file mode 100644 index b2e141b60af..00000000000 --- a/dll/opengl/mesa/main/fog.c +++ /dev/null @@ -1,204 +0,0 @@ -/* - * Mesa 3-D graphics library - * Version: 5.1 - * - * Copyright (C) 1999-2003 Brian Paul All Rights Reserved. - * - * Permission is hereby granted, free of charge, to any person obtaining a - * copy of this software and associated documentation files (the "Software"), - * to deal in the Software without restriction, including without limitation - * the rights to use, copy, modify, merge, publish, distribute, sublicense, - * and/or sell copies of the Software, and to permit persons to whom the - * Software is furnished to do so, subject to the following conditions: - * - * The above copyright notice and this permission notice shall be included - * in all copies or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS - * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL - * BRIAN PAUL BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN - * AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN - * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. - */ - -#include - -void GLAPIENTRY -_mesa_Fogf(GLenum pname, GLfloat param) -{ - GLfloat fparam[4]; - fparam[0] = param; - fparam[1] = fparam[2] = fparam[3] = 0.0F; - _mesa_Fogfv(pname, fparam); -} - - -void GLAPIENTRY -_mesa_Fogi(GLenum pname, GLint param ) -{ - GLfloat fparam[4]; - fparam[0] = (GLfloat) param; - fparam[1] = fparam[2] = fparam[3] = 0.0F; - _mesa_Fogfv(pname, fparam); -} - - -void GLAPIENTRY -_mesa_Fogiv(GLenum pname, const GLint *params ) -{ - GLfloat p[4]; - switch (pname) { - case GL_FOG_MODE: - case GL_FOG_DENSITY: - case GL_FOG_START: - case GL_FOG_END: - case GL_FOG_INDEX: - case GL_FOG_COORDINATE_SOURCE_EXT: - p[0] = (GLfloat) *params; - break; - case GL_FOG_COLOR: - p[0] = INT_TO_FLOAT( params[0] ); - p[1] = INT_TO_FLOAT( params[1] ); - p[2] = INT_TO_FLOAT( params[2] ); - p[3] = INT_TO_FLOAT( params[3] ); - break; - default: - /* Error will be caught later in _mesa_Fogfv */ - ASSIGN_4V(p, 0.0F, 0.0F, 0.0F, 0.0F); - } - _mesa_Fogfv(pname, p); -} - - -/** - * Update the gl_fog_attrib::_Scale field. - */ -static void -update_fog_scale(struct gl_context *ctx) -{ - if (ctx->Fog.End == ctx->Fog.Start) - ctx->Fog._Scale = 1.0f; - else - ctx->Fog._Scale = 1.0f / (ctx->Fog.End - ctx->Fog.Start); -} - - -void GLAPIENTRY -_mesa_Fogfv( GLenum pname, const GLfloat *params ) -{ - GET_CURRENT_CONTEXT(ctx); - GLenum m; - ASSERT_OUTSIDE_BEGIN_END(ctx); - - switch (pname) { - case GL_FOG_MODE: - m = (GLenum) (GLint) *params; - switch (m) { - case GL_LINEAR: - case GL_EXP: - case GL_EXP2: - break; - default: - _mesa_error( ctx, GL_INVALID_ENUM, "glFog" ); - return; - } - if (ctx->Fog.Mode == m) - return; - FLUSH_VERTICES(ctx, _NEW_FOG); - ctx->Fog.Mode = m; - break; - case GL_FOG_DENSITY: - if (*params<0.0) { - _mesa_error( ctx, GL_INVALID_VALUE, "glFog" ); - return; - } - if (ctx->Fog.Density == *params) - return; - FLUSH_VERTICES(ctx, _NEW_FOG); - ctx->Fog.Density = *params; - break; - case GL_FOG_START: - if (ctx->Fog.Start == *params) - return; - FLUSH_VERTICES(ctx, _NEW_FOG); - ctx->Fog.Start = *params; - update_fog_scale(ctx); - break; - case GL_FOG_END: - if (ctx->Fog.End == *params) - return; - FLUSH_VERTICES(ctx, _NEW_FOG); - ctx->Fog.End = *params; - update_fog_scale(ctx); - break; - case GL_FOG_INDEX: - if (ctx->Fog.Index == *params) - return; - FLUSH_VERTICES(ctx, _NEW_FOG); - ctx->Fog.Index = *params; - break; - case GL_FOG_COLOR: - if (TEST_EQ_4V(ctx->Fog.Color, params)) - return; - FLUSH_VERTICES(ctx, _NEW_FOG); - ctx->Fog.Color[0] = params[0]; - ctx->Fog.Color[1] = params[1]; - ctx->Fog.Color[2] = params[2]; - ctx->Fog.Color[3] = params[3]; - break; - case GL_FOG_COORDINATE_SOURCE_EXT: { - GLenum p = (GLenum) (GLint) *params; - if (!ctx->Extensions.EXT_fog_coord || - (p != GL_FOG_COORDINATE_EXT && p != GL_FRAGMENT_DEPTH_EXT)) { - _mesa_error(ctx, GL_INVALID_ENUM, "glFog"); - return; - } - if (ctx->Fog.FogCoordinateSource == p) - return; - FLUSH_VERTICES(ctx, _NEW_FOG); - ctx->Fog.FogCoordinateSource = p; - break; - } - case GL_FOG_DISTANCE_MODE_NV: { - GLenum p = (GLenum) (GLint) *params; - if (!ctx->Extensions.NV_fog_distance || - (p != GL_EYE_RADIAL_NV && p != GL_EYE_PLANE && p != GL_EYE_PLANE_ABSOLUTE_NV)) { - _mesa_error(ctx, GL_INVALID_ENUM, "glFog"); - return; - } - if (ctx->Fog.FogDistanceMode == p) - return; - FLUSH_VERTICES(ctx, _NEW_FOG); - ctx->Fog.FogDistanceMode = p; - break; - } - default: - _mesa_error( ctx, GL_INVALID_ENUM, "glFog" ); - return; - } - - if (ctx->Driver.Fogfv) { - (*ctx->Driver.Fogfv)( ctx, pname, params ); - } -} - - -/**********************************************************************/ -/***** Initialization *****/ -/**********************************************************************/ - -void _mesa_init_fog( struct gl_context * ctx ) -{ - /* Fog group */ - ctx->Fog.Enabled = GL_FALSE; - ctx->Fog.Mode = GL_EXP; - ASSIGN_4V( ctx->Fog.Color, 0.0, 0.0, 0.0, 0.0 ); - ctx->Fog.Index = 0.0; - ctx->Fog.Density = 1.0; - ctx->Fog.Start = 0.0; - ctx->Fog.End = 1.0; - ctx->Fog.FogCoordinateSource = GL_FRAGMENT_DEPTH_EXT; - ctx->Fog._Scale = 1.0f; - ctx->Fog.FogDistanceMode = GL_EYE_PLANE_ABSOLUTE_NV; -} diff --git a/dll/opengl/mesa/main/fog.h b/dll/opengl/mesa/main/fog.h deleted file mode 100644 index 9191a4a54cc..00000000000 --- a/dll/opengl/mesa/main/fog.h +++ /dev/null @@ -1,69 +0,0 @@ -/** - * \file fog.h - * Fog operations. - * - * \if subset - * (No-op) - * - * \endif - */ - -/* - * Mesa 3-D graphics library - * Version: 3.5 - * - * Copyright (C) 1999-2001 Brian Paul All Rights Reserved. - * - * Permission is hereby granted, free of charge, to any person obtaining a - * copy of this software and associated documentation files (the "Software"), - * to deal in the Software without restriction, including without limitation - * the rights to use, copy, modify, merge, publish, distribute, sublicense, - * and/or sell copies of the Software, and to permit persons to whom the - * Software is furnished to do so, subject to the following conditions: - * - * The above copyright notice and this permission notice shall be included - * in all copies or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS - * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL - * BRIAN PAUL BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN - * AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN - * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. - */ - - -#ifndef FOG_H -#define FOG_H - - -#include "glheader.h" -#include "mfeatures.h" - -struct gl_context; - - -#if _HAVE_FULL_GL - -extern void GLAPIENTRY -_mesa_Fogf(GLenum pname, GLfloat param); - -extern void GLAPIENTRY -_mesa_Fogi(GLenum pname, GLint param ); - -extern void GLAPIENTRY -_mesa_Fogfv(GLenum pname, const GLfloat *params ); - -extern void GLAPIENTRY -_mesa_Fogiv(GLenum pname, const GLint *params ); - -extern void _mesa_init_fog( struct gl_context * ctx ); - -#else - -/** No-op */ -#define _mesa_init_fog( c ) ((void)0) - -#endif - -#endif diff --git a/dll/opengl/mesa/main/format_pack.c b/dll/opengl/mesa/main/format_pack.c deleted file mode 100644 index 3842289068b..00000000000 --- a/dll/opengl/mesa/main/format_pack.c +++ /dev/null @@ -1,1461 +0,0 @@ -/* - * Mesa 3-D graphics library - * - * Copyright (c) 2011 VMware, Inc. - * - * Permission is hereby granted, free of charge, to any person obtaining a - * copy of this software and associated documentation files (the "Software"), - * to deal in the Software without restriction, including without limitation - * the rights to use, copy, modify, merge, publish, distribute, sublicense, - * and/or sell copies of the Software, and to permit persons to whom the - * Software is furnished to do so, subject to the following conditions: - * - * The above copyright notice and this permission notice shall be included - * in all copies or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS - * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL - * THE AUTHORS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN - * AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN - * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. - */ - - -/** - * Color, depth, stencil packing functions. - * Used to pack basic color, depth and stencil formats to specific - * hardware formats. - * - * There are both per-pixel and per-row packing functions: - * - The former will be used by swrast to write values to the color, depth, - * stencil buffers when drawing points, lines and masked spans. - * - The later will be used for image-oriented functions like glDrawPixels, - * glAccum, and glTexImage. - */ - -#include - -typedef void (*pack_ubyte_rgba_row_func)(GLuint n, - const GLubyte src[][4], void *dst); - -typedef void (*pack_float_rgba_row_func)(GLuint n, - const GLfloat src[][4], void *dst); - -/* - * MESA_FORMAT_RGBA8888 - */ - -static void -pack_ubyte_RGBA8888(const GLubyte src[4], void *dst) -{ - GLuint *d = ((GLuint *) dst); - *d = PACK_COLOR_8888(src[RCOMP], src[GCOMP], src[BCOMP], src[ACOMP]); -} - -static void -pack_float_RGBA8888(const GLfloat src[4], void *dst) -{ - GLubyte v[4]; - _mesa_unclamped_float_rgba_to_ubyte(v, src); - pack_ubyte_RGBA8888(v, dst); -} - -static void -pack_row_ubyte_RGBA8888(GLuint n, const GLubyte src[][4], void *dst) -{ - GLuint *d = ((GLuint *) dst); - GLuint i; - for (i = 0; i < n; i++) { - d[i] = PACK_COLOR_8888(src[i][RCOMP], src[i][GCOMP], - src[i][BCOMP], src[i][ACOMP]); - } -} - -static void -pack_row_float_RGBA8888(GLuint n, const GLfloat src[][4], void *dst) -{ - GLuint *d = ((GLuint *) dst); - GLuint i; - for (i = 0; i < n; i++) { - GLubyte v[4]; - _mesa_unclamped_float_rgba_to_ubyte(v, src[i]); - pack_ubyte_RGBA8888(v, d + i); - } -} - - - -/* - * MESA_FORMAT_RGBA8888_REV - */ - -static void -pack_ubyte_RGBA8888_REV(const GLubyte src[4], void *dst) -{ - GLuint *d = ((GLuint *) dst); - *d = PACK_COLOR_8888(src[ACOMP], src[BCOMP], src[GCOMP], src[RCOMP]); -} - -static void -pack_float_RGBA8888_REV(const GLfloat src[4], void *dst) -{ - GLubyte v[4]; - _mesa_unclamped_float_rgba_to_ubyte(v, src); - pack_ubyte_RGBA8888_REV(v, dst); -} - -static void -pack_row_ubyte_RGBA8888_REV(GLuint n, const GLubyte src[][4], void *dst) -{ - GLuint *d = ((GLuint *) dst); - GLuint i; - for (i = 0; i < n; i++) { - d[i] = PACK_COLOR_8888(src[i][ACOMP], src[i][BCOMP], - src[i][GCOMP], src[i][RCOMP]); - } -} - -static void -pack_row_float_RGBA8888_REV(GLuint n, const GLfloat src[][4], void *dst) -{ - GLuint *d = ((GLuint *) dst); - GLuint i; - for (i = 0; i < n; i++) { - GLubyte v[4]; - _mesa_unclamped_float_rgba_to_ubyte(v, src[i]); - pack_ubyte_RGBA8888_REV(v, d + i); - } -} - - -/* - * MESA_FORMAT_ARGB8888 - */ - -static void -pack_ubyte_ARGB8888(const GLubyte src[4], void *dst) -{ - GLuint *d = ((GLuint *) dst); - *d = PACK_COLOR_8888(src[ACOMP], src[RCOMP], src[GCOMP], src[BCOMP]); -} - -static void -pack_float_ARGB8888(const GLfloat src[4], void *dst) -{ - GLubyte v[4]; - _mesa_unclamped_float_rgba_to_ubyte(v, src); - pack_ubyte_ARGB8888(v, dst); -} - -static void -pack_row_ubyte_ARGB8888(GLuint n, const GLubyte src[][4], void *dst) -{ - GLuint *d = ((GLuint *) dst); - GLuint i; - for (i = 0; i < n; i++) { - d[i] = PACK_COLOR_8888(src[i][ACOMP], src[i][RCOMP], - src[i][GCOMP], src[i][BCOMP]); - } -} - -static void -pack_row_float_ARGB8888(GLuint n, const GLfloat src[][4], void *dst) -{ - GLuint *d = ((GLuint *) dst); - GLuint i; - for (i = 0; i < n; i++) { - GLubyte v[4]; - _mesa_unclamped_float_rgba_to_ubyte(v, src[i]); - pack_ubyte_ARGB8888(v, d + i); - } -} - - -/* - * MESA_FORMAT_ARGB8888_REV - */ - -static void -pack_ubyte_ARGB8888_REV(const GLubyte src[4], void *dst) -{ - GLuint *d = ((GLuint *) dst); - *d = PACK_COLOR_8888(src[BCOMP], src[GCOMP], src[RCOMP], src[ACOMP]); -} - -static void -pack_float_ARGB8888_REV(const GLfloat src[4], void *dst) -{ - GLubyte v[4]; - _mesa_unclamped_float_rgba_to_ubyte(v, src); - pack_ubyte_ARGB8888_REV(v, dst); -} - -static void -pack_row_ubyte_ARGB8888_REV(GLuint n, const GLubyte src[][4], void *dst) -{ - GLuint *d = ((GLuint *) dst); - GLuint i; - for (i = 0; i < n; i++) { - d[i] = PACK_COLOR_8888(src[i][BCOMP], src[i][GCOMP], - src[i][RCOMP], src[i][ACOMP]); - } -} - -static void -pack_row_float_ARGB8888_REV(GLuint n, const GLfloat src[][4], void *dst) -{ - GLuint *d = ((GLuint *) dst); - GLuint i; - for (i = 0; i < n; i++) { - GLubyte v[4]; - _mesa_unclamped_float_rgba_to_ubyte(v, src[i]); - pack_ubyte_ARGB8888_REV(v, d + i); - } -} - - -/* - * MESA_FORMAT_XRGB8888 - */ - -static void -pack_ubyte_XRGB8888(const GLubyte src[4], void *dst) -{ - GLuint *d = ((GLuint *) dst); - *d = PACK_COLOR_8888(0x0, src[RCOMP], src[GCOMP], src[BCOMP]); -} - -static void -pack_float_XRGB8888(const GLfloat src[4], void *dst) -{ - GLubyte v[4]; - _mesa_unclamped_float_rgba_to_ubyte(v, src); - pack_ubyte_XRGB8888(v, dst); -} - -static void -pack_row_ubyte_XRGB8888(GLuint n, const GLubyte src[][4], void *dst) -{ - GLuint *d = ((GLuint *) dst); - GLuint i; - for (i = 0; i < n; i++) { - d[i] = PACK_COLOR_8888(0, src[i][RCOMP], src[i][GCOMP], src[i][BCOMP]); - } -} - -static void -pack_row_float_XRGB8888(GLuint n, const GLfloat src[][4], void *dst) -{ - GLuint *d = ((GLuint *) dst); - GLuint i; - for (i = 0; i < n; i++) { - GLubyte v[4]; - _mesa_unclamped_float_rgba_to_ubyte(v, src[i]); - pack_ubyte_XRGB8888(v, d + i); - } -} - - -/* - * MESA_FORMAT_XRGB8888_REV - */ - -static void -pack_ubyte_XRGB8888_REV(const GLubyte src[4], void *dst) -{ - GLuint *d = ((GLuint *) dst); - *d = PACK_COLOR_8888(src[BCOMP], src[GCOMP], src[RCOMP], 0); -} - -static void -pack_float_XRGB8888_REV(const GLfloat src[4], void *dst) -{ - GLubyte v[4]; - _mesa_unclamped_float_rgba_to_ubyte(v, src); - pack_ubyte_XRGB8888_REV(v, dst); -} - -static void -pack_row_ubyte_XRGB8888_REV(GLuint n, const GLubyte src[][4], void *dst) -{ - GLuint *d = ((GLuint *) dst); - GLuint i; - for (i = 0; i < n; i++) { - d[i] = PACK_COLOR_8888(src[i][BCOMP], src[i][GCOMP], src[i][RCOMP], 0); - } -} - -static void -pack_row_float_XRGB8888_REV(GLuint n, const GLfloat src[][4], void *dst) -{ - GLuint *d = ((GLuint *) dst); - GLuint i; - for (i = 0; i < n; i++) { - GLubyte v[4]; - _mesa_unclamped_float_rgba_to_ubyte(v, src[i]); - pack_ubyte_XRGB8888_REV(v, d + i); - } -} - - -/* - * MESA_FORMAT_RGB888 - */ - -static void -pack_ubyte_RGB888(const GLubyte src[4], void *dst) -{ - GLubyte *d = ((GLubyte *) dst); - d[2] = src[RCOMP]; - d[1] = src[GCOMP]; - d[0] = src[BCOMP]; -} - -static void -pack_float_RGB888(const GLfloat src[4], void *dst) -{ - GLubyte *d = ((GLubyte *) dst); - UNCLAMPED_FLOAT_TO_UBYTE(d[2], src[RCOMP]); - UNCLAMPED_FLOAT_TO_UBYTE(d[1], src[GCOMP]); - UNCLAMPED_FLOAT_TO_UBYTE(d[0], src[BCOMP]); -} - -static void -pack_row_ubyte_RGB888(GLuint n, const GLubyte src[][4], void *dst) -{ - GLubyte *d = ((GLubyte *) dst); - GLuint i; - for (i = 0; i < n; i++) { - d[i*3+2] = src[i][RCOMP]; - d[i*3+1] = src[i][GCOMP]; - d[i*3+0] = src[i][BCOMP]; - } -} - -static void -pack_row_float_RGB888(GLuint n, const GLfloat src[][4], void *dst) -{ - GLubyte *d = ((GLubyte *) dst); - GLuint i; - for (i = 0; i < n; i++) { - GLubyte v[4]; - _mesa_unclamped_float_rgba_to_ubyte(v, src[i]); - d[i*3+2] = v[RCOMP]; - d[i*3+1] = v[GCOMP]; - d[i*3+0] = v[BCOMP]; - } -} - - -/* - * MESA_FORMAT_BGR888 - */ - -static void -pack_ubyte_BGR888(const GLubyte src[4], void *dst) -{ - GLubyte *d = ((GLubyte *) dst); - d[2] = src[BCOMP]; - d[1] = src[GCOMP]; - d[0] = src[RCOMP]; -} - -static void -pack_float_BGR888(const GLfloat src[4], void *dst) -{ - GLubyte *d = ((GLubyte *) dst); - UNCLAMPED_FLOAT_TO_UBYTE(d[2], src[BCOMP]); - UNCLAMPED_FLOAT_TO_UBYTE(d[1], src[GCOMP]); - UNCLAMPED_FLOAT_TO_UBYTE(d[0], src[RCOMP]); -} - -static void -pack_row_ubyte_BGR888(GLuint n, const GLubyte src[][4], void *dst) -{ - GLubyte *d = ((GLubyte *) dst); - GLuint i; - for (i = 0; i < n; i++) { - d[i*3+2] = src[i][BCOMP]; - d[i*3+1] = src[i][GCOMP]; - d[i*3+0] = src[i][RCOMP]; - } -} - -static void -pack_row_float_BGR888(GLuint n, const GLfloat src[][4], void *dst) -{ - GLubyte *d = ((GLubyte *) dst); - GLuint i; - for (i = 0; i < n; i++) { - GLubyte v[4]; - _mesa_unclamped_float_rgba_to_ubyte(v, src[i]); - d[i*3+2] = v[BCOMP]; - d[i*3+1] = v[GCOMP]; - d[i*3+0] = v[RCOMP]; - } -} - - -/* - * MESA_FORMAT_RGB565 - */ - -static void -pack_ubyte_RGB565(const GLubyte src[4], void *dst) -{ - GLushort *d = ((GLushort *) dst); - *d = PACK_COLOR_565(src[RCOMP], src[GCOMP], src[BCOMP]); -} - -static void -pack_float_RGB565(const GLfloat src[4], void *dst) -{ - GLubyte v[3]; - UNCLAMPED_FLOAT_TO_UBYTE(v[0], src[RCOMP]); - UNCLAMPED_FLOAT_TO_UBYTE(v[1], src[GCOMP]); - UNCLAMPED_FLOAT_TO_UBYTE(v[2], src[BCOMP]); - pack_ubyte_RGB565(v, dst); -} - -static void -pack_row_ubyte_RGB565(GLuint n, const GLubyte src[][4], void *dst) -{ - GLushort *d = ((GLushort *) dst); - GLuint i; - for (i = 0; i < n; i++) { - pack_ubyte_RGB565(src[i], d + i); - } -} - -static void -pack_row_float_RGB565(GLuint n, const GLfloat src[][4], void *dst) -{ - GLushort *d = ((GLushort *) dst); - GLuint i; - for (i = 0; i < n; i++) { - GLubyte v[4]; - _mesa_unclamped_float_rgba_to_ubyte(v, src[i]); - pack_ubyte_RGB565(v, d + i); - } -} - - -/* - * MESA_FORMAT_RGB565_REV - */ - -static void -pack_ubyte_RGB565_REV(const GLubyte src[4], void *dst) -{ - GLushort *d = ((GLushort *) dst); - *d = PACK_COLOR_565_REV(src[RCOMP], src[GCOMP], src[BCOMP]); -} - -static void -pack_float_RGB565_REV(const GLfloat src[4], void *dst) -{ - GLushort *d = ((GLushort *) dst); - GLubyte r, g, b; - UNCLAMPED_FLOAT_TO_UBYTE(r, src[RCOMP]); - UNCLAMPED_FLOAT_TO_UBYTE(g, src[GCOMP]); - UNCLAMPED_FLOAT_TO_UBYTE(b, src[BCOMP]); - *d = PACK_COLOR_565_REV(r, g, b); -} - -static void -pack_row_ubyte_RGB565_REV(GLuint n, const GLubyte src[][4], void *dst) -{ - GLushort *d = ((GLushort *) dst); - GLuint i; - for (i = 0; i < n; i++) { - pack_ubyte_RGB565_REV(src[i], d + i); - } -} - -static void -pack_row_float_RGB565_REV(GLuint n, const GLfloat src[][4], void *dst) -{ - GLushort *d = ((GLushort *) dst); - GLuint i; - for (i = 0; i < n; i++) { - GLubyte v[4]; - _mesa_unclamped_float_rgba_to_ubyte(v, src[i]); - pack_ubyte_RGB565_REV(v, d + i); - } -} - - -/* - * MESA_FORMAT_ARGB4444 - */ - -static void -pack_ubyte_ARGB4444(const GLubyte src[4], void *dst) -{ - GLushort *d = ((GLushort *) dst); - *d = PACK_COLOR_4444(src[ACOMP], src[RCOMP], src[GCOMP], src[BCOMP]); -} - -static void -pack_float_ARGB4444(const GLfloat src[4], void *dst) -{ - GLubyte v[4]; - _mesa_unclamped_float_rgba_to_ubyte(v, src); - pack_ubyte_ARGB4444(v, dst); -} - -/* use fallback row packing functions */ - - -/* - * MESA_FORMAT_ARGB4444_REV - */ - -static void -pack_ubyte_ARGB4444_REV(const GLubyte src[4], void *dst) -{ - GLushort *d = ((GLushort *) dst); - *d = PACK_COLOR_4444(src[GCOMP], src[BCOMP], src[ACOMP], src[RCOMP]); -} - -static void -pack_float_ARGB4444_REV(const GLfloat src[4], void *dst) -{ - GLubyte v[4]; - _mesa_unclamped_float_rgba_to_ubyte(v, src); - pack_ubyte_ARGB4444_REV(v, dst); -} - -/* use fallback row packing functions */ - - -/* - * MESA_FORMAT_RGBA5551 - */ - -static void -pack_ubyte_RGBA5551(const GLubyte src[4], void *dst) -{ - GLushort *d = ((GLushort *) dst); - *d = PACK_COLOR_5551(src[RCOMP], src[GCOMP], src[BCOMP], src[ACOMP]); -} - -static void -pack_float_RGBA5551(const GLfloat src[4], void *dst) -{ - GLubyte v[4]; - _mesa_unclamped_float_rgba_to_ubyte(v, src); - pack_ubyte_RGBA5551(v, dst); -} - -/* use fallback row packing functions */ - - -/* - * MESA_FORMAT_ARGB1555 - */ - -static void -pack_ubyte_ARGB1555(const GLubyte src[4], void *dst) -{ - GLushort *d = ((GLushort *) dst); - *d = PACK_COLOR_1555(src[ACOMP], src[RCOMP], src[GCOMP], src[BCOMP]); -} - -static void -pack_float_ARGB1555(const GLfloat src[4], void *dst) -{ - GLubyte v[4]; - _mesa_unclamped_float_rgba_to_ubyte(v, src); - pack_ubyte_ARGB1555(v, dst); -} - - -/* MESA_FORMAT_ARGB1555_REV */ - -static void -pack_ubyte_ARGB1555_REV(const GLubyte src[4], void *dst) -{ - GLushort *d = ((GLushort *) dst), tmp; - tmp = PACK_COLOR_1555(src[ACOMP], src[RCOMP], src[GCOMP], src[BCOMP]); - *d = (tmp >> 8) | (tmp << 8); -} - -static void -pack_float_ARGB1555_REV(const GLfloat src[4], void *dst) -{ - GLubyte v[4]; - _mesa_unclamped_float_rgba_to_ubyte(v, src); - pack_ubyte_ARGB1555_REV(v, dst); -} - - -/* MESA_FORMAT_AL44 */ - -static void -pack_ubyte_AL44(const GLubyte src[4], void *dst) -{ - GLubyte *d = ((GLubyte *) dst); - *d = PACK_COLOR_44(src[ACOMP], src[RCOMP]); -} - -static void -pack_float_AL44(const GLfloat src[4], void *dst) -{ - GLubyte v[4]; - UNCLAMPED_FLOAT_TO_UBYTE(v[0], src[RCOMP]); - UNCLAMPED_FLOAT_TO_UBYTE(v[3], src[ACOMP]); - pack_ubyte_AL44(v, dst); -} - - -/* MESA_FORMAT_AL88 */ - -static void -pack_ubyte_AL88(const GLubyte src[4], void *dst) -{ - GLushort *d = ((GLushort *) dst); - *d = PACK_COLOR_88(src[ACOMP], src[RCOMP]); -} - -static void -pack_float_AL88(const GLfloat src[4], void *dst) -{ - GLubyte v[4]; - UNCLAMPED_FLOAT_TO_UBYTE(v[0], src[RCOMP]); - UNCLAMPED_FLOAT_TO_UBYTE(v[3], src[ACOMP]); - pack_ubyte_AL88(v, dst); -} - - -/* MESA_FORMAT_AL88_REV */ - -static void -pack_ubyte_AL88_REV(const GLubyte src[4], void *dst) -{ - GLushort *d = ((GLushort *) dst); - *d = PACK_COLOR_88(src[RCOMP], src[ACOMP]); -} - -static void -pack_float_AL88_REV(const GLfloat src[4], void *dst) -{ - GLubyte v[4]; - UNCLAMPED_FLOAT_TO_UBYTE(v[0], src[RCOMP]); - UNCLAMPED_FLOAT_TO_UBYTE(v[3], src[ACOMP]); - pack_ubyte_AL88_REV(v, dst); -} - - -/* MESA_FORMAT_AL1616 */ - -static void -pack_ubyte_AL1616(const GLubyte src[4], void *dst) -{ - GLuint *d = ((GLuint *) dst); - GLushort l = UBYTE_TO_USHORT(src[RCOMP]); - GLushort a = UBYTE_TO_USHORT(src[ACOMP]); - *d = PACK_COLOR_1616(a, l); -} - -static void -pack_float_AL1616(const GLfloat src[4], void *dst) -{ - GLuint *d = ((GLuint *) dst); - GLushort l, a; - UNCLAMPED_FLOAT_TO_USHORT(l, src[RCOMP]); - UNCLAMPED_FLOAT_TO_USHORT(a, src[ACOMP]); - *d = PACK_COLOR_1616(a, l); -} - - -/* MESA_FORMAT_AL1616_REV */ - -static void -pack_ubyte_AL1616_REV(const GLubyte src[4], void *dst) -{ - GLuint *d = ((GLuint *) dst); - GLushort l = UBYTE_TO_USHORT(src[RCOMP]); - GLushort a = UBYTE_TO_USHORT(src[ACOMP]); - *d = PACK_COLOR_1616(l, a); -} - -static void -pack_float_AL1616_REV(const GLfloat src[4], void *dst) -{ - GLuint *d = ((GLuint *) dst); - GLushort l, a; - UNCLAMPED_FLOAT_TO_USHORT(l, src[RCOMP]); - UNCLAMPED_FLOAT_TO_USHORT(a, src[ACOMP]); - *d = PACK_COLOR_1616(l, a); -} - - -/* MESA_FORMAT_RGB332 */ - -static void -pack_ubyte_RGB332(const GLubyte src[4], void *dst) -{ - GLubyte *d = ((GLubyte *) dst); - *d = PACK_COLOR_332(src[RCOMP], src[GCOMP], src[BCOMP]); -} - -static void -pack_float_RGB332(const GLfloat src[4], void *dst) -{ - GLubyte v[4]; - UNCLAMPED_FLOAT_TO_UBYTE(v[0], src[RCOMP]); - UNCLAMPED_FLOAT_TO_UBYTE(v[1], src[GCOMP]); - UNCLAMPED_FLOAT_TO_UBYTE(v[2], src[BCOMP]); - pack_ubyte_RGB332(v, dst); -} - - -/* MESA_FORMAT_A8 */ - -static void -pack_ubyte_A8(const GLubyte src[4], void *dst) -{ - GLubyte *d = ((GLubyte *) dst); - *d = src[ACOMP]; -} - -static void -pack_float_A8(const GLfloat src[4], void *dst) -{ - GLubyte *d = ((GLubyte *) dst); - UNCLAMPED_FLOAT_TO_UBYTE(d[0], src[ACOMP]); -} - - -/* MESA_FORMAT_A16 */ - -static void -pack_ubyte_A16(const GLubyte src[4], void *dst) -{ - GLushort *d = ((GLushort *) dst); - *d = UBYTE_TO_USHORT(src[ACOMP]); -} - -static void -pack_float_A16(const GLfloat src[4], void *dst) -{ - GLushort *d = ((GLushort *) dst); - UNCLAMPED_FLOAT_TO_USHORT(d[0], src[ACOMP]); -} - - -/* MESA_FORMAT_L8 */ - -static void -pack_ubyte_L8(const GLubyte src[4], void *dst) -{ - GLubyte *d = ((GLubyte *) dst); - *d = src[RCOMP]; -} - -static void -pack_float_L8(const GLfloat src[4], void *dst) -{ - GLubyte *d = ((GLubyte *) dst); - UNCLAMPED_FLOAT_TO_UBYTE(d[0], src[RCOMP]); -} - - -/* MESA_FORMAT_L16 */ - -static void -pack_ubyte_L16(const GLubyte src[4], void *dst) -{ - GLushort *d = ((GLushort *) dst); - *d = UBYTE_TO_USHORT(src[RCOMP]); -} - -static void -pack_float_L16(const GLfloat src[4], void *dst) -{ - GLushort *d = ((GLushort *) dst); - UNCLAMPED_FLOAT_TO_USHORT(d[0], src[RCOMP]); -} - - -/* MESA_FORMAT_YCBCR */ - -static void -pack_ubyte_YCBCR(const GLubyte src[4], void *dst) -{ - /* todo */ -} - -static void -pack_float_YCBCR(const GLfloat src[4], void *dst) -{ - /* todo */ -} - - -/* MESA_FORMAT_YCBCR_REV */ - -static void -pack_ubyte_YCBCR_REV(const GLubyte src[4], void *dst) -{ - /* todo */ -} - -static void -pack_float_YCBCR_REV(const GLfloat src[4], void *dst) -{ - /* todo */ -} - - -/* MESA_FORMAT_RGBA_16 */ - -static void -pack_ubyte_RGBA_16(const GLubyte src[4], void *dst) -{ - GLushort *d = ((GLushort *) dst); - d[0] = UBYTE_TO_USHORT(src[RCOMP]); - d[1] = UBYTE_TO_USHORT(src[GCOMP]); - d[2] = UBYTE_TO_USHORT(src[BCOMP]); - d[3] = UBYTE_TO_USHORT(src[ACOMP]); -} - -static void -pack_float_RGBA_16(const GLfloat src[4], void *dst) -{ - GLushort *d = ((GLushort *) dst); - UNCLAMPED_FLOAT_TO_USHORT(d[0], src[RCOMP]); - UNCLAMPED_FLOAT_TO_USHORT(d[1], src[GCOMP]); - UNCLAMPED_FLOAT_TO_USHORT(d[2], src[BCOMP]); - UNCLAMPED_FLOAT_TO_USHORT(d[3], src[ACOMP]); -} - -/* - * MESA_FORMAT_SIGNED_RGBA_16 - */ - -static void -pack_float_SIGNED_RGBA_16(const GLfloat src[4], void *dst) -{ - GLshort *d = (GLshort *) dst; - d[0] = FLOAT_TO_SHORT(CLAMP(src[RCOMP], -1.0f, 1.0f)); - d[1] = FLOAT_TO_SHORT(CLAMP(src[GCOMP], -1.0f, 1.0f)); - d[2] = FLOAT_TO_SHORT(CLAMP(src[BCOMP], -1.0f, 1.0f)); - d[3] = FLOAT_TO_SHORT(CLAMP(src[ACOMP], -1.0f, 1.0f)); -} - - - -/** - * Return a function that can pack a GLubyte rgba[4] color. - */ -gl_pack_ubyte_rgba_func -_mesa_get_pack_ubyte_rgba_function(gl_format format) -{ - static gl_pack_ubyte_rgba_func table[MESA_FORMAT_COUNT]; - static GLboolean initialized = GL_FALSE; - - if (!initialized) { - memset(table, 0, sizeof(table)); - - table[MESA_FORMAT_NONE] = NULL; - - table[MESA_FORMAT_RGBA8888] = pack_ubyte_RGBA8888; - table[MESA_FORMAT_RGBA8888_REV] = pack_ubyte_RGBA8888_REV; - table[MESA_FORMAT_ARGB8888] = pack_ubyte_ARGB8888; - table[MESA_FORMAT_ARGB8888_REV] = pack_ubyte_ARGB8888_REV; - table[MESA_FORMAT_RGBX8888] = pack_ubyte_RGBA8888; /* reused */ - table[MESA_FORMAT_RGBX8888_REV] = pack_ubyte_RGBA8888_REV; /* reused */ - table[MESA_FORMAT_XRGB8888] = pack_ubyte_XRGB8888; - table[MESA_FORMAT_XRGB8888_REV] = pack_ubyte_XRGB8888_REV; - table[MESA_FORMAT_RGB888] = pack_ubyte_RGB888; - table[MESA_FORMAT_BGR888] = pack_ubyte_BGR888; - table[MESA_FORMAT_RGB565] = pack_ubyte_RGB565; - table[MESA_FORMAT_RGB565_REV] = pack_ubyte_RGB565_REV; - table[MESA_FORMAT_ARGB4444] = pack_ubyte_ARGB4444; - table[MESA_FORMAT_ARGB4444_REV] = pack_ubyte_ARGB4444_REV; - table[MESA_FORMAT_RGBA5551] = pack_ubyte_RGBA5551; - table[MESA_FORMAT_ARGB1555] = pack_ubyte_ARGB1555; - table[MESA_FORMAT_ARGB1555_REV] = pack_ubyte_ARGB1555_REV; - table[MESA_FORMAT_AL44] = pack_ubyte_AL44; - table[MESA_FORMAT_AL88] = pack_ubyte_AL88; - table[MESA_FORMAT_AL88_REV] = pack_ubyte_AL88_REV; - table[MESA_FORMAT_AL1616] = pack_ubyte_AL1616; - table[MESA_FORMAT_AL1616_REV] = pack_ubyte_AL1616_REV; - table[MESA_FORMAT_RGB332] = pack_ubyte_RGB332; - table[MESA_FORMAT_A8] = pack_ubyte_A8; - table[MESA_FORMAT_A16] = pack_ubyte_A16; - table[MESA_FORMAT_L8] = pack_ubyte_L8; - table[MESA_FORMAT_L16] = pack_ubyte_L16; - table[MESA_FORMAT_I8] = pack_ubyte_L8; /* reuse pack_ubyte_L8 */ - table[MESA_FORMAT_I16] = pack_ubyte_L16; /* reuse pack_ubyte_L16 */ - table[MESA_FORMAT_YCBCR] = pack_ubyte_YCBCR; - table[MESA_FORMAT_YCBCR_REV] = pack_ubyte_YCBCR_REV; - - /* should never convert RGBA to these formats */ - table[MESA_FORMAT_Z16] = NULL; - table[MESA_FORMAT_X8_Z24] = NULL; - table[MESA_FORMAT_Z24_X8] = NULL; - table[MESA_FORMAT_Z32] = NULL; - table[MESA_FORMAT_S8] = NULL; - - /* n/a */ - table[MESA_FORMAT_RGBA_INT8] = NULL; /* pack_ubyte_RGBA_INT8 */ - table[MESA_FORMAT_RGBA_INT16] = NULL; /* pack_ubyte_RGBA_INT16 */ - table[MESA_FORMAT_RGBA_INT32] = NULL; /* pack_ubyte_RGBA_INT32 */ - table[MESA_FORMAT_RGBA_UINT8] = NULL; /* pack_ubyte_RGBA_UINT8 */ - table[MESA_FORMAT_RGBA_UINT16] = NULL; /* pack_ubyte_RGBA_UINT16 */ - table[MESA_FORMAT_RGBA_UINT32] = NULL; /* pack_ubyte_RGBA_UINT32 */ - - table[MESA_FORMAT_RGBA_16] = pack_ubyte_RGBA_16; - - table[MESA_FORMAT_SIGNED_RGBA_16] = NULL; - - - table[MESA_FORMAT_RGBA_16] = pack_ubyte_RGBA_16; - - initialized = GL_TRUE; - } - - return table[format]; -} - - - -/** - * Return a function that can pack a GLfloat rgba[4] color. - */ -gl_pack_float_rgba_func -_mesa_get_pack_float_rgba_function(gl_format format) -{ - static gl_pack_float_rgba_func table[MESA_FORMAT_COUNT]; - static GLboolean initialized = GL_FALSE; - - if (!initialized) { - memset(table, 0, sizeof(table)); - - table[MESA_FORMAT_NONE] = NULL; - - table[MESA_FORMAT_RGBA8888] = pack_float_RGBA8888; - table[MESA_FORMAT_RGBA8888_REV] = pack_float_RGBA8888_REV; - table[MESA_FORMAT_ARGB8888] = pack_float_ARGB8888; - table[MESA_FORMAT_ARGB8888_REV] = pack_float_ARGB8888_REV; - table[MESA_FORMAT_RGBX8888] = pack_float_RGBA8888; /* reused */ - table[MESA_FORMAT_RGBX8888_REV] = pack_float_RGBA8888_REV; /* reused */ - table[MESA_FORMAT_XRGB8888] = pack_float_XRGB8888; - table[MESA_FORMAT_XRGB8888_REV] = pack_float_XRGB8888_REV; - table[MESA_FORMAT_RGB888] = pack_float_RGB888; - table[MESA_FORMAT_BGR888] = pack_float_BGR888; - table[MESA_FORMAT_RGB565] = pack_float_RGB565; - table[MESA_FORMAT_RGB565_REV] = pack_float_RGB565_REV; - table[MESA_FORMAT_ARGB4444] = pack_float_ARGB4444; - table[MESA_FORMAT_ARGB4444_REV] = pack_float_ARGB4444_REV; - table[MESA_FORMAT_RGBA5551] = pack_float_RGBA5551; - table[MESA_FORMAT_ARGB1555] = pack_float_ARGB1555; - table[MESA_FORMAT_ARGB1555_REV] = pack_float_ARGB1555_REV; - - table[MESA_FORMAT_AL44] = pack_float_AL44; - table[MESA_FORMAT_AL88] = pack_float_AL88; - table[MESA_FORMAT_AL88_REV] = pack_float_AL88_REV; - table[MESA_FORMAT_AL1616] = pack_float_AL1616; - table[MESA_FORMAT_AL1616_REV] = pack_float_AL1616_REV; - table[MESA_FORMAT_RGB332] = pack_float_RGB332; - table[MESA_FORMAT_A8] = pack_float_A8; - table[MESA_FORMAT_A16] = pack_float_A16; - table[MESA_FORMAT_L8] = pack_float_L8; - table[MESA_FORMAT_L16] = pack_float_L16; - table[MESA_FORMAT_I8] = pack_float_L8; /* reuse pack_float_L8 */ - table[MESA_FORMAT_I16] = pack_float_L16; /* reuse pack_float_L16 */ - table[MESA_FORMAT_YCBCR] = pack_float_YCBCR; - table[MESA_FORMAT_YCBCR_REV] = pack_float_YCBCR_REV; - - /* should never convert RGBA to these formats */ - table[MESA_FORMAT_Z16] = NULL; - table[MESA_FORMAT_X8_Z24] = NULL; - table[MESA_FORMAT_Z24_X8] = NULL; - table[MESA_FORMAT_Z32] = NULL; - table[MESA_FORMAT_S8] = NULL; - - /* n/a */ - table[MESA_FORMAT_RGBA_INT8] = NULL; - table[MESA_FORMAT_RGBA_INT16] = NULL; - table[MESA_FORMAT_RGBA_INT32] = NULL; - table[MESA_FORMAT_RGBA_UINT8] = NULL; - table[MESA_FORMAT_RGBA_UINT16] = NULL; - table[MESA_FORMAT_RGBA_UINT32] = NULL; - - table[MESA_FORMAT_RGBA_16] = pack_float_RGBA_16; - - table[MESA_FORMAT_SIGNED_RGBA_16] = pack_float_SIGNED_RGBA_16; - - - initialized = GL_TRUE; - } - - return table[format]; -} - - - -static pack_float_rgba_row_func -get_pack_float_rgba_row_function(gl_format format) -{ - static pack_float_rgba_row_func table[MESA_FORMAT_COUNT]; - static GLboolean initialized = GL_FALSE; - - if (!initialized) { - /* We don't need a special row packing function for each format. - * There's a generic fallback which uses a per-pixel packing function. - */ - memset(table, 0, sizeof(table)); - - table[MESA_FORMAT_RGBA8888] = pack_row_float_RGBA8888; - table[MESA_FORMAT_RGBA8888_REV] = pack_row_float_RGBA8888_REV; - table[MESA_FORMAT_ARGB8888] = pack_row_float_ARGB8888; - table[MESA_FORMAT_ARGB8888_REV] = pack_row_float_ARGB8888_REV; - table[MESA_FORMAT_RGBX8888] = pack_row_float_RGBA8888; /* reused */ - table[MESA_FORMAT_RGBX8888_REV] = pack_row_float_RGBA8888_REV; /* reused */ - table[MESA_FORMAT_XRGB8888] = pack_row_float_XRGB8888; - table[MESA_FORMAT_XRGB8888_REV] = pack_row_float_XRGB8888_REV; - table[MESA_FORMAT_RGB888] = pack_row_float_RGB888; - table[MESA_FORMAT_BGR888] = pack_row_float_BGR888; - table[MESA_FORMAT_RGB565] = pack_row_float_RGB565; - table[MESA_FORMAT_RGB565_REV] = pack_row_float_RGB565_REV; - - initialized = GL_TRUE; - } - - return table[format]; -} - - - -static pack_ubyte_rgba_row_func -get_pack_ubyte_rgba_row_function(gl_format format) -{ - static pack_ubyte_rgba_row_func table[MESA_FORMAT_COUNT]; - static GLboolean initialized = GL_FALSE; - - if (!initialized) { - /* We don't need a special row packing function for each format. - * There's a generic fallback which uses a per-pixel packing function. - */ - memset(table, 0, sizeof(table)); - - table[MESA_FORMAT_RGBA8888] = pack_row_ubyte_RGBA8888; - table[MESA_FORMAT_RGBA8888_REV] = pack_row_ubyte_RGBA8888_REV; - table[MESA_FORMAT_ARGB8888] = pack_row_ubyte_ARGB8888; - table[MESA_FORMAT_ARGB8888_REV] = pack_row_ubyte_ARGB8888_REV; - table[MESA_FORMAT_RGBX8888] = pack_row_ubyte_RGBA8888; /* reused */ - table[MESA_FORMAT_RGBX8888_REV] = pack_row_ubyte_RGBA8888_REV; /* reused */ - table[MESA_FORMAT_XRGB8888] = pack_row_ubyte_XRGB8888; - table[MESA_FORMAT_XRGB8888_REV] = pack_row_ubyte_XRGB8888_REV; - table[MESA_FORMAT_RGB888] = pack_row_ubyte_RGB888; - table[MESA_FORMAT_BGR888] = pack_row_ubyte_BGR888; - table[MESA_FORMAT_RGB565] = pack_row_ubyte_RGB565; - table[MESA_FORMAT_RGB565_REV] = pack_row_ubyte_RGB565_REV; - - initialized = GL_TRUE; - } - - return table[format]; -} - - - -/** - * Pack a row of GLfloat rgba[4] values to the destination. - */ -void -_mesa_pack_float_rgba_row(gl_format format, GLuint n, - const GLfloat src[][4], void *dst) -{ - pack_float_rgba_row_func packrow = get_pack_float_rgba_row_function(format); - if (packrow) { - /* use "fast" function */ - packrow(n, src, dst); - } - else { - /* slower fallback */ - gl_pack_float_rgba_func pack = _mesa_get_pack_float_rgba_function(format); - GLuint dstStride = _mesa_get_format_bytes(format); - GLubyte *dstPtr = (GLubyte *) dst; - GLuint i; - - assert(pack); - if (!pack) - return; - - for (i = 0; i < n; i++) { - pack(src[i], dstPtr); - dstPtr += dstStride; - } - } -} - - -/** - * Pack a row of GLubyte rgba[4] values to the destination. - */ -void -_mesa_pack_ubyte_rgba_row(gl_format format, GLuint n, - const GLubyte src[][4], void *dst) -{ - pack_ubyte_rgba_row_func packrow = get_pack_ubyte_rgba_row_function(format); - if (packrow) { - /* use "fast" function */ - packrow(n, src, dst); - } - else { - /* slower fallback */ - gl_pack_ubyte_rgba_func pack = _mesa_get_pack_ubyte_rgba_function(format); - const GLuint stride = _mesa_get_format_bytes(format); - GLubyte *d = ((GLubyte *) dst); - GLuint i; - - assert(pack); - if (!pack) - return; - - for (i = 0; i < n; i++) { - pack(src[i], d); - d += stride; - } - } -} - - -/** - ** Pack float Z pixels - **/ - -static void -pack_float_z_Z24_S8(const GLfloat *src, void *dst) -{ - /* don't disturb the stencil values */ - GLuint *d = ((GLuint *) dst); - const GLdouble scale = (GLdouble) 0xffffff; - GLuint s = *d & 0xff; - GLuint z = (GLuint) (*src * scale); - assert(z <= 0xffffff); - *d = (z << 8) | s; -} - -static void -pack_float_z_S8_Z24(const GLfloat *src, void *dst) -{ - /* don't disturb the stencil values */ - GLuint *d = ((GLuint *) dst); - const GLdouble scale = (GLdouble) 0xffffff; - GLuint s = *d & 0xff000000; - GLuint z = (GLuint) (*src * scale); - assert(z <= 0xffffff); - *d = s | z; -} - -static void -pack_float_z_Z16(const GLfloat *src, void *dst) -{ - GLushort *d = ((GLushort *) dst); - const GLfloat scale = (GLfloat) 0xffff; - *d = (GLushort) (*src * scale); -} - -static void -pack_float_z_Z32(const GLfloat *src, void *dst) -{ - GLuint *d = ((GLuint *) dst); - const GLdouble scale = (GLdouble) 0xffffffff; - *d = (GLuint) (*src * scale); -} - -gl_pack_float_z_func -_mesa_get_pack_float_z_func(gl_format format) -{ - switch (format) { - case MESA_FORMAT_Z24_X8: - return pack_float_z_Z24_S8; - case MESA_FORMAT_X8_Z24: - return pack_float_z_S8_Z24; - case MESA_FORMAT_Z16: - return pack_float_z_Z16; - case MESA_FORMAT_Z32: - return pack_float_z_Z32; - default: - _mesa_problem(NULL, - "unexpected format in _mesa_get_pack_float_z_func()"); - return NULL; - } -} - - - -/** - ** Pack uint Z pixels. The incoming src value is always in - ** the range [0, 2^32-1]. - **/ - -static void -pack_uint_z_Z24_S8(const GLuint *src, void *dst) -{ - /* don't disturb the stencil values */ - GLuint *d = ((GLuint *) dst); - GLuint s = *d & 0xff; - GLuint z = *src & 0xffffff00; - *d = z | s; -} - -static void -pack_uint_z_S8_Z24(const GLuint *src, void *dst) -{ - /* don't disturb the stencil values */ - GLuint *d = ((GLuint *) dst); - GLuint s = *d & 0xff000000; - GLuint z = *src >> 8; - *d = s | z; -} - -static void -pack_uint_z_Z16(const GLuint *src, void *dst) -{ - GLushort *d = ((GLushort *) dst); - *d = *src >> 16; -} - -static void -pack_uint_z_Z32(const GLuint *src, void *dst) -{ - GLuint *d = ((GLuint *) dst); - *d = *src; -} - -gl_pack_uint_z_func -_mesa_get_pack_uint_z_func(gl_format format) -{ - switch (format) { - case MESA_FORMAT_Z24_X8: - return pack_uint_z_Z24_S8; - case MESA_FORMAT_X8_Z24: - return pack_uint_z_S8_Z24; - case MESA_FORMAT_Z16: - return pack_uint_z_Z16; - case MESA_FORMAT_Z32: - return pack_uint_z_Z32; - default: - _mesa_problem(NULL, "unexpected format in _mesa_get_pack_uint_z_func()"); - return NULL; - } -} - - -/** - ** Pack ubyte stencil pixels - **/ - -static void -pack_ubyte_stencil_S8(const GLubyte *src, void *dst) -{ - GLubyte *d = (GLubyte *) dst; - *d = *src; -} - - -gl_pack_ubyte_stencil_func -_mesa_get_pack_ubyte_stencil_func(gl_format format) -{ - return pack_ubyte_stencil_S8; -} - - - -void -_mesa_pack_float_z_row(gl_format format, GLuint n, - const GLfloat *src, void *dst) -{ - switch (format) { - case MESA_FORMAT_Z24_X8: - { - /* don't disturb the stencil values */ - GLuint *d = ((GLuint *) dst); - const GLdouble scale = (GLdouble) 0xffffff; - GLuint i; - for (i = 0; i < n; i++) { - GLuint s = d[i] & 0xff; - GLuint z = (GLuint) (src[i] * scale); - assert(z <= 0xffffff); - d[i] = (z << 8) | s; - } - } - break; - case MESA_FORMAT_X8_Z24: - { - /* don't disturb the stencil values */ - GLuint *d = ((GLuint *) dst); - const GLdouble scale = (GLdouble) 0xffffff; - GLuint i; - for (i = 0; i < n; i++) { - GLuint s = d[i] & 0xff000000; - GLuint z = (GLuint) (src[i] * scale); - assert(z <= 0xffffff); - d[i] = s | z; - } - } - break; - case MESA_FORMAT_Z16: - { - GLushort *d = ((GLushort *) dst); - const GLfloat scale = (GLfloat) 0xffff; - GLuint i; - for (i = 0; i < n; i++) { - d[i] = (GLushort) (src[i] * scale); - } - } - break; - case MESA_FORMAT_Z32: - { - GLuint *d = ((GLuint *) dst); - const GLdouble scale = (GLdouble) 0xffffffff; - GLuint i; - for (i = 0; i < n; i++) { - d[i] = (GLuint) (src[i] * scale); - } - } - break; - default: - _mesa_problem(NULL, "unexpected format in _mesa_pack_float_z_row()"); - } -} - - -/** - * The incoming Z values are always in the range [0, 0xffffffff]. - */ -void -_mesa_pack_uint_z_row(gl_format format, GLuint n, - const GLuint *src, void *dst) -{ - switch (format) { - case MESA_FORMAT_Z24_X8: - { - /* don't disturb the stencil values */ - GLuint *d = ((GLuint *) dst); - GLuint i; - for (i = 0; i < n; i++) { - GLuint s = d[i] & 0xff; - GLuint z = src[i] & 0xffffff00; - d[i] = z | s; - } - } - break; - case MESA_FORMAT_X8_Z24: - { - /* don't disturb the stencil values */ - GLuint *d = ((GLuint *) dst); - GLuint i; - for (i = 0; i < n; i++) { - GLuint s = d[i] & 0xff000000; - GLuint z = src[i] >> 8; - d[i] = s | z; - } - } - break; - case MESA_FORMAT_Z16: - { - GLushort *d = ((GLushort *) dst); - GLuint i; - for (i = 0; i < n; i++) { - d[i] = src[i] >> 16; - } - } - break; - case MESA_FORMAT_Z32: - memcpy(dst, src, n * sizeof(GLfloat)); - break; - default: - _mesa_problem(NULL, "unexpected format in _mesa_pack_uint_z_row()"); - } -} - - -void -_mesa_pack_ubyte_stencil_row(gl_format format, GLuint n, - const GLubyte *src, void *dst) -{ - memcpy(dst, src, n * sizeof(GLubyte)); -} - - -/** - * Convert a boolean color mask to a packed color where each channel of - * the packed value at dst will be 0 or ~0 depending on the colorMask. - */ -void -_mesa_pack_colormask(gl_format format, const GLubyte colorMask[4], void *dst) -{ - GLfloat maskColor[4]; - - switch (_mesa_get_format_datatype(format)) { - case GL_UNSIGNED_NORMALIZED: - /* simple: 1.0 will convert to ~0 in the right bit positions */ - maskColor[0] = colorMask[0] ? 1.0 : 0.0; - maskColor[1] = colorMask[1] ? 1.0 : 0.0; - maskColor[2] = colorMask[2] ? 1.0 : 0.0; - maskColor[3] = colorMask[3] ? 1.0 : 0.0; - _mesa_pack_float_rgba_row(format, 1, - (const GLfloat (*)[4]) maskColor, dst); - break; - case GL_SIGNED_NORMALIZED: - case GL_FLOAT: - /* These formats are harder because it's hard to know the floating - * point values that will convert to ~0 for each color channel's bits. - * This solution just generates a non-zero value for each color channel - * then fixes up the non-zero values to be ~0. - * Note: we'll need to add special case code if we ever have to deal - * with formats with unequal color channel sizes, like R11_G11_B10. - * We issue a warning below for channel sizes other than 8,16,32. - */ - { - GLuint bits = _mesa_get_format_max_bits(format); /* bits per chan */ - GLuint bytes = _mesa_get_format_bytes(format); - GLuint i; - - /* this should put non-zero values into the channels of dst */ - maskColor[0] = colorMask[0] ? -1.0f : 0.0f; - maskColor[1] = colorMask[1] ? -1.0f : 0.0f; - maskColor[2] = colorMask[2] ? -1.0f : 0.0f; - maskColor[3] = colorMask[3] ? -1.0f : 0.0f; - _mesa_pack_float_rgba_row(format, 1, - (const GLfloat (*)[4]) maskColor, dst); - - /* fix-up the dst channels by converting non-zero values to ~0 */ - if (bits == 8) { - GLubyte *d = (GLubyte *) dst; - for (i = 0; i < bytes; i++) { - d[i] = d[i] ? 0xffff : 0x0; - } - } - else if (bits == 16) { - GLushort *d = (GLushort *) dst; - for (i = 0; i < bytes / 2; i++) { - d[i] = d[i] ? 0xffff : 0x0; - } - } - else if (bits == 32) { - GLuint *d = (GLuint *) dst; - for (i = 0; i < bytes / 4; i++) { - d[i] = d[i] ? 0xffffffffU : 0x0; - } - } - else { - _mesa_problem(NULL, "unexpected size in _mesa_pack_colormask()"); - return; - } - } - break; - default: - _mesa_problem(NULL, "unexpected format data type in gen_color_mask()"); - return; - } -} diff --git a/dll/opengl/mesa/main/format_pack.h b/dll/opengl/mesa/main/format_pack.h deleted file mode 100644 index d83805c6e5d..00000000000 --- a/dll/opengl/mesa/main/format_pack.h +++ /dev/null @@ -1,97 +0,0 @@ -/* - * Mesa 3-D graphics library - * - * Copyright (c) 2011 VMware, Inc. - * - * Permission is hereby granted, free of charge, to any person obtaining a - * copy of this software and associated documentation files (the "Software"), - * to deal in the Software without restriction, including without limitation - * the rights to use, copy, modify, merge, publish, distribute, sublicense, - * and/or sell copies of the Software, and to permit persons to whom the - * Software is furnished to do so, subject to the following conditions: - * - * The above copyright notice and this permission notice shall be included - * in all copies or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS - * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL - * THE AUTHORS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN - * AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN - * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. - */ - - -#ifndef FORMAT_PACK_H -#define FORMAT_PACK_H - - -#include "formats.h" - - -/** Pack a GLubyte rgba[4] color to dest address */ -typedef void (*gl_pack_ubyte_rgba_func)(const GLubyte src[4], void *dst); - -/** Pack a GLfloat rgba[4] color to dest address */ -typedef void (*gl_pack_float_rgba_func)(const GLfloat src[4], void *dst); - -/** Pack a GLfloat Z value to dest address */ -typedef void (*gl_pack_float_z_func)(const GLfloat *src, void *dst); - -/** Pack a GLuint Z value to dest address */ -typedef void (*gl_pack_uint_z_func)(const GLuint *src, void *dst); - -/** Pack a GLubyte stencil value to dest address */ -typedef void (*gl_pack_ubyte_stencil_func)(const GLubyte *src, void *dst); - - - - -extern gl_pack_ubyte_rgba_func -_mesa_get_pack_ubyte_rgba_function(gl_format format); - - -extern gl_pack_float_rgba_func -_mesa_get_pack_float_rgba_function(gl_format format); - - -extern gl_pack_float_z_func -_mesa_get_pack_float_z_func(gl_format format); - - -extern gl_pack_uint_z_func -_mesa_get_pack_uint_z_func(gl_format format); - - -extern gl_pack_ubyte_stencil_func -_mesa_get_pack_ubyte_stencil_func(gl_format format); - - - -extern void -_mesa_pack_float_rgba_row(gl_format format, GLuint n, - const GLfloat src[][4], void *dst); - -extern void -_mesa_pack_ubyte_rgba_row(gl_format format, GLuint n, - const GLubyte src[][4], void *dst); - - - -extern void -_mesa_pack_float_z_row(gl_format format, GLuint n, - const GLfloat *src, void *dst); - -extern void -_mesa_pack_uint_z_row(gl_format format, GLuint n, - const GLuint *src, void *dst); - -extern void -_mesa_pack_ubyte_stencil_row(gl_format format, GLuint n, - const GLubyte *src, void *dst); - - -extern void -_mesa_pack_colormask(gl_format format, const GLubyte colorMask[4], void *dst); - -#endif diff --git a/dll/opengl/mesa/main/format_unpack.c b/dll/opengl/mesa/main/format_unpack.c deleted file mode 100644 index 73e40c18f13..00000000000 --- a/dll/opengl/mesa/main/format_unpack.c +++ /dev/null @@ -1,1862 +0,0 @@ -/* - * Mesa 3-D graphics library - * - * Copyright (c) 2011 VMware, Inc. - * - * Permission is hereby granted, free of charge, to any person obtaining a - * copy of this software and associated documentation files (the "Software"), - * to deal in the Software without restriction, including without limitation - * the rights to use, copy, modify, merge, publish, distribute, sublicense, - * and/or sell copies of the Software, and to permit persons to whom the - * Software is furnished to do so, subject to the following conditions: - * - * The above copyright notice and this permission notice shall be included - * in all copies or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS - * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL - * THE AUTHORS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN - * AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN - * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. - */ - -#include - -/* Expand 1, 2, 3, 4, 5, 6-bit values to fill 8 bits */ - -#define EXPAND_1_8(X) ( (X) ? 0xff : 0x0 ) - -#define EXPAND_2_8(X) ( ((X) << 6) | ((X) << 4) | ((X) << 2) | (X) ) - -#define EXPAND_3_8(X) ( ((X) << 5) | ((X) << 2) | ((X) >> 1) ) - -#define EXPAND_4_8(X) ( ((X) << 4) | (X) ) - -#define EXPAND_5_8(X) ( ((X) << 3) | ((X) >> 2) ) - -#define EXPAND_6_8(X) ( ((X) << 2) | ((X) >> 4) ) - -/**********************************************************************/ -/* Unpack, returning GLfloat colors */ -/**********************************************************************/ - -typedef void (*unpack_rgba_func)(const void *src, GLfloat dst[][4], GLuint n); - - -static void -unpack_RGBA8888(const void *src, GLfloat dst[][4], GLuint n) -{ - const GLuint *s = ((const GLuint *) src); - GLuint i; - for (i = 0; i < n; i++) { - dst[i][RCOMP] = UBYTE_TO_FLOAT( (s[i] >> 24) ); - dst[i][GCOMP] = UBYTE_TO_FLOAT( (s[i] >> 16) & 0xff ); - dst[i][BCOMP] = UBYTE_TO_FLOAT( (s[i] >> 8) & 0xff ); - dst[i][ACOMP] = UBYTE_TO_FLOAT( (s[i] ) & 0xff ); - } -} - -static void -unpack_RGBA8888_REV(const void *src, GLfloat dst[][4], GLuint n) -{ - const GLuint *s = ((const GLuint *) src); - GLuint i; - for (i = 0; i < n; i++) { - dst[i][RCOMP] = UBYTE_TO_FLOAT( (s[i] ) & 0xff ); - dst[i][GCOMP] = UBYTE_TO_FLOAT( (s[i] >> 8) & 0xff ); - dst[i][BCOMP] = UBYTE_TO_FLOAT( (s[i] >> 16) & 0xff ); - dst[i][ACOMP] = UBYTE_TO_FLOAT( (s[i] >> 24) ); - } -} - -static void -unpack_ARGB8888(const void *src, GLfloat dst[][4], GLuint n) -{ - const GLuint *s = ((const GLuint *) src); - GLuint i; - for (i = 0; i < n; i++) { - dst[i][RCOMP] = UBYTE_TO_FLOAT( (s[i] >> 16) & 0xff ); - dst[i][GCOMP] = UBYTE_TO_FLOAT( (s[i] >> 8) & 0xff ); - dst[i][BCOMP] = UBYTE_TO_FLOAT( (s[i] ) & 0xff ); - dst[i][ACOMP] = UBYTE_TO_FLOAT( (s[i] >> 24) ); - } -} - -static void -unpack_ARGB8888_REV(const void *src, GLfloat dst[][4], GLuint n) -{ - const GLuint *s = ((const GLuint *) src); - GLuint i; - for (i = 0; i < n; i++) { - dst[i][RCOMP] = UBYTE_TO_FLOAT( (s[i] >> 8) & 0xff ); - dst[i][GCOMP] = UBYTE_TO_FLOAT( (s[i] >> 16) & 0xff ); - dst[i][BCOMP] = UBYTE_TO_FLOAT( (s[i] >> 24) ); - dst[i][ACOMP] = UBYTE_TO_FLOAT( (s[i] ) & 0xff ); - } -} - -static void -unpack_RGBX8888(const void *src, GLfloat dst[][4], GLuint n) -{ - const GLuint *s = ((const GLuint *) src); - GLuint i; - for (i = 0; i < n; i++) { - dst[i][RCOMP] = UBYTE_TO_FLOAT( (s[i] >> 24) ); - dst[i][GCOMP] = UBYTE_TO_FLOAT( (s[i] >> 16) & 0xff ); - dst[i][BCOMP] = UBYTE_TO_FLOAT( (s[i] >> 8) & 0xff ); - dst[i][ACOMP] = 1.0f; - } -} - -static void -unpack_RGBX8888_REV(const void *src, GLfloat dst[][4], GLuint n) -{ - const GLuint *s = ((const GLuint *) src); - GLuint i; - for (i = 0; i < n; i++) { - dst[i][RCOMP] = UBYTE_TO_FLOAT( (s[i] ) & 0xff ); - dst[i][GCOMP] = UBYTE_TO_FLOAT( (s[i] >> 8) & 0xff ); - dst[i][BCOMP] = UBYTE_TO_FLOAT( (s[i] >> 16) & 0xff ); - dst[i][ACOMP] = 1.0f; - } -} - -static void -unpack_XRGB8888(const void *src, GLfloat dst[][4], GLuint n) -{ - const GLuint *s = ((const GLuint *) src); - GLuint i; - for (i = 0; i < n; i++) { - dst[i][RCOMP] = UBYTE_TO_FLOAT( (s[i] >> 16) & 0xff ); - dst[i][GCOMP] = UBYTE_TO_FLOAT( (s[i] >> 8) & 0xff ); - dst[i][BCOMP] = UBYTE_TO_FLOAT( (s[i] ) & 0xff ); - dst[i][ACOMP] = 1.0f; - } -} - -static void -unpack_XRGB8888_REV(const void *src, GLfloat dst[][4], GLuint n) -{ - const GLuint *s = ((const GLuint *) src); - GLuint i; - for (i = 0; i < n; i++) { - dst[i][RCOMP] = UBYTE_TO_FLOAT( (s[i] >> 8) & 0xff ); - dst[i][GCOMP] = UBYTE_TO_FLOAT( (s[i] >> 16) & 0xff ); - dst[i][BCOMP] = UBYTE_TO_FLOAT( (s[i] >> 24) ); - dst[i][ACOMP] = 1.0f; - } -} - -static void -unpack_RGB888(const void *src, GLfloat dst[][4], GLuint n) -{ - const GLubyte *s = (const GLubyte *) src; - GLuint i; - for (i = 0; i < n; i++) { - dst[i][RCOMP] = UBYTE_TO_FLOAT( s[i*3+2] ); - dst[i][GCOMP] = UBYTE_TO_FLOAT( s[i*3+1] ); - dst[i][BCOMP] = UBYTE_TO_FLOAT( s[i*3+0] ); - dst[i][ACOMP] = 1.0F; - } -} - -static void -unpack_BGR888(const void *src, GLfloat dst[][4], GLuint n) -{ - const GLubyte *s = (const GLubyte *) src; - GLuint i; - for (i = 0; i < n; i++) { - dst[i][RCOMP] = UBYTE_TO_FLOAT( s[i*3+0] ); - dst[i][GCOMP] = UBYTE_TO_FLOAT( s[i*3+1] ); - dst[i][BCOMP] = UBYTE_TO_FLOAT( s[i*3+2] ); - dst[i][ACOMP] = 1.0F; - } -} - -static void -unpack_RGB565(const void *src, GLfloat dst[][4], GLuint n) -{ - const GLushort *s = ((const GLushort *) src); - GLuint i; - for (i = 0; i < n; i++) { - dst[i][RCOMP] = ((s[i] >> 11) & 0x1f) * (1.0F / 31.0F); - dst[i][GCOMP] = ((s[i] >> 5 ) & 0x3f) * (1.0F / 63.0F); - dst[i][BCOMP] = ((s[i] ) & 0x1f) * (1.0F / 31.0F); - dst[i][ACOMP] = 1.0F; - } -} - -static void -unpack_RGB565_REV(const void *src, GLfloat dst[][4], GLuint n) -{ - const GLushort *s = ((const GLushort *) src); - GLuint i; - for (i = 0; i < n; i++) { - GLuint t = (s[i] >> 8) | (s[i] << 8); /* byte swap */ - dst[i][RCOMP] = UBYTE_TO_FLOAT( ((t >> 8) & 0xf8) | ((t >> 13) & 0x7) ); - dst[i][GCOMP] = UBYTE_TO_FLOAT( ((t >> 3) & 0xfc) | ((t >> 9) & 0x3) ); - dst[i][BCOMP] = UBYTE_TO_FLOAT( ((t << 3) & 0xf8) | ((t >> 2) & 0x7) ); - dst[i][ACOMP] = 1.0F; - } -} - -static void -unpack_ARGB4444(const void *src, GLfloat dst[][4], GLuint n) -{ - const GLushort *s = ((const GLushort *) src); - GLuint i; - for (i = 0; i < n; i++) { - dst[i][RCOMP] = ((s[i] >> 8) & 0xf) * (1.0F / 15.0F); - dst[i][GCOMP] = ((s[i] >> 4) & 0xf) * (1.0F / 15.0F); - dst[i][BCOMP] = ((s[i] ) & 0xf) * (1.0F / 15.0F); - dst[i][ACOMP] = ((s[i] >> 12) & 0xf) * (1.0F / 15.0F); - } -} - -static void -unpack_ARGB4444_REV(const void *src, GLfloat dst[][4], GLuint n) -{ - const GLushort *s = ((const GLushort *) src); - GLuint i; - for (i = 0; i < n; i++) { - dst[i][RCOMP] = ((s[i] ) & 0xf) * (1.0F / 15.0F); - dst[i][GCOMP] = ((s[i] >> 12) & 0xf) * (1.0F / 15.0F); - dst[i][BCOMP] = ((s[i] >> 8) & 0xf) * (1.0F / 15.0F); - dst[i][ACOMP] = ((s[i] >> 4) & 0xf) * (1.0F / 15.0F); - } -} - -static void -unpack_RGBA5551(const void *src, GLfloat dst[][4], GLuint n) -{ - const GLushort *s = ((const GLushort *) src); - GLuint i; - for (i = 0; i < n; i++) { - dst[i][RCOMP] = ((s[i] >> 11) & 0x1f) * (1.0F / 31.0F); - dst[i][GCOMP] = ((s[i] >> 6) & 0x1f) * (1.0F / 31.0F); - dst[i][BCOMP] = ((s[i] >> 1) & 0x1f) * (1.0F / 31.0F); - dst[i][ACOMP] = ((s[i] ) & 0x01) * 1.0F; - } -} - -static void -unpack_ARGB1555(const void *src, GLfloat dst[][4], GLuint n) -{ - const GLushort *s = ((const GLushort *) src); - GLuint i; - for (i = 0; i < n; i++) { - dst[i][RCOMP] = ((s[i] >> 10) & 0x1f) * (1.0F / 31.0F); - dst[i][GCOMP] = ((s[i] >> 5) & 0x1f) * (1.0F / 31.0F); - dst[i][BCOMP] = ((s[i] >> 0) & 0x1f) * (1.0F / 31.0F); - dst[i][ACOMP] = ((s[i] >> 15) & 0x01) * 1.0F; - } -} - -static void -unpack_ARGB1555_REV(const void *src, GLfloat dst[][4], GLuint n) -{ - const GLushort *s = ((const GLushort *) src); - GLuint i; - for (i = 0; i < n; i++) { - GLushort tmp = (s[i] << 8) | (s[i] >> 8); /* byteswap */ - dst[i][RCOMP] = ((tmp >> 10) & 0x1f) * (1.0F / 31.0F); - dst[i][GCOMP] = ((tmp >> 5) & 0x1f) * (1.0F / 31.0F); - dst[i][BCOMP] = ((tmp >> 0) & 0x1f) * (1.0F / 31.0F); - dst[i][ACOMP] = ((tmp >> 15) & 0x01) * 1.0F; - } -} - -static void -unpack_AL44(const void *src, GLfloat dst[][4], GLuint n) -{ - const GLubyte *s = ((const GLubyte *) src); - GLuint i; - for (i = 0; i < n; i++) { - dst[i][RCOMP] = - dst[i][GCOMP] = - dst[i][BCOMP] = (s[i] & 0xf) * (1.0F / 15.0F); - dst[i][ACOMP] = ((s[i] >> 4) & 0xf) * (1.0F / 15.0F); - } -} - -static void -unpack_AL88(const void *src, GLfloat dst[][4], GLuint n) -{ - const GLushort *s = ((const GLushort *) src); - GLuint i; - for (i = 0; i < n; i++) { - dst[i][RCOMP] = - dst[i][GCOMP] = - dst[i][BCOMP] = UBYTE_TO_FLOAT( s[i] & 0xff ); - dst[i][ACOMP] = UBYTE_TO_FLOAT( s[i] >> 8 ); - } -} - -static void -unpack_AL88_REV(const void *src, GLfloat dst[][4], GLuint n) -{ - const GLushort *s = ((const GLushort *) src); - GLuint i; - for (i = 0; i < n; i++) { - dst[i][RCOMP] = - dst[i][GCOMP] = - dst[i][BCOMP] = UBYTE_TO_FLOAT( s[i] >> 8 ); - dst[i][ACOMP] = UBYTE_TO_FLOAT( s[i] & 0xff ); - } -} - -static void -unpack_AL1616(const void *src, GLfloat dst[][4], GLuint n) -{ - const GLuint *s = ((const GLuint *) src); - GLuint i; - for (i = 0; i < n; i++) { - dst[i][RCOMP] = - dst[i][GCOMP] = - dst[i][BCOMP] = USHORT_TO_FLOAT( s[i] & 0xffff ); - dst[i][ACOMP] = USHORT_TO_FLOAT( s[i] >> 16 ); - } -} - -static void -unpack_AL1616_REV(const void *src, GLfloat dst[][4], GLuint n) -{ - const GLuint *s = ((const GLuint *) src); - GLuint i; - for (i = 0; i < n; i++) { - dst[i][RCOMP] = - dst[i][GCOMP] = - dst[i][BCOMP] = USHORT_TO_FLOAT( s[i] >> 16 ); - dst[i][ACOMP] = USHORT_TO_FLOAT( s[i] & 0xffff ); - } -} - -static void -unpack_RGB332(const void *src, GLfloat dst[][4], GLuint n) -{ - const GLubyte *s = ((const GLubyte *) src); - GLuint i; - for (i = 0; i < n; i++) { - dst[i][RCOMP] = ((s[i] >> 5) & 0x7) * (1.0F / 7.0F); - dst[i][GCOMP] = ((s[i] >> 2) & 0x7) * (1.0F / 7.0F); - dst[i][BCOMP] = ((s[i] ) & 0x3) * (1.0F / 3.0F); - dst[i][ACOMP] = 1.0F; - } -} - - -static void -unpack_A8(const void *src, GLfloat dst[][4], GLuint n) -{ - const GLubyte *s = ((const GLubyte *) src); - GLuint i; - for (i = 0; i < n; i++) { - dst[i][RCOMP] = - dst[i][GCOMP] = - dst[i][BCOMP] = 0.0F; - dst[i][ACOMP] = UBYTE_TO_FLOAT(s[i]); - } -} - -static void -unpack_A16(const void *src, GLfloat dst[][4], GLuint n) -{ - const GLushort *s = ((const GLushort *) src); - GLuint i; - for (i = 0; i < n; i++) { - dst[i][RCOMP] = - dst[i][GCOMP] = - dst[i][BCOMP] = 0.0F; - dst[i][ACOMP] = USHORT_TO_FLOAT(s[i]); - } -} - -static void -unpack_L8(const void *src, GLfloat dst[][4], GLuint n) -{ - const GLubyte *s = ((const GLubyte *) src); - GLuint i; - for (i = 0; i < n; i++) { - dst[i][RCOMP] = - dst[i][GCOMP] = - dst[i][BCOMP] = UBYTE_TO_FLOAT(s[i]); - dst[i][ACOMP] = 1.0F; - } -} - -static void -unpack_L16(const void *src, GLfloat dst[][4], GLuint n) -{ - const GLushort *s = ((const GLushort *) src); - GLuint i; - for (i = 0; i < n; i++) { - dst[i][RCOMP] = - dst[i][GCOMP] = - dst[i][BCOMP] = USHORT_TO_FLOAT(s[i]); - dst[i][ACOMP] = 1.0F; - } -} - -static void -unpack_I8(const void *src, GLfloat dst[][4], GLuint n) -{ - const GLubyte *s = ((const GLubyte *) src); - GLuint i; - for (i = 0; i < n; i++) { - dst[i][RCOMP] = - dst[i][GCOMP] = - dst[i][BCOMP] = - dst[i][ACOMP] = UBYTE_TO_FLOAT(s[i]); - } -} - -static void -unpack_I16(const void *src, GLfloat dst[][4], GLuint n) -{ - const GLushort *s = ((const GLushort *) src); - GLuint i; - for (i = 0; i < n; i++) { - dst[i][RCOMP] = - dst[i][GCOMP] = - dst[i][BCOMP] = - dst[i][ACOMP] = USHORT_TO_FLOAT(s[i]); - } -} - -static void -unpack_YCBCR(const void *src, GLfloat dst[][4], GLuint n) -{ - GLuint i; - for (i = 0; i < n; i++) { - const GLushort *src0 = ((const GLushort *) src) + i * 2; /* even */ - const GLushort *src1 = src0 + 1; /* odd */ - const GLubyte y0 = (*src0 >> 8) & 0xff; /* luminance */ - const GLubyte cb = *src0 & 0xff; /* chroma U */ - const GLubyte y1 = (*src1 >> 8) & 0xff; /* luminance */ - const GLubyte cr = *src1 & 0xff; /* chroma V */ - const GLubyte y = (i & 1) ? y1 : y0; /* choose even/odd luminance */ - GLfloat r = 1.164F * (y - 16) + 1.596F * (cr - 128); - GLfloat g = 1.164F * (y - 16) - 0.813F * (cr - 128) - 0.391F * (cb - 128); - GLfloat b = 1.164F * (y - 16) + 2.018F * (cb - 128); - r *= (1.0F / 255.0F); - g *= (1.0F / 255.0F); - b *= (1.0F / 255.0F); - dst[i][RCOMP] = CLAMP(r, 0.0F, 1.0F); - dst[i][GCOMP] = CLAMP(g, 0.0F, 1.0F); - dst[i][BCOMP] = CLAMP(b, 0.0F, 1.0F); - dst[i][ACOMP] = 1.0F; - } -} - -static void -unpack_YCBCR_REV(const void *src, GLfloat dst[][4], GLuint n) -{ - GLuint i; - for (i = 0; i < n; i++) { - const GLushort *src0 = ((const GLushort *) src) + i * 2; /* even */ - const GLushort *src1 = src0 + 1; /* odd */ - const GLubyte y0 = *src0 & 0xff; /* luminance */ - const GLubyte cr = (*src0 >> 8) & 0xff; /* chroma V */ - const GLubyte y1 = *src1 & 0xff; /* luminance */ - const GLubyte cb = (*src1 >> 8) & 0xff; /* chroma U */ - const GLubyte y = (i & 1) ? y1 : y0; /* choose even/odd luminance */ - GLfloat r = 1.164F * (y - 16) + 1.596F * (cr - 128); - GLfloat g = 1.164F * (y - 16) - 0.813F * (cr - 128) - 0.391F * (cb - 128); - GLfloat b = 1.164F * (y - 16) + 2.018F * (cb - 128); - r *= (1.0F / 255.0F); - g *= (1.0F / 255.0F); - b *= (1.0F / 255.0F); - dst[i][RCOMP] = CLAMP(r, 0.0F, 1.0F); - dst[i][GCOMP] = CLAMP(g, 0.0F, 1.0F); - dst[i][BCOMP] = CLAMP(b, 0.0F, 1.0F); - dst[i][ACOMP] = 1.0F; - } -} - - -static void -unpack_Z24_S8(const void *src, GLfloat dst[][4], GLuint n) -{ - /* only return Z, not stencil data */ - const GLuint *s = ((const GLuint *) src); - const GLdouble scale = 1.0 / (GLdouble) 0xffffff; - GLuint i; - for (i = 0; i < n; i++) { - dst[i][0] = - dst[i][1] = - dst[i][2] = (s[i] >> 8) * scale; - dst[i][3] = 1.0F; - ASSERT(dst[i][0] >= 0.0F); - ASSERT(dst[i][0] <= 1.0F); - } -} - -static void -unpack_S8_Z24(const void *src, GLfloat dst[][4], GLuint n) -{ - /* only return Z, not stencil data */ - const GLuint *s = ((const GLuint *) src); - const GLdouble scale = 1.0 / (GLdouble) 0xffffff; - GLuint i; - for (i = 0; i < n; i++) { - dst[i][0] = - dst[i][1] = - dst[i][2] = (s[i] & 0x00ffffff) * scale; - dst[i][3] = 1.0F; - ASSERT(dst[i][0] >= 0.0F); - ASSERT(dst[i][0] <= 1.0F); - } -} - -static void -unpack_Z16(const void *src, GLfloat dst[][4], GLuint n) -{ - const GLushort *s = ((const GLushort *) src); - GLuint i; - for (i = 0; i < n; i++) { - dst[i][0] = - dst[i][1] = - dst[i][2] = s[i] * (1.0F / 65535.0F); - dst[i][3] = 1.0F; - } -} - -static void -unpack_X8_Z24(const void *src, GLfloat dst[][4], GLuint n) -{ - unpack_S8_Z24(src, dst, n); -} - -static void -unpack_Z24_X8(const void *src, GLfloat dst[][4], GLuint n) -{ - unpack_Z24_S8(src, dst, n); -} - -static void -unpack_Z32(const void *src, GLfloat dst[][4], GLuint n) -{ - const GLuint *s = ((const GLuint *) src); - GLuint i; - for (i = 0; i < n; i++) { - dst[i][0] = - dst[i][1] = - dst[i][2] = s[i] * (1.0F / 0xffffffff); - dst[i][3] = 1.0F; - } -} - - -static void -unpack_S8(const void *src, GLfloat dst[][4], GLuint n) -{ - /* should never be used */ - GLuint i; - for (i = 0; i < n; i++) { - dst[i][0] = - dst[i][1] = - dst[i][2] = 0.0F; - dst[i][3] = 1.0F; - } -} - -static void -unpack_RGBA_INT8(const void *src, GLfloat dst[][4], GLuint n) -{ - const GLbyte *s = (const GLbyte *) src; - GLuint i; - for (i = 0; i < n; i++) { - dst[i][RCOMP] = (GLfloat) s[i*4+0]; - dst[i][GCOMP] = (GLfloat) s[i*4+1]; - dst[i][BCOMP] = (GLfloat) s[i*4+2]; - dst[i][ACOMP] = (GLfloat) s[i*4+3]; - } -} - -static void -unpack_RGBA_INT16(const void *src, GLfloat dst[][4], GLuint n) -{ - const GLshort *s = (const GLshort *) src; - GLuint i; - for (i = 0; i < n; i++) { - dst[i][RCOMP] = (GLfloat) s[i*4+0]; - dst[i][GCOMP] = (GLfloat) s[i*4+1]; - dst[i][BCOMP] = (GLfloat) s[i*4+2]; - dst[i][ACOMP] = (GLfloat) s[i*4+3]; - } -} - -static void -unpack_RGBA_INT32(const void *src, GLfloat dst[][4], GLuint n) -{ - const GLint *s = (const GLint *) src; - GLuint i; - for (i = 0; i < n; i++) { - dst[i][RCOMP] = (GLfloat) s[i*4+0]; - dst[i][GCOMP] = (GLfloat) s[i*4+1]; - dst[i][BCOMP] = (GLfloat) s[i*4+2]; - dst[i][ACOMP] = (GLfloat) s[i*4+3]; - } -} - -static void -unpack_RGBA_UINT8(const void *src, GLfloat dst[][4], GLuint n) -{ - const GLubyte *s = (const GLubyte *) src; - GLuint i; - for (i = 0; i < n; i++) { - dst[i][RCOMP] = (GLfloat) s[i*4+0]; - dst[i][GCOMP] = (GLfloat) s[i*4+1]; - dst[i][BCOMP] = (GLfloat) s[i*4+2]; - dst[i][ACOMP] = (GLfloat) s[i*4+3]; - } -} - -static void -unpack_RGBA_UINT16(const void *src, GLfloat dst[][4], GLuint n) -{ - const GLushort *s = (const GLushort *) src; - GLuint i; - for (i = 0; i < n; i++) { - dst[i][RCOMP] = (GLfloat) s[i*4+0]; - dst[i][GCOMP] = (GLfloat) s[i*4+1]; - dst[i][BCOMP] = (GLfloat) s[i*4+2]; - dst[i][ACOMP] = (GLfloat) s[i*4+3]; - } -} - -static void -unpack_RGBA_UINT32(const void *src, GLfloat dst[][4], GLuint n) -{ - const GLuint *s = (const GLuint *) src; - GLuint i; - for (i = 0; i < n; i++) { - dst[i][RCOMP] = (GLfloat) s[i*4+0]; - dst[i][GCOMP] = (GLfloat) s[i*4+1]; - dst[i][BCOMP] = (GLfloat) s[i*4+2]; - dst[i][ACOMP] = (GLfloat) s[i*4+3]; - } -} - -static void -unpack_SIGNED_RGBA_16(const void *src, GLfloat dst[][4], GLuint n) -{ - const GLshort *s = (const GLshort *) src; - GLuint i; - for (i = 0; i < n; i++) { - dst[i][RCOMP] = SHORT_TO_FLOAT_TEX( s[i*4+0] ); - dst[i][GCOMP] = SHORT_TO_FLOAT_TEX( s[i*4+1] ); - dst[i][BCOMP] = SHORT_TO_FLOAT_TEX( s[i*4+2] ); - dst[i][ACOMP] = SHORT_TO_FLOAT_TEX( s[i*4+3] ); - } -} - -static void -unpack_RGBA_16(const void *src, GLfloat dst[][4], GLuint n) -{ - const GLushort *s = (const GLushort *) src; - GLuint i; - for (i = 0; i < n; i++) { - dst[i][RCOMP] = USHORT_TO_FLOAT( s[i*4+0] ); - dst[i][GCOMP] = USHORT_TO_FLOAT( s[i*4+1] ); - dst[i][BCOMP] = USHORT_TO_FLOAT( s[i*4+2] ); - dst[i][ACOMP] = USHORT_TO_FLOAT( s[i*4+3] ); - } -} - - -/** - * Return the unpacker function for the given format. - */ -static unpack_rgba_func -get_unpack_rgba_function(gl_format format) -{ - static unpack_rgba_func table[MESA_FORMAT_COUNT]; - static GLboolean initialized = GL_FALSE; - - if (!initialized) { - table[MESA_FORMAT_NONE] = NULL; - - table[MESA_FORMAT_RGBA8888] = unpack_RGBA8888; - table[MESA_FORMAT_RGBA8888_REV] = unpack_RGBA8888_REV; - table[MESA_FORMAT_ARGB8888] = unpack_ARGB8888; - table[MESA_FORMAT_ARGB8888_REV] = unpack_ARGB8888_REV; - table[MESA_FORMAT_RGBX8888] = unpack_RGBX8888; - table[MESA_FORMAT_RGBX8888_REV] = unpack_RGBX8888_REV; - table[MESA_FORMAT_XRGB8888] = unpack_XRGB8888; - table[MESA_FORMAT_XRGB8888_REV] = unpack_XRGB8888_REV; - table[MESA_FORMAT_RGB888] = unpack_RGB888; - table[MESA_FORMAT_BGR888] = unpack_BGR888; - table[MESA_FORMAT_RGB565] = unpack_RGB565; - table[MESA_FORMAT_RGB565_REV] = unpack_RGB565_REV; - table[MESA_FORMAT_ARGB4444] = unpack_ARGB4444; - table[MESA_FORMAT_ARGB4444_REV] = unpack_ARGB4444_REV; - table[MESA_FORMAT_RGBA5551] = unpack_RGBA5551; - table[MESA_FORMAT_ARGB1555] = unpack_ARGB1555; - table[MESA_FORMAT_ARGB1555_REV] = unpack_ARGB1555_REV; - table[MESA_FORMAT_AL44] = unpack_AL44; - table[MESA_FORMAT_AL88] = unpack_AL88; - table[MESA_FORMAT_AL88_REV] = unpack_AL88_REV; - table[MESA_FORMAT_AL1616] = unpack_AL1616; - table[MESA_FORMAT_AL1616_REV] = unpack_AL1616_REV; - table[MESA_FORMAT_RGB332] = unpack_RGB332; - table[MESA_FORMAT_A8] = unpack_A8; - table[MESA_FORMAT_A16] = unpack_A16; - table[MESA_FORMAT_L8] = unpack_L8; - table[MESA_FORMAT_L16] = unpack_L16; - table[MESA_FORMAT_I8] = unpack_I8; - table[MESA_FORMAT_I16] = unpack_I16; - table[MESA_FORMAT_YCBCR] = unpack_YCBCR; - table[MESA_FORMAT_YCBCR_REV] = unpack_YCBCR_REV; - table[MESA_FORMAT_Z16] = unpack_Z16; - table[MESA_FORMAT_X8_Z24] = unpack_X8_Z24; - table[MESA_FORMAT_Z24_X8] = unpack_Z24_X8; - table[MESA_FORMAT_Z32] = unpack_Z32; - table[MESA_FORMAT_S8] = unpack_S8; - - table[MESA_FORMAT_RGBA_INT8] = unpack_RGBA_INT8; - table[MESA_FORMAT_RGBA_INT16] = unpack_RGBA_INT16; - table[MESA_FORMAT_RGBA_INT32] = unpack_RGBA_INT32; - table[MESA_FORMAT_RGBA_UINT8] = unpack_RGBA_UINT8; - table[MESA_FORMAT_RGBA_UINT16] = unpack_RGBA_UINT16; - table[MESA_FORMAT_RGBA_UINT32] = unpack_RGBA_UINT32; - - table[MESA_FORMAT_SIGNED_RGBA_16] = unpack_SIGNED_RGBA_16; - table[MESA_FORMAT_RGBA_16] = unpack_RGBA_16; - - initialized = GL_TRUE; - } - - return table[format]; -} - - -/** - * Unpack rgba colors, returning as GLfloat values. - */ -void -_mesa_unpack_rgba_row(gl_format format, GLuint n, - const void *src, GLfloat dst[][4]) -{ - unpack_rgba_func unpack = get_unpack_rgba_function(format); - unpack(src, dst, n); -} - - -/**********************************************************************/ -/* Unpack, returning GLubyte colors */ -/**********************************************************************/ - - -static void -unpack_ubyte_RGBA8888(const void *src, GLubyte dst[][4], GLuint n) -{ - const GLuint *s = ((const GLuint *) src); - GLuint i; - for (i = 0; i < n; i++) { - dst[i][RCOMP] = (s[i] >> 24); - dst[i][GCOMP] = (s[i] >> 16) & 0xff; - dst[i][BCOMP] = (s[i] >> 8) & 0xff; - dst[i][ACOMP] = (s[i] ) & 0xff; - } -} - -static void -unpack_ubyte_RGBA8888_REV(const void *src, GLubyte dst[][4], GLuint n) -{ - const GLuint *s = ((const GLuint *) src); - GLuint i; - for (i = 0; i < n; i++) { - dst[i][RCOMP] = (s[i] ) & 0xff; - dst[i][GCOMP] = (s[i] >> 8) & 0xff; - dst[i][BCOMP] = (s[i] >> 16) & 0xff; - dst[i][ACOMP] = (s[i] >> 24); - } -} - -static void -unpack_ubyte_ARGB8888(const void *src, GLubyte dst[][4], GLuint n) -{ - const GLuint *s = ((const GLuint *) src); - GLuint i; - for (i = 0; i < n; i++) { - dst[i][RCOMP] = (s[i] >> 16) & 0xff; - dst[i][GCOMP] = (s[i] >> 8) & 0xff; - dst[i][BCOMP] = (s[i] ) & 0xff; - dst[i][ACOMP] = (s[i] >> 24); - } -} - -static void -unpack_ubyte_ARGB8888_REV(const void *src, GLubyte dst[][4], GLuint n) -{ - const GLuint *s = ((const GLuint *) src); - GLuint i; - for (i = 0; i < n; i++) { - dst[i][RCOMP] = (s[i] >> 8) & 0xff; - dst[i][GCOMP] = (s[i] >> 16) & 0xff; - dst[i][BCOMP] = (s[i] >> 24); - dst[i][ACOMP] = (s[i] ) & 0xff; - } -} - -static void -unpack_ubyte_RGBX8888(const void *src, GLubyte dst[][4], GLuint n) -{ - const GLuint *s = ((const GLuint *) src); - GLuint i; - for (i = 0; i < n; i++) { - dst[i][RCOMP] = (s[i] >> 24); - dst[i][GCOMP] = (s[i] >> 16) & 0xff; - dst[i][BCOMP] = (s[i] >> 8) & 0xff; - dst[i][ACOMP] = 0xff; - } -} - -static void -unpack_ubyte_RGBX8888_REV(const void *src, GLubyte dst[][4], GLuint n) -{ - const GLuint *s = ((const GLuint *) src); - GLuint i; - for (i = 0; i < n; i++) { - dst[i][RCOMP] = (s[i] ) & 0xff; - dst[i][GCOMP] = (s[i] >> 8) & 0xff; - dst[i][BCOMP] = (s[i] >> 16) & 0xff; - dst[i][ACOMP] = 0xff; - } -} - -static void -unpack_ubyte_XRGB8888(const void *src, GLubyte dst[][4], GLuint n) -{ - const GLuint *s = ((const GLuint *) src); - GLuint i; - for (i = 0; i < n; i++) { - dst[i][RCOMP] = (s[i] >> 16) & 0xff; - dst[i][GCOMP] = (s[i] >> 8) & 0xff; - dst[i][BCOMP] = (s[i] ) & 0xff; - dst[i][ACOMP] = 0xff; - } -} - -static void -unpack_ubyte_XRGB8888_REV(const void *src, GLubyte dst[][4], GLuint n) -{ - const GLuint *s = ((const GLuint *) src); - GLuint i; - for (i = 0; i < n; i++) { - dst[i][RCOMP] = (s[i] >> 8) & 0xff; - dst[i][GCOMP] = (s[i] >> 16) & 0xff; - dst[i][BCOMP] = (s[i] >> 24); - dst[i][ACOMP] = 0xff; - } -} - -static void -unpack_ubyte_RGB888(const void *src, GLubyte dst[][4], GLuint n) -{ - const GLubyte *s = (const GLubyte *) src; - GLuint i; - for (i = 0; i < n; i++) { - dst[i][RCOMP] = s[i*3+2]; - dst[i][GCOMP] = s[i*3+1]; - dst[i][BCOMP] = s[i*3+0]; - dst[i][ACOMP] = 0xff; - } -} - -static void -unpack_ubyte_BGR888(const void *src, GLubyte dst[][4], GLuint n) -{ - const GLubyte *s = (const GLubyte *) src; - GLuint i; - for (i = 0; i < n; i++) { - dst[i][RCOMP] = s[i*3+0]; - dst[i][GCOMP] = s[i*3+1]; - dst[i][BCOMP] = s[i*3+2]; - dst[i][ACOMP] = 0xff; - } -} - -static void -unpack_ubyte_RGB565(const void *src, GLubyte dst[][4], GLuint n) -{ - const GLushort *s = ((const GLushort *) src); - GLuint i; - for (i = 0; i < n; i++) { - dst[i][RCOMP] = EXPAND_5_8((s[i] >> 11) & 0x1f); - dst[i][GCOMP] = EXPAND_6_8((s[i] >> 5 ) & 0x3f); - dst[i][BCOMP] = EXPAND_5_8( s[i] & 0x1f); - dst[i][ACOMP] = 0xff; - } -} - -static void -unpack_ubyte_RGB565_REV(const void *src, GLubyte dst[][4], GLuint n) -{ - const GLushort *s = ((const GLushort *) src); - GLuint i; - for (i = 0; i < n; i++) { - GLuint t = (s[i] >> 8) | (s[i] << 8); /* byte swap */ - dst[i][RCOMP] = EXPAND_5_8((t >> 11) & 0x1f); - dst[i][GCOMP] = EXPAND_6_8((t >> 5 ) & 0x3f); - dst[i][BCOMP] = EXPAND_5_8( t & 0x1f); - dst[i][ACOMP] = 0xff; - } -} - -static void -unpack_ubyte_ARGB4444(const void *src, GLubyte dst[][4], GLuint n) -{ - const GLushort *s = ((const GLushort *) src); - GLuint i; - for (i = 0; i < n; i++) { - dst[i][RCOMP] = EXPAND_4_8((s[i] >> 8) & 0xf); - dst[i][GCOMP] = EXPAND_4_8((s[i] >> 4) & 0xf); - dst[i][BCOMP] = EXPAND_4_8((s[i] ) & 0xf); - dst[i][ACOMP] = EXPAND_4_8((s[i] >> 12) & 0xf); - } -} - -static void -unpack_ubyte_ARGB4444_REV(const void *src, GLubyte dst[][4], GLuint n) -{ - const GLushort *s = ((const GLushort *) src); - GLuint i; - for (i = 0; i < n; i++) { - dst[i][RCOMP] = EXPAND_4_8((s[i] ) & 0xf); - dst[i][GCOMP] = EXPAND_4_8((s[i] >> 12) & 0xf); - dst[i][BCOMP] = EXPAND_4_8((s[i] >> 8) & 0xf); - dst[i][ACOMP] = EXPAND_4_8((s[i] >> 4) & 0xf); - } -} - -static void -unpack_ubyte_RGBA5551(const void *src, GLubyte dst[][4], GLuint n) -{ - const GLushort *s = ((const GLushort *) src); - GLuint i; - for (i = 0; i < n; i++) { - dst[i][RCOMP] = EXPAND_5_8((s[i] >> 11) & 0x1f); - dst[i][GCOMP] = EXPAND_5_8((s[i] >> 6) & 0x1f); - dst[i][BCOMP] = EXPAND_5_8((s[i] >> 1) & 0x1f); - dst[i][ACOMP] = EXPAND_1_8((s[i] ) & 0x01); - } -} - -static void -unpack_ubyte_ARGB1555(const void *src, GLubyte dst[][4], GLuint n) -{ - const GLushort *s = ((const GLushort *) src); - GLuint i; - for (i = 0; i < n; i++) { - dst[i][RCOMP] = EXPAND_5_8((s[i] >> 10) & 0x1f); - dst[i][GCOMP] = EXPAND_5_8((s[i] >> 5) & 0x1f); - dst[i][BCOMP] = EXPAND_5_8((s[i] >> 0) & 0x1f); - dst[i][ACOMP] = EXPAND_1_8((s[i] >> 15) & 0x01); - } -} - -static void -unpack_ubyte_ARGB1555_REV(const void *src, GLubyte dst[][4], GLuint n) -{ - const GLushort *s = ((const GLushort *) src); - GLuint i; - for (i = 0; i < n; i++) { - GLushort tmp = (s[i] << 8) | (s[i] >> 8); /* byteswap */ - dst[i][RCOMP] = EXPAND_5_8((tmp >> 10) & 0x1f); - dst[i][GCOMP] = EXPAND_5_8((tmp >> 5) & 0x1f); - dst[i][BCOMP] = EXPAND_5_8((tmp >> 0) & 0x1f); - dst[i][ACOMP] = EXPAND_1_8((tmp >> 15) & 0x01); - } -} - -static void -unpack_ubyte_AL44(const void *src, GLubyte dst[][4], GLuint n) -{ - const GLubyte *s = ((const GLubyte *) src); - GLuint i; - for (i = 0; i < n; i++) { - dst[i][RCOMP] = - dst[i][GCOMP] = - dst[i][BCOMP] = EXPAND_4_8(s[i] & 0xf); - dst[i][ACOMP] = EXPAND_4_8(s[i] >> 4); - } -} - -static void -unpack_ubyte_AL88(const void *src, GLubyte dst[][4], GLuint n) -{ - const GLushort *s = ((const GLushort *) src); - GLuint i; - for (i = 0; i < n; i++) { - dst[i][RCOMP] = - dst[i][GCOMP] = - dst[i][BCOMP] = EXPAND_4_8(s[i] & 0xff); - dst[i][ACOMP] = EXPAND_4_8(s[i] >> 8); - } -} - -static void -unpack_ubyte_AL88_REV(const void *src, GLubyte dst[][4], GLuint n) -{ - const GLushort *s = ((const GLushort *) src); - GLuint i; - for (i = 0; i < n; i++) { - dst[i][RCOMP] = - dst[i][GCOMP] = - dst[i][BCOMP] = EXPAND_4_8(s[i] >> 8); - dst[i][ACOMP] = EXPAND_4_8(s[i] & 0xff); - } -} - -static void -unpack_ubyte_RGB332(const void *src, GLubyte dst[][4], GLuint n) -{ - const GLubyte *s = ((const GLubyte *) src); - GLuint i; - for (i = 0; i < n; i++) { - dst[i][RCOMP] = EXPAND_3_8((s[i] >> 5) & 0x7); - dst[i][GCOMP] = EXPAND_3_8((s[i] >> 2) & 0x7); - dst[i][BCOMP] = EXPAND_2_8((s[i] ) & 0x3); - dst[i][ACOMP] = 0xff; - } -} - -static void -unpack_ubyte_A8(const void *src, GLubyte dst[][4], GLuint n) -{ - const GLubyte *s = ((const GLubyte *) src); - GLuint i; - for (i = 0; i < n; i++) { - dst[i][RCOMP] = - dst[i][GCOMP] = - dst[i][BCOMP] = 0; - dst[i][ACOMP] = s[i]; - } -} - -static void -unpack_ubyte_L8(const void *src, GLubyte dst[][4], GLuint n) -{ - const GLubyte *s = ((const GLubyte *) src); - GLuint i; - for (i = 0; i < n; i++) { - dst[i][RCOMP] = - dst[i][GCOMP] = - dst[i][BCOMP] = s[i]; - dst[i][ACOMP] = 0xff; - } -} - - -static void -unpack_ubyte_I8(const void *src, GLubyte dst[][4], GLuint n) -{ - const GLubyte *s = ((const GLubyte *) src); - GLuint i; - for (i = 0; i < n; i++) { - dst[i][RCOMP] = - dst[i][GCOMP] = - dst[i][BCOMP] = - dst[i][ACOMP] = s[i]; - } -} - - -/** - * Unpack rgba colors, returning as GLubyte values. This should usually - * only be used for unpacking formats that use 8 bits or less per channel. - */ -void -_mesa_unpack_ubyte_rgba_row(gl_format format, GLuint n, - const void *src, GLubyte dst[][4]) -{ - switch (format) { - case MESA_FORMAT_RGBA8888: - unpack_ubyte_RGBA8888(src, dst, n); - break; - case MESA_FORMAT_RGBA8888_REV: - unpack_ubyte_RGBA8888_REV(src, dst, n); - break; - case MESA_FORMAT_ARGB8888: - unpack_ubyte_ARGB8888(src, dst, n); - break; - case MESA_FORMAT_ARGB8888_REV: - unpack_ubyte_ARGB8888_REV(src, dst, n); - break; - case MESA_FORMAT_RGBX8888: - unpack_ubyte_RGBX8888(src, dst, n); - break; - case MESA_FORMAT_RGBX8888_REV: - unpack_ubyte_RGBX8888_REV(src, dst, n); - break; - case MESA_FORMAT_XRGB8888: - unpack_ubyte_XRGB8888(src, dst, n); - break; - case MESA_FORMAT_XRGB8888_REV: - unpack_ubyte_XRGB8888_REV(src, dst, n); - break; - case MESA_FORMAT_RGB888: - unpack_ubyte_RGB888(src, dst, n); - break; - case MESA_FORMAT_BGR888: - unpack_ubyte_BGR888(src, dst, n); - break; - case MESA_FORMAT_RGB565: - unpack_ubyte_RGB565(src, dst, n); - break; - case MESA_FORMAT_RGB565_REV: - unpack_ubyte_RGB565_REV(src, dst, n); - break; - case MESA_FORMAT_ARGB4444: - unpack_ubyte_ARGB4444(src, dst, n); - break; - case MESA_FORMAT_ARGB4444_REV: - unpack_ubyte_ARGB4444_REV(src, dst, n); - break; - case MESA_FORMAT_RGBA5551: - unpack_ubyte_RGBA5551(src, dst, n); - break; - case MESA_FORMAT_ARGB1555: - unpack_ubyte_ARGB1555(src, dst, n); - break; - case MESA_FORMAT_ARGB1555_REV: - unpack_ubyte_ARGB1555_REV(src, dst, n); - break; - case MESA_FORMAT_AL44: - unpack_ubyte_AL44(src, dst, n); - break; - case MESA_FORMAT_AL88: - unpack_ubyte_AL88(src, dst, n); - break; - case MESA_FORMAT_AL88_REV: - unpack_ubyte_AL88_REV(src, dst, n); - break; - case MESA_FORMAT_RGB332: - unpack_ubyte_RGB332(src, dst, n); - break; - case MESA_FORMAT_A8: - unpack_ubyte_A8(src, dst, n); - break; - case MESA_FORMAT_L8: - unpack_ubyte_L8(src, dst, n); - break; - case MESA_FORMAT_I8: - unpack_ubyte_I8(src, dst, n); - break; - default: - /* get float values, convert to ubyte */ - { - GLfloat *tmp = (GLfloat *) malloc(n * 4 * sizeof(GLfloat)); - if (tmp) { - GLuint i; - _mesa_unpack_rgba_row(format, n, src, (GLfloat (*)[4]) tmp); - for (i = 0; i < n; i++) { - UNCLAMPED_FLOAT_TO_UBYTE(dst[i][0], tmp[i*4+0]); - UNCLAMPED_FLOAT_TO_UBYTE(dst[i][1], tmp[i*4+1]); - UNCLAMPED_FLOAT_TO_UBYTE(dst[i][2], tmp[i*4+2]); - UNCLAMPED_FLOAT_TO_UBYTE(dst[i][3], tmp[i*4+3]); - } - free(tmp); - } - } - break; - } -} - - -/**********************************************************************/ -/* Unpack, returning GLuint colors */ -/**********************************************************************/ - -static void -unpack_int_rgba_RGBA_UINT32(const GLuint *src, GLuint dst[][4], GLuint n) -{ - memcpy(dst, src, n * 4 * sizeof(GLuint)); -} - -static void -unpack_int_rgba_RGBA_UINT16(const GLushort *src, GLuint dst[][4], GLuint n) -{ - unsigned int i; - - for (i = 0; i < n; i++) { - dst[i][0] = src[i * 4 + 0]; - dst[i][1] = src[i * 4 + 1]; - dst[i][2] = src[i * 4 + 2]; - dst[i][3] = src[i * 4 + 3]; - } -} - -static void -unpack_int_rgba_RGBA_INT16(const GLshort *src, GLuint dst[][4], GLuint n) -{ - unsigned int i; - - for (i = 0; i < n; i++) { - dst[i][0] = src[i * 4 + 0]; - dst[i][1] = src[i * 4 + 1]; - dst[i][2] = src[i * 4 + 2]; - dst[i][3] = src[i * 4 + 3]; - } -} - -static void -unpack_int_rgba_RGBA_UINT8(const GLubyte *src, GLuint dst[][4], GLuint n) -{ - unsigned int i; - - for (i = 0; i < n; i++) { - dst[i][0] = src[i * 4 + 0]; - dst[i][1] = src[i * 4 + 1]; - dst[i][2] = src[i * 4 + 2]; - dst[i][3] = src[i * 4 + 3]; - } -} - -static void -unpack_int_rgba_RGBA_INT8(const GLbyte *src, GLuint dst[][4], GLuint n) -{ - unsigned int i; - - for (i = 0; i < n; i++) { - dst[i][0] = src[i * 4 + 0]; - dst[i][1] = src[i * 4 + 1]; - dst[i][2] = src[i * 4 + 2]; - dst[i][3] = src[i * 4 + 3]; - } -} - -static void -unpack_int_rgba_RGB_UINT32(const GLuint *src, GLuint dst[][4], GLuint n) -{ - unsigned int i; - - for (i = 0; i < n; i++) { - dst[i][0] = src[i * 3 + 0]; - dst[i][1] = src[i * 3 + 1]; - dst[i][2] = src[i * 3 + 2]; - dst[i][3] = 1; - } -} - -static void -unpack_int_rgba_RGB_UINT16(const GLushort *src, GLuint dst[][4], GLuint n) -{ - unsigned int i; - - for (i = 0; i < n; i++) { - dst[i][0] = src[i * 3 + 0]; - dst[i][1] = src[i * 3 + 1]; - dst[i][2] = src[i * 3 + 2]; - dst[i][3] = 1; - } -} - -static void -unpack_int_rgba_RGB_INT16(const GLshort *src, GLuint dst[][4], GLuint n) -{ - unsigned int i; - - for (i = 0; i < n; i++) { - dst[i][0] = src[i * 3 + 0]; - dst[i][1] = src[i * 3 + 1]; - dst[i][2] = src[i * 3 + 2]; - dst[i][3] = 1; - } -} - -static void -unpack_int_rgba_RGB_UINT8(const GLubyte *src, GLuint dst[][4], GLuint n) -{ - unsigned int i; - - for (i = 0; i < n; i++) { - dst[i][0] = src[i * 3 + 0]; - dst[i][1] = src[i * 3 + 1]; - dst[i][2] = src[i * 3 + 2]; - dst[i][3] = 1; - } -} - -static void -unpack_int_rgba_RGB_INT8(const GLbyte *src, GLuint dst[][4], GLuint n) -{ - unsigned int i; - - for (i = 0; i < n; i++) { - dst[i][0] = src[i * 3 + 0]; - dst[i][1] = src[i * 3 + 1]; - dst[i][2] = src[i * 3 + 2]; - dst[i][3] = 1; - } -} - -static void -unpack_int_rgba_ALPHA_UINT32(const GLuint *src, GLuint dst[][4], GLuint n) -{ - unsigned int i; - - for (i = 0; i < n; i++) { - dst[i][0] = dst[i][1] = dst[i][2] = 0; - dst[i][3] = src[i]; - } -} - -static void -unpack_int_rgba_ALPHA_UINT16(const GLushort *src, GLuint dst[][4], GLuint n) -{ - unsigned int i; - - for (i = 0; i < n; i++) { - dst[i][0] = dst[i][1] = dst[i][2] = 0; - dst[i][3] = src[i]; - } -} - -static void -unpack_int_rgba_ALPHA_INT16(const GLshort *src, GLuint dst[][4], GLuint n) -{ - unsigned int i; - - for (i = 0; i < n; i++) { - dst[i][0] = dst[i][1] = dst[i][2] = 0; - dst[i][3] = src[i]; - } -} - -static void -unpack_int_rgba_ALPHA_UINT8(const GLubyte *src, GLuint dst[][4], GLuint n) -{ - unsigned int i; - - for (i = 0; i < n; i++) { - dst[i][0] = dst[i][1] = dst[i][2] = 0; - dst[i][3] = src[i]; - } -} - -static void -unpack_int_rgba_ALPHA_INT8(const GLbyte *src, GLuint dst[][4], GLuint n) -{ - unsigned int i; - - for (i = 0; i < n; i++) { - dst[i][0] = dst[i][1] = dst[i][2] = 0; - dst[i][3] = src[i]; - } -} - -static void -unpack_int_rgba_LUMINANCE_UINT32(const GLuint *src, GLuint dst[][4], GLuint n) -{ - unsigned int i; - - for (i = 0; i < n; i++) { - dst[i][0] = dst[i][1] = dst[i][2] = src[i]; - dst[i][3] = 1; - } -} - -static void -unpack_int_rgba_LUMINANCE_UINT16(const GLushort *src, GLuint dst[][4], GLuint n) -{ - unsigned int i; - - for (i = 0; i < n; i++) { - dst[i][0] = dst[i][1] = dst[i][2] = src[i]; - dst[i][3] = 1; - } -} - -static void -unpack_int_rgba_LUMINANCE_INT16(const GLshort *src, GLuint dst[][4], GLuint n) -{ - unsigned int i; - - for (i = 0; i < n; i++) { - dst[i][0] = dst[i][1] = dst[i][2] = src[i]; - dst[i][3] = 1; - } -} - -static void -unpack_int_rgba_LUMINANCE_UINT8(const GLubyte *src, GLuint dst[][4], GLuint n) -{ - unsigned int i; - - for (i = 0; i < n; i++) { - dst[i][0] = dst[i][1] = dst[i][2] = src[i]; - dst[i][3] = 1; - } -} - -static void -unpack_int_rgba_LUMINANCE_INT8(const GLbyte *src, GLuint dst[][4], GLuint n) -{ - unsigned int i; - - for (i = 0; i < n; i++) { - dst[i][0] = dst[i][1] = dst[i][2] = src[i]; - dst[i][3] = 1; - } -} - - -static void -unpack_int_rgba_LUMINANCE_ALPHA_UINT32(const GLuint *src, GLuint dst[][4], GLuint n) -{ - unsigned int i; - - for (i = 0; i < n; i++) { - dst[i][0] = dst[i][1] = dst[i][2] = src[i * 2 + 0]; - dst[i][3] = src[i * 2 + 1]; - } -} - -static void -unpack_int_rgba_LUMINANCE_ALPHA_UINT16(const GLushort *src, GLuint dst[][4], GLuint n) -{ - unsigned int i; - - for (i = 0; i < n; i++) { - dst[i][0] = dst[i][1] = dst[i][2] = src[i * 2 + 0]; - dst[i][3] = src[i * 2 + 1]; - } -} - -static void -unpack_int_rgba_LUMINANCE_ALPHA_INT16(const GLshort *src, GLuint dst[][4], GLuint n) -{ - unsigned int i; - - for (i = 0; i < n; i++) { - dst[i][0] = dst[i][1] = dst[i][2] = src[i * 2 + 0]; - dst[i][3] = src[i * 2 + 1]; - } -} - -static void -unpack_int_rgba_LUMINANCE_ALPHA_UINT8(const GLubyte *src, GLuint dst[][4], GLuint n) -{ - unsigned int i; - - for (i = 0; i < n; i++) { - dst[i][0] = dst[i][1] = dst[i][2] = src[i * 2 + 0]; - dst[i][3] = src[i * 2 + 1]; - } -} - -static void -unpack_int_rgba_LUMINANCE_ALPHA_INT8(const GLbyte *src, GLuint dst[][4], GLuint n) -{ - unsigned int i; - - for (i = 0; i < n; i++) { - dst[i][0] = dst[i][1] = dst[i][2] = src[i * 2 + 0]; - dst[i][3] = src[i * 2 + 1]; - } -} - -static void -unpack_int_rgba_INTENSITY_UINT32(const GLuint *src, GLuint dst[][4], GLuint n) -{ - unsigned int i; - - for (i = 0; i < n; i++) { - dst[i][0] = dst[i][1] = dst[i][2] = dst[i][3] = src[i]; - } -} - -static void -unpack_int_rgba_INTENSITY_UINT16(const GLushort *src, GLuint dst[][4], GLuint n) -{ - unsigned int i; - - for (i = 0; i < n; i++) { - dst[i][0] = dst[i][1] = dst[i][2] = dst[i][3] = src[i]; - } -} - -static void -unpack_int_rgba_INTENSITY_INT16(const GLshort *src, GLuint dst[][4], GLuint n) -{ - unsigned int i; - - for (i = 0; i < n; i++) { - dst[i][0] = dst[i][1] = dst[i][2] = dst[i][3] = src[i]; - } -} - -static void -unpack_int_rgba_INTENSITY_UINT8(const GLubyte *src, GLuint dst[][4], GLuint n) -{ - unsigned int i; - - for (i = 0; i < n; i++) { - dst[i][0] = dst[i][1] = dst[i][2] = dst[i][3] = src[i]; - } -} - -static void -unpack_int_rgba_INTENSITY_INT8(const GLbyte *src, GLuint dst[][4], GLuint n) -{ - unsigned int i; - - for (i = 0; i < n; i++) { - dst[i][0] = dst[i][1] = dst[i][2] = dst[i][3] = src[i]; - } -} - -void -_mesa_unpack_uint_rgba_row(gl_format format, GLuint n, - const void *src, GLuint dst[][4]) -{ - switch (format) { - /* Since there won't be any sign extension happening, there's no need to - * make separate paths for 32-bit-to-32-bit integer unpack. - */ - case MESA_FORMAT_RGBA_UINT32: - case MESA_FORMAT_RGBA_INT32: - unpack_int_rgba_RGBA_UINT32(src, dst, n); - break; - - case MESA_FORMAT_RGBA_UINT16: - unpack_int_rgba_RGBA_UINT16(src, dst, n); - break; - case MESA_FORMAT_RGBA_INT16: - unpack_int_rgba_RGBA_INT16(src, dst, n); - break; - - case MESA_FORMAT_RGBA_UINT8: - unpack_int_rgba_RGBA_UINT8(src, dst, n); - break; - case MESA_FORMAT_RGBA_INT8: - unpack_int_rgba_RGBA_INT8(src, dst, n); - break; - - case MESA_FORMAT_RGB_UINT32: - case MESA_FORMAT_RGB_INT32: - unpack_int_rgba_RGB_UINT32(src, dst, n); - break; - - case MESA_FORMAT_RGB_UINT16: - unpack_int_rgba_RGB_UINT16(src, dst, n); - break; - case MESA_FORMAT_RGB_INT16: - unpack_int_rgba_RGB_INT16(src, dst, n); - break; - - case MESA_FORMAT_RGB_UINT8: - unpack_int_rgba_RGB_UINT8(src, dst, n); - break; - case MESA_FORMAT_RGB_INT8: - unpack_int_rgba_RGB_INT8(src, dst, n); - break; - - case MESA_FORMAT_ALPHA_UINT32: - case MESA_FORMAT_ALPHA_INT32: - unpack_int_rgba_ALPHA_UINT32(src, dst, n); - break; - - case MESA_FORMAT_ALPHA_UINT16: - unpack_int_rgba_ALPHA_UINT16(src, dst, n); - break; - case MESA_FORMAT_ALPHA_INT16: - unpack_int_rgba_ALPHA_INT16(src, dst, n); - break; - - case MESA_FORMAT_ALPHA_UINT8: - unpack_int_rgba_ALPHA_UINT8(src, dst, n); - break; - case MESA_FORMAT_ALPHA_INT8: - unpack_int_rgba_ALPHA_INT8(src, dst, n); - break; - - case MESA_FORMAT_LUMINANCE_UINT32: - case MESA_FORMAT_LUMINANCE_INT32: - unpack_int_rgba_LUMINANCE_UINT32(src, dst, n); - break; - case MESA_FORMAT_LUMINANCE_UINT16: - unpack_int_rgba_LUMINANCE_UINT16(src, dst, n); - break; - case MESA_FORMAT_LUMINANCE_INT16: - unpack_int_rgba_LUMINANCE_INT16(src, dst, n); - break; - - case MESA_FORMAT_LUMINANCE_UINT8: - unpack_int_rgba_LUMINANCE_UINT8(src, dst, n); - break; - case MESA_FORMAT_LUMINANCE_INT8: - unpack_int_rgba_LUMINANCE_INT8(src, dst, n); - break; - - case MESA_FORMAT_LUMINANCE_ALPHA_UINT32: - case MESA_FORMAT_LUMINANCE_ALPHA_INT32: - unpack_int_rgba_LUMINANCE_ALPHA_UINT32(src, dst, n); - break; - - case MESA_FORMAT_LUMINANCE_ALPHA_UINT16: - unpack_int_rgba_LUMINANCE_ALPHA_UINT16(src, dst, n); - break; - case MESA_FORMAT_LUMINANCE_ALPHA_INT16: - unpack_int_rgba_LUMINANCE_ALPHA_INT16(src, dst, n); - break; - - case MESA_FORMAT_LUMINANCE_ALPHA_UINT8: - unpack_int_rgba_LUMINANCE_ALPHA_UINT8(src, dst, n); - break; - case MESA_FORMAT_LUMINANCE_ALPHA_INT8: - unpack_int_rgba_LUMINANCE_ALPHA_INT8(src, dst, n); - break; - - case MESA_FORMAT_INTENSITY_UINT32: - case MESA_FORMAT_INTENSITY_INT32: - unpack_int_rgba_INTENSITY_UINT32(src, dst, n); - break; - - case MESA_FORMAT_INTENSITY_UINT16: - unpack_int_rgba_INTENSITY_UINT16(src, dst, n); - break; - case MESA_FORMAT_INTENSITY_INT16: - unpack_int_rgba_INTENSITY_INT16(src, dst, n); - break; - - case MESA_FORMAT_INTENSITY_UINT8: - unpack_int_rgba_INTENSITY_UINT8(src, dst, n); - break; - case MESA_FORMAT_INTENSITY_INT8: - unpack_int_rgba_INTENSITY_INT8(src, dst, n); - break; - - default: - _mesa_problem(NULL, "%s: bad format %s", __FUNCTION__, - _mesa_get_format_name(format)); - return; - } -} - -/** - * Unpack a 2D rect of pixels returning float RGBA colors. - * \param format the source image format - * \param src start address of the source image - * \param srcRowStride source image row stride in bytes - * \param dst start address of the dest image - * \param dstRowStride dest image row stride in bytes - * \param x source image start X pos - * \param y source image start Y pos - * \param width width of rect region to convert - * \param height height of rect region to convert - */ -void -_mesa_unpack_rgba_block(gl_format format, - const void *src, GLint srcRowStride, - GLfloat dst[][4], GLint dstRowStride, - GLuint x, GLuint y, GLuint width, GLuint height) -{ - unpack_rgba_func unpack = get_unpack_rgba_function(format); - const GLuint srcPixStride = _mesa_get_format_bytes(format); - const GLuint dstPixStride = 4 * sizeof(GLfloat); - const GLubyte *srcRow; - GLubyte *dstRow; - GLuint i; - - /* XXX needs to be fixed for compressed formats */ - - srcRow = ((const GLubyte *) src) + srcRowStride * y + srcPixStride * x; - dstRow = ((GLubyte *) dst) + dstRowStride * y + dstPixStride * x; - - for (i = 0; i < height; i++) { - unpack(srcRow, (GLfloat (*)[4]) dstRow, width); - - dstRow += dstRowStride; - srcRow += srcRowStride; - } -} - - - - -typedef void (*unpack_float_z_func)(GLuint n, const void *src, GLfloat *dst); - -static void -unpack_float_z_Z24_X8(GLuint n, const void *src, GLfloat *dst) -{ - /* only return Z, not stencil data */ - const GLuint *s = ((const GLuint *) src); - const GLdouble scale = 1.0 / (GLdouble) 0xffffff; - GLuint i; - for (i = 0; i < n; i++) { - dst[i] = (s[i] >> 8) * scale; - ASSERT(dst[i] >= 0.0F); - ASSERT(dst[i] <= 1.0F); - } -} - -static void -unpack_float_z_X8_Z24(GLuint n, const void *src, GLfloat *dst) -{ - /* only return Z, not stencil data */ - const GLuint *s = ((const GLuint *) src); - const GLdouble scale = 1.0 / (GLdouble) 0xffffff; - GLuint i; - for (i = 0; i < n; i++) { - dst[i] = (s[i] & 0x00ffffff) * scale; - ASSERT(dst[i] >= 0.0F); - ASSERT(dst[i] <= 1.0F); - } -} - -static void -unpack_float_z_Z16(GLuint n, const void *src, GLfloat *dst) -{ - const GLushort *s = ((const GLushort *) src); - GLuint i; - for (i = 0; i < n; i++) { - dst[i] = s[i] * (1.0F / 65535.0F); - } -} - -static void -unpack_float_z_Z32(GLuint n, const void *src, GLfloat *dst) -{ - const GLuint *s = ((const GLuint *) src); - GLuint i; - for (i = 0; i < n; i++) { - dst[i] = s[i] * (1.0F / 0xffffffff); - } -} - - - -/** - * Unpack Z values. - * The returned values will always be in the range [0.0, 1.0]. - */ -void -_mesa_unpack_float_z_row(gl_format format, GLuint n, - const void *src, GLfloat *dst) -{ - unpack_float_z_func unpack; - - switch (format) { - case MESA_FORMAT_Z24_X8: - unpack = unpack_float_z_Z24_X8; - break; - case MESA_FORMAT_X8_Z24: - unpack = unpack_float_z_X8_Z24; - break; - case MESA_FORMAT_Z16: - unpack = unpack_float_z_Z16; - break; - case MESA_FORMAT_Z32: - unpack = unpack_float_z_Z32; - break; - default: - _mesa_problem(NULL, "bad format %s in _mesa_unpack_float_z_row", - _mesa_get_format_name(format)); - return; - } - - unpack(n, src, dst); -} - - - -typedef void (*unpack_uint_z_func)(const void *src, GLuint *dst, GLuint n); - -static void -unpack_uint_z_Z24_X8(const void *src, GLuint *dst, GLuint n) -{ - /* only return Z, not stencil data */ - const GLuint *s = ((const GLuint *) src); - GLuint i; - for (i = 0; i < n; i++) { - dst[i] = (s[i] & 0xffffff00) | (s[i] >> 24); - } -} - -static void -unpack_uint_z_X8_Z24(const void *src, GLuint *dst, GLuint n) -{ - /* only return Z, not stencil data */ - const GLuint *s = ((const GLuint *) src); - GLuint i; - for (i = 0; i < n; i++) { - dst[i] = (s[i] << 8) | ((s[i] >> 16) & 0xff); - } -} - -static void -unpack_uint_z_Z16(const void *src, GLuint *dst, GLuint n) -{ - const GLushort *s = ((const GLushort *)src); - GLuint i; - for (i = 0; i < n; i++) { - dst[i] = (s[i] << 16) | s[i]; - } -} - -static void -unpack_uint_z_Z32(const void *src, GLuint *dst, GLuint n) -{ - memcpy(dst, src, n * sizeof(GLuint)); -} - - -/** - * Unpack Z values. - * The returned values will always be in the range [0, 0xffffffff]. - */ -void -_mesa_unpack_uint_z_row(gl_format format, GLuint n, - const void *src, GLuint *dst) -{ - unpack_uint_z_func unpack; - const GLubyte *srcPtr = (GLubyte *) src; - - switch (format) { - case MESA_FORMAT_Z24_X8: - unpack = unpack_uint_z_Z24_X8; - break; - case MESA_FORMAT_X8_Z24: - unpack = unpack_uint_z_X8_Z24; - break; - case MESA_FORMAT_Z16: - unpack = unpack_uint_z_Z16; - break; - case MESA_FORMAT_Z32: - unpack = unpack_uint_z_Z32; - break; - default: - _mesa_problem(NULL, "bad format %s in _mesa_unpack_uint_z_row", - _mesa_get_format_name(format)); - return; - } - - unpack(srcPtr, dst, n); -} - - -static void -unpack_ubyte_s_S8(const void *src, GLubyte *dst, GLuint n) -{ - memcpy(dst, src, n); -} - -void -_mesa_unpack_ubyte_stencil_row(gl_format format, GLuint n, - const void *src, GLubyte *dst) -{ - switch (format) { - case MESA_FORMAT_S8: - unpack_ubyte_s_S8(src, dst, n); - break; - default: - _mesa_problem(NULL, "bad format %s in _mesa_unpack_ubyte_s_row", - _mesa_get_format_name(format)); - return; - } -} diff --git a/dll/opengl/mesa/main/format_unpack.h b/dll/opengl/mesa/main/format_unpack.h deleted file mode 100644 index 09610483b3e..00000000000 --- a/dll/opengl/mesa/main/format_unpack.h +++ /dev/null @@ -1,59 +0,0 @@ -/* - * Mesa 3-D graphics library - * - * Copyright (c) 2011 VMware, Inc. - * - * Permission is hereby granted, free of charge, to any person obtaining a - * copy of this software and associated documentation files (the "Software"), - * to deal in the Software without restriction, including without limitation - * the rights to use, copy, modify, merge, publish, distribute, sublicense, - * and/or sell copies of the Software, and to permit persons to whom the - * Software is furnished to do so, subject to the following conditions: - * - * The above copyright notice and this permission notice shall be included - * in all copies or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS - * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL - * THE AUTHORS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN - * AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN - * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. - */ - -#ifndef FORMAT_UNPACK_H -#define FORMAT_UNPACK_H - -extern void -_mesa_unpack_rgba_row(gl_format format, GLuint n, - const void *src, GLfloat dst[][4]); - -extern void -_mesa_unpack_ubyte_rgba_row(gl_format format, GLuint n, - const void *src, GLubyte dst[][4]); - -void -_mesa_unpack_uint_rgba_row(gl_format format, GLuint n, - const void *src, GLuint dst[][4]); - -extern void -_mesa_unpack_rgba_block(gl_format format, - const void *src, GLint srcRowStride, - GLfloat dst[][4], GLint dstRowStride, - GLuint x, GLuint y, GLuint width, GLuint height); - -extern void -_mesa_unpack_float_z_row(gl_format format, GLuint n, - const void *src, GLfloat *dst); - - -void -_mesa_unpack_uint_z_row(gl_format format, GLuint n, - const void *src, GLuint *dst); - -void -_mesa_unpack_ubyte_stencil_row(gl_format format, GLuint n, - const void *src, GLubyte *dst); - - -#endif /* FORMAT_UNPACK_H */ diff --git a/dll/opengl/mesa/main/formats.c b/dll/opengl/mesa/main/formats.c deleted file mode 100644 index 1d46fa3e18d..00000000000 --- a/dll/opengl/mesa/main/formats.c +++ /dev/null @@ -1,1567 +0,0 @@ -/* - * Mesa 3-D graphics library - * Version: 7.7 - * - * Copyright (C) 1999-2008 Brian Paul All Rights Reserved. - * Copyright (c) 2008-2009 VMware, Inc. - * - * Permission is hereby granted, free of charge, to any person obtaining a - * copy of this software and associated documentation files (the "Software"), - * to deal in the Software without restriction, including without limitation - * the rights to use, copy, modify, merge, publish, distribute, sublicense, - * and/or sell copies of the Software, and to permit persons to whom the - * Software is furnished to do so, subject to the following conditions: - * - * The above copyright notice and this permission notice shall be included - * in all copies or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS - * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL - * BRIAN PAUL BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN - * AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN - * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. - */ - -#include - -/** - * Information about texture formats. - */ -struct gl_format_info -{ - gl_format Name; - - /** text name for debugging */ - const char *StrName; - - /** - * Base format is one of GL_RED, GL_RG, GL_RGB, GL_RGBA, GL_ALPHA, - * GL_LUMINANCE, GL_LUMINANCE_ALPHA, GL_INTENSITY, GL_YCBCR_MESA, - * GL_DEPTH_COMPONENT, GL_STENCIL_INDEX, GL_DEPTH_STENCIL. - */ - GLenum BaseFormat; - - /** - * Logical data type: one of GL_UNSIGNED_NORMALIZED, GL_SIGNED_NORMALIZED, - * GL_UNSIGNED_INT, GL_INT, GL_FLOAT. - */ - GLenum DataType; - - GLubyte RedBits; - GLubyte GreenBits; - GLubyte BlueBits; - GLubyte AlphaBits; - GLubyte LuminanceBits; - GLubyte IntensityBits; - GLubyte IndexBits; - GLubyte DepthBits; - GLubyte StencilBits; - - /** - * To describe compressed formats. If not compressed, Width=Height=1. - */ - GLubyte BlockWidth, BlockHeight; - GLubyte BytesPerBlock; -}; - - -/** - * Info about each format. - * These must be in the same order as the MESA_FORMAT_* enums so that - * we can do lookups without searching. - */ -static struct gl_format_info format_info[MESA_FORMAT_COUNT] = -{ - { - MESA_FORMAT_NONE, /* Name */ - "MESA_FORMAT_NONE", /* StrName */ - GL_NONE, /* BaseFormat */ - GL_NONE, /* DataType */ - 0, 0, 0, 0, /* Red/Green/Blue/AlphaBits */ - 0, 0, 0, 0, 0, /* Lum/Int/Index/Depth/StencilBits */ - 0, 0, 0 /* BlockWidth/Height,Bytes */ - }, - { - MESA_FORMAT_RGBA8888, /* Name */ - "MESA_FORMAT_RGBA8888", /* StrName */ - GL_RGBA, /* BaseFormat */ - GL_UNSIGNED_NORMALIZED, /* DataType */ - 8, 8, 8, 8, /* Red/Green/Blue/AlphaBits */ - 0, 0, 0, 0, 0, /* Lum/Int/Index/Depth/StencilBits */ - 1, 1, 4 /* BlockWidth/Height,Bytes */ - }, - { - MESA_FORMAT_RGBA8888_REV, /* Name */ - "MESA_FORMAT_RGBA8888_REV", /* StrName */ - GL_RGBA, /* BaseFormat */ - GL_UNSIGNED_NORMALIZED, /* DataType */ - 8, 8, 8, 8, /* Red/Green/Blue/AlphaBits */ - 0, 0, 0, 0, 0, /* Lum/Int/Index/Depth/StencilBits */ - 1, 1, 4 /* BlockWidth/Height,Bytes */ - }, - { - MESA_FORMAT_ARGB8888, /* Name */ - "MESA_FORMAT_ARGB8888", /* StrName */ - GL_RGBA, /* BaseFormat */ - GL_UNSIGNED_NORMALIZED, /* DataType */ - 8, 8, 8, 8, /* Red/Green/Blue/AlphaBits */ - 0, 0, 0, 0, 0, /* Lum/Int/Index/Depth/StencilBits */ - 1, 1, 4 /* BlockWidth/Height,Bytes */ - }, - { - MESA_FORMAT_ARGB8888_REV, /* Name */ - "MESA_FORMAT_ARGB8888_REV", /* StrName */ - GL_RGBA, /* BaseFormat */ - GL_UNSIGNED_NORMALIZED, /* DataType */ - 8, 8, 8, 8, /* Red/Green/Blue/AlphaBits */ - 0, 0, 0, 0, 0, /* Lum/Int/Index/Depth/StencilBits */ - 1, 1, 4 /* BlockWidth/Height,Bytes */ - }, - { - MESA_FORMAT_RGBX8888, /* Name */ - "MESA_FORMAT_RGBX8888", /* StrName */ - GL_RGB, /* BaseFormat */ - GL_UNSIGNED_NORMALIZED, /* DataType */ - 8, 8, 8, 0, /* Red/Green/Blue/AlphaBits */ - 0, 0, 0, 0, 0, /* Lum/Int/Index/Depth/StencilBits */ - 1, 1, 4 /* BlockWidth/Height,Bytes */ - }, - { - MESA_FORMAT_RGBX8888_REV, /* Name */ - "MESA_FORMAT_RGBX8888_REV", /* StrName */ - GL_RGB, /* BaseFormat */ - GL_UNSIGNED_NORMALIZED, /* DataType */ - 8, 8, 8, 0, /* Red/Green/Blue/AlphaBits */ - 0, 0, 0, 0, 0, /* Lum/Int/Index/Depth/StencilBits */ - 1, 1, 4 /* BlockWidth/Height,Bytes */ - }, - { - MESA_FORMAT_XRGB8888, /* Name */ - "MESA_FORMAT_XRGB8888", /* StrName */ - GL_RGB, /* BaseFormat */ - GL_UNSIGNED_NORMALIZED, /* DataType */ - 8, 8, 8, 0, /* Red/Green/Blue/AlphaBits */ - 0, 0, 0, 0, 0, /* Lum/Int/Index/Depth/StencilBits */ - 1, 1, 4 /* BlockWidth/Height,Bytes */ - }, - { - MESA_FORMAT_XRGB8888_REV, /* Name */ - "MESA_FORMAT_XRGB8888_REV", /* StrName */ - GL_RGB, /* BaseFormat */ - GL_UNSIGNED_NORMALIZED, /* DataType */ - 8, 8, 8, 0, /* Red/Green/Blue/AlphaBits */ - 0, 0, 0, 0, 0, /* Lum/Int/Index/Depth/StencilBits */ - 1, 1, 4 /* BlockWidth/Height,Bytes */ - }, - { - MESA_FORMAT_RGB888, /* Name */ - "MESA_FORMAT_RGB888", /* StrName */ - GL_RGB, /* BaseFormat */ - GL_UNSIGNED_NORMALIZED, /* DataType */ - 8, 8, 8, 0, /* Red/Green/Blue/AlphaBits */ - 0, 0, 0, 0, 0, /* Lum/Int/Index/Depth/StencilBits */ - 1, 1, 3 /* BlockWidth/Height,Bytes */ - }, - { - MESA_FORMAT_BGR888, /* Name */ - "MESA_FORMAT_BGR888", /* StrName */ - GL_RGB, /* BaseFormat */ - GL_UNSIGNED_NORMALIZED, /* DataType */ - 8, 8, 8, 0, /* Red/Green/Blue/AlphaBits */ - 0, 0, 0, 0, 0, /* Lum/Int/Index/Depth/StencilBits */ - 1, 1, 3 /* BlockWidth/Height,Bytes */ - }, - { - MESA_FORMAT_RGB565, /* Name */ - "MESA_FORMAT_RGB565", /* StrName */ - GL_RGB, /* BaseFormat */ - GL_UNSIGNED_NORMALIZED, /* DataType */ - 5, 6, 5, 0, /* Red/Green/Blue/AlphaBits */ - 0, 0, 0, 0, 0, /* Lum/Int/Index/Depth/StencilBits */ - 1, 1, 2 /* BlockWidth/Height,Bytes */ - }, - { - MESA_FORMAT_RGB565_REV, /* Name */ - "MESA_FORMAT_RGB565_REV", /* StrName */ - GL_RGB, /* BaseFormat */ - GL_UNSIGNED_NORMALIZED, /* DataType */ - 5, 6, 5, 0, /* Red/Green/Blue/AlphaBits */ - 0, 0, 0, 0, 0, /* Lum/Int/Index/Depth/StencilBits */ - 1, 1, 2 /* BlockWidth/Height,Bytes */ - }, - { - MESA_FORMAT_ARGB4444, /* Name */ - "MESA_FORMAT_ARGB4444", /* StrName */ - GL_RGBA, /* BaseFormat */ - GL_UNSIGNED_NORMALIZED, /* DataType */ - 4, 4, 4, 4, /* Red/Green/Blue/AlphaBits */ - 0, 0, 0, 0, 0, /* Lum/Int/Index/Depth/StencilBits */ - 1, 1, 2 /* BlockWidth/Height,Bytes */ - }, - { - MESA_FORMAT_ARGB4444_REV, /* Name */ - "MESA_FORMAT_ARGB4444_REV", /* StrName */ - GL_RGBA, /* BaseFormat */ - GL_UNSIGNED_NORMALIZED, /* DataType */ - 4, 4, 4, 4, /* Red/Green/Blue/AlphaBits */ - 0, 0, 0, 0, 0, /* Lum/Int/Index/Depth/StencilBits */ - 1, 1, 2 /* BlockWidth/Height,Bytes */ - }, - { - MESA_FORMAT_RGBA5551, /* Name */ - "MESA_FORMAT_RGBA5551", /* StrName */ - GL_RGBA, /* BaseFormat */ - GL_UNSIGNED_NORMALIZED, /* DataType */ - 5, 5, 5, 1, /* Red/Green/Blue/AlphaBits */ - 0, 0, 0, 0, 0, /* Lum/Int/Index/Depth/StencilBits */ - 1, 1, 2 /* BlockWidth/Height,Bytes */ - }, - { - MESA_FORMAT_ARGB1555, /* Name */ - "MESA_FORMAT_ARGB1555", /* StrName */ - GL_RGBA, /* BaseFormat */ - GL_UNSIGNED_NORMALIZED, /* DataType */ - 5, 5, 5, 1, /* Red/Green/Blue/AlphaBits */ - 0, 0, 0, 0, 0, /* Lum/Int/Index/Depth/StencilBits */ - 1, 1, 2 /* BlockWidth/Height,Bytes */ - }, - { - MESA_FORMAT_ARGB1555_REV, /* Name */ - "MESA_FORMAT_ARGB1555_REV", /* StrName */ - GL_RGBA, /* BaseFormat */ - GL_UNSIGNED_NORMALIZED, /* DataType */ - 5, 5, 5, 1, /* Red/Green/Blue/AlphaBits */ - 0, 0, 0, 0, 0, /* Lum/Int/Index/Depth/StencilBits */ - 1, 1, 2 /* BlockWidth/Height,Bytes */ - }, - { - MESA_FORMAT_AL44, /* Name */ - "MESA_FORMAT_AL44", /* StrName */ - GL_LUMINANCE_ALPHA, /* BaseFormat */ - GL_UNSIGNED_NORMALIZED, /* DataType */ - 0, 0, 0, 4, /* Red/Green/Blue/AlphaBits */ - 4, 0, 0, 0, 0, /* Lum/Int/Index/Depth/StencilBits */ - 1, 1, 1 /* BlockWidth/Height,Bytes */ - }, - { - MESA_FORMAT_AL88, /* Name */ - "MESA_FORMAT_AL88", /* StrName */ - GL_LUMINANCE_ALPHA, /* BaseFormat */ - GL_UNSIGNED_NORMALIZED, /* DataType */ - 0, 0, 0, 8, /* Red/Green/Blue/AlphaBits */ - 8, 0, 0, 0, 0, /* Lum/Int/Index/Depth/StencilBits */ - 1, 1, 2 /* BlockWidth/Height,Bytes */ - }, - { - MESA_FORMAT_AL88_REV, /* Name */ - "MESA_FORMAT_AL88_REV", /* StrName */ - GL_LUMINANCE_ALPHA, /* BaseFormat */ - GL_UNSIGNED_NORMALIZED, /* DataType */ - 0, 0, 0, 8, /* Red/Green/Blue/AlphaBits */ - 8, 0, 0, 0, 0, /* Lum/Int/Index/Depth/StencilBits */ - 1, 1, 2 /* BlockWidth/Height,Bytes */ - }, - { - MESA_FORMAT_AL1616, /* Name */ - "MESA_FORMAT_AL1616", /* StrName */ - GL_LUMINANCE_ALPHA, /* BaseFormat */ - GL_UNSIGNED_NORMALIZED, /* DataType */ - 0, 0, 0, 16, /* Red/Green/Blue/AlphaBits */ - 16, 0, 0, 0, 0, /* Lum/Int/Index/Depth/StencilBits */ - 1, 1, 4 /* BlockWidth/Height,Bytes */ - }, - { - MESA_FORMAT_AL1616_REV, /* Name */ - "MESA_FORMAT_AL1616_REV", /* StrName */ - GL_LUMINANCE_ALPHA, /* BaseFormat */ - GL_UNSIGNED_NORMALIZED, /* DataType */ - 0, 0, 0, 16, /* Red/Green/Blue/AlphaBits */ - 16, 0, 0, 0, 0, /* Lum/Int/Index/Depth/StencilBits */ - 1, 1, 4 /* BlockWidth/Height,Bytes */ - }, - { - MESA_FORMAT_RGB332, /* Name */ - "MESA_FORMAT_RGB332", /* StrName */ - GL_RGB, /* BaseFormat */ - GL_UNSIGNED_NORMALIZED, /* DataType */ - 3, 3, 2, 0, /* Red/Green/Blue/AlphaBits */ - 0, 0, 0, 0, 0, /* Lum/Int/Index/Depth/StencilBits */ - 1, 1, 1 /* BlockWidth/Height,Bytes */ - }, - { - MESA_FORMAT_A8, /* Name */ - "MESA_FORMAT_A8", /* StrName */ - GL_ALPHA, /* BaseFormat */ - GL_UNSIGNED_NORMALIZED, /* DataType */ - 0, 0, 0, 8, /* Red/Green/Blue/AlphaBits */ - 0, 0, 0, 0, 0, /* Lum/Int/Index/Depth/StencilBits */ - 1, 1, 1 /* BlockWidth/Height,Bytes */ - }, - { - MESA_FORMAT_A16, /* Name */ - "MESA_FORMAT_A16", /* StrName */ - GL_ALPHA, /* BaseFormat */ - GL_UNSIGNED_NORMALIZED, /* DataType */ - 0, 0, 0, 16, /* Red/Green/Blue/AlphaBits */ - 0, 0, 0, 0, 0, /* Lum/Int/Index/Depth/StencilBits */ - 1, 1, 2 /* BlockWidth/Height,Bytes */ - }, - { - MESA_FORMAT_L8, /* Name */ - "MESA_FORMAT_L8", /* StrName */ - GL_LUMINANCE, /* BaseFormat */ - GL_UNSIGNED_NORMALIZED, /* DataType */ - 0, 0, 0, 0, /* Red/Green/Blue/AlphaBits */ - 8, 0, 0, 0, 0, /* Lum/Int/Index/Depth/StencilBits */ - 1, 1, 1 /* BlockWidth/Height,Bytes */ - }, - { - MESA_FORMAT_L16, /* Name */ - "MESA_FORMAT_L16", /* StrName */ - GL_LUMINANCE, /* BaseFormat */ - GL_UNSIGNED_NORMALIZED, /* DataType */ - 0, 0, 0, 0, /* Red/Green/Blue/AlphaBits */ - 16, 0, 0, 0, 0, /* Lum/Int/Index/Depth/StencilBits */ - 1, 1, 2 /* BlockWidth/Height,Bytes */ - }, - { - MESA_FORMAT_I8, /* Name */ - "MESA_FORMAT_I8", /* StrName */ - GL_INTENSITY, /* BaseFormat */ - GL_UNSIGNED_NORMALIZED, /* DataType */ - 0, 0, 0, 0, /* Red/Green/Blue/AlphaBits */ - 0, 8, 0, 0, 0, /* Lum/Int/Index/Depth/StencilBits */ - 1, 1, 1 /* BlockWidth/Height,Bytes */ - }, - { - MESA_FORMAT_I16, /* Name */ - "MESA_FORMAT_I16", /* StrName */ - GL_INTENSITY, /* BaseFormat */ - GL_UNSIGNED_NORMALIZED, /* DataType */ - 0, 0, 0, 0, /* Red/Green/Blue/AlphaBits */ - 0, 16, 0, 0, 0, /* Lum/Int/Index/Depth/StencilBits */ - 1, 1, 2 /* BlockWidth/Height,Bytes */ - }, - { - MESA_FORMAT_YCBCR, /* Name */ - "MESA_FORMAT_YCBCR", /* StrName */ - GL_YCBCR_MESA, /* BaseFormat */ - GL_UNSIGNED_NORMALIZED, /* DataType */ - 0, 0, 0, 0, /* Red/Green/Blue/AlphaBits */ - 0, 0, 0, 0, 0, /* Lum/Int/Index/Depth/StencilBits */ - 1, 1, 2 /* BlockWidth/Height,Bytes */ - }, - { - MESA_FORMAT_YCBCR_REV, /* Name */ - "MESA_FORMAT_YCBCR_REV", /* StrName */ - GL_YCBCR_MESA, /* BaseFormat */ - GL_UNSIGNED_NORMALIZED, /* DataType */ - 0, 0, 0, 0, /* Red/Green/Blue/AlphaBits */ - 0, 0, 0, 0, 0, /* Lum/Int/Index/Depth/StencilBits */ - 1, 1, 2 /* BlockWidth/Height,Bytes */ - }, - { - MESA_FORMAT_Z16, /* Name */ - "MESA_FORMAT_Z16", /* StrName */ - GL_DEPTH_COMPONENT, /* BaseFormat */ - GL_UNSIGNED_NORMALIZED, /* DataType */ - 0, 0, 0, 0, /* Red/Green/Blue/AlphaBits */ - 0, 0, 0, 16, 0, /* Lum/Int/Index/Depth/StencilBits */ - 1, 1, 2 /* BlockWidth/Height,Bytes */ - }, - { - MESA_FORMAT_X8_Z24, /* Name */ - "MESA_FORMAT_X8_Z24", /* StrName */ - GL_DEPTH_COMPONENT, /* BaseFormat */ - GL_UNSIGNED_NORMALIZED, /* DataType */ - 0, 0, 0, 0, /* Red/Green/Blue/AlphaBits */ - 0, 0, 0, 24, 0, /* Lum/Int/Index/Depth/StencilBits */ - 1, 1, 4 /* BlockWidth/Height,Bytes */ - }, - { - MESA_FORMAT_Z24_X8, /* Name */ - "MESA_FORMAT_Z24_X8", /* StrName */ - GL_DEPTH_COMPONENT, /* BaseFormat */ - GL_UNSIGNED_NORMALIZED, /* DataType */ - 0, 0, 0, 0, /* Red/Green/Blue/AlphaBits */ - 0, 0, 0, 24, 0, /* Lum/Int/Index/Depth/StencilBits */ - 1, 1, 4 /* BlockWidth/Height,Bytes */ - }, - { - MESA_FORMAT_Z32, /* Name */ - "MESA_FORMAT_Z32", /* StrName */ - GL_DEPTH_COMPONENT, /* BaseFormat */ - GL_UNSIGNED_NORMALIZED, /* DataType */ - 0, 0, 0, 0, /* Red/Green/Blue/AlphaBits */ - 0, 0, 0, 32, 0, /* Lum/Int/Index/Depth/StencilBits */ - 1, 1, 4 /* BlockWidth/Height,Bytes */ - }, - { - MESA_FORMAT_S8, /* Name */ - "MESA_FORMAT_S8", /* StrName */ - GL_STENCIL_INDEX, /* BaseFormat */ - GL_UNSIGNED_INT, /* DataType */ - 0, 0, 0, 0, /* Red/Green/Blue/AlphaBits */ - 0, 0, 0, 0, 8, /* Lum/Int/Index/Depth/StencilBits */ - 1, 1, 1 /* BlockWidth/Height,Bytes */ - }, - - /* unnormalized unsigned int formats */ - { - MESA_FORMAT_ALPHA_UINT8, - "MESA_FORMAT_ALPHA_UINT8", - GL_ALPHA, - GL_UNSIGNED_INT, - 0, 0, 0, 8, - 0, 0, 0, 0, 0, - 1, 1, 1 - }, - { - MESA_FORMAT_ALPHA_UINT16, - "MESA_FORMAT_ALPHA_UINT16", - GL_ALPHA, - GL_UNSIGNED_INT, - 0, 0, 0, 16, - 0, 0, 0, 0, 0, - 1, 1, 2 - }, - { - MESA_FORMAT_ALPHA_UINT32, - "MESA_FORMAT_ALPHA_UINT32", - GL_ALPHA, - GL_UNSIGNED_INT, - 0, 0, 0, 32, - 0, 0, 0, 0, 0, - 1, 1, 4 - }, - { - MESA_FORMAT_ALPHA_INT8, - "MESA_FORMAT_ALPHA_INT8", - GL_ALPHA, - GL_INT, - 0, 0, 0, 8, - 0, 0, 0, 0, 0, - 1, 1, 1 - }, - { - MESA_FORMAT_ALPHA_INT16, - "MESA_FORMAT_ALPHA_INT16", - GL_ALPHA, - GL_INT, - 0, 0, 0, 16, - 0, 0, 0, 0, 0, - 1, 1, 2 - }, - { - MESA_FORMAT_ALPHA_INT32, - "MESA_FORMAT_ALPHA_INT32", - GL_ALPHA, - GL_INT, - 0, 0, 0, 32, - 0, 0, 0, 0, 0, - 1, 1, 4 - }, - { - MESA_FORMAT_INTENSITY_UINT8, - "MESA_FORMAT_INTENSITY_UINT8", - GL_INTENSITY, - GL_UNSIGNED_INT, - 0, 0, 0, 0, - 0, 8, 0, 0, 0, - 1, 1, 1 - }, - { - MESA_FORMAT_INTENSITY_UINT16, - "MESA_FORMAT_INTENSITY_UINT16", - GL_INTENSITY, - GL_UNSIGNED_INT, - 0, 0, 0, 0, - 0, 16, 0, 0, 0, - 1, 1, 2 - }, - { - MESA_FORMAT_INTENSITY_UINT32, - "MESA_FORMAT_INTENSITY_UINT32", - GL_INTENSITY, - GL_UNSIGNED_INT, - 0, 0, 0, 0, - 0, 32, 0, 0, 0, - 1, 1, 4 - }, - { - MESA_FORMAT_INTENSITY_INT8, - "MESA_FORMAT_INTENSITY_INT8", - GL_INTENSITY, - GL_INT, - 0, 0, 0, 0, - 0, 8, 0, 0, 0, - 1, 1, 1 - }, - { - MESA_FORMAT_INTENSITY_INT16, - "MESA_FORMAT_INTENSITY_INT16", - GL_INTENSITY, - GL_INT, - 0, 0, 0, 0, - 0, 16, 0, 0, 0, - 1, 1, 2 - }, - { - MESA_FORMAT_INTENSITY_INT32, - "MESA_FORMAT_INTENSITY_INT32", - GL_INTENSITY, - GL_INT, - 0, 0, 0, 0, - 0, 32, 0, 0, 0, - 1, 1, 4 - }, - { - MESA_FORMAT_LUMINANCE_UINT8, - "MESA_FORMAT_LUMINANCE_UINT8", - GL_LUMINANCE, - GL_UNSIGNED_INT, - 0, 0, 0, 0, - 8, 0, 0, 0, 0, - 1, 1, 1 - }, - { - MESA_FORMAT_LUMINANCE_UINT16, - "MESA_FORMAT_LUMINANCE_UINT16", - GL_LUMINANCE, - GL_UNSIGNED_INT, - 0, 0, 0, 0, - 16, 0, 0, 0, 0, - 1, 1, 2 - }, - { - MESA_FORMAT_LUMINANCE_UINT32, - "MESA_FORMAT_LUMINANCE_UINT32", - GL_LUMINANCE, - GL_UNSIGNED_INT, - 0, 0, 0, 0, - 32, 0, 0, 0, 0, - 1, 1, 4 - }, - { - MESA_FORMAT_LUMINANCE_INT8, - "MESA_FORMAT_LUMINANCE_INT8", - GL_LUMINANCE, - GL_INT, - 0, 0, 0, 0, - 8, 0, 0, 0, 0, - 1, 1, 1 - }, - { - MESA_FORMAT_LUMINANCE_INT16, - "MESA_FORMAT_LUMINANCE_INT16", - GL_LUMINANCE, - GL_INT, - 0, 0, 0, 0, - 16, 0, 0, 0, 0, - 1, 1, 2 - }, - { - MESA_FORMAT_LUMINANCE_INT32, - "MESA_FORMAT_LUMINANCE_INT32", - GL_LUMINANCE, - GL_INT, - 0, 0, 0, 0, - 32, 0, 0, 0, 0, - 1, 1, 4 - }, - { - MESA_FORMAT_LUMINANCE_ALPHA_UINT8, - "MESA_FORMAT_LUMINANCE_ALPHA_UINT8", - GL_LUMINANCE_ALPHA, - GL_UNSIGNED_INT, - 0, 0, 0, 8, - 8, 0, 0, 0, 0, - 1, 1, 2 - }, - { - MESA_FORMAT_LUMINANCE_ALPHA_UINT16, - "MESA_FORMAT_LUMINANCE_ALPHA_UINT16", - GL_LUMINANCE_ALPHA, - GL_UNSIGNED_INT, - 0, 0, 0, 16, - 16, 0, 0, 0, 0, - 1, 1, 4 - }, - { - MESA_FORMAT_LUMINANCE_ALPHA_UINT32, - "MESA_FORMAT_LUMINANCE_ALPHA_UINT32", - GL_LUMINANCE_ALPHA, - GL_UNSIGNED_INT, - 0, 0, 0, 32, - 32, 0, 0, 0, 0, - 1, 1, 8 - }, - { - MESA_FORMAT_LUMINANCE_ALPHA_INT8, - "MESA_FORMAT_LUMINANCE_ALPHA_INT8", - GL_LUMINANCE_ALPHA, - GL_INT, - 0, 0, 0, 8, - 8, 0, 0, 0, 0, - 1, 1, 2 - }, - { - MESA_FORMAT_LUMINANCE_ALPHA_INT16, - "MESA_FORMAT_LUMINANCE_ALPHA_INT16", - GL_LUMINANCE_ALPHA, - GL_INT, - 0, 0, 0, 16, - 16, 0, 0, 0, 0, - 1, 1, 4 - }, - { - MESA_FORMAT_LUMINANCE_ALPHA_INT32, - "MESA_FORMAT_LUMINANCE_ALPHA_INT32", - GL_LUMINANCE_ALPHA, - GL_INT, - 0, 0, 0, 32, - 32, 0, 0, 0, 0, - 1, 1, 8 - }, - { - MESA_FORMAT_RGB_INT8, - "MESA_FORMAT_RGB_INT8", - GL_RGB, - GL_INT, - 8, 8, 8, 0, - 0, 0, 0, 0, 0, - 1, 1, 3 - }, - { - MESA_FORMAT_RGBA_INT8, - "MESA_FORMAT_RGBA_INT8", - GL_RGBA, - GL_INT, - 8, 8, 8, 8, - 0, 0, 0, 0, 0, - 1, 1, 4 - }, - { - MESA_FORMAT_RGB_INT16, - "MESA_FORMAT_RGB_INT16", - GL_RGB, - GL_INT, - 16, 16, 16, 0, - 0, 0, 0, 0, 0, - 1, 1, 6 - }, - { - MESA_FORMAT_RGBA_INT16, - "MESA_FORMAT_RGBA_INT16", - GL_RGBA, - GL_INT, - 16, 16, 16, 16, - 0, 0, 0, 0, 0, - 1, 1, 8 - }, - { - MESA_FORMAT_RGB_INT32, - "MESA_FORMAT_RGB_INT32", - GL_RGB, - GL_INT, - 32, 32, 32, 0, - 0, 0, 0, 0, 0, - 1, 1, 12 - }, - { - MESA_FORMAT_RGBA_INT32, - "MESA_FORMAT_RGBA_INT32", - GL_RGBA, - GL_INT, - 32, 32, 32, 32, - 0, 0, 0, 0, 0, - 1, 1, 16 - }, - { - MESA_FORMAT_RGB_UINT8, - "MESA_FORMAT_RGB_UINT8", - GL_RGB, - GL_UNSIGNED_INT, - 8, 8, 8, 0, - 0, 0, 0, 0, 0, - 1, 1, 3 - }, - { - MESA_FORMAT_RGBA_UINT8, - "MESA_FORMAT_RGBA_UINT8", - GL_RGBA, - GL_UNSIGNED_INT, - 8, 8, 8, 8, - 0, 0, 0, 0, 0, - 1, 1, 4 - }, - { - MESA_FORMAT_RGB_UINT16, - "MESA_FORMAT_RGB_UINT16", - GL_RGB, - GL_UNSIGNED_INT, - 16, 16, 16, 0, - 0, 0, 0, 0, 0, - 1, 1, 6 - }, - { - MESA_FORMAT_RGBA_UINT16, - "MESA_FORMAT_RGBA_UINT16", - GL_RGBA, - GL_UNSIGNED_INT, - 16, 16, 16, 16, - 0, 0, 0, 0, 0, - 1, 1, 8 - }, - { - MESA_FORMAT_RGB_UINT32, - "MESA_FORMAT_RGB_UINT32", - GL_RGB, - GL_UNSIGNED_INT, - 32, 32, 32, 0, - 0, 0, 0, 0, 0, - 1, 1, 12 - }, - { - MESA_FORMAT_RGBA_UINT32, - "MESA_FORMAT_RGBA_UINT32", - GL_RGBA, - GL_UNSIGNED_INT, - 32, 32, 32, 32, - 0, 0, 0, 0, 0, - 1, 1, 16 - }, - - - { - MESA_FORMAT_SIGNED_RGBA_16, - "MESA_FORMAT_SIGNED_RGBA_16", - GL_RGBA, - GL_SIGNED_NORMALIZED, - 16, 16, 16, 16, - 0, 0, 0, 0, 0, - 1, 1, 8 - }, - { - MESA_FORMAT_RGBA_16, - "MESA_FORMAT_RGBA_16", - GL_RGBA, - GL_UNSIGNED_NORMALIZED, - 16, 16, 16, 16, - 0, 0, 0, 0, 0, - 1, 1, 8 - } -}; - - - -static const struct gl_format_info * -_mesa_get_format_info(gl_format format) -{ - const struct gl_format_info *info = &format_info[format]; - assert(info->Name == format); - return info; -} - - -/** Return string name of format (for debugging) */ -const char * -_mesa_get_format_name(gl_format format) -{ - const struct gl_format_info *info = _mesa_get_format_info(format); - return info->StrName; -} - - - -/** - * Return bytes needed to store a block of pixels in the given format. - * Normally, a block is 1x1 (a single pixel). But for compressed formats - * a block may be 4x4 or 8x4, etc. - * - * Note: not GLuint, so as not to coerce math to unsigned. cf. fdo #37351 - */ -GLint -_mesa_get_format_bytes(gl_format format) -{ - const struct gl_format_info *info = _mesa_get_format_info(format); - ASSERT(info->BytesPerBlock); - ASSERT(info->BytesPerBlock <= MAX_PIXEL_BYTES); - return info->BytesPerBlock; -} - - -/** - * Return bits per component for the given format. - * \param format one of MESA_FORMAT_x - * \param pname the component, such as GL_RED_BITS, GL_TEXTURE_BLUE_BITS, etc. - */ -GLint -_mesa_get_format_bits(gl_format format, GLenum pname) -{ - const struct gl_format_info *info = _mesa_get_format_info(format); - - switch (pname) { - case GL_RED_BITS: - case GL_TEXTURE_RED_SIZE: - case GL_RENDERBUFFER_RED_SIZE_EXT: - case GL_FRAMEBUFFER_ATTACHMENT_RED_SIZE: - return info->RedBits; - case GL_GREEN_BITS: - case GL_TEXTURE_GREEN_SIZE: - case GL_RENDERBUFFER_GREEN_SIZE_EXT: - case GL_FRAMEBUFFER_ATTACHMENT_GREEN_SIZE: - return info->GreenBits; - case GL_BLUE_BITS: - case GL_TEXTURE_BLUE_SIZE: - case GL_RENDERBUFFER_BLUE_SIZE_EXT: - case GL_FRAMEBUFFER_ATTACHMENT_BLUE_SIZE: - return info->BlueBits; - case GL_ALPHA_BITS: - case GL_TEXTURE_ALPHA_SIZE: - case GL_RENDERBUFFER_ALPHA_SIZE_EXT: - case GL_FRAMEBUFFER_ATTACHMENT_ALPHA_SIZE: - return info->AlphaBits; - case GL_TEXTURE_INTENSITY_SIZE: - return info->IntensityBits; - case GL_TEXTURE_LUMINANCE_SIZE: - return info->LuminanceBits; - case GL_INDEX_BITS: - return info->IndexBits; - case GL_DEPTH_BITS: - case GL_TEXTURE_DEPTH_SIZE_ARB: - case GL_RENDERBUFFER_DEPTH_SIZE_EXT: - case GL_FRAMEBUFFER_ATTACHMENT_DEPTH_SIZE: - return info->DepthBits; - case GL_STENCIL_BITS: - case GL_RENDERBUFFER_STENCIL_SIZE_EXT: - case GL_FRAMEBUFFER_ATTACHMENT_STENCIL_SIZE: - return info->StencilBits; - default: - _mesa_problem(NULL, "bad pname in _mesa_get_format_bits()"); - return 0; - } -} - - -GLuint -_mesa_get_format_max_bits(gl_format format) -{ - const struct gl_format_info *info = _mesa_get_format_info(format); - GLuint max = MAX2(info->RedBits, info->GreenBits); - max = MAX2(max, info->BlueBits); - max = MAX2(max, info->AlphaBits); - max = MAX2(max, info->LuminanceBits); - max = MAX2(max, info->IntensityBits); - max = MAX2(max, info->DepthBits); - max = MAX2(max, info->StencilBits); - return max; -} - - -/** - * Return the data type (or more specifically, the data representation) - * for the given format. - * The return value will be one of: - * GL_UNSIGNED_NORMALIZED = unsigned int representing [0,1] - * GL_SIGNED_NORMALIZED = signed int representing [-1, 1] - * GL_UNSIGNED_INT = an ordinary unsigned integer - * GL_INT = an ordinary signed integer - * GL_FLOAT = an ordinary float - */ -GLenum -_mesa_get_format_datatype(gl_format format) -{ - const struct gl_format_info *info = _mesa_get_format_info(format); - return info->DataType; -} - - -/** - * Return the basic format for the given type. The result will be one of - * GL_RGB, GL_RGBA, GL_ALPHA, GL_LUMINANCE, GL_LUMINANCE_ALPHA, GL_INTENSITY, - * GL_YCBCR_MESA, GL_DEPTH_COMPONENT, GL_STENCIL_INDEX, GL_DEPTH_STENCIL. - */ -GLenum -_mesa_get_format_base_format(gl_format format) -{ - const struct gl_format_info *info = _mesa_get_format_info(format); - return info->BaseFormat; -} - - -/** - * Return the block size (in pixels) for the given format. Normally - * the block size is 1x1. But compressed formats will have block sizes - * of 4x4 or 8x4 pixels, etc. - * \param bw returns block width in pixels - * \param bh returns block height in pixels - */ -void -_mesa_get_format_block_size(gl_format format, GLuint *bw, GLuint *bh) -{ - const struct gl_format_info *info = _mesa_get_format_info(format); - *bw = info->BlockWidth; - *bh = info->BlockHeight; -} - - -/** - * Is the given format a signed/unsigned integer color format? - */ -GLboolean -_mesa_is_format_integer_color(gl_format format) -{ - const struct gl_format_info *info = _mesa_get_format_info(format); - return (info->DataType == GL_INT || info->DataType == GL_UNSIGNED_INT) && - info->BaseFormat != GL_DEPTH_COMPONENT && - info->BaseFormat != GL_STENCIL_INDEX; -} - - -GLuint -_mesa_format_num_components(gl_format format) -{ - const struct gl_format_info *info = _mesa_get_format_info(format); - return ((info->RedBits > 0) + - (info->GreenBits > 0) + - (info->BlueBits > 0) + - (info->AlphaBits > 0) + - (info->LuminanceBits > 0) + - (info->IntensityBits > 0) + - (info->DepthBits > 0) + - (info->StencilBits > 0)); -} - - -/** - * Return number of bytes needed to store an image of the given size - * in the given format. - */ -GLuint -_mesa_format_image_size(gl_format format, GLsizei width, - GLsizei height, GLsizei depth) -{ - const struct gl_format_info *info = _mesa_get_format_info(format); - /* Strictly speaking, a conditional isn't needed here */ - if (info->BlockWidth > 1 || info->BlockHeight > 1) { - /* compressed format (2D only for now) */ - const GLuint bw = info->BlockWidth, bh = info->BlockHeight; - const GLuint wblocks = (width + bw - 1) / bw; - const GLuint hblocks = (height + bh - 1) / bh; - const GLuint sz = wblocks * hblocks * info->BytesPerBlock; - assert(depth == 1); - return sz; - } - else { - /* non-compressed */ - const GLuint sz = width * height * depth * info->BytesPerBlock; - return sz; - } -} - - -/** - * Same as _mesa_format_image_size() but returns a 64-bit value to - * accomodate very large textures. - */ -uint64_t -_mesa_format_image_size64(gl_format format, GLsizei width, - GLsizei height, GLsizei depth) -{ - const struct gl_format_info *info = _mesa_get_format_info(format); - /* Strictly speaking, a conditional isn't needed here */ - if (info->BlockWidth > 1 || info->BlockHeight > 1) { - /* compressed format (2D only for now) */ - const uint64_t bw = info->BlockWidth, bh = info->BlockHeight; - const uint64_t wblocks = (width + bw - 1) / bw; - const uint64_t hblocks = (height + bh - 1) / bh; - const uint64_t sz = wblocks * hblocks * info->BytesPerBlock; - assert(depth == 1); - return sz; - } - else { - /* non-compressed */ - const uint64_t sz = ((uint64_t) width * - (uint64_t) height * - (uint64_t) depth * - info->BytesPerBlock); - return sz; - } -} - - - -GLint -_mesa_format_row_stride(gl_format format, GLsizei width) -{ - const struct gl_format_info *info = _mesa_get_format_info(format); - /* Strictly speaking, a conditional isn't needed here */ - if (info->BlockWidth > 1 || info->BlockHeight > 1) { - /* compressed format */ - const GLuint bw = info->BlockWidth; - const GLuint wblocks = (width + bw - 1) / bw; - const GLint stride = wblocks * info->BytesPerBlock; - return stride; - } - else { - const GLint stride = width * info->BytesPerBlock; - return stride; - } -} - - -/** - * Debug/test: check that all formats are handled in the - * _mesa_format_to_type_and_comps() function. When new pixel formats - * are added to Mesa, that function needs to be updated. - * This is a no-op after the first call. - */ -static void -check_format_to_type_and_comps(void) -{ - gl_format f; - - for (f = MESA_FORMAT_NONE + 1; f < MESA_FORMAT_COUNT; f++) { - GLenum datatype = 0; - GLuint comps = 0; - /* This function will emit a problem/warning if the format is - * not handled. - */ - _mesa_format_to_type_and_comps(f, &datatype, &comps); - } -} - - -/** - * Do sanity checking of the format info table. - */ -void -_mesa_test_formats(void) -{ - GLuint i; - - STATIC_ASSERT(Elements(format_info) == MESA_FORMAT_COUNT); - - for (i = 0; i < MESA_FORMAT_COUNT; i++) { - const struct gl_format_info *info = _mesa_get_format_info(i); - assert(info); - - assert(info->Name == i); - - if (info->Name == MESA_FORMAT_NONE) - continue; - - if (info->BlockWidth == 1 && info->BlockHeight == 1) { - if (info->RedBits > 0) { - GLuint t = info->RedBits + info->GreenBits - + info->BlueBits + info->AlphaBits; - assert(t / 8 <= info->BytesPerBlock); - (void) t; - } - } - - assert(info->DataType == GL_UNSIGNED_NORMALIZED || - info->DataType == GL_SIGNED_NORMALIZED || - info->DataType == GL_UNSIGNED_INT || - info->DataType == GL_INT || - info->DataType == GL_FLOAT || - /* Z32_FLOAT_X24S8 has DataType of GL_NONE */ - info->DataType == GL_NONE); - - if (info->BaseFormat == GL_RGB) { - assert(info->RedBits > 0); - assert(info->GreenBits > 0); - assert(info->BlueBits > 0); - assert(info->AlphaBits == 0); - assert(info->LuminanceBits == 0); - assert(info->IntensityBits == 0); - } - else if (info->BaseFormat == GL_RGBA) { - assert(info->RedBits > 0); - assert(info->GreenBits > 0); - assert(info->BlueBits > 0); - assert(info->AlphaBits > 0); - assert(info->LuminanceBits == 0); - assert(info->IntensityBits == 0); - } - else if (info->BaseFormat == GL_RG) { - assert(info->RedBits > 0); - assert(info->GreenBits > 0); - assert(info->BlueBits == 0); - assert(info->AlphaBits == 0); - assert(info->LuminanceBits == 0); - assert(info->IntensityBits == 0); - } - else if (info->BaseFormat == GL_RED) { - assert(info->RedBits > 0); - assert(info->GreenBits == 0); - assert(info->BlueBits == 0); - assert(info->AlphaBits == 0); - assert(info->LuminanceBits == 0); - assert(info->IntensityBits == 0); - } - else if (info->BaseFormat == GL_LUMINANCE) { - assert(info->RedBits == 0); - assert(info->GreenBits == 0); - assert(info->BlueBits == 0); - assert(info->AlphaBits == 0); - assert(info->LuminanceBits > 0); - assert(info->IntensityBits == 0); - } - else if (info->BaseFormat == GL_INTENSITY) { - assert(info->RedBits == 0); - assert(info->GreenBits == 0); - assert(info->BlueBits == 0); - assert(info->AlphaBits == 0); - assert(info->LuminanceBits == 0); - assert(info->IntensityBits > 0); - } - } - - check_format_to_type_and_comps(); -} - - - -/** - * Return datatype and number of components per texel for the given gl_format. - * Only used for mipmap generation code. - */ -void -_mesa_format_to_type_and_comps(gl_format format, - GLenum *datatype, GLuint *comps) -{ - switch (format) { - case MESA_FORMAT_RGBA8888: - case MESA_FORMAT_RGBA8888_REV: - case MESA_FORMAT_ARGB8888: - case MESA_FORMAT_ARGB8888_REV: - case MESA_FORMAT_RGBX8888: - case MESA_FORMAT_RGBX8888_REV: - case MESA_FORMAT_XRGB8888: - case MESA_FORMAT_XRGB8888_REV: - *datatype = GL_UNSIGNED_BYTE; - *comps = 4; - return; - case MESA_FORMAT_RGB888: - case MESA_FORMAT_BGR888: - *datatype = GL_UNSIGNED_BYTE; - *comps = 3; - return; - case MESA_FORMAT_RGB565: - case MESA_FORMAT_RGB565_REV: - *datatype = GL_UNSIGNED_SHORT_5_6_5; - *comps = 3; - return; - - case MESA_FORMAT_ARGB4444: - case MESA_FORMAT_ARGB4444_REV: - *datatype = GL_UNSIGNED_SHORT_4_4_4_4; - *comps = 4; - return; - - case MESA_FORMAT_ARGB1555: - case MESA_FORMAT_ARGB1555_REV: - *datatype = GL_UNSIGNED_SHORT_1_5_5_5_REV; - *comps = 4; - return; - - case MESA_FORMAT_RGBA5551: - *datatype = GL_UNSIGNED_SHORT_5_5_5_1; - *comps = 4; - return; - - case MESA_FORMAT_AL44: - *datatype = MESA_UNSIGNED_BYTE_4_4; - *comps = 2; - return; - - case MESA_FORMAT_AL88: - case MESA_FORMAT_AL88_REV: - *datatype = GL_UNSIGNED_BYTE; - *comps = 2; - return; - - case MESA_FORMAT_AL1616: - case MESA_FORMAT_AL1616_REV: - *datatype = GL_UNSIGNED_SHORT; - *comps = 2; - return; - - case MESA_FORMAT_A16: - case MESA_FORMAT_L16: - case MESA_FORMAT_I16: - *datatype = GL_UNSIGNED_SHORT; - *comps = 1; - return; - - case MESA_FORMAT_RGB332: - *datatype = GL_UNSIGNED_BYTE_3_3_2; - *comps = 3; - return; - - case MESA_FORMAT_A8: - case MESA_FORMAT_L8: - case MESA_FORMAT_I8: - case MESA_FORMAT_S8: - *datatype = GL_UNSIGNED_BYTE; - *comps = 1; - return; - - case MESA_FORMAT_YCBCR: - case MESA_FORMAT_YCBCR_REV: - *datatype = GL_UNSIGNED_SHORT; - *comps = 2; - return; - - case MESA_FORMAT_Z16: - *datatype = GL_UNSIGNED_SHORT; - *comps = 1; - return; - - case MESA_FORMAT_X8_Z24: - *datatype = GL_UNSIGNED_INT; - *comps = 1; - return; - - case MESA_FORMAT_Z24_X8: - *datatype = GL_UNSIGNED_INT; - *comps = 1; - return; - - case MESA_FORMAT_Z32: - *datatype = GL_UNSIGNED_INT; - *comps = 1; - return; - - case MESA_FORMAT_RGBA_16: - *datatype = GL_UNSIGNED_SHORT; - *comps = 4; - return; - - case MESA_FORMAT_SIGNED_RGBA_16: - *datatype = GL_SHORT; - *comps = 4; - return; - - case MESA_FORMAT_ALPHA_UINT8: - case MESA_FORMAT_LUMINANCE_UINT8: - case MESA_FORMAT_INTENSITY_UINT8: - *datatype = GL_UNSIGNED_BYTE; - *comps = 1; - return; - case MESA_FORMAT_LUMINANCE_ALPHA_UINT8: - *datatype = GL_UNSIGNED_BYTE; - *comps = 2; - return; - - case MESA_FORMAT_ALPHA_UINT16: - case MESA_FORMAT_LUMINANCE_UINT16: - case MESA_FORMAT_INTENSITY_UINT16: - *datatype = GL_UNSIGNED_SHORT; - *comps = 1; - return; - case MESA_FORMAT_LUMINANCE_ALPHA_UINT16: - *datatype = GL_UNSIGNED_SHORT; - *comps = 2; - return; - case MESA_FORMAT_ALPHA_UINT32: - case MESA_FORMAT_LUMINANCE_UINT32: - case MESA_FORMAT_INTENSITY_UINT32: - *datatype = GL_UNSIGNED_INT; - *comps = 1; - return; - case MESA_FORMAT_LUMINANCE_ALPHA_UINT32: - *datatype = GL_UNSIGNED_INT; - *comps = 2; - return; - case MESA_FORMAT_ALPHA_INT8: - case MESA_FORMAT_LUMINANCE_INT8: - case MESA_FORMAT_INTENSITY_INT8: - *datatype = GL_BYTE; - *comps = 1; - return; - case MESA_FORMAT_LUMINANCE_ALPHA_INT8: - *datatype = GL_BYTE; - *comps = 2; - return; - - case MESA_FORMAT_ALPHA_INT16: - case MESA_FORMAT_LUMINANCE_INT16: - case MESA_FORMAT_INTENSITY_INT16: - *datatype = GL_SHORT; - *comps = 1; - return; - case MESA_FORMAT_LUMINANCE_ALPHA_INT16: - *datatype = GL_SHORT; - *comps = 2; - return; - - case MESA_FORMAT_ALPHA_INT32: - case MESA_FORMAT_LUMINANCE_INT32: - case MESA_FORMAT_INTENSITY_INT32: - *datatype = GL_INT; - *comps = 1; - return; - case MESA_FORMAT_LUMINANCE_ALPHA_INT32: - *datatype = GL_INT; - *comps = 2; - return; - - case MESA_FORMAT_RGB_INT8: - *datatype = GL_BYTE; - *comps = 3; - return; - case MESA_FORMAT_RGBA_INT8: - *datatype = GL_BYTE; - *comps = 4; - return; - case MESA_FORMAT_RGB_INT16: - *datatype = GL_SHORT; - *comps = 3; - return; - case MESA_FORMAT_RGBA_INT16: - *datatype = GL_SHORT; - *comps = 4; - return; - case MESA_FORMAT_RGB_INT32: - *datatype = GL_INT; - *comps = 3; - return; - case MESA_FORMAT_RGBA_INT32: - *datatype = GL_INT; - *comps = 4; - return; - - /** - * \name Non-normalized unsigned integer formats. - */ - case MESA_FORMAT_RGB_UINT8: - *datatype = GL_UNSIGNED_BYTE; - *comps = 3; - return; - case MESA_FORMAT_RGBA_UINT8: - *datatype = GL_UNSIGNED_BYTE; - *comps = 4; - return; - case MESA_FORMAT_RGB_UINT16: - *datatype = GL_UNSIGNED_SHORT; - *comps = 3; - return; - case MESA_FORMAT_RGBA_UINT16: - *datatype = GL_UNSIGNED_SHORT; - *comps = 4; - return; - case MESA_FORMAT_RGB_UINT32: - *datatype = GL_UNSIGNED_INT; - *comps = 3; - return; - case MESA_FORMAT_RGBA_UINT32: - *datatype = GL_UNSIGNED_INT; - *comps = 4; - return; - - case MESA_FORMAT_COUNT: - assert(0); - return; - - case MESA_FORMAT_NONE: - /* For debug builds, warn if any formats are not handled */ -#ifdef DEBUG - default: -#endif - _mesa_problem(NULL, "bad format %s in _mesa_format_to_type_and_comps", - _mesa_get_format_name(format)); - *datatype = 0; - *comps = 1; - } -} - -/** - * Check if a gl_format exactly matches a GL formaat/type combination - * such that we can use memcpy() from one to the other. - * - * Note: this matching assumes that GL_PACK/UNPACK_SWAP_BYTES is unset. - * - * \return GL_TRUE if the formats match, GL_FALSE otherwise. - */ -GLboolean -_mesa_format_matches_format_and_type(gl_format gl_format, - GLenum format, GLenum type) -{ - const GLboolean littleEndian = _mesa_little_endian(); - - /* Note: When reading a GL format/type combination, the format lists channel - * assignments from most significant channel in the type to least - * significant. A type with _REV indicates that the assignments are - * swapped, so they are listed from least significant to most significant. - * - * For sanity, please keep this switch statement ordered the same as the - * enums in formats.h. - */ - - switch (gl_format) { - - case MESA_FORMAT_NONE: - case MESA_FORMAT_COUNT: - return GL_FALSE; - - case MESA_FORMAT_RGBA8888: - return ((format == GL_RGBA && (type == GL_UNSIGNED_INT_8_8_8_8 || - (type == GL_UNSIGNED_BYTE && !littleEndian))) || - (format == GL_ABGR_EXT && (type == GL_UNSIGNED_INT_8_8_8_8_REV || - (type == GL_UNSIGNED_BYTE && littleEndian)))); - - case MESA_FORMAT_RGBA8888_REV: - return ((format == GL_RGBA && type == GL_UNSIGNED_INT_8_8_8_8_REV)); - - case MESA_FORMAT_ARGB8888: - return ((format == GL_BGRA && (type == GL_UNSIGNED_INT_8_8_8_8_REV || - (type == GL_UNSIGNED_BYTE && littleEndian)))); - - case MESA_FORMAT_ARGB8888_REV: - return ((format == GL_BGRA && (type == GL_UNSIGNED_INT_8_8_8_8 || - (type == GL_UNSIGNED_BYTE && !littleEndian)))); - - case MESA_FORMAT_RGBX8888: - case MESA_FORMAT_RGBX8888_REV: - return GL_FALSE; - - case MESA_FORMAT_XRGB8888: - case MESA_FORMAT_XRGB8888_REV: - return GL_FALSE; - - case MESA_FORMAT_RGB888: - return format == GL_BGR && type == GL_UNSIGNED_BYTE && littleEndian; - - case MESA_FORMAT_BGR888: - return format == GL_RGB && type == GL_UNSIGNED_BYTE && littleEndian; - - case MESA_FORMAT_RGB565: - return format == GL_RGB && type == GL_UNSIGNED_SHORT_5_6_5; - case MESA_FORMAT_RGB565_REV: - /* Some of the 16-bit MESA_FORMATs that would seem to correspond to - * GL_UNSIGNED_SHORT_* are byte-swapped instead of channel-reversed, - * according to formats.h, so they can't be matched. - */ - return GL_FALSE; - - case MESA_FORMAT_ARGB4444: - return format == GL_BGRA && type == GL_UNSIGNED_SHORT_4_4_4_4_REV; - case MESA_FORMAT_ARGB4444_REV: - return GL_FALSE; - - case MESA_FORMAT_RGBA5551: - return format == GL_RGBA && type == GL_UNSIGNED_SHORT_5_5_5_1; - - case MESA_FORMAT_ARGB1555: - return format == GL_BGRA && type == GL_UNSIGNED_SHORT_1_5_5_5_REV; - case MESA_FORMAT_ARGB1555_REV: - return GL_FALSE; - - case MESA_FORMAT_AL44: - return GL_FALSE; - case MESA_FORMAT_AL88: - return format == GL_LUMINANCE_ALPHA && type == GL_UNSIGNED_BYTE && littleEndian; - case MESA_FORMAT_AL88_REV: - return GL_FALSE; - - case MESA_FORMAT_AL1616: - return format == GL_LUMINANCE_ALPHA && type == GL_UNSIGNED_SHORT && littleEndian; - case MESA_FORMAT_AL1616_REV: - return GL_FALSE; - - case MESA_FORMAT_RGB332: - return format == GL_RGB && type == GL_UNSIGNED_BYTE_3_3_2; - - case MESA_FORMAT_A8: - return format == GL_ALPHA && type == GL_UNSIGNED_BYTE; - case MESA_FORMAT_A16: - return format == GL_ALPHA && type == GL_UNSIGNED_SHORT && littleEndian; - case MESA_FORMAT_L8: - return format == GL_LUMINANCE && type == GL_UNSIGNED_BYTE; - case MESA_FORMAT_L16: - return format == GL_LUMINANCE && type == GL_UNSIGNED_SHORT && littleEndian; - case MESA_FORMAT_I8: - return format == GL_INTENSITY && type == GL_UNSIGNED_BYTE; - case MESA_FORMAT_I16: - return format == GL_INTENSITY && type == GL_UNSIGNED_SHORT && littleEndian; - - case MESA_FORMAT_YCBCR: - case MESA_FORMAT_YCBCR_REV: - return GL_FALSE; - - case MESA_FORMAT_Z24_X8: - return GL_FALSE; - - case MESA_FORMAT_Z16: - return format == GL_DEPTH_COMPONENT && type == GL_UNSIGNED_SHORT; - - case MESA_FORMAT_X8_Z24: - return GL_FALSE; - - case MESA_FORMAT_Z32: - return format == GL_DEPTH_COMPONENT && type == GL_UNSIGNED_INT; - - case MESA_FORMAT_S8: - return GL_FALSE; - - /* FINISHME: What do we want to do for GL_EXT_texture_integer? */ - case MESA_FORMAT_ALPHA_UINT8: - case MESA_FORMAT_ALPHA_UINT16: - case MESA_FORMAT_ALPHA_UINT32: - case MESA_FORMAT_ALPHA_INT8: - case MESA_FORMAT_ALPHA_INT16: - case MESA_FORMAT_ALPHA_INT32: - return GL_FALSE; - - case MESA_FORMAT_INTENSITY_UINT8: - case MESA_FORMAT_INTENSITY_UINT16: - case MESA_FORMAT_INTENSITY_UINT32: - case MESA_FORMAT_INTENSITY_INT8: - case MESA_FORMAT_INTENSITY_INT16: - case MESA_FORMAT_INTENSITY_INT32: - return GL_FALSE; - - case MESA_FORMAT_LUMINANCE_UINT8: - case MESA_FORMAT_LUMINANCE_UINT16: - case MESA_FORMAT_LUMINANCE_UINT32: - case MESA_FORMAT_LUMINANCE_INT8: - case MESA_FORMAT_LUMINANCE_INT16: - case MESA_FORMAT_LUMINANCE_INT32: - return GL_FALSE; - - case MESA_FORMAT_LUMINANCE_ALPHA_UINT8: - case MESA_FORMAT_LUMINANCE_ALPHA_UINT16: - case MESA_FORMAT_LUMINANCE_ALPHA_UINT32: - case MESA_FORMAT_LUMINANCE_ALPHA_INT8: - case MESA_FORMAT_LUMINANCE_ALPHA_INT16: - case MESA_FORMAT_LUMINANCE_ALPHA_INT32: - return GL_FALSE; - - case MESA_FORMAT_RGB_INT8: - case MESA_FORMAT_RGBA_INT8: - case MESA_FORMAT_RGB_INT16: - case MESA_FORMAT_RGBA_INT16: - case MESA_FORMAT_RGB_INT32: - case MESA_FORMAT_RGBA_INT32: - return GL_FALSE; - - case MESA_FORMAT_RGB_UINT8: - case MESA_FORMAT_RGBA_UINT8: - case MESA_FORMAT_RGB_UINT16: - case MESA_FORMAT_RGBA_UINT16: - case MESA_FORMAT_RGB_UINT32: - case MESA_FORMAT_RGBA_UINT32: - return GL_FALSE; - - case MESA_FORMAT_SIGNED_RGBA_16: - case MESA_FORMAT_RGBA_16: - /* FINISHME: SNORM */ - return GL_FALSE; - } - - return GL_FALSE; -} diff --git a/dll/opengl/mesa/main/formats.h b/dll/opengl/mesa/main/formats.h deleted file mode 100644 index 5a93a5c5a8e..00000000000 --- a/dll/opengl/mesa/main/formats.h +++ /dev/null @@ -1,226 +0,0 @@ -/* - * Mesa 3-D graphics library - * Version: 7.7 - * - * Copyright (C) 1999-2008 Brian Paul All Rights Reserved. - * Copyright (c) 2008-2009 VMware, Inc. - * - * Permission is hereby granted, free of charge, to any person obtaining a - * copy of this software and associated documentation files (the "Software"), - * to deal in the Software without restriction, including without limitation - * the rights to use, copy, modify, merge, publish, distribute, sublicense, - * and/or sell copies of the Software, and to permit persons to whom the - * Software is furnished to do so, subject to the following conditions: - * - * The above copyright notice and this permission notice shall be included - * in all copies or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS - * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL - * BRIAN PAUL BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN - * AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN - * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. - */ - -/* - * Authors: - * Brian Paul - */ - - -#ifndef FORMATS_H -#define FORMATS_H - - -#include - - -#ifdef __cplusplus -extern "C" { -#endif - - -/* OpenGL doesn't have GL_UNSIGNED_BYTE_4_4, so we must define our own type - * for GL_LUMINANCE4_ALPHA4. */ -#define MESA_UNSIGNED_BYTE_4_4 (GL_UNSIGNED_BYTE<<1) - - -/** - * Max number of bytes for any non-compressed pixel format below, or for - * intermediate pixel storage in Mesa. This should never be less than - * 16. Maybe 32 someday? - */ -#define MAX_PIXEL_BYTES 16 - - -/** - * Mesa texture/renderbuffer image formats. - */ -typedef enum -{ - MESA_FORMAT_NONE = 0, - - /** - * \name Basic hardware formats - */ - /*@{*/ - /* msb <------ TEXEL BITS -----------> lsb */ - /* ---- ---- ---- ---- ---- ---- ---- ---- */ - MESA_FORMAT_RGBA8888, /* RRRR RRRR GGGG GGGG BBBB BBBB AAAA AAAA */ - MESA_FORMAT_RGBA8888_REV, /* AAAA AAAA BBBB BBBB GGGG GGGG RRRR RRRR */ - MESA_FORMAT_ARGB8888, /* AAAA AAAA RRRR RRRR GGGG GGGG BBBB BBBB */ - MESA_FORMAT_ARGB8888_REV, /* BBBB BBBB GGGG GGGG RRRR RRRR AAAA AAAA */ - MESA_FORMAT_RGBX8888, /* RRRR RRRR GGGG GGGG BBBB BBBB XXXX XXXX */ - MESA_FORMAT_RGBX8888_REV, /* xxxx xxxx BBBB BBBB GGGG GGGG RRRR RRRR */ - MESA_FORMAT_XRGB8888, /* xxxx xxxx RRRR RRRR GGGG GGGG BBBB BBBB */ - MESA_FORMAT_XRGB8888_REV, /* BBBB BBBB GGGG GGGG RRRR RRRR xxxx xxxx */ - MESA_FORMAT_RGB888, /* RRRR RRRR GGGG GGGG BBBB BBBB */ - MESA_FORMAT_BGR888, /* BBBB BBBB GGGG GGGG RRRR RRRR */ - MESA_FORMAT_RGB565, /* RRRR RGGG GGGB BBBB */ - MESA_FORMAT_RGB565_REV, /* GGGB BBBB RRRR RGGG */ - MESA_FORMAT_ARGB4444, /* AAAA RRRR GGGG BBBB */ - MESA_FORMAT_ARGB4444_REV, /* GGGG BBBB AAAA RRRR */ - MESA_FORMAT_RGBA5551, /* RRRR RGGG GGBB BBBA */ - MESA_FORMAT_ARGB1555, /* ARRR RRGG GGGB BBBB */ - MESA_FORMAT_ARGB1555_REV, /* GGGB BBBB ARRR RRGG */ - MESA_FORMAT_AL44, /* AAAA LLLL */ - MESA_FORMAT_AL88, /* AAAA AAAA LLLL LLLL */ - MESA_FORMAT_AL88_REV, /* LLLL LLLL AAAA AAAA */ - MESA_FORMAT_AL1616, /* AAAA AAAA AAAA AAAA LLLL LLLL LLLL LLLL */ - MESA_FORMAT_AL1616_REV, /* LLLL LLLL LLLL LLLL AAAA AAAA AAAA AAAA */ - MESA_FORMAT_RGB332, /* RRRG GGBB */ - MESA_FORMAT_A8, /* AAAA AAAA */ - MESA_FORMAT_A16, /* AAAA AAAA AAAA AAAA */ - MESA_FORMAT_L8, /* LLLL LLLL */ - MESA_FORMAT_L16, /* LLLL LLLL LLLL LLLL */ - MESA_FORMAT_I8, /* IIII IIII */ - MESA_FORMAT_I16, /* IIII IIII IIII IIII */ - MESA_FORMAT_YCBCR, /* YYYY YYYY UorV UorV */ - MESA_FORMAT_YCBCR_REV, /* UorV UorV YYYY YYYY */ - MESA_FORMAT_Z16, /* ZZZZ ZZZZ ZZZZ ZZZZ */ - MESA_FORMAT_X8_Z24, /* xxxx xxxx ZZZZ ZZZZ ZZZZ ZZZZ ZZZZ ZZZZ */ - MESA_FORMAT_Z24_X8, /* ZZZZ ZZZZ ZZZZ ZZZZ ZZZZ ZZZZ xxxx xxxx */ - MESA_FORMAT_Z32, /* ZZZZ ZZZZ ZZZZ ZZZZ ZZZZ ZZZZ ZZZZ ZZZZ */ - MESA_FORMAT_S8, /* SSSS SSSS */ - /*@}*/ - - /** - * \name Non-normalized signed integer formats. - * XXX Note: these are just stand-ins for some better hardware - * formats TBD such as BGRA or ARGB. - */ - MESA_FORMAT_ALPHA_UINT8, - MESA_FORMAT_ALPHA_UINT16, - MESA_FORMAT_ALPHA_UINT32, - MESA_FORMAT_ALPHA_INT8, - MESA_FORMAT_ALPHA_INT16, - MESA_FORMAT_ALPHA_INT32, - - MESA_FORMAT_INTENSITY_UINT8, - MESA_FORMAT_INTENSITY_UINT16, - MESA_FORMAT_INTENSITY_UINT32, - MESA_FORMAT_INTENSITY_INT8, - MESA_FORMAT_INTENSITY_INT16, - MESA_FORMAT_INTENSITY_INT32, - - MESA_FORMAT_LUMINANCE_UINT8, - MESA_FORMAT_LUMINANCE_UINT16, - MESA_FORMAT_LUMINANCE_UINT32, - MESA_FORMAT_LUMINANCE_INT8, - MESA_FORMAT_LUMINANCE_INT16, - MESA_FORMAT_LUMINANCE_INT32, - - MESA_FORMAT_LUMINANCE_ALPHA_UINT8, - MESA_FORMAT_LUMINANCE_ALPHA_UINT16, - MESA_FORMAT_LUMINANCE_ALPHA_UINT32, - MESA_FORMAT_LUMINANCE_ALPHA_INT8, - MESA_FORMAT_LUMINANCE_ALPHA_INT16, - MESA_FORMAT_LUMINANCE_ALPHA_INT32, - - MESA_FORMAT_RGB_INT8, - MESA_FORMAT_RGBA_INT8, - MESA_FORMAT_RGB_INT16, - MESA_FORMAT_RGBA_INT16, - MESA_FORMAT_RGB_INT32, - MESA_FORMAT_RGBA_INT32, - - /** - * \name Non-normalized unsigned integer formats. - */ - MESA_FORMAT_RGB_UINT8, - MESA_FORMAT_RGBA_UINT8, - MESA_FORMAT_RGB_UINT16, - MESA_FORMAT_RGBA_UINT16, - MESA_FORMAT_RGB_UINT32, - MESA_FORMAT_RGBA_UINT32, - - /* msb <------ TEXEL BITS -----------> lsb */ - /* ---- ---- ---- ---- ---- ---- ---- ---- */ - /** - * \name Signed fixed point texture formats. - */ - /*@{*/ - MESA_FORMAT_SIGNED_RGBA_16, /* ... */ - MESA_FORMAT_RGBA_16, /* ... */ - /*@}*/ - - MESA_FORMAT_COUNT -} gl_format; - - -extern const char * -_mesa_get_format_name(gl_format format); - -extern GLint -_mesa_get_format_bytes(gl_format format); - -extern GLint -_mesa_get_format_bits(gl_format format, GLenum pname); - -extern GLuint -_mesa_get_format_max_bits(gl_format format); - -extern GLenum -_mesa_get_format_datatype(gl_format format); - -extern GLenum -_mesa_get_format_base_format(gl_format format); - -extern void -_mesa_get_format_block_size(gl_format format, GLuint *bw, GLuint *bh); - -extern GLboolean -_mesa_is_format_integer_color(gl_format format); - -extern GLuint -_mesa_format_image_size(gl_format format, GLsizei width, - GLsizei height, GLsizei depth); - -extern uint64_t -_mesa_format_image_size64(gl_format format, GLsizei width, - GLsizei height, GLsizei depth); - -extern GLint -_mesa_format_row_stride(gl_format format, GLsizei width); - -extern void -_mesa_format_to_type_and_comps(gl_format format, - GLenum *datatype, GLuint *comps); - -extern void -_mesa_test_formats(void); - -extern GLuint -_mesa_format_num_components(gl_format format); - -GLboolean -_mesa_format_matches_format_and_type(gl_format gl_format, - GLenum format, GLenum type); - - -#ifdef __cplusplus -} -#endif - -#endif /* FORMATS_H */ diff --git a/dll/opengl/mesa/main/framebuffer.c b/dll/opengl/mesa/main/framebuffer.c deleted file mode 100644 index 4381d7e6f07..00000000000 --- a/dll/opengl/mesa/main/framebuffer.c +++ /dev/null @@ -1,623 +0,0 @@ -/* - * Mesa 3-D graphics library - * Version: 7.2 - * - * Copyright (C) 1999-2008 Brian Paul All Rights Reserved. - * - * Permission is hereby granted, free of charge, to any person obtaining a - * copy of this software and associated documentation files (the "Software"), - * to deal in the Software without restriction, including without limitation - * the rights to use, copy, modify, merge, publish, distribute, sublicense, - * and/or sell copies of the Software, and to permit persons to whom the - * Software is furnished to do so, subject to the following conditions: - * - * The above copyright notice and this permission notice shall be included - * in all copies or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS - * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL - * BRIAN PAUL BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN - * AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN - * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. - */ - -/** - * Functions for allocating/managing framebuffers and renderbuffers. - * Also, routines for reading/writing renderbuffer data as ubytes, - * ushorts, uints, etc. - */ - -#include - -/** - * Compute/set the _DepthMax field for the given framebuffer. - * This value depends on the Z buffer resolution. - */ -static void -compute_depth_max(struct gl_framebuffer *fb) -{ - if (fb->Visual.depthBits == 0) { - /* Special case. Even if we don't have a depth buffer we need - * good values for DepthMax for Z vertex transformation purposes - * and for per-fragment fog computation. - */ - fb->_DepthMax = (1 << 16) - 1; - } - else if (fb->Visual.depthBits < 32) { - fb->_DepthMax = (1 << fb->Visual.depthBits) - 1; - } - else { - /* Special case since shift values greater than or equal to the - * number of bits in the left hand expression's type are undefined. - */ - fb->_DepthMax = 0xffffffff; - } - fb->_DepthMaxF = (GLfloat) fb->_DepthMax; - - /* Minimum resolvable depth value, for polygon offset */ - fb->_MRD = (GLfloat)1.0 / fb->_DepthMaxF; -} - -/** - * Create and initialize a gl_framebuffer object. - * This is intended for creating _window_system_ framebuffers, not generic - * framebuffer objects ala GL_EXT_framebuffer_object. - * - * \sa _mesa_new_framebuffer - */ -struct gl_framebuffer * -_mesa_create_framebuffer(const struct gl_config *visual) -{ - struct gl_framebuffer *fb = CALLOC_STRUCT(gl_framebuffer); - assert(visual); - if (fb) { - _mesa_initialize_window_framebuffer(fb, visual); - } - return fb; -} - - -/** - * Initialize a gl_framebuffer object. Typically used to initialize - * window system-created framebuffers, not user-created framebuffers. - * \sa _mesa_initialize_user_framebuffer - */ -void -_mesa_initialize_window_framebuffer(struct gl_framebuffer *fb, - const struct gl_config *visual) -{ - assert(fb); - assert(visual); - - memset(fb, 0, sizeof(struct gl_framebuffer)); - - _glthread_INIT_MUTEX(fb->Mutex); - - fb->RefCount = 1; - - /* save the visual */ - fb->Visual = *visual; - - /* Init read/draw renderbuffer state */ - if (visual->doubleBufferMode) { - fb->ColorDrawBuffer = GL_BACK; - fb->_ColorDrawBufferIndex = BUFFER_BACK_LEFT; - fb->ColorReadBuffer = GL_BACK; - fb->_ColorReadBufferIndex = BUFFER_BACK_LEFT; - } - else { - fb->ColorDrawBuffer = GL_FRONT; - fb->_ColorDrawBufferIndex = BUFFER_FRONT_LEFT; - fb->ColorReadBuffer = GL_FRONT; - fb->_ColorReadBufferIndex = BUFFER_FRONT_LEFT; - } - - fb->Delete = _mesa_destroy_framebuffer; - - compute_depth_max(fb); -} - - -/** - * Deallocate buffer and everything attached to it. - * Typically called via the gl_framebuffer->Delete() method. - */ -void -_mesa_destroy_framebuffer(struct gl_framebuffer *fb) -{ - if (fb) { - _mesa_free_framebuffer_data(fb); - free(fb); - } -} - - -/** - * Free all the data hanging off the given gl_framebuffer, but don't free - * the gl_framebuffer object itself. - */ -void -_mesa_free_framebuffer_data(struct gl_framebuffer *fb) -{ - GLuint i; - - assert(fb); - assert(fb->RefCount == 0); - - _glthread_DESTROY_MUTEX(fb->Mutex); - - for (i = 0; i < BUFFER_COUNT; i++) { - struct gl_renderbuffer_attachment *att = &fb->Attachment[i]; - if (att->Renderbuffer) { - _mesa_reference_renderbuffer(&att->Renderbuffer, NULL); - } - } -} - - -/** - * Set *ptr to point to fb, with refcounting and locking. - * This is normally only called from the _mesa_reference_framebuffer() macro - * when there's a real pointer change. - */ -void -_mesa_reference_framebuffer_(struct gl_framebuffer **ptr, - struct gl_framebuffer *fb) -{ - if (*ptr) { - /* unreference old renderbuffer */ - GLboolean deleteFlag = GL_FALSE; - struct gl_framebuffer *oldFb = *ptr; - - _glthread_LOCK_MUTEX(oldFb->Mutex); - ASSERT(oldFb->RefCount > 0); - oldFb->RefCount--; - deleteFlag = (oldFb->RefCount == 0); - _glthread_UNLOCK_MUTEX(oldFb->Mutex); - - if (deleteFlag) - oldFb->Delete(oldFb); - - *ptr = NULL; - } - assert(!*ptr); - - if (fb) { - _glthread_LOCK_MUTEX(fb->Mutex); - fb->RefCount++; - _glthread_UNLOCK_MUTEX(fb->Mutex); - *ptr = fb; - } -} - - -/** - * Resize the given framebuffer's renderbuffers to the new width and height. - * This should only be used for window-system framebuffers, not - * user-created renderbuffers (i.e. made with GL_EXT_framebuffer_object). - * This will typically be called via ctx->Driver.ResizeBuffers() or directly - * from a device driver. - * - * \note it's possible for ctx to be null since a window can be resized - * without a currently bound rendering context. - */ -void -_mesa_resize_framebuffer(struct gl_context *ctx, struct gl_framebuffer *fb, - GLuint width, GLuint height) -{ - GLuint i; - for (i = 0; i < BUFFER_COUNT; i++) { - struct gl_renderbuffer_attachment *att = &fb->Attachment[i]; - if (att->Renderbuffer) { - struct gl_renderbuffer *rb = att->Renderbuffer; - /* only resize if size is changing */ - if (rb->Width != width || rb->Height != height) { - if (rb->AllocStorage(ctx, rb, rb->InternalFormat, width, height)) { - ASSERT(rb->Width == width); - ASSERT(rb->Height == height); - } - else { - _mesa_error(ctx, GL_OUT_OF_MEMORY, "Resizing framebuffer"); - /* no return */ - } - } - } - } - - fb->Width = width; - fb->Height = height; - - if (ctx) { - /* update scissor / window bounds */ - _mesa_update_draw_buffer_bounds(ctx); - /* Signal new buffer state so that swrast will update its clipping - * info (the CLIP_BIT flag). - */ - ctx->NewState |= _NEW_BUFFERS; - } -} - - - -/** - * XXX THIS IS OBSOLETE - drivers should take care of detecting window - * size changes and act accordingly, likely calling _mesa_resize_framebuffer(). - * - * GL_MESA_resize_buffers extension. - * - * When this function is called, we'll ask the window system how large - * the current window is. If it's a new size, we'll call the driver's - * ResizeBuffers function. The driver will then resize its color buffers - * as needed, and maybe call the swrast's routine for reallocating - * swrast-managed depth/stencil/accum/etc buffers. - * \note This function should only be called through the GL API, not - * from device drivers (as was done in the past). - */ -void -_mesa_resizebuffers( struct gl_context *ctx ) -{ - ASSERT_OUTSIDE_BEGIN_END_AND_FLUSH( ctx ); - - if (MESA_VERBOSE & VERBOSE_API) - _mesa_debug(ctx, "glResizeBuffersMESA\n"); - - if (!ctx->Driver.GetBufferSize) { - return; - } - - if (ctx->WinSysDrawBuffer) { - GLuint newWidth, newHeight; - struct gl_framebuffer *buffer = ctx->WinSysDrawBuffer; - - /* ask device driver for size of output buffer */ - ctx->Driver.GetBufferSize( buffer, &newWidth, &newHeight ); - - /* see if size of device driver's color buffer (window) has changed */ - if (buffer->Width != newWidth || buffer->Height != newHeight) { - if (ctx->Driver.ResizeBuffers) - ctx->Driver.ResizeBuffers(ctx, buffer, newWidth, newHeight ); - } - } - - if (ctx->WinSysReadBuffer - && ctx->WinSysReadBuffer != ctx->WinSysDrawBuffer) { - GLuint newWidth, newHeight; - struct gl_framebuffer *buffer = ctx->WinSysReadBuffer; - - /* ask device driver for size of read buffer */ - ctx->Driver.GetBufferSize( buffer, &newWidth, &newHeight ); - - /* see if size of device driver's color buffer (window) has changed */ - if (buffer->Width != newWidth || buffer->Height != newHeight) { - if (ctx->Driver.ResizeBuffers) - ctx->Driver.ResizeBuffers(ctx, buffer, newWidth, newHeight ); - } - } - - ctx->NewState |= _NEW_BUFFERS; /* to update scissor / window bounds */ -} - -/** - * Update the context's current drawing buffer's Xmin, Xmax, Ymin, Ymax fields. - * These values are computed from the buffer's width and height and - * the scissor box, if it's enabled. - * \param ctx the GL context. - */ -void -_mesa_update_draw_buffer_bounds(struct gl_context *ctx) -{ - struct gl_framebuffer *buffer = ctx->DrawBuffer; - - if (!buffer) - return; - - buffer->_Xmin = 0; - buffer->_Ymin = 0; - buffer->_Xmax = buffer->Width; - buffer->_Ymax = buffer->Height; - - if (ctx->Scissor.Enabled) { - if (ctx->Scissor.X > buffer->_Xmin) { - buffer->_Xmin = ctx->Scissor.X; - } - if (ctx->Scissor.Y > buffer->_Ymin) { - buffer->_Ymin = ctx->Scissor.Y; - } - if (ctx->Scissor.X + ctx->Scissor.Width < buffer->_Xmax) { - buffer->_Xmax = ctx->Scissor.X + ctx->Scissor.Width; - } - if (ctx->Scissor.Y + ctx->Scissor.Height < buffer->_Ymax) { - buffer->_Ymax = ctx->Scissor.Y + ctx->Scissor.Height; - } - /* finally, check for empty region */ - if (buffer->_Xmin > buffer->_Xmax) { - buffer->_Xmin = buffer->_Xmax; - } - if (buffer->_Ymin > buffer->_Ymax) { - buffer->_Ymin = buffer->_Ymax; - } - } - - ASSERT(buffer->_Xmin <= buffer->_Xmax); - ASSERT(buffer->_Ymin <= buffer->_Ymax); -} - -/* - * Example DrawBuffers scenarios: - * - * 1. glDrawBuffer(GL_FRONT_AND_BACK), fixed-func or shader writes to - * "gl_FragColor" or program writes to the "result.color" register: - * - * fragment color output renderbuffer - * --------------------- --------------- - * color[0] Front, Back - * - * - * 2. glDrawBuffers(3, [GL_FRONT, GL_AUX0, GL_AUX1]), shader writes to - * gl_FragData[i] or program writes to result.color[i] registers: - * - * fragment color output renderbuffer - * --------------------- --------------- - * color[0] Front - * color[1] Aux0 - * color[3] Aux1 - * - * - * 3. glDrawBuffers(3, [GL_FRONT, GL_AUX0, GL_AUX1]) and shader writes to - * gl_FragColor, or fixed function: - * - * fragment color output renderbuffer - * --------------------- --------------- - * color[0] Front, Aux0, Aux1 - * - * - * In either case, the list of renderbuffers is stored in the - * framebuffer->_ColorDrawBuffers[] array and - * framebuffer->_NumColorDrawBuffers indicates the number of buffers. - * The renderer (like swrast) has to look at the current fragment shader - * to see if it writes to gl_FragColor vs. gl_FragData[i] to determine - * how to map color outputs to renderbuffers. - * - * Note that these two calls are equivalent (for fixed function fragment - * shading anyway): - * a) glDrawBuffer(GL_FRONT_AND_BACK); (assuming non-stereo framebuffer) - * b) glDrawBuffers(2, [GL_FRONT_LEFT, GL_BACK_LEFT]); - */ - - - - -/** - * Update the (derived) list of color drawing renderbuffer pointers. - * Later, when we're rendering we'll loop from 0 to _NumColorDrawBuffers - * writing colors. - */ -static void -update_color_draw_buffers(struct gl_context *ctx, struct gl_framebuffer *fb) -{ - GLint buf = fb->_ColorDrawBufferIndex; - if (buf >= 0) { - fb->_ColorDrawBuffer = fb->Attachment[buf].Renderbuffer; - } - else { - fb->_ColorDrawBuffer = NULL; - } -} - - -/** - * Update the (derived) color read renderbuffer pointer. - * Unlike the DrawBuffer, we can only read from one (or zero) color buffers. - */ -static void -update_color_read_buffer(struct gl_context *ctx, struct gl_framebuffer *fb) -{ - (void) ctx; - if (fb->_ColorReadBufferIndex == -1 || - fb->DeletePending || - fb->Width == 0 || - fb->Height == 0) { - fb->_ColorReadBuffer = NULL; /* legal! */ - } - else { - ASSERT(fb->_ColorReadBufferIndex >= 0); - ASSERT(fb->_ColorReadBufferIndex < BUFFER_COUNT); - fb->_ColorReadBuffer - = fb->Attachment[fb->_ColorReadBufferIndex].Renderbuffer; - } -} - - -/** - * Update a gl_framebuffer's derived state. - * - * Specifically, update these framebuffer fields: - * _ColorDrawBuffers - * _NumColorDrawBuffers - * _ColorReadBuffer - * - * If the framebuffer is user-created, make sure it's complete. - * - * The following functions (at least) can effect framebuffer state: - * glReadBuffer, glDrawBuffer, glDrawBuffersARB, glFramebufferRenderbufferEXT, - * glRenderbufferStorageEXT. - */ -static void -update_framebuffer(struct gl_context *ctx, struct gl_framebuffer *fb) -{ - _mesa_drawbuffer(ctx, ctx->Color.DrawBuffer, 0); - - /* Strictly speaking, we don't need to update the draw-state - * if this FB is bound as ctx->ReadBuffer (and conversely, the - * read-state if this FB is bound as ctx->DrawBuffer), but no - * harm. - */ - update_color_draw_buffers(ctx, fb); - update_color_read_buffer(ctx, fb); - - compute_depth_max(fb); -} - - -/** - * Update state related to the current draw/read framebuffers. - */ -void -_mesa_update_framebuffer(struct gl_context *ctx) -{ - struct gl_framebuffer *drawFb; - struct gl_framebuffer *readFb; - - assert(ctx); - drawFb = ctx->DrawBuffer; - readFb = ctx->ReadBuffer; - - update_framebuffer(ctx, drawFb); - if (readFb != drawFb) - update_framebuffer(ctx, readFb); -} - - -/** - * Check if the renderbuffer for a read/draw operation exists. - * \param format a basic image format such as GL_RGB, GL_RGBA, GL_ALPHA, - * GL_DEPTH_COMPONENT, etc. or GL_COLOR, GL_DEPTH, GL_STENCIL. - * \param reading if TRUE, we're going to read from the buffer, - if FALSE, we're going to write to the buffer. - * \return GL_TRUE if buffer exists, GL_FALSE otherwise - */ -static GLboolean -renderbuffer_exists(struct gl_context *ctx, - struct gl_framebuffer *fb, - GLenum format, - GLboolean reading) -{ - const struct gl_renderbuffer_attachment *att = fb->Attachment; - - switch (format) { - case GL_COLOR: - case GL_RED: - case GL_GREEN: - case GL_BLUE: - case GL_ALPHA: - case GL_LUMINANCE: - case GL_LUMINANCE_ALPHA: - case GL_INTENSITY: - case GL_RG: - case GL_RGB: - case GL_BGR: - case GL_RGBA: - case GL_BGRA: - case GL_ABGR_EXT: - case GL_RED_INTEGER_EXT: - case GL_RG_INTEGER: - case GL_GREEN_INTEGER_EXT: - case GL_BLUE_INTEGER_EXT: - case GL_ALPHA_INTEGER_EXT: - case GL_RGB_INTEGER_EXT: - case GL_RGBA_INTEGER_EXT: - case GL_BGR_INTEGER_EXT: - case GL_BGRA_INTEGER_EXT: - case GL_LUMINANCE_INTEGER_EXT: - case GL_LUMINANCE_ALPHA_INTEGER_EXT: - if (reading) { - /* about to read from a color buffer */ - const struct gl_renderbuffer *readBuf = fb->_ColorReadBuffer; - if (!readBuf) { - return GL_FALSE; - } - ASSERT(_mesa_get_format_bits(readBuf->Format, GL_RED_BITS) > 0 || - _mesa_get_format_bits(readBuf->Format, GL_ALPHA_BITS) > 0 || - _mesa_get_format_bits(readBuf->Format, GL_TEXTURE_LUMINANCE_SIZE) > 0 || - _mesa_get_format_bits(readBuf->Format, GL_TEXTURE_INTENSITY_SIZE) > 0 || - _mesa_get_format_bits(readBuf->Format, GL_INDEX_BITS) > 0); - } - else { - /* about to draw to zero or more color buffers (none is OK) */ - return GL_TRUE; - } - break; - case GL_DEPTH: - case GL_DEPTH_COMPONENT: - if (att[BUFFER_DEPTH].Renderbuffer == NULL) { - return GL_FALSE; - } - break; - case GL_STENCIL: - case GL_STENCIL_INDEX: - if (att[BUFFER_STENCIL].Renderbuffer == NULL) { - return GL_FALSE; - } - break; - default: - _mesa_problem(ctx, - "Unexpected format 0x%x in renderbuffer_exists", - format); - return GL_FALSE; - } - - /* OK */ - return GL_TRUE; -} - - -/** - * Check if the renderbuffer for a read operation (glReadPixels, glCopyPixels, - * glCopyTex[Sub]Image, etc) exists. - * \param format a basic image format such as GL_RGB, GL_RGBA, GL_ALPHA, - * GL_DEPTH_COMPONENT, etc. or GL_COLOR, GL_DEPTH, GL_STENCIL. - * \return GL_TRUE if buffer exists, GL_FALSE otherwise - */ -GLboolean -_mesa_source_buffer_exists(struct gl_context *ctx, GLenum format) -{ - return renderbuffer_exists(ctx, ctx->ReadBuffer, format, GL_TRUE); -} - - -/** - * As above, but for drawing operations. - * XXX could do some code merging w/ above function. - */ -GLboolean -_mesa_dest_buffer_exists(struct gl_context *ctx, GLenum format) -{ - return renderbuffer_exists(ctx, ctx->DrawBuffer, format, GL_FALSE); -} - - -/** - * Used to answer the GL_IMPLEMENTATION_COLOR_READ_FORMAT_OES query. - */ -GLenum -_mesa_get_color_read_format(struct gl_context *ctx) -{ - switch (ctx->ReadBuffer->_ColorReadBuffer->Format) { - case MESA_FORMAT_ARGB8888: - return GL_BGRA; - case MESA_FORMAT_RGB565: - return GL_BGR; - default: - return GL_RGBA; - } -} - - -/** - * Used to answer the GL_IMPLEMENTATION_COLOR_READ_TYPE_OES query. - */ -GLenum -_mesa_get_color_read_type(struct gl_context *ctx) -{ - switch (ctx->ReadBuffer->_ColorReadBuffer->Format) { - case MESA_FORMAT_ARGB8888: - return GL_UNSIGNED_BYTE; - case MESA_FORMAT_RGB565: - return GL_UNSIGNED_SHORT_5_6_5_REV; - default: - return GL_UNSIGNED_BYTE; - } -} - - diff --git a/dll/opengl/mesa/main/framebuffer.h b/dll/opengl/mesa/main/framebuffer.h deleted file mode 100644 index 09ed6ed1df8..00000000000 --- a/dll/opengl/mesa/main/framebuffer.h +++ /dev/null @@ -1,86 +0,0 @@ -/* - * Mesa 3-D graphics library - * Version: 6.5 - * - * Copyright (C) 1999-2006 Brian Paul All Rights Reserved. - * - * Permission is hereby granted, free of charge, to any person obtaining a - * copy of this software and associated documentation files (the "Software"), - * to deal in the Software without restriction, including without limitation - * the rights to use, copy, modify, merge, publish, distribute, sublicense, - * and/or sell copies of the Software, and to permit persons to whom the - * Software is furnished to do so, subject to the following conditions: - * - * The above copyright notice and this permission notice shall be included - * in all copies or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS - * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL - * BRIAN PAUL BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN - * AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN - * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. - */ - - -#ifndef FRAMEBUFFER_H -#define FRAMEBUFFER_H - -#include "glheader.h" - -struct gl_config; -struct gl_context; - -extern struct gl_framebuffer * -_mesa_create_framebuffer(const struct gl_config *visual); - -extern void -_mesa_initialize_window_framebuffer(struct gl_framebuffer *fb, - const struct gl_config *visual); - -extern void -_mesa_destroy_framebuffer(struct gl_framebuffer *buffer); - -extern void -_mesa_free_framebuffer_data(struct gl_framebuffer *buffer); - -extern void -_mesa_reference_framebuffer_(struct gl_framebuffer **ptr, - struct gl_framebuffer *fb); - -static inline void -_mesa_reference_framebuffer(struct gl_framebuffer **ptr, - struct gl_framebuffer *fb) -{ - if (*ptr != fb) - _mesa_reference_framebuffer_(ptr, fb); -} - -extern void -_mesa_resize_framebuffer(struct gl_context *ctx, struct gl_framebuffer *fb, - GLuint width, GLuint height); - - -extern void -_mesa_resizebuffers( struct gl_context *ctx ); - - -extern void -_mesa_update_draw_buffer_bounds(struct gl_context *ctx); - -extern void -_mesa_update_framebuffer(struct gl_context *ctx); - -extern GLboolean -_mesa_source_buffer_exists(struct gl_context *ctx, GLenum format); - -extern GLboolean -_mesa_dest_buffer_exists(struct gl_context *ctx, GLenum format); - -extern GLenum -_mesa_get_color_read_type(struct gl_context *ctx); - -extern GLenum -_mesa_get_color_read_format(struct gl_context *ctx); - -#endif /* FRAMEBUFFER_H */ diff --git a/dll/opengl/mesa/main/get.c b/dll/opengl/mesa/main/get.c deleted file mode 100644 index 1a388cd20b2..00000000000 --- a/dll/opengl/mesa/main/get.c +++ /dev/null @@ -1,1639 +0,0 @@ -/* - * Copyright (C) 2010 Brian Paul All Rights Reserved. - * Copyright (C) 2010 Intel Corporation - * - * Permission is hereby granted, free of charge, to any person obtaining a - * copy of this software and associated documentation files (the "Software"), - * to deal in the Software without restriction, including without limitation - * the rights to use, copy, modify, merge, publish, distribute, sublicense, - * and/or sell copies of the Software, and to permit persons to whom the - * Software is furnished to do so, subject to the following conditions: - * - * The above copyright notice and this permission notice shall be included - * in all copies or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS - * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL - * BRIAN PAUL BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN - * AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN - * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. - * - * Author: Kristian Høgsberg - */ - -#include - -/* This is a table driven implementation of the glGet*v() functions. - * The basic idea is that most getters just look up an int somewhere - * in struct gl_context and then convert it to a bool or float according to - * which of glGetIntegerv() glGetBooleanv() etc is being called. - * Instead of generating code to do this, we can just record the enum - * value and the offset into struct gl_context in an array of structs. Then - * in glGet*(), we lookup the struct for the enum in question, and use - * the offset to get the int we need. - * - * Sometimes we need to look up a float, a boolean, a bit in a - * bitfield, a matrix or other types instead, so we need to track the - * type of the value in struct gl_context. And sometimes the value isn't in - * struct gl_context but in the drawbuffer, the array object, current texture - * unit, or maybe it's a computed value. So we need to also track - * where or how to find the value. Finally, we sometimes need to - * check that one of a number of extensions are enabled, the GL - * version or flush or call _mesa_update_state(). This is done by - * attaching optional extra information to the value description - * struct, it's sort of like an array of opcodes that describe extra - * checks or actions. - * - * Putting all this together we end up with struct value_desc below, - * and with a couple of macros to help, the table of struct value_desc - * is about as concise as the specification in the old python script. - */ - -#undef CONST - -#define FLOAT_TO_BOOLEAN(X) ( (X) ? GL_TRUE : GL_FALSE ) -#define FLOAT_TO_FIXED(F) ( ((F) * 65536.0f > INT_MAX) ? INT_MAX : \ - ((F) * 65536.0f < INT_MIN) ? INT_MIN : \ - (GLint) ((F) * 65536.0f) ) - -#define INT_TO_BOOLEAN(I) ( (I) ? GL_TRUE : GL_FALSE ) -#define INT_TO_FIXED(I) ( ((I) > SHRT_MAX) ? INT_MAX : \ - ((I) < SHRT_MIN) ? INT_MIN : \ - (GLint) ((I) * 65536) ) - -#define INT64_TO_BOOLEAN(I) ( (I) ? GL_TRUE : GL_FALSE ) -#define INT64_TO_INT(I) ( (GLint)((I > INT_MAX) ? INT_MAX : ((I < INT_MIN) ? INT_MIN : (I))) ) - -#define BOOLEAN_TO_INT(B) ( (GLint) (B) ) -#define BOOLEAN_TO_INT64(B) ( (GLint64) (B) ) -#define BOOLEAN_TO_FLOAT(B) ( (B) ? 1.0F : 0.0F ) -#define BOOLEAN_TO_FIXED(B) ( (GLint) ((B) ? 1 : 0) << 16 ) - -#define ENUM_TO_INT64(E) ( (GLint64) (E) ) -#define ENUM_TO_FIXED(E) (E) - -enum value_type { - TYPE_INVALID, - TYPE_INT, - TYPE_INT_2, - TYPE_INT_3, - TYPE_INT_4, - TYPE_INT_N, - TYPE_INT64, - TYPE_ENUM, - TYPE_ENUM_2, - TYPE_BOOLEAN, - TYPE_BIT_0, - TYPE_BIT_1, - TYPE_BIT_2, - TYPE_BIT_3, - TYPE_BIT_4, - TYPE_BIT_5, - TYPE_BIT_6, - TYPE_BIT_7, - TYPE_FLOAT, - TYPE_FLOAT_2, - TYPE_FLOAT_3, - TYPE_FLOAT_4, - TYPE_FLOATN, - TYPE_FLOATN_2, - TYPE_FLOATN_3, - TYPE_FLOATN_4, - TYPE_DOUBLEN, - TYPE_MATRIX, - TYPE_MATRIX_T, - TYPE_CONST -}; - -enum value_location { - LOC_BUFFER, - LOC_CONTEXT, - LOC_ARRAY, - LOC_TEXUNIT, - LOC_CUSTOM -}; - -enum value_extra { - EXTRA_END = 0x8000, - EXTRA_VERSION_30, - EXTRA_VERSION_31, - EXTRA_VERSION_32, - EXTRA_NEW_BUFFERS, - EXTRA_VALID_TEXTURE_UNIT, - EXTRA_VALID_CLIP_DISTANCE, - EXTRA_FLUSH_CURRENT, -}; - -#define NO_EXTRA NULL -#define NO_OFFSET 0 - -struct value_desc { - GLenum pname; - GLubyte location; /**< enum value_location */ - GLubyte type; /**< enum value_type */ - int offset; - const int *extra; -}; - -union value { - GLfloat value_float; - GLfloat value_float_4[4]; - GLmatrix *value_matrix; - GLint value_int; - GLint value_int_4[4]; - GLint64 value_int64; - GLenum value_enum; - - /* Sigh, see GL_COMPRESSED_TEXTURE_FORMATS_ARB handling */ - struct { - GLint n, ints[100]; - } value_int_n; - GLboolean value_bool; -}; - -#define BUFFER_FIELD(field, type) \ - LOC_BUFFER, type, offsetof(struct gl_framebuffer, field) -#define CONTEXT_FIELD(field, type) \ - LOC_CONTEXT, type, offsetof(struct gl_context, field) -#define ARRAY_FIELD(field, type) \ - LOC_ARRAY, type, offsetof(struct gl_array_attrib, field) -#define CONST(value) \ - LOC_CONTEXT, TYPE_CONST, value - -#define BUFFER_INT(field) BUFFER_FIELD(field, TYPE_INT) -#define BUFFER_ENUM(field) BUFFER_FIELD(field, TYPE_ENUM) -#define BUFFER_BOOL(field) BUFFER_FIELD(field, TYPE_BOOLEAN) - -#define CONTEXT_INT(field) CONTEXT_FIELD(field, TYPE_INT) -#define CONTEXT_INT2(field) CONTEXT_FIELD(field, TYPE_INT_2) -#define CONTEXT_INT64(field) CONTEXT_FIELD(field, TYPE_INT64) -#define CONTEXT_ENUM(field) CONTEXT_FIELD(field, TYPE_ENUM) -#define CONTEXT_ENUM2(field) CONTEXT_FIELD(field, TYPE_ENUM_2) -#define CONTEXT_BOOL(field) CONTEXT_FIELD(field, TYPE_BOOLEAN) -#define CONTEXT_BIT0(field) CONTEXT_FIELD(field, TYPE_BIT_0) -#define CONTEXT_BIT1(field) CONTEXT_FIELD(field, TYPE_BIT_1) -#define CONTEXT_BIT2(field) CONTEXT_FIELD(field, TYPE_BIT_2) -#define CONTEXT_BIT3(field) CONTEXT_FIELD(field, TYPE_BIT_3) -#define CONTEXT_BIT4(field) CONTEXT_FIELD(field, TYPE_BIT_4) -#define CONTEXT_BIT5(field) CONTEXT_FIELD(field, TYPE_BIT_5) -#define CONTEXT_BIT6(field) CONTEXT_FIELD(field, TYPE_BIT_6) -#define CONTEXT_BIT7(field) CONTEXT_FIELD(field, TYPE_BIT_7) -#define CONTEXT_FLOAT(field) CONTEXT_FIELD(field, TYPE_FLOAT) -#define CONTEXT_FLOAT2(field) CONTEXT_FIELD(field, TYPE_FLOAT_2) -#define CONTEXT_FLOAT3(field) CONTEXT_FIELD(field, TYPE_FLOAT_3) -#define CONTEXT_FLOAT4(field) CONTEXT_FIELD(field, TYPE_FLOAT_4) -#define CONTEXT_MATRIX(field) CONTEXT_FIELD(field, TYPE_MATRIX) -#define CONTEXT_MATRIX_T(field) CONTEXT_FIELD(field, TYPE_MATRIX_T) - -#define ARRAY_INT(field) ARRAY_FIELD(field, TYPE_INT) -#define ARRAY_ENUM(field) ARRAY_FIELD(field, TYPE_ENUM) -#define ARRAY_BOOL(field) ARRAY_FIELD(field, TYPE_BOOLEAN) - -#define EXT(f) \ - offsetof(struct gl_extensions, f) - -#define EXTRA_EXT(e) \ - static const int extra_##e[] = { \ - EXT(e), EXTRA_END \ - } - -#define EXTRA_EXT2(e1, e2) \ - static const int extra_##e1##_##e2[] = { \ - EXT(e1), EXT(e2), EXTRA_END \ - } - -/* The 'extra' mechanism is a way to specify extra checks (such as - * extensions or specific gl versions) or actions (flush current, new - * buffers) that we need to do before looking up an enum. We need to - * declare them all up front so we can refer to them in the value_desc - * structs below. */ - -static const int extra_new_buffers[] = { - EXTRA_NEW_BUFFERS, - EXTRA_END -}; - -static const int extra_valid_texture_unit[] = { - EXTRA_VALID_TEXTURE_UNIT, - EXTRA_END -}; - -static const int extra_valid_clip_distance[] = { - EXTRA_VALID_CLIP_DISTANCE, - EXTRA_END -}; - -static const int extra_flush_current_valid_texture_unit[] = { - EXTRA_FLUSH_CURRENT, - EXTRA_VALID_TEXTURE_UNIT, - EXTRA_END -}; - -static const int extra_flush_current[] = { - EXTRA_FLUSH_CURRENT, - EXTRA_END -}; - -static const int extra_EXT_fog_coord_flush_current[] = { - EXT(EXT_fog_coord), - EXTRA_FLUSH_CURRENT, - EXTRA_END -}; - -static const int extra_EXT_texture_integer[] = { - EXT(EXT_texture_integer), - EXTRA_END -}; - - -EXTRA_EXT(ARB_texture_cube_map); -EXTRA_EXT(EXT_fog_coord); -EXTRA_EXT(NV_fog_distance); -EXTRA_EXT(EXT_texture_filter_anisotropic); -EXTRA_EXT(IBM_rasterpos_clip); -EXTRA_EXT(NV_point_sprite); -EXTRA_EXT(NV_light_max_exponent); -EXTRA_EXT(EXT_depth_bounds_test); -EXTRA_EXT(EXT_compiled_vertex_array); -EXTRA_EXT2(NV_point_sprite, ARB_point_sprite); - -static const int extra_version_30[] = { EXTRA_VERSION_30, EXTRA_END }; -static const int extra_version_32[] = { EXTRA_VERSION_32, EXTRA_END }; - -#define API_OPENGL_BIT (1 << API_OPENGL) - -/* This is the big table describing all the enums we accept in - * glGet*v(). The table is partitioned into six parts: enums - * understood by all GL APIs (OpenGL, GLES and GLES2), enums shared - * between OpenGL and GLES, enums exclusive to GLES, etc for the - * remaining combinations. When we add the enums to the hash table in - * _mesa_init_get_hash(), we only add the enums for the API we're - * instantiating and the different sections are guarded by #if - * FEATURE_GL etc to make sure we only compile in the enums we may - * need. */ - -static const struct value_desc values[] = { - { GL_ALPHA_BITS, BUFFER_INT(Visual.alphaBits), extra_new_buffers }, - { GL_BLEND, CONTEXT_BIT0(Color.BlendEnabled), NO_EXTRA }, - { GL_BLEND_SRC, CONTEXT_ENUM(Color.SrcFactor), NO_EXTRA }, - { GL_BLUE_BITS, BUFFER_INT(Visual.blueBits), extra_new_buffers }, - { GL_COLOR_CLEAR_VALUE, LOC_CUSTOM, TYPE_FLOATN_4, 0, NO_EXTRA }, - { GL_COLOR_WRITEMASK, LOC_CUSTOM, TYPE_INT_4, 0, NO_EXTRA }, - { GL_CULL_FACE, CONTEXT_BOOL(Polygon.CullFlag), NO_EXTRA }, - { GL_CULL_FACE_MODE, CONTEXT_ENUM(Polygon.CullFaceMode), NO_EXTRA }, - { GL_DEPTH_BITS, BUFFER_INT(Visual.depthBits), NO_EXTRA }, - { GL_DEPTH_CLEAR_VALUE, CONTEXT_FIELD(Depth.Clear, TYPE_DOUBLEN), NO_EXTRA }, - { GL_DEPTH_FUNC, CONTEXT_ENUM(Depth.Func), NO_EXTRA }, - { GL_DEPTH_RANGE, CONTEXT_FIELD(Viewport.Near, TYPE_FLOATN_2), NO_EXTRA }, - { GL_DEPTH_TEST, CONTEXT_BOOL(Depth.Test), NO_EXTRA }, - { GL_DEPTH_WRITEMASK, CONTEXT_BOOL(Depth.Mask), NO_EXTRA }, - { GL_DITHER, CONTEXT_BOOL(Color.DitherFlag), NO_EXTRA }, - { GL_FRONT_FACE, CONTEXT_ENUM(Polygon.FrontFace), NO_EXTRA }, - { GL_GREEN_BITS, BUFFER_INT(Visual.greenBits), extra_new_buffers }, - { GL_LINE_WIDTH, CONTEXT_FLOAT(Line.Width), NO_EXTRA }, - { GL_ALIASED_LINE_WIDTH_RANGE, CONTEXT_FLOAT2(Const.MinLineWidth), NO_EXTRA }, - { GL_MAX_ELEMENTS_VERTICES, CONTEXT_INT(Const.MaxArrayLockSize), NO_EXTRA }, - { GL_MAX_ELEMENTS_INDICES, CONTEXT_INT(Const.MaxArrayLockSize), NO_EXTRA }, - { GL_MAX_TEXTURE_SIZE, LOC_CUSTOM, TYPE_INT, - offsetof(struct gl_context, Const.MaxTextureLevels), NO_EXTRA }, - { GL_MAX_VIEWPORT_DIMS, CONTEXT_INT2(Const.MaxViewportWidth), NO_EXTRA }, - { GL_PACK_ALIGNMENT, CONTEXT_INT(Pack.Alignment), NO_EXTRA }, - { GL_ALIASED_POINT_SIZE_RANGE, CONTEXT_FLOAT2(Const.MinPointSize), NO_EXTRA }, - { GL_POLYGON_OFFSET_FACTOR, CONTEXT_FLOAT(Polygon.OffsetFactor ), NO_EXTRA }, - { GL_POLYGON_OFFSET_UNITS, CONTEXT_FLOAT(Polygon.OffsetUnits ), NO_EXTRA }, - { GL_POLYGON_OFFSET_FILL, CONTEXT_BOOL(Polygon.OffsetFill), NO_EXTRA }, - { GL_RED_BITS, BUFFER_INT(Visual.redBits), extra_new_buffers }, - { GL_SCISSOR_BOX, LOC_CUSTOM, TYPE_INT_4, 0, NO_EXTRA }, - { GL_SCISSOR_TEST, CONTEXT_BOOL(Scissor.Enabled), NO_EXTRA }, - { GL_STENCIL_BITS, BUFFER_INT(Visual.stencilBits), NO_EXTRA }, - { GL_STENCIL_CLEAR_VALUE, CONTEXT_INT(Stencil.Clear), NO_EXTRA }, - { GL_STENCIL_FAIL, LOC_CUSTOM, TYPE_ENUM, NO_OFFSET, NO_EXTRA }, - { GL_STENCIL_FUNC, LOC_CUSTOM, TYPE_ENUM, NO_OFFSET, NO_EXTRA }, - { GL_STENCIL_PASS_DEPTH_FAIL, LOC_CUSTOM, TYPE_ENUM, NO_OFFSET, NO_EXTRA }, - { GL_STENCIL_PASS_DEPTH_PASS, LOC_CUSTOM, TYPE_ENUM, NO_OFFSET, NO_EXTRA }, - { GL_STENCIL_REF, LOC_CUSTOM, TYPE_INT, NO_OFFSET, NO_EXTRA }, - { GL_STENCIL_TEST, CONTEXT_BOOL(Stencil.Enabled), NO_EXTRA }, - { GL_STENCIL_VALUE_MASK, LOC_CUSTOM, TYPE_INT, NO_OFFSET, NO_EXTRA }, - { GL_STENCIL_WRITEMASK, LOC_CUSTOM, TYPE_INT, NO_OFFSET, NO_EXTRA }, - { GL_SUBPIXEL_BITS, CONTEXT_INT(Const.SubPixelBits), NO_EXTRA }, - { GL_TEXTURE_BINDING_2D, LOC_CUSTOM, TYPE_INT, TEXTURE_2D_INDEX, NO_EXTRA }, - { GL_UNPACK_ALIGNMENT, CONTEXT_INT(Unpack.Alignment), NO_EXTRA }, - { GL_VIEWPORT, LOC_CUSTOM, TYPE_INT_4, 0, NO_EXTRA }, - - /* GL_ARB_multitexture */ - { GL_ACTIVE_TEXTURE, LOC_CUSTOM, TYPE_INT, 0, NO_EXTRA }, - - /* Note that all the OES_* extensions require that the Mesa "struct - * gl_extensions" include a member with the name of the extension. - * That structure does not yet include OES extensions (and we're - * not sure whether it will). If it does, all the OES_* - * extensions below should mark the dependency. */ - - /* GL_ARB_texture_cube_map */ - { GL_TEXTURE_BINDING_CUBE_MAP_ARB, LOC_CUSTOM, TYPE_INT, - TEXTURE_CUBE_INDEX, extra_ARB_texture_cube_map }, - { GL_MAX_CUBE_MAP_TEXTURE_SIZE_ARB, LOC_CUSTOM, TYPE_INT, - offsetof(struct gl_context, Const.MaxCubeTextureLevels), - extra_ARB_texture_cube_map }, /* XXX: OES_texture_cube_map */ - - /* XXX: OES_blend_subtract */ - { GL_BLEND_SRC_RGB_EXT, CONTEXT_ENUM(Color.SrcFactor), NO_EXTRA }, - { GL_BLEND_DST_RGB_EXT, CONTEXT_ENUM(Color.DstFactor), NO_EXTRA }, - - /* GL_ARB_multisample */ - { GL_SAMPLE_ALPHA_TO_COVERAGE_ARB, - CONTEXT_BOOL(Multisample.SampleAlphaToCoverage), NO_EXTRA }, - { GL_SAMPLE_COVERAGE_ARB, CONTEXT_BOOL(Multisample.SampleCoverage), NO_EXTRA }, - { GL_SAMPLE_COVERAGE_VALUE_ARB, - CONTEXT_FLOAT(Multisample.SampleCoverageValue), NO_EXTRA }, - { GL_SAMPLE_COVERAGE_INVERT_ARB, - CONTEXT_BOOL(Multisample.SampleCoverageInvert), NO_EXTRA }, - - /* GL_ARB_vertex_buffer_object */ - { GL_ARRAY_BUFFER_BINDING_ARB, LOC_CUSTOM, TYPE_INT, 0, NO_EXTRA }, - - /* GL_ARB_vertex_buffer_object */ - /* GL_WEIGHT_ARRAY_BUFFER_BINDING_ARB - not supported */ - { GL_ELEMENT_ARRAY_BUFFER_BINDING_ARB, LOC_CUSTOM, TYPE_INT, 0, NO_EXTRA }, - - /* GL_OES_read_format */ - { GL_IMPLEMENTATION_COLOR_READ_TYPE_OES, LOC_CUSTOM, TYPE_INT, 0, - extra_new_buffers }, - { GL_IMPLEMENTATION_COLOR_READ_FORMAT_OES, LOC_CUSTOM, TYPE_INT, 0, - extra_new_buffers }, - - /* This entry isn't spec'ed for GLES 2, but is needed for Mesa's - * GLSL: */ - { GL_MAX_CLIP_PLANES, CONTEXT_INT(Const.MaxClipPlanes), NO_EXTRA }, - - { GL_MAX_LIGHTS, CONTEXT_INT(Const.MaxLights), NO_EXTRA }, - { GL_LIGHT0, CONTEXT_BOOL(Light.Light[0].Enabled), NO_EXTRA }, - { GL_LIGHT1, CONTEXT_BOOL(Light.Light[1].Enabled), NO_EXTRA }, - { GL_LIGHT2, CONTEXT_BOOL(Light.Light[2].Enabled), NO_EXTRA }, - { GL_LIGHT3, CONTEXT_BOOL(Light.Light[3].Enabled), NO_EXTRA }, - { GL_LIGHT4, CONTEXT_BOOL(Light.Light[4].Enabled), NO_EXTRA }, - { GL_LIGHT5, CONTEXT_BOOL(Light.Light[5].Enabled), NO_EXTRA }, - { GL_LIGHT6, CONTEXT_BOOL(Light.Light[6].Enabled), NO_EXTRA }, - { GL_LIGHT7, CONTEXT_BOOL(Light.Light[7].Enabled), NO_EXTRA }, - { GL_LIGHTING, CONTEXT_BOOL(Light.Enabled), NO_EXTRA }, - { GL_LIGHT_MODEL_AMBIENT, - CONTEXT_FIELD(Light.Model.Ambient[0], TYPE_FLOATN_4), NO_EXTRA }, - { GL_LIGHT_MODEL_TWO_SIDE, CONTEXT_BOOL(Light.Model.TwoSide), NO_EXTRA }, - { GL_ALPHA_TEST, CONTEXT_BOOL(Color.AlphaEnabled), NO_EXTRA }, - { GL_ALPHA_TEST_FUNC, CONTEXT_ENUM(Color.AlphaFunc), NO_EXTRA }, - { GL_ALPHA_TEST_REF, LOC_CUSTOM, TYPE_FLOATN, 0, NO_EXTRA }, - { GL_BLEND_DST, CONTEXT_ENUM(Color.DstFactor), NO_EXTRA }, - { GL_CLIP_DISTANCE0, CONTEXT_BIT0(Transform.ClipPlanesEnabled), extra_valid_clip_distance }, - { GL_CLIP_DISTANCE1, CONTEXT_BIT1(Transform.ClipPlanesEnabled), extra_valid_clip_distance }, - { GL_CLIP_DISTANCE2, CONTEXT_BIT2(Transform.ClipPlanesEnabled), extra_valid_clip_distance }, - { GL_CLIP_DISTANCE3, CONTEXT_BIT3(Transform.ClipPlanesEnabled), extra_valid_clip_distance }, - { GL_CLIP_DISTANCE4, CONTEXT_BIT4(Transform.ClipPlanesEnabled), extra_valid_clip_distance }, - { GL_CLIP_DISTANCE5, CONTEXT_BIT5(Transform.ClipPlanesEnabled), extra_valid_clip_distance }, - { GL_CLIP_DISTANCE6, CONTEXT_BIT6(Transform.ClipPlanesEnabled), extra_valid_clip_distance }, - { GL_CLIP_DISTANCE7, CONTEXT_BIT7(Transform.ClipPlanesEnabled), extra_valid_clip_distance }, - { GL_COLOR_MATERIAL, CONTEXT_BOOL(Light.ColorMaterialEnabled), NO_EXTRA }, - { GL_CURRENT_COLOR, - CONTEXT_FIELD(Current.Attrib[VERT_ATTRIB_COLOR][0], TYPE_FLOATN_4), - extra_flush_current }, - { GL_CURRENT_NORMAL, - CONTEXT_FIELD(Current.Attrib[VERT_ATTRIB_NORMAL][0], TYPE_FLOATN_3), - extra_flush_current }, - { GL_CURRENT_TEXTURE_COORDS, LOC_CUSTOM, TYPE_FLOAT_4, 0, - extra_flush_current_valid_texture_unit }, - { GL_DISTANCE_ATTENUATION_EXT, CONTEXT_FLOAT3(Point.Params[0]), NO_EXTRA }, - { GL_FOG, CONTEXT_BOOL(Fog.Enabled), NO_EXTRA }, - { GL_FOG_COLOR, LOC_CUSTOM, TYPE_FLOATN_4, 0, NO_EXTRA }, - { GL_FOG_DENSITY, CONTEXT_FLOAT(Fog.Density), NO_EXTRA }, - { GL_FOG_END, CONTEXT_FLOAT(Fog.End), NO_EXTRA }, - { GL_FOG_HINT, CONTEXT_ENUM(Hint.Fog), NO_EXTRA }, - { GL_FOG_MODE, CONTEXT_ENUM(Fog.Mode), NO_EXTRA }, - { GL_FOG_START, CONTEXT_FLOAT(Fog.Start), NO_EXTRA }, - { GL_LINE_SMOOTH, CONTEXT_BOOL(Line.SmoothFlag), NO_EXTRA }, - { GL_LINE_SMOOTH_HINT, CONTEXT_ENUM(Hint.LineSmooth), NO_EXTRA }, - { GL_LINE_WIDTH_RANGE, CONTEXT_FLOAT2(Const.MinLineWidthAA), NO_EXTRA }, - { GL_COLOR_LOGIC_OP, CONTEXT_BOOL(Color.ColorLogicOpEnabled), NO_EXTRA }, - { GL_LOGIC_OP_MODE, CONTEXT_ENUM(Color.LogicOp), NO_EXTRA }, - { GL_MATRIX_MODE, CONTEXT_ENUM(Transform.MatrixMode), NO_EXTRA }, - { GL_MAX_MODELVIEW_STACK_DEPTH, CONST(MAX_MODELVIEW_STACK_DEPTH), NO_EXTRA }, - { GL_MAX_PROJECTION_STACK_DEPTH, CONST(MAX_PROJECTION_STACK_DEPTH), NO_EXTRA }, - { GL_MAX_TEXTURE_STACK_DEPTH, CONST(MAX_TEXTURE_STACK_DEPTH), NO_EXTRA }, - { GL_MODELVIEW_MATRIX, CONTEXT_MATRIX(ModelviewMatrixStack.Top), NO_EXTRA }, - { GL_MODELVIEW_STACK_DEPTH, LOC_CUSTOM, TYPE_INT, - offsetof(struct gl_context, ModelviewMatrixStack.Depth), NO_EXTRA }, - { GL_NORMALIZE, CONTEXT_BOOL(Transform.Normalize), NO_EXTRA }, - { GL_PACK_SKIP_IMAGES_EXT, CONTEXT_INT(Pack.SkipImages), NO_EXTRA }, - { GL_PERSPECTIVE_CORRECTION_HINT, CONTEXT_ENUM(Hint.PerspectiveCorrection), NO_EXTRA }, - { GL_POINT_SIZE, CONTEXT_FLOAT(Point.Size), NO_EXTRA }, - { GL_POINT_SIZE_RANGE, CONTEXT_FLOAT2(Const.MinPointSizeAA), NO_EXTRA }, - { GL_POINT_SMOOTH, CONTEXT_BOOL(Point.SmoothFlag), NO_EXTRA }, - { GL_POINT_SMOOTH_HINT, CONTEXT_ENUM(Hint.PointSmooth), NO_EXTRA }, - { GL_POINT_SIZE_MIN_EXT, CONTEXT_FLOAT(Point.MinSize), NO_EXTRA }, - { GL_POINT_SIZE_MAX_EXT, CONTEXT_FLOAT(Point.MaxSize), NO_EXTRA }, - { GL_POINT_FADE_THRESHOLD_SIZE_EXT, CONTEXT_FLOAT(Point.Threshold), NO_EXTRA }, - { GL_PROJECTION_MATRIX, CONTEXT_MATRIX(ProjectionMatrixStack.Top), NO_EXTRA }, - { GL_PROJECTION_STACK_DEPTH, LOC_CUSTOM, TYPE_INT, - offsetof(struct gl_context, ProjectionMatrixStack.Depth), NO_EXTRA }, - { GL_RESCALE_NORMAL, CONTEXT_BOOL(Transform.RescaleNormals), NO_EXTRA }, - { GL_SHADE_MODEL, CONTEXT_ENUM(Light.ShadeModel), NO_EXTRA }, - { GL_TEXTURE_2D, LOC_CUSTOM, TYPE_BOOLEAN, 0, NO_EXTRA }, - { GL_TEXTURE_MATRIX, LOC_CUSTOM, TYPE_MATRIX, 0, extra_valid_texture_unit }, - { GL_TEXTURE_STACK_DEPTH, LOC_CUSTOM, TYPE_INT, 0, - extra_valid_texture_unit }, - - { GL_VERTEX_ARRAY, ARRAY_BOOL(VertexAttrib[VERT_ATTRIB_POS].Enabled), NO_EXTRA }, - { GL_VERTEX_ARRAY_SIZE, ARRAY_INT(VertexAttrib[VERT_ATTRIB_POS].Size), NO_EXTRA }, - { GL_VERTEX_ARRAY_TYPE, ARRAY_ENUM(VertexAttrib[VERT_ATTRIB_POS].Type), NO_EXTRA }, - { GL_VERTEX_ARRAY_STRIDE, ARRAY_INT(VertexAttrib[VERT_ATTRIB_POS].Stride), NO_EXTRA }, - { GL_NORMAL_ARRAY, ARRAY_BOOL(VertexAttrib[VERT_ATTRIB_NORMAL].Enabled), NO_EXTRA }, - { GL_NORMAL_ARRAY_TYPE, ARRAY_ENUM(VertexAttrib[VERT_ATTRIB_NORMAL].Type), NO_EXTRA }, - { GL_NORMAL_ARRAY_STRIDE, ARRAY_INT(VertexAttrib[VERT_ATTRIB_NORMAL].Stride), NO_EXTRA }, - { GL_COLOR_ARRAY, ARRAY_BOOL(VertexAttrib[VERT_ATTRIB_COLOR].Enabled), NO_EXTRA }, - { GL_COLOR_ARRAY_SIZE, ARRAY_INT(VertexAttrib[VERT_ATTRIB_COLOR].Size), NO_EXTRA }, - { GL_COLOR_ARRAY_TYPE, ARRAY_ENUM(VertexAttrib[VERT_ATTRIB_COLOR].Type), NO_EXTRA }, - { GL_COLOR_ARRAY_STRIDE, ARRAY_INT(VertexAttrib[VERT_ATTRIB_COLOR].Stride), NO_EXTRA }, - { GL_TEXTURE_COORD_ARRAY, - LOC_CUSTOM, TYPE_BOOLEAN, offsetof(struct gl_client_array, Enabled), NO_EXTRA }, - { GL_TEXTURE_COORD_ARRAY_SIZE, - LOC_CUSTOM, TYPE_INT, offsetof(struct gl_client_array, Size), NO_EXTRA }, - { GL_TEXTURE_COORD_ARRAY_TYPE, - LOC_CUSTOM, TYPE_ENUM, offsetof(struct gl_client_array, Type), NO_EXTRA }, - { GL_TEXTURE_COORD_ARRAY_STRIDE, - LOC_CUSTOM, TYPE_INT, offsetof(struct gl_client_array, Stride), NO_EXTRA }, - - /* GL_ARB_texture_cube_map */ - { GL_TEXTURE_CUBE_MAP_ARB, LOC_CUSTOM, TYPE_BOOLEAN, 0, NO_EXTRA }, - /* S, T, and R are always set at the same time */ - { GL_TEXTURE_GEN_STR_OES, LOC_TEXUNIT, TYPE_BIT_0, - offsetof(struct gl_texture_unit, TexGenEnabled), NO_EXTRA }, - - /* GL_ARB_multisample */ - { GL_MULTISAMPLE_ARB, CONTEXT_BOOL(Multisample.Enabled), NO_EXTRA }, - { GL_SAMPLE_ALPHA_TO_ONE_ARB, CONTEXT_BOOL(Multisample.SampleAlphaToOne), NO_EXTRA }, - - /* GL_ARB_vertex_buffer_object */ - { GL_VERTEX_ARRAY_BUFFER_BINDING_ARB, LOC_CUSTOM, TYPE_INT, - offsetof(struct gl_array_attrib, VertexAttrib[VERT_ATTRIB_POS].BufferObj), NO_EXTRA }, - { GL_NORMAL_ARRAY_BUFFER_BINDING_ARB, LOC_CUSTOM, TYPE_INT, - offsetof(struct gl_array_attrib, VertexAttrib[VERT_ATTRIB_NORMAL].BufferObj), NO_EXTRA }, - { GL_COLOR_ARRAY_BUFFER_BINDING_ARB, LOC_CUSTOM, TYPE_INT, - offsetof(struct gl_array_attrib, VertexAttrib[VERT_ATTRIB_COLOR].BufferObj), NO_EXTRA }, - { GL_TEXTURE_COORD_ARRAY_BUFFER_BINDING_ARB, LOC_CUSTOM, TYPE_INT, NO_OFFSET, NO_EXTRA }, - - /* GL_OES_point_sprite */ - { GL_POINT_SPRITE_NV, - CONTEXT_BOOL(Point.PointSprite), - extra_NV_point_sprite_ARB_point_sprite }, - - /* GL_EXT_texture_filter_anisotropic */ - { GL_MAX_TEXTURE_MAX_ANISOTROPY_EXT, - CONTEXT_FLOAT(Const.MaxTextureMaxAnisotropy), - extra_EXT_texture_filter_anisotropic }, - - { GL_BLEND_COLOR_EXT, LOC_CUSTOM, TYPE_FLOATN_4, 0, NO_EXTRA }, - - { GL_ACCUM_RED_BITS, BUFFER_INT(Visual.accumRedBits), NO_EXTRA }, - { GL_ACCUM_GREEN_BITS, BUFFER_INT(Visual.accumGreenBits), NO_EXTRA }, - { GL_ACCUM_BLUE_BITS, BUFFER_INT(Visual.accumBlueBits), NO_EXTRA }, - { GL_ACCUM_ALPHA_BITS, BUFFER_INT(Visual.accumAlphaBits), NO_EXTRA }, - { GL_ACCUM_CLEAR_VALUE, CONTEXT_FIELD(Accum.ClearColor[0], TYPE_FLOATN_4), NO_EXTRA }, - { GL_ALPHA_BIAS, CONTEXT_FLOAT(Pixel.AlphaBias), NO_EXTRA }, - { GL_ALPHA_SCALE, CONTEXT_FLOAT(Pixel.AlphaScale), NO_EXTRA }, - { GL_ATTRIB_STACK_DEPTH, CONTEXT_INT(AttribStackDepth), NO_EXTRA }, - { GL_AUTO_NORMAL, CONTEXT_BOOL(Eval.AutoNormal), NO_EXTRA }, - { GL_AUX_BUFFERS, BUFFER_INT(Visual.numAuxBuffers), NO_EXTRA }, - { GL_BLUE_BIAS, CONTEXT_FLOAT(Pixel.BlueBias), NO_EXTRA }, - { GL_BLUE_SCALE, CONTEXT_FLOAT(Pixel.BlueScale), NO_EXTRA }, - { GL_CLIENT_ATTRIB_STACK_DEPTH, CONTEXT_INT(ClientAttribStackDepth), NO_EXTRA }, - { GL_COLOR_MATERIAL_FACE, CONTEXT_ENUM(Light.ColorMaterialFace), NO_EXTRA }, - { GL_COLOR_MATERIAL_PARAMETER, CONTEXT_ENUM(Light.ColorMaterialMode), NO_EXTRA }, - { GL_CURRENT_INDEX, - CONTEXT_FLOAT(Current.Attrib[VERT_ATTRIB_COLOR_INDEX][0]), - extra_flush_current }, - { GL_CURRENT_RASTER_COLOR, - CONTEXT_FIELD(Current.RasterColor[0], TYPE_FLOATN_4), NO_EXTRA }, - { GL_CURRENT_RASTER_DISTANCE, CONTEXT_FLOAT(Current.RasterDistance), NO_EXTRA }, - { GL_CURRENT_RASTER_INDEX, CONST(1), NO_EXTRA }, - { GL_CURRENT_RASTER_POSITION, CONTEXT_FLOAT4(Current.RasterPos[0]), NO_EXTRA }, - { GL_CURRENT_RASTER_TEXTURE_COORDS, LOC_CUSTOM, TYPE_FLOAT_4, 0, - extra_valid_texture_unit }, - { GL_CURRENT_RASTER_POSITION_VALID, CONTEXT_BOOL(Current.RasterPosValid), NO_EXTRA }, - { GL_DEPTH_BIAS, CONTEXT_FLOAT(Pixel.DepthBias), NO_EXTRA }, - { GL_DEPTH_SCALE, CONTEXT_FLOAT(Pixel.DepthScale), NO_EXTRA }, - { GL_DOUBLEBUFFER, BUFFER_INT(Visual.doubleBufferMode), NO_EXTRA }, - { GL_DRAW_BUFFER, BUFFER_ENUM(ColorDrawBuffer), NO_EXTRA }, - { GL_EDGE_FLAG, LOC_CUSTOM, TYPE_BOOLEAN, 0, NO_EXTRA }, - { GL_FEEDBACK_BUFFER_SIZE, CONTEXT_INT(Feedback.BufferSize), NO_EXTRA }, - { GL_FEEDBACK_BUFFER_TYPE, CONTEXT_ENUM(Feedback.Type), NO_EXTRA }, - { GL_FOG_INDEX, CONTEXT_FLOAT(Fog.Index), NO_EXTRA }, - { GL_GREEN_BIAS, CONTEXT_FLOAT(Pixel.GreenBias), NO_EXTRA }, - { GL_GREEN_SCALE, CONTEXT_FLOAT(Pixel.GreenScale), NO_EXTRA }, - { GL_INDEX_BITS, BUFFER_INT(Visual.indexBits), extra_new_buffers }, - { GL_INDEX_CLEAR_VALUE, CONTEXT_INT(Color.ClearIndex), NO_EXTRA }, - { GL_INDEX_MODE, CONST(0) , NO_EXTRA}, - { GL_INDEX_OFFSET, CONTEXT_INT(Pixel.IndexOffset), NO_EXTRA }, - { GL_INDEX_SHIFT, CONTEXT_INT(Pixel.IndexShift), NO_EXTRA }, - { GL_INDEX_WRITEMASK, CONTEXT_INT(Color.IndexMask), NO_EXTRA }, - { GL_LIGHT_MODEL_LOCAL_VIEWER, CONTEXT_BOOL(Light.Model.LocalViewer), NO_EXTRA }, - { GL_LINE_STIPPLE, CONTEXT_BOOL(Line.StippleFlag), NO_EXTRA }, - { GL_LINE_STIPPLE_PATTERN, LOC_CUSTOM, TYPE_INT, 0, NO_EXTRA }, - { GL_LINE_STIPPLE_REPEAT, CONTEXT_INT(Line.StippleFactor), NO_EXTRA }, - { GL_LINE_WIDTH_GRANULARITY, CONTEXT_FLOAT(Const.LineWidthGranularity), NO_EXTRA }, - { GL_LIST_BASE, CONTEXT_INT(List.ListBase), NO_EXTRA }, - { GL_LIST_INDEX, LOC_CUSTOM, TYPE_INT, 0, NO_EXTRA }, - { GL_LIST_MODE, LOC_CUSTOM, TYPE_ENUM, 0, NO_EXTRA }, - { GL_INDEX_LOGIC_OP, CONTEXT_BOOL(Color.IndexLogicOpEnabled), NO_EXTRA }, - { GL_MAP1_COLOR_4, CONTEXT_BOOL(Eval.Map1Color4), NO_EXTRA }, - { GL_MAP1_GRID_DOMAIN, CONTEXT_FLOAT2(Eval.MapGrid1u1), NO_EXTRA }, - { GL_MAP1_GRID_SEGMENTS, CONTEXT_INT(Eval.MapGrid1un), NO_EXTRA }, - { GL_MAP1_INDEX, CONTEXT_BOOL(Eval.Map1Index), NO_EXTRA }, - { GL_MAP1_NORMAL, CONTEXT_BOOL(Eval.Map1Normal), NO_EXTRA }, - { GL_MAP1_TEXTURE_COORD_1, CONTEXT_BOOL(Eval.Map1TextureCoord1), NO_EXTRA }, - { GL_MAP1_TEXTURE_COORD_2, CONTEXT_BOOL(Eval.Map1TextureCoord2), NO_EXTRA }, - { GL_MAP1_TEXTURE_COORD_3, CONTEXT_BOOL(Eval.Map1TextureCoord3), NO_EXTRA }, - { GL_MAP1_TEXTURE_COORD_4, CONTEXT_BOOL(Eval.Map1TextureCoord4), NO_EXTRA }, - { GL_MAP1_VERTEX_3, CONTEXT_BOOL(Eval.Map1Vertex3), NO_EXTRA }, - { GL_MAP1_VERTEX_4, CONTEXT_BOOL(Eval.Map1Vertex4), NO_EXTRA }, - { GL_MAP2_COLOR_4, CONTEXT_BOOL(Eval.Map2Color4), NO_EXTRA }, - { GL_MAP2_GRID_DOMAIN, LOC_CUSTOM, TYPE_FLOAT_4, 0, NO_EXTRA }, - { GL_MAP2_GRID_SEGMENTS, CONTEXT_INT2(Eval.MapGrid2un), NO_EXTRA }, - { GL_MAP2_INDEX, CONTEXT_BOOL(Eval.Map2Index), NO_EXTRA }, - { GL_MAP2_NORMAL, CONTEXT_BOOL(Eval.Map2Normal), NO_EXTRA }, - { GL_MAP2_TEXTURE_COORD_1, CONTEXT_BOOL(Eval.Map2TextureCoord1), NO_EXTRA }, - { GL_MAP2_TEXTURE_COORD_2, CONTEXT_BOOL(Eval.Map2TextureCoord2), NO_EXTRA }, - { GL_MAP2_TEXTURE_COORD_3, CONTEXT_BOOL(Eval.Map2TextureCoord3), NO_EXTRA }, - { GL_MAP2_TEXTURE_COORD_4, CONTEXT_BOOL(Eval.Map2TextureCoord4), NO_EXTRA }, - { GL_MAP2_VERTEX_3, CONTEXT_BOOL(Eval.Map2Vertex3), NO_EXTRA }, - { GL_MAP2_VERTEX_4, CONTEXT_BOOL(Eval.Map2Vertex4), NO_EXTRA }, - { GL_MAP_COLOR, CONTEXT_BOOL(Pixel.MapColorFlag), NO_EXTRA }, - { GL_MAP_STENCIL, CONTEXT_BOOL(Pixel.MapStencilFlag), NO_EXTRA }, - { GL_MAX_ATTRIB_STACK_DEPTH, CONST(MAX_ATTRIB_STACK_DEPTH), NO_EXTRA }, - { GL_MAX_CLIENT_ATTRIB_STACK_DEPTH, CONST(MAX_CLIENT_ATTRIB_STACK_DEPTH), NO_EXTRA }, - - { GL_MAX_EVAL_ORDER, CONST(MAX_EVAL_ORDER), NO_EXTRA }, - { GL_MAX_LIST_NESTING, CONST(MAX_LIST_NESTING), NO_EXTRA }, - { GL_MAX_NAME_STACK_DEPTH, CONST(MAX_NAME_STACK_DEPTH), NO_EXTRA }, - { GL_MAX_PIXEL_MAP_TABLE, CONST(MAX_PIXEL_MAP_TABLE), NO_EXTRA }, - { GL_NAME_STACK_DEPTH, CONTEXT_INT(Select.NameStackDepth), NO_EXTRA }, - { GL_PACK_LSB_FIRST, CONTEXT_BOOL(Pack.LsbFirst), NO_EXTRA }, - { GL_PACK_ROW_LENGTH, CONTEXT_INT(Pack.RowLength), NO_EXTRA }, - { GL_PACK_SKIP_PIXELS, CONTEXT_INT(Pack.SkipPixels), NO_EXTRA }, - { GL_PACK_SKIP_ROWS, CONTEXT_INT(Pack.SkipRows), NO_EXTRA }, - { GL_PACK_SWAP_BYTES, CONTEXT_BOOL(Pack.SwapBytes), NO_EXTRA }, - { GL_PACK_IMAGE_HEIGHT_EXT, CONTEXT_INT(Pack.ImageHeight), NO_EXTRA }, - { GL_PACK_INVERT_MESA, CONTEXT_BOOL(Pack.Invert), NO_EXTRA }, - { GL_PIXEL_MAP_A_TO_A_SIZE, CONTEXT_INT(PixelMaps.AtoA.Size), NO_EXTRA }, - { GL_PIXEL_MAP_B_TO_B_SIZE, CONTEXT_INT(PixelMaps.BtoB.Size), NO_EXTRA }, - { GL_PIXEL_MAP_G_TO_G_SIZE, CONTEXT_INT(PixelMaps.GtoG.Size), NO_EXTRA }, - { GL_PIXEL_MAP_I_TO_A_SIZE, CONTEXT_INT(PixelMaps.ItoA.Size), NO_EXTRA }, - { GL_PIXEL_MAP_I_TO_B_SIZE, CONTEXT_INT(PixelMaps.ItoB.Size), NO_EXTRA }, - { GL_PIXEL_MAP_I_TO_G_SIZE, CONTEXT_INT(PixelMaps.ItoG.Size), NO_EXTRA }, - { GL_PIXEL_MAP_I_TO_I_SIZE, CONTEXT_INT(PixelMaps.ItoI.Size), NO_EXTRA }, - { GL_PIXEL_MAP_I_TO_R_SIZE, CONTEXT_INT(PixelMaps.ItoR.Size), NO_EXTRA }, - { GL_PIXEL_MAP_R_TO_R_SIZE, CONTEXT_INT(PixelMaps.RtoR.Size), NO_EXTRA }, - { GL_PIXEL_MAP_S_TO_S_SIZE, CONTEXT_INT(PixelMaps.StoS.Size), NO_EXTRA }, - { GL_POINT_SIZE_GRANULARITY, CONTEXT_FLOAT(Const.PointSizeGranularity), NO_EXTRA }, - { GL_POLYGON_MODE, CONTEXT_ENUM2(Polygon.FrontMode), NO_EXTRA }, - { GL_POLYGON_OFFSET_BIAS_EXT, CONTEXT_FLOAT(Polygon.OffsetUnits), NO_EXTRA }, - { GL_POLYGON_OFFSET_POINT, CONTEXT_BOOL(Polygon.OffsetPoint), NO_EXTRA }, - { GL_POLYGON_OFFSET_LINE, CONTEXT_BOOL(Polygon.OffsetLine), NO_EXTRA }, - { GL_POLYGON_SMOOTH, CONTEXT_BOOL(Polygon.SmoothFlag), NO_EXTRA }, - { GL_POLYGON_SMOOTH_HINT, CONTEXT_ENUM(Hint.PolygonSmooth), NO_EXTRA }, - { GL_POLYGON_STIPPLE, CONTEXT_BOOL(Polygon.StippleFlag), NO_EXTRA }, - { GL_READ_BUFFER, LOC_CUSTOM, TYPE_ENUM, NO_OFFSET, NO_EXTRA }, - { GL_RED_BIAS, CONTEXT_FLOAT(Pixel.RedBias), NO_EXTRA }, - { GL_RED_SCALE, CONTEXT_FLOAT(Pixel.RedScale), NO_EXTRA }, - { GL_RENDER_MODE, CONTEXT_ENUM(RenderMode), NO_EXTRA }, - { GL_RGBA_MODE, CONST(1), NO_EXTRA }, - { GL_SELECTION_BUFFER_SIZE, CONTEXT_INT(Select.BufferSize), NO_EXTRA }, - - { GL_STEREO, BUFFER_INT(Visual.stereoMode), NO_EXTRA }, - - { GL_TEXTURE_1D, LOC_CUSTOM, TYPE_BOOLEAN, NO_OFFSET, NO_EXTRA }, - - { GL_TEXTURE_BINDING_1D, LOC_CUSTOM, TYPE_INT, TEXTURE_1D_INDEX, NO_EXTRA }, - - { GL_TEXTURE_GEN_S, LOC_TEXUNIT, TYPE_BIT_0, - offsetof(struct gl_texture_unit, TexGenEnabled), NO_EXTRA }, - { GL_TEXTURE_GEN_T, LOC_TEXUNIT, TYPE_BIT_1, - offsetof(struct gl_texture_unit, TexGenEnabled), NO_EXTRA }, - { GL_TEXTURE_GEN_R, LOC_TEXUNIT, TYPE_BIT_2, - offsetof(struct gl_texture_unit, TexGenEnabled), NO_EXTRA }, - { GL_TEXTURE_GEN_Q, LOC_TEXUNIT, TYPE_BIT_3, - offsetof(struct gl_texture_unit, TexGenEnabled), NO_EXTRA }, - { GL_UNPACK_LSB_FIRST, CONTEXT_BOOL(Unpack.LsbFirst), NO_EXTRA }, - { GL_UNPACK_ROW_LENGTH, CONTEXT_INT(Unpack.RowLength), NO_EXTRA }, - { GL_UNPACK_SKIP_PIXELS, CONTEXT_INT(Unpack.SkipPixels), NO_EXTRA }, - { GL_UNPACK_SKIP_ROWS, CONTEXT_INT(Unpack.SkipRows), NO_EXTRA }, - { GL_UNPACK_SWAP_BYTES, CONTEXT_BOOL(Unpack.SwapBytes), NO_EXTRA }, - { GL_UNPACK_SKIP_IMAGES_EXT, CONTEXT_INT(Unpack.SkipImages), NO_EXTRA }, - { GL_UNPACK_IMAGE_HEIGHT_EXT, CONTEXT_INT(Unpack.ImageHeight), NO_EXTRA }, - { GL_ZOOM_X, CONTEXT_FLOAT(Pixel.ZoomX), NO_EXTRA }, - { GL_ZOOM_Y, CONTEXT_FLOAT(Pixel.ZoomY), NO_EXTRA }, - - /* Vertex arrays */ - { GL_VERTEX_ARRAY_COUNT_EXT, CONST(0), NO_EXTRA }, - { GL_NORMAL_ARRAY_COUNT_EXT, CONST(0), NO_EXTRA }, - { GL_COLOR_ARRAY_COUNT_EXT, CONST(0), NO_EXTRA }, - { GL_INDEX_ARRAY, ARRAY_BOOL(VertexAttrib[VERT_ATTRIB_COLOR_INDEX].Enabled), NO_EXTRA }, - { GL_INDEX_ARRAY_TYPE, ARRAY_ENUM(VertexAttrib[VERT_ATTRIB_COLOR_INDEX].Type), NO_EXTRA }, - { GL_INDEX_ARRAY_STRIDE, ARRAY_INT(VertexAttrib[VERT_ATTRIB_COLOR_INDEX].Stride), NO_EXTRA }, - { GL_INDEX_ARRAY_COUNT_EXT, CONST(0), NO_EXTRA }, - { GL_TEXTURE_COORD_ARRAY_COUNT_EXT, CONST(0), NO_EXTRA }, - { GL_EDGE_FLAG_ARRAY, ARRAY_BOOL(VertexAttrib[VERT_ATTRIB_EDGEFLAG].Enabled), NO_EXTRA }, - { GL_EDGE_FLAG_ARRAY_STRIDE, ARRAY_INT(VertexAttrib[VERT_ATTRIB_EDGEFLAG].Stride), NO_EXTRA }, - { GL_EDGE_FLAG_ARRAY_COUNT_EXT, CONST(0), NO_EXTRA }, - - /* GL_EXT_compiled_vertex_array */ - { GL_ARRAY_ELEMENT_LOCK_FIRST_EXT, CONTEXT_INT(Array.LockFirst), - extra_EXT_compiled_vertex_array }, - { GL_ARRAY_ELEMENT_LOCK_COUNT_EXT, CONTEXT_INT(Array.LockCount), - extra_EXT_compiled_vertex_array }, - - /* GL_ARB_transpose_matrix */ - { GL_TRANSPOSE_MODELVIEW_MATRIX_ARB, - CONTEXT_MATRIX_T(ModelviewMatrixStack), NO_EXTRA }, - { GL_TRANSPOSE_PROJECTION_MATRIX_ARB, - CONTEXT_MATRIX_T(ProjectionMatrixStack.Top), NO_EXTRA }, - { GL_TRANSPOSE_TEXTURE_MATRIX_ARB, CONTEXT_MATRIX_T(TextureMatrixStack), NO_EXTRA }, - - /* GL_EXT_fog_coord */ - { GL_CURRENT_FOG_COORDINATE_EXT, - CONTEXT_FLOAT(Current.Attrib[VERT_ATTRIB_FOG][0]), - extra_EXT_fog_coord_flush_current }, - { GL_FOG_COORDINATE_ARRAY_EXT, ARRAY_BOOL(VertexAttrib[VERT_ATTRIB_FOG].Enabled), - extra_EXT_fog_coord }, - { GL_FOG_COORDINATE_ARRAY_TYPE_EXT, ARRAY_ENUM(VertexAttrib[VERT_ATTRIB_FOG].Type), - extra_EXT_fog_coord }, - { GL_FOG_COORDINATE_ARRAY_STRIDE_EXT, ARRAY_INT(VertexAttrib[VERT_ATTRIB_FOG].Stride), - extra_EXT_fog_coord }, - { GL_FOG_COORDINATE_SOURCE_EXT, CONTEXT_ENUM(Fog.FogCoordinateSource), - extra_EXT_fog_coord }, - - /* GL_NV_fog_distance */ - { GL_FOG_DISTANCE_MODE_NV, CONTEXT_ENUM(Fog.FogDistanceMode), - extra_NV_fog_distance }, - - /* GL_IBM_rasterpos_clip */ - { GL_RASTER_POSITION_UNCLIPPED_IBM, - CONTEXT_BOOL(Transform.RasterPositionUnclipped), - extra_IBM_rasterpos_clip }, - - /* GL_NV_point_sprite */ - { GL_POINT_SPRITE_R_MODE_NV, - CONTEXT_ENUM(Point.SpriteRMode), extra_NV_point_sprite }, - { GL_POINT_SPRITE_COORD_ORIGIN, CONTEXT_ENUM(Point.SpriteOrigin), - extra_NV_point_sprite_ARB_point_sprite }, - - /* GL_NV_light_max_exponent */ - { GL_MAX_SHININESS_NV, CONTEXT_FLOAT(Const.MaxShininess), - extra_NV_light_max_exponent }, - { GL_MAX_SPOT_EXPONENT_NV, CONTEXT_FLOAT(Const.MaxSpotExponent), - extra_NV_light_max_exponent }, - - /* GL_ARB_vertex_buffer_object */ - { GL_INDEX_ARRAY_BUFFER_BINDING_ARB, LOC_CUSTOM, TYPE_INT, - offsetof(struct gl_array_attrib, VertexAttrib[VERT_ATTRIB_COLOR_INDEX].BufferObj), NO_EXTRA }, - { GL_EDGE_FLAG_ARRAY_BUFFER_BINDING_ARB, LOC_CUSTOM, TYPE_INT, - offsetof(struct gl_array_attrib, VertexAttrib[VERT_ATTRIB_EDGEFLAG].BufferObj), NO_EXTRA }, - { GL_FOG_COORDINATE_ARRAY_BUFFER_BINDING_ARB, LOC_CUSTOM, TYPE_INT, - offsetof(struct gl_array_attrib, VertexAttrib[VERT_ATTRIB_FOG].BufferObj), NO_EXTRA }, - - /* GL_EXT_depth_bounds_test */ - { GL_DEPTH_BOUNDS_TEST_EXT, CONTEXT_BOOL(Depth.BoundsTest), - extra_EXT_depth_bounds_test }, - { GL_DEPTH_BOUNDS_EXT, CONTEXT_FLOAT2(Depth.BoundsMin), - extra_EXT_depth_bounds_test }, - - /* GL_EXT_texture_integer */ - { GL_RGBA_INTEGER_MODE_EXT, BUFFER_BOOL(_IntegerColor), - extra_EXT_texture_integer }, - - /* GL 3.0 */ - { GL_NUM_EXTENSIONS, LOC_CUSTOM, TYPE_INT, 0, extra_version_30 }, - { GL_MAJOR_VERSION, CONTEXT_INT(VersionMajor), extra_version_30 }, - { GL_MINOR_VERSION, CONTEXT_INT(VersionMinor), extra_version_30 }, - { GL_CONTEXT_FLAGS, CONTEXT_INT(Const.ContextFlags), extra_version_30 }, - - - /* GL 3.2 */ - { GL_CONTEXT_PROFILE_MASK, CONTEXT_INT(Const.ProfileMask), - extra_version_32 }, -}; - -/* All we need now is a way to look up the value struct from the enum. - * The code generated by gcc for the old generated big switch - * statement is a big, balanced, open coded if/else tree, essentially - * an unrolled binary search. It would be natural to sort the new - * enum table and use bsearch(), but we will use a read-only hash - * table instead. bsearch() has a nice guaranteed worst case - * performance, but we're also guaranteed to hit that worst case - * (log2(n) iterations) for about half the enums. Instead, using an - * open addressing hash table, we can find the enum on the first try - * for 80% of the enums, 1 collision for 10% and never more than 5 - * collisions for any enum (typical numbers). And the code is very - * simple, even though it feels a little magic. */ - -static unsigned short table[1024]; -static const int prime_factor = 89, prime_step = 281; - -#ifdef GET_DEBUG -static void -print_table_stats(void) -{ - int i, j, collisions[11], count, hash, mask; - const struct value_desc *d; - - count = 0; - mask = Elements(table) - 1; - memset(collisions, 0, sizeof collisions); - - for (i = 0; i < Elements(table); i++) { - if (!table[i]) - continue; - count++; - d = &values[table[i]]; - hash = (d->pname * prime_factor); - j = 0; - while (1) { - if (values[table[hash & mask]].pname == d->pname) - break; - hash += prime_step; - j++; - } - - if (j < 10) - collisions[j]++; - else - collisions[10]++; - } - - printf("number of enums: %d (total %d)\n", count, Elements(values)); - for (i = 0; i < Elements(collisions) - 1; i++) - if (collisions[i] > 0) - printf(" %d enums with %d %scollisions\n", - collisions[i], i, i == 10 ? "or more " : ""); -} -#endif - -/** - * Initialize the enum hash for a given API - * - * This is called from one_time_init() to insert the enum values that - * are valid for the API in question into the enum hash table. - * - * \param the current context, for determining the API in question - */ -void _mesa_init_get_hash(struct gl_context *ctx) -{ - int i, hash, index, mask; - - mask = Elements(table) - 1; - - for (i = 0; i < Elements(values); i++) { - - hash = (values[i].pname * prime_factor) & mask; - while (1) { - index = hash & mask; - if (!table[index]) { - table[index] = i; - break; - } - hash += prime_step; - } - } - -#ifdef GET_DEBUG - print_table_stats(); -#endif -} - -/** - * Handle irregular enums - * - * Some values don't conform to the "well-known type at context - * pointer + offset" pattern, so we have this function to catch all - * the corner cases. Typically, it's a computed value or a one-off - * pointer to a custom struct or something. - * - * In this case we can't return a pointer to the value, so we'll have - * to use the temporary variable 'v' declared back in the calling - * glGet*v() function to store the result. - * - * \param ctx the current context - * \param d the struct value_desc that describes the enum - * \param v pointer to the tmp declared in the calling glGet*v() function - */ -static void -find_custom_value(struct gl_context *ctx, const struct value_desc *d, union value *v) -{ - struct gl_buffer_object **buffer_obj; - struct gl_client_array *array; - GLuint *p; - - switch (d->pname) { - case GL_TEXTURE_1D: - case GL_TEXTURE_2D: - case GL_TEXTURE_CUBE_MAP_ARB: - v->value_bool = _mesa_IsEnabled(d->pname); - break; - - case GL_LINE_STIPPLE_PATTERN: - /* This is the only GLushort, special case it here by promoting - * to an int rather than introducing a new type. */ - v->value_int = ctx->Line.StipplePattern; - break; - - case GL_CURRENT_RASTER_TEXTURE_COORDS: - v->value_float_4[0] = ctx->Current.RasterTexCoords[0]; - v->value_float_4[1] = ctx->Current.RasterTexCoords[1]; - v->value_float_4[2] = ctx->Current.RasterTexCoords[2]; - v->value_float_4[3] = ctx->Current.RasterTexCoords[3]; - break; - - case GL_CURRENT_TEXTURE_COORDS: - v->value_float_4[0] = ctx->Current.Attrib[VERT_ATTRIB_TEX][0]; - v->value_float_4[1] = ctx->Current.Attrib[VERT_ATTRIB_TEX][1]; - v->value_float_4[2] = ctx->Current.Attrib[VERT_ATTRIB_TEX][2]; - v->value_float_4[3] = ctx->Current.Attrib[VERT_ATTRIB_TEX][3]; - break; - - case GL_COLOR_WRITEMASK: - v->value_int_4[0] = ctx->Color.ColorMask[RCOMP] ? 1 : 0; - v->value_int_4[1] = ctx->Color.ColorMask[GCOMP] ? 1 : 0; - v->value_int_4[2] = ctx->Color.ColorMask[BCOMP] ? 1 : 0; - v->value_int_4[3] = ctx->Color.ColorMask[ACOMP] ? 1 : 0; - break; - - case GL_EDGE_FLAG: - v->value_bool = ctx->Current.Attrib[VERT_ATTRIB_EDGEFLAG][0] == 1.0; - break; - - case GL_READ_BUFFER: - v->value_enum = ctx->ReadBuffer->ColorReadBuffer; - break; - - case GL_MAP2_GRID_DOMAIN: - v->value_float_4[0] = ctx->Eval.MapGrid2u1; - v->value_float_4[1] = ctx->Eval.MapGrid2u2; - v->value_float_4[2] = ctx->Eval.MapGrid2v1; - v->value_float_4[3] = ctx->Eval.MapGrid2v2; - break; - - case GL_TEXTURE_STACK_DEPTH: - v->value_int = ctx->TextureMatrixStack.Depth + 1; - break; - case GL_TEXTURE_MATRIX: - v->value_matrix = ctx->TextureMatrixStack.Top; - break; - - case GL_TEXTURE_COORD_ARRAY: - case GL_TEXTURE_COORD_ARRAY_SIZE: - case GL_TEXTURE_COORD_ARRAY_TYPE: - case GL_TEXTURE_COORD_ARRAY_STRIDE: - array = &ctx->Array.VertexAttrib[VERT_ATTRIB_TEX]; - v->value_int = *(GLuint *) ((char *) array + d->offset); - break; - - case GL_MODELVIEW_STACK_DEPTH: - case GL_PROJECTION_STACK_DEPTH: - v->value_int = *(GLint *) ((char *) ctx + d->offset) + 1; - break; - - case GL_MAX_TEXTURE_SIZE: - case GL_MAX_3D_TEXTURE_SIZE: - case GL_MAX_CUBE_MAP_TEXTURE_SIZE_ARB: - p = (GLuint *) ((char *) ctx + d->offset); - v->value_int = 1 << (*p - 1); - break; - - case GL_SCISSOR_BOX: - v->value_int_4[0] = ctx->Scissor.X; - v->value_int_4[1] = ctx->Scissor.Y; - v->value_int_4[2] = ctx->Scissor.Width; - v->value_int_4[3] = ctx->Scissor.Height; - break; - - case GL_LIST_INDEX: - v->value_int = - ctx->ListState.CurrentList ? ctx->ListState.CurrentList->Name : 0; - break; - case GL_LIST_MODE: - if (!ctx->CompileFlag) - v->value_enum = 0; - else if (ctx->ExecuteFlag) - v->value_enum = GL_COMPILE_AND_EXECUTE; - else - v->value_enum = GL_COMPILE; - break; - - case GL_VIEWPORT: - v->value_int_4[0] = ctx->Viewport.X; - v->value_int_4[1] = ctx->Viewport.Y; - v->value_int_4[2] = ctx->Viewport.Width; - v->value_int_4[3] = ctx->Viewport.Height; - break; - - case GL_STENCIL_FAIL: - v->value_enum = ctx->Stencil.FailFunc; - break; - case GL_STENCIL_FUNC: - v->value_enum = ctx->Stencil.Function; - break; - case GL_STENCIL_PASS_DEPTH_FAIL: - v->value_enum = ctx->Stencil.ZFailFunc; - break; - case GL_STENCIL_PASS_DEPTH_PASS: - v->value_enum = ctx->Stencil.ZPassFunc; - break; - case GL_STENCIL_REF: - v->value_int = ctx->Stencil.Ref; - break; - case GL_STENCIL_VALUE_MASK: - v->value_int = ctx->Stencil.ValueMask; - break; - case GL_STENCIL_WRITEMASK: - v->value_int = ctx->Stencil.WriteMask; - break; - - case GL_NUM_EXTENSIONS: - v->value_int = _mesa_get_extension_count(ctx); - break; - - case GL_IMPLEMENTATION_COLOR_READ_TYPE_OES: - v->value_int = _mesa_get_color_read_type(ctx); - break; - case GL_IMPLEMENTATION_COLOR_READ_FORMAT_OES: - v->value_int = _mesa_get_color_read_format(ctx); - break; - - case GL_CURRENT_MATRIX_STACK_DEPTH_ARB: - v->value_int = ctx->CurrentStack->Depth + 1; - break; - case GL_CURRENT_MATRIX_ARB: - case GL_TRANSPOSE_CURRENT_MATRIX_ARB: - v->value_matrix = ctx->CurrentStack->Top; - break; - - /* Various object names */ - - case GL_TEXTURE_BINDING_1D: - case GL_TEXTURE_BINDING_2D: - case GL_TEXTURE_BINDING_3D: - case GL_TEXTURE_BINDING_CUBE_MAP_ARB: - v->value_int = - ctx->Texture.Unit.CurrentTex[d->offset]->Name; - break; - - /* GL_ARB_vertex_buffer_object */ - case GL_VERTEX_ARRAY_BUFFER_BINDING_ARB: - case GL_NORMAL_ARRAY_BUFFER_BINDING_ARB: - case GL_COLOR_ARRAY_BUFFER_BINDING_ARB: - case GL_INDEX_ARRAY_BUFFER_BINDING_ARB: - case GL_EDGE_FLAG_ARRAY_BUFFER_BINDING_ARB: - case GL_SECONDARY_COLOR_ARRAY_BUFFER_BINDING_ARB: - case GL_FOG_COORDINATE_ARRAY_BUFFER_BINDING_ARB: - buffer_obj = (struct gl_buffer_object **) - ((char *) &ctx->Array + d->offset); - v->value_int = (*buffer_obj)->Name; - break; - case GL_TEXTURE_COORD_ARRAY_BUFFER_BINDING_ARB: - v->value_int = - ctx->Array.VertexAttrib[VERT_ATTRIB_TEX].BufferObj->Name; - break; - case GL_ELEMENT_ARRAY_BUFFER_BINDING_ARB: - v->value_int = ctx->Array.ElementArrayBufferObj->Name; - break; - - case GL_FOG_COLOR: - COPY_4FV(v->value_float_4, ctx->Fog.Color); - break; - case GL_COLOR_CLEAR_VALUE: - v->value_float_4[0] = ctx->Color.ClearColor.f[0]; - v->value_float_4[1] = ctx->Color.ClearColor.f[1]; - v->value_float_4[2] = ctx->Color.ClearColor.f[2]; - v->value_float_4[3] = ctx->Color.ClearColor.f[3]; - break; - case GL_ALPHA_TEST_REF: - v->value_float = ctx->Color.AlphaRef; - break; - } -} - -/** - * Check extra constraints on a struct value_desc descriptor - * - * If a struct value_desc has a non-NULL extra pointer, it means that - * there are a number of extra constraints to check or actions to - * perform. The extras is just an integer array where each integer - * encode different constraints or actions. - * - * \param ctx current context - * \param func name of calling glGet*v() function for error reporting - * \param d the struct value_desc that has the extra constraints - * - * \return GL_FALSE if one of the constraints was not satisfied, - * otherwise GL_TRUE. - */ -static GLboolean -check_extra(struct gl_context *ctx, const char *func, const struct value_desc *d) -{ - const GLuint version = ctx->VersionMajor * 10 + ctx->VersionMinor; - int total, enabled; - const int *e; - - total = 0; - enabled = 0; - for (e = d->extra; *e != EXTRA_END; e++) - switch (*e) { - case EXTRA_VERSION_30: - if (version >= 30) { - total++; - enabled++; - } - break; - case EXTRA_VERSION_31: - if (version >= 31) { - total++; - enabled++; - } - break; - case EXTRA_VERSION_32: - if (version >= 32) { - total++; - enabled++; - } - break; - case EXTRA_NEW_BUFFERS: - if (ctx->NewState & _NEW_BUFFERS) - _mesa_update_state(ctx); - break; - case EXTRA_FLUSH_CURRENT: - FLUSH_CURRENT(ctx, 0); - break; - case EXTRA_VALID_CLIP_DISTANCE: - if (d->pname - GL_CLIP_DISTANCE0 >= ctx->Const.MaxClipPlanes) { - _mesa_error(ctx, GL_INVALID_ENUM, "%s(clip distance %u)", - func, d->pname - GL_CLIP_DISTANCE0); - return GL_FALSE; - } - break; - case EXTRA_END: - break; - default: /* *e is a offset into the extension struct */ - total++; - if (*(GLboolean *) ((char *) &ctx->Extensions + *e)) - enabled++; - break; - } - - if (total > 0 && enabled == 0) { - _mesa_error(ctx, GL_INVALID_ENUM, "%s(pname=%s)", func, - _mesa_lookup_enum_by_nr(d->pname)); - return GL_FALSE; - } - - return GL_TRUE; -} - -static const struct value_desc error_value = - { 0, 0, TYPE_INVALID, NO_OFFSET, NO_EXTRA }; - -/** - * Find the struct value_desc corresponding to the enum 'pname'. - * - * We hash the enum value to get an index into the 'table' array, - * which holds the index in the 'values' array of struct value_desc. - * Once we've found the entry, we do the extra checks, if any, then - * look up the value and return a pointer to it. - * - * If the value has to be computed (for example, it's the result of a - * function call or we need to add 1 to it), we use the tmp 'v' to - * store the result. - * - * \param func name of glGet*v() func for error reporting - * \param pname the enum value we're looking up - * \param p is were we return the pointer to the value - * \param v a tmp union value variable in the calling glGet*v() function - * - * \return the struct value_desc corresponding to the enum or a struct - * value_desc of TYPE_INVALID if not found. This lets the calling - * glGet*v() function jump right into a switch statement and - * handle errors there instead of having to check for NULL. - */ -static const struct value_desc * -find_value(const char *func, GLenum pname, void **p, union value *v) -{ - GET_CURRENT_CONTEXT(ctx); - struct gl_texture_unit *unit; - int mask, hash; - const struct value_desc *d; - - mask = Elements(table) - 1; - hash = (pname * prime_factor); - while (1) { - int idx = table[hash & mask]; - - /* If the enum isn't valid, the hash walk ends with index 0, - * pointing to the first entry of values[] which doesn't hold - * any valid enum. */ - if (unlikely(idx == 0)) { - _mesa_error(ctx, GL_INVALID_ENUM, "%s(pname=%s)", func, - _mesa_lookup_enum_by_nr(pname)); - return &error_value; - } - - d = &values[idx]; - if (likely(d->pname == pname)) - break; - - hash += prime_step; - } - - if (unlikely(d->extra && !check_extra(ctx, func, d))) - return &error_value; - - switch (d->location) { - case LOC_BUFFER: - *p = ((char *) ctx->DrawBuffer + d->offset); - return d; - case LOC_CONTEXT: - *p = ((char *) ctx + d->offset); - return d; - case LOC_ARRAY: - *p = ((char *)&ctx->Array + d->offset); - return d; - case LOC_TEXUNIT: - unit = &ctx->Texture.Unit; - *p = ((char *) unit + d->offset); - return d; - case LOC_CUSTOM: - find_custom_value(ctx, d, v); - *p = v; - return d; - default: - assert(0); - break; - } - - /* silence warning */ - return &error_value; -} - -static const int transpose[] = { - 0, 4, 8, 12, - 1, 5, 9, 13, - 2, 6, 10, 14, - 3, 7, 11, 15 -}; - -void GLAPIENTRY -_mesa_GetBooleanv(GLenum pname, GLboolean *params) -{ - const struct value_desc *d; - union value v; - GLmatrix *m; - int shift, i; - void *p; - GET_CURRENT_CONTEXT(ctx); - - ASSERT_OUTSIDE_BEGIN_END(ctx); - - d = find_value("glGetBooleanv", pname, &p, &v); - switch (d->type) { - case TYPE_INVALID: - break; - case TYPE_CONST: - params[0] = INT_TO_BOOLEAN(d->offset); - break; - - case TYPE_FLOAT_4: - case TYPE_FLOATN_4: - params[3] = FLOAT_TO_BOOLEAN(((GLfloat *) p)[3]); - case TYPE_FLOAT_3: - case TYPE_FLOATN_3: - params[2] = FLOAT_TO_BOOLEAN(((GLfloat *) p)[2]); - case TYPE_FLOAT_2: - case TYPE_FLOATN_2: - params[1] = FLOAT_TO_BOOLEAN(((GLfloat *) p)[1]); - case TYPE_FLOAT: - case TYPE_FLOATN: - params[0] = FLOAT_TO_BOOLEAN(((GLfloat *) p)[0]); - break; - - case TYPE_DOUBLEN: - params[0] = FLOAT_TO_BOOLEAN(((GLdouble *) p)[0]); - break; - - case TYPE_INT_4: - params[3] = INT_TO_BOOLEAN(((GLint *) p)[3]); - case TYPE_INT_3: - params[2] = INT_TO_BOOLEAN(((GLint *) p)[2]); - case TYPE_INT_2: - case TYPE_ENUM_2: - params[1] = INT_TO_BOOLEAN(((GLint *) p)[1]); - case TYPE_INT: - case TYPE_ENUM: - params[0] = INT_TO_BOOLEAN(((GLint *) p)[0]); - break; - - case TYPE_INT_N: - for (i = 0; i < v.value_int_n.n; i++) - params[i] = INT_TO_BOOLEAN(v.value_int_n.ints[i]); - break; - - case TYPE_INT64: - params[0] = INT64_TO_BOOLEAN(((GLint64 *) p)[0]); - break; - - case TYPE_BOOLEAN: - params[0] = ((GLboolean*) p)[0]; - break; - - case TYPE_MATRIX: - m = *(GLmatrix **) p; - for (i = 0; i < 16; i++) - params[i] = FLOAT_TO_BOOLEAN(m->m[i]); - break; - - case TYPE_MATRIX_T: - m = *(GLmatrix **) p; - for (i = 0; i < 16; i++) - params[i] = FLOAT_TO_BOOLEAN(m->m[transpose[i]]); - break; - - case TYPE_BIT_0: - case TYPE_BIT_1: - case TYPE_BIT_2: - case TYPE_BIT_3: - case TYPE_BIT_4: - case TYPE_BIT_5: - case TYPE_BIT_6: - case TYPE_BIT_7: - shift = d->type - TYPE_BIT_0; - params[0] = (*(GLbitfield *) p >> shift) & 1; - break; - } -} - -void GLAPIENTRY -_mesa_GetFloatv(GLenum pname, GLfloat *params) -{ - const struct value_desc *d; - union value v; - GLmatrix *m; - int shift, i; - void *p; - GET_CURRENT_CONTEXT(ctx); - - ASSERT_OUTSIDE_BEGIN_END(ctx); - - d = find_value("glGetFloatv", pname, &p, &v); - switch (d->type) { - case TYPE_INVALID: - break; - case TYPE_CONST: - params[0] = (GLfloat) d->offset; - break; - - case TYPE_FLOAT_4: - case TYPE_FLOATN_4: - params[3] = ((GLfloat *) p)[3]; - case TYPE_FLOAT_3: - case TYPE_FLOATN_3: - params[2] = ((GLfloat *) p)[2]; - case TYPE_FLOAT_2: - case TYPE_FLOATN_2: - params[1] = ((GLfloat *) p)[1]; - case TYPE_FLOAT: - case TYPE_FLOATN: - params[0] = ((GLfloat *) p)[0]; - break; - - case TYPE_DOUBLEN: - params[0] = ((GLdouble *) p)[0]; - break; - - case TYPE_INT_4: - params[3] = (GLfloat) (((GLint *) p)[3]); - case TYPE_INT_3: - params[2] = (GLfloat) (((GLint *) p)[2]); - case TYPE_INT_2: - case TYPE_ENUM_2: - params[1] = (GLfloat) (((GLint *) p)[1]); - case TYPE_INT: - case TYPE_ENUM: - params[0] = (GLfloat) (((GLint *) p)[0]); - break; - - case TYPE_INT_N: - for (i = 0; i < v.value_int_n.n; i++) - params[i] = INT_TO_FLOAT(v.value_int_n.ints[i]); - break; - - case TYPE_INT64: - params[0] = ((GLint64 *) p)[0]; - break; - - case TYPE_BOOLEAN: - params[0] = BOOLEAN_TO_FLOAT(*(GLboolean*) p); - break; - - case TYPE_MATRIX: - m = *(GLmatrix **) p; - for (i = 0; i < 16; i++) - params[i] = m->m[i]; - break; - - case TYPE_MATRIX_T: - m = *(GLmatrix **) p; - for (i = 0; i < 16; i++) - params[i] = m->m[transpose[i]]; - break; - - case TYPE_BIT_0: - case TYPE_BIT_1: - case TYPE_BIT_2: - case TYPE_BIT_3: - case TYPE_BIT_4: - case TYPE_BIT_5: - case TYPE_BIT_6: - case TYPE_BIT_7: - shift = d->type - TYPE_BIT_0; - params[0] = BOOLEAN_TO_FLOAT((*(GLbitfield *) p >> shift) & 1); - break; - } -} - -void GLAPIENTRY -_mesa_GetIntegerv(GLenum pname, GLint *params) -{ - const struct value_desc *d; - union value v; - GLmatrix *m; - int shift, i; - void *p; - GET_CURRENT_CONTEXT(ctx); - - ASSERT_OUTSIDE_BEGIN_END(ctx); - - d = find_value("glGetIntegerv", pname, &p, &v); - switch (d->type) { - case TYPE_INVALID: - break; - case TYPE_CONST: - params[0] = d->offset; - break; - - case TYPE_FLOAT_4: - params[3] = IROUND(((GLfloat *) p)[3]); - case TYPE_FLOAT_3: - params[2] = IROUND(((GLfloat *) p)[2]); - case TYPE_FLOAT_2: - params[1] = IROUND(((GLfloat *) p)[1]); - case TYPE_FLOAT: - params[0] = IROUND(((GLfloat *) p)[0]); - break; - - case TYPE_FLOATN_4: - params[3] = FLOAT_TO_INT(((GLfloat *) p)[3]); - case TYPE_FLOATN_3: - params[2] = FLOAT_TO_INT(((GLfloat *) p)[2]); - case TYPE_FLOATN_2: - params[1] = FLOAT_TO_INT(((GLfloat *) p)[1]); - case TYPE_FLOATN: - params[0] = FLOAT_TO_INT(((GLfloat *) p)[0]); - break; - - case TYPE_DOUBLEN: - params[0] = FLOAT_TO_INT(((GLdouble *) p)[0]); - break; - - case TYPE_INT_4: - params[3] = ((GLint *) p)[3]; - case TYPE_INT_3: - params[2] = ((GLint *) p)[2]; - case TYPE_INT_2: - case TYPE_ENUM_2: - params[1] = ((GLint *) p)[1]; - case TYPE_INT: - case TYPE_ENUM: - params[0] = ((GLint *) p)[0]; - break; - - case TYPE_INT_N: - for (i = 0; i < v.value_int_n.n; i++) - params[i] = v.value_int_n.ints[i]; - break; - - case TYPE_INT64: - params[0] = INT64_TO_INT(((GLint64 *) p)[0]); - break; - - case TYPE_BOOLEAN: - params[0] = BOOLEAN_TO_INT(*(GLboolean*) p); - break; - - case TYPE_MATRIX: - m = *(GLmatrix **) p; - for (i = 0; i < 16; i++) - params[i] = FLOAT_TO_INT(m->m[i]); - break; - - case TYPE_MATRIX_T: - m = *(GLmatrix **) p; - for (i = 0; i < 16; i++) - params[i] = FLOAT_TO_INT(m->m[transpose[i]]); - break; - - case TYPE_BIT_0: - case TYPE_BIT_1: - case TYPE_BIT_2: - case TYPE_BIT_3: - case TYPE_BIT_4: - case TYPE_BIT_5: - case TYPE_BIT_6: - case TYPE_BIT_7: - shift = d->type - TYPE_BIT_0; - params[0] = (*(GLbitfield *) p >> shift) & 1; - break; - } -} - - -void GLAPIENTRY -_mesa_GetDoublev(GLenum pname, GLdouble *params) -{ - const struct value_desc *d; - union value v; - GLmatrix *m; - int shift, i; - void *p; - GET_CURRENT_CONTEXT(ctx); - - ASSERT_OUTSIDE_BEGIN_END(ctx); - - d = find_value("glGetDoublev", pname, &p, &v); - switch (d->type) { - case TYPE_INVALID: - break; - case TYPE_CONST: - params[0] = d->offset; - break; - - case TYPE_FLOAT_4: - case TYPE_FLOATN_4: - params[3] = ((GLfloat *) p)[3]; - case TYPE_FLOAT_3: - case TYPE_FLOATN_3: - params[2] = ((GLfloat *) p)[2]; - case TYPE_FLOAT_2: - case TYPE_FLOATN_2: - params[1] = ((GLfloat *) p)[1]; - case TYPE_FLOAT: - case TYPE_FLOATN: - params[0] = ((GLfloat *) p)[0]; - break; - - case TYPE_DOUBLEN: - params[0] = ((GLdouble *) p)[0]; - break; - - case TYPE_INT_4: - params[3] = ((GLint *) p)[3]; - case TYPE_INT_3: - params[2] = ((GLint *) p)[2]; - case TYPE_INT_2: - case TYPE_ENUM_2: - params[1] = ((GLint *) p)[1]; - case TYPE_INT: - case TYPE_ENUM: - params[0] = ((GLint *) p)[0]; - break; - - case TYPE_INT_N: - for (i = 0; i < v.value_int_n.n; i++) - params[i] = v.value_int_n.ints[i]; - break; - - case TYPE_INT64: - params[0] = ((GLint64 *) p)[0]; - break; - - case TYPE_BOOLEAN: - params[0] = *(GLboolean*) p; - break; - - case TYPE_MATRIX: - m = *(GLmatrix **) p; - for (i = 0; i < 16; i++) - params[i] = m->m[i]; - break; - - case TYPE_MATRIX_T: - m = *(GLmatrix **) p; - for (i = 0; i < 16; i++) - params[i] = m->m[transpose[i]]; - break; - - case TYPE_BIT_0: - case TYPE_BIT_1: - case TYPE_BIT_2: - case TYPE_BIT_3: - case TYPE_BIT_4: - case TYPE_BIT_5: - case TYPE_BIT_6: - case TYPE_BIT_7: - shift = d->type - TYPE_BIT_0; - params[0] = (*(GLbitfield *) p >> shift) & 1; - break; - } -} - -#if FEATURE_ES1 -void GLAPIENTRY -_mesa_GetFixedv(GLenum pname, GLfixed *params) -{ - const struct value_desc *d; - union value v; - GLmatrix *m; - int shift, i; - void *p; - - d = find_value("glGetDoublev", pname, &p, &v); - switch (d->type) { - case TYPE_INVALID: - break; - case TYPE_CONST: - params[0] = INT_TO_FIXED(d->offset); - break; - - case TYPE_FLOAT_4: - case TYPE_FLOATN_4: - params[3] = FLOAT_TO_FIXED(((GLfloat *) p)[3]); - case TYPE_FLOAT_3: - case TYPE_FLOATN_3: - params[2] = FLOAT_TO_FIXED(((GLfloat *) p)[2]); - case TYPE_FLOAT_2: - case TYPE_FLOATN_2: - params[1] = FLOAT_TO_FIXED(((GLfloat *) p)[1]); - case TYPE_FLOAT: - case TYPE_FLOATN: - params[0] = FLOAT_TO_FIXED(((GLfloat *) p)[0]); - break; - - case TYPE_DOUBLEN: - params[0] = FLOAT_TO_FIXED(((GLdouble *) p)[0]); - break; - - case TYPE_INT_4: - params[3] = INT_TO_FIXED(((GLint *) p)[3]); - case TYPE_INT_3: - params[2] = INT_TO_FIXED(((GLint *) p)[2]); - case TYPE_INT_2: - case TYPE_ENUM_2: - params[1] = INT_TO_FIXED(((GLint *) p)[1]); - case TYPE_INT: - case TYPE_ENUM: - params[0] = INT_TO_FIXED(((GLint *) p)[0]); - break; - - case TYPE_INT_N: - for (i = 0; i < v.value_int_n.n; i++) - params[i] = INT_TO_FIXED(v.value_int_n.ints[i]); - break; - - case TYPE_INT64: - params[0] = ((GLint64 *) p)[0]; - break; - - case TYPE_BOOLEAN: - params[0] = BOOLEAN_TO_FIXED(((GLboolean*) p)[0]); - break; - - case TYPE_MATRIX: - m = *(GLmatrix **) p; - for (i = 0; i < 16; i++) - params[i] = FLOAT_TO_FIXED(m->m[i]); - break; - - case TYPE_MATRIX_T: - m = *(GLmatrix **) p; - for (i = 0; i < 16; i++) - params[i] = FLOAT_TO_FIXED(m->m[transpose[i]]); - break; - - case TYPE_BIT_0: - case TYPE_BIT_1: - case TYPE_BIT_2: - case TYPE_BIT_3: - case TYPE_BIT_4: - case TYPE_BIT_5: - case TYPE_BIT_6: - case TYPE_BIT_7: - shift = d->type - TYPE_BIT_0; - params[0] = BOOLEAN_TO_FIXED((*(GLbitfield *) p >> shift) & 1); - break; - } -} -#endif diff --git a/dll/opengl/mesa/main/get.h b/dll/opengl/mesa/main/get.h deleted file mode 100644 index accaf19e5bc..00000000000 --- a/dll/opengl/mesa/main/get.h +++ /dev/null @@ -1,68 +0,0 @@ -/** - * \file get.h - * State query functions. - */ - -/* - * Mesa 3-D graphics library - * Version: 3.5 - * - * Copyright (C) 1999-2001 Brian Paul All Rights Reserved. - * - * Permission is hereby granted, free of charge, to any person obtaining a - * copy of this software and associated documentation files (the "Software"), - * to deal in the Software without restriction, including without limitation - * the rights to use, copy, modify, merge, publish, distribute, sublicense, - * and/or sell copies of the Software, and to permit persons to whom the - * Software is furnished to do so, subject to the following conditions: - * - * The above copyright notice and this permission notice shall be included - * in all copies or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS - * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL - * BRIAN PAUL BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN - * AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN - * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. - */ - - -#ifndef GET_H -#define GET_H - - -#include "glheader.h" - - -extern void GLAPIENTRY -_mesa_GetBooleanv( GLenum pname, GLboolean *params ); - -extern void GLAPIENTRY -_mesa_GetDoublev( GLenum pname, GLdouble *params ); - -extern void GLAPIENTRY -_mesa_GetFloatv( GLenum pname, GLfloat *params ); - -extern void GLAPIENTRY -_mesa_GetIntegerv( GLenum pname, GLint *params ); - -extern void GLAPIENTRY -_mesa_GetInteger64v( GLenum pname, GLint64 *params ); - -extern void GLAPIENTRY -_mesa_GetFixedv(GLenum pname, GLfixed *params); - -extern void GLAPIENTRY -_mesa_GetInteger64Indexedv( GLenum pname, GLuint index, GLint64 *params ); - -extern void GLAPIENTRY -_mesa_GetPointerv( GLenum pname, GLvoid **params ); - -extern const GLubyte * GLAPIENTRY -_mesa_GetString( GLenum name ); - -extern GLenum GLAPIENTRY -_mesa_GetError( void ); - -#endif diff --git a/dll/opengl/mesa/main/getstring.c b/dll/opengl/mesa/main/getstring.c deleted file mode 100644 index ef5c272fcad..00000000000 --- a/dll/opengl/mesa/main/getstring.c +++ /dev/null @@ -1,153 +0,0 @@ -/* - * Mesa 3-D graphics library - * Version: 7.1 - * - * Copyright (C) 1999-2008 Brian Paul All Rights Reserved. - * - * Permission is hereby granted, free of charge, to any person obtaining a - * copy of this software and associated documentation files (the "Software"), - * to deal in the Software without restriction, including without limitation - * the rights to use, copy, modify, merge, publish, distribute, sublicense, - * and/or sell copies of the Software, and to permit persons to whom the - * Software is furnished to do so, subject to the following conditions: - * - * The above copyright notice and this permission notice shall be included - * in all copies or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS - * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL - * BRIAN PAUL BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN - * AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN - * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. - */ - -#include - -/** - * Query string-valued state. The return value should _not_ be freed by - * the caller. - * - * \param name the state variable to query. - * - * \sa glGetString(). - * - * Tries to get the string from dd_function_table::GetString, otherwise returns - * the hardcoded strings. - */ -const GLubyte * GLAPIENTRY -_mesa_GetString( GLenum name ) -{ - GET_CURRENT_CONTEXT(ctx); - static const char *vendor = "Brian Paul"; - static const char *renderer = "Mesa"; - - if (!ctx) - return NULL; - - ASSERT_OUTSIDE_BEGIN_END_WITH_RETVAL(ctx, NULL); - - /* this is a required driver function */ - assert(ctx->Driver.GetString); - { - /* Give the driver the chance to handle this query */ - const GLubyte *str = (*ctx->Driver.GetString)(ctx, name); - if (str) - return str; - } - - switch (name) { - case GL_VENDOR: - return (const GLubyte *) vendor; - case GL_RENDERER: - return (const GLubyte *) renderer; - case GL_VERSION: - return (const GLubyte *) ctx->VersionString; - case GL_EXTENSIONS: - return (const GLubyte *) ctx->Extensions.String; - default: - _mesa_error( ctx, GL_INVALID_ENUM, "glGetString" ); - return (const GLubyte *) 0; - } -} - - - -/** - * Return pointer-valued state, such as a vertex array pointer. - * - * \param pname names state to be queried - * \param params returns the pointer value - * - * \sa glGetPointerv(). - * - * Tries to get the specified pointer via dd_function_table::GetPointerv, - * otherwise gets the specified pointer from the current context. - */ -void GLAPIENTRY -_mesa_GetPointerv( GLenum pname, GLvoid **params ) -{ - GET_CURRENT_CONTEXT(ctx); - ASSERT_OUTSIDE_BEGIN_END(ctx); - - if (!params) - return; - - if (MESA_VERBOSE & VERBOSE_API) - _mesa_debug(ctx, "glGetPointerv %s\n", _mesa_lookup_enum_by_nr(pname)); - - switch (pname) { - case GL_VERTEX_ARRAY_POINTER: - *params = (GLvoid *) ctx->Array.VertexAttrib[VERT_ATTRIB_POS].Ptr; - break; - case GL_NORMAL_ARRAY_POINTER: - *params = (GLvoid *) ctx->Array.VertexAttrib[VERT_ATTRIB_NORMAL].Ptr; - break; - case GL_COLOR_ARRAY_POINTER: - *params = (GLvoid *) ctx->Array.VertexAttrib[VERT_ATTRIB_COLOR].Ptr; - break; - case GL_FOG_COORDINATE_ARRAY_POINTER_EXT: - *params = (GLvoid *) ctx->Array.VertexAttrib[VERT_ATTRIB_FOG].Ptr; - break; - case GL_INDEX_ARRAY_POINTER: - *params = (GLvoid *) ctx->Array.VertexAttrib[VERT_ATTRIB_COLOR_INDEX].Ptr; - break; - case GL_TEXTURE_COORD_ARRAY_POINTER: - *params = (GLvoid *) ctx->Array.VertexAttrib[VERT_ATTRIB_TEX].Ptr; - break; - case GL_EDGE_FLAG_ARRAY_POINTER: - *params = (GLvoid *) ctx->Array.VertexAttrib[VERT_ATTRIB_EDGEFLAG].Ptr; - break; - case GL_FEEDBACK_BUFFER_POINTER: - *params = ctx->Feedback.Buffer; - break; - case GL_SELECTION_BUFFER_POINTER: - *params = ctx->Select.Buffer; - break; - default: - _mesa_error( ctx, GL_INVALID_ENUM, "glGetPointerv" ); - return; - } -} - - -/** - * Returns the current GL error code, or GL_NO_ERROR. - * \return current error code - * - * Returns __struct gl_contextRec::ErrorValue. - */ -GLenum GLAPIENTRY -_mesa_GetError( void ) -{ - GET_CURRENT_CONTEXT(ctx); - GLenum e = ctx->ErrorValue; - ASSERT_OUTSIDE_BEGIN_END_WITH_RETVAL(ctx, 0); - - if (MESA_VERBOSE & VERBOSE_API) - _mesa_debug(ctx, "glGetError <-- %s\n", _mesa_lookup_enum_by_nr(e)); - - ctx->ErrorValue = (GLenum) GL_NO_ERROR; - ctx->ErrorDebugCount = 0; - return e; -} diff --git a/dll/opengl/mesa/main/git_sha1.h b/dll/opengl/mesa/main/git_sha1.h deleted file mode 100644 index e69de29bb2d..00000000000 diff --git a/dll/opengl/mesa/main/glheader.h b/dll/opengl/mesa/main/glheader.h deleted file mode 100644 index 6f4a59de554..00000000000 --- a/dll/opengl/mesa/main/glheader.h +++ /dev/null @@ -1,193 +0,0 @@ -/* - * Mesa 3-D graphics library - * Version: 7.5 - * - * Copyright (C) 1999-2008 Brian Paul All Rights Reserved. - * - * Permission is hereby granted, free of charge, to any person obtaining a - * copy of this software and associated documentation files (the "Software"), - * to deal in the Software without restriction, including without limitation - * the rights to use, copy, modify, merge, publish, distribute, sublicense, - * and/or sell copies of the Software, and to permit persons to whom the - * Software is furnished to do so, subject to the following conditions: - * - * The above copyright notice and this permission notice shall be included - * in all copies or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS - * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL - * BRIAN PAUL BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN - * AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN - * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. - */ - - -/** - * \file glheader.h - * Wrapper for GL/gl.h and GL/glext.h - */ - - -#ifndef GLHEADER_H -#define GLHEADER_H - - -#ifdef WGLAPI -#undef WGLAPI -#endif - - -#if !defined(OPENSTEP) && (defined(__WIN32__) && !defined(__CYGWIN__)) && !defined(BUILD_FOR_SNAP) -# if (defined(_MSC_VER) || defined(__MINGW32__)) && defined(BUILD_GL32) /* tag specify we're building mesa as a DLL */ -# define WGLAPI __declspec(dllexport) -# elif (defined(_MSC_VER) || defined(__MINGW32__)) && defined(_DLL) /* tag specifying we're building for DLL runtime support */ -# define WGLAPI __declspec(dllimport) -# else /* for use with static link lib build of Win32 edition only */ -# define WGLAPI __declspec(dllimport) -# endif /* _STATIC_MESA support */ -#endif /* WIN32 / CYGWIN bracket */ - -#define WIN32_NO_STATUS - -#define GL_GLEXT_PROTOTYPES -#include -#include - -/* Threading glue for WINAPI */ -#include -#include -typedef CRITICAL_SECTION _glthread_Mutex; -#define _glthread_DECLARE_STATIC_MUTEX(name) static _glthread_Mutex name = {(PCRITICAL_SECTION_DEBUG)-1, -1, 0, 0, 0, 0} -#define _glthread_INIT_MUTEX(name) InitializeCriticalSection(&name) -#define _glthread_DESTROY_MUTEX(name) DeleteCriticalSection(&name) -#define _glthread_LOCK_MUTEX(name) EnterCriticalSection(&name) -#define _glthread_UNLOCK_MUTEX(name) LeaveCriticalSection(&name) - -/* Context glue with opengl32 */ -#include "../opengl32/opengl32.h" -#define GET_CURRENT_CONTEXT(__ctx__) struct gl_context* __ctx__ = (struct gl_context*)IntGetCurrentICDPrivate() -#define GET_DISPATCH() ((struct _glapi_table*)IntGetCurrentDispatchTable()) -#define _glapi_set_dispatch(table) IntSetCurrentDispatchTable((const GLDISPATCHTABLE*)(table)) -#define _glapi_get_dispatch_table_size() (OPENGL_VERSION_110_ENTRIES) -#define _glapi_get_context() ((void*)IntGetCurrentICDPrivate()) -#define _glapi_set_context(__ctx__) IntSetCurrentICDPrivate((void*)(__ctx__)) - - -#ifdef __cplusplus -extern "C" { -#endif - - -/** - * GL_FIXED is defined in glext.h version 64 but these typedefs aren't (yet). - */ -typedef int GLfixed; -typedef int GLclampx; - - -#ifndef GL_OES_EGL_image -typedef void *GLeglImageOES; -#endif - - -#ifndef GL_OES_EGL_image_external -#define GL_TEXTURE_EXTERNAL_OES 0x8D65 -#define GL_SAMPLER_EXTERNAL_OES 0x8D66 -#define GL_TEXTURE_BINDING_EXTERNAL_OES 0x8D67 -#define GL_REQUIRED_TEXTURE_IMAGE_UNITS_OES 0x8D68 -#endif - - -#ifndef GL_OES_point_size_array -#define GL_POINT_SIZE_ARRAY_OES 0x8B9C -#define GL_POINT_SIZE_ARRAY_TYPE_OES 0x898A -#define GL_POINT_SIZE_ARRAY_STRIDE_OES 0x898B -#define GL_POINT_SIZE_ARRAY_POINTER_OES 0x898C -#define GL_POINT_SIZE_ARRAY_BUFFER_BINDING_OES 0x8B9F -#endif - - -#ifndef GL_OES_draw_texture -#define GL_TEXTURE_CROP_RECT_OES 0x8B9D -#endif - - -#ifndef GL_PROGRAM_BINARY_LENGTH_OES -#define GL_PROGRAM_BINARY_LENGTH_OES 0x8741 -#endif - -/* GLES 2.0 tokens */ -#ifndef GL_RGB565 -#define GL_RGB565 0x8D62 -#endif - -#ifndef GL_TEXTURE_GEN_STR_OES -#define GL_TEXTURE_GEN_STR_OES 0x8D60 -#endif - -#ifndef GL_OES_compressed_paletted_texture -#define GL_PALETTE4_RGB8_OES 0x8B90 -#define GL_PALETTE4_RGBA8_OES 0x8B91 -#define GL_PALETTE4_R5_G6_B5_OES 0x8B92 -#define GL_PALETTE4_RGBA4_OES 0x8B93 -#define GL_PALETTE4_RGB5_A1_OES 0x8B94 -#define GL_PALETTE8_RGB8_OES 0x8B95 -#define GL_PALETTE8_RGBA8_OES 0x8B96 -#define GL_PALETTE8_R5_G6_B5_OES 0x8B97 -#define GL_PALETTE8_RGBA4_OES 0x8B98 -#define GL_PALETTE8_RGB5_A1_OES 0x8B99 -#endif - -#ifndef GL_OES_matrix_get -#define GL_MODELVIEW_MATRIX_FLOAT_AS_INT_BITS_OES 0x898D -#define GL_PROJECTION_MATRIX_FLOAT_AS_INT_BITS_OES 0x898E -#define GL_TEXTURE_MATRIX_FLOAT_AS_INT_BITS_OES 0x898F -#endif - -#ifndef GL_ES_VERSION_2_0 -#define GL_SHADER_BINARY_FORMATS 0x8DF8 -#define GL_NUM_SHADER_BINARY_FORMATS 0x8DF9 -#define GL_SHADER_COMPILER 0x8DFA -#define GL_MAX_VERTEX_UNIFORM_VECTORS 0x8DFB -#define GL_MAX_VARYING_VECTORS 0x8DFC -#define GL_MAX_FRAGMENT_UNIFORM_VECTORS 0x8DFD -#endif - - -/** - * Internal token to represent a GLSL shader program (a collection of - * one or more shaders that get linked together). Note that GLSL - * shaders and shader programs share one name space (one hash table) - * so we need a value that's different from any of the - * GL_VERTEX/FRAGMENT/GEOMETRY_PROGRAM tokens. - */ -#define GL_SHADER_PROGRAM_MESA 0x9999 - -/* Several fields of struct gl_config can take these as values. Since - * GLX header files may not be available everywhere they need to be used, - * redefine them here. - */ -#define GLX_NONE 0x8000 -#define GLX_SLOW_CONFIG 0x8001 -#define GLX_TRUE_COLOR 0x8002 -#define GLX_DIRECT_COLOR 0x8003 -#define GLX_PSEUDO_COLOR 0x8004 -#define GLX_STATIC_COLOR 0x8005 -#define GLX_GRAY_SCALE 0x8006 -#define GLX_STATIC_GRAY 0x8007 -#define GLX_TRANSPARENT_RGB 0x8008 -#define GLX_TRANSPARENT_INDEX 0x8009 -#define GLX_NON_CONFORMANT_CONFIG 0x800D -#define GLX_SWAP_EXCHANGE_OML 0x8061 -#define GLX_SWAP_COPY_OML 0x8062 -#define GLX_SWAP_UNDEFINED_OML 0x8063 - -#define GLX_DONT_CARE 0xFFFFFFFF - - -#ifdef __cplusplus -} -#endif - -#endif /* GLHEADER_H */ diff --git a/dll/opengl/mesa/main/hash.c b/dll/opengl/mesa/main/hash.c deleted file mode 100644 index 3d97fe24843..00000000000 --- a/dll/opengl/mesa/main/hash.c +++ /dev/null @@ -1,562 +0,0 @@ -/** - * \file hash.c - * Generic hash table. - * - * Used for display lists, texture objects, vertex/fragment programs, - * buffer objects, etc. The hash functions are thread-safe. - * - * \note key=0 is illegal. - * - * \author Brian Paul - */ - -/* - * Mesa 3-D graphics library - * Version: 6.5.1 - * - * Copyright (C) 1999-2006 Brian Paul All Rights Reserved. - * - * Permission is hereby granted, free of charge, to any person obtaining a - * copy of this software and associated documentation files (the "Software"), - * to deal in the Software without restriction, including without limitation - * the rights to use, copy, modify, merge, publish, distribute, sublicense, - * and/or sell copies of the Software, and to permit persons to whom the - * Software is furnished to do so, subject to the following conditions: - * - * The above copyright notice and this permission notice shall be included - * in all copies or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS - * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL - * BRIAN PAUL BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN - * AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN - * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. - */ - -#include - -#define TABLE_SIZE 1023 /**< Size of lookup table/array */ - -#define HASH_FUNC(K) ((K) % TABLE_SIZE) - - -/** - * An entry in the hash table. - */ -struct HashEntry { - GLuint Key; /**< the entry's key */ - void *Data; /**< the entry's data */ - struct HashEntry *Next; /**< pointer to next entry */ -}; - - -/** - * The hash table data structure. - */ -struct _mesa_HashTable { - struct HashEntry *Table[TABLE_SIZE]; /**< the lookup table */ - GLuint MaxKey; /**< highest key inserted so far */ - _glthread_Mutex Mutex; /**< mutual exclusion lock */ - _glthread_Mutex WalkMutex; /**< for _mesa_HashWalk() */ - GLboolean InDeleteAll; /**< Debug check */ -}; - - - -/** - * Create a new hash table. - * - * \return pointer to a new, empty hash table. - */ -struct _mesa_HashTable * -_mesa_NewHashTable(void) -{ - struct _mesa_HashTable *table = CALLOC_STRUCT(_mesa_HashTable); - if (table) { - _glthread_INIT_MUTEX(table->Mutex); - _glthread_INIT_MUTEX(table->WalkMutex); - } - return table; -} - - - -/** - * Delete a hash table. - * Frees each entry on the hash table and then the hash table structure itself. - * Note that the caller should have already traversed the table and deleted - * the objects in the table (i.e. We don't free the entries' data pointer). - * - * \param table the hash table to delete. - */ -void -_mesa_DeleteHashTable(struct _mesa_HashTable *table) -{ - GLuint pos; - assert(table); - for (pos = 0; pos < TABLE_SIZE; pos++) { - struct HashEntry *entry = table->Table[pos]; - while (entry) { - struct HashEntry *next = entry->Next; - if (entry->Data) { - _mesa_problem(NULL, - "In _mesa_DeleteHashTable, found non-freed data"); - } - free(entry); - entry = next; - } - } - _glthread_DESTROY_MUTEX(table->Mutex); - _glthread_DESTROY_MUTEX(table->WalkMutex); - free(table); -} - - - -/** - * Lookup an entry in the hash table, without locking. - * \sa _mesa_HashLookup - */ -static inline void * -_mesa_HashLookup_unlocked(struct _mesa_HashTable *table, GLuint key) -{ - GLuint pos; - const struct HashEntry *entry; - - assert(table); - assert(key); - - pos = HASH_FUNC(key); - entry = table->Table[pos]; - while (entry) { - if (entry->Key == key) { - return entry->Data; - } - entry = entry->Next; - } - return NULL; -} - - -/** - * Lookup an entry in the hash table. - * - * \param table the hash table. - * \param key the key. - * - * \return pointer to user's data or NULL if key not in table - */ -void * -_mesa_HashLookup(struct _mesa_HashTable *table, GLuint key) -{ - void *res; - assert(table); - _glthread_LOCK_MUTEX(table->Mutex); - res = _mesa_HashLookup_unlocked(table, key); - _glthread_UNLOCK_MUTEX(table->Mutex); - return res; -} - - -/** - * Insert a key/pointer pair into the hash table. - * If an entry with this key already exists we'll replace the existing entry. - * - * \param table the hash table. - * \param key the key (not zero). - * \param data pointer to user data. - */ -void -_mesa_HashInsert(struct _mesa_HashTable *table, GLuint key, void *data) -{ - /* search for existing entry with this key */ - GLuint pos; - struct HashEntry *entry; - - assert(table); - assert(key); - - _glthread_LOCK_MUTEX(table->Mutex); - - if (key > table->MaxKey) - table->MaxKey = key; - - pos = HASH_FUNC(key); - - /* check if replacing an existing entry with same key */ - for (entry = table->Table[pos]; entry; entry = entry->Next) { - if (entry->Key == key) { - /* replace entry's data */ -#if 0 /* not sure this check is always valid */ - if (entry->Data) { - _mesa_problem(NULL, "Memory leak detected in _mesa_HashInsert"); - } -#endif - entry->Data = data; - _glthread_UNLOCK_MUTEX(table->Mutex); - return; - } - } - - /* alloc and insert new table entry */ - entry = MALLOC_STRUCT(HashEntry); - if (entry) { - entry->Key = key; - entry->Data = data; - entry->Next = table->Table[pos]; - table->Table[pos] = entry; - } - - _glthread_UNLOCK_MUTEX(table->Mutex); -} - - - -/** - * Remove an entry from the hash table. - * - * \param table the hash table. - * \param key key of entry to remove. - * - * While holding the hash table's lock, searches the entry with the matching - * key and unlinks it. - */ -void -_mesa_HashRemove(struct _mesa_HashTable *table, GLuint key) -{ - GLuint pos; - struct HashEntry *entry, *prev; - - assert(table); - assert(key); - - /* have to check this outside of mutex lock */ - if (table->InDeleteAll) { - _mesa_problem(NULL, "_mesa_HashRemove illegally called from " - "_mesa_HashDeleteAll callback function"); - return; - } - - _glthread_LOCK_MUTEX(table->Mutex); - - pos = HASH_FUNC(key); - prev = NULL; - entry = table->Table[pos]; - while (entry) { - if (entry->Key == key) { - /* found it! */ - if (prev) { - prev->Next = entry->Next; - } - else { - table->Table[pos] = entry->Next; - } - free(entry); - _glthread_UNLOCK_MUTEX(table->Mutex); - return; - } - prev = entry; - entry = entry->Next; - } - - _glthread_UNLOCK_MUTEX(table->Mutex); -} - - - -/** - * Delete all entries in a hash table, but don't delete the table itself. - * Invoke the given callback function for each table entry. - * - * \param table the hash table to delete - * \param callback the callback function - * \param userData arbitrary pointer to pass along to the callback - * (this is typically a struct gl_context pointer) - */ -void -_mesa_HashDeleteAll(struct _mesa_HashTable *table, - void (*callback)(GLuint key, void *data, void *userData), - void *userData) -{ - GLuint pos; - ASSERT(table); - ASSERT(callback); - _glthread_LOCK_MUTEX(table->Mutex); - table->InDeleteAll = GL_TRUE; - for (pos = 0; pos < TABLE_SIZE; pos++) { - struct HashEntry *entry, *next; - for (entry = table->Table[pos]; entry; entry = next) { - callback(entry->Key, entry->Data, userData); - next = entry->Next; - free(entry); - } - table->Table[pos] = NULL; - } - table->InDeleteAll = GL_FALSE; - _glthread_UNLOCK_MUTEX(table->Mutex); -} - - -/** - * Walk over all entries in a hash table, calling callback function for each. - * Note: we use a separate mutex in this function to avoid a recursive - * locking deadlock (in case the callback calls _mesa_HashRemove()) and to - * prevent multiple threads/contexts from getting tangled up. - * A lock-less version of this function could be used when the table will - * not be modified. - * \param table the hash table to walk - * \param callback the callback function - * \param userData arbitrary pointer to pass along to the callback - * (this is typically a struct gl_context pointer) - */ -void -_mesa_HashWalk(const struct _mesa_HashTable *table, - void (*callback)(GLuint key, void *data, void *userData), - void *userData) -{ - /* cast-away const */ - struct _mesa_HashTable *table2 = (struct _mesa_HashTable *) table; - GLuint pos; - ASSERT(table); - ASSERT(callback); - _glthread_LOCK_MUTEX(table2->WalkMutex); - for (pos = 0; pos < TABLE_SIZE; pos++) { - struct HashEntry *entry, *next; - for (entry = table->Table[pos]; entry; entry = next) { - /* save 'next' pointer now in case the callback deletes the entry */ - next = entry->Next; - callback(entry->Key, entry->Data, userData); - } - } - _glthread_UNLOCK_MUTEX(table2->WalkMutex); -} - - -/** - * Return the key of the "first" entry in the hash table. - * While holding the lock, walks through all table positions until finding - * the first entry of the first non-empty one. - * - * \param table the hash table - * \return key for the "first" entry in the hash table. - */ -GLuint -_mesa_HashFirstEntry(struct _mesa_HashTable *table) -{ - GLuint pos; - assert(table); - _glthread_LOCK_MUTEX(table->Mutex); - for (pos = 0; pos < TABLE_SIZE; pos++) { - if (table->Table[pos]) { - _glthread_UNLOCK_MUTEX(table->Mutex); - return table->Table[pos]->Key; - } - } - _glthread_UNLOCK_MUTEX(table->Mutex); - return 0; -} - - -/** - * Given a hash table key, return the next key. This is used to walk - * over all entries in the table. Note that the keys returned during - * walking won't be in any particular order. - * \return next hash key or 0 if end of table. - */ -GLuint -_mesa_HashNextEntry(const struct _mesa_HashTable *table, GLuint key) -{ - const struct HashEntry *entry; - GLuint pos; - - assert(table); - assert(key); - - /* Find the entry with given key */ - pos = HASH_FUNC(key); - for (entry = table->Table[pos]; entry ; entry = entry->Next) { - if (entry->Key == key) { - break; - } - } - - if (!entry) { - /* the given key was not found, so we can't find the next entry */ - return 0; - } - - if (entry->Next) { - /* return next in linked list */ - return entry->Next->Key; - } - else { - /* look for next non-empty table slot */ - pos++; - while (pos < TABLE_SIZE) { - if (table->Table[pos]) { - return table->Table[pos]->Key; - } - pos++; - } - return 0; - } -} - - -/** - * Dump contents of hash table for debugging. - * - * \param table the hash table. - */ -void -_mesa_HashPrint(const struct _mesa_HashTable *table) -{ - GLuint pos; - assert(table); - for (pos = 0; pos < TABLE_SIZE; pos++) { - const struct HashEntry *entry = table->Table[pos]; - while (entry) { - _mesa_debug(NULL, "%u %p\n", entry->Key, entry->Data); - entry = entry->Next; - } - } -} - - - -/** - * Find a block of adjacent unused hash keys. - * - * \param table the hash table. - * \param numKeys number of keys needed. - * - * \return Starting key of free block or 0 if failure. - * - * If there are enough free keys between the maximum key existing in the table - * (_mesa_HashTable::MaxKey) and the maximum key possible, then simply return - * the adjacent key. Otherwise do a full search for a free key block in the - * allowable key range. - */ -GLuint -_mesa_HashFindFreeKeyBlock(struct _mesa_HashTable *table, GLuint numKeys) -{ - const GLuint maxKey = ~((GLuint) 0); - _glthread_LOCK_MUTEX(table->Mutex); - if (maxKey - numKeys > table->MaxKey) { - /* the quick solution */ - _glthread_UNLOCK_MUTEX(table->Mutex); - return table->MaxKey + 1; - } - else { - /* the slow solution */ - GLuint freeCount = 0; - GLuint freeStart = 1; - GLuint key; - for (key = 1; key != maxKey; key++) { - if (_mesa_HashLookup_unlocked(table, key)) { - /* darn, this key is already in use */ - freeCount = 0; - freeStart = key+1; - } - else { - /* this key not in use, check if we've found enough */ - freeCount++; - if (freeCount == numKeys) { - _glthread_UNLOCK_MUTEX(table->Mutex); - return freeStart; - } - } - } - /* cannot allocate a block of numKeys consecutive keys */ - _glthread_UNLOCK_MUTEX(table->Mutex); - return 0; - } -} - - -/** - * Return the number of entries in the hash table. - */ -GLuint -_mesa_HashNumEntries(const struct _mesa_HashTable *table) -{ - GLuint pos, count = 0; - - for (pos = 0; pos < TABLE_SIZE; pos++) { - const struct HashEntry *entry; - for (entry = table->Table[pos]; entry; entry = entry->Next) { - count++; - } - } - - return count; -} - - - -#if 0 /* debug only */ - -/** - * Test walking over all the entries in a hash table. - */ -static void -test_hash_walking(void) -{ - struct _mesa_HashTable *t = _mesa_NewHashTable(); - const GLuint limit = 50000; - GLuint i; - - /* create some entries */ - for (i = 0; i < limit; i++) { - GLuint dummy; - GLuint k = (rand() % (limit * 10)) + 1; - while (_mesa_HashLookup(t, k)) { - /* id already in use, try another */ - k = (rand() % (limit * 10)) + 1; - } - _mesa_HashInsert(t, k, &dummy); - } - - /* walk over all entries */ - { - GLuint k = _mesa_HashFirstEntry(t); - GLuint count = 0; - while (k) { - GLuint knext = _mesa_HashNextEntry(t, k); - assert(knext != k); - _mesa_HashRemove(t, k); - count++; - k = knext; - } - assert(count == limit); - k = _mesa_HashFirstEntry(t); - assert(k==0); - } - - _mesa_DeleteHashTable(t); -} - - -void -_mesa_test_hash_functions(void) -{ - int a, b, c; - struct _mesa_HashTable *t; - - t = _mesa_NewHashTable(); - _mesa_HashInsert(t, 501, &a); - _mesa_HashInsert(t, 10, &c); - _mesa_HashInsert(t, 0xfffffff8, &b); - /*_mesa_HashPrint(t);*/ - - assert(_mesa_HashLookup(t,501)); - assert(!_mesa_HashLookup(t,1313)); - assert(_mesa_HashFindFreeKeyBlock(t, 100)); - - _mesa_DeleteHashTable(t); - - test_hash_walking(); -} - -#endif diff --git a/dll/opengl/mesa/main/hash.h b/dll/opengl/mesa/main/hash.h deleted file mode 100644 index e935f8d3984..00000000000 --- a/dll/opengl/mesa/main/hash.h +++ /dev/null @@ -1,72 +0,0 @@ -/** - * \file hash.h - * Generic hash table. - */ - -/* - * Mesa 3-D graphics library - * Version: 6.5.1 - * - * Copyright (C) 1999-2006 Brian Paul All Rights Reserved. - * - * Permission is hereby granted, free of charge, to any person obtaining a - * copy of this software and associated documentation files (the "Software"), - * to deal in the Software without restriction, including without limitation - * the rights to use, copy, modify, merge, publish, distribute, sublicense, - * and/or sell copies of the Software, and to permit persons to whom the - * Software is furnished to do so, subject to the following conditions: - * - * The above copyright notice and this permission notice shall be included - * in all copies or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS - * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL - * BRIAN PAUL BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN - * AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN - * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. - */ - - -#ifndef HASH_H -#define HASH_H - - -#include "glheader.h" - - -extern struct _mesa_HashTable *_mesa_NewHashTable(void); - -extern void _mesa_DeleteHashTable(struct _mesa_HashTable *table); - -extern void *_mesa_HashLookup(struct _mesa_HashTable *table, GLuint key); - -extern void _mesa_HashInsert(struct _mesa_HashTable *table, GLuint key, void *data); - -extern void _mesa_HashRemove(struct _mesa_HashTable *table, GLuint key); - -extern void -_mesa_HashDeleteAll(struct _mesa_HashTable *table, - void (*callback)(GLuint key, void *data, void *userData), - void *userData); - -extern void -_mesa_HashWalk(const struct _mesa_HashTable *table, - void (*callback)(GLuint key, void *data, void *userData), - void *userData); - -extern GLuint _mesa_HashFirstEntry(struct _mesa_HashTable *table); - -extern GLuint _mesa_HashNextEntry(const struct _mesa_HashTable *table, GLuint key); - -extern void _mesa_HashPrint(const struct _mesa_HashTable *table); - -extern GLuint _mesa_HashFindFreeKeyBlock(struct _mesa_HashTable *table, GLuint numKeys); - -extern GLuint -_mesa_HashNumEntries(const struct _mesa_HashTable *table); - -extern void _mesa_test_hash_functions(void); - - -#endif diff --git a/dll/opengl/mesa/main/hint.c b/dll/opengl/mesa/main/hint.c deleted file mode 100644 index af204c94124..00000000000 --- a/dll/opengl/mesa/main/hint.c +++ /dev/null @@ -1,108 +0,0 @@ - -/* - * Mesa 3-D graphics library - * Version: 4.1 - * - * Copyright (C) 1999-2002 Brian Paul All Rights Reserved. - * - * Permission is hereby granted, free of charge, to any person obtaining a - * copy of this software and associated documentation files (the "Software"), - * to deal in the Software without restriction, including without limitation - * the rights to use, copy, modify, merge, publish, distribute, sublicense, - * and/or sell copies of the Software, and to permit persons to whom the - * Software is furnished to do so, subject to the following conditions: - * - * The above copyright notice and this permission notice shall be included - * in all copies or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS - * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL - * BRIAN PAUL BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN - * AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN - * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. - */ - -#include - -void GLAPIENTRY -_mesa_Hint( GLenum target, GLenum mode ) -{ - GET_CURRENT_CONTEXT(ctx); - ASSERT_OUTSIDE_BEGIN_END(ctx); - - if (MESA_VERBOSE & VERBOSE_API) - _mesa_debug(ctx, "glHint %s %s\n", - _mesa_lookup_enum_by_nr(target), - _mesa_lookup_enum_by_nr(mode)); - - if (mode != GL_NICEST && mode != GL_FASTEST && mode != GL_DONT_CARE) { - _mesa_error(ctx, GL_INVALID_ENUM, "glHint(mode)"); - return; - } - - switch (target) { - case GL_FOG_HINT: - if (ctx->Hint.Fog == mode) - return; - FLUSH_VERTICES(ctx, _NEW_HINT); - ctx->Hint.Fog = mode; - break; - case GL_LINE_SMOOTH_HINT: - if (ctx->Hint.LineSmooth == mode) - return; - FLUSH_VERTICES(ctx, _NEW_HINT); - ctx->Hint.LineSmooth = mode; - break; - case GL_PERSPECTIVE_CORRECTION_HINT: - if (ctx->Hint.PerspectiveCorrection == mode) - return; - FLUSH_VERTICES(ctx, _NEW_HINT); - ctx->Hint.PerspectiveCorrection = mode; - break; - case GL_POINT_SMOOTH_HINT: - if (ctx->Hint.PointSmooth == mode) - return; - FLUSH_VERTICES(ctx, _NEW_HINT); - ctx->Hint.PointSmooth = mode; - break; - case GL_POLYGON_SMOOTH_HINT: - if (ctx->Hint.PolygonSmooth == mode) - return; - FLUSH_VERTICES(ctx, _NEW_HINT); - ctx->Hint.PolygonSmooth = mode; - break; - - /* GL_EXT_clip_volume_hint */ - case GL_CLIP_VOLUME_CLIPPING_HINT_EXT: - if (ctx->Hint.ClipVolumeClipping == mode) - return; - FLUSH_VERTICES(ctx, _NEW_HINT); - ctx->Hint.ClipVolumeClipping = mode; - break; - - default: - _mesa_error(ctx, GL_INVALID_ENUM, "glHint(target)"); - return; - } - - if (ctx->Driver.Hint) { - (*ctx->Driver.Hint)( ctx, target, mode ); - } -} - - -/**********************************************************************/ -/***** Initialization *****/ -/**********************************************************************/ - -void _mesa_init_hint( struct gl_context * ctx ) -{ - /* Hint group */ - ctx->Hint.PerspectiveCorrection = GL_DONT_CARE; - ctx->Hint.PointSmooth = GL_DONT_CARE; - ctx->Hint.LineSmooth = GL_DONT_CARE; - ctx->Hint.PolygonSmooth = GL_DONT_CARE; - ctx->Hint.Fog = GL_DONT_CARE; - ctx->Hint.ClipVolumeClipping = GL_DONT_CARE; -} diff --git a/dll/opengl/mesa/main/hint.h b/dll/opengl/mesa/main/hint.h deleted file mode 100644 index 6c62068743a..00000000000 --- a/dll/opengl/mesa/main/hint.h +++ /dev/null @@ -1,59 +0,0 @@ -/** - * \file hint.h - * Hints operations. - * - * \if subset - * (No-op) - * - * \endif - */ - -/* - * Mesa 3-D graphics library - * Version: 4.1 - * - * Copyright (C) 1999-2002 Brian Paul All Rights Reserved. - * - * Permission is hereby granted, free of charge, to any person obtaining a - * copy of this software and associated documentation files (the "Software"), - * to deal in the Software without restriction, including without limitation - * the rights to use, copy, modify, merge, publish, distribute, sublicense, - * and/or sell copies of the Software, and to permit persons to whom the - * Software is furnished to do so, subject to the following conditions: - * - * The above copyright notice and this permission notice shall be included - * in all copies or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS - * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL - * BRIAN PAUL BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN - * AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN - * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. - */ - - -#ifndef HINT_H -#define HINT_H - -#include "glheader.h" -#include "mfeatures.h" - -struct gl_context; - -#if _HAVE_FULL_GL - -extern void GLAPIENTRY -_mesa_Hint( GLenum target, GLenum mode ); - -extern void -_mesa_init_hint( struct gl_context * ctx ); - -#else - -/** No-op */ -#define _mesa_init_hint( c ) ((void) 0) - -#endif - -#endif diff --git a/dll/opengl/mesa/main/image.c b/dll/opengl/mesa/main/image.c deleted file mode 100644 index 820323b4dd3..00000000000 --- a/dll/opengl/mesa/main/image.c +++ /dev/null @@ -1,1805 +0,0 @@ -/* - * Mesa 3-D graphics library - * Version: 7.5 - * - * Copyright (C) 1999-2008 Brian Paul All Rights Reserved. - * Copyright (C) 2009 VMware, Inc. All Rights Reserved. - * - * Permission is hereby granted, free of charge, to any person obtaining a - * copy of this software and associated documentation files (the "Software"), - * to deal in the Software without restriction, including without limitation - * the rights to use, copy, modify, merge, publish, distribute, sublicense, - * and/or sell copies of the Software, and to permit persons to whom the - * Software is furnished to do so, subject to the following conditions: - * - * The above copyright notice and this permission notice shall be included - * in all copies or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS - * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL - * BRIAN PAUL BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN - * AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN - * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. - */ - -/** - * \file image.c - * Image handling. - */ - -#include - -/** - * \return GL_TRUE if type is packed pixel type, GL_FALSE otherwise. - */ -GLboolean -_mesa_type_is_packed(GLenum type) -{ - switch (type) { - case GL_UNSIGNED_BYTE_3_3_2: - case GL_UNSIGNED_BYTE_2_3_3_REV: - case MESA_UNSIGNED_BYTE_4_4: - case GL_UNSIGNED_SHORT_5_6_5: - case GL_UNSIGNED_SHORT_5_6_5_REV: - case GL_UNSIGNED_SHORT_4_4_4_4: - case GL_UNSIGNED_SHORT_4_4_4_4_REV: - case GL_UNSIGNED_SHORT_5_5_5_1: - case GL_UNSIGNED_SHORT_1_5_5_5_REV: - case GL_UNSIGNED_INT_8_8_8_8: - case GL_UNSIGNED_INT_8_8_8_8_REV: - case GL_UNSIGNED_SHORT_8_8_MESA: - case GL_UNSIGNED_SHORT_8_8_REV_MESA: - case GL_UNSIGNED_INT_5_9_9_9_REV: - case GL_UNSIGNED_INT_10F_11F_11F_REV: - return GL_TRUE; - } - - return GL_FALSE; -} - - - -/** - * Flip the order of the 2 bytes in each word in the given array. - * - * \param p array. - * \param n number of words. - */ -void -_mesa_swap2( GLushort *p, GLuint n ) -{ - GLuint i; - for (i = 0; i < n; i++) { - p[i] = (p[i] >> 8) | ((p[i] << 8) & 0xff00); - } -} - - - -/* - * Flip the order of the 4 bytes in each word in the given array. - */ -void -_mesa_swap4( GLuint *p, GLuint n ) -{ - GLuint i, a, b; - for (i = 0; i < n; i++) { - b = p[i]; - a = (b >> 24) - | ((b >> 8) & 0xff00) - | ((b << 8) & 0xff0000) - | ((b << 24) & 0xff000000); - p[i] = a; - } -} - - -/** - * Get the size of a GL data type. - * - * \param type GL data type. - * - * \return the size, in bytes, of the given data type, 0 if a GL_BITMAP, or -1 - * if an invalid type enum. - */ -GLint -_mesa_sizeof_type( GLenum type ) -{ - switch (type) { - case GL_BITMAP: - return 0; - case GL_UNSIGNED_BYTE: - return sizeof(GLubyte); - case GL_BYTE: - return sizeof(GLbyte); - case GL_UNSIGNED_SHORT: - return sizeof(GLushort); - case GL_SHORT: - return sizeof(GLshort); - case GL_UNSIGNED_INT: - return sizeof(GLuint); - case GL_INT: - return sizeof(GLint); - case GL_FLOAT: - return sizeof(GLfloat); - case GL_DOUBLE: - return sizeof(GLdouble); - case GL_FIXED: - return sizeof(GLfixed); - default: - return -1; - } -} - - -/** - * Same as _mesa_sizeof_type() but also accepting the packed pixel - * format data types. - */ -GLint -_mesa_sizeof_packed_type( GLenum type ) -{ - switch (type) { - case GL_BITMAP: - return 0; - case GL_UNSIGNED_BYTE: - return sizeof(GLubyte); - case GL_BYTE: - return sizeof(GLbyte); - case GL_UNSIGNED_SHORT: - return sizeof(GLushort); - case GL_SHORT: - return sizeof(GLshort); - case GL_UNSIGNED_INT: - return sizeof(GLuint); - case GL_INT: - return sizeof(GLint); - case GL_FLOAT: - return sizeof(GLfloat); - case GL_UNSIGNED_BYTE_3_3_2: - case GL_UNSIGNED_BYTE_2_3_3_REV: - case MESA_UNSIGNED_BYTE_4_4: - return sizeof(GLubyte); - case GL_UNSIGNED_SHORT_5_6_5: - case GL_UNSIGNED_SHORT_5_6_5_REV: - case GL_UNSIGNED_SHORT_4_4_4_4: - case GL_UNSIGNED_SHORT_4_4_4_4_REV: - case GL_UNSIGNED_SHORT_5_5_5_1: - case GL_UNSIGNED_SHORT_1_5_5_5_REV: - case GL_UNSIGNED_SHORT_8_8_MESA: - case GL_UNSIGNED_SHORT_8_8_REV_MESA: - return sizeof(GLushort); - case GL_UNSIGNED_INT_8_8_8_8: - case GL_UNSIGNED_INT_8_8_8_8_REV: - case GL_UNSIGNED_INT_5_9_9_9_REV: - case GL_UNSIGNED_INT_10F_11F_11F_REV: - return sizeof(GLuint); - default: - return -1; - } -} - - -/** - * Get the number of components in a pixel format. - * - * \param format pixel format. - * - * \return the number of components in the given format, or -1 if a bad format. - */ -GLint -_mesa_components_in_format( GLenum format ) -{ - switch (format) { - case GL_COLOR_INDEX: - case GL_STENCIL_INDEX: - case GL_DEPTH_COMPONENT: - case GL_RED: - case GL_RED_INTEGER_EXT: - case GL_GREEN: - case GL_GREEN_INTEGER_EXT: - case GL_BLUE: - case GL_BLUE_INTEGER_EXT: - case GL_ALPHA: - case GL_ALPHA_INTEGER_EXT: - case GL_LUMINANCE: - case GL_LUMINANCE_INTEGER_EXT: - case GL_INTENSITY: - return 1; - - case GL_LUMINANCE_ALPHA: - case GL_LUMINANCE_ALPHA_INTEGER_EXT: - case GL_RG: - case GL_YCBCR_MESA: - case GL_RG_INTEGER: - return 2; - - case GL_RGB: - case GL_BGR: - case GL_RGB_INTEGER_EXT: - case GL_BGR_INTEGER_EXT: - return 3; - - case GL_RGBA: - case GL_BGRA: - case GL_ABGR_EXT: - case GL_RGBA_INTEGER_EXT: - case GL_BGRA_INTEGER_EXT: - return 4; - - default: - return -1; - } -} - - -/** - * Get the bytes per pixel of pixel format type pair. - * - * \param format pixel format. - * \param type pixel type. - * - * \return bytes per pixel, or -1 if a bad format or type was given. - */ -GLint -_mesa_bytes_per_pixel( GLenum format, GLenum type ) -{ - GLint comps = _mesa_components_in_format( format ); - if (comps < 0) - return -1; - - switch (type) { - case GL_BITMAP: - return 0; /* special case */ - case GL_BYTE: - case GL_UNSIGNED_BYTE: - return comps * sizeof(GLubyte); - case GL_SHORT: - case GL_UNSIGNED_SHORT: - return comps * sizeof(GLshort); - case GL_INT: - case GL_UNSIGNED_INT: - return comps * sizeof(GLint); - case GL_FLOAT: - return comps * sizeof(GLfloat); - case GL_UNSIGNED_BYTE_3_3_2: - case GL_UNSIGNED_BYTE_2_3_3_REV: - if (format == GL_RGB || format == GL_BGR || - format == GL_RGB_INTEGER_EXT || format == GL_BGR_INTEGER_EXT) - return sizeof(GLubyte); - else - return -1; /* error */ - case GL_UNSIGNED_SHORT_5_6_5: - case GL_UNSIGNED_SHORT_5_6_5_REV: - if (format == GL_RGB || format == GL_BGR || - format == GL_RGB_INTEGER_EXT || format == GL_BGR_INTEGER_EXT) - return sizeof(GLushort); - else - return -1; /* error */ - case GL_UNSIGNED_SHORT_4_4_4_4: - case GL_UNSIGNED_SHORT_4_4_4_4_REV: - case GL_UNSIGNED_SHORT_5_5_5_1: - case GL_UNSIGNED_SHORT_1_5_5_5_REV: - if (format == GL_RGBA || format == GL_BGRA || format == GL_ABGR_EXT || - format == GL_RGBA_INTEGER_EXT || format == GL_BGRA_INTEGER_EXT) - return sizeof(GLushort); - else - return -1; - case GL_UNSIGNED_INT_8_8_8_8: - case GL_UNSIGNED_INT_8_8_8_8_REV: - if (format == GL_RGBA || format == GL_BGRA || format == GL_ABGR_EXT || - format == GL_RGBA_INTEGER_EXT || format == GL_BGRA_INTEGER_EXT) - return sizeof(GLuint); - else - return -1; - case GL_UNSIGNED_SHORT_8_8_MESA: - case GL_UNSIGNED_SHORT_8_8_REV_MESA: - if (format == GL_YCBCR_MESA) - return sizeof(GLushort); - else - return -1; - case GL_UNSIGNED_INT_5_9_9_9_REV: - if (format == GL_RGB) - return sizeof(GLuint); - else - return -1; - case GL_UNSIGNED_INT_10F_11F_11F_REV: - if (format == GL_RGB) - return sizeof(GLuint); - else - return -1; - default: - return -1; - } -} - - -/** - * Do error checking of format/type combinations for glReadPixels, - * glDrawPixels and glTex[Sub]Image. Note that depending on the format - * and type values, we may either generate GL_INVALID_OPERATION or - * GL_INVALID_ENUM. - * - * \param format pixel format. - * \param type pixel type. - * - * \return GL_INVALID_ENUM, GL_INVALID_OPERATION or GL_NO_ERROR - */ -GLenum -_mesa_error_check_format_and_type(const struct gl_context *ctx, - GLenum format, GLenum type) -{ - /* special type-based checks (see glReadPixels, glDrawPixels error lists) */ - switch (type) { - case GL_BITMAP: - if (format != GL_COLOR_INDEX && format != GL_STENCIL_INDEX) { - return GL_INVALID_ENUM; - } - break; - - case GL_UNSIGNED_BYTE_3_3_2: - case GL_UNSIGNED_BYTE_2_3_3_REV: - case GL_UNSIGNED_SHORT_5_6_5: - case GL_UNSIGNED_SHORT_5_6_5_REV: - if (format == GL_RGB) { - break; /* OK */ - } - return GL_INVALID_OPERATION; - - case GL_UNSIGNED_SHORT_4_4_4_4: - case GL_UNSIGNED_SHORT_4_4_4_4_REV: - case GL_UNSIGNED_SHORT_5_5_5_1: - case GL_UNSIGNED_SHORT_1_5_5_5_REV: - case GL_UNSIGNED_INT_8_8_8_8: - case GL_UNSIGNED_INT_8_8_8_8_REV: - if (format == GL_RGBA || - format == GL_BGRA || - format == GL_ABGR_EXT) { - break; /* OK */ - } - return GL_INVALID_OPERATION; - - default: - ; /* fall-through */ - } - - /* now, for each format, check the type for compatibility */ - switch (format) { - case GL_COLOR_INDEX: - case GL_STENCIL_INDEX: - switch (type) { - case GL_BITMAP: - case GL_BYTE: - case GL_UNSIGNED_BYTE: - case GL_SHORT: - case GL_UNSIGNED_SHORT: - case GL_INT: - case GL_UNSIGNED_INT: - case GL_FLOAT: - return GL_NO_ERROR; - default: - return GL_INVALID_ENUM; - } - - case GL_RED: - case GL_GREEN: - case GL_BLUE: - case GL_ALPHA: -#if 0 /* not legal! see table 3.6 of the 1.5 spec */ - case GL_INTENSITY: -#endif - case GL_LUMINANCE: - case GL_LUMINANCE_ALPHA: - case GL_DEPTH_COMPONENT: - switch (type) { - case GL_BYTE: - case GL_UNSIGNED_BYTE: - case GL_SHORT: - case GL_UNSIGNED_SHORT: - case GL_INT: - case GL_UNSIGNED_INT: - case GL_FLOAT: - return GL_NO_ERROR; - default: - return GL_INVALID_ENUM; - } - - case GL_RGB: - switch (type) { - case GL_BYTE: - case GL_UNSIGNED_BYTE: - case GL_SHORT: - case GL_UNSIGNED_SHORT: - case GL_INT: - case GL_UNSIGNED_INT: - case GL_FLOAT: - case GL_UNSIGNED_BYTE_3_3_2: - case GL_UNSIGNED_BYTE_2_3_3_REV: - case GL_UNSIGNED_SHORT_5_6_5: - case GL_UNSIGNED_SHORT_5_6_5_REV: - return GL_NO_ERROR; - default: - return GL_INVALID_ENUM; - } - - case GL_BGR: - switch (type) { - /* NOTE: no packed types are supported with BGR. That's - * intentional, according to the GL spec. - */ - case GL_BYTE: - case GL_UNSIGNED_BYTE: - case GL_SHORT: - case GL_UNSIGNED_SHORT: - case GL_INT: - case GL_UNSIGNED_INT: - case GL_FLOAT: - return GL_NO_ERROR; - default: - return GL_INVALID_ENUM; - } - - case GL_RGBA: - case GL_BGRA: - case GL_ABGR_EXT: - switch (type) { - case GL_BYTE: - case GL_UNSIGNED_BYTE: - case GL_SHORT: - case GL_UNSIGNED_SHORT: - case GL_INT: - case GL_UNSIGNED_INT: - case GL_FLOAT: - case GL_UNSIGNED_SHORT_4_4_4_4: - case GL_UNSIGNED_SHORT_4_4_4_4_REV: - case GL_UNSIGNED_SHORT_5_5_5_1: - case GL_UNSIGNED_SHORT_1_5_5_5_REV: - case GL_UNSIGNED_INT_8_8_8_8: - case GL_UNSIGNED_INT_8_8_8_8_REV: - return GL_NO_ERROR; - default: - return GL_INVALID_ENUM; - } - - case GL_YCBCR_MESA: - if (!ctx->Extensions.MESA_ycbcr_texture) - return GL_INVALID_ENUM; - if (type == GL_UNSIGNED_SHORT_8_8_MESA || - type == GL_UNSIGNED_SHORT_8_8_REV_MESA) - return GL_NO_ERROR; - else - return GL_INVALID_OPERATION; - - /* integer-valued formats */ - case GL_RED_INTEGER_EXT: - case GL_GREEN_INTEGER_EXT: - case GL_BLUE_INTEGER_EXT: - case GL_ALPHA_INTEGER_EXT: - case GL_RG_INTEGER: - switch (type) { - case GL_BYTE: - case GL_UNSIGNED_BYTE: - case GL_SHORT: - case GL_UNSIGNED_SHORT: - case GL_INT: - case GL_UNSIGNED_INT: - return (ctx->VersionMajor >= 3 || - ctx->Extensions.EXT_texture_integer) - ? GL_NO_ERROR : GL_INVALID_ENUM; - default: - return GL_INVALID_ENUM; - } - - case GL_RGB_INTEGER_EXT: - switch (type) { - case GL_BYTE: - case GL_UNSIGNED_BYTE: - case GL_SHORT: - case GL_UNSIGNED_SHORT: - case GL_INT: - case GL_UNSIGNED_INT: - return (ctx->VersionMajor >= 3 || - ctx->Extensions.EXT_texture_integer) - ? GL_NO_ERROR : GL_INVALID_ENUM; - default: - return GL_INVALID_ENUM; - } - - case GL_BGR_INTEGER_EXT: - switch (type) { - case GL_BYTE: - case GL_UNSIGNED_BYTE: - case GL_SHORT: - case GL_UNSIGNED_SHORT: - case GL_INT: - case GL_UNSIGNED_INT: - /* NOTE: no packed formats w/ BGR format */ - return (ctx->VersionMajor >= 3 || - ctx->Extensions.EXT_texture_integer) - ? GL_NO_ERROR : GL_INVALID_ENUM; - default: - return GL_INVALID_ENUM; - } - - case GL_RGBA_INTEGER_EXT: - case GL_BGRA_INTEGER_EXT: - switch (type) { - case GL_BYTE: - case GL_UNSIGNED_BYTE: - case GL_SHORT: - case GL_UNSIGNED_SHORT: - case GL_INT: - case GL_UNSIGNED_INT: - return (ctx->VersionMajor >= 3 || - ctx->Extensions.EXT_texture_integer) - ? GL_NO_ERROR : GL_INVALID_ENUM; - default: - return GL_INVALID_ENUM; - } - - case GL_LUMINANCE_INTEGER_EXT: - case GL_LUMINANCE_ALPHA_INTEGER_EXT: - switch (type) { - case GL_BYTE: - case GL_UNSIGNED_BYTE: - case GL_SHORT: - case GL_UNSIGNED_SHORT: - case GL_INT: - case GL_UNSIGNED_INT: - return ctx->Extensions.EXT_texture_integer - ? GL_NO_ERROR : GL_INVALID_ENUM; - default: - return GL_INVALID_ENUM; - } - - default: - return GL_INVALID_ENUM; - } - return GL_NO_ERROR; -} - - -/** - * Test if the given image format is a color/RGBA format (i.e., not color - * index, depth, stencil, etc). - * \param format the image format value (may by an internal texture format) - * \return GL_TRUE if its a color/RGBA format, GL_FALSE otherwise. - */ -GLboolean -_mesa_is_color_format(GLenum format) -{ - switch (format) { - case GL_RED: - case GL_GREEN: - case GL_BLUE: - case GL_ALPHA: - case GL_ALPHA4: - case GL_ALPHA8: - case GL_ALPHA12: - case GL_ALPHA16: - case 1: - case GL_LUMINANCE: - case GL_LUMINANCE4: - case GL_LUMINANCE8: - case GL_LUMINANCE12: - case GL_LUMINANCE16: - case 2: - case GL_LUMINANCE_ALPHA: - case GL_LUMINANCE4_ALPHA4: - case GL_LUMINANCE6_ALPHA2: - case GL_LUMINANCE8_ALPHA8: - case GL_LUMINANCE12_ALPHA4: - case GL_LUMINANCE12_ALPHA12: - case GL_LUMINANCE16_ALPHA16: - case GL_INTENSITY: - case GL_INTENSITY4: - case GL_INTENSITY8: - case GL_INTENSITY12: - case GL_INTENSITY16: - case GL_R8: - case GL_R16: - case GL_RG: - case GL_RG8: - case GL_RG16: - case 3: - case GL_RGB: - case GL_BGR: - case GL_R3_G3_B2: - case GL_RGB4: - case GL_RGB5: - case GL_RGB8: - case GL_RGB10: - case GL_RGB12: - case GL_RGB16: - case 4: - case GL_ABGR_EXT: - case GL_RGBA: - case GL_BGRA: - case GL_RGBA2: - case GL_RGBA4: - case GL_RGB5_A1: - case GL_RGBA8: - case GL_RGB10_A2: - case GL_RGBA12: - case GL_RGBA16: - /* float texture formats */ - case GL_ALPHA16F_ARB: - case GL_ALPHA32F_ARB: - case GL_LUMINANCE16F_ARB: - case GL_LUMINANCE32F_ARB: - case GL_LUMINANCE_ALPHA16F_ARB: - case GL_LUMINANCE_ALPHA32F_ARB: - case GL_INTENSITY16F_ARB: - case GL_INTENSITY32F_ARB: - case GL_R16F: - case GL_R32F: - case GL_RG16F: - case GL_RG32F: - case GL_RGB16F_ARB: - case GL_RGB32F_ARB: - case GL_RGBA16F_ARB: - case GL_RGBA32F_ARB: - /* generic integer formats */ - case GL_RED_INTEGER_EXT: - case GL_GREEN_INTEGER_EXT: - case GL_BLUE_INTEGER_EXT: - case GL_ALPHA_INTEGER_EXT: - case GL_RGB_INTEGER_EXT: - case GL_RGBA_INTEGER_EXT: - case GL_BGR_INTEGER_EXT: - case GL_BGRA_INTEGER_EXT: - case GL_LUMINANCE_INTEGER_EXT: - case GL_LUMINANCE_ALPHA_INTEGER_EXT: - /* sized integer formats */ - case GL_RGBA32UI_EXT: - case GL_RGB32UI_EXT: - case GL_ALPHA32UI_EXT: - case GL_INTENSITY32UI_EXT: - case GL_LUMINANCE32UI_EXT: - case GL_LUMINANCE_ALPHA32UI_EXT: - case GL_RGBA16UI_EXT: - case GL_RGB16UI_EXT: - case GL_ALPHA16UI_EXT: - case GL_INTENSITY16UI_EXT: - case GL_LUMINANCE16UI_EXT: - case GL_LUMINANCE_ALPHA16UI_EXT: - case GL_RGBA8UI_EXT: - case GL_RGB8UI_EXT: - case GL_ALPHA8UI_EXT: - case GL_INTENSITY8UI_EXT: - case GL_LUMINANCE8UI_EXT: - case GL_LUMINANCE_ALPHA8UI_EXT: - case GL_RGBA32I_EXT: - case GL_RGB32I_EXT: - case GL_ALPHA32I_EXT: - case GL_INTENSITY32I_EXT: - case GL_LUMINANCE32I_EXT: - case GL_LUMINANCE_ALPHA32I_EXT: - case GL_RGBA16I_EXT: - case GL_RGB16I_EXT: - case GL_ALPHA16I_EXT: - case GL_INTENSITY16I_EXT: - case GL_LUMINANCE16I_EXT: - case GL_LUMINANCE_ALPHA16I_EXT: - case GL_RGBA8I_EXT: - case GL_RGB8I_EXT: - case GL_ALPHA8I_EXT: - case GL_INTENSITY8I_EXT: - case GL_LUMINANCE8I_EXT: - case GL_LUMINANCE_ALPHA8I_EXT: - case GL_R11F_G11F_B10F: - case GL_RGB10_A2UI: - return GL_TRUE; - case GL_YCBCR_MESA: /* not considered to be RGB */ - /* fall-through */ - default: - return GL_FALSE; - } -} - - -/** - * Test if the given image format is a depth component format. - */ -GLboolean -_mesa_is_depth_format(GLenum format) -{ - switch (format) { - case GL_DEPTH_COMPONENT: - case GL_DEPTH_COMPONENT16: - case GL_DEPTH_COMPONENT24: - case GL_DEPTH_COMPONENT32: - return GL_TRUE; - default: - return GL_FALSE; - } -} - - -/** - * Test if the given image format is a stencil format. - */ -GLboolean -_mesa_is_stencil_format(GLenum format) -{ - switch (format) { - case GL_STENCIL_INDEX: - return GL_TRUE; - default: - return GL_FALSE; - } -} - - -/** - * Test if the given image format is a YCbCr format. - */ -GLboolean -_mesa_is_ycbcr_format(GLenum format) -{ - switch (format) { - case GL_YCBCR_MESA: - return GL_TRUE; - default: - return GL_FALSE; - } -} - - -/** - * Test if the given image format is a depth or stencil format. - */ -GLboolean -_mesa_is_depth_or_stencil_format(GLenum format) -{ - switch (format) { - case GL_DEPTH_COMPONENT: - case GL_DEPTH_COMPONENT16: - case GL_DEPTH_COMPONENT24: - case GL_DEPTH_COMPONENT32: - case GL_STENCIL_INDEX: - case GL_STENCIL_INDEX1_EXT: - case GL_STENCIL_INDEX4_EXT: - case GL_STENCIL_INDEX8_EXT: - case GL_STENCIL_INDEX16_EXT: - return GL_TRUE; - default: - return GL_FALSE; - } -} - - -/** - * Test if the given format is an integer (non-normalized) format. - */ -GLboolean -_mesa_is_integer_format(GLenum format) -{ - switch (format) { - /* generic integer formats */ - case GL_RED_INTEGER_EXT: - case GL_GREEN_INTEGER_EXT: - case GL_BLUE_INTEGER_EXT: - case GL_ALPHA_INTEGER_EXT: - case GL_RGB_INTEGER_EXT: - case GL_RGBA_INTEGER_EXT: - case GL_BGR_INTEGER_EXT: - case GL_BGRA_INTEGER_EXT: - case GL_LUMINANCE_INTEGER_EXT: - case GL_LUMINANCE_ALPHA_INTEGER_EXT: - case GL_RG_INTEGER: - /* specific integer formats */ - case GL_RGBA32UI_EXT: - case GL_RGB32UI_EXT: - case GL_RG32UI: - case GL_R32UI: - case GL_ALPHA32UI_EXT: - case GL_INTENSITY32UI_EXT: - case GL_LUMINANCE32UI_EXT: - case GL_LUMINANCE_ALPHA32UI_EXT: - case GL_RGBA16UI_EXT: - case GL_RGB16UI_EXT: - case GL_RG16UI: - case GL_R16UI: - case GL_ALPHA16UI_EXT: - case GL_INTENSITY16UI_EXT: - case GL_LUMINANCE16UI_EXT: - case GL_LUMINANCE_ALPHA16UI_EXT: - case GL_RGBA8UI_EXT: - case GL_RGB8UI_EXT: - case GL_RG8UI: - case GL_R8UI: - case GL_ALPHA8UI_EXT: - case GL_INTENSITY8UI_EXT: - case GL_LUMINANCE8UI_EXT: - case GL_LUMINANCE_ALPHA8UI_EXT: - case GL_RGBA32I_EXT: - case GL_RGB32I_EXT: - case GL_RG32I: - case GL_R32I: - case GL_ALPHA32I_EXT: - case GL_INTENSITY32I_EXT: - case GL_LUMINANCE32I_EXT: - case GL_LUMINANCE_ALPHA32I_EXT: - case GL_RGBA16I_EXT: - case GL_RGB16I_EXT: - case GL_RG16I: - case GL_R16I: - case GL_ALPHA16I_EXT: - case GL_INTENSITY16I_EXT: - case GL_LUMINANCE16I_EXT: - case GL_LUMINANCE_ALPHA16I_EXT: - case GL_RGBA8I_EXT: - case GL_RGB8I_EXT: - case GL_RG8I: - case GL_R8I: - case GL_ALPHA8I_EXT: - case GL_INTENSITY8I_EXT: - case GL_LUMINANCE8I_EXT: - case GL_LUMINANCE_ALPHA8I_EXT: - case GL_RGB10_A2UI: - return GL_TRUE; - default: - return GL_FALSE; - } -} - - -/** - * Does the given base texture/renderbuffer format have the channel - * named by 'pname'? - */ -GLboolean -_mesa_base_format_has_channel(GLenum base_format, GLenum pname) -{ - switch (pname) { - case GL_TEXTURE_RED_SIZE: - case GL_TEXTURE_RED_TYPE: - case GL_RENDERBUFFER_RED_SIZE_EXT: - case GL_FRAMEBUFFER_ATTACHMENT_RED_SIZE: - if (base_format == GL_RED || - base_format == GL_RG || - base_format == GL_RGB || - base_format == GL_RGBA) { - return GL_TRUE; - } - return GL_FALSE; - case GL_TEXTURE_GREEN_SIZE: - case GL_TEXTURE_GREEN_TYPE: - case GL_RENDERBUFFER_GREEN_SIZE_EXT: - case GL_FRAMEBUFFER_ATTACHMENT_GREEN_SIZE: - if (base_format == GL_RG || - base_format == GL_RGB || - base_format == GL_RGBA) { - return GL_TRUE; - } - return GL_FALSE; - case GL_TEXTURE_BLUE_SIZE: - case GL_TEXTURE_BLUE_TYPE: - case GL_RENDERBUFFER_BLUE_SIZE_EXT: - case GL_FRAMEBUFFER_ATTACHMENT_BLUE_SIZE: - if (base_format == GL_RGB || - base_format == GL_RGBA) { - return GL_TRUE; - } - return GL_FALSE; - case GL_TEXTURE_ALPHA_SIZE: - case GL_TEXTURE_ALPHA_TYPE: - case GL_RENDERBUFFER_ALPHA_SIZE_EXT: - case GL_FRAMEBUFFER_ATTACHMENT_ALPHA_SIZE: - if (base_format == GL_RGBA || - base_format == GL_ALPHA || - base_format == GL_LUMINANCE_ALPHA) { - return GL_TRUE; - } - return GL_FALSE; - case GL_TEXTURE_LUMINANCE_SIZE: - case GL_TEXTURE_LUMINANCE_TYPE: - if (base_format == GL_LUMINANCE || - base_format == GL_LUMINANCE_ALPHA) { - return GL_TRUE; - } - return GL_FALSE; - case GL_TEXTURE_INTENSITY_SIZE: - case GL_TEXTURE_INTENSITY_TYPE: - if (base_format == GL_INTENSITY) { - return GL_TRUE; - } - return GL_FALSE; - case GL_TEXTURE_DEPTH_SIZE: - case GL_TEXTURE_DEPTH_TYPE: - case GL_RENDERBUFFER_DEPTH_SIZE_EXT: - case GL_FRAMEBUFFER_ATTACHMENT_DEPTH_SIZE: - if (base_format == GL_DEPTH_COMPONENT) { - return GL_TRUE; - } - return GL_FALSE; - case GL_RENDERBUFFER_STENCIL_SIZE_EXT: - case GL_FRAMEBUFFER_ATTACHMENT_STENCIL_SIZE: - if (base_format == GL_STENCIL_INDEX) { - return GL_TRUE; - } - return GL_FALSE; - default: - _mesa_warning(NULL, "%s: Unexpected channel token 0x%x\n", - __FUNCTION__, pname); - return GL_FALSE; - } - - return GL_FALSE; -} - - -/** - * Return the byte offset of a specific pixel in an image (1D, 2D or 3D). - * - * Pixel unpacking/packing parameters are observed according to \p packing. - * - * \param dimensions either 1, 2 or 3 to indicate dimensionality of image - * \param packing the pixelstore attributes - * \param width the image width - * \param height the image height - * \param format the pixel format (must be validated beforehand) - * \param type the pixel data type (must be validated beforehand) - * \param img which image in the volume (0 for 1D or 2D images) - * \param row row of pixel in the image (0 for 1D images) - * \param column column of pixel in the image - * - * \return offset of pixel. - * - * \sa gl_pixelstore_attrib. - */ -GLintptr -_mesa_image_offset( GLuint dimensions, - const struct gl_pixelstore_attrib *packing, - GLsizei width, GLsizei height, - GLenum format, GLenum type, - GLint img, GLint row, GLint column ) -{ - GLint alignment; /* 1, 2 or 4 */ - GLint pixels_per_row; - GLint rows_per_image; - GLint skiprows; - GLint skippixels; - GLint skipimages; /* for 3-D volume images */ - GLintptr offset; - - ASSERT(dimensions >= 1 && dimensions <= 3); - - alignment = packing->Alignment; - if (packing->RowLength > 0) { - pixels_per_row = packing->RowLength; - } - else { - pixels_per_row = width; - } - if (packing->ImageHeight > 0) { - rows_per_image = packing->ImageHeight; - } - else { - rows_per_image = height; - } - - skippixels = packing->SkipPixels; - /* Note: SKIP_ROWS _is_ used for 1D images */ - skiprows = packing->SkipRows; - /* Note: SKIP_IMAGES is only used for 3D images */ - skipimages = (dimensions == 3) ? packing->SkipImages : 0; - - if (type == GL_BITMAP) { - /* BITMAP data */ - GLint bytes_per_row; - GLint bytes_per_image; - /* components per pixel for color or stencil index: */ - const GLint comp_per_pixel = 1; - - /* The pixel type and format should have been error checked earlier */ - assert(format == GL_COLOR_INDEX || format == GL_STENCIL_INDEX); - - bytes_per_row = alignment - * CEILING( comp_per_pixel*pixels_per_row, 8*alignment ); - - bytes_per_image = bytes_per_row * rows_per_image; - - offset = (skipimages + img) * bytes_per_image - + (skiprows + row) * bytes_per_row - + (skippixels + column) / 8; - } - else { - /* Non-BITMAP data */ - GLint bytes_per_pixel, bytes_per_row, remainder, bytes_per_image; - GLint topOfImage; - - bytes_per_pixel = _mesa_bytes_per_pixel( format, type ); - - /* The pixel type and format should have been error checked earlier */ - assert(bytes_per_pixel > 0); - - bytes_per_row = pixels_per_row * bytes_per_pixel; - remainder = bytes_per_row % alignment; - if (remainder > 0) - bytes_per_row += (alignment - remainder); - - ASSERT(bytes_per_row % alignment == 0); - - bytes_per_image = bytes_per_row * rows_per_image; - - if (packing->Invert) { - /* set pixel_addr to the last row */ - topOfImage = bytes_per_row * (height - 1); - bytes_per_row = -bytes_per_row; - } - else { - topOfImage = 0; - } - - /* compute final pixel address */ - offset = (skipimages + img) * bytes_per_image - + topOfImage - + (skiprows + row) * bytes_per_row - + (skippixels + column) * bytes_per_pixel; - } - - return offset; -} - - -/** - * Return the address of a specific pixel in an image (1D, 2D or 3D). - * - * Pixel unpacking/packing parameters are observed according to \p packing. - * - * \param dimensions either 1, 2 or 3 to indicate dimensionality of image - * \param packing the pixelstore attributes - * \param image starting address of image data - * \param width the image width - * \param height the image height - * \param format the pixel format (must be validated beforehand) - * \param type the pixel data type (must be validated beforehand) - * \param img which image in the volume (0 for 1D or 2D images) - * \param row row of pixel in the image (0 for 1D images) - * \param column column of pixel in the image - * - * \return address of pixel. - * - * \sa gl_pixelstore_attrib. - */ -GLvoid * -_mesa_image_address( GLuint dimensions, - const struct gl_pixelstore_attrib *packing, - const GLvoid *image, - GLsizei width, GLsizei height, - GLenum format, GLenum type, - GLint img, GLint row, GLint column ) -{ - const GLubyte *addr = (const GLubyte *) image; - - addr += _mesa_image_offset(dimensions, packing, width, height, - format, type, img, row, column); - - return (GLvoid *) addr; -} - - -GLvoid * -_mesa_image_address1d( const struct gl_pixelstore_attrib *packing, - const GLvoid *image, - GLsizei width, - GLenum format, GLenum type, - GLint column ) -{ - return _mesa_image_address(1, packing, image, width, 1, - format, type, 0, 0, column); -} - - -GLvoid * -_mesa_image_address2d( const struct gl_pixelstore_attrib *packing, - const GLvoid *image, - GLsizei width, GLsizei height, - GLenum format, GLenum type, - GLint row, GLint column ) -{ - return _mesa_image_address(2, packing, image, width, height, - format, type, 0, row, column); -} - - -GLvoid * -_mesa_image_address3d( const struct gl_pixelstore_attrib *packing, - const GLvoid *image, - GLsizei width, GLsizei height, - GLenum format, GLenum type, - GLint img, GLint row, GLint column ) -{ - return _mesa_image_address(3, packing, image, width, height, - format, type, img, row, column); -} - - - -/** - * Compute the stride (in bytes) between image rows. - * - * \param packing the pixelstore attributes - * \param width image width. - * \param format pixel format. - * \param type pixel data type. - * - * \return the stride in bytes for the given parameters, or -1 if error - */ -GLint -_mesa_image_row_stride( const struct gl_pixelstore_attrib *packing, - GLint width, GLenum format, GLenum type ) -{ - GLint bytesPerRow, remainder; - - ASSERT(packing); - - if (type == GL_BITMAP) { - if (packing->RowLength == 0) { - bytesPerRow = (width + 7) / 8; - } - else { - bytesPerRow = (packing->RowLength + 7) / 8; - } - } - else { - /* Non-BITMAP data */ - const GLint bytesPerPixel = _mesa_bytes_per_pixel(format, type); - if (bytesPerPixel <= 0) - return -1; /* error */ - if (packing->RowLength == 0) { - bytesPerRow = bytesPerPixel * width; - } - else { - bytesPerRow = bytesPerPixel * packing->RowLength; - } - } - - remainder = bytesPerRow % packing->Alignment; - if (remainder > 0) { - bytesPerRow += (packing->Alignment - remainder); - } - - if (packing->Invert) { - /* negate the bytes per row (negative row stride) */ - bytesPerRow = -bytesPerRow; - } - - return bytesPerRow; -} - - -/* - * Compute the stride between images in a 3D texture (in bytes) for the given - * pixel packing parameters and image width, format and type. - */ -GLint -_mesa_image_image_stride( const struct gl_pixelstore_attrib *packing, - GLint width, GLint height, - GLenum format, GLenum type ) -{ - GLint bytesPerRow, bytesPerImage, remainder; - - ASSERT(packing); - - if (type == GL_BITMAP) { - if (packing->RowLength == 0) { - bytesPerRow = (width + 7) / 8; - } - else { - bytesPerRow = (packing->RowLength + 7) / 8; - } - } - else { - const GLint bytesPerPixel = _mesa_bytes_per_pixel(format, type); - - if (bytesPerPixel <= 0) - return -1; /* error */ - if (packing->RowLength == 0) { - bytesPerRow = bytesPerPixel * width; - } - else { - bytesPerRow = bytesPerPixel * packing->RowLength; - } - } - - remainder = bytesPerRow % packing->Alignment; - if (remainder > 0) - bytesPerRow += (packing->Alignment - remainder); - - if (packing->ImageHeight == 0) - bytesPerImage = bytesPerRow * height; - else - bytesPerImage = bytesPerRow * packing->ImageHeight; - - return bytesPerImage; -} - - - -/** - * "Expand" a bitmap from 1-bit per pixel to 8-bits per pixel. - * This is typically used to convert a bitmap into a GLubyte/pixel texture. - * "On" bits will set texels to \p onValue. - * "Off" bits will not modify texels. - * \param width src bitmap width in pixels - * \param height src bitmap height in pixels - * \param unpack bitmap unpacking state - * \param bitmap the src bitmap data - * \param destBuffer start of dest buffer - * \param destStride row stride in dest buffer - * \param onValue if bit is 1, set destBuffer pixel to this value - */ -void -_mesa_expand_bitmap(GLsizei width, GLsizei height, - const struct gl_pixelstore_attrib *unpack, - const GLubyte *bitmap, - GLubyte *destBuffer, GLint destStride, - GLubyte onValue) -{ - const GLubyte *srcRow = (const GLubyte *) - _mesa_image_address2d(unpack, bitmap, width, height, - GL_COLOR_INDEX, GL_BITMAP, 0, 0); - const GLint srcStride = _mesa_image_row_stride(unpack, width, - GL_COLOR_INDEX, GL_BITMAP); - GLint row, col; - -#define SET_PIXEL(COL, ROW) \ - destBuffer[(ROW) * destStride + (COL)] = onValue; - - for (row = 0; row < height; row++) { - const GLubyte *src = srcRow; - - if (unpack->LsbFirst) { - /* Lsb first */ - GLubyte mask = 1U << (unpack->SkipPixels & 0x7); - for (col = 0; col < width; col++) { - - if (*src & mask) { - SET_PIXEL(col, row); - } - - if (mask == 128U) { - src++; - mask = 1U; - } - else { - mask = mask << 1; - } - } - - /* get ready for next row */ - if (mask != 1) - src++; - } - else { - /* Msb first */ - GLubyte mask = 128U >> (unpack->SkipPixels & 0x7); - for (col = 0; col < width; col++) { - - if (*src & mask) { - SET_PIXEL(col, row); - } - - if (mask == 1U) { - src++; - mask = 128U; - } - else { - mask = mask >> 1; - } - } - - /* get ready for next row */ - if (mask != 128) - src++; - } - - srcRow += srcStride; - } /* row */ - -#undef SET_PIXEL -} - - - - -/** - * Convert an array of RGBA colors from one datatype to another. - * NOTE: src may equal dst. In that case, we use a temporary buffer. - */ -void -_mesa_convert_colors(GLenum srcType, const GLvoid *src, - GLenum dstType, GLvoid *dst, - GLuint count, const GLubyte mask[]) -{ - GLuint *tempBuffer; - const GLboolean useTemp = (src == dst); - - tempBuffer = malloc(count * MAX_PIXEL_BYTES); - if (!tempBuffer) - return; - - ASSERT(srcType != dstType); - - switch (srcType) { - case GL_UNSIGNED_BYTE: - if (dstType == GL_UNSIGNED_SHORT) { - const GLubyte (*src1)[4] = (const GLubyte (*)[4]) src; - GLushort (*dst2)[4] = (GLushort (*)[4]) (useTemp ? tempBuffer : dst); - GLuint i; - for (i = 0; i < count; i++) { - if (!mask || mask[i]) { - dst2[i][RCOMP] = UBYTE_TO_USHORT(src1[i][RCOMP]); - dst2[i][GCOMP] = UBYTE_TO_USHORT(src1[i][GCOMP]); - dst2[i][BCOMP] = UBYTE_TO_USHORT(src1[i][BCOMP]); - dst2[i][ACOMP] = UBYTE_TO_USHORT(src1[i][ACOMP]); - } - } - if (useTemp) - memcpy(dst, tempBuffer, count * 4 * sizeof(GLushort)); - } - else { - const GLubyte (*src1)[4] = (const GLubyte (*)[4]) src; - GLfloat (*dst4)[4] = (GLfloat (*)[4]) (useTemp ? tempBuffer : dst); - GLuint i; - ASSERT(dstType == GL_FLOAT); - for (i = 0; i < count; i++) { - if (!mask || mask[i]) { - dst4[i][RCOMP] = UBYTE_TO_FLOAT(src1[i][RCOMP]); - dst4[i][GCOMP] = UBYTE_TO_FLOAT(src1[i][GCOMP]); - dst4[i][BCOMP] = UBYTE_TO_FLOAT(src1[i][BCOMP]); - dst4[i][ACOMP] = UBYTE_TO_FLOAT(src1[i][ACOMP]); - } - } - if (useTemp) - memcpy(dst, tempBuffer, count * 4 * sizeof(GLfloat)); - } - break; - case GL_UNSIGNED_SHORT: - if (dstType == GL_UNSIGNED_BYTE) { - const GLushort (*src2)[4] = (const GLushort (*)[4]) src; - GLubyte (*dst1)[4] = (GLubyte (*)[4]) (useTemp ? tempBuffer : dst); - GLuint i; - for (i = 0; i < count; i++) { - if (!mask || mask[i]) { - dst1[i][RCOMP] = USHORT_TO_UBYTE(src2[i][RCOMP]); - dst1[i][GCOMP] = USHORT_TO_UBYTE(src2[i][GCOMP]); - dst1[i][BCOMP] = USHORT_TO_UBYTE(src2[i][BCOMP]); - dst1[i][ACOMP] = USHORT_TO_UBYTE(src2[i][ACOMP]); - } - } - if (useTemp) - memcpy(dst, tempBuffer, count * 4 * sizeof(GLubyte)); - } - else { - const GLushort (*src2)[4] = (const GLushort (*)[4]) src; - GLfloat (*dst4)[4] = (GLfloat (*)[4]) (useTemp ? tempBuffer : dst); - GLuint i; - ASSERT(dstType == GL_FLOAT); - for (i = 0; i < count; i++) { - if (!mask || mask[i]) { - dst4[i][RCOMP] = USHORT_TO_FLOAT(src2[i][RCOMP]); - dst4[i][GCOMP] = USHORT_TO_FLOAT(src2[i][GCOMP]); - dst4[i][BCOMP] = USHORT_TO_FLOAT(src2[i][BCOMP]); - dst4[i][ACOMP] = USHORT_TO_FLOAT(src2[i][ACOMP]); - } - } - if (useTemp) - memcpy(dst, tempBuffer, count * 4 * sizeof(GLfloat)); - } - break; - case GL_FLOAT: - if (dstType == GL_UNSIGNED_BYTE) { - const GLfloat (*src4)[4] = (const GLfloat (*)[4]) src; - GLubyte (*dst1)[4] = (GLubyte (*)[4]) (useTemp ? tempBuffer : dst); - GLuint i; - for (i = 0; i < count; i++) { - if (!mask || mask[i]) - _mesa_unclamped_float_rgba_to_ubyte(dst1[i], src4[i]); - } - if (useTemp) - memcpy(dst, tempBuffer, count * 4 * sizeof(GLubyte)); - } - else { - const GLfloat (*src4)[4] = (const GLfloat (*)[4]) src; - GLushort (*dst2)[4] = (GLushort (*)[4]) (useTemp ? tempBuffer : dst); - GLuint i; - ASSERT(dstType == GL_UNSIGNED_SHORT); - for (i = 0; i < count; i++) { - if (!mask || mask[i]) { - UNCLAMPED_FLOAT_TO_USHORT(dst2[i][RCOMP], src4[i][RCOMP]); - UNCLAMPED_FLOAT_TO_USHORT(dst2[i][GCOMP], src4[i][GCOMP]); - UNCLAMPED_FLOAT_TO_USHORT(dst2[i][BCOMP], src4[i][BCOMP]); - UNCLAMPED_FLOAT_TO_USHORT(dst2[i][ACOMP], src4[i][ACOMP]); - } - } - if (useTemp) - memcpy(dst, tempBuffer, count * 4 * sizeof(GLushort)); - } - break; - default: - _mesa_problem(NULL, "Invalid datatype in _mesa_convert_colors"); - } - - free(tempBuffer); -} - - - - -/** - * Perform basic clipping for glDrawPixels. The image's position and size - * and the unpack SkipPixels and SkipRows are adjusted so that the image - * region is entirely within the window and scissor bounds. - * NOTE: this will only work when glPixelZoom is (1, 1) or (1, -1). - * If Pixel.ZoomY is -1, *destY will be changed to be the first row which - * we'll actually write. Beforehand, *destY-1 is the first drawing row. - * - * \return GL_TRUE if image is ready for drawing or - * GL_FALSE if image was completely clipped away (draw nothing) - */ -GLboolean -_mesa_clip_drawpixels(const struct gl_context *ctx, - GLint *destX, GLint *destY, - GLsizei *width, GLsizei *height, - struct gl_pixelstore_attrib *unpack) -{ - const struct gl_framebuffer *buffer = ctx->DrawBuffer; - - if (unpack->RowLength == 0) { - unpack->RowLength = *width; - } - - ASSERT(ctx->Pixel.ZoomX == 1.0F); - ASSERT(ctx->Pixel.ZoomY == 1.0F || ctx->Pixel.ZoomY == -1.0F); - - /* left clipping */ - if (*destX < buffer->_Xmin) { - unpack->SkipPixels += (buffer->_Xmin - *destX); - *width -= (buffer->_Xmin - *destX); - *destX = buffer->_Xmin; - } - /* right clipping */ - if (*destX + *width > buffer->_Xmax) - *width -= (*destX + *width - buffer->_Xmax); - - if (*width <= 0) - return GL_FALSE; - - if (ctx->Pixel.ZoomY == 1.0F) { - /* bottom clipping */ - if (*destY < buffer->_Ymin) { - unpack->SkipRows += (buffer->_Ymin - *destY); - *height -= (buffer->_Ymin - *destY); - *destY = buffer->_Ymin; - } - /* top clipping */ - if (*destY + *height > buffer->_Ymax) - *height -= (*destY + *height - buffer->_Ymax); - } - else { /* upside down */ - /* top clipping */ - if (*destY > buffer->_Ymax) { - unpack->SkipRows += (*destY - buffer->_Ymax); - *height -= (*destY - buffer->_Ymax); - *destY = buffer->_Ymax; - } - /* bottom clipping */ - if (*destY - *height < buffer->_Ymin) - *height -= (buffer->_Ymin - (*destY - *height)); - /* adjust destY so it's the first row to write to */ - (*destY)--; - } - - if (*height <= 0) - return GL_FALSE; - - return GL_TRUE; -} - - -/** - * Perform clipping for glReadPixels. The image's window position - * and size, and the pack skipPixels, skipRows and rowLength are adjusted - * so that the image region is entirely within the window bounds. - * Note: this is different from _mesa_clip_drawpixels() in that the - * scissor box is ignored, and we use the bounds of the current readbuffer - * surface. - * - * \return GL_TRUE if region to read is in bounds - * GL_FALSE if region is completely out of bounds (nothing to read) - */ -GLboolean -_mesa_clip_readpixels(const struct gl_context *ctx, - GLint *srcX, GLint *srcY, - GLsizei *width, GLsizei *height, - struct gl_pixelstore_attrib *pack) -{ - const struct gl_framebuffer *buffer = ctx->ReadBuffer; - - if (pack->RowLength == 0) { - pack->RowLength = *width; - } - - /* left clipping */ - if (*srcX < 0) { - pack->SkipPixels += (0 - *srcX); - *width -= (0 - *srcX); - *srcX = 0; - } - /* right clipping */ - if (*srcX + *width > (GLsizei) buffer->Width) - *width -= (*srcX + *width - buffer->Width); - - if (*width <= 0) - return GL_FALSE; - - /* bottom clipping */ - if (*srcY < 0) { - pack->SkipRows += (0 - *srcY); - *height -= (0 - *srcY); - *srcY = 0; - } - /* top clipping */ - if (*srcY + *height > (GLsizei) buffer->Height) - *height -= (*srcY + *height - buffer->Height); - - if (*height <= 0) - return GL_FALSE; - - return GL_TRUE; -} - - -/** - * Do clipping for a glCopyTexSubImage call. - * The framebuffer source region might extend outside the framebuffer - * bounds. Clip the source region against the framebuffer bounds and - * adjust the texture/dest position and size accordingly. - * - * \return GL_FALSE if region is totally clipped, GL_TRUE otherwise. - */ -GLboolean -_mesa_clip_copytexsubimage(const struct gl_context *ctx, - GLint *destX, GLint *destY, - GLint *srcX, GLint *srcY, - GLsizei *width, GLsizei *height) -{ - const struct gl_framebuffer *fb = ctx->ReadBuffer; - const GLint srcX0 = *srcX, srcY0 = *srcY; - - if (_mesa_clip_to_region(0, 0, fb->Width, fb->Height, - srcX, srcY, width, height)) { - *destX = *destX + *srcX - srcX0; - *destY = *destY + *srcY - srcY0; - - return GL_TRUE; - } - else { - return GL_FALSE; - } -} - - - -/** - * Clip the rectangle defined by (x, y, width, height) against the bounds - * specified by [xmin, xmax) and [ymin, ymax). - * \return GL_FALSE if rect is totally clipped, GL_TRUE otherwise. - */ -GLboolean -_mesa_clip_to_region(GLint xmin, GLint ymin, - GLint xmax, GLint ymax, - GLint *x, GLint *y, - GLsizei *width, GLsizei *height ) -{ - /* left clipping */ - if (*x < xmin) { - *width -= (xmin - *x); - *x = xmin; - } - - /* right clipping */ - if (*x + *width > xmax) - *width -= (*x + *width - xmax); - - if (*width <= 0) - return GL_FALSE; - - /* bottom (or top) clipping */ - if (*y < ymin) { - *height -= (ymin - *y); - *y = ymin; - } - - /* top (or bottom) clipping */ - if (*y + *height > ymax) - *height -= (*y + *height - ymax); - - if (*height <= 0) - return GL_FALSE; - - return GL_TRUE; -} - - -/** - * Clip dst coords against Xmax (or Ymax). - */ -static inline void -clip_right_or_top(GLint *srcX0, GLint *srcX1, - GLint *dstX0, GLint *dstX1, - GLint maxValue) -{ - GLfloat t, bias; - - if (*dstX1 > maxValue) { - /* X1 outside right edge */ - ASSERT(*dstX0 < maxValue); /* X0 should be inside right edge */ - t = (GLfloat) (maxValue - *dstX0) / (GLfloat) (*dstX1 - *dstX0); - /* chop off [t, 1] part */ - ASSERT(t >= 0.0 && t <= 1.0); - *dstX1 = maxValue; - bias = (*srcX0 < *srcX1) ? 0.5F : -0.5F; - *srcX1 = *srcX0 + (GLint) (t * (*srcX1 - *srcX0) + bias); - } - else if (*dstX0 > maxValue) { - /* X0 outside right edge */ - ASSERT(*dstX1 < maxValue); /* X1 should be inside right edge */ - t = (GLfloat) (maxValue - *dstX1) / (GLfloat) (*dstX0 - *dstX1); - /* chop off [t, 1] part */ - ASSERT(t >= 0.0 && t <= 1.0); - *dstX0 = maxValue; - bias = (*srcX0 < *srcX1) ? -0.5F : 0.5F; - *srcX0 = *srcX1 + (GLint) (t * (*srcX0 - *srcX1) + bias); - } -} - - -/** - * Clip dst coords against Xmin (or Ymin). - */ -static inline void -clip_left_or_bottom(GLint *srcX0, GLint *srcX1, - GLint *dstX0, GLint *dstX1, - GLint minValue) -{ - GLfloat t, bias; - - if (*dstX0 < minValue) { - /* X0 outside left edge */ - ASSERT(*dstX1 > minValue); /* X1 should be inside left edge */ - t = (GLfloat) (minValue - *dstX0) / (GLfloat) (*dstX1 - *dstX0); - /* chop off [0, t] part */ - ASSERT(t >= 0.0 && t <= 1.0); - *dstX0 = minValue; - bias = (*srcX0 < *srcX1) ? 0.5F : -0.5F; /* flipped??? */ - *srcX0 = *srcX0 + (GLint) (t * (*srcX1 - *srcX0) + bias); - } - else if (*dstX1 < minValue) { - /* X1 outside left edge */ - ASSERT(*dstX0 > minValue); /* X0 should be inside left edge */ - t = (GLfloat) (minValue - *dstX1) / (GLfloat) (*dstX0 - *dstX1); - /* chop off [0, t] part */ - ASSERT(t >= 0.0 && t <= 1.0); - *dstX1 = minValue; - bias = (*srcX0 < *srcX1) ? 0.5F : -0.5F; - *srcX1 = *srcX1 + (GLint) (t * (*srcX0 - *srcX1) + bias); - } -} - - -/** - * Do clipping of blit src/dest rectangles. - * The dest rect is clipped against both the buffer bounds and scissor bounds. - * The src rect is just clipped against the buffer bounds. - * - * When either the src or dest rect is clipped, the other is also clipped - * proportionately! - * - * Note that X0 need not be less than X1 (same for Y) for either the source - * and dest rects. That makes the clipping a little trickier. - * - * \return GL_TRUE if anything is left to draw, GL_FALSE if totally clipped - */ -GLboolean -_mesa_clip_blit(struct gl_context *ctx, - GLint *srcX0, GLint *srcY0, GLint *srcX1, GLint *srcY1, - GLint *dstX0, GLint *dstY0, GLint *dstX1, GLint *dstY1) -{ - const GLint srcXmin = 0; - const GLint srcXmax = ctx->ReadBuffer->Width; - const GLint srcYmin = 0; - const GLint srcYmax = ctx->ReadBuffer->Height; - - /* these include scissor bounds */ - const GLint dstXmin = ctx->DrawBuffer->_Xmin; - const GLint dstXmax = ctx->DrawBuffer->_Xmax; - const GLint dstYmin = ctx->DrawBuffer->_Ymin; - const GLint dstYmax = ctx->DrawBuffer->_Ymax; - - /* - printf("PreClipX: src: %d .. %d dst: %d .. %d\n", - *srcX0, *srcX1, *dstX0, *dstX1); - printf("PreClipY: src: %d .. %d dst: %d .. %d\n", - *srcY0, *srcY1, *dstY0, *dstY1); - */ - - /* trivial rejection tests */ - if (*dstX0 == *dstX1) - return GL_FALSE; /* no width */ - if (*dstX0 <= dstXmin && *dstX1 <= dstXmin) - return GL_FALSE; /* totally out (left) of bounds */ - if (*dstX0 >= dstXmax && *dstX1 >= dstXmax) - return GL_FALSE; /* totally out (right) of bounds */ - - if (*dstY0 == *dstY1) - return GL_FALSE; - if (*dstY0 <= dstYmin && *dstY1 <= dstYmin) - return GL_FALSE; - if (*dstY0 >= dstYmax && *dstY1 >= dstYmax) - return GL_FALSE; - - if (*srcX0 == *srcX1) - return GL_FALSE; - if (*srcX0 <= srcXmin && *srcX1 <= srcXmin) - return GL_FALSE; - if (*srcX0 >= srcXmax && *srcX1 >= srcXmax) - return GL_FALSE; - - if (*srcY0 == *srcY1) - return GL_FALSE; - if (*srcY0 <= srcYmin && *srcY1 <= srcYmin) - return GL_FALSE; - if (*srcY0 >= srcYmax && *srcY1 >= srcYmax) - return GL_FALSE; - - /* - * dest clip - */ - clip_right_or_top(srcX0, srcX1, dstX0, dstX1, dstXmax); - clip_right_or_top(srcY0, srcY1, dstY0, dstY1, dstYmax); - clip_left_or_bottom(srcX0, srcX1, dstX0, dstX1, dstXmin); - clip_left_or_bottom(srcY0, srcY1, dstY0, dstY1, dstYmin); - - /* - * src clip (just swap src/dst values from above) - */ - clip_right_or_top(dstX0, dstX1, srcX0, srcX1, srcXmax); - clip_right_or_top(dstY0, dstY1, srcY0, srcY1, srcYmax); - clip_left_or_bottom(dstX0, dstX1, srcX0, srcX1, srcXmin); - clip_left_or_bottom(dstY0, dstY1, srcY0, srcY1, srcYmin); - - /* - printf("PostClipX: src: %d .. %d dst: %d .. %d\n", - *srcX0, *srcX1, *dstX0, *dstX1); - printf("PostClipY: src: %d .. %d dst: %d .. %d\n", - *srcY0, *srcY1, *dstY0, *dstY1); - */ - - ASSERT(*dstX0 >= dstXmin); - ASSERT(*dstX0 <= dstXmax); - ASSERT(*dstX1 >= dstXmin); - ASSERT(*dstX1 <= dstXmax); - - ASSERT(*dstY0 >= dstYmin); - ASSERT(*dstY0 <= dstYmax); - ASSERT(*dstY1 >= dstYmin); - ASSERT(*dstY1 <= dstYmax); - - ASSERT(*srcX0 >= srcXmin); - ASSERT(*srcX0 <= srcXmax); - ASSERT(*srcX1 >= srcXmin); - ASSERT(*srcX1 <= srcXmax); - - ASSERT(*srcY0 >= srcYmin); - ASSERT(*srcY0 <= srcYmax); - ASSERT(*srcY1 >= srcYmin); - ASSERT(*srcY1 <= srcYmax); - - return GL_TRUE; -} diff --git a/dll/opengl/mesa/main/image.h b/dll/opengl/mesa/main/image.h deleted file mode 100644 index 6cd7b08dce4..00000000000 --- a/dll/opengl/mesa/main/image.h +++ /dev/null @@ -1,174 +0,0 @@ -/* - * Mesa 3-D graphics library - * Version: 7.1 - * - * Copyright (C) 1999-2008 Brian Paul All Rights Reserved. - * - * Permission is hereby granted, free of charge, to any person obtaining a - * copy of this software and associated documentation files (the "Software"), - * to deal in the Software without restriction, including without limitation - * the rights to use, copy, modify, merge, publish, distribute, sublicense, - * and/or sell copies of the Software, and to permit persons to whom the - * Software is furnished to do so, subject to the following conditions: - * - * The above copyright notice and this permission notice shall be included - * in all copies or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS - * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL - * BRIAN PAUL BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN - * AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN - * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. - */ - - -#ifndef IMAGE_H -#define IMAGE_H - - -#include "glheader.h" - -struct gl_context; -struct gl_pixelstore_attrib; - -extern void -_mesa_swap2( GLushort *p, GLuint n ); - -extern void -_mesa_swap4( GLuint *p, GLuint n ); - -extern GLboolean -_mesa_type_is_packed(GLenum type); - -extern GLint -_mesa_sizeof_type( GLenum type ); - -extern GLint -_mesa_sizeof_packed_type( GLenum type ); - -extern GLint -_mesa_components_in_format( GLenum format ); - -extern GLint -_mesa_bytes_per_pixel( GLenum format, GLenum type ); - -extern GLenum -_mesa_error_check_format_and_type(const struct gl_context *ctx, - GLenum format, GLenum type); - -extern GLboolean -_mesa_is_color_format(GLenum format); - -extern GLboolean -_mesa_is_depth_format(GLenum format); - -extern GLboolean -_mesa_is_stencil_format(GLenum format); - -extern GLboolean -_mesa_is_ycbcr_format(GLenum format); - -extern GLboolean -_mesa_is_depth_or_stencil_format(GLenum format); - -extern GLboolean -_mesa_is_integer_format(GLenum format); - -extern GLboolean -_mesa_base_format_has_channel(GLenum base_format, GLenum pname); - -extern GLintptr -_mesa_image_offset( GLuint dimensions, - const struct gl_pixelstore_attrib *packing, - GLsizei width, GLsizei height, - GLenum format, GLenum type, - GLint img, GLint row, GLint column ); - -extern GLvoid * -_mesa_image_address( GLuint dimensions, - const struct gl_pixelstore_attrib *packing, - const GLvoid *image, - GLsizei width, GLsizei height, - GLenum format, GLenum type, - GLint img, GLint row, GLint column ); - -extern GLvoid * -_mesa_image_address1d( const struct gl_pixelstore_attrib *packing, - const GLvoid *image, - GLsizei width, - GLenum format, GLenum type, - GLint column ); - -extern GLvoid * -_mesa_image_address2d( const struct gl_pixelstore_attrib *packing, - const GLvoid *image, - GLsizei width, GLsizei height, - GLenum format, GLenum type, - GLint row, GLint column ); - -extern GLvoid * -_mesa_image_address3d( const struct gl_pixelstore_attrib *packing, - const GLvoid *image, - GLsizei width, GLsizei height, - GLenum format, GLenum type, - GLint img, GLint row, GLint column ); - - -extern GLint -_mesa_image_row_stride( const struct gl_pixelstore_attrib *packing, - GLint width, GLenum format, GLenum type ); - - -extern GLint -_mesa_image_image_stride( const struct gl_pixelstore_attrib *packing, - GLint width, GLint height, - GLenum format, GLenum type ); - - -extern void -_mesa_expand_bitmap(GLsizei width, GLsizei height, - const struct gl_pixelstore_attrib *unpack, - const GLubyte *bitmap, - GLubyte *destBuffer, GLint destStride, - GLubyte onValue); - - -extern void -_mesa_convert_colors(GLenum srcType, const GLvoid *src, - GLenum dstType, GLvoid *dst, - GLuint count, const GLubyte mask[]); - - -extern GLboolean -_mesa_clip_drawpixels(const struct gl_context *ctx, - GLint *destX, GLint *destY, - GLsizei *width, GLsizei *height, - struct gl_pixelstore_attrib *unpack); - - -extern GLboolean -_mesa_clip_readpixels(const struct gl_context *ctx, - GLint *srcX, GLint *srcY, - GLsizei *width, GLsizei *height, - struct gl_pixelstore_attrib *pack); - -extern GLboolean -_mesa_clip_copytexsubimage(const struct gl_context *ctx, - GLint *destX, GLint *destY, - GLint *srcX, GLint *srcY, - GLsizei *width, GLsizei *height); - -extern GLboolean -_mesa_clip_to_region(GLint xmin, GLint ymin, - GLint xmax, GLint ymax, - GLint *x, GLint *y, - GLsizei *width, GLsizei *height ); - -extern GLboolean -_mesa_clip_blit(struct gl_context *ctx, - GLint *srcX0, GLint *srcY0, GLint *srcX1, GLint *srcY1, - GLint *dstX0, GLint *dstY0, GLint *dstX1, GLint *dstY1); - - -#endif diff --git a/dll/opengl/mesa/main/imports.c b/dll/opengl/mesa/main/imports.c deleted file mode 100644 index e4f5b59f209..00000000000 --- a/dll/opengl/mesa/main/imports.c +++ /dev/null @@ -1,903 +0,0 @@ -/** - * \file imports.c - * Standard C library function wrappers. - * - * Imports are services which the device driver or window system or - * operating system provides to the core renderer. The core renderer (Mesa) - * will call these functions in order to do memory allocation, simple I/O, - * etc. - * - * Some drivers will want to override/replace this file with something - * specialized, but that'll be rare. - * - * Eventually, I want to move roll the glheader.h file into this. - * - * \todo Functions still needed: - * - scanf - * - qsort - * - rand and RAND_MAX - */ - -/* - * Mesa 3-D graphics library - * Version: 7.1 - * - * Copyright (C) 1999-2007 Brian Paul All Rights Reserved. - * - * Permission is hereby granted, free of charge, to any person obtaining a - * copy of this software and associated documentation files (the "Software"), - * to deal in the Software without restriction, including without limitation - * the rights to use, copy, modify, merge, publish, distribute, sublicense, - * and/or sell copies of the Software, and to permit persons to whom the - * Software is furnished to do so, subject to the following conditions: - * - * The above copyright notice and this permission notice shall be included - * in all copies or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS - * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL - * BRIAN PAUL BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN - * AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN - * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. - */ - - -#include - -#ifdef _GNU_SOURCE -#include -#ifdef __APPLE__ -#include -#endif -#endif - -#define MAXSTRING 4000 /* for vsnprintf() */ - -#ifdef WIN32 -#define vsnprintf _vsnprintf -#elif defined(__IBMC__) || defined(__IBMCPP__) || ( defined(__VMS) && __CRTL_VER < 70312000 ) -extern int vsnprintf(char *str, size_t count, const char *fmt, va_list arg); -#ifdef __VMS -#include "vsnprintf.c" -#endif -#endif - -/**********************************************************************/ -/** \name Memory */ -/*@{*/ - -/** - * Allocate aligned memory. - * - * \param bytes number of bytes to allocate. - * \param alignment alignment (must be greater than zero). - * - * Allocates extra memory to accommodate rounding up the address for - * alignment and to record the real malloc address. - * - * \sa _mesa_align_free(). - */ -void * -_mesa_align_malloc(size_t bytes, unsigned long alignment) -{ -#if defined(HAVE_POSIX_MEMALIGN) - void *mem; - int err = posix_memalign(& mem, alignment, bytes); - if (err) - return NULL; - return mem; -#elif defined(_WIN32) && defined(_MSC_VER) - return _aligned_malloc(bytes, alignment); -#else - uintptr_t ptr, buf; - - ASSERT( alignment > 0 ); - - ptr = (uintptr_t) malloc(bytes + alignment + sizeof(void *)); - if (!ptr) - return NULL; - - buf = (ptr + alignment + sizeof(void *)) & ~(uintptr_t)(alignment - 1); - *(uintptr_t *)(buf - sizeof(void *)) = ptr; - -#ifdef DEBUG - /* mark the non-aligned area */ - while ( ptr < buf - sizeof(void *) ) { - *(unsigned long *)ptr = 0xcdcdcdcd; - ptr += sizeof(unsigned long); - } -#endif - - return (void *) buf; -#endif /* defined(HAVE_POSIX_MEMALIGN) */ -} - -/** - * Same as _mesa_align_malloc(), but using calloc(1, ) instead of - * malloc() - */ -void * -_mesa_align_calloc(size_t bytes, unsigned long alignment) -{ -#if defined(HAVE_POSIX_MEMALIGN) - void *mem; - - mem = _mesa_align_malloc(bytes, alignment); - if (mem != NULL) { - (void) memset(mem, 0, bytes); - } - - return mem; -#elif defined(_WIN32) && defined(_MSC_VER) - void *mem; - - mem = _aligned_malloc(bytes, alignment); - if (mem != NULL) { - (void) memset(mem, 0, bytes); - } - - return mem; -#else - uintptr_t ptr, buf; - - ASSERT( alignment > 0 ); - - ptr = (uintptr_t) calloc(1, bytes + alignment + sizeof(void *)); - if (!ptr) - return NULL; - - buf = (ptr + alignment + sizeof(void *)) & ~(uintptr_t)(alignment - 1); - *(uintptr_t *)(buf - sizeof(void *)) = ptr; - -#ifdef DEBUG - /* mark the non-aligned area */ - while ( ptr < buf - sizeof(void *) ) { - *(unsigned long *)ptr = 0xcdcdcdcd; - ptr += sizeof(unsigned long); - } -#endif - - return (void *)buf; -#endif /* defined(HAVE_POSIX_MEMALIGN) */ -} - -/** - * Free memory which was allocated with either _mesa_align_malloc() - * or _mesa_align_calloc(). - * \param ptr pointer to the memory to be freed. - * The actual address to free is stored in the word immediately before the - * address the client sees. - */ -void -_mesa_align_free(void *ptr) -{ -#if defined(HAVE_POSIX_MEMALIGN) - free(ptr); -#elif defined(_WIN32) && defined(_MSC_VER) - _aligned_free(ptr); -#else - void **cubbyHole = (void **) ((char *) ptr - sizeof(void *)); - void *realAddr = *cubbyHole; - free(realAddr); -#endif /* defined(HAVE_POSIX_MEMALIGN) */ -} - -/** - * Reallocate memory, with alignment. - */ -void * -_mesa_align_realloc(void *oldBuffer, size_t oldSize, size_t newSize, - unsigned long alignment) -{ -#if defined(_WIN32) && defined(_MSC_VER) - (void) oldSize; - return _aligned_realloc(oldBuffer, newSize, alignment); -#else - const size_t copySize = (oldSize < newSize) ? oldSize : newSize; - void *newBuf = _mesa_align_malloc(newSize, alignment); - if (newBuf && oldBuffer && copySize > 0) { - memcpy(newBuf, oldBuffer, copySize); - } - if (oldBuffer) - _mesa_align_free(oldBuffer); - return newBuf; -#endif -} - - - -/** Reallocate memory */ -void * -_mesa_realloc(void *oldBuffer, size_t oldSize, size_t newSize) -{ - const size_t copySize = (oldSize < newSize) ? oldSize : newSize; - void *newBuffer = malloc(newSize); - if (newBuffer && oldBuffer && copySize > 0) - memcpy(newBuffer, oldBuffer, copySize); - if (oldBuffer) - free(oldBuffer); - return newBuffer; -} - -/** - * Fill memory with a constant 16bit word. - * \param dst destination pointer. - * \param val value. - * \param n number of words. - */ -void -_mesa_memset16( unsigned short *dst, unsigned short val, size_t n ) -{ - while (n-- > 0) - *dst++ = val; -} - -/*@}*/ - - -/**********************************************************************/ -/** \name Math */ -/*@{*/ - -/** Wrapper around sqrt() */ -double -_mesa_sqrtd(double x) -{ - return sqrt(x); -} - - -/* - * A High Speed, Low Precision Square Root - * by Paul Lalonde and Robert Dawson - * from "Graphics Gems", Academic Press, 1990 - * - * SPARC implementation of a fast square root by table - * lookup. - * SPARC floating point format is as follows: - * - * BIT 31 30 23 22 0 - * sign exponent mantissa - */ -static short sqrttab[0x100]; /* declare table of square roots */ - -void -_mesa_init_sqrt_table(void) -{ -#if defined(USE_IEEE) && !defined(DEBUG) - unsigned short i; - fi_type fi; /* to access the bits of a float in C quickly */ - /* we use a union defined in glheader.h */ - - for(i=0; i<= 0x7f; i++) { - fi.i = 0; - - /* - * Build a float with the bit pattern i as mantissa - * and an exponent of 0, stored as 127 - */ - - fi.i = (i << 16) | (127 << 23); - fi.f = _mesa_sqrtd(fi.f); - - /* - * Take the square root then strip the first 7 bits of - * the mantissa into the table - */ - - sqrttab[i] = (fi.i & 0x7fffff) >> 16; - - /* - * Repeat the process, this time with an exponent of - * 1, stored as 128 - */ - - fi.i = 0; - fi.i = (i << 16) | (128 << 23); - fi.f = sqrt(fi.f); - sqrttab[i+0x80] = (fi.i & 0x7fffff) >> 16; - } -#else - (void) sqrttab; /* silence compiler warnings */ -#endif /*HAVE_FAST_MATH*/ -} - - -/** - * Single precision square root. - */ -float -_mesa_sqrtf( float x ) -{ -#if defined(USE_IEEE) && !defined(DEBUG) - fi_type num; - /* to access the bits of a float in C - * we use a union from glheader.h */ - - short e; /* the exponent */ - if (x == 0.0F) return 0.0F; /* check for square root of 0 */ - num.f = x; - e = (num.i >> 23) - 127; /* get the exponent - on a SPARC the */ - /* exponent is stored with 127 added */ - num.i &= 0x7fffff; /* leave only the mantissa */ - if (e & 0x01) num.i |= 0x800000; - /* the exponent is odd so we have to */ - /* look it up in the second half of */ - /* the lookup table, so we set the */ - /* high bit */ - e >>= 1; /* divide the exponent by two */ - /* note that in C the shift */ - /* operators are sign preserving */ - /* for signed operands */ - /* Do the table lookup, based on the quaternary mantissa, - * then reconstruct the result back into a float - */ - num.i = ((sqrttab[num.i >> 16]) << 16) | ((e + 127) << 23); - - return num.f; -#else - return (float) _mesa_sqrtd((double) x); -#endif -} - - -/** - inv_sqrt - A single precision 1/sqrt routine for IEEE format floats. - written by Josh Vanderhoof, based on newsgroup posts by James Van Buskirk - and Vesa Karvonen. -*/ -float -_mesa_inv_sqrtf(float n) -{ -#if defined(USE_IEEE) && !defined(DEBUG) - float r0, x0, y0; - float r1, x1, y1; - float r2, x2, y2; -#if 0 /* not used, see below -BP */ - float r3, x3, y3; -#endif - fi_type u; - unsigned int magic; - - /* - Exponent part of the magic number - - - We want to: - 1. subtract the bias from the exponent, - 2. negate it - 3. divide by two (rounding towards -inf) - 4. add the bias back - - Which is the same as subtracting the exponent from 381 and dividing - by 2. - - floor(-(x - 127) / 2) + 127 = floor((381 - x) / 2) - */ - - magic = 381 << 23; - - /* - Significand part of magic number - - - With the current magic number, "(magic - u.i) >> 1" will give you: - - for 1 <= u.f <= 2: 1.25 - u.f / 4 - for 2 <= u.f <= 4: 1.00 - u.f / 8 - - This isn't a bad approximation of 1/sqrt. The maximum difference from - 1/sqrt will be around .06. After three Newton-Raphson iterations, the - maximum difference is less than 4.5e-8. (Which is actually close - enough to make the following bias academic...) - - To get a better approximation you can add a bias to the magic - number. For example, if you subtract 1/2 of the maximum difference in - the first approximation (.03), you will get the following function: - - for 1 <= u.f <= 2: 1.22 - u.f / 4 - for 2 <= u.f <= 3.76: 0.97 - u.f / 8 - for 3.76 <= u.f <= 4: 0.72 - u.f / 16 - (The 3.76 to 4 range is where the result is < .5.) - - This is the closest possible initial approximation, but with a maximum - error of 8e-11 after three NR iterations, it is still not perfect. If - you subtract 0.0332281 instead of .03, the maximum error will be - 2.5e-11 after three NR iterations, which should be about as close as - is possible. - - for 1 <= u.f <= 2: 1.2167719 - u.f / 4 - for 2 <= u.f <= 3.73: 0.9667719 - u.f / 8 - for 3.73 <= u.f <= 4: 0.7167719 - u.f / 16 - - */ - - magic -= (int)(0.0332281 * (1 << 25)); - - u.f = n; - u.i = (magic - u.i) >> 1; - - /* - Instead of Newton-Raphson, we use Goldschmidt's algorithm, which - allows more parallelism. From what I understand, the parallelism - comes at the cost of less precision, because it lets error - accumulate across iterations. - */ - x0 = 1.0f; - y0 = 0.5f * n; - r0 = u.f; - - x1 = x0 * r0; - y1 = y0 * r0 * r0; - r1 = 1.5f - y1; - - x2 = x1 * r1; - y2 = y1 * r1 * r1; - r2 = 1.5f - y2; - -#if 1 - return x2 * r2; /* we can stop here, and be conformant -BP */ -#else - x3 = x2 * r2; - y3 = y2 * r2 * r2; - r3 = 1.5f - y3; - - return x3 * r3; -#endif -#else - return (float) (1.0 / sqrt(n)); -#endif -} - -#ifndef __GNUC__ -/** - * Find the first bit set in a word. - */ -int -_mesa_ffs(int32_t i) -{ -#if (defined(_WIN32) ) || defined(__IBMC__) || defined(__IBMCPP__) - register int bit = 0; - if (i != 0) { - if ((i & 0xffff) == 0) { - bit += 16; - i >>= 16; - } - if ((i & 0xff) == 0) { - bit += 8; - i >>= 8; - } - if ((i & 0xf) == 0) { - bit += 4; - i >>= 4; - } - while ((i & 1) == 0) { - bit++; - i >>= 1; - } - bit++; - } - return bit; -#else - return ffs(i); -#endif -} - - -/** - * Find position of first bit set in given value. - * XXX Warning: this function can only be used on 64-bit systems! - * \return position of least-significant bit set, starting at 1, return zero - * if no bits set. - */ -int -_mesa_ffsll(int64_t val) -{ - int bit; - - assert(sizeof(val) == 8); - - bit = _mesa_ffs((int32_t)val); - if (bit != 0) - return bit; - - bit = _mesa_ffs((int32_t)(val >> 32)); - if (bit != 0) - return 32 + bit; - - return 0; -} -#endif - -#if !defined(__GNUC__) ||\ - ((__GNUC__ * 100 + __GNUC_MINOR__) < 304) /* Not gcc 3.4 or later */ -/** - * Return number of bits set in given GLuint. - */ -unsigned int -_mesa_bitcount(unsigned int n) -{ - unsigned int bits; - for (bits = 0; n > 0; n = n >> 1) { - bits += (n & 1); - } - return bits; -} - -/** - * Return number of bits set in given 64-bit uint. - */ -unsigned int -_mesa_bitcount_64(uint64_t n) -{ - unsigned int bits; - for (bits = 0; n > 0; n = n >> 1) { - bits += (n & 1); - } - return bits; -} -#endif - -/*@}*/ - - -/**********************************************************************/ -/** \name Sort & Search */ -/*@{*/ - -/** - * Wrapper for bsearch(). - */ -void * -_mesa_bsearch( const void *key, const void *base, size_t nmemb, size_t size, - int (*compar)(const void *, const void *) ) -{ -#if defined(_WIN32_WCE) - void *mid; - int cmp; - while (nmemb) { - nmemb >>= 1; - mid = (char *)base + nmemb * size; - cmp = (*compar)(key, mid); - if (cmp == 0) - return mid; - if (cmp > 0) { - base = (char *)mid + size; - --nmemb; - } - } - return NULL; -#else - return bsearch(key, base, nmemb, size, compar); -#endif -} - -/*@}*/ - - -/**********************************************************************/ -/** \name Environment vars */ -/*@{*/ - -/** - * Wrapper for getenv(). - */ -char * -_mesa_getenv( const char *var ) -{ -#if defined(_XBOX) || defined(_WIN32_WCE) - return NULL; -#else - return getenv(var); -#endif -} - -/*@}*/ - - -/**********************************************************************/ -/** \name String */ -/*@{*/ - -/** - * Implemented using malloc() and strcpy. - * Note that NULL is handled accordingly. - */ -char * -_mesa_strdup( const char *s ) -{ - if (s) { - size_t l = strlen(s); - char *s2 = (char *) malloc(l + 1); - if (s2) - strcpy(s2, s); - return s2; - } - else { - return NULL; - } -} - -/** Wrapper around strtof() */ -float -_mesa_strtof( const char *s, char **end ) -{ -#if defined(_GNU_SOURCE) && !defined(__CYGWIN__) && !defined(__FreeBSD__) && \ - !defined(ANDROID) && !defined(__HAIKU__) - static locale_t loc = NULL; - if (!loc) { - loc = newlocale(LC_CTYPE_MASK, "C", NULL); - } - return strtof_l(s, end, loc); -#elif defined(_ISOC99_SOURCE) || (defined(_XOPEN_SOURCE) && _XOPEN_SOURCE >= 600) - return strtof(s, end); -#else - return (float)strtod(s, end); -#endif -} - -/** Compute simple checksum/hash for a string */ -unsigned int -_mesa_str_checksum(const char *str) -{ - /* This could probably be much better */ - unsigned int sum, i; - const char *c; - sum = i = 1; - for (c = str; *c; c++, i++) - sum += *c * (i % 100); - return sum + i; -} - - -/*@}*/ - - -/** Wrapper around vsnprintf() */ -int -_mesa_snprintf( char *str, size_t size, const char *fmt, ... ) -{ - int r; - va_list args; - va_start( args, fmt ); - r = vsnprintf( str, size, fmt, args ); - va_end( args ); - return r; -} - - -/**********************************************************************/ -/** \name Diagnostics */ -/*@{*/ - -static void -output_if_debug(const char *prefixString, const char *outputString, - GLboolean newline) -{ - static int debug = -1; - - /* Check the MESA_DEBUG environment variable if it hasn't - * been checked yet. We only have to check it once... - */ - if (debug == -1) { - char *env = _mesa_getenv("MESA_DEBUG"); - - /* In a debug build, we print warning messages *unless* - * MESA_DEBUG is 0. In a non-debug build, we don't - * print warning messages *unless* MESA_DEBUG is - * set *to any value*. - */ -#ifdef DEBUG - debug = (env != NULL && atoi(env) == 0) ? 0 : 1; -#else - debug = (env != NULL) ? 1 : 0; -#endif - } - - /* Now only print the string if we're required to do so. */ - if (debug) { - fprintf(stderr, "%s: %s", prefixString, outputString); - if (newline) - fprintf(stderr, "\n"); - -#if defined(_WIN32) && !defined(_WIN32_WCE) - /* stderr from windows applications without console is not usually - * visible, so communicate with the debugger instead */ - { - char buf[4096]; - _mesa_snprintf(buf, sizeof(buf), "%s: %s%s", prefixString, outputString, newline ? "\n" : ""); - OutputDebugStringA(buf); - } -#endif - } -} - - -/** - * Return string version of GL error code. - */ -static const char * -error_string( GLenum error ) -{ - switch (error) { - case GL_NO_ERROR: - return "GL_NO_ERROR"; - case GL_INVALID_VALUE: - return "GL_INVALID_VALUE"; - case GL_INVALID_ENUM: - return "GL_INVALID_ENUM"; - case GL_INVALID_OPERATION: - return "GL_INVALID_OPERATION"; - case GL_STACK_OVERFLOW: - return "GL_STACK_OVERFLOW"; - case GL_STACK_UNDERFLOW: - return "GL_STACK_UNDERFLOW"; - case GL_OUT_OF_MEMORY: - return "GL_OUT_OF_MEMORY"; - case GL_TABLE_TOO_LARGE: - return "GL_TABLE_TOO_LARGE"; - case GL_INVALID_FRAMEBUFFER_OPERATION_EXT: - return "GL_INVALID_FRAMEBUFFER_OPERATION"; - default: - return "unknown"; - } -} - - -/** - * When a new type of error is recorded, print a message describing - * previous errors which were accumulated. - */ -static void -flush_delayed_errors( struct gl_context *ctx ) -{ - char s[MAXSTRING]; - - if (ctx->ErrorDebugCount) { - _mesa_snprintf(s, MAXSTRING, "%d similar %s errors", - ctx->ErrorDebugCount, - error_string(ctx->ErrorValue)); - - output_if_debug("Mesa", s, GL_TRUE); - - ctx->ErrorDebugCount = 0; - } -} - - -/** - * Report a warning (a recoverable error condition) to stderr if - * either DEBUG is defined or the MESA_DEBUG env var is set. - * - * \param ctx GL context. - * \param fmtString printf()-like format string. - */ -void -_mesa_warning( struct gl_context *ctx, const char *fmtString, ... ) -{ - char str[MAXSTRING]; - va_list args; - va_start( args, fmtString ); - (void) vsnprintf( str, MAXSTRING, fmtString, args ); - va_end( args ); - - if (ctx) - flush_delayed_errors( ctx ); - - output_if_debug("Mesa warning", str, GL_TRUE); -} - - -/** - * Report an internal implementation problem. - * Prints the message to stderr via fprintf(). - * - * \param ctx GL context. - * \param fmtString problem description string. - */ -void -_mesa_problem( const struct gl_context *ctx, const char *fmtString, ... ) -{ - va_list args; - char str[MAXSTRING]; - static int numCalls = 0; - - (void) ctx; - - if (numCalls < 50) { - numCalls++; - - va_start( args, fmtString ); - vsnprintf( str, MAXSTRING, fmtString, args ); - va_end( args ); - fprintf(stderr, "Mesa %s implementation error: %s\n", - MESA_VERSION_STRING, str); - fprintf(stderr, "Please report at bugs.freedesktop.org\n"); - } -} - - -/** - * Record an OpenGL state error. These usually occur when the user - * passes invalid parameters to a GL function. - * - * If debugging is enabled (either at compile-time via the DEBUG macro, or - * run-time via the MESA_DEBUG environment variable), report the error with - * _mesa_debug(). - * - * \param ctx the GL context. - * \param error the error value. - * \param fmtString printf() style format string, followed by optional args - */ -void -_mesa_error( struct gl_context *ctx, GLenum error, const char *fmtString, ... ) -{ - static GLint debug = -1; - - /* Check debug environment variable only once: - */ - if (debug == -1) { - const char *debugEnv = _mesa_getenv("MESA_DEBUG"); - -#ifdef DEBUG - if (debugEnv && strstr(debugEnv, "silent")) - debug = GL_FALSE; - else - debug = GL_TRUE; -#else - if (debugEnv) - debug = GL_TRUE; - else - debug = GL_FALSE; -#endif - } - - if (debug) { - if (ctx->ErrorValue == error && - ctx->ErrorDebugFmtString == fmtString) { - ctx->ErrorDebugCount++; - } - else { - char s[MAXSTRING], s2[MAXSTRING]; - va_list args; - - flush_delayed_errors( ctx ); - - va_start(args, fmtString); - vsnprintf(s, MAXSTRING, fmtString, args); - va_end(args); - - _mesa_snprintf(s2, MAXSTRING, "%s in %s", error_string(error), s); - output_if_debug("Mesa: User error", s2, GL_TRUE); - - ctx->ErrorDebugFmtString = fmtString; - ctx->ErrorDebugCount = 0; - } - } - - _mesa_record_error(ctx, error); -} - - -/** - * Report debug information. Print error message to stderr via fprintf(). - * No-op if DEBUG mode not enabled. - * - * \param ctx GL context. - * \param fmtString printf()-style format string, followed by optional args. - */ -void -_mesa_debug( const struct gl_context *ctx, const char *fmtString, ... ) -{ -//#ifdef DEBUG - char s[MAXSTRING]; - va_list args; - va_start(args, fmtString); - vsnprintf(s, MAXSTRING, fmtString, args); - va_end(args); - output_if_debug("Mesa", s, GL_FALSE); -//#endif /* DEBUG */ - (void) ctx; - (void) fmtString; -} - -/*@}*/ diff --git a/dll/opengl/mesa/main/imports.h b/dll/opengl/mesa/main/imports.h deleted file mode 100644 index d2ba34db888..00000000000 --- a/dll/opengl/mesa/main/imports.h +++ /dev/null @@ -1,645 +0,0 @@ -/* - * Mesa 3-D graphics library - * Version: 7.5 - * - * Copyright (C) 1999-2008 Brian Paul All Rights Reserved. - * - * Permission is hereby granted, free of charge, to any person obtaining a - * copy of this software and associated documentation files (the "Software"), - * to deal in the Software without restriction, including without limitation - * the rights to use, copy, modify, merge, publish, distribute, sublicense, - * and/or sell copies of the Software, and to permit persons to whom the - * Software is furnished to do so, subject to the following conditions: - * - * The above copyright notice and this permission notice shall be included - * in all copies or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS - * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL - * BRIAN PAUL BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN - * AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN - * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. - */ - - -/** - * \file imports.h - * Standard C library function wrappers. - * - * This file provides wrappers for all the standard C library functions - * like malloc(), free(), printf(), getenv(), etc. - */ - - -#ifndef IMPORTS_H -#define IMPORTS_H - - -#include "compiler.h" -#include "glheader.h" - - -#ifdef __cplusplus -extern "C" { -#endif - - -/**********************************************************************/ -/** Memory macros */ -/*@{*/ - -/** Allocate \p BYTES bytes */ -#define MALLOC(BYTES) malloc(BYTES) -/** Allocate and zero \p BYTES bytes */ -#define CALLOC(BYTES) calloc(1, BYTES) -/** Allocate a structure of type \p T */ -#define MALLOC_STRUCT(T) (struct T *) malloc(sizeof(struct T)) -/** Allocate and zero a structure of type \p T */ -#define CALLOC_STRUCT(T) (struct T *) calloc(1, sizeof(struct T)) -/** Free memory */ -#define FREE(PTR) free(PTR) - -/*@}*/ - - -/* - * For GL_ARB_vertex_buffer_object we need to treat vertex array pointers - * as offsets into buffer stores. Since the vertex array pointer and - * buffer store pointer are both pointers and we need to add them, we use - * this macro. - * Both pointers/offsets are expressed in bytes. - */ -#define ADD_POINTERS(A, B) ( (GLubyte *) (A) + (uintptr_t) (B) ) - - -/** - * Sometimes we treat GLfloats as GLints. On x86 systems, moving a float - * as a int (thereby using integer registers instead of FP registers) is - * a performance win. Typically, this can be done with ordinary casts. - * But with gcc's -fstrict-aliasing flag (which defaults to on in gcc 3.0) - * these casts generate warnings. - * The following union typedef is used to solve that. - */ -typedef union { GLfloat f; GLint i; } fi_type; - - - -/********************************************************************** - * Math macros - */ - -#define MAX_GLUSHORT 0xffff -#define MAX_GLUINT 0xffffffff - -/* Degrees to radians conversion: */ -#define DEG2RAD (M_PI/180.0) - - -/*** - *** SQRTF: single-precision square root - ***/ -#if 0 /* _mesa_sqrtf() not accurate enough - temporarily disabled */ -# define SQRTF(X) _mesa_sqrtf(X) -#else -# define SQRTF(X) (float) sqrt((float) (X)) -#endif - - -/*** - *** INV_SQRTF: single-precision inverse square root - ***/ -#if 0 -#define INV_SQRTF(X) _mesa_inv_sqrt(X) -#else -#define INV_SQRTF(X) (1.0F / SQRTF(X)) /* this is faster on a P4 */ -#endif - - -/** - * \name Work-arounds for platforms that lack C99 math functions - */ -/*@{*/ -#if (!defined(_XOPEN_SOURCE) || (_XOPEN_SOURCE < 600)) && !defined(_ISOC99_SOURCE) \ - && (!defined(__STDC_VERSION__) || (__STDC_VERSION__ < 199901L)) \ - && (!defined(_MSC_VER) || (_MSC_VER < 1400)) -#define acosf(f) ((float) acos(f)) -#define asinf(f) ((float) asin(f)) -#define atan2f(x,y) ((float) atan2(x,y)) -#define atanf(f) ((float) atan(f)) -#define cielf(f) ((float) ciel(f)) -#define cosf(f) ((float) cos(f)) -#define coshf(f) ((float) cosh(f)) -#define expf(f) ((float) exp(f)) -#define exp2f(f) ((float) exp2(f)) -#define floorf(f) ((float) floor(f)) -#define logf(f) ((float) log(f)) - -#ifdef ANDROID -#define log2f(f) (logf(f) * (float) (1.0 / M_LN2)) -#else -#define log2f(f) ((float) log2(f)) -#endif - -#define powf(x,y) ((float) pow(x,y)) -#define sinf(f) ((float) sin(f)) -#define sinhf(f) ((float) sinh(f)) -#define sqrtf(f) ((float) sqrt(f)) -#define tanf(f) ((float) tan(f)) -#define tanhf(f) ((float) tanh(f)) -#define acoshf(f) ((float) acosh(f)) -#define asinhf(f) ((float) asinh(f)) -#define atanhf(f) ((float) atanh(f)) -#endif - -#if defined(_MSC_VER) -static inline float truncf(float x) { return x < 0.0f ? ceilf(x) : floorf(x); } -static inline float exp2f(float x) { return powf(2.0f, x); } -static inline float log2f(float x) { return logf(x) * 1.442695041f; } -static inline float asinhf(float x) { return logf(x + sqrtf(x * x + 1.0f)); } -static inline float acoshf(float x) { return logf(x + sqrtf(x * x - 1.0f)); } -static inline float atanhf(float x) { return (logf(1.0f + x) - logf(1.0f - x)) / 2.0f; } -static inline int isblank(int ch) { return ch == ' ' || ch == '\t'; } -#define strtoll(p, e, b) _strtoi64(p, e, b) -#endif -/*@}*/ - -/*** - *** LOG2: Log base 2 of float - ***/ -#ifdef USE_IEEE -#if 0 -/* This is pretty fast, but not accurate enough (only 2 fractional bits). - * Based on code from http://www.stereopsis.com/log2.html - */ -static inline GLfloat LOG2(GLfloat x) -{ - const GLfloat y = x * x * x * x; - const GLuint ix = *((GLuint *) &y); - const GLuint exp = (ix >> 23) & 0xFF; - const GLint log2 = ((GLint) exp) - 127; - return (GLfloat) log2 * (1.0 / 4.0); /* 4, because of x^4 above */ -} -#endif -/* Pretty fast, and accurate. - * Based on code from http://www.flipcode.com/totd/ - */ -static inline GLfloat LOG2(GLfloat val) -{ - fi_type num; - GLint log_2; - num.f = val; - log_2 = ((num.i >> 23) & 255) - 128; - num.i &= ~(255 << 23); - num.i += 127 << 23; - num.f = ((-1.0f/3) * num.f + 2) * num.f - 2.0f/3; - return num.f + log_2; -} -#else -/* - * NOTE: log_base_2(x) = log(x) / log(2) - * NOTE: 1.442695 = 1/log(2). - */ -#define LOG2(x) ((GLfloat) (log(x) * 1.442695F)) -#endif - - -/*** - *** IS_INF_OR_NAN: test if float is infinite or NaN - ***/ -#ifdef USE_IEEE -static inline int IS_INF_OR_NAN( float x ) -{ - fi_type tmp; - tmp.f = x; - return !(int)((unsigned int)((tmp.i & 0x7fffffff)-0x7f800000) >> 31); -} -#elif defined(isfinite) -#define IS_INF_OR_NAN(x) (!isfinite(x)) -#elif defined(finite) -#define IS_INF_OR_NAN(x) (!finite(x)) -#elif defined(__VMS) -#define IS_INF_OR_NAN(x) (!finite(x)) -#elif defined(__STDC_VERSION__) && __STDC_VERSION__ >= 199901L -#define IS_INF_OR_NAN(x) (!isfinite(x)) -#else -#define IS_INF_OR_NAN(x) (!finite(x)) -#endif - - -/*** - *** IS_NEGATIVE: test if float is negative - ***/ -#if defined(USE_IEEE) -static inline int GET_FLOAT_BITS( float x ) -{ - fi_type fi; - fi.f = x; - return fi.i; -} -#define IS_NEGATIVE(x) (GET_FLOAT_BITS(x) < 0) -#else -#define IS_NEGATIVE(x) (x < 0.0F) -#endif - - -/*** - *** DIFFERENT_SIGNS: test if two floats have opposite signs - ***/ -#if defined(USE_IEEE) -#define DIFFERENT_SIGNS(x,y) ((GET_FLOAT_BITS(x) ^ GET_FLOAT_BITS(y)) & (1<<31)) -#else -/* Could just use (x*y<0) except for the flatshading requirements. - * Maybe there's a better way? - */ -#define DIFFERENT_SIGNS(x,y) ((x) * (y) <= 0.0F && (x) - (y) != 0.0F) -#endif - - -/*** - *** CEILF: ceiling of float - *** FLOORF: floor of float - *** FABSF: absolute value of float - *** LOGF: the natural logarithm (base e) of the value - *** EXPF: raise e to the value - *** LDEXPF: multiply value by an integral power of two - *** FREXPF: extract mantissa and exponent from value - ***/ -#if defined(__gnu_linux__) -/* C99 functions */ -#define CEILF(x) ceilf(x) -#define FLOORF(x) floorf(x) -#define FABSF(x) fabsf(x) -#define LOGF(x) logf(x) -#define EXPF(x) expf(x) -#define LDEXPF(x,y) ldexpf(x,y) -#define FREXPF(x,y) frexpf(x,y) -#else -#define CEILF(x) ((GLfloat) ceil(x)) -#define FLOORF(x) ((GLfloat) floor(x)) -#define FABSF(x) ((GLfloat) fabs(x)) -#define LOGF(x) ((GLfloat) log(x)) -#define EXPF(x) ((GLfloat) exp(x)) -#define LDEXPF(x,y) ((GLfloat) ldexp(x,y)) -#define FREXPF(x,y) ((GLfloat) frexp(x,y)) -#endif - - -/*** - *** IROUND: return (as an integer) float rounded to nearest integer - ***/ -#if defined(USE_X86_ASM) && defined(__GNUC__) && defined(__i386__) -static inline int iround(float f) -{ - int r; - __asm__ ("fistpl %0" : "=m" (r) : "t" (f) : "st"); - return r; -} -#define IROUND(x) iround(x) -#elif defined(USE_X86_ASM) && defined(_MSC_VER) -static inline int iround(float f) -{ - int r; - _asm { - fld f - fistp r - } - return r; -} -#define IROUND(x) iround(x) -#elif defined(__WATCOMC__) && defined(__386__) -long iround(float f); -#pragma aux iround = \ - "push eax" \ - "fistp dword ptr [esp]" \ - "pop eax" \ - parm [8087] \ - value [eax] \ - modify exact [eax]; -#define IROUND(x) iround(x) -#else -#define IROUND(f) ((int) (((f) >= 0.0F) ? ((f) + 0.5F) : ((f) - 0.5F))) -#endif - -#define IROUND64(f) ((GLint64) (((f) >= 0.0F) ? ((f) + 0.5F) : ((f) - 0.5F))) - -/*** - *** IROUND_POS: return (as an integer) positive float rounded to nearest int - ***/ -#ifdef DEBUG -#define IROUND_POS(f) (assert((f) >= 0.0F), IROUND(f)) -#else -#define IROUND_POS(f) (IROUND(f)) -#endif - - -/*** - *** IFLOOR: return (as an integer) floor of float - ***/ -#if defined(USE_X86_ASM) && defined(__GNUC__) && defined(__i386__) -/* - * IEEE floor for computers that round to nearest or even. - * 'f' must be between -4194304 and 4194303. - * This floor operation is done by "(iround(f + .5) + iround(f - .5)) >> 1", - * but uses some IEEE specific tricks for better speed. - * Contributed by Josh Vanderhoof - */ -static inline int ifloor(float f) -{ - int ai, bi; - double af, bf; - af = (3 << 22) + 0.5 + (double)f; - bf = (3 << 22) + 0.5 - (double)f; - /* GCC generates an extra fstp/fld without this. */ - __asm__ ("fstps %0" : "=m" (ai) : "t" (af) : "st"); - __asm__ ("fstps %0" : "=m" (bi) : "t" (bf) : "st"); - return (ai - bi) >> 1; -} -#define IFLOOR(x) ifloor(x) -#elif defined(USE_IEEE) -static inline int ifloor(float f) -{ - int ai, bi; - double af, bf; - fi_type u; - - af = (3 << 22) + 0.5 + (double)f; - bf = (3 << 22) + 0.5 - (double)f; - u.f = (float) af; ai = u.i; - u.f = (float) bf; bi = u.i; - return (ai - bi) >> 1; -} -#define IFLOOR(x) ifloor(x) -#else -static inline int ifloor(float f) -{ - int i = IROUND(f); - return (i > f) ? i - 1 : i; -} -#define IFLOOR(x) ifloor(x) -#endif - - -/*** - *** ICEIL: return (as an integer) ceiling of float - ***/ -#if defined(USE_X86_ASM) && defined(__GNUC__) && defined(__i386__) -/* - * IEEE ceil for computers that round to nearest or even. - * 'f' must be between -4194304 and 4194303. - * This ceil operation is done by "(iround(f + .5) + iround(f - .5) + 1) >> 1", - * but uses some IEEE specific tricks for better speed. - * Contributed by Josh Vanderhoof - */ -static inline int iceil(float f) -{ - int ai, bi; - double af, bf; - af = (3 << 22) + 0.5 + (double)f; - bf = (3 << 22) + 0.5 - (double)f; - /* GCC generates an extra fstp/fld without this. */ - __asm__ ("fstps %0" : "=m" (ai) : "t" (af) : "st"); - __asm__ ("fstps %0" : "=m" (bi) : "t" (bf) : "st"); - return (ai - bi + 1) >> 1; -} -#define ICEIL(x) iceil(x) -#elif defined(USE_IEEE) -static inline int iceil(float f) -{ - int ai, bi; - double af, bf; - fi_type u; - af = (3 << 22) + 0.5 + (double)f; - bf = (3 << 22) + 0.5 - (double)f; - u.f = (float) af; ai = u.i; - u.f = (float) bf; bi = u.i; - return (ai - bi + 1) >> 1; -} -#define ICEIL(x) iceil(x) -#else -static inline int iceil(float f) -{ - int i = IROUND(f); - return (i < f) ? i + 1 : i; -} -#define ICEIL(x) iceil(x) -#endif - - -/** - * Is x a power of two? - */ -static inline int -_mesa_is_pow_two(int x) -{ - return !(x & (x - 1)); -} - -/** - * Round given integer to next higer power of two - * If X is zero result is undefined. - * - * Source for the fallback implementation is - * Sean Eron Anderson's webpage "Bit Twiddling Hacks" - * http://graphics.stanford.edu/~seander/bithacks.html - * - * When using builtin function have to do some work - * for case when passed values 1 to prevent hiting - * undefined result from __builtin_clz. Undefined - * results would be different depending on optimization - * level used for build. - */ -static inline int32_t -_mesa_next_pow_two_32(uint32_t x) -{ -#if defined(__GNUC__) && \ - ((__GNUC__ * 100 + __GNUC_MINOR__) >= 304) /* gcc 3.4 or later */ - uint32_t y = (x != 1); - return (1 + y) << ((__builtin_clz(x - y) ^ 31) ); -#else - x--; - x |= x >> 1; - x |= x >> 2; - x |= x >> 4; - x |= x >> 8; - x |= x >> 16; - x++; - return x; -#endif -} - -static inline int64_t -_mesa_next_pow_two_64(uint64_t x) -{ -#if defined(__GNUC__) && \ - ((__GNUC__ * 100 + __GNUC_MINOR__) >= 304) /* gcc 3.4 or later */ - uint64_t y = (x != 1); - if (sizeof(x) == sizeof(long)) - return (1 + y) << ((__builtin_clzl(x - y) ^ 63)); - else - return (1 + y) << ((__builtin_clzll(x - y) ^ 63)); -#else - x--; - x |= x >> 1; - x |= x >> 2; - x |= x >> 4; - x |= x >> 8; - x |= x >> 16; - x |= x >> 32; - x++; - return x; -#endif -} - - -/* - * Returns the floor form of binary logarithm for a 32-bit integer. - */ -static inline GLuint -_mesa_logbase2(GLuint n) -{ -#if defined(__GNUC__) && \ - ((__GNUC__ * 100 + __GNUC_MINOR__) >= 304) /* gcc 3.4 or later */ - return (31 - __builtin_clz(n | 1)); -#else - GLuint pos = 0; - if (n >= 1<<16) { n >>= 16; pos += 16; } - if (n >= 1<< 8) { n >>= 8; pos += 8; } - if (n >= 1<< 4) { n >>= 4; pos += 4; } - if (n >= 1<< 2) { n >>= 2; pos += 2; } - if (n >= 1<< 1) { pos += 1; } - return pos; -#endif -} - - -/** - * Return 1 if this is a little endian machine, 0 if big endian. - */ -static inline GLboolean -_mesa_little_endian(void) -{ - const GLuint ui = 1; /* intentionally not static */ - return *((const GLubyte *) &ui); -} - - - -/********************************************************************** - * Functions - */ - -extern void * -_mesa_align_malloc( size_t bytes, unsigned long alignment ); - -extern void * -_mesa_align_calloc( size_t bytes, unsigned long alignment ); - -extern void -_mesa_align_free( void *ptr ); - -extern void * -_mesa_align_realloc(void *oldBuffer, size_t oldSize, size_t newSize, - unsigned long alignment); - -extern void * -_mesa_exec_malloc( GLuint size ); - -extern void -_mesa_exec_free( void *addr ); - -extern void * -_mesa_realloc( void *oldBuffer, size_t oldSize, size_t newSize ); - -extern void -_mesa_memset16( unsigned short *dst, unsigned short val, size_t n ); - -extern double -_mesa_sqrtd(double x); - -extern float -_mesa_sqrtf(float x); - -extern float -_mesa_inv_sqrtf(float x); - -extern void -_mesa_init_sqrt_table(void); - -#ifdef __GNUC__ - -#if defined(__MINGW32__) || defined(__CYGWIN__) || defined(ANDROID) || defined(__APPLE__) -#define ffs __builtin_ffs -#define ffsll __builtin_ffsll -#endif - -#define _mesa_ffs(i) ffs(i) -#define _mesa_ffsll(i) ffsll(i) - -#if ((__GNUC__ * 100 + __GNUC_MINOR__) >= 304) /* gcc 3.4 or later */ -#define _mesa_bitcount(i) __builtin_popcount(i) -#define _mesa_bitcount_64(i) __builtin_popcountll(i) -#else -extern unsigned int -_mesa_bitcount(unsigned int n); -extern unsigned int -_mesa_bitcount_64(uint64_t n); -#endif - -#else -extern int -_mesa_ffs(int32_t i); - -extern int -_mesa_ffsll(int64_t i); - -extern unsigned int -_mesa_bitcount(unsigned int n); -#endif - - -extern void * -_mesa_bsearch( const void *key, const void *base, size_t nmemb, size_t size, - int (*compar)(const void *, const void *) ); - -extern char * -_mesa_getenv( const char *var ); - -extern char * -_mesa_strdup( const char *s ); - -extern float -_mesa_strtof( const char *s, char **end ); - -extern unsigned int -_mesa_str_checksum(const char *str); - -extern int -_mesa_snprintf( char *str, size_t size, const char *fmt, ... ) PRINTFLIKE(3, 4); - -struct gl_context; - -extern void -_mesa_warning( struct gl_context *gc, const char *fmtString, ... ) PRINTFLIKE(2, 3); - -extern void -_mesa_problem( const struct gl_context *ctx, const char *fmtString, ... ) PRINTFLIKE(2, 3); - -extern void -_mesa_error( struct gl_context *ctx, GLenum error, const char *fmtString, ... ) PRINTFLIKE(3, 4); - -extern void -_mesa_debug( const struct gl_context *ctx, const char *fmtString, ... ) PRINTFLIKE(2, 3); - - -#if defined(_MSC_VER) && !defined(snprintf) -#define snprintf _snprintf -#endif - - -#ifdef __cplusplus -} -#endif - - -#endif /* IMPORTS_H */ diff --git a/dll/opengl/mesa/main/light.c b/dll/opengl/mesa/main/light.c deleted file mode 100644 index beaa8aa9979..00000000000 --- a/dll/opengl/mesa/main/light.c +++ /dev/null @@ -1,1357 +0,0 @@ -/* - * Mesa 3-D graphics library - * Version: 7.5 - * - * Copyright (C) 1999-2008 Brian Paul All Rights Reserved. - * Copyright (C) 2009 VMware, Inc. All Rights Reserved. - * - * Permission is hereby granted, free of charge, to any person obtaining a - * copy of this software and associated documentation files (the "Software"), - * to deal in the Software without restriction, including without limitation - * the rights to use, copy, modify, merge, publish, distribute, sublicense, - * and/or sell copies of the Software, and to permit persons to whom the - * Software is furnished to do so, subject to the following conditions: - * - * The above copyright notice and this permission notice shall be included - * in all copies or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS - * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL - * BRIAN PAUL BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN - * AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN - * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. - */ - -#include - -void GLAPIENTRY -_mesa_ShadeModel( GLenum mode ) -{ - GET_CURRENT_CONTEXT(ctx); - ASSERT_OUTSIDE_BEGIN_END(ctx); - - if (MESA_VERBOSE & VERBOSE_API) - _mesa_debug(ctx, "glShadeModel %s\n", _mesa_lookup_enum_by_nr(mode)); - - if (mode != GL_FLAT && mode != GL_SMOOTH) { - _mesa_error(ctx, GL_INVALID_ENUM, "glShadeModel"); - return; - } - - if (ctx->Light.ShadeModel == mode) - return; - - FLUSH_VERTICES(ctx, _NEW_LIGHT); - ctx->Light.ShadeModel = mode; - if (mode == GL_FLAT) - ctx->_TriangleCaps |= DD_FLATSHADE; - else - ctx->_TriangleCaps &= ~DD_FLATSHADE; - - if (ctx->Driver.ShadeModel) - ctx->Driver.ShadeModel( ctx, mode ); -} - -/** - * Helper function called by _mesa_Lightfv and _mesa_PopAttrib to set - * per-light state. - * For GL_POSITION and GL_SPOT_DIRECTION the params position/direction - * will have already been transformed by the modelview matrix! - * Also, all error checking should have already been done. - */ -void -_mesa_light(struct gl_context *ctx, GLuint lnum, GLenum pname, const GLfloat *params) -{ - struct gl_light *light; - - ASSERT(lnum < MAX_LIGHTS); - light = &ctx->Light.Light[lnum]; - - switch (pname) { - case GL_AMBIENT: - if (TEST_EQ_4V(light->Ambient, params)) - return; - FLUSH_VERTICES(ctx, _NEW_LIGHT); - COPY_4V( light->Ambient, params ); - break; - case GL_DIFFUSE: - if (TEST_EQ_4V(light->Diffuse, params)) - return; - FLUSH_VERTICES(ctx, _NEW_LIGHT); - COPY_4V( light->Diffuse, params ); - break; - case GL_SPECULAR: - if (TEST_EQ_4V(light->Specular, params)) - return; - FLUSH_VERTICES(ctx, _NEW_LIGHT); - COPY_4V( light->Specular, params ); - break; - case GL_POSITION: - /* NOTE: position has already been transformed by ModelView! */ - if (TEST_EQ_4V(light->EyePosition, params)) - return; - FLUSH_VERTICES(ctx, _NEW_LIGHT); - COPY_4V(light->EyePosition, params); - if (light->EyePosition[3] != 0.0F) - light->_Flags |= LIGHT_POSITIONAL; - else - light->_Flags &= ~LIGHT_POSITIONAL; - break; - case GL_SPOT_DIRECTION: - /* NOTE: Direction already transformed by inverse ModelView! */ - if (TEST_EQ_3V(light->SpotDirection, params)) - return; - FLUSH_VERTICES(ctx, _NEW_LIGHT); - COPY_3V(light->SpotDirection, params); - break; - case GL_SPOT_EXPONENT: - ASSERT(params[0] >= 0.0); - ASSERT(params[0] <= ctx->Const.MaxSpotExponent); - if (light->SpotExponent == params[0]) - return; - FLUSH_VERTICES(ctx, _NEW_LIGHT); - light->SpotExponent = params[0]; - _mesa_invalidate_spot_exp_table(light); - break; - case GL_SPOT_CUTOFF: - ASSERT(params[0] == 180.0 || (params[0] >= 0.0 && params[0] <= 90.0)); - if (light->SpotCutoff == params[0]) - return; - FLUSH_VERTICES(ctx, _NEW_LIGHT); - light->SpotCutoff = params[0]; - light->_CosCutoffNeg = (GLfloat) (cos(light->SpotCutoff * DEG2RAD)); - if (light->_CosCutoffNeg < 0) - light->_CosCutoff = 0; - else - light->_CosCutoff = light->_CosCutoffNeg; - if (light->SpotCutoff != 180.0F) - light->_Flags |= LIGHT_SPOT; - else - light->_Flags &= ~LIGHT_SPOT; - break; - case GL_CONSTANT_ATTENUATION: - ASSERT(params[0] >= 0.0); - if (light->ConstantAttenuation == params[0]) - return; - FLUSH_VERTICES(ctx, _NEW_LIGHT); - light->ConstantAttenuation = params[0]; - break; - case GL_LINEAR_ATTENUATION: - ASSERT(params[0] >= 0.0); - if (light->LinearAttenuation == params[0]) - return; - FLUSH_VERTICES(ctx, _NEW_LIGHT); - light->LinearAttenuation = params[0]; - break; - case GL_QUADRATIC_ATTENUATION: - ASSERT(params[0] >= 0.0); - if (light->QuadraticAttenuation == params[0]) - return; - FLUSH_VERTICES(ctx, _NEW_LIGHT); - light->QuadraticAttenuation = params[0]; - break; - default: - _mesa_problem(ctx, "Unexpected pname in _mesa_light()"); - return; - } - - if (ctx->Driver.Lightfv) - ctx->Driver.Lightfv( ctx, GL_LIGHT0 + lnum, pname, params ); -} - - -void GLAPIENTRY -_mesa_Lightf( GLenum light, GLenum pname, GLfloat param ) -{ - GLfloat fparam[4]; - fparam[0] = param; - fparam[1] = fparam[2] = fparam[3] = 0.0F; - _mesa_Lightfv( light, pname, fparam ); -} - - -void GLAPIENTRY -_mesa_Lightfv( GLenum light, GLenum pname, const GLfloat *params ) -{ - GET_CURRENT_CONTEXT(ctx); - GLint i = (GLint) (light - GL_LIGHT0); - GLfloat temp[4]; - ASSERT_OUTSIDE_BEGIN_END(ctx); - - if (i < 0 || i >= (GLint) ctx->Const.MaxLights) { - _mesa_error( ctx, GL_INVALID_ENUM, "glLight(light=0x%x)", light ); - return; - } - - /* do particular error checks, transformations */ - switch (pname) { - case GL_AMBIENT: - case GL_DIFFUSE: - case GL_SPECULAR: - /* nothing */ - break; - case GL_POSITION: - /* transform position by ModelView matrix */ - TRANSFORM_POINT(temp, ctx->ModelviewMatrixStack.Top->m, params); - params = temp; - break; - case GL_SPOT_DIRECTION: - /* transform direction by inverse modelview */ - if (_math_matrix_is_dirty(ctx->ModelviewMatrixStack.Top)) { - _math_matrix_analyse(ctx->ModelviewMatrixStack.Top); - } - TRANSFORM_DIRECTION(temp, params, ctx->ModelviewMatrixStack.Top->m); - params = temp; - break; - case GL_SPOT_EXPONENT: - if (params[0] < 0.0 || params[0] > ctx->Const.MaxSpotExponent) { - _mesa_error(ctx, GL_INVALID_VALUE, "glLight"); - return; - } - break; - case GL_SPOT_CUTOFF: - if ((params[0] < 0.0 || params[0] > 90.0) && params[0] != 180.0) { - _mesa_error(ctx, GL_INVALID_VALUE, "glLight"); - return; - } - break; - case GL_CONSTANT_ATTENUATION: - if (params[0] < 0.0) { - _mesa_error(ctx, GL_INVALID_VALUE, "glLight"); - return; - } - break; - case GL_LINEAR_ATTENUATION: - if (params[0] < 0.0) { - _mesa_error(ctx, GL_INVALID_VALUE, "glLight"); - return; - } - break; - case GL_QUADRATIC_ATTENUATION: - if (params[0] < 0.0) { - _mesa_error(ctx, GL_INVALID_VALUE, "glLight"); - return; - } - break; - default: - _mesa_error(ctx, GL_INVALID_ENUM, "glLight(pname=0x%x)", pname); - return; - } - - _mesa_light(ctx, i, pname, params); -} - - -void GLAPIENTRY -_mesa_Lighti( GLenum light, GLenum pname, GLint param ) -{ - GLint iparam[4]; - iparam[0] = param; - iparam[1] = iparam[2] = iparam[3] = 0; - _mesa_Lightiv( light, pname, iparam ); -} - - -void GLAPIENTRY -_mesa_Lightiv( GLenum light, GLenum pname, const GLint *params ) -{ - GLfloat fparam[4]; - - switch (pname) { - case GL_AMBIENT: - case GL_DIFFUSE: - case GL_SPECULAR: - fparam[0] = INT_TO_FLOAT( params[0] ); - fparam[1] = INT_TO_FLOAT( params[1] ); - fparam[2] = INT_TO_FLOAT( params[2] ); - fparam[3] = INT_TO_FLOAT( params[3] ); - break; - case GL_POSITION: - fparam[0] = (GLfloat) params[0]; - fparam[1] = (GLfloat) params[1]; - fparam[2] = (GLfloat) params[2]; - fparam[3] = (GLfloat) params[3]; - break; - case GL_SPOT_DIRECTION: - fparam[0] = (GLfloat) params[0]; - fparam[1] = (GLfloat) params[1]; - fparam[2] = (GLfloat) params[2]; - break; - case GL_SPOT_EXPONENT: - case GL_SPOT_CUTOFF: - case GL_CONSTANT_ATTENUATION: - case GL_LINEAR_ATTENUATION: - case GL_QUADRATIC_ATTENUATION: - fparam[0] = (GLfloat) params[0]; - break; - default: - /* error will be caught later in gl_Lightfv */ - ; - } - - _mesa_Lightfv( light, pname, fparam ); -} - - - -void GLAPIENTRY -_mesa_GetLightfv( GLenum light, GLenum pname, GLfloat *params ) -{ - GET_CURRENT_CONTEXT(ctx); - GLint l = (GLint) (light - GL_LIGHT0); - ASSERT_OUTSIDE_BEGIN_END(ctx); - - if (l < 0 || l >= (GLint) ctx->Const.MaxLights) { - _mesa_error( ctx, GL_INVALID_ENUM, "glGetLightfv" ); - return; - } - - switch (pname) { - case GL_AMBIENT: - COPY_4V( params, ctx->Light.Light[l].Ambient ); - break; - case GL_DIFFUSE: - COPY_4V( params, ctx->Light.Light[l].Diffuse ); - break; - case GL_SPECULAR: - COPY_4V( params, ctx->Light.Light[l].Specular ); - break; - case GL_POSITION: - COPY_4V( params, ctx->Light.Light[l].EyePosition ); - break; - case GL_SPOT_DIRECTION: - COPY_3V( params, ctx->Light.Light[l].SpotDirection ); - break; - case GL_SPOT_EXPONENT: - params[0] = ctx->Light.Light[l].SpotExponent; - break; - case GL_SPOT_CUTOFF: - params[0] = ctx->Light.Light[l].SpotCutoff; - break; - case GL_CONSTANT_ATTENUATION: - params[0] = ctx->Light.Light[l].ConstantAttenuation; - break; - case GL_LINEAR_ATTENUATION: - params[0] = ctx->Light.Light[l].LinearAttenuation; - break; - case GL_QUADRATIC_ATTENUATION: - params[0] = ctx->Light.Light[l].QuadraticAttenuation; - break; - default: - _mesa_error( ctx, GL_INVALID_ENUM, "glGetLightfv" ); - break; - } -} - - -void GLAPIENTRY -_mesa_GetLightiv( GLenum light, GLenum pname, GLint *params ) -{ - GET_CURRENT_CONTEXT(ctx); - GLint l = (GLint) (light - GL_LIGHT0); - ASSERT_OUTSIDE_BEGIN_END(ctx); - - if (l < 0 || l >= (GLint) ctx->Const.MaxLights) { - _mesa_error( ctx, GL_INVALID_ENUM, "glGetLightiv" ); - return; - } - - switch (pname) { - case GL_AMBIENT: - params[0] = FLOAT_TO_INT(ctx->Light.Light[l].Ambient[0]); - params[1] = FLOAT_TO_INT(ctx->Light.Light[l].Ambient[1]); - params[2] = FLOAT_TO_INT(ctx->Light.Light[l].Ambient[2]); - params[3] = FLOAT_TO_INT(ctx->Light.Light[l].Ambient[3]); - break; - case GL_DIFFUSE: - params[0] = FLOAT_TO_INT(ctx->Light.Light[l].Diffuse[0]); - params[1] = FLOAT_TO_INT(ctx->Light.Light[l].Diffuse[1]); - params[2] = FLOAT_TO_INT(ctx->Light.Light[l].Diffuse[2]); - params[3] = FLOAT_TO_INT(ctx->Light.Light[l].Diffuse[3]); - break; - case GL_SPECULAR: - params[0] = FLOAT_TO_INT(ctx->Light.Light[l].Specular[0]); - params[1] = FLOAT_TO_INT(ctx->Light.Light[l].Specular[1]); - params[2] = FLOAT_TO_INT(ctx->Light.Light[l].Specular[2]); - params[3] = FLOAT_TO_INT(ctx->Light.Light[l].Specular[3]); - break; - case GL_POSITION: - params[0] = (GLint) ctx->Light.Light[l].EyePosition[0]; - params[1] = (GLint) ctx->Light.Light[l].EyePosition[1]; - params[2] = (GLint) ctx->Light.Light[l].EyePosition[2]; - params[3] = (GLint) ctx->Light.Light[l].EyePosition[3]; - break; - case GL_SPOT_DIRECTION: - params[0] = (GLint) ctx->Light.Light[l].SpotDirection[0]; - params[1] = (GLint) ctx->Light.Light[l].SpotDirection[1]; - params[2] = (GLint) ctx->Light.Light[l].SpotDirection[2]; - break; - case GL_SPOT_EXPONENT: - params[0] = (GLint) ctx->Light.Light[l].SpotExponent; - break; - case GL_SPOT_CUTOFF: - params[0] = (GLint) ctx->Light.Light[l].SpotCutoff; - break; - case GL_CONSTANT_ATTENUATION: - params[0] = (GLint) ctx->Light.Light[l].ConstantAttenuation; - break; - case GL_LINEAR_ATTENUATION: - params[0] = (GLint) ctx->Light.Light[l].LinearAttenuation; - break; - case GL_QUADRATIC_ATTENUATION: - params[0] = (GLint) ctx->Light.Light[l].QuadraticAttenuation; - break; - default: - _mesa_error( ctx, GL_INVALID_ENUM, "glGetLightiv" ); - break; - } -} - - - -/**********************************************************************/ -/*** Light Model ***/ -/**********************************************************************/ - - -void GLAPIENTRY -_mesa_LightModelfv( GLenum pname, const GLfloat *params ) -{ - GLboolean newbool; - GET_CURRENT_CONTEXT(ctx); - ASSERT_OUTSIDE_BEGIN_END(ctx); - - switch (pname) { - case GL_LIGHT_MODEL_AMBIENT: - if (TEST_EQ_4V( ctx->Light.Model.Ambient, params )) - return; - FLUSH_VERTICES(ctx, _NEW_LIGHT); - COPY_4V( ctx->Light.Model.Ambient, params ); - break; - case GL_LIGHT_MODEL_LOCAL_VIEWER: - newbool = (params[0]!=0.0); - if (ctx->Light.Model.LocalViewer == newbool) - return; - FLUSH_VERTICES(ctx, _NEW_LIGHT); - ctx->Light.Model.LocalViewer = newbool; - break; - case GL_LIGHT_MODEL_TWO_SIDE: - newbool = (params[0]!=0.0); - if (ctx->Light.Model.TwoSide == newbool) - return; - FLUSH_VERTICES(ctx, _NEW_LIGHT); - ctx->Light.Model.TwoSide = newbool; - if (ctx->Light.Enabled && ctx->Light.Model.TwoSide) - ctx->_TriangleCaps |= DD_TRI_LIGHT_TWOSIDE; - else - ctx->_TriangleCaps &= ~DD_TRI_LIGHT_TWOSIDE; - break; - default: - _mesa_error( ctx, GL_INVALID_ENUM, "glLightModel(pname=0x%x)", pname ); - break; - } - - if (ctx->Driver.LightModelfv) - ctx->Driver.LightModelfv( ctx, pname, params ); -} - - -void GLAPIENTRY -_mesa_LightModeliv( GLenum pname, const GLint *params ) -{ - GLfloat fparam[4]; - - switch (pname) { - case GL_LIGHT_MODEL_AMBIENT: - fparam[0] = INT_TO_FLOAT( params[0] ); - fparam[1] = INT_TO_FLOAT( params[1] ); - fparam[2] = INT_TO_FLOAT( params[2] ); - fparam[3] = INT_TO_FLOAT( params[3] ); - break; - case GL_LIGHT_MODEL_LOCAL_VIEWER: - case GL_LIGHT_MODEL_TWO_SIDE: - case GL_LIGHT_MODEL_COLOR_CONTROL: - fparam[0] = (GLfloat) params[0]; - break; - default: - /* Error will be caught later in gl_LightModelfv */ - ASSIGN_4V(fparam, 0.0F, 0.0F, 0.0F, 0.0F); - } - _mesa_LightModelfv( pname, fparam ); -} - - -void GLAPIENTRY -_mesa_LightModeli( GLenum pname, GLint param ) -{ - GLint iparam[4]; - iparam[0] = param; - iparam[1] = iparam[2] = iparam[3] = 0; - _mesa_LightModeliv( pname, iparam ); -} - - -void GLAPIENTRY -_mesa_LightModelf( GLenum pname, GLfloat param ) -{ - GLfloat fparam[4]; - fparam[0] = param; - fparam[1] = fparam[2] = fparam[3] = 0.0F; - _mesa_LightModelfv( pname, fparam ); -} - - - -/********** MATERIAL **********/ - - -/* - * Given a face and pname value (ala glColorMaterial), compute a bitmask - * of the targeted material values. - */ -GLuint -_mesa_material_bitmask( struct gl_context *ctx, GLenum face, GLenum pname, - GLuint legal, const char *where ) -{ - GLuint bitmask = 0; - - /* Make a bitmask indicating what material attribute(s) we're updating */ - switch (pname) { - case GL_EMISSION: - bitmask |= MAT_BIT_FRONT_EMISSION | MAT_BIT_BACK_EMISSION; - break; - case GL_AMBIENT: - bitmask |= MAT_BIT_FRONT_AMBIENT | MAT_BIT_BACK_AMBIENT; - break; - case GL_DIFFUSE: - bitmask |= MAT_BIT_FRONT_DIFFUSE | MAT_BIT_BACK_DIFFUSE; - break; - case GL_SPECULAR: - bitmask |= MAT_BIT_FRONT_SPECULAR | MAT_BIT_BACK_SPECULAR; - break; - case GL_SHININESS: - bitmask |= MAT_BIT_FRONT_SHININESS | MAT_BIT_BACK_SHININESS; - break; - case GL_AMBIENT_AND_DIFFUSE: - bitmask |= MAT_BIT_FRONT_AMBIENT | MAT_BIT_BACK_AMBIENT; - bitmask |= MAT_BIT_FRONT_DIFFUSE | MAT_BIT_BACK_DIFFUSE; - break; - case GL_COLOR_INDEXES: - bitmask |= MAT_BIT_FRONT_INDEXES | MAT_BIT_BACK_INDEXES; - break; - default: - _mesa_error( ctx, GL_INVALID_ENUM, "%s", where ); - return 0; - } - - if (face==GL_FRONT) { - bitmask &= FRONT_MATERIAL_BITS; - } - else if (face==GL_BACK) { - bitmask &= BACK_MATERIAL_BITS; - } - else if (face != GL_FRONT_AND_BACK) { - _mesa_error( ctx, GL_INVALID_ENUM, "%s", where ); - return 0; - } - - if (bitmask & ~legal) { - _mesa_error( ctx, GL_INVALID_ENUM, "%s", where ); - return 0; - } - - return bitmask; -} - - - -/* Update derived values following a change in ctx->Light.Material - */ -void -_mesa_update_material( struct gl_context *ctx, GLuint bitmask ) -{ - struct gl_light *light, *list = &ctx->Light.EnabledList; - GLfloat (*mat)[4] = ctx->Light.Material.Attrib; - - if (MESA_VERBOSE & VERBOSE_MATERIAL) - _mesa_debug(ctx, "_mesa_update_material, mask 0x%x\n", bitmask); - - if (!bitmask) - return; - - /* update material ambience */ - if (bitmask & MAT_BIT_FRONT_AMBIENT) { - foreach (light, list) { - SCALE_3V( light->_MatAmbient[0], light->Ambient, - mat[MAT_ATTRIB_FRONT_AMBIENT]); - } - } - - if (bitmask & MAT_BIT_BACK_AMBIENT) { - foreach (light, list) { - SCALE_3V( light->_MatAmbient[1], light->Ambient, - mat[MAT_ATTRIB_BACK_AMBIENT]); - } - } - - /* update BaseColor = emission + scene's ambience * material's ambience */ - if (bitmask & (MAT_BIT_FRONT_EMISSION | MAT_BIT_FRONT_AMBIENT)) { - COPY_3V( ctx->Light._BaseColor[0], mat[MAT_ATTRIB_FRONT_EMISSION] ); - ACC_SCALE_3V( ctx->Light._BaseColor[0], mat[MAT_ATTRIB_FRONT_AMBIENT], - ctx->Light.Model.Ambient ); - } - - if (bitmask & (MAT_BIT_BACK_EMISSION | MAT_BIT_BACK_AMBIENT)) { - COPY_3V( ctx->Light._BaseColor[1], mat[MAT_ATTRIB_BACK_EMISSION] ); - ACC_SCALE_3V( ctx->Light._BaseColor[1], mat[MAT_ATTRIB_BACK_AMBIENT], - ctx->Light.Model.Ambient ); - } - - /* update material diffuse values */ - if (bitmask & MAT_BIT_FRONT_DIFFUSE) { - foreach (light, list) { - SCALE_3V( light->_MatDiffuse[0], light->Diffuse, - mat[MAT_ATTRIB_FRONT_DIFFUSE] ); - } - } - - if (bitmask & MAT_BIT_BACK_DIFFUSE) { - foreach (light, list) { - SCALE_3V( light->_MatDiffuse[1], light->Diffuse, - mat[MAT_ATTRIB_BACK_DIFFUSE] ); - } - } - - /* update material specular values */ - if (bitmask & MAT_BIT_FRONT_SPECULAR) { - foreach (light, list) { - SCALE_3V( light->_MatSpecular[0], light->Specular, - mat[MAT_ATTRIB_FRONT_SPECULAR]); - } - } - - if (bitmask & MAT_BIT_BACK_SPECULAR) { - foreach (light, list) { - SCALE_3V( light->_MatSpecular[1], light->Specular, - mat[MAT_ATTRIB_BACK_SPECULAR]); - } - } - - if (bitmask & MAT_BIT_FRONT_SHININESS) { - _mesa_invalidate_shine_table( ctx, 0 ); - } - - if (bitmask & MAT_BIT_BACK_SHININESS) { - _mesa_invalidate_shine_table( ctx, 1 ); - } -} - - -/* - * Update the current materials from the given rgba color - * according to the bitmask in ColorMaterialBitmask, which is - * set by glColorMaterial(). - */ -void -_mesa_update_color_material( struct gl_context *ctx, const GLfloat color[4] ) -{ - GLuint bitmask = ctx->Light.ColorMaterialBitmask; - struct gl_material *mat = &ctx->Light.Material; - int i; - - for (i = 0 ; i < MAT_ATTRIB_MAX ; i++) - if (bitmask & (1<Attrib[i], color ); - - _mesa_update_material( ctx, bitmask ); -} - - -void GLAPIENTRY -_mesa_ColorMaterial( GLenum face, GLenum mode ) -{ - GET_CURRENT_CONTEXT(ctx); - GLuint bitmask; - GLuint legal = (MAT_BIT_FRONT_EMISSION | MAT_BIT_BACK_EMISSION | - MAT_BIT_FRONT_SPECULAR | MAT_BIT_BACK_SPECULAR | - MAT_BIT_FRONT_DIFFUSE | MAT_BIT_BACK_DIFFUSE | - MAT_BIT_FRONT_AMBIENT | MAT_BIT_BACK_AMBIENT); - ASSERT_OUTSIDE_BEGIN_END(ctx); - - if (MESA_VERBOSE&VERBOSE_API) - _mesa_debug(ctx, "glColorMaterial %s %s\n", - _mesa_lookup_enum_by_nr(face), - _mesa_lookup_enum_by_nr(mode)); - - bitmask = _mesa_material_bitmask(ctx, face, mode, legal, "glColorMaterial"); - if (bitmask == 0) - return; /* error was recorded */ - - if (ctx->Light.ColorMaterialBitmask == bitmask && - ctx->Light.ColorMaterialFace == face && - ctx->Light.ColorMaterialMode == mode) - return; - - FLUSH_VERTICES(ctx, _NEW_LIGHT); - ctx->Light.ColorMaterialBitmask = bitmask; - ctx->Light.ColorMaterialFace = face; - ctx->Light.ColorMaterialMode = mode; - - if (ctx->Light.ColorMaterialEnabled) { - FLUSH_CURRENT( ctx, 0 ); - _mesa_update_color_material(ctx,ctx->Current.Attrib[VERT_ATTRIB_COLOR]); - } - - if (ctx->Driver.ColorMaterial) - ctx->Driver.ColorMaterial( ctx, face, mode ); -} - - -void GLAPIENTRY -_mesa_GetMaterialfv( GLenum face, GLenum pname, GLfloat *params ) -{ - GET_CURRENT_CONTEXT(ctx); - GLuint f; - GLfloat (*mat)[4] = ctx->Light.Material.Attrib; - ASSERT_OUTSIDE_BEGIN_END_AND_FLUSH(ctx); /* update materials */ - - FLUSH_CURRENT(ctx, 0); /* update ctx->Light.Material from vertex buffer */ - - if (face==GL_FRONT) { - f = 0; - } - else if (face==GL_BACK) { - f = 1; - } - else { - _mesa_error( ctx, GL_INVALID_ENUM, "glGetMaterialfv(face)" ); - return; - } - - switch (pname) { - case GL_AMBIENT: - COPY_4FV( params, mat[MAT_ATTRIB_AMBIENT(f)] ); - break; - case GL_DIFFUSE: - COPY_4FV( params, mat[MAT_ATTRIB_DIFFUSE(f)] ); - break; - case GL_SPECULAR: - COPY_4FV( params, mat[MAT_ATTRIB_SPECULAR(f)] ); - break; - case GL_EMISSION: - COPY_4FV( params, mat[MAT_ATTRIB_EMISSION(f)] ); - break; - case GL_SHININESS: - *params = mat[MAT_ATTRIB_SHININESS(f)][0]; - break; - case GL_COLOR_INDEXES: - params[0] = mat[MAT_ATTRIB_INDEXES(f)][0]; - params[1] = mat[MAT_ATTRIB_INDEXES(f)][1]; - params[2] = mat[MAT_ATTRIB_INDEXES(f)][2]; - break; - default: - _mesa_error( ctx, GL_INVALID_ENUM, "glGetMaterialfv(pname)" ); - } -} - - -void GLAPIENTRY -_mesa_GetMaterialiv( GLenum face, GLenum pname, GLint *params ) -{ - GET_CURRENT_CONTEXT(ctx); - GLuint f; - GLfloat (*mat)[4] = ctx->Light.Material.Attrib; - ASSERT_OUTSIDE_BEGIN_END_AND_FLUSH(ctx); /* update materials */ - - FLUSH_CURRENT(ctx, 0); /* update ctx->Light.Material from vertex buffer */ - - if (face==GL_FRONT) { - f = 0; - } - else if (face==GL_BACK) { - f = 1; - } - else { - _mesa_error( ctx, GL_INVALID_ENUM, "glGetMaterialiv(face)" ); - return; - } - switch (pname) { - case GL_AMBIENT: - params[0] = FLOAT_TO_INT( mat[MAT_ATTRIB_AMBIENT(f)][0] ); - params[1] = FLOAT_TO_INT( mat[MAT_ATTRIB_AMBIENT(f)][1] ); - params[2] = FLOAT_TO_INT( mat[MAT_ATTRIB_AMBIENT(f)][2] ); - params[3] = FLOAT_TO_INT( mat[MAT_ATTRIB_AMBIENT(f)][3] ); - break; - case GL_DIFFUSE: - params[0] = FLOAT_TO_INT( mat[MAT_ATTRIB_DIFFUSE(f)][0] ); - params[1] = FLOAT_TO_INT( mat[MAT_ATTRIB_DIFFUSE(f)][1] ); - params[2] = FLOAT_TO_INT( mat[MAT_ATTRIB_DIFFUSE(f)][2] ); - params[3] = FLOAT_TO_INT( mat[MAT_ATTRIB_DIFFUSE(f)][3] ); - break; - case GL_SPECULAR: - params[0] = FLOAT_TO_INT( mat[MAT_ATTRIB_SPECULAR(f)][0] ); - params[1] = FLOAT_TO_INT( mat[MAT_ATTRIB_SPECULAR(f)][1] ); - params[2] = FLOAT_TO_INT( mat[MAT_ATTRIB_SPECULAR(f)][2] ); - params[3] = FLOAT_TO_INT( mat[MAT_ATTRIB_SPECULAR(f)][3] ); - break; - case GL_EMISSION: - params[0] = FLOAT_TO_INT( mat[MAT_ATTRIB_EMISSION(f)][0] ); - params[1] = FLOAT_TO_INT( mat[MAT_ATTRIB_EMISSION(f)][1] ); - params[2] = FLOAT_TO_INT( mat[MAT_ATTRIB_EMISSION(f)][2] ); - params[3] = FLOAT_TO_INT( mat[MAT_ATTRIB_EMISSION(f)][3] ); - break; - case GL_SHININESS: - *params = IROUND( mat[MAT_ATTRIB_SHININESS(f)][0] ); - break; - case GL_COLOR_INDEXES: - params[0] = IROUND( mat[MAT_ATTRIB_INDEXES(f)][0] ); - params[1] = IROUND( mat[MAT_ATTRIB_INDEXES(f)][1] ); - params[2] = IROUND( mat[MAT_ATTRIB_INDEXES(f)][2] ); - break; - default: - _mesa_error( ctx, GL_INVALID_ENUM, "glGetMaterialfv(pname)" ); - } -} - - - -/**********************************************************************/ -/***** Lighting computation *****/ -/**********************************************************************/ - - -/* - * Notes: - * When two-sided lighting is enabled we compute the color (or index) - * for both the front and back side of the primitive. Then, when the - * orientation of the facet is later learned, we can determine which - * color (or index) to use for rendering. - * - * KW: We now know orientation in advance and only shade for - * the side or sides which are actually required. - * - * Variables: - * n = normal vector - * V = vertex position - * P = light source position - * Pe = (0,0,0,1) - * - * Precomputed: - * IF P[3]==0 THEN - * // light at infinity - * IF local_viewer THEN - * _VP_inf_norm = unit vector from V to P // Precompute - * ELSE - * // eye at infinity - * _h_inf_norm = Normalize( VP + <0,0,1> ) // Precompute - * ENDIF - * ENDIF - * - * Functions: - * Normalize( v ) = normalized vector v - * Magnitude( v ) = length of vector v - */ - - - -/* - * Whenever the spotlight exponent for a light changes we must call - * this function to recompute the exponent lookup table. - */ -void -_mesa_invalidate_spot_exp_table( struct gl_light *l ) -{ - l->_SpotExpTable[0][0] = -1; -} - - -static void -validate_spot_exp_table( struct gl_light *l ) -{ - GLint i; - GLdouble exponent = l->SpotExponent; - GLdouble tmp = 0; - GLint clamp = 0; - - l->_SpotExpTable[0][0] = 0.0; - - for (i = EXP_TABLE_SIZE - 1; i > 0 ;i--) { - if (clamp == 0) { - tmp = pow(i / (GLdouble) (EXP_TABLE_SIZE - 1), exponent); - if (tmp < FLT_MIN * 100.0) { - tmp = 0.0; - clamp = 1; - } - } - l->_SpotExpTable[i][0] = (GLfloat) tmp; - } - for (i = 0; i < EXP_TABLE_SIZE - 1; i++) { - l->_SpotExpTable[i][1] = (l->_SpotExpTable[i+1][0] - - l->_SpotExpTable[i][0]); - } - l->_SpotExpTable[EXP_TABLE_SIZE-1][1] = 0.0; -} - - - -/* Calculate a new shine table. Doing this here saves a branch in - * lighting, and the cost of doing it early may be partially offset - * by keeping a MRU cache of shine tables for various shine values. - */ -void -_mesa_invalidate_shine_table( struct gl_context *ctx, GLuint side ) -{ - ASSERT(side < 2); - if (ctx->_ShineTable[side]) - ctx->_ShineTable[side]->refcount--; - ctx->_ShineTable[side] = NULL; -} - - -static void -validate_shine_table( struct gl_context *ctx, GLuint side, GLfloat shininess ) -{ - struct gl_shine_tab *list = ctx->_ShineTabList; - struct gl_shine_tab *s; - - ASSERT(side < 2); - - foreach(s, list) - if ( s->shininess == shininess ) - break; - - if (s == list) { - GLint j; - GLfloat *m; - - foreach(s, list) - if (s->refcount == 0) - break; - - m = s->tab; - m[0] = 0.0; - if (shininess == 0.0) { - for (j = 1 ; j <= SHINE_TABLE_SIZE ; j++) - m[j] = 1.0; - } - else { - for (j = 1 ; j < SHINE_TABLE_SIZE ; j++) { - GLdouble t, x = j / (GLfloat) (SHINE_TABLE_SIZE - 1); - if (x < 0.005) /* underflow check */ - x = 0.005; - t = pow(x, shininess); - if (t > 1e-20) - m[j] = (GLfloat) t; - else - m[j] = 0.0; - } - m[SHINE_TABLE_SIZE] = 1.0; - } - - s->shininess = shininess; - } - - if (ctx->_ShineTable[side]) - ctx->_ShineTable[side]->refcount--; - - ctx->_ShineTable[side] = s; - move_to_tail( list, s ); - s->refcount++; -} - - -void -_mesa_validate_all_lighting_tables( struct gl_context *ctx ) -{ - GLuint i; - GLfloat shininess; - - shininess = ctx->Light.Material.Attrib[MAT_ATTRIB_FRONT_SHININESS][0]; - if (!ctx->_ShineTable[0] || ctx->_ShineTable[0]->shininess != shininess) - validate_shine_table( ctx, 0, shininess ); - - shininess = ctx->Light.Material.Attrib[MAT_ATTRIB_BACK_SHININESS][0]; - if (!ctx->_ShineTable[1] || ctx->_ShineTable[1]->shininess != shininess) - validate_shine_table( ctx, 1, shininess ); - - for (i = 0; i < ctx->Const.MaxLights; i++) - if (ctx->Light.Light[i]._SpotExpTable[0][0] == -1) - validate_spot_exp_table( &ctx->Light.Light[i] ); -} - - -/** - * Examine current lighting parameters to determine if the optimized lighting - * function can be used. - * Also, precompute some lighting values such as the products of light - * source and material ambient, diffuse and specular coefficients. - */ -void -_mesa_update_lighting( struct gl_context *ctx ) -{ - struct gl_light *light; - ctx->Light._NeedEyeCoords = GL_FALSE; - ctx->Light._Flags = 0; - - if (!ctx->Light.Enabled) - return; - - foreach(light, &ctx->Light.EnabledList) { - ctx->Light._Flags |= light->_Flags; - } - - ctx->Light._NeedVertices = - ((ctx->Light._Flags & (LIGHT_POSITIONAL|LIGHT_SPOT)) || - ctx->Light.Model.LocalViewer); - - ctx->Light._NeedEyeCoords = ((ctx->Light._Flags & LIGHT_POSITIONAL) || - ctx->Light.Model.LocalViewer); - - /* XXX: This test is overkill & needs to be fixed both for software and - * hardware t&l drivers. The above should be sufficient & should - * be tested to verify this. - */ - if (ctx->Light._NeedVertices) - ctx->Light._NeedEyeCoords = GL_TRUE; - - /* Precompute some shading values. Although we reference - * Light.Material here, we can get away without flushing - * FLUSH_UPDATE_CURRENT, as when any outstanding material changes - * are flushed, they will update the derived state at that time. - */ - if (ctx->Light.Model.TwoSide) - _mesa_update_material(ctx, - MAT_BIT_FRONT_EMISSION | - MAT_BIT_FRONT_AMBIENT | - MAT_BIT_FRONT_DIFFUSE | - MAT_BIT_FRONT_SPECULAR | - MAT_BIT_BACK_EMISSION | - MAT_BIT_BACK_AMBIENT | - MAT_BIT_BACK_DIFFUSE | - MAT_BIT_BACK_SPECULAR); - else - _mesa_update_material(ctx, - MAT_BIT_FRONT_EMISSION | - MAT_BIT_FRONT_AMBIENT | - MAT_BIT_FRONT_DIFFUSE | - MAT_BIT_FRONT_SPECULAR); -} - - -/** - * Update state derived from light position, spot direction. - * Called upon: - * _NEW_MODELVIEW - * _NEW_LIGHT - * _TNL_NEW_NEED_EYE_COORDS - * - * Update on (_NEW_MODELVIEW | _NEW_LIGHT) when lighting is enabled. - * Also update on lighting space changes. - */ -static void -compute_light_positions( struct gl_context *ctx ) -{ - struct gl_light *light; - static const GLfloat eye_z[3] = { 0, 0, 1 }; - - if (!ctx->Light.Enabled) - return; - - if (ctx->_NeedEyeCoords) { - COPY_3V( ctx->_EyeZDir, eye_z ); - } - else { - TRANSFORM_NORMAL( ctx->_EyeZDir, eye_z, ctx->ModelviewMatrixStack.Top->m ); - } - - /* Make sure all the light tables are updated before the computation */ - _mesa_validate_all_lighting_tables(ctx); - - foreach (light, &ctx->Light.EnabledList) { - - if (ctx->_NeedEyeCoords) { - /* _Position is in eye coordinate space */ - COPY_4FV( light->_Position, light->EyePosition ); - } - else { - /* _Position is in object coordinate space */ - TRANSFORM_POINT( light->_Position, ctx->ModelviewMatrixStack.Top->inv, - light->EyePosition ); - } - - if (!(light->_Flags & LIGHT_POSITIONAL)) { - /* VP (VP) = Normalize( Position ) */ - COPY_3V( light->_VP_inf_norm, light->_Position ); - NORMALIZE_3FV( light->_VP_inf_norm ); - - if (!ctx->Light.Model.LocalViewer) { - /* _h_inf_norm = Normalize( V_to_P + <0,0,1> ) */ - ADD_3V( light->_h_inf_norm, light->_VP_inf_norm, ctx->_EyeZDir); - NORMALIZE_3FV( light->_h_inf_norm ); - } - light->_VP_inf_spot_attenuation = 1.0; - } - else { - /* positional light w/ homogeneous coordinate, divide by W */ - GLfloat wInv = (GLfloat)1.0 / light->_Position[3]; - light->_Position[0] *= wInv; - light->_Position[1] *= wInv; - light->_Position[2] *= wInv; - } - - if (light->_Flags & LIGHT_SPOT) { - /* Note: we normalize the spot direction now */ - - if (ctx->_NeedEyeCoords) { - COPY_3V( light->_NormSpotDirection, light->SpotDirection ); - NORMALIZE_3FV( light->_NormSpotDirection ); - } - else { - GLfloat spotDir[3]; - COPY_3V(spotDir, light->SpotDirection); - NORMALIZE_3FV(spotDir); - TRANSFORM_NORMAL( light->_NormSpotDirection, - spotDir, - ctx->ModelviewMatrixStack.Top->m); - } - - NORMALIZE_3FV( light->_NormSpotDirection ); - - if (!(light->_Flags & LIGHT_POSITIONAL)) { - GLfloat PV_dot_dir = - DOT3(light->_VP_inf_norm, - light->_NormSpotDirection); - - if (PV_dot_dir > light->_CosCutoff) { - double x = PV_dot_dir * (EXP_TABLE_SIZE-1); - int k = (int) x; - light->_VP_inf_spot_attenuation = - (GLfloat) (light->_SpotExpTable[k][0] + - (x-k)*light->_SpotExpTable[k][1]); - } - else { - light->_VP_inf_spot_attenuation = 0; - } - } - } - } -} - - - -static void -update_modelview_scale( struct gl_context *ctx ) -{ - ctx->_ModelViewInvScale = 1.0F; - if (!_math_matrix_is_length_preserving(ctx->ModelviewMatrixStack.Top)) { - const GLfloat *m = ctx->ModelviewMatrixStack.Top->inv; - GLfloat f = m[2] * m[2] + m[6] * m[6] + m[10] * m[10]; - if (f < 1e-12) f = 1.0; - if (ctx->_NeedEyeCoords) - ctx->_ModelViewInvScale = (GLfloat) INV_SQRTF(f); - else - ctx->_ModelViewInvScale = (GLfloat) SQRTF(f); - } -} - - -/** - * Bring up to date any state that relies on _NeedEyeCoords. - */ -void -_mesa_update_tnl_spaces( struct gl_context *ctx, GLuint new_state ) -{ - const GLuint oldneedeyecoords = ctx->_NeedEyeCoords; - - (void) new_state; - ctx->_NeedEyeCoords = GL_FALSE; - - if (ctx->_ForceEyeCoords || - (ctx->Texture._GenFlags & TEXGEN_NEED_EYE_COORD) || - ctx->Point._Attenuated || - ctx->Light._NeedEyeCoords) - ctx->_NeedEyeCoords = GL_TRUE; - - if (ctx->Light.Enabled && - !_math_matrix_is_length_preserving(ctx->ModelviewMatrixStack.Top)) - ctx->_NeedEyeCoords = GL_TRUE; - - /* Check if the truth-value interpretations of the bitfields have - * changed: - */ - if (oldneedeyecoords != ctx->_NeedEyeCoords) { - /* Recalculate all state that depends on _NeedEyeCoords. - */ - update_modelview_scale(ctx); - compute_light_positions( ctx ); - - if (ctx->Driver.LightingSpaceChange) - ctx->Driver.LightingSpaceChange( ctx ); - } - else { - GLuint new_state2 = ctx->NewState; - - /* Recalculate that same state only if it has been invalidated - * by other statechanges. - */ - if (new_state2 & _NEW_MODELVIEW) - update_modelview_scale(ctx); - - if (new_state2 & (_NEW_LIGHT|_NEW_MODELVIEW)) - compute_light_positions( ctx ); - } -} - - -/** - * Drivers may need this if the hardware tnl unit doesn't support the - * light-in-modelspace optimization. It's also useful for debugging. - */ -void -_mesa_allow_light_in_model( struct gl_context *ctx, GLboolean flag ) -{ - ctx->_ForceEyeCoords = !flag; - ctx->NewState |= _NEW_POINT; /* one of the bits from - * _MESA_NEW_NEED_EYE_COORDS. - */ -} - - - -/**********************************************************************/ -/***** Initialization *****/ -/**********************************************************************/ - -/** - * Initialize the n-th light data structure. - * - * \param l pointer to the gl_light structure to be initialized. - * \param n number of the light. - * \note The defaults for light 0 are different than the other lights. - */ -static void -init_light( struct gl_light *l, GLuint n ) -{ - make_empty_list( l ); - - ASSIGN_4V( l->Ambient, 0.0, 0.0, 0.0, 1.0 ); - if (n==0) { - ASSIGN_4V( l->Diffuse, 1.0, 1.0, 1.0, 1.0 ); - ASSIGN_4V( l->Specular, 1.0, 1.0, 1.0, 1.0 ); - } - else { - ASSIGN_4V( l->Diffuse, 0.0, 0.0, 0.0, 1.0 ); - ASSIGN_4V( l->Specular, 0.0, 0.0, 0.0, 1.0 ); - } - ASSIGN_4V( l->EyePosition, 0.0, 0.0, 1.0, 0.0 ); - ASSIGN_3V( l->SpotDirection, 0.0, 0.0, -1.0 ); - l->SpotExponent = 0.0; - _mesa_invalidate_spot_exp_table( l ); - l->SpotCutoff = 180.0; - l->_CosCutoffNeg = -1.0f; - l->_CosCutoff = 0.0; /* KW: -ve values not admitted */ - l->ConstantAttenuation = 1.0; - l->LinearAttenuation = 0.0; - l->QuadraticAttenuation = 0.0; - l->Enabled = GL_FALSE; -} - - -/** - * Initialize the light model data structure. - * - * \param lm pointer to the gl_lightmodel structure to be initialized. - */ -static void -init_lightmodel( struct gl_lightmodel *lm ) -{ - ASSIGN_4V( lm->Ambient, 0.2F, 0.2F, 0.2F, 1.0F ); - lm->LocalViewer = GL_FALSE; - lm->TwoSide = GL_FALSE; -} - - -/** - * Initialize the material data structure. - * - * \param m pointer to the gl_material structure to be initialized. - */ -static void -init_material( struct gl_material *m ) -{ - ASSIGN_4V( m->Attrib[MAT_ATTRIB_FRONT_AMBIENT], 0.2F, 0.2F, 0.2F, 1.0F ); - ASSIGN_4V( m->Attrib[MAT_ATTRIB_FRONT_DIFFUSE], 0.8F, 0.8F, 0.8F, 1.0F ); - ASSIGN_4V( m->Attrib[MAT_ATTRIB_FRONT_SPECULAR], 0.0F, 0.0F, 0.0F, 1.0F ); - ASSIGN_4V( m->Attrib[MAT_ATTRIB_FRONT_EMISSION], 0.0F, 0.0F, 0.0F, 1.0F ); - ASSIGN_4V( m->Attrib[MAT_ATTRIB_FRONT_SHININESS], 0.0F, 0.0F, 0.0F, 0.0F ); - ASSIGN_4V( m->Attrib[MAT_ATTRIB_FRONT_INDEXES], 0.0F, 1.0F, 1.0F, 0.0F ); - - ASSIGN_4V( m->Attrib[MAT_ATTRIB_BACK_AMBIENT], 0.2F, 0.2F, 0.2F, 1.0F ); - ASSIGN_4V( m->Attrib[MAT_ATTRIB_BACK_DIFFUSE], 0.8F, 0.8F, 0.8F, 1.0F ); - ASSIGN_4V( m->Attrib[MAT_ATTRIB_BACK_SPECULAR], 0.0F, 0.0F, 0.0F, 1.0F ); - ASSIGN_4V( m->Attrib[MAT_ATTRIB_BACK_EMISSION], 0.0F, 0.0F, 0.0F, 1.0F ); - ASSIGN_4V( m->Attrib[MAT_ATTRIB_BACK_SHININESS], 0.0F, 0.0F, 0.0F, 0.0F ); - ASSIGN_4V( m->Attrib[MAT_ATTRIB_BACK_INDEXES], 0.0F, 1.0F, 1.0F, 0.0F ); -} - - -/** - * Initialize all lighting state for the given context. - */ -void -_mesa_init_lighting( struct gl_context *ctx ) -{ - GLuint i; - - /* Lighting group */ - for (i = 0; i < MAX_LIGHTS; i++) { - init_light( &ctx->Light.Light[i], i ); - } - make_empty_list( &ctx->Light.EnabledList ); - - init_lightmodel( &ctx->Light.Model ); - init_material( &ctx->Light.Material ); - ctx->Light.ShadeModel = GL_SMOOTH; - ctx->Light.Enabled = GL_FALSE; - ctx->Light.ColorMaterialFace = GL_FRONT_AND_BACK; - ctx->Light.ColorMaterialMode = GL_AMBIENT_AND_DIFFUSE; - ctx->Light.ColorMaterialBitmask = _mesa_material_bitmask( ctx, - GL_FRONT_AND_BACK, - GL_AMBIENT_AND_DIFFUSE, ~0, - NULL ); - - ctx->Light.ColorMaterialEnabled = GL_FALSE; - - /* Lighting miscellaneous */ - ctx->_ShineTabList = MALLOC_STRUCT( gl_shine_tab ); - make_empty_list( ctx->_ShineTabList ); - /* Allocate 10 (arbitrary) shininess lookup tables */ - for (i = 0 ; i < 10 ; i++) { - struct gl_shine_tab *s = MALLOC_STRUCT( gl_shine_tab ); - s->shininess = -1; - s->refcount = 0; - insert_at_tail( ctx->_ShineTabList, s ); - } - - /* Miscellaneous */ - ctx->Light._NeedEyeCoords = GL_FALSE; - ctx->_NeedEyeCoords = GL_FALSE; - ctx->_ForceEyeCoords = GL_FALSE; - ctx->_ModelViewInvScale = 1.0; -} - - -/** - * Deallocate malloc'd lighting state attached to given context. - */ -void -_mesa_free_lighting_data( struct gl_context *ctx ) -{ - struct gl_shine_tab *s, *tmps; - - /* Free lighting shininess exponentiation table */ - foreach_s( s, tmps, ctx->_ShineTabList ) { - free( s ); - } - free( ctx->_ShineTabList ); -} diff --git a/dll/opengl/mesa/main/light.h b/dll/opengl/mesa/main/light.h deleted file mode 100644 index decf7be6bc9..00000000000 --- a/dll/opengl/mesa/main/light.h +++ /dev/null @@ -1,144 +0,0 @@ -/* - * Mesa 3-D graphics library - * Version: 7.5 - * - * Copyright (C) 1999-2008 Brian Paul All Rights Reserved. - * Copyright (C) 2009 VMware, Inc. All Rights Reserved. - * - * Permission is hereby granted, free of charge, to any person obtaining a - * copy of this software and associated documentation files (the "Software"), - * to deal in the Software without restriction, including without limitation - * the rights to use, copy, modify, merge, publish, distribute, sublicense, - * and/or sell copies of the Software, and to permit persons to whom the - * Software is furnished to do so, subject to the following conditions: - * - * The above copyright notice and this permission notice shall be included - * in all copies or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS - * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL - * BRIAN PAUL BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN - * AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN - * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. - */ - - -#ifndef LIGHT_H -#define LIGHT_H - - -#include "glheader.h" -#include "mfeatures.h" - -struct gl_context; -struct gl_light; -struct gl_material; - -extern void GLAPIENTRY -_mesa_ShadeModel( GLenum mode ); - - -#if _HAVE_FULL_GL -extern void GLAPIENTRY -_mesa_ColorMaterial( GLenum face, GLenum mode ); - -extern void GLAPIENTRY -_mesa_Lightf( GLenum light, GLenum pname, GLfloat param ); - -extern void GLAPIENTRY -_mesa_Lightfv( GLenum light, GLenum pname, const GLfloat *params ); - -extern void GLAPIENTRY -_mesa_Lightiv( GLenum light, GLenum pname, const GLint *params ); - -extern void GLAPIENTRY -_mesa_Lighti( GLenum light, GLenum pname, GLint param ); - -extern void GLAPIENTRY -_mesa_LightModelf( GLenum pname, GLfloat param ); - -extern void GLAPIENTRY -_mesa_LightModelfv( GLenum pname, const GLfloat *params ); - -extern void GLAPIENTRY -_mesa_LightModeli( GLenum pname, GLint param ); - -extern void GLAPIENTRY -_mesa_LightModeliv( GLenum pname, const GLint *params ); - -extern void GLAPIENTRY -_mesa_GetLightfv( GLenum light, GLenum pname, GLfloat *params ); - -extern void GLAPIENTRY -_mesa_GetLightiv( GLenum light, GLenum pname, GLint *params ); - -extern void GLAPIENTRY -_mesa_GetMaterialfv( GLenum face, GLenum pname, GLfloat *params ); - -extern void GLAPIENTRY -_mesa_GetMaterialiv( GLenum face, GLenum pname, GLint *params ); - - -extern void -_mesa_light(struct gl_context *ctx, GLuint lnum, GLenum pname, const GLfloat *params); - - -/* Lerp between adjacent values in the f(x) lookup table, giving a - * continuous function, with adequeate overall accuracy. (Though - * still pretty good compared to a straight lookup). - * Result should be a GLfloat. - */ -#define GET_SHINE_TAB_ENTRY( table, dp, result ) \ -do { \ - struct gl_shine_tab *_tab = table; \ - float f = (dp * (SHINE_TABLE_SIZE-1)); \ - int k = (int) f; \ - if (k < 0 /* gcc may cast an overflow float value to negative int value*/ \ - || k > SHINE_TABLE_SIZE-2) \ - result = (GLfloat) pow( dp, _tab->shininess ); \ - else \ - result = _tab->tab[k] + (f-k)*(_tab->tab[k+1]-_tab->tab[k]); \ -} while (0) - - -extern GLuint _mesa_material_bitmask( struct gl_context *ctx, - GLenum face, GLenum pname, - GLuint legal, - const char * ); - -extern void _mesa_invalidate_spot_exp_table( struct gl_light *l ); - -extern void _mesa_invalidate_shine_table( struct gl_context *ctx, GLuint i ); - -extern void _mesa_validate_all_lighting_tables( struct gl_context *ctx ); - -extern void _mesa_update_lighting( struct gl_context *ctx ); - -extern void _mesa_update_tnl_spaces( struct gl_context *ctx, GLuint new_state ); - -extern void _mesa_update_material( struct gl_context *ctx, - GLuint bitmask ); - -extern void _mesa_update_color_material( struct gl_context *ctx, - const GLfloat rgba[4] ); - -extern void _mesa_init_lighting( struct gl_context *ctx ); - -extern void _mesa_free_lighting_data( struct gl_context *ctx ); - -extern void _mesa_allow_light_in_model( struct gl_context *ctx, GLboolean flag ); - -#else -#define _mesa_update_color_material( c, r ) ((void)0) -#define _mesa_validate_all_lighting_tables( c ) ((void)0) -#define _mesa_invalidate_spot_exp_table( l ) ((void)0) -#define _mesa_material_bitmask( c, f, p, l, s ) 0 -#define _mesa_init_lighting( c ) ((void)0) -#define _mesa_free_lighting_data( c ) ((void)0) -#define _mesa_update_lighting( c ) ((void)0) -#define _mesa_update_tnl_spaces( c, n ) ((void)0) -#define GET_SHINE_TAB_ENTRY( table, dp, result ) ((result)=0) -#endif - -#endif diff --git a/dll/opengl/mesa/main/lines.c b/dll/opengl/mesa/main/lines.c deleted file mode 100644 index cf8f0a32328..00000000000 --- a/dll/opengl/mesa/main/lines.c +++ /dev/null @@ -1,111 +0,0 @@ -/* - * Mesa 3-D graphics library - * Version: 6.5.3 - * - * Copyright (C) 1999-2006 Brian Paul All Rights Reserved. - * - * Permission is hereby granted, free of charge, to any person obtaining a - * copy of this software and associated documentation files (the "Software"), - * to deal in the Software without restriction, including without limitation - * the rights to use, copy, modify, merge, publish, distribute, sublicense, - * and/or sell copies of the Software, and to permit persons to whom the - * Software is furnished to do so, subject to the following conditions: - * - * The above copyright notice and this permission notice shall be included - * in all copies or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS - * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL - * BRIAN PAUL BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN - * AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN - * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. - */ - -#include - -/** - * Set the line width. - * - * \param width line width in pixels. - * - * \sa glLineWidth(). - */ -void GLAPIENTRY -_mesa_LineWidth( GLfloat width ) -{ - GET_CURRENT_CONTEXT(ctx); - ASSERT_OUTSIDE_BEGIN_END(ctx); - - if (MESA_VERBOSE & VERBOSE_API) - _mesa_debug(ctx, "glLineWidth %f\n", width); - - if (width<=0.0) { - _mesa_error( ctx, GL_INVALID_VALUE, "glLineWidth" ); - return; - } - - if (ctx->Line.Width == width) - return; - - FLUSH_VERTICES(ctx, _NEW_LINE); - ctx->Line.Width = width; - - if (ctx->Driver.LineWidth) - ctx->Driver.LineWidth(ctx, width); -} - - -/** - * Set the line stipple pattern. - * - * \param factor pattern scale factor. - * \param pattern bit pattern. - * - * \sa glLineStipple(). - * - * Updates gl_line_attrib::StippleFactor and gl_line_attrib::StipplePattern. On - * change flushes the vertices and notifies the driver via - * the dd_function_table::LineStipple callback. - */ -void GLAPIENTRY -_mesa_LineStipple( GLint factor, GLushort pattern ) -{ - GET_CURRENT_CONTEXT(ctx); - ASSERT_OUTSIDE_BEGIN_END(ctx); - - if (MESA_VERBOSE & VERBOSE_API) - _mesa_debug(ctx, "glLineStipple %d %u\n", factor, pattern); - - factor = CLAMP( factor, 1, 256 ); - - if (ctx->Line.StippleFactor == factor && - ctx->Line.StipplePattern == pattern) - return; - - FLUSH_VERTICES(ctx, _NEW_LINE); - ctx->Line.StippleFactor = factor; - ctx->Line.StipplePattern = pattern; - - if (ctx->Driver.LineStipple) - ctx->Driver.LineStipple( ctx, factor, pattern ); -} - - -/** - * Initialize the context line state. - * - * \param ctx GL context. - * - * Initializes __struct gl_contextRec::Line and line related constants in - * __struct gl_contextRec::Const. - */ -void GLAPIENTRY -_mesa_init_line( struct gl_context * ctx ) -{ - ctx->Line.SmoothFlag = GL_FALSE; - ctx->Line.StippleFlag = GL_FALSE; - ctx->Line.Width = 1.0; - ctx->Line.StipplePattern = 0xffff; - ctx->Line.StippleFactor = 1; -} diff --git a/dll/opengl/mesa/main/lines.h b/dll/opengl/mesa/main/lines.h deleted file mode 100644 index 8e8b3f8d6e1..00000000000 --- a/dll/opengl/mesa/main/lines.h +++ /dev/null @@ -1,49 +0,0 @@ -/** - * \file lines.h - * Line operations. - */ - -/* - * Mesa 3-D graphics library - * Version: 3.5 - * - * Copyright (C) 1999-2001 Brian Paul All Rights Reserved. - * - * Permission is hereby granted, free of charge, to any person obtaining a - * copy of this software and associated documentation files (the "Software"), - * to deal in the Software without restriction, including without limitation - * the rights to use, copy, modify, merge, publish, distribute, sublicense, - * and/or sell copies of the Software, and to permit persons to whom the - * Software is furnished to do so, subject to the following conditions: - * - * The above copyright notice and this permission notice shall be included - * in all copies or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS - * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL - * BRIAN PAUL BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN - * AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN - * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. - */ - - - -#ifndef LINES_H -#define LINES_H - - -#include "glheader.h" - -struct gl_context; - -extern void GLAPIENTRY -_mesa_LineWidth( GLfloat width ); - -extern void GLAPIENTRY -_mesa_LineStipple( GLint factor, GLushort pattern ); - -extern void GLAPIENTRY -_mesa_init_line( struct gl_context * ctx ); - -#endif diff --git a/dll/opengl/mesa/main/macros.h b/dll/opengl/mesa/main/macros.h deleted file mode 100644 index 9da2f283599..00000000000 --- a/dll/opengl/mesa/main/macros.h +++ /dev/null @@ -1,683 +0,0 @@ -/** - * \file macros.h - * A collection of useful macros. - */ - -/* - * Mesa 3-D graphics library - * Version: 6.5.2 - * - * Copyright (C) 1999-2006 Brian Paul All Rights Reserved. - * - * Permission is hereby granted, free of charge, to any person obtaining a - * copy of this software and associated documentation files (the "Software"), - * to deal in the Software without restriction, including without limitation - * the rights to use, copy, modify, merge, publish, distribute, sublicense, - * and/or sell copies of the Software, and to permit persons to whom the - * Software is furnished to do so, subject to the following conditions: - * - * The above copyright notice and this permission notice shall be included - * in all copies or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS - * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL - * BRIAN PAUL BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN - * AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN - * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. - */ - - -#ifndef MACROS_H -#define MACROS_H - -#include "imports.h" - - -/** - * \name Integer / float conversion for colors, normals, etc. - */ -/*@{*/ - -/** Convert GLubyte in [0,255] to GLfloat in [0.0,1.0] */ -extern GLfloat _mesa_ubyte_to_float_color_tab[256]; -#define UBYTE_TO_FLOAT(u) _mesa_ubyte_to_float_color_tab[(unsigned int)(u)] - -/** Convert GLfloat in [0.0,1.0] to GLubyte in [0,255] */ -#define FLOAT_TO_UBYTE(X) ((GLubyte) (GLint) ((X) * 255.0F)) - - -/** Convert GLbyte in [-128,127] to GLfloat in [-1.0,1.0] */ -#define BYTE_TO_FLOAT(B) ((2.0F * (B) + 1.0F) * (1.0F/255.0F)) - -/** Convert GLfloat in [-1.0,1.0] to GLbyte in [-128,127] */ -#define FLOAT_TO_BYTE(X) ( (((GLint) (255.0F * (X))) - 1) / 2 ) - - -/** Convert GLbyte to GLfloat while preserving zero */ -#define BYTE_TO_FLOATZ(B) ((B) == 0 ? 0.0F : BYTE_TO_FLOAT(B)) - - -/** Convert GLbyte in [-128,127] to GLfloat in [-1.0,1.0], texture/fb data */ -#define BYTE_TO_FLOAT_TEX(B) ((B) == -128 ? -1.0F : (B) * (1.0F/127.0F)) - -/** Convert GLfloat in [-1.0,1.0] to GLbyte in [-128,127], texture/fb data */ -#define FLOAT_TO_BYTE_TEX(X) CLAMP( (GLint) (127.0F * (X)), -128, 127 ) - -/** Convert GLushort in [0,65535] to GLfloat in [0.0,1.0] */ -#define USHORT_TO_FLOAT(S) ((GLfloat) (S) * (1.0F / 65535.0F)) - -/** Convert GLfloat in [0.0,1.0] to GLushort in [0, 65535] */ -#define FLOAT_TO_USHORT(X) ((GLuint) ((X) * 65535.0F)) - - -/** Convert GLshort in [-32768,32767] to GLfloat in [-1.0,1.0] */ -#define SHORT_TO_FLOAT(S) ((2.0F * (S) + 1.0F) * (1.0F/65535.0F)) - -/** Convert GLfloat in [-1.0,1.0] to GLshort in [-32768,32767] */ -#define FLOAT_TO_SHORT(X) ( (((GLint) (65535.0F * (X))) - 1) / 2 ) - -/** Convert GLshort to GLfloat while preserving zero */ -#define SHORT_TO_FLOATZ(S) ((S) == 0 ? 0.0F : SHORT_TO_FLOAT(S)) - - -/** Convert GLshort in [-32768,32767] to GLfloat in [-1.0,1.0], texture/fb data */ -#define SHORT_TO_FLOAT_TEX(S) ((S) == -32768 ? -1.0F : (S) * (1.0F/32767.0F)) - -/** Convert GLfloat in [-1.0,1.0] to GLshort in [-32768,32767], texture/fb data */ -#define FLOAT_TO_SHORT_TEX(X) ( (GLint) (32767.0F * (X)) ) - - -/** Convert GLuint in [0,4294967295] to GLfloat in [0.0,1.0] */ -#define UINT_TO_FLOAT(U) ((GLfloat) ((U) * (1.0F / 4294967295.0))) - -/** Convert GLfloat in [0.0,1.0] to GLuint in [0,4294967295] */ -#define FLOAT_TO_UINT(X) ((GLuint) ((X) * 4294967295.0)) - - -/** Convert GLint in [-2147483648,2147483647] to GLfloat in [-1.0,1.0] */ -#define INT_TO_FLOAT(I) ((GLfloat) ((2.0F * (I) + 1.0F) * (1.0F/4294967294.0))) - -/** Convert GLfloat in [-1.0,1.0] to GLint in [-2147483648,2147483647] */ -/* causes overflow: -#define FLOAT_TO_INT(X) ( (((GLint) (4294967294.0 * (X))) - 1) / 2 ) -*/ -/* a close approximation: */ -#define FLOAT_TO_INT(X) ( (GLint) (2147483647.0 * (X)) ) - -/** Convert GLfloat in [-1.0,1.0] to GLint64 in [-(1<<63),(1 << 63) -1] */ -#define FLOAT_TO_INT64(X) ( (GLint64) (9223372036854775807.0 * (double)(X)) ) - - -/** Convert GLint in [-2147483648,2147483647] to GLfloat in [-1.0,1.0], texture/fb data */ -#define INT_TO_FLOAT_TEX(I) ((I) == -2147483648 ? -1.0F : (I) * (1.0F/2147483647.0)) - -/** Convert GLfloat in [-1.0,1.0] to GLint in [-2147483648,2147483647], texture/fb data */ -#define FLOAT_TO_INT_TEX(X) ( (GLint) (2147483647.0 * (X)) ) - - -#define BYTE_TO_UBYTE(b) ((GLubyte) ((b) < 0 ? 0 : (GLubyte) (b))) -#define SHORT_TO_UBYTE(s) ((GLubyte) ((s) < 0 ? 0 : (GLubyte) ((s) >> 7))) -#define USHORT_TO_UBYTE(s) ((GLubyte) ((s) >> 8)) -#define INT_TO_UBYTE(i) ((GLubyte) ((i) < 0 ? 0 : (GLubyte) ((i) >> 23))) -#define UINT_TO_UBYTE(i) ((GLubyte) ((i) >> 24)) - - -#define BYTE_TO_USHORT(b) ((b) < 0 ? 0 : ((GLushort) (((b) * 65535) / 255))) -#define UBYTE_TO_USHORT(b) (((GLushort) (b) << 8) | (GLushort) (b)) -#define SHORT_TO_USHORT(s) ((s) < 0 ? 0 : ((GLushort) (((s) * 65535 / 32767)))) -#define INT_TO_USHORT(i) ((i) < 0 ? 0 : ((GLushort) ((i) >> 15))) -#define UINT_TO_USHORT(i) ((i) < 0 ? 0 : ((GLushort) ((i) >> 16))) -#define UNCLAMPED_FLOAT_TO_USHORT(us, f) \ - us = ( (GLushort) IROUND( CLAMP((f), 0.0F, 1.0F) * 65535.0F) ) -#define CLAMPED_FLOAT_TO_USHORT(us, f) \ - us = ( (GLushort) IROUND( (f) * 65535.0F) ) - -#define UNCLAMPED_FLOAT_TO_SHORT(s, f) \ - s = ( (GLshort) IROUND( CLAMP((f), -1.0F, 1.0F) * 32767.0F) ) - -/*** - *** UNCLAMPED_FLOAT_TO_UBYTE: clamp float to [0,1] and map to ubyte in [0,255] - *** CLAMPED_FLOAT_TO_UBYTE: map float known to be in [0,1] to ubyte in [0,255] - ***/ -#if defined(USE_IEEE) && !defined(DEBUG) -#define IEEE_0996 0x3f7f0000 /* 0.996 or so */ -/* This function/macro is sensitive to precision. Test very carefully - * if you change it! - */ -#define UNCLAMPED_FLOAT_TO_UBYTE(UB, F) \ - do { \ - fi_type __tmp; \ - __tmp.f = (F); \ - if (__tmp.i < 0) \ - UB = (GLubyte) 0; \ - else if (__tmp.i >= IEEE_0996) \ - UB = (GLubyte) 255; \ - else { \ - __tmp.f = __tmp.f * (255.0f/256.0f) + 32768.0f; \ - UB = (GLubyte) __tmp.i; \ - } \ - } while (0) -#define CLAMPED_FLOAT_TO_UBYTE(UB, F) \ - do { \ - fi_type __tmp; \ - __tmp.f = (F) * (255.0f/256.0f) + 32768.0f; \ - UB = (GLubyte) __tmp.i; \ - } while (0) -#else -#define UNCLAMPED_FLOAT_TO_UBYTE(ub, f) \ - ub = ((GLubyte) IROUND(CLAMP((f), 0.0F, 1.0F) * 255.0F)) -#define CLAMPED_FLOAT_TO_UBYTE(ub, f) \ - ub = ((GLubyte) IROUND((f) * 255.0F)) -#endif - -/*@}*/ - - -/** Stepping a GLfloat pointer by a byte stride */ -#define STRIDE_F(p, i) (p = (GLfloat *)((GLubyte *)p + i)) -/** Stepping a GLuint pointer by a byte stride */ -#define STRIDE_UI(p, i) (p = (GLuint *)((GLubyte *)p + i)) -/** Stepping a GLubyte[4] pointer by a byte stride */ -#define STRIDE_4UB(p, i) (p = (GLubyte (*)[4])((GLubyte *)p + i)) -/** Stepping a GLfloat[4] pointer by a byte stride */ -#define STRIDE_4F(p, i) (p = (GLfloat (*)[4])((GLubyte *)p + i)) -/** Stepping a \p t pointer by a byte stride */ -#define STRIDE_T(p, t, i) (p = (t)((GLubyte *)p + i)) - - -/**********************************************************************/ -/** \name 4-element vector operations */ -/*@{*/ - -/** Zero */ -#define ZERO_4V( DST ) (DST)[0] = (DST)[1] = (DST)[2] = (DST)[3] = 0 - -/** Test for equality */ -#define TEST_EQ_4V(a,b) ((a)[0] == (b)[0] && \ - (a)[1] == (b)[1] && \ - (a)[2] == (b)[2] && \ - (a)[3] == (b)[3]) - -/** Test for equality (unsigned bytes) */ -#if defined(__i386__) -#define TEST_EQ_4UBV(DST, SRC) *((GLuint*)(DST)) == *((GLuint*)(SRC)) -#else -#define TEST_EQ_4UBV(DST, SRC) TEST_EQ_4V(DST, SRC) -#endif - -/** Copy a 4-element vector */ -#define COPY_4V( DST, SRC ) \ -do { \ - (DST)[0] = (SRC)[0]; \ - (DST)[1] = (SRC)[1]; \ - (DST)[2] = (SRC)[2]; \ - (DST)[3] = (SRC)[3]; \ -} while (0) - -/** Copy a 4-element vector with cast */ -#define COPY_4V_CAST( DST, SRC, CAST ) \ -do { \ - (DST)[0] = (CAST)(SRC)[0]; \ - (DST)[1] = (CAST)(SRC)[1]; \ - (DST)[2] = (CAST)(SRC)[2]; \ - (DST)[3] = (CAST)(SRC)[3]; \ -} while (0) - -/** Copy a 4-element unsigned byte vector */ -#if defined(__i386__) -#define COPY_4UBV(DST, SRC) \ -do { \ - *((GLuint*)(DST)) = *((GLuint*)(SRC)); \ -} while (0) -#else -/* The GLuint cast might fail if DST or SRC are not dword-aligned (RISC) */ -#define COPY_4UBV(DST, SRC) \ -do { \ - (DST)[0] = (SRC)[0]; \ - (DST)[1] = (SRC)[1]; \ - (DST)[2] = (SRC)[2]; \ - (DST)[3] = (SRC)[3]; \ -} while (0) -#endif - -/** - * Copy a 4-element float vector - * memcpy seems to be most efficient - */ -#define COPY_4FV( DST, SRC ) \ -do { \ - memcpy(DST, SRC, sizeof(GLfloat) * 4); \ -} while (0) - -/** Copy \p SZ elements into a 4-element vector */ -#define COPY_SZ_4V(DST, SZ, SRC) \ -do { \ - switch (SZ) { \ - case 4: (DST)[3] = (SRC)[3]; \ - case 3: (DST)[2] = (SRC)[2]; \ - case 2: (DST)[1] = (SRC)[1]; \ - case 1: (DST)[0] = (SRC)[0]; \ - } \ -} while(0) - -/** Copy \p SZ elements into a homegeneous (4-element) vector, giving - * default values to the remaining */ -#define COPY_CLEAN_4V(DST, SZ, SRC) \ -do { \ - ASSIGN_4V( DST, 0, 0, 0, 1 ); \ - COPY_SZ_4V( DST, SZ, SRC ); \ -} while (0) - -/** Subtraction */ -#define SUB_4V( DST, SRCA, SRCB ) \ -do { \ - (DST)[0] = (SRCA)[0] - (SRCB)[0]; \ - (DST)[1] = (SRCA)[1] - (SRCB)[1]; \ - (DST)[2] = (SRCA)[2] - (SRCB)[2]; \ - (DST)[3] = (SRCA)[3] - (SRCB)[3]; \ -} while (0) - -/** Addition */ -#define ADD_4V( DST, SRCA, SRCB ) \ -do { \ - (DST)[0] = (SRCA)[0] + (SRCB)[0]; \ - (DST)[1] = (SRCA)[1] + (SRCB)[1]; \ - (DST)[2] = (SRCA)[2] + (SRCB)[2]; \ - (DST)[3] = (SRCA)[3] + (SRCB)[3]; \ -} while (0) - -/** Element-wise multiplication */ -#define SCALE_4V( DST, SRCA, SRCB ) \ -do { \ - (DST)[0] = (SRCA)[0] * (SRCB)[0]; \ - (DST)[1] = (SRCA)[1] * (SRCB)[1]; \ - (DST)[2] = (SRCA)[2] * (SRCB)[2]; \ - (DST)[3] = (SRCA)[3] * (SRCB)[3]; \ -} while (0) - -/** In-place addition */ -#define ACC_4V( DST, SRC ) \ -do { \ - (DST)[0] += (SRC)[0]; \ - (DST)[1] += (SRC)[1]; \ - (DST)[2] += (SRC)[2]; \ - (DST)[3] += (SRC)[3]; \ -} while (0) - -/** Element-wise multiplication and addition */ -#define ACC_SCALE_4V( DST, SRCA, SRCB ) \ -do { \ - (DST)[0] += (SRCA)[0] * (SRCB)[0]; \ - (DST)[1] += (SRCA)[1] * (SRCB)[1]; \ - (DST)[2] += (SRCA)[2] * (SRCB)[2]; \ - (DST)[3] += (SRCA)[3] * (SRCB)[3]; \ -} while (0) - -/** In-place scalar multiplication and addition */ -#define ACC_SCALE_SCALAR_4V( DST, S, SRCB ) \ -do { \ - (DST)[0] += S * (SRCB)[0]; \ - (DST)[1] += S * (SRCB)[1]; \ - (DST)[2] += S * (SRCB)[2]; \ - (DST)[3] += S * (SRCB)[3]; \ -} while (0) - -/** Scalar multiplication */ -#define SCALE_SCALAR_4V( DST, S, SRCB ) \ -do { \ - (DST)[0] = S * (SRCB)[0]; \ - (DST)[1] = S * (SRCB)[1]; \ - (DST)[2] = S * (SRCB)[2]; \ - (DST)[3] = S * (SRCB)[3]; \ -} while (0) - -/** In-place scalar multiplication */ -#define SELF_SCALE_SCALAR_4V( DST, S ) \ -do { \ - (DST)[0] *= S; \ - (DST)[1] *= S; \ - (DST)[2] *= S; \ - (DST)[3] *= S; \ -} while (0) - -/** Assignment */ -#define ASSIGN_4V( V, V0, V1, V2, V3 ) \ -do { \ - V[0] = V0; \ - V[1] = V1; \ - V[2] = V2; \ - V[3] = V3; \ -} while(0) - -/*@}*/ - - -/**********************************************************************/ -/** \name 3-element vector operations*/ -/*@{*/ - -/** Zero */ -#define ZERO_3V( DST ) (DST)[0] = (DST)[1] = (DST)[2] = 0 - -/** Test for equality */ -#define TEST_EQ_3V(a,b) \ - ((a)[0] == (b)[0] && \ - (a)[1] == (b)[1] && \ - (a)[2] == (b)[2]) - -/** Copy a 3-element vector */ -#define COPY_3V( DST, SRC ) \ -do { \ - (DST)[0] = (SRC)[0]; \ - (DST)[1] = (SRC)[1]; \ - (DST)[2] = (SRC)[2]; \ -} while (0) - -/** Copy a 3-element vector with cast */ -#define COPY_3V_CAST( DST, SRC, CAST ) \ -do { \ - (DST)[0] = (CAST)(SRC)[0]; \ - (DST)[1] = (CAST)(SRC)[1]; \ - (DST)[2] = (CAST)(SRC)[2]; \ -} while (0) - -/** Copy a 3-element float vector */ -#define COPY_3FV( DST, SRC ) \ -do { \ - const GLfloat *_tmp = (SRC); \ - (DST)[0] = _tmp[0]; \ - (DST)[1] = _tmp[1]; \ - (DST)[2] = _tmp[2]; \ -} while (0) - -/** Subtraction */ -#define SUB_3V( DST, SRCA, SRCB ) \ -do { \ - (DST)[0] = (SRCA)[0] - (SRCB)[0]; \ - (DST)[1] = (SRCA)[1] - (SRCB)[1]; \ - (DST)[2] = (SRCA)[2] - (SRCB)[2]; \ -} while (0) - -/** Addition */ -#define ADD_3V( DST, SRCA, SRCB ) \ -do { \ - (DST)[0] = (SRCA)[0] + (SRCB)[0]; \ - (DST)[1] = (SRCA)[1] + (SRCB)[1]; \ - (DST)[2] = (SRCA)[2] + (SRCB)[2]; \ -} while (0) - -/** In-place scalar multiplication */ -#define SCALE_3V( DST, SRCA, SRCB ) \ -do { \ - (DST)[0] = (SRCA)[0] * (SRCB)[0]; \ - (DST)[1] = (SRCA)[1] * (SRCB)[1]; \ - (DST)[2] = (SRCA)[2] * (SRCB)[2]; \ -} while (0) - -/** In-place element-wise multiplication */ -#define SELF_SCALE_3V( DST, SRC ) \ -do { \ - (DST)[0] *= (SRC)[0]; \ - (DST)[1] *= (SRC)[1]; \ - (DST)[2] *= (SRC)[2]; \ -} while (0) - -/** In-place addition */ -#define ACC_3V( DST, SRC ) \ -do { \ - (DST)[0] += (SRC)[0]; \ - (DST)[1] += (SRC)[1]; \ - (DST)[2] += (SRC)[2]; \ -} while (0) - -/** Element-wise multiplication and addition */ -#define ACC_SCALE_3V( DST, SRCA, SRCB ) \ -do { \ - (DST)[0] += (SRCA)[0] * (SRCB)[0]; \ - (DST)[1] += (SRCA)[1] * (SRCB)[1]; \ - (DST)[2] += (SRCA)[2] * (SRCB)[2]; \ -} while (0) - -/** Scalar multiplication */ -#define SCALE_SCALAR_3V( DST, S, SRCB ) \ -do { \ - (DST)[0] = S * (SRCB)[0]; \ - (DST)[1] = S * (SRCB)[1]; \ - (DST)[2] = S * (SRCB)[2]; \ -} while (0) - -/** In-place scalar multiplication and addition */ -#define ACC_SCALE_SCALAR_3V( DST, S, SRCB ) \ -do { \ - (DST)[0] += S * (SRCB)[0]; \ - (DST)[1] += S * (SRCB)[1]; \ - (DST)[2] += S * (SRCB)[2]; \ -} while (0) - -/** In-place scalar multiplication */ -#define SELF_SCALE_SCALAR_3V( DST, S ) \ -do { \ - (DST)[0] *= S; \ - (DST)[1] *= S; \ - (DST)[2] *= S; \ -} while (0) - -/** In-place scalar addition */ -#define ACC_SCALAR_3V( DST, S ) \ -do { \ - (DST)[0] += S; \ - (DST)[1] += S; \ - (DST)[2] += S; \ -} while (0) - -/** Assignment */ -#define ASSIGN_3V( V, V0, V1, V2 ) \ -do { \ - V[0] = V0; \ - V[1] = V1; \ - V[2] = V2; \ -} while(0) - -/*@}*/ - - -/**********************************************************************/ -/** \name 2-element vector operations*/ -/*@{*/ - -/** Zero */ -#define ZERO_2V( DST ) (DST)[0] = (DST)[1] = 0 - -/** Copy a 2-element vector */ -#define COPY_2V( DST, SRC ) \ -do { \ - (DST)[0] = (SRC)[0]; \ - (DST)[1] = (SRC)[1]; \ -} while (0) - -/** Copy a 2-element vector with cast */ -#define COPY_2V_CAST( DST, SRC, CAST ) \ -do { \ - (DST)[0] = (CAST)(SRC)[0]; \ - (DST)[1] = (CAST)(SRC)[1]; \ -} while (0) - -/** Copy a 2-element float vector */ -#define COPY_2FV( DST, SRC ) \ -do { \ - const GLfloat *_tmp = (SRC); \ - (DST)[0] = _tmp[0]; \ - (DST)[1] = _tmp[1]; \ -} while (0) - -/** Subtraction */ -#define SUB_2V( DST, SRCA, SRCB ) \ -do { \ - (DST)[0] = (SRCA)[0] - (SRCB)[0]; \ - (DST)[1] = (SRCA)[1] - (SRCB)[1]; \ -} while (0) - -/** Addition */ -#define ADD_2V( DST, SRCA, SRCB ) \ -do { \ - (DST)[0] = (SRCA)[0] + (SRCB)[0]; \ - (DST)[1] = (SRCA)[1] + (SRCB)[1]; \ -} while (0) - -/** In-place scalar multiplication */ -#define SCALE_2V( DST, SRCA, SRCB ) \ -do { \ - (DST)[0] = (SRCA)[0] * (SRCB)[0]; \ - (DST)[1] = (SRCA)[1] * (SRCB)[1]; \ -} while (0) - -/** In-place addition */ -#define ACC_2V( DST, SRC ) \ -do { \ - (DST)[0] += (SRC)[0]; \ - (DST)[1] += (SRC)[1]; \ -} while (0) - -/** Element-wise multiplication and addition */ -#define ACC_SCALE_2V( DST, SRCA, SRCB ) \ -do { \ - (DST)[0] += (SRCA)[0] * (SRCB)[0]; \ - (DST)[1] += (SRCA)[1] * (SRCB)[1]; \ -} while (0) - -/** Scalar multiplication */ -#define SCALE_SCALAR_2V( DST, S, SRCB ) \ -do { \ - (DST)[0] = S * (SRCB)[0]; \ - (DST)[1] = S * (SRCB)[1]; \ -} while (0) - -/** In-place scalar multiplication and addition */ -#define ACC_SCALE_SCALAR_2V( DST, S, SRCB ) \ -do { \ - (DST)[0] += S * (SRCB)[0]; \ - (DST)[1] += S * (SRCB)[1]; \ -} while (0) - -/** In-place scalar multiplication */ -#define SELF_SCALE_SCALAR_2V( DST, S ) \ -do { \ - (DST)[0] *= S; \ - (DST)[1] *= S; \ -} while (0) - -/** In-place scalar addition */ -#define ACC_SCALAR_2V( DST, S ) \ -do { \ - (DST)[0] += S; \ - (DST)[1] += S; \ -} while (0) - -/** Assign scalers to short vectors */ -#define ASSIGN_2V( V, V0, V1 ) \ -do { \ - V[0] = V0; \ - V[1] = V1; \ -} while(0) - -/*@}*/ - - -/** \name Linear interpolation macros */ -/*@{*/ - -/** - * Linear interpolation - * - * \note \p OUT argument is evaluated twice! - * \note Be wary of using *coord++ as an argument to any of these macros! - */ -#define LINTERP(T, OUT, IN) ((OUT) + (T) * ((IN) - (OUT))) - -#define INTERP_F( t, dstf, outf, inf ) \ - dstf = LINTERP( t, outf, inf ) - -#define INTERP_4F( t, dst, out, in ) \ -do { \ - dst[0] = LINTERP( (t), (out)[0], (in)[0] ); \ - dst[1] = LINTERP( (t), (out)[1], (in)[1] ); \ - dst[2] = LINTERP( (t), (out)[2], (in)[2] ); \ - dst[3] = LINTERP( (t), (out)[3], (in)[3] ); \ -} while (0) - -#define INTERP_3F( t, dst, out, in ) \ -do { \ - dst[0] = LINTERP( (t), (out)[0], (in)[0] ); \ - dst[1] = LINTERP( (t), (out)[1], (in)[1] ); \ - dst[2] = LINTERP( (t), (out)[2], (in)[2] ); \ -} while (0) - -/*@}*/ - - - -/** Clamp X to [MIN,MAX] */ -#define CLAMP( X, MIN, MAX ) ( (X)<(MIN) ? (MIN) : ((X)>(MAX) ? (MAX) : (X)) ) - -/** Minimum of two values: */ -#define MIN2( A, B ) ( (A)<(B) ? (A) : (B) ) - -/** Maximum of two values: */ -#define MAX2( A, B ) ( (A)>(B) ? (A) : (B) ) - -/** Minimum and maximum of three values: */ -#define MIN3( A, B, C ) ((A) < (B) ? MIN2(A, C) : MIN2(B, C)) -#define MAX3( A, B, C ) ((A) > (B) ? MAX2(A, C) : MAX2(B, C)) - -/** Dot product of two 2-element vectors */ -#define DOT2( a, b ) ( (a)[0]*(b)[0] + (a)[1]*(b)[1] ) - -/** Dot product of two 3-element vectors */ -#define DOT3( a, b ) ( (a)[0]*(b)[0] + (a)[1]*(b)[1] + (a)[2]*(b)[2] ) - -/** Dot product of two 4-element vectors */ -#define DOT4( a, b ) ( (a)[0]*(b)[0] + (a)[1]*(b)[1] + \ - (a)[2]*(b)[2] + (a)[3]*(b)[3] ) - - -/** Cross product of two 3-element vectors */ -#define CROSS3(n, u, v) \ -do { \ - (n)[0] = (u)[1]*(v)[2] - (u)[2]*(v)[1]; \ - (n)[1] = (u)[2]*(v)[0] - (u)[0]*(v)[2]; \ - (n)[2] = (u)[0]*(v)[1] - (u)[1]*(v)[0]; \ -} while (0) - - -/* Normalize a 3-element vector to unit length. */ -#define NORMALIZE_3FV( V ) \ -do { \ - GLfloat len = (GLfloat) LEN_SQUARED_3FV(V); \ - if (len) { \ - len = INV_SQRTF(len); \ - (V)[0] = (GLfloat) ((V)[0] * len); \ - (V)[1] = (GLfloat) ((V)[1] * len); \ - (V)[2] = (GLfloat) ((V)[2] * len); \ - } \ -} while(0) - -#define LEN_3FV( V ) (SQRTF((V)[0]*(V)[0]+(V)[1]*(V)[1]+(V)[2]*(V)[2])) -#define LEN_2FV( V ) (SQRTF((V)[0]*(V)[0]+(V)[1]*(V)[1])) - -#define LEN_SQUARED_3FV( V ) ((V)[0]*(V)[0]+(V)[1]*(V)[1]+(V)[2]*(V)[2]) -#define LEN_SQUARED_2FV( V ) ((V)[0]*(V)[0]+(V)[1]*(V)[1]) - - -/** Compute ceiling of integer quotient of A divided by B. */ -#define CEILING( A, B ) ( (A) % (B) == 0 ? (A)/(B) : (A)/(B)+1 ) - - -/** casts to silence warnings with some compilers */ -#define ENUM_TO_INT(E) ((GLint)(E)) -#define ENUM_TO_FLOAT(E) ((GLfloat)(GLint)(E)) -#define ENUM_TO_DOUBLE(E) ((GLdouble)(GLint)(E)) -#define ENUM_TO_BOOLEAN(E) ((E) ? GL_TRUE : GL_FALSE) - - -#endif diff --git a/dll/opengl/mesa/main/matrix.c b/dll/opengl/mesa/main/matrix.c deleted file mode 100644 index 964172b3470..00000000000 --- a/dll/opengl/mesa/main/matrix.c +++ /dev/null @@ -1,711 +0,0 @@ -/* - * Mesa 3-D graphics library - * Version: 7.5 - * - * Copyright (C) 1999-2008 Brian Paul All Rights Reserved. - * Copyright (C) 2009 VMware, Inc. All Rights Reserved. - * - * Permission is hereby granted, free of charge, to any person obtaining a - * copy of this software and associated documentation files (the "Software"), - * to deal in the Software without restriction, including without limitation - * the rights to use, copy, modify, merge, publish, distribute, sublicense, - * and/or sell copies of the Software, and to permit persons to whom the - * Software is furnished to do so, subject to the following conditions: - * - * The above copyright notice and this permission notice shall be included - * in all copies or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS - * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL - * BRIAN PAUL BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN - * AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN - * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. - */ - - -/** - * \file matrix.c - * Matrix operations. - * - * \note - * -# 4x4 transformation matrices are stored in memory in column major order. - * -# Points/vertices are to be thought of as column vectors. - * -# Transformation of a point p by a matrix M is: p' = M * p - */ - -#include - -/** - * Apply a perspective projection matrix. - * - * \param left left clipping plane coordinate. - * \param right right clipping plane coordinate. - * \param bottom bottom clipping plane coordinate. - * \param top top clipping plane coordinate. - * \param nearval distance to the near clipping plane. - * \param farval distance to the far clipping plane. - * - * \sa glFrustum(). - * - * Flushes vertices and validates parameters. Calls _math_matrix_frustum() with - * the top matrix of the current matrix stack and sets - * __struct gl_contextRec::NewState. - */ -void GLAPIENTRY -_mesa_Frustum( GLdouble left, GLdouble right, - GLdouble bottom, GLdouble top, - GLdouble nearval, GLdouble farval ) -{ - GET_CURRENT_CONTEXT(ctx); - ASSERT_OUTSIDE_BEGIN_END_AND_FLUSH(ctx); - - if (nearval <= 0.0 || - farval <= 0.0 || - nearval == farval || - left == right || - top == bottom) - { - _mesa_error( ctx, GL_INVALID_VALUE, "glFrustum" ); - return; - } - - _math_matrix_frustum( ctx->CurrentStack->Top, - (GLfloat) left, (GLfloat) right, - (GLfloat) bottom, (GLfloat) top, - (GLfloat) nearval, (GLfloat) farval ); - ctx->NewState |= ctx->CurrentStack->DirtyFlag; -} - - -/** - * Apply an orthographic projection matrix. - * - * \param left left clipping plane coordinate. - * \param right right clipping plane coordinate. - * \param bottom bottom clipping plane coordinate. - * \param top top clipping plane coordinate. - * \param nearval distance to the near clipping plane. - * \param farval distance to the far clipping plane. - * - * \sa glOrtho(). - * - * Flushes vertices and validates parameters. Calls _math_matrix_ortho() with - * the top matrix of the current matrix stack and sets - * __struct gl_contextRec::NewState. - */ -void GLAPIENTRY -_mesa_Ortho( GLdouble left, GLdouble right, - GLdouble bottom, GLdouble top, - GLdouble nearval, GLdouble farval ) -{ - GET_CURRENT_CONTEXT(ctx); - ASSERT_OUTSIDE_BEGIN_END_AND_FLUSH(ctx); - - if (MESA_VERBOSE & VERBOSE_API) - _mesa_debug(ctx, "glOrtho(%f, %f, %f, %f, %f, %f)\n", - left, right, bottom, top, nearval, farval); - - if (left == right || - bottom == top || - nearval == farval) - { - _mesa_error( ctx, GL_INVALID_VALUE, "glOrtho" ); - return; - } - - _math_matrix_ortho( ctx->CurrentStack->Top, - (GLfloat) left, (GLfloat) right, - (GLfloat) bottom, (GLfloat) top, - (GLfloat) nearval, (GLfloat) farval ); - ctx->NewState |= ctx->CurrentStack->DirtyFlag; -} - - -/** - * Set the current matrix stack. - * - * \param mode matrix stack. - * - * \sa glMatrixMode(). - * - * Flushes the vertices, validates the parameter and updates - * __struct gl_contextRec::CurrentStack and gl_transform_attrib::MatrixMode - * with the specified matrix stack. - */ -void GLAPIENTRY -_mesa_MatrixMode( GLenum mode ) -{ - GET_CURRENT_CONTEXT(ctx); - ASSERT_OUTSIDE_BEGIN_END(ctx); - - if (ctx->Transform.MatrixMode == mode && mode != GL_TEXTURE) - return; - FLUSH_VERTICES(ctx, _NEW_TRANSFORM); - - switch (mode) { - case GL_MODELVIEW: - ctx->CurrentStack = &ctx->ModelviewMatrixStack; - break; - case GL_PROJECTION: - ctx->CurrentStack = &ctx->ProjectionMatrixStack; - break; - case GL_TEXTURE: - ctx->CurrentStack = &ctx->TextureMatrixStack; - break; - default: - _mesa_error( ctx, GL_INVALID_ENUM, "glMatrixMode(mode)" ); - return; - } - - ctx->Transform.MatrixMode = mode; -} - - -/** - * Push the current matrix stack. - * - * \sa glPushMatrix(). - * - * Verifies the current matrix stack is not full, and duplicates the top-most - * matrix in the stack. - * Marks __struct gl_contextRec::NewState with the stack dirty flag. - */ -void GLAPIENTRY -_mesa_PushMatrix( void ) -{ - GET_CURRENT_CONTEXT(ctx); - struct gl_matrix_stack *stack = ctx->CurrentStack; - ASSERT_OUTSIDE_BEGIN_END(ctx); - - if (MESA_VERBOSE&VERBOSE_API) - _mesa_debug(ctx, "glPushMatrix %s\n", - _mesa_lookup_enum_by_nr(ctx->Transform.MatrixMode)); - - if (stack->Depth + 1 >= stack->MaxDepth) { - if (ctx->Transform.MatrixMode == GL_TEXTURE) { - _mesa_error(ctx, GL_STACK_OVERFLOW, - "glPushMatrix(mode=GL_TEXTURE)"); - } - else { - _mesa_error(ctx, GL_STACK_OVERFLOW, "glPushMatrix(mode=%s)", - _mesa_lookup_enum_by_nr(ctx->Transform.MatrixMode)); - } - return; - } - _math_matrix_copy( &stack->Stack[stack->Depth + 1], - &stack->Stack[stack->Depth] ); - stack->Depth++; - stack->Top = &(stack->Stack[stack->Depth]); - ctx->NewState |= stack->DirtyFlag; -} - - -/** - * Pop the current matrix stack. - * - * \sa glPopMatrix(). - * - * Flushes the vertices, verifies the current matrix stack is not empty, and - * moves the stack head down. - * Marks __struct gl_contextRec::NewState with the dirty stack flag. - */ -void GLAPIENTRY -_mesa_PopMatrix( void ) -{ - GET_CURRENT_CONTEXT(ctx); - struct gl_matrix_stack *stack = ctx->CurrentStack; - ASSERT_OUTSIDE_BEGIN_END_AND_FLUSH(ctx); - - if (MESA_VERBOSE&VERBOSE_API) - _mesa_debug(ctx, "glPopMatrix %s\n", - _mesa_lookup_enum_by_nr(ctx->Transform.MatrixMode)); - - if (stack->Depth == 0) { - if (ctx->Transform.MatrixMode == GL_TEXTURE) { - _mesa_error(ctx, GL_STACK_UNDERFLOW, - "glPopMatrix(mode=GL_TEXTURE)"); - } - else { - _mesa_error(ctx, GL_STACK_UNDERFLOW, "glPopMatrix(mode=%s)", - _mesa_lookup_enum_by_nr(ctx->Transform.MatrixMode)); - } - return; - } - stack->Depth--; - stack->Top = &(stack->Stack[stack->Depth]); - ctx->NewState |= stack->DirtyFlag; -} - - -/** - * Replace the current matrix with the identity matrix. - * - * \sa glLoadIdentity(). - * - * Flushes the vertices and calls _math_matrix_set_identity() with the - * top-most matrix in the current stack. - * Marks __struct gl_contextRec::NewState with the stack dirty flag. - */ -void GLAPIENTRY -_mesa_LoadIdentity( void ) -{ - GET_CURRENT_CONTEXT(ctx); - ASSERT_OUTSIDE_BEGIN_END_AND_FLUSH(ctx); - - if (MESA_VERBOSE & VERBOSE_API) - _mesa_debug(ctx, "glLoadIdentity()\n"); - - _math_matrix_set_identity( ctx->CurrentStack->Top ); - ctx->NewState |= ctx->CurrentStack->DirtyFlag; -} - - -/** - * Replace the current matrix with a given matrix. - * - * \param m matrix. - * - * \sa glLoadMatrixf(). - * - * Flushes the vertices and calls _math_matrix_loadf() with the top-most - * matrix in the current stack and the given matrix. - * Marks __struct gl_contextRec::NewState with the dirty stack flag. - */ -void GLAPIENTRY -_mesa_LoadMatrixf( const GLfloat *m ) -{ - GET_CURRENT_CONTEXT(ctx); - if (!m) return; - if (MESA_VERBOSE & VERBOSE_API) - _mesa_debug(ctx, - "glLoadMatrix(%f %f %f %f, %f %f %f %f, %f %f %f %f, %f %f %f %f\n", - m[0], m[4], m[8], m[12], - m[1], m[5], m[9], m[13], - m[2], m[6], m[10], m[14], - m[3], m[7], m[11], m[15]); - - ASSERT_OUTSIDE_BEGIN_END_AND_FLUSH(ctx); - _math_matrix_loadf( ctx->CurrentStack->Top, m ); - ctx->NewState |= ctx->CurrentStack->DirtyFlag; -} - - -/** - * Multiply the current matrix with a given matrix. - * - * \param m matrix. - * - * \sa glMultMatrixf(). - * - * Flushes the vertices and calls _math_matrix_mul_floats() with the top-most - * matrix in the current stack and the given matrix. Marks - * __struct gl_contextRec::NewState with the dirty stack flag. - */ -void GLAPIENTRY -_mesa_MultMatrixf( const GLfloat *m ) -{ - GET_CURRENT_CONTEXT(ctx); - if (!m) return; - if (MESA_VERBOSE & VERBOSE_API) - _mesa_debug(ctx, - "glMultMatrix(%f %f %f %f, %f %f %f %f, %f %f %f %f, %f %f %f %f\n", - m[0], m[4], m[8], m[12], - m[1], m[5], m[9], m[13], - m[2], m[6], m[10], m[14], - m[3], m[7], m[11], m[15]); - ASSERT_OUTSIDE_BEGIN_END_AND_FLUSH(ctx); - _math_matrix_mul_floats( ctx->CurrentStack->Top, m ); - ctx->NewState |= ctx->CurrentStack->DirtyFlag; -} - - -/** - * Multiply the current matrix with a rotation matrix. - * - * \param angle angle of rotation, in degrees. - * \param x rotation vector x coordinate. - * \param y rotation vector y coordinate. - * \param z rotation vector z coordinate. - * - * \sa glRotatef(). - * - * Flushes the vertices and calls _math_matrix_rotate() with the top-most - * matrix in the current stack and the given parameters. Marks - * __struct gl_contextRec::NewState with the dirty stack flag. - */ -void GLAPIENTRY -_mesa_Rotatef( GLfloat angle, GLfloat x, GLfloat y, GLfloat z ) -{ - GET_CURRENT_CONTEXT(ctx); - ASSERT_OUTSIDE_BEGIN_END_AND_FLUSH(ctx); - if (angle != 0.0F) { - _math_matrix_rotate( ctx->CurrentStack->Top, angle, x, y, z); - ctx->NewState |= ctx->CurrentStack->DirtyFlag; - } -} - - -/** - * Multiply the current matrix with a general scaling matrix. - * - * \param x x axis scale factor. - * \param y y axis scale factor. - * \param z z axis scale factor. - * - * \sa glScalef(). - * - * Flushes the vertices and calls _math_matrix_scale() with the top-most - * matrix in the current stack and the given parameters. Marks - * __struct gl_contextRec::NewState with the dirty stack flag. - */ -void GLAPIENTRY -_mesa_Scalef( GLfloat x, GLfloat y, GLfloat z ) -{ - GET_CURRENT_CONTEXT(ctx); - ASSERT_OUTSIDE_BEGIN_END_AND_FLUSH(ctx); - _math_matrix_scale( ctx->CurrentStack->Top, x, y, z); - ctx->NewState |= ctx->CurrentStack->DirtyFlag; -} - - -/** - * Multiply the current matrix with a translation matrix. - * - * \param x translation vector x coordinate. - * \param y translation vector y coordinate. - * \param z translation vector z coordinate. - * - * \sa glTranslatef(). - * - * Flushes the vertices and calls _math_matrix_translate() with the top-most - * matrix in the current stack and the given parameters. Marks - * __struct gl_contextRec::NewState with the dirty stack flag. - */ -void GLAPIENTRY -_mesa_Translatef( GLfloat x, GLfloat y, GLfloat z ) -{ - GET_CURRENT_CONTEXT(ctx); - ASSERT_OUTSIDE_BEGIN_END_AND_FLUSH(ctx); - _math_matrix_translate( ctx->CurrentStack->Top, x, y, z); - ctx->NewState |= ctx->CurrentStack->DirtyFlag; -} - - -#if _HAVE_FULL_GL -void GLAPIENTRY -_mesa_LoadMatrixd( const GLdouble *m ) -{ - GLint i; - GLfloat f[16]; - if (!m) return; - for (i = 0; i < 16; i++) - f[i] = (GLfloat) m[i]; - _mesa_LoadMatrixf(f); -} - -void GLAPIENTRY -_mesa_MultMatrixd( const GLdouble *m ) -{ - GLint i; - GLfloat f[16]; - if (!m) return; - for (i = 0; i < 16; i++) - f[i] = (GLfloat) m[i]; - _mesa_MultMatrixf( f ); -} - - -void GLAPIENTRY -_mesa_Rotated( GLdouble angle, GLdouble x, GLdouble y, GLdouble z ) -{ - _mesa_Rotatef((GLfloat) angle, (GLfloat) x, (GLfloat) y, (GLfloat) z); -} - - -void GLAPIENTRY -_mesa_Scaled( GLdouble x, GLdouble y, GLdouble z ) -{ - _mesa_Scalef((GLfloat) x, (GLfloat) y, (GLfloat) z); -} - - -void GLAPIENTRY -_mesa_Translated( GLdouble x, GLdouble y, GLdouble z ) -{ - _mesa_Translatef((GLfloat) x, (GLfloat) y, (GLfloat) z); -} -#endif - - -#if _HAVE_FULL_GL -void GLAPIENTRY -_mesa_LoadTransposeMatrixfARB( const GLfloat *m ) -{ - GLfloat tm[16]; - if (!m) return; - _math_transposef(tm, m); - _mesa_LoadMatrixf(tm); -} - - -void GLAPIENTRY -_mesa_LoadTransposeMatrixdARB( const GLdouble *m ) -{ - GLfloat tm[16]; - if (!m) return; - _math_transposefd(tm, m); - _mesa_LoadMatrixf(tm); -} - - -void GLAPIENTRY -_mesa_MultTransposeMatrixfARB( const GLfloat *m ) -{ - GLfloat tm[16]; - if (!m) return; - _math_transposef(tm, m); - _mesa_MultMatrixf(tm); -} - - -void GLAPIENTRY -_mesa_MultTransposeMatrixdARB( const GLdouble *m ) -{ - GLfloat tm[16]; - if (!m) return; - _math_transposefd(tm, m); - _mesa_MultMatrixf(tm); -} -#endif - - - -/**********************************************************************/ -/** \name State management */ -/*@{*/ - - -/** - * Update the projection matrix stack. - * - * \param ctx GL context. - * - * Calls _math_matrix_analyse() with the top-matrix of the projection matrix - * stack, and recomputes user clip positions if necessary. - * - * \note This routine references __struct gl_contextRec::Tranform attribute - * values to compute userclip positions in clip space, but is only called on - * _NEW_PROJECTION. The _mesa_ClipPlane() function keeps these values up to - * date across changes to the __struct gl_contextRec::Transform attributes. - */ -static void -update_projection( struct gl_context *ctx ) -{ - _math_matrix_analyse( ctx->ProjectionMatrixStack.Top ); - -#if FEATURE_userclip - /* Recompute clip plane positions in clipspace. This is also done - * in _mesa_ClipPlane(). - */ - if (ctx->Transform.ClipPlanesEnabled) { - GLuint p; - for (p = 0; p < ctx->Const.MaxClipPlanes; p++) { - if (ctx->Transform.ClipPlanesEnabled & (1 << p)) { - _mesa_transform_vector( ctx->Transform._ClipUserPlane[p], - ctx->Transform.EyeUserPlane[p], - ctx->ProjectionMatrixStack.Top->inv ); - } - } - } -#endif -} - - -/** - * Calculate the combined modelview-projection matrix. - * - * \param ctx GL context. - * - * Multiplies the top matrices of the projection and model view stacks into - * __struct gl_contextRec::_ModelProjectMatrix via _math_matrix_mul_matrix() - * and analyzes the resulting matrix via _math_matrix_analyse(). - */ -static void -calculate_model_project_matrix( struct gl_context *ctx ) -{ - _math_matrix_mul_matrix( &ctx->_ModelProjectMatrix, - ctx->ProjectionMatrixStack.Top, - ctx->ModelviewMatrixStack.Top ); - - _math_matrix_analyse( &ctx->_ModelProjectMatrix ); -} - - -/** - * Updates the combined modelview-projection matrix. - * - * \param ctx GL context. - * \param new_state new state bit mask. - * - * If there is a new model view matrix then analyzes it. If there is a new - * projection matrix, updates it. Finally calls - * calculate_model_project_matrix() to recalculate the modelview-projection - * matrix. - */ -void _mesa_update_modelview_project( struct gl_context *ctx, GLuint new_state ) -{ - if (new_state & _NEW_MODELVIEW) { - _math_matrix_analyse( ctx->ModelviewMatrixStack.Top ); - - /* Bring cull position up to date. - */ - TRANSFORM_POINT3( ctx->Transform.CullObjPos, - ctx->ModelviewMatrixStack.Top->inv, - ctx->Transform.CullEyePos ); - } - - - if (new_state & _NEW_PROJECTION) - update_projection( ctx ); - - /* Keep ModelviewProject up to date always to allow tnl - * implementations that go model->clip even when eye is required. - */ - calculate_model_project_matrix(ctx); -} - -/*@}*/ - - -/**********************************************************************/ -/** Matrix stack initialization */ -/*@{*/ - - -/** - * Initialize a matrix stack. - * - * \param stack matrix stack. - * \param maxDepth maximum stack depth. - * \param dirtyFlag dirty flag. - * - * Allocates an array of \p maxDepth elements for the matrix stack and calls - * _math_matrix_ctr() and _math_matrix_alloc_inv() for each element to - * initialize it. - */ -static void -init_matrix_stack( struct gl_matrix_stack *stack, - GLuint maxDepth, GLuint dirtyFlag ) -{ - GLuint i; - - stack->Depth = 0; - stack->MaxDepth = maxDepth; - stack->DirtyFlag = dirtyFlag; - /* The stack */ - stack->Stack = (GLmatrix *) CALLOC(maxDepth * sizeof(GLmatrix)); - for (i = 0; i < maxDepth; i++) { - _math_matrix_ctr(&stack->Stack[i]); - _math_matrix_alloc_inv(&stack->Stack[i]); - } - stack->Top = stack->Stack; -} - -/** - * Free matrix stack. - * - * \param stack matrix stack. - * - * Calls _math_matrix_dtr() for each element of the matrix stack and - * frees the array. - */ -static void -free_matrix_stack( struct gl_matrix_stack *stack ) -{ - GLuint i; - for (i = 0; i < stack->MaxDepth; i++) { - _math_matrix_dtr(&stack->Stack[i]); - } - FREE(stack->Stack); - stack->Stack = stack->Top = NULL; -} - -/*@}*/ - - -/**********************************************************************/ -/** \name Initialization */ -/*@{*/ - - -/** - * Initialize the context matrix data. - * - * \param ctx GL context. - * - * Initializes each of the matrix stacks and the combined modelview-projection - * matrix. - */ -void _mesa_init_matrix( struct gl_context * ctx ) -{ - /* Initialize matrix stacks */ - init_matrix_stack(&ctx->ModelviewMatrixStack, MAX_MODELVIEW_STACK_DEPTH, - _NEW_MODELVIEW); - init_matrix_stack(&ctx->ProjectionMatrixStack, MAX_PROJECTION_STACK_DEPTH, - _NEW_PROJECTION); - init_matrix_stack(&ctx->TextureMatrixStack, MAX_TEXTURE_STACK_DEPTH, - _NEW_TEXTURE_MATRIX); - ctx->CurrentStack = &ctx->ModelviewMatrixStack; - - /* Init combined Modelview*Projection matrix */ - _math_matrix_ctr( &ctx->_ModelProjectMatrix ); -} - - -/** - * Free the context matrix data. - * - * \param ctx GL context. - * - * Frees each of the matrix stacks and the combined modelview-projection - * matrix. - */ -void _mesa_free_matrix_data( struct gl_context *ctx ) -{ - free_matrix_stack(&ctx->ModelviewMatrixStack); - free_matrix_stack(&ctx->ProjectionMatrixStack); - free_matrix_stack(&ctx->TextureMatrixStack); - /* combined Modelview*Projection matrix */ - _math_matrix_dtr( &ctx->_ModelProjectMatrix ); - -} - - -/** - * Initialize the context transform attribute group. - * - * \param ctx GL context. - * - * \todo Move this to a new file with other 'transform' routines. - */ -void _mesa_init_transform( struct gl_context *ctx ) -{ - GLint i; - - /* Transformation group */ - ctx->Transform.MatrixMode = GL_MODELVIEW; - ctx->Transform.Normalize = GL_FALSE; - ctx->Transform.RescaleNormals = GL_FALSE; - ctx->Transform.RasterPositionUnclipped = GL_FALSE; - for (i=0;iConst.MaxClipPlanes;i++) { - ASSIGN_4V( ctx->Transform.EyeUserPlane[i], 0.0, 0.0, 0.0, 0.0 ); - } - ctx->Transform.ClipPlanesEnabled = 0; - - ASSIGN_4V( ctx->Transform.CullObjPos, 0.0, 0.0, 1.0, 0.0 ); - ASSIGN_4V( ctx->Transform.CullEyePos, 0.0, 0.0, 1.0, 0.0 ); -} - - -/*@}*/ diff --git a/dll/opengl/mesa/main/matrix.h b/dll/opengl/mesa/main/matrix.h deleted file mode 100644 index 2878cc134b5..00000000000 --- a/dll/opengl/mesa/main/matrix.h +++ /dev/null @@ -1,113 +0,0 @@ -/* - * Mesa 3-D graphics library - * Version: 7.5 - * - * Copyright (C) 1999-2008 Brian Paul All Rights Reserved. - * Copyright (C) 2009 VMware, Inc. All Rights Reserved. - * - * Permission is hereby granted, free of charge, to any person obtaining a - * copy of this software and associated documentation files (the "Software"), - * to deal in the Software without restriction, including without limitation - * the rights to use, copy, modify, merge, publish, distribute, sublicense, - * and/or sell copies of the Software, and to permit persons to whom the - * Software is furnished to do so, subject to the following conditions: - * - * The above copyright notice and this permission notice shall be included - * in all copies or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS - * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL - * BRIAN PAUL BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN - * AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN - * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. - */ - - -#ifndef MATRIX_H -#define MATRIX_H - - -#include "glheader.h" - -struct gl_context; - -extern void GLAPIENTRY -_mesa_Frustum( GLdouble left, GLdouble right, - GLdouble bottom, GLdouble top, - GLdouble nearval, GLdouble farval ); - -extern void GLAPIENTRY -_mesa_Ortho( GLdouble left, GLdouble right, - GLdouble bottom, GLdouble top, - GLdouble nearval, GLdouble farval ); - -extern void GLAPIENTRY -_mesa_PushMatrix( void ); - -extern void GLAPIENTRY -_mesa_PopMatrix( void ); - -extern void GLAPIENTRY -_mesa_LoadIdentity( void ); - -extern void GLAPIENTRY -_mesa_LoadMatrixf( const GLfloat *m ); - -extern void GLAPIENTRY -_mesa_LoadMatrixd( const GLdouble *m ); - -extern void GLAPIENTRY -_mesa_MatrixMode( GLenum mode ); - -extern void GLAPIENTRY -_mesa_MultMatrixf( const GLfloat *m ); - -extern void GLAPIENTRY -_mesa_MultMatrixd( const GLdouble *m ); - -extern void GLAPIENTRY -_mesa_Rotatef( GLfloat angle, GLfloat x, GLfloat y, GLfloat z ); - -extern void GLAPIENTRY -_mesa_Rotated( GLdouble angle, GLdouble x, GLdouble y, GLdouble z ); - -extern void GLAPIENTRY -_mesa_Scalef( GLfloat x, GLfloat y, GLfloat z ); - -extern void GLAPIENTRY -_mesa_Scaled( GLdouble x, GLdouble y, GLdouble z ); - -extern void GLAPIENTRY -_mesa_Translatef( GLfloat x, GLfloat y, GLfloat z ); - -extern void GLAPIENTRY -_mesa_Translated( GLdouble x, GLdouble y, GLdouble z ); - -extern void GLAPIENTRY -_mesa_LoadTransposeMatrixfARB( const GLfloat *m ); - -extern void GLAPIENTRY -_mesa_LoadTransposeMatrixdARB( const GLdouble *m ); - -extern void GLAPIENTRY -_mesa_MultTransposeMatrixfARB( const GLfloat *m ); - -extern void GLAPIENTRY -_mesa_MultTransposeMatrixdARB( const GLdouble *m ); - - -extern void -_mesa_init_matrix( struct gl_context * ctx ); - -extern void -_mesa_init_transform( struct gl_context *ctx ); - -extern void -_mesa_free_matrix_data( struct gl_context *ctx ); - -extern void -_mesa_update_modelview_project( struct gl_context *ctx, GLuint newstate ); - - -#endif diff --git a/dll/opengl/mesa/main/mfeatures.h b/dll/opengl/mesa/main/mfeatures.h deleted file mode 100644 index 41d3bda35ed..00000000000 --- a/dll/opengl/mesa/main/mfeatures.h +++ /dev/null @@ -1,135 +0,0 @@ -/* - * Mesa 3-D graphics library - * Version: 7.1 - * - * Copyright (C) 1999-2008 Brian Paul All Rights Reserved. - * - * Permission is hereby granted, free of charge, to any person obtaining a - * copy of this software and associated documentation files (the "Software"), - * to deal in the Software without restriction, including without limitation - * the rights to use, copy, modify, merge, publish, distribute, sublicense, - * and/or sell copies of the Software, and to permit persons to whom the - * Software is furnished to do so, subject to the following conditions: - * - * The above copyright notice and this permission notice shall be included - * in all copies or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS - * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL - * BRIAN PAUL BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN - * AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN - * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. - */ - - -/** - * \file mfeatures.h - * Flags to enable/disable specific parts of the API. - */ - -#ifndef FEATURES_H -#define FEATURES_H - - -#ifndef _HAVE_FULL_GL -#define _HAVE_FULL_GL 1 -#endif - -/* assert that a feature is disabled and should never be used */ -#define ASSERT_NO_FEATURE() ASSERT(0) - -/** - * A feature can be anything. But most of them share certain characteristics. - * - * When a feature defines vtxfmt entries, they can be initialized and - * installed by - * _MESA_INIT__VTXFMT - * _mesa_install__vtxfmt - * - * When a feature defines dispatch entries, they are initialized by - * _mesa_init__dispatch - * - * When a feature has states, they are initialized and freed by - * _mesa_init_ - * _mesa_free__data - * - * Except for states, the others compile to no-op when a feature is disabled. - * - * The GLAPIENTRYs and helper functions defined by a feature should also - * compile to no-op when it is disabled. But to save typings and to catch - * bugs, some of them may be unavailable, or compile to ASSERT_NO_FEATURE() - * when the feature is disabled. - * - * A feature following the conventions may be used without knowing if it is - * enabled or not. - */ - -#ifndef FEATURE_ES1 -#define FEATURE_ES1 0 -#endif -#ifndef FEATURE_ES2 -#define FEATURE_ES2 0 -#endif - -#define FEATURE_ES (FEATURE_ES1 || FEATURE_ES2) - -#ifndef FEATURE_GL -#define FEATURE_GL !FEATURE_ES -#endif - -#define FEATURE_dispatch 1 -#define FEATURE_texgen 1 -#define FEATURE_userclip 1 - -#define FEATURE_accum FEATURE_GL -#define FEATURE_arrayelt FEATURE_GL -#define FEATURE_attrib_stack FEATURE_GL -/* this disables vtxfmt, api_loopback, and api_noop completely */ -#define FEATURE_beginend FEATURE_GL -#define FEATURE_colortable FEATURE_GL -#define FEATURE_convolve FEATURE_GL -#define FEATURE_dlist (FEATURE_GL && FEATURE_arrayelt && FEATURE_beginend) -#define FEATURE_draw_read_buffer FEATURE_GL -#define FEATURE_drawpix FEATURE_GL -#define FEATURE_evaluators FEATURE_GL -#define FEATURE_feedback FEATURE_GL -#define FEATURE_pixel_transfer FEATURE_GL -#define FEATURE_queryobj FEATURE_GL -#define FEATURE_rastpos FEATURE_GL - -#define FEATURE_extra_context_init FEATURE_ES -#define FEATURE_point_size_array FEATURE_ES - -#define FEATURE_ARB_fragment_program 1 -#define FEATURE_ARB_vertex_program 1 -#define FEATURE_ARB_vertex_shader 1 -#define FEATURE_ARB_fragment_shader 1 -#define FEATURE_ARB_shader_objects (FEATURE_ARB_vertex_shader || FEATURE_ARB_fragment_shader) -#define FEATURE_ARB_shading_language_100 FEATURE_ARB_shader_objects -#define FEATURE_ARB_geometry_shader4 FEATURE_ARB_shader_objects - -#define FEATURE_ARB_framebuffer_object (FEATURE_GL && FEATURE_EXT_framebuffer_object) -#define FEATURE_ARB_map_buffer_range FEATURE_GL -#define FEATURE_ARB_pixel_buffer_object (FEATURE_GL && FEATURE_EXT_pixel_buffer_object) -#define FEATURE_ARB_sampler_objects FEATURE_GL -#define FEATURE_ARB_sync FEATURE_GL - -#define FEATURE_EXT_framebuffer_blit FEATURE_GL -#define FEATURE_EXT_framebuffer_object 1 -#define FEATURE_EXT_pixel_buffer_object 1 -#define FEATURE_EXT_texture_sRGB FEATURE_GL -#define FEATURE_EXT_transform_feedback FEATURE_GL - -#define FEATURE_APPLE_object_purgeable FEATURE_GL -#define FEATURE_ATI_fragment_shader 0 -#define FEATURE_NV_fence FEATURE_GL -#define FEATURE_NV_fragment_program 0 -#define FEATURE_NV_vertex_program 0 - -#define FEATURE_OES_EGL_image 1 -#define FEATURE_OES_draw_texture FEATURE_ES1 -#define FEATURE_OES_framebuffer_object FEATURE_ES -#define FEATURE_OES_mapbuffer FEATURE_ES - -#endif /* FEATURES_H */ diff --git a/dll/opengl/mesa/main/mm.c b/dll/opengl/mesa/main/mm.c deleted file mode 100644 index 36cae8aa0f1..00000000000 --- a/dll/opengl/mesa/main/mm.c +++ /dev/null @@ -1,281 +0,0 @@ -/* - * GLX Hardware Device Driver common code - * Copyright (C) 1999 Wittawat Yamwong - * - * Permission is hereby granted, free of charge, to any person obtaining a - * copy of this software and associated documentation files (the "Software"), - * to deal in the Software without restriction, including without limitation - * the rights to use, copy, modify, merge, publish, distribute, sublicense, - * and/or sell copies of the Software, and to permit persons to whom the - * Software is furnished to do so, subject to the following conditions: - * - * The above copyright notice and this permission notice shall be included - * in all copies or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS - * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL - * WITTAWAT YAMWONG, OR ANY OTHER CONTRIBUTORS BE LIABLE FOR ANY CLAIM, - * DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR - * OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE - * OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. - * - */ - -#include - -#include -#include -#include - -void -mmDumpMemInfo(const struct mem_block *heap) -{ - fprintf(stderr, "Memory heap %p:\n", (void *)heap); - if (heap == 0) { - fprintf(stderr, " heap == 0\n"); - } else { - const struct mem_block *p; - - for(p = heap->next; p != heap; p = p->next) { - fprintf(stderr, " Offset:%08x, Size:%08x, %c%c\n",p->ofs,p->size, - p->free ? 'F':'.', - p->reserved ? 'R':'.'); - } - - fprintf(stderr, "\nFree list:\n"); - - for(p = heap->next_free; p != heap; p = p->next_free) { - fprintf(stderr, " FREE Offset:%08x, Size:%08x, %c%c\n",p->ofs,p->size, - p->free ? 'F':'.', - p->reserved ? 'R':'.'); - } - - } - fprintf(stderr, "End of memory blocks\n"); -} - -struct mem_block * -mmInit(unsigned ofs, unsigned size) -{ - struct mem_block *heap, *block; - - if (!size) - return NULL; - - heap = (struct mem_block *) calloc(1, sizeof(struct mem_block)); - if (!heap) - return NULL; - - block = (struct mem_block *) calloc(1, sizeof(struct mem_block)); - if (!block) { - free(heap); - return NULL; - } - - heap->next = block; - heap->prev = block; - heap->next_free = block; - heap->prev_free = block; - - block->heap = heap; - block->next = heap; - block->prev = heap; - block->next_free = heap; - block->prev_free = heap; - - block->ofs = ofs; - block->size = size; - block->free = 1; - - return heap; -} - - -static struct mem_block * -SliceBlock(struct mem_block *p, - unsigned startofs, unsigned size, - unsigned reserved, unsigned alignment) -{ - struct mem_block *newblock; - - /* break left [p, newblock, p->next], then p = newblock */ - if (startofs > p->ofs) { - newblock = (struct mem_block*) calloc(1, sizeof(struct mem_block)); - if (!newblock) - return NULL; - newblock->ofs = startofs; - newblock->size = p->size - (startofs - p->ofs); - newblock->free = 1; - newblock->heap = p->heap; - - newblock->next = p->next; - newblock->prev = p; - p->next->prev = newblock; - p->next = newblock; - - newblock->next_free = p->next_free; - newblock->prev_free = p; - p->next_free->prev_free = newblock; - p->next_free = newblock; - - p->size -= newblock->size; - p = newblock; - } - - /* break right, also [p, newblock, p->next] */ - if (size < p->size) { - newblock = (struct mem_block*) calloc(1, sizeof(struct mem_block)); - if (!newblock) - return NULL; - newblock->ofs = startofs + size; - newblock->size = p->size - size; - newblock->free = 1; - newblock->heap = p->heap; - - newblock->next = p->next; - newblock->prev = p; - p->next->prev = newblock; - p->next = newblock; - - newblock->next_free = p->next_free; - newblock->prev_free = p; - p->next_free->prev_free = newblock; - p->next_free = newblock; - - p->size = size; - } - - /* p = middle block */ - p->free = 0; - - /* Remove p from the free list: - */ - p->next_free->prev_free = p->prev_free; - p->prev_free->next_free = p->next_free; - - p->next_free = 0; - p->prev_free = 0; - - p->reserved = reserved; - return p; -} - - -struct mem_block * -mmAllocMem(struct mem_block *heap, unsigned size, unsigned align2, unsigned startSearch) -{ - struct mem_block *p; - const unsigned mask = (1 << align2)-1; - unsigned startofs = 0; - unsigned endofs; - - if (!heap || !size) - return NULL; - - for (p = heap->next_free; p != heap; p = p->next_free) { - assert(p->free); - - startofs = (p->ofs + mask) & ~mask; - if ( startofs < startSearch ) { - startofs = startSearch; - } - endofs = startofs+size; - if (endofs <= (p->ofs+p->size)) - break; - } - - if (p == heap) - return NULL; - - assert(p->free); - p = SliceBlock(p,startofs,size,0,mask+1); - - return p; -} - - -struct mem_block * -mmFindBlock(struct mem_block *heap, unsigned start) -{ - struct mem_block *p; - - for (p = heap->next; p != heap; p = p->next) { - if (p->ofs == start) - return p; - } - - return NULL; -} - - -static inline int -Join2Blocks(struct mem_block *p) -{ - /* XXX there should be some assertions here */ - - /* NOTE: heap->free == 0 */ - - if (p->free && p->next->free) { - struct mem_block *q = p->next; - - assert(p->ofs + p->size == q->ofs); - p->size += q->size; - - p->next = q->next; - q->next->prev = p; - - q->next_free->prev_free = q->prev_free; - q->prev_free->next_free = q->next_free; - - free(q); - return 1; - } - return 0; -} - -int -mmFreeMem(struct mem_block *b) -{ - if (!b) - return 0; - - if (b->free) { - fprintf(stderr, "block already free\n"); - return -1; - } - if (b->reserved) { - fprintf(stderr, "block is reserved\n"); - return -1; - } - - b->free = 1; - b->next_free = b->heap->next_free; - b->prev_free = b->heap; - b->next_free->prev_free = b; - b->prev_free->next_free = b; - - Join2Blocks(b); - if (b->prev != b->heap) - Join2Blocks(b->prev); - - return 0; -} - - -void -mmDestroy(struct mem_block *heap) -{ - struct mem_block *p; - - if (!heap) - return; - - for (p = heap->next; p != heap; ) { - struct mem_block *next = p->next; - free(p); - p = next; - } - - free(heap); -} diff --git a/dll/opengl/mesa/main/mm.h b/dll/opengl/mesa/main/mm.h deleted file mode 100644 index 228721ca2a5..00000000000 --- a/dll/opengl/mesa/main/mm.h +++ /dev/null @@ -1,90 +0,0 @@ -/* - * GLX Hardware Device Driver common code - * Copyright (C) 1999 Wittawat Yamwong - * - * Permission is hereby granted, free of charge, to any person obtaining a - * copy of this software and associated documentation files (the "Software"), - * to deal in the Software without restriction, including without limitation - * the rights to use, copy, modify, merge, publish, distribute, sublicense, - * and/or sell copies of the Software, and to permit persons to whom the - * Software is furnished to do so, subject to the following conditions: - * - * The above copyright notice and this permission notice shall be included - * in all copies or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS - * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL - * KEITH WHITWELL, OR ANY OTHER CONTRIBUTORS BE LIABLE FOR ANY CLAIM, - * DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR - * OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE - * OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. - */ - - -/** - * Memory manager code. Primarily used by device drivers to manage texture - * heaps, etc. - */ - - -#ifndef MM_H -#define MM_H - - -struct mem_block { - struct mem_block *next, *prev; - struct mem_block *next_free, *prev_free; - struct mem_block *heap; - unsigned ofs; - unsigned size; - unsigned free:1; - unsigned reserved:1; -}; - - - -/** - * input: total size in bytes - * return: a heap pointer if OK, NULL if error - */ -extern struct mem_block *mmInit(unsigned ofs, unsigned size); - -/** - * Allocate 'size' bytes with 2^align2 bytes alignment, - * restrict the search to free memory after 'startSearch' - * depth and back buffers should be in different 4mb banks - * to get better page hits if possible - * input: size = size of block - * align2 = 2^align2 bytes alignment - * startSearch = linear offset from start of heap to begin search - * return: pointer to the allocated block, 0 if error - */ -extern struct mem_block *mmAllocMem(struct mem_block *heap, unsigned size, - unsigned align2, unsigned startSearch); - -/** - * Free block starts at offset - * input: pointer to a block - * return: 0 if OK, -1 if error - */ -extern int mmFreeMem(struct mem_block *b); - -/** - * Free block starts at offset - * input: pointer to a heap, start offset - * return: pointer to a block - */ -extern struct mem_block *mmFindBlock(struct mem_block *heap, unsigned start); - -/** - * destroy MM - */ -extern void mmDestroy(struct mem_block *mmInit); - -/** - * For debuging purpose. - */ -extern void mmDumpMemInfo(const struct mem_block *mmInit); - -#endif diff --git a/dll/opengl/mesa/main/mtypes.h b/dll/opengl/mesa/main/mtypes.h deleted file mode 100644 index c306a0cddd7..00000000000 --- a/dll/opengl/mesa/main/mtypes.h +++ /dev/null @@ -1,1976 +0,0 @@ -/* - * Mesa 3-D graphics library - * Version: 7.7 - * - * Copyright (C) 1999-2008 Brian Paul All Rights Reserved. - * Copyright (C) 2009 VMware, Inc. All Rights Reserved. - * - * Permission is hereby granted, free of charge, to any person obtaining a - * copy of this software and associated documentation files (the "Software"), - * to deal in the Software without restriction, including without limitation - * the rights to use, copy, modify, merge, publish, distribute, sublicense, - * and/or sell copies of the Software, and to permit persons to whom the - * Software is furnished to do so, subject to the following conditions: - * - * The above copyright notice and this permission notice shall be included - * in all copies or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS - * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL - * BRIAN PAUL BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN - * AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN - * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. - */ - -/** - * \file mtypes.h - * Main Mesa data structures. - * - * Please try to mark derived values with a leading underscore ('_'). - */ - -#ifndef MTYPES_H -#define MTYPES_H - - -#include "main/glheader.h" -#include "main/config.h" -#include "main/mfeatures.h" -#include "math/m_matrix.h" /* GLmatrix */ -#include "main/simple_list.h" /* struct simple_node */ -#include "main/formats.h" /* MESA_FORMAT_COUNT */ - - -#ifdef __cplusplus -extern "C" { -#endif - - -/** - * \name 64-bit extension of GLbitfield. - */ -/*@{*/ -typedef GLuint64 GLbitfield64; - -/** Set a single bit */ -#define BITFIELD64_BIT(b) ((GLbitfield64)1 << (b)) -/** Set all bits up to excluding bit b */ -#define BITFIELD64_MASK(b) \ - ((b) == 64 ? (~(GLbitfield64)0) : BITFIELD64_BIT(b) - 1) -/** Set count bits starting from bit b */ -#define BITFIELD64_RANGE(b, count) \ - (BITFIELD64_MASK((b) + (count)) & ~BITFIELD64_MASK(b)) - - -/** - * \name Some forward type declarations - */ -/*@{*/ -struct _mesa_HashTable; -struct gl_attrib_node; -struct gl_list_extensions; -struct gl_meta_state; -struct gl_texture_object; -struct gl_context; -struct st_context; -/*@}*/ - - -/** Extra draw modes beyond GL_POINTS, GL_TRIANGLE_FAN, etc */ -#define PRIM_OUTSIDE_BEGIN_END (GL_POLYGON+1) -#define PRIM_INSIDE_UNKNOWN_PRIM (GL_POLYGON+2) -#define PRIM_UNKNOWN (GL_POLYGON+3) - - - -/** - * Indexes for vertex program attributes. - * GL_NV_vertex_program aliases generic attributes over the conventional - * attributes. In GL_ARB_vertex_program shader the aliasing is optional. - * In GL_ARB_vertex_shader / OpenGL 2.0 the aliasing is disallowed (the - * generic attributes are distinct/separate). - */ -typedef enum -{ - VERT_ATTRIB_POS = 0, - VERT_ATTRIB_WEIGHT = 1, - VERT_ATTRIB_NORMAL = 2, - VERT_ATTRIB_COLOR = 3, - VERT_ATTRIB_FOG = 4, - VERT_ATTRIB_COLOR_INDEX = 5, - VERT_ATTRIB_EDGEFLAG = 6, - VERT_ATTRIB_TEX = 7, - VERT_ATTRIB_POINT_SIZE = 8, - VERT_ATTRIB_MAX = 9 -} gl_vert_attrib; - -/** - * Symbolic constats to help iterating over - * specific blocks of vertex attributes. - * - */ -#define VERT_ATTRIB(i) (VERT_ATTRIB_POS + (i)) - -/** - * Bitflags for vertex attributes. - * These are used in bitfields in many places. - */ -/*@{*/ -#define VERT_BIT_POS BITFIELD64_BIT(VERT_ATTRIB_POS) -#define VERT_BIT_WEIGHT BITFIELD64_BIT(VERT_ATTRIB_WEIGHT) -#define VERT_BIT_NORMAL BITFIELD64_BIT(VERT_ATTRIB_NORMAL) -#define VERT_BIT_COLOR BITFIELD64_BIT(VERT_ATTRIB_COLOR) -#define VERT_BIT_FOG BITFIELD64_BIT(VERT_ATTRIB_FOG) -#define VERT_BIT_COLOR_INDEX BITFIELD64_BIT(VERT_ATTRIB_COLOR_INDEX) -#define VERT_BIT_EDGEFLAG BITFIELD64_BIT(VERT_ATTRIB_EDGEFLAG) -#define VERT_BIT_TEX BITFIELD64_BIT(VERT_ATTRIB_TEX) -#define VERT_BIT_POINT_SIZE BITFIELD64_BIT(VERT_ATTRIB_POINT_SIZE) - -#define VERT_BIT(i) BITFIELD64_BIT(i) -#define VERT_BIT_ALL (BITFIELD64_BIT(VERT_ATTRIB_MAX) - 1) - -/*@}*/ - - -/** - * Indexes for fragment program input attributes. Note that - * _mesa_vert_result_to_frag_attrib() and frag_attrib_to_vert_result() make - * assumptions about the layout of this enum. - */ -typedef enum -{ - FRAG_ATTRIB_WPOS = 0, - FRAG_ATTRIB_COL = 1, - FRAG_ATTRIB_FOGC = 2, - FRAG_ATTRIB_TEX = 3, - FRAG_ATTRIB_FACE = 4, /**< front/back face */ - FRAG_ATTRIB_PNTC = 5, /**< sprite/point coord */ - FRAG_ATTRIB_CLIP_DIST0 = 6, - FRAG_ATTRIB_CLIP_DIST1 = 7, - FRAG_ATTRIB_MAX = 8 -} gl_frag_attrib; - - -#define FRAG_BIT_COL (1 << FRAG_ATTRIB_COL) -#define FRAG_BIT_FOGC (1 << FRAG_ATTRIB_FOGC) -#define FRAG_BIT_TEX (1 << FRAG_ATTRIB_TEX) - -/** - * Indexes for all renderbuffers - */ -typedef enum -{ - /* the four standard color buffers */ - BUFFER_FRONT_LEFT, - BUFFER_BACK_LEFT, - BUFFER_FRONT_RIGHT, - BUFFER_BACK_RIGHT, - BUFFER_DEPTH, - BUFFER_STENCIL, - BUFFER_ACCUM, - /* optional aux buffer */ - BUFFER_AUX0, - BUFFER_COUNT -} gl_buffer_index; - -/** - * Bit flags for all renderbuffers - */ -#define BUFFER_BIT_FRONT_LEFT (1 << BUFFER_FRONT_LEFT) -#define BUFFER_BIT_BACK_LEFT (1 << BUFFER_BACK_LEFT) -#define BUFFER_BIT_FRONT_RIGHT (1 << BUFFER_FRONT_RIGHT) -#define BUFFER_BIT_BACK_RIGHT (1 << BUFFER_BACK_RIGHT) -#define BUFFER_BIT_AUX0 (1 << BUFFER_AUX0) -#define BUFFER_BIT_AUX1 (1 << BUFFER_AUX1) -#define BUFFER_BIT_AUX2 (1 << BUFFER_AUX2) -#define BUFFER_BIT_AUX3 (1 << BUFFER_AUX3) -#define BUFFER_BIT_DEPTH (1 << BUFFER_DEPTH) -#define BUFFER_BIT_STENCIL (1 << BUFFER_STENCIL) -#define BUFFER_BIT_ACCUM (1 << BUFFER_ACCUM) - -/** - * Mask of all the color buffer bits (but not accum). - */ -#define BUFFER_BITS_COLOR (BUFFER_BIT_FRONT_LEFT | \ - BUFFER_BIT_BACK_LEFT | \ - BUFFER_BIT_FRONT_RIGHT | \ - BUFFER_BIT_BACK_RIGHT | \ - BUFFER_BIT_AUX0) - - -/** - * Framebuffer configuration (aka visual / pixelformat) - * Note: some of these fields should be boolean, but it appears that - * code in drivers/dri/common/util.c requires int-sized fields. - */ -struct gl_config -{ - GLboolean rgbMode; - GLboolean colorIndexMode; /* XXX is this used anywhere? */ - GLuint doubleBufferMode; - GLuint stereoMode; - - GLboolean haveAccumBuffer; - GLboolean haveDepthBuffer; - GLboolean haveStencilBuffer; - - GLint redBits, greenBits, blueBits, alphaBits; /* bits per comp */ - GLuint redMask, greenMask, blueMask, alphaMask; - GLint rgbBits; /* total bits for rgb */ - GLint indexBits; /* total bits for colorindex */ - - GLint accumRedBits, accumGreenBits, accumBlueBits, accumAlphaBits; - GLint depthBits; - GLint stencilBits; - - GLint numAuxBuffers; - - GLint level; - - /* EXT_visual_rating / GLX 1.2 */ - GLint visualRating; - - /* EXT_visual_info / GLX 1.2 */ - GLint transparentPixel; - /* colors are floats scaled to ints */ - GLint transparentRed, transparentGreen, transparentBlue, transparentAlpha; - GLint transparentIndex; - - /* SGIX_pbuffer / GLX 1.3 */ - GLint maxPbufferWidth; - GLint maxPbufferHeight; - GLint maxPbufferPixels; - GLint optimalPbufferWidth; /* Only for SGIX_pbuffer. */ - GLint optimalPbufferHeight; /* Only for SGIX_pbuffer. */ - - /* OML_swap_method */ - GLint swapMethod; - - /* EXT_texture_from_pixmap */ - GLint bindToTextureRgb; - GLint bindToTextureRgba; - GLint bindToMipmapTexture; - GLint bindToTextureTargets; - GLint yInverted; -}; - - -/** - * \name Bit flags used for updating material values. - */ -/*@{*/ -#define MAT_ATTRIB_FRONT_AMBIENT 0 -#define MAT_ATTRIB_BACK_AMBIENT 1 -#define MAT_ATTRIB_FRONT_DIFFUSE 2 -#define MAT_ATTRIB_BACK_DIFFUSE 3 -#define MAT_ATTRIB_FRONT_SPECULAR 4 -#define MAT_ATTRIB_BACK_SPECULAR 5 -#define MAT_ATTRIB_FRONT_EMISSION 6 -#define MAT_ATTRIB_BACK_EMISSION 7 -#define MAT_ATTRIB_FRONT_SHININESS 8 -#define MAT_ATTRIB_BACK_SHININESS 9 -#define MAT_ATTRIB_FRONT_INDEXES 10 -#define MAT_ATTRIB_BACK_INDEXES 11 -#define MAT_ATTRIB_MAX 12 - -#define MAT_ATTRIB_AMBIENT(f) (MAT_ATTRIB_FRONT_AMBIENT+(f)) -#define MAT_ATTRIB_DIFFUSE(f) (MAT_ATTRIB_FRONT_DIFFUSE+(f)) -#define MAT_ATTRIB_SPECULAR(f) (MAT_ATTRIB_FRONT_SPECULAR+(f)) -#define MAT_ATTRIB_EMISSION(f) (MAT_ATTRIB_FRONT_EMISSION+(f)) -#define MAT_ATTRIB_SHININESS(f)(MAT_ATTRIB_FRONT_SHININESS+(f)) -#define MAT_ATTRIB_INDEXES(f) (MAT_ATTRIB_FRONT_INDEXES+(f)) - -#define MAT_INDEX_AMBIENT 0 -#define MAT_INDEX_DIFFUSE 1 -#define MAT_INDEX_SPECULAR 2 - -#define MAT_BIT_FRONT_AMBIENT (1< ) */ - GLfloat _NormSpotDirection[4]; /**< normalized spotlight direction */ - GLfloat _VP_inf_spot_attenuation; - - GLfloat _SpotExpTable[EXP_TABLE_SIZE][2]; /**< to replace a pow() call */ - GLfloat _MatAmbient[2][3]; /**< material ambient * light ambient */ - GLfloat _MatDiffuse[2][3]; /**< material diffuse * light diffuse */ - GLfloat _MatSpecular[2][3]; /**< material spec * light specular */ - /*@}*/ -}; - - -/** - * Light model state. - */ -struct gl_lightmodel -{ - GLfloat Ambient[4]; /**< ambient color */ - GLboolean LocalViewer; /**< Local (or infinite) view point? */ - GLboolean TwoSide; /**< Two (or one) sided lighting? */ -}; - - -/** - * Material state. - */ -struct gl_material -{ - GLfloat Attrib[MAT_ATTRIB_MAX][4]; -}; - - -/** - * Accumulation buffer attribute group (GL_ACCUM_BUFFER_BIT) - */ -struct gl_accum_attrib -{ - GLfloat ClearColor[4]; /**< Accumulation buffer clear color */ -}; - - -/** - * Used for storing clear color, texture border color, etc. - * The float values are typically unclamped. - */ -union gl_color_union -{ - GLfloat f[4]; - GLint i[4]; - GLuint ui[4]; -}; - - -/** - * Color buffer attribute group (GL_COLOR_BUFFER_BIT). - */ -struct gl_colorbuffer_attrib -{ - GLuint ClearIndex; /**< Index for glClear */ - union gl_color_union ClearColor; /**< Color for glClear, unclamped */ - GLuint IndexMask; /**< Color index write mask */ - GLubyte ColorMask[4]; /**< Each flag is 0xff or 0x0 */ - - GLenum DrawBuffer; /**< Which buffer to draw into */ - - /** - * \name alpha testing - */ - /*@{*/ - GLboolean AlphaEnabled; /**< Alpha test enabled flag */ - GLenum AlphaFunc; /**< Alpha test function */ - GLclampf AlphaRef; /**< Alpha reference value */ - /*@}*/ - - /** - * \name Blending - */ - /*@{*/ - GLbitfield BlendEnabled; /**< Per-buffer blend enable flags */ - - /* NOTE: this does _not_ depend on fragment clamping or any other clamping - * control, only on the fixed-pointness of the render target. - * The query does however depend on fragment color clamping. - */ - - GLenum SrcFactor; /**< RGB blend source term */ - GLenum DstFactor; /**< RGB blend dest term */ - /*@}*/ - - /** - * \name Logic op - */ - /*@{*/ - GLenum LogicOp; /**< Logic operator */ - GLboolean IndexLogicOpEnabled; /**< Color index logic op enabled flag */ - GLboolean ColorLogicOpEnabled; /**< RGBA logic op enabled flag */ - /*@}*/ - - GLboolean DitherFlag; /**< Dither enable flag */ -}; - - -/** - * Current attribute group (GL_CURRENT_BIT). - */ -struct gl_current_attrib -{ - /** - * \name Current vertex attributes. - * \note Values are valid only after FLUSH_VERTICES has been called. - * \note Index and Edgeflag current values are stored as floats in the - * SIX and SEVEN attribute slots. - */ - GLfloat Attrib[VERT_ATTRIB_MAX][4]; /**< Position, color, texcoords, etc */ - - /** - * \name Current raster position attributes (always valid). - * \note This set of attributes is very similar to the SWvertex struct. - */ - /*@{*/ - GLfloat RasterPos[4]; - GLfloat RasterDistance; - GLfloat RasterColor[4]; - GLfloat RasterTexCoords[4]; - GLboolean RasterPosValid; - /*@}*/ -}; - - -/** - * Depth buffer attribute group (GL_DEPTH_BUFFER_BIT). - */ -struct gl_depthbuffer_attrib -{ - GLenum Func; /**< Function for depth buffer compare */ - GLclampd Clear; /**< Value to clear depth buffer to */ - GLboolean Test; /**< Depth buffering enabled flag */ - GLboolean Mask; /**< Depth buffer writable? */ - GLboolean BoundsTest; /**< GL_EXT_depth_bounds_test */ - GLfloat BoundsMin, BoundsMax;/**< GL_EXT_depth_bounds_test */ -}; - - -/** - * Evaluator attribute group (GL_EVAL_BIT). - */ -struct gl_eval_attrib -{ - /** - * \name Enable bits - */ - /*@{*/ - GLboolean Map1Color4; - GLboolean Map1Index; - GLboolean Map1Normal; - GLboolean Map1TextureCoord1; - GLboolean Map1TextureCoord2; - GLboolean Map1TextureCoord3; - GLboolean Map1TextureCoord4; - GLboolean Map1Vertex3; - GLboolean Map1Vertex4; - GLboolean Map2Color4; - GLboolean Map2Index; - GLboolean Map2Normal; - GLboolean Map2TextureCoord1; - GLboolean Map2TextureCoord2; - GLboolean Map2TextureCoord3; - GLboolean Map2TextureCoord4; - GLboolean Map2Vertex3; - GLboolean Map2Vertex4; - GLboolean AutoNormal; - /*@}*/ - - /** - * \name Map Grid endpoints and divisions and calculated du values - */ - /*@{*/ - GLint MapGrid1un; - GLfloat MapGrid1u1, MapGrid1u2, MapGrid1du; - GLint MapGrid2un, MapGrid2vn; - GLfloat MapGrid2u1, MapGrid2u2, MapGrid2du; - GLfloat MapGrid2v1, MapGrid2v2, MapGrid2dv; - /*@}*/ -}; - - -/** - * Fog attribute group (GL_FOG_BIT). - */ -struct gl_fog_attrib -{ - GLboolean Enabled; /**< Fog enabled flag */ - GLfloat Color[4]; /**< Fog color */ - GLfloat Density; /**< Density >= 0.0 */ - GLfloat Start; /**< Start distance in eye coords */ - GLfloat End; /**< End distance in eye coords */ - GLfloat Index; /**< Fog index */ - GLenum Mode; /**< Fog mode */ - GLenum FogCoordinateSource; /**< GL_EXT_fog_coord */ - GLfloat _Scale; /**< (End == Start) ? 1.0 : 1.0 / (End - Start) */ - GLenum FogDistanceMode; /**< GL_NV_fog_distance */ -}; - - -/** - * \brief Layout qualifiers for gl_FragDepth. - * - * Extension AMD_conservative_depth allows gl_FragDepth to be redeclared with - * a layout qualifier. - * - * \see enum ir_depth_layout - */ -enum gl_frag_depth_layout { - FRAG_DEPTH_LAYOUT_NONE, /**< No layout is specified. */ - FRAG_DEPTH_LAYOUT_ANY, - FRAG_DEPTH_LAYOUT_GREATER, - FRAG_DEPTH_LAYOUT_LESS, - FRAG_DEPTH_LAYOUT_UNCHANGED -}; - - -/** - * Hint attribute group (GL_HINT_BIT). - * - * Values are always one of GL_FASTEST, GL_NICEST, or GL_DONT_CARE. - */ -struct gl_hint_attrib -{ - GLenum PerspectiveCorrection; - GLenum PointSmooth; - GLenum LineSmooth; - GLenum PolygonSmooth; - GLenum Fog; - GLenum ClipVolumeClipping; /**< GL_EXT_clip_volume_hint */ -}; - -/** - * Light state flags. - */ -/*@{*/ -#define LIGHT_SPOT 0x1 -#define LIGHT_LOCAL_VIEWER 0x2 -#define LIGHT_POSITIONAL 0x4 -#define LIGHT_NEED_VERTICES (LIGHT_POSITIONAL|LIGHT_LOCAL_VIEWER) -/*@}*/ - - -/** - * Lighting attribute group (GL_LIGHT_BIT). - */ -struct gl_light_attrib -{ - struct gl_light Light[MAX_LIGHTS]; /**< Array of light sources */ - struct gl_lightmodel Model; /**< Lighting model */ - - /** - * Must flush FLUSH_VERTICES before referencing: - */ - /*@{*/ - struct gl_material Material; /**< Includes front & back values */ - /*@}*/ - - GLboolean Enabled; /**< Lighting enabled flag */ - GLenum ShadeModel; /**< GL_FLAT or GL_SMOOTH */ - GLenum ColorMaterialFace; /**< GL_FRONT, BACK or FRONT_AND_BACK */ - GLenum ColorMaterialMode; /**< GL_AMBIENT, GL_DIFFUSE, etc */ - GLbitfield ColorMaterialBitmask; /**< bitmask formed from Face and Mode */ - GLboolean ColorMaterialEnabled; - - struct gl_light EnabledList; /**< List sentinel */ - - /** - * Derived state for optimizations: - */ - /*@{*/ - GLboolean _NeedEyeCoords; - GLboolean _NeedVertices; /**< Use fast shader? */ - GLbitfield _Flags; /**< LIGHT_* flags, see above */ - GLfloat _BaseColor[2][3]; - /*@}*/ -}; - - -/** - * Line attribute group (GL_LINE_BIT). - */ -struct gl_line_attrib -{ - GLboolean SmoothFlag; /**< GL_LINE_SMOOTH enabled? */ - GLboolean StippleFlag; /**< GL_LINE_STIPPLE enabled? */ - GLushort StipplePattern; /**< Stipple pattern */ - GLint StippleFactor; /**< Stipple repeat factor */ - GLfloat Width; /**< Line width */ -}; - - -/** - * Display list attribute group (GL_LIST_BIT). - */ -struct gl_list_attrib -{ - GLuint ListBase; -}; - - -/** - * Multisample attribute group (GL_MULTISAMPLE_BIT). - */ -struct gl_multisample_attrib -{ - GLboolean Enabled; - GLboolean _Enabled; /**< true if Enabled and multisample buffer */ - GLboolean SampleAlphaToCoverage; - GLboolean SampleAlphaToOne; - GLboolean SampleCoverage; - GLfloat SampleCoverageValue; - GLboolean SampleCoverageInvert; -}; - - -/** - * A pixelmap (see glPixelMap) - */ -struct gl_pixelmap -{ - GLint Size; - GLfloat Map[MAX_PIXEL_MAP_TABLE]; - GLubyte Map8[MAX_PIXEL_MAP_TABLE]; /**< converted to 8-bit color */ -}; - - -/** - * Collection of all pixelmaps - */ -struct gl_pixelmaps -{ - struct gl_pixelmap RtoR; /**< i.e. GL_PIXEL_MAP_R_TO_R */ - struct gl_pixelmap GtoG; - struct gl_pixelmap BtoB; - struct gl_pixelmap AtoA; - struct gl_pixelmap ItoR; - struct gl_pixelmap ItoG; - struct gl_pixelmap ItoB; - struct gl_pixelmap ItoA; - struct gl_pixelmap ItoI; - struct gl_pixelmap StoS; -}; - - -/** - * Pixel attribute group (GL_PIXEL_MODE_BIT). - */ -struct gl_pixel_attrib -{ - GLenum ReadBuffer; /**< source buffer for glRead/CopyPixels() */ - - /*--- Begin Pixel Transfer State ---*/ - /* Fields are in the order in which they're applied... */ - - /** Scale & Bias (index shift, offset) */ - /*@{*/ - GLfloat RedBias, RedScale; - GLfloat GreenBias, GreenScale; - GLfloat BlueBias, BlueScale; - GLfloat AlphaBias, AlphaScale; - GLfloat DepthBias, DepthScale; - GLint IndexShift, IndexOffset; - /*@}*/ - - /* Pixel Maps */ - /* Note: actual pixel maps are not part of this attrib group */ - GLboolean MapColorFlag; - GLboolean MapStencilFlag; - - /*--- End Pixel Transfer State ---*/ - - /** glPixelZoom */ - GLfloat ZoomX, ZoomY; -}; - - -/** - * Point attribute group (GL_POINT_BIT). - */ -struct gl_point_attrib -{ - GLboolean SmoothFlag; /**< True if GL_POINT_SMOOTH is enabled */ - GLfloat Size; /**< User-specified point size */ - GLfloat Params[3]; /**< GL_EXT_point_parameters */ - GLfloat MinSize, MaxSize; /**< GL_EXT_point_parameters */ - GLfloat Threshold; /**< GL_EXT_point_parameters */ - GLboolean _Attenuated; /**< True if Params != [1, 0, 0] */ - GLboolean PointSprite; /**< GL_NV/ARB_point_sprite */ - GLboolean CoordReplace; /**< GL_ARB_point_sprite*/ - GLenum SpriteRMode; /**< GL_NV_point_sprite (only!) */ - GLenum SpriteOrigin; /**< GL_ARB_point_sprite */ -}; - - -/** - * Polygon attribute group (GL_POLYGON_BIT). - */ -struct gl_polygon_attrib -{ - GLenum FrontFace; /**< Either GL_CW or GL_CCW */ - GLenum FrontMode; /**< Either GL_POINT, GL_LINE or GL_FILL */ - GLenum BackMode; /**< Either GL_POINT, GL_LINE or GL_FILL */ - GLboolean _FrontBit; /**< 0=GL_CCW, 1=GL_CW */ - GLboolean CullFlag; /**< Culling on/off flag */ - GLboolean SmoothFlag; /**< True if GL_POLYGON_SMOOTH is enabled */ - GLboolean StippleFlag; /**< True if GL_POLYGON_STIPPLE is enabled */ - GLenum CullFaceMode; /**< Culling mode GL_FRONT or GL_BACK */ - GLfloat OffsetFactor; /**< Polygon offset factor, from user */ - GLfloat OffsetUnits; /**< Polygon offset units, from user */ - GLboolean OffsetPoint; /**< Offset in GL_POINT mode */ - GLboolean OffsetLine; /**< Offset in GL_LINE mode */ - GLboolean OffsetFill; /**< Offset in GL_FILL mode */ -}; - - -/** - * Scissor attributes (GL_SCISSOR_BIT). - */ -struct gl_scissor_attrib -{ - GLboolean Enabled; /**< Scissor test enabled? */ - GLint X, Y; /**< Lower left corner of box */ - GLsizei Width, Height; /**< Size of box */ -}; - - -/** - * Stencil attribute group (GL_STENCIL_BUFFER_BIT). - * - */ -struct gl_stencil_attrib -{ - GLboolean Enabled; /**< Enabled flag */ - GLboolean _Enabled; /**< Enabled and stencil buffer present */ - GLenum Function; /**< Stencil function */ - GLenum FailFunc; /**< Fail function */ - GLenum ZPassFunc; /**< Depth buffer pass function */ - GLenum ZFailFunc; /**< Depth buffer fail function */ - GLint Ref; /**< Reference value */ - GLuint ValueMask; /**< Value mask */ - GLuint WriteMask; /**< Write mask */ - GLuint Clear; /**< Clear value */ -}; - - -/** - * An index for each type of texture object. These correspond to the GL - * texture target enums, such as GL_TEXTURE_2D, GL_TEXTURE_CUBE_MAP, etc. - * Note: the order is from highest priority to lowest priority. - */ -typedef enum -{ - TEXTURE_CUBE_INDEX, - TEXTURE_2D_INDEX, - TEXTURE_1D_INDEX, - NUM_TEXTURE_TARGETS -} gl_texture_index; - - -/** - * Bit flags for each type of texture object - * Used for Texture.Unit[]._ReallyEnabled flags. - */ -/*@{*/ -#define TEXTURE_CUBE_BIT (1 << TEXTURE_CUBE_INDEX) -#define TEXTURE_2D_BIT (1 << TEXTURE_2D_INDEX) -#define TEXTURE_1D_BIT (1 << TEXTURE_1D_INDEX) -/*@}*/ - - -/** - * TexGenEnabled flags. - */ -/*@{*/ -#define S_BIT 1 -#define T_BIT 2 -#define R_BIT 4 -#define Q_BIT 8 -#define STR_BITS (S_BIT | T_BIT | R_BIT) -/*@}*/ - - -/** - * Bit flag versions of the corresponding GL_ constants. - */ -/*@{*/ -#define TEXGEN_SPHERE_MAP 0x1 -#define TEXGEN_OBJ_LINEAR 0x2 -#define TEXGEN_EYE_LINEAR 0x4 -#define TEXGEN_REFLECTION_MAP_NV 0x8 -#define TEXGEN_NORMAL_MAP_NV 0x10 - -#define TEXGEN_NEED_NORMALS (TEXGEN_SPHERE_MAP | \ - TEXGEN_REFLECTION_MAP_NV | \ - TEXGEN_NORMAL_MAP_NV) -#define TEXGEN_NEED_EYE_COORD (TEXGEN_SPHERE_MAP | \ - TEXGEN_REFLECTION_MAP_NV | \ - TEXGEN_NORMAL_MAP_NV | \ - TEXGEN_EYE_LINEAR) -/*@}*/ - - - -/** Tex-gen enabled for texture unit? */ -#define ENABLE_TEXGEN(unit) (1 << (unit)) - -/** Non-identity texture matrix for texture unit? */ -#define ENABLE_TEXMAT(unit) (1 << (unit)) - - -/** - * Texture image state. Drivers will typically create a subclass of this - * with extra fields for memory buffers, etc. - */ -struct gl_texture_image -{ - GLint InternalFormat; /**< Internal format as given by the user */ - GLenum _BaseFormat; /**< Either GL_RGB, GL_RGBA, GL_ALPHA, - * GL_LUMINANCE, GL_LUMINANCE_ALPHA, - * GL_INTENSITY, GL_DEPTH_COMPONENT or - * GL_DEPTH_STENCIL_EXT only. Used for - * choosing TexEnv arithmetic. - */ - gl_format TexFormat; /**< The actual texture memory format */ - - GLuint Border; /**< 0 or 1 */ - GLuint Width; /**< = 2^WidthLog2 + 2*Border */ - GLuint Height; /**< = 2^HeightLog2 + 2*Border */ - GLuint Depth; /**< = 2^DepthLog2 + 2*Border */ - GLuint Width2; /**< = Width - 2*Border */ - GLuint Height2; /**< = Height - 2*Border */ - GLuint Depth2; /**< = Depth - 2*Border */ - GLuint WidthLog2; /**< = log2(Width2) */ - GLuint HeightLog2; /**< = log2(Height2) */ - GLuint DepthLog2; /**< = log2(Depth2) */ - GLuint MaxLog2; /**< = MAX(WidthLog2, HeightLog2) */ - - struct gl_texture_object *TexObject; /**< Pointer back to parent object */ - GLuint Level; /**< Which mipmap level am I? */ - /** Cube map face: index into gl_texture_object::Image[] array */ - GLuint Face; -}; - - -/** - * Indexes for cube map faces. - */ -typedef enum -{ - FACE_POS_X = 0, - FACE_NEG_X = 1, - FACE_POS_Y = 2, - FACE_NEG_Y = 3, - FACE_POS_Z = 4, - FACE_NEG_Z = 5, - MAX_FACES = 6 -} gl_face_index; - -/** - * Sampler object state. These objects are new with GL_ARB_sampler_objects - * and OpenGL 3.3. Legacy texture objects also contain a sampler object. - */ -struct gl_sampler_object -{ - GLuint Name; - GLint RefCount; - - GLenum WrapS; /**< S-axis texture image wrap mode */ - GLenum WrapT; /**< T-axis texture image wrap mode */ - GLenum WrapR; /**< R-axis texture image wrap mode */ - GLenum MinFilter; /**< minification filter */ - GLenum MagFilter; /**< magnification filter */ - union gl_color_union BorderColor; /**< Interpreted according to texture format */ - GLfloat MaxAnisotropy; /**< GL_EXT_texture_filter_anisotropic */ - -}; - - -/** - * Texture object state. Contains the array of mipmap images, border color, - * wrap modes, filter modes, and shadow/texcompare state. - */ -struct gl_texture_object -{ - _glthread_Mutex Mutex; /**< for thread safety */ - GLint RefCount; /**< reference count */ - GLuint Name; /**< the user-visible texture object ID */ - GLenum Target; /**< GL_TEXTURE_1D, GL_TEXTURE_2D, etc. */ - - struct gl_sampler_object Sampler; - - GLfloat Priority; /**< in [0,1] */ - GLint BaseLevel; /**< min mipmap level, OpenGL 1.2 */ - GLint MaxLevel; /**< max mipmap level, OpenGL 1.2 */ - GLint _MaxLevel; /**< actual max mipmap level (q in the spec) */ - GLfloat _MaxLambda; /**< = _MaxLevel - BaseLevel (q - b in spec) */ - GLboolean _Complete; /**< Is texture object complete? */ - GLboolean Purgeable; /**< Is the buffer purgeable under memory pressure? */ - GLboolean Immutable; /**< GL_ARB_texture_storage */ - - /** Actual texture images, indexed by [cube face] and [mipmap level] */ - struct gl_texture_image *Image[MAX_FACES][MAX_TEXTURE_LEVELS]; -}; - - -/** Up to four combiner sources are possible with GL_NV_texture_env_combine4 */ -#define MAX_COMBINER_TERMS 4 - - -/** - * Texture combine environment state. - */ -struct gl_tex_env_combine_state -{ - GLenum ModeRGB; /**< GL_REPLACE, GL_DECAL, GL_ADD, etc. */ - GLenum ModeA; /**< GL_REPLACE, GL_DECAL, GL_ADD, etc. */ - /** Source terms: GL_PRIMARY_COLOR, GL_TEXTURE, etc */ - GLenum SourceRGB[MAX_COMBINER_TERMS]; - GLenum SourceA[MAX_COMBINER_TERMS]; - /** Source operands: GL_SRC_COLOR, GL_ONE_MINUS_SRC_COLOR, etc */ - GLenum OperandRGB[MAX_COMBINER_TERMS]; - GLenum OperandA[MAX_COMBINER_TERMS]; - GLuint ScaleShiftRGB; /**< 0, 1 or 2 */ - GLuint ScaleShiftA; /**< 0, 1 or 2 */ - GLuint _NumArgsRGB; /**< Number of inputs used for the RGB combiner */ - GLuint _NumArgsA; /**< Number of inputs used for the A combiner */ -}; - - -/** - * Texture coord generation state. - */ -struct gl_texgen -{ - GLenum Mode; /**< GL_EYE_LINEAR, GL_SPHERE_MAP, etc */ - GLbitfield _ModeBit; /**< TEXGEN_x bit corresponding to Mode */ - GLfloat ObjectPlane[4]; - GLfloat EyePlane[4]; -}; - - -/** - * Texture unit state. Contains enable flags, texture environment/function/ - * combiners, texgen state, and pointers to current texture objects. - */ -struct gl_texture_unit -{ - GLbitfield Enabled; /**< bitmask of TEXTURE_*_BIT flags */ - GLbitfield _ReallyEnabled; /**< 0 or exactly one of TEXTURE_*_BIT flags */ - - GLenum EnvMode; /**< GL_MODULATE, GL_DECAL, GL_BLEND, etc. */ - GLclampf EnvColor[4]; - - struct gl_texgen GenS; - struct gl_texgen GenT; - struct gl_texgen GenR; - struct gl_texgen GenQ; - GLbitfield TexGenEnabled; /**< Bitwise-OR of [STRQ]_BIT values */ - GLbitfield _GenFlags; /**< Bitwise-OR of Gen[STRQ]._ModeBit */ - - GLfloat LodBias; /**< for biasing mipmap levels */ - - /** - * \name GL_EXT_texture_env_combine - */ - struct gl_tex_env_combine_state Combine; - - /** - * Derived state based on \c EnvMode and the \c BaseFormat of the - * currently enabled texture. - */ - struct gl_tex_env_combine_state _EnvMode; - - /** - * Currently enabled combiner state. This will point to either - * \c Combine or \c _EnvMode. - */ - struct gl_tex_env_combine_state *_CurrentCombine; - - /** Current texture object pointers */ - struct gl_texture_object *CurrentTex[NUM_TEXTURE_TARGETS]; - - /** Points to highest priority, complete and enabled texture object */ - struct gl_texture_object *_Current; -}; - - -/** - * Texture attribute group (GL_TEXTURE_BIT). - */ -struct gl_texture_attrib -{ - struct gl_texture_unit Unit; - - struct gl_texture_object *ProxyTex[NUM_TEXTURE_TARGETS]; - - GLboolean _Enabled; - - /** Texture coord units/sets used for fragment texturing */ - GLboolean _EnabledCoord; - - /** Texture coord units that have texgen enabled */ - GLboolean _TexGenEnabled; - - /** Texture coord units that have non-identity matrices */ - GLboolean _TexMatEnabled; - - /** Bitwise-OR of all Texture.Unit[i]._GenFlags */ - GLbitfield _GenFlags; -}; - - -/** - * Data structure representing a single clip plane (e.g. one of the elements - * of the ctx->Transform.EyeUserPlane or ctx->Transform._ClipUserPlane array). - */ -typedef GLfloat gl_clip_plane[4]; - - -/** - * Transformation attribute group (GL_TRANSFORM_BIT). - */ -struct gl_transform_attrib -{ - GLenum MatrixMode; /**< Matrix mode */ - gl_clip_plane EyeUserPlane[MAX_CLIP_PLANES]; /**< User clip planes */ - gl_clip_plane _ClipUserPlane[MAX_CLIP_PLANES]; /**< derived */ - GLbitfield ClipPlanesEnabled; /**< on/off bitmask */ - GLboolean Normalize; /**< Normalize all normals? */ - GLboolean RescaleNormals; /**< GL_EXT_rescale_normal */ - GLboolean RasterPositionUnclipped; /**< GL_IBM_rasterpos_clip */ - - GLfloat CullEyePos[4]; - GLfloat CullObjPos[4]; -}; - - -/** - * Viewport attribute group (GL_VIEWPORT_BIT). - */ -struct gl_viewport_attrib -{ - GLint X, Y; /**< position */ - GLsizei Width, Height; /**< size */ - GLfloat Near, Far; /**< Depth buffer range */ - GLmatrix _WindowMap; /**< Mapping transformation as a matrix. */ -}; - - -/** - * GL_ARB_vertex/pixel_buffer_object buffer object - */ -struct gl_buffer_object -{ - _glthread_Mutex Mutex; - GLint RefCount; - GLuint Name; - GLenum Usage; /**< GL_STREAM_DRAW_ARB, GL_STREAM_READ_ARB, etc. */ - GLsizeiptrARB Size; /**< Size of buffer storage in bytes */ - GLubyte *Data; /**< Location of storage either in RAM or VRAM. */ - /** Fields describing a mapped buffer */ - /*@{*/ - GLbitfield AccessFlags; /**< Mask of GL_MAP_x_BIT flags */ - GLvoid *Pointer; /**< User-space address of mapping */ - GLintptr Offset; /**< Mapped offset */ - GLsizeiptr Length; /**< Mapped length */ - /*@}*/ - GLboolean DeletePending; /**< true if buffer object is removed from the hash */ - GLboolean Written; /**< Ever written to? (for debugging) */ - GLboolean Purgeable; /**< Is the buffer purgeable under memory pressure? */ -}; - - -/** - * Client pixel packing/unpacking attributes - */ -struct gl_pixelstore_attrib -{ - GLint Alignment; - GLint RowLength; - GLint SkipPixels; - GLint SkipRows; - GLint ImageHeight; - GLint SkipImages; - GLboolean SwapBytes; - GLboolean LsbFirst; - GLboolean Invert; /**< GL_MESA_pack_invert */ -}; - - -/** - * Client vertex array attributes - */ -struct gl_client_array -{ - GLint Size; /**< components per element (1,2,3,4) */ - GLenum Type; /**< datatype: GL_FLOAT, GL_INT, etc */ - GLsizei Stride; /**< user-specified stride */ - GLsizei StrideB; /**< actual stride in bytes */ - const GLubyte *Ptr; /**< Points to array data */ - GLboolean Enabled; /**< Enabled flag is a boolean */ - GLboolean Normalized; /**< GL_ARB_vertex_program */ - GLboolean Integer; /**< Integer-valued? */ - GLuint _ElementSize; /**< size of each element in bytes */ - - struct gl_buffer_object *BufferObj;/**< GL_ARB_vertex_buffer_object */ - GLuint _MaxElement; /**< max element index into array buffer + 1 */ -}; - - -/** - * Vertex array state - */ -struct gl_array_attrib -{ - /** Vertex attribute arrays */ - struct gl_client_array VertexAttrib[VERT_ATTRIB_MAX]; - - /** Mask of VERT_BIT_* values indicating which arrays are enabled */ - GLbitfield64 _Enabled; - - /** - * Min of all enabled arrays' _MaxElement. When arrays reside inside VBOs - * we can determine the max legal (in bounds) glDrawElements array index. - */ - GLuint _MaxElement; - - struct gl_buffer_object *ElementArrayBufferObj; - - GLuint LockFirst; /**< GL_EXT_compiled_vertex_array */ - GLuint LockCount; /**< GL_EXT_compiled_vertex_array */ - - GLbitfield64 NewState; /**< mask of VERT_BIT_* values */ - GLboolean RebindArrays; /**< whether the VBO module should rebind arrays */ -}; - - -/** - * Feedback buffer state - */ -struct gl_feedback -{ - GLenum Type; - GLbitfield _Mask; /**< FB_* bits */ - GLfloat *Buffer; - GLuint BufferSize; - GLuint Count; -}; - - -/** - * Selection buffer state - */ -struct gl_selection -{ - GLuint *Buffer; /**< selection buffer */ - GLuint BufferSize; /**< size of the selection buffer */ - GLuint BufferCount; /**< number of values in the selection buffer */ - GLuint Hits; /**< number of records in the selection buffer */ - GLuint NameStackDepth; /**< name stack depth */ - GLuint NameStack[MAX_NAME_STACK_DEPTH]; /**< name stack */ - GLboolean HitFlag; /**< hit flag */ - GLfloat HitMinZ; /**< minimum hit depth */ - GLfloat HitMaxZ; /**< maximum hit depth */ -}; - - -/** - * 1-D Evaluator control points - */ -struct gl_1d_map -{ - GLuint Order; /**< Number of control points */ - GLfloat u1, u2, du; /**< u1, u2, 1.0/(u2-u1) */ - GLfloat *Points; /**< Points to contiguous control points */ -}; - - -/** - * 2-D Evaluator control points - */ -struct gl_2d_map -{ - GLuint Uorder; /**< Number of control points in U dimension */ - GLuint Vorder; /**< Number of control points in V dimension */ - GLfloat u1, u2, du; - GLfloat v1, v2, dv; - GLfloat *Points; /**< Points to contiguous control points */ -}; - - -/** - * All evaluator control point state - */ -struct gl_evaluators -{ - /** - * \name 1-D maps - */ - /*@{*/ - struct gl_1d_map Map1Vertex3; - struct gl_1d_map Map1Vertex4; - struct gl_1d_map Map1Index; - struct gl_1d_map Map1Color4; - struct gl_1d_map Map1Normal; - struct gl_1d_map Map1Texture1; - struct gl_1d_map Map1Texture2; - struct gl_1d_map Map1Texture3; - struct gl_1d_map Map1Texture4; - /*@}*/ - - /** - * \name 2-D maps - */ - /*@{*/ - struct gl_2d_map Map2Vertex3; - struct gl_2d_map Map2Vertex4; - struct gl_2d_map Map2Index; - struct gl_2d_map Map2Color4; - struct gl_2d_map Map2Normal; - struct gl_2d_map Map2Texture1; - struct gl_2d_map Map2Texture2; - struct gl_2d_map Map2Texture3; - struct gl_2d_map Map2Texture4; - /*@}*/ -}; - - -/** - * State which can be shared by multiple contexts: - */ -struct gl_shared_state -{ - _glthread_Mutex Mutex; /**< for thread safety */ - GLint RefCount; /**< Reference count */ - struct _mesa_HashTable *DisplayList; /**< Display lists hash table */ - struct _mesa_HashTable *TexObjects; /**< Texture objects hash table */ - - /** Default texture objects (shared by all texture units) */ - struct gl_texture_object *DefaultTex[NUM_TEXTURE_TARGETS]; - - /** Fallback texture used when a bound texture is incomplete */ - struct gl_texture_object *FallbackTex; - - /** - * \name Thread safety and statechange notification for texture - * objects. - * - * \todo Improve the granularity of locking. - */ - /*@{*/ - _glthread_Mutex TexMutex; /**< texobj thread safety */ - GLuint TextureStateStamp; /**< state notification for shared tex */ - /*@}*/ - - /** Default buffer object for vertex arrays that aren't in VBOs */ - struct gl_buffer_object *NullBufferObj; - - struct _mesa_HashTable *BufferObjects; - - void *DriverData; /**< Device driver shared state */ -}; - - - -/** - * Renderbuffers represent drawing surfaces such as color, depth and/or - * stencil. A framebuffer object has a set of renderbuffers. - * Drivers will typically derive subclasses of this type. - */ -struct gl_renderbuffer -{ - _glthread_Mutex Mutex; /**< for thread safety */ - GLuint ClassID; /**< Useful for drivers */ - GLint RefCount; - GLuint Width, Height; - GLboolean Purgeable; /**< Is the buffer purgeable under memory pressure? */ - GLboolean AttachedAnytime; /**< TRUE if it was attached to a framebuffer */ - GLenum InternalFormat; /**< The user-specified format */ - GLenum _BaseFormat; /**< Either GL_RGB, GL_RGBA, GL_DEPTH_COMPONENT or - GL_STENCIL_INDEX. */ - gl_format Format; /**< The actual renderbuffer memory format */ - - /** Delete this renderbuffer */ - void (*Delete)(struct gl_renderbuffer *rb); - - /** Allocate new storage for this renderbuffer */ - GLboolean (*AllocStorage)(struct gl_context *ctx, - struct gl_renderbuffer *rb, - GLenum internalFormat, - GLuint width, GLuint height); -}; - - -/** - * A renderbuffer attachment points to either a texture object (and specifies - * a mipmap level, cube face or 3D texture slice) or points to a renderbuffer. - */ -struct gl_renderbuffer_attachment -{ - /** - * If \c Type is \c GL_RENDERBUFFER_EXT, this stores a pointer to the - * application supplied renderbuffer object. - */ - struct gl_renderbuffer *Renderbuffer; -}; - - -/** - * A framebuffer is a collection of renderbuffers (color, depth, stencil, etc). - * In C++ terms, think of this as a base class from which device drivers - * will make derived classes. - */ -struct gl_framebuffer -{ - _glthread_Mutex Mutex; /**< for thread safety */ - - GLint RefCount; - GLboolean DeletePending; - - /** - * The framebuffer's visual. Immutable if this is a window system buffer. - * Computed from attachments if user-made FBO. - */ - struct gl_config Visual; - - GLboolean Initialized; - - GLuint Width, Height; /**< size of frame buffer in pixels */ - - /** \name Drawing bounds (Intersection of buffer size and scissor box) */ - /*@{*/ - GLint _Xmin, _Xmax; /**< inclusive */ - GLint _Ymin, _Ymax; /**< exclusive */ - /*@}*/ - - /** \name Derived Z buffer stuff */ - /*@{*/ - GLuint _DepthMax; /**< Max depth buffer value */ - GLfloat _DepthMaxF; /**< Float max depth buffer value */ - GLfloat _MRD; /**< minimum resolvable difference in Z values */ - /*@}*/ - - /** Integer color values */ - GLboolean _IntegerColor; - - /** Array of all renderbuffer attachments, indexed by BUFFER_* tokens. */ - struct gl_renderbuffer_attachment Attachment[BUFFER_COUNT]; - - /* In unextended OpenGL these vars are part of the GL_COLOR_BUFFER - * attribute group and GL_PIXEL attribute group, respectively. - */ - GLenum ColorDrawBuffer; - GLenum ColorReadBuffer; - - /** Computed from ColorDraw/ReadBuffer above */ - GLint _ColorDrawBufferIndex; /**< BUFFER_x or -1 */ - GLint _ColorReadBufferIndex; /* -1 = None */ - struct gl_renderbuffer *_ColorDrawBuffer; - struct gl_renderbuffer *_ColorReadBuffer; - - /** Delete this framebuffer */ - void (*Delete)(struct gl_framebuffer *fb); -}; - -/** - * Constants which may be overridden by device driver during context creation - * but are never changed after that. - */ -struct gl_constants -{ - GLint MaxTextureMbytes; /**< Max memory per image, in MB */ - GLint MaxTextureLevels; /**< Max mipmap levels. */ - GLint MaxCubeTextureLevels; /**< Max mipmap levels for cube textures */ - GLfloat MaxTextureMaxAnisotropy; /**< GL_EXT_texture_filter_anisotropic */ - - GLuint MaxArrayLockSize; - - GLint SubPixelBits; - - GLfloat MinPointSize, MaxPointSize; /**< aliased */ - GLfloat MinPointSizeAA, MaxPointSizeAA; /**< antialiased */ - GLfloat PointSizeGranularity; - GLfloat MinLineWidth, MaxLineWidth; /**< aliased */ - GLfloat MinLineWidthAA, MaxLineWidthAA; /**< antialiased */ - GLfloat LineWidthGranularity; - - GLuint MaxClipPlanes; - GLuint MaxLights; - GLfloat MaxShininess; /**< GL_NV_light_max_exponent */ - GLfloat MaxSpotExponent; /**< GL_NV_light_max_exponent */ - - GLuint MaxViewportWidth, MaxViewportHeight; - - /** vertex array / buffer object bounds checking */ - GLboolean CheckArrayBounds; - - /** - * Does the driver support real 32-bit integers? (Otherwise, integers are - * simulated via floats.) - */ - GLboolean NativeIntegers; - - /** OpenGL version 3.0 */ - GLbitfield ContextFlags; /**< Ex: GL_CONTEXT_FLAG_FORWARD_COMPATIBLE_BIT */ - - /** OpenGL version 3.2 */ - GLbitfield ProfileMask; /**< Mask of CONTEXT_x_PROFILE_BIT */ - - /** - * Whether the implementation strips out and ignores texture borders. - * - * Many GPU hardware implementations don't support rendering with texture - * borders and mipmapped textures. (Note: not static border color, but the - * old 1-pixel border around each edge). Implementations then have to do - * slow fallbacks to be correct, or just ignore the border and be fast but - * wrong. Setting the flag stripts the border off of TexImage calls, - * providing "fast but wrong" at significantly reduced driver complexity. - * - * Texture borders are deprecated in GL 3.0. - **/ - GLboolean StripTextureBorder; -}; - - -/** - * Enable flag for each OpenGL extension. Different device drivers will - * enable different extensions at runtime. - */ -struct gl_extensions -{ - GLboolean dummy; /* don't remove this! */ - GLboolean dummy_true; /* Set true by _mesa_init_extensions(). */ - GLboolean dummy_false; /* Set false by _mesa_init_extensions(). */ - GLboolean ARB_map_buffer_range; - GLboolean ARB_point_sprite; - GLboolean ARB_texture_cube_map; - GLboolean ARB_texture_env_combine; - GLboolean ARB_texture_env_crossbar; - GLboolean ARB_texture_env_dot3; - GLboolean ARB_texture_storage; - GLboolean ARB_transpose_matrix; - GLboolean ARB_window_pos; - GLboolean EXT_blend_color; - GLboolean EXT_blend_equation_separate; - GLboolean EXT_blend_func_separate; - GLboolean EXT_blend_minmax; - GLboolean EXT_clip_volume_hint; - GLboolean EXT_compiled_vertex_array; - GLboolean EXT_depth_bounds_test; - GLboolean EXT_draw_range_elements; - GLboolean EXT_fog_coord; - GLboolean EXT_packed_pixels; - GLboolean EXT_point_parameters; - GLboolean EXT_rescale_normal; - GLboolean EXT_shadow_funcs; - GLboolean EXT_secondary_color; - GLboolean EXT_separate_shader_objects; - GLboolean EXT_separate_specular_color; - GLboolean EXT_texture_env_dot3; - GLboolean EXT_texture_filter_anisotropic; - GLboolean EXT_texture_integer; - /* vendor extensions */ - GLboolean APPLE_packed_pixels; - GLboolean ATI_texture_env_combine3; - GLboolean IBM_rasterpos_clip; - GLboolean IBM_multimode_draw_arrays; - GLboolean MESA_pack_invert; - GLboolean MESA_resize_buffers; - GLboolean MESA_ycbcr_texture; - GLboolean NV_blend_square; - GLboolean NV_fog_distance; - GLboolean NV_light_max_exponent; - GLboolean NV_point_sprite; - GLboolean NV_texgen_reflection; - GLboolean NV_texture_env_combine4; - GLboolean extension_sentinel; - /** The extension string */ - const GLubyte *String; - /** Number of supported extensions */ - GLuint Count; -}; - - -/** - * A stack of matrices (projection, modelview, color, texture, etc). - */ -struct gl_matrix_stack -{ - GLmatrix *Top; /**< points into Stack */ - GLmatrix *Stack; /**< array [MaxDepth] of GLmatrix */ - GLuint Depth; /**< 0 <= Depth < MaxDepth */ - GLuint MaxDepth; /**< size of Stack[] array */ - GLuint DirtyFlag; /**< _NEW_MODELVIEW or _NEW_PROJECTION, for example */ -}; - - -/** - * \name Bits for image transfer operations - * \sa __struct gl_contextRec::ImageTransferState. - */ -/*@{*/ -#define IMAGE_SCALE_BIAS_BIT 0x1 -#define IMAGE_SHIFT_OFFSET_BIT 0x2 -#define IMAGE_MAP_COLOR_BIT 0x4 -#define IMAGE_CLAMP_BIT 0x800 - - -/** Pixel Transfer ops */ -#define IMAGE_BITS (IMAGE_SCALE_BIAS_BIT | \ - IMAGE_SHIFT_OFFSET_BIT | \ - IMAGE_MAP_COLOR_BIT) - -/** - * \name Bits to indicate what state has changed. - */ -/*@{*/ -#define _NEW_MODELVIEW (1 << 0) /**< gl_context::ModelView */ -#define _NEW_PROJECTION (1 << 1) /**< gl_context::Projection */ -#define _NEW_TEXTURE_MATRIX (1 << 2) /**< gl_context::TextureMatrix */ -#define _NEW_COLOR (1 << 3) /**< gl_context::Color */ -#define _NEW_DEPTH (1 << 4) /**< gl_context::Depth */ -#define _NEW_EVAL (1 << 5) /**< gl_context::Eval, EvalMap */ -#define _NEW_FOG (1 << 6) /**< gl_context::Fog */ -#define _NEW_HINT (1 << 7) /**< gl_context::Hint */ -#define _NEW_LIGHT (1 << 8) /**< gl_context::Light */ -#define _NEW_LINE (1 << 9) /**< gl_context::Line */ -#define _NEW_PIXEL (1 << 10) /**< gl_context::Pixel */ -#define _NEW_POINT (1 << 11) /**< gl_context::Point */ -#define _NEW_POLYGON (1 << 12) /**< gl_context::Polygon */ -#define _NEW_POLYGONSTIPPLE (1 << 13) /**< gl_context::PolygonStipple */ -#define _NEW_SCISSOR (1 << 14) /**< gl_context::Scissor */ -#define _NEW_STENCIL (1 << 15) /**< gl_context::Stencil */ -#define _NEW_TEXTURE (1 << 16) /**< gl_context::Texture */ -#define _NEW_TRANSFORM (1 << 17) /**< gl_context::Transform */ -#define _NEW_VIEWPORT (1 << 18) /**< gl_context::Viewport */ -#define _NEW_PACKUNPACK (1 << 19) /**< gl_context::Pack, Unpack */ -#define _NEW_ARRAY (1 << 20) /**< gl_context::Array */ -#define _NEW_RENDERMODE (1 << 21) /**< gl_context::RenderMode, etc */ -#define _NEW_BUFFERS (1 << 22) /**< gl_context::Visual, DrawBuffer, */ -#define _NEW_CURRENT_ATTRIB (1 << 23) /**< gl_context::Current */ -#define _NEW_MULTISAMPLE (1 << 24) /**< gl_context::Multisample */ -#define _NEW_BUFFER_OBJECT (1 << 25) -#define _NEW_ALL ~0 - -/** - * We use _NEW_TRANSFORM for GL_RASTERIZER_DISCARD. This #define is for - * clarity. - */ -#define _NEW_RASTERIZER_DISCARD _NEW_TRANSFORM -/*@}*/ - - -/** - * \name A bunch of flags that we think might be useful to drivers. - * - * Set in the __struct gl_contextRec::_TriangleCaps bitfield. - */ -/*@{*/ -#define DD_FLATSHADE 0x1 -#define DD_TRI_CULL_FRONT_BACK 0x2 /* special case on some hw */ -#define DD_TRI_LIGHT_TWOSIDE 0x4 -#define DD_TRI_UNFILLED 0x8 -#define DD_TRI_SMOOTH 0x10 -#define DD_TRI_STIPPLE 0x20 -#define DD_TRI_OFFSET 0x40 -#define DD_LINE_SMOOTH 0x80 -#define DD_LINE_STIPPLE 0x100 -#define DD_POINT_SMOOTH 0x200 -#define DD_POINT_ATTEN 0x400 -/*@}*/ - - -/** - * \name Define the state changes under which each of these bits might change - */ -/*@{*/ -#define _DD_NEW_FLATSHADE _NEW_LIGHT -#define _DD_NEW_SEPARATE_SPECULAR (_NEW_LIGHT | _NEW_FOG) -#define _DD_NEW_TRI_CULL_FRONT_BACK _NEW_POLYGON -#define _DD_NEW_TRI_LIGHT_TWOSIDE _NEW_LIGHT -#define _DD_NEW_TRI_UNFILLED _NEW_POLYGON -#define _DD_NEW_TRI_SMOOTH _NEW_POLYGON -#define _DD_NEW_TRI_STIPPLE _NEW_POLYGON -#define _DD_NEW_TRI_OFFSET _NEW_POLYGON -#define _DD_NEW_LINE_SMOOTH _NEW_LINE -#define _DD_NEW_LINE_STIPPLE _NEW_LINE -#define _DD_NEW_LINE_WIDTH _NEW_LINE -#define _DD_NEW_POINT_SMOOTH _NEW_POINT -#define _DD_NEW_POINT_SIZE _NEW_POINT -#define _DD_NEW_POINT_ATTEN _NEW_POINT -/*@}*/ - - -/** - * Composite state flags - */ -/*@{*/ -#define _MESA_NEW_NEED_EYE_COORDS (_NEW_LIGHT | \ - _NEW_TEXTURE | \ - _NEW_POINT | \ - _NEW_MODELVIEW) -/*@}*/ - - - - -/* This has to be included here. */ -#include "dd.h" - - -/** - * Display list flags. - * Strictly this is a tnl-private concept, but it doesn't seem - * worthwhile adding a tnl private structure just to hold this one bit - * of information: - */ -#define DLIST_DANGLING_REFS 0x1 - - -/** Opaque declaration of display list payload data type */ -union gl_dlist_node; - - -/** - * Provide a location where information about a display list can be - * collected. Could be extended with driverPrivate structures, - * etc. in the future. - */ -struct gl_display_list -{ - GLuint Name; - GLbitfield Flags; /**< DLIST_x flags */ - /** The dlist commands are in a linked list of nodes */ - union gl_dlist_node *Head; -}; - - -/** - * State used during display list compilation and execution. - */ -struct gl_dlist_state -{ - GLuint CallDepth; /**< Current recursion calling depth */ - - struct gl_display_list *CurrentList; /**< List currently being compiled */ - union gl_dlist_node *CurrentBlock; /**< Pointer to current block of nodes */ - GLuint CurrentPos; /**< Index into current block of nodes */ - - GLvertexformat ListVtxfmt; - - GLubyte ActiveAttribSize[VERT_ATTRIB_MAX]; - GLfloat CurrentAttrib[VERT_ATTRIB_MAX][4]; - - GLubyte ActiveMaterialSize[MAT_ATTRIB_MAX]; - GLfloat CurrentMaterial[MAT_ATTRIB_MAX][4]; - - GLubyte ActiveIndex; - GLfloat CurrentIndex; - - GLubyte ActiveEdgeFlag; - GLboolean CurrentEdgeFlag; - - struct { - /* State known to have been set by the currently-compiling display - * list. Used to eliminate some redundant state changes. - */ - GLenum ShadeModel; - } Current; -}; - - -/** - * Mesa rendering context. - * - * This is the central context data structure for Mesa. Almost all - * OpenGL state is contained in this structure. - * Think of this as a base class from which device drivers will derive - * sub classes. - * - * The struct gl_context typedef names this structure. - */ -struct gl_context -{ - /** State possibly shared with other contexts in the address space */ - struct gl_shared_state *Shared; - - /** \name API function pointer tables */ - /*@{*/ - struct _glapi_table *Save; /**< Display list save functions */ - struct _glapi_table *Exec; /**< Execute functions */ - struct _glapi_table *CurrentDispatch; /**< == Save or Exec !! */ - /*@}*/ - - struct gl_config Visual; - struct gl_framebuffer *DrawBuffer; /**< buffer for writing */ - struct gl_framebuffer *ReadBuffer; /**< buffer for reading */ - struct gl_framebuffer *WinSysDrawBuffer; /**< set with MakeCurrent */ - struct gl_framebuffer *WinSysReadBuffer; /**< set with MakeCurrent */ - - /** - * Device driver function pointer table - */ - struct dd_function_table Driver; - - void *DriverCtx; /**< Points to device driver context/state */ - - /** Core/Driver constants */ - struct gl_constants Const; - - /** \name The various 4x4 matrix stacks */ - /*@{*/ - struct gl_matrix_stack ModelviewMatrixStack; - struct gl_matrix_stack ProjectionMatrixStack; - struct gl_matrix_stack TextureMatrixStack; - struct gl_matrix_stack *CurrentStack; /**< Points to one of the above stacks */ - /*@}*/ - - /** Combined modelview and projection matrix */ - GLmatrix _ModelProjectMatrix; - - /** \name Display lists */ - struct gl_dlist_state ListState; - - GLboolean ExecuteFlag; /**< Execute GL commands? */ - GLboolean CompileFlag; /**< Compile GL commands into display list? */ - - /** Extension information */ - struct gl_extensions Extensions; - - /** Version info */ - GLuint VersionMajor, VersionMinor; - char *VersionString; - - /** \name State attribute stack (for glPush/PopAttrib) */ - /*@{*/ - GLuint AttribStackDepth; - struct gl_attrib_node *AttribStack[MAX_ATTRIB_STACK_DEPTH]; - /*@}*/ - - /** \name Renderer attribute groups - * - * We define a struct for each attribute group to make pushing and popping - * attributes easy. Also it's a good organization. - */ - /*@{*/ - struct gl_accum_attrib Accum; /**< Accum buffer attributes */ - struct gl_colorbuffer_attrib Color; /**< Color buffer attributes */ - struct gl_current_attrib Current; /**< Current attributes */ - struct gl_depthbuffer_attrib Depth; /**< Depth buffer attributes */ - struct gl_eval_attrib Eval; /**< Eval attributes */ - struct gl_fog_attrib Fog; /**< Fog attributes */ - struct gl_hint_attrib Hint; /**< Hint attributes */ - struct gl_light_attrib Light; /**< Light attributes */ - struct gl_line_attrib Line; /**< Line attributes */ - struct gl_list_attrib List; /**< List attributes */ - struct gl_multisample_attrib Multisample; - struct gl_pixel_attrib Pixel; /**< Pixel attributes */ - struct gl_point_attrib Point; /**< Point attributes */ - struct gl_polygon_attrib Polygon; /**< Polygon attributes */ - GLuint PolygonStipple[32]; /**< Polygon stipple */ - struct gl_scissor_attrib Scissor; /**< Scissor attributes */ - struct gl_stencil_attrib Stencil; /**< Stencil buffer attributes */ - struct gl_texture_attrib Texture; /**< Texture attributes */ - struct gl_transform_attrib Transform; /**< Transformation attributes */ - struct gl_viewport_attrib Viewport; /**< Viewport attributes */ - /*@}*/ - - /** \name Client attribute stack */ - /*@{*/ - GLuint ClientAttribStackDepth; - struct gl_attrib_node *ClientAttribStack[MAX_CLIENT_ATTRIB_STACK_DEPTH]; - /*@}*/ - - /** \name Client attribute groups */ - /*@{*/ - struct gl_array_attrib Array; /**< Vertex arrays */ - struct gl_pixelstore_attrib Pack; /**< Pixel packing */ - struct gl_pixelstore_attrib Unpack; /**< Pixel unpacking */ - struct gl_pixelstore_attrib DefaultPacking; /**< Default params */ - /*@}*/ - - /** \name Other assorted state (not pushed/popped on attribute stack) */ - /*@{*/ - struct gl_pixelmaps PixelMaps; - - struct gl_evaluators EvalMap; /**< All evaluators */ - struct gl_feedback Feedback; /**< Feedback */ - struct gl_selection Select; /**< Selection */ - /*@}*/ - - struct gl_meta_state *Meta; /**< for "meta" operations */ - - /* GL_EXT_framebuffer_object */ - struct gl_renderbuffer *CurrentRenderbuffer; - - GLenum ErrorValue; /**< Last error code */ - - /** - * Recognize and silence repeated error debug messages in buggy apps. - */ - const char *ErrorDebugFmtString; - GLuint ErrorDebugCount; - - GLenum RenderMode; /**< either GL_RENDER, GL_SELECT, GL_FEEDBACK */ - GLbitfield NewState; /**< bitwise-or of _NEW_* flags */ - - GLboolean ViewportInitialized; /**< has viewport size been initialized? */ - - /** \name Derived state */ - /*@{*/ - /** Bitwise-or of DD_* flags. Note that this bitfield may be used before - * state validation so they need to always be current. - */ - GLbitfield _TriangleCaps; - GLbitfield _ImageTransferState;/**< bitwise-or of IMAGE_*_BIT flags */ - GLfloat _EyeZDir[3]; - GLfloat _ModelViewInvScale; - GLboolean _NeedEyeCoords; - GLboolean _ForceEyeCoords; - - GLuint TextureStateTimestamp; /**< detect changes to shared state */ - - struct gl_shine_tab *_ShineTable[2]; /**< Active shine tables */ - struct gl_shine_tab *_ShineTabList; /**< MRU list of inactive shine tables */ - /**@}*/ - - struct gl_list_extensions *ListExt; /**< driver dlist extensions */ - - /** \name For debugging/development only */ - /*@{*/ - GLboolean FirstTimeCurrent; - /*@}*/ - - GLboolean TextureFormatSupported[MESA_FORMAT_COUNT]; - - /** - * Use dp4 (rather than mul/mad) instructions for position - * transformation? - */ - GLboolean mvp_with_dp4; - - GLboolean RasterDiscard; /**< GL_RASTERIZER_DISCARD */ - - /** - * \name Hooks for module contexts. - * - * These will eventually live in the driver or elsewhere. - */ - /*@{*/ - void *swrast_context; - void *swsetup_context; - void *swtnl_context; - void *swtnl_im; - struct st_context *st; - void *aelt_context; - /*@}*/ -}; - - -#ifdef DEBUG -extern int MESA_VERBOSE; -extern int MESA_DEBUG_FLAGS; -# define MESA_FUNCTION __FUNCTION__ -#else -# define MESA_VERBOSE 0 -# define MESA_DEBUG_FLAGS 0 -# define MESA_FUNCTION "a function" -# ifndef NDEBUG -# define NDEBUG -# endif -#endif - - -/** The MESA_VERBOSE var is a bitmask of these flags */ -enum _verbose -{ - VERBOSE_VARRAY = 0x0001, - VERBOSE_TEXTURE = 0x0002, - VERBOSE_MATERIAL = 0x0004, - VERBOSE_PIPELINE = 0x0008, - VERBOSE_DRIVER = 0x0010, - VERBOSE_STATE = 0x0020, - VERBOSE_API = 0x0040, - VERBOSE_DISPLAY_LIST = 0x0100, - VERBOSE_LIGHTING = 0x0200, - VERBOSE_PRIMS = 0x0400, - VERBOSE_VERTS = 0x0800, - VERBOSE_DISASSEM = 0x1000, - VERBOSE_DRAW = 0x2000, - VERBOSE_SWAPBUFFERS = 0x4000 -}; - - -/** The MESA_DEBUG_FLAGS var is a bitmask of these flags */ -enum _debug -{ - DEBUG_ALWAYS_FLUSH = 0x1 -}; - - - -#ifdef __cplusplus -} -#endif - -#endif /* MTYPES_H */ diff --git a/dll/opengl/mesa/main/multisample.c b/dll/opengl/mesa/main/multisample.c deleted file mode 100644 index 8a844b5ff4b..00000000000 --- a/dll/opengl/mesa/main/multisample.c +++ /dev/null @@ -1,56 +0,0 @@ -/* - * Mesa 3-D graphics library - * Version: 7.1 - * - * Copyright (C) 1999-2007 Brian Paul All Rights Reserved. - * - * Permission is hereby granted, free of charge, to any person obtaining a - * copy of this software and associated documentation files (the "Software"), - * to deal in the Software without restriction, including without limitation - * the rights to use, copy, modify, merge, publish, distribute, sublicense, - * and/or sell copies of the Software, and to permit persons to whom the - * Software is furnished to do so, subject to the following conditions: - * - * The above copyright notice and this permission notice shall be included - * in all copies or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS - * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL - * BRIAN PAUL BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN - * AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN - * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. - */ - -#include - -/** - * Called via glSampleCoverageARB - */ -void GLAPIENTRY -_mesa_SampleCoverageARB(GLclampf value, GLboolean invert) -{ - GET_CURRENT_CONTEXT(ctx); - - ASSERT_OUTSIDE_BEGIN_END_AND_FLUSH( ctx ); - - ctx->Multisample.SampleCoverageValue = (GLfloat) CLAMP(value, 0.0, 1.0); - ctx->Multisample.SampleCoverageInvert = invert; - ctx->NewState |= _NEW_MULTISAMPLE; -} - - -/** - * Initialize the context's multisample state. - * \param ctx the GL context. - */ -void -_mesa_init_multisample(struct gl_context *ctx) -{ - ctx->Multisample.Enabled = GL_TRUE; - ctx->Multisample.SampleAlphaToCoverage = GL_FALSE; - ctx->Multisample.SampleAlphaToOne = GL_FALSE; - ctx->Multisample.SampleCoverage = GL_FALSE; - ctx->Multisample.SampleCoverageValue = 1.0; - ctx->Multisample.SampleCoverageInvert = GL_FALSE; -} diff --git a/dll/opengl/mesa/main/multisample.h b/dll/opengl/mesa/main/multisample.h deleted file mode 100644 index e86d4092bc9..00000000000 --- a/dll/opengl/mesa/main/multisample.h +++ /dev/null @@ -1,41 +0,0 @@ -/* - * Mesa 3-D graphics library - * Version: 7.1 - * - * Copyright (C) 1999-2007 Brian Paul All Rights Reserved. - * - * Permission is hereby granted, free of charge, to any person obtaining a - * copy of this software and associated documentation files (the "Software"), - * to deal in the Software without restriction, including without limitation - * the rights to use, copy, modify, merge, publish, distribute, sublicense, - * and/or sell copies of the Software, and to permit persons to whom the - * Software is furnished to do so, subject to the following conditions: - * - * The above copyright notice and this permission notice shall be included - * in all copies or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS - * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL - * BRIAN PAUL BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN - * AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN - * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. - */ - - -#ifndef MULTISAMPLE_H -#define MULTISAMPLE_H - -#include "glheader.h" - -struct gl_context; - -extern void GLAPIENTRY -_mesa_SampleCoverageARB(GLclampf value, GLboolean invert); - - -extern void -_mesa_init_multisample(struct gl_context *ctx); - - -#endif diff --git a/dll/opengl/mesa/main/pack.c b/dll/opengl/mesa/main/pack.c deleted file mode 100644 index 6217e2f3d8c..00000000000 --- a/dll/opengl/mesa/main/pack.c +++ /dev/null @@ -1,4547 +0,0 @@ -/* - * Mesa 3-D graphics library - * - * Copyright (C) 1999-2008 Brian Paul All Rights Reserved. - * Copyright (C) 2009-2010 VMware, Inc. All Rights Reserved. - * - * Permission is hereby granted, free of charge, to any person obtaining a - * copy of this software and associated documentation files (the "Software"), - * to deal in the Software without restriction, including without limitation - * the rights to use, copy, modify, merge, publish, distribute, sublicense, - * and/or sell copies of the Software, and to permit persons to whom the - * Software is furnished to do so, subject to the following conditions: - * - * The above copyright notice and this permission notice shall be included - * in all copies or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS - * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL - * THEA AUTHORS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN - * AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN - * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. - */ - -/** - * \file pack.c - * Image and pixel span packing and unpacking. - */ - -#include - -/** - * Flip the 8 bits in each byte of the given array. - * - * \param p array. - * \param n number of bytes. - * - * \todo try this trick to flip bytes someday: - * \code - * v = ((v & 0x55555555) << 1) | ((v >> 1) & 0x55555555); - * v = ((v & 0x33333333) << 2) | ((v >> 2) & 0x33333333); - * v = ((v & 0x0f0f0f0f) << 4) | ((v >> 4) & 0x0f0f0f0f); - * \endcode - */ -static void -flip_bytes( GLubyte *p, GLuint n ) -{ - GLuint i, a, b; - for (i = 0; i < n; i++) { - b = (GLuint) p[i]; /* words are often faster than bytes */ - a = ((b & 0x01) << 7) | - ((b & 0x02) << 5) | - ((b & 0x04) << 3) | - ((b & 0x08) << 1) | - ((b & 0x10) >> 1) | - ((b & 0x20) >> 3) | - ((b & 0x40) >> 5) | - ((b & 0x80) >> 7); - p[i] = (GLubyte) a; - } -} - - - -/* - * Unpack a 32x32 pixel polygon stipple from user memory using the - * current pixel unpack settings. - */ -void -_mesa_unpack_polygon_stipple( const GLubyte *pattern, GLuint dest[32], - const struct gl_pixelstore_attrib *unpacking ) -{ - GLubyte *ptrn = (GLubyte *) _mesa_unpack_bitmap(32, 32, pattern, unpacking); - if (ptrn) { - /* Convert pattern from GLubytes to GLuints and handle big/little - * endian differences - */ - GLubyte *p = ptrn; - GLint i; - for (i = 0; i < 32; i++) { - dest[i] = (p[0] << 24) - | (p[1] << 16) - | (p[2] << 8) - | (p[3] ); - p += 4; - } - free(ptrn); - } -} - - -/* - * Pack polygon stipple into user memory given current pixel packing - * settings. - */ -void -_mesa_pack_polygon_stipple( const GLuint pattern[32], GLubyte *dest, - const struct gl_pixelstore_attrib *packing ) -{ - /* Convert pattern from GLuints to GLubytes to handle big/little - * endian differences. - */ - GLubyte ptrn[32*4]; - GLint i; - for (i = 0; i < 32; i++) { - ptrn[i * 4 + 0] = (GLubyte) ((pattern[i] >> 24) & 0xff); - ptrn[i * 4 + 1] = (GLubyte) ((pattern[i] >> 16) & 0xff); - ptrn[i * 4 + 2] = (GLubyte) ((pattern[i] >> 8 ) & 0xff); - ptrn[i * 4 + 3] = (GLubyte) ((pattern[i] ) & 0xff); - } - - _mesa_pack_bitmap(32, 32, ptrn, dest, packing); -} - - -/* - * Unpack bitmap data. Resulting data will be in most-significant-bit-first - * order with row alignment = 1 byte. - */ -GLvoid * -_mesa_unpack_bitmap( GLint width, GLint height, const GLubyte *pixels, - const struct gl_pixelstore_attrib *packing ) -{ - GLint bytes, row, width_in_bytes; - GLubyte *buffer, *dst; - - if (!pixels) - return NULL; - - /* Alloc dest storage */ - bytes = ((width + 7) / 8 * height); - buffer = (GLubyte *) malloc( bytes ); - if (!buffer) - return NULL; - - width_in_bytes = CEILING( width, 8 ); - dst = buffer; - for (row = 0; row < height; row++) { - const GLubyte *src = (const GLubyte *) - _mesa_image_address2d(packing, pixels, width, height, - GL_COLOR_INDEX, GL_BITMAP, row, 0); - if (!src) { - free(buffer); - return NULL; - } - - if ((packing->SkipPixels & 7) == 0) { - memcpy( dst, src, width_in_bytes ); - if (packing->LsbFirst) { - flip_bytes( dst, width_in_bytes ); - } - } - else { - /* handling SkipPixels is a bit tricky (no pun intended!) */ - GLint i; - if (packing->LsbFirst) { - GLubyte srcMask = 1 << (packing->SkipPixels & 0x7); - GLubyte dstMask = 128; - const GLubyte *s = src; - GLubyte *d = dst; - *d = 0; - for (i = 0; i < width; i++) { - if (*s & srcMask) { - *d |= dstMask; - } - if (srcMask == 128) { - srcMask = 1; - s++; - } - else { - srcMask = srcMask << 1; - } - if (dstMask == 1) { - dstMask = 128; - d++; - *d = 0; - } - else { - dstMask = dstMask >> 1; - } - } - } - else { - GLubyte srcMask = 128 >> (packing->SkipPixels & 0x7); - GLubyte dstMask = 128; - const GLubyte *s = src; - GLubyte *d = dst; - *d = 0; - for (i = 0; i < width; i++) { - if (*s & srcMask) { - *d |= dstMask; - } - if (srcMask == 1) { - srcMask = 128; - s++; - } - else { - srcMask = srcMask >> 1; - } - if (dstMask == 1) { - dstMask = 128; - d++; - *d = 0; - } - else { - dstMask = dstMask >> 1; - } - } - } - } - dst += width_in_bytes; - } - - return buffer; -} - - -/* - * Pack bitmap data. - */ -void -_mesa_pack_bitmap( GLint width, GLint height, const GLubyte *source, - GLubyte *dest, const struct gl_pixelstore_attrib *packing ) -{ - GLint row, width_in_bytes; - const GLubyte *src; - - if (!source) - return; - - width_in_bytes = CEILING( width, 8 ); - src = source; - for (row = 0; row < height; row++) { - GLubyte *dst = (GLubyte *) _mesa_image_address2d(packing, dest, - width, height, GL_COLOR_INDEX, GL_BITMAP, row, 0); - if (!dst) - return; - - if ((packing->SkipPixels & 7) == 0) { - memcpy( dst, src, width_in_bytes ); - if (packing->LsbFirst) { - flip_bytes( dst, width_in_bytes ); - } - } - else { - /* handling SkipPixels is a bit tricky (no pun intended!) */ - GLint i; - if (packing->LsbFirst) { - GLubyte srcMask = 128; - GLubyte dstMask = 1 << (packing->SkipPixels & 0x7); - const GLubyte *s = src; - GLubyte *d = dst; - *d = 0; - for (i = 0; i < width; i++) { - if (*s & srcMask) { - *d |= dstMask; - } - if (srcMask == 1) { - srcMask = 128; - s++; - } - else { - srcMask = srcMask >> 1; - } - if (dstMask == 128) { - dstMask = 1; - d++; - *d = 0; - } - else { - dstMask = dstMask << 1; - } - } - } - else { - GLubyte srcMask = 128; - GLubyte dstMask = 128 >> (packing->SkipPixels & 0x7); - const GLubyte *s = src; - GLubyte *d = dst; - *d = 0; - for (i = 0; i < width; i++) { - if (*s & srcMask) { - *d |= dstMask; - } - if (srcMask == 1) { - srcMask = 128; - s++; - } - else { - srcMask = srcMask >> 1; - } - if (dstMask == 1) { - dstMask = 128; - d++; - *d = 0; - } - else { - dstMask = dstMask >> 1; - } - } - } - } - src += width_in_bytes; - } -} - - -/** - * Get indexes of color components for a basic color format, such as - * GL_RGBA, GL_RED, GL_LUMINANCE_ALPHA, etc. Return -1 for indexes - * that do not apply. - */ -static void -get_component_indexes(GLenum format, - GLint *redIndex, - GLint *greenIndex, - GLint *blueIndex, - GLint *alphaIndex, - GLint *luminanceIndex, - GLint *intensityIndex) -{ - *redIndex = -1; - *greenIndex = -1; - *blueIndex = -1; - *alphaIndex = -1; - *luminanceIndex = -1; - *intensityIndex = -1; - - switch (format) { - case GL_LUMINANCE: - case GL_LUMINANCE_INTEGER_EXT: - *luminanceIndex = 0; - break; - case GL_LUMINANCE_ALPHA: - case GL_LUMINANCE_ALPHA_INTEGER_EXT: - *luminanceIndex = 0; - *alphaIndex = 1; - break; - case GL_INTENSITY: - *intensityIndex = 0; - break; - case GL_RED: - case GL_RED_INTEGER_EXT: - *redIndex = 0; - break; - case GL_GREEN: - case GL_GREEN_INTEGER_EXT: - *greenIndex = 0; - break; - case GL_BLUE: - case GL_BLUE_INTEGER_EXT: - *blueIndex = 0; - break; - case GL_ALPHA: - case GL_ALPHA_INTEGER_EXT: - *alphaIndex = 0; - break; - case GL_RG: - case GL_RG_INTEGER: - *redIndex = 0; - *greenIndex = 1; - break; - case GL_RGB: - case GL_RGB_INTEGER_EXT: - *redIndex = 0; - *greenIndex = 1; - *blueIndex = 2; - break; - case GL_BGR: - case GL_BGR_INTEGER_EXT: - *blueIndex = 0; - *greenIndex = 1; - *redIndex = 2; - break; - case GL_RGBA: - case GL_RGBA_INTEGER_EXT: - *redIndex = 0; - *greenIndex = 1; - *blueIndex = 2; - *alphaIndex = 3; - break; - case GL_BGRA: - case GL_BGRA_INTEGER: - *redIndex = 2; - *greenIndex = 1; - *blueIndex = 0; - *alphaIndex = 3; - break; - case GL_ABGR_EXT: - *redIndex = 3; - *greenIndex = 2; - *blueIndex = 1; - *alphaIndex = 0; - break; - default: - assert(0 && "bad format in get_component_indexes()"); - } -} - - - -/** - * For small integer types, return the min and max possible values. - * Used for clamping floats to unscaled integer types. - * \return GL_TRUE if type is handled, GL_FALSE otherwise. - */ -static GLboolean -get_type_min_max(GLenum type, GLfloat *min, GLfloat *max) -{ - switch (type) { - case GL_BYTE: - *min = -128.0; - *max = 127.0; - return GL_TRUE; - case GL_UNSIGNED_BYTE: - *min = 0.0; - *max = 255.0; - return GL_TRUE; - case GL_SHORT: - *min = -32768.0; - *max = 32767.0; - return GL_TRUE; - case GL_UNSIGNED_SHORT: - *min = 0.0; - *max = 65535.0; - return GL_TRUE; - default: - return GL_FALSE; - } -} - -/* Customization of integer packing. We always treat src as uint, and can pack dst - * as any integer type/format combo. - */ -#define SRC_TYPE GLuint - -#define DST_TYPE GLuint -#define SRC_CONVERT(x) (x) -#define FN_NAME pack_uint_from_uint_rgba -#include "pack_tmp.h" -#undef DST_TYPE -#undef SRC_CONVERT -#undef FN_NAME - -#define DST_TYPE GLushort -#define SRC_CONVERT(x) MIN2(x, 0xffff) -#define FN_NAME pack_ushort_from_uint_rgba -#include "pack_tmp.h" -#undef DST_TYPE -#undef SRC_CONVERT -#undef FN_NAME - -#define DST_TYPE GLshort -#define SRC_CONVERT(x) CLAMP((int)x, -32768, 32767) -#define FN_NAME pack_short_from_uint_rgba -#include "pack_tmp.h" -#undef DST_TYPE -#undef SRC_CONVERT -#undef FN_NAME - -#define DST_TYPE GLubyte -#define SRC_CONVERT(x) MIN2(x, 0xff) -#define FN_NAME pack_ubyte_from_uint_rgba -#include "pack_tmp.h" -#undef DST_TYPE -#undef SRC_CONVERT -#undef FN_NAME - -#define DST_TYPE GLbyte -#define SRC_CONVERT(x) CLAMP((int)x, -128, 127) -#define FN_NAME pack_byte_from_uint_rgba -#include "pack_tmp.h" -#undef DST_TYPE -#undef SRC_CONVERT -#undef FN_NAME - -void -_mesa_pack_rgba_span_int(struct gl_context *ctx, GLuint n, GLuint rgba[][4], - GLenum dstFormat, GLenum dstType, - GLvoid *dstAddr) -{ - switch(dstType) { - case GL_UNSIGNED_INT: - pack_uint_from_uint_rgba(dstAddr, dstFormat, rgba, n); - break; - case GL_INT: - /* No conversion necessary. */ - pack_uint_from_uint_rgba(dstAddr, dstFormat, rgba, n); - break; - case GL_UNSIGNED_SHORT: - pack_ushort_from_uint_rgba(dstAddr, dstFormat, rgba, n); - break; - case GL_SHORT: - pack_short_from_uint_rgba(dstAddr, dstFormat, rgba, n); - break; - case GL_UNSIGNED_BYTE: - pack_ubyte_from_uint_rgba(dstAddr, dstFormat, rgba, n); - break; - case GL_BYTE: - pack_byte_from_uint_rgba(dstAddr, dstFormat, rgba, n); - break; - default: - assert(0); - return; - } -} - - -/** - * Used to pack an array [][4] of RGBA float colors as specified - * by the dstFormat, dstType and dstPacking. Used by glReadPixels. - * Historically, the RGBA values were in [0,1] and rescaled to fit - * into GLubytes, etc. But with new integer formats, the RGBA values - * may have any value and we don't always rescale when converting to - * integers. - * - * Note: the rgba values will be modified by this function when any pixel - * transfer ops are enabled. - */ -void -_mesa_pack_rgba_span_float(struct gl_context *ctx, GLuint n, GLfloat rgba[][4], - GLenum dstFormat, GLenum dstType, - GLvoid *dstAddr, - const struct gl_pixelstore_attrib *dstPacking, - GLbitfield transferOps) -{ - GLfloat *luminance; - const GLint comps = _mesa_components_in_format(dstFormat); - const GLboolean intDstFormat = _mesa_is_integer_format(dstFormat); - GLuint i; - - if (dstFormat == GL_LUMINANCE || - dstFormat == GL_LUMINANCE_ALPHA || - dstFormat == GL_LUMINANCE_INTEGER_EXT || - dstFormat == GL_LUMINANCE_ALPHA_INTEGER_EXT) { - luminance = (GLfloat *) malloc(n * sizeof(GLfloat)); - if (!luminance) { - _mesa_error(ctx, GL_OUT_OF_MEMORY, "pixel packing"); - return; - } - } - else { - luminance = NULL; - } - - /* EXT_texture_integer specifies no transfer ops on integer - * types in the resolved issues section. Just set them to 0 - * for integer surfaces. - */ - if (intDstFormat) - transferOps = 0; - - if (transferOps) { - _mesa_apply_rgba_transfer_ops(ctx, transferOps, n, rgba); - } - - /* - * Component clamping (besides clamping to [0,1] in - * _mesa_apply_rgba_transfer_ops()). - */ - if (intDstFormat) { - /* clamping to dest type's min/max values */ - GLfloat min, max; - if (get_type_min_max(dstType, &min, &max)) { - for (i = 0; i < n; i++) { - rgba[i][RCOMP] = CLAMP(rgba[i][RCOMP], min, max); - rgba[i][GCOMP] = CLAMP(rgba[i][GCOMP], min, max); - rgba[i][BCOMP] = CLAMP(rgba[i][BCOMP], min, max); - rgba[i][ACOMP] = CLAMP(rgba[i][ACOMP], min, max); - } - } - } - else if (dstFormat == GL_LUMINANCE || dstFormat == GL_LUMINANCE_ALPHA) { - /* compute luminance values */ - if (transferOps & IMAGE_CLAMP_BIT) { - for (i = 0; i < n; i++) { - GLfloat sum = rgba[i][RCOMP] + rgba[i][GCOMP] + rgba[i][BCOMP]; - luminance[i] = CLAMP(sum, 0.0F, 1.0F); - } - } - else { - for (i = 0; i < n; i++) { - luminance[i] = rgba[i][RCOMP] + rgba[i][GCOMP] + rgba[i][BCOMP]; - } - } - } - - /* - * Pack/store the pixels. Ugh! Lots of cases!!! - */ - switch (dstType) { - case GL_UNSIGNED_BYTE: - { - GLubyte *dst = (GLubyte *) dstAddr; - switch (dstFormat) { - case GL_RED: - for (i=0;iSwapBytes) { - GLint swapSize = _mesa_sizeof_packed_type(dstType); - if (swapSize == 2) { - if (dstPacking->SwapBytes) { - _mesa_swap2((GLushort *) dstAddr, n * comps); - } - } - else if (swapSize == 4) { - if (dstPacking->SwapBytes) { - _mesa_swap4((GLuint *) dstAddr, n * comps); - } - } - } - - free(luminance); -} - - - -#define SWAP2BYTE(VALUE) \ - { \ - GLubyte *bytes = (GLubyte *) &(VALUE); \ - GLubyte tmp = bytes[0]; \ - bytes[0] = bytes[1]; \ - bytes[1] = tmp; \ - } - -#define SWAP4BYTE(VALUE) \ - { \ - GLubyte *bytes = (GLubyte *) &(VALUE); \ - GLubyte tmp = bytes[0]; \ - bytes[0] = bytes[3]; \ - bytes[3] = tmp; \ - tmp = bytes[1]; \ - bytes[1] = bytes[2]; \ - bytes[2] = tmp; \ - } - - -static void -extract_uint_indexes(GLuint n, GLuint indexes[], - GLenum srcFormat, GLenum srcType, const GLvoid *src, - const struct gl_pixelstore_attrib *unpack ) -{ - ASSERT(srcFormat == GL_COLOR_INDEX || srcFormat == GL_STENCIL_INDEX); - - ASSERT(srcType == GL_BITMAP || - srcType == GL_UNSIGNED_BYTE || - srcType == GL_BYTE || - srcType == GL_UNSIGNED_SHORT || - srcType == GL_SHORT || - srcType == GL_UNSIGNED_INT || - srcType == GL_INT || - srcType == GL_HALF_FLOAT_ARB || - srcType == GL_FLOAT); - - switch (srcType) { - case GL_BITMAP: - { - GLubyte *ubsrc = (GLubyte *) src; - if (unpack->LsbFirst) { - GLubyte mask = 1 << (unpack->SkipPixels & 0x7); - GLuint i; - for (i = 0; i < n; i++) { - indexes[i] = (*ubsrc & mask) ? 1 : 0; - if (mask == 128) { - mask = 1; - ubsrc++; - } - else { - mask = mask << 1; - } - } - } - else { - GLubyte mask = 128 >> (unpack->SkipPixels & 0x7); - GLuint i; - for (i = 0; i < n; i++) { - indexes[i] = (*ubsrc & mask) ? 1 : 0; - if (mask == 1) { - mask = 128; - ubsrc++; - } - else { - mask = mask >> 1; - } - } - } - } - break; - case GL_UNSIGNED_BYTE: - { - GLuint i; - const GLubyte *s = (const GLubyte *) src; - for (i = 0; i < n; i++) - indexes[i] = s[i]; - } - break; - case GL_BYTE: - { - GLuint i; - const GLbyte *s = (const GLbyte *) src; - for (i = 0; i < n; i++) - indexes[i] = s[i]; - } - break; - case GL_UNSIGNED_SHORT: - { - GLuint i; - const GLushort *s = (const GLushort *) src; - if (unpack->SwapBytes) { - for (i = 0; i < n; i++) { - GLushort value = s[i]; - SWAP2BYTE(value); - indexes[i] = value; - } - } - else { - for (i = 0; i < n; i++) - indexes[i] = s[i]; - } - } - break; - case GL_SHORT: - { - GLuint i; - const GLshort *s = (const GLshort *) src; - if (unpack->SwapBytes) { - for (i = 0; i < n; i++) { - GLshort value = s[i]; - SWAP2BYTE(value); - indexes[i] = value; - } - } - else { - for (i = 0; i < n; i++) - indexes[i] = s[i]; - } - } - break; - case GL_UNSIGNED_INT: - { - GLuint i; - const GLuint *s = (const GLuint *) src; - if (unpack->SwapBytes) { - for (i = 0; i < n; i++) { - GLuint value = s[i]; - SWAP4BYTE(value); - indexes[i] = value; - } - } - else { - for (i = 0; i < n; i++) - indexes[i] = s[i]; - } - } - break; - case GL_INT: - { - GLuint i; - const GLint *s = (const GLint *) src; - if (unpack->SwapBytes) { - for (i = 0; i < n; i++) { - GLint value = s[i]; - SWAP4BYTE(value); - indexes[i] = value; - } - } - else { - for (i = 0; i < n; i++) - indexes[i] = s[i]; - } - } - break; - case GL_FLOAT: - { - GLuint i; - const GLfloat *s = (const GLfloat *) src; - if (unpack->SwapBytes) { - for (i = 0; i < n; i++) { - GLfloat value = s[i]; - SWAP4BYTE(value); - indexes[i] = (GLuint) value; - } - } - else { - for (i = 0; i < n; i++) - indexes[i] = (GLuint) s[i]; - } - } - break; - - default: - _mesa_problem(NULL, "bad srcType in extract_uint_indexes"); - return; - } -} - - -/** - * Return source/dest RGBA indexes for unpacking pixels. - */ -static void -get_component_mapping(GLenum format, - GLint *rSrc, - GLint *gSrc, - GLint *bSrc, - GLint *aSrc, - GLint *rDst, - GLint *gDst, - GLint *bDst, - GLint *aDst) -{ - switch (format) { - case GL_RED: - case GL_RED_INTEGER_EXT: - *rSrc = 0; - *gSrc = *bSrc = *aSrc = -1; - break; - case GL_GREEN: - case GL_GREEN_INTEGER_EXT: - *gSrc = 0; - *rSrc = *bSrc = *aSrc = -1; - break; - case GL_BLUE: - case GL_BLUE_INTEGER_EXT: - *bSrc = 0; - *rSrc = *gSrc = *aSrc = -1; - break; - case GL_ALPHA: - case GL_ALPHA_INTEGER_EXT: - *rSrc = *gSrc = *bSrc = -1; - *aSrc = 0; - break; - case GL_LUMINANCE: - case GL_LUMINANCE_INTEGER_EXT: - *rSrc = *gSrc = *bSrc = 0; - *aSrc = -1; - break; - case GL_LUMINANCE_ALPHA: - case GL_LUMINANCE_ALPHA_INTEGER_EXT: - *rSrc = *gSrc = *bSrc = 0; - *aSrc = 1; - break; - case GL_INTENSITY: - *rSrc = *gSrc = *bSrc = *aSrc = 0; - break; - case GL_RG: - case GL_RG_INTEGER: - *rSrc = 0; - *gSrc = 1; - *bSrc = -1; - *aSrc = -1; - *rDst = 0; - *gDst = 1; - *bDst = 2; - *aDst = 3; - break; - case GL_RGB: - case GL_RGB_INTEGER: - *rSrc = 0; - *gSrc = 1; - *bSrc = 2; - *aSrc = -1; - *rDst = 0; - *gDst = 1; - *bDst = 2; - *aDst = 3; - break; - case GL_BGR: - case GL_BGR_INTEGER: - *rSrc = 2; - *gSrc = 1; - *bSrc = 0; - *aSrc = -1; - *rDst = 2; - *gDst = 1; - *bDst = 0; - *aDst = 3; - break; - case GL_RGBA: - case GL_RGBA_INTEGER: - *rSrc = 0; - *gSrc = 1; - *bSrc = 2; - *aSrc = 3; - *rDst = 0; - *gDst = 1; - *bDst = 2; - *aDst = 3; - break; - case GL_BGRA: - case GL_BGRA_INTEGER: - *rSrc = 2; - *gSrc = 1; - *bSrc = 0; - *aSrc = 3; - *rDst = 2; - *gDst = 1; - *bDst = 0; - *aDst = 3; - break; - case GL_ABGR_EXT: - *rSrc = 3; - *gSrc = 2; - *bSrc = 1; - *aSrc = 0; - *rDst = 3; - *gDst = 2; - *bDst = 1; - *aDst = 0; - break; - default: - _mesa_problem(NULL, "bad srcFormat %s in get_component_mapping", - _mesa_lookup_enum_by_nr(format)); - return; - } -} - - - -/* - * This function extracts floating point RGBA values from arbitrary - * image data. srcFormat and srcType are the format and type parameters - * passed to glDrawPixels, glTexImage[123]D, glTexSubImage[123]D, etc. - * - * Refering to section 3.6.4 of the OpenGL 1.2 spec, this function - * implements the "Conversion to floating point", "Conversion to RGB", - * and "Final Expansion to RGBA" operations. - * - * Args: n - number of pixels - * rgba - output colors - * srcFormat - format of incoming data - * srcType - data type of incoming data - * src - source data pointer - * swapBytes - perform byteswapping of incoming data? - */ -static void -extract_float_rgba(GLuint n, GLfloat rgba[][4], - GLenum srcFormat, GLenum srcType, const GLvoid *src, - GLboolean swapBytes) -{ - GLint rSrc, gSrc, bSrc, aSrc; - GLint stride; - GLint rDst, bDst, gDst, aDst; - GLboolean intFormat; - GLfloat rs = 1.0f, gs = 1.0f, bs = 1.0f, as = 1.0f; /* scale factors */ - - ASSERT(srcFormat == GL_RED || - srcFormat == GL_GREEN || - srcFormat == GL_BLUE || - srcFormat == GL_ALPHA || - srcFormat == GL_LUMINANCE || - srcFormat == GL_LUMINANCE_ALPHA || - srcFormat == GL_INTENSITY || - srcFormat == GL_RG || - srcFormat == GL_RGB || - srcFormat == GL_BGR || - srcFormat == GL_RGBA || - srcFormat == GL_BGRA || - srcFormat == GL_ABGR_EXT || - srcFormat == GL_RED_INTEGER_EXT || - srcFormat == GL_GREEN_INTEGER_EXT || - srcFormat == GL_BLUE_INTEGER_EXT || - srcFormat == GL_ALPHA_INTEGER_EXT || - srcFormat == GL_RG_INTEGER || - srcFormat == GL_RGB_INTEGER_EXT || - srcFormat == GL_RGBA_INTEGER_EXT || - srcFormat == GL_BGR_INTEGER_EXT || - srcFormat == GL_BGRA_INTEGER_EXT || - srcFormat == GL_LUMINANCE_INTEGER_EXT || - srcFormat == GL_LUMINANCE_ALPHA_INTEGER_EXT); - - ASSERT(srcType == GL_UNSIGNED_BYTE || - srcType == GL_BYTE || - srcType == GL_UNSIGNED_SHORT || - srcType == GL_SHORT || - srcType == GL_UNSIGNED_INT || - srcType == GL_INT || - srcType == GL_HALF_FLOAT_ARB || - srcType == GL_FLOAT || - srcType == GL_UNSIGNED_BYTE_3_3_2 || - srcType == GL_UNSIGNED_BYTE_2_3_3_REV || - srcType == GL_UNSIGNED_SHORT_5_6_5 || - srcType == GL_UNSIGNED_SHORT_5_6_5_REV || - srcType == GL_UNSIGNED_SHORT_4_4_4_4 || - srcType == GL_UNSIGNED_SHORT_4_4_4_4_REV || - srcType == GL_UNSIGNED_SHORT_5_5_5_1 || - srcType == GL_UNSIGNED_SHORT_1_5_5_5_REV || - srcType == GL_UNSIGNED_INT_8_8_8_8 || - srcType == GL_UNSIGNED_INT_8_8_8_8_REV || - srcType == GL_UNSIGNED_INT_5_9_9_9_REV || - srcType == GL_UNSIGNED_INT_10F_11F_11F_REV); - - get_component_mapping(srcFormat, - &rSrc, &gSrc, &bSrc, &aSrc, - &rDst, &gDst, &bDst, &aDst); - - stride = _mesa_components_in_format(srcFormat); - - intFormat = _mesa_is_integer_format(srcFormat); - -#define PROCESS(SRC_INDEX, DST_INDEX, DEFAULT_FLT, DEFAULT_INT, TYPE, CONVERSION) \ - if ((SRC_INDEX) < 0) { \ - GLuint i; \ - if (intFormat) { \ - for (i = 0; i < n; i++) { \ - rgba[i][DST_INDEX] = DEFAULT_INT; \ - } \ - } \ - else { \ - for (i = 0; i < n; i++) { \ - rgba[i][DST_INDEX] = DEFAULT_FLT; \ - } \ - } \ - } \ - else if (swapBytes) { \ - const TYPE *s = (const TYPE *) src; \ - GLuint i; \ - for (i = 0; i < n; i++) { \ - TYPE value = s[SRC_INDEX]; \ - if (sizeof(TYPE) == 2) { \ - SWAP2BYTE(value); \ - } \ - else if (sizeof(TYPE) == 4) { \ - SWAP4BYTE(value); \ - } \ - if (intFormat) \ - rgba[i][DST_INDEX] = (GLfloat) value; \ - else \ - rgba[i][DST_INDEX] = (GLfloat) CONVERSION(value); \ - s += stride; \ - } \ - } \ - else { \ - const TYPE *s = (const TYPE *) src; \ - GLuint i; \ - if (intFormat) { \ - for (i = 0; i < n; i++) { \ - rgba[i][DST_INDEX] = (GLfloat) s[SRC_INDEX]; \ - s += stride; \ - } \ - } \ - else { \ - for (i = 0; i < n; i++) { \ - rgba[i][DST_INDEX] = (GLfloat) CONVERSION(s[SRC_INDEX]); \ - s += stride; \ - } \ - } \ - } - - switch (srcType) { - case GL_UNSIGNED_BYTE: - PROCESS(rSrc, RCOMP, 0.0F, 0, GLubyte, UBYTE_TO_FLOAT); - PROCESS(gSrc, GCOMP, 0.0F, 0, GLubyte, UBYTE_TO_FLOAT); - PROCESS(bSrc, BCOMP, 0.0F, 0, GLubyte, UBYTE_TO_FLOAT); - PROCESS(aSrc, ACOMP, 1.0F, 255, GLubyte, UBYTE_TO_FLOAT); - break; - case GL_BYTE: - PROCESS(rSrc, RCOMP, 0.0F, 0, GLbyte, BYTE_TO_FLOATZ); - PROCESS(gSrc, GCOMP, 0.0F, 0, GLbyte, BYTE_TO_FLOATZ); - PROCESS(bSrc, BCOMP, 0.0F, 0, GLbyte, BYTE_TO_FLOATZ); - PROCESS(aSrc, ACOMP, 1.0F, 127, GLbyte, BYTE_TO_FLOATZ); - break; - case GL_UNSIGNED_SHORT: - PROCESS(rSrc, RCOMP, 0.0F, 0, GLushort, USHORT_TO_FLOAT); - PROCESS(gSrc, GCOMP, 0.0F, 0, GLushort, USHORT_TO_FLOAT); - PROCESS(bSrc, BCOMP, 0.0F, 0, GLushort, USHORT_TO_FLOAT); - PROCESS(aSrc, ACOMP, 1.0F, 0xffff, GLushort, USHORT_TO_FLOAT); - break; - case GL_SHORT: - PROCESS(rSrc, RCOMP, 0.0F, 0, GLshort, SHORT_TO_FLOATZ); - PROCESS(gSrc, GCOMP, 0.0F, 0, GLshort, SHORT_TO_FLOATZ); - PROCESS(bSrc, BCOMP, 0.0F, 0, GLshort, SHORT_TO_FLOATZ); - PROCESS(aSrc, ACOMP, 1.0F, 32767, GLshort, SHORT_TO_FLOATZ); - break; - case GL_UNSIGNED_INT: - PROCESS(rSrc, RCOMP, 0.0F, 0, GLuint, UINT_TO_FLOAT); - PROCESS(gSrc, GCOMP, 0.0F, 0, GLuint, UINT_TO_FLOAT); - PROCESS(bSrc, BCOMP, 0.0F, 0, GLuint, UINT_TO_FLOAT); - PROCESS(aSrc, ACOMP, 1.0F, 0xffffffff, GLuint, UINT_TO_FLOAT); - break; - case GL_INT: - PROCESS(rSrc, RCOMP, 0.0F, 0, GLint, INT_TO_FLOAT); - PROCESS(gSrc, GCOMP, 0.0F, 0, GLint, INT_TO_FLOAT); - PROCESS(bSrc, BCOMP, 0.0F, 0, GLint, INT_TO_FLOAT); - PROCESS(aSrc, ACOMP, 1.0F, 2147483647, GLint, INT_TO_FLOAT); - break; - case GL_FLOAT: - PROCESS(rSrc, RCOMP, 0.0F, 0.0F, GLfloat, (GLfloat)); - PROCESS(gSrc, GCOMP, 0.0F, 0.0F, GLfloat, (GLfloat)); - PROCESS(bSrc, BCOMP, 0.0F, 0.0F, GLfloat, (GLfloat)); - PROCESS(aSrc, ACOMP, 1.0F, 1.0F, GLfloat, (GLfloat)); - break; - case GL_UNSIGNED_BYTE_3_3_2: - { - const GLubyte *ubsrc = (const GLubyte *) src; - GLuint i; - if (!intFormat) { - rs = 1.0F / 7.0F; - gs = 1.0F / 7.0F; - bs = 1.0F / 3.0F; - } - for (i = 0; i < n; i ++) { - GLubyte p = ubsrc[i]; - rgba[i][rDst] = ((p >> 5) ) * rs; - rgba[i][gDst] = ((p >> 2) & 0x7) * gs; - rgba[i][bDst] = ((p ) & 0x3) * bs; - rgba[i][aDst] = 1.0F; - } - } - break; - case GL_UNSIGNED_BYTE_2_3_3_REV: - { - const GLubyte *ubsrc = (const GLubyte *) src; - GLuint i; - if (!intFormat) { - rs = 1.0F / 7.0F; - gs = 1.0F / 7.0F; - bs = 1.0F / 3.0F; - } - for (i = 0; i < n; i ++) { - GLubyte p = ubsrc[i]; - rgba[i][rDst] = ((p ) & 0x7) * rs; - rgba[i][gDst] = ((p >> 3) & 0x7) * gs; - rgba[i][bDst] = ((p >> 6) ) * bs; - rgba[i][aDst] = 1.0F; - } - } - break; - case GL_UNSIGNED_SHORT_5_6_5: - if (!intFormat) { - rs = 1.0F / 31.0F; - gs = 1.0F / 63.0F; - bs = 1.0F / 31.0F; - } - if (swapBytes) { - const GLushort *ussrc = (const GLushort *) src; - GLuint i; - for (i = 0; i < n; i ++) { - GLushort p = ussrc[i]; - SWAP2BYTE(p); - rgba[i][rDst] = ((p >> 11) ) * rs; - rgba[i][gDst] = ((p >> 5) & 0x3f) * gs; - rgba[i][bDst] = ((p ) & 0x1f) * bs; - rgba[i][aDst] = 1.0F; - } - } - else { - const GLushort *ussrc = (const GLushort *) src; - GLuint i; - for (i = 0; i < n; i ++) { - GLushort p = ussrc[i]; - rgba[i][rDst] = ((p >> 11) ) * rs; - rgba[i][gDst] = ((p >> 5) & 0x3f) * gs; - rgba[i][bDst] = ((p ) & 0x1f) * bs; - rgba[i][aDst] = 1.0F; - } - } - break; - case GL_UNSIGNED_SHORT_5_6_5_REV: - if (!intFormat) { - rs = 1.0F / 31.0F; - gs = 1.0F / 63.0F; - bs = 1.0F / 31.0F; - } - if (swapBytes) { - const GLushort *ussrc = (const GLushort *) src; - GLuint i; - for (i = 0; i < n; i ++) { - GLushort p = ussrc[i]; - SWAP2BYTE(p); - rgba[i][rDst] = ((p ) & 0x1f) * rs; - rgba[i][gDst] = ((p >> 5) & 0x3f) * gs; - rgba[i][bDst] = ((p >> 11) ) * bs; - rgba[i][aDst] = 1.0F; - } - } - else { - const GLushort *ussrc = (const GLushort *) src; - GLuint i; - for (i = 0; i < n; i ++) { - GLushort p = ussrc[i]; - rgba[i][rDst] = ((p ) & 0x1f) * rs; - rgba[i][gDst] = ((p >> 5) & 0x3f) * gs; - rgba[i][bDst] = ((p >> 11) ) * bs; - rgba[i][aDst] = 1.0F; - } - } - break; - case GL_UNSIGNED_SHORT_4_4_4_4: - if (!intFormat) { - rs = gs = bs = as = 1.0F / 15.0F; - } - if (swapBytes) { - const GLushort *ussrc = (const GLushort *) src; - GLuint i; - for (i = 0; i < n; i ++) { - GLushort p = ussrc[i]; - SWAP2BYTE(p); - rgba[i][rDst] = ((p >> 12) ) * rs; - rgba[i][gDst] = ((p >> 8) & 0xf) * gs; - rgba[i][bDst] = ((p >> 4) & 0xf) * bs; - rgba[i][aDst] = ((p ) & 0xf) * as; - } - } - else { - const GLushort *ussrc = (const GLushort *) src; - GLuint i; - for (i = 0; i < n; i ++) { - GLushort p = ussrc[i]; - rgba[i][rDst] = ((p >> 12) ) * rs; - rgba[i][gDst] = ((p >> 8) & 0xf) * gs; - rgba[i][bDst] = ((p >> 4) & 0xf) * bs; - rgba[i][aDst] = ((p ) & 0xf) * as; - } - } - break; - case GL_UNSIGNED_SHORT_4_4_4_4_REV: - if (!intFormat) { - rs = gs = bs = as = 1.0F / 15.0F; - } - if (swapBytes) { - const GLushort *ussrc = (const GLushort *) src; - GLuint i; - for (i = 0; i < n; i ++) { - GLushort p = ussrc[i]; - SWAP2BYTE(p); - rgba[i][rDst] = ((p ) & 0xf) * rs; - rgba[i][gDst] = ((p >> 4) & 0xf) * gs; - rgba[i][bDst] = ((p >> 8) & 0xf) * bs; - rgba[i][aDst] = ((p >> 12) ) * as; - } - } - else { - const GLushort *ussrc = (const GLushort *) src; - GLuint i; - for (i = 0; i < n; i ++) { - GLushort p = ussrc[i]; - rgba[i][rDst] = ((p ) & 0xf) * rs; - rgba[i][gDst] = ((p >> 4) & 0xf) * gs; - rgba[i][bDst] = ((p >> 8) & 0xf) * bs; - rgba[i][aDst] = ((p >> 12) ) * as; - } - } - break; - case GL_UNSIGNED_SHORT_5_5_5_1: - if (!intFormat) { - rs = gs = bs = 1.0F / 31.0F; - } - if (swapBytes) { - const GLushort *ussrc = (const GLushort *) src; - GLuint i; - for (i = 0; i < n; i ++) { - GLushort p = ussrc[i]; - SWAP2BYTE(p); - rgba[i][rDst] = ((p >> 11) ) * rs; - rgba[i][gDst] = ((p >> 6) & 0x1f) * gs; - rgba[i][bDst] = ((p >> 1) & 0x1f) * bs; - rgba[i][aDst] = ((p ) & 0x1) * as; - } - } - else { - const GLushort *ussrc = (const GLushort *) src; - GLuint i; - for (i = 0; i < n; i ++) { - GLushort p = ussrc[i]; - rgba[i][rDst] = ((p >> 11) ) * rs; - rgba[i][gDst] = ((p >> 6) & 0x1f) * gs; - rgba[i][bDst] = ((p >> 1) & 0x1f) * bs; - rgba[i][aDst] = ((p ) & 0x1) * as; - } - } - break; - case GL_UNSIGNED_SHORT_1_5_5_5_REV: - if (!intFormat) { - rs = gs = bs = 1.0F / 31.0F; - } - if (swapBytes) { - const GLushort *ussrc = (const GLushort *) src; - GLuint i; - for (i = 0; i < n; i ++) { - GLushort p = ussrc[i]; - SWAP2BYTE(p); - rgba[i][rDst] = ((p ) & 0x1f) * rs; - rgba[i][gDst] = ((p >> 5) & 0x1f) * gs; - rgba[i][bDst] = ((p >> 10) & 0x1f) * bs; - rgba[i][aDst] = ((p >> 15) ) * as; - } - } - else { - const GLushort *ussrc = (const GLushort *) src; - GLuint i; - for (i = 0; i < n; i ++) { - GLushort p = ussrc[i]; - rgba[i][rDst] = ((p ) & 0x1f) * rs; - rgba[i][gDst] = ((p >> 5) & 0x1f) * gs; - rgba[i][bDst] = ((p >> 10) & 0x1f) * bs; - rgba[i][aDst] = ((p >> 15) ) * as; - } - } - break; - case GL_UNSIGNED_INT_8_8_8_8: - if (swapBytes) { - const GLuint *uisrc = (const GLuint *) src; - GLuint i; - if (intFormat) { - for (i = 0; i < n; i ++) { - GLuint p = uisrc[i]; - rgba[i][rDst] = (GLfloat) ((p ) & 0xff); - rgba[i][gDst] = (GLfloat) ((p >> 8) & 0xff); - rgba[i][bDst] = (GLfloat) ((p >> 16) & 0xff); - rgba[i][aDst] = (GLfloat) ((p >> 24) ); - } - } - else { - for (i = 0; i < n; i ++) { - GLuint p = uisrc[i]; - rgba[i][rDst] = UBYTE_TO_FLOAT((p ) & 0xff); - rgba[i][gDst] = UBYTE_TO_FLOAT((p >> 8) & 0xff); - rgba[i][bDst] = UBYTE_TO_FLOAT((p >> 16) & 0xff); - rgba[i][aDst] = UBYTE_TO_FLOAT((p >> 24) ); - } - } - } - else { - const GLuint *uisrc = (const GLuint *) src; - GLuint i; - if (intFormat) { - for (i = 0; i < n; i ++) { - GLuint p = uisrc[i]; - rgba[i][rDst] = (GLfloat) ((p >> 24) ); - rgba[i][gDst] = (GLfloat) ((p >> 16) & 0xff); - rgba[i][bDst] = (GLfloat) ((p >> 8) & 0xff); - rgba[i][aDst] = (GLfloat) ((p ) & 0xff); - } - } - else { - for (i = 0; i < n; i ++) { - GLuint p = uisrc[i]; - rgba[i][rDst] = UBYTE_TO_FLOAT((p >> 24) ); - rgba[i][gDst] = UBYTE_TO_FLOAT((p >> 16) & 0xff); - rgba[i][bDst] = UBYTE_TO_FLOAT((p >> 8) & 0xff); - rgba[i][aDst] = UBYTE_TO_FLOAT((p ) & 0xff); - } - } - } - break; - case GL_UNSIGNED_INT_8_8_8_8_REV: - if (swapBytes) { - const GLuint *uisrc = (const GLuint *) src; - GLuint i; - if (intFormat) { - for (i = 0; i < n; i ++) { - GLuint p = uisrc[i]; - rgba[i][rDst] = (GLfloat) ((p >> 24) ); - rgba[i][gDst] = (GLfloat) ((p >> 16) & 0xff); - rgba[i][bDst] = (GLfloat) ((p >> 8) & 0xff); - rgba[i][aDst] = (GLfloat) ((p ) & 0xff); - } - } - else { - for (i = 0; i < n; i ++) { - GLuint p = uisrc[i]; - rgba[i][rDst] = UBYTE_TO_FLOAT((p >> 24) ); - rgba[i][gDst] = UBYTE_TO_FLOAT((p >> 16) & 0xff); - rgba[i][bDst] = UBYTE_TO_FLOAT((p >> 8) & 0xff); - rgba[i][aDst] = UBYTE_TO_FLOAT((p ) & 0xff); - } - } - } - else { - const GLuint *uisrc = (const GLuint *) src; - GLuint i; - if (intFormat) { - for (i = 0; i < n; i ++) { - GLuint p = uisrc[i]; - rgba[i][rDst] = (GLfloat) ((p ) & 0xff); - rgba[i][gDst] = (GLfloat) ((p >> 8) & 0xff); - rgba[i][bDst] = (GLfloat) ((p >> 16) & 0xff); - rgba[i][aDst] = (GLfloat) ((p >> 24) ); - } - } - else { - for (i = 0; i < n; i ++) { - GLuint p = uisrc[i]; - rgba[i][rDst] = UBYTE_TO_FLOAT((p ) & 0xff); - rgba[i][gDst] = UBYTE_TO_FLOAT((p >> 8) & 0xff); - rgba[i][bDst] = UBYTE_TO_FLOAT((p >> 16) & 0xff); - rgba[i][aDst] = UBYTE_TO_FLOAT((p >> 24) ); - } - } - } - break; - default: - _mesa_problem(NULL, "bad srcType in extract float data"); - break; - } -#undef PROCESS -} - - -static inline GLuint -clamp_float_to_uint(GLfloat f) -{ - return f < 0.0F ? 0 : IROUND(f); -} - -/** - * \sa extract_float_rgba() - */ -static void -extract_uint_rgba(GLuint n, GLuint rgba[][4], - GLenum srcFormat, GLenum srcType, const GLvoid *src, - GLboolean swapBytes) -{ - GLint rSrc, gSrc, bSrc, aSrc; - GLint stride; - GLint rDst, bDst, gDst, aDst; - - ASSERT(srcFormat == GL_RED || - srcFormat == GL_GREEN || - srcFormat == GL_BLUE || - srcFormat == GL_ALPHA || - srcFormat == GL_LUMINANCE || - srcFormat == GL_LUMINANCE_ALPHA || - srcFormat == GL_INTENSITY || - srcFormat == GL_RG || - srcFormat == GL_RGB || - srcFormat == GL_BGR || - srcFormat == GL_RGBA || - srcFormat == GL_BGRA || - srcFormat == GL_ABGR_EXT || - srcFormat == GL_RED_INTEGER_EXT || - srcFormat == GL_RG_INTEGER || - srcFormat == GL_GREEN_INTEGER_EXT || - srcFormat == GL_BLUE_INTEGER_EXT || - srcFormat == GL_ALPHA_INTEGER_EXT || - srcFormat == GL_RGB_INTEGER_EXT || - srcFormat == GL_RGBA_INTEGER_EXT || - srcFormat == GL_BGR_INTEGER_EXT || - srcFormat == GL_BGRA_INTEGER_EXT || - srcFormat == GL_LUMINANCE_INTEGER_EXT || - srcFormat == GL_LUMINANCE_ALPHA_INTEGER_EXT); - - ASSERT(srcType == GL_UNSIGNED_BYTE || - srcType == GL_BYTE || - srcType == GL_UNSIGNED_SHORT || - srcType == GL_SHORT || - srcType == GL_UNSIGNED_INT || - srcType == GL_INT || - srcType == GL_HALF_FLOAT_ARB || - srcType == GL_FLOAT || - srcType == GL_UNSIGNED_BYTE_3_3_2 || - srcType == GL_UNSIGNED_BYTE_2_3_3_REV || - srcType == GL_UNSIGNED_SHORT_5_6_5 || - srcType == GL_UNSIGNED_SHORT_5_6_5_REV || - srcType == GL_UNSIGNED_SHORT_4_4_4_4 || - srcType == GL_UNSIGNED_SHORT_4_4_4_4_REV || - srcType == GL_UNSIGNED_SHORT_5_5_5_1 || - srcType == GL_UNSIGNED_SHORT_1_5_5_5_REV || - srcType == GL_UNSIGNED_INT_8_8_8_8 || - srcType == GL_UNSIGNED_INT_8_8_8_8_REV || - srcType == GL_UNSIGNED_INT_5_9_9_9_REV || - srcType == GL_UNSIGNED_INT_10F_11F_11F_REV); - - get_component_mapping(srcFormat, - &rSrc, &gSrc, &bSrc, &aSrc, - &rDst, &gDst, &bDst, &aDst); - - stride = _mesa_components_in_format(srcFormat); - -#define PROCESS(SRC_INDEX, DST_INDEX, DEFAULT, TYPE, CONVERSION) \ - if ((SRC_INDEX) < 0) { \ - GLuint i; \ - for (i = 0; i < n; i++) { \ - rgba[i][DST_INDEX] = DEFAULT; \ - } \ - } \ - else if (swapBytes) { \ - const TYPE *s = (const TYPE *) src; \ - GLuint i; \ - for (i = 0; i < n; i++) { \ - TYPE value = s[SRC_INDEX]; \ - if (sizeof(TYPE) == 2) { \ - SWAP2BYTE(value); \ - } \ - else if (sizeof(TYPE) == 4) { \ - SWAP4BYTE(value); \ - } \ - rgba[i][DST_INDEX] = CONVERSION(value); \ - s += stride; \ - } \ - } \ - else { \ - const TYPE *s = (const TYPE *) src; \ - GLuint i; \ - for (i = 0; i < n; i++) { \ - rgba[i][DST_INDEX] = CONVERSION(s[SRC_INDEX]); \ - s += stride; \ - } \ - } - - switch (srcType) { - case GL_UNSIGNED_BYTE: - PROCESS(rSrc, RCOMP, 0, GLubyte, (GLuint)); - PROCESS(gSrc, GCOMP, 0, GLubyte, (GLuint)); - PROCESS(bSrc, BCOMP, 0, GLubyte, (GLuint)); - PROCESS(aSrc, ACOMP, 1, GLubyte, (GLuint)); - break; - case GL_BYTE: - PROCESS(rSrc, RCOMP, 0, GLbyte, (GLuint)); - PROCESS(gSrc, GCOMP, 0, GLbyte, (GLuint)); - PROCESS(bSrc, BCOMP, 0, GLbyte, (GLuint)); - PROCESS(aSrc, ACOMP, 1, GLbyte, (GLuint)); - break; - case GL_UNSIGNED_SHORT: - PROCESS(rSrc, RCOMP, 0, GLushort, (GLuint)); - PROCESS(gSrc, GCOMP, 0, GLushort, (GLuint)); - PROCESS(bSrc, BCOMP, 0, GLushort, (GLuint)); - PROCESS(aSrc, ACOMP, 1, GLushort, (GLuint)); - break; - case GL_SHORT: - PROCESS(rSrc, RCOMP, 0, GLshort, (GLuint)); - PROCESS(gSrc, GCOMP, 0, GLshort, (GLuint)); - PROCESS(bSrc, BCOMP, 0, GLshort, (GLuint)); - PROCESS(aSrc, ACOMP, 1, GLshort, (GLuint)); - break; - case GL_UNSIGNED_INT: - PROCESS(rSrc, RCOMP, 0, GLuint, (GLuint)); - PROCESS(gSrc, GCOMP, 0, GLuint, (GLuint)); - PROCESS(bSrc, BCOMP, 0, GLuint, (GLuint)); - PROCESS(aSrc, ACOMP, 1, GLuint, (GLuint)); - break; - case GL_INT: - PROCESS(rSrc, RCOMP, 0, GLint, (GLuint)); - PROCESS(gSrc, GCOMP, 0, GLint, (GLuint)); - PROCESS(bSrc, BCOMP, 0, GLint, (GLuint)); - PROCESS(aSrc, ACOMP, 1, GLint, (GLuint)); - break; - case GL_FLOAT: - PROCESS(rSrc, RCOMP, 0, GLfloat, clamp_float_to_uint); - PROCESS(gSrc, GCOMP, 0, GLfloat, clamp_float_to_uint); - PROCESS(bSrc, BCOMP, 0, GLfloat, clamp_float_to_uint); - PROCESS(aSrc, ACOMP, 1, GLfloat, clamp_float_to_uint); - break; - case GL_UNSIGNED_BYTE_3_3_2: - { - const GLubyte *ubsrc = (const GLubyte *) src; - GLuint i; - for (i = 0; i < n; i ++) { - GLubyte p = ubsrc[i]; - rgba[i][rDst] = ((p >> 5) ); - rgba[i][gDst] = ((p >> 2) & 0x7); - rgba[i][bDst] = ((p ) & 0x3); - rgba[i][aDst] = 1; - } - } - break; - case GL_UNSIGNED_BYTE_2_3_3_REV: - { - const GLubyte *ubsrc = (const GLubyte *) src; - GLuint i; - for (i = 0; i < n; i ++) { - GLubyte p = ubsrc[i]; - rgba[i][rDst] = ((p ) & 0x7); - rgba[i][gDst] = ((p >> 3) & 0x7); - rgba[i][bDst] = ((p >> 6) ); - rgba[i][aDst] = 1; - } - } - break; - case GL_UNSIGNED_SHORT_5_6_5: - if (swapBytes) { - const GLushort *ussrc = (const GLushort *) src; - GLuint i; - for (i = 0; i < n; i ++) { - GLushort p = ussrc[i]; - SWAP2BYTE(p); - rgba[i][rDst] = ((p >> 11) ); - rgba[i][gDst] = ((p >> 5) & 0x3f); - rgba[i][bDst] = ((p ) & 0x1f); - rgba[i][aDst] = 1; - } - } - else { - const GLushort *ussrc = (const GLushort *) src; - GLuint i; - for (i = 0; i < n; i ++) { - GLushort p = ussrc[i]; - rgba[i][rDst] = ((p >> 11) ); - rgba[i][gDst] = ((p >> 5) & 0x3f); - rgba[i][bDst] = ((p ) & 0x1f); - rgba[i][aDst] = 1; - } - } - break; - case GL_UNSIGNED_SHORT_5_6_5_REV: - if (swapBytes) { - const GLushort *ussrc = (const GLushort *) src; - GLuint i; - for (i = 0; i < n; i ++) { - GLushort p = ussrc[i]; - SWAP2BYTE(p); - rgba[i][rDst] = ((p ) & 0x1f); - rgba[i][gDst] = ((p >> 5) & 0x3f); - rgba[i][bDst] = ((p >> 11) ); - rgba[i][aDst] = 1; - } - } - else { - const GLushort *ussrc = (const GLushort *) src; - GLuint i; - for (i = 0; i < n; i ++) { - GLushort p = ussrc[i]; - rgba[i][rDst] = ((p ) & 0x1f); - rgba[i][gDst] = ((p >> 5) & 0x3f); - rgba[i][bDst] = ((p >> 11) ); - rgba[i][aDst] = 1; - } - } - break; - case GL_UNSIGNED_SHORT_4_4_4_4: - if (swapBytes) { - const GLushort *ussrc = (const GLushort *) src; - GLuint i; - for (i = 0; i < n; i ++) { - GLushort p = ussrc[i]; - SWAP2BYTE(p); - rgba[i][rDst] = ((p >> 12) ); - rgba[i][gDst] = ((p >> 8) & 0xf); - rgba[i][bDst] = ((p >> 4) & 0xf); - rgba[i][aDst] = ((p ) & 0xf); - } - } - else { - const GLushort *ussrc = (const GLushort *) src; - GLuint i; - for (i = 0; i < n; i ++) { - GLushort p = ussrc[i]; - rgba[i][rDst] = ((p >> 12) ); - rgba[i][gDst] = ((p >> 8) & 0xf); - rgba[i][bDst] = ((p >> 4) & 0xf); - rgba[i][aDst] = ((p ) & 0xf); - } - } - break; - case GL_UNSIGNED_SHORT_4_4_4_4_REV: - if (swapBytes) { - const GLushort *ussrc = (const GLushort *) src; - GLuint i; - for (i = 0; i < n; i ++) { - GLushort p = ussrc[i]; - SWAP2BYTE(p); - rgba[i][rDst] = ((p ) & 0xf); - rgba[i][gDst] = ((p >> 4) & 0xf); - rgba[i][bDst] = ((p >> 8) & 0xf); - rgba[i][aDst] = ((p >> 12) ); - } - } - else { - const GLushort *ussrc = (const GLushort *) src; - GLuint i; - for (i = 0; i < n; i ++) { - GLushort p = ussrc[i]; - rgba[i][rDst] = ((p ) & 0xf); - rgba[i][gDst] = ((p >> 4) & 0xf); - rgba[i][bDst] = ((p >> 8) & 0xf); - rgba[i][aDst] = ((p >> 12) ); - } - } - break; - case GL_UNSIGNED_SHORT_5_5_5_1: - if (swapBytes) { - const GLushort *ussrc = (const GLushort *) src; - GLuint i; - for (i = 0; i < n; i ++) { - GLushort p = ussrc[i]; - SWAP2BYTE(p); - rgba[i][rDst] = ((p >> 11) ); - rgba[i][gDst] = ((p >> 6) & 0x1f); - rgba[i][bDst] = ((p >> 1) & 0x1f); - rgba[i][aDst] = ((p ) & 0x1 ); - } - } - else { - const GLushort *ussrc = (const GLushort *) src; - GLuint i; - for (i = 0; i < n; i ++) { - GLushort p = ussrc[i]; - rgba[i][rDst] = ((p >> 11) ); - rgba[i][gDst] = ((p >> 6) & 0x1f); - rgba[i][bDst] = ((p >> 1) & 0x1f); - rgba[i][aDst] = ((p ) & 0x1 ); - } - } - break; - case GL_UNSIGNED_SHORT_1_5_5_5_REV: - if (swapBytes) { - const GLushort *ussrc = (const GLushort *) src; - GLuint i; - for (i = 0; i < n; i ++) { - GLushort p = ussrc[i]; - SWAP2BYTE(p); - rgba[i][rDst] = ((p ) & 0x1f); - rgba[i][gDst] = ((p >> 5) & 0x1f); - rgba[i][bDst] = ((p >> 10) & 0x1f); - rgba[i][aDst] = ((p >> 15) ); - } - } - else { - const GLushort *ussrc = (const GLushort *) src; - GLuint i; - for (i = 0; i < n; i ++) { - GLushort p = ussrc[i]; - rgba[i][rDst] = ((p ) & 0x1f); - rgba[i][gDst] = ((p >> 5) & 0x1f); - rgba[i][bDst] = ((p >> 10) & 0x1f); - rgba[i][aDst] = ((p >> 15) ); - } - } - break; - case GL_UNSIGNED_INT_8_8_8_8: - if (swapBytes) { - const GLuint *uisrc = (const GLuint *) src; - GLuint i; - for (i = 0; i < n; i ++) { - GLuint p = uisrc[i]; - rgba[i][rDst] = ((p ) & 0xff); - rgba[i][gDst] = ((p >> 8) & 0xff); - rgba[i][bDst] = ((p >> 16) & 0xff); - rgba[i][aDst] = ((p >> 24) ); - } - } - else { - const GLuint *uisrc = (const GLuint *) src; - GLuint i; - for (i = 0; i < n; i ++) { - GLuint p = uisrc[i]; - rgba[i][rDst] = ((p >> 24) ); - rgba[i][gDst] = ((p >> 16) & 0xff); - rgba[i][bDst] = ((p >> 8) & 0xff); - rgba[i][aDst] = ((p ) & 0xff); - } - } - break; - case GL_UNSIGNED_INT_8_8_8_8_REV: - if (swapBytes) { - const GLuint *uisrc = (const GLuint *) src; - GLuint i; - for (i = 0; i < n; i ++) { - GLuint p = uisrc[i]; - rgba[i][rDst] = ((p >> 24) ); - rgba[i][gDst] = ((p >> 16) & 0xff); - rgba[i][bDst] = ((p >> 8) & 0xff); - rgba[i][aDst] = ((p ) & 0xff); - } - } - else { - const GLuint *uisrc = (const GLuint *) src; - GLuint i; - for (i = 0; i < n; i ++) { - GLuint p = uisrc[i]; - rgba[i][rDst] = ((p ) & 0xff); - rgba[i][gDst] = ((p >> 8) & 0xff); - rgba[i][bDst] = ((p >> 16) & 0xff); - rgba[i][aDst] = ((p >> 24) ); - } - } - break; - default: - _mesa_problem(NULL, "bad srcType in extract uint data"); - break; - } -#undef PROCESS -} - - - -/* - * Unpack a row of color image data from a client buffer according to - * the pixel unpacking parameters. - * Return GLubyte values in the specified dest image format. - * This is used by glDrawPixels and glTexImage?D(). - * \param ctx - the context - * n - number of pixels in the span - * dstFormat - format of destination color array - * dest - the destination color array - * srcFormat - source image format - * srcType - source image data type - * source - source image pointer - * srcPacking - pixel unpacking parameters - * transferOps - bitmask of IMAGE_*_BIT values of operations to apply - * - * XXX perhaps expand this to process whole images someday. - */ -void -_mesa_unpack_color_span_ubyte(struct gl_context *ctx, - GLuint n, GLenum dstFormat, GLubyte dest[], - GLenum srcFormat, GLenum srcType, - const GLvoid *source, - const struct gl_pixelstore_attrib *srcPacking, - GLbitfield transferOps ) -{ - GLboolean intFormat = _mesa_is_integer_format(srcFormat); - ASSERT(dstFormat == GL_ALPHA || - dstFormat == GL_LUMINANCE || - dstFormat == GL_LUMINANCE_ALPHA || - dstFormat == GL_INTENSITY || - dstFormat == GL_RED || - dstFormat == GL_RG || - dstFormat == GL_RGB || - dstFormat == GL_RGBA); - - ASSERT(srcFormat == GL_RED || - srcFormat == GL_GREEN || - srcFormat == GL_BLUE || - srcFormat == GL_ALPHA || - srcFormat == GL_LUMINANCE || - srcFormat == GL_LUMINANCE_ALPHA || - srcFormat == GL_INTENSITY || - srcFormat == GL_RG || - srcFormat == GL_RGB || - srcFormat == GL_BGR || - srcFormat == GL_RGBA || - srcFormat == GL_BGRA || - srcFormat == GL_ABGR_EXT || - srcFormat == GL_COLOR_INDEX); - - ASSERT(srcType == GL_BITMAP || - srcType == GL_UNSIGNED_BYTE || - srcType == GL_BYTE || - srcType == GL_UNSIGNED_SHORT || - srcType == GL_SHORT || - srcType == GL_UNSIGNED_INT || - srcType == GL_INT || - srcType == GL_HALF_FLOAT_ARB || - srcType == GL_FLOAT || - srcType == GL_UNSIGNED_BYTE_3_3_2 || - srcType == GL_UNSIGNED_BYTE_2_3_3_REV || - srcType == GL_UNSIGNED_SHORT_5_6_5 || - srcType == GL_UNSIGNED_SHORT_5_6_5_REV || - srcType == GL_UNSIGNED_SHORT_4_4_4_4 || - srcType == GL_UNSIGNED_SHORT_4_4_4_4_REV || - srcType == GL_UNSIGNED_SHORT_5_5_5_1 || - srcType == GL_UNSIGNED_SHORT_1_5_5_5_REV || - srcType == GL_UNSIGNED_INT_8_8_8_8 || - srcType == GL_UNSIGNED_INT_8_8_8_8_REV || - srcType == GL_UNSIGNED_INT_5_9_9_9_REV || - srcType == GL_UNSIGNED_INT_10F_11F_11F_REV); - - /* EXT_texture_integer specifies no transfer ops on integer - * types in the resolved issues section. Just set them to 0 - * for integer surfaces. - */ - if (intFormat) - transferOps = 0; - - /* Try simple cases first */ - if (transferOps == 0) { - if (srcType == GL_UNSIGNED_BYTE) { - if (dstFormat == GL_RGBA) { - if (srcFormat == GL_RGBA) { - memcpy( dest, source, n * 4 * sizeof(GLubyte) ); - return; - } - else if (srcFormat == GL_RGB) { - GLuint i; - const GLubyte *src = (const GLubyte *) source; - GLubyte *dst = dest; - for (i = 0; i < n; i++) { - dst[0] = src[0]; - dst[1] = src[1]; - dst[2] = src[2]; - dst[3] = 255; - src += 3; - dst += 4; - } - return; - } - } - else if (dstFormat == GL_RGB) { - if (srcFormat == GL_RGB) { - memcpy( dest, source, n * 3 * sizeof(GLubyte) ); - return; - } - else if (srcFormat == GL_RGBA) { - GLuint i; - const GLubyte *src = (const GLubyte *) source; - GLubyte *dst = dest; - for (i = 0; i < n; i++) { - dst[0] = src[0]; - dst[1] = src[1]; - dst[2] = src[2]; - src += 4; - dst += 3; - } - return; - } - } - else if (dstFormat == srcFormat) { - GLint comps = _mesa_components_in_format(srcFormat); - assert(comps > 0); - memcpy( dest, source, n * comps * sizeof(GLubyte) ); - return; - } - } - } - - - /* general solution begins here */ - { - GLint dstComponents; - GLint rDst, gDst, bDst, aDst, lDst, iDst; - GLfloat (*rgba)[4] = (GLfloat (*)[4]) malloc(4 * n * sizeof(GLfloat)); - - if (!rgba) { - _mesa_error(ctx, GL_OUT_OF_MEMORY, "pixel unpacking"); - return; - } - - dstComponents = _mesa_components_in_format( dstFormat ); - /* source & dest image formats should have been error checked by now */ - assert(dstComponents > 0); - - /* - * Extract image data and convert to RGBA floats - */ - if (srcFormat == GL_COLOR_INDEX) { - GLuint *indexes = (GLuint *) malloc(n * sizeof(GLuint)); - - if (!indexes) { - _mesa_error(ctx, GL_OUT_OF_MEMORY, "pixel unpacking"); - free(rgba); - return; - } - - extract_uint_indexes(n, indexes, srcFormat, srcType, source, - srcPacking); - - /* Convert indexes to RGBA */ - if (transferOps & IMAGE_SHIFT_OFFSET_BIT) { - _mesa_shift_and_offset_ci(ctx, n, indexes); - } - _mesa_map_ci_to_rgba(ctx, n, indexes, rgba); - - /* Don't do RGBA scale/bias or RGBA->RGBA mapping if starting - * with color indexes. - */ - transferOps &= ~(IMAGE_SCALE_BIAS_BIT | IMAGE_MAP_COLOR_BIT); - - free(indexes); - } - else { - /* non-color index data */ - extract_float_rgba(n, rgba, srcFormat, srcType, source, - srcPacking->SwapBytes); - } - - /* Need to clamp if returning GLubytes */ - transferOps |= IMAGE_CLAMP_BIT; - - if (transferOps) { - _mesa_apply_rgba_transfer_ops(ctx, transferOps, n, rgba); - } - - get_component_indexes(dstFormat, - &rDst, &gDst, &bDst, &aDst, &lDst, &iDst); - - /* Now return the GLubyte data in the requested dstFormat */ - if (rDst >= 0) { - GLubyte *dst = dest; - GLuint i; - for (i = 0; i < n; i++) { - CLAMPED_FLOAT_TO_UBYTE(dst[rDst], rgba[i][RCOMP]); - dst += dstComponents; - } - } - - if (gDst >= 0) { - GLubyte *dst = dest; - GLuint i; - for (i = 0; i < n; i++) { - CLAMPED_FLOAT_TO_UBYTE(dst[gDst], rgba[i][GCOMP]); - dst += dstComponents; - } - } - - if (bDst >= 0) { - GLubyte *dst = dest; - GLuint i; - for (i = 0; i < n; i++) { - CLAMPED_FLOAT_TO_UBYTE(dst[bDst], rgba[i][BCOMP]); - dst += dstComponents; - } - } - - if (aDst >= 0) { - GLubyte *dst = dest; - GLuint i; - for (i = 0; i < n; i++) { - CLAMPED_FLOAT_TO_UBYTE(dst[aDst], rgba[i][ACOMP]); - dst += dstComponents; - } - } - - if (iDst >= 0) { - GLubyte *dst = dest; - GLuint i; - assert(iDst == 0); - assert(dstComponents == 1); - for (i = 0; i < n; i++) { - /* Intensity comes from red channel */ - CLAMPED_FLOAT_TO_UBYTE(dst[i], rgba[i][RCOMP]); - } - } - - if (lDst >= 0) { - GLubyte *dst = dest; - GLuint i; - assert(lDst == 0); - for (i = 0; i < n; i++) { - /* Luminance comes from red channel */ - CLAMPED_FLOAT_TO_UBYTE(dst[0], rgba[i][RCOMP]); - dst += dstComponents; - } - } - - free(rgba); - } -} - - -/** - * Same as _mesa_unpack_color_span_ubyte(), but return GLfloat data - * instead of GLubyte. - */ -void -_mesa_unpack_color_span_float( struct gl_context *ctx, - GLuint n, GLenum dstFormat, GLfloat dest[], - GLenum srcFormat, GLenum srcType, - const GLvoid *source, - const struct gl_pixelstore_attrib *srcPacking, - GLbitfield transferOps ) -{ - ASSERT(dstFormat == GL_ALPHA || - dstFormat == GL_LUMINANCE || - dstFormat == GL_LUMINANCE_ALPHA || - dstFormat == GL_INTENSITY || - dstFormat == GL_RED || - dstFormat == GL_RG || - dstFormat == GL_RGB || - dstFormat == GL_RGBA); - - ASSERT(srcFormat == GL_RED || - srcFormat == GL_GREEN || - srcFormat == GL_BLUE || - srcFormat == GL_ALPHA || - srcFormat == GL_LUMINANCE || - srcFormat == GL_LUMINANCE_ALPHA || - srcFormat == GL_INTENSITY || - srcFormat == GL_RG || - srcFormat == GL_RGB || - srcFormat == GL_BGR || - srcFormat == GL_RGBA || - srcFormat == GL_BGRA || - srcFormat == GL_ABGR_EXT || - srcFormat == GL_RED_INTEGER_EXT || - srcFormat == GL_GREEN_INTEGER_EXT || - srcFormat == GL_BLUE_INTEGER_EXT || - srcFormat == GL_ALPHA_INTEGER_EXT || - srcFormat == GL_RG_INTEGER || - srcFormat == GL_RGB_INTEGER_EXT || - srcFormat == GL_RGBA_INTEGER_EXT || - srcFormat == GL_BGR_INTEGER_EXT || - srcFormat == GL_BGRA_INTEGER_EXT || - srcFormat == GL_LUMINANCE_INTEGER_EXT || - srcFormat == GL_LUMINANCE_ALPHA_INTEGER_EXT || - srcFormat == GL_COLOR_INDEX); - - ASSERT(srcType == GL_BITMAP || - srcType == GL_UNSIGNED_BYTE || - srcType == GL_BYTE || - srcType == GL_UNSIGNED_SHORT || - srcType == GL_SHORT || - srcType == GL_UNSIGNED_INT || - srcType == GL_INT || - srcType == GL_HALF_FLOAT_ARB || - srcType == GL_FLOAT || - srcType == GL_UNSIGNED_BYTE_3_3_2 || - srcType == GL_UNSIGNED_BYTE_2_3_3_REV || - srcType == GL_UNSIGNED_SHORT_5_6_5 || - srcType == GL_UNSIGNED_SHORT_5_6_5_REV || - srcType == GL_UNSIGNED_SHORT_4_4_4_4 || - srcType == GL_UNSIGNED_SHORT_4_4_4_4_REV || - srcType == GL_UNSIGNED_SHORT_5_5_5_1 || - srcType == GL_UNSIGNED_SHORT_1_5_5_5_REV || - srcType == GL_UNSIGNED_INT_8_8_8_8 || - srcType == GL_UNSIGNED_INT_8_8_8_8_REV || - srcType == GL_UNSIGNED_INT_5_9_9_9_REV || - srcType == GL_UNSIGNED_INT_10F_11F_11F_REV); - - /* general solution, no special cases, yet */ - { - GLint dstComponents; - GLint rDst, gDst, bDst, aDst, lDst, iDst; - GLfloat (*rgba)[4] = (GLfloat (*)[4]) malloc(4 * n * sizeof(GLfloat)); - GLboolean intFormat = _mesa_is_integer_format(srcFormat); - - if (!rgba) { - _mesa_error(ctx, GL_OUT_OF_MEMORY, "pixel unpacking"); - return; - } - - dstComponents = _mesa_components_in_format( dstFormat ); - /* source & dest image formats should have been error checked by now */ - assert(dstComponents > 0); - - /* EXT_texture_integer specifies no transfer ops on integer - * types in the resolved issues section. Just set them to 0 - * for integer surfaces. - */ - if (intFormat) - transferOps = 0; - - /* - * Extract image data and convert to RGBA floats - */ - if (srcFormat == GL_COLOR_INDEX) { - GLuint *indexes = (GLuint *) malloc(n * sizeof(GLuint)); - - if (!indexes) { - _mesa_error(ctx, GL_OUT_OF_MEMORY, "pixel unpacking"); - free(rgba); - return; - } - - extract_uint_indexes(n, indexes, srcFormat, srcType, source, - srcPacking); - - /* Convert indexes to RGBA */ - if (transferOps & IMAGE_SHIFT_OFFSET_BIT) { - _mesa_shift_and_offset_ci(ctx, n, indexes); - } - _mesa_map_ci_to_rgba(ctx, n, indexes, rgba); - - /* Don't do RGBA scale/bias or RGBA->RGBA mapping if starting - * with color indexes. - */ - transferOps &= ~(IMAGE_SCALE_BIAS_BIT | IMAGE_MAP_COLOR_BIT); - - free(indexes); - } - else { - /* non-color index data */ - extract_float_rgba(n, rgba, srcFormat, srcType, source, - srcPacking->SwapBytes); - } - - if (transferOps) { - _mesa_apply_rgba_transfer_ops(ctx, transferOps, n, rgba); - } - - get_component_indexes(dstFormat, - &rDst, &gDst, &bDst, &aDst, &lDst, &iDst); - - /* Now pack results in the requested dstFormat */ - if (rDst >= 0) { - GLfloat *dst = dest; - GLuint i; - for (i = 0; i < n; i++) { - dst[rDst] = rgba[i][RCOMP]; - dst += dstComponents; - } - } - - if (gDst >= 0) { - GLfloat *dst = dest; - GLuint i; - for (i = 0; i < n; i++) { - dst[gDst] = rgba[i][GCOMP]; - dst += dstComponents; - } - } - - if (bDst >= 0) { - GLfloat *dst = dest; - GLuint i; - for (i = 0; i < n; i++) { - dst[bDst] = rgba[i][BCOMP]; - dst += dstComponents; - } - } - - if (aDst >= 0) { - GLfloat *dst = dest; - GLuint i; - for (i = 0; i < n; i++) { - dst[aDst] = rgba[i][ACOMP]; - dst += dstComponents; - } - } - - if (iDst >= 0) { - GLfloat *dst = dest; - GLuint i; - assert(iDst == 0); - assert(dstComponents == 1); - for (i = 0; i < n; i++) { - /* Intensity comes from red channel */ - dst[i] = rgba[i][RCOMP]; - } - } - - if (lDst >= 0) { - GLfloat *dst = dest; - GLuint i; - assert(lDst == 0); - for (i = 0; i < n; i++) { - /* Luminance comes from red channel */ - dst[0] = rgba[i][RCOMP]; - dst += dstComponents; - } - } - - free(rgba); - } -} - - -/** - * Same as _mesa_unpack_color_span_ubyte(), but return GLuint data - * instead of GLubyte. - * No pixel transfer ops are applied. - */ -void -_mesa_unpack_color_span_uint(struct gl_context *ctx, - GLuint n, GLenum dstFormat, GLuint *dest, - GLenum srcFormat, GLenum srcType, - const GLvoid *source, - const struct gl_pixelstore_attrib *srcPacking) -{ - GLuint (*rgba)[4] = (GLuint (*)[4]) malloc(n * 4 * sizeof(GLfloat)); - - if (!rgba) { - _mesa_error(ctx, GL_OUT_OF_MEMORY, "pixel unpacking"); - return; - } - - ASSERT(dstFormat == GL_ALPHA || - dstFormat == GL_LUMINANCE || - dstFormat == GL_LUMINANCE_ALPHA || - dstFormat == GL_INTENSITY || - dstFormat == GL_RED || - dstFormat == GL_RG || - dstFormat == GL_RGB || - dstFormat == GL_RGBA); - - ASSERT(srcFormat == GL_RED || - srcFormat == GL_GREEN || - srcFormat == GL_BLUE || - srcFormat == GL_ALPHA || - srcFormat == GL_LUMINANCE || - srcFormat == GL_LUMINANCE_ALPHA || - srcFormat == GL_INTENSITY || - srcFormat == GL_RG || - srcFormat == GL_RGB || - srcFormat == GL_BGR || - srcFormat == GL_RGBA || - srcFormat == GL_BGRA || - srcFormat == GL_ABGR_EXT || - srcFormat == GL_RED_INTEGER_EXT || - srcFormat == GL_GREEN_INTEGER_EXT || - srcFormat == GL_BLUE_INTEGER_EXT || - srcFormat == GL_ALPHA_INTEGER_EXT || - srcFormat == GL_RG_INTEGER || - srcFormat == GL_RGB_INTEGER_EXT || - srcFormat == GL_RGBA_INTEGER_EXT || - srcFormat == GL_BGR_INTEGER_EXT || - srcFormat == GL_BGRA_INTEGER_EXT || - srcFormat == GL_LUMINANCE_INTEGER_EXT || - srcFormat == GL_LUMINANCE_ALPHA_INTEGER_EXT); - - ASSERT(srcType == GL_UNSIGNED_BYTE || - srcType == GL_BYTE || - srcType == GL_UNSIGNED_SHORT || - srcType == GL_SHORT || - srcType == GL_UNSIGNED_INT || - srcType == GL_INT || - srcType == GL_HALF_FLOAT_ARB || - srcType == GL_FLOAT || - srcType == GL_UNSIGNED_BYTE_3_3_2 || - srcType == GL_UNSIGNED_BYTE_2_3_3_REV || - srcType == GL_UNSIGNED_SHORT_5_6_5 || - srcType == GL_UNSIGNED_SHORT_5_6_5_REV || - srcType == GL_UNSIGNED_SHORT_4_4_4_4 || - srcType == GL_UNSIGNED_SHORT_4_4_4_4_REV || - srcType == GL_UNSIGNED_SHORT_5_5_5_1 || - srcType == GL_UNSIGNED_SHORT_1_5_5_5_REV || - srcType == GL_UNSIGNED_INT_8_8_8_8 || - srcType == GL_UNSIGNED_INT_8_8_8_8_REV || - srcType == GL_UNSIGNED_INT_5_9_9_9_REV || - srcType == GL_UNSIGNED_INT_10F_11F_11F_REV); - - - /* Extract image data as uint[4] pixels */ - extract_uint_rgba(n, rgba, srcFormat, srcType, source, - srcPacking->SwapBytes); - - if (dstFormat == GL_RGBA) { - /* simple case */ - memcpy(dest, rgba, 4 * sizeof(GLuint) * n); - } - else { - /* general case */ - GLint rDst, gDst, bDst, aDst, lDst, iDst; - GLint dstComponents = _mesa_components_in_format( dstFormat ); - - assert(dstComponents > 0); - - get_component_indexes(dstFormat, - &rDst, &gDst, &bDst, &aDst, &lDst, &iDst); - - /* Now pack values in the requested dest format */ - if (rDst >= 0) { - GLuint *dst = dest; - GLuint i; - for (i = 0; i < n; i++) { - dst[rDst] = rgba[i][RCOMP]; - dst += dstComponents; - } - } - - if (gDst >= 0) { - GLuint *dst = dest; - GLuint i; - for (i = 0; i < n; i++) { - dst[gDst] = rgba[i][GCOMP]; - dst += dstComponents; - } - } - - if (bDst >= 0) { - GLuint *dst = dest; - GLuint i; - for (i = 0; i < n; i++) { - dst[bDst] = rgba[i][BCOMP]; - dst += dstComponents; - } - } - - if (aDst >= 0) { - GLuint *dst = dest; - GLuint i; - for (i = 0; i < n; i++) { - dst[aDst] = rgba[i][ACOMP]; - dst += dstComponents; - } - } - - if (iDst >= 0) { - GLuint *dst = dest; - GLuint i; - assert(iDst == 0); - assert(dstComponents == 1); - for (i = 0; i < n; i++) { - /* Intensity comes from red channel */ - dst[i] = rgba[i][RCOMP]; - } - } - - if (lDst >= 0) { - GLuint *dst = dest; - GLuint i; - assert(lDst == 0); - for (i = 0; i < n; i++) { - /* Luminance comes from red channel */ - dst[0] = rgba[i][RCOMP]; - dst += dstComponents; - } - } - } - - free(rgba); -} - - -/* - * Unpack a row of color index data from a client buffer according to - * the pixel unpacking parameters. - * This is (or will be) used by glDrawPixels, glTexImage[123]D, etc. - * - * Args: ctx - the context - * n - number of pixels - * dstType - destination data type - * dest - destination array - * srcType - source pixel type - * source - source data pointer - * srcPacking - pixel unpacking parameters - * transferOps - the pixel transfer operations to apply - */ -void -_mesa_unpack_index_span( struct gl_context *ctx, GLuint n, - GLenum dstType, GLvoid *dest, - GLenum srcType, const GLvoid *source, - const struct gl_pixelstore_attrib *srcPacking, - GLbitfield transferOps ) -{ - ASSERT(srcType == GL_BITMAP || - srcType == GL_UNSIGNED_BYTE || - srcType == GL_BYTE || - srcType == GL_UNSIGNED_SHORT || - srcType == GL_SHORT || - srcType == GL_UNSIGNED_INT || - srcType == GL_INT || - srcType == GL_HALF_FLOAT_ARB || - srcType == GL_FLOAT); - - ASSERT(dstType == GL_UNSIGNED_BYTE || - dstType == GL_UNSIGNED_SHORT || - dstType == GL_UNSIGNED_INT); - - - transferOps &= (IMAGE_MAP_COLOR_BIT | IMAGE_SHIFT_OFFSET_BIT); - - /* - * Try simple cases first - */ - if (transferOps == 0 && srcType == GL_UNSIGNED_BYTE - && dstType == GL_UNSIGNED_BYTE) { - memcpy(dest, source, n * sizeof(GLubyte)); - } - else if (transferOps == 0 && srcType == GL_UNSIGNED_INT - && dstType == GL_UNSIGNED_INT && !srcPacking->SwapBytes) { - memcpy(dest, source, n * sizeof(GLuint)); - } - else { - /* - * general solution - */ - GLuint *indexes = (GLuint *) malloc(n * sizeof(GLuint)); - - if (!indexes) { - _mesa_error(ctx, GL_OUT_OF_MEMORY, "pixel unpacking"); - return; - } - - extract_uint_indexes(n, indexes, GL_COLOR_INDEX, srcType, source, - srcPacking); - - if (transferOps) - _mesa_apply_ci_transfer_ops(ctx, transferOps, n, indexes); - - /* convert to dest type */ - switch (dstType) { - case GL_UNSIGNED_BYTE: - { - GLubyte *dst = (GLubyte *) dest; - GLuint i; - for (i = 0; i < n; i++) { - dst[i] = (GLubyte) (indexes[i] & 0xff); - } - } - break; - case GL_UNSIGNED_SHORT: - { - GLuint *dst = (GLuint *) dest; - GLuint i; - for (i = 0; i < n; i++) { - dst[i] = (GLushort) (indexes[i] & 0xffff); - } - } - break; - case GL_UNSIGNED_INT: - memcpy(dest, indexes, n * sizeof(GLuint)); - break; - default: - _mesa_problem(ctx, "bad dstType in _mesa_unpack_index_span"); - } - - free(indexes); - } -} - - -void -_mesa_pack_index_span( struct gl_context *ctx, GLuint n, - GLenum dstType, GLvoid *dest, const GLuint *source, - const struct gl_pixelstore_attrib *dstPacking, - GLbitfield transferOps ) -{ - GLuint *indexes = (GLuint *) malloc(n * sizeof(GLuint)); - - if (!indexes) { - _mesa_error(ctx, GL_OUT_OF_MEMORY, "pixel packing"); - return; - } - - transferOps &= (IMAGE_MAP_COLOR_BIT | IMAGE_SHIFT_OFFSET_BIT); - - if (transferOps & (IMAGE_MAP_COLOR_BIT | IMAGE_SHIFT_OFFSET_BIT)) { - /* make a copy of input */ - memcpy(indexes, source, n * sizeof(GLuint)); - _mesa_apply_ci_transfer_ops(ctx, transferOps, n, indexes); - source = indexes; - } - - switch (dstType) { - case GL_UNSIGNED_BYTE: - { - GLubyte *dst = (GLubyte *) dest; - GLuint i; - for (i = 0; i < n; i++) { - *dst++ = (GLubyte) source[i]; - } - } - break; - case GL_BYTE: - { - GLbyte *dst = (GLbyte *) dest; - GLuint i; - for (i = 0; i < n; i++) { - dst[i] = (GLbyte) source[i]; - } - } - break; - case GL_UNSIGNED_SHORT: - { - GLushort *dst = (GLushort *) dest; - GLuint i; - for (i = 0; i < n; i++) { - dst[i] = (GLushort) source[i]; - } - if (dstPacking->SwapBytes) { - _mesa_swap2( (GLushort *) dst, n ); - } - } - break; - case GL_SHORT: - { - GLshort *dst = (GLshort *) dest; - GLuint i; - for (i = 0; i < n; i++) { - dst[i] = (GLshort) source[i]; - } - if (dstPacking->SwapBytes) { - _mesa_swap2( (GLushort *) dst, n ); - } - } - break; - case GL_UNSIGNED_INT: - { - GLuint *dst = (GLuint *) dest; - GLuint i; - for (i = 0; i < n; i++) { - dst[i] = (GLuint) source[i]; - } - if (dstPacking->SwapBytes) { - _mesa_swap4( (GLuint *) dst, n ); - } - } - break; - case GL_INT: - { - GLint *dst = (GLint *) dest; - GLuint i; - for (i = 0; i < n; i++) { - dst[i] = (GLint) source[i]; - } - if (dstPacking->SwapBytes) { - _mesa_swap4( (GLuint *) dst, n ); - } - } - break; - case GL_FLOAT: - { - GLfloat *dst = (GLfloat *) dest; - GLuint i; - for (i = 0; i < n; i++) { - dst[i] = (GLfloat) source[i]; - } - if (dstPacking->SwapBytes) { - _mesa_swap4( (GLuint *) dst, n ); - } - } - break; - default: - _mesa_problem(ctx, "bad type in _mesa_pack_index_span"); - } - - free(indexes); -} - - -/* - * Unpack a row of stencil data from a client buffer according to - * the pixel unpacking parameters. - * This is (or will be) used by glDrawPixels - * - * Args: ctx - the context - * n - number of pixels - * dstType - destination data type - * dest - destination array - * srcType - source pixel type - * source - source data pointer - * srcPacking - pixel unpacking parameters - * transferOps - apply offset/bias/lookup ops? - */ -void -_mesa_unpack_stencil_span( struct gl_context *ctx, GLuint n, - GLenum dstType, GLvoid *dest, - GLenum srcType, const GLvoid *source, - const struct gl_pixelstore_attrib *srcPacking, - GLbitfield transferOps ) -{ - ASSERT(srcType == GL_BITMAP || - srcType == GL_UNSIGNED_BYTE || - srcType == GL_BYTE || - srcType == GL_UNSIGNED_SHORT || - srcType == GL_SHORT || - srcType == GL_UNSIGNED_INT || - srcType == GL_INT || - srcType == GL_HALF_FLOAT_ARB || - srcType == GL_FLOAT); - - ASSERT(dstType == GL_UNSIGNED_BYTE || - dstType == GL_UNSIGNED_SHORT || - dstType == GL_UNSIGNED_INT); - - /* only shift and offset apply to stencil */ - transferOps &= IMAGE_SHIFT_OFFSET_BIT; - - /* - * Try simple cases first - */ - if (transferOps == 0 && - !ctx->Pixel.MapStencilFlag && - srcType == GL_UNSIGNED_BYTE && - dstType == GL_UNSIGNED_BYTE) { - memcpy(dest, source, n * sizeof(GLubyte)); - } - else if (transferOps == 0 && - !ctx->Pixel.MapStencilFlag && - srcType == GL_UNSIGNED_INT && - dstType == GL_UNSIGNED_INT && - !srcPacking->SwapBytes) { - memcpy(dest, source, n * sizeof(GLuint)); - } - else { - /* - * general solution - */ - GLuint *indexes = (GLuint *) malloc(n * sizeof(GLuint)); - - if (!indexes) { - _mesa_error(ctx, GL_OUT_OF_MEMORY, "stencil unpacking"); - return; - } - - extract_uint_indexes(n, indexes, GL_STENCIL_INDEX, srcType, source, - srcPacking); - - if (transferOps & IMAGE_SHIFT_OFFSET_BIT) { - /* shift and offset indexes */ - _mesa_shift_and_offset_ci(ctx, n, indexes); - } - - if (ctx->Pixel.MapStencilFlag) { - /* Apply stencil lookup table */ - const GLuint mask = ctx->PixelMaps.StoS.Size - 1; - GLuint i; - for (i = 0; i < n; i++) { - indexes[i] = (GLuint)ctx->PixelMaps.StoS.Map[ indexes[i] & mask ]; - } - } - - /* convert to dest type */ - switch (dstType) { - case GL_UNSIGNED_BYTE: - { - GLubyte *dst = (GLubyte *) dest; - GLuint i; - for (i = 0; i < n; i++) { - dst[i] = (GLubyte) (indexes[i] & 0xff); - } - } - break; - case GL_UNSIGNED_SHORT: - { - GLuint *dst = (GLuint *) dest; - GLuint i; - for (i = 0; i < n; i++) { - dst[i] = (GLushort) (indexes[i] & 0xffff); - } - } - break; - case GL_UNSIGNED_INT: - memcpy(dest, indexes, n * sizeof(GLuint)); - break; - default: - _mesa_problem(ctx, "bad dstType in _mesa_unpack_stencil_span"); - } - - free(indexes); - } -} - - -void -_mesa_pack_stencil_span( struct gl_context *ctx, GLuint n, - GLenum dstType, GLvoid *dest, const GLubyte *source, - const struct gl_pixelstore_attrib *dstPacking ) -{ - GLubyte *stencil = (GLubyte *) malloc(n * sizeof(GLubyte)); - - if (!stencil) { - _mesa_error(ctx, GL_OUT_OF_MEMORY, "stencil packing"); - return; - } - - if (ctx->Pixel.IndexShift || ctx->Pixel.IndexOffset || - ctx->Pixel.MapStencilFlag) { - /* make a copy of input */ - memcpy(stencil, source, n * sizeof(GLubyte)); - _mesa_apply_stencil_transfer_ops(ctx, n, stencil); - source = stencil; - } - - switch (dstType) { - case GL_UNSIGNED_BYTE: - memcpy(dest, source, n); - break; - case GL_BYTE: - { - GLbyte *dst = (GLbyte *) dest; - GLuint i; - for (i=0;iSwapBytes) { - _mesa_swap2( (GLushort *) dst, n ); - } - } - break; - case GL_SHORT: - { - GLshort *dst = (GLshort *) dest; - GLuint i; - for (i=0;iSwapBytes) { - _mesa_swap2( (GLushort *) dst, n ); - } - } - break; - case GL_UNSIGNED_INT: - { - GLuint *dst = (GLuint *) dest; - GLuint i; - for (i=0;iSwapBytes) { - _mesa_swap4( (GLuint *) dst, n ); - } - } - break; - case GL_INT: - { - GLint *dst = (GLint *) dest; - GLuint i; - for (i=0;iSwapBytes) { - _mesa_swap4( (GLuint *) dst, n ); - } - } - break; - case GL_FLOAT: - { - GLfloat *dst = (GLfloat *) dest; - GLuint i; - for (i=0;iSwapBytes) { - _mesa_swap4( (GLuint *) dst, n ); - } - } - break; - case GL_BITMAP: - if (dstPacking->LsbFirst) { - GLubyte *dst = (GLubyte *) dest; - GLint shift = 0; - GLuint i; - for (i = 0; i < n; i++) { - if (shift == 0) - *dst = 0; - *dst |= ((source[i] != 0) << shift); - shift++; - if (shift == 8) { - shift = 0; - dst++; - } - } - } - else { - GLubyte *dst = (GLubyte *) dest; - GLint shift = 7; - GLuint i; - for (i = 0; i < n; i++) { - if (shift == 7) - *dst = 0; - *dst |= ((source[i] != 0) << shift); - shift--; - if (shift < 0) { - shift = 7; - dst++; - } - } - } - break; - default: - _mesa_problem(ctx, "bad type in _mesa_pack_index_span"); - } - - free(stencil); -} - -#define DEPTH_VALUES(GLTYPE, GLTYPE2FLOAT) \ - do { \ - GLuint i; \ - const GLTYPE *src = (const GLTYPE *)source; \ - for (i = 0; i < n; i++) { \ - GLTYPE value = src[i]; \ - if (srcPacking->SwapBytes) { \ - if (sizeof(GLTYPE) == 2) { \ - SWAP2BYTE(value); \ - } else if (sizeof(GLTYPE) == 4) { \ - SWAP4BYTE(value); \ - } \ - } \ - depthValues[i] = GLTYPE2FLOAT(value); \ - } \ - } while (0) - - -/** - * Unpack a row of depth/z values from memory, returning GLushort, GLuint - * or GLfloat values. - * The glPixelTransfer (scale/bias) params will be applied. - * - * \param dstType one of GL_UNSIGNED_SHORT, GL_UNSIGNED_INT, GL_FLOAT - * \param depthMax max value for returned GLushort or GLuint values - * (ignored for GLfloat). - */ -void -_mesa_unpack_depth_span( struct gl_context *ctx, GLuint n, - GLenum dstType, GLvoid *dest, GLuint depthMax, - GLenum srcType, const GLvoid *source, - const struct gl_pixelstore_attrib *srcPacking ) -{ - GLfloat *depthTemp = NULL, *depthValues; - GLboolean needClamp = GL_FALSE; - - /* Look for special cases first. - * Not only are these faster, they're less prone to numeric conversion - * problems. Otherwise, converting from an int type to a float then - * back to an int type can introduce errors that will show up as - * artifacts in things like depth peeling which uses glCopyTexImage. - */ - if (ctx->Pixel.DepthScale == 1.0 && ctx->Pixel.DepthBias == 0.0) { - if (srcType == GL_UNSIGNED_INT && dstType == GL_UNSIGNED_SHORT) { - const GLuint *src = (const GLuint *) source; - GLushort *dst = (GLushort *) dest; - GLuint i; - for (i = 0; i < n; i++) { - dst[i] = src[i] >> 16; - } - return; - } - if (srcType == GL_UNSIGNED_SHORT - && dstType == GL_UNSIGNED_INT - && depthMax == 0xffffffff) { - const GLushort *src = (const GLushort *) source; - GLuint *dst = (GLuint *) dest; - GLuint i; - for (i = 0; i < n; i++) { - dst[i] = src[i] | (src[i] << 16); - } - return; - } - /* XXX may want to add additional cases here someday */ - } - - /* general case path follows */ - - if (dstType == GL_FLOAT) { - depthValues = (GLfloat *) dest; - } - else { - depthTemp = (GLfloat *) malloc(n * sizeof(GLfloat)); - if (!depthTemp) { - _mesa_error(ctx, GL_OUT_OF_MEMORY, "pixel unpacking"); - return; - } - - depthValues = depthTemp; - } - - /* Convert incoming values to GLfloat. Some conversions will require - * clamping, below. - */ - switch (srcType) { - case GL_BYTE: - DEPTH_VALUES(GLbyte, BYTE_TO_FLOATZ); - needClamp = GL_TRUE; - break; - case GL_UNSIGNED_BYTE: - DEPTH_VALUES(GLubyte, UBYTE_TO_FLOAT); - break; - case GL_SHORT: - DEPTH_VALUES(GLshort, SHORT_TO_FLOATZ); - needClamp = GL_TRUE; - break; - case GL_UNSIGNED_SHORT: - DEPTH_VALUES(GLushort, USHORT_TO_FLOAT); - break; - case GL_INT: - DEPTH_VALUES(GLint, INT_TO_FLOAT); - needClamp = GL_TRUE; - break; - case GL_UNSIGNED_INT: - DEPTH_VALUES(GLuint, UINT_TO_FLOAT); - break; - case GL_FLOAT: - DEPTH_VALUES(GLfloat, 1*); - needClamp = GL_TRUE; - break; - default: - _mesa_problem(NULL, "bad type in _mesa_unpack_depth_span()"); - free(depthTemp); - return; - } - - /* apply depth scale and bias */ - { - const GLfloat scale = ctx->Pixel.DepthScale; - const GLfloat bias = ctx->Pixel.DepthBias; - if (scale != 1.0 || bias != 0.0) { - GLuint i; - for (i = 0; i < n; i++) { - depthValues[i] = depthValues[i] * scale + bias; - } - needClamp = GL_TRUE; - } - } - - /* clamp to [0, 1] */ - if (needClamp) { - GLuint i; - for (i = 0; i < n; i++) { - depthValues[i] = (GLfloat)CLAMP(depthValues[i], 0.0, 1.0); - } - } - - /* - * Convert values to dstType - */ - if (dstType == GL_UNSIGNED_INT) { - GLuint *zValues = (GLuint *) dest; - GLuint i; - if (depthMax <= 0xffffff) { - /* no overflow worries */ - for (i = 0; i < n; i++) { - zValues[i] = (GLuint) (depthValues[i] * (GLfloat) depthMax); - } - } - else { - /* need to use double precision to prevent overflow problems */ - for (i = 0; i < n; i++) { - GLdouble z = depthValues[i] * (GLfloat) depthMax; - if (z >= (GLdouble) 0xffffffff) - zValues[i] = 0xffffffff; - else - zValues[i] = (GLuint) z; - } - } - } - else if (dstType == GL_UNSIGNED_SHORT) { - GLushort *zValues = (GLushort *) dest; - GLuint i; - ASSERT(depthMax <= 0xffff); - for (i = 0; i < n; i++) { - zValues[i] = (GLushort) (depthValues[i] * (GLfloat) depthMax); - } - } - else if (dstType == GL_FLOAT) { - /* Nothing to do. depthValues is pointing to dest. */ - } - else { - ASSERT(0); - } - - free(depthTemp); -} - - -/* - * Pack an array of depth values. The values are floats in [0,1]. - */ -void -_mesa_pack_depth_span( struct gl_context *ctx, GLuint n, GLvoid *dest, - GLenum dstType, const GLfloat *depthSpan, - const struct gl_pixelstore_attrib *dstPacking ) -{ - GLfloat *depthCopy = (GLfloat *) malloc(n * sizeof(GLfloat)); - if (!depthCopy) { - _mesa_error(ctx, GL_OUT_OF_MEMORY, "pixel packing"); - return; - } - - if (ctx->Pixel.DepthScale != 1.0 || ctx->Pixel.DepthBias != 0.0) { - memcpy(depthCopy, depthSpan, n * sizeof(GLfloat)); - _mesa_scale_and_bias_depth(ctx, n, depthCopy); - depthSpan = depthCopy; - } - - switch (dstType) { - case GL_UNSIGNED_BYTE: - { - GLubyte *dst = (GLubyte *) dest; - GLuint i; - for (i = 0; i < n; i++) { - dst[i] = FLOAT_TO_UBYTE( depthSpan[i] ); - } - } - break; - case GL_BYTE: - { - GLbyte *dst = (GLbyte *) dest; - GLuint i; - for (i = 0; i < n; i++) { - dst[i] = FLOAT_TO_BYTE( depthSpan[i] ); - } - } - break; - case GL_UNSIGNED_SHORT: - { - GLushort *dst = (GLushort *) dest; - GLuint i; - for (i = 0; i < n; i++) { - CLAMPED_FLOAT_TO_USHORT(dst[i], depthSpan[i]); - } - if (dstPacking->SwapBytes) { - _mesa_swap2( (GLushort *) dst, n ); - } - } - break; - case GL_SHORT: - { - GLshort *dst = (GLshort *) dest; - GLuint i; - for (i = 0; i < n; i++) { - dst[i] = FLOAT_TO_SHORT( depthSpan[i] ); - } - if (dstPacking->SwapBytes) { - _mesa_swap2( (GLushort *) dst, n ); - } - } - break; - case GL_UNSIGNED_INT: - { - GLuint *dst = (GLuint *) dest; - GLuint i; - for (i = 0; i < n; i++) { - dst[i] = FLOAT_TO_UINT( depthSpan[i] ); - } - if (dstPacking->SwapBytes) { - _mesa_swap4( (GLuint *) dst, n ); - } - } - break; - case GL_INT: - { - GLint *dst = (GLint *) dest; - GLuint i; - for (i = 0; i < n; i++) { - dst[i] = FLOAT_TO_INT( depthSpan[i] ); - } - if (dstPacking->SwapBytes) { - _mesa_swap4( (GLuint *) dst, n ); - } - } - break; - case GL_FLOAT: - { - GLfloat *dst = (GLfloat *) dest; - GLuint i; - for (i = 0; i < n; i++) { - dst[i] = depthSpan[i]; - } - if (dstPacking->SwapBytes) { - _mesa_swap4( (GLuint *) dst, n ); - } - } - break; - default: - _mesa_problem(ctx, "bad type in _mesa_pack_depth_span"); - } - - free(depthCopy); -} - - - -/** - * Unpack image data. Apply byte swapping, byte flipping (bitmap). - * Return all image data in a contiguous block. This is used when we - * compile glDrawPixels, glTexImage, etc into a display list. We - * need a copy of the data in a standard format. - */ -void * -_mesa_unpack_image( GLuint dimensions, - GLsizei width, GLsizei height, GLsizei depth, - GLenum format, GLenum type, const GLvoid *pixels, - const struct gl_pixelstore_attrib *unpack ) -{ - GLint bytesPerRow, compsPerRow; - GLboolean flipBytes, swap2, swap4; - - if (!pixels) - return NULL; /* not necessarily an error */ - - if (width <= 0 || height <= 0 || depth <= 0) - return NULL; /* generate error later */ - - if (type == GL_BITMAP) { - bytesPerRow = (width + 7) >> 3; - flipBytes = unpack->LsbFirst; - swap2 = swap4 = GL_FALSE; - compsPerRow = 0; - } - else { - const GLint bytesPerPixel = _mesa_bytes_per_pixel(format, type); - GLint components = _mesa_components_in_format(format); - GLint bytesPerComp; - - if (_mesa_type_is_packed(type)) - components = 1; - - if (bytesPerPixel <= 0 || components <= 0) - return NULL; /* bad format or type. generate error later */ - bytesPerRow = bytesPerPixel * width; - bytesPerComp = bytesPerPixel / components; - flipBytes = GL_FALSE; - swap2 = (bytesPerComp == 2) && unpack->SwapBytes; - swap4 = (bytesPerComp == 4) && unpack->SwapBytes; - compsPerRow = components * width; - assert(compsPerRow >= width); - } - - { - GLubyte *destBuffer - = (GLubyte *) malloc(bytesPerRow * height * depth); - GLubyte *dst; - GLint img, row; - if (!destBuffer) - return NULL; /* generate GL_OUT_OF_MEMORY later */ - - dst = destBuffer; - for (img = 0; img < depth; img++) { - for (row = 0; row < height; row++) { - const GLvoid *src = _mesa_image_address(dimensions, unpack, pixels, - width, height, format, type, img, row, 0); - - if ((type == GL_BITMAP) && (unpack->SkipPixels & 0x7)) { - GLint i; - flipBytes = GL_FALSE; - if (unpack->LsbFirst) { - GLubyte srcMask = 1 << (unpack->SkipPixels & 0x7); - GLubyte dstMask = 128; - const GLubyte *s = src; - GLubyte *d = dst; - *d = 0; - for (i = 0; i < width; i++) { - if (*s & srcMask) { - *d |= dstMask; - } - if (srcMask == 128) { - srcMask = 1; - s++; - } - else { - srcMask = srcMask << 1; - } - if (dstMask == 1) { - dstMask = 128; - d++; - *d = 0; - } - else { - dstMask = dstMask >> 1; - } - } - } - else { - GLubyte srcMask = 128 >> (unpack->SkipPixels & 0x7); - GLubyte dstMask = 128; - const GLubyte *s = src; - GLubyte *d = dst; - *d = 0; - for (i = 0; i < width; i++) { - if (*s & srcMask) { - *d |= dstMask; - } - if (srcMask == 1) { - srcMask = 128; - s++; - } - else { - srcMask = srcMask >> 1; - } - if (dstMask == 1) { - dstMask = 128; - d++; - *d = 0; - } - else { - dstMask = dstMask >> 1; - } - } - } - } - else { - memcpy(dst, src, bytesPerRow); - } - - /* byte flipping/swapping */ - if (flipBytes) { - flip_bytes((GLubyte *) dst, bytesPerRow); - } - else if (swap2) { - _mesa_swap2((GLushort*) dst, compsPerRow); - } - else if (swap4) { - _mesa_swap4((GLuint*) dst, compsPerRow); - } - dst += bytesPerRow; - } - } - return destBuffer; - } -} - - - -/** - * If we unpack colors from a luminance surface, we'll get pixel colors - * such as (l, l, l, a). - * When we call _mesa_pack_rgba_span_float(format=GL_LUMINANCE), that - * function will compute L=R+G+B before packing. The net effect is we'll - * accidentally store luminance values = 3*l. - * This function compensates for that by converting (aka rebasing) (l,l,l,a) - * to be (l,0,0,a). - * It's a similar story for other formats such as LUMINANCE_ALPHA, ALPHA - * and INTENSITY. - * - * Finally, we also need to do this when the actual surface format does - * not match the logical surface format. For example, suppose the user - * requests a GL_LUMINANCE texture but the driver stores it as RGBA. - * Again, we'll get pixel values like (l,l,l,a). - */ -void -_mesa_rebase_rgba_float(GLuint n, GLfloat rgba[][4], GLenum baseFormat) -{ - GLuint i; - - switch (baseFormat) { - case GL_ALPHA: - for (i = 0; i < n; i++) { - rgba[i][RCOMP] = 0.0F; - rgba[i][GCOMP] = 0.0F; - rgba[i][BCOMP] = 0.0F; - } - break; - case GL_INTENSITY: - /* fall-through */ - case GL_LUMINANCE: - for (i = 0; i < n; i++) { - rgba[i][GCOMP] = 0.0F; - rgba[i][BCOMP] = 0.0F; - rgba[i][ACOMP] = 1.0F; - } - break; - case GL_LUMINANCE_ALPHA: - for (i = 0; i < n; i++) { - rgba[i][GCOMP] = 0.0F; - rgba[i][BCOMP] = 0.0F; - } - break; - default: - /* no-op */ - ; - } -} - - -/** - * As above, but GLuint components. - */ -void -_mesa_rebase_rgba_uint(GLuint n, GLuint rgba[][4], GLenum baseFormat) -{ - GLuint i; - - switch (baseFormat) { - case GL_ALPHA: - for (i = 0; i < n; i++) { - rgba[i][RCOMP] = 0; - rgba[i][GCOMP] = 0; - rgba[i][BCOMP] = 0; - } - break; - case GL_INTENSITY: - /* fall-through */ - case GL_LUMINANCE: - for (i = 0; i < n; i++) { - rgba[i][GCOMP] = 0; - rgba[i][BCOMP] = 0; - rgba[i][ACOMP] = 1; - } - break; - case GL_LUMINANCE_ALPHA: - for (i = 0; i < n; i++) { - rgba[i][GCOMP] = 0; - rgba[i][BCOMP] = 0; - } - break; - default: - /* no-op */ - ; - } -} - - diff --git a/dll/opengl/mesa/main/pack.h b/dll/opengl/mesa/main/pack.h deleted file mode 100644 index c5ccc9f493a..00000000000 --- a/dll/opengl/mesa/main/pack.h +++ /dev/null @@ -1,143 +0,0 @@ -/* - * Mesa 3-D graphics library - * - * Copyright (C) 1999-2008 Brian Paul All Rights Reserved. - * Copyright (C) 1999-2010 VMware, Inc. All Rights Reserved. - * - * Permission is hereby granted, free of charge, to any person obtaining a - * copy of this software and associated documentation files (the "Software"), - * to deal in the Software without restriction, including without limitation - * the rights to use, copy, modify, merge, publish, distribute, sublicense, - * and/or sell copies of the Software, and to permit persons to whom the - * Software is furnished to do so, subject to the following conditions: - * - * The above copyright notice and this permission notice shall be included - * in all copies or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS - * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL - * THE AUTHORS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN - * AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN - * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. - */ - - -#ifndef PACK_H -#define PACK_H - - -#include "mtypes.h" - - -extern void -_mesa_unpack_polygon_stipple(const GLubyte *pattern, GLuint dest[32], - const struct gl_pixelstore_attrib *unpacking); - - -extern void -_mesa_pack_polygon_stipple(const GLuint pattern[32], GLubyte *dest, - const struct gl_pixelstore_attrib *packing); - - -extern GLvoid * -_mesa_unpack_bitmap(GLint width, GLint height, const GLubyte *pixels, - const struct gl_pixelstore_attrib *packing); - -extern void -_mesa_pack_bitmap(GLint width, GLint height, const GLubyte *source, - GLubyte *dest, const struct gl_pixelstore_attrib *packing); - - -extern void -_mesa_pack_rgba_span_float(struct gl_context *ctx, GLuint n, - GLfloat rgba[][4], - GLenum dstFormat, GLenum dstType, GLvoid *dstAddr, - const struct gl_pixelstore_attrib *dstPacking, - GLbitfield transferOps); - - -extern void -_mesa_unpack_color_span_ubyte(struct gl_context *ctx, - GLuint n, GLenum dstFormat, GLubyte dest[], - GLenum srcFormat, GLenum srcType, - const GLvoid *source, - const struct gl_pixelstore_attrib *srcPacking, - GLbitfield transferOps); - - -extern void -_mesa_unpack_color_span_float(struct gl_context *ctx, - GLuint n, GLenum dstFormat, GLfloat dest[], - GLenum srcFormat, GLenum srcType, - const GLvoid *source, - const struct gl_pixelstore_attrib *srcPacking, - GLbitfield transferOps); - -extern void -_mesa_unpack_color_span_uint(struct gl_context *ctx, - GLuint n, GLenum dstFormat, GLuint *dest, - GLenum srcFormat, GLenum srcType, - const GLvoid *source, - const struct gl_pixelstore_attrib *srcPacking); - -extern void -_mesa_unpack_index_span(struct gl_context *ctx, GLuint n, - GLenum dstType, GLvoid *dest, - GLenum srcType, const GLvoid *source, - const struct gl_pixelstore_attrib *srcPacking, - GLbitfield transferOps); - - -extern void -_mesa_pack_index_span(struct gl_context *ctx, GLuint n, - GLenum dstType, GLvoid *dest, const GLuint *source, - const struct gl_pixelstore_attrib *dstPacking, - GLbitfield transferOps); - - -extern void -_mesa_unpack_stencil_span(struct gl_context *ctx, GLuint n, - GLenum dstType, GLvoid *dest, - GLenum srcType, const GLvoid *source, - const struct gl_pixelstore_attrib *srcPacking, - GLbitfield transferOps); - -extern void -_mesa_pack_stencil_span(struct gl_context *ctx, GLuint n, - GLenum dstType, GLvoid *dest, const GLubyte *source, - const struct gl_pixelstore_attrib *dstPacking); - - -extern void -_mesa_unpack_depth_span(struct gl_context *ctx, GLuint n, - GLenum dstType, GLvoid *dest, GLuint depthMax, - GLenum srcType, const GLvoid *source, - const struct gl_pixelstore_attrib *srcPacking); - -extern void -_mesa_pack_depth_span(struct gl_context *ctx, GLuint n, GLvoid *dest, - GLenum dstType, const GLfloat *depthSpan, - const struct gl_pixelstore_attrib *dstPacking); - - -extern void * -_mesa_unpack_image(GLuint dimensions, - GLsizei width, GLsizei height, GLsizei depth, - GLenum format, GLenum type, const GLvoid *pixels, - const struct gl_pixelstore_attrib *unpack); - - -void -_mesa_pack_rgba_span_int(struct gl_context *ctx, GLuint n, GLuint rgba[][4], - GLenum dstFormat, GLenum dstType, - GLvoid *dstAddr); - - -extern void -_mesa_rebase_rgba_float(GLuint n, GLfloat rgba[][4], GLenum baseFormat); - -extern void -_mesa_rebase_rgba_uint(GLuint n, GLuint rgba[][4], GLenum baseFormat); - -#endif diff --git a/dll/opengl/mesa/main/pack_tmp.h b/dll/opengl/mesa/main/pack_tmp.h deleted file mode 100644 index 83b65572998..00000000000 --- a/dll/opengl/mesa/main/pack_tmp.h +++ /dev/null @@ -1,115 +0,0 @@ -/* - * Copyright © 2012 Intel Corporation - * - * Permission is hereby granted, free of charge, to any person obtaining a - * copy of this software and associated documentation files (the "Software"), - * to deal in the Software without restriction, including without limitation - * the rights to use, copy, modify, merge, publish, distribute, sublicense, - * and/or sell copies of the Software, and to permit persons to whom the - * Software is furnished to do so, subject to the following conditions: - * - * The above copyright notice and this permission notice (including the next - * paragraph) shall be included in all copies or substantial portions of the - * Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR - * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL - * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER - * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING - * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS - * IN THE SOFTWARE. - */ - -static void -FN_NAME(DST_TYPE *dst, - GLenum dstFormat, - SRC_TYPE rgba[][4], - int n) -{ - int i; - - switch (dstFormat) { - case GL_RED_INTEGER_EXT: - for (i=0;i - -#if FEATURE_pixel_transfer - - -/**********************************************************************/ -/***** glPixelZoom *****/ -/**********************************************************************/ - -static void GLAPIENTRY -_mesa_PixelZoom( GLfloat xfactor, GLfloat yfactor ) -{ - GET_CURRENT_CONTEXT(ctx); - - ASSERT_OUTSIDE_BEGIN_END(ctx); - - if (ctx->Pixel.ZoomX == xfactor && - ctx->Pixel.ZoomY == yfactor) - return; - - FLUSH_VERTICES(ctx, _NEW_PIXEL); - ctx->Pixel.ZoomX = xfactor; - ctx->Pixel.ZoomY = yfactor; -} - - - -/**********************************************************************/ -/***** glPixelMap *****/ -/**********************************************************************/ - -/** - * Return pointer to a pixelmap by name. - */ -static struct gl_pixelmap * -get_pixelmap(struct gl_context *ctx, GLenum map) -{ - switch (map) { - case GL_PIXEL_MAP_I_TO_I: - return &ctx->PixelMaps.ItoI; - case GL_PIXEL_MAP_S_TO_S: - return &ctx->PixelMaps.StoS; - case GL_PIXEL_MAP_I_TO_R: - return &ctx->PixelMaps.ItoR; - case GL_PIXEL_MAP_I_TO_G: - return &ctx->PixelMaps.ItoG; - case GL_PIXEL_MAP_I_TO_B: - return &ctx->PixelMaps.ItoB; - case GL_PIXEL_MAP_I_TO_A: - return &ctx->PixelMaps.ItoA; - case GL_PIXEL_MAP_R_TO_R: - return &ctx->PixelMaps.RtoR; - case GL_PIXEL_MAP_G_TO_G: - return &ctx->PixelMaps.GtoG; - case GL_PIXEL_MAP_B_TO_B: - return &ctx->PixelMaps.BtoB; - case GL_PIXEL_MAP_A_TO_A: - return &ctx->PixelMaps.AtoA; - default: - return NULL; - } -} - - -/** - * Helper routine used by the other _mesa_PixelMap() functions. - */ -static void -store_pixelmap(struct gl_context *ctx, GLenum map, GLsizei mapsize, - const GLfloat *values) -{ - GLint i; - struct gl_pixelmap *pm = get_pixelmap(ctx, map); - if (!pm) { - _mesa_error(ctx, GL_INVALID_ENUM, "glPixelMap(map)"); - return; - } - - switch (map) { - case GL_PIXEL_MAP_S_TO_S: - /* special case */ - ctx->PixelMaps.StoS.Size = mapsize; - for (i = 0; i < mapsize; i++) { - ctx->PixelMaps.StoS.Map[i] = (GLfloat)IROUND(values[i]); - } - break; - case GL_PIXEL_MAP_I_TO_I: - /* special case */ - ctx->PixelMaps.ItoI.Size = mapsize; - for (i = 0; i < mapsize; i++) { - ctx->PixelMaps.ItoI.Map[i] = values[i]; - } - break; - default: - /* general case */ - pm->Size = mapsize; - for (i = 0; i < mapsize; i++) { - GLfloat val = CLAMP(values[i], 0.0F, 1.0F); - pm->Map[i] = val; - pm->Map8[i] = (GLint) (val * 255.0F); - } - } -} - - -static void GLAPIENTRY -_mesa_PixelMapfv( GLenum map, GLsizei mapsize, const GLfloat *values ) -{ - GET_CURRENT_CONTEXT(ctx); - ASSERT_OUTSIDE_BEGIN_END(ctx); - - /* XXX someday, test against ctx->Const.MaxPixelMapTableSize */ - if (mapsize < 1 || mapsize > MAX_PIXEL_MAP_TABLE) { - _mesa_error( ctx, GL_INVALID_VALUE, "glPixelMapfv(mapsize)" ); - return; - } - - if (map >= GL_PIXEL_MAP_S_TO_S && map <= GL_PIXEL_MAP_I_TO_A) { - /* test that mapsize is a power of two */ - if (!_mesa_is_pow_two(mapsize)) { - _mesa_error( ctx, GL_INVALID_VALUE, "glPixelMapfv(mapsize)" ); - return; - } - } - - FLUSH_VERTICES(ctx, _NEW_PIXEL); - - if (!values) { - return; - } - - store_pixelmap(ctx, map, mapsize, values); -} - - -static void GLAPIENTRY -_mesa_PixelMapuiv(GLenum map, GLsizei mapsize, const GLuint *values ) -{ - GLfloat fvalues[MAX_PIXEL_MAP_TABLE]; - GET_CURRENT_CONTEXT(ctx); - ASSERT_OUTSIDE_BEGIN_END(ctx); - - if (mapsize < 1 || mapsize > MAX_PIXEL_MAP_TABLE) { - _mesa_error( ctx, GL_INVALID_VALUE, "glPixelMapuiv(mapsize)" ); - return; - } - - if (map >= GL_PIXEL_MAP_S_TO_S && map <= GL_PIXEL_MAP_I_TO_A) { - /* test that mapsize is a power of two */ - if (!_mesa_is_pow_two(mapsize)) { - _mesa_error( ctx, GL_INVALID_VALUE, "glPixelMapuiv(mapsize)" ); - return; - } - } - - FLUSH_VERTICES(ctx, _NEW_PIXEL); - - if (!values) { - return; - } - - /* convert to floats */ - if (map == GL_PIXEL_MAP_I_TO_I || map == GL_PIXEL_MAP_S_TO_S) { - GLint i; - for (i = 0; i < mapsize; i++) { - fvalues[i] = (GLfloat) values[i]; - } - } - else { - GLint i; - for (i = 0; i < mapsize; i++) { - fvalues[i] = UINT_TO_FLOAT( values[i] ); - } - } - - store_pixelmap(ctx, map, mapsize, fvalues); -} - - -static void GLAPIENTRY -_mesa_PixelMapusv(GLenum map, GLsizei mapsize, const GLushort *values ) -{ - GLfloat fvalues[MAX_PIXEL_MAP_TABLE]; - GET_CURRENT_CONTEXT(ctx); - ASSERT_OUTSIDE_BEGIN_END(ctx); - - if (mapsize < 1 || mapsize > MAX_PIXEL_MAP_TABLE) { - _mesa_error( ctx, GL_INVALID_VALUE, "glPixelMapusv(mapsize)" ); - return; - } - - if (map >= GL_PIXEL_MAP_S_TO_S && map <= GL_PIXEL_MAP_I_TO_A) { - /* test that mapsize is a power of two */ - if (!_mesa_is_pow_two(mapsize)) { - _mesa_error( ctx, GL_INVALID_VALUE, "glPixelMapuiv(mapsize)" ); - return; - } - } - - FLUSH_VERTICES(ctx, _NEW_PIXEL); - - if (!values) { - return; - } - - /* convert to floats */ - if (map == GL_PIXEL_MAP_I_TO_I || map == GL_PIXEL_MAP_S_TO_S) { - GLint i; - for (i = 0; i < mapsize; i++) { - fvalues[i] = (GLfloat) values[i]; - } - } - else { - GLint i; - for (i = 0; i < mapsize; i++) { - fvalues[i] = USHORT_TO_FLOAT( values[i] ); - } - } - - store_pixelmap(ctx, map, mapsize, fvalues); -} - - -static void GLAPIENTRY -_mesa_GetPixelMapfv( GLenum map, GLfloat *values ) -{ - GET_CURRENT_CONTEXT(ctx); - GLint mapsize, i; - const struct gl_pixelmap *pm; - - ASSERT_OUTSIDE_BEGIN_END(ctx); - - pm = get_pixelmap(ctx, map); - if (!pm) { - _mesa_error(ctx, GL_INVALID_ENUM, "glGetPixelMapfv(map)"); - return; - } - - mapsize = pm->Size; - - if (!values) { - return; - } - - if (map == GL_PIXEL_MAP_S_TO_S) { - /* special case */ - for (i = 0; i < mapsize; i++) { - values[i] = (GLfloat) ctx->PixelMaps.StoS.Map[i]; - } - } - else { - memcpy(values, pm->Map, mapsize * sizeof(GLfloat)); - } -} - - -static void GLAPIENTRY -_mesa_GetPixelMapuiv( GLenum map, GLuint *values ) -{ - GET_CURRENT_CONTEXT(ctx); - GLint mapsize, i; - const struct gl_pixelmap *pm; - - ASSERT_OUTSIDE_BEGIN_END(ctx); - - pm = get_pixelmap(ctx, map); - if (!pm) { - _mesa_error(ctx, GL_INVALID_ENUM, "glGetPixelMapuiv(map)"); - return; - } - - mapsize = pm->Size; - - if (!values) { - return; - } - - if (map == GL_PIXEL_MAP_S_TO_S) { - /* special case */ - memcpy(values, ctx->PixelMaps.StoS.Map, mapsize * sizeof(GLint)); - } - else { - for (i = 0; i < mapsize; i++) { - values[i] = FLOAT_TO_UINT( pm->Map[i] ); - } - } -} - - -static void GLAPIENTRY -_mesa_GetPixelMapusv( GLenum map, GLushort *values ) -{ - GET_CURRENT_CONTEXT(ctx); - GLint mapsize, i; - const struct gl_pixelmap *pm; - - ASSERT_OUTSIDE_BEGIN_END(ctx); - - pm = get_pixelmap(ctx, map); - if (!pm) { - _mesa_error(ctx, GL_INVALID_ENUM, "glGetPixelMapusv(map)"); - return; - } - - mapsize = pm->Size; - - if (!values) { - return; - } - - switch (map) { - /* special cases */ - case GL_PIXEL_MAP_I_TO_I: - for (i = 0; i < mapsize; i++) { - values[i] = (GLushort) CLAMP(ctx->PixelMaps.ItoI.Map[i], 0.0, 65535.); - } - break; - case GL_PIXEL_MAP_S_TO_S: - for (i = 0; i < mapsize; i++) { - values[i] = (GLushort) CLAMP(ctx->PixelMaps.StoS.Map[i], 0.0, 65535.); - } - break; - default: - for (i = 0; i < mapsize; i++) { - CLAMPED_FLOAT_TO_USHORT(values[i], pm->Map[i] ); - } - } -} - - -/**********************************************************************/ -/***** glPixelTransfer *****/ -/**********************************************************************/ - - -/* - * Implements glPixelTransfer[fi] whether called immediately or from a - * display list. - */ -void GLAPIENTRY -_mesa_PixelTransferf( GLenum pname, GLfloat param ) -{ - GET_CURRENT_CONTEXT(ctx); - ASSERT_OUTSIDE_BEGIN_END(ctx); - - switch (pname) { - case GL_MAP_COLOR: - if (ctx->Pixel.MapColorFlag == (param ? GL_TRUE : GL_FALSE)) - return; - FLUSH_VERTICES(ctx, _NEW_PIXEL); - ctx->Pixel.MapColorFlag = param ? GL_TRUE : GL_FALSE; - break; - case GL_MAP_STENCIL: - if (ctx->Pixel.MapStencilFlag == (param ? GL_TRUE : GL_FALSE)) - return; - FLUSH_VERTICES(ctx, _NEW_PIXEL); - ctx->Pixel.MapStencilFlag = param ? GL_TRUE : GL_FALSE; - break; - case GL_INDEX_SHIFT: - if (ctx->Pixel.IndexShift == (GLint) param) - return; - FLUSH_VERTICES(ctx, _NEW_PIXEL); - ctx->Pixel.IndexShift = (GLint) param; - break; - case GL_INDEX_OFFSET: - if (ctx->Pixel.IndexOffset == (GLint) param) - return; - FLUSH_VERTICES(ctx, _NEW_PIXEL); - ctx->Pixel.IndexOffset = (GLint) param; - break; - case GL_RED_SCALE: - if (ctx->Pixel.RedScale == param) - return; - FLUSH_VERTICES(ctx, _NEW_PIXEL); - ctx->Pixel.RedScale = param; - break; - case GL_RED_BIAS: - if (ctx->Pixel.RedBias == param) - return; - FLUSH_VERTICES(ctx, _NEW_PIXEL); - ctx->Pixel.RedBias = param; - break; - case GL_GREEN_SCALE: - if (ctx->Pixel.GreenScale == param) - return; - FLUSH_VERTICES(ctx, _NEW_PIXEL); - ctx->Pixel.GreenScale = param; - break; - case GL_GREEN_BIAS: - if (ctx->Pixel.GreenBias == param) - return; - FLUSH_VERTICES(ctx, _NEW_PIXEL); - ctx->Pixel.GreenBias = param; - break; - case GL_BLUE_SCALE: - if (ctx->Pixel.BlueScale == param) - return; - FLUSH_VERTICES(ctx, _NEW_PIXEL); - ctx->Pixel.BlueScale = param; - break; - case GL_BLUE_BIAS: - if (ctx->Pixel.BlueBias == param) - return; - FLUSH_VERTICES(ctx, _NEW_PIXEL); - ctx->Pixel.BlueBias = param; - break; - case GL_ALPHA_SCALE: - if (ctx->Pixel.AlphaScale == param) - return; - FLUSH_VERTICES(ctx, _NEW_PIXEL); - ctx->Pixel.AlphaScale = param; - break; - case GL_ALPHA_BIAS: - if (ctx->Pixel.AlphaBias == param) - return; - FLUSH_VERTICES(ctx, _NEW_PIXEL); - ctx->Pixel.AlphaBias = param; - break; - case GL_DEPTH_SCALE: - if (ctx->Pixel.DepthScale == param) - return; - FLUSH_VERTICES(ctx, _NEW_PIXEL); - ctx->Pixel.DepthScale = param; - break; - case GL_DEPTH_BIAS: - if (ctx->Pixel.DepthBias == param) - return; - FLUSH_VERTICES(ctx, _NEW_PIXEL); - ctx->Pixel.DepthBias = param; - break; - default: - _mesa_error( ctx, GL_INVALID_ENUM, "glPixelTransfer(pname)" ); - return; - } -} - - -static void GLAPIENTRY -_mesa_PixelTransferi( GLenum pname, GLint param ) -{ - _mesa_PixelTransferf( pname, (GLfloat) param ); -} - - - -/**********************************************************************/ -/***** State Management *****/ -/**********************************************************************/ - -/* - * Return a bitmask of IMAGE_*_BIT flags which to indicate which - * pixel transfer operations are enabled. - */ -static void -update_image_transfer_state(struct gl_context *ctx) -{ - GLuint mask = 0; - - if (ctx->Pixel.RedScale != 1.0F || ctx->Pixel.RedBias != 0.0F || - ctx->Pixel.GreenScale != 1.0F || ctx->Pixel.GreenBias != 0.0F || - ctx->Pixel.BlueScale != 1.0F || ctx->Pixel.BlueBias != 0.0F || - ctx->Pixel.AlphaScale != 1.0F || ctx->Pixel.AlphaBias != 0.0F) - mask |= IMAGE_SCALE_BIAS_BIT; - - if (ctx->Pixel.IndexShift || ctx->Pixel.IndexOffset) - mask |= IMAGE_SHIFT_OFFSET_BIT; - - if (ctx->Pixel.MapColorFlag) - mask |= IMAGE_MAP_COLOR_BIT; - - ctx->_ImageTransferState = mask; -} - - -/** - * Update mesa pixel transfer derived state. - */ -void _mesa_update_pixel( struct gl_context *ctx, GLuint new_state ) -{ - if (new_state & _NEW_PIXEL) - update_image_transfer_state(ctx); -} - - -void -_mesa_init_pixel_dispatch(struct _glapi_table *disp) -{ - SET_GetPixelMapfv(disp, _mesa_GetPixelMapfv); - SET_GetPixelMapuiv(disp, _mesa_GetPixelMapuiv); - SET_GetPixelMapusv(disp, _mesa_GetPixelMapusv); - SET_PixelMapfv(disp, _mesa_PixelMapfv); - SET_PixelMapuiv(disp, _mesa_PixelMapuiv); - SET_PixelMapusv(disp, _mesa_PixelMapusv); - SET_PixelTransferf(disp, _mesa_PixelTransferf); - SET_PixelTransferi(disp, _mesa_PixelTransferi); - SET_PixelZoom(disp, _mesa_PixelZoom); -} - - -#endif /* FEATURE_pixel_transfer */ - - -/**********************************************************************/ -/***** Initialization *****/ -/**********************************************************************/ - -static void -init_pixelmap(struct gl_pixelmap *map) -{ - map->Size = 1; - map->Map[0] = 0.0; - map->Map8[0] = 0; -} - - -/** - * Initialize the context's PIXEL attribute group. - */ -void -_mesa_init_pixel( struct gl_context *ctx ) -{ - /* Pixel group */ - ctx->Pixel.RedBias = 0.0; - ctx->Pixel.RedScale = 1.0; - ctx->Pixel.GreenBias = 0.0; - ctx->Pixel.GreenScale = 1.0; - ctx->Pixel.BlueBias = 0.0; - ctx->Pixel.BlueScale = 1.0; - ctx->Pixel.AlphaBias = 0.0; - ctx->Pixel.AlphaScale = 1.0; - ctx->Pixel.DepthBias = 0.0; - ctx->Pixel.DepthScale = 1.0; - ctx->Pixel.IndexOffset = 0; - ctx->Pixel.IndexShift = 0; - ctx->Pixel.ZoomX = 1.0; - ctx->Pixel.ZoomY = 1.0; - ctx->Pixel.MapColorFlag = GL_FALSE; - ctx->Pixel.MapStencilFlag = GL_FALSE; - init_pixelmap(&ctx->PixelMaps.StoS); - init_pixelmap(&ctx->PixelMaps.ItoI); - init_pixelmap(&ctx->PixelMaps.ItoR); - init_pixelmap(&ctx->PixelMaps.ItoG); - init_pixelmap(&ctx->PixelMaps.ItoB); - init_pixelmap(&ctx->PixelMaps.ItoA); - init_pixelmap(&ctx->PixelMaps.RtoR); - init_pixelmap(&ctx->PixelMaps.GtoG); - init_pixelmap(&ctx->PixelMaps.BtoB); - init_pixelmap(&ctx->PixelMaps.AtoA); - - if (ctx->Visual.doubleBufferMode) { - ctx->Pixel.ReadBuffer = GL_BACK; - } - else { - ctx->Pixel.ReadBuffer = GL_FRONT; - } - - /* Miscellaneous */ - ctx->_ImageTransferState = 0; -} diff --git a/dll/opengl/mesa/main/pixel.h b/dll/opengl/mesa/main/pixel.h deleted file mode 100644 index 797b0d9d624..00000000000 --- a/dll/opengl/mesa/main/pixel.h +++ /dev/null @@ -1,81 +0,0 @@ -/* - * Mesa 3-D graphics library - * Version: 7.1 - * - * Copyright (C) 1999-2008 Brian Paul All Rights Reserved. - * - * Permission is hereby granted, free of charge, to any person obtaining a - * copy of this software and associated documentation files (the "Software"), - * to deal in the Software without restriction, including without limitation - * the rights to use, copy, modify, merge, publish, distribute, sublicense, - * and/or sell copies of the Software, and to permit persons to whom the - * Software is furnished to do so, subject to the following conditions: - * - * The above copyright notice and this permission notice shall be included - * in all copies or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS - * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL - * BRIAN PAUL BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN - * AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN - * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. - */ - - -/** - * \file pixel.h - * Pixel operations. - */ - - -#ifndef PIXEL_H -#define PIXEL_H - - -#include "compiler.h" -#include "glheader.h" -#include "mfeatures.h" - -struct _glapi_table; -struct gl_context; - - -#if FEATURE_pixel_transfer - -extern void GLAPIENTRY -_mesa_PixelTransferf(GLenum pname, GLfloat param); - -extern void -_mesa_update_pixel( struct gl_context *ctx, GLuint newstate ); - -extern void -_mesa_init_pixel_dispatch( struct _glapi_table * disp ); - -#else /* FEATURE_pixel_transfer */ - -static inline void GLAPIENTRY -_mesa_PixelTransferf(GLenum pname, GLfloat param) -{ -} - - -static inline void -_mesa_update_pixel(struct gl_context *ctx, GLuint newstate) -{ -} - -static inline void -_mesa_init_pixel_dispatch(struct _glapi_table *disp) -{ -} - -#endif /* FEATURE_pixel_transfer */ - - -extern void -_mesa_init_pixel( struct gl_context * ctx ); - -/*@}*/ - -#endif /* PIXEL_H */ diff --git a/dll/opengl/mesa/main/pixelstore.c b/dll/opengl/mesa/main/pixelstore.c deleted file mode 100644 index ce07e633b26..00000000000 --- a/dll/opengl/mesa/main/pixelstore.c +++ /dev/null @@ -1,256 +0,0 @@ -/* - * Mesa 3-D graphics library - * Version: 7.1 - * - * Copyright (C) 1999-2008 Brian Paul All Rights Reserved. - * - * Permission is hereby granted, free of charge, to any person obtaining a - * copy of this software and associated documentation files (the "Software"), - * to deal in the Software without restriction, including without limitation - * the rights to use, copy, modify, merge, publish, distribute, sublicense, - * and/or sell copies of the Software, and to permit persons to whom the - * Software is furnished to do so, subject to the following conditions: - * - * The above copyright notice and this permission notice shall be included - * in all copies or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS - * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL - * BRIAN PAUL BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN - * AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN - * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. - */ - -/** - * \file pixelstore.c - * glPixelStore functions. - */ - -#include - -void GLAPIENTRY -_mesa_PixelStorei( GLenum pname, GLint param ) -{ - /* NOTE: this call can't be compiled into the display list */ - GET_CURRENT_CONTEXT(ctx); - ASSERT_OUTSIDE_BEGIN_END(ctx); - - switch (pname) { - case GL_PACK_SWAP_BYTES: - if (param == (GLint)ctx->Pack.SwapBytes) - return; - FLUSH_VERTICES(ctx, _NEW_PACKUNPACK); - ctx->Pack.SwapBytes = param ? GL_TRUE : GL_FALSE; - break; - case GL_PACK_LSB_FIRST: - if (param == (GLint)ctx->Pack.LsbFirst) - return; - FLUSH_VERTICES(ctx, _NEW_PACKUNPACK); - ctx->Pack.LsbFirst = param ? GL_TRUE : GL_FALSE; - break; - case GL_PACK_ROW_LENGTH: - if (param<0) { - _mesa_error( ctx, GL_INVALID_VALUE, "glPixelStore(param)" ); - return; - } - if (ctx->Pack.RowLength == param) - return; - FLUSH_VERTICES(ctx, _NEW_PACKUNPACK); - ctx->Pack.RowLength = param; - break; - case GL_PACK_IMAGE_HEIGHT: - if (param<0) { - _mesa_error( ctx, GL_INVALID_VALUE, "glPixelStore(param)" ); - return; - } - if (ctx->Pack.ImageHeight == param) - return; - FLUSH_VERTICES(ctx, _NEW_PACKUNPACK); - ctx->Pack.ImageHeight = param; - break; - case GL_PACK_SKIP_PIXELS: - if (param<0) { - _mesa_error( ctx, GL_INVALID_VALUE, "glPixelStore(param)" ); - return; - } - if (ctx->Pack.SkipPixels == param) - return; - FLUSH_VERTICES(ctx, _NEW_PACKUNPACK); - ctx->Pack.SkipPixels = param; - break; - case GL_PACK_SKIP_ROWS: - if (param<0) { - _mesa_error( ctx, GL_INVALID_VALUE, "glPixelStore(param)" ); - return; - } - if (ctx->Pack.SkipRows == param) - return; - FLUSH_VERTICES(ctx, _NEW_PACKUNPACK); - ctx->Pack.SkipRows = param; - break; - case GL_PACK_SKIP_IMAGES: - if (param<0) { - _mesa_error( ctx, GL_INVALID_VALUE, "glPixelStore(param)" ); - return; - } - if (ctx->Pack.SkipImages == param) - return; - FLUSH_VERTICES(ctx, _NEW_PACKUNPACK); - ctx->Pack.SkipImages = param; - break; - case GL_PACK_ALIGNMENT: - if (param!=1 && param!=2 && param!=4 && param!=8) { - _mesa_error( ctx, GL_INVALID_VALUE, "glPixelStore(param)" ); - return; - } - if (ctx->Pack.Alignment == param) - return; - FLUSH_VERTICES(ctx, _NEW_PACKUNPACK); - ctx->Pack.Alignment = param; - break; - case GL_PACK_INVERT_MESA: - if (!ctx->Extensions.MESA_pack_invert) { - _mesa_error( ctx, GL_INVALID_ENUM, "glPixelstore(pname)" ); - return; - } - if (ctx->Pack.Invert == param) - return; - FLUSH_VERTICES(ctx, _NEW_PACKUNPACK); - ctx->Pack.Invert = param; - break; - - case GL_UNPACK_SWAP_BYTES: - if (param == (GLint)ctx->Unpack.SwapBytes) - return; - if ((GLint)ctx->Unpack.SwapBytes == param) - return; - FLUSH_VERTICES(ctx, _NEW_PACKUNPACK); - ctx->Unpack.SwapBytes = param ? GL_TRUE : GL_FALSE; - break; - case GL_UNPACK_LSB_FIRST: - if (param == (GLint)ctx->Unpack.LsbFirst) - return; - if ((GLint)ctx->Unpack.LsbFirst == param) - return; - FLUSH_VERTICES(ctx, _NEW_PACKUNPACK); - ctx->Unpack.LsbFirst = param ? GL_TRUE : GL_FALSE; - break; - case GL_UNPACK_ROW_LENGTH: - if (param<0) { - _mesa_error( ctx, GL_INVALID_VALUE, "glPixelStore(param)" ); - return; - } - if (ctx->Unpack.RowLength == param) - return; - FLUSH_VERTICES(ctx, _NEW_PACKUNPACK); - ctx->Unpack.RowLength = param; - break; - case GL_UNPACK_IMAGE_HEIGHT: - if (param<0) { - _mesa_error( ctx, GL_INVALID_VALUE, "glPixelStore(param)" ); - return; - } - if (ctx->Unpack.ImageHeight == param) - return; - - FLUSH_VERTICES(ctx, _NEW_PACKUNPACK); - ctx->Unpack.ImageHeight = param; - break; - case GL_UNPACK_SKIP_PIXELS: - if (param<0) { - _mesa_error( ctx, GL_INVALID_VALUE, "glPixelStore(param)" ); - return; - } - if (ctx->Unpack.SkipPixels == param) - return; - FLUSH_VERTICES(ctx, _NEW_PACKUNPACK); - ctx->Unpack.SkipPixels = param; - break; - case GL_UNPACK_SKIP_ROWS: - if (param<0) { - _mesa_error( ctx, GL_INVALID_VALUE, "glPixelStore(param)" ); - return; - } - if (ctx->Unpack.SkipRows == param) - return; - FLUSH_VERTICES(ctx, _NEW_PACKUNPACK); - ctx->Unpack.SkipRows = param; - break; - case GL_UNPACK_SKIP_IMAGES: - if (param < 0) { - _mesa_error( ctx, GL_INVALID_VALUE, "glPixelStore(param)" ); - return; - } - if (ctx->Unpack.SkipImages == param) - return; - FLUSH_VERTICES(ctx, _NEW_PACKUNPACK); - ctx->Unpack.SkipImages = param; - break; - case GL_UNPACK_ALIGNMENT: - if (param!=1 && param!=2 && param!=4 && param!=8) { - _mesa_error( ctx, GL_INVALID_VALUE, "glPixelStore" ); - return; - } - if (ctx->Unpack.Alignment == param) - return; - FLUSH_VERTICES(ctx, _NEW_PACKUNPACK); - ctx->Unpack.Alignment = param; - break; - default: - _mesa_error( ctx, GL_INVALID_ENUM, "glPixelStore" ); - return; - } -} - - -void GLAPIENTRY -_mesa_PixelStoref( GLenum pname, GLfloat param ) -{ - _mesa_PixelStorei( pname, IROUND(param) ); -} - - - -/** - * Initialize the context's pixel store state. - */ -void -_mesa_init_pixelstore( struct gl_context *ctx ) -{ - /* Pixel transfer */ - ctx->Pack.Alignment = 4; - ctx->Pack.RowLength = 0; - ctx->Pack.ImageHeight = 0; - ctx->Pack.SkipPixels = 0; - ctx->Pack.SkipRows = 0; - ctx->Pack.SkipImages = 0; - ctx->Pack.SwapBytes = GL_FALSE; - ctx->Pack.LsbFirst = GL_FALSE; - ctx->Pack.Invert = GL_FALSE; - ctx->Unpack.Alignment = 4; - ctx->Unpack.RowLength = 0; - ctx->Unpack.ImageHeight = 0; - ctx->Unpack.SkipPixels = 0; - ctx->Unpack.SkipRows = 0; - ctx->Unpack.SkipImages = 0; - ctx->Unpack.SwapBytes = GL_FALSE; - ctx->Unpack.LsbFirst = GL_FALSE; - ctx->Unpack.Invert = GL_FALSE; - - /* - * _mesa_unpack_image() returns image data in this format. When we - * execute image commands (glDrawPixels(), glTexImage(), etc) from - * within display lists we have to be sure to set the current - * unpacking parameters to these values! - */ - ctx->DefaultPacking.Alignment = 1; - ctx->DefaultPacking.RowLength = 0; - ctx->DefaultPacking.SkipPixels = 0; - ctx->DefaultPacking.SkipRows = 0; - ctx->DefaultPacking.ImageHeight = 0; - ctx->DefaultPacking.SkipImages = 0; - ctx->DefaultPacking.SwapBytes = GL_FALSE; - ctx->DefaultPacking.LsbFirst = GL_FALSE; - ctx->DefaultPacking.Invert = GL_FALSE; -} diff --git a/dll/opengl/mesa/main/pixelstore.h b/dll/opengl/mesa/main/pixelstore.h deleted file mode 100644 index eb508197490..00000000000 --- a/dll/opengl/mesa/main/pixelstore.h +++ /dev/null @@ -1,52 +0,0 @@ -/* - * Mesa 3-D graphics library - * Version: 7.1 - * - * Copyright (C) 1999-2008 Brian Paul All Rights Reserved. - * - * Permission is hereby granted, free of charge, to any person obtaining a - * copy of this software and associated documentation files (the "Software"), - * to deal in the Software without restriction, including without limitation - * the rights to use, copy, modify, merge, publish, distribute, sublicense, - * and/or sell copies of the Software, and to permit persons to whom the - * Software is furnished to do so, subject to the following conditions: - * - * The above copyright notice and this permission notice shall be included - * in all copies or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS - * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL - * BRIAN PAUL BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN - * AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN - * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. - */ - -/** - * \file pixelstore.h - * glPixelStore functions. - */ - - -#ifndef PIXELSTORE_H -#define PIXELSTORE_H - - -#include "glheader.h" - -struct gl_context; - - -extern void GLAPIENTRY -_mesa_PixelStorei( GLenum pname, GLint param ); - - -extern void GLAPIENTRY -_mesa_PixelStoref( GLenum pname, GLfloat param ); - - -extern void -_mesa_init_pixelstore( struct gl_context *ctx ); - - -#endif diff --git a/dll/opengl/mesa/main/pixeltransfer.c b/dll/opengl/mesa/main/pixeltransfer.c deleted file mode 100644 index 378f7a6993b..00000000000 --- a/dll/opengl/mesa/main/pixeltransfer.c +++ /dev/null @@ -1,299 +0,0 @@ -/* - * Mesa 3-D graphics library - * - * Copyright (C) 1999-2008 Brian Paul All Rights Reserved. - * Copyright (C) 2009-2010 VMware, Inc. All Rights Reserved. - * - * Permission is hereby granted, free of charge, to any person obtaining a - * copy of this software and associated documentation files (the "Software"), - * to deal in the Software without restriction, including without limitation - * the rights to use, copy, modify, merge, publish, distribute, sublicense, - * and/or sell copies of the Software, and to permit persons to whom the - * Software is furnished to do so, subject to the following conditions: - * - * The above copyright notice and this permission notice shall be included - * in all copies or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS - * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL - * THE AUTHORS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN - * AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN - * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. - */ - -/** - * \file pixeltransfer.c - * Pixel transfer operations (scale, bias, table lookups, etc) - */ - -#include - -/* - * Apply scale and bias factors to an array of RGBA pixels. - */ -void -_mesa_scale_and_bias_rgba(GLuint n, GLfloat rgba[][4], - GLfloat rScale, GLfloat gScale, - GLfloat bScale, GLfloat aScale, - GLfloat rBias, GLfloat gBias, - GLfloat bBias, GLfloat aBias) -{ - if (rScale != 1.0 || rBias != 0.0) { - GLuint i; - for (i = 0; i < n; i++) { - rgba[i][RCOMP] = rgba[i][RCOMP] * rScale + rBias; - } - } - if (gScale != 1.0 || gBias != 0.0) { - GLuint i; - for (i = 0; i < n; i++) { - rgba[i][GCOMP] = rgba[i][GCOMP] * gScale + gBias; - } - } - if (bScale != 1.0 || bBias != 0.0) { - GLuint i; - for (i = 0; i < n; i++) { - rgba[i][BCOMP] = rgba[i][BCOMP] * bScale + bBias; - } - } - if (aScale != 1.0 || aBias != 0.0) { - GLuint i; - for (i = 0; i < n; i++) { - rgba[i][ACOMP] = rgba[i][ACOMP] * aScale + aBias; - } - } -} - - -/* - * Apply pixel mapping to an array of floating point RGBA pixels. - */ -void -_mesa_map_rgba( const struct gl_context *ctx, GLuint n, GLfloat rgba[][4] ) -{ - const GLfloat rscale = (GLfloat) (ctx->PixelMaps.RtoR.Size - 1); - const GLfloat gscale = (GLfloat) (ctx->PixelMaps.GtoG.Size - 1); - const GLfloat bscale = (GLfloat) (ctx->PixelMaps.BtoB.Size - 1); - const GLfloat ascale = (GLfloat) (ctx->PixelMaps.AtoA.Size - 1); - const GLfloat *rMap = ctx->PixelMaps.RtoR.Map; - const GLfloat *gMap = ctx->PixelMaps.GtoG.Map; - const GLfloat *bMap = ctx->PixelMaps.BtoB.Map; - const GLfloat *aMap = ctx->PixelMaps.AtoA.Map; - GLuint i; - for (i=0;iPixelMaps.ItoR.Size - 1; - GLuint gmask = ctx->PixelMaps.ItoG.Size - 1; - GLuint bmask = ctx->PixelMaps.ItoB.Size - 1; - GLuint amask = ctx->PixelMaps.ItoA.Size - 1; - const GLfloat *rMap = ctx->PixelMaps.ItoR.Map; - const GLfloat *gMap = ctx->PixelMaps.ItoG.Map; - const GLfloat *bMap = ctx->PixelMaps.ItoB.Map; - const GLfloat *aMap = ctx->PixelMaps.ItoA.Map; - GLuint i; - for (i=0;iPixelMaps.ItoR.Size - 1; - GLuint gmask = ctx->PixelMaps.ItoG.Size - 1; - GLuint bmask = ctx->PixelMaps.ItoB.Size - 1; - GLuint amask = ctx->PixelMaps.ItoA.Size - 1; - const GLubyte *rMap = ctx->PixelMaps.ItoR.Map8; - const GLubyte *gMap = ctx->PixelMaps.ItoG.Map8; - const GLubyte *bMap = ctx->PixelMaps.ItoB.Map8; - const GLubyte *aMap = ctx->PixelMaps.ItoA.Map8; - GLuint i; - for (i=0;iPixel.DepthScale; - const GLfloat bias = ctx->Pixel.DepthBias; - GLuint i; - for (i = 0; i < n; i++) { - GLfloat d = depthValues[i] * scale + bias; - depthValues[i] = CLAMP(d, 0.0F, 1.0F); - } -} - - -void -_mesa_scale_and_bias_depth_uint(const struct gl_context *ctx, GLuint n, - GLuint depthValues[]) -{ - const GLdouble max = (double) 0xffffffff; - const GLdouble scale = ctx->Pixel.DepthScale; - const GLdouble bias = ctx->Pixel.DepthBias * max; - GLuint i; - for (i = 0; i < n; i++) { - GLdouble d = (GLdouble) depthValues[i] * scale + bias; - d = CLAMP(d, 0.0, max); - depthValues[i] = (GLuint) d; - } -} - -/** - * Apply various pixel transfer operations to an array of RGBA pixels - * as indicated by the transferOps bitmask - */ -void -_mesa_apply_rgba_transfer_ops(struct gl_context *ctx, GLbitfield transferOps, - GLuint n, GLfloat rgba[][4]) -{ - /* scale & bias */ - if (transferOps & IMAGE_SCALE_BIAS_BIT) { - _mesa_scale_and_bias_rgba(n, rgba, - ctx->Pixel.RedScale, ctx->Pixel.GreenScale, - ctx->Pixel.BlueScale, ctx->Pixel.AlphaScale, - ctx->Pixel.RedBias, ctx->Pixel.GreenBias, - ctx->Pixel.BlueBias, ctx->Pixel.AlphaBias); - } - /* color map lookup */ - if (transferOps & IMAGE_MAP_COLOR_BIT) { - _mesa_map_rgba( ctx, n, rgba ); - } - - /* clamping to [0,1] */ - if (transferOps & IMAGE_CLAMP_BIT) { - GLuint i; - for (i = 0; i < n; i++) { - rgba[i][RCOMP] = CLAMP(rgba[i][RCOMP], 0.0F, 1.0F); - rgba[i][GCOMP] = CLAMP(rgba[i][GCOMP], 0.0F, 1.0F); - rgba[i][BCOMP] = CLAMP(rgba[i][BCOMP], 0.0F, 1.0F); - rgba[i][ACOMP] = CLAMP(rgba[i][ACOMP], 0.0F, 1.0F); - } - } -} - - -/* - * Apply color index shift and offset to an array of pixels. - */ -void -_mesa_shift_and_offset_ci(const struct gl_context *ctx, - GLuint n, GLuint indexes[]) -{ - GLint shift = ctx->Pixel.IndexShift; - GLint offset = ctx->Pixel.IndexOffset; - GLuint i; - if (shift > 0) { - for (i=0;i> shift) + offset; - } - } - else { - for (i=0;iPixelMaps.ItoI.Size - 1; - GLuint i; - for (i = 0; i < n; i++) { - const GLuint j = indexes[i] & mask; - indexes[i] = IROUND(ctx->PixelMaps.ItoI.Map[j]); - } - } -} - - -/** - * Apply stencil index shift, offset and table lookup to an array - * of stencil values. - */ -void -_mesa_apply_stencil_transfer_ops(const struct gl_context *ctx, GLuint n, - GLubyte stencil[]) -{ - if (ctx->Pixel.IndexShift != 0 || ctx->Pixel.IndexOffset != 0) { - const GLint offset = ctx->Pixel.IndexOffset; - GLint shift = ctx->Pixel.IndexShift; - GLuint i; - if (shift > 0) { - for (i = 0; i < n; i++) { - stencil[i] = (stencil[i] << shift) + offset; - } - } - else if (shift < 0) { - shift = -shift; - for (i = 0; i < n; i++) { - stencil[i] = (stencil[i] >> shift) + offset; - } - } - else { - for (i = 0; i < n; i++) { - stencil[i] = stencil[i] + offset; - } - } - } - if (ctx->Pixel.MapStencilFlag) { - GLuint mask = ctx->PixelMaps.StoS.Size - 1; - GLuint i; - for (i = 0; i < n; i++) { - stencil[i] = (GLubyte) ctx->PixelMaps.StoS.Map[ stencil[i] & mask ]; - } - } -} diff --git a/dll/opengl/mesa/main/pixeltransfer.h b/dll/opengl/mesa/main/pixeltransfer.h deleted file mode 100644 index a8c14757ffa..00000000000 --- a/dll/opengl/mesa/main/pixeltransfer.h +++ /dev/null @@ -1,81 +0,0 @@ -/* - * Mesa 3-D graphics library - * - * Copyright (C) 1999-2008 Brian Paul All Rights Reserved. - * Copyright (C) 2009-2010 VMware, Inc. All Rights Reserved. - * - * Permission is hereby granted, free of charge, to any person obtaining a - * copy of this software and associated documentation files (the "Software"), - * to deal in the Software without restriction, including without limitation - * the rights to use, copy, modify, merge, publish, distribute, sublicense, - * and/or sell copies of the Software, and to permit persons to whom the - * Software is furnished to do so, subject to the following conditions: - * - * The above copyright notice and this permission notice shall be included - * in all copies or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS - * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL - * THE AUTHORS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN - * AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN - * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. - */ - - -#ifndef PIXELTRANSFER_H -#define PIXELTRANSFER_H - - -#include "mtypes.h" - - -extern void -_mesa_scale_and_bias_rgba(GLuint n, GLfloat rgba[][4], - GLfloat rScale, GLfloat gScale, - GLfloat bScale, GLfloat aScale, - GLfloat rBias, GLfloat gBias, - GLfloat bBias, GLfloat aBias); - -extern void -_mesa_map_rgba(const struct gl_context *ctx, GLuint n, GLfloat rgba[][4]); - -extern void -_mesa_map_ci_to_rgba(const struct gl_context *ctx, - GLuint n, const GLuint index[], GLfloat rgba[][4]); - - -extern void -_mesa_map_ci8_to_rgba8(const struct gl_context *ctx, - GLuint n, const GLubyte index[], - GLubyte rgba[][4]); - - -extern void -_mesa_scale_and_bias_depth(const struct gl_context *ctx, GLuint n, - GLfloat depthValues[]); - -extern void -_mesa_scale_and_bias_depth_uint(const struct gl_context *ctx, GLuint n, - GLuint depthValues[]); - -extern void -_mesa_apply_rgba_transfer_ops(struct gl_context *ctx, GLbitfield transferOps, - GLuint n, GLfloat rgba[][4]); - -extern void -_mesa_shift_and_offset_ci(const struct gl_context *ctx, - GLuint n, GLuint indexes[]); - -extern void -_mesa_apply_ci_transfer_ops(const struct gl_context *ctx, - GLbitfield transferOps, - GLuint n, GLuint indexes[]); - - -extern void -_mesa_apply_stencil_transfer_ops(const struct gl_context *ctx, GLuint n, - GLubyte stencil[]); - - -#endif diff --git a/dll/opengl/mesa/main/points.c b/dll/opengl/mesa/main/points.c deleted file mode 100644 index 7006643605e..00000000000 --- a/dll/opengl/mesa/main/points.c +++ /dev/null @@ -1,262 +0,0 @@ -/** - * \file points.c - * Point operations. - */ - -/* - * Mesa 3-D graphics library - * Version: 7.1 - * - * Copyright (C) 1999-2007 Brian Paul All Rights Reserved. - * - * Permission is hereby granted, free of charge, to any person obtaining a - * copy of this software and associated documentation files (the "Software"), - * to deal in the Software without restriction, including without limitation - * the rights to use, copy, modify, merge, publish, distribute, sublicense, - * and/or sell copies of the Software, and to permit persons to whom the - * Software is furnished to do so, subject to the following conditions: - * - * The above copyright notice and this permission notice shall be included - * in all copies or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS - * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL - * BRIAN PAUL BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN - * AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN - * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. - */ - -#include - -/** - * Set current point size. - * \param size point diameter in pixels - * \sa glPointSize(). - */ -void GLAPIENTRY -_mesa_PointSize( GLfloat size ) -{ - GET_CURRENT_CONTEXT(ctx); - ASSERT_OUTSIDE_BEGIN_END(ctx); - - if (size <= 0.0) { - _mesa_error( ctx, GL_INVALID_VALUE, "glPointSize" ); - return; - } - - if (ctx->Point.Size == size) - return; - - FLUSH_VERTICES(ctx, _NEW_POINT); - ctx->Point.Size = size; - - if (ctx->Driver.PointSize) - ctx->Driver.PointSize(ctx, size); -} - - -#if _HAVE_FULL_GL - - -void GLAPIENTRY -_mesa_PointParameteri( GLenum pname, GLint param ) -{ - GLfloat p[3]; - p[0] = (GLfloat) param; - p[1] = p[2] = 0.0F; - _mesa_PointParameterfv(pname, p); -} - - -void GLAPIENTRY -_mesa_PointParameteriv( GLenum pname, const GLint *params ) -{ - GLfloat p[3]; - p[0] = (GLfloat) params[0]; - if (pname == GL_DISTANCE_ATTENUATION_EXT) { - p[1] = (GLfloat) params[1]; - p[2] = (GLfloat) params[2]; - } - _mesa_PointParameterfv(pname, p); -} - - -void GLAPIENTRY -_mesa_PointParameterf( GLenum pname, GLfloat param) -{ - GLfloat p[3]; - p[0] = param; - p[1] = p[2] = 0.0F; - _mesa_PointParameterfv(pname, p); -} - - -void GLAPIENTRY -_mesa_PointParameterfv( GLenum pname, const GLfloat *params) -{ - GET_CURRENT_CONTEXT(ctx); - ASSERT_OUTSIDE_BEGIN_END(ctx); - - switch (pname) { - case GL_DISTANCE_ATTENUATION_EXT: - if (ctx->Extensions.EXT_point_parameters) { - if (TEST_EQ_3V(ctx->Point.Params, params)) - return; - FLUSH_VERTICES(ctx, _NEW_POINT); - COPY_3V(ctx->Point.Params, params); - ctx->Point._Attenuated = (ctx->Point.Params[0] != 1.0 || - ctx->Point.Params[1] != 0.0 || - ctx->Point.Params[2] != 0.0); - - if (ctx->Point._Attenuated) - ctx->_TriangleCaps |= DD_POINT_ATTEN; - else - ctx->_TriangleCaps &= ~DD_POINT_ATTEN; - } - else { - _mesa_error(ctx, GL_INVALID_ENUM, - "glPointParameterf[v]{EXT,ARB}(pname)"); - return; - } - break; - case GL_POINT_SIZE_MIN_EXT: - if (ctx->Extensions.EXT_point_parameters) { - if (params[0] < 0.0F) { - _mesa_error( ctx, GL_INVALID_VALUE, - "glPointParameterf[v]{EXT,ARB}(param)" ); - return; - } - if (ctx->Point.MinSize == params[0]) - return; - FLUSH_VERTICES(ctx, _NEW_POINT); - ctx->Point.MinSize = params[0]; - } - else { - _mesa_error(ctx, GL_INVALID_ENUM, - "glPointParameterf[v]{EXT,ARB}(pname)"); - return; - } - break; - case GL_POINT_SIZE_MAX_EXT: - if (ctx->Extensions.EXT_point_parameters) { - if (params[0] < 0.0F) { - _mesa_error( ctx, GL_INVALID_VALUE, - "glPointParameterf[v]{EXT,ARB}(param)" ); - return; - } - if (ctx->Point.MaxSize == params[0]) - return; - FLUSH_VERTICES(ctx, _NEW_POINT); - ctx->Point.MaxSize = params[0]; - } - else { - _mesa_error(ctx, GL_INVALID_ENUM, - "glPointParameterf[v]{EXT,ARB}(pname)"); - return; - } - break; - case GL_POINT_FADE_THRESHOLD_SIZE_EXT: - if (ctx->Extensions.EXT_point_parameters) { - if (params[0] < 0.0F) { - _mesa_error( ctx, GL_INVALID_VALUE, - "glPointParameterf[v]{EXT,ARB}(param)" ); - return; - } - if (ctx->Point.Threshold == params[0]) - return; - FLUSH_VERTICES(ctx, _NEW_POINT); - ctx->Point.Threshold = params[0]; - } - else { - _mesa_error(ctx, GL_INVALID_ENUM, - "glPointParameterf[v]{EXT,ARB}(pname)"); - return; - } - break; - case GL_POINT_SPRITE_R_MODE_NV: - /* This is one area where ARB_point_sprite and NV_point_sprite - * differ. In ARB_point_sprite the POINT_SPRITE_R_MODE is - * always ZERO. NV_point_sprite adds the S and R modes. - */ - if (ctx->Extensions.NV_point_sprite) { - GLenum value = (GLenum) params[0]; - if (value != GL_ZERO && value != GL_S && value != GL_R) { - _mesa_error(ctx, GL_INVALID_VALUE, - "glPointParameterf[v]{EXT,ARB}(param)"); - return; - } - if (ctx->Point.SpriteRMode == value) - return; - FLUSH_VERTICES(ctx, _NEW_POINT); - ctx->Point.SpriteRMode = value; - } - else { - _mesa_error(ctx, GL_INVALID_ENUM, - "glPointParameterf[v]{EXT,ARB}(pname)"); - return; - } - break; - case GL_POINT_SPRITE_COORD_ORIGIN: - /* This is not completely correct. GL_POINT_SPRITE_COORD_ORIGIN was - * added to point sprites when the extension was merged into OpenGL - * 2.0. It is expected that an implementation supporting OpenGL 1.4 - * and GL_ARB_point_sprite will generate an error here. - */ - if (ctx->Extensions.ARB_point_sprite) { - GLenum value = (GLenum) params[0]; - if (value != GL_LOWER_LEFT && value != GL_UPPER_LEFT) { - _mesa_error(ctx, GL_INVALID_VALUE, - "glPointParameterf[v]{EXT,ARB}(param)"); - return; - } - if (ctx->Point.SpriteOrigin == value) - return; - FLUSH_VERTICES(ctx, _NEW_POINT); - ctx->Point.SpriteOrigin = value; - } - else { - _mesa_error(ctx, GL_INVALID_ENUM, - "glPointParameterf[v]{EXT,ARB}(pname)"); - return; - } - break; - default: - _mesa_error( ctx, GL_INVALID_ENUM, - "glPointParameterf[v]{EXT,ARB}(pname)" ); - return; - } - - if (ctx->Driver.PointParameterfv) - (*ctx->Driver.PointParameterfv)(ctx, pname, params); -} -#endif - - - -/** - * Initialize the context point state. - * - * \param ctx GL context. - * - * Initializes __struct gl_contextRec::Point and point related constants in - * __struct gl_contextRec::Const. - */ -void -_mesa_init_point(struct gl_context *ctx) -{ - ctx->Point.SmoothFlag = GL_FALSE; - ctx->Point.Size = 1.0; - ctx->Point.Params[0] = 1.0; - ctx->Point.Params[1] = 0.0; - ctx->Point.Params[2] = 0.0; - ctx->Point._Attenuated = GL_FALSE; - ctx->Point.MinSize = 0.0; - ctx->Point.MaxSize - = MAX2(ctx->Const.MaxPointSize, ctx->Const.MaxPointSizeAA); - ctx->Point.Threshold = 1.0; - ctx->Point.PointSprite = GL_FALSE; /* GL_ARB/NV_point_sprite */ - ctx->Point.SpriteRMode = GL_ZERO; /* GL_NV_point_sprite (only!) */ - ctx->Point.SpriteOrigin = GL_UPPER_LEFT; /* GL_ARB_point_sprite */ - ctx->Point.CoordReplace = GL_FALSE; /* GL_ARB/NV_point_sprite */ -} diff --git a/dll/opengl/mesa/main/points.h b/dll/opengl/mesa/main/points.h deleted file mode 100644 index 306a8a572f9..00000000000 --- a/dll/opengl/mesa/main/points.h +++ /dev/null @@ -1,59 +0,0 @@ -/** - * \file points.h - * Point operations. - */ - -/* - * Mesa 3-D graphics library - * Version: 6.5 - * - * Copyright (C) 1999-2005 Brian Paul All Rights Reserved. - * - * Permission is hereby granted, free of charge, to any person obtaining a - * copy of this software and associated documentation files (the "Software"), - * to deal in the Software without restriction, including without limitation - * the rights to use, copy, modify, merge, publish, distribute, sublicense, - * and/or sell copies of the Software, and to permit persons to whom the - * Software is furnished to do so, subject to the following conditions: - * - * The above copyright notice and this permission notice shall be included - * in all copies or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS - * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL - * BRIAN PAUL BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN - * AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN - * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. - */ - - -#ifndef POINTS_H -#define POINTS_H - - -#include "glheader.h" - -struct gl_context; - - -extern void GLAPIENTRY -_mesa_PointSize( GLfloat size ); - -extern void GLAPIENTRY -_mesa_PointParameteri( GLenum pname, GLint param ); - -extern void GLAPIENTRY -_mesa_PointParameteriv( GLenum pname, const GLint *params ); - -extern void GLAPIENTRY -_mesa_PointParameterf( GLenum pname, GLfloat param ); - -extern void GLAPIENTRY -_mesa_PointParameterfv( GLenum pname, const GLfloat *params ); - -extern void -_mesa_init_point( struct gl_context * ctx ); - - -#endif diff --git a/dll/opengl/mesa/main/polygon.c b/dll/opengl/mesa/main/polygon.c deleted file mode 100644 index 6d2dfeee7ca..00000000000 --- a/dll/opengl/mesa/main/polygon.c +++ /dev/null @@ -1,299 +0,0 @@ -/** - * \file polygon.c - * Polygon operations. - */ - -/* - * Mesa 3-D graphics library - * Version: 6.5.1 - * - * Copyright (C) 1999-2006 Brian Paul All Rights Reserved. - * - * Permission is hereby granted, free of charge, to any person obtaining a - * copy of this software and associated documentation files (the "Software"), - * to deal in the Software without restriction, including without limitation - * the rights to use, copy, modify, merge, publish, distribute, sublicense, - * and/or sell copies of the Software, and to permit persons to whom the - * Software is furnished to do so, subject to the following conditions: - * - * The above copyright notice and this permission notice shall be included - * in all copies or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS - * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL - * BRIAN PAUL BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN - * AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN - * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. - */ - -#include - -/** - * Specify whether to cull front- or back-facing facets. - * - * \param mode culling mode. - * - * \sa glCullFace(). - * - * Verifies the parameter and updates gl_polygon_attrib::CullFaceMode. On - * change, flushes the vertices and notifies the driver via - * the dd_function_table::CullFace callback. - */ -void GLAPIENTRY -_mesa_CullFace( GLenum mode ) -{ - GET_CURRENT_CONTEXT(ctx); - ASSERT_OUTSIDE_BEGIN_END(ctx); - - if (MESA_VERBOSE&VERBOSE_API) - _mesa_debug(ctx, "glCullFace %s\n", _mesa_lookup_enum_by_nr(mode)); - - if (mode!=GL_FRONT && mode!=GL_BACK && mode!=GL_FRONT_AND_BACK) { - _mesa_error( ctx, GL_INVALID_ENUM, "glCullFace" ); - return; - } - - if (ctx->Polygon.CullFaceMode == mode) - return; - - FLUSH_VERTICES(ctx, _NEW_POLYGON); - ctx->Polygon.CullFaceMode = mode; - - if (ctx->Driver.CullFace) - ctx->Driver.CullFace( ctx, mode ); -} - - -/** - * Define front- and back-facing - * - * \param mode orientation of front-facing polygons. - * - * \sa glFrontFace(). - * - * Verifies the parameter and updates gl_polygon_attrib::FrontFace. On change - * flushes the vertices and notifies the driver via - * the dd_function_table::FrontFace callback. - */ -void GLAPIENTRY -_mesa_FrontFace( GLenum mode ) -{ - GET_CURRENT_CONTEXT(ctx); - ASSERT_OUTSIDE_BEGIN_END(ctx); - - if (MESA_VERBOSE&VERBOSE_API) - _mesa_debug(ctx, "glFrontFace %s\n", _mesa_lookup_enum_by_nr(mode)); - - if (mode!=GL_CW && mode!=GL_CCW) { - _mesa_error( ctx, GL_INVALID_ENUM, "glFrontFace" ); - return; - } - - if (ctx->Polygon.FrontFace == mode) - return; - - FLUSH_VERTICES(ctx, _NEW_POLYGON); - ctx->Polygon.FrontFace = mode; - - ctx->Polygon._FrontBit = (GLboolean) (mode == GL_CW); - - if (ctx->Driver.FrontFace) - ctx->Driver.FrontFace( ctx, mode ); -} - - -/** - * Set the polygon rasterization mode. - * - * \param face the polygons which \p mode applies to. - * \param mode how polygons should be rasterized. - * - * \sa glPolygonMode(). - * - * Verifies the parameters and updates gl_polygon_attrib::FrontMode and - * gl_polygon_attrib::BackMode. On change flushes the vertices and notifies the - * driver via the dd_function_table::PolygonMode callback. - */ -void GLAPIENTRY -_mesa_PolygonMode( GLenum face, GLenum mode ) -{ - GET_CURRENT_CONTEXT(ctx); - ASSERT_OUTSIDE_BEGIN_END(ctx); - - if (MESA_VERBOSE&VERBOSE_API) - _mesa_debug(ctx, "glPolygonMode %s %s\n", - _mesa_lookup_enum_by_nr(face), - _mesa_lookup_enum_by_nr(mode)); - - if (mode!=GL_POINT && mode!=GL_LINE && mode!=GL_FILL) { - _mesa_error( ctx, GL_INVALID_ENUM, "glPolygonMode(mode)" ); - return; - } - - switch (face) { - case GL_FRONT: - if (ctx->Polygon.FrontMode == mode) - return; - FLUSH_VERTICES(ctx, _NEW_POLYGON); - ctx->Polygon.FrontMode = mode; - break; - case GL_FRONT_AND_BACK: - if (ctx->Polygon.FrontMode == mode && - ctx->Polygon.BackMode == mode) - return; - FLUSH_VERTICES(ctx, _NEW_POLYGON); - ctx->Polygon.FrontMode = mode; - ctx->Polygon.BackMode = mode; - break; - case GL_BACK: - if (ctx->Polygon.BackMode == mode) - return; - FLUSH_VERTICES(ctx, _NEW_POLYGON); - ctx->Polygon.BackMode = mode; - break; - default: - _mesa_error( ctx, GL_INVALID_ENUM, "glPolygonMode(face)" ); - return; - } - - if (ctx->Polygon.FrontMode == GL_FILL && ctx->Polygon.BackMode == GL_FILL) - ctx->_TriangleCaps &= ~DD_TRI_UNFILLED; - else - ctx->_TriangleCaps |= DD_TRI_UNFILLED; - - if (ctx->Driver.PolygonMode) - ctx->Driver.PolygonMode(ctx, face, mode); -} - -#if _HAVE_FULL_GL - - -/** - * This routine updates the ctx->Polygon.Stipple state. - * If we're getting the stipple data from a PBO, we map the buffer - * in order to access the data. - * In any case, we obey the current pixel unpacking parameters when fetching - * the stipple data. - * - * In the future, this routine should be used as a fallback, called via - * ctx->Driver.PolygonStipple(). We'll have to update all the DRI drivers - * too. - */ -void -_mesa_polygon_stipple(struct gl_context *ctx, const GLubyte *pattern) -{ - if (!pattern) - return; - - _mesa_unpack_polygon_stipple(pattern, ctx->PolygonStipple, &ctx->Unpack); -} - - -/** - * Called by glPolygonStipple. - */ -void GLAPIENTRY -_mesa_PolygonStipple( const GLubyte *pattern ) -{ - GET_CURRENT_CONTEXT(ctx); - ASSERT_OUTSIDE_BEGIN_END(ctx); - - if (MESA_VERBOSE&VERBOSE_API) - _mesa_debug(ctx, "glPolygonStipple\n"); - - FLUSH_VERTICES(ctx, _NEW_POLYGONSTIPPLE); - - _mesa_polygon_stipple(ctx, pattern); - - if (ctx->Driver.PolygonStipple) - ctx->Driver.PolygonStipple(ctx, pattern); -} - - -/** - * Called by glPolygonStipple. - */ -void GLAPIENTRY -_mesa_GetPolygonStipple( GLubyte *dest ) -{ - GET_CURRENT_CONTEXT(ctx); - ASSERT_OUTSIDE_BEGIN_END(ctx); - - if (MESA_VERBOSE&VERBOSE_API) - _mesa_debug(ctx, "glGetPolygonStipple\n"); - if (!dest) - return; - - _mesa_pack_polygon_stipple(ctx->PolygonStipple, dest, &ctx->Pack); -} - - -void GLAPIENTRY -_mesa_PolygonOffset( GLfloat factor, GLfloat units ) -{ - GET_CURRENT_CONTEXT(ctx); - ASSERT_OUTSIDE_BEGIN_END(ctx); - - if (MESA_VERBOSE&VERBOSE_API) - _mesa_debug(ctx, "glPolygonOffset %f %f\n", factor, units); - - if (ctx->Polygon.OffsetFactor == factor && - ctx->Polygon.OffsetUnits == units) - return; - - FLUSH_VERTICES(ctx, _NEW_POLYGON); - ctx->Polygon.OffsetFactor = factor; - ctx->Polygon.OffsetUnits = units; - - if (ctx->Driver.PolygonOffset) - ctx->Driver.PolygonOffset( ctx, factor, units ); -} - - -void GLAPIENTRY -_mesa_PolygonOffsetEXT( GLfloat factor, GLfloat bias ) -{ - GET_CURRENT_CONTEXT(ctx); - /* XXX mult by DepthMaxF here??? */ - _mesa_PolygonOffset(factor, bias * ctx->DrawBuffer->_DepthMaxF ); -} - -#endif - - -/**********************************************************************/ -/** \name Initialization */ -/*@{*/ - -/** - * Initialize the context polygon state. - * - * \param ctx GL context. - * - * Initializes __struct gl_contextRec::Polygon and __struct gl_contextRec::PolygonStipple - * attribute groups. - */ -void _mesa_init_polygon( struct gl_context * ctx ) -{ - /* Polygon group */ - ctx->Polygon.CullFlag = GL_FALSE; - ctx->Polygon.CullFaceMode = GL_BACK; - ctx->Polygon.FrontFace = GL_CCW; - ctx->Polygon._FrontBit = 0; - ctx->Polygon.FrontMode = GL_FILL; - ctx->Polygon.BackMode = GL_FILL; - ctx->Polygon.SmoothFlag = GL_FALSE; - ctx->Polygon.StippleFlag = GL_FALSE; - ctx->Polygon.OffsetFactor = 0.0F; - ctx->Polygon.OffsetUnits = 0.0F; - ctx->Polygon.OffsetPoint = GL_FALSE; - ctx->Polygon.OffsetLine = GL_FALSE; - ctx->Polygon.OffsetFill = GL_FALSE; - - - /* Polygon Stipple group */ - memset( ctx->PolygonStipple, 0xff, 32*sizeof(GLuint) ); -} - -/*@}*/ diff --git a/dll/opengl/mesa/main/polygon.h b/dll/opengl/mesa/main/polygon.h deleted file mode 100644 index 13f7c91ed07..00000000000 --- a/dll/opengl/mesa/main/polygon.h +++ /dev/null @@ -1,67 +0,0 @@ -/** - * \file polygon.h - * Polygon operations. - */ - -/* - * Mesa 3-D graphics library - * Version: 6.5.1 - * - * Copyright (C) 1999-2006 Brian Paul All Rights Reserved. - * - * Permission is hereby granted, free of charge, to any person obtaining a - * copy of this software and associated documentation files (the "Software"), - * to deal in the Software without restriction, including without limitation - * the rights to use, copy, modify, merge, publish, distribute, sublicense, - * and/or sell copies of the Software, and to permit persons to whom the - * Software is furnished to do so, subject to the following conditions: - * - * The above copyright notice and this permission notice shall be included - * in all copies or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS - * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL - * BRIAN PAUL BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN - * AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN - * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. - */ - - -#ifndef POLYGON_H -#define POLYGON_H - - -#include "glheader.h" - -struct gl_context; - -extern void -_mesa_polygon_stipple(struct gl_context *ctx, const GLubyte *pattern); - - -extern void GLAPIENTRY -_mesa_CullFace( GLenum mode ); - -extern void GLAPIENTRY -_mesa_FrontFace( GLenum mode ); - -extern void GLAPIENTRY -_mesa_PolygonMode( GLenum face, GLenum mode ); - -extern void GLAPIENTRY -_mesa_PolygonOffset( GLfloat factor, GLfloat units ); - -extern void GLAPIENTRY -_mesa_PolygonOffsetEXT( GLfloat factor, GLfloat bias ); - -extern void GLAPIENTRY -_mesa_PolygonStipple( const GLubyte *mask ); - -extern void GLAPIENTRY -_mesa_GetPolygonStipple( GLubyte *mask ); - -extern void -_mesa_init_polygon( struct gl_context * ctx ); - -#endif diff --git a/dll/opengl/mesa/main/precomp.h b/dll/opengl/mesa/main/precomp.h deleted file mode 100644 index 168125d7c02..00000000000 --- a/dll/opengl/mesa/main/precomp.h +++ /dev/null @@ -1,79 +0,0 @@ -#ifndef _MESA_MAIN_PCH_ -#define _MESA_MAIN_PCH_ - -#include "accum.h" -#include "api_arrayelt.h" -#include "api_exec.h" -#include "api_loopback.h" -#include "api_validate.h" -#include "attrib.h" -#include "blend.h" -#include "bufferobj.h" -#include "buffers.h" -#include "clear.h" -#include "clip.h" -#include "colormac.h" -#include "compiler.h" -#include "context.h" -#include "cpuinfo.h" -#include "depth.h" -#include "dispatch.h" -#include "dlist.h" -#include "drawpix.h" -#include "enable.h" -#include "enums.h" -#include "eval.h" -#include "extensions.h" -#include "feedback.h" -#include "fog.h" -#include "format_pack.h" -#include "format_unpack.h" -#include "formats.h" -#include "framebuffer.h" -#include "get.h" -#include "glheader.h" -#include "hash.h" -#include "hint.h" -#include "image.h" -#include "imports.h" -#include "light.h" -#include "lines.h" -#include "macros.h" -#include "matrix.h" -#include "mfeatures.h" -#include "mm.h" -#include "mtypes.h" -#include "multisample.h" -#include "pack.h" -#include "pixel.h" -#include "pixelstore.h" -#include "pixeltransfer.h" -#include "points.h" -#include "polygon.h" -#include "rastpos.h" -#include "readpix.h" -#include "renderbuffer.h" -#include "scissor.h" -#include "shared.h" -#include "simple_list.h" -#include "state.h" -#include "stencil.h" -#include "texenv.h" -#include "texformat.h" -#include "texgen.h" -#include "texgetimage.h" -#include "teximage.h" -#include "texobj.h" -#include "texparam.h" -#include "texstate.h" -#include "texstorage.h" -#include "texstore.h" -#include "varray.h" -#include "version.h" -#include "viewport.h" -#include "vtxfmt.h" - -#include -#include - -#endif /* _MESA_MAIN_PCH_ */ diff --git a/dll/opengl/mesa/main/rastpos.c b/dll/opengl/mesa/main/rastpos.c deleted file mode 100644 index a54c0b5622e..00000000000 --- a/dll/opengl/mesa/main/rastpos.c +++ /dev/null @@ -1,538 +0,0 @@ -/* - * Mesa 3-D graphics library - * Version: 6.5.3 - * - * Copyright (C) 1999-2007 Brian Paul All Rights Reserved. - * - * Permission is hereby granted, free of charge, to any person obtaining a - * copy of this software and associated documentation files (the "Software"), - * to deal in the Software without restriction, including without limitation - * the rights to use, copy, modify, merge, publish, distribute, sublicense, - * and/or sell copies of the Software, and to permit persons to whom the - * Software is furnished to do so, subject to the following conditions: - * - * The above copyright notice and this permission notice shall be included - * in all copies or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS - * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL - * BRIAN PAUL BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN - * AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN - * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. - */ - - -/** - * \file rastpos.c - * Raster position operations. - */ - -#include - -#if FEATURE_rastpos - - -/** - * Helper function for all the RasterPos functions. - */ -static void -rasterpos(GLfloat x, GLfloat y, GLfloat z, GLfloat w) -{ - GET_CURRENT_CONTEXT(ctx); - GLfloat p[4]; - - p[0] = x; - p[1] = y; - p[2] = z; - p[3] = w; - - ASSERT_OUTSIDE_BEGIN_END_AND_FLUSH(ctx); - FLUSH_CURRENT(ctx, 0); - - if (ctx->NewState) - _mesa_update_state( ctx ); - - ctx->Driver.RasterPos(ctx, p); -} - - -static void GLAPIENTRY -_mesa_RasterPos2d(GLdouble x, GLdouble y) -{ - rasterpos((GLfloat)x, (GLfloat)y, (GLfloat)0.0, (GLfloat)1.0); -} - -static void GLAPIENTRY -_mesa_RasterPos2f(GLfloat x, GLfloat y) -{ - rasterpos(x, y, 0.0F, 1.0F); -} - -static void GLAPIENTRY -_mesa_RasterPos2i(GLint x, GLint y) -{ - rasterpos((GLfloat) x, (GLfloat) y, 0.0F, 1.0F); -} - -static void GLAPIENTRY -_mesa_RasterPos2s(GLshort x, GLshort y) -{ - rasterpos(x, y, 0.0F, 1.0F); -} - -static void GLAPIENTRY -_mesa_RasterPos3d(GLdouble x, GLdouble y, GLdouble z) -{ - rasterpos((GLfloat) x, (GLfloat) y, (GLfloat) z, 1.0F); -} - -static void GLAPIENTRY -_mesa_RasterPos3f(GLfloat x, GLfloat y, GLfloat z) -{ - rasterpos(x, y, z, 1.0F); -} - -static void GLAPIENTRY -_mesa_RasterPos3i(GLint x, GLint y, GLint z) -{ - rasterpos((GLfloat) x, (GLfloat) y, (GLfloat) z, 1.0F); -} - -static void GLAPIENTRY -_mesa_RasterPos3s(GLshort x, GLshort y, GLshort z) -{ - rasterpos(x, y, z, 1.0F); -} - -static void GLAPIENTRY -_mesa_RasterPos4d(GLdouble x, GLdouble y, GLdouble z, GLdouble w) -{ - rasterpos((GLfloat) x, (GLfloat) y, (GLfloat) z, (GLfloat) w); -} - -static void GLAPIENTRY -_mesa_RasterPos4f(GLfloat x, GLfloat y, GLfloat z, GLfloat w) -{ - rasterpos(x, y, z, w); -} - -static void GLAPIENTRY -_mesa_RasterPos4i(GLint x, GLint y, GLint z, GLint w) -{ - rasterpos((GLfloat) x, (GLfloat) y, (GLfloat) z, (GLfloat) w); -} - -static void GLAPIENTRY -_mesa_RasterPos4s(GLshort x, GLshort y, GLshort z, GLshort w) -{ - rasterpos(x, y, z, w); -} - -static void GLAPIENTRY -_mesa_RasterPos2dv(const GLdouble *v) -{ - rasterpos((GLfloat) v[0], (GLfloat) v[1], 0.0F, 1.0F); -} - -static void GLAPIENTRY -_mesa_RasterPos2fv(const GLfloat *v) -{ - rasterpos(v[0], v[1], 0.0F, 1.0F); -} - -static void GLAPIENTRY -_mesa_RasterPos2iv(const GLint *v) -{ - rasterpos((GLfloat) v[0], (GLfloat) v[1], 0.0F, 1.0F); -} - -static void GLAPIENTRY -_mesa_RasterPos2sv(const GLshort *v) -{ - rasterpos(v[0], v[1], 0.0F, 1.0F); -} - -static void GLAPIENTRY -_mesa_RasterPos3dv(const GLdouble *v) -{ - rasterpos((GLfloat) v[0], (GLfloat) v[1], (GLfloat) v[2], 1.0F); -} - -static void GLAPIENTRY -_mesa_RasterPos3fv(const GLfloat *v) -{ - rasterpos(v[0], v[1], v[2], 1.0F); -} - -static void GLAPIENTRY -_mesa_RasterPos3iv(const GLint *v) -{ - rasterpos((GLfloat) v[0], (GLfloat) v[1], (GLfloat) v[2], 1.0F); -} - -static void GLAPIENTRY -_mesa_RasterPos3sv(const GLshort *v) -{ - rasterpos(v[0], v[1], v[2], 1.0F); -} - -static void GLAPIENTRY -_mesa_RasterPos4dv(const GLdouble *v) -{ - rasterpos((GLfloat) v[0], (GLfloat) v[1], - (GLfloat) v[2], (GLfloat) v[3]); -} - -static void GLAPIENTRY -_mesa_RasterPos4fv(const GLfloat *v) -{ - rasterpos(v[0], v[1], v[2], v[3]); -} - -static void GLAPIENTRY -_mesa_RasterPos4iv(const GLint *v) -{ - rasterpos((GLfloat) v[0], (GLfloat) v[1], - (GLfloat) v[2], (GLfloat) v[3]); -} - -static void GLAPIENTRY -_mesa_RasterPos4sv(const GLshort *v) -{ - rasterpos(v[0], v[1], v[2], v[3]); -} - - -/**********************************************************************/ -/*** GL_ARB_window_pos / GL_MESA_window_pos ***/ -/**********************************************************************/ - - -/** - * All glWindowPosMESA and glWindowPosARB commands call this function to - * update the current raster position. - */ -static void -window_pos3f(GLfloat x, GLfloat y, GLfloat z) -{ - GET_CURRENT_CONTEXT(ctx); - GLfloat z2; - - ASSERT_OUTSIDE_BEGIN_END_AND_FLUSH(ctx); - FLUSH_CURRENT(ctx, 0); - - z2 = CLAMP(z, 0.0F, 1.0F) * (ctx->Viewport.Far - ctx->Viewport.Near) - + ctx->Viewport.Near; - - /* set raster position */ - ctx->Current.RasterPos[0] = x; - ctx->Current.RasterPos[1] = y; - ctx->Current.RasterPos[2] = z2; - ctx->Current.RasterPos[3] = 1.0F; - - ctx->Current.RasterPosValid = GL_TRUE; - - if (ctx->Fog.FogCoordinateSource == GL_FOG_COORDINATE_EXT) - ctx->Current.RasterDistance = ctx->Current.Attrib[VERT_ATTRIB_FOG][0]; - else - ctx->Current.RasterDistance = 0.0; - - /* raster color = current color or index */ - ctx->Current.RasterColor[0] - = CLAMP(ctx->Current.Attrib[VERT_ATTRIB_COLOR][0], 0.0F, 1.0F); - ctx->Current.RasterColor[1] - = CLAMP(ctx->Current.Attrib[VERT_ATTRIB_COLOR][1], 0.0F, 1.0F); - ctx->Current.RasterColor[2] - = CLAMP(ctx->Current.Attrib[VERT_ATTRIB_COLOR][2], 0.0F, 1.0F); - ctx->Current.RasterColor[3] - = CLAMP(ctx->Current.Attrib[VERT_ATTRIB_COLOR][3], 0.0F, 1.0F); - - /* raster texcoord = current texcoord */ - COPY_4FV( ctx->Current.RasterTexCoords, ctx->Current.Attrib[VERT_ATTRIB_TEX] ); - - if (ctx->RenderMode==GL_SELECT) { - _mesa_update_hitflag( ctx, ctx->Current.RasterPos[2] ); - } -} - - -/* This is just to support the GL_MESA_window_pos version */ -static void -window_pos4f(GLfloat x, GLfloat y, GLfloat z, GLfloat w) -{ - GET_CURRENT_CONTEXT(ctx); - window_pos3f(x, y, z); - ctx->Current.RasterPos[3] = w; -} - - -static void GLAPIENTRY -_mesa_WindowPos2dMESA(GLdouble x, GLdouble y) -{ - window_pos4f((GLfloat) x, (GLfloat) y, 0.0F, 1.0F); -} - -static void GLAPIENTRY -_mesa_WindowPos2fMESA(GLfloat x, GLfloat y) -{ - window_pos4f(x, y, 0.0F, 1.0F); -} - -static void GLAPIENTRY -_mesa_WindowPos2iMESA(GLint x, GLint y) -{ - window_pos4f((GLfloat) x, (GLfloat) y, 0.0F, 1.0F); -} - -static void GLAPIENTRY -_mesa_WindowPos2sMESA(GLshort x, GLshort y) -{ - window_pos4f(x, y, 0.0F, 1.0F); -} - -static void GLAPIENTRY -_mesa_WindowPos3dMESA(GLdouble x, GLdouble y, GLdouble z) -{ - window_pos4f((GLfloat) x, (GLfloat) y, (GLfloat) z, 1.0F); -} - -static void GLAPIENTRY -_mesa_WindowPos3fMESA(GLfloat x, GLfloat y, GLfloat z) -{ - window_pos4f(x, y, z, 1.0F); -} - -static void GLAPIENTRY -_mesa_WindowPos3iMESA(GLint x, GLint y, GLint z) -{ - window_pos4f((GLfloat) x, (GLfloat) y, (GLfloat) z, 1.0F); -} - -static void GLAPIENTRY -_mesa_WindowPos3sMESA(GLshort x, GLshort y, GLshort z) -{ - window_pos4f(x, y, z, 1.0F); -} - -static void GLAPIENTRY -_mesa_WindowPos4dMESA(GLdouble x, GLdouble y, GLdouble z, GLdouble w) -{ - window_pos4f((GLfloat) x, (GLfloat) y, (GLfloat) z, (GLfloat) w); -} - -static void GLAPIENTRY -_mesa_WindowPos4fMESA(GLfloat x, GLfloat y, GLfloat z, GLfloat w) -{ - window_pos4f(x, y, z, w); -} - -static void GLAPIENTRY -_mesa_WindowPos4iMESA(GLint x, GLint y, GLint z, GLint w) -{ - window_pos4f((GLfloat) x, (GLfloat) y, (GLfloat) z, (GLfloat) w); -} - -static void GLAPIENTRY -_mesa_WindowPos4sMESA(GLshort x, GLshort y, GLshort z, GLshort w) -{ - window_pos4f(x, y, z, w); -} - -static void GLAPIENTRY -_mesa_WindowPos2dvMESA(const GLdouble *v) -{ - window_pos4f((GLfloat) v[0], (GLfloat) v[1], 0.0F, 1.0F); -} - -static void GLAPIENTRY -_mesa_WindowPos2fvMESA(const GLfloat *v) -{ - window_pos4f(v[0], v[1], 0.0F, 1.0F); -} - -static void GLAPIENTRY -_mesa_WindowPos2ivMESA(const GLint *v) -{ - window_pos4f((GLfloat) v[0], (GLfloat) v[1], 0.0F, 1.0F); -} - -static void GLAPIENTRY -_mesa_WindowPos2svMESA(const GLshort *v) -{ - window_pos4f(v[0], v[1], 0.0F, 1.0F); -} - -static void GLAPIENTRY -_mesa_WindowPos3dvMESA(const GLdouble *v) -{ - window_pos4f((GLfloat) v[0], (GLfloat) v[1], (GLfloat) v[2], 1.0F); -} - -static void GLAPIENTRY -_mesa_WindowPos3fvMESA(const GLfloat *v) -{ - window_pos4f(v[0], v[1], v[2], 1.0); -} - -static void GLAPIENTRY -_mesa_WindowPos3ivMESA(const GLint *v) -{ - window_pos4f((GLfloat) v[0], (GLfloat) v[1], (GLfloat) v[2], 1.0F); -} - -static void GLAPIENTRY -_mesa_WindowPos3svMESA(const GLshort *v) -{ - window_pos4f(v[0], v[1], v[2], 1.0F); -} - -static void GLAPIENTRY -_mesa_WindowPos4dvMESA(const GLdouble *v) -{ - window_pos4f((GLfloat) v[0], (GLfloat) v[1], - (GLfloat) v[2], (GLfloat) v[3]); -} - -static void GLAPIENTRY -_mesa_WindowPos4fvMESA(const GLfloat *v) -{ - window_pos4f(v[0], v[1], v[2], v[3]); -} - -static void GLAPIENTRY -_mesa_WindowPos4ivMESA(const GLint *v) -{ - window_pos4f((GLfloat) v[0], (GLfloat) v[1], - (GLfloat) v[2], (GLfloat) v[3]); -} - -static void GLAPIENTRY -_mesa_WindowPos4svMESA(const GLshort *v) -{ - window_pos4f(v[0], v[1], v[2], v[3]); -} - - -#if 0 - -/* - * OpenGL implementation of glWindowPos*MESA() - */ -void glWindowPos4fMESA( GLfloat x, GLfloat y, GLfloat z, GLfloat w ) -{ - GLfloat fx, fy; - - /* Push current matrix mode and viewport attributes */ - glPushAttrib( GL_TRANSFORM_BIT | GL_VIEWPORT_BIT ); - - /* Setup projection parameters */ - glMatrixMode( GL_PROJECTION ); - glPushMatrix(); - glLoadIdentity(); - glMatrixMode( GL_MODELVIEW ); - glPushMatrix(); - glLoadIdentity(); - - glDepthRange( z, z ); - glViewport( (int) x - 1, (int) y - 1, 2, 2 ); - - /* set the raster (window) position */ - fx = x - (int) x; - fy = y - (int) y; - glRasterPos4f( fx, fy, 0.0, w ); - - /* restore matrices, viewport and matrix mode */ - glPopMatrix(); - glMatrixMode( GL_PROJECTION ); - glPopMatrix(); - - glPopAttrib(); -} - -#endif - - -void -_mesa_init_rastpos_dispatch(struct _glapi_table *disp) -{ - SET_RasterPos2f(disp, _mesa_RasterPos2f); - SET_RasterPos2fv(disp, _mesa_RasterPos2fv); - SET_RasterPos2i(disp, _mesa_RasterPos2i); - SET_RasterPos2iv(disp, _mesa_RasterPos2iv); - SET_RasterPos2d(disp, _mesa_RasterPos2d); - SET_RasterPos2dv(disp, _mesa_RasterPos2dv); - SET_RasterPos2s(disp, _mesa_RasterPos2s); - SET_RasterPos2sv(disp, _mesa_RasterPos2sv); - SET_RasterPos3d(disp, _mesa_RasterPos3d); - SET_RasterPos3dv(disp, _mesa_RasterPos3dv); - SET_RasterPos3f(disp, _mesa_RasterPos3f); - SET_RasterPos3fv(disp, _mesa_RasterPos3fv); - SET_RasterPos3i(disp, _mesa_RasterPos3i); - SET_RasterPos3iv(disp, _mesa_RasterPos3iv); - SET_RasterPos3s(disp, _mesa_RasterPos3s); - SET_RasterPos3sv(disp, _mesa_RasterPos3sv); - SET_RasterPos4d(disp, _mesa_RasterPos4d); - SET_RasterPos4dv(disp, _mesa_RasterPos4dv); - SET_RasterPos4f(disp, _mesa_RasterPos4f); - SET_RasterPos4fv(disp, _mesa_RasterPos4fv); - SET_RasterPos4i(disp, _mesa_RasterPos4i); - SET_RasterPos4iv(disp, _mesa_RasterPos4iv); - SET_RasterPos4s(disp, _mesa_RasterPos4s); - SET_RasterPos4sv(disp, _mesa_RasterPos4sv); - - /* 197. GL_MESA_window_pos */ - SET_WindowPos2dMESA(disp, _mesa_WindowPos2dMESA); - SET_WindowPos2dvMESA(disp, _mesa_WindowPos2dvMESA); - SET_WindowPos2fMESA(disp, _mesa_WindowPos2fMESA); - SET_WindowPos2fvMESA(disp, _mesa_WindowPos2fvMESA); - SET_WindowPos2iMESA(disp, _mesa_WindowPos2iMESA); - SET_WindowPos2ivMESA(disp, _mesa_WindowPos2ivMESA); - SET_WindowPos2sMESA(disp, _mesa_WindowPos2sMESA); - SET_WindowPos2svMESA(disp, _mesa_WindowPos2svMESA); - SET_WindowPos3dMESA(disp, _mesa_WindowPos3dMESA); - SET_WindowPos3dvMESA(disp, _mesa_WindowPos3dvMESA); - SET_WindowPos3fMESA(disp, _mesa_WindowPos3fMESA); - SET_WindowPos3fvMESA(disp, _mesa_WindowPos3fvMESA); - SET_WindowPos3iMESA(disp, _mesa_WindowPos3iMESA); - SET_WindowPos3ivMESA(disp, _mesa_WindowPos3ivMESA); - SET_WindowPos3sMESA(disp, _mesa_WindowPos3sMESA); - SET_WindowPos3svMESA(disp, _mesa_WindowPos3svMESA); - SET_WindowPos4dMESA(disp, _mesa_WindowPos4dMESA); - SET_WindowPos4dvMESA(disp, _mesa_WindowPos4dvMESA); - SET_WindowPos4fMESA(disp, _mesa_WindowPos4fMESA); - SET_WindowPos4fvMESA(disp, _mesa_WindowPos4fvMESA); - SET_WindowPos4iMESA(disp, _mesa_WindowPos4iMESA); - SET_WindowPos4ivMESA(disp, _mesa_WindowPos4ivMESA); - SET_WindowPos4sMESA(disp, _mesa_WindowPos4sMESA); - SET_WindowPos4svMESA(disp, _mesa_WindowPos4svMESA); -} - - -#endif /* FEATURE_rastpos */ - - -/**********************************************************************/ -/** \name Initialization */ -/**********************************************************************/ -/*@{*/ - -/** - * Initialize the context current raster position information. - * - * \param ctx GL context. - * - * Initialize the current raster position information in - * __struct gl_contextRec::Current, and adds the extension entry points to the - * dispatcher. - */ -void _mesa_init_rastpos( struct gl_context * ctx ) -{ - ASSIGN_4V( ctx->Current.RasterPos, 0.0, 0.0, 0.0, 1.0 ); - ctx->Current.RasterDistance = 0.0; - ASSIGN_4V( ctx->Current.RasterColor, 1.0, 1.0, 1.0, 1.0 ); - ASSIGN_4V( ctx->Current.RasterTexCoords, 0.0, 0.0, 0.0, 1.0 ); - ctx->Current.RasterPosValid = GL_TRUE; -} - -/*@}*/ diff --git a/dll/opengl/mesa/main/rastpos.h b/dll/opengl/mesa/main/rastpos.h deleted file mode 100644 index cdd94a66ce0..00000000000 --- a/dll/opengl/mesa/main/rastpos.h +++ /dev/null @@ -1,60 +0,0 @@ -/** - * \file rastpos.h - * Raster position operations. - */ - -/* - * Mesa 3-D graphics library - * Version: 4.1 - * - * Copyright (C) 1999-2002 Brian Paul All Rights Reserved. - * - * Permission is hereby granted, free of charge, to any person obtaining a - * copy of this software and associated documentation files (the "Software"), - * to deal in the Software without restriction, including without limitation - * the rights to use, copy, modify, merge, publish, distribute, sublicense, - * and/or sell copies of the Software, and to permit persons to whom the - * Software is furnished to do so, subject to the following conditions: - * - * The above copyright notice and this permission notice shall be included - * in all copies or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS - * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL - * BRIAN PAUL BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN - * AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN - * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. - */ - - -#ifndef RASTPOS_H -#define RASTPOS_H - - -#include "compiler.h" -#include "mfeatures.h" - -struct _glapi_table; -struct gl_context; - -#if FEATURE_rastpos - -extern void -_mesa_init_rastpos_dispatch(struct _glapi_table *disp); - -#else /* FEATURE_rastpos */ - -static inline void -_mesa_init_rastpos_dispatch(struct _glapi_table *disp) -{ -} - -#endif /* FEATURE_rastpos */ - -extern void -_mesa_init_rastpos(struct gl_context *ctx); - -/*@}*/ - -#endif /* RASTPOS_H */ diff --git a/dll/opengl/mesa/main/readpix.c b/dll/opengl/mesa/main/readpix.c deleted file mode 100644 index 2da1fd007a7..00000000000 --- a/dll/opengl/mesa/main/readpix.c +++ /dev/null @@ -1,574 +0,0 @@ -/* - * Mesa 3-D graphics library - * Version: 7.1 - * - * Copyright (C) 1999-2008 Brian Paul All Rights Reserved. - * - * Permission is hereby granted, free of charge, to any person obtaining a - * copy of this software and associated documentation files (the "Software"), - * to deal in the Software without restriction, including without limitation - * the rights to use, copy, modify, merge, publish, distribute, sublicense, - * and/or sell copies of the Software, and to permit persons to whom the - * Software is furnished to do so, subject to the following conditions: - * - * The above copyright notice and this permission notice shall be included - * in all copies or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS - * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL - * BRIAN PAUL BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN - * AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN - * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. - */ - -#include - -/** - * Tries to implement glReadPixels() of GL_DEPTH_COMPONENT using memcpy of the - * mapping. - */ -static GLboolean -fast_read_depth_pixels( struct gl_context *ctx, - GLint x, GLint y, - GLsizei width, GLsizei height, - GLenum type, GLvoid *pixels, - const struct gl_pixelstore_attrib *packing ) -{ - struct gl_framebuffer *fb = ctx->ReadBuffer; - struct gl_renderbuffer *rb = fb->Attachment[BUFFER_DEPTH].Renderbuffer; - GLubyte *map, *dst; - int stride, dstStride, j; - - if (ctx->Pixel.DepthScale != 1.0 || ctx->Pixel.DepthBias != 0.0) - return GL_FALSE; - - if (packing->SwapBytes) - return GL_FALSE; - - if (_mesa_get_format_datatype(rb->Format) != GL_UNSIGNED_NORMALIZED) - return GL_FALSE; - - if (!((type == GL_UNSIGNED_SHORT && rb->Format == MESA_FORMAT_Z16) || - type == GL_UNSIGNED_INT)) - return GL_FALSE; - - ctx->Driver.MapRenderbuffer(ctx, rb, x, y, width, height, GL_MAP_READ_BIT, - &map, &stride); - - if (!map) { - _mesa_error(ctx, GL_OUT_OF_MEMORY, "glReadPixels"); - return GL_TRUE; /* don't bother trying the slow path */ - } - - dstStride = _mesa_image_row_stride(packing, width, GL_DEPTH_COMPONENT, type); - dst = (GLubyte *) _mesa_image_address2d(packing, pixels, width, height, - GL_DEPTH_COMPONENT, type, 0, 0); - - for (j = 0; j < height; j++) { - if (type == GL_UNSIGNED_INT) { - _mesa_unpack_uint_z_row(rb->Format, width, map, (GLuint *)dst); - } else { - ASSERT(type == GL_UNSIGNED_SHORT && rb->Format == MESA_FORMAT_Z16); - memcpy(dst, map, width * 2); - } - - map += stride; - dst += dstStride; - } - ctx->Driver.UnmapRenderbuffer(ctx, rb); - - return GL_TRUE; -} - -/** - * Read pixels for format=GL_DEPTH_COMPONENT. - */ -static void -read_depth_pixels( struct gl_context *ctx, - GLint x, GLint y, - GLsizei width, GLsizei height, - GLenum type, GLvoid *pixels, - const struct gl_pixelstore_attrib *packing ) -{ - struct gl_framebuffer *fb = ctx->ReadBuffer; - struct gl_renderbuffer *rb = fb->Attachment[BUFFER_DEPTH].Renderbuffer; - GLint j; - GLubyte *dst, *map; - int dstStride, stride; - - if (!rb) - return; - - /* clipping should have been done already */ - ASSERT(x >= 0); - ASSERT(y >= 0); - ASSERT(x + width <= (GLint) rb->Width); - ASSERT(y + height <= (GLint) rb->Height); - /* width should never be > MAX_WIDTH since we did clipping earlier */ - ASSERT(width <= MAX_WIDTH); - - if (fast_read_depth_pixels(ctx, x, y, width, height, type, pixels, packing)) - return; - - dstStride = _mesa_image_row_stride(packing, width, GL_DEPTH_COMPONENT, type); - dst = (GLubyte *) _mesa_image_address2d(packing, pixels, width, height, - GL_DEPTH_COMPONENT, type, 0, 0); - - ctx->Driver.MapRenderbuffer(ctx, rb, x, y, width, height, GL_MAP_READ_BIT, - &map, &stride); - if (!map) { - _mesa_error(ctx, GL_OUT_OF_MEMORY, "glReadPixels"); - return; - } - - /* General case (slower) */ - for (j = 0; j < height; j++, y++) { - GLfloat depthValues[MAX_WIDTH]; - _mesa_unpack_float_z_row(rb->Format, width, map, depthValues); - _mesa_pack_depth_span(ctx, width, dst, type, depthValues, packing); - - dst += dstStride; - map += stride; - } - - ctx->Driver.UnmapRenderbuffer(ctx, rb); -} - - -/** - * Read pixels for format=GL_STENCIL_INDEX. - */ -static void -read_stencil_pixels( struct gl_context *ctx, - GLint x, GLint y, - GLsizei width, GLsizei height, - GLenum type, GLvoid *pixels, - const struct gl_pixelstore_attrib *packing ) -{ - struct gl_framebuffer *fb = ctx->ReadBuffer; - struct gl_renderbuffer *rb = fb->Attachment[BUFFER_STENCIL].Renderbuffer; - GLint j; - GLubyte *map; - GLint stride; - - if (!rb) - return; - - /* width should never be > MAX_WIDTH since we did clipping earlier */ - ASSERT(width <= MAX_WIDTH); - - ctx->Driver.MapRenderbuffer(ctx, rb, x, y, width, height, GL_MAP_READ_BIT, - &map, &stride); - if (!map) { - _mesa_error(ctx, GL_OUT_OF_MEMORY, "glReadPixels"); - return; - } - - /* process image row by row */ - for (j = 0; j < height; j++) { - GLvoid *dest; - GLubyte stencil[MAX_WIDTH]; - - _mesa_unpack_ubyte_stencil_row(rb->Format, width, map, stencil); - dest = _mesa_image_address2d(packing, pixels, width, height, - GL_STENCIL_INDEX, type, j, 0); - - _mesa_pack_stencil_span(ctx, width, type, dest, stencil, packing); - - map += stride; - } - - ctx->Driver.UnmapRenderbuffer(ctx, rb); -} - - -/** - * Try to do glReadPixels of RGBA data using a simple memcpy or swizzle. - * \return GL_TRUE if successful, GL_FALSE otherwise (use the slow path) - */ -static GLboolean -fast_read_rgba_pixels_memcpy( struct gl_context *ctx, - GLint x, GLint y, - GLsizei width, GLsizei height, - GLenum format, GLenum type, - GLvoid *pixels, - const struct gl_pixelstore_attrib *packing, - GLbitfield transferOps ) -{ - struct gl_renderbuffer *rb = ctx->ReadBuffer->_ColorReadBuffer; - GLubyte *dst, *map; - int dstStride, stride, j, texelBytes; - GLboolean swizzle_rb = GL_FALSE, copy_xrgb = GL_FALSE; - - /* XXX we could check for other swizzle/special cases here as needed */ - if (rb->Format == MESA_FORMAT_RGBA8888_REV && - format == GL_BGRA && - type == GL_UNSIGNED_INT_8_8_8_8_REV) { - swizzle_rb = GL_TRUE; - } - else if (rb->Format == MESA_FORMAT_XRGB8888 && - format == GL_BGRA && - type == GL_UNSIGNED_INT_8_8_8_8_REV) { - copy_xrgb = GL_TRUE; - } - else if (!_mesa_format_matches_format_and_type(rb->Format, format, type)) - return GL_FALSE; - - /* check for things we can't handle here */ - if (packing->SwapBytes) { - return GL_FALSE; - } - - /* If the format is unsigned normalized then we can ignore clamping - * because the values are already in the range [0,1] so it won't - * have any effect anyway. - */ - if (_mesa_get_format_datatype(rb->Format) == GL_UNSIGNED_NORMALIZED) - transferOps &= ~IMAGE_CLAMP_BIT; - - if (transferOps) - return GL_FALSE; - - dstStride = _mesa_image_row_stride(packing, width, format, type); - dst = (GLubyte *) _mesa_image_address2d(packing, pixels, width, height, - format, type, 0, 0); - - ctx->Driver.MapRenderbuffer(ctx, rb, x, y, width, height, GL_MAP_READ_BIT, - &map, &stride); - if (!map) { - _mesa_error(ctx, GL_OUT_OF_MEMORY, "glReadPixels"); - return GL_TRUE; /* don't bother trying the slow path */ - } - - texelBytes = _mesa_get_format_bytes(rb->Format); - - if (swizzle_rb) { - /* swap R/B */ - for (j = 0; j < height; j++) { - int i; - for (i = 0; i < width; i++) { - GLuint *dst4 = (GLuint *) dst, *map4 = (GLuint *) map; - GLuint pixel = map4[i]; - dst4[i] = (pixel & 0xff00ff00) - | ((pixel & 0x00ff0000) >> 16) - | ((pixel & 0x000000ff) << 16); - } - dst += dstStride; - map += stride; - } - } else if (copy_xrgb) { - /* convert xrgb -> argb */ - for (j = 0; j < height; j++) { - GLuint *dst4 = (GLuint *) dst, *map4 = (GLuint *) map; - int i; - for (i = 0; i < width; i++) { - dst4[i] = map4[i] | 0xff000000; /* set A=0xff */ - } - dst += dstStride; - map += stride; - } - } else { - /* just memcpy */ - for (j = 0; j < height; j++) { - memcpy(dst, map, width * texelBytes); - dst += dstStride; - map += stride; - } - } - - ctx->Driver.UnmapRenderbuffer(ctx, rb); - - return GL_TRUE; -} - -static void -slow_read_rgba_pixels( struct gl_context *ctx, - GLint x, GLint y, - GLsizei width, GLsizei height, - GLenum format, GLenum type, - GLvoid *pixels, - const struct gl_pixelstore_attrib *packing, - GLbitfield transferOps ) -{ - struct gl_renderbuffer *rb = ctx->ReadBuffer->_ColorReadBuffer; - const gl_format rbFormat = rb->Format; - void *rgba; - GLubyte *dst, *map; - int dstStride, stride, j; - - dstStride = _mesa_image_row_stride(packing, width, format, type); - dst = (GLubyte *) _mesa_image_address2d(packing, pixels, width, height, - format, type, 0, 0); - - ctx->Driver.MapRenderbuffer(ctx, rb, x, y, width, height, GL_MAP_READ_BIT, - &map, &stride); - if (!map) { - _mesa_error(ctx, GL_OUT_OF_MEMORY, "glReadPixels"); - return; - } - - rgba = malloc(width * MAX_PIXEL_BYTES); - if (!rgba) - goto done; - - for (j = 0; j < height; j++) { - if (_mesa_is_integer_format(format)) { - _mesa_unpack_uint_rgba_row(rbFormat, width, map, (GLuint (*)[4]) rgba); - _mesa_rebase_rgba_uint(width, (GLuint (*)[4]) rgba, - rb->_BaseFormat); - _mesa_pack_rgba_span_int(ctx, width, (GLuint (*)[4]) rgba, format, - type, dst); - } else { - _mesa_unpack_rgba_row(rbFormat, width, map, (GLfloat (*)[4]) rgba); - _mesa_rebase_rgba_float(width, (GLfloat (*)[4]) rgba, - rb->_BaseFormat); - _mesa_pack_rgba_span_float(ctx, width, (GLfloat (*)[4]) rgba, format, - type, dst, packing, transferOps); - } - dst += dstStride; - map += stride; - } - - free(rgba); - -done: - ctx->Driver.UnmapRenderbuffer(ctx, rb); -} - -/* - * Read R, G, B, A, RGB, L, or LA pixels. - */ -static void -read_rgba_pixels( struct gl_context *ctx, - GLint x, GLint y, - GLsizei width, GLsizei height, - GLenum format, GLenum type, GLvoid *pixels, - const struct gl_pixelstore_attrib *packing ) -{ - GLbitfield transferOps = ctx->_ImageTransferState; - struct gl_framebuffer *fb = ctx->ReadBuffer; - struct gl_renderbuffer *rb = fb->_ColorReadBuffer; - - if (!rb) - return; - - if (!_mesa_is_integer_format(format)) { - transferOps |= IMAGE_CLAMP_BIT; - } - - /* Try the optimized paths first. */ - if (fast_read_rgba_pixels_memcpy(ctx, x, y, width, height, - format, type, pixels, packing, - transferOps)) { - return; - } - - slow_read_rgba_pixels(ctx, x, y, width, height, - format, type, pixels, packing, transferOps); -} - -/** - * Software fallback routine for ctx->Driver.ReadPixels(). - * By time we get here, all error checking will have been done. - */ -void -_mesa_readpixels(struct gl_context *ctx, - GLint x, GLint y, GLsizei width, GLsizei height, - GLenum format, GLenum type, - const struct gl_pixelstore_attrib *packing, - GLvoid *pixels) -{ - struct gl_pixelstore_attrib clippedPacking = *packing; - - if (ctx->NewState) - _mesa_update_state(ctx); - - /* Do all needed clipping here, so that we can forget about it later */ - if (_mesa_clip_readpixels(ctx, &x, &y, &width, &height, &clippedPacking)) { - - if (pixels) { - switch (format) { - case GL_STENCIL_INDEX: - read_stencil_pixels(ctx, x, y, width, height, type, pixels, - &clippedPacking); - break; - case GL_DEPTH_COMPONENT: - read_depth_pixels(ctx, x, y, width, height, type, pixels, - &clippedPacking); - break; - default: - /* all other formats should be color formats */ - read_rgba_pixels(ctx, x, y, width, height, format, type, pixels, - &clippedPacking); - } - } - } -} - - -/** - * Do error checking of the format/type parameters to glReadPixels and - * glDrawPixels. - * \param drawing if GL_TRUE do checking for DrawPixels, else do checking - * for ReadPixels. - * \return GL_TRUE if error detected, GL_FALSE if no errors - */ -GLboolean -_mesa_error_check_format_type(struct gl_context *ctx, GLenum format, - GLenum type, GLboolean drawing) -{ - const char *readDraw = drawing ? "Draw" : "Read"; - const GLboolean reading = !drawing; - GLenum err; - - /* state validation should have already been done */ - ASSERT(ctx->NewState == 0x0); - - /* basic combinations test */ - err = _mesa_error_check_format_and_type(ctx, format, type); - if (err != GL_NO_ERROR) { - _mesa_error(ctx, err, "gl%sPixels(format or type)", readDraw); - return GL_TRUE; - } - - /* additional checks */ - switch (format) { - case GL_RG: - case GL_RED: - case GL_GREEN: - case GL_BLUE: - case GL_ALPHA: - case GL_LUMINANCE: - case GL_LUMINANCE_ALPHA: - case GL_RGB: - case GL_BGR: - case GL_RGBA: - case GL_BGRA: - case GL_ABGR_EXT: - case GL_RED_INTEGER_EXT: - case GL_GREEN_INTEGER_EXT: - case GL_BLUE_INTEGER_EXT: - case GL_ALPHA_INTEGER_EXT: - case GL_RGB_INTEGER_EXT: - case GL_RGBA_INTEGER_EXT: - case GL_BGR_INTEGER_EXT: - case GL_BGRA_INTEGER_EXT: - case GL_LUMINANCE_INTEGER_EXT: - case GL_LUMINANCE_ALPHA_INTEGER_EXT: - if (!drawing) { - /* reading */ - if (!_mesa_source_buffer_exists(ctx, GL_COLOR)) { - _mesa_error(ctx, GL_INVALID_OPERATION, - "glReadPixels(no color buffer)"); - return GL_TRUE; - } - } - break; - case GL_COLOR_INDEX: - if (drawing) { - if (ctx->PixelMaps.ItoR.Size == 0 || - ctx->PixelMaps.ItoG.Size == 0 || - ctx->PixelMaps.ItoB.Size == 0) { - _mesa_error(ctx, GL_INVALID_OPERATION, - "glDrawPixels(drawing color index pixels into RGB buffer)"); - return GL_TRUE; - } - } - else { - /* reading */ - if (!_mesa_source_buffer_exists(ctx, GL_COLOR)) { - _mesa_error(ctx, GL_INVALID_OPERATION, - "glReadPixels(no color buffer)"); - return GL_TRUE; - } - /* We no longer support CI-mode color buffers so trying to read - * GL_COLOR_INDEX pixels is always an error. - */ - _mesa_error(ctx, GL_INVALID_OPERATION, - "glReadPixels(color buffer is RGB)"); - return GL_TRUE; - } - break; - case GL_STENCIL_INDEX: - if ((drawing && !_mesa_dest_buffer_exists(ctx, format)) || - (reading && !_mesa_source_buffer_exists(ctx, format))) { - _mesa_error(ctx, GL_INVALID_OPERATION, - "gl%sPixels(no stencil buffer)", readDraw); - return GL_TRUE; - } - break; - case GL_DEPTH_COMPONENT: - if ((drawing && !_mesa_dest_buffer_exists(ctx, format))) { - _mesa_error(ctx, GL_INVALID_OPERATION, - "gl%sPixels(no depth buffer)", readDraw); - return GL_TRUE; - } - break; - default: - /* this should have been caught in _mesa_error_check_format_type() */ - _mesa_problem(ctx, "unexpected format in _mesa_%sPixels", readDraw); - return GL_TRUE; - } - - /* no errors */ - return GL_FALSE; -} - - - -void GLAPIENTRY -_mesa_ReadPixels( GLint x, GLint y, GLsizei width, GLsizei height, - GLenum format, GLenum type, GLvoid *pixels ) -{ - GET_CURRENT_CONTEXT(ctx); - ASSERT_OUTSIDE_BEGIN_END_AND_FLUSH(ctx); - - FLUSH_CURRENT(ctx, 0); - - if (MESA_VERBOSE & VERBOSE_API) - _mesa_debug(ctx, "glReadPixels(%d, %d, %s, %s, %p)\n", - width, height, - _mesa_lookup_enum_by_nr(format), - _mesa_lookup_enum_by_nr(type), - pixels); - - if (width < 0 || height < 0) { - _mesa_error( ctx, GL_INVALID_VALUE, - "glReadPixels(width=%d height=%d)", width, height ); - return; - } - - if (ctx->NewState) - _mesa_update_state(ctx); - - if (_mesa_error_check_format_type(ctx, format, type, GL_FALSE)) { - /* found an error */ - return; - } - - /* Check that the destination format and source buffer are both - * integer-valued or both non-integer-valued. - */ - if (ctx->Extensions.EXT_texture_integer && _mesa_is_color_format(format)) { - const struct gl_renderbuffer *rb = ctx->ReadBuffer->_ColorReadBuffer; - const GLboolean srcInteger = _mesa_is_format_integer_color(rb->Format); - const GLboolean dstInteger = _mesa_is_integer_format(format); - if (dstInteger != srcInteger) { - _mesa_error(ctx, GL_INVALID_OPERATION, - "glReadPixels(integer / non-integer format mismatch"); - return; - } - } - - if (!_mesa_source_buffer_exists(ctx, format)) { - _mesa_error(ctx, GL_INVALID_OPERATION, "glReadPixels(no readbuffer)"); - return; - } - - if (width == 0 || height == 0) - return; /* nothing to do */ - - ctx->Driver.ReadPixels(ctx, x, y, width, height, - format, type, &ctx->Pack, pixels); -} diff --git a/dll/opengl/mesa/main/readpix.h b/dll/opengl/mesa/main/readpix.h deleted file mode 100644 index 6fca7b99c97..00000000000 --- a/dll/opengl/mesa/main/readpix.h +++ /dev/null @@ -1,51 +0,0 @@ -/* - * Mesa 3-D graphics library - * Version: 7.1 - * - * Copyright (C) 1999-2008 Brian Paul All Rights Reserved. - * - * Permission is hereby granted, free of charge, to any person obtaining a - * copy of this software and associated documentation files (the "Software"), - * to deal in the Software without restriction, including without limitation - * the rights to use, copy, modify, merge, publish, distribute, sublicense, - * and/or sell copies of the Software, and to permit persons to whom the - * Software is furnished to do so, subject to the following conditions: - * - * The above copyright notice and this permission notice shall be included - * in all copies or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS - * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL - * BRIAN PAUL BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN - * AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN - * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. - */ - - -#ifndef READPIXELS_H -#define READPIXELS_H - - -#include "glheader.h" - -struct gl_context; -struct gl_pixelstore_attrib; - - -extern GLboolean -_mesa_error_check_format_type(struct gl_context *ctx, GLenum format, GLenum type, - GLboolean drawing); - -extern void -_mesa_readpixels(struct gl_context *ctx, - GLint x, GLint y, GLsizei width, GLsizei height, - GLenum format, GLenum type, - const struct gl_pixelstore_attrib *packing, - GLvoid *pixels); - -extern void GLAPIENTRY -_mesa_ReadPixels( GLint x, GLint y, GLsizei width, GLsizei height, - GLenum format, GLenum type, GLvoid *pixels ); - -#endif diff --git a/dll/opengl/mesa/main/renderbuffer.c b/dll/opengl/mesa/main/renderbuffer.c deleted file mode 100644 index 36a66d0ced3..00000000000 --- a/dll/opengl/mesa/main/renderbuffer.c +++ /dev/null @@ -1,139 +0,0 @@ -/* - * Mesa 3-D graphics library - * Version: 6.5 - * - * Copyright (C) 1999-2006 Brian Paul All Rights Reserved. - * - * Permission is hereby granted, free of charge, to any person obtaining a - * copy of this software and associated documentation files (the "Software"), - * to deal in the Software without restriction, including without limitation - * the rights to use, copy, modify, merge, publish, distribute, sublicense, - * and/or sell copies of the Software, and to permit persons to whom the - * Software is furnished to do so, subject to the following conditions: - * - * The above copyright notice and this permission notice shall be included - * in all copies or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS - * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL - * BRIAN PAUL BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN - * AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN - * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. - */ - -#include - -/** - * Initialize the fields of a gl_renderbuffer to default values. - */ -void -_mesa_init_renderbuffer(struct gl_renderbuffer *rb, GLuint name) -{ - _glthread_INIT_MUTEX(rb->Mutex); - - rb->ClassID = 0; - rb->RefCount = 0; - rb->Delete = _mesa_delete_renderbuffer; - - /* The rest of these should be set later by the caller of this function or - * the AllocStorage method: - */ - rb->AllocStorage = NULL; - - rb->Width = 0; - rb->Height = 0; - rb->InternalFormat = GL_RGBA; - rb->Format = MESA_FORMAT_NONE; -} - - -/** - * Delete a gl_framebuffer. - * This is the default function for renderbuffer->Delete(). - */ -void -_mesa_delete_renderbuffer(struct gl_renderbuffer *rb) -{ - /* no-op */ -} - - -/** - * Attach a renderbuffer to a framebuffer. - * \param bufferName one of the BUFFER_x tokens - */ -void -_mesa_add_renderbuffer(struct gl_framebuffer *fb, - gl_buffer_index bufferName, struct gl_renderbuffer *rb) -{ - assert(fb); - assert(rb); - assert(bufferName < BUFFER_COUNT); - - /* There should be no previous renderbuffer on this attachment point, - * with the exception of depth/stencil since the same renderbuffer may - * be used for both. - */ - assert(bufferName == BUFFER_DEPTH || - bufferName == BUFFER_STENCIL || - fb->Attachment[bufferName].Renderbuffer == NULL); - - _mesa_reference_renderbuffer(&fb->Attachment[bufferName].Renderbuffer, rb); -} - - -/** - * Remove the named renderbuffer from the given framebuffer. - * \param bufferName one of the BUFFER_x tokens - */ -void -_mesa_remove_renderbuffer(struct gl_framebuffer *fb, - gl_buffer_index bufferName) -{ - assert(bufferName < BUFFER_COUNT); - _mesa_reference_renderbuffer(&fb->Attachment[bufferName].Renderbuffer, - NULL); -} - - -/** - * Set *ptr to point to rb. If *ptr points to another renderbuffer, - * dereference that buffer first. The new renderbuffer's refcount will - * be incremented. The old renderbuffer's refcount will be decremented. - * This is normally only called from the _mesa_reference_renderbuffer() macro - * when there's a real pointer change. - */ -void -_mesa_reference_renderbuffer_(struct gl_renderbuffer **ptr, - struct gl_renderbuffer *rb) -{ - if (*ptr) { - /* Unreference the old renderbuffer */ - GLboolean deleteFlag = GL_FALSE; - struct gl_renderbuffer *oldRb = *ptr; - - _glthread_LOCK_MUTEX(oldRb->Mutex); - ASSERT(oldRb->RefCount > 0); - oldRb->RefCount--; - /*printf("RB DECR %p (%d) to %d\n", (void*) oldRb, oldRb->Name, oldRb->RefCount);*/ - deleteFlag = (oldRb->RefCount == 0); - _glthread_UNLOCK_MUTEX(oldRb->Mutex); - - if (deleteFlag) { - oldRb->Delete(oldRb); - } - - *ptr = NULL; - } - assert(!*ptr); - - if (rb) { - /* reference new renderbuffer */ - _glthread_LOCK_MUTEX(rb->Mutex); - rb->RefCount++; - /*printf("RB INCR %p (%d) to %d\n", (void*) rb, rb->Name, rb->RefCount);*/ - _glthread_UNLOCK_MUTEX(rb->Mutex); - *ptr = rb; - } -} diff --git a/dll/opengl/mesa/main/renderbuffer.h b/dll/opengl/mesa/main/renderbuffer.h deleted file mode 100644 index ee3a159afe1..00000000000 --- a/dll/opengl/mesa/main/renderbuffer.h +++ /dev/null @@ -1,64 +0,0 @@ -/* - * Mesa 3-D graphics library - * Version: 6.5 - * - * Copyright (C) 1999-2005 Brian Paul All Rights Reserved. - * - * Permission is hereby granted, free of charge, to any person obtaining a - * copy of this software and associated documentation files (the "Software"), - * to deal in the Software without restriction, including without limitation - * the rights to use, copy, modify, merge, publish, distribute, sublicense, - * and/or sell copies of the Software, and to permit persons to whom the - * Software is furnished to do so, subject to the following conditions: - * - * The above copyright notice and this permission notice shall be included - * in all copies or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS - * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL - * BRIAN PAUL BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN - * AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN - * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. - */ - - -#ifndef RENDERBUFFER_H -#define RENDERBUFFER_H - -#include "glheader.h" -#include "mtypes.h" - -struct gl_context; -struct gl_framebuffer; -struct gl_renderbuffer; - -extern void -_mesa_init_renderbuffer(struct gl_renderbuffer *rb, GLuint name); - -extern void -_mesa_delete_renderbuffer(struct gl_renderbuffer *rb); - -extern void -_mesa_add_renderbuffer(struct gl_framebuffer *fb, - gl_buffer_index bufferName, struct gl_renderbuffer *rb); - -extern void -_mesa_remove_renderbuffer(struct gl_framebuffer *fb, - gl_buffer_index bufferName); - -extern void -_mesa_reference_renderbuffer_(struct gl_renderbuffer **ptr, - struct gl_renderbuffer *rb); - -static inline void -_mesa_reference_renderbuffer(struct gl_renderbuffer **ptr, - struct gl_renderbuffer *rb) -{ - if (*ptr != rb) - _mesa_reference_renderbuffer_(ptr, rb); -} - - - -#endif /* RENDERBUFFER_H */ diff --git a/dll/opengl/mesa/main/scissor.c b/dll/opengl/mesa/main/scissor.c deleted file mode 100644 index 6f5add5ceb8..00000000000 --- a/dll/opengl/mesa/main/scissor.c +++ /dev/null @@ -1,95 +0,0 @@ -/* - * Mesa 3-D graphics library - * Version: 7.1 - * - * Copyright (C) 1999-2007 Brian Paul All Rights Reserved. - * - * Permission is hereby granted, free of charge, to any person obtaining a - * copy of this software and associated documentation files (the "Software"), - * to deal in the Software without restriction, including without limitation - * the rights to use, copy, modify, merge, publish, distribute, sublicense, - * and/or sell copies of the Software, and to permit persons to whom the - * Software is furnished to do so, subject to the following conditions: - * - * The above copyright notice and this permission notice shall be included - * in all copies or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS - * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL - * BRIAN PAUL BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN - * AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN - * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. - */ - -#include - -/** - * Called via glScissor - */ -void GLAPIENTRY -_mesa_Scissor( GLint x, GLint y, GLsizei width, GLsizei height ) -{ - GET_CURRENT_CONTEXT(ctx); - ASSERT_OUTSIDE_BEGIN_END(ctx); - - if (MESA_VERBOSE & VERBOSE_API) - _mesa_debug(ctx, "glScissor %d %d %d %d\n", x, y, width, height); - - if (width < 0 || height < 0) { - _mesa_error( ctx, GL_INVALID_VALUE, "glScissor" ); - return; - } - - _mesa_set_scissor(ctx, x, y, width, height); -} - - -/** - * Define the scissor box. - * - * \param x, y coordinates of the scissor box lower-left corner. - * \param width width of the scissor box. - * \param height height of the scissor box. - * - * \sa glScissor(). - * - * Verifies the parameters and updates __struct gl_contextRec::Scissor. On a - * change flushes the vertices and notifies the driver via - * the dd_function_table::Scissor callback. - */ -void -_mesa_set_scissor(struct gl_context *ctx, - GLint x, GLint y, GLsizei width, GLsizei height) -{ - if (x == ctx->Scissor.X && - y == ctx->Scissor.Y && - width == ctx->Scissor.Width && - height == ctx->Scissor.Height) - return; - - FLUSH_VERTICES(ctx, _NEW_SCISSOR); - ctx->Scissor.X = x; - ctx->Scissor.Y = y; - ctx->Scissor.Width = width; - ctx->Scissor.Height = height; - - if (ctx->Driver.Scissor) - ctx->Driver.Scissor( ctx, x, y, width, height ); -} - - -/** - * Initialize the context's scissor state. - * \param ctx the GL context. - */ -void -_mesa_init_scissor(struct gl_context *ctx) -{ - /* Scissor group */ - ctx->Scissor.Enabled = GL_FALSE; - ctx->Scissor.X = 0; - ctx->Scissor.Y = 0; - ctx->Scissor.Width = 0; - ctx->Scissor.Height = 0; -} diff --git a/dll/opengl/mesa/main/scissor.h b/dll/opengl/mesa/main/scissor.h deleted file mode 100644 index da9385e2b95..00000000000 --- a/dll/opengl/mesa/main/scissor.h +++ /dev/null @@ -1,47 +0,0 @@ -/* - * Mesa 3-D graphics library - * Version: 7.1 - * - * Copyright (C) 1999-2007 Brian Paul All Rights Reserved. - * - * Permission is hereby granted, free of charge, to any person obtaining a - * copy of this software and associated documentation files (the "Software"), - * to deal in the Software without restriction, including without limitation - * the rights to use, copy, modify, merge, publish, distribute, sublicense, - * and/or sell copies of the Software, and to permit persons to whom the - * Software is furnished to do so, subject to the following conditions: - * - * The above copyright notice and this permission notice shall be included - * in all copies or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS - * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL - * BRIAN PAUL BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN - * AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN - * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. - */ - - -#ifndef SCISSOR_H -#define SCISSOR_H - - -#include "glheader.h" - -struct gl_context; - -extern void GLAPIENTRY -_mesa_Scissor( GLint x, GLint y, GLsizei width, GLsizei height ); - - -extern void -_mesa_set_scissor(struct gl_context *ctx, - GLint x, GLint y, GLsizei width, GLsizei height); - - -extern void -_mesa_init_scissor(struct gl_context *ctx); - - -#endif diff --git a/dll/opengl/mesa/main/shared.c b/dll/opengl/mesa/main/shared.c deleted file mode 100644 index cc9ae8ba38c..00000000000 --- a/dll/opengl/mesa/main/shared.c +++ /dev/null @@ -1,214 +0,0 @@ -/* - * Mesa 3-D graphics library - * Version: 7.5 - * - * Copyright (C) 2009 VMware, Inc. All Rights Reserved. - * - * Permission is hereby granted, free of charge, to any person obtaining a - * copy of this software and associated documentation files (the "Software"), - * to deal in the Software without restriction, including without limitation - * the rights to use, copy, modify, merge, publish, distribute, sublicense, - * and/or sell copies of the Software, and to permit persons to whom the - * Software is furnished to do so, subject to the following conditions: - * - * The above copyright notice and this permission notice shall be included - * in all copies or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS - * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL - * BRIAN PAUL BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN - * AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN - * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. - */ - -/** - * \file shared.c - * Shared-context state - */ - -#include - -/** - * Allocate and initialize a shared context state structure. - * Initializes the display list, texture objects and vertex programs hash - * tables, allocates the texture objects. If it runs out of memory, frees - * everything already allocated before returning NULL. - * - * \return pointer to a gl_shared_state structure on success, or NULL on - * failure. - */ -struct gl_shared_state * -_mesa_alloc_shared_state(struct gl_context *ctx) -{ - struct gl_shared_state *shared; - GLuint i; - - shared = CALLOC_STRUCT(gl_shared_state); - if (!shared) - return NULL; - - _glthread_INIT_MUTEX(shared->Mutex); - - shared->DisplayList = _mesa_NewHashTable(); - shared->TexObjects = _mesa_NewHashTable(); - - shared->BufferObjects = _mesa_NewHashTable(); - - /* Allocate the default buffer object */ - shared->NullBufferObj = ctx->Driver.NewBufferObject(ctx, 0, 0); - - /* Create default texture objects */ - for (i = 0; i < NUM_TEXTURE_TARGETS; i++) { - /* NOTE: the order of these enums matches the TEXTURE_x_INDEX values */ - static const GLenum targets[NUM_TEXTURE_TARGETS] = { - GL_TEXTURE_CUBE_MAP, - GL_TEXTURE_2D, - GL_TEXTURE_1D - }; - STATIC_ASSERT(Elements(targets) == NUM_TEXTURE_TARGETS); - shared->DefaultTex[i] = ctx->Driver.NewTextureObject(ctx, 0, targets[i]); - } - - /* sanity check */ - assert(shared->DefaultTex[TEXTURE_1D_INDEX]->RefCount == 1); - - /* Mutex and timestamp for texobj state validation */ - _glthread_INIT_MUTEX(shared->TexMutex); - shared->TextureStateStamp = 0; - - return shared; -} - - -/** - * Callback for deleting a display list. Called by _mesa_HashDeleteAll(). - */ -static void -delete_displaylist_cb(GLuint id, void *data, void *userData) -{ - struct gl_display_list *list = (struct gl_display_list *) data; - struct gl_context *ctx = (struct gl_context *) userData; - _mesa_delete_list(ctx, list); -} - - -/** - * Callback for deleting a texture object. Called by _mesa_HashDeleteAll(). - */ -static void -delete_texture_cb(GLuint id, void *data, void *userData) -{ - struct gl_texture_object *texObj = (struct gl_texture_object *) data; - struct gl_context *ctx = (struct gl_context *) userData; - ctx->Driver.DeleteTexture(ctx, texObj); -} - - -/** - * Callback for deleting a buffer object. Called by _mesa_HashDeleteAll(). - */ -static void -delete_bufferobj_cb(GLuint id, void *data, void *userData) -{ - struct gl_buffer_object *bufObj = (struct gl_buffer_object *) data; - struct gl_context *ctx = (struct gl_context *) userData; - if (_mesa_bufferobj_mapped(bufObj)) { - ctx->Driver.UnmapBuffer(ctx, bufObj); - bufObj->Pointer = NULL; - } - _mesa_reference_buffer_object(ctx, &bufObj, NULL); -} - - -/** - * Deallocate a shared state object and all children structures. - * - * \param ctx GL context. - * \param shared shared state pointer. - * - * Frees the display lists, the texture objects (calling the driver texture - * deletion callback to free its private data) and the vertex programs, as well - * as their hash tables. - * - * \sa alloc_shared_state(). - */ -static void -free_shared_state(struct gl_context *ctx, struct gl_shared_state *shared) -{ - GLuint i; - - /* Free the dummy/fallback texture object */ - if (shared->FallbackTex) - ctx->Driver.DeleteTexture(ctx, shared->FallbackTex); - - /* - * Free display lists - */ - _mesa_HashDeleteAll(shared->DisplayList, delete_displaylist_cb, ctx); - _mesa_DeleteHashTable(shared->DisplayList); - - _mesa_HashDeleteAll(shared->BufferObjects, delete_bufferobj_cb, ctx); - _mesa_DeleteHashTable(shared->BufferObjects); - - _mesa_reference_buffer_object(ctx, &shared->NullBufferObj, NULL); - - /* - * Free texture objects (after FBOs since some textures might have - * been bound to FBOs). - */ - ASSERT(ctx->Driver.DeleteTexture); - /* the default textures */ - for (i = 0; i < NUM_TEXTURE_TARGETS; i++) { - ctx->Driver.DeleteTexture(ctx, shared->DefaultTex[i]); - } - - /* all other textures */ - _mesa_HashDeleteAll(shared->TexObjects, delete_texture_cb, ctx); - _mesa_DeleteHashTable(shared->TexObjects); - - _glthread_DESTROY_MUTEX(shared->Mutex); - _glthread_DESTROY_MUTEX(shared->TexMutex); - - free(shared); -} - - -/** - * gl_shared_state objects are ref counted. - * If ptr's refcount goes to zero, free the shared state. - */ -void -_mesa_reference_shared_state(struct gl_context *ctx, - struct gl_shared_state **ptr, - struct gl_shared_state *state) -{ - if (*ptr == state) - return; - - if (*ptr) { - /* unref old state */ - struct gl_shared_state *old = *ptr; - GLboolean delete; - - _glthread_LOCK_MUTEX(old->Mutex); - assert(old->RefCount >= 1); - old->RefCount--; - delete = (old->RefCount == 0); - _glthread_UNLOCK_MUTEX(old->Mutex); - - if (delete) { - free_shared_state(ctx, old); - } - - *ptr = NULL; - } - - if (state) { - /* reference new state */ - _glthread_LOCK_MUTEX(state->Mutex); - state->RefCount++; - *ptr = state; - _glthread_UNLOCK_MUTEX(state->Mutex); - } -} diff --git a/dll/opengl/mesa/main/shared.h b/dll/opengl/mesa/main/shared.h deleted file mode 100644 index 3fe4578cf31..00000000000 --- a/dll/opengl/mesa/main/shared.h +++ /dev/null @@ -1,40 +0,0 @@ -/* - * Mesa 3-D graphics library - * Version: 7.5 - * - * Copyright (C) 2009 VMware, Inc. All Rights Reserved. - * - * Permission is hereby granted, free of charge, to any person obtaining a - * copy of this software and associated documentation files (the "Software"), - * to deal in the Software without restriction, including without limitation - * the rights to use, copy, modify, merge, publish, distribute, sublicense, - * and/or sell copies of the Software, and to permit persons to whom the - * Software is furnished to do so, subject to the following conditions: - * - * The above copyright notice and this permission notice shall be included - * in all copies or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS - * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL - * BRIAN PAUL BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN - * AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN - * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. - */ - -#ifndef SHARED_H -#define SHARED_H - -struct gl_context; - -void -_mesa_reference_shared_state(struct gl_context *ctx, - struct gl_shared_state **ptr, - struct gl_shared_state *state); - - -struct gl_shared_state * -_mesa_alloc_shared_state(struct gl_context *ctx); - - -#endif diff --git a/dll/opengl/mesa/main/simple_list.h b/dll/opengl/mesa/main/simple_list.h deleted file mode 100644 index 9417108a07f..00000000000 --- a/dll/opengl/mesa/main/simple_list.h +++ /dev/null @@ -1,210 +0,0 @@ -/** - * \file simple_list.h - * Simple macros for type-safe, intrusive lists. - * - * Intended to work with a list sentinal which is created as an empty - * list. Insert & delete are O(1). - * - * \author - * (C) 1997, Keith Whitwell - */ - -/* - * Mesa 3-D graphics library - * Version: 3.5 - * - * Copyright (C) 1999-2001 Brian Paul All Rights Reserved. - * - * Permission is hereby granted, free of charge, to any person obtaining a - * copy of this software and associated documentation files (the "Software"), - * to deal in the Software without restriction, including without limitation - * the rights to use, copy, modify, merge, publish, distribute, sublicense, - * and/or sell copies of the Software, and to permit persons to whom the - * Software is furnished to do so, subject to the following conditions: - * - * The above copyright notice and this permission notice shall be included - * in all copies or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS - * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL - * BRIAN PAUL BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN - * AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN - * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. - */ - - -#ifndef _SIMPLE_LIST_H -#define _SIMPLE_LIST_H - -#ifdef __cplusplus -extern "C" { -#endif - -struct simple_node { - struct simple_node *next; - struct simple_node *prev; -}; - -/** - * Remove an element from list. - * - * \param elem element to remove. - */ -#define remove_from_list(elem) \ -do { \ - (elem)->next->prev = (elem)->prev; \ - (elem)->prev->next = (elem)->next; \ -} while (0) - -/** - * Insert an element to the list head. - * - * \param list list. - * \param elem element to insert. - */ -#define insert_at_head(list, elem) \ -do { \ - (elem)->prev = list; \ - (elem)->next = (list)->next; \ - (list)->next->prev = elem; \ - (list)->next = elem; \ -} while(0) - -/** - * Insert an element to the list tail. - * - * \param list list. - * \param elem element to insert. - */ -#define insert_at_tail(list, elem) \ -do { \ - (elem)->next = list; \ - (elem)->prev = (list)->prev; \ - (list)->prev->next = elem; \ - (list)->prev = elem; \ -} while(0) - -/** - * Move an element to the list head. - * - * \param list list. - * \param elem element to move. - */ -#define move_to_head(list, elem) \ -do { \ - remove_from_list(elem); \ - insert_at_head(list, elem); \ -} while (0) - -/** - * Move an element to the list tail. - * - * \param list list. - * \param elem element to move. - */ -#define move_to_tail(list, elem) \ -do { \ - remove_from_list(elem); \ - insert_at_tail(list, elem); \ -} while (0) - -/** - * Make a empty list empty. - * - * \param sentinal list (sentinal element). - */ -#define make_empty_list(sentinal) \ -do { \ - (sentinal)->next = sentinal; \ - (sentinal)->prev = sentinal; \ -} while (0) - -/** - * Get list first element. - * - * \param list list. - * - * \return pointer to first element. - */ -#define first_elem(list) ((list)->next) - -/** - * Get list last element. - * - * \param list list. - * - * \return pointer to last element. - */ -#define last_elem(list) ((list)->prev) - -/** - * Get next element. - * - * \param elem element. - * - * \return pointer to next element. - */ -#define next_elem(elem) ((elem)->next) - -/** - * Get previous element. - * - * \param elem element. - * - * \return pointer to previous element. - */ -#define prev_elem(elem) ((elem)->prev) - -/** - * Test whether element is at end of the list. - * - * \param list list. - * \param elem element. - * - * \return non-zero if element is at end of list, or zero otherwise. - */ -#define at_end(list, elem) ((elem) == (list)) - -/** - * Test if a list is empty. - * - * \param list list. - * - * \return non-zero if list empty, or zero otherwise. - */ -#define is_empty_list(list) ((list)->next == (list)) - -/** - * Walk through the elements of a list. - * - * \param ptr pointer to the current element. - * \param list list. - * - * \note It should be followed by a { } block or a single statement, as in a \c - * for loop. - */ -#define foreach(ptr, list) \ - for( ptr=(list)->next ; ptr!=list ; ptr=(ptr)->next ) - -/** - * Walk through the elements of a list. - * - * Same as #foreach but lets you unlink the current value during a list - * traversal. Useful for freeing a list, element by element. - * - * \param ptr pointer to the current element. - * \param t temporary pointer. - * \param list list. - * - * \note It should be followed by a { } block or a single statement, as in a \c - * for loop. - */ -#define foreach_s(ptr, t, list) \ - for(ptr=(list)->next,t=(ptr)->next; list != ptr; ptr=t, t=(t)->next) - -#ifdef __cplusplus -} -#endif - -#endif diff --git a/dll/opengl/mesa/main/state.c b/dll/opengl/mesa/main/state.c deleted file mode 100644 index 428c8dafaaf..00000000000 --- a/dll/opengl/mesa/main/state.c +++ /dev/null @@ -1,303 +0,0 @@ -/* - * Mesa 3-D graphics library - * Version: 7.3 - * - * Copyright (C) 1999-2008 Brian Paul All Rights Reserved. - * - * Permission is hereby granted, free of charge, to any person obtaining a - * copy of this software and associated documentation files (the "Software"), - * to deal in the Software without restriction, including without limitation - * the rights to use, copy, modify, merge, publish, distribute, sublicense, - * and/or sell copies of the Software, and to permit persons to whom the - * Software is furnished to do so, subject to the following conditions: - * - * The above copyright notice and this permission notice shall be included - * in all copies or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS - * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL - * BRIAN PAUL BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN - * AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN - * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. - */ - - -/** - * \file state.c - * State management. - * - * This file manages recalculation of derived values in struct gl_context. - */ - -#include - - -/** - * Helper for update_arrays(). - * \return min(current min, array->_MaxElement). - */ -static GLuint -update_min(GLuint min, struct gl_client_array *array) -{ - _mesa_update_array_max_element(array); - return MIN2(min, array->_MaxElement); -} - - -/** - * Update ctx->Array._MaxElement (the max legal index into all enabled arrays). - * Need to do this upon new array state or new buffer object state. - */ -static void -update_arrays( struct gl_context *ctx ) -{ - GLuint min = ~0; - - /* find min of _MaxElement values for all enabled arrays. - * Note that the generic arrays always take precedence over - * the legacy arrays. - */ - - /* 0 */ - if (ctx->Array.VertexAttrib[VERT_ATTRIB_POS].Enabled) { - min = update_min(min, &ctx->Array.VertexAttrib[VERT_ATTRIB_POS]); - } - - /* 2 */ - if (ctx->Array.VertexAttrib[VERT_ATTRIB_NORMAL].Enabled) { - min = update_min(min, &ctx->Array.VertexAttrib[VERT_ATTRIB_NORMAL]); - } - - /* 3 */ - if (ctx->Array.VertexAttrib[VERT_ATTRIB_COLOR].Enabled) { - min = update_min(min, &ctx->Array.VertexAttrib[VERT_ATTRIB_COLOR]); - } - - /* 5 */ - if (ctx->Array.VertexAttrib[VERT_ATTRIB_FOG].Enabled) { - min = update_min(min, &ctx->Array.VertexAttrib[VERT_ATTRIB_FOG]); - } - - /* 6 */ - if (ctx->Array.VertexAttrib[VERT_ATTRIB_COLOR_INDEX].Enabled) { - min = update_min(min, &ctx->Array.VertexAttrib[VERT_ATTRIB_COLOR_INDEX]); - } - - /* 8 */ - if (ctx->Array.VertexAttrib[VERT_ATTRIB_TEX].Enabled) { - min = update_min(min, &ctx->Array.VertexAttrib[VERT_ATTRIB_TEX]); - } - - if (ctx->Array.VertexAttrib[VERT_ATTRIB_EDGEFLAG].Enabled) { - min = update_min(min, &ctx->Array.VertexAttrib[VERT_ATTRIB_EDGEFLAG]); - } - - /* _MaxElement is one past the last legal array element */ - ctx->Array._MaxElement = min; -} - -static void -update_viewport_matrix(struct gl_context *ctx) -{ - const GLfloat depthMax = ctx->DrawBuffer->_DepthMaxF; - - ASSERT(depthMax > 0); - - /* Compute scale and bias values. This is really driver-specific - * and should be maintained elsewhere if at all. - * NOTE: RasterPos uses this. - */ - _math_matrix_viewport(&ctx->Viewport._WindowMap, - ctx->Viewport.X, ctx->Viewport.Y, - ctx->Viewport.Width, ctx->Viewport.Height, - ctx->Viewport.Near, ctx->Viewport.Far, - depthMax); -} - - -/* - * Check polygon state and set DD_TRI_CULL_FRONT_BACK and/or DD_TRI_OFFSET - * in ctx->_TriangleCaps if needed. - */ -static void -update_polygon(struct gl_context *ctx) -{ - ctx->_TriangleCaps &= ~(DD_TRI_CULL_FRONT_BACK | DD_TRI_OFFSET); - - if (ctx->Polygon.CullFlag && ctx->Polygon.CullFaceMode == GL_FRONT_AND_BACK) - ctx->_TriangleCaps |= DD_TRI_CULL_FRONT_BACK; - - if ( ctx->Polygon.OffsetPoint - || ctx->Polygon.OffsetLine - || ctx->Polygon.OffsetFill) - ctx->_TriangleCaps |= DD_TRI_OFFSET; -} - - -/** - * Update the ctx->_TriangleCaps bitfield. - * XXX that bitfield should really go away someday! - * This function must be called after other update_*() functions since - * there are dependencies on some other derived values. - */ -#if 0 -static void -update_tricaps(struct gl_context *ctx, GLbitfield new_state) -{ - ctx->_TriangleCaps = 0; - - /* - * Points - */ - if (1/*new_state & _NEW_POINT*/) { - if (ctx->Point.SmoothFlag) - ctx->_TriangleCaps |= DD_POINT_SMOOTH; - if (ctx->Point._Attenuated) - ctx->_TriangleCaps |= DD_POINT_ATTEN; - } - - /* - * Lines - */ - if (1/*new_state & _NEW_LINE*/) { - if (ctx->Line.SmoothFlag) - ctx->_TriangleCaps |= DD_LINE_SMOOTH; - if (ctx->Line.StippleFlag) - ctx->_TriangleCaps |= DD_LINE_STIPPLE; - } - - /* - * Polygons - */ - if (1/*new_state & _NEW_POLYGON*/) { - if (ctx->Polygon.SmoothFlag) - ctx->_TriangleCaps |= DD_TRI_SMOOTH; - if (ctx->Polygon.StippleFlag) - ctx->_TriangleCaps |= DD_TRI_STIPPLE; - if (ctx->Polygon.FrontMode != GL_FILL - || ctx->Polygon.BackMode != GL_FILL) - ctx->_TriangleCaps |= DD_TRI_UNFILLED; - if (ctx->Polygon.CullFlag - && ctx->Polygon.CullFaceMode == GL_FRONT_AND_BACK) - ctx->_TriangleCaps |= DD_TRI_CULL_FRONT_BACK; - if (ctx->Polygon.OffsetPoint || - ctx->Polygon.OffsetLine || - ctx->Polygon.OffsetFill) - ctx->_TriangleCaps |= DD_TRI_OFFSET; - } - - /* - * Lighting and shading - */ - if (ctx->Light.Enabled && ctx->Light.Model.TwoSide) - ctx->_TriangleCaps |= DD_TRI_LIGHT_TWOSIDE; - if (ctx->Light.ShadeModel == GL_FLAT) - ctx->_TriangleCaps |= DD_FLATSHADE; - if (_mesa_need_secondary_color(ctx)) - ctx->_TriangleCaps |= DD_SEPARATE_SPECULAR; -} -#endif - - -/** - * Compute derived GL state. - * If __struct gl_contextRec::NewState is non-zero then this function \b must - * be called before rendering anything. - * - * Calls dd_function_table::UpdateState to perform any internal state - * management necessary. - * - * \sa _mesa_update_modelview_project(), _mesa_update_texture(), - * _mesa_update_buffer_bounds(), - * _mesa_update_lighting() and _mesa_update_tnl_spaces(). - */ -void -_mesa_update_state_locked( struct gl_context *ctx ) -{ - GLbitfield new_state = ctx->NewState; - - if (new_state == _NEW_CURRENT_ATTRIB) - goto out; - - /* - * Now update derived state info - */ - - if (new_state & (_NEW_MODELVIEW|_NEW_PROJECTION)) - _mesa_update_modelview_project( ctx, new_state ); - - if (new_state & (_NEW_TEXTURE|_NEW_TEXTURE_MATRIX)) - _mesa_update_texture( ctx, new_state ); - - if (new_state & _NEW_BUFFERS) - _mesa_update_framebuffer(ctx); - - if (new_state & (_NEW_SCISSOR | _NEW_BUFFERS | _NEW_VIEWPORT)) - _mesa_update_draw_buffer_bounds( ctx ); - - if (new_state & _NEW_POLYGON) - update_polygon( ctx ); - - if (new_state & _NEW_LIGHT) - _mesa_update_lighting( ctx ); - - if (new_state & (_NEW_STENCIL | _NEW_BUFFERS)) - _mesa_update_stencil( ctx ); - - if (new_state & _NEW_PIXEL) - _mesa_update_pixel( ctx, new_state ); - - if (new_state & (_NEW_BUFFERS | _NEW_VIEWPORT)) - update_viewport_matrix(ctx); - -#if 0 - if (new_state & (_NEW_POINT | _NEW_LINE | _NEW_POLYGON | _NEW_LIGHT - | _NEW_STENCIL | _DD_NEW_SEPARATE_SPECULAR)) - update_tricaps( ctx, new_state ); -#endif - - /* ctx->_NeedEyeCoords is now up to date. - * - * If the truth value of this variable has changed, update for the - * new lighting space and recompute the positions of lights and the - * normal transform. - * - * If the lighting space hasn't changed, may still need to recompute - * light positions & normal transforms for other reasons. - */ - if (new_state & _MESA_NEW_NEED_EYE_COORDS) - _mesa_update_tnl_spaces( ctx, new_state ); - - if (new_state & (_NEW_ARRAY | _NEW_BUFFER_OBJECT)) - update_arrays( ctx ); - - out: - - /* - * Give the driver a chance to act upon the new_state flags. - * The driver might plug in different span functions, for example. - * Also, this is where the driver can invalidate the state of any - * active modules (such as swrast_setup, swrast, tnl, etc). - * - * Set ctx->NewState to zero to avoid recursion if - * Driver.UpdateState() has to call FLUSH_VERTICES(). (fixed?) - */ - new_state = ctx->NewState; - ctx->NewState = 0; - ctx->Driver.UpdateState(ctx, new_state); - ctx->Array.NewState = 0; - if (!ctx->Array.RebindArrays) - ctx->Array.RebindArrays = (new_state & _NEW_ARRAY) != 0; -} - - -/* This is the usual entrypoint for state updates: - */ -void -_mesa_update_state( struct gl_context *ctx ) -{ - _mesa_lock_context_textures(ctx); - _mesa_update_state_locked(ctx); - _mesa_unlock_context_textures(ctx); -} diff --git a/dll/opengl/mesa/main/state.h b/dll/opengl/mesa/main/state.h deleted file mode 100644 index 3793cab12f2..00000000000 --- a/dll/opengl/mesa/main/state.h +++ /dev/null @@ -1,40 +0,0 @@ -/* - * Mesa 3-D graphics library - * Version: 7.3 - * - * Copyright (C) 1999-2008 Brian Paul All Rights Reserved. - * - * Permission is hereby granted, free of charge, to any person obtaining a - * copy of this software and associated documentation files (the "Software"), - * to deal in the Software without restriction, including without limitation - * the rights to use, copy, modify, merge, publish, distribute, sublicense, - * and/or sell copies of the Software, and to permit persons to whom the - * Software is furnished to do so, subject to the following conditions: - * - * The above copyright notice and this permission notice shall be included - * in all copies or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS - * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL - * BRIAN PAUL BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN - * AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN - * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. - */ - - -#ifndef STATE_H -#define STATE_H - -#include "mtypes.h" - -extern void -_mesa_update_state(struct gl_context *ctx); - -/* As above but can only be called between _mesa_lock_context_textures() and - * _mesa_unlock_context_textures(). - */ -extern void -_mesa_update_state_locked(struct gl_context *ctx); - -#endif diff --git a/dll/opengl/mesa/main/stencil.c b/dll/opengl/mesa/main/stencil.c deleted file mode 100644 index 1aae25334f8..00000000000 --- a/dll/opengl/mesa/main/stencil.c +++ /dev/null @@ -1,249 +0,0 @@ -/* - * Mesa 3-D graphics library - * Version: 7.1 - * - * Copyright (C) 1999-2007 Brian Paul All Rights Reserved. - * - * Permission is hereby granted, free of charge, to any person obtaining a - * copy of this software and associated documentation files (the "Software"), - * to deal in the Software without restriction, including without limitation - * the rights to use, copy, modify, merge, publish, distribute, sublicense, - * and/or sell copies of the Software, and to permit persons to whom the - * Software is furnished to do so, subject to the following conditions: - * - * The above copyright notice and this permission notice shall be included - * in all copies or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS - * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL - * BRIAN PAUL BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN - * AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN - * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. - */ - - -/** - * \file stencil.c - * Stencil operations. - * - */ - -#include - -static GLboolean -validate_stencil_op(struct gl_context *ctx, GLenum op) -{ - switch (op) { - case GL_KEEP: - case GL_ZERO: - case GL_REPLACE: - case GL_INCR: - case GL_DECR: - case GL_INVERT: - case GL_INCR_WRAP: - case GL_DECR_WRAP: - return GL_TRUE; - default: - return GL_FALSE; - } -} - - -static GLboolean -validate_stencil_func(struct gl_context *ctx, GLenum func) -{ - switch (func) { - case GL_NEVER: - case GL_LESS: - case GL_LEQUAL: - case GL_GREATER: - case GL_GEQUAL: - case GL_EQUAL: - case GL_NOTEQUAL: - case GL_ALWAYS: - return GL_TRUE; - default: - return GL_FALSE; - } -} - - -/** - * Set the clear value for the stencil buffer. - * - * \param s clear value. - * - * \sa glClearStencil(). - * - * Updates gl_stencil_attrib::Clear. On change - * flushes the vertices and notifies the driver via - * the dd_function_table::ClearStencil callback. - */ -void GLAPIENTRY -_mesa_ClearStencil( GLint s ) -{ - GET_CURRENT_CONTEXT(ctx); - ASSERT_OUTSIDE_BEGIN_END(ctx); - - if (ctx->Stencil.Clear == (GLuint) s) - return; - - FLUSH_VERTICES(ctx, _NEW_STENCIL); - ctx->Stencil.Clear = (GLuint) s; - - if (ctx->Driver.ClearStencil) { - ctx->Driver.ClearStencil( ctx, s ); - } -} - -/** - * Set the function and reference value for stencil testing. - * - * \param func test function. - * \param ref reference value. - * \param mask bitmask. - * - * \sa glStencilFunc(). - * - * Verifies the parameters and updates the respective values in - * __struct gl_contextRec::Stencil. On change flushes the vertices and notifies the - * driver via the dd_function_table::StencilFunc callback. - */ -void GLAPIENTRY -_mesa_StencilFunc( GLenum func, GLint ref, GLuint mask ) -{ - GET_CURRENT_CONTEXT(ctx); - const GLint stencilMax = (1 << ctx->DrawBuffer->Visual.stencilBits) - 1; - ASSERT_OUTSIDE_BEGIN_END(ctx); - - if (MESA_VERBOSE & VERBOSE_API) - _mesa_debug(ctx, "glStencilFunc()\n"); - - if (!validate_stencil_func(ctx, func)) { - _mesa_error(ctx, GL_INVALID_ENUM, "glStencilFunc(func)"); - return; - } - - ref = CLAMP( ref, 0, stencilMax ); - - /* set both front and back state */ - if (ctx->Stencil.Function == func && - ctx->Stencil.ValueMask == mask && - ctx->Stencil.Ref == ref) - return; - FLUSH_VERTICES(ctx, _NEW_STENCIL); - ctx->Stencil.Function = func; - ctx->Stencil.Ref = ref; - ctx->Stencil.ValueMask = mask; -} - - -/** - * Set the stencil writing mask. - * - * \param mask bit-mask to enable/disable writing of individual bits in the - * stencil planes. - * - * \sa glStencilMask(). - * - * Updates gl_stencil_attrib::WriteMask. On change flushes the vertices and - * notifies the driver via the dd_function_table::StencilMask callback. - */ -void GLAPIENTRY -_mesa_StencilMask( GLuint mask ) -{ - GET_CURRENT_CONTEXT(ctx); - - if (MESA_VERBOSE & VERBOSE_API) - _mesa_debug(ctx, "glStencilMask()\n"); - - ASSERT_OUTSIDE_BEGIN_END(ctx); - - /* set both front and back state */ - if (ctx->Stencil.WriteMask == mask) - return; - FLUSH_VERTICES(ctx, _NEW_STENCIL); - ctx->Stencil.WriteMask = mask; -} - - -/** - * Set the stencil test actions. - * - * \param fail action to take when stencil test fails. - * \param zfail action to take when stencil test passes, but depth test fails. - * \param zpass action to take when stencil test passes and the depth test - * passes (or depth testing is not enabled). - * - * \sa glStencilOp(). - * - * Verifies the parameters and updates the respective fields in - * __struct gl_contextRec::Stencil. On change flushes the vertices and notifies the - * driver via the dd_function_table::StencilOp callback. - */ -void GLAPIENTRY -_mesa_StencilOp(GLenum fail, GLenum zfail, GLenum zpass) -{ - GET_CURRENT_CONTEXT(ctx); - - if (MESA_VERBOSE & VERBOSE_API) - _mesa_debug(ctx, "glStencilOp()\n"); - - ASSERT_OUTSIDE_BEGIN_END(ctx); - - if (!validate_stencil_op(ctx, fail)) { - _mesa_error(ctx, GL_INVALID_ENUM, "glStencilOp(sfail)"); - return; - } - if (!validate_stencil_op(ctx, zfail)) { - _mesa_error(ctx, GL_INVALID_ENUM, "glStencilOp(zfail)"); - return; - } - if (!validate_stencil_op(ctx, zpass)) { - _mesa_error(ctx, GL_INVALID_ENUM, "glStencilOp(zpass)"); - return; - } - - /* set both front and back state */ - if (ctx->Stencil.ZFailFunc == zfail && - ctx->Stencil.ZPassFunc == zpass && - ctx->Stencil.FailFunc == fail) - return; - FLUSH_VERTICES(ctx, _NEW_STENCIL); - ctx->Stencil.ZFailFunc = zfail; - ctx->Stencil.ZPassFunc = zpass; - ctx->Stencil.FailFunc = fail; -} - -/** - * Update derived stencil state. - */ -void -_mesa_update_stencil(struct gl_context *ctx) -{ - ctx->Stencil._Enabled = (ctx->Stencil.Enabled && - ctx->DrawBuffer->Visual.stencilBits > 0); -} - - -/** - * Initialize the context stipple state. - * - * \param ctx GL context. - * - * Initializes __struct gl_contextRec::Stencil attribute group. - */ -void -_mesa_init_stencil(struct gl_context *ctx) -{ - ctx->Stencil.Enabled = GL_FALSE; - ctx->Stencil.Function = GL_ALWAYS; - ctx->Stencil.FailFunc = GL_KEEP; - ctx->Stencil.ZPassFunc = GL_KEEP; - ctx->Stencil.ZFailFunc = GL_KEEP; - ctx->Stencil.Ref = 0; - ctx->Stencil.ValueMask = ~0U; - ctx->Stencil.WriteMask = ~0U; - ctx->Stencil.Clear = 0; -} diff --git a/dll/opengl/mesa/main/stencil.h b/dll/opengl/mesa/main/stencil.h deleted file mode 100644 index 74f97c7eda1..00000000000 --- a/dll/opengl/mesa/main/stencil.h +++ /dev/null @@ -1,69 +0,0 @@ -/** - * \file stencil.h - * Stencil operations. - */ - -/* - * Mesa 3-D graphics library - * Version: 7.1 - * - * Copyright (C) 1999-2007 Brian Paul All Rights Reserved. - * - * Permission is hereby granted, free of charge, to any person obtaining a - * copy of this software and associated documentation files (the "Software"), - * to deal in the Software without restriction, including without limitation - * the rights to use, copy, modify, merge, publish, distribute, sublicense, - * and/or sell copies of the Software, and to permit persons to whom the - * Software is furnished to do so, subject to the following conditions: - * - * The above copyright notice and this permission notice shall be included - * in all copies or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS - * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL - * BRIAN PAUL BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN - * AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN - * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. - */ - - -#ifndef STENCIL_H -#define STENCIL_H - - -#include "glheader.h" - -struct gl_context; - -extern void GLAPIENTRY -_mesa_ClearStencil( GLint s ); - - -extern void GLAPIENTRY -_mesa_StencilFunc( GLenum func, GLint ref, GLuint mask ); - - -extern void GLAPIENTRY -_mesa_StencilMask( GLuint mask ); - - -extern void GLAPIENTRY -_mesa_StencilOp( GLenum fail, GLenum zfail, GLenum zpass ); - - -extern void GLAPIENTRY -_mesa_ActiveStencilFaceEXT(GLenum face); - -extern void GLAPIENTRY -_mesa_StencilMaskSeparate(GLenum face, GLuint mask); - - -extern void -_mesa_update_stencil(struct gl_context *ctx); - - -extern void -_mesa_init_stencil( struct gl_context * ctx ); - -#endif diff --git a/dll/opengl/mesa/main/texenv.c b/dll/opengl/mesa/main/texenv.c deleted file mode 100644 index 3e7004bcbf5..00000000000 --- a/dll/opengl/mesa/main/texenv.c +++ /dev/null @@ -1,635 +0,0 @@ -/* - * Mesa 3-D graphics library - * Version: 7.5 - * - * Copyright (C) 1999-2008 Brian Paul All Rights Reserved. - * Copyright (C) 2009 VMware, Inc. All Rights Reserved. - * - * Permission is hereby granted, free of charge, to any person obtaining a - * copy of this software and associated documentation files (the "Software"), - * to deal in the Software without restriction, including without limitation - * the rights to use, copy, modify, merge, publish, distribute, sublicense, - * and/or sell copies of the Software, and to permit persons to whom the - * Software is furnished to do so, subject to the following conditions: - * - * The above copyright notice and this permission notice shall be included - * in all copies or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS - * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL - * BRIAN PAUL BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN - * AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN - * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. - */ - -/** - * \file texenv.c - * - * glTexEnv-related functions - */ - -#include - -#define TE_ERROR(errCode, msg, value) \ - _mesa_error(ctx, errCode, msg, _mesa_lookup_enum_by_nr(value)); - - -/** Set texture env mode */ -static void -set_env_mode(struct gl_context *ctx, - struct gl_texture_unit *texUnit, - GLenum mode) -{ - GLboolean legal; - - if (texUnit->EnvMode == mode) - return; - - switch (mode) { - case GL_MODULATE: - case GL_BLEND: - case GL_DECAL: - case GL_REPLACE: - case GL_ADD: - case GL_COMBINE: - legal = GL_TRUE; - break; - case GL_REPLACE_EXT: - mode = GL_REPLACE; /* GL_REPLACE_EXT != GL_REPLACE */ - legal = GL_TRUE; - break; - case GL_COMBINE4_NV: - legal = ctx->Extensions.NV_texture_env_combine4; - break; - default: - legal = GL_FALSE; - } - - if (legal) { - FLUSH_VERTICES(ctx, _NEW_TEXTURE); - texUnit->EnvMode = mode; - } - else { - TE_ERROR(GL_INVALID_ENUM, "glTexEnv(param=%s)", mode); - } -} - - -static void -set_env_color(struct gl_context *ctx, - struct gl_texture_unit *texUnit, - const GLfloat *color) -{ - if (TEST_EQ_4V(color, texUnit->EnvColor)) - return; - FLUSH_VERTICES(ctx, _NEW_TEXTURE); - COPY_4FV(texUnit->EnvColor, color); -} - - -/** Set an RGB or A combiner mode/function */ -static void -set_combiner_mode(struct gl_context *ctx, - struct gl_texture_unit *texUnit, - GLenum pname, GLenum mode) -{ - GLboolean legal; - - switch (mode) { - case GL_REPLACE: - case GL_MODULATE: - case GL_ADD: - case GL_ADD_SIGNED: - case GL_INTERPOLATE: - legal = GL_TRUE; - break; - case GL_SUBTRACT: - legal = ctx->Extensions.ARB_texture_env_combine; - break; - case GL_DOT3_RGB_EXT: - case GL_DOT3_RGBA_EXT: - legal = (ctx->Extensions.EXT_texture_env_dot3 && - pname == GL_COMBINE_RGB); - break; - case GL_DOT3_RGB: - case GL_DOT3_RGBA: - legal = (ctx->Extensions.ARB_texture_env_dot3 && - pname == GL_COMBINE_RGB); - break; - case GL_MODULATE_ADD_ATI: - case GL_MODULATE_SIGNED_ADD_ATI: - case GL_MODULATE_SUBTRACT_ATI: - legal = ctx->Extensions.ATI_texture_env_combine3; - break; - default: - legal = GL_FALSE; - } - - if (!legal) { - TE_ERROR(GL_INVALID_ENUM, "glTexEnv(param=%s)", mode); - return; - } - - switch (pname) { - case GL_COMBINE_RGB: - if (texUnit->Combine.ModeRGB == mode) - return; - FLUSH_VERTICES(ctx, _NEW_TEXTURE); - texUnit->Combine.ModeRGB = mode; - break; - - case GL_COMBINE_ALPHA: - if (texUnit->Combine.ModeA == mode) - return; - FLUSH_VERTICES(ctx, _NEW_TEXTURE); - texUnit->Combine.ModeA = mode; - break; - default: - TE_ERROR(GL_INVALID_ENUM, "glTexEnv(pname=%s)", pname); - } -} - - - -/** Set an RGB or A combiner source term */ -static void -set_combiner_source(struct gl_context *ctx, - struct gl_texture_unit *texUnit, - GLenum pname, GLenum param) -{ - GLuint term; - GLboolean alpha, legal; - - /* - * Translate pname to (term, alpha). - * - * The enums were given sequential values for a reason. - */ - switch (pname) { - case GL_SOURCE0_RGB: - case GL_SOURCE1_RGB: - case GL_SOURCE2_RGB: - case GL_SOURCE3_RGB_NV: - term = pname - GL_SOURCE0_RGB; - alpha = GL_FALSE; - break; - case GL_SOURCE0_ALPHA: - case GL_SOURCE1_ALPHA: - case GL_SOURCE2_ALPHA: - case GL_SOURCE3_ALPHA_NV: - term = pname - GL_SOURCE0_ALPHA; - alpha = GL_TRUE; - break; - default: - TE_ERROR(GL_INVALID_ENUM, "glTexEnv(pname=%s)", pname); - return; - } - - if ((term == 3) && !ctx->Extensions.NV_texture_env_combine4) { - TE_ERROR(GL_INVALID_ENUM, "glTexEnv(pname=%s)", pname); - return; - } - - assert(term < MAX_COMBINER_TERMS); - - /* - * Error-check param (the source term) - */ - switch (param) { - case GL_TEXTURE: - case GL_CONSTANT: - case GL_PRIMARY_COLOR: - case GL_PREVIOUS: - legal = GL_TRUE; - break; - case GL_ZERO: - legal = (ctx->Extensions.ATI_texture_env_combine3 || - ctx->Extensions.NV_texture_env_combine4); - break; - case GL_ONE: - legal = ctx->Extensions.ATI_texture_env_combine3; - break; - default: - legal = GL_FALSE; - } - - if (!legal) { - TE_ERROR(GL_INVALID_ENUM, "glTexEnv(param=%s)", param); - return; - } - - FLUSH_VERTICES(ctx, _NEW_TEXTURE); - - if (alpha) - texUnit->Combine.SourceA[term] = param; - else - texUnit->Combine.SourceRGB[term] = param; -} - - -/** Set an RGB or A combiner operand term */ -static void -set_combiner_operand(struct gl_context *ctx, - struct gl_texture_unit *texUnit, - GLenum pname, GLenum param) -{ - GLuint term; - GLboolean alpha, legal; - - /* The enums were given sequential values for a reason. - */ - switch (pname) { - case GL_OPERAND0_RGB: - case GL_OPERAND1_RGB: - case GL_OPERAND2_RGB: - case GL_OPERAND3_RGB_NV: - term = pname - GL_OPERAND0_RGB; - alpha = GL_FALSE; - break; - case GL_OPERAND0_ALPHA: - case GL_OPERAND1_ALPHA: - case GL_OPERAND2_ALPHA: - case GL_OPERAND3_ALPHA_NV: - term = pname - GL_OPERAND0_ALPHA; - alpha = GL_TRUE; - break; - default: - TE_ERROR(GL_INVALID_ENUM, "glTexEnv(pname=%s)", pname); - return; - } - - if ((term == 3) && !ctx->Extensions.NV_texture_env_combine4) { - TE_ERROR(GL_INVALID_ENUM, "glTexEnv(pname=%s)", pname); - return; - } - - assert(term < MAX_COMBINER_TERMS); - - /* - * Error-check param (the source operand) - */ - switch (param) { - case GL_SRC_COLOR: - case GL_ONE_MINUS_SRC_COLOR: - /* The color input can only be used with GL_OPERAND[01]_RGB in the EXT - * version. In the ARB and NV versions they can be used for any RGB - * operand. - */ - legal = !alpha - && ((term < 2) || ctx->Extensions.ARB_texture_env_combine - || ctx->Extensions.NV_texture_env_combine4); - break; - case GL_ONE_MINUS_SRC_ALPHA: - /* GL_ONE_MINUS_SRC_ALPHA can only be used with - * GL_OPERAND[01]_(RGB|ALPHA) in the EXT version. In the ARB and NV - * versions it can be used for any operand. - */ - legal = (term < 2) || ctx->Extensions.ARB_texture_env_combine - || ctx->Extensions.NV_texture_env_combine4; - break; - case GL_SRC_ALPHA: - legal = GL_TRUE; - break; - default: - legal = GL_FALSE; - } - - if (!legal) { - TE_ERROR(GL_INVALID_ENUM, "glTexEnv(param=%s)", param); - return; - } - - FLUSH_VERTICES(ctx, _NEW_TEXTURE); - - if (alpha) - texUnit->Combine.OperandA[term] = param; - else - texUnit->Combine.OperandRGB[term] = param; -} - - -static void -set_combiner_scale(struct gl_context *ctx, - struct gl_texture_unit *texUnit, - GLenum pname, GLfloat scale) -{ - GLuint shift; - - if (scale == 1.0F) { - shift = 0; - } - else if (scale == 2.0F) { - shift = 1; - } - else if (scale == 4.0F) { - shift = 2; - } - else { - _mesa_error( ctx, GL_INVALID_VALUE, - "glTexEnv(GL_RGB_SCALE not 1, 2 or 4)" ); - return; - } - - switch (pname) { - case GL_RGB_SCALE: - if (texUnit->Combine.ScaleShiftRGB == shift) - return; - FLUSH_VERTICES(ctx, _NEW_TEXTURE); - texUnit->Combine.ScaleShiftRGB = shift; - break; - case GL_ALPHA_SCALE: - if (texUnit->Combine.ScaleShiftA == shift) - return; - FLUSH_VERTICES(ctx, _NEW_TEXTURE); - texUnit->Combine.ScaleShiftA = shift; - break; - default: - TE_ERROR(GL_INVALID_ENUM, "glTexEnv(pname=%s)", pname); - } -} - - - -void GLAPIENTRY -_mesa_TexEnvfv( GLenum target, GLenum pname, const GLfloat *param ) -{ - const GLint iparam0 = (GLint) param[0]; - struct gl_texture_unit *texUnit; - GET_CURRENT_CONTEXT(ctx); - ASSERT_OUTSIDE_BEGIN_END(ctx); - - texUnit = &ctx->Texture.Unit; - - if (target == GL_TEXTURE_ENV) { - switch (pname) { - case GL_TEXTURE_ENV_MODE: - set_env_mode(ctx, texUnit, (GLenum) iparam0); - break; - case GL_TEXTURE_ENV_COLOR: - set_env_color(ctx, texUnit, param); - break; - case GL_COMBINE_RGB: - case GL_COMBINE_ALPHA: - set_combiner_mode(ctx, texUnit, pname, (GLenum) iparam0); - break; - case GL_SOURCE0_RGB: - case GL_SOURCE1_RGB: - case GL_SOURCE2_RGB: - case GL_SOURCE3_RGB_NV: - case GL_SOURCE0_ALPHA: - case GL_SOURCE1_ALPHA: - case GL_SOURCE2_ALPHA: - case GL_SOURCE3_ALPHA_NV: - set_combiner_source(ctx, texUnit, pname, (GLenum) iparam0); - break; - case GL_OPERAND0_RGB: - case GL_OPERAND1_RGB: - case GL_OPERAND2_RGB: - case GL_OPERAND3_RGB_NV: - case GL_OPERAND0_ALPHA: - case GL_OPERAND1_ALPHA: - case GL_OPERAND2_ALPHA: - case GL_OPERAND3_ALPHA_NV: - set_combiner_operand(ctx, texUnit, pname, (GLenum) iparam0); - break; - case GL_RGB_SCALE: - case GL_ALPHA_SCALE: - set_combiner_scale(ctx, texUnit, pname, param[0]); - break; - default: - _mesa_error( ctx, GL_INVALID_ENUM, "glTexEnv(pname)" ); - return; - } - } - else if (target == GL_TEXTURE_FILTER_CONTROL_EXT) { - if (pname == GL_TEXTURE_LOD_BIAS_EXT) { - if (texUnit->LodBias == param[0]) - return; - FLUSH_VERTICES(ctx, _NEW_TEXTURE); - texUnit->LodBias = param[0]; - } - else { - TE_ERROR(GL_INVALID_ENUM, "glTexEnv(pname=%s)", pname); - return; - } - } - else { - _mesa_error( ctx, GL_INVALID_ENUM, "glTexEnv(target=0x%x)",target ); - return; - } - - if (MESA_VERBOSE&(VERBOSE_API|VERBOSE_TEXTURE)) - _mesa_debug(ctx, "glTexEnv %s %s %.1f(%s) ...\n", - _mesa_lookup_enum_by_nr(target), - _mesa_lookup_enum_by_nr(pname), - *param, - _mesa_lookup_enum_by_nr((GLenum) iparam0)); - - /* Tell device driver about the new texture environment */ - if (ctx->Driver.TexEnv) { - (*ctx->Driver.TexEnv)( ctx, target, pname, param ); - } -} - - -void GLAPIENTRY -_mesa_TexEnvf( GLenum target, GLenum pname, GLfloat param ) -{ - GLfloat p[4]; - p[0] = param; - p[1] = p[2] = p[3] = 0.0; - _mesa_TexEnvfv( target, pname, p ); -} - - - -void GLAPIENTRY -_mesa_TexEnvi( GLenum target, GLenum pname, GLint param ) -{ - GLfloat p[4]; - p[0] = (GLfloat) param; - p[1] = p[2] = p[3] = 0.0; - _mesa_TexEnvfv( target, pname, p ); -} - - -void GLAPIENTRY -_mesa_TexEnviv( GLenum target, GLenum pname, const GLint *param ) -{ - GLfloat p[4]; - if (pname == GL_TEXTURE_ENV_COLOR) { - p[0] = INT_TO_FLOAT( param[0] ); - p[1] = INT_TO_FLOAT( param[1] ); - p[2] = INT_TO_FLOAT( param[2] ); - p[3] = INT_TO_FLOAT( param[3] ); - } - else { - p[0] = (GLfloat) param[0]; - p[1] = p[2] = p[3] = 0; /* init to zero, just to be safe */ - } - _mesa_TexEnvfv( target, pname, p ); -} - - - -/** - * Helper for glGetTexEnvi/f() - * \return value of queried pname or -1 if error. - */ -static GLint -get_texenvi(struct gl_context *ctx, const struct gl_texture_unit *texUnit, - GLenum pname) -{ - switch (pname) { - case GL_TEXTURE_ENV_MODE: - return texUnit->EnvMode; - break; - case GL_COMBINE_RGB: - return texUnit->Combine.ModeRGB; - case GL_COMBINE_ALPHA: - return texUnit->Combine.ModeA; - case GL_SOURCE0_RGB: - case GL_SOURCE1_RGB: - case GL_SOURCE2_RGB: { - const unsigned rgb_idx = pname - GL_SOURCE0_RGB; - return texUnit->Combine.SourceRGB[rgb_idx]; - } - case GL_SOURCE3_RGB_NV: - if (ctx->Extensions.NV_texture_env_combine4) { - return texUnit->Combine.SourceRGB[3]; - } - else { - _mesa_error(ctx, GL_INVALID_ENUM, "glGetTexEnvfv(pname)"); - } - break; - case GL_SOURCE0_ALPHA: - case GL_SOURCE1_ALPHA: - case GL_SOURCE2_ALPHA: { - const unsigned alpha_idx = pname - GL_SOURCE0_ALPHA; - return texUnit->Combine.SourceA[alpha_idx]; - } - case GL_SOURCE3_ALPHA_NV: - if (ctx->Extensions.NV_texture_env_combine4) { - return texUnit->Combine.SourceA[3]; - } - else { - _mesa_error(ctx, GL_INVALID_ENUM, "glGetTexEnvfv(pname)"); - } - break; - case GL_OPERAND0_RGB: - case GL_OPERAND1_RGB: - case GL_OPERAND2_RGB: { - const unsigned op_rgb = pname - GL_OPERAND0_RGB; - return texUnit->Combine.OperandRGB[op_rgb]; - } - case GL_OPERAND3_RGB_NV: - if (ctx->Extensions.NV_texture_env_combine4) { - return texUnit->Combine.OperandRGB[3]; - } - else { - _mesa_error(ctx, GL_INVALID_ENUM, "glGetTexEnvfv(pname)"); - } - break; - case GL_OPERAND0_ALPHA: - case GL_OPERAND1_ALPHA: - case GL_OPERAND2_ALPHA: { - const unsigned op_alpha = pname - GL_OPERAND0_ALPHA; - return texUnit->Combine.OperandA[op_alpha]; - } - case GL_OPERAND3_ALPHA_NV: - if (ctx->Extensions.NV_texture_env_combine4) { - return texUnit->Combine.OperandA[3]; - } - else { - _mesa_error(ctx, GL_INVALID_ENUM, "glGetTexEnvfv(pname)"); - } - break; - case GL_RGB_SCALE: - return 1 << texUnit->Combine.ScaleShiftRGB; - case GL_ALPHA_SCALE: - return 1 << texUnit->Combine.ScaleShiftA; - - default: - _mesa_error(ctx, GL_INVALID_ENUM, "glGetTexEnvfv(pname)"); - break; - } - - return -1; /* error */ -} - - - -void GLAPIENTRY -_mesa_GetTexEnvfv( GLenum target, GLenum pname, GLfloat *params ) -{ - GET_CURRENT_CONTEXT(ctx); - const struct gl_texture_unit *texUnit = &ctx->Texture.Unit; - ASSERT_OUTSIDE_BEGIN_END(ctx); - - if (target == GL_TEXTURE_ENV) { - if (pname == GL_TEXTURE_ENV_COLOR) { - if(ctx->NewState & _NEW_BUFFERS) - _mesa_update_state(ctx); - COPY_4FV( params, texUnit->EnvColor ); - } - else { - GLint val = get_texenvi(ctx, texUnit, pname); - if (val >= 0) { - *params = (GLfloat) val; - } - } - } - else if (target == GL_TEXTURE_FILTER_CONTROL_EXT) { - if (pname == GL_TEXTURE_LOD_BIAS_EXT) { - *params = texUnit->LodBias; - } - else { - _mesa_error( ctx, GL_INVALID_ENUM, "glGetTexEnvfv(pname)" ); - return; - } - } - else { - _mesa_error( ctx, GL_INVALID_ENUM, "glGetTexEnvfv(target)" ); - return; - } -} - - -void GLAPIENTRY -_mesa_GetTexEnviv( GLenum target, GLenum pname, GLint *params ) -{ - GET_CURRENT_CONTEXT(ctx); - const struct gl_texture_unit *texUnit = &ctx->Texture.Unit;; - ASSERT_OUTSIDE_BEGIN_END(ctx); - - if (target == GL_TEXTURE_ENV) { - if (pname == GL_TEXTURE_ENV_COLOR) { - params[0] = FLOAT_TO_INT( texUnit->EnvColor[0] ); - params[1] = FLOAT_TO_INT( texUnit->EnvColor[1] ); - params[2] = FLOAT_TO_INT( texUnit->EnvColor[2] ); - params[3] = FLOAT_TO_INT( texUnit->EnvColor[3] ); - } - else { - GLint val = get_texenvi(ctx, texUnit, pname); - if (val >= 0) { - *params = val; - } - } - } - else if (target == GL_TEXTURE_FILTER_CONTROL_EXT) { - if (pname == GL_TEXTURE_LOD_BIAS_EXT) { - *params = (GLint) texUnit->LodBias; - } - else { - _mesa_error( ctx, GL_INVALID_ENUM, "glGetTexEnviv(pname)" ); - return; - } - } - else { - _mesa_error( ctx, GL_INVALID_ENUM, "glGetTexEnviv(target)" ); - return; - } -} - - diff --git a/dll/opengl/mesa/main/texenv.h b/dll/opengl/mesa/main/texenv.h deleted file mode 100644 index d967f5d4219..00000000000 --- a/dll/opengl/mesa/main/texenv.h +++ /dev/null @@ -1,51 +0,0 @@ -/* - * Mesa 3-D graphics library - * Version: 7.1 - * - * Copyright (C) 1999-2008 Brian Paul All Rights Reserved. - * - * Permission is hereby granted, free of charge, to any person obtaining a - * copy of this software and associated documentation files (the "Software"), - * to deal in the Software without restriction, including without limitation - * the rights to use, copy, modify, merge, publish, distribute, sublicense, - * and/or sell copies of the Software, and to permit persons to whom the - * Software is furnished to do so, subject to the following conditions: - * - * The above copyright notice and this permission notice shall be included - * in all copies or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS - * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL - * BRIAN PAUL BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN - * AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN - * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. - */ - - -#ifndef TEXENV_H -#define TEXENV_H - - -#include "main/glheader.h" - - -extern void GLAPIENTRY -_mesa_GetTexEnvfv( GLenum target, GLenum pname, GLfloat *params ); - -extern void GLAPIENTRY -_mesa_GetTexEnviv( GLenum target, GLenum pname, GLint *params ); - -extern void GLAPIENTRY -_mesa_TexEnvf( GLenum target, GLenum pname, GLfloat param ); - -extern void GLAPIENTRY -_mesa_TexEnvfv( GLenum target, GLenum pname, const GLfloat *param ); - -extern void GLAPIENTRY -_mesa_TexEnvi( GLenum target, GLenum pname, GLint param ); - -extern void GLAPIENTRY -_mesa_TexEnviv( GLenum target, GLenum pname, const GLint *param ); - -#endif /* TEXENV_H */ diff --git a/dll/opengl/mesa/main/texformat.c b/dll/opengl/mesa/main/texformat.c deleted file mode 100644 index 2d6efe2be25..00000000000 --- a/dll/opengl/mesa/main/texformat.c +++ /dev/null @@ -1,361 +0,0 @@ -/* - * Mesa 3-D graphics library - * Version: 7.7 - * - * Copyright (C) 1999-2008 Brian Paul All Rights Reserved. - * Copyright (c) 2008-2009 VMware, Inc. - * - * Permission is hereby granted, free of charge, to any person obtaining a - * copy of this software and associated documentation files (the "Software"), - * to deal in the Software without restriction, including without limitation - * the rights to use, copy, modify, merge, publish, distribute, sublicense, - * and/or sell copies of the Software, and to permit persons to whom the - * Software is furnished to do so, subject to the following conditions: - * - * The above copyright notice and this permission notice shall be included - * in all copies or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS - * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL - * BRIAN PAUL BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN - * AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN - * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. - */ - - -/** - * \file texformat.c - * Texture formats. - * - * \author Gareth Hughes - * \author Brian Paul - */ - -#include - -#define RETURN_IF_SUPPORTED(f) do { \ - if (ctx->TextureFormatSupported[f]) \ - return f; \ -} while (0) - -/** - * Choose an appropriate texture format given the format, type and - * internalFormat parameters passed to glTexImage(). - * - * \param ctx the GL context. - * \param internalFormat user's prefered internal texture format. - * \param format incoming image pixel format. - * \param type incoming image data type. - * - * \return a pointer to a gl_texture_format object which describes the - * choosen texture format, or NULL on failure. - * - * This is called via dd_function_table::ChooseTextureFormat. Hardware drivers - * will typically override this function with a specialized version. - */ -gl_format -_mesa_choose_tex_format( struct gl_context *ctx, GLint internalFormat, - GLenum format, GLenum type ) -{ - (void) format; - (void) type; - - switch (internalFormat) { - /* shallow RGBA formats */ - case 4: - case GL_RGBA: - if (type == GL_UNSIGNED_SHORT_4_4_4_4_REV) { - RETURN_IF_SUPPORTED(MESA_FORMAT_ARGB4444); - } else if (type == GL_UNSIGNED_SHORT_1_5_5_5_REV) { - RETURN_IF_SUPPORTED(MESA_FORMAT_ARGB1555); - } - RETURN_IF_SUPPORTED(MESA_FORMAT_RGBA8888); - RETURN_IF_SUPPORTED(MESA_FORMAT_ARGB8888); - break; - - case GL_RGBA8: - RETURN_IF_SUPPORTED(MESA_FORMAT_RGBA8888); - RETURN_IF_SUPPORTED(MESA_FORMAT_ARGB8888); - break; - case GL_RGB5_A1: - RETURN_IF_SUPPORTED(MESA_FORMAT_ARGB1555); - break; - case GL_RGBA2: - RETURN_IF_SUPPORTED(MESA_FORMAT_ARGB4444_REV); /* just to test another format*/ - RETURN_IF_SUPPORTED(MESA_FORMAT_ARGB4444); - break; - case GL_RGBA4: - RETURN_IF_SUPPORTED(MESA_FORMAT_ARGB4444); - break; - - /* deep RGBA formats */ - case GL_RGB10_A2: - RETURN_IF_SUPPORTED(MESA_FORMAT_ARGB8888); - break; - case GL_RGBA12: - case GL_RGBA16: - RETURN_IF_SUPPORTED(MESA_FORMAT_RGBA_16); - RETURN_IF_SUPPORTED(MESA_FORMAT_RGBA8888); - RETURN_IF_SUPPORTED(MESA_FORMAT_ARGB8888); - break; - - /* shallow RGB formats */ - case 3: - case GL_RGB: - case GL_RGB8: - RETURN_IF_SUPPORTED(MESA_FORMAT_RGB888); - RETURN_IF_SUPPORTED(MESA_FORMAT_XRGB8888); - RETURN_IF_SUPPORTED(MESA_FORMAT_ARGB8888); - break; - case GL_R3_G3_B2: - RETURN_IF_SUPPORTED(MESA_FORMAT_RGB332); - RETURN_IF_SUPPORTED(MESA_FORMAT_RGB565); - RETURN_IF_SUPPORTED(MESA_FORMAT_RGB565_REV); - RETURN_IF_SUPPORTED(MESA_FORMAT_RGB888); - RETURN_IF_SUPPORTED(MESA_FORMAT_XRGB8888); - RETURN_IF_SUPPORTED(MESA_FORMAT_ARGB8888); - break; - case GL_RGB4: - RETURN_IF_SUPPORTED(MESA_FORMAT_RGB565_REV); /* just to test another format */ - RETURN_IF_SUPPORTED(MESA_FORMAT_RGB565); - break; - case GL_RGB5: - RETURN_IF_SUPPORTED(MESA_FORMAT_RGB565); - break; - - /* deep RGB formats */ - case GL_RGB10: - case GL_RGB12: - case GL_RGB16: - RETURN_IF_SUPPORTED(MESA_FORMAT_RGBA_16); - RETURN_IF_SUPPORTED(MESA_FORMAT_XRGB8888); - RETURN_IF_SUPPORTED(MESA_FORMAT_ARGB8888); - break; - - /* Alpha formats */ - case GL_ALPHA: - case GL_ALPHA4: - case GL_ALPHA8: - RETURN_IF_SUPPORTED(MESA_FORMAT_A8); - break; - - case GL_ALPHA12: - case GL_ALPHA16: - RETURN_IF_SUPPORTED(MESA_FORMAT_A16); - RETURN_IF_SUPPORTED(MESA_FORMAT_A8); - break; - - /* Luminance formats */ - case 1: - case GL_LUMINANCE: - case GL_LUMINANCE4: - case GL_LUMINANCE8: - RETURN_IF_SUPPORTED(MESA_FORMAT_L8); - break; - - case GL_LUMINANCE12: - case GL_LUMINANCE16: - RETURN_IF_SUPPORTED(MESA_FORMAT_L16); - RETURN_IF_SUPPORTED(MESA_FORMAT_L8); - break; - - /* Luminance/Alpha formats */ - case GL_LUMINANCE4_ALPHA4: - RETURN_IF_SUPPORTED(MESA_FORMAT_AL44); - RETURN_IF_SUPPORTED(MESA_FORMAT_AL88); - break; - - case 2: - case GL_LUMINANCE_ALPHA: - case GL_LUMINANCE6_ALPHA2: - case GL_LUMINANCE8_ALPHA8: - RETURN_IF_SUPPORTED(MESA_FORMAT_AL88); - break; - - case GL_LUMINANCE12_ALPHA4: - case GL_LUMINANCE12_ALPHA12: - case GL_LUMINANCE16_ALPHA16: - RETURN_IF_SUPPORTED(MESA_FORMAT_AL1616); - RETURN_IF_SUPPORTED(MESA_FORMAT_AL88); - break; - - case GL_INTENSITY: - case GL_INTENSITY4: - case GL_INTENSITY8: - RETURN_IF_SUPPORTED(MESA_FORMAT_I8); - break; - - case GL_INTENSITY12: - case GL_INTENSITY16: - RETURN_IF_SUPPORTED(MESA_FORMAT_I16); - RETURN_IF_SUPPORTED(MESA_FORMAT_I8); - break; - - default: - ; /* fallthrough */ - } - - if (ctx->Extensions.MESA_ycbcr_texture) { - if (internalFormat == GL_YCBCR_MESA) { - if (type == GL_UNSIGNED_SHORT_8_8_MESA) - RETURN_IF_SUPPORTED(MESA_FORMAT_YCBCR); - else - RETURN_IF_SUPPORTED(MESA_FORMAT_YCBCR_REV); - } - } - - if (ctx->Extensions.EXT_texture_integer) { - switch (internalFormat) { - case GL_ALPHA8UI_EXT: - RETURN_IF_SUPPORTED(MESA_FORMAT_ALPHA_UINT8); - RETURN_IF_SUPPORTED(MESA_FORMAT_RGBA_UINT8); - break; - case GL_ALPHA16UI_EXT: - RETURN_IF_SUPPORTED(MESA_FORMAT_ALPHA_UINT16); - RETURN_IF_SUPPORTED(MESA_FORMAT_RGBA_UINT16); - break; - case GL_ALPHA32UI_EXT: - RETURN_IF_SUPPORTED(MESA_FORMAT_ALPHA_UINT32); - RETURN_IF_SUPPORTED(MESA_FORMAT_RGBA_UINT32); - break; - case GL_ALPHA8I_EXT: - RETURN_IF_SUPPORTED(MESA_FORMAT_ALPHA_INT8); - RETURN_IF_SUPPORTED(MESA_FORMAT_RGBA_INT8); - break; - case GL_ALPHA16I_EXT: - RETURN_IF_SUPPORTED(MESA_FORMAT_ALPHA_INT16); - RETURN_IF_SUPPORTED(MESA_FORMAT_RGBA_INT16); - break; - case GL_ALPHA32I_EXT: - RETURN_IF_SUPPORTED(MESA_FORMAT_ALPHA_INT32); - RETURN_IF_SUPPORTED(MESA_FORMAT_RGBA_INT32); - break; - case GL_LUMINANCE8UI_EXT: - RETURN_IF_SUPPORTED(MESA_FORMAT_LUMINANCE_UINT8); - RETURN_IF_SUPPORTED(MESA_FORMAT_RGBA_UINT8); - break; - case GL_LUMINANCE16UI_EXT: - RETURN_IF_SUPPORTED(MESA_FORMAT_LUMINANCE_UINT16); - RETURN_IF_SUPPORTED(MESA_FORMAT_RGBA_UINT16); - break; - case GL_LUMINANCE32UI_EXT: - RETURN_IF_SUPPORTED(MESA_FORMAT_LUMINANCE_UINT32); - RETURN_IF_SUPPORTED(MESA_FORMAT_RGBA_UINT32); - break; - case GL_LUMINANCE8I_EXT: - RETURN_IF_SUPPORTED(MESA_FORMAT_LUMINANCE_INT8); - RETURN_IF_SUPPORTED(MESA_FORMAT_RGBA_INT8); - break; - case GL_LUMINANCE16I_EXT: - RETURN_IF_SUPPORTED(MESA_FORMAT_LUMINANCE_INT16); - RETURN_IF_SUPPORTED(MESA_FORMAT_RGBA_INT16); - break; - case GL_LUMINANCE32I_EXT: - RETURN_IF_SUPPORTED(MESA_FORMAT_LUMINANCE_INT32); - RETURN_IF_SUPPORTED(MESA_FORMAT_RGBA_INT32); - break; - case GL_LUMINANCE_ALPHA8UI_EXT: - RETURN_IF_SUPPORTED(MESA_FORMAT_LUMINANCE_ALPHA_UINT8); - RETURN_IF_SUPPORTED(MESA_FORMAT_RGBA_UINT8); - break; - case GL_LUMINANCE_ALPHA16UI_EXT: - RETURN_IF_SUPPORTED(MESA_FORMAT_LUMINANCE_ALPHA_UINT16); - RETURN_IF_SUPPORTED(MESA_FORMAT_RGBA_UINT16); - break; - case GL_LUMINANCE_ALPHA32UI_EXT: - RETURN_IF_SUPPORTED(MESA_FORMAT_LUMINANCE_ALPHA_UINT32); - RETURN_IF_SUPPORTED(MESA_FORMAT_RGBA_UINT32); - break; - case GL_LUMINANCE_ALPHA8I_EXT: - RETURN_IF_SUPPORTED(MESA_FORMAT_LUMINANCE_ALPHA_INT8); - RETURN_IF_SUPPORTED(MESA_FORMAT_RGBA_INT8); - break; - case GL_LUMINANCE_ALPHA16I_EXT: - RETURN_IF_SUPPORTED(MESA_FORMAT_LUMINANCE_ALPHA_INT16); - RETURN_IF_SUPPORTED(MESA_FORMAT_RGBA_INT16); - break; - case GL_LUMINANCE_ALPHA32I_EXT: - RETURN_IF_SUPPORTED(MESA_FORMAT_LUMINANCE_ALPHA_INT32); - RETURN_IF_SUPPORTED(MESA_FORMAT_RGBA_INT32); - break; - case GL_INTENSITY8UI_EXT: - RETURN_IF_SUPPORTED(MESA_FORMAT_INTENSITY_UINT8); - RETURN_IF_SUPPORTED(MESA_FORMAT_RGBA_UINT8); - break; - case GL_INTENSITY16UI_EXT: - RETURN_IF_SUPPORTED(MESA_FORMAT_INTENSITY_UINT16); - RETURN_IF_SUPPORTED(MESA_FORMAT_RGBA_UINT16); - break; - case GL_INTENSITY32UI_EXT: - RETURN_IF_SUPPORTED(MESA_FORMAT_INTENSITY_UINT32); - RETURN_IF_SUPPORTED(MESA_FORMAT_RGBA_UINT32); - break; - case GL_INTENSITY8I_EXT: - RETURN_IF_SUPPORTED(MESA_FORMAT_INTENSITY_INT8); - RETURN_IF_SUPPORTED(MESA_FORMAT_RGBA_INT8); - break; - case GL_INTENSITY16I_EXT: - RETURN_IF_SUPPORTED(MESA_FORMAT_INTENSITY_INT16); - RETURN_IF_SUPPORTED(MESA_FORMAT_RGBA_INT16); - break; - case GL_INTENSITY32I_EXT: - RETURN_IF_SUPPORTED(MESA_FORMAT_INTENSITY_INT32); - RETURN_IF_SUPPORTED(MESA_FORMAT_RGBA_INT32); - break; - } - } - - if (ctx->VersionMajor >= 3 || - ctx->Extensions.EXT_texture_integer) { - switch (internalFormat) { - case GL_RGB8UI_EXT: - RETURN_IF_SUPPORTED(MESA_FORMAT_RGB_UINT8); - RETURN_IF_SUPPORTED(MESA_FORMAT_RGBA_UINT8); - break; - case GL_RGB16UI_EXT: - RETURN_IF_SUPPORTED(MESA_FORMAT_RGB_UINT16); - RETURN_IF_SUPPORTED(MESA_FORMAT_RGBA_UINT16); - break; - case GL_RGB32UI_EXT: - RETURN_IF_SUPPORTED(MESA_FORMAT_RGB_UINT32); - RETURN_IF_SUPPORTED(MESA_FORMAT_RGBA_UINT32); - break; - case GL_RGB8I_EXT: - RETURN_IF_SUPPORTED(MESA_FORMAT_RGB_INT8); - RETURN_IF_SUPPORTED(MESA_FORMAT_RGBA_INT8); - break; - case GL_RGB16I_EXT: - RETURN_IF_SUPPORTED(MESA_FORMAT_RGB_INT16); - RETURN_IF_SUPPORTED(MESA_FORMAT_RGBA_INT16); - break; - case GL_RGB32I_EXT: - RETURN_IF_SUPPORTED(MESA_FORMAT_RGB_INT32); - RETURN_IF_SUPPORTED(MESA_FORMAT_RGBA_INT32); - break; - case GL_RGBA8UI_EXT: - RETURN_IF_SUPPORTED(MESA_FORMAT_RGBA_UINT8); - break; - case GL_RGBA16UI_EXT: - RETURN_IF_SUPPORTED(MESA_FORMAT_RGBA_UINT16); - break; - case GL_RGBA32UI_EXT: - RETURN_IF_SUPPORTED(MESA_FORMAT_RGBA_UINT32); - break; - case GL_RGBA8I_EXT: - RETURN_IF_SUPPORTED(MESA_FORMAT_RGBA_INT8); - break; - case GL_RGBA16I_EXT: - RETURN_IF_SUPPORTED(MESA_FORMAT_RGBA_INT16); - break; - case GL_RGBA32I_EXT: - RETURN_IF_SUPPORTED(MESA_FORMAT_RGBA_INT32); - break; - } - } - - _mesa_problem(ctx, "unexpected format %s in _mesa_choose_tex_format()", - _mesa_lookup_enum_by_nr(internalFormat)); - return MESA_FORMAT_NONE; -} - diff --git a/dll/opengl/mesa/main/texformat.h b/dll/opengl/mesa/main/texformat.h deleted file mode 100644 index 3cf09213ac4..00000000000 --- a/dll/opengl/mesa/main/texformat.h +++ /dev/null @@ -1,39 +0,0 @@ -/* - * Mesa 3-D graphics library - * Version: 7.75 - * - * Copyright (C) 1999-2008 Brian Paul All Rights Reserved. - * Copyright (c) 2008-2009 VMware, Inc. - * - * Permission is hereby granted, free of charge, to any person obtaining a - * copy of this software and associated documentation files (the "Software"), - * to deal in the Software without restriction, including without limitation - * the rights to use, copy, modify, merge, publish, distribute, sublicense, - * and/or sell copies of the Software, and to permit persons to whom the - * Software is furnished to do so, subject to the following conditions: - * - * The above copyright notice and this permission notice shall be included - * in all copies or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS - * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL - * BRIAN PAUL BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN - * AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN - * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. - */ - -#ifndef TEXFORMAT_H -#define TEXFORMAT_H - - -#include "formats.h" - -struct gl_context; - -extern gl_format -_mesa_choose_tex_format( struct gl_context *ctx, GLint internalFormat, - GLenum format, GLenum type ); - - -#endif diff --git a/dll/opengl/mesa/main/texgen.c b/dll/opengl/mesa/main/texgen.c deleted file mode 100644 index 4056a259d27..00000000000 --- a/dll/opengl/mesa/main/texgen.c +++ /dev/null @@ -1,371 +0,0 @@ -/* - * Mesa 3-D graphics library - * Version: 7.5 - * - * Copyright (C) 1999-2008 Brian Paul All Rights Reserved. - * Copyright (C) 2009 VMware, Inc. All Rights Reserved. - * - * Permission is hereby granted, free of charge, to any person obtaining a - * copy of this software and associated documentation files (the "Software"), - * to deal in the Software without restriction, including without limitation - * the rights to use, copy, modify, merge, publish, distribute, sublicense, - * and/or sell copies of the Software, and to permit persons to whom the - * Software is furnished to do so, subject to the following conditions: - * - * The above copyright notice and this permission notice shall be included - * in all copies or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS - * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL - * BRIAN PAUL BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN - * AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN - * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. - */ - -/** - * \file texgen.c - * - * glTexGen-related functions - */ - -#include - -#if FEATURE_texgen - - -/** - * Return texgen state for given coordinate - */ -static struct gl_texgen * -get_texgen(struct gl_texture_unit *texUnit, GLenum coord) -{ - switch (coord) { - case GL_S: - return &texUnit->GenS; - case GL_T: - return &texUnit->GenT; - case GL_R: - return &texUnit->GenR; - case GL_Q: - return &texUnit->GenQ; - default: - return NULL; - } -} - - -void GLAPIENTRY -_mesa_TexGenfv( GLenum coord, GLenum pname, const GLfloat *params ) -{ - struct gl_texture_unit *texUnit; - struct gl_texgen *texgen; - GET_CURRENT_CONTEXT(ctx); - ASSERT_OUTSIDE_BEGIN_END(ctx); - - if (MESA_VERBOSE&(VERBOSE_API|VERBOSE_TEXTURE)) - _mesa_debug(ctx, "glTexGen %s %s %.1f(%s)...\n", - _mesa_lookup_enum_by_nr(coord), - _mesa_lookup_enum_by_nr(pname), - *params, - _mesa_lookup_enum_by_nr((GLenum) (GLint) *params)); - - texUnit = &ctx->Texture.Unit; - - texgen = get_texgen(texUnit, coord); - if (!texgen) { - _mesa_error(ctx, GL_INVALID_ENUM, "glTexGen(coord)"); - return; - } - - switch (pname) { - case GL_TEXTURE_GEN_MODE: - { - GLenum mode = (GLenum) (GLint) params[0]; - GLbitfield bit = 0x0; - if (texgen->Mode == mode) - return; - switch (mode) { - case GL_OBJECT_LINEAR: - bit = TEXGEN_OBJ_LINEAR; - break; - case GL_EYE_LINEAR: - bit = TEXGEN_EYE_LINEAR; - break; - case GL_SPHERE_MAP: - if (coord == GL_S || coord == GL_T) - bit = TEXGEN_SPHERE_MAP; - break; - case GL_REFLECTION_MAP_NV: - if (coord != GL_Q) - bit = TEXGEN_REFLECTION_MAP_NV; - break; - case GL_NORMAL_MAP_NV: - if (coord != GL_Q) - bit = TEXGEN_NORMAL_MAP_NV; - break; - default: - ; /* nop */ - } - if (!bit) { - _mesa_error( ctx, GL_INVALID_ENUM, "glTexGenfv(param)" ); - return; - } - FLUSH_VERTICES(ctx, _NEW_TEXTURE); - texgen->Mode = mode; - texgen->_ModeBit = bit; - } - break; - - case GL_OBJECT_PLANE: - { - if (TEST_EQ_4V(texgen->ObjectPlane, params)) - return; - FLUSH_VERTICES(ctx, _NEW_TEXTURE); - COPY_4FV(texgen->ObjectPlane, params); - } - break; - - case GL_EYE_PLANE: - { - GLfloat tmp[4]; - /* Transform plane equation by the inverse modelview matrix */ - if (_math_matrix_is_dirty(ctx->ModelviewMatrixStack.Top)) { - _math_matrix_analyse(ctx->ModelviewMatrixStack.Top); - } - _mesa_transform_vector(tmp, params, - ctx->ModelviewMatrixStack.Top->inv); - if (TEST_EQ_4V(texgen->EyePlane, tmp)) - return; - FLUSH_VERTICES(ctx, _NEW_TEXTURE); - COPY_4FV(texgen->EyePlane, tmp); - } - break; - - default: - _mesa_error( ctx, GL_INVALID_ENUM, "glTexGenfv(pname)" ); - return; - } - - if (ctx->Driver.TexGen) - ctx->Driver.TexGen( ctx, coord, pname, params ); -} - - -static void GLAPIENTRY -_mesa_TexGeniv(GLenum coord, GLenum pname, const GLint *params ) -{ - GLfloat p[4]; - p[0] = (GLfloat) params[0]; - if (pname == GL_TEXTURE_GEN_MODE) { - p[1] = p[2] = p[3] = 0.0F; - } - else { - p[1] = (GLfloat) params[1]; - p[2] = (GLfloat) params[2]; - p[3] = (GLfloat) params[3]; - } - _mesa_TexGenfv(coord, pname, p); -} - - -static void GLAPIENTRY -_mesa_TexGend(GLenum coord, GLenum pname, GLdouble param ) -{ - GLfloat p[4]; - p[0] = (GLfloat) param; - p[1] = p[2] = p[3] = 0.0F; - _mesa_TexGenfv( coord, pname, p ); -} - -#if FEATURE_ES1 - -void GLAPIENTRY -_es_GetTexGenfv(GLenum coord, GLenum pname, GLfloat *params) -{ - ASSERT(coord == GL_TEXTURE_GEN_STR_OES); - _mesa_GetTexGenfv(GL_S, pname, params); -} - - -void GLAPIENTRY -_es_TexGenf(GLenum coord, GLenum pname, GLfloat param) -{ - ASSERT(coord == GL_TEXTURE_GEN_STR_OES); - /* set S, T, and R at the same time */ - _mesa_TexGenf(GL_S, pname, param); - _mesa_TexGenf(GL_T, pname, param); - _mesa_TexGenf(GL_R, pname, param); -} - - -void GLAPIENTRY -_es_TexGenfv(GLenum coord, GLenum pname, const GLfloat *params) -{ - ASSERT(coord == GL_TEXTURE_GEN_STR_OES); - /* set S, T, and R at the same time */ - _mesa_TexGenfv(GL_S, pname, params); - _mesa_TexGenfv(GL_T, pname, params); - _mesa_TexGenfv(GL_R, pname, params); -} - -#endif - -static void GLAPIENTRY -_mesa_TexGendv(GLenum coord, GLenum pname, const GLdouble *params ) -{ - GLfloat p[4]; - p[0] = (GLfloat) params[0]; - if (pname == GL_TEXTURE_GEN_MODE) { - p[1] = p[2] = p[3] = 0.0F; - } - else { - p[1] = (GLfloat) params[1]; - p[2] = (GLfloat) params[2]; - p[3] = (GLfloat) params[3]; - } - _mesa_TexGenfv( coord, pname, p ); -} - - -void GLAPIENTRY -_mesa_TexGenf( GLenum coord, GLenum pname, GLfloat param ) -{ - GLfloat p[4]; - p[0] = param; - p[1] = p[2] = p[3] = 0.0F; - _mesa_TexGenfv(coord, pname, p); -} - - -void GLAPIENTRY -_mesa_TexGeni( GLenum coord, GLenum pname, GLint param ) -{ - GLint p[4]; - p[0] = param; - p[1] = p[2] = p[3] = 0; - _mesa_TexGeniv( coord, pname, p ); -} - - - -static void GLAPIENTRY -_mesa_GetTexGendv( GLenum coord, GLenum pname, GLdouble *params ) -{ - struct gl_texture_unit *texUnit; - struct gl_texgen *texgen; - GET_CURRENT_CONTEXT(ctx); - ASSERT_OUTSIDE_BEGIN_END(ctx); - - texUnit = &ctx->Texture.Unit; - - texgen = get_texgen(texUnit, coord); - if (!texgen) { - _mesa_error(ctx, GL_INVALID_ENUM, "glGetTexGendv(coord)"); - return; - } - - switch (pname) { - case GL_TEXTURE_GEN_MODE: - params[0] = ENUM_TO_DOUBLE(texgen->Mode); - break; - case GL_OBJECT_PLANE: - COPY_4V(params, texgen->ObjectPlane); - break; - case GL_EYE_PLANE: - COPY_4V(params, texgen->EyePlane); - break; - default: - _mesa_error( ctx, GL_INVALID_ENUM, "glGetTexGendv(pname)" ); - } -} - - - -void GLAPIENTRY -_mesa_GetTexGenfv( GLenum coord, GLenum pname, GLfloat *params ) -{ - struct gl_texture_unit *texUnit; - struct gl_texgen *texgen; - GET_CURRENT_CONTEXT(ctx); - ASSERT_OUTSIDE_BEGIN_END(ctx); - - texUnit = &ctx->Texture.Unit; - - texgen = get_texgen(texUnit, coord); - if (!texgen) { - _mesa_error(ctx, GL_INVALID_ENUM, "glGetTexGenfv(coord)"); - return; - } - - switch (pname) { - case GL_TEXTURE_GEN_MODE: - params[0] = ENUM_TO_FLOAT(texgen->Mode); - break; - case GL_OBJECT_PLANE: - COPY_4V(params, texgen->ObjectPlane); - break; - case GL_EYE_PLANE: - COPY_4V(params, texgen->EyePlane); - break; - default: - _mesa_error( ctx, GL_INVALID_ENUM, "glGetTexGenfv(pname)" ); - } -} - - - -static void GLAPIENTRY -_mesa_GetTexGeniv( GLenum coord, GLenum pname, GLint *params ) -{ - struct gl_texture_unit *texUnit; - struct gl_texgen *texgen; - GET_CURRENT_CONTEXT(ctx); - ASSERT_OUTSIDE_BEGIN_END(ctx); - - texUnit = &ctx->Texture.Unit; - - texgen = get_texgen(texUnit, coord); - if (!texgen) { - _mesa_error(ctx, GL_INVALID_ENUM, "glGetTexGeniv(coord)"); - return; - } - - switch (pname) { - case GL_TEXTURE_GEN_MODE: - params[0] = texgen->Mode; - break; - case GL_OBJECT_PLANE: - params[0] = (GLint) texgen->ObjectPlane[0]; - params[1] = (GLint) texgen->ObjectPlane[1]; - params[2] = (GLint) texgen->ObjectPlane[2]; - params[3] = (GLint) texgen->ObjectPlane[3]; - break; - case GL_EYE_PLANE: - params[0] = (GLint) texgen->EyePlane[0]; - params[1] = (GLint) texgen->EyePlane[1]; - params[2] = (GLint) texgen->EyePlane[2]; - params[3] = (GLint) texgen->EyePlane[3]; - break; - default: - _mesa_error( ctx, GL_INVALID_ENUM, "glGetTexGeniv(pname)" ); - } -} - - -void -_mesa_init_texgen_dispatch(struct _glapi_table *disp) -{ - SET_GetTexGendv(disp, _mesa_GetTexGendv); - SET_GetTexGenfv(disp, _mesa_GetTexGenfv); - SET_GetTexGeniv(disp, _mesa_GetTexGeniv); - SET_TexGend(disp, _mesa_TexGend); - SET_TexGendv(disp, _mesa_TexGendv); - SET_TexGenf(disp, _mesa_TexGenf); - SET_TexGenfv(disp, _mesa_TexGenfv); - SET_TexGeni(disp, _mesa_TexGeni); - SET_TexGeniv(disp, _mesa_TexGeniv); -} - - -#endif /* FEATURE_texgen */ diff --git a/dll/opengl/mesa/main/texgen.h b/dll/opengl/mesa/main/texgen.h deleted file mode 100644 index 60a9522af88..00000000000 --- a/dll/opengl/mesa/main/texgen.h +++ /dev/null @@ -1,85 +0,0 @@ -/* - * Mesa 3-D graphics library - * Version: 7.1 - * - * Copyright (C) 1999-2008 Brian Paul All Rights Reserved. - * - * Permission is hereby granted, free of charge, to any person obtaining a - * copy of this software and associated documentation files (the "Software"), - * to deal in the Software without restriction, including without limitation - * the rights to use, copy, modify, merge, publish, distribute, sublicense, - * and/or sell copies of the Software, and to permit persons to whom the - * Software is furnished to do so, subject to the following conditions: - * - * The above copyright notice and this permission notice shall be included - * in all copies or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS - * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL - * BRIAN PAUL BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN - * AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN - * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. - */ - - -#ifndef TEXGEN_H -#define TEXGEN_H - - -#include "compiler.h" -#include "glheader.h" -#include "mfeatures.h" - -struct _glapi_table; - - -#if FEATURE_texgen - -extern void GLAPIENTRY -_mesa_TexGenfv( GLenum coord, GLenum pname, const GLfloat *params ); - -extern void GLAPIENTRY -_mesa_TexGenf( GLenum coord, GLenum pname, GLfloat param ); - -extern void GLAPIENTRY -_mesa_TexGeni( GLenum coord, GLenum pname, GLint param ); - -extern void GLAPIENTRY -_mesa_GetTexGenfv( GLenum coord, GLenum pname, GLfloat *params ); - -extern void -_mesa_init_texgen_dispatch(struct _glapi_table *disp); - - -extern void GLAPIENTRY -_es_GetTexGenfv(GLenum coord, GLenum pname, GLfloat *params); - -extern void GLAPIENTRY -_es_TexGenf(GLenum coord, GLenum pname, GLfloat param); - -extern void GLAPIENTRY -_es_TexGenfv(GLenum coord, GLenum pname, const GLfloat *params); - - -#else /* FEATURE_texgen */ - -static void -_mesa_TexGenfv( GLenum coord, GLenum pname, const GLfloat *params ) -{ -} - -static void inline -_mesa_TexGeni( GLenum coord, GLenum pname, GLint param ) -{ -} - -static inline void -_mesa_init_texgen_dispatch(struct _glapi_table *disp) -{ -} - -#endif /* FEATURE_texgen */ - - -#endif /* TEXGEN_H */ diff --git a/dll/opengl/mesa/main/texgetimage.c b/dll/opengl/mesa/main/texgetimage.c deleted file mode 100644 index f77d38331ef..00000000000 --- a/dll/opengl/mesa/main/texgetimage.c +++ /dev/null @@ -1,557 +0,0 @@ -/* - * Mesa 3-D graphics library - * Version: 7.7 - * - * Copyright (C) 1999-2008 Brian Paul All Rights Reserved. - * Copyright (c) 2009 VMware, Inc. - * - * Permission is hereby granted, free of charge, to any person obtaining a - * copy of this software and associated documentation files (the "Software"), - * to deal in the Software without restriction, including without limitation - * the rights to use, copy, modify, merge, publish, distribute, sublicense, - * and/or sell copies of the Software, and to permit persons to whom the - * Software is furnished to do so, subject to the following conditions: - * - * The above copyright notice and this permission notice shall be included - * in all copies or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS - * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL - * BRIAN PAUL BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN - * AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN - * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. - */ - -/** - * Code for glGetTexImage() and glGetCompressedTexImage(). - */ - -#include - -/** - * Can the given type represent negative values? - */ -static inline GLboolean -type_needs_clamping(GLenum type) -{ - switch (type) { - case GL_BYTE: - case GL_SHORT: - case GL_INT: - case GL_FLOAT: - case GL_UNSIGNED_INT_10F_11F_11F_REV: - case GL_UNSIGNED_INT_5_9_9_9_REV: - return GL_FALSE; - default: - return GL_TRUE; - } -} - - -/** - * glGetTexImage for depth/Z pixels. - */ -static void -get_tex_depth(struct gl_context *ctx, GLuint dimensions, - GLenum format, GLenum type, GLvoid *pixels, - struct gl_texture_image *texImage) -{ - const GLint width = texImage->Width; - const GLint height = texImage->Height; - const GLint depth = texImage->Depth; - GLint img, row; - GLfloat *depthRow = (GLfloat *) malloc(width * sizeof(GLfloat)); - - if (!depthRow) { - _mesa_error(ctx, GL_OUT_OF_MEMORY, "glGetTexImage"); - return; - } - - for (img = 0; img < depth; img++) { - GLubyte *srcMap; - GLint srcRowStride; - - /* map src texture buffer */ - ctx->Driver.MapTextureImage(ctx, texImage, img, - 0, 0, width, height, GL_MAP_READ_BIT, - &srcMap, &srcRowStride); - - if (srcMap) { - for (row = 0; row < height; row++) { - void *dest = _mesa_image_address(dimensions, &ctx->Pack, pixels, - width, height, format, type, - img, row, 0); - const GLubyte *src = srcMap + row * srcRowStride; - _mesa_unpack_float_z_row(texImage->TexFormat, width, src, depthRow); - _mesa_pack_depth_span(ctx, width, dest, type, depthRow, &ctx->Pack); - } - - ctx->Driver.UnmapTextureImage(ctx, texImage, img); - } - else { - _mesa_error(ctx, GL_OUT_OF_MEMORY, "glGetTexImage"); - break; - } - } - - free(depthRow); -} - -/** - * glGetTexImage for YCbCr pixels. - */ -static void -get_tex_ycbcr(struct gl_context *ctx, GLuint dimensions, - GLenum format, GLenum type, GLvoid *pixels, - struct gl_texture_image *texImage) -{ - const GLint width = texImage->Width; - const GLint height = texImage->Height; - const GLint depth = texImage->Depth; - GLint img, row; - - for (img = 0; img < depth; img++) { - GLubyte *srcMap; - GLint rowstride; - - /* map src texture buffer */ - ctx->Driver.MapTextureImage(ctx, texImage, img, - 0, 0, width, height, GL_MAP_READ_BIT, - &srcMap, &rowstride); - - if (srcMap) { - for (row = 0; row < height; row++) { - const GLubyte *src = srcMap + row * rowstride; - void *dest = _mesa_image_address(dimensions, &ctx->Pack, pixels, - width, height, format, type, - img, row, 0); - memcpy(dest, src, width * sizeof(GLushort)); - - /* check for byte swapping */ - if ((texImage->TexFormat == MESA_FORMAT_YCBCR - && type == GL_UNSIGNED_SHORT_8_8_REV_MESA) || - (texImage->TexFormat == MESA_FORMAT_YCBCR_REV - && type == GL_UNSIGNED_SHORT_8_8_MESA)) { - if (!ctx->Pack.SwapBytes) - _mesa_swap2((GLushort *) dest, width); - } - else if (ctx->Pack.SwapBytes) { - _mesa_swap2((GLushort *) dest, width); - } - } - - ctx->Driver.UnmapTextureImage(ctx, texImage, img); - } - else { - _mesa_error(ctx, GL_OUT_OF_MEMORY, "glGetTexImage"); - break; - } - } -} - -/** - * Get an uncompressed color texture image. - */ -static void -get_tex_rgba_uncompressed(struct gl_context *ctx, GLuint dimensions, - GLenum format, GLenum type, GLvoid *pixels, - struct gl_texture_image *texImage, - GLbitfield transferOps) -{ - const gl_format texFormat = texImage->TexFormat; - const GLuint width = texImage->Width; - const GLenum destBaseFormat = _mesa_base_tex_format(ctx, format); - GLenum rebaseFormat = GL_NONE; - GLuint height = texImage->Height; - GLuint depth = texImage->Depth; - GLuint img, row; - GLfloat (*rgba)[4]; - GLuint (*rgba_uint)[4]; - GLboolean is_integer = _mesa_is_format_integer_color(texImage->TexFormat); - - /* Allocate buffer for one row of texels */ - rgba = (GLfloat (*)[4]) malloc(4 * width * sizeof(GLfloat)); - rgba_uint = (GLuint (*)[4]) rgba; - if (!rgba) { - _mesa_error(ctx, GL_OUT_OF_MEMORY, "glGetTexImage()"); - return; - } - - if (texImage->_BaseFormat == GL_LUMINANCE || - texImage->_BaseFormat == GL_INTENSITY || - texImage->_BaseFormat == GL_LUMINANCE_ALPHA) { - /* If a luminance (or intensity) texture is read back as RGB(A), the - * returned value should be (L,0,0,1), not (L,L,L,1). Set rebaseFormat - * here to get G=B=0. - */ - rebaseFormat = texImage->_BaseFormat; - } - else if ((texImage->_BaseFormat == GL_RGBA || - texImage->_BaseFormat == GL_RGB) && - (destBaseFormat == GL_LUMINANCE || - destBaseFormat == GL_LUMINANCE_ALPHA || - destBaseFormat == GL_LUMINANCE_INTEGER_EXT || - destBaseFormat == GL_LUMINANCE_ALPHA_INTEGER_EXT)) { - /* If we're reading back an RGB(A) texture as luminance then we need - * to return L=tex(R). Note, that's different from glReadPixels which - * returns L=R+G+B. - */ - rebaseFormat = GL_LUMINANCE_ALPHA; /* this covers GL_LUMINANCE too */ - } - - for (img = 0; img < depth; img++) { - GLubyte *srcMap; - GLint rowstride; - - /* map src texture buffer */ - ctx->Driver.MapTextureImage(ctx, texImage, img, - 0, 0, width, height, GL_MAP_READ_BIT, - &srcMap, &rowstride); - if (srcMap) { - for (row = 0; row < height; row++) { - const GLubyte *src = srcMap + row * rowstride; - void *dest = _mesa_image_address(dimensions, &ctx->Pack, pixels, - width, height, format, type, - img, row, 0); - - if (is_integer) { - _mesa_unpack_uint_rgba_row(texFormat, width, src, rgba_uint); - if (rebaseFormat) - _mesa_rebase_rgba_uint(width, rgba_uint, rebaseFormat); - _mesa_pack_rgba_span_int(ctx, width, rgba_uint, - format, type, dest); - } else { - _mesa_unpack_rgba_row(texFormat, width, src, rgba); - if (rebaseFormat) - _mesa_rebase_rgba_float(width, rgba, rebaseFormat); - _mesa_pack_rgba_span_float(ctx, width, (GLfloat (*)[4]) rgba, - format, type, dest, - &ctx->Pack, transferOps); - } - } - - /* Unmap the src texture buffer */ - ctx->Driver.UnmapTextureImage(ctx, texImage, img); - } - else { - _mesa_error(ctx, GL_OUT_OF_MEMORY, "glGetTexImage"); - break; - } - } - - free(rgba); -} - - -/** - * glGetTexImage for color formats (RGBA, RGB, alpha, LA, etc). - * Compressed textures are handled here as well. - */ -static void -get_tex_rgba(struct gl_context *ctx, GLuint dimensions, - GLenum format, GLenum type, GLvoid *pixels, - struct gl_texture_image *texImage) -{ - const GLenum dataType = _mesa_get_format_datatype(texImage->TexFormat); - GLbitfield transferOps = 0x0; - - /* In general, clamping does not apply to glGetTexImage, except when - * the returned type of the image can't hold negative values. - */ - if (type_needs_clamping(type)) { - /* the returned image type can't have negative values */ - if (dataType == GL_FLOAT || - dataType == GL_SIGNED_NORMALIZED || - format == GL_LUMINANCE || - format == GL_LUMINANCE_ALPHA) { - transferOps |= IMAGE_CLAMP_BIT; - } - } - /* This applies to RGB, RGBA textures. if the format is either LUMINANCE - * or LUMINANCE ALPHA, luminance (L) is computed as L=R+G+B .we need to - * clamp the sum to [0,1]. - */ - else if ((format == GL_LUMINANCE || - format == GL_LUMINANCE_ALPHA) && - dataType == GL_UNSIGNED_NORMALIZED) { - transferOps |= IMAGE_CLAMP_BIT; - } - get_tex_rgba_uncompressed(ctx, dimensions, format, type, - pixels, texImage, transferOps); -} - - -/** - * Try to do glGetTexImage() with simple memcpy(). - * \return GL_TRUE if done, GL_FALSE otherwise - */ -static GLboolean -get_tex_memcpy(struct gl_context *ctx, GLenum format, GLenum type, - GLvoid *pixels, - struct gl_texture_image *texImage) -{ - const GLenum target = texImage->TexObject->Target; - GLboolean memCopy = GL_FALSE; - - /* - * Check if the src/dst formats are compatible. - * Also note that GL's pixel transfer ops don't apply to glGetTexImage() - * so we don't have to worry about those. - * XXX more format combinations could be supported here. - */ - if (target == GL_TEXTURE_1D || - target == GL_TEXTURE_2D || - _mesa_is_cube_face(target)) { - if ((texImage->TexFormat == MESA_FORMAT_ARGB8888) && - format == GL_BGRA && - (type == GL_UNSIGNED_BYTE || type == GL_UNSIGNED_INT_8_8_8_8_REV) && - !ctx->Pack.SwapBytes && - _mesa_little_endian()) { - memCopy = GL_TRUE; - } - else if ((texImage->TexFormat == MESA_FORMAT_AL88) && - format == GL_LUMINANCE_ALPHA && - type == GL_UNSIGNED_BYTE && - !ctx->Pack.SwapBytes && - _mesa_little_endian()) { - memCopy = GL_TRUE; - } - else if ((texImage->TexFormat == MESA_FORMAT_L8) && - format == GL_LUMINANCE && - type == GL_UNSIGNED_BYTE) { - memCopy = GL_TRUE; - } - else if (texImage->TexFormat == MESA_FORMAT_L16 && - format == GL_LUMINANCE && - type == GL_UNSIGNED_SHORT) { - memCopy = GL_TRUE; - } - else if (texImage->TexFormat == MESA_FORMAT_A8 && - format == GL_ALPHA && - type == GL_UNSIGNED_BYTE) { - memCopy = GL_TRUE; - } - else if (texImage->TexFormat == MESA_FORMAT_A16 && - format == GL_ALPHA && - type == GL_UNSIGNED_SHORT) { - memCopy = GL_TRUE; - } - } - - if (memCopy) { - const GLuint bpp = _mesa_get_format_bytes(texImage->TexFormat); - const GLuint bytesPerRow = texImage->Width * bpp; - GLubyte *dst = - _mesa_image_address2d(&ctx->Pack, pixels, texImage->Width, - texImage->Height, format, type, 0, 0); - const GLint dstRowStride = - _mesa_image_row_stride(&ctx->Pack, texImage->Width, format, type); - GLubyte *src; - GLint srcRowStride; - - /* map src texture buffer */ - ctx->Driver.MapTextureImage(ctx, texImage, 0, - 0, 0, texImage->Width, texImage->Height, - GL_MAP_READ_BIT, &src, &srcRowStride); - - if (src) { - if (bytesPerRow == dstRowStride && bytesPerRow == srcRowStride) { - memcpy(dst, src, bytesPerRow * texImage->Height); - } - else { - GLuint row; - for (row = 0; row < texImage->Height; row++) { - memcpy(dst, src, bytesPerRow); - dst += dstRowStride; - src += srcRowStride; - } - } - - /* unmap src texture buffer */ - ctx->Driver.UnmapTextureImage(ctx, texImage, 0); - } - else { - _mesa_error(ctx, GL_OUT_OF_MEMORY, "glGetTexImage"); - } - } - - return memCopy; -} - - -/** - * This is the software fallback for Driver.GetTexImage(). - * All error checking will have been done before this routine is called. - * We'll call ctx->Driver.MapTextureImage() to access the data, then - * unmap with ctx->Driver.UnmapTextureImage(). - */ -void -_mesa_get_teximage(struct gl_context *ctx, - GLenum format, GLenum type, GLvoid *pixels, - struct gl_texture_image *texImage) -{ - GLuint dimensions; - - switch (texImage->TexObject->Target) { - case GL_TEXTURE_1D: - dimensions = 1; - break; - default: - dimensions = 2; - } - - if (get_tex_memcpy(ctx, format, type, pixels, texImage)) { - /* all done */ - } - else if (format == GL_DEPTH_COMPONENT) { - get_tex_depth(ctx, dimensions, format, type, pixels, texImage); - } - else if (format == GL_YCBCR_MESA) { - get_tex_ycbcr(ctx, dimensions, format, type, pixels, texImage); - } - else { - get_tex_rgba(ctx, dimensions, format, type, pixels, texImage); - } -} - -/** - * Do error checking for a glGetTexImage() call. - * \return GL_TRUE if any error, GL_FALSE if no errors. - */ -static GLboolean -getteximage_error_check(struct gl_context *ctx, GLenum target, GLint level, - GLenum format, GLenum type, GLvoid *pixels ) -{ - struct gl_texture_object *texObj; - struct gl_texture_image *texImage; - const GLint maxLevels = _mesa_max_texture_levels(ctx, target); - GLenum baseFormat, err; - - if (maxLevels == 0) { - _mesa_error(ctx, GL_INVALID_ENUM, "glGetTexImage(target=0x%x)", target); - return GL_TRUE; - } - - if (level < 0 || level >= maxLevels) { - _mesa_error( ctx, GL_INVALID_VALUE, "glGetTexImage(level)" ); - return GL_TRUE; - } - - if (_mesa_sizeof_packed_type(type) <= 0) { - _mesa_error( ctx, GL_INVALID_ENUM, "glGetTexImage(type)" ); - return GL_TRUE; - } - - if (_mesa_components_in_format(format) <= 0 || - format == GL_STENCIL_INDEX || - format == GL_COLOR_INDEX) { - _mesa_error( ctx, GL_INVALID_ENUM, "glGetTexImage(format)" ); - return GL_TRUE; - } - - if (_mesa_is_depth_format(format)) { - _mesa_error(ctx, GL_INVALID_ENUM, "glGetTexImage(format)"); - return GL_TRUE; - } - - if (!ctx->Extensions.MESA_ycbcr_texture && _mesa_is_ycbcr_format(format)) { - _mesa_error(ctx, GL_INVALID_ENUM, "glGetTexImage(format)"); - return GL_TRUE; - } - - err = _mesa_error_check_format_and_type(ctx, format, type); - if (err != GL_NO_ERROR) { - _mesa_error(ctx, err, "glGetTexImage(format/type)"); - return GL_TRUE; - } - - texObj = _mesa_select_tex_object(ctx, target); - - if (!texObj || _mesa_is_proxy_texture(target)) { - _mesa_error(ctx, GL_INVALID_ENUM, "glGetTexImage(target)"); - return GL_TRUE; - } - - texImage = _mesa_select_tex_image(ctx, texObj, target, level); - if (!texImage) { - /* non-existant texture image */ - return GL_TRUE; - } - - baseFormat = _mesa_get_format_base_format(texImage->TexFormat); - - /* Make sure the requested image format is compatible with the - * texture's format. - */ - if (_mesa_is_color_format(format) - && !_mesa_is_color_format(baseFormat)) { - _mesa_error(ctx, GL_INVALID_OPERATION, "glGetTexImage(format mismatch)"); - return GL_TRUE; - } - else if (_mesa_is_depth_format(format) - && !_mesa_is_depth_format(baseFormat)) { - _mesa_error(ctx, GL_INVALID_OPERATION, "glGetTexImage(format mismatch)"); - return GL_TRUE; - } - else if (_mesa_is_ycbcr_format(format) - && !_mesa_is_ycbcr_format(baseFormat)) { - _mesa_error(ctx, GL_INVALID_OPERATION, "glGetTexImage(format mismatch)"); - return GL_TRUE; - } - - return GL_FALSE; -} - - - -/** - * Get texture image. Called by glGetTexImage. - * - * \param target texture target. - * \param level image level. - * \param format pixel data format for returned image. - * \param type pixel data type for returned image. - * \param bufSize size of the pixels data buffer. - * \param pixels returned pixel data. - */ -void GLAPIENTRY -_mesa_GetTexImage( GLenum target, GLint level, GLenum format, - GLenum type, GLvoid *pixels ) -{ - struct gl_texture_object *texObj; - struct gl_texture_image *texImage; - GET_CURRENT_CONTEXT(ctx); - ASSERT_OUTSIDE_BEGIN_END_AND_FLUSH(ctx); - - if (getteximage_error_check(ctx, target, level, format, type, pixels)) { - return; - } - - if (!pixels) { - /* not an error, do nothing */ - return; - } - - texObj = _mesa_select_tex_object(ctx, target); - texImage = _mesa_select_tex_image(ctx, texObj, target, level); - - if (_mesa_is_zero_size_texture(texImage)) - return; - - if (MESA_VERBOSE & (VERBOSE_API | VERBOSE_TEXTURE)) { - _mesa_debug(ctx, "glGetTexImage(tex %u) format = %s, w=%d, h=%d," - " dstFmt=0x%x, dstType=0x%x\n", - texObj->Name, - _mesa_get_format_name(texImage->TexFormat), - texImage->Width, texImage->Height, - format, type); - } - - _mesa_lock_texture(ctx, texObj); - { - ctx->Driver.GetTexImage(ctx, format, type, pixels, texImage); - } - _mesa_unlock_texture(ctx, texObj); -} - diff --git a/dll/opengl/mesa/main/texgetimage.h b/dll/opengl/mesa/main/texgetimage.h deleted file mode 100644 index eedf2ebfb47..00000000000 --- a/dll/opengl/mesa/main/texgetimage.h +++ /dev/null @@ -1,47 +0,0 @@ -/* - * Mesa 3-D graphics library - * Version: 7.5 - * - * Copyright (C) 1999-2008 Brian Paul All Rights Reserved. - * Copyright (c) 2009 VMware, Inc. - * - * Permission is hereby granted, free of charge, to any person obtaining a - * copy of this software and associated documentation files (the "Software"), - * to deal in the Software without restriction, including without limitation - * the rights to use, copy, modify, merge, publish, distribute, sublicense, - * and/or sell copies of the Software, and to permit persons to whom the - * Software is furnished to do so, subject to the following conditions: - * - * The above copyright notice and this permission notice shall be included - * in all copies or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS - * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL - * BRIAN PAUL BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN - * AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN - * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. - */ - - -#ifndef TEXGETIMAGE_H -#define TEXGETIMAGE_H - -#include "glheader.h" - -struct gl_context; -struct gl_texture_image; -struct gl_texture_object; - -extern void -_mesa_get_teximage(struct gl_context *ctx, - GLenum format, GLenum type, GLvoid *pixels, - struct gl_texture_image *texImage); - - - -extern void GLAPIENTRY -_mesa_GetTexImage( GLenum target, GLint level, - GLenum format, GLenum type, GLvoid *pixels ); - -#endif /* TEXGETIMAGE_H */ diff --git a/dll/opengl/mesa/main/teximage.c b/dll/opengl/mesa/main/teximage.c deleted file mode 100644 index f6352726fee..00000000000 --- a/dll/opengl/mesa/main/teximage.c +++ /dev/null @@ -1,2094 +0,0 @@ -/* - * Mesa 3-D graphics library - * - * Copyright (C) 1999-2008 Brian Paul All Rights Reserved. - * Copyright (C) 2009 VMware, Inc. All Rights Reserved. - * - * Permission is hereby granted, free of charge, to any person obtaining a - * copy of this software and associated documentation files (the "Software"), - * to deal in the Software without restriction, including without limitation - * the rights to use, copy, modify, merge, publish, distribute, sublicense, - * and/or sell copies of the Software, and to permit persons to whom the - * Software is furnished to do so, subject to the following conditions: - * - * The above copyright notice and this permission notice shall be included - * in all copies or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS - * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL - * BRIAN PAUL BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN - * AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN - * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. - */ - - -/** - * \file teximage.c - * Texture image-related functions. - */ - -#include - -/** - * State changes which we care about for glCopyTex[Sub]Image() calls. - * In particular, we care about pixel transfer state and buffer state - * (such as glReadBuffer to make sure we read from the right renderbuffer). - */ -#define NEW_COPY_TEX_STATE (_NEW_BUFFERS | _NEW_PIXEL) - - - -/** - * Return the simple base format for a given internal texture format. - * For example, given GL_LUMINANCE12_ALPHA4, return GL_LUMINANCE_ALPHA. - * - * \param ctx GL context. - * \param internalFormat the internal texture format token or 1, 2, 3, or 4. - * - * \return the corresponding \u base internal format (GL_ALPHA, GL_LUMINANCE, - * GL_LUMANCE_ALPHA, GL_INTENSITY, GL_RGB, or GL_RGBA), or -1 if invalid enum. - * - * This is the format which is used during texture application (i.e. the - * texture format and env mode determine the arithmetic used. - * - * XXX this could be static - */ -GLint -_mesa_base_tex_format( struct gl_context *ctx, GLint internalFormat ) -{ - switch (internalFormat) { - case GL_ALPHA: - case GL_ALPHA4: - case GL_ALPHA8: - case GL_ALPHA12: - case GL_ALPHA16: - return GL_ALPHA; - case 1: - case GL_LUMINANCE: - case GL_LUMINANCE4: - case GL_LUMINANCE8: - case GL_LUMINANCE12: - case GL_LUMINANCE16: - return GL_LUMINANCE; - case 2: - case GL_LUMINANCE_ALPHA: - case GL_LUMINANCE4_ALPHA4: - case GL_LUMINANCE6_ALPHA2: - case GL_LUMINANCE8_ALPHA8: - case GL_LUMINANCE12_ALPHA4: - case GL_LUMINANCE12_ALPHA12: - case GL_LUMINANCE16_ALPHA16: - return GL_LUMINANCE_ALPHA; - case GL_INTENSITY: - case GL_INTENSITY4: - case GL_INTENSITY8: - case GL_INTENSITY12: - case GL_INTENSITY16: - return GL_INTENSITY; - case 3: - case GL_RGB: - case GL_R3_G3_B2: - case GL_RGB4: - case GL_RGB5: - case GL_RGB8: - case GL_RGB10: - case GL_RGB12: - case GL_RGB16: - return GL_RGB; - case 4: - case GL_RGBA: - case GL_RGBA2: - case GL_RGBA4: - case GL_RGB5_A1: - case GL_RGBA8: - case GL_RGB10_A2: - case GL_RGBA12: - case GL_RGBA16: - return GL_RGBA; - default: - ; /* fallthrough */ - } - - if (ctx->Extensions.MESA_ycbcr_texture) { - if (internalFormat == GL_YCBCR_MESA) - return GL_YCBCR_MESA; - } - - if (ctx->VersionMajor >= 3 || - ctx->Extensions.EXT_texture_integer) { - switch (internalFormat) { - case GL_RGBA8UI_EXT: - case GL_RGBA16UI_EXT: - case GL_RGBA32UI_EXT: - case GL_RGBA8I_EXT: - case GL_RGBA16I_EXT: - case GL_RGBA32I_EXT: - case GL_RGB10_A2UI: - return GL_RGBA; - case GL_RGB8UI_EXT: - case GL_RGB16UI_EXT: - case GL_RGB32UI_EXT: - case GL_RGB8I_EXT: - case GL_RGB16I_EXT: - case GL_RGB32I_EXT: - return GL_RGB; - } - } - - if (ctx->Extensions.EXT_texture_integer) { - switch (internalFormat) { - case GL_ALPHA8UI_EXT: - case GL_ALPHA16UI_EXT: - case GL_ALPHA32UI_EXT: - case GL_ALPHA8I_EXT: - case GL_ALPHA16I_EXT: - case GL_ALPHA32I_EXT: - return GL_ALPHA; - case GL_INTENSITY8UI_EXT: - case GL_INTENSITY16UI_EXT: - case GL_INTENSITY32UI_EXT: - case GL_INTENSITY8I_EXT: - case GL_INTENSITY16I_EXT: - case GL_INTENSITY32I_EXT: - return GL_INTENSITY; - case GL_LUMINANCE8UI_EXT: - case GL_LUMINANCE16UI_EXT: - case GL_LUMINANCE32UI_EXT: - case GL_LUMINANCE8I_EXT: - case GL_LUMINANCE16I_EXT: - case GL_LUMINANCE32I_EXT: - return GL_LUMINANCE; - case GL_LUMINANCE_ALPHA8UI_EXT: - case GL_LUMINANCE_ALPHA16UI_EXT: - case GL_LUMINANCE_ALPHA32UI_EXT: - case GL_LUMINANCE_ALPHA8I_EXT: - case GL_LUMINANCE_ALPHA16I_EXT: - case GL_LUMINANCE_ALPHA32I_EXT: - return GL_LUMINANCE_ALPHA; - default: - ; /* fallthrough */ - } - } - - return -1; /* error */ -} - - -/** - * Is the given texture format a generic compressed format? - */ - - -/** - * For cube map faces, return a face index in [0,5]. - * For other targets return 0; - */ -GLuint -_mesa_tex_target_to_face(GLenum target) -{ - if (_mesa_is_cube_face(target)) - return (GLuint) target - (GLuint) GL_TEXTURE_CUBE_MAP_POSITIVE_X; - else - return 0; -} - - - -/** - * Install gl_texture_image in a gl_texture_object according to the target - * and level parameters. - * - * \param tObj texture object. - * \param target texture target. - * \param level image level. - * \param texImage texture image. - */ -static void -set_tex_image(struct gl_texture_object *tObj, - GLenum target, GLint level, - struct gl_texture_image *texImage) -{ - const GLuint face = _mesa_tex_target_to_face(target); - - ASSERT(tObj); - ASSERT(texImage); - - tObj->Image[face][level] = texImage; - - /* Set the 'back' pointer */ - texImage->TexObject = tObj; - texImage->Level = level; - texImage->Face = face; -} - - -/** - * Allocate a texture image structure. - * - * Called via ctx->Driver.NewTextureImage() unless overriden by a device - * driver. - * - * \return a pointer to gl_texture_image struct with all fields initialized to - * zero. - */ -struct gl_texture_image * -_mesa_new_texture_image( struct gl_context *ctx ) -{ - (void) ctx; - return CALLOC_STRUCT(gl_texture_image); -} - - -/** - * Free a gl_texture_image and associated data. - * This function is a fallback called via ctx->Driver.DeleteTextureImage(). - * - * \param texImage texture image. - * - * Free the texture image structure and the associated image data. - */ -void -_mesa_delete_texture_image(struct gl_context *ctx, - struct gl_texture_image *texImage) -{ - /* Free texImage->Data and/or any other driver-specific texture - * image storage. - */ - ASSERT(ctx->Driver.FreeTextureImageBuffer); - ctx->Driver.FreeTextureImageBuffer( ctx, texImage ); - free(texImage); -} - - -/** - * Test if a target is a proxy target. - * - * \param target texture target. - * - * \return GL_TRUE if the target is a proxy target, GL_FALSE otherwise. - */ -GLboolean -_mesa_is_proxy_texture(GLenum target) -{ - /* - * NUM_TEXTURE_TARGETS should match number of terms below, except there's no - * proxy for GL_TEXTURE_BUFFER and GL_TEXTURE_EXTERNAL_OES. - */ - assert(NUM_TEXTURE_TARGETS == 7 + 2); - - return (target == GL_PROXY_TEXTURE_1D || - target == GL_PROXY_TEXTURE_2D || - target == GL_PROXY_TEXTURE_CUBE_MAP_ARB); -} - - -/** - * Return the proxy target which corresponds to the given texture target - */ -static GLenum -get_proxy_target(GLenum target) -{ - switch (target) { - case GL_TEXTURE_1D: - case GL_PROXY_TEXTURE_1D: - return GL_PROXY_TEXTURE_1D; - case GL_TEXTURE_2D: - case GL_PROXY_TEXTURE_2D: - return GL_PROXY_TEXTURE_2D; - case GL_TEXTURE_CUBE_MAP_POSITIVE_X_ARB: - case GL_TEXTURE_CUBE_MAP_NEGATIVE_X_ARB: - case GL_TEXTURE_CUBE_MAP_POSITIVE_Y_ARB: - case GL_TEXTURE_CUBE_MAP_NEGATIVE_Y_ARB: - case GL_TEXTURE_CUBE_MAP_POSITIVE_Z_ARB: - case GL_TEXTURE_CUBE_MAP_NEGATIVE_Z_ARB: - case GL_TEXTURE_CUBE_MAP_ARB: - case GL_PROXY_TEXTURE_CUBE_MAP_ARB: - return GL_PROXY_TEXTURE_CUBE_MAP_ARB; - default: - _mesa_problem(NULL, "unexpected target in get_proxy_target()"); - return 0; - } -} - - -/** - * Get the texture object that corresponds to the target of the given - * texture unit. The target should have already been checked for validity. - * - * \param ctx GL context. - * \param texUnit texture unit. - * \param target texture target. - * - * \return pointer to the texture object on success, or NULL on failure. - */ -struct gl_texture_object * -_mesa_select_tex_object(struct gl_context *ctx, - GLenum target) -{ - switch (target) { - case GL_TEXTURE_1D: - return ctx->Texture.Unit.CurrentTex[TEXTURE_1D_INDEX]; - case GL_PROXY_TEXTURE_1D: - return ctx->Texture.ProxyTex[TEXTURE_1D_INDEX]; - case GL_TEXTURE_2D: - return ctx->Texture.Unit.CurrentTex[TEXTURE_2D_INDEX]; - case GL_PROXY_TEXTURE_2D: - return ctx->Texture.ProxyTex[TEXTURE_2D_INDEX]; - default: - _mesa_problem(NULL, "bad target in _mesa_select_tex_object()"); - return NULL; - } -} - - -/** - * Get a texture image pointer from a texture object, given a texture - * target and mipmap level. The target and level parameters should - * have already been error-checked. - * - * \param ctx GL context. - * \param texObj texture unit. - * \param target texture target. - * \param level image level. - * - * \return pointer to the texture image structure, or NULL on failure. - */ -struct gl_texture_image * -_mesa_select_tex_image(struct gl_context *ctx, - const struct gl_texture_object *texObj, - GLenum target, GLint level) -{ - const GLuint face = _mesa_tex_target_to_face(target); - - ASSERT(texObj); - ASSERT(level >= 0); - ASSERT(level < MAX_TEXTURE_LEVELS); - - return texObj->Image[face][level]; -} - - -/** - * Like _mesa_select_tex_image() but if the image doesn't exist, allocate - * it and install it. Only return NULL if passed a bad parameter or run - * out of memory. - */ -struct gl_texture_image * -_mesa_get_tex_image(struct gl_context *ctx, struct gl_texture_object *texObj, - GLenum target, GLint level) -{ - struct gl_texture_image *texImage; - - if (!texObj) - return NULL; - - texImage = _mesa_select_tex_image(ctx, texObj, target, level); - if (!texImage) { - texImage = ctx->Driver.NewTextureImage(ctx); - if (!texImage) { - _mesa_error(ctx, GL_OUT_OF_MEMORY, "texture image allocation"); - return NULL; - } - - set_tex_image(texObj, target, level, texImage); - } - - return texImage; -} - - -/** - * Return pointer to the specified proxy texture image. - * Note that proxy textures are per-context, not per-texture unit. - * \return pointer to texture image or NULL if invalid target, invalid - * level, or out of memory. - */ -struct gl_texture_image * -_mesa_get_proxy_tex_image(struct gl_context *ctx, GLenum target, GLint level) -{ - struct gl_texture_image *texImage; - GLuint texIndex; - - if (level < 0 ) - return NULL; - - switch (target) { - case GL_PROXY_TEXTURE_1D: - if (level >= ctx->Const.MaxTextureLevels) - return NULL; - texIndex = TEXTURE_1D_INDEX; - break; - case GL_PROXY_TEXTURE_2D: - if (level >= ctx->Const.MaxTextureLevels) - return NULL; - texIndex = TEXTURE_2D_INDEX; - break; - case GL_PROXY_TEXTURE_CUBE_MAP: - if (level >= ctx->Const.MaxCubeTextureLevels) - return NULL; - texIndex = TEXTURE_CUBE_INDEX; - break; - default: - return NULL; - } - - texImage = ctx->Texture.ProxyTex[texIndex]->Image[0][level]; - if (!texImage) { - texImage = ctx->Driver.NewTextureImage(ctx); - if (!texImage) { - _mesa_error(ctx, GL_OUT_OF_MEMORY, "proxy texture allocation"); - return NULL; - } - ctx->Texture.ProxyTex[texIndex]->Image[0][level] = texImage; - /* Set the 'back' pointer */ - texImage->TexObject = ctx->Texture.ProxyTex[texIndex]; - } - return texImage; -} - - -/** - * Get the maximum number of allowed mipmap levels. - * - * \param ctx GL context. - * \param target texture target. - * - * \return the maximum number of allowed mipmap levels for the given - * texture target, or zero if passed a bad target. - * - * \sa gl_constants. - */ -GLint -_mesa_max_texture_levels(struct gl_context *ctx, GLenum target) -{ - switch (target) { - case GL_TEXTURE_1D: - case GL_PROXY_TEXTURE_1D: - case GL_TEXTURE_2D: - case GL_PROXY_TEXTURE_2D: - return ctx->Const.MaxTextureLevels; - case GL_TEXTURE_CUBE_MAP_POSITIVE_X_ARB: - case GL_TEXTURE_CUBE_MAP_NEGATIVE_X_ARB: - case GL_TEXTURE_CUBE_MAP_POSITIVE_Y_ARB: - case GL_TEXTURE_CUBE_MAP_NEGATIVE_Y_ARB: - case GL_TEXTURE_CUBE_MAP_POSITIVE_Z_ARB: - case GL_TEXTURE_CUBE_MAP_NEGATIVE_Z_ARB: - case GL_PROXY_TEXTURE_CUBE_MAP_ARB: - return ctx->Extensions.ARB_texture_cube_map - ? ctx->Const.MaxCubeTextureLevels : 0; - default: - return 0; /* bad target */ - } -} - - -/** - * Return number of dimensions per mipmap level for the given texture target. - */ -GLint -_mesa_get_texture_dimensions(GLenum target) -{ - switch (target) { - case GL_TEXTURE_1D: - case GL_PROXY_TEXTURE_1D: - return 1; - case GL_TEXTURE_2D: - case GL_TEXTURE_CUBE_MAP: - case GL_PROXY_TEXTURE_2D: - case GL_PROXY_TEXTURE_CUBE_MAP: - case GL_TEXTURE_CUBE_MAP_POSITIVE_X: - case GL_TEXTURE_CUBE_MAP_NEGATIVE_X: - case GL_TEXTURE_CUBE_MAP_POSITIVE_Y: - case GL_TEXTURE_CUBE_MAP_NEGATIVE_Y: - case GL_TEXTURE_CUBE_MAP_POSITIVE_Z: - case GL_TEXTURE_CUBE_MAP_NEGATIVE_Z: - return 2; - default: - _mesa_problem(NULL, "invalid target 0x%x in get_texture_dimensions()", - target); - return 2; - } -} - - - - -#if 000 /* not used anymore */ -/* - * glTexImage[123]D can accept a NULL image pointer. In this case we - * create a texture image with unspecified image contents per the OpenGL - * spec. - */ -static GLubyte * -make_null_texture(GLint width, GLint height, GLint depth, GLenum format) -{ - const GLint components = _mesa_components_in_format(format); - const GLint numPixels = width * height * depth; - GLubyte *data = (GLubyte *) MALLOC(numPixels * components * sizeof(GLubyte)); - -#ifdef DEBUG - /* - * Let's see if anyone finds this. If glTexImage2D() is called with - * a NULL image pointer then load the texture image with something - * interesting instead of leaving it indeterminate. - */ - if (data) { - static const char message[8][32] = { - " X X XXXXX XXX X ", - " XX XX X X X X X ", - " X X X X X X X ", - " X X XXXX XXX XXXXX ", - " X X X X X X ", - " X X X X X X X ", - " X X XXXXX XXX X X ", - " " - }; - - GLubyte *imgPtr = data; - GLint h, i, j, k; - for (h = 0; h < depth; h++) { - for (i = 0; i < height; i++) { - GLint srcRow = 7 - (i % 8); - for (j = 0; j < width; j++) { - GLint srcCol = j % 32; - GLubyte texel = (message[srcRow][srcCol]=='X') ? 255 : 70; - for (k = 0; k < components; k++) { - *imgPtr++ = texel; - } - } - } - } - } -#endif - - return data; -} -#endif - - - -/** - * Set the size and format-related fields of a gl_texture_image struct - * to zero. This is used when a proxy texture test fails. - */ -static void -clear_teximage_fields(struct gl_texture_image *img) -{ - ASSERT(img); - img->_BaseFormat = 0; - img->InternalFormat = 0; - img->Border = 0; - img->Width = 0; - img->Height = 0; - img->Depth = 0; - img->Width2 = 0; - img->Height2 = 0; - img->Depth2 = 0; - img->WidthLog2 = 0; - img->HeightLog2 = 0; - img->DepthLog2 = 0; - img->TexFormat = MESA_FORMAT_NONE; -} - - -/** - * Initialize basic fields of the gl_texture_image struct. - * - * \param ctx GL context. - * \param img texture image structure to be initialized. - * \param width image width. - * \param height image height. - * \param depth image depth. - * \param border image border. - * \param internalFormat internal format. - * \param format the actual hardware format (one of MESA_FORMAT_*) - * - * Fills in the fields of \p img with the given information. - * Note: width, height and depth include the border. - */ -void -_mesa_init_teximage_fields(struct gl_context *ctx, - struct gl_texture_image *img, - GLsizei width, GLsizei height, GLsizei depth, - GLint border, GLenum internalFormat, - gl_format format) -{ - GLenum target; - ASSERT(img); - ASSERT(width >= 0); - ASSERT(height >= 0); - ASSERT(depth >= 0); - - target = img->TexObject->Target; - img->_BaseFormat = _mesa_base_tex_format( ctx, internalFormat ); - ASSERT(img->_BaseFormat > 0); - img->InternalFormat = internalFormat; - img->Border = border; - img->Width = width; - img->Height = height; - img->Depth = depth; - - img->Width2 = width - 2 * border; /* == 1 << img->WidthLog2; */ - img->WidthLog2 = _mesa_logbase2(img->Width2); - - switch(target) { - case GL_TEXTURE_1D: - case GL_PROXY_TEXTURE_1D: - if (height == 0) - img->Height2 = 0; - else - img->Height2 = 1; - img->HeightLog2 = 0; - if (depth == 0) - img->Depth2 = 0; - else - img->Depth2 = 1; - img->DepthLog2 = 0; - break; - case GL_TEXTURE_2D: - case GL_TEXTURE_CUBE_MAP: - case GL_TEXTURE_CUBE_MAP_POSITIVE_X: - case GL_TEXTURE_CUBE_MAP_NEGATIVE_X: - case GL_TEXTURE_CUBE_MAP_POSITIVE_Y: - case GL_TEXTURE_CUBE_MAP_NEGATIVE_Y: - case GL_TEXTURE_CUBE_MAP_POSITIVE_Z: - case GL_TEXTURE_CUBE_MAP_NEGATIVE_Z: - case GL_PROXY_TEXTURE_2D: - case GL_PROXY_TEXTURE_CUBE_MAP: - img->Height2 = height - 2 * border; /* == 1 << img->HeightLog2; */ - img->HeightLog2 = _mesa_logbase2(img->Height2); - if (depth == 0) - img->Depth2 = 0; - else - img->Depth2 = 1; - img->DepthLog2 = 0; - break; - default: - _mesa_problem(NULL, "invalid target 0x%x in _mesa_init_teximage_fields()", - target); - } - - img->MaxLog2 = MAX2(img->WidthLog2, img->HeightLog2); - img->TexFormat = format; -} - - -/** - * Free and clear fields of the gl_texture_image struct. - * - * \param ctx GL context. - * \param texImage texture image structure to be cleared. - * - * After the call, \p texImage will have no data associated with it. Its - * fields are cleared so that its parent object will test incomplete. - */ -void -_mesa_clear_texture_image(struct gl_context *ctx, - struct gl_texture_image *texImage) -{ - ctx->Driver.FreeTextureImageBuffer(ctx, texImage); - clear_teximage_fields(texImage); -} - - -/** - * This is the fallback for Driver.TestProxyTexImage(). Test the texture - * level, width, height and depth against the ctx->Const limits for textures. - * - * A hardware driver might override this function if, for example, the - * max 3D texture size is 512x512x64 (i.e. not a cube). - * - * Note that width, height, depth == 0 is not an error. However, a - * texture with zero width/height/depth will be considered "incomplete" - * and texturing will effectively be disabled. - * - * \param target one of GL_PROXY_TEXTURE_1D, GL_PROXY_TEXTURE_2D, - * GL_PROXY_TEXTURE_3D, GL_PROXY_TEXTURE_RECTANGLE_NV, - * GL_PROXY_TEXTURE_CUBE_MAP_ARB. - * \param level as passed to glTexImage - * \param internalFormat as passed to glTexImage - * \param format as passed to glTexImage - * \param type as passed to glTexImage - * \param width as passed to glTexImage - * \param height as passed to glTexImage - * \param depth as passed to glTexImage - * \param border as passed to glTexImage - * \return GL_TRUE if the image is acceptable, GL_FALSE if not acceptable. - */ -GLboolean -_mesa_test_proxy_teximage(struct gl_context *ctx, GLenum target, GLint level, - GLint internalFormat, GLenum format, GLenum type, - GLint width, GLint height, GLint depth, GLint border) -{ - GLint maxSize; - - (void) internalFormat; - (void) format; - (void) type; - - switch (target) { - case GL_PROXY_TEXTURE_1D: - maxSize = 1 << (ctx->Const.MaxTextureLevels - 1); - if (width < 2 * border || width > 2 * border + maxSize) - return GL_FALSE; - if (level >= ctx->Const.MaxTextureLevels) - return GL_FALSE; - if (width > 0 && !_mesa_is_pow_two(width - 2 * border)) - return GL_FALSE; - return GL_TRUE; - - case GL_PROXY_TEXTURE_2D: - maxSize = 1 << (ctx->Const.MaxTextureLevels - 1); - if (width < 2 * border || width > 2 * border + maxSize) - return GL_FALSE; - if (height < 2 * border || height > 2 * border + maxSize) - return GL_FALSE; - if (level >= ctx->Const.MaxTextureLevels) - return GL_FALSE; - if (width > 0 && !_mesa_is_pow_two(width - 2 * border)) - return GL_FALSE; - if (height > 0 && !_mesa_is_pow_two(height - 2 * border)) - return GL_FALSE; - return GL_TRUE; - - case GL_PROXY_TEXTURE_CUBE_MAP_ARB: - maxSize = 1 << (ctx->Const.MaxCubeTextureLevels - 1); - if (width < 2 * border || width > 2 * border + maxSize) - return GL_FALSE; - if (height < 2 * border || height > 2 * border + maxSize) - return GL_FALSE; - if (level >= ctx->Const.MaxCubeTextureLevels) - return GL_FALSE; - if (width > 0 && !_mesa_is_pow_two(width - 2 * border)) - return GL_FALSE; - if (height > 0 && !_mesa_is_pow_two(height - 2 * border)) - return GL_FALSE; - return GL_TRUE; - - default: - _mesa_problem(ctx, "Invalid target in _mesa_test_proxy_teximage"); - return GL_FALSE; - } -} - - -/** - * Check if the memory used by the texture would exceed the driver's limit. - * This lets us support a max 3D texture size of 8K (for example) but - * prevents allocating a full 8K x 8K x 8K texture. - * XXX this could be rolled into the proxy texture size test (above) but - * we don't have the actual texture internal format at that point. - */ -static GLboolean -legal_texture_size(struct gl_context *ctx, gl_format format, - GLint width, GLint height, GLint depth) -{ - uint64_t bytes = _mesa_format_image_size64(format, width, height, depth); - uint64_t mbytes = bytes / (1024 * 1024); /* convert to MB */ - return mbytes <= (uint64_t) ctx->Const.MaxTextureMbytes; -} - -/** - * Check if the given texture target value is legal for a - * glTexImage1/2/3D call. - */ -static GLboolean -legal_teximage_target(struct gl_context *ctx, GLuint dims, GLenum target) -{ - switch (dims) { - case 1: - switch (target) { - case GL_TEXTURE_1D: - case GL_PROXY_TEXTURE_1D: - return GL_TRUE; - default: - return GL_FALSE; - } - case 2: - switch (target) { - case GL_TEXTURE_2D: - case GL_PROXY_TEXTURE_2D: - return GL_TRUE; - case GL_PROXY_TEXTURE_CUBE_MAP: - case GL_TEXTURE_CUBE_MAP_POSITIVE_X: - case GL_TEXTURE_CUBE_MAP_NEGATIVE_X: - case GL_TEXTURE_CUBE_MAP_POSITIVE_Y: - case GL_TEXTURE_CUBE_MAP_NEGATIVE_Y: - case GL_TEXTURE_CUBE_MAP_POSITIVE_Z: - case GL_TEXTURE_CUBE_MAP_NEGATIVE_Z: - return ctx->Extensions.ARB_texture_cube_map; - default: - return GL_FALSE; - } - default: - _mesa_problem(ctx, "invalid dims=%u in legal_teximage_target()", dims); - return GL_FALSE; - } -} - - -/** - * Check if the given texture target value is legal for a - * glTexSubImage, glCopyTexSubImage or glCopyTexImage call. - * The difference compared to legal_teximage_target() above is that - * proxy targets are not supported. - */ -static GLboolean -legal_texsubimage_target(struct gl_context *ctx, GLuint dims, GLenum target) -{ - switch (dims) { - case 1: - return target == GL_TEXTURE_1D; - case 2: - switch (target) { - case GL_TEXTURE_2D: - return GL_TRUE; - case GL_TEXTURE_CUBE_MAP_POSITIVE_X: - case GL_TEXTURE_CUBE_MAP_NEGATIVE_X: - case GL_TEXTURE_CUBE_MAP_POSITIVE_Y: - case GL_TEXTURE_CUBE_MAP_NEGATIVE_Y: - case GL_TEXTURE_CUBE_MAP_POSITIVE_Z: - case GL_TEXTURE_CUBE_MAP_NEGATIVE_Z: - return ctx->Extensions.ARB_texture_cube_map; - default: - return GL_FALSE; - } - default: - _mesa_problem(ctx, "invalid dims=%u in legal_texsubimage_target()", - dims); - return GL_FALSE; - } -} - - -/** - * Helper function to determine if a texture object is mutable (in terms - * of GL_ARB_texture_storage). - */ -static GLboolean -mutable_tex_object(struct gl_context *ctx, GLenum target) -{ - if (ctx->Extensions.ARB_texture_storage) { - struct gl_texture_object *texObj = - _mesa_select_tex_object(ctx, target); - return !texObj->Immutable; - } - return GL_TRUE; -} - - - -/** - * Test the glTexImage[123]D() parameters for errors. - * - * \param ctx GL context. - * \param dimensions texture image dimensions (must be 1, 2 or 3). - * \param target texture target given by the user. - * \param level image level given by the user. - * \param internalFormat internal format given by the user. - * \param format pixel data format given by the user. - * \param type pixel data type given by the user. - * \param width image width given by the user. - * \param height image height given by the user. - * \param depth image depth given by the user. - * \param border image border given by the user. - * - * \return GL_TRUE if an error was detected, or GL_FALSE if no errors. - * - * Verifies each of the parameters against the constants specified in - * __struct gl_contextRec::Const and the supported extensions, and according - * to the OpenGL specification. - */ -static GLboolean -texture_error_check( struct gl_context *ctx, - GLuint dimensions, GLenum target, - GLint level, GLint internalFormat, - GLenum format, GLenum type, - GLint width, GLint height, - GLint depth, GLint border ) -{ - const GLenum proxyTarget = get_proxy_target(target); - const GLboolean isProxy = target == proxyTarget; - GLboolean sizeOK = GL_TRUE; - GLboolean colorFormat; - GLenum err; - - /* Even though there are no color-index textures, we still have to support - * uploading color-index data and remapping it to RGB via the - * GL_PIXEL_MAP_I_TO_[RGBA] tables. - */ - const GLboolean indexFormat = (format == GL_COLOR_INDEX); - - /* Basic level check (more checking in ctx->Driver.TestProxyTexImage) */ - if (level < 0 || level >= MAX_TEXTURE_LEVELS) { - if (!isProxy) { - _mesa_error(ctx, GL_INVALID_VALUE, - "glTexImage%dD(level=%d)", dimensions, level); - } - return GL_TRUE; - } - - /* Check border */ - if (border < 0 || border > 1) { - if (!isProxy) { - _mesa_error(ctx, GL_INVALID_VALUE, - "glTexImage%dD(border=%d)", dimensions, border); - } - return GL_TRUE; - } - - if (width < 0 || height < 0 || depth < 0) { - if (!isProxy) { - _mesa_error(ctx, GL_INVALID_VALUE, - "glTexImage%dD(width, height or depth < 0)", dimensions); - } - return GL_TRUE; - } - - /* Do this simple check before calling the TestProxyTexImage() function */ - if (proxyTarget == GL_PROXY_TEXTURE_CUBE_MAP_ARB) { - sizeOK = (width == height); - } - - /* - * Use the proxy texture driver hook to see if the size/level/etc are - * legal. - */ - sizeOK = sizeOK && ctx->Driver.TestProxyTexImage(ctx, proxyTarget, level, - internalFormat, format, - type, width, height, - depth, border); - if (!sizeOK) { - if (!isProxy) { - _mesa_error(ctx, GL_INVALID_VALUE, - "glTexImage%dD(level=%d, width=%d, height=%d, depth=%d)", - dimensions, level, width, height, depth); - } - return GL_TRUE; - } - - /* Check internalFormat */ - if (_mesa_base_tex_format(ctx, internalFormat) < 0) { - if (!isProxy) { - _mesa_error(ctx, GL_INVALID_VALUE, - "glTexImage%dD(internalFormat=%s)", - dimensions, _mesa_lookup_enum_by_nr(internalFormat)); - } - return GL_TRUE; - } - - /* Check incoming image format and type */ - err = _mesa_error_check_format_and_type(ctx, format, type); - if (err != GL_NO_ERROR) { - if (!isProxy) { - _mesa_error(ctx, err, - "glTexImage%dD(incompatible format 0x%x, type 0x%x)", - dimensions, format, type); - } - return GL_TRUE; - } - - /* make sure internal format and format basically agree */ - colorFormat = _mesa_is_color_format(format); - if ((_mesa_is_color_format(internalFormat) && !colorFormat && !indexFormat) || - (_mesa_is_depth_format(internalFormat) != _mesa_is_depth_format(format)) || - (_mesa_is_ycbcr_format(internalFormat) != _mesa_is_ycbcr_format(format))) { - if (!isProxy) - _mesa_error(ctx, GL_INVALID_OPERATION, - "glTexImage%dD(incompatible internalFormat 0x%x, format 0x%x)", - dimensions, internalFormat, format); - return GL_TRUE; - } - - /* additional checks for ycbcr textures */ - if (internalFormat == GL_YCBCR_MESA) { - ASSERT(ctx->Extensions.MESA_ycbcr_texture); - if (type != GL_UNSIGNED_SHORT_8_8_MESA && - type != GL_UNSIGNED_SHORT_8_8_REV_MESA) { - char message[100]; - _mesa_snprintf(message, sizeof(message), - "glTexImage%dD(format/type YCBCR mismatch", dimensions); - _mesa_error(ctx, GL_INVALID_ENUM, "%s", message); - return GL_TRUE; /* error */ - } - if (target != GL_TEXTURE_2D && - target != GL_PROXY_TEXTURE_2D) { - if (!isProxy) - _mesa_error(ctx, GL_INVALID_ENUM, "glTexImage(target)"); - return GL_TRUE; - } - if (border != 0) { - if (!isProxy) { - char message[100]; - _mesa_snprintf(message, sizeof(message), - "glTexImage%dD(format=GL_YCBCR_MESA and border=%d)", - dimensions, border); - _mesa_error(ctx, GL_INVALID_VALUE, "%s", message); - } - return GL_TRUE; - } - } - - /* additional checks for depth textures */ - if (_mesa_base_tex_format(ctx, internalFormat) == GL_DEPTH_COMPONENT) { - /* Only 1D, 2D, rect, array and cube textures supported, not 3D - * Cubemaps are only supported for GL version > 3.0 or with EXT_gpu_shader4 */ - if (target != GL_TEXTURE_1D && - target != GL_PROXY_TEXTURE_1D && - target != GL_TEXTURE_2D && - target != GL_PROXY_TEXTURE_2D && - !((_mesa_is_cube_face(target) || target == GL_PROXY_TEXTURE_CUBE_MAP) && - (ctx->VersionMajor >= 3))) { - if (!isProxy) - _mesa_error(ctx, GL_INVALID_ENUM, - "glTexImage(target/internalFormat)"); - return GL_TRUE; - } - } - - /* additional checks for integer textures */ - if ((ctx->VersionMajor >= 3 || ctx->Extensions.EXT_texture_integer) && - (_mesa_is_integer_format(format) != - _mesa_is_integer_format(internalFormat))) { - if (!isProxy) { - _mesa_error(ctx, GL_INVALID_OPERATION, - "glTexImage%dD(integer/non-integer format mismatch)", - dimensions); - } - return GL_TRUE; - } - - if (!mutable_tex_object(ctx, target)) { - _mesa_error(ctx, GL_INVALID_OPERATION, - "glTexImage%dD(immutable texture)", dimensions); - return GL_TRUE; - } - - /* if we get here, the parameters are OK */ - return GL_FALSE; -} - - -/** - * Test glTexSubImage[123]D() parameters for errors. - * - * \param ctx GL context. - * \param dimensions texture image dimensions (must be 1, 2 or 3). - * \param target texture target given by the user. - * \param level image level given by the user. - * \param xoffset sub-image x offset given by the user. - * \param yoffset sub-image y offset given by the user. - * \param zoffset sub-image z offset given by the user. - * \param format pixel data format given by the user. - * \param type pixel data type given by the user. - * \param width image width given by the user. - * \param height image height given by the user. - * \param depth image depth given by the user. - * - * \return GL_TRUE if an error was detected, or GL_FALSE if no errors. - * - * Verifies each of the parameters against the constants specified in - * __struct gl_contextRec::Const and the supported extensions, and according - * to the OpenGL specification. - */ -static GLboolean -subtexture_error_check( struct gl_context *ctx, GLuint dimensions, - GLenum target, GLint level, - GLint xoffset, GLint yoffset, GLint zoffset, - GLint width, GLint height, GLint depth, - GLenum format, GLenum type ) -{ - GLenum err; - - /* Basic level check */ - if (level < 0 || level >= MAX_TEXTURE_LEVELS) { - _mesa_error(ctx, GL_INVALID_ENUM, "glTexSubImage2D(level=%d)", level); - return GL_TRUE; - } - - /* Check for negative sizes */ - if (width < 0) { - _mesa_error(ctx, GL_INVALID_VALUE, - "glTexSubImage%dD(width=%d)", dimensions, width); - return GL_TRUE; - } - if (height < 0 && dimensions > 1) { - _mesa_error(ctx, GL_INVALID_VALUE, - "glTexSubImage%dD(height=%d)", dimensions, height); - return GL_TRUE; - } - if (depth < 0 && dimensions > 2) { - _mesa_error(ctx, GL_INVALID_VALUE, - "glTexSubImage%dD(depth=%d)", dimensions, depth); - return GL_TRUE; - } - - err = _mesa_error_check_format_and_type(ctx, format, type); - if (err != GL_NO_ERROR) { - _mesa_error(ctx, err, - "glTexSubImage%dD(incompatible format 0x%x, type 0x%x)", - dimensions, format, type); - return GL_TRUE; - } - - return GL_FALSE; -} - - -/** - * Do second part of glTexSubImage which depends on the destination texture. - * \return GL_TRUE if error recorded, GL_FALSE otherwise - */ -static GLboolean -subtexture_error_check2( struct gl_context *ctx, GLuint dimensions, - GLenum target, GLint level, - GLint xoffset, GLint yoffset, GLint zoffset, - GLint width, GLint height, GLint depth, - GLenum format, GLenum type, - const struct gl_texture_image *destTex ) -{ - if (!destTex) { - /* undefined image level */ - _mesa_error(ctx, GL_INVALID_OPERATION, "glTexSubImage%dD", dimensions); - return GL_TRUE; - } - - if (xoffset < -((GLint)destTex->Border)) { - _mesa_error(ctx, GL_INVALID_VALUE, "glTexSubImage%dD(xoffset)", - dimensions); - return GL_TRUE; - } - if (xoffset + width > (GLint) (destTex->Width + destTex->Border)) { - _mesa_error(ctx, GL_INVALID_VALUE, "glTexSubImage%dD(xoffset+width)", - dimensions); - return GL_TRUE; - } - if (dimensions > 1) { - if (yoffset < -((GLint)destTex->Border)) { - _mesa_error(ctx, GL_INVALID_VALUE, "glTexSubImage%dD(yoffset)", - dimensions); - return GL_TRUE; - } - if (yoffset + height > (GLint) (destTex->Height + destTex->Border)) { - _mesa_error(ctx, GL_INVALID_VALUE, "glTexSubImage%dD(yoffset+height)", - dimensions); - return GL_TRUE; - } - } - - if (ctx->VersionMajor >= 3 || ctx->Extensions.EXT_texture_integer) { - /* both source and dest must be integer-valued, or neither */ - if (_mesa_is_format_integer_color(destTex->TexFormat) != - _mesa_is_integer_format(format)) { - _mesa_error(ctx, GL_INVALID_OPERATION, - "glTexSubImage%dD(integer/non-integer format mismatch)", - dimensions); - return GL_TRUE; - } - } - - return GL_FALSE; -} - - -/** - * Test glCopyTexImage[12]D() parameters for errors. - * - * \param ctx GL context. - * \param dimensions texture image dimensions (must be 1, 2 or 3). - * \param target texture target given by the user. - * \param level image level given by the user. - * \param internalFormat internal format given by the user. - * \param width image width given by the user. - * \param height image height given by the user. - * \param border texture border. - * - * \return GL_TRUE if an error was detected, or GL_FALSE if no errors. - * - * Verifies each of the parameters against the constants specified in - * __struct gl_contextRec::Const and the supported extensions, and according - * to the OpenGL specification. - */ -static GLboolean -copytexture_error_check( struct gl_context *ctx, GLuint dimensions, - GLenum target, GLint level, GLint internalFormat, - GLint width, GLint height, GLint border ) -{ - const GLenum proxyTarget = get_proxy_target(target); - const GLenum type = GL_FLOAT; - GLboolean sizeOK; - GLint baseFormat; - - /* check target */ - if (!legal_texsubimage_target(ctx, dimensions, target)) { - _mesa_error(ctx, GL_INVALID_ENUM, "glCopyTexImage%uD(target=%s)", - dimensions, _mesa_lookup_enum_by_nr(target)); - return GL_TRUE; - } - - /* Basic level check (more checking in ctx->Driver.TestProxyTexImage) */ - if (level < 0 || level >= MAX_TEXTURE_LEVELS) { - _mesa_error(ctx, GL_INVALID_VALUE, - "glCopyTexImage%dD(level=%d)", dimensions, level); - return GL_TRUE; - } - - /* Check border */ - if (border < 0 || border > 1) { - return GL_TRUE; - } - - baseFormat = _mesa_base_tex_format(ctx, internalFormat); - if (baseFormat < 0) { - _mesa_error(ctx, GL_INVALID_VALUE, - "glCopyTexImage%dD(internalFormat)", dimensions); - return GL_TRUE; - } - - if (!_mesa_source_buffer_exists(ctx, baseFormat)) { - _mesa_error(ctx, GL_INVALID_OPERATION, - "glCopyTexImage%dD(missing readbuffer)", dimensions); - return GL_TRUE; - } - - /* From the EXT_texture_integer spec: - * - * "INVALID_OPERATION is generated by CopyTexImage* and CopyTexSubImage* - * if the texture internalformat is an integer format and the read color - * buffer is not an integer format, or if the internalformat is not an - * integer format and the read color buffer is an integer format." - */ - if (_mesa_is_color_format(internalFormat)) { - struct gl_renderbuffer *rb = ctx->ReadBuffer->_ColorReadBuffer; - - if (_mesa_is_integer_format(rb->InternalFormat) != - _mesa_is_integer_format(internalFormat)) { - _mesa_error(ctx, GL_INVALID_OPERATION, - "glCopyTexImage%dD(integer vs non-integer)", dimensions); - return GL_TRUE; - } - } - - /* Do size, level checking */ - sizeOK = (proxyTarget == GL_PROXY_TEXTURE_CUBE_MAP_ARB) - ? (width == height) : 1; - - sizeOK = sizeOK && ctx->Driver.TestProxyTexImage(ctx, proxyTarget, level, - internalFormat, baseFormat, - type, width, height, - 1, border); - - if (!sizeOK) { - if (dimensions == 1) { - _mesa_error(ctx, GL_INVALID_VALUE, - "glCopyTexImage1D(width=%d)", width); - } - else { - ASSERT(dimensions == 2); - _mesa_error(ctx, GL_INVALID_VALUE, - "glCopyTexImage2D(width=%d, height=%d)", width, height); - } - return GL_TRUE; - } - - if (!mutable_tex_object(ctx, target)) { - _mesa_error(ctx, GL_INVALID_OPERATION, - "glCopyTexImage%dD(immutable texture)", dimensions); - return GL_TRUE; - } - - /* if we get here, the parameters are OK */ - return GL_FALSE; -} - - -/** - * Test glCopyTexSubImage[12]D() parameters for errors. - * Note that this is the first part of error checking. - * See also copytexsubimage_error_check2() below for the second part. - * - * \param ctx GL context. - * \param dimensions texture image dimensions (must be 1, 2 or 3). - * \param target texture target given by the user. - * \param level image level given by the user. - * - * \return GL_TRUE if an error was detected, or GL_FALSE if no errors. - */ -static GLboolean -copytexsubimage_error_check1( struct gl_context *ctx, GLuint dimensions, - GLenum target, GLint level) -{ - /* check target (proxies not allowed) */ - if (!legal_texsubimage_target(ctx, dimensions, target)) { - _mesa_error(ctx, GL_INVALID_ENUM, "glCopyTexSubImage%uD(target=%s)", - dimensions, _mesa_lookup_enum_by_nr(target)); - return GL_TRUE; - } - - /* Check level */ - if (level < 0 || level >= MAX_TEXTURE_LEVELS) { - _mesa_error(ctx, GL_INVALID_VALUE, - "glCopyTexSubImage%dD(level=%d)", dimensions, level); - return GL_TRUE; - } - - return GL_FALSE; -} - - -/** - * Second part of error checking for glCopyTexSubImage[12]D(). - * \param xoffset sub-image x offset given by the user. - * \param yoffset sub-image y offset given by the user. - * \param zoffset sub-image z offset given by the user. - * \param width image width given by the user. - * \param height image height given by the user. - */ -static GLboolean -copytexsubimage_error_check2( struct gl_context *ctx, GLuint dimensions, - GLenum target, GLint level, - GLint xoffset, GLint yoffset, GLint zoffset, - GLsizei width, GLsizei height, - const struct gl_texture_image *teximage ) -{ - /* check that dest tex image exists */ - if (!teximage) { - _mesa_error(ctx, GL_INVALID_OPERATION, - "glCopyTexSubImage%dD(undefined texture level: %d)", - dimensions, level); - return GL_TRUE; - } - - /* Check size */ - if (width < 0) { - _mesa_error(ctx, GL_INVALID_VALUE, - "glCopyTexSubImage%dD(width=%d)", dimensions, width); - return GL_TRUE; - } - if (dimensions > 1 && height < 0) { - _mesa_error(ctx, GL_INVALID_VALUE, - "glCopyTexSubImage%dD(height=%d)", dimensions, height); - return GL_TRUE; - } - - /* check x/y offsets */ - if (xoffset < -((GLint)teximage->Border)) { - _mesa_error(ctx, GL_INVALID_VALUE, - "glCopyTexSubImage%dD(xoffset=%d)", dimensions, xoffset); - return GL_TRUE; - } - if (xoffset + width > (GLint) (teximage->Width + teximage->Border)) { - _mesa_error(ctx, GL_INVALID_VALUE, - "glCopyTexSubImage%dD(xoffset+width)", dimensions); - return GL_TRUE; - } - if (dimensions > 1) { - if (yoffset < -((GLint)teximage->Border)) { - _mesa_error(ctx, GL_INVALID_VALUE, - "glCopyTexSubImage%dD(yoffset=%d)", dimensions, yoffset); - return GL_TRUE; - } - /* NOTE: we're adding the border here, not subtracting! */ - if (yoffset + height > (GLint) (teximage->Height + teximage->Border)) { - _mesa_error(ctx, GL_INVALID_VALUE, - "glCopyTexSubImage%dD(yoffset+height)", dimensions); - return GL_TRUE; - } - } - - /* check z offset */ - if (dimensions > 2) { - if (zoffset < -((GLint)teximage->Border)) { - _mesa_error(ctx, GL_INVALID_VALUE, - "glCopyTexSubImage%dD(zoffset)", dimensions); - return GL_TRUE; - } - if (zoffset > (GLint) (teximage->Depth + teximage->Border)) { - _mesa_error(ctx, GL_INVALID_VALUE, - "glCopyTexSubImage%dD(zoffset+depth)", dimensions); - return GL_TRUE; - } - } - - if (teximage->InternalFormat == GL_YCBCR_MESA) { - _mesa_error(ctx, GL_INVALID_OPERATION, "glCopyTexSubImage2D"); - return GL_TRUE; - } - - if (!_mesa_source_buffer_exists(ctx, teximage->_BaseFormat)) { - _mesa_error(ctx, GL_INVALID_OPERATION, - "glCopyTexSubImage%dD(missing readbuffer, format=0x%x)", - dimensions, teximage->_BaseFormat); - return GL_TRUE; - } - - /* From the EXT_texture_integer spec: - * - * "INVALID_OPERATION is generated by CopyTexImage* and CopyTexSubImage* - * if the texture internalformat is an integer format and the read color - * buffer is not an integer format, or if the internalformat is not an - * integer format and the read color buffer is an integer format." - */ - if (_mesa_is_color_format(teximage->InternalFormat)) { - struct gl_renderbuffer *rb = ctx->ReadBuffer->_ColorReadBuffer; - - if (_mesa_is_format_integer_color(rb->Format) != - _mesa_is_format_integer_color(teximage->TexFormat)) { - _mesa_error(ctx, GL_INVALID_OPERATION, - "glCopyTexImage%dD(integer vs non-integer)", dimensions); - return GL_TRUE; - } - } - - /* if we get here, the parameters are OK */ - return GL_FALSE; -} - - -/** Callback info for walking over FBO hash table */ -struct cb_info -{ - struct gl_context *ctx; - struct gl_texture_object *texObj; - GLuint level, face; -}; - -/** Debug helper: override the user-requested internal format */ -static GLenum -override_internal_format(GLenum internalFormat, GLint width, GLint height) -{ -#if 0 - if (internalFormat == GL_RGBA16F_ARB || - internalFormat == GL_RGBA32F_ARB) { - printf("Convert rgba float tex to int %d x %d\n", width, height); - return GL_RGBA; - } - else if (internalFormat == GL_RGB16F_ARB || - internalFormat == GL_RGB32F_ARB) { - printf("Convert rgb float tex to int %d x %d\n", width, height); - return GL_RGB; - } - else if (internalFormat == GL_LUMINANCE_ALPHA16F_ARB || - internalFormat == GL_LUMINANCE_ALPHA32F_ARB) { - printf("Convert luminance float tex to int %d x %d\n", width, height); - return GL_LUMINANCE_ALPHA; - } - else if (internalFormat == GL_LUMINANCE16F_ARB || - internalFormat == GL_LUMINANCE32F_ARB) { - printf("Convert luminance float tex to int %d x %d\n", width, height); - return GL_LUMINANCE; - } - else if (internalFormat == GL_ALPHA16F_ARB || - internalFormat == GL_ALPHA32F_ARB) { - printf("Convert luminance float tex to int %d x %d\n", width, height); - return GL_ALPHA; - } - else { - return internalFormat; - } -#else - return internalFormat; -#endif -} - - -/** - * Choose the actual hardware format for a texture image. - * Try to use the same format as the previous image level when possible. - * Otherwise, ask the driver for the best format. - * It's important to try to choose a consistant format for all levels - * for efficient texture memory layout/allocation. In particular, this - * comes up during automatic mipmap generation. - */ -gl_format -_mesa_choose_texture_format(struct gl_context *ctx, - struct gl_texture_object *texObj, - GLenum target, GLint level, - GLenum internalFormat, GLenum format, GLenum type) -{ - gl_format f; - - /* see if we've already chosen a format for the previous level */ - if (level > 0) { - struct gl_texture_image *prevImage = - _mesa_select_tex_image(ctx, texObj, target, level - 1); - /* See if the prev level is defined and has an internal format which - * matches the new internal format. - */ - if (prevImage && - prevImage->Width > 0 && - prevImage->InternalFormat == internalFormat) { - /* use the same format */ - ASSERT(prevImage->TexFormat != MESA_FORMAT_NONE); - return prevImage->TexFormat; - } - } - - /* choose format from scratch */ - f = ctx->Driver.ChooseTextureFormat(ctx, internalFormat, format, type); - ASSERT(f != MESA_FORMAT_NONE); - return f; -} - -/** - * Adjust pixel unpack params and image dimensions to strip off the - * texture border. - * - * Gallium and intel don't support texture borders. They've seldem been used - * and seldom been implemented correctly anyway. - * - * \param unpackNew returns the new pixel unpack parameters - */ -static void -strip_texture_border(GLint *border, - GLint *width, GLint *height, GLint *depth, - const struct gl_pixelstore_attrib *unpack, - struct gl_pixelstore_attrib *unpackNew) -{ - assert(*border > 0); /* sanity check */ - - *unpackNew = *unpack; - - if (unpackNew->RowLength == 0) - unpackNew->RowLength = *width; - - if (depth && unpackNew->ImageHeight == 0) - unpackNew->ImageHeight = *height; - - unpackNew->SkipPixels += *border; - if (height) - unpackNew->SkipRows += *border; - if (depth) - unpackNew->SkipImages += *border; - - assert(*width >= 3); - *width = *width - 2 * *border; - if (height && *height >= 3) - *height = *height - 2 * *border; - if (depth && *depth >= 3) - *depth = *depth - 2 * *border; - *border = 0; -} - -/** - * Common code to implement all the glTexImage1D/2D/3D functions. - */ -static void -teximage(struct gl_context *ctx, GLuint dims, - GLenum target, GLint level, GLint internalFormat, - GLsizei width, GLsizei height, GLsizei depth, - GLint border, GLenum format, GLenum type, - const GLvoid *pixels) -{ - GLboolean error; - struct gl_pixelstore_attrib unpack_no_border; - const struct gl_pixelstore_attrib *unpack = &ctx->Unpack; - - ASSERT_OUTSIDE_BEGIN_END_AND_FLUSH(ctx); - - if (MESA_VERBOSE & (VERBOSE_API|VERBOSE_TEXTURE)) - _mesa_debug(ctx, "glTexImage%uD %s %d %s %d %d %d %d %s %s %p\n", - dims, - _mesa_lookup_enum_by_nr(target), level, - _mesa_lookup_enum_by_nr(internalFormat), - width, height, depth, border, - _mesa_lookup_enum_by_nr(format), - _mesa_lookup_enum_by_nr(type), pixels); - - internalFormat = override_internal_format(internalFormat, width, height); - - /* target error checking */ - if (!legal_teximage_target(ctx, dims, target)) { - _mesa_error(ctx, GL_INVALID_ENUM, "glTexImage%uD(target=%s)", - dims, _mesa_lookup_enum_by_nr(target)); - return; - } - - /* general error checking */ - error = texture_error_check(ctx, dims, target, level, internalFormat, - format, type, width, height, depth, border); - - if (_mesa_is_proxy_texture(target)) { - /* Proxy texture: just clear or set state depending on error checking */ - struct gl_texture_image *texImage = - _mesa_get_proxy_tex_image(ctx, target, level); - - if (error) { - /* when error, clear all proxy texture image parameters */ - if (texImage) - clear_teximage_fields(texImage); - } - else { - /* no error, set the tex image parameters */ - struct gl_texture_object *texObj = - _mesa_select_tex_object(ctx, target); - gl_format texFormat = _mesa_choose_texture_format(ctx, texObj, - target, level, - internalFormat, - format, type); - - if (legal_texture_size(ctx, texFormat, width, height, depth)) { - _mesa_init_teximage_fields(ctx, texImage, width, height, - depth, border, internalFormat, - texFormat); - } - else if (texImage) { - clear_teximage_fields(texImage); - } - } - } - else { - /* non-proxy target */ - struct gl_texture_object *texObj; - struct gl_texture_image *texImage; - - if (error) { - return; /* error was recorded */ - } - - /* Allow a hardware driver to just strip out the border, to provide - * reliable but slightly incorrect hardware rendering instead of - * rarely-tested software fallback rendering. - */ - if (border && ctx->Const.StripTextureBorder) { - strip_texture_border(&border, &width, &height, &depth, unpack, - &unpack_no_border); - unpack = &unpack_no_border; - } - - if (ctx->NewState & _NEW_PIXEL) - _mesa_update_state(ctx); - - texObj = _mesa_select_tex_object(ctx, target); - - _mesa_lock_texture(ctx, texObj); - { - texImage = _mesa_get_tex_image(ctx, texObj, target, level); - - if (!texImage) { - _mesa_error(ctx, GL_OUT_OF_MEMORY, "glTexImage%uD", dims); - } - else { - gl_format texFormat; - - ctx->Driver.FreeTextureImageBuffer(ctx, texImage); - - texFormat = _mesa_choose_texture_format(ctx, texObj, target, level, - internalFormat, format, - type); - - if (legal_texture_size(ctx, texFormat, width, height, depth)) { - _mesa_init_teximage_fields(ctx, texImage, - width, height, depth, - border, internalFormat, texFormat); - - /* Give the texture to the driver. may be null. */ - switch (dims) { - case 1: - ctx->Driver.TexImage1D(ctx, texImage, internalFormat, - width, border, format, - type, pixels, unpack); - break; - case 2: - ctx->Driver.TexImage2D(ctx, texImage, internalFormat, - width, height, border, format, - type, pixels, unpack); - break; - default: - _mesa_problem(ctx, "invalid dims=%u in teximage()", dims); - } - - /* state update */ - texObj->_Complete = GL_FALSE; - ctx->NewState |= _NEW_TEXTURE; - } - else { - _mesa_error(ctx, GL_OUT_OF_MEMORY, "glTexImage%uD", dims); - } - } - } - _mesa_unlock_texture(ctx, texObj); - } -} - - -/* - * Called from the API. Note that width includes the border. - */ -void GLAPIENTRY -_mesa_TexImage1D( GLenum target, GLint level, GLint internalFormat, - GLsizei width, GLint border, GLenum format, - GLenum type, const GLvoid *pixels ) -{ - GET_CURRENT_CONTEXT(ctx); - teximage(ctx, 1, target, level, internalFormat, width, 1, 1, - border, format, type, pixels); -} - - -void GLAPIENTRY -_mesa_TexImage2D( GLenum target, GLint level, GLint internalFormat, - GLsizei width, GLsizei height, GLint border, - GLenum format, GLenum type, - const GLvoid *pixels ) -{ - GET_CURRENT_CONTEXT(ctx); - teximage(ctx, 2, target, level, internalFormat, width, height, 1, - border, format, type, pixels); -} - - -/** - * Implement all the glTexSubImage1/2/3D() functions. - */ -static void -texsubimage(struct gl_context *ctx, GLuint dims, GLenum target, GLint level, - GLint xoffset, GLint yoffset, GLint zoffset, - GLsizei width, GLsizei height, GLsizei depth, - GLenum format, GLenum type, const GLvoid *pixels ) -{ - struct gl_texture_object *texObj; - struct gl_texture_image *texImage; - - ASSERT_OUTSIDE_BEGIN_END_AND_FLUSH(ctx); - - if (MESA_VERBOSE & (VERBOSE_API|VERBOSE_TEXTURE)) - _mesa_debug(ctx, "glTexSubImage%uD %s %d %d %d %d %d %d %d %s %s %p\n", - dims, - _mesa_lookup_enum_by_nr(target), level, - xoffset, yoffset, zoffset, width, height, depth, - _mesa_lookup_enum_by_nr(format), - _mesa_lookup_enum_by_nr(type), pixels); - - /* check target (proxies not allowed) */ - if (!legal_texsubimage_target(ctx, dims, target)) { - _mesa_error(ctx, GL_INVALID_ENUM, "glTexSubImage%uD(target=%s)", - dims, _mesa_lookup_enum_by_nr(target)); - return; - } - - if (ctx->NewState & _NEW_PIXEL) - _mesa_update_state(ctx); - - if (subtexture_error_check(ctx, dims, target, level, xoffset, yoffset, zoffset, - width, height, depth, format, type)) { - return; /* error was detected */ - } - - texObj = _mesa_select_tex_object(ctx, target); - - _mesa_lock_texture(ctx, texObj); - { - texImage = _mesa_select_tex_image(ctx, texObj, target, level); - - if (subtexture_error_check2(ctx, dims, target, level, - xoffset, yoffset, zoffset, - width, height, depth, - format, type, texImage)) { - /* error was recorded */ - } - else if (width > 0 && height > 0 && depth > 0) { - /* If we have a border, offset=-1 is legal. Bias by border width. */ - switch (dims) { - case 3: - zoffset += texImage->Border; - /* fall-through */ - case 2: - yoffset += texImage->Border; - /* fall-through */ - case 1: - xoffset += texImage->Border; - } - - switch (dims) { - case 1: - ctx->Driver.TexSubImage1D(ctx, texImage, - xoffset, width, - format, type, pixels, &ctx->Unpack); - break; - case 2: - ctx->Driver.TexSubImage2D(ctx, texImage, - xoffset, yoffset, width, height, - format, type, pixels, &ctx->Unpack); - break; - default: - _mesa_problem(ctx, "unexpected dims in subteximage()"); - } - - ctx->NewState |= _NEW_TEXTURE; - } - } - _mesa_unlock_texture(ctx, texObj); -} - - -void GLAPIENTRY -_mesa_TexSubImage1D( GLenum target, GLint level, - GLint xoffset, GLsizei width, - GLenum format, GLenum type, - const GLvoid *pixels ) -{ - GET_CURRENT_CONTEXT(ctx); - texsubimage(ctx, 1, target, level, - xoffset, 0, 0, - width, 1, 1, - format, type, pixels); -} - - -void GLAPIENTRY -_mesa_TexSubImage2D( GLenum target, GLint level, - GLint xoffset, GLint yoffset, - GLsizei width, GLsizei height, - GLenum format, GLenum type, - const GLvoid *pixels ) -{ - GET_CURRENT_CONTEXT(ctx); - texsubimage(ctx, 2, target, level, - xoffset, yoffset, 0, - width, height, 1, - format, type, pixels); -} - - - -/** - * For glCopyTexSubImage, return the source renderbuffer to copy texel data - * from. This depends on whether the texture contains color or depth values. - */ -static struct gl_renderbuffer * -get_copy_tex_image_source(struct gl_context *ctx, gl_format texFormat) -{ - if (_mesa_get_format_bits(texFormat, GL_DEPTH_BITS) > 0) { - /* reading from depth/stencil buffer */ - return ctx->ReadBuffer->Attachment[BUFFER_DEPTH].Renderbuffer; - } - else { - /* copying from color buffer */ - return ctx->ReadBuffer->_ColorReadBuffer; - } -} - - - -/** - * Implement the glCopyTexImage1/2D() functions. - */ -static void -copyteximage(struct gl_context *ctx, GLuint dims, - GLenum target, GLint level, GLenum internalFormat, - GLint x, GLint y, GLsizei width, GLsizei height, GLint border ) -{ - struct gl_texture_object *texObj; - struct gl_texture_image *texImage; - - ASSERT_OUTSIDE_BEGIN_END_AND_FLUSH(ctx); - - if (MESA_VERBOSE & (VERBOSE_API|VERBOSE_TEXTURE)) - _mesa_debug(ctx, "glCopyTexImage%uD %s %d %s %d %d %d %d %d\n", - dims, - _mesa_lookup_enum_by_nr(target), level, - _mesa_lookup_enum_by_nr(internalFormat), - x, y, width, height, border); - - if (ctx->NewState & NEW_COPY_TEX_STATE) - _mesa_update_state(ctx); - - if (copytexture_error_check(ctx, dims, target, level, internalFormat, - width, height, border)) - return; - - texObj = _mesa_select_tex_object(ctx, target); - - if (border && ctx->Const.StripTextureBorder) { - x += border; - width -= border * 2; - if (dims == 2) { - y += border; - height -= border * 2; - } - border = 0; - } - - _mesa_lock_texture(ctx, texObj); - { - texImage = _mesa_get_tex_image(ctx, texObj, target, level); - - if (!texImage) { - _mesa_error(ctx, GL_OUT_OF_MEMORY, "glCopyTexImage%uD", dims); - } - else { - /* choose actual hw format */ - gl_format texFormat = _mesa_choose_texture_format(ctx, texObj, - target, level, - internalFormat, - GL_NONE, GL_NONE); - - if (legal_texture_size(ctx, texFormat, width, height, 1)) { - GLint srcX = x, srcY = y, dstX = 0, dstY = 0; - - /* Free old texture image */ - ctx->Driver.FreeTextureImageBuffer(ctx, texImage); - - _mesa_init_teximage_fields(ctx, texImage, width, height, 1, - border, internalFormat, texFormat); - - /* Allocate texture memory (no pixel data yet) */ - if (dims == 1) { - ctx->Driver.TexImage1D(ctx, texImage, internalFormat, - width, border, GL_NONE, GL_NONE, NULL, - &ctx->Unpack); - } - else { - ctx->Driver.TexImage2D(ctx, texImage, internalFormat, - width, height, border, GL_NONE, GL_NONE, - NULL, &ctx->Unpack); - } - - if (_mesa_clip_copytexsubimage(ctx, &dstX, &dstY, &srcX, &srcY, - &width, &height)) { - struct gl_renderbuffer *srcRb = - get_copy_tex_image_source(ctx, texImage->TexFormat); - - if (dims == 1) - ctx->Driver.CopyTexSubImage1D(ctx, texImage, dstX, - srcRb, srcX, srcY, width); - - else - ctx->Driver.CopyTexSubImage2D(ctx, texImage, dstX, dstY, - srcRb, srcX, srcY, width, height); - } - - /* state update */ - texObj->_Complete = GL_FALSE; - ctx->NewState |= _NEW_TEXTURE; - } - else { - /* probably too large of image */ - _mesa_error(ctx, GL_OUT_OF_MEMORY, "glCopyTexImage%uD", dims); - } - } - } - _mesa_unlock_texture(ctx, texObj); -} - - - -void GLAPIENTRY -_mesa_CopyTexImage1D( GLenum target, GLint level, - GLenum internalFormat, - GLint x, GLint y, - GLsizei width, GLint border ) -{ - GET_CURRENT_CONTEXT(ctx); - copyteximage(ctx, 1, target, level, internalFormat, x, y, width, 1, border); -} - - - -void GLAPIENTRY -_mesa_CopyTexImage2D( GLenum target, GLint level, GLenum internalFormat, - GLint x, GLint y, GLsizei width, GLsizei height, - GLint border ) -{ - GET_CURRENT_CONTEXT(ctx); - copyteximage(ctx, 2, target, level, internalFormat, - x, y, width, height, border); -} - - - -/** - * Implementation for glCopyTexSubImage1/2/3D() functions. - */ -static void -copytexsubimage(struct gl_context *ctx, GLuint dims, GLenum target, GLint level, - GLint xoffset, GLint yoffset, GLint zoffset, - GLint x, GLint y, GLsizei width, GLsizei height) -{ - struct gl_texture_object *texObj; - struct gl_texture_image *texImage; - - ASSERT_OUTSIDE_BEGIN_END_AND_FLUSH(ctx); - - if (MESA_VERBOSE & (VERBOSE_API|VERBOSE_TEXTURE)) - _mesa_debug(ctx, "glCopyTexSubImage%uD %s %d %d %d %d %d %d %d %d\n", - dims, - _mesa_lookup_enum_by_nr(target), - level, xoffset, yoffset, zoffset, x, y, width, height); - - if (ctx->NewState & NEW_COPY_TEX_STATE) - _mesa_update_state(ctx); - - if (copytexsubimage_error_check1(ctx, dims, target, level)) - return; - - texObj = _mesa_select_tex_object(ctx, target); - - _mesa_lock_texture(ctx, texObj); - { - texImage = _mesa_select_tex_image(ctx, texObj, target, level); - - if (copytexsubimage_error_check2(ctx, dims, target, level, xoffset, yoffset, - zoffset, width, height, texImage)) { - /* error was recored */ - } - else { - /* If we have a border, offset=-1 is legal. Bias by border width. */ - switch (dims) { - case 3: - zoffset += texImage->Border; - /* fall-through */ - case 2: - yoffset += texImage->Border; - /* fall-through */ - case 1: - xoffset += texImage->Border; - } - - if (_mesa_clip_copytexsubimage(ctx, &xoffset, &yoffset, &x, &y, - &width, &height)) { - struct gl_renderbuffer *srcRb = - get_copy_tex_image_source(ctx, texImage->TexFormat); - - switch (dims) { - case 1: - ctx->Driver.CopyTexSubImage1D(ctx, texImage, xoffset, - srcRb, x, y, width); - break; - case 2: - ctx->Driver.CopyTexSubImage2D(ctx, texImage, xoffset, yoffset, - srcRb, x, y, width, height); - break; - default: - _mesa_problem(ctx, "bad dims in copytexsubimage()"); - } - - ctx->NewState |= _NEW_TEXTURE; - } - } - } - _mesa_unlock_texture(ctx, texObj); -} - - -void GLAPIENTRY -_mesa_CopyTexSubImage1D( GLenum target, GLint level, - GLint xoffset, GLint x, GLint y, GLsizei width ) -{ - GET_CURRENT_CONTEXT(ctx); - copytexsubimage(ctx, 1, target, level, xoffset, 0, 0, x, y, width, 1); -} - - - -void GLAPIENTRY -_mesa_CopyTexSubImage2D( GLenum target, GLint level, - GLint xoffset, GLint yoffset, - GLint x, GLint y, GLsizei width, GLsizei height ) -{ - GET_CURRENT_CONTEXT(ctx); - copytexsubimage(ctx, 2, target, level, xoffset, yoffset, 0, x, y, - width, height); -} diff --git a/dll/opengl/mesa/main/teximage.h b/dll/opengl/mesa/main/teximage.h deleted file mode 100644 index c22171297dc..00000000000 --- a/dll/opengl/mesa/main/teximage.h +++ /dev/null @@ -1,205 +0,0 @@ -/** - * \file teximage.h - * Texture images manipulation functions. - */ - -/* - * Mesa 3-D graphics library - * Version: 6.5 - * - * Copyright (C) 1999-2005 Brian Paul All Rights Reserved. - * - * Permission is hereby granted, free of charge, to any person obtaining a - * copy of this software and associated documentation files (the "Software"), - * to deal in the Software without restriction, including without limitation - * the rights to use, copy, modify, merge, publish, distribute, sublicense, - * and/or sell copies of the Software, and to permit persons to whom the - * Software is furnished to do so, subject to the following conditions: - * - * The above copyright notice and this permission notice shall be included - * in all copies or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS - * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL - * BRIAN PAUL BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN - * AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN - * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. - */ - - -#ifndef TEXIMAGE_H -#define TEXIMAGE_H - - -#include "mtypes.h" -#include "formats.h" - - -/** Is the given value one of the 6 cube faces? */ -static inline GLboolean -_mesa_is_cube_face(GLenum target) -{ - return (target >= GL_TEXTURE_CUBE_MAP_POSITIVE_X_ARB && - target <= GL_TEXTURE_CUBE_MAP_NEGATIVE_Z_ARB); -} - -/** Is any of the dimensions of given texture equal to zero? */ -static inline GLboolean -_mesa_is_zero_size_texture(const struct gl_texture_image *texImage) -{ - return (texImage->Width == 0 || - texImage->Height == 0 || - texImage->Depth == 0); -} - -/** \name Internal functions */ -/*@{*/ - -extern GLint -_mesa_base_tex_format( struct gl_context *ctx, GLint internalFormat ); - - -extern GLboolean -_mesa_is_proxy_texture(GLenum target); - - -extern struct gl_texture_image * -_mesa_new_texture_image( struct gl_context *ctx ); - - -extern void -_mesa_delete_texture_image( struct gl_context *ctx, - struct gl_texture_image *teximage ); - - -extern void -_mesa_init_teximage_fields(struct gl_context *ctx, - struct gl_texture_image *img, - GLsizei width, GLsizei height, GLsizei depth, - GLint border, GLenum internalFormat, - gl_format format); - - -extern gl_format -_mesa_choose_texture_format(struct gl_context *ctx, - struct gl_texture_object *texObj, - GLenum target, GLint level, - GLenum internalFormat, GLenum format, GLenum type); - -extern void -_mesa_clear_texture_image(struct gl_context *ctx, - struct gl_texture_image *texImage); - - -extern struct gl_texture_object * -_mesa_select_tex_object(struct gl_context *ctx, - GLenum target); - - -extern struct gl_texture_image * -_mesa_select_tex_image(struct gl_context *ctx, - const struct gl_texture_object *texObj, - GLenum target, GLint level); - - -extern struct gl_texture_image * -_mesa_get_tex_image(struct gl_context *ctx, struct gl_texture_object *texObj, - GLenum target, GLint level); - - -extern struct gl_texture_image * -_mesa_get_proxy_tex_image(struct gl_context *ctx, GLenum target, GLint level); - - -extern GLint -_mesa_max_texture_levels(struct gl_context *ctx, GLenum target); - - -extern GLboolean -_mesa_test_proxy_teximage(struct gl_context *ctx, GLenum target, GLint level, - GLint internalFormat, GLenum format, GLenum type, - GLint width, GLint height, GLint depth, GLint border); - - -extern GLuint -_mesa_tex_target_to_face(GLenum target); - -extern GLint -_mesa_get_texture_dimensions(GLenum target); - -/** - * Lock a texture for updating. See also _mesa_lock_context_textures(). - */ -static inline void -_mesa_lock_texture(struct gl_context *ctx, struct gl_texture_object *texObj) -{ - _glthread_LOCK_MUTEX(ctx->Shared->TexMutex); - ctx->Shared->TextureStateStamp++; - (void) texObj; -} - -static inline void -_mesa_unlock_texture(struct gl_context *ctx, struct gl_texture_object *texObj) -{ - (void) texObj; - _glthread_UNLOCK_MUTEX(ctx->Shared->TexMutex); -} - -/*@}*/ - - -/** \name API entry point functions */ -/*@{*/ - -extern void GLAPIENTRY -_mesa_TexImage1D( GLenum target, GLint level, GLint internalformat, - GLsizei width, GLint border, - GLenum format, GLenum type, const GLvoid *pixels ); - - -extern void GLAPIENTRY -_mesa_TexImage2D( GLenum target, GLint level, GLint internalformat, - GLsizei width, GLsizei height, GLint border, - GLenum format, GLenum type, const GLvoid *pixels ); - - -extern void GLAPIENTRY -_mesa_TexSubImage1D( GLenum target, GLint level, GLint xoffset, - GLsizei width, - GLenum format, GLenum type, - const GLvoid *pixels ); - - -extern void GLAPIENTRY -_mesa_TexSubImage2D( GLenum target, GLint level, - GLint xoffset, GLint yoffset, - GLsizei width, GLsizei height, - GLenum format, GLenum type, - const GLvoid *pixels ); - - -extern void GLAPIENTRY -_mesa_CopyTexImage1D( GLenum target, GLint level, GLenum internalformat, - GLint x, GLint y, GLsizei width, GLint border ); - - -extern void GLAPIENTRY -_mesa_CopyTexImage2D( GLenum target, GLint level, - GLenum internalformat, GLint x, GLint y, - GLsizei width, GLsizei height, GLint border ); - - -extern void GLAPIENTRY -_mesa_CopyTexSubImage1D( GLenum target, GLint level, GLint xoffset, - GLint x, GLint y, GLsizei width ); - - -extern void GLAPIENTRY -_mesa_CopyTexSubImage2D( GLenum target, GLint level, - GLint xoffset, GLint yoffset, - GLint x, GLint y, GLsizei width, GLsizei height ); - -/*@}*/ - -#endif diff --git a/dll/opengl/mesa/main/texobj.c b/dll/opengl/mesa/main/texobj.c deleted file mode 100644 index a0c7c97f869..00000000000 --- a/dll/opengl/mesa/main/texobj.c +++ /dev/null @@ -1,1073 +0,0 @@ -/** - * \file texobj.c - * Texture object management. - */ - -/* - * Mesa 3-D graphics library - * Version: 7.1 - * - * Copyright (C) 1999-2007 Brian Paul All Rights Reserved. - * - * Permission is hereby granted, free of charge, to any person obtaining a - * copy of this software and associated documentation files (the "Software"), - * to deal in the Software without restriction, including without limitation - * the rights to use, copy, modify, merge, publish, distribute, sublicense, - * and/or sell copies of the Software, and to permit persons to whom the - * Software is furnished to do so, subject to the following conditions: - * - * The above copyright notice and this permission notice shall be included - * in all copies or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS - * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL - * BRIAN PAUL BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN - * AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN - * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. - */ - -#include - -/**********************************************************************/ -/** \name Internal functions */ -/*@{*/ - - -/** - * Return the gl_texture_object for a given ID. - */ -struct gl_texture_object * -_mesa_lookup_texture(struct gl_context *ctx, GLuint id) -{ - return (struct gl_texture_object *) - _mesa_HashLookup(ctx->Shared->TexObjects, id); -} - - - -/** - * Allocate and initialize a new texture object. But don't put it into the - * texture object hash table. - * - * Called via ctx->Driver.NewTextureObject, unless overridden by a device - * driver. - * - * \param shared the shared GL state structure to contain the texture object - * \param name integer name for the texture object - * \param target either GL_TEXTURE_1D, GL_TEXTURE_2D, GL_TEXTURE_3D, - * GL_TEXTURE_CUBE_MAP_ARB or GL_TEXTURE_RECTANGLE_NV. zero is ok for the sake - * of GenTextures() - * - * \return pointer to new texture object. - */ -struct gl_texture_object * -_mesa_new_texture_object( struct gl_context *ctx, GLuint name, GLenum target ) -{ - struct gl_texture_object *obj; - (void) ctx; - obj = MALLOC_STRUCT(gl_texture_object); - _mesa_initialize_texture_object(obj, name, target); - return obj; -} - - -/** - * Initialize a new texture object to default values. - * \param obj the texture object - * \param name the texture name - * \param target the texture target - */ -void -_mesa_initialize_texture_object( struct gl_texture_object *obj, - GLuint name, GLenum target ) -{ - ASSERT(target == 0 || - target == GL_TEXTURE_1D || - target == GL_TEXTURE_2D || - target == GL_TEXTURE_3D || - target == GL_TEXTURE_CUBE_MAP_ARB); - - memset(obj, 0, sizeof(*obj)); - /* init the non-zero fields */ - _glthread_INIT_MUTEX(obj->Mutex); - obj->RefCount = 1; - obj->Name = name; - obj->Target = target; - obj->Priority = 1.0F; - obj->BaseLevel = 0; - obj->MaxLevel = 1000; - - /* sampler state */ - obj->Sampler.WrapS = GL_REPEAT; - obj->Sampler.WrapT = GL_REPEAT; - obj->Sampler.WrapR = GL_REPEAT; - obj->Sampler.MinFilter = GL_NEAREST_MIPMAP_LINEAR; - - obj->Sampler.MagFilter = GL_LINEAR; - obj->Sampler.MaxAnisotropy = 1.0; -} - - -/** - * Deallocate a texture object struct. It should have already been - * removed from the texture object pool. - * Called via ctx->Driver.DeleteTexture() if not overriden by a driver. - * - * \param shared the shared GL state to which the object belongs. - * \param texObj the texture object to delete. - */ -void -_mesa_delete_texture_object(struct gl_context *ctx, - struct gl_texture_object *texObj) -{ - GLuint i, face; - - /* Set Target to an invalid value. With some assertions elsewhere - * we can try to detect possible use of deleted textures. - */ - texObj->Target = 0x99; - - /* free the texture images */ - for (face = 0; face < 6; face++) { - for (i = 0; i < MAX_TEXTURE_LEVELS; i++) { - if (texObj->Image[face][i]) { - ctx->Driver.DeleteTextureImage(ctx, texObj->Image[face][i]); - } - } - } - - /* destroy the mutex -- it may have allocated memory (eg on bsd) */ - _glthread_DESTROY_MUTEX(texObj->Mutex); - - /* free this object */ - free(texObj); -} - - - -/** - * Copy texture object state from one texture object to another. - * Use for glPush/PopAttrib. - * - * \param dest destination texture object. - * \param src source texture object. - */ -void -_mesa_copy_texture_object( struct gl_texture_object *dest, - const struct gl_texture_object *src ) -{ - dest->Target = src->Target; - dest->Name = src->Name; - dest->Priority = src->Priority; - dest->Sampler.BorderColor.f[0] = src->Sampler.BorderColor.f[0]; - dest->Sampler.BorderColor.f[1] = src->Sampler.BorderColor.f[1]; - dest->Sampler.BorderColor.f[2] = src->Sampler.BorderColor.f[2]; - dest->Sampler.BorderColor.f[3] = src->Sampler.BorderColor.f[3]; - dest->Sampler.WrapS = src->Sampler.WrapS; - dest->Sampler.WrapT = src->Sampler.WrapT; - dest->Sampler.WrapR = src->Sampler.WrapR; - dest->Sampler.MinFilter = src->Sampler.MinFilter; - dest->Sampler.MagFilter = src->Sampler.MagFilter; - dest->BaseLevel = src->BaseLevel; - dest->MaxLevel = src->MaxLevel; - dest->Sampler.MaxAnisotropy = src->Sampler.MaxAnisotropy; - dest->_MaxLevel = src->_MaxLevel; - dest->_MaxLambda = src->_MaxLambda; - dest->_Complete = src->_Complete; -} - - -/** - * Free all texture images of the given texture object. - * - * \param ctx GL context. - * \param t texture object. - * - * \sa _mesa_clear_texture_image(). - */ -void -_mesa_clear_texture_object(struct gl_context *ctx, - struct gl_texture_object *texObj) -{ - GLuint i, j; - - if (texObj->Target == 0) - return; - - for (i = 0; i < MAX_FACES; i++) { - for (j = 0; j < MAX_TEXTURE_LEVELS; j++) { - struct gl_texture_image *texImage = texObj->Image[i][j]; - if (texImage) - _mesa_clear_texture_image(ctx, texImage); - } - } -} - - -/** - * Check if the given texture object is valid by examining its Target field. - * For debugging only. - */ -static GLboolean -valid_texture_object(const struct gl_texture_object *tex) -{ - switch (tex->Target) { - case 0: - case GL_TEXTURE_1D: - case GL_TEXTURE_2D: - case GL_TEXTURE_CUBE_MAP_ARB: - return GL_TRUE; - case 0x99: - _mesa_problem(NULL, "invalid reference to a deleted texture object"); - return GL_FALSE; - default: - _mesa_problem(NULL, "invalid texture object Target 0x%x, Id = %u", - tex->Target, tex->Name); - return GL_FALSE; - } -} - - -/** - * Reference (or unreference) a texture object. - * If '*ptr', decrement *ptr's refcount (and delete if it becomes zero). - * If 'tex' is non-null, increment its refcount. - * This is normally only called from the _mesa_reference_texobj() macro - * when there's a real pointer change. - */ -void -_mesa_reference_texobj_(struct gl_texture_object **ptr, - struct gl_texture_object *tex) -{ - assert(ptr); - - if (*ptr) { - /* Unreference the old texture */ - GLboolean deleteFlag = GL_FALSE; - struct gl_texture_object *oldTex = *ptr; - - ASSERT(valid_texture_object(oldTex)); - (void) valid_texture_object; /* silence warning in release builds */ - - _glthread_LOCK_MUTEX(oldTex->Mutex); - ASSERT(oldTex->RefCount > 0); - oldTex->RefCount--; - - deleteFlag = (oldTex->RefCount == 0); - _glthread_UNLOCK_MUTEX(oldTex->Mutex); - - if (deleteFlag) { - GET_CURRENT_CONTEXT(ctx); - if (ctx) - ctx->Driver.DeleteTexture(ctx, oldTex); - else - _mesa_problem(NULL, "Unable to delete texture, no context"); - } - - *ptr = NULL; - } - assert(!*ptr); - - if (tex) { - /* reference new texture */ - ASSERT(valid_texture_object(tex)); - _glthread_LOCK_MUTEX(tex->Mutex); - if (tex->RefCount == 0) { - /* this texture's being deleted (look just above) */ - /* Not sure this can every really happen. Warn if it does. */ - _mesa_problem(NULL, "referencing deleted texture object"); - *ptr = NULL; - } - else { - tex->RefCount++; - *ptr = tex; - } - _glthread_UNLOCK_MUTEX(tex->Mutex); - } -} - - - -/** - * Mark a texture object as incomplete. - * \param t texture object - * \param fmt... string describing why it's incomplete (for debugging). - */ -static void -incomplete(struct gl_texture_object *t, const char *fmt, ...) -{ -#if 0 - va_list args; - char s[100]; - - va_start(args, fmt); - vsnprintf(s, sizeof(s), fmt, args); - va_end(args); - - printf("Texture Obj %d incomplete because: %s\n", t->Name, s); -#endif - t->_Complete = GL_FALSE; -} - - -/** - * Examine a texture object to determine if it is complete. - * - * The gl_texture_object::Complete flag will be set to GL_TRUE or GL_FALSE - * accordingly. - * - * \param ctx GL context. - * \param t texture object. - * - * According to the texture target, verifies that each of the mipmaps is - * present and has the expected size. - */ -void -_mesa_test_texobj_completeness( const struct gl_context *ctx, - struct gl_texture_object *t ) -{ - const GLint baseLevel = t->BaseLevel; - GLint maxLog2 = 0, maxLevels = 0; - - t->_Complete = GL_TRUE; /* be optimistic */ - - /* Detect cases where the application set the base level to an invalid - * value. - */ - if ((baseLevel < 0) || (baseLevel >= MAX_TEXTURE_LEVELS)) { - incomplete(t, "base level = %d is invalid", baseLevel); - return; - } - - /* Always need the base level image */ - if (!t->Image[0][baseLevel]) { - incomplete(t, "Image[baseLevel=%d] == NULL", baseLevel); - return; - } - - /* Check width/height/depth for zero */ - if (t->Image[0][baseLevel]->Width == 0 || - t->Image[0][baseLevel]->Height == 0 || - t->Image[0][baseLevel]->Depth == 0) { - incomplete(t, "texture width = 0"); - return; - } - - /* Compute _MaxLevel */ - if (t->Target == GL_TEXTURE_1D) { - maxLog2 = t->Image[0][baseLevel]->WidthLog2; - maxLevels = ctx->Const.MaxTextureLevels; - } - else if (t->Target == GL_TEXTURE_2D) { - maxLog2 = MAX2(t->Image[0][baseLevel]->WidthLog2, - t->Image[0][baseLevel]->HeightLog2); - maxLevels = ctx->Const.MaxTextureLevels; - } - else if (t->Target == GL_TEXTURE_CUBE_MAP_ARB) { - maxLog2 = MAX2(t->Image[0][baseLevel]->WidthLog2, - t->Image[0][baseLevel]->HeightLog2); - maxLevels = ctx->Const.MaxCubeTextureLevels; - } - else { - _mesa_problem(ctx, "Bad t->Target in _mesa_test_texobj_completeness"); - return; - } - - ASSERT(maxLevels > 0); - - if (t->MaxLevel < t->BaseLevel) { - incomplete(t, "MAX_LEVEL (%d) < BASE_LEVEL (%d)", - t->MaxLevel, t->BaseLevel); - return; - } - - t->_MaxLevel = baseLevel + maxLog2; - t->_MaxLevel = MIN2(t->_MaxLevel, t->MaxLevel); - t->_MaxLevel = MIN2(t->_MaxLevel, maxLevels - 1); - - /* Compute _MaxLambda = q - b (see the 1.2 spec) used during mipmapping */ - t->_MaxLambda = (GLfloat) (t->_MaxLevel - t->BaseLevel); - - if (t->Immutable) { - /* This texture object was created with glTexStorage1/2/3D() so we - * know that all the mipmap levels are the right size and all cube - * map faces are the same size. - * We don't need to do any of the additional checks below. - */ - return; - } - - if (t->Target == GL_TEXTURE_CUBE_MAP_ARB) { - /* make sure that all six cube map level 0 images are the same size */ - const GLuint w = t->Image[0][baseLevel]->Width2; - const GLuint h = t->Image[0][baseLevel]->Height2; - GLuint face; - for (face = 1; face < 6; face++) { - if (t->Image[face][baseLevel] == NULL || - t->Image[face][baseLevel]->Width2 != w || - t->Image[face][baseLevel]->Height2 != h) { - incomplete(t, "Cube face missing or mismatched size"); - return; - } - } - } - - /* extra checking for mipmaps */ - if (t->Sampler.MinFilter != GL_NEAREST && t->Sampler.MinFilter != GL_LINEAR) { - /* - * Mipmapping: determine if we have a complete set of mipmaps - */ - GLint i; - GLint minLevel = baseLevel; - GLint maxLevel = t->_MaxLevel; - - if (minLevel > maxLevel) { - incomplete(t, "minLevel > maxLevel"); - return; - } - - /* Test dimension-independent attributes */ - for (i = minLevel; i <= maxLevel; i++) { - if (t->Image[0][i]) { - if (t->Image[0][i]->TexFormat != t->Image[0][baseLevel]->TexFormat) { - incomplete(t, "Format[i] != Format[baseLevel]"); - return; - } - if (t->Image[0][i]->Border != t->Image[0][baseLevel]->Border) { - incomplete(t, "Border[i] != Border[baseLevel]"); - return; - } - } - } - - /* Test things which depend on number of texture image dimensions */ - if (t->Target == GL_TEXTURE_1D) { - /* Test 1-D mipmaps */ - GLuint width = t->Image[0][baseLevel]->Width2; - for (i = baseLevel + 1; i < maxLevels; i++) { - if (width > 1) { - width /= 2; - } - if (i >= minLevel && i <= maxLevel) { - const struct gl_texture_image *img = t->Image[0][i]; - if (!img) { - incomplete(t, "1D Image[%d] is missing", i); - return; - } - if (img->Width2 != width ) { - incomplete(t, "1D Image[%d] bad width %u", i, img->Width2); - return; - } - } - if (width == 1) { - return; /* found smallest needed mipmap, all done! */ - } - } - } - else if (t->Target == GL_TEXTURE_2D) { - /* Test 2-D mipmaps */ - GLuint width = t->Image[0][baseLevel]->Width2; - GLuint height = t->Image[0][baseLevel]->Height2; - for (i = baseLevel + 1; i < maxLevels; i++) { - if (width > 1) { - width /= 2; - } - if (height > 1) { - height /= 2; - } - if (i >= minLevel && i <= maxLevel) { - const struct gl_texture_image *img = t->Image[0][i]; - if (!img) { - incomplete(t, "2D Image[%d of %d] is missing", i, maxLevel); - return; - } - if (img->Width2 != width) { - incomplete(t, "2D Image[%d] bad width %u", i, img->Width2); - return; - } - if (img->Height2 != height) { - incomplete(t, "2D Image[i] bad height %u", i, img->Height2); - return; - } - if (width==1 && height==1) { - return; /* found smallest needed mipmap, all done! */ - } - } - } - } - else if (t->Target == GL_TEXTURE_CUBE_MAP_ARB) { - /* make sure 6 cube faces are consistant */ - GLuint width = t->Image[0][baseLevel]->Width2; - GLuint height = t->Image[0][baseLevel]->Height2; - for (i = baseLevel + 1; i < maxLevels; i++) { - if (width > 1) { - width /= 2; - } - if (height > 1) { - height /= 2; - } - if (i >= minLevel && i <= maxLevel) { - GLuint face; - for (face = 0; face < 6; face++) { - /* check that we have images defined */ - if (!t->Image[face][i]) { - incomplete(t, "CubeMap Image[n][i] == NULL"); - return; - } - /* Don't support GL_DEPTH_COMPONENT for cube maps */ - if (ctx->VersionMajor < 3) { - if (t->Image[face][i]->_BaseFormat == GL_DEPTH_COMPONENT) { - incomplete(t, "GL_DEPTH_COMPONENT only works with 1/2D tex"); - return; - } - } - /* check that all six images have same size */ - if (t->Image[face][i]->Width2 != width || - t->Image[face][i]->Height2 != height) { - incomplete(t, "CubeMap Image[n][i] bad size"); - return; - } - } - } - if (width == 1 && height == 1) { - return; /* found smallest needed mipmap, all done! */ - } - } - } - else { - /* Target = ??? */ - _mesa_problem(ctx, "Bug in gl_test_texture_object_completeness\n"); - } - } -} - - -/** - * Check if the given cube map texture is "cube complete" as defined in - * the OpenGL specification. - */ -GLboolean -_mesa_cube_complete(const struct gl_texture_object *texObj) -{ - const GLint baseLevel = texObj->BaseLevel; - const struct gl_texture_image *img0, *img; - GLuint face; - - if (texObj->Target != GL_TEXTURE_CUBE_MAP) - return GL_FALSE; - - if ((baseLevel < 0) || (baseLevel >= MAX_TEXTURE_LEVELS)) - return GL_FALSE; - - /* check first face */ - img0 = texObj->Image[0][baseLevel]; - if (!img0 || - img0->Width < 1 || - img0->Width != img0->Height) - return GL_FALSE; - - /* check remaining faces vs. first face */ - for (face = 1; face < 6; face++) { - img = texObj->Image[face][baseLevel]; - if (!img || - img->Width != img0->Width || - img->Height != img0->Height || - img->TexFormat != img0->TexFormat) - return GL_FALSE; - } - - return GL_TRUE; -} - - -/** - * Mark a texture object dirty. It forces the object to be incomplete - * and optionally forces the context to re-validate its state. - * - * \param ctx GL context. - * \param texObj texture object. - * \param invalidate_state also invalidate context state. - */ -void -_mesa_dirty_texobj(struct gl_context *ctx, struct gl_texture_object *texObj, - GLboolean invalidate_state) -{ - texObj->_Complete = GL_FALSE; - if (invalidate_state) - ctx->NewState |= _NEW_TEXTURE; -} - - -/** - * Return pointer to a default/fallback texture. - * The texture is a 2D 8x8 RGBA texture with all texels = (0,0,0,1). - * That's the value a sampler should get when sampling from an - * incomplete texture. - */ -struct gl_texture_object * -_mesa_get_fallback_texture(struct gl_context *ctx) -{ - if (!ctx->Shared->FallbackTex) { - /* create fallback texture now */ - static GLubyte texels[8 * 8][4]; - struct gl_texture_object *texObj; - struct gl_texture_image *texImage; - gl_format texFormat; - GLuint i; - - for (i = 0; i < 8 * 8; i++) { - texels[i][0] = - texels[i][1] = - texels[i][2] = 0x0; - texels[i][3] = 0xff; - } - - /* create texture object */ - texObj = ctx->Driver.NewTextureObject(ctx, 0, GL_TEXTURE_2D); - assert(texObj->RefCount == 1); - texObj->Sampler.MinFilter = GL_NEAREST; - texObj->Sampler.MagFilter = GL_NEAREST; - - /* create level[0] texture image */ - texImage = _mesa_get_tex_image(ctx, texObj, GL_TEXTURE_2D, 0); - - texFormat = ctx->Driver.ChooseTextureFormat(ctx, GL_RGBA, GL_RGBA, - GL_UNSIGNED_BYTE); - - /* init the image fields */ - _mesa_init_teximage_fields(ctx, texImage, - 8, 8, 1, 0, GL_RGBA, texFormat); - - ASSERT(texImage->TexFormat != MESA_FORMAT_NONE); - - /* set image data */ - ctx->Driver.TexImage2D(ctx, texImage, GL_RGBA, - 8, 8, 0, - GL_RGBA, GL_UNSIGNED_BYTE, texels, - &ctx->DefaultPacking); - - _mesa_test_texobj_completeness(ctx, texObj); - assert(texObj->_Complete); - - ctx->Shared->FallbackTex = texObj; - } - return ctx->Shared->FallbackTex; -} - - -/*@}*/ - - -/***********************************************************************/ -/** \name API functions */ -/*@{*/ - - -/** - * Generate texture names. - * - * \param n number of texture names to be generated. - * \param textures an array in which will hold the generated texture names. - * - * \sa glGenTextures(). - * - * Calls _mesa_HashFindFreeKeyBlock() to find a block of free texture - * IDs which are stored in \p textures. Corresponding empty texture - * objects are also generated. - */ -void GLAPIENTRY -_mesa_GenTextures( GLsizei n, GLuint *textures ) -{ - GET_CURRENT_CONTEXT(ctx); - GLuint first; - GLint i; - ASSERT_OUTSIDE_BEGIN_END(ctx); - - if (n < 0) { - _mesa_error( ctx, GL_INVALID_VALUE, "glGenTextures" ); - return; - } - - if (!textures) - return; - - /* - * This must be atomic (generation and allocation of texture IDs) - */ - _glthread_LOCK_MUTEX(ctx->Shared->Mutex); - - first = _mesa_HashFindFreeKeyBlock(ctx->Shared->TexObjects, n); - - /* Allocate new, empty texture objects */ - for (i = 0; i < n; i++) { - struct gl_texture_object *texObj; - GLuint name = first + i; - GLenum target = 0; - texObj = ctx->Driver.NewTextureObject(ctx, name, target); - if (!texObj) { - _glthread_UNLOCK_MUTEX(ctx->Shared->Mutex); - _mesa_error(ctx, GL_OUT_OF_MEMORY, "glGenTextures"); - return; - } - - /* insert into hash table */ - _mesa_HashInsert(ctx->Shared->TexObjects, texObj->Name, texObj); - - textures[i] = name; - } - - _glthread_UNLOCK_MUTEX(ctx->Shared->Mutex); -} - -/** - * Check if the given texture object is bound to any texture image units and - * unbind it if so (revert to default textures). - */ -static void -unbind_texobj_from_texunits(struct gl_context *ctx, - struct gl_texture_object *texObj) -{ - GLuint tex; - struct gl_texture_unit *unit = &ctx->Texture.Unit; - for (tex = 0; tex < NUM_TEXTURE_TARGETS; tex++) { - if (texObj == unit->CurrentTex[tex]) { - _mesa_reference_texobj(&unit->CurrentTex[tex], - ctx->Shared->DefaultTex[tex]); - ASSERT(unit->CurrentTex[tex]); - break; - } - } -} - - -/** - * Delete named textures. - * - * \param n number of textures to be deleted. - * \param textures array of texture IDs to be deleted. - * - * \sa glDeleteTextures(). - * - * If we're about to delete a texture that's currently bound to any - * texture unit, unbind the texture first. Decrement the reference - * count on the texture object and delete it if it's zero. - * Recall that texture objects can be shared among several rendering - * contexts. - */ -void GLAPIENTRY -_mesa_DeleteTextures( GLsizei n, const GLuint *textures) -{ - GET_CURRENT_CONTEXT(ctx); - GLint i; - ASSERT_OUTSIDE_BEGIN_END_AND_FLUSH(ctx); /* too complex */ - - if (!textures) - return; - - for (i = 0; i < n; i++) { - if (textures[i] > 0) { - struct gl_texture_object *delObj - = _mesa_lookup_texture(ctx, textures[i]); - - if (delObj) { - _mesa_lock_texture(ctx, delObj); - - /* Check if this texture is currently bound to any texture units. - * If so, unbind it. - */ - unbind_texobj_from_texunits(ctx, delObj); - - _mesa_unlock_texture(ctx, delObj); - - ctx->NewState |= _NEW_TEXTURE; - - /* The texture _name_ is now free for re-use. - * Remove it from the hash table now. - */ - _glthread_LOCK_MUTEX(ctx->Shared->Mutex); - _mesa_HashRemove(ctx->Shared->TexObjects, delObj->Name); - _glthread_UNLOCK_MUTEX(ctx->Shared->Mutex); - - /* Unreference the texobj. If refcount hits zero, the texture - * will be deleted. - */ - _mesa_reference_texobj(&delObj, NULL); - } - } - } -} - - -/** - * Convert a GL texture target enum such as GL_TEXTURE_2D or GL_TEXTURE_3D - * into the corresponding Mesa texture target index. - * Note that proxy targets are not valid here. - * \return TEXTURE_x_INDEX or -1 if target is invalid - */ -static GLint -target_enum_to_index(GLenum target) -{ - switch (target) { - case GL_TEXTURE_1D: - return TEXTURE_1D_INDEX; - case GL_TEXTURE_2D: - return TEXTURE_2D_INDEX; - case GL_TEXTURE_CUBE_MAP_ARB: - return TEXTURE_CUBE_INDEX; - default: - return -1; - } -} - - -/** - * Bind a named texture to a texturing target. - * - * \param target texture target. - * \param texName texture name. - * - * \sa glBindTexture(). - * - * Determines the old texture object bound and returns immediately if rebinding - * the same texture. Get the current texture which is either a default texture - * if name is null, a named texture from the hash, or a new texture if the - * given texture name is new. Increments its reference count, binds it, and - * calls dd_function_table::BindTexture. Decrements the old texture reference - * count and deletes it if it reaches zero. - */ -void GLAPIENTRY -_mesa_BindTexture( GLenum target, GLuint texName ) -{ - GET_CURRENT_CONTEXT(ctx); - struct gl_texture_unit *texUnit = &ctx->Texture.Unit; - struct gl_texture_object *newTexObj = NULL; - GLint targetIndex; - ASSERT_OUTSIDE_BEGIN_END(ctx); - - if (MESA_VERBOSE & (VERBOSE_API|VERBOSE_TEXTURE)) - _mesa_debug(ctx, "glBindTexture %s %d\n", - _mesa_lookup_enum_by_nr(target), (GLint) texName); - - targetIndex = target_enum_to_index(target); - if (targetIndex < 0) { - _mesa_error(ctx, GL_INVALID_ENUM, "glBindTexture(target)"); - return; - } - assert(targetIndex < NUM_TEXTURE_TARGETS); - - /* - * Get pointer to new texture object (newTexObj) - */ - if (texName == 0) { - /* Use a default texture object */ - newTexObj = ctx->Shared->DefaultTex[targetIndex]; - } - else { - /* non-default texture object */ - newTexObj = _mesa_lookup_texture(ctx, texName); - if (newTexObj) { - /* error checking */ - if (newTexObj->Target != 0 && newTexObj->Target != target) { - /* the named texture object's target doesn't match the given target */ - _mesa_error( ctx, GL_INVALID_OPERATION, - "glBindTexture(target mismatch)" ); - return; - } - } - else { - /* if this is a new texture id, allocate a texture object now */ - newTexObj = ctx->Driver.NewTextureObject(ctx, texName, target); - if (!newTexObj) { - _mesa_error(ctx, GL_OUT_OF_MEMORY, "glBindTexture"); - return; - } - - /* and insert it into hash table */ - _glthread_LOCK_MUTEX(ctx->Shared->Mutex); - _mesa_HashInsert(ctx->Shared->TexObjects, texName, newTexObj); - _glthread_UNLOCK_MUTEX(ctx->Shared->Mutex); - } - newTexObj->Target = target; - } - - assert(valid_texture_object(newTexObj)); - - /* Check if this texture is only used by this context and is already bound. - * If so, just return. - */ - { - GLboolean early_out; - _glthread_LOCK_MUTEX(ctx->Shared->Mutex); - early_out = ((ctx->Shared->RefCount == 1) - && (newTexObj == texUnit->CurrentTex[targetIndex])); - _glthread_UNLOCK_MUTEX(ctx->Shared->Mutex); - if (early_out) { - return; - } - } - - /* flush before changing binding */ - FLUSH_VERTICES(ctx, _NEW_TEXTURE); - - /* Do the actual binding. The refcount on the previously bound - * texture object will be decremented. It'll be deleted if the - * count hits zero. - */ - _mesa_reference_texobj(&texUnit->CurrentTex[targetIndex], newTexObj); - ASSERT(texUnit->CurrentTex[targetIndex]); - - /* Pass BindTexture call to device driver */ - if (ctx->Driver.BindTexture) - ctx->Driver.BindTexture(ctx, target, newTexObj); -} - - -/** - * Set texture priorities. - * - * \param n number of textures. - * \param texName texture names. - * \param priorities corresponding texture priorities. - * - * \sa glPrioritizeTextures(). - * - * Looks up each texture in the hash, clamps the corresponding priority between - * 0.0 and 1.0, and calls dd_function_table::PrioritizeTexture. - */ -void GLAPIENTRY -_mesa_PrioritizeTextures( GLsizei n, const GLuint *texName, - const GLclampf *priorities ) -{ - GET_CURRENT_CONTEXT(ctx); - GLint i; - ASSERT_OUTSIDE_BEGIN_END_AND_FLUSH(ctx); - - if (n < 0) { - _mesa_error( ctx, GL_INVALID_VALUE, "glPrioritizeTextures" ); - return; - } - - if (!priorities) - return; - - for (i = 0; i < n; i++) { - if (texName[i] > 0) { - struct gl_texture_object *t = _mesa_lookup_texture(ctx, texName[i]); - if (t) { - t->Priority = CLAMP( priorities[i], 0.0F, 1.0F ); - } - } - } - - ctx->NewState |= _NEW_TEXTURE; -} - - - -/** - * See if textures are loaded in texture memory. - * - * \param n number of textures to query. - * \param texName array with the texture names. - * \param residences array which will hold the residence status. - * - * \return GL_TRUE if all textures are resident and \p residences is left unchanged, - * - * Note: we assume all textures are always resident - */ -GLboolean GLAPIENTRY -_mesa_AreTexturesResident(GLsizei n, const GLuint *texName, - GLboolean *residences) -{ - GET_CURRENT_CONTEXT(ctx); - GLboolean allResident = GL_TRUE; - GLint i; - ASSERT_OUTSIDE_BEGIN_END_WITH_RETVAL(ctx, GL_FALSE); - - if (n < 0) { - _mesa_error(ctx, GL_INVALID_VALUE, "glAreTexturesResident(n)"); - return GL_FALSE; - } - - if (!texName || !residences) - return GL_FALSE; - - /* We only do error checking on the texture names */ - for (i = 0; i < n; i++) { - struct gl_texture_object *t; - if (texName[i] == 0) { - _mesa_error(ctx, GL_INVALID_VALUE, "glAreTexturesResident"); - return GL_FALSE; - } - t = _mesa_lookup_texture(ctx, texName[i]); - if (!t) { - _mesa_error(ctx, GL_INVALID_VALUE, "glAreTexturesResident"); - return GL_FALSE; - } - } - - return allResident; -} - - -/** - * See if a name corresponds to a texture. - * - * \param texture texture name. - * - * \return GL_TRUE if texture name corresponds to a texture, or GL_FALSE - * otherwise. - * - * \sa glIsTexture(). - * - * Calls _mesa_HashLookup(). - */ -GLboolean GLAPIENTRY -_mesa_IsTexture( GLuint texture ) -{ - struct gl_texture_object *t; - GET_CURRENT_CONTEXT(ctx); - ASSERT_OUTSIDE_BEGIN_END_WITH_RETVAL(ctx, GL_FALSE); - - if (!texture) - return GL_FALSE; - - t = _mesa_lookup_texture(ctx, texture); - - /* IsTexture is true only after object has been bound once. */ - return t && t->Target; -} - - -/** - * Simplest implementation of texture locking: grab the shared tex - * mutex. Examine the shared context state timestamp and if there has - * been a change, set the appropriate bits in ctx->NewState. - * - * This is used to deal with synchronizing things when a texture object - * is used/modified by different contexts (or threads) which are sharing - * the texture. - * - * See also _mesa_lock/unlock_texture() in teximage.h - */ -void -_mesa_lock_context_textures( struct gl_context *ctx ) -{ - _glthread_LOCK_MUTEX(ctx->Shared->TexMutex); - - if (ctx->Shared->TextureStateStamp != ctx->TextureStateTimestamp) { - ctx->NewState |= _NEW_TEXTURE; - ctx->TextureStateTimestamp = ctx->Shared->TextureStateStamp; - } -} - - -void -_mesa_unlock_context_textures( struct gl_context *ctx ) -{ - assert(ctx->Shared->TextureStateStamp == ctx->TextureStateTimestamp); - _glthread_UNLOCK_MUTEX(ctx->Shared->TexMutex); -} - -/*@}*/ diff --git a/dll/opengl/mesa/main/texobj.h b/dll/opengl/mesa/main/texobj.h deleted file mode 100644 index 9ca7a4c9e11..00000000000 --- a/dll/opengl/mesa/main/texobj.h +++ /dev/null @@ -1,134 +0,0 @@ -/** - * \file texobj.h - * Texture object management. - */ - -/* - * Mesa 3-D graphics library - * Version: 6.5 - * - * Copyright (C) 1999-2006 Brian Paul All Rights Reserved. - * - * Permission is hereby granted, free of charge, to any person obtaining a - * copy of this software and associated documentation files (the "Software"), - * to deal in the Software without restriction, including without limitation - * the rights to use, copy, modify, merge, publish, distribute, sublicense, - * and/or sell copies of the Software, and to permit persons to whom the - * Software is furnished to do so, subject to the following conditions: - * - * The above copyright notice and this permission notice shall be included - * in all copies or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS - * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL - * BRIAN PAUL BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN - * AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN - * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. - */ - - -#ifndef TEXTOBJ_H -#define TEXTOBJ_H - - -#include "compiler.h" -#include "glheader.h" - -struct gl_context; - -/** - * \name Internal functions - */ -/*@{*/ - -extern struct gl_texture_object * -_mesa_lookup_texture(struct gl_context *ctx, GLuint id); - -extern struct gl_texture_object * -_mesa_new_texture_object( struct gl_context *ctx, GLuint name, GLenum target ); - -extern void -_mesa_initialize_texture_object( struct gl_texture_object *obj, - GLuint name, GLenum target ); - -extern void -_mesa_delete_texture_object( struct gl_context *ctx, - struct gl_texture_object *obj ); - -extern void -_mesa_copy_texture_object( struct gl_texture_object *dest, - const struct gl_texture_object *src ); - -extern void -_mesa_clear_texture_object(struct gl_context *ctx, - struct gl_texture_object *obj); - -extern void -_mesa_reference_texobj_(struct gl_texture_object **ptr, - struct gl_texture_object *tex); - -static inline void -_mesa_reference_texobj(struct gl_texture_object **ptr, - struct gl_texture_object *tex) -{ - if (*ptr != tex) - _mesa_reference_texobj_(ptr, tex); -} - - -extern void -_mesa_test_texobj_completeness( const struct gl_context *ctx, - struct gl_texture_object *obj ); - -extern GLboolean -_mesa_cube_complete(const struct gl_texture_object *texObj); - -extern void -_mesa_dirty_texobj(struct gl_context *ctx, struct gl_texture_object *texObj, - GLboolean invalidate_state); - -extern struct gl_texture_object * -_mesa_get_fallback_texture(struct gl_context *ctx); - -extern void -_mesa_unlock_context_textures( struct gl_context *ctx ); - -extern void -_mesa_lock_context_textures( struct gl_context *ctx ); - -/*@}*/ - -/** - * \name API functions - */ -/*@{*/ - -extern void GLAPIENTRY -_mesa_GenTextures( GLsizei n, GLuint *textures ); - - -extern void GLAPIENTRY -_mesa_DeleteTextures( GLsizei n, const GLuint *textures ); - - -extern void GLAPIENTRY -_mesa_BindTexture( GLenum target, GLuint texture ); - - -extern void GLAPIENTRY -_mesa_PrioritizeTextures( GLsizei n, const GLuint *textures, - const GLclampf *priorities ); - - -extern GLboolean GLAPIENTRY -_mesa_AreTexturesResident( GLsizei n, const GLuint *textures, - GLboolean *residences ); - -extern GLboolean GLAPIENTRY -_mesa_IsTexture( GLuint texture ); - -/*@}*/ - - -#endif diff --git a/dll/opengl/mesa/main/texpal.c b/dll/opengl/mesa/main/texpal.c deleted file mode 100644 index 92387e417e3..00000000000 --- a/dll/opengl/mesa/main/texpal.c +++ /dev/null @@ -1,210 +0,0 @@ -/************************************************************************** - * - * Copyright 2008 Tungsten Graphics, Inc., Cedar Park, Texas. - * All Rights Reserved. - * - **************************************************************************/ - - -/** - * Code to convert compressed/paletted texture images to ordinary images. - * See the GL_OES_compressed_paletted_texture spec at - * http://khronos.org/registry/gles/extensions/OES/OES_compressed_paletted_texture.txt - * - * XXX this makes it impossible to add hardware support... - */ - - -#include - -#include "texpal.h" - -#if FEATURE_ES - - -static const struct cpal_format_info { - GLenum cpal_format; - GLenum format; - GLenum type; - GLuint palette_size; - GLuint size; -} formats[] = { - { GL_PALETTE4_RGB8_OES, GL_RGB, GL_UNSIGNED_BYTE, 16, 3 }, - { GL_PALETTE4_RGBA8_OES, GL_RGBA, GL_UNSIGNED_BYTE, 16, 4 }, - { GL_PALETTE4_R5_G6_B5_OES, GL_RGB, GL_UNSIGNED_SHORT_5_6_5, 16, 2 }, - { GL_PALETTE4_RGBA4_OES, GL_RGBA, GL_UNSIGNED_SHORT_4_4_4_4, 16, 2 }, - { GL_PALETTE4_RGB5_A1_OES, GL_RGBA, GL_UNSIGNED_SHORT_5_5_5_1, 16, 2 }, - { GL_PALETTE8_RGB8_OES, GL_RGB, GL_UNSIGNED_BYTE, 256, 3 }, - { GL_PALETTE8_RGBA8_OES, GL_RGBA, GL_UNSIGNED_BYTE, 256, 4 }, - { GL_PALETTE8_R5_G6_B5_OES, GL_RGB, GL_UNSIGNED_SHORT_5_6_5, 256, 2 }, - { GL_PALETTE8_RGBA4_OES, GL_RGBA, GL_UNSIGNED_SHORT_4_4_4_4, 256, 2 }, - { GL_PALETTE8_RGB5_A1_OES, GL_RGBA, GL_UNSIGNED_SHORT_5_5_5_1, 256, 2 } -}; - - -/** - * Get a color/entry from the palette. - */ -static GLuint -get_palette_entry(const struct cpal_format_info *info, const GLubyte *palette, - GLuint index, GLubyte *pixel) -{ - memcpy(pixel, palette + info->size * index, info->size); - return info->size; -} - - -/** - * Convert paletted texture to color texture. - */ -static void -paletted_to_color(const struct cpal_format_info *info, const GLubyte *palette, - const void *indices, GLuint num_pixels, GLubyte *image) -{ - GLubyte *pix = image; - GLuint remain, i; - - if (info->palette_size == 16) { - /* 4 bits per index */ - const GLubyte *ind = (const GLubyte *) indices; - - /* two pixels per iteration */ - remain = num_pixels % 2; - for (i = 0; i < num_pixels / 2; i++) { - pix += get_palette_entry(info, palette, (ind[i] >> 4) & 0xf, pix); - pix += get_palette_entry(info, palette, ind[i] & 0xf, pix); - } - if (remain) { - get_palette_entry(info, palette, (ind[i] >> 4) & 0xf, pix); - } - } - else { - /* 8 bits per index */ - const GLubyte *ind = (const GLubyte *) indices; - for (i = 0; i < num_pixels; i++) - pix += get_palette_entry(info, palette, ind[i], pix); - } -} - -unsigned -_mesa_cpal_compressed_size(int level, GLenum internalFormat, - unsigned width, unsigned height) -{ - const struct cpal_format_info *info; - const int num_levels = -level + 1; - int lvl; - unsigned w, h, expect_size; - - if (internalFormat < GL_PALETTE4_RGB8_OES - || internalFormat > GL_PALETTE8_RGB5_A1_OES) { - return 0; - } - - info = &formats[internalFormat - GL_PALETTE4_RGB8_OES]; - ASSERT(info->cpal_format == internalFormat); - - expect_size = info->palette_size * info->size; - for (lvl = 0; lvl < num_levels; lvl++) { - w = width >> lvl; - if (!w) - w = 1; - h = height >> lvl; - if (!h) - h = 1; - - if (info->palette_size == 16) - expect_size += (w * h + 1) / 2; - else - expect_size += w * h; - } - - return expect_size; -} - -void -_mesa_cpal_compressed_format_type(GLenum internalFormat, GLenum *format, - GLenum *type) -{ - const struct cpal_format_info *info; - - if (internalFormat < GL_PALETTE4_RGB8_OES - || internalFormat > GL_PALETTE8_RGB5_A1_OES) { - return; - } - - info = &formats[internalFormat - GL_PALETTE4_RGB8_OES]; - *format = info->format; - *type = info->type; -} - -/** - * Convert a call to glCompressedTexImage2D() where internalFormat is a - * compressed palette format into a regular GLubyte/RGBA glTexImage2D() call. - */ -void -_mesa_cpal_compressed_teximage2d(GLenum target, GLint level, - GLenum internalFormat, - GLsizei width, GLsizei height, - GLsizei imageSize, const void *palette) -{ - const struct cpal_format_info *info; - GLint lvl, num_levels; - const GLubyte *indices; - GLint saved_align, align; - GET_CURRENT_CONTEXT(ctx); - - /* By this point, the internalFormat should have been validated. - */ - assert(internalFormat >= GL_PALETTE4_RGB8_OES - && internalFormat <= GL_PALETTE8_RGB5_A1_OES); - - info = &formats[internalFormat - GL_PALETTE4_RGB8_OES]; - - num_levels = -level + 1; - - /* first image follows the palette */ - indices = (const GLubyte *) palette + info->palette_size * info->size; - - saved_align = ctx->Unpack.Alignment; - align = saved_align; - - for (lvl = 0; lvl < num_levels; lvl++) { - GLsizei w, h; - GLuint num_texels; - GLubyte *image = NULL; - - w = width >> lvl; - if (!w) - w = 1; - h = height >> lvl; - if (!h) - h = 1; - num_texels = w * h; - if (w * info->size % align) { - _mesa_PixelStorei(GL_UNPACK_ALIGNMENT, 1); - align = 1; - } - - /* allocate and fill dest image buffer */ - if (palette) { - image = (GLubyte *) malloc(num_texels * info->size); - paletted_to_color(info, palette, indices, num_texels, image); - } - - _mesa_TexImage2D(target, lvl, info->format, w, h, 0, - info->format, info->type, image); - if (image) - free(image); - - /* advance index pointer to point to next src mipmap */ - if (info->palette_size == 16) - indices += (num_texels + 1) / 2; - else - indices += num_texels; - } - - if (saved_align != align) - _mesa_PixelStorei(GL_UNPACK_ALIGNMENT, saved_align); -} - -#endif diff --git a/dll/opengl/mesa/main/texpal.h b/dll/opengl/mesa/main/texpal.h deleted file mode 100644 index acfaa313ec5..00000000000 --- a/dll/opengl/mesa/main/texpal.h +++ /dev/null @@ -1,45 +0,0 @@ -/* - * Mesa 3-D graphics library - * Version: 7.8 - * - * Copyright (C) 1999-2010 Brian Paul All Rights Reserved. - * - * Permission is hereby granted, free of charge, to any person obtaining a - * copy of this software and associated documentation files (the "Software"), - * to deal in the Software without restriction, including without limitation - * the rights to use, copy, modify, merge, publish, distribute, sublicense, - * and/or sell copies of the Software, and to permit persons to whom the - * Software is furnished to do so, subject to the following conditions: - * - * The above copyright notice and this permission notice shall be included - * in all copies or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS - * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL - * BRIAN PAUL BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN - * AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN - * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. - */ - - -#ifndef TEXPAL_H -#define TEXPAL_H - - -#include "main/glheader.h" -extern void -_mesa_cpal_compressed_teximage2d(GLenum target, GLint level, - GLenum internalFormat, - GLsizei width, GLsizei height, - GLsizei imageSize, const void *palette); - -extern unsigned -_mesa_cpal_compressed_size(int level, GLenum internalFormat, - unsigned width, unsigned height); - -extern void -_mesa_cpal_compressed_format_type(GLenum internalFormat, GLenum *format, - GLenum *type); - -#endif /* TEXPAL_H */ diff --git a/dll/opengl/mesa/main/texparam.c b/dll/opengl/mesa/main/texparam.c deleted file mode 100644 index 8109e553f4e..00000000000 --- a/dll/opengl/mesa/main/texparam.c +++ /dev/null @@ -1,834 +0,0 @@ -/* - * Mesa 3-D graphics library - * Version: 7.5 - * - * Copyright (C) 1999-2008 Brian Paul All Rights Reserved. - * Copyright (C) 2009 VMware, Inc. All Rights Reserved. - * - * Permission is hereby granted, free of charge, to any person obtaining a - * copy of this software and associated documentation files (the "Software"), - * to deal in the Software without restriction, including without limitation - * the rights to use, copy, modify, merge, publish, distribute, sublicense, - * and/or sell copies of the Software, and to permit persons to whom the - * Software is furnished to do so, subject to the following conditions: - * - * The above copyright notice and this permission notice shall be included - * in all copies or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS - * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL - * BRIAN PAUL BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN - * AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN - * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. - */ - -/** - * \file texparam.c - * - * glTexParameter-related functions - */ - -#include - -/** - * Check if a coordinate wrap mode is supported for the texture target. - * \return GL_TRUE if legal, GL_FALSE otherwise - */ -static GLboolean -validate_texture_wrap_mode(struct gl_context * ctx, GLenum target, GLenum wrap) -{ - switch (wrap) { - case GL_CLAMP: - case GL_REPEAT: - case GL_MIRRORED_REPEAT: - return GL_TRUE; - default: - break; - } - - _mesa_error( ctx, GL_INVALID_ENUM, "glTexParameter(param=0x%x)", wrap ); - return GL_FALSE; -} - - -/** - * Get current texture object for given target. - * Return NULL if any error (and record the error). - * Note that this is different from _mesa_select_tex_object() in that proxy - * targets are not accepted. - * Only the glGetTexLevelParameter() functions accept proxy targets. - */ -static struct gl_texture_object * -get_texobj(struct gl_context *ctx, GLenum target, GLboolean get) -{ - struct gl_texture_unit *texUnit; - - texUnit = &ctx->Texture.Unit; - - switch (target) { - case GL_TEXTURE_1D: - return texUnit->CurrentTex[TEXTURE_1D_INDEX]; - case GL_TEXTURE_2D: - return texUnit->CurrentTex[TEXTURE_2D_INDEX]; - case GL_TEXTURE_CUBE_MAP: - if (ctx->Extensions.ARB_texture_cube_map) { - return texUnit->CurrentTex[TEXTURE_CUBE_INDEX]; - } - break; - default: - ; - } - - _mesa_error(ctx, GL_INVALID_ENUM, - "gl%sTexParameter(target)", get ? "Get" : ""); - return NULL; -} - - -/** - * This is called just prior to changing any texture object state which - * will not effect texture completeness. - */ -static inline void -flush(struct gl_context *ctx) -{ - FLUSH_VERTICES(ctx, _NEW_TEXTURE); -} - - -/** - * This is called just prior to changing any texture object state which - * can effect texture completeness (texture base level, max level, - * minification filter). - * Any pending rendering will be flushed out, we'll set the _NEW_TEXTURE - * state flag and then mark the texture object as 'incomplete' so that any - * per-texture derived state gets recomputed. - */ -static inline void -incomplete(struct gl_context *ctx, struct gl_texture_object *texObj) -{ - FLUSH_VERTICES(ctx, _NEW_TEXTURE); - texObj->_Complete = GL_FALSE; -} - - -/** - * Set an integer-valued texture parameter - * \return GL_TRUE if legal AND the value changed, GL_FALSE otherwise - */ -static GLboolean -set_tex_parameteri(struct gl_context *ctx, - struct gl_texture_object *texObj, - GLenum pname, const GLint *params) -{ - switch (pname) { - case GL_TEXTURE_MIN_FILTER: - if (texObj->Sampler.MinFilter == params[0]) - return GL_FALSE; - switch (params[0]) { - case GL_NEAREST: - case GL_LINEAR: - incomplete(ctx, texObj); - texObj->Sampler.MinFilter = params[0]; - return GL_TRUE; - case GL_NEAREST_MIPMAP_NEAREST: - case GL_LINEAR_MIPMAP_NEAREST: - case GL_NEAREST_MIPMAP_LINEAR: - case GL_LINEAR_MIPMAP_LINEAR: - incomplete(ctx, texObj); - texObj->Sampler.MinFilter = params[0]; - return GL_TRUE; - /* fall-through */ - default: - goto invalid_param; - } - return GL_FALSE; - - case GL_TEXTURE_MAG_FILTER: - if (texObj->Sampler.MagFilter == params[0]) - return GL_FALSE; - switch (params[0]) { - case GL_NEAREST: - case GL_LINEAR: - flush(ctx); /* does not effect completeness */ - texObj->Sampler.MagFilter = params[0]; - return GL_TRUE; - default: - goto invalid_param; - } - return GL_FALSE; - - case GL_TEXTURE_WRAP_S: - if (texObj->Sampler.WrapS == params[0]) - return GL_FALSE; - if (validate_texture_wrap_mode(ctx, texObj->Target, params[0])) { - flush(ctx); - texObj->Sampler.WrapS = params[0]; - return GL_TRUE; - } - return GL_FALSE; - - case GL_TEXTURE_WRAP_T: - if (texObj->Sampler.WrapT == params[0]) - return GL_FALSE; - if (validate_texture_wrap_mode(ctx, texObj->Target, params[0])) { - flush(ctx); - texObj->Sampler.WrapT = params[0]; - return GL_TRUE; - } - return GL_FALSE; - - case GL_TEXTURE_WRAP_R: - if (texObj->Sampler.WrapR == params[0]) - return GL_FALSE; - if (validate_texture_wrap_mode(ctx, texObj->Target, params[0])) { - flush(ctx); - texObj->Sampler.WrapR = params[0]; - return GL_TRUE; - } - return GL_FALSE; - - default: - goto invalid_pname; - } - -invalid_pname: - _mesa_error(ctx, GL_INVALID_ENUM, "glTexParameter(pname=%s)", - _mesa_lookup_enum_by_nr(pname)); - return GL_FALSE; - -invalid_param: - _mesa_error(ctx, GL_INVALID_ENUM, "glTexParameter(param=%s)", - _mesa_lookup_enum_by_nr(params[0])); - return GL_FALSE; -} - - -/** - * Set a float-valued texture parameter - * \return GL_TRUE if legal AND the value changed, GL_FALSE otherwise - */ -static GLboolean -set_tex_parameterf(struct gl_context *ctx, - struct gl_texture_object *texObj, - GLenum pname, const GLfloat *params) -{ - switch (pname) { - - case GL_TEXTURE_PRIORITY: - flush(ctx); - texObj->Priority = CLAMP(params[0], 0.0F, 1.0F); - return GL_TRUE; - - case GL_TEXTURE_MAX_ANISOTROPY_EXT: - if (ctx->Extensions.EXT_texture_filter_anisotropic) { - if (texObj->Sampler.MaxAnisotropy == params[0]) - return GL_FALSE; - if (params[0] < 1.0) { - _mesa_error(ctx, GL_INVALID_VALUE, "glTexParameter(param)" ); - return GL_FALSE; - } - flush(ctx); - /* clamp to max, that's what NVIDIA does */ - texObj->Sampler.MaxAnisotropy = MIN2(params[0], - ctx->Const.MaxTextureMaxAnisotropy); - return GL_TRUE; - } - else { - static GLuint count = 0; - if (count++ < 10) - _mesa_error(ctx, GL_INVALID_ENUM, - "glTexParameter(pname=GL_TEXTURE_MAX_ANISOTROPY_EXT)"); - } - return GL_FALSE; - - case GL_TEXTURE_BORDER_COLOR: - flush(ctx); - texObj->Sampler.BorderColor.f[RCOMP] = CLAMP(params[0], 0.0F, 1.0F); - texObj->Sampler.BorderColor.f[GCOMP] = CLAMP(params[1], 0.0F, 1.0F); - texObj->Sampler.BorderColor.f[BCOMP] = CLAMP(params[2], 0.0F, 1.0F); - texObj->Sampler.BorderColor.f[ACOMP] = CLAMP(params[3], 0.0F, 1.0F); - return GL_TRUE; - - default: - _mesa_error(ctx, GL_INVALID_ENUM, "glTexParameter(pname=0x%x)", pname); - } - return GL_FALSE; -} - - -void GLAPIENTRY -_mesa_TexParameterf(GLenum target, GLenum pname, GLfloat param) -{ - GLboolean need_update; - struct gl_texture_object *texObj; - GET_CURRENT_CONTEXT(ctx); - ASSERT_OUTSIDE_BEGIN_END(ctx); - - texObj = get_texobj(ctx, target, GL_FALSE); - if (!texObj) - return; - - switch (pname) { - case GL_TEXTURE_MIN_FILTER: - case GL_TEXTURE_MAG_FILTER: - case GL_TEXTURE_WRAP_S: - case GL_TEXTURE_WRAP_T: - case GL_TEXTURE_WRAP_R: - case GL_TEXTURE_COMPARE_MODE_ARB: - case GL_TEXTURE_COMPARE_FUNC_ARB: - case GL_DEPTH_TEXTURE_MODE_ARB: - case GL_TEXTURE_CUBE_MAP_SEAMLESS: - { - /* convert float param to int */ - GLint p[4]; - p[0] = (GLint) param; - p[1] = p[2] = p[3] = 0; - need_update = set_tex_parameteri(ctx, texObj, pname, p); - } - break; - case GL_TEXTURE_SWIZZLE_R_EXT: - case GL_TEXTURE_SWIZZLE_G_EXT: - case GL_TEXTURE_SWIZZLE_B_EXT: - case GL_TEXTURE_SWIZZLE_A_EXT: - { - GLint p[4]; - p[0] = (GLint) param; - p[1] = p[2] = p[3] = 0; - need_update = set_tex_parameteri(ctx, texObj, pname, p); - } - break; - default: - { - /* this will generate an error if pname is illegal */ - GLfloat p[4]; - p[0] = param; - p[1] = p[2] = p[3] = 0.0F; - need_update = set_tex_parameterf(ctx, texObj, pname, p); - } - } - - if (ctx->Driver.TexParameter && need_update) { - ctx->Driver.TexParameter(ctx, target, texObj, pname, ¶m); - } -} - - -void GLAPIENTRY -_mesa_TexParameterfv(GLenum target, GLenum pname, const GLfloat *params) -{ - GLboolean need_update; - struct gl_texture_object *texObj; - GET_CURRENT_CONTEXT(ctx); - ASSERT_OUTSIDE_BEGIN_END(ctx); - - texObj = get_texobj(ctx, target, GL_FALSE); - if (!texObj) - return; - - switch (pname) { - case GL_TEXTURE_MIN_FILTER: - case GL_TEXTURE_MAG_FILTER: - case GL_TEXTURE_WRAP_S: - case GL_TEXTURE_WRAP_T: - case GL_TEXTURE_WRAP_R: - case GL_TEXTURE_COMPARE_MODE_ARB: - case GL_TEXTURE_COMPARE_FUNC_ARB: - case GL_DEPTH_TEXTURE_MODE_ARB: - case GL_TEXTURE_CUBE_MAP_SEAMLESS: - { - /* convert float param to int */ - GLint p[4]; - p[0] = (GLint) params[0]; - p[1] = p[2] = p[3] = 0; - need_update = set_tex_parameteri(ctx, texObj, pname, p); - } - break; - - case GL_TEXTURE_SWIZZLE_R_EXT: - case GL_TEXTURE_SWIZZLE_G_EXT: - case GL_TEXTURE_SWIZZLE_B_EXT: - case GL_TEXTURE_SWIZZLE_A_EXT: - case GL_TEXTURE_SWIZZLE_RGBA_EXT: - { - GLint p[4] = {0, 0, 0, 0}; - p[0] = (GLint) params[0]; - if (pname == GL_TEXTURE_SWIZZLE_RGBA_EXT) { - p[1] = (GLint) params[1]; - p[2] = (GLint) params[2]; - p[3] = (GLint) params[3]; - } - need_update = set_tex_parameteri(ctx, texObj, pname, p); - } - break; - default: - /* this will generate an error if pname is illegal */ - need_update = set_tex_parameterf(ctx, texObj, pname, params); - } - - if (ctx->Driver.TexParameter && need_update) { - ctx->Driver.TexParameter(ctx, target, texObj, pname, params); - } -} - - -void GLAPIENTRY -_mesa_TexParameteri(GLenum target, GLenum pname, GLint param) -{ - GLboolean need_update; - struct gl_texture_object *texObj; - GET_CURRENT_CONTEXT(ctx); - ASSERT_OUTSIDE_BEGIN_END(ctx); - - texObj = get_texobj(ctx, target, GL_FALSE); - if (!texObj) - return; - - switch (pname) { - case GL_TEXTURE_MIN_LOD: - case GL_TEXTURE_MAX_LOD: - case GL_TEXTURE_PRIORITY: - case GL_TEXTURE_MAX_ANISOTROPY_EXT: - case GL_TEXTURE_LOD_BIAS: - case GL_TEXTURE_COMPARE_FAIL_VALUE_ARB: - { - GLfloat fparam[4]; - fparam[0] = (GLfloat) param; - fparam[1] = fparam[2] = fparam[3] = 0.0F; - /* convert int param to float */ - need_update = set_tex_parameterf(ctx, texObj, pname, fparam); - } - break; - default: - /* this will generate an error if pname is illegal */ - { - GLint iparam[4]; - iparam[0] = param; - iparam[1] = iparam[2] = iparam[3] = 0; - need_update = set_tex_parameteri(ctx, texObj, pname, iparam); - } - } - - if (ctx->Driver.TexParameter && need_update) { - GLfloat fparam = (GLfloat) param; - ctx->Driver.TexParameter(ctx, target, texObj, pname, &fparam); - } -} - - -void GLAPIENTRY -_mesa_TexParameteriv(GLenum target, GLenum pname, const GLint *params) -{ - GLboolean need_update; - struct gl_texture_object *texObj; - GET_CURRENT_CONTEXT(ctx); - ASSERT_OUTSIDE_BEGIN_END(ctx); - - texObj = get_texobj(ctx, target, GL_FALSE); - if (!texObj) - return; - - switch (pname) { - case GL_TEXTURE_BORDER_COLOR: - { - /* convert int params to float */ - GLfloat fparams[4]; - fparams[0] = INT_TO_FLOAT(params[0]); - fparams[1] = INT_TO_FLOAT(params[1]); - fparams[2] = INT_TO_FLOAT(params[2]); - fparams[3] = INT_TO_FLOAT(params[3]); - need_update = set_tex_parameterf(ctx, texObj, pname, fparams); - } - break; - case GL_TEXTURE_MIN_LOD: - case GL_TEXTURE_MAX_LOD: - case GL_TEXTURE_PRIORITY: - case GL_TEXTURE_MAX_ANISOTROPY_EXT: - case GL_TEXTURE_LOD_BIAS: - case GL_TEXTURE_COMPARE_FAIL_VALUE_ARB: - { - /* convert int param to float */ - GLfloat fparams[4]; - fparams[0] = (GLfloat) params[0]; - fparams[1] = fparams[2] = fparams[3] = 0.0F; - need_update = set_tex_parameterf(ctx, texObj, pname, fparams); - } - break; - default: - /* this will generate an error if pname is illegal */ - need_update = set_tex_parameteri(ctx, texObj, pname, params); - } - - if (ctx->Driver.TexParameter && need_update) { - GLfloat fparams[4]; - fparams[0] = INT_TO_FLOAT(params[0]); - if (pname == GL_TEXTURE_BORDER_COLOR || - pname == GL_TEXTURE_CROP_RECT_OES) { - fparams[1] = INT_TO_FLOAT(params[1]); - fparams[2] = INT_TO_FLOAT(params[2]); - fparams[3] = INT_TO_FLOAT(params[3]); - } - ctx->Driver.TexParameter(ctx, target, texObj, pname, fparams); - } -} - - -/** - * Set tex parameter to integer value(s). Primarily intended to set - * integer-valued texture border color (for integer-valued textures). - * New in GL 3.0. - */ -void GLAPIENTRY -_mesa_TexParameterIiv(GLenum target, GLenum pname, const GLint *params) -{ - struct gl_texture_object *texObj; - GET_CURRENT_CONTEXT(ctx); - ASSERT_OUTSIDE_BEGIN_END(ctx); - - texObj = get_texobj(ctx, target, GL_FALSE); - if (!texObj) - return; - - switch (pname) { - case GL_TEXTURE_BORDER_COLOR: - FLUSH_VERTICES(ctx, _NEW_TEXTURE); - /* set the integer-valued border color */ - COPY_4V(texObj->Sampler.BorderColor.i, params); - break; - default: - _mesa_TexParameteriv(target, pname, params); - break; - } - /* XXX no driver hook for TexParameterIiv() yet */ -} - - -/** - * Set tex parameter to unsigned integer value(s). Primarily intended to set - * uint-valued texture border color (for integer-valued textures). - * New in GL 3.0 - */ -void GLAPIENTRY -_mesa_TexParameterIuiv(GLenum target, GLenum pname, const GLuint *params) -{ - struct gl_texture_object *texObj; - GET_CURRENT_CONTEXT(ctx); - ASSERT_OUTSIDE_BEGIN_END(ctx); - - texObj = get_texobj(ctx, target, GL_FALSE); - if (!texObj) - return; - - switch (pname) { - case GL_TEXTURE_BORDER_COLOR: - FLUSH_VERTICES(ctx, _NEW_TEXTURE); - /* set the unsigned integer-valued border color */ - COPY_4V(texObj->Sampler.BorderColor.ui, params); - break; - default: - _mesa_TexParameteriv(target, pname, (const GLint *) params); - break; - } - /* XXX no driver hook for TexParameterIuiv() yet */ -} - - -void GLAPIENTRY -_mesa_GetTexLevelParameterfv( GLenum target, GLint level, - GLenum pname, GLfloat *params ) -{ - GLint iparam; - _mesa_GetTexLevelParameteriv( target, level, pname, &iparam ); - *params = (GLfloat) iparam; -} - - -void GLAPIENTRY -_mesa_GetTexLevelParameteriv( GLenum target, GLint level, - GLenum pname, GLint *params ) -{ - struct gl_texture_object *texObj; - const struct gl_texture_image *img = NULL; - GLint maxLevels; - gl_format texFormat; - GET_CURRENT_CONTEXT(ctx); - ASSERT_OUTSIDE_BEGIN_END(ctx); - - /* this will catch bad target values */ - maxLevels = _mesa_max_texture_levels(ctx, target); - if (maxLevels == 0) { - _mesa_error(ctx, GL_INVALID_ENUM, - "glGetTexLevelParameter[if]v(target=0x%x)", target); - return; - } - - if (level < 0 || level >= maxLevels) { - _mesa_error( ctx, GL_INVALID_VALUE, "glGetTexLevelParameter[if]v" ); - return; - } - - texObj = _mesa_select_tex_object(ctx, target); - - img = _mesa_select_tex_image(ctx, texObj, target, level); - if (!img || img->TexFormat == MESA_FORMAT_NONE) { - /* undefined texture image */ - if (pname == GL_TEXTURE_COMPONENTS) - *params = 1; - else - *params = 0; - return; - } - - texFormat = img->TexFormat; - - switch (pname) { - case GL_TEXTURE_WIDTH: - *params = img->Width; - break; - case GL_TEXTURE_HEIGHT: - *params = img->Height; - break; - case GL_TEXTURE_DEPTH: - *params = img->Depth; - break; - case GL_TEXTURE_INTERNAL_FORMAT: - *params = img->InternalFormat; - break; - case GL_TEXTURE_BORDER: - *params = img->Border; - break; - case GL_TEXTURE_RED_SIZE: - case GL_TEXTURE_GREEN_SIZE: - case GL_TEXTURE_BLUE_SIZE: - case GL_TEXTURE_ALPHA_SIZE: - if (_mesa_base_format_has_channel(img->_BaseFormat, pname)) - *params = _mesa_get_format_bits(texFormat, pname); - else - *params = 0; - break; - case GL_TEXTURE_INTENSITY_SIZE: - case GL_TEXTURE_LUMINANCE_SIZE: - if (_mesa_base_format_has_channel(img->_BaseFormat, pname)) { - *params = _mesa_get_format_bits(texFormat, pname); - if (*params == 0) { - /* intensity or luminance is probably stored as RGB[A] */ - *params = MIN2(_mesa_get_format_bits(texFormat, - GL_TEXTURE_RED_SIZE), - _mesa_get_format_bits(texFormat, - GL_TEXTURE_GREEN_SIZE)); - } - } - else { - *params = 0; - } - break; - - default: - goto invalid_pname; - } - - /* no error if we get here */ - return; - -invalid_pname: - _mesa_error(ctx, GL_INVALID_ENUM, - "glGetTexLevelParameter[if]v(pname=%s)", - _mesa_lookup_enum_by_nr(pname)); -} - - - -void GLAPIENTRY -_mesa_GetTexParameterfv( GLenum target, GLenum pname, GLfloat *params ) -{ - struct gl_texture_object *obj; - GET_CURRENT_CONTEXT(ctx); - ASSERT_OUTSIDE_BEGIN_END(ctx); - - obj = get_texobj(ctx, target, GL_TRUE); - if (!obj) - return; - - _mesa_lock_texture(ctx, obj); - switch (pname) { - case GL_TEXTURE_MAG_FILTER: - *params = ENUM_TO_FLOAT(obj->Sampler.MagFilter); - break; - case GL_TEXTURE_MIN_FILTER: - *params = ENUM_TO_FLOAT(obj->Sampler.MinFilter); - break; - case GL_TEXTURE_WRAP_S: - *params = ENUM_TO_FLOAT(obj->Sampler.WrapS); - break; - case GL_TEXTURE_WRAP_T: - *params = ENUM_TO_FLOAT(obj->Sampler.WrapT); - break; - case GL_TEXTURE_WRAP_R: - *params = ENUM_TO_FLOAT(obj->Sampler.WrapR); - break; - case GL_TEXTURE_BORDER_COLOR: - if (ctx->NewState & _NEW_BUFFERS) - _mesa_update_state_locked(ctx); - params[0] = obj->Sampler.BorderColor.f[0]; - params[1] = obj->Sampler.BorderColor.f[1]; - params[2] = obj->Sampler.BorderColor.f[2]; - params[3] = obj->Sampler.BorderColor.f[3]; - break; - case GL_TEXTURE_RESIDENT: - *params = 1.0F; - break; - case GL_TEXTURE_PRIORITY: - *params = obj->Priority; - break; - case GL_TEXTURE_MAX_ANISOTROPY_EXT: - if (!ctx->Extensions.EXT_texture_filter_anisotropic) - goto invalid_pname; - *params = obj->Sampler.MaxAnisotropy; - break; - - case GL_TEXTURE_IMMUTABLE_FORMAT: - if (!ctx->Extensions.ARB_texture_storage) - goto invalid_pname; - *params = (GLfloat) obj->Immutable; - break; - - default: - goto invalid_pname; - } - - /* no error if we get here */ - _mesa_unlock_texture(ctx, obj); - return; - -invalid_pname: - _mesa_unlock_texture(ctx, obj); - _mesa_error(ctx, GL_INVALID_ENUM, "glGetTexParameterfv(pname=0x%x)", pname); -} - - -void GLAPIENTRY -_mesa_GetTexParameteriv( GLenum target, GLenum pname, GLint *params ) -{ - struct gl_texture_object *obj; - GET_CURRENT_CONTEXT(ctx); - ASSERT_OUTSIDE_BEGIN_END(ctx); - - obj = get_texobj(ctx, target, GL_TRUE); - if (!obj) - return; - - _mesa_lock_texture(ctx, obj); - switch (pname) { - case GL_TEXTURE_MAG_FILTER: - *params = (GLint) obj->Sampler.MagFilter; - break;; - case GL_TEXTURE_MIN_FILTER: - *params = (GLint) obj->Sampler.MinFilter; - break;; - case GL_TEXTURE_WRAP_S: - *params = (GLint) obj->Sampler.WrapS; - break;; - case GL_TEXTURE_WRAP_T: - *params = (GLint) obj->Sampler.WrapT; - break;; - case GL_TEXTURE_WRAP_R: - *params = (GLint) obj->Sampler.WrapR; - break;; - case GL_TEXTURE_BORDER_COLOR: - { - GLfloat b[4]; - b[0] = CLAMP(obj->Sampler.BorderColor.f[0], 0.0F, 1.0F); - b[1] = CLAMP(obj->Sampler.BorderColor.f[1], 0.0F, 1.0F); - b[2] = CLAMP(obj->Sampler.BorderColor.f[2], 0.0F, 1.0F); - b[3] = CLAMP(obj->Sampler.BorderColor.f[3], 0.0F, 1.0F); - params[0] = FLOAT_TO_INT(b[0]); - params[1] = FLOAT_TO_INT(b[1]); - params[2] = FLOAT_TO_INT(b[2]); - params[3] = FLOAT_TO_INT(b[3]); - } - break;; - case GL_TEXTURE_RESIDENT: - *params = 1; - break;; - case GL_TEXTURE_PRIORITY: - *params = FLOAT_TO_INT(obj->Priority); - break; - case GL_TEXTURE_MAX_ANISOTROPY_EXT: - if (!ctx->Extensions.EXT_texture_filter_anisotropic) - goto invalid_pname; - *params = (GLint) obj->Sampler.MaxAnisotropy; - break; - - case GL_TEXTURE_IMMUTABLE_FORMAT: - if (!ctx->Extensions.ARB_texture_storage) - goto invalid_pname; - *params = (GLint) obj->Immutable; - break; - - default: - goto invalid_pname; - } - - /* no error if we get here */ - _mesa_unlock_texture(ctx, obj); - return; - -invalid_pname: - _mesa_unlock_texture(ctx, obj); - _mesa_error(ctx, GL_INVALID_ENUM, "glGetTexParameteriv(pname=0x%x)", pname); -} - - -/** New in GL 3.0 */ -void GLAPIENTRY -_mesa_GetTexParameterIiv(GLenum target, GLenum pname, GLint *params) -{ - struct gl_texture_object *texObj; - GET_CURRENT_CONTEXT(ctx); - ASSERT_OUTSIDE_BEGIN_END(ctx); - - texObj = get_texobj(ctx, target, GL_TRUE); - if (!texObj) - return; - - switch (pname) { - case GL_TEXTURE_BORDER_COLOR: - COPY_4V(params, texObj->Sampler.BorderColor.i); - break; - default: - _mesa_GetTexParameteriv(target, pname, params); - } -} - - -/** New in GL 3.0 */ -void GLAPIENTRY -_mesa_GetTexParameterIuiv(GLenum target, GLenum pname, GLuint *params) -{ - struct gl_texture_object *texObj; - GET_CURRENT_CONTEXT(ctx); - ASSERT_OUTSIDE_BEGIN_END(ctx); - - texObj = get_texobj(ctx, target, GL_TRUE); - if (!texObj) - return; - - switch (pname) { - case GL_TEXTURE_BORDER_COLOR: - COPY_4V(params, texObj->Sampler.BorderColor.i); - break; - default: - { - GLint ip[4]; - _mesa_GetTexParameteriv(target, pname, ip); - params[0] = ip[0]; - if (pname == GL_TEXTURE_SWIZZLE_RGBA_EXT || - pname == GL_TEXTURE_CROP_RECT_OES) { - params[1] = ip[1]; - params[2] = ip[2]; - params[3] = ip[3]; - } - } - } -} diff --git a/dll/opengl/mesa/main/texparam.h b/dll/opengl/mesa/main/texparam.h deleted file mode 100644 index 19b4116c0b6..00000000000 --- a/dll/opengl/mesa/main/texparam.h +++ /dev/null @@ -1,75 +0,0 @@ -/* - * Mesa 3-D graphics library - * Version: 7.1 - * - * Copyright (C) 1999-2008 Brian Paul All Rights Reserved. - * - * Permission is hereby granted, free of charge, to any person obtaining a - * copy of this software and associated documentation files (the "Software"), - * to deal in the Software without restriction, including without limitation - * the rights to use, copy, modify, merge, publish, distribute, sublicense, - * and/or sell copies of the Software, and to permit persons to whom the - * Software is furnished to do so, subject to the following conditions: - * - * The above copyright notice and this permission notice shall be included - * in all copies or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS - * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL - * BRIAN PAUL BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN - * AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN - * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. - */ - - -#ifndef TEXPARAM_H -#define TEXPARAM_H - - -#include "main/glheader.h" - - -extern void GLAPIENTRY -_mesa_GetTexLevelParameterfv( GLenum target, GLint level, - GLenum pname, GLfloat *params ); - -extern void GLAPIENTRY -_mesa_GetTexLevelParameteriv( GLenum target, GLint level, - GLenum pname, GLint *params ); - -extern void GLAPIENTRY -_mesa_GetTexParameterfv( GLenum target, GLenum pname, GLfloat *params ); - -extern void GLAPIENTRY -_mesa_GetTexParameteriv( GLenum target, GLenum pname, GLint *params ); - -extern void GLAPIENTRY -_mesa_GetTexParameterIiv(GLenum target, GLenum pname, GLint *params); - -extern void GLAPIENTRY -_mesa_GetTexParameterIuiv(GLenum target, GLenum pname, GLuint *params); - - -extern void GLAPIENTRY -_mesa_TexParameterfv( GLenum target, GLenum pname, const GLfloat *params ); - -extern void GLAPIENTRY -_mesa_TexParameterf( GLenum target, GLenum pname, GLfloat param ); - - -extern void GLAPIENTRY -_mesa_TexParameteri( GLenum target, GLenum pname, GLint param ); - -extern void GLAPIENTRY -_mesa_TexParameteriv( GLenum target, GLenum pname, const GLint *params ); - - -extern void GLAPIENTRY -_mesa_TexParameterIiv(GLenum target, GLenum pname, const GLint *params); - -extern void GLAPIENTRY -_mesa_TexParameterIuiv(GLenum target, GLenum pname, const GLuint *params); - - -#endif /* TEXPARAM_H */ diff --git a/dll/opengl/mesa/main/texstate.c b/dll/opengl/mesa/main/texstate.c deleted file mode 100644 index ffe8ec13feb..00000000000 --- a/dll/opengl/mesa/main/texstate.c +++ /dev/null @@ -1,636 +0,0 @@ -/* - * Mesa 3-D graphics library - * Version: 7.5 - * - * Copyright (C) 1999-2007 Brian Paul All Rights Reserved. - * - * Permission is hereby granted, free of charge, to any person obtaining a - * copy of this software and associated documentation files (the "Software"), - * to deal in the Software without restriction, including without limitation - * the rights to use, copy, modify, merge, publish, distribute, sublicense, - * and/or sell copies of the Software, and to permit persons to whom the - * Software is furnished to do so, subject to the following conditions: - * - * The above copyright notice and this permission notice shall be included - * in all copies or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS - * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL - * BRIAN PAUL BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN - * AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN - * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. - */ - -/** - * \file texstate.c - * - * Texture state handling. - */ - -#include - -/** - * Default texture combine environment state. This is used to initialize - * a context's texture units and as the basis for converting "classic" - * texture environmnets to ARB_texture_env_combine style values. - */ -static const struct gl_tex_env_combine_state default_combine_state = { - GL_MODULATE, GL_MODULATE, - { GL_TEXTURE, GL_PREVIOUS, GL_CONSTANT, GL_CONSTANT }, - { GL_TEXTURE, GL_PREVIOUS, GL_CONSTANT, GL_CONSTANT }, - { GL_SRC_COLOR, GL_SRC_COLOR, GL_SRC_ALPHA, GL_SRC_ALPHA }, - { GL_SRC_ALPHA, GL_SRC_ALPHA, GL_SRC_ALPHA, GL_SRC_ALPHA }, - 0, 0, - 2, 2 -}; - - - -/** - * Used by glXCopyContext to copy texture state from one context to another. - */ -void -_mesa_copy_texture_state( const struct gl_context *src, struct gl_context *dst ) -{ - GLuint tex; - - ASSERT(src); - ASSERT(dst); - - dst->Texture._GenFlags = src->Texture._GenFlags; - dst->Texture._TexGenEnabled = src->Texture._TexGenEnabled; - dst->Texture._TexMatEnabled = src->Texture._TexMatEnabled; - - dst->Texture.Unit.Enabled = src->Texture.Unit.Enabled; - dst->Texture.Unit.EnvMode = src->Texture.Unit.EnvMode; - COPY_4V(dst->Texture.Unit.EnvColor, src->Texture.Unit.EnvColor); - dst->Texture.Unit.TexGenEnabled = src->Texture.Unit.TexGenEnabled; - dst->Texture.Unit.GenS = src->Texture.Unit.GenS; - dst->Texture.Unit.GenT = src->Texture.Unit.GenT; - dst->Texture.Unit.GenR = src->Texture.Unit.GenR; - dst->Texture.Unit.GenQ = src->Texture.Unit.GenQ; - dst->Texture.Unit.LodBias = src->Texture.Unit.LodBias; - - /* GL_EXT_texture_env_combine */ - dst->Texture.Unit.Combine = src->Texture.Unit.Combine; - - /* - * XXX strictly speaking, we should compare texture names/ids and - * bind textures in the dest context according to id. For now, only - * copy bindings if the contexts share the same pool of textures to - * avoid refcounting bugs. - */ - if (dst->Shared == src->Shared) { - /* copy texture object bindings, not contents of texture objects */ - _mesa_lock_context_textures(dst); - - for (tex = 0; tex < NUM_TEXTURE_TARGETS; tex++) { - _mesa_reference_texobj(&dst->Texture.Unit.CurrentTex[tex], - src->Texture.Unit.CurrentTex[tex]); - } - _mesa_unlock_context_textures(dst); - } -} - - -/* - * For debugging - */ -void -_mesa_print_texunit_state( struct gl_context *ctx ) -{ - const struct gl_texture_unit *texUnit = &ctx->Texture.Unit; - printf("Texture Unit\n"); - printf(" GL_TEXTURE_ENV_MODE = %s\n", _mesa_lookup_enum_by_nr(texUnit->EnvMode)); - printf(" GL_COMBINE_RGB = %s\n", _mesa_lookup_enum_by_nr(texUnit->Combine.ModeRGB)); - printf(" GL_COMBINE_ALPHA = %s\n", _mesa_lookup_enum_by_nr(texUnit->Combine.ModeA)); - printf(" GL_SOURCE0_RGB = %s\n", _mesa_lookup_enum_by_nr(texUnit->Combine.SourceRGB[0])); - printf(" GL_SOURCE1_RGB = %s\n", _mesa_lookup_enum_by_nr(texUnit->Combine.SourceRGB[1])); - printf(" GL_SOURCE2_RGB = %s\n", _mesa_lookup_enum_by_nr(texUnit->Combine.SourceRGB[2])); - printf(" GL_SOURCE0_ALPHA = %s\n", _mesa_lookup_enum_by_nr(texUnit->Combine.SourceA[0])); - printf(" GL_SOURCE1_ALPHA = %s\n", _mesa_lookup_enum_by_nr(texUnit->Combine.SourceA[1])); - printf(" GL_SOURCE2_ALPHA = %s\n", _mesa_lookup_enum_by_nr(texUnit->Combine.SourceA[2])); - printf(" GL_OPERAND0_RGB = %s\n", _mesa_lookup_enum_by_nr(texUnit->Combine.OperandRGB[0])); - printf(" GL_OPERAND1_RGB = %s\n", _mesa_lookup_enum_by_nr(texUnit->Combine.OperandRGB[1])); - printf(" GL_OPERAND2_RGB = %s\n", _mesa_lookup_enum_by_nr(texUnit->Combine.OperandRGB[2])); - printf(" GL_OPERAND0_ALPHA = %s\n", _mesa_lookup_enum_by_nr(texUnit->Combine.OperandA[0])); - printf(" GL_OPERAND1_ALPHA = %s\n", _mesa_lookup_enum_by_nr(texUnit->Combine.OperandA[1])); - printf(" GL_OPERAND2_ALPHA = %s\n", _mesa_lookup_enum_by_nr(texUnit->Combine.OperandA[2])); - printf(" GL_RGB_SCALE = %d\n", 1 << texUnit->Combine.ScaleShiftRGB); - printf(" GL_ALPHA_SCALE = %d\n", 1 << texUnit->Combine.ScaleShiftA); - printf(" GL_TEXTURE_ENV_COLOR = (%f, %f, %f, %f)\n", texUnit->EnvColor[0], texUnit->EnvColor[1], texUnit->EnvColor[2], texUnit->EnvColor[3]); -} - - - -/**********************************************************************/ -/* Texture Environment */ -/**********************************************************************/ - -/** - * Convert "classic" texture environment to ARB_texture_env_combine style - * environments. - * - * \param state texture_env_combine state vector to be filled-in. - * \param mode Classic texture environment mode (i.e., \c GL_REPLACE, - * \c GL_BLEND, \c GL_DECAL, etc.). - * \param texBaseFormat Base format of the texture associated with the - * texture unit. - */ -static void -calculate_derived_texenv( struct gl_tex_env_combine_state *state, - GLenum mode, GLenum texBaseFormat ) -{ - GLenum mode_rgb; - GLenum mode_a; - - *state = default_combine_state; - - switch (texBaseFormat) { - case GL_ALPHA: - state->SourceRGB[0] = GL_PREVIOUS; - break; - - case GL_LUMINANCE_ALPHA: - case GL_INTENSITY: - case GL_RGBA: - break; - - case GL_LUMINANCE: - case GL_RED: - case GL_RG: - case GL_RGB: - case GL_YCBCR_MESA: - state->SourceA[0] = GL_PREVIOUS; - break; - - default: - _mesa_problem(NULL, - "Invalid texBaseFormat 0x%x in calculate_derived_texenv", - texBaseFormat); - return; - } - - if (mode == GL_REPLACE_EXT) - mode = GL_REPLACE; - - switch (mode) { - case GL_REPLACE: - case GL_MODULATE: - mode_rgb = (texBaseFormat == GL_ALPHA) ? GL_REPLACE : mode; - mode_a = mode; - break; - - case GL_DECAL: - mode_rgb = GL_INTERPOLATE; - mode_a = GL_REPLACE; - - state->SourceA[0] = GL_PREVIOUS; - - /* Having alpha / luminance / intensity textures replace using the - * incoming fragment color matches the definition in NV_texture_shader. - * The 1.5 spec simply marks these as "undefined". - */ - switch (texBaseFormat) { - case GL_ALPHA: - case GL_LUMINANCE: - case GL_LUMINANCE_ALPHA: - case GL_INTENSITY: - state->SourceRGB[0] = GL_PREVIOUS; - break; - case GL_RED: - case GL_RG: - case GL_RGB: - case GL_YCBCR_MESA: - mode_rgb = GL_REPLACE; - break; - case GL_RGBA: - state->SourceRGB[2] = GL_TEXTURE; - break; - } - break; - - case GL_BLEND: - mode_rgb = GL_INTERPOLATE; - mode_a = GL_MODULATE; - - switch (texBaseFormat) { - case GL_ALPHA: - mode_rgb = GL_REPLACE; - break; - case GL_INTENSITY: - mode_a = GL_INTERPOLATE; - state->SourceA[0] = GL_CONSTANT; - state->OperandA[2] = GL_SRC_ALPHA; - /* FALLTHROUGH */ - case GL_LUMINANCE: - case GL_RED: - case GL_RG: - case GL_RGB: - case GL_LUMINANCE_ALPHA: - case GL_RGBA: - case GL_YCBCR_MESA: - state->SourceRGB[2] = GL_TEXTURE; - state->SourceA[2] = GL_TEXTURE; - state->SourceRGB[0] = GL_CONSTANT; - state->OperandRGB[2] = GL_SRC_COLOR; - break; - } - break; - - case GL_ADD: - mode_rgb = (texBaseFormat == GL_ALPHA) ? GL_REPLACE : GL_ADD; - mode_a = (texBaseFormat == GL_INTENSITY) ? GL_ADD : GL_MODULATE; - break; - - default: - _mesa_problem(NULL, - "Invalid texture env mode 0x%x in calculate_derived_texenv", - mode); - return; - } - - state->ModeRGB = (state->SourceRGB[0] != GL_PREVIOUS) - ? mode_rgb : GL_REPLACE; - state->ModeA = (state->SourceA[0] != GL_PREVIOUS) - ? mode_a : GL_REPLACE; -} - -/**********************************************************************/ -/***** State management *****/ -/**********************************************************************/ - - -/** - * \note This routine refers to derived texture attribute values to - * compute the ENABLE_TEXMAT flags, but is only called on - * _NEW_TEXTURE_MATRIX. On changes to _NEW_TEXTURE, the ENABLE_TEXMAT - * flags are updated by _mesa_update_textures(), below. - * - * \param ctx GL context. - */ -static void -update_texture_matrices( struct gl_context *ctx ) -{ - ctx->Texture._TexMatEnabled = 0x0; - - if (_math_matrix_is_dirty(ctx->TextureMatrixStack.Top)) { - _math_matrix_analyse( ctx->TextureMatrixStack.Top ); - - if (ctx->Texture.Unit._ReallyEnabled && - ctx->TextureMatrixStack.Top->type != MATRIX_IDENTITY) - ctx->Texture._TexMatEnabled = GL_TRUE; - } -} - - -/** - * Examine texture unit's combine/env state to update derived state. - */ -static void -update_tex_combine(struct gl_context *ctx, struct gl_texture_unit *texUnit) -{ - struct gl_tex_env_combine_state *combine; - - /* Set the texUnit->_CurrentCombine field to point to the user's combiner - * state, or the combiner state which is derived from traditional texenv - * mode. - */ - if (texUnit->EnvMode == GL_COMBINE || - texUnit->EnvMode == GL_COMBINE4_NV) { - texUnit->_CurrentCombine = & texUnit->Combine; - } - else { - const struct gl_texture_object *texObj = texUnit->_Current; - GLenum format = texObj->Image[0][texObj->BaseLevel]->_BaseFormat; - - calculate_derived_texenv(&texUnit->_EnvMode, texUnit->EnvMode, format); - texUnit->_CurrentCombine = & texUnit->_EnvMode; - } - - combine = texUnit->_CurrentCombine; - - /* Determine number of source RGB terms in the combiner function */ - switch (combine->ModeRGB) { - case GL_REPLACE: - combine->_NumArgsRGB = 1; - break; - case GL_ADD: - case GL_ADD_SIGNED: - if (texUnit->EnvMode == GL_COMBINE4_NV) - combine->_NumArgsRGB = 4; - else - combine->_NumArgsRGB = 2; - break; - case GL_MODULATE: - case GL_SUBTRACT: - case GL_DOT3_RGB: - case GL_DOT3_RGBA: - case GL_DOT3_RGB_EXT: - case GL_DOT3_RGBA_EXT: - combine->_NumArgsRGB = 2; - break; - case GL_INTERPOLATE: - case GL_MODULATE_ADD_ATI: - case GL_MODULATE_SIGNED_ADD_ATI: - case GL_MODULATE_SUBTRACT_ATI: - combine->_NumArgsRGB = 3; - break; - default: - combine->_NumArgsRGB = 0; - _mesa_problem(ctx, "invalid RGB combine mode in update_texture_state"); - return; - } - - /* Determine number of source Alpha terms in the combiner function */ - switch (combine->ModeA) { - case GL_REPLACE: - combine->_NumArgsA = 1; - break; - case GL_ADD: - case GL_ADD_SIGNED: - if (texUnit->EnvMode == GL_COMBINE4_NV) - combine->_NumArgsA = 4; - else - combine->_NumArgsA = 2; - break; - case GL_MODULATE: - case GL_SUBTRACT: - combine->_NumArgsA = 2; - break; - case GL_INTERPOLATE: - case GL_MODULATE_ADD_ATI: - case GL_MODULATE_SIGNED_ADD_ATI: - case GL_MODULATE_SUBTRACT_ATI: - combine->_NumArgsA = 3; - break; - default: - combine->_NumArgsA = 0; - _mesa_problem(ctx, "invalid Alpha combine mode in update_texture_state"); - break; - } -} - - -/** - * \note This routine refers to derived texture matrix values to - * compute the ENABLE_TEXMAT flags, but is only called on - * _NEW_TEXTURE. On changes to _NEW_TEXTURE_MATRIX, the ENABLE_TEXMAT - * flags are updated by _mesa_update_texture_matrices, above. - * - * \param ctx GL context. - */ -static void -update_texture_state( struct gl_context *ctx ) -{ - /* TODO: only set this if there are actual changes */ - ctx->NewState |= _NEW_TEXTURE; - - ctx->Texture._Enabled = GL_FALSE; - ctx->Texture._GenFlags = 0x0; - ctx->Texture._TexMatEnabled = GL_FALSE; - ctx->Texture._TexGenEnabled = GL_FALSE; - - /* - * Update texture unit state. - */ - { - struct gl_texture_unit *texUnit = &ctx->Texture.Unit; - GLbitfield enabledTargets = texUnit->Enabled; - - texUnit->_ReallyEnabled = 0x0; - - if (enabledTargets) { - GLuint texIndex; - /* Look for the highest priority texture target that's enabled (or used - * by the vert/frag shaders) and "complete". That's the one we'll use - * for texturing. If we're using vert/frag program we're guaranteed - * that bitcount(enabledBits) <= 1. - * Note that the TEXTURE_x_INDEX values are in high to low priority. - */ - for (texIndex = 0; texIndex < NUM_TEXTURE_TARGETS; texIndex++) { - if (enabledTargets & (1 << texIndex)) { - struct gl_texture_object *texObj = texUnit->CurrentTex[texIndex]; - if (!texObj->_Complete) { - _mesa_test_texobj_completeness(ctx, texObj); - } - if (texObj->_Complete) { - texUnit->_ReallyEnabled = 1 << texIndex; - _mesa_reference_texobj(&texUnit->_Current, texObj); - break; - } - } - } - - if (texUnit->_ReallyEnabled) { - /* if we get here, we know this texture unit is enabled */ - ctx->Texture._Enabled = GL_TRUE; - update_tex_combine(ctx, texUnit); - } - } - } - - - /* Determine if texture coordinates are actually needed */ - ctx->Texture._EnabledCoord = ctx->Texture._Enabled; - - /* Setup texgen for those texture coordinate sets that are in use */ - if(ctx->Texture._EnabledCoord) - { - struct gl_texture_unit *texUnit = &ctx->Texture.Unit; - - texUnit->_GenFlags = 0x0; - - if (texUnit->TexGenEnabled) { - if (texUnit->TexGenEnabled & S_BIT) { - texUnit->_GenFlags |= texUnit->GenS._ModeBit; - } - if (texUnit->TexGenEnabled & T_BIT) { - texUnit->_GenFlags |= texUnit->GenT._ModeBit; - } - if (texUnit->TexGenEnabled & R_BIT) { - texUnit->_GenFlags |= texUnit->GenR._ModeBit; - } - if (texUnit->TexGenEnabled & Q_BIT) { - texUnit->_GenFlags |= texUnit->GenQ._ModeBit; - } - - ctx->Texture._TexGenEnabled = GL_TRUE; - ctx->Texture._GenFlags |= texUnit->_GenFlags; - } - - if (ctx->TextureMatrixStack.Top->type != MATRIX_IDENTITY) - ctx->Texture._TexMatEnabled = GL_TRUE; - } -} - - -/** - * Update texture-related derived state. - */ -void -_mesa_update_texture( struct gl_context *ctx, GLuint new_state ) -{ - if (new_state & _NEW_TEXTURE_MATRIX) - update_texture_matrices( ctx ); - - if (new_state & _NEW_TEXTURE) - update_texture_state( ctx ); -} - - -/**********************************************************************/ -/***** Initialization *****/ -/**********************************************************************/ - -/** - * Allocate the proxy textures for the given context. - * - * \param ctx the context to allocate proxies for. - * - * \return GL_TRUE on success, or GL_FALSE on failure - * - * If run out of memory part way through the allocations, clean up and return - * GL_FALSE. - */ -static GLboolean -alloc_proxy_textures( struct gl_context *ctx ) -{ - /* NOTE: these values must be in the same order as the TEXTURE_x_INDEX - * values! - */ - static const GLenum targets[] = { - GL_TEXTURE_CUBE_MAP_ARB, - GL_TEXTURE_2D, - GL_TEXTURE_1D, - }; - GLint tgt; - - STATIC_ASSERT(Elements(targets) == NUM_TEXTURE_TARGETS); - assert(targets[TEXTURE_2D_INDEX] == GL_TEXTURE_2D); - assert(targets[TEXTURE_CUBE_INDEX] == GL_TEXTURE_CUBE_MAP); - - for (tgt = 0; tgt < NUM_TEXTURE_TARGETS; tgt++) { - if (!(ctx->Texture.ProxyTex[tgt] - = ctx->Driver.NewTextureObject(ctx, 0, targets[tgt]))) { - /* out of memory, free what we did allocate */ - while (--tgt >= 0) { - ctx->Driver.DeleteTexture(ctx, ctx->Texture.ProxyTex[tgt]); - } - return GL_FALSE; - } - } - - assert(ctx->Texture.ProxyTex[0]->RefCount == 1); /* sanity check */ - return GL_TRUE; -} - - -/** - * Initialize a texture unit. - * - * \param ctx GL context. - * \param unit texture unit number to be initialized. - */ -static void -init_texture_unit( struct gl_context *ctx) -{ - struct gl_texture_unit *texUnit = &ctx->Texture.Unit; - GLuint tex; - - texUnit->EnvMode = GL_MODULATE; - ASSIGN_4V( texUnit->EnvColor, 0.0, 0.0, 0.0, 0.0 ); - - texUnit->Combine = default_combine_state; - texUnit->_EnvMode = default_combine_state; - texUnit->_CurrentCombine = & texUnit->_EnvMode; - - texUnit->TexGenEnabled = 0x0; - texUnit->GenS.Mode = GL_EYE_LINEAR; - texUnit->GenT.Mode = GL_EYE_LINEAR; - texUnit->GenR.Mode = GL_EYE_LINEAR; - texUnit->GenQ.Mode = GL_EYE_LINEAR; - texUnit->GenS._ModeBit = TEXGEN_EYE_LINEAR; - texUnit->GenT._ModeBit = TEXGEN_EYE_LINEAR; - texUnit->GenR._ModeBit = TEXGEN_EYE_LINEAR; - texUnit->GenQ._ModeBit = TEXGEN_EYE_LINEAR; - - /* Yes, these plane coefficients are correct! */ - ASSIGN_4V( texUnit->GenS.ObjectPlane, 1.0, 0.0, 0.0, 0.0 ); - ASSIGN_4V( texUnit->GenT.ObjectPlane, 0.0, 1.0, 0.0, 0.0 ); - ASSIGN_4V( texUnit->GenR.ObjectPlane, 0.0, 0.0, 0.0, 0.0 ); - ASSIGN_4V( texUnit->GenQ.ObjectPlane, 0.0, 0.0, 0.0, 0.0 ); - ASSIGN_4V( texUnit->GenS.EyePlane, 1.0, 0.0, 0.0, 0.0 ); - ASSIGN_4V( texUnit->GenT.EyePlane, 0.0, 1.0, 0.0, 0.0 ); - ASSIGN_4V( texUnit->GenR.EyePlane, 0.0, 0.0, 0.0, 0.0 ); - ASSIGN_4V( texUnit->GenQ.EyePlane, 0.0, 0.0, 0.0, 0.0 ); - - /* initialize current texture object ptrs to the shared default objects */ - for (tex = 0; tex < NUM_TEXTURE_TARGETS; tex++) { - _mesa_reference_texobj(&texUnit->CurrentTex[tex], - ctx->Shared->DefaultTex[tex]); - } -} - - -/** - * Initialize texture state for the given context. - */ -GLboolean -_mesa_init_texture(struct gl_context *ctx) -{ - /* Texture group */ - ctx->Texture._Enabled = GL_FALSE; - - init_texture_unit(ctx); - - /* Allocate proxy textures */ - if (!alloc_proxy_textures( ctx )) - return GL_FALSE; - - return GL_TRUE; -} - - -/** - * Free dynamically-allocted texture data attached to the given context. - */ -void -_mesa_free_texture_data(struct gl_context *ctx) -{ - GLuint tgt; - - /* unreference current textures */ - /* The _Current texture could account for another reference */ - _mesa_reference_texobj(&ctx->Texture.Unit._Current, NULL); - - for (tgt = 0; tgt < NUM_TEXTURE_TARGETS; tgt++) { - _mesa_reference_texobj(&ctx->Texture.Unit.CurrentTex[tgt], NULL); - } - - /* Free proxy texture objects */ - for (tgt = 0; tgt < NUM_TEXTURE_TARGETS; tgt++) - ctx->Driver.DeleteTexture(ctx, ctx->Texture.ProxyTex[tgt]); - -#if FEATURE_sampler_objects - _mesa_reference_sampler_object(ctx, &ctx->Texture.Unit.Sampler, NULL); -#endif -} - - -/** - * Update the default texture objects in the given context to reference those - * specified in the shared state and release those referencing the old - * shared state. - */ -void -_mesa_update_default_objects_texture(struct gl_context *ctx) -{ - GLuint tex; - struct gl_texture_unit *texUnit = &ctx->Texture.Unit; - for (tex = 0; tex < NUM_TEXTURE_TARGETS; tex++) { - _mesa_reference_texobj(&texUnit->CurrentTex[tex], - ctx->Shared->DefaultTex[tex]); - } -} diff --git a/dll/opengl/mesa/main/texstate.h b/dll/opengl/mesa/main/texstate.h deleted file mode 100644 index 2183589d98b..00000000000 --- a/dll/opengl/mesa/main/texstate.h +++ /dev/null @@ -1,65 +0,0 @@ -/** - * \file texstate.h - * Texture state management. - */ - -/* - * Mesa 3-D graphics library - * Version: 7.1 - * - * Copyright (C) 1999-2007 Brian Paul All Rights Reserved. - * - * Permission is hereby granted, free of charge, to any person obtaining a - * copy of this software and associated documentation files (the "Software"), - * to deal in the Software without restriction, including without limitation - * the rights to use, copy, modify, merge, publish, distribute, sublicense, - * and/or sell copies of the Software, and to permit persons to whom the - * Software is furnished to do so, subject to the following conditions: - * - * The above copyright notice and this permission notice shall be included - * in all copies or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS - * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL - * BRIAN PAUL BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN - * AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN - * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. - */ - - -#ifndef TEXSTATE_H -#define TEXSTATE_H - - -#include "compiler.h" -#include "mtypes.h" - - -extern void -_mesa_copy_texture_state( const struct gl_context *src, struct gl_context *dst ); - -extern void -_mesa_print_texunit_state( struct gl_context *ctx ); - - -/** - * \name Initialization, state maintenance - */ -/*@{*/ - -extern void -_mesa_update_texture( struct gl_context *ctx, GLuint new_state ); - -extern GLboolean -_mesa_init_texture( struct gl_context *ctx ); - -extern void -_mesa_free_texture_data( struct gl_context *ctx ); - -extern void -_mesa_update_default_objects_texture(struct gl_context *ctx); - -/*@}*/ - -#endif diff --git a/dll/opengl/mesa/main/texstorage.c b/dll/opengl/mesa/main/texstorage.c deleted file mode 100644 index 0af95d076ca..00000000000 --- a/dll/opengl/mesa/main/texstorage.c +++ /dev/null @@ -1,371 +0,0 @@ -/* - * Mesa 3-D graphics library - * - * Copyright (C) 2011 VMware, Inc. All Rights Reserved. - * - * Permission is hereby granted, free of charge, to any person obtaining a - * copy of this software and associated documentation files (the "Software"), - * to deal in the Software without restriction, including without limitation - * the rights to use, copy, modify, merge, publish, distribute, sublicense, - * and/or sell copies of the Software, and to permit persons to whom the - * Software is furnished to do so, subject to the following conditions: - * - * The above copyright notice and this permission notice shall be included - * in all copies or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS - * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL - * THE AUTHORS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN - * AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN - * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. - */ - - -/** - * \file texstorage.c - * GL_ARB_texture_storage functions - */ - -#include - -/** - * Check if the given texture target is a legal texture object target - * for a glTexStorage() command. - * This is a bit different than legal_teximage_target() when it comes - * to cube maps. - */ -static GLboolean -legal_texobj_target(struct gl_context *ctx, GLuint dims, GLenum target) -{ - switch (dims) { - case 1: - switch (target) { - case GL_TEXTURE_1D: - case GL_PROXY_TEXTURE_1D: - return GL_TRUE; - default: - return GL_FALSE; - } - case 2: - switch (target) { - case GL_TEXTURE_2D: - case GL_PROXY_TEXTURE_2D: - return GL_TRUE; - case GL_TEXTURE_CUBE_MAP: - case GL_PROXY_TEXTURE_CUBE_MAP: - return ctx->Extensions.ARB_texture_cube_map; - default: - return GL_FALSE; - } - default: - _mesa_problem(ctx, "invalid dims=%u in legal_texobj_target()", dims); - return GL_FALSE; - } -} - - -/** - * Compute the size of the next mipmap level. - */ -static void -next_mipmap_level_size(GLenum target, - GLint *width, GLint *height, GLint *depth) -{ - if (*width > 1) { - *width /= 2; - } - - if (*height > 1) { - *height /= 2; - } - - if (*depth > 1) { - *depth /= 2; - } -} - - -/** - * Do actual memory allocation for glTexStorage1/2/3D(). - */ -static void -setup_texstorage(struct gl_context *ctx, - struct gl_texture_object *texObj, - GLuint dims, - GLsizei levels, GLenum internalFormat, - GLsizei width, GLsizei height, GLsizei depth) -{ - const GLenum target = texObj->Target; - const GLuint numFaces = (target == GL_TEXTURE_CUBE_MAP) ? 6 : 1; - gl_format texFormat; - GLint level, levelWidth = width, levelHeight = height, levelDepth = depth; - GLuint face; - - assert(levels > 0); - assert(width > 0); - assert(height > 0); - assert(depth > 0); - - texFormat = _mesa_choose_texture_format(ctx, texObj, target, 0, - internalFormat, GL_NONE, GL_NONE); - - /* Set up all the texture object's gl_texture_images */ - for (level = 0; level < levels; level++) { - for (face = 0; face < numFaces; face++) { - const GLenum faceTarget = - (target == GL_TEXTURE_CUBE_MAP) - ? GL_TEXTURE_CUBE_MAP_POSITIVE_X + face : target; - struct gl_texture_image *texImage = - _mesa_get_tex_image(ctx, texObj, faceTarget, level); - - if (!texImage) { - _mesa_error(ctx, GL_OUT_OF_MEMORY, "glTexImage%uD", dims); - return; - } - - _mesa_init_teximage_fields(ctx, texImage, - levelWidth, levelHeight, levelDepth, - 0, internalFormat, texFormat); - } - - next_mipmap_level_size(target, &levelWidth, &levelHeight, &levelDepth); - } - - assert(levelWidth > 0); - assert(levelHeight > 0); - assert(levelDepth > 0); - - if (!_mesa_is_proxy_texture(texObj->Target)) { - /* Do actual texture memory allocation */ - if (!ctx->Driver.AllocTextureStorage(ctx, texObj, levels, - width, height, depth)) { - /* Reset the texture images' info to zeros. - * Strictly speaking, we probably don't have to do this since - * generating GL_OUT_OF_MEMORY can leave things in an undefined - * state but this puts things in a consistent state. - */ - for (level = 0; level < levels; level++) { - for (face = 0; face < numFaces; face++) { - struct gl_texture_image *texImage = texObj->Image[face][level]; - if (texImage) { - _mesa_init_teximage_fields(ctx, texImage, - 0, 0, 0, 0, - GL_NONE, MESA_FORMAT_NONE); - } - } - } - - _mesa_error(ctx, GL_OUT_OF_MEMORY, "glTexStorage%uD", dims); - - return; - } - } - - texObj->Immutable = GL_TRUE; -} - - -/** - * Clear all fields of texture object to zeros. Used for proxy texture tests. - */ -static void -clear_image_fields(struct gl_context *ctx, - GLuint dims, - struct gl_texture_object *texObj) -{ - const GLenum target = texObj->Target; - const GLuint numFaces = (target == GL_TEXTURE_CUBE_MAP) ? 6 : 1; - GLint level; - GLuint face; - - for (level = 0; level < Elements(texObj->Image[0]); level++) { - for (face = 0; face < numFaces; face++) { - const GLenum faceTarget = - (target == GL_TEXTURE_CUBE_MAP) - ? GL_TEXTURE_CUBE_MAP_POSITIVE_X + face : target; - struct gl_texture_image *texImage = - _mesa_get_tex_image(ctx, texObj, faceTarget, level); - - if (!texImage) { - _mesa_error(ctx, GL_OUT_OF_MEMORY, "glTexStorage%uD", dims); - return; - } - - _mesa_init_teximage_fields(ctx, texImage, - 0, 0, 0, 0, GL_NONE, MESA_FORMAT_NONE); - } - } -} - - -/** - * Do error checking for calls to glTexStorage1/2/3D(). - * If an error is found, record it with _mesa_error(), unless the target - * is a proxy texture. - * \return GL_TRUE if any error, GL_FALSE otherwise. - */ -static GLboolean -tex_storage_error_check(struct gl_context *ctx, GLuint dims, GLenum target, - GLsizei levels, GLenum internalformat, - GLsizei width, GLsizei height, GLsizei depth) -{ - const GLboolean isProxy = _mesa_is_proxy_texture(target); - struct gl_texture_object *texObj; - GLuint maxDim; - - /* size check */ - if (width < 1 || height < 1 || depth < 1) { - if (!isProxy) { - _mesa_error(ctx, GL_INVALID_VALUE, - "glTexStorage%uD(width, height or depth < 1)", dims); - } - return GL_TRUE; - } - - /* levels check */ - if (levels < 1 || height < 1 || depth < 1) { - if (!isProxy) { - _mesa_error(ctx, GL_INVALID_VALUE, "glTexStorage%uD(levels < 1)", - dims); - } - return GL_TRUE; - } - - /* target check */ - if (!legal_texobj_target(ctx, dims, target)) { - _mesa_error(ctx, GL_INVALID_ENUM, - "glTexStorage%uD(illegal target=%s)", - dims, _mesa_lookup_enum_by_nr(target)); - return GL_TRUE; - } - - /* check levels against maximum */ - if (levels > _mesa_max_texture_levels(ctx, target)) { - if (!isProxy) { - _mesa_error(ctx, GL_INVALID_OPERATION, - "glTexStorage%uD(levels too large)", dims); - } - return GL_TRUE; - } - - /* check levels against width/height/depth */ - maxDim = MAX3(width, height, depth); - if (levels > _mesa_logbase2(maxDim) + 1) { - if (!isProxy) { - _mesa_error(ctx, GL_INVALID_OPERATION, - "glTexStorage%uD(too many levels for max texture dimension)", - dims); - } - return GL_TRUE; - } - - /* non-default texture object check */ - texObj = _mesa_select_tex_object(ctx, target); - if (!texObj || (texObj->Name == 0 && !isProxy)) { - if (!isProxy) { - _mesa_error(ctx, GL_INVALID_OPERATION, - "glTexStorage%uD(texture object 0)", dims); - } - return GL_TRUE; - } - - /* Check if texObj->Immutable is set */ - if (texObj->Immutable) { - if (!isProxy) { - _mesa_error(ctx, GL_INVALID_OPERATION, "glTexStorage%uD(immutable)", - dims); - } - return GL_TRUE; - } - - return GL_FALSE; -} - - -/** - * Helper used by _mesa_TexStorage1/2/3D(). - */ -static void -texstorage(GLuint dims, GLenum target, GLsizei levels, GLenum internalformat, - GLsizei width, GLsizei height, GLsizei depth) -{ - struct gl_texture_object *texObj; - GLboolean error; - - GET_CURRENT_CONTEXT(ctx); - - texObj = _mesa_select_tex_object(ctx, target); - - error = tex_storage_error_check(ctx, dims, target, levels, - internalformat, width, height, depth); - if (!error) { - setup_texstorage(ctx, texObj, dims, levels, internalformat, - width, height, depth); - } - else if (_mesa_is_proxy_texture(target)) { - /* clear all image fields for [levels] */ - clear_image_fields(ctx, dims, texObj); - } -} - - -void GLAPIENTRY -_mesa_TexStorage1D(GLenum target, GLsizei levels, GLenum internalformat, - GLsizei width) -{ - texstorage(1, target, levels, internalformat, width, 1, 1); -} - - -void GLAPIENTRY -_mesa_TexStorage2D(GLenum target, GLsizei levels, GLenum internalformat, - GLsizei width, GLsizei height) -{ - texstorage(2, target, levels, internalformat, width, height, 1); -} - - -void GLAPIENTRY -_mesa_TexStorage3D(GLenum target, GLsizei levels, GLenum internalformat, - GLsizei width, GLsizei height, GLsizei depth) -{ - texstorage(3, target, levels, internalformat, width, height, depth); -} - - - -/* - * Note: we don't support GL_EXT_direct_state_access and the spec says - * we don't need the following functions. However, glew checks for the - * presence of all six functions and will say that GL_ARB_texture_storage - * is not supported if these functions are missing. - */ - - -void GLAPIENTRY -_mesa_TextureStorage1DEXT(GLuint texture, GLenum target, GLsizei levels, - GLenum internalformat, - GLsizei width) -{ - /* no-op */ -} - - -void GLAPIENTRY -_mesa_TextureStorage2DEXT(GLuint texture, GLenum target, GLsizei levels, - GLenum internalformat, - GLsizei width, GLsizei height) -{ - /* no-op */ -} - - - -void GLAPIENTRY -_mesa_TextureStorage3DEXT(GLuint texture, GLenum target, GLsizei levels, - GLenum internalformat, - GLsizei width, GLsizei height, GLsizei depth) -{ - /* no-op */ -} diff --git a/dll/opengl/mesa/main/texstorage.h b/dll/opengl/mesa/main/texstorage.h deleted file mode 100644 index 99382df51d3..00000000000 --- a/dll/opengl/mesa/main/texstorage.h +++ /dev/null @@ -1,61 +0,0 @@ -/* - * Mesa 3-D graphics library - * - * Copyright (C) 2011 VMware, Inc. All Rights Reserved. - * - * Permission is hereby granted, free of charge, to any person obtaining a - * copy of this software and associated documentation files (the "Software"), - * to deal in the Software without restriction, including without limitation - * the rights to use, copy, modify, merge, publish, distribute, sublicense, - * and/or sell copies of the Software, and to permit persons to whom the - * Software is furnished to do so, subject to the following conditions: - * - * The above copyright notice and this permission notice shall be included - * in all copies or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS - * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL - * THE AUTHORS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN - * AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN - * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. - */ - - -#ifndef TEXSTORAGE_H -#define TEXSTORAGE_H - - -extern void GLAPIENTRY -_mesa_TexStorage1D(GLenum target, GLsizei levels, GLenum internalformat, - GLsizei width); - - -extern void GLAPIENTRY -_mesa_TexStorage2D(GLenum target, GLsizei levels, GLenum internalformat, - GLsizei width, GLsizei height); - - -extern void GLAPIENTRY -_mesa_TexStorage3D(GLenum target, GLsizei levels, GLenum internalformat, - GLsizei width, GLsizei height, GLsizei depth); - - - -extern void GLAPIENTRY -_mesa_TextureStorage1DEXT(GLuint texture, GLenum target, GLsizei levels, - GLenum internalformat, - GLsizei width); - -extern void GLAPIENTRY -_mesa_TextureStorage2DEXT(GLuint texture, GLenum target, GLsizei levels, - GLenum internalformat, - GLsizei width, GLsizei height); - -extern void GLAPIENTRY -_mesa_TextureStorage3DEXT(GLuint texture, GLenum target, GLsizei levels, - GLenum internalformat, - GLsizei width, GLsizei height, GLsizei depth); - - -#endif /* TEXSTORAGE_H */ diff --git a/dll/opengl/mesa/main/texstore.c b/dll/opengl/mesa/main/texstore.c deleted file mode 100644 index 77747dc3586..00000000000 --- a/dll/opengl/mesa/main/texstore.c +++ /dev/null @@ -1,3311 +0,0 @@ -/* - * Mesa 3-D graphics library - * Version: 7.5 - * - * Copyright (C) 1999-2008 Brian Paul All Rights Reserved. - * Copyright (c) 2008-2009 VMware, Inc. - * - * Permission is hereby granted, free of charge, to any person obtaining a - * copy of this software and associated documentation files (the "Software"), - * to deal in the Software without restriction, including without limitation - * the rights to use, copy, modify, merge, publish, distribute, sublicense, - * and/or sell copies of the Software, and to permit persons to whom the - * Software is furnished to do so, subject to the following conditions: - * - * The above copyright notice and this permission notice shall be included - * in all copies or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS - * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL - * BRIAN PAUL BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN - * AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN - * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. - */ - -/* - * Authors: - * Brian Paul - */ - -/** - * The GL texture image functions in teximage.c basically just do - * error checking and data structure allocation. They in turn call - * device driver functions which actually copy/convert/store the user's - * texture image data. - * - * However, most device drivers will be able to use the fallback functions - * in this file. That is, most drivers will have the following bit of - * code: - * ctx->Driver.TexImage1D = _mesa_store_teximage1d; - * ctx->Driver.TexImage2D = _mesa_store_teximage2d; - * etc... - * - * Texture image processing is actually kind of complicated. We have to do: - * Format/type conversions - * pixel unpacking - * pixel transfer (scale, bais, lookup, etc) - * - * These functions can handle most everything, including processing full - * images and sub-images. - */ - -#include - -enum { - ZERO = 4, - ONE = 5 -}; - - -/** - * Texture image storage function. - */ -typedef GLboolean (*StoreTexImageFunc)(TEXSTORE_PARAMS); - - -/** - * Return GL_TRUE if the given image format is one that be converted - * to another format by swizzling. - */ -static GLboolean -can_swizzle(GLenum logicalBaseFormat) -{ - switch (logicalBaseFormat) { - case GL_RGBA: - case GL_RGB: - case GL_LUMINANCE_ALPHA: - case GL_INTENSITY: - case GL_ALPHA: - case GL_LUMINANCE: - case GL_RED: - case GL_GREEN: - case GL_BLUE: - case GL_BGR: - case GL_BGRA: - case GL_ABGR_EXT: - case GL_RG: - return GL_TRUE; - default: - return GL_FALSE; - } -} - - - -enum { - IDX_LUMINANCE = 0, - IDX_ALPHA, - IDX_INTENSITY, - IDX_LUMINANCE_ALPHA, - IDX_RGB, - IDX_RGBA, - IDX_RED, - IDX_GREEN, - IDX_BLUE, - IDX_BGR, - IDX_BGRA, - IDX_ABGR, - IDX_RG, - MAX_IDX -}; - -#define MAP1(x) MAP4(x, ZERO, ZERO, ZERO) -#define MAP2(x,y) MAP4(x, y, ZERO, ZERO) -#define MAP3(x,y,z) MAP4(x, y, z, ZERO) -#define MAP4(x,y,z,w) { x, y, z, w, ZERO, ONE } - - -static const struct { - GLubyte format_idx; - GLubyte to_rgba[6]; - GLubyte from_rgba[6]; -} mappings[MAX_IDX] = -{ - { - IDX_LUMINANCE, - MAP4(0,0,0,ONE), - MAP1(0) - }, - - { - IDX_ALPHA, - MAP4(ZERO, ZERO, ZERO, 0), - MAP1(3) - }, - - { - IDX_INTENSITY, - MAP4(0, 0, 0, 0), - MAP1(0), - }, - - { - IDX_LUMINANCE_ALPHA, - MAP4(0,0,0,1), - MAP2(0,3) - }, - - { - IDX_RGB, - MAP4(0,1,2,ONE), - MAP3(0,1,2) - }, - - { - IDX_RGBA, - MAP4(0,1,2,3), - MAP4(0,1,2,3), - }, - - { - IDX_RED, - MAP4(0, ZERO, ZERO, ONE), - MAP1(0), - }, - - { - IDX_GREEN, - MAP4(ZERO, 0, ZERO, ONE), - MAP1(1), - }, - - { - IDX_BLUE, - MAP4(ZERO, ZERO, 0, ONE), - MAP1(2), - }, - - { - IDX_BGR, - MAP4(2,1,0,ONE), - MAP3(2,1,0) - }, - - { - IDX_BGRA, - MAP4(2,1,0,3), - MAP4(2,1,0,3) - }, - - { - IDX_ABGR, - MAP4(3,2,1,0), - MAP4(3,2,1,0) - }, - - { - IDX_RG, - MAP4(0, 1, ZERO, ONE), - MAP2(0, 1) - }, -}; - - - -/** - * Convert a GL image format enum to an IDX_* value (see above). - */ -static int -get_map_idx(GLenum value) -{ - switch (value) { - case GL_LUMINANCE: return IDX_LUMINANCE; - case GL_ALPHA: return IDX_ALPHA; - case GL_INTENSITY: return IDX_INTENSITY; - case GL_LUMINANCE_ALPHA: return IDX_LUMINANCE_ALPHA; - case GL_RGB: return IDX_RGB; - case GL_RGBA: return IDX_RGBA; - case GL_RED: return IDX_RED; - case GL_GREEN: return IDX_GREEN; - case GL_BLUE: return IDX_BLUE; - case GL_BGR: return IDX_BGR; - case GL_BGRA: return IDX_BGRA; - case GL_ABGR_EXT: return IDX_ABGR; - case GL_RG: return IDX_RG; - default: - _mesa_problem(NULL, "Unexpected inFormat"); - return 0; - } -} - - -/** - * When promoting texture formats (see below) we need to compute the - * mapping of dest components back to source components. - * This function does that. - * \param inFormat the incoming format of the texture - * \param outFormat the final texture format - * \return map[6] a full 6-component map - */ -static void -compute_component_mapping(GLenum inFormat, GLenum outFormat, - GLubyte *map) -{ - const int inFmt = get_map_idx(inFormat); - const int outFmt = get_map_idx(outFormat); - const GLubyte *in2rgba = mappings[inFmt].to_rgba; - const GLubyte *rgba2out = mappings[outFmt].from_rgba; - int i; - - for (i = 0; i < 4; i++) - map[i] = in2rgba[rgba2out[i]]; - - map[ZERO] = ZERO; - map[ONE] = ONE; - -#if 0 - printf("from %x/%s to %x/%s map %d %d %d %d %d %d\n", - inFormat, _mesa_lookup_enum_by_nr(inFormat), - outFormat, _mesa_lookup_enum_by_nr(outFormat), - map[0], - map[1], - map[2], - map[3], - map[4], - map[5]); -#endif -} - - -/** - * Make a temporary (color) texture image with GLfloat components. - * Apply all needed pixel unpacking and pixel transfer operations. - * Note that there are both logicalBaseFormat and textureBaseFormat parameters. - * Suppose the user specifies GL_LUMINANCE as the internal texture format - * but the graphics hardware doesn't support luminance textures. So, we might - * use an RGB hardware format instead. - * If logicalBaseFormat != textureBaseFormat we have some extra work to do. - * - * \param ctx the rendering context - * \param dims image dimensions: 1, 2 or 3 - * \param logicalBaseFormat basic texture derived from the user's - * internal texture format value - * \param textureBaseFormat the actual basic format of the texture - * \param srcWidth source image width - * \param srcHeight source image height - * \param srcDepth source image depth - * \param srcFormat source image format - * \param srcType source image type - * \param srcAddr source image address - * \param srcPacking source image pixel packing - * \return resulting image with format = textureBaseFormat and type = GLfloat. - */ -GLfloat * -_mesa_make_temp_float_image(struct gl_context *ctx, GLuint dims, - GLenum logicalBaseFormat, - GLenum textureBaseFormat, - GLint srcWidth, GLint srcHeight, GLint srcDepth, - GLenum srcFormat, GLenum srcType, - const GLvoid *srcAddr, - const struct gl_pixelstore_attrib *srcPacking, - GLbitfield transferOps) -{ - GLfloat *tempImage; - const GLint components = _mesa_components_in_format(logicalBaseFormat); - const GLint srcStride = - _mesa_image_row_stride(srcPacking, srcWidth, srcFormat, srcType); - GLfloat *dst; - GLint img, row; - - ASSERT(dims >= 1 && dims <= 3); - - ASSERT(logicalBaseFormat == GL_RGBA || - logicalBaseFormat == GL_RGB || - logicalBaseFormat == GL_RG || - logicalBaseFormat == GL_RED || - logicalBaseFormat == GL_LUMINANCE_ALPHA || - logicalBaseFormat == GL_LUMINANCE || - logicalBaseFormat == GL_ALPHA || - logicalBaseFormat == GL_INTENSITY || - logicalBaseFormat == GL_DEPTH_COMPONENT); - - ASSERT(textureBaseFormat == GL_RGBA || - textureBaseFormat == GL_RGB || - textureBaseFormat == GL_RG || - textureBaseFormat == GL_RED || - textureBaseFormat == GL_LUMINANCE_ALPHA || - textureBaseFormat == GL_LUMINANCE || - textureBaseFormat == GL_ALPHA || - textureBaseFormat == GL_INTENSITY || - textureBaseFormat == GL_DEPTH_COMPONENT); - - tempImage = (GLfloat *) malloc(srcWidth * srcHeight * srcDepth - * components * sizeof(GLfloat)); - if (!tempImage) - return NULL; - - dst = tempImage; - for (img = 0; img < srcDepth; img++) { - const GLubyte *src - = (const GLubyte *) _mesa_image_address(dims, srcPacking, srcAddr, - srcWidth, srcHeight, - srcFormat, srcType, - img, 0, 0); - for (row = 0; row < srcHeight; row++) { - _mesa_unpack_color_span_float(ctx, srcWidth, logicalBaseFormat, - dst, srcFormat, srcType, src, - srcPacking, transferOps); - dst += srcWidth * components; - src += srcStride; - } - } - - if (logicalBaseFormat != textureBaseFormat) { - /* more work */ - GLint texComponents = _mesa_components_in_format(textureBaseFormat); - GLint logComponents = _mesa_components_in_format(logicalBaseFormat); - GLfloat *newImage; - GLint i, n; - GLubyte map[6]; - - /* we only promote up to RGB, RGBA and LUMINANCE_ALPHA formats for now */ - ASSERT(textureBaseFormat == GL_RGB || textureBaseFormat == GL_RGBA || - textureBaseFormat == GL_LUMINANCE_ALPHA); - - /* The actual texture format should have at least as many components - * as the logical texture format. - */ - ASSERT(texComponents >= logComponents); - - newImage = (GLfloat *) malloc(srcWidth * srcHeight * srcDepth - * texComponents * sizeof(GLfloat)); - if (!newImage) { - free(tempImage); - return NULL; - } - - compute_component_mapping(logicalBaseFormat, textureBaseFormat, map); - - n = srcWidth * srcHeight * srcDepth; - for (i = 0; i < n; i++) { - GLint k; - for (k = 0; k < texComponents; k++) { - GLint j = map[k]; - if (j == ZERO) - newImage[i * texComponents + k] = 0.0F; - else if (j == ONE) - newImage[i * texComponents + k] = 1.0F; - else - newImage[i * texComponents + k] = tempImage[i * logComponents + j]; - } - } - - free(tempImage); - tempImage = newImage; - } - - return tempImage; -} - - -/** - * Make temporary image with uint pixel values. Used for unsigned - * integer-valued textures. - */ -static GLuint * -make_temp_uint_image(struct gl_context *ctx, GLuint dims, - GLenum logicalBaseFormat, - GLenum textureBaseFormat, - GLint srcWidth, GLint srcHeight, GLint srcDepth, - GLenum srcFormat, GLenum srcType, - const GLvoid *srcAddr, - const struct gl_pixelstore_attrib *srcPacking) -{ - GLuint *tempImage; - const GLint components = _mesa_components_in_format(logicalBaseFormat); - const GLint srcStride = - _mesa_image_row_stride(srcPacking, srcWidth, srcFormat, srcType); - GLuint *dst; - GLint img, row; - - ASSERT(dims >= 1 && dims <= 3); - - ASSERT(logicalBaseFormat == GL_RGBA || - logicalBaseFormat == GL_RGB || - logicalBaseFormat == GL_RG || - logicalBaseFormat == GL_RED || - logicalBaseFormat == GL_LUMINANCE_ALPHA || - logicalBaseFormat == GL_LUMINANCE || - logicalBaseFormat == GL_INTENSITY || - logicalBaseFormat == GL_ALPHA); - - ASSERT(textureBaseFormat == GL_RGBA || - textureBaseFormat == GL_RGB || - textureBaseFormat == GL_RG || - textureBaseFormat == GL_RED || - textureBaseFormat == GL_LUMINANCE_ALPHA || - textureBaseFormat == GL_LUMINANCE || - textureBaseFormat == GL_INTENSITY || - textureBaseFormat == GL_ALPHA); - - tempImage = (GLuint *) malloc(srcWidth * srcHeight * srcDepth - * components * sizeof(GLuint)); - if (!tempImage) - return NULL; - - dst = tempImage; - for (img = 0; img < srcDepth; img++) { - const GLubyte *src - = (const GLubyte *) _mesa_image_address(dims, srcPacking, srcAddr, - srcWidth, srcHeight, - srcFormat, srcType, - img, 0, 0); - for (row = 0; row < srcHeight; row++) { - _mesa_unpack_color_span_uint(ctx, srcWidth, logicalBaseFormat, - dst, srcFormat, srcType, src, - srcPacking); - dst += srcWidth * components; - src += srcStride; - } - } - - if (logicalBaseFormat != textureBaseFormat) { - /* more work */ - GLint texComponents = _mesa_components_in_format(textureBaseFormat); - GLint logComponents = _mesa_components_in_format(logicalBaseFormat); - GLuint *newImage; - GLint i, n; - GLubyte map[6]; - - /* we only promote up to RGB, RGBA and LUMINANCE_ALPHA formats for now */ - ASSERT(textureBaseFormat == GL_RGB || textureBaseFormat == GL_RGBA || - textureBaseFormat == GL_LUMINANCE_ALPHA); - - /* The actual texture format should have at least as many components - * as the logical texture format. - */ - ASSERT(texComponents >= logComponents); - - newImage = (GLuint *) malloc(srcWidth * srcHeight * srcDepth - * texComponents * sizeof(GLuint)); - if (!newImage) { - free(tempImage); - return NULL; - } - - compute_component_mapping(logicalBaseFormat, textureBaseFormat, map); - - n = srcWidth * srcHeight * srcDepth; - for (i = 0; i < n; i++) { - GLint k; - for (k = 0; k < texComponents; k++) { - GLint j = map[k]; - if (j == ZERO) - newImage[i * texComponents + k] = 0; - else if (j == ONE) - newImage[i * texComponents + k] = 1; - else - newImage[i * texComponents + k] = tempImage[i * logComponents + j]; - } - } - - free(tempImage); - tempImage = newImage; - } - - return tempImage; -} - - - -/** - * Make a temporary (color) texture image with GLubyte components. - * Apply all needed pixel unpacking and pixel transfer operations. - * Note that there are both logicalBaseFormat and textureBaseFormat parameters. - * Suppose the user specifies GL_LUMINANCE as the internal texture format - * but the graphics hardware doesn't support luminance textures. So, we might - * use an RGB hardware format instead. - * If logicalBaseFormat != textureBaseFormat we have some extra work to do. - * - * \param ctx the rendering context - * \param dims image dimensions: 1, 2 or 3 - * \param logicalBaseFormat basic texture derived from the user's - * internal texture format value - * \param textureBaseFormat the actual basic format of the texture - * \param srcWidth source image width - * \param srcHeight source image height - * \param srcDepth source image depth - * \param srcFormat source image format - * \param srcType source image type - * \param srcAddr source image address - * \param srcPacking source image pixel packing - * \return resulting image with format = textureBaseFormat and type = GLubyte. - */ -GLubyte * -_mesa_make_temp_ubyte_image(struct gl_context *ctx, GLuint dims, - GLenum logicalBaseFormat, - GLenum textureBaseFormat, - GLint srcWidth, GLint srcHeight, GLint srcDepth, - GLenum srcFormat, GLenum srcType, - const GLvoid *srcAddr, - const struct gl_pixelstore_attrib *srcPacking) -{ - GLuint transferOps = ctx->_ImageTransferState; - const GLint components = _mesa_components_in_format(logicalBaseFormat); - GLint img, row; - GLubyte *tempImage, *dst; - - ASSERT(dims >= 1 && dims <= 3); - - ASSERT(logicalBaseFormat == GL_RGBA || - logicalBaseFormat == GL_RGB || - logicalBaseFormat == GL_RG || - logicalBaseFormat == GL_RED || - logicalBaseFormat == GL_LUMINANCE_ALPHA || - logicalBaseFormat == GL_LUMINANCE || - logicalBaseFormat == GL_ALPHA || - logicalBaseFormat == GL_INTENSITY); - - ASSERT(textureBaseFormat == GL_RGBA || - textureBaseFormat == GL_RGB || - textureBaseFormat == GL_RG || - textureBaseFormat == GL_RED || - textureBaseFormat == GL_LUMINANCE_ALPHA || - textureBaseFormat == GL_LUMINANCE || - textureBaseFormat == GL_ALPHA || - textureBaseFormat == GL_INTENSITY); - - /* unpack and transfer the source image */ - tempImage = (GLubyte *) malloc(srcWidth * srcHeight * srcDepth - * components * sizeof(GLubyte)); - if (!tempImage) { - return NULL; - } - - dst = tempImage; - for (img = 0; img < srcDepth; img++) { - const GLint srcStride = - _mesa_image_row_stride(srcPacking, srcWidth, srcFormat, srcType); - const GLubyte *src = - (const GLubyte *) _mesa_image_address(dims, srcPacking, srcAddr, - srcWidth, srcHeight, - srcFormat, srcType, - img, 0, 0); - for (row = 0; row < srcHeight; row++) { - _mesa_unpack_color_span_ubyte(ctx, srcWidth, logicalBaseFormat, dst, - srcFormat, srcType, src, srcPacking, - transferOps); - dst += srcWidth * components; - src += srcStride; - } - } - - if (logicalBaseFormat != textureBaseFormat) { - /* one more conversion step */ - GLint texComponents = _mesa_components_in_format(textureBaseFormat); - GLint logComponents = _mesa_components_in_format(logicalBaseFormat); - GLubyte *newImage; - GLint i, n; - GLubyte map[6]; - - /* we only promote up to RGB, RGBA and LUMINANCE_ALPHA formats for now */ - ASSERT(textureBaseFormat == GL_RGB || textureBaseFormat == GL_RGBA || - textureBaseFormat == GL_LUMINANCE_ALPHA); - - /* The actual texture format should have at least as many components - * as the logical texture format. - */ - ASSERT(texComponents >= logComponents); - - newImage = (GLubyte *) malloc(srcWidth * srcHeight * srcDepth - * texComponents * sizeof(GLubyte)); - if (!newImage) { - free(tempImage); - return NULL; - } - - compute_component_mapping(logicalBaseFormat, textureBaseFormat, map); - - n = srcWidth * srcHeight * srcDepth; - for (i = 0; i < n; i++) { - GLint k; - for (k = 0; k < texComponents; k++) { - GLint j = map[k]; - if (j == ZERO) - newImage[i * texComponents + k] = 0; - else if (j == ONE) - newImage[i * texComponents + k] = 255; - else - newImage[i * texComponents + k] = tempImage[i * logComponents + j]; - } - } - - free(tempImage); - tempImage = newImage; - } - - return tempImage; -} - - -/** - * Copy GLubyte pixels from to with swizzling. - * \param dst destination pixels - * \param dstComponents number of color components in destination pixels - * \param src source pixels - * \param srcComponents number of color components in source pixels - * \param map the swizzle mapping. map[X] says where to find the X component - * in the source image's pixels. For example, if the source image - * is GL_BGRA and X = red, map[0] yields 2. - * \param count number of pixels to copy/swizzle. - */ -static void -swizzle_copy(GLubyte *dst, GLuint dstComponents, const GLubyte *src, - GLuint srcComponents, const GLubyte *map, GLuint count) -{ -#define SWZ_CPY(dst, src, count, dstComps, srcComps) \ - do { \ - GLuint i; \ - for (i = 0; i < count; i++) { \ - GLuint j; \ - if (srcComps == 4) { \ - COPY_4UBV(tmp, src); \ - } \ - else { \ - for (j = 0; j < srcComps; j++) { \ - tmp[j] = src[j]; \ - } \ - } \ - src += srcComps; \ - for (j = 0; j < dstComps; j++) { \ - dst[j] = tmp[map[j]]; \ - } \ - dst += dstComps; \ - } \ - } while (0) - - GLubyte tmp[6]; - - tmp[ZERO] = 0x0; - tmp[ONE] = 0xff; - - ASSERT(srcComponents <= 4); - ASSERT(dstComponents <= 4); - - switch (dstComponents) { - case 4: - switch (srcComponents) { - case 4: - SWZ_CPY(dst, src, count, 4, 4); - break; - case 3: - SWZ_CPY(dst, src, count, 4, 3); - break; - case 2: - SWZ_CPY(dst, src, count, 4, 2); - break; - case 1: - SWZ_CPY(dst, src, count, 4, 1); - break; - default: - ; - } - break; - case 3: - switch (srcComponents) { - case 4: - SWZ_CPY(dst, src, count, 3, 4); - break; - case 3: - SWZ_CPY(dst, src, count, 3, 3); - break; - case 2: - SWZ_CPY(dst, src, count, 3, 2); - break; - case 1: - SWZ_CPY(dst, src, count, 3, 1); - break; - default: - ; - } - break; - case 2: - switch (srcComponents) { - case 4: - SWZ_CPY(dst, src, count, 2, 4); - break; - case 3: - SWZ_CPY(dst, src, count, 2, 3); - break; - case 2: - SWZ_CPY(dst, src, count, 2, 2); - break; - case 1: - SWZ_CPY(dst, src, count, 2, 1); - break; - default: - ; - } - break; - case 1: - switch (srcComponents) { - case 4: - SWZ_CPY(dst, src, count, 1, 4); - break; - case 3: - SWZ_CPY(dst, src, count, 1, 3); - break; - case 2: - SWZ_CPY(dst, src, count, 1, 2); - break; - case 1: - SWZ_CPY(dst, src, count, 1, 1); - break; - default: - ; - } - break; - default: - ; - } -#undef SWZ_CPY -} - - - -static const GLubyte map_identity[6] = { 0, 1, 2, 3, ZERO, ONE }; -static const GLubyte map_3210[6] = { 3, 2, 1, 0, ZERO, ONE }; - - -/** - * For 1-byte/pixel formats (or 8_8_8_8 packed formats), return a - * mapping array depending on endianness. - */ -static const GLubyte * -type_mapping( GLenum srcType ) -{ - switch (srcType) { - case GL_BYTE: - case GL_UNSIGNED_BYTE: - return map_identity; - case GL_UNSIGNED_INT_8_8_8_8: - return _mesa_little_endian() ? map_3210 : map_identity; - case GL_UNSIGNED_INT_8_8_8_8_REV: - return _mesa_little_endian() ? map_identity : map_3210; - default: - return NULL; - } -} - - -/** - * For 1-byte/pixel formats (or 8_8_8_8 packed formats), return a - * mapping array depending on pixelstore byte swapping state. - */ -static const GLubyte * -byteswap_mapping( GLboolean swapBytes, - GLenum srcType ) -{ - if (!swapBytes) - return map_identity; - - switch (srcType) { - case GL_BYTE: - case GL_UNSIGNED_BYTE: - return map_identity; - case GL_UNSIGNED_INT_8_8_8_8: - case GL_UNSIGNED_INT_8_8_8_8_REV: - return map_3210; - default: - return NULL; - } -} - - - -/** - * Transfer a GLubyte texture image with component swizzling. - */ -static void -_mesa_swizzle_ubyte_image(struct gl_context *ctx, - GLuint dimensions, - GLenum srcFormat, - GLenum srcType, - - GLenum baseInternalFormat, - - const GLubyte *rgba2dst, - GLuint dstComponents, - - GLint dstRowStride, - GLubyte **dstSlices, - - GLint srcWidth, GLint srcHeight, GLint srcDepth, - const GLvoid *srcAddr, - const struct gl_pixelstore_attrib *srcPacking ) -{ - GLint srcComponents = _mesa_components_in_format(srcFormat); - const GLubyte *srctype2ubyte, *swap; - GLubyte map[4], src2base[6], base2rgba[6]; - GLint i; - const GLint srcRowStride = - _mesa_image_row_stride(srcPacking, srcWidth, - srcFormat, GL_UNSIGNED_BYTE); - const GLint srcImageStride - = _mesa_image_image_stride(srcPacking, srcWidth, srcHeight, srcFormat, - GL_UNSIGNED_BYTE); - const GLubyte *srcImage - = (const GLubyte *) _mesa_image_address(dimensions, srcPacking, srcAddr, - srcWidth, srcHeight, srcFormat, - GL_UNSIGNED_BYTE, 0, 0, 0); - - (void) ctx; - - /* Translate from src->baseInternal->GL_RGBA->dst. This will - * correctly deal with RGBA->RGB->RGBA conversions where the final - * A value must be 0xff regardless of the incoming alpha values. - */ - compute_component_mapping(srcFormat, baseInternalFormat, src2base); - compute_component_mapping(baseInternalFormat, GL_RGBA, base2rgba); - swap = byteswap_mapping(srcPacking->SwapBytes, srcType); - srctype2ubyte = type_mapping(srcType); - - - for (i = 0; i < 4; i++) - map[i] = srctype2ubyte[swap[src2base[base2rgba[rgba2dst[i]]]]]; - -/* printf("map %d %d %d %d\n", map[0], map[1], map[2], map[3]); */ - - if (srcComponents == dstComponents && - srcRowStride == dstRowStride && - srcRowStride == srcWidth * srcComponents && - dimensions < 3) { - /* 1 and 2D images only */ - GLubyte *dstImage = dstSlices[0]; - swizzle_copy(dstImage, dstComponents, srcImage, srcComponents, map, - srcWidth * srcHeight); - } - else { - GLint img, row; - for (img = 0; img < srcDepth; img++) { - const GLubyte *srcRow = srcImage; - GLubyte *dstRow = dstSlices[img]; - for (row = 0; row < srcHeight; row++) { - swizzle_copy(dstRow, dstComponents, srcRow, srcComponents, map, srcWidth); - dstRow += dstRowStride; - srcRow += srcRowStride; - } - srcImage += srcImageStride; - } - } -} - - -/** - * Teximage storage routine for when a simple memcpy will do. - * No pixel transfer operations or special texel encodings allowed. - * 1D, 2D and 3D images supported. - */ -static void -memcpy_texture(struct gl_context *ctx, - GLuint dimensions, - gl_format dstFormat, - GLint dstRowStride, - GLubyte **dstSlices, - GLint srcWidth, GLint srcHeight, GLint srcDepth, - GLenum srcFormat, GLenum srcType, - const GLvoid *srcAddr, - const struct gl_pixelstore_attrib *srcPacking) -{ - const GLint srcRowStride = _mesa_image_row_stride(srcPacking, srcWidth, - srcFormat, srcType); - const GLint srcImageStride = _mesa_image_image_stride(srcPacking, - srcWidth, srcHeight, srcFormat, srcType); - const GLubyte *srcImage = (const GLubyte *) _mesa_image_address(dimensions, - srcPacking, srcAddr, srcWidth, srcHeight, srcFormat, srcType, 0, 0, 0); - const GLuint texelBytes = _mesa_get_format_bytes(dstFormat); - const GLint bytesPerRow = srcWidth * texelBytes; - - if (dstRowStride == srcRowStride && - dstRowStride == bytesPerRow) { - /* memcpy image by image */ - GLint img; - for (img = 0; img < srcDepth; img++) { - GLubyte *dstImage = dstSlices[img]; - memcpy(dstImage, srcImage, bytesPerRow * srcHeight); - srcImage += srcImageStride; - } - } - else { - /* memcpy row by row */ - GLint img, row; - for (img = 0; img < srcDepth; img++) { - const GLubyte *srcRow = srcImage; - GLubyte *dstRow = dstSlices[img]; - for (row = 0; row < srcHeight; row++) { - memcpy(dstRow, srcRow, bytesPerRow); - dstRow += dstRowStride; - srcRow += srcRowStride; - } - srcImage += srcImageStride; - } - } -} - - - -/** - * Store a 32-bit integer or float depth component texture image. - */ -static GLboolean -_mesa_texstore_z32(TEXSTORE_PARAMS) -{ - const GLuint depthScale = 0xffffffff; - GLenum dstType; - (void) dims; - ASSERT(dstFormat == MESA_FORMAT_Z32 || - dstFormat == MESA_FORMAT_Z32_FLOAT); - ASSERT(_mesa_get_format_bytes(dstFormat) == sizeof(GLuint)); - - if (dstFormat == MESA_FORMAT_Z32) - dstType = GL_UNSIGNED_INT; - else - dstType = GL_FLOAT; - - if (ctx->Pixel.DepthScale == 1.0f && - ctx->Pixel.DepthBias == 0.0f && - !srcPacking->SwapBytes && - baseInternalFormat == GL_DEPTH_COMPONENT && - srcFormat == GL_DEPTH_COMPONENT && - srcType == dstType) { - /* simple memcpy path */ - memcpy_texture(ctx, dims, - dstFormat, - dstRowStride, dstSlices, - srcWidth, srcHeight, srcDepth, srcFormat, srcType, - srcAddr, srcPacking); - } - else { - /* general path */ - GLint img, row; - for (img = 0; img < srcDepth; img++) { - GLubyte *dstRow = dstSlices[img]; - for (row = 0; row < srcHeight; row++) { - const GLvoid *src = _mesa_image_address(dims, srcPacking, - srcAddr, srcWidth, srcHeight, srcFormat, srcType, img, row, 0); - _mesa_unpack_depth_span(ctx, srcWidth, - dstType, dstRow, - depthScale, srcType, src, srcPacking); - dstRow += dstRowStride; - } - } - } - return GL_TRUE; -} - - -/** - * Store a 24-bit integer depth component texture image. - */ -static GLboolean -_mesa_texstore_x8_z24(TEXSTORE_PARAMS) -{ - const GLuint depthScale = 0xffffff; - - (void) dims; - ASSERT(dstFormat == MESA_FORMAT_X8_Z24); - - { - /* general path */ - GLint img, row; - for (img = 0; img < srcDepth; img++) { - GLubyte *dstRow = dstSlices[img]; - for (row = 0; row < srcHeight; row++) { - const GLvoid *src = _mesa_image_address(dims, srcPacking, - srcAddr, srcWidth, srcHeight, srcFormat, srcType, img, row, 0); - _mesa_unpack_depth_span(ctx, srcWidth, - GL_UNSIGNED_INT, (GLuint *) dstRow, - depthScale, srcType, src, srcPacking); - dstRow += dstRowStride; - } - } - } - return GL_TRUE; -} - - -/** - * Store a 24-bit integer depth component texture image. - */ -static GLboolean -_mesa_texstore_z24_x8(TEXSTORE_PARAMS) -{ - const GLuint depthScale = 0xffffff; - - (void) dims; - ASSERT(dstFormat == MESA_FORMAT_Z24_X8); - - { - /* general path */ - GLint img, row; - for (img = 0; img < srcDepth; img++) { - GLubyte *dstRow = dstSlices[img]; - for (row = 0; row < srcHeight; row++) { - const GLvoid *src = _mesa_image_address(dims, srcPacking, - srcAddr, srcWidth, srcHeight, srcFormat, srcType, img, row, 0); - GLuint *dst = (GLuint *) dstRow; - GLint i; - _mesa_unpack_depth_span(ctx, srcWidth, - GL_UNSIGNED_INT, dst, - depthScale, srcType, src, srcPacking); - for (i = 0; i < srcWidth; i++) - dst[i] <<= 8; - dstRow += dstRowStride; - } - } - } - return GL_TRUE; -} - - -/** - * Store a 16-bit integer depth component texture image. - */ -static GLboolean -_mesa_texstore_z16(TEXSTORE_PARAMS) -{ - const GLuint depthScale = 0xffff; - (void) dims; - ASSERT(dstFormat == MESA_FORMAT_Z16); - ASSERT(_mesa_get_format_bytes(dstFormat) == sizeof(GLushort)); - - if (ctx->Pixel.DepthScale == 1.0f && - ctx->Pixel.DepthBias == 0.0f && - !srcPacking->SwapBytes && - baseInternalFormat == GL_DEPTH_COMPONENT && - srcFormat == GL_DEPTH_COMPONENT && - srcType == GL_UNSIGNED_SHORT) { - /* simple memcpy path */ - memcpy_texture(ctx, dims, - dstFormat, - dstRowStride, dstSlices, - srcWidth, srcHeight, srcDepth, srcFormat, srcType, - srcAddr, srcPacking); - } - else { - /* general path */ - GLint img, row; - for (img = 0; img < srcDepth; img++) { - GLubyte *dstRow = dstSlices[img]; - for (row = 0; row < srcHeight; row++) { - const GLvoid *src = _mesa_image_address(dims, srcPacking, - srcAddr, srcWidth, srcHeight, srcFormat, srcType, img, row, 0); - GLushort *dst16 = (GLushort *) dstRow; - _mesa_unpack_depth_span(ctx, srcWidth, - GL_UNSIGNED_SHORT, dst16, depthScale, - srcType, src, srcPacking); - dstRow += dstRowStride; - } - } - } - return GL_TRUE; -} - - -/** - * Store an rgb565 or rgb565_rev texture image. - */ -static GLboolean -_mesa_texstore_rgb565(TEXSTORE_PARAMS) -{ - const GLenum baseFormat = _mesa_get_format_base_format(dstFormat); - - ASSERT(dstFormat == MESA_FORMAT_RGB565 || - dstFormat == MESA_FORMAT_RGB565_REV); - ASSERT(_mesa_get_format_bytes(dstFormat) == 2); - - if (!ctx->_ImageTransferState && - !srcPacking->SwapBytes && - dstFormat == MESA_FORMAT_RGB565 && - baseInternalFormat == GL_RGB && - srcFormat == GL_RGB && - srcType == GL_UNSIGNED_SHORT_5_6_5) { - /* simple memcpy path */ - memcpy_texture(ctx, dims, - dstFormat, - dstRowStride, dstSlices, - srcWidth, srcHeight, srcDepth, srcFormat, srcType, - srcAddr, srcPacking); - } - else if (!ctx->_ImageTransferState && - !srcPacking->SwapBytes && - baseInternalFormat == GL_RGB && - srcFormat == GL_RGB && - srcType == GL_UNSIGNED_BYTE && - dims == 2) { - /* do optimized tex store */ - const GLint srcRowStride = - _mesa_image_row_stride(srcPacking, srcWidth, srcFormat, srcType); - const GLubyte *src = (const GLubyte *) - _mesa_image_address(dims, srcPacking, srcAddr, srcWidth, srcHeight, - srcFormat, srcType, 0, 0, 0); - GLubyte *dst = dstSlices[0]; - GLint row, col; - for (row = 0; row < srcHeight; row++) { - const GLubyte *srcUB = (const GLubyte *) src; - GLushort *dstUS = (GLushort *) dst; - /* check for byteswapped format */ - if (dstFormat == MESA_FORMAT_RGB565) { - for (col = 0; col < srcWidth; col++) { - dstUS[col] = PACK_COLOR_565( srcUB[0], srcUB[1], srcUB[2] ); - srcUB += 3; - } - } - else { - for (col = 0; col < srcWidth; col++) { - dstUS[col] = PACK_COLOR_565_REV( srcUB[0], srcUB[1], srcUB[2] ); - srcUB += 3; - } - } - dst += dstRowStride; - src += srcRowStride; - } - } - else { - /* general path */ - const GLubyte *tempImage = _mesa_make_temp_ubyte_image(ctx, dims, - baseInternalFormat, - baseFormat, - srcWidth, srcHeight, srcDepth, - srcFormat, srcType, srcAddr, - srcPacking); - const GLubyte *src = tempImage; - GLint img, row, col; - if (!tempImage) - return GL_FALSE; - for (img = 0; img < srcDepth; img++) { - GLubyte *dstRow = dstSlices[img]; - for (row = 0; row < srcHeight; row++) { - GLushort *dstUS = (GLushort *) dstRow; - /* check for byteswapped format */ - if (dstFormat == MESA_FORMAT_RGB565) { - for (col = 0; col < srcWidth; col++) { - dstUS[col] = PACK_COLOR_565( src[RCOMP], - src[GCOMP], - src[BCOMP] ); - src += 3; - } - } - else { - for (col = 0; col < srcWidth; col++) { - dstUS[col] = PACK_COLOR_565_REV( src[RCOMP], - src[GCOMP], - src[BCOMP] ); - src += 3; - } - } - dstRow += dstRowStride; - } - } - free((void *) tempImage); - } - return GL_TRUE; -} - - -/** - * Store a texture in MESA_FORMAT_RGBA8888 or MESA_FORMAT_RGBA8888_REV. - */ -static GLboolean -_mesa_texstore_rgba8888(TEXSTORE_PARAMS) -{ - const GLboolean littleEndian = _mesa_little_endian(); - const GLenum baseFormat = _mesa_get_format_base_format(dstFormat); - - ASSERT(dstFormat == MESA_FORMAT_RGBA8888 || - dstFormat == MESA_FORMAT_RGBA8888_REV || - dstFormat == MESA_FORMAT_RGBX8888 || - dstFormat == MESA_FORMAT_RGBX8888_REV); - ASSERT(_mesa_get_format_bytes(dstFormat) == 4); - - if (!ctx->_ImageTransferState && - !srcPacking->SwapBytes && - (dstFormat == MESA_FORMAT_RGBA8888 || - dstFormat == MESA_FORMAT_RGBX8888) && - baseInternalFormat == GL_RGBA && - ((srcFormat == GL_RGBA && srcType == GL_UNSIGNED_INT_8_8_8_8) || - (srcFormat == GL_RGBA && srcType == GL_UNSIGNED_BYTE && !littleEndian) || - (srcFormat == GL_ABGR_EXT && srcType == GL_UNSIGNED_INT_8_8_8_8_REV) || - (srcFormat == GL_ABGR_EXT && srcType == GL_UNSIGNED_BYTE && littleEndian))) { - /* simple memcpy path */ - memcpy_texture(ctx, dims, - dstFormat, - dstRowStride, dstSlices, - srcWidth, srcHeight, srcDepth, srcFormat, srcType, - srcAddr, srcPacking); - } - else if (!ctx->_ImageTransferState && - !srcPacking->SwapBytes && - (dstFormat == MESA_FORMAT_RGBA8888_REV || - dstFormat == MESA_FORMAT_RGBX8888_REV) && - baseInternalFormat == GL_RGBA && - ((srcFormat == GL_RGBA && srcType == GL_UNSIGNED_INT_8_8_8_8_REV) || - (srcFormat == GL_RGBA && srcType == GL_UNSIGNED_BYTE && littleEndian) || - (srcFormat == GL_ABGR_EXT && srcType == GL_UNSIGNED_INT_8_8_8_8) || - (srcFormat == GL_ABGR_EXT && srcType == GL_UNSIGNED_BYTE && !littleEndian))) { - /* simple memcpy path */ - memcpy_texture(ctx, dims, - dstFormat, - dstRowStride, dstSlices, - srcWidth, srcHeight, srcDepth, srcFormat, srcType, - srcAddr, srcPacking); - } - else if (!ctx->_ImageTransferState && - (srcType == GL_UNSIGNED_BYTE || - srcType == GL_UNSIGNED_INT_8_8_8_8 || - srcType == GL_UNSIGNED_INT_8_8_8_8_REV) && - can_swizzle(baseInternalFormat) && - can_swizzle(srcFormat)) { - - GLubyte dstmap[4]; - - /* dstmap - how to swizzle from RGBA to dst format: - */ - if ((littleEndian && (dstFormat == MESA_FORMAT_RGBA8888 || - dstFormat == MESA_FORMAT_RGBX8888)) || - (!littleEndian && (dstFormat == MESA_FORMAT_RGBA8888_REV || - dstFormat == MESA_FORMAT_RGBX8888_REV))) { - dstmap[3] = 0; - dstmap[2] = 1; - dstmap[1] = 2; - dstmap[0] = 3; - } - else { - dstmap[3] = 3; - dstmap[2] = 2; - dstmap[1] = 1; - dstmap[0] = 0; - } - - _mesa_swizzle_ubyte_image(ctx, dims, - srcFormat, - srcType, - baseInternalFormat, - dstmap, 4, - dstRowStride, dstSlices, - srcWidth, srcHeight, srcDepth, srcAddr, - srcPacking); - } - else { - /* general path */ - const GLubyte *tempImage = _mesa_make_temp_ubyte_image(ctx, dims, - baseInternalFormat, - baseFormat, - srcWidth, srcHeight, srcDepth, - srcFormat, srcType, srcAddr, - srcPacking); - const GLubyte *src = tempImage; - GLint img, row, col; - if (!tempImage) - return GL_FALSE; - for (img = 0; img < srcDepth; img++) { - GLubyte *dstRow = dstSlices[img]; - for (row = 0; row < srcHeight; row++) { - GLuint *dstUI = (GLuint *) dstRow; - if (dstFormat == MESA_FORMAT_RGBA8888 || - dstFormat == MESA_FORMAT_RGBX8888) { - for (col = 0; col < srcWidth; col++) { - dstUI[col] = PACK_COLOR_8888( src[RCOMP], - src[GCOMP], - src[BCOMP], - src[ACOMP] ); - src += 4; - } - } - else { - for (col = 0; col < srcWidth; col++) { - dstUI[col] = PACK_COLOR_8888_REV( src[RCOMP], - src[GCOMP], - src[BCOMP], - src[ACOMP] ); - src += 4; - } - } - dstRow += dstRowStride; - } - } - free((void *) tempImage); - } - return GL_TRUE; -} - - -static GLboolean -_mesa_texstore_argb8888(TEXSTORE_PARAMS) -{ - const GLboolean littleEndian = _mesa_little_endian(); - const GLenum baseFormat = GL_RGBA; - - ASSERT(dstFormat == MESA_FORMAT_ARGB8888 || - dstFormat == MESA_FORMAT_ARGB8888_REV || - dstFormat == MESA_FORMAT_XRGB8888 || - dstFormat == MESA_FORMAT_XRGB8888_REV ); - ASSERT(_mesa_get_format_bytes(dstFormat) == 4); - - if (!ctx->_ImageTransferState && - !srcPacking->SwapBytes && - (dstFormat == MESA_FORMAT_ARGB8888 || - dstFormat == MESA_FORMAT_XRGB8888) && - baseInternalFormat == GL_RGBA && - srcFormat == GL_BGRA && - ((srcType == GL_UNSIGNED_BYTE && littleEndian) || - srcType == GL_UNSIGNED_INT_8_8_8_8_REV)) { - /* simple memcpy path (little endian) */ - memcpy_texture(ctx, dims, - dstFormat, - dstRowStride, dstSlices, - srcWidth, srcHeight, srcDepth, srcFormat, srcType, - srcAddr, srcPacking); - } - else if (!ctx->_ImageTransferState && - !srcPacking->SwapBytes && - (dstFormat == MESA_FORMAT_ARGB8888_REV || - dstFormat == MESA_FORMAT_XRGB8888_REV) && - baseInternalFormat == GL_RGBA && - srcFormat == GL_BGRA && - ((srcType == GL_UNSIGNED_BYTE && !littleEndian) || - srcType == GL_UNSIGNED_INT_8_8_8_8)) { - /* simple memcpy path (big endian) */ - memcpy_texture(ctx, dims, - dstFormat, - dstRowStride, dstSlices, - srcWidth, srcHeight, srcDepth, srcFormat, srcType, - srcAddr, srcPacking); - } - else if (!ctx->_ImageTransferState && - !srcPacking->SwapBytes && - (dstFormat == MESA_FORMAT_ARGB8888 || - dstFormat == MESA_FORMAT_XRGB8888) && - srcFormat == GL_RGB && - (baseInternalFormat == GL_RGBA || - baseInternalFormat == GL_RGB) && - srcType == GL_UNSIGNED_BYTE) { - int img, row, col; - for (img = 0; img < srcDepth; img++) { - const GLint srcRowStride = - _mesa_image_row_stride(srcPacking, srcWidth, srcFormat, srcType); - GLubyte *srcRow = (GLubyte *) _mesa_image_address(dims, srcPacking, - srcAddr, srcWidth, srcHeight, srcFormat, srcType, img, 0, 0); - GLubyte *dstRow = dstSlices[img]; - for (row = 0; row < srcHeight; row++) { - GLuint *d4 = (GLuint *) dstRow; - for (col = 0; col < srcWidth; col++) { - d4[col] = PACK_COLOR_8888(0xff, - srcRow[col * 3 + RCOMP], - srcRow[col * 3 + GCOMP], - srcRow[col * 3 + BCOMP]); - } - dstRow += dstRowStride; - srcRow += srcRowStride; - } - } - } - else if (!ctx->_ImageTransferState && - !srcPacking->SwapBytes && - dstFormat == MESA_FORMAT_ARGB8888 && - srcFormat == GL_RGBA && - baseInternalFormat == GL_RGBA && - srcType == GL_UNSIGNED_BYTE) { - /* same as above case, but src data has alpha too */ - GLint img, row, col; - /* For some reason, streaming copies to write-combined regions - * are extremely sensitive to the characteristics of how the - * source data is retrieved. By reordering the source reads to - * be in-order, the speed of this operation increases by half. - * Strangely the same isn't required for the RGB path, above. - */ - for (img = 0; img < srcDepth; img++) { - const GLint srcRowStride = - _mesa_image_row_stride(srcPacking, srcWidth, srcFormat, srcType); - GLubyte *srcRow = (GLubyte *) _mesa_image_address(dims, srcPacking, - srcAddr, srcWidth, srcHeight, srcFormat, srcType, img, 0, 0); - GLubyte *dstRow = dstSlices[img]; - for (row = 0; row < srcHeight; row++) { - GLuint *d4 = (GLuint *) dstRow; - for (col = 0; col < srcWidth; col++) { - d4[col] = PACK_COLOR_8888(srcRow[col * 4 + ACOMP], - srcRow[col * 4 + RCOMP], - srcRow[col * 4 + GCOMP], - srcRow[col * 4 + BCOMP]); - } - dstRow += dstRowStride; - srcRow += srcRowStride; - } - } - } - else if (!ctx->_ImageTransferState && - (srcType == GL_UNSIGNED_BYTE || - srcType == GL_UNSIGNED_INT_8_8_8_8 || - srcType == GL_UNSIGNED_INT_8_8_8_8_REV) && - can_swizzle(baseInternalFormat) && - can_swizzle(srcFormat)) { - - GLubyte dstmap[4]; - - /* dstmap - how to swizzle from RGBA to dst format: - */ - if ((littleEndian && dstFormat == MESA_FORMAT_ARGB8888) || - (littleEndian && dstFormat == MESA_FORMAT_XRGB8888) || - (!littleEndian && dstFormat == MESA_FORMAT_ARGB8888_REV) || - (!littleEndian && dstFormat == MESA_FORMAT_XRGB8888_REV)) { - dstmap[3] = 3; /* alpha */ - dstmap[2] = 0; /* red */ - dstmap[1] = 1; /* green */ - dstmap[0] = 2; /* blue */ - } - else { - assert((littleEndian && dstFormat == MESA_FORMAT_ARGB8888_REV) || - (!littleEndian && dstFormat == MESA_FORMAT_ARGB8888) || - (littleEndian && dstFormat == MESA_FORMAT_XRGB8888_REV) || - (!littleEndian && dstFormat == MESA_FORMAT_XRGB8888)); - dstmap[3] = 2; - dstmap[2] = 1; - dstmap[1] = 0; - dstmap[0] = 3; - } - - _mesa_swizzle_ubyte_image(ctx, dims, - srcFormat, - srcType, - baseInternalFormat, - dstmap, 4, - dstRowStride, - dstSlices, - srcWidth, srcHeight, srcDepth, srcAddr, - srcPacking); - } - else { - /* general path */ - const GLubyte *tempImage = _mesa_make_temp_ubyte_image(ctx, dims, - baseInternalFormat, - baseFormat, - srcWidth, srcHeight, srcDepth, - srcFormat, srcType, srcAddr, - srcPacking); - const GLubyte *src = tempImage; - GLint img, row, col; - if (!tempImage) - return GL_FALSE; - for (img = 0; img < srcDepth; img++) { - GLubyte *dstRow = dstSlices[img]; - for (row = 0; row < srcHeight; row++) { - GLuint *dstUI = (GLuint *) dstRow; - if (dstFormat == MESA_FORMAT_ARGB8888) { - for (col = 0; col < srcWidth; col++) { - dstUI[col] = PACK_COLOR_8888( src[ACOMP], - src[RCOMP], - src[GCOMP], - src[BCOMP] ); - src += 4; - } - } - else if (dstFormat == MESA_FORMAT_XRGB8888) { - for (col = 0; col < srcWidth; col++) { - dstUI[col] = PACK_COLOR_8888( 0xff, - src[RCOMP], - src[GCOMP], - src[BCOMP] ); - src += 4; - } - } - else { - for (col = 0; col < srcWidth; col++) { - dstUI[col] = PACK_COLOR_8888_REV( src[ACOMP], - src[RCOMP], - src[GCOMP], - src[BCOMP] ); - src += 4; - } - } - dstRow += dstRowStride; - } - } - free((void *) tempImage); - } - return GL_TRUE; -} - - -static GLboolean -_mesa_texstore_rgb888(TEXSTORE_PARAMS) -{ - const GLboolean littleEndian = _mesa_little_endian(); - const GLenum baseFormat = _mesa_get_format_base_format(dstFormat); - - ASSERT(dstFormat == MESA_FORMAT_RGB888); - ASSERT(_mesa_get_format_bytes(dstFormat) == 3); - - if (!ctx->_ImageTransferState && - !srcPacking->SwapBytes && - baseInternalFormat == GL_RGB && - srcFormat == GL_BGR && - srcType == GL_UNSIGNED_BYTE && - littleEndian) { - /* simple memcpy path */ - memcpy_texture(ctx, dims, - dstFormat, - dstRowStride, dstSlices, - srcWidth, srcHeight, srcDepth, srcFormat, srcType, - srcAddr, srcPacking); - } - else if (!ctx->_ImageTransferState && - !srcPacking->SwapBytes && - srcFormat == GL_RGBA && - srcType == GL_UNSIGNED_BYTE) { - /* extract RGB from RGBA */ - GLint img, row, col; - for (img = 0; img < srcDepth; img++) { - const GLint srcRowStride = - _mesa_image_row_stride(srcPacking, srcWidth, srcFormat, srcType); - GLubyte *srcRow = (GLubyte *) _mesa_image_address(dims, srcPacking, - srcAddr, srcWidth, srcHeight, srcFormat, srcType, img, 0, 0); - GLubyte *dstRow = dstSlices[img]; - for (row = 0; row < srcHeight; row++) { - for (col = 0; col < srcWidth; col++) { - dstRow[col * 3 + 0] = srcRow[col * 4 + BCOMP]; - dstRow[col * 3 + 1] = srcRow[col * 4 + GCOMP]; - dstRow[col * 3 + 2] = srcRow[col * 4 + RCOMP]; - } - dstRow += dstRowStride; - srcRow += srcRowStride; - } - } - } - else if (!ctx->_ImageTransferState && - srcType == GL_UNSIGNED_BYTE && - can_swizzle(baseInternalFormat) && - can_swizzle(srcFormat)) { - - GLubyte dstmap[4]; - - /* dstmap - how to swizzle from RGBA to dst format: - */ - dstmap[0] = 2; - dstmap[1] = 1; - dstmap[2] = 0; - dstmap[3] = ONE; /* ? */ - - _mesa_swizzle_ubyte_image(ctx, dims, - srcFormat, - srcType, - baseInternalFormat, - dstmap, 3, - dstRowStride, dstSlices, - srcWidth, srcHeight, srcDepth, srcAddr, - srcPacking); - } - else { - /* general path */ - const GLubyte *tempImage = _mesa_make_temp_ubyte_image(ctx, dims, - baseInternalFormat, - baseFormat, - srcWidth, srcHeight, srcDepth, - srcFormat, srcType, srcAddr, - srcPacking); - const GLubyte *src = (const GLubyte *) tempImage; - GLint img, row, col; - if (!tempImage) - return GL_FALSE; - for (img = 0; img < srcDepth; img++) { - GLubyte *dstRow = dstSlices[img]; - for (row = 0; row < srcHeight; row++) { -#if 0 - if (littleEndian) { - for (col = 0; col < srcWidth; col++) { - dstRow[col * 3 + 0] = src[RCOMP]; - dstRow[col * 3 + 1] = src[GCOMP]; - dstRow[col * 3 + 2] = src[BCOMP]; - srcUB += 3; - } - } - else { - for (col = 0; col < srcWidth; col++) { - dstRow[col * 3 + 0] = srcUB[BCOMP]; - dstRow[col * 3 + 1] = srcUB[GCOMP]; - dstRow[col * 3 + 2] = srcUB[RCOMP]; - srcUB += 3; - } - } -#else - for (col = 0; col < srcWidth; col++) { - dstRow[col * 3 + 0] = src[BCOMP]; - dstRow[col * 3 + 1] = src[GCOMP]; - dstRow[col * 3 + 2] = src[RCOMP]; - src += 3; - } -#endif - dstRow += dstRowStride; - } - } - free((void *) tempImage); - } - return GL_TRUE; -} - - -static GLboolean -_mesa_texstore_bgr888(TEXSTORE_PARAMS) -{ - const GLboolean littleEndian = _mesa_little_endian(); - const GLenum baseFormat = _mesa_get_format_base_format(dstFormat); - - ASSERT(dstFormat == MESA_FORMAT_BGR888); - ASSERT(_mesa_get_format_bytes(dstFormat) == 3); - - if (!ctx->_ImageTransferState && - !srcPacking->SwapBytes && - baseInternalFormat == GL_RGB && - srcFormat == GL_RGB && - srcType == GL_UNSIGNED_BYTE && - littleEndian) { - /* simple memcpy path */ - memcpy_texture(ctx, dims, - dstFormat, - dstRowStride, dstSlices, - srcWidth, srcHeight, srcDepth, srcFormat, srcType, - srcAddr, srcPacking); - } - else if (!ctx->_ImageTransferState && - !srcPacking->SwapBytes && - srcFormat == GL_RGBA && - srcType == GL_UNSIGNED_BYTE) { - /* extract BGR from RGBA */ - int img, row, col; - for (img = 0; img < srcDepth; img++) { - const GLint srcRowStride = - _mesa_image_row_stride(srcPacking, srcWidth, srcFormat, srcType); - GLubyte *srcRow = (GLubyte *) _mesa_image_address(dims, srcPacking, - srcAddr, srcWidth, srcHeight, srcFormat, srcType, img, 0, 0); - GLubyte *dstRow = dstSlices[img]; - for (row = 0; row < srcHeight; row++) { - for (col = 0; col < srcWidth; col++) { - dstRow[col * 3 + 0] = srcRow[col * 4 + RCOMP]; - dstRow[col * 3 + 1] = srcRow[col * 4 + GCOMP]; - dstRow[col * 3 + 2] = srcRow[col * 4 + BCOMP]; - } - dstRow += dstRowStride; - srcRow += srcRowStride; - } - } - } - else if (!ctx->_ImageTransferState && - srcType == GL_UNSIGNED_BYTE && - can_swizzle(baseInternalFormat) && - can_swizzle(srcFormat)) { - - GLubyte dstmap[4]; - - /* dstmap - how to swizzle from RGBA to dst format: - */ - dstmap[0] = 0; - dstmap[1] = 1; - dstmap[2] = 2; - dstmap[3] = ONE; /* ? */ - - _mesa_swizzle_ubyte_image(ctx, dims, - srcFormat, - srcType, - baseInternalFormat, - dstmap, 3, - dstRowStride, dstSlices, - srcWidth, srcHeight, srcDepth, srcAddr, - srcPacking); - } - else { - /* general path */ - const GLubyte *tempImage = _mesa_make_temp_ubyte_image(ctx, dims, - baseInternalFormat, - baseFormat, - srcWidth, srcHeight, srcDepth, - srcFormat, srcType, srcAddr, - srcPacking); - const GLubyte *src = (const GLubyte *) tempImage; - GLint img, row, col; - if (!tempImage) - return GL_FALSE; - for (img = 0; img < srcDepth; img++) { - GLubyte *dstRow = dstSlices[img]; - for (row = 0; row < srcHeight; row++) { - for (col = 0; col < srcWidth; col++) { - dstRow[col * 3 + 0] = src[RCOMP]; - dstRow[col * 3 + 1] = src[GCOMP]; - dstRow[col * 3 + 2] = src[BCOMP]; - src += 3; - } - dstRow += dstRowStride; - } - } - free((void *) tempImage); - } - return GL_TRUE; -} - - -static GLboolean -_mesa_texstore_argb4444(TEXSTORE_PARAMS) -{ - const GLenum baseFormat = _mesa_get_format_base_format(dstFormat); - - ASSERT(dstFormat == MESA_FORMAT_ARGB4444 || - dstFormat == MESA_FORMAT_ARGB4444_REV); - ASSERT(_mesa_get_format_bytes(dstFormat) == 2); - - if (!ctx->_ImageTransferState && - !srcPacking->SwapBytes && - dstFormat == MESA_FORMAT_ARGB4444 && - baseInternalFormat == GL_RGBA && - srcFormat == GL_BGRA && - srcType == GL_UNSIGNED_SHORT_4_4_4_4_REV) { - /* simple memcpy path */ - memcpy_texture(ctx, dims, - dstFormat, - dstRowStride, dstSlices, - srcWidth, srcHeight, srcDepth, srcFormat, srcType, - srcAddr, srcPacking); - } - else { - /* general path */ - const GLubyte *tempImage = _mesa_make_temp_ubyte_image(ctx, dims, - baseInternalFormat, - baseFormat, - srcWidth, srcHeight, srcDepth, - srcFormat, srcType, srcAddr, - srcPacking); - const GLubyte *src = tempImage; - GLint img, row, col; - if (!tempImage) - return GL_FALSE; - for (img = 0; img < srcDepth; img++) { - GLubyte *dstRow = dstSlices[img]; - for (row = 0; row < srcHeight; row++) { - GLushort *dstUS = (GLushort *) dstRow; - if (dstFormat == MESA_FORMAT_ARGB4444) { - for (col = 0; col < srcWidth; col++) { - dstUS[col] = PACK_COLOR_4444( src[ACOMP], - src[RCOMP], - src[GCOMP], - src[BCOMP] ); - src += 4; - } - } - else { - for (col = 0; col < srcWidth; col++) { - dstUS[col] = PACK_COLOR_4444_REV( src[ACOMP], - src[RCOMP], - src[GCOMP], - src[BCOMP] ); - src += 4; - } - } - dstRow += dstRowStride; - } - } - free((void *) tempImage); - } - return GL_TRUE; -} - -static GLboolean -_mesa_texstore_rgba5551(TEXSTORE_PARAMS) -{ - const GLenum baseFormat = _mesa_get_format_base_format(dstFormat); - - ASSERT(dstFormat == MESA_FORMAT_RGBA5551); - ASSERT(_mesa_get_format_bytes(dstFormat) == 2); - - if (!ctx->_ImageTransferState && - !srcPacking->SwapBytes && - dstFormat == MESA_FORMAT_RGBA5551 && - baseInternalFormat == GL_RGBA && - srcFormat == GL_RGBA && - srcType == GL_UNSIGNED_SHORT_5_5_5_1) { - /* simple memcpy path */ - memcpy_texture(ctx, dims, - dstFormat, - dstRowStride, dstSlices, - srcWidth, srcHeight, srcDepth, srcFormat, srcType, - srcAddr, srcPacking); - } - else { - /* general path */ - const GLubyte *tempImage = _mesa_make_temp_ubyte_image(ctx, dims, - baseInternalFormat, - baseFormat, - srcWidth, srcHeight, srcDepth, - srcFormat, srcType, srcAddr, - srcPacking); - const GLubyte *src =tempImage; - GLint img, row, col; - if (!tempImage) - return GL_FALSE; - for (img = 0; img < srcDepth; img++) { - GLubyte *dstRow = dstSlices[img]; - for (row = 0; row < srcHeight; row++) { - GLushort *dstUS = (GLushort *) dstRow; - for (col = 0; col < srcWidth; col++) { - dstUS[col] = PACK_COLOR_5551( src[RCOMP], - src[GCOMP], - src[BCOMP], - src[ACOMP] ); - src += 4; - } - dstRow += dstRowStride; - } - } - free((void *) tempImage); - } - return GL_TRUE; -} - -static GLboolean -_mesa_texstore_argb1555(TEXSTORE_PARAMS) -{ - const GLenum baseFormat = _mesa_get_format_base_format(dstFormat); - - ASSERT(dstFormat == MESA_FORMAT_ARGB1555 || - dstFormat == MESA_FORMAT_ARGB1555_REV); - ASSERT(_mesa_get_format_bytes(dstFormat) == 2); - - if (!ctx->_ImageTransferState && - !srcPacking->SwapBytes && - dstFormat == MESA_FORMAT_ARGB1555 && - baseInternalFormat == GL_RGBA && - srcFormat == GL_BGRA && - srcType == GL_UNSIGNED_SHORT_1_5_5_5_REV) { - /* simple memcpy path */ - memcpy_texture(ctx, dims, - dstFormat, - dstRowStride, dstSlices, - srcWidth, srcHeight, srcDepth, srcFormat, srcType, - srcAddr, srcPacking); - } - else { - /* general path */ - const GLubyte *tempImage = _mesa_make_temp_ubyte_image(ctx, dims, - baseInternalFormat, - baseFormat, - srcWidth, srcHeight, srcDepth, - srcFormat, srcType, srcAddr, - srcPacking); - const GLubyte *src =tempImage; - GLint img, row, col; - if (!tempImage) - return GL_FALSE; - for (img = 0; img < srcDepth; img++) { - GLubyte *dstRow = dstSlices[img]; - for (row = 0; row < srcHeight; row++) { - GLushort *dstUS = (GLushort *) dstRow; - if (dstFormat == MESA_FORMAT_ARGB1555) { - for (col = 0; col < srcWidth; col++) { - dstUS[col] = PACK_COLOR_1555( src[ACOMP], - src[RCOMP], - src[GCOMP], - src[BCOMP] ); - src += 4; - } - } - else { - for (col = 0; col < srcWidth; col++) { - dstUS[col] = PACK_COLOR_1555_REV( src[ACOMP], - src[RCOMP], - src[GCOMP], - src[BCOMP] ); - src += 4; - } - } - dstRow += dstRowStride; - } - } - free((void *) tempImage); - } - return GL_TRUE; -} - -/** - * Do texstore for 2-channel, 4-bit/channel, unsigned normalized formats. - */ -static GLboolean -_mesa_texstore_unorm44(TEXSTORE_PARAMS) -{ - const GLenum baseFormat = _mesa_get_format_base_format(dstFormat); - - ASSERT(dstFormat == MESA_FORMAT_AL44); - ASSERT(_mesa_get_format_bytes(dstFormat) == 1); - - { - /* general path */ - const GLubyte *tempImage = _mesa_make_temp_ubyte_image(ctx, dims, - baseInternalFormat, - baseFormat, - srcWidth, srcHeight, srcDepth, - srcFormat, srcType, srcAddr, - srcPacking); - const GLubyte *src = tempImage; - GLint img, row, col; - if (!tempImage) - return GL_FALSE; - for (img = 0; img < srcDepth; img++) { - GLubyte *dstRow = dstSlices[img]; - for (row = 0; row < srcHeight; row++) { - GLubyte *dstUS = (GLubyte *) dstRow; - for (col = 0; col < srcWidth; col++) { - /* src[0] is luminance, src[1] is alpha */ - dstUS[col] = PACK_COLOR_44( src[1], - src[0] ); - src += 2; - } - dstRow += dstRowStride; - } - } - free((void *) tempImage); - } - return GL_TRUE; -} - - -/** - * Do texstore for 2-channel, 8-bit/channel, unsigned normalized formats. - */ -static GLboolean -_mesa_texstore_unorm88(TEXSTORE_PARAMS) -{ - const GLboolean littleEndian = _mesa_little_endian(); - const GLenum baseFormat = _mesa_get_format_base_format(dstFormat); - - ASSERT(dstFormat == MESA_FORMAT_AL88 || - dstFormat == MESA_FORMAT_AL88_REV); - ASSERT(_mesa_get_format_bytes(dstFormat) == 2); - - if (!ctx->_ImageTransferState && - !srcPacking->SwapBytes && - (dstFormat == MESA_FORMAT_AL88 && - baseInternalFormat == GL_LUMINANCE_ALPHA && - srcFormat == GL_LUMINANCE_ALPHA) && - srcType == GL_UNSIGNED_BYTE && - littleEndian) { - /* simple memcpy path */ - memcpy_texture(ctx, dims, - dstFormat, - dstRowStride, dstSlices, - srcWidth, srcHeight, srcDepth, srcFormat, srcType, - srcAddr, srcPacking); - } - else if (!ctx->_ImageTransferState && - littleEndian && - srcType == GL_UNSIGNED_BYTE && - can_swizzle(baseInternalFormat) && - can_swizzle(srcFormat)) { - GLubyte dstmap[4]; - - /* dstmap - how to swizzle from RGBA to dst format: - */ - if (dstFormat == MESA_FORMAT_AL88 || dstFormat == MESA_FORMAT_AL88_REV) { - if ((littleEndian && dstFormat == MESA_FORMAT_AL88) || - (!littleEndian && dstFormat == MESA_FORMAT_AL88_REV)) { - dstmap[0] = 0; - dstmap[1] = 3; - } - else { - dstmap[0] = 3; - dstmap[1] = 0; - } - } - dstmap[2] = ZERO; /* ? */ - dstmap[3] = ONE; /* ? */ - - _mesa_swizzle_ubyte_image(ctx, dims, - srcFormat, - srcType, - baseInternalFormat, - dstmap, 2, - dstRowStride, dstSlices, - srcWidth, srcHeight, srcDepth, srcAddr, - srcPacking); - } - else { - /* general path */ - const GLubyte *tempImage = _mesa_make_temp_ubyte_image(ctx, dims, - baseInternalFormat, - baseFormat, - srcWidth, srcHeight, srcDepth, - srcFormat, srcType, srcAddr, - srcPacking); - const GLubyte *src = tempImage; - GLint img, row, col; - if (!tempImage) - return GL_FALSE; - for (img = 0; img < srcDepth; img++) { - GLubyte *dstRow = dstSlices[img]; - for (row = 0; row < srcHeight; row++) { - GLushort *dstUS = (GLushort *) dstRow; - if (dstFormat == MESA_FORMAT_AL88) { - for (col = 0; col < srcWidth; col++) { - /* src[0] is luminance (or R), src[1] is alpha (or G) */ - dstUS[col] = PACK_COLOR_88( src[1], - src[0] ); - src += 2; - } - } - else { - for (col = 0; col < srcWidth; col++) { - /* src[0] is luminance (or R), src[1] is alpha (or G) */ - dstUS[col] = PACK_COLOR_88_REV( src[1], - src[0] ); - src += 2; - } - } - dstRow += dstRowStride; - } - } - free((void *) tempImage); - } - return GL_TRUE; -} - - -/** - * Do texstore for 2-channel, 16-bit/channel, unsigned normalized formats. - */ -static GLboolean -_mesa_texstore_unorm1616(TEXSTORE_PARAMS) -{ - const GLboolean littleEndian = _mesa_little_endian(); - const GLenum baseFormat = _mesa_get_format_base_format(dstFormat); - - ASSERT(dstFormat == MESA_FORMAT_AL1616 || - dstFormat == MESA_FORMAT_AL1616_REV || - dstFormat == MESA_FORMAT_RG1616 || - dstFormat == MESA_FORMAT_RG1616_REV); - ASSERT(_mesa_get_format_bytes(dstFormat) == 4); - - if (!ctx->_ImageTransferState && - !srcPacking->SwapBytes && - (dstFormat == MESA_FORMAT_AL1616 && - baseInternalFormat == GL_LUMINANCE_ALPHA && - srcFormat == GL_LUMINANCE_ALPHA) && - srcType == GL_UNSIGNED_SHORT && - littleEndian) { - /* simple memcpy path */ - memcpy_texture(ctx, dims, - dstFormat, - dstRowStride, dstSlices, - srcWidth, srcHeight, srcDepth, srcFormat, srcType, - srcAddr, srcPacking); - } - else { - /* general path */ - const GLfloat *tempImage = _mesa_make_temp_float_image(ctx, dims, - baseInternalFormat, - baseFormat, - srcWidth, srcHeight, srcDepth, - srcFormat, srcType, srcAddr, - srcPacking, - ctx->_ImageTransferState); - const GLfloat *src = tempImage; - GLint img, row, col; - if (!tempImage) - return GL_FALSE; - for (img = 0; img < srcDepth; img++) { - GLubyte *dstRow = dstSlices[img]; - for (row = 0; row < srcHeight; row++) { - GLuint *dstUI = (GLuint *) dstRow; - if (dstFormat == MESA_FORMAT_AL1616) { - for (col = 0; col < srcWidth; col++) { - GLushort l, a; - - UNCLAMPED_FLOAT_TO_USHORT(l, src[0]); - UNCLAMPED_FLOAT_TO_USHORT(a, src[1]); - dstUI[col] = PACK_COLOR_1616(a, l); - src += 2; - } - } - else { - for (col = 0; col < srcWidth; col++) { - GLushort l, a; - - UNCLAMPED_FLOAT_TO_USHORT(l, src[0]); - UNCLAMPED_FLOAT_TO_USHORT(a, src[1]); - dstUI[col] = PACK_COLOR_1616_REV(a, l); - src += 2; - } - } - dstRow += dstRowStride; - } - } - free((void *) tempImage); - } - return GL_TRUE; -} - - -/* Texstore for R16, A16, L16, I16. */ -static GLboolean -_mesa_texstore_unorm16(TEXSTORE_PARAMS) -{ - const GLboolean littleEndian = _mesa_little_endian(); - const GLenum baseFormat = _mesa_get_format_base_format(dstFormat); - - ASSERT(dstFormat == MESA_FORMAT_R16 || - dstFormat == MESA_FORMAT_A16 || - dstFormat == MESA_FORMAT_L16 || - dstFormat == MESA_FORMAT_I16); - ASSERT(_mesa_get_format_bytes(dstFormat) == 2); - - if (!ctx->_ImageTransferState && - !srcPacking->SwapBytes && - baseInternalFormat == srcFormat && - srcType == GL_UNSIGNED_SHORT && - littleEndian) { - /* simple memcpy path */ - memcpy_texture(ctx, dims, - dstFormat, - dstRowStride, dstSlices, - srcWidth, srcHeight, srcDepth, srcFormat, srcType, - srcAddr, srcPacking); - } - else { - /* general path */ - const GLfloat *tempImage = _mesa_make_temp_float_image(ctx, dims, - baseInternalFormat, - baseFormat, - srcWidth, srcHeight, srcDepth, - srcFormat, srcType, srcAddr, - srcPacking, - ctx->_ImageTransferState); - const GLfloat *src = tempImage; - GLint img, row, col; - if (!tempImage) - return GL_FALSE; - for (img = 0; img < srcDepth; img++) { - GLubyte *dstRow = dstSlices[img]; - for (row = 0; row < srcHeight; row++) { - GLushort *dstUS = (GLushort *) dstRow; - for (col = 0; col < srcWidth; col++) { - GLushort r; - - UNCLAMPED_FLOAT_TO_USHORT(r, src[0]); - dstUS[col] = r; - src += 1; - } - dstRow += dstRowStride; - } - } - free((void *) tempImage); - } - return GL_TRUE; -} - - -static GLboolean -_mesa_texstore_rgba_16(TEXSTORE_PARAMS) -{ - const GLenum baseFormat = _mesa_get_format_base_format(dstFormat); - - ASSERT(dstFormat == MESA_FORMAT_RGBA_16); - ASSERT(_mesa_get_format_bytes(dstFormat) == 8); - - if (!ctx->_ImageTransferState && - !srcPacking->SwapBytes && - baseInternalFormat == GL_RGBA && - srcFormat == GL_RGBA && - srcType == GL_UNSIGNED_SHORT) { - /* simple memcpy path */ - memcpy_texture(ctx, dims, - dstFormat, - dstRowStride, dstSlices, - srcWidth, srcHeight, srcDepth, srcFormat, srcType, - srcAddr, srcPacking); - } - else { - /* general path */ - const GLfloat *tempImage = _mesa_make_temp_float_image(ctx, dims, - baseInternalFormat, - baseFormat, - srcWidth, srcHeight, srcDepth, - srcFormat, srcType, srcAddr, - srcPacking, - ctx->_ImageTransferState); - const GLfloat *src = tempImage; - GLint img, row, col; - if (!tempImage) - return GL_FALSE; - for (img = 0; img < srcDepth; img++) { - GLubyte *dstRow = dstSlices[img]; - for (row = 0; row < srcHeight; row++) { - GLushort *dstUS = (GLushort *) dstRow; - for (col = 0; col < srcWidth; col++) { - GLushort r, g, b, a; - - UNCLAMPED_FLOAT_TO_USHORT(r, src[0]); - UNCLAMPED_FLOAT_TO_USHORT(g, src[1]); - UNCLAMPED_FLOAT_TO_USHORT(b, src[2]); - UNCLAMPED_FLOAT_TO_USHORT(a, src[3]); - dstUS[col*4+0] = r; - dstUS[col*4+1] = g; - dstUS[col*4+2] = b; - dstUS[col*4+3] = a; - src += 4; - } - dstRow += dstRowStride; - } - } - free((void *) tempImage); - } - return GL_TRUE; -} - - -static GLboolean -_mesa_texstore_signed_rgba_16(TEXSTORE_PARAMS) -{ - const GLenum baseFormat = _mesa_get_format_base_format(dstFormat); - - ASSERT(dstFormat == MESA_FORMAT_SIGNED_RGB_16 || - dstFormat == MESA_FORMAT_SIGNED_RGBA_16); - - if (!ctx->_ImageTransferState && - !srcPacking->SwapBytes && - baseInternalFormat == GL_RGBA && - dstFormat == MESA_FORMAT_SIGNED_RGBA_16 && - srcFormat == GL_RGBA && - srcType == GL_SHORT) { - /* simple memcpy path */ - memcpy_texture(ctx, dims, - dstFormat, - dstRowStride, dstSlices, - srcWidth, srcHeight, srcDepth, srcFormat, srcType, - srcAddr, srcPacking); - } - else { - /* general path */ - const GLfloat *tempImage = _mesa_make_temp_float_image(ctx, dims, - baseInternalFormat, - baseFormat, - srcWidth, srcHeight, srcDepth, - srcFormat, srcType, srcAddr, - srcPacking, - ctx->_ImageTransferState); - const GLfloat *src = tempImage; - const GLuint comps = _mesa_get_format_bytes(dstFormat) / 2; - GLint img, row, col; - - if (!tempImage) - return GL_FALSE; - - /* Note: tempImage is always float[4] / RGBA. We convert to 1, 2, - * 3 or 4 components/pixel here. - */ - for (img = 0; img < srcDepth; img++) { - GLubyte *dstRow = dstSlices[img]; - for (row = 0; row < srcHeight; row++) { - GLshort *dstRowS = (GLshort *) dstRow; - if (dstFormat == MESA_FORMAT_SIGNED_RGBA_16) { - for (col = 0; col < srcWidth; col++) { - GLuint c; - for (c = 0; c < comps; c++) { - GLshort p; - UNCLAMPED_FLOAT_TO_SHORT(p, src[col * 4 + c]); - dstRowS[col * comps + c] = p; - } - } - dstRow += dstRowStride; - src += 4 * srcWidth; - } else { - for (col = 0; col < srcWidth; col++) { - GLuint c; - for (c = 0; c < comps; c++) { - GLshort p; - UNCLAMPED_FLOAT_TO_SHORT(p, src[col * 3 + c]); - dstRowS[col * comps + c] = p; - } - } - dstRow += dstRowStride; - src += 3 * srcWidth; - } - } - } - free((void *) tempImage); - } - return GL_TRUE; -} - - -static GLboolean -_mesa_texstore_rgb332(TEXSTORE_PARAMS) -{ - const GLenum baseFormat = _mesa_get_format_base_format(dstFormat); - - ASSERT(dstFormat == MESA_FORMAT_RGB332); - ASSERT(_mesa_get_format_bytes(dstFormat) == 1); - - if (!ctx->_ImageTransferState && - !srcPacking->SwapBytes && - baseInternalFormat == GL_RGB && - srcFormat == GL_RGB && srcType == GL_UNSIGNED_BYTE_3_3_2) { - /* simple memcpy path */ - memcpy_texture(ctx, dims, - dstFormat, - dstRowStride, dstSlices, - srcWidth, srcHeight, srcDepth, srcFormat, srcType, - srcAddr, srcPacking); - } - else { - /* general path */ - const GLubyte *tempImage = _mesa_make_temp_ubyte_image(ctx, dims, - baseInternalFormat, - baseFormat, - srcWidth, srcHeight, srcDepth, - srcFormat, srcType, srcAddr, - srcPacking); - const GLubyte *src = tempImage; - GLint img, row, col; - if (!tempImage) - return GL_FALSE; - for (img = 0; img < srcDepth; img++) { - GLubyte *dstRow = dstSlices[img]; - for (row = 0; row < srcHeight; row++) { - for (col = 0; col < srcWidth; col++) { - dstRow[col] = PACK_COLOR_332( src[RCOMP], - src[GCOMP], - src[BCOMP] ); - src += 3; - } - dstRow += dstRowStride; - } - } - free((void *) tempImage); - } - return GL_TRUE; -} - - -/** - * Texstore for _mesa_texformat_a8, _mesa_texformat_l8, _mesa_texformat_i8. - */ -static GLboolean -_mesa_texstore_unorm8(TEXSTORE_PARAMS) -{ - const GLenum baseFormat = _mesa_get_format_base_format(dstFormat); - - ASSERT(dstFormat == MESA_FORMAT_A8 || - dstFormat == MESA_FORMAT_L8 || - dstFormat == MESA_FORMAT_I8 || - dstFormat == MESA_FORMAT_R8); - ASSERT(_mesa_get_format_bytes(dstFormat) == 1); - - if (!ctx->_ImageTransferState && - !srcPacking->SwapBytes && - baseInternalFormat == srcFormat && - srcType == GL_UNSIGNED_BYTE) { - /* simple memcpy path */ - memcpy_texture(ctx, dims, - dstFormat, - dstRowStride, dstSlices, - srcWidth, srcHeight, srcDepth, srcFormat, srcType, - srcAddr, srcPacking); - } - else if (!ctx->_ImageTransferState && - srcType == GL_UNSIGNED_BYTE && - can_swizzle(baseInternalFormat) && - can_swizzle(srcFormat)) { - GLubyte dstmap[4]; - - /* dstmap - how to swizzle from RGBA to dst format: - */ - if (dstFormat == MESA_FORMAT_A8) { - dstmap[0] = 3; - } - else { - dstmap[0] = 0; - } - dstmap[1] = ZERO; /* ? */ - dstmap[2] = ZERO; /* ? */ - dstmap[3] = ONE; /* ? */ - - _mesa_swizzle_ubyte_image(ctx, dims, - srcFormat, - srcType, - baseInternalFormat, - dstmap, 1, - dstRowStride, dstSlices, - srcWidth, srcHeight, srcDepth, srcAddr, - srcPacking); - } - else { - /* general path */ - const GLubyte *tempImage = _mesa_make_temp_ubyte_image(ctx, dims, - baseInternalFormat, - baseFormat, - srcWidth, srcHeight, srcDepth, - srcFormat, srcType, srcAddr, - srcPacking); - const GLubyte *src = tempImage; - GLint img, row, col; - if (!tempImage) - return GL_FALSE; - for (img = 0; img < srcDepth; img++) { - GLubyte *dstRow = dstSlices[img]; - for (row = 0; row < srcHeight; row++) { - for (col = 0; col < srcWidth; col++) { - dstRow[col] = src[col]; - } - dstRow += dstRowStride; - src += srcWidth; - } - } - free((void *) tempImage); - } - return GL_TRUE; -} - - - -/** - * Texstore for _mesa_texformat_ycbcr or _mesa_texformat_ycbcr_REV. - */ -static GLboolean -_mesa_texstore_ycbcr(TEXSTORE_PARAMS) -{ - const GLboolean littleEndian = _mesa_little_endian(); - - (void) ctx; (void) dims; (void) baseInternalFormat; - - ASSERT((dstFormat == MESA_FORMAT_YCBCR) || - (dstFormat == MESA_FORMAT_YCBCR_REV)); - ASSERT(_mesa_get_format_bytes(dstFormat) == 2); - ASSERT(ctx->Extensions.MESA_ycbcr_texture); - ASSERT(srcFormat == GL_YCBCR_MESA); - ASSERT((srcType == GL_UNSIGNED_SHORT_8_8_MESA) || - (srcType == GL_UNSIGNED_SHORT_8_8_REV_MESA)); - ASSERT(baseInternalFormat == GL_YCBCR_MESA); - - /* always just memcpy since no pixel transfer ops apply */ - memcpy_texture(ctx, dims, - dstFormat, - dstRowStride, dstSlices, - srcWidth, srcHeight, srcDepth, srcFormat, srcType, - srcAddr, srcPacking); - - /* Check if we need byte swapping */ - /* XXX the logic here _might_ be wrong */ - if (srcPacking->SwapBytes ^ - (srcType == GL_UNSIGNED_SHORT_8_8_REV_MESA) ^ - (dstFormat == MESA_FORMAT_YCBCR_REV) ^ - !littleEndian) { - GLint img, row; - for (img = 0; img < srcDepth; img++) { - GLubyte *dstRow = dstSlices[img]; - for (row = 0; row < srcHeight; row++) { - _mesa_swap2((GLushort *) dstRow, srcWidth); - dstRow += dstRowStride; - } - } - } - return GL_TRUE; -} - -/** - * Store simple 8-bit/value stencil texture data. - */ -static GLboolean -_mesa_texstore_s8(TEXSTORE_PARAMS) -{ - ASSERT(dstFormat == MESA_FORMAT_S8); - ASSERT(srcFormat == GL_STENCIL_INDEX); - - if (!ctx->_ImageTransferState && - !srcPacking->SwapBytes && - baseInternalFormat == srcFormat && - srcType == GL_UNSIGNED_BYTE) { - /* simple memcpy path */ - memcpy_texture(ctx, dims, - dstFormat, - dstRowStride, dstSlices, - srcWidth, srcHeight, srcDepth, srcFormat, srcType, - srcAddr, srcPacking); - } - else { - const GLint srcRowStride - = _mesa_image_row_stride(srcPacking, srcWidth, srcFormat, srcType); - GLint img, row; - - for (img = 0; img < srcDepth; img++) { - GLubyte *dstRow = dstSlices[img]; - const GLubyte *src - = (const GLubyte *) _mesa_image_address(dims, srcPacking, srcAddr, - srcWidth, srcHeight, - srcFormat, srcType, - img, 0, 0); - for (row = 0; row < srcHeight; row++) { - GLubyte stencil[MAX_WIDTH]; - GLint i; - - /* get the 8-bit stencil values */ - _mesa_unpack_stencil_span(ctx, srcWidth, - GL_UNSIGNED_BYTE, /* dst type */ - stencil, /* dst addr */ - srcType, src, srcPacking, - ctx->_ImageTransferState); - /* merge stencil values into depth values */ - for (i = 0; i < srcWidth; i++) - dstRow[i] = stencil[i]; - - src += srcRowStride; - dstRow += dstRowStride / sizeof(GLubyte); - } - } - - } - - return GL_TRUE; -} - - -/* non-normalized, signed int8 */ -static GLboolean -_mesa_texstore_rgba_int8(TEXSTORE_PARAMS) -{ - const GLenum baseFormat = _mesa_get_format_base_format(dstFormat); - const GLint components = _mesa_components_in_format(baseFormat); - - ASSERT(dstFormat == MESA_FORMAT_R_INT8 || - dstFormat == MESA_FORMAT_RG_INT8 || - dstFormat == MESA_FORMAT_RGB_INT8 || - dstFormat == MESA_FORMAT_RGBA_INT8 || - dstFormat == MESA_FORMAT_ALPHA_INT8 || - dstFormat == MESA_FORMAT_INTENSITY_INT8 || - dstFormat == MESA_FORMAT_LUMINANCE_INT8 || - dstFormat == MESA_FORMAT_LUMINANCE_ALPHA_INT8); - ASSERT(baseInternalFormat == GL_RGBA || - baseInternalFormat == GL_RGB || - baseInternalFormat == GL_RG || - baseInternalFormat == GL_RED || - baseInternalFormat == GL_ALPHA || - baseInternalFormat == GL_LUMINANCE || - baseInternalFormat == GL_LUMINANCE_ALPHA || - baseInternalFormat == GL_INTENSITY); - ASSERT(_mesa_get_format_bytes(dstFormat) == components * sizeof(GLbyte)); - - /* Note: Pixel transfer ops (scale, bias, table lookup) do not apply - * to integer formats. - */ - if (!srcPacking->SwapBytes && - baseInternalFormat == srcFormat && - srcType == GL_BYTE) { - /* simple memcpy path */ - memcpy_texture(ctx, dims, - dstFormat, - dstRowStride, dstSlices, - srcWidth, srcHeight, srcDepth, srcFormat, srcType, - srcAddr, srcPacking); - } - else { - /* general path */ - const GLuint *tempImage = make_temp_uint_image(ctx, dims, - baseInternalFormat, - baseFormat, - srcWidth, srcHeight, srcDepth, - srcFormat, srcType, - srcAddr, - srcPacking); - const GLuint *src = tempImage; - GLint img, row; - if (!tempImage) - return GL_FALSE; - for (img = 0; img < srcDepth; img++) { - GLubyte *dstRow = dstSlices[img]; - for (row = 0; row < srcHeight; row++) { - GLbyte *dstTexel = (GLbyte *) dstRow; - GLint i; - for (i = 0; i < srcWidth * components; i++) { - dstTexel[i] = (GLbyte) src[i]; - } - dstRow += dstRowStride; - src += srcWidth * components; - } - } - - free((void *) tempImage); - } - return GL_TRUE; -} - - -/* non-normalized, signed int16 */ -static GLboolean -_mesa_texstore_rgba_int16(TEXSTORE_PARAMS) -{ - const GLenum baseFormat = _mesa_get_format_base_format(dstFormat); - const GLint components = _mesa_components_in_format(baseFormat); - - ASSERT(dstFormat == MESA_FORMAT_R_INT16 || - dstFormat == MESA_FORMAT_RG_INT16 || - dstFormat == MESA_FORMAT_RGB_INT16 || - dstFormat == MESA_FORMAT_RGBA_INT16 || - dstFormat == MESA_FORMAT_ALPHA_INT16 || - dstFormat == MESA_FORMAT_LUMINANCE_INT16 || - dstFormat == MESA_FORMAT_INTENSITY_INT16 || - dstFormat == MESA_FORMAT_LUMINANCE_ALPHA_INT16); - ASSERT(baseInternalFormat == GL_RGBA || - baseInternalFormat == GL_RGB || - baseInternalFormat == GL_RG || - baseInternalFormat == GL_RED || - baseInternalFormat == GL_ALPHA || - baseInternalFormat == GL_LUMINANCE || - baseInternalFormat == GL_LUMINANCE_ALPHA || - baseInternalFormat == GL_INTENSITY); - ASSERT(_mesa_get_format_bytes(dstFormat) == components * sizeof(GLshort)); - - /* Note: Pixel transfer ops (scale, bias, table lookup) do not apply - * to integer formats. - */ - if (!srcPacking->SwapBytes && - baseInternalFormat == srcFormat && - srcType == GL_SHORT) { - /* simple memcpy path */ - memcpy_texture(ctx, dims, - dstFormat, - dstRowStride, dstSlices, - srcWidth, srcHeight, srcDepth, srcFormat, srcType, - srcAddr, srcPacking); - } - else { - /* general path */ - const GLuint *tempImage = make_temp_uint_image(ctx, dims, - baseInternalFormat, - baseFormat, - srcWidth, srcHeight, srcDepth, - srcFormat, srcType, - srcAddr, - srcPacking); - const GLuint *src = tempImage; - GLint img, row; - if (!tempImage) - return GL_FALSE; - for (img = 0; img < srcDepth; img++) { - GLubyte *dstRow = dstSlices[img]; - for (row = 0; row < srcHeight; row++) { - GLshort *dstTexel = (GLshort *) dstRow; - GLint i; - for (i = 0; i < srcWidth * components; i++) { - dstTexel[i] = (GLint) src[i]; - } - dstRow += dstRowStride; - src += srcWidth * components; - } - } - - free((void *) tempImage); - } - return GL_TRUE; -} - - -/* non-normalized, signed int32 */ -static GLboolean -_mesa_texstore_rgba_int32(TEXSTORE_PARAMS) -{ - const GLenum baseFormat = _mesa_get_format_base_format(dstFormat); - const GLint components = _mesa_components_in_format(baseFormat); - - ASSERT(dstFormat == MESA_FORMAT_R_INT32 || - dstFormat == MESA_FORMAT_RG_INT32 || - dstFormat == MESA_FORMAT_RGB_INT32 || - dstFormat == MESA_FORMAT_RGBA_INT32 || - dstFormat == MESA_FORMAT_ALPHA_INT32 || - dstFormat == MESA_FORMAT_INTENSITY_INT32 || - dstFormat == MESA_FORMAT_LUMINANCE_INT32 || - dstFormat == MESA_FORMAT_LUMINANCE_ALPHA_INT32); - ASSERT(baseInternalFormat == GL_RGBA || - baseInternalFormat == GL_RGB || - baseInternalFormat == GL_RG || - baseInternalFormat == GL_RED || - baseInternalFormat == GL_ALPHA || - baseInternalFormat == GL_LUMINANCE || - baseInternalFormat == GL_LUMINANCE_ALPHA || - baseInternalFormat == GL_INTENSITY); - ASSERT(_mesa_get_format_bytes(dstFormat) == components * sizeof(GLint)); - - /* Note: Pixel transfer ops (scale, bias, table lookup) do not apply - * to integer formats. - */ - if (!srcPacking->SwapBytes && - baseInternalFormat == srcFormat && - srcType == GL_INT) { - /* simple memcpy path */ - memcpy_texture(ctx, dims, - dstFormat, - dstRowStride, dstSlices, - srcWidth, srcHeight, srcDepth, srcFormat, srcType, - srcAddr, srcPacking); - } - else { - /* general path */ - const GLuint *tempImage = make_temp_uint_image(ctx, dims, - baseInternalFormat, - baseFormat, - srcWidth, srcHeight, srcDepth, - srcFormat, srcType, - srcAddr, - srcPacking); - const GLuint *src = tempImage; - GLint img, row; - if (!tempImage) - return GL_FALSE; - for (img = 0; img < srcDepth; img++) { - GLubyte *dstRow = dstSlices[img]; - for (row = 0; row < srcHeight; row++) { - GLint *dstTexel = (GLint *) dstRow; - GLint i; - for (i = 0; i < srcWidth * components; i++) { - dstTexel[i] = (GLint) src[i]; - } - dstRow += dstRowStride; - src += srcWidth * components; - } - } - - free((void *) tempImage); - } - return GL_TRUE; -} - - -/* non-normalized, unsigned int8 */ -static GLboolean -_mesa_texstore_rgba_uint8(TEXSTORE_PARAMS) -{ - const GLenum baseFormat = _mesa_get_format_base_format(dstFormat); - const GLint components = _mesa_components_in_format(baseFormat); - - ASSERT(dstFormat == MESA_FORMAT_R_UINT8 || - dstFormat == MESA_FORMAT_RG_UINT8 || - dstFormat == MESA_FORMAT_RGB_UINT8 || - dstFormat == MESA_FORMAT_RGBA_UINT8 || - dstFormat == MESA_FORMAT_ALPHA_UINT8 || - dstFormat == MESA_FORMAT_INTENSITY_UINT8 || - dstFormat == MESA_FORMAT_LUMINANCE_UINT8 || - dstFormat == MESA_FORMAT_LUMINANCE_ALPHA_UINT8); - ASSERT(baseInternalFormat == GL_RGBA || - baseInternalFormat == GL_RGB || - baseInternalFormat == GL_RG || - baseInternalFormat == GL_RED || - baseInternalFormat == GL_ALPHA || - baseInternalFormat == GL_LUMINANCE || - baseInternalFormat == GL_LUMINANCE_ALPHA || - baseInternalFormat == GL_INTENSITY); - ASSERT(_mesa_get_format_bytes(dstFormat) == components * sizeof(GLubyte)); - - /* Note: Pixel transfer ops (scale, bias, table lookup) do not apply - * to integer formats. - */ - if (!srcPacking->SwapBytes && - baseInternalFormat == srcFormat && - srcType == GL_UNSIGNED_BYTE) { - /* simple memcpy path */ - memcpy_texture(ctx, dims, - dstFormat, - dstRowStride, dstSlices, - srcWidth, srcHeight, srcDepth, srcFormat, srcType, - srcAddr, srcPacking); - } - else { - /* general path */ - const GLuint *tempImage = - make_temp_uint_image(ctx, dims, baseInternalFormat, baseFormat, - srcWidth, srcHeight, srcDepth, - srcFormat, srcType, srcAddr, srcPacking); - const GLuint *src = tempImage; - GLint img, row; - if (!tempImage) - return GL_FALSE; - for (img = 0; img < srcDepth; img++) { - GLubyte *dstRow = dstSlices[img]; - for (row = 0; row < srcHeight; row++) { - GLubyte *dstTexel = (GLubyte *) dstRow; - GLint i; - for (i = 0; i < srcWidth * components; i++) { - dstTexel[i] = (GLubyte) CLAMP(src[i], 0, 0xff); - } - dstRow += dstRowStride; - src += srcWidth * components; - } - } - - free((void *) tempImage); - } - return GL_TRUE; -} - - -/* non-normalized, unsigned int16 */ -static GLboolean -_mesa_texstore_rgba_uint16(TEXSTORE_PARAMS) -{ - const GLenum baseFormat = _mesa_get_format_base_format(dstFormat); - const GLint components = _mesa_components_in_format(baseFormat); - - ASSERT(dstFormat == MESA_FORMAT_R_UINT16 || - dstFormat == MESA_FORMAT_RG_UINT16 || - dstFormat == MESA_FORMAT_RGB_UINT16 || - dstFormat == MESA_FORMAT_RGBA_UINT16 || - dstFormat == MESA_FORMAT_ALPHA_UINT16 || - dstFormat == MESA_FORMAT_INTENSITY_UINT16 || - dstFormat == MESA_FORMAT_LUMINANCE_UINT16 || - dstFormat == MESA_FORMAT_LUMINANCE_ALPHA_UINT16); - ASSERT(baseInternalFormat == GL_RGBA || - baseInternalFormat == GL_RGB || - baseInternalFormat == GL_RG || - baseInternalFormat == GL_RED || - baseInternalFormat == GL_ALPHA || - baseInternalFormat == GL_LUMINANCE || - baseInternalFormat == GL_LUMINANCE_ALPHA || - baseInternalFormat == GL_INTENSITY); - ASSERT(_mesa_get_format_bytes(dstFormat) == components * sizeof(GLushort)); - - /* Note: Pixel transfer ops (scale, bias, table lookup) do not apply - * to integer formats. - */ - if (!srcPacking->SwapBytes && - baseInternalFormat == srcFormat && - srcType == GL_UNSIGNED_SHORT) { - /* simple memcpy path */ - memcpy_texture(ctx, dims, - dstFormat, - dstRowStride, dstSlices, - srcWidth, srcHeight, srcDepth, srcFormat, srcType, - srcAddr, srcPacking); - } - else { - /* general path */ - const GLuint *tempImage = - make_temp_uint_image(ctx, dims, baseInternalFormat, baseFormat, - srcWidth, srcHeight, srcDepth, - srcFormat, srcType, srcAddr, srcPacking); - const GLuint *src = tempImage; - GLint img, row; - if (!tempImage) - return GL_FALSE; - for (img = 0; img < srcDepth; img++) { - GLubyte *dstRow = dstSlices[img]; - for (row = 0; row < srcHeight; row++) { - GLushort *dstTexel = (GLushort *) dstRow; - GLint i; - for (i = 0; i < srcWidth * components; i++) { - dstTexel[i] = (GLushort) CLAMP(src[i], 0, 0xffff); - } - dstRow += dstRowStride; - src += srcWidth * components; - } - } - - free((void *) tempImage); - } - return GL_TRUE; -} - - -/* non-normalized, unsigned int32 */ -static GLboolean -_mesa_texstore_rgba_uint32(TEXSTORE_PARAMS) -{ - const GLenum baseFormat = _mesa_get_format_base_format(dstFormat); - const GLint components = _mesa_components_in_format(baseFormat); - - ASSERT(dstFormat == MESA_FORMAT_R_UINT32 || - dstFormat == MESA_FORMAT_RG_UINT32 || - dstFormat == MESA_FORMAT_RGB_UINT32 || - dstFormat == MESA_FORMAT_RGBA_UINT32 || - dstFormat == MESA_FORMAT_ALPHA_UINT32 || - dstFormat == MESA_FORMAT_INTENSITY_UINT32 || - dstFormat == MESA_FORMAT_LUMINANCE_UINT32 || - dstFormat == MESA_FORMAT_LUMINANCE_ALPHA_UINT32); - ASSERT(baseInternalFormat == GL_RGBA || - baseInternalFormat == GL_RGB || - baseInternalFormat == GL_RG || - baseInternalFormat == GL_RED || - baseInternalFormat == GL_ALPHA || - baseInternalFormat == GL_LUMINANCE || - baseInternalFormat == GL_LUMINANCE_ALPHA || - baseInternalFormat == GL_INTENSITY); - ASSERT(_mesa_get_format_bytes(dstFormat) == components * sizeof(GLuint)); - - /* Note: Pixel transfer ops (scale, bias, table lookup) do not apply - * to integer formats. - */ - if (!srcPacking->SwapBytes && - baseInternalFormat == srcFormat && - srcType == GL_UNSIGNED_INT) { - /* simple memcpy path */ - memcpy_texture(ctx, dims, - dstFormat, - dstRowStride, dstSlices, - srcWidth, srcHeight, srcDepth, srcFormat, srcType, - srcAddr, srcPacking); - } - else { - /* general path */ - const GLuint *tempImage = - make_temp_uint_image(ctx, dims, baseInternalFormat, baseFormat, - srcWidth, srcHeight, srcDepth, - srcFormat, srcType, srcAddr, srcPacking); - const GLuint *src = tempImage; - GLint img, row; - if (!tempImage) - return GL_FALSE; - for (img = 0; img < srcDepth; img++) { - GLubyte *dstRow = dstSlices[img]; - for (row = 0; row < srcHeight; row++) { - GLuint *dstTexel = (GLuint *) dstRow; - GLint i; - for (i = 0; i < srcWidth * components; i++) { - dstTexel[i] = src[i]; - } - dstRow += dstRowStride; - src += srcWidth * components; - } - } - - free((void *) tempImage); - } - return GL_TRUE; -} - -static GLboolean -_mesa_texstore_null(TEXSTORE_PARAMS) -{ - (void) ctx; (void) dims; - (void) baseInternalFormat; - (void) dstFormat; - (void) dstRowStride; (void) dstSlices, - (void) srcWidth; (void) srcHeight; (void) srcDepth; - (void) srcFormat; (void) srcType; - (void) srcAddr; - (void) srcPacking; - - /* should never happen */ - _mesa_problem(NULL, "_mesa_texstore_null() is called"); - return GL_FALSE; -} - - -/** - * Return the StoreTexImageFunc pointer to store an image in the given format. - */ -static StoreTexImageFunc -_mesa_get_texstore_func(gl_format format) -{ - static StoreTexImageFunc table[MESA_FORMAT_COUNT]; - static GLboolean initialized = GL_FALSE; - - if (!initialized) { - table[MESA_FORMAT_NONE] = _mesa_texstore_null; - - table[MESA_FORMAT_RGBA8888] = _mesa_texstore_rgba8888; - table[MESA_FORMAT_RGBA8888_REV] = _mesa_texstore_rgba8888; - table[MESA_FORMAT_ARGB8888] = _mesa_texstore_argb8888; - table[MESA_FORMAT_ARGB8888_REV] = _mesa_texstore_argb8888; - table[MESA_FORMAT_RGBX8888] = _mesa_texstore_rgba8888; - table[MESA_FORMAT_RGBX8888_REV] = _mesa_texstore_rgba8888; - table[MESA_FORMAT_XRGB8888] = _mesa_texstore_argb8888; - table[MESA_FORMAT_XRGB8888_REV] = _mesa_texstore_argb8888; - table[MESA_FORMAT_RGB888] = _mesa_texstore_rgb888; - table[MESA_FORMAT_BGR888] = _mesa_texstore_bgr888; - table[MESA_FORMAT_RGB565] = _mesa_texstore_rgb565; - table[MESA_FORMAT_RGB565_REV] = _mesa_texstore_rgb565; - table[MESA_FORMAT_ARGB4444] = _mesa_texstore_argb4444; - table[MESA_FORMAT_ARGB4444_REV] = _mesa_texstore_argb4444; - table[MESA_FORMAT_RGBA5551] = _mesa_texstore_rgba5551; - table[MESA_FORMAT_ARGB1555] = _mesa_texstore_argb1555; - table[MESA_FORMAT_ARGB1555_REV] = _mesa_texstore_argb1555; - table[MESA_FORMAT_AL44] = _mesa_texstore_unorm44; - table[MESA_FORMAT_AL88] = _mesa_texstore_unorm88; - table[MESA_FORMAT_AL88_REV] = _mesa_texstore_unorm88; - table[MESA_FORMAT_AL1616] = _mesa_texstore_unorm1616; - table[MESA_FORMAT_AL1616_REV] = _mesa_texstore_unorm1616; - table[MESA_FORMAT_RGB332] = _mesa_texstore_rgb332; - table[MESA_FORMAT_A8] = _mesa_texstore_unorm8; - table[MESA_FORMAT_A16] = _mesa_texstore_unorm16; - table[MESA_FORMAT_L8] = _mesa_texstore_unorm8; - table[MESA_FORMAT_L16] = _mesa_texstore_unorm16; - table[MESA_FORMAT_I8] = _mesa_texstore_unorm8; - table[MESA_FORMAT_I16] = _mesa_texstore_unorm16; - table[MESA_FORMAT_YCBCR] = _mesa_texstore_ycbcr; - table[MESA_FORMAT_YCBCR_REV] = _mesa_texstore_ycbcr; - table[MESA_FORMAT_Z16] = _mesa_texstore_z16; - table[MESA_FORMAT_X8_Z24] = _mesa_texstore_x8_z24; - table[MESA_FORMAT_Z24_X8] = _mesa_texstore_z24_x8; - table[MESA_FORMAT_Z32] = _mesa_texstore_z32; - table[MESA_FORMAT_S8] = _mesa_texstore_s8; - table[MESA_FORMAT_SIGNED_RGBA_16] = _mesa_texstore_signed_rgba_16; - table[MESA_FORMAT_RGBA_16] = _mesa_texstore_rgba_16; - - table[MESA_FORMAT_ALPHA_UINT8] = _mesa_texstore_rgba_uint8; - table[MESA_FORMAT_ALPHA_UINT16] = _mesa_texstore_rgba_uint16; - table[MESA_FORMAT_ALPHA_UINT32] = _mesa_texstore_rgba_uint32; - table[MESA_FORMAT_ALPHA_INT8] = _mesa_texstore_rgba_int8; - table[MESA_FORMAT_ALPHA_INT16] = _mesa_texstore_rgba_int16; - table[MESA_FORMAT_ALPHA_INT32] = _mesa_texstore_rgba_int32; - - table[MESA_FORMAT_INTENSITY_UINT8] = _mesa_texstore_rgba_uint8; - table[MESA_FORMAT_INTENSITY_UINT16] = _mesa_texstore_rgba_uint16; - table[MESA_FORMAT_INTENSITY_UINT32] = _mesa_texstore_rgba_uint32; - table[MESA_FORMAT_INTENSITY_INT8] = _mesa_texstore_rgba_int8; - table[MESA_FORMAT_INTENSITY_INT16] = _mesa_texstore_rgba_int16; - table[MESA_FORMAT_INTENSITY_INT32] = _mesa_texstore_rgba_int32; - - table[MESA_FORMAT_LUMINANCE_UINT8] = _mesa_texstore_rgba_uint8; - table[MESA_FORMAT_LUMINANCE_UINT16] = _mesa_texstore_rgba_uint16; - table[MESA_FORMAT_LUMINANCE_UINT32] = _mesa_texstore_rgba_uint32; - table[MESA_FORMAT_LUMINANCE_INT8] = _mesa_texstore_rgba_int8; - table[MESA_FORMAT_LUMINANCE_INT16] = _mesa_texstore_rgba_int16; - table[MESA_FORMAT_LUMINANCE_INT32] = _mesa_texstore_rgba_int32; - - table[MESA_FORMAT_LUMINANCE_ALPHA_UINT8] = _mesa_texstore_rgba_uint8; - table[MESA_FORMAT_LUMINANCE_ALPHA_UINT16] = _mesa_texstore_rgba_uint16; - table[MESA_FORMAT_LUMINANCE_ALPHA_UINT32] = _mesa_texstore_rgba_uint32; - table[MESA_FORMAT_LUMINANCE_ALPHA_INT8] = _mesa_texstore_rgba_int8; - table[MESA_FORMAT_LUMINANCE_ALPHA_INT16] = _mesa_texstore_rgba_int16; - table[MESA_FORMAT_LUMINANCE_ALPHA_INT32] = _mesa_texstore_rgba_int32; - - table[MESA_FORMAT_RGB_INT8] = _mesa_texstore_rgba_int8; - table[MESA_FORMAT_RGBA_INT8] = _mesa_texstore_rgba_int8; - table[MESA_FORMAT_RGB_INT16] = _mesa_texstore_rgba_int16; - table[MESA_FORMAT_RGBA_INT16] = _mesa_texstore_rgba_int16; - table[MESA_FORMAT_RGB_INT32] = _mesa_texstore_rgba_int32; - table[MESA_FORMAT_RGBA_INT32] = _mesa_texstore_rgba_int32; - - table[MESA_FORMAT_RGB_UINT8] = _mesa_texstore_rgba_uint8; - table[MESA_FORMAT_RGBA_UINT8] = _mesa_texstore_rgba_uint8; - table[MESA_FORMAT_RGB_UINT16] = _mesa_texstore_rgba_uint16; - table[MESA_FORMAT_RGBA_UINT16] = _mesa_texstore_rgba_uint16; - table[MESA_FORMAT_RGB_UINT32] = _mesa_texstore_rgba_uint32; - table[MESA_FORMAT_RGBA_UINT32] = _mesa_texstore_rgba_uint32; - - initialized = GL_TRUE; - } - - ASSERT(table[format]); - return table[format]; -} - - -/** - * Store user data into texture memory. - * Called via glTex[Sub]Image1/2/3D() - */ -GLboolean -_mesa_texstore(TEXSTORE_PARAMS) -{ - StoreTexImageFunc storeImage; - GLboolean success; - - storeImage = _mesa_get_texstore_func(dstFormat); - - success = storeImage(ctx, dims, baseInternalFormat, - dstFormat, - dstRowStride, dstSlices, - srcWidth, srcHeight, srcDepth, - srcFormat, srcType, srcAddr, srcPacking); - return success; -} - - -/** - * Normally, we'll only _write_ texel data to a texture when we map it. - * But if the user is providing depth or stencil values and the texture - * image is a combined depth/stencil format, we'll actually read from - * the texture buffer too (in order to insert the depth or stencil values. - * \param userFormat the user-provided image format - * \param texFormat the destination texture format - */ -static GLbitfield -get_read_write_mode(GLenum userFormat, gl_format texFormat) -{ - return GL_MAP_WRITE_BIT | GL_MAP_INVALIDATE_RANGE_BIT; -} - - -/** - * Helper function for storing 1D, 2D, 3D whole and subimages into texture - * memory. - * The source of the image data may be user memory or a PBO. In the later - * case, we'll map the PBO, copy from it, then unmap it. - */ -static void -store_texsubimage(struct gl_context *ctx, - struct gl_texture_image *texImage, - GLint xoffset, GLint yoffset, GLint zoffset, - GLint width, GLint height, GLint depth, - GLenum format, GLenum type, const GLvoid *pixels, - const struct gl_pixelstore_attrib *packing, - const char *caller) - -{ - const GLbitfield mapMode = get_read_write_mode(format, texImage->TexFormat); - const GLenum target = texImage->TexObject->Target; - GLboolean success = GL_FALSE; - GLuint dims, slice, numSlices = 1, sliceOffset = 0; - GLint srcImageStride = 0; - const GLubyte *src; - - assert(xoffset + width <= texImage->Width); - assert(yoffset + height <= texImage->Height); - assert(zoffset + depth <= texImage->Depth); - - switch (target) { - case GL_TEXTURE_1D: - dims = 1; - break; - default: - dims = 2; - } - - /* get pointer to src pixels (may be in a pbo which we'll map here) */ - src = (const GLubyte *)pixels; - if (!src) - return; - - /* compute slice info (and do some sanity checks) */ - switch (target) { - case GL_TEXTURE_2D: - case GL_TEXTURE_CUBE_MAP: - /* one image slice, nothing special needs to be done */ - break; - case GL_TEXTURE_1D: - assert(height == 1); - assert(depth == 1); - assert(yoffset == 0); - assert(zoffset == 0); - break; - default: - _mesa_warning(ctx, "Unexpected target 0x%x in store_texsubimage()", target); - return; - } - - assert(numSlices == 1 || srcImageStride != 0); - - for (slice = 0; slice < numSlices; slice++) { - GLubyte *dstMap; - GLint dstRowStride; - - ctx->Driver.MapTextureImage(ctx, texImage, - slice + sliceOffset, - xoffset, yoffset, width, height, - mapMode, &dstMap, &dstRowStride); - if (dstMap) { - /* Note: we're only storing a 2D (or 1D) slice at a time but we need - * to pass the right 'dims' value so that GL_UNPACK_SKIP_IMAGES is - * used for 3D images. - */ - success = _mesa_texstore(ctx, dims, texImage->_BaseFormat, - texImage->TexFormat, - dstRowStride, - &dstMap, - width, height, 1, /* w, h, d */ - format, type, src, packing); - - ctx->Driver.UnmapTextureImage(ctx, texImage, slice + sliceOffset); - } - - src += srcImageStride; - - if (!success) - break; - } - - if (!success) - _mesa_error(ctx, GL_OUT_OF_MEMORY, "%s", caller); -} - - - -/** - * This is the fallback for Driver.TexImage1D(). - */ -void -_mesa_store_teximage1d(struct gl_context *ctx, - struct gl_texture_image *texImage, - GLint internalFormat, - GLint width, GLint border, - GLenum format, GLenum type, const GLvoid *pixels, - const struct gl_pixelstore_attrib *packing) -{ - if (width == 0) - return; - - /* allocate storage for texture data */ - if (!ctx->Driver.AllocTextureImageBuffer(ctx, texImage, texImage->TexFormat, - width, 1, 1)) { - _mesa_error(ctx, GL_OUT_OF_MEMORY, "glTexImage1D"); - return; - } - - store_texsubimage(ctx, texImage, - 0, 0, 0, width, 1, 1, - format, type, pixels, packing, "glTexImage1D"); -} - - -/** - * This is the fallback for Driver.TexImage2D(). - */ -void -_mesa_store_teximage2d(struct gl_context *ctx, - struct gl_texture_image *texImage, - GLint internalFormat, - GLint width, GLint height, GLint border, - GLenum format, GLenum type, const void *pixels, - const struct gl_pixelstore_attrib *packing) -{ - if (width == 0 || height == 0) - return; - - /* allocate storage for texture data */ - if (!ctx->Driver.AllocTextureImageBuffer(ctx, texImage, texImage->TexFormat, - width, height, 1)) { - _mesa_error(ctx, GL_OUT_OF_MEMORY, "glTexImage2D"); - return; - } - - store_texsubimage(ctx, texImage, - 0, 0, 0, width, height, 1, - format, type, pixels, packing, "glTexImage2D"); -} - - - - -/* - * This is the fallback for Driver.TexSubImage1D(). - */ -void -_mesa_store_texsubimage1d(struct gl_context *ctx, - struct gl_texture_image *texImage, - GLint xoffset, GLint width, - GLenum format, GLenum type, const void *pixels, - const struct gl_pixelstore_attrib *packing) -{ - store_texsubimage(ctx, texImage, - xoffset, 0, 0, width, 1, 1, - format, type, pixels, packing, "glTexSubImage1D"); -} - - - -/** - * This is the fallback for Driver.TexSubImage2D(). - */ -void -_mesa_store_texsubimage2d(struct gl_context *ctx, - struct gl_texture_image *texImage, - GLint xoffset, GLint yoffset, - GLint width, GLint height, - GLenum format, GLenum type, const void *pixels, - const struct gl_pixelstore_attrib *packing) -{ - store_texsubimage(ctx, texImage, - xoffset, yoffset, 0, width, height, 1, - format, type, pixels, packing, "glTexSubImage2D"); -} diff --git a/dll/opengl/mesa/main/texstore.h b/dll/opengl/mesa/main/texstore.h deleted file mode 100644 index 07f20165b67..00000000000 --- a/dll/opengl/mesa/main/texstore.h +++ /dev/null @@ -1,127 +0,0 @@ -/* - * Mesa 3-D graphics library - * Version: 6.5.1 - * - * Copyright (C) 1999-2006 Brian Paul All Rights Reserved. - * Copyright (c) 2008 VMware, Inc. - * - * Permission is hereby granted, free of charge, to any person obtaining a - * copy of this software and associated documentation files (the "Software"), - * to deal in the Software without restriction, including without limitation - * the rights to use, copy, modify, merge, publish, distribute, sublicense, - * and/or sell copies of the Software, and to permit persons to whom the - * Software is furnished to do so, subject to the following conditions: - * - * The above copyright notice and this permission notice shall be included - * in all copies or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS - * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL - * BRIAN PAUL BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN - * AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN - * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. - */ - - -/** - * \file texstore.h - * Texture image storage routines. - * - * \author Brian Paul - */ - - -#ifndef TEXSTORE_H -#define TEXSTORE_H - - -#include "mtypes.h" -#include "formats.h" - - -/** - * This macro defines the (many) parameters to the texstore functions. - * \param dims either 1 or 2 or 3 - * \param baseInternalFormat user-specified base internal format - * \param dstFormat destination Mesa texture format - * \param dstX/Y/Zoffset destination x/y/z offset (ala TexSubImage), in texels - * \param dstRowStride destination image row stride, in bytes - * \param dstSlices array of addresses of image slices (for 3D, array texture) - * \param srcWidth/Height/Depth source image size, in pixels - * \param srcFormat incoming image format - * \param srcType incoming image data type - * \param srcAddr source image address - * \param srcPacking source image packing parameters - */ -#define TEXSTORE_PARAMS \ - struct gl_context *ctx, GLuint dims, \ - GLenum baseInternalFormat, \ - gl_format dstFormat, \ - GLint dstRowStride, \ - GLubyte **dstSlices, \ - GLint srcWidth, GLint srcHeight, GLint srcDepth, \ - GLenum srcFormat, GLenum srcType, \ - const GLvoid *srcAddr, \ - const struct gl_pixelstore_attrib *srcPacking - - -extern GLboolean -_mesa_texstore(TEXSTORE_PARAMS); - - -extern GLubyte * -_mesa_make_temp_ubyte_image(struct gl_context *ctx, GLuint dims, - GLenum logicalBaseFormat, - GLenum textureBaseFormat, - GLint srcWidth, GLint srcHeight, GLint srcDepth, - GLenum srcFormat, GLenum srcType, - const GLvoid *srcAddr, - const struct gl_pixelstore_attrib *srcPacking); - -GLfloat * -_mesa_make_temp_float_image(struct gl_context *ctx, GLuint dims, - GLenum logicalBaseFormat, - GLenum textureBaseFormat, - GLint srcWidth, GLint srcHeight, GLint srcDepth, - GLenum srcFormat, GLenum srcType, - const GLvoid *srcAddr, - const struct gl_pixelstore_attrib *srcPacking, - GLbitfield transferOps); - -extern void -_mesa_store_teximage1d(struct gl_context *ctx, - struct gl_texture_image *texImage, - GLint internalFormat, - GLint width, GLint border, - GLenum format, GLenum type, const GLvoid *pixels, - const struct gl_pixelstore_attrib *packing); - - -extern void -_mesa_store_teximage2d(struct gl_context *ctx, - struct gl_texture_image *texImage, - GLint internalFormat, - GLint width, GLint height, GLint border, - GLenum format, GLenum type, const GLvoid *pixels, - const struct gl_pixelstore_attrib *packing); - - -extern void -_mesa_store_texsubimage1d(struct gl_context *ctx, - struct gl_texture_image *texImage, - GLint xoffset, GLint width, - GLenum format, GLenum type, const GLvoid *pixels, - const struct gl_pixelstore_attrib *packing); - - -extern void -_mesa_store_texsubimage2d(struct gl_context *ctx, - struct gl_texture_image *texImage, - GLint xoffset, GLint yoffset, - GLint width, GLint height, - GLenum format, GLenum type, const GLvoid *pixels, - const struct gl_pixelstore_attrib *packing); - - -#endif diff --git a/dll/opengl/mesa/main/varray.c b/dll/opengl/mesa/main/varray.c deleted file mode 100644 index ab2a870f61d..00000000000 --- a/dll/opengl/mesa/main/varray.c +++ /dev/null @@ -1,650 +0,0 @@ -/* - * Mesa 3-D graphics library - * Version: 7.6 - * - * Copyright (C) 1999-2008 Brian Paul All Rights Reserved. - * Copyright (C) 2009 VMware, Inc. All Rights Reserved. - * - * Permission is hereby granted, free of charge, to any person obtaining a - * copy of this software and associated documentation files (the "Software"), - * to deal in the Software without restriction, including without limitation - * the rights to use, copy, modify, merge, publish, distribute, sublicense, - * and/or sell copies of the Software, and to permit persons to whom the - * Software is furnished to do so, subject to the following conditions: - * - * The above copyright notice and this permission notice shall be included - * in all copies or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS - * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL - * BRIAN PAUL BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN - * AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN - * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. - */ - -#include - -/** Used to indicate which GL datatypes are accepted by each of the - * glVertex/Color/Attrib/EtcPointer() functions. - */ -#define BOOL_BIT 0x1 -#define BYTE_BIT 0x2 -#define UNSIGNED_BYTE_BIT 0x4 -#define SHORT_BIT 0x8 -#define UNSIGNED_SHORT_BIT 0x10 -#define INT_BIT 0x20 -#define UNSIGNED_INT_BIT 0x40 -#define HALF_BIT 0x80 -#define FLOAT_BIT 0x100 -#define DOUBLE_BIT 0x200 - - -/** Convert GL datatype enum into a _BIT value seen above */ -static GLbitfield -type_to_bit(const struct gl_context *ctx, GLenum type) -{ - switch (type) { - case GL_BOOL: - return BOOL_BIT; - case GL_BYTE: - return BYTE_BIT; - case GL_UNSIGNED_BYTE: - return UNSIGNED_BYTE_BIT; - case GL_SHORT: - return SHORT_BIT; - case GL_UNSIGNED_SHORT: - return UNSIGNED_SHORT_BIT; - case GL_INT: - return INT_BIT; - case GL_UNSIGNED_INT: - return UNSIGNED_INT_BIT; - case GL_FLOAT: - return FLOAT_BIT; - case GL_DOUBLE: - return DOUBLE_BIT; - default: - return 0; - } -} - - -/** - * Do error checking and update state for glVertex/Color/TexCoord/...Pointer - * functions. - * - * \param func name of calling function used for error reporting - * \param attrib the attribute array index to update - * \param legalTypes bitmask of *_BIT above indicating legal datatypes - * \param sizeMin min allowable size value - * \param sizeMax max allowable size value - * \param size components per element (1, 2, 3 or 4) - * \param type datatype of each component (GL_FLOAT, GL_INT, etc) - * \param stride stride between elements, in elements - * \param normalized are integer types converted to floats in [-1, 1]? - * \param integer integer-valued values (will not be normalized to [-1,1]) - * \param ptr the address (or offset inside VBO) of the array data - */ -static void -update_array(struct gl_context *ctx, - const char *func, - GLuint attrib, GLbitfield legalTypesMask, - GLint sizeMin, GLint sizeMax, - GLint size, GLenum type, GLsizei stride, - GLboolean normalized, GLboolean integer, - const GLvoid *ptr) -{ - struct gl_client_array *array; - GLbitfield typeBit; - GLsizei elementSize; - - typeBit = type_to_bit(ctx, type); - if (typeBit == 0x0 || (typeBit & legalTypesMask) == 0x0) { - _mesa_error(ctx, GL_INVALID_ENUM, "%s(type = %s)", - func, _mesa_lookup_enum_by_nr(type)); - return; - } - - /* Do size parameter checking. */ - if (size < sizeMin || size > sizeMax || size > 4) { - _mesa_error(ctx, GL_INVALID_VALUE, "%s(size=%d)", func, size); - return; - } - - ASSERT(size <= 4); - - if (stride < 0) { - _mesa_error( ctx, GL_INVALID_VALUE, "%s(stride=%d)", func, stride ); - return; - } - - elementSize = _mesa_sizeof_type(type) * size; - - array = &ctx->Array.VertexAttrib[attrib]; - array->Size = size; - array->Type = type; - array->Stride = stride; - array->StrideB = stride ? stride : elementSize; - array->Normalized = normalized; - array->Integer = integer; - array->Ptr = (const GLubyte *) ptr; - array->_ElementSize = elementSize; - - ctx->NewState |= _NEW_ARRAY; - ctx->Array.NewState |= VERT_BIT(attrib); -} - - -void GLAPIENTRY -_mesa_VertexPointer(GLint size, GLenum type, GLsizei stride, const GLvoid *ptr) -{ - GLbitfield legalTypes = (SHORT_BIT | INT_BIT | FLOAT_BIT | - DOUBLE_BIT | HALF_BIT); - GET_CURRENT_CONTEXT(ctx); - ASSERT_OUTSIDE_BEGIN_END_AND_FLUSH(ctx); - - update_array(ctx, "glVertexPointer", VERT_ATTRIB_POS, - legalTypes, 2, 4, - size, type, stride, GL_FALSE, GL_FALSE, ptr); -} - - -void GLAPIENTRY -_mesa_NormalPointer(GLenum type, GLsizei stride, const GLvoid *ptr ) -{ - const GLbitfield legalTypes = (BYTE_BIT | SHORT_BIT | INT_BIT | - HALF_BIT | FLOAT_BIT | DOUBLE_BIT); - GET_CURRENT_CONTEXT(ctx); - ASSERT_OUTSIDE_BEGIN_END_AND_FLUSH(ctx); - - update_array(ctx, "glNormalPointer", VERT_ATTRIB_NORMAL, - legalTypes, 3, 3, - 3, type, stride, GL_TRUE, GL_FALSE, ptr); -} - - -void GLAPIENTRY -_mesa_ColorPointer(GLint size, GLenum type, GLsizei stride, const GLvoid *ptr) -{ - const GLbitfield legalTypes = (BYTE_BIT | UNSIGNED_BYTE_BIT | - SHORT_BIT | UNSIGNED_SHORT_BIT | - INT_BIT | UNSIGNED_INT_BIT | - HALF_BIT | FLOAT_BIT | DOUBLE_BIT); - GET_CURRENT_CONTEXT(ctx); - ASSERT_OUTSIDE_BEGIN_END_AND_FLUSH(ctx); - - update_array(ctx, "glColorPointer", VERT_ATTRIB_COLOR, - legalTypes, 3, 4, - size, type, stride, GL_TRUE, GL_FALSE, ptr); -} - - -void GLAPIENTRY -_mesa_FogCoordPointerEXT(GLenum type, GLsizei stride, const GLvoid *ptr) -{ - const GLbitfield legalTypes = (HALF_BIT | FLOAT_BIT | DOUBLE_BIT); - GET_CURRENT_CONTEXT(ctx); - ASSERT_OUTSIDE_BEGIN_END_AND_FLUSH(ctx); - - update_array(ctx, "glFogCoordPointer", VERT_ATTRIB_FOG, - legalTypes, 1, 1, - 1, type, stride, GL_FALSE, GL_FALSE, ptr); -} - - -void GLAPIENTRY -_mesa_IndexPointer(GLenum type, GLsizei stride, const GLvoid *ptr) -{ - const GLbitfield legalTypes = (UNSIGNED_BYTE_BIT | SHORT_BIT | INT_BIT | - FLOAT_BIT | DOUBLE_BIT); - GET_CURRENT_CONTEXT(ctx); - ASSERT_OUTSIDE_BEGIN_END_AND_FLUSH(ctx); - - update_array(ctx, "glIndexPointer", VERT_ATTRIB_COLOR_INDEX, - legalTypes, 1, 1, - 1, type, stride, GL_FALSE, GL_FALSE, ptr); -} - - -void GLAPIENTRY -_mesa_TexCoordPointer(GLint size, GLenum type, GLsizei stride, - const GLvoid *ptr) -{ - GLbitfield legalTypes = (SHORT_BIT | INT_BIT | - HALF_BIT | FLOAT_BIT | DOUBLE_BIT); - GET_CURRENT_CONTEXT(ctx); - ASSERT_OUTSIDE_BEGIN_END_AND_FLUSH(ctx); - - update_array(ctx, "glTexCoordPointer", VERT_ATTRIB_TEX, - legalTypes, 1, 4, - size, type, stride, GL_FALSE, GL_FALSE, - ptr); -} - - -void GLAPIENTRY -_mesa_EdgeFlagPointer(GLsizei stride, const GLvoid *ptr) -{ - const GLbitfield legalTypes = UNSIGNED_BYTE_BIT; - /* see table 2.4 edits in GL_EXT_gpu_shader4 spec: */ - const GLboolean integer = GL_TRUE; - GET_CURRENT_CONTEXT(ctx); - ASSERT_OUTSIDE_BEGIN_END_AND_FLUSH(ctx); - - update_array(ctx, "glEdgeFlagPointer", VERT_ATTRIB_EDGEFLAG, - legalTypes, 1, 1, - 1, GL_UNSIGNED_BYTE, stride, GL_FALSE, integer, ptr); -} - -void GLAPIENTRY -_mesa_VertexPointerEXT(GLint size, GLenum type, GLsizei stride, - GLsizei count, const GLvoid *ptr) -{ - (void) count; - _mesa_VertexPointer(size, type, stride, ptr); -} - - -void GLAPIENTRY -_mesa_NormalPointerEXT(GLenum type, GLsizei stride, GLsizei count, - const GLvoid *ptr) -{ - (void) count; - _mesa_NormalPointer(type, stride, ptr); -} - - -void GLAPIENTRY -_mesa_ColorPointerEXT(GLint size, GLenum type, GLsizei stride, GLsizei count, - const GLvoid *ptr) -{ - (void) count; - _mesa_ColorPointer(size, type, stride, ptr); -} - - -void GLAPIENTRY -_mesa_IndexPointerEXT(GLenum type, GLsizei stride, GLsizei count, - const GLvoid *ptr) -{ - (void) count; - _mesa_IndexPointer(type, stride, ptr); -} - - -void GLAPIENTRY -_mesa_TexCoordPointerEXT(GLint size, GLenum type, GLsizei stride, - GLsizei count, const GLvoid *ptr) -{ - (void) count; - _mesa_TexCoordPointer(size, type, stride, ptr); -} - - -void GLAPIENTRY -_mesa_EdgeFlagPointerEXT(GLsizei stride, GLsizei count, const GLboolean *ptr) -{ - (void) count; - _mesa_EdgeFlagPointer(stride, ptr); -} - - -void GLAPIENTRY -_mesa_InterleavedArrays(GLenum format, GLsizei stride, const GLvoid *pointer) -{ - GET_CURRENT_CONTEXT(ctx); - GLboolean tflag, cflag, nflag; /* enable/disable flags */ - GLint tcomps, ccomps, vcomps; /* components per texcoord, color, vertex */ - GLenum ctype = 0; /* color type */ - GLint coffset = 0, noffset = 0, voffset;/* color, normal, vertex offsets */ - const GLint toffset = 0; /* always zero */ - GLint defstride; /* default stride */ - GLint c, f; - - ASSERT_OUTSIDE_BEGIN_END_AND_FLUSH(ctx); - - f = sizeof(GLfloat); - c = f * ((4 * sizeof(GLubyte) + (f - 1)) / f); - - if (stride < 0) { - _mesa_error( ctx, GL_INVALID_VALUE, "glInterleavedArrays(stride)" ); - return; - } - - switch (format) { - case GL_V2F: - tflag = GL_FALSE; cflag = GL_FALSE; nflag = GL_FALSE; - tcomps = 0; ccomps = 0; vcomps = 2; - voffset = 0; - defstride = 2*f; - break; - case GL_V3F: - tflag = GL_FALSE; cflag = GL_FALSE; nflag = GL_FALSE; - tcomps = 0; ccomps = 0; vcomps = 3; - voffset = 0; - defstride = 3*f; - break; - case GL_C4UB_V2F: - tflag = GL_FALSE; cflag = GL_TRUE; nflag = GL_FALSE; - tcomps = 0; ccomps = 4; vcomps = 2; - ctype = GL_UNSIGNED_BYTE; - coffset = 0; - voffset = c; - defstride = c + 2*f; - break; - case GL_C4UB_V3F: - tflag = GL_FALSE; cflag = GL_TRUE; nflag = GL_FALSE; - tcomps = 0; ccomps = 4; vcomps = 3; - ctype = GL_UNSIGNED_BYTE; - coffset = 0; - voffset = c; - defstride = c + 3*f; - break; - case GL_C3F_V3F: - tflag = GL_FALSE; cflag = GL_TRUE; nflag = GL_FALSE; - tcomps = 0; ccomps = 3; vcomps = 3; - ctype = GL_FLOAT; - coffset = 0; - voffset = 3*f; - defstride = 6*f; - break; - case GL_N3F_V3F: - tflag = GL_FALSE; cflag = GL_FALSE; nflag = GL_TRUE; - tcomps = 0; ccomps = 0; vcomps = 3; - noffset = 0; - voffset = 3*f; - defstride = 6*f; - break; - case GL_C4F_N3F_V3F: - tflag = GL_FALSE; cflag = GL_TRUE; nflag = GL_TRUE; - tcomps = 0; ccomps = 4; vcomps = 3; - ctype = GL_FLOAT; - coffset = 0; - noffset = 4*f; - voffset = 7*f; - defstride = 10*f; - break; - case GL_T2F_V3F: - tflag = GL_TRUE; cflag = GL_FALSE; nflag = GL_FALSE; - tcomps = 2; ccomps = 0; vcomps = 3; - voffset = 2*f; - defstride = 5*f; - break; - case GL_T4F_V4F: - tflag = GL_TRUE; cflag = GL_FALSE; nflag = GL_FALSE; - tcomps = 4; ccomps = 0; vcomps = 4; - voffset = 4*f; - defstride = 8*f; - break; - case GL_T2F_C4UB_V3F: - tflag = GL_TRUE; cflag = GL_TRUE; nflag = GL_FALSE; - tcomps = 2; ccomps = 4; vcomps = 3; - ctype = GL_UNSIGNED_BYTE; - coffset = 2*f; - voffset = c+2*f; - defstride = c+5*f; - break; - case GL_T2F_C3F_V3F: - tflag = GL_TRUE; cflag = GL_TRUE; nflag = GL_FALSE; - tcomps = 2; ccomps = 3; vcomps = 3; - ctype = GL_FLOAT; - coffset = 2*f; - voffset = 5*f; - defstride = 8*f; - break; - case GL_T2F_N3F_V3F: - tflag = GL_TRUE; cflag = GL_FALSE; nflag = GL_TRUE; - tcomps = 2; ccomps = 0; vcomps = 3; - noffset = 2*f; - voffset = 5*f; - defstride = 8*f; - break; - case GL_T2F_C4F_N3F_V3F: - tflag = GL_TRUE; cflag = GL_TRUE; nflag = GL_TRUE; - tcomps = 2; ccomps = 4; vcomps = 3; - ctype = GL_FLOAT; - coffset = 2*f; - noffset = 6*f; - voffset = 9*f; - defstride = 12*f; - break; - case GL_T4F_C4F_N3F_V4F: - tflag = GL_TRUE; cflag = GL_TRUE; nflag = GL_TRUE; - tcomps = 4; ccomps = 4; vcomps = 4; - ctype = GL_FLOAT; - coffset = 4*f; - noffset = 8*f; - voffset = 11*f; - defstride = 15*f; - break; - default: - _mesa_error( ctx, GL_INVALID_ENUM, "glInterleavedArrays(format)" ); - return; - } - - if (stride==0) { - stride = defstride; - } - - _mesa_DisableClientState( GL_EDGE_FLAG_ARRAY ); - _mesa_DisableClientState( GL_INDEX_ARRAY ); - /* XXX also disable secondary color and generic arrays? */ - - /* Texcoords */ - if (tflag) { - _mesa_EnableClientState( GL_TEXTURE_COORD_ARRAY ); - _mesa_TexCoordPointer( tcomps, GL_FLOAT, stride, - (GLubyte *) pointer + toffset ); - } - else { - _mesa_DisableClientState( GL_TEXTURE_COORD_ARRAY ); - } - - /* Color */ - if (cflag) { - _mesa_EnableClientState( GL_COLOR_ARRAY ); - _mesa_ColorPointer( ccomps, ctype, stride, - (GLubyte *) pointer + coffset ); - } - else { - _mesa_DisableClientState( GL_COLOR_ARRAY ); - } - - - /* Normals */ - if (nflag) { - _mesa_EnableClientState( GL_NORMAL_ARRAY ); - _mesa_NormalPointer( GL_FLOAT, stride, (GLubyte *) pointer + noffset ); - } - else { - _mesa_DisableClientState( GL_NORMAL_ARRAY ); - } - - /* Vertices */ - _mesa_EnableClientState( GL_VERTEX_ARRAY ); - _mesa_VertexPointer( vcomps, GL_FLOAT, stride, - (GLubyte *) pointer + voffset ); -} - - -void GLAPIENTRY -_mesa_LockArraysEXT(GLint first, GLsizei count) -{ - GET_CURRENT_CONTEXT(ctx); - ASSERT_OUTSIDE_BEGIN_END_AND_FLUSH(ctx); - - if (MESA_VERBOSE & VERBOSE_API) - _mesa_debug(ctx, "glLockArrays %d %d\n", first, count); - - if (first < 0) { - _mesa_error( ctx, GL_INVALID_VALUE, "glLockArraysEXT(first)" ); - return; - } - if (count <= 0) { - _mesa_error( ctx, GL_INVALID_VALUE, "glLockArraysEXT(count)" ); - return; - } - if (ctx->Array.LockCount != 0) { - _mesa_error( ctx, GL_INVALID_OPERATION, "glLockArraysEXT(reentry)" ); - return; - } - - ctx->Array.LockFirst = first; - ctx->Array.LockCount = count; - - ctx->NewState |= _NEW_ARRAY; - ctx->Array.NewState |= VERT_BIT_ALL; -} - - -void GLAPIENTRY -_mesa_UnlockArraysEXT( void ) -{ - GET_CURRENT_CONTEXT(ctx); - ASSERT_OUTSIDE_BEGIN_END_AND_FLUSH(ctx); - - if (MESA_VERBOSE & VERBOSE_API) - _mesa_debug(ctx, "glUnlockArrays\n"); - - if (ctx->Array.LockCount == 0) { - _mesa_error( ctx, GL_INVALID_OPERATION, "glUnlockArraysEXT(reexit)" ); - return; - } - - ctx->Array.LockFirst = 0; - ctx->Array.LockCount = 0; - ctx->NewState |= _NEW_ARRAY; - ctx->Array.NewState |= VERT_BIT_ALL; -} - -/* GL_IBM_multimode_draw_arrays */ -void GLAPIENTRY -_mesa_MultiModeDrawArraysIBM( const GLenum * mode, const GLint * first, - const GLsizei * count, - GLsizei primcount, GLint modestride ) -{ - GET_CURRENT_CONTEXT(ctx); - GLint i; - - ASSERT_OUTSIDE_BEGIN_END_AND_FLUSH(ctx); - - for ( i = 0 ; i < primcount ; i++ ) { - if ( count[i] > 0 ) { - GLenum m = *((GLenum *) ((GLubyte *) mode + i * modestride)); - CALL_DrawArrays(ctx->Exec, ( m, first[i], count[i] )); - } - } -} - - -/* GL_IBM_multimode_draw_arrays */ -void GLAPIENTRY -_mesa_MultiModeDrawElementsIBM( const GLenum * mode, const GLsizei * count, - GLenum type, const GLvoid * const * indices, - GLsizei primcount, GLint modestride ) -{ - GET_CURRENT_CONTEXT(ctx); - GLint i; - - ASSERT_OUTSIDE_BEGIN_END_AND_FLUSH(ctx); - - /* XXX not sure about ARB_vertex_buffer_object handling here */ - - for ( i = 0 ; i < primcount ; i++ ) { - if ( count[i] > 0 ) { - GLenum m = *((GLenum *) ((GLubyte *) mode + i * modestride)); - CALL_DrawElements(ctx->Exec, ( m, count[i], type, indices[i] )); - } - } -} - - -/** - * Copy one client vertex array to another. - */ -void -_mesa_copy_client_array(struct gl_context *ctx, - struct gl_client_array *dst, - struct gl_client_array *src) -{ - dst->Size = src->Size; - dst->Type = src->Type; - dst->Stride = src->Stride; - dst->StrideB = src->StrideB; - dst->Ptr = src->Ptr; - dst->Enabled = src->Enabled; - dst->Normalized = src->Normalized; - dst->Integer = src->Integer; - dst->_ElementSize = src->_ElementSize; - _mesa_reference_buffer_object(ctx, &dst->BufferObj, src->BufferObj); - dst->_MaxElement = src->_MaxElement; -} - -static void -init_array(struct gl_context *ctx, - struct gl_client_array *array, GLint size, GLint type) -{ - array->Size = size; - array->Type = type; - array->Stride = 0; - array->StrideB = 0; - array->Ptr = NULL; - array->Enabled = GL_FALSE; - array->Normalized = GL_FALSE; - array->Integer = GL_FALSE; - array->_ElementSize = size * _mesa_sizeof_type(type); - /* Vertex array buffers */ - _mesa_reference_buffer_object(ctx, &array->BufferObj, - ctx->Shared->NullBufferObj); -} - - -/** - * Initialize vertex array state for given context. - */ -void -_mesa_init_varray(struct gl_context *ctx, struct gl_array_attrib *array) -{ - GLuint i; - - /* Init the individual arrays */ - for (i = 0; i < Elements(array->VertexAttrib); i++) { - switch (i) { - case VERT_ATTRIB_WEIGHT: - init_array(ctx, &array->VertexAttrib[VERT_ATTRIB_WEIGHT], 1, GL_FLOAT); - break; - case VERT_ATTRIB_NORMAL: - init_array(ctx, &array->VertexAttrib[VERT_ATTRIB_NORMAL], 3, GL_FLOAT); - break; - case VERT_ATTRIB_FOG: - init_array(ctx, &array->VertexAttrib[VERT_ATTRIB_FOG], 1, GL_FLOAT); - break; - case VERT_ATTRIB_COLOR_INDEX: - init_array(ctx, &array->VertexAttrib[VERT_ATTRIB_COLOR_INDEX], 1, GL_FLOAT); - break; - case VERT_ATTRIB_EDGEFLAG: - init_array(ctx, &array->VertexAttrib[VERT_ATTRIB_EDGEFLAG], 1, GL_BOOL); - break; - default: - init_array(ctx, &array->VertexAttrib[i], 4, GL_FLOAT); - break; - } - } -} - - -/** - * Free vertex array state for given context. - */ -void -_mesa_free_varray_data(struct gl_context *ctx, struct gl_array_attrib* array) -{ - GLuint i; - - /* Uninit the individual arrays */ - for (i = 0; i < Elements(array->VertexAttrib); i++) - { - _mesa_reference_buffer_object(ctx, &array->VertexAttrib[i].BufferObj, NULL); - memset(&array->VertexAttrib[i], 0, sizeof(struct gl_client_array)); - } -} diff --git a/dll/opengl/mesa/main/varray.h b/dll/opengl/mesa/main/varray.h deleted file mode 100644 index 0a984bcec88..00000000000 --- a/dll/opengl/mesa/main/varray.h +++ /dev/null @@ -1,183 +0,0 @@ -/* - * Mesa 3-D graphics library - * Version: 7.6 - * - * Copyright (C) 1999-2008 Brian Paul All Rights Reserved. - * Copyright (C) 2009 VMware, Inc. All Rights Reserved. - * - * Permission is hereby granted, free of charge, to any person obtaining a - * copy of this software and associated documentation files (the "Software"), - * to deal in the Software without restriction, including without limitation - * the rights to use, copy, modify, merge, publish, distribute, sublicense, - * and/or sell copies of the Software, and to permit persons to whom the - * Software is furnished to do so, subject to the following conditions: - * - * The above copyright notice and this permission notice shall be included - * in all copies or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS - * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL - * BRIAN PAUL BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN - * AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN - * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. - */ - - -#ifndef VARRAY_H -#define VARRAY_H - - -#include "glheader.h" -#include "mfeatures.h" - -struct gl_client_array; -struct gl_context; - - -/** - * Compute the index of the last array element that can be safely accessed in - * a vertex array. We can really only do this when the array lives in a VBO. - * The array->_MaxElement field will be updated. - * Later in glDrawArrays/Elements/etc we can do some bounds checking. - */ -static inline void -_mesa_update_array_max_element(struct gl_client_array *array) -{ - assert(array->Enabled); - - if (array->BufferObj->Name) { - GLsizeiptrARB offset = (GLsizeiptrARB) array->Ptr; - GLsizeiptrARB bufSize = (GLsizeiptrARB) array->BufferObj->Size; - - if (offset < bufSize) { - array->_MaxElement = (bufSize - offset + array->StrideB - - array->_ElementSize) / array->StrideB; - } - else { - array->_MaxElement = 0; - } - } - else { - /* user-space array, no idea how big it is */ - array->_MaxElement = 2 * 1000 * 1000 * 1000; /* just a big number */ - } -} - - -#if _HAVE_FULL_GL - -extern void GLAPIENTRY -_mesa_VertexPointer(GLint size, GLenum type, GLsizei stride, - const GLvoid *ptr); - -extern void GLAPIENTRY -_mesa_UnlockArraysEXT( void ); - -extern void GLAPIENTRY -_mesa_LockArraysEXT(GLint first, GLsizei count); - - -extern void GLAPIENTRY -_mesa_NormalPointer(GLenum type, GLsizei stride, const GLvoid *ptr); - - -extern void GLAPIENTRY -_mesa_ColorPointer(GLint size, GLenum type, GLsizei stride, const GLvoid *ptr); - - -extern void GLAPIENTRY -_mesa_IndexPointer(GLenum type, GLsizei stride, const GLvoid *ptr); - - -extern void GLAPIENTRY -_mesa_TexCoordPointer(GLint size, GLenum type, GLsizei stride, - const GLvoid *ptr); - - -extern void GLAPIENTRY -_mesa_EdgeFlagPointer(GLsizei stride, const GLvoid *ptr); - - -extern void GLAPIENTRY -_mesa_VertexPointerEXT(GLint size, GLenum type, GLsizei stride, - GLsizei count, const GLvoid *ptr); - - -extern void GLAPIENTRY -_mesa_NormalPointerEXT(GLenum type, GLsizei stride, GLsizei count, - const GLvoid *ptr); - - -extern void GLAPIENTRY -_mesa_ColorPointerEXT(GLint size, GLenum type, GLsizei stride, GLsizei count, - const GLvoid *ptr); - - -extern void GLAPIENTRY -_mesa_IndexPointerEXT(GLenum type, GLsizei stride, GLsizei count, - const GLvoid *ptr); - - -extern void GLAPIENTRY -_mesa_TexCoordPointerEXT(GLint size, GLenum type, GLsizei stride, - GLsizei count, const GLvoid *ptr); - - -extern void GLAPIENTRY -_mesa_EdgeFlagPointerEXT(GLsizei stride, GLsizei count, const GLboolean *ptr); - - -extern void GLAPIENTRY -_mesa_FogCoordPointerEXT(GLenum type, GLsizei stride, const GLvoid *ptr); - - -extern void GLAPIENTRY -_mesa_InterleavedArrays(GLenum format, GLsizei stride, const GLvoid *pointer); - -extern void GLAPIENTRY -_mesa_MultiModeDrawArraysIBM( const GLenum * mode, const GLint * first, - const GLsizei * count, - GLsizei primcount, GLint modestride ); - - -extern void GLAPIENTRY -_mesa_MultiModeDrawElementsIBM( const GLenum * mode, const GLsizei * count, - GLenum type, const GLvoid * const * indices, - GLsizei primcount, GLint modestride ); - -extern void GLAPIENTRY -_mesa_LockArraysEXT(GLint first, GLsizei count); - -extern void GLAPIENTRY -_mesa_UnlockArraysEXT( void ); - - -extern void GLAPIENTRY -_mesa_DrawArrays(GLenum mode, GLint first, GLsizei count); - -extern void GLAPIENTRY -_mesa_DrawElements(GLenum mode, GLsizei count, GLenum type, - const GLvoid *indices); - - -extern void -_mesa_copy_client_array(struct gl_context *ctx, - struct gl_client_array *dst, - struct gl_client_array *src); - -extern void -_mesa_init_varray( struct gl_context * ctx, struct gl_array_attrib *array); - -extern void -_mesa_free_varray_data(struct gl_context *ctx, struct gl_array_attrib *array); - -#else - -/** No-op */ -#define _mesa_init_varray( c ) ((void)0) -#define _mesa_free_varray_data( c ) ((void)0) - -#endif - -#endif diff --git a/dll/opengl/mesa/main/version.c b/dll/opengl/mesa/main/version.c deleted file mode 100644 index 89c912cbd1b..00000000000 --- a/dll/opengl/mesa/main/version.c +++ /dev/null @@ -1,89 +0,0 @@ -/* - * Mesa 3-D graphics library - * - * Copyright (C) 2010 VMware, Inc. All Rights Reserved. - * - * Permission is hereby granted, free of charge, to any person obtaining a - * copy of this software and associated documentation files (the "Software"), - * to deal in the Software without restriction, including without limitation - * the rights to use, copy, modify, merge, publish, distribute, sublicense, - * and/or sell copies of the Software, and to permit persons to whom the - * Software is furnished to do so, subject to the following conditions: - * - * The above copyright notice and this permission notice shall be included - * in all copies or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS - * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL - * THE AUTHORS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN - * AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN - * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. - */ - -#include - -#include "git_sha1.h" - -/** - * Override the context's GL version if the environment variable - * MESA_GL_VERSION_OVERRIDE is set. Valid values of MESA_GL_VERSION_OVERRIDE - * are point-separated version numbers, such as "3.0". - */ -static void -override_version(struct gl_context *ctx, GLuint *major, GLuint *minor) -{ - const char *env_var = "MESA_GL_VERSION_OVERRIDE"; - const char *version; - int n; - - version = getenv(env_var); - if (!version) { - return; - } - - n = sscanf(version, "%u.%u", major, minor); - if (n != 2) { - fprintf(stderr, "error: invalid value for %s: %s\n", env_var, version); - return; - } -} - -/** - * Examine enabled GL extensions to determine GL version. - * Return major and minor version numbers. - */ -static void -compute_version(struct gl_context *ctx) -{ - /* report openGL 1.1 */ - ctx->VersionMajor = 1; - ctx->VersionMinor = 1; - - override_version(ctx, &ctx->VersionMajor, &ctx->VersionMinor); - - ctx->VersionString = (char *) malloc(20); - if (ctx->VersionString) { - _mesa_snprintf(ctx->VersionString, 20, - "%u.%u Mesa " MESA_VERSION_STRING -#ifdef MESA_GIT_SHA1 - " (" MESA_GIT_SHA1 ")" -#endif - , - ctx->VersionMajor, ctx->VersionMinor); - } -} - -/** - * Set the context's VersionMajor, VersionMinor, VersionString fields. - * This should only be called once as part of context initialization - * or to perform version check for GLX_ARB_create_context_profile. - */ -void -_mesa_compute_version(struct gl_context *ctx) -{ - if (ctx->VersionMajor) - return; - - compute_version(ctx); -} diff --git a/dll/opengl/mesa/main/version.h b/dll/opengl/mesa/main/version.h deleted file mode 100644 index a34cc52000a..00000000000 --- a/dll/opengl/mesa/main/version.h +++ /dev/null @@ -1,48 +0,0 @@ -/* - * Mesa 3-D graphics library - * Version: 7.11 - * - * Copyright (C) 1999-2008 Brian Paul All Rights Reserved. - * Copyright (C) 2009 VMware, Inc. All Rights Reserved. - * - * Permission is hereby granted, free of charge, to any person obtaining a - * copy of this software and associated documentation files (the "Software"), - * to deal in the Software without restriction, including without limitation - * the rights to use, copy, modify, merge, publish, distribute, sublicense, - * and/or sell copies of the Software, and to permit persons to whom the - * Software is furnished to do so, subject to the following conditions: - * - * The above copyright notice and this permission notice shall be included - * in all copies or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS - * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL - * BRIAN PAUL BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN - * AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN - * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. - */ - - -#ifndef VERSION_H -#define VERSION_H - - -struct gl_context; - - -/* Mesa version */ -#define MESA_MAJOR 8 -#define MESA_MINOR 0 -#define MESA_PATCH 4 -#define MESA_VERSION_STRING "8.0.4" - -/* To make version comparison easy */ -#define MESA_VERSION(a,b,c) (((a) << 16) + ((b) << 8) + (c)) -#define MESA_VERSION_CODE MESA_VERSION(MESA_MAJOR, MESA_MINOR, MESA_PATCH) - - -extern void -_mesa_compute_version(struct gl_context *ctx); - -#endif /* VERSION_H */ diff --git a/dll/opengl/mesa/main/viewport.c b/dll/opengl/mesa/main/viewport.c deleted file mode 100644 index b51c55c5300..00000000000 --- a/dll/opengl/mesa/main/viewport.c +++ /dev/null @@ -1,174 +0,0 @@ -/* - * Mesa 3-D graphics library - * Version: 7.5 - * - * Copyright (C) 2009 VMware, Inc. All Rights Reserved. - * - * Permission is hereby granted, free of charge, to any person obtaining a - * copy of this software and associated documentation files (the "Software"), - * to deal in the Software without restriction, including without limitation - * the rights to use, copy, modify, merge, publish, distribute, sublicense, - * and/or sell copies of the Software, and to permit persons to whom the - * Software is furnished to do so, subject to the following conditions: - * - * The above copyright notice and this permission notice shall be included - * in all copies or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS - * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL - * BRIAN PAUL BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN - * AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN - * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. - */ - - -/** - * \file viewport.c - * glViewport and glDepthRange functions. - */ - -#include - -/** - * Set the viewport. - * \sa Called via glViewport() or display list execution. - * - * Flushes the vertices and calls _mesa_set_viewport() with the given - * parameters. - */ -void GLAPIENTRY -_mesa_Viewport(GLint x, GLint y, GLsizei width, GLsizei height) -{ - GET_CURRENT_CONTEXT(ctx); - ASSERT_OUTSIDE_BEGIN_END_AND_FLUSH(ctx); - _mesa_set_viewport(ctx, x, y, width, height); -} - - -/** - * Set new viewport parameters and update derived state (the _WindowMap - * matrix). Usually called from _mesa_Viewport(). - * - * \param ctx GL context. - * \param x, y coordinates of the lower left corner of the viewport rectangle. - * \param width width of the viewport rectangle. - * \param height height of the viewport rectangle. - */ -void -_mesa_set_viewport(struct gl_context *ctx, GLint x, GLint y, - GLsizei width, GLsizei height) -{ - if (MESA_VERBOSE & VERBOSE_API) - _mesa_debug(ctx, "glViewport %d %d %d %d\n", x, y, width, height); - - if (width < 0 || height < 0) { - _mesa_error(ctx, GL_INVALID_VALUE, - "glViewport(%d, %d, %d, %d)", x, y, width, height); - return; - } - - /* clamp width and height to the implementation dependent range */ - width = MIN2(width, (GLsizei) ctx->Const.MaxViewportWidth); - height = MIN2(height, (GLsizei) ctx->Const.MaxViewportHeight); - - ctx->Viewport.X = x; - ctx->Viewport.Width = width; - ctx->Viewport.Y = y; - ctx->Viewport.Height = height; - ctx->NewState |= _NEW_VIEWPORT; - -#if 1 - /* XXX remove this someday. Currently the DRI drivers rely on - * the WindowMap matrix being up to date in the driver's Viewport - * and DepthRange functions. - */ - _math_matrix_viewport(&ctx->Viewport._WindowMap, - ctx->Viewport.X, ctx->Viewport.Y, - ctx->Viewport.Width, ctx->Viewport.Height, - ctx->Viewport.Near, ctx->Viewport.Far, - ctx->DrawBuffer->_DepthMaxF); -#endif - - if (ctx->Driver.Viewport) { - /* Many drivers will use this call to check for window size changes - * and reallocate the z/stencil/accum/etc buffers if needed. - */ - ctx->Driver.Viewport(ctx, x, y, width, height); - } -} - - -/** - * Called by glDepthRange - * - * \param nearval specifies the Z buffer value which should correspond to - * the near clip plane - * \param farval specifies the Z buffer value which should correspond to - * the far clip plane - */ -void GLAPIENTRY -_mesa_DepthRange(GLclampd nearval, GLclampd farval) -{ - GET_CURRENT_CONTEXT(ctx); - ASSERT_OUTSIDE_BEGIN_END_AND_FLUSH(ctx); - - if (MESA_VERBOSE&VERBOSE_API) - _mesa_debug(ctx, "glDepthRange %f %f\n", nearval, farval); - - if (ctx->Viewport.Near == nearval && - ctx->Viewport.Far == farval) - return; - - ctx->Viewport.Near = (GLfloat) CLAMP(nearval, 0.0, 1.0); - ctx->Viewport.Far = (GLfloat) CLAMP(farval, 0.0, 1.0); - ctx->NewState |= _NEW_VIEWPORT; - -#if 1 - /* XXX remove this someday. Currently the DRI drivers rely on - * the WindowMap matrix being up to date in the driver's Viewport - * and DepthRange functions. - */ - _math_matrix_viewport(&ctx->Viewport._WindowMap, - ctx->Viewport.X, ctx->Viewport.Y, - ctx->Viewport.Width, ctx->Viewport.Height, - ctx->Viewport.Near, ctx->Viewport.Far, - ctx->DrawBuffer->_DepthMaxF); -#endif - - if (ctx->Driver.DepthRange) { - ctx->Driver.DepthRange(ctx, nearval, farval); - } -} - -/** - * Initialize the context viewport attribute group. - * \param ctx the GL context. - */ -void _mesa_init_viewport(struct gl_context *ctx) -{ - GLfloat depthMax = 65535.0F; /* sorf of arbitrary */ - - /* Viewport group */ - ctx->Viewport.X = 0; - ctx->Viewport.Y = 0; - ctx->Viewport.Width = 0; - ctx->Viewport.Height = 0; - ctx->Viewport.Near = 0.0; - ctx->Viewport.Far = 1.0; - _math_matrix_ctr(&ctx->Viewport._WindowMap); - - _math_matrix_viewport(&ctx->Viewport._WindowMap, 0, 0, 0, 0, - 0.0F, 1.0F, depthMax); -} - - -/** - * Free the context viewport attribute group data. - * \param ctx the GL context. - */ -void _mesa_free_viewport_data(struct gl_context *ctx) -{ - _math_matrix_dtr(&ctx->Viewport._WindowMap); -} - diff --git a/dll/opengl/mesa/main/viewport.h b/dll/opengl/mesa/main/viewport.h deleted file mode 100644 index 909ff92eee5..00000000000 --- a/dll/opengl/mesa/main/viewport.h +++ /dev/null @@ -1,55 +0,0 @@ -/* - * Mesa 3-D graphics library - * Version: 7.5 - * - * Copyright (C) 1999-2008 Brian Paul All Rights Reserved. - * Copyright (C) 2009 VMware, Inc. All Rights Reserved. - * - * Permission is hereby granted, free of charge, to any person obtaining a - * copy of this software and associated documentation files (the "Software"), - * to deal in the Software without restriction, including without limitation - * the rights to use, copy, modify, merge, publish, distribute, sublicense, - * and/or sell copies of the Software, and to permit persons to whom the - * Software is furnished to do so, subject to the following conditions: - * - * The above copyright notice and this permission notice shall be included - * in all copies or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS - * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL - * BRIAN PAUL BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN - * AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN - * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. - */ - - -#ifndef VIEWPORT_H -#define VIEWPORT_H - -#include "glheader.h" - -struct gl_context; - -extern void GLAPIENTRY -_mesa_Viewport(GLint x, GLint y, GLsizei width, GLsizei height); - - -extern void -_mesa_set_viewport(struct gl_context *ctx, GLint x, GLint y, - GLsizei width, GLsizei height); - - -extern void GLAPIENTRY -_mesa_DepthRange(GLclampd nearval, GLclampd farval); - - -extern void -_mesa_init_viewport(struct gl_context *ctx); - - -extern void -_mesa_free_viewport_data(struct gl_context *ctx); - - -#endif diff --git a/dll/opengl/mesa/main/vsnprintf.c b/dll/opengl/mesa/main/vsnprintf.c deleted file mode 100644 index ab6c740d772..00000000000 --- a/dll/opengl/mesa/main/vsnprintf.c +++ /dev/null @@ -1,165 +0,0 @@ -/* - * Revision 12: http://theos.com/~deraadt/snprintf.c - * - * Copyright (c) 1997 Theo de Raadt - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * - * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR - * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES - * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. - * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, - * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT - * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, - * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY - * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT - * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF - * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - */ - -#ifndef __VMS -# include -#endif -#include -#include -#include -#include -#if __STDC__ -#include -#include -#else -#include -#endif -#include -#include -#include - -#ifndef roundup -#define roundup(x, y) ((((x)+((y)-1))/(y))*(y)) -#endif - -#ifdef __sgi -#define size_t ssize_t -#endif - -static int pgsize; -static char *curobj; -static int caught; -static sigjmp_buf bail; - -#define EXTRABYTES 2 /* XXX: why 2? you don't want to know */ - -static char * -msetup(str, n) - char *str; - size_t n; -{ - char *e; - - if (n == 0) - return NULL; - if (pgsize == 0) - pgsize = getpagesize(); - curobj = (char *)malloc(n + EXTRABYTES + pgsize * 2); - if (curobj == NULL) - return NULL; - e = curobj + n + EXTRABYTES; - e = (char *)roundup((unsigned long)e, pgsize); - if (mprotect(e, pgsize, PROT_NONE) == -1) { - free(curobj); - curobj = NULL; - return NULL; - } - e = e - n - EXTRABYTES; - *e = '\0'; - return (e); -} - -static void - mcatch( int a ) -{ - siglongjmp(bail, 1); -} - -static void -mcleanup(str, n, p) - char *str; - size_t n; - char *p; -{ - strncpy(str, p, n-1); - str[n-1] = '\0'; - if (mprotect((caddr_t)(p + n + EXTRABYTES), pgsize, - PROT_READ|PROT_WRITE|PROT_EXEC) == -1) - mprotect((caddr_t)(p + n + EXTRABYTES), pgsize, - PROT_READ|PROT_WRITE); - free(curobj); -} - -int -#if __STDC__ -vsnprintf(char *str, size_t n, char const *fmt, va_list ap) -#else -vsnprintf(str, n, fmt, ap) - char *str; - size_t n; - char *fmt; - char *ap; -#endif -{ - struct sigaction osa, nsa; - char *p; - int ret = n + 1; /* if we bail, indicated we overflowed */ - - memset(&nsa, 0, sizeof nsa); - nsa.sa_handler = mcatch; - sigemptyset(&nsa.sa_mask); - - p = msetup(str, n); - if (p == NULL) { - *str = '\0'; - return 0; - } - if (sigsetjmp(bail, 1) == 0) { - if (sigaction(SIGSEGV, &nsa, &osa) == -1) { - mcleanup(str, n, p); - return (0); - } - ret = vsprintf(p, fmt, ap); - } - mcleanup(str, n, p); - (void) sigaction(SIGSEGV, &osa, NULL); - return (ret); -} - -int -#if __STDC__ -snprintf(char *str, size_t n, char const *fmt, ...) -#else -snprintf(str, n, fmt, va_alist) - char *str; - size_t n; - char *fmt; - va_dcl -#endif -{ - va_list ap; -#if __STDC__ - va_start(ap, fmt); -#else - va_start(ap); -#endif - - return (vsnprintf(str, n, fmt, ap)); - va_end(ap); -} - - - diff --git a/dll/opengl/mesa/main/vtxfmt.c b/dll/opengl/mesa/main/vtxfmt.c deleted file mode 100644 index 877a4714f6e..00000000000 --- a/dll/opengl/mesa/main/vtxfmt.c +++ /dev/null @@ -1,115 +0,0 @@ -/* - * Mesa 3-D graphics library - * Version: 6.3 - * - * Copyright (C) 1999-2004 Brian Paul All Rights Reserved. - * - * Permission is hereby granted, free of charge, to any person obtaining a - * copy of this software and associated documentation files (the "Software"), - * to deal in the Software without restriction, including without limitation - * the rights to use, copy, modify, merge, publish, distribute, sublicense, - * and/or sell copies of the Software, and to permit persons to whom the - * Software is furnished to do so, subject to the following conditions: - * - * The above copyright notice and this permission notice shall be included - * in all copies or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS - * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL - * BRIAN PAUL BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN - * AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN - * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. - * - * Authors: - * Keith Whitwell - * Gareth Hughes - */ - -#include - -#if FEATURE_beginend - -/** - * Use the per-vertex functions found in to initialoze the given - * API dispatch table. - */ -static void -install_vtxfmt( struct _glapi_table *tab, const GLvertexformat *vfmt ) -{ - _mesa_install_arrayelt_vtxfmt(tab, vfmt); - - SET_Color3f(tab, vfmt->Color3f); - SET_Color3fv(tab, vfmt->Color3fv); - SET_Color4f(tab, vfmt->Color4f); - SET_Color4fv(tab, vfmt->Color4fv); - SET_EdgeFlag(tab, vfmt->EdgeFlag); - - _mesa_install_eval_vtxfmt(tab, vfmt); - - SET_FogCoordfEXT(tab, vfmt->FogCoordfEXT); - SET_FogCoordfvEXT(tab, vfmt->FogCoordfvEXT); - SET_Indexf(tab, vfmt->Indexf); - SET_Indexfv(tab, vfmt->Indexfv); - SET_Materialfv(tab, vfmt->Materialfv); - SET_Normal3f(tab, vfmt->Normal3f); - SET_Normal3fv(tab, vfmt->Normal3fv); - SET_TexCoord1f(tab, vfmt->TexCoord1f); - SET_TexCoord1fv(tab, vfmt->TexCoord1fv); - SET_TexCoord2f(tab, vfmt->TexCoord2f); - SET_TexCoord2fv(tab, vfmt->TexCoord2fv); - SET_TexCoord3f(tab, vfmt->TexCoord3f); - SET_TexCoord3fv(tab, vfmt->TexCoord3fv); - SET_TexCoord4f(tab, vfmt->TexCoord4f); - SET_TexCoord4fv(tab, vfmt->TexCoord4fv); - SET_Vertex2f(tab, vfmt->Vertex2f); - SET_Vertex2fv(tab, vfmt->Vertex2fv); - SET_Vertex3f(tab, vfmt->Vertex3f); - SET_Vertex3fv(tab, vfmt->Vertex3fv); - SET_Vertex4f(tab, vfmt->Vertex4f); - SET_Vertex4fv(tab, vfmt->Vertex4fv); - - _mesa_install_dlist_vtxfmt(tab, vfmt); /* glCallList / glCallLists */ - - SET_Begin(tab, vfmt->Begin); - SET_End(tab, vfmt->End); - - SET_Rectf(tab, vfmt->Rectf); - - SET_DrawArrays(tab, vfmt->DrawArrays); - SET_DrawElements(tab, vfmt->DrawElements); - - /* GL_NV_vertex_program */ - SET_VertexAttrib1fNV(tab, vfmt->VertexAttrib1fNV); - SET_VertexAttrib1fvNV(tab, vfmt->VertexAttrib1fvNV); - SET_VertexAttrib2fNV(tab, vfmt->VertexAttrib2fNV); - SET_VertexAttrib2fvNV(tab, vfmt->VertexAttrib2fvNV); - SET_VertexAttrib3fNV(tab, vfmt->VertexAttrib3fNV); - SET_VertexAttrib3fvNV(tab, vfmt->VertexAttrib3fvNV); - SET_VertexAttrib4fNV(tab, vfmt->VertexAttrib4fNV); - SET_VertexAttrib4fvNV(tab, vfmt->VertexAttrib4fvNV); -} - - -/** - * Install per-vertex functions into the API dispatch table for execution. - */ -void -_mesa_install_exec_vtxfmt(struct gl_context *ctx, const GLvertexformat *vfmt) -{ - install_vtxfmt( ctx->Exec, vfmt ); -} - - -/** - * Install per-vertex functions into the API dispatch table for display - * list compilation. - */ -void -_mesa_install_save_vtxfmt(struct gl_context *ctx, const GLvertexformat *vfmt) -{ - install_vtxfmt( ctx->Save, vfmt ); -} - - -#endif /* FEATURE_beginend */ diff --git a/dll/opengl/mesa/main/vtxfmt.h b/dll/opengl/mesa/main/vtxfmt.h deleted file mode 100644 index aac656879bf..00000000000 --- a/dll/opengl/mesa/main/vtxfmt.h +++ /dev/null @@ -1,59 +0,0 @@ -/** - * \file vtxfmt.h - * - * \author Keith Whitwell - * \author Gareth Hughes - */ - -/* - * Mesa 3-D graphics library - * Version: 6.1 - * - * Copyright (C) 1999-2004 Brian Paul All Rights Reserved. - * - * Permission is hereby granted, free of charge, to any person obtaining a - * copy of this software and associated documentation files (the "Software"), - * to deal in the Software without restriction, including without limitation - * the rights to use, copy, modify, merge, publish, distribute, sublicense, - * and/or sell copies of the Software, and to permit persons to whom the - * Software is furnished to do so, subject to the following conditions: - * - * The above copyright notice and this permission notice shall be included - * in all copies or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS - * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL - * BRIAN PAUL BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN - * AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN - * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. - */ - - -#ifndef _VTXFMT_H_ -#define _VTXFMT_H_ - -#include "compiler.h" -#include "mfeatures.h" -#include "mtypes.h" - -#if FEATURE_beginend - -extern void _mesa_install_exec_vtxfmt( struct gl_context *ctx, const GLvertexformat *vfmt ); -extern void _mesa_install_save_vtxfmt( struct gl_context *ctx, const GLvertexformat *vfmt ); - -#else /* FEATURE_beginend */ - -static inline void -_mesa_install_exec_vtxfmt( struct gl_context *ctx, const GLvertexformat *vfmt ) -{ -} - -static inline void -_mesa_install_save_vtxfmt( struct gl_context *ctx, const GLvertexformat *vfmt ) -{ -} - -#endif /* FEATURE_beginend */ - -#endif /* _VTXFMT_H_ */ diff --git a/dll/opengl/mesa/masking.c b/dll/opengl/mesa/masking.c new file mode 100644 index 00000000000..80a07e36169 --- /dev/null +++ b/dll/opengl/mesa/masking.c @@ -0,0 +1,200 @@ +/* $Id: masking.c,v 1.5 1997/07/24 01:23:16 brianp Exp $ */ + +/* + * Mesa 3-D graphics library + * Version: 2.4 + * Copyright (C) 1995-1997 Brian Paul + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Library General Public + * License as published by the Free Software Foundation; either + * version 2 of the License, or (at your option) any later version. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Library General Public License for more details. + * + * You should have received a copy of the GNU Library General Public + * License along with this library; if not, write to the Free + * Software Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. + */ + + +/* + * $Log: masking.c,v $ + * Revision 1.5 1997/07/24 01:23:16 brianp + * changed precompiled header symbol from PCH to PC_HEADER + * + * Revision 1.4 1997/05/28 03:25:43 brianp + * added precompiled header (PCH) support + * + * Revision 1.3 1996/11/06 04:19:40 brianp + * now call gl_read_color/index_span() instead of device driver function + * + * Revision 1.2 1996/10/25 00:07:46 brianp + * changed MAX_WIDTH to PB_SIZE in gl_mask_index_pixels() + * + * Revision 1.1 1996/09/13 01:38:16 brianp + * Initial revision + * + */ + + +/* + * Implement the effect of glColorMask and glIndexMask in software. + */ + + +#ifdef PC_HEADER +#include "all.h" +#else +#include +#include "alphabuf.h" +#include "context.h" +#include "macros.h" +#include "masking.h" +#include "pb.h" +#include "span.h" +#include "types.h" +#endif + + + +void gl_IndexMask( GLcontext *ctx, GLuint mask ) +{ + if (INSIDE_BEGIN_END(ctx)) { + gl_error( ctx, GL_INVALID_OPERATION, "glIndexMask" ); + return; + } + ctx->Color.IndexMask = mask; + ctx->NewState |= NEW_RASTER_OPS; +} + + + +void gl_ColorMask( GLcontext *ctx, GLboolean red, GLboolean green, + GLboolean blue, GLboolean alpha ) +{ + if (INSIDE_BEGIN_END(ctx)) { + gl_error( ctx, GL_INVALID_OPERATION, "glColorMask" ); + return; + } + ctx->Color.ColorMask = (red << 3) | (green << 2) | (blue << 1) | alpha; + ctx->NewState |= NEW_RASTER_OPS; +} + + + + +/* + * Apply glColorMask to a span of RGBA pixels. + */ +void gl_mask_color_span( GLcontext *ctx, + GLuint n, GLint x, GLint y, + GLubyte red[], GLubyte green[], + GLubyte blue[], GLubyte alpha[] ) +{ + GLubyte r[MAX_WIDTH], g[MAX_WIDTH], b[MAX_WIDTH], a[MAX_WIDTH]; + + gl_read_color_span( ctx, n, x, y, r, g, b, a ); + + if ((ctx->Color.ColorMask & 8) == 0) { + /* replace source reds with frame buffer reds */ + MEMCPY( red, r, n ); + } + if ((ctx->Color.ColorMask & 4) == 0) { + /* replace source greens with frame buffer greens */ + MEMCPY( green, g, n ); + } + if ((ctx->Color.ColorMask & 2) == 0) { + /* replace source blues with frame buffer blues */ + MEMCPY( blue, b, n ); + } + if ((ctx->Color.ColorMask & 1) == 0) { + /* replace source alphas with frame buffer alphas */ + MEMCPY( alpha, a, n ); + } +} + + + +/* + * Apply glColorMask to an array of RGBA pixels. + */ +void gl_mask_color_pixels( GLcontext *ctx, + GLuint n, const GLint x[], const GLint y[], + GLubyte red[], GLubyte green[], + GLubyte blue[], GLubyte alpha[], + const GLubyte mask[] ) +{ + GLubyte r[PB_SIZE], g[PB_SIZE], b[PB_SIZE], a[PB_SIZE]; + + (*ctx->Driver.ReadColorPixels)( ctx, n, x, y, r, g, b, a, mask ); + if (ctx->RasterMask & ALPHABUF_BIT) { + gl_read_alpha_pixels( ctx, n, x, y, a, mask ); + } + + if ((ctx->Color.ColorMask & 8) == 0) { + /* replace source reds with frame buffer reds */ + MEMCPY( red, r, n ); + } + if ((ctx->Color.ColorMask & 4) == 0) { + /* replace source greens with frame buffer greens */ + MEMCPY( green, g, n ); + } + if ((ctx->Color.ColorMask & 2) == 0) { + /* replace source blues with frame buffer blues */ + MEMCPY( blue, b, n ); + } + if ((ctx->Color.ColorMask & 1) == 0) { + /* replace source alphas with frame buffer alphas */ + MEMCPY( alpha, a, n ); + } +} + + + +/* + * Apply glIndexMask to a span of CI pixels. + */ +void gl_mask_index_span( GLcontext *ctx, + GLuint n, GLint x, GLint y, GLuint index[] ) +{ + GLuint i; + GLuint fbindexes[MAX_WIDTH]; + GLuint msrc, mdest; + + gl_read_index_span( ctx, n, x, y, fbindexes ); + + msrc = ctx->Color.IndexMask; + mdest = ~msrc; + + for (i=0;iDriver.ReadIndexPixels)( ctx, n, x, y, fbindexes, mask ); + + msrc = ctx->Color.IndexMask; + mdest = ~msrc; + + for (i=0;istride; - const GLfloat *from = (GLfloat *)clip_vec->start; - const GLuint count = clip_vec->count; - GLuint c = 0; - GLfloat (*vProj)[4] = (GLfloat (*)[4])proj_vec->start; - GLubyte tmpAndMask = *andMask; - GLubyte tmpOrMask = *orMask; - GLuint i; - STRIDE_LOOP { - const GLfloat cx = from[0]; - const GLfloat cy = from[1]; - const GLfloat cz = from[2]; - const GLfloat cw = from[3]; -#if defined(macintosh) || defined(__powerpc__) - /* on powerpc cliptest is 17% faster in this way. */ - GLuint mask; - mask = (((cw < cx) << CLIP_RIGHT_SHIFT)); - mask |= (((cw < -cx) << CLIP_LEFT_SHIFT)); - mask |= (((cw < cy) << CLIP_TOP_SHIFT)); - mask |= (((cw < -cy) << CLIP_BOTTOM_SHIFT)); - mask |= (((cw < cz) << CLIP_FAR_SHIFT)); - mask |= (((cw < -cz) << CLIP_NEAR_SHIFT)); -#else /* !defined(macintosh)) */ - GLubyte mask = 0; - if (-cx + cw < 0) mask |= CLIP_RIGHT_BIT; - if ( cx + cw < 0) mask |= CLIP_LEFT_BIT; - if (-cy + cw < 0) mask |= CLIP_TOP_BIT; - if ( cy + cw < 0) mask |= CLIP_BOTTOM_BIT; - if (-cz + cw < 0) mask |= CLIP_FAR_BIT; - if ( cz + cw < 0) mask |= CLIP_NEAR_BIT; -#endif /* defined(macintosh) */ - - clipMask[i] = mask; - if (mask) { - c++; - tmpAndMask &= mask; - tmpOrMask |= mask; - vProj[i][0] = 0; - vProj[i][1] = 0; - vProj[i][2] = 0; - vProj[i][3] = 1; - } else { - GLfloat oow = 1.0F / cw; - vProj[i][0] = cx * oow; - vProj[i][1] = cy * oow; - vProj[i][2] = cz * oow; - vProj[i][3] = oow; - } - } - - *orMask = tmpOrMask; - *andMask = (GLubyte) (c < count ? 0 : tmpAndMask); - - proj_vec->flags |= VEC_SIZE_4; - proj_vec->size = 4; - proj_vec->count = clip_vec->count; - return proj_vec; -} - - - -/* - * \param clip_vec vector of incoming clip-space coords - * \param proj_vec vector of resultant NDC-space projected coords - * \param clipMask resulting array of clip flags - * \param orMask bitwise-OR of clipMask values - * \param andMask bitwise-AND of clipMask values - * \return clip_vec pointer - */ -static GLvector4f * _XFORMAPI TAG(cliptest_np_points4)( GLvector4f *clip_vec, - GLvector4f *proj_vec, - GLubyte clipMask[], - GLubyte *orMask, - GLubyte *andMask) -{ - const GLuint stride = clip_vec->stride; - const GLuint count = clip_vec->count; - const GLfloat *from = (GLfloat *)clip_vec->start; - GLuint c = 0; - GLubyte tmpAndMask = *andMask; - GLubyte tmpOrMask = *orMask; - GLuint i; - (void) proj_vec; - STRIDE_LOOP { - const GLfloat cx = from[0]; - const GLfloat cy = from[1]; - const GLfloat cz = from[2]; - const GLfloat cw = from[3]; -#if defined(macintosh) || defined(__powerpc__) - /* on powerpc cliptest is 17% faster in this way. */ - GLuint mask; - mask = (((cw < cx) << CLIP_RIGHT_SHIFT)); - mask |= (((cw < -cx) << CLIP_LEFT_SHIFT)); - mask |= (((cw < cy) << CLIP_TOP_SHIFT)); - mask |= (((cw < -cy) << CLIP_BOTTOM_SHIFT)); - mask |= (((cw < cz) << CLIP_FAR_SHIFT)); - mask |= (((cw < -cz) << CLIP_NEAR_SHIFT)); -#else /* !defined(macintosh)) */ - GLubyte mask = 0; - if (-cx + cw < 0) mask |= CLIP_RIGHT_BIT; - if ( cx + cw < 0) mask |= CLIP_LEFT_BIT; - if (-cy + cw < 0) mask |= CLIP_TOP_BIT; - if ( cy + cw < 0) mask |= CLIP_BOTTOM_BIT; - if (-cz + cw < 0) mask |= CLIP_FAR_BIT; - if ( cz + cw < 0) mask |= CLIP_NEAR_BIT; -#endif /* defined(macintosh) */ - - clipMask[i] = mask; - if (mask) { - c++; - tmpAndMask &= mask; - tmpOrMask |= mask; - } - } - - *orMask = tmpOrMask; - *andMask = (GLubyte) (c < count ? 0 : tmpAndMask); - return clip_vec; -} - - -static GLvector4f * _XFORMAPI TAG(cliptest_points3)( GLvector4f *clip_vec, - GLvector4f *proj_vec, - GLubyte clipMask[], - GLubyte *orMask, - GLubyte *andMask) -{ - const GLuint stride = clip_vec->stride; - const GLuint count = clip_vec->count; - const GLfloat *from = (GLfloat *)clip_vec->start; - GLubyte tmpOrMask = *orMask; - GLubyte tmpAndMask = *andMask; - GLuint i; - (void) proj_vec; - STRIDE_LOOP { - const GLfloat cx = from[0], cy = from[1], cz = from[2]; - GLubyte mask = 0; - if (cx > 1.0) mask |= CLIP_RIGHT_BIT; - else if (cx < -1.0) mask |= CLIP_LEFT_BIT; - if (cy > 1.0) mask |= CLIP_TOP_BIT; - else if (cy < -1.0) mask |= CLIP_BOTTOM_BIT; - if (cz > 1.0) mask |= CLIP_FAR_BIT; - else if (cz < -1.0) mask |= CLIP_NEAR_BIT; - clipMask[i] = mask; - tmpOrMask |= mask; - tmpAndMask &= mask; - } - - *orMask = tmpOrMask; - *andMask = tmpAndMask; - return clip_vec; -} - - -static GLvector4f * _XFORMAPI TAG(cliptest_points2)( GLvector4f *clip_vec, - GLvector4f *proj_vec, - GLubyte clipMask[], - GLubyte *orMask, - GLubyte *andMask) -{ - const GLuint stride = clip_vec->stride; - const GLuint count = clip_vec->count; - const GLfloat *from = (GLfloat *)clip_vec->start; - GLubyte tmpOrMask = *orMask; - GLubyte tmpAndMask = *andMask; - GLuint i; - (void) proj_vec; - STRIDE_LOOP { - const GLfloat cx = from[0], cy = from[1]; - GLubyte mask = 0; - if (cx > 1.0) mask |= CLIP_RIGHT_BIT; - else if (cx < -1.0) mask |= CLIP_LEFT_BIT; - if (cy > 1.0) mask |= CLIP_TOP_BIT; - else if (cy < -1.0) mask |= CLIP_BOTTOM_BIT; - clipMask[i] = mask; - tmpOrMask |= mask; - tmpAndMask &= mask; - } - - *orMask = tmpOrMask; - *andMask = tmpAndMask; - return clip_vec; -} - - -void TAG(init_c_cliptest)( void ) -{ - _mesa_clip_tab[4] = TAG(cliptest_points4); - _mesa_clip_tab[3] = TAG(cliptest_points3); - _mesa_clip_tab[2] = TAG(cliptest_points2); - - _mesa_clip_np_tab[4] = TAG(cliptest_np_points4); - _mesa_clip_np_tab[3] = TAG(cliptest_points3); - _mesa_clip_np_tab[2] = TAG(cliptest_points2); -} diff --git a/dll/opengl/mesa/math/m_copy_tmp.h b/dll/opengl/mesa/math/m_copy_tmp.h deleted file mode 100644 index 07ab1f7b2aa..00000000000 --- a/dll/opengl/mesa/math/m_copy_tmp.h +++ /dev/null @@ -1,86 +0,0 @@ - -/* - * Mesa 3-D graphics library - * Version: 3.5 - * - * Copyright (C) 1999-2001 Brian Paul All Rights Reserved. - * - * Permission is hereby granted, free of charge, to any person obtaining a - * copy of this software and associated documentation files (the "Software"), - * to deal in the Software without restriction, including without limitation - * the rights to use, copy, modify, merge, publish, distribute, sublicense, - * and/or sell copies of the Software, and to permit persons to whom the - * Software is furnished to do so, subject to the following conditions: - * - * The above copyright notice and this permission notice shall be included - * in all copies or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS - * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL - * BRIAN PAUL BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN - * AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN - * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. - */ - -/* - * New (3.1) transformation code written by Keith Whitwell. - */ - - -#define COPY_FUNC( BITS ) \ -static void TAG2(copy, BITS)( GLvector4f *to, const GLvector4f *f ) \ -{ \ - GLfloat (*t)[4] = (GLfloat (*)[4])to->start; \ - GLfloat *from = f->start; \ - GLuint stride = f->stride; \ - GLuint count = to->count; \ - GLuint i; \ - \ - if (BITS) \ - STRIDE_LOOP { \ - if (BITS&1) t[i][0] = from[0]; \ - if (BITS&2) t[i][1] = from[1]; \ - if (BITS&4) t[i][2] = from[2]; \ - if (BITS&8) t[i][3] = from[3]; \ - } \ -} - -/* We got them all here: - */ -COPY_FUNC( 0x0 ) /* noop */ -COPY_FUNC( 0x1 ) -COPY_FUNC( 0x2 ) -COPY_FUNC( 0x3 ) -COPY_FUNC( 0x4 ) -COPY_FUNC( 0x5 ) -COPY_FUNC( 0x6 ) -COPY_FUNC( 0x7 ) -COPY_FUNC( 0x8 ) -COPY_FUNC( 0x9 ) -COPY_FUNC( 0xa ) -COPY_FUNC( 0xb ) -COPY_FUNC( 0xc ) -COPY_FUNC( 0xd ) -COPY_FUNC( 0xe ) -COPY_FUNC( 0xf ) - -static void TAG2(init_copy, 0)( void ) -{ - _mesa_copy_tab[0x0] = TAG2(copy, 0x0); - _mesa_copy_tab[0x1] = TAG2(copy, 0x1); - _mesa_copy_tab[0x2] = TAG2(copy, 0x2); - _mesa_copy_tab[0x3] = TAG2(copy, 0x3); - _mesa_copy_tab[0x4] = TAG2(copy, 0x4); - _mesa_copy_tab[0x5] = TAG2(copy, 0x5); - _mesa_copy_tab[0x6] = TAG2(copy, 0x6); - _mesa_copy_tab[0x7] = TAG2(copy, 0x7); - _mesa_copy_tab[0x8] = TAG2(copy, 0x8); - _mesa_copy_tab[0x9] = TAG2(copy, 0x9); - _mesa_copy_tab[0xa] = TAG2(copy, 0xa); - _mesa_copy_tab[0xb] = TAG2(copy, 0xb); - _mesa_copy_tab[0xc] = TAG2(copy, 0xc); - _mesa_copy_tab[0xd] = TAG2(copy, 0xd); - _mesa_copy_tab[0xe] = TAG2(copy, 0xe); - _mesa_copy_tab[0xf] = TAG2(copy, 0xf); -} diff --git a/dll/opengl/mesa/math/m_debug.h b/dll/opengl/mesa/math/m_debug.h deleted file mode 100644 index 6476b6de28c..00000000000 --- a/dll/opengl/mesa/math/m_debug.h +++ /dev/null @@ -1,42 +0,0 @@ - -/* - * Mesa 3-D graphics library - * Version: 3.5 - * - * Copyright (C) 1999-2001 Brian Paul All Rights Reserved. - * - * Permission is hereby granted, free of charge, to any person obtaining a - * copy of this software and associated documentation files (the "Software"), - * to deal in the Software without restriction, including without limitation - * the rights to use, copy, modify, merge, publish, distribute, sublicense, - * and/or sell copies of the Software, and to permit persons to whom the - * Software is furnished to do so, subject to the following conditions: - * - * The above copyright notice and this permission notice shall be included - * in all copies or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS - * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL - * BRIAN PAUL BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN - * AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN - * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. - * - * Authors: - * Gareth Hughes - */ - -#ifndef __M_DEBUG_H__ -#define __M_DEBUG_H__ - -extern void _math_test_all_transform_functions( char *description ); -extern void _math_test_all_normal_transform_functions( char *description ); -extern void _math_test_all_cliptest_functions( char *description ); - -/* Deprecated? - */ -extern void _math_test_all_vertex_functions( char *description ); - -extern char *mesa_profile; - -#endif diff --git a/dll/opengl/mesa/math/m_debug_clip.c b/dll/opengl/mesa/math/m_debug_clip.c deleted file mode 100644 index 4112713a308..00000000000 --- a/dll/opengl/mesa/math/m_debug_clip.c +++ /dev/null @@ -1,397 +0,0 @@ -/* - * Mesa 3-D graphics library - * Version: 6.1 - * - * Copyright (C) 1999-2005 Brian Paul All Rights Reserved. - * - * Permission is hereby granted, free of charge, to any person obtaining a - * copy of this software and associated documentation files (the "Software"), - * to deal in the Software without restriction, including without limitation - * the rights to use, copy, modify, merge, publish, distribute, sublicense, - * and/or sell copies of the Software, and to permit persons to whom the - * Software is furnished to do so, subject to the following conditions: - * - * The above copyright notice and this permission notice shall be included - * in all copies or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS - * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL - * BRIAN PAUL BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN - * AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN - * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. - * - * Authors: - * Gareth Hughes - */ - -#include - -#include "m_debug.h" -#include "m_debug_util.h" - -#ifdef __UNIXOS2__ -/* The linker doesn't like empty files */ -static char dummy; -#endif - -#ifdef DEBUG_MATH /* This code only used for debugging */ - -static clip_func *clip_tab[2] = { - _mesa_clip_tab, - _mesa_clip_np_tab -}; -static char *cnames[2] = { - "_mesa_clip_tab", - "_mesa_clip_np_tab" -}; -#ifdef RUN_DEBUG_BENCHMARK -static char *cstrings[2] = { - "clip, perspective divide", - "clip, no divide" -}; -#endif - - -/* ============================================================= - * Reference cliptests - */ - -static GLvector4f *ref_cliptest_points4( GLvector4f *clip_vec, - GLvector4f *proj_vec, - GLubyte clipMask[], - GLubyte *orMask, - GLubyte *andMask ) -{ - const GLuint stride = clip_vec->stride; - const GLuint count = clip_vec->count; - const GLfloat *from = (GLfloat *)clip_vec->start; - GLuint c = 0; - GLfloat (*vProj)[4] = (GLfloat (*)[4])proj_vec->start; - GLubyte tmpAndMask = *andMask; - GLubyte tmpOrMask = *orMask; - GLuint i; - for ( i = 0 ; i < count ; i++, STRIDE_F(from, stride) ) { - const GLfloat cx = from[0]; - const GLfloat cy = from[1]; - const GLfloat cz = from[2]; - const GLfloat cw = from[3]; - GLubyte mask = 0; - if ( -cx + cw < 0 ) mask |= CLIP_RIGHT_BIT; - if ( cx + cw < 0 ) mask |= CLIP_LEFT_BIT; - if ( -cy + cw < 0 ) mask |= CLIP_TOP_BIT; - if ( cy + cw < 0 ) mask |= CLIP_BOTTOM_BIT; - if ( -cz + cw < 0 ) mask |= CLIP_FAR_BIT; - if ( cz + cw < 0 ) mask |= CLIP_NEAR_BIT; - clipMask[i] = mask; - if ( mask ) { - c++; - tmpAndMask &= mask; - tmpOrMask |= mask; - vProj[i][0] = 0; - vProj[i][1] = 0; - vProj[i][2] = 0; - vProj[i][3] = 1; - } else { - GLfloat oow = 1.0F / cw; - vProj[i][0] = cx * oow; - vProj[i][1] = cy * oow; - vProj[i][2] = cz * oow; - vProj[i][3] = oow; - } - } - - *orMask = tmpOrMask; - *andMask = (GLubyte) (c < count ? 0 : tmpAndMask); - - proj_vec->flags |= VEC_SIZE_4; - proj_vec->size = 4; - proj_vec->count = clip_vec->count; - return proj_vec; -} - -/* Keep these here for now, even though we don't use them... - */ -static GLvector4f *ref_cliptest_points3( GLvector4f *clip_vec, - GLvector4f *proj_vec, - GLubyte clipMask[], - GLubyte *orMask, - GLubyte *andMask) -{ - const GLuint stride = clip_vec->stride; - const GLuint count = clip_vec->count; - const GLfloat *from = (GLfloat *)clip_vec->start; - - GLubyte tmpOrMask = *orMask; - GLubyte tmpAndMask = *andMask; - GLuint i; - for ( i = 0 ; i < count ; i++, STRIDE_F(from, stride) ) { - const GLfloat cx = from[0], cy = from[1], cz = from[2]; - GLubyte mask = 0; - if ( cx > 1.0 ) mask |= CLIP_RIGHT_BIT; - else if ( cx < -1.0 ) mask |= CLIP_LEFT_BIT; - if ( cy > 1.0 ) mask |= CLIP_TOP_BIT; - else if ( cy < -1.0 ) mask |= CLIP_BOTTOM_BIT; - if ( cz > 1.0 ) mask |= CLIP_FAR_BIT; - else if ( cz < -1.0 ) mask |= CLIP_NEAR_BIT; - clipMask[i] = mask; - tmpOrMask |= mask; - tmpAndMask &= mask; - } - - *orMask = tmpOrMask; - *andMask = tmpAndMask; - return clip_vec; -} - -static GLvector4f * ref_cliptest_points2( GLvector4f *clip_vec, - GLvector4f *proj_vec, - GLubyte clipMask[], - GLubyte *orMask, - GLubyte *andMask, - GLboolean viewport_z_clip ) -{ - const GLuint stride = clip_vec->stride; - const GLuint count = clip_vec->count; - const GLfloat *from = (GLfloat *)clip_vec->start; - - GLubyte tmpOrMask = *orMask; - GLubyte tmpAndMask = *andMask; - GLuint i; - - (void) viewport_z_clip; - - for ( i = 0 ; i < count ; i++, STRIDE_F(from, stride) ) { - const GLfloat cx = from[0], cy = from[1]; - GLubyte mask = 0; - if ( cx > 1.0 ) mask |= CLIP_RIGHT_BIT; - else if ( cx < -1.0 ) mask |= CLIP_LEFT_BIT; - if ( cy > 1.0 ) mask |= CLIP_TOP_BIT; - else if ( cy < -1.0 ) mask |= CLIP_BOTTOM_BIT; - clipMask[i] = mask; - tmpOrMask |= mask; - tmpAndMask &= mask; - } - - *orMask = tmpOrMask; - *andMask = tmpAndMask; - return clip_vec; -} - -static clip_func ref_cliptest[5] = { - 0, - 0, - ref_cliptest_points2, - ref_cliptest_points3, - ref_cliptest_points4 -}; - - -/* ============================================================= - * Cliptest tests - */ - -ALIGN16(static GLfloat, s[TEST_COUNT][4]); -ALIGN16(static GLfloat, d[TEST_COUNT][4]); -ALIGN16(static GLfloat, r[TEST_COUNT][4]); - - -/** - * Check if X, Y or Z component of the coordinate is close to W, in terms - * of the clip test. - */ -static GLboolean -xyz_close_to_w(const GLfloat c[4]) -{ - float k = 0.0001; - return (fabs(c[0] - c[3]) < k || - fabs(c[1] - c[3]) < k || - fabs(c[2] - c[3]) < k || - fabs(-c[0] - c[3]) < k || - fabs(-c[1] - c[3]) < k || - fabs(-c[2] - c[3]) < k); -} - - - -static int test_cliptest_function( clip_func func, int np, - int psize, long *cycles ) -{ - GLvector4f source[1], dest[1], ref[1]; - GLubyte dm[TEST_COUNT], dco, dca; - GLubyte rm[TEST_COUNT], rco, rca; - int i, j; -#ifdef RUN_DEBUG_BENCHMARK - int cycle_i; /* the counter for the benchmarks we run */ -#endif - GLboolean viewport_z_clip = GL_TRUE; - - (void) cycles; - - if ( psize > 4 ) { - _mesa_problem( NULL, "test_cliptest_function called with psize > 4\n" ); - return 0; - } - - for ( i = 0 ; i < TEST_COUNT ; i++) { - ASSIGN_4V( d[i], 0.0, 0.0, 0.0, 1.0 ); - ASSIGN_4V( s[i], 0.0, 0.0, 0.0, 1.0 ); - for ( j = 0 ; j < psize ; j++ ) - s[i][j] = rnd(); - } - - source->data = (GLfloat(*)[4])s; - source->start = (GLfloat *)s; - source->count = TEST_COUNT; - source->stride = sizeof(s[0]); - source->size = 4; - source->flags = 0; - - dest->data = (GLfloat(*)[4])d; - dest->start = (GLfloat *)d; - dest->count = TEST_COUNT; - dest->stride = sizeof(float[4]); - dest->size = 0; - dest->flags = 0; - - ref->data = (GLfloat(*)[4])r; - ref->start = (GLfloat *)r; - ref->count = TEST_COUNT; - ref->stride = sizeof(float[4]); - ref->size = 0; - ref->flags = 0; - - dco = rco = 0; - dca = rca = CLIP_FRUSTUM_BITS; - - ref_cliptest[psize]( source, ref, rm, &rco, &rca, viewport_z_clip ); - - if ( mesa_profile ) { - BEGIN_RACE( *cycles ); - func( source, dest, dm, &dco, &dca, viewport_z_clip ); - END_RACE( *cycles ); - } - else { - func( source, dest, dm, &dco, &dca, viewport_z_clip ); - } - - if ( dco != rco ) { - printf( "\n-----------------------------\n" ); - printf( "dco = 0x%02x rco = 0x%02x\n", dco, rco ); - return 0; - } - if ( dca != rca ) { - printf( "\n-----------------------------\n" ); - printf( "dca = 0x%02x rca = 0x%02x\n", dca, rca ); - return 0; - } - for ( i = 0 ; i < TEST_COUNT ; i++ ) { - if ( dm[i] != rm[i] ) { - GLfloat *c = source->start; - STRIDE_F(c, source->stride * i); - if (psize == 4 && xyz_close_to_w(c)) { - /* The coordinate is very close to the clip plane. The clipmask - * may vary depending on code path, but that's OK. - */ - continue; - } - printf( "\n-----------------------------\n" ); - printf( "mask[%d] = 0x%02x ref mask[%d] = 0x%02x\n", i, dm[i], i,rm[i] ); - printf(" coord = %f, %f, %f, %f\n", - c[0], c[1], c[2], c[3]); - return 0; - } - } - - /* Only verify output on projected points4 case. FIXME: Do we need - * to test other cases? - */ - if ( np || psize < 4 ) - return 1; - - for ( i = 0 ; i < TEST_COUNT ; i++ ) { - for ( j = 0 ; j < 4 ; j++ ) { - if ( significand_match( d[i][j], r[i][j] ) < REQUIRED_PRECISION ) { - printf( "\n-----------------------------\n" ); - printf( "(i = %i, j = %i) dm = 0x%02x rm = 0x%02x\n", - i, j, dm[i], rm[i] ); - printf( "%f \t %f \t [diff = %e - %i bit missed]\n", - d[i][0], r[i][0], r[i][0]-d[i][0], - MAX_PRECISION - significand_match( d[i][0], r[i][0] ) ); - printf( "%f \t %f \t [diff = %e - %i bit missed]\n", - d[i][1], r[i][1], r[i][1]-d[i][1], - MAX_PRECISION - significand_match( d[i][1], r[i][1] ) ); - printf( "%f \t %f \t [diff = %e - %i bit missed]\n", - d[i][2], r[i][2], r[i][2]-d[i][2], - MAX_PRECISION - significand_match( d[i][2], r[i][2] ) ); - printf( "%f \t %f \t [diff = %e - %i bit missed]\n", - d[i][3], r[i][3], r[i][3]-d[i][3], - MAX_PRECISION - significand_match( d[i][3], r[i][3] ) ); - return 0; - } - } - } - - return 1; -} - -void _math_test_all_cliptest_functions( char *description ) -{ - int np, psize; - long benchmark_tab[2][4]; - static int first_time = 1; - - if ( first_time ) { - first_time = 0; - mesa_profile = _mesa_getenv( "MESA_PROFILE" ); - } - -#ifdef RUN_DEBUG_BENCHMARK - if ( mesa_profile ) { - if ( !counter_overhead ) { - INIT_COUNTER(); - printf( "counter overhead: %ld cycles\n\n", counter_overhead ); - } - printf( "cliptest results after hooking in %s functions:\n", description ); - } -#endif - -#ifdef RUN_DEBUG_BENCHMARK - if ( mesa_profile ) { - printf( "\n\t" ); - for ( psize = 2 ; psize <= 4 ; psize++ ) { - printf( " p%d\t", psize ); - } - printf( "\n--------------------------------------------------------\n\t" ); - } -#endif - - for ( np = 0 ; np < 2 ; np++ ) { - for ( psize = 2 ; psize <= 4 ; psize++ ) { - clip_func func = clip_tab[np][psize]; - long *cycles = &(benchmark_tab[np][psize-1]); - - if ( test_cliptest_function( func, np, psize, cycles ) == 0 ) { - char buf[100]; - sprintf( buf, "%s[%d] failed test (%s)", - cnames[np], psize, description ); - _mesa_problem( NULL, "%s", buf ); - } -#ifdef RUN_DEBUG_BENCHMARK - if ( mesa_profile ) - printf( " %li\t", benchmark_tab[np][psize-1] ); -#endif - } -#ifdef RUN_DEBUG_BENCHMARK - if ( mesa_profile ) - printf( " | [%s]\n\t", cstrings[np] ); -#endif - } -#ifdef RUN_DEBUG_BENCHMARK - if ( mesa_profile ) - printf( "\n" ); -#endif -} - - -#endif /* DEBUG_MATH */ diff --git a/dll/opengl/mesa/math/m_debug_norm.c b/dll/opengl/mesa/math/m_debug_norm.c deleted file mode 100644 index db11edbea83..00000000000 --- a/dll/opengl/mesa/math/m_debug_norm.c +++ /dev/null @@ -1,377 +0,0 @@ - -/* - * Mesa 3-D graphics library - * Version: 5.1 - * - * Copyright (C) 1999-2003 Brian Paul All Rights Reserved. - * - * Permission is hereby granted, free of charge, to any person obtaining a - * copy of this software and associated documentation files (the "Software"), - * to deal in the Software without restriction, including without limitation - * the rights to use, copy, modify, merge, publish, distribute, sublicense, - * and/or sell copies of the Software, and to permit persons to whom the - * Software is furnished to do so, subject to the following conditions: - * - * The above copyright notice and this permission notice shall be included - * in all copies or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS - * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL - * BRIAN PAUL BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN - * AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN - * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. - * - * Authors: - * Gareth Hughes - */ - -#include - -#include "m_debug.h" -#include "m_debug_util.h" - - -#ifdef __UNIXOS2__ -/* The linker doesn't like empty files */ -static char dummy; -#endif - -#ifdef DEBUG_MATH /* This code only used for debugging */ - - -static int m_norm_identity[16] = { - ONE, NIL, NIL, NIL, - NIL, ONE, NIL, NIL, - NIL, NIL, ONE, NIL, - NIL, NIL, NIL, NIL -}; -static int m_norm_general[16] = { - VAR, VAR, VAR, NIL, - VAR, VAR, VAR, NIL, - VAR, VAR, VAR, NIL, - NIL, NIL, NIL, NIL -}; -static int m_norm_no_rot[16] = { - VAR, NIL, NIL, NIL, - NIL, VAR, NIL, NIL, - NIL, NIL, VAR, NIL, - NIL, NIL, NIL, NIL -}; -static int *norm_templates[8] = { - m_norm_no_rot, - m_norm_no_rot, - m_norm_no_rot, - m_norm_general, - m_norm_general, - m_norm_general, - m_norm_identity, - m_norm_identity -}; -static int norm_types[8] = { - NORM_TRANSFORM_NO_ROT, - NORM_TRANSFORM_NO_ROT | NORM_RESCALE, - NORM_TRANSFORM_NO_ROT | NORM_NORMALIZE, - NORM_TRANSFORM, - NORM_TRANSFORM | NORM_RESCALE, - NORM_TRANSFORM | NORM_NORMALIZE, - NORM_RESCALE, - NORM_NORMALIZE -}; -static int norm_scale_types[8] = { /* rescale factor */ - NIL, /* NIL disables rescaling */ - VAR, - NIL, - NIL, - VAR, - NIL, - VAR, - NIL -}; -static int norm_normalize_types[8] = { /* normalizing ?? (no = 0) */ - 0, - 0, - 1, - 0, - 0, - 1, - 0, - 1 -}; -static char *norm_strings[8] = { - "NORM_TRANSFORM_NO_ROT", - "NORM_TRANSFORM_NO_ROT | NORM_RESCALE", - "NORM_TRANSFORM_NO_ROT | NORM_NORMALIZE", - "NORM_TRANSFORM", - "NORM_TRANSFORM | NORM_RESCALE", - "NORM_TRANSFORM | NORM_NORMALIZE", - "NORM_RESCALE", - "NORM_NORMALIZE" -}; - - -/* ============================================================= - * Reference transformations - */ - -static void ref_norm_transform_rescale( const GLmatrix *mat, - GLfloat scale, - const GLvector4f *in, - const GLfloat *lengths, - GLvector4f *dest ) -{ - GLuint i; - const GLfloat *s = in->start; - const GLfloat *m = mat->inv; - GLfloat (*out)[4] = (GLfloat (*)[4]) dest->start; - - (void) lengths; - - for ( i = 0 ; i < in->count ; i++ ) { - GLfloat t[3]; - - TRANSFORM_NORMAL( t, s, m ); - SCALE_SCALAR_3V( out[i], scale, t ); - - s = (GLfloat *)((char *)s + in->stride); - } -} - -static void ref_norm_transform_normalize( const GLmatrix *mat, - GLfloat scale, - const GLvector4f *in, - const GLfloat *lengths, - GLvector4f *dest ) -{ - GLuint i; - const GLfloat *s = in->start; - const GLfloat *m = mat->inv; - GLfloat (*out)[4] = (GLfloat (*)[4]) dest->start; - - for ( i = 0 ; i < in->count ; i++ ) { - GLfloat t[3]; - - TRANSFORM_NORMAL( t, s, m ); - - if ( !lengths ) { - GLfloat len = LEN_SQUARED_3FV( t ); - if ( len > 1e-20 ) { - /* Hmmm, don't know how we could test the precalculated - * length case... - */ - scale = 1.0 / SQRTF( len ); - SCALE_SCALAR_3V( out[i], scale, t ); - } else { - out[i][0] = out[i][1] = out[i][2] = 0; - } - } else { - scale = lengths[i];; - SCALE_SCALAR_3V( out[i], scale, t ); - } - - s = (GLfloat *)((char *)s + in->stride); - } -} - - -/* ============================================================= - * Normal transformation tests - */ - -static void init_matrix( GLfloat *m ) -{ - m[0] = 63.0; m[4] = 43.0; m[ 8] = 29.0; m[12] = 43.0; - m[1] = 55.0; m[5] = 17.0; m[ 9] = 31.0; m[13] = 7.0; - m[2] = 44.0; m[6] = 9.0; m[10] = 7.0; m[14] = 3.0; - m[3] = 11.0; m[7] = 23.0; m[11] = 91.0; m[15] = 9.0; -} - - -static int test_norm_function( normal_func func, int mtype, long *cycles ) -{ - GLvector4f source[1], dest[1], dest2[1], ref[1], ref2[1]; - GLmatrix mat[1]; - GLfloat s[TEST_COUNT][5], d[TEST_COUNT][4], r[TEST_COUNT][4]; - GLfloat d2[TEST_COUNT][4], r2[TEST_COUNT][4], length[TEST_COUNT]; - GLfloat scale; - GLfloat *m; - int i, j; -#ifdef RUN_DEBUG_BENCHMARK - int cycle_i; /* the counter for the benchmarks we run */ -#endif - - (void) cycles; - - mat->m = (GLfloat *) _mesa_align_malloc( 16 * sizeof(GLfloat), 16 ); - mat->inv = m = mat->m; - - init_matrix( m ); - - scale = 1.0F + rnd () * norm_scale_types[mtype]; - - for ( i = 0 ; i < 4 ; i++ ) { - for ( j = 0 ; j < 4 ; j++ ) { - switch ( norm_templates[mtype][i * 4 + j] ) { - case NIL: - m[j * 4 + i] = 0.0; - break; - case ONE: - m[j * 4 + i] = 1.0; - break; - case NEG: - m[j * 4 + i] = -1.0; - break; - case VAR: - break; - default: - exit(1); - } - } - } - - for ( i = 0 ; i < TEST_COUNT ; i++ ) { - ASSIGN_3V( d[i], 0.0, 0.0, 0.0 ); - ASSIGN_3V( s[i], 0.0, 0.0, 0.0 ); - ASSIGN_3V( d2[i], 0.0, 0.0, 0.0 ); - for ( j = 0 ; j < 3 ; j++ ) - s[i][j] = rnd(); - length[i] = 1 / SQRTF( LEN_SQUARED_3FV( s[i] ) ); - } - - source->data = (GLfloat(*)[4]) s; - source->start = (GLfloat *) s; - source->count = TEST_COUNT; - source->stride = sizeof(s[0]); - source->flags = 0; - - dest->data = d; - dest->start = (GLfloat *) d; - dest->count = TEST_COUNT; - dest->stride = sizeof(float[4]); - dest->flags = 0; - - dest2->data = d2; - dest2->start = (GLfloat *) d2; - dest2->count = TEST_COUNT; - dest2->stride = sizeof(float[4]); - dest2->flags = 0; - - ref->data = r; - ref->start = (GLfloat *) r; - ref->count = TEST_COUNT; - ref->stride = sizeof(float[4]); - ref->flags = 0; - - ref2->data = r2; - ref2->start = (GLfloat *) r2; - ref2->count = TEST_COUNT; - ref2->stride = sizeof(float[4]); - ref2->flags = 0; - - if ( norm_normalize_types[mtype] == 0 ) { - ref_norm_transform_rescale( mat, scale, source, NULL, ref ); - } else { - ref_norm_transform_normalize( mat, scale, source, NULL, ref ); - ref_norm_transform_normalize( mat, scale, source, length, ref2 ); - } - - if ( mesa_profile ) { - BEGIN_RACE( *cycles ); - func( mat, scale, source, NULL, dest ); - END_RACE( *cycles ); - func( mat, scale, source, length, dest2 ); - } else { - func( mat, scale, source, NULL, dest ); - func( mat, scale, source, length, dest2 ); - } - - for ( i = 0 ; i < TEST_COUNT ; i++ ) { - for ( j = 0 ; j < 3 ; j++ ) { - if ( significand_match( d[i][j], r[i][j] ) < REQUIRED_PRECISION ) { - printf( "-----------------------------\n" ); - printf( "(i = %i, j = %i)\n", i, j ); - printf( "%f \t %f \t [ratio = %e - %i bit missed]\n", - d[i][0], r[i][0], r[i][0]/d[i][0], - MAX_PRECISION - significand_match( d[i][0], r[i][0] ) ); - printf( "%f \t %f \t [ratio = %e - %i bit missed]\n", - d[i][1], r[i][1], r[i][1]/d[i][1], - MAX_PRECISION - significand_match( d[i][1], r[i][1] ) ); - printf( "%f \t %f \t [ratio = %e - %i bit missed]\n", - d[i][2], r[i][2], r[i][2]/d[i][2], - MAX_PRECISION - significand_match( d[i][2], r[i][2] ) ); - return 0; - } - - if ( norm_normalize_types[mtype] != 0 ) { - if ( significand_match( d2[i][j], r2[i][j] ) < REQUIRED_PRECISION ) { - printf( "------------------- precalculated length case ------\n" ); - printf( "(i = %i, j = %i)\n", i, j ); - printf( "%f \t %f \t [ratio = %e - %i bit missed]\n", - d2[i][0], r2[i][0], r2[i][0]/d2[i][0], - MAX_PRECISION - significand_match( d2[i][0], r2[i][0] ) ); - printf( "%f \t %f \t [ratio = %e - %i bit missed]\n", - d2[i][1], r2[i][1], r2[i][1]/d2[i][1], - MAX_PRECISION - significand_match( d2[i][1], r2[i][1] ) ); - printf( "%f \t %f \t [ratio = %e - %i bit missed]\n", - d2[i][2], r2[i][2], r2[i][2]/d2[i][2], - MAX_PRECISION - significand_match( d2[i][2], r2[i][2] ) ); - return 0; - } - } - } - } - - _mesa_align_free( mat->m ); - return 1; -} - -void _math_test_all_normal_transform_functions( char *description ) -{ - int mtype; - long benchmark_tab[0xf]; - static int first_time = 1; - - if ( first_time ) { - first_time = 0; - mesa_profile = _mesa_getenv( "MESA_PROFILE" ); - } - -#ifdef RUN_DEBUG_BENCHMARK - if ( mesa_profile ) { - if ( !counter_overhead ) { - INIT_COUNTER(); - printf( "counter overhead: %ld cycles\n\n", counter_overhead ); - } - printf( "normal transform results after hooking in %s functions:\n", - description ); - printf( "\n-------------------------------------------------------\n" ); - } -#endif - - for ( mtype = 0 ; mtype < 8 ; mtype++ ) { - normal_func func = _mesa_normal_tab[norm_types[mtype]]; - long *cycles = &benchmark_tab[mtype]; - - if ( test_norm_function( func, mtype, cycles ) == 0 ) { - char buf[100]; - sprintf( buf, "_mesa_normal_tab[0][%s] failed test (%s)", - norm_strings[mtype], description ); - _mesa_problem( NULL, "%s", buf ); - } - -#ifdef RUN_DEBUG_BENCHMARK - if ( mesa_profile ) { - printf( " %li\t", benchmark_tab[mtype] ); - printf( " | [%s]\n", norm_strings[mtype] ); - } -#endif - } -#ifdef RUN_DEBUG_BENCHMARK - if ( mesa_profile ) { - printf( "\n" ); - } -#endif -} - - -#endif /* DEBUG_MATH */ diff --git a/dll/opengl/mesa/math/m_debug_util.h b/dll/opengl/mesa/math/m_debug_util.h deleted file mode 100644 index ed11c849ece..00000000000 --- a/dll/opengl/mesa/math/m_debug_util.h +++ /dev/null @@ -1,320 +0,0 @@ -/* - * Mesa 3-D graphics library - * Version: 6.1 - * - * Copyright (C) 1999-2004 Brian Paul All Rights Reserved. - * - * Permission is hereby granted, free of charge, to any person obtaining a - * copy of this software and associated documentation files (the "Software"), - * to deal in the Software without restriction, including without limitation - * the rights to use, copy, modify, merge, publish, distribute, sublicense, - * and/or sell copies of the Software, and to permit persons to whom the - * Software is furnished to do so, subject to the following conditions: - * - * The above copyright notice and this permission notice shall be included - * in all copies or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS - * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL - * BRIAN PAUL BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN - * AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN - * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. - * - * Authors: - * Gareth Hughes - */ - -#ifndef __M_DEBUG_UTIL_H__ -#define __M_DEBUG_UTIL_H__ - - -#ifdef DEBUG_MATH /* This code only used for debugging */ - - -/* Comment this out to deactivate the cycle counter. - * NOTE: it works only on CPUs which know the 'rdtsc' command (586 or higher) - * (hope, you don't try to debug Mesa on a 386 ;) - */ -#if defined(__GNUC__) && \ - ((defined(__i386__) && defined(USE_X86_ASM)) || \ - (defined(__sparc__) && defined(USE_SPARC_ASM))) -#define RUN_DEBUG_BENCHMARK -#endif - -#define TEST_COUNT 128 /* size of the tested vector array */ - -#define REQUIRED_PRECISION 10 /* allow 4 bits to miss */ -#define MAX_PRECISION 24 /* max. precision possible */ - - -#ifdef RUN_DEBUG_BENCHMARK -/* Overhead of profiling counter in cycles. Automatically adjusted to - * your machine at run time - counter initialization should give very - * consistent results. - */ -extern long counter_overhead; - -/* This is the value of the environment variable MESA_PROFILE, and is - * used to determine if we should benchmark the functions as well as - * verify their correctness. - */ -extern char *mesa_profile; - -/* Modify the number of tests if you like. - * We take the minimum of all results, because every error should be - * positive (time used by other processes, task switches etc). - * It is assumed that all calculations are done in the cache. - */ - -#if defined(__i386__) - -#if 1 /* PPro, PII, PIII version */ - -/* Profiling on the P6 architecture requires a little more work, due to - * the internal out-of-order execution. We must perform a serializing - * 'cpuid' instruction before and after the 'rdtsc' instructions to make - * sure no other uops are executed when we sample the timestamp counter. - */ -#define INIT_COUNTER() \ - do { \ - int cycle_i; \ - counter_overhead = LONG_MAX; \ - for ( cycle_i = 0 ; cycle_i < 8 ; cycle_i++ ) { \ - long cycle_tmp1 = 0, cycle_tmp2 = 0; \ - __asm__ __volatile__ ( "push %%ebx \n" \ - "xor %%eax, %%eax \n" \ - "cpuid \n" \ - "rdtsc \n" \ - "mov %%eax, %0 \n" \ - "xor %%eax, %%eax \n" \ - "cpuid \n" \ - "pop %%ebx \n" \ - "push %%ebx \n" \ - "xor %%eax, %%eax \n" \ - "cpuid \n" \ - "rdtsc \n" \ - "mov %%eax, %1 \n" \ - "xor %%eax, %%eax \n" \ - "cpuid \n" \ - "pop %%ebx \n" \ - : "=m" (cycle_tmp1), "=m" (cycle_tmp2) \ - : : "eax", "ecx", "edx" ); \ - if ( counter_overhead > (cycle_tmp2 - cycle_tmp1) ) { \ - counter_overhead = cycle_tmp2 - cycle_tmp1; \ - } \ - } \ - } while (0) - -#define BEGIN_RACE(x) \ - x = LONG_MAX; \ - for ( cycle_i = 0 ; cycle_i < 10 ; cycle_i++ ) { \ - long cycle_tmp1 = 0, cycle_tmp2 = 0; \ - __asm__ __volatile__ ( "push %%ebx \n" \ - "xor %%eax, %%eax \n" \ - "cpuid \n" \ - "rdtsc \n" \ - "mov %%eax, %0 \n" \ - "xor %%eax, %%eax \n" \ - "cpuid \n" \ - "pop %%ebx \n" \ - : "=m" (cycle_tmp1) \ - : : "eax", "ecx", "edx" ); - -#define END_RACE(x) \ - __asm__ __volatile__ ( "push %%ebx \n" \ - "xor %%eax, %%eax \n" \ - "cpuid \n" \ - "rdtsc \n" \ - "mov %%eax, %0 \n" \ - "xor %%eax, %%eax \n" \ - "cpuid \n" \ - "pop %%ebx \n" \ - : "=m" (cycle_tmp2) \ - : : "eax", "ecx", "edx" ); \ - if ( x > (cycle_tmp2 - cycle_tmp1) ) { \ - x = cycle_tmp2 - cycle_tmp1; \ - } \ - } \ - x -= counter_overhead; - -#else /* PPlain, PMMX version */ - -/* To ensure accurate results, we stall the pipelines with the - * non-pairable 'cdq' instruction. This ensures all the code being - * profiled is complete when the 'rdtsc' instruction executes. - */ -#define INIT_COUNTER(x) \ - do { \ - int cycle_i; \ - x = LONG_MAX; \ - for ( cycle_i = 0 ; cycle_i < 32 ; cycle_i++ ) { \ - long cycle_tmp1, cycle_tmp2, dummy; \ - __asm__ ( "mov %%eax, %0" : "=a" (cycle_tmp1) ); \ - __asm__ ( "mov %%eax, %0" : "=a" (cycle_tmp2) ); \ - __asm__ ( "cdq" ); \ - __asm__ ( "cdq" ); \ - __asm__ ( "rdtsc" : "=a" (cycle_tmp1), "=d" (dummy) ); \ - __asm__ ( "cdq" ); \ - __asm__ ( "cdq" ); \ - __asm__ ( "rdtsc" : "=a" (cycle_tmp2), "=d" (dummy) ); \ - if ( x > (cycle_tmp2 - cycle_tmp1) ) \ - x = cycle_tmp2 - cycle_tmp1; \ - } \ - } while (0) - -#define BEGIN_RACE(x) \ - x = LONG_MAX; \ - for ( cycle_i = 0 ; cycle_i < 16 ; cycle_i++ ) { \ - long cycle_tmp1, cycle_tmp2, dummy; \ - __asm__ ( "mov %%eax, %0" : "=a" (cycle_tmp1) ); \ - __asm__ ( "mov %%eax, %0" : "=a" (cycle_tmp2) ); \ - __asm__ ( "cdq" ); \ - __asm__ ( "cdq" ); \ - __asm__ ( "rdtsc" : "=a" (cycle_tmp1), "=d" (dummy) ); - - -#define END_RACE(x) \ - __asm__ ( "cdq" ); \ - __asm__ ( "cdq" ); \ - __asm__ ( "rdtsc" : "=a" (cycle_tmp2), "=d" (dummy) ); \ - if ( x > (cycle_tmp2 - cycle_tmp1) ) \ - x = cycle_tmp2 - cycle_tmp1; \ - } \ - x -= counter_overhead; - -#endif - -#elif defined(__x86_64__) - -#define rdtscll(val) do { \ - unsigned int a,d; \ - __asm__ volatile("rdtsc" : "=a" (a), "=d" (d)); \ - (val) = ((unsigned long)a) | (((unsigned long)d)<<32); \ -} while(0) - -/* Copied from i386 PIII version */ -#define INIT_COUNTER() \ - do { \ - int cycle_i; \ - counter_overhead = LONG_MAX; \ - for ( cycle_i = 0 ; cycle_i < 16 ; cycle_i++ ) { \ - unsigned long cycle_tmp1, cycle_tmp2; \ - rdtscll(cycle_tmp1); \ - rdtscll(cycle_tmp2); \ - if ( counter_overhead > (cycle_tmp2 - cycle_tmp1) ) { \ - counter_overhead = cycle_tmp2 - cycle_tmp1; \ - } \ - } \ - } while (0) - - -#define BEGIN_RACE(x) \ - x = LONG_MAX; \ - for ( cycle_i = 0 ; cycle_i < 10 ; cycle_i++ ) { \ - unsigned long cycle_tmp1, cycle_tmp2; \ - rdtscll(cycle_tmp1); \ - -#define END_RACE(x) \ - rdtscll(cycle_tmp2); \ - if ( x > (cycle_tmp2 - cycle_tmp1) ) { \ - x = cycle_tmp2 - cycle_tmp1; \ - } \ - } \ - x -= counter_overhead; - -#elif defined(__sparc__) - -#define INIT_COUNTER() \ - do { counter_overhead = 5; } while(0) - -#define BEGIN_RACE(x) \ -x = LONG_MAX; \ -for (cycle_i = 0; cycle_i <10; cycle_i++) { \ - register long cycle_tmp1 __asm__("l0"); \ - register long cycle_tmp2 __asm__("l1"); \ - /* rd %tick, %l0 */ \ - __asm__ __volatile__ (".word 0xa1410000" : "=r" (cycle_tmp1)); /* save timestamp */ - -#define END_RACE(x) \ - /* rd %tick, %l1 */ \ - __asm__ __volatile__ (".word 0xa3410000" : "=r" (cycle_tmp2)); \ - if (x > (cycle_tmp2-cycle_tmp1)) x = cycle_tmp2 - cycle_tmp1; \ -} \ -x -= counter_overhead; - -#else -#error Your processor is not supported for RUN_XFORM_BENCHMARK -#endif - -#else - -#define BEGIN_RACE(x) -#define END_RACE(x) - -#endif - - -/* ============================================================= - * Helper functions - */ - -static GLfloat rnd( void ) -{ - GLfloat f = (GLfloat)rand() / (GLfloat)RAND_MAX; - GLfloat gran = (GLfloat)(1 << 13); - - f = (GLfloat)(GLint)(f * gran) / gran; - - return f * 2.0 - 1.0; -} - -static int significand_match( GLfloat a, GLfloat b ) -{ - GLfloat d = a - b; - int a_ex, b_ex, d_ex; - - if ( d == 0.0F ) { - return MAX_PRECISION; /* Exact match */ - } - - if ( a == 0.0F || b == 0.0F ) { - /* It would probably be better to check if the - * non-zero number is denormalized and return - * the index of the highest set bit here. - */ - return 0; - } - - FREXPF( a, &a_ex ); - FREXPF( b, &b_ex ); - FREXPF( d, &d_ex ); - - if ( a_ex < b_ex ) { - return a_ex - d_ex; - } else { - return b_ex - d_ex; - } -} - -enum { NIL = 0, ONE = 1, NEG = -1, VAR = 2 }; - -/* Ensure our arrays are correctly aligned. - */ -#if defined(__GNUC__) -# define ALIGN16(type, array) type array __attribute__ ((aligned (16))) -#elif defined(_MSC_VER) -# define ALIGN16(type, array) type array __declspec(align(16)) /* GH: Does this work? */ -#elif defined(__WATCOMC__) -# define ALIGN16(type, array) /* Watcom does not support this */ -#elif defined(__xlC__) -# define ALIGN16(type, array) type __align (16) array -#else -# warning "ALIGN16 will not 16-byte align!\n" -# define ALIGN16 -#endif - - -#endif /* DEBUG_MATH */ - -#endif /* __M_DEBUG_UTIL_H__ */ diff --git a/dll/opengl/mesa/math/m_debug_xform.c b/dll/opengl/mesa/math/m_debug_xform.c deleted file mode 100644 index 3dd530b33f2..00000000000 --- a/dll/opengl/mesa/math/m_debug_xform.c +++ /dev/null @@ -1,333 +0,0 @@ -/* - * Mesa 3-D graphics library - * Version: 6.1 - * - * Copyright (C) 1999-2004 Brian Paul All Rights Reserved. - * - * Permission is hereby granted, free of charge, to any person obtaining a - * copy of this software and associated documentation files (the "Software"), - * to deal in the Software without restriction, including without limitation - * the rights to use, copy, modify, merge, publish, distribute, sublicense, - * and/or sell copies of the Software, and to permit persons to whom the - * Software is furnished to do so, subject to the following conditions: - * - * The above copyright notice and this permission notice shall be included - * in all copies or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS - * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL - * BRIAN PAUL BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN - * AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN - * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. - */ - -/* - * Updated for P6 architecture by Gareth Hughes. - */ - -#include - -#include "m_debug.h" -#include "m_debug_util.h" - -#ifdef __UNIXOS2__ -/* The linker doesn't like empty files */ -static char dummy; -#endif - -#ifdef DEBUG_MATH /* This code only used for debugging */ - - -/* Overhead of profiling counter in cycles. Automatically adjusted to - * your machine at run time - counter initialization should give very - * consistent results. - */ -long counter_overhead = 0; - -/* This is the value of the environment variable MESA_PROFILE, and is - * used to determine if we should benchmark the functions as well as - * verify their correctness. - */ -char *mesa_profile = NULL; - - -static int m_general[16] = { - VAR, VAR, VAR, VAR, - VAR, VAR, VAR, VAR, - VAR, VAR, VAR, VAR, - VAR, VAR, VAR, VAR -}; -static int m_identity[16] = { - ONE, NIL, NIL, NIL, - NIL, ONE, NIL, NIL, - NIL, NIL, ONE, NIL, - NIL, NIL, NIL, ONE -}; -static int m_2d[16] = { - VAR, VAR, NIL, VAR, - VAR, VAR, NIL, VAR, - NIL, NIL, ONE, NIL, - NIL, NIL, NIL, ONE -}; -static int m_2d_no_rot[16] = { - VAR, NIL, NIL, VAR, - NIL, VAR, NIL, VAR, - NIL, NIL, ONE, NIL, - NIL, NIL, NIL, ONE -}; -static int m_3d[16] = { - VAR, VAR, VAR, VAR, - VAR, VAR, VAR, VAR, - VAR, VAR, VAR, VAR, - NIL, NIL, NIL, ONE -}; -static int m_3d_no_rot[16] = { - VAR, NIL, NIL, VAR, - NIL, VAR, NIL, VAR, - NIL, NIL, VAR, VAR, - NIL, NIL, NIL, ONE -}; -static int m_perspective[16] = { - VAR, NIL, VAR, NIL, - NIL, VAR, VAR, NIL, - NIL, NIL, VAR, VAR, - NIL, NIL, NEG, NIL -}; -static int *templates[7] = { - m_general, - m_identity, - m_3d_no_rot, - m_perspective, - m_2d, - m_2d_no_rot, - m_3d -}; -static enum GLmatrixtype mtypes[7] = { - MATRIX_GENERAL, - MATRIX_IDENTITY, - MATRIX_3D_NO_ROT, - MATRIX_PERSPECTIVE, - MATRIX_2D, - MATRIX_2D_NO_ROT, - MATRIX_3D -}; -static char *mstrings[7] = { - "MATRIX_GENERAL", - "MATRIX_IDENTITY", - "MATRIX_3D_NO_ROT", - "MATRIX_PERSPECTIVE", - "MATRIX_2D", - "MATRIX_2D_NO_ROT", - "MATRIX_3D" -}; - - -/* ============================================================= - * Reference transformations - */ - -static void ref_transform( GLvector4f *dst, - const GLmatrix *mat, - const GLvector4f *src ) -{ - GLuint i; - GLfloat *s = (GLfloat *)src->start; - GLfloat (*d)[4] = (GLfloat (*)[4])dst->start; - const GLfloat *m = mat->m; - - for ( i = 0 ; i < src->count ; i++ ) { - TRANSFORM_POINT( d[i], m, s ); - s = (GLfloat *)((char *)s + src->stride); - } -} - - -/* ============================================================= - * Vertex transformation tests - */ - -static void init_matrix( GLfloat *m ) -{ - m[0] = 63.0; m[4] = 43.0; m[ 8] = 29.0; m[12] = 43.0; - m[1] = 55.0; m[5] = 17.0; m[ 9] = 31.0; m[13] = 7.0; - m[2] = 44.0; m[6] = 9.0; m[10] = 7.0; m[14] = 3.0; - m[3] = 11.0; m[7] = 23.0; m[11] = 91.0; m[15] = 9.0; -} - -ALIGN16(static GLfloat, s[TEST_COUNT][4]); -ALIGN16(static GLfloat, d[TEST_COUNT][4]); -ALIGN16(static GLfloat, r[TEST_COUNT][4]); - -static int test_transform_function( transform_func func, int psize, - int mtype, unsigned long *cycles ) -{ - GLvector4f source[1], dest[1], ref[1]; - GLmatrix mat[1]; - GLfloat *m; - int i, j; -#ifdef RUN_DEBUG_BENCHMARK - int cycle_i; /* the counter for the benchmarks we run */ -#endif - - (void) cycles; - - if ( psize > 4 ) { - _mesa_problem( NULL, "test_transform_function called with psize > 4\n" ); - return 0; - } - - mat->m = (GLfloat *) _mesa_align_malloc( 16 * sizeof(GLfloat), 16 ); - mat->type = mtypes[mtype]; - - m = mat->m; - ASSERT( ((long)m & 15) == 0 ); - - init_matrix( m ); - - for ( i = 0 ; i < 4 ; i++ ) { - for ( j = 0 ; j < 4 ; j++ ) { - switch ( templates[mtype][i * 4 + j] ) { - case NIL: - m[j * 4 + i] = 0.0; - break; - case ONE: - m[j * 4 + i] = 1.0; - break; - case NEG: - m[j * 4 + i] = -1.0; - break; - case VAR: - break; - default: - ASSERT(0); - return 0; - } - } - } - - for ( i = 0 ; i < TEST_COUNT ; i++) { - ASSIGN_4V( d[i], 0.0, 0.0, 0.0, 1.0 ); - ASSIGN_4V( s[i], 0.0, 0.0, 0.0, 1.0 ); - for ( j = 0 ; j < psize ; j++ ) - s[i][j] = rnd(); - } - - source->data = (GLfloat(*)[4])s; - source->start = (GLfloat *)s; - source->count = TEST_COUNT; - source->stride = sizeof(s[0]); - source->size = 4; - source->flags = 0; - - dest->data = (GLfloat(*)[4])d; - dest->start = (GLfloat *)d; - dest->count = TEST_COUNT; - dest->stride = sizeof(float[4]); - dest->size = 0; - dest->flags = 0; - - ref->data = (GLfloat(*)[4])r; - ref->start = (GLfloat *)r; - ref->count = TEST_COUNT; - ref->stride = sizeof(float[4]); - ref->size = 0; - ref->flags = 0; - - ref_transform( ref, mat, source ); - - if ( mesa_profile ) { - BEGIN_RACE( *cycles ); - func( dest, mat->m, source ); - END_RACE( *cycles ); - } - else { - func( dest, mat->m, source ); - } - - for ( i = 0 ; i < TEST_COUNT ; i++ ) { - for ( j = 0 ; j < 4 ; j++ ) { - if ( significand_match( d[i][j], r[i][j] ) < REQUIRED_PRECISION ) { - printf("-----------------------------\n" ); - printf("(i = %i, j = %i)\n", i, j ); - printf("%f \t %f \t [diff = %e - %i bit missed]\n", - d[i][0], r[i][0], r[i][0]-d[i][0], - MAX_PRECISION - significand_match( d[i][0], r[i][0] ) ); - printf("%f \t %f \t [diff = %e - %i bit missed]\n", - d[i][1], r[i][1], r[i][1]-d[i][1], - MAX_PRECISION - significand_match( d[i][1], r[i][1] ) ); - printf("%f \t %f \t [diff = %e - %i bit missed]\n", - d[i][2], r[i][2], r[i][2]-d[i][2], - MAX_PRECISION - significand_match( d[i][2], r[i][2] ) ); - printf("%f \t %f \t [diff = %e - %i bit missed]\n", - d[i][3], r[i][3], r[i][3]-d[i][3], - MAX_PRECISION - significand_match( d[i][3], r[i][3] ) ); - return 0; - } - } - } - - _mesa_align_free( mat->m ); - return 1; -} - -void _math_test_all_transform_functions( char *description ) -{ - int psize, mtype; - unsigned long benchmark_tab[4][7]; - static int first_time = 1; - - if ( first_time ) { - first_time = 0; - mesa_profile = _mesa_getenv( "MESA_PROFILE" ); - } - -#ifdef RUN_DEBUG_BENCHMARK - if ( mesa_profile ) { - if ( !counter_overhead ) { - INIT_COUNTER(); - printf("counter overhead: %lu cycles\n\n", counter_overhead ); - } - printf("transform results after hooking in %s functions:\n", description ); - } -#endif - -#ifdef RUN_DEBUG_BENCHMARK - if ( mesa_profile ) { - printf("\n" ); - for ( psize = 1 ; psize <= 4 ; psize++ ) { - printf(" p%d\t", psize ); - } - printf("\n--------------------------------------------------------\n" ); - } -#endif - - for ( mtype = 0 ; mtype < 7 ; mtype++ ) { - for ( psize = 1 ; psize <= 4 ; psize++ ) { - transform_func func = _mesa_transform_tab[psize][mtypes[mtype]]; - unsigned long *cycles = &(benchmark_tab[psize-1][mtype]); - - if ( test_transform_function( func, psize, mtype, cycles ) == 0 ) { - char buf[100]; - sprintf(buf, "_mesa_transform_tab[0][%d][%s] failed test (%s)", - psize, mstrings[mtype], description ); - _mesa_problem( NULL, "%s", buf ); - } -#ifdef RUN_DEBUG_BENCHMARK - if ( mesa_profile ) - printf(" %li\t", benchmark_tab[psize-1][mtype] ); -#endif - } -#ifdef RUN_DEBUG_BENCHMARK - if ( mesa_profile ) - printf(" | [%s]\n", mstrings[mtype] ); -#endif - } -#ifdef RUN_DEBUG_BENCHMARK - if ( mesa_profile ) - printf( "\n" ); -#endif -} - - -#endif /* DEBUG_MATH */ diff --git a/dll/opengl/mesa/math/m_dotprod_tmp.h b/dll/opengl/mesa/math/m_dotprod_tmp.h deleted file mode 100644 index 03e65af6c1a..00000000000 --- a/dll/opengl/mesa/math/m_dotprod_tmp.h +++ /dev/null @@ -1,102 +0,0 @@ - -/* - * Mesa 3-D graphics library - * Version: 3.5 - * - * Copyright (C) 1999-2001 Brian Paul All Rights Reserved. - * - * Permission is hereby granted, free of charge, to any person obtaining a - * copy of this software and associated documentation files (the "Software"), - * to deal in the Software without restriction, including without limitation - * the rights to use, copy, modify, merge, publish, distribute, sublicense, - * and/or sell copies of the Software, and to permit persons to whom the - * Software is furnished to do so, subject to the following conditions: - * - * The above copyright notice and this permission notice shall be included - * in all copies or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS - * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL - * BRIAN PAUL BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN - * AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN - * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. - */ - -/* - * New (3.1) transformation code written by Keith Whitwell. - */ - - -/* Note - respects the stride of the output vector. - */ -static void TAG(dotprod_vec2)( GLfloat *out, - GLuint outstride, - const GLvector4f *coord_vec, - const GLfloat plane[4] ) -{ - GLuint stride = coord_vec->stride; - GLfloat *coord = coord_vec->start; - GLuint count = coord_vec->count; - - GLuint i; - - const GLfloat plane0 = plane[0], plane1 = plane[1], plane3 = plane[3]; - - for (i=0;istride; - GLfloat *coord = coord_vec->start; - GLuint count = coord_vec->count; - - GLuint i; - - const GLfloat plane0 = plane[0], plane1 = plane[1], plane2 = plane[2]; - const GLfloat plane3 = plane[3]; - - for (i=0;istride; - GLfloat *coord = coord_vec->start; - GLuint count = coord_vec->count; - GLuint i; - - const GLfloat plane0 = plane[0], plane1 = plane[1], plane2 = plane[2]; - const GLfloat plane3 = plane[3]; - - for (i=0;i - -#include
- -static GLfloat inv_tab[MAX_EVAL_ORDER]; - -/* - * Horner scheme for Bezier curves - * - * Bezier curves can be computed via a Horner scheme. - * Horner is numerically less stable than the de Casteljau - * algorithm, but it is faster. For curves of degree n - * the complexity of Horner is O(n) and de Casteljau is O(n^2). - * Since stability is not important for displaying curve - * points I decided to use the Horner scheme. - * - * A cubic Bezier curve with control points b0, b1, b2, b3 can be - * written as - * - * (([3] [3] ) [3] ) [3] - * c(t) = (([0]*s*b0 + [1]*t*b1)*s + [2]*t^2*b2)*s + [3]*t^2*b3 - * - * [n] - * where s=1-t and the binomial coefficients [i]. These can - * be computed iteratively using the identity: - * - * [n] [n ] [n] - * [i] = (n-i+1)/i * [i-1] and [0] = 1 - */ - - -void -_math_horner_bezier_curve(const GLfloat * cp, GLfloat * out, GLfloat t, - GLuint dim, GLuint order) -{ - GLfloat s, powert, bincoeff; - GLuint i, k; - - if (order >= 2) { - bincoeff = (GLfloat) (order - 1); - s = 1.0F - t; - - for (k = 0; k < dim; k++) - out[k] = s * cp[k] + bincoeff * t * cp[dim + k]; - - for (i = 2, cp += 2 * dim, powert = t * t; i < order; - i++, powert *= t, cp += dim) { - bincoeff *= (GLfloat) (order - i); - bincoeff *= inv_tab[i]; - - for (k = 0; k < dim; k++) - out[k] = s * out[k] + bincoeff * powert * cp[k]; - } - } - else { /* order=1 -> constant curve */ - - for (k = 0; k < dim; k++) - out[k] = cp[k]; - } -} - -/* - * Tensor product Bezier surfaces - * - * Again the Horner scheme is used to compute a point on a - * TP Bezier surface. First a control polygon for a curve - * on the surface in one parameter direction is computed, - * then the point on the curve for the other parameter - * direction is evaluated. - * - * To store the curve control polygon additional storage - * for max(uorder,vorder) points is needed in the - * control net cn. - */ - -void -_math_horner_bezier_surf(GLfloat * cn, GLfloat * out, GLfloat u, GLfloat v, - GLuint dim, GLuint uorder, GLuint vorder) -{ - GLfloat *cp = cn + uorder * vorder * dim; - GLuint i, uinc = vorder * dim; - - if (vorder > uorder) { - if (uorder >= 2) { - GLfloat s, poweru, bincoeff; - GLuint j, k; - - /* Compute the control polygon for the surface-curve in u-direction */ - for (j = 0; j < vorder; j++) { - GLfloat *ucp = &cn[j * dim]; - - /* Each control point is the point for parameter u on a */ - /* curve defined by the control polygons in u-direction */ - bincoeff = (GLfloat) (uorder - 1); - s = 1.0F - u; - - for (k = 0; k < dim; k++) - cp[j * dim + k] = s * ucp[k] + bincoeff * u * ucp[uinc + k]; - - for (i = 2, ucp += 2 * uinc, poweru = u * u; i < uorder; - i++, poweru *= u, ucp += uinc) { - bincoeff *= (GLfloat) (uorder - i); - bincoeff *= inv_tab[i]; - - for (k = 0; k < dim; k++) - cp[j * dim + k] = - s * cp[j * dim + k] + bincoeff * poweru * ucp[k]; - } - } - - /* Evaluate curve point in v */ - _math_horner_bezier_curve(cp, out, v, dim, vorder); - } - else /* uorder=1 -> cn defines a curve in v */ - _math_horner_bezier_curve(cn, out, v, dim, vorder); - } - else { /* vorder <= uorder */ - - if (vorder > 1) { - GLuint i; - - /* Compute the control polygon for the surface-curve in u-direction */ - for (i = 0; i < uorder; i++, cn += uinc) { - /* For constant i all cn[i][j] (j=0..vorder) are located */ - /* on consecutive memory locations, so we can use */ - /* horner_bezier_curve to compute the control points */ - - _math_horner_bezier_curve(cn, &cp[i * dim], v, dim, vorder); - } - - /* Evaluate curve point in u */ - _math_horner_bezier_curve(cp, out, u, dim, uorder); - } - else /* vorder=1 -> cn defines a curve in u */ - _math_horner_bezier_curve(cn, out, u, dim, uorder); - } -} - -/* - * The direct de Casteljau algorithm is used when a point on the - * surface and the tangent directions spanning the tangent plane - * should be computed (this is needed to compute normals to the - * surface). In this case the de Casteljau algorithm approach is - * nicer because a point and the partial derivatives can be computed - * at the same time. To get the correct tangent length du and dv - * must be multiplied with the (u2-u1)/uorder-1 and (v2-v1)/vorder-1. - * Since only the directions are needed, this scaling step is omitted. - * - * De Casteljau needs additional storage for uorder*vorder - * values in the control net cn. - */ - -void -_math_de_casteljau_surf(GLfloat * cn, GLfloat * out, GLfloat * du, - GLfloat * dv, GLfloat u, GLfloat v, GLuint dim, - GLuint uorder, GLuint vorder) -{ - GLfloat *dcn = cn + uorder * vorder * dim; - GLfloat us = 1.0F - u, vs = 1.0F - v; - GLuint h, i, j, k; - GLuint minorder = uorder < vorder ? uorder : vorder; - GLuint uinc = vorder * dim; - GLuint dcuinc = vorder; - - /* Each component is evaluated separately to save buffer space */ - /* This does not drasticaly decrease the performance of the */ - /* algorithm. If additional storage for (uorder-1)*(vorder-1) */ - /* points would be available, the components could be accessed */ - /* in the innermost loop which could lead to less cache misses. */ - -#define CN(I,J,K) cn[(I)*uinc+(J)*dim+(K)] -#define DCN(I, J) dcn[(I)*dcuinc+(J)] - if (minorder < 3) { - if (uorder == vorder) { - for (k = 0; k < dim; k++) { - /* Derivative direction in u */ - du[k] = vs * (CN(1, 0, k) - CN(0, 0, k)) + - v * (CN(1, 1, k) - CN(0, 1, k)); - - /* Derivative direction in v */ - dv[k] = us * (CN(0, 1, k) - CN(0, 0, k)) + - u * (CN(1, 1, k) - CN(1, 0, k)); - - /* bilinear de Casteljau step */ - out[k] = us * (vs * CN(0, 0, k) + v * CN(0, 1, k)) + - u * (vs * CN(1, 0, k) + v * CN(1, 1, k)); - } - } - else if (minorder == uorder) { - for (k = 0; k < dim; k++) { - /* bilinear de Casteljau step */ - DCN(1, 0) = CN(1, 0, k) - CN(0, 0, k); - DCN(0, 0) = us * CN(0, 0, k) + u * CN(1, 0, k); - - for (j = 0; j < vorder - 1; j++) { - /* for the derivative in u */ - DCN(1, j + 1) = CN(1, j + 1, k) - CN(0, j + 1, k); - DCN(1, j) = vs * DCN(1, j) + v * DCN(1, j + 1); - - /* for the `point' */ - DCN(0, j + 1) = us * CN(0, j + 1, k) + u * CN(1, j + 1, k); - DCN(0, j) = vs * DCN(0, j) + v * DCN(0, j + 1); - } - - /* remaining linear de Casteljau steps until the second last step */ - for (h = minorder; h < vorder - 1; h++) - for (j = 0; j < vorder - h; j++) { - /* for the derivative in u */ - DCN(1, j) = vs * DCN(1, j) + v * DCN(1, j + 1); - - /* for the `point' */ - DCN(0, j) = vs * DCN(0, j) + v * DCN(0, j + 1); - } - - /* derivative direction in v */ - dv[k] = DCN(0, 1) - DCN(0, 0); - - /* derivative direction in u */ - du[k] = vs * DCN(1, 0) + v * DCN(1, 1); - - /* last linear de Casteljau step */ - out[k] = vs * DCN(0, 0) + v * DCN(0, 1); - } - } - else { /* minorder == vorder */ - - for (k = 0; k < dim; k++) { - /* bilinear de Casteljau step */ - DCN(0, 1) = CN(0, 1, k) - CN(0, 0, k); - DCN(0, 0) = vs * CN(0, 0, k) + v * CN(0, 1, k); - for (i = 0; i < uorder - 1; i++) { - /* for the derivative in v */ - DCN(i + 1, 1) = CN(i + 1, 1, k) - CN(i + 1, 0, k); - DCN(i, 1) = us * DCN(i, 1) + u * DCN(i + 1, 1); - - /* for the `point' */ - DCN(i + 1, 0) = vs * CN(i + 1, 0, k) + v * CN(i + 1, 1, k); - DCN(i, 0) = us * DCN(i, 0) + u * DCN(i + 1, 0); - } - - /* remaining linear de Casteljau steps until the second last step */ - for (h = minorder; h < uorder - 1; h++) - for (i = 0; i < uorder - h; i++) { - /* for the derivative in v */ - DCN(i, 1) = us * DCN(i, 1) + u * DCN(i + 1, 1); - - /* for the `point' */ - DCN(i, 0) = us * DCN(i, 0) + u * DCN(i + 1, 0); - } - - /* derivative direction in u */ - du[k] = DCN(1, 0) - DCN(0, 0); - - /* derivative direction in v */ - dv[k] = us * DCN(0, 1) + u * DCN(1, 1); - - /* last linear de Casteljau step */ - out[k] = us * DCN(0, 0) + u * DCN(1, 0); - } - } - } - else if (uorder == vorder) { - for (k = 0; k < dim; k++) { - /* first bilinear de Casteljau step */ - for (i = 0; i < uorder - 1; i++) { - DCN(i, 0) = us * CN(i, 0, k) + u * CN(i + 1, 0, k); - for (j = 0; j < vorder - 1; j++) { - DCN(i, j + 1) = us * CN(i, j + 1, k) + u * CN(i + 1, j + 1, k); - DCN(i, j) = vs * DCN(i, j) + v * DCN(i, j + 1); - } - } - - /* remaining bilinear de Casteljau steps until the second last step */ - for (h = 2; h < minorder - 1; h++) - for (i = 0; i < uorder - h; i++) { - DCN(i, 0) = us * DCN(i, 0) + u * DCN(i + 1, 0); - for (j = 0; j < vorder - h; j++) { - DCN(i, j + 1) = us * DCN(i, j + 1) + u * DCN(i + 1, j + 1); - DCN(i, j) = vs * DCN(i, j) + v * DCN(i, j + 1); - } - } - - /* derivative direction in u */ - du[k] = vs * (DCN(1, 0) - DCN(0, 0)) + v * (DCN(1, 1) - DCN(0, 1)); - - /* derivative direction in v */ - dv[k] = us * (DCN(0, 1) - DCN(0, 0)) + u * (DCN(1, 1) - DCN(1, 0)); - - /* last bilinear de Casteljau step */ - out[k] = us * (vs * DCN(0, 0) + v * DCN(0, 1)) + - u * (vs * DCN(1, 0) + v * DCN(1, 1)); - } - } - else if (minorder == uorder) { - for (k = 0; k < dim; k++) { - /* first bilinear de Casteljau step */ - for (i = 0; i < uorder - 1; i++) { - DCN(i, 0) = us * CN(i, 0, k) + u * CN(i + 1, 0, k); - for (j = 0; j < vorder - 1; j++) { - DCN(i, j + 1) = us * CN(i, j + 1, k) + u * CN(i + 1, j + 1, k); - DCN(i, j) = vs * DCN(i, j) + v * DCN(i, j + 1); - } - } - - /* remaining bilinear de Casteljau steps until the second last step */ - for (h = 2; h < minorder - 1; h++) - for (i = 0; i < uorder - h; i++) { - DCN(i, 0) = us * DCN(i, 0) + u * DCN(i + 1, 0); - for (j = 0; j < vorder - h; j++) { - DCN(i, j + 1) = us * DCN(i, j + 1) + u * DCN(i + 1, j + 1); - DCN(i, j) = vs * DCN(i, j) + v * DCN(i, j + 1); - } - } - - /* last bilinear de Casteljau step */ - DCN(2, 0) = DCN(1, 0) - DCN(0, 0); - DCN(0, 0) = us * DCN(0, 0) + u * DCN(1, 0); - for (j = 0; j < vorder - 1; j++) { - /* for the derivative in u */ - DCN(2, j + 1) = DCN(1, j + 1) - DCN(0, j + 1); - DCN(2, j) = vs * DCN(2, j) + v * DCN(2, j + 1); - - /* for the `point' */ - DCN(0, j + 1) = us * DCN(0, j + 1) + u * DCN(1, j + 1); - DCN(0, j) = vs * DCN(0, j) + v * DCN(0, j + 1); - } - - /* remaining linear de Casteljau steps until the second last step */ - for (h = minorder; h < vorder - 1; h++) - for (j = 0; j < vorder - h; j++) { - /* for the derivative in u */ - DCN(2, j) = vs * DCN(2, j) + v * DCN(2, j + 1); - - /* for the `point' */ - DCN(0, j) = vs * DCN(0, j) + v * DCN(0, j + 1); - } - - /* derivative direction in v */ - dv[k] = DCN(0, 1) - DCN(0, 0); - - /* derivative direction in u */ - du[k] = vs * DCN(2, 0) + v * DCN(2, 1); - - /* last linear de Casteljau step */ - out[k] = vs * DCN(0, 0) + v * DCN(0, 1); - } - } - else { /* minorder == vorder */ - - for (k = 0; k < dim; k++) { - /* first bilinear de Casteljau step */ - for (i = 0; i < uorder - 1; i++) { - DCN(i, 0) = us * CN(i, 0, k) + u * CN(i + 1, 0, k); - for (j = 0; j < vorder - 1; j++) { - DCN(i, j + 1) = us * CN(i, j + 1, k) + u * CN(i + 1, j + 1, k); - DCN(i, j) = vs * DCN(i, j) + v * DCN(i, j + 1); - } - } - - /* remaining bilinear de Casteljau steps until the second last step */ - for (h = 2; h < minorder - 1; h++) - for (i = 0; i < uorder - h; i++) { - DCN(i, 0) = us * DCN(i, 0) + u * DCN(i + 1, 0); - for (j = 0; j < vorder - h; j++) { - DCN(i, j + 1) = us * DCN(i, j + 1) + u * DCN(i + 1, j + 1); - DCN(i, j) = vs * DCN(i, j) + v * DCN(i, j + 1); - } - } - - /* last bilinear de Casteljau step */ - DCN(0, 2) = DCN(0, 1) - DCN(0, 0); - DCN(0, 0) = vs * DCN(0, 0) + v * DCN(0, 1); - for (i = 0; i < uorder - 1; i++) { - /* for the derivative in v */ - DCN(i + 1, 2) = DCN(i + 1, 1) - DCN(i + 1, 0); - DCN(i, 2) = us * DCN(i, 2) + u * DCN(i + 1, 2); - - /* for the `point' */ - DCN(i + 1, 0) = vs * DCN(i + 1, 0) + v * DCN(i + 1, 1); - DCN(i, 0) = us * DCN(i, 0) + u * DCN(i + 1, 0); - } - - /* remaining linear de Casteljau steps until the second last step */ - for (h = minorder; h < uorder - 1; h++) - for (i = 0; i < uorder - h; i++) { - /* for the derivative in v */ - DCN(i, 2) = us * DCN(i, 2) + u * DCN(i + 1, 2); - - /* for the `point' */ - DCN(i, 0) = us * DCN(i, 0) + u * DCN(i + 1, 0); - } - - /* derivative direction in u */ - du[k] = DCN(1, 0) - DCN(0, 0); - - /* derivative direction in v */ - dv[k] = us * DCN(0, 2) + u * DCN(1, 2); - - /* last linear de Casteljau step */ - out[k] = us * DCN(0, 0) + u * DCN(1, 0); - } - } -#undef DCN -#undef CN -} - - -/* - * Do one-time initialization for evaluators. - */ -void -_math_init_eval(void) -{ - GLuint i; - - /* KW: precompute 1/x for useful x. - */ - for (i = 1; i < MAX_EVAL_ORDER; i++) - inv_tab[i] = 1.0F / i; -} diff --git a/dll/opengl/mesa/math/m_eval.h b/dll/opengl/mesa/math/m_eval.h deleted file mode 100644 index d73ecaafb28..00000000000 --- a/dll/opengl/mesa/math/m_eval.h +++ /dev/null @@ -1,103 +0,0 @@ - -/* - * Mesa 3-D graphics library - * Version: 3.5 - * - * Copyright (C) 1999-2001 Brian Paul All Rights Reserved. - * - * Permission is hereby granted, free of charge, to any person obtaining a - * copy of this software and associated documentation files (the "Software"), - * to deal in the Software without restriction, including without limitation - * the rights to use, copy, modify, merge, publish, distribute, sublicense, - * and/or sell copies of the Software, and to permit persons to whom the - * Software is furnished to do so, subject to the following conditions: - * - * The above copyright notice and this permission notice shall be included - * in all copies or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS - * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL - * BRIAN PAUL BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN - * AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN - * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. - */ - -#ifndef _M_EVAL_H -#define _M_EVAL_H - -#include "main/glheader.h" - -void _math_init_eval( void ); - - -/* - * Horner scheme for Bezier curves - * - * Bezier curves can be computed via a Horner scheme. - * Horner is numerically less stable than the de Casteljau - * algorithm, but it is faster. For curves of degree n - * the complexity of Horner is O(n) and de Casteljau is O(n^2). - * Since stability is not important for displaying curve - * points I decided to use the Horner scheme. - * - * A cubic Bezier curve with control points b0, b1, b2, b3 can be - * written as - * - * (([3] [3] ) [3] ) [3] - * c(t) = (([0]*s*b0 + [1]*t*b1)*s + [2]*t^2*b2)*s + [3]*t^2*b3 - * - * [n] - * where s=1-t and the binomial coefficients [i]. These can - * be computed iteratively using the identity: - * - * [n] [n ] [n] - * [i] = (n-i+1)/i * [i-1] and [0] = 1 - */ - - -void -_math_horner_bezier_curve(const GLfloat *cp, GLfloat *out, GLfloat t, - GLuint dim, GLuint order); - - -/* - * Tensor product Bezier surfaces - * - * Again the Horner scheme is used to compute a point on a - * TP Bezier surface. First a control polygon for a curve - * on the surface in one parameter direction is computed, - * then the point on the curve for the other parameter - * direction is evaluated. - * - * To store the curve control polygon additional storage - * for max(uorder,vorder) points is needed in the - * control net cn. - */ - -void -_math_horner_bezier_surf(GLfloat *cn, GLfloat *out, GLfloat u, GLfloat v, - GLuint dim, GLuint uorder, GLuint vorder); - - -/* - * The direct de Casteljau algorithm is used when a point on the - * surface and the tangent directions spanning the tangent plane - * should be computed (this is needed to compute normals to the - * surface). In this case the de Casteljau algorithm approach is - * nicer because a point and the partial derivatives can be computed - * at the same time. To get the correct tangent length du and dv - * must be multiplied with the (u2-u1)/uorder-1 and (v2-v1)/vorder-1. - * Since only the directions are needed, this scaling step is omitted. - * - * De Casteljau needs additional storage for uorder*vorder - * values in the control net cn. - */ - -void -_math_de_casteljau_surf(GLfloat *cn, GLfloat *out, GLfloat *du, GLfloat *dv, - GLfloat u, GLfloat v, GLuint dim, - GLuint uorder, GLuint vorder); - - -#endif diff --git a/dll/opengl/mesa/math/m_matrix.c b/dll/opengl/mesa/math/m_matrix.c deleted file mode 100644 index d6a956a0fe7..00000000000 --- a/dll/opengl/mesa/math/m_matrix.c +++ /dev/null @@ -1,1635 +0,0 @@ -/* - * Mesa 3-D graphics library - * Version: 6.3 - * - * Copyright (C) 1999-2005 Brian Paul All Rights Reserved. - * - * Permission is hereby granted, free of charge, to any person obtaining a - * copy of this software and associated documentation files (the "Software"), - * to deal in the Software without restriction, including without limitation - * the rights to use, copy, modify, merge, publish, distribute, sublicense, - * and/or sell copies of the Software, and to permit persons to whom the - * Software is furnished to do so, subject to the following conditions: - * - * The above copyright notice and this permission notice shall be included - * in all copies or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS - * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL - * BRIAN PAUL BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN - * AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN - * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. - */ - - -/** - * \file m_matrix.c - * Matrix operations. - * - * \note - * -# 4x4 transformation matrices are stored in memory in column major order. - * -# Points/vertices are to be thought of as column vectors. - * -# Transformation of a point p by a matrix M is: p' = M * p - */ - -#include - -/** - * \defgroup MatFlags MAT_FLAG_XXX-flags - * - * Bitmasks to indicate different kinds of 4x4 matrices in GLmatrix::flags - * It would be nice to make all these flags private to m_matrix.c - */ -/*@{*/ -#define MAT_FLAG_IDENTITY 0 /**< is an identity matrix flag. - * (Not actually used - the identity - * matrix is identified by the absense - * of all other flags.) - */ -#define MAT_FLAG_GENERAL 0x1 /**< is a general matrix flag */ -#define MAT_FLAG_ROTATION 0x2 /**< is a rotation matrix flag */ -#define MAT_FLAG_TRANSLATION 0x4 /**< is a translation matrix flag */ -#define MAT_FLAG_UNIFORM_SCALE 0x8 /**< is an uniform scaling matrix flag */ -#define MAT_FLAG_GENERAL_SCALE 0x10 /**< is a general scaling matrix flag */ -#define MAT_FLAG_GENERAL_3D 0x20 /**< general 3D matrix flag */ -#define MAT_FLAG_PERSPECTIVE 0x40 /**< is a perspective proj matrix flag */ -#define MAT_FLAG_SINGULAR 0x80 /**< is a singular matrix flag */ -#define MAT_DIRTY_TYPE 0x100 /**< matrix type is dirty */ -#define MAT_DIRTY_FLAGS 0x200 /**< matrix flags are dirty */ -#define MAT_DIRTY_INVERSE 0x400 /**< matrix inverse is dirty */ - -/** angle preserving matrix flags mask */ -#define MAT_FLAGS_ANGLE_PRESERVING (MAT_FLAG_ROTATION | \ - MAT_FLAG_TRANSLATION | \ - MAT_FLAG_UNIFORM_SCALE) - -/** geometry related matrix flags mask */ -#define MAT_FLAGS_GEOMETRY (MAT_FLAG_GENERAL | \ - MAT_FLAG_ROTATION | \ - MAT_FLAG_TRANSLATION | \ - MAT_FLAG_UNIFORM_SCALE | \ - MAT_FLAG_GENERAL_SCALE | \ - MAT_FLAG_GENERAL_3D | \ - MAT_FLAG_PERSPECTIVE | \ - MAT_FLAG_SINGULAR) - -/** length preserving matrix flags mask */ -#define MAT_FLAGS_LENGTH_PRESERVING (MAT_FLAG_ROTATION | \ - MAT_FLAG_TRANSLATION) - - -/** 3D (non-perspective) matrix flags mask */ -#define MAT_FLAGS_3D (MAT_FLAG_ROTATION | \ - MAT_FLAG_TRANSLATION | \ - MAT_FLAG_UNIFORM_SCALE | \ - MAT_FLAG_GENERAL_SCALE | \ - MAT_FLAG_GENERAL_3D) - -/** dirty matrix flags mask */ -#define MAT_DIRTY (MAT_DIRTY_TYPE | \ - MAT_DIRTY_FLAGS | \ - MAT_DIRTY_INVERSE) - -/*@}*/ - - -/** - * Test geometry related matrix flags. - * - * \param mat a pointer to a GLmatrix structure. - * \param a flags mask. - * - * \returns non-zero if all geometry related matrix flags are contained within - * the mask, or zero otherwise. - */ -#define TEST_MAT_FLAGS(mat, a) \ - ((MAT_FLAGS_GEOMETRY & (~(a)) & ((mat)->flags) ) == 0) - - - -/** - * Names of the corresponding GLmatrixtype values. - */ -static const char *types[] = { - "MATRIX_GENERAL", - "MATRIX_IDENTITY", - "MATRIX_3D_NO_ROT", - "MATRIX_PERSPECTIVE", - "MATRIX_2D", - "MATRIX_2D_NO_ROT", - "MATRIX_3D" -}; - - -/** - * Identity matrix. - */ -static GLfloat Identity[16] = { - 1.0, 0.0, 0.0, 0.0, - 0.0, 1.0, 0.0, 0.0, - 0.0, 0.0, 1.0, 0.0, - 0.0, 0.0, 0.0, 1.0 -}; - - - -/**********************************************************************/ -/** \name Matrix multiplication */ -/*@{*/ - -#define A(row,col) a[(col<<2)+row] -#define B(row,col) b[(col<<2)+row] -#define P(row,col) product[(col<<2)+row] - -/** - * Perform a full 4x4 matrix multiplication. - * - * \param a matrix. - * \param b matrix. - * \param product will receive the product of \p a and \p b. - * - * \warning Is assumed that \p product != \p b. \p product == \p a is allowed. - * - * \note KW: 4*16 = 64 multiplications - * - * \author This \c matmul was contributed by Thomas Malik - */ -static void matmul4( GLfloat *product, const GLfloat *a, const GLfloat *b ) -{ - GLint i; - for (i = 0; i < 4; i++) { - const GLfloat ai0=A(i,0), ai1=A(i,1), ai2=A(i,2), ai3=A(i,3); - P(i,0) = ai0 * B(0,0) + ai1 * B(1,0) + ai2 * B(2,0) + ai3 * B(3,0); - P(i,1) = ai0 * B(0,1) + ai1 * B(1,1) + ai2 * B(2,1) + ai3 * B(3,1); - P(i,2) = ai0 * B(0,2) + ai1 * B(1,2) + ai2 * B(2,2) + ai3 * B(3,2); - P(i,3) = ai0 * B(0,3) + ai1 * B(1,3) + ai2 * B(2,3) + ai3 * B(3,3); - } -} - -/** - * Multiply two matrices known to occupy only the top three rows, such - * as typical model matrices, and orthogonal matrices. - * - * \param a matrix. - * \param b matrix. - * \param product will receive the product of \p a and \p b. - */ -static void matmul34( GLfloat *product, const GLfloat *a, const GLfloat *b ) -{ - GLint i; - for (i = 0; i < 3; i++) { - const GLfloat ai0=A(i,0), ai1=A(i,1), ai2=A(i,2), ai3=A(i,3); - P(i,0) = ai0 * B(0,0) + ai1 * B(1,0) + ai2 * B(2,0); - P(i,1) = ai0 * B(0,1) + ai1 * B(1,1) + ai2 * B(2,1); - P(i,2) = ai0 * B(0,2) + ai1 * B(1,2) + ai2 * B(2,2); - P(i,3) = ai0 * B(0,3) + ai1 * B(1,3) + ai2 * B(2,3) + ai3; - } - P(3,0) = 0; - P(3,1) = 0; - P(3,2) = 0; - P(3,3) = 1; -} - -#undef A -#undef B -#undef P - -/** - * Multiply a matrix by an array of floats with known properties. - * - * \param mat pointer to a GLmatrix structure containing the left multiplication - * matrix, and that will receive the product result. - * \param m right multiplication matrix array. - * \param flags flags of the matrix \p m. - * - * Joins both flags and marks the type and inverse as dirty. Calls matmul34() - * if both matrices are 3D, or matmul4() otherwise. - */ -static void matrix_multf( GLmatrix *mat, const GLfloat *m, GLuint flags ) -{ - mat->flags |= (flags | MAT_DIRTY_TYPE | MAT_DIRTY_INVERSE); - - if (TEST_MAT_FLAGS(mat, MAT_FLAGS_3D)) - matmul34( mat->m, mat->m, m ); - else - matmul4( mat->m, mat->m, m ); -} - -/** - * Matrix multiplication. - * - * \param dest destination matrix. - * \param a left matrix. - * \param b right matrix. - * - * Joins both flags and marks the type and inverse as dirty. Calls matmul34() - * if both matrices are 3D, or matmul4() otherwise. - */ -void -_math_matrix_mul_matrix( GLmatrix *dest, const GLmatrix *a, const GLmatrix *b ) -{ - dest->flags = (a->flags | - b->flags | - MAT_DIRTY_TYPE | - MAT_DIRTY_INVERSE); - - if (TEST_MAT_FLAGS(dest, MAT_FLAGS_3D)) - matmul34( dest->m, a->m, b->m ); - else - matmul4( dest->m, a->m, b->m ); -} - -/** - * Matrix multiplication. - * - * \param dest left and destination matrix. - * \param m right matrix array. - * - * Marks the matrix flags with general flag, and type and inverse dirty flags. - * Calls matmul4() for the multiplication. - */ -void -_math_matrix_mul_floats( GLmatrix *dest, const GLfloat *m ) -{ - dest->flags |= (MAT_FLAG_GENERAL | - MAT_DIRTY_TYPE | - MAT_DIRTY_INVERSE | - MAT_DIRTY_FLAGS); - - matmul4( dest->m, dest->m, m ); -} - -/*@}*/ - - -/**********************************************************************/ -/** \name Matrix output */ -/*@{*/ - -/** - * Print a matrix array. - * - * \param m matrix array. - * - * Called by _math_matrix_print() to print a matrix or its inverse. - */ -static void print_matrix_floats( const GLfloat m[16] ) -{ - int i; - for (i=0;i<4;i++) { - _mesa_debug(NULL,"\t%f %f %f %f\n", m[i], m[4+i], m[8+i], m[12+i] ); - } -} - -/** - * Dumps the contents of a GLmatrix structure. - * - * \param m pointer to the GLmatrix structure. - */ -void -_math_matrix_print( const GLmatrix *m ) -{ - _mesa_debug(NULL, "Matrix type: %s, flags: %x\n", types[m->type], m->flags); - print_matrix_floats(m->m); - _mesa_debug(NULL, "Inverse: \n"); - if (m->inv) { - GLfloat prod[16]; - print_matrix_floats(m->inv); - matmul4(prod, m->m, m->inv); - _mesa_debug(NULL, "Mat * Inverse:\n"); - print_matrix_floats(prod); - } - else { - _mesa_debug(NULL, " - not available\n"); - } -} - -/*@}*/ - - -/** - * References an element of 4x4 matrix. - * - * \param m matrix array. - * \param c column of the desired element. - * \param r row of the desired element. - * - * \return value of the desired element. - * - * Calculate the linear storage index of the element and references it. - */ -#define MAT(m,r,c) (m)[(c)*4+(r)] - - -/**********************************************************************/ -/** \name Matrix inversion */ -/*@{*/ - -/** - * Swaps the values of two floating pointer variables. - * - * Used by invert_matrix_general() to swap the row pointers. - */ -#define SWAP_ROWS(a, b) { GLfloat *_tmp = a; (a)=(b); (b)=_tmp; } - -/** - * Compute inverse of 4x4 transformation matrix. - * - * \param mat pointer to a GLmatrix structure. The matrix inverse will be - * stored in the GLmatrix::inv attribute. - * - * \return GL_TRUE for success, GL_FALSE for failure (\p singular matrix). - * - * \author - * Code contributed by Jacques Leroy jle@star.be - * - * Calculates the inverse matrix by performing the gaussian matrix reduction - * with partial pivoting followed by back/substitution with the loops manually - * unrolled. - */ -static GLboolean invert_matrix_general( GLmatrix *mat ) -{ - const GLfloat *m = mat->m; - GLfloat *out = mat->inv; - GLfloat wtmp[4][8]; - GLfloat m0, m1, m2, m3, s; - GLfloat *r0, *r1, *r2, *r3; - - r0 = wtmp[0], r1 = wtmp[1], r2 = wtmp[2], r3 = wtmp[3]; - - r0[0] = MAT(m,0,0), r0[1] = MAT(m,0,1), - r0[2] = MAT(m,0,2), r0[3] = MAT(m,0,3), - r0[4] = 1.0, r0[5] = r0[6] = r0[7] = 0.0, - - r1[0] = MAT(m,1,0), r1[1] = MAT(m,1,1), - r1[2] = MAT(m,1,2), r1[3] = MAT(m,1,3), - r1[5] = 1.0, r1[4] = r1[6] = r1[7] = 0.0, - - r2[0] = MAT(m,2,0), r2[1] = MAT(m,2,1), - r2[2] = MAT(m,2,2), r2[3] = MAT(m,2,3), - r2[6] = 1.0, r2[4] = r2[5] = r2[7] = 0.0, - - r3[0] = MAT(m,3,0), r3[1] = MAT(m,3,1), - r3[2] = MAT(m,3,2), r3[3] = MAT(m,3,3), - r3[7] = 1.0, r3[4] = r3[5] = r3[6] = 0.0; - - /* choose pivot - or die */ - if (FABSF(r3[0])>FABSF(r2[0])) SWAP_ROWS(r3, r2); - if (FABSF(r2[0])>FABSF(r1[0])) SWAP_ROWS(r2, r1); - if (FABSF(r1[0])>FABSF(r0[0])) SWAP_ROWS(r1, r0); - if (0.0 == r0[0]) return GL_FALSE; - - /* eliminate first variable */ - m1 = r1[0]/r0[0]; m2 = r2[0]/r0[0]; m3 = r3[0]/r0[0]; - s = r0[1]; r1[1] -= m1 * s; r2[1] -= m2 * s; r3[1] -= m3 * s; - s = r0[2]; r1[2] -= m1 * s; r2[2] -= m2 * s; r3[2] -= m3 * s; - s = r0[3]; r1[3] -= m1 * s; r2[3] -= m2 * s; r3[3] -= m3 * s; - s = r0[4]; - if (s != 0.0) { r1[4] -= m1 * s; r2[4] -= m2 * s; r3[4] -= m3 * s; } - s = r0[5]; - if (s != 0.0) { r1[5] -= m1 * s; r2[5] -= m2 * s; r3[5] -= m3 * s; } - s = r0[6]; - if (s != 0.0) { r1[6] -= m1 * s; r2[6] -= m2 * s; r3[6] -= m3 * s; } - s = r0[7]; - if (s != 0.0) { r1[7] -= m1 * s; r2[7] -= m2 * s; r3[7] -= m3 * s; } - - /* choose pivot - or die */ - if (FABSF(r3[1])>FABSF(r2[1])) SWAP_ROWS(r3, r2); - if (FABSF(r2[1])>FABSF(r1[1])) SWAP_ROWS(r2, r1); - if (0.0 == r1[1]) return GL_FALSE; - - /* eliminate second variable */ - m2 = r2[1]/r1[1]; m3 = r3[1]/r1[1]; - r2[2] -= m2 * r1[2]; r3[2] -= m3 * r1[2]; - r2[3] -= m2 * r1[3]; r3[3] -= m3 * r1[3]; - s = r1[4]; if (0.0 != s) { r2[4] -= m2 * s; r3[4] -= m3 * s; } - s = r1[5]; if (0.0 != s) { r2[5] -= m2 * s; r3[5] -= m3 * s; } - s = r1[6]; if (0.0 != s) { r2[6] -= m2 * s; r3[6] -= m3 * s; } - s = r1[7]; if (0.0 != s) { r2[7] -= m2 * s; r3[7] -= m3 * s; } - - /* choose pivot - or die */ - if (FABSF(r3[2])>FABSF(r2[2])) SWAP_ROWS(r3, r2); - if (0.0 == r2[2]) return GL_FALSE; - - /* eliminate third variable */ - m3 = r3[2]/r2[2]; - r3[3] -= m3 * r2[3], r3[4] -= m3 * r2[4], - r3[5] -= m3 * r2[5], r3[6] -= m3 * r2[6], - r3[7] -= m3 * r2[7]; - - /* last check */ - if (0.0 == r3[3]) return GL_FALSE; - - s = 1.0F/r3[3]; /* now back substitute row 3 */ - r3[4] *= s; r3[5] *= s; r3[6] *= s; r3[7] *= s; - - m2 = r2[3]; /* now back substitute row 2 */ - s = 1.0F/r2[2]; - r2[4] = s * (r2[4] - r3[4] * m2), r2[5] = s * (r2[5] - r3[5] * m2), - r2[6] = s * (r2[6] - r3[6] * m2), r2[7] = s * (r2[7] - r3[7] * m2); - m1 = r1[3]; - r1[4] -= r3[4] * m1, r1[5] -= r3[5] * m1, - r1[6] -= r3[6] * m1, r1[7] -= r3[7] * m1; - m0 = r0[3]; - r0[4] -= r3[4] * m0, r0[5] -= r3[5] * m0, - r0[6] -= r3[6] * m0, r0[7] -= r3[7] * m0; - - m1 = r1[2]; /* now back substitute row 1 */ - s = 1.0F/r1[1]; - r1[4] = s * (r1[4] - r2[4] * m1), r1[5] = s * (r1[5] - r2[5] * m1), - r1[6] = s * (r1[6] - r2[6] * m1), r1[7] = s * (r1[7] - r2[7] * m1); - m0 = r0[2]; - r0[4] -= r2[4] * m0, r0[5] -= r2[5] * m0, - r0[6] -= r2[6] * m0, r0[7] -= r2[7] * m0; - - m0 = r0[1]; /* now back substitute row 0 */ - s = 1.0F/r0[0]; - r0[4] = s * (r0[4] - r1[4] * m0), r0[5] = s * (r0[5] - r1[5] * m0), - r0[6] = s * (r0[6] - r1[6] * m0), r0[7] = s * (r0[7] - r1[7] * m0); - - MAT(out,0,0) = r0[4]; MAT(out,0,1) = r0[5], - MAT(out,0,2) = r0[6]; MAT(out,0,3) = r0[7], - MAT(out,1,0) = r1[4]; MAT(out,1,1) = r1[5], - MAT(out,1,2) = r1[6]; MAT(out,1,3) = r1[7], - MAT(out,2,0) = r2[4]; MAT(out,2,1) = r2[5], - MAT(out,2,2) = r2[6]; MAT(out,2,3) = r2[7], - MAT(out,3,0) = r3[4]; MAT(out,3,1) = r3[5], - MAT(out,3,2) = r3[6]; MAT(out,3,3) = r3[7]; - - return GL_TRUE; -} -#undef SWAP_ROWS - -/** - * Compute inverse of a general 3d transformation matrix. - * - * \param mat pointer to a GLmatrix structure. The matrix inverse will be - * stored in the GLmatrix::inv attribute. - * - * \return GL_TRUE for success, GL_FALSE for failure (\p singular matrix). - * - * \author Adapted from graphics gems II. - * - * Calculates the inverse of the upper left by first calculating its - * determinant and multiplying it to the symmetric adjust matrix of each - * element. Finally deals with the translation part by transforming the - * original translation vector using by the calculated submatrix inverse. - */ -static GLboolean invert_matrix_3d_general( GLmatrix *mat ) -{ - const GLfloat *in = mat->m; - GLfloat *out = mat->inv; - GLfloat pos, neg, t; - GLfloat det; - - /* Calculate the determinant of upper left 3x3 submatrix and - * determine if the matrix is singular. - */ - pos = neg = 0.0; - t = MAT(in,0,0) * MAT(in,1,1) * MAT(in,2,2); - if (t >= 0.0) pos += t; else neg += t; - - t = MAT(in,1,0) * MAT(in,2,1) * MAT(in,0,2); - if (t >= 0.0) pos += t; else neg += t; - - t = MAT(in,2,0) * MAT(in,0,1) * MAT(in,1,2); - if (t >= 0.0) pos += t; else neg += t; - - t = -MAT(in,2,0) * MAT(in,1,1) * MAT(in,0,2); - if (t >= 0.0) pos += t; else neg += t; - - t = -MAT(in,1,0) * MAT(in,0,1) * MAT(in,2,2); - if (t >= 0.0) pos += t; else neg += t; - - t = -MAT(in,0,0) * MAT(in,2,1) * MAT(in,1,2); - if (t >= 0.0) pos += t; else neg += t; - - det = pos + neg; - - if (det*det < 1e-25) - return GL_FALSE; - - det = 1.0F / det; - MAT(out,0,0) = ( (MAT(in,1,1)*MAT(in,2,2) - MAT(in,2,1)*MAT(in,1,2) )*det); - MAT(out,0,1) = (- (MAT(in,0,1)*MAT(in,2,2) - MAT(in,2,1)*MAT(in,0,2) )*det); - MAT(out,0,2) = ( (MAT(in,0,1)*MAT(in,1,2) - MAT(in,1,1)*MAT(in,0,2) )*det); - MAT(out,1,0) = (- (MAT(in,1,0)*MAT(in,2,2) - MAT(in,2,0)*MAT(in,1,2) )*det); - MAT(out,1,1) = ( (MAT(in,0,0)*MAT(in,2,2) - MAT(in,2,0)*MAT(in,0,2) )*det); - MAT(out,1,2) = (- (MAT(in,0,0)*MAT(in,1,2) - MAT(in,1,0)*MAT(in,0,2) )*det); - MAT(out,2,0) = ( (MAT(in,1,0)*MAT(in,2,1) - MAT(in,2,0)*MAT(in,1,1) )*det); - MAT(out,2,1) = (- (MAT(in,0,0)*MAT(in,2,1) - MAT(in,2,0)*MAT(in,0,1) )*det); - MAT(out,2,2) = ( (MAT(in,0,0)*MAT(in,1,1) - MAT(in,1,0)*MAT(in,0,1) )*det); - - /* Do the translation part */ - MAT(out,0,3) = - (MAT(in,0,3) * MAT(out,0,0) + - MAT(in,1,3) * MAT(out,0,1) + - MAT(in,2,3) * MAT(out,0,2) ); - MAT(out,1,3) = - (MAT(in,0,3) * MAT(out,1,0) + - MAT(in,1,3) * MAT(out,1,1) + - MAT(in,2,3) * MAT(out,1,2) ); - MAT(out,2,3) = - (MAT(in,0,3) * MAT(out,2,0) + - MAT(in,1,3) * MAT(out,2,1) + - MAT(in,2,3) * MAT(out,2,2) ); - - return GL_TRUE; -} - -/** - * Compute inverse of a 3d transformation matrix. - * - * \param mat pointer to a GLmatrix structure. The matrix inverse will be - * stored in the GLmatrix::inv attribute. - * - * \return GL_TRUE for success, GL_FALSE for failure (\p singular matrix). - * - * If the matrix is not an angle preserving matrix then calls - * invert_matrix_3d_general for the actual calculation. Otherwise calculates - * the inverse matrix analyzing and inverting each of the scaling, rotation and - * translation parts. - */ -static GLboolean invert_matrix_3d( GLmatrix *mat ) -{ - const GLfloat *in = mat->m; - GLfloat *out = mat->inv; - - if (!TEST_MAT_FLAGS(mat, MAT_FLAGS_ANGLE_PRESERVING)) { - return invert_matrix_3d_general( mat ); - } - - if (mat->flags & MAT_FLAG_UNIFORM_SCALE) { - GLfloat scale = (MAT(in,0,0) * MAT(in,0,0) + - MAT(in,0,1) * MAT(in,0,1) + - MAT(in,0,2) * MAT(in,0,2)); - - if (scale == 0.0) - return GL_FALSE; - - scale = 1.0F / scale; - - /* Transpose and scale the 3 by 3 upper-left submatrix. */ - MAT(out,0,0) = scale * MAT(in,0,0); - MAT(out,1,0) = scale * MAT(in,0,1); - MAT(out,2,0) = scale * MAT(in,0,2); - MAT(out,0,1) = scale * MAT(in,1,0); - MAT(out,1,1) = scale * MAT(in,1,1); - MAT(out,2,1) = scale * MAT(in,1,2); - MAT(out,0,2) = scale * MAT(in,2,0); - MAT(out,1,2) = scale * MAT(in,2,1); - MAT(out,2,2) = scale * MAT(in,2,2); - } - else if (mat->flags & MAT_FLAG_ROTATION) { - /* Transpose the 3 by 3 upper-left submatrix. */ - MAT(out,0,0) = MAT(in,0,0); - MAT(out,1,0) = MAT(in,0,1); - MAT(out,2,0) = MAT(in,0,2); - MAT(out,0,1) = MAT(in,1,0); - MAT(out,1,1) = MAT(in,1,1); - MAT(out,2,1) = MAT(in,1,2); - MAT(out,0,2) = MAT(in,2,0); - MAT(out,1,2) = MAT(in,2,1); - MAT(out,2,2) = MAT(in,2,2); - } - else { - /* pure translation */ - memcpy( out, Identity, sizeof(Identity) ); - MAT(out,0,3) = - MAT(in,0,3); - MAT(out,1,3) = - MAT(in,1,3); - MAT(out,2,3) = - MAT(in,2,3); - return GL_TRUE; - } - - if (mat->flags & MAT_FLAG_TRANSLATION) { - /* Do the translation part */ - MAT(out,0,3) = - (MAT(in,0,3) * MAT(out,0,0) + - MAT(in,1,3) * MAT(out,0,1) + - MAT(in,2,3) * MAT(out,0,2) ); - MAT(out,1,3) = - (MAT(in,0,3) * MAT(out,1,0) + - MAT(in,1,3) * MAT(out,1,1) + - MAT(in,2,3) * MAT(out,1,2) ); - MAT(out,2,3) = - (MAT(in,0,3) * MAT(out,2,0) + - MAT(in,1,3) * MAT(out,2,1) + - MAT(in,2,3) * MAT(out,2,2) ); - } - else { - MAT(out,0,3) = MAT(out,1,3) = MAT(out,2,3) = 0.0; - } - - return GL_TRUE; -} - -/** - * Compute inverse of an identity transformation matrix. - * - * \param mat pointer to a GLmatrix structure. The matrix inverse will be - * stored in the GLmatrix::inv attribute. - * - * \return always GL_TRUE. - * - * Simply copies Identity into GLmatrix::inv. - */ -static GLboolean invert_matrix_identity( GLmatrix *mat ) -{ - memcpy( mat->inv, Identity, sizeof(Identity) ); - return GL_TRUE; -} - -/** - * Compute inverse of a no-rotation 3d transformation matrix. - * - * \param mat pointer to a GLmatrix structure. The matrix inverse will be - * stored in the GLmatrix::inv attribute. - * - * \return GL_TRUE for success, GL_FALSE for failure (\p singular matrix). - * - * Calculates the - */ -static GLboolean invert_matrix_3d_no_rot( GLmatrix *mat ) -{ - const GLfloat *in = mat->m; - GLfloat *out = mat->inv; - - if (MAT(in,0,0) == 0 || MAT(in,1,1) == 0 || MAT(in,2,2) == 0 ) - return GL_FALSE; - - memcpy( out, Identity, 16 * sizeof(GLfloat) ); - MAT(out,0,0) = 1.0F / MAT(in,0,0); - MAT(out,1,1) = 1.0F / MAT(in,1,1); - MAT(out,2,2) = 1.0F / MAT(in,2,2); - - if (mat->flags & MAT_FLAG_TRANSLATION) { - MAT(out,0,3) = - (MAT(in,0,3) * MAT(out,0,0)); - MAT(out,1,3) = - (MAT(in,1,3) * MAT(out,1,1)); - MAT(out,2,3) = - (MAT(in,2,3) * MAT(out,2,2)); - } - - return GL_TRUE; -} - -/** - * Compute inverse of a no-rotation 2d transformation matrix. - * - * \param mat pointer to a GLmatrix structure. The matrix inverse will be - * stored in the GLmatrix::inv attribute. - * - * \return GL_TRUE for success, GL_FALSE for failure (\p singular matrix). - * - * Calculates the inverse matrix by applying the inverse scaling and - * translation to the identity matrix. - */ -static GLboolean invert_matrix_2d_no_rot( GLmatrix *mat ) -{ - const GLfloat *in = mat->m; - GLfloat *out = mat->inv; - - if (MAT(in,0,0) == 0 || MAT(in,1,1) == 0) - return GL_FALSE; - - memcpy( out, Identity, 16 * sizeof(GLfloat) ); - MAT(out,0,0) = 1.0F / MAT(in,0,0); - MAT(out,1,1) = 1.0F / MAT(in,1,1); - - if (mat->flags & MAT_FLAG_TRANSLATION) { - MAT(out,0,3) = - (MAT(in,0,3) * MAT(out,0,0)); - MAT(out,1,3) = - (MAT(in,1,3) * MAT(out,1,1)); - } - - return GL_TRUE; -} - -#if 0 -/* broken */ -static GLboolean invert_matrix_perspective( GLmatrix *mat ) -{ - const GLfloat *in = mat->m; - GLfloat *out = mat->inv; - - if (MAT(in,2,3) == 0) - return GL_FALSE; - - memcpy( out, Identity, 16 * sizeof(GLfloat) ); - - MAT(out,0,0) = 1.0F / MAT(in,0,0); - MAT(out,1,1) = 1.0F / MAT(in,1,1); - - MAT(out,0,3) = MAT(in,0,2); - MAT(out,1,3) = MAT(in,1,2); - - MAT(out,2,2) = 0; - MAT(out,2,3) = -1; - - MAT(out,3,2) = 1.0F / MAT(in,2,3); - MAT(out,3,3) = MAT(in,2,2) * MAT(out,3,2); - - return GL_TRUE; -} -#endif - -/** - * Matrix inversion function pointer type. - */ -typedef GLboolean (*inv_mat_func)( GLmatrix *mat ); - -/** - * Table of the matrix inversion functions according to the matrix type. - */ -static inv_mat_func inv_mat_tab[7] = { - invert_matrix_general, - invert_matrix_identity, - invert_matrix_3d_no_rot, -#if 0 - /* Don't use this function for now - it fails when the projection matrix - * is premultiplied by a translation (ala Chromium's tilesort SPU). - */ - invert_matrix_perspective, -#else - invert_matrix_general, -#endif - invert_matrix_3d, /* lazy! */ - invert_matrix_2d_no_rot, - invert_matrix_3d -}; - -/** - * Compute inverse of a transformation matrix. - * - * \param mat pointer to a GLmatrix structure. The matrix inverse will be - * stored in the GLmatrix::inv attribute. - * - * \return GL_TRUE for success, GL_FALSE for failure (\p singular matrix). - * - * Calls the matrix inversion function in inv_mat_tab corresponding to the - * given matrix type. In case of failure, updates the MAT_FLAG_SINGULAR flag, - * and copies the identity matrix into GLmatrix::inv. - */ -static GLboolean matrix_invert( GLmatrix *mat ) -{ - if (inv_mat_tab[mat->type](mat)) { - mat->flags &= ~MAT_FLAG_SINGULAR; - return GL_TRUE; - } else { - mat->flags |= MAT_FLAG_SINGULAR; - memcpy( mat->inv, Identity, sizeof(Identity) ); - return GL_FALSE; - } -} - -/*@}*/ - - -/**********************************************************************/ -/** \name Matrix generation */ -/*@{*/ - -/** - * Generate a 4x4 transformation matrix from glRotate parameters, and - * post-multiply the input matrix by it. - * - * \author - * This function was contributed by Erich Boleyn (erich@uruk.org). - * Optimizations contributed by Rudolf Opalla (rudi@khm.de). - */ -void -_math_matrix_rotate( GLmatrix *mat, - GLfloat angle, GLfloat x, GLfloat y, GLfloat z ) -{ - GLfloat xx, yy, zz, xy, yz, zx, xs, ys, zs, one_c, s, c; - GLfloat m[16]; - GLboolean optimized; - - s = (GLfloat) sin( angle * DEG2RAD ); - c = (GLfloat) cos( angle * DEG2RAD ); - - memcpy(m, Identity, sizeof(GLfloat)*16); - optimized = GL_FALSE; - -#define M(row,col) m[col*4+row] - - if (x == 0.0F) { - if (y == 0.0F) { - if (z != 0.0F) { - optimized = GL_TRUE; - /* rotate only around z-axis */ - M(0,0) = c; - M(1,1) = c; - if (z < 0.0F) { - M(0,1) = s; - M(1,0) = -s; - } - else { - M(0,1) = -s; - M(1,0) = s; - } - } - } - else if (z == 0.0F) { - optimized = GL_TRUE; - /* rotate only around y-axis */ - M(0,0) = c; - M(2,2) = c; - if (y < 0.0F) { - M(0,2) = -s; - M(2,0) = s; - } - else { - M(0,2) = s; - M(2,0) = -s; - } - } - } - else if (y == 0.0F) { - if (z == 0.0F) { - optimized = GL_TRUE; - /* rotate only around x-axis */ - M(1,1) = c; - M(2,2) = c; - if (x < 0.0F) { - M(1,2) = s; - M(2,1) = -s; - } - else { - M(1,2) = -s; - M(2,1) = s; - } - } - } - - if (!optimized) { - const GLfloat mag = SQRTF(x * x + y * y + z * z); - - if (mag <= 1.0e-4) { - /* no rotation, leave mat as-is */ - return; - } - - x /= mag; - y /= mag; - z /= mag; - - - /* - * Arbitrary axis rotation matrix. - * - * This is composed of 5 matrices, Rz, Ry, T, Ry', Rz', multiplied - * like so: Rz * Ry * T * Ry' * Rz'. T is the final rotation - * (which is about the X-axis), and the two composite transforms - * Ry' * Rz' and Rz * Ry are (respectively) the rotations necessary - * from the arbitrary axis to the X-axis then back. They are - * all elementary rotations. - * - * Rz' is a rotation about the Z-axis, to bring the axis vector - * into the x-z plane. Then Ry' is applied, rotating about the - * Y-axis to bring the axis vector parallel with the X-axis. The - * rotation about the X-axis is then performed. Ry and Rz are - * simply the respective inverse transforms to bring the arbitrary - * axis back to its original orientation. The first transforms - * Rz' and Ry' are considered inverses, since the data from the - * arbitrary axis gives you info on how to get to it, not how - * to get away from it, and an inverse must be applied. - * - * The basic calculation used is to recognize that the arbitrary - * axis vector (x, y, z), since it is of unit length, actually - * represents the sines and cosines of the angles to rotate the - * X-axis to the same orientation, with theta being the angle about - * Z and phi the angle about Y (in the order described above) - * as follows: - * - * cos ( theta ) = x / sqrt ( 1 - z^2 ) - * sin ( theta ) = y / sqrt ( 1 - z^2 ) - * - * cos ( phi ) = sqrt ( 1 - z^2 ) - * sin ( phi ) = z - * - * Note that cos ( phi ) can further be inserted to the above - * formulas: - * - * cos ( theta ) = x / cos ( phi ) - * sin ( theta ) = y / sin ( phi ) - * - * ...etc. Because of those relations and the standard trigonometric - * relations, it is pssible to reduce the transforms down to what - * is used below. It may be that any primary axis chosen will give the - * same results (modulo a sign convention) using thie method. - * - * Particularly nice is to notice that all divisions that might - * have caused trouble when parallel to certain planes or - * axis go away with care paid to reducing the expressions. - * After checking, it does perform correctly under all cases, since - * in all the cases of division where the denominator would have - * been zero, the numerator would have been zero as well, giving - * the expected result. - */ - - xx = x * x; - yy = y * y; - zz = z * z; - xy = x * y; - yz = y * z; - zx = z * x; - xs = x * s; - ys = y * s; - zs = z * s; - one_c = 1.0F - c; - - /* We already hold the identity-matrix so we can skip some statements */ - M(0,0) = (one_c * xx) + c; - M(0,1) = (one_c * xy) - zs; - M(0,2) = (one_c * zx) + ys; -/* M(0,3) = 0.0F; */ - - M(1,0) = (one_c * xy) + zs; - M(1,1) = (one_c * yy) + c; - M(1,2) = (one_c * yz) - xs; -/* M(1,3) = 0.0F; */ - - M(2,0) = (one_c * zx) - ys; - M(2,1) = (one_c * yz) + xs; - M(2,2) = (one_c * zz) + c; -/* M(2,3) = 0.0F; */ - -/* - M(3,0) = 0.0F; - M(3,1) = 0.0F; - M(3,2) = 0.0F; - M(3,3) = 1.0F; -*/ - } -#undef M - - matrix_multf( mat, m, MAT_FLAG_ROTATION ); -} - -/** - * Apply a perspective projection matrix. - * - * \param mat matrix to apply the projection. - * \param left left clipping plane coordinate. - * \param right right clipping plane coordinate. - * \param bottom bottom clipping plane coordinate. - * \param top top clipping plane coordinate. - * \param nearval distance to the near clipping plane. - * \param farval distance to the far clipping plane. - * - * Creates the projection matrix and multiplies it with \p mat, marking the - * MAT_FLAG_PERSPECTIVE flag. - */ -void -_math_matrix_frustum( GLmatrix *mat, - GLfloat left, GLfloat right, - GLfloat bottom, GLfloat top, - GLfloat nearval, GLfloat farval ) -{ - GLfloat x, y, a, b, c, d; - GLfloat m[16]; - - x = (2.0F*nearval) / (right-left); - y = (2.0F*nearval) / (top-bottom); - a = (right+left) / (right-left); - b = (top+bottom) / (top-bottom); - c = -(farval+nearval) / ( farval-nearval); - d = -(2.0F*farval*nearval) / (farval-nearval); /* error? */ - -#define M(row,col) m[col*4+row] - M(0,0) = x; M(0,1) = 0.0F; M(0,2) = a; M(0,3) = 0.0F; - M(1,0) = 0.0F; M(1,1) = y; M(1,2) = b; M(1,3) = 0.0F; - M(2,0) = 0.0F; M(2,1) = 0.0F; M(2,2) = c; M(2,3) = d; - M(3,0) = 0.0F; M(3,1) = 0.0F; M(3,2) = -1.0F; M(3,3) = 0.0F; -#undef M - - matrix_multf( mat, m, MAT_FLAG_PERSPECTIVE ); -} - -/** - * Apply an orthographic projection matrix. - * - * \param mat matrix to apply the projection. - * \param left left clipping plane coordinate. - * \param right right clipping plane coordinate. - * \param bottom bottom clipping plane coordinate. - * \param top top clipping plane coordinate. - * \param nearval distance to the near clipping plane. - * \param farval distance to the far clipping plane. - * - * Creates the projection matrix and multiplies it with \p mat, marking the - * MAT_FLAG_GENERAL_SCALE and MAT_FLAG_TRANSLATION flags. - */ -void -_math_matrix_ortho( GLmatrix *mat, - GLfloat left, GLfloat right, - GLfloat bottom, GLfloat top, - GLfloat nearval, GLfloat farval ) -{ - GLfloat m[16]; - -#define M(row,col) m[col*4+row] - M(0,0) = 2.0F / (right-left); - M(0,1) = 0.0F; - M(0,2) = 0.0F; - M(0,3) = -(right+left) / (right-left); - - M(1,0) = 0.0F; - M(1,1) = 2.0F / (top-bottom); - M(1,2) = 0.0F; - M(1,3) = -(top+bottom) / (top-bottom); - - M(2,0) = 0.0F; - M(2,1) = 0.0F; - M(2,2) = -2.0F / (farval-nearval); - M(2,3) = -(farval+nearval) / (farval-nearval); - - M(3,0) = 0.0F; - M(3,1) = 0.0F; - M(3,2) = 0.0F; - M(3,3) = 1.0F; -#undef M - - matrix_multf( mat, m, (MAT_FLAG_GENERAL_SCALE|MAT_FLAG_TRANSLATION)); -} - -/** - * Multiply a matrix with a general scaling matrix. - * - * \param mat matrix. - * \param x x axis scale factor. - * \param y y axis scale factor. - * \param z z axis scale factor. - * - * Multiplies in-place the elements of \p mat by the scale factors. Checks if - * the scales factors are roughly the same, marking the MAT_FLAG_UNIFORM_SCALE - * flag, or MAT_FLAG_GENERAL_SCALE. Marks the MAT_DIRTY_TYPE and - * MAT_DIRTY_INVERSE dirty flags. - */ -void -_math_matrix_scale( GLmatrix *mat, GLfloat x, GLfloat y, GLfloat z ) -{ - GLfloat *m = mat->m; - m[0] *= x; m[4] *= y; m[8] *= z; - m[1] *= x; m[5] *= y; m[9] *= z; - m[2] *= x; m[6] *= y; m[10] *= z; - m[3] *= x; m[7] *= y; m[11] *= z; - - if (FABSF(x - y) < 1e-8 && FABSF(x - z) < 1e-8) - mat->flags |= MAT_FLAG_UNIFORM_SCALE; - else - mat->flags |= MAT_FLAG_GENERAL_SCALE; - - mat->flags |= (MAT_DIRTY_TYPE | - MAT_DIRTY_INVERSE); -} - -/** - * Multiply a matrix with a translation matrix. - * - * \param mat matrix. - * \param x translation vector x coordinate. - * \param y translation vector y coordinate. - * \param z translation vector z coordinate. - * - * Adds the translation coordinates to the elements of \p mat in-place. Marks - * the MAT_FLAG_TRANSLATION flag, and the MAT_DIRTY_TYPE and MAT_DIRTY_INVERSE - * dirty flags. - */ -void -_math_matrix_translate( GLmatrix *mat, GLfloat x, GLfloat y, GLfloat z ) -{ - GLfloat *m = mat->m; - m[12] = m[0] * x + m[4] * y + m[8] * z + m[12]; - m[13] = m[1] * x + m[5] * y + m[9] * z + m[13]; - m[14] = m[2] * x + m[6] * y + m[10] * z + m[14]; - m[15] = m[3] * x + m[7] * y + m[11] * z + m[15]; - - mat->flags |= (MAT_FLAG_TRANSLATION | - MAT_DIRTY_TYPE | - MAT_DIRTY_INVERSE); -} - - -/** - * Set matrix to do viewport and depthrange mapping. - * Transforms Normalized Device Coords to window/Z values. - */ -void -_math_matrix_viewport(GLmatrix *m, GLint x, GLint y, GLint width, GLint height, - GLfloat zNear, GLfloat zFar, GLfloat depthMax) -{ - m->m[MAT_SX] = (GLfloat) width / 2.0F; - m->m[MAT_TX] = m->m[MAT_SX] + x; - m->m[MAT_SY] = (GLfloat) height / 2.0F; - m->m[MAT_TY] = m->m[MAT_SY] + y; - m->m[MAT_SZ] = depthMax * ((zFar - zNear) / 2.0F); - m->m[MAT_TZ] = depthMax * ((zFar - zNear) / 2.0F + zNear); - m->flags = MAT_FLAG_GENERAL_SCALE | MAT_FLAG_TRANSLATION; - m->type = MATRIX_3D_NO_ROT; -} - - -/** - * Set a matrix to the identity matrix. - * - * \param mat matrix. - * - * Copies ::Identity into \p GLmatrix::m, and into GLmatrix::inv if not NULL. - * Sets the matrix type to identity, and clear the dirty flags. - */ -void -_math_matrix_set_identity( GLmatrix *mat ) -{ - memcpy( mat->m, Identity, 16*sizeof(GLfloat) ); - - if (mat->inv) - memcpy( mat->inv, Identity, 16*sizeof(GLfloat) ); - - mat->type = MATRIX_IDENTITY; - mat->flags &= ~(MAT_DIRTY_FLAGS| - MAT_DIRTY_TYPE| - MAT_DIRTY_INVERSE); -} - -/*@}*/ - - -/**********************************************************************/ -/** \name Matrix analysis */ -/*@{*/ - -#define ZERO(x) (1<m; - GLuint mask = 0; - GLuint i; - - for (i = 0 ; i < 16 ; i++) { - if (m[i] == 0.0) mask |= (1<flags &= ~MAT_FLAGS_GEOMETRY; - - /* Check for translation - no-one really cares - */ - if ((mask & MASK_NO_TRX) != MASK_NO_TRX) - mat->flags |= MAT_FLAG_TRANSLATION; - - /* Do the real work - */ - if (mask == (GLuint) MASK_IDENTITY) { - mat->type = MATRIX_IDENTITY; - } - else if ((mask & MASK_2D_NO_ROT) == (GLuint) MASK_2D_NO_ROT) { - mat->type = MATRIX_2D_NO_ROT; - - if ((mask & MASK_NO_2D_SCALE) != MASK_NO_2D_SCALE) - mat->flags |= MAT_FLAG_GENERAL_SCALE; - } - else if ((mask & MASK_2D) == (GLuint) MASK_2D) { - GLfloat mm = DOT2(m, m); - GLfloat m4m4 = DOT2(m+4,m+4); - GLfloat mm4 = DOT2(m,m+4); - - mat->type = MATRIX_2D; - - /* Check for scale */ - if (SQ(mm-1) > SQ(1e-6) || - SQ(m4m4-1) > SQ(1e-6)) - mat->flags |= MAT_FLAG_GENERAL_SCALE; - - /* Check for rotation */ - if (SQ(mm4) > SQ(1e-6)) - mat->flags |= MAT_FLAG_GENERAL_3D; - else - mat->flags |= MAT_FLAG_ROTATION; - - } - else if ((mask & MASK_3D_NO_ROT) == (GLuint) MASK_3D_NO_ROT) { - mat->type = MATRIX_3D_NO_ROT; - - /* Check for scale */ - if (SQ(m[0]-m[5]) < SQ(1e-6) && - SQ(m[0]-m[10]) < SQ(1e-6)) { - if (SQ(m[0]-1.0) > SQ(1e-6)) { - mat->flags |= MAT_FLAG_UNIFORM_SCALE; - } - } - else { - mat->flags |= MAT_FLAG_GENERAL_SCALE; - } - } - else if ((mask & MASK_3D) == (GLuint) MASK_3D) { - GLfloat c1 = DOT3(m,m); - GLfloat c2 = DOT3(m+4,m+4); - GLfloat c3 = DOT3(m+8,m+8); - GLfloat d1 = DOT3(m, m+4); - GLfloat cp[3]; - - mat->type = MATRIX_3D; - - /* Check for scale */ - if (SQ(c1-c2) < SQ(1e-6) && SQ(c1-c3) < SQ(1e-6)) { - if (SQ(c1-1.0) > SQ(1e-6)) - mat->flags |= MAT_FLAG_UNIFORM_SCALE; - /* else no scale at all */ - } - else { - mat->flags |= MAT_FLAG_GENERAL_SCALE; - } - - /* Check for rotation */ - if (SQ(d1) < SQ(1e-6)) { - CROSS3( cp, m, m+4 ); - SUB_3V( cp, cp, (m+8) ); - if (LEN_SQUARED_3FV(cp) < SQ(1e-6)) - mat->flags |= MAT_FLAG_ROTATION; - else - mat->flags |= MAT_FLAG_GENERAL_3D; - } - else { - mat->flags |= MAT_FLAG_GENERAL_3D; /* shear, etc */ - } - } - else if ((mask & MASK_PERSPECTIVE) == MASK_PERSPECTIVE && m[11]==-1.0F) { - mat->type = MATRIX_PERSPECTIVE; - mat->flags |= MAT_FLAG_GENERAL; - } - else { - mat->type = MATRIX_GENERAL; - mat->flags |= MAT_FLAG_GENERAL; - } -} - -/** - * Analyze a matrix given that its flags are accurate. - * - * This is the more common operation, hopefully. - */ -static void analyse_from_flags( GLmatrix *mat ) -{ - const GLfloat *m = mat->m; - - if (TEST_MAT_FLAGS(mat, 0)) { - mat->type = MATRIX_IDENTITY; - } - else if (TEST_MAT_FLAGS(mat, (MAT_FLAG_TRANSLATION | - MAT_FLAG_UNIFORM_SCALE | - MAT_FLAG_GENERAL_SCALE))) { - if ( m[10]==1.0F && m[14]==0.0F ) { - mat->type = MATRIX_2D_NO_ROT; - } - else { - mat->type = MATRIX_3D_NO_ROT; - } - } - else if (TEST_MAT_FLAGS(mat, MAT_FLAGS_3D)) { - if ( m[ 8]==0.0F - && m[ 9]==0.0F - && m[2]==0.0F && m[6]==0.0F && m[10]==1.0F && m[14]==0.0F) { - mat->type = MATRIX_2D; - } - else { - mat->type = MATRIX_3D; - } - } - else if ( m[4]==0.0F && m[12]==0.0F - && m[1]==0.0F && m[13]==0.0F - && m[2]==0.0F && m[6]==0.0F - && m[3]==0.0F && m[7]==0.0F && m[11]==-1.0F && m[15]==0.0F) { - mat->type = MATRIX_PERSPECTIVE; - } - else { - mat->type = MATRIX_GENERAL; - } -} - -/** - * Analyze and update a matrix. - * - * \param mat matrix. - * - * If the matrix type is dirty then calls either analyse_from_scratch() or - * analyse_from_flags() to determine its type, according to whether the flags - * are dirty or not, respectively. If the matrix has an inverse and it's dirty - * then calls matrix_invert(). Finally clears the dirty flags. - */ -void -_math_matrix_analyse( GLmatrix *mat ) -{ - if (mat->flags & MAT_DIRTY_TYPE) { - if (mat->flags & MAT_DIRTY_FLAGS) - analyse_from_scratch( mat ); - else - analyse_from_flags( mat ); - } - - if (mat->inv && (mat->flags & MAT_DIRTY_INVERSE)) { - matrix_invert( mat ); - mat->flags &= ~MAT_DIRTY_INVERSE; - } - - mat->flags &= ~(MAT_DIRTY_FLAGS | MAT_DIRTY_TYPE); -} - -/*@}*/ - - -/** - * Test if the given matrix preserves vector lengths. - */ -GLboolean -_math_matrix_is_length_preserving( const GLmatrix *m ) -{ - return TEST_MAT_FLAGS( m, MAT_FLAGS_LENGTH_PRESERVING); -} - - -/** - * Test if the given matrix does any rotation. - * (or perhaps if the upper-left 3x3 is non-identity) - */ -GLboolean -_math_matrix_has_rotation( const GLmatrix *m ) -{ - if (m->flags & (MAT_FLAG_GENERAL | - MAT_FLAG_ROTATION | - MAT_FLAG_GENERAL_3D | - MAT_FLAG_PERSPECTIVE)) - return GL_TRUE; - else - return GL_FALSE; -} - - -GLboolean -_math_matrix_is_general_scale( const GLmatrix *m ) -{ - return (m->flags & MAT_FLAG_GENERAL_SCALE) ? GL_TRUE : GL_FALSE; -} - - -GLboolean -_math_matrix_is_dirty( const GLmatrix *m ) -{ - return (m->flags & MAT_DIRTY) ? GL_TRUE : GL_FALSE; -} - - -/**********************************************************************/ -/** \name Matrix setup */ -/*@{*/ - -/** - * Copy a matrix. - * - * \param to destination matrix. - * \param from source matrix. - * - * Copies all fields in GLmatrix, creating an inverse array if necessary. - */ -void -_math_matrix_copy( GLmatrix *to, const GLmatrix *from ) -{ - memcpy( to->m, from->m, sizeof(Identity) ); - to->flags = from->flags; - to->type = from->type; - - if (to->inv != 0) { - if (from->inv == 0) { - matrix_invert( to ); - } - else { - memcpy(to->inv, from->inv, sizeof(GLfloat)*16); - } - } -} - -/** - * Loads a matrix array into GLmatrix. - * - * \param m matrix array. - * \param mat matrix. - * - * Copies \p m into GLmatrix::m and marks the MAT_FLAG_GENERAL and MAT_DIRTY - * flags. - */ -void -_math_matrix_loadf( GLmatrix *mat, const GLfloat *m ) -{ - memcpy( mat->m, m, 16*sizeof(GLfloat) ); - mat->flags = (MAT_FLAG_GENERAL | MAT_DIRTY); -} - -/** - * Matrix constructor. - * - * \param m matrix. - * - * Initialize the GLmatrix fields. - */ -void -_math_matrix_ctr( GLmatrix *m ) -{ - m->m = (GLfloat *) _mesa_align_malloc( 16 * sizeof(GLfloat), 16 ); - if (m->m) - memcpy( m->m, Identity, sizeof(Identity) ); - m->inv = NULL; - m->type = MATRIX_IDENTITY; - m->flags = 0; -} - -/** - * Matrix destructor. - * - * \param m matrix. - * - * Frees the data in a GLmatrix. - */ -void -_math_matrix_dtr( GLmatrix *m ) -{ - if (m->m) { - _mesa_align_free( m->m ); - m->m = NULL; - } - if (m->inv) { - _mesa_align_free( m->inv ); - m->inv = NULL; - } -} - -/** - * Allocate a matrix inverse. - * - * \param m matrix. - * - * Allocates the matrix inverse, GLmatrix::inv, and sets it to Identity. - */ -void -_math_matrix_alloc_inv( GLmatrix *m ) -{ - if (!m->inv) { - m->inv = (GLfloat *) _mesa_align_malloc( 16 * sizeof(GLfloat), 16 ); - if (m->inv) - memcpy( m->inv, Identity, 16 * sizeof(GLfloat) ); - } -} - -/*@}*/ - - -/**********************************************************************/ -/** \name Matrix transpose */ -/*@{*/ - -/** - * Transpose a GLfloat matrix. - * - * \param to destination array. - * \param from source array. - */ -void -_math_transposef( GLfloat to[16], const GLfloat from[16] ) -{ - to[0] = from[0]; - to[1] = from[4]; - to[2] = from[8]; - to[3] = from[12]; - to[4] = from[1]; - to[5] = from[5]; - to[6] = from[9]; - to[7] = from[13]; - to[8] = from[2]; - to[9] = from[6]; - to[10] = from[10]; - to[11] = from[14]; - to[12] = from[3]; - to[13] = from[7]; - to[14] = from[11]; - to[15] = from[15]; -} - -/** - * Transpose a GLdouble matrix. - * - * \param to destination array. - * \param from source array. - */ -void -_math_transposed( GLdouble to[16], const GLdouble from[16] ) -{ - to[0] = from[0]; - to[1] = from[4]; - to[2] = from[8]; - to[3] = from[12]; - to[4] = from[1]; - to[5] = from[5]; - to[6] = from[9]; - to[7] = from[13]; - to[8] = from[2]; - to[9] = from[6]; - to[10] = from[10]; - to[11] = from[14]; - to[12] = from[3]; - to[13] = from[7]; - to[14] = from[11]; - to[15] = from[15]; -} - -/** - * Transpose a GLdouble matrix and convert to GLfloat. - * - * \param to destination array. - * \param from source array. - */ -void -_math_transposefd( GLfloat to[16], const GLdouble from[16] ) -{ - to[0] = (GLfloat) from[0]; - to[1] = (GLfloat) from[4]; - to[2] = (GLfloat) from[8]; - to[3] = (GLfloat) from[12]; - to[4] = (GLfloat) from[1]; - to[5] = (GLfloat) from[5]; - to[6] = (GLfloat) from[9]; - to[7] = (GLfloat) from[13]; - to[8] = (GLfloat) from[2]; - to[9] = (GLfloat) from[6]; - to[10] = (GLfloat) from[10]; - to[11] = (GLfloat) from[14]; - to[12] = (GLfloat) from[3]; - to[13] = (GLfloat) from[7]; - to[14] = (GLfloat) from[11]; - to[15] = (GLfloat) from[15]; -} - -/*@}*/ - - -/** - * Transform a 4-element row vector (1x4 matrix) by a 4x4 matrix. This - * function is used for transforming clipping plane equations and spotlight - * directions. - * Mathematically, u = v * m. - * Input: v - input vector - * m - transformation matrix - * Output: u - transformed vector - */ -void -_mesa_transform_vector( GLfloat u[4], const GLfloat v[4], const GLfloat m[16] ) -{ - const GLfloat v0 = v[0], v1 = v[1], v2 = v[2], v3 = v[3]; -#define M(row,col) m[row + col*4] - u[0] = v0 * M(0,0) + v1 * M(1,0) + v2 * M(2,0) + v3 * M(3,0); - u[1] = v0 * M(0,1) + v1 * M(1,1) + v2 * M(2,1) + v3 * M(3,1); - u[2] = v0 * M(0,2) + v1 * M(1,2) + v2 * M(2,2) + v3 * M(3,2); - u[3] = v0 * M(0,3) + v1 * M(1,3) + v2 * M(2,3) + v3 * M(3,3); -#undef M -} diff --git a/dll/opengl/mesa/math/m_matrix.h b/dll/opengl/mesa/math/m_matrix.h deleted file mode 100644 index e8e48aab75a..00000000000 --- a/dll/opengl/mesa/math/m_matrix.h +++ /dev/null @@ -1,221 +0,0 @@ -/* - * Mesa 3-D graphics library - * Version: 6.3 - * - * Copyright (C) 1999-2005 Brian Paul All Rights Reserved. - * - * Permission is hereby granted, free of charge, to any person obtaining a - * copy of this software and associated documentation files (the "Software"), - * to deal in the Software without restriction, including without limitation - * the rights to use, copy, modify, merge, publish, distribute, sublicense, - * and/or sell copies of the Software, and to permit persons to whom the - * Software is furnished to do so, subject to the following conditions: - * - * The above copyright notice and this permission notice shall be included - * in all copies or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS - * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL - * BRIAN PAUL BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN - * AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN - * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. - */ - - -/** - * \file math/m_matrix.h - * Defines basic structures for matrix-handling. - */ - -#ifndef _M_MATRIX_H -#define _M_MATRIX_H - - -#include "main/glheader.h" - - -#ifdef __cplusplus -extern "C" { -#endif - - -/** - * \name Symbolic names to some of the entries in the matrix - * - * These are handy for the viewport mapping, which is expressed as a matrix. - */ -/*@{*/ -#define MAT_SX 0 -#define MAT_SY 5 -#define MAT_SZ 10 -#define MAT_TX 12 -#define MAT_TY 13 -#define MAT_TZ 14 -/*@}*/ - - -/** - * Different kinds of 4x4 transformation matrices. - * We use these to select specific optimized vertex transformation routines. - */ -enum GLmatrixtype { - MATRIX_GENERAL, /**< general 4x4 matrix */ - MATRIX_IDENTITY, /**< identity matrix */ - MATRIX_3D_NO_ROT, /**< orthogonal projection and others... */ - MATRIX_PERSPECTIVE, /**< perspective projection matrix */ - MATRIX_2D, /**< 2-D transformation */ - MATRIX_2D_NO_ROT, /**< 2-D scale & translate only */ - MATRIX_3D /**< 3-D transformation */ -} ; - -/** - * Matrix type to represent 4x4 transformation matrices. - */ -typedef struct { - GLfloat *m; /**< 16 matrix elements (16-byte aligned) */ - GLfloat *inv; /**< optional 16-element inverse (16-byte aligned) */ - GLuint flags; /**< possible values determined by (of \link - * MatFlags MAT_FLAG_* flags\endlink) - */ - enum GLmatrixtype type; -} GLmatrix; - - - - -extern void -_math_matrix_ctr( GLmatrix *m ); - -extern void -_math_matrix_dtr( GLmatrix *m ); - -extern void -_math_matrix_alloc_inv( GLmatrix *m ); - -extern void -_math_matrix_mul_matrix( GLmatrix *dest, const GLmatrix *a, const GLmatrix *b ); - -extern void -_math_matrix_mul_floats( GLmatrix *dest, const GLfloat *b ); - -extern void -_math_matrix_loadf( GLmatrix *mat, const GLfloat *m ); - -extern void -_math_matrix_translate( GLmatrix *mat, GLfloat x, GLfloat y, GLfloat z ); - -extern void -_math_matrix_rotate( GLmatrix *m, GLfloat angle, - GLfloat x, GLfloat y, GLfloat z ); - -extern void -_math_matrix_scale( GLmatrix *mat, GLfloat x, GLfloat y, GLfloat z ); - -extern void -_math_matrix_ortho( GLmatrix *mat, - GLfloat left, GLfloat right, - GLfloat bottom, GLfloat top, - GLfloat nearval, GLfloat farval ); - -extern void -_math_matrix_frustum( GLmatrix *mat, - GLfloat left, GLfloat right, - GLfloat bottom, GLfloat top, - GLfloat nearval, GLfloat farval ); - -extern void -_math_matrix_viewport(GLmatrix *m, GLint x, GLint y, GLint width, GLint height, - GLfloat zNear, GLfloat zFar, GLfloat depthMax); - -extern void -_math_matrix_set_identity( GLmatrix *dest ); - -extern void -_math_matrix_copy( GLmatrix *to, const GLmatrix *from ); - -extern void -_math_matrix_analyse( GLmatrix *mat ); - -extern void -_math_matrix_print( const GLmatrix *m ); - -extern GLboolean -_math_matrix_is_length_preserving( const GLmatrix *m ); - -extern GLboolean -_math_matrix_has_rotation( const GLmatrix *m ); - -extern GLboolean -_math_matrix_is_general_scale( const GLmatrix *m ); - -extern GLboolean -_math_matrix_is_dirty( const GLmatrix *m ); - - -/** - * \name Related functions that don't actually operate on GLmatrix structs - */ -/*@{*/ - -extern void -_math_transposef( GLfloat to[16], const GLfloat from[16] ); - -extern void -_math_transposed( GLdouble to[16], const GLdouble from[16] ); - -extern void -_math_transposefd( GLfloat to[16], const GLdouble from[16] ); - - -/* - * Transform a point (column vector) by a matrix: Q = M * P - */ -#define TRANSFORM_POINT( Q, M, P ) \ - Q[0] = M[0] * P[0] + M[4] * P[1] + M[8] * P[2] + M[12] * P[3]; \ - Q[1] = M[1] * P[0] + M[5] * P[1] + M[9] * P[2] + M[13] * P[3]; \ - Q[2] = M[2] * P[0] + M[6] * P[1] + M[10] * P[2] + M[14] * P[3]; \ - Q[3] = M[3] * P[0] + M[7] * P[1] + M[11] * P[2] + M[15] * P[3]; - - -#define TRANSFORM_POINT3( Q, M, P ) \ - Q[0] = M[0] * P[0] + M[4] * P[1] + M[8] * P[2] + M[12]; \ - Q[1] = M[1] * P[0] + M[5] * P[1] + M[9] * P[2] + M[13]; \ - Q[2] = M[2] * P[0] + M[6] * P[1] + M[10] * P[2] + M[14]; \ - Q[3] = M[3] * P[0] + M[7] * P[1] + M[11] * P[2] + M[15]; - - -/* - * Transform a normal (row vector) by a matrix: [NX NY NZ] = N * MAT - */ -#define TRANSFORM_NORMAL( TO, N, MAT ) \ -do { \ - TO[0] = N[0] * MAT[0] + N[1] * MAT[1] + N[2] * MAT[2]; \ - TO[1] = N[0] * MAT[4] + N[1] * MAT[5] + N[2] * MAT[6]; \ - TO[2] = N[0] * MAT[8] + N[1] * MAT[9] + N[2] * MAT[10]; \ -} while (0) - - -/** - * Transform a direction by a matrix. - */ -#define TRANSFORM_DIRECTION( TO, DIR, MAT ) \ -do { \ - TO[0] = DIR[0] * MAT[0] + DIR[1] * MAT[4] + DIR[2] * MAT[8]; \ - TO[1] = DIR[0] * MAT[1] + DIR[1] * MAT[5] + DIR[2] * MAT[9]; \ - TO[2] = DIR[0] * MAT[2] + DIR[1] * MAT[6] + DIR[2] * MAT[10];\ -} while (0) - - -extern void -_mesa_transform_vector(GLfloat u[4], const GLfloat v[4], const GLfloat m[16]); - - -/*@}*/ - - -#ifdef __cplusplus -} -#endif - -#endif diff --git a/dll/opengl/mesa/math/m_norm_tmp.h b/dll/opengl/mesa/math/m_norm_tmp.h deleted file mode 100644 index a20cb05017d..00000000000 --- a/dll/opengl/mesa/math/m_norm_tmp.h +++ /dev/null @@ -1,390 +0,0 @@ - -/* - * Mesa 3-D graphics library - * Version: 5.1 - * - * Copyright (C) 1999-2003 Brian Paul All Rights Reserved. - * - * Permission is hereby granted, free of charge, to any person obtaining a - * copy of this software and associated documentation files (the "Software"), - * to deal in the Software without restriction, including without limitation - * the rights to use, copy, modify, merge, publish, distribute, sublicense, - * and/or sell copies of the Software, and to permit persons to whom the - * Software is furnished to do so, subject to the following conditions: - * - * The above copyright notice and this permission notice shall be included - * in all copies or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS - * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL - * BRIAN PAUL BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN - * AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN - * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. - */ - -/* - * New (3.1) transformation code written by Keith Whitwell. - */ - -/* Functions to tranform a vector of normals. This includes applying - * the transformation matrix, rescaling and normalization. - */ - -/* - * mat - the 4x4 transformation matrix - * scale - uniform scale factor of the transformation matrix (not always used) - * in - the source vector of normals - * lengths - length of each incoming normal (may be NULL) (a display list - * optimization) - * dest - the destination vector of normals - */ -static void _XFORMAPI -TAG(transform_normalize_normals)( const GLmatrix *mat, - GLfloat scale, - const GLvector4f *in, - const GLfloat *lengths, - GLvector4f *dest ) -{ - GLfloat (*out)[4] = (GLfloat (*)[4])dest->start; - const GLfloat *from = in->start; - const GLuint stride = in->stride; - const GLuint count = in->count; - const GLfloat *m = mat->inv; - GLfloat m0 = m[0], m4 = m[4], m8 = m[8]; - GLfloat m1 = m[1], m5 = m[5], m9 = m[9]; - GLfloat m2 = m[2], m6 = m[6], m10 = m[10]; - GLuint i; - - if (!lengths) { - STRIDE_LOOP { - GLfloat tx, ty, tz; - { - const GLfloat ux = from[0], uy = from[1], uz = from[2]; - tx = ux * m0 + uy * m1 + uz * m2; - ty = ux * m4 + uy * m5 + uz * m6; - tz = ux * m8 + uy * m9 + uz * m10; - } - { - GLdouble len = tx*tx + ty*ty + tz*tz; - if (len > 1e-20) { - GLfloat scale = INV_SQRTF(len); - out[i][0] = tx * scale; - out[i][1] = ty * scale; - out[i][2] = tz * scale; - } - else { - out[i][0] = out[i][1] = out[i][2] = 0; - } - } - } - } - else { - if (scale != 1.0) { - m0 *= scale, m4 *= scale, m8 *= scale; - m1 *= scale, m5 *= scale, m9 *= scale; - m2 *= scale, m6 *= scale, m10 *= scale; - } - - STRIDE_LOOP { - GLfloat tx, ty, tz; - { - const GLfloat ux = from[0], uy = from[1], uz = from[2]; - tx = ux * m0 + uy * m1 + uz * m2; - ty = ux * m4 + uy * m5 + uz * m6; - tz = ux * m8 + uy * m9 + uz * m10; - } - { - GLfloat len = lengths[i]; - out[i][0] = tx * len; - out[i][1] = ty * len; - out[i][2] = tz * len; - } - } - } - dest->count = in->count; -} - - -static void _XFORMAPI -TAG(transform_normalize_normals_no_rot)( const GLmatrix *mat, - GLfloat scale, - const GLvector4f *in, - const GLfloat *lengths, - GLvector4f *dest ) -{ - GLfloat (*out)[4] = (GLfloat (*)[4])dest->start; - const GLfloat *from = in->start; - const GLuint stride = in->stride; - const GLuint count = in->count; - const GLfloat *m = mat->inv; - GLfloat m0 = m[0]; - GLfloat m5 = m[5]; - GLfloat m10 = m[10]; - GLuint i; - - if (!lengths) { - STRIDE_LOOP { - GLfloat tx, ty, tz; - { - const GLfloat ux = from[0], uy = from[1], uz = from[2]; - tx = ux * m0 ; - ty = uy * m5 ; - tz = uz * m10; - } - { - GLdouble len = tx*tx + ty*ty + tz*tz; - if (len > 1e-20) { - GLfloat scale = INV_SQRTF(len); - out[i][0] = tx * scale; - out[i][1] = ty * scale; - out[i][2] = tz * scale; - } - else { - out[i][0] = out[i][1] = out[i][2] = 0; - } - } - } - } - else { - m0 *= scale; - m5 *= scale; - m10 *= scale; - - STRIDE_LOOP { - GLfloat tx, ty, tz; - { - const GLfloat ux = from[0], uy = from[1], uz = from[2]; - tx = ux * m0 ; - ty = uy * m5 ; - tz = uz * m10; - } - { - GLfloat len = lengths[i]; - out[i][0] = tx * len; - out[i][1] = ty * len; - out[i][2] = tz * len; - } - } - } - dest->count = in->count; -} - - -static void _XFORMAPI -TAG(transform_rescale_normals_no_rot)( const GLmatrix *mat, - GLfloat scale, - const GLvector4f *in, - const GLfloat *lengths, - GLvector4f *dest ) -{ - GLfloat (*out)[4] = (GLfloat (*)[4])dest->start; - const GLfloat *from = in->start; - const GLuint stride = in->stride; - const GLuint count = in->count; - const GLfloat *m = mat->inv; - const GLfloat m0 = scale*m[0]; - const GLfloat m5 = scale*m[5]; - const GLfloat m10 = scale*m[10]; - GLuint i; - - (void) lengths; - - STRIDE_LOOP { - GLfloat ux = from[0], uy = from[1], uz = from[2]; - out[i][0] = ux * m0; - out[i][1] = uy * m5; - out[i][2] = uz * m10; - } - dest->count = in->count; -} - - -static void _XFORMAPI -TAG(transform_rescale_normals)( const GLmatrix *mat, - GLfloat scale, - const GLvector4f *in, - const GLfloat *lengths, - GLvector4f *dest ) -{ - GLfloat (*out)[4] = (GLfloat (*)[4])dest->start; - const GLfloat *from = in->start; - const GLuint stride = in->stride; - const GLuint count = in->count; - /* Since we are unlikely to have < 3 vertices in the buffer, - * it makes sense to pre-multiply by scale. - */ - const GLfloat *m = mat->inv; - const GLfloat m0 = scale*m[0], m4 = scale*m[4], m8 = scale*m[8]; - const GLfloat m1 = scale*m[1], m5 = scale*m[5], m9 = scale*m[9]; - const GLfloat m2 = scale*m[2], m6 = scale*m[6], m10 = scale*m[10]; - GLuint i; - - (void) lengths; - - STRIDE_LOOP { - GLfloat ux = from[0], uy = from[1], uz = from[2]; - out[i][0] = ux * m0 + uy * m1 + uz * m2; - out[i][1] = ux * m4 + uy * m5 + uz * m6; - out[i][2] = ux * m8 + uy * m9 + uz * m10; - } - dest->count = in->count; -} - - -static void _XFORMAPI -TAG(transform_normals_no_rot)( const GLmatrix *mat, - GLfloat scale, - const GLvector4f *in, - const GLfloat *lengths, - GLvector4f *dest ) -{ - GLfloat (*out)[4] = (GLfloat (*)[4])dest->start; - const GLfloat *from = in->start; - const GLuint stride = in->stride; - const GLuint count = in->count; - const GLfloat *m = mat->inv; - const GLfloat m0 = m[0]; - const GLfloat m5 = m[5]; - const GLfloat m10 = m[10]; - GLuint i; - - (void) scale; - (void) lengths; - - STRIDE_LOOP { - GLfloat ux = from[0], uy = from[1], uz = from[2]; - out[i][0] = ux * m0; - out[i][1] = uy * m5; - out[i][2] = uz * m10; - } - dest->count = in->count; -} - - -static void _XFORMAPI -TAG(transform_normals)( const GLmatrix *mat, - GLfloat scale, - const GLvector4f *in, - const GLfloat *lengths, - GLvector4f *dest ) -{ - GLfloat (*out)[4] = (GLfloat (*)[4])dest->start; - const GLfloat *from = in->start; - const GLuint stride = in->stride; - const GLuint count = in->count; - const GLfloat *m = mat->inv; - const GLfloat m0 = m[0], m4 = m[4], m8 = m[8]; - const GLfloat m1 = m[1], m5 = m[5], m9 = m[9]; - const GLfloat m2 = m[2], m6 = m[6], m10 = m[10]; - GLuint i; - - (void) scale; - (void) lengths; - - STRIDE_LOOP { - GLfloat ux = from[0], uy = from[1], uz = from[2]; - out[i][0] = ux * m0 + uy * m1 + uz * m2; - out[i][1] = ux * m4 + uy * m5 + uz * m6; - out[i][2] = ux * m8 + uy * m9 + uz * m10; - } - dest->count = in->count; -} - - -static void _XFORMAPI -TAG(normalize_normals)( const GLmatrix *mat, - GLfloat scale, - const GLvector4f *in, - const GLfloat *lengths, - GLvector4f *dest ) -{ - GLfloat (*out)[4] = (GLfloat (*)[4])dest->start; - const GLfloat *from = in->start; - const GLuint stride = in->stride; - const GLuint count = in->count; - GLuint i; - - (void) mat; - (void) scale; - - if (lengths) { - STRIDE_LOOP { - const GLfloat x = from[0], y = from[1], z = from[2]; - GLfloat invlen = lengths[i]; - out[i][0] = x * invlen; - out[i][1] = y * invlen; - out[i][2] = z * invlen; - } - } - else { - STRIDE_LOOP { - const GLfloat x = from[0], y = from[1], z = from[2]; - GLdouble len = x * x + y * y + z * z; - if (len > 1e-50) { - len = INV_SQRTF(len); - out[i][0] = (GLfloat)(x * len); - out[i][1] = (GLfloat)(y * len); - out[i][2] = (GLfloat)(z * len); - } - else { - out[i][0] = x; - out[i][1] = y; - out[i][2] = z; - } - } - } - dest->count = in->count; -} - - -static void _XFORMAPI -TAG(rescale_normals)( const GLmatrix *mat, - GLfloat scale, - const GLvector4f *in, - const GLfloat *lengths, - GLvector4f *dest ) -{ - GLfloat (*out)[4] = (GLfloat (*)[4])dest->start; - const GLfloat *from = in->start; - const GLuint stride = in->stride; - const GLuint count = in->count; - GLuint i; - - (void) mat; - (void) lengths; - - STRIDE_LOOP { - SCALE_SCALAR_3V( out[i], scale, from ); - } - dest->count = in->count; -} - - -static void _XFORMAPI -TAG(init_c_norm_transform)( void ) -{ - _mesa_normal_tab[NORM_TRANSFORM_NO_ROT] = - TAG(transform_normals_no_rot); - - _mesa_normal_tab[NORM_TRANSFORM_NO_ROT | NORM_RESCALE] = - TAG(transform_rescale_normals_no_rot); - - _mesa_normal_tab[NORM_TRANSFORM_NO_ROT | NORM_NORMALIZE] = - TAG(transform_normalize_normals_no_rot); - - _mesa_normal_tab[NORM_TRANSFORM] = - TAG(transform_normals); - - _mesa_normal_tab[NORM_TRANSFORM | NORM_RESCALE] = - TAG(transform_rescale_normals); - - _mesa_normal_tab[NORM_TRANSFORM | NORM_NORMALIZE] = - TAG(transform_normalize_normals); - - _mesa_normal_tab[NORM_RESCALE] = - TAG(rescale_normals); - - _mesa_normal_tab[NORM_NORMALIZE] = - TAG(normalize_normals); -} diff --git a/dll/opengl/mesa/math/m_trans_tmp.h b/dll/opengl/mesa/math/m_trans_tmp.h deleted file mode 100644 index 08fb4d1e9c4..00000000000 --- a/dll/opengl/mesa/math/m_trans_tmp.h +++ /dev/null @@ -1,281 +0,0 @@ -/* - * Mesa 3-D graphics library - * Version: 6.5.1 - * - * Copyright (C) 1999-2006 Brian Paul All Rights Reserved. - * - * Permission is hereby granted, free of charge, to any person obtaining a - * copy of this software and associated documentation files (the "Software"), - * to deal in the Software without restriction, including without limitation - * the rights to use, copy, modify, merge, publish, distribute, sublicense, - * and/or sell copies of the Software, and to permit persons to whom the - * Software is furnished to do so, subject to the following conditions: - * - * The above copyright notice and this permission notice shall be included - * in all copies or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS - * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL - * BRIAN PAUL BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN - * AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN - * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. - */ - -/** - * \brief Templates for vector conversions. - * \author Keith Whitwell. - */ - -#ifdef DEST_4F -static void DEST_4F( GLfloat (*t)[4], - CONST void *ptr, - GLuint stride, - ARGS ) -{ - const GLubyte *f = (GLubyte *) ptr + SRC_START * stride; - const GLubyte *first = f; - GLuint i; - - (void) first; - (void) start; - for (i = DST_START ; i < n ; i++, NEXT_F) { - CHECK { - NEXT_F2; - if (SZ >= 1) t[i][0] = TRX_4F(f, 0); - if (SZ >= 2) t[i][1] = TRX_4F(f, 1); - if (SZ >= 3) t[i][2] = TRX_4F(f, 2); - if (SZ == 4) t[i][3] = TRX_4F(f, 3); else t[i][3] = 1.0; - } - } -} -#endif - - - -#ifdef DEST_4FN -static void DEST_4FN( GLfloat (*t)[4], - CONST void *ptr, - GLuint stride, - ARGS ) -{ - const GLubyte *f = (GLubyte *) ptr + SRC_START * stride; - const GLubyte *first = f; - GLuint i; - - (void) first; - (void) start; - for (i = DST_START ; i < n ; i++, NEXT_F) { - CHECK { - NEXT_F2; - if (SZ >= 1) t[i][0] = TRX_4FN(f, 0); - if (SZ >= 2) t[i][1] = TRX_4FN(f, 1); - if (SZ >= 3) t[i][2] = TRX_4FN(f, 2); - if (SZ == 4) t[i][3] = TRX_4FN(f, 3); else t[i][3] = 1.0; - } - } -} -#endif - - -#ifdef DEST_3FN -static void DEST_3FN( GLfloat (*t)[3], - CONST void *ptr, - GLuint stride, - ARGS ) -{ - const GLubyte *f = (GLubyte *) ptr + SRC_START * stride; - const GLubyte *first = f; - GLuint i; - (void) first; - (void) start; - for (i = DST_START ; i < n ; i++, NEXT_F) { - CHECK { - NEXT_F2; - t[i][0] = TRX_3FN(f, 0); - t[i][1] = TRX_3FN(f, 1); - t[i][2] = TRX_3FN(f, 2); - } - } -} -#endif - -#ifdef DEST_1F -static void DEST_1F( GLfloat *t, - CONST void *ptr, - GLuint stride, - ARGS ) -{ - const GLubyte *f = (GLubyte *) ptr + SRC_START * stride; - const GLubyte *first = f; - GLuint i; - (void) first; - (void) start; - for (i = DST_START ; i < n ; i++, NEXT_F) { - CHECK { - NEXT_F2; - t[i] = TRX_1F(f, 0); - } - } -} -#endif - -#ifdef DEST_4UB -static void DEST_4UB( GLubyte (*t)[4], - CONST void *ptr, - GLuint stride, - ARGS ) -{ - const GLubyte *f = (GLubyte *) ptr + SRC_START * stride; - const GLubyte *first = f; - GLuint i; - (void) start; - (void) first; - for (i = DST_START ; i < n ; i++, NEXT_F) { - CHECK { - NEXT_F2; - if (SZ >= 1) TRX_UB(t[i][0], f, 0); - if (SZ >= 2) TRX_UB(t[i][1], f, 1); - if (SZ >= 3) TRX_UB(t[i][2], f, 2); - if (SZ == 4) TRX_UB(t[i][3], f, 3); else t[i][3] = 255; - } - } -} -#endif - - -#ifdef DEST_4US -static void DEST_4US( GLushort (*t)[4], - CONST void *ptr, - GLuint stride, - ARGS ) -{ - const GLubyte *f = (GLubyte *) ((GLubyte *) ptr + SRC_START * stride); - const GLubyte *first = f; - GLuint i; - (void) start; - (void) first; - for (i = DST_START ; i < n ; i++, NEXT_F) { - CHECK { - NEXT_F2; - if (SZ >= 1) TRX_US(t[i][0], f, 0); - if (SZ >= 2) TRX_US(t[i][1], f, 1); - if (SZ >= 3) TRX_US(t[i][2], f, 2); - if (SZ == 4) TRX_US(t[i][3], f, 3); else t[i][3] = 65535; - } - } -} -#endif - - -#ifdef DEST_1UB -static void DEST_1UB( GLubyte *t, - CONST void *ptr, - GLuint stride, - ARGS ) -{ - const GLubyte *f = (GLubyte *) ptr + SRC_START * stride; - const GLubyte *first = f; - GLuint i; - (void) start; - (void) first; - for (i = DST_START ; i < n ; i++, NEXT_F) { - CHECK { - NEXT_F2; - TRX_UB(t[i], f, 0); - } - } -} -#endif - - -#ifdef DEST_1UI -static void DEST_1UI( GLuint *t, - CONST void *ptr, - GLuint stride, - ARGS ) -{ - const GLubyte *f = (GLubyte *) ptr + SRC_START * stride; - const GLubyte *first = f; - GLuint i; - (void) start; - (void) first; - - for (i = DST_START ; i < n ; i++, NEXT_F) { - CHECK { - NEXT_F2; - t[i] = TRX_UI(f, 0); - } - } -} -#endif - - -static void INIT(void) -{ -#ifdef DEST_1UI - ASSERT(SZ == 1); - TAB(_1ui)[SRC_IDX] = DEST_1UI; -#endif -#ifdef DEST_1UB - ASSERT(SZ == 1); - TAB(_1ub)[SRC_IDX] = DEST_1UB; -#endif -#ifdef DEST_1F - ASSERT(SZ == 1); - TAB(_1f)[SRC_IDX] = DEST_1F; -#endif -#ifdef DEST_3FN - ASSERT(SZ == 3); - TAB(_3fn)[SRC_IDX] = DEST_3FN; -#endif -#ifdef DEST_4UB - TAB(_4ub)[SZ][SRC_IDX] = DEST_4UB; -#endif -#ifdef DEST_4US - TAB(_4us)[SZ][SRC_IDX] = DEST_4US; -#endif -#ifdef DEST_4F - TAB(_4f)[SZ][SRC_IDX] = DEST_4F; -#endif -#ifdef DEST_4FN - TAB(_4fn)[SZ][SRC_IDX] = DEST_4FN; -#endif - -} - - -#ifdef INIT -#undef INIT -#endif -#ifdef DEST_1UI -#undef DEST_1UI -#endif -#ifdef DEST_1UB -#undef DEST_1UB -#endif -#ifdef DEST_4UB -#undef DEST_4UB -#endif -#ifdef DEST_4US -#undef DEST_4US -#endif -#ifdef DEST_3FN -#undef DEST_3FN -#endif -#ifdef DEST_4F -#undef DEST_4F -#endif -#ifdef DEST_4FN -#undef DEST_4FN -#endif -#ifdef DEST_1F -#undef DEST_1F -#endif -#ifdef SZ -#undef SZ -#endif -#ifdef TAG -#undef TAG -#endif - diff --git a/dll/opengl/mesa/math/m_translate.c b/dll/opengl/mesa/math/m_translate.c deleted file mode 100644 index 8bad65f2256..00000000000 --- a/dll/opengl/mesa/math/m_translate.c +++ /dev/null @@ -1,747 +0,0 @@ -/* - * Mesa 3-D graphics library - * Version: 6.5.1 - * - * Copyright (C) 1999-2006 Brian Paul All Rights Reserved. - * - * Permission is hereby granted, free of charge, to any person obtaining a - * copy of this software and associated documentation files (the "Software"), - * to deal in the Software without restriction, including without limitation - * the rights to use, copy, modify, merge, publish, distribute, sublicense, - * and/or sell copies of the Software, and to permit persons to whom the - * Software is furnished to do so, subject to the following conditions: - * - * The above copyright notice and this permission notice shall be included - * in all copies or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS - * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL - * BRIAN PAUL BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN - * AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN - * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. - */ - -/** - * \brief Translate vectors of numbers between various types. - * \author Keith Whitwell. - */ - - -#include - -#include "main/mtypes.h" /* GLchan hack */ - -typedef void (*trans_1f_func)(GLfloat *to, - CONST void *ptr, - GLuint stride, - GLuint start, - GLuint n ); - -typedef void (*trans_1ui_func)(GLuint *to, - CONST void *ptr, - GLuint stride, - GLuint start, - GLuint n ); - -typedef void (*trans_1ub_func)(GLubyte *to, - CONST void *ptr, - GLuint stride, - GLuint start, - GLuint n ); - -typedef void (*trans_4ub_func)(GLubyte (*to)[4], - CONST void *ptr, - GLuint stride, - GLuint start, - GLuint n ); - -typedef void (*trans_4us_func)(GLushort (*to)[4], - CONST void *ptr, - GLuint stride, - GLuint start, - GLuint n ); - -typedef void (*trans_4f_func)(GLfloat (*to)[4], - CONST void *ptr, - GLuint stride, - GLuint start, - GLuint n ); - -typedef void (*trans_3fn_func)(GLfloat (*to)[3], - CONST void *ptr, - GLuint stride, - GLuint start, - GLuint n ); - - - - -#define TYPE_IDX(t) ((t) & 0xf) -#define MAX_TYPES TYPE_IDX(GL_DOUBLE)+1 /* 0xa + 1 */ - - -/* This macro is used on other systems, so undefine it for this module */ - -#undef CHECK - -static trans_1f_func _math_trans_1f_tab[MAX_TYPES]; -static trans_1ui_func _math_trans_1ui_tab[MAX_TYPES]; -static trans_1ub_func _math_trans_1ub_tab[MAX_TYPES]; -static trans_3fn_func _math_trans_3fn_tab[MAX_TYPES]; -static trans_4ub_func _math_trans_4ub_tab[5][MAX_TYPES]; -static trans_4us_func _math_trans_4us_tab[5][MAX_TYPES]; -static trans_4f_func _math_trans_4f_tab[5][MAX_TYPES]; -static trans_4f_func _math_trans_4fn_tab[5][MAX_TYPES]; - - -#define PTR_ELT(ptr, elt) (((SRC *)ptr)[elt]) - - -#define TAB(x) _math_trans##x##_tab -#define ARGS GLuint start, GLuint n -#define SRC_START start -#define DST_START 0 -#define STRIDE stride -#define NEXT_F f += stride -#define NEXT_F2 -#define CHECK - - - - -/** - * Translate from GL_BYTE. - */ -#define SRC GLbyte -#define SRC_IDX TYPE_IDX(GL_BYTE) -#define TRX_3FN(f,n) BYTE_TO_FLOAT( PTR_ELT(f,n) ) -#if 1 -#define TRX_4F(f,n) BYTE_TO_FLOAT( PTR_ELT(f,n) ) -#else -#define TRX_4F(f,n) (GLfloat)( PTR_ELT(f,n) ) -#endif -#define TRX_4FN(f,n) BYTE_TO_FLOAT( PTR_ELT(f,n) ) -#define TRX_UB(ub, f,n) ub = BYTE_TO_UBYTE( PTR_ELT(f,n) ) -#define TRX_US(ch, f,n) ch = BYTE_TO_USHORT( PTR_ELT(f,n) ) -#define TRX_UI(f,n) (PTR_ELT(f,n) < 0 ? 0 : (GLuint) PTR_ELT(f,n)) - - -#define SZ 4 -#define INIT init_trans_4_GLbyte_raw -#define DEST_4F trans_4_GLbyte_4f_raw -#define DEST_4FN trans_4_GLbyte_4fn_raw -#define DEST_4UB trans_4_GLbyte_4ub_raw -#define DEST_4US trans_4_GLbyte_4us_raw -#include "m_trans_tmp.h" - -#define SZ 3 -#define INIT init_trans_3_GLbyte_raw -#define DEST_4F trans_3_GLbyte_4f_raw -#define DEST_4FN trans_3_GLbyte_4fn_raw -#define DEST_4UB trans_3_GLbyte_4ub_raw -#define DEST_4US trans_3_GLbyte_4us_raw -#define DEST_3FN trans_3_GLbyte_3fn_raw -#include "m_trans_tmp.h" - -#define SZ 2 -#define INIT init_trans_2_GLbyte_raw -#define DEST_4F trans_2_GLbyte_4f_raw -#define DEST_4FN trans_2_GLbyte_4fn_raw -#include "m_trans_tmp.h" - -#define SZ 1 -#define INIT init_trans_1_GLbyte_raw -#define DEST_4F trans_1_GLbyte_4f_raw -#define DEST_4FN trans_1_GLbyte_4fn_raw -#define DEST_1UB trans_1_GLbyte_1ub_raw -#define DEST_1UI trans_1_GLbyte_1ui_raw -#include "m_trans_tmp.h" - -#undef SRC -#undef TRX_3FN -#undef TRX_4F -#undef TRX_4FN -#undef TRX_UB -#undef TRX_US -#undef TRX_UI -#undef SRC_IDX - - -/** - * Translate from GL_UNSIGNED_BYTE. - */ -#define SRC GLubyte -#define SRC_IDX TYPE_IDX(GL_UNSIGNED_BYTE) -#define TRX_3FN(f,n) UBYTE_TO_FLOAT(PTR_ELT(f,n)) -#define TRX_4F(f,n) (GLfloat)( PTR_ELT(f,n) ) -#define TRX_4FN(f,n) UBYTE_TO_FLOAT(PTR_ELT(f,n)) -#define TRX_UB(ub, f,n) ub = PTR_ELT(f,n) -#define TRX_US(us, f,n) us = UBYTE_TO_USHORT(PTR_ELT(f,n)) -#define TRX_UI(f,n) (GLuint)PTR_ELT(f,n) - -/* 4ub->4ub handled in special case below. - */ -#define SZ 4 -#define INIT init_trans_4_GLubyte_raw -#define DEST_4F trans_4_GLubyte_4f_raw -#define DEST_4FN trans_4_GLubyte_4fn_raw -#define DEST_4US trans_4_GLubyte_4us_raw -#include "m_trans_tmp.h" - - -#define SZ 3 -#define INIT init_trans_3_GLubyte_raw -#define DEST_4UB trans_3_GLubyte_4ub_raw -#define DEST_4US trans_3_GLubyte_4us_raw -#define DEST_3FN trans_3_GLubyte_3fn_raw -#define DEST_4F trans_3_GLubyte_4f_raw -#define DEST_4FN trans_3_GLubyte_4fn_raw -#include "m_trans_tmp.h" - - -#define SZ 1 -#define INIT init_trans_1_GLubyte_raw -#define DEST_1UI trans_1_GLubyte_1ui_raw -#define DEST_1UB trans_1_GLubyte_1ub_raw -#include "m_trans_tmp.h" - -#undef SRC -#undef SRC_IDX -#undef TRX_3FN -#undef TRX_4F -#undef TRX_4FN -#undef TRX_UB -#undef TRX_US -#undef TRX_UI - - -/* GL_SHORT - */ -#define SRC GLshort -#define SRC_IDX TYPE_IDX(GL_SHORT) -#define TRX_3FN(f,n) SHORT_TO_FLOAT( PTR_ELT(f,n) ) -#define TRX_4F(f,n) (GLfloat)( PTR_ELT(f,n) ) -#define TRX_4FN(f,n) SHORT_TO_FLOAT( PTR_ELT(f,n) ) -#define TRX_UB(ub, f,n) ub = SHORT_TO_UBYTE(PTR_ELT(f,n)) -#define TRX_US(us, f,n) us = SHORT_TO_USHORT(PTR_ELT(f,n)) -#define TRX_UI(f,n) (PTR_ELT(f,n) < 0 ? 0 : (GLuint) PTR_ELT(f,n)) - - -#define SZ 4 -#define INIT init_trans_4_GLshort_raw -#define DEST_4F trans_4_GLshort_4f_raw -#define DEST_4FN trans_4_GLshort_4fn_raw -#define DEST_4UB trans_4_GLshort_4ub_raw -#define DEST_4US trans_4_GLshort_4us_raw -#include "m_trans_tmp.h" - -#define SZ 3 -#define INIT init_trans_3_GLshort_raw -#define DEST_4F trans_3_GLshort_4f_raw -#define DEST_4FN trans_3_GLshort_4fn_raw -#define DEST_4UB trans_3_GLshort_4ub_raw -#define DEST_4US trans_3_GLshort_4us_raw -#define DEST_3FN trans_3_GLshort_3fn_raw -#include "m_trans_tmp.h" - -#define SZ 2 -#define INIT init_trans_2_GLshort_raw -#define DEST_4F trans_2_GLshort_4f_raw -#define DEST_4FN trans_2_GLshort_4fn_raw -#include "m_trans_tmp.h" - -#define SZ 1 -#define INIT init_trans_1_GLshort_raw -#define DEST_4F trans_1_GLshort_4f_raw -#define DEST_4FN trans_1_GLshort_4fn_raw -#define DEST_1UB trans_1_GLshort_1ub_raw -#define DEST_1UI trans_1_GLshort_1ui_raw -#include "m_trans_tmp.h" - - -#undef SRC -#undef SRC_IDX -#undef TRX_3FN -#undef TRX_4F -#undef TRX_4FN -#undef TRX_UB -#undef TRX_US -#undef TRX_UI - - -/* GL_UNSIGNED_SHORT - */ -#define SRC GLushort -#define SRC_IDX TYPE_IDX(GL_UNSIGNED_SHORT) -#define TRX_3FN(f,n) USHORT_TO_FLOAT( PTR_ELT(f,n) ) -#define TRX_4F(f,n) (GLfloat)( PTR_ELT(f,n) ) -#define TRX_4FN(f,n) USHORT_TO_FLOAT( PTR_ELT(f,n) ) -#define TRX_UB(ub,f,n) ub = (GLubyte) (PTR_ELT(f,n) >> 8) -#define TRX_US(us,f,n) us = PTR_ELT(f,n) -#define TRX_UI(f,n) (GLuint) PTR_ELT(f,n) - - -#define SZ 4 -#define INIT init_trans_4_GLushort_raw -#define DEST_4F trans_4_GLushort_4f_raw -#define DEST_4FN trans_4_GLushort_4fn_raw -#define DEST_4UB trans_4_GLushort_4ub_raw -#define DEST_4US trans_4_GLushort_4us_raw -#include "m_trans_tmp.h" - -#define SZ 3 -#define INIT init_trans_3_GLushort_raw -#define DEST_4F trans_3_GLushort_4f_raw -#define DEST_4FN trans_3_GLushort_4fn_raw -#define DEST_4UB trans_3_GLushort_4ub_raw -#define DEST_4US trans_3_GLushort_4us_raw -#define DEST_3FN trans_3_GLushort_3fn_raw -#include "m_trans_tmp.h" - -#define SZ 2 -#define INIT init_trans_2_GLushort_raw -#define DEST_4F trans_2_GLushort_4f_raw -#define DEST_4FN trans_2_GLushort_4fn_raw -#include "m_trans_tmp.h" - -#define SZ 1 -#define INIT init_trans_1_GLushort_raw -#define DEST_4F trans_1_GLushort_4f_raw -#define DEST_4FN trans_1_GLushort_4fn_raw -#define DEST_1UB trans_1_GLushort_1ub_raw -#define DEST_1UI trans_1_GLushort_1ui_raw -#include "m_trans_tmp.h" - -#undef SRC -#undef SRC_IDX -#undef TRX_3FN -#undef TRX_4F -#undef TRX_4FN -#undef TRX_UB -#undef TRX_US -#undef TRX_UI - - -/* GL_INT - */ -#define SRC GLint -#define SRC_IDX TYPE_IDX(GL_INT) -#define TRX_3FN(f,n) INT_TO_FLOAT( PTR_ELT(f,n) ) -#define TRX_4F(f,n) (GLfloat)( PTR_ELT(f,n) ) -#define TRX_4FN(f,n) INT_TO_FLOAT( PTR_ELT(f,n) ) -#define TRX_UB(ub, f,n) ub = INT_TO_UBYTE(PTR_ELT(f,n)) -#define TRX_US(us, f,n) us = INT_TO_USHORT(PTR_ELT(f,n)) -#define TRX_UI(f,n) (PTR_ELT(f,n) < 0 ? 0 : (GLuint) PTR_ELT(f,n)) - - -#define SZ 4 -#define INIT init_trans_4_GLint_raw -#define DEST_4F trans_4_GLint_4f_raw -#define DEST_4FN trans_4_GLint_4fn_raw -#define DEST_4UB trans_4_GLint_4ub_raw -#define DEST_4US trans_4_GLint_4us_raw -#include "m_trans_tmp.h" - -#define SZ 3 -#define INIT init_trans_3_GLint_raw -#define DEST_4F trans_3_GLint_4f_raw -#define DEST_4FN trans_3_GLint_4fn_raw -#define DEST_4UB trans_3_GLint_4ub_raw -#define DEST_4US trans_3_GLint_4us_raw -#define DEST_3FN trans_3_GLint_3fn_raw -#include "m_trans_tmp.h" - -#define SZ 2 -#define INIT init_trans_2_GLint_raw -#define DEST_4F trans_2_GLint_4f_raw -#define DEST_4FN trans_2_GLint_4fn_raw -#include "m_trans_tmp.h" - -#define SZ 1 -#define INIT init_trans_1_GLint_raw -#define DEST_4F trans_1_GLint_4f_raw -#define DEST_4FN trans_1_GLint_4fn_raw -#define DEST_1UB trans_1_GLint_1ub_raw -#define DEST_1UI trans_1_GLint_1ui_raw -#include "m_trans_tmp.h" - - -#undef SRC -#undef SRC_IDX -#undef TRX_3FN -#undef TRX_4F -#undef TRX_4FN -#undef TRX_UB -#undef TRX_US -#undef TRX_UI - - -/* GL_UNSIGNED_INT - */ -#define SRC GLuint -#define SRC_IDX TYPE_IDX(GL_UNSIGNED_INT) -#define TRX_3FN(f,n) INT_TO_FLOAT( PTR_ELT(f,n) ) -#define TRX_4F(f,n) (GLfloat)( PTR_ELT(f,n) ) -#define TRX_4FN(f,n) UINT_TO_FLOAT( PTR_ELT(f,n) ) -#define TRX_UB(ub, f,n) ub = (GLubyte) (PTR_ELT(f,n) >> 24) -#define TRX_US(us, f,n) us = (GLshort) (PTR_ELT(f,n) >> 16) -#define TRX_UI(f,n) PTR_ELT(f,n) - - -#define SZ 4 -#define INIT init_trans_4_GLuint_raw -#define DEST_4F trans_4_GLuint_4f_raw -#define DEST_4FN trans_4_GLuint_4fn_raw -#define DEST_4UB trans_4_GLuint_4ub_raw -#define DEST_4US trans_4_GLuint_4us_raw -#include "m_trans_tmp.h" - -#define SZ 3 -#define INIT init_trans_3_GLuint_raw -#define DEST_4F trans_3_GLuint_4f_raw -#define DEST_4FN trans_3_GLuint_4fn_raw -#define DEST_4UB trans_3_GLuint_4ub_raw -#define DEST_4US trans_3_GLuint_4us_raw -#define DEST_3FN trans_3_GLuint_3fn_raw -#include "m_trans_tmp.h" - -#define SZ 2 -#define INIT init_trans_2_GLuint_raw -#define DEST_4F trans_2_GLuint_4f_raw -#define DEST_4FN trans_2_GLuint_4fn_raw -#include "m_trans_tmp.h" - -#define SZ 1 -#define INIT init_trans_1_GLuint_raw -#define DEST_4F trans_1_GLuint_4f_raw -#define DEST_4FN trans_1_GLuint_4fn_raw -#define DEST_1UB trans_1_GLuint_1ub_raw -#define DEST_1UI trans_1_GLuint_1ui_raw -#include "m_trans_tmp.h" - -#undef SRC -#undef SRC_IDX -#undef TRX_3FN -#undef TRX_4F -#undef TRX_4FN -#undef TRX_UB -#undef TRX_US -#undef TRX_UI - - -/* GL_DOUBLE - */ -#define SRC GLdouble -#define SRC_IDX TYPE_IDX(GL_DOUBLE) -#define TRX_3FN(f,n) (GLfloat) PTR_ELT(f,n) -#define TRX_4F(f,n) (GLfloat) PTR_ELT(f,n) -#define TRX_4FN(f,n) (GLfloat) PTR_ELT(f,n) -#define TRX_UB(ub,f,n) UNCLAMPED_FLOAT_TO_UBYTE(ub, PTR_ELT(f,n)) -#define TRX_US(us,f,n) UNCLAMPED_FLOAT_TO_USHORT(us, PTR_ELT(f,n)) -#define TRX_UI(f,n) (GLuint) (GLint) PTR_ELT(f,n) -#define TRX_1F(f,n) (GLfloat) PTR_ELT(f,n) - - -#define SZ 4 -#define INIT init_trans_4_GLdouble_raw -#define DEST_4F trans_4_GLdouble_4f_raw -#define DEST_4FN trans_4_GLdouble_4fn_raw -#define DEST_4UB trans_4_GLdouble_4ub_raw -#define DEST_4US trans_4_GLdouble_4us_raw -#include "m_trans_tmp.h" - -#define SZ 3 -#define INIT init_trans_3_GLdouble_raw -#define DEST_4F trans_3_GLdouble_4f_raw -#define DEST_4FN trans_3_GLdouble_4fn_raw -#define DEST_4UB trans_3_GLdouble_4ub_raw -#define DEST_4US trans_3_GLdouble_4us_raw -#define DEST_3FN trans_3_GLdouble_3fn_raw -#include "m_trans_tmp.h" - -#define SZ 2 -#define INIT init_trans_2_GLdouble_raw -#define DEST_4F trans_2_GLdouble_4f_raw -#define DEST_4FN trans_2_GLdouble_4fn_raw -#include "m_trans_tmp.h" - -#define SZ 1 -#define INIT init_trans_1_GLdouble_raw -#define DEST_4F trans_1_GLdouble_4f_raw -#define DEST_4FN trans_1_GLdouble_4fn_raw -#define DEST_1UB trans_1_GLdouble_1ub_raw -#define DEST_1UI trans_1_GLdouble_1ui_raw -#define DEST_1F trans_1_GLdouble_1f_raw -#include "m_trans_tmp.h" - -#undef SRC -#undef SRC_IDX - -/* GL_FLOAT - */ -#define SRC GLfloat -#define SRC_IDX TYPE_IDX(GL_FLOAT) -#define SZ 4 -#define INIT init_trans_4_GLfloat_raw -#define DEST_4UB trans_4_GLfloat_4ub_raw -#define DEST_4US trans_4_GLfloat_4us_raw -#define DEST_4F trans_4_GLfloat_4f_raw -#define DEST_4FN trans_4_GLfloat_4fn_raw -#include "m_trans_tmp.h" - -#define SZ 3 -#define INIT init_trans_3_GLfloat_raw -#define DEST_4F trans_3_GLfloat_4f_raw -#define DEST_4FN trans_3_GLfloat_4fn_raw -#define DEST_4UB trans_3_GLfloat_4ub_raw -#define DEST_4US trans_3_GLfloat_4us_raw -#define DEST_3FN trans_3_GLfloat_3fn_raw -#include "m_trans_tmp.h" - -#define SZ 2 -#define INIT init_trans_2_GLfloat_raw -#define DEST_4F trans_2_GLfloat_4f_raw -#define DEST_4FN trans_2_GLfloat_4fn_raw -#include "m_trans_tmp.h" - -#define SZ 1 -#define INIT init_trans_1_GLfloat_raw -#define DEST_4F trans_1_GLfloat_4f_raw -#define DEST_4FN trans_1_GLfloat_4fn_raw -#define DEST_1UB trans_1_GLfloat_1ub_raw -#define DEST_1UI trans_1_GLfloat_1ui_raw -#define DEST_1F trans_1_GLfloat_1f_raw - -#include "m_trans_tmp.h" - -#undef SRC -#undef SRC_IDX -#undef TRX_3FN -#undef TRX_4F -#undef TRX_4FN -#undef TRX_UB -#undef TRX_US -#undef TRX_UI - - -static void trans_4_GLubyte_4ub_raw(GLubyte (*t)[4], - CONST void *Ptr, - GLuint stride, - ARGS ) -{ - const GLubyte *f = (GLubyte *) Ptr + SRC_START * stride; - GLuint i; - - if (((((uintptr_t) f | (uintptr_t) stride)) & 3L) == 0L) { - /* Aligned. - */ - for (i = DST_START ; i < n ; i++, f += stride) { - COPY_4UBV( t[i], f ); - } - } else { - for (i = DST_START ; i < n ; i++, f += stride) { - t[i][0] = f[0]; - t[i][1] = f[1]; - t[i][2] = f[2]; - t[i][3] = f[3]; - } - } -} - - -static void init_translate_raw(void) -{ - memset( TAB(_1ui), 0, sizeof(TAB(_1ui)) ); - memset( TAB(_1ub), 0, sizeof(TAB(_1ub)) ); - memset( TAB(_3fn), 0, sizeof(TAB(_3fn)) ); - memset( TAB(_4ub), 0, sizeof(TAB(_4ub)) ); - memset( TAB(_4us), 0, sizeof(TAB(_4us)) ); - memset( TAB(_4f), 0, sizeof(TAB(_4f)) ); - memset( TAB(_4fn), 0, sizeof(TAB(_4fn)) ); - - init_trans_4_GLbyte_raw(); - init_trans_3_GLbyte_raw(); - init_trans_2_GLbyte_raw(); - init_trans_1_GLbyte_raw(); - init_trans_1_GLubyte_raw(); - init_trans_3_GLubyte_raw(); - init_trans_4_GLubyte_raw(); - init_trans_4_GLshort_raw(); - init_trans_3_GLshort_raw(); - init_trans_2_GLshort_raw(); - init_trans_1_GLshort_raw(); - init_trans_4_GLushort_raw(); - init_trans_3_GLushort_raw(); - init_trans_2_GLushort_raw(); - init_trans_1_GLushort_raw(); - init_trans_4_GLint_raw(); - init_trans_3_GLint_raw(); - init_trans_2_GLint_raw(); - init_trans_1_GLint_raw(); - init_trans_4_GLuint_raw(); - init_trans_3_GLuint_raw(); - init_trans_2_GLuint_raw(); - init_trans_1_GLuint_raw(); - init_trans_4_GLdouble_raw(); - init_trans_3_GLdouble_raw(); - init_trans_2_GLdouble_raw(); - init_trans_1_GLdouble_raw(); - init_trans_4_GLfloat_raw(); - init_trans_3_GLfloat_raw(); - init_trans_2_GLfloat_raw(); - init_trans_1_GLfloat_raw(); - - TAB(_4ub)[4][TYPE_IDX(GL_UNSIGNED_BYTE)] = trans_4_GLubyte_4ub_raw; -} - - -#undef TAB -#ifdef CLASS -#undef CLASS -#endif -#undef ARGS -#undef CHECK -#undef SRC_START -#undef DST_START -#undef NEXT_F -#undef NEXT_F2 - - - - - -void _math_init_translate( void ) -{ - init_translate_raw(); -} - - -/** - * Translate vector of values to GLfloat [1]. - */ -void _math_trans_1f(GLfloat *to, - CONST void *ptr, - GLuint stride, - GLenum type, - GLuint start, - GLuint n ) -{ - _math_trans_1f_tab[TYPE_IDX(type)]( to, ptr, stride, start, n ); -} - -/** - * Translate vector of values to GLuint [1]. - */ -void _math_trans_1ui(GLuint *to, - CONST void *ptr, - GLuint stride, - GLenum type, - GLuint start, - GLuint n ) -{ - _math_trans_1ui_tab[TYPE_IDX(type)]( to, ptr, stride, start, n ); -} - -/** - * Translate vector of values to GLubyte [1]. - */ -void _math_trans_1ub(GLubyte *to, - CONST void *ptr, - GLuint stride, - GLenum type, - GLuint start, - GLuint n ) -{ - _math_trans_1ub_tab[TYPE_IDX(type)]( to, ptr, stride, start, n ); -} - - -/** - * Translate vector of values to GLubyte [4]. - */ -void _math_trans_4ub(GLubyte (*to)[4], - CONST void *ptr, - GLuint stride, - GLenum type, - GLuint size, - GLuint start, - GLuint n ) -{ - _math_trans_4ub_tab[size][TYPE_IDX(type)]( to, ptr, stride, start, n ); -} - -/** - * Translate vector of values to GLchan [4]. - */ -void _math_trans_4chan( GLchan (*to)[4], - CONST void *ptr, - GLuint stride, - GLenum type, - GLuint size, - GLuint start, - GLuint n ) -{ -#if CHAN_TYPE == GL_UNSIGNED_BYTE - _math_trans_4ub( to, ptr, stride, type, size, start, n ); -#elif CHAN_TYPE == GL_UNSIGNED_SHORT - _math_trans_4us( to, ptr, stride, type, size, start, n ); -#elif CHAN_TYPE == GL_FLOAT - _math_trans_4fn( to, ptr, stride, type, size, start, n ); -#endif -} - -/** - * Translate vector of values to GLushort [4]. - */ -void _math_trans_4us(GLushort (*to)[4], - CONST void *ptr, - GLuint stride, - GLenum type, - GLuint size, - GLuint start, - GLuint n ) -{ - _math_trans_4us_tab[size][TYPE_IDX(type)]( to, ptr, stride, start, n ); -} - -/** - * Translate vector of values to GLfloat [4]. - */ -void _math_trans_4f(GLfloat (*to)[4], - CONST void *ptr, - GLuint stride, - GLenum type, - GLuint size, - GLuint start, - GLuint n ) -{ - _math_trans_4f_tab[size][TYPE_IDX(type)]( to, ptr, stride, start, n ); -} - -/** - * Translate vector of values to GLfloat[4], normalized to [-1, 1]. - */ -void _math_trans_4fn(GLfloat (*to)[4], - CONST void *ptr, - GLuint stride, - GLenum type, - GLuint size, - GLuint start, - GLuint n ) -{ - _math_trans_4fn_tab[size][TYPE_IDX(type)]( to, ptr, stride, start, n ); -} - -/** - * Translate vector of values to GLfloat[3], normalized to [-1, 1]. - */ -void _math_trans_3fn(GLfloat (*to)[3], - CONST void *ptr, - GLuint stride, - GLenum type, - GLuint start, - GLuint n ) -{ - _math_trans_3fn_tab[TYPE_IDX(type)]( to, ptr, stride, start, n ); -} diff --git a/dll/opengl/mesa/math/m_translate.h b/dll/opengl/mesa/math/m_translate.h deleted file mode 100644 index bf7485c8c12..00000000000 --- a/dll/opengl/mesa/math/m_translate.h +++ /dev/null @@ -1,123 +0,0 @@ -/* - * Mesa 3-D graphics library - * Version: 6.5.1 - * - * Copyright (C) 1999-2006 Brian Paul All Rights Reserved. - * - * Permission is hereby granted, free of charge, to any person obtaining a - * copy of this software and associated documentation files (the "Software"), - * to deal in the Software without restriction, including without limitation - * the rights to use, copy, modify, merge, publish, distribute, sublicense, - * and/or sell copies of the Software, and to permit persons to whom the - * Software is furnished to do so, subject to the following conditions: - * - * The above copyright notice and this permission notice shall be included - * in all copies or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS - * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL - * BRIAN PAUL BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN - * AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN - * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. - */ - - -#ifndef _M_TRANSLATE_H_ -#define _M_TRANSLATE_H_ - -#include "main/compiler.h" -#include "main/glheader.h" -#include "main/mtypes.h" /* hack for GLchan */ -#include "swrast/s_chan.h" - -/** - * Array translation. - * For example, convert array of GLushort[3] to GLfloat[4]. - * The function name specifies the destination format/size. - * \param to the destination address - * \param ptr the source address - * \param stride the source stride (in bytes) between elements - * \param type the source datatype (GL_SHORT, GL_UNSIGNED_INT, etc) - * \param size number of values per element in source array (1,2,3 or 4) - * \param start first element in source array to convert - * \param n number of elements to convert - * - * Note: "element" means a tuple like GLfloat[3] or GLubyte[4]. - */ - - -extern void _math_trans_1f(GLfloat *to, - CONST void *ptr, - GLuint stride, - GLenum type, - GLuint start, - GLuint n ); - -extern void _math_trans_1ui(GLuint *to, - CONST void *ptr, - GLuint stride, - GLenum type, - GLuint start, - GLuint n ); - -extern void _math_trans_1ub(GLubyte *to, - CONST void *ptr, - GLuint stride, - GLenum type, - GLuint start, - GLuint n ); - -extern void _math_trans_4ub(GLubyte (*to)[4], - CONST void *ptr, - GLuint stride, - GLenum type, - GLuint size, - GLuint start, - GLuint n ); - -extern void _math_trans_4chan( GLchan (*to)[4], - CONST void *ptr, - GLuint stride, - GLenum type, - GLuint size, - GLuint start, - GLuint n ); - -extern void _math_trans_4us(GLushort (*to)[4], - CONST void *ptr, - GLuint stride, - GLenum type, - GLuint size, - GLuint start, - GLuint n ); - -/** Convert to floats w/out normalization (i.e. just cast) */ -extern void _math_trans_4f(GLfloat (*to)[4], - CONST void *ptr, - GLuint stride, - GLenum type, - GLuint size, - GLuint start, - GLuint n ); - -/** Convert to normalized floats in [0,1] or [-1, 1] */ -extern void _math_trans_4fn(GLfloat (*to)[4], - CONST void *ptr, - GLuint stride, - GLenum type, - GLuint size, - GLuint start, - GLuint n ); - -extern void _math_trans_3fn(GLfloat (*to)[3], - CONST void *ptr, - GLuint stride, - GLenum type, - GLuint start, - GLuint n ); - -extern void _math_init_translate( void ); - - -#endif diff --git a/dll/opengl/mesa/math/m_vector.c b/dll/opengl/mesa/math/m_vector.c deleted file mode 100644 index a3314883a4f..00000000000 --- a/dll/opengl/mesa/math/m_vector.c +++ /dev/null @@ -1,179 +0,0 @@ -/* - * Mesa 3-D graphics library - * Version: 3.5 - * - * Copyright (C) 1999-2001 Brian Paul All Rights Reserved. - * - * Permission is hereby granted, free of charge, to any person obtaining a - * copy of this software and associated documentation files (the "Software"), - * to deal in the Software without restriction, including without limitation - * the rights to use, copy, modify, merge, publish, distribute, sublicense, - * and/or sell copies of the Software, and to permit persons to whom the - * Software is furnished to do so, subject to the following conditions: - * - * The above copyright notice and this permission notice shall be included - * in all copies or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS - * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL - * BRIAN PAUL BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN - * AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN - * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. - */ - -/* - * New (3.1) transformation code written by Keith Whitwell. - */ - -#include - -#include "m_vector.h" - -/** - * Given a vector [count][4] of floats, set all the [][elt] values - * to 0 (if elt = 0, 1, 2) or 1.0 (if elt = 3). - */ -void -_mesa_vector4f_clean_elem( GLvector4f *vec, GLuint count, GLuint elt ) -{ - static const GLubyte elem_bits[4] = { - VEC_DIRTY_0, - VEC_DIRTY_1, - VEC_DIRTY_2, - VEC_DIRTY_3 - }; - static const GLfloat clean[4] = { 0, 0, 0, 1 }; - const GLfloat v = clean[elt]; - GLfloat (*data)[4] = (GLfloat (*)[4])vec->start; - GLuint i; - - for (i = 0; i < count; i++) - data[i][elt] = v; - - vec->flags &= ~elem_bits[elt]; -} - - -static const GLubyte size_bits[5] = { - 0, - VEC_SIZE_1, - VEC_SIZE_2, - VEC_SIZE_3, - VEC_SIZE_4, -}; - - -/** - * Initialize GLvector objects. - * \param v the vector object to initialize. - * \param flags bitwise-OR of VEC_* flags - * \param storage pointer to storage for the vector's data - */ -void -_mesa_vector4f_init( GLvector4f *v, GLbitfield flags, GLfloat (*storage)[4] ) -{ - v->stride = 4 * sizeof(GLfloat); - v->size = 2; /* may change: 2-4 for vertices and 1-4 for texcoords */ - v->data = storage; - v->start = (GLfloat *) storage; - v->count = 0; - v->flags = size_bits[4] | flags; -} - - -/** - * Initialize GLvector objects and allocate storage. - * \param v the vector object - * \param flags bitwise-OR of VEC_* flags - * \param count number of elements to allocate in vector - * \param alignment desired memory alignment for the data (in bytes) - */ -void -_mesa_vector4f_alloc( GLvector4f *v, GLbitfield flags, GLuint count, - GLuint alignment ) -{ - v->stride = 4 * sizeof(GLfloat); - v->size = 2; - v->storage = _mesa_align_malloc( count * 4 * sizeof(GLfloat), alignment ); - v->storage_count = count; - v->start = (GLfloat *) v->storage; - v->data = (GLfloat (*)[4]) v->storage; - v->count = 0; - v->flags = size_bits[4] | flags | VEC_MALLOC; -} - - -/** - * Vector deallocation. Free whatever memory is pointed to by the - * vector's storage field if the VEC_MALLOC flag is set. - * DO NOT free the GLvector object itself, though. - */ -void -_mesa_vector4f_free( GLvector4f *v ) -{ - if (v->flags & VEC_MALLOC) { - _mesa_align_free( v->storage ); - v->data = NULL; - v->start = NULL; - v->storage = NULL; - v->flags &= ~VEC_MALLOC; - } -} - - -/** - * For debugging - */ -void -_mesa_vector4f_print( const GLvector4f *v, const GLubyte *cullmask, - GLboolean culling ) -{ - static const GLfloat c[4] = { 0, 0, 0, 1 }; - static const char *templates[5] = { - "%d:\t0, 0, 0, 1\n", - "%d:\t%f, 0, 0, 1\n", - "%d:\t%f, %f, 0, 1\n", - "%d:\t%f, %f, %f, 1\n", - "%d:\t%f, %f, %f, %f\n" - }; - - const char *t = templates[v->size]; - GLfloat *d = (GLfloat *)v->data; - GLuint j, i = 0, count; - - printf("data-start\n"); - for (; d != v->start; STRIDE_F(d, v->stride), i++) - printf(t, i, d[0], d[1], d[2], d[3]); - - printf("start-count(%u)\n", v->count); - count = i + v->count; - - if (culling) { - for (; i < count; STRIDE_F(d, v->stride), i++) - if (cullmask[i]) - printf(t, i, d[0], d[1], d[2], d[3]); - } - else { - for (; i < count; STRIDE_F(d, v->stride), i++) - printf(t, i, d[0], d[1], d[2], d[3]); - } - - for (j = v->size; j < 4; j++) { - if ((v->flags & (1<data; - i < count && d[j] == c[j]; - i++, STRIDE_F(d, v->stride)) { - /* no-op */ - } - - if (i == count) - printf(" --> ok\n"); - else - printf(" --> Failed at %u ******\n", i); - } - } -} diff --git a/dll/opengl/mesa/math/m_vector.h b/dll/opengl/mesa/math/m_vector.h deleted file mode 100644 index 71281d57589..00000000000 --- a/dll/opengl/mesa/math/m_vector.h +++ /dev/null @@ -1,92 +0,0 @@ -/* - * Mesa 3-D graphics library - * Version: 7.3 - * - * Copyright (C) 1999-2008 Brian Paul All Rights Reserved. - * - * Permission is hereby granted, free of charge, to any person obtaining a - * copy of this software and associated documentation files (the "Software"), - * to deal in the Software without restriction, including without limitation - * the rights to use, copy, modify, merge, publish, distribute, sublicense, - * and/or sell copies of the Software, and to permit persons to whom the - * Software is furnished to do so, subject to the following conditions: - * - * The above copyright notice and this permission notice shall be included - * in all copies or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS - * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL - * BRIAN PAUL BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN - * AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN - * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. - */ - -/* - * New (3.1) transformation code written by Keith Whitwell. - */ - - -#ifndef _M_VECTOR_H_ -#define _M_VECTOR_H_ - -#include "main/glheader.h" - - -#define VEC_DIRTY_0 0x1 -#define VEC_DIRTY_1 0x2 -#define VEC_DIRTY_2 0x4 -#define VEC_DIRTY_3 0x8 -#define VEC_MALLOC 0x10 /* storage field points to self-allocated mem*/ -#define VEC_NOT_WRITEABLE 0x40 /* writable elements to hold clipped data */ -#define VEC_BAD_STRIDE 0x100 /* matches tnl's prefered stride */ - - -#define VEC_SIZE_1 VEC_DIRTY_0 -#define VEC_SIZE_2 (VEC_DIRTY_0|VEC_DIRTY_1) -#define VEC_SIZE_3 (VEC_DIRTY_0|VEC_DIRTY_1|VEC_DIRTY_2) -#define VEC_SIZE_4 (VEC_DIRTY_0|VEC_DIRTY_1|VEC_DIRTY_2|VEC_DIRTY_3) - - - -/** - * Wrap all the information about vectors up in a struct. Has - * additional fields compared to the other vectors to help us track of - * different vertex sizes, and whether we need to clean columns out - * because they contain non-(0,0,0,1) values. - * - * The start field is used to reserve data for copied vertices at the - * end of _mesa_transform_vb, and avoids the need for a multiplication in - * the transformation routines. - */ -typedef struct { - GLfloat (*data)[4]; /**< may be malloc'd or point to client data */ - GLfloat *start; /**< points somewhere inside of */ - GLuint count; /**< size of the vector (in elements) */ - GLuint stride; /**< stride from one element to the next (in bytes) */ - GLuint size; /**< 2-4 for vertices and 1-4 for texcoords */ - GLbitfield flags; /**< bitmask of VEC_x flags */ - void *storage; /**< self-allocated storage */ - GLuint storage_count; /**< storage size in elements */ -} GLvector4f; - - -extern void _mesa_vector4f_init( GLvector4f *v, GLbitfield flags, - GLfloat (*storage)[4] ); -extern void _mesa_vector4f_alloc( GLvector4f *v, GLbitfield flags, - GLuint count, GLuint alignment ); -extern void _mesa_vector4f_free( GLvector4f *v ); -extern void _mesa_vector4f_print( const GLvector4f *v, const GLubyte *, GLboolean ); -extern void _mesa_vector4f_clean_elem( GLvector4f *vec, GLuint nr, GLuint elt ); - - -/** - * Given vector , return a pointer (cast to to the
-th element. - * - * End up doing a lot of slow imuls if not careful. - */ -#define VEC_ELT( v, type, i ) \ - ( (type *) ( ((GLbyte *) ((v)->data)) + (i) * (v)->stride) ) - - -#endif diff --git a/dll/opengl/mesa/math/m_xform.c b/dll/opengl/mesa/math/m_xform.c deleted file mode 100644 index 386117e2a93..00000000000 --- a/dll/opengl/mesa/math/m_xform.c +++ /dev/null @@ -1,121 +0,0 @@ -/* - * Mesa 3-D graphics library - * Version: 5.1 - * - * Copyright (C) 1999-2003 Brian Paul All Rights Reserved. - * - * Permission is hereby granted, free of charge, to any person obtaining a - * copy of this software and associated documentation files (the "Software"), - * to deal in the Software without restriction, including without limitation - * the rights to use, copy, modify, merge, publish, distribute, sublicense, - * and/or sell copies of the Software, and to permit persons to whom the - * Software is furnished to do so, subject to the following conditions: - * - * The above copyright notice and this permission notice shall be included - * in all copies or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS - * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL - * BRIAN PAUL BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN - * AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN - * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. - */ - - -/* - * Matrix/vertex/vector transformation stuff - * - * - * NOTES: - * 1. 4x4 transformation matrices are stored in memory in column major order. - * 2. Points/vertices are to be thought of as column vectors. - * 3. Transformation of a point p by a matrix M is: p' = M * p - */ - -#include - -#ifdef DEBUG_MATH -#include "m_debug.h" -#endif - -#ifdef USE_X86_ASM -#include "x86/common_x86_asm.h" -#endif - -#ifdef USE_X86_64_ASM -#include "x86-64/x86-64.h" -#endif - -#ifdef USE_SPARC_ASM -#include "sparc/sparc.h" -#endif - -#ifdef USE_PPC_ASM -#include "ppc/common_ppc_features.h" -#endif - -clip_func _mesa_clip_tab[5]; -clip_func _mesa_clip_np_tab[5]; -dotprod_func _mesa_dotprod_tab[5]; -vec_copy_func _mesa_copy_tab[0x10]; -normal_func _mesa_normal_tab[0xf]; -transform_func *_mesa_transform_tab[5]; - - -/* Raw data format used for: - * - Object-to-eye transform prior to culling, although this too - * could be culled under some circumstances. - * - Eye-to-clip transform (via the function above). - * - Cliptesting - * - And everything else too, if culling happens to be disabled. - * - * GH: It's used for everything now, as clipping/culling is done - * elsewhere (most often by the driver itself). - */ -#define TAG(x) x -#define TAG2(x,y) x##y -#define STRIDE_LOOP for ( i = 0 ; i < count ; i++, STRIDE_F(from, stride) ) -#define LOOP for ( i = 0 ; i < n ; i++ ) -#define ARGS -#include "m_xform_tmp.h" -#include "m_clip_tmp.h" -#include "m_norm_tmp.h" -#include "m_dotprod_tmp.h" -#include "m_copy_tmp.h" -#undef TAG -#undef TAG2 -#undef LOOP -#undef ARGS - - -/* - * This is called only once. It initializes several tables with pointers - * to optimized transformation functions. This is where we can test for - * AMD 3Dnow! capability, Intel SSE, etc. and hook in the right code. - */ -void -_math_init_transformation( void ) -{ - init_c_transformations(); - init_c_norm_transform(); - init_c_cliptest(); - init_copy0(); - init_dotprod(); - -#ifdef DEBUG_MATH - _math_test_all_transform_functions( "default" ); - _math_test_all_normal_transform_functions( "default" ); - _math_test_all_cliptest_functions( "default" ); -#endif - -#ifdef USE_X86_ASM - _mesa_init_all_x86_transform_asm(); -#elif defined( USE_SPARC_ASM ) - _mesa_init_all_sparc_transform_asm(); -#elif defined( USE_PPC_ASM ) - _mesa_init_all_ppc_transform_asm(); -#elif defined( USE_X86_64_ASM ) - _mesa_init_all_x86_64_transform_asm(); -#endif -} diff --git a/dll/opengl/mesa/math/m_xform.h b/dll/opengl/mesa/math/m_xform.h deleted file mode 100644 index ee7166116f2..00000000000 --- a/dll/opengl/mesa/math/m_xform.h +++ /dev/null @@ -1,167 +0,0 @@ -/* - * Mesa 3-D graphics library - * Version: 7.3 - * - * Copyright (C) 1999-2008 Brian Paul All Rights Reserved. - * - * Permission is hereby granted, free of charge, to any person obtaining a - * copy of this software and associated documentation files (the "Software"), - * to deal in the Software without restriction, including without limitation - * the rights to use, copy, modify, merge, publish, distribute, sublicense, - * and/or sell copies of the Software, and to permit persons to whom the - * Software is furnished to do so, subject to the following conditions: - * - * The above copyright notice and this permission notice shall be included - * in all copies or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS - * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL - * BRIAN PAUL BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN - * AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN - * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. - */ - - -#ifndef _M_XFORM_H -#define _M_XFORM_H - - -#include "main/compiler.h" -#include "main/glheader.h" -#include "math/m_matrix.h" -#include "math/m_vector.h" - -#ifdef USE_X86_ASM -#define _XFORMAPI _ASMAPI -#define _XFORMAPIP _ASMAPIP -#else -#define _XFORMAPI -#define _XFORMAPIP * -#endif - - -extern void -_math_init_transformation(void); -extern void -init_c_cliptest(void); - -/* KW: Clip functions now do projective divide as well. The projected - * coordinates are very useful to us because they let us cull - * backfaces and eliminate vertices from lighting, fogging, etc - * calculations. Despite the fact that this divide could be done one - * day in hardware, we would still have a reason to want to do it here - * as long as those other calculations remain in software. - * - * Clipping is a convenient place to do the divide on x86 as it should be - * possible to overlap with integer outcode calculations. - * - * There are two cases where we wouldn't want to do the divide in cliptest: - * - When we aren't clipping. We still might want to cull backfaces - * so the divide should be done elsewhere. This currently never - * happens. - * - * - When culling isn't likely to help us, such as when the GL culling - * is disabled and we not lighting or are only lighting - * one-sided. In this situation, backface determination provides - * us with no useful information. A tricky case to detect is when - * all input data is already culled, although hopefully the - * application wouldn't turn on culling in such cases. - * - * We supply a buffer to hold the [x/w,y/w,z/w,1/w] values which - * are the result of the projection. This is only used in the - * 4-vector case - in other cases, we just use the clip coordinates - * as the projected coordinates - they are identical. - * - * This is doubly convenient because it means the Win[] array is now - * of the same stride as all the others, so I can now turn map_vertices - * into a straight-forward matrix transformation, with asm acceleration - * automatically available. - */ - -/* Vertex buffer clipping flags - */ -#define CLIP_RIGHT_SHIFT 0 -#define CLIP_LEFT_SHIFT 1 -#define CLIP_TOP_SHIFT 2 -#define CLIP_BOTTOM_SHIFT 3 -#define CLIP_NEAR_SHIFT 4 -#define CLIP_FAR_SHIFT 5 - -#define CLIP_RIGHT_BIT 0x01 -#define CLIP_LEFT_BIT 0x02 -#define CLIP_TOP_BIT 0x04 -#define CLIP_BOTTOM_BIT 0x08 -#define CLIP_NEAR_BIT 0x10 -#define CLIP_FAR_BIT 0x20 -#define CLIP_USER_BIT 0x40 -#define CLIP_CULL_BIT 0x80 -#define CLIP_FRUSTUM_BITS 0x3f - - -typedef GLvector4f * (_XFORMAPIP clip_func)( GLvector4f *vClip, - GLvector4f *vProj, - GLubyte clipMask[], - GLubyte *orMask, - GLubyte *andMask ); - -typedef void (*dotprod_func)( GLfloat *out, - GLuint out_stride, - CONST GLvector4f *coord_vec, - CONST GLfloat plane[4] ); - -typedef void (*vec_copy_func)( GLvector4f *to, - CONST GLvector4f *from ); - - - -/* - * Functions for transformation of normals in the VB. - */ -typedef void (_NORMAPIP normal_func)( CONST GLmatrix *mat, - GLfloat scale, - CONST GLvector4f *in, - CONST GLfloat lengths[], - GLvector4f *dest ); - - -/* Flags for selecting a normal transformation function. - */ -#define NORM_RESCALE 0x1 /* apply the scale factor */ -#define NORM_NORMALIZE 0x2 /* normalize */ -#define NORM_TRANSFORM 0x4 /* apply the transformation matrix */ -#define NORM_TRANSFORM_NO_ROT 0x8 /* apply the transformation matrix */ - - - - -/* KW: New versions of the transform function allow a mask array - * specifying that individual vector transform should be skipped - * when the mask byte is zero. This is always present as a - * parameter, to allow a unified interface. - */ -typedef void (_XFORMAPIP transform_func)( GLvector4f *to_vec, - CONST GLfloat m[16], - CONST GLvector4f *from_vec ); - - -extern dotprod_func _mesa_dotprod_tab[5]; -extern vec_copy_func _mesa_copy_tab[0x10]; -extern vec_copy_func _mesa_copy_clean_tab[5]; -extern clip_func _mesa_clip_tab[5]; -extern clip_func _mesa_clip_np_tab[5]; -extern normal_func _mesa_normal_tab[0xf]; - -/* Use of 2 layers of linked 1-dimensional arrays to reduce - * cost of lookup. - */ -extern transform_func *_mesa_transform_tab[5]; - - - -#define TransformRaw( to, mat, from ) \ - ( _mesa_transform_tab[(from)->size][(mat)->type]( to, (mat)->m, from ), \ - (to) ) - - -#endif diff --git a/dll/opengl/mesa/math/m_xform_tmp.h b/dll/opengl/mesa/math/m_xform_tmp.h deleted file mode 100644 index e9383772562..00000000000 --- a/dll/opengl/mesa/math/m_xform_tmp.h +++ /dev/null @@ -1,810 +0,0 @@ - -/* - * Mesa 3-D graphics library - * Version: 3.5 - * - * Copyright (C) 1999-2001 Brian Paul All Rights Reserved. - * - * Permission is hereby granted, free of charge, to any person obtaining a - * copy of this software and associated documentation files (the "Software"), - * to deal in the Software without restriction, including without limitation - * the rights to use, copy, modify, merge, publish, distribute, sublicense, - * and/or sell copies of the Software, and to permit persons to whom the - * Software is furnished to do so, subject to the following conditions: - * - * The above copyright notice and this permission notice shall be included - * in all copies or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS - * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL - * BRIAN PAUL BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN - * AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN - * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. - */ - -/* - * New (3.1) transformation code written by Keith Whitwell. - */ - - -/*---------------------------------------------------------------------- - * Begin Keith's new code - * - *---------------------------------------------------------------------- - */ - -/* KW: Fixed stride, now measured in bytes as is the OpenGL array stride. - */ - -/* KW: These are now parameterized to produce two versions, one - * which transforms all incoming points, and a second which - * takes notice of a cullmask array, and only transforms - * unculled vertices. - */ - -/* KW: 1-vectors can sneak into the texture pipeline via the array - * interface. These functions are here because I want consistant - * treatment of the vertex sizes and a lazy strategy for - * cleaning unused parts of the vector, and so as not to exclude - * them from the vertex array interface. - * - * Under our current analysis of matrices, there is no way that - * the product of a matrix and a 1-vector can remain a 1-vector, - * with the exception of the identity transform. - */ - -/* KW: No longer zero-pad outgoing vectors. Now that external - * vectors can get into the pipeline we cannot ever assume - * that there is more to a vector than indicated by its - * size. - */ - -/* KW: Now uses clipmask and a flag to allow us to skip both/either - * cliped and/or culled vertices. - */ - -/* GH: Not any more -- it's easier (and faster) to just process the - * entire vector. Clipping and culling are handled further down - * the pipe, most often during or after the conversion to some - * driver-specific vertex format. - */ - -static void _XFORMAPI -TAG(transform_points1_general)( GLvector4f *to_vec, - const GLfloat m[16], - const GLvector4f *from_vec ) -{ - const GLuint stride = from_vec->stride; - GLfloat *from = from_vec->start; - GLfloat (*to)[4] = (GLfloat (*)[4])to_vec->start; - GLuint count = from_vec->count; - const GLfloat m0 = m[0], m12 = m[12]; - const GLfloat m1 = m[1], m13 = m[13]; - const GLfloat m2 = m[2], m14 = m[14]; - const GLfloat m3 = m[3], m15 = m[15]; - GLuint i; - STRIDE_LOOP { - const GLfloat ox = from[0]; - to[i][0] = m0 * ox + m12; - to[i][1] = m1 * ox + m13; - to[i][2] = m2 * ox + m14; - to[i][3] = m3 * ox + m15; - } - to_vec->size = 4; - to_vec->flags |= VEC_SIZE_4; - to_vec->count = from_vec->count; -} - -static void _XFORMAPI -TAG(transform_points1_identity)( GLvector4f *to_vec, - const GLfloat m[16], - const GLvector4f *from_vec ) -{ - const GLuint stride = from_vec->stride; - GLfloat *from = from_vec->start; - GLuint count = from_vec->count; - GLfloat (*to)[4] = (GLfloat (*)[4])to_vec->start; - GLuint i; - (void) m; - if (to_vec == from_vec) return; - STRIDE_LOOP { - to[i][0] = from[0]; - } - to_vec->size = 1; - to_vec->flags |= VEC_SIZE_1; - to_vec->count = from_vec->count; -} - -static void _XFORMAPI -TAG(transform_points1_2d)( GLvector4f *to_vec, - const GLfloat m[16], - const GLvector4f *from_vec ) -{ - const GLuint stride = from_vec->stride; - GLfloat *from = from_vec->start; - GLfloat (*to)[4] = (GLfloat (*)[4])to_vec->start; - GLuint count = from_vec->count; - const GLfloat m0 = m[0], m1 = m[1]; - const GLfloat m12 = m[12], m13 = m[13]; - GLuint i; - STRIDE_LOOP { - const GLfloat ox = from[0]; - to[i][0] = m0 * ox + m12; - to[i][1] = m1 * ox + m13; - } - to_vec->size = 2; - to_vec->flags |= VEC_SIZE_2; - to_vec->count = from_vec->count; -} - -static void _XFORMAPI -TAG(transform_points1_2d_no_rot)( GLvector4f *to_vec, - const GLfloat m[16], - const GLvector4f *from_vec ) -{ - const GLuint stride = from_vec->stride; - GLfloat *from = from_vec->start; - GLfloat (*to)[4] = (GLfloat (*)[4])to_vec->start; - GLuint count = from_vec->count; - const GLfloat m0 = m[0], m12 = m[12], m13 = m[13]; - GLuint i; - STRIDE_LOOP { - const GLfloat ox = from[0]; - to[i][0] = m0 * ox + m12; - to[i][1] = m13; - } - to_vec->size = 2; - to_vec->flags |= VEC_SIZE_2; - to_vec->count = from_vec->count; -} - -static void _XFORMAPI -TAG(transform_points1_3d)( GLvector4f *to_vec, - const GLfloat m[16], - const GLvector4f *from_vec ) -{ - const GLuint stride = from_vec->stride; - GLfloat *from = from_vec->start; - GLfloat (*to)[4] = (GLfloat (*)[4])to_vec->start; - GLuint count = from_vec->count; - const GLfloat m0 = m[0], m1 = m[1], m2 = m[2]; - const GLfloat m12 = m[12], m13 = m[13], m14 = m[14]; - GLuint i; - STRIDE_LOOP { - const GLfloat ox = from[0]; - to[i][0] = m0 * ox + m12; - to[i][1] = m1 * ox + m13; - to[i][2] = m2 * ox + m14; - } - to_vec->size = 3; - to_vec->flags |= VEC_SIZE_3; - to_vec->count = from_vec->count; -} - - -static void _XFORMAPI -TAG(transform_points1_3d_no_rot)( GLvector4f *to_vec, - const GLfloat m[16], - const GLvector4f *from_vec ) -{ - const GLuint stride = from_vec->stride; - GLfloat *from = from_vec->start; - GLfloat (*to)[4] = (GLfloat (*)[4])to_vec->start; - GLuint count = from_vec->count; - const GLfloat m0 = m[0]; - const GLfloat m12 = m[12], m13 = m[13], m14 = m[14]; - GLuint i; - STRIDE_LOOP { - const GLfloat ox = from[0]; - to[i][0] = m0 * ox + m12; - to[i][1] = m13; - to[i][2] = m14; - } - to_vec->size = 3; - to_vec->flags |= VEC_SIZE_3; - to_vec->count = from_vec->count; -} - -static void _XFORMAPI -TAG(transform_points1_perspective)( GLvector4f *to_vec, - const GLfloat m[16], - const GLvector4f *from_vec ) -{ - const GLuint stride = from_vec->stride; - GLfloat *from = from_vec->start; - GLfloat (*to)[4] = (GLfloat (*)[4])to_vec->start; - GLuint count = from_vec->count; - const GLfloat m0 = m[0], m14 = m[14]; - GLuint i; - STRIDE_LOOP { - const GLfloat ox = from[0]; - to[i][0] = m0 * ox ; - to[i][1] = 0 ; - to[i][2] = m14; - to[i][3] = 0; - } - to_vec->size = 4; - to_vec->flags |= VEC_SIZE_4; - to_vec->count = from_vec->count; -} - - - - -/* 2-vectors, which are a lot more relevant than 1-vectors, are - * present early in the geometry pipeline and throughout the - * texture pipeline. - */ -static void _XFORMAPI -TAG(transform_points2_general)( GLvector4f *to_vec, - const GLfloat m[16], - const GLvector4f *from_vec ) -{ - const GLuint stride = from_vec->stride; - GLfloat *from = from_vec->start; - GLfloat (*to)[4] = (GLfloat (*)[4])to_vec->start; - GLuint count = from_vec->count; - const GLfloat m0 = m[0], m4 = m[4], m12 = m[12]; - const GLfloat m1 = m[1], m5 = m[5], m13 = m[13]; - const GLfloat m2 = m[2], m6 = m[6], m14 = m[14]; - const GLfloat m3 = m[3], m7 = m[7], m15 = m[15]; - GLuint i; - STRIDE_LOOP { - const GLfloat ox = from[0], oy = from[1]; - to[i][0] = m0 * ox + m4 * oy + m12; - to[i][1] = m1 * ox + m5 * oy + m13; - to[i][2] = m2 * ox + m6 * oy + m14; - to[i][3] = m3 * ox + m7 * oy + m15; - } - to_vec->size = 4; - to_vec->flags |= VEC_SIZE_4; - to_vec->count = from_vec->count; -} - -static void _XFORMAPI -TAG(transform_points2_identity)( GLvector4f *to_vec, - const GLfloat m[16], - const GLvector4f *from_vec ) -{ - const GLuint stride = from_vec->stride; - GLfloat *from = from_vec->start; - GLfloat (*to)[4] = (GLfloat (*)[4])to_vec->start; - GLuint count = from_vec->count; - GLuint i; - (void) m; - if (to_vec == from_vec) return; - STRIDE_LOOP { - to[i][0] = from[0]; - to[i][1] = from[1]; - } - to_vec->size = 2; - to_vec->flags |= VEC_SIZE_2; - to_vec->count = from_vec->count; -} - -static void _XFORMAPI -TAG(transform_points2_2d)( GLvector4f *to_vec, - const GLfloat m[16], - const GLvector4f *from_vec ) -{ - const GLuint stride = from_vec->stride; - GLfloat *from = from_vec->start; - GLfloat (*to)[4] = (GLfloat (*)[4])to_vec->start; - GLuint count = from_vec->count; - const GLfloat m0 = m[0], m1 = m[1], m4 = m[4], m5 = m[5]; - const GLfloat m12 = m[12], m13 = m[13]; - GLuint i; - STRIDE_LOOP { - const GLfloat ox = from[0], oy = from[1]; - to[i][0] = m0 * ox + m4 * oy + m12; - to[i][1] = m1 * ox + m5 * oy + m13; - } - to_vec->size = 2; - to_vec->flags |= VEC_SIZE_2; - to_vec->count = from_vec->count; -} - -static void _XFORMAPI -TAG(transform_points2_2d_no_rot)( GLvector4f *to_vec, - const GLfloat m[16], - const GLvector4f *from_vec ) -{ - const GLuint stride = from_vec->stride; - GLfloat *from = from_vec->start; - GLfloat (*to)[4] = (GLfloat (*)[4])to_vec->start; - GLuint count = from_vec->count; - const GLfloat m0 = m[0], m5 = m[5], m12 = m[12], m13 = m[13]; - GLuint i; - STRIDE_LOOP { - const GLfloat ox = from[0], oy = from[1]; - to[i][0] = m0 * ox + m12; - to[i][1] = m5 * oy + m13; - } - to_vec->size = 2; - to_vec->flags |= VEC_SIZE_2; - to_vec->count = from_vec->count; -} - -static void _XFORMAPI -TAG(transform_points2_3d)( GLvector4f *to_vec, - const GLfloat m[16], - const GLvector4f *from_vec ) -{ - const GLuint stride = from_vec->stride; - GLfloat *from = from_vec->start; - GLfloat (*to)[4] = (GLfloat (*)[4])to_vec->start; - GLuint count = from_vec->count; - const GLfloat m0 = m[0], m1 = m[1], m2 = m[2], m4 = m[4], m5 = m[5]; - const GLfloat m6 = m[6], m12 = m[12], m13 = m[13], m14 = m[14]; - GLuint i; - STRIDE_LOOP { - const GLfloat ox = from[0], oy = from[1]; - to[i][0] = m0 * ox + m4 * oy + m12; - to[i][1] = m1 * ox + m5 * oy + m13; - to[i][2] = m2 * ox + m6 * oy + m14; - } - to_vec->size = 3; - to_vec->flags |= VEC_SIZE_3; - to_vec->count = from_vec->count; -} - - -/* I would actually say this was a fairly important function, from - * a texture transformation point of view. - */ -static void _XFORMAPI -TAG(transform_points2_3d_no_rot)( GLvector4f *to_vec, - const GLfloat m[16], - const GLvector4f *from_vec ) -{ - const GLuint stride = from_vec->stride; - GLfloat *from = from_vec->start; - GLfloat (*to)[4] = (GLfloat (*)[4])to_vec->start; - GLuint count = from_vec->count; - const GLfloat m0 = m[0], m5 = m[5]; - const GLfloat m12 = m[12], m13 = m[13], m14 = m[14]; - GLuint i; - STRIDE_LOOP { - const GLfloat ox = from[0], oy = from[1]; - to[i][0] = m0 * ox + m12; - to[i][1] = m5 * oy + m13; - to[i][2] = m14; - } - if (m14 == 0) { - to_vec->size = 2; - to_vec->flags |= VEC_SIZE_2; - } else { - to_vec->size = 3; - to_vec->flags |= VEC_SIZE_3; - } - to_vec->count = from_vec->count; -} - - -static void _XFORMAPI -TAG(transform_points2_perspective)( GLvector4f *to_vec, - const GLfloat m[16], - const GLvector4f *from_vec ) -{ - const GLuint stride = from_vec->stride; - GLfloat *from = from_vec->start; - GLfloat (*to)[4] = (GLfloat (*)[4])to_vec->start; - GLuint count = from_vec->count; - const GLfloat m0 = m[0], m5 = m[5], m14 = m[14]; - GLuint i; - STRIDE_LOOP { - const GLfloat ox = from[0], oy = from[1]; - to[i][0] = m0 * ox ; - to[i][1] = m5 * oy ; - to[i][2] = m14; - to[i][3] = 0; - } - to_vec->size = 4; - to_vec->flags |= VEC_SIZE_4; - to_vec->count = from_vec->count; -} - - - -static void _XFORMAPI -TAG(transform_points3_general)( GLvector4f *to_vec, - const GLfloat m[16], - const GLvector4f *from_vec ) -{ - const GLuint stride = from_vec->stride; - GLfloat *from = from_vec->start; - GLfloat (*to)[4] = (GLfloat (*)[4])to_vec->start; - GLuint count = from_vec->count; - const GLfloat m0 = m[0], m4 = m[4], m8 = m[8], m12 = m[12]; - const GLfloat m1 = m[1], m5 = m[5], m9 = m[9], m13 = m[13]; - const GLfloat m2 = m[2], m6 = m[6], m10 = m[10], m14 = m[14]; - const GLfloat m3 = m[3], m7 = m[7], m11 = m[11], m15 = m[15]; - GLuint i; - STRIDE_LOOP { - const GLfloat ox = from[0], oy = from[1], oz = from[2]; - to[i][0] = m0 * ox + m4 * oy + m8 * oz + m12; - to[i][1] = m1 * ox + m5 * oy + m9 * oz + m13; - to[i][2] = m2 * ox + m6 * oy + m10 * oz + m14; - to[i][3] = m3 * ox + m7 * oy + m11 * oz + m15; - } - to_vec->size = 4; - to_vec->flags |= VEC_SIZE_4; - to_vec->count = from_vec->count; -} - -static void _XFORMAPI -TAG(transform_points3_identity)( GLvector4f *to_vec, - const GLfloat m[16], - const GLvector4f *from_vec ) -{ - const GLuint stride = from_vec->stride; - GLfloat *from = from_vec->start; - GLfloat (*to)[4] = (GLfloat (*)[4])to_vec->start; - GLuint count = from_vec->count; - GLuint i; - (void) m; - if (to_vec == from_vec) return; - STRIDE_LOOP { - to[i][0] = from[0]; - to[i][1] = from[1]; - to[i][2] = from[2]; - } - to_vec->size = 3; - to_vec->flags |= VEC_SIZE_3; - to_vec->count = from_vec->count; -} - -static void _XFORMAPI -TAG(transform_points3_2d)( GLvector4f *to_vec, - const GLfloat m[16], - const GLvector4f *from_vec ) -{ - const GLuint stride = from_vec->stride; - GLfloat *from = from_vec->start; - GLfloat (*to)[4] = (GLfloat (*)[4])to_vec->start; - GLuint count = from_vec->count; - const GLfloat m0 = m[0], m1 = m[1], m4 = m[4], m5 = m[5]; - const GLfloat m12 = m[12], m13 = m[13]; - GLuint i; - STRIDE_LOOP { - const GLfloat ox = from[0], oy = from[1], oz = from[2]; - to[i][0] = m0 * ox + m4 * oy + m12 ; - to[i][1] = m1 * ox + m5 * oy + m13 ; - to[i][2] = + oz ; - } - to_vec->size = 3; - to_vec->flags |= VEC_SIZE_3; - to_vec->count = from_vec->count; -} - -static void _XFORMAPI -TAG(transform_points3_2d_no_rot)( GLvector4f *to_vec, - const GLfloat m[16], - const GLvector4f *from_vec ) -{ - const GLuint stride = from_vec->stride; - GLfloat *from = from_vec->start; - GLfloat (*to)[4] = (GLfloat (*)[4])to_vec->start; - GLuint count = from_vec->count; - const GLfloat m0 = m[0], m5 = m[5], m12 = m[12], m13 = m[13]; - GLuint i; - STRIDE_LOOP { - const GLfloat ox = from[0], oy = from[1], oz = from[2]; - to[i][0] = m0 * ox + m12 ; - to[i][1] = m5 * oy + m13 ; - to[i][2] = + oz ; - } - to_vec->size = 3; - to_vec->flags |= VEC_SIZE_3; - to_vec->count = from_vec->count; -} - -static void _XFORMAPI -TAG(transform_points3_3d)( GLvector4f *to_vec, - const GLfloat m[16], - const GLvector4f *from_vec ) -{ - const GLuint stride = from_vec->stride; - GLfloat *from = from_vec->start; - GLfloat (*to)[4] = (GLfloat (*)[4])to_vec->start; - GLuint count = from_vec->count; - const GLfloat m0 = m[0], m1 = m[1], m2 = m[2], m4 = m[4], m5 = m[5]; - const GLfloat m6 = m[6], m8 = m[8], m9 = m[9], m10 = m[10]; - const GLfloat m12 = m[12], m13 = m[13], m14 = m[14]; - GLuint i; - STRIDE_LOOP { - const GLfloat ox = from[0], oy = from[1], oz = from[2]; - to[i][0] = m0 * ox + m4 * oy + m8 * oz + m12 ; - to[i][1] = m1 * ox + m5 * oy + m9 * oz + m13 ; - to[i][2] = m2 * ox + m6 * oy + m10 * oz + m14 ; - } - to_vec->size = 3; - to_vec->flags |= VEC_SIZE_3; - to_vec->count = from_vec->count; -} - -/* previously known as ortho... - */ -static void _XFORMAPI -TAG(transform_points3_3d_no_rot)( GLvector4f *to_vec, - const GLfloat m[16], - const GLvector4f *from_vec ) -{ - const GLuint stride = from_vec->stride; - GLfloat *from = from_vec->start; - GLfloat (*to)[4] = (GLfloat (*)[4])to_vec->start; - GLuint count = from_vec->count; - const GLfloat m0 = m[0], m5 = m[5]; - const GLfloat m10 = m[10], m12 = m[12], m13 = m[13], m14 = m[14]; - GLuint i; - STRIDE_LOOP { - const GLfloat ox = from[0], oy = from[1], oz = from[2]; - to[i][0] = m0 * ox + m12 ; - to[i][1] = m5 * oy + m13 ; - to[i][2] = m10 * oz + m14 ; - } - to_vec->size = 3; - to_vec->flags |= VEC_SIZE_3; - to_vec->count = from_vec->count; -} - -static void _XFORMAPI -TAG(transform_points3_perspective)( GLvector4f *to_vec, - const GLfloat m[16], - const GLvector4f *from_vec ) -{ - const GLuint stride = from_vec->stride; - GLfloat *from = from_vec->start; - GLfloat (*to)[4] = (GLfloat (*)[4])to_vec->start; - GLuint count = from_vec->count; - const GLfloat m0 = m[0], m5 = m[5], m8 = m[8], m9 = m[9]; - const GLfloat m10 = m[10], m14 = m[14]; - GLuint i; - STRIDE_LOOP { - const GLfloat ox = from[0], oy = from[1], oz = from[2]; - to[i][0] = m0 * ox + m8 * oz ; - to[i][1] = m5 * oy + m9 * oz ; - to[i][2] = m10 * oz + m14 ; - to[i][3] = -oz ; - } - to_vec->size = 4; - to_vec->flags |= VEC_SIZE_4; - to_vec->count = from_vec->count; -} - - - -static void _XFORMAPI -TAG(transform_points4_general)( GLvector4f *to_vec, - const GLfloat m[16], - const GLvector4f *from_vec ) -{ - const GLuint stride = from_vec->stride; - GLfloat *from = from_vec->start; - GLfloat (*to)[4] = (GLfloat (*)[4])to_vec->start; - GLuint count = from_vec->count; - const GLfloat m0 = m[0], m4 = m[4], m8 = m[8], m12 = m[12]; - const GLfloat m1 = m[1], m5 = m[5], m9 = m[9], m13 = m[13]; - const GLfloat m2 = m[2], m6 = m[6], m10 = m[10], m14 = m[14]; - const GLfloat m3 = m[3], m7 = m[7], m11 = m[11], m15 = m[15]; - GLuint i; - STRIDE_LOOP { - const GLfloat ox = from[0], oy = from[1], oz = from[2], ow = from[3]; - to[i][0] = m0 * ox + m4 * oy + m8 * oz + m12 * ow; - to[i][1] = m1 * ox + m5 * oy + m9 * oz + m13 * ow; - to[i][2] = m2 * ox + m6 * oy + m10 * oz + m14 * ow; - to[i][3] = m3 * ox + m7 * oy + m11 * oz + m15 * ow; - } - to_vec->size = 4; - to_vec->flags |= VEC_SIZE_4; - to_vec->count = from_vec->count; -} - -static void _XFORMAPI -TAG(transform_points4_identity)( GLvector4f *to_vec, - const GLfloat m[16], - const GLvector4f *from_vec ) -{ - const GLuint stride = from_vec->stride; - GLfloat *from = from_vec->start; - GLfloat (*to)[4] = (GLfloat (*)[4])to_vec->start; - GLuint count = from_vec->count; - GLuint i; - (void) m; - if (to_vec == from_vec) return; - STRIDE_LOOP { - to[i][0] = from[0]; - to[i][1] = from[1]; - to[i][2] = from[2]; - to[i][3] = from[3]; - } - to_vec->size = 4; - to_vec->flags |= VEC_SIZE_4; - to_vec->count = from_vec->count; -} - -static void _XFORMAPI -TAG(transform_points4_2d)( GLvector4f *to_vec, - const GLfloat m[16], - const GLvector4f *from_vec ) -{ - const GLuint stride = from_vec->stride; - GLfloat *from = from_vec->start; - GLfloat (*to)[4] = (GLfloat (*)[4])to_vec->start; - GLuint count = from_vec->count; - const GLfloat m0 = m[0], m1 = m[1], m4 = m[4], m5 = m[5]; - const GLfloat m12 = m[12], m13 = m[13]; - GLuint i; - STRIDE_LOOP { - const GLfloat ox = from[0], oy = from[1], oz = from[2], ow = from[3]; - to[i][0] = m0 * ox + m4 * oy + m12 * ow; - to[i][1] = m1 * ox + m5 * oy + m13 * ow; - to[i][2] = + oz ; - to[i][3] = ow; - } - to_vec->size = 4; - to_vec->flags |= VEC_SIZE_4; - to_vec->count = from_vec->count; -} - -static void _XFORMAPI -TAG(transform_points4_2d_no_rot)( GLvector4f *to_vec, - const GLfloat m[16], - const GLvector4f *from_vec ) -{ - const GLuint stride = from_vec->stride; - GLfloat *from = from_vec->start; - GLfloat (*to)[4] = (GLfloat (*)[4])to_vec->start; - GLuint count = from_vec->count; - const GLfloat m0 = m[0], m5 = m[5], m12 = m[12], m13 = m[13]; - GLuint i; - STRIDE_LOOP { - const GLfloat ox = from[0], oy = from[1], oz = from[2], ow = from[3]; - to[i][0] = m0 * ox + m12 * ow; - to[i][1] = m5 * oy + m13 * ow; - to[i][2] = + oz ; - to[i][3] = ow; - } - to_vec->size = 4; - to_vec->flags |= VEC_SIZE_4; - to_vec->count = from_vec->count; -} - -static void _XFORMAPI -TAG(transform_points4_3d)( GLvector4f *to_vec, - const GLfloat m[16], - const GLvector4f *from_vec ) -{ - const GLuint stride = from_vec->stride; - GLfloat *from = from_vec->start; - GLfloat (*to)[4] = (GLfloat (*)[4])to_vec->start; - GLuint count = from_vec->count; - const GLfloat m0 = m[0], m1 = m[1], m2 = m[2], m4 = m[4], m5 = m[5]; - const GLfloat m6 = m[6], m8 = m[8], m9 = m[9], m10 = m[10]; - const GLfloat m12 = m[12], m13 = m[13], m14 = m[14]; - GLuint i; - STRIDE_LOOP { - const GLfloat ox = from[0], oy = from[1], oz = from[2], ow = from[3]; - to[i][0] = m0 * ox + m4 * oy + m8 * oz + m12 * ow; - to[i][1] = m1 * ox + m5 * oy + m9 * oz + m13 * ow; - to[i][2] = m2 * ox + m6 * oy + m10 * oz + m14 * ow; - to[i][3] = ow; - } - to_vec->size = 4; - to_vec->flags |= VEC_SIZE_4; - to_vec->count = from_vec->count; -} - -static void _XFORMAPI -TAG(transform_points4_3d_no_rot)( GLvector4f *to_vec, - const GLfloat m[16], - const GLvector4f *from_vec ) -{ - const GLuint stride = from_vec->stride; - GLfloat *from = from_vec->start; - GLfloat (*to)[4] = (GLfloat (*)[4])to_vec->start; - GLuint count = from_vec->count; - const GLfloat m0 = m[0], m5 = m[5]; - const GLfloat m10 = m[10], m12 = m[12], m13 = m[13], m14 = m[14]; - GLuint i; - STRIDE_LOOP { - const GLfloat ox = from[0], oy = from[1], oz = from[2], ow = from[3]; - to[i][0] = m0 * ox + m12 * ow; - to[i][1] = m5 * oy + m13 * ow; - to[i][2] = m10 * oz + m14 * ow; - to[i][3] = ow; - } - to_vec->size = 4; - to_vec->flags |= VEC_SIZE_4; - to_vec->count = from_vec->count; -} - -static void _XFORMAPI -TAG(transform_points4_perspective)( GLvector4f *to_vec, - const GLfloat m[16], - const GLvector4f *from_vec ) -{ - const GLuint stride = from_vec->stride; - GLfloat *from = from_vec->start; - GLfloat (*to)[4] = (GLfloat (*)[4])to_vec->start; - GLuint count = from_vec->count; - const GLfloat m0 = m[0], m5 = m[5], m8 = m[8], m9 = m[9]; - const GLfloat m10 = m[10], m14 = m[14]; - GLuint i; - STRIDE_LOOP { - const GLfloat ox = from[0], oy = from[1], oz = from[2], ow = from[3]; - to[i][0] = m0 * ox + m8 * oz ; - to[i][1] = m5 * oy + m9 * oz ; - to[i][2] = m10 * oz + m14 * ow ; - to[i][3] = -oz ; - } - to_vec->size = 4; - to_vec->flags |= VEC_SIZE_4; - to_vec->count = from_vec->count; -} - -static transform_func TAG(transform_tab_1)[7]; -static transform_func TAG(transform_tab_2)[7]; -static transform_func TAG(transform_tab_3)[7]; -static transform_func TAG(transform_tab_4)[7]; - -/* Similar functions could be called several times, with more highly - * optimized routines overwriting the arrays. This only occurs during - * startup. - */ -static void _XFORMAPI TAG(init_c_transformations)( void ) -{ -#define TAG_TAB _mesa_transform_tab -#define TAG_TAB_1 TAG(transform_tab_1) -#define TAG_TAB_2 TAG(transform_tab_2) -#define TAG_TAB_3 TAG(transform_tab_3) -#define TAG_TAB_4 TAG(transform_tab_4) - - TAG_TAB[1] = TAG_TAB_1; - TAG_TAB[2] = TAG_TAB_2; - TAG_TAB[3] = TAG_TAB_3; - TAG_TAB[4] = TAG_TAB_4; - - /* 1-D points (ie texcoords) */ - TAG_TAB_1[MATRIX_GENERAL] = TAG(transform_points1_general); - TAG_TAB_1[MATRIX_IDENTITY] = TAG(transform_points1_identity); - TAG_TAB_1[MATRIX_3D_NO_ROT] = TAG(transform_points1_3d_no_rot); - TAG_TAB_1[MATRIX_PERSPECTIVE] = TAG(transform_points1_perspective); - TAG_TAB_1[MATRIX_2D] = TAG(transform_points1_2d); - TAG_TAB_1[MATRIX_2D_NO_ROT] = TAG(transform_points1_2d_no_rot); - TAG_TAB_1[MATRIX_3D] = TAG(transform_points1_3d); - - /* 2-D points */ - TAG_TAB_2[MATRIX_GENERAL] = TAG(transform_points2_general); - TAG_TAB_2[MATRIX_IDENTITY] = TAG(transform_points2_identity); - TAG_TAB_2[MATRIX_3D_NO_ROT] = TAG(transform_points2_3d_no_rot); - TAG_TAB_2[MATRIX_PERSPECTIVE] = TAG(transform_points2_perspective); - TAG_TAB_2[MATRIX_2D] = TAG(transform_points2_2d); - TAG_TAB_2[MATRIX_2D_NO_ROT] = TAG(transform_points2_2d_no_rot); - TAG_TAB_2[MATRIX_3D] = TAG(transform_points2_3d); - - /* 3-D points */ - TAG_TAB_3[MATRIX_GENERAL] = TAG(transform_points3_general); - TAG_TAB_3[MATRIX_IDENTITY] = TAG(transform_points3_identity); - TAG_TAB_3[MATRIX_3D_NO_ROT] = TAG(transform_points3_3d_no_rot); - TAG_TAB_3[MATRIX_PERSPECTIVE] = TAG(transform_points3_perspective); - TAG_TAB_3[MATRIX_2D] = TAG(transform_points3_2d); - TAG_TAB_3[MATRIX_2D_NO_ROT] = TAG(transform_points3_2d_no_rot); - TAG_TAB_3[MATRIX_3D] = TAG(transform_points3_3d); - - /* 4-D points */ - TAG_TAB_4[MATRIX_GENERAL] = TAG(transform_points4_general); - TAG_TAB_4[MATRIX_IDENTITY] = TAG(transform_points4_identity); - TAG_TAB_4[MATRIX_3D_NO_ROT] = TAG(transform_points4_3d_no_rot); - TAG_TAB_4[MATRIX_PERSPECTIVE] = TAG(transform_points4_perspective); - TAG_TAB_4[MATRIX_2D] = TAG(transform_points4_2d); - TAG_TAB_4[MATRIX_2D_NO_ROT] = TAG(transform_points4_2d_no_rot); - TAG_TAB_4[MATRIX_3D] = TAG(transform_points4_3d); - -#undef TAG_TAB -#undef TAG_TAB_1 -#undef TAG_TAB_2 -#undef TAG_TAB_3 -#undef TAG_TAB_4 -} diff --git a/dll/opengl/mesa/math/precomp.h b/dll/opengl/mesa/math/precomp.h deleted file mode 100644 index 8ceb43f0484..00000000000 --- a/dll/opengl/mesa/math/precomp.h +++ /dev/null @@ -1,14 +0,0 @@ -#ifndef _MESA_MATH_PCH_ -#define _MESA_MATH_PCH_ - -#include
-#include
-#include
-#include
- -#include "m_eval.h" -#include "m_matrix.h" -#include "m_translate.h" -#include "m_xform.h" - -#endif /* _MESA_MATH_PCH_ */ diff --git a/dll/opengl/mesa/matrix.c b/dll/opengl/mesa/matrix.c new file mode 100644 index 00000000000..297607bd06d --- /dev/null +++ b/dll/opengl/mesa/matrix.c @@ -0,0 +1,1048 @@ +/* $Id: matrix.c,v 1.23 1997/12/29 23:48:53 brianp Exp $ */ + +/* + * Mesa 3-D graphics library + * Version: 2.6 + * Copyright (C) 1995-1997 Brian Paul + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Library General Public + * License as published by the Free Software Foundation; either + * version 2 of the License, or (at your option) any later version. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Library General Public License for more details. + * + * You should have received a copy of the GNU Library General Public + * License along with this library; if not, write to the Free + * Software Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. + */ + + +/* + * $Log: matrix.c,v $ + * Revision 1.23 1997/12/29 23:48:53 brianp + * call Driver.NearFar() in gl_LoadMatrixf() for projection matrix + * + * Revision 1.22 1997/10/16 23:37:23 brianp + * fixed scotter's email address + * + * Revision 1.21 1997/08/13 01:54:34 brianp + * new matrix invert code from Scott McCaskill + * + * Revision 1.20 1997/07/24 01:23:16 brianp + * changed precompiled header symbol from PCH to PC_HEADER + * + * Revision 1.19 1997/05/30 02:21:43 brianp + * gl_PopMatrix() set ctx->New*Matrix flag incorrectly + * + * Revision 1.18 1997/05/28 04:06:03 brianp + * implemented projection near/far value stack for Driver.NearFar() function + * + * Revision 1.17 1997/05/28 03:25:43 brianp + * added precompiled header (PCH) support + * + * Revision 1.16 1997/05/01 01:39:40 brianp + * replace sqrt() with GL_SQRT() + * + * Revision 1.15 1997/04/21 01:20:41 brianp + * added MATRIX_2D_NO_ROT + * + * Revision 1.14 1997/04/20 20:28:49 brianp + * replaced abort() with gl_problem() + * + * Revision 1.13 1997/04/20 16:31:08 brianp + * added NearFar device driver function + * + * Revision 1.12 1997/04/20 16:18:15 brianp + * added glOrtho and glFrustum API pointers + * + * Revision 1.11 1997/04/01 04:23:53 brianp + * added gl_analyze_*_matrix() functions + * + * Revision 1.10 1997/02/10 19:47:53 brianp + * moved buffer resize code out of gl_Viewport() into gl_ResizeBuffersMESA() + * + * Revision 1.9 1997/01/31 23:32:40 brianp + * now clear depth buffer after reallocation due to window resize + * + * Revision 1.8 1997/01/29 19:06:04 brianp + * removed extra, local definition of Identity[] matrix + * + * Revision 1.7 1997/01/28 22:19:17 brianp + * new matrix inversion code from Stephane Rehel + * + * Revision 1.6 1996/12/22 17:53:11 brianp + * faster invert_matrix() function from scotter@iname.com + * + * Revision 1.5 1996/12/02 18:58:34 brianp + * gl_rotation_matrix() now returns identity matrix if given a 0 rotation axis + * + * Revision 1.4 1996/09/27 01:29:05 brianp + * added missing default cases to switches + * + * Revision 1.3 1996/09/15 14:18:37 brianp + * now use GLframebuffer and GLvisual + * + * Revision 1.2 1996/09/14 06:46:04 brianp + * better matmul() from Jacques Leroy + * + * Revision 1.1 1996/09/13 01:38:16 brianp + * Initial revision + * + */ + + +/* + * Matrix operations + * + * + * NOTES: + * 1. 4x4 transformation matrices are stored in memory in column major order. + * 2. Points/vertices are to be thought of as column vectors. + * 3. Transformation of a point p by a matrix M is: p' = M * p + * + */ + + +#ifdef PC_HEADER +#include "all.h" +#else +#include +#include +#include +#include +#include "context.h" +#include "dlist.h" +#include "macros.h" +#include "matrix.h" +#include "mmath.h" +#include "types.h" +#endif + + + +static GLfloat Identity[16] = { + 1.0, 0.0, 0.0, 0.0, + 0.0, 1.0, 0.0, 0.0, + 0.0, 0.0, 1.0, 0.0, + 0.0, 0.0, 0.0, 1.0 +}; + + +#if 0 +static void print_matrix( const GLfloat m[16] ) +{ + int i; + + for (i=0;i<4;i++) { + printf("%f %f %f %f\n", m[i], m[4+i], m[8+i], m[12+i] ); + } +} +#endif + + +/* + * Perform a 4x4 matrix multiplication (product = a x b). + * Input: a, b - matrices to multiply + * Output: product - product of a and b + * WARNING: (product != b) assumed + * NOTE: (product == a) allowed + */ +static void matmul( GLfloat *product, const GLfloat *a, const GLfloat *b ) +{ + /* This matmul was contributed by Thomas Malik */ + GLint i; + +#define A(row,col) a[(col<<2)+row] +#define B(row,col) b[(col<<2)+row] +#define P(row,col) product[(col<<2)+row] + + /* i-te Zeile */ + for (i = 0; i < 4; i++) { + GLfloat ai0=A(i,0), ai1=A(i,1), ai2=A(i,2), ai3=A(i,3); + P(i,0) = ai0 * B(0,0) + ai1 * B(1,0) + ai2 * B(2,0) + ai3 * B(3,0); + P(i,1) = ai0 * B(0,1) + ai1 * B(1,1) + ai2 * B(2,1) + ai3 * B(3,1); + P(i,2) = ai0 * B(0,2) + ai1 * B(1,2) + ai2 * B(2,2) + ai3 * B(3,2); + P(i,3) = ai0 * B(0,3) + ai1 * B(1,3) + ai2 * B(2,3) + ai3 * B(3,3); + } + +#undef A +#undef B +#undef P +} + + + +/* + * Compute the inverse of a 4x4 matrix. + * + * From an algorithm by V. Strassen, 1969, _Numerishe Mathematik_, vol. 13, + * pp. 354-356. + * 60 multiplies, 24 additions, 10 subtractions, 8 negations, 2 divisions, + * 48 assignments, _0_ branches + * + * This implementation by Scott McCaskill + */ + +typedef GLfloat Mat2[2][2]; + +enum { + M00 = 0, M01 = 4, M02 = 8, M03 = 12, + M10 = 1, M11 = 5, M12 = 9, M13 = 13, + M20 = 2, M21 = 6, M22 = 10,M23 = 14, + M30 = 3, M31 = 7, M32 = 11,M33 = 15 +}; + +static void invert_matrix_general( const GLfloat *m, GLfloat *out ) +{ + Mat2 r1, r2, r3, r4, r5, r6, r7; + const GLfloat * A = m; + GLfloat * C = out; + GLfloat one_over_det; + + /* + * A is the 4x4 source matrix (to be inverted). + * C is the 4x4 destination matrix + * a11 is the 2x2 matrix in the upper left quadrant of A + * a12 is the 2x2 matrix in the upper right quadrant of A + * a21 is the 2x2 matrix in the lower left quadrant of A + * a22 is the 2x2 matrix in the lower right quadrant of A + * similarly, cXX are the 2x2 quadrants of the destination matrix + */ + + /* R1 = inverse( a11 ) */ + one_over_det = 1.0f / ( ( A[M00] * A[M11] ) - ( A[M10] * A[M01] ) ); + r1[0][0] = one_over_det * A[M11]; + r1[0][1] = one_over_det * -A[M01]; + r1[1][0] = one_over_det * -A[M10]; + r1[1][1] = one_over_det * A[M00]; + + /* R2 = a21 x R1 */ + r2[0][0] = A[M20] * r1[0][0] + A[M21] * r1[1][0]; + r2[0][1] = A[M20] * r1[0][1] + A[M21] * r1[1][1]; + r2[1][0] = A[M30] * r1[0][0] + A[M31] * r1[1][0]; + r2[1][1] = A[M30] * r1[0][1] + A[M31] * r1[1][1]; + + /* R3 = R1 x a12 */ + r3[0][0] = r1[0][0] * A[M02] + r1[0][1] * A[M12]; + r3[0][1] = r1[0][0] * A[M03] + r1[0][1] * A[M13]; + r3[1][0] = r1[1][0] * A[M02] + r1[1][1] * A[M12]; + r3[1][1] = r1[1][0] * A[M03] + r1[1][1] * A[M13]; + + /* R4 = a21 x R3 */ + r4[0][0] = A[M20] * r3[0][0] + A[M21] * r3[1][0]; + r4[0][1] = A[M20] * r3[0][1] + A[M21] * r3[1][1]; + r4[1][0] = A[M30] * r3[0][0] + A[M31] * r3[1][0]; + r4[1][1] = A[M30] * r3[0][1] + A[M31] * r3[1][1]; + + /* R5 = R4 - a22 */ + r5[0][0] = r4[0][0] - A[M22]; + r5[0][1] = r4[0][1] - A[M23]; + r5[1][0] = r4[1][0] - A[M32]; + r5[1][1] = r4[1][1] - A[M33]; + + /* R6 = inverse( R5 ) */ + one_over_det = 1.0f / ( ( r5[0][0] * r5[1][1] ) - ( r5[1][0] * r5[0][1] ) ); + r6[0][0] = one_over_det * r5[1][1]; + r6[0][1] = one_over_det * -r5[0][1]; + r6[1][0] = one_over_det * -r5[1][0]; + r6[1][1] = one_over_det * r5[0][0]; + + /* c12 = R3 x R6 */ + C[M02] = r3[0][0] * r6[0][0] + r3[0][1] * r6[1][0]; + C[M03] = r3[0][0] * r6[0][1] + r3[0][1] * r6[1][1]; + C[M12] = r3[1][0] * r6[0][0] + r3[1][1] * r6[1][0]; + C[M13] = r3[1][0] * r6[0][1] + r3[1][1] * r6[1][1]; + + /* c21 = R6 x R2 */ + C[M20] = r6[0][0] * r2[0][0] + r6[0][1] * r2[1][0]; + C[M21] = r6[0][0] * r2[0][1] + r6[0][1] * r2[1][1]; + C[M30] = r6[1][0] * r2[0][0] + r6[1][1] * r2[1][0]; + C[M31] = r6[1][0] * r2[0][1] + r6[1][1] * r2[1][1]; + + /* R7 = R3 x c21 */ + r7[0][0] = r3[0][0] * C[M20] + r3[0][1] * C[M30]; + r7[0][1] = r3[0][0] * C[M21] + r3[0][1] * C[M31]; + r7[1][0] = r3[1][0] * C[M20] + r3[1][1] * C[M30]; + r7[1][1] = r3[1][0] * C[M21] + r3[1][1] * C[M31]; + + /* c11 = R1 - R7 */ + C[M00] = r1[0][0] - r7[0][0]; + C[M01] = r1[0][1] - r7[0][1]; + C[M10] = r1[1][0] - r7[1][0]; + C[M11] = r1[1][1] - r7[1][1]; + + /* c22 = -R6 */ + C[M22] = -r6[0][0]; + C[M23] = -r6[0][1]; + C[M32] = -r6[1][0]; + C[M33] = -r6[1][1]; +} + + +/* + * Invert matrix m. This algorithm contributed by Stephane Rehel + * + */ +static void invert_matrix( const GLfloat *m, GLfloat *out ) +{ +/* NB. OpenGL Matrices are COLUMN major. */ +#define MAT(m,r,c) (m)[(c)*4+(r)] + +/* Here's some shorthand converting standard (row,column) to index. */ +#define m11 MAT(m,0,0) +#define m12 MAT(m,0,1) +#define m13 MAT(m,0,2) +#define m14 MAT(m,0,3) +#define m21 MAT(m,1,0) +#define m22 MAT(m,1,1) +#define m23 MAT(m,1,2) +#define m24 MAT(m,1,3) +#define m31 MAT(m,2,0) +#define m32 MAT(m,2,1) +#define m33 MAT(m,2,2) +#define m34 MAT(m,2,3) +#define m41 MAT(m,3,0) +#define m42 MAT(m,3,1) +#define m43 MAT(m,3,2) +#define m44 MAT(m,3,3) + + register GLfloat det; + GLfloat tmp[16]; /* Allow out == in. */ + + if( m41 != 0. || m42 != 0. || m43 != 0. || m44 != 1. ) { + invert_matrix_general(m, out); + return; + } + + /* Inverse = adjoint / det. (See linear algebra texts.)*/ + + tmp[0]= m22 * m33 - m23 * m32; + tmp[1]= m23 * m31 - m21 * m33; + tmp[2]= m21 * m32 - m22 * m31; + + /* Compute determinant as early as possible using these cofactors. */ + det= m11 * tmp[0] + m12 * tmp[1] + m13 * tmp[2]; + + /* Run singularity test. */ + if (det == 0.0F) { + /* printf("invert_matrix: Warning: Singular matrix.\n"); */ + MEMCPY( out, Identity, 16*sizeof(GLfloat) ); + } + else { + GLfloat d12, d13, d23, d24, d34, d41; + register GLfloat im11, im12, im13, im14; + + det= 1. / det; + + /* Compute rest of inverse. */ + tmp[0] *= det; + tmp[1] *= det; + tmp[2] *= det; + tmp[3] = 0.; + + im11= m11 * det; + im12= m12 * det; + im13= m13 * det; + im14= m14 * det; + tmp[4] = im13 * m32 - im12 * m33; + tmp[5] = im11 * m33 - im13 * m31; + tmp[6] = im12 * m31 - im11 * m32; + tmp[7] = 0.; + + /* Pre-compute 2x2 dets for first two rows when computing */ + /* cofactors of last two rows. */ + d12 = im11*m22 - m21*im12; + d13 = im11*m23 - m21*im13; + d23 = im12*m23 - m22*im13; + d24 = im12*m24 - m22*im14; + d34 = im13*m24 - m23*im14; + d41 = im14*m21 - m24*im11; + + tmp[8] = d23; + tmp[9] = -d13; + tmp[10] = d12; + tmp[11] = 0.; + + tmp[12] = -(m32 * d34 - m33 * d24 + m34 * d23); + tmp[13] = (m31 * d34 + m33 * d41 + m34 * d13); + tmp[14] = -(m31 * d24 + m32 * d41 + m34 * d12); + tmp[15] = 1.; + + MEMCPY(out, tmp, 16*sizeof(GLfloat)); + } + +#undef m11 +#undef m12 +#undef m13 +#undef m14 +#undef m21 +#undef m22 +#undef m23 +#undef m24 +#undef m31 +#undef m32 +#undef m33 +#undef m34 +#undef m41 +#undef m42 +#undef m43 +#undef m44 +#undef MAT +} + + + +/* + * Determine if the given matrix is the identity matrix. + */ +static GLboolean is_identity( const GLfloat m[16] ) +{ + if ( m[0]==1.0F && m[4]==0.0F && m[ 8]==0.0F && m[12]==0.0F + && m[1]==0.0F && m[5]==1.0F && m[ 9]==0.0F && m[13]==0.0F + && m[2]==0.0F && m[6]==0.0F && m[10]==1.0F && m[14]==0.0F + && m[3]==0.0F && m[7]==0.0F && m[11]==0.0F && m[15]==1.0F) { + return GL_TRUE; + } + else { + return GL_FALSE; + } +} + + +/* + * Examine the current modelview matrix to determine its type. + * Later we use the matrix type to optimize vertex transformations. + */ +void gl_analyze_modelview_matrix( GLcontext *ctx ) +{ + const GLfloat *m = ctx->ModelViewMatrix; + if (is_identity(m)) { + ctx->ModelViewMatrixType = MATRIX_IDENTITY; + } + else if ( m[4]==0.0F && m[ 8]==0.0F + && m[1]==0.0F && m[ 9]==0.0F + && m[2]==0.0F && m[6]==0.0F && m[10]==1.0F && m[14]==0.0F + && m[3]==0.0F && m[7]==0.0F && m[11]==0.0F && m[15]==1.0F) { + ctx->ModelViewMatrixType = MATRIX_2D_NO_ROT; + } + else if ( m[ 8]==0.0F + && m[ 9]==0.0F + && m[2]==0.0F && m[6]==0.0F && m[10]==1.0F && m[14]==0.0F + && m[3]==0.0F && m[7]==0.0F && m[11]==0.0F && m[15]==1.0F) { + ctx->ModelViewMatrixType = MATRIX_2D; + } + else if (m[3]==0.0F && m[7]==0.0F && m[11]==0.0F && m[15]==1.0F) { + ctx->ModelViewMatrixType = MATRIX_3D; + } + else { + ctx->ModelViewMatrixType = MATRIX_GENERAL; + } + + invert_matrix( ctx->ModelViewMatrix, ctx->ModelViewInv ); + ctx->NewModelViewMatrix = GL_FALSE; +} + + + +/* + * Examine the current projection matrix to determine its type. + * Later we use the matrix type to optimize vertex transformations. + */ +void gl_analyze_projection_matrix( GLcontext *ctx ) +{ + /* look for common-case ortho and perspective matrices */ + const GLfloat *m = ctx->ProjectionMatrix; + if (is_identity(m)) { + ctx->ProjectionMatrixType = MATRIX_IDENTITY; + } + else if ( m[4]==0.0F && m[8] ==0.0F + && m[1]==0.0F && m[9] ==0.0F + && m[2]==0.0F && m[6]==0.0F + && m[3]==0.0F && m[7]==0.0F && m[11]==0.0F && m[15]==1.0F) { + ctx->ProjectionMatrixType = MATRIX_ORTHO; + } + else if ( m[4]==0.0F && m[12]==0.0F + && m[1]==0.0F && m[13]==0.0F + && m[2]==0.0F && m[6]==0.0F + && m[3]==0.0F && m[7]==0.0F && m[11]==-1.0F && m[15]==0.0F) { + ctx->ProjectionMatrixType = MATRIX_PERSPECTIVE; + } + else { + ctx->ProjectionMatrixType = MATRIX_GENERAL; + } + + ctx->NewProjectionMatrix = GL_FALSE; +} + + + +/* + * Examine the current texture matrix to determine its type. + * Later we use the matrix type to optimize texture coordinate transformations. + */ +void gl_analyze_texture_matrix( GLcontext *ctx ) +{ + const GLfloat *m = ctx->TextureMatrix; + if (is_identity(m)) { + ctx->TextureMatrixType = MATRIX_IDENTITY; + } + else if ( m[ 8]==0.0F + && m[ 9]==0.0F + && m[2]==0.0F && m[6]==0.0F && m[10]==1.0F && m[14]==0.0F + && m[3]==0.0F && m[7]==0.0F && m[11]==0.0F && m[15]==1.0F) { + ctx->TextureMatrixType = MATRIX_2D; + } + else if (m[3]==0.0F && m[7]==0.0F && m[11]==0.0F && m[15]==1.0F) { + ctx->TextureMatrixType = MATRIX_3D; + } + else { + ctx->TextureMatrixType = MATRIX_GENERAL; + } + + ctx->NewTextureMatrix = GL_FALSE; +} + + + +void gl_Frustum( GLcontext *ctx, + GLdouble left, GLdouble right, + GLdouble bottom, GLdouble top, + GLdouble nearval, GLdouble farval ) +{ + GLfloat x, y, a, b, c, d; + GLfloat m[16]; + + if (nearval<=0.0 || farval<=0.0) { + gl_error( ctx, GL_INVALID_VALUE, "glFrustum(near or far)" ); + } + + x = (2.0*nearval) / (right-left); + y = (2.0*nearval) / (top-bottom); + a = (right+left) / (right-left); + b = (top+bottom) / (top-bottom); + c = -(farval+nearval) / ( farval-nearval); + d = -(2.0*farval*nearval) / (farval-nearval); /* error? */ + +#define M(row,col) m[col*4+row] + M(0,0) = x; M(0,1) = 0.0F; M(0,2) = a; M(0,3) = 0.0F; + M(1,0) = 0.0F; M(1,1) = y; M(1,2) = b; M(1,3) = 0.0F; + M(2,0) = 0.0F; M(2,1) = 0.0F; M(2,2) = c; M(2,3) = d; + M(3,0) = 0.0F; M(3,1) = 0.0F; M(3,2) = -1.0F; M(3,3) = 0.0F; +#undef M + + gl_MultMatrixf( ctx, m ); + + + /* Need to keep a stack of near/far values in case the user push/pops + * the projection matrix stack so that we can call Driver.NearFar() + * after a pop. + */ + ctx->NearFarStack[ctx->ProjectionStackDepth][0] = nearval; + ctx->NearFarStack[ctx->ProjectionStackDepth][1] = farval; + + if (ctx->Driver.NearFar) { + (*ctx->Driver.NearFar)( ctx, nearval, farval ); + } +} + + +void gl_Ortho( GLcontext *ctx, + GLdouble left, GLdouble right, + GLdouble bottom, GLdouble top, + GLdouble nearval, GLdouble farval ) +{ + GLfloat x, y, z; + GLfloat tx, ty, tz; + GLfloat m[16]; + + x = 2.0 / (right-left); + y = 2.0 / (top-bottom); + z = -2.0 / (farval-nearval); + tx = -(right+left) / (right-left); + ty = -(top+bottom) / (top-bottom); + tz = -(farval+nearval) / (farval-nearval); + +#define M(row,col) m[col*4+row] + M(0,0) = x; M(0,1) = 0.0F; M(0,2) = 0.0F; M(0,3) = tx; + M(1,0) = 0.0F; M(1,1) = y; M(1,2) = 0.0F; M(1,3) = ty; + M(2,0) = 0.0F; M(2,1) = 0.0F; M(2,2) = z; M(2,3) = tz; + M(3,0) = 0.0F; M(3,1) = 0.0F; M(3,2) = 0.0F; M(3,3) = 1.0F; +#undef M + + gl_MultMatrixf( ctx, m ); + + if (ctx->Driver.NearFar) { + (*ctx->Driver.NearFar)( ctx, nearval, farval ); + } +} + + +void gl_MatrixMode( GLcontext *ctx, GLenum mode ) +{ + if (INSIDE_BEGIN_END(ctx)) { + gl_error( ctx, GL_INVALID_OPERATION, "glMatrixMode" ); + return; + } + switch (mode) { + case GL_MODELVIEW: + case GL_PROJECTION: + case GL_TEXTURE: + ctx->Transform.MatrixMode = mode; + break; + default: + gl_error( ctx, GL_INVALID_ENUM, "glMatrixMode" ); + } +} + + + +void gl_PushMatrix( GLcontext *ctx ) +{ + if (INSIDE_BEGIN_END(ctx)) { + gl_error( ctx, GL_INVALID_OPERATION, "glPushMatrix" ); + return; + } + switch (ctx->Transform.MatrixMode) { + case GL_MODELVIEW: + if (ctx->ModelViewStackDepth>=MAX_MODELVIEW_STACK_DEPTH-1) { + gl_error( ctx, GL_STACK_OVERFLOW, "glPushMatrix"); + return; + } + MEMCPY( ctx->ModelViewStack[ctx->ModelViewStackDepth], + ctx->ModelViewMatrix, + 16*sizeof(GLfloat) ); + ctx->ModelViewStackDepth++; + break; + case GL_PROJECTION: + if (ctx->ProjectionStackDepth>=MAX_PROJECTION_STACK_DEPTH) { + gl_error( ctx, GL_STACK_OVERFLOW, "glPushMatrix"); + return; + } + MEMCPY( ctx->ProjectionStack[ctx->ProjectionStackDepth], + ctx->ProjectionMatrix, + 16*sizeof(GLfloat) ); + ctx->ProjectionStackDepth++; + + /* Save near and far projection values */ + ctx->NearFarStack[ctx->ProjectionStackDepth][0] + = ctx->NearFarStack[ctx->ProjectionStackDepth-1][0]; + ctx->NearFarStack[ctx->ProjectionStackDepth][1] + = ctx->NearFarStack[ctx->ProjectionStackDepth-1][1]; + break; + case GL_TEXTURE: + if (ctx->TextureStackDepth>=MAX_TEXTURE_STACK_DEPTH) { + gl_error( ctx, GL_STACK_OVERFLOW, "glPushMatrix"); + return; + } + MEMCPY( ctx->TextureStack[ctx->TextureStackDepth], + ctx->TextureMatrix, + 16*sizeof(GLfloat) ); + ctx->TextureStackDepth++; + break; + default: + gl_problem(ctx, "Bad matrix mode in gl_PushMatrix"); + } +} + + + +void gl_PopMatrix( GLcontext *ctx ) +{ + if (INSIDE_BEGIN_END(ctx)) { + gl_error( ctx, GL_INVALID_OPERATION, "glPopMatrix" ); + return; + } + switch (ctx->Transform.MatrixMode) { + case GL_MODELVIEW: + if (ctx->ModelViewStackDepth==0) { + gl_error( ctx, GL_STACK_UNDERFLOW, "glPopMatrix"); + return; + } + ctx->ModelViewStackDepth--; + MEMCPY( ctx->ModelViewMatrix, + ctx->ModelViewStack[ctx->ModelViewStackDepth], + 16*sizeof(GLfloat) ); + ctx->NewModelViewMatrix = GL_TRUE; + break; + case GL_PROJECTION: + if (ctx->ProjectionStackDepth==0) { + gl_error( ctx, GL_STACK_UNDERFLOW, "glPopMatrix"); + return; + } + ctx->ProjectionStackDepth--; + MEMCPY( ctx->ProjectionMatrix, + ctx->ProjectionStack[ctx->ProjectionStackDepth], + 16*sizeof(GLfloat) ); + ctx->NewProjectionMatrix = GL_TRUE; + + /* Device driver near/far values */ + { + GLfloat nearVal = ctx->NearFarStack[ctx->ProjectionStackDepth][0]; + GLfloat farVal = ctx->NearFarStack[ctx->ProjectionStackDepth][1]; + if (ctx->Driver.NearFar) { + (*ctx->Driver.NearFar)( ctx, nearVal, farVal ); + } + } + break; + case GL_TEXTURE: + if (ctx->TextureStackDepth==0) { + gl_error( ctx, GL_STACK_UNDERFLOW, "glPopMatrix"); + return; + } + ctx->TextureStackDepth--; + MEMCPY( ctx->TextureMatrix, + ctx->TextureStack[ctx->TextureStackDepth], + 16*sizeof(GLfloat) ); + ctx->NewTextureMatrix = GL_TRUE; + break; + default: + gl_problem(ctx, "Bad matrix mode in gl_PopMatrix"); + } +} + + + +void gl_LoadIdentity( GLcontext *ctx ) +{ + if (INSIDE_BEGIN_END(ctx)) { + gl_error( ctx, GL_INVALID_OPERATION, "glLoadIdentity" ); + return; + } + switch (ctx->Transform.MatrixMode) { + case GL_MODELVIEW: + MEMCPY( ctx->ModelViewMatrix, Identity, 16*sizeof(GLfloat) ); + MEMCPY( ctx->ModelViewInv, Identity, 16*sizeof(GLfloat) ); + ctx->ModelViewMatrixType = MATRIX_IDENTITY; + ctx->NewModelViewMatrix = GL_FALSE; + break; + case GL_PROJECTION: + MEMCPY( ctx->ProjectionMatrix, Identity, 16*sizeof(GLfloat) ); + ctx->ProjectionMatrixType = MATRIX_IDENTITY; + ctx->NewProjectionMatrix = GL_FALSE; + break; + case GL_TEXTURE: + MEMCPY( ctx->TextureMatrix, Identity, 16*sizeof(GLfloat) ); + ctx->TextureMatrixType = MATRIX_IDENTITY; + ctx->NewTextureMatrix = GL_FALSE; + break; + default: + gl_problem(ctx, "Bad matrix mode in gl_LoadIdentity"); + } +} + + +void gl_LoadMatrixf( GLcontext *ctx, const GLfloat *m ) +{ + if (INSIDE_BEGIN_END(ctx)) { + gl_error( ctx, GL_INVALID_OPERATION, "glLoadMatrix" ); + return; + } + switch (ctx->Transform.MatrixMode) { + case GL_MODELVIEW: + MEMCPY( ctx->ModelViewMatrix, m, 16*sizeof(GLfloat) ); + ctx->NewModelViewMatrix = GL_TRUE; + break; + case GL_PROJECTION: + MEMCPY( ctx->ProjectionMatrix, m, 16*sizeof(GLfloat) ); + ctx->NewProjectionMatrix = GL_TRUE; + { + float n,f,c,d; + +#define M(row,col) m[col*4+row] + c = M(2,2); + d = M(2,3); +#undef M + n = d / (c-1); + f = d / (c+1); + + /* Need to keep a stack of near/far values in case the user + * push/pops the projection matrix stack so that we can call + * Driver.NearFar() after a pop. + */ + ctx->NearFarStack[ctx->ProjectionStackDepth][0] = n; + ctx->NearFarStack[ctx->ProjectionStackDepth][1] = f; + + if (ctx->Driver.NearFar) { + (*ctx->Driver.NearFar)( ctx, n, f ); + } + } + break; + case GL_TEXTURE: + MEMCPY( ctx->TextureMatrix, m, 16*sizeof(GLfloat) ); + ctx->NewTextureMatrix = GL_TRUE; + break; + default: + gl_problem(ctx, "Bad matrix mode in gl_LoadMatrixf"); + } +} + + + +void gl_MultMatrixf( GLcontext *ctx, const GLfloat *m ) +{ + if (INSIDE_BEGIN_END(ctx)) { + gl_error( ctx, GL_INVALID_OPERATION, "glMultMatrix" ); + return; + } + switch (ctx->Transform.MatrixMode) { + case GL_MODELVIEW: + matmul( ctx->ModelViewMatrix, ctx->ModelViewMatrix, m ); + ctx->NewModelViewMatrix = GL_TRUE; + break; + case GL_PROJECTION: + matmul( ctx->ProjectionMatrix, ctx->ProjectionMatrix, m ); + ctx->NewProjectionMatrix = GL_TRUE; + break; + case GL_TEXTURE: + matmul( ctx->TextureMatrix, ctx->TextureMatrix, m ); + ctx->NewTextureMatrix = GL_TRUE; + break; + default: + gl_problem(ctx, "Bad matrix mode in gl_MultMatrixf"); + } +} + + + +/* + * Generate a 4x4 transformation matrix from glRotate parameters. + */ +void gl_rotation_matrix( GLfloat angle, GLfloat x, GLfloat y, GLfloat z, + GLfloat m[] ) +{ + /* This function contributed by Erich Boleyn (erich@uruk.org) */ + GLfloat mag, s, c; + GLfloat xx, yy, zz, xy, yz, zx, xs, ys, zs, one_c; + + s = sin( angle * DEG2RAD ); + c = cos( angle * DEG2RAD ); + + mag = GL_SQRT( x*x + y*y + z*z ); + + if (mag == 0.0) { + /* generate an identity matrix and return */ + MEMCPY(m, Identity, sizeof(GLfloat)*16); + return; + } + + x /= mag; + y /= mag; + z /= mag; + +#define M(row,col) m[col*4+row] + + /* + * Arbitrary axis rotation matrix. + * + * This is composed of 5 matrices, Rz, Ry, T, Ry', Rz', multiplied + * like so: Rz * Ry * T * Ry' * Rz'. T is the final rotation + * (which is about the X-axis), and the two composite transforms + * Ry' * Rz' and Rz * Ry are (respectively) the rotations necessary + * from the arbitrary axis to the X-axis then back. They are + * all elementary rotations. + * + * Rz' is a rotation about the Z-axis, to bring the axis vector + * into the x-z plane. Then Ry' is applied, rotating about the + * Y-axis to bring the axis vector parallel with the X-axis. The + * rotation about the X-axis is then performed. Ry and Rz are + * simply the respective inverse transforms to bring the arbitrary + * axis back to it's original orientation. The first transforms + * Rz' and Ry' are considered inverses, since the data from the + * arbitrary axis gives you info on how to get to it, not how + * to get away from it, and an inverse must be applied. + * + * The basic calculation used is to recognize that the arbitrary + * axis vector (x, y, z), since it is of unit length, actually + * represents the sines and cosines of the angles to rotate the + * X-axis to the same orientation, with theta being the angle about + * Z and phi the angle about Y (in the order described above) + * as follows: + * + * cos ( theta ) = x / sqrt ( 1 - z^2 ) + * sin ( theta ) = y / sqrt ( 1 - z^2 ) + * + * cos ( phi ) = sqrt ( 1 - z^2 ) + * sin ( phi ) = z + * + * Note that cos ( phi ) can further be inserted to the above + * formulas: + * + * cos ( theta ) = x / cos ( phi ) + * sin ( theta ) = y / sin ( phi ) + * + * ...etc. Because of those relations and the standard trigonometric + * relations, it is pssible to reduce the transforms down to what + * is used below. It may be that any primary axis chosen will give the + * same results (modulo a sign convention) using thie method. + * + * Particularly nice is to notice that all divisions that might + * have caused trouble when parallel to certain planes or + * axis go away with care paid to reducing the expressions. + * After checking, it does perform correctly under all cases, since + * in all the cases of division where the denominator would have + * been zero, the numerator would have been zero as well, giving + * the expected result. + */ + + xx = x * x; + yy = y * y; + zz = z * z; + xy = x * y; + yz = y * z; + zx = z * x; + xs = x * s; + ys = y * s; + zs = z * s; + one_c = 1.0F - c; + + M(0,0) = (one_c * xx) + c; + M(0,1) = (one_c * xy) - zs; + M(0,2) = (one_c * zx) + ys; + M(0,3) = 0.0F; + + M(1,0) = (one_c * xy) + zs; + M(1,1) = (one_c * yy) + c; + M(1,2) = (one_c * yz) - xs; + M(1,3) = 0.0F; + + M(2,0) = (one_c * zx) - ys; + M(2,1) = (one_c * yz) + xs; + M(2,2) = (one_c * zz) + c; + M(2,3) = 0.0F; + + M(3,0) = 0.0F; + M(3,1) = 0.0F; + M(3,2) = 0.0F; + M(3,3) = 1.0F; + +#undef M +} + + + +void gl_Rotatef( GLcontext *ctx, + GLfloat angle, GLfloat x, GLfloat y, GLfloat z ) +{ + GLfloat m[16]; + gl_rotation_matrix( angle, x, y, z, m ); + gl_MultMatrixf( ctx, m ); +} + + + +/* + * Execute a glScale call + */ +void gl_Scalef( GLcontext *ctx, GLfloat x, GLfloat y, GLfloat z ) +{ + GLfloat *m; + + if (INSIDE_BEGIN_END(ctx)) { + gl_error( ctx, GL_INVALID_OPERATION, "glScale" ); + return; + } + switch (ctx->Transform.MatrixMode) { + case GL_MODELVIEW: + m = ctx->ModelViewMatrix; + ctx->NewModelViewMatrix = GL_TRUE; + break; + case GL_PROJECTION: + m = ctx->ProjectionMatrix; + ctx->NewProjectionMatrix = GL_TRUE; + break; + case GL_TEXTURE: + m = ctx->TextureMatrix; + ctx->NewTextureMatrix = GL_TRUE; + break; + default: + gl_problem(ctx, "Bad matrix mode in gl_Scalef"); + return; + } + m[0] *= x; m[4] *= y; m[8] *= z; + m[1] *= x; m[5] *= y; m[9] *= z; + m[2] *= x; m[6] *= y; m[10] *= z; + m[3] *= x; m[7] *= y; m[11] *= z; +} + + + +/* + * Execute a glTranslate call + */ +void gl_Translatef( GLcontext *ctx, GLfloat x, GLfloat y, GLfloat z ) +{ + GLfloat *m; + if (INSIDE_BEGIN_END(ctx)) { + gl_error( ctx, GL_INVALID_OPERATION, "glTranslate" ); + return; + } + switch (ctx->Transform.MatrixMode) { + case GL_MODELVIEW: + m = ctx->ModelViewMatrix; + ctx->NewModelViewMatrix = GL_TRUE; + break; + case GL_PROJECTION: + m = ctx->ProjectionMatrix; + ctx->NewProjectionMatrix = GL_TRUE; + break; + case GL_TEXTURE: + m = ctx->TextureMatrix; + ctx->NewTextureMatrix = GL_TRUE; + break; + default: + gl_problem(ctx, "Bad matrix mode in gl_Translatef"); + return; + } + + m[12] = m[0] * x + m[4] * y + m[8] * z + m[12]; + m[13] = m[1] * x + m[5] * y + m[9] * z + m[13]; + m[14] = m[2] * x + m[6] * y + m[10] * z + m[14]; + m[15] = m[3] * x + m[7] * y + m[11] * z + m[15]; +} + + + + +/* + * Define a new viewport and reallocate auxillary buffers if the size of + * the window (color buffer) has changed. + */ +void gl_Viewport( GLcontext *ctx, + GLint x, GLint y, GLsizei width, GLsizei height ) +{ + if (width<0 || height<0) { + gl_error( ctx, GL_INVALID_VALUE, "glViewport" ); + return; + } + if (INSIDE_BEGIN_END(ctx)) { + gl_error( ctx, GL_INVALID_OPERATION, "glViewport" ); + return; + } + + /* clamp width, and height to implementation dependent range */ + width = CLAMP( width, 1, MAX_WIDTH ); + height = CLAMP( height, 1, MAX_HEIGHT ); + + /* Save viewport */ + ctx->Viewport.X = x; + ctx->Viewport.Width = width; + ctx->Viewport.Y = y; + ctx->Viewport.Height = height; + + /* compute scale and bias values */ + ctx->Viewport.Sx = (GLfloat) width / 2.0F; + ctx->Viewport.Tx = ctx->Viewport.Sx + x; + ctx->Viewport.Sy = (GLfloat) height / 2.0F; + ctx->Viewport.Ty = ctx->Viewport.Sy + y; + + ctx->NewState |= NEW_ALL; /* just to be safe */ + + /* Check if window/buffer has been resized and if so, reallocate the + * ancillary buffers. + */ + gl_ResizeBuffersMESA(ctx); +} diff --git a/dll/opengl/mesa/matrix.h b/dll/opengl/mesa/matrix.h new file mode 100644 index 00000000000..b5565535465 --- /dev/null +++ b/dll/opengl/mesa/matrix.h @@ -0,0 +1,92 @@ +/* $Id: matrix.h,v 1.3 1997/04/20 16:18:15 brianp Exp $ */ + +/* + * Mesa 3-D graphics library + * Version: 2.3 + * Copyright (C) 1995-1997 Brian Paul + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Library General Public + * License as published by the Free Software Foundation; either + * version 2 of the License, or (at your option) any later version. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Library General Public License for more details. + * + * You should have received a copy of the GNU Library General Public + * License along with this library; if not, write to the Free + * Software Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. + */ + + +/* + * $Log: matrix.h,v $ + * Revision 1.3 1997/04/20 16:18:15 brianp + * added glOrtho and glFrustum API pointers + * + * Revision 1.2 1997/04/01 04:23:53 brianp + * added gl_analyze_*_matrix() functions + * + * Revision 1.1 1996/09/13 01:38:16 brianp + * Initial revision + * + */ + + +#ifndef MATRIX_H +#define MATRIX_H + + +#include "types.h" + + + +extern void gl_analyze_modelview_matrix( GLcontext *ctx ); + +extern void gl_analyze_projection_matrix( GLcontext *ctx ); + +extern void gl_analyze_texture_matrix( GLcontext *ctx ); + + + +extern void gl_rotation_matrix( GLfloat angle, GLfloat x, GLfloat y, GLfloat z, + GLfloat m[] ); + + + +extern void gl_Frustum( GLcontext *ctx, + GLdouble left, GLdouble right, + GLdouble bottom, GLdouble top, + GLdouble nearval, GLdouble farval ); + +extern void gl_Ortho( GLcontext *ctx, + GLdouble left, GLdouble right, + GLdouble bottom, GLdouble top, + GLdouble nearval, GLdouble farval ); + +extern void gl_PushMatrix( GLcontext *ctx ); + +extern void gl_PopMatrix( GLcontext *ctx ); + +extern void gl_LoadIdentity( GLcontext *ctx ); + +extern void gl_LoadMatrixf( GLcontext *ctx, const GLfloat *m ); + +extern void gl_MatrixMode( GLcontext *ctx, GLenum mode ); + +extern void gl_MultMatrixf( GLcontext *ctx, const GLfloat *m ); + +extern void gl_Viewport( GLcontext *ctx, + GLint x, GLint y, GLsizei width, GLsizei height ); + +extern void gl_Rotatef( GLcontext *ctx, + GLfloat angle, GLfloat x, GLfloat y, GLfloat z ); + +extern void gl_Scalef( GLcontext *ctx, GLfloat x, GLfloat y, GLfloat z ); + +extern void gl_Translatef( GLcontext *ctx, GLfloat x, GLfloat y, GLfloat z ); + + +#endif diff --git a/dll/opengl/mesa/misc.c b/dll/opengl/mesa/misc.c new file mode 100644 index 00000000000..0762d184a02 --- /dev/null +++ b/dll/opengl/mesa/misc.c @@ -0,0 +1,495 @@ +/* $Id: misc.c,v 1.23 1997/12/06 18:07:13 brianp Exp $ */ + +/* + * Mesa 3-D graphics library + * Version: 2.6 + * Copyright (C) 1995-1997 Brian Paul + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Library General Public + * License as published by the Free Software Foundation; either + * version 2 of the License, or (at your option) any later version. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Library General Public License for more details. + * + * You should have received a copy of the GNU Library General Public + * License along with this library; if not, write to the Free + * Software Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. + */ + + +/* + * $Log: misc.c,v $ + * Revision 1.23 1997/12/06 18:07:13 brianp + * changed version to 2.6 + * + * Revision 1.22 1997/12/05 04:38:55 brianp + * added ClearColorAndDepth() function pointer (David Bucciarelli) + * + * Revision 1.21 1997/10/29 01:29:09 brianp + * added GL_EXT_point_parameters extension from Daniel Barrero + * + * Revision 1.20 1997/10/16 02:32:19 brianp + * added GL_EXT_shared_texture_palette extension + * + * Revision 1.19 1997/10/14 00:17:48 brianp + * added 3DFX_set_global_palette to extension string for 3Dfx + * + * Revision 1.18 1997/09/27 00:13:44 brianp + * added GL_EXT_paletted_texture extension + * + * Revision 1.17 1997/08/13 01:26:40 brianp + * changed version string to 2.4 + * + * Revision 1.16 1997/07/24 01:23:16 brianp + * changed precompiled header symbol from PCH to PC_HEADER + * + * Revision 1.15 1997/06/20 02:21:36 brianp + * don't clear buffers if RenderMode != GL_RENDER + * + * Revision 1.14 1997/05/28 03:25:43 brianp + * added precompiled header (PCH) support + * + * Revision 1.13 1997/04/12 12:31:18 brianp + * removed gl_Rectf() + * + * Revision 1.12 1997/03/21 01:58:54 brianp + * now call Driver.RendererString() in gl_GetString() + * + * Revision 1.11 1997/02/10 20:40:51 brianp + * added GL_MESA_resize_buffers to extensions string + * + * Revision 1.10 1997/02/09 18:44:35 brianp + * added GL_EXT_texture3D support + * + * Revision 1.9 1997/01/08 20:55:02 brianp + * added GL_EXT_texture_object + * + * Revision 1.8 1996/11/05 01:41:45 brianp + * fixed potential scissor/clear color buffer bug + * + * Revision 1.7 1996/10/30 03:14:02 brianp + * incremented version to 2.1 + * + * Revision 1.6 1996/10/11 03:42:17 brianp + * added GL_EXT_polygon_offset to extensions string + * + * Revision 1.5 1996/10/02 02:51:44 brianp + * created clear_color_buffers() which handles draw mode GL_FRONT_AND_BACK + * + * Revision 1.4 1996/09/25 03:22:14 brianp + * glDrawBuffer(GL_NONE) works now + * + * Revision 1.3 1996/09/24 00:16:10 brianp + * set NewState flag in glRead/DrawBuffer() and glHint() + * fixed display list bug in gl_Hint() + * + * Revision 1.2 1996/09/15 14:18:37 brianp + * now use GLframebuffer and GLvisual + * + * Revision 1.1 1996/09/13 01:38:16 brianp + * Initial revision + * + */ + + +#ifdef PC_HEADER +#include "all.h" +#else +#include +#include +#include "accum.h" +#include "alphabuf.h" +#include "context.h" +#include "depth.h" +#include "macros.h" +#include "masking.h" +#include "misc.h" +#include "stencil.h" +#include "types.h" +#endif + + + +void gl_ClearIndex( GLcontext *ctx, GLfloat c ) +{ + if (INSIDE_BEGIN_END(ctx)) { + gl_error( ctx, GL_INVALID_OPERATION, "glClearIndex" ); + return; + } + ctx->Color.ClearIndex = (GLuint) c; + if (!ctx->Visual->RGBAflag) { + /* it's OK to call glClearIndex in RGBA mode but it should be a NOP */ + (*ctx->Driver.ClearIndex)( ctx, ctx->Color.ClearIndex ); + } +} + + + +void gl_ClearColor( GLcontext *ctx, GLclampf red, GLclampf green, + GLclampf blue, GLclampf alpha ) +{ + if (INSIDE_BEGIN_END(ctx)) { + gl_error( ctx, GL_INVALID_OPERATION, "glClearColor" ); + return; + } + + ctx->Color.ClearColor[0] = CLAMP( red, 0.0F, 1.0F ); + ctx->Color.ClearColor[1] = CLAMP( green, 0.0F, 1.0F ); + ctx->Color.ClearColor[2] = CLAMP( blue, 0.0F, 1.0F ); + ctx->Color.ClearColor[3] = CLAMP( alpha, 0.0F, 1.0F ); + + if (ctx->Visual->RGBAflag) { + GLubyte r = (GLint) (ctx->Color.ClearColor[0] * ctx->Visual->RedScale); + GLubyte g = (GLint) (ctx->Color.ClearColor[1] * ctx->Visual->GreenScale); + GLubyte b = (GLint) (ctx->Color.ClearColor[2] * ctx->Visual->BlueScale); + GLubyte a = (GLint) (ctx->Color.ClearColor[3] * ctx->Visual->AlphaScale); + (*ctx->Driver.ClearColor)( ctx, r, g, b, a ); + } +} + + + + +/* + * Clear the color buffer when glColorMask or glIndexMask is in effect. + */ +static void clear_color_buffer_with_masking( GLcontext *ctx ) +{ + GLint x, y, height, width; + + /* Compute region to clear */ + if (ctx->Scissor.Enabled) { + x = ctx->Buffer->Xmin; + y = ctx->Buffer->Ymin; + height = ctx->Buffer->Ymax - ctx->Buffer->Ymin + 1; + width = ctx->Buffer->Xmax - ctx->Buffer->Xmin + 1; + } + else { + x = 0; + y = 0; + height = ctx->Buffer->Height; + width = ctx->Buffer->Width; + } + + if (ctx->Visual->RGBAflag) { + /* RGBA mode */ + GLubyte red[MAX_WIDTH], green[MAX_WIDTH]; + GLubyte blue[MAX_WIDTH], alpha[MAX_WIDTH]; + GLubyte r = ctx->Color.ClearColor[0] * ctx->Visual->RedScale; + GLubyte g = ctx->Color.ClearColor[1] * ctx->Visual->GreenScale; + GLubyte b = ctx->Color.ClearColor[2] * ctx->Visual->BlueScale; + GLubyte a = ctx->Color.ClearColor[3] * ctx->Visual->AlphaScale; + GLint i; + for (i=0;iDriver.WriteColorSpan)( ctx, + width, x, y, red, green, blue, alpha, NULL ); + if (ctx->RasterMask & ALPHABUF_BIT) { + gl_write_alpha_span( ctx, width, x, y, alpha, NULL ); + } + } + } + else { + /* Color index mode */ + GLuint indx[MAX_WIDTH]; + GLubyte mask[MAX_WIDTH]; + GLint i, j; + MEMSET( mask, 1, width ); + for (i=0;iColor.ClearIndex; + } + gl_mask_index_span( ctx, width, x, y, indx ); + (*ctx->Driver.WriteIndexSpan)( ctx, width, x, y, indx, mask ); + } + } +} + + + +/* + * Clear the front and/or back color buffers. Also clear the alpha + * buffer(s) if present. + */ +static void clear_color_buffers( GLcontext *ctx ) +{ + if (ctx->Color.SWmasking) { + clear_color_buffer_with_masking( ctx ); + } + else { + GLint x = ctx->Buffer->Xmin; + GLint y = ctx->Buffer->Ymin; + GLint height = ctx->Buffer->Ymax - ctx->Buffer->Ymin + 1; + GLint width = ctx->Buffer->Xmax - ctx->Buffer->Xmin + 1; + (*ctx->Driver.Clear)( ctx, !ctx->Scissor.Enabled, + x, y, width, height ); + if (ctx->RasterMask & ALPHABUF_BIT) { + /* front and/or back alpha buffers will be cleared here */ + gl_clear_alpha_buffers( ctx ); + } + } + + if (ctx->RasterMask & FRONT_AND_BACK_BIT) { + /*** Also clear the back buffer ***/ + (*ctx->Driver.SetBuffer)( ctx, GL_BACK ); + if (ctx->Color.SWmasking) { + clear_color_buffer_with_masking( ctx ); + } + else { + GLint x = ctx->Buffer->Xmin; + GLint y = ctx->Buffer->Ymin; + GLint height = ctx->Buffer->Ymax - ctx->Buffer->Ymin + 1; + GLint width = ctx->Buffer->Xmax - ctx->Buffer->Xmin + 1; + (*ctx->Driver.Clear)( ctx, !ctx->Scissor.Enabled, + x, y, width, height ); + } + (*ctx->Driver.SetBuffer)( ctx, GL_FRONT ); + } +} + + + +void gl_Clear( GLcontext *ctx, GLbitfield mask ) +{ +#ifdef PROFILE + GLdouble t0 = gl_time(); +#endif + + if (INSIDE_BEGIN_END(ctx)) { + gl_error( ctx, GL_INVALID_OPERATION, "glClear" ); + return; + } + + if (ctx->RenderMode==GL_RENDER) { + if (ctx->NewState) { + gl_update_state( ctx ); + } + + /* See if we can call device driver function to clear both the + * color and depth buffers. + */ + if (ctx->Driver.ClearColorAndDepth && + (mask & GL_COLOR_BUFFER_BIT) && (mask & GL_DEPTH_BUFFER_BIT)) { + GLint x = ctx->Buffer->Xmin; + GLint y = ctx->Buffer->Ymin; + GLint height = ctx->Buffer->Ymax - ctx->Buffer->Ymin + 1; + GLint width = ctx->Buffer->Xmax - ctx->Buffer->Xmin + 1; + (*ctx->Driver.ClearColorAndDepth)( ctx, !ctx->Scissor.Enabled, + x, y, width, height ); + if (ctx->RasterMask & FRONT_AND_BACK_BIT) { + /*** Also clear the back buffer ***/ + (*ctx->Driver.SetBuffer)( ctx, GL_BACK ); + (*ctx->Driver.ClearColorAndDepth)( ctx, !ctx->Scissor.Enabled, + x, y, width, height ); + (*ctx->Driver.SetBuffer)( ctx, GL_FRONT ); + } + } + else { + /* normal procedure for clearing buffers */ + if (mask & GL_COLOR_BUFFER_BIT) clear_color_buffers( ctx ); + if (mask & GL_DEPTH_BUFFER_BIT) (*ctx->Driver.ClearDepthBuffer)(ctx); + if (mask & GL_ACCUM_BUFFER_BIT) gl_clear_accum_buffer( ctx ); + if (mask & GL_STENCIL_BUFFER_BIT) gl_clear_stencil_buffer( ctx ); + } + +#ifdef PROFILE + ctx->ClearTime += gl_time() - t0; + ctx->ClearCount++; +#endif + } +} + + + +const GLubyte *gl_GetString( GLcontext *ctx, GLenum name ) +{ + static char renderer[1000]; + static char *vendor = "Brian Paul & ReactOS Developers"; + static char *version = "1.1"; + static char *extensions = "GL_EXT_paletted_texture GL_EXT_bgra GL_WIN_swap_hint"; + + if (INSIDE_BEGIN_END(ctx)) { + gl_error( ctx, GL_INVALID_OPERATION, "glGetString" ); + return (GLubyte *) 0; + } + + switch (name) { + case GL_VENDOR: + return (GLubyte *) vendor; + case GL_RENDERER: + strcpy(renderer, "Mesa"); + if (ctx->Driver.RendererString) { + strcat(renderer, " "); + strcat(renderer, (*ctx->Driver.RendererString)()); + } + return (GLubyte *) renderer; + case GL_VERSION: + return (GLubyte *) version; + case GL_EXTENSIONS: + return (GLubyte *) extensions; + default: + gl_error( ctx, GL_INVALID_ENUM, "glGetString" ); + return (GLubyte *) 0; + } +} + + + +void gl_Finish( GLcontext *ctx ) +{ + /* Don't compile into display list */ + if (INSIDE_BEGIN_END(ctx)) { + gl_error( ctx, GL_INVALID_OPERATION, "glFinish" ); + return; + } + if (ctx->Driver.Finish) { + (*ctx->Driver.Finish)( ctx ); + } +} + + + +void gl_Flush( GLcontext *ctx ) +{ + /* Don't compile into display list */ + if (INSIDE_BEGIN_END(ctx)) { + gl_error( ctx, GL_INVALID_OPERATION, "glFlush" ); + return; + } + if (ctx->Driver.Flush) { + (*ctx->Driver.Flush)( ctx ); + } +} + + + +void gl_Hint( GLcontext *ctx, GLenum target, GLenum mode ) +{ + if (INSIDE_BEGIN_END(ctx)) { + gl_error( ctx, GL_INVALID_OPERATION, "glHint" ); + return; + } + if (mode!=GL_DONT_CARE && mode!=GL_FASTEST && mode!=GL_NICEST) { + gl_error( ctx, GL_INVALID_ENUM, "glHint(mode)" ); + return; + } + switch (target) { + case GL_FOG_HINT: + ctx->Hint.Fog = mode; + break; + case GL_LINE_SMOOTH_HINT: + ctx->Hint.LineSmooth = mode; + break; + case GL_PERSPECTIVE_CORRECTION_HINT: + ctx->Hint.PerspectiveCorrection = mode; + break; + case GL_POINT_SMOOTH_HINT: + ctx->Hint.PointSmooth = mode; + break; + case GL_POLYGON_SMOOTH_HINT: + ctx->Hint.PolygonSmooth = mode; + break; + default: + gl_error( ctx, GL_INVALID_ENUM, "glHint(target)" ); + } + ctx->NewState |= NEW_ALL; /* just to be safe */ +} + + + +void gl_DrawBuffer( GLcontext *ctx, GLenum mode ) +{ + if (INSIDE_BEGIN_END(ctx)) { + gl_error( ctx, GL_INVALID_OPERATION, "glDrawBuffer" ); + return; + } + switch (mode) { + case GL_FRONT: + case GL_FRONT_LEFT: + case GL_FRONT_AND_BACK: + if ( (*ctx->Driver.SetBuffer)( ctx, GL_FRONT ) == GL_FALSE ) { + gl_error( ctx, GL_INVALID_ENUM, "glDrawBuffer" ); + return; + } + ctx->Color.DrawBuffer = mode; + ctx->Buffer->Alpha = ctx->Buffer->FrontAlpha; + ctx->NewState |= NEW_RASTER_OPS; + break; + case GL_BACK: + case GL_BACK_LEFT: + if ( (*ctx->Driver.SetBuffer)( ctx, GL_BACK ) == GL_FALSE) { + gl_error( ctx, GL_INVALID_ENUM, "glDrawBuffer" ); + return; + } + ctx->Color.DrawBuffer = mode; + ctx->Buffer->Alpha = ctx->Buffer->BackAlpha; + ctx->NewState |= NEW_RASTER_OPS; + break; + case GL_NONE: + ctx->Color.DrawBuffer = mode; + ctx->Buffer->Alpha = NULL; + ctx->NewState |= NEW_RASTER_OPS; + break; + case GL_FRONT_RIGHT: + case GL_BACK_RIGHT: + case GL_LEFT: + case GL_RIGHT: + case GL_AUX0: + gl_error( ctx, GL_INVALID_OPERATION, "glDrawBuffer" ); + break; + default: + gl_error( ctx, GL_INVALID_ENUM, "glDrawBuffer" ); + } +} + + + +void gl_ReadBuffer( GLcontext *ctx, GLenum mode ) +{ + if (INSIDE_BEGIN_END(ctx)) { + gl_error( ctx, GL_INVALID_OPERATION, "glReadBuffer" ); + return; + } + switch (mode) { + case GL_FRONT: + case GL_FRONT_LEFT: + if ( (*ctx->Driver.SetBuffer)( ctx, GL_FRONT ) == GL_FALSE) { + gl_error( ctx, GL_INVALID_ENUM, "glReadBuffer" ); + return; + } + ctx->Pixel.ReadBuffer = mode; + ctx->Buffer->Alpha = ctx->Buffer->FrontAlpha; + ctx->NewState |= NEW_RASTER_OPS; + break; + case GL_BACK: + case GL_BACK_LEFT: + if ( (*ctx->Driver.SetBuffer)( ctx, GL_BACK ) == GL_FALSE) { + gl_error( ctx, GL_INVALID_ENUM, "glReadBuffer" ); + return; + } + ctx->Pixel.ReadBuffer = mode; + ctx->Buffer->Alpha = ctx->Buffer->BackAlpha; + ctx->NewState |= NEW_RASTER_OPS; + break; + case GL_FRONT_RIGHT: + case GL_BACK_RIGHT: + case GL_LEFT: + case GL_RIGHT: + case GL_AUX0: + gl_error( ctx, GL_INVALID_OPERATION, "glReadBuffer" ); + break; + default: + gl_error( ctx, GL_INVALID_ENUM, "glReadBuffer" ); + } + + /* Remember, the draw buffer is the default state */ + (void) (*ctx->Driver.SetBuffer)( ctx, ctx->Color.DrawBuffer ); +} diff --git a/dll/opengl/mesa/misc.h b/dll/opengl/mesa/misc.h new file mode 100644 index 00000000000..19a6c22bb1e --- /dev/null +++ b/dll/opengl/mesa/misc.h @@ -0,0 +1,63 @@ +/* $Id: misc.h,v 1.2 1997/04/12 12:31:18 brianp Exp $ */ + +/* + * Mesa 3-D graphics library + * Version: 2.3 + * Copyright (C) 1995-1996 Brian Paul + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Library General Public + * License as published by the Free Software Foundation; either + * version 2 of the License, or (at your option) any later version. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Library General Public License for more details. + * + * You should have received a copy of the GNU Library General Public + * License along with this library; if not, write to the Free + * Software Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. + */ + + +/* + * $Log: misc.h,v $ + * Revision 1.2 1997/04/12 12:31:18 brianp + * removed gl_Rectf() + * + * Revision 1.1 1996/09/13 01:38:16 brianp + * Initial revision + * + */ + + +#ifndef MISC_H +#define MISC_H + + +#include "types.h" + + +extern void gl_ClearIndex( GLcontext *ctx, GLfloat c ); + +extern void gl_ClearColor( GLcontext *ctx, GLclampf red, GLclampf green, + GLclampf blue, GLclampf alpha ); + +extern void gl_Clear( GLcontext *ctx, GLbitfield mask ); + + +extern const GLubyte *gl_GetString( GLcontext *ctx, GLenum name ); + +extern void gl_Finish( GLcontext *ctx ); + +extern void gl_Flush( GLcontext *ctx ); + +extern void gl_Hint( GLcontext *ctx, GLenum target, GLenum mode ); + +extern void gl_DrawBuffer( GLcontext *ctx, GLenum mode ); + +extern void gl_ReadBuffer( GLcontext *ctx, GLenum mode ); + + +#endif diff --git a/dll/opengl/mesa/mmath.c b/dll/opengl/mesa/mmath.c new file mode 100644 index 00000000000..3cfae5f3a11 --- /dev/null +++ b/dll/opengl/mesa/mmath.c @@ -0,0 +1,150 @@ +/* $Id: mmath.c,v 1.3 1997/07/24 01:23:16 brianp Exp $ */ + +/* + * Mesa 3-D graphics library + * Version: 2.4 + * Copyright (C) 1995-1997 Brian Paul + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Library General Public + * License as published by the Free Software Foundation; either + * version 2 of the License, or (at your option) any later version. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Library General Public License for more details. + * + * You should have received a copy of the GNU Library General Public + * License along with this library; if not, write to the Free + * Software Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. + */ + + +/* + * $Log: mmath.c,v $ + * Revision 1.3 1997/07/24 01:23:16 brianp + * changed precompiled header symbol from PCH to PC_HEADER + * + * Revision 1.2 1997/05/28 03:25:43 brianp + * added precompiled header (PCH) support + * + * Revision 1.1 1997/05/01 01:41:54 brianp + * Initial revision + * + */ + + +#ifdef PC_HEADER +#include "all.h" +#else +#include "GL/gl.h" +#include "mmath.h" +#endif + + + +/* + * A High Speed, Low Precision Square Root + * by Paul Lalonde and Robert Dawson + * from "Graphics Gems", Academic Press, 1990 + */ + +/* + * SPARC implementation of a fast square root by table + * lookup. + * SPARC floating point format is as follows: + * + * BIT 31 30 23 22 0 + * sign exponent mantissa + */ +static short sqrttab[0x100]; /* declare table of square roots */ + +static void init_sqrt(void) +{ +#ifdef FAST_MATH + unsigned short i; + float f; + unsigned int *fi = (unsigned int *)&f; + /* to access the bits of a float in */ + /* C quickly we must misuse pointers */ + + for(i=0; i<= 0x7f; i++) { + *fi = 0; + + /* + * Build a float with the bit pattern i as mantissa + * and an exponent of 0, stored as 127 + */ + + *fi = (i << 16) | (127 << 23); + f = sqrt(f); + + /* + * Take the square root then strip the first 7 bits of + * the mantissa into the table + */ + + sqrttab[i] = (*fi & 0x7fffff) >> 16; + + /* + * Repeat the process, this time with an exponent of + * 1, stored as 128 + */ + + *fi = 0; + *fi = (i << 16) | (128 << 23); + f = sqrt(f); + sqrttab[i+0x80] = (*fi & 0x7fffff) >> 16; + } +#endif /*FAST_MATH*/ +} + + +float gl_sqrt( float x ) +{ +#ifdef FAST_MATH + unsigned int *num = (unsigned int *)&x; + /* to access the bits of a float in C + * we must misuse pointers */ + + short e; /* the exponent */ + if (x == 0.0F) return 0.0F; /* check for square root of 0 */ + e = (*num >> 23) - 127; /* get the exponent - on a SPARC the */ + /* exponent is stored with 127 added */ + *num &= 0x7fffff; /* leave only the mantissa */ + if (e & 0x01) *num |= 0x800000; + /* the exponent is odd so we have to */ + /* look it up in the second half of */ + /* the lookup table, so we set the */ + /* high bit */ + e >>= 1; /* divide the exponent by two */ + /* note that in C the shift */ + /* operators are sign preserving */ + /* for signed operands */ + /* Do the table lookup, based on the quaternary mantissa, + * then reconstruct the result back into a float + */ + *num = ((sqrttab[*num >> 16]) << 16) | ((e + 127) << 23); + return x; +#else + return sqrt(x); +#endif +} + + + +/* + * Initialize tables, etc for fast math functions. + */ +void gl_init_math(void) +{ + static GLboolean initialized = GL_FALSE; + + if (!initialized) { + init_sqrt(); + + + initialized = GL_TRUE; + } +} diff --git a/dll/opengl/mesa/mmath.h b/dll/opengl/mesa/mmath.h new file mode 100644 index 00000000000..d83f8c1335f --- /dev/null +++ b/dll/opengl/mesa/mmath.h @@ -0,0 +1,84 @@ +/* $Id: mmath.h,v 1.5 1997/12/18 02:54:26 brianp Exp $ */ + +/* + * Mesa 3-D graphics library + * Version: 2.6 + * Copyright (C) 1995-1997 Brian Paul + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Library General Public + * License as published by the Free Software Foundation; either + * version 2 of the License, or (at your option) any later version. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Library General Public License for more details. + * + * You should have received a copy of the GNU Library General Public + * License along with this library; if not, write to the Free + * Software Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. + */ + + +/* + * $Log: mmath.h,v $ + * Revision 1.5 1997/12/18 02:54:26 brianp + * added Josh Vanderhoof's float->int x86 asm code + * + * Revision 1.4 1997/10/15 00:36:17 brianp + * renamed the FAST/REGULAR_MATH macros + * + * Revision 1.3 1997/09/29 22:23:54 brianp + * added FAST/REGULAR_MATH macros + * + * Revision 1.2 1997/05/03 00:54:31 brianp + * fixed a comment + * + * Revision 1.1 1997/05/01 01:42:38 brianp + * Initial revision + * + */ + + +/* + * Faster arithmetic functions. If the FAST_MATH preprocessor symbol is + * defined on the command line (-DFAST_MATH) then we'll use some (hopefully) + * faster functions for sqrt(), etc. + */ + + +#ifndef MMATH_H +#define MMATH_H + +#include + +#define FloatToInt(F) lrintf((F)) + +extern float gl_sqrt(float x); + +#ifdef FAST_MATH +# define GL_SQRT(X) gl_sqrt(X) +#else +# define GL_SQRT(X) sqrt(X) +#endif + + +/* Normalize a 3-element vector to unit length */ +#define NORMALIZE_3FV( V ) \ +{ \ + GLfloat len; \ + len = GL_SQRT(V[0]*V[0]+V[1]*V[1]+V[2]*V[2]); \ + if (len>0.0001F) { \ + len = 1.0F / len; \ + V[0] *= len; \ + V[1] *= len; \ + V[2] *= len; \ + } \ +} + + +extern void gl_init_math(void); + + +#endif diff --git a/dll/opengl/mesa/pb.c b/dll/opengl/mesa/pb.c new file mode 100644 index 00000000000..ef6caed264f --- /dev/null +++ b/dll/opengl/mesa/pb.c @@ -0,0 +1,449 @@ +/* $Id: pb.c,v 1.14 1997/11/13 02:16:48 brianp Exp $ */ + +/* + * Mesa 3-D graphics library + * Version: 2.4 + * Copyright (C) 1995-1997 Brian Paul + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Library General Public + * License as published by the Free Software Foundation; either + * version 2 of the License, or (at your option) any later version. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Library General Public License for more details. + * + * You should have received a copy of the GNU Library General Public + * License along with this library; if not, write to the Free + * Software Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. + */ + + +/* + * $Log: pb.c,v $ + * Revision 1.14 1997/11/13 02:16:48 brianp + * added lambda array, initialized to zeros + * + * Revision 1.13 1997/07/24 01:24:11 brianp + * changed precompiled header symbol from PCH to PC_HEADER + * + * Revision 1.12 1997/05/28 03:26:02 brianp + * added precompiled header (PCH) support + * + * Revision 1.11 1997/05/09 22:40:19 brianp + * added gl_alloc_pb() + * + * Revision 1.10 1997/05/03 00:51:30 brianp + * new texturing function call: gl_texture_pixels() + * + * Revision 1.9 1997/05/01 02:10:33 brianp + * removed manually unrolled loop to stop Purify uninitialized memory read + * + * Revision 1.8 1997/04/16 23:54:11 brianp + * do per-pixel fog if texturing is enabled + * + * Revision 1.7 1997/02/09 19:53:43 brianp + * now use TEXTURE_xD enable constants + * + * Revision 1.6 1997/02/09 18:43:14 brianp + * added GL_EXT_texture3D support + * + * Revision 1.5 1997/02/03 20:30:54 brianp + * added a few DEFARRAY macros for BeOS + * + * Revision 1.4 1997/01/28 22:17:44 brianp + * new RGBA mode logic op support + * + * Revision 1.3 1996/09/25 03:21:10 brianp + * added NO_DRAW_BIT support + * + * Revision 1.2 1996/09/15 14:18:37 brianp + * now use GLframebuffer and GLvisual + * + * Revision 1.1 1996/09/13 01:38:16 brianp + * Initial revision + * + */ + + +/* + * Pixel buffer: + * + * As fragments are produced (by point, line, and bitmap drawing) they + * are accumlated in a buffer. When the buffer is full or has to be + * flushed (glEnd), we apply all enabled rasterization functions to the + * pixels and write the results to the display buffer. The goal is to + * maximize the number of pixels processed inside loops and to minimize + * the number of function calls. + */ + + + +#ifdef PC_HEADER +#include "all.h" +#else +#include +#include +#include "alpha.h" +#include "alphabuf.h" +#include "blend.h" +#include "depth.h" +#include "fog.h" +#include "logic.h" +#include "macros.h" +#include "masking.h" +#include "pb.h" +#include "scissor.h" +#include "stencil.h" +#include "texture.h" +#include "types.h" +#endif + + + +/* + * Allocate and initialize a new pixel buffer structure. + */ +struct pixel_buffer *gl_alloc_pb(void) +{ + struct pixel_buffer *pb; + pb = (struct pixel_buffer *) calloc(sizeof(struct pixel_buffer), 1); + if (pb) { + int i; + /* set non-zero fields */ + pb->primitive = GL_BITMAP; + /* Set all lambda values to 0.0 since we don't do mipmapping for + * points or lines and want to use the level 0 texture image. + */ + for (i=0; ilambda[i] = 0.0; + } + } + return pb; +} + + + + +/* + * When the pixel buffer is full, or needs to be flushed, call this + * function. All the pixels in the pixel buffer will be subjected + * to texturing, scissoring, stippling, alpha testing, stenciling, + * depth testing, blending, and finally written to the frame buffer. + */ +void gl_flush_pb( GLcontext *ctx ) +{ + struct pixel_buffer* PB = ctx->PB; + + DEFARRAY(GLubyte,mask,PB_SIZE); + DEFARRAY(GLubyte, rsave, PB_SIZE); + DEFARRAY(GLubyte, gsave, PB_SIZE); + DEFARRAY(GLubyte, bsave, PB_SIZE); + DEFARRAY(GLubyte, asave, PB_SIZE); + + if (PB->count==0) goto CleanUp; + + /* initialize mask array and clip pixels simultaneously */ + { + GLint xmin = ctx->Buffer->Xmin; + GLint xmax = ctx->Buffer->Xmax; + GLint ymin = ctx->Buffer->Ymin; + GLint ymax = ctx->Buffer->Ymax; + GLint *x = PB->x; + GLint *y = PB->y; + GLuint i, n = PB->count; + for (i=0;i=xmin) & (x[i]<=xmax) & (y[i]>=ymin) & (y[i]<=ymax); + } + } + + if (ctx->Visual->RGBAflag) { + /* RGBA COLOR PIXELS */ + if (PB->mono && ctx->MutablePixels) { + /* Copy flat color to all pixels */ + MEMSET( PB->r, PB->color[0], PB->count ); + MEMSET( PB->g, PB->color[1], PB->count ); + MEMSET( PB->b, PB->color[2], PB->count ); + MEMSET( PB->a, PB->color[3], PB->count ); + } + + /* If each pixel can be of a different color... */ + if (ctx->MutablePixels || !PB->mono) { + + if (ctx->Texture.Enabled) { + /* TODO: need texture lambda valus */ + gl_texture_pixels( ctx, PB->count, PB->s, PB->t, PB->u, + PB->lambda, PB->r, PB->g, PB->b, PB->a); + } + + if (ctx->Fog.Enabled + && (ctx->Hint.Fog==GL_NICEST || PB->primitive==GL_BITMAP + || ctx->Texture.Enabled)) { + gl_fog_color_pixels( ctx, PB->count, PB->z, + PB->r, PB->g, PB->b, PB->a ); + } + + /* Scissoring already done above */ + + if (ctx->Color.AlphaEnabled) { + if (gl_alpha_test( ctx, PB->count, PB->a, mask )==0) { + goto CleanUp; + } + } + + if (ctx->Stencil.Enabled) { + /* first stencil test */ + if (gl_stencil_pixels( ctx, PB->count, PB->x, PB->y, mask )==0) { + goto CleanUp; + } + /* depth buffering w/ stencil */ + gl_depth_stencil_pixels( ctx, PB->count, PB->x, PB->y, PB->z, mask ); + } + else if (ctx->Depth.Test) { + /* regular depth testing */ + (*ctx->Driver.DepthTestPixels)( ctx, PB->count, PB->x, PB->y, PB->z, mask ); + } + + if (ctx->RasterMask & NO_DRAW_BIT) { + goto CleanUp; + } + + if (ctx->RasterMask & FRONT_AND_BACK_BIT) { + /* make a copy of the colors */ + MEMCPY( rsave, PB->r, PB->count * sizeof(GLubyte) ); + MEMCPY( gsave, PB->r, PB->count * sizeof(GLubyte) ); + MEMCPY( bsave, PB->r, PB->count * sizeof(GLubyte) ); + MEMCPY( asave, PB->r, PB->count * sizeof(GLubyte) ); + } + + if (ctx->Color.SWLogicOpEnabled) { + gl_logicop_rgba_pixels( ctx, PB->count, PB->x, PB->y, + PB->r, PB->g, PB->b, PB->a, mask); + } + else if (ctx->Color.BlendEnabled) { + gl_blend_pixels( ctx, PB->count, PB->x, PB->y, + PB->r, PB->g, PB->b, PB->a, mask); + } + + if (ctx->Color.SWmasking) { + gl_mask_color_pixels( ctx, PB->count, PB->x, PB->y, + PB->r, PB->g, PB->b, PB->a, mask ); + } + + /* write pixels */ + (*ctx->Driver.WriteColorPixels)( ctx, PB->count, PB->x, PB->y, + PB->r, PB->g, PB->b, PB->a, mask ); + if (ctx->RasterMask & ALPHABUF_BIT) { + gl_write_alpha_pixels( ctx, PB->count, PB->x, PB->y, PB->a, mask ); + } + + if (ctx->RasterMask & FRONT_AND_BACK_BIT) { + /*** Also draw to back buffer ***/ + (*ctx->Driver.SetBuffer)( ctx, GL_BACK ); + if (ctx->Color.SWLogicOpEnabled) { + gl_logicop_rgba_pixels( ctx, PB->count, PB->x, PB->y, + PB->r, PB->g, PB->b, PB->a, mask); + } + else if (ctx->Color.BlendEnabled) { + gl_blend_pixels( ctx, PB->count, PB->x, PB->y, + rsave, gsave, bsave, asave, mask ); + } + if (ctx->Color.SWmasking) { + gl_mask_color_pixels( ctx, PB->count, PB->x, PB->y, + rsave, gsave, bsave, asave, mask); + } + (*ctx->Driver.WriteColorPixels)( ctx, PB->count, PB->x, PB->y, + rsave, gsave, bsave, asave, mask); + if (ctx->RasterMask & ALPHABUF_BIT) { + ctx->Buffer->Alpha = ctx->Buffer->BackAlpha; + gl_write_alpha_pixels( ctx, PB->count, PB->x, PB->y, + asave, mask ); + ctx->Buffer->Alpha = ctx->Buffer->FrontAlpha; + } + (*ctx->Driver.SetBuffer)( ctx, GL_FRONT ); + /*** ALL DONE ***/ + } + } + else { + /* Same color for all pixels */ + + /* Scissoring already done above */ + + if (ctx->Color.AlphaEnabled) { + if (gl_alpha_test( ctx, PB->count, PB->a, mask )==0) { + goto CleanUp; + } + } + + if (ctx->Stencil.Enabled) { + /* first stencil test */ + if (gl_stencil_pixels( ctx, PB->count, PB->x, PB->y, mask )==0) { + goto CleanUp; + } + /* depth buffering w/ stencil */ + gl_depth_stencil_pixels( ctx, PB->count, PB->x, PB->y, PB->z, mask ); + } + else if (ctx->Depth.Test) { + /* regular depth testing */ + (*ctx->Driver.DepthTestPixels)( ctx, PB->count, PB->x, PB->y, PB->z, mask ); + } + + if (ctx->RasterMask & NO_DRAW_BIT) { + goto CleanUp; + } + + /* write pixels */ + { + GLubyte red, green, blue, alpha; + red = PB->color[0]; + green = PB->color[1]; + blue = PB->color[2]; + alpha = PB->color[3]; + (*ctx->Driver.Color)( ctx, red, green, blue, alpha ); + } + (*ctx->Driver.WriteMonocolorPixels)( ctx, PB->count, PB->x, PB->y, mask ); + if (ctx->RasterMask & ALPHABUF_BIT) { + gl_write_mono_alpha_pixels( ctx, PB->count, PB->x, PB->y, + PB->color[3], mask ); + } + + if (ctx->RasterMask & FRONT_AND_BACK_BIT) { + /*** Also render to back buffer ***/ + (*ctx->Driver.SetBuffer)( ctx, GL_BACK ); + (*ctx->Driver.WriteMonocolorPixels)( ctx, PB->count, PB->x, PB->y, mask ); + if (ctx->RasterMask & ALPHABUF_BIT) { + ctx->Buffer->Alpha = ctx->Buffer->BackAlpha; + gl_write_mono_alpha_pixels( ctx, PB->count, PB->x, PB->y, + PB->color[3], mask ); + ctx->Buffer->Alpha = ctx->Buffer->FrontAlpha; + } + (*ctx->Driver.SetBuffer)( ctx, GL_FRONT ); + } + /*** ALL DONE ***/ + } + } + else { + /* COLOR INDEX PIXELS */ + + /* If we may be writting pixels with different indexes... */ + if (PB->mono && ctx->MutablePixels) { + /* copy index to all pixels */ + GLuint n = PB->count, indx = PB->index; + GLuint *pbindex = PB->i; + do { + *pbindex++ = indx; + n--; + } while (n); + } + + if (ctx->MutablePixels || !PB->mono) { + /* Pixel color index may be modified */ + GLuint isave[PB_SIZE]; + + if (ctx->Fog.Enabled + && (ctx->Hint.Fog==GL_NICEST || PB->primitive==GL_BITMAP)) { + gl_fog_index_pixels( ctx, PB->count, PB->z, PB->i ); + } + + /* Scissoring already done above */ + + if (ctx->Stencil.Enabled) { + /* first stencil test */ + if (gl_stencil_pixels( ctx, PB->count, PB->x, PB->y, mask )==0) { + goto CleanUp; + } + /* depth buffering w/ stencil */ + gl_depth_stencil_pixels( ctx, PB->count, PB->x, PB->y, PB->z, mask ); + } + else if (ctx->Depth.Test) { + /* regular depth testing */ + (*ctx->Driver.DepthTestPixels)( ctx, PB->count, PB->x, PB->y, PB->z, mask ); + } + + if (ctx->RasterMask & NO_DRAW_BIT) { + goto CleanUp; + } + + if (ctx->RasterMask & FRONT_AND_BACK_BIT) { + /* make a copy of the indexes */ + MEMCPY( isave, PB->i, PB->count * sizeof(GLuint) ); + } + + if (ctx->Color.SWLogicOpEnabled) { + gl_logicop_ci_pixels( ctx, PB->count, PB->x, PB->y, PB->i, mask ); + } + + if (ctx->Color.SWmasking) { + gl_mask_index_pixels( ctx, PB->count, PB->x, PB->y, PB->i, mask ); + } + + /* write pixels */ + (*ctx->Driver.WriteIndexPixels)( ctx, PB->count, PB->x, PB->y, + PB->i, mask ); + + if (ctx->RasterMask & FRONT_AND_BACK_BIT) { + /*** Also write to back buffer ***/ + (*ctx->Driver.SetBuffer)( ctx, GL_BACK ); + MEMCPY( PB->i, isave, PB->count * sizeof(GLuint) ); + if (ctx->Color.SWLogicOpEnabled) { + gl_logicop_ci_pixels( ctx, PB->count, PB->x, PB->y, PB->i, mask ); + } + if (ctx->Color.SWmasking) { + gl_mask_index_pixels( ctx, PB->count, PB->x, PB->y, + PB->i, mask ); + } + (*ctx->Driver.WriteIndexPixels)( ctx, PB->count, PB->x, PB->y, + PB->i, mask ); + (*ctx->Driver.SetBuffer)( ctx, GL_FRONT ); + } + + /*** ALL DONE ***/ + } + else { + /* Same color index for all pixels */ + + /* Scissoring already done above */ + + if (ctx->Stencil.Enabled) { + /* first stencil test */ + if (gl_stencil_pixels( ctx, PB->count, PB->x, PB->y, mask )==0) { + goto CleanUp; + } + /* depth buffering w/ stencil */ + gl_depth_stencil_pixels( ctx, PB->count, PB->x, PB->y, PB->z, mask ); + } + else if (ctx->Depth.Test) { + /* regular depth testing */ + (*ctx->Driver.DepthTestPixels)( ctx, PB->count, PB->x, PB->y, PB->z, mask ); + } + + if (ctx->RasterMask & NO_DRAW_BIT) { + goto CleanUp; + } + + /* write pixels */ + (*ctx->Driver.Index)( ctx, PB->index ); + (*ctx->Driver.WriteMonoindexPixels)( ctx, PB->count, PB->x, PB->y, mask ); + + if (ctx->RasterMask & FRONT_AND_BACK_BIT) { + /*** Also write to back buffer ***/ + (*ctx->Driver.SetBuffer)( ctx, GL_BACK ); + (*ctx->Driver.WriteMonoindexPixels)( ctx, PB->count, PB->x, PB->y, mask ); + (*ctx->Driver.SetBuffer)( ctx, GL_FRONT ); + } + /*** ALL DONE ***/ + } + } + +CleanUp: + PB->count = 0; + UNDEFARRAY(mask); + UNDEFARRAY(rsave); + UNDEFARRAY(gsave); + UNDEFARRAY(bsave); + UNDEFARRAY(asave); +} + + diff --git a/dll/opengl/mesa/pb.h b/dll/opengl/mesa/pb.h new file mode 100644 index 00000000000..0a09afa1ab9 --- /dev/null +++ b/dll/opengl/mesa/pb.h @@ -0,0 +1,177 @@ +/* $Id: pb.h,v 1.4 1997/11/13 02:16:48 brianp Exp $ */ + +/* + * Mesa 3-D graphics library + * Version: 2.5 + * Copyright (C) 1995-1997 Brian Paul + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Library General Public + * License as published by the Free Software Foundation; either + * version 2 of the License, or (at your option) any later version. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Library General Public License for more details. + * + * You should have received a copy of the GNU Library General Public + * License along with this library; if not, write to the Free + * Software Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. + */ + + +/* + * $Log: pb.h,v $ + * Revision 1.4 1997/11/13 02:16:48 brianp + * added lambda array, initialized to zeros + * + * Revision 1.3 1997/05/09 22:40:19 brianp + * added gl_alloc_pb() + * + * Revision 1.2 1997/02/09 18:43:14 brianp + * added GL_EXT_texture3D support + * + * Revision 1.1 1996/09/13 01:38:16 brianp + * Initial revision + * + */ + + +#ifndef PB_H +#define PB_H + + +#include "types.h" + + + +/* + * Pixel buffer size, must be larger than MAX_WIDTH. + */ +#define PB_SIZE (3*MAX_WIDTH) + + +struct pixel_buffer { + GLint x[PB_SIZE]; /* X window coord in [0,MAX_WIDTH) */ + GLint y[PB_SIZE]; /* Y window coord in [0,MAX_HEIGHT) */ + GLdepth z[PB_SIZE]; /* Z window coord in [0,MAX_DEPTH] */ + GLubyte r[PB_SIZE]; /* Red */ + GLubyte g[PB_SIZE]; /* Green */ + GLubyte b[PB_SIZE]; /* Blue */ + GLubyte a[PB_SIZE]; /* Alpha */ + GLuint i[PB_SIZE]; /* Index */ + GLfloat s[PB_SIZE]; /* Texture S coordinate */ + GLfloat t[PB_SIZE]; /* Texture T coordinate */ + GLfloat u[PB_SIZE]; /* Texture R coordinate */ + GLfloat lambda[PB_SIZE];/* Texture lambda value */ + GLint color[4]; /* Mono color, integers! */ + GLuint index; /* Mono index */ + GLuint count; /* Number of pixels in buffer */ + GLboolean mono; /* Same color or index for all pixels? */ + GLenum primitive; /* GL_POINT, GL_LINE, GL_POLYGON or GL_BITMAP*/ +}; + + +/* + * Initialize the Pixel Buffer, specifying the type of primitive being drawn. + */ +#define PB_INIT( PB, PRIM ) \ + (PB)->count = 0; \ + (PB)->mono = GL_FALSE; \ + (PB)->primitive = (PRIM); + + + +/* + * Set the color used for all subsequent pixels in the buffer. + */ +#define PB_SET_COLOR( CTX, PB, R, G, B, A ) \ + if ((PB)->color[0]!=(R) || (PB)->color[1]!=(G) \ + || (PB)->color[2]!=(B) || (PB)->color[3]!=(A) \ + || !(PB)->mono) { \ + gl_flush_pb( ctx ); \ + } \ + (PB)->color[0] = R; \ + (PB)->color[1] = G; \ + (PB)->color[2] = B; \ + (PB)->color[3] = A; \ + (PB)->mono = GL_TRUE; + + +/* + * Set the color index used for all subsequent pixels in the buffer. + */ +#define PB_SET_INDEX( CTX, PB, I ) \ + if ((PB)->index!=(I) || !(PB)->mono) { \ + gl_flush_pb( CTX ); \ + } \ + (PB)->index = I; \ + (PB)->mono = GL_TRUE; + + +/* + * "write" a pixel using current color or index + */ +#define PB_WRITE_PIXEL( PB, X, Y, Z ) \ + (PB)->x[(PB)->count] = X; \ + (PB)->y[(PB)->count] = Y; \ + (PB)->z[(PB)->count] = Z; \ + (PB)->count++; + + +/* + * "write" an RGBA pixel + */ +#define PB_WRITE_RGBA_PIXEL( PB, X, Y, Z, R, G, B, A ) \ + (PB)->x[(PB)->count] = X; \ + (PB)->y[(PB)->count] = Y; \ + (PB)->z[(PB)->count] = Z; \ + (PB)->r[(PB)->count] = R; \ + (PB)->g[(PB)->count] = G; \ + (PB)->b[(PB)->count] = B; \ + (PB)->a[(PB)->count] = A; \ + (PB)->count++; + +/* + * "write" a color-index pixel + */ +#define PB_WRITE_CI_PIXEL( PB, X, Y, Z, I ) \ + (PB)->x[(PB)->count] = X; \ + (PB)->y[(PB)->count] = Y; \ + (PB)->z[(PB)->count] = Z; \ + (PB)->i[(PB)->count] = I; \ + (PB)->count++; + + +/* + * "write" an RGBA pixel with texture coordinates + */ +#define PB_WRITE_TEX_PIXEL( PB, X, Y, Z, R, G, B, A, S, T, U ) \ + (PB)->x[(PB)->count] = X; \ + (PB)->y[(PB)->count] = Y; \ + (PB)->z[(PB)->count] = Z; \ + (PB)->r[(PB)->count] = R; \ + (PB)->g[(PB)->count] = G; \ + (PB)->b[(PB)->count] = B; \ + (PB)->a[(PB)->count] = A; \ + (PB)->s[(PB)->count] = S; \ + (PB)->t[(PB)->count] = T; \ + (PB)->u[(PB)->count] = U; \ + (PB)->count++; + + +/* + * Call this function at least every MAX_WIDTH pixels: + */ +#define PB_CHECK_FLUSH( CTX, PB ) \ + if ((PB)->count>=PB_SIZE-MAX_WIDTH) { \ + gl_flush_pb( CTX ); \ + } + + +extern struct pixel_buffer *gl_alloc_pb(void); + +extern void gl_flush_pb( GLcontext *ctx ); + +#endif diff --git a/dll/opengl/mesa/pixel.c b/dll/opengl/mesa/pixel.c new file mode 100644 index 00000000000..2d0691ac24d --- /dev/null +++ b/dll/opengl/mesa/pixel.c @@ -0,0 +1,991 @@ +/* $Id: pixel.c,v 1.8 1997/07/24 01:23:44 brianp Exp $ */ + +/* + * Mesa 3-D graphics library + * Version: 2.4 + * Copyright (C) 1995-1997 Brian Paul + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Library General Public + * License as published by the Free Software Foundation; either + * version 2 of the License, or (at your option) any later version. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Library General Public License for more details. + * + * You should have received a copy of the GNU Library General Public + * License along with this library; if not, write to the Free + * Software Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. + */ + + +/* + * $Log: pixel.c,v $ + * Revision 1.8 1997/07/24 01:23:44 brianp + * changed precompiled header symbol from PCH to PC_HEADER + * + * Revision 1.7 1997/05/28 03:26:02 brianp + * added precompiled header (PCH) support + * + * Revision 1.6 1997/02/09 20:05:03 brianp + * new arguments for gl_pixel_addr_in_image() + * + * Revision 1.5 1997/02/09 18:52:37 brianp + * added GL_EXT_texture3D support + * + * Revision 1.4 1996/11/06 04:09:37 brianp + * added a missing return after a gl_error() call + * + * Revision 1.3 1996/09/26 22:35:10 brianp + * fixed a few compiler warnings from IRIX 6 -n32 and -64 compiler + * + * Revision 1.2 1996/09/15 14:18:55 brianp + * now use GLframebuffer and GLvisual + * + * Revision 1.1 1996/09/13 01:38:16 brianp + * Initial revision + * + */ + + +/* + * glPixelStore, glPixelTransfer, glPixelMap, glPixelZoom, etc. + */ + + +#ifdef PC_HEADER +#include "all.h" +#else +#include +#include +#include +#include +#include "context.h" +#include "dlist.h" +#include "macros.h" +#include "pixel.h" +#include "image.h" +#include "span.h" +#include "stencil.h" +#include "types.h" +#endif + + + +/* + * Determine if we can use the optimized glDrawPixels function. + */ +static void update_drawpixels_state( GLcontext *ctx ) +{ + if (ctx->Visual->RGBAflag==GL_TRUE && + ctx->Visual->EightBitColor && + ctx->Pixel.RedBias==0.0 && ctx->Pixel.RedScale==1.0 && + ctx->Pixel.GreenBias==0.0 && ctx->Pixel.GreenScale==1.0 && + ctx->Pixel.BlueBias==0.0 && ctx->Pixel.BlueScale==1.0 && + ctx->Pixel.AlphaBias==0.0 && ctx->Pixel.AlphaScale==1.0 && + ctx->Pixel.MapColorFlag==GL_FALSE && + ctx->Pixel.ZoomX==1.0 && ctx->Pixel.ZoomY==1.0 && +/* ctx->Unpack.Alignment==4 &&*/ + ctx->Unpack.RowLength==0 && + ctx->Unpack.SkipPixels==0 && + ctx->Unpack.SkipRows==0 && + ctx->Unpack.SwapBytes==0 && + ctx->Unpack.LsbFirst==0) { + ctx->FastDrawPixels = GL_TRUE; + } + else { + ctx->FastDrawPixels = GL_FALSE; + } +} + + + + +/**********************************************************************/ +/***** glPixelZoom *****/ +/**********************************************************************/ + + + +void gl_PixelZoom( GLcontext *ctx, GLfloat xfactor, GLfloat yfactor ) +{ + if (INSIDE_BEGIN_END(ctx)) { + gl_error( ctx, GL_INVALID_OPERATION, "glPixelZoom" ); + return; + } + ctx->Pixel.ZoomX = xfactor; + ctx->Pixel.ZoomY = yfactor; + update_drawpixels_state( ctx ); +} + + + + +/* + * Write a span of pixels to the frame buffer while applying a pixel zoom. + * This is only used by glDrawPixels and glCopyPixels. + * Input: n - number of pixels in input row + * x, y - destination of the span + * z - depth values for the span + * red, green, blue, alpha - array of colors + * y0 - location of first row in the image we're drawing. + */ +void +gl_write_zoomed_color_span( GLcontext *ctx, + GLuint n, GLint x, GLint y, const GLdepth z[], + const GLubyte red[], const GLubyte green[], + const GLubyte blue[], const GLubyte alpha[], + GLint y0 ) +{ + GLint m; + GLint r0, r1, row, r; + GLint i, j, skipcol; + GLubyte zred[MAX_WIDTH], zgreen[MAX_WIDTH]; /* zoomed pixel colors */ + GLubyte zblue[MAX_WIDTH], zalpha[MAX_WIDTH]; + GLdepth zdepth[MAX_WIDTH]; /* zoomed depth values */ + GLint maxwidth = MIN2( ctx->Buffer->Width, MAX_WIDTH ); + + /* compute width of output row */ + m = (GLint) ABSF( n * ctx->Pixel.ZoomX ); + if (m==0) { + return; + } + if (ctx->Pixel.ZoomX<0.0) { + /* adjust x coordinate for left/right mirroring */ + x = x - m; + } + + /* compute which rows to draw */ + row = y-y0; + r0 = y0 + (GLint) (row * ctx->Pixel.ZoomY); + r1 = y0 + (GLint) ((row+1) * ctx->Pixel.ZoomY); + if (r0==r1) { + return; + } + else if (r1=ctx->Buffer->Height && r1>=ctx->Buffer->Height) { + /* above window */ + return; + } + + /* check if left edge is outside window */ + skipcol = 0; + if (x<0) { + skipcol = -x; + m += x; + } + /* make sure span isn't too long or short */ + if (m>maxwidth) { + m = maxwidth; + } + else if (m<=0) { + return; + } + + assert( m <= MAX_WIDTH ); + + /* zoom the span horizontally */ + if (ctx->Pixel.ZoomX==-1.0F) { + /* n==m */ + for (j=0;jPixel.ZoomX; + for (j=0;jBuffer->Width, MAX_WIDTH ); + + /* compute width of output row */ + m = (GLint) ABSF( n * ctx->Pixel.ZoomX ); + if (m==0) { + return; + } + if (ctx->Pixel.ZoomX<0.0) { + /* adjust x coordinate for left/right mirroring */ + x = x - m; + } + + /* compute which rows to draw */ + row = y-y0; + r0 = y0 + (GLint) (row * ctx->Pixel.ZoomY); + r1 = y0 + (GLint) ((row+1) * ctx->Pixel.ZoomY); + if (r0==r1) { + return; + } + else if (r1=ctx->Buffer->Height && r1>=ctx->Buffer->Height) { + /* above window */ + return; + } + + /* check if left edge is outside window */ + skipcol = 0; + if (x<0) { + skipcol = -x; + m += x; + } + /* make sure span isn't too long or short */ + if (m>maxwidth) { + m = maxwidth; + } + else if (m<=0) { + return; + } + + assert( m <= MAX_WIDTH ); + + /* zoom the span horizontally */ + if (ctx->Pixel.ZoomX==-1.0F) { + /* n==m */ + for (j=0;jPixel.ZoomX; + for (j=0;jBuffer->Width, MAX_WIDTH ); + + /* compute width of output row */ + m = (GLint) ABSF( n * ctx->Pixel.ZoomX ); + if (m==0) { + return; + } + if (ctx->Pixel.ZoomX<0.0) { + /* adjust x coordinate for left/right mirroring */ + x = x - m; + } + + /* compute which rows to draw */ + row = y-y0; + r0 = y0 + (GLint) (row * ctx->Pixel.ZoomY); + r1 = y0 + (GLint) ((row+1) * ctx->Pixel.ZoomY); + if (r0==r1) { + return; + } + else if (r1=ctx->Buffer->Height && r1>=ctx->Buffer->Height) { + /* above window */ + return; + } + + /* check if left edge is outside window */ + skipcol = 0; + if (x<0) { + skipcol = -x; + m += x; + } + /* make sure span isn't too long or short */ + if (m>maxwidth) { + m = maxwidth; + } + else if (m<=0) { + return; + } + + assert( m <= MAX_WIDTH ); + + /* zoom the span horizontally */ + if (ctx->Pixel.ZoomX==-1.0F) { + /* n==m */ + for (j=0;jPixel.ZoomX; + for (j=0;jPack.SwapBytes = param ? GL_TRUE : GL_FALSE; + break; + case GL_PACK_LSB_FIRST: + ctx->Pack.LsbFirst = param ? GL_TRUE : GL_FALSE; + break; + case GL_PACK_ROW_LENGTH: + if (param<0) { + gl_error( ctx, GL_INVALID_VALUE, "glPixelStore(param)" ); + } + else { + ctx->Pack.RowLength = param; + } + break; + case GL_PACK_SKIP_PIXELS: + if (param<0) { + gl_error( ctx, GL_INVALID_VALUE, "glPixelStore(param)" ); + } + else { + ctx->Pack.SkipPixels = param; + } + break; + case GL_PACK_SKIP_ROWS: + if (param<0) { + gl_error( ctx, GL_INVALID_VALUE, "glPixelStore(param)" ); + } + else { + ctx->Pack.SkipRows = param; + } + break; + case GL_PACK_ALIGNMENT: + if (param==1 || param==2 || param==4 || param==8) { + ctx->Pack.Alignment = param; + } + else { + gl_error( ctx, GL_INVALID_VALUE, "glPixelStore(param)" ); + } + break; + case GL_UNPACK_SWAP_BYTES: + ctx->Unpack.SwapBytes = param ? GL_TRUE : GL_FALSE; + break; + case GL_UNPACK_LSB_FIRST: + ctx->Unpack.LsbFirst = param ? GL_TRUE : GL_FALSE; + break; + case GL_UNPACK_ROW_LENGTH: + if (param<0) { + gl_error( ctx, GL_INVALID_VALUE, "glPixelStore(param)" ); + } + else { + ctx->Unpack.RowLength = param; + } + break; + case GL_UNPACK_SKIP_PIXELS: + if (param<0) { + gl_error( ctx, GL_INVALID_VALUE, "glPixelStore(param)" ); + } + else { + ctx->Unpack.SkipPixels = param; + } + break; + case GL_UNPACK_SKIP_ROWS: + if (param<0) { + gl_error( ctx, GL_INVALID_VALUE, "glPixelStore(param)" ); + } + else { + ctx->Unpack.SkipRows = param; + } + break; + case GL_UNPACK_ALIGNMENT: + if (param==1 || param==2 || param==4 || param==8) { + ctx->Unpack.Alignment = param; + } + else { + gl_error( ctx, GL_INVALID_VALUE, "glPixelStore" ); + } + break; + default: + gl_error( ctx, GL_INVALID_ENUM, "glPixelStore" ); + } + update_drawpixels_state( ctx ); +} + + + + + +/**********************************************************************/ +/***** glPixelMap *****/ +/**********************************************************************/ + + + +void gl_PixelMapfv( GLcontext *ctx, + GLenum map, GLint mapsize, const GLfloat *values ) +{ + GLuint i; + + if (INSIDE_BEGIN_END(ctx)) { + gl_error( ctx, GL_INVALID_OPERATION, "glPixelMapfv" ); + return; + } + + if (mapsize<0 || mapsize>MAX_PIXEL_MAP_TABLE) { + gl_error( ctx, GL_INVALID_VALUE, "glPixelMapfv(mapsize)" ); + return; + } + + if (map>=GL_PIXEL_MAP_S_TO_S && map<=GL_PIXEL_MAP_I_TO_A) { + /* test that mapsize is a power of two */ + GLuint p; + GLboolean ok = GL_FALSE; + for (p=1; p<=MAX_PIXEL_MAP_TABLE; p=p<<1) { + if ( (p&mapsize) == p ) { + ok = GL_TRUE; + break; + } + } + if (!ok) { + gl_error( ctx, GL_INVALID_VALUE, "glPixelMapfv(mapsize)" ); + return; + } + } + + switch (map) { + case GL_PIXEL_MAP_S_TO_S: + ctx->Pixel.MapStoSsize = mapsize; + for (i=0;iPixel.MapStoS[i] = (GLint) values[i]; + } + break; + case GL_PIXEL_MAP_I_TO_I: + ctx->Pixel.MapItoIsize = mapsize; + for (i=0;iPixel.MapItoI[i] = (GLint) values[i]; + } + break; + case GL_PIXEL_MAP_I_TO_R: + ctx->Pixel.MapItoRsize = mapsize; + for (i=0;iPixel.MapItoR[i] = CLAMP( values[i], 0.0, 1.0 ); + } + break; + case GL_PIXEL_MAP_I_TO_G: + ctx->Pixel.MapItoGsize = mapsize; + for (i=0;iPixel.MapItoG[i] = CLAMP( values[i], 0.0, 1.0 ); + } + break; + case GL_PIXEL_MAP_I_TO_B: + ctx->Pixel.MapItoBsize = mapsize; + for (i=0;iPixel.MapItoB[i] = CLAMP( values[i], 0.0, 1.0 ); + } + break; + case GL_PIXEL_MAP_I_TO_A: + ctx->Pixel.MapItoAsize = mapsize; + for (i=0;iPixel.MapItoA[i] = CLAMP( values[i], 0.0, 1.0 ); + } + break; + case GL_PIXEL_MAP_R_TO_R: + ctx->Pixel.MapRtoRsize = mapsize; + for (i=0;iPixel.MapRtoR[i] = CLAMP( values[i], 0.0, 1.0 ); + } + break; + case GL_PIXEL_MAP_G_TO_G: + ctx->Pixel.MapGtoGsize = mapsize; + for (i=0;iPixel.MapGtoG[i] = CLAMP( values[i], 0.0, 1.0 ); + } + break; + case GL_PIXEL_MAP_B_TO_B: + ctx->Pixel.MapBtoBsize = mapsize; + for (i=0;iPixel.MapBtoB[i] = CLAMP( values[i], 0.0, 1.0 ); + } + break; + case GL_PIXEL_MAP_A_TO_A: + ctx->Pixel.MapAtoAsize = mapsize; + for (i=0;iPixel.MapAtoA[i] = CLAMP( values[i], 0.0, 1.0 ); + } + break; + default: + gl_error( ctx, GL_INVALID_ENUM, "glPixelMapfv(map)" ); + } +} + + + + + +void gl_GetPixelMapfv( GLcontext *ctx, GLenum map, GLfloat *values ) +{ + GLuint i; + + if (INSIDE_BEGIN_END(ctx)) { + gl_error( ctx, GL_INVALID_OPERATION, "glGetPixelMapfv" ); + return; + } + switch (map) { + case GL_PIXEL_MAP_I_TO_I: + for (i=0;iPixel.MapItoIsize;i++) { + values[i] = (GLfloat) ctx->Pixel.MapItoI[i]; + } + break; + case GL_PIXEL_MAP_S_TO_S: + for (i=0;iPixel.MapStoSsize;i++) { + values[i] = (GLfloat) ctx->Pixel.MapStoS[i]; + } + break; + case GL_PIXEL_MAP_I_TO_R: + MEMCPY(values,ctx->Pixel.MapItoR,ctx->Pixel.MapItoRsize*sizeof(GLfloat)); + break; + case GL_PIXEL_MAP_I_TO_G: + MEMCPY(values,ctx->Pixel.MapItoG,ctx->Pixel.MapItoGsize*sizeof(GLfloat)); + break; + case GL_PIXEL_MAP_I_TO_B: + MEMCPY(values,ctx->Pixel.MapItoB,ctx->Pixel.MapItoBsize*sizeof(GLfloat)); + break; + case GL_PIXEL_MAP_I_TO_A: + MEMCPY(values,ctx->Pixel.MapItoA,ctx->Pixel.MapItoAsize*sizeof(GLfloat)); + break; + case GL_PIXEL_MAP_R_TO_R: + MEMCPY(values,ctx->Pixel.MapRtoR,ctx->Pixel.MapRtoRsize*sizeof(GLfloat)); + break; + case GL_PIXEL_MAP_G_TO_G: + MEMCPY(values,ctx->Pixel.MapGtoG,ctx->Pixel.MapGtoGsize*sizeof(GLfloat)); + break; + case GL_PIXEL_MAP_B_TO_B: + MEMCPY(values,ctx->Pixel.MapBtoB,ctx->Pixel.MapBtoBsize*sizeof(GLfloat)); + break; + case GL_PIXEL_MAP_A_TO_A: + MEMCPY(values,ctx->Pixel.MapAtoA,ctx->Pixel.MapAtoAsize*sizeof(GLfloat)); + break; + default: + gl_error( ctx, GL_INVALID_ENUM, "glGetPixelMapfv" ); + } +} + + +void gl_GetPixelMapuiv( GLcontext *ctx, GLenum map, GLuint *values ) +{ + GLuint i; + + if (INSIDE_BEGIN_END(ctx)) { + gl_error( ctx, GL_INVALID_OPERATION, "glGetPixelMapfv" ); + return; + } + switch (map) { + case GL_PIXEL_MAP_I_TO_I: + MEMCPY(values, ctx->Pixel.MapItoI, ctx->Pixel.MapItoIsize*sizeof(GLint)); + break; + case GL_PIXEL_MAP_S_TO_S: + MEMCPY(values, ctx->Pixel.MapStoS, ctx->Pixel.MapStoSsize*sizeof(GLint)); + break; + case GL_PIXEL_MAP_I_TO_R: + for (i=0;iPixel.MapItoRsize;i++) { + values[i] = FLOAT_TO_UINT( ctx->Pixel.MapItoR[i] ); + } + break; + case GL_PIXEL_MAP_I_TO_G: + for (i=0;iPixel.MapItoGsize;i++) { + values[i] = FLOAT_TO_UINT( ctx->Pixel.MapItoG[i] ); + } + break; + case GL_PIXEL_MAP_I_TO_B: + for (i=0;iPixel.MapItoBsize;i++) { + values[i] = FLOAT_TO_UINT( ctx->Pixel.MapItoB[i] ); + } + break; + case GL_PIXEL_MAP_I_TO_A: + for (i=0;iPixel.MapItoAsize;i++) { + values[i] = FLOAT_TO_UINT( ctx->Pixel.MapItoA[i] ); + } + break; + case GL_PIXEL_MAP_R_TO_R: + for (i=0;iPixel.MapRtoRsize;i++) { + values[i] = FLOAT_TO_UINT( ctx->Pixel.MapRtoR[i] ); + } + break; + case GL_PIXEL_MAP_G_TO_G: + for (i=0;iPixel.MapGtoGsize;i++) { + values[i] = FLOAT_TO_UINT( ctx->Pixel.MapGtoG[i] ); + } + break; + case GL_PIXEL_MAP_B_TO_B: + for (i=0;iPixel.MapBtoBsize;i++) { + values[i] = FLOAT_TO_UINT( ctx->Pixel.MapBtoB[i] ); + } + break; + case GL_PIXEL_MAP_A_TO_A: + for (i=0;iPixel.MapAtoAsize;i++) { + values[i] = FLOAT_TO_UINT( ctx->Pixel.MapAtoA[i] ); + } + break; + default: + gl_error( ctx, GL_INVALID_ENUM, "glGetPixelMapfv" ); + } +} + + +void gl_GetPixelMapusv( GLcontext *ctx, GLenum map, GLushort *values ) +{ + GLuint i; + + if (INSIDE_BEGIN_END(ctx)) { + gl_error( ctx, GL_INVALID_OPERATION, "glGetPixelMapfv" ); + return; + } + switch (map) { + case GL_PIXEL_MAP_I_TO_I: + for (i=0;iPixel.MapItoIsize;i++) { + values[i] = (GLushort) ctx->Pixel.MapItoI[i]; + } + break; + case GL_PIXEL_MAP_S_TO_S: + for (i=0;iPixel.MapStoSsize;i++) { + values[i] = (GLushort) ctx->Pixel.MapStoS[i]; + } + break; + case GL_PIXEL_MAP_I_TO_R: + for (i=0;iPixel.MapItoRsize;i++) { + values[i] = FLOAT_TO_USHORT( ctx->Pixel.MapItoR[i] ); + } + break; + case GL_PIXEL_MAP_I_TO_G: + for (i=0;iPixel.MapItoGsize;i++) { + values[i] = FLOAT_TO_USHORT( ctx->Pixel.MapItoG[i] ); + } + break; + case GL_PIXEL_MAP_I_TO_B: + for (i=0;iPixel.MapItoBsize;i++) { + values[i] = FLOAT_TO_USHORT( ctx->Pixel.MapItoB[i] ); + } + break; + case GL_PIXEL_MAP_I_TO_A: + for (i=0;iPixel.MapItoAsize;i++) { + values[i] = FLOAT_TO_USHORT( ctx->Pixel.MapItoA[i] ); + } + break; + case GL_PIXEL_MAP_R_TO_R: + for (i=0;iPixel.MapRtoRsize;i++) { + values[i] = FLOAT_TO_USHORT( ctx->Pixel.MapRtoR[i] ); + } + break; + case GL_PIXEL_MAP_G_TO_G: + for (i=0;iPixel.MapGtoGsize;i++) { + values[i] = FLOAT_TO_USHORT( ctx->Pixel.MapGtoG[i] ); + } + break; + case GL_PIXEL_MAP_B_TO_B: + for (i=0;iPixel.MapBtoBsize;i++) { + values[i] = FLOAT_TO_USHORT( ctx->Pixel.MapBtoB[i] ); + } + break; + case GL_PIXEL_MAP_A_TO_A: + for (i=0;iPixel.MapAtoAsize;i++) { + values[i] = FLOAT_TO_USHORT( ctx->Pixel.MapAtoA[i] ); + } + break; + default: + gl_error( ctx, GL_INVALID_ENUM, "glGetPixelMapfv" ); + } +} + + + +/**********************************************************************/ +/***** glPixelTransfer *****/ +/**********************************************************************/ + + +/* + * Implements glPixelTransfer[fi] whether called immediately or from a + * display list. + */ +void gl_PixelTransferf( GLcontext *ctx, GLenum pname, GLfloat param ) +{ + if (INSIDE_BEGIN_END(ctx)) { + gl_error( ctx, GL_INVALID_OPERATION, "glPixelTransfer" ); + return; + } + + switch (pname) { + case GL_MAP_COLOR: + ctx->Pixel.MapColorFlag = param ? GL_TRUE : GL_FALSE; + break; + case GL_MAP_STENCIL: + ctx->Pixel.MapStencilFlag = param ? GL_TRUE : GL_FALSE; + break; + case GL_INDEX_SHIFT: + ctx->Pixel.IndexShift = (GLint) param; + break; + case GL_INDEX_OFFSET: + ctx->Pixel.IndexOffset = (GLint) param; + break; + case GL_RED_SCALE: + ctx->Pixel.RedScale = param; + break; + case GL_RED_BIAS: + ctx->Pixel.RedBias = param; + break; + case GL_GREEN_SCALE: + ctx->Pixel.GreenScale = param; + break; + case GL_GREEN_BIAS: + ctx->Pixel.GreenBias = param; + break; + case GL_BLUE_SCALE: + ctx->Pixel.BlueScale = param; + break; + case GL_BLUE_BIAS: + ctx->Pixel.BlueBias = param; + break; + case GL_ALPHA_SCALE: + ctx->Pixel.AlphaScale = param; + break; + case GL_ALPHA_BIAS: + ctx->Pixel.AlphaBias = param; + break; + case GL_DEPTH_SCALE: + ctx->Pixel.DepthScale = param; + break; + case GL_DEPTH_BIAS: + ctx->Pixel.DepthBias = param; + break; + default: + gl_error( ctx, GL_INVALID_ENUM, "glPixelTransfer(pname)" ); + return; + } + update_drawpixels_state( ctx ); +} + + + + + +/**********************************************************************/ +/***** Pixel packing/unpacking *****/ +/**********************************************************************/ + + + +/* + * Unpack a 2-D pixel array/image. The unpacked format will be con- + * tiguous (no "empty" bytes) with byte/bit swapping applied as needed. + * Input: same as glDrawPixels + * Output: pointer to block of pixel data in same format and type as input + * or NULL if error. + */ +GLvoid *gl_unpack_pixels( GLcontext *ctx, + GLsizei width, GLsizei height, + GLenum format, GLenum type, + const GLvoid *pixels ) +{ + GLint s, n; + + s = gl_sizeof_type( type ); + if (s<0) { + gl_error( ctx, GL_INVALID_ENUM, "internal error in gl_unpack(type)" ); + return NULL; + } + + n = gl_components_in_format( format ); + if (n<0) { + gl_error( ctx, GL_INVALID_ENUM, "gl_unpack_pixels(format)" ); + return NULL; + } + + if (type==GL_BITMAP) { + /* BITMAP data */ + GLint bytes, i, width_in_bytes; + GLubyte *buffer, *dst; + GLvoid *src; + + /* Alloc dest storage */ + bytes = CEILING( width * height , 8 ); + buffer = (GLubyte *) malloc( bytes ); + if (!buffer) { + return NULL; + } + + /* Copy/unpack pixel data to buffer */ + width_in_bytes = CEILING( width, 8 ); + dst = buffer; + for (i=0;iUnpack, pixels, width, height, + format, type, i); + if (!src) { + free(buffer); + return NULL; + } + MEMCPY( dst, src, width_in_bytes ); + dst += width_in_bytes; + } + + /* Bit flipping */ + if (ctx->Unpack.LsbFirst) { + gl_flip_bytes( buffer, bytes ); + } + return (GLvoid *) buffer; + } + else { + /* Non-BITMAP data */ + GLint width_in_bytes, bytes, i; + GLubyte *buffer, *dst; + GLvoid *src; + + width_in_bytes = width * n * s; + + /* Alloc dest storage */ + bytes = height * width_in_bytes; + buffer = (GLubyte *) malloc( bytes ); + if (!buffer) { + return NULL; + } + + /* Copy/unpack pixel data to buffer */ + dst = buffer; + for (i=0;iUnpack, pixels, width, height, + format, type, i); + if (!src) { + free(buffer); + return NULL; + } + MEMCPY( dst, src, width_in_bytes ); + dst += width_in_bytes; + } + + /* Byte swapping */ + if (ctx->Unpack.SwapBytes && s>1) { + if (s==2) { + gl_swap2( (GLushort *) buffer, bytes/2 ); + } + else if (s==4) { + gl_swap4( (GLuint *) buffer, bytes/4 ); + } + } + return (GLvoid *) buffer; + } +} + + + + +/* + if (s>=a) { + k = n * l; + } + else { *s +#include +#include +#include "accum.h" +#include "alpha.h" +#include "attrib.h" +#include "bitmap.h" +#include "blend.h" +#include "clip.h" +#include "context.h" +#include "colortab.h" +#include "copypix.h" +#include "depth.h" +#include "drawpix.h" +#include "enable.h" +#include "eval.h" +#include "feedback.h" +#include "fog.h" +#include "get.h" +#include "light.h" +#include "lines.h" +#include "dlist.h" +#include "logic.h" +#include "macros.h" +#include "masking.h" +#include "matrix.h" +#include "misc.h" +#include "pixel.h" +#include "points.h" +#include "polygon.h" +#include "rastpos.h" +#include "readpix.h" +#include "rect.h" +#include "scissor.h" +#include "stencil.h" +#include "teximage.h" +#include "texobj.h" +#include "texstate.h" +#include "types.h" +#include "varray.h" +#include "vbfill.h" +#endif + + + +/* + * For debugging + */ +static void check_pointers( struct gl_api_table *table ) +{ + void **entry; + int numentries = sizeof( struct gl_api_table ) / sizeof(void*); + int i; + + entry = (void **) table; + + for (i=0;iAccum = gl_Accum; + table->AlphaFunc = gl_AlphaFunc; + table->AreTexturesResident = gl_AreTexturesResident; + table->ArrayElement = gl_ArrayElement; + table->Begin = gl_Begin; + table->BindTexture = gl_BindTexture; + table->Bitmap = gl_Bitmap; + table->BlendFunc = gl_BlendFunc; + table->CallList = gl_CallList; + table->CallLists = gl_CallLists; + table->Clear = gl_Clear; + table->ClearAccum = gl_ClearAccum; + table->ClearColor = gl_ClearColor; + table->ClearDepth = gl_ClearDepth; + table->ClearIndex = gl_ClearIndex; + table->ClearStencil = gl_ClearStencil; + table->ClipPlane = gl_ClipPlane; + table->Color3f = gl_Color3f; + table->Color3fv = gl_Color3fv; + table->Color4f = gl_Color4f; + table->Color4fv = gl_Color4fv; + table->Color4ub = gl_Color4ub; + table->Color4ubv = gl_Color4ubv; + table->ColorMask = gl_ColorMask; + table->ColorMaterial = gl_ColorMaterial; + table->ColorPointer = gl_ColorPointer; + table->ColorTable = gl_ColorTable; + table->ColorSubTable = gl_ColorSubTable; + table->CopyPixels = gl_CopyPixels; + table->CopyTexImage1D = gl_CopyTexImage1D; + table->CopyTexImage2D = gl_CopyTexImage2D; + table->CopyTexSubImage1D = gl_CopyTexSubImage1D; + table->CopyTexSubImage2D = gl_CopyTexSubImage2D; + table->CullFace = gl_CullFace; + table->DeleteLists = gl_DeleteLists; + table->DeleteTextures = gl_DeleteTextures; + table->DepthFunc = gl_DepthFunc; + table->DepthMask = gl_DepthMask; + table->DepthRange = gl_DepthRange; + table->Disable = gl_Disable; + table->DisableClientState = gl_DisableClientState; + table->DrawArrays = gl_DrawArrays; + table->DrawBuffer = gl_DrawBuffer; + table->DrawElements = gl_DrawElements; + table->DrawPixels = gl_DrawPixels; + table->EdgeFlag = gl_EdgeFlag; + table->EdgeFlagPointer = gl_EdgeFlagPointer; + table->Enable = gl_Enable; + table->EnableClientState = gl_EnableClientState; + table->End = gl_End; + table->EndList = gl_EndList; + table->EvalCoord1f = gl_EvalCoord1f; + table->EvalCoord2f = gl_EvalCoord2f; + table->EvalMesh1 = gl_EvalMesh1; + table->EvalMesh2 = gl_EvalMesh2; + table->EvalPoint1 = gl_EvalPoint1; + table->EvalPoint2 = gl_EvalPoint2; + table->FeedbackBuffer = gl_FeedbackBuffer; + table->Finish = gl_Finish; + table->Flush = gl_Flush; + table->Fogfv = gl_Fogfv; + table->FrontFace = gl_FrontFace; + table->Frustum = gl_Frustum; + table->GenLists = gl_GenLists; + table->GenTextures = gl_GenTextures; + table->GetBooleanv = gl_GetBooleanv; + table->GetClipPlane = gl_GetClipPlane; + table->GetColorTable = gl_GetColorTable; + table->GetColorTableParameteriv = gl_GetColorTableParameteriv; + table->GetDoublev = gl_GetDoublev; + table->GetError = gl_GetError; + table->GetFloatv = gl_GetFloatv; + table->GetIntegerv = gl_GetIntegerv; + table->GetPointerv = gl_GetPointerv; + table->GetLightfv = gl_GetLightfv; + table->GetLightiv = gl_GetLightiv; + table->GetMapdv = gl_GetMapdv; + table->GetMapfv = gl_GetMapfv; + table->GetMapiv = gl_GetMapiv; + table->GetMaterialfv = gl_GetMaterialfv; + table->GetMaterialiv = gl_GetMaterialiv; + table->GetPixelMapfv = gl_GetPixelMapfv; + table->GetPixelMapuiv = gl_GetPixelMapuiv; + table->GetPixelMapusv = gl_GetPixelMapusv; + table->GetPolygonStipple = gl_GetPolygonStipple; + table->GetString = gl_GetString; + table->GetTexEnvfv = gl_GetTexEnvfv; + table->GetTexEnviv = gl_GetTexEnviv; + table->GetTexGendv = gl_GetTexGendv; + table->GetTexGenfv = gl_GetTexGenfv; + table->GetTexGeniv = gl_GetTexGeniv; + table->GetTexImage = gl_GetTexImage; + table->GetTexLevelParameterfv = gl_GetTexLevelParameterfv; + table->GetTexLevelParameteriv = gl_GetTexLevelParameteriv; + table->GetTexParameterfv = gl_GetTexParameterfv; + table->GetTexParameteriv = gl_GetTexParameteriv; + table->Hint = gl_Hint; + table->Indexf = gl_Indexf; + table->Indexi = gl_Indexi; + table->IndexMask = gl_IndexMask; + table->IndexPointer = gl_IndexPointer; + table->InitNames = gl_InitNames; + table->InterleavedArrays = gl_InterleavedArrays; + table->IsEnabled = gl_IsEnabled; + table->IsList = gl_IsList; + table->IsTexture = gl_IsTexture; + table->LightModelfv = gl_LightModelfv; + table->Lightfv = gl_Lightfv; + table->LineStipple = gl_LineStipple; + table->LineWidth = gl_LineWidth; + table->ListBase = gl_ListBase; + table->LoadIdentity = gl_LoadIdentity; + table->LoadMatrixf = gl_LoadMatrixf; + table->LoadName = gl_LoadName; + table->LogicOp = gl_LogicOp; + table->Map1f = gl_Map1f; + table->Map2f = gl_Map2f; + table->MapGrid1f = gl_MapGrid1f; + table->MapGrid2f = gl_MapGrid2f; + table->Materialfv = gl_Materialfv; + table->MatrixMode = gl_MatrixMode; + table->MultMatrixf = gl_MultMatrixf; + table->NewList = gl_NewList; + table->Normal3f = gl_Normal3f; + table->NormalPointer = gl_NormalPointer; + table->Normal3fv = gl_Normal3fv; + table->Ortho = gl_Ortho; + table->PassThrough = gl_PassThrough; + table->PixelMapfv = gl_PixelMapfv; + table->PixelStorei = gl_PixelStorei; + table->PixelTransferf = gl_PixelTransferf; + table->PixelZoom = gl_PixelZoom; + table->PointSize = gl_PointSize; + table->PolygonMode = gl_PolygonMode; + table->PolygonOffset = gl_PolygonOffset; + table->PolygonStipple = gl_PolygonStipple; + table->PopAttrib = gl_PopAttrib; + table->PopClientAttrib = gl_PopClientAttrib; + table->PopMatrix = gl_PopMatrix; + table->PopName = gl_PopName; + table->PrioritizeTextures = gl_PrioritizeTextures; + table->PushAttrib = gl_PushAttrib; + table->PushClientAttrib = gl_PushClientAttrib; + table->PushMatrix = gl_PushMatrix; + table->PushName = gl_PushName; + table->RasterPos4f = gl_RasterPos4f; + table->ReadBuffer = gl_ReadBuffer; + table->ReadPixels = gl_ReadPixels; + table->Rectf = gl_Rectf; + table->RenderMode = gl_RenderMode; + table->Rotatef = gl_Rotatef; + table->Scalef = gl_Scalef; + table->Scissor = gl_Scissor; + table->SelectBuffer = gl_SelectBuffer; + table->ShadeModel = gl_ShadeModel; + table->StencilFunc = gl_StencilFunc; + table->StencilMask = gl_StencilMask; + table->StencilOp = gl_StencilOp; + table->TexCoord2f = gl_TexCoord2f; + table->TexCoord4f = gl_TexCoord4f; + table->TexCoordPointer = gl_TexCoordPointer; + table->TexEnvfv = gl_TexEnvfv; + table->TexGenfv = gl_TexGenfv; + table->TexImage1D = gl_TexImage1D; + table->TexImage2D = gl_TexImage2D; + table->TexSubImage1D = gl_TexSubImage1D; + table->TexSubImage2D = gl_TexSubImage2D; + table->TexParameterfv = gl_TexParameterfv; + table->Translatef = gl_Translatef; + table->Vertex2f = gl_vertex2f_nop; + table->Vertex3f = gl_vertex3f_nop; + table->Vertex4f = gl_vertex4f_nop; + table->Vertex3fv = gl_vertex3fv_nop; + table->VertexPointer = gl_VertexPointer; + table->Viewport = gl_Viewport; +} + + + +/* + * Assign all the pointers in 'table' to point to Mesa's display list + * building functions. + */ +static void init_dlist_pointers( struct gl_api_table *table ) +{ + table->Accum = gl_save_Accum; + table->AlphaFunc = gl_save_AlphaFunc; + table->AreTexturesResident = gl_AreTexturesResident; + table->ArrayElement = gl_save_ArrayElement; + table->Begin = gl_save_Begin; + table->BindTexture = gl_save_BindTexture; + table->Bitmap = gl_save_Bitmap; + table->BlendFunc = gl_save_BlendFunc; + table->CallList = gl_save_CallList; + table->CallLists = gl_save_CallLists; + table->Clear = gl_save_Clear; + table->ClearAccum = gl_save_ClearAccum; + table->ClearColor = gl_save_ClearColor; + table->ClearDepth = gl_save_ClearDepth; + table->ClearIndex = gl_save_ClearIndex; + table->ClearStencil = gl_save_ClearStencil; + table->ClipPlane = gl_save_ClipPlane; + table->Color3f = gl_save_Color3f; + table->Color3fv = gl_save_Color3fv; + table->Color4f = gl_save_Color4f; + table->Color4fv = gl_save_Color4fv; + table->Color4ub = gl_save_Color4ub; + table->Color4ubv = gl_save_Color4ubv; + table->ColorMask = gl_save_ColorMask; + table->ColorMaterial = gl_save_ColorMaterial; + table->ColorPointer = gl_ColorPointer; + table->ColorTable = gl_save_ColorTable; + table->ColorSubTable = gl_save_ColorSubTable; + table->CopyPixels = gl_save_CopyPixels; + table->CopyTexImage1D = gl_save_CopyTexImage1D; + table->CopyTexImage2D = gl_save_CopyTexImage2D; + table->CopyTexSubImage1D = gl_save_CopyTexSubImage1D; + table->CopyTexSubImage2D = gl_save_CopyTexSubImage2D; + table->CullFace = gl_save_CullFace; + table->DeleteLists = gl_DeleteLists; /* NOT SAVED */ + table->DeleteTextures = gl_DeleteTextures; /* NOT SAVED */ + table->DepthFunc = gl_save_DepthFunc; + table->DepthMask = gl_save_DepthMask; + table->DepthRange = gl_save_DepthRange; + table->Disable = gl_save_Disable; + table->DisableClientState = gl_DisableClientState; /* NOT SAVED */ + table->DrawArrays = gl_save_DrawArrays; + table->DrawBuffer = gl_save_DrawBuffer; + table->DrawElements = gl_save_DrawElements; + table->DrawPixels = gl_DrawPixels; /* SPECIAL CASE */ + table->EdgeFlag = gl_save_EdgeFlag; + table->EdgeFlagPointer = gl_EdgeFlagPointer; + table->Enable = gl_save_Enable; + table->EnableClientState = gl_EnableClientState; /* NOT SAVED */ + table->End = gl_save_End; + table->EndList = gl_EndList; /* NOT SAVED */ + table->EvalCoord1f = gl_save_EvalCoord1f; + table->EvalCoord2f = gl_save_EvalCoord2f; + table->EvalMesh1 = gl_save_EvalMesh1; + table->EvalMesh2 = gl_save_EvalMesh2; + table->EvalPoint1 = gl_save_EvalPoint1; + table->EvalPoint2 = gl_save_EvalPoint2; + table->FeedbackBuffer = gl_FeedbackBuffer; /* NOT SAVED */ + table->Finish = gl_Finish; /* NOT SAVED */ + table->Flush = gl_Flush; /* NOT SAVED */ + table->Fogfv = gl_save_Fogfv; + table->FrontFace = gl_save_FrontFace; + table->Frustum = gl_save_Frustum; + table->GenLists = gl_GenLists; /* NOT SAVED */ + table->GenTextures = gl_GenTextures; /* NOT SAVED */ + + /* NONE OF THESE COMMANDS ARE COMPILED INTO DISPLAY LISTS */ + table->GetBooleanv = gl_GetBooleanv; + table->GetClipPlane = gl_GetClipPlane; + table->GetColorTable = gl_GetColorTable; + table->GetColorTableParameteriv = gl_GetColorTableParameteriv; + table->GetDoublev = gl_GetDoublev; + table->GetError = gl_GetError; + table->GetFloatv = gl_GetFloatv; + table->GetIntegerv = gl_GetIntegerv; + table->GetString = gl_GetString; + table->GetLightfv = gl_GetLightfv; + table->GetLightiv = gl_GetLightiv; + table->GetMapdv = gl_GetMapdv; + table->GetMapfv = gl_GetMapfv; + table->GetMapiv = gl_GetMapiv; + table->GetMaterialfv = gl_GetMaterialfv; + table->GetMaterialiv = gl_GetMaterialiv; + table->GetPixelMapfv = gl_GetPixelMapfv; + table->GetPixelMapuiv = gl_GetPixelMapuiv; + table->GetPixelMapusv = gl_GetPixelMapusv; + table->GetPointerv = gl_GetPointerv; + table->GetPolygonStipple = gl_GetPolygonStipple; + table->GetTexEnvfv = gl_GetTexEnvfv; + table->GetTexEnviv = gl_GetTexEnviv; + table->GetTexGendv = gl_GetTexGendv; + table->GetTexGenfv = gl_GetTexGenfv; + table->GetTexGeniv = gl_GetTexGeniv; + table->GetTexImage = gl_GetTexImage; + table->GetTexLevelParameterfv = gl_GetTexLevelParameterfv; + table->GetTexLevelParameteriv = gl_GetTexLevelParameteriv; + table->GetTexParameterfv = gl_GetTexParameterfv; + table->GetTexParameteriv = gl_GetTexParameteriv; + + table->Hint = gl_save_Hint; + table->IndexMask = gl_save_IndexMask; + table->Indexf = gl_save_Indexf; + table->Indexi = gl_save_Indexi; + table->IndexPointer = gl_IndexPointer; + table->InitNames = gl_save_InitNames; + table->InterleavedArrays = gl_save_InterleavedArrays; + table->IsEnabled = gl_IsEnabled; /* NOT SAVED */ + table->IsTexture = gl_IsTexture; /* NOT SAVED */ + table->IsList = gl_IsList; /* NOT SAVED */ + table->LightModelfv = gl_save_LightModelfv; + table->Lightfv = gl_save_Lightfv; + table->LineStipple = gl_save_LineStipple; + table->LineWidth = gl_save_LineWidth; + table->ListBase = gl_save_ListBase; + table->LoadIdentity = gl_save_LoadIdentity; + table->LoadMatrixf = gl_save_LoadMatrixf; + table->LoadName = gl_save_LoadName; + table->LogicOp = gl_save_LogicOp; + table->Map1f = gl_save_Map1f; + table->Map2f = gl_save_Map2f; + table->MapGrid1f = gl_save_MapGrid1f; + table->MapGrid2f = gl_save_MapGrid2f; + table->Materialfv = gl_save_Materialfv; + table->MatrixMode = gl_save_MatrixMode; + table->MultMatrixf = gl_save_MultMatrixf; + table->NewList = gl_save_NewList; + table->Normal3f = gl_save_Normal3f; + table->Normal3fv = gl_save_Normal3fv; + table->NormalPointer = gl_NormalPointer; /* NOT SAVED */ + table->Ortho = gl_save_Ortho; + table->PassThrough = gl_save_PassThrough; + table->PixelMapfv = gl_save_PixelMapfv; + table->PixelStorei = gl_PixelStorei; /* NOT SAVED */ + table->PixelTransferf = gl_save_PixelTransferf; + table->PixelZoom = gl_save_PixelZoom; + table->PointSize = gl_save_PointSize; + table->PolygonMode = gl_save_PolygonMode; + table->PolygonOffset = gl_save_PolygonOffset; + table->PolygonStipple = gl_save_PolygonStipple; + table->PopAttrib = gl_save_PopAttrib; + table->PopClientAttrib = gl_PopClientAttrib; /* NOT SAVED */ + table->PopMatrix = gl_save_PopMatrix; + table->PopName = gl_save_PopName; + table->PrioritizeTextures = gl_save_PrioritizeTextures; + table->PushAttrib = gl_save_PushAttrib; + table->PushClientAttrib = gl_PushClientAttrib; /* NOT SAVED */ + table->PushMatrix = gl_save_PushMatrix; + table->PushName = gl_save_PushName; + table->RasterPos4f = gl_save_RasterPos4f; + table->ReadBuffer = gl_save_ReadBuffer; + table->ReadPixels = gl_ReadPixels; /* NOT SAVED */ + table->Rectf = gl_save_Rectf; + table->RenderMode = gl_RenderMode; /* NOT SAVED */ + table->Rotatef = gl_save_Rotatef; + table->Scalef = gl_save_Scalef; + table->Scissor = gl_save_Scissor; + table->SelectBuffer = gl_SelectBuffer; /* NOT SAVED */ + table->ShadeModel = gl_save_ShadeModel; + table->StencilFunc = gl_save_StencilFunc; + table->StencilMask = gl_save_StencilMask; + table->StencilOp = gl_save_StencilOp; + table->TexCoord2f = gl_save_TexCoord2f; + table->TexCoord4f = gl_save_TexCoord4f; + table->TexCoordPointer = gl_TexCoordPointer; /* NOT SAVED */ + table->TexEnvfv = gl_save_TexEnvfv; + table->TexGenfv = gl_save_TexGenfv; + table->TexImage1D = gl_save_TexImage1D; + table->TexImage2D = gl_save_TexImage2D; + table->TexSubImage1D = gl_save_TexSubImage1D; + table->TexSubImage2D = gl_save_TexSubImage2D; + table->TexParameterfv = gl_save_TexParameterfv; + table->Translatef = gl_save_Translatef; + table->Vertex2f = gl_save_Vertex2f; + table->Vertex3f = gl_save_Vertex3f; + table->Vertex4f = gl_save_Vertex4f; + table->Vertex3fv = gl_save_Vertex3fv; + table->VertexPointer = gl_VertexPointer; /* NOT SAVED */ + table->Viewport = gl_save_Viewport; +} + + + +void gl_init_api_function_pointers( GLcontext *ctx ) +{ + init_exec_pointers( &ctx->Exec ); + + init_dlist_pointers( &ctx->Save ); + + /* make sure there's no NULL pointers */ + check_pointers( &ctx->Exec ); + check_pointers( &ctx->Save ); +} + diff --git a/dll/opengl/mesa/pointers.h b/dll/opengl/mesa/pointers.h new file mode 100644 index 00000000000..fbf25bd51c4 --- /dev/null +++ b/dll/opengl/mesa/pointers.h @@ -0,0 +1,45 @@ +/* $Id: pointers.h,v 1.2 1996/10/16 00:52:22 brianp Exp $ */ + +/* + * Mesa 3-D graphics library + * Version: 2.0 + * Copyright (C) 1995-1996 Brian Paul + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Library General Public + * License as published by the Free Software Foundation; either + * version 2 of the License, or (at your option) any later version. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Library General Public License for more details. + * + * You should have received a copy of the GNU Library General Public + * License along with this library; if not, write to the Free + * Software Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. + */ + + +/* + * $Log: pointers.h,v $ + * Revision 1.2 1996/10/16 00:52:22 brianp + * gl_initialize_api_function_pointers() now gl_init_api_function_pointers() + * + * Revision 1.1 1996/09/13 01:38:16 brianp + * Initial revision + * + */ + + +#include "types.h" + + +#ifndef POINTERS_H +#define POINTERS_H + + +extern void gl_init_api_function_pointers( GLcontext *ctx ); + + +#endif diff --git a/dll/opengl/mesa/points.c b/dll/opengl/mesa/points.c new file mode 100644 index 00000000000..8f73bf4a9e4 --- /dev/null +++ b/dll/opengl/mesa/points.c @@ -0,0 +1,586 @@ +/* $Id: points.c,v 1.15 1998/02/03 23:46:00 brianp Exp $ */ + +/* + * Mesa 3-D graphics library + * Version: 2.5 + * Copyright (C) 1995-1997 Brian Paul + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Library General Public + * License as published by the Free Software Foundation; either + * version 2 of the License, or (at your option) any later version. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Library General Public License for more details. + * + * You should have received a copy of the GNU Library General Public + * License along with this library; if not, write to the Free + * Software Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. + */ + + +/* + * $Log: points.c,v $ + * Revision 1.15 1998/02/03 23:46:00 brianp + * fixed a few problems with condition expressions for Amiga StormC compiler + * + * Revision 1.14 1997/10/29 01:29:09 brianp + * added GL_EXT_point_parameters extension from Daniel Barrero + * + * Revision 1.13 1997/07/24 01:23:44 brianp + * changed precompiled header symbol from PCH to PC_HEADER + * + * Revision 1.12 1997/06/20 02:50:39 brianp + * changed color components from GLfixed to GLubyte + * + * Revision 1.11 1997/05/28 03:26:02 brianp + * added precompiled header (PCH) support + * + * Revision 1.10 1997/05/03 00:51:02 brianp + * removed calls to gl_texturing_enabled() + * + * Revision 1.9 1997/04/14 02:00:39 brianp + * #include "texstate.h" instead of "texture.h" + * + * Revision 1.8 1997/04/12 12:24:43 brianp + * replaced ctx->PointsFunc with ctx->Driver.PointsFunc + * + * Revision 1.7 1997/04/02 03:11:38 brianp + * replaced VB->Unclipped with VB->ClipMask + * + * Revision 1.6 1997/03/08 02:04:27 brianp + * better implementation of feedback function + * + * Revision 1.5 1997/02/09 18:43:52 brianp + * added GL_EXT_texture3D support + * + * Revision 1.4 1997/01/09 19:48:00 brianp + * now call gl_texturing_enabled() + * + * Revision 1.3 1996/11/08 02:21:21 brianp + * added null drawing function for GL_NO_RASTER + * + * Revision 1.2 1996/09/15 14:18:37 brianp + * now use GLframebuffer and GLvisual + * + * Revision 1.1 1996/09/13 01:38:16 brianp + * Initial revision + * + */ + + +#ifdef PC_HEADER +#include "all.h" +#else +#include "context.h" +#include "feedback.h" +#include "dlist.h" +#include "macros.h" +#include "pb.h" +#include "span.h" +#include "texstate.h" +#include "types.h" +#include "vb.h" +#include "mmath.h" +#endif + + + +void gl_PointSize( GLcontext *ctx, GLfloat size ) +{ + if (size<=0.0) { + gl_error( ctx, GL_INVALID_VALUE, "glPointSize" ); + return; + } + if (INSIDE_BEGIN_END(ctx)) { + gl_error( ctx, GL_INVALID_OPERATION, "glPointSize" ); + return; + } + ctx->Point.Size = size; + ctx->NewState |= NEW_RASTER_OPS; +} + + +/**********************************************************************/ +/***** Rasterization *****/ +/**********************************************************************/ + + +/* + * There are 3 pairs (RGBA, CI) of point rendering functions: + * 1. simple: size=1 and no special rasterization functions (fastest) + * 2. size1: size=1 and any rasterization functions + * 3. general: any size and rasterization functions (slowest) + * + * All point rendering functions take the same two arguments: first and + * last which specify that the points specified by VB[first] through + * VB[last] are to be rendered. + */ + + + +/* + * Put points in feedback buffer. + */ +static void feedback_points( GLcontext *ctx, GLuint first, GLuint last ) +{ + struct vertex_buffer *VB = ctx->VB; + GLuint i; + GLfloat invRedScale = ctx->Visual->InvRedScale; + GLfloat invGreenScale = ctx->Visual->InvGreenScale; + GLfloat invBlueScale = ctx->Visual->InvBlueScale; + GLfloat invAlphaScale = ctx->Visual->InvAlphaScale; + + for (i=first;i<=last;i++) { + if (VB->ClipMask[i]==0) { + GLfloat x, y, z, w, invq; + GLfloat color[4], texcoord[4]; + + x = VB->Win[i][0]; + y = VB->Win[i][1]; + z = VB->Win[i][2] / DEPTH_SCALE; + w = VB->Clip[i][3]; + + /* convert color from integer back to a float in [0,1] */ + if (ctx->Light.ShadeModel==GL_SMOOTH) { + /* smooth shading - colors are in fixed point */ + color[0] = FixedToFloat(VB->Color[i][0]) * invRedScale; + color[1] = FixedToFloat(VB->Color[i][1]) * invGreenScale; + color[2] = FixedToFloat(VB->Color[i][2]) * invBlueScale; + color[3] = FixedToFloat(VB->Color[i][3]) * invAlphaScale; + } + else { + /* flat shading - colors are integers */ + color[0] = VB->Color[i][0] * invRedScale; + color[1] = VB->Color[i][1] * invGreenScale; + color[2] = VB->Color[i][2] * invBlueScale; + color[3] = VB->Color[i][3] * invAlphaScale; + } + invq = 1.0F / VB->TexCoord[i][3]; + texcoord[0] = VB->TexCoord[i][0] * invq; + texcoord[1] = VB->TexCoord[i][1] * invq; + texcoord[2] = VB->TexCoord[i][2] * invq; + texcoord[3] = VB->TexCoord[i][3]; + + FEEDBACK_TOKEN( ctx, (GLfloat) (GLint) GL_POINT_TOKEN ); + gl_feedback_vertex( ctx, x, y, z, w, color, + (GLfloat) VB->Index[i], texcoord ); + } + } +} + + + +/* + * Put points in selection buffer. + */ +static void select_points( GLcontext *ctx, GLuint first, GLuint last ) +{ + struct vertex_buffer *VB = ctx->VB; + GLuint i; + + for (i=first;i<=last;i++) { + if (VB->ClipMask[i]==0) { + gl_update_hitflag( ctx, VB->Win[i][2] / DEPTH_SCALE ); + } + } +} + + +/* + * CI points with size == 1.0 + */ +void size1_ci_points( GLcontext *ctx, GLuint first, GLuint last ) +{ + struct vertex_buffer *VB = ctx->VB; + struct pixel_buffer *PB = ctx->PB; + GLfloat *win; + GLint *pbx = PB->x, *pby = PB->y; + GLdepth *pbz = PB->z; + GLuint *pbi = PB->i; + GLuint pbcount = PB->count; + GLuint i; + + win = &VB->Win[first][0]; + for (i=first;i<=last;i++) { + if (VB->ClipMask[i]==0) { + pbx[pbcount] = (GLint) win[0]; + pby[pbcount] = (GLint) win[1]; + pbz[pbcount] = (GLint) (win[2] + ctx->PointZoffset); + pbi[pbcount] = VB->Index[i]; + pbcount++; + } + win += 3; + } + PB->count = pbcount; + PB_CHECK_FLUSH(ctx, PB) +} + + + +/* + * RGBA points with size == 1.0 + */ +static void size1_rgba_points( GLcontext *ctx, GLuint first, GLuint last ) +{ + struct vertex_buffer *VB = ctx->VB; + struct pixel_buffer *PB = ctx->PB; + GLuint i; + + for (i=first;i<=last;i++) { + if (VB->ClipMask[i]==0) { + GLint x, y, z; + GLint red, green, blue, alpha; + + x = (GLint) VB->Win[i][0]; + y = (GLint) VB->Win[i][1]; + z = (GLint) (VB->Win[i][2] + ctx->PointZoffset); + + red = VB->Color[i][0]; + green = VB->Color[i][1]; + blue = VB->Color[i][2]; + alpha = VB->Color[i][3]; + + PB_WRITE_RGBA_PIXEL( PB, x, y, z, red, green, blue, alpha ); + } + } + PB_CHECK_FLUSH(ctx,PB) +} + + + +/* + * General CI points. + */ +static void general_ci_points( GLcontext *ctx, GLuint first, GLuint last ) +{ + struct vertex_buffer *VB = ctx->VB; + struct pixel_buffer *PB = ctx->PB; + GLuint i; + GLint isize; + + isize = (GLint) (CLAMP(ctx->Point.Size,MIN_POINT_SIZE,MAX_POINT_SIZE) + 0.5F); + + for (i=first;i<=last;i++) { + if (VB->ClipMask[i]==0) { + GLint x, y, z; + GLint x0, x1, y0, y1; + GLint ix, iy; + + x = (GLint) VB->Win[i][0]; + y = (GLint) VB->Win[i][1]; + z = (GLint) (VB->Win[i][2] + ctx->PointZoffset); + + if (isize&1) { + /* odd size */ + x0 = x - isize/2; + x1 = x + isize/2; + y0 = y - isize/2; + y1 = y + isize/2; + } + else { + /* even size */ + x0 = (GLint) (x + 0.5F) - isize/2; + x1 = x0 + isize-1; + y0 = (GLint) (y + 0.5F) - isize/2; + y1 = y0 + isize-1; + } + + PB_SET_INDEX( ctx, PB, VB->Index[i] ); + + for (iy=y0;iy<=y1;iy++) { + for (ix=x0;ix<=x1;ix++) { + PB_WRITE_PIXEL( PB, ix, iy, z ); + } + } + PB_CHECK_FLUSH(ctx,PB) + } + } +} + + +/* + * General RGBA points. + */ +static void general_rgba_points( GLcontext *ctx, GLuint first, GLuint last ) +{ + struct vertex_buffer *VB = ctx->VB; + struct pixel_buffer *PB = ctx->PB; + GLuint i; + GLint isize; + + isize = (GLint) (CLAMP(ctx->Point.Size,MIN_POINT_SIZE,MAX_POINT_SIZE) + 0.5F); + + for (i=first;i<=last;i++) { + if (VB->ClipMask[i]==0) { + GLint x, y, z; + GLint x0, x1, y0, y1; + GLint ix, iy; + + x = (GLint) VB->Win[i][0]; + y = (GLint) VB->Win[i][1]; + z = (GLint) (VB->Win[i][2] + ctx->PointZoffset); + + if (isize&1) { + /* odd size */ + x0 = x - isize/2; + x1 = x + isize/2; + y0 = y - isize/2; + y1 = y + isize/2; + } + else { + /* even size */ + x0 = (GLint) (x + 0.5F) - isize/2; + x1 = x0 + isize-1; + y0 = (GLint) (y + 0.5F) - isize/2; + y1 = y0 + isize-1; + } + + PB_SET_COLOR( ctx, PB, + VB->Color[i][0], + VB->Color[i][1], + VB->Color[i][2], + VB->Color[i][3] ); + + for (iy=y0;iy<=y1;iy++) { + for (ix=x0;ix<=x1;ix++) { + PB_WRITE_PIXEL( PB, ix, iy, z ); + } + } + PB_CHECK_FLUSH(ctx,PB) + } + } +} + + + + +/* + * Textured RGBA points. + */ +static void textured_rgba_points( GLcontext *ctx, GLuint first, GLuint last ) +{ + struct vertex_buffer *VB = ctx->VB; + struct pixel_buffer *PB = ctx->PB; + GLuint i; + + for (i=first;i<=last;i++) { + if (VB->ClipMask[i]==0) { + GLint x, y, z; + GLint x0, x1, y0, y1; + GLint ix, iy; + GLint isize; + GLint red, green, blue, alpha; + GLfloat s, t, u; + + x = (GLint) VB->Win[i][0]; + y = (GLint) VB->Win[i][1]; + z = (GLint) (VB->Win[i][2] + ctx->PointZoffset); + + isize = (GLint) + (CLAMP(ctx->Point.Size,MIN_POINT_SIZE,MAX_POINT_SIZE) + 0.5F); + if (isize<1) { + isize = 1; + } + + if (isize&1) { + /* odd size */ + x0 = x - isize/2; + x1 = x + isize/2; + y0 = y - isize/2; + y1 = y + isize/2; + } + else { + /* even size */ + x0 = (GLint) (x + 0.5F) - isize/2; + x1 = x0 + isize-1; + y0 = (GLint) (y + 0.5F) - isize/2; + y1 = y0 + isize-1; + } + + red = VB->Color[i][0]; + green = VB->Color[i][1]; + blue = VB->Color[i][2]; + alpha = VB->Color[i][3]; + s = VB->TexCoord[i][0] / VB->TexCoord[i][3]; + t = VB->TexCoord[i][1] / VB->TexCoord[i][3]; + u = VB->TexCoord[i][2] / VB->TexCoord[i][3]; + +/* don't think this is needed + PB_SET_COLOR( red, green, blue, alpha ); +*/ + + for (iy=y0;iy<=y1;iy++) { + for (ix=x0;ix<=x1;ix++) { + PB_WRITE_TEX_PIXEL( PB, ix, iy, z, red, green, blue, alpha, s, t, u ); + } + } + PB_CHECK_FLUSH(ctx,PB) + } + } +} + + + +/* + * Antialiased points with or without texture mapping. + */ +static void antialiased_rgba_points( GLcontext *ctx, + GLuint first, GLuint last ) +{ + struct vertex_buffer *VB = ctx->VB; + struct pixel_buffer *PB = ctx->PB; + GLuint i; + GLfloat radius, rmin, rmax, rmin2, rmax2, cscale; + + radius = CLAMP( ctx->Point.Size, MIN_POINT_SIZE, MAX_POINT_SIZE ) * 0.5F; + rmin = radius - 0.7071F; /* 0.7071 = sqrt(2)/2 */ + rmax = radius + 0.7071F; + rmin2 = rmin*rmin; + rmax2 = rmax*rmax; + cscale = 256.0F / (rmax2-rmin2); + + if (ctx->Texture.Enabled) { + for (i=first;i<=last;i++) { + if (VB->ClipMask[i]==0) { + GLint xmin, ymin, xmax, ymax; + GLint x, y, z; + GLint red, green, blue, alpha; + GLfloat s, t, u; + + xmin = (GLint) (VB->Win[i][0] - radius); + xmax = (GLint) (VB->Win[i][0] + radius); + ymin = (GLint) (VB->Win[i][1] - radius); + ymax = (GLint) (VB->Win[i][1] + radius); + z = (GLint) (VB->Win[i][2] + ctx->PointZoffset); + + red = VB->Color[i][0]; + green = VB->Color[i][1]; + blue = VB->Color[i][2]; + s = VB->TexCoord[i][0] / VB->TexCoord[i][3]; + t = VB->TexCoord[i][1] / VB->TexCoord[i][3]; + u = VB->TexCoord[i][2] / VB->TexCoord[i][3]; + + for (y=ymin;y<=ymax;y++) { + for (x=xmin;x<=xmax;x++) { + GLfloat dx = x/*+0.5F*/ - VB->Win[i][0]; + GLfloat dy = y/*+0.5F*/ - VB->Win[i][1]; + GLfloat dist2 = dx*dx + dy*dy; + if (dist2Color[i][3]; + if (dist2>=rmin2) { + GLint coverage = (GLint) (256.0F-(dist2-rmin2)*cscale); + /* coverage is in [0,256] */ + alpha = (alpha * coverage) >> 8; + } + PB_WRITE_TEX_PIXEL( PB, x,y,z, red, green, blue, alpha, s, t, u ); + } + } + } + PB_CHECK_FLUSH(ctx,PB) + } + } + } + else { + /* Not texture mapped */ + for (i=first;i<=last;i++) { + if (VB->ClipMask[i]==0) { + GLint xmin, ymin, xmax, ymax; + GLint x, y, z; + GLint red, green, blue, alpha; + + xmin = (GLint) (VB->Win[i][0] - radius); + xmax = (GLint) (VB->Win[i][0] + radius); + ymin = (GLint) (VB->Win[i][1] - radius); + ymax = (GLint) (VB->Win[i][1] + radius); + z = (GLint) (VB->Win[i][2] + ctx->PointZoffset); + + red = VB->Color[i][0]; + green = VB->Color[i][1]; + blue = VB->Color[i][2]; + + for (y=ymin;y<=ymax;y++) { + for (x=xmin;x<=xmax;x++) { + GLfloat dx = x/*+0.5F*/ - VB->Win[i][0]; + GLfloat dy = y/*+0.5F*/ - VB->Win[i][1]; + GLfloat dist2 = dx*dx + dy*dy; + if (dist2Color[i][3]; + if (dist2>=rmin2) { + GLint coverage = (GLint) (256.0F-(dist2-rmin2)*cscale); + /* coverage is in [0,256] */ + alpha = (alpha * coverage) >> 8; + } + PB_WRITE_RGBA_PIXEL( PB, x, y, z, red, green, blue, alpha ); + } + } + } + PB_CHECK_FLUSH(ctx,PB) + } + } + } +} + + + +/* + * Null rasterizer for measuring transformation speed. + */ +static void null_points( GLcontext *ctx, GLuint first, GLuint last ) +{ +} + +/* Definition of the functions for GL_EXT_point_parameters */ + +/* + * Examine the current context to determine which point drawing function + * should be used. + */ +void gl_set_point_function( GLcontext *ctx ) +{ + GLboolean rgbmode = ctx->Visual->RGBAflag; + + if (ctx->RenderMode==GL_RENDER) { + if (ctx->NoRaster) { + ctx->Driver.PointsFunc = null_points; + return; + } + if (ctx->Driver.PointsFunc) { + /* Device driver will draw points. */ + ctx->Driver.PointsFunc = ctx->Driver.PointsFunc; + } + else { + if (ctx->Point.SmoothFlag && rgbmode) { + ctx->Driver.PointsFunc = antialiased_rgba_points; + } + else if (ctx->Texture.Enabled) { + ctx->Driver.PointsFunc = textured_rgba_points; + } + else if (ctx->Point.Size==1.0) { + /* size=1, any raster ops */ + if (rgbmode) + ctx->Driver.PointsFunc = size1_rgba_points; + else + ctx->Driver.PointsFunc = size1_ci_points; + } + else { + /* every other kind of point rendering */ + if (rgbmode) + ctx->Driver.PointsFunc = general_rgba_points; + else + ctx->Driver.PointsFunc = general_ci_points; + } + } + } + else if (ctx->RenderMode==GL_FEEDBACK) { + ctx->Driver.PointsFunc = feedback_points; + } + else { + /* GL_SELECT mode */ + ctx->Driver.PointsFunc = select_points; + } + +} + diff --git a/dll/opengl/mesa/points.h b/dll/opengl/mesa/points.h new file mode 100644 index 00000000000..6dbebe7f5d3 --- /dev/null +++ b/dll/opengl/mesa/points.h @@ -0,0 +1,46 @@ +/* $Id: points.h,v 1.2 1997/10/29 01:29:09 brianp Exp $ */ + +/* + * Mesa 3-D graphics library + * Version: 2.5 + * Copyright (C) 1995-1996 Brian Paul + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Library General Public + * License as published by the Free Software Foundation; either + * version 2 of the License, or (at your option) any later version. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Library General Public License for more details. + * + * You should have received a copy of the GNU Library General Public + * License along with this library; if not, write to the Free + * Software Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. + */ + + +/* + * $Log: points.h,v $ + * Revision 1.2 1997/10/29 01:29:09 brianp + * added GL_EXT_point_parameters extension from Daniel Barrero + * + * Revision 1.1 1996/09/13 01:38:16 brianp + * Initial revision + * + */ + + +#ifndef POINTS_H +#define POINTS_H + + +#include "types.h" + + +extern void gl_PointSize( GLcontext *ctx, GLfloat size ); + +extern void gl_set_point_function( GLcontext *ctx ); + +#endif diff --git a/dll/opengl/mesa/polygon.c b/dll/opengl/mesa/polygon.c new file mode 100644 index 00000000000..179f8d5e45d --- /dev/null +++ b/dll/opengl/mesa/polygon.c @@ -0,0 +1,171 @@ +/* $Id: polygon.c,v 1.7 1997/07/24 01:23:44 brianp Exp $ */ + +/* + * Mesa 3-D graphics library + * Version: 2.4 + * Copyright (C) 1995-1997 Brian Paul + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Library General Public + * License as published by the Free Software Foundation; either + * version 2 of the License, or (at your option) any later version. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Library General Public License for more details. + * + * You should have received a copy of the GNU Library General Public + * License along with this library; if not, write to the Free + * Software Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. + */ + + +/* + * $Log: polygon.c,v $ + * Revision 1.7 1997/07/24 01:23:44 brianp + * changed precompiled header symbol from PCH to PC_HEADER + * + * Revision 1.6 1997/06/03 01:58:27 brianp + * fixed unpacking bug in gl_PolygonStipple() + * + * Revision 1.5 1997/05/28 03:26:02 brianp + * added precompiled header (PCH) support + * + * Revision 1.4 1997/04/12 16:54:05 brianp + * new NEW_POLYGON state flag + * + * Revision 1.3 1996/10/11 03:44:58 brianp + * removed Polygon.OffsetBias + * + * Revision 1.2 1996/09/26 22:48:40 brianp + * set NEW_RASTER_OPS flag in gl_PolygonStipple() if stippling enabled + * + * Revision 1.1 1996/09/13 01:38:16 brianp + * Initial revision + * + */ + + +#ifdef PC_HEADER +#include "all.h" +#else +#include +#include +#include +#include "context.h" +#include "macros.h" +#include "polygon.h" +#include "types.h" +#endif + + + +void gl_CullFace( GLcontext *ctx, GLenum mode ) +{ + if (mode!=GL_FRONT && mode!=GL_BACK && mode!=GL_FRONT_AND_BACK) { + gl_error( ctx, GL_INVALID_ENUM, "glCullFace" ); + return; + } + if (INSIDE_BEGIN_END(ctx)) { + gl_error( ctx, GL_INVALID_OPERATION, "glCullFace" ); + return; + } + ctx->Polygon.CullFaceMode = mode; + ctx->NewState |= NEW_POLYGON; +} + + + +void gl_FrontFace( GLcontext *ctx, GLenum mode ) +{ + if (INSIDE_BEGIN_END(ctx)) { + gl_error( ctx, GL_INVALID_OPERATION, "glFrontFace" ); + return; + } + if (mode!=GL_CW && mode!=GL_CCW) { + gl_error( ctx, GL_INVALID_ENUM, "glFrontFace" ); + return; + } + ctx->Polygon.FrontFace = mode; +} + + + +void gl_PolygonMode( GLcontext *ctx, GLenum face, GLenum mode ) +{ + if (INSIDE_BEGIN_END(ctx)) { + gl_error( ctx, GL_INVALID_OPERATION, "glPolygonMode" ); + return; + } + if (face!=GL_FRONT && face!=GL_BACK && face!=GL_FRONT_AND_BACK) { + gl_error( ctx, GL_INVALID_ENUM, "glPolygonMode(face)" ); + return; + } + else if (mode!=GL_POINT && mode!=GL_LINE && mode!=GL_FILL) { + gl_error( ctx, GL_INVALID_ENUM, "glPolygonMode(mode)" ); + return; + } + + if (face==GL_FRONT || face==GL_FRONT_AND_BACK) { + ctx->Polygon.FrontMode = mode; + } + if (face==GL_BACK || face==GL_FRONT_AND_BACK) { + ctx->Polygon.BackMode = mode; + } + + /* Compute a handy "shortcut" value: */ + if (ctx->Polygon.FrontMode!=GL_FILL || ctx->Polygon.BackMode!=GL_FILL) { + ctx->Polygon.Unfilled = GL_TRUE; + } + else { + ctx->Polygon.Unfilled = GL_FALSE; + } + + ctx->NewState |= NEW_POLYGON; +} + + + +void gl_PolygonStipple( GLcontext *ctx, const GLubyte *mask ) +{ + GLint i; + + if (INSIDE_BEGIN_END(ctx)) { + gl_error( ctx, GL_INVALID_OPERATION, "glPolygonStipple" ); + return; + } + + /* TODO: bit twiddling, unpacking */ + for (i=0;i<32;i++) { + ctx->PolygonStipple[i] = (mask[i*4+0] << 24) + | (mask[i*4+1] << 16) + | (mask[i*4+2] << 8) + | (mask[i*4+3]); + } + + if (ctx->Polygon.StippleFlag) { + ctx->NewState |= NEW_RASTER_OPS; + } +} + + + +void gl_GetPolygonStipple( GLcontext *ctx, GLubyte *mask ) +{ + /* TODO */ +} + + + +void gl_PolygonOffset( GLcontext *ctx, + GLfloat factor, GLfloat units ) +{ + if (INSIDE_BEGIN_END(ctx)) { + gl_error( ctx, GL_INVALID_OPERATION, "glPolygonOffset" ); + return; + } + ctx->Polygon.OffsetFactor = factor; + ctx->Polygon.OffsetUnits = units; +} + diff --git a/dll/opengl/mesa/polygon.h b/dll/opengl/mesa/polygon.h new file mode 100644 index 00000000000..9550a7d4916 --- /dev/null +++ b/dll/opengl/mesa/polygon.h @@ -0,0 +1,54 @@ +/* $Id: polygon.h,v 1.1 1996/09/13 01:38:16 brianp Exp $ */ + +/* + * Mesa 3-D graphics library + * Version: 2.0 + * Copyright (C) 1995-1996 Brian Paul + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Library General Public + * License as published by the Free Software Foundation; either + * version 2 of the License, or (at your option) any later version. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Library General Public License for more details. + * + * You should have received a copy of the GNU Library General Public + * License along with this library; if not, write to the Free + * Software Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. + */ + + +/* + * $Log: polygon.h,v $ + * Revision 1.1 1996/09/13 01:38:16 brianp + * Initial revision + * + */ + + +#ifndef POLYGON_H +#define POLYGON_H + + +#include "types.h" + + +extern void gl_CullFace( GLcontext *ctx, GLenum mode ); + +extern void gl_FrontFace( GLcontext *ctx, GLenum mode ); + +extern void gl_PolygonMode( GLcontext *ctx, GLenum face, GLenum mode ); + +extern void gl_PolygonOffset( GLcontext *ctx, + GLfloat factor, GLfloat units ); + +extern void gl_PolygonStipple( GLcontext *ctx, const GLubyte *mask ); + +extern void gl_GetPolygonStipple( GLcontext *ctx, GLubyte *mask ); + + +#endif + diff --git a/dll/opengl/mesa/quads.c b/dll/opengl/mesa/quads.c new file mode 100644 index 00000000000..db124fd31d9 --- /dev/null +++ b/dll/opengl/mesa/quads.c @@ -0,0 +1,101 @@ +/* $Id: quads.c,v 1.5 1997/08/19 02:44:18 brianp Exp $ */ + +/* + * Mesa 3-D graphics library + * Version: 2.4 + * Copyright (C) 1995-1997 Brian Paul + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Library General Public + * License as published by the Free Software Foundation; either + * version 2 of the License, or (at your option) any later version. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Library General Public License for more details. + * + * You should have received a copy of the GNU Library General Public + * License along with this library; if not, write to the Free + * Software Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. + */ + + +/* + * $Log: quads.c,v $ + * Revision 1.5 1997/08/19 02:44:18 brianp + * added null_quad() and re-implemented gl_set_quad_function() + * + * Revision 1.4 1997/07/24 01:23:44 brianp + * changed precompiled header symbol from PCH to PC_HEADER + * + * Revision 1.3 1997/05/28 03:26:18 brianp + * added precompiled header (PCH) support + * + * Revision 1.2 1997/04/20 19:45:46 brianp + * added a comment + * + * Revision 1.1 1997/04/12 12:24:07 brianp + * Initial revision + * + */ + + +/* + * Quadrilateral rendering functions. + */ + + +#ifdef PC_HEADER +#include "all.h" +#else +#include "types.h" +#include "quads.h" +#endif + + + +/* + * At this time there is no quadrilateral optimization. Just call the + * triangle function twice. + * v0, v1, v2, v3 in CCW order = front facing. + */ +static void quad( GLcontext *ctx, + GLuint v0, GLuint v1, GLuint v2, GLuint v3, GLuint pv ) +{ + (*ctx->Driver.TriangleFunc)( ctx, v0, v1, v3, pv ); + (*ctx->Driver.TriangleFunc)( ctx, v1, v2, v3, pv ); +} + + + +/* + * Draw nothing (NULL raster mode) + */ +static void null_quad( GLcontext *ctx, + GLuint v0, GLuint v1, GLuint v2, GLuint v3, GLuint pv ) +{ +} + + + +void gl_set_quad_function( GLcontext *ctx ) +{ + if (ctx->RenderMode==GL_RENDER) { + if (ctx->NoRaster) { + ctx->Driver.QuadFunc = null_quad; + } + else if (ctx->Driver.QuadFunc) { + /* Device driver will draw quads. */ + } + else { + ctx->Driver.QuadFunc = quad; + } + } + else { + /* if in feedback or selection mode we can fall back to triangle code */ + ctx->Driver.QuadFunc = quad; + } +} + + diff --git a/dll/opengl/mesa/quads.h b/dll/opengl/mesa/quads.h new file mode 100644 index 00000000000..13e1e2c091d --- /dev/null +++ b/dll/opengl/mesa/quads.h @@ -0,0 +1,42 @@ +/* $Id: quads.h,v 1.1 1997/04/12 12:24:07 brianp Exp $ */ + +/* + * Mesa 3-D graphics library + * Version: 2.3 + * Copyright (C) 1995-1997 Brian Paul + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Library General Public + * License as published by the Free Software Foundation; either + * version 2 of the License, or (at your option) any later version. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Library General Public License for more details. + * + * You should have received a copy of the GNU Library General Public + * License along with this library; if not, write to the Free + * Software Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. + */ + + +/* + * $Log: quads.h,v $ + * Revision 1.1 1997/04/12 12:24:07 brianp + * Initial revision + * + */ + + +#ifndef QUADS_H +#define QUADS_H + + +#include "types.h" + + +extern void gl_set_quad_function( GLcontext *ctx ); + + +#endif diff --git a/dll/opengl/mesa/rastpos.c b/dll/opengl/mesa/rastpos.c new file mode 100644 index 00000000000..480c49ebc13 --- /dev/null +++ b/dll/opengl/mesa/rastpos.c @@ -0,0 +1,225 @@ +/* $Id: rastpos.c,v 1.5 1997/07/24 01:23:44 brianp Exp $ */ + +/* + * Mesa 3-D graphics library + * Version: 2.4 + * Copyright (C) 1995-1997 Brian Paul + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Library General Public + * License as published by the Free Software Foundation; either + * version 2 of the License, or (at your option) any later version. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Library General Public License for more details. + * + * You should have received a copy of the GNU Library General Public + * License along with this library; if not, write to the Free + * Software Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. + */ + + +/* + * $Log: rastpos.c,v $ + * Revision 1.5 1997/07/24 01:23:44 brianp + * changed precompiled header symbol from PCH to PC_HEADER + * + * Revision 1.4 1997/06/20 02:25:54 brianp + * replaced Current.IntColor with Current.ByteColor + * + * Revision 1.3 1997/05/28 03:26:18 brianp + * added precompiled header (PCH) support + * + * Revision 1.2 1997/05/01 01:39:59 brianp + * replaced sqrt() with GL_SQRT() + * + * Revision 1.1 1997/04/01 04:17:13 brianp + * Initial revision + * + */ + + +#ifdef PC_HEADER +#include "all.h" +#else +#include "clip.h" +#include "feedback.h" +#include "light.h" +#include "macros.h" +#include "matrix.h" +#include "mmath.h" +#include "shade.h" +#include "types.h" +#include "xform.h" +#endif + + +/* + * Caller: context->API.RasterPos4f + */ +void gl_RasterPos4f( GLcontext *ctx, + GLfloat x, GLfloat y, GLfloat z, GLfloat w ) +{ + GLfloat v[4], eye[4], clip[4], ndc[3], d; + + ASSIGN_4V( v, x, y, z, w ); + + if (ctx->NewModelViewMatrix) { + gl_analyze_modelview_matrix(ctx); + } + if (ctx->NewProjectionMatrix) { + gl_analyze_projection_matrix(ctx); + } + if (ctx->NewTextureMatrix) { + gl_analyze_texture_matrix(ctx); + } + + /* transform v to eye coords: eye = ModelView * v */ + TRANSFORM_POINT( eye, ctx->ModelViewMatrix, v ); + + /* raster color */ + if (ctx->Light.Enabled) { + GLfloat eyenorm[3]; + TRANSFORM_NORMAL( eyenorm[0], eyenorm[1], eyenorm[2], ctx->Current.Normal, + ctx->ModelViewInv ); + if (ctx->Visual->RGBAflag) { + GLubyte color[4]; + gl_color_shade_vertices( ctx, 0, 1, &eye, &eyenorm, &color ); + ctx->Current.RasterColor[0] = color[0] * ctx->Visual->InvRedScale; + ctx->Current.RasterColor[1] = color[1] * ctx->Visual->InvGreenScale; + ctx->Current.RasterColor[2] = color[2] * ctx->Visual->InvBlueScale; + ctx->Current.RasterColor[3] = color[3] * ctx->Visual->InvAlphaScale; + } + else { + gl_index_shade_vertices( ctx, 0, 1, &eye, &eyenorm, + &ctx->Current.RasterIndex ); + } + } + else { + /* use current color or index */ + if (ctx->Visual->RGBAflag) { + GLfloat *rc = ctx->Current.RasterColor; + rc[0] = ctx->Current.ByteColor[0] * ctx->Visual->InvRedScale; + rc[1] = ctx->Current.ByteColor[1] * ctx->Visual->InvGreenScale; + rc[2] = ctx->Current.ByteColor[2] * ctx->Visual->InvBlueScale; + rc[3] = ctx->Current.ByteColor[3] * ctx->Visual->InvAlphaScale; + } + else { + ctx->Current.RasterIndex = ctx->Current.Index; + } + } + + /* clip to user clipping planes */ + if (gl_userclip_point(ctx, eye)==0) { + ctx->Current.RasterPosValid = GL_FALSE; + return; + } + + /* compute raster distance */ + ctx->Current.RasterDistance = + GL_SQRT( eye[0]*eye[0] + eye[1]*eye[1] + eye[2]*eye[2] ); + + /* apply projection matrix: clip = Proj * eye */ + TRANSFORM_POINT( clip, ctx->ProjectionMatrix, eye ); + + /* clip to view volume */ + if (gl_viewclip_point( clip )==0) { + ctx->Current.RasterPosValid = GL_FALSE; + return; + } + + /* ndc = clip / W */ + ASSERT( clip[3]!=0.0 ); + d = 1.0F / clip[3]; + ndc[0] = clip[0] * d; + ndc[1] = clip[1] * d; + ndc[2] = clip[2] * d; + + ctx->Current.RasterPos[0] = ndc[0] * ctx->Viewport.Sx + ctx->Viewport.Tx; + ctx->Current.RasterPos[1] = ndc[1] * ctx->Viewport.Sy + ctx->Viewport.Ty; + ctx->Current.RasterPos[2] = (ndc[2] * ctx->Viewport.Sz + ctx->Viewport.Tz) + / DEPTH_SCALE; + ctx->Current.RasterPos[3] = clip[3]; + ctx->Current.RasterPosValid = GL_TRUE; + + /* FOG??? */ + + if (ctx->Texture.Enabled) { + COPY_4V( ctx->Current.RasterTexCoord, ctx->Current.TexCoord ); + } + + if (ctx->RenderMode==GL_SELECT) { + gl_update_hitflag( ctx, ctx->Current.RasterPos[2] ); + } + +} + + + +/* + * This is a MESA extension function. Pretty much just like glRasterPos + * except we don't apply the modelview or projection matrices; specify a + * window coordinate directly. + * Caller: context->API.WindowPos4fMESA pointer. + */ +void gl_windowpos( GLcontext *ctx, GLfloat x, GLfloat y, GLfloat z, GLfloat w ) +{ + /* set raster position */ + ctx->Current.RasterPos[0] = x; + ctx->Current.RasterPos[1] = y; + ctx->Current.RasterPos[2] = CLAMP( z, 0.0F, 1.0F ); + ctx->Current.RasterPos[3] = w; + + ctx->Current.RasterPosValid = GL_TRUE; + + /* raster color */ + if (ctx->Light.Enabled) { + GLfloat eye[4]; + GLfloat eyenorm[3]; + COPY_4V( eye, ctx->Current.RasterPos ); + if (ctx->NewModelViewMatrix) { + gl_analyze_modelview_matrix(ctx); + } + TRANSFORM_NORMAL( eyenorm[0], eyenorm[1], eyenorm[2], + ctx->Current.Normal, + ctx->ModelViewInv ); + if (ctx->Visual->RGBAflag) { + GLubyte color[4]; + gl_color_shade_vertices( ctx, 0, 1, &eye, &eyenorm, &color ); + ASSIGN_4V( ctx->Current.RasterColor, + (GLfloat) color[0] * ctx->Visual->InvRedScale, + (GLfloat) color[1] * ctx->Visual->InvGreenScale, + (GLfloat) color[2] * ctx->Visual->InvBlueScale, + (GLfloat) color[3] * ctx->Visual->InvAlphaScale ); + } + else { + gl_index_shade_vertices( ctx, 0, 1, &eye, &eyenorm, + &ctx->Current.RasterIndex ); + } + } + else { + /* use current color or index */ + if (ctx->Visual->RGBAflag) { + ASSIGN_4V( ctx->Current.RasterColor, + ctx->Current.ByteColor[0] * ctx->Visual->InvRedScale, + ctx->Current.ByteColor[1] * ctx->Visual->InvGreenScale, + ctx->Current.ByteColor[2] * ctx->Visual->InvBlueScale, + ctx->Current.ByteColor[3] * ctx->Visual->InvAlphaScale ); + } + else { + ctx->Current.RasterIndex = ctx->Current.Index; + } + } + + ctx->Current.RasterDistance = 0.0; + + if (ctx->Texture.Enabled) { + COPY_4V( ctx->Current.RasterTexCoord, ctx->Current.TexCoord ); + } + + if (ctx->RenderMode==GL_SELECT) { + gl_update_hitflag( ctx, ctx->Current.RasterPos[2] ); + } +} diff --git a/dll/opengl/mesa/rastpos.h b/dll/opengl/mesa/rastpos.h new file mode 100644 index 00000000000..1121e268f27 --- /dev/null +++ b/dll/opengl/mesa/rastpos.h @@ -0,0 +1,49 @@ +/* $Id: rastpos.h,v 1.1 1997/04/01 04:17:13 brianp Exp $ */ + +/* + * Mesa 3-D graphics library + * Version: 2.3 + * Copyright (C) 1995-1996 Brian Paul + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Library General Public + * License as published by the Free Software Foundation; either + * version 2 of the License, or (at your option) any later version. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Library General Public License for more details. + * + * You should have received a copy of the GNU Library General Public + * License along with this library; if not, write to the Free + * Software Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. + */ + + +/* + * $Log: rastpos.h,v $ + * Revision 1.1 1997/04/01 04:17:13 brianp + * Initial revision + * + */ + + +#ifndef RASTPOS_H +#define RASTPOS_H + + +#include "types.h" + + +extern void gl_RasterPos4f( GLcontext *ctx, + GLfloat x, GLfloat y, GLfloat z, GLfloat w ); + + +extern void gl_windowpos( GLcontext *ctx, + GLfloat x, GLfloat y, GLfloat z, GLfloat w ); + + + +#endif + diff --git a/dll/opengl/mesa/readpix.c b/dll/opengl/mesa/readpix.c new file mode 100644 index 00000000000..df188af1da2 --- /dev/null +++ b/dll/opengl/mesa/readpix.c @@ -0,0 +1,1099 @@ +/* $Id: readpix.c,v 1.10 1997/07/24 01:25:18 brianp Exp $ */ + +/* + * Mesa 3-D graphics library + * Version: 2.4 + * Copyright (C) 1995-1997 Brian Paul + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Library General Public + * License as published by the Free Software Foundation; either + * version 2 of the License, or (at your option) any later version. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Library General Public License for more details. + * + * You should have received a copy of the GNU Library General Public + * License along with this library; if not, write to the Free + * Software Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. + */ + + +/* + * $Log: readpix.c,v $ + * Revision 1.10 1997/07/24 01:25:18 brianp + * changed precompiled header symbol from PCH to PC_HEADER + * + * Revision 1.9 1997/05/28 03:26:18 brianp + * added precompiled header (PCH) support + * + * Revision 1.8 1997/05/08 01:43:50 brianp + * added error check to gl_ReadPixels() for inside glBegin/glEnd + * + * Revision 1.7 1997/02/03 20:31:15 brianp + * added a few DEFARRAY macros for BeOS + * + * Revision 1.6 1997/01/16 19:24:05 brianp + * replaced a few abort()'s with gl_error() calls + * + * Revision 1.5 1996/12/20 20:28:04 brianp + * use DEF/UNDEFARRAY() macros in read_color_pixels() for Mac compilers + * + * Revision 1.4 1996/11/01 03:20:47 brianp + * reading GL_LUMINANCE pixels weren't clamped + * + * Revision 1.3 1996/09/27 01:29:47 brianp + * added missing default cases to switches + * + * Revision 1.2 1996/09/15 14:18:37 brianp + * now use GLframebuffer and GLvisual + * + * Revision 1.1 1996/09/13 01:38:16 brianp + * Initial revision + * + */ + + +#ifdef PC_HEADER +#include "all.h" +#else +#include +#include +#include +#include "alphabuf.h" +#include "context.h" +#include "depth.h" +#include "feedback.h" +#include "dlist.h" +#include "macros.h" +#include "image.h" +#include "readpix.h" +#include "span.h" +#include "stencil.h" +#include "types.h" +#endif + + + + +/* + * Read a block of color index pixels. + */ +static void read_index_pixels( GLcontext *ctx, + GLint x, GLint y, + GLsizei width, GLsizei height, + GLenum type, GLvoid *pixels ) +{ + GLint i, j; + GLuint a, s, k, l, start; + + /* error checking */ + if (ctx->Visual->RGBAflag) { + gl_error( ctx, GL_INVALID_OPERATION, "glReadPixels" ); + return; + } + + /* Size of each component */ + s = gl_sizeof_type( type ); + if (s<=0) { + gl_error( ctx, GL_INVALID_ENUM, "glReadPixels(type)" ); + return; + } + + /* Compute packing parameters */ + a = ctx->Pack.Alignment; + if (ctx->Pack.RowLength>0) { + l = ctx->Pack.RowLength; + } + else { + l = width; + } + /* k = offset between rows in components */ + if (s>=a) { + k = l; + } + else { + k = a/s * CEILING( s*l, a ); + } + + /* offset to first component returned */ + start = ctx->Pack.SkipRows * k + ctx->Pack.SkipPixels; + + /* process image row by row */ + for (j=0;jDriver.ReadIndexSpan)( ctx, width, x, y, index ); + + if (ctx->Pixel.IndexShift!=0 || ctx->Pixel.IndexOffset!=0) { + GLuint s; + if (ctx->Pixel.IndexShift<0) { + /* right shift */ + s = -ctx->Pixel.IndexShift; + for (i=0;i> s) + ctx->Pixel.IndexOffset; + } + } + else { + /* left shift */ + s = ctx->Pixel.IndexShift; + for (i=0;iPixel.IndexOffset; + } + } + } + + if (ctx->Pixel.MapColorFlag) { + for (i=0;iPixel.MapItoI[ index[i] ]; + } + } + + switch (type) { + case GL_UNSIGNED_BYTE: + { + GLubyte *dst = (GLubyte *) pixels + start + j * k; + for (i=0;iPack.SwapBytes) { + gl_swap2( (GLushort *) pixels + start + j * k, width ); + } + } + break; + case GL_SHORT: + { + GLshort *dst = (GLshort *) pixels + start + j * k; + for (i=0;iPack.SwapBytes) { + gl_swap2( (GLushort *) pixels + start + j * k, width ); + } + } + break; + case GL_UNSIGNED_INT: + { + GLuint *dst = (GLuint *) pixels + start + j * k; + for (i=0;iPack.SwapBytes) { + gl_swap4( (GLuint *) pixels + start + j * k, width ); + } + } + break; + case GL_INT: + { + GLint *dst = (GLint *) pixels + start + j * k; + for (i=0;iPack.SwapBytes) { + gl_swap4( (GLuint *) pixels + start + j * k, width ); + } + } + break; + case GL_FLOAT: + { + GLfloat *dst = (GLfloat *) pixels + start + j * k; + for (i=0;iPack.SwapBytes) { + gl_swap4( (GLuint *) pixels + start + j * k, width ); + } + } + break; + default: + gl_error( ctx, GL_INVALID_ENUM, "glReadPixels(type)" ); + } + } +} + + + +static void read_depth_pixels( GLcontext *ctx, + GLint x, GLint y, + GLsizei width, GLsizei height, + GLenum type, GLvoid *pixels ) +{ + GLint i, j; + GLuint a, s, k, l, start; + GLboolean bias_or_scale; + + /* Error checking */ + if (ctx->Visual->DepthBits<=0) { + /* No depth buffer */ + gl_error( ctx, GL_INVALID_OPERATION, "glReadPixels" ); + return; + } + + bias_or_scale = ctx->Pixel.DepthBias!=0.0 || ctx->Pixel.DepthScale!=1.0; + + /* Size of each component */ + s = gl_sizeof_type( type ); + if (s<=0) { + gl_error( ctx, GL_INVALID_ENUM, "glReadPixels(type)" ); + return; + } + + /* Compute packing parameters */ + a = ctx->Pack.Alignment; + if (ctx->Pack.RowLength>0) { + l = ctx->Pack.RowLength; + } + else { + l = width; + } + /* k = offset between rows in components */ + if (s>=a) { + k = l; + } + else { + k = a/s * CEILING( s*l, a ); + } + + /* offset to first component returned */ + start = ctx->Pack.SkipRows * k + ctx->Pack.SkipPixels; + + if (type==GL_UNSIGNED_INT && !bias_or_scale && !ctx->Pack.SwapBytes) { + /* Special case: directly read 32-bit unsigned depth values. */ + /* Compute shift value to scale depth values up to 32-bit uints. */ + GLuint shift = 0; + GLuint max = MAX_DEPTH; + while ((max&0x80000000)==0) { + max = max << 1; + shift++; + } + for (j=0;jDriver.ReadDepthSpanInt)( ctx, width, x, y, (GLdepth*) dst); + for (i=0;iDriver.ReadDepthSpanFloat)( ctx, width, x, y, depth ); + + if (bias_or_scale) { + for (i=0;iPixel.DepthScale + ctx->Pixel.DepthBias; + depth[i] = CLAMP( d, 0.0, 1.0 ); + } + } + + switch (type) { + case GL_UNSIGNED_BYTE: + { + GLubyte *dst = (GLubyte *) pixels + start + j * k; + for (i=0;iPack.SwapBytes) { + gl_swap2( (GLushort *) pixels + start + j * k, width ); + } + } + break; + case GL_SHORT: + { + GLshort *dst = (GLshort *) pixels + start + j * k; + for (i=0;iPack.SwapBytes) { + gl_swap2( (GLushort *) pixels + start + j * k, width ); + } + } + break; + case GL_UNSIGNED_INT: + { + GLuint *dst = (GLuint *) pixels + start + j * k; + for (i=0;iPack.SwapBytes) { + gl_swap4( (GLuint *) pixels + start + j * k, width ); + } + } + break; + case GL_INT: + { + GLint *dst = (GLint *) pixels + start + j * k; + for (i=0;iPack.SwapBytes) { + gl_swap4( (GLuint *) pixels + start + j * k, width ); + } + } + break; + case GL_FLOAT: + { + GLfloat *dst = (GLfloat *) pixels + start + j * k; + for (i=0;iPack.SwapBytes) { + gl_swap4( (GLuint *) pixels + start + j * k, width ); + } + } + break; + default: + gl_error( ctx, GL_INVALID_ENUM, "glReadPixels(type)" ); + } + } + } +} + + + + +static void read_stencil_pixels( GLcontext *ctx, + GLint x, GLint y, + GLsizei width, GLsizei height, + GLenum type, GLvoid *pixels ) +{ + GLint i, j; + GLuint a, s, k, l, start; + GLboolean shift_or_offset; + + if (ctx->Visual->StencilBits<=0) { + /* No stencil buffer */ + gl_error( ctx, GL_INVALID_OPERATION, "glReadPixels" ); + return; + } + + shift_or_offset = ctx->Pixel.IndexShift!=0 || ctx->Pixel.IndexOffset!=0; + + /* Size of each component */ + s = gl_sizeof_type( type ); + if (s<=0) { + gl_error( ctx, GL_INVALID_ENUM, "glReadPixels(type)" ); + return; + } + + /* Compute packing parameters */ + a = ctx->Pack.Alignment; + if (ctx->Pack.RowLength>0) { + l = ctx->Pack.RowLength; + } + else { + l = width; + } + /* k = offset between rows in components */ + if (s>=a) { + k = l; + } + else { + k = a/s * CEILING( s*l, a ); + } + + /* offset to first component returned */ + start = ctx->Pack.SkipRows * k + ctx->Pack.SkipPixels; + + /* process image row by row */ + for (j=0;jPixel.IndexShift<0) { + /* right shift */ + s = -ctx->Pixel.IndexShift; + for (i=0;i> s) + ctx->Pixel.IndexOffset; + } + } + else { + /* left shift */ + s = ctx->Pixel.IndexShift; + for (i=0;iPixel.IndexOffset; + } + } + } + + if (ctx->Pixel.MapStencilFlag) { + for (i=0;iPixel.MapStoS[ stencil[i] ]; + } + } + + switch (type) { + case GL_UNSIGNED_BYTE: + { + GLubyte *dst = (GLubyte *) pixels + start + j * k; + MEMCPY( dst, stencil, width ); + } + break; + case GL_BYTE: + { + GLbyte *dst = (GLbyte *) pixels + start + j * k; + MEMCPY( dst, stencil, width ); + } + break; + case GL_UNSIGNED_SHORT: + { + GLushort *dst = (GLushort *) pixels + start + j * k; + for (i=0;iPack.SwapBytes) { + gl_swap2( (GLushort *) pixels + start +j * k, width ); + } + } + break; + case GL_SHORT: + { + GLshort *dst = (GLshort *) pixels + start + j * k; + for (i=0;iPack.SwapBytes) { + gl_swap2( (GLushort *) pixels + start +j * k, width ); + } + } + break; + case GL_UNSIGNED_INT: + { + GLuint *dst = (GLuint *) pixels + start + j * k; + for (i=0;iPack.SwapBytes) { + gl_swap4( (GLuint *) pixels + start +j * k, width ); + } + } + break; + case GL_INT: + { + GLint *dst = (GLint *) pixels + start + j * k; + for (i=0;iPack.SwapBytes) { + gl_swap4( (GLuint *) pixels + start +j * k, width ); + } + } + break; + case GL_FLOAT: + { + GLfloat *dst = (GLfloat *) pixels + start + j * k; + for (i=0;iPack.SwapBytes) { + gl_swap4( (GLuint *) pixels + start +j * k, width ); + } + } + break; + default: + gl_error( ctx, GL_INVALID_ENUM, "glReadPixels(type)" ); + } + } +} + + + +/* + * Test if scaling or biasing of colors is needed. + */ +static GLboolean scale_or_bias_rgba( GLcontext *ctx ) +{ + if (ctx->Pixel.RedScale!=1.0F || ctx->Pixel.RedBias!=0.0F || + ctx->Pixel.GreenScale!=1.0F || ctx->Pixel.GreenBias!=0.0F || + ctx->Pixel.BlueScale!=1.0F || ctx->Pixel.BlueBias!=0.0F || + ctx->Pixel.AlphaScale!=1.0F || ctx->Pixel.AlphaBias!=0.0F) { + return GL_TRUE; + } + else { + return GL_FALSE; + } +} + + + +/* + * Apply scale and bias factors to an array of RGBA pixels. + */ +static void scale_and_bias_rgba( GLcontext *ctx, + GLint n, + GLfloat red[], GLfloat green[], + GLfloat blue[], GLfloat alpha[] ) +{ + register GLint i; + register GLfloat r, g, b, a; + + for (i=0;iPixel.RedScale + ctx->Pixel.RedBias; + g = green[i] * ctx->Pixel.GreenScale + ctx->Pixel.GreenBias; + b = blue[i] * ctx->Pixel.BlueScale + ctx->Pixel.BlueBias; + a = alpha[i] * ctx->Pixel.AlphaScale + ctx->Pixel.AlphaBias; + red[i] = CLAMP( r, 0.0F, 1.0F ); + green[i] = CLAMP( g, 0.0F, 1.0F ); + blue[i] = CLAMP( b, 0.0F, 1.0F ); + alpha[i] = CLAMP( a, 0.0F, 1.0F ); + } +} + + + +/* + * Apply pixel mapping to an array of RGBA pixels. + */ +static void map_rgba( GLcontext *ctx, + GLint n, + GLfloat red[], GLfloat green[], + GLfloat blue[], GLfloat alpha[] ) +{ + GLfloat rscale = ctx->Pixel.MapRtoRsize-1; + GLfloat gscale = ctx->Pixel.MapGtoGsize-1; + GLfloat bscale = ctx->Pixel.MapBtoBsize-1; + GLfloat ascale = ctx->Pixel.MapAtoAsize-1; + GLint i; + + for (i=0;iPixel.MapRtoR[ (GLint) (red[i] * rscale) ]; + green[i] = ctx->Pixel.MapGtoG[ (GLint) (green[i] * gscale) ]; + blue[i] = ctx->Pixel.MapBtoB[ (GLint) (blue[i] * bscale) ]; + alpha[i] = ctx->Pixel.MapAtoA[ (GLint) (alpha[i] * ascale) ]; + } +} + + + + +/* + * Read R, G, B, A, RGB, L, or LA pixels. + */ +static void read_color_pixels(GLcontext *ctx, GLint x, GLint y, GLsizei width, + GLsizei height, GLenum format, GLenum type, GLvoid *pixels) +{ + GLint i, j, n, a, s, l, k; + GLboolean scale_or_bias; + DEFARRAY(GLfloat, red, MAX_WIDTH); + DEFARRAY(GLfloat, green, MAX_WIDTH); + DEFARRAY(GLfloat, blue, MAX_WIDTH); + DEFARRAY(GLfloat, alpha, MAX_WIDTH); + DEFARRAY(GLfloat, luminance, MAX_WIDTH); + GLboolean r_flag, g_flag, b_flag, a_flag, l_flag; + GLboolean is_bgr = GL_FALSE; + GLuint start; + + scale_or_bias = scale_or_bias_rgba(ctx); + + /* Determine how many / which components to return */ + r_flag = g_flag = b_flag = a_flag = l_flag = GL_FALSE; + switch (format) + { + case GL_RED: + r_flag = GL_TRUE; + n = 1; + break; + case GL_GREEN: + g_flag = GL_TRUE; + n = 1; + break; + case GL_BLUE: + b_flag = GL_TRUE; + n = 1; + break; + case GL_ALPHA: + a_flag = GL_TRUE; + n = 1; + break; + case GL_LUMINANCE: + l_flag = GL_TRUE; + n = 1; + break; + case GL_LUMINANCE_ALPHA: + l_flag = a_flag = GL_TRUE; + n = 2; + break; + case GL_RGB: + r_flag = g_flag = b_flag = GL_TRUE; + n = 3; + break; + case GL_BGR_EXT: + r_flag = g_flag = b_flag = GL_TRUE; + n = 3; + is_bgr = GL_TRUE; + break; + case GL_RGBA: + r_flag = g_flag = b_flag = a_flag = GL_TRUE; + n = 4; + break; + case GL_BGRA_EXT: + r_flag = g_flag = b_flag = a_flag = GL_TRUE; + n = 4; + is_bgr = GL_TRUE; + break; + default: + gl_error(ctx, GL_INVALID_ENUM, "glReadPixels(format)"); + UNDEFARRAY( red ); + UNDEFARRAY( green ); + UNDEFARRAY( blue ); + UNDEFARRAY( alpha ); + UNDEFARRAY( luminance ); + return; + } + + /* Size of each component */ + s = gl_sizeof_type(type); + if (s <= 0) + { + gl_error(ctx, GL_INVALID_ENUM, "glReadPixels(type)"); + UNDEFARRAY( red ); + UNDEFARRAY( green ); + UNDEFARRAY( blue ); + UNDEFARRAY( alpha ); + UNDEFARRAY( luminance ); + return; + } + + /* Compute packing parameters */ + a = ctx->Pack.Alignment; + if (ctx->Pack.RowLength > 0) + { + l = ctx->Pack.RowLength; + } + else + { + l = width; + } + /* k = offset between rows in components */ + if (s >= a) + { + k = n * l; + } + else + { + k = a / s * CEILING(s * n * l, a); + } + + /* offset to first component returned */ + start = ctx->Pack.SkipRows * k + ctx->Pack.SkipPixels * n; + + /* process image row by row */ + for (j = 0; j < height; j++, y++) + { + /* + * Read the pixels from frame buffer + */ + if (ctx->Visual->RGBAflag) + { + DEFARRAY(GLubyte, r, MAX_WIDTH); + DEFARRAY(GLubyte, g, MAX_WIDTH); + DEFARRAY(GLubyte, b, MAX_WIDTH); + DEFARRAY(GLubyte, a, MAX_WIDTH); + GLfloat rscale = 1.0F * ctx->Visual->InvRedScale; + GLfloat gscale = 1.0F * ctx->Visual->InvGreenScale; + GLfloat bscale = 1.0F * ctx->Visual->InvBlueScale; + GLfloat ascale = 1.0F * ctx->Visual->InvAlphaScale; + + /* read colors and convert to floats */ + (*ctx->Driver.ReadColorSpan)(ctx, width, x, y, r, g, b, a); + if (ctx->RasterMask & ALPHABUF_BIT) + { + gl_read_alpha_span(ctx, width, x, y, a); + } + for (i = 0; i < width; i++) + { + red[i] = r[i] * rscale; + green[i] = g[i] * gscale; + blue[i] = b[i] * bscale; + alpha[i] = a[i] * ascale; + } + + if (scale_or_bias) + { + scale_and_bias_rgba(ctx, width, red, green, blue, alpha); + } + if (ctx->Pixel.MapColorFlag) + { + map_rgba(ctx, width, red, green, blue, alpha); + } + UNDEFARRAY(r); + UNDEFARRAY(g); + UNDEFARRAY(b); + UNDEFARRAY(a); + } + else + { + /* convert CI values to RGBA */ + GLuint index[MAX_WIDTH]; + (*ctx->Driver.ReadIndexSpan)(ctx, width, x, y, index); + + if (ctx->Pixel.IndexShift != 0 || ctx->Pixel.IndexOffset != 0) + { + GLuint s; + if (ctx->Pixel.IndexShift < 0) + { + /* right shift */ + s = -ctx->Pixel.IndexShift; + for (i = 0; i < width; i++) + { + index[i] = (index[i] >> s) + ctx->Pixel.IndexOffset; + } + } + else + { + /* left shift */ + s = ctx->Pixel.IndexShift; + for (i = 0; i < width; i++) + { + index[i] = (index[i] << s) + ctx->Pixel.IndexOffset; + } + } + } + + for (i = 0; i < width; i++) + { + red[i] = ctx->Pixel.MapItoR[index[i]]; + green[i] = ctx->Pixel.MapItoG[index[i]]; + blue[i] = ctx->Pixel.MapItoB[index[i]]; + alpha[i] = ctx->Pixel.MapItoA[index[i]]; + } + } + + if (l_flag) + { + for (i = 0; i < width; i++) + { + GLfloat sum = red[i] + green[i] + blue[i]; + luminance[i] = CLAMP(sum, 0.0F, 1.0F); + } + } + + /* + * Pack/transfer/store the pixels + */ + + switch (type) + { + case GL_UNSIGNED_BYTE: + { + GLubyte *dst = (GLubyte *) pixels + start + j * k; + for (i = 0; i < width; i++) + { + if (is_bgr) + { + if (b_flag) + *dst++ = FLOAT_TO_UBYTE(blue[i]); + if (g_flag) + *dst++ = FLOAT_TO_UBYTE(green[i]); + if (r_flag) + *dst++ = FLOAT_TO_UBYTE(red[i]); + } + else + { + if (r_flag) + *dst++ = FLOAT_TO_UBYTE(red[i]); + if (g_flag) + *dst++ = FLOAT_TO_UBYTE(green[i]); + if (b_flag) + *dst++ = FLOAT_TO_UBYTE(blue[i]); + } + if (l_flag) + *dst++ = FLOAT_TO_UBYTE(luminance[i]); + if (a_flag) + *dst++ = FLOAT_TO_UBYTE(alpha[i]); + } + break; + } + case GL_BYTE: + { + GLbyte *dst = (GLbyte *) pixels + start + j * k; + for (i = 0; i < width; i++) + { + if (is_bgr) + { + if (b_flag) + *dst++ = FLOAT_TO_BYTE(blue[i]); + if (g_flag) + *dst++ = FLOAT_TO_BYTE(green[i]); + if (r_flag) + *dst++ = FLOAT_TO_BYTE(red[i]); + } + else + { + if (r_flag) + *dst++ = FLOAT_TO_BYTE(red[i]); + if (g_flag) + *dst++ = FLOAT_TO_BYTE(green[i]); + if (b_flag) + *dst++ = FLOAT_TO_BYTE(blue[i]); + } + if (l_flag) + *dst++ = FLOAT_TO_BYTE(luminance[i]); + if (a_flag) + *dst++ = FLOAT_TO_BYTE(alpha[i]); + } + break; + } + case GL_UNSIGNED_SHORT: + { + GLushort *dst = (GLushort *) pixels + start + j * k; + for (i = 0; i < width; i++) + { + if (is_bgr) + { + if (b_flag) + *dst++ = FLOAT_TO_USHORT(blue[i]); + if (g_flag) + *dst++ = FLOAT_TO_USHORT(green[i]); + if (r_flag) + *dst++ = FLOAT_TO_USHORT(red[i]); + } + else + { + if (r_flag) + *dst++ = FLOAT_TO_USHORT(red[i]); + if (g_flag) + *dst++ = FLOAT_TO_USHORT(green[i]); + if (b_flag) + *dst++ = FLOAT_TO_USHORT(blue[i]); + } + if (l_flag) + *dst++ = FLOAT_TO_USHORT(luminance[i]); + if (a_flag) + *dst++ = FLOAT_TO_USHORT(alpha[i]); + } + if (ctx->Pack.SwapBytes) + { + gl_swap2((GLushort *) pixels + start + j * k, width * n); + } + break; + } + case GL_SHORT: + { + GLshort *dst = (GLshort *) pixels + start + j * k; + for (i = 0; i < width; i++) + { + if (is_bgr) + { + if (b_flag) + *dst++ = FLOAT_TO_SHORT(blue[i]); + if (g_flag) + *dst++ = FLOAT_TO_SHORT(green[i]); + if (r_flag) + *dst++ = FLOAT_TO_SHORT(red[i]); + } + else + { + if (r_flag) + *dst++ = FLOAT_TO_SHORT(red[i]); + if (g_flag) + *dst++ = FLOAT_TO_SHORT(green[i]); + if (b_flag) + *dst++ = FLOAT_TO_SHORT(blue[i]); + } + if (l_flag) + *dst++ = FLOAT_TO_SHORT(luminance[i]); + if (a_flag) + *dst++ = FLOAT_TO_SHORT(alpha[i]); + } + if (ctx->Pack.SwapBytes) + { + gl_swap2((GLushort *) pixels + start + j * k, width * n); + } + break; + } + case GL_UNSIGNED_INT: + { + GLuint *dst = (GLuint *) pixels + start + j * k; + for (i = 0; i < width; i++) + { + if (is_bgr) + { + if (b_flag) + *dst++ = FLOAT_TO_UINT(blue[i]); + if (g_flag) + *dst++ = FLOAT_TO_UINT(green[i]); + if (r_flag) + *dst++ = FLOAT_TO_UINT(red[i]); + } + else + { + if (r_flag) + *dst++ = FLOAT_TO_UINT(red[i]); + if (g_flag) + *dst++ = FLOAT_TO_UINT(green[i]); + if (b_flag) + *dst++ = FLOAT_TO_UINT(blue[i]); + } + if (l_flag) + *dst++ = FLOAT_TO_UINT(luminance[i]); + if (a_flag) + *dst++ = FLOAT_TO_UINT(alpha[i]); + } + if (ctx->Pack.SwapBytes) + { + gl_swap4((GLuint *) pixels + start + j * k, width * n); + } + break; + } + case GL_INT: + { + GLint *dst = (GLint *) pixels + start + j * k; + for (i = 0; i < width; i++) + { + if (is_bgr) + { + if (b_flag) + *dst++ = FLOAT_TO_INT(blue[i]); + if (g_flag) + *dst++ = FLOAT_TO_INT(green[i]); + if (r_flag) + *dst++ = FLOAT_TO_INT(red[i]); + } + else + { + if (r_flag) + *dst++ = FLOAT_TO_INT(red[i]); + if (g_flag) + *dst++ = FLOAT_TO_INT(green[i]); + if (b_flag) + *dst++ = FLOAT_TO_INT(blue[i]); + } + if (l_flag) + *dst++ = FLOAT_TO_INT(luminance[i]); + if (a_flag) + *dst++ = FLOAT_TO_INT(alpha[i]); + } + if (ctx->Pack.SwapBytes) + { + gl_swap4((GLuint *) pixels + start + j * k, width * n); + } + break; + } + case GL_FLOAT: + { + GLfloat *dst = (GLfloat *) pixels + start + j * k; + for (i = 0; i < width; i++) + { + if (is_bgr) + { + if (b_flag) + *dst++ = blue[i]; + if (g_flag) + *dst++ = green[i]; + if (r_flag) + *dst++ = red[i]; + } + else + { + if (r_flag) + *dst++ = red[i]; + if (g_flag) + *dst++ = green[i]; + if (b_flag) + *dst++ = blue[i]; + } + if (l_flag) + *dst++ = luminance[i]; + if (a_flag) + *dst++ = alpha[i]; + } + if (ctx->Pack.SwapBytes) + { + gl_swap4((GLuint *) pixels + start + j * k, width * n); + } + break; + } + default: + gl_error(ctx, GL_INVALID_ENUM, "glReadPixels(type)"); + } + } + UNDEFARRAY( red ); + UNDEFARRAY( green ); + UNDEFARRAY( blue ); + UNDEFARRAY( alpha ); + UNDEFARRAY( luminance ); +} + + + +void gl_ReadPixels( GLcontext *ctx, + GLint x, GLint y, GLsizei width, GLsizei height, + GLenum format, GLenum type, GLvoid *pixels ) +{ + if (INSIDE_BEGIN_END(ctx)) + { + gl_error(ctx, GL_INVALID_OPERATION, "glReadPixels"); + return; + } + + (void) (*ctx->Driver.SetBuffer)(ctx, ctx->Pixel.ReadBuffer); + + switch (format) + { + case GL_COLOR_INDEX: + read_index_pixels(ctx, x, y, width, height, type, pixels); + break; + case GL_STENCIL_INDEX: + read_stencil_pixels(ctx, x, y, width, height, type, pixels); + break; + case GL_DEPTH_COMPONENT: + read_depth_pixels(ctx, x, y, width, height, type, pixels); + break; + case GL_RED: + case GL_GREEN: + case GL_BLUE: + case GL_ALPHA: + case GL_RGB: + case GL_BGR_EXT: + case GL_LUMINANCE: + case GL_LUMINANCE_ALPHA: + case GL_RGBA: + case GL_BGRA_EXT: + read_color_pixels(ctx, x, y, width, height, format, type, pixels); + break; + default: + gl_error(ctx, GL_INVALID_ENUM, "glReadPixels(format)"); + } + + (void) (*ctx->Driver.SetBuffer)(ctx, ctx->Color.DrawBuffer); +} diff --git a/dll/opengl/mesa/readpix.h b/dll/opengl/mesa/readpix.h new file mode 100644 index 00000000000..a4e07a83927 --- /dev/null +++ b/dll/opengl/mesa/readpix.h @@ -0,0 +1,44 @@ +/* $Id: readpix.h,v 1.1 1996/09/13 01:38:16 brianp Exp $ */ + +/* + * Mesa 3-D graphics library + * Version: 2.0 + * Copyright (C) 1995-1996 Brian Paul + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Library General Public + * License as published by the Free Software Foundation; either + * version 2 of the License, or (at your option) any later version. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Library General Public License for more details. + * + * You should have received a copy of the GNU Library General Public + * License along with this library; if not, write to the Free + * Software Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. + */ + + +/* + * $Log: readpix.h,v $ + * Revision 1.1 1996/09/13 01:38:16 brianp + * Initial revision + * + */ + + +#ifndef READPIX_H +#define READPIX_H + + +#include "types.h" + + +extern void gl_ReadPixels( GLcontext *ctx, + GLint x, GLint y, GLsizei width, GLsizei height, + GLenum format, GLenum type, GLvoid *pixels ); + + +#endif diff --git a/dll/opengl/mesa/rect.c b/dll/opengl/mesa/rect.c new file mode 100644 index 00000000000..8da780a79dd --- /dev/null +++ b/dll/opengl/mesa/rect.c @@ -0,0 +1,76 @@ +/* $Id: rect.c,v 1.5 1997/07/24 01:25:18 brianp Exp $ */ + +/* + * Mesa 3-D graphics library + * Version: 2.4 + * Copyright (C) 1995-1997 Brian Paul + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Library General Public + * License as published by the Free Software Foundation; either + * version 2 of the License, or (at your option) any later version. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Library General Public License for more details. + * + * You should have received a copy of the GNU Library General Public + * License along with this library; if not, write to the Free + * Software Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. + */ + + +/* + * $Log: rect.c,v $ + * Revision 1.5 1997/07/24 01:25:18 brianp + * changed precompiled header symbol from PCH to PC_HEADER + * + * Revision 1.4 1997/05/28 03:26:18 brianp + * added precompiled header (PCH) support + * + * Revision 1.3 1997/04/29 01:27:13 brianp + * added #include "vbfill.h" + * + * Revision 1.2 1997/04/21 01:22:08 brianp + * added a comment + * + * Revision 1.1 1997/04/12 16:00:35 brianp + * Initial revision + * + */ + + +#ifdef PC_HEADER +#include "all.h" +#else +#include "context.h" +#include "macros.h" +#include "rect.h" +#include "vbfill.h" +#endif + + + +/* + * Execute a glRect*() function. + */ +void gl_Rectf( GLcontext *ctx, GLfloat x1, GLfloat y1, GLfloat x2, GLfloat y2 ) +{ + /* + * TODO: we could examine a bunch of state variables and ultimately + * call the Driver->RectFunc() function to draw a screen-aligned + * filled rectangle. Someday... + */ + + if (INSIDE_BEGIN_END(ctx)) { + gl_error( ctx, GL_INVALID_OPERATION, "glRect" ); + return; + } + gl_Begin( ctx, GL_QUADS ); + (*ctx->Exec.Vertex2f)( ctx, x1, y1 ); + (*ctx->Exec.Vertex2f)( ctx, x2, y1 ); + (*ctx->Exec.Vertex2f)( ctx, x2, y2 ); + (*ctx->Exec.Vertex2f)( ctx, x1, y2 ); + gl_End( ctx ); +} diff --git a/dll/opengl/mesa/rect.h b/dll/opengl/mesa/rect.h new file mode 100644 index 00000000000..f94bee23c18 --- /dev/null +++ b/dll/opengl/mesa/rect.h @@ -0,0 +1,43 @@ +/* $Id: rect.h,v 1.1 1997/04/12 16:00:35 brianp Exp $ */ + +/* + * Mesa 3-D graphics library + * Version: 2.3 + * Copyright (C) 1995-1997 Brian Paul + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Library General Public + * License as published by the Free Software Foundation; either + * version 2 of the License, or (at your option) any later version. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Library General Public License for more details. + * + * You should have received a copy of the GNU Library General Public + * License along with this library; if not, write to the Free + * Software Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. + */ + + +/* + * $Log: rect.h,v $ + * Revision 1.1 1997/04/12 16:00:35 brianp + * Initial revision + * + */ + + +#ifndef RECT_H +#define RECT_H + + +#include "types.h" + + +extern void gl_Rectf( GLcontext *ctx, + GLfloat x1, GLfloat y1, GLfloat x2, GLfloat y2 ); + + +#endif diff --git a/dll/opengl/mesa/scissor.c b/dll/opengl/mesa/scissor.c new file mode 100644 index 00000000000..263299260f5 --- /dev/null +++ b/dll/opengl/mesa/scissor.c @@ -0,0 +1,132 @@ +/* $Id: scissor.c,v 1.6 1997/11/25 03:38:58 brianp Exp $ */ + +/* + * Mesa 3-D graphics library + * Version: 2.5 + * Copyright (C) 1995-1997 Brian Paul + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Library General Public + * License as published by the Free Software Foundation; either + * version 2 of the License, or (at your option) any later version. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Library General Public License for more details. + * + * You should have received a copy of the GNU Library General Public + * License along with this library; if not, write to the Free + * Software Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. + */ + + +/* + * $Log: scissor.c,v $ + * Revision 1.6 1997/11/25 03:38:58 brianp + * small optimization to gl_Scissor() (Daryll Strauss) + * + * Revision 1.5 1997/07/24 01:21:56 brianp + * changed precompiled header symbol from PCH to PC_HEADER + * + * Revision 1.4 1997/05/28 03:26:29 brianp + * added precompiled header (PCH) support + * + * Revision 1.3 1997/05/17 03:17:50 brianp + * faster gl_scissor_span() from Mats Lofkvist + * + * Revision 1.2 1996/09/15 14:18:37 brianp + * now use GLframebuffer and GLvisual + * + * Revision 1.1 1996/09/13 01:38:16 brianp + * Initial revision + * + */ + + +#ifdef PC_HEADER +#include "all.h" +#else +#include "context.h" +#include "macros.h" +#include "dlist.h" +#include "scissor.h" +#include "types.h" +#endif + + +void gl_Scissor( GLcontext *ctx, + GLint x, GLint y, GLsizei width, GLsizei height ) +{ + if (width<0 || height<0) { + gl_error( ctx, GL_INVALID_VALUE, "glScissor" ); + return; + } + if (INSIDE_BEGIN_END(ctx)) { + gl_error( ctx, GL_INVALID_OPERATION, "glBegin" ); + return; + } + + if (x!=ctx->Scissor.X || y!=ctx->Scissor.Y || + width!=ctx->Scissor.Width || height!=ctx->Scissor.Height) { + ctx->Scissor.X = x; + ctx->Scissor.Y = y; + ctx->Scissor.Width = width; + ctx->Scissor.Height = height; + ctx->NewState |= NEW_ALL; /* TODO: this is overkill */ + } +} + + + +/* + * Apply the scissor test to a span of pixels. + * Return: 0 = all pixels in the span are outside the scissor box. + * 1 = one or more pixels passed the scissor test. + */ +GLint gl_scissor_span( GLcontext *ctx, + GLuint n, GLint x, GLint y, GLubyte mask[] ) +{ + /* first check if whole span is outside the scissor box */ + if (yBuffer->Ymin || y>ctx->Buffer->Ymax + || x>ctx->Buffer->Xmax || x+(GLint)n-1Buffer->Xmin) { + return 0; + } + else { + GLint i; + GLint xMin = ctx->Buffer->Xmin; + GLint xMax = ctx->Buffer->Xmax; + for (i=0; x+i < xMin; i++) { + mask[i] = 0; + } + for (i=(GLint)n-1; x+i > xMax; i--) { + mask[i] = 0; + } + + return 1; + } +} + + + + +/* + * Apply the scissor test to an array of pixels. + */ +GLuint gl_scissor_pixels( GLcontext *ctx, + GLuint n, const GLint x[], const GLint y[], + GLubyte mask[] ) +{ + GLint xmin = ctx->Buffer->Xmin; + GLint xmax = ctx->Buffer->Xmax; + GLint ymin = ctx->Buffer->Ymin; + GLint ymax = ctx->Buffer->Ymax; + GLuint i; + + for (i=0;i=xmin) & (x[i]<=xmax) & (y[i]>=ymin) & (y[i]<=ymax); + } + + return 1; +} + diff --git a/dll/opengl/mesa/scissor.h b/dll/opengl/mesa/scissor.h new file mode 100644 index 00000000000..add2a934f1d --- /dev/null +++ b/dll/opengl/mesa/scissor.h @@ -0,0 +1,52 @@ +/* $Id: scissor.h,v 1.1 1996/09/13 01:38:16 brianp Exp $ */ + +/* + * Mesa 3-D graphics library + * Version: 2.0 + * Copyright (C) 1995-1996 Brian Paul + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Library General Public + * License as published by the Free Software Foundation; either + * version 2 of the License, or (at your option) any later version. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Library General Public License for more details. + * + * You should have received a copy of the GNU Library General Public + * License along with this library; if not, write to the Free + * Software Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. + */ + + +/* + * $Log: scissor.h,v $ + * Revision 1.1 1996/09/13 01:38:16 brianp + * Initial revision + * + */ + + +#ifndef SCISSOR_H +#define SCISSOR_H + + +#include "types.h" + + +extern void gl_Scissor( GLcontext *ctx, + GLint x, GLint y, GLsizei width, GLsizei height ); + + +extern GLint gl_scissor_span( GLcontext *ctx, + GLuint n, GLint x, GLint y, GLubyte mask[] ); + + +extern GLuint gl_scissor_pixels( GLcontext *ctx, + GLuint n, const GLint x[], const GLint y[], + GLubyte mask[] ); + + +#endif diff --git a/dll/opengl/mesa/shade.c b/dll/opengl/mesa/shade.c new file mode 100644 index 00000000000..5049f0d68c1 --- /dev/null +++ b/dll/opengl/mesa/shade.c @@ -0,0 +1,607 @@ +/* $Id: shade.c,v 1.10 1997/12/18 02:54:48 brianp Exp $ */ + +/* + * Mesa 3-D graphics library + * Version: 2.6 + * Copyright (C) 1995-1997 Brian Paul + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Library General Public + * License as published by the Free Software Foundation; either + * version 2 of the License, or (at your option) any later version. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Library General Public License for more details. + * + * You should have received a copy of the GNU Library General Public + * License along with this library; if not, write to the Free + * Software Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. + */ + + +/* + * $Log: shade.c,v $ + * Revision 1.10 1997/12/18 02:54:48 brianp + * now using FloatToInt() macro for better performance on x86 + * + * Revision 1.9 1997/07/24 01:21:56 brianp + * changed precompiled header symbol from PCH to PC_HEADER + * + * Revision 1.8 1997/07/09 03:04:44 brianp + * fixed bug in gl_color_shade_vertices() with GL_COLOR_MATERIAL + * + * Revision 1.7 1997/07/05 16:24:26 brianp + * fixed FP underflow problem in pow(). Renamed h[xyz] to h_[xyz]. + * + * Revision 1.6 1997/06/20 04:15:43 brianp + * optimized changing of SHININESS (Henk Kok) + * + * Revision 1.5 1997/06/20 02:28:40 brianp + * changed color components from GLfixed to GLubyte + * + * Revision 1.4 1997/05/28 03:26:29 brianp + * added precompiled header (PCH) support + * + * Revision 1.3 1997/05/23 03:01:18 brianp + * commented out a few const keywords because IRIX cc chokes on them + * + * Revision 1.2 1997/05/09 02:41:08 brianp + * call GL_SQRT() instead of sqrt() + * + * Revision 1.1 1997/04/01 04:11:04 brianp + * Initial revision + * + */ + + +#ifdef PC_HEADER +#include "all.h" +#else +#include +#include "macros.h" +#include "mmath.h" +#include "shade.h" +#include "types.h" +#endif + + + +/* + * Return x^y. + */ +static GLfloat gl_pow( GLfloat x, GLfloat y ) +{ + GLdouble z = pow(x, y); + if (z<1.0e-10) + return 0.0F; + else + return (GLfloat) z; +} + + + +/* + * Use current lighting/material settings to compute the RGBA colors of + * an array of vertexes. + * Input: side - 0=use front material, 1=use back material + * n - number of vertexes to process + * vertex - array of vertex positions in eye coordinates + * normal - array of surface normal vectors + * Output: color - array of resulting colors + */ +void gl_color_shade_vertices( GLcontext *ctx, + GLuint side, + GLuint n, + /*const*/ GLfloat vertex[][4], + /*const*/ GLfloat normal[][3], + GLubyte color[][4] ) +{ + GLint j; + GLfloat rscale, gscale, bscale, ascale; + GLfloat baseR, baseG, baseB, baseA; + GLint sumA; + struct gl_light *light; + struct gl_material *mat; + + /* Compute scale factor to go from floats in [0,1] to integers or fixed + * point values: + */ + rscale = ctx->Visual->RedScale; + gscale = ctx->Visual->GreenScale; + bscale = ctx->Visual->BlueScale; + ascale = ctx->Visual->AlphaScale; + + mat = &ctx->Light.Material[side]; + + /*** Compute color contribution from global lighting ***/ + baseR = mat->Emission[0] + ctx->Light.Model.Ambient[0] * mat->Ambient[0]; + baseG = mat->Emission[1] + ctx->Light.Model.Ambient[1] * mat->Ambient[1]; + baseB = mat->Emission[2] + ctx->Light.Model.Ambient[2] * mat->Ambient[2]; + baseA = mat->Diffuse[3]; /* Alpha is simple, same for all vertices */ + + sumA = (GLint) (CLAMP( baseA, 0.0F, 1.0F ) * ascale); + + for (j=0;jLight.FirstEnabled; light; light=light->NextEnabled) { + GLfloat ambientR, ambientG, ambientB; + GLfloat attenuation, spot; + GLfloat VPx, VPy, VPz; /* unit vector from vertex to light */ + GLfloat n_dot_VP; /* n dot VP */ + + /* compute VP and attenuation */ + if (light->Position[3]==0.0) { + /* directional light */ + VPx = light->VP_inf_norm[0]; + VPy = light->VP_inf_norm[1]; + VPz = light->VP_inf_norm[2]; + attenuation = 1.0F; + } + else { + /* positional light */ + GLfloat d; /* distance from vertex to light */ + VPx = light->Position[0] - vertex[j][0]; + VPy = light->Position[1] - vertex[j][1]; + VPz = light->Position[2] - vertex[j][2]; + d = (GLfloat) GL_SQRT( VPx*VPx + VPy*VPy + VPz*VPz ); + if (d>0.001F) { + GLfloat invd = 1.0F / d; + VPx *= invd; + VPy *= invd; + VPz *= invd; + } + attenuation = 1.0F / (light->ConstantAttenuation + + d * (light->LinearAttenuation + + d * light->QuadraticAttenuation)); + } + + /* spotlight factor */ + if (light->SpotCutoff==180.0F) { + /* not a spot light */ + spot = 1.0F; + } + else { + GLfloat PVx, PVy, PVz, PV_dot_dir; + PVx = -VPx; + PVy = -VPy; + PVz = -VPz; + PV_dot_dir = PVx*light->NormDirection[0] + + PVy*light->NormDirection[1] + + PVz*light->NormDirection[2]; + if (PV_dot_dir<=0.0F || PV_dot_dirCosCutoff) { + /* outside of cone */ + spot = 0.0F; + } + else { + double x = PV_dot_dir * (EXP_TABLE_SIZE-1); + int k = (int) x; + spot = light->SpotExpTable[k][0] + + (x-k)*light->SpotExpTable[k][1]; + } + } + + ambientR = mat->Ambient[0] * light->Ambient[0]; + ambientG = mat->Ambient[1] * light->Ambient[1]; + ambientB = mat->Ambient[2] * light->Ambient[2]; + + /* Compute dot product or normal and vector from V to light pos */ + n_dot_VP = nx * VPx + ny * VPy + nz * VPz; + + /* diffuse and specular terms */ + if (n_dot_VP<=0.0F) { + /* surface face away from light, no diffuse or specular */ + GLfloat t = attenuation * spot; + sumR += t * ambientR; + sumG += t * ambientG; + sumB += t * ambientB; + /* done with this light */ + } + else { + GLfloat diffuseR, diffuseG, diffuseB; + GLfloat specularR, specularG, specularB; + GLfloat h_x, h_y, h_z, n_dot_h, t; + + /* diffuse term */ + diffuseR = n_dot_VP * mat->Diffuse[0] * light->Diffuse[0]; + diffuseG = n_dot_VP * mat->Diffuse[1] * light->Diffuse[1]; + diffuseB = n_dot_VP * mat->Diffuse[2] * light->Diffuse[2]; + + /* specular term */ + if (ctx->Light.Model.LocalViewer) { + GLfloat vx, vy, vz, vlen; + vx = vertex[j][0]; + vy = vertex[j][1]; + vz = vertex[j][2]; + vlen = GL_SQRT( vx*vx + vy*vy + vz*vz ); + if (vlen>0.0001F) { + GLfloat invlen = 1.0F / vlen; + vx *= invlen; + vy *= invlen; + vz *= invlen; + } + /* h = VP + VPe */ + h_x = VPx - vx; + h_y = VPy - vy; + h_z = VPz - vz; + } + else { + /* h = VP + <0,0,1> */ + h_x = VPx; + h_y = VPy; + h_z = VPz + 1.0F; + } + + /* attention: h is not normalized, done later if needed */ + n_dot_h = nx*h_x + ny*h_y + nz*h_z; + + if (n_dot_h<=0.0F) { + specularR = 0.0F; + specularG = 0.0F; + specularB = 0.0F; + } + else { + GLfloat spec_coef; + /* now `correct' the dot product */ + n_dot_h = n_dot_h / GL_SQRT( h_x*h_x + h_y*h_y + h_z*h_z ); + if (n_dot_h>1.0F) { + /* only happens if normal vector length > 1.0 */ + spec_coef = pow( n_dot_h, mat->Shininess ); + } + else { + /* use table lookup approximation */ + int k = (int) (n_dot_h * (GLfloat) (SHINE_TABLE_SIZE-1)); + if (mat->ShineTable[k] < 0.0F) + mat->ShineTable[k] = gl_pow( n_dot_h, mat->Shininess ); + spec_coef = mat->ShineTable[k]; + } + if (spec_coef<1.0e-10) { + specularR = 0.0F; + specularG = 0.0F; + specularB = 0.0F; + } + else { + specularR = spec_coef * mat->Specular[0]*light->Specular[0]; + specularG = spec_coef * mat->Specular[1]*light->Specular[1]; + specularB = spec_coef * mat->Specular[2]*light->Specular[2]; + } + } + + t = attenuation * spot; + sumR += t * (ambientR + diffuseR + specularR); + sumG += t * (ambientG + diffuseG + specularG); + sumB += t * (ambientB + diffuseB + specularB); + } + + } /*loop over lights*/ + + /* clamp and convert to integer or fixed point */ + color[j][0] = FloatToInt(CLAMP( sumR, 0.0F, 1.0F ) * rscale); + color[j][1] = FloatToInt(CLAMP( sumG, 0.0F, 1.0F ) * gscale); + color[j][2] = FloatToInt(CLAMP( sumB, 0.0F, 1.0F ) * bscale); + color[j][3] = sumA; + + } /*loop over vertices*/ +} + + + +/* + * This is an optimized version of the above function. + */ +void gl_color_shade_vertices_fast( GLcontext *ctx, + GLuint side, + GLuint n, + /*const*/ GLfloat normal[][3], + GLubyte color[][4] ) +{ + GLint j; + GLfloat rscale, gscale, bscale, ascale; + GLint sumA; + GLfloat *baseColor = ctx->Light.BaseColor[side]; + + /* Compute scale factor to go from floats in [0,1] to integers or fixed + * point values: + */ + rscale = ctx->Visual->RedScale; + gscale = ctx->Visual->GreenScale; + bscale = ctx->Visual->BlueScale; + ascale = ctx->Visual->AlphaScale; + + /* Alpha is easy to compute, same for all vertices */ + sumA = (GLint) (baseColor[3] * ascale); + + /* Loop over vertices */ + for (j=0;jLight.FirstEnabled; light; light=light->NextEnabled) { + GLfloat n_dot_VP; /* n dot VP */ + + n_dot_VP = nx * light->VP_inf_norm[0] + + ny * light->VP_inf_norm[1] + + nz * light->VP_inf_norm[2]; + + /* diffuse and specular terms */ + if (n_dot_VP>0.0F) { + GLfloat n_dot_h; + GLfloat *lightMatDiffuse = light->MatDiffuse[side]; + + /** add diffuse term **/ + sumR += n_dot_VP * lightMatDiffuse[0]; + sumG += n_dot_VP * lightMatDiffuse[1]; + sumB += n_dot_VP * lightMatDiffuse[2]; + + /** specular term **/ + /* dot product of n and h_inf_norm */ + n_dot_h = nx * light->h_inf_norm[0] + + ny * light->h_inf_norm[1] + + nz * light->h_inf_norm[2]; + if (n_dot_h>0.0F) { + if (n_dot_h>1.0F) { + /* only happens if Magnitude(n) > 1.0 */ + GLfloat spec_coef = pow( n_dot_h, + ctx->Light.Material[side].Shininess ); + if (spec_coef>1.0e-10F) { + sumR += spec_coef * light->MatSpecular[side][0]; + sumG += spec_coef * light->MatSpecular[side][1]; + sumB += spec_coef * light->MatSpecular[side][2]; + } + } + else { + /* use table lookup approximation */ + int k = (int) (n_dot_h * (GLfloat) (SHINE_TABLE_SIZE-1)); + struct gl_material *m = &ctx->Light.Material[side]; + GLfloat spec_coef; + if (m->ShineTable[k] < 0.0F) + m->ShineTable[k] = gl_pow( n_dot_h, m->Shininess ); + spec_coef = m->ShineTable[k]; + sumR += spec_coef * light->MatSpecular[side][0]; + sumG += spec_coef * light->MatSpecular[side][1]; + sumB += spec_coef * light->MatSpecular[side][2]; + } + } + } + + } /*loop over lights*/ + + /* clamp and convert to integer or fixed point */ + color[j][0] = FloatToInt(MIN2( sumR, 1.0F ) * rscale); + color[j][1] = FloatToInt(MIN2( sumG, 1.0F ) * gscale); + color[j][2] = FloatToInt(MIN2( sumB, 1.0F ) * bscale); + color[j][3] = sumA; + + } /*loop over vertices*/ +} + + + +/* + * Use current lighting/material settings to compute the color indexes + * for an array of vertices. + * Input: n - number of vertices to shade + * side - 0=use front material, 1=use back material + * vertex - array of [n] vertex position in eye coordinates + * normal - array of [n] surface normal vector + * Output: indexResult - resulting array of [n] color indexes + */ +void gl_index_shade_vertices( GLcontext *ctx, + GLuint side, + GLuint n, + GLfloat vertex[][4], + GLfloat normal[][3], + GLuint indexResult[] ) +{ + struct gl_material *mat = &ctx->Light.Material[side]; + GLint j; + + /* loop over vertices */ + for (j=0;jLight.FirstEnabled; light; light=light->NextEnabled) { + GLfloat attenuation; + GLfloat lx, ly, lz; /* unit vector from vertex to light */ + GLfloat l_dot_norm; /* dot product of l and n */ + + /* compute l and attenuation */ + if (light->Position[3]==0.0) { + /* directional light */ + /* Effectively, l is a vector from the origin to the light. */ + lx = light->VP_inf_norm[0]; + ly = light->VP_inf_norm[1]; + lz = light->VP_inf_norm[2]; + attenuation = 1.0F; + } + else { + /* positional light */ + GLfloat d; /* distance from vertex to light */ + lx = light->Position[0] - vertex[j][0]; + ly = light->Position[1] - vertex[j][1]; + lz = light->Position[2] - vertex[j][2]; + d = (GLfloat) GL_SQRT( lx*lx + ly*ly + lz*lz ); + if (d>0.001F) { + GLfloat invd = 1.0F / d; + lx *= invd; + ly *= invd; + lz *= invd; + } + attenuation = 1.0F / (light->ConstantAttenuation + + d * (light->LinearAttenuation + + d * light->QuadraticAttenuation)); + } + + l_dot_norm = lx*nx + ly*ny + lz*nz; + + if (l_dot_norm>0.0F) { + GLfloat spot_times_atten; + + /* spotlight factor */ + if (light->SpotCutoff==180.0F) { + /* not a spot light */ + spot_times_atten = attenuation; + } + else { + GLfloat v[3], dot; + v[0] = -lx; /* v points from light to vertex */ + v[1] = -ly; + v[2] = -lz; + dot = DOT3( v, light->NormDirection ); + if (dot<=0.0F || dotCosCutoff) { + /* outside of cone */ + spot_times_atten = 0.0F; + } + else { + double x = dot * (EXP_TABLE_SIZE-1); + int k = (int) x; + GLfloat spot = light->SpotExpTable[k][0] + + (x-k)*light->SpotExpTable[k][1]; + spot_times_atten = spot * attenuation; + } + } + + /* accumulate diffuse term */ + diffuse += l_dot_norm * light->dli * spot_times_atten; + + /* accumulate specular term */ + { + GLfloat h_x, h_y, h_z, n_dot_h, spec_coef; + + /* specular term */ + if (ctx->Light.Model.LocalViewer) { + GLfloat vx, vy, vz, vlen; + vx = vertex[j][0]; + vy = vertex[j][1]; + vz = vertex[j][2]; + vlen = GL_SQRT( vx*vx + vy*vy + vz*vz ); + if (vlen>0.0001F) { + GLfloat invlen = 1.0F / vlen; + vx *= invlen; + vy *= invlen; + vz *= invlen; + } + h_x = lx - vx; + h_y = ly - vy; + h_z = lz - vz; + } + else { + h_x = lx; + h_y = ly; + h_z = lz + 1.0F; + } + /* attention: s is not normalized, done later if necessary */ + n_dot_h = h_x*nx + h_y*ny + h_z*nz; + + if (n_dot_h <= 0.0F) { + spec_coef = 0.0F; + } + else { + /* now `correct' the dot product */ + n_dot_h = n_dot_h / GL_SQRT(h_x*h_x + h_y*h_y + h_z*h_z); + if (n_dot_h>1.0F) { + spec_coef = pow( n_dot_h, mat->Shininess ); + } + else { + int k = (int) (n_dot_h * (GLfloat)(SHINE_TABLE_SIZE-1)); + if (mat->ShineTable[k] < 0.0F) + mat->ShineTable[k] = gl_pow( n_dot_h, mat->Shininess ); + spec_coef = mat->ShineTable[k]; + } + } + specular += spec_coef * light->sli * spot_times_atten; + } + } + + } /*loop over lights*/ + + /* Now compute final color index */ + if (specular>1.0F) { + index = mat->SpecularIndex; + } + else { + GLfloat d_a, s_a; + d_a = mat->DiffuseIndex - mat->AmbientIndex; + s_a = mat->SpecularIndex - mat->AmbientIndex; + + index = mat->AmbientIndex + + diffuse * (1.0F-specular) * d_a + + specular * s_a; + if (index>mat->SpecularIndex) { + index = mat->SpecularIndex; + } + } + indexResult[j] = (GLuint) (GLint) index; + + } /*for vertex*/ +} + diff --git a/dll/opengl/mesa/shade.h b/dll/opengl/mesa/shade.h new file mode 100644 index 00000000000..cdf5008964e --- /dev/null +++ b/dll/opengl/mesa/shade.h @@ -0,0 +1,68 @@ +/* $Id: shade.h,v 1.3 1997/06/20 02:28:40 brianp Exp $ */ + +/* + * Mesa 3-D graphics library + * Version: 2.3 + * Copyright (C) 1995-1997 Brian Paul + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Library General Public + * License as published by the Free Software Foundation; either + * version 2 of the License, or (at your option) any later version. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Library General Public License for more details. + * + * You should have received a copy of the GNU Library General Public + * License along with this library; if not, write to the Free + * Software Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. + */ + + +/* + * $Log: shade.h,v $ + * Revision 1.3 1997/06/20 02:28:40 brianp + * changed color components from GLfixed to GLubyte + * + * Revision 1.2 1997/05/23 03:01:18 brianp + * commented out a few const keywords because IRIX cc chokes on them + * + * Revision 1.1 1997/04/01 04:10:06 brianp + * Initial revision + * + */ + + +#ifndef SHADE_H +#define SHADE_H + + +#include "types.h" + + +extern void gl_color_shade_vertices( GLcontext *ctx, + GLuint side, + GLuint n, + /*const*/ GLfloat vertex[][4], + /*const*/ GLfloat normal[][3], + GLubyte color[][4] ); + + +extern void gl_color_shade_vertices_fast( GLcontext *ctx, + GLuint side, + GLuint n, + /*const*/ GLfloat normal[][3], + GLubyte color[][4] ); + + +extern void gl_index_shade_vertices( GLcontext *ctx, + GLuint side, + GLuint n, + GLfloat vertex[][4], + GLfloat normal[][3], + GLuint indexResult[] ); + +#endif + diff --git a/dll/opengl/mesa/span.c b/dll/opengl/mesa/span.c new file mode 100644 index 00000000000..3b50c03207b --- /dev/null +++ b/dll/opengl/mesa/span.c @@ -0,0 +1,929 @@ +/* $Id: span.c,v 1.12 1997/08/14 01:12:37 brianp Exp $ */ + +/* + * Mesa 3-D graphics library + * Version: 2.4 + * Copyright (C) 1995-1997 Brian Paul + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Library General Public + * License as published by the Free Software Foundation; either + * version 2 of the License, or (at your option) any later version. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Library General Public License for more details. + * + * You should have received a copy of the GNU Library General Public + * License along with this library; if not, write to the Free + * Software Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. + */ + + +/* + * $Log: span.c,v $ + * Revision 1.12 1997/08/14 01:12:37 brianp + * replaced a few for loops with MEMSET calls + * + * Revision 1.11 1997/07/24 01:21:56 brianp + * changed precompiled header symbol from PCH to PC_HEADER + * + * Revision 1.10 1997/05/28 03:26:29 brianp + * added precompiled header (PCH) support + * + * Revision 1.9 1997/05/03 00:51:30 brianp + * new texturing function call: gl_texture_pixels() + * + * Revision 1.8 1997/04/16 23:54:11 brianp + * do per-pixel fog if texturing is enabled + * + * Revision 1.7 1997/02/09 19:53:43 brianp + * now use TEXTURE_xD enable constants + * + * Revision 1.6 1997/02/09 18:43:34 brianp + * added GL_EXT_texture3D support + * + * Revision 1.5 1997/01/28 22:17:44 brianp + * new RGBA mode logic op support + * + * Revision 1.4 1996/09/25 03:22:05 brianp + * added NO_DRAW_BIT support + * + * Revision 1.3 1996/09/15 14:18:55 brianp + * now use GLframebuffer and GLvisual + * + * Revision 1.2 1996/09/15 01:48:58 brianp + * removed #define NULL 0 + * + * Revision 1.1 1996/09/13 01:38:16 brianp + * Initial revision + * + */ + + +/* + * pixel span rasterization: + * These functions simulate the rasterization pipeline. + */ + + +#ifdef PC_HEADER +#include "all.h" +#else +#include +#include "alpha.h" +#include "alphabuf.h" +#include "blend.h" +#include "depth.h" +#include "fog.h" +#include "logic.h" +#include "macros.h" +#include "masking.h" +#include "scissor.h" +#include "span.h" +#include "stencil.h" +#include "texture.h" +#include "types.h" +#endif + + + + +/* + * Apply the current polygon stipple pattern to a span of pixels. + */ +static void stipple_polygon_span( GLcontext *ctx, + GLuint n, GLint x, GLint y, GLubyte mask[] ) +{ + register GLuint i, m, stipple, highbit=0x80000000; + + stipple = ctx->PolygonStipple[y % 32]; + m = highbit >> (GLuint) (x % 32); + + for (i=0;i> 1; + if (m==0) { + m = 0x80000000; + } + } +} + + + +/* + * Clip a pixel span to the current buffer/window boundaries. + * Return: 0 = all pixels clipped + * 1 = at least one pixel is visible + */ +static GLuint clip_span( GLcontext *ctx, + GLint n, GLint x, GLint y, GLubyte mask[] ) +{ + GLint i; + + /* Clip to top and bottom */ + if (y<0 || y>=ctx->Buffer->Height) { + return 0; + } + + /* Clip to left and right */ + if (x>=0 && x+n<=ctx->Buffer->Width) { + /* no clipping needed */ + return 1; + } + else if (x+n<=0) { + /* completely off left side */ + return 0; + } + else if (x>=ctx->Buffer->Width) { + /* completely off right side */ + return 0; + } + else { + /* clip-test each pixel, this could be done better */ + for (i=0;i=ctx->Buffer->Width) { + mask[i] = 0; + } + } + return 1; + } +} + + + +/* + * Write a horizontal span of color index pixels to the frame buffer. + * Stenciling, Depth-testing, etc. are done as needed. + * Input: n - number of pixels in the span + * x, y - location of leftmost pixel in the span + * z - array of [n] z-values + * index - array of [n] color indexes + * primitive - either GL_POINT, GL_LINE, GL_POLYGON, or GL_BITMAP + */ +void gl_write_index_span( GLcontext *ctx, + GLuint n, GLint x, GLint y, GLdepth z[], + GLuint index[], GLenum primitive ) +{ + GLubyte mask[MAX_WIDTH]; + GLuint index_save[MAX_WIDTH]; + + /* init mask to 1's (all pixels are to be written) */ + MEMSET(mask, 1, n); + + if ((ctx->RasterMask & WINCLIP_BIT) || primitive==GL_BITMAP) { + if (clip_span(ctx,n,x,y,mask)==0) { + return; + } + } + + /* Per-pixel fog */ + if (ctx->Fog.Enabled + && (ctx->Hint.Fog==GL_NICEST || primitive==GL_BITMAP)) { + gl_fog_index_pixels( ctx, n, z, index ); + } + + /* Do the scissor test */ + if (ctx->Scissor.Enabled) { + if (gl_scissor_span( ctx, n, x, y, mask )==0) { + return; + } + } + + /* Polygon Stippling */ + if (ctx->Polygon.StippleFlag && primitive==GL_POLYGON) { + stipple_polygon_span( ctx, n, x, y, mask ); + } + + if (ctx->Stencil.Enabled) { + /* first stencil test */ + if (gl_stencil_span( ctx, n, x, y, mask )==0) { + return; + } + /* depth buffering w/ stencil */ + gl_depth_stencil_span( ctx, n, x, y, z, mask ); + } + else if (ctx->Depth.Test) { + /* regular depth testing */ + if ((*ctx->Driver.DepthTestSpan)( ctx, n, x, y, z, mask )==0) return; + } + + if (ctx->RasterMask & NO_DRAW_BIT) { + /* write no pixels */ + return; + } + + if (ctx->RasterMask & FRONT_AND_BACK_BIT) { + /* Save a copy of the indexes since LogicOp and IndexMask + * may change them + */ + MEMCPY( index_save, index, n * sizeof(GLuint) ); + } + + if (ctx->Color.SWLogicOpEnabled) { + gl_logicop_ci_span( ctx, n, x, y, index, mask ); + } + if (ctx->Color.SWmasking) { + gl_mask_index_span( ctx, n, x, y, index ); + } + + /* write pixels */ + (*ctx->Driver.WriteIndexSpan)( ctx, n, x, y, index, mask ); + + + if (ctx->RasterMask & FRONT_AND_BACK_BIT) { + /*** Also draw to back buffer ***/ + (*ctx->Driver.SetBuffer)( ctx, GL_BACK ); + MEMCPY( index, index_save, n * sizeof(GLuint) ); + if (ctx->Color.SWLogicOpEnabled) { + gl_logicop_ci_span( ctx, n, x, y, index, mask ); + } + if (ctx->Color.SWmasking) { + gl_mask_index_span( ctx, n, x, y, index ); + } + (*ctx->Driver.WriteIndexSpan)( ctx, n, x, y, index, mask ); + (*ctx->Driver.SetBuffer)( ctx, GL_FRONT ); + } +} + + + + +void gl_write_monoindex_span( GLcontext *ctx, + GLuint n, GLint x, GLint y, GLdepth z[], + GLuint index, GLenum primitive ) +{ + GLuint i; + GLubyte mask[MAX_WIDTH]; + GLuint index_save[MAX_WIDTH]; + + /* init mask to 1's (all pixels are to be written) */ + MEMSET(mask, 1, n); + + if ((ctx->RasterMask & WINCLIP_BIT) || primitive==GL_BITMAP) + { + if (clip_span( ctx,n,x,y,mask)==0) { + return; + } + } + + /* Do the scissor test */ + if (ctx->Scissor.Enabled) + { + if (gl_scissor_span( ctx, n, x, y, mask )==0) { + return; + } + } + + /* Polygon Stippling */ + if (ctx->Polygon.StippleFlag && primitive==GL_POLYGON) + { + stipple_polygon_span( ctx, n, x, y, mask ); + } + + if (ctx->Stencil.Enabled) + { + /* first stencil test */ + if (gl_stencil_span( ctx, n, x, y, mask )==0) + { + return; + } + /* depth buffering w/ stencil */ + gl_depth_stencil_span( ctx, n, x, y, z, mask ); + } + else if (ctx->Depth.Test) + { + /* regular depth testing */ + if ((*ctx->Driver.DepthTestSpan)( ctx, n, x, y, z, mask )==0) + return; + } + + if (ctx->RasterMask & NO_DRAW_BIT) + { + /* write no pixels */ + return; + } + + if ((ctx->Fog.Enabled && (ctx->Hint.Fog==GL_NICEST || primitive==GL_BITMAP)) + || ctx->Color.SWLogicOpEnabled || ctx->Color.SWmasking) + { + GLuint ispan[MAX_WIDTH]; + /* index may change, replicate single index into an array */ + for (i=0;iFog.Enabled + && (ctx->Hint.Fog==GL_NICEST || primitive==GL_BITMAP)) + { + gl_fog_index_pixels( ctx, n, z, ispan ); + } + + if (ctx->RasterMask & FRONT_AND_BACK_BIT) + { + MEMCPY( index_save, ispan, n * sizeof(GLuint) ); + } + + if (ctx->Color.SWLogicOpEnabled) + { + gl_logicop_ci_span( ctx, n, x, y, ispan, mask ); + } + + if (ctx->Color.SWmasking) + { + gl_mask_index_span( ctx, n, x, y, ispan ); + } + + (*ctx->Driver.WriteIndexSpan)( ctx, n, x, y, ispan, mask ); + + if (ctx->RasterMask & FRONT_AND_BACK_BIT) + { + /*** Also draw to back buffer ***/ + (*ctx->Driver.SetBuffer)( ctx, GL_BACK ); + for (i=0;iColor.SWLogicOpEnabled) { + gl_logicop_ci_span( ctx, n, x, y, ispan, mask ); + } + if (ctx->Color.SWmasking) { + gl_mask_index_span( ctx, n, x, y, ispan ); + } + (*ctx->Driver.WriteIndexSpan)( ctx, n, x, y, ispan, mask ); + (*ctx->Driver.SetBuffer)( ctx, GL_FRONT ); + } + } + else + { + (*ctx->Driver.WriteMonoindexSpan)( ctx, n, x, y, mask ); + + if (ctx->RasterMask & FRONT_AND_BACK_BIT) + { + /*** Also draw to back buffer ***/ + (*ctx->Driver.SetBuffer)( ctx, GL_BACK ); + (*ctx->Driver.WriteMonoindexSpan)( ctx, n, x, y, mask ); + (*ctx->Driver.SetBuffer)( ctx, GL_FRONT ); + } + } +} + + + +void gl_write_color_span( GLcontext *ctx, + GLuint n, GLint x, GLint y, GLdepth z[], + GLubyte r[], GLubyte g[], + GLubyte b[], GLubyte a[], + GLenum primitive ) +{ + GLubyte mask[MAX_WIDTH]; + GLboolean write_all = GL_TRUE; + GLubyte rtmp[MAX_WIDTH], gtmp[MAX_WIDTH], btmp[MAX_WIDTH], atmp[MAX_WIDTH]; + GLubyte *red, *green, *blue, *alpha; + + /* init mask to 1's (all pixels are to be written) */ + MEMSET(mask, 1, n); + + if ((ctx->RasterMask & WINCLIP_BIT) || primitive==GL_BITMAP) { + if (clip_span( ctx,n,x,y,mask)==0) { + return; + } + write_all = GL_FALSE; + } + + if ((primitive==GL_BITMAP && ctx->MutablePixels) + || (ctx->RasterMask & FRONT_AND_BACK_BIT)) { + /* must make a copy of the colors since they may be modified */ + MEMCPY( rtmp, r, n * sizeof(GLubyte) ); + MEMCPY( gtmp, g, n * sizeof(GLubyte) ); + MEMCPY( btmp, b, n * sizeof(GLubyte) ); + MEMCPY( atmp, a, n * sizeof(GLubyte) ); + red = rtmp; + green = gtmp; + blue = btmp; + alpha = atmp; + } + else { + red = r; + green = g; + blue = b; + alpha = a; + } + + /* Per-pixel fog */ + if (ctx->Fog.Enabled && (ctx->Hint.Fog==GL_NICEST || primitive==GL_BITMAP + || ctx->Texture.Enabled)) { + gl_fog_color_pixels( ctx, n, z, red, green, blue, alpha ); + } + + /* Do the scissor test */ + if (ctx->Scissor.Enabled) { + if (gl_scissor_span( ctx, n, x, y, mask )==0) { + return; + } + write_all = GL_FALSE; + } + + /* Polygon Stippling */ + if (ctx->Polygon.StippleFlag && primitive==GL_POLYGON) { + stipple_polygon_span( ctx, n, x, y, mask ); + write_all = GL_FALSE; + } + + /* Do the alpha test */ + if (ctx->Color.AlphaEnabled) { + if (gl_alpha_test( ctx, n, alpha, mask )==0) { + return; + } + write_all = GL_FALSE; + } + + if (ctx->Stencil.Enabled) { + /* first stencil test */ + if (gl_stencil_span( ctx, n, x, y, mask )==0) { + return; + } + /* depth buffering w/ stencil */ + gl_depth_stencil_span( ctx, n, x, y, z, mask ); + write_all = GL_FALSE; + } + else if (ctx->Depth.Test) { + /* regular depth testing */ + GLuint m = (*ctx->Driver.DepthTestSpan)( ctx, n, x, y, z, mask ); + if (m==0) { + return; + } + if (mRasterMask & NO_DRAW_BIT) { + /* write no pixels */ + return; + } + + /* logic op or blending */ + if (ctx->Color.SWLogicOpEnabled) { + gl_logicop_rgba_span( ctx, n, x, y, red, green, blue, alpha, mask ); + } + else if (ctx->Color.BlendEnabled) { + gl_blend_span( ctx, n, x, y, red, green, blue, alpha, mask ); + } + + /* Color component masking */ + if (ctx->Color.SWmasking) { + gl_mask_color_span( ctx, n, x, y, red, green, blue, alpha ); + } + + /* write pixels */ + (*ctx->Driver.WriteColorSpan)( ctx, n, x, y, red, green, blue, alpha, + write_all ? NULL : mask ); + if (ctx->RasterMask & ALPHABUF_BIT) { + gl_write_alpha_span( ctx, n, x, y, alpha, write_all ? NULL : mask ); + } + + if (ctx->RasterMask & FRONT_AND_BACK_BIT) { + /*** Also render to back buffer ***/ + MEMCPY( rtmp, r, n * sizeof(GLubyte) ); + MEMCPY( gtmp, g, n * sizeof(GLubyte) ); + MEMCPY( btmp, b, n * sizeof(GLubyte) ); + MEMCPY( atmp, a, n * sizeof(GLubyte) ); + (*ctx->Driver.SetBuffer)( ctx, GL_BACK ); + if (ctx->Color.SWLogicOpEnabled) { + gl_logicop_rgba_span( ctx, n, x, y, red, green, blue, alpha, mask ); + } + else if (ctx->Color.BlendEnabled) { + gl_blend_span( ctx, n, x, y, red, green, blue, alpha, mask ); + } + if (ctx->Color.SWmasking) { + gl_mask_color_span( ctx, n, x, y, red, green, blue, alpha ); + } + (*ctx->Driver.WriteColorSpan)( ctx, n, x, y, red, green, blue, alpha, + write_all ? NULL : mask ); + if (ctx->RasterMask & ALPHABUF_BIT) { + ctx->Buffer->Alpha = ctx->Buffer->BackAlpha; + gl_write_alpha_span( ctx, n, x, y, alpha, write_all ? NULL : mask ); + ctx->Buffer->Alpha = ctx->Buffer->FrontAlpha; + } + (*ctx->Driver.SetBuffer)( ctx, GL_FRONT ); + } + +} + + + +/* + * Write a horizontal span of color pixels to the frame buffer. + * The color is initially constant for the whole span. + * Alpha-testing, stenciling, depth-testing, and blending are done as needed. + * Input: n - number of pixels in the span + * x, y - location of leftmost pixel in the span + * z - array of [n] z-values + * r, g, b, a - the color of the pixels + * primitive - either GL_POINT, GL_LINE, GL_POLYGON or GL_BITMAP. + */ +void gl_write_monocolor_span( GLcontext *ctx, + GLuint n, GLint x, GLint y, GLdepth z[], + GLint r, GLint g, GLint b, GLint a, + GLenum primitive ) +{ + GLuint i; + GLubyte mask[MAX_WIDTH]; + GLboolean write_all = GL_TRUE; + GLubyte red[MAX_WIDTH], green[MAX_WIDTH], blue[MAX_WIDTH], alpha[MAX_WIDTH]; + + /* init mask to 1's (all pixels are to be written) */ + MEMSET(mask, 1, n); + + if ((ctx->RasterMask & WINCLIP_BIT) || primitive==GL_BITMAP) { + if (clip_span( ctx,n,x,y,mask)==0) { + return; + } + write_all = GL_FALSE; + } + + /* Do the scissor test */ + if (ctx->Scissor.Enabled) { + if (gl_scissor_span( ctx, n, x, y, mask )==0) { + return; + } + write_all = GL_FALSE; + } + + /* Polygon Stippling */ + if (ctx->Polygon.StippleFlag && primitive==GL_POLYGON) { + stipple_polygon_span( ctx, n, x, y, mask ); + write_all = GL_FALSE; + } + + /* Do the alpha test */ + if (ctx->Color.AlphaEnabled) { + GLubyte alpha[MAX_WIDTH]; + for (i=0;iStencil.Enabled) { + /* first stencil test */ + if (gl_stencil_span( ctx, n, x, y, mask )==0) { + return; + } + /* depth buffering w/ stencil */ + gl_depth_stencil_span( ctx, n, x, y, z, mask ); + write_all = GL_FALSE; + } + else if (ctx->Depth.Test) { + /* regular depth testing */ + GLuint m = (*ctx->Driver.DepthTestSpan)( ctx, n, x, y, z, mask ); + if (m==0) { + return; + } + if (mRasterMask & NO_DRAW_BIT) { + /* write no pixels */ + return; + } + + if (ctx->Color.BlendEnabled || ctx->Color.SWLogicOpEnabled + || ctx->Color.SWmasking) { + /* assign same color to each pixel */ + for (i=0;iColor.SWLogicOpEnabled) { + gl_logicop_rgba_span( ctx, n, x, y, red, green, blue, alpha, mask ); + } + else if (ctx->Color.BlendEnabled) { + gl_blend_span( ctx, n, x, y, red, green, blue, alpha, mask ); + } + + /* Color component masking */ + if (ctx->Color.SWmasking) { + gl_mask_color_span( ctx, n, x, y, red, green, blue, alpha ); + } + + /* write pixels */ + (*ctx->Driver.WriteColorSpan)( ctx, n, x, y, red, green, blue, alpha, + write_all ? NULL : mask ); + if (ctx->RasterMask & ALPHABUF_BIT) { + gl_write_alpha_span( ctx, n, x, y, alpha, write_all ? NULL : mask ); + } + + if (ctx->RasterMask & FRONT_AND_BACK_BIT) { + /*** Also draw to back buffer ***/ + for (i=0;iDriver.SetBuffer)( ctx, GL_BACK ); + if (ctx->Color.SWLogicOpEnabled) { + gl_logicop_rgba_span( ctx, n, x, y, red, green, blue, alpha, mask); + } + else if (ctx->Color.BlendEnabled) { + gl_blend_span( ctx, n, x, y, red, green, blue, alpha, mask ); + } + if (ctx->Color.SWmasking) { + gl_mask_color_span( ctx, n, x, y, red, green, blue, alpha ); + } + (*ctx->Driver.WriteColorSpan)( ctx, n, x, y, red, green, blue, alpha, + write_all ? NULL : mask ); + (*ctx->Driver.SetBuffer)( ctx, GL_FRONT ); + if (ctx->RasterMask & ALPHABUF_BIT) { + ctx->Buffer->Alpha = ctx->Buffer->BackAlpha; + gl_write_alpha_span( ctx, n, x, y, alpha, + write_all ? NULL : mask ); + ctx->Buffer->Alpha = ctx->Buffer->FrontAlpha; + } + } + } + else { + (*ctx->Driver.WriteMonocolorSpan)( ctx, n, x, y, mask ); + if (ctx->RasterMask & ALPHABUF_BIT) { + gl_write_mono_alpha_span( ctx, n, x, y, a, write_all ? NULL : mask ); + } + if (ctx->RasterMask & FRONT_AND_BACK_BIT) { + /* Also draw to back buffer */ + (*ctx->Driver.SetBuffer)( ctx, GL_BACK ); + (*ctx->Driver.WriteMonocolorSpan)( ctx, n, x, y, mask ); + (*ctx->Driver.SetBuffer)( ctx, GL_FRONT ); + if (ctx->RasterMask & ALPHABUF_BIT) { + ctx->Buffer->Alpha = ctx->Buffer->BackAlpha; + gl_write_mono_alpha_span( ctx, n, x, y, a, + write_all ? NULL : mask ); + ctx->Buffer->Alpha = ctx->Buffer->FrontAlpha; + } + } + } +} + + + +/* + * Write a horizontal span of textured pixels to the frame buffer. + * The color of each pixel is different. + * Alpha-testing, stenciling, depth-testing, and blending are done + * as needed. + * Input: n - number of pixels in the span + * x, y - location of leftmost pixel in the span + * z - array of [n] z-values + * s, t - array of (s,t) texture coordinates for each pixel + * lambda - array of texture lambda values + * red, green, blue, alpha - array of [n] color components + * primitive - either GL_POINT, GL_LINE, GL_POLYGON or GL_BITMAP. + */ +void gl_write_texture_span( GLcontext *ctx, + GLuint n, GLint x, GLint y, GLdepth z[], + GLfloat s[], GLfloat t[], GLfloat u[], + GLfloat lambda[], + GLubyte r[], GLubyte g[], + GLubyte b[], GLubyte a[], + GLenum primitive ) +{ + GLubyte mask[MAX_WIDTH]; + GLboolean write_all = GL_TRUE; + GLubyte rtmp[MAX_WIDTH], gtmp[MAX_WIDTH], btmp[MAX_WIDTH], atmp[MAX_WIDTH]; + GLubyte *red, *green, *blue, *alpha; + + /* init mask to 1's (all pixels are to be written) */ + MEMSET(mask, 1, n); + + if ((ctx->RasterMask & WINCLIP_BIT) || primitive==GL_BITMAP) { + if (clip_span( ctx,n,x,y,mask)==0) { + return; + } + write_all = GL_FALSE; + } + + + if (primitive==GL_BITMAP || (ctx->RasterMask & FRONT_AND_BACK_BIT)) { + /* must make a copy of the colors since they may be modified */ + MEMCPY( rtmp, r, n * sizeof(GLubyte) ); + MEMCPY( gtmp, g, n * sizeof(GLubyte) ); + MEMCPY( btmp, b, n * sizeof(GLubyte) ); + MEMCPY( atmp, a, n * sizeof(GLubyte) ); + red = rtmp; + green = gtmp; + blue = btmp; + alpha = atmp; + } + else { + red = r; + green = g; + blue = b; + alpha = a; + } + + /* Texture */ + ASSERT(ctx->Texture.Enabled); + gl_texture_pixels( ctx, n, s, t, u, lambda, red, green, blue, alpha ); + + /* Per-pixel fog */ + if (ctx->Fog.Enabled && (ctx->Hint.Fog==GL_NICEST || primitive==GL_BITMAP + || ctx->Texture.Enabled)) { + gl_fog_color_pixels( ctx, n, z, red, green, blue, alpha ); + } + + /* Do the scissor test */ + if (ctx->Scissor.Enabled) { + if (gl_scissor_span( ctx, n, x, y, mask )==0) { + return; + } + write_all = GL_FALSE; + } + + /* Polygon Stippling */ + if (ctx->Polygon.StippleFlag && primitive==GL_POLYGON) { + stipple_polygon_span( ctx, n, x, y, mask ); + write_all = GL_FALSE; + } + + /* Do the alpha test */ + if (ctx->Color.AlphaEnabled) { + if (gl_alpha_test( ctx, n, alpha, mask )==0) { + return; + } + write_all = GL_FALSE; + } + + if (ctx->Stencil.Enabled) { + /* first stencil test */ + if (gl_stencil_span( ctx, n, x, y, mask )==0) { + return; + } + /* depth buffering w/ stencil */ + gl_depth_stencil_span( ctx, n, x, y, z, mask ); + write_all = GL_FALSE; + } + else if (ctx->Depth.Test) { + /* regular depth testing */ + GLuint m = (*ctx->Driver.DepthTestSpan)( ctx, n, x, y, z, mask ); + if (m==0) { + return; + } + if (mRasterMask & NO_DRAW_BIT) { + /* write no pixels */ + return; + } + + /* blending */ + if (ctx->Color.SWLogicOpEnabled) { + gl_logicop_rgba_span( ctx, n, x, y, red, green, blue, alpha, mask ); + } + else if (ctx->Color.BlendEnabled) { + gl_blend_span( ctx, n, x, y, red, green, blue, alpha, mask ); + } + + if (ctx->Color.SWmasking) { + gl_mask_color_span( ctx, n, x, y, red, green, blue, alpha ); + } + + /* write pixels */ + (*ctx->Driver.WriteColorSpan)( ctx, n, x, y, red, green, blue, alpha, + write_all ? NULL : mask ); + if (ctx->RasterMask & ALPHABUF_BIT) { + gl_write_alpha_span( ctx, n, x, y, alpha, write_all ? NULL : mask ); + } + + if (ctx->RasterMask & FRONT_AND_BACK_BIT) { + /* Also draw to back buffer */ + MEMCPY( rtmp, r, n * sizeof(GLubyte) ); + MEMCPY( gtmp, g, n * sizeof(GLubyte) ); + MEMCPY( btmp, b, n * sizeof(GLubyte) ); + MEMCPY( atmp, a, n * sizeof(GLubyte) ); + (*ctx->Driver.SetBuffer)( ctx, GL_BACK ); + if (ctx->Color.SWLogicOpEnabled) { + gl_logicop_rgba_span( ctx, n, x, y, red, green, blue, alpha, mask ); + } + else if (ctx->Color.BlendEnabled) { + gl_blend_span( ctx, n, x, y, red, green, blue, alpha, mask ); + } + if (ctx->Color.SWmasking) { + gl_mask_color_span( ctx, n, x, y, red, green, blue, alpha ); + } + (*ctx->Driver.WriteColorSpan)( ctx, n, x, y, red, green, blue, alpha, + write_all ? NULL : mask ); + (*ctx->Driver.SetBuffer)( ctx, GL_FRONT ); + if (ctx->RasterMask & ALPHABUF_BIT) { + ctx->Buffer->Alpha = ctx->Buffer->BackAlpha; + gl_write_alpha_span( ctx, n, x, y, alpha, write_all ? NULL : mask ); + ctx->Buffer->Alpha = ctx->Buffer->FrontAlpha; + } + } +} + + + +/* + * Read RGBA pixels from frame buffer. Clipping will be done to prevent + * reading ouside the buffer's boundaries. + */ +void gl_read_color_span( GLcontext *ctx, + GLuint n, GLint x, GLint y, + GLubyte red[], GLubyte green[], + GLubyte blue[], GLubyte alpha[] ) +{ + register GLuint i; + + if (y<0 || y>=ctx->Buffer->Height || x>=ctx->Buffer->Width) { + /* completely above, below, or right */ + for (i=0;i=0 && x+n<=ctx->Buffer->Width) { + /* OK */ + (*ctx->Driver.ReadColorSpan)( ctx, n, x, y, red, green, blue, alpha ); + if (ctx->RasterMask & ALPHABUF_BIT) { + gl_read_alpha_span( ctx, n, x, y, alpha ); + } + } + else { + i = 0; + if (x<0) { + while (x<0 && n>0) { + red[i] = green[i] = blue[i] = alpha[i] = 0; + x++; + n--; + i++; + } + } + n = MIN2( n, ctx->Buffer->Width - x ); + (*ctx->Driver.ReadColorSpan)( ctx, n, x, y, red+i, green+i, blue+i, alpha+i); + if (ctx->RasterMask & ALPHABUF_BIT) { + gl_read_alpha_span( ctx, n, x, y, alpha+i ); + } + } + } +} + + + + +/* + * Read CI pixels from frame buffer. Clipping will be done to prevent + * reading ouside the buffer's boundaries. + */ +void gl_read_index_span( GLcontext *ctx, + GLuint n, GLint x, GLint y, GLuint indx[] ) +{ + register GLuint i; + + if (y<0 || y>=ctx->Buffer->Height || x>=ctx->Buffer->Width) { + /* completely above, below, or right */ + for (i=0;i=0 && x+n<=ctx->Buffer->Width) { + /* OK */ + (*ctx->Driver.ReadIndexSpan)( ctx, n, x, y, indx ); + } + else { + i = 0; + if (x<0) { + while (x<0 && n>0) { + indx[i] = 0; + x++; + n--; + i++; + } + } + n = MIN2( n, ctx->Buffer->Width - x ); + (*ctx->Driver.ReadIndexSpan)( ctx, n, x, y, indx+i ); + } + } +} + + diff --git a/dll/opengl/mesa/span.h b/dll/opengl/mesa/span.h new file mode 100644 index 00000000000..0553ccc04aa --- /dev/null +++ b/dll/opengl/mesa/span.h @@ -0,0 +1,84 @@ +/* $Id: span.h,v 1.2 1997/02/09 18:43:34 brianp Exp $ */ + +/* + * Mesa 3-D graphics library + * Version: 2.2 + * Copyright (C) 1995-1997 Brian Paul + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Library General Public + * License as published by the Free Software Foundation; either + * version 2 of the License, or (at your option) any later version. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Library General Public License for more details. + * + * You should have received a copy of the GNU Library General Public + * License along with this library; if not, write to the Free + * Software Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. + */ + + +/* + * $Log: span.h,v $ + * Revision 1.2 1997/02/09 18:43:34 brianp + * added GL_EXT_texture3D support + * + * Revision 1.1 1996/09/13 01:38:16 brianp + * Initial revision + * + */ + + +#ifndef SPAN_H +#define SPAN_H + + +#include "types.h" + + +extern void gl_write_index_span( GLcontext *ctx, + GLuint n, GLint x, GLint y, GLdepth z[], + GLuint index[], GLenum primitive ); + + +extern void gl_write_monoindex_span( GLcontext *ctx, + GLuint n, GLint x, GLint y, GLdepth z[], + GLuint index, GLenum primitive ); + + +extern void gl_write_color_span( GLcontext *ctx, + GLuint n, GLint x, GLint y, GLdepth z[], + GLubyte red[], GLubyte green[], + GLubyte blue[], GLubyte alpha[], + GLenum primitive ); + + +extern void gl_write_monocolor_span( GLcontext *ctx, + GLuint n, GLint x, GLint y, GLdepth z[], + GLint r, GLint g, GLint b, GLint a, + GLenum primitive ); + + +extern void gl_write_texture_span( GLcontext *ctx, + GLuint n, GLint x, GLint y, GLdepth z[], + GLfloat s[], GLfloat t[], GLfloat u[], + GLfloat lambda[], + GLubyte red[], GLubyte green[], + GLubyte blue[], GLubyte alpha[], + GLenum primitive ); + + +extern void gl_read_color_span( GLcontext *ctx, + GLuint n, GLint x, GLint y, + GLubyte red[], GLubyte green[], + GLubyte blue[], GLubyte alpha[] ); + + +extern void gl_read_index_span( GLcontext *ctx, + GLuint n, GLint x, GLint y, GLuint indx[] ); + + +#endif diff --git a/dll/opengl/mesa/stencil.c b/dll/opengl/mesa/stencil.c new file mode 100644 index 00000000000..60089ae17a7 --- /dev/null +++ b/dll/opengl/mesa/stencil.c @@ -0,0 +1,1022 @@ +/* $Id: stencil.c,v 1.8 1998/01/01 00:52:11 brianp Exp $ */ + +/* + * Mesa 3-D graphics library + * Version: 2.6 + * Copyright (C) 1995-1997 Brian Paul + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Library General Public + * License as published by the Free Software Foundation; either + * version 2 of the License, or (at your option) any later version. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Library General Public License for more details. + * + * You should have received a copy of the GNU Library General Public + * License along with this library; if not, write to the Free + * Software Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. + */ + + +/* + * $Log: stencil.c,v $ + * Revision 1.8 1998/01/01 00:52:11 brianp + * added some tests to prevent crashing if Driver.DepthTestPixels not defined + * + * Revision 1.7 1997/07/24 01:21:56 brianp + * changed precompiled header symbol from PCH to PC_HEADER + * + * Revision 1.6 1997/05/28 03:26:29 brianp + * added precompiled header (PCH) support + * + * Revision 1.5 1997/04/29 01:26:37 brianp + * fixed a few return statements which were missing values + * + * Revision 1.4 1997/04/20 20:29:11 brianp + * replaced abort() with gl_problem() + * + * Revision 1.3 1997/02/27 19:58:35 brianp + * don't try to clear stencil buffer if there isn't one + * + * Revision 1.2 1996/09/15 14:18:55 brianp + * now use GLframebuffer and GLvisual + * + * Revision 1.1 1996/09/13 01:38:16 brianp + * Initial revision + * + */ + + +#ifdef PC_HEADER +#include "all.h" +#else +#include +#include +#include "context.h" +#include "dlist.h" +#include "macros.h" +#include "pb.h" +#include "stencil.h" +#include "types.h" +#endif + + +/* + * Return the address of a stencil buffer value given the window coords: + */ +#define STENCIL_ADDRESS(X,Y) (ctx->Buffer->Stencil + ctx->Buffer->Width * (Y) + (X)) + + +void gl_ClearStencil( GLcontext *ctx, GLint s ) +{ + if (INSIDE_BEGIN_END(ctx)) { + gl_error( ctx, GL_INVALID_OPERATION, "glClearStencil" ); + return; + } + ctx->Stencil.Clear = (GLstencil) s; +} + + + +void gl_StencilFunc( GLcontext *ctx, GLenum func, GLint ref, GLuint mask ) +{ + GLint maxref; + + if (INSIDE_BEGIN_END(ctx)) { + gl_error( ctx, GL_INVALID_OPERATION, "glStencilFunc" ); + return; + } + + switch (func) { + case GL_NEVER: + case GL_LESS: + case GL_LEQUAL: + case GL_GREATER: + case GL_GEQUAL: + case GL_EQUAL: + case GL_NOTEQUAL: + case GL_ALWAYS: + ctx->Stencil.Function = func; + break; + default: + gl_error( ctx, GL_INVALID_ENUM, "glStencilFunc" ); + return; + } + + maxref = (1 << STENCIL_BITS) - 1; + ctx->Stencil.Ref = CLAMP( ref, 0, maxref ); + ctx->Stencil.ValueMask = mask; +} + + + +void gl_StencilMask( GLcontext *ctx, GLuint mask ) +{ + if (INSIDE_BEGIN_END(ctx)) { + gl_error( ctx, GL_INVALID_OPERATION, "glStencilMask" ); + return; + } + ctx->Stencil.WriteMask = (GLstencil) mask; +} + + + +void gl_StencilOp( GLcontext *ctx, GLenum fail, GLenum zfail, GLenum zpass ) +{ + if (INSIDE_BEGIN_END(ctx)) { + gl_error( ctx, GL_INVALID_OPERATION, "glStencilOp" ); + return; + } + switch (fail) { + case GL_KEEP: + case GL_ZERO: + case GL_REPLACE: + case GL_INCR: + case GL_DECR: + case GL_INVERT: + ctx->Stencil.FailFunc = fail; + break; + default: + gl_error( ctx, GL_INVALID_ENUM, "glStencilOp" ); + return; + } + switch (zfail) { + case GL_KEEP: + case GL_ZERO: + case GL_REPLACE: + case GL_INCR: + case GL_DECR: + case GL_INVERT: + ctx->Stencil.ZFailFunc = zfail; + break; + default: + gl_error( ctx, GL_INVALID_ENUM, "glStencilOp" ); + return; + } + switch (zpass) { + case GL_KEEP: + case GL_ZERO: + case GL_REPLACE: + case GL_INCR: + case GL_DECR: + case GL_INVERT: + ctx->Stencil.ZPassFunc = zpass; + break; + default: + gl_error( ctx, GL_INVALID_ENUM, "glStencilOp" ); + return; + } +} + + + +/* Stencil Logic: + +IF stencil test fails THEN + Don't write the pixel (RGBA,Z) + Execute FailOp +ELSE + Write the pixel +ENDIF + +Perform Depth Test + +IF depth test passes OR no depth buffer THEN + Execute ZPass + Write the pixel +ELSE + Execute ZFail +ENDIF + +*/ + + + + +/* + * Apply the given stencil operator for each pixel in the span whose + * mask flag is set. + * Input: n - number of pixels in the span + * x, y - location of leftmost pixel in the span + * oper - the stencil buffer operator + * mask - array [n] of flag: 1=apply operator, 0=don't apply operator + */ +static void apply_stencil_op_to_span( GLcontext *ctx, + GLuint n, GLint x, GLint y, + GLenum oper, GLubyte mask[] ) +{ + GLint i; + GLstencil s, ref; + GLstencil wrtmask, invmask; + GLstencil *stencil; + + wrtmask = ctx->Stencil.WriteMask; + invmask = ~ctx->Stencil.WriteMask; + ref = ctx->Stencil.Ref; + stencil = STENCIL_ADDRESS( x, y ); + + switch (oper) { + case GL_KEEP: + /* do nothing */ + break; + case GL_ZERO: + if (invmask==0) { + for (i=0;i0) { + stencil[i] = s-1; + } + } + } + } + else { + for (i=0;i0) { + stencil[i] = (invmask & s) | (wrtmask & (s-1)); + } + } + } + } + break; + case GL_INVERT: + if (invmask==0) { + for (i=0;iStencil.Function) { + case GL_NEVER: + /* always fail */ + for (i=0;iStencil.Ref & ctx->Stencil.ValueMask; + for (i=0;iStencil.ValueMask; + if (r < s) { + /* passed */ + fail[i] = 0; + } + else { + fail[i] = 1; + mask[i] = 0; + } + } + else { + fail[i] = 0; + } + } + break; + case GL_LEQUAL: + r = ctx->Stencil.Ref & ctx->Stencil.ValueMask; + for (i=0;iStencil.ValueMask; + if (r <= s) { + /* pass */ + fail[i] = 0; + } + else { + fail[i] = 1; + mask[i] = 0; + } + } + else { + fail[i] = 0; + } + } + break; + case GL_GREATER: + r = ctx->Stencil.Ref & ctx->Stencil.ValueMask; + for (i=0;iStencil.ValueMask; + if (r > s) { + /* passed */ + fail[i] = 0; + } + else { + fail[i] = 1; + mask[i] = 0; + } + } + else { + fail[i] = 0; + } + } + break; + case GL_GEQUAL: + r = ctx->Stencil.Ref & ctx->Stencil.ValueMask; + for (i=0;iStencil.ValueMask; + if (r >= s) { + /* passed */ + fail[i] = 0; + } + else { + fail[i] = 1; + mask[i] = 0; + } + } + else { + fail[i] = 0; + } + } + break; + case GL_EQUAL: + r = ctx->Stencil.Ref & ctx->Stencil.ValueMask; + for (i=0;iStencil.ValueMask; + if (r == s) { + /* passed */ + fail[i] = 0; + } + else { + fail[i] = 1; + mask[i] = 0; + } + } + else { + fail[i] = 0; + } + } + break; + case GL_NOTEQUAL: + r = ctx->Stencil.Ref & ctx->Stencil.ValueMask; + for (i=0;iStencil.ValueMask; + if (r != s) { + /* passed */ + fail[i] = 0; + } + else { + fail[i] = 1; + mask[i] = 0; + } + } + else { + fail[i] = 0; + } + } + break; + case GL_ALWAYS: + /* always pass */ + for (i=0;iStencil.FailFunc, fail ); + + return (allfail) ? 0 : 1; +} + + + + +/* + * Apply the combination depth-buffer/stencil operator to a span of pixels. + * Input: n - number of pixels in the span + * x, y - location of leftmost pixel in span + * z - array [n] of z values + * Input: mask - array [n] of flags (1=test this pixel, 0=skip the pixel) + * Output: mask - array [n] of flags (1=depth test passed, 0=failed) + */ +void gl_depth_stencil_span( GLcontext *ctx, + GLuint n, GLint x, GLint y, const GLdepth z[], + GLubyte mask[] ) +{ + if (ctx->Depth.Test==GL_FALSE) { + /* + * No depth buffer, just apply zpass stencil function to active pixels. + */ + apply_stencil_op_to_span( ctx, n, x, y, ctx->Stencil.ZPassFunc, mask ); + } + else { + /* + * Perform depth buffering, then apply zpass or zfail stencil function. + */ + GLubyte passmask[MAX_WIDTH], failmask[MAX_WIDTH], oldmask[MAX_WIDTH]; + GLuint i; + + /* init pass and fail masks to zero, copy mask[] to oldmask[] */ + for (i=0;iDriver.DepthTestSpan) + (*ctx->Driver.DepthTestSpan)( ctx, n, x, y, z, mask ); + + /* set the stencil pass/fail flags according to result of depth test */ + for (i=0;iStencil.ZFailFunc, failmask ); + apply_stencil_op_to_span( ctx, n, x, y, ctx->Stencil.ZPassFunc, passmask ); + } +} + + + + +/* + * Apply the given stencil operator for each pixel in the array whose + * mask flag is set. + * Input: n - number of pixels in the span + * x, y - array of [n] pixels + * operator - the stencil buffer operator + * mask - array [n] of flag: 1=apply operator, 0=don't apply operator + */ +static void apply_stencil_op_to_pixels( GLcontext *ctx, + GLuint n, const GLint x[], + const GLint y[], + GLenum oper, GLubyte mask[] ) +{ + GLint i; + GLstencil ref; + GLstencil wrtmask, invmask; + + wrtmask = ctx->Stencil.WriteMask; + invmask = ~ctx->Stencil.WriteMask; + + ref = ctx->Stencil.Ref; + + switch (oper) { + case GL_KEEP: + /* do nothing */ + break; + case GL_ZERO: + if (invmask==0) { + for (i=0;i0) { + *sptr = *sptr - 1; + } + } + } + } + else { + for (i=0;i0) { + *sptr = (invmask & *sptr) | (wrtmask & (*sptr-1)); + } + } + } + } + break; + case GL_INVERT: + if (invmask==0) { + for (i=0;iStencil.Function) { + case GL_NEVER: + /* always fail */ + for (i=0;iStencil.Ref & ctx->Stencil.ValueMask; + for (i=0;iStencil.ValueMask; + if (r < s) { + /* passed */ + fail[i] = 0; + } + else { + fail[i] = 1; + mask[i] = 0; + } + } + else { + fail[i] = 0; + } + } + break; + case GL_LEQUAL: + r = ctx->Stencil.Ref & ctx->Stencil.ValueMask; + for (i=0;iStencil.ValueMask; + if (r <= s) { + /* pass */ + fail[i] = 0; + } + else { + fail[i] = 1; + mask[i] = 0; + } + } + else { + fail[i] = 0; + } + } + break; + case GL_GREATER: + r = ctx->Stencil.Ref & ctx->Stencil.ValueMask; + for (i=0;iStencil.ValueMask; + if (r > s) { + /* passed */ + fail[i] = 0; + } + else { + fail[i] = 1; + mask[i] = 0; + } + } + else { + fail[i] = 0; + } + } + break; + case GL_GEQUAL: + r = ctx->Stencil.Ref & ctx->Stencil.ValueMask; + for (i=0;iStencil.ValueMask; + if (r >= s) { + /* passed */ + fail[i] = 0; + } + else { + fail[i] = 1; + mask[i] = 0; + } + } + else { + fail[i] = 0; + } + } + break; + case GL_EQUAL: + r = ctx->Stencil.Ref & ctx->Stencil.ValueMask; + for (i=0;iStencil.ValueMask; + if (r == s) { + /* passed */ + fail[i] = 0; + } + else { + fail[i] = 1; + mask[i] = 0; + } + } + else { + fail[i] = 0; + } + } + break; + case GL_NOTEQUAL: + r = ctx->Stencil.Ref & ctx->Stencil.ValueMask; + for (i=0;iStencil.ValueMask; + if (r != s) { + /* passed */ + fail[i] = 0; + } + else { + fail[i] = 1; + mask[i] = 0; + } + } + else { + fail[i] = 0; + } + } + break; + case GL_ALWAYS: + /* always pass */ + for (i=0;iStencil.FailFunc, fail ); + + return (allfail) ? 0 : 1; +} + + + + +/* + * Apply the combination depth-buffer/stencil operator to a span of pixels. + * Input: n - number of pixels in the span + * x, y - array of [n] pixels to stencil + * z - array [n] of z values + * Input: mask - array [n] of flags (1=test this pixel, 0=skip the pixel) + * Output: mask - array [n] of flags (1=depth test passed, 0=failed) + */ +void gl_depth_stencil_pixels( GLcontext *ctx, + GLuint n, const GLint x[], const GLint y[], + const GLdepth z[], GLubyte mask[] ) +{ + if (ctx->Depth.Test==GL_FALSE) { + /* + * No depth buffer, just apply zpass stencil function to active pixels. + */ + apply_stencil_op_to_pixels( ctx, n, x, y, ctx->Stencil.ZPassFunc, mask ); + } + else { + /* + * Perform depth buffering, then apply zpass or zfail stencil function. + */ + GLubyte passmask[PB_SIZE], failmask[PB_SIZE], oldmask[PB_SIZE]; + GLuint i; + + /* init pass and fail masks to zero */ + for (i=0;iDriver.DepthTestPixels) + (*ctx->Driver.DepthTestPixels)( ctx, n, x, y, z, mask ); + + /* set the stencil pass/fail flags according to result of depth test */ + for (i=0;iStencil.ZFailFunc, failmask ); + apply_stencil_op_to_pixels( ctx, n, x, y, + ctx->Stencil.ZPassFunc, passmask ); + } + +} + + + +/* + * Return a span of stencil values from the stencil buffer. + * Input: n - how many pixels + * x,y - location of first pixel + * Output: stencil - the array of stencil values + */ +void gl_read_stencil_span( GLcontext *ctx, + GLuint n, GLint x, GLint y, GLubyte stencil[] ) +{ + GLstencil *s; + + if (ctx->Buffer->Stencil) { + s = STENCIL_ADDRESS( x, y ); + MEMCPY( stencil, s, n * sizeof(GLubyte) ); + } +} + + + +/* + * Write a span of stencil values to the stencil buffer. + * Input: n - how many pixels + * x,y - location of first pixel + * stencil - the array of stencil values + */ +void gl_write_stencil_span( GLcontext *ctx, + GLuint n, GLint x, GLint y, + const GLubyte stencil[] ) +{ + GLstencil *s; + + if (ctx->Buffer->Stencil) { + s = STENCIL_ADDRESS( x, y ); + MEMCPY( s, stencil, n * sizeof(GLubyte) ); + } +} + + + +/* + * Allocate a new stencil buffer. If there's an old one it will be + * deallocated first. The new stencil buffer will be uninitialized. + */ +void gl_alloc_stencil_buffer( GLcontext *ctx ) +{ + GLuint buffersize = ctx->Buffer->Width * ctx->Buffer->Height; + + /* deallocate current stencil buffer if present */ + if (ctx->Buffer->Stencil) { + free(ctx->Buffer->Stencil); + ctx->Buffer->Stencil = NULL; + } + + /* allocate new stencil buffer */ + ctx->Buffer->Stencil = (GLstencil *) malloc(buffersize * sizeof(GLstencil)); + if (!ctx->Buffer->Stencil) { + /* out of memory */ + ctx->Stencil.Enabled = GL_FALSE; + gl_error( ctx, GL_OUT_OF_MEMORY, "gl_alloc_stencil_buffer" ); + } +} + + + + +/* + * Clear the stencil buffer. If the stencil buffer doesn't exist yet we'll + * allocate it now. + */ +void gl_clear_stencil_buffer( GLcontext *ctx ) +{ + if (ctx->Visual->StencilBits==0 || !ctx->Buffer->Stencil) { + /* no stencil buffer */ + return; + } + + if (ctx->Scissor.Enabled) { + /* clear scissor region only */ + GLint y; + GLint width = ctx->Buffer->Xmax - ctx->Buffer->Xmin + 1; + for (y=ctx->Buffer->Ymin; y<=ctx->Buffer->Ymax; y++) { + GLstencil *ptr = STENCIL_ADDRESS( ctx->Buffer->Xmin, y ); + MEMSET( ptr, ctx->Stencil.Clear, width * sizeof(GLstencil) ); + } + } + else { + /* clear whole stencil buffer */ + MEMSET( ctx->Buffer->Stencil, ctx->Stencil.Clear, + ctx->Buffer->Width * ctx->Buffer->Height * sizeof(GLstencil) ); + } +} diff --git a/dll/opengl/mesa/stencil.h b/dll/opengl/mesa/stencil.h new file mode 100644 index 00000000000..2f14c815646 --- /dev/null +++ b/dll/opengl/mesa/stencil.h @@ -0,0 +1,89 @@ +/* $Id: stencil.h,v 1.1 1996/09/13 01:38:16 brianp Exp $ */ + +/* + * Mesa 3-D graphics library + * Version: 2.0 + * Copyright (C) 1995-1996 Brian Paul + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Library General Public + * License as published by the Free Software Foundation; either + * version 2 of the License, or (at your option) any later version. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Library General Public License for more details. + * + * You should have received a copy of the GNU Library General Public + * License along with this library; if not, write to the Free + * Software Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. + */ + + +/* + * $Log: stencil.h,v $ + * Revision 1.1 1996/09/13 01:38:16 brianp + * Initial revision + * + */ + + +#ifndef STENCIL_H +#define STENCIL_H + + +#include "types.h" + + +extern void gl_ClearStencil( GLcontext *ctx, GLint s ); + + +extern void gl_StencilFunc( GLcontext *ctx, GLenum func, + GLint ref, GLuint mask ); + + +extern void gl_StencilMask( GLcontext *ctx, GLuint mask ); + + +extern void gl_StencilOp( GLcontext *ctx, GLenum fail, + GLenum zfail, GLenum zpass ); + + + +extern GLint gl_stencil_span( GLcontext *ctx, + GLuint n, GLint x, GLint y, GLubyte mask[] ); + + +extern void gl_depth_stencil_span( GLcontext *ctx, GLuint n, GLint x, GLint y, + const GLdepth z[], GLubyte mask[] ); + + +extern GLint gl_stencil_pixels( GLcontext *ctx, + GLuint n, const GLint x[], const GLint y[], + GLubyte mask[] ); + + +extern void gl_depth_stencil_pixels( GLcontext *ctx, + GLuint n, const GLint x[], + const GLint y[], const GLdepth z[], + GLubyte mask[] ); + + +extern void gl_read_stencil_span( GLcontext *ctx, + GLuint n, GLint x, GLint y, + GLubyte stencil[] ); + + +extern void gl_write_stencil_span( GLcontext *ctx, + GLuint n, GLint x, GLint y, + const GLubyte stencil[] ); + + +extern void gl_alloc_stencil_buffer( GLcontext *ctx ); + + +extern void gl_clear_stencil_buffer( GLcontext *ctx ); + + +#endif diff --git a/dll/opengl/mesa/swrast/CMakeLists.txt b/dll/opengl/mesa/swrast/CMakeLists.txt deleted file mode 100644 index 32ae3fcd641..00000000000 --- a/dll/opengl/mesa/swrast/CMakeLists.txt +++ /dev/null @@ -1,41 +0,0 @@ - -list(APPEND SOURCE - s_aaline.c - s_aatriangle.c - s_alpha.c - s_bitmap.c - s_blend.c - s_clear.c - s_context.c - s_copypix.c - s_depth.c - s_drawpix.c - s_feedback.c - s_fog.c - s_lines.c - s_logic.c - s_masking.c - s_points.c - s_renderbuffer.c - s_span.c - s_stencil.c - s_texcombine.c - s_texfetch.c - s_texfilter.c - s_texture.c - s_triangle.c - s_zoom.c - precomp.h) - -add_library(mesa_swrast STATIC ${SOURCE}) -add_dependencies(mesa_swrast xdk) -add_pch(mesa_swrast precomp.h SOURCE) - -if(MSVC AND (NOT USE_CLANG_CL)) - replace_compile_flags("/we4189" " ") -else() - add_target_compile_flags(mesa_swrast "-Wno-unused-variable") - if(USE_CLANG_CL) - add_target_compile_flags(mesa_swrast "-Wno-sometimes-uninitialized -Wno-unused-local-typedef") - endif() -endif() diff --git a/dll/opengl/mesa/swrast/precomp.h b/dll/opengl/mesa/swrast/precomp.h deleted file mode 100644 index d619e86ee53..00000000000 --- a/dll/opengl/mesa/swrast/precomp.h +++ /dev/null @@ -1,40 +0,0 @@ -#ifndef _MESA_SWRAST_PCH_ -#define _MESA_SWRAST_PCH_ - -#include
-#include
-#include
-#include
-#include
-#include
-#include
-#include
-#include
-#include
-#include
-#include
-#include
-#include
- -#include "s_aaline.h" -#include "s_aatriangle.h" -#include "s_alpha.h" -#include "s_blend.h" -#include "s_context.h" -#include "s_depth.h" -#include "s_feedback.h" -#include "s_fog.h" -#include "s_lines.h" -#include "s_logic.h" -#include "s_masking.h" -#include "s_points.h" -#include "s_span.h" -#include "s_stencil.h" -#include "s_texcombine.h" -#include "s_texfetch.h" -#include "s_texfilter.h" -#include "s_triangle.h" -#include "s_zoom.h" -#include "swrast.h" - -#endif /* _MESA_SWRAST_PCH_ */ diff --git a/dll/opengl/mesa/swrast/s_aaline.c b/dll/opengl/mesa/swrast/s_aaline.c deleted file mode 100644 index 05085adccbb..00000000000 --- a/dll/opengl/mesa/swrast/s_aaline.c +++ /dev/null @@ -1,479 +0,0 @@ -/* - * Mesa 3-D graphics library - * Version: 6.5.3 - * - * Copyright (C) 1999-2007 Brian Paul All Rights Reserved. - * - * Permission is hereby granted, free of charge, to any person obtaining a - * copy of this software and associated documentation files (the "Software"), - * to deal in the Software without restriction, including without limitation - * the rights to use, copy, modify, merge, publish, distribute, sublicense, - * and/or sell copies of the Software, and to permit persons to whom the - * Software is furnished to do so, subject to the following conditions: - * - * The above copyright notice and this permission notice shall be included - * in all copies or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS - * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL - * BRIAN PAUL BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN - * AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN - * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. - */ - -#include - -#define SUB_PIXEL 4 - - -/* - * Info about the AA line we're rendering - */ -struct LineInfo -{ - GLfloat x0, y0; /* start */ - GLfloat x1, y1; /* end */ - GLfloat dx, dy; /* direction vector */ - GLfloat len; /* length */ - GLfloat halfWidth; /* half of line width */ - GLfloat xAdj, yAdj; /* X and Y adjustment for quad corners around line */ - /* for coverage computation */ - GLfloat qx0, qy0; /* quad vertices */ - GLfloat qx1, qy1; - GLfloat qx2, qy2; - GLfloat qx3, qy3; - GLfloat ex0, ey0; /* quad edge vectors */ - GLfloat ex1, ey1; - GLfloat ex2, ey2; - GLfloat ex3, ey3; - - /* DO_Z */ - GLfloat zPlane[4]; - /* DO_RGBA - always enabled */ - GLfloat rPlane[4], gPlane[4], bPlane[4], aPlane[4]; - /* DO_ATTRIBS */ - GLfloat wPlane[4]; - GLfloat attrPlane[FRAG_ATTRIB_MAX][4][4]; - GLfloat lambda[FRAG_ATTRIB_MAX]; - GLfloat texWidth[FRAG_ATTRIB_MAX]; - GLfloat texHeight[FRAG_ATTRIB_MAX]; - - SWspan span; -}; - - - -/* - * Compute the equation of a plane used to interpolate line fragment data - * such as color, Z, texture coords, etc. - * Input: (x0, y0) and (x1,y1) are the endpoints of the line. - * z0, and z1 are the end point values to interpolate. - * Output: plane - the plane equation. - * - * Note: we don't really have enough parameters to specify a plane. - * We take the endpoints of the line and compute a plane such that - * the cross product of the line vector and the plane normal is - * parallel to the projection plane. - */ -static void -compute_plane(GLfloat x0, GLfloat y0, GLfloat x1, GLfloat y1, - GLfloat z0, GLfloat z1, GLfloat plane[4]) -{ -#if 0 - /* original */ - const GLfloat px = x1 - x0; - const GLfloat py = y1 - y0; - const GLfloat pz = z1 - z0; - const GLfloat qx = -py; - const GLfloat qy = px; - const GLfloat qz = 0; - const GLfloat a = py * qz - pz * qy; - const GLfloat b = pz * qx - px * qz; - const GLfloat c = px * qy - py * qx; - const GLfloat d = -(a * x0 + b * y0 + c * z0); - plane[0] = a; - plane[1] = b; - plane[2] = c; - plane[3] = d; -#else - /* simplified */ - const GLfloat px = x1 - x0; - const GLfloat py = y1 - y0; - const GLfloat pz = z0 - z1; - const GLfloat a = pz * px; - const GLfloat b = pz * py; - const GLfloat c = px * px + py * py; - const GLfloat d = -(a * x0 + b * y0 + c * z0); - if (a == 0.0 && b == 0.0 && c == 0.0 && d == 0.0) { - plane[0] = 0.0; - plane[1] = 0.0; - plane[2] = 1.0; - plane[3] = 0.0; - } - else { - plane[0] = a; - plane[1] = b; - plane[2] = c; - plane[3] = d; - } -#endif -} - - -static inline void -constant_plane(GLfloat value, GLfloat plane[4]) -{ - plane[0] = 0.0; - plane[1] = 0.0; - plane[2] = -1.0; - plane[3] = value; -} - - -static inline GLfloat -solve_plane(GLfloat x, GLfloat y, const GLfloat plane[4]) -{ - const GLfloat z = (plane[3] + plane[0] * x + plane[1] * y) / -plane[2]; - return z; -} - -#define SOLVE_PLANE(X, Y, PLANE) \ - ((PLANE[3] + PLANE[0] * (X) + PLANE[1] * (Y)) / -PLANE[2]) - - -/* - * Return 1 / solve_plane(). - */ -static inline GLfloat -solve_plane_recip(GLfloat x, GLfloat y, const GLfloat plane[4]) -{ - const GLfloat denom = plane[3] + plane[0] * x + plane[1] * y; - if (denom == 0.0) - return 0.0; - else - return -plane[2] / denom; -} - - -/* - * Solve plane and return clamped GLchan value. - */ -static inline GLchan -solve_plane_chan(GLfloat x, GLfloat y, const GLfloat plane[4]) -{ - const GLfloat z = (plane[3] + plane[0] * x + plane[1] * y) / -plane[2]; -#if CHAN_TYPE == GL_FLOAT - return CLAMP(z, 0.0F, CHAN_MAXF); -#else - if (z < 0) - return 0; - else if (z > CHAN_MAX) - return CHAN_MAX; - return (GLchan) IROUND_POS(z); -#endif -} - - -/* - * Compute mipmap level of detail. - */ -static inline GLfloat -compute_lambda(const GLfloat sPlane[4], const GLfloat tPlane[4], - GLfloat invQ, GLfloat width, GLfloat height) -{ - GLfloat dudx = sPlane[0] / sPlane[2] * invQ * width; - GLfloat dudy = sPlane[1] / sPlane[2] * invQ * width; - GLfloat dvdx = tPlane[0] / tPlane[2] * invQ * height; - GLfloat dvdy = tPlane[1] / tPlane[2] * invQ * height; - GLfloat r1 = dudx * dudx + dudy * dudy; - GLfloat r2 = dvdx * dvdx + dvdy * dvdy; - GLfloat rho2 = r1 + r2; - /* return log base 2 of rho */ - if (rho2 == 0.0F) - return 0.0; - else - return (GLfloat) (LOGF(rho2) * 1.442695 * 0.5);/* 1.442695 = 1/log(2) */ -} - - - - -/* - * Fill in the samples[] array with the (x,y) subpixel positions of - * xSamples * ySamples sample positions. - * Note that the four corner samples are put into the first four - * positions of the array. This allows us to optimize for the common - * case of all samples being inside the polygon. - */ -static void -make_sample_table(GLint xSamples, GLint ySamples, GLfloat samples[][2]) -{ - const GLfloat dx = 1.0F / (GLfloat) xSamples; - const GLfloat dy = 1.0F / (GLfloat) ySamples; - GLint x, y; - GLint i; - - i = 4; - for (x = 0; x < xSamples; x++) { - for (y = 0; y < ySamples; y++) { - GLint j; - if (x == 0 && y == 0) { - /* lower left */ - j = 0; - } - else if (x == xSamples - 1 && y == 0) { - /* lower right */ - j = 1; - } - else if (x == 0 && y == ySamples - 1) { - /* upper left */ - j = 2; - } - else if (x == xSamples - 1 && y == ySamples - 1) { - /* upper right */ - j = 3; - } - else { - j = i++; - } - samples[j][0] = x * dx + 0.5F * dx; - samples[j][1] = y * dy + 0.5F * dy; - } - } -} - - - -/* - * Compute how much of the given pixel's area is inside the rectangle - * defined by vertices v0, v1, v2, v3. - * Vertices MUST be specified in counter-clockwise order. - * Return: coverage in [0, 1]. - */ -static GLfloat -compute_coveragef(const struct LineInfo *info, - GLint winx, GLint winy) -{ - static GLfloat samples[SUB_PIXEL * SUB_PIXEL][2]; - static GLboolean haveSamples = GL_FALSE; - const GLfloat x = (GLfloat) winx; - const GLfloat y = (GLfloat) winy; - GLint stop = 4, i; - GLfloat insideCount = SUB_PIXEL * SUB_PIXEL; - - if (!haveSamples) { - make_sample_table(SUB_PIXEL, SUB_PIXEL, samples); - haveSamples = GL_TRUE; - } - -#if 0 /*DEBUG*/ - { - const GLfloat area = dx0 * dy1 - dx1 * dy0; - assert(area >= 0.0); - } -#endif - - for (i = 0; i < stop; i++) { - const GLfloat sx = x + samples[i][0]; - const GLfloat sy = y + samples[i][1]; - const GLfloat fx0 = sx - info->qx0; - const GLfloat fy0 = sy - info->qy0; - const GLfloat fx1 = sx - info->qx1; - const GLfloat fy1 = sy - info->qy1; - const GLfloat fx2 = sx - info->qx2; - const GLfloat fy2 = sy - info->qy2; - const GLfloat fx3 = sx - info->qx3; - const GLfloat fy3 = sy - info->qy3; - /* cross product determines if sample is inside or outside each edge */ - GLfloat cross0 = (info->ex0 * fy0 - info->ey0 * fx0); - GLfloat cross1 = (info->ex1 * fy1 - info->ey1 * fx1); - GLfloat cross2 = (info->ex2 * fy2 - info->ey2 * fx2); - GLfloat cross3 = (info->ex3 * fy3 - info->ey3 * fx3); - /* Check if the sample is exactly on an edge. If so, let cross be a - * positive or negative value depending on the direction of the edge. - */ - if (cross0 == 0.0F) - cross0 = info->ex0 + info->ey0; - if (cross1 == 0.0F) - cross1 = info->ex1 + info->ey1; - if (cross2 == 0.0F) - cross2 = info->ex2 + info->ey2; - if (cross3 == 0.0F) - cross3 = info->ex3 + info->ey3; - if (cross0 < 0.0F || cross1 < 0.0F || cross2 < 0.0F || cross3 < 0.0F) { - /* point is outside quadrilateral */ - insideCount -= 1.0F; - stop = SUB_PIXEL * SUB_PIXEL; - } - } - if (stop == 4) - return 1.0F; - else - return insideCount * (1.0F / (SUB_PIXEL * SUB_PIXEL)); -} - - -typedef void (*plot_func)(struct gl_context *ctx, struct LineInfo *line, - int ix, int iy); - - - -/* - * Draw an AA line segment (called many times per line when stippling) - */ -static void -segment(struct gl_context *ctx, - struct LineInfo *line, - plot_func plot, - GLfloat t0, GLfloat t1) -{ - const GLfloat absDx = (line->dx < 0.0F) ? -line->dx : line->dx; - const GLfloat absDy = (line->dy < 0.0F) ? -line->dy : line->dy; - /* compute the actual segment's endpoints */ - const GLfloat x0 = line->x0 + t0 * line->dx; - const GLfloat y0 = line->y0 + t0 * line->dy; - const GLfloat x1 = line->x0 + t1 * line->dx; - const GLfloat y1 = line->y0 + t1 * line->dy; - - /* compute vertices of the line-aligned quadrilateral */ - line->qx0 = x0 - line->yAdj; - line->qy0 = y0 + line->xAdj; - line->qx1 = x0 + line->yAdj; - line->qy1 = y0 - line->xAdj; - line->qx2 = x1 + line->yAdj; - line->qy2 = y1 - line->xAdj; - line->qx3 = x1 - line->yAdj; - line->qy3 = y1 + line->xAdj; - /* compute the quad's edge vectors (for coverage calc) */ - line->ex0 = line->qx1 - line->qx0; - line->ey0 = line->qy1 - line->qy0; - line->ex1 = line->qx2 - line->qx1; - line->ey1 = line->qy2 - line->qy1; - line->ex2 = line->qx3 - line->qx2; - line->ey2 = line->qy3 - line->qy2; - line->ex3 = line->qx0 - line->qx3; - line->ey3 = line->qy0 - line->qy3; - - if (absDx > absDy) { - /* X-major line */ - GLfloat dydx = line->dy / line->dx; - GLfloat xLeft, xRight, yBot, yTop; - GLint ix, ixRight; - if (x0 < x1) { - xLeft = x0 - line->halfWidth; - xRight = x1 + line->halfWidth; - if (line->dy >= 0.0) { - yBot = y0 - 3.0F * line->halfWidth; - yTop = y0 + line->halfWidth; - } - else { - yBot = y0 - line->halfWidth; - yTop = y0 + 3.0F * line->halfWidth; - } - } - else { - xLeft = x1 - line->halfWidth; - xRight = x0 + line->halfWidth; - if (line->dy <= 0.0) { - yBot = y1 - 3.0F * line->halfWidth; - yTop = y1 + line->halfWidth; - } - else { - yBot = y1 - line->halfWidth; - yTop = y1 + 3.0F * line->halfWidth; - } - } - - /* scan along the line, left-to-right */ - ixRight = (GLint) (xRight + 1.0F); - - /*printf("avg span height: %g\n", yTop - yBot);*/ - for (ix = (GLint) xLeft; ix < ixRight; ix++) { - const GLint iyBot = (GLint) yBot; - const GLint iyTop = (GLint) (yTop + 1.0F); - GLint iy; - /* scan across the line, bottom-to-top */ - for (iy = iyBot; iy < iyTop; iy++) { - (*plot)(ctx, line, ix, iy); - } - yBot += dydx; - yTop += dydx; - } - } - else { - /* Y-major line */ - GLfloat dxdy = line->dx / line->dy; - GLfloat yBot, yTop, xLeft, xRight; - GLint iy, iyTop; - if (y0 < y1) { - yBot = y0 - line->halfWidth; - yTop = y1 + line->halfWidth; - if (line->dx >= 0.0) { - xLeft = x0 - 3.0F * line->halfWidth; - xRight = x0 + line->halfWidth; - } - else { - xLeft = x0 - line->halfWidth; - xRight = x0 + 3.0F * line->halfWidth; - } - } - else { - yBot = y1 - line->halfWidth; - yTop = y0 + line->halfWidth; - if (line->dx <= 0.0) { - xLeft = x1 - 3.0F * line->halfWidth; - xRight = x1 + line->halfWidth; - } - else { - xLeft = x1 - line->halfWidth; - xRight = x1 + 3.0F * line->halfWidth; - } - } - - /* scan along the line, bottom-to-top */ - iyTop = (GLint) (yTop + 1.0F); - - /*printf("avg span width: %g\n", xRight - xLeft);*/ - for (iy = (GLint) yBot; iy < iyTop; iy++) { - const GLint ixLeft = (GLint) xLeft; - const GLint ixRight = (GLint) (xRight + 1.0F); - GLint ix; - /* scan across the line, left-to-right */ - for (ix = ixLeft; ix < ixRight; ix++) { - (*plot)(ctx, line, ix, iy); - } - xLeft += dxdy; - xRight += dxdy; - } - } -} - - -#define NAME(x) aa_rgba_##x -#define DO_Z -#include "s_aalinetemp.h" - - -#define NAME(x) aa_general_rgba_##x -#define DO_Z -#define DO_ATTRIBS -#include "s_aalinetemp.h" - - - -void -_swrast_choose_aa_line_function(struct gl_context *ctx) -{ - SWcontext *swrast = SWRAST_CONTEXT(ctx); - - ASSERT(ctx->Line.SmoothFlag); - - if (ctx->Texture._EnabledCoord - || swrast->_FogEnabled) { - swrast->Line = aa_general_rgba_line; - } - else { - swrast->Line = aa_rgba_line; - } -} diff --git a/dll/opengl/mesa/swrast/s_aaline.h b/dll/opengl/mesa/swrast/s_aaline.h deleted file mode 100644 index 74d5518e179..00000000000 --- a/dll/opengl/mesa/swrast/s_aaline.h +++ /dev/null @@ -1,38 +0,0 @@ - -/* - * Mesa 3-D graphics library - * Version: 3.5 - * - * Copyright (C) 1999-2001 Brian Paul All Rights Reserved. - * - * Permission is hereby granted, free of charge, to any person obtaining a - * copy of this software and associated documentation files (the "Software"), - * to deal in the Software without restriction, including without limitation - * the rights to use, copy, modify, merge, publish, distribute, sublicense, - * and/or sell copies of the Software, and to permit persons to whom the - * Software is furnished to do so, subject to the following conditions: - * - * The above copyright notice and this permission notice shall be included - * in all copies or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS - * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL - * BRIAN PAUL BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN - * AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN - * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. - */ - - -#ifndef S_AALINE_H -#define S_AALINE_H - - -struct gl_context; - - -extern void -_swrast_choose_aa_line_function(struct gl_context *ctx); - - -#endif diff --git a/dll/opengl/mesa/swrast/s_aalinetemp.h b/dll/opengl/mesa/swrast/s_aalinetemp.h deleted file mode 100644 index 2c04801a5aa..00000000000 --- a/dll/opengl/mesa/swrast/s_aalinetemp.h +++ /dev/null @@ -1,238 +0,0 @@ -/* - * Mesa 3-D graphics library - * Version: 7.1 - * - * Copyright (C) 1999-2007 Brian Paul All Rights Reserved. - * - * Permission is hereby granted, free of charge, to any person obtaining a - * copy of this software and associated documentation files (the "Software"), - * to deal in the Software without restriction, including without limitation - * the rights to use, copy, modify, merge, publish, distribute, sublicense, - * and/or sell copies of the Software, and to permit persons to whom the - * Software is furnished to do so, subject to the following conditions: - * - * The above copyright notice and this permission notice shall be included - * in all copies or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS - * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL - * BRIAN PAUL BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN - * AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN - * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. - */ - - -/* - * Antialiased line template. - */ - - -/* - * Function to render each fragment in the AA line. - * \param ix - integer fragment window X coordiante - * \param iy - integer fragment window Y coordiante - */ -static void -NAME(plot)(struct gl_context *ctx, struct LineInfo *line, int ix, int iy) -{ - const SWcontext *swrast = SWRAST_CONTEXT(ctx); - const GLfloat fx = (GLfloat) ix; - const GLfloat fy = (GLfloat) iy; - const GLfloat coverage = compute_coveragef(line, ix, iy); - const GLuint i = line->span.end; - - (void) swrast; - - if (coverage == 0.0) - return; - - line->span.end++; - line->span.array->coverage[i] = coverage; - line->span.array->x[i] = ix; - line->span.array->y[i] = iy; - - /* - * Compute Z, color, texture coords, fog for the fragment by - * solving the plane equations at (ix,iy). - */ -#ifdef DO_Z - line->span.array->z[i] = (GLuint) solve_plane(fx, fy, line->zPlane); -#endif - line->span.array->rgba[i][RCOMP] = solve_plane_chan(fx, fy, line->rPlane); - line->span.array->rgba[i][GCOMP] = solve_plane_chan(fx, fy, line->gPlane); - line->span.array->rgba[i][BCOMP] = solve_plane_chan(fx, fy, line->bPlane); - line->span.array->rgba[i][ACOMP] = solve_plane_chan(fx, fy, line->aPlane); -#if defined(DO_ATTRIBS) - ATTRIB_LOOP_BEGIN - GLfloat (*attribArray)[4] = line->span.array->attribs[attr]; - if (attr == FRAG_ATTRIB_TEX) { - /* texcoord w/ divide by Q */ - const GLfloat invQ = solve_plane_recip(fx, fy, line->attrPlane[attr][3]); - GLuint c; - for (c = 0; c < 3; c++) { - attribArray[i][c] = solve_plane(fx, fy, line->attrPlane[attr][c]) * invQ; - } - line->span.array->lambda[i] - = compute_lambda(line->attrPlane[attr][0], - line->attrPlane[attr][1], invQ, - line->texWidth[attr], line->texHeight[attr]); - } - else { - /* non-texture attrib */ - const GLfloat invW = solve_plane_recip(fx, fy, line->wPlane); - GLuint c; - for (c = 0; c < 4; c++) { - attribArray[i][c] = solve_plane(fx, fy, line->attrPlane[attr][c]) * invW; - } - } - ATTRIB_LOOP_END -#endif - - if (line->span.end == MAX_WIDTH) { - _swrast_write_rgba_span(ctx, &(line->span)); - line->span.end = 0; /* reset counter */ - } -} - - - -/* - * Line setup - */ -static void -NAME(line)(struct gl_context *ctx, const SWvertex *v0, const SWvertex *v1) -{ - SWcontext *swrast = SWRAST_CONTEXT(ctx); - GLfloat tStart, tEnd; /* segment start, end along line length */ - GLboolean inSegment; - GLint iLen, i; - - /* Init the LineInfo struct */ - struct LineInfo line; - line.x0 = v0->attrib[FRAG_ATTRIB_WPOS][0]; - line.y0 = v0->attrib[FRAG_ATTRIB_WPOS][1]; - line.x1 = v1->attrib[FRAG_ATTRIB_WPOS][0]; - line.y1 = v1->attrib[FRAG_ATTRIB_WPOS][1]; - line.dx = line.x1 - line.x0; - line.dy = line.y1 - line.y0; - line.len = SQRTF(line.dx * line.dx + line.dy * line.dy); - line.halfWidth = 0.5F * CLAMP(ctx->Line.Width, - ctx->Const.MinLineWidthAA, - ctx->Const.MaxLineWidthAA); - - if (line.len == 0.0 || IS_INF_OR_NAN(line.len)) - return; - - INIT_SPAN(line.span, GL_LINE); - line.span.arrayMask = SPAN_XY | SPAN_COVERAGE; - line.xAdj = line.dx / line.len * line.halfWidth; - line.yAdj = line.dy / line.len * line.halfWidth; - -#ifdef DO_Z - line.span.arrayMask |= SPAN_Z; - compute_plane(line.x0, line.y0, line.x1, line.y1, - v0->attrib[FRAG_ATTRIB_WPOS][2], v1->attrib[FRAG_ATTRIB_WPOS][2], line.zPlane); -#endif - line.span.arrayMask |= SPAN_RGBA; - if (ctx->Light.ShadeModel == GL_SMOOTH) { - compute_plane(line.x0, line.y0, line.x1, line.y1, - v0->color[RCOMP], v1->color[RCOMP], line.rPlane); - compute_plane(line.x0, line.y0, line.x1, line.y1, - v0->color[GCOMP], v1->color[GCOMP], line.gPlane); - compute_plane(line.x0, line.y0, line.x1, line.y1, - v0->color[BCOMP], v1->color[BCOMP], line.bPlane); - compute_plane(line.x0, line.y0, line.x1, line.y1, - v0->color[ACOMP], v1->color[ACOMP], line.aPlane); - } - else { - constant_plane(v1->color[RCOMP], line.rPlane); - constant_plane(v1->color[GCOMP], line.gPlane); - constant_plane(v1->color[BCOMP], line.bPlane); - constant_plane(v1->color[ACOMP], line.aPlane); - } -#if defined(DO_ATTRIBS) - { - const GLfloat invW0 = v0->attrib[FRAG_ATTRIB_WPOS][3]; - const GLfloat invW1 = v1->attrib[FRAG_ATTRIB_WPOS][3]; - line.span.arrayMask |= SPAN_LAMBDA; - compute_plane(line.x0, line.y0, line.x1, line.y1, invW0, invW1, line.wPlane); - ATTRIB_LOOP_BEGIN - GLuint c; - if (swrast->_InterpMode[attr] == GL_FLAT) { - for (c = 0; c < 4; c++) { - constant_plane(v1->attrib[attr][c], line.attrPlane[attr][c]); - } - } - else { - for (c = 0; c < 4; c++) { - const GLfloat a0 = v0->attrib[attr][c] * invW0; - const GLfloat a1 = v1->attrib[attr][c] * invW1; - compute_plane(line.x0, line.y0, line.x1, line.y1, a0, a1, - line.attrPlane[attr][c]); - } - } - line.span.arrayAttribs |= BITFIELD64_BIT(attr); - if (attr == FRAG_ATTRIB_TEX) { - const struct gl_texture_object *obj = ctx->Texture.Unit._Current; - const struct gl_texture_image *texImage = obj->Image[0][obj->BaseLevel]; - line.texWidth[attr] = (GLfloat) texImage->Width; - line.texHeight[attr] = (GLfloat) texImage->Height; - } - ATTRIB_LOOP_END - } -#endif - - tStart = tEnd = 0.0; - inSegment = GL_FALSE; - iLen = (GLint) line.len; - - if (ctx->Line.StippleFlag) { - for (i = 0; i < iLen; i++) { - const GLuint bit = (swrast->StippleCounter / ctx->Line.StippleFactor) & 0xf; - if ((1 << bit) & ctx->Line.StipplePattern) { - /* stipple bit is on */ - const GLfloat t = (GLfloat) i / (GLfloat) line.len; - if (!inSegment) { - /* start new segment */ - inSegment = GL_TRUE; - tStart = t; - } - else { - /* still in the segment, extend it */ - tEnd = t; - } - } - else { - /* stipple bit is off */ - if (inSegment && (tEnd > tStart)) { - /* draw the segment */ - segment(ctx, &line, NAME(plot), tStart, tEnd); - inSegment = GL_FALSE; - } - else { - /* still between segments, do nothing */ - } - } - swrast->StippleCounter++; - } - - if (inSegment) { - /* draw the final segment of the line */ - segment(ctx, &line, NAME(plot), tStart, 1.0F); - } - } - else { - /* non-stippled */ - segment(ctx, &line, NAME(plot), 0.0, 1.0); - } - - _swrast_write_rgba_span(ctx, &(line.span)); -} - - - - -#undef DO_Z -#undef DO_ATTRIBS -#undef NAME diff --git a/dll/opengl/mesa/swrast/s_aatriangle.c b/dll/opengl/mesa/swrast/s_aatriangle.c deleted file mode 100644 index b597b575ad1..00000000000 --- a/dll/opengl/mesa/swrast/s_aatriangle.c +++ /dev/null @@ -1,285 +0,0 @@ -/* - * Mesa 3-D graphics library - * Version: 6.5.3 - * - * Copyright (C) 1999-2007 Brian Paul All Rights Reserved. - * - * Permission is hereby granted, free of charge, to any person obtaining a - * copy of this software and associated documentation files (the "Software"), - * to deal in the Software without restriction, including without limitation - * the rights to use, copy, modify, merge, publish, distribute, sublicense, - * and/or sell copies of the Software, and to permit persons to whom the - * Software is furnished to do so, subject to the following conditions: - * - * The above copyright notice and this permission notice shall be included - * in all copies or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS - * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL - * BRIAN PAUL BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN - * AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN - * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. - */ - - -/* - * Antialiased Triangle rasterizers - */ - -#include - -/* - * Compute coefficients of a plane using the X,Y coords of the v0, v1, v2 - * vertices and the given Z values. - * A point (x,y,z) lies on plane iff a*x+b*y+c*z+d = 0. - */ -static inline void -compute_plane(const GLfloat v0[], const GLfloat v1[], const GLfloat v2[], - GLfloat z0, GLfloat z1, GLfloat z2, GLfloat plane[4]) -{ - const GLfloat px = v1[0] - v0[0]; - const GLfloat py = v1[1] - v0[1]; - const GLfloat pz = z1 - z0; - - const GLfloat qx = v2[0] - v0[0]; - const GLfloat qy = v2[1] - v0[1]; - const GLfloat qz = z2 - z0; - - /* Crossproduct "(a,b,c):= dv1 x dv2" is orthogonal to plane. */ - const GLfloat a = py * qz - pz * qy; - const GLfloat b = pz * qx - px * qz; - const GLfloat c = px * qy - py * qx; - /* Point on the plane = "r*(a,b,c) + w", with fixed "r" depending - on the distance of plane from origin and arbitrary "w" parallel - to the plane. */ - /* The scalar product "(r*(a,b,c)+w)*(a,b,c)" is "r*(a^2+b^2+c^2)", - which is equal to "-d" below. */ - const GLfloat d = -(a * v0[0] + b * v0[1] + c * z0); - - plane[0] = a; - plane[1] = b; - plane[2] = c; - plane[3] = d; -} - - -/* - * Compute coefficients of a plane with a constant Z value. - */ -static inline void -constant_plane(GLfloat value, GLfloat plane[4]) -{ - plane[0] = 0.0; - plane[1] = 0.0; - plane[2] = -1.0; - plane[3] = value; -} - -#define CONSTANT_PLANE(VALUE, PLANE) \ -do { \ - PLANE[0] = 0.0F; \ - PLANE[1] = 0.0F; \ - PLANE[2] = -1.0F; \ - PLANE[3] = VALUE; \ -} while (0) - - - -/* - * Solve plane equation for Z at (X,Y). - */ -static inline GLfloat -solve_plane(GLfloat x, GLfloat y, const GLfloat plane[4]) -{ - ASSERT(plane[2] != 0.0F); - return (plane[3] + plane[0] * x + plane[1] * y) / -plane[2]; -} - - -#define SOLVE_PLANE(X, Y, PLANE) \ - ((PLANE[3] + PLANE[0] * (X) + PLANE[1] * (Y)) / -PLANE[2]) - -/* - * Solve plane and return clamped GLchan value. - */ -static inline GLchan -solve_plane_chan(GLfloat x, GLfloat y, const GLfloat plane[4]) -{ - const GLfloat z = (plane[3] + plane[0] * x + plane[1] * y) / -plane[2]; -#if CHAN_TYPE == GL_FLOAT - return CLAMP(z, 0.0F, CHAN_MAXF); -#else - if (z < 0) - return 0; - else if (z > CHAN_MAX) - return CHAN_MAX; - return (GLchan) IROUND_POS(z); -#endif -} - - -static inline GLfloat -plane_dx(const GLfloat plane[4]) -{ - return -plane[0] / plane[2]; -} - -static inline GLfloat -plane_dy(const GLfloat plane[4]) -{ - return -plane[1] / plane[2]; -} - - - -/* - * Compute how much (area) of the given pixel is inside the triangle. - * Vertices MUST be specified in counter-clockwise order. - * Return: coverage in [0, 1]. - */ -static GLfloat -compute_coveragef(const GLfloat v0[3], const GLfloat v1[3], - const GLfloat v2[3], GLint winx, GLint winy) -{ - /* Given a position [0,3]x[0,3] return the sub-pixel sample position. - * Contributed by Ray Tice. - * - * Jitter sample positions - - * - average should be .5 in x & y for each column - * - each of the 16 rows and columns should be used once - * - the rectangle formed by the first four points - * should contain the other points - * - the distrubition should be fairly even in any given direction - * - * The pattern drawn below isn't optimal, but it's better than a regular - * grid. In the drawing, the center of each subpixel is surrounded by - * four dots. The "x" marks the jittered position relative to the - * subpixel center. - */ -#define POS(a, b) (0.5+a*4+b)/16 - static const GLfloat samples[16][2] = { - /* start with the four corners */ - { POS(0, 2), POS(0, 0) }, - { POS(3, 3), POS(0, 2) }, - { POS(0, 0), POS(3, 1) }, - { POS(3, 1), POS(3, 3) }, - /* continue with interior samples */ - { POS(1, 1), POS(0, 1) }, - { POS(2, 0), POS(0, 3) }, - { POS(0, 3), POS(1, 3) }, - { POS(1, 2), POS(1, 0) }, - { POS(2, 3), POS(1, 2) }, - { POS(3, 2), POS(1, 1) }, - { POS(0, 1), POS(2, 2) }, - { POS(1, 0), POS(2, 1) }, - { POS(2, 1), POS(2, 3) }, - { POS(3, 0), POS(2, 0) }, - { POS(1, 3), POS(3, 0) }, - { POS(2, 2), POS(3, 2) } - }; - - const GLfloat x = (GLfloat) winx; - const GLfloat y = (GLfloat) winy; - const GLfloat dx0 = v1[0] - v0[0]; - const GLfloat dy0 = v1[1] - v0[1]; - const GLfloat dx1 = v2[0] - v1[0]; - const GLfloat dy1 = v2[1] - v1[1]; - const GLfloat dx2 = v0[0] - v2[0]; - const GLfloat dy2 = v0[1] - v2[1]; - GLint stop = 4, i; - GLfloat insideCount = 16.0F; - - ASSERT(dx0 * dy1 - dx1 * dy0 >= 0.0); /* area >= 0.0 */ - - for (i = 0; i < stop; i++) { - const GLfloat sx = x + samples[i][0]; - const GLfloat sy = y + samples[i][1]; - /* cross product determines if sample is inside or outside each edge */ - GLfloat cross = (dx0 * (sy - v0[1]) - dy0 * (sx - v0[0])); - /* Check if the sample is exactly on an edge. If so, let cross be a - * positive or negative value depending on the direction of the edge. - */ - if (cross == 0.0F) - cross = dx0 + dy0; - if (cross < 0.0F) { - /* sample point is outside first edge */ - insideCount -= 1.0F; - stop = 16; - } - else { - /* sample point is inside first edge */ - cross = (dx1 * (sy - v1[1]) - dy1 * (sx - v1[0])); - if (cross == 0.0F) - cross = dx1 + dy1; - if (cross < 0.0F) { - /* sample point is outside second edge */ - insideCount -= 1.0F; - stop = 16; - } - else { - /* sample point is inside first and second edges */ - cross = (dx2 * (sy - v2[1]) - dy2 * (sx - v2[0])); - if (cross == 0.0F) - cross = dx2 + dy2; - if (cross < 0.0F) { - /* sample point is outside third edge */ - insideCount -= 1.0F; - stop = 16; - } - } - } - } - if (stop == 4) - return 1.0F; - else - return insideCount * (1.0F / 16.0F); -} - - - -static void -rgba_aa_tri(struct gl_context *ctx, - const SWvertex *v0, - const SWvertex *v1, - const SWvertex *v2) -{ -#define DO_Z -#include "s_aatritemp.h" -} - - -static void -general_aa_tri(struct gl_context *ctx, - const SWvertex *v0, - const SWvertex *v1, - const SWvertex *v2) -{ -#define DO_Z -#define DO_ATTRIBS -#include "s_aatritemp.h" -} - - - -/* - * Examine GL state and set swrast->Triangle to an - * appropriate antialiased triangle rasterizer function. - */ -void -_swrast_set_aa_triangle_function(struct gl_context *ctx) -{ - SWcontext *swrast = SWRAST_CONTEXT(ctx); - - ASSERT(ctx->Polygon.SmoothFlag); - - if (ctx->Texture._EnabledCoord - || swrast->_FogEnabled) { - SWRAST_CONTEXT(ctx)->Triangle = general_aa_tri; - } - else { - SWRAST_CONTEXT(ctx)->Triangle = rgba_aa_tri; - } - - ASSERT(SWRAST_CONTEXT(ctx)->Triangle); -} diff --git a/dll/opengl/mesa/swrast/s_aatriangle.h b/dll/opengl/mesa/swrast/s_aatriangle.h deleted file mode 100644 index e40efb1985b..00000000000 --- a/dll/opengl/mesa/swrast/s_aatriangle.h +++ /dev/null @@ -1,38 +0,0 @@ - -/* - * Mesa 3-D graphics library - * Version: 3.5 - * - * Copyright (C) 1999-2001 Brian Paul All Rights Reserved. - * - * Permission is hereby granted, free of charge, to any person obtaining a - * copy of this software and associated documentation files (the "Software"), - * to deal in the Software without restriction, including without limitation - * the rights to use, copy, modify, merge, publish, distribute, sublicense, - * and/or sell copies of the Software, and to permit persons to whom the - * Software is furnished to do so, subject to the following conditions: - * - * The above copyright notice and this permission notice shall be included - * in all copies or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS - * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL - * BRIAN PAUL BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN - * AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN - * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. - */ - - -#ifndef S_AATRIANGLE_H -#define S_AATRIANGLE_H - - -struct gl_context; - - -extern void -_swrast_set_aa_triangle_function(struct gl_context *ctx); - - -#endif diff --git a/dll/opengl/mesa/swrast/s_aatritemp.h b/dll/opengl/mesa/swrast/s_aatritemp.h deleted file mode 100644 index 6ac564d6012..00000000000 --- a/dll/opengl/mesa/swrast/s_aatritemp.h +++ /dev/null @@ -1,341 +0,0 @@ -/* - * Mesa 3-D graphics library - * Version: 7.0.3 - * - * Copyright (C) 1999-2007 Brian Paul All Rights Reserved. - * - * Permission is hereby granted, free of charge, to any person obtaining a - * copy of this software and associated documentation files (the "Software"), - * to deal in the Software without restriction, including without limitation - * the rights to use, copy, modify, merge, publish, distribute, sublicense, - * and/or sell copies of the Software, and to permit persons to whom the - * Software is furnished to do so, subject to the following conditions: - * - * The above copyright notice and this permission notice shall be included - * in all copies or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS - * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL - * BRIAN PAUL BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN - * AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN - * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. - */ - - -/* - * Antialiased Triangle Rasterizer Template - * - * This file is #include'd to generate custom AA triangle rasterizers. - * NOTE: this code hasn't been optimized yet. That'll come after it - * works correctly. - * - * The following macros may be defined to indicate what auxillary information - * must be copmuted across the triangle: - * DO_Z - if defined, compute Z values - * DO_ATTRIBS - if defined, compute texcoords, varying, etc. - */ - -/*void triangle( struct gl_context *ctx, GLuint v0, GLuint v1, GLuint v2, GLuint pv )*/ -{ - const SWcontext *swrast = SWRAST_CONTEXT(ctx); - const GLfloat *p0 = v0->attrib[FRAG_ATTRIB_WPOS]; - const GLfloat *p1 = v1->attrib[FRAG_ATTRIB_WPOS]; - const GLfloat *p2 = v2->attrib[FRAG_ATTRIB_WPOS]; - const SWvertex *vMin, *vMid, *vMax; - GLint iyMin, iyMax; - GLfloat yMin, yMax; - GLboolean ltor; - GLfloat majDx, majDy; /* major (i.e. long) edge dx and dy */ - - SWspan span; - -#ifdef DO_Z - GLfloat zPlane[4]; -#endif - GLfloat rPlane[4], gPlane[4], bPlane[4], aPlane[4]; -#if defined(DO_ATTRIBS) - GLfloat attrPlane[FRAG_ATTRIB_MAX][4][4]; - GLfloat wPlane[4]; /* win[3] */ -#endif - GLfloat bf = SWRAST_CONTEXT(ctx)->_BackfaceCullSign; - - (void) swrast; - - INIT_SPAN(span, GL_POLYGON); - span.arrayMask = SPAN_COVERAGE; - - /* determine bottom to top order of vertices */ - { - GLfloat y0 = v0->attrib[FRAG_ATTRIB_WPOS][1]; - GLfloat y1 = v1->attrib[FRAG_ATTRIB_WPOS][1]; - GLfloat y2 = v2->attrib[FRAG_ATTRIB_WPOS][1]; - if (y0 <= y1) { - if (y1 <= y2) { - vMin = v0; vMid = v1; vMax = v2; /* y0<=y1<=y2 */ - } - else if (y2 <= y0) { - vMin = v2; vMid = v0; vMax = v1; /* y2<=y0<=y1 */ - } - else { - vMin = v0; vMid = v2; vMax = v1; bf = -bf; /* y0<=y2<=y1 */ - } - } - else { - if (y0 <= y2) { - vMin = v1; vMid = v0; vMax = v2; bf = -bf; /* y1<=y0<=y2 */ - } - else if (y2 <= y1) { - vMin = v2; vMid = v1; vMax = v0; bf = -bf; /* y2<=y1<=y0 */ - } - else { - vMin = v1; vMid = v2; vMax = v0; /* y1<=y2<=y0 */ - } - } - } - - majDx = vMax->attrib[FRAG_ATTRIB_WPOS][0] - vMin->attrib[FRAG_ATTRIB_WPOS][0]; - majDy = vMax->attrib[FRAG_ATTRIB_WPOS][1] - vMin->attrib[FRAG_ATTRIB_WPOS][1]; - - /* front/back-face determination and cullling */ - { - const GLfloat botDx = vMid->attrib[FRAG_ATTRIB_WPOS][0] - vMin->attrib[FRAG_ATTRIB_WPOS][0]; - const GLfloat botDy = vMid->attrib[FRAG_ATTRIB_WPOS][1] - vMin->attrib[FRAG_ATTRIB_WPOS][1]; - const GLfloat area = majDx * botDy - botDx * majDy; - /* Do backface culling */ - if (area * bf < 0 || area == 0 || IS_INF_OR_NAN(area)) - return; - ltor = (GLboolean) (area < 0.0F); - } - - /* Plane equation setup: - * We evaluate plane equations at window (x,y) coordinates in order - * to compute color, Z, fog, texcoords, etc. This isn't terribly - * efficient but it's easy and reliable. - */ -#ifdef DO_Z - compute_plane(p0, p1, p2, p0[2], p1[2], p2[2], zPlane); - span.arrayMask |= SPAN_Z; -#endif - if (ctx->Light.ShadeModel == GL_SMOOTH) { - compute_plane(p0, p1, p2, v0->color[RCOMP], v1->color[RCOMP], v2->color[RCOMP], rPlane); - compute_plane(p0, p1, p2, v0->color[GCOMP], v1->color[GCOMP], v2->color[GCOMP], gPlane); - compute_plane(p0, p1, p2, v0->color[BCOMP], v1->color[BCOMP], v2->color[BCOMP], bPlane); - compute_plane(p0, p1, p2, v0->color[ACOMP], v1->color[ACOMP], v2->color[ACOMP], aPlane); - } - else { - constant_plane(v2->color[RCOMP], rPlane); - constant_plane(v2->color[GCOMP], gPlane); - constant_plane(v2->color[BCOMP], bPlane); - constant_plane(v2->color[ACOMP], aPlane); - } - span.arrayMask |= SPAN_RGBA; -#if defined(DO_ATTRIBS) - { - const GLfloat invW0 = v0->attrib[FRAG_ATTRIB_WPOS][3]; - const GLfloat invW1 = v1->attrib[FRAG_ATTRIB_WPOS][3]; - const GLfloat invW2 = v2->attrib[FRAG_ATTRIB_WPOS][3]; - compute_plane(p0, p1, p2, invW0, invW1, invW2, wPlane); - span.attrStepX[FRAG_ATTRIB_WPOS][3] = plane_dx(wPlane); - span.attrStepY[FRAG_ATTRIB_WPOS][3] = plane_dy(wPlane); - ATTRIB_LOOP_BEGIN - GLuint c; - if (swrast->_InterpMode[attr] == GL_FLAT) { - for (c = 0; c < 4; c++) { - constant_plane(v2->attrib[attr][c] * invW2, attrPlane[attr][c]); - } - } - else { - for (c = 0; c < 4; c++) { - const GLfloat a0 = v0->attrib[attr][c] * invW0; - const GLfloat a1 = v1->attrib[attr][c] * invW1; - const GLfloat a2 = v2->attrib[attr][c] * invW2; - compute_plane(p0, p1, p2, a0, a1, a2, attrPlane[attr][c]); - } - } - for (c = 0; c < 4; c++) { - span.attrStepX[attr][c] = plane_dx(attrPlane[attr][c]); - span.attrStepY[attr][c] = plane_dy(attrPlane[attr][c]); - } - ATTRIB_LOOP_END - } -#endif - - /* Begin bottom-to-top scan over the triangle. - * The long edge will either be on the left or right side of the - * triangle. We always scan from the long edge toward the shorter - * edges, stopping when we find that coverage = 0. If the long edge - * is on the left we scan left-to-right. Else, we scan right-to-left. - */ - yMin = vMin->attrib[FRAG_ATTRIB_WPOS][1]; - yMax = vMax->attrib[FRAG_ATTRIB_WPOS][1]; - iyMin = (GLint) yMin; - iyMax = (GLint) yMax + 1; - - if (ltor) { - /* scan left to right */ - const GLfloat *pMin = vMin->attrib[FRAG_ATTRIB_WPOS]; - const GLfloat *pMid = vMid->attrib[FRAG_ATTRIB_WPOS]; - const GLfloat *pMax = vMax->attrib[FRAG_ATTRIB_WPOS]; - const GLfloat dxdy = majDx / majDy; - const GLfloat xAdj = dxdy < 0.0F ? -dxdy : 0.0F; - GLint iy; -#ifdef _OPENMP -#pragma omp parallel for schedule(dynamic) private(iy) firstprivate(span) -#endif - for (iy = iyMin; iy < iyMax; iy++) { - GLfloat x = pMin[0] - (yMin - iy) * dxdy; - GLint ix, startX = (GLint) (x - xAdj); - GLuint count; - GLfloat coverage = 0.0F; - -#ifdef _OPENMP - /* each thread needs to use a different (global) SpanArrays variable */ - span.array = SWRAST_CONTEXT(ctx)->SpanArrays + omp_get_thread_num(); -#endif - /* skip over fragments with zero coverage */ - while (startX < MAX_WIDTH) { - coverage = compute_coveragef(pMin, pMid, pMax, startX, iy); - if (coverage > 0.0F) - break; - startX++; - } - - /* enter interior of triangle */ - ix = startX; - -#if defined(DO_ATTRIBS) - /* compute attributes at left-most fragment */ - span.attrStart[FRAG_ATTRIB_WPOS][3] = solve_plane(ix + 0.5F, iy + 0.5F, wPlane); - ATTRIB_LOOP_BEGIN - GLuint c; - for (c = 0; c < 4; c++) { - span.attrStart[attr][c] = solve_plane(ix + 0.5F, iy + 0.5F, attrPlane[attr][c]); - } - ATTRIB_LOOP_END -#endif - - count = 0; - while (coverage > 0.0F) { - /* (cx,cy) = center of fragment */ - const GLfloat cx = ix + 0.5F, cy = iy + 0.5F; - SWspanarrays *array = span.array; - array->coverage[count] = coverage; -#ifdef DO_Z - array->z[count] = (GLuint) solve_plane(cx, cy, zPlane); -#endif - array->rgba[count][RCOMP] = solve_plane_chan(cx, cy, rPlane); - array->rgba[count][GCOMP] = solve_plane_chan(cx, cy, gPlane); - array->rgba[count][BCOMP] = solve_plane_chan(cx, cy, bPlane); - array->rgba[count][ACOMP] = solve_plane_chan(cx, cy, aPlane); - ix++; - count++; - coverage = compute_coveragef(pMin, pMid, pMax, ix, iy); - } - - if (ix > startX) { - span.x = startX; - span.y = iy; - span.end = (GLuint) ix - (GLuint) startX; - _swrast_write_rgba_span(ctx, &span); - } - } - } - else { - /* scan right to left */ - const GLfloat *pMin = vMin->attrib[FRAG_ATTRIB_WPOS]; - const GLfloat *pMid = vMid->attrib[FRAG_ATTRIB_WPOS]; - const GLfloat *pMax = vMax->attrib[FRAG_ATTRIB_WPOS]; - const GLfloat dxdy = majDx / majDy; - const GLfloat xAdj = dxdy > 0 ? dxdy : 0.0F; - GLint iy; -#ifdef _OPENMP -#pragma omp parallel for schedule(dynamic) private(iy) firstprivate(span) -#endif - for (iy = iyMin; iy < iyMax; iy++) { - GLfloat x = pMin[0] - (yMin - iy) * dxdy; - GLint ix, left, startX = (GLint) (x + xAdj); - GLuint count, n; - GLfloat coverage = 0.0F; - -#ifdef _OPENMP - /* each thread needs to use a different (global) SpanArrays variable */ - span.array = SWRAST_CONTEXT(ctx)->SpanArrays + omp_get_thread_num(); -#endif - /* make sure we're not past the window edge */ - if (startX >= ctx->DrawBuffer->_Xmax) { - startX = ctx->DrawBuffer->_Xmax - 1; - } - - /* skip fragments with zero coverage */ - while (startX > 0) { - coverage = compute_coveragef(pMin, pMax, pMid, startX, iy); - if (coverage > 0.0F) - break; - startX--; - } - - /* enter interior of triangle */ - ix = startX; - count = 0; - while (coverage > 0.0F) { - /* (cx,cy) = center of fragment */ - const GLfloat cx = ix + 0.5F, cy = iy + 0.5F; - SWspanarrays *array = span.array; - ASSERT(ix >= 0); - array->coverage[ix] = coverage; -#ifdef DO_Z - array->z[ix] = (GLuint) solve_plane(cx, cy, zPlane); -#endif - array->rgba[ix][RCOMP] = solve_plane_chan(cx, cy, rPlane); - array->rgba[ix][GCOMP] = solve_plane_chan(cx, cy, gPlane); - array->rgba[ix][BCOMP] = solve_plane_chan(cx, cy, bPlane); - array->rgba[ix][ACOMP] = solve_plane_chan(cx, cy, aPlane); - ix--; - count++; - coverage = compute_coveragef(pMin, pMax, pMid, ix, iy); - } - -#if defined(DO_ATTRIBS) - /* compute attributes at left-most fragment */ - span.attrStart[FRAG_ATTRIB_WPOS][3] = solve_plane(ix + 1.5F, iy + 0.5F, wPlane); - ATTRIB_LOOP_BEGIN - GLuint c; - for (c = 0; c < 4; c++) { - span.attrStart[attr][c] = solve_plane(ix + 1.5F, iy + 0.5F, attrPlane[attr][c]); - } - ATTRIB_LOOP_END -#endif - - if (startX > ix) { - n = (GLuint) startX - (GLuint) ix; - - left = ix + 1; - - /* shift all values to the left */ - /* XXX this is temporary */ - { - SWspanarrays *array = span.array; - GLint j; - for (j = 0; j < (GLint) n; j++) { - array->coverage[j] = array->coverage[j + left]; - COPY_CHAN4(array->rgba[j], array->rgba[j + left]); -#ifdef DO_Z - array->z[j] = array->z[j + left]; -#endif - } - } - - span.x = left; - span.y = iy; - span.end = n; - _swrast_write_rgba_span(ctx, &span); - } - } - } -} - - -#undef DO_Z -#undef DO_ATTRIBS -#undef DO_OCCLUSION_TEST diff --git a/dll/opengl/mesa/swrast/s_alpha.c b/dll/opengl/mesa/swrast/s_alpha.c deleted file mode 100644 index 32f66b9cdd6..00000000000 --- a/dll/opengl/mesa/swrast/s_alpha.c +++ /dev/null @@ -1,153 +0,0 @@ -/* - * Mesa 3-D graphics library - * Version: 6.5.2 - * - * Copyright (C) 1999-2006 Brian Paul All Rights Reserved. - * - * Permission is hereby granted, free of charge, to any person obtaining a - * copy of this software and associated documentation files (the "Software"), - * to deal in the Software without restriction, including without limitation - * the rights to use, copy, modify, merge, publish, distribute, sublicense, - * and/or sell copies of the Software, and to permit persons to whom the - * Software is furnished to do so, subject to the following conditions: - * - * The above copyright notice and this permission notice shall be included - * in all copies or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS - * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL - * BRIAN PAUL BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN - * AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN - * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. - */ - -/** - * \file swrast/s_alpha.c - * \brief Functions to apply alpha test. - */ - -#include - -#define ALPHA_TEST(ALPHA, LOOP_CODE) \ -do { \ - switch (ctx->Color.AlphaFunc) { \ - case GL_LESS: \ - for (i = 0; i < n; i++) { \ - mask[i] &= (ALPHA < ref); \ - LOOP_CODE; \ - } \ - break; \ - case GL_LEQUAL: \ - for (i = 0; i < n; i++) { \ - mask[i] &= (ALPHA <= ref); \ - LOOP_CODE; \ - } \ - break; \ - case GL_GEQUAL: \ - for (i = 0; i < n; i++) { \ - mask[i] &= (ALPHA >= ref); \ - LOOP_CODE; \ - } \ - break; \ - case GL_GREATER: \ - for (i = 0; i < n; i++) { \ - mask[i] &= (ALPHA > ref); \ - LOOP_CODE; \ - } \ - break; \ - case GL_NOTEQUAL: \ - for (i = 0; i < n; i++) { \ - mask[i] &= (ALPHA != ref); \ - LOOP_CODE; \ - } \ - break; \ - case GL_EQUAL: \ - for (i = 0; i < n; i++) { \ - mask[i] &= (ALPHA == ref); \ - LOOP_CODE; \ - } \ - break; \ - default: \ - _mesa_problem(ctx, "Invalid alpha test in _swrast_alpha_test" ); \ - return 0; \ - } \ -} while (0) - - - -/** - * Perform the alpha test for an array of pixels. - * For pixels that fail the test, mask[i] will be set to 0. - * \return 0 if all pixels in the span failed the alpha test, - * 1 if one or more pixels passed the alpha test. - */ -GLint -_swrast_alpha_test(const struct gl_context *ctx, SWspan *span) -{ - const GLuint n = span->end; - GLubyte *mask = span->array->mask; - GLuint i; - - if (ctx->Color.AlphaFunc == GL_ALWAYS) { - /* do nothing */ - return 1; - } - else if (ctx->Color.AlphaFunc == GL_NEVER) { - /* All pixels failed - caller should check for this return value and - * act accordingly. - */ - span->writeAll = GL_FALSE; - return 0; - } - - if (span->arrayMask & SPAN_RGBA) { - /* Use array's alpha values */ - if (span->array->ChanType == GL_UNSIGNED_BYTE) { - GLubyte (*rgba)[4] = span->array->rgba8; - GLubyte ref; - CLAMPED_FLOAT_TO_UBYTE(ref, ctx->Color.AlphaRef); - ALPHA_TEST(rgba[i][ACOMP], ;); - } - else if (span->array->ChanType == GL_UNSIGNED_SHORT) { - GLushort (*rgba)[4] = span->array->rgba16; - GLushort ref; - CLAMPED_FLOAT_TO_USHORT(ref, ctx->Color.AlphaRef); - ALPHA_TEST(rgba[i][ACOMP], ;); - } - else { - GLfloat (*rgba)[4] = span->array->attribs[FRAG_ATTRIB_COL]; - const GLfloat ref = ctx->Color.AlphaRef; - ALPHA_TEST(rgba[i][ACOMP], ;); - } - } - else { - /* Interpolate alpha values */ - ASSERT(span->interpMask & SPAN_RGBA); - if (span->array->ChanType == GL_UNSIGNED_BYTE) { - const GLfixed alphaStep = span->alphaStep; - GLfixed alpha = span->alpha; - GLubyte ref; - CLAMPED_FLOAT_TO_UBYTE(ref, ctx->Color.AlphaRef); - ALPHA_TEST(FixedToInt(alpha), alpha += alphaStep); - } - else if (span->array->ChanType == GL_UNSIGNED_SHORT) { - const GLfixed alphaStep = span->alphaStep; - GLfixed alpha = span->alpha; - GLushort ref; - CLAMPED_FLOAT_TO_USHORT(ref, ctx->Color.AlphaRef); - ALPHA_TEST(FixedToInt(alpha), alpha += alphaStep); - } - else { - const GLfloat alphaStep = FixedToFloat(span->alphaStep); - GLfloat alpha = FixedToFloat(span->alpha); - const GLfloat ref = ctx->Color.AlphaRef; - ALPHA_TEST(alpha, alpha += alphaStep); - } - } - - span->writeAll = GL_FALSE; - - /* XXX examine mask[] values? */ - return 1; -} diff --git a/dll/opengl/mesa/swrast/s_alpha.h b/dll/opengl/mesa/swrast/s_alpha.h deleted file mode 100644 index fca209a4467..00000000000 --- a/dll/opengl/mesa/swrast/s_alpha.h +++ /dev/null @@ -1,39 +0,0 @@ -/* - * Mesa 3-D graphics library - * Version: 4.1 - * - * Copyright (C) 1999-2002 Brian Paul All Rights Reserved. - * - * Permission is hereby granted, free of charge, to any person obtaining a - * copy of this software and associated documentation files (the "Software"), - * to deal in the Software without restriction, including without limitation - * the rights to use, copy, modify, merge, publish, distribute, sublicense, - * and/or sell copies of the Software, and to permit persons to whom the - * Software is furnished to do so, subject to the following conditions: - * - * The above copyright notice and this permission notice shall be included - * in all copies or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS - * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL - * BRIAN PAUL BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN - * AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN - * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. - */ - - -#ifndef S_ALPHA_H -#define S_ALPHA_H - - -#include "main/glheader.h" -#include "s_span.h" - -struct gl_context; - -extern GLint -_swrast_alpha_test( const struct gl_context *ctx, SWspan *span ); - - -#endif diff --git a/dll/opengl/mesa/swrast/s_bitmap.c b/dll/opengl/mesa/swrast/s_bitmap.c deleted file mode 100644 index 2cd6ae57e50..00000000000 --- a/dll/opengl/mesa/swrast/s_bitmap.c +++ /dev/null @@ -1,207 +0,0 @@ -/* - * Mesa 3-D graphics library - * Version: 7.1 - * - * Copyright (C) 1999-2008 Brian Paul All Rights Reserved. - * - * Permission is hereby granted, free of charge, to any person obtaining a - * copy of this software and associated documentation files (the "Software"), - * to deal in the Software without restriction, including without limitation - * the rights to use, copy, modify, merge, publish, distribute, sublicense, - * and/or sell copies of the Software, and to permit persons to whom the - * Software is furnished to do so, subject to the following conditions: - * - * The above copyright notice and this permission notice shall be included - * in all copies or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS - * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL - * BRIAN PAUL BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN - * AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN - * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. - */ - -/** - * \file swrast/s_bitmap.c - * \brief glBitmap rendering. - * \author Brian Paul - */ - -#include - -/** - * Render a bitmap. - * Called via ctx->Driver.Bitmap() - * All parameter error checking will have been done before this is called. - */ -void -_swrast_Bitmap( struct gl_context *ctx, GLint px, GLint py, - GLsizei width, GLsizei height, - const struct gl_pixelstore_attrib *unpack, - const GLubyte *bitmap ) -{ - GLint row, col; - GLuint count = 0; - SWspan span; - - ASSERT(ctx->RenderMode == GL_RENDER); - - if (!bitmap) - return; - - swrast_render_start(ctx); - - if (SWRAST_CONTEXT(ctx)->NewState) - _swrast_validate_derived( ctx ); - - INIT_SPAN(span, GL_BITMAP); - span.end = width; - span.arrayMask = SPAN_XY; - _swrast_span_default_attribs(ctx, &span); - - for (row = 0; row < height; row++) { - const GLubyte *src = (const GLubyte *) _mesa_image_address2d(unpack, - bitmap, width, height, GL_COLOR_INDEX, GL_BITMAP, row, 0); - - if (unpack->LsbFirst) { - /* Lsb first */ - GLubyte mask = 1U << (unpack->SkipPixels & 0x7); - for (col = 0; col < width; col++) { - if (*src & mask) { - span.array->x[count] = px + col; - span.array->y[count] = py + row; - count++; - } - if (mask == 128U) { - src++; - mask = 1U; - } - else { - mask = mask << 1; - } - } - - /* get ready for next row */ - if (mask != 1) - src++; - } - else { - /* Msb first */ - GLubyte mask = 128U >> (unpack->SkipPixels & 0x7); - for (col = 0; col < width; col++) { - if (*src & mask) { - span.array->x[count] = px + col; - span.array->y[count] = py + row; - count++; - } - if (mask == 1U) { - src++; - mask = 128U; - } - else { - mask = mask >> 1; - } - } - - /* get ready for next row */ - if (mask != 128) - src++; - } - - if (count + width >= MAX_WIDTH || row + 1 == height) { - /* flush the span */ - span.end = count; - _swrast_write_rgba_span(ctx, &span); - span.end = 0; - count = 0; - } - } - - swrast_render_finish(ctx); -} - - -#if 0 -/* - * XXX this is another way to implement Bitmap. Use horizontal runs of - * fragments, initializing the mask array to indicate which fragments to - * draw or skip. - */ -void -_swrast_Bitmap( struct gl_context *ctx, GLint px, GLint py, - GLsizei width, GLsizei height, - const struct gl_pixelstore_attrib *unpack, - const GLubyte *bitmap ) -{ - SWcontext *swrast = SWRAST_CONTEXT(ctx); - GLint row, col; - SWspan span; - - ASSERT(ctx->RenderMode == GL_RENDER); - ASSERT(bitmap); - - swrast_render_start(ctx); - - if (SWRAST_CONTEXT(ctx)->NewState) - _swrast_validate_derived( ctx ); - - INIT_SPAN(span, GL_BITMAP); - span.end = width; - span.arrayMask = SPAN_MASK; - _swrast_span_default_attribs(ctx, &span); - - /*span.arrayMask |= SPAN_MASK;*/ /* we'll init span.mask[] */ - span.x = px; - span.y = py; - /*span.end = width;*/ - - for (row=0; rowLsbFirst) { - /* Lsb first */ - GLubyte mask = 1U << (unpack->SkipPixels & 0x7); - for (col=0; colmask[col] = (*src & mask) ? GL_TRUE : GL_FALSE; - if (mask == 128U) { - src++; - mask = 1U; - } - else { - mask = mask << 1; - } - } - - _swrast_write_rgba_span(ctx, &span); - - /* get ready for next row */ - if (mask != 1) - src++; - } - else { - /* Msb first */ - GLubyte mask = 128U >> (unpack->SkipPixels & 0x7); - for (col=0; colmask[col] = (*src & mask) ? GL_TRUE : GL_FALSE; - if (mask == 1U) { - src++; - mask = 128U; - } - else { - mask = mask >> 1; - } - } - - _swrast_write_rgba_span(ctx, &span); - - /* get ready for next row */ - if (mask != 128) - src++; - } - } - - swrast_render_finish(ctx); -} -#endif diff --git a/dll/opengl/mesa/swrast/s_blend.c b/dll/opengl/mesa/swrast/s_blend.c deleted file mode 100644 index fa73e28e568..00000000000 --- a/dll/opengl/mesa/swrast/s_blend.c +++ /dev/null @@ -1,673 +0,0 @@ -/* - * Mesa 3-D graphics library - * Version: 7.1 - * - * Copyright (C) 1999-2008 Brian Paul All Rights Reserved. - * - * Permission is hereby granted, free of charge, to any person obtaining a - * copy of this software and associated documentation files (the "Software"), - * to deal in the Software without restriction, including without limitation - * the rights to use, copy, modify, merge, publish, distribute, sublicense, - * and/or sell copies of the Software, and to permit persons to whom the - * Software is furnished to do so, subject to the following conditions: - * - * The above copyright notice and this permission notice shall be included - * in all copies or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS - * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL - * BRIAN PAUL BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN - * AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN - * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. - */ - -/** - * \file swrast/s_blend.c - * \brief software blending. - * \author Brian Paul - * - * Only a few blend modes have been optimized (min, max, transparency, add) - * more optimized cases can easily be added if needed. - * Celestia uses glBlendFunc(GL_SRC_ALPHA, GL_ONE), for example. - */ - -#include - -#if defined(USE_MMX_ASM) -#include "x86/mmx.h" -#include "x86/common_x86_asm.h" -#define _BLENDAPI _ASMAPI -#else -#define _BLENDAPI -#endif - -/** - * Integer divide by 255 - * Declare "int divtemp" before using. - * This satisfies Glean and should be reasonably fast. - * Contributed by Nathan Hand. - */ -#define DIV255(X) (divtemp = (X), ((divtemp << 8) + divtemp + 256) >> 16) - - - -/** - * Special case for glBlendFunc(GL_ZERO, GL_ONE). - * No-op means the framebuffer values remain unchanged. - * Any chanType ok. - */ -static void _BLENDAPI -blend_noop(struct gl_context *ctx, GLuint n, const GLubyte mask[], - GLvoid *src, const GLvoid *dst, GLenum chanType) -{ - GLint bytes; - - ASSERT(ctx->Color.EquationRGB == GL_FUNC_ADD); - ASSERT(ctx->Color.EquationA == GL_FUNC_ADD); - ASSERT(ctx->Color.SrcRGB == GL_ZERO); - ASSERT(ctx->Color.DstRGB == GL_ONE); - (void) ctx; - - /* just memcpy */ - if (chanType == GL_UNSIGNED_BYTE) - bytes = 4 * n * sizeof(GLubyte); - else if (chanType == GL_UNSIGNED_SHORT) - bytes = 4 * n * sizeof(GLushort); - else - bytes = 4 * n * sizeof(GLfloat); - - memcpy(src, dst, bytes); -} - - -/** - * Special case for glBlendFunc(GL_ONE, GL_ZERO) - * Any chanType ok. - */ -static void _BLENDAPI -blend_replace(struct gl_context *ctx, GLuint n, const GLubyte mask[], - GLvoid *src, const GLvoid *dst, GLenum chanType) -{ - ASSERT(ctx->Color.EquationRGB == GL_FUNC_ADD); - ASSERT(ctx->Color.EquationA == GL_FUNC_ADD); - ASSERT(ctx->Color.SrcRGB == GL_ONE); - ASSERT(ctx->Color.DstRGB == GL_ZERO); - (void) ctx; - (void) n; - (void) mask; - (void) src; - (void) dst; -} - - -/** - * Common transparency blending mode: - * glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA). - */ -static void _BLENDAPI -blend_transparency_ubyte(struct gl_context *ctx, GLuint n, const GLubyte mask[], - GLvoid *src, const GLvoid *dst, GLenum chanType) -{ - GLubyte (*rgba)[4] = (GLubyte (*)[4]) src; - const GLubyte (*dest)[4] = (const GLubyte (*)[4]) dst; - GLuint i; - - ASSERT(ctx->Color.EquationRGB == GL_FUNC_ADD); - ASSERT(ctx->Color.EquationA == GL_FUNC_ADD); - ASSERT(ctx->Color.SrcRGB == GL_SRC_ALPHA); - ASSERT(ctx->Color.SrcA == GL_SRC_ALPHA); - ASSERT(ctx->Color.DstRGB == GL_ONE_MINUS_SRC_ALPHA); - ASSERT(ctx->Color.DstA == GL_ONE_MINUS_SRC_ALPHA); - ASSERT(chanType == GL_UNSIGNED_BYTE); - - (void) ctx; - - for (i = 0; i < n; i++) { - if (mask[i]) { - const GLint t = rgba[i][ACOMP]; /* t is in [0, 255] */ - if (t == 0) { - /* 0% alpha */ - COPY_4UBV(rgba[i], dest[i]); - } - else if (t != 255) { - GLint divtemp; - const GLint r = DIV255((rgba[i][RCOMP] - dest[i][RCOMP]) * t) + dest[i][RCOMP]; - const GLint g = DIV255((rgba[i][GCOMP] - dest[i][GCOMP]) * t) + dest[i][GCOMP]; - const GLint b = DIV255((rgba[i][BCOMP] - dest[i][BCOMP]) * t) + dest[i][BCOMP]; - const GLint a = DIV255((rgba[i][ACOMP] - dest[i][ACOMP]) * t) + dest[i][ACOMP]; - ASSERT(r <= 255); - ASSERT(g <= 255); - ASSERT(b <= 255); - ASSERT(a <= 255); - rgba[i][RCOMP] = (GLubyte) r; - rgba[i][GCOMP] = (GLubyte) g; - rgba[i][BCOMP] = (GLubyte) b; - rgba[i][ACOMP] = (GLubyte) a; - } - } - } -} - - -static void _BLENDAPI -blend_transparency_ushort(struct gl_context *ctx, GLuint n, const GLubyte mask[], - GLvoid *src, const GLvoid *dst, GLenum chanType) -{ - GLushort (*rgba)[4] = (GLushort (*)[4]) src; - const GLushort (*dest)[4] = (const GLushort (*)[4]) dst; - GLuint i; - - ASSERT(ctx->Color.EquationRGB == GL_FUNC_ADD); - ASSERT(ctx->Color.EquationA == GL_FUNC_ADD); - ASSERT(ctx->Color.SrcRGB == GL_SRC_ALPHA); - ASSERT(ctx->Color.SrcA == GL_SRC_ALPHA); - ASSERT(ctx->Color.DstRGB == GL_ONE_MINUS_SRC_ALPHA); - ASSERT(ctx->Color.DstA == GL_ONE_MINUS_SRC_ALPHA); - ASSERT(chanType == GL_UNSIGNED_SHORT); - - (void) ctx; - - for (i = 0; i < n; i++) { - if (mask[i]) { - const GLint t = rgba[i][ACOMP]; - if (t == 0) { - /* 0% alpha */ - COPY_4V(rgba[i], dest[i]); - } - else if (t != 65535) { - const GLfloat tt = (GLfloat) t / 65535.0F; - GLushort r = (GLushort) ((rgba[i][RCOMP] - dest[i][RCOMP]) * tt + dest[i][RCOMP]); - GLushort g = (GLushort) ((rgba[i][GCOMP] - dest[i][GCOMP]) * tt + dest[i][GCOMP]); - GLushort b = (GLushort) ((rgba[i][BCOMP] - dest[i][BCOMP]) * tt + dest[i][BCOMP]); - GLushort a = (GLushort) ((rgba[i][ACOMP] - dest[i][ACOMP]) * tt + dest[i][ACOMP]); - ASSIGN_4V(rgba[i], r, g, b, a); - } - } - } -} - - -static void _BLENDAPI -blend_transparency_float(struct gl_context *ctx, GLuint n, const GLubyte mask[], - GLvoid *src, const GLvoid *dst, GLenum chanType) -{ - GLfloat (*rgba)[4] = (GLfloat (*)[4]) src; - const GLfloat (*dest)[4] = (const GLfloat (*)[4]) dst; - GLuint i; - - ASSERT(ctx->Color.EquationRGB == GL_FUNC_ADD); - ASSERT(ctx->Color.EquationA == GL_FUNC_ADD); - ASSERT(ctx->Color.SrcRGB == GL_SRC_ALPHA); - ASSERT(ctx->Color.SrcA == GL_SRC_ALPHA); - ASSERT(ctx->Color.DstRGB == GL_ONE_MINUS_SRC_ALPHA); - ASSERT(ctx->Color.DstA == GL_ONE_MINUS_SRC_ALPHA); - ASSERT(chanType == GL_FLOAT); - - (void) ctx; - - for (i = 0; i < n; i++) { - if (mask[i]) { - const GLfloat t = rgba[i][ACOMP]; /* t in [0, 1] */ - if (t == 0.0F) { - /* 0% alpha */ - COPY_4V(rgba[i], dest[i]); - } - else if (t != 1.0F) { - GLfloat r = (rgba[i][RCOMP] - dest[i][RCOMP]) * t + dest[i][RCOMP]; - GLfloat g = (rgba[i][GCOMP] - dest[i][GCOMP]) * t + dest[i][GCOMP]; - GLfloat b = (rgba[i][BCOMP] - dest[i][BCOMP]) * t + dest[i][BCOMP]; - GLfloat a = (rgba[i][ACOMP] - dest[i][ACOMP]) * t + dest[i][ACOMP]; - ASSIGN_4V(rgba[i], r, g, b, a); - } - } - } -} - - - -/** - * Add src and dest: glBlendFunc(GL_ONE, GL_ONE). - * Any chanType ok. - */ -static void _BLENDAPI -blend_add(struct gl_context *ctx, GLuint n, const GLubyte mask[], - GLvoid *src, const GLvoid *dst, GLenum chanType) -{ - GLuint i; - - ASSERT(ctx->Color.EquationRGB == GL_FUNC_ADD); - ASSERT(ctx->Color.EquationA == GL_FUNC_ADD); - ASSERT(ctx->Color.SrcRGB == GL_ONE); - ASSERT(ctx->Color.DstRGB == GL_ONE); - (void) ctx; - - if (chanType == GL_UNSIGNED_BYTE) { - GLubyte (*rgba)[4] = (GLubyte (*)[4]) src; - const GLubyte (*dest)[4] = (const GLubyte (*)[4]) dst; - for (i=0;i> 16; - rgba[i][GCOMP] = (rgba[i][GCOMP] * dest[i][GCOMP] + 65535) >> 16; - rgba[i][BCOMP] = (rgba[i][BCOMP] * dest[i][BCOMP] + 65535) >> 16; - rgba[i][ACOMP] = (rgba[i][ACOMP] * dest[i][ACOMP] + 65535) >> 16; - } - } - } - else { - GLfloat (*rgba)[4] = (GLfloat (*)[4]) src; - const GLfloat (*dest)[4] = (const GLfloat (*)[4]) dst; - ASSERT(chanType == GL_FLOAT); - for (i=0;iColor.SrcFactor) { - case GL_ZERO: - sR = sG = sB = sA = 0.0F; - break; - case GL_ONE: - sR = sG = sB = sA = 1.0F; - break; - case GL_DST_COLOR: - sR = Rd; - sG = Gd; - sB = Bd; - sA = Ad; - break; - case GL_ONE_MINUS_DST_COLOR: - sR = 1.0F - Rd; - sG = 1.0F - Gd; - sB = 1.0F - Bd; - sA = 1.0f - Ad; - break; - case GL_SRC_ALPHA: - sR = sG = sB = sA = As; - break; - case GL_ONE_MINUS_SRC_ALPHA: - sR = sG = sB = sA = 1.0F - As; - break; - case GL_DST_ALPHA: - sR = sG = sB = sA = Ad; - break; - case GL_ONE_MINUS_DST_ALPHA: - sR = sG = sB = sA = 1.0F - Ad; - break; - case GL_SRC_ALPHA_SATURATE: - if (As < 1.0F - Ad) { - sR = sG = sB = sA = As; - } - else { - sR = sG = sB = sA = 1.0F - Ad; - } - break; - case GL_SRC_COLOR: - sR = Rs; - sG = Gs; - sB = Bs; - sA = As; - break; - case GL_ONE_MINUS_SRC_COLOR: - sR = 1.0F - Rs; - sG = 1.0F - Gs; - sB = 1.0F - Bs; - sA = 1.0F - As; - break; - default: - /* this should never happen */ - _mesa_problem(ctx, "Bad blend source RGB factor in blend_general_float"); - return; - } - - /* Dest factor */ - switch (ctx->Color.DstFactor) { - case GL_ZERO: - dR = dG = dB = dA = 0.0F; - break; - case GL_ONE: - dR = dG = dB = dA = 1.0F; - break; - case GL_SRC_COLOR: - dR = Rs; - dG = Gs; - dB = Bs; - dA = As; - break; - case GL_ONE_MINUS_SRC_COLOR: - dR = 1.0F - Rs; - dG = 1.0F - Gs; - dB = 1.0F - Bs; - dA = 1.0F - As; - break; - case GL_SRC_ALPHA: - dR = dG = dB = dA = As; - break; - case GL_ONE_MINUS_SRC_ALPHA: - dR = dG = dB = dA = 1.0F - As; - break; - case GL_DST_ALPHA: - dR = dG = dB = dA = Ad; - break; - case GL_ONE_MINUS_DST_ALPHA: - dR = dG = dB = dA = 1.0F - Ad; - break; - case GL_DST_COLOR: - dR = Rd; - dG = Gd; - dB = Bd; - dA = Ad; - break; - case GL_ONE_MINUS_DST_COLOR: - dR = 1.0F - Rd; - dG = 1.0F - Gd; - dB = 1.0F - Bd; - dA = 1.0F - Ad; - break; - default: - /* this should never happen */ - dR = dG = dB = dA = 0.0F; - _mesa_problem(ctx, "Bad blend dest factor in blend_general_float"); - return; - } - - /* compute the blended RGBA */ - r = Rs * sR + Rd * dR; - g = Gs * sG + Gd * dG; - b = Bs * sB + Bd * dB; - a = As * sA + Ad * dA; - - /* final clamping */ -#if 0 - rgba[i][RCOMP] = MAX2( r, 0.0F ); - rgba[i][GCOMP] = MAX2( g, 0.0F ); - rgba[i][BCOMP] = MAX2( b, 0.0F ); - rgba[i][ACOMP] = CLAMP( a, 0.0F, 1.0F ); -#else - ASSIGN_4V(rgba[i], r, g, b, a); -#endif - } - } -} - - -/** - * Do any blending operation, any chanType. - */ -static void -blend_general(struct gl_context *ctx, GLuint n, const GLubyte mask[], - void *src, const void *dst, GLenum chanType) -{ - GLfloat (*rgbaF)[4], (*destF)[4]; - - rgbaF = (GLfloat (*)[4]) malloc(4 * n * sizeof(GLfloat)); - destF = (GLfloat (*)[4]) malloc(4 * n * sizeof(GLfloat)); - if (!rgbaF || !destF) { - free(rgbaF); - free(destF); - _mesa_error(ctx, GL_OUT_OF_MEMORY, "blending"); - return; - } - - if (chanType == GL_UNSIGNED_BYTE) { - GLubyte (*rgba)[4] = (GLubyte (*)[4]) src; - const GLubyte (*dest)[4] = (const GLubyte (*)[4]) dst; - GLuint i; - /* convert ubytes to floats */ - for (i = 0; i < n; i++) { - if (mask[i]) { - rgbaF[i][RCOMP] = UBYTE_TO_FLOAT(rgba[i][RCOMP]); - rgbaF[i][GCOMP] = UBYTE_TO_FLOAT(rgba[i][GCOMP]); - rgbaF[i][BCOMP] = UBYTE_TO_FLOAT(rgba[i][BCOMP]); - rgbaF[i][ACOMP] = UBYTE_TO_FLOAT(rgba[i][ACOMP]); - destF[i][RCOMP] = UBYTE_TO_FLOAT(dest[i][RCOMP]); - destF[i][GCOMP] = UBYTE_TO_FLOAT(dest[i][GCOMP]); - destF[i][BCOMP] = UBYTE_TO_FLOAT(dest[i][BCOMP]); - destF[i][ACOMP] = UBYTE_TO_FLOAT(dest[i][ACOMP]); - } - } - /* do blend */ - blend_general_float(ctx, n, mask, rgbaF, destF, chanType); - /* convert back to ubytes */ - for (i = 0; i < n; i++) { - if (mask[i]) - _mesa_unclamped_float_rgba_to_ubyte(rgba[i], rgbaF[i]); - } - } - else if (chanType == GL_UNSIGNED_SHORT) { - GLushort (*rgba)[4] = (GLushort (*)[4]) src; - const GLushort (*dest)[4] = (const GLushort (*)[4]) dst; - GLuint i; - /* convert ushorts to floats */ - for (i = 0; i < n; i++) { - if (mask[i]) { - rgbaF[i][RCOMP] = USHORT_TO_FLOAT(rgba[i][RCOMP]); - rgbaF[i][GCOMP] = USHORT_TO_FLOAT(rgba[i][GCOMP]); - rgbaF[i][BCOMP] = USHORT_TO_FLOAT(rgba[i][BCOMP]); - rgbaF[i][ACOMP] = USHORT_TO_FLOAT(rgba[i][ACOMP]); - destF[i][RCOMP] = USHORT_TO_FLOAT(dest[i][RCOMP]); - destF[i][GCOMP] = USHORT_TO_FLOAT(dest[i][GCOMP]); - destF[i][BCOMP] = USHORT_TO_FLOAT(dest[i][BCOMP]); - destF[i][ACOMP] = USHORT_TO_FLOAT(dest[i][ACOMP]); - } - } - /* do blend */ - blend_general_float(ctx, n, mask, rgbaF, destF, chanType); - /* convert back to ushorts */ - for (i = 0; i < n; i++) { - if (mask[i]) { - UNCLAMPED_FLOAT_TO_USHORT(rgba[i][RCOMP], rgbaF[i][RCOMP]); - UNCLAMPED_FLOAT_TO_USHORT(rgba[i][GCOMP], rgbaF[i][GCOMP]); - UNCLAMPED_FLOAT_TO_USHORT(rgba[i][BCOMP], rgbaF[i][BCOMP]); - UNCLAMPED_FLOAT_TO_USHORT(rgba[i][ACOMP], rgbaF[i][ACOMP]); - } - } - } - else { - blend_general_float(ctx, n, mask, (GLfloat (*)[4]) src, - (GLfloat (*)[4]) dst, chanType); - } - - free(rgbaF); - free(destF); -} - - - -/** - * Analyze current blending parameters to pick fastest blending function. - * Result: the ctx->Color.BlendFunc pointer is updated. - */ -void -_swrast_choose_blend_func(struct gl_context *ctx, GLenum chanType) -{ - SWcontext *swrast = SWRAST_CONTEXT(ctx); - const GLenum srcFactor = ctx->Color.SrcFactor; - const GLenum dstFactor = ctx->Color.DstFactor; - - if (srcFactor == GL_SRC_ALPHA && dstFactor == GL_ONE_MINUS_SRC_ALPHA) { -#if defined(USE_MMX_ASM) - if (cpu_has_mmx && chanType == GL_UNSIGNED_BYTE) { - swrast->BlendFunc = _mesa_mmx_blend_transparency; - } - else -#endif - { - if (chanType == GL_UNSIGNED_BYTE) - swrast->BlendFunc = blend_transparency_ubyte; - else if (chanType == GL_UNSIGNED_SHORT) - swrast->BlendFunc = blend_transparency_ushort; - else - swrast->BlendFunc = blend_transparency_float; - } - } - else if (srcFactor == GL_ONE && dstFactor == GL_ONE) { -#if defined(USE_MMX_ASM) - if (cpu_has_mmx && chanType == GL_UNSIGNED_BYTE) { - swrast->BlendFunc = _mesa_mmx_blend_add; - } - else -#endif - swrast->BlendFunc = blend_add; - } - else if ((srcFactor == GL_ZERO && dstFactor == GL_SRC_COLOR) - || (srcFactor == GL_DST_COLOR && dstFactor == GL_ZERO)) { -#if defined(USE_MMX_ASM) - if (cpu_has_mmx && chanType == GL_UNSIGNED_BYTE) { - swrast->BlendFunc = _mesa_mmx_blend_modulate; - } - else -#endif - swrast->BlendFunc = blend_modulate; - } - else if (srcFactor == GL_ZERO && dstFactor == GL_ONE) { - swrast->BlendFunc = blend_noop; - } - else if (srcFactor == GL_ONE && dstFactor == GL_ZERO) { - swrast->BlendFunc = blend_replace; - } - else { - swrast->BlendFunc = blend_general; - } -} - - - -/** - * Apply the blending operator to a span of pixels. - * We can handle horizontal runs of pixels (spans) or arrays of x/y - * pixel coordinates. - */ -void -_swrast_blend_span(struct gl_context *ctx, struct gl_renderbuffer *rb, SWspan *span) -{ - SWcontext *swrast = SWRAST_CONTEXT(ctx); - void *rbPixels; - - ASSERT(span->end <= MAX_WIDTH); - ASSERT(span->arrayMask & SPAN_RGBA); - ASSERT(!ctx->Color.ColorLogicOpEnabled); - - rbPixels = _swrast_get_dest_rgba(ctx, rb, span); - - swrast->BlendFunc(ctx, span->end, span->array->mask, - span->array->rgba, rbPixels, span->array->ChanType); -} diff --git a/dll/opengl/mesa/swrast/s_blend.h b/dll/opengl/mesa/swrast/s_blend.h deleted file mode 100644 index 69cd89e7ac4..00000000000 --- a/dll/opengl/mesa/swrast/s_blend.h +++ /dev/null @@ -1,45 +0,0 @@ -/* - * Mesa 3-D graphics library - * Version: 6.5.2 - * - * Copyright (C) 1999-2006 Brian Paul All Rights Reserved. - * - * Permission is hereby granted, free of charge, to any person obtaining a - * copy of this software and associated documentation files (the "Software"), - * to deal in the Software without restriction, including without limitation - * the rights to use, copy, modify, merge, publish, distribute, sublicense, - * and/or sell copies of the Software, and to permit persons to whom the - * Software is furnished to do so, subject to the following conditions: - * - * The above copyright notice and this permission notice shall be included - * in all copies or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS - * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL - * BRIAN PAUL BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN - * AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN - * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. - */ - - -#ifndef S_BLEND_H -#define S_BLEND_H - - -#include "main/glheader.h" -#include "s_span.h" - -struct gl_context; -struct gl_renderbuffer; - - -extern void -_swrast_blend_span(struct gl_context *ctx, struct gl_renderbuffer *rb, SWspan *span); - - -extern void -_swrast_choose_blend_func(struct gl_context *ctx, GLenum chanType); - - -#endif diff --git a/dll/opengl/mesa/swrast/s_chan.h b/dll/opengl/mesa/swrast/s_chan.h deleted file mode 100644 index 94ac8b65be1..00000000000 --- a/dll/opengl/mesa/swrast/s_chan.h +++ /dev/null @@ -1,119 +0,0 @@ -/* - * Mesa 3-D graphics library - * - * Copyright (C) 2011 VMware, Inc. All Rights Reserved. - * - * Permission is hereby granted, free of charge, to any person obtaining a - * copy of this software and associated documentation files (the "Software"), - * to deal in the Software without restriction, including without limitation - * the rights to use, copy, modify, merge, publish, distribute, sublicense, - * and/or sell copies of the Software, and to permit persons to whom the - * Software is furnished to do so, subject to the following conditions: - * - * The above copyright notice and this permission notice shall be included - * in all copies or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS - * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL - * THE AUTHORS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN - * AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN - * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. - */ - -/** - * Types, macros, etc for the GLchan datatype. - * The swrast module is kind of hard-coded for 8bpp color channels but - * may be recompiled to use 16- or 32-bit color channels. But that - * feature is seldom used and is likely broken in various ways. - */ - -#ifndef U_CHAN_H -#define U_CHAN_H - - -#include "main/config.h" - - -/** - * Color channel data type. - */ -#if CHAN_BITS == 8 - typedef GLubyte GLchan; -#define CHAN_MAX 255 -#define CHAN_MAXF 255.0F -#define CHAN_TYPE GL_UNSIGNED_BYTE -#elif CHAN_BITS == 16 - typedef GLushort GLchan; -#define CHAN_MAX 65535 -#define CHAN_MAXF 65535.0F -#define CHAN_TYPE GL_UNSIGNED_SHORT -#elif CHAN_BITS == 32 - typedef GLfloat GLchan; -#define CHAN_MAX 1.0 -#define CHAN_MAXF 1.0F -#define CHAN_TYPE GL_FLOAT -#else -#error "illegal number of color channel bits" -#endif - - -#if CHAN_BITS == 8 - -#define CHAN_TO_UBYTE(c) (c) -#define CHAN_TO_USHORT(c) (((c) << 8) | (c)) -#define CHAN_TO_SHORT(c) (((c) << 7) | ((c) >> 1)) -#define CHAN_TO_FLOAT(c) UBYTE_TO_FLOAT(c) - -#define CLAMPED_FLOAT_TO_CHAN(c, f) CLAMPED_FLOAT_TO_UBYTE(c, f) -#define UNCLAMPED_FLOAT_TO_CHAN(c, f) UNCLAMPED_FLOAT_TO_UBYTE(c, f) - -#define COPY_CHAN4(DST, SRC) COPY_4UBV(DST, SRC) - -#elif CHAN_BITS == 16 - -#define CHAN_TO_UBYTE(c) ((c) >> 8) -#define CHAN_TO_USHORT(c) (c) -#define CHAN_TO_SHORT(c) ((c) >> 1) -#define CHAN_TO_FLOAT(c) ((GLfloat) ((c) * (1.0 / CHAN_MAXF))) - -#define CLAMPED_FLOAT_TO_CHAN(c, f) CLAMPED_FLOAT_TO_USHORT(c, f) -#define UNCLAMPED_FLOAT_TO_CHAN(c, f) UNCLAMPED_FLOAT_TO_USHORT(c, f) - -#define COPY_CHAN4(DST, SRC) COPY_4V(DST, SRC) - -#elif CHAN_BITS == 32 - -#define CHAN_TO_UBYTE(c) FLOAT_TO_UBYTE(c) -#define CHAN_TO_USHORT(c) ((GLushort) (CLAMP((c), 0.0f, 1.0f) * 65535.0)) -#define CHAN_TO_SHORT(c) ((GLshort) (CLAMP((c), 0.0f, 1.0f) * 32767.0)) -#define CHAN_TO_FLOAT(c) (c) - -#define CLAMPED_FLOAT_TO_CHAN(c, f) c = (f) -#define UNCLAMPED_FLOAT_TO_CHAN(c, f) c = (f) - -#define COPY_CHAN4(DST, SRC) COPY_4V(DST, SRC) - -#else - -#error unexpected CHAN_BITS size - -#endif - - -/** - * Convert 4 floats to GLchan values. - * \param dst pointer to destination GLchan[4] array. - * \param f pointer to source GLfloat[4] array. - */ -#define UNCLAMPED_FLOAT_TO_RGBA_CHAN(dst, f) \ -do { \ - UNCLAMPED_FLOAT_TO_CHAN((dst)[0], (f)[0]); \ - UNCLAMPED_FLOAT_TO_CHAN((dst)[1], (f)[1]); \ - UNCLAMPED_FLOAT_TO_CHAN((dst)[2], (f)[2]); \ - UNCLAMPED_FLOAT_TO_CHAN((dst)[3], (f)[3]); \ -} while (0) - - - -#endif /* U_CHAN_H */ diff --git a/dll/opengl/mesa/swrast/s_clear.c b/dll/opengl/mesa/swrast/s_clear.c deleted file mode 100644 index 50addd79bd3..00000000000 --- a/dll/opengl/mesa/swrast/s_clear.c +++ /dev/null @@ -1,216 +0,0 @@ -/* - * Mesa 3-D graphics library - * Version: 7.1 - * - * Copyright (C) 1999-2008 Brian Paul All Rights Reserved. - * - * Permission is hereby granted, free of charge, to any person obtaining a - * copy of this software and associated documentation files (the "Software"), - * to deal in the Software without restriction, including without limitation - * the rights to use, copy, modify, merge, publish, distribute, sublicense, - * and/or sell copies of the Software, and to permit persons to whom the - * Software is furnished to do so, subject to the following conditions: - * - * The above copyright notice and this permission notice shall be included - * in all copies or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS - * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL - * BRIAN PAUL BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN - * AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN - * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. - */ - -#include - -#include
- -/** - * Clear an rgba color buffer with masking if needed. - */ -static void -clear_rgba_buffer(struct gl_context *ctx, struct gl_renderbuffer *rb, - const GLubyte colorMask[4]) -{ - const GLint x = ctx->DrawBuffer->_Xmin; - const GLint y = ctx->DrawBuffer->_Ymin; - const GLint height = ctx->DrawBuffer->_Ymax - ctx->DrawBuffer->_Ymin; - const GLint width = ctx->DrawBuffer->_Xmax - ctx->DrawBuffer->_Xmin; - const GLuint pixelSize = _mesa_get_format_bytes(rb->Format); - const GLboolean doMasking = (colorMask[0] == 0 || - colorMask[1] == 0 || - colorMask[2] == 0 || - colorMask[3] == 0); - const GLfloat (*clearColor)[4] = - (const GLfloat (*)[4]) ctx->Color.ClearColor.f; - GLbitfield mapMode = GL_MAP_WRITE_BIT; - GLubyte *map; - GLint rowStride; - GLint i, j; - - if (doMasking) { - /* we'll need to read buffer values too */ - mapMode |= GL_MAP_READ_BIT; - } - - /* map dest buffer */ - ctx->Driver.MapRenderbuffer(ctx, rb, x, y, width, height, - mapMode, &map, &rowStride); - if (!map) { - _mesa_error(ctx, GL_OUT_OF_MEMORY, "glClear(color)"); - return; - } - - /* for 1, 2, 4-byte clearing */ -#define SIMPLE_TYPE_CLEAR(TYPE) \ - do { \ - TYPE pixel, pixelMask; \ - _mesa_pack_float_rgba_row(rb->Format, 1, clearColor, &pixel); \ - if (doMasking) { \ - _mesa_pack_colormask(rb->Format, colorMask, &pixelMask); \ - pixel &= pixelMask; \ - pixelMask = ~pixelMask; \ - } \ - for (i = 0; i < height; i++) { \ - TYPE *row = (TYPE *) map; \ - if (doMasking) { \ - for (j = 0; j < width; j++) { \ - row[j] = (row[j] & pixelMask) | pixel; \ - } \ - } \ - else { \ - for (j = 0; j < width; j++) { \ - row[j] = pixel; \ - } \ - } \ - map += rowStride; \ - } \ - } while (0) - - - /* for 3, 6, 8, 12, 16-byte clearing */ -#define MULTI_WORD_CLEAR(TYPE, N) \ - do { \ - TYPE pixel[N], pixelMask[N]; \ - GLuint k; \ - _mesa_pack_float_rgba_row(rb->Format, 1, clearColor, pixel); \ - if (doMasking) { \ - _mesa_pack_colormask(rb->Format, colorMask, pixelMask); \ - for (k = 0; k < N; k++) { \ - pixel[k] &= pixelMask[k]; \ - pixelMask[k] = ~pixelMask[k]; \ - } \ - } \ - for (i = 0; i < height; i++) { \ - TYPE *row = (TYPE *) map; \ - if (doMasking) { \ - for (j = 0; j < width; j++) { \ - for (k = 0; k < N; k++) { \ - row[j * N + k] = \ - (row[j * N + k] & pixelMask[k]) | pixel[k]; \ - } \ - } \ - } \ - else { \ - for (j = 0; j < width; j++) { \ - for (k = 0; k < N; k++) { \ - row[j * N + k] = pixel[k]; \ - } \ - } \ - } \ - map += rowStride; \ - } \ - } while(0) - - switch (pixelSize) { - case 1: - SIMPLE_TYPE_CLEAR(GLubyte); - break; - case 2: - SIMPLE_TYPE_CLEAR(GLushort); - break; - case 3: - MULTI_WORD_CLEAR(GLubyte, 3); - break; - case 4: - SIMPLE_TYPE_CLEAR(GLuint); - break; - case 6: - MULTI_WORD_CLEAR(GLushort, 3); - break; - case 8: - MULTI_WORD_CLEAR(GLuint, 2); - break; - case 12: - MULTI_WORD_CLEAR(GLuint, 3); - break; - case 16: - MULTI_WORD_CLEAR(GLuint, 4); - break; - default: - _mesa_problem(ctx, "bad pixel size in clear_rgba_buffer()"); - } - - /* unmap buffer */ - ctx->Driver.UnmapRenderbuffer(ctx, rb); -} - - -/** - * Clear the front/back/left/right/aux color buffers. - * This function is usually only called if the device driver can't - * clear its own color buffers for some reason (such as with masking). - */ -static void -clear_color_buffers(struct gl_context *ctx) -{ - struct gl_renderbuffer *rb = ctx->DrawBuffer->_ColorDrawBuffer; - - clear_rgba_buffer(ctx, rb, ctx->Color.ColorMask); -} - - -/** - * Called via the device driver's ctx->Driver.Clear() function if the - * device driver can't clear one or more of the buffers itself. - * \param buffers bitfield of BUFFER_BIT_* values indicating which - * renderbuffers are to be cleared. - * \param all if GL_TRUE, clear whole buffer, else clear specified region. - */ -void -_swrast_Clear(struct gl_context *ctx, GLbitfield buffers) -{ -#ifdef DEBUG_FOO - { - const GLbitfield legalBits = - BUFFER_BIT_FRONT_LEFT | - BUFFER_BIT_FRONT_RIGHT | - BUFFER_BIT_BACK_LEFT | - BUFFER_BIT_BACK_RIGHT | - BUFFER_BIT_DEPTH | - BUFFER_BIT_STENCIL | - BUFFER_BIT_ACCUM | - BUFFER_BIT_AUX0; - assert((buffers & (~legalBits)) == 0); - } -#endif - - if (SWRAST_CONTEXT(ctx)->NewState) - _swrast_validate_derived(ctx); - - if (buffers & BUFFER_BITS_COLOR) { - clear_color_buffers(ctx); - } - - if (buffers & BUFFER_BIT_ACCUM) { - _mesa_clear_accum_buffer(ctx); - } - - if (buffers & BUFFER_BIT_DEPTH) { - _swrast_clear_depth_buffer(ctx); - } - if (buffers & BUFFER_BIT_STENCIL) { - _swrast_clear_stencil_buffer(ctx); - } -} diff --git a/dll/opengl/mesa/swrast/s_context.c b/dll/opengl/mesa/swrast/s_context.c deleted file mode 100644 index 179014b6ca9..00000000000 --- a/dll/opengl/mesa/swrast/s_context.c +++ /dev/null @@ -1,735 +0,0 @@ -/* - * Mesa 3-D graphics library - * Version: 7.1 - * - * Copyright (C) 1999-2008 Brian Paul All Rights Reserved. - * - * Permission is hereby granted, free of charge, to any person obtaining a - * copy of this software and associated documentation files (the "Software"), - * to deal in the Software without restriction, including without limitation - * the rights to use, copy, modify, merge, publish, distribute, sublicense, - * and/or sell copies of the Software, and to permit persons to whom the - * Software is furnished to do so, subject to the following conditions: - * - * The above copyright notice and this permission notice shall be included - * in all copies or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS - * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL - * BRIAN PAUL BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN - * AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN - * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. - * - * Authors: - * Keith Whitwell - * Brian Paul - */ - -#include - -/** - * Recompute the value of swrast->_RasterMask, etc. according to - * the current context. The _RasterMask field can be easily tested by - * drivers to determine certain basic GL state (does the primitive need - * stenciling, logic-op, fog, etc?). - */ -static void -_swrast_update_rasterflags( struct gl_context *ctx ) -{ - SWcontext *swrast = SWRAST_CONTEXT(ctx); - GLbitfield rasterMask = 0; - - if (ctx->Color.AlphaEnabled) rasterMask |= ALPHATEST_BIT; - if (ctx->Color.BlendEnabled) rasterMask |= BLEND_BIT; - if (ctx->Depth.Test) rasterMask |= DEPTH_BIT; - if (swrast->_FogEnabled) rasterMask |= FOG_BIT; - if (ctx->Scissor.Enabled) rasterMask |= CLIP_BIT; - if (ctx->Stencil._Enabled) rasterMask |= STENCIL_BIT; - if (!ctx->Color.ColorMask[0] || - !ctx->Color.ColorMask[1] || - !ctx->Color.ColorMask[2] || - !ctx->Color.ColorMask[3]) { - rasterMask |= MASKING_BIT; - } - - if (ctx->Color.ColorLogicOpEnabled) rasterMask |= LOGIC_OP_BIT; - if (ctx->Texture._Enabled) rasterMask |= TEXTURE_BIT; - if ( ctx->Viewport.X < 0 - || ctx->Viewport.X + ctx->Viewport.Width > (GLint) ctx->DrawBuffer->Width - || ctx->Viewport.Y < 0 - || ctx->Viewport.Y + ctx->Viewport.Height > (GLint) ctx->DrawBuffer->Height) { - rasterMask |= CLIP_BIT; - } - - if (ctx->Color.ColorMask[0] + - ctx->Color.ColorMask[1] + - ctx->Color.ColorMask[2] + - ctx->Color.ColorMask[3] == 0) { - rasterMask |= MULTI_DRAW_BIT; /* all RGBA channels disabled */ - } - -#if CHAN_TYPE == GL_FLOAT - if (ctx->Color.ClampFragmentColor == GL_TRUE) { - rasterMask |= CLAMPING_BIT; - } -#endif - - SWRAST_CONTEXT(ctx)->_RasterMask = rasterMask; -} - - -/** - * Examine polygon cull state to compute the _BackfaceCullSign field. - * _BackfaceCullSign will be 0 if no culling, -1 if culling back-faces, - * and 1 if culling front-faces. The Polygon FrontFace state also - * factors in. - */ -static void -_swrast_update_polygon( struct gl_context *ctx ) -{ - GLfloat backface_sign; - - if (ctx->Polygon.CullFlag) { - switch (ctx->Polygon.CullFaceMode) { - case GL_BACK: - backface_sign = -1.0F; - break; - case GL_FRONT: - backface_sign = 1.0F; - break; - case GL_FRONT_AND_BACK: - /* fallthrough */ - default: - backface_sign = 0.0F; - } - } - else { - backface_sign = 0.0F; - } - - SWRAST_CONTEXT(ctx)->_BackfaceCullSign = backface_sign; - - /* This is for front/back-face determination, but not for culling */ - SWRAST_CONTEXT(ctx)->_BackfaceSign - = (ctx->Polygon.FrontFace == GL_CW) ? -1.0F : 1.0F; -} - - - -/** - * Update the _PreferPixelFog field to indicate if we need to compute - * fog blend factors (from the fog coords) per-fragment. - */ -static void -_swrast_update_fog_hint( struct gl_context *ctx ) -{ - SWcontext *swrast = SWRAST_CONTEXT(ctx); - swrast->_PreferPixelFog = (!swrast->AllowVertexFog || - (ctx->Hint.Fog == GL_NICEST && - swrast->AllowPixelFog)); -} - - - -/** - * Update the swrast->_TextureCombinePrimary flag. - */ -static void -_swrast_update_texture_env( struct gl_context *ctx ) -{ - SWcontext *swrast = SWRAST_CONTEXT(ctx); - const struct gl_tex_env_combine_state *combine = - ctx->Texture.Unit._CurrentCombine; - GLuint term; - - swrast->_TextureCombinePrimary = GL_FALSE; - - for (term = 0; term < combine->_NumArgsRGB; term++) { - if (combine->SourceRGB[term] == GL_PRIMARY_COLOR) { - swrast->_TextureCombinePrimary = GL_TRUE; - return; - } - if (combine->SourceA[term] == GL_PRIMARY_COLOR) { - swrast->_TextureCombinePrimary = GL_TRUE; - return; - } - } -} - - -/** - * Determine if we can defer texturing/shading until after Z/stencil - * testing. This potentially allows us to skip texturing/shading for - * lots of fragments. - */ -static void -_swrast_update_deferred_texture(struct gl_context *ctx) -{ - SWcontext *swrast = SWRAST_CONTEXT(ctx); - if (ctx->Color.AlphaEnabled) { - /* alpha test depends on post-texture/shader colors */ - swrast->_DeferredTexture = GL_FALSE; - } - else { - swrast->_DeferredTexture = GL_TRUE; - } -} - - -/** - * Update swrast->_FogColor and swrast->_FogEnable values. - */ -static void -_swrast_update_fog_state( struct gl_context *ctx ) -{ - SWcontext *swrast = SWRAST_CONTEXT(ctx); - - /* determine if fog is needed, and if so, which fog mode */ - swrast->_FogEnabled = ctx->Fog.Enabled; -} - - -#define _SWRAST_NEW_DERIVED (_SWRAST_NEW_RASTERMASK | \ - _NEW_TEXTURE | \ - _NEW_HINT | \ - _NEW_POLYGON ) - -/* State referenced by _swrast_choose_triangle, _swrast_choose_line. - */ -#define _SWRAST_NEW_TRIANGLE (_SWRAST_NEW_DERIVED | \ - _NEW_RENDERMODE| \ - _NEW_POLYGON| \ - _NEW_DEPTH| \ - _NEW_STENCIL| \ - _NEW_COLOR| \ - _NEW_TEXTURE| \ - _SWRAST_NEW_RASTERMASK| \ - _NEW_LIGHT| \ - _NEW_FOG | \ - _DD_NEW_SEPARATE_SPECULAR) - -#define _SWRAST_NEW_LINE (_SWRAST_NEW_DERIVED | \ - _NEW_RENDERMODE| \ - _NEW_LINE| \ - _NEW_TEXTURE| \ - _NEW_LIGHT| \ - _NEW_FOG| \ - _NEW_DEPTH | \ - _DD_NEW_SEPARATE_SPECULAR) - -#define _SWRAST_NEW_POINT (_SWRAST_NEW_DERIVED | \ - _NEW_RENDERMODE | \ - _NEW_POINT | \ - _NEW_TEXTURE | \ - _NEW_LIGHT | \ - _NEW_FOG | \ - _DD_NEW_SEPARATE_SPECULAR) - -#define _SWRAST_NEW_TEXTURE_SAMPLE_FUNC _NEW_TEXTURE - -#define _SWRAST_NEW_TEXTURE_ENV_MODE _NEW_TEXTURE - -#define _SWRAST_NEW_BLEND_FUNC _NEW_COLOR - - - -/** - * Stub for swrast->Triangle to select a true triangle function - * after a state change. - */ -static void -_swrast_validate_triangle( struct gl_context *ctx, - const SWvertex *v0, - const SWvertex *v1, - const SWvertex *v2 ) -{ - SWcontext *swrast = SWRAST_CONTEXT(ctx); - - _swrast_validate_derived( ctx ); - swrast->choose_triangle( ctx ); - ASSERT(swrast->Triangle); - - swrast->Triangle( ctx, v0, v1, v2 ); -} - -/** - * Called via swrast->Line. Examine current GL state and choose a software - * line routine. Then call it. - */ -static void -_swrast_validate_line( struct gl_context *ctx, const SWvertex *v0, const SWvertex *v1 ) -{ - SWcontext *swrast = SWRAST_CONTEXT(ctx); - - _swrast_validate_derived( ctx ); - swrast->choose_line( ctx ); - ASSERT(swrast->Line); - - swrast->Line( ctx, v0, v1 ); -} - -/** - * Called via swrast->Point. Examine current GL state and choose a software - * point routine. Then call it. - */ -static void -_swrast_validate_point( struct gl_context *ctx, const SWvertex *v0 ) -{ - SWcontext *swrast = SWRAST_CONTEXT(ctx); - - _swrast_validate_derived( ctx ); - swrast->choose_point( ctx ); - - swrast->Point( ctx, v0 ); -} - - -/** - * Called via swrast->BlendFunc. Examine GL state to choose a blending - * function, then call it. - */ -static void _ASMAPI -_swrast_validate_blend_func(struct gl_context *ctx, GLuint n, const GLubyte mask[], - GLvoid *src, const GLvoid *dst, - GLenum chanType ) -{ - SWcontext *swrast = SWRAST_CONTEXT(ctx); - - _swrast_validate_derived( ctx ); /* why is this needed? */ - _swrast_choose_blend_func( ctx, chanType ); - - swrast->BlendFunc( ctx, n, mask, src, dst, chanType ); -} - -static void -_swrast_sleep( struct gl_context *ctx, GLbitfield new_state ) -{ - (void) ctx; (void) new_state; -} - - -static void -_swrast_invalidate_state( struct gl_context *ctx, GLbitfield new_state ) -{ - SWcontext *swrast = SWRAST_CONTEXT(ctx); - - swrast->NewState |= new_state; - - /* After 10 statechanges without any swrast functions being called, - * put the module to sleep. - */ - if (++swrast->StateChanges > 10) { - swrast->InvalidateState = _swrast_sleep; - swrast->NewState = ~0; - new_state = ~0; - } - - if (new_state & swrast->InvalidateTriangleMask) - swrast->Triangle = _swrast_validate_triangle; - - if (new_state & swrast->InvalidateLineMask) - swrast->Line = _swrast_validate_line; - - if (new_state & swrast->InvalidatePointMask) - swrast->Point = _swrast_validate_point; - - if (new_state & _SWRAST_NEW_BLEND_FUNC) - swrast->BlendFunc = _swrast_validate_blend_func; - - if (new_state & _SWRAST_NEW_TEXTURE_SAMPLE_FUNC) - swrast->TextureSample = NULL; -} - - -void -_swrast_update_texture_samplers(struct gl_context *ctx) -{ - SWcontext *swrast = SWRAST_CONTEXT(ctx); - struct gl_texture_object *tObj; - - if (!swrast) - return; /* pipe hack */ - - tObj = ctx->Texture.Unit._Current; - - /* Note: If tObj is NULL, the sample function will be a simple - * function that just returns opaque black (0,0,0,1). - */ - if (tObj) { - _mesa_update_fetch_functions(tObj); - } - swrast->TextureSample = _swrast_choose_texture_sample_func(ctx, tObj); -} - - -/** - * Update swrast->_ActiveAttribs, swrast->_NumActiveAttribs, - * swrast->_ActiveAtttribMask. - */ -static void -_swrast_update_active_attribs(struct gl_context *ctx) -{ - SWcontext *swrast = SWRAST_CONTEXT(ctx); - GLbitfield64 attribsMask; - - /* - * Compute _ActiveAttribsMask = which fragment attributes are needed. - */ - attribsMask = 0x0; - -#if CHAN_TYPE == GL_FLOAT - attribsMask |= FRAG_BIT_COL; -#endif - - if (swrast->_FogEnabled) - attribsMask |= FRAG_BIT_FOGC; - - attribsMask |= ctx->Texture._Enabled << FRAG_ATTRIB_TEX; - - swrast->_ActiveAttribMask = attribsMask; - - /* Update _ActiveAttribs[] list */ - { - GLuint i, num = 0; - for (i = 0; i < FRAG_ATTRIB_MAX; i++) { - if (attribsMask & BITFIELD64_BIT(i)) { - swrast->_ActiveAttribs[num++] = i; - /* how should this attribute be interpolated? */ - if (i == FRAG_ATTRIB_COL) - swrast->_InterpMode[i] = ctx->Light.ShadeModel; - else - swrast->_InterpMode[i] = GL_SMOOTH; - } - } - swrast->_NumActiveAttribs = num; - } -} - - -void -_swrast_validate_derived( struct gl_context *ctx ) -{ - SWcontext *swrast = SWRAST_CONTEXT(ctx); - - if (swrast->NewState) { - if (swrast->NewState & _NEW_POLYGON) - _swrast_update_polygon( ctx ); - - if (swrast->NewState & _NEW_HINT) - _swrast_update_fog_hint( ctx ); - - if (swrast->NewState & _SWRAST_NEW_TEXTURE_ENV_MODE) - _swrast_update_texture_env( ctx ); - - if (swrast->NewState & _NEW_FOG) - _swrast_update_fog_state( ctx ); - - if (swrast->NewState & _NEW_TEXTURE) { - _swrast_update_texture_samplers( ctx ); - } - - if (swrast->NewState & _NEW_COLOR) - _swrast_update_deferred_texture(ctx); - - if (swrast->NewState & _SWRAST_NEW_RASTERMASK) - _swrast_update_rasterflags( ctx ); - - if (swrast->NewState & (_NEW_DEPTH | - _NEW_FOG | - _NEW_LIGHT | - _NEW_TEXTURE)) - _swrast_update_active_attribs(ctx); - - swrast->NewState = 0; - swrast->StateChanges = 0; - swrast->InvalidateState = _swrast_invalidate_state; - } -} - -#define SWRAST_DEBUG 0 - -/* Public entrypoints: See also s_bitmap.c, etc. - */ -void -_swrast_Quad( struct gl_context *ctx, - const SWvertex *v0, const SWvertex *v1, - const SWvertex *v2, const SWvertex *v3 ) -{ - if (SWRAST_DEBUG) { - _mesa_debug(ctx, "_swrast_Quad\n"); - _swrast_print_vertex( ctx, v0 ); - _swrast_print_vertex( ctx, v1 ); - _swrast_print_vertex( ctx, v2 ); - _swrast_print_vertex( ctx, v3 ); - } - SWRAST_CONTEXT(ctx)->Triangle( ctx, v0, v1, v3 ); - SWRAST_CONTEXT(ctx)->Triangle( ctx, v1, v2, v3 ); -} - -void -_swrast_Triangle( struct gl_context *ctx, const SWvertex *v0, - const SWvertex *v1, const SWvertex *v2 ) -{ - if (SWRAST_DEBUG) { - _mesa_debug(ctx, "_swrast_Triangle\n"); - _swrast_print_vertex( ctx, v0 ); - _swrast_print_vertex( ctx, v1 ); - _swrast_print_vertex( ctx, v2 ); - } - SWRAST_CONTEXT(ctx)->Triangle( ctx, v0, v1, v2 ); -} - -void -_swrast_Line( struct gl_context *ctx, const SWvertex *v0, const SWvertex *v1 ) -{ - if (SWRAST_DEBUG) { - _mesa_debug(ctx, "_swrast_Line\n"); - _swrast_print_vertex( ctx, v0 ); - _swrast_print_vertex( ctx, v1 ); - } - SWRAST_CONTEXT(ctx)->Line( ctx, v0, v1 ); -} - -void -_swrast_Point( struct gl_context *ctx, const SWvertex *v0 ) -{ - if (SWRAST_DEBUG) { - _mesa_debug(ctx, "_swrast_Point\n"); - _swrast_print_vertex( ctx, v0 ); - } - SWRAST_CONTEXT(ctx)->Point( ctx, v0 ); -} - -void -_swrast_InvalidateState( struct gl_context *ctx, GLbitfield new_state ) -{ - if (SWRAST_DEBUG) { - _mesa_debug(ctx, "_swrast_InvalidateState\n"); - } - SWRAST_CONTEXT(ctx)->InvalidateState( ctx, new_state ); -} - -void -_swrast_ResetLineStipple( struct gl_context *ctx ) -{ - if (SWRAST_DEBUG) { - _mesa_debug(ctx, "_swrast_ResetLineStipple\n"); - } - SWRAST_CONTEXT(ctx)->StippleCounter = 0; -} - -void -_swrast_allow_vertex_fog( struct gl_context *ctx, GLboolean value ) -{ - if (SWRAST_DEBUG) { - _mesa_debug(ctx, "_swrast_allow_vertex_fog %d\n", value); - } - SWRAST_CONTEXT(ctx)->InvalidateState( ctx, _NEW_HINT ); - SWRAST_CONTEXT(ctx)->AllowVertexFog = value; -} - -void -_swrast_allow_pixel_fog( struct gl_context *ctx, GLboolean value ) -{ - if (SWRAST_DEBUG) { - _mesa_debug(ctx, "_swrast_allow_pixel_fog %d\n", value); - } - SWRAST_CONTEXT(ctx)->InvalidateState( ctx, _NEW_HINT ); - SWRAST_CONTEXT(ctx)->AllowPixelFog = value; -} - - -GLboolean -_swrast_CreateContext( struct gl_context *ctx ) -{ - GLuint i; - SWcontext *swrast = (SWcontext *)CALLOC(sizeof(SWcontext)); -#ifdef _OPENMP - const GLuint maxThreads = omp_get_max_threads(); -#else - const GLuint maxThreads = 1; -#endif - - if (SWRAST_DEBUG) { - _mesa_debug(ctx, "_swrast_CreateContext\n"); - } - - if (!swrast) - return GL_FALSE; - - swrast->NewState = ~0; - - swrast->choose_point = _swrast_choose_point; - swrast->choose_line = _swrast_choose_line; - swrast->choose_triangle = _swrast_choose_triangle; - - swrast->InvalidatePointMask = _SWRAST_NEW_POINT; - swrast->InvalidateLineMask = _SWRAST_NEW_LINE; - swrast->InvalidateTriangleMask = _SWRAST_NEW_TRIANGLE; - - swrast->Point = _swrast_validate_point; - swrast->Line = _swrast_validate_line; - swrast->Triangle = _swrast_validate_triangle; - swrast->InvalidateState = _swrast_sleep; - swrast->BlendFunc = _swrast_validate_blend_func; - - swrast->AllowVertexFog = GL_TRUE; - swrast->AllowPixelFog = GL_TRUE; - - swrast->Driver.SpanRenderStart = _swrast_span_render_start; - swrast->Driver.SpanRenderFinish = _swrast_span_render_finish; - - swrast->TextureSample = NULL; - - /* SpanArrays is global and shared by all SWspan instances. However, when - * using multiple threads, it is necessary to have one SpanArrays instance - * per thread. - */ - swrast->SpanArrays = (SWspanarrays *) MALLOC(maxThreads * sizeof(SWspanarrays)); - if (!swrast->SpanArrays) { - FREE(swrast); - return GL_FALSE; - } - for(i = 0; i < maxThreads; i++) { - swrast->SpanArrays[i].ChanType = CHAN_TYPE; -#if CHAN_TYPE == GL_UNSIGNED_BYTE - swrast->SpanArrays[i].rgba = swrast->SpanArrays[i].rgba8; -#elif CHAN_TYPE == GL_UNSIGNED_SHORT - swrast->SpanArrays[i].rgba = swrast->SpanArrays[i].rgba16; -#else - swrast->SpanArrays[i].rgba = swrast->SpanArrays[i].attribs[FRAG_ATTRIB_COL0]; -#endif - } - - /* init point span buffer */ - swrast->PointSpan.primitive = GL_POINT; - swrast->PointSpan.end = 0; - swrast->PointSpan.array = swrast->SpanArrays; - - ctx->swrast_context = swrast; - - return GL_TRUE; -} - -void -_swrast_DestroyContext( struct gl_context *ctx ) -{ - SWcontext *swrast = SWRAST_CONTEXT(ctx); - - if (SWRAST_DEBUG) { - _mesa_debug(ctx, "_swrast_DestroyContext\n"); - } - - FREE( swrast->SpanArrays ); - if (swrast->ZoomedArrays) - FREE( swrast->ZoomedArrays ); - FREE( swrast->TexelBuffer ); - FREE( swrast ); - - ctx->swrast_context = 0; -} - - -struct swrast_device_driver * -_swrast_GetDeviceDriverReference( struct gl_context *ctx ) -{ - SWcontext *swrast = SWRAST_CONTEXT(ctx); - return &swrast->Driver; -} - -void -_swrast_flush( struct gl_context *ctx ) -{ - SWcontext *swrast = SWRAST_CONTEXT(ctx); - /* flush any pending fragments from rendering points */ - if (swrast->PointSpan.end > 0) { - _swrast_write_rgba_span(ctx, &(swrast->PointSpan)); - swrast->PointSpan.end = 0; - } -} - -void -_swrast_render_primitive( struct gl_context *ctx, GLenum prim ) -{ - SWcontext *swrast = SWRAST_CONTEXT(ctx); - if (swrast->Primitive == GL_POINTS && prim != GL_POINTS) { - _swrast_flush(ctx); - } - swrast->Primitive = prim; -} - - -/** called via swrast->Driver.SpanRenderStart() */ -void -_swrast_span_render_start(struct gl_context *ctx) -{ - _swrast_map_textures(ctx); - _swrast_map_renderbuffers(ctx); -} - - -/** called via swrast->Driver.SpanRenderFinish() */ -void -_swrast_span_render_finish(struct gl_context *ctx) -{ - _swrast_unmap_textures(ctx); - _swrast_unmap_renderbuffers(ctx); -} - - -void -_swrast_render_start( struct gl_context *ctx ) -{ - SWcontext *swrast = SWRAST_CONTEXT(ctx); - if (swrast->Driver.SpanRenderStart) - swrast->Driver.SpanRenderStart( ctx ); - swrast->PointSpan.end = 0; -} - -void -_swrast_render_finish( struct gl_context *ctx ) -{ - SWcontext *swrast = SWRAST_CONTEXT(ctx); - - _swrast_flush(ctx); - - if (swrast->Driver.SpanRenderFinish) - swrast->Driver.SpanRenderFinish( ctx ); -} - - -#define SWRAST_DEBUG_VERTICES 0 - -void -_swrast_print_vertex( struct gl_context *ctx, const SWvertex *v ) -{ - GLuint i; - - if (SWRAST_DEBUG_VERTICES) { - _mesa_debug(ctx, "win %f %f %f %f\n", - v->attrib[FRAG_ATTRIB_WPOS][0], - v->attrib[FRAG_ATTRIB_WPOS][1], - v->attrib[FRAG_ATTRIB_WPOS][2], - v->attrib[FRAG_ATTRIB_WPOS][3]); - - if (ctx->Texture.Unit._ReallyEnabled) - _mesa_debug(ctx, "texcoord[%d] %f %f %f %f\n", i, - v->attrib[FRAG_ATTRIB_TEX][0], - v->attrib[FRAG_ATTRIB_TEX][1], - v->attrib[FRAG_ATTRIB_TEX][2], - v->attrib[FRAG_ATTRIB_TEX][3]); - -#if CHAN_TYPE == GL_FLOAT - _mesa_debug(ctx, "color %f %f %f %f\n", - v->color[0], v->color[1], v->color[2], v->color[3]); -#else - _mesa_debug(ctx, "color %d %d %d %d\n", - v->color[0], v->color[1], v->color[2], v->color[3]); -#endif - _mesa_debug(ctx, "fog %f\n", v->attrib[FRAG_ATTRIB_FOGC][0]); - _mesa_debug(ctx, "index %f\n", v->attrib[FRAG_ATTRIB_CI][0]); - _mesa_debug(ctx, "pointsize %f\n", v->pointSize); - _mesa_debug(ctx, "\n"); - } -} diff --git a/dll/opengl/mesa/swrast/s_context.h b/dll/opengl/mesa/swrast/s_context.h deleted file mode 100644 index 190667e2c11..00000000000 --- a/dll/opengl/mesa/swrast/s_context.h +++ /dev/null @@ -1,460 +0,0 @@ -/* - * Mesa 3-D graphics library - * Version: 6.5.3 - * - * Copyright (C) 1999-2007 Brian Paul All Rights Reserved. - * - * Permission is hereby granted, free of charge, to any person obtaining a - * copy of this software and associated documentation files (the "Software"), - * to deal in the Software without restriction, including without limitation - * the rights to use, copy, modify, merge, publish, distribute, sublicense, - * and/or sell copies of the Software, and to permit persons to whom the - * Software is furnished to do so, subject to the following conditions: - * - * The above copyright notice and this permission notice shall be included - * in all copies or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS - * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL - * BRIAN PAUL BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN - * AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN - * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. - */ - - -/** - * \file swrast/s_context.h - * \brief Software rasterization context and private types. - * \author Keith Whitwell - */ - -/** - * \mainpage swrast module - * - * This module, software rasterization, contains the software fallback - * routines for drawing points, lines, triangles, bitmaps and images. - * All rendering boils down to writing spans (arrays) of pixels with - * particular colors. The span-writing routines must be implemented - * by the device driver. - */ - - -#ifndef S_CONTEXT_H -#define S_CONTEXT_H - -#include "main/compiler.h" -#include "main/mtypes.h" -#include "swrast.h" -#include "s_span.h" - - -typedef void (*texture_sample_func)(struct gl_context *ctx, - const struct gl_texture_object *tObj, - GLuint n, const GLfloat texcoords[][4], - const GLfloat lambda[], GLfloat rgba[][4]); - -typedef void (_ASMAPIP blend_func)( struct gl_context *ctx, GLuint n, - const GLubyte mask[], - GLvoid *src, const GLvoid *dst, - GLenum chanType); - -typedef void (*swrast_point_func)( struct gl_context *ctx, const SWvertex *); - -typedef void (*swrast_line_func)( struct gl_context *ctx, - const SWvertex *, const SWvertex *); - -typedef void (*swrast_tri_func)( struct gl_context *ctx, const SWvertex *, - const SWvertex *, const SWvertex *); - - -typedef void (*validate_texture_image_func)(struct gl_context *ctx, - struct gl_texture_object *texObj, - GLuint face, GLuint level); - - -/** - * \defgroup Bitmasks - * Bitmasks to indicate which rasterization options are enabled - * (RasterMask) - */ -/*@{*/ -#define ALPHATEST_BIT 0x001 /**< Alpha-test pixels */ -#define BLEND_BIT 0x002 /**< Blend pixels */ -#define DEPTH_BIT 0x004 /**< Depth-test pixels */ -#define FOG_BIT 0x008 /**< Fog pixels */ -#define LOGIC_OP_BIT 0x010 /**< Apply logic op in software */ -#define CLIP_BIT 0x020 /**< Scissor or window clip pixels */ -#define STENCIL_BIT 0x040 /**< Stencil pixels */ -#define MASKING_BIT 0x080 /**< Do glColorMask or glIndexMask */ -#define MULTI_DRAW_BIT 0x400 /**< Write to more than one color- */ - /**< buffer or no buffers. */ -#define TEXTURE_BIT 0x1000 /**< Texturing really enabled */ -#define CLAMPING_BIT 0x8000 /**< Clamp colors to [0,1] */ -/*@}*/ - -#define _SWRAST_NEW_RASTERMASK (_NEW_BUFFERS| \ - _NEW_SCISSOR| \ - _NEW_COLOR| \ - _NEW_DEPTH| \ - _NEW_FOG| \ - _NEW_STENCIL| \ - _NEW_TEXTURE| \ - _NEW_VIEWPORT| \ - _NEW_DEPTH) - - -struct swrast_texture_image; - - -/** - * Fetch a texel from texture image at given position. - */ -typedef void (*FetchTexelFunc)(const struct swrast_texture_image *texImage, - GLint col, GLint row, GLint img, - GLfloat *texelOut); - - -/** - * Subclass of gl_texture_image. - * We need extra fields/info to keep tracking of mapped texture buffers, - * strides and Fetch functions. - */ -struct swrast_texture_image -{ - struct gl_texture_image Base; - - GLboolean _IsPowerOfTwo; /**< Are all dimensions powers of two? */ - - /** used for mipmap LOD computation */ - GLfloat WidthScale, HeightScale, DepthScale; - - /** These fields only valid when texture memory is mapped */ - GLint RowStride; /**< Padded width in units of texels */ - GLuint *ImageOffsets; /**< if 3D texture: array [Depth] of offsets to - each 2D slice in 'Data', in texels */ - GLubyte *Map; /**< Pointer to mapped image memory */ - - /** Malloc'd texture memory */ - GLubyte *Buffer; - - FetchTexelFunc FetchTexel; -}; - - -/** cast wrapper */ -static inline struct swrast_texture_image * -swrast_texture_image(struct gl_texture_image *img) -{ - return (struct swrast_texture_image *) img; -} - -/** cast wrapper */ -static inline const struct swrast_texture_image * -swrast_texture_image_const(const struct gl_texture_image *img) -{ - return (const struct swrast_texture_image *) img; -} - - -/** - * Subclass of gl_renderbuffer with extra fields needed for software - * rendering. - */ -struct swrast_renderbuffer -{ - struct gl_renderbuffer Base; - - GLubyte *Buffer; /**< The malloc'd memory for buffer */ - - /** These fields are only valid while buffer is mapped for rendering */ - GLubyte *Map; - GLint RowStride; /**< in bytes */ - - /** For span rendering */ - GLenum ColorType; -}; - - -/** cast wrapper */ -static inline struct swrast_renderbuffer * -swrast_renderbuffer(struct gl_renderbuffer *img) -{ - return (struct swrast_renderbuffer *) img; -} - - - -/** - * \struct SWcontext - * \brief Per-context state that's private to the software rasterizer module. - */ -typedef struct -{ - /** Driver interface: - */ - struct swrast_device_driver Driver; - - /** Configuration mechanisms to make software rasterizer match - * characteristics of the hardware rasterizer (if present): - */ - GLboolean AllowVertexFog; - GLboolean AllowPixelFog; - - /** Derived values, invalidated on statechanges, updated from - * _swrast_validate_derived(): - */ - GLbitfield _RasterMask; - GLfloat _BackfaceSign; /** +1 or -1 */ - GLfloat _BackfaceCullSign; /** +1, 0, or -1 */ - GLboolean _PreferPixelFog; /* Compute fog blend factor per fragment? */ - GLboolean _TextureCombinePrimary; - GLboolean _FogEnabled; - GLboolean _DeferredTexture; - - /** List/array of the fragment attributes to interpolate */ - GLuint _ActiveAttribs[FRAG_ATTRIB_MAX]; - /** Same info, but as a bitmask of FRAG_BIT_x bits */ - GLbitfield64 _ActiveAttribMask; - /** Number of fragment attributes to interpolate */ - GLuint _NumActiveAttribs; - /** Indicates how each attrib is to be interpolated (lines/tris) */ - GLenum _InterpMode[FRAG_ATTRIB_MAX]; /* GL_FLAT or GL_SMOOTH (for now) */ - - /* Working values: - */ - GLuint StippleCounter; /**< Line stipple counter */ - GLbitfield NewState; - GLuint StateChanges; - GLenum Primitive; /* current primitive being drawn (ala glBegin) */ - - void (*InvalidateState)( struct gl_context *ctx, GLbitfield new_state ); - - /** - * When the NewState mask intersects these masks, we invalidate the - * Point/Line/Triangle function pointers below. - */ - /*@{*/ - GLbitfield InvalidatePointMask; - GLbitfield InvalidateLineMask; - GLbitfield InvalidateTriangleMask; - /*@}*/ - - /** - * Device drivers plug in functions for these callbacks. - * Will be called when the GL state change mask intersects the above masks. - */ - /*@{*/ - void (*choose_point)( struct gl_context * ); - void (*choose_line)( struct gl_context * ); - void (*choose_triangle)( struct gl_context * ); - /*@}*/ - - /** - * Current point, line and triangle drawing functions. - */ - /*@{*/ - swrast_point_func Point; - swrast_line_func Line; - swrast_tri_func Triangle; - /*@}*/ - - /** - * Placeholders for when separate specular (or secondary color) is - * enabled but texturing is not. - */ - /*@{*/ - swrast_point_func SpecPoint; - swrast_line_func SpecLine; - swrast_tri_func SpecTriangle; - /*@}*/ - - /** - * Typically, we'll allocate a sw_span structure as a local variable - * and set its 'array' pointer to point to this object. The reason is - * this object is big and causes problems when allocated on the stack - * on some systems. - */ - SWspanarrays *SpanArrays; - SWspanarrays *ZoomedArrays; /**< For pixel zooming */ - - /** - * Used to buffer N GL_POINTS, instead of rendering one by one. - */ - SWspan PointSpan; - - /** Internal hooks, kept up to date by the same mechanism as above. - */ - blend_func BlendFunc; - texture_sample_func TextureSample; - - /** Buffer for saving the sampled texture colors. - * Needed for GL_ARB_texture_env_crossbar implementation. - */ - GLfloat *TexelBuffer; - - validate_texture_image_func ValidateTextureImage; - -} SWcontext; - - -extern void -_swrast_validate_derived( struct gl_context *ctx ); - -extern void -_swrast_update_texture_samplers(struct gl_context *ctx); - - -/** Return SWcontext for the given struct gl_context */ -static inline SWcontext * -SWRAST_CONTEXT(struct gl_context *ctx) -{ - return (SWcontext *) ctx->swrast_context; -} - -/** const version of above */ -static inline const SWcontext * -CONST_SWRAST_CONTEXT(const struct gl_context *ctx) -{ - return (const SWcontext *) ctx->swrast_context; -} - - -/** - * Called prior to framebuffer reading/writing. - * For drivers that rely on swrast for fallback rendering, this is the - * driver's opportunity to map renderbuffers and textures. - */ -static inline void -swrast_render_start(struct gl_context *ctx) -{ - SWcontext *swrast = SWRAST_CONTEXT(ctx); - if (swrast->Driver.SpanRenderStart) - swrast->Driver.SpanRenderStart(ctx); -} - - -/** Called after framebuffer reading/writing */ -static inline void -swrast_render_finish(struct gl_context *ctx) -{ - SWcontext *swrast = SWRAST_CONTEXT(ctx); - if (swrast->Driver.SpanRenderFinish) - swrast->Driver.SpanRenderFinish(ctx); -} - - -extern void -_swrast_span_render_start(struct gl_context *ctx); - -extern void -_swrast_span_render_finish(struct gl_context *ctx); - -extern void -_swrast_map_textures(struct gl_context *ctx); - -extern void -_swrast_unmap_textures(struct gl_context *ctx); - -extern void -_swrast_map_texture(struct gl_context *ctx, struct gl_texture_object *texObj); - -extern void -_swrast_unmap_texture(struct gl_context *ctx, struct gl_texture_object *texObj); - - -extern void -_swrast_map_renderbuffers(struct gl_context *ctx); - -extern void -_swrast_unmap_renderbuffers(struct gl_context *ctx); - - -/** - * Size of an RGBA pixel, in bytes, for given datatype. - */ -#define RGBA_PIXEL_SIZE(TYPE) \ - ((TYPE == GL_UNSIGNED_BYTE) ? 4 * sizeof(GLubyte) : \ - ((TYPE == GL_UNSIGNED_SHORT) ? 4 * sizeof(GLushort) \ - : 4 * sizeof(GLfloat))) - - - -/* - * Fixed point arithmetic macros - */ -#ifndef FIXED_FRAC_BITS -#define FIXED_FRAC_BITS 11 -#endif - -#define FIXED_SHIFT FIXED_FRAC_BITS -#define FIXED_ONE (1 << FIXED_SHIFT) -#define FIXED_HALF (1 << (FIXED_SHIFT-1)) -#define FIXED_FRAC_MASK (FIXED_ONE - 1) -#define FIXED_INT_MASK (~FIXED_FRAC_MASK) -#define FIXED_EPSILON 1 -#define FIXED_SCALE ((float) FIXED_ONE) -#define FIXED_DBL_SCALE ((double) FIXED_ONE) -#define FloatToFixed(X) (IROUND((X) * FIXED_SCALE)) -#define FixedToDouble(X) ((X) * (1.0 / FIXED_DBL_SCALE)) -#define IntToFixed(I) ((I) << FIXED_SHIFT) -#define FixedToInt(X) ((X) >> FIXED_SHIFT) -#define FixedToUns(X) (((unsigned int)(X)) >> FIXED_SHIFT) -#define FixedCeil(X) (((X) + FIXED_ONE - FIXED_EPSILON) & FIXED_INT_MASK) -#define FixedFloor(X) ((X) & FIXED_INT_MASK) -#define FixedToFloat(X) ((X) * (1.0F / FIXED_SCALE)) -#define PosFloatToFixed(X) FloatToFixed(X) -#define SignedFloatToFixed(X) FloatToFixed(X) - - - -/* - * XXX these macros are just bandages for now in order to make - * CHAN_BITS==32 compile cleanly. - * These should probably go elsewhere at some point. - */ -#if CHAN_TYPE == GL_FLOAT -#define ChanToFixed(X) (X) -#define FixedToChan(X) (X) -#else -#define ChanToFixed(X) IntToFixed(X) -#define FixedToChan(X) FixedToInt(X) -#endif - - -/** - * For looping over fragment attributes in the pointe, line - * triangle rasterizers. - */ -#define ATTRIB_LOOP_BEGIN \ - { \ - GLuint a; \ - for (a = 0; a < swrast->_NumActiveAttribs; a++) { \ - const GLuint attr = swrast->_ActiveAttribs[a]; - -#define ATTRIB_LOOP_END } } - - -/** - * Return the address of a pixel value in a mapped renderbuffer. - */ -static inline GLubyte * -_swrast_pixel_address(struct gl_renderbuffer *rb, GLint x, GLint y) -{ - struct swrast_renderbuffer *srb = swrast_renderbuffer(rb); - const GLint bpp = _mesa_get_format_bytes(rb->Format); - const GLint rowStride = srb->RowStride; - assert(x >= 0); - assert(y >= 0); - /* NOTE: using <= only because of s_tritemp.h which gets a pixel - * address but doesn't necessarily access it. - */ - assert(x <= (GLint) rb->Width); - assert(y <= (GLint) rb->Height); - assert(srb->Map); - return (GLubyte *) srb->Map + y * rowStride + x * bpp; -} - - - -#endif diff --git a/dll/opengl/mesa/swrast/s_copypix.c b/dll/opengl/mesa/swrast/s_copypix.c deleted file mode 100644 index a63976fe483..00000000000 --- a/dll/opengl/mesa/swrast/s_copypix.c +++ /dev/null @@ -1,615 +0,0 @@ -/* - * Mesa 3-D graphics library - * Version: 7.1 - * - * Copyright (C) 1999-2007 Brian Paul All Rights Reserved. - * - * Permission is hereby granted, free of charge, to any person obtaining a - * copy of this software and associated documentation files (the "Software"), - * to deal in the Software without restriction, including without limitation - * the rights to use, copy, modify, merge, publish, distribute, sublicense, - * and/or sell copies of the Software, and to permit persons to whom the - * Software is furnished to do so, subject to the following conditions: - * - * The above copyright notice and this permission notice shall be included - * in all copies or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS - * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL - * BRIAN PAUL BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN - * AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN - * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. - */ - -#include - -/** - * Determine if there's overlap in an image copy. - * This test also compensates for the fact that copies are done from - * bottom to top and overlaps can sometimes be handled correctly - * without making a temporary image copy. - * \return GL_TRUE if the regions overlap, GL_FALSE otherwise. - */ -static GLboolean -regions_overlap(GLint srcx, GLint srcy, - GLint dstx, GLint dsty, - GLint width, GLint height, - GLfloat zoomX, GLfloat zoomY) -{ - if (zoomX == 1.0 && zoomY == 1.0) { - /* no zoom */ - if (srcx >= dstx + width || (srcx + width <= dstx)) { - return GL_FALSE; - } - else if (srcy < dsty) { /* this is OK */ - return GL_FALSE; - } - else if (srcy > dsty + height) { - return GL_FALSE; - } - else { - return GL_TRUE; - } - } - else { - /* add one pixel of slop when zooming, just to be safe */ - if (srcx > (dstx + ((zoomX > 0.0F) ? (width * zoomX + 1.0F) : 0.0F))) { - /* src is completely right of dest */ - return GL_FALSE; - } - else if (srcx + width + 1.0F < dstx + ((zoomX > 0.0F) ? 0.0F : (width * zoomX))) { - /* src is completely left of dest */ - return GL_FALSE; - } - else if ((srcy < dsty) && (srcy + height < dsty + (height * zoomY))) { - /* src is completely below dest */ - return GL_FALSE; - } - else if ((srcy > dsty) && (srcy + height > dsty + (height * zoomY))) { - /* src is completely above dest */ - return GL_FALSE; - } - else { - return GL_TRUE; - } - } -} - - -/** - * RGBA copypixels - */ -static void -copy_rgba_pixels(struct gl_context *ctx, GLint srcx, GLint srcy, - GLint width, GLint height, GLint destx, GLint desty) -{ - GLfloat *tmpImage, *p; - GLint sy, dy, stepy, row; - const GLboolean zoom = ctx->Pixel.ZoomX != 1.0F || ctx->Pixel.ZoomY != 1.0F; - GLint overlapping; - GLuint transferOps = ctx->_ImageTransferState; - SWspan span; - - if (!ctx->ReadBuffer->_ColorReadBuffer) { - /* no readbuffer - OK */ - return; - } - - if (ctx->DrawBuffer == ctx->ReadBuffer) { - overlapping = regions_overlap(srcx, srcy, destx, desty, width, height, - ctx->Pixel.ZoomX, ctx->Pixel.ZoomY); - } - else { - overlapping = GL_FALSE; - } - - /* Determine if copy should be done bottom-to-top or top-to-bottom */ - if (!overlapping && srcy < desty) { - /* top-down max-to-min */ - sy = srcy + height - 1; - dy = desty + height - 1; - stepy = -1; - } - else { - /* bottom-up min-to-max */ - sy = srcy; - dy = desty; - stepy = 1; - } - - INIT_SPAN(span, GL_BITMAP); - _swrast_span_default_attribs(ctx, &span); - span.arrayMask = SPAN_RGBA; - span.arrayAttribs = FRAG_BIT_COL; /* we'll fill in COL0 attrib values */ - - if (overlapping) { - tmpImage = (GLfloat *) malloc(width * height * sizeof(GLfloat) * 4); - if (!tmpImage) { - _mesa_error( ctx, GL_OUT_OF_MEMORY, "glCopyPixels" ); - return; - } - /* read the source image as RGBA/float */ - p = tmpImage; - for (row = 0; row < height; row++) { - _swrast_read_rgba_span( ctx, ctx->ReadBuffer->_ColorReadBuffer, - width, srcx, sy + row, p ); - p += width * 4; - } - p = tmpImage; - } - else { - tmpImage = NULL; /* silence compiler warnings */ - p = NULL; - } - - ASSERT(width < MAX_WIDTH); - - for (row = 0; row < height; row++, sy += stepy, dy += stepy) { - GLvoid *rgba = span.array->attribs[FRAG_ATTRIB_COL]; - - /* Get row/span of source pixels */ - if (overlapping) { - /* get from buffered image */ - memcpy(rgba, p, width * sizeof(GLfloat) * 4); - p += width * 4; - } - else { - /* get from framebuffer */ - _swrast_read_rgba_span( ctx, ctx->ReadBuffer->_ColorReadBuffer, - width, srcx, sy, rgba ); - } - - if (transferOps) { - _mesa_apply_rgba_transfer_ops(ctx, transferOps, width, - (GLfloat (*)[4]) rgba); - } - - /* Write color span */ - span.x = destx; - span.y = dy; - span.end = width; - span.array->ChanType = GL_FLOAT; - if (zoom) { - _swrast_write_zoomed_rgba_span(ctx, destx, desty, &span, rgba); - } - else { - _swrast_write_rgba_span(ctx, &span); - } - } - - span.array->ChanType = CHAN_TYPE; /* restore */ - - if (overlapping) - free(tmpImage); -} - - -/** - * Convert floating point Z values to integer Z values with pixel transfer's - * Z scale and bias. - */ -static void -scale_and_bias_z(struct gl_context *ctx, GLuint width, - const GLfloat depth[], GLuint z[]) -{ - const GLuint depthMax = ctx->DrawBuffer->_DepthMax; - GLuint i; - - if (depthMax <= 0xffffff && - ctx->Pixel.DepthScale == 1.0 && - ctx->Pixel.DepthBias == 0.0) { - /* no scale or bias and no clamping and no worry of overflow */ - const GLfloat depthMaxF = ctx->DrawBuffer->_DepthMaxF; - for (i = 0; i < width; i++) { - z[i] = (GLuint) (depth[i] * depthMaxF); - } - } - else { - /* need to be careful with overflow */ - const GLdouble depthMaxF = ctx->DrawBuffer->_DepthMaxF; - for (i = 0; i < width; i++) { - GLdouble d = depth[i] * ctx->Pixel.DepthScale + ctx->Pixel.DepthBias; - d = CLAMP(d, 0.0, 1.0) * depthMaxF; - if (d >= depthMaxF) - z[i] = depthMax; - else - z[i] = (GLuint) d; - } - } -} - - - -/* - * TODO: Optimize!!!! - */ -static void -copy_depth_pixels( struct gl_context *ctx, GLint srcx, GLint srcy, - GLint width, GLint height, - GLint destx, GLint desty ) -{ - struct gl_framebuffer *fb = ctx->ReadBuffer; - struct gl_renderbuffer *readRb = fb->Attachment[BUFFER_DEPTH].Renderbuffer; - GLfloat *p, *tmpImage; - GLint sy, dy, stepy; - GLint j; - const GLboolean zoom = ctx->Pixel.ZoomX != 1.0F || ctx->Pixel.ZoomY != 1.0F; - GLint overlapping; - SWspan span; - - if (!readRb) { - /* no readbuffer - OK */ - return; - } - - INIT_SPAN(span, GL_BITMAP); - _swrast_span_default_attribs(ctx, &span); - span.arrayMask = SPAN_Z; - - if (ctx->DrawBuffer == ctx->ReadBuffer) { - overlapping = regions_overlap(srcx, srcy, destx, desty, width, height, - ctx->Pixel.ZoomX, ctx->Pixel.ZoomY); - } - else { - overlapping = GL_FALSE; - } - - /* Determine if copy should be bottom-to-top or top-to-bottom */ - if (!overlapping && srcy < desty) { - /* top-down max-to-min */ - sy = srcy + height - 1; - dy = desty + height - 1; - stepy = -1; - } - else { - /* bottom-up min-to-max */ - sy = srcy; - dy = desty; - stepy = 1; - } - - if (overlapping) { - GLint ssy = sy; - tmpImage = (GLfloat *) malloc(width * height * sizeof(GLfloat)); - if (!tmpImage) { - _mesa_error( ctx, GL_OUT_OF_MEMORY, "glCopyPixels" ); - return; - } - p = tmpImage; - for (j = 0; j < height; j++, ssy += stepy) { - _swrast_read_depth_span_float(ctx, readRb, width, srcx, ssy, p); - p += width; - } - p = tmpImage; - } - else { - tmpImage = NULL; /* silence compiler warning */ - p = NULL; - } - - for (j = 0; j < height; j++, sy += stepy, dy += stepy) { - GLfloat depth[MAX_WIDTH]; - /* get depth values */ - if (overlapping) { - memcpy(depth, p, width * sizeof(GLfloat)); - p += width; - } - else { - _swrast_read_depth_span_float(ctx, readRb, width, srcx, sy, depth); - } - - /* apply scale and bias */ - scale_and_bias_z(ctx, width, depth, span.array->z); - - /* write depth values */ - span.x = destx; - span.y = dy; - span.end = width; - if (zoom) - _swrast_write_zoomed_depth_span(ctx, destx, desty, &span); - else - _swrast_write_rgba_span(ctx, &span); - } - - if (overlapping) - free(tmpImage); -} - - - -static void -copy_stencil_pixels( struct gl_context *ctx, GLint srcx, GLint srcy, - GLint width, GLint height, - GLint destx, GLint desty ) -{ - struct gl_framebuffer *fb = ctx->ReadBuffer; - struct gl_renderbuffer *rb = fb->Attachment[BUFFER_STENCIL].Renderbuffer; - GLint sy, dy, stepy; - GLint j; - GLubyte *p, *tmpImage; - const GLboolean zoom = ctx->Pixel.ZoomX != 1.0F || ctx->Pixel.ZoomY != 1.0F; - GLint overlapping; - - if (!rb) { - /* no readbuffer - OK */ - return; - } - - if (ctx->DrawBuffer == ctx->ReadBuffer) { - overlapping = regions_overlap(srcx, srcy, destx, desty, width, height, - ctx->Pixel.ZoomX, ctx->Pixel.ZoomY); - } - else { - overlapping = GL_FALSE; - } - - /* Determine if copy should be bottom-to-top or top-to-bottom */ - if (!overlapping && srcy < desty) { - /* top-down max-to-min */ - sy = srcy + height - 1; - dy = desty + height - 1; - stepy = -1; - } - else { - /* bottom-up min-to-max */ - sy = srcy; - dy = desty; - stepy = 1; - } - - if (overlapping) { - GLint ssy = sy; - tmpImage = (GLubyte *) malloc(width * height * sizeof(GLubyte)); - if (!tmpImage) { - _mesa_error( ctx, GL_OUT_OF_MEMORY, "glCopyPixels" ); - return; - } - p = tmpImage; - for (j = 0; j < height; j++, ssy += stepy) { - _swrast_read_stencil_span( ctx, rb, width, srcx, ssy, p ); - p += width; - } - p = tmpImage; - } - else { - tmpImage = NULL; /* silence compiler warning */ - p = NULL; - } - - for (j = 0; j < height; j++, sy += stepy, dy += stepy) { - GLubyte stencil[MAX_WIDTH]; - - /* Get stencil values */ - if (overlapping) { - memcpy(stencil, p, width * sizeof(GLubyte)); - p += width; - } - else { - _swrast_read_stencil_span( ctx, rb, width, srcx, sy, stencil ); - } - - _mesa_apply_stencil_transfer_ops(ctx, width, stencil); - - /* Write stencil values */ - if (zoom) { - _swrast_write_zoomed_stencil_span(ctx, destx, desty, width, - destx, dy, stencil); - } - else { - _swrast_write_stencil_span( ctx, width, destx, dy, stencil ); - } - } - - if (overlapping) - free(tmpImage); -} - - -/** - * Try to do a fast 1:1 blit with memcpy. - * \return GL_TRUE if successful, GL_FALSE otherwise. - */ -GLboolean -swrast_fast_copy_pixels(struct gl_context *ctx, - GLint srcX, GLint srcY, GLsizei width, GLsizei height, - GLint dstX, GLint dstY, GLenum type) -{ - struct gl_framebuffer *srcFb = ctx->ReadBuffer; - struct gl_framebuffer *dstFb = ctx->DrawBuffer; - struct gl_renderbuffer *srcRb, *dstRb; - GLint row; - GLuint pixelBytes, widthInBytes; - GLubyte *srcMap, *dstMap; - GLint srcRowStride, dstRowStride; - - if (type == GL_COLOR) { - srcRb = srcFb->_ColorReadBuffer; - dstRb = dstFb->_ColorDrawBuffer; - } - else if (type == GL_STENCIL) { - srcRb = srcFb->Attachment[BUFFER_STENCIL].Renderbuffer; - dstRb = dstFb->Attachment[BUFFER_STENCIL].Renderbuffer; - } - else if (type == GL_DEPTH) { - srcRb = srcFb->Attachment[BUFFER_DEPTH].Renderbuffer; - dstRb = dstFb->Attachment[BUFFER_DEPTH].Renderbuffer; - } - - /* src and dst renderbuffers must be same format */ - if (!srcRb || !dstRb || srcRb->Format != dstRb->Format) { - return GL_FALSE; - } - - /* clipping not supported */ - if (srcX < 0 || srcX + width > (GLint) srcFb->Width || - srcY < 0 || srcY + height > (GLint) srcFb->Height || - dstX < dstFb->_Xmin || dstX + width > dstFb->_Xmax || - dstY < dstFb->_Ymin || dstY + height > dstFb->_Ymax) { - return GL_FALSE; - } - - pixelBytes = _mesa_get_format_bytes(srcRb->Format); - widthInBytes = width * pixelBytes; - - if (srcRb == dstRb) { - /* map whole buffer for read/write */ - /* XXX we could be clever and just map the union region of the - * source and dest rects. - */ - GLubyte *map; - GLint rowStride; - - ctx->Driver.MapRenderbuffer(ctx, srcRb, 0, 0, - srcRb->Width, srcRb->Height, - GL_MAP_READ_BIT | GL_MAP_WRITE_BIT, - &map, &rowStride); - if (!map) { - _mesa_error(ctx, GL_OUT_OF_MEMORY, "glCopyPixels"); - return GL_TRUE; /* don't retry with slow path */ - } - - srcMap = map + srcY * rowStride + srcX * pixelBytes; - dstMap = map + dstY * rowStride + dstX * pixelBytes; - - /* this handles overlapping copies */ - if (srcY < dstY) { - /* copy in reverse (top->down) order */ - srcMap += rowStride * (height - 1); - dstMap += rowStride * (height - 1); - srcRowStride = -rowStride; - dstRowStride = -rowStride; - } - else { - /* copy in normal (bottom->up) order */ - srcRowStride = rowStride; - dstRowStride = rowStride; - } - } - else { - /* different src/dst buffers */ - ctx->Driver.MapRenderbuffer(ctx, srcRb, srcX, srcY, - width, height, - GL_MAP_READ_BIT, &srcMap, &srcRowStride); - if (!srcMap) { - _mesa_error(ctx, GL_OUT_OF_MEMORY, "glCopyPixels"); - return GL_TRUE; /* don't retry with slow path */ - } - ctx->Driver.MapRenderbuffer(ctx, dstRb, dstX, dstY, - width, height, - GL_MAP_WRITE_BIT, &dstMap, &dstRowStride); - if (!dstMap) { - ctx->Driver.UnmapRenderbuffer(ctx, srcRb); - _mesa_error(ctx, GL_OUT_OF_MEMORY, "glCopyPixels"); - return GL_TRUE; /* don't retry with slow path */ - } - } - - for (row = 0; row < height; row++) { - /* memmove() in case of overlap */ - memmove(dstMap, srcMap, widthInBytes); - dstMap += dstRowStride; - srcMap += srcRowStride; - } - - ctx->Driver.UnmapRenderbuffer(ctx, srcRb); - if (dstRb != srcRb) { - ctx->Driver.UnmapRenderbuffer(ctx, dstRb); - } - - return GL_TRUE; -} - - -/** - * Find/map the renderbuffer that we'll be reading from. - * The swrast_render_start() function only maps the drawing buffers, - * not the read buffer. - */ -static struct gl_renderbuffer * -map_readbuffer(struct gl_context *ctx, GLenum type) -{ - struct gl_framebuffer *fb = ctx->ReadBuffer; - struct gl_renderbuffer *rb; - struct swrast_renderbuffer *srb; - - switch (type) { - case GL_COLOR: - rb = fb->Attachment[fb->_ColorReadBufferIndex].Renderbuffer; - break; - case GL_DEPTH: - rb = fb->Attachment[BUFFER_DEPTH].Renderbuffer; - break; - case GL_STENCIL: - rb = fb->Attachment[BUFFER_STENCIL].Renderbuffer; - break; - default: - return NULL; - } - - srb = swrast_renderbuffer(rb); - - if (!srb || srb->Map) { - /* no buffer, or buffer is mapped already, we're done */ - return NULL; - } - - ctx->Driver.MapRenderbuffer(ctx, rb, - 0, 0, rb->Width, rb->Height, - GL_MAP_READ_BIT, - &srb->Map, &srb->RowStride); - - return rb; -} - - -/** - * Do software-based glCopyPixels. - * By time we get here, all parameters will have been error-checked. - */ -void -_swrast_CopyPixels( struct gl_context *ctx, - GLint srcx, GLint srcy, GLsizei width, GLsizei height, - GLint destx, GLint desty, GLenum type ) -{ - SWcontext *swrast = SWRAST_CONTEXT(ctx); - struct gl_renderbuffer *rb; - - if (swrast->NewState) - _swrast_validate_derived( ctx ); - - if (!(SWRAST_CONTEXT(ctx)->_RasterMask != 0x0 || - ctx->Pixel.ZoomX != 1.0F || - ctx->Pixel.ZoomY != 1.0F || - ctx->_ImageTransferState) && - swrast_fast_copy_pixels(ctx, srcx, srcy, width, height, destx, desty, - type)) { - /* all done */ - return; - } - - swrast_render_start(ctx); - rb = map_readbuffer(ctx, type); - - switch (type) { - case GL_COLOR: - copy_rgba_pixels( ctx, srcx, srcy, width, height, destx, desty ); - break; - case GL_DEPTH: - copy_depth_pixels( ctx, srcx, srcy, width, height, destx, desty ); - break; - case GL_STENCIL: - copy_stencil_pixels( ctx, srcx, srcy, width, height, destx, desty ); - break; - default: - _mesa_problem(ctx, "unexpected type in _swrast_CopyPixels"); - } - - swrast_render_finish(ctx); - - if (rb) { - struct swrast_renderbuffer *srb = swrast_renderbuffer(rb); - ctx->Driver.UnmapRenderbuffer(ctx, rb); - srb->Map = NULL; - } -} diff --git a/dll/opengl/mesa/swrast/s_depth.c b/dll/opengl/mesa/swrast/s_depth.c deleted file mode 100644 index a8b73a4004f..00000000000 --- a/dll/opengl/mesa/swrast/s_depth.c +++ /dev/null @@ -1,556 +0,0 @@ -/* - * Mesa 3-D graphics library - * Version: 7.2.1 - * - * Copyright (C) 1999-2008 Brian Paul All Rights Reserved. - * - * Permission is hereby granted, free of charge, to any person obtaining a - * copy of this software and associated documentation files (the "Software"), - * to deal in the Software without restriction, including without limitation - * the rights to use, copy, modify, merge, publish, distribute, sublicense, - * and/or sell copies of the Software, and to permit persons to whom the - * Software is furnished to do so, subject to the following conditions: - * - * The above copyright notice and this permission notice shall be included - * in all copies or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS - * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL - * BRIAN PAUL BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN - * AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN - * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. - */ - -#include - -#define Z_TEST(COMPARE) \ - do { \ - GLuint i; \ - for (i = 0; i < n; i++) { \ - if (mask[i]) { \ - if (COMPARE) { \ - /* pass */ \ - if (write) { \ - zbuffer[i] = zfrag[i]; \ - } \ - passed++; \ - } \ - else { \ - /* fail */ \ - mask[i] = 0; \ - } \ - } \ - } \ - } while (0) - - -/** - * Do depth test for an array of 16-bit Z values. - * @param zbuffer array of Z buffer values (16-bit) - * @param zfrag array of fragment Z values (use 16-bit in 32-bit uint) - * @param mask which fragments are alive, killed afterward - * @return number of fragments which pass the test. - */ -static GLuint -depth_test_span16( struct gl_context *ctx, GLuint n, - GLushort zbuffer[], const GLuint zfrag[], GLubyte mask[] ) -{ - const GLboolean write = ctx->Depth.Mask; - GLuint passed = 0; - - /* switch cases ordered from most frequent to less frequent */ - switch (ctx->Depth.Func) { - case GL_LESS: - Z_TEST(zfrag[i] < zbuffer[i]); - break; - case GL_LEQUAL: - Z_TEST(zfrag[i] <= zbuffer[i]); - break; - case GL_GEQUAL: - Z_TEST(zfrag[i] >= zbuffer[i]); - break; - case GL_GREATER: - Z_TEST(zfrag[i] > zbuffer[i]); - break; - case GL_NOTEQUAL: - Z_TEST(zfrag[i] != zbuffer[i]); - break; - case GL_EQUAL: - Z_TEST(zfrag[i] == zbuffer[i]); - break; - case GL_ALWAYS: - Z_TEST(1); - break; - case GL_NEVER: - memset(mask, 0, n * sizeof(GLubyte)); - break; - default: - _mesa_problem(ctx, "Bad depth func in depth_test_span16"); - } - - return passed; -} - - -/** - * Do depth test for an array of 32-bit Z values. - * @param zbuffer array of Z buffer values (32-bit) - * @param zfrag array of fragment Z values (use 32-bits in 32-bit uint) - * @param mask which fragments are alive, killed afterward - * @return number of fragments which pass the test. - */ -static GLuint -depth_test_span32( struct gl_context *ctx, GLuint n, - GLuint zbuffer[], const GLuint zfrag[], GLubyte mask[]) -{ - const GLboolean write = ctx->Depth.Mask; - GLuint passed = 0; - - /* switch cases ordered from most frequent to less frequent */ - switch (ctx->Depth.Func) { - case GL_LESS: - Z_TEST(zfrag[i] < zbuffer[i]); - break; - case GL_LEQUAL: - Z_TEST(zfrag[i] <= zbuffer[i]); - break; - case GL_GEQUAL: - Z_TEST(zfrag[i] >= zbuffer[i]); - break; - case GL_GREATER: - Z_TEST(zfrag[i] > zbuffer[i]); - break; - case GL_NOTEQUAL: - Z_TEST(zfrag[i] != zbuffer[i]); - break; - case GL_EQUAL: - Z_TEST(zfrag[i] == zbuffer[i]); - break; - case GL_ALWAYS: - Z_TEST(1); - break; - case GL_NEVER: - memset(mask, 0, n * sizeof(GLubyte)); - break; - default: - _mesa_problem(ctx, "Bad depth func in depth_test_span32"); - } - - return passed; -} - - -/** - * Get array of 32-bit z values from the depth buffer. With clipping. - * Note: the returned values are always in the range [0, 2^32-1]. - */ -static void -get_z32_values(struct gl_context *ctx, struct gl_renderbuffer *rb, - GLuint count, const GLint x[], const GLint y[], - GLuint zbuffer[]) -{ - struct swrast_renderbuffer *srb = swrast_renderbuffer(rb); - const GLint w = rb->Width, h = rb->Height; - const GLubyte *map = _swrast_pixel_address(rb, 0, 0); - GLuint i; - - if (rb->Format == MESA_FORMAT_Z32) { - const GLint rowStride = srb->RowStride; - for (i = 0; i < count; i++) { - if (x[i] >= 0 && y[i] >= 0 && x[i] < w && y[i] < h) { - zbuffer[i] = *((GLuint *) (map + y[i] * rowStride + x[i] * 4)); - } - } - } - else { - const GLint bpp = _mesa_get_format_bytes(rb->Format); - const GLint rowStride = srb->RowStride; - for (i = 0; i < count; i++) { - if (x[i] >= 0 && y[i] >= 0 && x[i] < w && y[i] < h) { - const GLubyte *src = map + y[i] * rowStride+ x[i] * bpp; - _mesa_unpack_uint_z_row(rb->Format, 1, src, &zbuffer[i]); - } - } - } -} - - -/** - * Put an array of 32-bit z values into the depth buffer. - * Note: the z values are always in the range [0, 2^32-1]. - */ -static void -put_z32_values(struct gl_context *ctx, struct gl_renderbuffer *rb, - GLuint count, const GLint x[], const GLint y[], - const GLuint zvalues[], const GLubyte mask[]) -{ - struct swrast_renderbuffer *srb = swrast_renderbuffer(rb); - const GLint w = rb->Width, h = rb->Height; - GLubyte *map = _swrast_pixel_address(rb, 0, 0); - GLuint i; - - if (rb->Format == MESA_FORMAT_Z32) { - const GLint rowStride = srb->RowStride; - for (i = 0; i < count; i++) { - if (mask[i] && x[i] >= 0 && y[i] >= 0 && x[i] < w && y[i] < h) { - GLuint *dst = (GLuint *) (map + y[i] * rowStride + x[i] * 4); - *dst = zvalues[i]; - } - } - } - else { - gl_pack_uint_z_func packZ = _mesa_get_pack_uint_z_func(rb->Format); - const GLint bpp = _mesa_get_format_bytes(rb->Format); - const GLint rowStride = srb->RowStride; - for (i = 0; i < count; i++) { - if (mask[i] && x[i] >= 0 && y[i] >= 0 && x[i] < w && y[i] < h) { - void *dst = map + y[i] * rowStride + x[i] * bpp; - packZ(zvalues + i, dst); - } - } - } -} - - -/** - * Apply depth (Z) buffer testing to the span. - * \return approx number of pixels that passed (only zero is reliable) - */ -GLuint -_swrast_depth_test_span(struct gl_context *ctx, SWspan *span) -{ - struct gl_framebuffer *fb = ctx->DrawBuffer; - struct gl_renderbuffer *rb = fb->Attachment[BUFFER_DEPTH].Renderbuffer; - const GLint bpp = _mesa_get_format_bytes(rb->Format); - void *zStart; - const GLuint count = span->end; - const GLuint *fragZ = span->array->z; - GLubyte *mask = span->array->mask; - void *zBufferVals; - GLuint *zBufferTemp = NULL; - GLuint passed; - GLuint zBits = _mesa_get_format_bits(rb->Format, GL_DEPTH_BITS); - GLboolean ztest16 = GL_FALSE; - - if (span->arrayMask & SPAN_XY) - zStart = NULL; - else - zStart = _swrast_pixel_address(rb, span->x, span->y); - - if (rb->Format == MESA_FORMAT_Z16 && !(span->arrayMask & SPAN_XY)) { - /* directly read/write row of 16-bit Z values */ - zBufferVals = zStart; - ztest16 = GL_TRUE; - } - else if (rb->Format == MESA_FORMAT_Z32 && !(span->arrayMask & SPAN_XY)) { - /* directly read/write row of 32-bit Z values */ - zBufferVals = zStart; - } - else { - /* copy Z buffer values into temp buffer (32-bit Z values) */ - zBufferTemp = (GLuint *) malloc(count * sizeof(GLuint)); - if (!zBufferTemp) - return 0; - - if (span->arrayMask & SPAN_XY) { - get_z32_values(ctx, rb, count, - span->array->x, span->array->y, zBufferTemp); - } - else { - _mesa_unpack_uint_z_row(rb->Format, count, zStart, zBufferTemp); - } - - if (zBits == 24) { - GLuint i; - /* Convert depth buffer values from 32 to 24 bits to match the - * fragment Z values generated by rasterization. - */ - for (i = 0; i < count; i++) { - zBufferTemp[i] >>= 8; - } - } - else if (zBits == 16) { - GLuint i; - /* Convert depth buffer values from 32 to 16 bits */ - for (i = 0; i < count; i++) { - zBufferTemp[i] >>= 16; - } - } - else { - assert(zBits == 32); - } - - zBufferVals = zBufferTemp; - } - - /* do the depth test either with 16 or 32-bit values */ - if (ztest16) - passed = depth_test_span16(ctx, count, zBufferVals, fragZ, mask); - else - passed = depth_test_span32(ctx, count, zBufferVals, fragZ, mask); - - if (zBufferTemp) { - /* need to write temp Z values back into the buffer */ - - /* Convert depth buffer values back to 32-bit values. The least - * significant bits don't matter since they'll get dropped when - * they're packed back into the depth buffer. - */ - if (zBits == 24) { - GLuint i; - for (i = 0; i < count; i++) { - zBufferTemp[i] = (zBufferTemp[i] << 8); - } - } - else if (zBits == 16) { - GLuint i; - for (i = 0; i < count; i++) { - zBufferTemp[i] = zBufferTemp[i] << 16; - } - } - - if (span->arrayMask & SPAN_XY) { - /* random locations */ - put_z32_values(ctx, rb, count, span->array->x, span->array->y, - zBufferTemp, mask); - } - else { - /* horizontal row */ - gl_pack_uint_z_func packZ = _mesa_get_pack_uint_z_func(rb->Format); - GLubyte *dst = zStart; - GLuint i; - for (i = 0; i < count; i++) { - if (mask[i]) { - packZ(&zBufferTemp[i], dst); - } - dst += bpp; - } - } - - free(zBufferTemp); - } - - if (passed < count) { - span->writeAll = GL_FALSE; - } - return passed; -} - - -/** - * GL_EXT_depth_bounds_test extension. - * Discard fragments depending on whether the corresponding Z-buffer - * values are outside the depth bounds test range. - * Note: we test the Z buffer values, not the fragment Z values! - * \return GL_TRUE if any fragments pass, GL_FALSE if no fragments pass - */ -GLboolean -_swrast_depth_bounds_test( struct gl_context *ctx, SWspan *span ) -{ - struct gl_framebuffer *fb = ctx->DrawBuffer; - struct gl_renderbuffer *rb = fb->Attachment[BUFFER_DEPTH].Renderbuffer; - GLubyte *zStart; - GLuint zMin = (GLuint) (ctx->Depth.BoundsMin * fb->_DepthMaxF + 0.5F); - GLuint zMax = (GLuint) (ctx->Depth.BoundsMax * fb->_DepthMaxF + 0.5F); - GLubyte *mask = span->array->mask; - const GLuint count = span->end; - GLuint i; - GLboolean anyPass = GL_FALSE; - GLuint zBufferTemp[MAX_WIDTH]; - const GLuint *zBufferVals; - - if (span->arrayMask & SPAN_XY) - zStart = NULL; - else - zStart = _swrast_pixel_address(rb, span->x, span->y); - - if (rb->Format == MESA_FORMAT_Z32 && !(span->arrayMask & SPAN_XY)) { - /* directly access 32-bit values in the depth buffer */ - zBufferVals = (const GLuint *) zStart; - } - else { - /* unpack Z values into a temporary array */ - if (span->arrayMask & SPAN_XY) { - get_z32_values(ctx, rb, count, span->array->x, span->array->y, - zBufferTemp); - } - else { - _mesa_unpack_uint_z_row(rb->Format, count, zStart, zBufferTemp); - } - zBufferVals = zBufferTemp; - } - - /* Now do the tests */ - for (i = 0; i < count; i++) { - if (mask[i]) { - if (zBufferVals[i] < zMin || zBufferVals[i] > zMax) - mask[i] = GL_FALSE; - else - anyPass = GL_TRUE; - } - } - - return anyPass; -} - - - -/**********************************************************************/ -/***** Read Depth Buffer *****/ -/**********************************************************************/ - - -/** - * Read a span of depth values from the given depth renderbuffer, returning - * the values as GLfloats. - * This function does clipping to prevent reading outside the depth buffer's - * bounds. - */ -void -_swrast_read_depth_span_float(struct gl_context *ctx, - struct gl_renderbuffer *rb, - GLint n, GLint x, GLint y, GLfloat depth[]) -{ - if (!rb) { - /* really only doing this to prevent FP exceptions later */ - memset(depth, 0, n * sizeof(GLfloat)); - return; - } - - if (y < 0 || y >= (GLint) rb->Height || - x + n <= 0 || x >= (GLint) rb->Width) { - /* span is completely outside framebuffer */ - memset(depth, 0, n * sizeof(GLfloat)); - return; - } - - if (x < 0) { - GLint dx = -x; - GLint i; - for (i = 0; i < dx; i++) - depth[i] = 0.0; - x = 0; - n -= dx; - depth += dx; - } - if (x + n > (GLint) rb->Width) { - GLint dx = x + n - (GLint) rb->Width; - GLint i; - for (i = 0; i < dx; i++) - depth[n - i - 1] = 0.0; - n -= dx; - } - if (n <= 0) { - return; - } - - _mesa_unpack_float_z_row(rb->Format, n, _swrast_pixel_address(rb, x, y), - depth); -} - - -/** - * Clear the given z/depth renderbuffer. If the buffer is a combined - * depth+stencil buffer, only the Z bits will be touched. - */ -void -_swrast_clear_depth_buffer(struct gl_context *ctx) -{ - struct gl_renderbuffer *rb = - ctx->DrawBuffer->Attachment[BUFFER_DEPTH].Renderbuffer; - GLint x, y, width, height; - GLubyte *map; - GLint rowStride, i, j; - GLbitfield mapMode; - - if (!rb || !ctx->Depth.Mask) { - /* no depth buffer, or writing to it is disabled */ - return; - } - - /* compute region to clear */ - x = ctx->DrawBuffer->_Xmin; - y = ctx->DrawBuffer->_Ymin; - width = ctx->DrawBuffer->_Xmax - ctx->DrawBuffer->_Xmin; - height = ctx->DrawBuffer->_Ymax - ctx->DrawBuffer->_Ymin; - - mapMode = GL_MAP_WRITE_BIT; - if (rb->Format == MESA_FORMAT_X8_Z24 || - rb->Format == MESA_FORMAT_Z24_X8) { - mapMode |= GL_MAP_READ_BIT; - } - - ctx->Driver.MapRenderbuffer(ctx, rb, x, y, width, height, - mapMode, &map, &rowStride); - if (!map) { - _mesa_error(ctx, GL_OUT_OF_MEMORY, "glClear(depth)"); - return; - } - - switch (rb->Format) { - case MESA_FORMAT_Z16: - { - GLfloat clear = (GLfloat) ctx->Depth.Clear; - GLushort clearVal = 0; - _mesa_pack_float_z_row(rb->Format, 1, &clear, &clearVal); - if (clearVal == 0xffff && width * 2 == rowStride) { - /* common case */ - memset(map, 0xff, width * height * 2); - } - else { - for (i = 0; i < height; i++) { - GLushort *row = (GLushort *) map; - for (j = 0; j < width; j++) { - row[j] = clearVal; - } - map += rowStride; - } - } - } - break; - case MESA_FORMAT_Z32: - { - GLfloat clear = (GLfloat) ctx->Depth.Clear; - GLuint clearVal = 0; - _mesa_pack_float_z_row(rb->Format, 1, &clear, &clearVal); - for (i = 0; i < height; i++) { - GLuint *row = (GLuint *) map; - for (j = 0; j < width; j++) { - row[j] = clearVal; - } - map += rowStride; - } - } - break; - case MESA_FORMAT_X8_Z24: - case MESA_FORMAT_Z24_X8: - { - GLfloat clear = (GLfloat) ctx->Depth.Clear; - GLuint clearVal = 0; - GLuint mask; - - if (rb->Format == MESA_FORMAT_X8_Z24) - mask = 0xff000000; - else - mask = 0xff; - - _mesa_pack_float_z_row(rb->Format, 1, &clear, &clearVal); - for (i = 0; i < height; i++) { - GLuint *row = (GLuint *) map; - for (j = 0; j < width; j++) { - row[j] = (row[j] & mask) | clearVal; - } - map += rowStride; - } - - } - break; - default: - _mesa_problem(ctx, "Unexpected depth buffer format %s" - " in _swrast_clear_depth_buffer()", - _mesa_get_format_name(rb->Format)); - } - - ctx->Driver.UnmapRenderbuffer(ctx, rb); -} diff --git a/dll/opengl/mesa/swrast/s_depth.h b/dll/opengl/mesa/swrast/s_depth.h deleted file mode 100644 index 05230d83879..00000000000 --- a/dll/opengl/mesa/swrast/s_depth.h +++ /dev/null @@ -1,53 +0,0 @@ -/* - * Mesa 3-D graphics library - * Version: 6.5.1 - * - * Copyright (C) 1999-2006 Brian Paul All Rights Reserved. - * - * Permission is hereby granted, free of charge, to any person obtaining a - * copy of this software and associated documentation files (the "Software"), - * to deal in the Software without restriction, including without limitation - * the rights to use, copy, modify, merge, publish, distribute, sublicense, - * and/or sell copies of the Software, and to permit persons to whom the - * Software is furnished to do so, subject to the following conditions: - * - * The above copyright notice and this permission notice shall be included - * in all copies or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS - * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL - * BRIAN PAUL BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN - * AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN - * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. - */ - - -#ifndef S_DEPTH_H -#define S_DEPTH_H - - -#include "main/glheader.h" -#include "s_span.h" - -struct gl_context; -struct gl_renderbuffer; - - -extern GLuint -_swrast_depth_test_span( struct gl_context *ctx, SWspan *span); - -extern GLboolean -_swrast_depth_bounds_test( struct gl_context *ctx, SWspan *span ); - - -extern void -_swrast_read_depth_span_float( struct gl_context *ctx, struct gl_renderbuffer *rb, - GLint n, GLint x, GLint y, GLfloat depth[] ); - -extern void -_swrast_clear_depth_buffer(struct gl_context *ctx); - - - -#endif diff --git a/dll/opengl/mesa/swrast/s_drawpix.c b/dll/opengl/mesa/swrast/s_drawpix.c deleted file mode 100644 index 06d9c94bfa4..00000000000 --- a/dll/opengl/mesa/swrast/s_drawpix.c +++ /dev/null @@ -1,520 +0,0 @@ -/* - * Mesa 3-D graphics library - * Version: 7.1 - * - * Copyright (C) 1999-2007 Brian Paul All Rights Reserved. - * - * Permission is hereby granted, free of charge, to any person obtaining a - * copy of this software and associated documentation files (the "Software"), - * to deal in the Software without restriction, including without limitation - * the rights to use, copy, modify, merge, publish, distribute, sublicense, - * and/or sell copies of the Software, and to permit persons to whom the - * Software is furnished to do so, subject to the following conditions: - * - * The above copyright notice and this permission notice shall be included - * in all copies or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS - * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL - * BRIAN PAUL BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN - * AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN - * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. - */ - -#include - -#include
- -/** - * Handle a common case of drawing GL_RGB/GL_UNSIGNED_BYTE into a - * MESA_FORMAT_XRGB888 or MESA_FORMAT_ARGB888 renderbuffer. - */ -static void -fast_draw_rgb_ubyte_pixels(struct gl_context *ctx, - struct gl_renderbuffer *rb, - GLint x, GLint y, - GLsizei width, GLsizei height, - const struct gl_pixelstore_attrib *unpack, - const GLvoid *pixels) -{ - const GLubyte *src = (const GLubyte *) - _mesa_image_address2d(unpack, pixels, width, - height, GL_RGB, GL_UNSIGNED_BYTE, 0, 0); - const GLint srcRowStride = _mesa_image_row_stride(unpack, width, - GL_RGB, GL_UNSIGNED_BYTE); - GLint i, j; - GLubyte *dst; - GLint dstRowStride; - - ctx->Driver.MapRenderbuffer(ctx, rb, x, y, width, height, - GL_MAP_WRITE_BIT, &dst, &dstRowStride); - - if (!dst) { - _mesa_error(ctx, GL_OUT_OF_MEMORY, "glDrawPixels"); - return; - } - - if (ctx->Pixel.ZoomY == -1.0f) { - dst = dst + (height - 1) * dstRowStride; - dstRowStride = -dstRowStride; - } - - for (i = 0; i < height; i++) { - GLuint *dst4 = (GLuint *) dst; - for (j = 0; j < width; j++) { - dst4[j] = PACK_COLOR_8888(0xff, src[j*3+0], src[j*3+1], src[j*3+2]); - } - dst += dstRowStride; - src += srcRowStride; - } - - ctx->Driver.UnmapRenderbuffer(ctx, rb); -} - - -/** - * Handle a common case of drawing GL_RGBA/GL_UNSIGNED_BYTE into a - * MESA_FORMAT_ARGB888 or MESA_FORMAT_xRGB888 renderbuffer. - */ -static void -fast_draw_rgba_ubyte_pixels(struct gl_context *ctx, - struct gl_renderbuffer *rb, - GLint x, GLint y, - GLsizei width, GLsizei height, - const struct gl_pixelstore_attrib *unpack, - const GLvoid *pixels) -{ - const GLubyte *src = (const GLubyte *) - _mesa_image_address2d(unpack, pixels, width, - height, GL_RGBA, GL_UNSIGNED_BYTE, 0, 0); - const GLint srcRowStride = - _mesa_image_row_stride(unpack, width, GL_RGBA, GL_UNSIGNED_BYTE); - GLint i, j; - GLubyte *dst; - GLint dstRowStride; - - ctx->Driver.MapRenderbuffer(ctx, rb, x, y, width, height, - GL_MAP_WRITE_BIT, &dst, &dstRowStride); - - if (!dst) { - _mesa_error(ctx, GL_OUT_OF_MEMORY, "glDrawPixels"); - return; - } - - if (ctx->Pixel.ZoomY == -1.0f) { - dst = dst + (height - 1) * dstRowStride; - dstRowStride = -dstRowStride; - } - - for (i = 0; i < height; i++) { - GLuint *dst4 = (GLuint *) dst; - for (j = 0; j < width; j++) { - dst4[j] = PACK_COLOR_8888(src[j*4+3], src[j*4+0], - src[j*4+1], src[j*4+2]); - } - dst += dstRowStride; - src += srcRowStride; - } - - ctx->Driver.UnmapRenderbuffer(ctx, rb); -} - - -/** - * Handle a common case of drawing a format/type combination that - * exactly matches the renderbuffer format. - */ -static void -fast_draw_generic_pixels(struct gl_context *ctx, - struct gl_renderbuffer *rb, - GLint x, GLint y, - GLsizei width, GLsizei height, - GLenum format, GLenum type, - const struct gl_pixelstore_attrib *unpack, - const GLvoid *pixels) -{ - const GLubyte *src = (const GLubyte *) - _mesa_image_address2d(unpack, pixels, width, - height, format, type, 0, 0); - const GLint srcRowStride = - _mesa_image_row_stride(unpack, width, format, type); - const GLint rowLength = width * _mesa_get_format_bytes(rb->Format); - GLint i; - GLubyte *dst; - GLint dstRowStride; - - ctx->Driver.MapRenderbuffer(ctx, rb, x, y, width, height, - GL_MAP_WRITE_BIT, &dst, &dstRowStride); - - if (!dst) { - _mesa_error(ctx, GL_OUT_OF_MEMORY, "glDrawPixels"); - return; - } - - if (ctx->Pixel.ZoomY == -1.0f) { - dst = dst + (height - 1) * dstRowStride; - dstRowStride = -dstRowStride; - } - - for (i = 0; i < height; i++) { - memcpy(dst, src, rowLength); - dst += dstRowStride; - src += srcRowStride; - } - - ctx->Driver.UnmapRenderbuffer(ctx, rb); -} - - -/** - * Try to do a fast and simple RGB(a) glDrawPixels. - * Return: GL_TRUE if success, GL_FALSE if slow path must be used instead - */ -static GLboolean -fast_draw_rgba_pixels(struct gl_context *ctx, GLint x, GLint y, - GLsizei width, GLsizei height, - GLenum format, GLenum type, - const struct gl_pixelstore_attrib *userUnpack, - const GLvoid *pixels) -{ - struct gl_renderbuffer *rb = ctx->DrawBuffer->_ColorDrawBuffer; - SWcontext *swrast = SWRAST_CONTEXT(ctx); - struct gl_pixelstore_attrib unpack; - - if (!rb) - return GL_TRUE; /* no-op */ - - if ((swrast->_RasterMask & ~CLIP_BIT) || - ctx->Texture._EnabledCoord || - userUnpack->SwapBytes || - ctx->Pixel.ZoomX != 1.0f || - fabsf(ctx->Pixel.ZoomY) != 1.0f || - ctx->_ImageTransferState) { - /* can't handle any of those conditions */ - return GL_FALSE; - } - - unpack = *userUnpack; - - /* clipping */ - if (!_mesa_clip_drawpixels(ctx, &x, &y, &width, &height, &unpack)) { - /* image was completely clipped: no-op, all done */ - return GL_TRUE; - } - - if (format == GL_RGB && - type == GL_UNSIGNED_BYTE && - (rb->Format == MESA_FORMAT_XRGB8888 || - rb->Format == MESA_FORMAT_ARGB8888)) { - fast_draw_rgb_ubyte_pixels(ctx, rb, x, y, width, height, - &unpack, pixels); - return GL_TRUE; - } - - if (format == GL_RGBA && - type == GL_UNSIGNED_BYTE && - (rb->Format == MESA_FORMAT_XRGB8888 || - rb->Format == MESA_FORMAT_ARGB8888)) { - fast_draw_rgba_ubyte_pixels(ctx, rb, x, y, width, height, - &unpack, pixels); - return GL_TRUE; - } - - if (_mesa_format_matches_format_and_type(rb->Format, format, type)) { - fast_draw_generic_pixels(ctx, rb, x, y, width, height, - format, type, &unpack, pixels); - return GL_TRUE; - } - - /* can't handle this pixel format and/or data type */ - return GL_FALSE; -} - - - -/* - * Draw stencil image. - */ -static void -draw_stencil_pixels( struct gl_context *ctx, GLint x, GLint y, - GLsizei width, GLsizei height, - GLenum type, - const struct gl_pixelstore_attrib *unpack, - const GLvoid *pixels ) -{ - const GLboolean zoom = ctx->Pixel.ZoomX != 1.0 || ctx->Pixel.ZoomY != 1.0; - const GLenum destType = GL_UNSIGNED_BYTE; - GLint skipPixels; - - /* if width > MAX_WIDTH, have to process image in chunks */ - skipPixels = 0; - while (skipPixels < width) { - const GLint spanX = x + skipPixels; - const GLint spanWidth = MIN2(width - skipPixels, MAX_WIDTH); - GLint row; - for (row = 0; row < height; row++) { - const GLint spanY = y + row; - GLubyte values[MAX_WIDTH]; - const GLvoid *source = _mesa_image_address2d(unpack, pixels, - width, height, - GL_STENCIL_INDEX, type, - row, skipPixels); - _mesa_unpack_stencil_span(ctx, spanWidth, destType, values, - type, source, unpack, - ctx->_ImageTransferState); - if (zoom) { - _swrast_write_zoomed_stencil_span(ctx, x, y, spanWidth, - spanX, spanY, values); - } - else { - _swrast_write_stencil_span(ctx, spanWidth, spanX, spanY, values); - } - } - skipPixels += spanWidth; - } -} - - -/* - * Draw depth image. - */ -static void -draw_depth_pixels( struct gl_context *ctx, GLint x, GLint y, - GLsizei width, GLsizei height, - GLenum type, - const struct gl_pixelstore_attrib *unpack, - const GLvoid *pixels ) -{ - const GLboolean scaleOrBias - = ctx->Pixel.DepthScale != 1.0 || ctx->Pixel.DepthBias != 0.0; - const GLboolean zoom = ctx->Pixel.ZoomX != 1.0 || ctx->Pixel.ZoomY != 1.0; - SWspan span; - - INIT_SPAN(span, GL_BITMAP); - span.arrayMask = SPAN_Z; - _swrast_span_default_attribs(ctx, &span); - - if (type == GL_UNSIGNED_SHORT - && ctx->DrawBuffer->Visual.depthBits == 16 - && !scaleOrBias - && !zoom - && width <= MAX_WIDTH - && !unpack->SwapBytes) { - /* Special case: directly write 16-bit depth values */ - GLint row; - for (row = 0; row < height; row++) { - const GLushort *zSrc = (const GLushort *) - _mesa_image_address2d(unpack, pixels, width, height, - GL_DEPTH_COMPONENT, type, row, 0); - GLint i; - for (i = 0; i < width; i++) - span.array->z[i] = zSrc[i]; - span.x = x; - span.y = y + row; - span.end = width; - _swrast_write_rgba_span(ctx, &span); - } - } - else if (type == GL_UNSIGNED_INT - && !scaleOrBias - && !zoom - && width <= MAX_WIDTH - && !unpack->SwapBytes) { - /* Special case: shift 32-bit values down to Visual.depthBits */ - const GLint shift = 32 - ctx->DrawBuffer->Visual.depthBits; - GLint row; - for (row = 0; row < height; row++) { - const GLuint *zSrc = (const GLuint *) - _mesa_image_address2d(unpack, pixels, width, height, - GL_DEPTH_COMPONENT, type, row, 0); - if (shift == 0) { - memcpy(span.array->z, zSrc, width * sizeof(GLuint)); - } - else { - GLint col; - for (col = 0; col < width; col++) - span.array->z[col] = zSrc[col] >> shift; - } - span.x = x; - span.y = y + row; - span.end = width; - _swrast_write_rgba_span(ctx, &span); - } - } - else { - /* General case */ - const GLuint depthMax = ctx->DrawBuffer->_DepthMax; - GLint skipPixels = 0; - - /* in case width > MAX_WIDTH do the copy in chunks */ - while (skipPixels < width) { - const GLint spanWidth = MIN2(width - skipPixels, MAX_WIDTH); - GLint row; - ASSERT(span.end <= MAX_WIDTH); - for (row = 0; row < height; row++) { - const GLvoid *zSrc = _mesa_image_address2d(unpack, - pixels, width, height, - GL_DEPTH_COMPONENT, type, - row, skipPixels); - - /* Set these for each row since the _swrast_write_* function may - * change them while clipping. - */ - span.x = x + skipPixels; - span.y = y + row; - span.end = spanWidth; - - _mesa_unpack_depth_span(ctx, spanWidth, - GL_UNSIGNED_INT, span.array->z, depthMax, - type, zSrc, unpack); - if (zoom) { - _swrast_write_zoomed_depth_span(ctx, x, y, &span); - } - else { - _swrast_write_rgba_span(ctx, &span); - } - } - skipPixels += spanWidth; - } - } -} - - - -/** - * Draw RGBA image. - */ -static void -draw_rgba_pixels( 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 ) -{ - const GLint imgX = x, imgY = y; - const GLboolean zoom = ctx->Pixel.ZoomX!=1.0 || ctx->Pixel.ZoomY!=1.0; - GLfloat *convImage = NULL; - GLbitfield transferOps = ctx->_ImageTransferState; - SWspan span; - - /* Try an optimized glDrawPixels first */ - if (fast_draw_rgba_pixels(ctx, x, y, width, height, format, type, - unpack, pixels)) { - return; - } - - swrast_render_start(ctx); - - INIT_SPAN(span, GL_BITMAP); - _swrast_span_default_attribs(ctx, &span); - span.arrayMask = SPAN_RGBA; - span.arrayAttribs = FRAG_BIT_COL; /* we're fill in COL0 attrib values */ - - if (_mesa_get_format_datatype(ctx->DrawBuffer->_ColorDrawBuffer->Format) != GL_FLOAT) { - /* need to clamp colors before applying fragment ops */ - transferOps |= IMAGE_CLAMP_BIT; - } - - /* - * General solution - */ - { - const GLbitfield interpMask = span.interpMask; - const GLbitfield arrayMask = span.arrayMask; - const GLint srcStride - = _mesa_image_row_stride(unpack, width, format, type); - GLint skipPixels = 0; - /* use span array for temp color storage */ - GLfloat *rgba = (GLfloat *) span.array->attribs[FRAG_ATTRIB_COL]; - - /* if the span is wider than MAX_WIDTH we have to do it in chunks */ - while (skipPixels < width) { - const GLint spanWidth = MIN2(width - skipPixels, MAX_WIDTH); - const GLubyte *source - = (const GLubyte *) _mesa_image_address2d(unpack, pixels, - width, height, format, - type, 0, skipPixels); - GLint row; - - for (row = 0; row < height; row++) { - /* get image row as float/RGBA */ - _mesa_unpack_color_span_float(ctx, spanWidth, GL_RGBA, rgba, - format, type, source, unpack, - transferOps); - /* Set these for each row since the _swrast_write_* functions - * may change them while clipping/rendering. - */ - span.array->ChanType = GL_FLOAT; - span.x = x + skipPixels; - span.y = y + row; - span.end = spanWidth; - span.arrayMask = arrayMask; - span.interpMask = interpMask; - if (zoom) { - _swrast_write_zoomed_rgba_span(ctx, imgX, imgY, &span, rgba); - } - else { - _swrast_write_rgba_span(ctx, &span); - } - - source += srcStride; - } /* for row */ - - skipPixels += spanWidth; - } /* while skipPixels < width */ - - /* XXX this is ugly/temporary, to undo above change */ - span.array->ChanType = CHAN_TYPE; - } - - if (convImage) { - free(convImage); - } - - swrast_render_finish(ctx); -} - -/** - * Execute software-based glDrawPixels. - * By time we get here, all error checking will have been done. - */ -void -_swrast_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 ) -{ - SWcontext *swrast = SWRAST_CONTEXT(ctx); - - if (ctx->NewState) - _mesa_update_state(ctx); - - if (swrast->NewState) - _swrast_validate_derived( ctx ); - - if (!pixels) { - return; - } - - /* - * By time we get here, all error checking should have been done. - */ - switch (format) { - case GL_STENCIL_INDEX: - swrast_render_start(ctx); - draw_stencil_pixels( ctx, x, y, width, height, type, unpack, pixels ); - swrast_render_finish(ctx); - break; - case GL_DEPTH_COMPONENT: - swrast_render_start(ctx); - draw_depth_pixels( ctx, x, y, width, height, type, unpack, pixels ); - swrast_render_finish(ctx); - break; - default: - /* all other formats should be color formats */ - draw_rgba_pixels(ctx, x, y, width, height, format, type, unpack, pixels); - } -} diff --git a/dll/opengl/mesa/swrast/s_feedback.c b/dll/opengl/mesa/swrast/s_feedback.c deleted file mode 100644 index 2916fac9363..00000000000 --- a/dll/opengl/mesa/swrast/s_feedback.c +++ /dev/null @@ -1,131 +0,0 @@ -/* - * Mesa 3-D graphics library - * Version: 7.0 - * - * Copyright (C) 1999-2007 Brian Paul All Rights Reserved. - * - * Permission is hereby granted, free of charge, to any person obtaining a - * copy of this software and associated documentation files (the "Software"), - * to deal in the Software without restriction, including without limitation - * the rights to use, copy, modify, merge, publish, distribute, sublicense, - * and/or sell copies of the Software, and to permit persons to whom the - * Software is furnished to do so, subject to the following conditions: - * - * The above copyright notice and this permission notice shall be included - * in all copies or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS - * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL - * BRIAN PAUL BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN - * AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN - * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. - */ - -#include - -#include
- -static void -feedback_vertex(struct gl_context * ctx, const SWvertex * v, const SWvertex * pv) -{ - GLfloat win[4]; - const GLfloat *vtc = v->attrib[FRAG_ATTRIB_TEX]; - const GLfloat *color = v->attrib[FRAG_ATTRIB_COL]; - - win[0] = v->attrib[FRAG_ATTRIB_WPOS][0]; - win[1] = v->attrib[FRAG_ATTRIB_WPOS][1]; - win[2] = v->attrib[FRAG_ATTRIB_WPOS][2] / ctx->DrawBuffer->_DepthMaxF; - win[3] = 1.0F / v->attrib[FRAG_ATTRIB_WPOS][3]; - - _mesa_feedback_vertex(ctx, win, color, vtc); -} - - -/* - * Put triangle in feedback buffer. - */ -void -_swrast_feedback_triangle(struct gl_context *ctx, const SWvertex *v0, - const SWvertex *v1, const SWvertex *v2) -{ - if (!_swrast_culltriangle(ctx, v0, v1, v2)) { - _mesa_feedback_token(ctx, (GLfloat) (GLint) GL_POLYGON_TOKEN); - _mesa_feedback_token(ctx, (GLfloat) 3); /* three vertices */ - - if (ctx->Light.ShadeModel == GL_SMOOTH) { - feedback_vertex(ctx, v0, v0); - feedback_vertex(ctx, v1, v1); - feedback_vertex(ctx, v2, v2); - } - else { - feedback_vertex(ctx, v0, v2); - feedback_vertex(ctx, v1, v2); - feedback_vertex(ctx, v2, v2); - } - } -} - - -void -_swrast_feedback_line(struct gl_context *ctx, const SWvertex *v0, - const SWvertex *v1) -{ - GLenum token = GL_LINE_TOKEN; - SWcontext *swrast = SWRAST_CONTEXT(ctx); - - if (swrast->StippleCounter == 0) - token = GL_LINE_RESET_TOKEN; - - _mesa_feedback_token(ctx, (GLfloat) (GLint) token); - - if (ctx->Light.ShadeModel == GL_SMOOTH) { - feedback_vertex(ctx, v0, v0); - feedback_vertex(ctx, v1, v1); - } - else { - feedback_vertex(ctx, v0, v1); - feedback_vertex(ctx, v1, v1); - } - - swrast->StippleCounter++; -} - - -void -_swrast_feedback_point(struct gl_context *ctx, const SWvertex *v) -{ - _mesa_feedback_token(ctx, (GLfloat) (GLint) GL_POINT_TOKEN); - feedback_vertex(ctx, v, v); -} - - -void -_swrast_select_triangle(struct gl_context *ctx, const SWvertex *v0, - const SWvertex *v1, const SWvertex *v2) -{ - if (!_swrast_culltriangle(ctx, v0, v1, v2)) { - const GLfloat zs = 1.0F / ctx->DrawBuffer->_DepthMaxF; - - _mesa_update_hitflag( ctx, v0->attrib[FRAG_ATTRIB_WPOS][2] * zs ); - _mesa_update_hitflag( ctx, v1->attrib[FRAG_ATTRIB_WPOS][2] * zs ); - _mesa_update_hitflag( ctx, v2->attrib[FRAG_ATTRIB_WPOS][2] * zs ); - } -} - - -void -_swrast_select_line(struct gl_context *ctx, const SWvertex *v0, const SWvertex *v1) -{ - const GLfloat zs = 1.0F / ctx->DrawBuffer->_DepthMaxF; - _mesa_update_hitflag( ctx, v0->attrib[FRAG_ATTRIB_WPOS][2] * zs ); - _mesa_update_hitflag( ctx, v1->attrib[FRAG_ATTRIB_WPOS][2] * zs ); -} - - -void -_swrast_select_point(struct gl_context *ctx, const SWvertex *v) -{ - const GLfloat zs = 1.0F / ctx->DrawBuffer->_DepthMaxF; - _mesa_update_hitflag( ctx, v->attrib[FRAG_ATTRIB_WPOS][2] * zs ); -} diff --git a/dll/opengl/mesa/swrast/s_feedback.h b/dll/opengl/mesa/swrast/s_feedback.h deleted file mode 100644 index 6bfd49735cc..00000000000 --- a/dll/opengl/mesa/swrast/s_feedback.h +++ /dev/null @@ -1,50 +0,0 @@ - -/* - * Mesa 3-D graphics library - * Version: 3.5 - * - * Copyright (C) 1999-2001 Brian Paul All Rights Reserved. - * - * Permission is hereby granted, free of charge, to any person obtaining a - * copy of this software and associated documentation files (the "Software"), - * to deal in the Software without restriction, including without limitation - * the rights to use, copy, modify, merge, publish, distribute, sublicense, - * and/or sell copies of the Software, and to permit persons to whom the - * Software is furnished to do so, subject to the following conditions: - * - * The above copyright notice and this permission notice shall be included - * in all copies or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS - * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL - * BRIAN PAUL BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN - * AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN - * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. - */ - - -#ifndef S_FEEDBACK_H -#define S_FEEDBACK_H - - -#include "swrast.h" - - -extern void _swrast_feedback_point( struct gl_context *ctx, const SWvertex *v ); - -extern void _swrast_feedback_line( struct gl_context *ctx, - const SWvertex *v1, const SWvertex *v2 ); - -extern void _swrast_feedback_triangle( struct gl_context *ctx, const SWvertex *v0, - const SWvertex *v1, const SWvertex *v2 ); - -extern void _swrast_select_point( struct gl_context *ctx, const SWvertex *v ); - -extern void _swrast_select_line( struct gl_context *ctx, - const SWvertex *v1, const SWvertex *v2 ); - -extern void _swrast_select_triangle( struct gl_context *ctx, const SWvertex *v0, - const SWvertex *v1, const SWvertex *v2 ); - -#endif diff --git a/dll/opengl/mesa/swrast/s_fog.c b/dll/opengl/mesa/swrast/s_fog.c deleted file mode 100644 index 29a56e0ba93..00000000000 --- a/dll/opengl/mesa/swrast/s_fog.c +++ /dev/null @@ -1,237 +0,0 @@ -/* - * Mesa 3-D graphics library - * Version: 6.5.2 - * - * Copyright (C) 1999-2006 Brian Paul All Rights Reserved. - * - * Permission is hereby granted, free of charge, to any person obtaining a - * copy of this software and associated documentation files (the "Software"), - * to deal in the Software without restriction, including without limitation - * the rights to use, copy, modify, merge, publish, distribute, sublicense, - * and/or sell copies of the Software, and to permit persons to whom the - * Software is furnished to do so, subject to the following conditions: - * - * The above copyright notice and this permission notice shall be included - * in all copies or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS - * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL - * BRIAN PAUL BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN - * AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN - * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. - */ - -#include - -/** - * Used to convert current raster distance to a fog factor in [0,1]. - */ -GLfloat -_swrast_z_to_fogfactor(struct gl_context *ctx, GLfloat z) -{ - GLfloat d, f; - - switch (ctx->Fog.Mode) { - case GL_LINEAR: - if (ctx->Fog.Start == ctx->Fog.End) - d = 1.0F; - else - d = 1.0F / (ctx->Fog.End - ctx->Fog.Start); - f = (ctx->Fog.End - z) * d; - return CLAMP(f, 0.0F, 1.0F); - case GL_EXP: - d = ctx->Fog.Density; - f = EXPF(-d * z); - f = CLAMP(f, 0.0F, 1.0F); - return f; - case GL_EXP2: - d = ctx->Fog.Density; - f = EXPF(-(d * d * z * z)); - f = CLAMP(f, 0.0F, 1.0F); - return f; - default: - _mesa_problem(ctx, "Bad fog mode in _swrast_z_to_fogfactor"); - return 0.0; - } -} - - -#define LINEAR_FOG(f, coord) f = (fogEnd - coord) * fogScale - -#define EXP_FOG(f, coord) f = EXPF(density * coord) - -#define EXP2_FOG(f, coord) \ -do { \ - GLfloat tmp = negDensitySquared * coord * coord; \ - if (tmp < FLT_MIN_10_EXP) \ - tmp = FLT_MIN_10_EXP; \ - f = EXPF(tmp); \ - } while(0) - - -#define BLEND_FOG(f, coord) f = coord - - - -/** - * Template code for computing fog blend factor and applying it to colors. - * \param TYPE either GLubyte, GLushort or GLfloat. - * \param COMPUTE_F code to compute the fog blend factor, f. - */ -#define FOG_LOOP(TYPE, FOG_FUNC) \ -if (span->arrayAttribs & FRAG_BIT_FOGC) { \ - GLuint i; \ - for (i = 0; i < span->end; i++) { \ - const GLfloat fogCoord = span->array->attribs[FRAG_ATTRIB_FOGC][i][0]; \ - const GLfloat c = FABSF(fogCoord); \ - GLfloat f, oneMinusF; \ - FOG_FUNC(f, c); \ - f = CLAMP(f, 0.0F, 1.0F); \ - oneMinusF = 1.0F - f; \ - rgba[i][RCOMP] = (TYPE) (f * rgba[i][RCOMP] + oneMinusF * rFog); \ - rgba[i][GCOMP] = (TYPE) (f * rgba[i][GCOMP] + oneMinusF * gFog); \ - rgba[i][BCOMP] = (TYPE) (f * rgba[i][BCOMP] + oneMinusF * bFog); \ - } \ -} \ -else { \ - const GLfloat fogStep = span->attrStepX[FRAG_ATTRIB_FOGC][0]; \ - GLfloat fogCoord = span->attrStart[FRAG_ATTRIB_FOGC][0]; \ - const GLfloat wStep = span->attrStepX[FRAG_ATTRIB_WPOS][3]; \ - GLfloat w = span->attrStart[FRAG_ATTRIB_WPOS][3]; \ - GLuint i; \ - for (i = 0; i < span->end; i++) { \ - const GLfloat c = FABSF(fogCoord) / w; \ - GLfloat f, oneMinusF; \ - FOG_FUNC(f, c); \ - f = CLAMP(f, 0.0F, 1.0F); \ - oneMinusF = 1.0F - f; \ - rgba[i][RCOMP] = (TYPE) (f * rgba[i][RCOMP] + oneMinusF * rFog); \ - rgba[i][GCOMP] = (TYPE) (f * rgba[i][GCOMP] + oneMinusF * gFog); \ - rgba[i][BCOMP] = (TYPE) (f * rgba[i][BCOMP] + oneMinusF * bFog); \ - fogCoord += fogStep; \ - w += wStep; \ - } \ -} - -/** - * Apply fog to a span of RGBA pixels. - * The fog value are either in the span->array->fog array or interpolated from - * the fog/fogStep values. - * They fog values are either fog coordinates (Z) or fog blend factors. - * _PreferPixelFog should be in sync with that state! - */ -void -_swrast_fog_rgba_span( const struct gl_context *ctx, SWspan *span ) -{ - const SWcontext *swrast = CONST_SWRAST_CONTEXT(ctx); - GLfloat rFog, gFog, bFog; - - ASSERT(swrast->_FogEnabled); - ASSERT(span->arrayMask & SPAN_RGBA); - - /* compute (scaled) fog color */ - if (span->array->ChanType == GL_UNSIGNED_BYTE) { - rFog = ctx->Fog.Color[RCOMP] * 255.0F; - gFog = ctx->Fog.Color[GCOMP] * 255.0F; - bFog = ctx->Fog.Color[BCOMP] * 255.0F; - } - else if (span->array->ChanType == GL_UNSIGNED_SHORT) { - rFog = ctx->Fog.Color[RCOMP] * 65535.0F; - gFog = ctx->Fog.Color[GCOMP] * 65535.0F; - bFog = ctx->Fog.Color[BCOMP] * 65535.0F; - } - else { - rFog = ctx->Fog.Color[RCOMP]; - gFog = ctx->Fog.Color[GCOMP]; - bFog = ctx->Fog.Color[BCOMP]; - } - - if (swrast->_PreferPixelFog) { - /* The span's fog values are fog coordinates, now compute blend factors - * and blend the fragment colors with the fog color. - */ - switch (ctx->Fog.Mode) { - case GL_LINEAR: - { - const GLfloat fogEnd = ctx->Fog.End; - const GLfloat fogScale = (ctx->Fog.Start == ctx->Fog.End) - ? 1.0F : 1.0F / (ctx->Fog.End - ctx->Fog.Start); - if (span->array->ChanType == GL_UNSIGNED_BYTE) { - GLubyte (*rgba)[4] = span->array->rgba8; - FOG_LOOP(GLubyte, LINEAR_FOG); - } - else if (span->array->ChanType == GL_UNSIGNED_SHORT) { - GLushort (*rgba)[4] = span->array->rgba16; - FOG_LOOP(GLushort, LINEAR_FOG); - } - else { - GLfloat (*rgba)[4] = span->array->attribs[FRAG_ATTRIB_COL]; - ASSERT(span->array->ChanType == GL_FLOAT); - FOG_LOOP(GLfloat, LINEAR_FOG); - } - } - break; - - case GL_EXP: - { - const GLfloat density = -ctx->Fog.Density; - if (span->array->ChanType == GL_UNSIGNED_BYTE) { - GLubyte (*rgba)[4] = span->array->rgba8; - FOG_LOOP(GLubyte, EXP_FOG); - } - else if (span->array->ChanType == GL_UNSIGNED_SHORT) { - GLushort (*rgba)[4] = span->array->rgba16; - FOG_LOOP(GLushort, EXP_FOG); - } - else { - GLfloat (*rgba)[4] = span->array->attribs[FRAG_ATTRIB_COL]; - ASSERT(span->array->ChanType == GL_FLOAT); - FOG_LOOP(GLfloat, EXP_FOG); - } - } - break; - - case GL_EXP2: - { - const GLfloat negDensitySquared = -ctx->Fog.Density * ctx->Fog.Density; - if (span->array->ChanType == GL_UNSIGNED_BYTE) { - GLubyte (*rgba)[4] = span->array->rgba8; - FOG_LOOP(GLubyte, EXP2_FOG); - } - else if (span->array->ChanType == GL_UNSIGNED_SHORT) { - GLushort (*rgba)[4] = span->array->rgba16; - FOG_LOOP(GLushort, EXP2_FOG); - } - else { - GLfloat (*rgba)[4] = span->array->attribs[FRAG_ATTRIB_COL]; - ASSERT(span->array->ChanType == GL_FLOAT); - FOG_LOOP(GLfloat, EXP2_FOG); - } - } - break; - - default: - _mesa_problem(ctx, "Bad fog mode in _swrast_fog_rgba_span"); - return; - } - } - else { - /* The span's fog start/step/array values are blend factors in [0,1]. - * They were previously computed per-vertex. - */ - if (span->array->ChanType == GL_UNSIGNED_BYTE) { - GLubyte (*rgba)[4] = span->array->rgba8; - FOG_LOOP(GLubyte, BLEND_FOG); - } - else if (span->array->ChanType == GL_UNSIGNED_SHORT) { - GLushort (*rgba)[4] = span->array->rgba16; - FOG_LOOP(GLushort, BLEND_FOG); - } - else { - GLfloat (*rgba)[4] = span->array->attribs[FRAG_ATTRIB_COL]; - ASSERT(span->array->ChanType == GL_FLOAT); - FOG_LOOP(GLfloat, BLEND_FOG); - } - } -} diff --git a/dll/opengl/mesa/swrast/s_fog.h b/dll/opengl/mesa/swrast/s_fog.h deleted file mode 100644 index 9f93b705084..00000000000 --- a/dll/opengl/mesa/swrast/s_fog.h +++ /dev/null @@ -1,42 +0,0 @@ - -/* - * Mesa 3-D graphics library - * Version: 4.1 - * - * Copyright (C) 1999-2002 Brian Paul All Rights Reserved. - * - * Permission is hereby granted, free of charge, to any person obtaining a - * copy of this software and associated documentation files (the "Software"), - * to deal in the Software without restriction, including without limitation - * the rights to use, copy, modify, merge, publish, distribute, sublicense, - * and/or sell copies of the Software, and to permit persons to whom the - * Software is furnished to do so, subject to the following conditions: - * - * The above copyright notice and this permission notice shall be included - * in all copies or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS - * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL - * BRIAN PAUL BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN - * AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN - * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. - */ - - -#ifndef S_FOG_H -#define S_FOG_H - - -#include "main/glheader.h" -#include "s_span.h" - -struct gl_context; - -extern GLfloat -_swrast_z_to_fogfactor(struct gl_context *ctx, GLfloat z); - -extern void -_swrast_fog_rgba_span( const struct gl_context *ctx, SWspan *span ); - -#endif diff --git a/dll/opengl/mesa/swrast/s_lines.c b/dll/opengl/mesa/swrast/s_lines.c deleted file mode 100644 index 7694cd61e4a..00000000000 --- a/dll/opengl/mesa/swrast/s_lines.c +++ /dev/null @@ -1,218 +0,0 @@ -/* - * Mesa 3-D graphics library - * Version: 7.1 - * - * Copyright (C) 1999-2007 Brian Paul All Rights Reserved. - * - * Permission is hereby granted, free of charge, to any person obtaining a - * copy of this software and associated documentation files (the "Software"), - * to deal in the Software without restriction, including without limitation - * the rights to use, copy, modify, merge, publish, distribute, sublicense, - * and/or sell copies of the Software, and to permit persons to whom the - * Software is furnished to do so, subject to the following conditions: - * - * The above copyright notice and this permission notice shall be included - * in all copies or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS - * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL - * BRIAN PAUL BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN - * AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN - * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. - */ - -#include - -/* - * Init the mask[] array to implement a line stipple. - */ -static void -compute_stipple_mask( struct gl_context *ctx, GLuint len, GLubyte mask[] ) -{ - SWcontext *swrast = SWRAST_CONTEXT(ctx); - GLuint i; - - for (i = 0; i < len; i++) { - GLuint bit = (swrast->StippleCounter / ctx->Line.StippleFactor) & 0xf; - if ((1 << bit) & ctx->Line.StipplePattern) { - mask[i] = GL_TRUE; - } - else { - mask[i] = GL_FALSE; - } - swrast->StippleCounter++; - } -} - - -/* - * To draw a wide line we can simply redraw the span N times, side by side. - */ -static void -draw_wide_line( struct gl_context *ctx, SWspan *span, GLboolean xMajor ) -{ - const GLint width = (GLint) CLAMP(ctx->Line.Width, - ctx->Const.MinLineWidth, - ctx->Const.MaxLineWidth); - GLint start; - - ASSERT(span->end < MAX_WIDTH); - - if (width & 1) - start = width / 2; - else - start = width / 2 - 1; - - if (xMajor) { - GLint *y = span->array->y; - GLuint i; - GLint w; - for (w = 0; w < width; w++) { - if (w == 0) { - for (i = 0; i < span->end; i++) - y[i] -= start; - } - else { - for (i = 0; i < span->end; i++) - y[i]++; - } - _swrast_write_rgba_span(ctx, span); - } - } - else { - GLint *x = span->array->x; - GLuint i; - GLint w; - for (w = 0; w < width; w++) { - if (w == 0) { - for (i = 0; i < span->end; i++) - x[i] -= start; - } - else { - for (i = 0; i < span->end; i++) - x[i]++; - } - _swrast_write_rgba_span(ctx, span); - } - } -} - - - -/**********************************************************************/ -/***** Rasterization *****/ -/**********************************************************************/ - -/* Simple RGBA index line (no stipple, width=1, no Z, no fog, no tex)*/ -#define NAME simple_no_z_rgba_line -#define INTERP_RGBA -#define RENDER_SPAN(span) _swrast_write_rgba_span(ctx, &span); -#include "s_linetemp.h" - - -/* Z, fog, wide, stipple RGBA line */ -#define NAME rgba_line -#define INTERP_RGBA -#define INTERP_Z -#define RENDER_SPAN(span) \ - if (ctx->Line.StippleFlag) { \ - span.arrayMask |= SPAN_MASK; \ - compute_stipple_mask(ctx, span.end, span.array->mask); \ - } \ - if (ctx->Line.Width > 1.0) { \ - draw_wide_line(ctx, &span, (GLboolean)(dx > dy)); \ - } \ - else { \ - _swrast_write_rgba_span(ctx, &span); \ - } -#include "s_linetemp.h" - - -/* General-purpose line (any/all features). */ -#define NAME general_line -#define INTERP_RGBA -#define INTERP_Z -#define INTERP_ATTRIBS -#define RENDER_SPAN(span) \ - if (ctx->Line.StippleFlag) { \ - span.arrayMask |= SPAN_MASK; \ - compute_stipple_mask(ctx, span.end, span.array->mask); \ - } \ - if (ctx->Line.Width > 1.0) { \ - draw_wide_line(ctx, &span, (GLboolean)(dx > dy)); \ - } \ - else { \ - _swrast_write_rgba_span(ctx, &span); \ - } -#include "s_linetemp.h" - - - -#ifdef DEBUG - -/* record the current line function name */ -static const char *lineFuncName = NULL; - -#define USE(lineFunc) \ -do { \ - lineFuncName = #lineFunc; \ - /*printf("%s\n", lineFuncName);*/ \ - swrast->Line = lineFunc; \ -} while (0) - -#else - -#define USE(lineFunc) swrast->Line = lineFunc - -#endif - - - -/** - * Determine which line drawing function to use given the current - * rendering context. - * - * Please update the summary flag _SWRAST_NEW_LINE if you add or remove - * tests to this code. - */ -void -_swrast_choose_line( struct gl_context *ctx ) -{ - SWcontext *swrast = SWRAST_CONTEXT(ctx); - - if (ctx->RenderMode == GL_RENDER) { - if (ctx->Line.SmoothFlag) { - /* antialiased lines */ - _swrast_choose_aa_line_function(ctx); - ASSERT(swrast->Line); - } - else if (ctx->Texture._EnabledCoord - || swrast->_FogEnabled) { - USE(general_line); - } - else if (ctx->Depth.Test - || ctx->Line.Width != 1.0 - || ctx->Line.StippleFlag) { - /* no texture, but Z, fog, width>1, stipple, etc. */ -#if CHAN_BITS == 32 - USE(general_line); -#else - USE(rgba_line); -#endif - } - else { - ASSERT(!ctx->Depth.Test); - ASSERT(ctx->Line.Width == 1.0); - /* simple lines */ - USE(simple_no_z_rgba_line); - } - } - else if (ctx->RenderMode == GL_FEEDBACK) { - USE(_swrast_feedback_line); - } - else { - ASSERT(ctx->RenderMode == GL_SELECT); - USE(_swrast_select_line); - } -} diff --git a/dll/opengl/mesa/swrast/s_lines.h b/dll/opengl/mesa/swrast/s_lines.h deleted file mode 100644 index a4c98a8558b..00000000000 --- a/dll/opengl/mesa/swrast/s_lines.h +++ /dev/null @@ -1,41 +0,0 @@ - -/* - * Mesa 3-D graphics library - * Version: 3.5 - * - * Copyright (C) 1999-2001 Brian Paul All Rights Reserved. - * - * Permission is hereby granted, free of charge, to any person obtaining a - * copy of this software and associated documentation files (the "Software"), - * to deal in the Software without restriction, including without limitation - * the rights to use, copy, modify, merge, publish, distribute, sublicense, - * and/or sell copies of the Software, and to permit persons to whom the - * Software is furnished to do so, subject to the following conditions: - * - * The above copyright notice and this permission notice shall be included - * in all copies or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS - * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL - * BRIAN PAUL BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN - * AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN - * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. - */ - - -#ifndef S_LINES_H -#define S_LINES_H - -#include "swrast.h" - -void -_swrast_choose_line( struct gl_context *ctx ); - -void -_swrast_add_spec_terms_line( struct gl_context *ctx, - const SWvertex *v0, - const SWvertex *v1 ); - - -#endif diff --git a/dll/opengl/mesa/swrast/s_linetemp.h b/dll/opengl/mesa/swrast/s_linetemp.h deleted file mode 100644 index 6f369eea3a5..00000000000 --- a/dll/opengl/mesa/swrast/s_linetemp.h +++ /dev/null @@ -1,388 +0,0 @@ -/* - * Mesa 3-D graphics library - * Version: 7.0 - * - * Copyright (C) 1999-2007 Brian Paul All Rights Reserved. - * - * Permission is hereby granted, free of charge, to any person obtaining a - * copy of this software and associated documentation files (the "Software"), - * to deal in the Software without restriction, including without limitation - * the rights to use, copy, modify, merge, publish, distribute, sublicense, - * and/or sell copies of the Software, and to permit persons to whom the - * Software is furnished to do so, subject to the following conditions: - * - * The above copyright notice and this permission notice shall be included - * in all copies or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS - * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL - * BRIAN PAUL BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN - * AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN - * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. - */ - - -/* - * Line Rasterizer Template - * - * This file is #include'd to generate custom line rasterizers. - * - * The following macros may be defined to indicate what auxillary information - * must be interplated along the line: - * INTERP_Z - if defined, interpolate Z values - * INTERP_ATTRIBS - if defined, interpolate attribs (texcoords, varying, etc) - * - * When one can directly address pixels in the color buffer the following - * macros can be defined and used to directly compute pixel addresses during - * rasterization (see pixelPtr): - * PIXEL_TYPE - the datatype of a pixel (GLubyte, GLushort, GLuint) - * BYTES_PER_ROW - number of bytes per row in the color buffer - * PIXEL_ADDRESS(X,Y) - returns the address of pixel at (X,Y) where - * Y==0 at bottom of screen and increases upward. - * - * Similarly, for direct depth buffer access, this type is used for depth - * buffer addressing: - * DEPTH_TYPE - either GLushort or GLuint - * - * Optionally, one may provide one-time setup code - * SETUP_CODE - code which is to be executed once per line - * - * To actually "plot" each pixel the PLOT macro must be defined... - * PLOT(X,Y) - code to plot a pixel. Example: - * if (Z < *zPtr) { - * *zPtr = Z; - * color = pack_rgb( FixedToInt(r0), FixedToInt(g0), - * FixedToInt(b0) ); - * put_pixel( X, Y, color ); - * } - * - * This code was designed for the origin to be in the lower-left corner. - * - */ - - -static void -NAME( struct gl_context *ctx, const SWvertex *vert0, const SWvertex *vert1 ) -{ - const SWcontext *swrast = SWRAST_CONTEXT(ctx); - SWspan span; - GLuint interpFlags = 0; - GLint x0 = (GLint) vert0->attrib[FRAG_ATTRIB_WPOS][0]; - GLint x1 = (GLint) vert1->attrib[FRAG_ATTRIB_WPOS][0]; - GLint y0 = (GLint) vert0->attrib[FRAG_ATTRIB_WPOS][1]; - GLint y1 = (GLint) vert1->attrib[FRAG_ATTRIB_WPOS][1]; - GLint dx, dy; - GLint numPixels; - GLint xstep, ystep; -#if defined(DEPTH_TYPE) - const GLint depthBits = ctx->DrawBuffer->Visual.depthBits; - const GLint fixedToDepthShift = depthBits <= 16 ? FIXED_SHIFT : 0; - struct gl_renderbuffer *zrb = ctx->DrawBuffer->Attachment[BUFFER_DEPTH].Renderbuffer; -#define FixedToDepth(F) ((F) >> fixedToDepthShift) - GLint zPtrXstep, zPtrYstep; - DEPTH_TYPE *zPtr; -#elif defined(INTERP_Z) - const GLint depthBits = ctx->DrawBuffer->Visual.depthBits; -#endif -#ifdef PIXEL_ADDRESS - PIXEL_TYPE *pixelPtr; - GLint pixelXstep, pixelYstep; -#endif - -#ifdef SETUP_CODE - SETUP_CODE -#endif - - (void) swrast; - - /* Cull primitives with malformed coordinates. - */ - { - GLfloat tmp = vert0->attrib[FRAG_ATTRIB_WPOS][0] + vert0->attrib[FRAG_ATTRIB_WPOS][1] - + vert1->attrib[FRAG_ATTRIB_WPOS][0] + vert1->attrib[FRAG_ATTRIB_WPOS][1]; - if (IS_INF_OR_NAN(tmp)) - return; - } - - /* - printf("%s():\n", __FUNCTION__); - printf(" (%f, %f, %f) -> (%f, %f, %f)\n", - vert0->attrib[FRAG_ATTRIB_WPOS][0], - vert0->attrib[FRAG_ATTRIB_WPOS][1], - vert0->attrib[FRAG_ATTRIB_WPOS][2], - vert1->attrib[FRAG_ATTRIB_WPOS][0], - vert1->attrib[FRAG_ATTRIB_WPOS][1], - vert1->attrib[FRAG_ATTRIB_WPOS][2]); - printf(" (%d, %d, %d) -> (%d, %d, %d)\n", - vert0->color[0], vert0->color[1], vert0->color[2], - vert1->color[0], vert1->color[1], vert1->color[2]); - printf(" (%d, %d, %d) -> (%d, %d, %d)\n", - vert0->specular[0], vert0->specular[1], vert0->specular[2], - vert1->specular[0], vert1->specular[1], vert1->specular[2]); - */ - -/* - * Despite being clipped to the view volume, the line's window coordinates - * may just lie outside the window bounds. That is, if the legal window - * coordinates are [0,W-1][0,H-1], it's possible for x==W and/or y==H. - * This quick and dirty code nudges the endpoints inside the window if - * necessary. - */ -#ifdef CLIP_HACK - { - GLint w = ctx->DrawBuffer->Width; - GLint h = ctx->DrawBuffer->Height; - if ((x0==w) | (x1==w)) { - if ((x0==w) & (x1==w)) - return; - x0 -= x0==w; - x1 -= x1==w; - } - if ((y0==h) | (y1==h)) { - if ((y0==h) & (y1==h)) - return; - y0 -= y0==h; - y1 -= y1==h; - } - } -#endif - - dx = x1 - x0; - dy = y1 - y0; - if (dx == 0 && dy == 0) - return; - -#ifdef DEPTH_TYPE - zPtr = (DEPTH_TYPE *) _swrast_pixel_address(zrb, x0, y0); -#endif -#ifdef PIXEL_ADDRESS - pixelPtr = (PIXEL_TYPE *) PIXEL_ADDRESS(x0,y0); -#endif - - if (dx<0) { - dx = -dx; /* make positive */ - xstep = -1; -#ifdef DEPTH_TYPE - zPtrXstep = -((GLint)sizeof(DEPTH_TYPE)); -#endif -#ifdef PIXEL_ADDRESS - pixelXstep = -((GLint)sizeof(PIXEL_TYPE)); -#endif - } - else { - xstep = 1; -#ifdef DEPTH_TYPE - zPtrXstep = ((GLint)sizeof(DEPTH_TYPE)); -#endif -#ifdef PIXEL_ADDRESS - pixelXstep = ((GLint)sizeof(PIXEL_TYPE)); -#endif - } - - if (dy<0) { - dy = -dy; /* make positive */ - ystep = -1; -#ifdef DEPTH_TYPE - zPtrYstep = -((GLint) (ctx->DrawBuffer->Width * sizeof(DEPTH_TYPE))); -#endif -#ifdef PIXEL_ADDRESS - pixelYstep = BYTES_PER_ROW; -#endif - } - else { - ystep = 1; -#ifdef DEPTH_TYPE - zPtrYstep = (GLint) (ctx->DrawBuffer->Width * sizeof(DEPTH_TYPE)); -#endif -#ifdef PIXEL_ADDRESS - pixelYstep = -(BYTES_PER_ROW); -#endif - } - - ASSERT(dx >= 0); - ASSERT(dy >= 0); - - numPixels = MAX2(dx, dy); - - /* - * Span setup: compute start and step values for all interpolated values. - */ - interpFlags |= SPAN_RGBA; - if (ctx->Light.ShadeModel == GL_SMOOTH) { - span.red = ChanToFixed(vert0->color[0]); - span.green = ChanToFixed(vert0->color[1]); - span.blue = ChanToFixed(vert0->color[2]); - span.alpha = ChanToFixed(vert0->color[3]); - span.redStep = (ChanToFixed(vert1->color[0]) - span.red ) / numPixels; - span.greenStep = (ChanToFixed(vert1->color[1]) - span.green) / numPixels; - span.blueStep = (ChanToFixed(vert1->color[2]) - span.blue ) / numPixels; - span.alphaStep = (ChanToFixed(vert1->color[3]) - span.alpha) / numPixels; - } - else { - span.red = ChanToFixed(vert1->color[0]); - span.green = ChanToFixed(vert1->color[1]); - span.blue = ChanToFixed(vert1->color[2]); - span.alpha = ChanToFixed(vert1->color[3]); - span.redStep = 0; - span.greenStep = 0; - span.blueStep = 0; - span.alphaStep = 0; - } -#if defined(INTERP_Z) || defined(DEPTH_TYPE) - interpFlags |= SPAN_Z; - { - if (depthBits <= 16) { - span.z = FloatToFixed(vert0->attrib[FRAG_ATTRIB_WPOS][2]) + FIXED_HALF; - span.zStep = FloatToFixed( vert1->attrib[FRAG_ATTRIB_WPOS][2] - - vert0->attrib[FRAG_ATTRIB_WPOS][2]) / numPixels; - } - else { - /* don't use fixed point */ - span.z = (GLuint) vert0->attrib[FRAG_ATTRIB_WPOS][2]; - span.zStep = (GLint) (( vert1->attrib[FRAG_ATTRIB_WPOS][2] - - vert0->attrib[FRAG_ATTRIB_WPOS][2]) / numPixels); - } - } -#endif -#if defined(INTERP_ATTRIBS) - { - const GLfloat invLen = 1.0F / numPixels; - const GLfloat invw0 = vert0->attrib[FRAG_ATTRIB_WPOS][3]; - const GLfloat invw1 = vert1->attrib[FRAG_ATTRIB_WPOS][3]; - - span.attrStart[FRAG_ATTRIB_WPOS][3] = invw0; - span.attrStepX[FRAG_ATTRIB_WPOS][3] = (invw1 - invw0) * invLen; - span.attrStepY[FRAG_ATTRIB_WPOS][3] = 0.0; - - ATTRIB_LOOP_BEGIN - if (swrast->_InterpMode[attr] == GL_FLAT) { - COPY_4V(span.attrStart[attr], vert1->attrib[attr]); - ASSIGN_4V(span.attrStepX[attr], 0.0, 0.0, 0.0, 0.0); - } - else { - GLuint c; - for (c = 0; c < 4; c++) { - float da; - span.attrStart[attr][c] = invw0 * vert0->attrib[attr][c]; - da = (invw1 * vert1->attrib[attr][c]) - span.attrStart[attr][c]; - span.attrStepX[attr][c] = da * invLen; - } - } - ASSIGN_4V(span.attrStepY[attr], 0.0, 0.0, 0.0, 0.0); - ATTRIB_LOOP_END - } -#endif - - INIT_SPAN(span, GL_LINE); - span.end = numPixels; - span.interpMask = interpFlags; - span.arrayMask = SPAN_XY; - - - /* - * Draw - */ - - if (dx > dy) { - /*** X-major line ***/ - GLint i; - GLint errorInc = dy+dy; - GLint error = errorInc-dx; - GLint errorDec = error-dx; - - for (i = 0; i < dx; i++) { -#ifdef DEPTH_TYPE - GLuint Z = FixedToDepth(span.z); -#endif -#ifdef PLOT - PLOT( x0, y0 ); -#else - span.array->x[i] = x0; - span.array->y[i] = y0; -#endif - x0 += xstep; -#ifdef DEPTH_TYPE - zPtr = (DEPTH_TYPE *) ((GLubyte*) zPtr + zPtrXstep); - span.z += span.zStep; -#endif -#ifdef PIXEL_ADDRESS - pixelPtr = (PIXEL_TYPE*) ((GLubyte*) pixelPtr + pixelXstep); -#endif - if (error < 0) { - error += errorInc; - } - else { - error += errorDec; - y0 += ystep; -#ifdef DEPTH_TYPE - zPtr = (DEPTH_TYPE *) ((GLubyte*) zPtr + zPtrYstep); -#endif -#ifdef PIXEL_ADDRESS - pixelPtr = (PIXEL_TYPE*) ((GLubyte*) pixelPtr + pixelYstep); -#endif - } - } - } - else { - /*** Y-major line ***/ - GLint i; - GLint errorInc = dx+dx; - GLint error = errorInc-dy; - GLint errorDec = error-dy; - - for (i=0;ix[i] = x0; - span.array->y[i] = y0; -#endif - y0 += ystep; -#ifdef DEPTH_TYPE - zPtr = (DEPTH_TYPE *) ((GLubyte*) zPtr + zPtrYstep); - span.z += span.zStep; -#endif -#ifdef PIXEL_ADDRESS - pixelPtr = (PIXEL_TYPE*) ((GLubyte*) pixelPtr + pixelYstep); -#endif - if (error<0) { - error += errorInc; - } - else { - error += errorDec; - x0 += xstep; -#ifdef DEPTH_TYPE - zPtr = (DEPTH_TYPE *) ((GLubyte*) zPtr + zPtrXstep); -#endif -#ifdef PIXEL_ADDRESS - pixelPtr = (PIXEL_TYPE*) ((GLubyte*) pixelPtr + pixelXstep); -#endif - } - } - } - -#ifdef RENDER_SPAN - RENDER_SPAN( span ); -#endif - - (void)span; - -} - - -#undef NAME -#undef INTERP_Z -#undef INTERP_ATTRIBS -#undef PIXEL_ADDRESS -#undef PIXEL_TYPE -#undef DEPTH_TYPE -#undef BYTES_PER_ROW -#undef SETUP_CODE -#undef PLOT -#undef CLIP_HACK -#undef FixedToDepth -#undef RENDER_SPAN diff --git a/dll/opengl/mesa/swrast/s_logic.c b/dll/opengl/mesa/swrast/s_logic.c deleted file mode 100644 index ffc4a6fb8c6..00000000000 --- a/dll/opengl/mesa/swrast/s_logic.c +++ /dev/null @@ -1,209 +0,0 @@ -/* - * Mesa 3-D graphics library - * Version: 6.5.2 - * - * Copyright (C) 1999-2006 Brian Paul All Rights Reserved. - * - * Permission is hereby granted, free of charge, to any person obtaining a - * copy of this software and associated documentation files (the "Software"), - * to deal in the Software without restriction, including without limitation - * the rights to use, copy, modify, merge, publish, distribute, sublicense, - * and/or sell copies of the Software, and to permit persons to whom the - * Software is furnished to do so, subject to the following conditions: - * - * The above copyright notice and this permission notice shall be included - * in all copies or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS - * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL - * BRIAN PAUL BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN - * AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN - * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. - */ - -#include - -/** - * We do all logic ops on 4-byte GLuints. - * Depending on bytes per pixel, the mask array elements correspond to - * 1, 2 or 4 GLuints. - */ -#define LOGIC_OP_LOOP(MODE, MASKSTRIDE) \ -do { \ - GLuint i; \ - switch (MODE) { \ - case GL_CLEAR: \ - for (i = 0; i < n; i++) { \ - if (mask[i / MASKSTRIDE]) { \ - src[i] = 0; \ - } \ - } \ - break; \ - case GL_SET: \ - for (i = 0; i < n; i++) { \ - if (mask[i / MASKSTRIDE]) { \ - src[i] = ~0; \ - } \ - } \ - break; \ - case GL_COPY: \ - /* do nothing */ \ - break; \ - case GL_COPY_INVERTED: \ - for (i = 0; i < n; i++) { \ - if (mask[i / MASKSTRIDE]) { \ - src[i] = ~src[i]; \ - } \ - } \ - break; \ - case GL_NOOP: \ - for (i = 0; i < n; i++) { \ - if (mask[i / MASKSTRIDE]) { \ - src[i] = dest[i]; \ - } \ - } \ - break; \ - case GL_INVERT: \ - for (i = 0; i < n; i++) { \ - if (mask[i / MASKSTRIDE]) { \ - src[i] = ~dest[i]; \ - } \ - } \ - break; \ - case GL_AND: \ - for (i = 0; i < n; i++) { \ - if (mask[i / MASKSTRIDE]) { \ - src[i] &= dest[i]; \ - } \ - } \ - break; \ - case GL_NAND: \ - for (i = 0; i < n; i++) { \ - if (mask[i / MASKSTRIDE]) { \ - src[i] = ~(src[i] & dest[i]); \ - } \ - } \ - break; \ - case GL_OR: \ - for (i = 0; i < n; i++) { \ - if (mask[i / MASKSTRIDE]) { \ - src[i] |= dest[i]; \ - } \ - } \ - break; \ - case GL_NOR: \ - for (i = 0; i < n; i++) { \ - if (mask[i / MASKSTRIDE]) { \ - src[i] = ~(src[i] | dest[i]); \ - } \ - } \ - break; \ - case GL_XOR: \ - for (i = 0; i < n; i++) { \ - if (mask[i / MASKSTRIDE]) { \ - src[i] ^= dest[i]; \ - } \ - } \ - break; \ - case GL_EQUIV: \ - for (i = 0; i < n; i++) { \ - if (mask[i / MASKSTRIDE]) { \ - src[i] = ~(src[i] ^ dest[i]); \ - } \ - } \ - break; \ - case GL_AND_REVERSE: \ - for (i = 0; i < n; i++) { \ - if (mask[i / MASKSTRIDE]) { \ - src[i] = src[i] & ~dest[i]; \ - } \ - } \ - break; \ - case GL_AND_INVERTED: \ - for (i = 0; i < n; i++) { \ - if (mask[i / MASKSTRIDE]) { \ - src[i] = ~src[i] & dest[i]; \ - } \ - } \ - break; \ - case GL_OR_REVERSE: \ - for (i = 0; i < n; i++) { \ - if (mask[i / MASKSTRIDE]) { \ - src[i] = src[i] | ~dest[i]; \ - } \ - } \ - break; \ - case GL_OR_INVERTED: \ - for (i = 0; i < n; i++) { \ - if (mask[i / MASKSTRIDE]) { \ - src[i] = ~src[i] | dest[i]; \ - } \ - } \ - break; \ - default: \ - _mesa_problem(ctx, "bad logicop mode");\ - } \ -} while (0) - - - -static inline void -logicop_uint1(struct gl_context *ctx, GLuint n, GLuint src[], const GLuint dest[], - const GLubyte mask[]) -{ - LOGIC_OP_LOOP(ctx->Color.LogicOp, 1); -} - - -static inline void -logicop_uint2(struct gl_context *ctx, GLuint n, GLuint src[], const GLuint dest[], - const GLubyte mask[]) -{ - LOGIC_OP_LOOP(ctx->Color.LogicOp, 2); -} - - -static inline void -logicop_uint4(struct gl_context *ctx, GLuint n, GLuint src[], const GLuint dest[], - const GLubyte mask[]) -{ - LOGIC_OP_LOOP(ctx->Color.LogicOp, 4); -} - - - -/** - * Apply the current logic operator to a span of RGBA pixels. - * We can handle horizontal runs of pixels (spans) or arrays of x/y - * pixel coordinates. - */ -void -_swrast_logicop_rgba_span(struct gl_context *ctx, struct gl_renderbuffer *rb, - SWspan *span) -{ - void *rbPixels; - - ASSERT(span->end < MAX_WIDTH); - ASSERT(span->arrayMask & SPAN_RGBA); - - rbPixels = _swrast_get_dest_rgba(ctx, rb, span); - - if (span->array->ChanType == GL_UNSIGNED_BYTE) { - /* treat 4*GLubyte as GLuint */ - logicop_uint1(ctx, span->end, - (GLuint *) span->array->rgba8, - (const GLuint *) rbPixels, span->array->mask); - } - else if (span->array->ChanType == GL_UNSIGNED_SHORT) { - /* treat 2*GLushort as GLuint */ - logicop_uint2(ctx, 2 * span->end, - (GLuint *) span->array->rgba16, - (const GLuint *) rbPixels, span->array->mask); - } - else { - logicop_uint4(ctx, 4 * span->end, - (GLuint *) span->array->attribs[FRAG_ATTRIB_COL], - (const GLuint *) rbPixels, span->array->mask); - } -} diff --git a/dll/opengl/mesa/swrast/s_logic.h b/dll/opengl/mesa/swrast/s_logic.h deleted file mode 100644 index 0a3adfca5ff..00000000000 --- a/dll/opengl/mesa/swrast/s_logic.h +++ /dev/null @@ -1,40 +0,0 @@ -/* - * Mesa 3-D graphics library - * Version: 6.5.2 - * - * Copyright (C) 1999-2006 Brian Paul All Rights Reserved. - * - * Permission is hereby granted, free of charge, to any person obtaining a - * copy of this software and associated documentation files (the "Software"), - * to deal in the Software without restriction, including without limitation - * the rights to use, copy, modify, merge, publish, distribute, sublicense, - * and/or sell copies of the Software, and to permit persons to whom the - * Software is furnished to do so, subject to the following conditions: - * - * The above copyright notice and this permission notice shall be included - * in all copies or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS - * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL - * BRIAN PAUL BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN - * AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN - * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. - */ - - -#ifndef S_LOGIC_H -#define S_LOGIC_H - - -#include "s_span.h" - -struct gl_context; -struct gl_renderbuffer; - -extern void -_swrast_logicop_rgba_span(struct gl_context *ctx, struct gl_renderbuffer *rb, - SWspan *span); - - -#endif diff --git a/dll/opengl/mesa/swrast/s_masking.c b/dll/opengl/mesa/swrast/s_masking.c deleted file mode 100644 index aa457a7b186..00000000000 --- a/dll/opengl/mesa/swrast/s_masking.c +++ /dev/null @@ -1,94 +0,0 @@ -/* - * Mesa 3-D graphics library - * Version: 6.5.2 - * - * Copyright (C) 1999-2006 Brian Paul All Rights Reserved. - * - * Permission is hereby granted, free of charge, to any person obtaining a - * copy of this software and associated documentation files (the "Software"), - * to deal in the Software without restriction, including without limitation - * the rights to use, copy, modify, merge, publish, distribute, sublicense, - * and/or sell copies of the Software, and to permit persons to whom the - * Software is furnished to do so, subject to the following conditions: - * - * The above copyright notice and this permission notice shall be included - * in all copies or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS - * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL - * BRIAN PAUL BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN - * AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN - * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. - */ - -/* - * Implement the effect of glColorMask and glIndexMask in software. - */ - -#include - -/** - * Apply the color mask to a span of rgba values. - */ -void -_swrast_mask_rgba_span(struct gl_context *ctx, struct gl_renderbuffer *rb, - SWspan *span) -{ - const GLuint n = span->end; - void *rbPixels; - - ASSERT(n < MAX_WIDTH); - ASSERT(span->arrayMask & SPAN_RGBA); - - rbPixels = _swrast_get_dest_rgba(ctx, rb, span); - - /* - * Do component masking. - * Note that we're not using span->array->mask[] here. We could... - */ - if (span->array->ChanType == GL_UNSIGNED_BYTE) { - /* treat 4xGLubyte as 1xGLuint */ - const GLuint srcMask = *((GLuint *) ctx->Color.ColorMask); - const GLuint dstMask = ~srcMask; - const GLuint *dst = (const GLuint *) rbPixels; - GLuint *src = (GLuint *) span->array->rgba8; - GLuint i; - for (i = 0; i < n; i++) { - src[i] = (src[i] & srcMask) | (dst[i] & dstMask); - } - } - else if (span->array->ChanType == GL_UNSIGNED_SHORT) { - /* 2-byte components */ - /* XXX try to use 64-bit arithmetic someday */ - const GLushort rMask = ctx->Color.ColorMask[RCOMP] ? 0xffff : 0x0; - const GLushort gMask = ctx->Color.ColorMask[GCOMP] ? 0xffff : 0x0; - const GLushort bMask = ctx->Color.ColorMask[BCOMP] ? 0xffff : 0x0; - const GLushort aMask = ctx->Color.ColorMask[ACOMP] ? 0xffff : 0x0; - const GLushort (*dst)[4] = (const GLushort (*)[4]) rbPixels; - GLushort (*src)[4] = span->array->rgba16; - GLuint i; - for (i = 0; i < n; i++) { - src[i][RCOMP] = (src[i][RCOMP] & rMask) | (dst[i][RCOMP] & ~rMask); - src[i][GCOMP] = (src[i][GCOMP] & gMask) | (dst[i][GCOMP] & ~gMask); - src[i][BCOMP] = (src[i][BCOMP] & bMask) | (dst[i][BCOMP] & ~bMask); - src[i][ACOMP] = (src[i][ACOMP] & aMask) | (dst[i][ACOMP] & ~aMask); - } - } - else { - /* 4-byte components */ - const GLuint rMask = ctx->Color.ColorMask[RCOMP] ? ~0x0 : 0x0; - const GLuint gMask = ctx->Color.ColorMask[GCOMP] ? ~0x0 : 0x0; - const GLuint bMask = ctx->Color.ColorMask[BCOMP] ? ~0x0 : 0x0; - const GLuint aMask = ctx->Color.ColorMask[ACOMP] ? ~0x0 : 0x0; - const GLuint (*dst)[4] = (const GLuint (*)[4]) rbPixels; - GLuint (*src)[4] = (GLuint (*)[4]) span->array->attribs[FRAG_ATTRIB_COL]; - GLuint i; - for (i = 0; i < n; i++) { - src[i][RCOMP] = (src[i][RCOMP] & rMask) | (dst[i][RCOMP] & ~rMask); - src[i][GCOMP] = (src[i][GCOMP] & gMask) | (dst[i][GCOMP] & ~gMask); - src[i][BCOMP] = (src[i][BCOMP] & bMask) | (dst[i][BCOMP] & ~bMask); - src[i][ACOMP] = (src[i][ACOMP] & aMask) | (dst[i][ACOMP] & ~aMask); - } - } -} diff --git a/dll/opengl/mesa/swrast/s_masking.h b/dll/opengl/mesa/swrast/s_masking.h deleted file mode 100644 index 87cce4691ea..00000000000 --- a/dll/opengl/mesa/swrast/s_masking.h +++ /dev/null @@ -1,41 +0,0 @@ -/* - * Mesa 3-D graphics library - * Version: 6.5.2 - * - * Copyright (C) 1999-2006 Brian Paul All Rights Reserved. - * - * Permission is hereby granted, free of charge, to any person obtaining a - * copy of this software and associated documentation files (the "Software"), - * to deal in the Software without restriction, including without limitation - * the rights to use, copy, modify, merge, publish, distribute, sublicense, - * and/or sell copies of the Software, and to permit persons to whom the - * Software is furnished to do so, subject to the following conditions: - * - * The above copyright notice and this permission notice shall be included - * in all copies or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS - * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL - * BRIAN PAUL BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN - * AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN - * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. - */ - - -#ifndef S_MASKING_H -#define S_MASKING_H - - -#include "main/glheader.h" -#include "s_span.h" - -struct gl_context; -struct gl_renderbuffer; - - -extern void -_swrast_mask_rgba_span(struct gl_context *ctx, struct gl_renderbuffer *rb, - SWspan *span); - -#endif diff --git a/dll/opengl/mesa/swrast/s_points.c b/dll/opengl/mesa/swrast/s_points.c deleted file mode 100644 index 93a3415cbdb..00000000000 --- a/dll/opengl/mesa/swrast/s_points.c +++ /dev/null @@ -1,522 +0,0 @@ -/* - * Mesa 3-D graphics library - * Version: 7.1 - * - * Copyright (C) 1999-2007 Brian Paul All Rights Reserved. - * - * Permission is hereby granted, free of charge, to any person obtaining a - * copy of this software and associated documentation files (the "Software"), - * to deal in the Software without restriction, including without limitation - * the rights to use, copy, modify, merge, publish, distribute, sublicense, - * and/or sell copies of the Software, and to permit persons to whom the - * Software is furnished to do so, subject to the following conditions: - * - * The above copyright notice and this permission notice shall be included - * in all copies or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS - * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL - * BRIAN PAUL BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN - * AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN - * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. - */ - -#include - -/** - * Used to cull points with invalid coords - */ -#define CULL_INVALID(V) \ - do { \ - float tmp = (V)->attrib[FRAG_ATTRIB_WPOS][0] \ - + (V)->attrib[FRAG_ATTRIB_WPOS][1]; \ - if (IS_INF_OR_NAN(tmp)) \ - return; \ - } while(0) - - - -/** - * Get/compute the point size. - * The size may come from a vertex shader, or computed with attentuation - * or just the glPointSize value. - * Must also clamp to user-defined range and implmentation limits. - */ -static inline GLfloat -get_size(const struct gl_context *ctx, const SWvertex *vert, GLboolean smoothed) -{ - GLfloat size; - - if (ctx->Point._Attenuated) { - /* use vertex's point size */ - size = vert->pointSize; - } - else { - /* use constant point size */ - size = ctx->Point.Size; - } - /* always clamp to user-specified limits */ - size = CLAMP(size, ctx->Point.MinSize, ctx->Point.MaxSize); - /* clamp to implementation limits */ - if (smoothed) - size = CLAMP(size, ctx->Const.MinPointSizeAA, ctx->Const.MaxPointSizeAA); - else - size = CLAMP(size, ctx->Const.MinPointSize, ctx->Const.MaxPointSize); - - return size; -} - - -/** - * Draw a point sprite - */ -static void -sprite_point(struct gl_context *ctx, const SWvertex *vert) -{ - SWcontext *swrast = SWRAST_CONTEXT(ctx); - SWspan span; - GLfloat size; - GLuint tCoords; - GLfloat t0, dtdy; - - CULL_INVALID(vert); - - /* z coord */ - if (ctx->DrawBuffer->Visual.depthBits <= 16) - span.z = FloatToFixed(vert->attrib[FRAG_ATTRIB_WPOS][2] + 0.5F); - else - span.z = (GLuint) (vert->attrib[FRAG_ATTRIB_WPOS][2] + 0.5F); - span.zStep = 0; - - size = get_size(ctx, vert, GL_FALSE); - - /* span init */ - INIT_SPAN(span, GL_POINT); - span.interpMask = SPAN_Z | SPAN_RGBA; - - span.red = ChanToFixed(vert->color[0]); - span.green = ChanToFixed(vert->color[1]); - span.blue = ChanToFixed(vert->color[2]); - span.alpha = ChanToFixed(vert->color[3]); - span.redStep = 0; - span.greenStep = 0; - span.blueStep = 0; - span.alphaStep = 0; - - /* need these for fragment programs */ - span.attrStart[FRAG_ATTRIB_WPOS][3] = 1.0F; - span.attrStepX[FRAG_ATTRIB_WPOS][3] = 0.0F; - span.attrStepY[FRAG_ATTRIB_WPOS][3] = 0.0F; - - { - GLfloat s, r, dsdx; - - /* texcoord / pointcoord interpolants */ - s = 0.0F; - dsdx = 1.0F / size; - if (ctx->Point.SpriteOrigin == GL_LOWER_LEFT) { - dtdy = 1.0F / size; - t0 = 0.5F * dtdy; - } - else { - /* GL_UPPER_LEFT */ - dtdy = -1.0F / size; - t0 = 1.0F + 0.5F * dtdy; - } - - ATTRIB_LOOP_BEGIN - if (attr == FRAG_ATTRIB_TEX) { - /* a texcoord attribute */ - if (ctx->Point.CoordReplace) { - tCoords = attr; - - if (ctx->Point.SpriteRMode == GL_ZERO) - r = 0.0F; - else if (ctx->Point.SpriteRMode == GL_S) - r = vert->attrib[attr][0]; - else /* GL_R */ - r = vert->attrib[attr][2]; - - span.attrStart[attr][0] = s; - span.attrStart[attr][1] = 0.0; /* overwritten below */ - span.attrStart[attr][2] = r; - span.attrStart[attr][3] = 1.0; - - span.attrStepX[attr][0] = dsdx; - span.attrStepX[attr][1] = 0.0; - span.attrStepX[attr][2] = 0.0; - span.attrStepX[attr][3] = 0.0; - - span.attrStepY[attr][0] = 0.0; - span.attrStepY[attr][1] = dtdy; - span.attrStepY[attr][2] = 0.0; - span.attrStepY[attr][3] = 0.0; - - continue; - } - } - else if (attr == FRAG_ATTRIB_PNTC) { - /* GLSL gl_PointCoord.xy (.zw undefined) */ - span.attrStart[FRAG_ATTRIB_PNTC][0] = 0.0; - span.attrStart[FRAG_ATTRIB_PNTC][1] = 0.0; /* t0 set below */ - span.attrStepX[FRAG_ATTRIB_PNTC][0] = dsdx; - span.attrStepX[FRAG_ATTRIB_PNTC][1] = 0.0; - span.attrStepY[FRAG_ATTRIB_PNTC][0] = 0.0; - span.attrStepY[FRAG_ATTRIB_PNTC][1] = dtdy; - tCoords = FRAG_ATTRIB_PNTC; - continue; - } - /* use vertex's texcoord/attrib */ - COPY_4V(span.attrStart[attr], vert->attrib[attr]); - ASSIGN_4V(span.attrStepX[attr], 0, 0, 0, 0); - ASSIGN_4V(span.attrStepY[attr], 0, 0, 0, 0); - ATTRIB_LOOP_END; - } - - /* compute pos, bounds and render */ - { - const GLfloat x = vert->attrib[FRAG_ATTRIB_WPOS][0]; - const GLfloat y = vert->attrib[FRAG_ATTRIB_WPOS][1]; - GLint iSize = (GLint) (size + 0.5F); - GLint xmin, xmax, ymin, ymax, iy; - GLint iRadius; - GLfloat tcoord = t0; - - iSize = MAX2(1, iSize); - iRadius = iSize / 2; - - if (iSize & 1) { - /* odd size */ - xmin = (GLint) (x - iRadius); - xmax = (GLint) (x + iRadius); - ymin = (GLint) (y - iRadius); - ymax = (GLint) (y + iRadius); - } - else { - /* even size */ - /* 0.501 factor allows conformance to pass */ - xmin = (GLint) (x + 0.501) - iRadius; - xmax = xmin + iSize - 1; - ymin = (GLint) (y + 0.501) - iRadius; - ymax = ymin + iSize - 1; - } - - /* render spans */ - for (iy = ymin; iy <= ymax; iy++) { - /* setup texcoord T for this row */ - span.attrStart[tCoords][1] = tcoord; - - /* these might get changed by span clipping */ - span.x = xmin; - span.y = iy; - span.end = xmax - xmin + 1; - - _swrast_write_rgba_span(ctx, &span); - - tcoord += dtdy; - } - } -} - - -/** - * Draw smooth/antialiased point. RGB or CI mode. - */ -static void -smooth_point(struct gl_context *ctx, const SWvertex *vert) -{ - SWcontext *swrast = SWRAST_CONTEXT(ctx); - SWspan span; - GLfloat size, alphaAtten; - - CULL_INVALID(vert); - - /* z coord */ - if (ctx->DrawBuffer->Visual.depthBits <= 16) - span.z = FloatToFixed(vert->attrib[FRAG_ATTRIB_WPOS][2] + 0.5F); - else - span.z = (GLuint) (vert->attrib[FRAG_ATTRIB_WPOS][2] + 0.5F); - span.zStep = 0; - - size = get_size(ctx, vert, GL_TRUE); - - /* alpha attenuation / fade factor */ - if (ctx->Multisample._Enabled) { - if (vert->pointSize >= ctx->Point.Threshold) { - alphaAtten = 1.0F; - } - else { - GLfloat dsize = vert->pointSize / ctx->Point.Threshold; - alphaAtten = dsize * dsize; - } - } - else { - alphaAtten = 1.0; - } - (void) alphaAtten; /* not used */ - - /* span init */ - INIT_SPAN(span, GL_POINT); - span.interpMask = SPAN_Z | SPAN_RGBA; - span.arrayMask = SPAN_COVERAGE | SPAN_MASK; - - span.red = ChanToFixed(vert->color[0]); - span.green = ChanToFixed(vert->color[1]); - span.blue = ChanToFixed(vert->color[2]); - span.alpha = ChanToFixed(vert->color[3]); - span.redStep = 0; - span.greenStep = 0; - span.blueStep = 0; - span.alphaStep = 0; - - /* need these for fragment programs */ - span.attrStart[FRAG_ATTRIB_WPOS][3] = 1.0F; - span.attrStepX[FRAG_ATTRIB_WPOS][3] = 0.0F; - span.attrStepY[FRAG_ATTRIB_WPOS][3] = 0.0F; - - ATTRIB_LOOP_BEGIN - COPY_4V(span.attrStart[attr], vert->attrib[attr]); - ASSIGN_4V(span.attrStepX[attr], 0, 0, 0, 0); - ASSIGN_4V(span.attrStepY[attr], 0, 0, 0, 0); - ATTRIB_LOOP_END - - /* compute pos, bounds and render */ - { - const GLfloat x = vert->attrib[FRAG_ATTRIB_WPOS][0]; - const GLfloat y = vert->attrib[FRAG_ATTRIB_WPOS][1]; - const GLfloat radius = 0.5F * size; - const GLfloat rmin = radius - 0.7071F; /* 0.7071 = sqrt(2)/2 */ - const GLfloat rmax = radius + 0.7071F; - const GLfloat rmin2 = MAX2(0.0F, rmin * rmin); - const GLfloat rmax2 = rmax * rmax; - const GLfloat cscale = 1.0F / (rmax2 - rmin2); - const GLint xmin = (GLint) (x - radius); - const GLint xmax = (GLint) (x + radius); - const GLint ymin = (GLint) (y - radius); - const GLint ymax = (GLint) (y + radius); - GLint ix, iy; - - for (iy = ymin; iy <= ymax; iy++) { - - /* these might get changed by span clipping */ - span.x = xmin; - span.y = iy; - span.end = xmax - xmin + 1; - - /* compute coverage for each pixel in span */ - for (ix = xmin; ix <= xmax; ix++) { - const GLfloat dx = ix - x + 0.5F; - const GLfloat dy = iy - y + 0.5F; - const GLfloat dist2 = dx * dx + dy * dy; - GLfloat coverage; - - if (dist2 < rmax2) { - if (dist2 >= rmin2) { - /* compute partial coverage */ - coverage = 1.0F - (dist2 - rmin2) * cscale; - } - else { - /* full coverage */ - coverage = 1.0F; - } - span.array->mask[ix - xmin] = 1; - } - else { - /* zero coverage - fragment outside the radius */ - coverage = 0.0; - span.array->mask[ix - xmin] = 0; - } - span.array->coverage[ix - xmin] = coverage; - } - - /* render span */ - _swrast_write_rgba_span(ctx, &span); - - } - } -} - - -/** - * Draw large (size >= 1) non-AA point. RGB or CI mode. - */ -static void -large_point(struct gl_context *ctx, const SWvertex *vert) -{ - SWcontext *swrast = SWRAST_CONTEXT(ctx); - SWspan span; - GLfloat size; - - CULL_INVALID(vert); - - /* z coord */ - if (ctx->DrawBuffer->Visual.depthBits <= 16) - span.z = FloatToFixed(vert->attrib[FRAG_ATTRIB_WPOS][2] + 0.5F); - else - span.z = (GLuint) (vert->attrib[FRAG_ATTRIB_WPOS][2] + 0.5F); - span.zStep = 0; - - size = get_size(ctx, vert, GL_FALSE); - - /* span init */ - INIT_SPAN(span, GL_POINT); - span.arrayMask = SPAN_XY; - - span.interpMask = SPAN_Z | SPAN_RGBA; - span.red = ChanToFixed(vert->color[0]); - span.green = ChanToFixed(vert->color[1]); - span.blue = ChanToFixed(vert->color[2]); - span.alpha = ChanToFixed(vert->color[3]); - span.redStep = 0; - span.greenStep = 0; - span.blueStep = 0; - span.alphaStep = 0; - - /* need these for fragment programs */ - span.attrStart[FRAG_ATTRIB_WPOS][3] = 1.0F; - span.attrStepX[FRAG_ATTRIB_WPOS][3] = 0.0F; - span.attrStepY[FRAG_ATTRIB_WPOS][3] = 0.0F; - - ATTRIB_LOOP_BEGIN - COPY_4V(span.attrStart[attr], vert->attrib[attr]); - ASSIGN_4V(span.attrStepX[attr], 0, 0, 0, 0); - ASSIGN_4V(span.attrStepY[attr], 0, 0, 0, 0); - ATTRIB_LOOP_END - - /* compute pos, bounds and render */ - { - const GLfloat x = vert->attrib[FRAG_ATTRIB_WPOS][0]; - const GLfloat y = vert->attrib[FRAG_ATTRIB_WPOS][1]; - GLint iSize = (GLint) (size + 0.5F); - GLint xmin, xmax, ymin, ymax, ix, iy; - GLint iRadius; - - iSize = MAX2(1, iSize); - iRadius = iSize / 2; - - if (iSize & 1) { - /* odd size */ - xmin = (GLint) (x - iRadius); - xmax = (GLint) (x + iRadius); - ymin = (GLint) (y - iRadius); - ymax = (GLint) (y + iRadius); - } - else { - /* even size */ - /* 0.501 factor allows conformance to pass */ - xmin = (GLint) (x + 0.501) - iRadius; - xmax = xmin + iSize - 1; - ymin = (GLint) (y + 0.501) - iRadius; - ymax = ymin + iSize - 1; - } - - /* generate fragments */ - span.end = 0; - for (iy = ymin; iy <= ymax; iy++) { - for (ix = xmin; ix <= xmax; ix++) { - span.array->x[span.end] = ix; - span.array->y[span.end] = iy; - span.end++; - } - } - assert(span.end <= MAX_WIDTH); - _swrast_write_rgba_span(ctx, &span); - } -} - - -/** - * Draw size=1, single-pixel point - */ -static void -pixel_point(struct gl_context *ctx, const SWvertex *vert) -{ - SWcontext *swrast = SWRAST_CONTEXT(ctx); - /* - * Note that unlike the other functions, we put single-pixel points - * into a special span array in order to render as many points as - * possible with a single _swrast_write_rgba_span() call. - */ - SWspan *span = &(swrast->PointSpan); - GLuint count; - - CULL_INVALID(vert); - - /* Span init */ - span->interpMask = 0; - span->arrayMask = SPAN_XY | SPAN_Z; - span->arrayMask |= SPAN_RGBA; - /*span->arrayMask |= SPAN_LAMBDA;*/ - span->arrayAttribs = swrast->_ActiveAttribMask; /* we'll produce these vals */ - - /* need these for fragment programs */ - span->attrStart[FRAG_ATTRIB_WPOS][3] = 1.0F; - span->attrStepX[FRAG_ATTRIB_WPOS][3] = 0.0F; - span->attrStepY[FRAG_ATTRIB_WPOS][3] = 0.0F; - - /* check if we need to flush */ - if (span->end >= MAX_WIDTH || - (swrast->_RasterMask & (BLEND_BIT | LOGIC_OP_BIT | MASKING_BIT))) { - if (span->end > 0) { - _swrast_write_rgba_span(ctx, span); - span->end = 0; - } - } - - count = span->end; - - /* fragment attributes */ - span->array->rgba[count][RCOMP] = vert->color[0]; - span->array->rgba[count][GCOMP] = vert->color[1]; - span->array->rgba[count][BCOMP] = vert->color[2]; - span->array->rgba[count][ACOMP] = vert->color[3]; - - ATTRIB_LOOP_BEGIN - COPY_4V(span->array->attribs[attr][count], vert->attrib[attr]); - ATTRIB_LOOP_END - - /* fragment position */ - span->array->x[count] = (GLint) vert->attrib[FRAG_ATTRIB_WPOS][0]; - span->array->y[count] = (GLint) vert->attrib[FRAG_ATTRIB_WPOS][1]; - span->array->z[count] = (GLint) (vert->attrib[FRAG_ATTRIB_WPOS][2] + 0.5F); - - span->end = count + 1; - ASSERT(span->end <= MAX_WIDTH); -} - - -/** - * Examine current state to determine which point drawing function to use. - */ -void -_swrast_choose_point(struct gl_context *ctx) -{ - SWcontext *swrast = SWRAST_CONTEXT(ctx); - const GLfloat size = CLAMP(ctx->Point.Size, - ctx->Point.MinSize, - ctx->Point.MaxSize); - - if (ctx->RenderMode == GL_RENDER) { - if (ctx->Point.PointSprite) { - swrast->Point = sprite_point; - } - else if (ctx->Point.SmoothFlag) { - swrast->Point = smooth_point; - } - else if (size > 1.0 || - ctx->Point._Attenuated) { - swrast->Point = large_point; - } - else { - swrast->Point = pixel_point; - } - } - else if (ctx->RenderMode == GL_FEEDBACK) { - swrast->Point = _swrast_feedback_point; - } - else { - /* GL_SELECT mode */ - swrast->Point = _swrast_select_point; - } -} diff --git a/dll/opengl/mesa/swrast/s_points.h b/dll/opengl/mesa/swrast/s_points.h deleted file mode 100644 index 0b6550e8018..00000000000 --- a/dll/opengl/mesa/swrast/s_points.h +++ /dev/null @@ -1,39 +0,0 @@ - -/* - * Mesa 3-D graphics library - * Version: 3.5 - * - * Copyright (C) 1999-2001 Brian Paul All Rights Reserved. - * - * Permission is hereby granted, free of charge, to any person obtaining a - * copy of this software and associated documentation files (the "Software"), - * to deal in the Software without restriction, including without limitation - * the rights to use, copy, modify, merge, publish, distribute, sublicense, - * and/or sell copies of the Software, and to permit persons to whom the - * Software is furnished to do so, subject to the following conditions: - * - * The above copyright notice and this permission notice shall be included - * in all copies or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS - * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL - * BRIAN PAUL BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN - * AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN - * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. - */ - - -#ifndef S_POINTS_H -#define S_POINTS_H - -#include "swrast.h" - -extern void -_swrast_choose_point( struct gl_context *ctx ); - -extern void -_swrast_add_spec_terms_point( struct gl_context *ctx, - const SWvertex *v0 ); - -#endif diff --git a/dll/opengl/mesa/swrast/s_renderbuffer.c b/dll/opengl/mesa/swrast/s_renderbuffer.c deleted file mode 100644 index 9c64eb50514..00000000000 --- a/dll/opengl/mesa/swrast/s_renderbuffer.c +++ /dev/null @@ -1,581 +0,0 @@ -/* - * Mesa 3-D graphics library - * Version: 6.5 - * - * Copyright (C) 1999-2006 Brian Paul All Rights Reserved. - * - * Permission is hereby granted, free of charge, to any person obtaining a - * copy of this software and associated documentation files (the "Software"), - * to deal in the Software without restriction, including without limitation - * the rights to use, copy, modify, merge, publish, distribute, sublicense, - * and/or sell copies of the Software, and to permit persons to whom the - * Software is furnished to do so, subject to the following conditions: - * - * The above copyright notice and this permission notice shall be included - * in all copies or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS - * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL - * BRIAN PAUL BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN - * AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN - * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. - */ - -/** - * Functions for allocating/managing software-based renderbuffers. - * Also, routines for reading/writing software-based renderbuffer data as - * ubytes, ushorts, uints, etc. - */ - -#include - -#include
-#include "s_renderbuffer.h" - -static -GLenum -_mesa_base_fb_format(struct gl_context *ctx, GLenum internalFormat) -{ - /* - * Notes: some formats such as alpha, luminance, etc. were added - * with GL_ARB_framebuffer_object. - */ - switch (internalFormat) { - case GL_RGB: - case GL_R3_G3_B2: - case GL_RGB4: - case GL_RGB5: - case GL_RGB8: - case GL_RGB10: - case GL_RGB12: - case GL_RGB16: - return GL_RGB; - case GL_RGBA: - case GL_RGBA2: - case GL_RGBA4: - case GL_RGB5_A1: - case GL_RGBA8: - case GL_RGB10_A2: - case GL_RGBA12: - case GL_RGBA16: - return GL_RGBA; - case GL_STENCIL_INDEX: - case GL_STENCIL_INDEX1_EXT: - case GL_STENCIL_INDEX4_EXT: - case GL_STENCIL_INDEX8_EXT: - case GL_STENCIL_INDEX16_EXT: - return GL_STENCIL_INDEX; - case GL_DEPTH_COMPONENT: - case GL_DEPTH_COMPONENT16: - case GL_DEPTH_COMPONENT24: - case GL_DEPTH_COMPONENT32: - return GL_DEPTH_COMPONENT; - - default: - return 0; - } -} - - -/** - * This is a software fallback for the gl_renderbuffer->AllocStorage - * function. - * Device drivers will typically override this function for the buffers - * which it manages (typically color buffers, Z and stencil). - * Other buffers (like software accumulation and aux buffers) which the driver - * doesn't manage can be handled with this function. - * - * This one multi-purpose function can allocate stencil, depth, accum, color - * or color-index buffers! - */ -static GLboolean -soft_renderbuffer_storage(struct gl_context *ctx, struct gl_renderbuffer *rb, - GLenum internalFormat, - GLuint width, GLuint height) -{ - struct swrast_renderbuffer *srb = swrast_renderbuffer(rb); - GLuint bpp; - - switch (internalFormat) { - case GL_RGB: - case GL_R3_G3_B2: - case GL_RGB4: - case GL_RGB5: - case GL_RGB8: - case GL_RGB10: - case GL_RGB12: - case GL_RGB16: - rb->Format = MESA_FORMAT_RGB888; - break; - case GL_RGBA: - case GL_RGBA2: - case GL_RGBA4: - case GL_RGB5_A1: - case GL_RGBA8: -#if 1 - case GL_RGB10_A2: - case GL_RGBA12: -#endif - if (_mesa_little_endian()) - rb->Format = MESA_FORMAT_RGBA8888_REV; - else - rb->Format = MESA_FORMAT_RGBA8888; - break; - case GL_RGBA16: - case GL_RGBA16_SNORM: - /* for accum buffer */ - rb->Format = MESA_FORMAT_SIGNED_RGBA_16; - break; - case GL_STENCIL_INDEX: - case GL_STENCIL_INDEX1_EXT: - case GL_STENCIL_INDEX4_EXT: - case GL_STENCIL_INDEX8_EXT: - case GL_STENCIL_INDEX16_EXT: - rb->Format = MESA_FORMAT_S8; - break; - case GL_DEPTH_COMPONENT: - case GL_DEPTH_COMPONENT16: - rb->Format = MESA_FORMAT_Z16; - break; - case GL_DEPTH_COMPONENT24: - rb->Format = MESA_FORMAT_X8_Z24; - break; - case GL_DEPTH_COMPONENT32: - rb->Format = MESA_FORMAT_Z32; - break; - default: - /* unsupported format */ - return GL_FALSE; - } - - bpp = _mesa_get_format_bytes(rb->Format); - - /* free old buffer storage */ - if (srb->Buffer) { - free(srb->Buffer); - srb->Buffer = NULL; - } - - srb->RowStride = width * bpp; - - if (width > 0 && height > 0) { - /* allocate new buffer storage */ - srb->Buffer = malloc(srb->RowStride * height); - - if (srb->Buffer == NULL) { - rb->Width = 0; - rb->Height = 0; - _mesa_error(ctx, GL_OUT_OF_MEMORY, - "software renderbuffer allocation (%d x %d x %d)", - width, height, bpp); - return GL_FALSE; - } - } - - rb->Width = width; - rb->Height = height; - rb->_BaseFormat = _mesa_base_fb_format(ctx, internalFormat); - - /* the internalFormat should have been error checked long ago */ - ASSERT(rb->_BaseFormat); - - return GL_TRUE; -} - - -/** - * Called via gl_renderbuffer::Delete() - */ -static void -soft_renderbuffer_delete(struct gl_renderbuffer *rb) -{ - struct swrast_renderbuffer *srb = swrast_renderbuffer(rb); - - if (srb->Buffer) { - free(srb->Buffer); - srb->Buffer = NULL; - } - free(srb); -} - - -void -_swrast_map_soft_renderbuffer(struct gl_context *ctx, - struct gl_renderbuffer *rb, - GLuint x, GLuint y, GLuint w, GLuint h, - GLbitfield mode, - GLubyte **out_map, - GLint *out_stride) -{ - struct swrast_renderbuffer *srb = swrast_renderbuffer(rb); - GLubyte *map = srb->Buffer; - int cpp = _mesa_get_format_bytes(rb->Format); - int stride = rb->Width * cpp; - - if (!map) { - *out_map = NULL; - *out_stride = 0; - } - - map += y * stride; - map += x * cpp; - - *out_map = map; - *out_stride = stride; -} - - -void -_swrast_unmap_soft_renderbuffer(struct gl_context *ctx, - struct gl_renderbuffer *rb) -{ -} - - - -/** - * Allocate a software-based renderbuffer. This is called via the - * ctx->Driver.NewRenderbuffer() function when the user creates a new - * renderbuffer. - * This would not be used for hardware-based renderbuffers. - */ -static -struct gl_renderbuffer * -_swrast_new_soft_renderbuffer(struct gl_context *ctx, GLuint name) -{ - struct swrast_renderbuffer *srb = CALLOC_STRUCT(swrast_renderbuffer); - if (srb) { - _mesa_init_renderbuffer(&srb->Base, name); - srb->Base.AllocStorage = soft_renderbuffer_storage; - srb->Base.Delete = soft_renderbuffer_delete; - } - return &srb->Base; -} - -/** - * Add a software-based depth renderbuffer to the given framebuffer. - * This is a helper routine for device drivers when creating a - * window system framebuffer (not a user-created render/framebuffer). - * Once this function is called, you can basically forget about this - * renderbuffer; core Mesa will handle all the buffer management and - * rendering! - */ -static GLboolean -add_depth_renderbuffer(struct gl_context *ctx, struct gl_framebuffer *fb, - GLuint depthBits) -{ - struct gl_renderbuffer *rb; - - if (depthBits > 32) { - _mesa_problem(ctx, - "Unsupported depthBits in add_depth_renderbuffer"); - return GL_FALSE; - } - - assert(fb->Attachment[BUFFER_DEPTH].Renderbuffer == NULL); - - rb = _swrast_new_soft_renderbuffer(ctx, 0); - if (!rb) { - _mesa_error(ctx, GL_OUT_OF_MEMORY, "Allocating depth buffer"); - return GL_FALSE; - } - - if (depthBits <= 16) { - rb->InternalFormat = GL_DEPTH_COMPONENT16; - } - else if (depthBits <= 24) { - rb->InternalFormat = GL_DEPTH_COMPONENT24; - } - else { - rb->InternalFormat = GL_DEPTH_COMPONENT32; - } - - rb->AllocStorage = soft_renderbuffer_storage; - _mesa_add_renderbuffer(fb, BUFFER_DEPTH, rb); - - return GL_TRUE; -} - - -/** - * Add a software-based stencil renderbuffer to the given framebuffer. - * This is a helper routine for device drivers when creating a - * window system framebuffer (not a user-created render/framebuffer). - * Once this function is called, you can basically forget about this - * renderbuffer; core Mesa will handle all the buffer management and - * rendering! - */ -static GLboolean -add_stencil_renderbuffer(struct gl_context *ctx, struct gl_framebuffer *fb, - GLuint stencilBits) -{ - struct gl_renderbuffer *rb; - - if (stencilBits > 16) { - _mesa_problem(ctx, - "Unsupported stencilBits in add_stencil_renderbuffer"); - return GL_FALSE; - } - - assert(fb->Attachment[BUFFER_STENCIL].Renderbuffer == NULL); - - rb = _swrast_new_soft_renderbuffer(ctx, 0); - if (!rb) { - _mesa_error(ctx, GL_OUT_OF_MEMORY, "Allocating stencil buffer"); - return GL_FALSE; - } - - assert(stencilBits <= 8); - rb->InternalFormat = GL_STENCIL_INDEX8; - - rb->AllocStorage = soft_renderbuffer_storage; - _mesa_add_renderbuffer(fb, BUFFER_STENCIL, rb); - - return GL_TRUE; -} - - -/** - * Add a software-based accumulation renderbuffer to the given framebuffer. - * This is a helper routine for device drivers when creating a - * window system framebuffer (not a user-created render/framebuffer). - * Once this function is called, you can basically forget about this - * renderbuffer; core Mesa will handle all the buffer management and - * rendering! - */ -static GLboolean -add_accum_renderbuffer(struct gl_context *ctx, struct gl_framebuffer *fb, - GLuint redBits, GLuint greenBits, - GLuint blueBits, GLuint alphaBits) -{ - struct gl_renderbuffer *rb; - - if (redBits > 16 || greenBits > 16 || blueBits > 16 || alphaBits > 16) { - _mesa_problem(ctx, - "Unsupported accumBits in add_accum_renderbuffer"); - return GL_FALSE; - } - - assert(fb->Attachment[BUFFER_ACCUM].Renderbuffer == NULL); - - rb = _swrast_new_soft_renderbuffer(ctx, 0); - if (!rb) { - _mesa_error(ctx, GL_OUT_OF_MEMORY, "Allocating accum buffer"); - return GL_FALSE; - } - - rb->InternalFormat = GL_RGBA16_SNORM; - rb->AllocStorage = soft_renderbuffer_storage; - _mesa_add_renderbuffer(fb, BUFFER_ACCUM, rb); - - return GL_TRUE; -} - - - -/** - * Add a software-based aux renderbuffer to the given framebuffer. - * This is a helper routine for device drivers when creating a - * window system framebuffer (not a user-created render/framebuffer). - * Once this function is called, you can basically forget about this - * renderbuffer; core Mesa will handle all the buffer management and - * rendering! - * - * NOTE: color-index aux buffers not supported. - */ -static GLboolean -add_aux_renderbuffers(struct gl_context *ctx, struct gl_framebuffer *fb, - GLuint colorBits, GLuint numBuffers) -{ - GLuint i; - - if (colorBits > 16) { - _mesa_problem(ctx, - "Unsupported colorBits in add_aux_renderbuffers"); - return GL_FALSE; - } - - assert(numBuffers <= MAX_AUX_BUFFERS); - - for (i = 0; i < numBuffers; i++) { - struct gl_renderbuffer *rb = _swrast_new_soft_renderbuffer(ctx, 0); - - assert(fb->Attachment[BUFFER_AUX0 + i].Renderbuffer == NULL); - - if (!rb) { - _mesa_error(ctx, GL_OUT_OF_MEMORY, "Allocating aux buffer"); - return GL_FALSE; - } - - assert (colorBits <= 8); - rb->InternalFormat = GL_RGBA; - - rb->AllocStorage = soft_renderbuffer_storage; - _mesa_add_renderbuffer(fb, BUFFER_AUX0 + i, rb); - } - return GL_TRUE; -} - - -/** - * Create/attach software-based renderbuffers to the given framebuffer. - * This is a helper routine for device drivers. Drivers can just as well - * call the individual _mesa_add_*_renderbuffer() routines directly. - */ -void -_swrast_add_soft_renderbuffers(struct gl_framebuffer *fb, - GLboolean color, - GLboolean depth, - GLboolean stencil, - GLboolean accum, - GLboolean alpha, - GLboolean aux) -{ - (void)color; - - if (depth) { - assert(fb->Visual.depthBits > 0); - add_depth_renderbuffer(NULL, fb, fb->Visual.depthBits); - } - - if (stencil) { - assert(fb->Visual.stencilBits > 0); - add_stencil_renderbuffer(NULL, fb, fb->Visual.stencilBits); - } - - if (accum) { - assert(fb->Visual.accumRedBits > 0); - assert(fb->Visual.accumGreenBits > 0); - assert(fb->Visual.accumBlueBits > 0); - add_accum_renderbuffer(NULL, fb, - fb->Visual.accumRedBits, - fb->Visual.accumGreenBits, - fb->Visual.accumBlueBits, - fb->Visual.accumAlphaBits); - } - - if (aux) { - assert(fb->Visual.numAuxBuffers > 0); - add_aux_renderbuffers(NULL, fb, fb->Visual.redBits, - fb->Visual.numAuxBuffers); - } - -#if 0 - if (multisample) { - /* maybe someday */ - } -#endif -} - - - -static void -map_attachment(struct gl_context *ctx, - struct gl_framebuffer *fb, - gl_buffer_index buffer) -{ - struct gl_renderbuffer *rb = fb->Attachment[buffer].Renderbuffer; - struct swrast_renderbuffer *srb = swrast_renderbuffer(rb); - - if (rb) { - /* Map ordinary renderbuffer */ - ctx->Driver.MapRenderbuffer(ctx, rb, - 0, 0, rb->Width, rb->Height, - GL_MAP_READ_BIT | GL_MAP_WRITE_BIT, - &srb->Map, &srb->RowStride); - } - - assert(srb->Map); -} - - -static void -unmap_attachment(struct gl_context *ctx, - struct gl_framebuffer *fb, - gl_buffer_index buffer) -{ - struct gl_renderbuffer *rb = fb->Attachment[buffer].Renderbuffer; - struct swrast_renderbuffer *srb = swrast_renderbuffer(rb); - - if (rb) { - /* unmap ordinary renderbuffer */ - ctx->Driver.UnmapRenderbuffer(ctx, rb); - } - - srb->Map = NULL; -} - - -/** - * Determine what type to use (ubyte vs. float) for span colors for the - * given renderbuffer. - * See also _swrast_write_rgba_span(). - */ -static void -find_renderbuffer_colortype(struct gl_renderbuffer *rb) -{ - struct swrast_renderbuffer *srb = swrast_renderbuffer(rb); - GLuint rbMaxBits = _mesa_get_format_max_bits(rb->Format); - GLenum rbDatatype = _mesa_get_format_datatype(rb->Format); - - if (rbDatatype == GL_UNSIGNED_NORMALIZED && rbMaxBits <= 8) { - /* the buffer's values fit in GLubyte values */ - srb->ColorType = GL_UNSIGNED_BYTE; - } - else { - /* use floats otherwise */ - srb->ColorType = GL_FLOAT; - } -} - - -/** - * Map the renderbuffers we'll use for tri/line/point rendering. - */ -void -_swrast_map_renderbuffers(struct gl_context *ctx) -{ - struct gl_framebuffer *fb = ctx->DrawBuffer; - struct gl_renderbuffer *depthRb, *stencilRb; - - depthRb = fb->Attachment[BUFFER_DEPTH].Renderbuffer; - if (depthRb) { - /* map depth buffer */ - map_attachment(ctx, fb, BUFFER_DEPTH); - } - - stencilRb = fb->Attachment[BUFFER_STENCIL].Renderbuffer; - if (stencilRb && stencilRb != depthRb) { - /* map stencil buffer */ - map_attachment(ctx, fb, BUFFER_STENCIL); - } - - map_attachment(ctx, fb, fb->_ColorDrawBufferIndex); - find_renderbuffer_colortype(fb->_ColorDrawBuffer); -} - - -/** - * Unmap renderbuffers after rendering. - */ -void -_swrast_unmap_renderbuffers(struct gl_context *ctx) -{ - struct gl_framebuffer *fb = ctx->DrawBuffer; - struct gl_renderbuffer *depthRb, *stencilRb; - - depthRb = fb->Attachment[BUFFER_DEPTH].Renderbuffer; - if (depthRb) { - /* map depth buffer */ - unmap_attachment(ctx, fb, BUFFER_DEPTH); - } - - stencilRb = fb->Attachment[BUFFER_STENCIL].Renderbuffer; - if (stencilRb && stencilRb != depthRb) { - /* map stencil buffer */ - unmap_attachment(ctx, fb, BUFFER_STENCIL); - } - - unmap_attachment(ctx, fb, fb->_ColorDrawBufferIndex); -} diff --git a/dll/opengl/mesa/swrast/s_renderbuffer.h b/dll/opengl/mesa/swrast/s_renderbuffer.h deleted file mode 100644 index d06948485e5..00000000000 --- a/dll/opengl/mesa/swrast/s_renderbuffer.h +++ /dev/null @@ -1,62 +0,0 @@ -/* - * Mesa 3-D graphics library - * Version: 6.5 - * - * Copyright (C) 1999-2005 Brian Paul All Rights Reserved. - * - * Permission is hereby granted, free of charge, to any person obtaining a - * copy of this software and associated documentation files (the "Software"), - * to deal in the Software without restriction, including without limitation - * the rights to use, copy, modify, merge, publish, distribute, sublicense, - * and/or sell copies of the Software, and to permit persons to whom the - * Software is furnished to do so, subject to the following conditions: - * - * The above copyright notice and this permission notice shall be included - * in all copies or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS - * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL - * BRIAN PAUL BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN - * AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN - * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. - */ - - -#ifndef S_RENDERBUFFER_H -#define S_RENDERBUFFER_H - -#include "main/glheader.h" - - -struct gl_context; -struct gl_framebuffer; -struct gl_renderbuffer; - -extern void -_swrast_map_soft_renderbuffer(struct gl_context *ctx, - struct gl_renderbuffer *rb, - GLuint x, GLuint y, GLuint w, GLuint h, - GLbitfield mode, - GLubyte **out_map, - GLint *out_stride); - -extern void -_swrast_unmap_soft_renderbuffer(struct gl_context *ctx, - struct gl_renderbuffer *rb); - -extern void -_swrast_set_renderbuffer_accessors(struct gl_renderbuffer *rb); - - -extern void -_swrast_add_soft_renderbuffers(struct gl_framebuffer *fb, - GLboolean color, - GLboolean depth, - GLboolean stencil, - GLboolean accum, - GLboolean alpha, - GLboolean aux); - - -#endif /* S_RENDERBUFFER_H */ diff --git a/dll/opengl/mesa/swrast/s_span.c b/dll/opengl/mesa/swrast/s_span.c deleted file mode 100644 index b7ab51e93a4..00000000000 --- a/dll/opengl/mesa/swrast/s_span.c +++ /dev/null @@ -1,1242 +0,0 @@ -/* - * Mesa 3-D graphics library - * Version: 7.5 - * - * Copyright (C) 1999-2008 Brian Paul All Rights Reserved. - * Copyright (C) 2009 VMware, Inc. All Rights Reserved. - * - * Permission is hereby granted, free of charge, to any person obtaining a - * copy of this software and associated documentation files (the "Software"), - * to deal in the Software without restriction, including without limitation - * the rights to use, copy, modify, merge, publish, distribute, sublicense, - * and/or sell copies of the Software, and to permit persons to whom the - * Software is furnished to do so, subject to the following conditions: - * - * The above copyright notice and this permission notice shall be included - * in all copies or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS - * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL - * BRIAN PAUL BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN - * AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN - * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. - */ - -/** - * \file swrast/s_span.c - * \brief Span processing functions used by all rasterization functions. - * This is where all the per-fragment tests are performed - * \author Brian Paul - */ - -#include - -/** - * Set default fragment attributes for the span using the - * current raster values. Used prior to glDraw/CopyPixels - * and glBitmap. - */ -void -_swrast_span_default_attribs(struct gl_context *ctx, SWspan *span) -{ - GLchan r, g, b, a; - /* Z*/ - { - const GLfloat depthMax = ctx->DrawBuffer->_DepthMaxF; - if (ctx->DrawBuffer->Visual.depthBits <= 16) - span->z = FloatToFixed(ctx->Current.RasterPos[2] * depthMax + 0.5F); - else { - GLfloat tmpf = ctx->Current.RasterPos[2] * depthMax; - tmpf = MIN2(tmpf, depthMax); - span->z = (GLint)tmpf; - } - span->zStep = 0; - span->interpMask |= SPAN_Z; - } - - /* W (for perspective correction) */ - span->attrStart[FRAG_ATTRIB_WPOS][3] = 1.0; - span->attrStepX[FRAG_ATTRIB_WPOS][3] = 0.0; - span->attrStepY[FRAG_ATTRIB_WPOS][3] = 0.0; - - /* primary color, or color index */ - UNCLAMPED_FLOAT_TO_CHAN(r, ctx->Current.RasterColor[0]); - UNCLAMPED_FLOAT_TO_CHAN(g, ctx->Current.RasterColor[1]); - UNCLAMPED_FLOAT_TO_CHAN(b, ctx->Current.RasterColor[2]); - UNCLAMPED_FLOAT_TO_CHAN(a, ctx->Current.RasterColor[3]); -#if CHAN_TYPE == GL_FLOAT - span->red = r; - span->green = g; - span->blue = b; - span->alpha = a; -#else - span->red = IntToFixed(r); - span->green = IntToFixed(g); - span->blue = IntToFixed(b); - span->alpha = IntToFixed(a); -#endif - span->redStep = 0; - span->greenStep = 0; - span->blueStep = 0; - span->alphaStep = 0; - span->interpMask |= SPAN_RGBA; - - COPY_4V(span->attrStart[FRAG_ATTRIB_COL], ctx->Current.RasterColor); - ASSIGN_4V(span->attrStepX[FRAG_ATTRIB_COL], 0.0, 0.0, 0.0, 0.0); - ASSIGN_4V(span->attrStepY[FRAG_ATTRIB_COL], 0.0, 0.0, 0.0, 0.0); - - /* fog */ - { - const SWcontext *swrast = SWRAST_CONTEXT(ctx); - GLfloat fogVal; /* a coord or a blend factor */ - if (swrast->_PreferPixelFog) { - /* fog blend factors will be computed from fog coordinates per pixel */ - fogVal = ctx->Current.RasterDistance; - } - else { - /* fog blend factor should be computed from fogcoord now */ - fogVal = _swrast_z_to_fogfactor(ctx, ctx->Current.RasterDistance); - } - span->attrStart[FRAG_ATTRIB_FOGC][0] = fogVal; - span->attrStepX[FRAG_ATTRIB_FOGC][0] = 0.0; - span->attrStepY[FRAG_ATTRIB_FOGC][0] = 0.0; - } - - /* texcoords */ - { - const GLuint attr = FRAG_ATTRIB_TEX; - const GLfloat *tc = ctx->Current.RasterTexCoords; - if (tc[3] > 0.0F) { - /* use (s/q, t/q, r/q, 1) */ - span->attrStart[attr][0] = tc[0] / tc[3]; - span->attrStart[attr][1] = tc[1] / tc[3]; - span->attrStart[attr][2] = tc[2] / tc[3]; - span->attrStart[attr][3] = 1.0; - } - else { - ASSIGN_4V(span->attrStart[attr], 0.0F, 0.0F, 0.0F, 1.0F); - } - ASSIGN_4V(span->attrStepX[attr], 0.0F, 0.0F, 0.0F, 0.0F); - ASSIGN_4V(span->attrStepY[attr], 0.0F, 0.0F, 0.0F, 0.0F); - } -} - - -/** - * Interpolate the active attributes (and'd with attrMask) to - * fill in span->array->attribs[]. - * Perspective correction will be done. The point/line/triangle function - * should have computed attrStart/Step values for FRAG_ATTRIB_WPOS[3]! - */ -static inline void -interpolate_active_attribs(struct gl_context *ctx, SWspan *span, - GLbitfield64 attrMask) -{ - const SWcontext *swrast = SWRAST_CONTEXT(ctx); - - /* - * Don't overwrite existing array values, such as colors that may have - * been produced by glDraw/CopyPixels. - */ - attrMask &= ~span->arrayAttribs; - - ATTRIB_LOOP_BEGIN - if (attrMask & BITFIELD64_BIT(attr)) { - const GLfloat dwdx = span->attrStepX[FRAG_ATTRIB_WPOS][3]; - GLfloat w = span->attrStart[FRAG_ATTRIB_WPOS][3]; - const GLfloat dv0dx = span->attrStepX[attr][0]; - const GLfloat dv1dx = span->attrStepX[attr][1]; - const GLfloat dv2dx = span->attrStepX[attr][2]; - const GLfloat dv3dx = span->attrStepX[attr][3]; - GLfloat v0 = span->attrStart[attr][0] + span->leftClip * dv0dx; - GLfloat v1 = span->attrStart[attr][1] + span->leftClip * dv1dx; - GLfloat v2 = span->attrStart[attr][2] + span->leftClip * dv2dx; - GLfloat v3 = span->attrStart[attr][3] + span->leftClip * dv3dx; - GLuint k; - for (k = 0; k < span->end; k++) { - const GLfloat invW = 1.0f / w; - span->array->attribs[attr][k][0] = v0 * invW; - span->array->attribs[attr][k][1] = v1 * invW; - span->array->attribs[attr][k][2] = v2 * invW; - span->array->attribs[attr][k][3] = v3 * invW; - v0 += dv0dx; - v1 += dv1dx; - v2 += dv2dx; - v3 += dv3dx; - w += dwdx; - } - ASSERT((span->arrayAttribs & BITFIELD64_BIT(attr)) == 0); - span->arrayAttribs |= BITFIELD64_BIT(attr); - } - ATTRIB_LOOP_END -} - - -/** - * Interpolate primary colors to fill in the span->array->rgba8 (or rgb16) - * color array. - */ -static inline void -interpolate_int_colors(struct gl_context *ctx, SWspan *span) -{ -#if CHAN_BITS != 32 - const GLuint n = span->end; - GLuint i; - - ASSERT(!(span->arrayMask & SPAN_RGBA)); -#endif - - switch (span->array->ChanType) { -#if CHAN_BITS != 32 - case GL_UNSIGNED_BYTE: - { - GLubyte (*rgba)[4] = span->array->rgba8; - if (span->interpMask & SPAN_FLAT) { - GLubyte color[4]; - color[RCOMP] = FixedToInt(span->red); - color[GCOMP] = FixedToInt(span->green); - color[BCOMP] = FixedToInt(span->blue); - color[ACOMP] = FixedToInt(span->alpha); - for (i = 0; i < n; i++) { - COPY_4UBV(rgba[i], color); - } - } - else { - GLfixed r = span->red; - GLfixed g = span->green; - GLfixed b = span->blue; - GLfixed a = span->alpha; - GLint dr = span->redStep; - GLint dg = span->greenStep; - GLint db = span->blueStep; - GLint da = span->alphaStep; - for (i = 0; i < n; i++) { - rgba[i][RCOMP] = FixedToChan(r); - rgba[i][GCOMP] = FixedToChan(g); - rgba[i][BCOMP] = FixedToChan(b); - rgba[i][ACOMP] = FixedToChan(a); - r += dr; - g += dg; - b += db; - a += da; - } - } - } - break; - case GL_UNSIGNED_SHORT: - { - GLushort (*rgba)[4] = span->array->rgba16; - if (span->interpMask & SPAN_FLAT) { - GLushort color[4]; - color[RCOMP] = FixedToInt(span->red); - color[GCOMP] = FixedToInt(span->green); - color[BCOMP] = FixedToInt(span->blue); - color[ACOMP] = FixedToInt(span->alpha); - for (i = 0; i < n; i++) { - COPY_4V(rgba[i], color); - } - } - else { - GLushort (*rgba)[4] = span->array->rgba16; - GLfixed r, g, b, a; - GLint dr, dg, db, da; - r = span->red; - g = span->green; - b = span->blue; - a = span->alpha; - dr = span->redStep; - dg = span->greenStep; - db = span->blueStep; - da = span->alphaStep; - for (i = 0; i < n; i++) { - rgba[i][RCOMP] = FixedToChan(r); - rgba[i][GCOMP] = FixedToChan(g); - rgba[i][BCOMP] = FixedToChan(b); - rgba[i][ACOMP] = FixedToChan(a); - r += dr; - g += dg; - b += db; - a += da; - } - } - } - break; -#endif - case GL_FLOAT: - interpolate_active_attribs(ctx, span, FRAG_BIT_COL); - break; - default: - _mesa_problem(ctx, "bad datatype 0x%x in interpolate_int_colors", - span->array->ChanType); - } - span->arrayMask |= SPAN_RGBA; -} - -/** - * Fill in the span.zArray array from the span->z, zStep values. - */ -void -_swrast_span_interpolate_z( const struct gl_context *ctx, SWspan *span ) -{ - const GLuint n = span->end; - GLuint i; - - ASSERT(!(span->arrayMask & SPAN_Z)); - - if (ctx->DrawBuffer->Visual.depthBits <= 16) { - GLfixed zval = span->z; - GLuint *z = span->array->z; - for (i = 0; i < n; i++) { - z[i] = FixedToInt(zval); - zval += span->zStep; - } - } - else { - /* Deep Z buffer, no fixed->int shift */ - GLuint zval = span->z; - GLuint *z = span->array->z; - for (i = 0; i < n; i++) { - z[i] = zval; - zval += span->zStep; - } - } - span->interpMask &= ~SPAN_Z; - span->arrayMask |= SPAN_Z; -} - - -/** - * Compute mipmap LOD from partial derivatives. - * This the ideal solution, as given in the OpenGL spec. - */ -GLfloat -_swrast_compute_lambda(GLfloat dsdx, GLfloat dsdy, GLfloat dtdx, GLfloat dtdy, - GLfloat dqdx, GLfloat dqdy, GLfloat texW, GLfloat texH, - GLfloat s, GLfloat t, GLfloat q, GLfloat invQ) -{ - GLfloat dudx = texW * ((s + dsdx) / (q + dqdx) - s * invQ); - GLfloat dvdx = texH * ((t + dtdx) / (q + dqdx) - t * invQ); - GLfloat dudy = texW * ((s + dsdy) / (q + dqdy) - s * invQ); - GLfloat dvdy = texH * ((t + dtdy) / (q + dqdy) - t * invQ); - GLfloat x = SQRTF(dudx * dudx + dvdx * dvdx); - GLfloat y = SQRTF(dudy * dudy + dvdy * dvdy); - GLfloat rho = MAX2(x, y); - GLfloat lambda = LOG2(rho); - return lambda; -} - - -/** - * Compute mipmap LOD from partial derivatives. - * This is a faster approximation than above function. - */ -#if 0 -GLfloat -_swrast_compute_lambda(GLfloat dsdx, GLfloat dsdy, GLfloat dtdx, GLfloat dtdy, - GLfloat dqdx, GLfloat dqdy, GLfloat texW, GLfloat texH, - GLfloat s, GLfloat t, GLfloat q, GLfloat invQ) -{ - GLfloat dsdx2 = (s + dsdx) / (q + dqdx) - s * invQ; - GLfloat dtdx2 = (t + dtdx) / (q + dqdx) - t * invQ; - GLfloat dsdy2 = (s + dsdy) / (q + dqdy) - s * invQ; - GLfloat dtdy2 = (t + dtdy) / (q + dqdy) - t * invQ; - GLfloat maxU, maxV, rho, lambda; - dsdx2 = FABSF(dsdx2); - dsdy2 = FABSF(dsdy2); - dtdx2 = FABSF(dtdx2); - dtdy2 = FABSF(dtdy2); - maxU = MAX2(dsdx2, dsdy2) * texW; - maxV = MAX2(dtdx2, dtdy2) * texH; - rho = MAX2(maxU, maxV); - lambda = LOG2(rho); - return lambda; -} -#endif - - -/** - * Fill in the span.array->attrib[FRAG_ATTRIB_TEXn] arrays from the - * using the attrStart/Step values. - * - * This function only used during fixed-function fragment processing. - * - * Note: in the places where we divide by Q (or mult by invQ) we're - * really doing two things: perspective correction and texcoord - * projection. Remember, for texcoord (s,t,r,q) we need to index - * texels with (s/q, t/q, r/q). - */ -static void -interpolate_texcoords(struct gl_context *ctx, SWspan *span) -{ - if (ctx->Texture._EnabledCoord) { - const GLuint attr = FRAG_ATTRIB_TEX; - const struct gl_texture_object *obj = ctx->Texture.Unit._Current; - GLfloat texW, texH; - GLboolean needLambda; - GLfloat (*texcoord)[4] = span->array->attribs[attr]; - GLfloat *lambda = span->array->lambda; - const GLfloat dsdx = span->attrStepX[attr][0]; - const GLfloat dsdy = span->attrStepY[attr][0]; - const GLfloat dtdx = span->attrStepX[attr][1]; - const GLfloat dtdy = span->attrStepY[attr][1]; - const GLfloat drdx = span->attrStepX[attr][2]; - const GLfloat dqdx = span->attrStepX[attr][3]; - const GLfloat dqdy = span->attrStepY[attr][3]; - GLfloat s = span->attrStart[attr][0] + span->leftClip * dsdx; - GLfloat t = span->attrStart[attr][1] + span->leftClip * dtdx; - GLfloat r = span->attrStart[attr][2] + span->leftClip * drdx; - GLfloat q = span->attrStart[attr][3] + span->leftClip * dqdx; - - if (obj) { - const struct gl_texture_image *img = obj->Image[0][obj->BaseLevel]; - const struct swrast_texture_image *swImg = - swrast_texture_image_const(img); - - needLambda = (obj->Sampler.MinFilter != obj->Sampler.MagFilter); - /* LOD is calculated directly in the ansiotropic filter, we can - * skip the normal lambda function as the result is ignored. - */ - if (obj->Sampler.MaxAnisotropy > 1.0 && - obj->Sampler.MinFilter == GL_LINEAR_MIPMAP_LINEAR) { - needLambda = GL_FALSE; - } - texW = swImg->WidthScale; - texH = swImg->HeightScale; - } - else { - /* using a fragment program */ - texW = 1.0; - texH = 1.0; - needLambda = GL_FALSE; - } - - if (needLambda) { - GLuint i; - for (i = 0; i < span->end; i++) { - const GLfloat invQ = (q == 0.0F) ? 1.0F : (1.0F / q); - texcoord[i][0] = s * invQ; - texcoord[i][1] = t * invQ; - texcoord[i][2] = r * invQ; - texcoord[i][3] = q; - lambda[i] = _swrast_compute_lambda(dsdx, dsdy, dtdx, dtdy, - dqdx, dqdy, texW, texH, - s, t, q, invQ); - s += dsdx; - t += dtdx; - r += drdx; - q += dqdx; - } - span->arrayMask |= SPAN_LAMBDA; - } - else { - GLuint i; - if (dqdx == 0.0F) { - /* Ortho projection or polygon's parallel to window X axis */ - const GLfloat invQ = (q == 0.0F) ? 1.0F : (1.0F / q); - for (i = 0; i < span->end; i++) { - texcoord[i][0] = s * invQ; - texcoord[i][1] = t * invQ; - texcoord[i][2] = r * invQ; - texcoord[i][3] = q; - lambda[i] = 0.0; - s += dsdx; - t += dtdx; - r += drdx; - } - } - else { - for (i = 0; i < span->end; i++) { - const GLfloat invQ = (q == 0.0F) ? 1.0F : (1.0F / q); - texcoord[i][0] = s * invQ; - texcoord[i][1] = t * invQ; - texcoord[i][2] = r * invQ; - texcoord[i][3] = q; - lambda[i] = 0.0; - s += dsdx; - t += dtdx; - r += drdx; - q += dqdx; - } - } - } /* lambda */ - } /* if */ -} - -/** - * Apply the current polygon stipple pattern to a span of pixels. - */ -static inline void -stipple_polygon_span(struct gl_context *ctx, SWspan *span) -{ - GLubyte *mask = span->array->mask; - - ASSERT(ctx->Polygon.StippleFlag); - - if (span->arrayMask & SPAN_XY) { - /* arrays of x/y pixel coords */ - GLuint i; - for (i = 0; i < span->end; i++) { - const GLint col = span->array->x[i] % 32; - const GLint row = span->array->y[i] % 32; - const GLuint stipple = ctx->PolygonStipple[row]; - if (((1 << col) & stipple) == 0) { - mask[i] = 0; - } - } - } - else { - /* horizontal span of pixels */ - const GLuint highBit = 1 << 31; - const GLuint stipple = ctx->PolygonStipple[span->y % 32]; - GLuint i, m = highBit >> (GLuint) (span->x % 32); - for (i = 0; i < span->end; i++) { - if ((m & stipple) == 0) { - mask[i] = 0; - } - m = m >> 1; - if (m == 0) { - m = highBit; - } - } - } - span->writeAll = GL_FALSE; -} - - -/** - * Clip a pixel span to the current buffer/window boundaries: - * DrawBuffer->_Xmin, _Xmax, _Ymin, _Ymax. This will accomplish - * window clipping and scissoring. - * Return: GL_TRUE some pixels still visible - * GL_FALSE nothing visible - */ -static inline GLuint -clip_span( struct gl_context *ctx, SWspan *span ) -{ - const GLint xmin = ctx->DrawBuffer->_Xmin; - const GLint xmax = ctx->DrawBuffer->_Xmax; - const GLint ymin = ctx->DrawBuffer->_Ymin; - const GLint ymax = ctx->DrawBuffer->_Ymax; - - span->leftClip = 0; - - if (span->arrayMask & SPAN_XY) { - /* arrays of x/y pixel coords */ - const GLint *x = span->array->x; - const GLint *y = span->array->y; - const GLint n = span->end; - GLubyte *mask = span->array->mask; - GLint i; - GLuint passed = 0; - if (span->arrayMask & SPAN_MASK) { - /* note: using & intead of && to reduce branches */ - for (i = 0; i < n; i++) { - mask[i] &= (x[i] >= xmin) & (x[i] < xmax) - & (y[i] >= ymin) & (y[i] < ymax); - passed += mask[i]; - } - } - else { - /* note: using & intead of && to reduce branches */ - for (i = 0; i < n; i++) { - mask[i] = (x[i] >= xmin) & (x[i] < xmax) - & (y[i] >= ymin) & (y[i] < ymax); - passed += mask[i]; - } - } - return passed > 0; - } - else { - /* horizontal span of pixels */ - const GLint x = span->x; - const GLint y = span->y; - GLint n = span->end; - - /* Trivial rejection tests */ - if (y < ymin || y >= ymax || x + n <= xmin || x >= xmax) { - span->end = 0; - return GL_FALSE; /* all pixels clipped */ - } - - /* Clip to right */ - if (x + n > xmax) { - ASSERT(x < xmax); - n = span->end = xmax - x; - } - - /* Clip to the left */ - if (x < xmin) { - const GLint leftClip = xmin - x; - GLuint i; - - ASSERT(leftClip > 0); - ASSERT(x + n > xmin); - - /* Clip 'leftClip' pixels from the left side. - * The span->leftClip field will be applied when we interpolate - * fragment attributes. - * For arrays of values, shift them left. - */ - for (i = 0; i < FRAG_ATTRIB_MAX; i++) { - if (span->interpMask & (1 << i)) { - GLuint j; - for (j = 0; j < 4; j++) { - span->attrStart[i][j] += leftClip * span->attrStepX[i][j]; - } - } - } - - span->red += leftClip * span->redStep; - span->green += leftClip * span->greenStep; - span->blue += leftClip * span->blueStep; - span->alpha += leftClip * span->alphaStep; - span->index += leftClip * span->indexStep; - span->z += leftClip * span->zStep; - span->intTex[0] += leftClip * span->intTexStep[0]; - span->intTex[1] += leftClip * span->intTexStep[1]; - -#define SHIFT_ARRAY(ARRAY, SHIFT, LEN) \ - memmove(ARRAY, ARRAY + (SHIFT), (LEN) * sizeof(ARRAY[0])) - - for (i = 0; i < FRAG_ATTRIB_MAX; i++) { - if (span->arrayAttribs & (1 << i)) { - /* shift array elements left by 'leftClip' */ - SHIFT_ARRAY(span->array->attribs[i], leftClip, n - leftClip); - } - } - - SHIFT_ARRAY(span->array->mask, leftClip, n - leftClip); - SHIFT_ARRAY(span->array->rgba8, leftClip, n - leftClip); - SHIFT_ARRAY(span->array->rgba16, leftClip, n - leftClip); - SHIFT_ARRAY(span->array->x, leftClip, n - leftClip); - SHIFT_ARRAY(span->array->y, leftClip, n - leftClip); - SHIFT_ARRAY(span->array->z, leftClip, n - leftClip); - SHIFT_ARRAY(span->array->index, leftClip, n - leftClip); - SHIFT_ARRAY(span->array->lambda, leftClip, n - leftClip); - SHIFT_ARRAY(span->array->coverage, leftClip, n - leftClip); - -#undef SHIFT_ARRAY - - span->leftClip = leftClip; - span->x = xmin; - span->end -= leftClip; - span->writeAll = GL_FALSE; - } - - ASSERT(span->x >= xmin); - ASSERT(span->x + span->end <= xmax); - ASSERT(span->y >= ymin); - ASSERT(span->y < ymax); - - return GL_TRUE; /* some pixels visible */ - } -} - - -/** - * Apply antialiasing coverage value to alpha values. - */ -static inline void -apply_aa_coverage(SWspan *span) -{ - const GLfloat *coverage = span->array->coverage; - GLuint i; - if (span->array->ChanType == GL_UNSIGNED_BYTE) { - GLubyte (*rgba)[4] = span->array->rgba8; - for (i = 0; i < span->end; i++) { - const GLfloat a = rgba[i][ACOMP] * coverage[i]; - rgba[i][ACOMP] = (GLubyte) CLAMP(a, 0.0, 255.0); - ASSERT(coverage[i] >= 0.0); - ASSERT(coverage[i] <= 1.0); - } - } - else if (span->array->ChanType == GL_UNSIGNED_SHORT) { - GLushort (*rgba)[4] = span->array->rgba16; - for (i = 0; i < span->end; i++) { - const GLfloat a = rgba[i][ACOMP] * coverage[i]; - rgba[i][ACOMP] = (GLushort) CLAMP(a, 0.0, 65535.0); - } - } - else { - GLfloat (*rgba)[4] = span->array->attribs[FRAG_ATTRIB_COL]; - for (i = 0; i < span->end; i++) { - rgba[i][ACOMP] = rgba[i][ACOMP] * coverage[i]; - /* clamp later */ - } - } -} - -/** - * Convert the span's color arrays to the given type. - * The only way 'output' can be greater than zero is when we have a fragment - * program that writes to gl_FragData[1] or higher. - * \param output which fragment program color output is being processed - */ -static inline void -convert_color_type(SWspan *span, GLenum newType, GLuint output) -{ - GLvoid *src, *dst; - - if (output > 0 || span->array->ChanType == GL_FLOAT) { - src = span->array->attribs[FRAG_ATTRIB_COL + output]; - span->array->ChanType = GL_FLOAT; - } - else if (span->array->ChanType == GL_UNSIGNED_BYTE) { - src = span->array->rgba8; - } - else { - ASSERT(span->array->ChanType == GL_UNSIGNED_SHORT); - src = span->array->rgba16; - } - - if (newType == GL_UNSIGNED_BYTE) { - dst = span->array->rgba8; - } - else if (newType == GL_UNSIGNED_SHORT) { - dst = span->array->rgba16; - } - else { - dst = span->array->attribs[FRAG_ATTRIB_COL]; - } - - _mesa_convert_colors(span->array->ChanType, src, - newType, dst, - span->end, span->array->mask); - - span->array->ChanType = newType; - span->array->rgba = dst; -} - - - -/** - * Apply fragment shader, fragment program or normal texturing to span. - */ -static inline void -shade_texture_span(struct gl_context *ctx, SWspan *span) -{ - if (ctx->Texture._EnabledCoord) { - /* conventional texturing */ - -#if CHAN_BITS == 32 - if ((span->arrayAttribs & FRAG_BIT_COL0) == 0) { - interpolate_int_colors(ctx, span); - } -#else - if (!(span->arrayMask & SPAN_RGBA)) - interpolate_int_colors(ctx, span); -#endif - if (!(span->arrayAttribs & FRAG_BIT_TEX)) - interpolate_texcoords(ctx, span); - - _swrast_texture_span(ctx, span); - } -} - - -/** Put colors at x/y locations into a renderbuffer */ -static void -put_values(struct gl_context *ctx, struct gl_renderbuffer *rb, - GLenum datatype, - GLuint count, const GLint x[], const GLint y[], - const void *values, const GLubyte *mask) -{ - gl_pack_ubyte_rgba_func pack_ubyte; - gl_pack_float_rgba_func pack_float; - GLuint i; - - if (datatype == GL_UNSIGNED_BYTE) - pack_ubyte = _mesa_get_pack_ubyte_rgba_function(rb->Format); - else - pack_float = _mesa_get_pack_float_rgba_function(rb->Format); - - for (i = 0; i < count; i++) { - if (mask[i]) { - GLubyte *dst = _swrast_pixel_address(rb, x[i], y[i]); - - if (datatype == GL_UNSIGNED_BYTE) { - pack_ubyte((const GLubyte *) values + 4 * i, dst); - } - else { - assert(datatype == GL_FLOAT); - pack_float((const GLfloat *) values + 4 * i, dst); - } - } - } -} - - -/** Put row of colors into renderbuffer */ -void -_swrast_put_row(struct gl_context *ctx, struct gl_renderbuffer *rb, - GLenum datatype, - GLuint count, GLint x, GLint y, - const void *values, const GLubyte *mask) -{ - GLubyte *dst = _swrast_pixel_address(rb, x, y); - - if (!mask) { - if (datatype == GL_UNSIGNED_BYTE) { - _mesa_pack_ubyte_rgba_row(rb->Format, count, - (const GLubyte (*)[4]) values, dst); - } - else { - assert(datatype == GL_FLOAT); - _mesa_pack_float_rgba_row(rb->Format, count, - (const GLfloat (*)[4]) values, dst); - } - } - else { - const GLuint bpp = _mesa_get_format_bytes(rb->Format); - GLuint i, runLen, runStart; - /* We can't pass a 'mask' array to the _mesa_pack_rgba_row() functions - * so look for runs where mask=1... - */ - runLen = runStart = 0; - for (i = 0; i < count; i++) { - if (mask[i]) { - if (runLen == 0) - runStart = i; - runLen++; - } - - if (!mask[i] || i == count - 1) { - /* might be the end of a run of pixels */ - if (runLen > 0) { - if (datatype == GL_UNSIGNED_BYTE) { - _mesa_pack_ubyte_rgba_row(rb->Format, runLen, - (const GLubyte (*)[4]) values + runStart, - dst + runStart * bpp); - } - else { - assert(datatype == GL_FLOAT); - _mesa_pack_float_rgba_row(rb->Format, runLen, - (const GLfloat (*)[4]) values + runStart, - dst + runStart * bpp); - } - runLen = 0; - } - } - } - } -} - - - -/** - * Apply all the per-fragment operations to a span. - * This now includes texturing (_swrast_write_texture_span() is history). - * This function may modify any of the array values in the span. - * span->interpMask and span->arrayMask may be changed but will be restored - * to their original values before returning. - */ -void -_swrast_write_rgba_span( struct gl_context *ctx, SWspan *span) -{ - const SWcontext *swrast = SWRAST_CONTEXT(ctx); - const GLuint colorMask = *((GLuint *)ctx->Color.ColorMask); - const GLbitfield origInterpMask = span->interpMask; - const GLbitfield origArrayMask = span->arrayMask; - const GLbitfield64 origArrayAttribs = span->arrayAttribs; - const GLenum origChanType = span->array->ChanType; - void * const origRgba = span->array->rgba; - const GLboolean texture = ctx->Texture._EnabledCoord; - struct gl_framebuffer *fb = ctx->DrawBuffer; - - /* - printf("%s() interp 0x%x array 0x%x\n", __FUNCTION__, - span->interpMask, span->arrayMask); - */ - - ASSERT(span->primitive == GL_POINT || - span->primitive == GL_LINE || - span->primitive == GL_POLYGON || - span->primitive == GL_BITMAP); - - /* Fragment write masks */ - if (span->arrayMask & SPAN_MASK) { - /* mask was initialized by caller, probably glBitmap */ - span->writeAll = GL_FALSE; - } - else { - memset(span->array->mask, 1, span->end); - span->writeAll = GL_TRUE; - } - - /* Clip to window/scissor box */ - if (!clip_span(ctx, span)) { - return; - } - - ASSERT(span->end <= MAX_WIDTH); - - /* Depth bounds test */ - if (ctx->Depth.BoundsTest && fb->Visual.depthBits > 0) { - if (!_swrast_depth_bounds_test(ctx, span)) { - return; - } - } - -#ifdef DEBUG - /* Make sure all fragments are within window bounds */ - if (span->arrayMask & SPAN_XY) { - /* array of pixel locations */ - GLuint i; - for (i = 0; i < span->end; i++) { - if (span->array->mask[i]) { - assert(span->array->x[i] >= fb->_Xmin); - assert(span->array->x[i] < fb->_Xmax); - assert(span->array->y[i] >= fb->_Ymin); - assert(span->array->y[i] < fb->_Ymax); - } - } - } -#endif - - /* Polygon Stippling */ - if (ctx->Polygon.StippleFlag && span->primitive == GL_POLYGON) { - stipple_polygon_span(ctx, span); - } - - /* This is the normal place to compute the fragment color/Z - * from texturing or shading. - */ - if (texture && !swrast->_DeferredTexture) { - shade_texture_span(ctx, span); - } - - /* Do the alpha test */ - if (ctx->Color.AlphaEnabled) { - if (!_swrast_alpha_test(ctx, span)) { - /* all fragments failed test */ - goto end; - } - } - - /* Stencil and Z testing */ - if (ctx->Stencil._Enabled || ctx->Depth.Test) { - if (!(span->arrayMask & SPAN_Z)) - _swrast_span_interpolate_z(ctx, span); - - if (ctx->Stencil._Enabled) { - /* Combined Z/stencil tests */ - if (!_swrast_stencil_and_ztest_span(ctx, span)) { - /* all fragments failed test */ - goto end; - } - } - else if (fb->Visual.depthBits > 0) { - /* Just regular depth testing */ - ASSERT(ctx->Depth.Test); - ASSERT(span->arrayMask & SPAN_Z); - if (!_swrast_depth_test_span(ctx, span)) { - /* all fragments failed test */ - goto end; - } - } - } - - /* We had to wait until now to check for glColorMask(0,0,0,0) because of - * the occlusion test. - */ - if (colorMask == 0) { - /* no colors to write */ - goto end; - } - - /* If we were able to defer fragment color computation to now, there's - * a good chance that many fragments will have already been killed by - * Z/stencil testing. - */ - if (texture && swrast->_DeferredTexture) { - shade_texture_span(ctx, span); - } - -#if CHAN_BITS == 32 - if ((span->arrayAttribs & FRAG_BIT_COL0) == 0) { - interpolate_active_attribs(ctx, span, FRAG_BIT_COL0); - } -#else - if ((span->arrayMask & SPAN_RGBA) == 0) { - interpolate_int_colors(ctx, span); - } -#endif - - ASSERT(span->arrayMask & SPAN_RGBA); - - /* Fog */ - if (swrast->_FogEnabled) { - _swrast_fog_rgba_span(ctx, span); - } - - /* Antialias coverage application */ - if (span->arrayMask & SPAN_COVERAGE) { - apply_aa_coverage(span); - } - - /* - * Write to renderbuffers. - * Depending on glDrawBuffer() state and the which color outputs are - * written by the fragment shader, we may either replicate one color to - * all renderbuffers or write a different color to each renderbuffer. - * multiFragOutputs=TRUE for the later case. - */ - { - struct gl_renderbuffer *rb = fb->_ColorDrawBuffer; - - /* color[fragOutput] will be written to buffer */ - - if (rb) { - struct swrast_renderbuffer *srb = swrast_renderbuffer(rb); - GLenum colorType = srb->ColorType; - - assert(colorType == GL_UNSIGNED_BYTE || - colorType == GL_FLOAT); - - /* set span->array->rgba to colors for renderbuffer's datatype */ - if (span->array->ChanType != colorType) { - convert_color_type(span, colorType, 0); - } - else { - if (span->array->ChanType == GL_UNSIGNED_BYTE) { - span->array->rgba = span->array->rgba8; - } - else { - span->array->rgba = (void *)span->array->attribs[FRAG_ATTRIB_COL]; - } - } - - - ASSERT(rb->_BaseFormat == GL_RGBA || - rb->_BaseFormat == GL_RGB || - rb->_BaseFormat == GL_RED || - rb->_BaseFormat == GL_RG || - rb->_BaseFormat == GL_ALPHA); - - if (ctx->Color.ColorLogicOpEnabled) { - _swrast_logicop_rgba_span(ctx, rb, span); - } - else if (ctx->Color.BlendEnabled) { - _swrast_blend_span(ctx, rb, span); - } - - if (colorMask != 0xffffffff) { - _swrast_mask_rgba_span(ctx, rb, span); - } - - if (span->arrayMask & SPAN_XY) { - /* array of pixel coords */ - put_values(ctx, rb, - span->array->ChanType, span->end, - span->array->x, span->array->y, - span->array->rgba, span->array->mask); - } - else { - /* horizontal run of pixels */ - _swrast_put_row(ctx, rb, - span->array->ChanType, - span->end, span->x, span->y, - span->array->rgba, - span->writeAll ? NULL: span->array->mask); - } - - } /* if rb */ - } - -end: - /* restore these values before returning */ - span->interpMask = origInterpMask; - span->arrayMask = origArrayMask; - span->arrayAttribs = origArrayAttribs; - span->array->ChanType = origChanType; - span->array->rgba = origRgba; -} - - -/** - * Read float RGBA pixels from a renderbuffer. Clipping will be done to - * prevent reading ouside the buffer's boundaries. - * \param rgba the returned colors - */ -void -_swrast_read_rgba_span( struct gl_context *ctx, struct gl_renderbuffer *rb, - GLuint n, GLint x, GLint y, - GLvoid *rgba) -{ - struct swrast_renderbuffer *srb = swrast_renderbuffer(rb); - GLenum dstType = GL_FLOAT; - const GLint bufWidth = (GLint) rb->Width; - const GLint bufHeight = (GLint) rb->Height; - - if (y < 0 || y >= bufHeight || x + (GLint) n < 0 || x >= bufWidth) { - /* completely above, below, or right */ - /* XXX maybe leave rgba values undefined? */ - memset(rgba, 0, 4 * n * sizeof(GLchan)); - } - else { - GLint skip, length; - GLubyte *src; - - if (x < 0) { - /* left edge clipping */ - skip = -x; - length = (GLint) n - skip; - if (length < 0) { - /* completely left of window */ - return; - } - if (length > bufWidth) { - length = bufWidth; - } - } - else if ((GLint) (x + n) > bufWidth) { - /* right edge clipping */ - skip = 0; - length = bufWidth - x; - if (length < 0) { - /* completely to right of window */ - return; - } - } - else { - /* no clipping */ - skip = 0; - length = (GLint) n; - } - - ASSERT(rb); - ASSERT(rb->_BaseFormat == GL_RGBA || - rb->_BaseFormat == GL_RGB || - rb->_BaseFormat == GL_RG || - rb->_BaseFormat == GL_RED || - rb->_BaseFormat == GL_LUMINANCE || - rb->_BaseFormat == GL_INTENSITY || - rb->_BaseFormat == GL_LUMINANCE_ALPHA || - rb->_BaseFormat == GL_ALPHA); - - assert(srb->Map); - - src = _swrast_pixel_address(rb, x + skip, y); - - if (dstType == GL_UNSIGNED_BYTE) { - _mesa_unpack_ubyte_rgba_row(rb->Format, length, src, - (GLubyte (*)[4]) rgba + skip); - } - else if (dstType == GL_FLOAT) { - _mesa_unpack_rgba_row(rb->Format, length, src, - (GLfloat (*)[4]) rgba + skip); - } - else { - _mesa_problem(ctx, "unexpected type in _swrast_read_rgba_span()"); - } - } -} - - -/** - * Get colors at x/y positions with clipping. - * \param type type of values to return - */ -static void -get_values(struct gl_context *ctx, struct gl_renderbuffer *rb, - GLuint count, const GLint x[], const GLint y[], - void *values, GLenum type) -{ - GLuint i; - - for (i = 0; i < count; i++) { - if (x[i] >= 0 && y[i] >= 0 && - x[i] < (GLint) rb->Width && y[i] < (GLint) rb->Height) { - /* inside */ - const GLubyte *src = _swrast_pixel_address(rb, x[i], y[i]); - - if (type == GL_UNSIGNED_BYTE) { - _mesa_unpack_ubyte_rgba_row(rb->Format, 1, src, - (GLubyte (*)[4]) values + i); - } - else if (type == GL_FLOAT) { - _mesa_unpack_rgba_row(rb->Format, 1, src, - (GLfloat (*)[4]) values + i); - } - else { - _mesa_problem(ctx, "unexpected type in get_values()"); - } - } - } -} - - -/** - * Get row of colors with clipping. - * \param type type of values to return - */ -static void -get_row(struct gl_context *ctx, struct gl_renderbuffer *rb, - GLuint count, GLint x, GLint y, - GLvoid *values, GLenum type) -{ - GLint skip = 0; - GLubyte *src; - - if (y < 0 || y >= (GLint) rb->Height) - return; /* above or below */ - - if (x + (GLint) count <= 0 || x >= (GLint) rb->Width) - return; /* entirely left or right */ - - if (x + count > rb->Width) { - /* right clip */ - GLint clip = x + count - rb->Width; - count -= clip; - } - - if (x < 0) { - /* left clip */ - skip = -x; - x = 0; - count -= skip; - } - - src = _swrast_pixel_address(rb, x, y); - - if (type == GL_UNSIGNED_BYTE) { - _mesa_unpack_ubyte_rgba_row(rb->Format, count, src, - (GLubyte (*)[4]) values + skip); - } - else if (type == GL_FLOAT) { - _mesa_unpack_rgba_row(rb->Format, count, src, - (GLfloat (*)[4]) values + skip); - } - else { - _mesa_problem(ctx, "unexpected type in get_row()"); - } -} - - -/** - * Get RGBA pixels from the given renderbuffer. - * Used by blending, logicop and masking functions. - * \return pointer to the colors we read. - */ -void * -_swrast_get_dest_rgba(struct gl_context *ctx, struct gl_renderbuffer *rb, - SWspan *span) -{ - void *rbPixels; - - /* Point rbPixels to a temporary space */ - rbPixels = span->array->attribs[FRAG_ATTRIB_MAX - 1]; - - /* Get destination values from renderbuffer */ - if (span->arrayMask & SPAN_XY) { - get_values(ctx, rb, span->end, span->array->x, span->array->y, - rbPixels, span->array->ChanType); - } - else { - get_row(ctx, rb, span->end, span->x, span->y, - rbPixels, span->array->ChanType); - } - - return rbPixels; -} diff --git a/dll/opengl/mesa/swrast/s_span.h b/dll/opengl/mesa/swrast/s_span.h deleted file mode 100644 index be41d113fc0..00000000000 --- a/dll/opengl/mesa/swrast/s_span.h +++ /dev/null @@ -1,212 +0,0 @@ -/* - * Mesa 3-D graphics library - * Version: 7.5 - * - * Copyright (C) 1999-2008 Brian Paul All Rights Reserved. - * Copyright (C) 2009 VMware, Inc. All Rights Reserved. - * - * Permission is hereby granted, free of charge, to any person obtaining a - * copy of this software and associated documentation files (the "Software"), - * to deal in the Software without restriction, including without limitation - * the rights to use, copy, modify, merge, publish, distribute, sublicense, - * and/or sell copies of the Software, and to permit persons to whom the - * Software is furnished to do so, subject to the following conditions: - * - * The above copyright notice and this permission notice shall be included - * in all copies or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS - * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL - * BRIAN PAUL BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN - * AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN - * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. - */ - - -#ifndef S_SPAN_H -#define S_SPAN_H - - -#include "main/config.h" -#include "main/glheader.h" -#include "main/mtypes.h" -#include "swrast/s_chan.h" - - -struct gl_context; -struct gl_renderbuffer; - - -/** - * \defgroup SpanFlags - * Special bitflags to describe span data. - * - * In general, the point/line/triangle functions interpolate/emit the - * attributes specified by swrast->_ActiveAttribs (i.e. FRAT_BIT_* values). - * Some things don't fit into that, though, so we have these flags. - */ -/*@{*/ -#define SPAN_RGBA 0x01 /**< interpMask and arrayMask */ -#define SPAN_Z 0x02 /**< interpMask and arrayMask */ -#define SPAN_FLAT 0x04 /**< interpMask: flat shading? */ -#define SPAN_XY 0x08 /**< array.x[], y[] valid? */ -#define SPAN_MASK 0x10 /**< was array.mask[] filled in by caller? */ -#define SPAN_LAMBDA 0x20 /**< array.lambda[] valid? */ -#define SPAN_COVERAGE 0x40 /**< array.coverage[] valid? */ -/*@}*/ - - -/** - * \sw_span_arrays - * \brief Arrays of fragment values. - * - * These will either be computed from the span x/xStep values or - * filled in by glDraw/CopyPixels, etc. - * These arrays are separated out of sw_span to conserve memory. - */ -typedef struct sw_span_arrays -{ - /** Per-fragment attributes (indexed by FRAG_ATTRIB_* tokens) */ - /* XXX someday look at transposing first two indexes for better memory - * access pattern. - */ - GLfloat attribs[FRAG_ATTRIB_MAX][MAX_WIDTH][4]; - - /** This mask indicates which fragments are alive or culled */ - GLubyte mask[MAX_WIDTH]; - - GLenum ChanType; /**< Color channel type, GL_UNSIGNED_BYTE, GL_FLOAT */ - - /** Attribute arrays that don't fit into attribs[] array above */ - /*@{*/ - GLubyte rgba8[MAX_WIDTH][4]; - GLushort rgba16[MAX_WIDTH][4]; - GLchan (*rgba)[4]; /** either == rgba8 or rgba16 */ - GLint x[MAX_WIDTH]; /**< fragment X coords */ - GLint y[MAX_WIDTH]; /**< fragment Y coords */ - GLuint z[MAX_WIDTH]; /**< fragment Z coords */ - GLuint index[MAX_WIDTH]; /**< Color indexes */ - GLfloat lambda[MAX_WIDTH]; /**< Texture LOD */ - GLfloat coverage[MAX_WIDTH]; /**< Fragment coverage for AA/smoothing */ - /*@}*/ -} SWspanarrays; - - -/** - * The SWspan structure describes the colors, Z, fogcoord, texcoords, - * etc for either a horizontal run or an array of independent pixels. - * We can either specify a base/step to indicate interpolated values, or - * fill in explicit arrays of values. The interpMask and arrayMask bitfields - * indicate which attributes are active interpolants or arrays, respectively. - * - * It would be interesting to experiment with multiprocessor rasterization - * with this structure. The triangle rasterizer could simply emit a - * stream of these structures which would be consumed by one or more - * span-processing threads which could run in parallel. - */ -typedef struct sw_span -{ - /** Coord of first fragment in horizontal span/run */ - GLint x, y; - - /** Number of fragments in the span */ - GLuint end; - - /** for clipping left edge of spans */ - GLuint leftClip; - - /** This flag indicates that mask[] array is effectively filled with ones */ - GLboolean writeAll; - - /** either GL_POLYGON, GL_LINE, GL_POLYGON, GL_BITMAP */ - GLenum primitive; - - /** - * This bitmask (of \link SpanFlags SPAN_* flags\endlink) indicates - * which of the attrStart/StepX/StepY variables are relevant. - */ - GLbitfield interpMask; - - /** Fragment attribute interpolants */ - GLfloat attrStart[FRAG_ATTRIB_MAX][4]; /**< initial value */ - GLfloat attrStepX[FRAG_ATTRIB_MAX][4]; /**< dvalue/dx */ - GLfloat attrStepY[FRAG_ATTRIB_MAX][4]; /**< dvalue/dy */ - - /* XXX the rest of these will go away eventually... */ - - /* For horizontal spans, step is the partial derivative wrt X. - * For lines, step is the delta from one fragment to the next. - */ - GLfixed red, redStep; - GLfixed green, greenStep; - GLfixed blue, blueStep; - GLfixed alpha, alphaStep; - GLfixed index, indexStep; - GLfixed z, zStep; /**< XXX z should probably be GLuint */ - GLfixed intTex[2], intTexStep[2]; /**< (s,t) for unit[0] only */ - - /** - * This bitmask (of \link SpanFlags SPAN_* flags\endlink) indicates - * which of the fragment arrays in the span_arrays struct are relevant. - */ - GLbitfield arrayMask; - - /** Mask of FRAG_BIT_x bits */ - GLbitfield64 arrayAttribs; - - /** - * We store the arrays of fragment values in a separate struct so - * that we can allocate sw_span structs on the stack without using - * a lot of memory. The span_arrays struct is about 1.4MB while the - * sw_span struct is only about 512 bytes. - */ - SWspanarrays *array; -} SWspan; - - - -#define INIT_SPAN(S, PRIMITIVE) \ -do { \ - (S).primitive = (PRIMITIVE); \ - (S).interpMask = 0x0; \ - (S).arrayMask = 0x0; \ - (S).arrayAttribs = 0x0; \ - (S).end = 0; \ - (S).leftClip = 0; \ - (S).array = SWRAST_CONTEXT(ctx)->SpanArrays; \ -} while (0) - - - -extern void -_swrast_span_default_attribs(struct gl_context *ctx, SWspan *span); - -extern void -_swrast_span_interpolate_z( const struct gl_context *ctx, SWspan *span ); - -extern GLfloat -_swrast_compute_lambda(GLfloat dsdx, GLfloat dsdy, GLfloat dtdx, GLfloat dtdy, - GLfloat dqdx, GLfloat dqdy, GLfloat texW, GLfloat texH, - GLfloat s, GLfloat t, GLfloat q, GLfloat invQ); - - -extern void -_swrast_write_rgba_span( struct gl_context *ctx, SWspan *span); - - -extern void -_swrast_read_rgba_span(struct gl_context *ctx, struct gl_renderbuffer *rb, - GLuint n, GLint x, GLint y, GLvoid *rgba); - -extern void -_swrast_put_row(struct gl_context *ctx, struct gl_renderbuffer *rb, - GLenum datatype, - GLuint count, GLint x, GLint y, - const void *values, const GLubyte *mask); - -extern void * -_swrast_get_dest_rgba(struct gl_context *ctx, struct gl_renderbuffer *rb, - SWspan *span); - -#endif diff --git a/dll/opengl/mesa/swrast/s_stencil.c b/dll/opengl/mesa/swrast/s_stencil.c deleted file mode 100644 index 16ca4f725d7..00000000000 --- a/dll/opengl/mesa/swrast/s_stencil.c +++ /dev/null @@ -1,602 +0,0 @@ -/* - * Mesa 3-D graphics library - * Version: 7.1 - * - * Copyright (C) 1999-2007 Brian Paul All Rights Reserved. - * - * Permission is hereby granted, free of charge, to any person obtaining a - * copy of this software and associated documentation files (the "Software"), - * to deal in the Software without restriction, including without limitation - * the rights to use, copy, modify, merge, publish, distribute, sublicense, - * and/or sell copies of the Software, and to permit persons to whom the - * Software is furnished to do so, subject to the following conditions: - * - * The above copyright notice and this permission notice shall be included - * in all copies or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS - * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL - * BRIAN PAUL BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN - * AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN - * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. - */ - -#include - -/* Stencil Logic: - -IF stencil test fails THEN - Apply fail-op to stencil value - Don't write the pixel (RGBA,Z) -ELSE - IF doing depth test && depth test fails THEN - Apply zfail-op to stencil value - Write RGBA and Z to appropriate buffers - ELSE - Apply zpass-op to stencil value -ENDIF - -*/ - - - -/** - * Compute/return the offset of the stencil value in a pixel. - * For example, if the format is Z24+S8, the position of the stencil bits - * within the 4-byte pixel will be either 0 or 3. - */ -static GLint -get_stencil_offset(gl_format format) -{ - const GLubyte one = 1; - GLubyte pixel[MAX_PIXEL_BYTES]; - GLint bpp = _mesa_get_format_bytes(format); - GLint i; - - assert(_mesa_get_format_bits(format, GL_STENCIL_BITS) == 8); - memset(pixel, 0, sizeof(pixel)); - _mesa_pack_ubyte_stencil_row(format, 1, &one, pixel); - - for (i = 0; i < bpp; i++) { - if (pixel[i]) - return i; - } - - _mesa_problem(NULL, "get_stencil_offset() failed\n"); - return 0; -} - - -/** Clamp the stencil value to [0, 255] */ -static inline GLubyte -clamp(GLint val) -{ - if (val < 0) - return 0; - else if (val > 255) - return 255; - else - return val; -} - - -#define STENCIL_OP(NEW_VAL) \ - if (invmask == 0) { \ - for (i = j = 0; i < n; i++, j += stride) { \ - if (mask[i]) { \ - GLubyte s = stencil[j]; \ - (void) s; \ - stencil[j] = (GLubyte) (NEW_VAL); \ - } \ - } \ - } \ - else { \ - for (i = j = 0; i < n; i++, j += stride) { \ - if (mask[i]) { \ - GLubyte s = stencil[j]; \ - stencil[j] = (GLubyte) ((invmask & s) | (wrtmask & (NEW_VAL))); \ - } \ - } \ - } - - -/** - * Apply the given stencil operator to the array of stencil values. - * Don't touch stencil[i] if mask[i] is zero. - * @param n number of stencil values - * @param oper the stencil buffer operator - * @param face 0 or 1 for front or back face operation - * @param stencil array of stencil values (in/out) - * @param mask array [n] of flag: 1=apply operator, 0=don't apply operator - * @param stride stride between stencil values - */ -static void -apply_stencil_op(const struct gl_context *ctx, GLenum oper, - GLuint n, GLubyte stencil[], const GLubyte mask[], - GLint stride) -{ - const GLubyte ref = ctx->Stencil.Ref; - const GLubyte wrtmask = ctx->Stencil.WriteMask; - const GLubyte invmask = (GLubyte) (~wrtmask); - GLuint i, j; - - switch (oper) { - case GL_KEEP: - /* do nothing */ - break; - case GL_ZERO: - /* replace stencil buf values with zero */ - STENCIL_OP(0); - break; - case GL_REPLACE: - /* replace stencil buf values with ref value */ - STENCIL_OP(ref); - break; - case GL_INCR: - /* increment stencil buf values, with clamping */ - STENCIL_OP(clamp(s + 1)); - break; - case GL_DECR: - /* increment stencil buf values, with clamping */ - STENCIL_OP(clamp(s - 1)); - break; - case GL_INCR_WRAP_EXT: - /* increment stencil buf values, without clamping */ - STENCIL_OP(s + 1); - break; - case GL_DECR_WRAP_EXT: - /* increment stencil buf values, without clamping */ - STENCIL_OP(s - 1); - break; - case GL_INVERT: - /* replace stencil buf values with inverted value */ - STENCIL_OP(~s); - break; - default: - _mesa_problem(ctx, "Bad stencil op in apply_stencil_op"); - } -} - - - -#define STENCIL_TEST(FUNC) \ - for (i = j = 0; i < n; i++, j += stride) { \ - if (mask[i]) { \ - s = (GLubyte) (stencil[j] & valueMask); \ - if (FUNC) { \ - /* stencil pass */ \ - fail[i] = 0; \ - } \ - else { \ - /* stencil fail */ \ - fail[i] = 1; \ - mask[i] = 0; \ - } \ - } \ - else { \ - fail[i] = 0; \ - } \ - } - - - -/** - * Apply stencil test to an array of stencil values (before depth buffering). - * For the values that fail, we'll apply the GL_STENCIL_FAIL operator to - * the stencil values. - * - * @param face 0 or 1 for front or back-face polygons - * @param n number of pixels in the array - * @param stencil array of [n] stencil values (in/out) - * @param mask array [n] of flag: 0=skip the pixel, 1=stencil the pixel, - * values are set to zero where the stencil test fails. - * @param stride stride between stencil values - * @return GL_FALSE = all pixels failed, GL_TRUE = zero or more pixels passed. - */ -static GLboolean -do_stencil_test(struct gl_context *ctx, GLuint n, - GLubyte stencil[], GLubyte mask[], GLint stride) -{ - GLubyte fail[MAX_WIDTH]; - GLboolean allfail = GL_FALSE; - GLuint i, j; - const GLuint valueMask = ctx->Stencil.ValueMask; - const GLubyte ref = (GLubyte) (ctx->Stencil.Ref & valueMask); - GLubyte s; - - /* - * Perform stencil test. The results of this operation are stored - * in the fail[] array: - * IF fail[i] is non-zero THEN - * the stencil fail operator is to be applied - * ELSE - * the stencil fail operator is not to be applied - * ENDIF - */ - switch (ctx->Stencil.Function) { - case GL_NEVER: - STENCIL_TEST(0); - allfail = GL_TRUE; - break; - case GL_LESS: - STENCIL_TEST(ref < s); - break; - case GL_LEQUAL: - STENCIL_TEST(ref <= s); - break; - case GL_GREATER: - STENCIL_TEST(ref > s); - break; - case GL_GEQUAL: - STENCIL_TEST(ref >= s); - break; - case GL_EQUAL: - STENCIL_TEST(ref == s); - break; - case GL_NOTEQUAL: - STENCIL_TEST(ref != s); - break; - case GL_ALWAYS: - STENCIL_TEST(1); - break; - default: - _mesa_problem(ctx, "Bad stencil func in gl_stencil_span"); - return 0; - } - - if (ctx->Stencil.FailFunc != GL_KEEP) { - apply_stencil_op(ctx, ctx->Stencil.FailFunc, n, stencil, - fail, stride); - } - - return !allfail; -} - - -/** - * Compute the zpass/zfail masks by comparing the pre- and post-depth test - * masks. - */ -static inline void -compute_pass_fail_masks(GLuint n, const GLubyte origMask[], - const GLubyte newMask[], - GLubyte passMask[], GLubyte failMask[]) -{ - GLuint i; - for (i = 0; i < n; i++) { - ASSERT(newMask[i] == 0 || newMask[i] == 1); - passMask[i] = origMask[i] & newMask[i]; - failMask[i] = origMask[i] & (newMask[i] ^ 1); - } -} - - -/** - * Get 8-bit stencil values from random locations in the stencil buffer. - */ -static void -get_s8_values(struct gl_context *ctx, struct gl_renderbuffer *rb, - GLuint count, const GLint x[], const GLint y[], - GLubyte stencil[]) -{ - struct swrast_renderbuffer *srb = swrast_renderbuffer(rb); - const GLint w = rb->Width, h = rb->Height; - const GLubyte *map = _swrast_pixel_address(rb, 0, 0); - GLuint i; - - if (rb->Format == MESA_FORMAT_S8) { - const GLint rowStride = srb->RowStride; - for (i = 0; i < count; i++) { - if (x[i] >= 0 && y[i] >= 0 && x[i] < w && y[i] < h) { - stencil[i] = *(map + y[i] * rowStride + x[i]); - } - } - } - else { - const GLint bpp = _mesa_get_format_bytes(rb->Format); - const GLint rowStride = srb->RowStride; - for (i = 0; i < count; i++) { - if (x[i] >= 0 && y[i] >= 0 && x[i] < w && y[i] < h) { - const GLubyte *src = map + y[i] * rowStride + x[i] * bpp; - _mesa_unpack_ubyte_stencil_row(rb->Format, 1, src, &stencil[i]); - } - } - } -} - - -/** - * Put 8-bit stencil values at random locations into the stencil buffer. - */ -static void -put_s8_values(struct gl_context *ctx, struct gl_renderbuffer *rb, - GLuint count, const GLint x[], const GLint y[], - const GLubyte stencil[]) -{ - const GLint w = rb->Width, h = rb->Height; - gl_pack_ubyte_stencil_func pack_stencil = - _mesa_get_pack_ubyte_stencil_func(rb->Format); - GLuint i; - - for (i = 0; i < count; i++) { - if (x[i] >= 0 && y[i] >= 0 && x[i] < w && y[i] < h) { - GLubyte *dst = _swrast_pixel_address(rb, x[i], y[i]); - pack_stencil(&stencil[i], dst); - } - } -} - - -/** - * /return GL_TRUE = one or more fragments passed, - * GL_FALSE = all fragments failed. - */ -GLboolean -_swrast_stencil_and_ztest_span(struct gl_context *ctx, SWspan *span) -{ - struct gl_framebuffer *fb = ctx->DrawBuffer; - struct gl_renderbuffer *rb = fb->Attachment[BUFFER_STENCIL].Renderbuffer; - const GLint stencilOffset = get_stencil_offset(rb->Format); - const GLint stencilStride = _mesa_get_format_bytes(rb->Format); - const GLuint count = span->end; - GLubyte *mask = span->array->mask; - GLubyte stencilTemp[MAX_WIDTH]; - GLubyte *stencilBuf; - - if (span->arrayMask & SPAN_XY) { - /* read stencil values from random locations */ - get_s8_values(ctx, rb, count, span->array->x, span->array->y, - stencilTemp); - stencilBuf = stencilTemp; - } - else { - /* Processing a horizontal run of pixels. Since stencil is always - * 8 bits for all MESA_FORMATs, we just need to use the right offset - * and stride to access them. - */ - stencilBuf = _swrast_pixel_address(rb, span->x, span->y) + stencilOffset; - } - - /* - * Apply the stencil test to the fragments. - * failMask[i] is 1 if the stencil test failed. - */ - if (!do_stencil_test(ctx, count, stencilBuf, mask, stencilStride)) { - /* all fragments failed the stencil test, we're done. */ - span->writeAll = GL_FALSE; - if (span->arrayMask & SPAN_XY) { - /* need to write the updated stencil values back to the buffer */ - put_s8_values(ctx, rb, count, span->array->x, span->array->y, - stencilTemp); - } - return GL_FALSE; - } - - /* - * Some fragments passed the stencil test, apply depth test to them - * and apply Zpass and Zfail stencil ops. - */ - if (ctx->Depth.Test == GL_FALSE || - ctx->DrawBuffer->Attachment[BUFFER_DEPTH].Renderbuffer == NULL) { - /* - * No depth buffer, just apply zpass stencil function to active pixels. - */ - apply_stencil_op(ctx, ctx->Stencil.ZPassFunc, count, - stencilBuf, mask, stencilStride); - } - else { - /* - * Perform depth buffering, then apply zpass or zfail stencil function. - */ - GLubyte passMask[MAX_WIDTH], failMask[MAX_WIDTH], origMask[MAX_WIDTH]; - - /* save the current mask bits */ - memcpy(origMask, mask, count * sizeof(GLubyte)); - - /* apply the depth test */ - _swrast_depth_test_span(ctx, span); - - compute_pass_fail_masks(count, origMask, mask, passMask, failMask); - - /* apply the pass and fail operations */ - if (ctx->Stencil.ZFailFunc != GL_KEEP) { - apply_stencil_op(ctx, ctx->Stencil.ZFailFunc, - count, stencilBuf, failMask, stencilStride); - } - if (ctx->Stencil.ZPassFunc != GL_KEEP) { - apply_stencil_op(ctx, ctx->Stencil.ZPassFunc, - count, stencilBuf, passMask, stencilStride); - } - } - - /* Write updated stencil values back into hardware stencil buffer */ - if (span->arrayMask & SPAN_XY) { - put_s8_values(ctx, rb, count, span->array->x, span->array->y, - stencilBuf); - } - - span->writeAll = GL_FALSE; - - return GL_TRUE; /* one or more fragments passed both tests */ -} - - - - -/** - * Return a span of stencil values from the stencil buffer. - * Used for glRead/CopyPixels - * Input: n - how many pixels - * x,y - location of first pixel - * Output: stencil - the array of stencil values - */ -void -_swrast_read_stencil_span(struct gl_context *ctx, struct gl_renderbuffer *rb, - GLint n, GLint x, GLint y, GLubyte stencil[]) -{ - GLubyte *src; - - if (y < 0 || y >= (GLint) rb->Height || - x + n <= 0 || x >= (GLint) rb->Width) { - /* span is completely outside framebuffer */ - return; /* undefined values OK */ - } - - if (x < 0) { - GLint dx = -x; - x = 0; - n -= dx; - stencil += dx; - } - if (x + n > (GLint) rb->Width) { - GLint dx = x + n - rb->Width; - n -= dx; - } - if (n <= 0) { - return; - } - - src = _swrast_pixel_address(rb, x, y); - _mesa_unpack_ubyte_stencil_row(rb->Format, n, src, stencil); -} - - - -/** - * Write a span of stencil values to the stencil buffer. This function - * applies the stencil write mask when needed. - * Used for glDraw/CopyPixels - * Input: n - how many pixels - * x, y - location of first pixel - * stencil - the array of stencil values - */ -void -_swrast_write_stencil_span(struct gl_context *ctx, GLint n, GLint x, GLint y, - const GLubyte stencil[] ) -{ - struct gl_framebuffer *fb = ctx->DrawBuffer; - struct gl_renderbuffer *rb = fb->Attachment[BUFFER_STENCIL].Renderbuffer; - const GLuint stencilMax = (1 << fb->Visual.stencilBits) - 1; - const GLuint stencilMask = ctx->Stencil.WriteMask; - GLubyte *stencilBuf; - - if (y < 0 || y >= (GLint) rb->Height || - x + n <= 0 || x >= (GLint) rb->Width) { - /* span is completely outside framebuffer */ - return; /* undefined values OK */ - } - if (x < 0) { - GLint dx = -x; - x = 0; - n -= dx; - stencil += dx; - } - if (x + n > (GLint) rb->Width) { - GLint dx = x + n - rb->Width; - n -= dx; - } - if (n <= 0) { - return; - } - - stencilBuf = _swrast_pixel_address(rb, x, y); - - if ((stencilMask & stencilMax) != stencilMax) { - /* need to apply writemask */ - GLubyte destVals[MAX_WIDTH], newVals[MAX_WIDTH]; - GLint i; - - _mesa_unpack_ubyte_stencil_row(rb->Format, n, stencilBuf, destVals); - for (i = 0; i < n; i++) { - newVals[i] - = (stencil[i] & stencilMask) | (destVals[i] & ~stencilMask); - } - _mesa_pack_ubyte_stencil_row(rb->Format, n, newVals, stencilBuf); - } - else { - _mesa_pack_ubyte_stencil_row(rb->Format, n, stencil, stencilBuf); - } -} - - - -/** - * Clear the stencil buffer. If the buffer is a combined - * depth+stencil buffer, only the stencil bits will be touched. - */ -void -_swrast_clear_stencil_buffer(struct gl_context *ctx) -{ - struct gl_renderbuffer *rb = - ctx->DrawBuffer->Attachment[BUFFER_STENCIL].Renderbuffer; - const GLubyte stencilBits = ctx->DrawBuffer->Visual.stencilBits; - const GLuint writeMask = ctx->Stencil.WriteMask; - const GLuint stencilMax = (1 << stencilBits) - 1; - GLint x, y, width, height; - GLubyte *map; - GLint rowStride, i, j; - GLbitfield mapMode; - - if (!rb || writeMask == 0) - return; - - /* compute region to clear */ - x = ctx->DrawBuffer->_Xmin; - y = ctx->DrawBuffer->_Ymin; - width = ctx->DrawBuffer->_Xmax - ctx->DrawBuffer->_Xmin; - height = ctx->DrawBuffer->_Ymax - ctx->DrawBuffer->_Ymin; - - mapMode = GL_MAP_WRITE_BIT; - if ((writeMask & stencilMax) != stencilMax) { - /* need to mask stencil values */ - mapMode |= GL_MAP_READ_BIT; - } - else if (_mesa_get_format_bits(rb->Format, GL_DEPTH_BITS) > 0) { - /* combined depth+stencil, need to mask Z values */ - mapMode |= GL_MAP_READ_BIT; - } - - ctx->Driver.MapRenderbuffer(ctx, rb, x, y, width, height, - mapMode, &map, &rowStride); - if (!map) { - _mesa_error(ctx, GL_OUT_OF_MEMORY, "glClear(stencil)"); - return; - } - - switch (rb->Format) { - case MESA_FORMAT_S8: - { - GLubyte clear = ctx->Stencil.Clear & writeMask & 0xff; - GLubyte mask = (~writeMask) & 0xff; - if (mask != 0) { - /* masked clear */ - for (i = 0; i < height; i++) { - GLubyte *row = map; - for (j = 0; j < width; j++) { - row[j] = (row[j] & mask) | clear; - } - map += rowStride; - } - } - else if (rowStride == width) { - /* clear whole buffer */ - memset(map, clear, width * height); - } - else { - /* clear scissored */ - for (i = 0; i < height; i++) { - memset(map, clear, width); - map += rowStride; - } - } - } - break; - default: - _mesa_problem(ctx, "Unexpected stencil buffer format %s" - " in _swrast_clear_stencil_buffer()", - _mesa_get_format_name(rb->Format)); - } - - ctx->Driver.UnmapRenderbuffer(ctx, rb); -} diff --git a/dll/opengl/mesa/swrast/s_stencil.h b/dll/opengl/mesa/swrast/s_stencil.h deleted file mode 100644 index 113649a375c..00000000000 --- a/dll/opengl/mesa/swrast/s_stencil.h +++ /dev/null @@ -1,53 +0,0 @@ -/* - * Mesa 3-D graphics library - * Version: 6.3 - * - * Copyright (C) 1999-2005 Brian Paul All Rights Reserved. - * - * Permission is hereby granted, free of charge, to any person obtaining a - * copy of this software and associated documentation files (the "Software"), - * to deal in the Software without restriction, including without limitation - * the rights to use, copy, modify, merge, publish, distribute, sublicense, - * and/or sell copies of the Software, and to permit persons to whom the - * Software is furnished to do so, subject to the following conditions: - * - * The above copyright notice and this permission notice shall be included - * in all copies or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS - * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL - * BRIAN PAUL BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN - * AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN - * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. - */ - - -#ifndef S_STENCIL_H -#define S_STENCIL_H - - -#include "main/mtypes.h" -#include "s_span.h" - - - -extern GLboolean -_swrast_stencil_and_ztest_span(struct gl_context *ctx, SWspan *span); - - -extern void -_swrast_read_stencil_span(struct gl_context *ctx, struct gl_renderbuffer *rb, - GLint n, GLint x, GLint y, GLubyte stencil[]); - - -extern void -_swrast_write_stencil_span( struct gl_context *ctx, GLint n, GLint x, GLint y, - const GLubyte stencil[] ); - - -extern void -_swrast_clear_stencil_buffer(struct gl_context *ctx); - - -#endif diff --git a/dll/opengl/mesa/swrast/s_texcombine.c b/dll/opengl/mesa/swrast/s_texcombine.c deleted file mode 100644 index acdacf43ccc..00000000000 --- a/dll/opengl/mesa/swrast/s_texcombine.c +++ /dev/null @@ -1,625 +0,0 @@ -/* - * Mesa 3-D graphics library - * Version: 7.5 - * - * Copyright (C) 1999-2008 Brian Paul All Rights Reserved. - * Copyright (C) 2009 VMware, Inc. All Rights Reserved. - * - * Permission is hereby granted, free of charge, to any person obtaining a - * copy of this software and associated documentation files (the "Software"), - * to deal in the Software without restriction, including without limitation - * the rights to use, copy, modify, merge, publish, distribute, sublicense, - * and/or sell copies of the Software, and to permit persons to whom the - * Software is furnished to do so, subject to the following conditions: - * - * The above copyright notice and this permission notice shall be included - * in all copies or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS - * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL - * BRIAN PAUL BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN - * AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN - * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. - */ - -#include - -/** - * Pointer to array of float[4] - * This type makes the code below more concise and avoids a lot of casting. - */ -typedef float (*float4_array)[4]; - - -/** - * Return array of texels for given unit. - */ -static inline float4_array -get_texel_array(SWcontext *swrast) -{ -#ifdef _OPENMP - return (float4_array) (swrast->TexelBuffer + (MAX_WIDTH * 4 * omp_get_thread_num())); -#else - return (float4_array) (swrast->TexelBuffer); -#endif -} - - - -/** - * Do texture application for: - * GL_EXT_texture_env_combine - * GL_ARB_texture_env_combine - * GL_EXT_texture_env_dot3 - * GL_ARB_texture_env_dot3 - * GL_ATI_texture_env_combine3 - * GL_NV_texture_env_combine4 - * conventional GL texture env modes - * - * \param ctx rendering context - * \param unit the texture combiner unit - * \param primary_rgba incoming fragment color array - * \param texelBuffer pointer to texel colors for all texture units - * - * \param span two fields are used in this function: - * span->end: number of fragments to process - * span->array->rgba: incoming/result fragment colors - */ -static void -texture_combine( struct gl_context *ctx, - const float4_array primary_rgba, - const GLfloat *texelBuffer, - SWspan *span ) -{ - SWcontext *swrast = SWRAST_CONTEXT(ctx); - const struct gl_texture_unit *textureUnit = &ctx->Texture.Unit; - const struct gl_tex_env_combine_state *combine = textureUnit->_CurrentCombine; - float4_array argRGB[MAX_COMBINER_TERMS]; - float4_array argA[MAX_COMBINER_TERMS]; - const GLfloat scaleRGB = (GLfloat) (1 << combine->ScaleShiftRGB); - const GLfloat scaleA = (GLfloat) (1 << combine->ScaleShiftA); - const GLuint numArgsRGB = combine->_NumArgsRGB; - const GLuint numArgsA = combine->_NumArgsA; - float4_array ccolor[4], rgba; - GLuint i, term; - GLuint n = span->end; - GLchan (*rgbaChan)[4] = span->array->rgba; - - /* alloc temp pixel buffers */ - rgba = (float4_array) malloc(4 * n * sizeof(GLfloat)); - if (!rgba) { - _mesa_error(ctx, GL_OUT_OF_MEMORY, "texture_combine"); - return; - } - - for (i = 0; i < numArgsRGB || i < numArgsA; i++) { - ccolor[i] = (float4_array) malloc(4 * n * sizeof(GLfloat)); - if (!ccolor[i]) { - while (i) { - free(ccolor[i]); - i--; - } - _mesa_error(ctx, GL_OUT_OF_MEMORY, "texture_combine"); - free(rgba); - return; - } - } - - for (i = 0; i < n; i++) { - rgba[i][RCOMP] = CHAN_TO_FLOAT(rgbaChan[i][RCOMP]); - rgba[i][GCOMP] = CHAN_TO_FLOAT(rgbaChan[i][GCOMP]); - rgba[i][BCOMP] = CHAN_TO_FLOAT(rgbaChan[i][BCOMP]); - rgba[i][ACOMP] = CHAN_TO_FLOAT(rgbaChan[i][ACOMP]); - } - - /* - printf("modeRGB 0x%x modeA 0x%x srcRGB1 0x%x srcA1 0x%x srcRGB2 0x%x srcA2 0x%x\n", - combine->ModeRGB, - combine->ModeA, - combine->SourceRGB[0], - combine->SourceA[0], - combine->SourceRGB[1], - combine->SourceA[1]); - */ - - /* - * Do operand setup for up to 4 operands. Loop over the terms. - */ - for (term = 0; term < numArgsRGB; term++) { - const GLenum srcRGB = combine->SourceRGB[term]; - const GLenum operandRGB = combine->OperandRGB[term]; - - switch (srcRGB) { - case GL_TEXTURE: - argRGB[term] = get_texel_array(swrast); - break; - case GL_PRIMARY_COLOR: - argRGB[term] = primary_rgba; - break; - case GL_PREVIOUS: - argRGB[term] = rgba; - break; - case GL_CONSTANT: - { - float4_array c = ccolor[term]; - GLfloat red = textureUnit->EnvColor[0]; - GLfloat green = textureUnit->EnvColor[1]; - GLfloat blue = textureUnit->EnvColor[2]; - GLfloat alpha = textureUnit->EnvColor[3]; - for (i = 0; i < n; i++) { - ASSIGN_4V(c[i], red, green, blue, alpha); - } - argRGB[term] = ccolor[term]; - } - break; - /* GL_ATI_texture_env_combine3 allows GL_ZERO & GL_ONE as sources. - */ - case GL_ZERO: - { - float4_array c = ccolor[term]; - for (i = 0; i < n; i++) { - ASSIGN_4V(c[i], 0.0F, 0.0F, 0.0F, 0.0F); - } - argRGB[term] = ccolor[term]; - } - break; - case GL_ONE: - { - float4_array c = ccolor[term]; - for (i = 0; i < n; i++) { - ASSIGN_4V(c[i], 1.0F, 1.0F, 1.0F, 1.0F); - } - argRGB[term] = ccolor[term]; - } - break; - default: - /* ARB_texture_env_crossbar source */ - { - if (!ctx->Texture.Unit._ReallyEnabled) - goto end; - argRGB[term] = get_texel_array(swrast); - } - } - - if (operandRGB != GL_SRC_COLOR) { - float4_array src = argRGB[term]; - float4_array dst = ccolor[term]; - - /* point to new arg[term] storage */ - argRGB[term] = ccolor[term]; - - switch (operandRGB) { - case GL_ONE_MINUS_SRC_COLOR: - for (i = 0; i < n; i++) { - dst[i][RCOMP] = 1.0F - src[i][RCOMP]; - dst[i][GCOMP] = 1.0F - src[i][GCOMP]; - dst[i][BCOMP] = 1.0F - src[i][BCOMP]; - } - break; - case GL_SRC_ALPHA: - for (i = 0; i < n; i++) { - dst[i][RCOMP] = - dst[i][GCOMP] = - dst[i][BCOMP] = src[i][ACOMP]; - } - break; - case GL_ONE_MINUS_SRC_ALPHA: - for (i = 0; i < n; i++) { - dst[i][RCOMP] = - dst[i][GCOMP] = - dst[i][BCOMP] = 1.0F - src[i][ACOMP]; - } - break; - default: - _mesa_problem(ctx, "Bad operandRGB"); - } - } - } - - /* - * Set up the argA[term] pointers - */ - for (term = 0; term < numArgsA; term++) { - const GLenum srcA = combine->SourceA[term]; - const GLenum operandA = combine->OperandA[term]; - - switch (srcA) { - case GL_TEXTURE: - argA[term] = get_texel_array(swrast); - break; - case GL_PRIMARY_COLOR: - argA[term] = primary_rgba; - break; - case GL_PREVIOUS: - argA[term] = rgba; - break; - case GL_CONSTANT: - { - float4_array c = ccolor[term]; - GLfloat alpha = textureUnit->EnvColor[3]; - for (i = 0; i < n; i++) - c[i][ACOMP] = alpha; - argA[term] = ccolor[term]; - } - break; - /* GL_ATI_texture_env_combine3 allows GL_ZERO & GL_ONE as sources. - */ - case GL_ZERO: - { - float4_array c = ccolor[term]; - for (i = 0; i < n; i++) - c[i][ACOMP] = 0.0F; - argA[term] = ccolor[term]; - } - break; - case GL_ONE: - { - float4_array c = ccolor[term]; - for (i = 0; i < n; i++) - c[i][ACOMP] = 1.0F; - argA[term] = ccolor[term]; - } - break; - default: - /* ARB_texture_env_crossbar source */ - { - if (!ctx->Texture.Unit._ReallyEnabled) - goto end; - argA[term] = get_texel_array(swrast); - } - } - - if (operandA == GL_ONE_MINUS_SRC_ALPHA) { - float4_array src = argA[term]; - float4_array dst = ccolor[term]; - argA[term] = ccolor[term]; - for (i = 0; i < n; i++) { - dst[i][ACOMP] = 1.0F - src[i][ACOMP]; - } - } - } - - /* RGB channel combine */ - { - float4_array arg0 = argRGB[0]; - float4_array arg1 = argRGB[1]; - float4_array arg2 = argRGB[2]; - float4_array arg3 = argRGB[3]; - - switch (combine->ModeRGB) { - case GL_REPLACE: - for (i = 0; i < n; i++) { - rgba[i][RCOMP] = arg0[i][RCOMP] * scaleRGB; - rgba[i][GCOMP] = arg0[i][GCOMP] * scaleRGB; - rgba[i][BCOMP] = arg0[i][BCOMP] * scaleRGB; - } - break; - case GL_MODULATE: - for (i = 0; i < n; i++) { - rgba[i][RCOMP] = arg0[i][RCOMP] * arg1[i][RCOMP] * scaleRGB; - rgba[i][GCOMP] = arg0[i][GCOMP] * arg1[i][GCOMP] * scaleRGB; - rgba[i][BCOMP] = arg0[i][BCOMP] * arg1[i][BCOMP] * scaleRGB; - } - break; - case GL_ADD: - if (textureUnit->EnvMode == GL_COMBINE4_NV) { - /* (a * b) + (c * d) */ - for (i = 0; i < n; i++) { - rgba[i][RCOMP] = (arg0[i][RCOMP] * arg1[i][RCOMP] + - arg2[i][RCOMP] * arg3[i][RCOMP]) * scaleRGB; - rgba[i][GCOMP] = (arg0[i][GCOMP] * arg1[i][GCOMP] + - arg2[i][GCOMP] * arg3[i][GCOMP]) * scaleRGB; - rgba[i][BCOMP] = (arg0[i][BCOMP] * arg1[i][BCOMP] + - arg2[i][BCOMP] * arg3[i][BCOMP]) * scaleRGB; - } - } - else { - /* 2-term addition */ - for (i = 0; i < n; i++) { - rgba[i][RCOMP] = (arg0[i][RCOMP] + arg1[i][RCOMP]) * scaleRGB; - rgba[i][GCOMP] = (arg0[i][GCOMP] + arg1[i][GCOMP]) * scaleRGB; - rgba[i][BCOMP] = (arg0[i][BCOMP] + arg1[i][BCOMP]) * scaleRGB; - } - } - break; - case GL_ADD_SIGNED: - if (textureUnit->EnvMode == GL_COMBINE4_NV) { - /* (a * b) + (c * d) - 0.5 */ - for (i = 0; i < n; i++) { - rgba[i][RCOMP] = (arg0[i][RCOMP] * arg1[i][RCOMP] + - arg2[i][RCOMP] * arg3[i][RCOMP] - 0.5F) * scaleRGB; - rgba[i][GCOMP] = (arg0[i][GCOMP] * arg1[i][GCOMP] + - arg2[i][GCOMP] * arg3[i][GCOMP] - 0.5F) * scaleRGB; - rgba[i][BCOMP] = (arg0[i][BCOMP] * arg1[i][BCOMP] + - arg2[i][BCOMP] * arg3[i][BCOMP] - 0.5F) * scaleRGB; - } - } - else { - for (i = 0; i < n; i++) { - rgba[i][RCOMP] = (arg0[i][RCOMP] + arg1[i][RCOMP] - 0.5F) * scaleRGB; - rgba[i][GCOMP] = (arg0[i][GCOMP] + arg1[i][GCOMP] - 0.5F) * scaleRGB; - rgba[i][BCOMP] = (arg0[i][BCOMP] + arg1[i][BCOMP] - 0.5F) * scaleRGB; - } - } - break; - case GL_INTERPOLATE: - for (i = 0; i < n; i++) { - rgba[i][RCOMP] = (arg0[i][RCOMP] * arg2[i][RCOMP] + - arg1[i][RCOMP] * (1.0F - arg2[i][RCOMP])) * scaleRGB; - rgba[i][GCOMP] = (arg0[i][GCOMP] * arg2[i][GCOMP] + - arg1[i][GCOMP] * (1.0F - arg2[i][GCOMP])) * scaleRGB; - rgba[i][BCOMP] = (arg0[i][BCOMP] * arg2[i][BCOMP] + - arg1[i][BCOMP] * (1.0F - arg2[i][BCOMP])) * scaleRGB; - } - break; - case GL_SUBTRACT: - for (i = 0; i < n; i++) { - rgba[i][RCOMP] = (arg0[i][RCOMP] - arg1[i][RCOMP]) * scaleRGB; - rgba[i][GCOMP] = (arg0[i][GCOMP] - arg1[i][GCOMP]) * scaleRGB; - rgba[i][BCOMP] = (arg0[i][BCOMP] - arg1[i][BCOMP]) * scaleRGB; - } - break; - case GL_DOT3_RGB_EXT: - case GL_DOT3_RGBA_EXT: - /* Do not scale the result by 1 2 or 4 */ - for (i = 0; i < n; i++) { - GLfloat dot = ((arg0[i][RCOMP] - 0.5F) * (arg1[i][RCOMP] - 0.5F) + - (arg0[i][GCOMP] - 0.5F) * (arg1[i][GCOMP] - 0.5F) + - (arg0[i][BCOMP] - 0.5F) * (arg1[i][BCOMP] - 0.5F)) - * 4.0F; - dot = CLAMP(dot, 0.0F, 1.0F); - rgba[i][RCOMP] = rgba[i][GCOMP] = rgba[i][BCOMP] = dot; - } - break; - case GL_DOT3_RGB: - case GL_DOT3_RGBA: - /* DO scale the result by 1 2 or 4 */ - for (i = 0; i < n; i++) { - GLfloat dot = ((arg0[i][RCOMP] - 0.5F) * (arg1[i][RCOMP] - 0.5F) + - (arg0[i][GCOMP] - 0.5F) * (arg1[i][GCOMP] - 0.5F) + - (arg0[i][BCOMP] - 0.5F) * (arg1[i][BCOMP] - 0.5F)) - * 4.0F * scaleRGB; - dot = CLAMP(dot, 0.0F, 1.0F); - rgba[i][RCOMP] = rgba[i][GCOMP] = rgba[i][BCOMP] = dot; - } - break; - case GL_MODULATE_ADD_ATI: - for (i = 0; i < n; i++) { - rgba[i][RCOMP] = ((arg0[i][RCOMP] * arg2[i][RCOMP]) + - arg1[i][RCOMP]) * scaleRGB; - rgba[i][GCOMP] = ((arg0[i][GCOMP] * arg2[i][GCOMP]) + - arg1[i][GCOMP]) * scaleRGB; - rgba[i][BCOMP] = ((arg0[i][BCOMP] * arg2[i][BCOMP]) + - arg1[i][BCOMP]) * scaleRGB; - } - break; - case GL_MODULATE_SIGNED_ADD_ATI: - for (i = 0; i < n; i++) { - rgba[i][RCOMP] = ((arg0[i][RCOMP] * arg2[i][RCOMP]) + - arg1[i][RCOMP] - 0.5F) * scaleRGB; - rgba[i][GCOMP] = ((arg0[i][GCOMP] * arg2[i][GCOMP]) + - arg1[i][GCOMP] - 0.5F) * scaleRGB; - rgba[i][BCOMP] = ((arg0[i][BCOMP] * arg2[i][BCOMP]) + - arg1[i][BCOMP] - 0.5F) * scaleRGB; - } - break; - case GL_MODULATE_SUBTRACT_ATI: - for (i = 0; i < n; i++) { - rgba[i][RCOMP] = ((arg0[i][RCOMP] * arg2[i][RCOMP]) - - arg1[i][RCOMP]) * scaleRGB; - rgba[i][GCOMP] = ((arg0[i][GCOMP] * arg2[i][GCOMP]) - - arg1[i][GCOMP]) * scaleRGB; - rgba[i][BCOMP] = ((arg0[i][BCOMP] * arg2[i][BCOMP]) - - arg1[i][BCOMP]) * scaleRGB; - } - break; - default: - _mesa_problem(ctx, "invalid combine mode"); - } - } - - /* Alpha channel combine */ - { - float4_array arg0 = argA[0]; - float4_array arg1 = argA[1]; - float4_array arg2 = argA[2]; - float4_array arg3 = argA[3]; - - switch (combine->ModeA) { - case GL_REPLACE: - for (i = 0; i < n; i++) { - rgba[i][ACOMP] = arg0[i][ACOMP] * scaleA; - } - break; - case GL_MODULATE: - for (i = 0; i < n; i++) { - rgba[i][ACOMP] = arg0[i][ACOMP] * arg1[i][ACOMP] * scaleA; - } - break; - case GL_ADD: - if (textureUnit->EnvMode == GL_COMBINE4_NV) { - /* (a * b) + (c * d) */ - for (i = 0; i < n; i++) { - rgba[i][ACOMP] = (arg0[i][ACOMP] * arg1[i][ACOMP] + - arg2[i][ACOMP] * arg3[i][ACOMP]) * scaleA; - } - } - else { - /* two-term add */ - for (i = 0; i < n; i++) { - rgba[i][ACOMP] = (arg0[i][ACOMP] + arg1[i][ACOMP]) * scaleA; - } - } - break; - case GL_ADD_SIGNED: - if (textureUnit->EnvMode == GL_COMBINE4_NV) { - /* (a * b) + (c * d) - 0.5 */ - for (i = 0; i < n; i++) { - rgba[i][ACOMP] = (arg0[i][ACOMP] * arg1[i][ACOMP] + - arg2[i][ACOMP] * arg3[i][ACOMP] - - 0.5F) * scaleA; - } - } - else { - /* a + b - 0.5 */ - for (i = 0; i < n; i++) { - rgba[i][ACOMP] = (arg0[i][ACOMP] + arg1[i][ACOMP] - 0.5F) * scaleA; - } - } - break; - case GL_INTERPOLATE: - for (i = 0; i < n; i++) { - rgba[i][ACOMP] = (arg0[i][ACOMP] * arg2[i][ACOMP] + - arg1[i][ACOMP] * (1.0F - arg2[i][ACOMP])) - * scaleA; - } - break; - case GL_SUBTRACT: - for (i = 0; i < n; i++) { - rgba[i][ACOMP] = (arg0[i][ACOMP] - arg1[i][ACOMP]) * scaleA; - } - break; - case GL_MODULATE_ADD_ATI: - for (i = 0; i < n; i++) { - rgba[i][ACOMP] = ((arg0[i][ACOMP] * arg2[i][ACOMP]) - + arg1[i][ACOMP]) * scaleA; - } - break; - case GL_MODULATE_SIGNED_ADD_ATI: - for (i = 0; i < n; i++) { - rgba[i][ACOMP] = ((arg0[i][ACOMP] * arg2[i][ACOMP]) + - arg1[i][ACOMP] - 0.5F) * scaleA; - } - break; - case GL_MODULATE_SUBTRACT_ATI: - for (i = 0; i < n; i++) { - rgba[i][ACOMP] = ((arg0[i][ACOMP] * arg2[i][ACOMP]) - - arg1[i][ACOMP]) * scaleA; - } - break; - default: - _mesa_problem(ctx, "invalid combine mode"); - } - } - - /* Fix the alpha component for GL_DOT3_RGBA_EXT/ARB combining. - * This is kind of a kludge. It would have been better if the spec - * were written such that the GL_COMBINE_ALPHA value could be set to - * GL_DOT3. - */ - if (combine->ModeRGB == GL_DOT3_RGBA_EXT || - combine->ModeRGB == GL_DOT3_RGBA) { - for (i = 0; i < n; i++) { - rgba[i][ACOMP] = rgba[i][RCOMP]; - } - } - - for (i = 0; i < n; i++) { - UNCLAMPED_FLOAT_TO_CHAN(rgbaChan[i][RCOMP], rgba[i][RCOMP]); - UNCLAMPED_FLOAT_TO_CHAN(rgbaChan[i][GCOMP], rgba[i][GCOMP]); - UNCLAMPED_FLOAT_TO_CHAN(rgbaChan[i][BCOMP], rgba[i][BCOMP]); - UNCLAMPED_FLOAT_TO_CHAN(rgbaChan[i][ACOMP], rgba[i][ACOMP]); - } - /* The span->array->rgba values are of CHAN type so set - * span->array->ChanType field accordingly. - */ - span->array->ChanType = CHAN_TYPE; - -end: - for (i = 0; i < numArgsRGB || i < numArgsA; i++) { - free(ccolor[i]); - } - free(rgba); -} - -/** - * Apply texture mapping to a span of fragments. - */ -void -_swrast_texture_span( struct gl_context *ctx, SWspan *span ) -{ - SWcontext *swrast = SWRAST_CONTEXT(ctx); - float4_array primary_rgba; - - if (!swrast->TexelBuffer) { -#ifdef _OPENMP - const GLint maxThreads = omp_get_max_threads(); -#else - const GLint maxThreads = 1; -#endif - - /* TexelBuffer is also global and normally shared by all SWspan - * instances; when running with multiple threads, create one per - * thread. - */ - swrast->TexelBuffer = (GLfloat *) MALLOC(maxThreads * MAX_WIDTH * 4 * sizeof(GLfloat)); - if (!swrast->TexelBuffer) { - _mesa_error(ctx, GL_OUT_OF_MEMORY, "texture_combine"); - return; - } - } - - primary_rgba = (float4_array) malloc(span->end * 4 * sizeof(GLfloat)); - - if (!primary_rgba) { - _mesa_error(ctx, GL_OUT_OF_MEMORY, "texture_span"); - return; - } - - ASSERT(span->end <= MAX_WIDTH); - - /* - * Save copy of the incoming fragment colors (the GL_PRIMARY_COLOR) - */ - if (swrast->_TextureCombinePrimary) { - GLuint i; - for (i = 0; i < span->end; i++) { - primary_rgba[i][RCOMP] = CHAN_TO_FLOAT(span->array->rgba[i][RCOMP]); - primary_rgba[i][GCOMP] = CHAN_TO_FLOAT(span->array->rgba[i][GCOMP]); - primary_rgba[i][BCOMP] = CHAN_TO_FLOAT(span->array->rgba[i][BCOMP]); - primary_rgba[i][ACOMP] = CHAN_TO_FLOAT(span->array->rgba[i][ACOMP]); - } - } - - /* - * Must do all texture sampling before combining in order to - * accomodate GL_ARB_texture_env_crossbar. - */ - { - const struct gl_texture_unit *texUnit = &ctx->Texture.Unit; - if (texUnit->_ReallyEnabled) { - const GLfloat (*texcoords)[4] = (const GLfloat (*)[4]) - span->array->attribs[FRAG_ATTRIB_TEX]; - const struct gl_texture_object *curObj = texUnit->_Current; - GLfloat *lambda = span->array->lambda; - float4_array texels = get_texel_array(swrast); - - if (curObj->Sampler.MaxAnisotropy > 1.0 && - curObj->Sampler.MinFilter == GL_LINEAR_MIPMAP_LINEAR) { - /* sample_lambda_2d_aniso is beeing used as texture_sample_func, - * it requires the current SWspan *span as an additional parameter. - * In order to keep the same function signature, the unused lambda - * parameter will be modified to actually contain the SWspan pointer. - * This is a Hack. To make it right, the texture_sample_func - * signature and all implementing functions need to be modified. - */ - /* "hide" SWspan struct; cast to (GLfloat *) to suppress warning */ - lambda = (GLfloat *)span; - } - - /* Sample the texture (span->end = number of fragments) */ - swrast->TextureSample( ctx, texUnit->_Current, span->end, - texcoords, lambda, texels ); - } - } - - /* - * OK, now apply the texture (aka texture combine/blend). - * We modify the span->color.rgba values. - */ - if (ctx->Texture.Unit._ReallyEnabled) - texture_combine(ctx, primary_rgba, swrast->TexelBuffer, span); - - free(primary_rgba); -} diff --git a/dll/opengl/mesa/swrast/s_texcombine.h b/dll/opengl/mesa/swrast/s_texcombine.h deleted file mode 100644 index 11049d86b26..00000000000 --- a/dll/opengl/mesa/swrast/s_texcombine.h +++ /dev/null @@ -1,37 +0,0 @@ -/* - * Mesa 3-D graphics library - * Version: 6.5 - * - * Copyright (C) 1999-2005 Brian Paul All Rights Reserved. - * - * Permission is hereby granted, free of charge, to any person obtaining a - * copy of this software and associated documentation files (the "Software"), - * to deal in the Software without restriction, including without limitation - * the rights to use, copy, modify, merge, publish, distribute, sublicense, - * and/or sell copies of the Software, and to permit persons to whom the - * Software is furnished to do so, subject to the following conditions: - * - * The above copyright notice and this permission notice shall be included - * in all copies or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS - * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL - * BRIAN PAUL BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN - * AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN - * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. - */ - - -#ifndef S_TEXCOMBINE_H -#define S_TEXCOMBINE_H - - -#include "s_span.h" - -struct gl_context; - -extern void -_swrast_texture_span( struct gl_context *ctx, SWspan *span ); - -#endif diff --git a/dll/opengl/mesa/swrast/s_texfetch.c b/dll/opengl/mesa/swrast/s_texfetch.c deleted file mode 100644 index 58a2759204d..00000000000 --- a/dll/opengl/mesa/swrast/s_texfetch.c +++ /dev/null @@ -1,622 +0,0 @@ -/* - * Mesa 3-D graphics library - * Version: 7.7 - * - * Copyright (C) 1999-2008 Brian Paul All Rights Reserved. - * Copyright (c) 2009 VMware, Inc. - * - * Permission is hereby granted, free of charge, to any person obtaining a - * copy of this software and associated documentation files (the "Software"), - * to deal in the Software without restriction, including without limitation - * the rights to use, copy, modify, merge, publish, distribute, sublicense, - * and/or sell copies of the Software, and to permit persons to whom the - * Software is furnished to do so, subject to the following conditions: - * - * The above copyright notice and this permission notice shall be included - * in all copies or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS - * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL - * BRIAN PAUL BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN - * AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN - * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. - */ - -/** - * \file s_texfetch.c - * - * Texel fetch/store functions - * - * \author Gareth Hughes - */ - -#include - -/* Texel fetch routines for all supported formats - */ -#define DIM 1 -#include "s_texfetch_tmp.h" - -#define DIM 2 -#include "s_texfetch_tmp.h" - -#define DIM 3 -#include "s_texfetch_tmp.h" - -/** - * Null texel fetch function. - * - * Have to have this so the FetchTexel function pointer is never NULL. - */ -static void fetch_null_texelf( const struct swrast_texture_image *texImage, - GLint i, GLint j, GLint k, GLfloat *texel ) -{ - (void) texImage; (void) i; (void) j; (void) k; - texel[RCOMP] = 0.0; - texel[GCOMP] = 0.0; - texel[BCOMP] = 0.0; - texel[ACOMP] = 0.0; - _mesa_warning(NULL, "fetch_null_texelf() called!"); -} - - -/** - * Table to map MESA_FORMAT_ to texel fetch/store funcs. - * XXX this is somewhat temporary. - */ -static struct { - gl_format Name; - FetchTexelFunc Fetch1D; - FetchTexelFunc Fetch2D; - FetchTexelFunc Fetch3D; -} -texfetch_funcs[MESA_FORMAT_COUNT] = -{ - { - MESA_FORMAT_NONE, - fetch_null_texelf, - fetch_null_texelf, - fetch_null_texelf - }, - - { - MESA_FORMAT_RGBA8888, - fetch_texel_1d_f_rgba8888, - fetch_texel_2d_f_rgba8888, - fetch_texel_3d_f_rgba8888 - }, - { - MESA_FORMAT_RGBA8888_REV, - fetch_texel_1d_f_rgba8888_rev, - fetch_texel_2d_f_rgba8888_rev, - fetch_texel_3d_f_rgba8888_rev - }, - { - MESA_FORMAT_ARGB8888, - fetch_texel_1d_f_argb8888, - fetch_texel_2d_f_argb8888, - fetch_texel_3d_f_argb8888 - }, - { - MESA_FORMAT_ARGB8888_REV, - fetch_texel_1d_f_argb8888_rev, - fetch_texel_2d_f_argb8888_rev, - fetch_texel_3d_f_argb8888_rev - }, - { - MESA_FORMAT_RGBX8888, - fetch_texel_1d_f_rgbx8888, - fetch_texel_2d_f_rgbx8888, - fetch_texel_3d_f_rgbx8888 - }, - { - MESA_FORMAT_RGBX8888_REV, - fetch_texel_1d_f_rgbx8888_rev, - fetch_texel_2d_f_rgbx8888_rev, - fetch_texel_3d_f_rgbx8888_rev - }, - { - MESA_FORMAT_XRGB8888, - fetch_texel_1d_f_xrgb8888, - fetch_texel_2d_f_xrgb8888, - fetch_texel_3d_f_xrgb8888 - }, - { - MESA_FORMAT_XRGB8888_REV, - fetch_texel_1d_f_xrgb8888_rev, - fetch_texel_2d_f_xrgb8888_rev, - fetch_texel_3d_f_xrgb8888_rev - }, - { - MESA_FORMAT_RGB888, - fetch_texel_1d_f_rgb888, - fetch_texel_2d_f_rgb888, - fetch_texel_3d_f_rgb888 - }, - { - MESA_FORMAT_BGR888, - fetch_texel_1d_f_bgr888, - fetch_texel_2d_f_bgr888, - fetch_texel_3d_f_bgr888 - }, - { - MESA_FORMAT_RGB565, - fetch_texel_1d_f_rgb565, - fetch_texel_2d_f_rgb565, - fetch_texel_3d_f_rgb565 - }, - { - MESA_FORMAT_RGB565_REV, - fetch_texel_1d_f_rgb565_rev, - fetch_texel_2d_f_rgb565_rev, - fetch_texel_3d_f_rgb565_rev - }, - { - MESA_FORMAT_ARGB4444, - fetch_texel_1d_f_argb4444, - fetch_texel_2d_f_argb4444, - fetch_texel_3d_f_argb4444 - }, - { - MESA_FORMAT_ARGB4444_REV, - fetch_texel_1d_f_argb4444_rev, - fetch_texel_2d_f_argb4444_rev, - fetch_texel_3d_f_argb4444_rev - }, - { - MESA_FORMAT_RGBA5551, - fetch_texel_1d_f_rgba5551, - fetch_texel_2d_f_rgba5551, - fetch_texel_3d_f_rgba5551 - }, - { - MESA_FORMAT_ARGB1555, - fetch_texel_1d_f_argb1555, - fetch_texel_2d_f_argb1555, - fetch_texel_3d_f_argb1555 - }, - { - MESA_FORMAT_ARGB1555_REV, - fetch_texel_1d_f_argb1555_rev, - fetch_texel_2d_f_argb1555_rev, - fetch_texel_3d_f_argb1555_rev - }, - { - MESA_FORMAT_AL44, - fetch_texel_1d_f_al44, - fetch_texel_2d_f_al44, - fetch_texel_3d_f_al44 - }, - { - MESA_FORMAT_AL88, - fetch_texel_1d_f_al88, - fetch_texel_2d_f_al88, - fetch_texel_3d_f_al88 - }, - { - MESA_FORMAT_AL88_REV, - fetch_texel_1d_f_al88_rev, - fetch_texel_2d_f_al88_rev, - fetch_texel_3d_f_al88_rev - }, - { - MESA_FORMAT_AL1616, - fetch_texel_1d_f_al1616, - fetch_texel_2d_f_al1616, - fetch_texel_3d_f_al1616 - }, - { - MESA_FORMAT_AL1616_REV, - fetch_texel_1d_f_al1616_rev, - fetch_texel_2d_f_al1616_rev, - fetch_texel_3d_f_al1616_rev - }, - { - MESA_FORMAT_RGB332, - fetch_texel_1d_f_rgb332, - fetch_texel_2d_f_rgb332, - fetch_texel_3d_f_rgb332 - }, - { - MESA_FORMAT_A8, - fetch_texel_1d_f_a8, - fetch_texel_2d_f_a8, - fetch_texel_3d_f_a8 - }, - { - MESA_FORMAT_A16, - fetch_texel_1d_f_a16, - fetch_texel_2d_f_a16, - fetch_texel_3d_f_a16 - }, - { - MESA_FORMAT_L8, - fetch_texel_1d_f_l8, - fetch_texel_2d_f_l8, - fetch_texel_3d_f_l8 - }, - { - MESA_FORMAT_L16, - fetch_texel_1d_f_l16, - fetch_texel_2d_f_l16, - fetch_texel_3d_f_l16 - }, - { - MESA_FORMAT_I8, - fetch_texel_1d_f_i8, - fetch_texel_2d_f_i8, - fetch_texel_3d_f_i8 - }, - { - MESA_FORMAT_I16, - fetch_texel_1d_f_i16, - fetch_texel_2d_f_i16, - fetch_texel_3d_f_i16 - }, - { - MESA_FORMAT_YCBCR, - fetch_texel_1d_f_ycbcr, - fetch_texel_2d_f_ycbcr, - fetch_texel_3d_f_ycbcr - }, - { - MESA_FORMAT_YCBCR_REV, - fetch_texel_1d_f_ycbcr_rev, - fetch_texel_2d_f_ycbcr_rev, - fetch_texel_3d_f_ycbcr_rev - }, - { - MESA_FORMAT_Z16, - fetch_texel_1d_f_z16, - fetch_texel_2d_f_z16, - fetch_texel_3d_f_z16 - }, - { - MESA_FORMAT_X8_Z24, - fetch_texel_1d_f_s8_z24, - fetch_texel_2d_f_s8_z24, - fetch_texel_3d_f_s8_z24 - }, - { - MESA_FORMAT_Z24_X8, - fetch_texel_1d_f_z24_s8, - fetch_texel_2d_f_z24_s8, - fetch_texel_3d_f_z24_s8 - }, - { - MESA_FORMAT_Z32, - fetch_texel_1d_f_z32, - fetch_texel_2d_f_z32, - fetch_texel_3d_f_z32 - }, - { - MESA_FORMAT_S8, - NULL, - NULL, - NULL - }, - { - MESA_FORMAT_ALPHA_UINT8, - NULL, - NULL, - NULL - }, - - { - MESA_FORMAT_ALPHA_UINT16, - NULL, - NULL, - NULL - }, - - { - MESA_FORMAT_ALPHA_UINT32, - NULL, - NULL, - NULL - }, - - { - MESA_FORMAT_ALPHA_INT8, - NULL, - NULL, - NULL - }, - - { - MESA_FORMAT_ALPHA_INT16, - NULL, - NULL, - NULL - }, - - { - MESA_FORMAT_ALPHA_INT32, - NULL, - NULL, - NULL - }, - - - { - MESA_FORMAT_INTENSITY_UINT8, - NULL, - NULL, - NULL - }, - - { - MESA_FORMAT_INTENSITY_UINT16, - NULL, - NULL, - NULL - }, - - { - MESA_FORMAT_INTENSITY_UINT32, - NULL, - NULL, - NULL - }, - - { - MESA_FORMAT_INTENSITY_INT8, - NULL, - NULL, - NULL - }, - - { - MESA_FORMAT_INTENSITY_INT16, - NULL, - NULL, - NULL - }, - - { - MESA_FORMAT_INTENSITY_INT32, - NULL, - NULL, - NULL - }, - - - { - MESA_FORMAT_LUMINANCE_UINT8, - NULL, - NULL, - NULL - }, - - { - MESA_FORMAT_LUMINANCE_UINT16, - NULL, - NULL, - NULL - }, - - { - MESA_FORMAT_LUMINANCE_UINT32, - NULL, - NULL, - NULL - }, - - { - MESA_FORMAT_LUMINANCE_INT8, - NULL, - NULL, - NULL - }, - - { - MESA_FORMAT_LUMINANCE_INT16, - NULL, - NULL, - NULL - }, - - { - MESA_FORMAT_LUMINANCE_INT32, - NULL, - NULL, - NULL - }, - - - { - MESA_FORMAT_LUMINANCE_ALPHA_UINT8, - NULL, - NULL, - NULL - }, - - { - MESA_FORMAT_LUMINANCE_ALPHA_UINT16, - NULL, - NULL, - NULL - }, - - { - MESA_FORMAT_LUMINANCE_ALPHA_UINT32, - NULL, - NULL, - NULL - }, - - { - MESA_FORMAT_LUMINANCE_ALPHA_INT8, - NULL, - NULL, - NULL - }, - - { - MESA_FORMAT_LUMINANCE_ALPHA_INT16, - NULL, - NULL, - NULL - }, - - { - MESA_FORMAT_LUMINANCE_ALPHA_INT32, - NULL, - NULL, - NULL - }, - - { - MESA_FORMAT_RGB_INT8, - NULL, - NULL, - NULL - }, - - /* non-normalized, signed int */ - { - MESA_FORMAT_RGBA_INT8, - fetch_texel_1d_rgba_int8, - fetch_texel_2d_rgba_int8, - fetch_texel_3d_rgba_int8 - }, - { - MESA_FORMAT_RGB_INT16, - NULL, - NULL, - NULL - }, - { - MESA_FORMAT_RGBA_INT16, - fetch_texel_1d_rgba_int16, - fetch_texel_2d_rgba_int16, - fetch_texel_3d_rgba_int16 - }, - { - MESA_FORMAT_RGB_INT32, - NULL, - NULL, - NULL - }, - { - MESA_FORMAT_RGBA_INT32, - fetch_texel_1d_rgba_int32, - fetch_texel_2d_rgba_int32, - fetch_texel_3d_rgba_int32 - }, - - /* non-normalized, unsigned int */ - { - MESA_FORMAT_RGB_UINT8, - NULL, - NULL, - NULL - }, - { - MESA_FORMAT_RGBA_UINT8, - fetch_texel_1d_rgba_uint8, - fetch_texel_2d_rgba_uint8, - fetch_texel_3d_rgba_uint8 - }, - { - MESA_FORMAT_RGB_UINT16, - NULL, - NULL, - NULL - }, - { - MESA_FORMAT_RGBA_UINT16, - fetch_texel_1d_rgba_uint16, - fetch_texel_2d_rgba_uint16, - fetch_texel_3d_rgba_uint16 - }, - { - MESA_FORMAT_RGB_UINT32, - NULL, - NULL, - NULL - }, - { - MESA_FORMAT_RGBA_UINT32, - fetch_texel_1d_rgba_uint32, - fetch_texel_2d_rgba_uint32, - fetch_texel_3d_rgba_uint32 - }, - - /* signed, normalized */ - { - MESA_FORMAT_SIGNED_RGBA_16, - fetch_texel_1d_signed_rgba_16, - fetch_texel_2d_signed_rgba_16, - fetch_texel_3d_signed_rgba_16 - }, - { - MESA_FORMAT_RGBA_16, - fetch_texel_1d_rgba_16, - fetch_texel_2d_rgba_16, - fetch_texel_3d_rgba_16 - } -}; - - -FetchTexelFunc -_mesa_get_texel_fetch_func(gl_format format, GLuint dims) -{ -#ifdef DEBUG - /* check that the table entries are sorted by format name */ - gl_format fmt; - for (fmt = 0; fmt < MESA_FORMAT_COUNT; fmt++) { - assert(texfetch_funcs[fmt].Name == fmt); - } -#endif - - STATIC_ASSERT(Elements(texfetch_funcs) == MESA_FORMAT_COUNT); - - assert(format < MESA_FORMAT_COUNT); - - switch (dims) { - case 1: - return texfetch_funcs[format].Fetch1D; - case 2: - return texfetch_funcs[format].Fetch2D; - case 3: - return texfetch_funcs[format].Fetch3D; - default: - assert(0 && "bad dims in _mesa_get_texel_fetch_func"); - return NULL; - } -} - - -/** - * Initialize the texture image's FetchTexel methods. - */ -static void -set_fetch_functions(struct swrast_texture_image *texImage, GLuint dims) -{ - gl_format format = texImage->Base.TexFormat; - - ASSERT(dims == 1 || dims == 2 || dims == 3); - - texImage->FetchTexel = _mesa_get_texel_fetch_func(format, dims); - ASSERT(texImage->FetchTexel); -} - -void -_mesa_update_fetch_functions(struct gl_texture_object *texObj) -{ - GLuint face, i; - GLuint dims; - - dims = _mesa_get_texture_dimensions(texObj->Target); - - for (face = 0; face < 6; face++) { - for (i = 0; i < MAX_TEXTURE_LEVELS; i++) { - if (texObj->Image[face][i]) { - set_fetch_functions(swrast_texture_image(texObj->Image[face][i]), - dims); - } - } - } -} diff --git a/dll/opengl/mesa/swrast/s_texfetch.h b/dll/opengl/mesa/swrast/s_texfetch.h deleted file mode 100644 index 1aa7ce573e2..00000000000 --- a/dll/opengl/mesa/swrast/s_texfetch.h +++ /dev/null @@ -1,38 +0,0 @@ -/* - * Mesa 3-D graphics library - * Version: 7.7 - * - * Copyright (C) 1999-2008 Brian Paul All Rights Reserved. - * Copyright (c) 2009 VMware, Inc. - * - * Permission is hereby granted, free of charge, to any person obtaining a - * copy of this software and associated documentation files (the "Software"), - * to deal in the Software without restriction, including without limitation - * the rights to use, copy, modify, merge, publish, distribute, sublicense, - * and/or sell copies of the Software, and to permit persons to whom the - * Software is furnished to do so, subject to the following conditions: - * - * The above copyright notice and this permission notice shall be included - * in all copies or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS - * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL - * BRIAN PAUL BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN - * AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN - * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. - */ - - -#ifndef S_TEXFETCH_H -#define S_TEXFETCH_H - -#include "swrast/s_context.h" - -extern FetchTexelFunc -_mesa_get_texel_fetch_func(gl_format format, GLuint dims); - -void -_mesa_update_fetch_functions(struct gl_texture_object *texObj); - -#endif /* S_TEXFETCH_H */ diff --git a/dll/opengl/mesa/swrast/s_texfetch_tmp.h b/dll/opengl/mesa/swrast/s_texfetch_tmp.h deleted file mode 100644 index 88ebec98c9e..00000000000 --- a/dll/opengl/mesa/swrast/s_texfetch_tmp.h +++ /dev/null @@ -1,802 +0,0 @@ -/* - * Mesa 3-D graphics library - * Version: 7.7 - * - * Copyright (C) 1999-2008 Brian Paul All Rights Reserved. - * Copyright (c) 2008-2009 VMware, Inc. - * - * Permission is hereby granted, free of charge, to any person obtaining a - * copy of this software and associated documentation files (the "Software"), - * to deal in the Software without restriction, including without limitation - * the rights to use, copy, modify, merge, publish, distribute, sublicense, - * and/or sell copies of the Software, and to permit persons to whom the - * Software is furnished to do so, subject to the following conditions: - * - * The above copyright notice and this permission notice shall be included - * in all copies or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS - * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL - * BRIAN PAUL BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN - * AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN - * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. - */ - - -/** - * \file texfetch_tmp.h - * Texel fetch functions template. - * - * This template file is used by texfetch.c to generate texel fetch functions - * for 1-D, 2-D and 3-D texture images. - * - * It should be expanded by defining \p DIM as the number texture dimensions - * (1, 2 or 3). According to the value of \p DIM a series of macros is defined - * for the texel lookup in the gl_texture_image::Data. - * - * \author Gareth Hughes - * \author Brian Paul - */ - - -#if DIM == 1 - -#define TEXEL_ADDR( type, image, i, j, k, size ) \ - ((void) (j), (void) (k), ((type *)(image)->Map + (i) * (size))) - -#define FETCH(x) fetch_texel_1d_##x - -#elif DIM == 2 - -#define TEXEL_ADDR( type, image, i, j, k, size ) \ - ((void) (k), \ - ((type *)(image)->Map + ((image)->RowStride * (j) + (i)) * (size))) - -#define FETCH(x) fetch_texel_2d_##x - -#elif DIM == 3 - -#define TEXEL_ADDR( type, image, i, j, k, size ) \ - ((type *)(image)->Map + ((image)->ImageOffsets[k] \ - + (image)->RowStride * (j) + (i)) * (size)) - -#define FETCH(x) fetch_texel_3d_##x - -#else -#error illegal number of texture dimensions -#endif - - -/* MESA_FORMAT_Z32 ***********************************************************/ - -/* Fetch depth texel from 1D, 2D or 3D 32-bit depth texture, - * returning 1 GLfloat. - * Note: no GLchan version of this function. - */ -static void FETCH(f_z32)( const struct swrast_texture_image *texImage, - GLint i, GLint j, GLint k, GLfloat *texel ) -{ - const GLuint *src = TEXEL_ADDR(GLuint, texImage, i, j, k, 1); - texel[0] = src[0] * (1.0F / 0xffffffff); -} - - -/* MESA_FORMAT_Z16 ***********************************************************/ - -/* Fetch depth texel from 1D, 2D or 3D 16-bit depth texture, - * returning 1 GLfloat. - * Note: no GLchan version of this function. - */ -static void FETCH(f_z16)(const struct swrast_texture_image *texImage, - GLint i, GLint j, GLint k, GLfloat *texel ) -{ - const GLushort *src = TEXEL_ADDR(GLushort, texImage, i, j, k, 1); - texel[0] = src[0] * (1.0F / 65535.0F); -} - - - -/* - * Begin Hardware formats - */ - -/* MESA_FORMAT_RGBA8888 ******************************************************/ - -/* Fetch texel from 1D, 2D or 3D rgba8888 texture, return 4 GLfloats */ -static void FETCH(f_rgba8888)( const struct swrast_texture_image *texImage, - GLint i, GLint j, GLint k, GLfloat *texel ) -{ - const GLuint s = *TEXEL_ADDR(GLuint, texImage, i, j, k, 1); - texel[RCOMP] = UBYTE_TO_FLOAT( (s >> 24) ); - texel[GCOMP] = UBYTE_TO_FLOAT( (s >> 16) & 0xff ); - texel[BCOMP] = UBYTE_TO_FLOAT( (s >> 8) & 0xff ); - texel[ACOMP] = UBYTE_TO_FLOAT( (s ) & 0xff ); -} - - - - - - -/* MESA_FORMAT_RGBA888_REV ***************************************************/ - -/* Fetch texel from 1D, 2D or 3D abgr8888 texture, return 4 GLchans */ -static void FETCH(f_rgba8888_rev)( const struct swrast_texture_image *texImage, - GLint i, GLint j, GLint k, GLfloat *texel ) -{ - const GLuint s = *TEXEL_ADDR(GLuint, texImage, i, j, k, 1); - texel[RCOMP] = UBYTE_TO_FLOAT( (s ) & 0xff ); - texel[GCOMP] = UBYTE_TO_FLOAT( (s >> 8) & 0xff ); - texel[BCOMP] = UBYTE_TO_FLOAT( (s >> 16) & 0xff ); - texel[ACOMP] = UBYTE_TO_FLOAT( (s >> 24) ); -} - - - - -/* MESA_FORMAT_ARGB8888 ******************************************************/ - -/* Fetch texel from 1D, 2D or 3D argb8888 texture, return 4 GLchans */ -static void FETCH(f_argb8888)( const struct swrast_texture_image *texImage, - GLint i, GLint j, GLint k, GLfloat *texel ) -{ - const GLuint s = *TEXEL_ADDR(GLuint, texImage, i, j, k, 1); - texel[RCOMP] = UBYTE_TO_FLOAT( (s >> 16) & 0xff ); - texel[GCOMP] = UBYTE_TO_FLOAT( (s >> 8) & 0xff ); - texel[BCOMP] = UBYTE_TO_FLOAT( (s ) & 0xff ); - texel[ACOMP] = UBYTE_TO_FLOAT( (s >> 24) ); -} - - - - -/* MESA_FORMAT_ARGB8888_REV **************************************************/ - -/* Fetch texel from 1D, 2D or 3D argb8888_rev texture, return 4 GLfloats */ -static void FETCH(f_argb8888_rev)( const struct swrast_texture_image *texImage, - GLint i, GLint j, GLint k, GLfloat *texel ) -{ - const GLuint s = *TEXEL_ADDR(GLuint, texImage, i, j, k, 1); - texel[RCOMP] = UBYTE_TO_FLOAT( (s >> 8) & 0xff ); - texel[GCOMP] = UBYTE_TO_FLOAT( (s >> 16) & 0xff ); - texel[BCOMP] = UBYTE_TO_FLOAT( (s >> 24) ); - texel[ACOMP] = UBYTE_TO_FLOAT( (s ) & 0xff ); -} - - - - -/* MESA_FORMAT_RGBX8888 ******************************************************/ - -/* Fetch texel from 1D, 2D or 3D rgbx8888 texture, return 4 GLfloats */ -static void FETCH(f_rgbx8888)( const struct swrast_texture_image *texImage, - GLint i, GLint j, GLint k, GLfloat *texel ) -{ - const GLuint s = *TEXEL_ADDR(GLuint, texImage, i, j, k, 1); - texel[RCOMP] = UBYTE_TO_FLOAT( (s >> 24) ); - texel[GCOMP] = UBYTE_TO_FLOAT( (s >> 16) & 0xff ); - texel[BCOMP] = UBYTE_TO_FLOAT( (s >> 8) & 0xff ); - texel[ACOMP] = 1.0f; -} - - - - -/* MESA_FORMAT_RGBX888_REV ***************************************************/ - -/* Fetch texel from 1D, 2D or 3D rgbx8888_rev texture, return 4 GLchans */ -static void FETCH(f_rgbx8888_rev)( const struct swrast_texture_image *texImage, - GLint i, GLint j, GLint k, GLfloat *texel ) -{ - const GLuint s = *TEXEL_ADDR(GLuint, texImage, i, j, k, 1); - texel[RCOMP] = UBYTE_TO_FLOAT( (s ) & 0xff ); - texel[GCOMP] = UBYTE_TO_FLOAT( (s >> 8) & 0xff ); - texel[BCOMP] = UBYTE_TO_FLOAT( (s >> 16) & 0xff ); - texel[ACOMP] = 1.0f; -} - - - - -/* MESA_FORMAT_XRGB8888 ******************************************************/ - -/* Fetch texel from 1D, 2D or 3D xrgb8888 texture, return 4 GLchans */ -static void FETCH(f_xrgb8888)( const struct swrast_texture_image *texImage, - GLint i, GLint j, GLint k, GLfloat *texel ) -{ - const GLuint s = *TEXEL_ADDR(GLuint, texImage, i, j, k, 1); - texel[RCOMP] = UBYTE_TO_FLOAT( (s >> 16) & 0xff ); - texel[GCOMP] = UBYTE_TO_FLOAT( (s >> 8) & 0xff ); - texel[BCOMP] = UBYTE_TO_FLOAT( (s ) & 0xff ); - texel[ACOMP] = 1.0f; -} - - - - -/* MESA_FORMAT_XRGB8888_REV **************************************************/ - -/* Fetch texel from 1D, 2D or 3D xrgb8888_rev texture, return 4 GLfloats */ -static void FETCH(f_xrgb8888_rev)( const struct swrast_texture_image *texImage, - GLint i, GLint j, GLint k, GLfloat *texel ) -{ - const GLuint s = *TEXEL_ADDR(GLuint, texImage, i, j, k, 1); - texel[RCOMP] = UBYTE_TO_FLOAT( (s >> 8) & 0xff ); - texel[GCOMP] = UBYTE_TO_FLOAT( (s >> 16) & 0xff ); - texel[BCOMP] = UBYTE_TO_FLOAT( (s >> 24) ); - texel[ACOMP] = 1.0f; -} - - - - -/* MESA_FORMAT_RGB888 ********************************************************/ - -/* Fetch texel from 1D, 2D or 3D rgb888 texture, return 4 GLchans */ -static void FETCH(f_rgb888)( const struct swrast_texture_image *texImage, - GLint i, GLint j, GLint k, GLfloat *texel ) -{ - const GLubyte *src = TEXEL_ADDR(GLubyte, texImage, i, j, k, 3); - texel[RCOMP] = UBYTE_TO_FLOAT( src[2] ); - texel[GCOMP] = UBYTE_TO_FLOAT( src[1] ); - texel[BCOMP] = UBYTE_TO_FLOAT( src[0] ); - texel[ACOMP] = 1.0F; -} - - - - -/* MESA_FORMAT_BGR888 ********************************************************/ - -/* Fetch texel from 1D, 2D or 3D bgr888 texture, return 4 GLchans */ -static void FETCH(f_bgr888)( const struct swrast_texture_image *texImage, - GLint i, GLint j, GLint k, GLfloat *texel ) -{ - const GLubyte *src = TEXEL_ADDR(GLubyte, texImage, i, j, k, 3); - texel[RCOMP] = UBYTE_TO_FLOAT( src[0] ); - texel[GCOMP] = UBYTE_TO_FLOAT( src[1] ); - texel[BCOMP] = UBYTE_TO_FLOAT( src[2] ); - texel[ACOMP] = 1.0F; -} - - - - -/* use color expansion like (g << 2) | (g >> 4) (does somewhat random rounding) - instead of slow (g << 2) * 255 / 252 (always rounds down) */ - -/* MESA_FORMAT_RGB565 ********************************************************/ - -/* Fetch texel from 1D, 2D or 3D rgb565 texture, return 4 GLchans */ -static void FETCH(f_rgb565)( const struct swrast_texture_image *texImage, - GLint i, GLint j, GLint k, GLfloat *texel ) -{ - const GLushort *src = TEXEL_ADDR(GLushort, texImage, i, j, k, 1); - const GLushort s = *src; - texel[RCOMP] = ((s >> 11) & 0x1f) * (1.0F / 31.0F); - texel[GCOMP] = ((s >> 5 ) & 0x3f) * (1.0F / 63.0F); - texel[BCOMP] = ((s ) & 0x1f) * (1.0F / 31.0F); - texel[ACOMP] = 1.0F; -} - - - - -/* MESA_FORMAT_RGB565_REV ****************************************************/ - -/* Fetch texel from 1D, 2D or 3D rgb565_rev texture, return 4 GLchans */ -static void FETCH(f_rgb565_rev)( const struct swrast_texture_image *texImage, - GLint i, GLint j, GLint k, GLfloat *texel ) -{ - const GLushort *src = TEXEL_ADDR(GLushort, texImage, i, j, k, 1); - const GLushort s = (*src >> 8) | (*src << 8); /* byte swap */ - texel[RCOMP] = UBYTE_TO_FLOAT( ((s >> 8) & 0xf8) | ((s >> 13) & 0x7) ); - texel[GCOMP] = UBYTE_TO_FLOAT( ((s >> 3) & 0xfc) | ((s >> 9) & 0x3) ); - texel[BCOMP] = UBYTE_TO_FLOAT( ((s << 3) & 0xf8) | ((s >> 2) & 0x7) ); - texel[ACOMP] = 1.0F; -} - - - - -/* MESA_FORMAT_ARGB4444 ******************************************************/ - -/* Fetch texel from 1D, 2D or 3D argb444 texture, return 4 GLchans */ -static void FETCH(f_argb4444)( const struct swrast_texture_image *texImage, - GLint i, GLint j, GLint k, GLfloat *texel ) -{ - const GLushort *src = TEXEL_ADDR(GLushort, texImage, i, j, k, 1); - const GLushort s = *src; - texel[RCOMP] = ((s >> 8) & 0xf) * (1.0F / 15.0F); - texel[GCOMP] = ((s >> 4) & 0xf) * (1.0F / 15.0F); - texel[BCOMP] = ((s ) & 0xf) * (1.0F / 15.0F); - texel[ACOMP] = ((s >> 12) & 0xf) * (1.0F / 15.0F); -} - - - - -/* MESA_FORMAT_ARGB4444_REV **************************************************/ - -/* Fetch texel from 1D, 2D or 3D argb4444_rev texture, return 4 GLchans */ -static void FETCH(f_argb4444_rev)( const struct swrast_texture_image *texImage, - GLint i, GLint j, GLint k, GLfloat *texel ) -{ - const GLushort s = *TEXEL_ADDR(GLushort, texImage, i, j, k, 1); - texel[RCOMP] = ((s ) & 0xf) * (1.0F / 15.0F); - texel[GCOMP] = ((s >> 12) & 0xf) * (1.0F / 15.0F); - texel[BCOMP] = ((s >> 8) & 0xf) * (1.0F / 15.0F); - texel[ACOMP] = ((s >> 4) & 0xf) * (1.0F / 15.0F); -} - - - -/* MESA_FORMAT_RGBA5551 ******************************************************/ - -/* Fetch texel from 1D, 2D or 3D argb1555 texture, return 4 GLchans */ -static void FETCH(f_rgba5551)( const struct swrast_texture_image *texImage, - GLint i, GLint j, GLint k, GLfloat *texel ) -{ - const GLushort *src = TEXEL_ADDR(GLushort, texImage, i, j, k, 1); - const GLushort s = *src; - texel[RCOMP] = ((s >> 11) & 0x1f) * (1.0F / 31.0F); - texel[GCOMP] = ((s >> 6) & 0x1f) * (1.0F / 31.0F); - texel[BCOMP] = ((s >> 1) & 0x1f) * (1.0F / 31.0F); - texel[ACOMP] = ((s ) & 0x01) * 1.0F; -} - - - -/* MESA_FORMAT_ARGB1555 ******************************************************/ - -/* Fetch texel from 1D, 2D or 3D argb1555 texture, return 4 GLchans */ -static void FETCH(f_argb1555)( const struct swrast_texture_image *texImage, - GLint i, GLint j, GLint k, GLfloat *texel ) -{ - const GLushort *src = TEXEL_ADDR(GLushort, texImage, i, j, k, 1); - const GLushort s = *src; - texel[RCOMP] = ((s >> 10) & 0x1f) * (1.0F / 31.0F); - texel[GCOMP] = ((s >> 5) & 0x1f) * (1.0F / 31.0F); - texel[BCOMP] = ((s >> 0) & 0x1f) * (1.0F / 31.0F); - texel[ACOMP] = ((s >> 15) & 0x01) * 1.0F; -} - - - - -/* MESA_FORMAT_ARGB1555_REV **************************************************/ - -/* Fetch texel from 1D, 2D or 3D argb1555_rev texture, return 4 GLchans */ -static void FETCH(f_argb1555_rev)( const struct swrast_texture_image *texImage, - GLint i, GLint j, GLint k, GLfloat *texel ) -{ - const GLushort *src = TEXEL_ADDR(GLushort, texImage, i, j, k, 1); - const GLushort s = (*src << 8) | (*src >> 8); /* byteswap */ - texel[RCOMP] = UBYTE_TO_FLOAT( ((s >> 7) & 0xf8) | ((s >> 12) & 0x7) ); - texel[GCOMP] = UBYTE_TO_FLOAT( ((s >> 2) & 0xf8) | ((s >> 7) & 0x7) ); - texel[BCOMP] = UBYTE_TO_FLOAT( ((s << 3) & 0xf8) | ((s >> 2) & 0x7) ); - texel[ACOMP] = UBYTE_TO_FLOAT( ((s >> 15) & 0x01) * 255 ); -} - - - - -/* MESA_FORMAT_AL44 **********************************************************/ - -/* Fetch texel from 1D, 2D or 3D al44 texture, return 4 GLchans */ -static void FETCH(f_al44)( const struct swrast_texture_image *texImage, - GLint i, GLint j, GLint k, GLfloat *texel ) -{ - const GLubyte s = *TEXEL_ADDR(GLubyte, texImage, i, j, k, 1); - texel[RCOMP] = - texel[GCOMP] = - texel[BCOMP] = (s & 0xf) * (1.0F / 15.0F); - texel[ACOMP] = ((s >> 4) & 0xf) * (1.0F / 15.0F); -} - - - - -/* MESA_FORMAT_AL88 **********************************************************/ - -/* Fetch texel from 1D, 2D or 3D al88 texture, return 4 GLchans */ -static void FETCH(f_al88)( const struct swrast_texture_image *texImage, - GLint i, GLint j, GLint k, GLfloat *texel ) -{ - const GLushort s = *TEXEL_ADDR(GLushort, texImage, i, j, k, 1); - texel[RCOMP] = - texel[GCOMP] = - texel[BCOMP] = UBYTE_TO_FLOAT( s & 0xff ); - texel[ACOMP] = UBYTE_TO_FLOAT( s >> 8 ); -} - - - - -/* MESA_FORMAT_AL88_REV ******************************************************/ - -/* Fetch texel from 1D, 2D or 3D al88_rev texture, return 4 GLchans */ -static void FETCH(f_al88_rev)( const struct swrast_texture_image *texImage, - GLint i, GLint j, GLint k, GLfloat *texel ) -{ - const GLushort s = *TEXEL_ADDR(GLushort, texImage, i, j, k, 1); - texel[RCOMP] = - texel[GCOMP] = - texel[BCOMP] = UBYTE_TO_FLOAT( s >> 8 ); - texel[ACOMP] = UBYTE_TO_FLOAT( s & 0xff ); -} - - - - -/* MESA_FORMAT_AL1616 ********************************************************/ - -/* Fetch texel from 1D, 2D or 3D al1616 texture, return 4 GLchans */ -static void FETCH(f_al1616)( const struct swrast_texture_image *texImage, - GLint i, GLint j, GLint k, GLfloat *texel ) -{ - const GLuint s = *TEXEL_ADDR(GLuint, texImage, i, j, k, 1); - texel[RCOMP] = - texel[GCOMP] = - texel[BCOMP] = USHORT_TO_FLOAT( s & 0xffff ); - texel[ACOMP] = USHORT_TO_FLOAT( s >> 16 ); -} - - - - -/* MESA_FORMAT_AL1616_REV ****************************************************/ - -/* Fetch texel from 1D, 2D or 3D al1616_rev texture, return 4 GLchans */ -static void FETCH(f_al1616_rev)( const struct swrast_texture_image *texImage, - GLint i, GLint j, GLint k, GLfloat *texel ) -{ - const GLuint s = *TEXEL_ADDR(GLuint, texImage, i, j, k, 1); - texel[RCOMP] = - texel[GCOMP] = - texel[BCOMP] = USHORT_TO_FLOAT( s >> 16 ); - texel[ACOMP] = USHORT_TO_FLOAT( s & 0xffff ); -} - - - - -/* MESA_FORMAT_RGB332 ********************************************************/ - -/* Fetch texel from 1D, 2D or 3D rgb332 texture, return 4 GLchans */ -static void FETCH(f_rgb332)( const struct swrast_texture_image *texImage, - GLint i, GLint j, GLint k, GLfloat *texel ) -{ - const GLubyte *src = TEXEL_ADDR(GLubyte, texImage, i, j, k, 1); - const GLubyte s = *src; - texel[RCOMP] = ((s >> 5) & 0x7) * (1.0F / 7.0F); - texel[GCOMP] = ((s >> 2) & 0x7) * (1.0F / 7.0F); - texel[BCOMP] = ((s ) & 0x3) * (1.0F / 3.0F); - texel[ACOMP] = 1.0F; -} - - - - -/* MESA_FORMAT_A8 ************************************************************/ - -/* Fetch texel from 1D, 2D or 3D a8 texture, return 4 GLchans */ -static void FETCH(f_a8)( const struct swrast_texture_image *texImage, - GLint i, GLint j, GLint k, GLfloat *texel ) -{ - const GLubyte *src = TEXEL_ADDR(GLubyte, texImage, i, j, k, 1); - texel[RCOMP] = - texel[GCOMP] = - texel[BCOMP] = 0.0F; - texel[ACOMP] = UBYTE_TO_FLOAT( src[0] ); -} - - - - -/* MESA_FORMAT_A16 ************************************************************/ - -/* Fetch texel from 1D, 2D or 3D a8 texture, return 4 GLchans */ -static void FETCH(f_a16)( const struct swrast_texture_image *texImage, - GLint i, GLint j, GLint k, GLfloat *texel ) -{ - const GLushort *src = TEXEL_ADDR(GLushort, texImage, i, j, k, 1); - texel[RCOMP] = - texel[GCOMP] = - texel[BCOMP] = 0.0F; - texel[ACOMP] = USHORT_TO_FLOAT( src[0] ); -} - - - - -/* MESA_FORMAT_L8 ************************************************************/ - -/* Fetch texel from 1D, 2D or 3D l8 texture, return 4 GLchans */ -static void FETCH(f_l8)( const struct swrast_texture_image *texImage, - GLint i, GLint j, GLint k, GLfloat *texel ) -{ - const GLubyte *src = TEXEL_ADDR(GLubyte, texImage, i, j, k, 1); - texel[RCOMP] = - texel[GCOMP] = - texel[BCOMP] = UBYTE_TO_FLOAT( src[0] ); - texel[ACOMP] = 1.0F; -} - - - - -/* MESA_FORMAT_L16 ***********************************************************/ - -/* Fetch texel from 1D, 2D or 3D l16 texture, return 4 GLchans */ -static void FETCH(f_l16)( const struct swrast_texture_image *texImage, - GLint i, GLint j, GLint k, GLfloat *texel ) -{ - const GLushort *src = TEXEL_ADDR(GLushort, texImage, i, j, k, 1); - texel[RCOMP] = - texel[GCOMP] = - texel[BCOMP] = USHORT_TO_FLOAT( src[0] ); - texel[ACOMP] = 1.0F; -} - - - - -/* MESA_FORMAT_I8 ************************************************************/ - -/* Fetch texel from 1D, 2D or 3D i8 texture, return 4 GLchans */ -static void FETCH(f_i8)( const struct swrast_texture_image *texImage, - GLint i, GLint j, GLint k, GLfloat *texel ) -{ - const GLubyte *src = TEXEL_ADDR(GLubyte, texImage, i, j, k, 1); - texel[RCOMP] = - texel[GCOMP] = - texel[BCOMP] = - texel[ACOMP] = UBYTE_TO_FLOAT( src[0] ); -} - - - - -/* MESA_FORMAT_I16 ***********************************************************/ - -/* Fetch texel from 1D, 2D or 3D i16 texture, return 4 GLchans */ -static void FETCH(f_i16)( const struct swrast_texture_image *texImage, - GLint i, GLint j, GLint k, GLfloat *texel ) -{ - const GLushort *src = TEXEL_ADDR(GLushort, texImage, i, j, k, 1); - texel[RCOMP] = - texel[GCOMP] = - texel[BCOMP] = - texel[ACOMP] = USHORT_TO_FLOAT( src[0] ); -} - - -/* MESA_FORMAT_RGBA_INT8 **************************************************/ - -static void -FETCH(rgba_int8)(const struct swrast_texture_image *texImage, - GLint i, GLint j, GLint k, GLfloat *texel ) -{ - const GLbyte *src = TEXEL_ADDR(GLbyte, texImage, i, j, k, 4); - texel[RCOMP] = (GLfloat) src[0]; - texel[GCOMP] = (GLfloat) src[1]; - texel[BCOMP] = (GLfloat) src[2]; - texel[ACOMP] = (GLfloat) src[3]; -} - - - - -/* MESA_FORMAT_RGBA_INT16 **************************************************/ - -static void -FETCH(rgba_int16)(const struct swrast_texture_image *texImage, - GLint i, GLint j, GLint k, GLfloat *texel ) -{ - const GLshort *src = TEXEL_ADDR(GLshort, texImage, i, j, k, 4); - texel[RCOMP] = (GLfloat) src[0]; - texel[GCOMP] = (GLfloat) src[1]; - texel[BCOMP] = (GLfloat) src[2]; - texel[ACOMP] = (GLfloat) src[3]; -} - - - - -/* MESA_FORMAT_RGBA_INT32 **************************************************/ - -static void -FETCH(rgba_int32)(const struct swrast_texture_image *texImage, - GLint i, GLint j, GLint k, GLfloat *texel ) -{ - const GLint *src = TEXEL_ADDR(GLint, texImage, i, j, k, 4); - texel[RCOMP] = (GLfloat) src[0]; - texel[GCOMP] = (GLfloat) src[1]; - texel[BCOMP] = (GLfloat) src[2]; - texel[ACOMP] = (GLfloat) src[3]; -} - - - - -/* MESA_FORMAT_RGBA_UINT8 **************************************************/ - -static void -FETCH(rgba_uint8)(const struct swrast_texture_image *texImage, - GLint i, GLint j, GLint k, GLfloat *texel ) -{ - const GLubyte *src = TEXEL_ADDR(GLubyte, texImage, i, j, k, 4); - texel[RCOMP] = (GLfloat) src[0]; - texel[GCOMP] = (GLfloat) src[1]; - texel[BCOMP] = (GLfloat) src[2]; - texel[ACOMP] = (GLfloat) src[3]; -} - - - - -/* MESA_FORMAT_RGBA_UINT16 **************************************************/ - -static void -FETCH(rgba_uint16)(const struct swrast_texture_image *texImage, - GLint i, GLint j, GLint k, GLfloat *texel ) -{ - const GLushort *src = TEXEL_ADDR(GLushort, texImage, i, j, k, 4); - texel[RCOMP] = (GLfloat) src[0]; - texel[GCOMP] = (GLfloat) src[1]; - texel[BCOMP] = (GLfloat) src[2]; - texel[ACOMP] = (GLfloat) src[3]; -} - - - - -/* MESA_FORMAT_RGBA_UINT32 **************************************************/ - -static void -FETCH(rgba_uint32)(const struct swrast_texture_image *texImage, - GLint i, GLint j, GLint k, GLfloat *texel ) -{ - const GLuint *src = TEXEL_ADDR(GLuint, texImage, i, j, k, 4); - texel[RCOMP] = (GLfloat) src[0]; - texel[GCOMP] = (GLfloat) src[1]; - texel[BCOMP] = (GLfloat) src[2]; - texel[ACOMP] = (GLfloat) src[3]; -} - - - -/* MESA_FORMAT_SIGNED_RGBA_16 ***********************************************/ - -static void -FETCH(signed_rgba_16)(const struct swrast_texture_image *texImage, - GLint i, GLint j, GLint k, GLfloat *texel) -{ - const GLshort *s = TEXEL_ADDR(GLshort, texImage, i, j, k, 4); - texel[RCOMP] = SHORT_TO_FLOAT_TEX( s[0] ); - texel[GCOMP] = SHORT_TO_FLOAT_TEX( s[1] ); - texel[BCOMP] = SHORT_TO_FLOAT_TEX( s[2] ); - texel[ACOMP] = SHORT_TO_FLOAT_TEX( s[3] ); -} - - - - - -/* MESA_FORMAT_RGBA_16 ***********************************************/ - -static void -FETCH(rgba_16)(const struct swrast_texture_image *texImage, - GLint i, GLint j, GLint k, GLfloat *texel) -{ - const GLushort *s = TEXEL_ADDR(GLushort, texImage, i, j, k, 4); - texel[RCOMP] = USHORT_TO_FLOAT( s[0] ); - texel[GCOMP] = USHORT_TO_FLOAT( s[1] ); - texel[BCOMP] = USHORT_TO_FLOAT( s[2] ); - texel[ACOMP] = USHORT_TO_FLOAT( s[3] ); -} - - - - - -/* MESA_FORMAT_YCBCR *********************************************************/ - -/* Fetch texel from 1D, 2D or 3D ycbcr texture, return 4 GLfloats. - * We convert YCbCr to RGB here. - */ -static void FETCH(f_ycbcr)( const struct swrast_texture_image *texImage, - GLint i, GLint j, GLint k, GLfloat *texel ) -{ - const GLushort *src0 = TEXEL_ADDR(GLushort, texImage, (i & ~1), j, k, 1); /* even */ - const GLushort *src1 = src0 + 1; /* odd */ - const GLubyte y0 = (*src0 >> 8) & 0xff; /* luminance */ - const GLubyte cb = *src0 & 0xff; /* chroma U */ - const GLubyte y1 = (*src1 >> 8) & 0xff; /* luminance */ - const GLubyte cr = *src1 & 0xff; /* chroma V */ - const GLubyte y = (i & 1) ? y1 : y0; /* choose even/odd luminance */ - GLfloat r = 1.164F * (y - 16) + 1.596F * (cr - 128); - GLfloat g = 1.164F * (y - 16) - 0.813F * (cr - 128) - 0.391F * (cb - 128); - GLfloat b = 1.164F * (y - 16) + 2.018F * (cb - 128); - r *= (1.0F / 255.0F); - g *= (1.0F / 255.0F); - b *= (1.0F / 255.0F); - texel[RCOMP] = CLAMP(r, 0.0F, 1.0F); - texel[GCOMP] = CLAMP(g, 0.0F, 1.0F); - texel[BCOMP] = CLAMP(b, 0.0F, 1.0F); - texel[ACOMP] = 1.0F; -} - - - - -/* MESA_FORMAT_YCBCR_REV *****************************************************/ - -/* Fetch texel from 1D, 2D or 3D ycbcr_rev texture, return 4 GLfloats. - * We convert YCbCr to RGB here. - */ -static void FETCH(f_ycbcr_rev)( const struct swrast_texture_image *texImage, - GLint i, GLint j, GLint k, GLfloat *texel ) -{ - const GLushort *src0 = TEXEL_ADDR(GLushort, texImage, (i & ~1), j, k, 1); /* even */ - const GLushort *src1 = src0 + 1; /* odd */ - const GLubyte y0 = *src0 & 0xff; /* luminance */ - const GLubyte cr = (*src0 >> 8) & 0xff; /* chroma V */ - const GLubyte y1 = *src1 & 0xff; /* luminance */ - const GLubyte cb = (*src1 >> 8) & 0xff; /* chroma U */ - const GLubyte y = (i & 1) ? y1 : y0; /* choose even/odd luminance */ - GLfloat r = 1.164F * (y - 16) + 1.596F * (cr - 128); - GLfloat g = 1.164F * (y - 16) - 0.813F * (cr - 128) - 0.391F * (cb - 128); - GLfloat b = 1.164F * (y - 16) + 2.018F * (cb - 128); - r *= (1.0F / 255.0F); - g *= (1.0F / 255.0F); - b *= (1.0F / 255.0F); - texel[RCOMP] = CLAMP(r, 0.0F, 1.0F); - texel[GCOMP] = CLAMP(g, 0.0F, 1.0F); - texel[BCOMP] = CLAMP(b, 0.0F, 1.0F); - texel[ACOMP] = 1.0F; -} - - - - -/* MESA_TEXFORMAT_Z24_S8 ***************************************************/ - -static void FETCH(f_z24_s8)( const struct swrast_texture_image *texImage, - GLint i, GLint j, GLint k, GLfloat *texel ) -{ - /* only return Z, not stencil data */ - const GLuint *src = TEXEL_ADDR(GLuint, texImage, i, j, k, 1); - const GLdouble scale = 1.0 / (GLdouble) 0xffffff; - texel[0] = ((*src) >> 8) * scale; - ASSERT(texImage->Base.TexFormat == MESA_FORMAT_Z24_S8 || - texImage->Base.TexFormat == MESA_FORMAT_Z24_X8); - ASSERT(texel[0] >= 0.0F); - ASSERT(texel[0] <= 1.0F); -} - - - - -/* MESA_TEXFORMAT_S8_Z24 ***************************************************/ - -static void FETCH(f_s8_z24)( const struct swrast_texture_image *texImage, - GLint i, GLint j, GLint k, GLfloat *texel ) -{ - /* only return Z, not stencil data */ - const GLuint *src = TEXEL_ADDR(GLuint, texImage, i, j, k, 1); - const GLdouble scale = 1.0 / (GLdouble) 0xffffff; - texel[0] = ((*src) & 0x00ffffff) * scale; - ASSERT(texImage->Base.TexFormat == MESA_FORMAT_S8_Z24 || - texImage->Base.TexFormat == MESA_FORMAT_X8_Z24); - ASSERT(texel[0] >= 0.0F); - ASSERT(texel[0] <= 1.0F); -} - - - -#undef TEXEL_ADDR -#undef DIM -#undef FETCH diff --git a/dll/opengl/mesa/swrast/s_texfilter.c b/dll/opengl/mesa/swrast/s_texfilter.c deleted file mode 100644 index 80686cb76ca..00000000000 --- a/dll/opengl/mesa/swrast/s_texfilter.c +++ /dev/null @@ -1,1922 +0,0 @@ -/* - * Mesa 3-D graphics library - * Version: 7.3 - * - * Copyright (C) 1999-2008 Brian Paul All Rights Reserved. - * - * Permission is hereby granted, free of charge, to any person obtaining a - * copy of this software and associated documentation files (the "Software"), - * to deal in the Software without restriction, including without limitation - * the rights to use, copy, modify, merge, publish, distribute, sublicense, - * and/or sell copies of the Software, and to permit persons to whom the - * Software is furnished to do so, subject to the following conditions: - * - * The above copyright notice and this permission notice shall be included - * in all copies or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS - * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL - * BRIAN PAUL BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN - * AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN - * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. - */ - -#include - -/* - * Note, the FRAC macro has to work perfectly. Otherwise you'll sometimes - * see 1-pixel bands of improperly weighted linear-filtered textures. - * The tests/texwrap.c demo is a good test. - * Also note, FRAC(x) doesn't truly return the fractional part of x for x < 0. - * Instead, if x < 0 then FRAC(x) = 1 - true_frac(x). - */ -#define FRAC(f) ((f) - IFLOOR(f)) - - - -/** - * Linear interpolation macro - */ -#define LERP(T, A, B) ( (A) + (T) * ((B) - (A)) ) - - -/** - * Do 2D/biliner interpolation of float values. - * v00, v10, v01 and v11 are typically four texture samples in a square/box. - * a and b are the horizontal and vertical interpolants. - * It's important that this function is inlined when compiled with - * optimization! If we find that's not true on some systems, convert - * to a macro. - */ -static inline GLfloat -lerp_2d(GLfloat a, GLfloat b, - GLfloat v00, GLfloat v10, GLfloat v01, GLfloat v11) -{ - const GLfloat temp0 = LERP(a, v00, v10); - const GLfloat temp1 = LERP(a, v01, v11); - return LERP(b, temp0, temp1); -} - -/** - * Do linear interpolation of colors. - */ -static inline void -lerp_rgba(GLfloat result[4], GLfloat t, const GLfloat a[4], const GLfloat b[4]) -{ - result[0] = LERP(t, a[0], b[0]); - result[1] = LERP(t, a[1], b[1]); - result[2] = LERP(t, a[2], b[2]); - result[3] = LERP(t, a[3], b[3]); -} - - -/** - * Do bilinear interpolation of colors. - */ -static inline void -lerp_rgba_2d(GLfloat result[4], GLfloat a, GLfloat b, - const GLfloat t00[4], const GLfloat t10[4], - const GLfloat t01[4], const GLfloat t11[4]) -{ - result[0] = lerp_2d(a, b, t00[0], t10[0], t01[0], t11[0]); - result[1] = lerp_2d(a, b, t00[1], t10[1], t01[1], t11[1]); - result[2] = lerp_2d(a, b, t00[2], t10[2], t01[2], t11[2]); - result[3] = lerp_2d(a, b, t00[3], t10[3], t01[3], t11[3]); -} - -/** - * Used for GL_REPEAT wrap mode. Using A % B doesn't produce the - * right results for A<0. Casting to A to be unsigned only works if B - * is a power of two. Adding a bias to A (which is a multiple of B) - * avoids the problems with A < 0 (for reasonable A) without using a - * conditional. - */ -#define REMAINDER(A, B) (((A) + (B) * 1024) % (B)) - - -/** - * Used to compute texel locations for linear sampling. - * Input: - * wrapMode = GL_REPEAT, GL_CLAMP - * s = texcoord in [0,1] - * size = width (or height or depth) of texture - * Output: - * i0, i1 = returns two nearest texel indexes - * weight = returns blend factor between texels - */ -static inline void -linear_texel_locations(GLenum wrapMode, - const struct gl_texture_image *img, - GLint size, GLfloat s, - GLint *i0, GLint *i1, GLfloat *weight) -{ - const struct swrast_texture_image *swImg = swrast_texture_image_const(img); - GLfloat u; - switch (wrapMode) { - case GL_REPEAT: - u = s * size - 0.5F; - if (swImg->_IsPowerOfTwo) { - *i0 = IFLOOR(u) & (size - 1); - *i1 = (*i0 + 1) & (size - 1); - } - else { - *i0 = REMAINDER(IFLOOR(u), size); - *i1 = REMAINDER(*i0 + 1, size); - } - break; - case GL_MIRRORED_REPEAT: - { - const GLint flr = IFLOOR(s); - if (flr & 1) - u = 1.0F - (s - (GLfloat) flr); - else - u = s - (GLfloat) flr; - u = (u * size) - 0.5F; - *i0 = IFLOOR(u); - *i1 = *i0 + 1; - if (*i0 < 0) - *i0 = 0; - if (*i1 >= (GLint) size) - *i1 = size - 1; - } - break; - case GL_CLAMP: - if (s <= 0.0F) - u = 0.0F; - else if (s >= 1.0F) - u = (GLfloat) size; - else - u = s * size; - u -= 0.5F; - *i0 = IFLOOR(u); - *i1 = *i0 + 1; - break; - default: - _mesa_problem(NULL, "Bad wrap mode"); - u = 0.0F; - break; - } - *weight = FRAC(u); -} - - -/** - * Used to compute texel location for nearest sampling. - */ -static inline GLint -nearest_texel_location(GLenum wrapMode, - const struct gl_texture_image *img, - GLint size, GLfloat s) -{ - const struct swrast_texture_image *swImg = swrast_texture_image_const(img); - GLint i; - - switch (wrapMode) { - case GL_REPEAT: - /* s limited to [0,1) */ - /* i limited to [0,size-1] */ - i = IFLOOR(s * size); - if (swImg->_IsPowerOfTwo) - i &= (size - 1); - else - i = REMAINDER(i, size); - return i; - case GL_MIRRORED_REPEAT: - { - const GLfloat min = 1.0F / (2.0F * size); - const GLfloat max = 1.0F - min; - const GLint flr = IFLOOR(s); - GLfloat u; - if (flr & 1) - u = 1.0F - (s - (GLfloat) flr); - else - u = s - (GLfloat) flr; - if (u < min) - i = 0; - else if (u > max) - i = size - 1; - else - i = IFLOOR(u * size); - } - return i; - case GL_CLAMP: - /* s limited to [0,1] */ - /* i limited to [0,size-1] */ - if (s <= 0.0F) - i = 0; - else if (s >= 1.0F) - i = size - 1; - else - i = IFLOOR(s * size); - return i; - default: - _mesa_problem(NULL, "Bad wrap mode"); - return 0; - } -} - -/* Power of two image sizes only */ -static inline void -linear_repeat_texel_location(GLuint size, GLfloat s, - GLint *i0, GLint *i1, GLfloat *weight) -{ - GLfloat u = s * size - 0.5F; - *i0 = IFLOOR(u) & (size - 1); - *i1 = (*i0 + 1) & (size - 1); - *weight = FRAC(u); -} - -/** - * For linear interpolation between mipmap levels N and N+1, this function - * computes N. - */ -static inline GLint -linear_mipmap_level(const struct gl_texture_object *tObj, GLfloat lambda) -{ - if (lambda < 0.0F) - return tObj->BaseLevel; - else if (lambda > tObj->_MaxLambda) - return (GLint) (tObj->BaseLevel + tObj->_MaxLambda); - else - return (GLint) (tObj->BaseLevel + lambda); -} - - -/** - * Compute the nearest mipmap level to take texels from. - */ -static inline GLint -nearest_mipmap_level(const struct gl_texture_object *tObj, GLfloat lambda) -{ - GLfloat l; - GLint level; - if (lambda <= 0.5F) - l = 0.0F; - else if (lambda > tObj->_MaxLambda + 0.4999F) - l = tObj->_MaxLambda + 0.4999F; - else - l = lambda; - level = (GLint) (tObj->BaseLevel + l + 0.5F); - if (level > tObj->_MaxLevel) - level = tObj->_MaxLevel; - return level; -} - - - -/* - * Bitflags for texture border color sampling. - */ -#define I0BIT 1 -#define I1BIT 2 -#define J0BIT 4 -#define J1BIT 8 -#define K0BIT 16 -#define K1BIT 32 - - - -/** - * The lambda[] array values are always monotonic. Either the whole span - * will be minified, magnified, or split between the two. This function - * determines the subranges in [0, n-1] that are to be minified or magnified. - */ -static inline void -compute_min_mag_ranges(const struct gl_texture_object *tObj, - GLuint n, const GLfloat lambda[], - GLuint *minStart, GLuint *minEnd, - GLuint *magStart, GLuint *magEnd) -{ - GLfloat minMagThresh; - - /* we shouldn't be here if minfilter == magfilter */ - ASSERT(tObj->Sampler.MinFilter != tObj->Sampler.MagFilter); - - /* This bit comes from the OpenGL spec: */ - if (tObj->Sampler.MagFilter == GL_LINEAR - && (tObj->Sampler.MinFilter == GL_NEAREST_MIPMAP_NEAREST || - tObj->Sampler.MinFilter == GL_NEAREST_MIPMAP_LINEAR)) { - minMagThresh = 0.5F; - } - else { - minMagThresh = 0.0F; - } - -#if 0 - /* DEBUG CODE: Verify that lambda[] is monotonic. - * We can't really use this because the inaccuracy in the LOG2 function - * causes this test to fail, yet the resulting texturing is correct. - */ - if (n > 1) { - GLuint i; - printf("lambda delta = %g\n", lambda[0] - lambda[n-1]); - if (lambda[0] >= lambda[n-1]) { /* decreasing */ - for (i = 0; i < n - 1; i++) { - ASSERT((GLint) (lambda[i] * 10) >= (GLint) (lambda[i+1] * 10)); - } - } - else { /* increasing */ - for (i = 0; i < n - 1; i++) { - ASSERT((GLint) (lambda[i] * 10) <= (GLint) (lambda[i+1] * 10)); - } - } - } -#endif /* DEBUG */ - - if (lambda[0] <= minMagThresh && (n <= 1 || lambda[n-1] <= minMagThresh)) { - /* magnification for whole span */ - *magStart = 0; - *magEnd = n; - *minStart = *minEnd = 0; - } - else if (lambda[0] > minMagThresh && (n <=1 || lambda[n-1] > minMagThresh)) { - /* minification for whole span */ - *minStart = 0; - *minEnd = n; - *magStart = *magEnd = 0; - } - else { - /* a mix of minification and magnification */ - GLuint i; - if (lambda[0] > minMagThresh) { - /* start with minification */ - for (i = 1; i < n; i++) { - if (lambda[i] <= minMagThresh) - break; - } - *minStart = 0; - *minEnd = i; - *magStart = i; - *magEnd = n; - } - else { - /* start with magnification */ - for (i = 1; i < n; i++) { - if (lambda[i] > minMagThresh) - break; - } - *magStart = 0; - *magEnd = i; - *minStart = i; - *minEnd = n; - } - } - -#if 0 - /* Verify the min/mag Start/End values - * We don't use this either (see above) - */ - { - GLint i; - for (i = 0; i < n; i++) { - if (lambda[i] > minMagThresh) { - /* minification */ - ASSERT(i >= *minStart); - ASSERT(i < *minEnd); - } - else { - /* magnification */ - ASSERT(i >= *magStart); - ASSERT(i < *magEnd); - } - } - } -#endif -} - - -/** - * When we sample the border color, it must be interpreted according to - * the base texture format. Ex: if the texture base format it GL_ALPHA, - * we return (0,0,0,BorderAlpha). - */ -static inline void -get_border_color(const struct gl_texture_object *tObj, - const struct gl_texture_image *img, - GLfloat rgba[4]) -{ - switch (img->_BaseFormat) { - case GL_RGB: - rgba[0] = tObj->Sampler.BorderColor.f[0]; - rgba[1] = tObj->Sampler.BorderColor.f[1]; - rgba[2] = tObj->Sampler.BorderColor.f[2]; - rgba[3] = 1.0F; - break; - case GL_ALPHA: - rgba[0] = rgba[1] = rgba[2] = 0.0; - rgba[3] = tObj->Sampler.BorderColor.f[3]; - break; - case GL_LUMINANCE: - rgba[0] = rgba[1] = rgba[2] = tObj->Sampler.BorderColor.f[0]; - rgba[3] = 1.0; - break; - case GL_LUMINANCE_ALPHA: - rgba[0] = rgba[1] = rgba[2] = tObj->Sampler.BorderColor.f[0]; - rgba[3] = tObj->Sampler.BorderColor.f[3]; - break; - case GL_INTENSITY: - rgba[0] = rgba[1] = rgba[2] = rgba[3] = tObj->Sampler.BorderColor.f[0]; - break; - default: - COPY_4V(rgba, tObj->Sampler.BorderColor.f); - break; - } -} - - -/**********************************************************************/ -/* 1-D Texture Sampling Functions */ -/**********************************************************************/ - -/** - * Return the texture sample for coordinate (s) using GL_NEAREST filter. - */ -static inline void -sample_1d_nearest(struct gl_context *ctx, - const struct gl_texture_object *tObj, - const struct gl_texture_image *img, - const GLfloat texcoord[4], GLfloat rgba[4]) -{ - const struct swrast_texture_image *swImg = swrast_texture_image_const(img); - const GLint width = img->Width2; /* without border, power of two */ - GLint i; - i = nearest_texel_location(tObj->Sampler.WrapS, img, width, texcoord[0]); - /* skip over the border, if any */ - i += img->Border; - if (i < 0 || i >= (GLint) img->Width) { - /* Need this test for GL_CLAMP_TO_BORDER mode */ - get_border_color(tObj, img, rgba); - } - else { - swImg->FetchTexel(swImg, i, 0, 0, rgba); - } -} - - -/** - * Return the texture sample for coordinate (s) using GL_LINEAR filter. - */ -static inline void -sample_1d_linear(struct gl_context *ctx, - const struct gl_texture_object *tObj, - const struct gl_texture_image *img, - const GLfloat texcoord[4], GLfloat rgba[4]) -{ - const struct swrast_texture_image *swImg = swrast_texture_image_const(img); - const GLint width = img->Width2; - GLint i0, i1; - GLbitfield useBorderColor = 0x0; - GLfloat a; - GLfloat t0[4], t1[4]; /* texels */ - - linear_texel_locations(tObj->Sampler.WrapS, img, width, texcoord[0], &i0, &i1, &a); - - if (img->Border) { - i0 += img->Border; - i1 += img->Border; - } - else { - if (i0 < 0 || i0 >= width) useBorderColor |= I0BIT; - if (i1 < 0 || i1 >= width) useBorderColor |= I1BIT; - } - - /* fetch texel colors */ - if (useBorderColor & I0BIT) { - get_border_color(tObj, img, t0); - } - else { - swImg->FetchTexel(swImg, i0, 0, 0, t0); - } - if (useBorderColor & I1BIT) { - get_border_color(tObj, img, t1); - } - else { - swImg->FetchTexel(swImg, i1, 0, 0, t1); - } - - lerp_rgba(rgba, a, t0, t1); -} - - -static void -sample_1d_nearest_mipmap_nearest(struct gl_context *ctx, - const struct gl_texture_object *tObj, - GLuint n, const GLfloat texcoord[][4], - const GLfloat lambda[], GLfloat rgba[][4]) -{ - GLuint i; - ASSERT(lambda != NULL); - for (i = 0; i < n; i++) { - GLint level = nearest_mipmap_level(tObj, lambda[i]); - sample_1d_nearest(ctx, tObj, tObj->Image[0][level], texcoord[i], rgba[i]); - } -} - - -static void -sample_1d_linear_mipmap_nearest(struct gl_context *ctx, - const struct gl_texture_object *tObj, - GLuint n, const GLfloat texcoord[][4], - const GLfloat lambda[], GLfloat rgba[][4]) -{ - GLuint i; - ASSERT(lambda != NULL); - for (i = 0; i < n; i++) { - GLint level = nearest_mipmap_level(tObj, lambda[i]); - sample_1d_linear(ctx, tObj, tObj->Image[0][level], texcoord[i], rgba[i]); - } -} - - -static void -sample_1d_nearest_mipmap_linear(struct gl_context *ctx, - const struct gl_texture_object *tObj, - GLuint n, const GLfloat texcoord[][4], - const GLfloat lambda[], GLfloat rgba[][4]) -{ - GLuint i; - ASSERT(lambda != NULL); - for (i = 0; i < n; i++) { - GLint level = linear_mipmap_level(tObj, lambda[i]); - if (level >= tObj->_MaxLevel) { - sample_1d_nearest(ctx, tObj, tObj->Image[0][tObj->_MaxLevel], - texcoord[i], rgba[i]); - } - else { - GLfloat t0[4], t1[4]; - const GLfloat f = FRAC(lambda[i]); - sample_1d_nearest(ctx, tObj, tObj->Image[0][level ], texcoord[i], t0); - sample_1d_nearest(ctx, tObj, tObj->Image[0][level+1], texcoord[i], t1); - lerp_rgba(rgba[i], f, t0, t1); - } - } -} - - -static void -sample_1d_linear_mipmap_linear(struct gl_context *ctx, - const struct gl_texture_object *tObj, - GLuint n, const GLfloat texcoord[][4], - const GLfloat lambda[], GLfloat rgba[][4]) -{ - GLuint i; - ASSERT(lambda != NULL); - for (i = 0; i < n; i++) { - GLint level = linear_mipmap_level(tObj, lambda[i]); - if (level >= tObj->_MaxLevel) { - sample_1d_linear(ctx, tObj, tObj->Image[0][tObj->_MaxLevel], - texcoord[i], rgba[i]); - } - else { - GLfloat t0[4], t1[4]; - const GLfloat f = FRAC(lambda[i]); - sample_1d_linear(ctx, tObj, tObj->Image[0][level ], texcoord[i], t0); - sample_1d_linear(ctx, tObj, tObj->Image[0][level+1], texcoord[i], t1); - lerp_rgba(rgba[i], f, t0, t1); - } - } -} - - -/** Sample 1D texture, nearest filtering for both min/magnification */ -static void -sample_nearest_1d( struct gl_context *ctx, - const struct gl_texture_object *tObj, GLuint n, - const GLfloat texcoords[][4], const GLfloat lambda[], - GLfloat rgba[][4] ) -{ - GLuint i; - struct gl_texture_image *image = tObj->Image[0][tObj->BaseLevel]; - (void) lambda; - for (i = 0; i < n; i++) { - sample_1d_nearest(ctx, tObj, image, texcoords[i], rgba[i]); - } -} - - -/** Sample 1D texture, linear filtering for both min/magnification */ -static void -sample_linear_1d( struct gl_context *ctx, - const struct gl_texture_object *tObj, GLuint n, - const GLfloat texcoords[][4], const GLfloat lambda[], - GLfloat rgba[][4] ) -{ - GLuint i; - struct gl_texture_image *image = tObj->Image[0][tObj->BaseLevel]; - (void) lambda; - for (i = 0; i < n; i++) { - sample_1d_linear(ctx, tObj, image, texcoords[i], rgba[i]); - } -} - - -/** Sample 1D texture, using lambda to choose between min/magnification */ -static void -sample_lambda_1d( struct gl_context *ctx, - const struct gl_texture_object *tObj, GLuint n, - const GLfloat texcoords[][4], - const GLfloat lambda[], GLfloat rgba[][4] ) -{ - GLuint minStart, minEnd; /* texels with minification */ - GLuint magStart, magEnd; /* texels with magnification */ - GLuint i; - - ASSERT(lambda != NULL); - compute_min_mag_ranges(tObj, n, lambda, - &minStart, &minEnd, &magStart, &magEnd); - - if (minStart < minEnd) { - /* do the minified texels */ - const GLuint m = minEnd - minStart; - switch (tObj->Sampler.MinFilter) { - case GL_NEAREST: - for (i = minStart; i < minEnd; i++) - sample_1d_nearest(ctx, tObj, tObj->Image[0][tObj->BaseLevel], - texcoords[i], rgba[i]); - break; - case GL_LINEAR: - for (i = minStart; i < minEnd; i++) - sample_1d_linear(ctx, tObj, tObj->Image[0][tObj->BaseLevel], - texcoords[i], rgba[i]); - break; - case GL_NEAREST_MIPMAP_NEAREST: - sample_1d_nearest_mipmap_nearest(ctx, tObj, m, texcoords + minStart, - lambda + minStart, rgba + minStart); - break; - case GL_LINEAR_MIPMAP_NEAREST: - sample_1d_linear_mipmap_nearest(ctx, tObj, m, texcoords + minStart, - lambda + minStart, rgba + minStart); - break; - case GL_NEAREST_MIPMAP_LINEAR: - sample_1d_nearest_mipmap_linear(ctx, tObj, m, texcoords + minStart, - lambda + minStart, rgba + minStart); - break; - case GL_LINEAR_MIPMAP_LINEAR: - sample_1d_linear_mipmap_linear(ctx, tObj, m, texcoords + minStart, - lambda + minStart, rgba + minStart); - break; - default: - _mesa_problem(ctx, "Bad min filter in sample_1d_texture"); - return; - } - } - - if (magStart < magEnd) { - /* do the magnified texels */ - switch (tObj->Sampler.MagFilter) { - case GL_NEAREST: - for (i = magStart; i < magEnd; i++) - sample_1d_nearest(ctx, tObj, tObj->Image[0][tObj->BaseLevel], - texcoords[i], rgba[i]); - break; - case GL_LINEAR: - for (i = magStart; i < magEnd; i++) - sample_1d_linear(ctx, tObj, tObj->Image[0][tObj->BaseLevel], - texcoords[i], rgba[i]); - break; - default: - _mesa_problem(ctx, "Bad mag filter in sample_1d_texture"); - return; - } - } -} - - -/**********************************************************************/ -/* 2-D Texture Sampling Functions */ -/**********************************************************************/ - - -/** - * Return the texture sample for coordinate (s,t) using GL_NEAREST filter. - */ -static inline void -sample_2d_nearest(struct gl_context *ctx, - const struct gl_texture_object *tObj, - const struct gl_texture_image *img, - const GLfloat texcoord[4], - GLfloat rgba[]) -{ - const struct swrast_texture_image *swImg = swrast_texture_image_const(img); - const GLint width = img->Width2; /* without border, power of two */ - const GLint height = img->Height2; /* without border, power of two */ - GLint i, j; - (void) ctx; - - i = nearest_texel_location(tObj->Sampler.WrapS, img, width, texcoord[0]); - j = nearest_texel_location(tObj->Sampler.WrapT, img, height, texcoord[1]); - - /* skip over the border, if any */ - i += img->Border; - j += img->Border; - - if (i < 0 || i >= (GLint) img->Width || j < 0 || j >= (GLint) img->Height) { - /* Need this test for GL_CLAMP_TO_BORDER mode */ - get_border_color(tObj, img, rgba); - } - else { - swImg->FetchTexel(swImg, i, j, 0, rgba); - } -} - - -/** - * Return the texture sample for coordinate (s,t) using GL_LINEAR filter. - * New sampling code contributed by Lynn Quam . - */ -static inline void -sample_2d_linear(struct gl_context *ctx, - const struct gl_texture_object *tObj, - const struct gl_texture_image *img, - const GLfloat texcoord[4], - GLfloat rgba[]) -{ - const struct swrast_texture_image *swImg = swrast_texture_image_const(img); - const GLint width = img->Width2; - const GLint height = img->Height2; - GLint i0, j0, i1, j1; - GLbitfield useBorderColor = 0x0; - GLfloat a, b; - GLfloat t00[4], t10[4], t01[4], t11[4]; /* sampled texel colors */ - - linear_texel_locations(tObj->Sampler.WrapS, img, width, texcoord[0], &i0, &i1, &a); - linear_texel_locations(tObj->Sampler.WrapT, img, height, texcoord[1], &j0, &j1, &b); - - if (img->Border) { - i0 += img->Border; - i1 += img->Border; - j0 += img->Border; - j1 += img->Border; - } - else { - if (i0 < 0 || i0 >= width) useBorderColor |= I0BIT; - if (i1 < 0 || i1 >= width) useBorderColor |= I1BIT; - if (j0 < 0 || j0 >= height) useBorderColor |= J0BIT; - if (j1 < 0 || j1 >= height) useBorderColor |= J1BIT; - } - - /* fetch four texel colors */ - if (useBorderColor & (I0BIT | J0BIT)) { - get_border_color(tObj, img, t00); - } - else { - swImg->FetchTexel(swImg, i0, j0, 0, t00); - } - if (useBorderColor & (I1BIT | J0BIT)) { - get_border_color(tObj, img, t10); - } - else { - swImg->FetchTexel(swImg, i1, j0, 0, t10); - } - if (useBorderColor & (I0BIT | J1BIT)) { - get_border_color(tObj, img, t01); - } - else { - swImg->FetchTexel(swImg, i0, j1, 0, t01); - } - if (useBorderColor & (I1BIT | J1BIT)) { - get_border_color(tObj, img, t11); - } - else { - swImg->FetchTexel(swImg, i1, j1, 0, t11); - } - - lerp_rgba_2d(rgba, a, b, t00, t10, t01, t11); -} - - -/** - * As above, but we know WRAP_S == REPEAT and WRAP_T == REPEAT. - * We don't have to worry about the texture border. - */ -static inline void -sample_2d_linear_repeat(struct gl_context *ctx, - const struct gl_texture_object *tObj, - const struct gl_texture_image *img, - const GLfloat texcoord[4], - GLfloat rgba[]) -{ - const struct swrast_texture_image *swImg = swrast_texture_image_const(img); - const GLint width = img->Width2; - const GLint height = img->Height2; - GLint i0, j0, i1, j1; - GLfloat wi, wj; - GLfloat t00[4], t10[4], t01[4], t11[4]; /* sampled texel colors */ - - (void) ctx; - - ASSERT(tObj->Sampler.WrapS == GL_REPEAT); - ASSERT(tObj->Sampler.WrapT == GL_REPEAT); - ASSERT(img->Border == 0); - ASSERT(swImg->_IsPowerOfTwo); - - linear_repeat_texel_location(width, texcoord[0], &i0, &i1, &wi); - linear_repeat_texel_location(height, texcoord[1], &j0, &j1, &wj); - - swImg->FetchTexel(swImg, i0, j0, 0, t00); - swImg->FetchTexel(swImg, i1, j0, 0, t10); - swImg->FetchTexel(swImg, i0, j1, 0, t01); - swImg->FetchTexel(swImg, i1, j1, 0, t11); - - lerp_rgba_2d(rgba, wi, wj, t00, t10, t01, t11); -} - - -static void -sample_2d_nearest_mipmap_nearest(struct gl_context *ctx, - const struct gl_texture_object *tObj, - GLuint n, const GLfloat texcoord[][4], - const GLfloat lambda[], GLfloat rgba[][4]) -{ - GLuint i; - for (i = 0; i < n; i++) { - GLint level = nearest_mipmap_level(tObj, lambda[i]); - sample_2d_nearest(ctx, tObj, tObj->Image[0][level], texcoord[i], rgba[i]); - } -} - - -static void -sample_2d_linear_mipmap_nearest(struct gl_context *ctx, - const struct gl_texture_object *tObj, - GLuint n, const GLfloat texcoord[][4], - const GLfloat lambda[], GLfloat rgba[][4]) -{ - GLuint i; - ASSERT(lambda != NULL); - for (i = 0; i < n; i++) { - GLint level = nearest_mipmap_level(tObj, lambda[i]); - sample_2d_linear(ctx, tObj, tObj->Image[0][level], texcoord[i], rgba[i]); - } -} - - -static void -sample_2d_nearest_mipmap_linear(struct gl_context *ctx, - const struct gl_texture_object *tObj, - GLuint n, const GLfloat texcoord[][4], - const GLfloat lambda[], GLfloat rgba[][4]) -{ - GLuint i; - ASSERT(lambda != NULL); - for (i = 0; i < n; i++) { - GLint level = linear_mipmap_level(tObj, lambda[i]); - if (level >= tObj->_MaxLevel) { - sample_2d_nearest(ctx, tObj, tObj->Image[0][tObj->_MaxLevel], - texcoord[i], rgba[i]); - } - else { - GLfloat t0[4], t1[4]; /* texels */ - const GLfloat f = FRAC(lambda[i]); - sample_2d_nearest(ctx, tObj, tObj->Image[0][level ], texcoord[i], t0); - sample_2d_nearest(ctx, tObj, tObj->Image[0][level+1], texcoord[i], t1); - lerp_rgba(rgba[i], f, t0, t1); - } - } -} - - -static void -sample_2d_linear_mipmap_linear( struct gl_context *ctx, - const struct gl_texture_object *tObj, - GLuint n, const GLfloat texcoord[][4], - const GLfloat lambda[], GLfloat rgba[][4] ) -{ - GLuint i; - ASSERT(lambda != NULL); - for (i = 0; i < n; i++) { - GLint level = linear_mipmap_level(tObj, lambda[i]); - if (level >= tObj->_MaxLevel) { - sample_2d_linear(ctx, tObj, tObj->Image[0][tObj->_MaxLevel], - texcoord[i], rgba[i]); - } - else { - GLfloat t0[4], t1[4]; /* texels */ - const GLfloat f = FRAC(lambda[i]); - sample_2d_linear(ctx, tObj, tObj->Image[0][level ], texcoord[i], t0); - sample_2d_linear(ctx, tObj, tObj->Image[0][level+1], texcoord[i], t1); - lerp_rgba(rgba[i], f, t0, t1); - } - } -} - - -static void -sample_2d_linear_mipmap_linear_repeat(struct gl_context *ctx, - const struct gl_texture_object *tObj, - GLuint n, const GLfloat texcoord[][4], - const GLfloat lambda[], GLfloat rgba[][4]) -{ - GLuint i; - ASSERT(lambda != NULL); - ASSERT(tObj->Sampler.WrapS == GL_REPEAT); - ASSERT(tObj->Sampler.WrapT == GL_REPEAT); - for (i = 0; i < n; i++) { - GLint level = linear_mipmap_level(tObj, lambda[i]); - if (level >= tObj->_MaxLevel) { - sample_2d_linear_repeat(ctx, tObj, tObj->Image[0][tObj->_MaxLevel], - texcoord[i], rgba[i]); - } - else { - GLfloat t0[4], t1[4]; /* texels */ - const GLfloat f = FRAC(lambda[i]); - sample_2d_linear_repeat(ctx, tObj, tObj->Image[0][level ], - texcoord[i], t0); - sample_2d_linear_repeat(ctx, tObj, tObj->Image[0][level+1], - texcoord[i], t1); - lerp_rgba(rgba[i], f, t0, t1); - } - } -} - - -/** Sample 2D texture, nearest filtering for both min/magnification */ -static void -sample_nearest_2d(struct gl_context *ctx, - const struct gl_texture_object *tObj, GLuint n, - const GLfloat texcoords[][4], - const GLfloat lambda[], GLfloat rgba[][4]) -{ - GLuint i; - struct gl_texture_image *image = tObj->Image[0][tObj->BaseLevel]; - (void) lambda; - for (i = 0; i < n; i++) { - sample_2d_nearest(ctx, tObj, image, texcoords[i], rgba[i]); - } -} - - -/** Sample 2D texture, linear filtering for both min/magnification */ -static void -sample_linear_2d(struct gl_context *ctx, - const struct gl_texture_object *tObj, GLuint n, - const GLfloat texcoords[][4], - const GLfloat lambda[], GLfloat rgba[][4]) -{ - GLuint i; - struct gl_texture_image *image = tObj->Image[0][tObj->BaseLevel]; - const struct swrast_texture_image *swImg = swrast_texture_image_const(image); - (void) lambda; - if (tObj->Sampler.WrapS == GL_REPEAT && - tObj->Sampler.WrapT == GL_REPEAT && - swImg->_IsPowerOfTwo && - image->Border == 0) { - for (i = 0; i < n; i++) { - sample_2d_linear_repeat(ctx, tObj, image, texcoords[i], rgba[i]); - } - } - else { - for (i = 0; i < n; i++) { - sample_2d_linear(ctx, tObj, image, texcoords[i], rgba[i]); - } - } -} - - -/** - * Optimized 2-D texture sampling: - * S and T wrap mode == GL_REPEAT - * GL_NEAREST min/mag filter - * No border, - * RowStride == Width, - * Format = GL_RGB - */ -static void -opt_sample_rgb_2d(struct gl_context *ctx, - const struct gl_texture_object *tObj, - GLuint n, const GLfloat texcoords[][4], - const GLfloat lambda[], GLfloat rgba[][4]) -{ - const struct gl_texture_image *img = tObj->Image[0][tObj->BaseLevel]; - const struct swrast_texture_image *swImg = swrast_texture_image_const(img); - const GLfloat width = (GLfloat) img->Width; - const GLfloat height = (GLfloat) img->Height; - const GLint colMask = img->Width - 1; - const GLint rowMask = img->Height - 1; - const GLint shift = img->WidthLog2; - GLuint k; - (void) ctx; - (void) lambda; - ASSERT(tObj->Sampler.WrapS==GL_REPEAT); - ASSERT(tObj->Sampler.WrapT==GL_REPEAT); - ASSERT(img->Border==0); - ASSERT(img->TexFormat == MESA_FORMAT_RGB888); - ASSERT(swImg->_IsPowerOfTwo); - (void) swImg; - - for (k=0; kMap + 3 * pos; - rgba[k][RCOMP] = UBYTE_TO_FLOAT(texel[2]); - rgba[k][GCOMP] = UBYTE_TO_FLOAT(texel[1]); - rgba[k][BCOMP] = UBYTE_TO_FLOAT(texel[0]); - rgba[k][ACOMP] = 1.0F; - } -} - - -/** - * Optimized 2-D texture sampling: - * S and T wrap mode == GL_REPEAT - * GL_NEAREST min/mag filter - * No border - * RowStride == Width, - * Format = GL_RGBA - */ -static void -opt_sample_rgba_2d(struct gl_context *ctx, - const struct gl_texture_object *tObj, - GLuint n, const GLfloat texcoords[][4], - const GLfloat lambda[], GLfloat rgba[][4]) -{ - const struct gl_texture_image *img = tObj->Image[0][tObj->BaseLevel]; - const struct swrast_texture_image *swImg = swrast_texture_image_const(img); - const GLfloat width = (GLfloat) img->Width; - const GLfloat height = (GLfloat) img->Height; - const GLint colMask = img->Width - 1; - const GLint rowMask = img->Height - 1; - const GLint shift = img->WidthLog2; - GLuint i; - (void) ctx; - (void) lambda; - ASSERT(tObj->Sampler.WrapS==GL_REPEAT); - ASSERT(tObj->Sampler.WrapT==GL_REPEAT); - ASSERT(img->Border==0); - ASSERT(img->TexFormat == MESA_FORMAT_RGBA8888); - ASSERT(swImg->_IsPowerOfTwo); - (void) swImg; - - for (i = 0; i < n; i++) { - const GLint col = IFLOOR(texcoords[i][0] * width) & colMask; - const GLint row = IFLOOR(texcoords[i][1] * height) & rowMask; - const GLint pos = (row << shift) | col; - const GLuint texel = *((GLuint *) swImg->Map + pos); - rgba[i][RCOMP] = UBYTE_TO_FLOAT( (texel >> 24) ); - rgba[i][GCOMP] = UBYTE_TO_FLOAT( (texel >> 16) & 0xff ); - rgba[i][BCOMP] = UBYTE_TO_FLOAT( (texel >> 8) & 0xff ); - rgba[i][ACOMP] = UBYTE_TO_FLOAT( (texel ) & 0xff ); - } -} - - -/** Sample 2D texture, using lambda to choose between min/magnification */ -static void -sample_lambda_2d(struct gl_context *ctx, - const struct gl_texture_object *tObj, - GLuint n, const GLfloat texcoords[][4], - const GLfloat lambda[], GLfloat rgba[][4]) -{ - const struct gl_texture_image *tImg = tObj->Image[0][tObj->BaseLevel]; - const struct swrast_texture_image *swImg = swrast_texture_image_const(tImg); - GLuint minStart, minEnd; /* texels with minification */ - GLuint magStart, magEnd; /* texels with magnification */ - - const GLboolean repeatNoBorderPOT = (tObj->Sampler.WrapS == GL_REPEAT) - && (tObj->Sampler.WrapT == GL_REPEAT) - && (tImg->Border == 0 && (tImg->Width == swImg->RowStride)) - && swImg->_IsPowerOfTwo; - - ASSERT(lambda != NULL); - compute_min_mag_ranges(tObj, n, lambda, - &minStart, &minEnd, &magStart, &magEnd); - - if (minStart < minEnd) { - /* do the minified texels */ - const GLuint m = minEnd - minStart; - switch (tObj->Sampler.MinFilter) { - case GL_NEAREST: - if (repeatNoBorderPOT) { - switch (tImg->TexFormat) { - case MESA_FORMAT_RGB888: - opt_sample_rgb_2d(ctx, tObj, m, texcoords + minStart, - NULL, rgba + minStart); - break; - case MESA_FORMAT_RGBA8888: - opt_sample_rgba_2d(ctx, tObj, m, texcoords + minStart, - NULL, rgba + minStart); - break; - default: - sample_nearest_2d(ctx, tObj, m, texcoords + minStart, - NULL, rgba + minStart ); - } - } - else { - sample_nearest_2d(ctx, tObj, m, texcoords + minStart, - NULL, rgba + minStart); - } - break; - case GL_LINEAR: - sample_linear_2d(ctx, tObj, m, texcoords + minStart, - NULL, rgba + minStart); - break; - case GL_NEAREST_MIPMAP_NEAREST: - sample_2d_nearest_mipmap_nearest(ctx, tObj, m, - texcoords + minStart, - lambda + minStart, rgba + minStart); - break; - case GL_LINEAR_MIPMAP_NEAREST: - sample_2d_linear_mipmap_nearest(ctx, tObj, m, texcoords + minStart, - lambda + minStart, rgba + minStart); - break; - case GL_NEAREST_MIPMAP_LINEAR: - sample_2d_nearest_mipmap_linear(ctx, tObj, m, texcoords + minStart, - lambda + minStart, rgba + minStart); - break; - case GL_LINEAR_MIPMAP_LINEAR: - if (repeatNoBorderPOT) - sample_2d_linear_mipmap_linear_repeat(ctx, tObj, m, - texcoords + minStart, lambda + minStart, rgba + minStart); - else - sample_2d_linear_mipmap_linear(ctx, tObj, m, texcoords + minStart, - lambda + minStart, rgba + minStart); - break; - default: - _mesa_problem(ctx, "Bad min filter in sample_2d_texture"); - return; - } - } - - if (magStart < magEnd) { - /* do the magnified texels */ - const GLuint m = magEnd - magStart; - - switch (tObj->Sampler.MagFilter) { - case GL_NEAREST: - if (repeatNoBorderPOT) { - switch (tImg->TexFormat) { - case MESA_FORMAT_RGB888: - opt_sample_rgb_2d(ctx, tObj, m, texcoords + magStart, - NULL, rgba + magStart); - break; - case MESA_FORMAT_RGBA8888: - opt_sample_rgba_2d(ctx, tObj, m, texcoords + magStart, - NULL, rgba + magStart); - break; - default: - sample_nearest_2d(ctx, tObj, m, texcoords + magStart, - NULL, rgba + magStart ); - } - } - else { - sample_nearest_2d(ctx, tObj, m, texcoords + magStart, - NULL, rgba + magStart); - } - break; - case GL_LINEAR: - sample_linear_2d(ctx, tObj, m, texcoords + magStart, - NULL, rgba + magStart); - break; - default: - _mesa_problem(ctx, "Bad mag filter in sample_lambda_2d"); - break; - } - } -} - - -/* For anisotropic filtering */ -#define WEIGHT_LUT_SIZE 1024 - -static GLfloat *weightLut = NULL; - -/** - * Creates the look-up table used to speed-up EWA sampling - */ -static void -create_filter_table(void) -{ - GLuint i; - if (!weightLut) { - weightLut = (GLfloat *) malloc(WEIGHT_LUT_SIZE * sizeof(GLfloat)); - - for (i = 0; i < WEIGHT_LUT_SIZE; ++i) { - GLfloat alpha = 2; - GLfloat r2 = (GLfloat) i / (GLfloat) (WEIGHT_LUT_SIZE - 1); - GLfloat weight = (GLfloat) exp(-alpha * r2); - weightLut[i] = weight; - } - } -} - - -/** - * Elliptical weighted average (EWA) filter for producing high quality - * anisotropic filtered results. - * Based on the Higher Quality Elliptical Weighted Avarage Filter - * published by Paul S. Heckbert in his Master's Thesis - * "Fundamentals of Texture Mapping and Image Warping" (1989) - */ -static void -sample_2d_ewa(struct gl_context *ctx, - const struct gl_texture_object *tObj, - const GLfloat texcoord[4], - const GLfloat dudx, const GLfloat dvdx, - const GLfloat dudy, const GLfloat dvdy, const GLint lod, - GLfloat rgba[]) -{ - GLint level = lod > 0 ? lod : 0; - GLfloat scaling = 1.0 / (1 << level); - const struct gl_texture_image *img = tObj->Image[0][level]; - const struct gl_texture_image *mostDetailedImage = - tObj->Image[0][tObj->BaseLevel]; - const struct swrast_texture_image *swImg = - swrast_texture_image_const(mostDetailedImage); - GLfloat tex_u=-0.5 + texcoord[0] * swImg->WidthScale * scaling; - GLfloat tex_v=-0.5 + texcoord[1] * swImg->HeightScale * scaling; - - GLfloat ux = dudx * scaling; - GLfloat vx = dvdx * scaling; - GLfloat uy = dudy * scaling; - GLfloat vy = dvdy * scaling; - - /* compute ellipse coefficients to bound the region: - * A*x*x + B*x*y + C*y*y = F. - */ - GLfloat A = vx*vx+vy*vy+1; - GLfloat B = -2*(ux*vx+uy*vy); - GLfloat C = ux*ux+uy*uy+1; - GLfloat F = A*C-B*B/4.0; - - /* check if it is an ellipse */ - /* ASSERT(F > 0.0); */ - - /* Compute the ellipse's (u,v) bounding box in texture space */ - GLfloat d = -B*B+4.0*C*A; - GLfloat box_u = 2.0 / d * sqrt(d*C*F); /* box_u -> half of bbox with */ - GLfloat box_v = 2.0 / d * sqrt(A*d*F); /* box_v -> half of bbox height */ - - GLint u0 = floor(tex_u - box_u); - GLint u1 = ceil (tex_u + box_u); - GLint v0 = floor(tex_v - box_v); - GLint v1 = ceil (tex_v + box_v); - - GLfloat num[4] = {0.0F, 0.0F, 0.0F, 0.0F}; - GLfloat newCoord[2]; - GLfloat den = 0.0F; - GLfloat ddq; - GLfloat U = u0 - tex_u; - GLint v; - - /* Scale ellipse formula to directly index the Filter Lookup Table. - * i.e. scale so that F = WEIGHT_LUT_SIZE-1 - */ - double formScale = (double) (WEIGHT_LUT_SIZE - 1) / F; - A *= formScale; - B *= formScale; - C *= formScale; - /* F *= formScale; */ /* no need to scale F as we don't use it below here */ - - /* Heckbert MS thesis, p. 59; scan over the bounding box of the ellipse - * and incrementally update the value of Ax^2+Bxy*Cy^2; when this - * value, q, is less than F, we're inside the ellipse - */ - ddq = 2 * A; - for (v = v0; v <= v1; ++v) { - GLfloat V = v - tex_v; - GLfloat dq = A * (2 * U + 1) + B * V; - GLfloat q = (C * V + B * U) * V + A * U * U; - - GLint u; - for (u = u0; u <= u1; ++u) { - /* Note that the ellipse has been pre-scaled so F = WEIGHT_LUT_SIZE - 1 */ - if (q < WEIGHT_LUT_SIZE) { - /* as a LUT is used, q must never be negative; - * should not happen, though - */ - const GLint qClamped = q >= 0.0F ? q : 0; - GLfloat weight = weightLut[qClamped]; - - newCoord[0] = u / ((GLfloat) img->Width2); - newCoord[1] = v / ((GLfloat) img->Height2); - - sample_2d_nearest(ctx, tObj, img, newCoord, rgba); - num[0] += weight * rgba[0]; - num[1] += weight * rgba[1]; - num[2] += weight * rgba[2]; - num[3] += weight * rgba[3]; - - den += weight; - } - q += dq; - dq += ddq; - } - } - - if (den <= 0.0F) { - /* Reaching this place would mean - * that no pixels intersected the ellipse. - * This should never happen because - * the filter we use always - * intersects at least one pixel. - */ - - /*rgba[0]=0; - rgba[1]=0; - rgba[2]=0; - rgba[3]=0;*/ - /* not enough pixels in resampling, resort to direct interpolation */ - sample_2d_linear(ctx, tObj, img, texcoord, rgba); - return; - } - - rgba[0] = num[0] / den; - rgba[1] = num[1] / den; - rgba[2] = num[2] / den; - rgba[3] = num[3] / den; -} - - -/** - * Anisotropic filtering using footprint assembly as outlined in the - * EXT_texture_filter_anisotropic spec: - * http://www.opengl.org/registry/specs/EXT/texture_filter_anisotropic.txt - * Faster than EWA but has less quality (more aliasing effects) - */ -static void -sample_2d_footprint(struct gl_context *ctx, - const struct gl_texture_object *tObj, - const GLfloat texcoord[4], - const GLfloat dudx, const GLfloat dvdx, - const GLfloat dudy, const GLfloat dvdy, const GLint lod, - GLfloat rgba[]) -{ - GLint level = lod > 0 ? lod : 0; - GLfloat scaling = 1.0F / (1 << level); - const struct gl_texture_image *img = tObj->Image[0][level]; - - GLfloat ux = dudx * scaling; - GLfloat vx = dvdx * scaling; - GLfloat uy = dudy * scaling; - GLfloat vy = dvdy * scaling; - - GLfloat Px2 = ux * ux + vx * vx; /* squared length of dx */ - GLfloat Py2 = uy * uy + vy * vy; /* squared length of dy */ - - GLint numSamples; - GLfloat ds; - GLfloat dt; - - GLfloat num[4] = {0.0F, 0.0F, 0.0F, 0.0F}; - GLfloat newCoord[2]; - GLint s; - - /* Calculate the per anisotropic sample offsets in s,t space. */ - if (Px2 > Py2) { - numSamples = ceil(SQRTF(Px2)); - ds = ux / ((GLfloat) img->Width2); - dt = vx / ((GLfloat) img->Height2); - } - else { - numSamples = ceil(SQRTF(Py2)); - ds = uy / ((GLfloat) img->Width2); - dt = vy / ((GLfloat) img->Height2); - } - - for (s = 0; sImage[0][tObj->BaseLevel]; - const struct swrast_texture_image *swImg = swrast_texture_image_const(tImg); - const GLfloat maxEccentricity = - tObj->Sampler.MaxAnisotropy * tObj->Sampler.MaxAnisotropy; - - /* re-calculate the lambda values so that they are usable with anisotropic - * filtering - */ - SWspan *span = (SWspan *)lambda_iso; /* access the "hidden" SWspan struct */ - - /* based on interpolate_texcoords(struct gl_context *ctx, SWspan *span) - * in swrast/s_span.c - */ - - /* find the texture unit index by looking up the current texture object - * from the context list of available texture objects. - */ - const GLuint attr = FRAG_ATTRIB_TEX; - GLfloat texW, texH; - - const GLfloat dsdx = span->attrStepX[attr][0]; - const GLfloat dsdy = span->attrStepY[attr][0]; - const GLfloat dtdx = span->attrStepX[attr][1]; - const GLfloat dtdy = span->attrStepY[attr][1]; - const GLfloat dqdx = span->attrStepX[attr][3]; - const GLfloat dqdy = span->attrStepY[attr][3]; - GLfloat s = span->attrStart[attr][0] + span->leftClip * dsdx; - GLfloat t = span->attrStart[attr][1] + span->leftClip * dtdx; - GLfloat q = span->attrStart[attr][3] + span->leftClip * dqdx; - - GLuint i; - - /* on first access create the lookup table containing the filter weights. */ - if (!weightLut) { - create_filter_table(); - } - - texW = swImg->WidthScale; - texH = swImg->HeightScale; - - for (i = 0; i < n; i++) { - const GLfloat invQ = (q == 0.0F) ? 1.0F : (1.0F / q); - - GLfloat dudx = texW * ((s + dsdx) / (q + dqdx) - s * invQ); - GLfloat dvdx = texH * ((t + dtdx) / (q + dqdx) - t * invQ); - GLfloat dudy = texW * ((s + dsdy) / (q + dqdy) - s * invQ); - GLfloat dvdy = texH * ((t + dtdy) / (q + dqdy) - t * invQ); - - /* note: instead of working with Px and Py, we will use the - * squared length instead, to avoid sqrt. - */ - GLfloat Px2 = dudx * dudx + dvdx * dvdx; - GLfloat Py2 = dudy * dudy + dvdy * dvdy; - - GLfloat Pmax2; - GLfloat Pmin2; - GLfloat e; - GLfloat lod; - - s += dsdx; - t += dtdx; - q += dqdx; - - if (Px2 < Py2) { - Pmax2 = Py2; - Pmin2 = Px2; - } - else { - Pmax2 = Px2; - Pmin2 = Py2; - } - - /* if the eccentricity of the ellipse is too big, scale up the shorter - * of the two vectors to limit the maximum amount of work per pixel - */ - e = Pmax2 / Pmin2; - if (e > maxEccentricity) { - /* GLfloat s=e / maxEccentricity; - minor[0] *= s; - minor[1] *= s; - Pmin2 *= s; */ - Pmin2 = Pmax2 / maxEccentricity; - } - - /* note: we need to have Pmin=sqrt(Pmin2) here, but we can avoid - * this since 0.5*log(x) = log(sqrt(x)) - */ - lod = 0.5 * LOG2(Pmin2); - - /* If the ellipse covers the whole image, we can - * simply return the average of the whole image. - */ - if (lod >= tObj->_MaxLevel) { - sample_2d_linear(ctx, tObj, tObj->Image[0][tObj->_MaxLevel], - texcoords[i], rgba[i]); - } - else { - /* don't bother interpolating between multiple LODs; it doesn't - * seem to be worth the extra running time. - */ - sample_2d_ewa(ctx, tObj, texcoords[i], - dudx, dvdx, dudy, dvdy, floor(lod), rgba[i]); - - /* unused: */ - (void) sample_2d_footprint; - /* - sample_2d_footprint(ctx, tObj, texcoords[i], - dudx, dvdx, dudy, dvdy, floor(lod), rgba[i]); - */ - } - } -} - - -/**********************************************************************/ -/* Texture Cube Map Sampling Functions */ -/**********************************************************************/ - -/** - * Choose one of six sides of a texture cube map given the texture - * coord (rx,ry,rz). Return pointer to corresponding array of texture - * images. - */ -static const struct gl_texture_image ** -choose_cube_face(const struct gl_texture_object *texObj, - const GLfloat texcoord[4], GLfloat newCoord[4]) -{ - /* - major axis - direction target sc tc ma - ---------- ------------------------------- --- --- --- - +rx TEXTURE_CUBE_MAP_POSITIVE_X_EXT -rz -ry rx - -rx TEXTURE_CUBE_MAP_NEGATIVE_X_EXT +rz -ry rx - +ry TEXTURE_CUBE_MAP_POSITIVE_Y_EXT +rx +rz ry - -ry TEXTURE_CUBE_MAP_NEGATIVE_Y_EXT +rx -rz ry - +rz TEXTURE_CUBE_MAP_POSITIVE_Z_EXT +rx -ry rz - -rz TEXTURE_CUBE_MAP_NEGATIVE_Z_EXT -rx -ry rz - */ - const GLfloat rx = texcoord[0]; - const GLfloat ry = texcoord[1]; - const GLfloat rz = texcoord[2]; - const GLfloat arx = FABSF(rx), ary = FABSF(ry), arz = FABSF(rz); - GLuint face; - GLfloat sc, tc, ma; - - if (arx >= ary && arx >= arz) { - if (rx >= 0.0F) { - face = FACE_POS_X; - sc = -rz; - tc = -ry; - ma = arx; - } - else { - face = FACE_NEG_X; - sc = rz; - tc = -ry; - ma = arx; - } - } - else if (ary >= arx && ary >= arz) { - if (ry >= 0.0F) { - face = FACE_POS_Y; - sc = rx; - tc = rz; - ma = ary; - } - else { - face = FACE_NEG_Y; - sc = rx; - tc = -rz; - ma = ary; - } - } - else { - if (rz > 0.0F) { - face = FACE_POS_Z; - sc = rx; - tc = -ry; - ma = arz; - } - else { - face = FACE_NEG_Z; - sc = -rx; - tc = -ry; - ma = arz; - } - } - - { - const float ima = 1.0F / ma; - newCoord[0] = ( sc * ima + 1.0F ) * 0.5F; - newCoord[1] = ( tc * ima + 1.0F ) * 0.5F; - } - - return (const struct gl_texture_image **) texObj->Image[face]; -} - - -static void -sample_nearest_cube(struct gl_context *ctx, - const struct gl_texture_object *tObj, GLuint n, - const GLfloat texcoords[][4], const GLfloat lambda[], - GLfloat rgba[][4]) -{ - GLuint i; - (void) lambda; - for (i = 0; i < n; i++) { - const struct gl_texture_image **images; - GLfloat newCoord[4]; - images = choose_cube_face(tObj, texcoords[i], newCoord); - sample_2d_nearest(ctx, tObj, images[tObj->BaseLevel], - newCoord, rgba[i]); - } -} - - -static void -sample_linear_cube(struct gl_context *ctx, - const struct gl_texture_object *tObj, GLuint n, - const GLfloat texcoords[][4], - const GLfloat lambda[], GLfloat rgba[][4]) -{ - GLuint i; - (void) lambda; - for (i = 0; i < n; i++) { - const struct gl_texture_image **images; - GLfloat newCoord[4]; - images = choose_cube_face(tObj, texcoords[i], newCoord); - sample_2d_linear(ctx, tObj, images[tObj->BaseLevel], - newCoord, rgba[i]); - } -} - - -static void -sample_cube_nearest_mipmap_nearest(struct gl_context *ctx, - const struct gl_texture_object *tObj, - GLuint n, const GLfloat texcoord[][4], - const GLfloat lambda[], GLfloat rgba[][4]) -{ - GLuint i; - ASSERT(lambda != NULL); - for (i = 0; i < n; i++) { - const struct gl_texture_image **images; - GLfloat newCoord[4]; - GLint level; - images = choose_cube_face(tObj, texcoord[i], newCoord); - - /* XXX we actually need to recompute lambda here based on the newCoords. - * But we would need the texcoords of adjacent fragments to compute that - * properly, and we don't have those here. - * For now, do an approximation: subtracting 1 from the chosen mipmap - * level seems to work in some test cases. - * The same adjustment is done in the next few functions. - */ - level = nearest_mipmap_level(tObj, lambda[i]); - level = MAX2(level - 1, 0); - - sample_2d_nearest(ctx, tObj, images[level], newCoord, rgba[i]); - } -} - - -static void -sample_cube_linear_mipmap_nearest(struct gl_context *ctx, - const struct gl_texture_object *tObj, - GLuint n, const GLfloat texcoord[][4], - const GLfloat lambda[], GLfloat rgba[][4]) -{ - GLuint i; - ASSERT(lambda != NULL); - for (i = 0; i < n; i++) { - const struct gl_texture_image **images; - GLfloat newCoord[4]; - GLint level = nearest_mipmap_level(tObj, lambda[i]); - level = MAX2(level - 1, 0); /* see comment above */ - images = choose_cube_face(tObj, texcoord[i], newCoord); - sample_2d_linear(ctx, tObj, images[level], newCoord, rgba[i]); - } -} - - -static void -sample_cube_nearest_mipmap_linear(struct gl_context *ctx, - const struct gl_texture_object *tObj, - GLuint n, const GLfloat texcoord[][4], - const GLfloat lambda[], GLfloat rgba[][4]) -{ - GLuint i; - ASSERT(lambda != NULL); - for (i = 0; i < n; i++) { - const struct gl_texture_image **images; - GLfloat newCoord[4]; - GLint level = linear_mipmap_level(tObj, lambda[i]); - level = MAX2(level - 1, 0); /* see comment above */ - images = choose_cube_face(tObj, texcoord[i], newCoord); - if (level >= tObj->_MaxLevel) { - sample_2d_nearest(ctx, tObj, images[tObj->_MaxLevel], - newCoord, rgba[i]); - } - else { - GLfloat t0[4], t1[4]; /* texels */ - const GLfloat f = FRAC(lambda[i]); - sample_2d_nearest(ctx, tObj, images[level ], newCoord, t0); - sample_2d_nearest(ctx, tObj, images[level+1], newCoord, t1); - lerp_rgba(rgba[i], f, t0, t1); - } - } -} - - -static void -sample_cube_linear_mipmap_linear(struct gl_context *ctx, - const struct gl_texture_object *tObj, - GLuint n, const GLfloat texcoord[][4], - const GLfloat lambda[], GLfloat rgba[][4]) -{ - GLuint i; - ASSERT(lambda != NULL); - for (i = 0; i < n; i++) { - const struct gl_texture_image **images; - GLfloat newCoord[4]; - GLint level = linear_mipmap_level(tObj, lambda[i]); - level = MAX2(level - 1, 0); /* see comment above */ - images = choose_cube_face(tObj, texcoord[i], newCoord); - if (level >= tObj->_MaxLevel) { - sample_2d_linear(ctx, tObj, images[tObj->_MaxLevel], - newCoord, rgba[i]); - } - else { - GLfloat t0[4], t1[4]; - const GLfloat f = FRAC(lambda[i]); - sample_2d_linear(ctx, tObj, images[level ], newCoord, t0); - sample_2d_linear(ctx, tObj, images[level+1], newCoord, t1); - lerp_rgba(rgba[i], f, t0, t1); - } - } -} - - -/** Sample cube texture, using lambda to choose between min/magnification */ -static void -sample_lambda_cube(struct gl_context *ctx, - const struct gl_texture_object *tObj, GLuint n, - const GLfloat texcoords[][4], const GLfloat lambda[], - GLfloat rgba[][4]) -{ - GLuint minStart, minEnd; /* texels with minification */ - GLuint magStart, magEnd; /* texels with magnification */ - - ASSERT(lambda != NULL); - compute_min_mag_ranges(tObj, n, lambda, - &minStart, &minEnd, &magStart, &magEnd); - - if (minStart < minEnd) { - /* do the minified texels */ - const GLuint m = minEnd - minStart; - switch (tObj->Sampler.MinFilter) { - case GL_NEAREST: - sample_nearest_cube(ctx, tObj, m, texcoords + minStart, - lambda + minStart, rgba + minStart); - break; - case GL_LINEAR: - sample_linear_cube(ctx, tObj, m, texcoords + minStart, - lambda + minStart, rgba + minStart); - break; - case GL_NEAREST_MIPMAP_NEAREST: - sample_cube_nearest_mipmap_nearest(ctx, tObj, m, - texcoords + minStart, - lambda + minStart, rgba + minStart); - break; - case GL_LINEAR_MIPMAP_NEAREST: - sample_cube_linear_mipmap_nearest(ctx, tObj, m, - texcoords + minStart, - lambda + minStart, rgba + minStart); - break; - case GL_NEAREST_MIPMAP_LINEAR: - sample_cube_nearest_mipmap_linear(ctx, tObj, m, - texcoords + minStart, - lambda + minStart, rgba + minStart); - break; - case GL_LINEAR_MIPMAP_LINEAR: - sample_cube_linear_mipmap_linear(ctx, tObj, m, - texcoords + minStart, - lambda + minStart, rgba + minStart); - break; - default: - _mesa_problem(ctx, "Bad min filter in sample_lambda_cube"); - break; - } - } - - if (magStart < magEnd) { - /* do the magnified texels */ - const GLuint m = magEnd - magStart; - switch (tObj->Sampler.MagFilter) { - case GL_NEAREST: - sample_nearest_cube(ctx, tObj, m, texcoords + magStart, - lambda + magStart, rgba + magStart); - break; - case GL_LINEAR: - sample_linear_cube(ctx, tObj, m, texcoords + magStart, - lambda + magStart, rgba + magStart); - break; - default: - _mesa_problem(ctx, "Bad mag filter in sample_lambda_cube"); - break; - } - } -} - -/** - * We use this function when a texture object is in an "incomplete" state. - * When a fragment program attempts to sample an incomplete texture we - * return black (see issue 23 in GL_ARB_fragment_program spec). - * Note: fragment programs don't observe the texture enable/disable flags. - */ -static void -null_sample_func( struct gl_context *ctx, - const struct gl_texture_object *tObj, GLuint n, - const GLfloat texcoords[][4], const GLfloat lambda[], - GLfloat rgba[][4]) -{ - GLuint i; - (void) ctx; - (void) tObj; - (void) texcoords; - (void) lambda; - for (i = 0; i < n; i++) { - rgba[i][RCOMP] = 0; - rgba[i][GCOMP] = 0; - rgba[i][BCOMP] = 0; - rgba[i][ACOMP] = 1.0; - } -} - - -/** - * Choose the texture sampling function for the given texture object. - */ -texture_sample_func -_swrast_choose_texture_sample_func( struct gl_context *ctx, - const struct gl_texture_object *t ) -{ - if (!t || !t->_Complete) { - return &null_sample_func; - } - else { - const GLboolean needLambda = - (GLboolean) (t->Sampler.MinFilter != t->Sampler.MagFilter); - - switch (t->Target) { - case GL_TEXTURE_1D: - if (needLambda) { - return &sample_lambda_1d; - } - else if (t->Sampler.MinFilter == GL_LINEAR) { - return &sample_linear_1d; - } - else { - ASSERT(t->Sampler.MinFilter == GL_NEAREST); - return &sample_nearest_1d; - } - case GL_TEXTURE_2D: - if (needLambda) { - /* Anisotropic filtering extension. Activated only if mipmaps are used */ - if (t->Sampler.MaxAnisotropy > 1.0 && - t->Sampler.MinFilter == GL_LINEAR_MIPMAP_LINEAR) { - return &sample_lambda_2d_aniso; - } - return &sample_lambda_2d; - } - else if (t->Sampler.MinFilter == GL_LINEAR) { - return &sample_linear_2d; - } - else { - /* check for a few optimized cases */ - const struct gl_texture_image *img = t->Image[0][t->BaseLevel]; - const struct swrast_texture_image *swImg = - swrast_texture_image_const(img); - texture_sample_func func; - - ASSERT(t->Sampler.MinFilter == GL_NEAREST); - func = &sample_nearest_2d; - if (t->Sampler.WrapS == GL_REPEAT && - t->Sampler.WrapT == GL_REPEAT && - swImg->_IsPowerOfTwo && - img->Border == 0) { - if (img->TexFormat == MESA_FORMAT_RGB888) - func = &opt_sample_rgb_2d; - else if (img->TexFormat == MESA_FORMAT_RGBA8888) - func = &opt_sample_rgba_2d; - } - - return func; - } - case GL_TEXTURE_CUBE_MAP: - if (needLambda) { - return &sample_lambda_cube; - } - else if (t->Sampler.MinFilter == GL_LINEAR) { - return &sample_linear_cube; - } - else { - ASSERT(t->Sampler.MinFilter == GL_NEAREST); - return &sample_nearest_cube; - } - default: - _mesa_problem(ctx, - "invalid target in _swrast_choose_texture_sample_func"); - return &null_sample_func; - } - } -} diff --git a/dll/opengl/mesa/swrast/s_texfilter.h b/dll/opengl/mesa/swrast/s_texfilter.h deleted file mode 100644 index 69f2d80003a..00000000000 --- a/dll/opengl/mesa/swrast/s_texfilter.h +++ /dev/null @@ -1,41 +0,0 @@ -/* - * Mesa 3-D graphics library - * Version: 6.5 - * - * Copyright (C) 1999-2005 Brian Paul All Rights Reserved. - * - * Permission is hereby granted, free of charge, to any person obtaining a - * copy of this software and associated documentation files (the "Software"), - * to deal in the Software without restriction, including without limitation - * the rights to use, copy, modify, merge, publish, distribute, sublicense, - * and/or sell copies of the Software, and to permit persons to whom the - * Software is furnished to do so, subject to the following conditions: - * - * The above copyright notice and this permission notice shall be included - * in all copies or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS - * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL - * BRIAN PAUL BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN - * AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN - * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. - */ - - -#ifndef S_TEXFILTER_H -#define S_TEXFILTER_H - - -#include "s_context.h" - -struct gl_context; -struct gl_texture_object; - - -extern texture_sample_func -_swrast_choose_texture_sample_func( struct gl_context *ctx, - const struct gl_texture_object *tObj ); - - -#endif diff --git a/dll/opengl/mesa/swrast/s_texture.c b/dll/opengl/mesa/swrast/s_texture.c deleted file mode 100644 index 81acbe6bb90..00000000000 --- a/dll/opengl/mesa/swrast/s_texture.c +++ /dev/null @@ -1,320 +0,0 @@ -/* - * Mesa 3-D graphics library - * - * Copyright (C) 2011 VMware, Inc. - * - * Permission is hereby granted, free of charge, to any person obtaining a - * copy of this software and associated documentation files (the "Software"), - * to deal in the Software without restriction, including without limitation - * the rights to use, copy, modify, merge, publish, distribute, sublicense, - * and/or sell copies of the Software, and to permit persons to whom the - * Software is furnished to do so, subject to the following conditions: - * - * The above copyright notice and this permission notice shall be included - * in all copies or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS - * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL - * THE AUTHORS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN - * AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN - * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. - */ - -/** - * Functions for mapping/unmapping texture images. - */ - -#include - -/** - * Allocate a new swrast_texture_image (a subclass of gl_texture_image). - * Called via ctx->Driver.NewTextureImage(). - */ -struct gl_texture_image * -_swrast_new_texture_image( struct gl_context *ctx ) -{ - (void) ctx; - return (struct gl_texture_image *) CALLOC_STRUCT(swrast_texture_image); -} - - -/** - * Free a swrast_texture_image (a subclass of gl_texture_image). - * Called via ctx->Driver.DeleteTextureImage(). - */ -void -_swrast_delete_texture_image(struct gl_context *ctx, - struct gl_texture_image *texImage) -{ - /* Nothing special for the subclass yet */ - _mesa_delete_texture_image(ctx, texImage); -} - - -/** - * Called via ctx->Driver.AllocTextureImageBuffer() - */ -GLboolean -_swrast_alloc_texture_image_buffer(struct gl_context *ctx, - struct gl_texture_image *texImage, - gl_format format, GLsizei width, - GLsizei height, GLsizei depth) -{ - struct swrast_texture_image *swImg = swrast_texture_image(texImage); - GLuint bytes = _mesa_format_image_size(format, width, height, depth); - GLuint i; - - /* This _should_ be true (revisit if these ever fail) */ - assert(texImage->Width == width); - assert(texImage->Height == height); - assert(texImage->Depth == depth); - - assert(!swImg->Buffer); - swImg->Buffer = _mesa_align_malloc(bytes, 512); - if (!swImg->Buffer) - return GL_FALSE; - - /* RowStride and ImageOffsets[] describe how to address texels in 'Data' */ - swImg->RowStride = width; - - /* Allocate the ImageOffsets array and initialize to typical values. - * We allocate the array for 1D/2D textures too in order to avoid special- - * case code in the texstore routines. - */ - swImg->ImageOffsets = (GLuint *) malloc(depth * sizeof(GLuint)); - if (!swImg->ImageOffsets) - return GL_FALSE; - - for (i = 0; i < depth; i++) { - swImg->ImageOffsets[i] = i * width * height; - } - - _swrast_init_texture_image(texImage, width, height, depth); - - return GL_TRUE; -} - - -/** - * Code that overrides ctx->Driver.AllocTextureImageBuffer may use this to - * initialize the fields of swrast_texture_image without allocating the image - * buffer or initializing ImageOffsets or RowStride. - * - * Returns GL_TRUE on success, GL_FALSE on memory allocation failure. - */ -void -_swrast_init_texture_image(struct gl_texture_image *texImage, GLsizei width, - GLsizei height, GLsizei depth) -{ - struct swrast_texture_image *swImg = swrast_texture_image(texImage); - - if ((width == 1 || _mesa_is_pow_two(texImage->Width2)) && - (height == 1 || _mesa_is_pow_two(texImage->Height2)) && - (depth == 1 || _mesa_is_pow_two(texImage->Depth2))) - swImg->_IsPowerOfTwo = GL_TRUE; - else - swImg->_IsPowerOfTwo = GL_FALSE; - - /* Compute Width/Height/DepthScale for mipmap lod computation */ - swImg->WidthScale = (GLfloat) texImage->Width; - swImg->HeightScale = (GLfloat) texImage->Height; - swImg->DepthScale = (GLfloat) texImage->Depth; -} - - -/** - * Called via ctx->Driver.FreeTextureImageBuffer() - */ -void -_swrast_free_texture_image_buffer(struct gl_context *ctx, - struct gl_texture_image *texImage) -{ - struct swrast_texture_image *swImage = swrast_texture_image(texImage); - if (swImage->Buffer) { - _mesa_align_free(swImage->Buffer); - swImage->Buffer = NULL; - } - - if (swImage->ImageOffsets) { - free(swImage->ImageOffsets); - swImage->ImageOffsets = NULL; - } -} - - -/** - * Error checking for debugging only. - */ -static void -_mesa_check_map_teximage(struct gl_texture_image *texImage, - GLuint slice, GLuint x, GLuint y, GLuint w, GLuint h) -{ - - if (texImage->TexObject->Target == GL_TEXTURE_1D) - assert(y == 0 && h == 1); - - assert(x < texImage->Width || texImage->Width == 0); - assert(y < texImage->Height || texImage->Height == 0); - assert(x + w <= texImage->Width); - assert(y + h <= texImage->Height); -} - -/** - * Map a 2D slice of a texture image into user space. - * (x,y,w,h) defines a region of interest (ROI). Reading/writing texels - * outside of the ROI is undefined. - * - * \param texImage the texture image - * \param slice the 3D image slice or array texture slice - * \param x, y, w, h region of interest - * \param mode bitmask of GL_MAP_READ_BIT, GL_MAP_WRITE_BIT - * \param mapOut returns start of mapping of region of interest - * \param rowStrideOut returns row stride (in bytes) - */ -void -_swrast_map_teximage(struct gl_context *ctx, - struct gl_texture_image *texImage, - GLuint slice, - GLuint x, GLuint y, GLuint w, GLuint h, - GLbitfield mode, - GLubyte **mapOut, - GLint *rowStrideOut) -{ - struct swrast_texture_image *swImage = swrast_texture_image(texImage); - GLubyte *map; - GLint stride, texelSize; - GLuint bw, bh; - - _mesa_check_map_teximage(texImage, slice, x, y, w, h); - - texelSize = _mesa_get_format_bytes(texImage->TexFormat); - stride = _mesa_format_row_stride(texImage->TexFormat, texImage->Width); - _mesa_get_format_block_size(texImage->TexFormat, &bw, &bh); - - assert(x % bw == 0); - assert(y % bh == 0); - - if (!swImage->Buffer) { - /* probably ran out of memory when allocating tex mem */ - *mapOut = NULL; - return; - } - - map = swImage->Buffer; - - /* apply x/y offset to map address */ - map += stride * (y / bh) + texelSize * (x / bw); - - *mapOut = map; - *rowStrideOut = stride; -} - -void -_swrast_unmap_teximage(struct gl_context *ctx, - struct gl_texture_image *texImage, - GLuint slice) -{ - /* nop */ -} - - -void -_swrast_map_texture(struct gl_context *ctx, struct gl_texture_object *texObj) -{ - const GLuint faces = texObj->Target == GL_TEXTURE_CUBE_MAP ? 6 : 1; - GLuint face, level; - - for (face = 0; face < faces; face++) { - for (level = texObj->BaseLevel; level < MAX_TEXTURE_LEVELS; level++) { - struct gl_texture_image *texImage = texObj->Image[face][level]; - if (texImage) { - struct swrast_texture_image *swImage = - swrast_texture_image(texImage); - - /* XXX we'll eventually call _swrast_map_teximage() here */ - swImage->Map = swImage->Buffer; - } - } - } -} - - -void -_swrast_unmap_texture(struct gl_context *ctx, struct gl_texture_object *texObj) -{ - const GLuint faces = texObj->Target == GL_TEXTURE_CUBE_MAP ? 6 : 1; - GLuint face, level; - - for (face = 0; face < faces; face++) { - for (level = texObj->BaseLevel; level < MAX_TEXTURE_LEVELS; level++) { - struct gl_texture_image *texImage = texObj->Image[face][level]; - if (texImage) { - struct swrast_texture_image *swImage - = swrast_texture_image(texImage); - - /* XXX we'll eventually call _swrast_unmap_teximage() here */ - swImage->Map = NULL; - } - } - } -} - - -/** - * Map all textures for reading prior to software rendering. - */ -void -_swrast_map_textures(struct gl_context *ctx) -{ - if (ctx->Texture._Enabled) { - struct gl_texture_object *texObj = ctx->Texture.Unit._Current; - - _swrast_map_texture(ctx, texObj); - } -} - - -/** - * Unmap all textures for reading prior to software rendering. - */ -void -_swrast_unmap_textures(struct gl_context *ctx) -{ - if(ctx->Texture._Enabled) { - struct gl_texture_object *texObj = ctx->Texture.Unit._Current; - - _swrast_unmap_texture(ctx, texObj); - } -} - - -/** - * Called via ctx->Driver.AllocTextureStorage() - * Just have to allocate memory for the texture images. - */ -GLboolean -_swrast_AllocTextureStorage(struct gl_context *ctx, - struct gl_texture_object *texObj, - GLsizei levels, GLsizei width, - GLsizei height, GLsizei depth) -{ - const GLint numFaces = (texObj->Target == GL_TEXTURE_CUBE_MAP) ? 6 : 1; - GLint face, level; - - for (face = 0; face < numFaces; face++) { - for (level = 0; level < levels; level++) { - struct gl_texture_image *texImage = texObj->Image[face][level]; - if (!_swrast_alloc_texture_image_buffer(ctx, texImage, - texImage->TexFormat, - texImage->Width, - texImage->Height, - texImage->Depth)) { - return GL_FALSE; - } - } - } - - return GL_TRUE; -} - diff --git a/dll/opengl/mesa/swrast/s_triangle.c b/dll/opengl/mesa/swrast/s_triangle.c deleted file mode 100644 index 0a78a3b9848..00000000000 --- a/dll/opengl/mesa/swrast/s_triangle.c +++ /dev/null @@ -1,1028 +0,0 @@ -/* - * Mesa 3-D graphics library - * Version: 7.3 - * - * Copyright (C) 1999-2007 Brian Paul All Rights Reserved. - * - * Permission is hereby granted, free of charge, to any person obtaining a - * copy of this software and associated documentation files (the "Software"), - * to deal in the Software without restriction, including without limitation - * the rights to use, copy, modify, merge, publish, distribute, sublicense, - * and/or sell copies of the Software, and to permit persons to whom the - * Software is furnished to do so, subject to the following conditions: - * - * The above copyright notice and this permission notice shall be included - * in all copies or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS - * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL - * BRIAN PAUL BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN - * AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN - * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. - */ - -/* - * When the device driver doesn't implement triangle rasterization it - * can hook in _swrast_Triangle, which eventually calls one of these - * functions to draw triangles. - */ - -#include - -/** - * Test if a triangle should be culled. Used for feedback and selection mode. - * \return GL_TRUE if the triangle is to be culled, GL_FALSE otherwise. - */ -GLboolean -_swrast_culltriangle( struct gl_context *ctx, - const SWvertex *v0, - const SWvertex *v1, - const SWvertex *v2 ) -{ - SWcontext *swrast = SWRAST_CONTEXT(ctx); - GLfloat ex = v1->attrib[FRAG_ATTRIB_WPOS][0] - v0->attrib[FRAG_ATTRIB_WPOS][0]; - GLfloat ey = v1->attrib[FRAG_ATTRIB_WPOS][1] - v0->attrib[FRAG_ATTRIB_WPOS][1]; - GLfloat fx = v2->attrib[FRAG_ATTRIB_WPOS][0] - v0->attrib[FRAG_ATTRIB_WPOS][0]; - GLfloat fy = v2->attrib[FRAG_ATTRIB_WPOS][1] - v0->attrib[FRAG_ATTRIB_WPOS][1]; - GLfloat c = ex*fy-ey*fx; - - if (c * swrast->_BackfaceSign * swrast->_BackfaceCullSign <= 0.0F) - return GL_FALSE; - - return GL_TRUE; -} - - - -/* - * Render a flat-shaded RGBA triangle. - */ -#define NAME flat_rgba_triangle -#define INTERP_Z 1 -#define SETUP_CODE \ - ASSERT(!ctx->Texture._EnabledCoord);\ - ASSERT(ctx->Light.ShadeModel==GL_FLAT); \ - span.interpMask |= SPAN_RGBA; \ - span.red = ChanToFixed(v2->color[0]); \ - span.green = ChanToFixed(v2->color[1]); \ - span.blue = ChanToFixed(v2->color[2]); \ - span.alpha = ChanToFixed(v2->color[3]); \ - span.redStep = 0; \ - span.greenStep = 0; \ - span.blueStep = 0; \ - span.alphaStep = 0; -#define RENDER_SPAN( span ) _swrast_write_rgba_span(ctx, &span); -#include "s_tritemp.h" - - - -/* - * Render a smooth-shaded RGBA triangle. - */ -#define NAME smooth_rgba_triangle -#define INTERP_Z 1 -#define INTERP_RGB 1 -#define INTERP_ALPHA 1 -#define SETUP_CODE \ - { \ - /* texturing must be off */ \ - ASSERT(!ctx->Texture._EnabledCoord); \ - ASSERT(ctx->Light.ShadeModel==GL_SMOOTH); \ - } -#define RENDER_SPAN( span ) _swrast_write_rgba_span(ctx, &span); -#include "s_tritemp.h" - - - -/* - * Render an RGB, GL_DECAL, textured triangle. - * Interpolate S,T only w/out mipmapping or perspective correction. - * - * No fog. No depth testing. - */ -#define NAME simple_textured_triangle -#define INTERP_INT_TEX 1 -#define S_SCALE twidth -#define T_SCALE theight - -#define SETUP_CODE \ - struct gl_renderbuffer *rb = ctx->DrawBuffer->_ColorDrawBuffer; \ - const struct gl_texture_object *obj = \ - ctx->Texture.Unit.CurrentTex[TEXTURE_2D_INDEX]; \ - const struct gl_texture_image *texImg = \ - obj->Image[0][obj->BaseLevel]; \ - const struct swrast_texture_image *swImg = \ - swrast_texture_image_const(texImg); \ - const GLfloat twidth = (GLfloat) texImg->Width; \ - const GLfloat theight = (GLfloat) texImg->Height; \ - const GLint twidth_log2 = texImg->WidthLog2; \ - const GLubyte *texture = (const GLubyte *) swImg->Map; \ - const GLint smask = texImg->Width - 1; \ - const GLint tmask = texImg->Height - 1; \ - ASSERT(texImg->TexFormat == MESA_FORMAT_RGB888); \ - if (!rb || !texture) { \ - return; \ - } - -#define RENDER_SPAN( span ) \ - GLuint i; \ - GLubyte rgba[MAX_WIDTH][4]; \ - span.intTex[0] -= FIXED_HALF; /* off-by-one error? */ \ - span.intTex[1] -= FIXED_HALF; \ - for (i = 0; i < span.end; i++) { \ - GLint s = FixedToInt(span.intTex[0]) & smask; \ - GLint t = FixedToInt(span.intTex[1]) & tmask; \ - GLint pos = (t << twidth_log2) + s; \ - pos = pos + pos + pos; /* multiply by 3 */ \ - rgba[i][RCOMP] = texture[pos+2]; \ - rgba[i][GCOMP] = texture[pos+1]; \ - rgba[i][BCOMP] = texture[pos+0]; \ - rgba[i][ACOMP] = 0xff; \ - span.intTex[0] += span.intTexStep[0]; \ - span.intTex[1] += span.intTexStep[1]; \ - } \ - _swrast_put_row(ctx, rb, GL_UNSIGNED_BYTE, span.end, \ - span.x, span.y, rgba, NULL); - -#include "s_tritemp.h" - - - -/* - * Render an RGB, GL_DECAL, textured triangle. - * Interpolate S,T, GL_LESS depth test, w/out mipmapping or - * perspective correction. - * Depth buffer bits must be <= sizeof(DEFAULT_SOFTWARE_DEPTH_TYPE) - * - * No fog. - */ -#define NAME simple_z_textured_triangle -#define INTERP_Z 1 -#define DEPTH_TYPE DEFAULT_SOFTWARE_DEPTH_TYPE -#define INTERP_INT_TEX 1 -#define S_SCALE twidth -#define T_SCALE theight - -#define SETUP_CODE \ - struct gl_renderbuffer *rb = ctx->DrawBuffer->_ColorDrawBuffer; \ - const struct gl_texture_object *obj = \ - ctx->Texture.Unit.CurrentTex[TEXTURE_2D_INDEX]; \ - const struct gl_texture_image *texImg = \ - obj->Image[0][obj->BaseLevel]; \ - const struct swrast_texture_image *swImg = \ - swrast_texture_image_const(texImg); \ - const GLfloat twidth = (GLfloat) texImg->Width; \ - const GLfloat theight = (GLfloat) texImg->Height; \ - const GLint twidth_log2 = texImg->WidthLog2; \ - const GLubyte *texture = (const GLubyte *) swImg->Map; \ - const GLint smask = texImg->Width - 1; \ - const GLint tmask = texImg->Height - 1; \ - ASSERT(texImg->TexFormat == MESA_FORMAT_RGB888); \ - if (!rb || !texture) { \ - return; \ - } - -#define RENDER_SPAN( span ) \ - GLuint i; \ - GLubyte rgba[MAX_WIDTH][4]; \ - span.intTex[0] -= FIXED_HALF; /* off-by-one error? */ \ - span.intTex[1] -= FIXED_HALF; \ - for (i = 0; i < span.end; i++) { \ - const GLuint z = FixedToDepth(span.z); \ - if (z < zRow[i]) { \ - GLint s = FixedToInt(span.intTex[0]) & smask; \ - GLint t = FixedToInt(span.intTex[1]) & tmask; \ - GLint pos = (t << twidth_log2) + s; \ - pos = pos + pos + pos; /* multiply by 3 */ \ - rgba[i][RCOMP] = texture[pos+2]; \ - rgba[i][GCOMP] = texture[pos+1]; \ - rgba[i][BCOMP] = texture[pos+0]; \ - rgba[i][ACOMP] = 0xff; \ - zRow[i] = z; \ - span.array->mask[i] = 1; \ - } \ - else { \ - span.array->mask[i] = 0; \ - } \ - span.intTex[0] += span.intTexStep[0]; \ - span.intTex[1] += span.intTexStep[1]; \ - span.z += span.zStep; \ - } \ - _swrast_put_row(ctx, rb, GL_UNSIGNED_BYTE, \ - span.end, span.x, span.y, rgba, span.array->mask); - -#include "s_tritemp.h" - - -#if CHAN_TYPE != GL_FLOAT - -struct affine_info -{ - GLenum filter; - GLenum format; - GLenum envmode; - GLint smask, tmask; - GLint twidth_log2; - const GLchan *texture; - GLfixed er, eg, eb, ea; - GLint tbytesline, tsize; -}; - - -static inline GLint -ilerp(GLint t, GLint a, GLint b) -{ - return a + ((t * (b - a)) >> FIXED_SHIFT); -} - -static inline GLint -ilerp_2d(GLint ia, GLint ib, GLint v00, GLint v10, GLint v01, GLint v11) -{ - const GLint temp0 = ilerp(ia, v00, v10); - const GLint temp1 = ilerp(ia, v01, v11); - return ilerp(ib, temp0, temp1); -} - - -/* This function can handle GL_NEAREST or GL_LINEAR sampling of 2D RGB or RGBA - * textures with GL_REPLACE, GL_MODULATE, GL_BLEND, GL_DECAL or GL_ADD - * texture env modes. - */ -static inline void -affine_span(struct gl_context *ctx, SWspan *span, - struct affine_info *info) -{ - GLchan sample[4]; /* the filtered texture sample */ - const GLboolean texEnableSave = ctx->Texture._EnabledCoord; - - /* Instead of defining a function for each mode, a test is done - * between the outer and inner loops. This is to reduce code size - * and complexity. Observe that an optimizing compiler kills - * unused variables (for instance tf,sf,ti,si in case of GL_NEAREST). - */ - -#define NEAREST_RGB \ - sample[RCOMP] = tex00[2]; \ - sample[GCOMP] = tex00[1]; \ - sample[BCOMP] = tex00[0]; \ - sample[ACOMP] = CHAN_MAX; - -#define LINEAR_RGB \ - sample[RCOMP] = ilerp_2d(sf, tf, tex00[2], tex01[2], tex10[2], tex11[2]);\ - sample[GCOMP] = ilerp_2d(sf, tf, tex00[1], tex01[1], tex10[1], tex11[1]);\ - sample[BCOMP] = ilerp_2d(sf, tf, tex00[0], tex01[0], tex10[0], tex11[0]);\ - sample[ACOMP] = CHAN_MAX; - -#define NEAREST_RGBA \ - sample[RCOMP] = tex00[3]; \ - sample[GCOMP] = tex00[2]; \ - sample[BCOMP] = tex00[1]; \ - sample[ACOMP] = tex00[0]; - -#define LINEAR_RGBA \ - sample[RCOMP] = ilerp_2d(sf, tf, tex00[3], tex01[3], tex10[3], tex11[3]);\ - sample[GCOMP] = ilerp_2d(sf, tf, tex00[2], tex01[2], tex10[2], tex11[2]);\ - sample[BCOMP] = ilerp_2d(sf, tf, tex00[1], tex01[1], tex10[1], tex11[1]);\ - sample[ACOMP] = ilerp_2d(sf, tf, tex00[0], tex01[0], tex10[0], tex11[0]) - -#define MODULATE \ - dest[RCOMP] = span->red * (sample[RCOMP] + 1u) >> (FIXED_SHIFT + 8); \ - dest[GCOMP] = span->green * (sample[GCOMP] + 1u) >> (FIXED_SHIFT + 8); \ - dest[BCOMP] = span->blue * (sample[BCOMP] + 1u) >> (FIXED_SHIFT + 8); \ - dest[ACOMP] = span->alpha * (sample[ACOMP] + 1u) >> (FIXED_SHIFT + 8) - -#define DECAL \ - dest[RCOMP] = ((CHAN_MAX - sample[ACOMP]) * span->red + \ - ((sample[ACOMP] + 1) * sample[RCOMP] << FIXED_SHIFT)) \ - >> (FIXED_SHIFT + 8); \ - dest[GCOMP] = ((CHAN_MAX - sample[ACOMP]) * span->green + \ - ((sample[ACOMP] + 1) * sample[GCOMP] << FIXED_SHIFT)) \ - >> (FIXED_SHIFT + 8); \ - dest[BCOMP] = ((CHAN_MAX - sample[ACOMP]) * span->blue + \ - ((sample[ACOMP] + 1) * sample[BCOMP] << FIXED_SHIFT)) \ - >> (FIXED_SHIFT + 8); \ - dest[ACOMP] = FixedToInt(span->alpha) - -#define BLEND \ - dest[RCOMP] = ((CHAN_MAX - sample[RCOMP]) * span->red \ - + (sample[RCOMP] + 1) * info->er) >> (FIXED_SHIFT + 8); \ - dest[GCOMP] = ((CHAN_MAX - sample[GCOMP]) * span->green \ - + (sample[GCOMP] + 1) * info->eg) >> (FIXED_SHIFT + 8); \ - dest[BCOMP] = ((CHAN_MAX - sample[BCOMP]) * span->blue \ - + (sample[BCOMP] + 1) * info->eb) >> (FIXED_SHIFT + 8); \ - dest[ACOMP] = span->alpha * (sample[ACOMP] + 1) >> (FIXED_SHIFT + 8) - -#define REPLACE COPY_CHAN4(dest, sample) - -#define ADD \ - { \ - GLint rSum = FixedToInt(span->red) + (GLint) sample[RCOMP]; \ - GLint gSum = FixedToInt(span->green) + (GLint) sample[GCOMP]; \ - GLint bSum = FixedToInt(span->blue) + (GLint) sample[BCOMP]; \ - dest[RCOMP] = MIN2(rSum, CHAN_MAX); \ - dest[GCOMP] = MIN2(gSum, CHAN_MAX); \ - dest[BCOMP] = MIN2(bSum, CHAN_MAX); \ - dest[ACOMP] = span->alpha * (sample[ACOMP] + 1) >> (FIXED_SHIFT + 8); \ - } - -/* shortcuts */ - -#define NEAREST_RGB_REPLACE \ - NEAREST_RGB; \ - dest[0] = sample[0]; \ - dest[1] = sample[1]; \ - dest[2] = sample[2]; \ - dest[3] = FixedToInt(span->alpha); - -#define NEAREST_RGBA_REPLACE \ - dest[RCOMP] = tex00[3]; \ - dest[GCOMP] = tex00[2]; \ - dest[BCOMP] = tex00[1]; \ - dest[ACOMP] = tex00[0] - -#define SPAN_NEAREST(DO_TEX, COMPS) \ - for (i = 0; i < span->end; i++) { \ - /* Isn't it necessary to use FixedFloor below?? */ \ - GLint s = FixedToInt(span->intTex[0]) & info->smask; \ - GLint t = FixedToInt(span->intTex[1]) & info->tmask; \ - GLint pos = (t << info->twidth_log2) + s; \ - const GLchan *tex00 = info->texture + COMPS * pos; \ - DO_TEX; \ - span->red += span->redStep; \ - span->green += span->greenStep; \ - span->blue += span->blueStep; \ - span->alpha += span->alphaStep; \ - span->intTex[0] += span->intTexStep[0]; \ - span->intTex[1] += span->intTexStep[1]; \ - dest += 4; \ - } - -#define SPAN_LINEAR(DO_TEX, COMPS) \ - for (i = 0; i < span->end; i++) { \ - /* Isn't it necessary to use FixedFloor below?? */ \ - const GLint s = FixedToInt(span->intTex[0]) & info->smask; \ - const GLint t = FixedToInt(span->intTex[1]) & info->tmask; \ - const GLfixed sf = span->intTex[0] & FIXED_FRAC_MASK; \ - const GLfixed tf = span->intTex[1] & FIXED_FRAC_MASK; \ - const GLint pos = (t << info->twidth_log2) + s; \ - const GLchan *tex00 = info->texture + COMPS * pos; \ - const GLchan *tex10 = tex00 + info->tbytesline; \ - const GLchan *tex01 = tex00 + COMPS; \ - const GLchan *tex11 = tex10 + COMPS; \ - if (t == info->tmask) { \ - tex10 -= info->tsize; \ - tex11 -= info->tsize; \ - } \ - if (s == info->smask) { \ - tex01 -= info->tbytesline; \ - tex11 -= info->tbytesline; \ - } \ - DO_TEX; \ - span->red += span->redStep; \ - span->green += span->greenStep; \ - span->blue += span->blueStep; \ - span->alpha += span->alphaStep; \ - span->intTex[0] += span->intTexStep[0]; \ - span->intTex[1] += span->intTexStep[1]; \ - dest += 4; \ - } - - - GLuint i; - GLchan *dest = span->array->rgba[0]; - - /* Disable tex units so they're not re-applied in swrast_write_rgba_span */ - ctx->Texture._EnabledCoord = GL_FALSE; - - span->intTex[0] -= FIXED_HALF; - span->intTex[1] -= FIXED_HALF; - switch (info->filter) { - case GL_NEAREST: - switch (info->format) { - case MESA_FORMAT_RGB888: - switch (info->envmode) { - case GL_MODULATE: - SPAN_NEAREST(NEAREST_RGB;MODULATE,3); - break; - case GL_DECAL: - case GL_REPLACE: - SPAN_NEAREST(NEAREST_RGB_REPLACE,3); - break; - case GL_BLEND: - SPAN_NEAREST(NEAREST_RGB;BLEND,3); - break; - case GL_ADD: - SPAN_NEAREST(NEAREST_RGB;ADD,3); - break; - default: - _mesa_problem(ctx, "bad tex env mode in SPAN_LINEAR"); - return; - } - break; - case MESA_FORMAT_RGBA8888: - switch(info->envmode) { - case GL_MODULATE: - SPAN_NEAREST(NEAREST_RGBA;MODULATE,4); - break; - case GL_DECAL: - SPAN_NEAREST(NEAREST_RGBA;DECAL,4); - break; - case GL_BLEND: - SPAN_NEAREST(NEAREST_RGBA;BLEND,4); - break; - case GL_ADD: - SPAN_NEAREST(NEAREST_RGBA;ADD,4); - break; - case GL_REPLACE: - SPAN_NEAREST(NEAREST_RGBA_REPLACE,4); - break; - default: - _mesa_problem(ctx, "bad tex env mode (2) in SPAN_LINEAR"); - return; - } - break; - } - break; - - case GL_LINEAR: - span->intTex[0] -= FIXED_HALF; - span->intTex[1] -= FIXED_HALF; - switch (info->format) { - case MESA_FORMAT_RGB888: - switch (info->envmode) { - case GL_MODULATE: - SPAN_LINEAR(LINEAR_RGB;MODULATE,3); - break; - case GL_DECAL: - case GL_REPLACE: - SPAN_LINEAR(LINEAR_RGB;REPLACE,3); - break; - case GL_BLEND: - SPAN_LINEAR(LINEAR_RGB;BLEND,3); - break; - case GL_ADD: - SPAN_LINEAR(LINEAR_RGB;ADD,3); - break; - default: - _mesa_problem(ctx, "bad tex env mode (3) in SPAN_LINEAR"); - return; - } - break; - case MESA_FORMAT_RGBA8888: - switch (info->envmode) { - case GL_MODULATE: - SPAN_LINEAR(LINEAR_RGBA;MODULATE,4); - break; - case GL_DECAL: - SPAN_LINEAR(LINEAR_RGBA;DECAL,4); - break; - case GL_BLEND: - SPAN_LINEAR(LINEAR_RGBA;BLEND,4); - break; - case GL_ADD: - SPAN_LINEAR(LINEAR_RGBA;ADD,4); - break; - case GL_REPLACE: - SPAN_LINEAR(LINEAR_RGBA;REPLACE,4); - break; - default: - _mesa_problem(ctx, "bad tex env mode (4) in SPAN_LINEAR"); - return; - } - break; - } - break; - } - span->interpMask &= ~SPAN_RGBA; - ASSERT(span->arrayMask & SPAN_RGBA); - - _swrast_write_rgba_span(ctx, span); - - /* re-enable texture units */ - ctx->Texture._EnabledCoord = texEnableSave; - -#undef SPAN_NEAREST -#undef SPAN_LINEAR -} - - - -/* - * Render an RGB/RGBA textured triangle without perspective correction. - */ -#define NAME affine_textured_triangle -#define INTERP_Z 1 -#define INTERP_RGB 1 -#define INTERP_ALPHA 1 -#define INTERP_INT_TEX 1 -#define S_SCALE twidth -#define T_SCALE theight - -#define SETUP_CODE \ - struct affine_info info; \ - struct gl_texture_unit *unit = &ctx->Texture.Unit; \ - const struct gl_texture_object *obj = \ - ctx->Texture.Unit.CurrentTex[TEXTURE_2D_INDEX]; \ - const struct gl_texture_image *texImg = \ - obj->Image[0][obj->BaseLevel]; \ - const struct swrast_texture_image *swImg = \ - swrast_texture_image_const(texImg); \ - const GLfloat twidth = (GLfloat) texImg->Width; \ - const GLfloat theight = (GLfloat) texImg->Height; \ - info.texture = (const GLchan *) swImg->Map; \ - info.twidth_log2 = texImg->WidthLog2; \ - info.smask = texImg->Width - 1; \ - info.tmask = texImg->Height - 1; \ - info.format = texImg->TexFormat; \ - info.filter = obj->Sampler.MinFilter; \ - info.envmode = unit->EnvMode; \ - info.er = 0; \ - info.eg = 0; \ - info.eb = 0; \ - span.arrayMask |= SPAN_RGBA; \ - \ - if (info.envmode == GL_BLEND) { \ - /* potential off-by-one error here? (1.0f -> 2048 -> 0) */ \ - info.er = FloatToFixed(unit->EnvColor[RCOMP] * CHAN_MAXF); \ - info.eg = FloatToFixed(unit->EnvColor[GCOMP] * CHAN_MAXF); \ - info.eb = FloatToFixed(unit->EnvColor[BCOMP] * CHAN_MAXF); \ - info.ea = FloatToFixed(unit->EnvColor[ACOMP] * CHAN_MAXF); \ - } \ - if (!info.texture) { \ - /* this shouldn't happen */ \ - return; \ - } \ - \ - switch (info.format) { \ - case MESA_FORMAT_RGB888: \ - info.tbytesline = texImg->Width * 3; \ - break; \ - case MESA_FORMAT_RGBA8888: \ - info.tbytesline = texImg->Width * 4; \ - break; \ - default: \ - _mesa_problem(NULL, "Bad texture format in affine_texture_triangle");\ - return; \ - } \ - info.tsize = texImg->Height * info.tbytesline; - -#define RENDER_SPAN( span ) affine_span(ctx, &span, &info); - -#include "s_tritemp.h" - - - -struct persp_info -{ - GLenum filter; - GLenum format; - GLenum envmode; - GLint smask, tmask; - GLint twidth_log2; - const GLchan *texture; - GLfixed er, eg, eb, ea; /* texture env color */ - GLint tbytesline, tsize; -}; - - -static inline void -fast_persp_span(struct gl_context *ctx, SWspan *span, - struct persp_info *info) -{ - GLchan sample[4]; /* the filtered texture sample */ - - /* Instead of defining a function for each mode, a test is done - * between the outer and inner loops. This is to reduce code size - * and complexity. Observe that an optimizing compiler kills - * unused variables (for instance tf,sf,ti,si in case of GL_NEAREST). - */ -#define SPAN_NEAREST(DO_TEX,COMP) \ - for (i = 0; i < span->end; i++) { \ - GLdouble invQ = tex_coord[2] ? \ - (1.0 / tex_coord[2]) : 1.0; \ - GLfloat s_tmp = (GLfloat) (tex_coord[0] * invQ); \ - GLfloat t_tmp = (GLfloat) (tex_coord[1] * invQ); \ - GLint s = IFLOOR(s_tmp) & info->smask; \ - GLint t = IFLOOR(t_tmp) & info->tmask; \ - GLint pos = (t << info->twidth_log2) + s; \ - const GLchan *tex00 = info->texture + COMP * pos; \ - DO_TEX; \ - span->red += span->redStep; \ - span->green += span->greenStep; \ - span->blue += span->blueStep; \ - span->alpha += span->alphaStep; \ - tex_coord[0] += tex_step[0]; \ - tex_coord[1] += tex_step[1]; \ - tex_coord[2] += tex_step[2]; \ - dest += 4; \ - } - -#define SPAN_LINEAR(DO_TEX,COMP) \ - for (i = 0; i < span->end; i++) { \ - GLdouble invQ = tex_coord[2] ? \ - (1.0 / tex_coord[2]) : 1.0; \ - const GLfloat s_tmp = (GLfloat) (tex_coord[0] * invQ); \ - const GLfloat t_tmp = (GLfloat) (tex_coord[1] * invQ); \ - const GLfixed s_fix = FloatToFixed(s_tmp) - FIXED_HALF; \ - const GLfixed t_fix = FloatToFixed(t_tmp) - FIXED_HALF; \ - const GLint s = FixedToInt(FixedFloor(s_fix)) & info->smask; \ - const GLint t = FixedToInt(FixedFloor(t_fix)) & info->tmask; \ - const GLfixed sf = s_fix & FIXED_FRAC_MASK; \ - const GLfixed tf = t_fix & FIXED_FRAC_MASK; \ - const GLint pos = (t << info->twidth_log2) + s; \ - const GLchan *tex00 = info->texture + COMP * pos; \ - const GLchan *tex10 = tex00 + info->tbytesline; \ - const GLchan *tex01 = tex00 + COMP; \ - const GLchan *tex11 = tex10 + COMP; \ - if (t == info->tmask) { \ - tex10 -= info->tsize; \ - tex11 -= info->tsize; \ - } \ - if (s == info->smask) { \ - tex01 -= info->tbytesline; \ - tex11 -= info->tbytesline; \ - } \ - DO_TEX; \ - span->red += span->redStep; \ - span->green += span->greenStep; \ - span->blue += span->blueStep; \ - span->alpha += span->alphaStep; \ - tex_coord[0] += tex_step[0]; \ - tex_coord[1] += tex_step[1]; \ - tex_coord[2] += tex_step[2]; \ - dest += 4; \ - } - - GLuint i; - GLfloat tex_coord[3], tex_step[3]; - GLchan *dest = span->array->rgba[0]; - - const GLboolean texEnableSave = ctx->Texture._EnabledCoord; - ctx->Texture._EnabledCoord = GL_FALSE; - - tex_coord[0] = span->attrStart[FRAG_ATTRIB_TEX][0] * (info->smask + 1); - tex_step[0] = span->attrStepX[FRAG_ATTRIB_TEX][0] * (info->smask + 1); - tex_coord[1] = span->attrStart[FRAG_ATTRIB_TEX][1] * (info->tmask + 1); - tex_step[1] = span->attrStepX[FRAG_ATTRIB_TEX][1] * (info->tmask + 1); - /* span->attrStart[FRAG_ATTRIB_TEX0][2] only if 3D-texturing, here only 2D */ - tex_coord[2] = span->attrStart[FRAG_ATTRIB_TEX][3]; - tex_step[2] = span->attrStepX[FRAG_ATTRIB_TEX][3]; - - switch (info->filter) { - case GL_NEAREST: - switch (info->format) { - case MESA_FORMAT_RGB888: - switch (info->envmode) { - case GL_MODULATE: - SPAN_NEAREST(NEAREST_RGB;MODULATE,3); - break; - case GL_DECAL: - case GL_REPLACE: - SPAN_NEAREST(NEAREST_RGB_REPLACE,3); - break; - case GL_BLEND: - SPAN_NEAREST(NEAREST_RGB;BLEND,3); - break; - case GL_ADD: - SPAN_NEAREST(NEAREST_RGB;ADD,3); - break; - default: - _mesa_problem(ctx, "bad tex env mode (5) in SPAN_LINEAR"); - return; - } - break; - case MESA_FORMAT_RGBA8888: - switch(info->envmode) { - case GL_MODULATE: - SPAN_NEAREST(NEAREST_RGBA;MODULATE,4); - break; - case GL_DECAL: - SPAN_NEAREST(NEAREST_RGBA;DECAL,4); - break; - case GL_BLEND: - SPAN_NEAREST(NEAREST_RGBA;BLEND,4); - break; - case GL_ADD: - SPAN_NEAREST(NEAREST_RGBA;ADD,4); - break; - case GL_REPLACE: - SPAN_NEAREST(NEAREST_RGBA_REPLACE,4); - break; - default: - _mesa_problem(ctx, "bad tex env mode (6) in SPAN_LINEAR"); - return; - } - break; - } - break; - - case GL_LINEAR: - switch (info->format) { - case MESA_FORMAT_RGB888: - switch (info->envmode) { - case GL_MODULATE: - SPAN_LINEAR(LINEAR_RGB;MODULATE,3); - break; - case GL_DECAL: - case GL_REPLACE: - SPAN_LINEAR(LINEAR_RGB;REPLACE,3); - break; - case GL_BLEND: - SPAN_LINEAR(LINEAR_RGB;BLEND,3); - break; - case GL_ADD: - SPAN_LINEAR(LINEAR_RGB;ADD,3); - break; - default: - _mesa_problem(ctx, "bad tex env mode (7) in SPAN_LINEAR"); - return; - } - break; - case MESA_FORMAT_RGBA8888: - switch (info->envmode) { - case GL_MODULATE: - SPAN_LINEAR(LINEAR_RGBA;MODULATE,4); - break; - case GL_DECAL: - SPAN_LINEAR(LINEAR_RGBA;DECAL,4); - break; - case GL_BLEND: - SPAN_LINEAR(LINEAR_RGBA;BLEND,4); - break; - case GL_ADD: - SPAN_LINEAR(LINEAR_RGBA;ADD,4); - break; - case GL_REPLACE: - SPAN_LINEAR(LINEAR_RGBA;REPLACE,4); - break; - default: - _mesa_problem(ctx, "bad tex env mode (8) in SPAN_LINEAR"); - return; - } - break; - } - break; - } - - ASSERT(span->arrayMask & SPAN_RGBA); - _swrast_write_rgba_span(ctx, span); - -#undef SPAN_NEAREST -#undef SPAN_LINEAR - - /* restore state */ - ctx->Texture._EnabledCoord = texEnableSave; -} - - -/* - * Render an perspective corrected RGB/RGBA textured triangle. - * The Q (aka V in Mesa) coordinate must be zero such that the divide - * by interpolated Q/W comes out right. - * - */ -#define NAME persp_textured_triangle -#define INTERP_Z 1 -#define INTERP_RGB 1 -#define INTERP_ALPHA 1 -#define INTERP_ATTRIBS 1 - -#define SETUP_CODE \ - struct persp_info info; \ - const struct gl_texture_unit *unit = &ctx->Texture.Unit; \ - const struct gl_texture_object *obj = \ - ctx->Texture.Unit.CurrentTex[TEXTURE_2D_INDEX]; \ - const struct gl_texture_image *texImg = \ - obj->Image[0][obj->BaseLevel]; \ - const struct swrast_texture_image *swImg = \ - swrast_texture_image_const(texImg); \ - info.texture = (const GLchan *) swImg->Map; \ - info.twidth_log2 = texImg->WidthLog2; \ - info.smask = texImg->Width - 1; \ - info.tmask = texImg->Height - 1; \ - info.format = texImg->TexFormat; \ - info.filter = obj->Sampler.MinFilter; \ - info.envmode = unit->EnvMode; \ - info.er = 0; \ - info.eg = 0; \ - info.eb = 0; \ - \ - if (info.envmode == GL_BLEND) { \ - /* potential off-by-one error here? (1.0f -> 2048 -> 0) */ \ - info.er = FloatToFixed(unit->EnvColor[RCOMP] * CHAN_MAXF); \ - info.eg = FloatToFixed(unit->EnvColor[GCOMP] * CHAN_MAXF); \ - info.eb = FloatToFixed(unit->EnvColor[BCOMP] * CHAN_MAXF); \ - info.ea = FloatToFixed(unit->EnvColor[ACOMP] * CHAN_MAXF); \ - } \ - if (!info.texture) { \ - /* this shouldn't happen */ \ - return; \ - } \ - \ - switch (info.format) { \ - case MESA_FORMAT_RGB888: \ - info.tbytesline = texImg->Width * 3; \ - break; \ - case MESA_FORMAT_RGBA8888: \ - info.tbytesline = texImg->Width * 4; \ - break; \ - default: \ - _mesa_problem(NULL, "Bad texture format in persp_textured_triangle");\ - return; \ - } \ - info.tsize = texImg->Height * info.tbytesline; - -#define RENDER_SPAN( span ) \ - span.interpMask &= ~SPAN_RGBA; \ - span.arrayMask |= SPAN_RGBA; \ - fast_persp_span(ctx, &span, &info); - -#include "s_tritemp.h" - -#endif /*CHAN_TYPE != GL_FLOAT*/ - - - -/* - * Render an RGBA triangle with arbitrary attributes. - */ -#define NAME general_triangle -#define INTERP_Z 1 -#define INTERP_RGB 1 -#define INTERP_ALPHA 1 -#define INTERP_ATTRIBS 1 -#define RENDER_SPAN( span ) _swrast_write_rgba_span(ctx, &span); -#include "s_tritemp.h" - - - -static void -nodraw_triangle( struct gl_context *ctx, - const SWvertex *v0, - const SWvertex *v1, - const SWvertex *v2 ) -{ - (void) (ctx && v0 && v1 && v2); -} - - - -#ifdef DEBUG - -/* record the current triangle function name */ -const char *_mesa_triFuncName = NULL; - -#define USE(triFunc) \ -do { \ - _mesa_triFuncName = #triFunc; \ - /*printf("%s\n", _mesa_triFuncName);*/ \ - swrast->Triangle = triFunc; \ -} while (0) - -#else - -#define USE(triFunc) swrast->Triangle = triFunc; - -#endif - - - - -/* - * Determine which triangle rendering function to use given the current - * rendering context. - * - * Please update the summary flag _SWRAST_NEW_TRIANGLE if you add or - * remove tests to this code. - */ -void -_swrast_choose_triangle( struct gl_context *ctx ) -{ - SWcontext *swrast = SWRAST_CONTEXT(ctx); - - if (ctx->Polygon.CullFlag && - ctx->Polygon.CullFaceMode == GL_FRONT_AND_BACK) { - USE(nodraw_triangle); - return; - } - - if (ctx->RenderMode==GL_RENDER) { - - if (ctx->Polygon.SmoothFlag) { - _swrast_set_aa_triangle_function(ctx); - ASSERT(swrast->Triangle); - return; - } - - /* - * XXX should examine swrast->_ActiveAttribMask to determine what - * needs to be interpolated. - */ - if (ctx->Texture._EnabledCoord || - swrast->_FogEnabled) { - /* Ugh, we do a _lot_ of tests to pick the best textured tri func */ - const struct gl_texture_object *texObj2D; - const struct gl_texture_image *texImg; - const struct swrast_texture_image *swImg; - GLenum minFilter, magFilter, envMode; - gl_format format; - texObj2D = ctx->Texture.Unit.CurrentTex[TEXTURE_2D_INDEX]; - - texImg = texObj2D ? texObj2D->Image[0][texObj2D->BaseLevel] : NULL; - swImg = swrast_texture_image_const(texImg); - - format = texImg ? texImg->TexFormat : MESA_FORMAT_NONE; - minFilter = texObj2D ? texObj2D->Sampler.MinFilter : GL_NONE; - magFilter = texObj2D ? texObj2D->Sampler.MagFilter : GL_NONE; - envMode = ctx->Texture.Unit.EnvMode; - - /* First see if we can use an optimized 2-D texture function */ - if (ctx->Texture._EnabledCoord - && ctx->Texture._Enabled - && ctx->Texture.Unit._ReallyEnabled == TEXTURE_2D_BIT - && texObj2D->Sampler.WrapS == GL_REPEAT - && texObj2D->Sampler.WrapT == GL_REPEAT - && swImg->_IsPowerOfTwo - && texImg->Border == 0 - && texImg->Width == swImg->RowStride - && (format == MESA_FORMAT_RGB888 || format == MESA_FORMAT_RGBA8888) - && minFilter == magFilter - && !swrast->_FogEnabled - && ctx->Texture.Unit.EnvMode != GL_COMBINE_EXT - && ctx->Texture.Unit.EnvMode != GL_COMBINE4_NV) { - if (ctx->Hint.PerspectiveCorrection==GL_FASTEST) { - if (minFilter == GL_NEAREST - && format == MESA_FORMAT_RGB888 - && (envMode == GL_REPLACE || envMode == GL_DECAL) - && ((swrast->_RasterMask == (DEPTH_BIT | TEXTURE_BIT) - && ctx->Depth.Func == GL_LESS - && ctx->Depth.Mask == GL_TRUE) - || swrast->_RasterMask == TEXTURE_BIT) - && ctx->Polygon.StippleFlag == GL_FALSE - && ctx->DrawBuffer->Visual.depthBits <= 16) { - if (swrast->_RasterMask == (DEPTH_BIT | TEXTURE_BIT)) { - USE(simple_z_textured_triangle); - } - else { - USE(simple_textured_triangle); - } - } - else { -#if CHAN_BITS != 8 - USE(general_triangle); -#else - if (format == MESA_FORMAT_RGBA8888 && !_mesa_little_endian()) { - /* We only handle RGBA8888 correctly on little endian - * in the optimized code above. - */ - USE(general_triangle); - } - else { - USE(affine_textured_triangle); - } -#endif - } - } - else { -#if CHAN_BITS != 8 - USE(general_triangle); -#else - USE(persp_textured_triangle); -#endif - } - } - else { - /* general case textured triangles */ - USE(general_triangle); - } - } - else { - ASSERT(!swrast->_FogEnabled); - ASSERT(!_mesa_need_secondary_color(ctx)); - if (ctx->Light.ShadeModel==GL_SMOOTH) { - /* smooth shaded, no texturing, stippled or some raster ops */ -#if CHAN_BITS != 8 - USE(general_triangle); -#else - USE(smooth_rgba_triangle); -#endif - } - else { - /* flat shaded, no texturing, stippled or some raster ops */ -#if CHAN_BITS != 8 - USE(general_triangle); -#else - USE(flat_rgba_triangle); -#endif - } - } - } - else if (ctx->RenderMode==GL_FEEDBACK) { - USE(_swrast_feedback_triangle); - } - else { - /* GL_SELECT mode */ - USE(_swrast_select_triangle); - } -} diff --git a/dll/opengl/mesa/swrast/s_triangle.h b/dll/opengl/mesa/swrast/s_triangle.h deleted file mode 100644 index 46e23d42083..00000000000 --- a/dll/opengl/mesa/swrast/s_triangle.h +++ /dev/null @@ -1,50 +0,0 @@ - -/* - * Mesa 3-D graphics library - * Version: 5.1 - * - * Copyright (C) 1999-2003 Brian Paul All Rights Reserved. - * - * Permission is hereby granted, free of charge, to any person obtaining a - * copy of this software and associated documentation files (the "Software"), - * to deal in the Software without restriction, including without limitation - * the rights to use, copy, modify, merge, publish, distribute, sublicense, - * and/or sell copies of the Software, and to permit persons to whom the - * Software is furnished to do so, subject to the following conditions: - * - * The above copyright notice and this permission notice shall be included - * in all copies or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS - * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL - * BRIAN PAUL BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN - * AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN - * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. - */ - - -#ifndef S_TRIANGLES_H -#define S_TRIANGLES_H - - -#include "swrast.h" - - -extern GLboolean -_swrast_culltriangle( struct gl_context *ctx, - const SWvertex *v0, - const SWvertex *v1, - const SWvertex *v2); - -extern void -_swrast_choose_triangle( struct gl_context *ctx ); - -extern void -_swrast_add_spec_terms_triangle( struct gl_context *ctx, - const SWvertex *v0, - const SWvertex *v1, - const SWvertex *v2 ); - - -#endif diff --git a/dll/opengl/mesa/swrast/s_tritemp.h b/dll/opengl/mesa/swrast/s_tritemp.h deleted file mode 100644 index c6ae5fc3586..00000000000 --- a/dll/opengl/mesa/swrast/s_tritemp.h +++ /dev/null @@ -1,926 +0,0 @@ -/* - * Mesa 3-D graphics library - * Version: 7.0 - * - * Copyright (C) 1999-2007 Brian Paul All Rights Reserved. - * - * Permission is hereby granted, free of charge, to any person obtaining a - * copy of this software and associated documentation files (the "Software"), - * to deal in the Software without restriction, including without limitation - * the rights to use, copy, modify, merge, publish, distribute, sublicense, - * and/or sell copies of the Software, and to permit persons to whom the - * Software is furnished to do so, subject to the following conditions: - * - * The above copyright notice and this permission notice shall be included - * in all copies or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS - * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL - * BRIAN PAUL BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN - * AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN - * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. - */ - -/* - * Triangle Rasterizer Template - * - * This file is #include'd to generate custom triangle rasterizers. - * - * The following macros may be defined to indicate what auxillary information - * must be interpolated across the triangle: - * INTERP_Z - if defined, interpolate integer Z values - * INTERP_RGB - if defined, interpolate integer RGB values - * INTERP_ALPHA - if defined, interpolate integer Alpha values - * INTERP_INT_TEX - if defined, interpolate integer ST texcoords - * (fast, simple 2-D texture mapping, without - * perspective correction) - * INTERP_ATTRIBS - if defined, interpolate arbitrary attribs (texcoords, - * varying vars, etc) This also causes W to be - * computed for perspective correction). - * - * When one can directly address pixels in the color buffer the following - * macros can be defined and used to compute pixel addresses during - * rasterization (see pRow): - * PIXEL_TYPE - the datatype of a pixel (GLubyte, GLushort, GLuint) - * BYTES_PER_ROW - number of bytes per row in the color buffer - * PIXEL_ADDRESS(X,Y) - returns the address of pixel at (X,Y) where - * Y==0 at bottom of screen and increases upward. - * - * Similarly, for direct depth buffer access, this type is used for depth - * buffer addressing (see zRow): - * DEPTH_TYPE - either GLushort or GLuint - * - * Optionally, one may provide one-time setup code per triangle: - * SETUP_CODE - code which is to be executed once per triangle - * - * The following macro MUST be defined: - * RENDER_SPAN(span) - code to write a span of pixels. - * - * This code was designed for the origin to be in the lower-left corner. - * - * Inspired by triangle rasterizer code written by Allen Akin. Thanks Allen! - * - * - * Some notes on rasterization accuracy: - * - * This code uses fixed point arithmetic (the GLfixed type) to iterate - * over the triangle edges and interpolate ancillary data (such as Z, - * color, secondary color, etc). The number of fractional bits in - * GLfixed and the value of SUB_PIXEL_BITS has a direct bearing on the - * accuracy of rasterization. - * - * If SUB_PIXEL_BITS=4 then we'll snap the vertices to the nearest - * 1/16 of a pixel. If we're walking up a long, nearly vertical edge - * (dx=1/16, dy=1024) we'll need 4 + 10 = 14 fractional bits in - * GLfixed to walk the edge without error. If the maximum viewport - * height is 4K pixels, then we'll need 4 + 12 = 16 fractional bits. - * - * Historically, Mesa has used 11 fractional bits in GLfixed, snaps - * vertices to 1/16 pixel and allowed a maximum viewport height of 2K - * pixels. 11 fractional bits is actually insufficient for accurately - * rasterizing some triangles. More recently, the maximum viewport - * height was increased to 4K pixels. Thus, Mesa should be using 16 - * fractional bits in GLfixed. Unfortunately, there may be some issues - * with setting FIXED_FRAC_BITS=16, such as multiplication overflow. - * This will have to be examined in some detail... - * - * For now, if you find rasterization errors, particularly with tall, - * sliver triangles, try increasing FIXED_FRAC_BITS and/or decreasing - * SUB_PIXEL_BITS. - */ - - -/* - * Some code we unfortunately need to prevent negative interpolated colors. - */ -#ifndef CLAMP_INTERPOLANT -#define CLAMP_INTERPOLANT(CHANNEL, CHANNELSTEP, LEN) \ -do { \ - GLfixed endVal = span.CHANNEL + (LEN) * span.CHANNELSTEP; \ - if (endVal < 0) { \ - span.CHANNEL -= endVal; \ - } \ - if (span.CHANNEL < 0) { \ - span.CHANNEL = 0; \ - } \ -} while (0) -#endif - - -static void NAME(struct gl_context *ctx, const SWvertex *v0, - const SWvertex *v1, - const SWvertex *v2 ) -{ - typedef struct { - const SWvertex *v0, *v1; /* Y(v0) < Y(v1) */ - GLfloat dx; /* X(v1) - X(v0) */ - GLfloat dy; /* Y(v1) - Y(v0) */ - GLfloat dxdy; /* dx/dy */ - GLfixed fdxdy; /* dx/dy in fixed-point */ - GLfloat adjy; /* adjust from v[0]->fy to fsy, scaled */ - GLfixed fsx; /* first sample point x coord */ - GLfixed fsy; - GLfixed fx0; /* fixed pt X of lower endpoint */ - GLint lines; /* number of lines to be sampled on this edge */ - } EdgeT; - - const SWcontext *swrast = SWRAST_CONTEXT(ctx); -#ifdef INTERP_Z - const GLint depthBits = ctx->DrawBuffer->Visual.depthBits; - const GLint fixedToDepthShift = depthBits <= 16 ? FIXED_SHIFT : 0; - const GLfloat maxDepth = ctx->DrawBuffer->_DepthMaxF; -#define FixedToDepth(F) ((F) >> fixedToDepthShift) -#endif - EdgeT eMaj, eTop, eBot; - GLfloat oneOverArea; - const SWvertex *vMin, *vMid, *vMax; /* Y(vMin)<=Y(vMid)<=Y(vMax) */ - GLfloat bf = SWRAST_CONTEXT(ctx)->_BackfaceSign; - const GLint snapMask = ~((FIXED_ONE / (1 << SUB_PIXEL_BITS)) - 1); /* for x/y coord snapping */ - GLfixed vMin_fx, vMin_fy, vMid_fx, vMid_fy, vMax_fx, vMax_fy; - - SWspan span; - - (void) swrast; - - INIT_SPAN(span, GL_POLYGON); - span.y = 0; /* silence warnings */ - -#ifdef INTERP_Z - (void) fixedToDepthShift; -#endif - - /* - printf("%s()\n", __FUNCTION__); - printf(" %g, %g, %g\n", - v0->attrib[FRAG_ATTRIB_WPOS][0], - v0->attrib[FRAG_ATTRIB_WPOS][1], - v0->attrib[FRAG_ATTRIB_WPOS][2]); - printf(" %g, %g, %g\n", - v1->attrib[FRAG_ATTRIB_WPOS][0], - v1->attrib[FRAG_ATTRIB_WPOS][1], - v1->attrib[FRAG_ATTRIB_WPOS][2]); - printf(" %g, %g, %g\n", - v2->attrib[FRAG_ATTRIB_WPOS][0], - v2->attrib[FRAG_ATTRIB_WPOS][1], - v2->attrib[FRAG_ATTRIB_WPOS][2]); - */ - - /* Compute fixed point x,y coords w/ half-pixel offsets and snapping. - * And find the order of the 3 vertices along the Y axis. - */ - { - const GLfixed fy0 = FloatToFixed(v0->attrib[FRAG_ATTRIB_WPOS][1] - 0.5F) & snapMask; - const GLfixed fy1 = FloatToFixed(v1->attrib[FRAG_ATTRIB_WPOS][1] - 0.5F) & snapMask; - const GLfixed fy2 = FloatToFixed(v2->attrib[FRAG_ATTRIB_WPOS][1] - 0.5F) & snapMask; - if (fy0 <= fy1) { - if (fy1 <= fy2) { - /* y0 <= y1 <= y2 */ - vMin = v0; vMid = v1; vMax = v2; - vMin_fy = fy0; vMid_fy = fy1; vMax_fy = fy2; - } - else if (fy2 <= fy0) { - /* y2 <= y0 <= y1 */ - vMin = v2; vMid = v0; vMax = v1; - vMin_fy = fy2; vMid_fy = fy0; vMax_fy = fy1; - } - else { - /* y0 <= y2 <= y1 */ - vMin = v0; vMid = v2; vMax = v1; - vMin_fy = fy0; vMid_fy = fy2; vMax_fy = fy1; - bf = -bf; - } - } - else { - if (fy0 <= fy2) { - /* y1 <= y0 <= y2 */ - vMin = v1; vMid = v0; vMax = v2; - vMin_fy = fy1; vMid_fy = fy0; vMax_fy = fy2; - bf = -bf; - } - else if (fy2 <= fy1) { - /* y2 <= y1 <= y0 */ - vMin = v2; vMid = v1; vMax = v0; - vMin_fy = fy2; vMid_fy = fy1; vMax_fy = fy0; - bf = -bf; - } - else { - /* y1 <= y2 <= y0 */ - vMin = v1; vMid = v2; vMax = v0; - vMin_fy = fy1; vMid_fy = fy2; vMax_fy = fy0; - } - } - - /* fixed point X coords */ - vMin_fx = FloatToFixed(vMin->attrib[FRAG_ATTRIB_WPOS][0] + 0.5F) & snapMask; - vMid_fx = FloatToFixed(vMid->attrib[FRAG_ATTRIB_WPOS][0] + 0.5F) & snapMask; - vMax_fx = FloatToFixed(vMax->attrib[FRAG_ATTRIB_WPOS][0] + 0.5F) & snapMask; - } - - /* vertex/edge relationship */ - eMaj.v0 = vMin; eMaj.v1 = vMax; /*TODO: .v1's not needed */ - eTop.v0 = vMid; eTop.v1 = vMax; - eBot.v0 = vMin; eBot.v1 = vMid; - - /* compute deltas for each edge: vertex[upper] - vertex[lower] */ - eMaj.dx = FixedToFloat(vMax_fx - vMin_fx); - eMaj.dy = FixedToFloat(vMax_fy - vMin_fy); - eTop.dx = FixedToFloat(vMax_fx - vMid_fx); - eTop.dy = FixedToFloat(vMax_fy - vMid_fy); - eBot.dx = FixedToFloat(vMid_fx - vMin_fx); - eBot.dy = FixedToFloat(vMid_fy - vMin_fy); - - /* compute area, oneOverArea and perform backface culling */ - { - const GLfloat area = eMaj.dx * eBot.dy - eBot.dx * eMaj.dy; - - if (IS_INF_OR_NAN(area) || area == 0.0F) - return; - - if (area * bf * swrast->_BackfaceCullSign < 0.0) - return; - - oneOverArea = 1.0F / area; - } - - /* Edge setup. For a triangle strip these could be reused... */ - { - eMaj.fsy = FixedCeil(vMin_fy); - eMaj.lines = FixedToInt(FixedCeil(vMax_fy - eMaj.fsy)); - if (eMaj.lines > 0) { - eMaj.dxdy = eMaj.dx / eMaj.dy; - eMaj.fdxdy = SignedFloatToFixed(eMaj.dxdy); - eMaj.adjy = (GLfloat) (eMaj.fsy - vMin_fy); /* SCALED! */ - eMaj.fx0 = vMin_fx; - eMaj.fsx = eMaj.fx0 + (GLfixed) (eMaj.adjy * eMaj.dxdy); - } - else { - return; /*CULLED*/ - } - - eTop.fsy = FixedCeil(vMid_fy); - eTop.lines = FixedToInt(FixedCeil(vMax_fy - eTop.fsy)); - if (eTop.lines > 0) { - eTop.dxdy = eTop.dx / eTop.dy; - eTop.fdxdy = SignedFloatToFixed(eTop.dxdy); - eTop.adjy = (GLfloat) (eTop.fsy - vMid_fy); /* SCALED! */ - eTop.fx0 = vMid_fx; - eTop.fsx = eTop.fx0 + (GLfixed) (eTop.adjy * eTop.dxdy); - } - - eBot.fsy = FixedCeil(vMin_fy); - eBot.lines = FixedToInt(FixedCeil(vMid_fy - eBot.fsy)); - if (eBot.lines > 0) { - eBot.dxdy = eBot.dx / eBot.dy; - eBot.fdxdy = SignedFloatToFixed(eBot.dxdy); - eBot.adjy = (GLfloat) (eBot.fsy - vMin_fy); /* SCALED! */ - eBot.fx0 = vMin_fx; - eBot.fsx = eBot.fx0 + (GLfixed) (eBot.adjy * eBot.dxdy); - } - } - - /* - * Conceptually, we view a triangle as two subtriangles - * separated by a perfectly horizontal line. The edge that is - * intersected by this line is one with maximal absolute dy; we - * call it a ``major'' edge. The other two edges are the - * ``top'' edge (for the upper subtriangle) and the ``bottom'' - * edge (for the lower subtriangle). If either of these two - * edges is horizontal or very close to horizontal, the - * corresponding subtriangle might cover zero sample points; - * we take care to handle such cases, for performance as well - * as correctness. - * - * By stepping rasterization parameters along the major edge, - * we can avoid recomputing them at the discontinuity where - * the top and bottom edges meet. However, this forces us to - * be able to scan both left-to-right and right-to-left. - * Also, we must determine whether the major edge is at the - * left or right side of the triangle. We do this by - * computing the magnitude of the cross-product of the major - * and top edges. Since this magnitude depends on the sine of - * the angle between the two edges, its sign tells us whether - * we turn to the left or to the right when travelling along - * the major edge to the top edge, and from this we infer - * whether the major edge is on the left or the right. - * - * Serendipitously, this cross-product magnitude is also a - * value we need to compute the iteration parameter - * derivatives for the triangle, and it can be used to perform - * backface culling because its sign tells us whether the - * triangle is clockwise or counterclockwise. In this code we - * refer to it as ``area'' because it's also proportional to - * the pixel area of the triangle. - */ - - { - GLint scan_from_left_to_right; /* true if scanning left-to-right */ - - /* - * Execute user-supplied setup code - */ -#ifdef SETUP_CODE - SETUP_CODE -#endif - - scan_from_left_to_right = (oneOverArea < 0.0F); - - - /* compute d?/dx and d?/dy derivatives */ -#ifdef INTERP_Z - span.interpMask |= SPAN_Z; - { - GLfloat eMaj_dz = vMax->attrib[FRAG_ATTRIB_WPOS][2] - vMin->attrib[FRAG_ATTRIB_WPOS][2]; - GLfloat eBot_dz = vMid->attrib[FRAG_ATTRIB_WPOS][2] - vMin->attrib[FRAG_ATTRIB_WPOS][2]; - span.attrStepX[FRAG_ATTRIB_WPOS][2] = oneOverArea * (eMaj_dz * eBot.dy - eMaj.dy * eBot_dz); - if (span.attrStepX[FRAG_ATTRIB_WPOS][2] > maxDepth || - span.attrStepX[FRAG_ATTRIB_WPOS][2] < -maxDepth) { - /* probably a sliver triangle */ - span.attrStepX[FRAG_ATTRIB_WPOS][2] = 0.0; - span.attrStepY[FRAG_ATTRIB_WPOS][2] = 0.0; - } - else { - span.attrStepY[FRAG_ATTRIB_WPOS][2] = oneOverArea * (eMaj.dx * eBot_dz - eMaj_dz * eBot.dx); - } - if (depthBits <= 16) - span.zStep = SignedFloatToFixed(span.attrStepX[FRAG_ATTRIB_WPOS][2]); - else - span.zStep = (GLint) span.attrStepX[FRAG_ATTRIB_WPOS][2]; - } -#endif -#ifdef INTERP_RGB - span.interpMask |= SPAN_RGBA; - if (ctx->Light.ShadeModel == GL_SMOOTH) { - GLfloat eMaj_dr = (GLfloat) (vMax->color[RCOMP] - vMin->color[RCOMP]); - GLfloat eBot_dr = (GLfloat) (vMid->color[RCOMP] - vMin->color[RCOMP]); - GLfloat eMaj_dg = (GLfloat) (vMax->color[GCOMP] - vMin->color[GCOMP]); - GLfloat eBot_dg = (GLfloat) (vMid->color[GCOMP] - vMin->color[GCOMP]); - GLfloat eMaj_db = (GLfloat) (vMax->color[BCOMP] - vMin->color[BCOMP]); - GLfloat eBot_db = (GLfloat) (vMid->color[BCOMP] - vMin->color[BCOMP]); -# ifdef INTERP_ALPHA - GLfloat eMaj_da = (GLfloat) (vMax->color[ACOMP] - vMin->color[ACOMP]); - GLfloat eBot_da = (GLfloat) (vMid->color[ACOMP] - vMin->color[ACOMP]); -# endif - span.attrStepX[FRAG_ATTRIB_COL][0] = oneOverArea * (eMaj_dr * eBot.dy - eMaj.dy * eBot_dr); - span.attrStepY[FRAG_ATTRIB_COL][0] = oneOverArea * (eMaj.dx * eBot_dr - eMaj_dr * eBot.dx); - span.attrStepX[FRAG_ATTRIB_COL][1] = oneOverArea * (eMaj_dg * eBot.dy - eMaj.dy * eBot_dg); - span.attrStepY[FRAG_ATTRIB_COL][1] = oneOverArea * (eMaj.dx * eBot_dg - eMaj_dg * eBot.dx); - span.attrStepX[FRAG_ATTRIB_COL][2] = oneOverArea * (eMaj_db * eBot.dy - eMaj.dy * eBot_db); - span.attrStepY[FRAG_ATTRIB_COL][2] = oneOverArea * (eMaj.dx * eBot_db - eMaj_db * eBot.dx); - span.redStep = SignedFloatToFixed(span.attrStepX[FRAG_ATTRIB_COL][0]); - span.greenStep = SignedFloatToFixed(span.attrStepX[FRAG_ATTRIB_COL][1]); - span.blueStep = SignedFloatToFixed(span.attrStepX[FRAG_ATTRIB_COL][2]); -# ifdef INTERP_ALPHA - span.attrStepX[FRAG_ATTRIB_COL][3] = oneOverArea * (eMaj_da * eBot.dy - eMaj.dy * eBot_da); - span.attrStepY[FRAG_ATTRIB_COL][3] = oneOverArea * (eMaj.dx * eBot_da - eMaj_da * eBot.dx); - span.alphaStep = SignedFloatToFixed(span.attrStepX[FRAG_ATTRIB_COL][3]); -# endif /* INTERP_ALPHA */ - } - else { - ASSERT(ctx->Light.ShadeModel == GL_FLAT); - span.interpMask |= SPAN_FLAT; - span.attrStepX[FRAG_ATTRIB_COL][0] = span.attrStepY[FRAG_ATTRIB_COL][0] = 0.0F; - span.attrStepX[FRAG_ATTRIB_COL][1] = span.attrStepY[FRAG_ATTRIB_COL][1] = 0.0F; - span.attrStepX[FRAG_ATTRIB_COL][2] = span.attrStepY[FRAG_ATTRIB_COL][2] = 0.0F; - span.redStep = 0; - span.greenStep = 0; - span.blueStep = 0; -# ifdef INTERP_ALPHA - span.attrStepX[FRAG_ATTRIB_COL][3] = span.attrStepY[FRAG_ATTRIB_COL][3] = 0.0F; - span.alphaStep = 0; -# endif - } -#endif /* INTERP_RGB */ -#ifdef INTERP_INT_TEX - { - GLfloat eMaj_ds = (vMax->attrib[FRAG_ATTRIB_TEX][0] - vMin->attrib[FRAG_ATTRIB_TEX][0]) * S_SCALE; - GLfloat eBot_ds = (vMid->attrib[FRAG_ATTRIB_TEX][0] - vMin->attrib[FRAG_ATTRIB_TEX][0]) * S_SCALE; - GLfloat eMaj_dt = (vMax->attrib[FRAG_ATTRIB_TEX][1] - vMin->attrib[FRAG_ATTRIB_TEX][1]) * T_SCALE; - GLfloat eBot_dt = (vMid->attrib[FRAG_ATTRIB_TEX][1] - vMin->attrib[FRAG_ATTRIB_TEX][1]) * T_SCALE; - span.attrStepX[FRAG_ATTRIB_TEX][0] = oneOverArea * (eMaj_ds * eBot.dy - eMaj.dy * eBot_ds); - span.attrStepY[FRAG_ATTRIB_TEX][0] = oneOverArea * (eMaj.dx * eBot_ds - eMaj_ds * eBot.dx); - span.attrStepX[FRAG_ATTRIB_TEX][1] = oneOverArea * (eMaj_dt * eBot.dy - eMaj.dy * eBot_dt); - span.attrStepY[FRAG_ATTRIB_TEX][1] = oneOverArea * (eMaj.dx * eBot_dt - eMaj_dt * eBot.dx); - span.intTexStep[0] = SignedFloatToFixed(span.attrStepX[FRAG_ATTRIB_TEX][0]); - span.intTexStep[1] = SignedFloatToFixed(span.attrStepX[FRAG_ATTRIB_TEX][1]); - } -#endif -#ifdef INTERP_ATTRIBS - { - /* attrib[FRAG_ATTRIB_WPOS][3] is 1/W */ - const GLfloat wMax = vMax->attrib[FRAG_ATTRIB_WPOS][3]; - const GLfloat wMin = vMin->attrib[FRAG_ATTRIB_WPOS][3]; - const GLfloat wMid = vMid->attrib[FRAG_ATTRIB_WPOS][3]; - { - const GLfloat eMaj_dw = wMax - wMin; - const GLfloat eBot_dw = wMid - wMin; - span.attrStepX[FRAG_ATTRIB_WPOS][3] = oneOverArea * (eMaj_dw * eBot.dy - eMaj.dy * eBot_dw); - span.attrStepY[FRAG_ATTRIB_WPOS][3] = oneOverArea * (eMaj.dx * eBot_dw - eMaj_dw * eBot.dx); - } - ATTRIB_LOOP_BEGIN - if (swrast->_InterpMode[attr] == GL_FLAT) { - ASSIGN_4V(span.attrStepX[attr], 0.0, 0.0, 0.0, 0.0); - ASSIGN_4V(span.attrStepY[attr], 0.0, 0.0, 0.0, 0.0); - } - else { - GLuint c; - for (c = 0; c < 4; c++) { - GLfloat eMaj_da = vMax->attrib[attr][c] * wMax - vMin->attrib[attr][c] * wMin; - GLfloat eBot_da = vMid->attrib[attr][c] * wMid - vMin->attrib[attr][c] * wMin; - span.attrStepX[attr][c] = oneOverArea * (eMaj_da * eBot.dy - eMaj.dy * eBot_da); - span.attrStepY[attr][c] = oneOverArea * (eMaj.dx * eBot_da - eMaj_da * eBot.dx); - } - } - ATTRIB_LOOP_END - } -#endif - - /* - * We always sample at pixel centers. However, we avoid - * explicit half-pixel offsets in this code by incorporating - * the proper offset in each of x and y during the - * transformation to window coordinates. - * - * We also apply the usual rasterization rules to prevent - * cracks and overlaps. A pixel is considered inside a - * subtriangle if it meets all of four conditions: it is on or - * to the right of the left edge, strictly to the left of the - * right edge, on or below the top edge, and strictly above - * the bottom edge. (Some edges may be degenerate.) - * - * The following discussion assumes left-to-right scanning - * (that is, the major edge is on the left); the right-to-left - * case is a straightforward variation. - * - * We start by finding the half-integral y coordinate that is - * at or below the top of the triangle. This gives us the - * first scan line that could possibly contain pixels that are - * inside the triangle. - * - * Next we creep down the major edge until we reach that y, - * and compute the corresponding x coordinate on the edge. - * Then we find the half-integral x that lies on or just - * inside the edge. This is the first pixel that might lie in - * the interior of the triangle. (We won't know for sure - * until we check the other edges.) - * - * As we rasterize the triangle, we'll step down the major - * edge. For each step in y, we'll move an integer number - * of steps in x. There are two possible x step sizes, which - * we'll call the ``inner'' step (guaranteed to land on the - * edge or inside it) and the ``outer'' step (guaranteed to - * land on the edge or outside it). The inner and outer steps - * differ by one. During rasterization we maintain an error - * term that indicates our distance from the true edge, and - * select either the inner step or the outer step, whichever - * gets us to the first pixel that falls inside the triangle. - * - * All parameters (z, red, etc.) as well as the buffer - * addresses for color and z have inner and outer step values, - * so that we can increment them appropriately. This method - * eliminates the need to adjust parameters by creeping a - * sub-pixel amount into the triangle at each scanline. - */ - - { - GLint subTriangle; - GLfixed fxLeftEdge = 0, fxRightEdge = 0; - GLfixed fdxLeftEdge = 0, fdxRightEdge = 0; - GLfixed fError = 0, fdError = 0; -#ifdef PIXEL_ADDRESS - PIXEL_TYPE *pRow = NULL; - GLint dPRowOuter = 0, dPRowInner; /* offset in bytes */ -#endif -#ifdef INTERP_Z -# ifdef DEPTH_TYPE - struct gl_renderbuffer *zrb - = ctx->DrawBuffer->Attachment[BUFFER_DEPTH].Renderbuffer; - DEPTH_TYPE *zRow = NULL; - GLint dZRowOuter = 0, dZRowInner; /* offset in bytes */ -# endif - GLuint zLeft = 0; - GLfixed fdzOuter = 0, fdzInner; -#endif -#ifdef INTERP_RGB - GLint rLeft = 0, fdrOuter = 0, fdrInner; - GLint gLeft = 0, fdgOuter = 0, fdgInner; - GLint bLeft = 0, fdbOuter = 0, fdbInner; -#endif -#ifdef INTERP_ALPHA - GLint aLeft = 0, fdaOuter = 0, fdaInner; -#endif -#ifdef INTERP_INT_TEX - GLfixed sLeft=0, dsOuter=0, dsInner; - GLfixed tLeft=0, dtOuter=0, dtInner; -#endif -#ifdef INTERP_ATTRIBS - GLfloat wLeft = 0, dwOuter = 0, dwInner; - GLfloat attrLeft[FRAG_ATTRIB_MAX][4]; - GLfloat daOuter[FRAG_ATTRIB_MAX][4], daInner[FRAG_ATTRIB_MAX][4]; -#endif - - for (subTriangle=0; subTriangle<=1; subTriangle++) { - EdgeT *eLeft, *eRight; - int setupLeft, setupRight; - int lines; - - if (subTriangle==0) { - /* bottom half */ - if (scan_from_left_to_right) { - eLeft = &eMaj; - eRight = &eBot; - lines = eRight->lines; - setupLeft = 1; - setupRight = 1; - } - else { - eLeft = &eBot; - eRight = &eMaj; - lines = eLeft->lines; - setupLeft = 1; - setupRight = 1; - } - } - else { - /* top half */ - if (scan_from_left_to_right) { - eLeft = &eMaj; - eRight = &eTop; - lines = eRight->lines; - setupLeft = 0; - setupRight = 1; - } - else { - eLeft = &eTop; - eRight = &eMaj; - lines = eLeft->lines; - setupLeft = 1; - setupRight = 0; - } - if (lines == 0) - return; - } - - if (setupLeft && eLeft->lines > 0) { - const SWvertex *vLower = eLeft->v0; - const GLfixed fsy = eLeft->fsy; - const GLfixed fsx = eLeft->fsx; /* no fractional part */ - const GLfixed fx = FixedCeil(fsx); /* no fractional part */ - const GLfixed adjx = (GLfixed) (fx - eLeft->fx0); /* SCALED! */ - const GLfixed adjy = (GLfixed) eLeft->adjy; /* SCALED! */ - GLint idxOuter; - GLfloat dxOuter; - GLfixed fdxOuter; - - fError = fx - fsx - FIXED_ONE; - fxLeftEdge = fsx - FIXED_EPSILON; - fdxLeftEdge = eLeft->fdxdy; - fdxOuter = FixedFloor(fdxLeftEdge - FIXED_EPSILON); - fdError = fdxOuter - fdxLeftEdge + FIXED_ONE; - idxOuter = FixedToInt(fdxOuter); - dxOuter = (GLfloat) idxOuter; - span.y = FixedToInt(fsy); - - /* silence warnings on some compilers */ - (void) dxOuter; - (void) adjx; - (void) adjy; - (void) vLower; - -#ifdef PIXEL_ADDRESS - { - pRow = (PIXEL_TYPE *) PIXEL_ADDRESS(FixedToInt(fxLeftEdge), span.y); - dPRowOuter = -((int)BYTES_PER_ROW) + idxOuter * sizeof(PIXEL_TYPE); - /* negative because Y=0 at bottom and increases upward */ - } -#endif - /* - * Now we need the set of parameter (z, color, etc.) values at - * the point (fx, fsy). This gives us properly-sampled parameter - * values that we can step from pixel to pixel. Furthermore, - * although we might have intermediate results that overflow - * the normal parameter range when we step temporarily outside - * the triangle, we shouldn't overflow or underflow for any - * pixel that's actually inside the triangle. - */ - -#ifdef INTERP_Z - { - GLfloat z0 = vLower->attrib[FRAG_ATTRIB_WPOS][2]; - if (depthBits <= 16) { - /* interpolate fixed-pt values */ - GLfloat tmp = (z0 * FIXED_SCALE - + span.attrStepX[FRAG_ATTRIB_WPOS][2] * adjx - + span.attrStepY[FRAG_ATTRIB_WPOS][2] * adjy) + FIXED_HALF; - if (tmp < MAX_GLUINT / 2) - zLeft = (GLfixed) tmp; - else - zLeft = MAX_GLUINT / 2; - fdzOuter = SignedFloatToFixed(span.attrStepY[FRAG_ATTRIB_WPOS][2] + - dxOuter * span.attrStepX[FRAG_ATTRIB_WPOS][2]); - } - else { - /* interpolate depth values w/out scaling */ - zLeft = (GLuint) (z0 + span.attrStepX[FRAG_ATTRIB_WPOS][2] * FixedToFloat(adjx) - + span.attrStepY[FRAG_ATTRIB_WPOS][2] * FixedToFloat(adjy)); - fdzOuter = (GLint) (span.attrStepY[FRAG_ATTRIB_WPOS][2] + - dxOuter * span.attrStepX[FRAG_ATTRIB_WPOS][2]); - } -# ifdef DEPTH_TYPE - zRow = (DEPTH_TYPE *) - _swrast_pixel_address(zrb, FixedToInt(fxLeftEdge), span.y); - dZRowOuter = (ctx->DrawBuffer->Width + idxOuter) * sizeof(DEPTH_TYPE); -# endif - } -#endif -#ifdef INTERP_RGB - if (ctx->Light.ShadeModel == GL_SMOOTH) { - rLeft = (GLint)(ChanToFixed(vLower->color[RCOMP]) - + span.attrStepX[FRAG_ATTRIB_COL][0] * adjx - + span.attrStepY[FRAG_ATTRIB_COL][0] * adjy) + FIXED_HALF; - gLeft = (GLint)(ChanToFixed(vLower->color[GCOMP]) - + span.attrStepX[FRAG_ATTRIB_COL][1] * adjx - + span.attrStepY[FRAG_ATTRIB_COL][1] * adjy) + FIXED_HALF; - bLeft = (GLint)(ChanToFixed(vLower->color[BCOMP]) - + span.attrStepX[FRAG_ATTRIB_COL][2] * adjx - + span.attrStepY[FRAG_ATTRIB_COL][2] * adjy) + FIXED_HALF; - fdrOuter = SignedFloatToFixed(span.attrStepY[FRAG_ATTRIB_COL][0] - + dxOuter * span.attrStepX[FRAG_ATTRIB_COL][0]); - fdgOuter = SignedFloatToFixed(span.attrStepY[FRAG_ATTRIB_COL][1] - + dxOuter * span.attrStepX[FRAG_ATTRIB_COL][1]); - fdbOuter = SignedFloatToFixed(span.attrStepY[FRAG_ATTRIB_COL][2] - + dxOuter * span.attrStepX[FRAG_ATTRIB_COL][2]); -# ifdef INTERP_ALPHA - aLeft = (GLint)(ChanToFixed(vLower->color[ACOMP]) - + span.attrStepX[FRAG_ATTRIB_COL][3] * adjx - + span.attrStepY[FRAG_ATTRIB_COL][3] * adjy) + FIXED_HALF; - fdaOuter = SignedFloatToFixed(span.attrStepY[FRAG_ATTRIB_COL][3] - + dxOuter * span.attrStepX[FRAG_ATTRIB_COL][3]); -# endif - } - else { - ASSERT(ctx->Light.ShadeModel == GL_FLAT); - rLeft = ChanToFixed(v2->color[RCOMP]); - gLeft = ChanToFixed(v2->color[GCOMP]); - bLeft = ChanToFixed(v2->color[BCOMP]); - fdrOuter = fdgOuter = fdbOuter = 0; -# ifdef INTERP_ALPHA - aLeft = ChanToFixed(v2->color[ACOMP]); - fdaOuter = 0; -# endif - } -#endif /* INTERP_RGB */ - - -#ifdef INTERP_INT_TEX - { - GLfloat s0, t0; - s0 = vLower->attrib[FRAG_ATTRIB_TEX][0] * S_SCALE; - sLeft = (GLfixed)(s0 * FIXED_SCALE + span.attrStepX[FRAG_ATTRIB_TEX][0] * adjx - + span.attrStepY[FRAG_ATTRIB_TEX][0] * adjy) + FIXED_HALF; - dsOuter = SignedFloatToFixed(span.attrStepY[FRAG_ATTRIB_TEX][0] - + dxOuter * span.attrStepX[FRAG_ATTRIB_TEX][0]); - - t0 = vLower->attrib[FRAG_ATTRIB_TEX][1] * T_SCALE; - tLeft = (GLfixed)(t0 * FIXED_SCALE + span.attrStepX[FRAG_ATTRIB_TEX][1] * adjx - + span.attrStepY[FRAG_ATTRIB_TEX][1] * adjy) + FIXED_HALF; - dtOuter = SignedFloatToFixed(span.attrStepY[FRAG_ATTRIB_TEX][1] - + dxOuter * span.attrStepX[FRAG_ATTRIB_TEX][1]); - } -#endif -#ifdef INTERP_ATTRIBS - { - const GLuint attr = FRAG_ATTRIB_WPOS; - wLeft = vLower->attrib[FRAG_ATTRIB_WPOS][3] - + (span.attrStepX[attr][3] * adjx - + span.attrStepY[attr][3] * adjy) * (1.0F/FIXED_SCALE); - dwOuter = span.attrStepY[attr][3] + dxOuter * span.attrStepX[attr][3]; - } - ATTRIB_LOOP_BEGIN - const GLfloat invW = vLower->attrib[FRAG_ATTRIB_WPOS][3]; - if (swrast->_InterpMode[attr] == GL_FLAT) { - GLuint c; - for (c = 0; c < 4; c++) { - attrLeft[attr][c] = v2->attrib[attr][c] * invW; - daOuter[attr][c] = 0.0; - } - } - else { - GLuint c; - for (c = 0; c < 4; c++) { - const GLfloat a = vLower->attrib[attr][c] * invW; - attrLeft[attr][c] = a + ( span.attrStepX[attr][c] * adjx - + span.attrStepY[attr][c] * adjy) * (1.0F/FIXED_SCALE); - daOuter[attr][c] = span.attrStepY[attr][c] + dxOuter * span.attrStepX[attr][c]; - } - } - ATTRIB_LOOP_END -#endif - } /*if setupLeft*/ - - - if (setupRight && eRight->lines>0) { - fxRightEdge = eRight->fsx - FIXED_EPSILON; - fdxRightEdge = eRight->fdxdy; - } - - if (lines==0) { - continue; - } - - - /* Rasterize setup */ -#ifdef PIXEL_ADDRESS - dPRowInner = dPRowOuter + sizeof(PIXEL_TYPE); -#endif -#ifdef INTERP_Z -# ifdef DEPTH_TYPE - dZRowInner = dZRowOuter + sizeof(DEPTH_TYPE); -# endif - fdzInner = fdzOuter + span.zStep; -#endif -#ifdef INTERP_RGB - fdrInner = fdrOuter + span.redStep; - fdgInner = fdgOuter + span.greenStep; - fdbInner = fdbOuter + span.blueStep; -#endif -#ifdef INTERP_ALPHA - fdaInner = fdaOuter + span.alphaStep; -#endif -#ifdef INTERP_INT_TEX - dsInner = dsOuter + span.intTexStep[0]; - dtInner = dtOuter + span.intTexStep[1]; -#endif -#ifdef INTERP_ATTRIBS - dwInner = dwOuter + span.attrStepX[FRAG_ATTRIB_WPOS][3]; - ATTRIB_LOOP_BEGIN - GLuint c; - for (c = 0; c < 4; c++) { - daInner[attr][c] = daOuter[attr][c] + span.attrStepX[attr][c]; - } - ATTRIB_LOOP_END -#endif - - while (lines > 0) { - /* initialize the span interpolants to the leftmost value */ - /* ff = fixed-pt fragment */ - const GLint right = FixedToInt(fxRightEdge); - span.x = FixedToInt(fxLeftEdge); - if (right <= span.x) - span.end = 0; - else - span.end = right - span.x; - -#ifdef INTERP_Z - span.z = zLeft; -#endif -#ifdef INTERP_RGB - span.red = rLeft; - span.green = gLeft; - span.blue = bLeft; -#endif -#ifdef INTERP_ALPHA - span.alpha = aLeft; -#endif -#ifdef INTERP_INT_TEX - span.intTex[0] = sLeft; - span.intTex[1] = tLeft; -#endif - -#ifdef INTERP_ATTRIBS - span.attrStart[FRAG_ATTRIB_WPOS][3] = wLeft; - ATTRIB_LOOP_BEGIN - GLuint c; - for (c = 0; c < 4; c++) { - span.attrStart[attr][c] = attrLeft[attr][c]; - } - ATTRIB_LOOP_END -#endif - - /* This is where we actually generate fragments */ - /* XXX the test for span.y > 0 _shouldn't_ be needed but - * it fixes a problem on 64-bit Opterons (bug 4842). - */ - if (span.end > 0 && span.y >= 0) { - const GLint len = span.end - 1; - (void) len; -#ifdef INTERP_RGB - CLAMP_INTERPOLANT(red, redStep, len); - CLAMP_INTERPOLANT(green, greenStep, len); - CLAMP_INTERPOLANT(blue, blueStep, len); -#endif -#ifdef INTERP_ALPHA - CLAMP_INTERPOLANT(alpha, alphaStep, len); -#endif - { - RENDER_SPAN( span ); - } - } - - /* - * Advance to the next scan line. Compute the - * new edge coordinates, and adjust the - * pixel-center x coordinate so that it stays - * on or inside the major edge. - */ - span.y++; - lines--; - - fxLeftEdge += fdxLeftEdge; - fxRightEdge += fdxRightEdge; - - fError += fdError; - if (fError >= 0) { - fError -= FIXED_ONE; - -#ifdef PIXEL_ADDRESS - pRow = (PIXEL_TYPE *) ((GLubyte *) pRow + dPRowOuter); -#endif -#ifdef INTERP_Z -# ifdef DEPTH_TYPE - zRow = (DEPTH_TYPE *) ((GLubyte *) zRow + dZRowOuter); -# endif - zLeft += fdzOuter; -#endif -#ifdef INTERP_RGB - rLeft += fdrOuter; - gLeft += fdgOuter; - bLeft += fdbOuter; -#endif -#ifdef INTERP_ALPHA - aLeft += fdaOuter; -#endif -#ifdef INTERP_INT_TEX - sLeft += dsOuter; - tLeft += dtOuter; -#endif -#ifdef INTERP_ATTRIBS - wLeft += dwOuter; - ATTRIB_LOOP_BEGIN - GLuint c; - for (c = 0; c < 4; c++) { - attrLeft[attr][c] += daOuter[attr][c]; - } - ATTRIB_LOOP_END -#endif - } - else { -#ifdef PIXEL_ADDRESS - pRow = (PIXEL_TYPE *) ((GLubyte *) pRow + dPRowInner); -#endif -#ifdef INTERP_Z -# ifdef DEPTH_TYPE - zRow = (DEPTH_TYPE *) ((GLubyte *) zRow + dZRowInner); -# endif - zLeft += fdzInner; -#endif -#ifdef INTERP_RGB - rLeft += fdrInner; - gLeft += fdgInner; - bLeft += fdbInner; -#endif -#ifdef INTERP_ALPHA - aLeft += fdaInner; -#endif -#ifdef INTERP_INT_TEX - sLeft += dsInner; - tLeft += dtInner; -#endif -#ifdef INTERP_ATTRIBS - wLeft += dwInner; - ATTRIB_LOOP_BEGIN - GLuint c; - for (c = 0; c < 4; c++) { - attrLeft[attr][c] += daInner[attr][c]; - } - ATTRIB_LOOP_END -#endif - } - } /*while lines>0*/ - - } /* for subTriangle */ - - } - } -} - -#undef SETUP_CODE -#undef RENDER_SPAN - -#undef PIXEL_TYPE -#undef BYTES_PER_ROW -#undef PIXEL_ADDRESS -#undef DEPTH_TYPE - -#undef INTERP_Z -#undef INTERP_RGB -#undef INTERP_ALPHA -#undef INTERP_INT_TEX -#undef INTERP_ATTRIBS - -#undef S_SCALE -#undef T_SCALE - -#undef FixedToDepth - -#undef NAME diff --git a/dll/opengl/mesa/swrast/s_zoom.c b/dll/opengl/mesa/swrast/s_zoom.c deleted file mode 100644 index 240cd1f0aec..00000000000 --- a/dll/opengl/mesa/swrast/s_zoom.c +++ /dev/null @@ -1,420 +0,0 @@ -/* - * Mesa 3-D graphics library - * Version: 7.1 - * - * Copyright (C) 1999-2008 Brian Paul All Rights Reserved. - * - * Permission is hereby granted, free of charge, to any person obtaining a - * copy of this software and associated documentation files (the "Software"), - * to deal in the Software without restriction, including without limitation - * the rights to use, copy, modify, merge, publish, distribute, sublicense, - * and/or sell copies of the Software, and to permit persons to whom the - * Software is furnished to do so, subject to the following conditions: - * - * The above copyright notice and this permission notice shall be included - * in all copies or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS - * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL - * BRIAN PAUL BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN - * AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN - * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. - */ - -#include - -/** - * Compute the bounds of the region resulting from zooming a pixel span. - * The resulting region will be entirely inside the window/scissor bounds - * so no additional clipping is needed. - * \param imageX, imageY position of the mage being drawn (gl WindowPos) - * \param spanX, spanY position of span being drawing - * \param width number of pixels in span - * \param x0, x1 returned X bounds of zoomed region [x0, x1) - * \param y0, y1 returned Y bounds of zoomed region [y0, y1) - * \return GL_TRUE if any zoomed pixels visible, GL_FALSE if totally clipped - */ -static GLboolean -compute_zoomed_bounds(struct gl_context *ctx, GLint imageX, GLint imageY, - GLint spanX, GLint spanY, GLint width, - GLint *x0, GLint *x1, GLint *y0, GLint *y1) -{ - const struct gl_framebuffer *fb = ctx->DrawBuffer; - GLint c0, c1, r0, r1; - - ASSERT(spanX >= imageX); - ASSERT(spanY >= imageY); - - /* - * Compute destination columns: [c0, c1) - */ - c0 = imageX + (GLint) ((spanX - imageX) * ctx->Pixel.ZoomX); - c1 = imageX + (GLint) ((spanX + width - imageX) * ctx->Pixel.ZoomX); - if (c1 < c0) { - /* swap */ - GLint tmp = c1; - c1 = c0; - c0 = tmp; - } - c0 = CLAMP(c0, fb->_Xmin, fb->_Xmax); - c1 = CLAMP(c1, fb->_Xmin, fb->_Xmax); - if (c0 == c1) { - return GL_FALSE; /* no width */ - } - - /* - * Compute destination rows: [r0, r1) - */ - r0 = imageY + (GLint) ((spanY - imageY) * ctx->Pixel.ZoomY); - r1 = imageY + (GLint) ((spanY + 1 - imageY) * ctx->Pixel.ZoomY); - if (r1 < r0) { - /* swap */ - GLint tmp = r1; - r1 = r0; - r0 = tmp; - } - r0 = CLAMP(r0, fb->_Ymin, fb->_Ymax); - r1 = CLAMP(r1, fb->_Ymin, fb->_Ymax); - if (r0 == r1) { - return GL_FALSE; /* no height */ - } - - *x0 = c0; - *x1 = c1; - *y0 = r0; - *y1 = r1; - - return GL_TRUE; -} - - -/** - * Convert a zoomed x image coordinate back to an unzoomed x coord. - * 'zx' is screen position of a pixel in the zoomed image, who's left edge - * is at 'imageX'. - * return corresponding x coord in the original, unzoomed image. - * This can use this for unzooming X or Y values. - */ -static inline GLint -unzoom_x(GLfloat zoomX, GLint imageX, GLint zx) -{ - /* - zx = imageX + (x - imageX) * zoomX; - zx - imageX = (x - imageX) * zoomX; - (zx - imageX) / zoomX = x - imageX; - */ - GLint x; - if (zoomX < 0.0) - zx++; - x = imageX + (GLint) ((zx - imageX) / zoomX); - return x; -} - - - -/** - * Helper function called from _swrast_write_zoomed_rgba/rgb/ - * index/depth_span(). - */ -static void -zoom_span( struct gl_context *ctx, GLint imgX, GLint imgY, const SWspan *span, - const GLvoid *src, GLenum format ) -{ - SWcontext *swrast = SWRAST_CONTEXT(ctx); - SWspan zoomed; - GLint x0, x1, y0, y1; - GLint zoomedWidth; - - if (!compute_zoomed_bounds(ctx, imgX, imgY, span->x, span->y, span->end, - &x0, &x1, &y0, &y1)) { - return; /* totally clipped */ - } - - if (!swrast->ZoomedArrays) { - /* allocate on demand */ - swrast->ZoomedArrays = (SWspanarrays *) CALLOC(sizeof(SWspanarrays)); - if (!swrast->ZoomedArrays) - return; - } - - zoomedWidth = x1 - x0; - ASSERT(zoomedWidth > 0); - ASSERT(zoomedWidth <= MAX_WIDTH); - - /* no pixel arrays! must be horizontal spans. */ - ASSERT((span->arrayMask & SPAN_XY) == 0); - ASSERT(span->primitive == GL_BITMAP); - - INIT_SPAN(zoomed, GL_BITMAP); - zoomed.x = x0; - zoomed.end = zoomedWidth; - zoomed.array = swrast->ZoomedArrays; - zoomed.array->ChanType = span->array->ChanType; - if (zoomed.array->ChanType == GL_UNSIGNED_BYTE) - zoomed.array->rgba = (GLchan (*)[4]) zoomed.array->rgba8; - else if (zoomed.array->ChanType == GL_UNSIGNED_SHORT) - zoomed.array->rgba = (GLchan (*)[4]) zoomed.array->rgba16; - else - zoomed.array->rgba = (GLchan (*)[4]) zoomed.array->attribs[FRAG_ATTRIB_COL]; - - COPY_4V(zoomed.attrStart[FRAG_ATTRIB_WPOS], span->attrStart[FRAG_ATTRIB_WPOS]); - COPY_4V(zoomed.attrStepX[FRAG_ATTRIB_WPOS], span->attrStepX[FRAG_ATTRIB_WPOS]); - COPY_4V(zoomed.attrStepY[FRAG_ATTRIB_WPOS], span->attrStepY[FRAG_ATTRIB_WPOS]); - - zoomed.attrStart[FRAG_ATTRIB_FOGC][0] = span->attrStart[FRAG_ATTRIB_FOGC][0]; - zoomed.attrStepX[FRAG_ATTRIB_FOGC][0] = span->attrStepX[FRAG_ATTRIB_FOGC][0]; - zoomed.attrStepY[FRAG_ATTRIB_FOGC][0] = span->attrStepY[FRAG_ATTRIB_FOGC][0]; - - if (format == GL_RGBA || format == GL_RGB) { - /* copy Z info */ - zoomed.z = span->z; - zoomed.zStep = span->zStep; - /* we'll generate an array of colorss */ - zoomed.interpMask = span->interpMask & ~SPAN_RGBA; - zoomed.arrayMask |= SPAN_RGBA; - zoomed.arrayAttribs |= FRAG_BIT_COL; /* we'll produce these values */ - ASSERT(span->arrayMask & SPAN_RGBA); - } - else if (format == GL_DEPTH_COMPONENT) { - /* Copy color info */ - zoomed.red = span->red; - zoomed.green = span->green; - zoomed.blue = span->blue; - zoomed.alpha = span->alpha; - zoomed.redStep = span->redStep; - zoomed.greenStep = span->greenStep; - zoomed.blueStep = span->blueStep; - zoomed.alphaStep = span->alphaStep; - /* we'll generate an array of depth values */ - zoomed.interpMask = span->interpMask & ~SPAN_Z; - zoomed.arrayMask |= SPAN_Z; - ASSERT(span->arrayMask & SPAN_Z); - } - else { - _mesa_problem(ctx, "Bad format in zoom_span"); - return; - } - - /* zoom the span horizontally */ - if (format == GL_RGBA) { - if (zoomed.array->ChanType == GL_UNSIGNED_BYTE) { - const GLubyte (*rgba)[4] = (const GLubyte (*)[4]) src; - GLint i; - for (i = 0; i < zoomedWidth; i++) { - GLint j = unzoom_x(ctx->Pixel.ZoomX, imgX, x0 + i) - span->x; - ASSERT(j >= 0); - ASSERT(j < (GLint) span->end); - COPY_4UBV(zoomed.array->rgba8[i], rgba[j]); - } - } - else if (zoomed.array->ChanType == GL_UNSIGNED_SHORT) { - const GLushort (*rgba)[4] = (const GLushort (*)[4]) src; - GLint i; - for (i = 0; i < zoomedWidth; i++) { - GLint j = unzoom_x(ctx->Pixel.ZoomX, imgX, x0 + i) - span->x; - ASSERT(j >= 0); - ASSERT(j < (GLint) span->end); - COPY_4V(zoomed.array->rgba16[i], rgba[j]); - } - } - else { - const GLfloat (*rgba)[4] = (const GLfloat (*)[4]) src; - GLint i; - for (i = 0; i < zoomedWidth; i++) { - GLint j = unzoom_x(ctx->Pixel.ZoomX, imgX, x0 + i) - span->x; - ASSERT(j >= 0); - ASSERT(j < span->end); - COPY_4V(zoomed.array->attribs[FRAG_ATTRIB_COL][i], rgba[j]); - } - } - } - else if (format == GL_RGB) { - if (zoomed.array->ChanType == GL_UNSIGNED_BYTE) { - const GLubyte (*rgb)[3] = (const GLubyte (*)[3]) src; - GLint i; - for (i = 0; i < zoomedWidth; i++) { - GLint j = unzoom_x(ctx->Pixel.ZoomX, imgX, x0 + i) - span->x; - ASSERT(j >= 0); - ASSERT(j < (GLint) span->end); - zoomed.array->rgba8[i][0] = rgb[j][0]; - zoomed.array->rgba8[i][1] = rgb[j][1]; - zoomed.array->rgba8[i][2] = rgb[j][2]; - zoomed.array->rgba8[i][3] = 0xff; - } - } - else if (zoomed.array->ChanType == GL_UNSIGNED_SHORT) { - const GLushort (*rgb)[3] = (const GLushort (*)[3]) src; - GLint i; - for (i = 0; i < zoomedWidth; i++) { - GLint j = unzoom_x(ctx->Pixel.ZoomX, imgX, x0 + i) - span->x; - ASSERT(j >= 0); - ASSERT(j < (GLint) span->end); - zoomed.array->rgba16[i][0] = rgb[j][0]; - zoomed.array->rgba16[i][1] = rgb[j][1]; - zoomed.array->rgba16[i][2] = rgb[j][2]; - zoomed.array->rgba16[i][3] = 0xffff; - } - } - else { - const GLfloat (*rgb)[3] = (const GLfloat (*)[3]) src; - GLint i; - for (i = 0; i < zoomedWidth; i++) { - GLint j = unzoom_x(ctx->Pixel.ZoomX, imgX, x0 + i) - span->x; - ASSERT(j >= 0); - ASSERT(j < span->end); - zoomed.array->attribs[FRAG_ATTRIB_COL][i][0] = rgb[j][0]; - zoomed.array->attribs[FRAG_ATTRIB_COL][i][1] = rgb[j][1]; - zoomed.array->attribs[FRAG_ATTRIB_COL][i][2] = rgb[j][2]; - zoomed.array->attribs[FRAG_ATTRIB_COL][i][3] = 1.0F; - } - } - } - else if (format == GL_DEPTH_COMPONENT) { - const GLuint *zValues = (const GLuint *) src; - GLint i; - for (i = 0; i < zoomedWidth; i++) { - GLint j = unzoom_x(ctx->Pixel.ZoomX, imgX, x0 + i) - span->x; - ASSERT(j >= 0); - ASSERT(j < (GLint) span->end); - zoomed.array->z[i] = zValues[j]; - } - /* Now, fall into the RGB path below */ - format = GL_RGBA; - } - - /* write the span in rows [r0, r1) */ - if (format == GL_RGBA || format == GL_RGB) { - /* Writing the span may modify the colors, so make a backup now if we're - * going to call _swrast_write_zoomed_span() more than once. - * Also, clipping may change the span end value, so store it as well. - */ - const GLint end = zoomed.end; /* save */ - void *rgbaSave; - const GLint pixelSize = - (zoomed.array->ChanType == GL_UNSIGNED_BYTE) ? 4 * sizeof(GLubyte) : - ((zoomed.array->ChanType == GL_UNSIGNED_SHORT) ? 4 * sizeof(GLushort) - : 4 * sizeof(GLfloat)); - - rgbaSave = malloc(zoomed.end * pixelSize); - if (!rgbaSave) { - return; - } - - if (y1 - y0 > 1) { - memcpy(rgbaSave, zoomed.array->rgba, zoomed.end * pixelSize); - } - for (zoomed.y = y0; zoomed.y < y1; zoomed.y++) { - _swrast_write_rgba_span(ctx, &zoomed); - zoomed.end = end; /* restore */ - if (y1 - y0 > 1) { - /* restore the colors */ - memcpy(zoomed.array->rgba, rgbaSave, zoomed.end * pixelSize); - } - } - - free(rgbaSave); - } -} - - -void -_swrast_write_zoomed_rgba_span(struct gl_context *ctx, GLint imgX, GLint imgY, - const SWspan *span, const GLvoid *rgba) -{ - zoom_span(ctx, imgX, imgY, span, rgba, GL_RGBA); -} - - -void -_swrast_write_zoomed_rgb_span(struct gl_context *ctx, GLint imgX, GLint imgY, - const SWspan *span, const GLvoid *rgb) -{ - zoom_span(ctx, imgX, imgY, span, rgb, GL_RGB); -} - - -void -_swrast_write_zoomed_depth_span(struct gl_context *ctx, GLint imgX, GLint imgY, - const SWspan *span) -{ - zoom_span(ctx, imgX, imgY, span, - (const GLvoid *) span->array->z, GL_DEPTH_COMPONENT); -} - - -/** - * Zoom/write stencil values. - * No per-fragment operations are applied. - */ -void -_swrast_write_zoomed_stencil_span(struct gl_context *ctx, GLint imgX, GLint imgY, - GLint width, GLint spanX, GLint spanY, - const GLubyte stencil[]) -{ - GLubyte zoomedVals[MAX_WIDTH]; - GLint x0, x1, y0, y1, y; - GLint i, zoomedWidth; - - if (!compute_zoomed_bounds(ctx, imgX, imgY, spanX, spanY, width, - &x0, &x1, &y0, &y1)) { - return; /* totally clipped */ - } - - zoomedWidth = x1 - x0; - ASSERT(zoomedWidth > 0); - ASSERT(zoomedWidth <= MAX_WIDTH); - - /* zoom the span horizontally */ - for (i = 0; i < zoomedWidth; i++) { - GLint j = unzoom_x(ctx->Pixel.ZoomX, imgX, x0 + i) - spanX; - ASSERT(j >= 0); - ASSERT(j < width); - zoomedVals[i] = stencil[j]; - } - - /* write the zoomed spans */ - for (y = y0; y < y1; y++) { - _swrast_write_stencil_span(ctx, zoomedWidth, x0, y, zoomedVals); - } -} - - -/** - * Zoom/write 32-bit Z values. - * No per-fragment operations are applied. - */ -void -_swrast_write_zoomed_z_span(struct gl_context *ctx, GLint imgX, GLint imgY, - GLint width, GLint spanX, GLint spanY, - const GLuint *zVals) -{ - struct gl_renderbuffer *rb = - ctx->DrawBuffer->Attachment[BUFFER_DEPTH].Renderbuffer; - GLuint zoomedVals[MAX_WIDTH]; - GLint x0, x1, y0, y1, y; - GLint i, zoomedWidth; - - if (!compute_zoomed_bounds(ctx, imgX, imgY, spanX, spanY, width, - &x0, &x1, &y0, &y1)) { - return; /* totally clipped */ - } - - zoomedWidth = x1 - x0; - ASSERT(zoomedWidth > 0); - ASSERT(zoomedWidth <= MAX_WIDTH); - - /* zoom the span horizontally */ - for (i = 0; i < zoomedWidth; i++) { - GLint j = unzoom_x(ctx->Pixel.ZoomX, imgX, x0 + i) - spanX; - ASSERT(j >= 0); - ASSERT(j < width); - zoomedVals[i] = zVals[j]; - } - - /* write the zoomed spans */ - for (y = y0; y < y1; y++) { - GLubyte *dst = _swrast_pixel_address(rb, x0, y); - _mesa_pack_uint_z_row(rb->Format, zoomedWidth, zoomedVals, dst); - } -} diff --git a/dll/opengl/mesa/swrast/s_zoom.h b/dll/opengl/mesa/swrast/s_zoom.h deleted file mode 100644 index 1955e7e8839..00000000000 --- a/dll/opengl/mesa/swrast/s_zoom.h +++ /dev/null @@ -1,56 +0,0 @@ -/* - * Mesa 3-D graphics library - * Version: 6.5 - * - * Copyright (C) 1999-2005 Brian Paul All Rights Reserved. - * - * Permission is hereby granted, free of charge, to any person obtaining a - * copy of this software and associated documentation files (the "Software"), - * to deal in the Software without restriction, including without limitation - * the rights to use, copy, modify, merge, publish, distribute, sublicense, - * and/or sell copies of the Software, and to permit persons to whom the - * Software is furnished to do so, subject to the following conditions: - * - * The above copyright notice and this permission notice shall be included - * in all copies or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS - * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL - * BRIAN PAUL BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN - * AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN - * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. - */ - -#ifndef S_ZOOM_H -#define S_ZOOM_H - -#include "main/mtypes.h" -#include "s_span.h" - - -extern void -_swrast_write_zoomed_rgba_span(struct gl_context *ctx, GLint imgX, GLint imgY, - const SWspan *span, const GLvoid *rgba); - -extern void -_swrast_write_zoomed_rgb_span(struct gl_context *ctx, GLint imgX, GLint imgY, - const SWspan *span, const GLvoid *rgb); - -extern void -_swrast_write_zoomed_depth_span(struct gl_context *ctx, GLint imgX, GLint imgY, - const SWspan *span); - - -extern void -_swrast_write_zoomed_stencil_span(struct gl_context *ctx, GLint imgX, GLint imgY, - GLint width, GLint spanX, GLint spanY, - const GLubyte stencil[]); - -extern void -_swrast_write_zoomed_z_span(struct gl_context *ctx, GLint imgX, GLint imgY, - GLint width, GLint spanX, GLint spanY, - const GLuint *zVals); - - -#endif diff --git a/dll/opengl/mesa/swrast/swrast.h b/dll/opengl/mesa/swrast/swrast.h deleted file mode 100644 index e3f2d942fa1..00000000000 --- a/dll/opengl/mesa/swrast/swrast.h +++ /dev/null @@ -1,263 +0,0 @@ -/* - * Mesa 3-D graphics library - * Version: 6.5 - * - * Copyright (C) 1999-2006 Brian Paul All Rights Reserved. - * - * Permission is hereby granted, free of charge, to any person obtaining a - * copy of this software and associated documentation files (the "Software"), - * to deal in the Software without restriction, including without limitation - * the rights to use, copy, modify, merge, publish, distribute, sublicense, - * and/or sell copies of the Software, and to permit persons to whom the - * Software is furnished to do so, subject to the following conditions: - * - * The above copyright notice and this permission notice shall be included - * in all copies or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS - * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL - * BRIAN PAUL BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN - * AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN - * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. - * - */ - -/** - * \file swrast/swrast.h - * \brief Public interface to the software rasterization functions. - * \author Keith Whitwell - */ - -#ifndef SWRAST_H -#define SWRAST_H - -#include "main/mtypes.h" -#include "swrast/s_chan.h" - -/** - * \struct SWvertex - * \brief Data-structure to handle vertices in the software rasterizer. - * - * The software rasterizer now uses this format for vertices. Thus a - * 'RasterSetup' stage or other translation is required between the - * tnl module and the swrast rasterization functions. This serves to - * isolate the swrast module from the internals of the tnl module, and - * improve its usefulness as a fallback mechanism for hardware - * drivers. - * - * wpos = attr[FRAG_ATTRIB_WPOS] and MUST BE THE FIRST values in the - * vertex because of the tnl clipping code. - - * wpos[0] and [1] are the screen-coords of SWvertex. - * wpos[2] is the z-buffer coord (if 16-bit Z buffer, in range [0,65535]). - * wpos[3] is 1/w where w is the clip-space W coord. This is the value - * that clip{XYZ} were multiplied by to get ndc{XYZ}. - * - * Full software drivers: - * - Register the rastersetup and triangle functions from - * utils/software_helper. - * - On statechange, update the rasterization pointers in that module. - * - * Rasterization hardware drivers: - * - Keep native rastersetup. - * - Implement native twoside,offset and unfilled triangle setup. - * - Implement a translator from native vertices to swrast vertices. - * - On partial fallback (mix of accelerated and unaccelerated - * prims), call a pass-through function which translates native - * vertices to SWvertices and calls the appropriate swrast function. - * - On total fallback (vertex format insufficient for state or all - * primitives unaccelerated), hook in swrast_setup instead. - */ -typedef struct { - GLfloat attrib[FRAG_ATTRIB_MAX][4]; - GLchan color[4]; /** integer color */ - GLfloat pointSize; -} SWvertex; - - -#define FRAG_ATTRIB_CI FRAG_ATTRIB_COL - - -struct swrast_device_driver; - - -/* These are the public-access functions exported from swrast. - */ - -extern GLboolean -_swrast_CreateContext( struct gl_context *ctx ); - -extern void -_swrast_DestroyContext( struct gl_context *ctx ); - -/* Get a (non-const) reference to the device driver struct for swrast. - */ -extern struct swrast_device_driver * -_swrast_GetDeviceDriverReference( struct gl_context *ctx ); - -extern void -_swrast_Bitmap( struct gl_context *ctx, - GLint px, GLint py, - GLsizei width, GLsizei height, - const struct gl_pixelstore_attrib *unpack, - const GLubyte *bitmap ); - -extern void -_swrast_CopyPixels( struct gl_context *ctx, - GLint srcx, GLint srcy, - GLint destx, GLint desty, - GLsizei width, GLsizei height, - GLenum type ); - -extern GLboolean -swrast_fast_copy_pixels(struct gl_context *ctx, - GLint srcX, GLint srcY, GLsizei width, GLsizei height, - GLint dstX, GLint dstY, GLenum type); - -extern void -_swrast_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 ); - -extern void -_swrast_Clear(struct gl_context *ctx, GLbitfield buffers); - - - -/* Reset the stipple counter - */ -extern void -_swrast_ResetLineStipple( struct gl_context *ctx ); - -/* These will always render the correct point/line/triangle for the - * current state. - * - * For flatshaded primitives, the provoking vertex is the final one. - */ -extern void -_swrast_Point( struct gl_context *ctx, const SWvertex *v ); - -extern void -_swrast_Line( struct gl_context *ctx, const SWvertex *v0, const SWvertex *v1 ); - -extern void -_swrast_Triangle( struct gl_context *ctx, const SWvertex *v0, - const SWvertex *v1, const SWvertex *v2 ); - -extern void -_swrast_Quad( struct gl_context *ctx, - const SWvertex *v0, const SWvertex *v1, - const SWvertex *v2, const SWvertex *v3); - -extern void -_swrast_flush( struct gl_context *ctx ); - -extern void -_swrast_render_primitive( struct gl_context *ctx, GLenum mode ); - -extern void -_swrast_render_start( struct gl_context *ctx ); - -extern void -_swrast_render_finish( struct gl_context *ctx ); - -extern struct gl_texture_image * -_swrast_new_texture_image( struct gl_context *ctx ); - -extern void -_swrast_delete_texture_image(struct gl_context *ctx, - struct gl_texture_image *texImage); - -extern GLboolean -_swrast_alloc_texture_image_buffer(struct gl_context *ctx, - struct gl_texture_image *texImage, - gl_format format, GLsizei width, - GLsizei height, GLsizei depth); - -extern void -_swrast_init_texture_image(struct gl_texture_image *texImage, GLsizei width, - GLsizei height, GLsizei depth); - -extern void -_swrast_free_texture_image_buffer(struct gl_context *ctx, - struct gl_texture_image *texImage); - -extern void -_swrast_map_teximage(struct gl_context *ctx, - struct gl_texture_image *texImage, - GLuint slice, - GLuint x, GLuint y, GLuint w, GLuint h, - GLbitfield mode, - GLubyte **mapOut, - GLint *rowStrideOut); - -extern void -_swrast_unmap_teximage(struct gl_context *ctx, - struct gl_texture_image *texImage, - GLuint slice); - -/* Tell the software rasterizer about core state changes. - */ -extern void -_swrast_InvalidateState( struct gl_context *ctx, GLbitfield new_state ); - -/* Configure software rasterizer to match hardware rasterizer characteristics: - */ -extern void -_swrast_allow_vertex_fog( struct gl_context *ctx, GLboolean value ); - -extern void -_swrast_allow_pixel_fog( struct gl_context *ctx, GLboolean value ); - -/* Debug: - */ -extern void -_swrast_print_vertex( struct gl_context *ctx, const SWvertex *v ); - - - -extern void -_swrast_eject_texture_images(struct gl_context *ctx); - - -extern void -_swrast_render_texture(struct gl_context *ctx, - struct gl_framebuffer *fb, - struct gl_renderbuffer_attachment *att); - - - -extern GLboolean -_swrast_AllocTextureStorage(struct gl_context *ctx, - struct gl_texture_object *texObj, - GLsizei levels, GLsizei width, - GLsizei height, GLsizei depth); - - -/** - * The driver interface for the software rasterizer. - * XXX this may go away. - * We may move these functions to ctx->Driver.RenderStart, RenderEnd. - */ -struct swrast_device_driver { - /* - * These are called before and after accessing renderbuffers during - * software rasterization. - * - * These are a suitable place for grabbing/releasing hardware locks. - * - * NOTE: The swrast triangle/line/point routines *DO NOT* call - * these functions. Locking in that case must be organized by the - * driver by other mechanisms. - */ - void (*SpanRenderStart)(struct gl_context *ctx); - void (*SpanRenderFinish)(struct gl_context *ctx); -}; - - - -#endif diff --git a/dll/opengl/mesa/swrast_setup/CMakeLists.txt b/dll/opengl/mesa/swrast_setup/CMakeLists.txt deleted file mode 100644 index 0dcd413a537..00000000000 --- a/dll/opengl/mesa/swrast_setup/CMakeLists.txt +++ /dev/null @@ -1,7 +0,0 @@ - -list(APPEND SOURCE - ss_context.c - ss_triangle.c) - -add_library(mesa_swrast_setup STATIC ${SOURCE}) -add_dependencies(mesa_swrast_setup xdk) diff --git a/dll/opengl/mesa/swrast_setup/ss_context.c b/dll/opengl/mesa/swrast_setup/ss_context.c deleted file mode 100644 index ca2d37603dc..00000000000 --- a/dll/opengl/mesa/swrast_setup/ss_context.c +++ /dev/null @@ -1,230 +0,0 @@ -/* - * Mesa 3-D graphics library - * Version: 7.1 - * - * Copyright (C) 1999-2007 Brian Paul All Rights Reserved. - * - * Permission is hereby granted, free of charge, to any person obtaining a - * copy of this software and associated documentation files (the "Software"), - * to deal in the Software without restriction, including without limitation - * the rights to use, copy, modify, merge, publish, distribute, sublicense, - * and/or sell copies of the Software, and to permit persons to whom the - * Software is furnished to do so, subject to the following conditions: - * - * The above copyright notice and this permission notice shall be included - * in all copies or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS - * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL - * BRIAN PAUL BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN - * AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN - * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. - * - * Authors: - * Keith Whitwell - */ - -#include "main/glheader.h" -#include "main/imports.h" -#include "main/colormac.h" -#include "tnl/tnl.h" -#include "tnl/t_context.h" -#include "tnl/t_pipeline.h" -#include "tnl/t_vertex.h" -#include "swrast_setup.h" -#include "ss_context.h" -#include "ss_triangle.h" - - -/* Need to check lighting state and vertex program state to know - * if two-sided lighting is in effect. - */ -#define _SWSETUP_NEW_RENDERINDEX (_NEW_POLYGON|_NEW_LIGHT) - - -#define VARYING_EMIT_STYLE EMIT_4F - - -GLboolean -_swsetup_CreateContext( struct gl_context *ctx ) -{ - SScontext *swsetup = (SScontext *)CALLOC(sizeof(SScontext)); - - if (!swsetup) - return GL_FALSE; - - ctx->swsetup_context = swsetup; - - swsetup->NewState = ~0; - _swsetup_trifuncs_init( ctx ); - - _tnl_init_vertices( ctx, ctx->Const.MaxArrayLockSize + 12, - sizeof(SWvertex) ); - - - return GL_TRUE; -} - -void -_swsetup_DestroyContext( struct gl_context *ctx ) -{ - SScontext *swsetup = SWSETUP_CONTEXT(ctx); - - if (swsetup) { - FREE(swsetup); - ctx->swsetup_context = 0; - } - - _tnl_free_vertices( ctx ); -} - -static void -_swsetup_RenderPrimitive( struct gl_context *ctx, GLenum mode ) -{ - SWSETUP_CONTEXT(ctx)->render_prim = mode; - _swrast_render_primitive( ctx, mode ); -} - - -/** - * Helper macros for setup_vertex_format() - */ -#define SWZ ((SWvertex *)0) -#define SWOffset(MEMBER) (((char *)&(SWZ->MEMBER)) - ((char *)SWZ)) - -#define EMIT_ATTR( ATTR, STYLE, MEMBER ) \ -do { \ - map[e].attrib = (ATTR); \ - map[e].format = (STYLE); \ - map[e].offset = SWOffset(MEMBER); \ - e++; \ -} while (0) - - -/** - * Tell the tnl module how to build SWvertex objects for swrast. - * We'll build the map[] array with that info and pass it to - * _tnl_install_attrs(). - */ -static void -setup_vertex_format(struct gl_context *ctx) -{ - TNLcontext *tnl = TNL_CONTEXT(ctx); - SScontext *swsetup = SWSETUP_CONTEXT(ctx); - GLboolean intColors = ctx->RenderMode == GL_RENDER - && CHAN_TYPE != GL_FLOAT; - - if (intColors != swsetup->intColors || - tnl->render_inputs_bitset != swsetup->last_index_bitset) { - GLbitfield64 index_bitset = tnl->render_inputs_bitset; - struct tnl_attr_map map[_TNL_ATTRIB_MAX]; - unsigned e = 0; - - swsetup->intColors = intColors; - - EMIT_ATTR( _TNL_ATTRIB_POS, EMIT_4F_VIEWPORT, attrib[FRAG_ATTRIB_WPOS] ); - - if (index_bitset & BITFIELD64_BIT(_TNL_ATTRIB_COLOR)) { - if (swsetup->intColors) - EMIT_ATTR( _TNL_ATTRIB_COLOR, EMIT_4CHAN_4F_RGBA, color ); - else - EMIT_ATTR( _TNL_ATTRIB_COLOR, EMIT_4F, attrib[FRAG_ATTRIB_COL]); - } - - if (index_bitset & BITFIELD64_BIT(_TNL_ATTRIB_FOG)) { - EMIT_ATTR( _TNL_ATTRIB_FOG, EMIT_1F, attrib[FRAG_ATTRIB_FOGC]); - } - - if (index_bitset & BITFIELD64_BIT(_TNL_ATTRIB_TEX)) { - EMIT_ATTR( _TNL_ATTRIB_TEX, EMIT_4F, - attrib[FRAG_ATTRIB_TEX] ); - } - - if (index_bitset & BITFIELD64_BIT(_TNL_ATTRIB_POINTSIZE)) - EMIT_ATTR( _TNL_ATTRIB_POINTSIZE, EMIT_1F, pointSize ); - - _tnl_install_attrs( ctx, map, e, - ctx->Viewport._WindowMap.m, - sizeof(SWvertex) ); - - swsetup->last_index_bitset = index_bitset; - } -} - - -/** - * Prepare to render a vertex buffer. - * Called via tnl->Driver.Render.Start. - */ -static void -_swsetup_RenderStart( struct gl_context *ctx ) -{ - SScontext *swsetup = SWSETUP_CONTEXT(ctx); - TNLcontext *tnl = TNL_CONTEXT(ctx); - struct vertex_buffer *VB = &tnl->vb; - - if (swsetup->NewState & _SWSETUP_NEW_RENDERINDEX) { - _swsetup_choose_trifuncs(ctx); - } - - swsetup->NewState = 0; - - _swrast_render_start(ctx); - - /* Important */ - VB->AttribPtr[VERT_ATTRIB_POS] = VB->NdcPtr; - - setup_vertex_format(ctx); -} - - -/* - * We patch this function into tnl->Driver.Render.Finish. - * It's called when we finish rendering a vertex buffer. - */ -static void -_swsetup_RenderFinish( struct gl_context *ctx ) -{ - _swrast_render_finish( ctx ); -} - -void -_swsetup_InvalidateState( struct gl_context *ctx, GLuint new_state ) -{ - SScontext *swsetup = SWSETUP_CONTEXT(ctx); - swsetup->NewState |= new_state; - _tnl_invalidate_vertex_state( ctx, new_state ); -} - - -void -_swsetup_Wakeup( struct gl_context *ctx ) -{ - TNLcontext *tnl = TNL_CONTEXT(ctx); - SScontext *swsetup = SWSETUP_CONTEXT(ctx); - - tnl->Driver.Render.Start = _swsetup_RenderStart; - tnl->Driver.Render.Finish = _swsetup_RenderFinish; - tnl->Driver.Render.PrimitiveNotify = _swsetup_RenderPrimitive; - tnl->Driver.Render.Interp = _tnl_interp; - tnl->Driver.Render.CopyPV = _tnl_copy_pv; - tnl->Driver.Render.ClippedPolygon = _tnl_RenderClippedPolygon; /* new */ - tnl->Driver.Render.ClippedLine = _tnl_RenderClippedLine; /* new */ - /* points */ - /* line */ - /* triangle */ - /* quad */ - tnl->Driver.Render.PrimTabVerts = _tnl_render_tab_verts; - tnl->Driver.Render.PrimTabElts = _tnl_render_tab_elts; - tnl->Driver.Render.ResetLineStipple = _swrast_ResetLineStipple; - tnl->Driver.Render.BuildVertices = _tnl_build_vertices; - tnl->Driver.Render.Multipass = 0; - - _tnl_invalidate_vertices( ctx, ~0 ); - _tnl_need_projected_coords( ctx, GL_TRUE ); - _swsetup_InvalidateState( ctx, ~0 ); - - swsetup->verts = (SWvertex *)tnl->clipspace.vertex_buf; - swsetup->last_index_bitset = 0; -} diff --git a/dll/opengl/mesa/swrast_setup/ss_context.h b/dll/opengl/mesa/swrast_setup/ss_context.h deleted file mode 100644 index ecc1f5fd6a4..00000000000 --- a/dll/opengl/mesa/swrast_setup/ss_context.h +++ /dev/null @@ -1,45 +0,0 @@ -/* - * Mesa 3-D graphics library - * Version: 7.1 - * - * Copyright (C) 1999-2007 Brian Paul All Rights Reserved. - * - * Permission is hereby granted, free of charge, to any person obtaining a - * copy of this software and associated documentation files (the "Software"), - * to deal in the Software without restriction, including without limitation - * the rights to use, copy, modify, merge, publish, distribute, sublicense, - * and/or sell copies of the Software, and to permit persons to whom the - * Software is furnished to do so, subject to the following conditions: - * - * The above copyright notice and this permission notice shall be included - * in all copies or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS - * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL - * BRIAN PAUL BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN - * AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN - * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. - * - * Authors: - * Keith Whitwell - */ - -#ifndef SS_CONTEXT_H -#define SS_CONTEXT_H - -#include "main/glheader.h" -#include "swrast/swrast.h" -#include "tnl/t_context.h" - -typedef struct { - GLuint NewState; - GLenum render_prim; - GLbitfield64 last_index_bitset; - SWvertex *verts; - GLboolean intColors; -} SScontext; - -#define SWSETUP_CONTEXT(ctx) ((SScontext *)ctx->swsetup_context) - -#endif diff --git a/dll/opengl/mesa/swrast_setup/ss_triangle.c b/dll/opengl/mesa/swrast_setup/ss_triangle.c deleted file mode 100644 index 7684f722735..00000000000 --- a/dll/opengl/mesa/swrast_setup/ss_triangle.c +++ /dev/null @@ -1,253 +0,0 @@ -/* - * Mesa 3-D graphics library - * Version: 7.1 - * - * Copyright (C) 1999-2007 Brian Paul All Rights Reserved. - * - * Permission is hereby granted, free of charge, to any person obtaining a - * copy of this software and associated documentation files (the "Software"), - * to deal in the Software without restriction, including without limitation - * the rights to use, copy, modify, merge, publish, distribute, sublicense, - * and/or sell copies of the Software, and to permit persons to whom the - * Software is furnished to do so, subject to the following conditions: - * - * The above copyright notice and this permission notice shall be included - * in all copies or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS - * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL - * BRIAN PAUL BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN - * AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN - * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. - * - * Authors: - * Keith Whitwell - */ - -#include "main/glheader.h" -#include "main/colormac.h" -#include "main/macros.h" -#include "main/mtypes.h" - -#include "tnl/t_context.h" - -#include "ss_triangle.h" -#include "ss_context.h" - -#define SS_OFFSET_BIT 0x1 -#define SS_TWOSIDE_BIT 0x2 -#define SS_UNFILLED_BIT 0x4 -#define SS_MAX_TRIFUNC 0x8 - -static tnl_triangle_func tri_tab[SS_MAX_TRIFUNC]; -static tnl_quad_func quad_tab[SS_MAX_TRIFUNC]; - - -/* - * Render a triangle respecting edge flags. - */ -typedef void (* swsetup_edge_render_prim_tri)(struct gl_context *ctx, - const GLubyte *ef, - GLuint e0, - GLuint e1, - GLuint e2, - const SWvertex *v0, - const SWvertex *v1, - const SWvertex *v2); - -/* - * Render a triangle using lines and respecting edge flags. - */ -static void -_swsetup_edge_render_line_tri(struct gl_context *ctx, - const GLubyte *ef, - GLuint e0, - GLuint e1, - GLuint e2, - const SWvertex *v0, - const SWvertex *v1, - const SWvertex *v2) -{ - SScontext *swsetup = SWSETUP_CONTEXT(ctx); - - if (swsetup->render_prim == GL_POLYGON) { - if (ef[e2]) _swrast_Line( ctx, v2, v0 ); - if (ef[e0]) _swrast_Line( ctx, v0, v1 ); - if (ef[e1]) _swrast_Line( ctx, v1, v2 ); - } else { - if (ef[e0]) _swrast_Line( ctx, v0, v1 ); - if (ef[e1]) _swrast_Line( ctx, v1, v2 ); - if (ef[e2]) _swrast_Line( ctx, v2, v0 ); - } -} - -/* - * Render a triangle using points and respecting edge flags. - */ -static void -_swsetup_edge_render_point_tri(struct gl_context *ctx, - const GLubyte *ef, - GLuint e0, - GLuint e1, - GLuint e2, - const SWvertex *v0, - const SWvertex *v1, - const SWvertex *v2) -{ - if (ef[e0]) _swrast_Point( ctx, v0 ); - if (ef[e1]) _swrast_Point( ctx, v1 ); - if (ef[e2]) _swrast_Point( ctx, v2 ); - - _swrast_flush(ctx); -} - -/* - * Render a triangle respecting cull and shade model. - */ -static void _swsetup_render_tri(struct gl_context *ctx, - GLuint e0, - GLuint e1, - GLuint e2, - GLuint facing, - swsetup_edge_render_prim_tri render) -{ - SScontext *swsetup = SWSETUP_CONTEXT(ctx); - struct vertex_buffer *VB = &TNL_CONTEXT(ctx)->vb; - GLubyte *ef = VB->EdgeFlag; - SWvertex *verts = swsetup->verts; - SWvertex *v0 = &verts[e0]; - SWvertex *v1 = &verts[e1]; - SWvertex *v2 = &verts[e2]; - - /* cull testing */ - if (ctx->Polygon.CullFlag) { - if (facing == 1 && ctx->Polygon.CullFaceMode != GL_FRONT) - return; - if (facing == 0 && ctx->Polygon.CullFaceMode != GL_BACK) - return; - } - - if (ctx->Light.ShadeModel == GL_FLAT) { - GLchan c[2][4]; - - /* save colors/indexes for v0, v1 vertices */ - COPY_CHAN4(c[0], v0->color); - COPY_CHAN4(c[1], v1->color); - - /* copy v2 color/indexes to v0, v1 indexes */ - COPY_CHAN4(v0->color, v2->color); - COPY_CHAN4(v1->color, v2->color); - render(ctx, ef, e0, e1, e2, v0, v1, v2); - - COPY_CHAN4(v0->color, c[0]); - COPY_CHAN4(v1->color, c[1]); - } - else { - render(ctx, ef, e0, e1, e2, v0, v1, v2); - } -} - -#define SS_COLOR(a,b) UNCLAMPED_FLOAT_TO_RGBA_CHAN(a,b) -#define SS_SPEC(a,b) COPY_4V(a,b) -#define SS_IND(a,b) (a = b) - -#define IND (0) -#define TAG(x) x##_rgba -#include "ss_tritmp.h" - -#define IND (SS_OFFSET_BIT) -#define TAG(x) x##_offset_rgba -#include "ss_tritmp.h" - -#define IND (SS_TWOSIDE_BIT) -#define TAG(x) x##_twoside_rgba -#include "ss_tritmp.h" - -#define IND (SS_OFFSET_BIT|SS_TWOSIDE_BIT) -#define TAG(x) x##_offset_twoside_rgba -#include "ss_tritmp.h" - -#define IND (SS_UNFILLED_BIT) -#define TAG(x) x##_unfilled_rgba -#include "ss_tritmp.h" - -#define IND (SS_OFFSET_BIT|SS_UNFILLED_BIT) -#define TAG(x) x##_offset_unfilled_rgba -#include "ss_tritmp.h" - -#define IND (SS_TWOSIDE_BIT|SS_UNFILLED_BIT) -#define TAG(x) x##_twoside_unfilled_rgba -#include "ss_tritmp.h" - -#define IND (SS_OFFSET_BIT|SS_TWOSIDE_BIT|SS_UNFILLED_BIT) -#define TAG(x) x##_offset_twoside_unfilled_rgba -#include "ss_tritmp.h" - - -void _swsetup_trifuncs_init( struct gl_context *ctx ) -{ - (void) ctx; - - init_rgba(); - init_offset_rgba(); - init_twoside_rgba(); - init_offset_twoside_rgba(); - init_unfilled_rgba(); - init_offset_unfilled_rgba(); - init_twoside_unfilled_rgba(); - init_offset_twoside_unfilled_rgba(); -} - - -static void swsetup_points( struct gl_context *ctx, GLuint first, GLuint last ) -{ - struct vertex_buffer *VB = &TNL_CONTEXT(ctx)->vb; - SWvertex *verts = SWSETUP_CONTEXT(ctx)->verts; - GLuint i; - - if (VB->Elts) { - for (i = first; i < last; i++) - if (VB->ClipMask[VB->Elts[i]] == 0) - _swrast_Point( ctx, &verts[VB->Elts[i]] ); - } - else { - for (i = first; i < last; i++) - if (VB->ClipMask[i] == 0) - _swrast_Point( ctx, &verts[i] ); - } -} - -static void swsetup_line( struct gl_context *ctx, GLuint v0, GLuint v1 ) -{ - SWvertex *verts = SWSETUP_CONTEXT(ctx)->verts; - _swrast_Line( ctx, &verts[v0], &verts[v1] ); -} - - - -void _swsetup_choose_trifuncs( struct gl_context *ctx ) -{ - TNLcontext *tnl = TNL_CONTEXT(ctx); - GLuint ind = 0; - - if (ctx->Polygon.OffsetPoint || - ctx->Polygon.OffsetLine || - ctx->Polygon.OffsetFill) - ind |= SS_OFFSET_BIT; - - if (ctx->Light.Enabled && ctx->Light.Model.TwoSide) - ind |= SS_TWOSIDE_BIT; - - /* We piggyback the two-sided stencil front/back determination on the - * unfilled triangle path. - */ - if (ctx->Polygon.FrontMode != GL_FILL || - ctx->Polygon.BackMode != GL_FILL) - ind |= SS_UNFILLED_BIT; - - tnl->Driver.Render.Triangle = tri_tab[ind]; - tnl->Driver.Render.Quad = quad_tab[ind]; - tnl->Driver.Render.Line = swsetup_line; - tnl->Driver.Render.Points = swsetup_points; -} diff --git a/dll/opengl/mesa/swrast_setup/ss_triangle.h b/dll/opengl/mesa/swrast_setup/ss_triangle.h deleted file mode 100644 index a027f48269e..00000000000 --- a/dll/opengl/mesa/swrast_setup/ss_triangle.h +++ /dev/null @@ -1,38 +0,0 @@ - -/* - * Mesa 3-D graphics library - * Version: 3.5 - * - * Copyright (C) 1999-2001 Brian Paul All Rights Reserved. - * - * Permission is hereby granted, free of charge, to any person obtaining a - * copy of this software and associated documentation files (the "Software"), - * to deal in the Software without restriction, including without limitation - * the rights to use, copy, modify, merge, publish, distribute, sublicense, - * and/or sell copies of the Software, and to permit persons to whom the - * Software is furnished to do so, subject to the following conditions: - * - * The above copyright notice and this permission notice shall be included - * in all copies or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS - * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL - * BRIAN PAUL BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN - * AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN - * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. - * - * Authors: - * Keith Whitwell - */ - -#ifndef SS_TRIANGLE_H -#define SS_TRIANGLE_H - -struct gl_context; - - -void _swsetup_trifuncs_init( struct gl_context *ctx ); -void _swsetup_choose_trifuncs( struct gl_context *ctx ); - -#endif diff --git a/dll/opengl/mesa/swrast_setup/ss_tritmp.h b/dll/opengl/mesa/swrast_setup/ss_tritmp.h deleted file mode 100644 index d4a53076bac..00000000000 --- a/dll/opengl/mesa/swrast_setup/ss_tritmp.h +++ /dev/null @@ -1,239 +0,0 @@ -/* - * Mesa 3-D graphics library - * Version: 7.1 - * - * Copyright (C) 1999-2007 Brian Paul All Rights Reserved. - * - * Permission is hereby granted, free of charge, to any person obtaining a - * copy of this software and associated documentation files (the "Software"), - * to deal in the Software without restriction, including without limitation - * the rights to use, copy, modify, merge, publish, distribute, sublicense, - * and/or sell copies of the Software, and to permit persons to whom the - * Software is furnished to do so, subject to the following conditions: - * - * The above copyright notice and this permission notice shall be included - * in all copies or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS - * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL - * BRIAN PAUL BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN - * AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN - * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. - * - * Authors: - * Keith Whitwell - */ - - -/** - * This is where we handle assigning vertex colors based on front/back - * facing, compute polygon offset and handle glPolygonMode(). - */ -static void TAG(triangle)(struct gl_context *ctx, GLuint e0, GLuint e1, GLuint e2 ) -{ -#if IND & SS_TWOSIDE_BIT - struct vertex_buffer *VB = &TNL_CONTEXT(ctx)->vb; - SScontext *swsetup = SWSETUP_CONTEXT(ctx); - GLchan saved_color[3][4] = { { 0 } }; - GLfloat saved_col0[3][4] = { { 0 } }; -#endif - SWvertex *verts = SWSETUP_CONTEXT(ctx)->verts; - SWvertex *v[3]; -#if IND & SS_OFFSET_BIT - GLfloat z[3]; -#endif - GLfloat oz0, oz1, oz2; - GLenum mode = GL_FILL; - GLuint facing = 0; - - v[0] = &verts[e0]; - v[1] = &verts[e1]; - v[2] = &verts[e2]; - -#if IND & (SS_TWOSIDE_BIT | SS_OFFSET_BIT | SS_UNFILLED_BIT) - { - GLfloat ex = v[0]->attrib[FRAG_ATTRIB_WPOS][0] - v[2]->attrib[FRAG_ATTRIB_WPOS][0]; - GLfloat ey = v[0]->attrib[FRAG_ATTRIB_WPOS][1] - v[2]->attrib[FRAG_ATTRIB_WPOS][1]; - GLfloat fx = v[1]->attrib[FRAG_ATTRIB_WPOS][0] - v[2]->attrib[FRAG_ATTRIB_WPOS][0]; - GLfloat fy = v[1]->attrib[FRAG_ATTRIB_WPOS][1] - v[2]->attrib[FRAG_ATTRIB_WPOS][1]; - GLfloat cc = ex*fy - ey*fx; - -#if IND & (SS_TWOSIDE_BIT | SS_UNFILLED_BIT) - { - facing = (cc < 0.0) ^ ctx->Polygon._FrontBit; - -#if IND & SS_UNFILLED_BIT - mode = facing ? ctx->Polygon.BackMode : ctx->Polygon.FrontMode; -#endif - -#if IND & SS_TWOSIDE_BIT - if (facing == 1) { - if (VB->BackfaceColorPtr) { - GLfloat (*vbcolor)[4] = VB->BackfaceColorPtr->data; - - if (swsetup->intColors) { - COPY_CHAN4(saved_color[0], v[0]->color); - COPY_CHAN4(saved_color[1], v[1]->color); - COPY_CHAN4(saved_color[2], v[2]->color); - } - else { - COPY_4V(saved_col0[0], v[0]->attrib[FRAG_ATTRIB_COL]); - COPY_4V(saved_col0[1], v[1]->attrib[FRAG_ATTRIB_COL]); - COPY_4V(saved_col0[2], v[2]->attrib[FRAG_ATTRIB_COL]); - } - - if (VB->BackfaceColorPtr->stride) { - if (swsetup->intColors) { - SS_COLOR(v[0]->color, vbcolor[e0]); - SS_COLOR(v[1]->color, vbcolor[e1]); - SS_COLOR(v[2]->color, vbcolor[e2]); - } - else { - COPY_4V(v[0]->attrib[FRAG_ATTRIB_COL], vbcolor[e0]); - COPY_4V(v[1]->attrib[FRAG_ATTRIB_COL], vbcolor[e1]); - COPY_4V(v[2]->attrib[FRAG_ATTRIB_COL], vbcolor[e2]); - } - } - else { - /* flat shade */ - if (swsetup->intColors) { - SS_COLOR(v[0]->color, vbcolor[0]); - SS_COLOR(v[1]->color, vbcolor[0]); - SS_COLOR(v[2]->color, vbcolor[0]); - } - else { - COPY_4V(v[0]->attrib[FRAG_ATTRIB_COL], vbcolor[0]); - COPY_4V(v[1]->attrib[FRAG_ATTRIB_COL], vbcolor[0]); - COPY_4V(v[2]->attrib[FRAG_ATTRIB_COL], vbcolor[0]); - } - } - } - } -#endif - } -#endif - -#if IND & SS_OFFSET_BIT - { - GLfloat offset; - const GLfloat max = ctx->DrawBuffer->_DepthMaxF; - /* save original Z values (restored later) */ - z[0] = v[0]->attrib[FRAG_ATTRIB_WPOS][2]; - z[1] = v[1]->attrib[FRAG_ATTRIB_WPOS][2]; - z[2] = v[2]->attrib[FRAG_ATTRIB_WPOS][2]; - /* Note that Z values are already scaled to [0,65535] (for example) - * so no MRD value is used here. - */ - offset = ctx->Polygon.OffsetUnits; - if (cc * cc > 1e-16) { - const GLfloat ez = z[0] - z[2]; - const GLfloat fz = z[1] - z[2]; - const GLfloat oneOverArea = 1.0F / cc; - const GLfloat dzdx = FABSF((ey * fz - ez * fy) * oneOverArea); - const GLfloat dzdy = FABSF((ez * fx - ex * fz) * oneOverArea); - offset += MAX2(dzdx, dzdy) * ctx->Polygon.OffsetFactor; - } - /* new Z values */ - oz0 = CLAMP(v[0]->attrib[FRAG_ATTRIB_WPOS][2] + offset, 0.0F, max); - oz1 = CLAMP(v[1]->attrib[FRAG_ATTRIB_WPOS][2] + offset, 0.0F, max); - oz2 = CLAMP(v[2]->attrib[FRAG_ATTRIB_WPOS][2] + offset, 0.0F, max); - } -#endif - } -#endif - - if (mode == GL_POINT) { - if ((IND & SS_OFFSET_BIT) && ctx->Polygon.OffsetPoint) { - v[0]->attrib[FRAG_ATTRIB_WPOS][2] = oz0; - v[1]->attrib[FRAG_ATTRIB_WPOS][2] = oz1; - v[2]->attrib[FRAG_ATTRIB_WPOS][2] = oz2; - } - _swsetup_render_tri(ctx, e0, e1, e2, facing, _swsetup_edge_render_point_tri); - } else if (mode == GL_LINE) { - if ((IND & SS_OFFSET_BIT) && ctx->Polygon.OffsetLine) { - v[0]->attrib[FRAG_ATTRIB_WPOS][2] = oz0; - v[1]->attrib[FRAG_ATTRIB_WPOS][2] = oz1; - v[2]->attrib[FRAG_ATTRIB_WPOS][2] = oz2; - } - _swsetup_render_tri(ctx, e0, e1, e2, facing, _swsetup_edge_render_line_tri); - } - else { -#if IND & SS_OFFSET_BIT - if (ctx->Polygon.OffsetFill) { - v[0]->attrib[FRAG_ATTRIB_WPOS][2] = oz0; - v[1]->attrib[FRAG_ATTRIB_WPOS][2] = oz1; - v[2]->attrib[FRAG_ATTRIB_WPOS][2] = oz2; - } -#endif - _swrast_Triangle( ctx, v[0], v[1], v[2] ); - } - - /* - * Restore original vertex colors, etc. - */ -#if IND & SS_OFFSET_BIT - { - v[0]->attrib[FRAG_ATTRIB_WPOS][2] = z[0]; - v[1]->attrib[FRAG_ATTRIB_WPOS][2] = z[1]; - v[2]->attrib[FRAG_ATTRIB_WPOS][2] = z[2]; - } -#endif - -#if IND & SS_TWOSIDE_BIT - { - if (facing == 1) { - if (VB->BackfaceColorPtr) { - if (swsetup->intColors) { - COPY_CHAN4(v[0]->color, saved_color[0]); - COPY_CHAN4(v[1]->color, saved_color[1]); - COPY_CHAN4(v[2]->color, saved_color[2]); - } - else { - COPY_4V(v[0]->attrib[FRAG_ATTRIB_COL], saved_col0[0]); - COPY_4V(v[1]->attrib[FRAG_ATTRIB_COL], saved_col0[1]); - COPY_4V(v[2]->attrib[FRAG_ATTRIB_COL], saved_col0[2]); - } - } - } - } -#endif -} - - - -/* Need to fixup edgeflags when decomposing to triangles: - */ -static void TAG(quadfunc)( struct gl_context *ctx, GLuint v0, - GLuint v1, GLuint v2, GLuint v3 ) -{ - if (IND & SS_UNFILLED_BIT) { - struct vertex_buffer *VB = &TNL_CONTEXT(ctx)->vb; - if (VB->EdgeFlag) { /* XXX this test shouldn't be needed (bug 12614) */ - GLubyte ef1 = VB->EdgeFlag[v1]; - GLubyte ef3 = VB->EdgeFlag[v3]; - VB->EdgeFlag[v1] = 0; - TAG(triangle)( ctx, v0, v1, v3 ); - VB->EdgeFlag[v1] = ef1; - VB->EdgeFlag[v3] = 0; - TAG(triangle)( ctx, v1, v2, v3 ); - VB->EdgeFlag[v3] = ef3; - } - } else { - TAG(triangle)( ctx, v0, v1, v3 ); - TAG(triangle)( ctx, v1, v2, v3 ); - } -} - - - - -static void TAG(init)( void ) -{ - tri_tab[IND] = TAG(triangle); - quad_tab[IND] = TAG(quadfunc); -} - - -#undef IND -#undef TAG diff --git a/dll/opengl/mesa/swrast_setup/ss_vb.h b/dll/opengl/mesa/swrast_setup/ss_vb.h deleted file mode 100644 index 05e665b5c30..00000000000 --- a/dll/opengl/mesa/swrast_setup/ss_vb.h +++ /dev/null @@ -1,37 +0,0 @@ - -/* - * Mesa 3-D graphics library - * Version: 3.5 - * - * Copyright (C) 1999-2001 Brian Paul All Rights Reserved. - * - * Permission is hereby granted, free of charge, to any person obtaining a - * copy of this software and associated documentation files (the "Software"), - * to deal in the Software without restriction, including without limitation - * the rights to use, copy, modify, merge, publish, distribute, sublicense, - * and/or sell copies of the Software, and to permit persons to whom the - * Software is furnished to do so, subject to the following conditions: - * - * The above copyright notice and this permission notice shall be included - * in all copies or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS - * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL - * BRIAN PAUL BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN - * AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN - * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. - * - * Authors: - * Keith Whitwell - */ - -#ifndef SS_VB_H -#define SS_VB_H - -struct gl_context; - -void _swsetup_vb_init( struct gl_context *ctx ); -void _swsetup_choose_rastersetup_func( struct gl_context *ctx ); - -#endif diff --git a/dll/opengl/mesa/swrast_setup/swrast_setup.h b/dll/opengl/mesa/swrast_setup/swrast_setup.h deleted file mode 100644 index 56f9144d746..00000000000 --- a/dll/opengl/mesa/swrast_setup/swrast_setup.h +++ /dev/null @@ -1,55 +0,0 @@ - -/* - * Mesa 3-D graphics library - * Version: 3.5 - * - * Copyright (C) 1999-2001 Brian Paul All Rights Reserved. - * - * Permission is hereby granted, free of charge, to any person obtaining a - * copy of this software and associated documentation files (the "Software"), - * to deal in the Software without restriction, including without limitation - * the rights to use, copy, modify, merge, publish, distribute, sublicense, - * and/or sell copies of the Software, and to permit persons to whom the - * Software is furnished to do so, subject to the following conditions: - * - * The above copyright notice and this permission notice shall be included - * in all copies or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS - * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL - * BRIAN PAUL BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN - * AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN - * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. - * - * Authors: - * Keith Whitwell - */ - -/* Public interface to the swrast_setup module. This module provides - * an implementation of the driver interface to t_vb_render.c, and uses - * the software rasterizer (swrast) to perform actual rasterization. - * - * The internals of the implementation are private, but can be hooked - * into tnl at any time (except between RenderStart/RenderEnd) by - * calling _swsetup_Wakeup(). - */ - -#ifndef SWRAST_SETUP_H -#define SWRAST_SETUP_H - -#include "swrast/swrast.h" - -extern GLboolean -_swsetup_CreateContext( struct gl_context *ctx ); - -extern void -_swsetup_DestroyContext( struct gl_context *ctx ); - -extern void -_swsetup_InvalidateState( struct gl_context *ctx, GLuint new_state ); - -extern void -_swsetup_Wakeup( struct gl_context *ctx ); - -#endif diff --git a/dll/opengl/mesa/teximage.c b/dll/opengl/mesa/teximage.c new file mode 100644 index 00000000000..223ca03aa2e --- /dev/null +++ b/dll/opengl/mesa/teximage.c @@ -0,0 +1,1890 @@ +/* $Id: teximage.c,v 1.35 1998/02/07 14:36:41 brianp Exp $ */ + +/* + * Mesa 3-D graphics library + * Version: 2.6 + * Copyright (C) 1995-1997 Brian Paul + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Library General Public + * License as published by the Free Software Foundation; either + * version 2 of the License, or (at your option) any later version. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Library General Public License for more details. + * + * You should have received a copy of the GNU Library General Public + * License along with this library; if not, write to the Free + * Software Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. + */ + + +/* + * $Log: teximage.c,v $ + * Revision 1.35 1998/02/07 14:36:41 brianp + * fixed bug when passing NULL proxy image to glTexImageXD() (Wes Bethel) + * + * Revision 1.34 1998/01/16 03:46:07 brianp + * fixed a few Windows compilation warnings (Theodore Jump) + * + * Revision 1.33 1997/12/31 06:10:03 brianp + * added Henk Kok's texture validation optimization (AnyDirty flag) + * + * Revision 1.32 1997/12/07 17:30:39 brianp + * added DavidB's patches for v0.21 driver (TexSubImage) + * + * Revision 1.31 1997/11/07 03:38:07 brianp + * added stdio.h include for SunOS 4.x + * + * Revision 1.30 1997/11/02 20:20:30 brianp + * rewrote gl_TexSubImage[123]D() + * + * Revision 1.29 1997/10/16 01:14:04 brianp + * removed teximage Dirty flag + * + * Revision 1.28 1997/10/14 00:40:20 brianp + * added DavidB's v19 fxmesa changes + * + * Revision 1.27 1997/09/29 23:28:14 brianp + * updated for new device driver texture functions + * + * Revision 1.26 1997/09/28 15:29:03 brianp + * initialize image->Depth = 1 in read_color_image() (Hiroki Honda) + * + * Revision 1.25 1997/09/27 00:14:39 brianp + * added GL_EXT_paletted_texture extension + * + * Revision 1.24 1997/09/03 13:17:17 brianp + * added a few pointer casts + * + * Revision 1.23 1997/08/23 18:40:46 brianp + * glTexImage[123]D() with NULL image pointer is correctly handled now + * + * Revision 1.22 1997/08/11 01:23:29 brianp + * added a few pointer casts + * + * Revision 1.21 1997/07/24 01:25:34 brianp + * changed precompiled header symbol from PCH to PC_HEADER + * + * Revision 1.20 1997/07/05 16:21:17 brianp + * fixed unitialized variable bug in gl_TexSubImage1D() + * + * Revision 1.19 1997/06/24 01:13:53 brianp + * call gl_free_image() in gl_TexSubImage[123]D() if ref count==0 + * + * Revision 1.18 1997/06/04 00:33:14 brianp + * fixed reference count bug in gl_CopyTexImage1/2D() (Randy Frank) + * + * Revision 1.17 1997/05/28 03:26:49 brianp + * added precompiled header (PCH) support + * + * Revision 1.16 1997/05/03 00:52:19 brianp + * set texture object Dirty flag when changing texture image + * + * Revision 1.15 1997/04/20 20:29:11 brianp + * replaced abort() with gl_problem() + * + * Revision 1.14 1997/03/04 19:18:29 brianp + * added texture image Width2, Height2, and Depth2 fields + * + * Revision 1.13 1997/02/27 19:58:08 brianp + * call gl_problem() instead of gl_warning() + * + * Revision 1.12 1997/02/09 18:53:05 brianp + * added GL_EXT_texture3D support + * + * Revision 1.11 1997/01/16 03:35:10 brianp + * added calls to device driver TexImage() function + * + * Revision 1.10 1997/01/09 21:26:46 brianp + * gl_TexImage[12]D() didn't free the incoming image- a memory leak + * + * Revision 1.9 1997/01/09 19:55:52 brianp + * fixed a few error messages + * + * Revision 1.8 1997/01/09 19:49:18 brianp + * better error checking + * + * Revision 1.7 1996/12/02 18:59:54 brianp + * added code to handle GL_COLOR_INDEX textures, per Randy Frank + * + * Revision 1.6 1996/11/07 04:13:24 brianp + * all new texture image handling, now pixel scale, bias, mapping work + * + * Revision 1.5 1996/09/27 01:29:57 brianp + * removed unused variables, fixed cut&paste bug in color scaling + * + * Revision 1.4 1996/09/26 22:35:10 brianp + * fixed a few compiler warnings from IRIX 6 -n32 and -64 compiler + * + * Revision 1.3 1996/09/15 14:18:55 brianp + * now use GLframebuffer and GLvisual + * + * Revision 1.2 1996/09/15 01:48:58 brianp + * removed #define NULL 0 + * + * Revision 1.1 1996/09/13 01:38:16 brianp + * Initial revision + * + */ + + +#ifdef PC_HEADER +#include "all.h" +#else +#include +#include +#include +#include +#include "context.h" +#include "image.h" +#include "macros.h" +#include "pixel.h" +#include "span.h" +#include "teximage.h" +#include "types.h" +#endif + + +/* + * NOTES: + * + * The internal texture storage convension is an array of N GLubytes + * where N = width * height * components. There is no padding. + */ + + + + +/* + * Compute log base 2 of n. + * If n isn't an exact power of two return -1. + * If n<0 return -1. + */ +static int logbase2( int n ) +{ + GLint i = 1; + GLint log2 = 0; + + if (n<0) { + return -1; + } + + while ( n > i ) { + i *= 2; + log2++; + } + if (i != n) { + return -1; + } + else { + return log2; + } +} + + + +/* + * Given an internal texture format enum or 1, 2, 3, 4 return the + * corresponding _base_ internal format: GL_ALPHA, GL_LUMINANCE, + * GL_LUMANCE_ALPHA, GL_INTENSITY, GL_RGB, or GL_RGBA. Return -1 if + * invalid enum. + */ +static GLint decode_internal_format( GLint format ) +{ + switch (format) { + case GL_ALPHA: + case GL_ALPHA4: + case GL_ALPHA8: + case GL_ALPHA12: + case GL_ALPHA16: + return GL_ALPHA; + case 1: + case GL_LUMINANCE: + case GL_LUMINANCE4: + case GL_LUMINANCE8: + case GL_LUMINANCE12: + case GL_LUMINANCE16: + return GL_LUMINANCE; + case 2: + case GL_LUMINANCE_ALPHA: + case GL_LUMINANCE4_ALPHA4: + case GL_LUMINANCE6_ALPHA2: + case GL_LUMINANCE8_ALPHA8: + case GL_LUMINANCE12_ALPHA4: + case GL_LUMINANCE12_ALPHA12: + case GL_LUMINANCE16_ALPHA16: + return GL_LUMINANCE_ALPHA; + case GL_INTENSITY: + case GL_INTENSITY4: + case GL_INTENSITY8: + case GL_INTENSITY12: + case GL_INTENSITY16: + return GL_INTENSITY; + case 3: + case GL_RGB: + case GL_R3_G3_B2: + case GL_RGB4: + case GL_RGB5: + case GL_RGB8: + case GL_RGB10: + case GL_RGB12: + case GL_RGB16: + return GL_RGB; + case 4: + case GL_RGBA: + case GL_RGBA2: + case GL_RGBA4: + case GL_RGB5_A1: + case GL_RGBA8: + case GL_RGB10_A2: + case GL_RGBA12: + case GL_RGBA16: + return GL_RGBA; + case GL_COLOR_INDEX1_EXT: + case GL_COLOR_INDEX2_EXT: + case GL_COLOR_INDEX4_EXT: + case GL_COLOR_INDEX8_EXT: + case GL_COLOR_INDEX12_EXT: + case GL_COLOR_INDEX16_EXT: + return GL_COLOR_INDEX; + default: + return -1; /* error */ + } +} + + + +/* + * Given an internal texture format enum or 1, 2, 3, 4 return the + * corresponding _base_ internal format: GL_ALPHA, GL_LUMINANCE, + * GL_LUMANCE_ALPHA, GL_INTENSITY, GL_RGB, or GL_RGBA. Return the + * number of components for the format. Return -1 if invalid enum. + */ +static GLint components_in_intformat( GLint format ) +{ + switch (format) { + case GL_ALPHA: + case GL_ALPHA4: + case GL_ALPHA8: + case GL_ALPHA12: + case GL_ALPHA16: + return 1; + case 1: + case GL_LUMINANCE: + case GL_LUMINANCE4: + case GL_LUMINANCE8: + case GL_LUMINANCE12: + case GL_LUMINANCE16: + return 1; + case 2: + case GL_LUMINANCE_ALPHA: + case GL_LUMINANCE4_ALPHA4: + case GL_LUMINANCE6_ALPHA2: + case GL_LUMINANCE8_ALPHA8: + case GL_LUMINANCE12_ALPHA4: + case GL_LUMINANCE12_ALPHA12: + case GL_LUMINANCE16_ALPHA16: + return 2; + case GL_INTENSITY: + case GL_INTENSITY4: + case GL_INTENSITY8: + case GL_INTENSITY12: + case GL_INTENSITY16: + return 1; + case 3: + case GL_RGB: + case GL_R3_G3_B2: + case GL_RGB4: + case GL_RGB5: + case GL_RGB8: + case GL_RGB10: + case GL_RGB12: + case GL_RGB16: + return 3; + case 4: + case GL_RGBA: + case GL_RGBA2: + case GL_RGBA4: + case GL_RGB5_A1: + case GL_RGBA8: + case GL_RGB10_A2: + case GL_RGBA12: + case GL_RGBA16: + return 4; + case GL_COLOR_INDEX1_EXT: + case GL_COLOR_INDEX2_EXT: + case GL_COLOR_INDEX4_EXT: + case GL_COLOR_INDEX8_EXT: + case GL_COLOR_INDEX12_EXT: + case GL_COLOR_INDEX16_EXT: + return 1; + default: + return -1; /* error */ + } +} + + + +struct gl_texture_image *gl_alloc_texture_image( void ) +{ + return (struct gl_texture_image *) calloc( 1, sizeof(struct gl_texture_image) ); +} + + + +void gl_free_texture_image( struct gl_texture_image *teximage ) +{ + if (teximage->Data) { + free( teximage->Data ); + } + free( teximage ); +} + + + +/* + * Given a gl_image, apply the pixel transfer scale, bias, and mapping + * to produce a gl_texture_image. Convert image data to GLubytes. + * Input: image - the incoming gl_image + * internalFormat - desired format of resultant texture + * border - texture border width (0 or 1) + * Return: pointer to a gl_texture_image or NULL if an error occurs. + */ +static struct gl_texture_image * +image_to_texture( GLcontext *ctx, const struct gl_image *image, + GLenum internalFormat, GLint border ) +{ + GLint components; + struct gl_texture_image *texImage; + GLint numPixels, pixel; + GLboolean scaleOrBias; + + assert(image); + assert(image->Width>0); + assert(image->Height>0); + + /* internalFormat = decode_internal_format(internalFormat);*/ + components = components_in_intformat(internalFormat); + numPixels = image->Width * image->Height; + + texImage = gl_alloc_texture_image(); + if (!texImage) + return NULL; + + texImage->Format = decode_internal_format(internalFormat); + texImage->IntFormat = internalFormat; + texImage->Border = border; + texImage->Width = image->Width; + texImage->Height = image->Height; + texImage->WidthLog2 = logbase2(image->Width - 2*border); + if (image->Height==1) /* 1-D texture */ + texImage->HeightLog2 = 0; + else + texImage->HeightLog2 = logbase2(image->Height - 2*border); + texImage->Width2 = 1 << texImage->WidthLog2; + texImage->Height2 = 1 << texImage->HeightLog2; + texImage->MaxLog2 = MAX2( texImage->WidthLog2, texImage->HeightLog2 ); + texImage->Data = (GLubyte *) malloc( numPixels * components ); + + assert(texImage->WidthLog2>=0); + assert(texImage->HeightLog2>=0); + + if (!texImage->Data) { + /* out of memory */ + gl_free_texture_image( texImage ); + return NULL; + } + + /* Determine if scaling and/or biasing is needed */ + if (ctx->Pixel.RedScale!=1.0F || ctx->Pixel.RedBias!=0.0F || + ctx->Pixel.GreenScale!=1.0F || ctx->Pixel.GreenBias!=0.0F || + ctx->Pixel.BlueScale!=1.0F || ctx->Pixel.BlueBias!=0.0F || + ctx->Pixel.AlphaScale!=1.0F || ctx->Pixel.AlphaBias!=0.0F) { + scaleOrBias = GL_TRUE; + } + else { + scaleOrBias = GL_FALSE; + } + + switch (image->Type) { + case GL_BITMAP: + { + GLint shift = ctx->Pixel.IndexShift; + GLint offset = ctx->Pixel.IndexOffset; + /* MapIto[RGBA]Size must be powers of two */ + GLint rMask = ctx->Pixel.MapItoRsize-1; + GLint gMask = ctx->Pixel.MapItoGsize-1; + GLint bMask = ctx->Pixel.MapItoBsize-1; + GLint aMask = ctx->Pixel.MapItoAsize-1; + GLint i, j; + GLubyte *srcPtr = (GLubyte *) image->Data; + + assert( image->Format==GL_COLOR_INDEX ); + + for (j=0; jHeight; j++) { + GLubyte bitMask = 128; + for (i=0; iWidth; i++) { + GLint index; + GLubyte red, green, blue, alpha; + + /* Fetch image color index */ + index = (*srcPtr & bitMask) ? 1 : 0; + bitMask = bitMask >> 1; + if (bitMask==0) { + bitMask = 128; + srcPtr++; + } + /* apply index shift and offset */ + if (shift>=0) { + index = (index << shift) + offset; + } + else { + index = (index >> -shift) + offset; + } + /* convert index to RGBA */ + red = (GLint) (ctx->Pixel.MapItoR[index & rMask] * 255.0F); + green = (GLint) (ctx->Pixel.MapItoG[index & gMask] * 255.0F); + blue = (GLint) (ctx->Pixel.MapItoB[index & bMask] * 255.0F); + alpha = (GLint) (ctx->Pixel.MapItoA[index & aMask] * 255.0F); + + /* store texel (components are GLubytes in [0,255]) */ + pixel = j * image->Width + i; + switch (texImage->Format) { + case GL_ALPHA: + texImage->Data[pixel] = alpha; + break; + case GL_LUMINANCE: + texImage->Data[pixel] = red; + break; + case GL_LUMINANCE_ALPHA: + texImage->Data[pixel*2+0] = red; + texImage->Data[pixel*2+1] = alpha; + break; + case GL_INTENSITY: + texImage->Data[pixel] = red; + break; + case GL_RGB: + texImage->Data[pixel*3+0] = red; + texImage->Data[pixel*3+1] = green; + texImage->Data[pixel*3+2] = blue; + break; + case GL_RGBA: + texImage->Data[pixel*4+0] = red; + texImage->Data[pixel*4+1] = green; + texImage->Data[pixel*4+2] = blue; + texImage->Data[pixel*4+3] = alpha; + break; + default: + gl_problem(ctx,"Bad format in image_to_texture"); + return NULL; + } + } + if (bitMask!=128) { + srcPtr++; + } + } + } + break; + + case GL_UNSIGNED_BYTE: + for (pixel=0; pixelFormat) { + case GL_COLOR_INDEX: + if (decode_internal_format(internalFormat)==GL_COLOR_INDEX) { + /* a paletted texture */ + GLint index = ((GLubyte*)image->Data)[pixel]; + red = index; + } + else { + /* convert color index to RGBA */ + GLint index = ((GLubyte*)image->Data)[pixel]; + red = 255.0F * ctx->Pixel.MapItoR[index]; + green = 255.0F * ctx->Pixel.MapItoG[index]; + blue = 255.0F * ctx->Pixel.MapItoB[index]; + alpha = 255.0F * ctx->Pixel.MapItoA[index]; + } + break; + case GL_RGB: + /* Fetch image RGBA values */ + red = ((GLubyte*) image->Data)[pixel*3+0]; + green = ((GLubyte*) image->Data)[pixel*3+1]; + blue = ((GLubyte*) image->Data)[pixel*3+2]; + alpha = 255; + break; + case GL_BGR_EXT: + blue = ((GLubyte*) image->Data)[pixel*3+0]; + green = ((GLubyte*) image->Data)[pixel*3+1]; + red = ((GLubyte*) image->Data)[pixel*3+2]; + alpha = 255; + break; + case GL_RGBA: + red = ((GLubyte*) image->Data)[pixel*4+0]; + green = ((GLubyte*) image->Data)[pixel*4+1]; + blue = ((GLubyte*) image->Data)[pixel*4+2]; + alpha = ((GLubyte*) image->Data)[pixel*4+3]; + break; + case GL_BGRA_EXT: + blue = ((GLubyte*) image->Data)[pixel*4+0]; + green = ((GLubyte*) image->Data)[pixel*4+1]; + red = ((GLubyte*) image->Data)[pixel*4+2]; + alpha = ((GLubyte*) image->Data)[pixel*4+3]; + break; + case GL_RED: + red = ((GLubyte*) image->Data)[pixel]; + green = 0; + blue = 0; + alpha = 255; + break; + case GL_GREEN: + red = 0; + green = ((GLubyte*) image->Data)[pixel]; + blue = 0; + alpha = 255; + break; + case GL_BLUE: + red = 0; + green = 0; + blue = ((GLubyte*) image->Data)[pixel]; + alpha = 255; + break; + case GL_ALPHA: + red = 0; + green = 0; + blue = 0; + alpha = ((GLubyte*) image->Data)[pixel]; + break; + case GL_LUMINANCE: + red = ((GLubyte*) image->Data)[pixel]; + green = red; + blue = red; + alpha = 255; + break; + case GL_LUMINANCE_ALPHA: + red = ((GLubyte*) image->Data)[pixel*2+0]; + green = red; + blue = red; + alpha = ((GLubyte*) image->Data)[pixel*2+1]; + break; + default: + gl_problem(ctx,"Bad format (2) in image_to_texture"); + return NULL; + } + + if (scaleOrBias || ctx->Pixel.MapColorFlag) { + /* Apply RGBA scale and bias */ + GLfloat r = red * (1.0F/255.0F); + GLfloat g = green * (1.0F/255.0F); + GLfloat b = blue * (1.0F/255.0F); + GLfloat a = alpha * (1.0F/255.0F); + if (scaleOrBias) { + /* r,g,b,a now in [0,1] */ + r = r * ctx->Pixel.RedScale + ctx->Pixel.RedBias; + g = g * ctx->Pixel.GreenScale + ctx->Pixel.GreenBias; + b = b * ctx->Pixel.BlueScale + ctx->Pixel.BlueBias; + a = a * ctx->Pixel.AlphaScale + ctx->Pixel.AlphaBias; + r = CLAMP( r, 0.0F, 1.0F ); + g = CLAMP( g, 0.0F, 1.0F ); + b = CLAMP( b, 0.0F, 1.0F ); + a = CLAMP( a, 0.0F, 1.0F ); + } + /* Apply pixel maps */ + if (ctx->Pixel.MapColorFlag) { + GLint ir = (GLint) (r*ctx->Pixel.MapRtoRsize); + GLint ig = (GLint) (g*ctx->Pixel.MapGtoGsize); + GLint ib = (GLint) (b*ctx->Pixel.MapBtoBsize); + GLint ia = (GLint) (a*ctx->Pixel.MapAtoAsize); + r = ctx->Pixel.MapRtoR[ir]; + g = ctx->Pixel.MapGtoG[ig]; + b = ctx->Pixel.MapBtoB[ib]; + a = ctx->Pixel.MapAtoA[ia]; + } + red = (GLint) (r * 255.0F); + green = (GLint) (g * 255.0F); + blue = (GLint) (b * 255.0F); + alpha = (GLint) (a * 255.0F); + } + + /* store texel (components are GLubytes in [0,255]) */ + switch (texImage->Format) { + case GL_COLOR_INDEX: + texImage->Data[pixel] = red; /* really an index */ + break; + case GL_ALPHA: + texImage->Data[pixel] = alpha; + break; + case GL_LUMINANCE: + texImage->Data[pixel] = red; + break; + case GL_LUMINANCE_ALPHA: + texImage->Data[pixel*2+0] = red; + texImage->Data[pixel*2+1] = alpha; + break; + case GL_INTENSITY: + texImage->Data[pixel] = red; + break; + case GL_RGB: + texImage->Data[pixel*3+0] = red; + texImage->Data[pixel*3+1] = green; + texImage->Data[pixel*3+2] = blue; + break; + case GL_RGBA: + texImage->Data[pixel*4+0] = red; + texImage->Data[pixel*4+1] = green; + texImage->Data[pixel*4+2] = blue; + texImage->Data[pixel*4+3] = alpha; + break; + default: + gl_problem(ctx,"Bad format (3) in image_to_texture"); + return NULL; + } + } + break; + + case GL_FLOAT: + for (pixel=0; pixelFormat) { + case GL_COLOR_INDEX: + if (decode_internal_format(internalFormat)==GL_COLOR_INDEX) { + /* a paletted texture */ + GLint index = (GLint) ((GLfloat*) image->Data)[pixel]; + red = index; + } + else { + GLint shift = ctx->Pixel.IndexShift; + GLint offset = ctx->Pixel.IndexOffset; + /* MapIto[RGBA]Size must be powers of two */ + GLint rMask = ctx->Pixel.MapItoRsize-1; + GLint gMask = ctx->Pixel.MapItoGsize-1; + GLint bMask = ctx->Pixel.MapItoBsize-1; + GLint aMask = ctx->Pixel.MapItoAsize-1; + /* Fetch image color index */ + GLint index = (GLint) ((GLfloat*) image->Data)[pixel]; + /* apply index shift and offset */ + if (shift>=0) { + index = (index << shift) + offset; + } + else { + index = (index >> -shift) + offset; + } + /* convert index to RGBA */ + red = ctx->Pixel.MapItoR[index & rMask]; + green = ctx->Pixel.MapItoG[index & gMask]; + blue = ctx->Pixel.MapItoB[index & bMask]; + alpha = ctx->Pixel.MapItoA[index & aMask]; + } + break; + case GL_RGB: + /* Fetch image RGBA values */ + red = ((GLfloat*) image->Data)[pixel*3+0]; + green = ((GLfloat*) image->Data)[pixel*3+1]; + blue = ((GLfloat*) image->Data)[pixel*3+2]; + alpha = 1.0; + break; + case GL_RGBA: + red = ((GLfloat*) image->Data)[pixel*4+0]; + green = ((GLfloat*) image->Data)[pixel*4+1]; + blue = ((GLfloat*) image->Data)[pixel*4+2]; + alpha = ((GLfloat*) image->Data)[pixel*4+3]; + break; + case GL_RED: + red = ((GLfloat*) image->Data)[pixel]; + green = 0.0; + blue = 0.0; + alpha = 1.0; + break; + case GL_GREEN: + red = 0.0; + green = ((GLfloat*) image->Data)[pixel]; + blue = 0.0; + alpha = 1.0; + break; + case GL_BLUE: + red = 0.0; + green = 0.0; + blue = ((GLfloat*) image->Data)[pixel]; + alpha = 1.0; + break; + case GL_ALPHA: + red = 0.0; + green = 0.0; + blue = 0.0; + alpha = ((GLfloat*) image->Data)[pixel]; + break; + case GL_LUMINANCE: + red = ((GLfloat*) image->Data)[pixel]; + green = red; + blue = red; + alpha = 1.0; + break; + case GL_LUMINANCE_ALPHA: + red = ((GLfloat*) image->Data)[pixel*2+0]; + green = red; + blue = red; + alpha = ((GLfloat*) image->Data)[pixel*2+1]; + break; + default: + gl_problem(ctx,"Bad format (4) in image_to_texture"); + return NULL; + } + + if (image->Format!=GL_COLOR_INDEX) { + /* Apply RGBA scale and bias */ + if (scaleOrBias) { + red = red * ctx->Pixel.RedScale + ctx->Pixel.RedBias; + green = green * ctx->Pixel.GreenScale + ctx->Pixel.GreenBias; + blue = blue * ctx->Pixel.BlueScale + ctx->Pixel.BlueBias; + alpha = alpha * ctx->Pixel.AlphaScale + ctx->Pixel.AlphaBias; + red = CLAMP( red, 0.0F, 1.0F ); + green = CLAMP( green, 0.0F, 1.0F ); + blue = CLAMP( blue, 0.0F, 1.0F ); + alpha = CLAMP( alpha, 0.0F, 1.0F ); + } + /* Apply pixel maps */ + if (ctx->Pixel.MapColorFlag) { + GLint ir = (GLint) (red *ctx->Pixel.MapRtoRsize); + GLint ig = (GLint) (green*ctx->Pixel.MapGtoGsize); + GLint ib = (GLint) (blue *ctx->Pixel.MapBtoBsize); + GLint ia = (GLint) (alpha*ctx->Pixel.MapAtoAsize); + red = ctx->Pixel.MapRtoR[ir]; + green = ctx->Pixel.MapGtoG[ig]; + blue = ctx->Pixel.MapBtoB[ib]; + alpha = ctx->Pixel.MapAtoA[ia]; + } + } + + /* store texel (components are GLubytes in [0,255]) */ + switch (texImage->Format) { + case GL_COLOR_INDEX: + /* a paletted texture */ + texImage->Data[pixel] = (GLint) (red * 255.0F); + break; + case GL_ALPHA: + texImage->Data[pixel] = (GLint) (alpha * 255.0F); + break; + case GL_LUMINANCE: + texImage->Data[pixel] = (GLint) (red * 255.0F); + break; + case GL_LUMINANCE_ALPHA: + texImage->Data[pixel*2+0] = (GLint) (red * 255.0F); + texImage->Data[pixel*2+1] = (GLint) (alpha * 255.0F); + break; + case GL_INTENSITY: + texImage->Data[pixel] = (GLint) (red * 255.0F); + break; + case GL_RGB: + texImage->Data[pixel*3+0] = (GLint) (red * 255.0F); + texImage->Data[pixel*3+1] = (GLint) (green * 255.0F); + texImage->Data[pixel*3+2] = (GLint) (blue * 255.0F); + break; + case GL_RGBA: + texImage->Data[pixel*4+0] = (GLint) (red * 255.0F); + texImage->Data[pixel*4+1] = (GLint) (green * 255.0F); + texImage->Data[pixel*4+2] = (GLint) (blue * 255.0F); + texImage->Data[pixel*4+3] = (GLint) (alpha * 255.0F); + break; + default: + gl_problem(ctx,"Bad format (5) in image_to_texture"); + return NULL; + } + } + break; + + default: + gl_problem(ctx, "Bad image type in image_to_texture"); + return NULL; + } + + return texImage; +} + + + +/* + * glTexImage[123]D can accept a NULL image pointer. In this case we + * create a texture image with unspecified image contents per the OpenGL + * spec. + */ +static struct gl_texture_image * +make_null_texture( GLcontext *ctx, GLenum internalFormat, + GLsizei width, GLsizei height, GLsizei depth, GLint border ) +{ + GLint components; + struct gl_texture_image *texImage; + GLint numPixels; + + /*internalFormat = decode_internal_format(internalFormat);*/ + components = components_in_intformat(internalFormat); + numPixels = width * height * depth; + + texImage = gl_alloc_texture_image(); + if (!texImage) + return NULL; + + texImage->Format = decode_internal_format(internalFormat); + texImage->IntFormat = internalFormat; + texImage->Border = border; + texImage->Width = width; + texImage->Height = height; + texImage->WidthLog2 = logbase2(width - 2*border); + if (height==1) /* 1-D texture */ + texImage->HeightLog2 = 0; + else + texImage->HeightLog2 = logbase2(height - 2*border); + texImage->Width2 = 1 << texImage->WidthLog2; + texImage->Height2 = 1 << texImage->HeightLog2; + texImage->MaxLog2 = MAX2( texImage->WidthLog2, texImage->HeightLog2 ); + + /* XXX should we really allocate memory for the image or let it be NULL? */ + /*texImage->Data = NULL;*/ + + texImage->Data = (GLubyte *) malloc( numPixels * components ); + + /* + * Let's see if anyone finds this. If glTexImage2D() is called with + * a NULL image pointer then load the texture image with something + * interesting instead of leaving it indeterminate. + */ + if (texImage->Data) { + char message[8][32] = { + " X X XXXXX XXX X ", + " XX XX X X X X X ", + " X X X X X X X ", + " X X XXXX XXX XXXXX ", + " X X X X X X ", + " X X X X X X X ", + " X X XXXXX XXX X X ", + " " + }; + + GLubyte *imgPtr = texImage->Data; + GLint i, j, k; + for (i=0;i=MAX_TEXTURE_LEVELS) { + gl_error( ctx, GL_INVALID_VALUE, "glTexImage1D(level)" ); + return GL_TRUE; + } + iformat = decode_internal_format( internalFormat ); + if (iformat<0) { + gl_error( ctx, GL_INVALID_VALUE, "glTexImage1D(internalFormat)" ); + return GL_TRUE; + } + if (border!=0 && border!=1) { + if (target!=GL_PROXY_TEXTURE_1D) { + gl_error( ctx, GL_INVALID_VALUE, "glTexImage1D(border)" ); + } + return GL_TRUE; + } + if (width<2*border || width>2+MAX_TEXTURE_SIZE) { + if (target!=GL_PROXY_TEXTURE_1D) { + gl_error( ctx, GL_INVALID_VALUE, "glTexImage1D(width)" ); + } + return GL_TRUE; + } + if (logbase2( width-2*border )<0) { + gl_error( ctx, GL_INVALID_VALUE, + "glTexImage1D(width != 2^k + 2*border)"); + return GL_TRUE; + } + switch (format) { + case GL_COLOR_INDEX: + case GL_RED: + case GL_GREEN: + case GL_BLUE: + case GL_ALPHA: + case GL_RGB: + case GL_BGR_EXT: + case GL_RGBA: + case GL_BGRA_EXT: + case GL_LUMINANCE: + case GL_LUMINANCE_ALPHA: + /* OK */ + break; + default: + gl_error( ctx, GL_INVALID_ENUM, "glTexImage1D(format)" ); + return GL_TRUE; + } + switch (type) { + case GL_UNSIGNED_BYTE: + case GL_BYTE: + case GL_UNSIGNED_SHORT: + case GL_SHORT: + case GL_FLOAT: + /* OK */ + break; + default: + gl_error( ctx, GL_INVALID_ENUM, "glTexImage1D(type)" ); + return GL_TRUE; + } + return GL_FALSE; +} + + +/* + * Test glTexImagee2D() parameters for errors. + * Return: GL_TRUE = an error was detected, GL_FALSE = no errors + */ +static GLboolean texture_2d_error_check( GLcontext *ctx, GLenum target, + GLint level, GLenum internalFormat, + GLenum format, GLenum type, + GLint width, GLint height, + GLint border ) +{ + GLint iformat; + if (target!=GL_TEXTURE_2D && target!=GL_PROXY_TEXTURE_2D) { + gl_error( ctx, GL_INVALID_ENUM, "glTexImage2D(target)" ); + return GL_TRUE; + } + if (level<0 || level>=MAX_TEXTURE_LEVELS) { + gl_error( ctx, GL_INVALID_VALUE, "glTexImage2D(level)" ); + return GL_TRUE; + } + iformat = decode_internal_format( internalFormat ); + if (iformat<0) { + gl_error( ctx, GL_INVALID_VALUE, "glTexImage2D(internalFormat)" ); + return GL_TRUE; + } + if (border!=0 && border!=1) { + if (target!=GL_PROXY_TEXTURE_2D) { + gl_error( ctx, GL_INVALID_VALUE, "glTexImage2D(border)" ); + } + return GL_TRUE; + } + if (width<2*border || width>2+MAX_TEXTURE_SIZE) { + if (target!=GL_PROXY_TEXTURE_2D) { + gl_error( ctx, GL_INVALID_VALUE, "glTexImage2D(width)" ); + } + return GL_TRUE; + } + if (height<2*border || height>2+MAX_TEXTURE_SIZE) { + if (target!=GL_PROXY_TEXTURE_2D) { + gl_error( ctx, GL_INVALID_VALUE, "glTexImage2D(height)" ); + } + return GL_TRUE; + } + if (logbase2( width-2*border )<0) { + gl_error( ctx,GL_INVALID_VALUE, + "glTexImage2D(width != 2^k + 2*border)"); + return GL_TRUE; + } + if (logbase2( height-2*border )<0) { + gl_error( ctx,GL_INVALID_VALUE, + "glTexImage2D(height != 2^k + 2*border)"); + return GL_TRUE; + } + switch (format) { + case GL_COLOR_INDEX: + case GL_RED: + case GL_GREEN: + case GL_BLUE: + case GL_ALPHA: + case GL_RGB: + case GL_BGR_EXT: + case GL_RGBA: + case GL_BGRA_EXT: + case GL_LUMINANCE: + case GL_LUMINANCE_ALPHA: + /* OK */ + break; + default: + gl_error( ctx, GL_INVALID_ENUM, "glTexImage2D(format)" ); + return GL_TRUE; + } + switch (type) { + case GL_UNSIGNED_BYTE: + case GL_BYTE: + case GL_UNSIGNED_SHORT: + case GL_SHORT: + case GL_UNSIGNED_INT: + case GL_INT: + case GL_FLOAT: + /* OK */ + break; + default: + gl_error( ctx, GL_INVALID_ENUM, "glTexImage2D(type)" ); + return GL_TRUE; + } + return GL_FALSE; +} + + +/* + * Called from the API. Note that width includes the border. + */ +void gl_TexImage1D( GLcontext *ctx, + GLenum target, GLint level, GLint internalformat, + GLsizei width, GLint border, GLenum format, + GLenum type, struct gl_image *image ) +{ + if (INSIDE_BEGIN_END(ctx)) { + gl_error( ctx, GL_INVALID_OPERATION, "glTexImage1D" ); + return; + } + + if (target==GL_TEXTURE_1D) { + struct gl_texture_image *teximage; + if (texture_1d_error_check( ctx, target, level, internalformat, + format, type, width, border )) { + /* error in texture image was detected */ + return; + } + + /* free current texture image, if any */ + if (ctx->Texture.Current1D->Image[level]) { + gl_free_texture_image( ctx->Texture.Current1D->Image[level] ); + } + + /* make new texture from source image */ + if (image) { + teximage = image_to_texture(ctx, image, internalformat, border); + } + else { + teximage = make_null_texture(ctx, internalformat, + width, 1, 1, border); + } + + /* install new texture image */ + ctx->Texture.Current1D->Image[level] = teximage; + ctx->Texture.Current1D->Dirty = GL_TRUE; + ctx->Texture.AnyDirty = GL_TRUE; + ctx->NewState |= NEW_TEXTURING; + + /* free the source image */ + if (image && image->RefCount==0) { + /* if RefCount>0 then image must be in a display list */ + gl_free_image(image); + } + + /* tell driver about change */ + if (ctx->Driver.TexImage) { + (*ctx->Driver.TexImage)( ctx, GL_TEXTURE_1D, + ctx->Texture.Current1D, + level, internalformat, teximage ); + } + } + else if (target==GL_PROXY_TEXTURE_1D) { + /* Proxy texture: check for errors and update proxy state */ + if (texture_1d_error_check( ctx, target, level, internalformat, + format, type, width, border )) { + if (level>=0 && levelTexture.Proxy1D->Image[level], 0, + sizeof(struct gl_texture_image) ); + } + } + else { + ctx->Texture.Proxy1D->Image[level]->Format = internalformat; + ctx->Texture.Proxy1D->Image[level]->Border = border; + ctx->Texture.Proxy1D->Image[level]->Width = width; + ctx->Texture.Proxy1D->Image[level]->Height = 1; + } + if (image && image->RefCount==0) { + /* if RefCount>0 then image must be in a display list */ + gl_free_image(image); + } + } + else { + gl_error( ctx, GL_INVALID_ENUM, "glTexImage1D(target)" ); + return; + } +} + + + + +/* + * Called by the API or display list executor. + * Note that width and height include the border. + */ +void gl_TexImage2D( GLcontext *ctx, + GLenum target, GLint level, GLint internalformat, + GLsizei width, GLsizei height, GLint border, + GLenum format, GLenum type, + struct gl_image *image ) +{ + if (INSIDE_BEGIN_END(ctx)) { + gl_error( ctx, GL_INVALID_OPERATION, "glTexImage2D" ); + return; + } + + if (target==GL_TEXTURE_2D) { + struct gl_texture_image *teximage; + if (texture_2d_error_check( ctx, target, level, internalformat, + format, type, width, height, border )) { + /* error in texture image was detected */ + return; + } + + /* free current texture image, if any */ + if (ctx->Texture.Current2D->Image[level]) { + gl_free_texture_image( ctx->Texture.Current2D->Image[level] ); + } + + /* make new texture from source image */ + if (image) { + teximage = image_to_texture(ctx, image, internalformat, border); + } + else { + teximage = make_null_texture(ctx, internalformat, + width, height, 1, border); + } + + /* install new texture image */ + ctx->Texture.Current2D->Image[level] = teximage; + ctx->Texture.Current2D->Dirty = GL_TRUE; + ctx->Texture.AnyDirty = GL_TRUE; + ctx->NewState |= NEW_TEXTURING; + + /* free the source image */ + if (image && image->RefCount==0) { + /* if RefCount>0 then image must be in a display list */ + gl_free_image(image); + } + + /* tell driver about change */ + if (ctx->Driver.TexImage) { + (*ctx->Driver.TexImage)( ctx, GL_TEXTURE_2D, + ctx->Texture.Current2D, + level, internalformat, teximage ); + } + } + else if (target==GL_PROXY_TEXTURE_2D) { + /* Proxy texture: check for errors and update proxy state */ + if (texture_2d_error_check( ctx, target, level, internalformat, + format, type, width, height, border )) { + if (level>=0 && levelTexture.Proxy2D->Image[level], 0, + sizeof(struct gl_texture_image) ); + } + } + else { + ctx->Texture.Proxy2D->Image[level]->Format = internalformat; + ctx->Texture.Proxy2D->Image[level]->Border = border; + ctx->Texture.Proxy2D->Image[level]->Width = width; + ctx->Texture.Proxy2D->Image[level]->Height = height; + } + if (image && image->RefCount==0) { + /* if RefCount>0 then image must be in a display list */ + gl_free_image(image); + } + } + else { + gl_error( ctx, GL_INVALID_ENUM, "glTexImage2D(target)" ); + return; + } +} + + + +void gl_GetTexImage( GLcontext *ctx, GLenum target, GLint level, GLenum format, + GLenum type, GLvoid *pixels ) +{ + gl_problem(ctx, "glGetTexImage not implemented"); + /* TODO */ +} + + + + +/* + * Unpack the image data given to glTexSubImage[123]D. + * This function is just a wrapper for gl_unpack_image() but it does + * some extra error checking. + */ +struct gl_image * +gl_unpack_texsubimage( GLcontext *ctx, GLint width, GLint height, + GLenum format, GLenum type, const GLvoid *pixels ) +{ + if (type==GL_BITMAP && format!=GL_COLOR_INDEX) { + return NULL; + } + + if (format==GL_STENCIL_INDEX || format==GL_DEPTH_COMPONENT){ + return NULL; + } + + if (gl_sizeof_type(type)<=0) { + return NULL; + } + + return gl_unpack_image( ctx, width, height, format, type, pixels ); +} + + + +void gl_TexSubImage1D( GLcontext *ctx, + GLenum target, GLint level, GLint xoffset, + GLsizei width, GLenum format, GLenum type, + struct gl_image *image ) +{ + struct gl_texture_image *destTex; + + if (target!=GL_TEXTURE_1D) { + gl_error( ctx, GL_INVALID_ENUM, "glTexSubImage1D(target)" ); + return; + } + if (level<0 || level>=MAX_TEXTURE_LEVELS) { + gl_error( ctx, GL_INVALID_ENUM, "glTexSubImage1D(level)" ); + return; + } + + destTex = ctx->Texture.Current1D->Image[level]; + if (!destTex) { + gl_error( ctx, GL_INVALID_OPERATION, "glTexSubImage1D" ); + return; + } + + if (xoffset < -((GLint)destTex->Border)) { + gl_error( ctx, GL_INVALID_VALUE, "glTexSubImage1D(xoffset)" ); + return; + } + if (xoffset + width > destTex->Width + destTex->Border) { + gl_error( ctx, GL_INVALID_VALUE, "glTexSubImage1D(xoffset+width)" ); + return; + } + + if (image) { + /* unpacking must have been error-free */ + GLint texcomponents = components_in_intformat(destTex->Format); + + if (image->Type==GL_UNSIGNED_BYTE && texcomponents==image->Components) { + /* Simple case, just byte copy image data into texture image */ + /* row by row. */ + GLubyte *dst = destTex->Data + texcomponents * xoffset; + GLubyte *src = (GLubyte *) image->Data; + MEMCPY( dst, src, width * texcomponents ); + } + else { + /* General case, convert image pixels into texels, scale, bias, etc */ + struct gl_texture_image *subTexImg = image_to_texture(ctx, image, + destTex->IntFormat, destTex->Border); + GLubyte *dst = destTex->Data + texcomponents * xoffset; + GLubyte *src = subTexImg->Data; + MEMCPY( dst, src, width * texcomponents ); + gl_free_texture_image(subTexImg); + } + + /* if the image's reference count is zero, delete it now */ + if (image->RefCount==0) { + gl_free_image(image); + } + + ctx->Texture.Current1D->Dirty = GL_TRUE; + ctx->Texture.AnyDirty = GL_TRUE; + + /* tell driver about change */ + if (ctx->Driver.TexSubImage) { + (*ctx->Driver.TexSubImage)( ctx, GL_TEXTURE_1D, + ctx->Texture.Current1D, level, + xoffset,0,width,1, + ctx->Texture.Current1D->Image[level]->IntFormat, + destTex ); + } + else { + if (ctx->Driver.TexImage) { + (*ctx->Driver.TexImage)( ctx, GL_TEXTURE_1D, + ctx->Texture.Current1D, + level, ctx->Texture.Current1D->Image[level]->IntFormat, + destTex ); + } + } + } + else { + /* if no image, an error must have occured, do more testing now */ + GLint components, size; + + if (width<0) { + gl_error( ctx, GL_INVALID_VALUE, "glTexSubImage1D(width)" ); + return; + } + if (type==GL_BITMAP && format!=GL_COLOR_INDEX) { + gl_error( ctx, GL_INVALID_ENUM, "glTexSubImage1D(format)" ); + return; + } + components = components_in_intformat( format ); + if (components<0 || format==GL_STENCIL_INDEX + || format==GL_DEPTH_COMPONENT){ + gl_error( ctx, GL_INVALID_ENUM, "glTexSubImage1D(format)" ); + return; + } + size = gl_sizeof_type( type ); + if (size<=0) { + gl_error( ctx, GL_INVALID_ENUM, "glTexSubImage1D(type)" ); + return; + } + /* if we get here, probably ran out of memory during unpacking */ + gl_error( ctx, GL_OUT_OF_MEMORY, "glTexSubImage1D" ); + } +} + + + +void gl_TexSubImage2D( GLcontext *ctx, + GLenum target, GLint level, + GLint xoffset, GLint yoffset, + GLsizei width, GLsizei height, + GLenum format, GLenum type, + struct gl_image *image ) +{ + struct gl_texture_image *destTex; + + if (target!=GL_TEXTURE_2D) { + gl_error( ctx, GL_INVALID_ENUM, "glTexSubImage2D(target)" ); + return; + } + if (level<0 || level>=MAX_TEXTURE_LEVELS) { + gl_error( ctx, GL_INVALID_ENUM, "glTexSubImage2D(level)" ); + return; + } + + destTex = ctx->Texture.Current2D->Image[level]; + if (!destTex) { + gl_error( ctx, GL_INVALID_OPERATION, "glTexSubImage2D" ); + return; + } + + if (xoffset < -((GLint)destTex->Border)) { + gl_error( ctx, GL_INVALID_VALUE, "glTexSubImage2D(xoffset)" ); + return; + } + if (yoffset < -((GLint)destTex->Border)) { + gl_error( ctx, GL_INVALID_VALUE, "glTexSubImage2D(yoffset)" ); + return; + } + if (xoffset + width > destTex->Width + destTex->Border) { + gl_error( ctx, GL_INVALID_VALUE, "glTexSubImage2D(xoffset+width)" ); + return; + } + if (yoffset + height > destTex->Height + destTex->Border) { + gl_error( ctx, GL_INVALID_VALUE, "glTexSubImage2D(yoffset+height)" ); + return; + } + + if (image) { + /* unpacking must have been error-free */ + GLint texcomponents = components_in_intformat(destTex->Format); + + if (image->Type==GL_UNSIGNED_BYTE && texcomponents==image->Components) { + /* Simple case, just byte copy image data into texture image */ + /* row by row. */ + GLubyte *dst = destTex->Data + + (yoffset * destTex->Width + xoffset) * texcomponents; + GLubyte *src = (GLubyte *) image->Data; + GLint j; + for (j=0;jWidth * texcomponents * sizeof(GLubyte); + src += width * texcomponents * sizeof(GLubyte); + } + } + else { + /* General case, convert image pixels into texels, scale, bias, etc */ + struct gl_texture_image *subTexImg = image_to_texture(ctx, image, + destTex->IntFormat, destTex->Border); + GLubyte *dst = destTex->Data + + (yoffset * destTex->Width + xoffset) * texcomponents; + GLubyte *src = subTexImg->Data; + GLint j; + for (j=0;jWidth * texcomponents * sizeof(GLubyte); + src += width * texcomponents * sizeof(GLubyte); + } + gl_free_texture_image(subTexImg); + } + + /* if the image's reference count is zero, delete it now */ + if (image->RefCount==0) { + gl_free_image(image); + } + + ctx->Texture.Current2D->Dirty = GL_TRUE; + ctx->Texture.AnyDirty = GL_TRUE; + + /* tell driver about change */ + if (ctx->Driver.TexSubImage) { + (*ctx->Driver.TexSubImage)( ctx, GL_TEXTURE_2D, ctx->Texture.Current2D, level, + xoffset, yoffset, width, height, + ctx->Texture.Current2D->Image[level]->IntFormat, + destTex ); + } + else { + if (ctx->Driver.TexImage) { + (*ctx->Driver.TexImage)( ctx, GL_TEXTURE_2D, ctx->Texture.Current2D, + level, ctx->Texture.Current2D->Image[level]->IntFormat, + destTex ); + } + } + } + else { + /* if no image, an error must have occured, do more testing now */ + GLint components, size; + + if (width<0) { + gl_error( ctx, GL_INVALID_VALUE, "glTexSubImage2D(width)" ); + return; + } + if (height<0) { + gl_error( ctx, GL_INVALID_VALUE, "glTexSubImage2D(height)" ); + return; + } + if (type==GL_BITMAP && format!=GL_COLOR_INDEX) { + gl_error( ctx, GL_INVALID_ENUM, "glTexSubImage1D(format)" ); + return; + } + components = gl_components_in_format( format ); + if (components<0 || format==GL_STENCIL_INDEX + || format==GL_DEPTH_COMPONENT){ + gl_error( ctx, GL_INVALID_ENUM, "glTexSubImage2D(format)" ); + return; + } + size = gl_sizeof_type( type ); + if (size<=0) { + gl_error( ctx, GL_INVALID_ENUM, "glTexSubImage2D(type)" ); + return; + } + /* if we get here, probably ran out of memory during unpacking */ + gl_error( ctx, GL_OUT_OF_MEMORY, "glTexSubImage2D" ); + } +} + +/* + * Read an RGBA image from the frame buffer. + * Input: ctx - the context + * x, y - lower left corner + * width, height - size of region to read + * format - one of GL_RED, GL_RGB, GL_LUMINANCE, etc. + * Return: gl_image pointer or NULL if out of memory + */ +static struct gl_image *read_color_image( GLcontext *ctx, GLint x, GLint y, + GLsizei width, GLsizei height, + GLint format ) +{ + struct gl_image *image; + GLubyte *imgptr; + GLint components; + GLint i, j; + + components = components_in_intformat( format ); + + /* + * Allocate image struct and image data buffer + */ + image = (struct gl_image *) malloc( sizeof(struct gl_image) ); + if (image) { + image->Width = width; + image->Height = height; + image->Components = components; + image->Format = format; + image->Type = GL_UNSIGNED_BYTE; + image->RefCount = 0; + image->Data = (GLubyte *) malloc( width * height * components ); + if (!image->Data) { + free(image); + return NULL; + } + } + else { + return NULL; + } + + imgptr = (GLubyte *) image->Data; + + /* Select buffer to read from */ + (void) (*ctx->Driver.SetBuffer)( ctx, ctx->Pixel.ReadBuffer ); + + for (j=0;jVisual->EightBitColor) { + /* scale red, green, blue, alpha values to range [0,255] */ + GLfloat rscale = 255.0f * ctx->Visual->InvRedScale; + GLfloat gscale = 255.0f * ctx->Visual->InvGreenScale; + GLfloat bscale = 255.0f * ctx->Visual->InvBlueScale; + GLfloat ascale = 255.0f * ctx->Visual->InvAlphaScale; + for (i=0;iDriver.SetBuffer)( ctx, ctx->Color.DrawBuffer ); + + return image; +} + + + + +void gl_CopyTexImage1D( GLcontext *ctx, + GLenum target, GLint level, + GLenum internalformat, + GLint x, GLint y, + GLsizei width, GLint border ) +{ + GLint format; + struct gl_image *teximage; + + if (INSIDE_BEGIN_END(ctx)) { + gl_error( ctx, GL_INVALID_OPERATION, "glCopyTexImage1D" ); + return; + } + if (target!=GL_TEXTURE_1D) { + gl_error( ctx, GL_INVALID_ENUM, "glCopyTexImage1D(target)" ); + return; + } + if (level<0 || level>=MAX_TEXTURE_LEVELS) { + gl_error( ctx, GL_INVALID_VALUE, "glCopyTexImage1D(level)" ); + return; + } + if (border!=0 && border!=1) { + gl_error( ctx, GL_INVALID_VALUE, "glCopyTexImage1D(border)" ); + return; + } + if (width<2*border || width>2+MAX_TEXTURE_SIZE || width<0) { + gl_error( ctx, GL_INVALID_VALUE, "glCopyTexImage1D(width)" ); + return; + } + format = decode_internal_format( internalformat ); + if (format<0 || (internalformat>=1 && internalformat<=4)) { + gl_error( ctx, GL_INVALID_VALUE, "glCopyTexImage1D(format)" ); + return; + } + + teximage = read_color_image( ctx, x, y, width, 1, format ); + if (!teximage) { + gl_error( ctx, GL_OUT_OF_MEMORY, "glCopyTexImage1D" ); + return; + } + + gl_TexImage1D( ctx, target, level, internalformat, width, + border, GL_RGBA, GL_UNSIGNED_BYTE, teximage ); + + /* teximage was freed in gl_TexImage1D */ +} + + + +void gl_CopyTexImage2D( GLcontext *ctx, + GLenum target, GLint level, GLenum internalformat, + GLint x, GLint y, GLsizei width, GLsizei height, + GLint border ) +{ + GLint format; + struct gl_image *teximage; + + if (INSIDE_BEGIN_END(ctx)) { + gl_error( ctx, GL_INVALID_OPERATION, "glCopyTexImage2D" ); + return; + } + if (target!=GL_TEXTURE_2D) { + gl_error( ctx, GL_INVALID_ENUM, "glCopyTexImage2D(target)" ); + return; + } + if (level<0 || level>=MAX_TEXTURE_LEVELS) { + gl_error( ctx, GL_INVALID_VALUE, "glCopyTexImage2D(level)" ); + return; + } + if (border!=0 && border!=1) { + gl_error( ctx, GL_INVALID_VALUE, "glCopyTexImage2D(border)" ); + return; + } + if (width<2*border || width>2+MAX_TEXTURE_SIZE || width<0) { + gl_error( ctx, GL_INVALID_VALUE, "glCopyTexImage2D(width)" ); + return; + } + if (height<2*border || height>2+MAX_TEXTURE_SIZE || height<0) { + gl_error( ctx, GL_INVALID_VALUE, "glCopyTexImage2D(height)" ); + return; + } + format = decode_internal_format( internalformat ); + if (format<0 || (internalformat>=1 && internalformat<=4)) { + gl_error( ctx, GL_INVALID_VALUE, "glCopyTexImage2D(format)" ); + return; + } + + teximage = read_color_image( ctx, x, y, width, height, format ); + if (!teximage) { + gl_error( ctx, GL_OUT_OF_MEMORY, "glCopyTexImage2D" ); + return; + } + + gl_TexImage2D( ctx, target, level, internalformat, width, height, + border, GL_RGBA, GL_UNSIGNED_BYTE, teximage ); + + /* teximage was freed in gl_TexImage2D */ +} + + + + +/* + * Do the work of glCopyTexSubImage[12]D. + * TODO: apply pixel bias scale and mapping. + */ +static void copy_tex_sub_image( GLcontext *ctx, struct gl_texture_image *dest, + GLint width, GLint height, + GLint srcx, GLint srcy, + GLint dstx, GLint dsty) +{ + GLint i, j; + GLint format, components; + + format = dest->Format; + components = components_in_intformat( format ); + + for (j=0;jVisual->EightBitColor) { + /* scale red, green, blue, alpha values to range [0,255] */ + GLfloat rscale = 255.0f * ctx->Visual->InvRedScale; + GLfloat gscale = 255.0f * ctx->Visual->InvGreenScale; + GLfloat bscale = 255.0f * ctx->Visual->InvBlueScale; + GLfloat ascale = 255.0f * ctx->Visual->InvAlphaScale; + for (i=0;iData + ( (dsty+j) * width + dstx) * components; + + switch (format) { + case GL_ALPHA: + for (i=0;i=MAX_TEXTURE_LEVELS) { + gl_error( ctx, GL_INVALID_VALUE, "glCopyTexSubImage1D(level)" ); + return; + } + if (width<0) { + gl_error( ctx, GL_INVALID_VALUE, "glCopyTexSubImage1D(width)" ); + return; + } + + teximage = ctx->Texture.Current1D->Image[level]; + + if (teximage) { + if (xoffset < -((GLint)teximage->Border)) { + gl_error( ctx, GL_INVALID_VALUE, "glCopyTexSubImage1D(xoffset)" ); + return; + } + /* NOTE: we're adding the border here, not subtracting! */ + if (xoffset+width > teximage->Width+teximage->Border) { + gl_error( ctx, GL_INVALID_VALUE, + "glCopyTexSubImage1D(xoffset+width)" ); + return; + } + if (teximage->Data) { + copy_tex_sub_image( ctx, teximage, width, 1, x, y, xoffset, 0); + } + } + else { + gl_error( ctx, GL_INVALID_OPERATION, "glCopyTexSubImage1D" ); + } +} + + + +void gl_CopyTexSubImage2D( GLcontext *ctx, + GLenum target, GLint level, + GLint xoffset, GLint yoffset, + GLint x, GLint y, GLsizei width, GLsizei height ) +{ + struct gl_texture_image *teximage; + + if (INSIDE_BEGIN_END(ctx)) { + gl_error( ctx, GL_INVALID_OPERATION, "glCopyTexSubImage2D" ); + return; + } + if (target!=GL_TEXTURE_2D) { + gl_error( ctx, GL_INVALID_ENUM, "glCopyTexSubImage2D(target)" ); + return; + } + if (level<0 || level>=MAX_TEXTURE_LEVELS) { + gl_error( ctx, GL_INVALID_VALUE, "glCopyTexSubImage2D(level)" ); + return; + } + if (width<0) { + gl_error( ctx, GL_INVALID_VALUE, "glCopyTexSubImage2D(width)" ); + return; + } + if (height<0) { + gl_error( ctx, GL_INVALID_VALUE, "glCopyTexSubImage2D(height)" ); + return; + } + + teximage = ctx->Texture.Current2D->Image[level]; + + if (teximage) { + if (xoffset < -((GLint)teximage->Border)) { + gl_error( ctx, GL_INVALID_VALUE, "glCopyTexSubImage2D(xoffset)" ); + return; + } + if (yoffset < -((GLint)teximage->Border)) { + gl_error( ctx, GL_INVALID_VALUE, "glCopyTexSubImage2D(yoffset)" ); + return; + } + /* NOTE: we're adding the border here, not subtracting! */ + if (xoffset+width > teximage->Width+teximage->Border) { + gl_error( ctx, GL_INVALID_VALUE, + "glCopyTexSubImage2D(xoffset+width)" ); + return; + } + if (yoffset+height > teximage->Height+teximage->Border) { + gl_error( ctx, GL_INVALID_VALUE, + "glCopyTexSubImage2D(yoffset+height)" ); + return; + } + + if (teximage->Data) { + copy_tex_sub_image( ctx, teximage, width, height, + x, y, xoffset, yoffset); + } + } + else { + gl_error( ctx, GL_INVALID_OPERATION, "glCopyTexSubImage2D" ); + } +} + diff --git a/dll/opengl/mesa/teximage.h b/dll/opengl/mesa/teximage.h new file mode 100644 index 00000000000..2e4efa7ab08 --- /dev/null +++ b/dll/opengl/mesa/teximage.h @@ -0,0 +1,166 @@ +/* $Id: teximage.h,v 1.4 1997/11/02 20:20:47 brianp Exp $ */ + +/* + * Mesa 3-D graphics library + * Version: 2.5 + * Copyright (C) 1995-1997 Brian Paul + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Library General Public + * License as published by the Free Software Foundation; either + * version 2 of the License, or (at your option) any later version. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Library General Public License for more details. + * + * You should have received a copy of the GNU Library General Public + * License along with this library; if not, write to the Free + * Software Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. + */ + + +/* + * $Log: teximage.h,v $ + * Revision 1.4 1997/11/02 20:20:47 brianp + * removed gl_unpack_texsubimage3D() + * + * Revision 1.3 1997/02/09 18:53:05 brianp + * added GL_EXT_texture3D support + * + * Revision 1.2 1996/11/07 04:13:24 brianp + * all new texture image handling, now pixel scale, bias, mapping work + * + * Revision 1.1 1996/09/13 01:38:16 brianp + * Initial revision + * + */ + + +#ifndef TEXIMAGE_H +#define TEXIMAGE_H + + +#include "types.h" + + +/*** Internal functions ***/ + + +extern struct gl_texture_image *gl_alloc_texture_image( void ); + + +extern void gl_free_texture_image( struct gl_texture_image *teximage ); + + +extern struct gl_image * +gl_unpack_texsubimage( GLcontext *ctx, GLint width, GLint height, + GLenum format, GLenum type, const GLvoid *pixels ); + + +extern struct gl_texture_image * +gl_unpack_texture( GLcontext *ctx, + GLint dimensions, + GLenum target, + GLint level, + GLint internalformat, + GLsizei width, GLsizei height, + GLint border, + GLenum format, GLenum type, + const GLvoid *pixels ); + +extern struct gl_texture_image * +gl_unpack_texture3D( GLcontext *ctx, + GLint dimensions, + GLenum target, + GLint level, + GLint internalformat, + GLsizei width, GLsizei height, GLsizei depth, + GLint border, + GLenum format, GLenum type, + const GLvoid *pixels ); + + +extern void gl_tex_image_1D( GLcontext *ctx, + GLenum target, GLint level, GLint internalformat, + GLsizei width, GLint border, GLenum format, + GLenum type, const GLvoid *pixels ); + + +extern void gl_tex_image_2D( GLcontext *ctx, + GLenum target, GLint level, GLint internalformat, + GLsizei width, GLint height, GLint border, + GLenum format, GLenum type, + const GLvoid *pixels ); + +extern void gl_tex_image_3D( GLcontext *ctx, + GLenum target, GLint level, GLint internalformat, + GLsizei width, GLint height, GLint depth, + GLint border, + GLenum format, GLenum type, + const GLvoid *pixels ); + + +/*** API entry points ***/ + + +extern void gl_TexImage1D( GLcontext *ctx, + GLenum target, GLint level, GLint internalformat, + GLsizei width, GLint border, GLenum format, + GLenum type, struct gl_image *teximage ); + + +extern void gl_TexImage2D( GLcontext *ctx, + GLenum target, GLint level, GLint internalformat, + GLsizei width, GLsizei height, GLint border, + GLenum format, GLenum type, + struct gl_image *teximage ); + +extern void gl_GetTexImage( GLcontext *ctx, GLenum target, GLint level, + GLenum format, GLenum type, GLvoid *pixels ); + + + +extern void gl_TexSubImage1D( GLcontext *ctx, + GLenum target, GLint level, GLint xoffset, + GLsizei width, GLenum format, GLenum type, + struct gl_image *image ); + + +extern void gl_TexSubImage2D( GLcontext *ctx, + GLenum target, GLint level, + GLint xoffset, GLint yoffset, + GLsizei width, GLsizei height, + GLenum format, GLenum type, + struct gl_image *image ); + + +extern void gl_CopyTexImage1D( GLcontext *ctx, + GLenum target, GLint level, + GLenum internalformat, + GLint x, GLint y, + GLsizei width, GLint border ); + + +extern void gl_CopyTexImage2D( GLcontext *ctx, + GLenum target, GLint level, + GLenum internalformat, GLint x, GLint y, + GLsizei width, GLsizei height, + GLint border ); + + +extern void gl_CopyTexSubImage1D( GLcontext *ctx, + GLenum target, GLint level, + GLint xoffset, GLint x, GLint y, + GLsizei width ); + + +extern void gl_CopyTexSubImage2D( GLcontext *ctx, + GLenum target, GLint level, + GLint xoffset, GLint yoffset, + GLint x, GLint y, + GLsizei width, GLsizei height ); + +#endif + diff --git a/dll/opengl/mesa/texobj.c b/dll/opengl/mesa/texobj.c new file mode 100644 index 00000000000..e01f8019e94 --- /dev/null +++ b/dll/opengl/mesa/texobj.c @@ -0,0 +1,597 @@ +/* $Id: texobj.c,v 1.21 1998/01/16 01:09:44 brianp Exp $ */ + +/* + * Mesa 3-D graphics library + * Version: 2.6 + * Copyright (C) 1995-1997 Brian Paul + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Library General Public + * License as published by the Free Software Foundation; either + * version 2 of the License, or (at your option) any later version. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Library General Public License for more details. + * + * You should have received a copy of the GNU Library General Public + * License along with this library; if not, write to the Free + * Software Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. + */ + + +/* + * $Log: texobj.c,v $ + * Revision 1.21 1998/01/16 01:09:44 brianp + * glGenTextures() didn't reserve the returned texture IDs + * + * Revision 1.20 1997/12/07 17:34:05 brianp + * added DavidB's v0.21 fxmesa driver patch + * + * Revision 1.19 1997/11/07 03:38:07 brianp + * added stdio.h include for SunOS 4.x + * + * Revision 1.18 1997/10/13 23:57:59 brianp + * added target parameter to Driver.BindTexture() + * + * Revision 1.17 1997/09/29 23:28:14 brianp + * updated for new device driver texture functions + * + * Revision 1.16 1997/09/27 00:14:39 brianp + * added GL_EXT_paletted_texture extension + * + * Revision 1.15 1997/09/23 00:58:15 brianp + * now using hash table for texture objects + * + * Revision 1.14 1997/08/23 18:41:40 brianp + * fixed bug in glBindTexture() when binding an incomplete texture image + * + * Revision 1.13 1997/08/23 17:14:44 brianp + * fixed bug: glBindTexture(target, 0) caused segfault + * + * Revision 1.12 1997/07/24 01:25:34 brianp + * changed precompiled header symbol from PCH to PC_HEADER + * + * Revision 1.11 1997/05/28 03:26:49 brianp + * added precompiled header (PCH) support + * + * Revision 1.10 1997/05/17 03:41:49 brianp + * added code to update ctx->Texture.Current in gl_BindTexture() + * + * Revision 1.9 1997/05/03 00:52:52 brianp + * removed a few unused variables + * + * Revision 1.8 1997/05/01 02:08:12 brianp + * new implementation of gl_BindTexture() + * + * Revision 1.7 1997/04/28 23:38:45 brianp + * added gl_test_texture_object_completeness() + * + * Revision 1.6 1997/04/14 02:03:05 brianp + * added MinMagThresh to texture object + * + * Revision 1.5 1997/02/09 18:52:15 brianp + * added GL_EXT_texture3D support + * + * Revision 1.4 1997/01/16 03:35:34 brianp + * added calls to device driver DeleteTexture() and BindTexture() functions + * + * Revision 1.3 1997/01/09 19:49:47 brianp + * added a check to switch rasterizers if needed in glBindTexture() + * + * Revision 1.2 1996/09/27 17:09:42 brianp + * removed a redundant return statement + * + * Revision 1.1 1996/09/13 01:38:16 brianp + * Initial revision + * + */ + + +#ifdef PC_HEADER +#include "all.h" +#else +#include +#include +#include +#include "context.h" +#include "hash.h" +#include "macros.h" +#include "teximage.h" +#include "texobj.h" +#include "types.h" +#endif + + + +/* + * Allocate a new texture object and add it to the linked list of texture + * objects. If name>0 then also insert the new texture object into the hash + * table. + * Input: shared - the shared GL state structure to contain the texture object + * name - integer name for the texture object + * dimensions - either 1, 2 or 3 + * Return: pointer to new texture object + */ +struct gl_texture_object * +gl_alloc_texture_object( struct gl_shared_state *shared, GLuint name, + GLuint dimensions) +{ + struct gl_texture_object *obj; + + assert(dimensions >= 0 && dimensions <= 2); + + obj = (struct gl_texture_object *) + calloc(1,sizeof(struct gl_texture_object)); + if (obj) { + /* init the non-zero fields */ + obj->Name = name; + obj->Dimensions = dimensions; + obj->WrapS = GL_REPEAT; + obj->WrapT = GL_REPEAT; + obj->MinFilter = GL_NEAREST_MIPMAP_LINEAR; + obj->MagFilter = GL_LINEAR; + obj->MinMagThresh = 0.0F; + obj->Palette[0] = 255; + obj->Palette[1] = 255; + obj->Palette[2] = 255; + obj->Palette[3] = 255; + obj->PaletteSize = 1; + obj->PaletteIntFormat = GL_RGBA; + obj->PaletteFormat = GL_RGBA; + + /* insert into linked list */ + if (shared) { + obj->Next = shared->TexObjectList; + shared->TexObjectList = obj; + } + + if (name > 0) { + /* insert into hash table */ + HashInsert(shared->TexObjects, name, obj); + } + } + return obj; +} + + +/* + * Deallocate a texture object struct and remove it from the given + * shared GL state. + * Input: shared - the shared GL state to which the object belongs + * t - the texture object to delete + */ +void gl_free_texture_object( struct gl_shared_state *shared, + struct gl_texture_object *t ) +{ + struct gl_texture_object *tprev, *tcurr; + + assert(t); + + /* unlink t from the linked list */ + if (shared) { + tprev = NULL; + tcurr = shared->TexObjectList; + while (tcurr) { + if (tcurr==t) { + if (tprev) { + tprev->Next = t->Next; + } + else { + shared->TexObjectList = t->Next; + } + break; + } + tprev = tcurr; + tcurr = tcurr->Next; + } + } + + if (t->Name) { + /* remove from hash table */ + HashRemove(shared->TexObjects, t->Name); + } + + /* free texture image */ + { + GLuint i; + for (i=0;iImage[i]) { + gl_free_texture_image( t->Image[i] ); + } + } + } + /* free this object */ + free( t ); +} + + + +/* + * Examine a texture object to determine if it is complete or not. + * The t->Complete flag will be set to GL_TRUE or GL_FALSE accordingly. + */ +void gl_test_texture_object_completeness( struct gl_texture_object *t ) +{ + t->Complete = GL_TRUE; /* be optimistic */ + + /* Always need level zero image */ + if (!t->Image[0] || !t->Image[0]->Data) { + t->Complete = GL_FALSE; + return; + } + + if (t->MinFilter!=GL_NEAREST && t->MinFilter!=GL_LINEAR) { + /* + * Mipmapping: determine if we have a complete set of mipmaps + */ + int i; + + /* Test dimension-independent attributes */ + for (i=1; iImage[i]) { + if (!t->Image[i]->Data) { + t->Complete = GL_FALSE; + return; + } + if (t->Image[i]->Format != t->Image[0]->Format) { + t->Complete = GL_FALSE; + return; + } + if (t->Image[i]->Border != t->Image[0]->Border) { + t->Complete = GL_FALSE; + return; + } + } + } + + /* Test things which depend on number of texture image dimensions */ + if (t->Dimensions==1) { + /* Test 1-D mipmaps */ + GLuint width = t->Image[0]->Width2; + for (i=1; i1) { + width /= 2; + } + if (!t->Image[i]) { + t->Complete = GL_FALSE; + return; + } + if (!t->Image[i]->Data) { + t->Complete = GL_FALSE; + return; + } + if (t->Image[i]->Format != t->Image[0]->Format) { + t->Complete = GL_FALSE; + return; + } + if (t->Image[i]->Border != t->Image[0]->Border) { + t->Complete = GL_FALSE; + return; + } + if (t->Image[i]->Width2 != width ) { + t->Complete = GL_FALSE; + return; + } + if (width==1) { + return; /* found smallest needed mipmap, all done! */ + } + } + } + else if (t->Dimensions==2) { + /* Test 2-D mipmaps */ + GLuint width = t->Image[0]->Width2; + GLuint height = t->Image[0]->Height2; + for (i=1; i1) { + width /= 2; + } + if (height>1) { + height /= 2; + } + if (!t->Image[i]) { + t->Complete = GL_FALSE; + return; + } + if (t->Image[i]->Width2 != width) { + t->Complete = GL_FALSE; + return; + } + if (t->Image[i]->Height2 != height) { + t->Complete = GL_FALSE; + return; + } + if (width==1 && height==1) { + return; /* found smallest needed mipmap, all done! */ + } + } + } + else { + /* Dimensions = ??? */ + gl_problem(NULL, "Bug in gl_test_texture_object_completeness\n"); + } + } +} + + + +/* + * Execute glGenTextures + */ +void gl_GenTextures( GLcontext *ctx, GLsizei n, GLuint *texName ) +{ + GLuint first, i; + + if (INSIDE_BEGIN_END(ctx)) { + gl_error( ctx, GL_INVALID_OPERATION, "glGenTextures" ); + return; + } + if (n<0) { + gl_error( ctx, GL_INVALID_VALUE, "glGenTextures" ); + return; + } + + first = HashFindFreeKeyBlock(ctx->Shared->TexObjects, n); + + /* Return the texture names */ + for (i=0;iShared, name, dims); + (void)newTexObj; + } +} + + + +/* + * Execute glDeleteTextures + */ +void gl_DeleteTextures( GLcontext *ctx, GLsizei n, const GLuint *texName) +{ + GLuint i; + + if (INSIDE_BEGIN_END(ctx)) { + gl_error( ctx, GL_INVALID_OPERATION, "glAreTexturesResident" ); + return; + } + + for (i=0;i0) { + t = (struct gl_texture_object *) + HashLookup(ctx->Shared->TexObjects, texName[i]); + if (t) { + if (ctx->Texture.Current1D==t) { + /* revert to default 1-D texture */ + ctx->Texture.Current1D = ctx->Shared->Default1D; + t->RefCount--; + assert( t->RefCount >= 0 ); + } + else if (ctx->Texture.Current2D==t) { + /* revert to default 2-D texture */ + ctx->Texture.Current2D = ctx->Shared->Default2D; + t->RefCount--; + assert( t->RefCount >= 0 ); + } + + /* tell device driver to delete texture */ + if (ctx->Driver.DeleteTexture) { + (*ctx->Driver.DeleteTexture)( ctx, t ); + } + + if (t->RefCount==0) { + gl_free_texture_object(ctx->Shared, t); + } + } + } + } +} + + + +/* + * Execute glBindTexture + */ +void gl_BindTexture( GLcontext *ctx, GLenum target, GLuint texName ) +{ + struct gl_texture_object *oldTexObj; + struct gl_texture_object *newTexObj; + struct gl_texture_object **targetPointer; + GLuint targetDimensions; + + if (INSIDE_BEGIN_END(ctx)) { + gl_error( ctx, GL_INVALID_OPERATION, "glAreTexturesResident" ); + return; + } + switch (target) { + case GL_TEXTURE_1D: + oldTexObj = ctx->Texture.Current1D; + targetPointer = &ctx->Texture.Current1D; + targetDimensions = 1; + break; + case GL_TEXTURE_2D: + oldTexObj = ctx->Texture.Current2D; + targetPointer = &ctx->Texture.Current2D; + targetDimensions = 2; + break; + default: + gl_error( ctx, GL_INVALID_ENUM, "glBindTexture" ); + return; + } + + if (texName==0) { + /* use default n-D texture */ + switch (target) { + case GL_TEXTURE_1D: + newTexObj = ctx->Shared->Default1D; + break; + case GL_TEXTURE_2D: + newTexObj = ctx->Shared->Default2D; + break; + default: + gl_problem(ctx, "Bad target in gl_BindTexture"); + return; + } + } + else { + newTexObj = (struct gl_texture_object *) + HashLookup(ctx->Shared->TexObjects, texName); + if (newTexObj) { + if (newTexObj->Dimensions == 0) { + /* first time bound */ + newTexObj->Dimensions = targetDimensions; + } + else if (newTexObj->Dimensions != targetDimensions) { + /* wrong dimensionality */ + gl_error( ctx, GL_INVALID_OPERATION, "glBindTextureEXT" ); + return; + } + } + else { + /* create new texture object */ + newTexObj = gl_alloc_texture_object(ctx->Shared, texName, + targetDimensions); + } + } + + /* Update the Texture.Current[123]D pointer */ + *targetPointer = newTexObj; + + /* Tidy up reference counting */ + if (*targetPointer != oldTexObj && oldTexObj->Name>0) { + /* decrement reference count of the prev texture object */ + oldTexObj->RefCount--; + assert( oldTexObj->RefCount >= 0 ); + } + + if (newTexObj->Name>0) { + newTexObj->RefCount++; + } + + /* Check if we may have to use a new triangle rasterizer */ + if ( oldTexObj->WrapS != newTexObj->WrapS + || oldTexObj->WrapT != newTexObj->WrapT + || oldTexObj->WrapR != newTexObj->WrapR + || oldTexObj->MinFilter != newTexObj->MinFilter + || oldTexObj->MagFilter != newTexObj->MagFilter + || (oldTexObj->Image[0] && newTexObj->Image[0] && + (oldTexObj->Image[0]->Format!=newTexObj->Image[0]->Format)) + || !newTexObj->Complete) { + ctx->NewState |= NEW_RASTER_OPS; + } + + /* If we've changed the Current[123]D texture object then update the + * ctx->Texture.Current pointer to point to the new texture object. + */ + if (oldTexObj==ctx->Texture.Current) { + ctx->Texture.Current = newTexObj; + } + + /* The current n-D texture object can never be NULL! */ + assert(*targetPointer); + + /* Pass BindTexture call to device driver */ + if (ctx->Driver.BindTexture) { + (*ctx->Driver.BindTexture)( ctx, target, newTexObj ); + } +} + + + +/* + * Execute glPrioritizeTextures + */ +void gl_PrioritizeTextures( GLcontext *ctx, + GLsizei n, const GLuint *texName, + const GLclampf *priorities ) +{ + GLuint i; + + if (INSIDE_BEGIN_END(ctx)) { + gl_error( ctx, GL_INVALID_OPERATION, "glAreTexturesResident" ); + return; + } + if (n<0) { + gl_error( ctx, GL_INVALID_VALUE, "glAreTexturesResident(n)" ); + return; + } + + for (i=0;i0) { + t = (struct gl_texture_object *) + HashLookup(ctx->Shared->TexObjects, texName[i]); + if (t) { + t->Priority = CLAMP( priorities[i], 0.0F, 1.0F ); + } + } + } +} + + + +/* + * Execute glAreTexturesResident + */ +GLboolean gl_AreTexturesResident( GLcontext *ctx, GLsizei n, + const GLuint *texName, + GLboolean *residences ) +{ + GLboolean resident = GL_TRUE; + GLuint i; + + if (INSIDE_BEGIN_END(ctx)) { + gl_error( ctx, GL_INVALID_OPERATION, "glAreTexturesResident" ); + return GL_FALSE; + } + if (n<0) { + gl_error( ctx, GL_INVALID_VALUE, "glAreTexturesResident(n)" ); + return GL_FALSE; + } + + for (i=0;iShared->TexObjects, texName[i]); + if (t) { + /* we consider all valid texture objects to be resident */ + residences[i] = GL_TRUE; + } + else { + gl_error( ctx, GL_INVALID_VALUE, "glAreTexturesResident(textures)" ); + return GL_FALSE; + } + } + return resident; +} + + + +/* + * Execute glIsTexture + */ +GLboolean gl_IsTexture( GLcontext *ctx, GLuint texture ) +{ + if (INSIDE_BEGIN_END(ctx)) { + gl_error( ctx, GL_INVALID_OPERATION, "glIsTextures" ); + return GL_FALSE; + } + if (texture>0 && HashLookup(ctx->Shared->TexObjects, texture)) { + return GL_TRUE; + } + else { + return GL_FALSE; + } +} + diff --git a/dll/opengl/mesa/texobj.h b/dll/opengl/mesa/texobj.h new file mode 100644 index 00000000000..7f28165f06b --- /dev/null +++ b/dll/opengl/mesa/texobj.h @@ -0,0 +1,88 @@ +/* $Id: texobj.h,v 1.3 1997/09/23 00:58:15 brianp Exp $ */ + +/* + * Mesa 3-D graphics library + * Version: 2.3 + * Copyright (C) 1995-1996 Brian Paul + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Library General Public + * License as published by the Free Software Foundation; either + * version 2 of the License, or (at your option) any later version. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Library General Public License for more details. + * + * You should have received a copy of the GNU Library General Public + * License along with this library; if not, write to the Free + * Software Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. + */ + + +/* + * $Log: texobj.h,v $ + * Revision 1.3 1997/09/23 00:58:15 brianp + * now using hash table for texture objects + * + * Revision 1.2 1997/04/28 23:37:34 brianp + * added gl_test_texture_object_completeness() + * + * Revision 1.1 1996/09/13 01:38:16 brianp + * Initial revision + * + */ + + +#ifndef TEXTOBJ_H +#define TEXTOBJ_H + + +#include "types.h" + + +/* + * Internal functions + */ + +extern struct gl_texture_object * +gl_alloc_texture_object( struct gl_shared_state *shared, GLuint name, + GLuint dimensions ); + + +extern void gl_free_texture_object( struct gl_shared_state *shared, + struct gl_texture_object *t ); + + +extern void gl_test_texture_object_completeness( struct gl_texture_object *t ); + + +/* + * API functions + */ + +extern void gl_GenTextures( GLcontext *ctx, GLsizei n, GLuint *textures ); + + +extern void gl_DeleteTextures( GLcontext *ctx, + GLsizei n, const GLuint *textures); + + +extern void gl_BindTexture( GLcontext *ctx, GLenum target, GLuint texture ); + + +extern void gl_PrioritizeTextures( GLcontext *ctx, + GLsizei n, const GLuint *textures, + const GLclampf *priorities ); + + +extern GLboolean gl_AreTexturesResident( GLcontext *ctx, GLsizei n, + const GLuint *textures, + GLboolean *residences ); + + +extern GLboolean gl_IsTexture( GLcontext *ctx, GLuint texture ); + + +#endif diff --git a/dll/opengl/mesa/texstate.c b/dll/opengl/mesa/texstate.c new file mode 100644 index 00000000000..51843d7d298 --- /dev/null +++ b/dll/opengl/mesa/texstate.c @@ -0,0 +1,988 @@ +/* $Id: texstate.c,v 1.10 1998/02/03 23:45:02 brianp Exp $ */ + +/* + * Mesa 3-D graphics library + * Version: 2.6 + * Copyright (C) 1995-1997 Brian Paul + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Library General Public + * License as published by the Free Software Foundation; either + * version 2 of the License, or (at your option) any later version. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Library General Public License for more details. + * + * You should have received a copy of the GNU Library General Public + * License along with this library; if not, write to the Free + * Software Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. + */ + + +/* + * $Log: texstate.c,v $ + * Revision 1.10 1998/02/03 23:45:02 brianp + * added casts to prevent warnings with Amiga StormC compiler + * + * Revision 1.9 1997/12/31 06:10:03 brianp + * added Henk Kok's texture validation optimization (AnyDirty flag) + * + * Revision 1.8 1997/10/13 23:56:01 brianp + * replaced UpdateTexture() call with TexParameter() + * + * Revision 1.7 1997/09/29 23:28:14 brianp + * updated for new device driver texture functions + * + * Revision 1.6 1997/09/27 00:14:39 brianp + * added GL_EXT_paletted_texture extension + * + * Revision 1.5 1997/07/24 01:25:34 brianp + * changed precompiled header symbol from PCH to PC_HEADER + * + * Revision 1.4 1997/05/28 03:26:49 brianp + * added precompiled header (PCH) support + * + * Revision 1.3 1997/05/03 00:53:28 brianp + * misc changes related to new texture object sampling function pointer + * + * Revision 1.2 1997/04/28 23:34:39 brianp + * simplified gl_update_texture_state() + * + * Revision 1.1 1997/04/14 01:59:54 brianp + * Initial revision + * + */ + + +#ifdef PC_HEADER +#include "all.h" +#else +#include "context.h" +#include "macros.h" +#include "matrix.h" +#include "texobj.h" +#include "texstate.h" +#include "texture.h" +#include "types.h" +#include "xform.h" +#endif + + +#ifdef SPECIALCAST +/* Needed for an Amiga compiler */ +#define ENUM_TO_FLOAT(X) ((GLfloat)(GLint)(X)) +#define ENUM_TO_DOUBLE(X) ((GLdouble)(GLint)(X)) +#else +/* all other compilers */ +#define ENUM_TO_FLOAT(X) ((GLfloat)(X)) +#define ENUM_TO_DOUBLE(X) ((GLdouble)(X)) +#endif + + + +/**********************************************************************/ +/* Texture Environment */ +/**********************************************************************/ + + +void gl_TexEnvfv( GLcontext *ctx, + GLenum target, GLenum pname, const GLfloat *param ) +{ + if (INSIDE_BEGIN_END(ctx)) { + gl_error( ctx, GL_INVALID_OPERATION, "glTexEnv" ); + return; + } + + if (target!=GL_TEXTURE_ENV) { + gl_error( ctx, GL_INVALID_ENUM, "glTexEnv(target)" ); + return; + } + + if (pname==GL_TEXTURE_ENV_MODE) { + GLenum mode = (GLenum) (GLint) *param; + switch (mode) { + case GL_MODULATE: + case GL_BLEND: + case GL_DECAL: + case GL_REPLACE: + ctx->Texture.EnvMode = mode; + break; + default: + gl_error( ctx, GL_INVALID_ENUM, "glTexEnv(param)" ); + return; + } + } + else if (pname==GL_TEXTURE_ENV_COLOR) { + ctx->Texture.EnvColor[0] = CLAMP( param[0], 0.0, 1.0 ); + ctx->Texture.EnvColor[1] = CLAMP( param[1], 0.0, 1.0 ); + ctx->Texture.EnvColor[2] = CLAMP( param[2], 0.0, 1.0 ); + ctx->Texture.EnvColor[3] = CLAMP( param[3], 0.0, 1.0 ); + } + else { + gl_error( ctx, GL_INVALID_ENUM, "glTexEnv(pname)" ); + return; + } + + /* Tell device driver about the new texture environment */ + if (ctx->Driver.TexEnv) { + (*ctx->Driver.TexEnv)( ctx, pname, param ); + } +} + + + + + +void gl_GetTexEnvfv( GLcontext *ctx, + GLenum target, GLenum pname, GLfloat *params ) +{ + if (target!=GL_TEXTURE_ENV) { + gl_error( ctx, GL_INVALID_ENUM, "glGetTexEnvfv(target)" ); + return; + } + switch (pname) { + case GL_TEXTURE_ENV_MODE: + *params = ENUM_TO_FLOAT(ctx->Texture.EnvMode); + break; + case GL_TEXTURE_ENV_COLOR: + COPY_4V( params, ctx->Texture.EnvColor ); + break; + default: + gl_error( ctx, GL_INVALID_ENUM, "glGetTexEnvfv(pname)" ); + } +} + + +void gl_GetTexEnviv( GLcontext *ctx, + GLenum target, GLenum pname, GLint *params ) +{ + if (target!=GL_TEXTURE_ENV) { + gl_error( ctx, GL_INVALID_ENUM, "glGetTexEnvfv(target)" ); + return; + } + switch (pname) { + case GL_TEXTURE_ENV_MODE: + *params = (GLint) ctx->Texture.EnvMode; + break; + case GL_TEXTURE_ENV_COLOR: + params[0] = FLOAT_TO_INT( ctx->Texture.EnvColor[0] ); + params[1] = FLOAT_TO_INT( ctx->Texture.EnvColor[1] ); + params[2] = FLOAT_TO_INT( ctx->Texture.EnvColor[2] ); + params[3] = FLOAT_TO_INT( ctx->Texture.EnvColor[3] ); + break; + default: + gl_error( ctx, GL_INVALID_ENUM, "glGetTexEnvfv(pname)" ); + } +} + + + + +/**********************************************************************/ +/* Texture Parameters */ +/**********************************************************************/ + + +void gl_TexParameterfv( GLcontext *ctx, + GLenum target, GLenum pname, const GLfloat *params ) +{ + GLenum eparam = (GLenum) (GLint) params[0]; + struct gl_texture_object *texObj; + + switch (target) { + case GL_TEXTURE_1D: + texObj = ctx->Texture.Current1D; + break; + case GL_TEXTURE_2D: + texObj = ctx->Texture.Current2D; + break; + default: + gl_error( ctx, GL_INVALID_ENUM, "glTexParameter(target)" ); + return; + } + + switch (pname) { + case GL_TEXTURE_MIN_FILTER: + if (eparam==GL_NEAREST || eparam==GL_LINEAR + || eparam==GL_NEAREST_MIPMAP_NEAREST + || eparam==GL_LINEAR_MIPMAP_NEAREST + || eparam==GL_NEAREST_MIPMAP_LINEAR + || eparam==GL_LINEAR_MIPMAP_LINEAR) { + texObj->MinFilter = eparam; + ctx->NewState |= NEW_TEXTURING; + } + else { + gl_error( ctx, GL_INVALID_VALUE, "glTexParameter(param)" ); + return; + } + break; + case GL_TEXTURE_MAG_FILTER: + if (eparam==GL_NEAREST || eparam==GL_LINEAR) { + texObj->MagFilter = eparam; + ctx->NewState |= NEW_TEXTURING; + } + else { + gl_error( ctx, GL_INVALID_VALUE, "glTexParameter(param)" ); + return; + } + break; + case GL_TEXTURE_WRAP_S: + if (eparam==GL_CLAMP || eparam==GL_REPEAT) { + texObj->WrapS = eparam; + } + else { + gl_error( ctx, GL_INVALID_VALUE, "glTexParameter(param)" ); + return; + } + break; + case GL_TEXTURE_WRAP_T: + if (eparam==GL_CLAMP || eparam==GL_REPEAT) { + texObj->WrapT = eparam; + } + else { + gl_error( ctx, GL_INVALID_VALUE, "glTexParameter(param)" ); + return; + } + break; + case GL_TEXTURE_WRAP_R_EXT: + if (eparam==GL_CLAMP || eparam==GL_REPEAT) { + texObj->WrapR = eparam; + } + else { + gl_error( ctx, GL_INVALID_VALUE, "glTexParameter(param)" ); + } + break; + case GL_TEXTURE_BORDER_COLOR: + texObj->BorderColor[0] = CLAMP((GLint)(params[0]*255.0), 0, 255); + texObj->BorderColor[1] = CLAMP((GLint)(params[1]*255.0), 0, 255); + texObj->BorderColor[2] = CLAMP((GLint)(params[2]*255.0), 0, 255); + texObj->BorderColor[3] = CLAMP((GLint)(params[3]*255.0), 0, 255); + break; + default: + gl_error( ctx, GL_INVALID_ENUM, "glTexParameter(pname)" ); + return; + } + + texObj->Dirty = GL_TRUE; + ctx->Texture.AnyDirty = GL_TRUE; + + if (ctx->Driver.TexParameter) { + (*ctx->Driver.TexParameter)( ctx, target, texObj, pname, params ); + } +} + + + +void gl_GetTexLevelParameterfv( GLcontext *ctx, GLenum target, GLint level, + GLenum pname, GLfloat *params ) +{ + GLint iparam; + + gl_GetTexLevelParameteriv( ctx, target, level, pname, &iparam ); + *params = (GLfloat) iparam; +} + + + +void gl_GetTexLevelParameteriv( GLcontext *ctx, GLenum target, GLint level, + GLenum pname, GLint *params ) +{ + struct gl_texture_image *tex; + + if (level<0 || level>=MAX_TEXTURE_LEVELS) { + gl_error( ctx, GL_INVALID_VALUE, "glGetTexLevelParameter[if]v" ); + return; + } + + switch (target) { + case GL_TEXTURE_1D: + tex = ctx->Texture.Current1D->Image[level]; + switch (pname) { + case GL_TEXTURE_WIDTH: + *params = tex->Width; + break; + case GL_TEXTURE_COMPONENTS: + *params = tex->Format; + break; + case GL_TEXTURE_BORDER: + *params = tex->Border; + break; + case GL_TEXTURE_RED_SIZE: + case GL_TEXTURE_GREEN_SIZE: + case GL_TEXTURE_BLUE_SIZE: + case GL_TEXTURE_ALPHA_SIZE: + case GL_TEXTURE_INTENSITY_SIZE: + case GL_TEXTURE_LUMINANCE_SIZE: + *params = 8; /* 8-bits */ + break; + case GL_TEXTURE_INDEX_SIZE_EXT: + *params = 8; + break; + default: + gl_error( ctx, GL_INVALID_ENUM, + "glGetTexLevelParameter[if]v(pname)" ); + } + break; + case GL_TEXTURE_2D: + tex = ctx->Texture.Current2D->Image[level]; + switch (pname) { + case GL_TEXTURE_WIDTH: + *params = tex->Width; + break; + case GL_TEXTURE_HEIGHT: + *params = tex->Height; + break; + case GL_TEXTURE_COMPONENTS: + *params = tex->Format; + break; + case GL_TEXTURE_BORDER: + *params = tex->Border; + break; + case GL_TEXTURE_RED_SIZE: + case GL_TEXTURE_GREEN_SIZE: + case GL_TEXTURE_BLUE_SIZE: + case GL_TEXTURE_ALPHA_SIZE: + case GL_TEXTURE_INTENSITY_SIZE: + case GL_TEXTURE_LUMINANCE_SIZE: + *params = 8; /* 8-bits */ + break; + case GL_TEXTURE_INDEX_SIZE_EXT: + *params = 8; + break; + default: + gl_error( ctx, GL_INVALID_ENUM, + "glGetTexLevelParameter[if]v(pname)" ); + } + break; + case GL_PROXY_TEXTURE_1D: + tex = ctx->Texture.Proxy1D->Image[level]; + switch (pname) { + case GL_TEXTURE_WIDTH: + *params = tex->Width; + break; + case GL_TEXTURE_COMPONENTS: + *params = tex->Format; + break; + case GL_TEXTURE_BORDER: + *params = tex->Border; + break; + case GL_TEXTURE_RED_SIZE: + case GL_TEXTURE_GREEN_SIZE: + case GL_TEXTURE_BLUE_SIZE: + case GL_TEXTURE_ALPHA_SIZE: + case GL_TEXTURE_INTENSITY_SIZE: + case GL_TEXTURE_LUMINANCE_SIZE: + *params = 8; /* 8-bits */ + break; + case GL_TEXTURE_INDEX_SIZE_EXT: + *params = 8; + break; + default: + gl_error( ctx, GL_INVALID_ENUM, + "glGetTexLevelParameter[if]v(pname)" ); + } + break; + case GL_PROXY_TEXTURE_2D: + tex = ctx->Texture.Proxy2D->Image[level]; + switch (pname) { + case GL_TEXTURE_WIDTH: + *params = tex->Width; + break; + case GL_TEXTURE_HEIGHT: + *params = tex->Height; + break; + case GL_TEXTURE_COMPONENTS: + *params = tex->Format; + break; + case GL_TEXTURE_BORDER: + *params = tex->Border; + break; + case GL_TEXTURE_RED_SIZE: + case GL_TEXTURE_GREEN_SIZE: + case GL_TEXTURE_BLUE_SIZE: + case GL_TEXTURE_ALPHA_SIZE: + case GL_TEXTURE_INTENSITY_SIZE: + case GL_TEXTURE_LUMINANCE_SIZE: + *params = 8; /* 8-bits */ + break; + case GL_TEXTURE_INDEX_SIZE_EXT: + *params = 8; + break; + default: + gl_error( ctx, GL_INVALID_ENUM, + "glGetTexLevelParameter[if]v(pname)" ); + } + break; + default: + gl_error(ctx, GL_INVALID_ENUM, "glGetTexLevelParameter[if]v(target)"); + } +} + + + + +void gl_GetTexParameterfv( GLcontext *ctx, + GLenum target, GLenum pname, GLfloat *params ) +{ + switch (target) { + case GL_TEXTURE_1D: + switch (pname) { + case GL_TEXTURE_MAG_FILTER: + *params = ENUM_TO_FLOAT(ctx->Texture.Current1D->MagFilter); + break; + case GL_TEXTURE_MIN_FILTER: + *params = ENUM_TO_FLOAT(ctx->Texture.Current1D->MinFilter); + break; + case GL_TEXTURE_WRAP_S: + *params = ENUM_TO_FLOAT(ctx->Texture.Current1D->WrapS); + break; + case GL_TEXTURE_WRAP_T: + *params = ENUM_TO_FLOAT(ctx->Texture.Current1D->WrapT); + break; + case GL_TEXTURE_BORDER_COLOR: + params[0] = ctx->Texture.Current1D->BorderColor[0] / 255.0f; + params[1] = ctx->Texture.Current1D->BorderColor[1] / 255.0f; + params[2] = ctx->Texture.Current1D->BorderColor[2] / 255.0f; + params[3] = ctx->Texture.Current1D->BorderColor[3] / 255.0f; + break; + case GL_TEXTURE_RESIDENT: + *params = ENUM_TO_FLOAT(GL_TRUE); + break; + case GL_TEXTURE_PRIORITY: + *params = ctx->Texture.Current1D->Priority; + break; + default: + gl_error( ctx, GL_INVALID_ENUM, "glGetTexParameterfv(pname)" ); + } + break; + case GL_TEXTURE_2D: + switch (pname) { + case GL_TEXTURE_MAG_FILTER: + *params = ENUM_TO_FLOAT(ctx->Texture.Current2D->MagFilter); + break; + case GL_TEXTURE_MIN_FILTER: + *params = ENUM_TO_FLOAT(ctx->Texture.Current2D->MinFilter); + break; + case GL_TEXTURE_WRAP_S: + *params = ENUM_TO_FLOAT(ctx->Texture.Current2D->WrapS); + break; + case GL_TEXTURE_WRAP_T: + *params = ENUM_TO_FLOAT(ctx->Texture.Current2D->WrapT); + break; + case GL_TEXTURE_BORDER_COLOR: + params[0] = ctx->Texture.Current2D->BorderColor[0] / 255.0f; + params[1] = ctx->Texture.Current2D->BorderColor[1] / 255.0f; + params[2] = ctx->Texture.Current2D->BorderColor[2] / 255.0f; + params[3] = ctx->Texture.Current2D->BorderColor[3] / 255.0f; + break; + case GL_TEXTURE_RESIDENT: + *params = ENUM_TO_FLOAT(GL_TRUE); + break; + case GL_TEXTURE_PRIORITY: + *params = ctx->Texture.Current2D->Priority; + break; + default: + gl_error( ctx, GL_INVALID_ENUM, "glGetTexParameterfv(pname)" ); + } + break; + default: + gl_error( ctx, GL_INVALID_ENUM, "glGetTexParameterfv(target)" ); + } +} + + +void gl_GetTexParameteriv( GLcontext *ctx, + GLenum target, GLenum pname, GLint *params ) +{ + switch (target) { + case GL_TEXTURE_1D: + switch (pname) { + case GL_TEXTURE_MAG_FILTER: + *params = (GLint) ctx->Texture.Current1D->MagFilter; + break; + case GL_TEXTURE_MIN_FILTER: + *params = (GLint) ctx->Texture.Current1D->MinFilter; + break; + case GL_TEXTURE_WRAP_S: + *params = (GLint) ctx->Texture.Current1D->WrapS; + break; + case GL_TEXTURE_WRAP_T: + *params = (GLint) ctx->Texture.Current1D->WrapT; + break; + case GL_TEXTURE_BORDER_COLOR: + { + GLfloat color[4]; + color[0] = ctx->Texture.Current1D->BorderColor[0]/255.0; + color[1] = ctx->Texture.Current1D->BorderColor[1]/255.0; + color[2] = ctx->Texture.Current1D->BorderColor[2]/255.0; + color[3] = ctx->Texture.Current1D->BorderColor[3]/255.0; + params[0] = FLOAT_TO_INT( color[0] ); + params[1] = FLOAT_TO_INT( color[1] ); + params[2] = FLOAT_TO_INT( color[2] ); + params[3] = FLOAT_TO_INT( color[3] ); + } + break; + case GL_TEXTURE_RESIDENT: + *params = (GLint) GL_TRUE; + break; + case GL_TEXTURE_PRIORITY: + *params = (GLint) ctx->Texture.Current1D->Priority; + break; + default: + gl_error( ctx, GL_INVALID_ENUM, "glGetTexParameteriv(pname)" ); + } + break; + case GL_TEXTURE_2D: + switch (pname) { + case GL_TEXTURE_MAG_FILTER: + *params = (GLint) ctx->Texture.Current2D->MagFilter; + break; + case GL_TEXTURE_MIN_FILTER: + *params = (GLint) ctx->Texture.Current2D->MinFilter; + break; + case GL_TEXTURE_WRAP_S: + *params = (GLint) ctx->Texture.Current2D->WrapS; + break; + case GL_TEXTURE_WRAP_T: + *params = (GLint) ctx->Texture.Current2D->WrapT; + break; + case GL_TEXTURE_BORDER_COLOR: + { + GLfloat color[4]; + color[0] = ctx->Texture.Current2D->BorderColor[0]/255.0; + color[1] = ctx->Texture.Current2D->BorderColor[1]/255.0; + color[2] = ctx->Texture.Current2D->BorderColor[2]/255.0; + color[3] = ctx->Texture.Current2D->BorderColor[3]/255.0; + params[0] = FLOAT_TO_INT( color[0] ); + params[1] = FLOAT_TO_INT( color[1] ); + params[2] = FLOAT_TO_INT( color[2] ); + params[3] = FLOAT_TO_INT( color[3] ); + } + break; + case GL_TEXTURE_RESIDENT: + *params = (GLint) GL_TRUE; + break; + case GL_TEXTURE_PRIORITY: + *params = (GLint) ctx->Texture.Current2D->Priority; + break; + default: + gl_error( ctx, GL_INVALID_ENUM, "glGetTexParameteriv(pname)" ); + } + break; + default: + gl_error( ctx, GL_INVALID_ENUM, "glGetTexParameteriv(target)" ); + } +} + + + + +/**********************************************************************/ +/* Texture Coord Generation */ +/**********************************************************************/ + + +void gl_TexGenfv( GLcontext *ctx, + GLenum coord, GLenum pname, const GLfloat *params ) +{ + if (INSIDE_BEGIN_END(ctx)) { + gl_error( ctx, GL_INVALID_OPERATION, "glTexGenfv" ); + return; + } + + switch( coord ) { + case GL_S: + if (pname==GL_TEXTURE_GEN_MODE) { + GLenum mode = (GLenum) (GLint) *params; + if (mode==GL_OBJECT_LINEAR || + mode==GL_EYE_LINEAR || + mode==GL_SPHERE_MAP) { + ctx->Texture.GenModeS = mode; + } + else { + gl_error( ctx, GL_INVALID_ENUM, "glTexGenfv(param)" ); + return; + } + } + else if (pname==GL_OBJECT_PLANE) { + ctx->Texture.ObjectPlaneS[0] = params[0]; + ctx->Texture.ObjectPlaneS[1] = params[1]; + ctx->Texture.ObjectPlaneS[2] = params[2]; + ctx->Texture.ObjectPlaneS[3] = params[3]; + } + else if (pname==GL_EYE_PLANE) { + /* Transform plane equation by the inverse modelview matrix */ + if (ctx->NewModelViewMatrix) { + gl_analyze_modelview_matrix(ctx); + } + gl_transform_vector( ctx->Texture.EyePlaneS, params, + ctx->ModelViewInv ); + } + else { + gl_error( ctx, GL_INVALID_ENUM, "glTexGenfv(pname)" ); + return; + } + break; + case GL_T: + if (pname==GL_TEXTURE_GEN_MODE) { + GLenum mode = (GLenum) (GLint) *params; + if (mode==GL_OBJECT_LINEAR || + mode==GL_EYE_LINEAR || + mode==GL_SPHERE_MAP) { + ctx->Texture.GenModeT = mode; + } + else { + gl_error( ctx, GL_INVALID_ENUM, "glTexGenfv(param)" ); + return; + } + } + else if (pname==GL_OBJECT_PLANE) { + ctx->Texture.ObjectPlaneT[0] = params[0]; + ctx->Texture.ObjectPlaneT[1] = params[1]; + ctx->Texture.ObjectPlaneT[2] = params[2]; + ctx->Texture.ObjectPlaneT[3] = params[3]; + } + else if (pname==GL_EYE_PLANE) { + /* Transform plane equation by the inverse modelview matrix */ + if (ctx->NewModelViewMatrix) { + gl_analyze_modelview_matrix(ctx); + } + gl_transform_vector( ctx->Texture.EyePlaneT, params, + ctx->ModelViewInv ); + } + else { + gl_error( ctx, GL_INVALID_ENUM, "glTexGenfv(pname)" ); + return; + } + break; + case GL_R: + if (pname==GL_TEXTURE_GEN_MODE) { + GLenum mode = (GLenum) (GLint) *params; + if (mode==GL_OBJECT_LINEAR || + mode==GL_EYE_LINEAR) { + ctx->Texture.GenModeR = mode; + } + else { + gl_error( ctx, GL_INVALID_ENUM, "glTexGenfv(param)" ); + return; + } + } + else if (pname==GL_OBJECT_PLANE) { + ctx->Texture.ObjectPlaneR[0] = params[0]; + ctx->Texture.ObjectPlaneR[1] = params[1]; + ctx->Texture.ObjectPlaneR[2] = params[2]; + ctx->Texture.ObjectPlaneR[3] = params[3]; + } + else if (pname==GL_EYE_PLANE) { + /* Transform plane equation by the inverse modelview matrix */ + if (ctx->NewModelViewMatrix) { + gl_analyze_modelview_matrix(ctx); + } + gl_transform_vector( ctx->Texture.EyePlaneR, params, + ctx->ModelViewInv ); + } + else { + gl_error( ctx, GL_INVALID_ENUM, "glTexGenfv(pname)" ); + return; + } + break; + case GL_Q: + if (pname==GL_TEXTURE_GEN_MODE) { + GLenum mode = (GLenum) (GLint) *params; + if (mode==GL_OBJECT_LINEAR || + mode==GL_EYE_LINEAR) { + ctx->Texture.GenModeQ = mode; + } + else { + gl_error( ctx, GL_INVALID_ENUM, "glTexGenfv(param)" ); + return; + } + } + else if (pname==GL_OBJECT_PLANE) { + ctx->Texture.ObjectPlaneQ[0] = params[0]; + ctx->Texture.ObjectPlaneQ[1] = params[1]; + ctx->Texture.ObjectPlaneQ[2] = params[2]; + ctx->Texture.ObjectPlaneQ[3] = params[3]; + } + else if (pname==GL_EYE_PLANE) { + /* Transform plane equation by the inverse modelview matrix */ + if (ctx->NewModelViewMatrix) { + gl_analyze_modelview_matrix(ctx); + } + gl_transform_vector( ctx->Texture.EyePlaneQ, params, + ctx->ModelViewInv ); + } + else { + gl_error( ctx, GL_INVALID_ENUM, "glTexGenfv(pname)" ); + return; + } + break; + default: + gl_error( ctx, GL_INVALID_ENUM, "glTexGenfv(coord)" ); + return; + } + + ctx->NewState |= NEW_TEXTURING; +} + + + +void gl_GetTexGendv( GLcontext *ctx, + GLenum coord, GLenum pname, GLdouble *params ) +{ + if (INSIDE_BEGIN_END(ctx)) { + gl_error( ctx, GL_INVALID_OPERATION, "glGetTexGendv" ); + return; + } + + switch( coord ) { + case GL_S: + if (pname==GL_TEXTURE_GEN_MODE) { + params[0] = ENUM_TO_DOUBLE(ctx->Texture.GenModeS); + } + else if (pname==GL_OBJECT_PLANE) { + COPY_4V( params, ctx->Texture.ObjectPlaneS ); + } + else if (pname==GL_EYE_PLANE) { + COPY_4V( params, ctx->Texture.EyePlaneS ); + } + else { + gl_error( ctx, GL_INVALID_ENUM, "glGetTexGendv(pname)" ); + return; + } + break; + case GL_T: + if (pname==GL_TEXTURE_GEN_MODE) { + params[0] = ENUM_TO_DOUBLE(ctx->Texture.GenModeT); + } + else if (pname==GL_OBJECT_PLANE) { + COPY_4V( params, ctx->Texture.ObjectPlaneT ); + } + else if (pname==GL_EYE_PLANE) { + COPY_4V( params, ctx->Texture.EyePlaneT ); + } + else { + gl_error( ctx, GL_INVALID_ENUM, "glGetTexGendv(pname)" ); + return; + } + break; + case GL_R: + if (pname==GL_TEXTURE_GEN_MODE) { + params[0] = ENUM_TO_DOUBLE(ctx->Texture.GenModeR); + } + else if (pname==GL_OBJECT_PLANE) { + COPY_4V( params, ctx->Texture.ObjectPlaneR ); + } + else if (pname==GL_EYE_PLANE) { + COPY_4V( params, ctx->Texture.EyePlaneR ); + } + else { + gl_error( ctx, GL_INVALID_ENUM, "glGetTexGendv(pname)" ); + return; + } + break; + case GL_Q: + if (pname==GL_TEXTURE_GEN_MODE) { + params[0] = ENUM_TO_DOUBLE(ctx->Texture.GenModeQ); + } + else if (pname==GL_OBJECT_PLANE) { + COPY_4V( params, ctx->Texture.ObjectPlaneQ ); + } + else if (pname==GL_EYE_PLANE) { + COPY_4V( params, ctx->Texture.EyePlaneQ ); + } + else { + gl_error( ctx, GL_INVALID_ENUM, "glGetTexGendv(pname)" ); + return; + } + break; + default: + gl_error( ctx, GL_INVALID_ENUM, "glGetTexGendv(coord)" ); + return; + } +} + + + +void gl_GetTexGenfv( GLcontext *ctx, + GLenum coord, GLenum pname, GLfloat *params ) +{ + if (INSIDE_BEGIN_END(ctx)) { + gl_error( ctx, GL_INVALID_OPERATION, "glGetTexGenfv" ); + return; + } + + switch( coord ) { + case GL_S: + if (pname==GL_TEXTURE_GEN_MODE) { + params[0] = ENUM_TO_FLOAT(ctx->Texture.GenModeS); + } + else if (pname==GL_OBJECT_PLANE) { + COPY_4V( params, ctx->Texture.ObjectPlaneS ); + } + else if (pname==GL_EYE_PLANE) { + COPY_4V( params, ctx->Texture.EyePlaneS ); + } + else { + gl_error( ctx, GL_INVALID_ENUM, "glGetTexGenfv(pname)" ); + return; + } + break; + case GL_T: + if (pname==GL_TEXTURE_GEN_MODE) { + params[0] = ENUM_TO_FLOAT(ctx->Texture.GenModeT); + } + else if (pname==GL_OBJECT_PLANE) { + COPY_4V( params, ctx->Texture.ObjectPlaneT ); + } + else if (pname==GL_EYE_PLANE) { + COPY_4V( params, ctx->Texture.EyePlaneT ); + } + else { + gl_error( ctx, GL_INVALID_ENUM, "glGetTexGenfv(pname)" ); + return; + } + break; + case GL_R: + if (pname==GL_TEXTURE_GEN_MODE) { + params[0] = ENUM_TO_FLOAT(ctx->Texture.GenModeR); + } + else if (pname==GL_OBJECT_PLANE) { + COPY_4V( params, ctx->Texture.ObjectPlaneR ); + } + else if (pname==GL_EYE_PLANE) { + COPY_4V( params, ctx->Texture.EyePlaneR ); + } + else { + gl_error( ctx, GL_INVALID_ENUM, "glGetTexGenfv(pname)" ); + return; + } + break; + case GL_Q: + if (pname==GL_TEXTURE_GEN_MODE) { + params[0] = ENUM_TO_FLOAT(ctx->Texture.GenModeQ); + } + else if (pname==GL_OBJECT_PLANE) { + COPY_4V( params, ctx->Texture.ObjectPlaneQ ); + } + else if (pname==GL_EYE_PLANE) { + COPY_4V( params, ctx->Texture.EyePlaneQ ); + } + else { + gl_error( ctx, GL_INVALID_ENUM, "glGetTexGenfv(pname)" ); + return; + } + break; + default: + gl_error( ctx, GL_INVALID_ENUM, "glGetTexGenfv(coord)" ); + return; + } +} + + + +void gl_GetTexGeniv( GLcontext *ctx, + GLenum coord, GLenum pname, GLint *params ) +{ + if (INSIDE_BEGIN_END(ctx)) { + gl_error( ctx, GL_INVALID_OPERATION, "glGetTexGeniv" ); + return; + } + + switch( coord ) { + case GL_S: + if (pname==GL_TEXTURE_GEN_MODE) { + params[0] = ctx->Texture.GenModeS; + } + else if (pname==GL_OBJECT_PLANE) { + COPY_4V( params, ctx->Texture.ObjectPlaneS ); + } + else if (pname==GL_EYE_PLANE) { + COPY_4V( params, ctx->Texture.EyePlaneS ); + } + else { + gl_error( ctx, GL_INVALID_ENUM, "glGetTexGeniv(pname)" ); + return; + } + break; + case GL_T: + if (pname==GL_TEXTURE_GEN_MODE) { + params[0] = ctx->Texture.GenModeT; + } + else if (pname==GL_OBJECT_PLANE) { + COPY_4V( params, ctx->Texture.ObjectPlaneT ); + } + else if (pname==GL_EYE_PLANE) { + COPY_4V( params, ctx->Texture.EyePlaneT ); + } + else { + gl_error( ctx, GL_INVALID_ENUM, "glGetTexGeniv(pname)" ); + return; + } + break; + case GL_R: + if (pname==GL_TEXTURE_GEN_MODE) { + params[0] = ctx->Texture.GenModeR; + } + else if (pname==GL_OBJECT_PLANE) { + COPY_4V( params, ctx->Texture.ObjectPlaneR ); + } + else if (pname==GL_EYE_PLANE) { + COPY_4V( params, ctx->Texture.EyePlaneR ); + } + else { + gl_error( ctx, GL_INVALID_ENUM, "glGetTexGeniv(pname)" ); + return; + } + break; + case GL_Q: + if (pname==GL_TEXTURE_GEN_MODE) { + params[0] = ctx->Texture.GenModeQ; + } + else if (pname==GL_OBJECT_PLANE) { + COPY_4V( params, ctx->Texture.ObjectPlaneQ ); + } + else if (pname==GL_EYE_PLANE) { + COPY_4V( params, ctx->Texture.EyePlaneQ ); + } + else { + gl_error( ctx, GL_INVALID_ENUM, "glGetTexGeniv(pname)" ); + return; + } + break; + default: + gl_error( ctx, GL_INVALID_ENUM, "glGetTexGeniv(coord)" ); + return; + } +} + + + +/* + * This is called by gl_update_state() if the NEW_TEXTURING bit in + * ctx->NewState is set. + */ +void gl_update_texture_state( GLcontext *ctx ) +{ + struct gl_texture_object *t; + + if (ctx->Texture.Enabled & TEXTURE_2D) + ctx->Texture.Current = ctx->Texture.Current2D; + else if (ctx->Texture.Enabled & TEXTURE_1D) + ctx->Texture.Current = ctx->Texture.Current1D; + else + ctx->Texture.Current = NULL; + + if (ctx->Texture.AnyDirty) { + for (t = ctx->Shared->TexObjectList; t; t = t->Next) { + if (t->Dirty) { + gl_test_texture_object_completeness(t); + gl_set_texture_sampler(t); + t->Dirty = GL_FALSE; + } + } + ctx->Texture.AnyDirty = GL_FALSE; + } +} diff --git a/dll/opengl/mesa/texstate.h b/dll/opengl/mesa/texstate.h new file mode 100644 index 00000000000..2f335c00290 --- /dev/null +++ b/dll/opengl/mesa/texstate.h @@ -0,0 +1,93 @@ +/* $Id: texstate.h,v 1.2 1997/05/03 00:53:19 brianp Exp $ */ + +/* + * Mesa 3-D graphics library + * Version: 2.3 + * Copyright (C) 1995-1997 Brian Paul + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Library General Public + * License as published by the Free Software Foundation; either + * version 2 of the License, or (at your option) any later version. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Library General Public License for more details. + * + * You should have received a copy of the GNU Library General Public + * License along with this library; if not, write to the Free + * Software Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. + */ + + +/* + * $Log: texstate.h,v $ + * Revision 1.2 1997/05/03 00:53:19 brianp + * removed gl_texturing_enabled() + * + * Revision 1.1 1997/04/14 01:59:54 brianp + * Initial revision + * + */ + + +#ifndef TEXSTATE_H +#define TEXSTATE_H + + +#include "types.h" + + +/*** Called from API ***/ + +extern void gl_GetTexEnvfv( GLcontext *ctx, + GLenum target, GLenum pname, GLfloat *params ); + +extern void gl_GetTexEnviv( GLcontext *ctx, + GLenum target, GLenum pname, GLint *params ); + +extern void gl_GetTexGendv( GLcontext *ctx, + GLenum coord, GLenum pname, GLdouble *params ); + +extern void gl_GetTexGenfv( GLcontext *ctx, + GLenum coord, GLenum pname, GLfloat *params ); + +extern void gl_GetTexGeniv( GLcontext *ctx, + GLenum coord, GLenum pname, GLint *params ); + +extern void gl_GetTexLevelParameterfv( GLcontext *ctx, + GLenum target, GLint level, + GLenum pname, GLfloat *params ); + +extern void gl_GetTexLevelParameteriv( GLcontext *ctx, + GLenum target, GLint level, + GLenum pname, GLint *params ); + +extern void gl_GetTexParameterfv( GLcontext *ctx, GLenum target, + GLenum pname, GLfloat *params ); + +extern void gl_GetTexParameteriv( GLcontext *ctx, + GLenum target, GLenum pname, GLint *params ); + + +extern void gl_TexEnvfv( GLcontext *ctx, + GLenum target, GLenum pname, const GLfloat *param ); + + +extern void gl_TexParameterfv( GLcontext *ctx, GLenum target, GLenum pname, + const GLfloat *params ); + + +extern void gl_TexGenfv( GLcontext *ctx, + GLenum coord, GLenum pname, const GLfloat *params ); + + + +/*** Internal functions ***/ + +extern void gl_update_texture_state( GLcontext *ctx ); + + +#endif + diff --git a/dll/opengl/mesa/texture.c b/dll/opengl/mesa/texture.c new file mode 100644 index 00000000000..1f2d6a1735d --- /dev/null +++ b/dll/opengl/mesa/texture.c @@ -0,0 +1,1702 @@ +/* $Id: texture.c,v 1.36 1997/11/17 02:04:06 brianp Exp $ */ + +/* + * Mesa 3-D graphics library + * Version: 2.5 + * Copyright (C) 1995-1997 Brian Paul + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Library General Public + * License as published by the Free Software Foundation; either + * version 2 of the License, or (at your option) any later version. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Library General Public License for more details. + * + * You should have received a copy of the GNU Library General Public + * License along with this library; if not, write to the Free + * Software Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. + */ + + +/* + * $Log: texture.c,v $ + * Revision 1.36 1997/11/17 02:04:06 brianp + * fixed a typo in texture code + * + * Revision 1.35 1997/11/13 02:17:32 brianp + * added a few const keywords + * + * Revision 1.34 1997/10/16 01:59:08 brianp + * added GL_EXT_shared_texture_palette extension + * + * Revision 1.33 1997/09/27 00:14:39 brianp + * added GL_EXT_paletted_texture extension + * + * Revision 1.32 1997/08/14 01:03:12 brianp + * fixed small bug in GL_SPHERE_MAP texgen (Petri Nordlund) + * + * Revision 1.31 1997/07/24 01:25:34 brianp + * changed precompiled header symbol from PCH to PC_HEADER + * + * Revision 1.30 1997/07/22 01:23:48 brianp + * fixed negative texture coord sampling problem (Magnus Lundin) + * + * Revision 1.29 1997/07/09 00:32:26 brianp + * fixed bug involving sampling and incomplete texture objects + * + * Revision 1.28 1997/05/28 03:26:49 brianp + * added precompiled header (PCH) support + * + * Revision 1.27 1997/05/17 03:51:10 brianp + * fixed bug in PROD macro (Waldemar Celes) + * + * Revision 1.26 1997/05/03 00:53:56 brianp + * all-new texture sampling via gl_texture_object's SampleFunc pointer + * + * Revision 1.25 1997/05/01 01:40:14 brianp + * replaced sqrt() with GL_SQRT, use NORMALIZE_3FV instead of NORMALIZE_3V + * + * Revision 1.24 1997/04/28 02:04:18 brianp + * GL_SPHERE_MAP texgen was wrong (Eamon O'Dea) + * + * Revision 1.23 1997/04/20 20:29:11 brianp + * replaced abort() with gl_problem() + * + * Revision 1.22 1997/04/16 23:56:41 brianp + * added a few #include files + * + * Revision 1.21 1997/04/14 02:02:39 brianp + * moved many functions into new texstate.c file + * + * Revision 1.20 1997/04/01 04:19:14 brianp + * call gl_analyze_modelview_matrix instead of gl_compute_modelview_inverse + * + * Revision 1.19 1997/03/04 19:55:58 brianp + * small texture sampling optimizations. better comments. + * + * Revision 1.18 1997/03/04 19:19:20 brianp + * fixed a number of problems with texture borders + * + * Revision 1.17 1997/02/27 19:58:08 brianp + * call gl_problem() instead of gl_warning() + * + * Revision 1.16 1997/02/09 19:53:43 brianp + * now use TEXTURE_xD enable constants + * + * Revision 1.15 1997/02/09 18:53:14 brianp + * added GL_EXT_texture3D support + * + * Revision 1.14 1997/01/30 21:06:03 brianp + * added some missing glGetTexLevelParameter() GLenums + * + * Revision 1.13 1997/01/16 03:36:01 brianp + * added calls to device driver TexParameter() and TexEnv() functions + * + * Revision 1.12 1997/01/09 19:48:30 brianp + * better error checking + * added gl_texturing_enabled() + * + * Revision 1.11 1996/12/20 20:22:30 brianp + * linear interpolation between mipmap levels was reverse weighted + * max mipmap level was incorrectly tested for + * + * Revision 1.10 1996/12/12 22:33:05 brianp + * minor changes to gl_texgen() + * + * Revision 1.9 1996/12/07 10:35:41 brianp + * implmented glGetTexGen*() functions + * + * Revision 1.8 1996/11/14 01:03:09 brianp + * removed const's from gl_texgen() function to avoid VMS compiler warning + * + * Revision 1.7 1996/11/08 02:19:52 brianp + * gl_do_texgen() replaced with gl_texgen() + * + * Revision 1.6 1996/10/26 17:17:30 brianp + * glTexGen GL_EYE_PLANE vector now transformed by inverse modelview matrix + * + * Revision 1.5 1996/10/11 03:42:38 brianp + * replaced old _EXT symbols + * + * Revision 1.4 1996/09/27 01:30:24 brianp + * added missing default cases to switches + * + * Revision 1.3 1996/09/15 14:18:55 brianp + * now use GLframebuffer and GLvisual + * + * Revision 1.2 1996/09/15 01:48:58 brianp + * removed #define NULL 0 + * + * Revision 1.1 1996/09/13 01:38:16 brianp + * Initial revision + * + */ + + +#ifdef PC_HEADER +#include "all.h" +#else +#include +#include +#include "context.h" +#include "macros.h" +#include "mmath.h" +#include "pb.h" +#include "texture.h" +#include "types.h" +#endif + + + +/* + * Perform automatic texture coordinate generation. + * Input: ctx - the context + * n - number of texture coordinates to generate + * obj - array of vertexes in object coordinate system + * eye - array of vertexes in eye coordinate system + * normal - array of normal vectores in eye coordinate system + * Output: texcoord - array of resuling texture coordinates + */ +void gl_texgen( GLcontext *ctx, GLint n, + GLfloat obj[][4], GLfloat eye[][4], + GLfloat normal[][3], GLfloat texcoord[][4] ) +{ + /* special case: S and T sphere mapping */ + if (ctx->Texture.TexGenEnabled==(S_BIT|T_BIT) + && ctx->Texture.GenModeS==GL_SPHERE_MAP + && ctx->Texture.GenModeT==GL_SPHERE_MAP) { + GLint i; + for (i=0;iTexture.TexGenEnabled & S_BIT) { + GLint i; + switch (ctx->Texture.GenModeS) { + case GL_OBJECT_LINEAR: + for (i=0;iTexture.ObjectPlaneS ); + } + break; + case GL_EYE_LINEAR: + for (i=0;iTexture.EyePlaneS ); + } + break; + case GL_SPHERE_MAP: + for (i=0;iTexture.TexGenEnabled & T_BIT) { + GLint i; + switch (ctx->Texture.GenModeT) { + case GL_OBJECT_LINEAR: + for (i=0;iTexture.ObjectPlaneT ); + } + break; + case GL_EYE_LINEAR: + for (i=0;iTexture.EyePlaneT ); + } + break; + case GL_SPHERE_MAP: + for (i=0;iTexture.TexGenEnabled & R_BIT) { + GLint i; + switch (ctx->Texture.GenModeR) { + case GL_OBJECT_LINEAR: + for (i=0;iTexture.ObjectPlaneR ); + } + break; + case GL_EYE_LINEAR: + for (i=0;iTexture.EyePlaneR ); + } + break; + default: + gl_problem(ctx, "Bad R texgen"); + return; + } + } + + if (ctx->Texture.TexGenEnabled & Q_BIT) { + GLint i; + switch (ctx->Texture.GenModeQ) { + case GL_OBJECT_LINEAR: + for (i=0;iTexture.ObjectPlaneQ ); + } + break; + case GL_EYE_LINEAR: + for (i=0;iTexture.EyePlaneQ ); + } + break; + default: + gl_problem(ctx, "Bad Q texgen"); + return; + } + } +} + + + +/* + * Paletted texture sampling. + * Input: tObj - the texture object + * index - the palette index (8-bit only) + * Output: red, green, blue, alpha - the texel color + */ +static void palette_sample(const struct gl_texture_object *tObj, + GLubyte index, GLubyte *red, GLubyte *green, + GLubyte *blue, GLubyte *alpha) +{ + GLint i = index; + const GLubyte *palette; + + palette = tObj->Palette; + + switch (tObj->PaletteFormat) { + case GL_ALPHA: + *alpha = tObj->Palette[index]; + return; + case GL_LUMINANCE: + case GL_INTENSITY: + *red = palette[index]; + return; + case GL_LUMINANCE_ALPHA: + *red = palette[(index << 1) + 0]; + *alpha = palette[(index << 1) + 1]; + return; + case GL_RGB: + *red = palette[index * 3 + 0]; + *green = palette[index * 3 + 1]; + *blue = palette[index * 3 + 2]; + return; + case GL_RGBA: + *red = palette[(i << 2) + 0]; + *green = palette[(i << 2) + 1]; + *blue = palette[(i << 2) + 2]; + *alpha = palette[(i << 2) + 3]; + return; + default: + gl_problem(NULL, "Bad palette format in palette_sample"); + } +} + + + + +/**********************************************************************/ +/* 1-D Texture Sampling Functions */ +/**********************************************************************/ + + +/* + * Return the fractional part of x. + */ +#define frac(x) ((GLfloat)(x)-floor((GLfloat)x)) + + + +/* + * Given 1-D texture image and an (i) texel column coordinate, return the + * texel color. + */ +static void get_1d_texel( const struct gl_texture_object *tObj, + const struct gl_texture_image *img, GLint i, + GLubyte *red, GLubyte *green, GLubyte *blue, + GLubyte *alpha ) +{ + GLubyte *texel; + +#ifdef DEBUG + GLint width = img->Width; + if (i<0 || i>=width) abort(); +#endif + + switch (img->Format) { + case GL_COLOR_INDEX: + { + GLubyte index = img->Data[i]; + palette_sample(tObj, index, red, green, blue, alpha); + return; + } + return; + case GL_ALPHA: + *alpha = img->Data[ i ]; + return; + case GL_LUMINANCE: + case GL_INTENSITY: + *red = img->Data[ i ]; + return; + case GL_LUMINANCE_ALPHA: + texel = img->Data + i * 2; + *red = texel[0]; + *alpha = texel[1]; + return; + case GL_RGB: + texel = img->Data + i * 3; + *red = texel[0]; + *green = texel[1]; + *blue = texel[2]; + return; + case GL_RGBA: + texel = img->Data + i * 4; + *red = texel[0]; + *green = texel[1]; + *blue = texel[2]; + *alpha = texel[3]; + return; + default: + gl_problem(NULL, "Bad format in get_1d_texel"); + return; + } +} + + + +/* + * Return the texture sample for coordinate (s) using GL_NEAREST filter. + */ +static void sample_1d_nearest( const struct gl_texture_object *tObj, + const struct gl_texture_image *img, + GLfloat s, + GLubyte *red, GLubyte *green, + GLubyte *blue, GLubyte *alpha ) +{ + GLint width = img->Width2; /* without border, power of two */ + GLint i; + GLubyte *texel; + + /* Clamp/Repeat S and convert to integer texel coordinate */ + if (tObj->WrapS==GL_REPEAT) { + /* s limited to [0,1) */ + /* i limited to [0,width-1] */ + i = (GLint) (s * width); + if (s<0.0F) i -= 1; + i &= (width-1); + } + else { + /* s limited to [0,1] */ + /* i limited to [0,width-1] */ + if (s<0.0F) i = 0; + else if (s>1.0F) i = width-1; + else i = (GLint) (s * width); + } + + /* skip over the border, if any */ + i += img->Border; + + /* Get the texel */ + switch (img->Format) { + case GL_COLOR_INDEX: + { + GLubyte index = img->Data[i]; + palette_sample(tObj, index, red, green, blue, alpha); + return; + } + case GL_ALPHA: + *alpha = img->Data[i]; + return; + case GL_LUMINANCE: + case GL_INTENSITY: + *red = img->Data[i]; + return; + case GL_LUMINANCE_ALPHA: + texel = img->Data + i * 2; + *red = texel[0]; + *alpha = texel[1]; + return; + case GL_RGB: + texel = img->Data + i * 3; + *red = texel[0]; + *green = texel[1]; + *blue = texel[2]; + return; + case GL_RGBA: + texel = img->Data + i * 4; + *red = texel[0]; + *green = texel[1]; + *blue = texel[2]; + *alpha = texel[3]; + return; + default: + gl_problem(NULL, "Bad format in sample_1d_nearest"); + } +} + + + +/* + * Return the texture sample for coordinate (s) using GL_LINEAR filter. + */ +static void sample_1d_linear( const struct gl_texture_object *tObj, + const struct gl_texture_image *img, + GLfloat s, + GLubyte *red, GLubyte *green, + GLubyte *blue, GLubyte *alpha ) +{ + GLint width = img->Width2; + GLint i0, i1; + GLfloat u; + GLint i0border, i1border; + + u = s * width; + if (tObj->WrapS==GL_REPEAT) { + i0 = ((GLint) floor(u - 0.5F)) % width; + i1 = (i0 + 1) & (width-1); + i0border = i1border = 0; + } + else { + i0 = (GLint) floor(u - 0.5F); + i1 = i0 + 1; + i0border = (i0<0) | (i0>=width); + i1border = (i1<0) | (i1>=width); + } + + if (img->Border) { + i0 += img->Border; + i1 += img->Border; + i0border = i1border = 0; + } + else { + i0 &= (width-1); + } + + { + GLfloat a = frac(u - 0.5F); + + GLint w0 = (GLint) ((1.0F-a) * 256.0F); + GLint w1 = (GLint) ( a * 256.0F); + + GLubyte red0, green0, blue0, alpha0; + GLubyte red1, green1, blue1, alpha1; + + if (i0border) { + red0 = tObj->BorderColor[0]; + green0 = tObj->BorderColor[1]; + blue0 = tObj->BorderColor[2]; + alpha0 = tObj->BorderColor[3]; + } + else { + get_1d_texel( tObj, img, i0, &red0, &green0, &blue0, &alpha0 ); + } + if (i1border) { + red1 = tObj->BorderColor[0]; + green1 = tObj->BorderColor[1]; + blue1 = tObj->BorderColor[2]; + alpha1 = tObj->BorderColor[3]; + } + else { + get_1d_texel( tObj, img, i1, &red1, &green1, &blue1, &alpha1 ); + } + + *red = (w0*red0 + w1*red1) >> 8; + *green = (w0*green0 + w1*green1) >> 8; + *blue = (w0*blue0 + w1*blue1) >> 8; + *alpha = (w0*alpha0 + w1*alpha1) >> 8; + } +} + + +static void +sample_1d_nearest_mipmap_nearest( const struct gl_texture_object *tObj, + GLfloat s, GLfloat lambda, + GLubyte *red, GLubyte *green, + GLubyte *blue, GLubyte *alpha ) +{ + GLint level; + if (lambda<=0.5F) { + level = 0; + } + else { + GLint widthlog2 = tObj->Image[0]->WidthLog2; + level = (GLint) (lambda + 0.499999F); + if (level>widthlog2 ) { + level = widthlog2; + } + } + sample_1d_nearest( tObj, tObj->Image[level], + s, red, green, blue, alpha ); +} + + +static void +sample_1d_linear_mipmap_nearest( const struct gl_texture_object *tObj, + GLfloat s, GLfloat lambda, + GLubyte *red, GLubyte *green, + GLubyte *blue, GLubyte *alpha ) +{ + GLint level; + if (lambda<=0.5F) { + level = 0; + } + else { + GLint widthlog2 = tObj->Image[0]->WidthLog2; + level = (GLint) (lambda + 0.499999F); + if (level>widthlog2 ) { + level = widthlog2; + } + } + sample_1d_linear( tObj, tObj->Image[level], + s, red, green, blue, alpha ); +} + + + +static void +sample_1d_nearest_mipmap_linear( const struct gl_texture_object *tObj, + GLfloat s, GLfloat lambda, + GLubyte *red, GLubyte *green, + GLubyte *blue, GLubyte *alpha ) +{ + GLint max = tObj->Image[0]->MaxLog2; + + if (lambda>=max) { + sample_1d_nearest( tObj, tObj->Image[max], + s, red, green, blue, alpha ); + } + else { + GLubyte red0, green0, blue0, alpha0; + GLubyte red1, green1, blue1, alpha1; + GLfloat f = frac(lambda); + GLint level = (GLint) (lambda + 1.0F); + level = CLAMP( level, 1, max ); + sample_1d_nearest( tObj, tObj->Image[level-1], + s, &red0, &green0, &blue0, &alpha0 ); + sample_1d_nearest( tObj, tObj->Image[level], + s, &red1, &green1, &blue1, &alpha1 ); + *red = (1.0F-f)*red0 + f*red1; + *green = (1.0F-f)*green0 + f*green1; + *blue = (1.0F-f)*blue0 + f*blue1; + *alpha = (1.0F-f)*alpha0 + f*alpha1; + } +} + + + +static void +sample_1d_linear_mipmap_linear( const struct gl_texture_object *tObj, + GLfloat s, GLfloat lambda, + GLubyte *red, GLubyte *green, + GLubyte *blue, GLubyte *alpha ) +{ + GLint max = tObj->Image[0]->MaxLog2; + + if (lambda>=max) { + sample_1d_linear( tObj, tObj->Image[max], + s, red, green, blue, alpha ); + } + else { + GLubyte red0, green0, blue0, alpha0; + GLubyte red1, green1, blue1, alpha1; + GLfloat f = frac(lambda); + GLint level = (GLint) (lambda + 1.0F); + level = CLAMP( level, 1, max ); + sample_1d_linear( tObj, tObj->Image[level-1], + s, &red0, &green0, &blue0, &alpha0 ); + sample_1d_linear( tObj, tObj->Image[level], + s, &red1, &green1, &blue1, &alpha1 ); + *red = (1.0F-f)*red0 + f*red1; + *green = (1.0F-f)*green0 + f*green1; + *blue = (1.0F-f)*blue0 + f*blue1; + *alpha = (1.0F-f)*alpha0 + f*alpha1; + } +} + + + +static void sample_nearest_1d( const struct gl_texture_object *tObj, GLuint n, + const GLfloat s[], const GLfloat t[], + const GLfloat u[], const GLfloat lambda[], + GLubyte red[], GLubyte green[], GLubyte blue[], + GLubyte alpha[] ) +{ + GLuint i; + for (i=0;iImage[0], s[i], + &red[i], &green[i], &blue[i], &alpha[i]); + } +} + + + +static void sample_linear_1d( const struct gl_texture_object *tObj, GLuint n, + const GLfloat s[], const GLfloat t[], + const GLfloat u[], const GLfloat lambda[], + GLubyte red[], GLubyte green[], GLubyte blue[], + GLubyte alpha[] ) +{ + GLuint i; + for (i=0;iImage[0], s[i], + &red[i], &green[i], &blue[i], &alpha[i]); + } +} + + +/* + * Given an (s) texture coordinate and lambda (level of detail) value, + * return a texture sample. + * + */ +static void sample_lambda_1d( const struct gl_texture_object *tObj, GLuint n, + const GLfloat s[], const GLfloat t[], + const GLfloat u[], const GLfloat lambda[], + GLubyte red[], GLubyte green[], GLubyte blue[], + GLubyte alpha[] ) +{ + GLuint i; + + for (i=0;i tObj->MinMagThresh) { + /* minification */ + switch (tObj->MinFilter) { + case GL_NEAREST: + sample_1d_nearest( tObj, tObj->Image[0], s[i], + &red[i], &green[i], &blue[i], &alpha[i] ); + break; + case GL_LINEAR: + sample_1d_linear( tObj, tObj->Image[0], s[i], + &red[i], &green[i], &blue[i], &alpha[i] ); + break; + case GL_NEAREST_MIPMAP_NEAREST: + sample_1d_nearest_mipmap_nearest( tObj, lambda[i], s[i], + &red[i], &green[i], &blue[i], &alpha[i] ); + break; + case GL_LINEAR_MIPMAP_NEAREST: + sample_1d_linear_mipmap_nearest( tObj, s[i], lambda[i], + &red[i], &green[i], &blue[i], &alpha[i] ); + break; + case GL_NEAREST_MIPMAP_LINEAR: + sample_1d_nearest_mipmap_linear( tObj, s[i], lambda[i], + &red[i], &green[i], &blue[i], &alpha[i] ); + break; + case GL_LINEAR_MIPMAP_LINEAR: + sample_1d_linear_mipmap_linear( tObj, s[i], lambda[i], + &red[i], &green[i], &blue[i], &alpha[i] ); + break; + default: + gl_problem(NULL, "Bad min filter in sample_1d_texture"); + return; + } + } + else { + /* magnification */ + switch (tObj->MagFilter) { + case GL_NEAREST: + sample_1d_nearest( tObj, tObj->Image[0], s[i], + &red[i], &green[i], &blue[i], &alpha[i] ); + break; + case GL_LINEAR: + sample_1d_linear( tObj, tObj->Image[0], s[i], + &red[i], &green[i], &blue[i], &alpha[i] ); + break; + default: + gl_problem(NULL, "Bad mag filter in sample_1d_texture"); + return; + } + } + } +} + + + + +/**********************************************************************/ +/* 2-D Texture Sampling Functions */ +/**********************************************************************/ + + +/* + * Given a texture image and an (i,j) integer texel coordinate, return the + * texel color. + */ +static void get_2d_texel( const struct gl_texture_object *tObj, + const struct gl_texture_image *img, GLint i, GLint j, + GLubyte *red, GLubyte *green, GLubyte *blue, + GLubyte *alpha ) +{ + GLint width = img->Width; /* includes border */ + GLubyte *texel; + +#ifdef DEBUG + GLint height = img->Height; /* includes border */ + if (i<0 || i>=width) abort(); + if (j<0 || j>=height) abort(); +#endif + + switch (img->Format) { + case GL_COLOR_INDEX: + { + GLubyte index = img->Data[ width *j + i ]; + palette_sample(tObj, index, red, green, blue, alpha); + return; + } + case GL_ALPHA: + *alpha = img->Data[ width * j + i ]; + return; + case GL_LUMINANCE: + case GL_INTENSITY: + *red = img->Data[ width * j + i ]; + return; + case GL_LUMINANCE_ALPHA: + texel = img->Data + (width * j + i) * 2; + *red = texel[0]; + *alpha = texel[1]; + return; + case GL_RGB: + texel = img->Data + (width * j + i) * 3; + *red = texel[0]; + *green = texel[1]; + *blue = texel[2]; + return; + case GL_RGBA: + texel = img->Data + (width * j + i) * 4; + *red = texel[0]; + *green = texel[1]; + *blue = texel[2]; + *alpha = texel[3]; + return; + default: + gl_problem(NULL, "Bad format in get_2d_texel"); + } +} + + + +/* + * Return the texture sample for coordinate (s,t) using GL_NEAREST filter. + */ +static void sample_2d_nearest( const struct gl_texture_object *tObj, + const struct gl_texture_image *img, + GLfloat s, GLfloat t, + GLubyte *red, GLubyte *green, + GLubyte *blue, GLubyte *alpha ) +{ + GLint imgWidth = img->Width; /* includes border */ + GLint width = img->Width2; /* without border, power of two */ + GLint height = img->Height2; /* without border, power of two */ + GLint i, j; + GLubyte *texel; + + /* Clamp/Repeat S and convert to integer texel coordinate */ + if (tObj->WrapS==GL_REPEAT) { + /* s limited to [0,1) */ + /* i limited to [0,width-1] */ + i = (GLint) (s * width); + if (s<0.0F) i -= 1; + i &= (width-1); + } + else { + /* s limited to [0,1] */ + /* i limited to [0,width-1] */ + if (s<=0.0F) i = 0; + else if (s>1.0F) i = width-1; + else i = (GLint) (s * width); + } + + /* Clamp/Repeat T and convert to integer texel coordinate */ + if (tObj->WrapT==GL_REPEAT) { + /* t limited to [0,1) */ + /* j limited to [0,height-1] */ + j = (GLint) (t * height); + if (t<0.0F) j -= 1; + j &= (height-1); + } + else { + /* t limited to [0,1] */ + /* j limited to [0,height-1] */ + if (t<=0.0F) j = 0; + else if (t>1.0F) j = height-1; + else j = (GLint) (t * height); + } + + /* skip over the border, if any */ + i += img->Border; + j += img->Border; + + switch (img->Format) { + case GL_COLOR_INDEX: + { + GLubyte index = img->Data[ j * imgWidth + i ]; + palette_sample(tObj, index, red, green, blue, alpha); + return; + } + case GL_ALPHA: + *alpha = img->Data[ j * imgWidth + i ]; + return; + case GL_LUMINANCE: + case GL_INTENSITY: + *red = img->Data[ j * imgWidth + i ]; + return; + case GL_LUMINANCE_ALPHA: + texel = img->Data + ((j * imgWidth + i) << 1); + *red = texel[0]; + *alpha = texel[1]; + return; + case GL_RGB: + texel = img->Data + (j * imgWidth + i) * 3; + *red = texel[0]; + *green = texel[1]; + *blue = texel[2]; + return; + case GL_RGBA: + texel = img->Data + ((j * imgWidth + i) << 2); + *red = texel[0]; + *green = texel[1]; + *blue = texel[2]; + *alpha = texel[3]; + return; + default: + gl_problem(NULL, "Bad format in sample_2d_nearest"); + } +} + + + +/* + * Return the texture sample for coordinate (s,t) using GL_LINEAR filter. + */ +static void sample_2d_linear( const struct gl_texture_object *tObj, + const struct gl_texture_image *img, + GLfloat s, GLfloat t, + GLubyte *red, GLubyte *green, + GLubyte *blue, GLubyte *alpha ) +{ + GLint width = img->Width2; + GLint height = img->Height2; + GLint i0, j0, i1, j1; + GLint i0border, j0border, i1border, j1border; + GLfloat u, v; + + u = s * width; + if (tObj->WrapS==GL_REPEAT) { + i0 = ((GLint) floor(u - 0.5F)) % width; + i1 = (i0 + 1) & (width-1); + i0border = i1border = 0; + } + else { + i0 = (GLint) floor(u - 0.5F); + i1 = i0 + 1; + i0border = (i0<0) | (i0>=width); + i1border = (i1<0) | (i1>=width); + } + + v = t * height; + if (tObj->WrapT==GL_REPEAT) { + j0 = ((GLint) floor(v - 0.5F)) % height; + j1 = (j0 + 1) & (height-1); + j0border = j1border = 0; + } + else { + j0 = (GLint) floor(v - 0.5F ); + j1 = j0 + 1; + j0border = (j0<0) | (j0>=height); + j1border = (j1<0) | (j1>=height); + } + + if (img->Border) { + i0 += img->Border; + i1 += img->Border; + j0 += img->Border; + j1 += img->Border; + i0border = i1border = 0; + j0border = j1border = 0; + } + else { + i0 &= (width-1); + j0 &= (height-1); + } + + { + GLfloat a = frac(u - 0.5F); + GLfloat b = frac(v - 0.5F); + + GLint w00 = (GLint) ((1.0F-a)*(1.0F-b) * 256.0F); + GLint w10 = (GLint) ( a *(1.0F-b) * 256.0F); + GLint w01 = (GLint) ((1.0F-a)* b * 256.0F); + GLint w11 = (GLint) ( a * b * 256.0F); + + GLubyte red00, green00, blue00, alpha00; + GLubyte red10, green10, blue10, alpha10; + GLubyte red01, green01, blue01, alpha01; + GLubyte red11, green11, blue11, alpha11; + + if (i0border | j0border) { + red00 = tObj->BorderColor[0]; + green00 = tObj->BorderColor[1]; + blue00 = tObj->BorderColor[2]; + alpha00 = tObj->BorderColor[3]; + } + else { + get_2d_texel( tObj, img, i0, j0, &red00, &green00, &blue00, &alpha00); + } + if (i1border | j0border) { + red10 = tObj->BorderColor[0]; + green10 = tObj->BorderColor[1]; + blue10 = tObj->BorderColor[2]; + alpha10 = tObj->BorderColor[3]; + } + else { + get_2d_texel( tObj, img, i1, j0, &red10, &green10, &blue10, &alpha10); + } + if (i0border | j1border) { + red01 = tObj->BorderColor[0]; + green01 = tObj->BorderColor[1]; + blue01 = tObj->BorderColor[2]; + alpha01 = tObj->BorderColor[3]; + } + else { + get_2d_texel( tObj, img, i0, j1, &red01, &green01, &blue01, &alpha01); + } + if (i1border | j1border) { + red11 = tObj->BorderColor[0]; + green11 = tObj->BorderColor[1]; + blue11 = tObj->BorderColor[2]; + alpha11 = tObj->BorderColor[3]; + } + else { + get_2d_texel( tObj, img, i1, j1, &red11, &green11, &blue11, &alpha11); + } + + *red = (w00*red00 + w10*red10 + w01*red01 + w11*red11 ) >> 8; + *green = (w00*green00 + w10*green10 + w01*green01 + w11*green11) >> 8; + *blue = (w00*blue00 + w10*blue10 + w01*blue01 + w11*blue11 ) >> 8; + *alpha = (w00*alpha00 + w10*alpha10 + w01*alpha01 + w11*alpha11) >> 8; + } +} + + + +static void +sample_2d_nearest_mipmap_nearest( const struct gl_texture_object *tObj, + GLfloat s, GLfloat t, GLfloat lambda, + GLubyte *red, GLubyte *green, + GLubyte *blue, GLubyte *alpha ) +{ + GLint level; + if (lambda<=0.5F) { + level = 0; + } + else { + GLint max = tObj->Image[0]->MaxLog2; + level = (GLint) (lambda + 0.499999F); + if (level>max) { + level = max; + } + } + sample_2d_nearest( tObj, tObj->Image[level], + s, t, red, green, blue, alpha ); +} + + + +static void +sample_2d_linear_mipmap_nearest( const struct gl_texture_object *tObj, + GLfloat s, GLfloat t, GLfloat lambda, + GLubyte *red, GLubyte *green, + GLubyte *blue, GLubyte *alpha ) +{ + GLint level; + if (lambda<=0.5F) { + level = 0; + } + else { + GLint max = tObj->Image[0]->MaxLog2; + level = (GLint) (lambda + 0.499999F); + if (level>max) { + level = max; + } + } + sample_2d_linear( tObj, tObj->Image[level], + s, t, red, green, blue, alpha ); +} + + + +static void +sample_2d_nearest_mipmap_linear( const struct gl_texture_object *tObj, + GLfloat s, GLfloat t, GLfloat lambda, + GLubyte *red, GLubyte *green, + GLubyte *blue, GLubyte *alpha ) +{ + GLint max = tObj->Image[0]->MaxLog2; + + if (lambda>=max) { + sample_2d_nearest( tObj, tObj->Image[max], + s, t, red, green, blue, alpha ); + } + else { + GLubyte red0, green0, blue0, alpha0; + GLubyte red1, green1, blue1, alpha1; + GLfloat f = frac(lambda); + GLint level = (GLint) (lambda + 1.0F); + level = CLAMP( level, 1, max ); + sample_2d_nearest( tObj, tObj->Image[level-1], s, t, + &red0, &green0, &blue0, &alpha0 ); + sample_2d_nearest( tObj, tObj->Image[level], s, t, + &red1, &green1, &blue1, &alpha1 ); + *red = (1.0F-f)*red0 + f*red1; + *green = (1.0F-f)*green0 + f*green1; + *blue = (1.0F-f)*blue0 + f*blue1; + *alpha = (1.0F-f)*alpha0 + f*alpha1; + } +} + + + +static void +sample_2d_linear_mipmap_linear( const struct gl_texture_object *tObj, + GLfloat s, GLfloat t, GLfloat lambda, + GLubyte *red, GLubyte *green, + GLubyte *blue, GLubyte *alpha ) +{ + GLint max = tObj->Image[0]->MaxLog2; + + if (lambda>=max) { + sample_2d_linear( tObj, tObj->Image[max], + s, t, red, green, blue, alpha ); + } + else { + GLubyte red0, green0, blue0, alpha0; + GLubyte red1, green1, blue1, alpha1; + GLfloat f = frac(lambda); + GLint level = (GLint) (lambda + 1.0F); + level = CLAMP( level, 1, max ); + sample_2d_linear( tObj, tObj->Image[level-1], s, t, + &red0, &green0, &blue0, &alpha0 ); + sample_2d_linear( tObj, tObj->Image[level], s, t, + &red1, &green1, &blue1, &alpha1 ); + *red = (1.0F-f)*red0 + f*red1; + *green = (1.0F-f)*green0 + f*green1; + *blue = (1.0F-f)*blue0 + f*blue1; + *alpha = (1.0F-f)*alpha0 + f*alpha1; + } +} + + + +static void sample_nearest_2d( const struct gl_texture_object *tObj, GLuint n, + const GLfloat s[], const GLfloat t[], + const GLfloat u[], const GLfloat lambda[], + GLubyte red[], GLubyte green[], GLubyte blue[], + GLubyte alpha[] ) +{ + GLuint i; + for (i=0;iImage[0], s[i], t[i], + &red[i], &green[i], &blue[i], &alpha[i]); + } +} + + + +static void sample_linear_2d( const struct gl_texture_object *tObj, GLuint n, + const GLfloat s[], const GLfloat t[], + const GLfloat u[], const GLfloat lambda[], + GLubyte red[], GLubyte green[], GLubyte blue[], + GLubyte alpha[] ) +{ + GLuint i; + for (i=0;iImage[0], s[i], t[i], + &red[i], &green[i], &blue[i], &alpha[i]); + } +} + + +/* + * Given an (s,t) texture coordinate and lambda (level of detail) value, + * return a texture sample. + */ +static void sample_lambda_2d( const struct gl_texture_object *tObj, + GLuint n, + const GLfloat s[], const GLfloat t[], + const GLfloat u[], const GLfloat lambda[], + GLubyte red[], GLubyte green[], GLubyte blue[], + GLubyte alpha[] ) +{ + GLuint i; + for (i=0;i tObj->MinMagThresh) { + /* minification */ + switch (tObj->MinFilter) { + case GL_NEAREST: + sample_2d_nearest( tObj, tObj->Image[0], s[i], t[i], + &red[i], &green[i], &blue[i], &alpha[i] ); + break; + case GL_LINEAR: + sample_2d_linear( tObj, tObj->Image[0], s[i], t[i], + &red[i], &green[i], &blue[i], &alpha[i] ); + break; + case GL_NEAREST_MIPMAP_NEAREST: + sample_2d_nearest_mipmap_nearest( tObj, s[i], t[i], lambda[i], + &red[i], &green[i], &blue[i], &alpha[i] ); + break; + case GL_LINEAR_MIPMAP_NEAREST: + sample_2d_linear_mipmap_nearest( tObj, s[i], t[i], lambda[i], + &red[i], &green[i], &blue[i], &alpha[i] ); + break; + case GL_NEAREST_MIPMAP_LINEAR: + sample_2d_nearest_mipmap_linear( tObj, s[i], t[i], lambda[i], + &red[i], &green[i], &blue[i], &alpha[i] ); + break; + case GL_LINEAR_MIPMAP_LINEAR: + sample_2d_linear_mipmap_linear( tObj, s[i], t[i], lambda[i], + &red[i], &green[i], &blue[i], &alpha[i] ); + break; + default: + gl_problem(NULL, "Bad min filter in sample_2d_texture"); + return; + } + } + else { + /* magnification */ + switch (tObj->MagFilter) { + case GL_NEAREST: + sample_2d_nearest( tObj, tObj->Image[0], s[i], t[i], + &red[i], &green[i], &blue[i], &alpha[i] ); + break; + case GL_LINEAR: + sample_2d_linear( tObj, tObj->Image[0], s[i], t[i], + &red[i], &green[i], &blue[i], &alpha[i] ); + break; + default: + gl_problem(NULL, "Bad mag filter in sample_2d_texture"); + } + } + } +} + + +/* + * Optimized 2-D texture sampling: + * S and T wrap mode == GL_REPEAT + * No border + * Format = GL_RGB + */ +static void opt_sample_rgb_2d( const struct gl_texture_object *tObj, + GLuint n, const GLfloat s[], const GLfloat t[], + const GLfloat u[], const GLfloat lamda[], + GLubyte red[], GLubyte green[], + GLubyte blue[], GLubyte alpha[] ) +{ + const struct gl_texture_image *img = tObj->Image[0]; + GLfloat width = img->Width, height = img->Height; + GLint colMask = img->Width-1, rowMask = img->Height-1; + GLint shift = img->WidthLog2; + GLuint k; + + ASSERT(tObj->WrapS==GL_REPEAT); + ASSERT(tObj->WrapT==GL_REPEAT); + ASSERT(img->Border==0); + ASSERT(img->Format==GL_RGB); + + for (k=0;kData + pos + pos + pos; /* pos*3 */ + red[k] = texel[0]; + green[k] = texel[1]; + blue[k] = texel[2]; + } +} + + +/* + * Optimized 2-D texture sampling: + * S and T wrap mode == GL_REPEAT + * No border + * Format = GL_RGBA + */ +static void opt_sample_rgba_2d( const struct gl_texture_object *tObj, + GLuint n, const GLfloat s[], const GLfloat t[], + const GLfloat u[], const GLfloat lamda[], + GLubyte red[], GLubyte green[], + GLubyte blue[], GLubyte alpha[] ) +{ + const struct gl_texture_image *img = tObj->Image[0]; + GLfloat width = img->Width, height = img->Height; + GLint colMask = img->Width-1, rowMask = img->Height-1; + GLint shift = img->WidthLog2; + GLuint k; + + ASSERT(tObj->WrapS==GL_REPEAT); + ASSERT(tObj->WrapT==GL_REPEAT); + ASSERT(img->Border==0); + ASSERT(img->Format==GL_RGBA); + + for (k=0;kData + (pos << 2); /* pos*4 */ + red[k] = texel[0]; + green[k] = texel[1]; + blue[k] = texel[2]; + alpha[k] = texel[3]; + } +} + + +/**********************************************************************/ +/* Texture Sampling Setup */ +/**********************************************************************/ + + +/* + * Setup the texture sampling function for this texture object. + */ +void gl_set_texture_sampler( struct gl_texture_object *t ) +{ + if (!t->Complete) { + t->SampleFunc = NULL; + } + else { + GLboolean needLambda = (t->MinFilter != t->MagFilter); + + if (needLambda) { + /* Compute min/mag filter threshold */ + if (t->MagFilter==GL_LINEAR + && (t->MinFilter==GL_NEAREST_MIPMAP_NEAREST || + t->MinFilter==GL_LINEAR_MIPMAP_NEAREST)) { + t->MinMagThresh = 0.5F; + } + else { + t->MinMagThresh = 0.0F; + } + } + + switch (t->Dimensions) { + case 1: + if (needLambda) { + t->SampleFunc = sample_lambda_1d; + } + else if (t->MinFilter==GL_LINEAR) { + t->SampleFunc = sample_linear_1d; + } + else { + ASSERT(t->MinFilter==GL_NEAREST); + t->SampleFunc = sample_nearest_1d; + } + break; + case 2: + if (needLambda) { + t->SampleFunc = sample_lambda_2d; + } + else if (t->MinFilter==GL_LINEAR) { + t->SampleFunc = sample_linear_2d; + } + else { + ASSERT(t->MinFilter==GL_NEAREST); + if (t->WrapS==GL_REPEAT && t->WrapT==GL_REPEAT + && t->Image[0]->Border==0 && t->Image[0]->Format==GL_RGB) { + t->SampleFunc = opt_sample_rgb_2d; + } + else if (t->WrapS==GL_REPEAT && t->WrapT==GL_REPEAT + && t->Image[0]->Border==0 && t->Image[0]->Format==GL_RGBA) { + t->SampleFunc = opt_sample_rgba_2d; + } + else + t->SampleFunc = sample_nearest_2d; + } + break; + default: + gl_problem(NULL, "invalid dimensions in gl_set_texture_sampler"); + } + } +} + + + +/**********************************************************************/ +/* Texture Application */ +/**********************************************************************/ + + +/* + * Combine incoming fragment color with texel color to produce output color. + * Input: n - number of fragments + * format - base internal texture format + * env_mode - texture environment mode + * Rt, Gt, Bt, At - array of texel colors + * InOut: red, green, blue, alpha - incoming fragment colors modified + * by texel colors according to the + * texture environment mode. + */ +static void apply_texture( GLcontext *ctx, + GLuint n, GLint format, GLenum env_mode, + GLubyte red[], GLubyte green[], GLubyte blue[], GLubyte alpha[], + GLubyte Rt[], GLubyte Gt[], GLubyte Bt[], GLubyte At[] ) +{ + GLuint i; + GLint Rc, Gc, Bc, Ac; + + if (!ctx->Visual->EightBitColor) { + /* This is a hack! Rescale input colors from [0,scale] to [0,255]. */ + GLfloat rscale = 255.0 * ctx->Visual->InvRedScale; + GLfloat gscale = 255.0 * ctx->Visual->InvGreenScale; + GLfloat bscale = 255.0 * ctx->Visual->InvBlueScale; + GLfloat ascale = 255.0 * ctx->Visual->InvAlphaScale; + for (i=0;i> 8 as a fast approximation of (A*B)/255 for A + * and B in [0,255] + */ +#define PROD(A,B) (((GLint)(A) * ((GLint)(B)+1)) >> 8) + + if (format==GL_COLOR_INDEX) { + format = GL_RGBA; /* XXXX a hack! */ + } + + switch (env_mode) { + case GL_REPLACE: + switch (format) { + case GL_ALPHA: + for (i=0;iTexture.EnvColor[0] * 255.0F); + Gc = (GLint) (ctx->Texture.EnvColor[1] * 255.0F); + Bc = (GLint) (ctx->Texture.EnvColor[2] * 255.0F); + Ac = (GLint) (ctx->Texture.EnvColor[3] * 255.0F); + switch (format) { + case GL_ALPHA: + for (i=0;iVisual->EightBitColor) { + /* This is a hack! Rescale input colors from [0,255] to [0,scale]. */ + GLfloat rscale = ctx->Visual->RedScale * (1.0F/ 255.0F); + GLfloat gscale = ctx->Visual->GreenScale * (1.0F/ 255.0F); + GLfloat bscale = ctx->Visual->BlueScale * (1.0F/ 255.0F); + GLfloat ascale = ctx->Visual->AlphaScale * (1.0F/ 255.0F); + for (i=0;iTexture.Current || !ctx->Texture.Current->SampleFunc) + return; + + /* Sample the texture. */ + (*ctx->Texture.Current->SampleFunc)( ctx->Texture.Current, n, + s, t, r, lambda, + tred, tgreen, tblue, talpha ); + + apply_texture( ctx, n, + ctx->Texture.Current->Image[0]->Format, + ctx->Texture.EnvMode, + red, green, blue, alpha, + tred, tgreen, tblue, talpha ); +} diff --git a/dll/opengl/mesa/texture.h b/dll/opengl/mesa/texture.h new file mode 100644 index 00000000000..046c145731e --- /dev/null +++ b/dll/opengl/mesa/texture.h @@ -0,0 +1,79 @@ +/* $Id: texture.h,v 1.8 1997/11/13 02:17:32 brianp Exp $ */ + +/* + * Mesa 3-D graphics library + * Version: 2.5 + * Copyright (C) 1995-1997 Brian Paul + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Library General Public + * License as published by the Free Software Foundation; either + * version 2 of the License, or (at your option) any later version. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Library General Public License for more details. + * + * You should have received a copy of the GNU Library General Public + * License along with this library; if not, write to the Free + * Software Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. + */ + + +/* + * $Log: texture.h,v $ + * Revision 1.8 1997/11/13 02:17:32 brianp + * added a few const keywords + * + * Revision 1.7 1997/05/03 00:53:56 brianp + * all-new texture sampling via gl_texture_object's SampleFunc pointer + * + * Revision 1.6 1997/04/14 02:02:39 brianp + * moved many functions into new texstate.c file + * + * Revision 1.5 1997/02/09 18:53:14 brianp + * added GL_EXT_texture3D support + * + * Revision 1.4 1997/01/09 19:48:58 brianp + * added gl_texturing_enabled() + * + * Revision 1.3 1996/11/14 01:03:09 brianp + * removed const's from gl_texgen() function to avoid VMS compiler warning + * + * Revision 1.2 1996/11/08 02:20:09 brianp + * gl_do_texgen() replaced with gl_texgen() + * + * Revision 1.1 1996/09/13 01:38:16 brianp + * Initial revision + * + */ + + +#ifndef TEXTURE_H +#define TEXTURE_H + + +#include "types.h" + + +extern void gl_texgen( GLcontext *ctx, GLint n, + GLfloat obj[][4], GLfloat eye[][4], + GLfloat normal[][3], GLfloat texcoord[][4] ); + + + +extern void gl_set_texture_sampler( struct gl_texture_object *t ); + + + +extern void gl_texture_pixels( GLcontext *ctx, GLuint n, + const GLfloat s[], const GLfloat t[], + const GLfloat r[], + const GLfloat lambda[], + GLubyte red[], GLubyte green[], + GLubyte blue[], GLubyte alpha[] ); + + +#endif + diff --git a/dll/opengl/mesa/tnl/CMakeLists.txt b/dll/opengl/mesa/tnl/CMakeLists.txt deleted file mode 100644 index 734d23425f6..00000000000 --- a/dll/opengl/mesa/tnl/CMakeLists.txt +++ /dev/null @@ -1,22 +0,0 @@ - -list(APPEND SOURCE - t_context.c - t_draw.c - t_pipeline.c - t_rasterpos.c - t_vb_fog.c - t_vb_light.c - t_vb_normals.c - t_vb_points.c - t_vb_render.c - t_vb_texgen.c - t_vb_texmat.c - t_vb_vertex.c - t_vertex.c - t_vertex_generic.c - t_vertex_sse.c - precomp.h) - -add_library(mesa_tnl STATIC ${SOURCE}) -add_dependencies(mesa_tnl xdk) -add_pch(mesa_tnl precomp.h SOURCE) diff --git a/dll/opengl/mesa/tnl/precomp.h b/dll/opengl/mesa/tnl/precomp.h deleted file mode 100644 index d94a8196c74..00000000000 --- a/dll/opengl/mesa/tnl/precomp.h +++ /dev/null @@ -1,28 +0,0 @@ -#ifndef _MESA_TNL_PCH_ -#define _MESA_TNL_PCH_ - -#include
-#include
-#include
-#include
-#include
-#include
-#include
-#include
-#include
-#include
-#include
-#include
-#include
-#include -#include -#include -#include -#include - -#include "t_context.h" -#include "t_pipeline.h" -#include "t_vertex.h" -#include "tnl.h" - -#endif /* _MESA_TNL_PCH_ */ diff --git a/dll/opengl/mesa/tnl/t_context.c b/dll/opengl/mesa/tnl/t_context.c deleted file mode 100644 index e74f3e385a7..00000000000 --- a/dll/opengl/mesa/tnl/t_context.c +++ /dev/null @@ -1,176 +0,0 @@ -/* - * Mesa 3-D graphics library - * Version: 7.2 - * - * Copyright (C) 1999-2008 Brian Paul All Rights Reserved. - * - * Permission is hereby granted, free of charge, to any person obtaining a - * copy of this software and associated documentation files (the "Software"), - * to deal in the Software without restriction, including without limitation - * the rights to use, copy, modify, merge, publish, distribute, sublicense, - * and/or sell copies of the Software, and to permit persons to whom the - * Software is furnished to do so, subject to the following conditions: - * - * The above copyright notice and this permission notice shall be included - * in all copies or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS - * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL - * BRIAN PAUL BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN - * AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN - * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. - * - * Authors: - * Keith Whitwell - */ - -#include - -GLboolean -_tnl_CreateContext( struct gl_context *ctx ) -{ - TNLcontext *tnl; - - /* Create the TNLcontext structure - */ - ctx->swtnl_context = tnl = (TNLcontext *) CALLOC( sizeof(TNLcontext) ); - - if (!tnl) { - return GL_FALSE; - } - - /* Initialize the VB. - */ - tnl->vb.Size = ctx->Const.MaxArrayLockSize + MAX_CLIPPED_VERTICES; - - - /* Initialize tnl state. - */ - _tnl_install_pipeline( ctx, _tnl_default_pipeline ); - - tnl->NeedNdcCoords = GL_TRUE; - tnl->AllowVertexFog = GL_TRUE; - tnl->AllowPixelFog = GL_TRUE; - - /* Set a few default values in the driver struct. - */ - tnl->Driver.Render.PrimTabElts = _tnl_render_tab_elts; - tnl->Driver.Render.PrimTabVerts = _tnl_render_tab_verts; - tnl->Driver.NotifyMaterialChange = _mesa_validate_all_lighting_tables; - - tnl->nr_blocks = 0; - - /* plug in the VBO drawing function */ - vbo_set_draw_func(ctx, _tnl_vbo_draw_prims); - - _math_init_transformation(); - _math_init_translate(); - - return GL_TRUE; -} - - -void -_tnl_DestroyContext( struct gl_context *ctx ) -{ - TNLcontext *tnl = TNL_CONTEXT(ctx); - - _tnl_destroy_pipeline( ctx ); - - FREE(tnl); - ctx->swtnl_context = NULL; -} - - -void -_tnl_InvalidateState( struct gl_context *ctx, GLuint new_state ) -{ - TNLcontext *tnl = TNL_CONTEXT(ctx); - - if (new_state & _NEW_HINT) { - ASSERT(tnl->AllowVertexFog || tnl->AllowPixelFog); - tnl->_DoVertexFog = ((tnl->AllowVertexFog && (ctx->Hint.Fog != GL_NICEST)) - || !tnl->AllowPixelFog); - } - - tnl->pipeline.new_state |= new_state; - - /* Calculate tnl->render_inputs. This bitmask indicates which vertex - * attributes need to be emitted to the rasterizer. - */ - tnl->render_inputs_bitset = BITFIELD64_BIT(_TNL_ATTRIB_POS); - - tnl->render_inputs_bitset |= BITFIELD64_BIT(_TNL_ATTRIB_COLOR); - - if (ctx->Texture._EnabledCoord) { - tnl->render_inputs_bitset |= BITFIELD64_BIT(_TNL_ATTRIB_TEX); - } - - if (ctx->Fog.Enabled) { - /* Either fixed-function fog or a fragment program needs fog coord. - */ - tnl->render_inputs_bitset |= BITFIELD64_BIT(_TNL_ATTRIB_FOG); - } - - if (ctx->Polygon.FrontMode != GL_FILL || - ctx->Polygon.BackMode != GL_FILL) - tnl->render_inputs_bitset |= BITFIELD64_BIT(_TNL_ATTRIB_EDGEFLAG); - - if (ctx->RenderMode == GL_FEEDBACK) - tnl->render_inputs_bitset |= BITFIELD64_BIT(_TNL_ATTRIB_TEX); - - if (ctx->Point._Attenuated) - tnl->render_inputs_bitset |= BITFIELD64_BIT(_TNL_ATTRIB_POINTSIZE); -} - - -void -_tnl_wakeup( struct gl_context *ctx ) -{ - /* Assume we haven't been getting state updates either: - */ - _tnl_InvalidateState( ctx, ~0 ); - -#if 0 - if (ctx->Light.ColorMaterialEnabled) { - _mesa_update_color_material( ctx, - ctx->Current.Attrib[VERT_ATTRIB_COLOR0] ); - } -#endif -} - - - - -/** - * Drivers call this function to tell the TCL module whether or not - * it wants Normalized Device Coords (NDC) computed. I.e. whether - * we should "Divide-by-W". Software renders will want that. - */ -void -_tnl_need_projected_coords( struct gl_context *ctx, GLboolean mode ) -{ - TNLcontext *tnl = TNL_CONTEXT(ctx); - tnl->NeedNdcCoords = mode; -} - -void -_tnl_allow_vertex_fog( struct gl_context *ctx, GLboolean value ) -{ - TNLcontext *tnl = TNL_CONTEXT(ctx); - tnl->AllowVertexFog = value; - tnl->_DoVertexFog = ((tnl->AllowVertexFog && (ctx->Hint.Fog != GL_NICEST)) - || !tnl->AllowPixelFog); - -} - -void -_tnl_allow_pixel_fog( struct gl_context *ctx, GLboolean value ) -{ - TNLcontext *tnl = TNL_CONTEXT(ctx); - tnl->AllowPixelFog = value; - tnl->_DoVertexFog = ((tnl->AllowVertexFog && (ctx->Hint.Fog != GL_NICEST)) - || !tnl->AllowPixelFog); -} - diff --git a/dll/opengl/mesa/tnl/t_context.h b/dll/opengl/mesa/tnl/t_context.h deleted file mode 100644 index 81dcf17f46c..00000000000 --- a/dll/opengl/mesa/tnl/t_context.h +++ /dev/null @@ -1,486 +0,0 @@ -/* - * mesa 3-D graphics library - * Version: 6.5 - * - * Copyright (C) 1999-2006 Brian Paul All Rights Reserved. - * - * Permission is hereby granted, free of charge, to any person obtaining a - * copy of this software and associated documentation files (the "Software"), - * to deal in the Software without restriction, including without limitation - * the rights to use, copy, modify, merge, publish, distribute, sublicense, - * and/or sell copies of the Software, and to permit persons to whom the - * Software is furnished to do so, subject to the following conditions: - * - * The above copyright notice and this permission notice shall be included - * in all copies or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS - * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL - * BRIAN PAUL BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN - * AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN - * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. - */ - -/** - * \file t_context.h - * \brief TnL module datatypes and definitions. - * \author Keith Whitwell - */ - - -/** - * \mainpage The TNL-module - * - * TNL stands for "transform and lighting", i.e. this module implements - * a pipeline that receives as input a buffer of vertices and does all - * necessary transformations (rotations, clipping, vertex shader etc.) - * and passes then the output to the rasterizer. - * - * The tnl_pipeline contains the array of all stages, which should be - * applied. Each stage is a black-box, which is described by an - * tnl_pipeline_stage. The function ::_tnl_run_pipeline applies all the - * stages to the vertex_buffer TNLcontext::vb, where the vertex data - * is stored. The last stage in the pipeline is the rasterizer. - * - */ - - -#ifndef _T_CONTEXT_H -#define _T_CONTEXT_H - -#include "main/glheader.h" -#include "main/imports.h" -#include "main/mtypes.h" - -#include "math/m_vector.h" - -#include "vbo/vbo.h" - -#define MAX_PIPELINE_STAGES 30 - -/* - * Note: The first attributes match the VERT_ATTRIB_* definitions - * in mtypes.h. However, the tnl module has additional attributes - * for materials, color indexes, edge flags, etc. - */ -/* Although it's nice to use these as bit indexes in a DWORD flag, we - * could manage without if necessary. Another limit currently is the - * number of bits allocated for these numbers in places like vertex - * program instruction formats and register layouts. - */ -/* The bit space exhaustion is a fact now, done by _TNL_ATTRIB_ATTRIBUTE* for - * GLSL vertex shader which cannot be aliased with conventional vertex attribs. - * Compacting _TNL_ATTRIB_MAT_* attribs would not work, they would not give - * as many free bits (11 plus already 1 free bit) as _TNL_ATTRIB_ATTRIBUTE* - * attribs want (16). - */ -enum { - _TNL_ATTRIB_POS = 0, - _TNL_ATTRIB_WEIGHT = 1, - _TNL_ATTRIB_NORMAL = 2, - _TNL_ATTRIB_COLOR = 3, - _TNL_ATTRIB_FOG = 4, - _TNL_ATTRIB_COLOR_INDEX = 5, - _TNL_ATTRIB_EDGEFLAG = 6, - _TNL_ATTRIB_TEX = 7, - /* This is really a VERT_RESULT, not an attrib. Need to fix - * tnl to understand the difference. - */ - _TNL_ATTRIB_POINTSIZE = 8, - - /* These alias with the generics, but they are not active - * concurrently, so it's not a problem. The TNL module - * doesn't have to do anything about this as this is how they - * are passed into the _draw_prims callback. - * - * When we generate fixed-function replacement programs (in - * t_vp_build.c currently), they refer to the appropriate - * generic attribute in order to pick up per-vertex material - * data. - */ - _TNL_ATTRIB_MAT_FRONT_AMBIENT = 9, - _TNL_ATTRIB_MAT_BACK_AMBIENT = 10, - _TNL_ATTRIB_MAT_FRONT_DIFFUSE = 11, - _TNL_ATTRIB_MAT_BACK_DIFFUSE = 12, - _TNL_ATTRIB_MAT_FRONT_SPECULAR = 13, - _TNL_ATTRIB_MAT_BACK_SPECULAR = 14, - _TNL_ATTRIB_MAT_FRONT_EMISSION = 15, - _TNL_ATTRIB_MAT_BACK_EMISSION = 16, - _TNL_ATTRIB_MAT_FRONT_SHININESS = 17, - _TNL_ATTRIB_MAT_BACK_SHININESS = 18, - _TNL_ATTRIB_MAT_FRONT_INDEXES = 29, - _TNL_ATTRIB_MAT_BACK_INDEXES = 20, - - _TNL_ATTRIB_MAX = 21 -} ; - -/** - * Handy attribute ranges: - */ - -#define _TNL_FIRST_MAT _TNL_ATTRIB_MAT_FRONT_AMBIENT -#define _TNL_LAST_MAT _TNL_ATTRIB_MAT_BACK_INDEXES - - -#define PRIM_BEGIN 0x10 -#define PRIM_END 0x20 -#define PRIM_MODE_MASK 0x0f - -static inline GLuint _tnl_translate_prim( const struct _mesa_prim *prim ) -{ - GLuint flag; - flag = prim->mode; - if (prim->begin) flag |= PRIM_BEGIN; - if (prim->end) flag |= PRIM_END; - return flag; -} - - - - -/** - * Contains the current state of a running pipeline. - */ -struct vertex_buffer -{ - GLuint Size; /**< Max vertices per vertex buffer, constant */ - - /* Constant over the pipeline. - */ - GLuint Count; /**< Number of vertices currently in buffer */ - - /* Pointers to current data. Most of the data is in AttribPtr -- all of - * it that is one of VERT_ATTRIB_X. For things only produced by TNL, - * such as backface color or eye-space coordinates, they are stored - * here. - */ - GLuint *Elts; - GLvector4f *EyePtr; /* _TNL_BIT_POS */ - GLvector4f *ClipPtr; /* _TNL_BIT_POS */ - GLvector4f *NdcPtr; /* _TNL_BIT_POS */ - GLubyte ClipOrMask; /* _TNL_BIT_POS */ - GLubyte ClipAndMask; /* _TNL_BIT_POS */ - GLubyte *ClipMask; /* _TNL_BIT_POS */ - GLfloat *NormalLengthPtr; /* _TNL_BIT_NORMAL */ - GLboolean *EdgeFlag; /* _TNL_BIT_EDGEFLAG */ - GLvector4f *BackfaceIndexPtr; - GLvector4f *BackfaceColorPtr; - - const struct _mesa_prim *Primitive; - GLuint PrimitiveCount; - - /* Inputs to the vertex program stage */ - GLvector4f *AttribPtr[_TNL_ATTRIB_MAX]; /* GL_NV_vertex_program */ -}; - - -/** - * Describes an individual operation on the pipeline. - */ -struct tnl_pipeline_stage -{ - const char *name; - - /* Private data for the pipeline stage: - */ - void *privatePtr; - - /* Allocate private data - */ - GLboolean (*create)( struct gl_context *ctx, struct tnl_pipeline_stage * ); - - /* Free private data. - */ - void (*destroy)( struct tnl_pipeline_stage * ); - - /* Called on any statechange or input array size change or - * input array change to/from zero stride. - */ - void (*validate)( struct gl_context *ctx, struct tnl_pipeline_stage * ); - - /* Called from _tnl_run_pipeline(). The stage.changed_inputs value - * encodes all inputs to thee struct which have changed. If - * non-zero, recompute all affected outputs of the stage, otherwise - * execute any 'sideeffects' of the stage. - * - * Return value: GL_TRUE - keep going - * GL_FALSE - finished pipeline - */ - GLboolean (*run)( struct gl_context *ctx, struct tnl_pipeline_stage * ); -}; - - - -/** Contains the array of all pipeline stages. - * The default values are defined at the end of t_pipeline.c - */ -struct tnl_pipeline { - - GLuint last_attrib_stride[_TNL_ATTRIB_MAX]; - GLuint last_attrib_size[_TNL_ATTRIB_MAX]; - GLuint input_changes; - GLuint new_state; - - struct tnl_pipeline_stage stages[MAX_PIPELINE_STAGES+1]; - GLuint nr_stages; -}; - -struct tnl_clipspace; -struct tnl_clipspace_attr; - -typedef void (*tnl_extract_func)( const struct tnl_clipspace_attr *a, - GLfloat *out, - const GLubyte *v ); - -typedef void (*tnl_insert_func)( const struct tnl_clipspace_attr *a, - GLubyte *v, - const GLfloat *in ); - -typedef void (*tnl_emit_func)( struct gl_context *ctx, - GLuint count, - GLubyte *dest ); - - -/** - * Describes how to convert/move a vertex attribute from a vertex array - * to a vertex structure. - */ -struct tnl_clipspace_attr -{ - GLuint attrib; /* which vertex attrib (0=position, etc) */ - GLuint format; - GLuint vertoffset; /* position of the attrib in the vertex struct */ - GLuint vertattrsize; /* size of the attribute in bytes */ - GLubyte *inputptr; - GLuint inputstride; - GLuint inputsize; - const tnl_insert_func *insert; - tnl_insert_func emit; - tnl_extract_func extract; - const GLfloat *vp; /* NDC->Viewport mapping matrix */ -}; - - - - -typedef void (*tnl_points_func)( struct gl_context *ctx, GLuint first, GLuint last ); -typedef void (*tnl_line_func)( struct gl_context *ctx, GLuint v1, GLuint v2 ); -typedef void (*tnl_triangle_func)( struct gl_context *ctx, - GLuint v1, GLuint v2, GLuint v3 ); -typedef void (*tnl_quad_func)( struct gl_context *ctx, GLuint v1, GLuint v2, - GLuint v3, GLuint v4 ); -typedef void (*tnl_render_func)( struct gl_context *ctx, GLuint start, GLuint count, - GLuint flags ); -typedef void (*tnl_interp_func)( struct gl_context *ctx, - GLfloat t, GLuint dst, GLuint out, GLuint in, - GLboolean force_boundary ); -typedef void (*tnl_copy_pv_func)( struct gl_context *ctx, GLuint dst, GLuint src ); -typedef void (*tnl_setup_func)( struct gl_context *ctx, - GLuint start, GLuint end, - GLuint new_inputs); - - -struct tnl_attr_type { - GLuint format; - GLuint size; - GLuint stride; - GLuint offset; -}; - -struct tnl_clipspace_fastpath { - GLuint vertex_size; - GLuint attr_count; - GLboolean match_strides; - - struct tnl_attr_type *attr; - - tnl_emit_func func; - struct tnl_clipspace_fastpath *next; -}; - -/** - * Used to describe conversion of vertex arrays to vertex structures. - * I.e. Structure of arrays to arrays of structs. - */ -struct tnl_clipspace -{ - GLboolean need_extras; - - GLuint new_inputs; - - GLubyte *vertex_buf; - GLuint vertex_size; - GLuint max_vertex_size; - - struct tnl_clipspace_attr attr[_TNL_ATTRIB_MAX]; - GLuint attr_count; - - tnl_emit_func emit; - tnl_interp_func interp; - tnl_copy_pv_func copy_pv; - - /* Parameters and constants for codegen: - */ - GLboolean need_viewport; - GLfloat vp_scale[4]; - GLfloat vp_xlate[4]; - GLfloat chan_scale[4]; - GLfloat identity[4]; - - struct tnl_clipspace_fastpath *fastpath; - - void (*codegen_emit)( struct gl_context *ctx ); -}; - - -struct tnl_device_driver -{ - /*** - *** TNL Pipeline - ***/ - - void (*RunPipeline)(struct gl_context *ctx); - /* Replaces PipelineStart/PipelineFinish -- intended to allow - * drivers to wrap _tnl_run_pipeline() with code to validate state - * and grab/release hardware locks. - */ - - void (*NotifyMaterialChange)(struct gl_context *ctx); - /* Alert tnl-aware drivers of changes to material. - */ - - /*** - *** Rendering -- These functions called only from t_vb_render.c - ***/ - struct - { - void (*Start)(struct gl_context *ctx); - void (*Finish)(struct gl_context *ctx); - /* Called before and after all rendering operations, including DrawPixels, - * ReadPixels, Bitmap, span functions, and CopyTexImage, etc commands. - * These are a suitable place for grabbing/releasing hardware locks. - */ - - void (*PrimitiveNotify)(struct gl_context *ctx, GLenum mode); - /* Called between RenderStart() and RenderFinish() to indicate the - * type of primitive we're about to draw. Mode will be one of the - * modes accepted by glBegin(). - */ - - tnl_interp_func Interp; - /* The interp function is called by the clipping routines when we need - * to generate an interpolated vertex. All pertinant vertex ancilliary - * data should be computed by interpolating between the 'in' and 'out' - * vertices. - */ - - tnl_copy_pv_func CopyPV; - /* The copy function is used to make a copy of a vertex. All pertinant - * vertex attributes should be copied. - */ - - void (*ClippedPolygon)( struct gl_context *ctx, const GLuint *elts, GLuint n ); - /* Render a polygon with vertices whose indexes are in the - * array. - */ - - void (*ClippedLine)( struct gl_context *ctx, GLuint v0, GLuint v1 ); - /* Render a line between the two vertices given by indexes v0 and v1. */ - - tnl_points_func Points; /* must now respect vb->elts */ - tnl_line_func Line; - tnl_triangle_func Triangle; - tnl_quad_func Quad; - /* These functions are called in order to render points, lines, - * triangles and quads. These are only called via the T&L module. - */ - - tnl_render_func *PrimTabVerts; - tnl_render_func *PrimTabElts; - /* Render whole unclipped primitives (points, lines, linestrips, - * lineloops, etc). The tables are indexed by the GL enum of the - * primitive to be rendered. RenderTabVerts is used for non-indexed - * arrays of vertices. RenderTabElts is used for indexed arrays of - * vertices. - */ - - void (*ResetLineStipple)( struct gl_context *ctx ); - /* Reset the hardware's line stipple counter. - */ - - tnl_setup_func BuildVertices; - /* This function is called whenever new vertices are required for - * rendering. The vertices in question are those n such that start - * <= n < end. The new_inputs parameter indicates those fields of - * the vertex which need to be updated, if only a partial repair of - * the vertex is required. - * - * This function is called only from _tnl_render_stage in tnl/t_render.c. - */ - - - GLboolean (*Multipass)( struct gl_context *ctx, GLuint passno ); - /* Driver may request additional render passes by returning GL_TRUE - * when this function is called. This function will be called - * after the first pass, and passes will be made until the function - * returns GL_FALSE. If no function is registered, only one pass - * is made. - * - * This function will be first invoked with passno == 1. - */ - } Render; -}; - - -/** - * Context state for T&L context. - */ -typedef struct -{ - /* Driver interface. - */ - struct tnl_device_driver Driver; - - /* Pipeline - */ - struct tnl_pipeline pipeline; - struct vertex_buffer vb; - - /* Clipspace/ndc/window vertex managment: - */ - struct tnl_clipspace clipspace; - - /* Probably need a better configuration mechanism: - */ - GLboolean NeedNdcCoords; - GLboolean AllowVertexFog; - GLboolean AllowPixelFog; - GLboolean _DoVertexFog; /* eval fog function at each vertex? */ - - GLbitfield64 render_inputs_bitset; - - GLvector4f tmp_inputs[_TNL_ATTRIB_MAX]; - - /* Temp storage for t_draw.c: - */ - GLubyte *block[_TNL_ATTRIB_MAX]; - GLuint nr_blocks; - - GLuint CurInstance; -} TNLcontext; - - - -#define TNL_CONTEXT(ctx) ((TNLcontext *)((ctx)->swtnl_context)) - - -#define TYPE_IDX(t) ((t) & 0xf) -#define MAX_TYPES TYPE_IDX(GL_DOUBLE)+1 /* 0xa + 1 */ - - -extern void -tnl_clip_prepare(struct gl_context *ctx); - - -#endif diff --git a/dll/opengl/mesa/tnl/t_draw.c b/dll/opengl/mesa/tnl/t_draw.c deleted file mode 100644 index 404bfe3ec2e..00000000000 --- a/dll/opengl/mesa/tnl/t_draw.c +++ /dev/null @@ -1,438 +0,0 @@ -/* - * Mesa 3-D graphics library - * Version: 7.1 - * - * Copyright (C) 1999-2007 Brian Paul All Rights Reserved. - * - * Permission is hereby granted, free of charge, to any person obtaining a - * copy of this software and associated documentation files (the "Software"), - * to deal in the Software without restriction, including without limitation - * the rights to use, copy, modify, merge, publish, distribute, sublicense, - * and/or sell copies of the Software, and to permit persons to whom the - * Software is furnished to do so, subject to the following conditions: - * - * The above copyright notice and this permission notice shall be included - * in all copies or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS - * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL - * BRIAN PAUL BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN - * AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN - * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. - * - * Authors: - * Keith Whitwell - */ - -#include - -static GLubyte *get_space(struct gl_context *ctx, GLuint bytes) -{ - TNLcontext *tnl = TNL_CONTEXT(ctx); - GLubyte *space = malloc(bytes); - - tnl->block[tnl->nr_blocks++] = space; - return space; -} - - -static void free_space(struct gl_context *ctx) -{ - TNLcontext *tnl = TNL_CONTEXT(ctx); - GLuint i; - for (i = 0; i < tnl->nr_blocks; i++) - free(tnl->block[i]); - tnl->nr_blocks = 0; -} - - -/* Convert the incoming array to GLfloats. Understands the - * array->Normalized flag and selects the correct conversion method. - */ -#define CONVERT( TYPE, MACRO ) do { \ - GLuint i, j; \ - if (input->Normalized) { \ - for (i = 0; i < count; i++) { \ - const TYPE *in = (TYPE *)ptr; \ - for (j = 0; j < sz; j++) { \ - *fptr++ = MACRO(*in); \ - in++; \ - } \ - ptr += input->StrideB; \ - } \ - } else { \ - for (i = 0; i < count; i++) { \ - const TYPE *in = (TYPE *)ptr; \ - for (j = 0; j < sz; j++) { \ - *fptr++ = (GLfloat)(*in); \ - in++; \ - } \ - ptr += input->StrideB; \ - } \ - } \ -} while (0) - -/** - * \brief Convert fixed-point to floating-point. - * - * In OpenGL, a fixed-point number is a "signed 2's complement 16.16 scaled - * integer" (Table 2.2 of the OpenGL ES 2.0 spec). - * - * If the buffer has the \c normalized flag set, the formula - * \code normalize(x) := (2*x + 1) / (2^16 - 1) \endcode - * is used to map the fixed-point numbers into the range [-1, 1]. - */ -static void -convert_fixed_to_float(const struct gl_client_array *input, - const GLubyte *ptr, GLfloat *fptr, - GLuint count) -{ - GLuint i, j; - const GLint size = input->Size; - - if (input->Normalized) { - for (i = 0; i < count; ++i) { - const GLfixed *in = (GLfixed *) ptr; - for (j = 0; j < size; ++j) { - *fptr++ = (GLfloat) (2 * in[j] + 1) / (GLfloat) ((1 << 16) - 1); - } - ptr += input->StrideB; - } - } else { - for (i = 0; i < count; ++i) { - const GLfixed *in = (GLfixed *) ptr; - for (j = 0; j < size; ++j) { - *fptr++ = in[j] / (GLfloat) (1 << 16); - } - ptr += input->StrideB; - } - } -} - -/* Adjust pointer to point at first requested element, convert to - * floating point, populate VB->AttribPtr[]. - */ -static void _tnl_import_array( struct gl_context *ctx, - GLuint attrib, - GLuint count, - const struct gl_client_array *input, - const GLubyte *ptr ) -{ - TNLcontext *tnl = TNL_CONTEXT(ctx); - struct vertex_buffer *VB = &tnl->vb; - GLuint stride = input->StrideB; - - if (input->Type != GL_FLOAT) { - const GLuint sz = input->Size; - GLubyte *buf = get_space(ctx, count * sz * sizeof(GLfloat)); - GLfloat *fptr = (GLfloat *)buf; - - switch (input->Type) { - case GL_BYTE: - CONVERT(GLbyte, BYTE_TO_FLOAT); - break; - case GL_UNSIGNED_BYTE: - CONVERT(GLubyte, UBYTE_TO_FLOAT); - break; - case GL_SHORT: - CONVERT(GLshort, SHORT_TO_FLOAT); - break; - case GL_UNSIGNED_SHORT: - CONVERT(GLushort, USHORT_TO_FLOAT); - break; - case GL_INT: - CONVERT(GLint, INT_TO_FLOAT); - break; - case GL_UNSIGNED_INT: - CONVERT(GLuint, UINT_TO_FLOAT); - break; - case GL_DOUBLE: - CONVERT(GLdouble, (GLfloat)); - break; - case GL_FIXED: - convert_fixed_to_float(input, ptr, fptr, count); - break; - default: - assert(0); - break; - } - - ptr = buf; - stride = sz * sizeof(GLfloat); - } - - VB->AttribPtr[attrib] = &tnl->tmp_inputs[attrib]; - VB->AttribPtr[attrib]->data = (GLfloat (*)[4])ptr; - VB->AttribPtr[attrib]->start = (GLfloat *)ptr; - VB->AttribPtr[attrib]->count = count; - VB->AttribPtr[attrib]->stride = stride; - VB->AttribPtr[attrib]->size = input->Size; - - /* This should die, but so should the whole GLvector4f concept: - */ - VB->AttribPtr[attrib]->flags = (((1<Size)-1) | - VEC_NOT_WRITEABLE | - (stride == 4*sizeof(GLfloat) ? 0 : VEC_BAD_STRIDE)); - - VB->AttribPtr[attrib]->storage = NULL; -} - -#define CLIPVERTS ((6 + MAX_CLIP_PLANES) * 2) - - -static GLboolean *_tnl_import_edgeflag( struct gl_context *ctx, - const GLvector4f *input, - GLuint count) -{ - const GLubyte *ptr = (const GLubyte *)input->data; - const GLuint stride = input->stride; - GLboolean *space = (GLboolean *)get_space(ctx, count + CLIPVERTS); - GLboolean *bptr = space; - GLuint i; - - for (i = 0; i < count; i++) { - *bptr++ = ((GLfloat *)ptr)[0] == 1.0; - ptr += stride; - } - - return space; -} - -static void bind_inputs( struct gl_context *ctx, - const struct gl_client_array *inputs[], - GLint count, - struct gl_buffer_object **bo, - GLuint *nr_bo ) -{ - TNLcontext *tnl = TNL_CONTEXT(ctx); - struct vertex_buffer *VB = &tnl->vb; - GLuint i; - - /* Map all the VBOs - */ - for (i = 0; i < _TNL_ATTRIB_MAX; i++) { - const void *ptr; - - if (inputs[i]->BufferObj->Name) { - if (!inputs[i]->BufferObj->Pointer) { - bo[*nr_bo] = inputs[i]->BufferObj; - (*nr_bo)++; - ctx->Driver.MapBufferRange(ctx, 0, inputs[i]->BufferObj->Size, - GL_MAP_READ_BIT, - inputs[i]->BufferObj); - - assert(inputs[i]->BufferObj->Pointer); - } - - ptr = ADD_POINTERS(inputs[i]->BufferObj->Pointer, - inputs[i]->Ptr); - } - else - ptr = inputs[i]->Ptr; - - /* Just make sure the array is floating point, otherwise convert to - * temporary storage. - * - * XXX: remove the GLvector4f type at some stage and just use - * client arrays. - */ - _tnl_import_array(ctx, i, count, inputs[i], ptr); - } - - /* We process only the vertices between min & max index: - */ - VB->Count = count; - - /* These should perhaps be part of _TNL_ATTRIB_* */ - VB->BackfaceColorPtr = NULL; - VB->BackfaceIndexPtr = NULL; - - /* Clipping and drawing code still requires this to be a packed - * array of ubytes which can be written into. TODO: Fix and - * remove. - */ - if (ctx->Polygon.FrontMode != GL_FILL || - ctx->Polygon.BackMode != GL_FILL) - { - VB->EdgeFlag = _tnl_import_edgeflag( ctx, - VB->AttribPtr[_TNL_ATTRIB_EDGEFLAG], - VB->Count ); - } - else { - /* the data previously pointed to by EdgeFlag may have been freed */ - VB->EdgeFlag = NULL; - } -} - - -/* Translate indices to GLuints and store in VB->Elts. - */ -static void bind_indices( struct gl_context *ctx, - const struct _mesa_index_buffer *ib, - struct gl_buffer_object **bo, - GLuint *nr_bo) -{ - TNLcontext *tnl = TNL_CONTEXT(ctx); - struct vertex_buffer *VB = &tnl->vb; - GLuint i; - const void *ptr; - - if (!ib) { - VB->Elts = NULL; - return; - } - - if (_mesa_is_bufferobj(ib->obj) && !_mesa_bufferobj_mapped(ib->obj)) { - /* if the buffer object isn't mapped yet, map it now */ - bo[*nr_bo] = ib->obj; - (*nr_bo)++; - ptr = ctx->Driver.MapBufferRange(ctx, (GLsizeiptr) ib->ptr, - ib->count * vbo_sizeof_ib_type(ib->type), - GL_MAP_READ_BIT, ib->obj); - assert(ib->obj->Pointer); - } else { - /* user-space elements, or buffer already mapped */ - ptr = ADD_POINTERS(ib->obj->Pointer, ib->ptr); - } - - if (ib->type == GL_UNSIGNED_INT) { - VB->Elts = (GLuint *) ptr; - } - else { - GLuint *elts = (GLuint *)get_space(ctx, ib->count * sizeof(GLuint)); - VB->Elts = elts; - - if (ib->type == GL_UNSIGNED_SHORT) { - const GLushort *in = (GLushort *)ptr; - for (i = 0; i < ib->count; i++) - *elts++ = (GLuint)(*in++); - } - else { - const GLubyte *in = (GLubyte *)ptr; - for (i = 0; i < ib->count; i++) - *elts++ = (GLuint)(*in++); - } - } -} - -static void bind_prims( struct gl_context *ctx, - const struct _mesa_prim *prim, - GLuint nr_prims ) -{ - TNLcontext *tnl = TNL_CONTEXT(ctx); - struct vertex_buffer *VB = &tnl->vb; - - VB->Primitive = prim; - VB->PrimitiveCount = nr_prims; -} - -static void unmap_vbos( struct gl_context *ctx, - struct gl_buffer_object **bo, - GLuint nr_bo ) -{ - GLuint i; - for (i = 0; i < nr_bo; i++) { - ctx->Driver.UnmapBuffer(ctx, bo[i]); - } -} - - -void _tnl_vbo_draw_prims(struct gl_context *ctx, - const struct gl_client_array *arrays[], - const struct _mesa_prim *prim, - GLuint nr_prims, - const struct _mesa_index_buffer *ib, - GLboolean index_bounds_valid, - GLuint min_index, - GLuint max_index) -{ - if (!index_bounds_valid) - vbo_get_minmax_index(ctx, prim, ib, &min_index, &max_index); - - _tnl_draw_prims(ctx, arrays, prim, nr_prims, ib, min_index, max_index); -} - -/* This is the main entrypoint into the slimmed-down software tnl - * module. In a regular swtnl driver, this can be plugged straight - * into the vbo->Driver.DrawPrims() callback. - */ -void _tnl_draw_prims( struct gl_context *ctx, - const struct gl_client_array *arrays[], - const struct _mesa_prim *prim, - GLuint nr_prims, - const struct _mesa_index_buffer *ib, - GLuint min_index, - GLuint max_index) -{ - TNLcontext *tnl = TNL_CONTEXT(ctx); - const GLuint TEST_SPLIT = 0; - const GLint max = TEST_SPLIT ? 8 : tnl->vb.Size - MAX_CLIPPED_VERTICES; - - /* Mesa core state should have been validated already */ - assert(ctx->NewState == 0x0); - - if (0) - { - GLuint i; - printf("%s %d..%d\n", __FUNCTION__, min_index, max_index); - for (i = 0; i < nr_prims; i++) - printf("prim %d: %s start %d count %d\n", i, - _mesa_lookup_enum_by_nr(prim[i].mode), - prim[i].start, - prim[i].count); - } - - if (min_index) { - /* We always translate away calls with min_index != 0. - */ - vbo_rebase_prims( ctx, arrays, prim, nr_prims, ib, - min_index, max_index, - _tnl_vbo_draw_prims ); - return; - } - else if (max_index > max) { - /* The software TNL pipeline has a fixed amount of storage for - * vertices and it is necessary to split incoming drawing commands - * if they exceed that limit. - */ - struct split_limits limits; - limits.max_verts = max; - limits.max_vb_size = ~0; - limits.max_indices = ~0; - - /* This will split the buffers one way or another and - * recursively call back into this function. - */ - vbo_split_prims( ctx, arrays, prim, nr_prims, ib, - 0, max_index, - _tnl_vbo_draw_prims, - &limits ); - } - else { - /* May need to map a vertex buffer object for every attribute plus - * one for the index buffer. - */ - struct gl_buffer_object *bo[_TNL_ATTRIB_MAX]; - GLuint nr_bo = 0; - GLuint inst; - - /* Binding inputs may imply mapping some vertex buffer objects. - * They will need to be unmapped below. - */ - for (inst = 0; inst < prim[0].num_instances; inst++) { - - bind_prims(ctx, prim, nr_prims); - bind_inputs(ctx, arrays, max_index + 1, - bo, &nr_bo); - bind_indices(ctx, ib, bo, &nr_bo); - - tnl->CurInstance = inst; - TNL_CONTEXT(ctx)->Driver.RunPipeline(ctx); - - unmap_vbos(ctx, bo, nr_bo); - free_space(ctx); - } - } -} - diff --git a/dll/opengl/mesa/tnl/t_pipeline.c b/dll/opengl/mesa/tnl/t_pipeline.c deleted file mode 100644 index 02e891bf2c5..00000000000 --- a/dll/opengl/mesa/tnl/t_pipeline.c +++ /dev/null @@ -1,205 +0,0 @@ -/* - * Mesa 3-D graphics library - * Version: 6.5.3 - * - * Copyright (C) 1999-2007 Brian Paul All Rights Reserved. - * - * Permission is hereby granted, free of charge, to any person obtaining a - * copy of this software and associated documentation files (the "Software"), - * to deal in the Software without restriction, including without limitation - * the rights to use, copy, modify, merge, publish, distribute, sublicense, - * and/or sell copies of the Software, and to permit persons to whom the - * Software is furnished to do so, subject to the following conditions: - * - * The above copyright notice and this permission notice shall be included - * in all copies or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS - * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL - * BRIAN PAUL BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN - * AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN - * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. - * - * Authors: - * Keith Whitwell - */ - -#include - -void _tnl_install_pipeline( struct gl_context *ctx, - const struct tnl_pipeline_stage **stages ) -{ - TNLcontext *tnl = TNL_CONTEXT(ctx); - GLuint i; - - tnl->pipeline.new_state = ~0; - - /* Create a writeable copy of each stage. - */ - for (i = 0 ; i < MAX_PIPELINE_STAGES && stages[i] ; i++) { - struct tnl_pipeline_stage *s = &tnl->pipeline.stages[i]; - memcpy(s, stages[i], sizeof(*s)); - if (s->create) - s->create(ctx, s); - } - - tnl->pipeline.nr_stages = i; -} - -void _tnl_destroy_pipeline( struct gl_context *ctx ) -{ - TNLcontext *tnl = TNL_CONTEXT(ctx); - GLuint i; - - for (i = 0 ; i < tnl->pipeline.nr_stages ; i++) { - struct tnl_pipeline_stage *s = &tnl->pipeline.stages[i]; - if (s->destroy) - s->destroy(s); - } - - tnl->pipeline.nr_stages = 0; -} - - - -static GLuint check_input_changes( struct gl_context *ctx ) -{ - TNLcontext *tnl = TNL_CONTEXT(ctx); - GLuint i; - - for (i = 0; i < _TNL_FIRST_MAT; i++) { - if (tnl->vb.AttribPtr[i]->size != tnl->pipeline.last_attrib_size[i] || - tnl->vb.AttribPtr[i]->stride != tnl->pipeline.last_attrib_stride[i]) { - tnl->pipeline.last_attrib_size[i] = tnl->vb.AttribPtr[i]->size; - tnl->pipeline.last_attrib_stride[i] = tnl->vb.AttribPtr[i]->stride; - tnl->pipeline.input_changes |= 1<pipeline.input_changes; -} - - -static GLuint check_output_changes( struct gl_context *ctx ) -{ -#if 0 - TNLcontext *tnl = TNL_CONTEXT(ctx); - - for (i = 0; i < VERT_RESULT_MAX; i++) { - if (tnl->vb.ResultPtr[i]->size != tnl->last_result_size[i] || - tnl->vb.ResultPtr[i]->stride != tnl->last_result_stride[i]) { - tnl->last_result_size[i] = tnl->vb.ResultPtr[i]->size; - tnl->last_result_stride[i] = tnl->vb.ResultPtr[i]->stride; - tnl->pipeline.output_changes |= 1<pipeline.output_changes) - tnl->Driver.NotifyOutputChanges( ctx, tnl->pipeline.output_changes ); - - return tnl->pipeline.output_changes; -#else - return ~0; -#endif -} - - -void _tnl_run_pipeline( struct gl_context *ctx ) -{ - TNLcontext *tnl = TNL_CONTEXT(ctx); - unsigned short __tmp; - GLuint i; - - if (!tnl->vb.Count) - return; - - /* Check for changed input sizes or change in stride to/from zero - * (ie const or non-const). - */ - if (check_input_changes( ctx ) || tnl->pipeline.new_state) { - - for (i = 0; i < tnl->pipeline.nr_stages ; i++) { - struct tnl_pipeline_stage *s = &tnl->pipeline.stages[i]; - if (s->validate) - s->validate( ctx, s ); - } - - tnl->pipeline.new_state = 0; - tnl->pipeline.input_changes = 0; - - /* Pipeline can only change its output in response to either a - * statechange or an input size/stride change. No other changes - * are allowed. - */ - if (check_output_changes( ctx )) - _tnl_notify_pipeline_output_change( ctx ); - } - -#ifndef _OPENMP - /* Don't adjust FPU precision mode in case multiple threads are to be used. - * This would require that the additional threads also changed the FPU mode - * which is quite a mess as this had to be done in all parallelized sections; - * otherwise the master thread and all other threads are running in different - * modes, producing inconsistent results. - * Note that all x64 implementations don't define/use START_FAST_MATH, so - * this is "hack" is only used in i386 mode - */ - START_FAST_MATH(__tmp); -#endif - - for (i = 0; i < tnl->pipeline.nr_stages ; i++) { - struct tnl_pipeline_stage *s = &tnl->pipeline.stages[i]; - if (!s->run( ctx, s )) - break; - } - -#ifndef _OPENMP - END_FAST_MATH(__tmp); -#endif -} - - - -/* The default pipeline. This is useful for software rasterizers, and - * simple hardware rasterizers. For customization, I don't recommend - * tampering with the internals of these stages in the way that - * drivers did in Mesa 3.4. These stages are basically black boxes, - * and should be left intact. - * - * To customize the pipeline, consider: - * - * - removing redundant stages (making sure that the software rasterizer - * can cope with this on fallback paths). An example is fog - * coordinate generation, which is not required in the FX driver. - * - * - replacing general-purpose machine-independent stages with - * general-purpose machine-specific stages. There is no example of - * this to date, though it must be borne in mind that all subsequent - * stages that reference the output of the new stage must cope with - * any machine-specific data introduced. This may not be easy - * unless there are no such stages (ie the new stage is the last in - * the pipe). - * - * - inserting optimized (but specialized) stages ahead of the - * general-purpose fallback implementation. For example, the old - * fastpath mechanism, which only works when the VB->Elts input is - * available, can be duplicated by placing the fastpath stage at the - * head of this pipeline. Such specialized stages are currently - * constrained to have no outputs (ie. they must either finish the * - * pipeline by returning GL_FALSE from run(), or do nothing). - * - * Some work can be done to lift some of the restrictions in the final - * case, if it becomes necessary to do so. - */ -const struct tnl_pipeline_stage *_tnl_default_pipeline[] = { - &_tnl_vertex_transform_stage, - &_tnl_normal_transform_stage, - &_tnl_lighting_stage, - &_tnl_texgen_stage, - &_tnl_texture_transform_stage, - &_tnl_point_attenuation_stage, - &_tnl_fog_coordinate_stage, - &_tnl_render_stage, - NULL -}; diff --git a/dll/opengl/mesa/tnl/t_pipeline.h b/dll/opengl/mesa/tnl/t_pipeline.h deleted file mode 100644 index 419c5f45cab..00000000000 --- a/dll/opengl/mesa/tnl/t_pipeline.h +++ /dev/null @@ -1,71 +0,0 @@ -/* - * Mesa 3-D graphics library - * Version: 6.5.3 - * - * Copyright (C) 1999-2007 Brian Paul All Rights Reserved. - * - * Permission is hereby granted, free of charge, to any person obtaining a - * copy of this software and associated documentation files (the "Software"), - * to deal in the Software without restriction, including without limitation - * the rights to use, copy, modify, merge, publish, distribute, sublicense, - * and/or sell copies of the Software, and to permit persons to whom the - * Software is furnished to do so, subject to the following conditions: - * - * The above copyright notice and this permission notice shall be included - * in all copies or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS - * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL - * BRIAN PAUL BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN - * AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN - * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. - * - * Authors: - * Keith Whitwell - */ - - - -#ifndef _T_PIPELINE_H_ -#define _T_PIPELINE_H_ - -#include "main/mtypes.h" -#include "t_context.h" - -extern void _tnl_run_pipeline( struct gl_context *ctx ); - -extern void _tnl_destroy_pipeline( struct gl_context *ctx ); - -extern void _tnl_install_pipeline( struct gl_context *ctx, - const struct tnl_pipeline_stage **stages ); - - -/* These are implemented in the t_vb_*.c files: - */ -extern const struct tnl_pipeline_stage _tnl_vertex_transform_stage; -extern const struct tnl_pipeline_stage _tnl_normal_transform_stage; -extern const struct tnl_pipeline_stage _tnl_lighting_stage; -extern const struct tnl_pipeline_stage _tnl_fog_coordinate_stage; -extern const struct tnl_pipeline_stage _tnl_texgen_stage; -extern const struct tnl_pipeline_stage _tnl_texture_transform_stage; -extern const struct tnl_pipeline_stage _tnl_point_attenuation_stage; -extern const struct tnl_pipeline_stage _tnl_render_stage; - -/* Shorthand to plug in the default pipeline: - */ -extern const struct tnl_pipeline_stage *_tnl_default_pipeline[]; - - -/* Convenience routines provided by t_vb_render.c: - */ -extern tnl_render_func _tnl_render_tab_elts[]; -extern tnl_render_func _tnl_render_tab_verts[]; - -extern void _tnl_RenderClippedPolygon( struct gl_context *ctx, - const GLuint *elts, GLuint n ); - -extern void _tnl_RenderClippedLine( struct gl_context *ctx, GLuint ii, GLuint jj ); - - -#endif diff --git a/dll/opengl/mesa/tnl/t_rasterpos.c b/dll/opengl/mesa/tnl/t_rasterpos.c deleted file mode 100644 index 9d5794c5e3c..00000000000 --- a/dll/opengl/mesa/tnl/t_rasterpos.c +++ /dev/null @@ -1,437 +0,0 @@ -/* - * Mesa 3-D graphics library - * Version: 7.1 - * - * Copyright (C) 1999-2007 Brian Paul All Rights Reserved. - * - * Permission is hereby granted, free of charge, to any person obtaining a - * copy of this software and associated documentation files (the "Software"), - * to deal in the Software without restriction, including without limitation - * the rights to use, copy, modify, merge, publish, distribute, sublicense, - * and/or sell copies of the Software, and to permit persons to whom the - * Software is furnished to do so, subject to the following conditions: - * - * The above copyright notice and this permission notice shall be included - * in all copies or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS - * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL - * BRIAN PAUL BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN - * AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN - * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. - */ - -#include - -/** - * Clip a point against the view volume. - * - * \param v vertex vector describing the point to clip. - * - * \return zero if outside view volume, or one if inside. - */ -static GLuint -viewclip_point_xy( const GLfloat v[] ) -{ - if ( v[0] > v[3] || v[0] < -v[3] - || v[1] > v[3] || v[1] < -v[3] ) { - return 0; - } - else { - return 1; - } -} - - -/** - * Clip a point against the far/near Z clipping planes. - * - * \param v vertex vector describing the point to clip. - * - * \return zero if outside view volume, or one if inside. - */ -static GLuint -viewclip_point_z( const GLfloat v[] ) -{ - if (v[2] > v[3] || v[2] < -v[3] ) { - return 0; - } - else { - return 1; - } -} - - -/** - * Clip a point against the user clipping planes. - * - * \param ctx GL context. - * \param v vertex vector describing the point to clip. - * - * \return zero if the point was clipped, or one otherwise. - */ -static GLuint -userclip_point( struct gl_context *ctx, const GLfloat v[] ) -{ - GLuint p; - - for (p = 0; p < ctx->Const.MaxClipPlanes; p++) { - if (ctx->Transform.ClipPlanesEnabled & (1 << p)) { - GLfloat dot = v[0] * ctx->Transform._ClipUserPlane[p][0] - + v[1] * ctx->Transform._ClipUserPlane[p][1] - + v[2] * ctx->Transform._ClipUserPlane[p][2] - + v[3] * ctx->Transform._ClipUserPlane[p][3]; - if (dot < 0.0F) { - return 0; - } - } - } - - return 1; -} - - -/** - * Compute lighting for the raster position. RGB modes computed. - * \param ctx the context - * \param vertex vertex location - * \param normal normal vector - * \param Rcolor returned color - * \param Rspec returned specular color (if separate specular enabled) - */ -static void -shade_rastpos(struct gl_context *ctx, - const GLfloat vertex[4], - const GLfloat normal[3], - GLfloat Rcolor[4]) -{ - /*const*/ GLfloat (*base)[3] = ctx->Light._BaseColor; - const struct gl_light *light; - GLfloat diffuseColor[4], specularColor[4]; /* for RGB mode only */ - - _mesa_validate_all_lighting_tables( ctx ); - - COPY_3V(diffuseColor, base[0]); - diffuseColor[3] = CLAMP( - ctx->Light.Material.Attrib[MAT_ATTRIB_FRONT_DIFFUSE][3], 0.0F, 1.0F ); - ASSIGN_4V(specularColor, 0.0, 0.0, 0.0, 1.0); - - foreach (light, &ctx->Light.EnabledList) { - GLfloat attenuation = 1.0; - GLfloat VP[3]; /* vector from vertex to light pos */ - GLfloat n_dot_VP; - GLfloat diffuseContrib[3], specularContrib[3]; - - if (!(light->_Flags & LIGHT_POSITIONAL)) { - /* light at infinity */ - COPY_3V(VP, light->_VP_inf_norm); - attenuation = light->_VP_inf_spot_attenuation; - } - else { - /* local/positional light */ - GLfloat d; - - /* VP = vector from vertex pos to light[i].pos */ - SUB_3V(VP, light->_Position, vertex); - /* d = length(VP) */ - d = (GLfloat) LEN_3FV( VP ); - if (d > 1.0e-6) { - /* normalize VP */ - GLfloat invd = 1.0F / d; - SELF_SCALE_SCALAR_3V(VP, invd); - } - - /* atti */ - attenuation = 1.0F / (light->ConstantAttenuation + d * - (light->LinearAttenuation + d * - light->QuadraticAttenuation)); - - if (light->_Flags & LIGHT_SPOT) { - GLfloat PV_dot_dir = - DOT3(VP, light->_NormSpotDirection); - - if (PV_dot_dir_CosCutoff) { - continue; - } - else { - double x = PV_dot_dir * (EXP_TABLE_SIZE-1); - int k = (int) x; - GLfloat spot = (GLfloat) (light->_SpotExpTable[k][0] - + (x-k)*light->_SpotExpTable[k][1]); - attenuation *= spot; - } - } - } - - if (attenuation < 1e-3) - continue; - - n_dot_VP = DOT3( normal, VP ); - - if (n_dot_VP < 0.0F) { - ACC_SCALE_SCALAR_3V(diffuseColor, attenuation, light->_MatAmbient[0]); - continue; - } - - /* Ambient + diffuse */ - COPY_3V(diffuseContrib, light->_MatAmbient[0]); - ACC_SCALE_SCALAR_3V(diffuseContrib, n_dot_VP, light->_MatDiffuse[0]); - - /* Specular */ - { - const GLfloat *h; - GLfloat n_dot_h; - - ASSIGN_3V(specularContrib, 0.0, 0.0, 0.0); - - if (ctx->Light.Model.LocalViewer) { - GLfloat v[3]; - COPY_3V(v, vertex); - NORMALIZE_3FV(v); - SUB_3V(VP, VP, v); - NORMALIZE_3FV(VP); - h = VP; - } - else if (light->_Flags & LIGHT_POSITIONAL) { - ACC_3V(VP, ctx->_EyeZDir); - NORMALIZE_3FV(VP); - h = VP; - } - else { - h = light->_h_inf_norm; - } - - n_dot_h = DOT3(normal, h); - - if (n_dot_h > 0.0F) { - GLfloat spec_coef; - GET_SHINE_TAB_ENTRY( ctx->_ShineTable[0], n_dot_h, spec_coef ); - - if (spec_coef > 1.0e-10) { - ACC_SCALE_SCALAR_3V( diffuseContrib, spec_coef, - light->_MatSpecular[0]); - } - } - } - - ACC_SCALE_SCALAR_3V( diffuseColor, attenuation, diffuseContrib ); - ACC_SCALE_SCALAR_3V( specularColor, attenuation, specularContrib ); - } - - Rcolor[0] = CLAMP(diffuseColor[0], 0.0F, 1.0F); - Rcolor[1] = CLAMP(diffuseColor[1], 0.0F, 1.0F); - Rcolor[2] = CLAMP(diffuseColor[2], 0.0F, 1.0F); - Rcolor[3] = CLAMP(diffuseColor[3], 0.0F, 1.0F); -} - - -/** - * Do texgen needed for glRasterPos. - * \param ctx rendering context - * \param vObj object-space vertex coordinate - * \param vEye eye-space vertex coordinate - * \param normal vertex normal - * \param unit texture unit number - * \param texcoord incoming texcoord and resulting texcoord - */ -static void -compute_texgen(struct gl_context *ctx, const GLfloat vObj[4], const GLfloat vEye[4], - const GLfloat normal[3], GLfloat texcoord[4]) -{ - const struct gl_texture_unit *texUnit = &ctx->Texture.Unit; - - /* always compute sphere map terms, just in case */ - GLfloat u[3], two_nu, rx, ry, rz, m, mInv; - COPY_3V(u, vEye); - NORMALIZE_3FV(u); - two_nu = 2.0F * DOT3(normal, u); - rx = u[0] - normal[0] * two_nu; - ry = u[1] - normal[1] * two_nu; - rz = u[2] - normal[2] * two_nu; - m = rx * rx + ry * ry + (rz + 1.0F) * (rz + 1.0F); - if (m > 0.0F) - mInv = 0.5F * _mesa_inv_sqrtf(m); - else - mInv = 0.0F; - - if (texUnit->TexGenEnabled & S_BIT) { - switch (texUnit->GenS.Mode) { - case GL_OBJECT_LINEAR: - texcoord[0] = DOT4(vObj, texUnit->GenS.ObjectPlane); - break; - case GL_EYE_LINEAR: - texcoord[0] = DOT4(vEye, texUnit->GenS.EyePlane); - break; - case GL_SPHERE_MAP: - texcoord[0] = rx * mInv + 0.5F; - break; - case GL_REFLECTION_MAP: - texcoord[0] = rx; - break; - case GL_NORMAL_MAP: - texcoord[0] = normal[0]; - break; - default: - _mesa_problem(ctx, "Bad S texgen in compute_texgen()"); - return; - } - } - - if (texUnit->TexGenEnabled & T_BIT) { - switch (texUnit->GenT.Mode) { - case GL_OBJECT_LINEAR: - texcoord[1] = DOT4(vObj, texUnit->GenT.ObjectPlane); - break; - case GL_EYE_LINEAR: - texcoord[1] = DOT4(vEye, texUnit->GenT.EyePlane); - break; - case GL_SPHERE_MAP: - texcoord[1] = ry * mInv + 0.5F; - break; - case GL_REFLECTION_MAP: - texcoord[1] = ry; - break; - case GL_NORMAL_MAP: - texcoord[1] = normal[1]; - break; - default: - _mesa_problem(ctx, "Bad T texgen in compute_texgen()"); - return; - } - } - - if (texUnit->TexGenEnabled & R_BIT) { - switch (texUnit->GenR.Mode) { - case GL_OBJECT_LINEAR: - texcoord[2] = DOT4(vObj, texUnit->GenR.ObjectPlane); - break; - case GL_EYE_LINEAR: - texcoord[2] = DOT4(vEye, texUnit->GenR.EyePlane); - break; - case GL_REFLECTION_MAP: - texcoord[2] = rz; - break; - case GL_NORMAL_MAP: - texcoord[2] = normal[2]; - break; - default: - _mesa_problem(ctx, "Bad R texgen in compute_texgen()"); - return; - } - } - - if (texUnit->TexGenEnabled & Q_BIT) { - switch (texUnit->GenQ.Mode) { - case GL_OBJECT_LINEAR: - texcoord[3] = DOT4(vObj, texUnit->GenQ.ObjectPlane); - break; - case GL_EYE_LINEAR: - texcoord[3] = DOT4(vEye, texUnit->GenQ.EyePlane); - break; - default: - _mesa_problem(ctx, "Bad Q texgen in compute_texgen()"); - return; - } - } -} - - -/** - * glRasterPos transformation. Typically called via ctx->Driver.RasterPos(). - * XXX some of this code (such as viewport xform, clip testing and setting - * of ctx->Current.Raster* fields) could get lifted up into the - * main/rasterpos.c code. - * - * \param vObj vertex position in object space - */ -void -_tnl_RasterPos(struct gl_context *ctx, const GLfloat vObj[4]) -{ - GLfloat eye[4], clip[4], ndc[3], d; - GLfloat *norm, eyenorm[3]; - GLfloat *objnorm = ctx->Current.Attrib[VERT_ATTRIB_NORMAL]; - - /* apply modelview matrix: eye = MV * obj */ - TRANSFORM_POINT( eye, ctx->ModelviewMatrixStack.Top->m, vObj ); - /* apply projection matrix: clip = Proj * eye */ - TRANSFORM_POINT( clip, ctx->ProjectionMatrixStack.Top->m, eye ); - - /* clip to view volume. */ - if (viewclip_point_z(clip) == 0) { - ctx->Current.RasterPosValid = GL_FALSE; - return; - } - if (!ctx->Transform.RasterPositionUnclipped) { - if (viewclip_point_xy(clip) == 0) { - ctx->Current.RasterPosValid = GL_FALSE; - return; - } - } - - /* clip to user clipping planes */ - if (ctx->Transform.ClipPlanesEnabled && !userclip_point(ctx, clip)) { - ctx->Current.RasterPosValid = GL_FALSE; - return; - } - - /* ndc = clip / W */ - d = (clip[3] == 0.0F) ? 1.0F : 1.0F / clip[3]; - ndc[0] = clip[0] * d; - ndc[1] = clip[1] * d; - ndc[2] = clip[2] * d; - /* wincoord = viewport_mapping(ndc) */ - ctx->Current.RasterPos[0] = (ndc[0] * ctx->Viewport._WindowMap.m[MAT_SX] - + ctx->Viewport._WindowMap.m[MAT_TX]); - ctx->Current.RasterPos[1] = (ndc[1] * ctx->Viewport._WindowMap.m[MAT_SY] - + ctx->Viewport._WindowMap.m[MAT_TY]); - ctx->Current.RasterPos[2] = (ndc[2] * ctx->Viewport._WindowMap.m[MAT_SZ] - + ctx->Viewport._WindowMap.m[MAT_TZ]) - / ctx->DrawBuffer->_DepthMaxF; - ctx->Current.RasterPos[3] = clip[3]; - - /* compute raster distance */ - if (ctx->Fog.FogCoordinateSource == GL_FOG_COORDINATE_EXT) - ctx->Current.RasterDistance = ctx->Current.Attrib[VERT_ATTRIB_FOG][0]; - else - ctx->Current.RasterDistance = - SQRTF( eye[0]*eye[0] + eye[1]*eye[1] + eye[2]*eye[2] ); - - /* compute transformed normal vector (for lighting or texgen) */ - if (ctx->_NeedEyeCoords) { - const GLfloat *inv = ctx->ModelviewMatrixStack.Top->inv; - TRANSFORM_NORMAL( eyenorm, objnorm, inv ); - norm = eyenorm; - } - else { - norm = objnorm; - } - - /* update raster color */ - if (ctx->Light.Enabled) { - /* lighting */ - shade_rastpos( ctx, vObj, norm, - ctx->Current.RasterColor ); - } - else { - /* use current color */ - COPY_4FV(ctx->Current.RasterColor, - ctx->Current.Attrib[VERT_ATTRIB_COLOR]); - } - - /* texture coords */ - { - GLfloat tc[4]; - COPY_4V(tc, ctx->Current.Attrib[VERT_ATTRIB_TEX]); - if (ctx->Texture.Unit.TexGenEnabled) { - compute_texgen(ctx, vObj, eye, norm, tc); - } - TRANSFORM_POINT(ctx->Current.RasterTexCoords, - ctx->TextureMatrixStack.Top->m, tc); - } - - ctx->Current.RasterPosValid = GL_TRUE; - - if (ctx->RenderMode == GL_SELECT) { - _mesa_update_hitflag( ctx, ctx->Current.RasterPos[2] ); - } -} diff --git a/dll/opengl/mesa/tnl/t_vb_cliptmp.h b/dll/opengl/mesa/tnl/t_vb_cliptmp.h deleted file mode 100644 index 0b45bc5342e..00000000000 --- a/dll/opengl/mesa/tnl/t_vb_cliptmp.h +++ /dev/null @@ -1,320 +0,0 @@ -/* - * Mesa 3-D graphics library - * Version: 6.5.2 - * - * Copyright (C) 1999-2006 Brian Paul All Rights Reserved. - * - * Permission is hereby granted, free of charge, to any person obtaining a - * copy of this software and associated documentation files (the "Software"), - * to deal in the Software without restriction, including without limitation - * the rights to use, copy, modify, merge, publish, distribute, sublicense, - * and/or sell copies of the Software, and to permit persons to whom the - * Software is furnished to do so, subject to the following conditions: - * - * The above copyright notice and this permission notice shall be included - * in all copies or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS - * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL - * BRIAN PAUL BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN - * AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN - * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. - * - * Authors: - * Keith Whitwell - */ - - -#define CLIP_DOTPROD(K, A, B, C, D) X(K)*A + Y(K)*B + Z(K)*C + W(K)*D - -#define POLY_CLIP( PLANE_BIT, A, B, C, D ) \ -do { \ - if (mask & PLANE_BIT) { \ - GLuint idxPrev = inlist[0]; \ - GLfloat dpPrev = CLIP_DOTPROD(idxPrev, A, B, C, D ); \ - GLuint outcount = 0; \ - GLuint i; \ - \ - inlist[n] = inlist[0]; /* prevent rotation of vertices */ \ - for (i = 1; i <= n; i++) { \ - GLuint idx = inlist[i]; \ - GLfloat dp = CLIP_DOTPROD(idx, A, B, C, D ); \ - \ - if (!IS_NEGATIVE(dpPrev)) { \ - outlist[outcount++] = idxPrev; \ - } \ - \ - if (DIFFERENT_SIGNS(dp, dpPrev)) { \ - if (IS_NEGATIVE(dp)) { \ - /* Going out of bounds. Avoid division by zero as we \ - * know dp != dpPrev from DIFFERENT_SIGNS, above. \ - */ \ - GLfloat t = dp / (dp - dpPrev); \ - INTERP_4F( t, coord[newvert], coord[idx], coord[idxPrev]); \ - interp( ctx, t, newvert, idx, idxPrev, GL_TRUE ); \ - } else { \ - /* Coming back in. \ - */ \ - GLfloat t = dpPrev / (dpPrev - dp); \ - INTERP_4F( t, coord[newvert], coord[idxPrev], coord[idx]); \ - interp( ctx, t, newvert, idxPrev, idx, GL_FALSE ); \ - } \ - outlist[outcount++] = newvert++; \ - } \ - \ - idxPrev = idx; \ - dpPrev = dp; \ - } \ - \ - if (outcount < 3) \ - return; \ - \ - { \ - GLuint *tmp = inlist; \ - inlist = outlist; \ - outlist = tmp; \ - n = outcount; \ - } \ - } \ -} while (0) - - -#define LINE_CLIP(PLANE_BIT, A, B, C, D ) \ -do { \ - if (mask & PLANE_BIT) { \ - const GLfloat dp0 = CLIP_DOTPROD( v0, A, B, C, D ); \ - const GLfloat dp1 = CLIP_DOTPROD( v1, A, B, C, D ); \ - const GLboolean neg_dp0 = IS_NEGATIVE(dp0); \ - const GLboolean neg_dp1 = IS_NEGATIVE(dp1); \ - \ - /* For regular clipping, we know from the clipmask that one \ - * (or both) of these must be negative (otherwise we wouldn't \ - * be here). \ - * For userclip, there is only a single bit for all active \ - * planes, so we can end up here when there is nothing to do, \ - * hence the second IS_NEGATIVE() test: \ - */ \ - if (neg_dp0 && neg_dp1) \ - return; /* both vertices outside clip plane: discard */ \ - \ - if (neg_dp1) { \ - GLfloat t = dp1 / (dp1 - dp0); \ - if (t > t1) t1 = t; \ - } else if (neg_dp0) { \ - GLfloat t = dp0 / (dp0 - dp1); \ - if (t > t0) t0 = t; \ - } \ - if (t0 + t1 >= 1.0) \ - return; /* discard */ \ - } \ -} while (0) - - - -/* Clip a line against the viewport and user clip planes. - */ -static inline void -TAG(clip_line)( struct gl_context *ctx, GLuint v0, GLuint v1, GLubyte mask ) -{ - TNLcontext *tnl = TNL_CONTEXT(ctx); - struct vertex_buffer *VB = &tnl->vb; - tnl_interp_func interp = tnl->Driver.Render.Interp; - GLfloat (*coord)[4] = VB->ClipPtr->data; - GLuint newvert = VB->Count; - GLfloat t0 = 0; - GLfloat t1 = 0; - GLuint p; - const GLuint v0_orig = v0; - - if (mask & CLIP_FRUSTUM_BITS) { - LINE_CLIP( CLIP_RIGHT_BIT, -1, 0, 0, 1 ); - LINE_CLIP( CLIP_LEFT_BIT, 1, 0, 0, 1 ); - LINE_CLIP( CLIP_TOP_BIT, 0, -1, 0, 1 ); - LINE_CLIP( CLIP_BOTTOM_BIT, 0, 1, 0, 1 ); - LINE_CLIP( CLIP_FAR_BIT, 0, 0, -1, 1 ); - LINE_CLIP( CLIP_NEAR_BIT, 0, 0, 1, 1 ); - } - - if (mask & CLIP_USER_BIT) { - for (p = 0; p < ctx->Const.MaxClipPlanes; p++) { - if (ctx->Transform.ClipPlanesEnabled & (1 << p)) { - const GLfloat a = ctx->Transform._ClipUserPlane[p][0]; - const GLfloat b = ctx->Transform._ClipUserPlane[p][1]; - const GLfloat c = ctx->Transform._ClipUserPlane[p][2]; - const GLfloat d = ctx->Transform._ClipUserPlane[p][3]; - LINE_CLIP( CLIP_USER_BIT, a, b, c, d ); - } - } - } - - if (VB->ClipMask[v0]) { - INTERP_4F( t0, coord[newvert], coord[v0], coord[v1] ); - interp( ctx, t0, newvert, v0, v1, GL_FALSE ); - v0 = newvert; - newvert++; - } - else { - ASSERT(t0 == 0.0); - } - - /* Note: we need to use vertex v0_orig when computing the new - * interpolated/clipped vertex position, not the current v0 which - * may have got set when we clipped the other end of the line! - */ - if (VB->ClipMask[v1]) { - INTERP_4F( t1, coord[newvert], coord[v1], coord[v0_orig] ); - interp( ctx, t1, newvert, v1, v0_orig, GL_FALSE ); - - if (ctx->Light.ShadeModel == GL_FLAT) - tnl->Driver.Render.CopyPV( ctx, newvert, v1 ); - - v1 = newvert; - - newvert++; - } - else { - ASSERT(t1 == 0.0); - } - - tnl->Driver.Render.ClippedLine( ctx, v0, v1 ); -} - - -/* Clip a triangle against the viewport and user clip planes. - */ -static inline void -TAG(clip_tri)( struct gl_context *ctx, GLuint v0, GLuint v1, GLuint v2, GLubyte mask ) -{ - TNLcontext *tnl = TNL_CONTEXT(ctx); - struct vertex_buffer *VB = &tnl->vb; - tnl_interp_func interp = tnl->Driver.Render.Interp; - GLuint newvert = VB->Count; - GLfloat (*coord)[4] = VB->ClipPtr->data; - GLuint pv = v2; - GLuint vlist[2][MAX_CLIPPED_VERTICES]; - GLuint *inlist = vlist[0], *outlist = vlist[1]; - GLuint p; - GLuint n = 3; - - ASSIGN_3V(inlist, v2, v0, v1 ); /* pv rotated to slot zero */ - - if (0) { - /* print pre-clip vertex coords */ - GLuint i, j; - printf("pre clip:\n"); - for (i = 0; i < n; i++) { - j = inlist[i]; - printf(" %u: %u: %f, %f, %f, %f\n", - i, j, - coord[j][0], coord[j][1], coord[j][2], coord[j][3]); - assert(!IS_INF_OR_NAN(coord[j][0])); - assert(!IS_INF_OR_NAN(coord[j][1])); - assert(!IS_INF_OR_NAN(coord[j][2])); - assert(!IS_INF_OR_NAN(coord[j][3])); - } - } - - - if (mask & CLIP_FRUSTUM_BITS) { - POLY_CLIP( CLIP_RIGHT_BIT, -1, 0, 0, 1 ); - POLY_CLIP( CLIP_LEFT_BIT, 1, 0, 0, 1 ); - POLY_CLIP( CLIP_TOP_BIT, 0, -1, 0, 1 ); - POLY_CLIP( CLIP_BOTTOM_BIT, 0, 1, 0, 1 ); - POLY_CLIP( CLIP_FAR_BIT, 0, 0, -1, 1 ); - POLY_CLIP( CLIP_NEAR_BIT, 0, 0, 1, 1 ); - } - - if (mask & CLIP_USER_BIT) { - for (p = 0; p < ctx->Const.MaxClipPlanes; p++) { - if (ctx->Transform.ClipPlanesEnabled & (1 << p)) { - const GLfloat a = ctx->Transform._ClipUserPlane[p][0]; - const GLfloat b = ctx->Transform._ClipUserPlane[p][1]; - const GLfloat c = ctx->Transform._ClipUserPlane[p][2]; - const GLfloat d = ctx->Transform._ClipUserPlane[p][3]; - POLY_CLIP( CLIP_USER_BIT, a, b, c, d ); - } - } - } - - if (ctx->Light.ShadeModel == GL_FLAT) { - if (pv != inlist[0]) { - ASSERT( inlist[0] >= VB->Count ); - tnl->Driver.Render.CopyPV( ctx, inlist[0], pv ); - } - } - - if (0) { - /* print post-clip vertex coords */ - GLuint i, j; - printf("post clip:\n"); - for (i = 0; i < n; i++) { - j = inlist[i]; - printf(" %u: %u: %f, %f, %f, %f\n", - i, j, - coord[j][0], coord[j][1], coord[j][2], coord[j][3]); - } - } - - tnl->Driver.Render.ClippedPolygon( ctx, inlist, n ); -} - - -/* Clip a quad against the viewport and user clip planes. - */ -static inline void -TAG(clip_quad)( struct gl_context *ctx, GLuint v0, GLuint v1, GLuint v2, GLuint v3, - GLubyte mask ) -{ - TNLcontext *tnl = TNL_CONTEXT(ctx); - struct vertex_buffer *VB = &tnl->vb; - tnl_interp_func interp = tnl->Driver.Render.Interp; - GLuint newvert = VB->Count; - GLfloat (*coord)[4] = VB->ClipPtr->data; - GLuint pv = v3; - GLuint vlist[2][MAX_CLIPPED_VERTICES]; - GLuint *inlist = vlist[0], *outlist = vlist[1]; - GLuint p; - GLuint n = 4; - - ASSIGN_4V(inlist, v3, v0, v1, v2 ); /* pv rotated to slot zero */ - - if (mask & CLIP_FRUSTUM_BITS) { - POLY_CLIP( CLIP_RIGHT_BIT, -1, 0, 0, 1 ); - POLY_CLIP( CLIP_LEFT_BIT, 1, 0, 0, 1 ); - POLY_CLIP( CLIP_TOP_BIT, 0, -1, 0, 1 ); - POLY_CLIP( CLIP_BOTTOM_BIT, 0, 1, 0, 1 ); - POLY_CLIP( CLIP_FAR_BIT, 0, 0, -1, 1 ); - POLY_CLIP( CLIP_NEAR_BIT, 0, 0, 1, 1 ); - } - - if (mask & CLIP_USER_BIT) { - for (p = 0; p < ctx->Const.MaxClipPlanes; p++) { - if (ctx->Transform.ClipPlanesEnabled & (1 << p)) { - const GLfloat a = ctx->Transform._ClipUserPlane[p][0]; - const GLfloat b = ctx->Transform._ClipUserPlane[p][1]; - const GLfloat c = ctx->Transform._ClipUserPlane[p][2]; - const GLfloat d = ctx->Transform._ClipUserPlane[p][3]; - POLY_CLIP( CLIP_USER_BIT, a, b, c, d ); - } - } - } - - if (ctx->Light.ShadeModel == GL_FLAT) { - if (pv != inlist[0]) { - ASSERT( inlist[0] >= VB->Count ); - tnl->Driver.Render.CopyPV( ctx, inlist[0], pv ); - } - } - - tnl->Driver.Render.ClippedPolygon( ctx, inlist, n ); -} - -#undef W -#undef Z -#undef Y -#undef X -#undef SIZE -#undef TAG -#undef POLY_CLIP -#undef LINE_CLIP diff --git a/dll/opengl/mesa/tnl/t_vb_fog.c b/dll/opengl/mesa/tnl/t_vb_fog.c deleted file mode 100644 index ac773634ed4..00000000000 --- a/dll/opengl/mesa/tnl/t_vb_fog.c +++ /dev/null @@ -1,265 +0,0 @@ -/* - * Mesa 3-D graphics library - * Version: 6.5 - * - * Copyright (C) 1999-2006 Brian Paul All Rights Reserved. - * - * Permission is hereby granted, free of charge, to any person obtaining a - * copy of this software and associated documentation files (the "Software"), - * to deal in the Software without restriction, including without limitation - * the rights to use, copy, modify, merge, publish, distribute, sublicense, - * and/or sell copies of the Software, and to permit persons to whom the - * Software is furnished to do so, subject to the following conditions: - * - * The above copyright notice and this permission notice shall be included - * in all copies or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS - * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL - * BRIAN PAUL BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN - * AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN - * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. - * - * Authors: - * Keith Whitwell - */ - -#include - -struct fog_stage_data { - GLvector4f fogcoord; /* has actual storage allocated */ -}; - -#define FOG_STAGE_DATA(stage) ((struct fog_stage_data *)stage->privatePtr) - -#define FOG_EXP_TABLE_SIZE 256 -#define FOG_MAX (10.0) -#define EXP_FOG_MAX .0006595 -#define FOG_INCR (FOG_MAX/FOG_EXP_TABLE_SIZE) -static GLfloat exp_table[FOG_EXP_TABLE_SIZE]; -static GLfloat inited = 0; - -#if 1 -#define NEG_EXP( result, narg ) \ -do { \ - GLfloat f = (GLfloat) (narg * (1.0/FOG_INCR)); \ - GLint k = (GLint) f; \ - if (k > FOG_EXP_TABLE_SIZE-2) \ - result = (GLfloat) EXP_FOG_MAX; \ - else \ - result = exp_table[k] + (f-k)*(exp_table[k+1]-exp_table[k]); \ -} while (0) -#else -#define NEG_EXP( result, narg ) \ -do { \ - result = exp(-narg); \ -} while (0) -#endif - - -/** - * Initialize the exp_table[] lookup table for approximating exp(). - */ -static void -init_static_data( void ) -{ - GLfloat f = 0.0F; - GLint i = 0; - for ( ; i < FOG_EXP_TABLE_SIZE ; i++, f += FOG_INCR) { - exp_table[i] = EXPF(-f); - } - inited = 1; -} - - -/** - * Compute per-vertex fog blend factors from fog coordinates by - * evaluating the GL_LINEAR, GL_EXP or GL_EXP2 fog function. - * Fog coordinates are distances from the eye (typically between the - * near and far clip plane distances). - * Note that fogcoords may be negative, if eye z is source absolute - * value must be taken earlier. - * Fog blend factors are in the range [0,1]. - */ -static void -compute_fog_blend_factors(struct gl_context *ctx, GLvector4f *out, const GLvector4f *in) -{ - GLfloat end = ctx->Fog.End; - GLfloat *v = in->start; - GLuint stride = in->stride; - GLuint n = in->count; - GLfloat (*data)[4] = out->data; - GLfloat d; - GLuint i; - - out->count = in->count; - - switch (ctx->Fog.Mode) { - case GL_LINEAR: - if (ctx->Fog.Start == ctx->Fog.End) - d = 1.0F; - else - d = 1.0F / (ctx->Fog.End - ctx->Fog.Start); - for ( i = 0 ; i < n ; i++, STRIDE_F(v, stride)) { - const GLfloat z = *v; - GLfloat f = (end - z) * d; - data[i][0] = CLAMP(f, 0.0F, 1.0F); - } - break; - case GL_EXP: - d = ctx->Fog.Density; - for ( i = 0 ; i < n ; i++, STRIDE_F(v,stride)) { - const GLfloat z = *v; - NEG_EXP( data[i][0], d * z ); - } - break; - case GL_EXP2: - d = ctx->Fog.Density*ctx->Fog.Density; - for ( i = 0 ; i < n ; i++, STRIDE_F(v, stride)) { - const GLfloat z = *v; - NEG_EXP( data[i][0], d * z * z ); - } - break; - default: - _mesa_problem(ctx, "Bad fog mode in make_fog_coord"); - return; - } -} - - -static GLboolean -run_fog_stage(struct gl_context *ctx, struct tnl_pipeline_stage *stage) -{ - TNLcontext *tnl = TNL_CONTEXT(ctx); - struct vertex_buffer *VB = &tnl->vb; - struct fog_stage_data *store = FOG_STAGE_DATA(stage); - GLvector4f *input; - - - if (!ctx->Fog.Enabled) - return GL_TRUE; - - if (ctx->Fog.FogCoordinateSource == GL_FRAGMENT_DEPTH_EXT) { - GLuint i; - GLfloat *coord; - /* Fog is computed from vertex or fragment Z values */ - /* source = VB->AttribPtr[_TNL_ATTRIB_POS] or VB->EyePtr coords */ - /* dest = VB->AttribPtr[_TNL_ATTRIB_FOG] = fog stage private storage */ - VB->AttribPtr[_TNL_ATTRIB_FOG] = &store->fogcoord; - - if (!ctx->_NeedEyeCoords) { - /* compute fog coords from object coords */ - const GLfloat *m = ctx->ModelviewMatrixStack.Top->m; - GLfloat plane[4]; - - /* Use this to store calculated eye z values: - */ - input = &store->fogcoord; - - plane[0] = m[2]; - plane[1] = m[6]; - plane[2] = m[10]; - plane[3] = m[14]; - /* Full eye coords weren't required, just calculate the - * eye Z values. - */ - _mesa_dotprod_tab[VB->AttribPtr[_TNL_ATTRIB_POS]->size] - ( (GLfloat *) input->data, - 4 * sizeof(GLfloat), - VB->AttribPtr[_TNL_ATTRIB_POS], plane ); - - input->count = VB->AttribPtr[_TNL_ATTRIB_POS]->count; - - /* make sure coords are really positive - NOTE should avoid going through array twice */ - coord = input->start; - for (i = 0; i < input->count; i++) { - *coord = FABSF(*coord); - STRIDE_F(coord, input->stride); - } - } - else { - /* fog coordinates = eye Z coordinates - need to copy for ABS */ - input = &store->fogcoord; - - if (VB->EyePtr->size < 2) - _mesa_vector4f_clean_elem( VB->EyePtr, VB->Count, 2 ); - - input->stride = 4 * sizeof(GLfloat); - input->count = VB->EyePtr->count; - coord = VB->EyePtr->start; - for (i = 0 ; i < VB->EyePtr->count; i++) { - input->data[i][0] = FABSF(coord[2]); - STRIDE_F(coord, VB->EyePtr->stride); - } - } - } - else { - /* use glFogCoord() coordinates */ - input = VB->AttribPtr[_TNL_ATTRIB_FOG]; /* source data */ - - /* input->count may be one if glFogCoord was only called once - * before glBegin. But we need to compute fog for all vertices. - */ - input->count = VB->AttribPtr[_TNL_ATTRIB_POS]->count; - - VB->AttribPtr[_TNL_ATTRIB_FOG] = &store->fogcoord; /* dest data */ - } - - if (tnl->_DoVertexFog) { - /* compute blend factors from fog coordinates */ - compute_fog_blend_factors( ctx, VB->AttribPtr[_TNL_ATTRIB_FOG], input ); - } - else { - /* results = incoming fog coords (compute fog per-fragment later) */ - VB->AttribPtr[_TNL_ATTRIB_FOG] = input; - } - - return GL_TRUE; -} - - - -/* Called the first time stage->run() is invoked. - */ -static GLboolean -alloc_fog_data(struct gl_context *ctx, struct tnl_pipeline_stage *stage) -{ - TNLcontext *tnl = TNL_CONTEXT(ctx); - struct fog_stage_data *store; - stage->privatePtr = MALLOC(sizeof(*store)); - store = FOG_STAGE_DATA(stage); - if (!store) - return GL_FALSE; - - _mesa_vector4f_alloc( &store->fogcoord, 0, tnl->vb.Size, 32 ); - - if (!inited) - init_static_data(); - - return GL_TRUE; -} - - -static void -free_fog_data(struct tnl_pipeline_stage *stage) -{ - struct fog_stage_data *store = FOG_STAGE_DATA(stage); - if (store) { - _mesa_vector4f_free( &store->fogcoord ); - FREE( store ); - stage->privatePtr = NULL; - } -} - - -const struct tnl_pipeline_stage _tnl_fog_coordinate_stage = -{ - "build fog coordinates", /* name */ - NULL, /* private_data */ - alloc_fog_data, /* dtr */ - free_fog_data, /* dtr */ - NULL, /* check */ - run_fog_stage /* run -- initially set to init. */ -}; diff --git a/dll/opengl/mesa/tnl/t_vb_light.c b/dll/opengl/mesa/tnl/t_vb_light.c deleted file mode 100644 index 355e85f6fd3..00000000000 --- a/dll/opengl/mesa/tnl/t_vb_light.c +++ /dev/null @@ -1,320 +0,0 @@ -/* - * Mesa 3-D graphics library - * Version: 6.5 - * - * Copyright (C) 1999-2006 Brian Paul All Rights Reserved. - * - * Permission is hereby granted, free of charge, to any person obtaining a - * copy of this software and associated documentation files (the "Software"), - * to deal in the Software without restriction, including without limitation - * the rights to use, copy, modify, merge, publish, distribute, sublicense, - * and/or sell copies of the Software, and to permit persons to whom the - * Software is furnished to do so, subject to the following conditions: - * - * The above copyright notice and this permission notice shall be included - * in all copies or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS - * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL - * BRIAN PAUL BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN - * AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN - * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. - */ - -#include - -#define LIGHT_TWOSIDE 0x1 -#define LIGHT_MATERIAL 0x2 -#define MAX_LIGHT_FUNC 0x4 - -typedef void (*light_func)( struct gl_context *ctx, - struct vertex_buffer *VB, - struct tnl_pipeline_stage *stage, - GLvector4f *input ); - -/** - * Information for updating current material attributes from vertex color, - * for GL_COLOR_MATERIAL. - */ -struct material_cursor { - const GLfloat *ptr; /* points to src vertex color (in VB array) */ - GLuint stride; /* stride to next vertex color (bytes) */ - GLfloat *current; /* points to material attribute to update */ - GLuint size; /* vertex/color size: 1, 2, 3 or 4 */ -}; - -/** - * Data private to this pipeline stage. - */ -struct light_stage_data { - GLvector4f Input; - GLvector4f LitColor[2]; - light_func *light_func_tab; - - struct material_cursor mat[MAT_ATTRIB_MAX]; - GLuint mat_count; - GLuint mat_bitmask; -}; - - -#define LIGHT_STAGE_DATA(stage) ((struct light_stage_data *)(stage->privatePtr)) - - - -/** - * In the case of colormaterial, the effected material attributes - * should already have been bound to point to the incoming color data, - * prior to running the pipeline. - * This function copies the vertex's color to the material attributes - * which are tracking glColor. - * It's called per-vertex in the lighting loop. - */ -static void -update_materials(struct gl_context *ctx, struct light_stage_data *store) -{ - GLuint i; - - for (i = 0 ; i < store->mat_count ; i++) { - /* update the material */ - COPY_CLEAN_4V(store->mat[i].current, store->mat[i].size, store->mat[i].ptr); - /* increment src vertex color pointer */ - STRIDE_F(store->mat[i].ptr, store->mat[i].stride); - } - - /* recompute derived light/material values */ - _mesa_update_material( ctx, store->mat_bitmask ); - /* XXX we should only call this if we're tracking/changing the specular - * exponent. - */ - _mesa_validate_all_lighting_tables( ctx ); -} - - -/** - * Prepare things prior to running the lighting stage. - * Return number of material attributes which will track vertex color. - */ -static GLuint -prepare_materials(struct gl_context *ctx, - struct vertex_buffer *VB, struct light_stage_data *store) -{ - GLuint i; - - store->mat_count = 0; - store->mat_bitmask = 0; - - /* Examine the ColorMaterialBitmask to determine which materials - * track vertex color. Override the material attribute's pointer - * with the color pointer for each one. - */ - if (ctx->Light.ColorMaterialEnabled) { - const GLuint bitmask = ctx->Light.ColorMaterialBitmask; - for (i = 0 ; i < MAT_ATTRIB_MAX ; i++) - if (bitmask & (1<AttribPtr[_TNL_ATTRIB_MAT_FRONT_AMBIENT + i] = VB->AttribPtr[_TNL_ATTRIB_COLOR]; - } - - /* Now, for each material attribute that's tracking vertex color, save - * some values (ptr, stride, size, current) that we'll need in - * update_materials(), above, that'll actually copy the vertex color to - * the material attribute(s). - */ - for (i = _TNL_FIRST_MAT; i <= _TNL_LAST_MAT; i++) { - if (VB->AttribPtr[i]->stride) { - const GLuint j = store->mat_count++; - const GLuint attr = i - _TNL_ATTRIB_MAT_FRONT_AMBIENT; - store->mat[j].ptr = VB->AttribPtr[i]->start; - store->mat[j].stride = VB->AttribPtr[i]->stride; - store->mat[j].size = VB->AttribPtr[i]->size; - store->mat[j].current = ctx->Light.Material.Attrib[attr]; - store->mat_bitmask |= (1<mat_count; -} - -/* Tables for all the shading functions. - */ -static light_func _tnl_light_tab[MAX_LIGHT_FUNC]; -static light_func _tnl_light_fast_tab[MAX_LIGHT_FUNC]; -static light_func _tnl_light_fast_single_tab[MAX_LIGHT_FUNC]; -static light_func _tnl_light_spec_tab[MAX_LIGHT_FUNC]; - -#define TAG(x) x -#define IDX (0) -#include "t_vb_lighttmp.h" - -#define TAG(x) x##_twoside -#define IDX (LIGHT_TWOSIDE) -#include "t_vb_lighttmp.h" - -#define TAG(x) x##_material -#define IDX (LIGHT_MATERIAL) -#include "t_vb_lighttmp.h" - -#define TAG(x) x##_twoside_material -#define IDX (LIGHT_TWOSIDE|LIGHT_MATERIAL) -#include "t_vb_lighttmp.h" - - -static void init_lighting_tables( void ) -{ - static int done; - - if (!done) { - init_light_tab(); - init_light_tab_twoside(); - init_light_tab_material(); - init_light_tab_twoside_material(); - done = 1; - } -} - - -static GLboolean run_lighting( struct gl_context *ctx, - struct tnl_pipeline_stage *stage ) -{ - struct light_stage_data *store = LIGHT_STAGE_DATA(stage); - TNLcontext *tnl = TNL_CONTEXT(ctx); - struct vertex_buffer *VB = &tnl->vb; - GLvector4f *input = ctx->_NeedEyeCoords ? VB->EyePtr : VB->AttribPtr[_TNL_ATTRIB_POS]; - GLuint idx; - - if (!ctx->Light.Enabled) - return GL_TRUE; - - /* Make sure we can talk about position x,y and z: - */ - if (input->size <= 2 && input == VB->AttribPtr[_TNL_ATTRIB_POS]) { - - _math_trans_4f( store->Input.data, - VB->AttribPtr[_TNL_ATTRIB_POS]->data, - VB->AttribPtr[_TNL_ATTRIB_POS]->stride, - GL_FLOAT, - VB->AttribPtr[_TNL_ATTRIB_POS]->size, - 0, - VB->Count ); - - if (input->size <= 2) { - /* Clean z. - */ - _mesa_vector4f_clean_elem(&store->Input, VB->Count, 2); - } - - if (input->size <= 1) { - /* Clean y. - */ - _mesa_vector4f_clean_elem(&store->Input, VB->Count, 1); - } - - input = &store->Input; - } - - idx = 0; - - if (prepare_materials( ctx, VB, store )) - idx |= LIGHT_MATERIAL; - - if (ctx->Light.Model.TwoSide) - idx |= LIGHT_TWOSIDE; - - /* The individual functions know about replaying side-effects - * vs. full re-execution. - */ - store->light_func_tab[idx]( ctx, VB, stage, input ); - - return GL_TRUE; -} - - -/* Called in place of do_lighting when the light table may have changed. - */ -static void validate_lighting( struct gl_context *ctx, - struct tnl_pipeline_stage *stage ) -{ - light_func *tab; - - if (!ctx->Light.Enabled) - return; - - if (ctx->Light._NeedVertices) { - tab = _tnl_light_tab; - } - else { - if (ctx->Light.EnabledList.next == ctx->Light.EnabledList.prev) - tab = _tnl_light_fast_single_tab; - else - tab = _tnl_light_fast_tab; - } - - - LIGHT_STAGE_DATA(stage)->light_func_tab = tab; - - /* This and the above should only be done on _NEW_LIGHT: - */ - TNL_CONTEXT(ctx)->Driver.NotifyMaterialChange( ctx ); -} - - - -/* Called the first time stage->run is called. In effect, don't - * allocate data until the first time the stage is run. - */ -static GLboolean init_lighting( struct gl_context *ctx, - struct tnl_pipeline_stage *stage ) -{ - TNLcontext *tnl = TNL_CONTEXT(ctx); - struct light_stage_data *store; - GLuint size = tnl->vb.Size; - - stage->privatePtr = MALLOC(sizeof(*store)); - store = LIGHT_STAGE_DATA(stage); - if (!store) - return GL_FALSE; - - /* Do onetime init. - */ - init_lighting_tables(); - - _mesa_vector4f_alloc( &store->Input, 0, size, 32 ); - _mesa_vector4f_alloc( &store->LitColor[0], 0, size, 32 ); - _mesa_vector4f_alloc( &store->LitColor[1], 0, size, 32 ); - - store->LitColor[0].size = 4; - store->LitColor[1].size = 4; - - return GL_TRUE; -} - - - - -static void dtr( struct tnl_pipeline_stage *stage ) -{ - struct light_stage_data *store = LIGHT_STAGE_DATA(stage); - - if (store) { - _mesa_vector4f_free( &store->Input ); - _mesa_vector4f_free( &store->LitColor[0] ); - _mesa_vector4f_free( &store->LitColor[1] ); - FREE( store ); - stage->privatePtr = NULL; - } -} - -const struct tnl_pipeline_stage _tnl_lighting_stage = -{ - "lighting", /* name */ - NULL, /* private_data */ - init_lighting, - dtr, /* destroy */ - validate_lighting, - run_lighting -}; diff --git a/dll/opengl/mesa/tnl/t_vb_lighttmp.h b/dll/opengl/mesa/tnl/t_vb_lighttmp.h deleted file mode 100644 index f9a21149b92..00000000000 --- a/dll/opengl/mesa/tnl/t_vb_lighttmp.h +++ /dev/null @@ -1,637 +0,0 @@ -/* - * Mesa 3-D graphics library - * Version: 5.1 - * - * Copyright (C) 1999-2003 Brian Paul All Rights Reserved. - * - * Permission is hereby granted, free of charge, to any person obtaining a - * copy of this software and associated documentation files (the "Software"), - * to deal in the Software without restriction, including without limitation - * the rights to use, copy, modify, merge, publish, distribute, sublicense, - * and/or sell copies of the Software, and to permit persons to whom the - * Software is furnished to do so, subject to the following conditions: - * - * The above copyright notice and this permission notice shall be included - * in all copies or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS - * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL - * BRIAN PAUL BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN - * AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN - * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. - * - * - * Authors: - * Brian Paul - * Keith Whitwell - */ - - -/* define TRACE to trace lighting code */ -/* #define TRACE 1 */ - -/* - * ctx is the current context - * VB is the vertex buffer - * stage is the lighting stage-private data - * input is the vector of eye or object-space vertex coordinates - */ -static void TAG(light_rgba_spec)( struct gl_context *ctx, - struct vertex_buffer *VB, - struct tnl_pipeline_stage *stage, - GLvector4f *input ) -{ - struct light_stage_data *store = LIGHT_STAGE_DATA(stage); - GLfloat (*base)[3] = ctx->Light._BaseColor; - GLfloat sumA[2]; - GLuint j; - - const GLuint vstride = input->stride; - const GLfloat *vertex = (GLfloat *)input->data; - const GLuint nstride = VB->AttribPtr[_TNL_ATTRIB_NORMAL]->stride; - const GLfloat *normal = (GLfloat *)VB->AttribPtr[_TNL_ATTRIB_NORMAL]->data; - - GLfloat (*Fcolor)[4] = (GLfloat (*)[4]) store->LitColor[0].data; -#if IDX & LIGHT_TWOSIDE - GLfloat (*Bcolor)[4] = (GLfloat (*)[4]) store->LitColor[1].data; -#endif - - const GLuint nr = VB->Count; - -#ifdef TRACE - fprintf(stderr, "%s\n", __FUNCTION__ ); -#endif - - VB->AttribPtr[_TNL_ATTRIB_COLOR] = &store->LitColor[0]; - sumA[0] = ctx->Light.Material.Attrib[MAT_ATTRIB_FRONT_DIFFUSE][3]; - -#if IDX & LIGHT_TWOSIDE - VB->BackfaceColorPtr = &store->LitColor[1]; - sumA[1] = ctx->Light.Material.Attrib[MAT_ATTRIB_BACK_DIFFUSE][3]; -#endif - - - store->LitColor[0].stride = 16; - store->LitColor[1].stride = 16; - - for (j = 0; j < nr; j++,STRIDE_F(vertex,vstride),STRIDE_F(normal,nstride)) { - GLfloat sum[2][3], spec[2][3]; - struct gl_light *light; - -#if IDX & LIGHT_MATERIAL - update_materials( ctx, store ); - sumA[0] = ctx->Light.Material.Attrib[MAT_ATTRIB_FRONT_DIFFUSE][3]; -#if IDX & LIGHT_TWOSIDE - sumA[1] = ctx->Light.Material.Attrib[MAT_ATTRIB_BACK_DIFFUSE][3]; -#endif -#endif - - COPY_3V(sum[0], base[0]); - ZERO_3V(spec[0]); - -#if IDX & LIGHT_TWOSIDE - COPY_3V(sum[1], base[1]); - ZERO_3V(spec[1]); -#endif - - /* Add contribution from each enabled light source */ - foreach (light, &ctx->Light.EnabledList) { - GLfloat n_dot_h; - GLfloat correction; - GLint side; - GLfloat contrib[3]; - GLfloat attenuation; - GLfloat VP[3]; /* unit vector from vertex to light */ - GLfloat n_dot_VP; /* n dot VP */ - GLfloat *h; - - /* compute VP and attenuation */ - if (!(light->_Flags & LIGHT_POSITIONAL)) { - /* directional light */ - COPY_3V(VP, light->_VP_inf_norm); - attenuation = light->_VP_inf_spot_attenuation; - } - else { - GLfloat d; /* distance from vertex to light */ - - SUB_3V(VP, light->_Position, vertex); - - d = (GLfloat) LEN_3FV( VP ); - - if (d > 1e-6) { - GLfloat invd = 1.0F / d; - SELF_SCALE_SCALAR_3V(VP, invd); - } - - attenuation = 1.0F / (light->ConstantAttenuation + d * - (light->LinearAttenuation + d * - light->QuadraticAttenuation)); - - /* spotlight attenuation */ - if (light->_Flags & LIGHT_SPOT) { - GLfloat PV_dot_dir = - DOT3(VP, light->_NormSpotDirection); - - if (PV_dot_dir_CosCutoff) { - continue; /* this light makes no contribution */ - } - else { - GLdouble x = PV_dot_dir * (EXP_TABLE_SIZE-1); - GLint k = (GLint) x; - GLfloat spot = (GLfloat) (light->_SpotExpTable[k][0] - + (x-k)*light->_SpotExpTable[k][1]); - attenuation *= spot; - } - } - } - - if (attenuation < 1e-3) - continue; /* this light makes no contribution */ - - /* Compute dot product or normal and vector from V to light pos */ - n_dot_VP = DOT3( normal, VP ); - - /* Which side gets the diffuse & specular terms? */ - if (n_dot_VP < 0.0F) { - ACC_SCALE_SCALAR_3V(sum[0], attenuation, light->_MatAmbient[0]); -#if IDX & LIGHT_TWOSIDE - side = 1; - correction = -1; - n_dot_VP = -n_dot_VP; -#else - continue; -#endif - } - else { -#if IDX & LIGHT_TWOSIDE - ACC_SCALE_SCALAR_3V( sum[1], attenuation, light->_MatAmbient[1]); -#endif - side = 0; - correction = 1; - } - - /* diffuse term */ - COPY_3V(contrib, light->_MatAmbient[side]); - ACC_SCALE_SCALAR_3V(contrib, n_dot_VP, light->_MatDiffuse[side]); - ACC_SCALE_SCALAR_3V(sum[side], attenuation, contrib ); - - /* specular term - cannibalize VP... */ - if (ctx->Light.Model.LocalViewer) { - GLfloat v[3]; - COPY_3V(v, vertex); - NORMALIZE_3FV(v); - SUB_3V(VP, VP, v); /* h = VP + VPe */ - h = VP; - NORMALIZE_3FV(h); - } - else if (light->_Flags & LIGHT_POSITIONAL) { - h = VP; - ACC_3V(h, ctx->_EyeZDir); - NORMALIZE_3FV(h); - } - else { - h = light->_h_inf_norm; - } - - n_dot_h = correction * DOT3(normal, h); - - if (n_dot_h > 0.0F) { - GLfloat spec_coef; - struct gl_shine_tab *tab = ctx->_ShineTable[side]; - GET_SHINE_TAB_ENTRY( tab, n_dot_h, spec_coef ); - - if (spec_coef > 1.0e-10) { - spec_coef *= attenuation; - ACC_SCALE_SCALAR_3V( spec[side], spec_coef, - light->_MatSpecular[side]); - } - } - } /*loop over lights*/ - - COPY_3V( Fcolor[j], sum[0] ); - Fcolor[j][3] = sumA[0]; - -#if IDX & LIGHT_TWOSIDE - COPY_3V( Bcolor[j], sum[1] ); - Bcolor[j][3] = sumA[1]; -#endif - } -} - - -static void TAG(light_rgba)( struct gl_context *ctx, - struct vertex_buffer *VB, - struct tnl_pipeline_stage *stage, - GLvector4f *input ) -{ - struct light_stage_data *store = LIGHT_STAGE_DATA(stage); - GLuint j; - - GLfloat (*base)[3] = ctx->Light._BaseColor; - GLfloat sumA[2]; - - const GLuint vstride = input->stride; - const GLfloat *vertex = (GLfloat *) input->data; - const GLuint nstride = VB->AttribPtr[_TNL_ATTRIB_NORMAL]->stride; - const GLfloat *normal = (GLfloat *)VB->AttribPtr[_TNL_ATTRIB_NORMAL]->data; - - GLfloat (*Fcolor)[4] = (GLfloat (*)[4]) store->LitColor[0].data; -#if IDX & LIGHT_TWOSIDE - GLfloat (*Bcolor)[4] = (GLfloat (*)[4]) store->LitColor[1].data; -#endif - - const GLuint nr = VB->Count; - -#ifdef TRACE - fprintf(stderr, "%s\n", __FUNCTION__ ); -#endif - - VB->AttribPtr[_TNL_ATTRIB_COLOR] = &store->LitColor[0]; - sumA[0] = ctx->Light.Material.Attrib[MAT_ATTRIB_FRONT_DIFFUSE][3]; - -#if IDX & LIGHT_TWOSIDE - VB->BackfaceColorPtr = &store->LitColor[1]; - sumA[1] = ctx->Light.Material.Attrib[MAT_ATTRIB_BACK_DIFFUSE][3]; -#endif - - store->LitColor[0].stride = 16; - store->LitColor[1].stride = 16; - - for (j = 0; j < nr; j++,STRIDE_F(vertex,vstride),STRIDE_F(normal,nstride)) { - GLfloat sum[2][3]; - struct gl_light *light; - -#if IDX & LIGHT_MATERIAL - update_materials( ctx, store ); - sumA[0] = ctx->Light.Material.Attrib[MAT_ATTRIB_FRONT_DIFFUSE][3]; -#if IDX & LIGHT_TWOSIDE - sumA[1] = ctx->Light.Material.Attrib[MAT_ATTRIB_BACK_DIFFUSE][3]; -#endif -#endif - - COPY_3V(sum[0], base[0]); - -#if IDX & LIGHT_TWOSIDE - COPY_3V(sum[1], base[1]); -#endif - - /* Add contribution from each enabled light source */ - foreach (light, &ctx->Light.EnabledList) { - - GLfloat n_dot_h; - GLfloat correction; - GLint side; - GLfloat contrib[3]; - GLfloat attenuation = 1.0; - GLfloat VP[3]; /* unit vector from vertex to light */ - GLfloat n_dot_VP; /* n dot VP */ - GLfloat *h; - - /* compute VP and attenuation */ - if (!(light->_Flags & LIGHT_POSITIONAL)) { - /* directional light */ - COPY_3V(VP, light->_VP_inf_norm); - attenuation = light->_VP_inf_spot_attenuation; - } - else { - GLfloat d; /* distance from vertex to light */ - - - SUB_3V(VP, light->_Position, vertex); - - d = (GLfloat) LEN_3FV( VP ); - - if ( d > 1e-6) { - GLfloat invd = 1.0F / d; - SELF_SCALE_SCALAR_3V(VP, invd); - } - - attenuation = 1.0F / (light->ConstantAttenuation + d * - (light->LinearAttenuation + d * - light->QuadraticAttenuation)); - - /* spotlight attenuation */ - if (light->_Flags & LIGHT_SPOT) { - GLfloat PV_dot_dir = - DOT3(VP, light->_NormSpotDirection); - - if (PV_dot_dir_CosCutoff) { - continue; /* this light makes no contribution */ - } - else { - GLdouble x = PV_dot_dir * (EXP_TABLE_SIZE-1); - GLint k = (GLint) x; - GLfloat spot = (GLfloat) (light->_SpotExpTable[k][0] - + (x-k)*light->_SpotExpTable[k][1]); - attenuation *= spot; - } - } - } - - if (attenuation < 1e-3) - continue; /* this light makes no contribution */ - - /* Compute dot product or normal and vector from V to light pos */ - n_dot_VP = DOT3( normal, VP ); - - /* which side are we lighting? */ - if (n_dot_VP < 0.0F) { - ACC_SCALE_SCALAR_3V(sum[0], attenuation, light->_MatAmbient[0]); -#if IDX & LIGHT_TWOSIDE - side = 1; - correction = -1; - n_dot_VP = -n_dot_VP; -#else - continue; -#endif - } - else { -#if IDX & LIGHT_TWOSIDE - ACC_SCALE_SCALAR_3V( sum[1], attenuation, light->_MatAmbient[1]); -#endif - side = 0; - correction = 1; - } - - COPY_3V(contrib, light->_MatAmbient[side]); - - /* diffuse term */ - ACC_SCALE_SCALAR_3V(contrib, n_dot_VP, light->_MatDiffuse[side]); - - /* specular term - cannibalize VP... */ - { - if (ctx->Light.Model.LocalViewer) { - GLfloat v[3]; - COPY_3V(v, vertex); - NORMALIZE_3FV(v); - SUB_3V(VP, VP, v); /* h = VP + VPe */ - h = VP; - NORMALIZE_3FV(h); - } - else if (light->_Flags & LIGHT_POSITIONAL) { - h = VP; - ACC_3V(h, ctx->_EyeZDir); - NORMALIZE_3FV(h); - } - else { - h = light->_h_inf_norm; - } - - n_dot_h = correction * DOT3(normal, h); - - if (n_dot_h > 0.0F) - { - GLfloat spec_coef; - struct gl_shine_tab *tab = ctx->_ShineTable[side]; - - GET_SHINE_TAB_ENTRY( tab, n_dot_h, spec_coef ); - - ACC_SCALE_SCALAR_3V( contrib, spec_coef, - light->_MatSpecular[side]); - } - } - - ACC_SCALE_SCALAR_3V( sum[side], attenuation, contrib ); - } - - COPY_3V( Fcolor[j], sum[0] ); - Fcolor[j][3] = sumA[0]; - -#if IDX & LIGHT_TWOSIDE - COPY_3V( Bcolor[j], sum[1] ); - Bcolor[j][3] = sumA[1]; -#endif - } -} - - - - -/* As below, but with just a single light. - */ -static void TAG(light_fast_rgba_single)( struct gl_context *ctx, - struct vertex_buffer *VB, - struct tnl_pipeline_stage *stage, - GLvector4f *input ) - -{ - struct light_stage_data *store = LIGHT_STAGE_DATA(stage); - const GLuint nstride = VB->AttribPtr[_TNL_ATTRIB_NORMAL]->stride; - const GLfloat *normal = (GLfloat *)VB->AttribPtr[_TNL_ATTRIB_NORMAL]->data; - GLfloat (*Fcolor)[4] = (GLfloat (*)[4]) store->LitColor[0].data; -#if IDX & LIGHT_TWOSIDE - GLfloat (*Bcolor)[4] = (GLfloat (*)[4]) store->LitColor[1].data; -#endif - const struct gl_light *light = ctx->Light.EnabledList.next; - GLuint j = 0; - GLfloat base[2][4]; -#if IDX & LIGHT_MATERIAL - const GLuint nr = VB->Count; -#else - const GLuint nr = VB->AttribPtr[_TNL_ATTRIB_NORMAL]->count; -#endif - -#ifdef TRACE - fprintf(stderr, "%s\n", __FUNCTION__ ); -#endif - - (void) input; /* doesn't refer to Eye or Obj */ - - VB->AttribPtr[_TNL_ATTRIB_COLOR] = &store->LitColor[0]; -#if IDX & LIGHT_TWOSIDE - VB->BackfaceColorPtr = &store->LitColor[1]; -#endif - - if (nr > 1) { - store->LitColor[0].stride = 16; - store->LitColor[1].stride = 16; - } - else { - store->LitColor[0].stride = 0; - store->LitColor[1].stride = 0; - } - - for (j = 0; j < nr; j++, STRIDE_F(normal,nstride)) { - - GLfloat n_dot_VP; - -#if IDX & LIGHT_MATERIAL - update_materials( ctx, store ); -#endif - - /* No attenuation, so incoporate _MatAmbient into base color. - */ -#if !(IDX & LIGHT_MATERIAL) - if ( j == 0 ) -#endif - { - COPY_3V(base[0], light->_MatAmbient[0]); - ACC_3V(base[0], ctx->Light._BaseColor[0] ); - base[0][3] = ctx->Light.Material.Attrib[MAT_ATTRIB_FRONT_DIFFUSE][3]; - -#if IDX & LIGHT_TWOSIDE - COPY_3V(base[1], light->_MatAmbient[1]); - ACC_3V(base[1], ctx->Light._BaseColor[1]); - base[1][3] = ctx->Light.Material.Attrib[MAT_ATTRIB_BACK_DIFFUSE][3]; -#endif - } - - n_dot_VP = DOT3(normal, light->_VP_inf_norm); - - if (n_dot_VP < 0.0F) { -#if IDX & LIGHT_TWOSIDE - GLfloat n_dot_h = -DOT3(normal, light->_h_inf_norm); - GLfloat sum[3]; - COPY_3V(sum, base[1]); - ACC_SCALE_SCALAR_3V(sum, -n_dot_VP, light->_MatDiffuse[1]); - if (n_dot_h > 0.0F) { - GLfloat spec; - GET_SHINE_TAB_ENTRY( ctx->_ShineTable[1], n_dot_h, spec ); - ACC_SCALE_SCALAR_3V(sum, spec, light->_MatSpecular[1]); - } - COPY_3V(Bcolor[j], sum ); - Bcolor[j][3] = base[1][3]; -#endif - COPY_4FV(Fcolor[j], base[0]); - } - else { - GLfloat n_dot_h = DOT3(normal, light->_h_inf_norm); - GLfloat sum[3]; - COPY_3V(sum, base[0]); - ACC_SCALE_SCALAR_3V(sum, n_dot_VP, light->_MatDiffuse[0]); - if (n_dot_h > 0.0F) { - GLfloat spec; - GET_SHINE_TAB_ENTRY( ctx->_ShineTable[0], n_dot_h, spec ); - ACC_SCALE_SCALAR_3V(sum, spec, light->_MatSpecular[0]); - - } - COPY_3V(Fcolor[j], sum ); - Fcolor[j][3] = base[0][3]; -#if IDX & LIGHT_TWOSIDE - COPY_4FV(Bcolor[j], base[1]); -#endif - } - } -} - - -/* Light infinite lights - */ -static void TAG(light_fast_rgba)( struct gl_context *ctx, - struct vertex_buffer *VB, - struct tnl_pipeline_stage *stage, - GLvector4f *input ) -{ - struct light_stage_data *store = LIGHT_STAGE_DATA(stage); - GLfloat sumA[2]; - const GLuint nstride = VB->AttribPtr[_TNL_ATTRIB_NORMAL]->stride; - const GLfloat *normal = (GLfloat *)VB->AttribPtr[_TNL_ATTRIB_NORMAL]->data; - GLfloat (*Fcolor)[4] = (GLfloat (*)[4]) store->LitColor[0].data; -#if IDX & LIGHT_TWOSIDE - GLfloat (*Bcolor)[4] = (GLfloat (*)[4]) store->LitColor[1].data; -#endif - GLuint j = 0; -#if IDX & LIGHT_MATERIAL - const GLuint nr = VB->Count; -#else - const GLuint nr = VB->AttribPtr[_TNL_ATTRIB_NORMAL]->count; -#endif - const struct gl_light *light; - -#ifdef TRACE - fprintf(stderr, "%s %d\n", __FUNCTION__, nr ); -#endif - - (void) input; - - sumA[0] = ctx->Light.Material.Attrib[MAT_ATTRIB_FRONT_DIFFUSE][3]; - sumA[1] = ctx->Light.Material.Attrib[MAT_ATTRIB_BACK_DIFFUSE][3]; - - VB->AttribPtr[_TNL_ATTRIB_COLOR] = &store->LitColor[0]; -#if IDX & LIGHT_TWOSIDE - VB->BackfaceColorPtr = &store->LitColor[1]; -#endif - - if (nr > 1) { - store->LitColor[0].stride = 16; - store->LitColor[1].stride = 16; - } - else { - store->LitColor[0].stride = 0; - store->LitColor[1].stride = 0; - } - - for (j = 0; j < nr; j++, STRIDE_F(normal,nstride)) { - - GLfloat sum[2][3]; - -#if IDX & LIGHT_MATERIAL - update_materials( ctx, store ); - - sumA[0] = ctx->Light.Material.Attrib[MAT_ATTRIB_FRONT_DIFFUSE][3]; -#if IDX & LIGHT_TWOSIDE - sumA[1] = ctx->Light.Material.Attrib[MAT_ATTRIB_BACK_DIFFUSE][3]; -#endif -#endif - - - COPY_3V(sum[0], ctx->Light._BaseColor[0]); -#if IDX & LIGHT_TWOSIDE - COPY_3V(sum[1], ctx->Light._BaseColor[1]); -#endif - - foreach (light, &ctx->Light.EnabledList) { - GLfloat n_dot_h, n_dot_VP, spec; - - ACC_3V(sum[0], light->_MatAmbient[0]); -#if IDX & LIGHT_TWOSIDE - ACC_3V(sum[1], light->_MatAmbient[1]); -#endif - - n_dot_VP = DOT3(normal, light->_VP_inf_norm); - - if (n_dot_VP > 0.0F) { - ACC_SCALE_SCALAR_3V(sum[0], n_dot_VP, light->_MatDiffuse[0]); - n_dot_h = DOT3(normal, light->_h_inf_norm); - if (n_dot_h > 0.0F) { - struct gl_shine_tab *tab = ctx->_ShineTable[0]; - GET_SHINE_TAB_ENTRY( tab, n_dot_h, spec ); - ACC_SCALE_SCALAR_3V( sum[0], spec, light->_MatSpecular[0]); - } - } -#if IDX & LIGHT_TWOSIDE - else { - ACC_SCALE_SCALAR_3V(sum[1], -n_dot_VP, light->_MatDiffuse[1]); - n_dot_h = -DOT3(normal, light->_h_inf_norm); - if (n_dot_h > 0.0F) { - struct gl_shine_tab *tab = ctx->_ShineTable[1]; - GET_SHINE_TAB_ENTRY( tab, n_dot_h, spec ); - ACC_SCALE_SCALAR_3V( sum[1], spec, light->_MatSpecular[1]); - } - } -#endif - } - - COPY_3V( Fcolor[j], sum[0] ); - Fcolor[j][3] = sumA[0]; - -#if IDX & LIGHT_TWOSIDE - COPY_3V( Bcolor[j], sum[1] ); - Bcolor[j][3] = sumA[1]; -#endif - } -} - - - - -static void TAG(init_light_tab)( void ) -{ - _tnl_light_tab[IDX] = TAG(light_rgba); - _tnl_light_fast_tab[IDX] = TAG(light_fast_rgba); - _tnl_light_fast_single_tab[IDX] = TAG(light_fast_rgba_single); - _tnl_light_spec_tab[IDX] = TAG(light_rgba_spec); -} - - -#undef TAG -#undef IDX diff --git a/dll/opengl/mesa/tnl/t_vb_normals.c b/dll/opengl/mesa/tnl/t_vb_normals.c deleted file mode 100644 index 518e2ffbcec..00000000000 --- a/dll/opengl/mesa/tnl/t_vb_normals.c +++ /dev/null @@ -1,175 +0,0 @@ -/* - * Mesa 3-D graphics library - * Version: 6.5 - * - * Copyright (C) 1999-2006 Brian Paul All Rights Reserved. - * - * Permission is hereby granted, free of charge, to any person obtaining a - * copy of this software and associated documentation files (the "Software"), - * to deal in the Software without restriction, including without limitation - * the rights to use, copy, modify, merge, publish, distribute, sublicense, - * and/or sell copies of the Software, and to permit persons to whom the - * Software is furnished to do so, subject to the following conditions: - * - * The above copyright notice and this permission notice shall be included - * in all copies or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS - * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL - * BRIAN PAUL BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN - * AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN - * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. - * - * Authors: - * Keith Whitwell - */ - -#include - -struct normal_stage_data { - normal_func NormalTransform; - GLvector4f normal; -}; - -#define NORMAL_STAGE_DATA(stage) ((struct normal_stage_data *)stage->privatePtr) - - -static GLboolean -run_normal_stage(struct gl_context *ctx, struct tnl_pipeline_stage *stage) -{ - struct normal_stage_data *store = NORMAL_STAGE_DATA(stage); - struct vertex_buffer *VB = &TNL_CONTEXT(ctx)->vb; - const GLfloat *lengths; - - if (!store->NormalTransform) - return GL_TRUE; - - /* We can only use the display list's saved normal lengths if we've - * got a transformation matrix with uniform scaling. - */ - if (_math_matrix_is_general_scale(ctx->ModelviewMatrixStack.Top)) - lengths = NULL; - else - lengths = VB->NormalLengthPtr; - - store->NormalTransform( ctx->ModelviewMatrixStack.Top, - ctx->_ModelViewInvScale, - VB->AttribPtr[_TNL_ATTRIB_NORMAL], /* input normals */ - lengths, - &store->normal ); /* resulting normals */ - - if (VB->AttribPtr[_TNL_ATTRIB_NORMAL]->count > 1) { - store->normal.stride = 4 * sizeof(GLfloat); - } - else { - store->normal.stride = 0; - } - - VB->AttribPtr[_TNL_ATTRIB_NORMAL] = &store->normal; - - VB->NormalLengthPtr = NULL; /* no longer valid */ - return GL_TRUE; -} - - -/** - * Examine current GL state and set the store->NormalTransform pointer - * to point to the appropriate normal transformation routine. - */ -static void -validate_normal_stage(struct gl_context *ctx, struct tnl_pipeline_stage *stage) -{ - struct normal_stage_data *store = NORMAL_STAGE_DATA(stage); - - if (!ctx->Light.Enabled && - !(ctx->Texture._GenFlags & TEXGEN_NEED_NORMALS)) { - store->NormalTransform = NULL; - return; - } - - if (ctx->_NeedEyeCoords) { - /* Eye coordinates are needed, for whatever reasons. - * Do lighting in eye coordinates, as the GL spec says. - */ - GLuint transform = NORM_TRANSFORM_NO_ROT; - - if (_math_matrix_has_rotation(ctx->ModelviewMatrixStack.Top)) { - /* need to do full (3x3) matrix transform */ - transform = NORM_TRANSFORM; - } - - if (ctx->Transform.Normalize) { - store->NormalTransform = _mesa_normal_tab[transform | NORM_NORMALIZE]; - } - else if (ctx->Transform.RescaleNormals && - ctx->_ModelViewInvScale != 1.0) { - store->NormalTransform = _mesa_normal_tab[transform | NORM_RESCALE]; - } - else { - store->NormalTransform = _mesa_normal_tab[transform]; - } - } - else { - /* We don't need eye coordinates. - * Do lighting in object coordinates. Thus, we don't need to fully - * transform normal vectors (just leave them in object coordinates) - * but we still need to do normalization/rescaling if enabled. - */ - if (ctx->Transform.Normalize) { - store->NormalTransform = _mesa_normal_tab[NORM_NORMALIZE]; - } - else if (!ctx->Transform.RescaleNormals && - ctx->_ModelViewInvScale != 1.0) { - store->NormalTransform = _mesa_normal_tab[NORM_RESCALE]; - } - else { - store->NormalTransform = NULL; - } - } -} - - -/** - * Allocate stage's private data (storage for transformed normals). - */ -static GLboolean -alloc_normal_data(struct gl_context *ctx, struct tnl_pipeline_stage *stage) -{ - TNLcontext *tnl = TNL_CONTEXT(ctx); - struct normal_stage_data *store; - - stage->privatePtr = malloc(sizeof(*store)); - store = NORMAL_STAGE_DATA(stage); - if (!store) - return GL_FALSE; - - _mesa_vector4f_alloc( &store->normal, 0, tnl->vb.Size, 32 ); - return GL_TRUE; -} - - -/** - * Free stage's private data. - */ -static void -free_normal_data(struct tnl_pipeline_stage *stage) -{ - struct normal_stage_data *store = NORMAL_STAGE_DATA(stage); - if (store) { - _mesa_vector4f_free( &store->normal ); - free( store ); - stage->privatePtr = NULL; - } -} - - -const struct tnl_pipeline_stage _tnl_normal_transform_stage = -{ - "normal transform", /* name */ - NULL, /* privatePtr */ - alloc_normal_data, /* create */ - free_normal_data, /* destroy */ - validate_normal_stage, /* validate */ - run_normal_stage /* run */ -}; diff --git a/dll/opengl/mesa/tnl/t_vb_points.c b/dll/opengl/mesa/tnl/t_vb_points.c deleted file mode 100644 index e924e5a20e2..00000000000 --- a/dll/opengl/mesa/tnl/t_vb_points.c +++ /dev/null @@ -1,108 +0,0 @@ -/* - * Mesa 3-D graphics library - * Version: 7.0 - * - * Copyright (C) 1999-2007 Brian Paul All Rights Reserved. - * - * Permission is hereby granted, free of charge, to any person obtaining a - * copy of this software and associated documentation files (the "Software"), - * to deal in the Software without restriction, including without limitation - * the rights to use, copy, modify, merge, publish, distribute, sublicense, - * and/or sell copies of the Software, and to permit persons to whom the - * Software is furnished to do so, subject to the following conditions: - * - * The above copyright notice and this permission notice shall be included - * in all copies or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS - * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL - * BRIAN PAUL BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN - * AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN - * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. - * - * Authors: - * Brian Paul - */ - -#include - -struct point_stage_data { - GLvector4f PointSize; -}; - -#define POINT_STAGE_DATA(stage) ((struct point_stage_data *)stage->privatePtr) - - -/** - * Compute point size for each vertex from the vertex eye-space Z - * coordinate and the point size attenuation factors. - * Only done when point size attenuation is enabled and vertex program is - * disabled. - */ -static GLboolean -run_point_stage(struct gl_context *ctx, struct tnl_pipeline_stage *stage) -{ - if (ctx->Point._Attenuated) { - struct point_stage_data *store = POINT_STAGE_DATA(stage); - struct vertex_buffer *VB = &TNL_CONTEXT(ctx)->vb; - const GLfloat *eyeCoord = (GLfloat *) VB->EyePtr->data + 2; - const GLint eyeCoordStride = VB->EyePtr->stride / sizeof(GLfloat); - const GLfloat p0 = ctx->Point.Params[0]; - const GLfloat p1 = ctx->Point.Params[1]; - const GLfloat p2 = ctx->Point.Params[2]; - const GLfloat pointSize = ctx->Point.Size; - GLfloat (*size)[4] = store->PointSize.data; - GLuint i; - - for (i = 0; i < VB->Count; i++) { - const GLfloat dist = FABSF(*eyeCoord); - const GLfloat q = p0 + dist * (p1 + dist * p2); - const GLfloat atten = (q != 0.0F) ? SQRTF(1.0F / q) : 1.0F; - size[i][0] = pointSize * atten; /* clamping done in rasterization */ - eyeCoord += eyeCoordStride; - } - - VB->AttribPtr[_TNL_ATTRIB_POINTSIZE] = &store->PointSize; - } - - return GL_TRUE; -} - - -static GLboolean -alloc_point_data(struct gl_context *ctx, struct tnl_pipeline_stage *stage) -{ - struct vertex_buffer *VB = &TNL_CONTEXT(ctx)->vb; - struct point_stage_data *store; - stage->privatePtr = malloc(sizeof(*store)); - store = POINT_STAGE_DATA(stage); - if (!store) - return GL_FALSE; - - _mesa_vector4f_alloc( &store->PointSize, 0, VB->Size, 32 ); - return GL_TRUE; -} - - -static void -free_point_data(struct tnl_pipeline_stage *stage) -{ - struct point_stage_data *store = POINT_STAGE_DATA(stage); - if (store) { - _mesa_vector4f_free( &store->PointSize ); - free( store ); - stage->privatePtr = NULL; - } -} - - -const struct tnl_pipeline_stage _tnl_point_attenuation_stage = -{ - "point size attenuation", /* name */ - NULL, /* stage private data */ - alloc_point_data, /* alloc data */ - free_point_data, /* destructor */ - NULL, - run_point_stage /* run */ -}; diff --git a/dll/opengl/mesa/tnl/t_vb_render.c b/dll/opengl/mesa/tnl/t_vb_render.c deleted file mode 100644 index d89b2be2a31..00000000000 --- a/dll/opengl/mesa/tnl/t_vb_render.c +++ /dev/null @@ -1,337 +0,0 @@ -/* - * Mesa 3-D graphics library - * Version: 6.5 - * - * Copyright (C) 1999-2005 Brian Paul All Rights Reserved. - * - * Permission is hereby granted, free of charge, to any person obtaining a - * copy of this software and associated documentation files (the "Software"), - * to deal in the Software without restriction, including without limitation - * the rights to use, copy, modify, merge, publish, distribute, sublicense, - * and/or sell copies of the Software, and to permit persons to whom the - * Software is furnished to do so, subject to the following conditions: - * - * The above copyright notice and this permission notice shall be included - * in all copies or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS - * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL - * BRIAN PAUL BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN - * AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN - * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. - * - * Authors: - * Keith Whitwell - */ - - -/* - * Render whole vertex buffers, including projection of vertices from - * clip space and clipping of primitives. - * - * This file makes calls to project vertices and to the point, line - * and triangle rasterizers via the function pointers: - * - * context->Driver.Render.* - * - */ - -#include - -/**********************************************************************/ -/* Clip single primitives */ -/**********************************************************************/ - - -#define W(i) coord[i][3] -#define Z(i) coord[i][2] -#define Y(i) coord[i][1] -#define X(i) coord[i][0] -#define SIZE 4 -#define TAG(x) x##_4 -#include "t_vb_cliptmp.h" - - - -/**********************************************************************/ -/* Clip and render whole begin/end objects */ -/**********************************************************************/ - -#define NEED_EDGEFLAG_SETUP (ctx->Polygon.FrontMode != GL_FILL || ctx->Polygon.BackMode != GL_FILL) -#define EDGEFLAG_GET(idx) VB->EdgeFlag[idx] -#define EDGEFLAG_SET(idx, val) VB->EdgeFlag[idx] = val - - -/* This does NOT include the CLIP_USER_BIT! */ -#define CLIPMASK (CLIP_FRUSTUM_BITS | CLIP_CULL_BIT) - - -/* Vertices, with the possibility of clipping. - */ -#define RENDER_POINTS( start, count ) \ - tnl->Driver.Render.Points( ctx, start, count ) - -#define RENDER_LINE( v1, v2 ) \ -do { \ - GLubyte c1 = mask[v1], c2 = mask[v2]; \ - GLubyte ormask = c1|c2; \ - if (!ormask) \ - LineFunc( ctx, v1, v2 ); \ - else if (!(c1 & c2 & CLIPMASK)) \ - clip_line_4( ctx, v1, v2, ormask ); \ -} while (0) - -#define RENDER_TRI( v1, v2, v3 ) \ -do { \ - GLubyte c1 = mask[v1], c2 = mask[v2], c3 = mask[v3]; \ - GLubyte ormask = c1|c2|c3; \ - if (!ormask) \ - TriangleFunc( ctx, v1, v2, v3 ); \ - else if (!(c1 & c2 & c3 & CLIPMASK)) \ - clip_tri_4( ctx, v1, v2, v3, ormask ); \ -} while (0) - -#define RENDER_QUAD( v1, v2, v3, v4 ) \ -do { \ - GLubyte c1 = mask[v1], c2 = mask[v2]; \ - GLubyte c3 = mask[v3], c4 = mask[v4]; \ - GLubyte ormask = c1|c2|c3|c4; \ - if (!ormask) \ - QuadFunc( ctx, v1, v2, v3, v4 ); \ - else if (!(c1 & c2 & c3 & c4 & CLIPMASK)) \ - clip_quad_4( ctx, v1, v2, v3, v4, ormask ); \ -} while (0) - - -#define LOCAL_VARS \ - TNLcontext *tnl = TNL_CONTEXT(ctx); \ - struct vertex_buffer *VB = &tnl->vb; \ - const GLuint * const elt = VB->Elts; \ - const GLubyte *mask = VB->ClipMask; \ - const GLuint sz = VB->ClipPtr->size; \ - const tnl_line_func LineFunc = tnl->Driver.Render.Line; \ - const tnl_triangle_func TriangleFunc = tnl->Driver.Render.Triangle; \ - const tnl_quad_func QuadFunc = tnl->Driver.Render.Quad; \ - const GLboolean stipple = ctx->Line.StippleFlag; \ - (void) (LineFunc && TriangleFunc && QuadFunc); \ - (void) elt; (void) mask; (void) sz; (void) stipple; - -#define TAG(x) clip_##x##_verts -#define INIT(x) tnl->Driver.Render.PrimitiveNotify( ctx, x ) -#define RESET_STIPPLE if (stipple) tnl->Driver.Render.ResetLineStipple( ctx ) -#define PRESERVE_VB_DEFS -#include "t_vb_rendertmp.h" - - - -/* Elts, with the possibility of clipping. - */ -#undef ELT -#undef TAG -#define ELT(x) elt[x] -#define TAG(x) clip_##x##_elts -#include "t_vb_rendertmp.h" - -/* TODO: do this for all primitives, verts and elts: - */ -static void clip_elt_triangles( struct gl_context *ctx, - GLuint start, - GLuint count, - GLuint flags ) -{ - TNLcontext *tnl = TNL_CONTEXT(ctx); - tnl_render_func render_tris = tnl->Driver.Render.PrimTabElts[GL_TRIANGLES]; - struct vertex_buffer *VB = &tnl->vb; - const GLuint * const elt = VB->Elts; - GLubyte *mask = VB->ClipMask; - GLuint last = count-2; - GLuint j; - (void) flags; - - tnl->Driver.Render.PrimitiveNotify( ctx, GL_TRIANGLES ); - - for (j=start; j < last; j+=3 ) { - GLubyte c1 = mask[elt[j]]; - GLubyte c2 = mask[elt[j+1]]; - GLubyte c3 = mask[elt[j+2]]; - GLubyte ormask = c1|c2|c3; - if (ormask) { - if (start < j) - render_tris( ctx, start, j, 0 ); - if (!(c1&c2&c3&CLIPMASK)) - clip_tri_4( ctx, elt[j], elt[j+1], elt[j+2], ormask ); - start = j+3; - } - } - - if (start < j) - render_tris( ctx, start, j, 0 ); -} - -/**********************************************************************/ -/* Render whole begin/end objects */ -/**********************************************************************/ - -#define NEED_EDGEFLAG_SETUP (ctx->Polygon.FrontMode != GL_FILL || ctx->Polygon.BackMode != GL_FILL) -#define EDGEFLAG_GET(idx) VB->EdgeFlag[idx] -#define EDGEFLAG_SET(idx, val) VB->EdgeFlag[idx] = val - - -/* Vertices, no clipping. - */ -#define RENDER_POINTS( start, count ) \ - tnl->Driver.Render.Points( ctx, start, count ) - -#define RENDER_LINE( v1, v2 ) \ - LineFunc( ctx, v1, v2 ) - -#define RENDER_TRI( v1, v2, v3 ) \ - TriangleFunc( ctx, v1, v2, v3 ) - -#define RENDER_QUAD( v1, v2, v3, v4 ) \ - QuadFunc( ctx, v1, v2, v3, v4 ) - -#define TAG(x) _tnl_##x##_verts - -#define LOCAL_VARS \ - TNLcontext *tnl = TNL_CONTEXT(ctx); \ - struct vertex_buffer *VB = &tnl->vb; \ - const GLuint * const elt = VB->Elts; \ - const tnl_line_func LineFunc = tnl->Driver.Render.Line; \ - const tnl_triangle_func TriangleFunc = tnl->Driver.Render.Triangle; \ - const tnl_quad_func QuadFunc = tnl->Driver.Render.Quad; \ - const GLboolean stipple = ctx->Line.StippleFlag; \ - (void) (LineFunc && TriangleFunc && QuadFunc); \ - (void) elt; (void) stipple - -#define RESET_STIPPLE if (stipple) tnl->Driver.Render.ResetLineStipple( ctx ) -#define INIT(x) tnl->Driver.Render.PrimitiveNotify( ctx, x ) -#define RENDER_TAB_QUALIFIER -#define PRESERVE_VB_DEFS -#include "t_vb_rendertmp.h" - - -/* Elts, no clipping. - */ -#undef ELT -#define TAG(x) _tnl_##x##_elts -#define ELT(x) elt[x] -#include "t_vb_rendertmp.h" - - -/**********************************************************************/ -/* Helper functions for drivers */ -/**********************************************************************/ - -void _tnl_RenderClippedPolygon( struct gl_context *ctx, const GLuint *elts, GLuint n ) -{ - TNLcontext *tnl = TNL_CONTEXT(ctx); - struct vertex_buffer *VB = &tnl->vb; - GLuint *tmp = VB->Elts; - - VB->Elts = (GLuint *)elts; - tnl->Driver.Render.PrimTabElts[GL_POLYGON]( ctx, 0, n, PRIM_BEGIN|PRIM_END ); - VB->Elts = tmp; -} - -void _tnl_RenderClippedLine( struct gl_context *ctx, GLuint ii, GLuint jj ) -{ - TNLcontext *tnl = TNL_CONTEXT(ctx); - tnl->Driver.Render.Line( ctx, ii, jj ); -} - - - -/**********************************************************************/ -/* Clip and render whole vertex buffers */ -/**********************************************************************/ - - -static GLboolean run_render( struct gl_context *ctx, - struct tnl_pipeline_stage *stage ) -{ - TNLcontext *tnl = TNL_CONTEXT(ctx); - struct vertex_buffer *VB = &tnl->vb; - tnl_render_func *tab; - GLint pass = 0; - - /* Allow the drivers to lock before projected verts are built so - * that window coordinates are guarenteed not to change before - * rendering. - */ - ASSERT(tnl->Driver.Render.Start); - - tnl->Driver.Render.Start( ctx ); - - ASSERT(tnl->Driver.Render.BuildVertices); - ASSERT(tnl->Driver.Render.PrimitiveNotify); - ASSERT(tnl->Driver.Render.Points); - ASSERT(tnl->Driver.Render.Line); - ASSERT(tnl->Driver.Render.Triangle); - ASSERT(tnl->Driver.Render.Quad); - ASSERT(tnl->Driver.Render.ResetLineStipple); - ASSERT(tnl->Driver.Render.Interp); - ASSERT(tnl->Driver.Render.CopyPV); - ASSERT(tnl->Driver.Render.ClippedLine); - ASSERT(tnl->Driver.Render.ClippedPolygon); - ASSERT(tnl->Driver.Render.Finish); - - tnl->Driver.Render.BuildVertices( ctx, 0, VB->Count, ~0 ); - - if (VB->ClipOrMask) { - tab = VB->Elts ? clip_render_tab_elts : clip_render_tab_verts; - clip_render_tab_elts[GL_TRIANGLES] = clip_elt_triangles; - } - else { - tab = (VB->Elts ? - tnl->Driver.Render.PrimTabElts : - tnl->Driver.Render.PrimTabVerts); - } - - do - { - GLuint i; - - for (i = 0 ; i < VB->PrimitiveCount ; i++) - { - GLuint prim = _tnl_translate_prim(&VB->Primitive[i]); - GLuint start = VB->Primitive[i].start; - GLuint length = VB->Primitive[i].count; - - assert((prim & PRIM_MODE_MASK) <= GL_POLYGON); - - if (MESA_VERBOSE & VERBOSE_PRIMS) - _mesa_debug(NULL, "MESA prim %s %d..%d\n", - _mesa_lookup_enum_by_nr(prim & PRIM_MODE_MASK), - start, start+length); - - if (length) - tab[prim & PRIM_MODE_MASK]( ctx, start, start + length, prim ); - } - } while (tnl->Driver.Render.Multipass && - tnl->Driver.Render.Multipass( ctx, ++pass )); - - tnl->Driver.Render.Finish( ctx ); - - return GL_FALSE; /* finished the pipe */ -} - - -/**********************************************************************/ -/* Render pipeline stage */ -/**********************************************************************/ - - - - - -const struct tnl_pipeline_stage _tnl_render_stage = -{ - "render", /* name */ - NULL, /* private data */ - NULL, /* creator */ - NULL, /* destructor */ - NULL, /* validate */ - run_render /* run */ -}; diff --git a/dll/opengl/mesa/tnl/t_vb_rendertmp.h b/dll/opengl/mesa/tnl/t_vb_rendertmp.h deleted file mode 100644 index 3a1eddb2db2..00000000000 --- a/dll/opengl/mesa/tnl/t_vb_rendertmp.h +++ /dev/null @@ -1,433 +0,0 @@ -/* - * Mesa 3-D graphics library - * Version: 6.5 - * - * Copyright (C) 1999-2005 Brian Paul All Rights Reserved. - * - * Permission is hereby granted, free of charge, to any person obtaining a - * copy of this software and associated documentation files (the "Software"), - * to deal in the Software without restriction, including without limitation - * the rights to use, copy, modify, merge, publish, distribute, sublicense, - * and/or sell copies of the Software, and to permit persons to whom the - * Software is furnished to do so, subject to the following conditions: - * - * The above copyright notice and this permission notice shall be included - * in all copies or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS - * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL - * BRIAN PAUL BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN - * AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN - * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. - * - * Authors: - * Keith Whitwell - */ - - -#ifndef POSTFIX -#define POSTFIX -#endif - -#ifndef INIT -#define INIT(x) -#endif - -#ifndef NEED_EDGEFLAG_SETUP -#define NEED_EDGEFLAG_SETUP 0 -#define EDGEFLAG_GET(a) 0 -#define EDGEFLAG_SET(a,b) (void)b -#endif - -#ifndef RESET_STIPPLE -#define RESET_STIPPLE -#endif - -#ifndef TEST_PRIM_END -#define TEST_PRIM_END(prim) (flags & PRIM_END) -#define TEST_PRIM_BEGIN(prim) (flags & PRIM_BEGIN) -#endif - -#ifndef ELT -#define ELT(x) x -#endif - -#ifndef RENDER_TAB_QUALIFIER -#define RENDER_TAB_QUALIFIER static -#endif - -static void TAG(render_points)( struct gl_context *ctx, - GLuint start, - GLuint count, - GLuint flags ) -{ - LOCAL_VARS; - (void) flags; - - INIT(GL_POINTS); - RENDER_POINTS( start, count ); - POSTFIX; -} - -static void TAG(render_lines)( struct gl_context *ctx, - GLuint start, - GLuint count, - GLuint flags ) -{ - GLuint j; - LOCAL_VARS; - (void) flags; - - INIT(GL_LINES); - for (j=start+1; j - */ - -/* - * Regarding GL_NV_texgen_reflection: - * - * Portions of this software may use or implement intellectual - * property owned and licensed by NVIDIA Corporation. NVIDIA disclaims - * any and all warranties with respect to such intellectual property, - * including any use thereof or modifications thereto. - */ - -#include - -/*********************************************************************** - * Automatic texture coordinate generation (texgen) code. - */ - - -struct texgen_stage_data; - -typedef void (*texgen_func)( struct gl_context *ctx, - struct texgen_stage_data *store); - - -struct texgen_stage_data { - - /* Per-texunit derived state. - */ - GLuint TexgenSize; - texgen_func TexgenFunc; - - /* Temporary values used in texgen. - */ - GLfloat (*tmp_f)[3]; - GLfloat *tmp_m; - - /* Buffered outputs of the stage. - */ - GLvector4f texcoord; -}; - - -#define TEXGEN_STAGE_DATA(stage) ((struct texgen_stage_data *)stage->privatePtr) - - - -static GLuint all_bits[5] = { - 0, - VEC_SIZE_1, - VEC_SIZE_2, - VEC_SIZE_3, - VEC_SIZE_4, -}; - -#define VEC_SIZE_FLAGS (VEC_SIZE_1|VEC_SIZE_2|VEC_SIZE_3|VEC_SIZE_4) - -#define TEXGEN_NEED_M (TEXGEN_SPHERE_MAP) -#define TEXGEN_NEED_F (TEXGEN_SPHERE_MAP | \ - TEXGEN_REFLECTION_MAP_NV) - - - -static void build_m3( GLfloat f[][3], GLfloat m[], - const GLvector4f *normal, - const GLvector4f *eye ) -{ - GLuint stride = eye->stride; - GLfloat *coord = (GLfloat *)eye->start; - GLuint count = eye->count; - const GLfloat *norm = normal->start; - GLuint i; - - for (i=0;istride)) { - GLfloat u[3], two_nu, fx, fy, fz; - COPY_3V( u, coord ); - NORMALIZE_3FV( u ); - two_nu = 2.0F * DOT3(norm,u); - fx = f[i][0] = u[0] - norm[0] * two_nu; - fy = f[i][1] = u[1] - norm[1] * two_nu; - fz = f[i][2] = u[2] - norm[2] * two_nu; - m[i] = fx * fx + fy * fy + (fz + 1.0F) * (fz + 1.0F); - if (m[i] != 0.0F) { - m[i] = 0.5F * _mesa_inv_sqrtf(m[i]); - } - } -} - - - -static void build_m2( GLfloat f[][3], GLfloat m[], - const GLvector4f *normal, - const GLvector4f *eye ) -{ - GLuint stride = eye->stride; - GLfloat *coord = eye->start; - GLuint count = eye->count; - - GLfloat *norm = normal->start; - GLuint i; - - for (i=0;istride)) { - GLfloat u[3], two_nu, fx, fy, fz; - COPY_2V( u, coord ); - u[2] = 0; - NORMALIZE_3FV( u ); - two_nu = 2.0F * DOT3(norm,u); - fx = f[i][0] = u[0] - norm[0] * two_nu; - fy = f[i][1] = u[1] - norm[1] * two_nu; - fz = f[i][2] = u[2] - norm[2] * two_nu; - m[i] = fx * fx + fy * fy + (fz + 1.0F) * (fz + 1.0F); - if (m[i] != 0.0F) { - m[i] = 0.5F * _mesa_inv_sqrtf(m[i]); - } - } -} - - - -typedef void (*build_m_func)( GLfloat f[][3], - GLfloat m[], - const GLvector4f *normal, - const GLvector4f *eye ); - - -static build_m_func build_m_tab[5] = { - NULL, - NULL, - build_m2, - build_m3, - build_m3 -}; - - -/* This is unusual in that we respect the stride of the output vector - * (f). This allows us to pass in either a texcoord vector4f, or a - * temporary vector3f. - */ -static void build_f3( GLfloat *f, - GLuint fstride, - const GLvector4f *normal, - const GLvector4f *eye ) -{ - GLuint stride = eye->stride; - GLfloat *coord = eye->start; - GLuint count = eye->count; - - GLfloat *norm = normal->start; - GLuint i; - - for (i=0;istride); - } -} - - -static void build_f2( GLfloat *f, - GLuint fstride, - const GLvector4f *normal, - const GLvector4f *eye ) -{ - GLuint stride = eye->stride; - GLfloat *coord = eye->start; - GLuint count = eye->count; - GLfloat *norm = normal->start; - GLuint i; - - for (i=0;istride); - } -} - -typedef void (*build_f_func)( GLfloat *f, - GLuint fstride, - const GLvector4f *normal_vec, - const GLvector4f *eye ); - - - -/* Just treat 4-vectors as 3-vectors. - */ -static build_f_func build_f_tab[5] = { - NULL, - NULL, - build_f2, - build_f3, - build_f3 -}; - - - -/* Special case texgen functions. - */ -static void texgen_reflection_map_nv( struct gl_context *ctx, - struct texgen_stage_data *store) -{ - struct vertex_buffer *VB = &TNL_CONTEXT(ctx)->vb; - GLvector4f *in = VB->AttribPtr[VERT_ATTRIB_TEX]; - GLvector4f *out = &store->texcoord; - - build_f_tab[VB->EyePtr->size]( out->start, - out->stride, - VB->AttribPtr[_TNL_ATTRIB_NORMAL], - VB->EyePtr ); - - out->flags |= (in->flags & VEC_SIZE_FLAGS) | VEC_SIZE_3; - out->count = VB->Count; - out->size = MAX2(in->size, 3); - if (in->size == 4) - _mesa_copy_tab[0x8]( out, in ); -} - - - -static void texgen_normal_map_nv( struct gl_context *ctx, - struct texgen_stage_data *store) -{ - struct vertex_buffer *VB = &TNL_CONTEXT(ctx)->vb; - GLvector4f *in = VB->AttribPtr[VERT_ATTRIB_TEX]; - GLvector4f *out = &store->texcoord; - GLvector4f *normal = VB->AttribPtr[_TNL_ATTRIB_NORMAL]; - GLfloat (*texcoord)[4] = (GLfloat (*)[4])out->start; - GLuint count = VB->Count; - GLuint i; - const GLfloat *norm = normal->start; - - for (i=0;istride)) { - texcoord[i][0] = norm[0]; - texcoord[i][1] = norm[1]; - texcoord[i][2] = norm[2]; - } - - - out->flags |= (in->flags & VEC_SIZE_FLAGS) | VEC_SIZE_3; - out->count = count; - out->size = MAX2(in->size, 3); - if (in->size == 4) - _mesa_copy_tab[0x8]( out, in ); -} - - -static void texgen_sphere_map( struct gl_context *ctx, - struct texgen_stage_data *store) -{ - struct vertex_buffer *VB = &TNL_CONTEXT(ctx)->vb; - GLvector4f *in = VB->AttribPtr[VERT_ATTRIB_TEX]; - GLvector4f *out = &store->texcoord; - GLfloat (*texcoord)[4] = (GLfloat (*)[4]) out->start; - GLuint count = VB->Count; - GLuint i; - GLfloat (*f)[3] = store->tmp_f; - GLfloat *m = store->tmp_m; - - (build_m_tab[VB->EyePtr->size])( store->tmp_f, - store->tmp_m, - VB->AttribPtr[_TNL_ATTRIB_NORMAL], - VB->EyePtr ); - - out->size = MAX2(in->size,2); - - for (i=0;icount = count; - out->flags |= (in->flags & VEC_SIZE_FLAGS) | VEC_SIZE_2; - if (in->size > 2) - _mesa_copy_tab[all_bits[in->size] & ~0x3]( out, in ); -} - - - -static void texgen( struct gl_context *ctx, - struct texgen_stage_data *store) -{ - TNLcontext *tnl = TNL_CONTEXT(ctx); - struct vertex_buffer *VB = &tnl->vb; - GLvector4f *in = VB->AttribPtr[VERT_ATTRIB_TEX]; - GLvector4f *out = &store->texcoord; - const struct gl_texture_unit *texUnit = &ctx->Texture.Unit; - const GLvector4f *obj = VB->AttribPtr[_TNL_ATTRIB_POS]; - const GLvector4f *eye = VB->EyePtr; - const GLvector4f *normal = VB->AttribPtr[_TNL_ATTRIB_NORMAL]; - const GLfloat *m = store->tmp_m; - const GLuint count = VB->Count; - GLfloat (*texcoord)[4] = (GLfloat (*)[4])out->data; - GLfloat (*f)[3] = store->tmp_f; - GLuint copy; - - if (texUnit->_GenFlags & TEXGEN_NEED_M) { - build_m_tab[eye->size]( store->tmp_f, store->tmp_m, normal, eye ); - } else if (texUnit->_GenFlags & TEXGEN_NEED_F) { - build_f_tab[eye->size]( (GLfloat *)store->tmp_f, 3, normal, eye ); - } - - - out->size = MAX2(in->size, store->TexgenSize); - out->flags |= (in->flags & VEC_SIZE_FLAGS) | texUnit->TexGenEnabled; - out->count = count; - - copy = (all_bits[in->size] & ~texUnit->TexGenEnabled); - if (copy) - _mesa_copy_tab[copy]( out, in ); - - if (texUnit->TexGenEnabled & S_BIT) { - GLuint i; - switch (texUnit->GenS.Mode) { - case GL_OBJECT_LINEAR: - _mesa_dotprod_tab[obj->size]( (GLfloat *)out->data, - sizeof(out->data[0]), obj, - texUnit->GenS.ObjectPlane ); - break; - case GL_EYE_LINEAR: - _mesa_dotprod_tab[eye->size]( (GLfloat *)out->data, - sizeof(out->data[0]), eye, - texUnit->GenS.EyePlane ); - break; - case GL_SPHERE_MAP: - for (i = 0; i < count; i++) - texcoord[i][0] = f[i][0] * m[i] + 0.5F; - break; - case GL_REFLECTION_MAP_NV: - for (i=0;istart; - for (i=0;istride)) { - texcoord[i][0] = norm[0]; - } - break; - } - default: - _mesa_problem(ctx, "Bad S texgen"); - } - } - - if (texUnit->TexGenEnabled & T_BIT) { - GLuint i; - switch (texUnit->GenT.Mode) { - case GL_OBJECT_LINEAR: - _mesa_dotprod_tab[obj->size]( &(out->data[0][1]), - sizeof(out->data[0]), obj, - texUnit->GenT.ObjectPlane ); - break; - case GL_EYE_LINEAR: - _mesa_dotprod_tab[eye->size]( &(out->data[0][1]), - sizeof(out->data[0]), eye, - texUnit->GenT.EyePlane ); - break; - case GL_SPHERE_MAP: - for (i = 0; i < count; i++) - texcoord[i][1] = f[i][1] * m[i] + 0.5F; - break; - case GL_REFLECTION_MAP_NV: - for (i=0;istart; - for (i=0;istride)) { - texcoord[i][1] = norm[1]; - } - break; - } - default: - _mesa_problem(ctx, "Bad T texgen"); - } - } - - if (texUnit->TexGenEnabled & R_BIT) { - GLuint i; - switch (texUnit->GenR.Mode) { - case GL_OBJECT_LINEAR: - _mesa_dotprod_tab[obj->size]( &(out->data[0][2]), - sizeof(out->data[0]), obj, - texUnit->GenR.ObjectPlane ); - break; - case GL_EYE_LINEAR: - _mesa_dotprod_tab[eye->size]( &(out->data[0][2]), - sizeof(out->data[0]), eye, - texUnit->GenR.EyePlane ); - break; - case GL_REFLECTION_MAP_NV: - for (i=0;istart; - for (i=0;istride)) { - texcoord[i][2] = norm[2]; - } - break; - } - default: - _mesa_problem(ctx, "Bad R texgen"); - } - } - - if (texUnit->TexGenEnabled & Q_BIT) { - switch (texUnit->GenQ.Mode) { - case GL_OBJECT_LINEAR: - _mesa_dotprod_tab[obj->size]( &(out->data[0][3]), - sizeof(out->data[0]), obj, - texUnit->GenQ.ObjectPlane ); - break; - case GL_EYE_LINEAR: - _mesa_dotprod_tab[eye->size]( &(out->data[0][3]), - sizeof(out->data[0]), eye, - texUnit->GenQ.EyePlane ); - break; - default: - _mesa_problem(ctx, "Bad Q texgen"); - } - } -} - - - - -static GLboolean run_texgen_stage( struct gl_context *ctx, - struct tnl_pipeline_stage *stage ) -{ - struct vertex_buffer *VB = &TNL_CONTEXT(ctx)->vb; - struct texgen_stage_data *store = TEXGEN_STAGE_DATA(stage); - - if (!ctx->Texture._TexGenEnabled) - return GL_TRUE; - - { - struct gl_texture_unit *texUnit = &ctx->Texture.Unit; - - if (texUnit->TexGenEnabled) { - - store->TexgenFunc( ctx, store); - - VB->AttribPtr[VERT_ATTRIB_TEX] = &store->texcoord; - } - } - - return GL_TRUE; -} - - -static void validate_texgen_stage( struct gl_context *ctx, - struct tnl_pipeline_stage *stage ) -{ - struct texgen_stage_data *store = TEXGEN_STAGE_DATA(stage); - - if (!ctx->Texture._TexGenEnabled) - return; - - { - struct gl_texture_unit *texUnit = &ctx->Texture.Unit; - - if (texUnit->TexGenEnabled) { - GLuint sz; - - if (texUnit->TexGenEnabled & Q_BIT) - sz = 4; - else if (texUnit->TexGenEnabled & R_BIT) - sz = 3; - else if (texUnit->TexGenEnabled & T_BIT) - sz = 2; - else - sz = 1; - - store->TexgenSize = sz; - store->TexgenFunc = texgen; /* general solution */ - - /* look for special texgen cases */ - if (texUnit->TexGenEnabled == (S_BIT|T_BIT|R_BIT)) { - if (texUnit->_GenFlags == TEXGEN_REFLECTION_MAP_NV) { - store->TexgenFunc = texgen_reflection_map_nv; - } - else if (texUnit->_GenFlags == TEXGEN_NORMAL_MAP_NV) { - store->TexgenFunc = texgen_normal_map_nv; - } - } - else if (texUnit->TexGenEnabled == (S_BIT|T_BIT) && - texUnit->_GenFlags == TEXGEN_SPHERE_MAP) { - store->TexgenFunc = texgen_sphere_map; - } - } - } -} - - - - - -/* Called the first time stage->run() is invoked. - */ -static GLboolean alloc_texgen_data( struct gl_context *ctx, - struct tnl_pipeline_stage *stage ) -{ - struct vertex_buffer *VB = &TNL_CONTEXT(ctx)->vb; - struct texgen_stage_data *store; - - stage->privatePtr = CALLOC(sizeof(*store)); - store = TEXGEN_STAGE_DATA(stage); - if (!store) - return GL_FALSE; - - _mesa_vector4f_alloc( &store->texcoord, 0, VB->Size, 32 ); - - store->tmp_f = (GLfloat (*)[3]) MALLOC(VB->Size * sizeof(GLfloat) * 3); - store->tmp_m = (GLfloat *) MALLOC(VB->Size * sizeof(GLfloat)); - - return GL_TRUE; -} - - -static void free_texgen_data( struct tnl_pipeline_stage *stage ) - -{ - struct texgen_stage_data *store = TEXGEN_STAGE_DATA(stage); - - if (store) { - if (store->texcoord.data) - _mesa_vector4f_free( &store->texcoord ); - - - if (store->tmp_f) FREE( store->tmp_f ); - if (store->tmp_m) FREE( store->tmp_m ); - FREE( store ); - stage->privatePtr = NULL; - } -} - - - -const struct tnl_pipeline_stage _tnl_texgen_stage = -{ - "texgen", /* name */ - NULL, /* private data */ - alloc_texgen_data, /* destructor */ - free_texgen_data, /* destructor */ - validate_texgen_stage, /* check */ - run_texgen_stage /* run -- initially set to alloc data */ -}; diff --git a/dll/opengl/mesa/tnl/t_vb_texmat.c b/dll/opengl/mesa/tnl/t_vb_texmat.c deleted file mode 100644 index c6f15c6eafa..00000000000 --- a/dll/opengl/mesa/tnl/t_vb_texmat.c +++ /dev/null @@ -1,111 +0,0 @@ -/* - * Mesa 3-D graphics library - * Version: 6.5 - * - * Copyright (C) 1999-2006 Brian Paul All Rights Reserved. - * - * Permission is hereby granted, free of charge, to any person obtaining a - * copy of this software and associated documentation files (the "Software"), - * to deal in the Software without restriction, including without limitation - * the rights to use, copy, modify, merge, publish, distribute, sublicense, - * and/or sell copies of the Software, and to permit persons to whom the - * Software is furnished to do so, subject to the following conditions: - * - * The above copyright notice and this permission notice shall be included - * in all copies or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS - * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL - * BRIAN PAUL BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN - * AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN - * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. - * - * Authors: - * Keith Whitwell - */ - -#include - -/* Is there any real benefit seperating texmat from texgen? It means - * we need two lots of intermediate storage. Any changes to - * _NEW_TEXTURE will invalidate both sets -- it's only on changes to - * *only* _NEW_TEXTURE_MATRIX that texgen survives but texmat doesn't. - * - * However, the seperation of this code from the complex texgen stuff - * is very appealing. - */ -struct texmat_stage_data { - GLvector4f texcoord; -}; - -#define TEXMAT_STAGE_DATA(stage) ((struct texmat_stage_data *)stage->privatePtr) - - - -static GLboolean run_texmat_stage( struct gl_context *ctx, - struct tnl_pipeline_stage *stage ) -{ - struct texmat_stage_data *store = TEXMAT_STAGE_DATA(stage); - struct vertex_buffer *VB = &TNL_CONTEXT(ctx)->vb; - - if (!ctx->Texture._TexMatEnabled) - return GL_TRUE; - - /* ENABLE_TEXMAT implies that the texture matrix is not the - * identity, so we don't have to check that here. - */ - if (ctx->Texture._TexMatEnabled) { - (void) TransformRaw( &store->texcoord, - ctx->TextureMatrixStack.Top, - VB->AttribPtr[_TNL_ATTRIB_TEX]); - - VB->AttribPtr[VERT_ATTRIB_TEX] = &store->texcoord; - } - - return GL_TRUE; -} - - -/* Called the first time stage->run() is invoked. - */ -static GLboolean alloc_texmat_data( struct gl_context *ctx, - struct tnl_pipeline_stage *stage ) -{ - struct vertex_buffer *VB = &TNL_CONTEXT(ctx)->vb; - struct texmat_stage_data *store; - - stage->privatePtr = CALLOC(sizeof(*store)); - store = TEXMAT_STAGE_DATA(stage); - if (!store) - return GL_FALSE; - - _mesa_vector4f_alloc( &store->texcoord, 0, VB->Size, 32 ); - - return GL_TRUE; -} - - -static void free_texmat_data( struct tnl_pipeline_stage *stage ) -{ - struct texmat_stage_data *store = TEXMAT_STAGE_DATA(stage); - - if (store) { - if (store->texcoord.data) - _mesa_vector4f_free( &store->texcoord ); - FREE( store ); - stage->privatePtr = NULL; - } -} - - - -const struct tnl_pipeline_stage _tnl_texture_transform_stage = -{ - "texture transform", /* name */ - NULL, /* private data */ - alloc_texmat_data, - free_texmat_data, /* destructor */ - NULL, - run_texmat_stage, -}; diff --git a/dll/opengl/mesa/tnl/t_vb_vertex.c b/dll/opengl/mesa/tnl/t_vb_vertex.c deleted file mode 100644 index 14763c2bf17..00000000000 --- a/dll/opengl/mesa/tnl/t_vb_vertex.c +++ /dev/null @@ -1,248 +0,0 @@ -/* - * Mesa 3-D graphics library - * Version: 6.5 - * - * Copyright (C) 1999-2006 Brian Paul All Rights Reserved. - * - * Permission is hereby granted, free of charge, to any person obtaining a - * copy of this software and associated documentation files (the "Software"), - * to deal in the Software without restriction, including without limitation - * the rights to use, copy, modify, merge, publish, distribute, sublicense, - * and/or sell copies of the Software, and to permit persons to whom the - * Software is furnished to do so, subject to the following conditions: - * - * The above copyright notice and this permission notice shall be included - * in all copies or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS - * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL - * BRIAN PAUL BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN - * AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN - * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. - * - * Authors: - * Keith Whitwell - */ - -#include - -struct vertex_stage_data { - GLvector4f eye; - GLvector4f clip; - GLvector4f proj; - GLubyte *clipmask; - GLubyte ormask; - GLubyte andmask; -}; - -#define VERTEX_STAGE_DATA(stage) ((struct vertex_stage_data *)stage->privatePtr) - - - - -/* This function implements cliptesting for user-defined clip planes. - * The clipping of primitives to these planes is implemented in - * t_render_clip.h. - */ -#define USER_CLIPTEST(NAME, SZ) \ -static void NAME( struct gl_context *ctx, \ - GLvector4f *clip, \ - GLubyte *clipmask, \ - GLubyte *clipormask, \ - GLubyte *clipandmask ) \ -{ \ - GLuint p; \ - \ - for (p = 0; p < ctx->Const.MaxClipPlanes; p++) \ - if (ctx->Transform.ClipPlanesEnabled & (1 << p)) { \ - GLuint nr, i; \ - const GLfloat a = ctx->Transform._ClipUserPlane[p][0]; \ - const GLfloat b = ctx->Transform._ClipUserPlane[p][1]; \ - const GLfloat c = ctx->Transform._ClipUserPlane[p][2]; \ - const GLfloat d = ctx->Transform._ClipUserPlane[p][3]; \ - GLfloat *coord = (GLfloat *)clip->data; \ - GLuint stride = clip->stride; \ - GLuint count = clip->count; \ - \ - for (nr = 0, i = 0 ; i < count ; i++) { \ - GLfloat dp = coord[0] * a + coord[1] * b; \ - if (SZ > 2) dp += coord[2] * c; \ - if (SZ > 3) dp += coord[3] * d; else dp += d; \ - \ - if (dp < 0) { \ - nr++; \ - clipmask[i] |= CLIP_USER_BIT; \ - } \ - \ - STRIDE_F(coord, stride); \ - } \ - \ - if (nr > 0) { \ - *clipormask |= CLIP_USER_BIT; \ - if (nr == count) { \ - *clipandmask |= CLIP_USER_BIT; \ - return; \ - } \ - } \ - } \ -} - - -USER_CLIPTEST(userclip2, 2) -USER_CLIPTEST(userclip3, 3) -USER_CLIPTEST(userclip4, 4) - -static void (*(usercliptab[5]))( struct gl_context *, - GLvector4f *, GLubyte *, - GLubyte *, GLubyte * ) = -{ - NULL, - NULL, - userclip2, - userclip3, - userclip4 -}; - - - -static GLboolean run_vertex_stage( struct gl_context *ctx, - struct tnl_pipeline_stage *stage ) -{ - struct vertex_stage_data *store = (struct vertex_stage_data *)stage->privatePtr; - TNLcontext *tnl = TNL_CONTEXT(ctx); - struct vertex_buffer *VB = &tnl->vb; - - if (ctx->_NeedEyeCoords) { - /* Separate modelview transformation: - * Use combined ModelProject to avoid some depth artifacts - */ - if (ctx->ModelviewMatrixStack.Top->type == MATRIX_IDENTITY) - VB->EyePtr = VB->AttribPtr[_TNL_ATTRIB_POS]; - else - VB->EyePtr = TransformRaw( &store->eye, - ctx->ModelviewMatrixStack.Top, - VB->AttribPtr[_TNL_ATTRIB_POS]); - } - - VB->ClipPtr = TransformRaw( &store->clip, - &ctx->_ModelProjectMatrix, - VB->AttribPtr[_TNL_ATTRIB_POS] ); - - /* Drivers expect this to be clean to element 4... - */ - switch (VB->ClipPtr->size) { - case 1: - /* impossible */ - case 2: - _mesa_vector4f_clean_elem( VB->ClipPtr, VB->Count, 2 ); - /* fall-through */ - case 3: - _mesa_vector4f_clean_elem( VB->ClipPtr, VB->Count, 3 ); - /* fall-through */ - case 4: - break; - } - - - /* Cliptest and perspective divide. Clip functions must clear - * the clipmask. - */ - store->ormask = 0; - store->andmask = CLIP_FRUSTUM_BITS; - - if (tnl->NeedNdcCoords) { - VB->NdcPtr = - _mesa_clip_tab[VB->ClipPtr->size]( VB->ClipPtr, - &store->proj, - store->clipmask, - &store->ormask, - &store->andmask); - } - else { - VB->NdcPtr = NULL; - _mesa_clip_np_tab[VB->ClipPtr->size]( VB->ClipPtr, - NULL, - store->clipmask, - &store->ormask, - &store->andmask ); - } - - if (store->andmask) - return GL_FALSE; - - - /* Test userclip planes. This contributes to VB->ClipMask, so - * is essentially required to be in this stage. - */ - if (ctx->Transform.ClipPlanesEnabled) { - usercliptab[VB->ClipPtr->size]( ctx, - VB->ClipPtr, - store->clipmask, - &store->ormask, - &store->andmask ); - - if (store->andmask) - return GL_FALSE; - } - - VB->ClipAndMask = store->andmask; - VB->ClipOrMask = store->ormask; - VB->ClipMask = store->clipmask; - - return GL_TRUE; -} - - -static GLboolean init_vertex_stage( struct gl_context *ctx, - struct tnl_pipeline_stage *stage ) -{ - struct vertex_buffer *VB = &TNL_CONTEXT(ctx)->vb; - struct vertex_stage_data *store; - GLuint size = VB->Size; - - stage->privatePtr = CALLOC(sizeof(*store)); - store = VERTEX_STAGE_DATA(stage); - if (!store) - return GL_FALSE; - - _mesa_vector4f_alloc( &store->eye, 0, size, 32 ); - _mesa_vector4f_alloc( &store->clip, 0, size, 32 ); - _mesa_vector4f_alloc( &store->proj, 0, size, 32 ); - - store->clipmask = (GLubyte *) _mesa_align_malloc(sizeof(GLubyte)*size, 32 ); - - if (!store->clipmask || - !store->eye.data || - !store->clip.data || - !store->proj.data) - return GL_FALSE; - - return GL_TRUE; -} - -static void dtr( struct tnl_pipeline_stage *stage ) -{ - struct vertex_stage_data *store = VERTEX_STAGE_DATA(stage); - - if (store) { - _mesa_vector4f_free( &store->eye ); - _mesa_vector4f_free( &store->clip ); - _mesa_vector4f_free( &store->proj ); - _mesa_align_free( store->clipmask ); - FREE(store); - stage->privatePtr = NULL; - stage->run = init_vertex_stage; - } -} - - -const struct tnl_pipeline_stage _tnl_vertex_transform_stage = -{ - "modelview/project/cliptest/divide", - NULL, /* private data */ - init_vertex_stage, - dtr, /* destructor */ - NULL, - run_vertex_stage /* run -- initially set to init */ -}; diff --git a/dll/opengl/mesa/tnl/t_vertex.c b/dll/opengl/mesa/tnl/t_vertex.c deleted file mode 100644 index 039c18a4365..00000000000 --- a/dll/opengl/mesa/tnl/t_vertex.c +++ /dev/null @@ -1,559 +0,0 @@ -/* - * Copyright 2003 Tungsten Graphics, 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 - * on the rights to use, copy, modify, merge, publish, distribute, sub - * license, and/or sell copies of the Software, and to permit persons to whom - * the Software is furnished to do so, subject to the following conditions: - * - * The above copyright notice and this permission notice (including the next - * paragraph) shall be included in all copies or substantial portions of the - * Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR - * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT. IN NO EVENT SHALL - * TUNGSTEN GRAPHICS AND/OR THEIR SUPPLIERS BE LIABLE FOR ANY CLAIM, - * DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR - * OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE - * USE OR OTHER DEALINGS IN THE SOFTWARE. - * - * Authors: - * Keith Whitwell - */ - -#include - -#define DBG 0 - -/* Build and manage clipspace/ndc/window vertices. - */ - -static GLboolean match_fastpath( struct tnl_clipspace *vtx, - const struct tnl_clipspace_fastpath *fp) -{ - GLuint j; - - if (vtx->attr_count != fp->attr_count) - return GL_FALSE; - - for (j = 0; j < vtx->attr_count; j++) - if (vtx->attr[j].format != fp->attr[j].format || - vtx->attr[j].inputsize != fp->attr[j].size || - vtx->attr[j].vertoffset != fp->attr[j].offset) - return GL_FALSE; - - if (fp->match_strides) { - if (vtx->vertex_size != fp->vertex_size) - return GL_FALSE; - - for (j = 0; j < vtx->attr_count; j++) - if (vtx->attr[j].inputstride != fp->attr[j].stride) - return GL_FALSE; - } - - return GL_TRUE; -} - -static GLboolean search_fastpath_emit( struct tnl_clipspace *vtx ) -{ - struct tnl_clipspace_fastpath *fp = vtx->fastpath; - - for ( ; fp ; fp = fp->next) { - if (match_fastpath(vtx, fp)) { - vtx->emit = fp->func; - return GL_TRUE; - } - } - - return GL_FALSE; -} - -void _tnl_register_fastpath( struct tnl_clipspace *vtx, - GLboolean match_strides ) -{ - struct tnl_clipspace_fastpath *fastpath = CALLOC_STRUCT(tnl_clipspace_fastpath); - GLuint i; - - fastpath->vertex_size = vtx->vertex_size; - fastpath->attr_count = vtx->attr_count; - fastpath->match_strides = match_strides; - fastpath->func = vtx->emit; - fastpath->attr = (struct tnl_attr_type *) - malloc(vtx->attr_count * sizeof(fastpath->attr[0])); - - for (i = 0; i < vtx->attr_count; i++) { - fastpath->attr[i].format = vtx->attr[i].format; - fastpath->attr[i].stride = vtx->attr[i].inputstride; - fastpath->attr[i].size = vtx->attr[i].inputsize; - fastpath->attr[i].offset = vtx->attr[i].vertoffset; - } - - fastpath->next = vtx->fastpath; - vtx->fastpath = fastpath; -} - - - -/*********************************************************************** - * Build codegen functions or return generic ones: - */ -static void choose_emit_func( struct gl_context *ctx, GLuint count, GLubyte *dest) -{ - struct vertex_buffer *VB = &TNL_CONTEXT(ctx)->vb; - struct tnl_clipspace *vtx = GET_VERTEX_STATE(ctx); - struct tnl_clipspace_attr *a = vtx->attr; - const GLuint attr_count = vtx->attr_count; - GLuint j; - - for (j = 0; j < attr_count; j++) { - GLvector4f *vptr = VB->AttribPtr[a[j].attrib]; - a[j].inputstride = vptr->stride; - a[j].inputsize = vptr->size; - a[j].emit = a[j].insert[vptr->size - 1]; /* not always used */ - } - - vtx->emit = NULL; - - /* Does this match an existing (hardwired, codegen or known-bad) - * fastpath? - */ - if (search_fastpath_emit(vtx)) { - /* Use this result. If it is null, then it is already known - * that the current state will fail for codegen and there is no - * point trying again. - */ - } - else if (vtx->codegen_emit) { - vtx->codegen_emit(ctx); - } - - if (!vtx->emit) { - _tnl_generate_hardwired_emit(ctx); - } - - /* Otherwise use the generic version: - */ - if (!vtx->emit) - vtx->emit = _tnl_generic_emit; - - vtx->emit( ctx, count, dest ); -} - - - -static void choose_interp_func( struct gl_context *ctx, - GLfloat t, - GLuint edst, GLuint eout, GLuint ein, - GLboolean force_boundary ) -{ - struct tnl_clipspace *vtx = GET_VERTEX_STATE(ctx); - - if (vtx->need_extras && - (ctx->_TriangleCaps & (DD_TRI_LIGHT_TWOSIDE|DD_TRI_UNFILLED))) { - vtx->interp = _tnl_generic_interp_extras; - } else { - vtx->interp = _tnl_generic_interp; - } - - vtx->interp( ctx, t, edst, eout, ein, force_boundary ); -} - - -static void choose_copy_pv_func( struct gl_context *ctx, GLuint edst, GLuint esrc ) -{ - struct tnl_clipspace *vtx = GET_VERTEX_STATE(ctx); - - if (vtx->need_extras && - (ctx->_TriangleCaps & (DD_TRI_LIGHT_TWOSIDE|DD_TRI_UNFILLED))) { - vtx->copy_pv = _tnl_generic_copy_pv_extras; - } else { - vtx->copy_pv = _tnl_generic_copy_pv; - } - - vtx->copy_pv( ctx, edst, esrc ); -} - - -/*********************************************************************** - * Public entrypoints, mostly dispatch to the above: - */ - - -/* Interpolate between two vertices to produce a third: - */ -void _tnl_interp( struct gl_context *ctx, - GLfloat t, - GLuint edst, GLuint eout, GLuint ein, - GLboolean force_boundary ) -{ - struct tnl_clipspace *vtx = GET_VERTEX_STATE(ctx); - vtx->interp( ctx, t, edst, eout, ein, force_boundary ); -} - -/* Copy colors from one vertex to another: - */ -void _tnl_copy_pv( struct gl_context *ctx, GLuint edst, GLuint esrc ) -{ - struct tnl_clipspace *vtx = GET_VERTEX_STATE(ctx); - vtx->copy_pv( ctx, edst, esrc ); -} - - -/* Extract a named attribute from a hardware vertex. Will have to - * reverse any viewport transformation, swizzling or other conversions - * which may have been applied: - */ -void _tnl_get_attr( struct gl_context *ctx, const void *vin, - GLenum attr, GLfloat *dest ) -{ - struct tnl_clipspace *vtx = GET_VERTEX_STATE(ctx); - const struct tnl_clipspace_attr *a = vtx->attr; - const GLuint attr_count = vtx->attr_count; - GLuint j; - - for (j = 0; j < attr_count; j++) { - if (a[j].attrib == attr) { - a[j].extract( &a[j], dest, (GLubyte *)vin + a[j].vertoffset ); - return; - } - } - - /* Else return the value from ctx->Current. - */ - if (attr == _TNL_ATTRIB_POINTSIZE) { - /* If the hardware vertex doesn't have point size then use size from - * struct gl_context. XXX this will be wrong if drawing attenuated points! - */ - dest[0] = ctx->Point.Size; - } - else { - memcpy( dest, ctx->Current.Attrib[attr], 4*sizeof(GLfloat)); - } -} - - -/* Complementary operation to the above. - */ -void _tnl_set_attr( struct gl_context *ctx, void *vout, - GLenum attr, const GLfloat *src ) -{ - struct tnl_clipspace *vtx = GET_VERTEX_STATE(ctx); - const struct tnl_clipspace_attr *a = vtx->attr; - const GLuint attr_count = vtx->attr_count; - GLuint j; - - for (j = 0; j < attr_count; j++) { - if (a[j].attrib == attr) { - a[j].insert[4-1]( &a[j], (GLubyte *)vout + a[j].vertoffset, src ); - return; - } - } -} - - -void *_tnl_get_vertex( struct gl_context *ctx, GLuint nr ) -{ - struct tnl_clipspace *vtx = GET_VERTEX_STATE(ctx); - - return vtx->vertex_buf + nr * vtx->vertex_size; -} - -void _tnl_invalidate_vertex_state( struct gl_context *ctx, GLuint new_state ) -{ - if (new_state & (_DD_NEW_TRI_LIGHT_TWOSIDE|_DD_NEW_TRI_UNFILLED) ) { - struct tnl_clipspace *vtx = GET_VERTEX_STATE(ctx); - vtx->new_inputs = ~0; - vtx->interp = choose_interp_func; - vtx->copy_pv = choose_copy_pv_func; - } -} - -static void invalidate_funcs( struct tnl_clipspace *vtx ) -{ - vtx->emit = choose_emit_func; - vtx->interp = choose_interp_func; - vtx->copy_pv = choose_copy_pv_func; - vtx->new_inputs = ~0; -} - -GLuint _tnl_install_attrs( struct gl_context *ctx, const struct tnl_attr_map *map, - GLuint nr, const GLfloat *vp, - GLuint unpacked_size ) -{ - struct tnl_clipspace *vtx = GET_VERTEX_STATE(ctx); - GLuint offset = 0; - GLuint i, j; - - assert(nr < _TNL_ATTRIB_MAX); - assert(nr == 0 || map[0].attrib == VERT_ATTRIB_POS); - - vtx->new_inputs = ~0; - vtx->need_viewport = GL_FALSE; - - if (vp) { - vtx->need_viewport = GL_TRUE; - } - - for (j = 0, i = 0; i < nr; i++) { - const GLuint format = map[i].format; - if (format == EMIT_PAD) { - if (DBG) - printf("%d: pad %d, offset %d\n", i, - map[i].offset, offset); - - offset += map[i].offset; - - } - else { - GLuint tmpoffset; - - if (unpacked_size) - tmpoffset = map[i].offset; - else - tmpoffset = offset; - - if (vtx->attr_count != j || - vtx->attr[j].attrib != map[i].attrib || - vtx->attr[j].format != format || - vtx->attr[j].vertoffset != tmpoffset) { - invalidate_funcs(vtx); - - vtx->attr[j].attrib = map[i].attrib; - vtx->attr[j].format = format; - vtx->attr[j].vp = vp; - vtx->attr[j].insert = _tnl_format_info[format].insert; - vtx->attr[j].extract = _tnl_format_info[format].extract; - vtx->attr[j].vertattrsize = _tnl_format_info[format].attrsize; - vtx->attr[j].vertoffset = tmpoffset; - } - - - if (DBG) - printf("%d: %s, vp %p, offset %d\n", i, - _tnl_format_info[format].name, (void *)vp, - vtx->attr[j].vertoffset); - - offset += _tnl_format_info[format].attrsize; - j++; - } - } - - vtx->attr_count = j; - - if (unpacked_size) - vtx->vertex_size = unpacked_size; - else - vtx->vertex_size = offset; - - assert(vtx->vertex_size <= vtx->max_vertex_size); - return vtx->vertex_size; -} - - - -void _tnl_invalidate_vertices( struct gl_context *ctx, GLuint newinputs ) -{ - struct tnl_clipspace *vtx = GET_VERTEX_STATE(ctx); - vtx->new_inputs |= newinputs; -} - - -/* This event has broader use beyond this file - will move elsewhere - * and probably invoke a driver callback. - */ -void _tnl_notify_pipeline_output_change( struct gl_context *ctx ) -{ - struct tnl_clipspace *vtx = GET_VERTEX_STATE(ctx); - invalidate_funcs(vtx); -} - - -static void adjust_input_ptrs( struct gl_context *ctx, GLint diff) -{ - struct vertex_buffer *VB = &TNL_CONTEXT(ctx)->vb; - struct tnl_clipspace *vtx = GET_VERTEX_STATE(ctx); - struct tnl_clipspace_attr *a = vtx->attr; - const GLuint count = vtx->attr_count; - GLuint j; - - diff -= 1; - for (j=0; jAttribPtr[a->attrib]; - (a++)->inputptr += diff*vptr->stride; - } -} - -static void update_input_ptrs( struct gl_context *ctx, GLuint start ) -{ - struct vertex_buffer *VB = &TNL_CONTEXT(ctx)->vb; - struct tnl_clipspace *vtx = GET_VERTEX_STATE(ctx); - struct tnl_clipspace_attr *a = vtx->attr; - const GLuint count = vtx->attr_count; - GLuint j; - - for (j = 0; j < count; j++) { - GLvector4f *vptr = VB->AttribPtr[a[j].attrib]; - - if (vtx->emit != choose_emit_func) { - assert(a[j].inputstride == vptr->stride); - assert(a[j].inputsize == vptr->size); - } - - a[j].inputptr = ((GLubyte *)vptr->data) + start * vptr->stride; - } - - if (a->vp) { - vtx->vp_scale[0] = a->vp[MAT_SX]; - vtx->vp_scale[1] = a->vp[MAT_SY]; - vtx->vp_scale[2] = a->vp[MAT_SZ]; - vtx->vp_scale[3] = 1.0; - vtx->vp_xlate[0] = a->vp[MAT_TX]; - vtx->vp_xlate[1] = a->vp[MAT_TY]; - vtx->vp_xlate[2] = a->vp[MAT_TZ]; - vtx->vp_xlate[3] = 0.0; - } -} - - -void _tnl_build_vertices( struct gl_context *ctx, - GLuint start, - GLuint end, - GLuint newinputs ) -{ - struct tnl_clipspace *vtx = GET_VERTEX_STATE(ctx); - update_input_ptrs( ctx, start ); - vtx->emit( ctx, end - start, - (GLubyte *)(vtx->vertex_buf + - start * vtx->vertex_size)); -} - -/* Emit VB vertices start..end to dest. Note that VB vertex at - * position start will be emitted to dest at position zero. - */ -void *_tnl_emit_vertices_to_buffer( struct gl_context *ctx, - GLuint start, - GLuint end, - void *dest ) -{ - struct tnl_clipspace *vtx = GET_VERTEX_STATE(ctx); - - update_input_ptrs(ctx, start); - /* Note: dest should not be adjusted for non-zero 'start' values: - */ - vtx->emit( ctx, end - start, (GLubyte*) dest ); - return (void *)((GLubyte *)dest + vtx->vertex_size * (end - start)); -} - -/* Emit indexed VB vertices start..end to dest. Note that VB vertex at - * position start will be emitted to dest at position zero. - */ - -void *_tnl_emit_indexed_vertices_to_buffer( struct gl_context *ctx, - const GLuint *elts, - GLuint start, - GLuint end, - void *dest ) -{ - struct tnl_clipspace *vtx = GET_VERTEX_STATE(ctx); - GLuint oldIndex; - GLubyte *cdest = dest; - - update_input_ptrs(ctx, oldIndex = elts[start++]); - vtx->emit( ctx, 1, cdest ); - cdest += vtx->vertex_size; - - for (; start < end; ++start) { - adjust_input_ptrs(ctx, elts[start] - oldIndex); - oldIndex = elts[start]; - vtx->emit( ctx, 1, cdest); - cdest += vtx->vertex_size; - } - - return (void *) cdest; -} - - -void _tnl_init_vertices( struct gl_context *ctx, - GLuint vb_size, - GLuint max_vertex_size ) -{ - struct tnl_clipspace *vtx = GET_VERTEX_STATE(ctx); - - _tnl_install_attrs( ctx, NULL, 0, NULL, 0 ); - - vtx->need_extras = GL_TRUE; - if (max_vertex_size > vtx->max_vertex_size) { - _tnl_free_vertices( ctx ); - vtx->max_vertex_size = max_vertex_size; - vtx->vertex_buf = (GLubyte *)_mesa_align_calloc(vb_size * max_vertex_size, 32 ); - invalidate_funcs(vtx); - } - - switch(CHAN_TYPE) { - case GL_UNSIGNED_BYTE: - vtx->chan_scale[0] = 255.0; - vtx->chan_scale[1] = 255.0; - vtx->chan_scale[2] = 255.0; - vtx->chan_scale[3] = 255.0; - break; - case GL_UNSIGNED_SHORT: - vtx->chan_scale[0] = 65535.0; - vtx->chan_scale[1] = 65535.0; - vtx->chan_scale[2] = 65535.0; - vtx->chan_scale[3] = 65535.0; - break; - default: - vtx->chan_scale[0] = 1.0; - vtx->chan_scale[1] = 1.0; - vtx->chan_scale[2] = 1.0; - vtx->chan_scale[3] = 1.0; - break; - } - - vtx->identity[0] = 0.0; - vtx->identity[1] = 0.0; - vtx->identity[2] = 0.0; - vtx->identity[3] = 1.0; - - vtx->codegen_emit = NULL; - -#ifdef USE_SSE_ASM - if (!_mesa_getenv("MESA_NO_CODEGEN")) - vtx->codegen_emit = _tnl_generate_sse_emit; -#endif -} - - -void _tnl_free_vertices( struct gl_context *ctx ) -{ - TNLcontext *tnl = TNL_CONTEXT(ctx); - if (tnl) { - struct tnl_clipspace *vtx = GET_VERTEX_STATE(ctx); - struct tnl_clipspace_fastpath *fp, *tmp; - - if (vtx->vertex_buf) { - _mesa_align_free(vtx->vertex_buf); - vtx->vertex_buf = NULL; - } - - for (fp = vtx->fastpath ; fp ; fp = tmp) { - tmp = fp->next; - FREE(fp->attr); - - /* KW: At the moment, fp->func is constrained to be allocated by - * _mesa_exec_alloc(), as the hardwired fastpaths in - * t_vertex_generic.c are handled specially. It would be nice - * to unify them, but this probably won't change until this - * module gets another overhaul. - */ - _mesa_exec_free((void *) fp->func); - FREE(fp); - } - - vtx->fastpath = NULL; - } -} diff --git a/dll/opengl/mesa/tnl/t_vertex.h b/dll/opengl/mesa/tnl/t_vertex.h deleted file mode 100644 index 83b0dbcebbd..00000000000 --- a/dll/opengl/mesa/tnl/t_vertex.h +++ /dev/null @@ -1,184 +0,0 @@ -/* - * Copyright 2003 Tungsten Graphics, 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 - * on the rights to use, copy, modify, merge, publish, distribute, sub - * license, and/or sell copies of the Software, and to permit persons to whom - * the Software is furnished to do so, subject to the following conditions: - * - * The above copyright notice and this permission notice (including the next - * paragraph) shall be included in all copies or substantial portions of the - * Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR - * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT. IN NO EVENT SHALL - * TUNGSTEN GRAPHICS AND/OR THEIR SUPPLIERS BE LIABLE FOR ANY CLAIM, - * DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR - * OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE - * USE OR OTHER DEALINGS IN THE SOFTWARE. - * - * Authors: - * Keith Whitwell - */ - -#ifndef _TNL_VERTEX_H -#define _TNL_VERTEX_H - -#include "main/glheader.h" -#include "t_context.h" - -struct gl_context; -struct tnl_clipspace; - -/* New mechanism to specify hardware vertices so that tnl can build - * and manipulate them directly. - */ - - -/* It will probably be necessary to allow drivers to specify new - * emit-styles to cover all the wierd and wacky things out there. - */ -enum tnl_attr_format { - EMIT_1F, - EMIT_2F, - EMIT_3F, - EMIT_4F, - EMIT_2F_VIEWPORT, /* do viewport transform and emit */ - EMIT_3F_VIEWPORT, /* do viewport transform and emit */ - EMIT_4F_VIEWPORT, /* do viewport transform and emit */ - EMIT_3F_XYW, /* for projective texture */ - EMIT_1UB_1F, /* for fog coordinate */ - EMIT_3UB_3F_RGB, /* for specular color */ - EMIT_3UB_3F_BGR, /* for specular color */ - EMIT_4UB_4F_RGBA, /* for color */ - EMIT_4UB_4F_BGRA, /* for color */ - EMIT_4UB_4F_ARGB, /* for color */ - EMIT_4UB_4F_ABGR, /* for color */ - EMIT_4CHAN_4F_RGBA, /* for swrast color */ - EMIT_PAD, /* leave a hole of 'offset' bytes */ - EMIT_MAX -}; - -struct tnl_attr_map { - GLuint attrib; /* _TNL_ATTRIB_ enum */ - enum tnl_attr_format format; - GLuint offset; -}; - -struct tnl_format_info { - const char *name; - tnl_extract_func extract; - tnl_insert_func insert[4]; - const GLuint attrsize; -}; - -extern const struct tnl_format_info _tnl_format_info[EMIT_MAX]; - - -/* Interpolate between two vertices to produce a third: - */ -extern void _tnl_interp( struct gl_context *ctx, - GLfloat t, - GLuint edst, GLuint eout, GLuint ein, - GLboolean force_boundary ); - -/* Copy colors from one vertex to another: - */ -extern void _tnl_copy_pv( struct gl_context *ctx, GLuint edst, GLuint esrc ); - - -/* Extract a named attribute from a hardware vertex. Will have to - * reverse any viewport transformation, swizzling or other conversions - * which may have been applied: - */ -extern void _tnl_get_attr( struct gl_context *ctx, const void *vertex, GLenum attrib, - GLfloat *dest ); - -/* Complementary to the above. - */ -extern void _tnl_set_attr( struct gl_context *ctx, void *vout, GLenum attrib, - const GLfloat *src ); - - -extern void *_tnl_get_vertex( struct gl_context *ctx, GLuint nr ); - -extern GLuint _tnl_install_attrs( struct gl_context *ctx, - const struct tnl_attr_map *map, - GLuint nr, const GLfloat *vp, - GLuint unpacked_size ); - -extern void _tnl_free_vertices( struct gl_context *ctx ); - -extern void _tnl_init_vertices( struct gl_context *ctx, - GLuint vb_size, - GLuint max_vertex_size ); - -extern void *_tnl_emit_vertices_to_buffer( struct gl_context *ctx, - GLuint start, - GLuint end, - void *dest ); - -/* This function isn't optimal. Check out - * gallium/auxilary/translate for a more comprehensive implementation of - * the same functionality. - */ - -extern void *_tnl_emit_indexed_vertices_to_buffer( struct gl_context *ctx, - const GLuint *elts, - GLuint start, - GLuint end, - void *dest ); - - -extern void _tnl_build_vertices( struct gl_context *ctx, - GLuint start, - GLuint end, - GLuint newinputs ); - -extern void _tnl_invalidate_vertices( struct gl_context *ctx, GLuint newinputs ); - -extern void _tnl_invalidate_vertex_state( struct gl_context *ctx, GLuint new_state ); - -extern void _tnl_notify_pipeline_output_change( struct gl_context *ctx ); - - -#define GET_VERTEX_STATE(ctx) &(TNL_CONTEXT(ctx)->clipspace) - -/* Internal function: - */ -void _tnl_register_fastpath( struct tnl_clipspace *vtx, - GLboolean match_strides ); - - -/* t_vertex_generic.c -- Internal functions for t_vertex.c - */ -void _tnl_generic_copy_pv_extras( struct gl_context *ctx, - GLuint dst, GLuint src ); - -void _tnl_generic_interp_extras( struct gl_context *ctx, - GLfloat t, - GLuint dst, GLuint out, GLuint in, - GLboolean force_boundary ); - -void _tnl_generic_copy_pv( struct gl_context *ctx, GLuint edst, GLuint esrc ); - -void _tnl_generic_interp( struct gl_context *ctx, - GLfloat t, - GLuint edst, GLuint eout, GLuint ein, - GLboolean force_boundary ); - -void _tnl_generic_emit( struct gl_context *ctx, - GLuint count, - GLubyte *v ); - -void _tnl_generate_hardwired_emit( struct gl_context *ctx ); - -/* t_vertex_sse.c -- Internal functions for t_vertex.c - */ -void _tnl_generate_sse_emit( struct gl_context *ctx ); - -#endif diff --git a/dll/opengl/mesa/tnl/t_vertex_generic.c b/dll/opengl/mesa/tnl/t_vertex_generic.c deleted file mode 100644 index b8ef1f7d474..00000000000 --- a/dll/opengl/mesa/tnl/t_vertex_generic.c +++ /dev/null @@ -1,1134 +0,0 @@ - -/* - * Copyright 2003 Tungsten Graphics, 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 - * on the rights to use, copy, modify, merge, publish, distribute, sub - * license, and/or sell copies of the Software, and to permit persons to whom - * the Software is furnished to do so, subject to the following conditions: - * - * The above copyright notice and this permission notice (including the next - * paragraph) shall be included in all copies or substantial portions of the - * Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR - * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT. IN NO EVENT SHALL - * TUNGSTEN GRAPHICS AND/OR THEIR SUPPLIERS BE LIABLE FOR ANY CLAIM, - * DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR - * OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE - * USE OR OTHER DEALINGS IN THE SOFTWARE. - * - * Authors: - * Keith Whitwell - */ - -#include - -#if 0 -#define DEBUG_INSERT printf("%s\n", __FUNCTION__) -#else -#define DEBUG_INSERT -#endif - - -/* - * These functions take the NDC coordinates pointed to by 'in', apply the - * NDC->Viewport mapping and store the results at 'v'. - */ - -static inline void insert_4f_viewport_4( const struct tnl_clipspace_attr *a, GLubyte *v, - const GLfloat *in ) -{ - GLfloat *out = (GLfloat *)v; - const GLfloat * const vp = a->vp; - DEBUG_INSERT; - out[0] = vp[0] * in[0] + vp[12]; - out[1] = vp[5] * in[1] + vp[13]; - out[2] = vp[10] * in[2] + vp[14]; - out[3] = in[3]; -} - -static inline void insert_4f_viewport_3( const struct tnl_clipspace_attr *a, GLubyte *v, - const GLfloat *in ) -{ - GLfloat *out = (GLfloat *)v; - const GLfloat * const vp = a->vp; - DEBUG_INSERT; - out[0] = vp[0] * in[0] + vp[12]; - out[1] = vp[5] * in[1] + vp[13]; - out[2] = vp[10] * in[2] + vp[14]; - out[3] = 1; -} - -static inline void insert_4f_viewport_2( const struct tnl_clipspace_attr *a, GLubyte *v, - const GLfloat *in ) -{ - GLfloat *out = (GLfloat *)v; - const GLfloat * const vp = a->vp; - DEBUG_INSERT; - out[0] = vp[0] * in[0] + vp[12]; - out[1] = vp[5] * in[1] + vp[13]; - out[2] = vp[14]; - out[3] = 1; -} - -static inline void insert_4f_viewport_1( const struct tnl_clipspace_attr *a, GLubyte *v, - const GLfloat *in ) -{ - GLfloat *out = (GLfloat *)v; - const GLfloat * const vp = a->vp; - DEBUG_INSERT; - out[0] = vp[0] * in[0] + vp[12]; - out[1] = vp[13]; - out[2] = vp[14]; - out[3] = 1; -} - -static inline void insert_3f_viewport_3( const struct tnl_clipspace_attr *a, GLubyte *v, - const GLfloat *in ) -{ - GLfloat *out = (GLfloat *)v; - const GLfloat * const vp = a->vp; - DEBUG_INSERT; - out[0] = vp[0] * in[0] + vp[12]; - out[1] = vp[5] * in[1] + vp[13]; - out[2] = vp[10] * in[2] + vp[14]; -} - -static inline void insert_3f_viewport_2( const struct tnl_clipspace_attr *a, GLubyte *v, - const GLfloat *in ) -{ - GLfloat *out = (GLfloat *)v; - const GLfloat * const vp = a->vp; - DEBUG_INSERT; - out[0] = vp[0] * in[0] + vp[12]; - out[1] = vp[5] * in[1] + vp[13]; - out[2] = vp[14]; -} - -static inline void insert_3f_viewport_1( const struct tnl_clipspace_attr *a, GLubyte *v, - const GLfloat *in ) -{ - GLfloat *out = (GLfloat *)v; - const GLfloat * const vp = a->vp; - DEBUG_INSERT; - out[0] = vp[0] * in[0] + vp[12]; - out[1] = vp[13]; - out[2] = vp[14]; -} - -static inline void insert_2f_viewport_2( const struct tnl_clipspace_attr *a, GLubyte *v, - const GLfloat *in ) -{ - GLfloat *out = (GLfloat *)v; - const GLfloat * const vp = a->vp; - DEBUG_INSERT; - out[0] = vp[0] * in[0] + vp[12]; - out[1] = vp[5] * in[1] + vp[13]; -} - -static inline void insert_2f_viewport_1( const struct tnl_clipspace_attr *a, GLubyte *v, - const GLfloat *in ) -{ - GLfloat *out = (GLfloat *)v; - const GLfloat * const vp = a->vp; - DEBUG_INSERT; - out[0] = vp[0] * in[0] + vp[12]; - out[1] = vp[13]; -} - - -/* - * These functions do the same as above, except for the viewport mapping. - */ - -static inline void insert_4f_4( const struct tnl_clipspace_attr *a, GLubyte *v, const GLfloat *in ) -{ - GLfloat *out = (GLfloat *)(v); - (void) a; - DEBUG_INSERT; - out[0] = in[0]; - out[1] = in[1]; - out[2] = in[2]; - out[3] = in[3]; -} - -static inline void insert_4f_3( const struct tnl_clipspace_attr *a, GLubyte *v, const GLfloat *in ) -{ - GLfloat *out = (GLfloat *)(v); - (void) a; - DEBUG_INSERT; - out[0] = in[0]; - out[1] = in[1]; - out[2] = in[2]; - out[3] = 1; -} - -static inline void insert_4f_2( const struct tnl_clipspace_attr *a, GLubyte *v, const GLfloat *in ) -{ - GLfloat *out = (GLfloat *)(v); - (void) a; - DEBUG_INSERT; - out[0] = in[0]; - out[1] = in[1]; - out[2] = 0; - out[3] = 1; -} - -static inline void insert_4f_1( const struct tnl_clipspace_attr *a, GLubyte *v, const GLfloat *in ) -{ - GLfloat *out = (GLfloat *)(v); - (void) a; - DEBUG_INSERT; - out[0] = in[0]; - out[1] = 0; - out[2] = 0; - out[3] = 1; -} - -static inline void insert_3f_xyw_4( const struct tnl_clipspace_attr *a, GLubyte *v, const GLfloat *in ) -{ - GLfloat *out = (GLfloat *)(v); - (void) a; - DEBUG_INSERT; - out[0] = in[0]; - out[1] = in[1]; - out[2] = in[3]; -} - -static inline void insert_3f_xyw_err( const struct tnl_clipspace_attr *a, GLubyte *v, const GLfloat *in ) -{ - (void) a; (void) v; (void) in; - DEBUG_INSERT; - exit(1); -} - -static inline void insert_3f_3( const struct tnl_clipspace_attr *a, GLubyte *v, const GLfloat *in ) -{ - GLfloat *out = (GLfloat *)(v); - (void) a; - DEBUG_INSERT; - out[0] = in[0]; - out[1] = in[1]; - out[2] = in[2]; -} - -static inline void insert_3f_2( const struct tnl_clipspace_attr *a, GLubyte *v, const GLfloat *in ) -{ - GLfloat *out = (GLfloat *)(v); - (void) a; - DEBUG_INSERT; - out[0] = in[0]; - out[1] = in[1]; - out[2] = 0; -} - -static inline void insert_3f_1( const struct tnl_clipspace_attr *a, GLubyte *v, const GLfloat *in ) -{ - GLfloat *out = (GLfloat *)(v); - (void) a; - DEBUG_INSERT; - out[0] = in[0]; - out[1] = 0; - out[2] = 0; -} - - -static inline void insert_2f_2( const struct tnl_clipspace_attr *a, GLubyte *v, const GLfloat *in ) -{ - GLfloat *out = (GLfloat *)(v); - (void) a; - DEBUG_INSERT; - out[0] = in[0]; - out[1] = in[1]; -} - -static inline void insert_2f_1( const struct tnl_clipspace_attr *a, GLubyte *v, const GLfloat *in ) -{ - GLfloat *out = (GLfloat *)(v); - (void) a; - DEBUG_INSERT; - out[0] = in[0]; - out[1] = 0; -} - -static inline void insert_1f_1( const struct tnl_clipspace_attr *a, GLubyte *v, const GLfloat *in ) -{ - GLfloat *out = (GLfloat *)(v); - (void) a; - DEBUG_INSERT; - out[0] = in[0]; -} - -static inline void insert_null( const struct tnl_clipspace_attr *a, GLubyte *v, const GLfloat *in ) -{ - DEBUG_INSERT; - (void) a; (void) v; (void) in; -} - -static inline void insert_4chan_4f_rgba_4( const struct tnl_clipspace_attr *a, GLubyte *v, - const GLfloat *in ) -{ - GLchan *c = (GLchan *)v; - DEBUG_INSERT; - (void) a; - UNCLAMPED_FLOAT_TO_CHAN(c[0], in[0]); - UNCLAMPED_FLOAT_TO_CHAN(c[1], in[1]); - UNCLAMPED_FLOAT_TO_CHAN(c[2], in[2]); - UNCLAMPED_FLOAT_TO_CHAN(c[3], in[3]); -} - -static inline void insert_4chan_4f_rgba_3( const struct tnl_clipspace_attr *a, GLubyte *v, - const GLfloat *in ) -{ - GLchan *c = (GLchan *)v; - DEBUG_INSERT; - (void) a; - UNCLAMPED_FLOAT_TO_CHAN(c[0], in[0]); - UNCLAMPED_FLOAT_TO_CHAN(c[1], in[1]); - UNCLAMPED_FLOAT_TO_CHAN(c[2], in[2]); - c[3] = CHAN_MAX; -} - -static inline void insert_4chan_4f_rgba_2( const struct tnl_clipspace_attr *a, GLubyte *v, - const GLfloat *in ) -{ - GLchan *c = (GLchan *)v; - DEBUG_INSERT; - (void) a; - UNCLAMPED_FLOAT_TO_CHAN(c[0], in[0]); - UNCLAMPED_FLOAT_TO_CHAN(c[1], in[1]); - c[2] = 0; - c[3] = CHAN_MAX; -} - -static inline void insert_4chan_4f_rgba_1( const struct tnl_clipspace_attr *a, GLubyte *v, - const GLfloat *in ) -{ - GLchan *c = (GLchan *)v; - DEBUG_INSERT; - (void) a; - UNCLAMPED_FLOAT_TO_CHAN(c[0], in[0]); - c[1] = 0; - c[2] = 0; - c[3] = CHAN_MAX; -} - -static inline void insert_4ub_4f_rgba_4( const struct tnl_clipspace_attr *a, GLubyte *v, - const GLfloat *in ) -{ - DEBUG_INSERT; - (void) a; - UNCLAMPED_FLOAT_TO_UBYTE(v[0], in[0]); - UNCLAMPED_FLOAT_TO_UBYTE(v[1], in[1]); - UNCLAMPED_FLOAT_TO_UBYTE(v[2], in[2]); - UNCLAMPED_FLOAT_TO_UBYTE(v[3], in[3]); -} - -static inline void insert_4ub_4f_rgba_3( const struct tnl_clipspace_attr *a, GLubyte *v, - const GLfloat *in ) -{ - DEBUG_INSERT; - (void) a; - UNCLAMPED_FLOAT_TO_UBYTE(v[0], in[0]); - UNCLAMPED_FLOAT_TO_UBYTE(v[1], in[1]); - UNCLAMPED_FLOAT_TO_UBYTE(v[2], in[2]); - v[3] = 0xff; -} - -static inline void insert_4ub_4f_rgba_2( const struct tnl_clipspace_attr *a, GLubyte *v, - const GLfloat *in ) -{ - DEBUG_INSERT; - (void) a; - UNCLAMPED_FLOAT_TO_UBYTE(v[0], in[0]); - UNCLAMPED_FLOAT_TO_UBYTE(v[1], in[1]); - v[2] = 0; - v[3] = 0xff; -} - -static inline void insert_4ub_4f_rgba_1( const struct tnl_clipspace_attr *a, GLubyte *v, - const GLfloat *in ) -{ - DEBUG_INSERT; - (void) a; - UNCLAMPED_FLOAT_TO_UBYTE(v[0], in[0]); - v[1] = 0; - v[2] = 0; - v[3] = 0xff; -} - -static inline void insert_4ub_4f_bgra_4( const struct tnl_clipspace_attr *a, GLubyte *v, - const GLfloat *in ) -{ - DEBUG_INSERT; - (void) a; - UNCLAMPED_FLOAT_TO_UBYTE(v[2], in[0]); - UNCLAMPED_FLOAT_TO_UBYTE(v[1], in[1]); - UNCLAMPED_FLOAT_TO_UBYTE(v[0], in[2]); - UNCLAMPED_FLOAT_TO_UBYTE(v[3], in[3]); -} - -static inline void insert_4ub_4f_bgra_3( const struct tnl_clipspace_attr *a, GLubyte *v, - const GLfloat *in ) -{ - DEBUG_INSERT; - (void) a; - UNCLAMPED_FLOAT_TO_UBYTE(v[2], in[0]); - UNCLAMPED_FLOAT_TO_UBYTE(v[1], in[1]); - UNCLAMPED_FLOAT_TO_UBYTE(v[0], in[2]); - v[3] = 0xff; -} - -static inline void insert_4ub_4f_bgra_2( const struct tnl_clipspace_attr *a, GLubyte *v, - const GLfloat *in ) -{ - DEBUG_INSERT; - (void) a; - UNCLAMPED_FLOAT_TO_UBYTE(v[2], in[0]); - UNCLAMPED_FLOAT_TO_UBYTE(v[1], in[1]); - v[0] = 0; - v[3] = 0xff; -} - -static inline void insert_4ub_4f_bgra_1( const struct tnl_clipspace_attr *a, GLubyte *v, - const GLfloat *in ) -{ - DEBUG_INSERT; - (void) a; - UNCLAMPED_FLOAT_TO_UBYTE(v[2], in[0]); - v[1] = 0; - v[0] = 0; - v[3] = 0xff; -} - -static inline void insert_4ub_4f_argb_4( const struct tnl_clipspace_attr *a, GLubyte *v, - const GLfloat *in ) -{ - DEBUG_INSERT; - (void) a; - UNCLAMPED_FLOAT_TO_UBYTE(v[1], in[0]); - UNCLAMPED_FLOAT_TO_UBYTE(v[2], in[1]); - UNCLAMPED_FLOAT_TO_UBYTE(v[3], in[2]); - UNCLAMPED_FLOAT_TO_UBYTE(v[0], in[3]); -} - -static inline void insert_4ub_4f_argb_3( const struct tnl_clipspace_attr *a, GLubyte *v, - const GLfloat *in ) -{ - DEBUG_INSERT; - (void) a; - UNCLAMPED_FLOAT_TO_UBYTE(v[1], in[0]); - UNCLAMPED_FLOAT_TO_UBYTE(v[2], in[1]); - UNCLAMPED_FLOAT_TO_UBYTE(v[3], in[2]); - v[0] = 0xff; -} - -static inline void insert_4ub_4f_argb_2( const struct tnl_clipspace_attr *a, GLubyte *v, - const GLfloat *in ) -{ - DEBUG_INSERT; - (void) a; - UNCLAMPED_FLOAT_TO_UBYTE(v[1], in[0]); - UNCLAMPED_FLOAT_TO_UBYTE(v[2], in[1]); - v[3] = 0x00; - v[0] = 0xff; -} - -static inline void insert_4ub_4f_argb_1( const struct tnl_clipspace_attr *a, GLubyte *v, - const GLfloat *in ) -{ - DEBUG_INSERT; - (void) a; - UNCLAMPED_FLOAT_TO_UBYTE(v[1], in[0]); - v[2] = 0x00; - v[3] = 0x00; - v[0] = 0xff; -} - -static inline void insert_4ub_4f_abgr_4( const struct tnl_clipspace_attr *a, GLubyte *v, - const GLfloat *in ) -{ - DEBUG_INSERT; - (void) a; - UNCLAMPED_FLOAT_TO_UBYTE(v[3], in[0]); - UNCLAMPED_FLOAT_TO_UBYTE(v[2], in[1]); - UNCLAMPED_FLOAT_TO_UBYTE(v[1], in[2]); - UNCLAMPED_FLOAT_TO_UBYTE(v[0], in[3]); -} - -static inline void insert_4ub_4f_abgr_3( const struct tnl_clipspace_attr *a, GLubyte *v, - const GLfloat *in ) -{ - DEBUG_INSERT; - (void) a; - UNCLAMPED_FLOAT_TO_UBYTE(v[3], in[0]); - UNCLAMPED_FLOAT_TO_UBYTE(v[2], in[1]); - UNCLAMPED_FLOAT_TO_UBYTE(v[1], in[2]); - v[0] = 0xff; -} - -static inline void insert_4ub_4f_abgr_2( const struct tnl_clipspace_attr *a, GLubyte *v, - const GLfloat *in ) -{ - DEBUG_INSERT; - (void) a; - UNCLAMPED_FLOAT_TO_UBYTE(v[3], in[0]); - UNCLAMPED_FLOAT_TO_UBYTE(v[2], in[1]); - v[1] = 0x00; - v[0] = 0xff; -} - -static inline void insert_4ub_4f_abgr_1( const struct tnl_clipspace_attr *a, GLubyte *v, - const GLfloat *in ) -{ - DEBUG_INSERT; - (void) a; - UNCLAMPED_FLOAT_TO_UBYTE(v[3], in[0]); - v[2] = 0x00; - v[1] = 0x00; - v[0] = 0xff; -} - -static inline void insert_3ub_3f_rgb_3( const struct tnl_clipspace_attr *a, GLubyte *v, - const GLfloat *in ) -{ - DEBUG_INSERT; - (void) a; - UNCLAMPED_FLOAT_TO_UBYTE(v[0], in[0]); - UNCLAMPED_FLOAT_TO_UBYTE(v[1], in[1]); - UNCLAMPED_FLOAT_TO_UBYTE(v[2], in[2]); -} - -static inline void insert_3ub_3f_rgb_2( const struct tnl_clipspace_attr *a, GLubyte *v, - const GLfloat *in ) -{ - DEBUG_INSERT; - (void) a; - UNCLAMPED_FLOAT_TO_UBYTE(v[0], in[0]); - UNCLAMPED_FLOAT_TO_UBYTE(v[1], in[1]); - v[2] = 0; -} - -static inline void insert_3ub_3f_rgb_1( const struct tnl_clipspace_attr *a, GLubyte *v, - const GLfloat *in ) -{ - DEBUG_INSERT; - (void) a; - UNCLAMPED_FLOAT_TO_UBYTE(v[0], in[0]); - v[1] = 0; - v[2] = 0; -} - -static inline void insert_3ub_3f_bgr_3( const struct tnl_clipspace_attr *a, GLubyte *v, - const GLfloat *in ) -{ - DEBUG_INSERT; - (void) a; - UNCLAMPED_FLOAT_TO_UBYTE(v[2], in[0]); - UNCLAMPED_FLOAT_TO_UBYTE(v[1], in[1]); - UNCLAMPED_FLOAT_TO_UBYTE(v[0], in[2]); -} - -static inline void insert_3ub_3f_bgr_2( const struct tnl_clipspace_attr *a, GLubyte *v, - const GLfloat *in ) -{ - DEBUG_INSERT; - (void) a; - UNCLAMPED_FLOAT_TO_UBYTE(v[2], in[0]); - UNCLAMPED_FLOAT_TO_UBYTE(v[1], in[1]); - v[0] = 0; -} - -static inline void insert_3ub_3f_bgr_1( const struct tnl_clipspace_attr *a, GLubyte *v, - const GLfloat *in ) -{ - DEBUG_INSERT; - (void) a; - UNCLAMPED_FLOAT_TO_UBYTE(v[2], in[0]); - v[1] = 0; - v[0] = 0; -} - - -static inline void insert_1ub_1f_1( const struct tnl_clipspace_attr *a, GLubyte *v, - const GLfloat *in ) -{ - DEBUG_INSERT; - (void) a; - UNCLAMPED_FLOAT_TO_UBYTE(v[0], in[0]); -} - - -/*********************************************************************** - * Functions to perform the reverse operations to the above, for - * swrast translation and clip-interpolation. - * - * Currently always extracts a full 4 floats. - */ - -static void extract_4f_viewport( const struct tnl_clipspace_attr *a, GLfloat *out, - const GLubyte *v ) -{ - const GLfloat *in = (const GLfloat *)v; - const GLfloat * const vp = a->vp; - - /* Although included for completeness, the position coordinate is - * usually handled differently during clipping. - */ - DEBUG_INSERT; - out[0] = (in[0] - vp[12]) / vp[0]; - out[1] = (in[1] - vp[13]) / vp[5]; - out[2] = (in[2] - vp[14]) / vp[10]; - out[3] = in[3]; -} - -static void extract_3f_viewport( const struct tnl_clipspace_attr *a, GLfloat *out, - const GLubyte *v ) -{ - const GLfloat *in = (const GLfloat *)v; - const GLfloat * const vp = a->vp; - DEBUG_INSERT; - out[0] = (in[0] - vp[12]) / vp[0]; - out[1] = (in[1] - vp[13]) / vp[5]; - out[2] = (in[2] - vp[14]) / vp[10]; - out[3] = 1; -} - - -static void extract_2f_viewport( const struct tnl_clipspace_attr *a, GLfloat *out, - const GLubyte *v ) -{ - const GLfloat *in = (const GLfloat *)v; - const GLfloat * const vp = a->vp; - DEBUG_INSERT; - out[0] = (in[0] - vp[12]) / vp[0]; - out[1] = (in[1] - vp[13]) / vp[5]; - out[2] = 0; - out[3] = 1; -} - - -static void extract_4f( const struct tnl_clipspace_attr *a, GLfloat *out, const GLubyte *v ) -{ - const GLfloat *in = (const GLfloat *)v; - (void) a; - - out[0] = in[0]; - out[1] = in[1]; - out[2] = in[2]; - out[3] = in[3]; -} - -static void extract_3f_xyw( const struct tnl_clipspace_attr *a, GLfloat *out, const GLubyte *v ) -{ - const GLfloat *in = (const GLfloat *)v; - (void) a; - - out[0] = in[0]; - out[1] = in[1]; - out[2] = 0; - out[3] = in[2]; -} - - -static void extract_3f( const struct tnl_clipspace_attr *a, GLfloat *out, const GLubyte *v ) -{ - const GLfloat *in = (const GLfloat *)v; - (void) a; - - out[0] = in[0]; - out[1] = in[1]; - out[2] = in[2]; - out[3] = 1; -} - - -static void extract_2f( const struct tnl_clipspace_attr *a, GLfloat *out, const GLubyte *v ) -{ - const GLfloat *in = (const GLfloat *)v; - (void) a; - - out[0] = in[0]; - out[1] = in[1]; - out[2] = 0; - out[3] = 1; -} - -static void extract_1f( const struct tnl_clipspace_attr *a, GLfloat *out, const GLubyte *v ) -{ - const GLfloat *in = (const GLfloat *)v; - (void) a; - - out[0] = in[0]; - out[1] = 0; - out[2] = 0; - out[3] = 1; -} - -static void extract_4chan_4f_rgba( const struct tnl_clipspace_attr *a, GLfloat *out, - const GLubyte *v ) -{ - GLchan *c = (GLchan *)v; - (void) a; - - out[0] = CHAN_TO_FLOAT(c[0]); - out[1] = CHAN_TO_FLOAT(c[1]); - out[2] = CHAN_TO_FLOAT(c[2]); - out[3] = CHAN_TO_FLOAT(c[3]); -} - -static void extract_4ub_4f_rgba( const struct tnl_clipspace_attr *a, GLfloat *out, - const GLubyte *v ) -{ - (void) a; - out[0] = UBYTE_TO_FLOAT(v[0]); - out[1] = UBYTE_TO_FLOAT(v[1]); - out[2] = UBYTE_TO_FLOAT(v[2]); - out[3] = UBYTE_TO_FLOAT(v[3]); -} - -static void extract_4ub_4f_bgra( const struct tnl_clipspace_attr *a, GLfloat *out, - const GLubyte *v ) -{ - (void) a; - out[2] = UBYTE_TO_FLOAT(v[0]); - out[1] = UBYTE_TO_FLOAT(v[1]); - out[0] = UBYTE_TO_FLOAT(v[2]); - out[3] = UBYTE_TO_FLOAT(v[3]); -} - -static void extract_4ub_4f_argb( const struct tnl_clipspace_attr *a, GLfloat *out, - const GLubyte *v ) -{ - (void) a; - out[3] = UBYTE_TO_FLOAT(v[0]); - out[0] = UBYTE_TO_FLOAT(v[1]); - out[1] = UBYTE_TO_FLOAT(v[2]); - out[2] = UBYTE_TO_FLOAT(v[3]); -} - -static void extract_4ub_4f_abgr( const struct tnl_clipspace_attr *a, GLfloat *out, - const GLubyte *v ) -{ - (void) a; - out[3] = UBYTE_TO_FLOAT(v[0]); - out[2] = UBYTE_TO_FLOAT(v[1]); - out[1] = UBYTE_TO_FLOAT(v[2]); - out[0] = UBYTE_TO_FLOAT(v[3]); -} - -static void extract_3ub_3f_rgb( const struct tnl_clipspace_attr *a, GLfloat *out, - const GLubyte *v ) -{ - (void) a; - out[0] = UBYTE_TO_FLOAT(v[0]); - out[1] = UBYTE_TO_FLOAT(v[1]); - out[2] = UBYTE_TO_FLOAT(v[2]); - out[3] = 1; -} - -static void extract_3ub_3f_bgr( const struct tnl_clipspace_attr *a, GLfloat *out, - const GLubyte *v ) -{ - (void) a; - out[2] = UBYTE_TO_FLOAT(v[0]); - out[1] = UBYTE_TO_FLOAT(v[1]); - out[0] = UBYTE_TO_FLOAT(v[2]); - out[3] = 1; -} - -static void extract_1ub_1f( const struct tnl_clipspace_attr *a, GLfloat *out, const GLubyte *v ) -{ - (void) a; - out[0] = UBYTE_TO_FLOAT(v[0]); - out[1] = 0; - out[2] = 0; - out[3] = 1; -} - - -const struct tnl_format_info _tnl_format_info[EMIT_MAX] = -{ - { "1f", - extract_1f, - { insert_1f_1, insert_1f_1, insert_1f_1, insert_1f_1 }, - sizeof(GLfloat) }, - - { "2f", - extract_2f, - { insert_2f_1, insert_2f_2, insert_2f_2, insert_2f_2 }, - 2 * sizeof(GLfloat) }, - - { "3f", - extract_3f, - { insert_3f_1, insert_3f_2, insert_3f_3, insert_3f_3 }, - 3 * sizeof(GLfloat) }, - - { "4f", - extract_4f, - { insert_4f_1, insert_4f_2, insert_4f_3, insert_4f_4 }, - 4 * sizeof(GLfloat) }, - - { "2f_viewport", - extract_2f_viewport, - { insert_2f_viewport_1, insert_2f_viewport_2, insert_2f_viewport_2, - insert_2f_viewport_2 }, - 2 * sizeof(GLfloat) }, - - { "3f_viewport", - extract_3f_viewport, - { insert_3f_viewport_1, insert_3f_viewport_2, insert_3f_viewport_3, - insert_3f_viewport_3 }, - 3 * sizeof(GLfloat) }, - - { "4f_viewport", - extract_4f_viewport, - { insert_4f_viewport_1, insert_4f_viewport_2, insert_4f_viewport_3, - insert_4f_viewport_4 }, - 4 * sizeof(GLfloat) }, - - { "3f_xyw", - extract_3f_xyw, - { insert_3f_xyw_err, insert_3f_xyw_err, insert_3f_xyw_err, - insert_3f_xyw_4 }, - 3 * sizeof(GLfloat) }, - - { "1ub_1f", - extract_1ub_1f, - { insert_1ub_1f_1, insert_1ub_1f_1, insert_1ub_1f_1, insert_1ub_1f_1 }, - sizeof(GLubyte) }, - - { "3ub_3f_rgb", - extract_3ub_3f_rgb, - { insert_3ub_3f_rgb_1, insert_3ub_3f_rgb_2, insert_3ub_3f_rgb_3, - insert_3ub_3f_rgb_3 }, - 3 * sizeof(GLubyte) }, - - { "3ub_3f_bgr", - extract_3ub_3f_bgr, - { insert_3ub_3f_bgr_1, insert_3ub_3f_bgr_2, insert_3ub_3f_bgr_3, - insert_3ub_3f_bgr_3 }, - 3 * sizeof(GLubyte) }, - - { "4ub_4f_rgba", - extract_4ub_4f_rgba, - { insert_4ub_4f_rgba_1, insert_4ub_4f_rgba_2, insert_4ub_4f_rgba_3, - insert_4ub_4f_rgba_4 }, - 4 * sizeof(GLubyte) }, - - { "4ub_4f_bgra", - extract_4ub_4f_bgra, - { insert_4ub_4f_bgra_1, insert_4ub_4f_bgra_2, insert_4ub_4f_bgra_3, - insert_4ub_4f_bgra_4 }, - 4 * sizeof(GLubyte) }, - - { "4ub_4f_argb", - extract_4ub_4f_argb, - { insert_4ub_4f_argb_1, insert_4ub_4f_argb_2, insert_4ub_4f_argb_3, - insert_4ub_4f_argb_4 }, - 4 * sizeof(GLubyte) }, - - { "4ub_4f_abgr", - extract_4ub_4f_abgr, - { insert_4ub_4f_abgr_1, insert_4ub_4f_abgr_2, insert_4ub_4f_abgr_3, - insert_4ub_4f_abgr_4 }, - 4 * sizeof(GLubyte) }, - - { "4chan_4f_rgba", - extract_4chan_4f_rgba, - { insert_4chan_4f_rgba_1, insert_4chan_4f_rgba_2, insert_4chan_4f_rgba_3, - insert_4chan_4f_rgba_4 }, - 4 * sizeof(GLchan) }, - - { "pad", - NULL, - { NULL, NULL, NULL, NULL }, - 0 } - -}; - - - - -/*********************************************************************** - * Hardwired fastpaths for emitting whole vertices or groups of - * vertices - */ -#define EMIT5(NR, F0, F1, F2, F3, F4, NAME) \ -static void NAME( struct gl_context *ctx, \ - GLuint count, \ - GLubyte *v ) \ -{ \ - struct tnl_clipspace *vtx = GET_VERTEX_STATE(ctx); \ - struct tnl_clipspace_attr *a = vtx->attr; \ - GLuint i; \ - \ - for (i = 0 ; i < count ; i++, v += vtx->vertex_size) { \ - if (NR > 0) { \ - F0( &a[0], v + a[0].vertoffset, (GLfloat *)a[0].inputptr ); \ - a[0].inputptr += a[0].inputstride; \ - } \ - \ - if (NR > 1) { \ - F1( &a[1], v + a[1].vertoffset, (GLfloat *)a[1].inputptr ); \ - a[1].inputptr += a[1].inputstride; \ - } \ - \ - if (NR > 2) { \ - F2( &a[2], v + a[2].vertoffset, (GLfloat *)a[2].inputptr ); \ - a[2].inputptr += a[2].inputstride; \ - } \ - \ - if (NR > 3) { \ - F3( &a[3], v + a[3].vertoffset, (GLfloat *)a[3].inputptr ); \ - a[3].inputptr += a[3].inputstride; \ - } \ - \ - if (NR > 4) { \ - F4( &a[4], v + a[4].vertoffset, (GLfloat *)a[4].inputptr ); \ - a[4].inputptr += a[4].inputstride; \ - } \ - } \ -} - - -#define EMIT2(F0, F1, NAME) EMIT5(2, F0, F1, insert_null, \ - insert_null, insert_null, NAME) - -#define EMIT3(F0, F1, F2, NAME) EMIT5(3, F0, F1, F2, insert_null, \ - insert_null, NAME) - -#define EMIT4(F0, F1, F2, F3, NAME) EMIT5(4, F0, F1, F2, F3, \ - insert_null, NAME) - - -EMIT2(insert_3f_viewport_3, insert_4ub_4f_rgba_4, emit_viewport3_rgba4) -EMIT2(insert_3f_viewport_3, insert_4ub_4f_bgra_4, emit_viewport3_bgra4) -EMIT2(insert_3f_3, insert_4ub_4f_rgba_4, emit_xyz3_rgba4) - -EMIT3(insert_4f_viewport_4, insert_4ub_4f_rgba_4, insert_2f_2, emit_viewport4_rgba4_st2) -EMIT3(insert_4f_viewport_4, insert_4ub_4f_bgra_4, insert_2f_2, emit_viewport4_bgra4_st2) -EMIT3(insert_4f_4, insert_4ub_4f_rgba_4, insert_2f_2, emit_xyzw4_rgba4_st2) - -EMIT4(insert_4f_viewport_4, insert_4ub_4f_rgba_4, insert_2f_2, insert_2f_2, emit_viewport4_rgba4_st2_st2) -EMIT4(insert_4f_viewport_4, insert_4ub_4f_bgra_4, insert_2f_2, insert_2f_2, emit_viewport4_bgra4_st2_st2) -EMIT4(insert_4f_4, insert_4ub_4f_rgba_4, insert_2f_2, insert_2f_2, emit_xyzw4_rgba4_st2_st2) - - -/* Use the codegen paths to select one of a number of hardwired - * fastpaths. - */ -void _tnl_generate_hardwired_emit( struct gl_context *ctx ) -{ - struct tnl_clipspace *vtx = GET_VERTEX_STATE(ctx); - tnl_emit_func func = NULL; - - /* Does it fit a hardwired fastpath? Help! this is growing out of - * control! - */ - switch (vtx->attr_count) { - case 2: - if (vtx->attr[0].emit == insert_3f_viewport_3) { - if (vtx->attr[1].emit == insert_4ub_4f_bgra_4) - func = emit_viewport3_bgra4; - else if (vtx->attr[1].emit == insert_4ub_4f_rgba_4) - func = emit_viewport3_rgba4; - } - else if (vtx->attr[0].emit == insert_3f_3 && - vtx->attr[1].emit == insert_4ub_4f_rgba_4) { - func = emit_xyz3_rgba4; - } - break; - case 3: - if (vtx->attr[2].emit == insert_2f_2) { - if (vtx->attr[1].emit == insert_4ub_4f_rgba_4) { - if (vtx->attr[0].emit == insert_4f_viewport_4) - func = emit_viewport4_rgba4_st2; - else if (vtx->attr[0].emit == insert_4f_4) - func = emit_xyzw4_rgba4_st2; - } - else if (vtx->attr[1].emit == insert_4ub_4f_bgra_4 && - vtx->attr[0].emit == insert_4f_viewport_4) - func = emit_viewport4_bgra4_st2; - } - break; - case 4: - if (vtx->attr[2].emit == insert_2f_2 && - vtx->attr[3].emit == insert_2f_2) { - if (vtx->attr[1].emit == insert_4ub_4f_rgba_4) { - if (vtx->attr[0].emit == insert_4f_viewport_4) - func = emit_viewport4_rgba4_st2_st2; - else if (vtx->attr[0].emit == insert_4f_4) - func = emit_xyzw4_rgba4_st2_st2; - } - else if (vtx->attr[1].emit == insert_4ub_4f_bgra_4 && - vtx->attr[0].emit == insert_4f_viewport_4) - func = emit_viewport4_bgra4_st2_st2; - } - break; - } - - vtx->emit = func; -} - -/*********************************************************************** - * Generic (non-codegen) functions for whole vertices or groups of - * vertices - */ - -void _tnl_generic_emit( struct gl_context *ctx, - GLuint count, - GLubyte *v ) -{ - struct tnl_clipspace *vtx = GET_VERTEX_STATE(ctx); - struct tnl_clipspace_attr *a = vtx->attr; - const GLuint attr_count = vtx->attr_count; - const GLuint stride = vtx->vertex_size; - GLuint i, j; - - for (i = 0 ; i < count ; i++, v += stride) { - for (j = 0; j < attr_count; j++) { - GLfloat *in = (GLfloat *)a[j].inputptr; - a[j].inputptr += a[j].inputstride; - a[j].emit( &a[j], v + a[j].vertoffset, in ); - } - } -} - - -void _tnl_generic_interp( struct gl_context *ctx, - GLfloat t, - GLuint edst, GLuint eout, GLuint ein, - GLboolean force_boundary ) -{ - TNLcontext *tnl = TNL_CONTEXT(ctx); - struct vertex_buffer *VB = &tnl->vb; - struct tnl_clipspace *vtx = GET_VERTEX_STATE(ctx); - const GLubyte *vin = vtx->vertex_buf + ein * vtx->vertex_size; - const GLubyte *vout = vtx->vertex_buf + eout * vtx->vertex_size; - GLubyte *vdst = vtx->vertex_buf + edst * vtx->vertex_size; - const struct tnl_clipspace_attr *a = vtx->attr; - const GLuint attr_count = vtx->attr_count; - GLuint j; - (void) force_boundary; - - if (tnl->NeedNdcCoords) { - const GLfloat *dstclip = VB->ClipPtr->data[edst]; - if (dstclip[3] != 0.0) { - const GLfloat w = 1.0f / dstclip[3]; - GLfloat pos[4]; - - pos[0] = dstclip[0] * w; - pos[1] = dstclip[1] * w; - pos[2] = dstclip[2] * w; - pos[3] = w; - - a[0].insert[4-1]( &a[0], vdst, pos ); - } - } - else { - a[0].insert[4-1]( &a[0], vdst, VB->ClipPtr->data[edst] ); - } - - - for (j = 1; j < attr_count; j++) { - GLfloat fin[4], fout[4], fdst[4]; - - a[j].extract( &a[j], fin, vin + a[j].vertoffset ); - a[j].extract( &a[j], fout, vout + a[j].vertoffset ); - - INTERP_F( t, fdst[3], fout[3], fin[3] ); - INTERP_F( t, fdst[2], fout[2], fin[2] ); - INTERP_F( t, fdst[1], fout[1], fin[1] ); - INTERP_F( t, fdst[0], fout[0], fin[0] ); - - a[j].insert[4-1]( &a[j], vdst + a[j].vertoffset, fdst ); - } -} - - -/* Extract color attributes from one vertex and insert them into - * another. (Shortcircuit extract/insert with memcpy). - */ -void _tnl_generic_copy_pv( struct gl_context *ctx, GLuint edst, GLuint esrc ) -{ - struct tnl_clipspace *vtx = GET_VERTEX_STATE(ctx); - GLubyte *vsrc = vtx->vertex_buf + esrc * vtx->vertex_size; - GLubyte *vdst = vtx->vertex_buf + edst * vtx->vertex_size; - const struct tnl_clipspace_attr *a = vtx->attr; - const GLuint attr_count = vtx->attr_count; - GLuint j; - - for (j = 0; j < attr_count; j++) { - if (a[j].attrib == VERT_ATTRIB_COLOR) { - - memcpy( vdst + a[j].vertoffset, - vsrc + a[j].vertoffset, - a[j].vertattrsize ); - } - } -} - - -/* Helper functions for hardware which doesn't put back colors and/or - * edgeflags into vertices. - */ -void _tnl_generic_interp_extras( struct gl_context *ctx, - GLfloat t, - GLuint dst, GLuint out, GLuint in, - GLboolean force_boundary ) -{ - struct vertex_buffer *VB = &TNL_CONTEXT(ctx)->vb; - - /* If stride is zero, BackfaceColorPtr is constant across the VB, so - * there is no point interpolating between two values as they will - * be identical. In all other cases, this value is generated by - * t_vb_lighttmp.h and has a stride of 4 dwords. - */ - if (VB->BackfaceColorPtr && VB->BackfaceColorPtr->stride) { - assert(VB->BackfaceColorPtr->stride == 4 * sizeof(GLfloat)); - - INTERP_4F( t, - VB->BackfaceColorPtr->data[dst], - VB->BackfaceColorPtr->data[out], - VB->BackfaceColorPtr->data[in] ); - } - - if (VB->BackfaceIndexPtr) { - VB->BackfaceIndexPtr->data[dst][0] = LINTERP( t, - VB->BackfaceIndexPtr->data[out][0], - VB->BackfaceIndexPtr->data[in][0] ); - } - - if (VB->EdgeFlag) { - VB->EdgeFlag[dst] = VB->EdgeFlag[out] || force_boundary; - } - - _tnl_generic_interp(ctx, t, dst, out, in, force_boundary); -} - -void _tnl_generic_copy_pv_extras( struct gl_context *ctx, - GLuint dst, GLuint src ) -{ - struct vertex_buffer *VB = &TNL_CONTEXT(ctx)->vb; - - /* See above comment: - */ - if (VB->BackfaceColorPtr && VB->BackfaceColorPtr->stride) { - COPY_4FV( VB->BackfaceColorPtr->data[dst], - VB->BackfaceColorPtr->data[src] ); - } - - if (VB->BackfaceIndexPtr) { - VB->BackfaceIndexPtr->data[dst][0] = VB->BackfaceIndexPtr->data[src][0]; - } - - _tnl_generic_copy_pv(ctx, dst, src); -} - - diff --git a/dll/opengl/mesa/tnl/t_vertex_sse.c b/dll/opengl/mesa/tnl/t_vertex_sse.c deleted file mode 100644 index 8bcdce372fc..00000000000 --- a/dll/opengl/mesa/tnl/t_vertex_sse.c +++ /dev/null @@ -1,678 +0,0 @@ -/* - * Copyright 2003 Tungsten Graphics, 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 - * on the rights to use, copy, modify, merge, publish, distribute, sub - * license, and/or sell copies of the Software, and to permit persons to whom - * the Software is furnished to do so, subject to the following conditions: - * - * The above copyright notice and this permission notice (including the next - * paragraph) shall be included in all copies or substantial portions of the - * Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR - * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT. IN NO EVENT SHALL - * TUNGSTEN GRAPHICS AND/OR THEIR SUPPLIERS BE LIABLE FOR ANY CLAIM, - * DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR - * OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE - * USE OR OTHER DEALINGS IN THE SOFTWARE. - * - * Authors: - * Keith Whitwell - */ - -#include - -#if defined(USE_SSE_ASM) - -#include "x86/rtasm/x86sse.h" -#include "x86/common_x86_asm.h" - - -/** - * Number of bytes to allocate for generated SSE functions - */ -#define MAX_SSE_CODE_SIZE 1024 - - -#define X 0 -#define Y 1 -#define Z 2 -#define W 3 - - -struct x86_program { - struct x86_function func; - - struct gl_context *ctx; - GLboolean inputs_safe; - GLboolean outputs_safe; - GLboolean have_sse2; - - struct x86_reg identity; - struct x86_reg chan0; -}; - - -static struct x86_reg get_identity( struct x86_program *p ) -{ - return p->identity; -} - -static void emit_load4f_4( struct x86_program *p, - struct x86_reg dest, - struct x86_reg arg0 ) -{ - sse_movups(&p->func, dest, arg0); -} - -static void emit_load4f_3( struct x86_program *p, - struct x86_reg dest, - struct x86_reg arg0 ) -{ - /* Have to jump through some hoops: - * - * c 0 0 0 - * c 0 0 1 - * 0 0 c 1 - * a b c 1 - */ - sse_movss(&p->func, dest, x86_make_disp(arg0, 8)); - sse_shufps(&p->func, dest, get_identity(p), SHUF(X,Y,Z,W) ); - sse_shufps(&p->func, dest, dest, SHUF(Y,Z,X,W) ); - sse_movlps(&p->func, dest, arg0); -} - -static void emit_load4f_2( struct x86_program *p, - struct x86_reg dest, - struct x86_reg arg0 ) -{ - /* Initialize from identity, then pull in low two words: - */ - sse_movups(&p->func, dest, get_identity(p)); - sse_movlps(&p->func, dest, arg0); -} - -static void emit_load4f_1( struct x86_program *p, - struct x86_reg dest, - struct x86_reg arg0 ) -{ - /* Pull in low word, then swizzle in identity */ - sse_movss(&p->func, dest, arg0); - sse_shufps(&p->func, dest, get_identity(p), SHUF(X,Y,Z,W) ); -} - - - -static void emit_load3f_3( struct x86_program *p, - struct x86_reg dest, - struct x86_reg arg0 ) -{ - /* Over-reads by 1 dword - potential SEGV if input is a vertex - * array. - */ - if (p->inputs_safe) { - sse_movups(&p->func, dest, arg0); - } - else { - /* c 0 0 0 - * c c c c - * a b c c - */ - sse_movss(&p->func, dest, x86_make_disp(arg0, 8)); - sse_shufps(&p->func, dest, dest, SHUF(X,X,X,X)); - sse_movlps(&p->func, dest, arg0); - } -} - -static void emit_load3f_2( struct x86_program *p, - struct x86_reg dest, - struct x86_reg arg0 ) -{ - emit_load4f_2(p, dest, arg0); -} - -static void emit_load3f_1( struct x86_program *p, - struct x86_reg dest, - struct x86_reg arg0 ) -{ - /* Loading from memory erases the upper bits. */ - sse_movss(&p->func, dest, arg0); -} - -static void emit_load2f_2( struct x86_program *p, - struct x86_reg dest, - struct x86_reg arg0 ) -{ - sse_movlps(&p->func, dest, arg0); -} - -static void emit_load2f_1( struct x86_program *p, - struct x86_reg dest, - struct x86_reg arg0 ) -{ - /* Loading from memory erases the upper bits. */ - sse_movss(&p->func, dest, arg0); -} - -static void emit_load1f_1( struct x86_program *p, - struct x86_reg dest, - struct x86_reg arg0 ) -{ - sse_movss(&p->func, dest, arg0); -} - -static void (*load[4][4])( struct x86_program *p, - struct x86_reg dest, - struct x86_reg arg0 ) = { - { emit_load1f_1, - emit_load1f_1, - emit_load1f_1, - emit_load1f_1 }, - - { emit_load2f_1, - emit_load2f_2, - emit_load2f_2, - emit_load2f_2 }, - - { emit_load3f_1, - emit_load3f_2, - emit_load3f_3, - emit_load3f_3 }, - - { emit_load4f_1, - emit_load4f_2, - emit_load4f_3, - emit_load4f_4 } -}; - -static void emit_load( struct x86_program *p, - struct x86_reg dest, - GLuint sz, - struct x86_reg src, - GLuint src_sz) -{ - load[sz-1][src_sz-1](p, dest, src); -} - -static void emit_store4f( struct x86_program *p, - struct x86_reg dest, - struct x86_reg arg0 ) -{ - sse_movups(&p->func, dest, arg0); -} - -static void emit_store3f( struct x86_program *p, - struct x86_reg dest, - struct x86_reg arg0 ) -{ - if (p->outputs_safe) { - /* Emit the extra dword anyway. This may hurt writecombining, - * may cause other problems. - */ - sse_movups(&p->func, dest, arg0); - } - else { - /* Alternate strategy - emit two, shuffle, emit one. - */ - sse_movlps(&p->func, dest, arg0); - sse_shufps(&p->func, arg0, arg0, SHUF(Z,Z,Z,Z) ); /* NOTE! destructive */ - sse_movss(&p->func, x86_make_disp(dest,8), arg0); - } -} - -static void emit_store2f( struct x86_program *p, - struct x86_reg dest, - struct x86_reg arg0 ) -{ - sse_movlps(&p->func, dest, arg0); -} - -static void emit_store1f( struct x86_program *p, - struct x86_reg dest, - struct x86_reg arg0 ) -{ - sse_movss(&p->func, dest, arg0); -} - - -static void (*store[4])( struct x86_program *p, - struct x86_reg dest, - struct x86_reg arg0 ) = -{ - emit_store1f, - emit_store2f, - emit_store3f, - emit_store4f -}; - -static void emit_store( struct x86_program *p, - struct x86_reg dest, - GLuint sz, - struct x86_reg temp ) - -{ - store[sz-1](p, dest, temp); -} - -static void emit_pack_store_4ub( struct x86_program *p, - struct x86_reg dest, - struct x86_reg temp ) -{ - /* Scale by 255.0 - */ - sse_mulps(&p->func, temp, p->chan0); - - if (p->have_sse2) { - sse2_cvtps2dq(&p->func, temp, temp); - sse2_packssdw(&p->func, temp, temp); - sse2_packuswb(&p->func, temp, temp); - sse_movss(&p->func, dest, temp); - } - else { - struct x86_reg mmx0 = x86_make_reg(file_MMX, 0); - struct x86_reg mmx1 = x86_make_reg(file_MMX, 1); - sse_cvtps2pi(&p->func, mmx0, temp); - sse_movhlps(&p->func, temp, temp); - sse_cvtps2pi(&p->func, mmx1, temp); - mmx_packssdw(&p->func, mmx0, mmx1); - mmx_packuswb(&p->func, mmx0, mmx0); - mmx_movd(&p->func, dest, mmx0); - } -} - -static GLint get_offset( const void *a, const void *b ) -{ - return (const char *)b - (const char *)a; -} - -/* Not much happens here. Eventually use this function to try and - * avoid saving/reloading the source pointers each vertex (if some of - * them can fit in registers). - */ -static void get_src_ptr( struct x86_program *p, - struct x86_reg srcREG, - struct x86_reg vtxREG, - struct tnl_clipspace_attr *a ) -{ - struct tnl_clipspace *vtx = GET_VERTEX_STATE(p->ctx); - struct x86_reg ptr_to_src = x86_make_disp(vtxREG, get_offset(vtx, &a->inputptr)); - - /* Load current a[j].inputptr - */ - x86_mov(&p->func, srcREG, ptr_to_src); -} - -static void update_src_ptr( struct x86_program *p, - struct x86_reg srcREG, - struct x86_reg vtxREG, - struct tnl_clipspace_attr *a ) -{ - if (a->inputstride) { - struct tnl_clipspace *vtx = GET_VERTEX_STATE(p->ctx); - struct x86_reg ptr_to_src = x86_make_disp(vtxREG, get_offset(vtx, &a->inputptr)); - - /* add a[j].inputstride (hardcoded value - could just as easily - * pull the stride value from memory each time). - */ - x86_lea(&p->func, srcREG, x86_make_disp(srcREG, a->inputstride)); - - /* save new value of a[j].inputptr - */ - x86_mov(&p->func, ptr_to_src, srcREG); - } -} - - -/* Lots of hardcoding - * - * EAX -- pointer to current output vertex - * ECX -- pointer to current attribute - * - */ -static GLboolean build_vertex_emit( struct x86_program *p ) -{ - struct gl_context *ctx = p->ctx; - TNLcontext *tnl = TNL_CONTEXT(ctx); - struct tnl_clipspace *vtx = GET_VERTEX_STATE(ctx); - GLuint j = 0; - - struct x86_reg vertexEAX = x86_make_reg(file_REG32, reg_AX); - struct x86_reg srcECX = x86_make_reg(file_REG32, reg_CX); - struct x86_reg countEBP = x86_make_reg(file_REG32, reg_BP); - struct x86_reg vtxESI = x86_make_reg(file_REG32, reg_SI); - struct x86_reg temp = x86_make_reg(file_XMM, 0); - struct x86_reg vp0 = x86_make_reg(file_XMM, 1); - struct x86_reg vp1 = x86_make_reg(file_XMM, 2); - struct x86_reg temp2 = x86_make_reg(file_XMM, 3); - GLubyte *fixup, *label; - - /* Push a few regs? - */ - x86_push(&p->func, countEBP); - x86_push(&p->func, vtxESI); - - - /* Get vertex count, compare to zero - */ - x86_xor(&p->func, srcECX, srcECX); - x86_mov(&p->func, countEBP, x86_fn_arg(&p->func, 2)); - x86_cmp(&p->func, countEBP, srcECX); - fixup = x86_jcc_forward(&p->func, cc_E); - - /* Initialize destination register. - */ - x86_mov(&p->func, vertexEAX, x86_fn_arg(&p->func, 3)); - - /* Dereference ctx to get tnl, then vtx: - */ - x86_mov(&p->func, vtxESI, x86_fn_arg(&p->func, 1)); - x86_mov(&p->func, vtxESI, x86_make_disp(vtxESI, get_offset(ctx, &ctx->swtnl_context))); - vtxESI = x86_make_disp(vtxESI, get_offset(tnl, &tnl->clipspace)); - - - /* Possibly load vp0, vp1 for viewport calcs: - */ - if (vtx->need_viewport) { - sse_movups(&p->func, vp0, x86_make_disp(vtxESI, get_offset(vtx, &vtx->vp_scale[0]))); - sse_movups(&p->func, vp1, x86_make_disp(vtxESI, get_offset(vtx, &vtx->vp_xlate[0]))); - } - - /* always load, needed or not: - */ - sse_movups(&p->func, p->chan0, x86_make_disp(vtxESI, get_offset(vtx, &vtx->chan_scale[0]))); - sse_movups(&p->func, p->identity, x86_make_disp(vtxESI, get_offset(vtx, &vtx->identity[0]))); - - /* Note address for loop jump */ - label = x86_get_label(&p->func); - - /* Emit code for each of the attributes. Currently routes - * everything through SSE registers, even when it might be more - * efficient to stick with regular old x86. No optimization or - * other tricks - enough new ground to cover here just getting - * things working. - */ - while (j < vtx->attr_count) { - struct tnl_clipspace_attr *a = &vtx->attr[j]; - struct x86_reg dest = x86_make_disp(vertexEAX, a->vertoffset); - - /* Now, load an XMM reg from src, perhaps transform, then save. - * Could be shortcircuited in specific cases: - */ - switch (a->format) { - case EMIT_1F: - get_src_ptr(p, srcECX, vtxESI, a); - emit_load(p, temp, 1, x86_deref(srcECX), a->inputsize); - emit_store(p, dest, 1, temp); - update_src_ptr(p, srcECX, vtxESI, a); - break; - case EMIT_2F: - get_src_ptr(p, srcECX, vtxESI, a); - emit_load(p, temp, 2, x86_deref(srcECX), a->inputsize); - emit_store(p, dest, 2, temp); - update_src_ptr(p, srcECX, vtxESI, a); - break; - case EMIT_3F: - /* Potentially the worst case - hardcode 2+1 copying: - */ - if (0) { - get_src_ptr(p, srcECX, vtxESI, a); - emit_load(p, temp, 3, x86_deref(srcECX), a->inputsize); - emit_store(p, dest, 3, temp); - update_src_ptr(p, srcECX, vtxESI, a); - } - else { - get_src_ptr(p, srcECX, vtxESI, a); - emit_load(p, temp, 2, x86_deref(srcECX), a->inputsize); - emit_store(p, dest, 2, temp); - if (a->inputsize > 2) { - emit_load(p, temp, 1, x86_make_disp(srcECX, 8), 1); - emit_store(p, x86_make_disp(dest,8), 1, temp); - } - else { - sse_movss(&p->func, x86_make_disp(dest,8), get_identity(p)); - } - update_src_ptr(p, srcECX, vtxESI, a); - } - break; - case EMIT_4F: - get_src_ptr(p, srcECX, vtxESI, a); - emit_load(p, temp, 4, x86_deref(srcECX), a->inputsize); - emit_store(p, dest, 4, temp); - update_src_ptr(p, srcECX, vtxESI, a); - break; - case EMIT_2F_VIEWPORT: - get_src_ptr(p, srcECX, vtxESI, a); - emit_load(p, temp, 2, x86_deref(srcECX), a->inputsize); - sse_mulps(&p->func, temp, vp0); - sse_addps(&p->func, temp, vp1); - emit_store(p, dest, 2, temp); - update_src_ptr(p, srcECX, vtxESI, a); - break; - case EMIT_3F_VIEWPORT: - get_src_ptr(p, srcECX, vtxESI, a); - emit_load(p, temp, 3, x86_deref(srcECX), a->inputsize); - sse_mulps(&p->func, temp, vp0); - sse_addps(&p->func, temp, vp1); - emit_store(p, dest, 3, temp); - update_src_ptr(p, srcECX, vtxESI, a); - break; - case EMIT_4F_VIEWPORT: - get_src_ptr(p, srcECX, vtxESI, a); - emit_load(p, temp, 4, x86_deref(srcECX), a->inputsize); - sse_mulps(&p->func, temp, vp0); - sse_addps(&p->func, temp, vp1); - emit_store(p, dest, 4, temp); - update_src_ptr(p, srcECX, vtxESI, a); - break; - case EMIT_3F_XYW: - get_src_ptr(p, srcECX, vtxESI, a); - emit_load(p, temp, 4, x86_deref(srcECX), a->inputsize); - sse_shufps(&p->func, temp, temp, SHUF(X,Y,W,Z)); - emit_store(p, dest, 3, temp); - update_src_ptr(p, srcECX, vtxESI, a); - break; - - case EMIT_1UB_1F: - /* Test for PAD3 + 1UB: - */ - if (j > 0 && - a[-1].vertoffset + a[-1].vertattrsize <= a->vertoffset - 3) - { - get_src_ptr(p, srcECX, vtxESI, a); - emit_load(p, temp, 1, x86_deref(srcECX), a->inputsize); - sse_shufps(&p->func, temp, temp, SHUF(X,X,X,X)); - emit_pack_store_4ub(p, x86_make_disp(dest, -3), temp); /* overkill! */ - update_src_ptr(p, srcECX, vtxESI, a); - } - else { - printf("Can't emit 1ub %x %x %d\n", a->vertoffset, a[-1].vertoffset, a[-1].vertattrsize ); - return GL_FALSE; - } - break; - case EMIT_3UB_3F_RGB: - case EMIT_3UB_3F_BGR: - /* Test for 3UB + PAD1: - */ - if (j == vtx->attr_count - 1 || - a[1].vertoffset >= a->vertoffset + 4) { - get_src_ptr(p, srcECX, vtxESI, a); - emit_load(p, temp, 3, x86_deref(srcECX), a->inputsize); - if (a->format == EMIT_3UB_3F_BGR) - sse_shufps(&p->func, temp, temp, SHUF(Z,Y,X,W)); - emit_pack_store_4ub(p, dest, temp); - update_src_ptr(p, srcECX, vtxESI, a); - } - /* Test for 3UB + 1UB: - */ - else if (j < vtx->attr_count - 1 && - a[1].format == EMIT_1UB_1F && - a[1].vertoffset == a->vertoffset + 3) { - get_src_ptr(p, srcECX, vtxESI, a); - emit_load(p, temp, 3, x86_deref(srcECX), a->inputsize); - update_src_ptr(p, srcECX, vtxESI, a); - - /* Make room for incoming value: - */ - sse_shufps(&p->func, temp, temp, SHUF(W,X,Y,Z)); - - get_src_ptr(p, srcECX, vtxESI, &a[1]); - emit_load(p, temp2, 1, x86_deref(srcECX), a[1].inputsize); - sse_movss(&p->func, temp, temp2); - update_src_ptr(p, srcECX, vtxESI, &a[1]); - - /* Rearrange and possibly do BGR conversion: - */ - if (a->format == EMIT_3UB_3F_BGR) - sse_shufps(&p->func, temp, temp, SHUF(W,Z,Y,X)); - else - sse_shufps(&p->func, temp, temp, SHUF(Y,Z,W,X)); - - emit_pack_store_4ub(p, dest, temp); - j++; /* NOTE: two attrs consumed */ - } - else { - printf("Can't emit 3ub\n"); - return GL_FALSE; /* add this later */ - } - break; - - case EMIT_4UB_4F_RGBA: - get_src_ptr(p, srcECX, vtxESI, a); - emit_load(p, temp, 4, x86_deref(srcECX), a->inputsize); - emit_pack_store_4ub(p, dest, temp); - update_src_ptr(p, srcECX, vtxESI, a); - break; - case EMIT_4UB_4F_BGRA: - get_src_ptr(p, srcECX, vtxESI, a); - emit_load(p, temp, 4, x86_deref(srcECX), a->inputsize); - sse_shufps(&p->func, temp, temp, SHUF(Z,Y,X,W)); - emit_pack_store_4ub(p, dest, temp); - update_src_ptr(p, srcECX, vtxESI, a); - break; - case EMIT_4UB_4F_ARGB: - get_src_ptr(p, srcECX, vtxESI, a); - emit_load(p, temp, 4, x86_deref(srcECX), a->inputsize); - sse_shufps(&p->func, temp, temp, SHUF(W,X,Y,Z)); - emit_pack_store_4ub(p, dest, temp); - update_src_ptr(p, srcECX, vtxESI, a); - break; - case EMIT_4UB_4F_ABGR: - get_src_ptr(p, srcECX, vtxESI, a); - emit_load(p, temp, 4, x86_deref(srcECX), a->inputsize); - sse_shufps(&p->func, temp, temp, SHUF(W,Z,Y,X)); - emit_pack_store_4ub(p, dest, temp); - update_src_ptr(p, srcECX, vtxESI, a); - break; - case EMIT_4CHAN_4F_RGBA: - switch (CHAN_TYPE) { - case GL_UNSIGNED_BYTE: - get_src_ptr(p, srcECX, vtxESI, a); - emit_load(p, temp, 4, x86_deref(srcECX), a->inputsize); - emit_pack_store_4ub(p, dest, temp); - update_src_ptr(p, srcECX, vtxESI, a); - break; - case GL_FLOAT: - get_src_ptr(p, srcECX, vtxESI, a); - emit_load(p, temp, 4, x86_deref(srcECX), a->inputsize); - emit_store(p, dest, 4, temp); - update_src_ptr(p, srcECX, vtxESI, a); - break; - case GL_UNSIGNED_SHORT: - default: - printf("unknown CHAN_TYPE %s\n", _mesa_lookup_enum_by_nr(CHAN_TYPE)); - return GL_FALSE; - } - break; - default: - printf("unknown a[%d].format %d\n", j, a->format); - return GL_FALSE; /* catch any new opcodes */ - } - - /* Increment j by at least 1 - may have been incremented above also: - */ - j++; - } - - /* Next vertex: - */ - x86_lea(&p->func, vertexEAX, x86_make_disp(vertexEAX, vtx->vertex_size)); - - /* decr count, loop if not zero - */ - x86_dec(&p->func, countEBP); - x86_test(&p->func, countEBP, countEBP); - x86_jcc(&p->func, cc_NZ, label); - - /* Exit mmx state? - */ - if (p->func.need_emms) - mmx_emms(&p->func); - - /* Land forward jump here: - */ - x86_fixup_fwd_jump(&p->func, fixup); - - /* Pop regs and return - */ - x86_pop(&p->func, x86_get_base_reg(vtxESI)); - x86_pop(&p->func, countEBP); - x86_ret(&p->func); - - assert(!vtx->emit); - vtx->emit = (tnl_emit_func)x86_get_func(&p->func); - - assert( (char *) p->func.csr - (char *) p->func.store <= MAX_SSE_CODE_SIZE ); - return GL_TRUE; -} - - - -void _tnl_generate_sse_emit( struct gl_context *ctx ) -{ - struct tnl_clipspace *vtx = GET_VERTEX_STATE(ctx); - struct x86_program p; - - if (!cpu_has_xmm) { - vtx->codegen_emit = NULL; - return; - } - - memset(&p, 0, sizeof(p)); - - p.ctx = ctx; - p.inputs_safe = 0; /* for now */ - p.outputs_safe = 0; /* for now */ - p.have_sse2 = cpu_has_xmm2; - p.identity = x86_make_reg(file_XMM, 6); - p.chan0 = x86_make_reg(file_XMM, 7); - - if (!x86_init_func_size(&p.func, MAX_SSE_CODE_SIZE)) { - vtx->emit = NULL; - return; - } - - if (build_vertex_emit(&p)) { - _tnl_register_fastpath( vtx, GL_TRUE ); - } - else { - /* Note the failure so that we don't keep trying to codegen an - * impossible state: - */ - _tnl_register_fastpath( vtx, GL_FALSE ); - x86_release_func(&p.func); - } -} - -#else - -void _tnl_generate_sse_emit( struct gl_context *ctx ) -{ - /* Dummy version for when USE_SSE_ASM not defined */ -} - -#endif diff --git a/dll/opengl/mesa/tnl/tnl.h b/dll/opengl/mesa/tnl/tnl.h deleted file mode 100644 index ea505aaa74d..00000000000 --- a/dll/opengl/mesa/tnl/tnl.h +++ /dev/null @@ -1,100 +0,0 @@ -/* - * Mesa 3-D graphics library - * Version: 7.1 - * - * Copyright (C) 1999-2007 Brian Paul All Rights Reserved. - * - * Permission is hereby granted, free of charge, to any person obtaining a - * copy of this software and associated documentation files (the "Software"), - * to deal in the Software without restriction, including without limitation - * the rights to use, copy, modify, merge, publish, distribute, sublicense, - * and/or sell copies of the Software, and to permit persons to whom the - * Software is furnished to do so, subject to the following conditions: - * - * The above copyright notice and this permission notice shall be included - * in all copies or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS - * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL - * BRIAN PAUL BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN - * AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN - * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. - * - * Authors: - * Keith Whitwell - */ - -#ifndef _TNL_H -#define _TNL_H - -#include "main/glheader.h" - -struct gl_client_array; -struct gl_context; -struct gl_program; - - -/* These are the public-access functions exported from tnl. (A few - * more are currently hooked into dispatch directly by the module - * itself.) - */ -extern GLboolean -_tnl_CreateContext( struct gl_context *ctx ); - -extern void -_tnl_DestroyContext( struct gl_context *ctx ); - -extern void -_tnl_InvalidateState( struct gl_context *ctx, GLuint new_state ); - -/* Functions to revive the tnl module after being unhooked from - * dispatch and/or driver callbacks. - */ - -extern void -_tnl_wakeup( struct gl_context *ctx ); - -/* Driver configuration options: - */ -extern void -_tnl_need_projected_coords( struct gl_context *ctx, GLboolean flag ); - - -/* Control whether T&L does per-vertex fog - */ -extern void -_tnl_allow_vertex_fog( struct gl_context *ctx, GLboolean value ); - -extern void -_tnl_allow_pixel_fog( struct gl_context *ctx, GLboolean value ); - -struct _mesa_prim; -struct _mesa_index_buffer; - -void -_tnl_draw_prims( struct gl_context *ctx, - const struct gl_client_array *arrays[], - const struct _mesa_prim *prim, - GLuint nr_prims, - const struct _mesa_index_buffer *ib, - GLuint min_index, - GLuint max_index); - -void -_tnl_vbo_draw_prims( struct gl_context *ctx, - const struct gl_client_array *arrays[], - const struct _mesa_prim *prim, - GLuint nr_prims, - const struct _mesa_index_buffer *ib, - GLboolean index_bounds_valid, - GLuint min_index, - GLuint max_index); - -extern void -_mesa_load_tracked_matrices(struct gl_context *ctx); - -extern void -_tnl_RasterPos(struct gl_context *ctx, const GLfloat vObj[4]); - -#endif diff --git a/dll/opengl/mesa/triangle.c b/dll/opengl/mesa/triangle.c new file mode 100644 index 00000000000..57332c4c3af --- /dev/null +++ b/dll/opengl/mesa/triangle.c @@ -0,0 +1,793 @@ +/* $Id: triangle.c,v 1.31 1998/02/03 23:46:00 brianp Exp $ */ + +/* + * Mesa 3-D graphics library + * Version: 2.4 + * Copyright (C) 1995-1997 Brian Paul + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Library General Public + * License as published by the Free Software Foundation; either + * version 2 of the License, or (at your option) any later version. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Library General Public License for more details. + * + * You should have received a copy of the GNU Library General Public + * License along with this library; if not, write to the Free + * Software Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. + */ + + +/* + * $Log: triangle.c,v $ + * Revision 1.31 1998/02/03 23:46:00 brianp + * fixed a few problems with condition expressions for Amiga StormC compiler + * + * Revision 1.30 1997/08/27 01:20:05 brianp + * moved texture completeness test out one level (Karl Anders Oygard) + * + * Revision 1.29 1997/07/24 01:26:05 brianp + * changed precompiled header symbol from PCH to PC_HEADER + * + * Revision 1.28 1997/07/21 22:18:10 brianp + * fixed bug in compute_lambda() thanks to Magnus Lundin + * + * Revision 1.27 1997/06/23 00:40:03 brianp + * added a DEFARRAY/UNDEFARRAY for the Mac + * + * Revision 1.26 1997/06/20 02:51:38 brianp + * changed color components from GLfixed to GLubyte + * + * Revision 1.25 1997/06/03 01:38:22 brianp + * fixed divide by zero problem in feedback function (William Mitchell) + * + * Revision 1.24 1997/05/28 03:26:49 brianp + * added precompiled header (PCH) support + * + * Revision 1.23 1997/05/17 03:40:55 brianp + * refined textured triangle selection code (Mats Lofkvist) + * + * Revision 1.22 1997/05/03 00:51:02 brianp + * removed calls to gl_texturing_enabled() + * + * Revision 1.21 1997/04/14 21:38:15 brianp + * fixed a typo (dtdx instead of dudx) in lambda_textured_triangle() + * + * Revision 1.20 1997/04/14 02:00:39 brianp + * #include "texstate.h" instead of "texture.h" + * + * Revision 1.19 1997/04/12 12:27:16 brianp + * replaced ctx->TriangleFunc with ctx->Driver.TriangleFunc + * + * Revision 1.18 1997/04/02 03:12:06 brianp + * replaced ctx->IdentityTexMat with ctx->TextureMatrixType + * + * Revision 1.17 1997/03/13 03:05:31 brianp + * removed unused shift variable in feedback_triangle() + * + * Revision 1.16 1997/03/08 02:04:27 brianp + * better implementation of feedback function + * + * Revision 1.15 1997/03/04 18:54:13 brianp + * renamed mipmap_textured_triangle() to lambda_textured_triangle() + * better comments about lambda and mipmapping + * + * Revision 1.14 1997/02/20 23:47:35 brianp + * triangle feedback colors were wrong when using smooth shading + * + * Revision 1.13 1997/02/19 10:24:26 brianp + * use a GLdouble instead of a GLfloat for wwvvInv (perspective correction) + * + * Revision 1.12 1997/02/09 19:53:43 brianp + * now use TEXTURE_xD enable constants + * + * Revision 1.11 1997/02/09 18:51:02 brianp + * added GL_EXT_texture3D support + * + * Revision 1.10 1997/01/16 03:36:43 brianp + * added #include "texture.h" + * + * Revision 1.9 1997/01/09 19:50:49 brianp + * now call gl_texturing_enabled() + * + * Revision 1.8 1996/12/20 20:23:30 brianp + * the test for using general_textured_triangle() was wrong + * + * Revision 1.7 1996/12/12 22:37:30 brianp + * projective textures didn't work right + * + * Revision 1.6 1996/11/08 02:21:21 brianp + * added null drawing function for GL_NO_RASTER + * + * Revision 1.4 1996/09/27 01:30:37 brianp + * removed unneeded INTERP_ALPHA from flat_rgba_triangle() + * + * Revision 1.3 1996/09/15 14:19:16 brianp + * now use GLframebuffer and GLvisual + * + * Revision 1.2 1996/09/15 01:48:58 brianp + * removed #define NULL 0 + * + * Revision 1.1 1996/09/13 01:38:16 brianp + * Initial revision + * + */ + + +/* + * Triangle rasterizers + */ + + +#ifdef PC_HEADER +#include "all.h" +#else +#include +#include +#include +#include "depth.h" +#include "feedback.h" +#include "macros.h" +#include "span.h" +#include "texstate.h" +#include "triangle.h" +#include "types.h" +#include "vb.h" +#endif + + +/* + * Put triangle in feedback buffer. + */ +static void feedback_triangle( GLcontext *ctx, + GLuint v0, GLuint v1, GLuint v2, GLuint pv ) +{ + struct vertex_buffer *VB = ctx->VB; + GLfloat color[4]; + GLuint i; + GLfloat invRedScale = ctx->Visual->InvRedScale; + GLfloat invGreenScale = ctx->Visual->InvGreenScale; + GLfloat invBlueScale = ctx->Visual->InvBlueScale; + GLfloat invAlphaScale = ctx->Visual->InvAlphaScale; + + FEEDBACK_TOKEN( ctx, (GLfloat) (GLint) GL_POLYGON_TOKEN ); + FEEDBACK_TOKEN( ctx, (GLfloat) 3 ); /* three vertices */ + + if (ctx->Light.ShadeModel==GL_FLAT) { + /* flat shading - same color for each vertex */ + color[0] = (GLfloat) VB->Color[pv][0] * invRedScale; + color[1] = (GLfloat) VB->Color[pv][1] * invGreenScale; + color[2] = (GLfloat) VB->Color[pv][2] * invBlueScale; + color[3] = (GLfloat) VB->Color[pv][3] * invAlphaScale; + } + + for (i=0;i<3;i++) { + GLfloat x, y, z, w; + GLfloat tc[4]; + GLuint v; + GLfloat invq; + + if (i==0) v = v0; + else if (i==1) v = v1; + else v = v2; + + x = VB->Win[v][0]; + y = VB->Win[v][1]; + z = VB->Win[v][2] / DEPTH_SCALE; + w = VB->Clip[v][3]; + + if (ctx->Light.ShadeModel==GL_SMOOTH) { + /* smooth shading - different color for each vertex */ + color[0] = VB->Color[v][0] * invRedScale; + color[1] = VB->Color[v][1] * invGreenScale; + color[2] = VB->Color[v][2] * invBlueScale; + color[3] = VB->Color[v][3] * invAlphaScale; + } + + invq = (VB->TexCoord[v][3]==0.0) ? 1.0 : (1.0F / VB->TexCoord[v][3]); + tc[0] = VB->TexCoord[v][0] * invq; + tc[1] = VB->TexCoord[v][1] * invq; + tc[2] = VB->TexCoord[v][2] * invq; + tc[3] = VB->TexCoord[v][3]; + + gl_feedback_vertex( ctx, x, y, z, w, color, (GLfloat) VB->Index[v], tc ); + } +} + + + +/* + * Put triangle in selection buffer. + */ +static void select_triangle( GLcontext *ctx, + GLuint v0, GLuint v1, GLuint v2, GLuint pv ) +{ + struct vertex_buffer *VB = ctx->VB; + + gl_update_hitflag( ctx, VB->Win[v0][2] / DEPTH_SCALE ); + gl_update_hitflag( ctx, VB->Win[v1][2] / DEPTH_SCALE ); + gl_update_hitflag( ctx, VB->Win[v2][2] / DEPTH_SCALE ); +} + + + +/* + * Render a flat-shaded color index triangle. + */ +static void flat_ci_triangle( GLcontext *ctx, + GLuint v0, GLuint v1, GLuint v2, GLuint pv ) +{ +#define INTERP_Z 1 + +#define SETUP_CODE \ + GLuint index = VB->Index[pv]; \ + if (!VB->MonoColor) { \ + /* set the color index */ \ + (*ctx->Driver.Index)( ctx, index ); \ + } + +#define INNER_LOOP( LEFT, RIGHT, Y ) \ + { \ + GLint i, n = RIGHT-LEFT; \ + GLdepth zspan[MAX_WIDTH]; \ + if (n>0) { \ + for (i=0;i0) { \ + for (i=0;iMonoColor) { \ + /* set the color */ \ + GLubyte r = VB->Color[pv][0]; \ + GLubyte g = VB->Color[pv][1]; \ + GLubyte b = VB->Color[pv][2]; \ + GLubyte a = VB->Color[pv][3]; \ + (*ctx->Driver.Color)( ctx, r, g, b, a ); \ + } + +#define INNER_LOOP( LEFT, RIGHT, Y ) \ + { \ + GLint i, n = RIGHT-LEFT; \ + GLdepth zspan[MAX_WIDTH]; \ + if (n>0) { \ + for (i=0;iColor[pv][0], VB->Color[pv][1],\ + VB->Color[pv][2], VB->Color[pv][3],\ + GL_POLYGON ); \ + } \ + } + +#include "tritemp.h" +} + + + +/* + * Render a smooth-shaded RGBA triangle. + */ +static void smooth_rgba_triangle( GLcontext *ctx, + GLuint v0, GLuint v1, GLuint v2, GLuint pv ) +{ +#define INTERP_Z 1 +#define INTERP_RGB 1 +#define INTERP_ALPHA 1 + +#define INNER_LOOP( LEFT, RIGHT, Y ) \ + { \ + GLint i, n = RIGHT-LEFT; \ + GLdepth zspan[MAX_WIDTH]; \ + GLubyte red[MAX_WIDTH], green[MAX_WIDTH]; \ + GLubyte blue[MAX_WIDTH], alpha[MAX_WIDTH]; \ + if (n>0) { \ + for (i=0;iTexture.Current2D->Image[0]->Width; \ + GLfloat theight = (GLfloat) ctx->Texture.Current2D->Image[0]->Height;\ + GLint twidth_log2 = ctx->Texture.Current2D->Image[0]->WidthLog2; \ + GLubyte *texture = ctx->Texture.Current2D->Image[0]->Data; \ + GLint smask = ctx->Texture.Current2D->Image[0]->Width - 1; \ + GLint tmask = ctx->Texture.Current2D->Image[0]->Height - 1; + +#define INNER_LOOP( LEFT, RIGHT, Y ) \ + { \ + GLint i, n = RIGHT-LEFT; \ + GLubyte red[MAX_WIDTH], green[MAX_WIDTH]; \ + GLubyte blue[MAX_WIDTH], alpha[MAX_WIDTH]; \ + if (n>0) { \ + for (i=0;iDriver.WriteColorSpan)( ctx, n, LEFT, Y, \ + red, green, blue, alpha, NULL ); \ + } \ + } + +#include "tritemp.h" +} + + + +/* + * Render an RGB, GL_DECAL, textured triangle. + * Interpolate S,T, GL_LESS depth test, w/out mipmapping or + * perspective correction. + */ +static void simple_z_textured_triangle( GLcontext *ctx, GLuint v0, GLuint v1, + GLuint v2, GLuint pv ) +{ +#define INTERP_Z 1 +#define INTERP_ST 1 +#define S_SCALE twidth +#define T_SCALE theight +#define SETUP_CODE \ + GLfloat twidth = (GLfloat) ctx->Texture.Current2D->Image[0]->Width; \ + GLfloat theight = (GLfloat) ctx->Texture.Current2D->Image[0]->Height;\ + GLint twidth_log2 = ctx->Texture.Current2D->Image[0]->WidthLog2; \ + GLubyte *texture = ctx->Texture.Current2D->Image[0]->Data; \ + GLint smask = ctx->Texture.Current2D->Image[0]->Width - 1; \ + GLint tmask = ctx->Texture.Current2D->Image[0]->Height - 1; + +#define INNER_LOOP( LEFT, RIGHT, Y ) \ + { \ + GLint i, n = RIGHT-LEFT; \ + GLubyte red[MAX_WIDTH], green[MAX_WIDTH]; \ + GLubyte blue[MAX_WIDTH], alpha[MAX_WIDTH]; \ + GLubyte mask[MAX_WIDTH]; \ + if (n>0) { \ + for (i=0;iDriver.WriteColorSpan)( ctx, n, LEFT, Y, \ + red, green, blue, alpha, mask ); \ + } \ + } + +#include "tritemp.h" +} + + + +/* + * Render a smooth-shaded, textured, RGBA triangle. + * Interpolate S,T,U with perspective correction, w/out mipmapping. + * Note: we use texture coordinates S,T,U,V instead of S,T,R,Q because + * R is already used for red. + */ +static void general_textured_triangle( GLcontext *ctx, GLuint v0, GLuint v1, + GLuint v2, GLuint pv ) +{ +#define INTERP_Z 1 +#define INTERP_RGB 1 +#define INTERP_ALPHA 1 +#define INTERP_STW 1 +#define INTERP_UV 1 +#define SETUP_CODE \ + GLboolean flat_shade = (ctx->Light.ShadeModel==GL_FLAT); \ + GLint r, g, b, a; \ + if (flat_shade) { \ + r = VB->Color[pv][0]; \ + g = VB->Color[pv][1]; \ + b = VB->Color[pv][2]; \ + a = VB->Color[pv][3]; \ + } +#define INNER_LOOP( LEFT, RIGHT, Y ) \ + { \ + GLint i, n = RIGHT-LEFT; \ + GLdepth zspan[MAX_WIDTH]; \ + GLubyte red[MAX_WIDTH], green[MAX_WIDTH]; \ + GLubyte blue[MAX_WIDTH], alpha[MAX_WIDTH]; \ + GLfloat s[MAX_WIDTH], t[MAX_WIDTH], u[MAX_WIDTH]; \ + if (n>0) { \ + if (flat_shade) { \ + for (i=0;iLight.ShadeModel==GL_FLAT); \ + GLint r, g, b, a; \ + GLfloat twidth, theight; \ + if (ctx->Texture.Enabled & TEXTURE_2D) { \ + twidth = (GLfloat) ctx->Texture.Current2D->Image[0]->Width; \ + theight = (GLfloat) ctx->Texture.Current2D->Image[0]->Height; \ + } \ + else { \ + twidth = (GLfloat) ctx->Texture.Current1D->Image[0]->Width; \ + theight = 1.0; \ + } \ + if (flat_shade) { \ + r = VB->Color[pv][0]; \ + g = VB->Color[pv][1]; \ + b = VB->Color[pv][2]; \ + a = VB->Color[pv][3]; \ + } + +#define INNER_LOOP( LEFT, RIGHT, Y ) \ + { \ + GLint i, n = RIGHT-LEFT; \ + GLdepth zspan[MAX_WIDTH]; \ + GLubyte red[MAX_WIDTH], green[MAX_WIDTH]; \ + GLubyte blue[MAX_WIDTH], alpha[MAX_WIDTH]; \ + GLfloat s[MAX_WIDTH], t[MAX_WIDTH], u[MAX_WIDTH]; \ + DEFARRAY(GLfloat,lambda,MAX_WIDTH); \ + if (n>0) { \ + if (flat_shade) { \ + for (i=0;iVisual->RGBAflag; + + if (ctx->RenderMode==GL_RENDER) { + if (ctx->NoRaster) { + ctx->Driver.TriangleFunc = null_triangle; + return; + } + if (ctx->Driver.TriangleFunc) { + /* Device driver will draw triangles. */ + } + else if (ctx->Texture.Enabled + && ctx->Texture.Current + && ctx->Texture.Current->Complete) { + if ( (ctx->Texture.Enabled==TEXTURE_2D) + && ctx->Texture.Current2D->MinFilter==GL_NEAREST + && ctx->Texture.Current2D->MagFilter==GL_NEAREST + && ctx->Texture.Current2D->WrapS==GL_REPEAT + && ctx->Texture.Current2D->WrapT==GL_REPEAT + && ctx->Texture.Current2D->Image[0]->Format==GL_RGB + && ctx->Texture.Current2D->Image[0]->Border==0 + && (ctx->Texture.EnvMode==GL_DECAL + || ctx->Texture.EnvMode==GL_REPLACE) + && ctx->Hint.PerspectiveCorrection==GL_FASTEST + && ctx->TextureMatrixType==MATRIX_IDENTITY + && ((ctx->RasterMask==DEPTH_BIT + && ctx->Depth.Func==GL_LESS + && ctx->Depth.Mask==GL_TRUE) + || ctx->RasterMask==0) + && ctx->Polygon.StippleFlag==GL_FALSE + && ctx->Visual->EightBitColor) { + if (ctx->RasterMask==DEPTH_BIT) { + ctx->Driver.TriangleFunc = simple_z_textured_triangle; + } + else { + ctx->Driver.TriangleFunc = simple_textured_triangle; + } + } + else { + GLboolean needLambda = GL_TRUE; + /* if mag filter == min filter we're not mipmapping */ + if (ctx->Texture.Enabled & TEXTURE_2D) { + if (ctx->Texture.Current2D->MinFilter== + ctx->Texture.Current2D->MagFilter) { + needLambda = GL_FALSE; + } + } + else if (ctx->Texture.Enabled & TEXTURE_1D) { + if (ctx->Texture.Current1D->MinFilter== + ctx->Texture.Current1D->MagFilter) { + needLambda = GL_FALSE; + } + } + if (needLambda) + ctx->Driver.TriangleFunc = lambda_textured_triangle; + else + ctx->Driver.TriangleFunc = general_textured_triangle; + } + } + else { + if (ctx->Light.ShadeModel==GL_SMOOTH) { + /* smooth shaded, no texturing, stippled or some raster ops */ + if (rgbmode) + ctx->Driver.TriangleFunc = smooth_rgba_triangle; + else + ctx->Driver.TriangleFunc = smooth_ci_triangle; + } + else { + /* flat shaded, no texturing, stippled or some raster ops */ + if (rgbmode) + ctx->Driver.TriangleFunc = flat_rgba_triangle; + else + ctx->Driver.TriangleFunc = flat_ci_triangle; + } + } + } + else if (ctx->RenderMode==GL_FEEDBACK) { + ctx->Driver.TriangleFunc = feedback_triangle; + } + else { + /* GL_SELECT mode */ + ctx->Driver.TriangleFunc = select_triangle; + } +} + diff --git a/dll/opengl/mesa/triangle.h b/dll/opengl/mesa/triangle.h new file mode 100644 index 00000000000..c52b89e1af0 --- /dev/null +++ b/dll/opengl/mesa/triangle.h @@ -0,0 +1,43 @@ +/* $Id: triangle.h,v 1.1 1996/09/13 01:38:16 brianp Exp $ */ + +/* + * Mesa 3-D graphics library + * Version: 2.0 + * Copyright (C) 1995-1996 Brian Paul + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Library General Public + * License as published by the Free Software Foundation; either + * version 2 of the License, or (at your option) any later version. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Library General Public License for more details. + * + * You should have received a copy of the GNU Library General Public + * License along with this library; if not, write to the Free + * Software Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. + */ + + +/* + * $Log: triangle.h,v $ + * Revision 1.1 1996/09/13 01:38:16 brianp + * Initial revision + * + */ + + +#ifndef TRIANGLES_H +#define TRIANGLES_H + + +#include "types.h" + + +extern void gl_set_triangle_function( GLcontext *ctx ); + + +#endif + diff --git a/dll/opengl/mesa/tritemp.h b/dll/opengl/mesa/tritemp.h new file mode 100644 index 00000000000..8b95c26bd53 --- /dev/null +++ b/dll/opengl/mesa/tritemp.h @@ -0,0 +1,874 @@ +/* $Id: tritemp.h,v 1.17 1998/01/16 03:46:07 brianp Exp $ */ + +/* + * Mesa 3-D graphics library + * Version: 2.6 + * Copyright (C) 1995-1997 Brian Paul + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Library General Public + * License as published by the Free Software Foundation; either + * version 2 of the License, or (at your option) any later version. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Library General Public License for more details. + * + * You should have received a copy of the GNU Library General Public + * License along with this library; if not, write to the Free + * Software Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. + */ + + +/* + * $Log: tritemp.h,v $ + * Revision 1.17 1998/01/16 03:46:07 brianp + * fixed a few Windows compilation warnings (Theodore Jump) + * + * Revision 1.16 1997/09/18 01:08:10 brianp + * fixed S_SCALE / T_SCALE mix-up + * + * Revision 1.15 1997/08/22 01:53:03 brianp + * another attempt at fixing under/overflow errors + * + * Revision 1.14 1997/08/13 02:10:13 brianp + * added code to prevent over/underflow (Guido Jansen, Magnus Lundin) + * + * Revision 1.13 1997/06/20 02:52:49 brianp + * changed color components from GLfixed to GLubyte + * + * Revision 1.12 1997/03/14 00:25:02 brianp + * fixed unitialized memory read, contributed by Tom Schmidt + * + * Revision 1.11 1997/02/09 18:51:10 brianp + * fixed typo in texture R interpolation code + * + * Revision 1.10 1996/12/20 23:12:23 brianp + * another attempt at preventing color interpolation over/underflow + * + * Revision 1.9 1996/12/18 20:38:25 brianp + * commented out unused zp declaration + * + * Revision 1.8 1996/12/12 22:37:49 brianp + * projective textures didn't work right + * + * Revision 1.7 1996/11/02 06:17:37 brianp + * fixed some float/int roundoff and over/underflow errors (hopefully) + * + * Revision 1.6 1996/10/01 04:13:09 brianp + * fixed Z interpolation for >16-bit depth buffer + * added color underflow error check + * + * Revision 1.5 1996/09/27 01:32:59 brianp + * removed unused variables + * + * Revision 1.4 1996/09/18 01:03:43 brianp + * tightened threshold for culling by area + * + * Revision 1.3 1996/09/15 14:19:16 brianp + * now use GLframebuffer and GLvisual + * + * Revision 1.2 1996/09/14 06:41:38 brianp + * perspective correct texture code wasn't sub-pixel accurate (Doug Rabson) + * + * Revision 1.1 1996/09/13 01:38:16 brianp + * Initial revision + * + */ + + +/* + * Triangle Rasterizer Template + * + * This file is #include'd to generate custom triangle rasterizers. + * + * The following macros may be defined to indicate what auxillary information + * must be interplated across the triangle: + * INTERP_Z - if defined, interpolate Z values + * INTERP_RGB - if defined, interpolate RGB values + * INTERP_ALPHA - if defined, interpolate Alpha values + * INTERP_INDEX - if defined, interpolate color index values + * INTERP_ST - if defined, interpolate integer ST texcoords + * (fast, simple 2-D texture mapping) + * INTERP_STW - if defined, interpolate float ST texcoords and W + * (2-D texture maps with perspective correction) + * INTERP_UV - if defined, interpolate float UV texcoords too + * (for 3-D, 4-D? texture maps) + * + * When one can directly address pixels in the color buffer the following + * macros can be defined and used to compute pixel addresses during + * rasterization (see pRow): + * PIXEL_TYPE - the datatype of a pixel (GLubyte, GLushort, GLuint) + * BYTES_PER_ROW - number of bytes per row in the color buffer + * PIXEL_ADDRESS(X,Y) - returns the address of pixel at (X,Y) where + * Y==0 at bottom of screen and increases upward. + * + * Optionally, one may provide one-time setup code per triangle: + * SETUP_CODE - code which is to be executed once per triangle + * + * The following macro MUST be defined: + * INNER_LOOP(LEFT,RIGHT,Y) - code to write a span of pixels. + * Something like: + * + * for (x=LEFT; xfy to fsy, scaled */ + GLint lines; /* number of lines to be sampled on this edge */ + GLfixed fx0; /* fixed pt X of lower endpoint */ + } EdgeT; + + struct vertex_buffer *VB = ctx->VB; + EdgeT eMaj, eTop, eBot; + GLfloat oneOverArea; + int vMin, vMid, vMax; /* vertex indexes: Y(vMin)<=Y(vMid)<=Y(vMax) */ + + /* find the order of the 3 vertices along the Y axis */ + { + GLfloat y0 = VB->Win[v0][1]; + GLfloat y1 = VB->Win[v1][1]; + GLfloat y2 = VB->Win[v2][1]; + + if (y0<=y1) { + if (y1<=y2) { + vMin = v0; vMid = v1; vMax = v2; /* y0<=y1<=y2 */ + } + else if (y2<=y0) { + vMin = v2; vMid = v0; vMax = v1; /* y2<=y0<=y1 */ + } + else { + vMin = v0; vMid = v2; vMax = v1; /* y0<=y2<=y1 */ + } + } + else { + if (y0<=y2) { + vMin = v1; vMid = v0; vMax = v2; /* y1<=y0<=y2 */ + } + else if (y2<=y1) { + vMin = v2; vMid = v1; vMax = v0; /* y2<=y1<=y0 */ + } + else { + vMin = v1; vMid = v2; vMax = v0; /* y1<=y2<=y0 */ + } + } + } + + /* vertex/edge relationship */ + eMaj.v0 = vMin; eMaj.v1 = vMax; /*TODO: .v1's not needed */ + eTop.v0 = vMid; eTop.v1 = vMax; + eBot.v0 = vMin; eBot.v1 = vMid; + + /* compute deltas for each edge: vertex[v1] - vertex[v0] */ + eMaj.dx = VB->Win[vMax][0] - VB->Win[vMin][0]; + eMaj.dy = VB->Win[vMax][1] - VB->Win[vMin][1]; + eTop.dx = VB->Win[vMax][0] - VB->Win[vMid][0]; + eTop.dy = VB->Win[vMax][1] - VB->Win[vMid][1]; + eBot.dx = VB->Win[vMid][0] - VB->Win[vMin][0]; + eBot.dy = VB->Win[vMid][1] - VB->Win[vMin][1]; + + /* compute oneOverArea */ + { + GLfloat area = eMaj.dx * eBot.dy - eBot.dx * eMaj.dy; + if (area>-0.05f && area<0.05f) { + return; /* very small; CULLED */ + } + oneOverArea = 1.0F / area; + } + + /* Edge setup. For a triangle strip these could be reused... */ + { + /* fixed point Y coordinates */ + GLfixed vMin_fx = FloatToFixed(VB->Win[vMin][0] + 0.5F); + GLfixed vMin_fy = FloatToFixed(VB->Win[vMin][1] - 0.5F); + GLfixed vMid_fx = FloatToFixed(VB->Win[vMid][0] + 0.5F); + GLfixed vMid_fy = FloatToFixed(VB->Win[vMid][1] - 0.5F); + GLfixed vMax_fy = FloatToFixed(VB->Win[vMax][1] - 0.5F); + + eMaj.fsy = FixedCeil(vMin_fy); + eMaj.lines = FixedToInt(vMax_fy + FIXED_ONE - FIXED_EPSILON - eMaj.fsy); + if (eMaj.lines > 0) { + GLfloat dxdy = eMaj.dx / eMaj.dy; + eMaj.fdxdy = SignedFloatToFixed(dxdy); + eMaj.adjy = (GLfloat) (eMaj.fsy - vMin_fy); /* SCALED! */ + eMaj.fx0 = vMin_fx; + eMaj.fsx = eMaj.fx0 + (GLfixed) (eMaj.adjy * dxdy); + } + else { + return; /*CULLED*/ + } + + eTop.fsy = FixedCeil(vMid_fy); + eTop.lines = FixedToInt(vMax_fy + FIXED_ONE - FIXED_EPSILON - eTop.fsy); + if (eTop.lines > 0) { + GLfloat dxdy = eTop.dx / eTop.dy; + eTop.fdxdy = SignedFloatToFixed(dxdy); + eTop.adjy = (GLfloat) (eTop.fsy - vMid_fy); /* SCALED! */ + eTop.fx0 = vMid_fx; + eTop.fsx = eTop.fx0 + (GLfixed) (eTop.adjy * dxdy); + } + + eBot.fsy = FixedCeil(vMin_fy); + eBot.lines = FixedToInt(vMid_fy + FIXED_ONE - FIXED_EPSILON - eBot.fsy); + if (eBot.lines > 0) { + GLfloat dxdy = eBot.dx / eBot.dy; + eBot.fdxdy = SignedFloatToFixed(dxdy); + eBot.adjy = (GLfloat) (eBot.fsy - vMin_fy); /* SCALED! */ + eBot.fx0 = vMin_fx; + eBot.fsx = eBot.fx0 + (GLfixed) (eBot.adjy * dxdy); + } + } + + /* + * Conceptually, we view a triangle as two subtriangles + * separated by a perfectly horizontal line. The edge that is + * intersected by this line is one with maximal absolute dy; we + * call it a ``major'' edge. The other two edges are the + * ``top'' edge (for the upper subtriangle) and the ``bottom'' + * edge (for the lower subtriangle). If either of these two + * edges is horizontal or very close to horizontal, the + * corresponding subtriangle might cover zero sample points; + * we take care to handle such cases, for performance as well + * as correctness. + * + * By stepping rasterization parameters along the major edge, + * we can avoid recomputing them at the discontinuity where + * the top and bottom edges meet. However, this forces us to + * be able to scan both left-to-right and right-to-left. + * Also, we must determine whether the major edge is at the + * left or right side of the triangle. We do this by + * computing the magnitude of the cross-product of the major + * and top edges. Since this magnitude depends on the sine of + * the angle between the two edges, its sign tells us whether + * we turn to the left or to the right when travelling along + * the major edge to the top edge, and from this we infer + * whether the major edge is on the left or the right. + * + * Serendipitously, this cross-product magnitude is also a + * value we need to compute the iteration parameter + * derivatives for the triangle, and it can be used to perform + * backface culling because its sign tells us whether the + * triangle is clockwise or counterclockwise. In this code we + * refer to it as ``area'' because it's also proportional to + * the pixel area of the triangle. + */ + + { + GLint ltor; /* true if scanning left-to-right */ +#if INTERP_Z + GLfloat dzdx, dzdy; GLfixed fdzdx; +#endif +#if INTERP_RGB + GLfloat drdx, drdy; GLfixed fdrdx; + GLfloat dgdx, dgdy; GLfixed fdgdx; + GLfloat dbdx, dbdy; GLfixed fdbdx; +#endif +#if INTERP_ALPHA + GLfloat dadx, dady; GLfixed fdadx; +#endif +#if INTERP_INDEX + GLfloat didx, didy; GLfixed fdidx; +#endif +#if INTERP_ST + GLfloat dsdx, dsdy; GLfixed fdsdx; + GLfloat dtdx, dtdy; GLfixed fdtdx; +#endif +#if INTERP_STW + GLfloat dsdx, dsdy; + GLfloat dtdx, dtdy; + GLfloat dwdx, dwdy; +#endif +#if INTERP_UV + GLfloat dudx, dudy; + GLfloat dvdx, dvdy; +#endif + + /* + * Execute user-supplied setup code + */ +#ifdef SETUP_CODE + SETUP_CODE +#endif + + ltor = (oneOverArea < 0.0F); + + /* compute d?/dx and d?/dy derivatives */ +#if INTERP_Z + { + GLfloat eMaj_dz, eBot_dz; + eMaj_dz = VB->Win[vMax][2] - VB->Win[vMin][2]; + eBot_dz = VB->Win[vMid][2] - VB->Win[vMin][2]; + dzdx = oneOverArea * (eMaj_dz * eBot.dy - eMaj.dy * eBot_dz); + if (dzdx>DEPTH_SCALE || dzdx<-DEPTH_SCALE) { + /* probably a sliver triangle */ + dzdx = 0.0; + dzdy = 0.0; + } + else { + dzdy = oneOverArea * (eMaj.dx * eBot_dz - eMaj_dz * eBot.dx); + } + fdzdx = (GLint) dzdx; + } +#endif +#if INTERP_RGB + { + GLfloat eMaj_dr, eBot_dr; + eMaj_dr = (GLint) VB->Color[vMax][0] - (GLint) VB->Color[vMin][0]; + eBot_dr = (GLint) VB->Color[vMid][0] - (GLint) VB->Color[vMin][0]; + drdx = oneOverArea * (eMaj_dr * eBot.dy - eMaj.dy * eBot_dr); + fdrdx = SignedFloatToFixed(drdx); + drdy = oneOverArea * (eMaj.dx * eBot_dr - eMaj_dr * eBot.dx); + } + { + GLfloat eMaj_dg, eBot_dg; + eMaj_dg = (GLint) VB->Color[vMax][1] - (GLint) VB->Color[vMin][1]; + eBot_dg = (GLint) VB->Color[vMid][1] - (GLint) VB->Color[vMin][1]; + dgdx = oneOverArea * (eMaj_dg * eBot.dy - eMaj.dy * eBot_dg); + fdgdx = SignedFloatToFixed(dgdx); + dgdy = oneOverArea * (eMaj.dx * eBot_dg - eMaj_dg * eBot.dx); + } + { + GLfloat eMaj_db, eBot_db; + eMaj_db = (GLint) VB->Color[vMax][2] - (GLint) VB->Color[vMin][2]; + eBot_db = (GLint) VB->Color[vMid][2] - (GLint) VB->Color[vMin][2]; + dbdx = oneOverArea * (eMaj_db * eBot.dy - eMaj.dy * eBot_db); + fdbdx = SignedFloatToFixed(dbdx); + dbdy = oneOverArea * (eMaj.dx * eBot_db - eMaj_db * eBot.dx); + } +#endif +#if INTERP_ALPHA + { + GLfloat eMaj_da, eBot_da; + eMaj_da = (GLint) VB->Color[vMax][3] - (GLint) VB->Color[vMin][3]; + eBot_da = (GLint) VB->Color[vMid][3] - (GLint) VB->Color[vMin][3]; + dadx = oneOverArea * (eMaj_da * eBot.dy - eMaj.dy * eBot_da); + fdadx = SignedFloatToFixed(dadx); + dady = oneOverArea * (eMaj.dx * eBot_da - eMaj_da * eBot.dx); + } +#endif +#if INTERP_INDEX + { + GLfloat eMaj_di, eBot_di; + eMaj_di = (GLint) VB->Index[vMax] - (GLint) VB->Index[vMin]; + eBot_di = (GLint) VB->Index[vMid] - (GLint) VB->Index[vMin]; + didx = oneOverArea * (eMaj_di * eBot.dy - eMaj.dy * eBot_di); + fdidx = SignedFloatToFixed(didx); + didy = oneOverArea * (eMaj.dx * eBot_di - eMaj_di * eBot.dx); + } +#endif +#if INTERP_ST + { + GLfloat eMaj_ds, eBot_ds; + eMaj_ds = (VB->TexCoord[vMax][0] - VB->TexCoord[vMin][0]) * S_SCALE; + eBot_ds = (VB->TexCoord[vMid][0] - VB->TexCoord[vMin][0]) * S_SCALE; + dsdx = oneOverArea * (eMaj_ds * eBot.dy - eMaj.dy * eBot_ds); + fdsdx = SignedFloatToFixed(dsdx); + dsdy = oneOverArea * (eMaj.dx * eBot_ds - eMaj_ds * eBot.dx); + } + { + GLfloat eMaj_dt, eBot_dt; + eMaj_dt = (VB->TexCoord[vMax][1] - VB->TexCoord[vMin][1]) * T_SCALE; + eBot_dt = (VB->TexCoord[vMid][1] - VB->TexCoord[vMin][1]) * T_SCALE; + dtdx = oneOverArea * (eMaj_dt * eBot.dy - eMaj.dy * eBot_dt); + fdtdx = SignedFloatToFixed(dtdx); + dtdy = oneOverArea * (eMaj.dx * eBot_dt - eMaj_dt * eBot.dx); + } +#endif +#if INTERP_STW + { + GLfloat wMax = 1.0F / VB->Clip[vMax][3]; + GLfloat wMin = 1.0F / VB->Clip[vMin][3]; + GLfloat wMid = 1.0F / VB->Clip[vMid][3]; + GLfloat eMaj_dw, eBot_dw; + GLfloat eMaj_ds, eBot_ds; + GLfloat eMaj_dt, eBot_dt; +#if INTERP_UV + GLfloat eMaj_du, eBot_du; + GLfloat eMaj_dv, eBot_dv; +#endif + eMaj_dw = wMax - wMin; + eBot_dw = wMid - wMin; + dwdx = oneOverArea * (eMaj_dw * eBot.dy - eMaj.dy * eBot_dw); + dwdy = oneOverArea * (eMaj.dx * eBot_dw - eMaj_dw * eBot.dx); + + eMaj_ds = VB->TexCoord[vMax][0]*wMax - VB->TexCoord[vMin][0]*wMin; + eBot_ds = VB->TexCoord[vMid][0]*wMid - VB->TexCoord[vMin][0]*wMin; + dsdx = oneOverArea * (eMaj_ds * eBot.dy - eMaj.dy * eBot_ds); + dsdy = oneOverArea * (eMaj.dx * eBot_ds - eMaj_ds * eBot.dx); + + eMaj_dt = VB->TexCoord[vMax][1]*wMax - VB->TexCoord[vMin][1]*wMin; + eBot_dt = VB->TexCoord[vMid][1]*wMid - VB->TexCoord[vMin][1]*wMin; + dtdx = oneOverArea * (eMaj_dt * eBot.dy - eMaj.dy * eBot_dt); + dtdy = oneOverArea * (eMaj.dx * eBot_dt - eMaj_dt * eBot.dx); +#if INTERP_UV + eMaj_du = VB->TexCoord[vMax][2]*wMax - VB->TexCoord[vMin][2]*wMin; + eBot_du = VB->TexCoord[vMid][2]*wMid - VB->TexCoord[vMin][2]*wMin; + dudx = oneOverArea * (eMaj_du * eBot.dy - eMaj.dy * eBot_du); + dudy = oneOverArea * (eMaj.dx * eBot_du - eMaj_du * eBot.dx); + + /* Note: don't divide V component by W */ + eMaj_dv = VB->TexCoord[vMax][3] - VB->TexCoord[vMin][3]; + eBot_dv = VB->TexCoord[vMid][3] - VB->TexCoord[vMin][3]; + dvdx = oneOverArea * (eMaj_dv * eBot.dy - eMaj.dy * eBot_dv); + dvdy = oneOverArea * (eMaj.dx * eBot_dv - eMaj_dv * eBot.dx); +#endif + } +#endif + + /* + * We always sample at pixel centers. However, we avoid + * explicit half-pixel offsets in this code by incorporating + * the proper offset in each of x and y during the + * transformation to window coordinates. + * + * We also apply the usual rasterization rules to prevent + * cracks and overlaps. A pixel is considered inside a + * subtriangle if it meets all of four conditions: it is on or + * to the right of the left edge, strictly to the left of the + * right edge, on or below the top edge, and strictly above + * the bottom edge. (Some edges may be degenerate.) + * + * The following discussion assumes left-to-right scanning + * (that is, the major edge is on the left); the right-to-left + * case is a straightforward variation. + * + * We start by finding the half-integral y coordinate that is + * at or below the top of the triangle. This gives us the + * first scan line that could possibly contain pixels that are + * inside the triangle. + * + * Next we creep down the major edge until we reach that y, + * and compute the corresponding x coordinate on the edge. + * Then we find the half-integral x that lies on or just + * inside the edge. This is the first pixel that might lie in + * the interior of the triangle. (We won't know for sure + * until we check the other edges.) + * + * As we rasterize the triangle, we'll step down the major + * edge. For each step in y, we'll move an integer number + * of steps in x. There are two possible x step sizes, which + * we'll call the ``inner'' step (guaranteed to land on the + * edge or inside it) and the ``outer'' step (guaranteed to + * land on the edge or outside it). The inner and outer steps + * differ by one. During rasterization we maintain an error + * term that indicates our distance from the true edge, and + * select either the inner step or the outer step, whichever + * gets us to the first pixel that falls inside the triangle. + * + * All parameters (z, red, etc.) as well as the buffer + * addresses for color and z have inner and outer step values, + * so that we can increment them appropriately. This method + * eliminates the need to adjust parameters by creeping a + * sub-pixel amount into the triangle at each scanline. + */ + + { + int subTriangle; + GLfixed fx, fxLeftEdge, fxRightEdge, fdxLeftEdge, fdxRightEdge; + GLfixed fdxOuter; + int idxOuter; + float dxOuter; + GLfixed fError, fdError; + float adjx, adjy; + GLfixed fy; + int iy; +#ifdef PIXEL_ADDRESS + PIXEL_TYPE *pRow; + int dPRowOuter, dPRowInner; /* offset in bytes */ +#endif +#if INTERP_Z + GLdepth *zRow; + int dZRowOuter, dZRowInner; /* offset in bytes */ + GLfixed fz, fdzOuter, fdzInner; +#endif +#if INTERP_RGB + GLfixed fr, fdrOuter, fdrInner; + GLfixed fg, fdgOuter, fdgInner; + GLfixed fb, fdbOuter, fdbInner; +#endif +#if INTERP_ALPHA + GLfixed fa, fdaOuter, fdaInner; +#endif +#if INTERP_INDEX + GLfixed fi, fdiOuter, fdiInner; +#endif +#if INTERP_ST + GLfixed fs, fdsOuter, fdsInner; + GLfixed ft, fdtOuter, fdtInner; +#endif +#if INTERP_STW + GLfloat sLeft, dsOuter, dsInner; + GLfloat tLeft, dtOuter, dtInner; + GLfloat wLeft, dwOuter, dwInner; +#endif +#if INTERP_UV + GLfloat uLeft, duOuter, duInner; + GLfloat vLeft, dvOuter, dvInner; +#endif + + for (subTriangle=0; subTriangle<=1; subTriangle++) { + EdgeT *eLeft, *eRight; + int setupLeft, setupRight; + int lines; + + if (subTriangle==0) { + /* bottom half */ + if (ltor) { + eLeft = &eMaj; + eRight = &eBot; + lines = eRight->lines; + setupLeft = 1; + setupRight = 1; + } + else { + eLeft = &eBot; + eRight = &eMaj; + lines = eLeft->lines; + setupLeft = 1; + setupRight = 1; + } + } + else { + /* top half */ + if (ltor) { + eLeft = &eMaj; + eRight = &eTop; + lines = eRight->lines; + setupLeft = 0; + setupRight = 1; + } + else { + eLeft = &eTop; + eRight = &eMaj; + lines = eLeft->lines; + setupLeft = 1; + setupRight = 0; + } + if (lines==0) return; + } + + if (setupLeft && eLeft->lines>0) { + GLint vLower; + GLfixed fsx = eLeft->fsx; + fx = FixedCeil(fsx); + fError = fx - fsx - FIXED_ONE; + fxLeftEdge = fsx - FIXED_EPSILON; + fdxLeftEdge = eLeft->fdxdy; + fdxOuter = FixedFloor(fdxLeftEdge - FIXED_EPSILON); + fdError = fdxOuter - fdxLeftEdge + FIXED_ONE; + idxOuter = FixedToInt(fdxOuter); + dxOuter = (float) idxOuter; + + fy = eLeft->fsy; + iy = FixedToInt(fy); + + adjx = (float)(fx - eLeft->fx0); /* SCALED! */ + adjy = eLeft->adjy; /* SCALED! */ + + vLower = eLeft->v0; + +#ifdef PIXEL_ADDRESS + { + pRow = PIXEL_ADDRESS( FixedToInt(fxLeftEdge), iy ); + dPRowOuter = -((int)BYTES_PER_ROW) + idxOuter * sizeof(PIXEL_TYPE); + /* negative because Y=0 at bottom and increases upward */ + } +#endif + /* + * Now we need the set of parameter (z, color, etc.) values at + * the point (fx, fy). This gives us properly-sampled parameter + * values that we can step from pixel to pixel. Furthermore, + * although we might have intermediate results that overflow + * the normal parameter range when we step temporarily outside + * the triangle, we shouldn't overflow or underflow for any + * pixel that's actually inside the triangle. + */ + +#if INTERP_Z + { + GLfloat z0; + z0 = VB->Win[vLower][2] + ctx->PolygonZoffset; + + /* interpolate depth values exactly */ + fz = (GLint) (z0 + dzdx*FixedToFloat(adjx) + dzdy*FixedToFloat(adjy)); + fdzOuter = (GLint) (dzdy + dxOuter * dzdx); + zRow = Z_ADDRESS( ctx, FixedToInt(fxLeftEdge), iy ); + dZRowOuter = (ctx->Buffer->Width + idxOuter) * sizeof(GLdepth); + } +#endif +#if INTERP_RGB + fr = (GLfixed)(IntToFixed(VB->Color[vLower][0]) + drdx * adjx + drdy * adjy) + + FIXED_HALF; + fdrOuter = SignedFloatToFixed(drdy + dxOuter * drdx); + + fg = (GLfixed)(IntToFixed(VB->Color[vLower][1]) + dgdx * adjx + dgdy * adjy) + + FIXED_HALF; + fdgOuter = SignedFloatToFixed(dgdy + dxOuter * dgdx); + + fb = (GLfixed)(IntToFixed(VB->Color[vLower][2]) + dbdx * adjx + dbdy * adjy) + + FIXED_HALF; + fdbOuter = SignedFloatToFixed(dbdy + dxOuter * dbdx); +#endif +#if INTERP_ALPHA + fa = (GLfixed)(IntToFixed(VB->Color[vLower][3]) + dadx * adjx + dady * adjy) + + FIXED_HALF; + fdaOuter = SignedFloatToFixed(dady + dxOuter * dadx); +#endif +#if INTERP_INDEX + fi = (GLfixed)(VB->Index[vLower] * FIXED_SCALE + didx * adjx + + didy * adjy) + FIXED_HALF; + fdiOuter = SignedFloatToFixed(didy + dxOuter * didx); +#endif +#if INTERP_ST + { + GLfloat s0, t0; + s0 = VB->TexCoord[vLower][0] * S_SCALE; + fs = (GLfixed)(s0 * FIXED_SCALE + dsdx * adjx + dsdy * adjy) + FIXED_HALF; + fdsOuter = SignedFloatToFixed(dsdy + dxOuter * dsdx); + t0 = VB->TexCoord[vLower][1] * T_SCALE; + ft = (GLfixed)(t0 * FIXED_SCALE + dtdx * adjx + dtdy * adjy) + FIXED_HALF; + fdtOuter = SignedFloatToFixed(dtdy + dxOuter * dtdx); + } +#endif +#if INTERP_STW + { + GLfloat w0 = 1.0F / VB->Clip[vLower][3]; + GLfloat s0, t0, u0, v0; + wLeft = w0 + (dwdx * adjx + dwdy * adjy) * (1.0F/FIXED_SCALE); + dwOuter = dwdy + dxOuter * dwdx; + s0 = VB->TexCoord[vLower][0] * w0; + sLeft = s0 + (dsdx * adjx + dsdy * adjy) * (1.0F/FIXED_SCALE); + dsOuter = dsdy + dxOuter * dsdx; + t0 = VB->TexCoord[vLower][1] * w0; + tLeft = t0 + (dtdx * adjx + dtdy * adjy) * (1.0F/FIXED_SCALE); + dtOuter = dtdy + dxOuter * dtdx; +#if INTERP_UV + u0 = VB->TexCoord[vLower][2] * w0; + uLeft = u0 + (dudx * adjx + dudy * adjy) * (1.0F/FIXED_SCALE); + duOuter = dudy + dxOuter * dudx; + /* Note: don't divide V component by W */ + v0 = VB->TexCoord[vLower][3]; + vLeft = v0 + (dvdx * adjx + dvdy * adjy) * (1.0F/FIXED_SCALE); + dvOuter = dvdy + dxOuter * dvdx; +#endif + } +#endif + + } /*if setupLeft*/ + + + if (setupRight && eRight->lines>0) { + fxRightEdge = eRight->fsx - FIXED_EPSILON; + fdxRightEdge = eRight->fdxdy; + } + + if (lines==0) { + continue; + } + + + /* Rasterize setup */ +#ifdef PIXEL_ADDRESS + dPRowInner = dPRowOuter + sizeof(PIXEL_TYPE); +#endif +#if INTERP_Z + dZRowInner = dZRowOuter + sizeof(GLdepth); + fdzInner = fdzOuter + fdzdx; +#endif +#if INTERP_RGB + fdrInner = fdrOuter + fdrdx; + fdgInner = fdgOuter + fdgdx; + fdbInner = fdbOuter + fdbdx; +#endif +#if INTERP_ALPHA + fdaInner = fdaOuter + fdadx; +#endif +#if INTERP_INDEX + fdiInner = fdiOuter + fdidx; +#endif +#if INTERP_ST + fdsInner = fdsOuter + fdsdx; + fdtInner = fdtOuter + fdtdx; +#endif +#if INTERP_STW + dwInner = dwOuter + dwdx; + dsInner = dsOuter + dsdx; + dtInner = dtOuter + dtdx; +#if INTERP_UV + duInner = duOuter + dudx; + dvInner = dvOuter + dvdx; +#endif +#endif + + while (lines>0) { + /* initialize the span interpolants to the leftmost value */ + /* ff = fixed-pt fragment */ +#if INTERP_Z + GLfixed ffz = fz; + /*GLdepth *zp = zRow;*/ +#endif +#if INTERP_RGB + GLfixed ffr = fr, ffg = fg, ffb = fb; +#endif +#if INTERP_ALPHA + GLfixed ffa = fa; +#endif +#if INTERP_INDEX + GLfixed ffi = fi; +#endif +#if INTERP_ST + GLfixed ffs = fs, fft = ft; +#endif +#if INTERP_STW + GLfloat ss = sLeft, tt = tLeft, ww = wLeft; +#endif +#if INTERP_UV + GLfloat uu = uLeft, vv = vLeft; +#endif + GLint left = FixedToInt(fxLeftEdge); + GLint right = FixedToInt(fxRightEdge); + +#if INTERP_RGB + { + /* need this to accomodate round-off errors */ + GLfixed ffrend = ffr+(right-left-1)*fdrdx; + GLfixed ffgend = ffg+(right-left-1)*fdgdx; + GLfixed ffbend = ffb+(right-left-1)*fdbdx; + if (ffrend<0) ffr -= ffrend; + if (ffgend<0) ffg -= ffgend; + if (ffbend<0) ffb -= ffbend; + if (ffr<0) ffr = 0; + if (ffg<0) ffg = 0; + if (ffb<0) ffb = 0; + } +#endif +#if INTERP_ALPHA + { + GLfixed ffaend = ffa+(right-left-1)*fdadx; + if (ffaend<0) ffa -= ffaend; + if (ffa<0) ffa = 0; + } +#endif +#if INTERP_INDEX + if (ffi<0) ffi = 0; +#endif + + INNER_LOOP( left, right, iy ); + + /* + * Advance to the next scan line. Compute the + * new edge coordinates, and adjust the + * pixel-center x coordinate so that it stays + * on or inside the major edge. + */ + iy++; + lines--; + + fxLeftEdge += fdxLeftEdge; + fxRightEdge += fdxRightEdge; + + + fError += fdError; + if (fError >= 0) { + fError -= FIXED_ONE; +#ifdef PIXEL_ADDRESS + pRow = (PIXEL_TYPE*) ((GLubyte*)pRow + dPRowOuter); +#endif +#if INTERP_Z + zRow = (GLdepth*) ((GLubyte*)zRow + dZRowOuter); + fz += fdzOuter; +#endif +#if INTERP_RGB + fr += fdrOuter; fg += fdgOuter; fb += fdbOuter; +#endif +#if INTERP_ALPHA + fa += fdaOuter; +#endif +#if INTERP_INDEX + fi += fdiOuter; +#endif +#if INTERP_ST + fs += fdsOuter; ft += fdtOuter; +#endif +#if INTERP_STW + sLeft += dsOuter; + tLeft += dtOuter; + wLeft += dwOuter; +#endif +#if INTERP_UV + uLeft += duOuter; + vLeft += dvOuter; +#endif + } + else { +#ifdef PIXEL_ADDRESS + pRow = (PIXEL_TYPE*) ((GLubyte*)pRow + dPRowInner); +#endif +#if INTERP_Z + zRow = (GLdepth*) ((GLubyte*)zRow + dZRowInner); + fz += fdzInner; +#endif +#if INTERP_RGB + fr += fdrInner; fg += fdgInner; fb += fdbInner; +#endif +#if INTERP_ALPHA + fa += fdaInner; +#endif +#if INTERP_INDEX + fi += fdiInner; +#endif +#if INTERP_ST + fs += fdsInner; ft += fdtInner; +#endif +#if INTERP_STW + sLeft += dsInner; + tLeft += dtInner; + wLeft += dwInner; +#endif +#if INTERP_UV + uLeft += duInner; + vLeft += dvInner; +#endif + } + } /*while lines>0*/ + + } /* for subTriangle */ + + } + } +} + +#undef SETUP_CODE +#undef INNER_LOOP + +#undef PIXEL_TYPE +#undef BYTES_PER_ROW +#undef PIXEL_ADDRESS + +#undef INTERP_Z +#undef INTERP_RGB +#undef INTERP_ALPHA +#undef INTERP_INDEX +#undef INTERP_ST +#undef INTERP_STW +#undef INTERP_UV + +#undef S_SCALE +#undef T_SCALE diff --git a/dll/opengl/mesa/types.h b/dll/opengl/mesa/types.h new file mode 100644 index 00000000000..d6f9e174291 --- /dev/null +++ b/dll/opengl/mesa/types.h @@ -0,0 +1,1411 @@ +/* $Id: types.h,v 1.50 1998/02/03 23:45:36 brianp Exp $ */ + +/* + * Mesa 3-D graphics library + * Version: 2.6 + * Copyright (C) 1995-1997 Brian Paul + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Library General Public + * License as published by the Free Software Foundation; either + * version 2 of the License, or (at your option) any later version. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Library General Public License for more details. + * + * You should have received a copy of the GNU Library General Public + * License along with this library; if not, write to the Free + * Software Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. + */ + + +/* + * $Log: types.h,v $ + * Revision 1.50 1998/02/03 23:45:36 brianp + * added space parameter to clip interpolation functions + * + * Revision 1.49 1998/01/06 02:40:52 brianp + * added DavidB's clipping interpolation optimization + * + * Revision 1.48 1997/12/31 06:10:03 brianp + * added Henk Kok's texture validation optimization (AnyDirty flag) + * + * Revision 1.47 1997/12/06 18:06:50 brianp + * moved several static display list vars into GLcontext + * + * Revision 1.46 1997/10/29 01:33:29 brianp + * added DriverMgrCtx field to gl_context struct + * + * Revision 1.45 1997/10/29 01:29:09 brianp + * added GL_EXT_point_parameters extension from Daniel Barrero + * + * Revision 1.44 1997/10/16 01:59:08 brianp + * added GL_EXT_shared_texture_palette extension + * + * Revision 1.43 1997/10/16 01:13:03 brianp + * removed teximage Dirty, DirtyPalette flags, mondello code + * + * Revision 1.42 1997/09/29 23:27:08 brianp + * added Dirty and DriverData fields for texturing + * + * Revision 1.41 1997/09/27 00:13:44 brianp + * added GL_EXT_paletted_texture extension + * + * Revision 1.40 1997/09/23 00:57:38 brianp + * now using hash table for texture objects + * + * Revision 1.39 1997/09/22 02:33:58 brianp + * display lists now implemented with hash table + * + * Revision 1.38 1997/08/13 01:30:55 brianp + * LightTwoSide is now a GLboolean + * + * Revision 1.37 1997/08/01 02:23:27 brianp + * removed unused gl_list_group struct + * + * Revision 1.36 1997/06/20 02:07:50 brianp + * replaced Current.IntColor with Current.ByteColor + * removed ColorShift field + * + * Revision 1.35 1997/06/20 02:02:37 brianp + * added Color4ubv API pointer + * + * Revision 1.34 1997/05/31 16:57:14 brianp + * added MESA_NO_RASTER env var support + * + * Revision 1.33 1997/05/28 04:06:03 brianp + * implemented projection near/far value stack for Driver.NearFar() function + * + * Revision 1.32 1997/05/26 21:15:13 brianp + * added Red/Green/Blue/AlphaBits to GLvisual struct + * + * Revision 1.31 1997/05/03 00:49:31 brianp + * added SampleFunc, Current, and Dirty to gl_texture_object + * + * Revision 1.30 1997/05/01 02:07:35 brianp + * added shared state variable NextFreeTextureName + * + * Revision 1.29 1997/04/24 01:50:53 brianp + * optimized glColor3f, glColor3fv, glColor4fv + * + * Revision 1.28 1997/04/21 01:20:41 brianp + * added MATRIX_2D_NO_ROT + * + * Revision 1.27 1997/04/20 16:18:15 brianp + * added glOrtho and glFrustum API pointers + * + * Revision 1.26 1997/04/16 23:55:33 brianp + * added optimized glTexCoord2f code + * + * Revision 1.25 1997/04/14 22:18:23 brianp + * added optimized glVertex3fv code + * + * Revision 1.24 1997/04/14 02:03:05 brianp + * added MinMagThresh to texture object + * + * Revision 1.23 1997/04/12 16:54:05 brianp + * new NEW_POLYGON state flag + * + * Revision 1.22 1997/04/12 12:26:39 brianp + * added quad_func and rect_func, removed polygon_func + * + * Revision 1.21 1997/04/07 02:57:13 brianp + * added API.Vertex[23] functions + * + * Revision 1.20 1997/04/01 04:19:37 brianp + * added API pointer for glLoadIdentity + * added matrix type constants and fields + * + * Revision 1.19 1997/03/13 03:05:54 brianp + * changed AlphaRefInt to AlphaRefUbyte + * + * Revision 1.18 1997/03/04 19:17:38 brianp + * added a few members to gl_texture_image struct + * + * Revision 1.17 1997/02/10 19:49:29 brianp + * added glResizeBuffersMESA() code + * + * Revision 1.16 1997/02/09 19:53:43 brianp + * now use TEXTURE_xD enable constants + * + * Revision 1.15 1997/02/09 18:42:41 brianp + * added GL_EXT_texture3D support + * + * Revision 1.14 1997/01/28 22:14:36 brianp + * now there's separate state for CI and RGBA logic op enabled + * + * Revision 1.13 1997/01/21 03:09:41 brianp + * added definition: union node; + * + * Revision 1.12 1997/01/09 21:26:23 brianp + * added RefCount to gl_image struct + * + * Revision 1.11 1996/12/18 20:01:39 brianp + * added material bitmask constants and ColorMaterialBitmask + * + * Revision 1.10 1996/12/11 20:16:30 brianp + * changed GLaccum types to signed + * + * Revision 1.9 1996/11/08 02:21:04 brianp + * added NoRaster flag to context + * + * Revision 1.8 1996/11/07 04:11:34 brianp + * now pass gl_image struct pointer to glTexImage[12]D() + * + * Revision 1.7 1996/11/06 04:21:58 brianp + * added Format to struct gl_image + * + * Revision 1.6 1996/10/11 03:41:12 brianp + * removed OffsetBias field + * + * Revision 1.5 1996/10/11 00:23:04 brianp + * changed Polygon/Line/PointZoffset to GLfloat + * + * Revision 1.4 1996/09/25 03:22:53 brianp + * added NO_DRAW_BIT for glDrawBuffer(GL_NONE) + * + * Revision 1.3 1996/09/19 03:17:56 brianp + * removed Window field from struct gl_frame_buffer + * + * Revision 1.2 1996/09/15 14:20:54 brianp + * added GLframebuffer and GLvisual datatypes + * + * Revision 1.1 1996/09/13 01:38:16 brianp + * Initial revision + * + */ + + +#ifndef TYPES_H +#define TYPES_H + + +#include "GL/gl.h" +#include "config.h" + + +struct HashTable; + + +/* + * Accumulation buffer data type: + */ +#if ACCUM_BITS==8 + typedef GLbyte GLaccum; +#elif ACCUM_BITS==16 + typedef GLshort GLaccum; +#else + illegal number of accumulation bits +#endif + + +/* + * Stencil buffer data type: + */ +#if STENCIL_BITS==8 + typedef GLubyte GLstencil; +#else + illegal number of stencil bits +#endif + + + +/* + * Depth buffer data type: + */ +typedef GLint GLdepth; + + + +#include "fixed.h" + + + +typedef struct gl_visual GLvisual; + +typedef struct gl_context GLcontext; + +typedef struct gl_frame_buffer GLframebuffer; + + + +/* + * Point, line, triangle, quadrilateral and rectangle rasterizer functions: + */ +typedef void (*points_func)( GLcontext *ctx, GLuint first, GLuint last ); + +typedef void (*line_func)( GLcontext *ctx, GLuint v1, GLuint v2, GLuint pv ); + +typedef void (*triangle_func)( GLcontext *ctx, + GLuint v1, GLuint v2, GLuint v3, GLuint pv ); + +typedef void (*quad_func)( GLcontext *ctx, GLuint v1, GLuint v2, + GLuint v3, GLuint v4, GLuint pv ); + +typedef void (*rect_func)( GLcontext *ctx, GLint x, GLint y, + GLint width, GLint height ); + +/* + * The auxiliary interpolation function for clipping + */ +typedef void (* interp_func)(GLcontext *, GLuint, GLuint, GLfloat, GLuint, GLuint); + + +/* + * For texture sampling: + */ +struct gl_texture_object; + +typedef void (*TextureSampleFunc)( const struct gl_texture_object *tObj, + GLuint n, + const GLfloat s[], const GLfloat t[], + const GLfloat u[], const GLfloat lambda[], + GLubyte r[], GLubyte g[], + GLubyte b[],GLubyte a[] ); + + +/* Generic internal image format */ +struct gl_image { + GLint Width; + GLint Height; + GLint Components; /* 1, 2, 3 or 4 */ + GLenum Format; /* GL_COLOR_INDEX, GL_RED, GL_RGB, etc */ + GLenum Type; /* GL_UNSIGNED_BYTE or GL_FLOAT or GL_BITMAP */ + GLvoid *Data; + GLboolean Interleaved; /* If TRUE and Format==GL_RGB, GL_RGBA or + * GL_LUMINANCE_ALPHA then each row is + * stored as RRR..RGGG..GBBB.B instead of + * RGBRGBRGBRGB..RGB. This is only used + * for glDrawPixels. + */ + GLint RefCount; +}; + + + +/* Texture image record */ +struct gl_texture_image { + GLenum Format; /* GL_ALPHA, GL_LUMINANCE, GL_LUMINANCE_ALPHA, + * GL_INTENSITY, GL_RGB, GL_RGBA, or + * GL_COLOR_INDEX + */ + GLenum IntFormat; /* Internal format as given by the user */ + GLuint Border; /* 0 or 1 */ + GLuint Width; /* = 2^WidthLog2 + 2*Border */ + GLuint Height; /* = 2^HeightLog2 + 2*Border */ + GLuint Width2; /* = Width - 2*Border */ + GLuint Height2; /* = Height - 2*Border */ + GLuint WidthLog2; /* = log2(Width2) */ + GLuint HeightLog2; /* = log2(Height2) */ + GLuint MaxLog2; /* = MAX(WidthLog2, HeightLog2) */ + GLubyte *Data; /* Image data as unsigned bytes */ + + /* For device driver: */ + void *DriverData; /* Arbitrary device driver data */ +}; + + + +/* + * All gl* API functions in api.c jump through pointers in this struct. + */ +struct gl_api_table { + void (*Accum)( GLcontext *, GLenum, GLfloat ); + void (*AlphaFunc)( GLcontext *, GLenum, GLclampf ); + GLboolean (*AreTexturesResident)( GLcontext *, GLsizei, + const GLuint *, GLboolean * ); + void (*ArrayElement)( GLcontext *, GLint ); + void (*Begin)( GLcontext *, GLenum ); + void (*BindTexture)( GLcontext *, GLenum, GLuint ); + void (*Bitmap)( GLcontext *, GLsizei, GLsizei, GLfloat, GLfloat, + GLfloat, GLfloat, const struct gl_image *bitmap ); + void (*BlendFunc)( GLcontext *, GLenum, GLenum ); + void (*CallList)( GLcontext *, GLuint list ); + void (*CallLists)( GLcontext *, GLsizei, GLenum, const GLvoid * ); + void (*Clear)( GLcontext *, GLbitfield ); + void (*ClearAccum)( GLcontext *, GLfloat, GLfloat, GLfloat, GLfloat ); + void (*ClearColor)( GLcontext *, GLclampf, GLclampf, GLclampf, GLclampf ); + void (*ClearDepth)( GLcontext *, GLclampd ); + void (*ClearIndex)( GLcontext *, GLfloat ); + void (*ClearStencil)( GLcontext *, GLint ); + void (*ClipPlane)( GLcontext *, GLenum, const GLfloat * ); + void (*Color3f)( GLcontext *, GLfloat, GLfloat, GLfloat ); + void (*Color3fv)( GLcontext *, const GLfloat * ); + void (*Color4f)( GLcontext *, GLfloat, GLfloat, GLfloat, GLfloat ); + void (*Color4fv)( GLcontext *, const GLfloat * ); + void (*Color4ub)( GLcontext *, GLubyte, GLubyte, GLubyte, GLubyte ); + void (*Color4ubv)( GLcontext *, const GLubyte * ); + void (*ColorMask)( GLcontext *, + GLboolean, GLboolean, GLboolean, GLboolean ); + void (*ColorMaterial)( GLcontext *, GLenum, GLenum ); + void (*ColorPointer)( GLcontext *, GLint, GLenum, GLsizei, const GLvoid * ); + void (*ColorTable)( GLcontext *, GLenum, GLenum, struct gl_image * ); + void (*ColorSubTable)( GLcontext *, GLenum, GLsizei, struct gl_image * ); + void (*CopyPixels)( GLcontext *, GLint, GLint, GLsizei, GLsizei, GLenum ); + void (*CopyTexImage1D)( GLcontext *, GLenum, GLint, GLenum, + GLint, GLint, GLsizei, GLint ); + void (*CopyTexImage2D)( GLcontext *, GLenum, GLint, GLenum, + GLint, GLint, GLsizei, GLsizei, GLint ); + void (*CopyTexSubImage1D)( GLcontext *, GLenum, GLint, GLint, + GLint, GLint, GLsizei ); + void (*CopyTexSubImage2D)( GLcontext *, GLenum, GLint, GLint, GLint, + GLint, GLint, GLsizei, GLsizei ); + void (*CullFace)( GLcontext *, GLenum ); + void (*DeleteLists)( GLcontext *, GLuint, GLsizei ); + void (*DeleteTextures)( GLcontext *, GLsizei, const GLuint *); + void (*DepthFunc)( GLcontext *, GLenum ); + void (*DepthMask)( GLcontext *, GLboolean ); + void (*DepthRange)( GLcontext *, GLclampd, GLclampd ); + void (*Disable)( GLcontext *, GLenum ); + void (*DisableClientState)( GLcontext *, GLenum ); + void (*DrawArrays)( GLcontext *, GLenum, GLint, GLsizei ); + void (*DrawBuffer)( GLcontext *, GLenum ); + void (*DrawElements)( GLcontext *, GLenum, GLsizei, GLenum, const GLvoid *); + void (*DrawPixels)( GLcontext *, + GLsizei, GLsizei, GLenum, GLenum, const GLvoid * ); + void (*EdgeFlag)( GLcontext *, GLboolean ); + void (*EdgeFlagPointer)( GLcontext *, GLsizei, const GLboolean * ); + void (*Enable)( GLcontext *, GLenum ); + void (*EnableClientState)( GLcontext *, GLenum ); + void (*End)( GLcontext * ); + void (*EndList)( GLcontext * ); + void (*EvalCoord1f)( GLcontext *, GLfloat ); + void (*EvalCoord2f)( GLcontext *, GLfloat , GLfloat ); + void (*EvalMesh1)( GLcontext *, GLenum, GLint, GLint ); + void (*EvalMesh2)( GLcontext *, GLenum, GLint, GLint, GLint, GLint ); + void (*EvalPoint1)( GLcontext *, GLint ); + void (*EvalPoint2)( GLcontext *, GLint, GLint ); + void (*FeedbackBuffer)( GLcontext *, GLsizei, GLenum, GLfloat * ); + void (*Finish)( GLcontext * ); + void (*Flush)( GLcontext * ); + void (*Fogfv)( GLcontext *, GLenum, const GLfloat * ); + void (*FrontFace)( GLcontext *, GLenum ); + void (*Frustum)( GLcontext *, GLdouble, GLdouble, GLdouble, GLdouble, + GLdouble, GLdouble ); + GLuint (*GenLists)( GLcontext *, GLsizei ); + void (*GenTextures)( GLcontext *, GLsizei, GLuint * ); + void (*GetBooleanv)( GLcontext *, GLenum, GLboolean * ); + void (*GetClipPlane)( GLcontext *, GLenum, GLdouble * ); + void (*GetColorTable)( GLcontext *, GLenum, GLenum, GLenum, GLvoid *); + void (*GetColorTableParameteriv)( GLcontext *, GLenum, GLenum, GLint *); + void (*GetDoublev)( GLcontext *, GLenum, GLdouble * ); + GLenum (*GetError)( GLcontext * ); + void (*GetFloatv)( GLcontext *, GLenum, GLfloat * ); + void (*GetIntegerv)( GLcontext *, GLenum, GLint * ); + const GLubyte* (*GetString)( GLcontext *, GLenum name ); + void (*GetLightfv)( GLcontext *, GLenum light, GLenum, GLfloat * ); + void (*GetLightiv)( GLcontext *, GLenum light, GLenum, GLint * ); + void (*GetMapdv)( GLcontext *, GLenum, GLenum, GLdouble * ); + void (*GetMapfv)( GLcontext *, GLenum, GLenum, GLfloat * ); + void (*GetMapiv)( GLcontext *, GLenum, GLenum, GLint * ); + void (*GetMaterialfv)( GLcontext *, GLenum, GLenum, GLfloat * ); + void (*GetMaterialiv)( GLcontext *, GLenum, GLenum, GLint * ); + void (*GetPixelMapfv)( GLcontext *, GLenum, GLfloat * ); + void (*GetPixelMapuiv)( GLcontext *, GLenum, GLuint * ); + void (*GetPixelMapusv)( GLcontext *, GLenum, GLushort * ); + void (*GetPointerv)( GLcontext *, GLenum, GLvoid ** ); + void (*GetPolygonStipple)( GLcontext *, GLubyte * ); + void (*PrioritizeTextures)( GLcontext *, GLsizei, const GLuint *, + const GLclampf * ); + void (*GetTexEnvfv)( GLcontext *, GLenum, GLenum, GLfloat * ); + void (*GetTexEnviv)( GLcontext *, GLenum, GLenum, GLint * ); + void (*GetTexGendv)( GLcontext *, GLenum coord, GLenum, GLdouble * ); + void (*GetTexGenfv)( GLcontext *, GLenum coord, GLenum, GLfloat * ); + void (*GetTexGeniv)( GLcontext *, GLenum coord, GLenum, GLint * ); + void (*GetTexImage)( GLcontext *, GLenum, GLint level, GLenum, GLenum, + GLvoid * ); + void (*GetTexLevelParameterfv)( GLcontext *, + GLenum, GLint, GLenum, GLfloat * ); + void (*GetTexLevelParameteriv)( GLcontext *, + GLenum, GLint, GLenum, GLint * ); + void (*GetTexParameterfv)( GLcontext *, GLenum, GLenum, GLfloat *); + void (*GetTexParameteriv)( GLcontext *, GLenum, GLenum, GLint * ); + void (*Hint)( GLcontext *, GLenum, GLenum ); + void (*IndexMask)( GLcontext *, GLuint ); + void (*Indexf)( GLcontext *, GLfloat c ); + void (*Indexi)( GLcontext *, GLint c ); + void (*IndexPointer)( GLcontext *, GLenum, GLsizei, const GLvoid * ); + void (*InitNames)( GLcontext * ); + void (*InterleavedArrays)( GLcontext *, GLenum, GLsizei, const GLvoid * ); + GLboolean (*IsEnabled)( GLcontext *, GLenum ); + GLboolean (*IsList)( GLcontext *, GLuint ); + GLboolean (*IsTexture)( GLcontext *, GLuint ); + void (*LightModelfv)( GLcontext *, GLenum, const GLfloat * ); + void (*Lightfv)( GLcontext *, GLenum light, GLenum, const GLfloat *, GLint); + void (*LineStipple)( GLcontext *, GLint factor, GLushort ); + void (*LineWidth)( GLcontext *, GLfloat ); + void (*ListBase)( GLcontext *, GLuint ); + void (*LoadIdentity)( GLcontext * ); + /* LoadMatrixd implemented with glLoadMatrixf */ + void (*LoadMatrixf)( GLcontext *, const GLfloat * ); + void (*LoadName)( GLcontext *, GLuint ); + void (*LogicOp)( GLcontext *, GLenum ); + void (*Map1f)( GLcontext *, GLenum, GLfloat, GLfloat, GLint, GLint, + const GLfloat *, GLboolean ); + void (*Map2f)( GLcontext *, GLenum, GLfloat, GLfloat, GLint, GLint, + GLfloat, GLfloat, GLint, GLint, const GLfloat *, + GLboolean ); + void (*MapGrid1f)( GLcontext *, GLint, GLfloat, GLfloat ); + void (*MapGrid2f)( GLcontext *, GLint, GLfloat, GLfloat, + GLint, GLfloat, GLfloat ); + void (*Materialfv)( GLcontext *, GLenum, GLenum, const GLfloat * ); + void (*MatrixMode)( GLcontext *, GLenum ); + /* MultMatrixd implemented with glMultMatrixf */ + void (*MultMatrixf)( GLcontext *, const GLfloat * ); + void (*NewList)( GLcontext *, GLuint list, GLenum ); + void (*Normal3f)( GLcontext *, GLfloat, GLfloat, GLfloat ); + void (*Normal3fv)( GLcontext *, const GLfloat * ); + void (*NormalPointer)( GLcontext *, GLenum, GLsizei, const GLvoid * ); + void (*Ortho)( GLcontext *, GLdouble, GLdouble, GLdouble, GLdouble, + GLdouble, GLdouble ); + void (*PassThrough)( GLcontext *, GLfloat ); + void (*PixelMapfv)( GLcontext *, GLenum, GLint, const GLfloat * ); + void (*PixelStorei)( GLcontext *, GLenum, GLint ); + void (*PixelTransferf)( GLcontext *, GLenum, GLfloat ); + void (*PixelZoom)( GLcontext *, GLfloat, GLfloat ); + void (*PointSize)( GLcontext *, GLfloat ); + void (*PolygonMode)( GLcontext *, GLenum, GLenum ); + void (*PolygonOffset)( GLcontext *, GLfloat, GLfloat ); + void (*PolygonStipple)( GLcontext *, const GLubyte * ); + void (*PopAttrib)( GLcontext * ); + void (*PopClientAttrib)( GLcontext * ); + void (*PopMatrix)( GLcontext * ); + void (*PopName)( GLcontext * ); + void (*PushAttrib)( GLcontext *, GLbitfield ); + void (*PushClientAttrib)( GLcontext *, GLbitfield ); + void (*PushMatrix)( GLcontext * ); + void (*PushName)( GLcontext *, GLuint ); + void (*RasterPos4f)( GLcontext *, + GLfloat x, GLfloat y, GLfloat z, GLfloat w ); + void (*ReadBuffer)( GLcontext *, GLenum ); + void (*ReadPixels)( GLcontext *, GLint, GLint, GLsizei, GLsizei, GLenum, + GLenum, GLvoid * ); + void (*Rectf)( GLcontext *, GLfloat, GLfloat, GLfloat, GLfloat ); + GLint (*RenderMode)( GLcontext *, GLenum ); + void (*Rotatef)( GLcontext *, GLfloat, GLfloat, GLfloat, GLfloat ); + void (*Scalef)( GLcontext *, GLfloat, GLfloat, GLfloat ); + void (*Scissor)( GLcontext *, GLint, GLint, GLsizei, GLsizei); + void (*SelectBuffer)( GLcontext *, GLsizei, GLuint * ); + void (*ShadeModel)( GLcontext *, GLenum ); + void (*StencilFunc)( GLcontext *, GLenum, GLint, GLuint ); + void (*StencilMask)( GLcontext *, GLuint ); + void (*StencilOp)( GLcontext *, GLenum, GLenum, GLenum ); + void (*TexCoord2f)( GLcontext *, GLfloat, GLfloat ); + void (*TexCoord4f)( GLcontext *, GLfloat, GLfloat, GLfloat, GLfloat ); + void (*TexCoordPointer)( GLcontext *, GLint, GLenum, GLsizei, + const GLvoid *); + void (*TexEnvfv)( GLcontext *, GLenum, GLenum, const GLfloat * ); + void (*TexGenfv)( GLcontext *, GLenum coord, GLenum, const GLfloat * ); + void (*TexImage1D)( GLcontext *, GLenum, GLint, GLint, GLsizei, + GLint, GLenum, GLenum, struct gl_image * ); + void (*TexImage2D)( GLcontext *, GLenum, GLint, GLint, GLsizei, GLsizei, + GLint, GLenum, GLenum, struct gl_image * ); + void (*TexSubImage1D)( GLcontext *, GLenum, GLint, GLint, GLsizei, + GLenum, GLenum, struct gl_image * ); + void (*TexSubImage2D)( GLcontext *, GLenum, GLint, GLint, GLint, + GLsizei, GLsizei, GLenum, GLenum, + struct gl_image * ); + void (*TexParameterfv)( GLcontext *, GLenum, GLenum, const GLfloat * ); + /* Translated implemented by Translatef */ + void (*Translatef)( GLcontext *, GLfloat, GLfloat, GLfloat ); + void (*Vertex2f)( GLcontext *, GLfloat, GLfloat ); + void (*Vertex3f)( GLcontext *, GLfloat, GLfloat, GLfloat ); + void (*Vertex4f)( GLcontext *, GLfloat, GLfloat, GLfloat, GLfloat ); + void (*Vertex3fv)( GLcontext *, const GLfloat * ); + void (*VertexPointer)( GLcontext *, GLint, GLenum, GLsizei, const GLvoid *); + void (*Viewport)( GLcontext *, GLint, GLint, GLsizei, GLsizei ); +}; + + + +#include "dd.h" + + +/* + * Bit flags used for updating material values. + */ +#define FRONT_AMBIENT_BIT 0x1 +#define BACK_AMBIENT_BIT 0x2 +#define FRONT_DIFFUSE_BIT 0x4 +#define BACK_DIFFUSE_BIT 0x8 +#define FRONT_SPECULAR_BIT 0x10 +#define BACK_SPECULAR_BIT 0x20 +#define FRONT_EMISSION_BIT 0x40 +#define BACK_EMISSION_BIT 0x80 +#define FRONT_SHININESS_BIT 0x100 +#define BACK_SHININESS_BIT 0x200 +#define FRONT_INDEXES_BIT 0x400 +#define BACK_INDEXES_BIT 0x800 + +#define FRONT_MATERIAL_BITS (FRONT_EMISSION_BIT | FRONT_AMBIENT_BIT | \ + FRONT_DIFFUSE_BIT | FRONT_SPECULAR_BIT | \ + FRONT_SHININESS_BIT | FRONT_INDEXES_BIT) + +#define BACK_MATERIAL_BITS (BACK_EMISSION_BIT | BACK_AMBIENT_BIT | \ + BACK_DIFFUSE_BIT | BACK_SPECULAR_BIT | \ + BACK_SHININESS_BIT | BACK_INDEXES_BIT) + +#define ALL_MATERIAL_BITS (FRONT_MATERIAL_BITS | BACK_MATERIAL_BITS) + + + +/* + * Specular exponent and material shininess lookup table sizes: + */ +#define EXP_TABLE_SIZE 512 +#define SHINE_TABLE_SIZE 200 + +struct gl_light { + GLfloat Ambient[4]; /* ambient color */ + GLfloat Diffuse[4]; /* diffuse color */ + GLfloat Specular[4]; /* specular color */ + GLfloat Position[4]; /* position in eye coordinates */ + GLfloat Direction[4]; /* spotlight dir in eye coordinates */ + GLfloat SpotExponent; + GLfloat SpotCutoff; /* in degress */ + GLfloat CosCutoff; /* = cos(SpotCutoff) */ + GLfloat ConstantAttenuation; + GLfloat LinearAttenuation; + GLfloat QuadraticAttenuation; + GLboolean Enabled; /* On/off flag */ + + struct gl_light *NextEnabled; /* Ptr to next enabled light or NULL */ + + /* Derived fields */ + GLfloat VP_inf_norm[3]; /* Norm direction to infinite light */ + GLfloat h_inf_norm[3]; /* Norm( VP_inf_norm + <0,0,1> ) */ + GLfloat NormDirection[3]; /* normalized spotlight direction */ + GLfloat SpotExpTable[EXP_TABLE_SIZE][2]; /* to replace a pow() call */ + GLfloat MatAmbient[2][3]; /* material ambient * light ambient */ + GLfloat MatDiffuse[2][3]; /* material diffuse * light diffuse */ + GLfloat MatSpecular[2][3]; /* material spec * light specular */ + GLfloat dli; /* CI diffuse light intensity */ + GLfloat sli; /* CI specular light intensity */ +}; + + +struct gl_lightmodel { + GLfloat Ambient[4]; /* ambient color */ + GLboolean LocalViewer; /* Local (or infinite) view point? */ + GLboolean TwoSide; /* Two (or one) sided lighting? */ +}; + + +struct gl_material { + GLfloat Ambient[4]; + GLfloat Diffuse[4]; + GLfloat Specular[4]; + GLfloat Emission[4]; + GLfloat Shininess; + GLfloat AmbientIndex; /* for color index lighting */ + GLfloat DiffuseIndex; /* for color index lighting */ + GLfloat SpecularIndex; /* for color index lighting */ + GLfloat ShineTable[SHINE_TABLE_SIZE]; /* to replace a pow() call */ +}; + + + +/* + * Attribute structures: + * We define a struct for each attribute group to make pushing and + * popping attributes easy. Also it's a good organization. + */ + + +struct gl_accum_attrib { + GLfloat ClearColor[4]; /* Accumulation buffer clear color */ +}; + + +struct gl_colorbuffer_attrib { + GLuint ClearIndex; /* Index to use for glClear */ + GLfloat ClearColor[4]; /* Color to use for glClear */ + + GLuint IndexMask; /* Color index write mask */ + GLuint ColorMask; /* bit 3=red,2=green,1=blue,0=alpha*/ + GLboolean SWmasking; /* Do color/CI masking in software? */ + + GLenum DrawBuffer; /* Which buffer to draw into */ + + /* alpha testing */ + GLboolean AlphaEnabled; /* Alpha test enabled flag */ + GLenum AlphaFunc; /* Alpha test function */ + GLfloat AlphaRef; /* Alpha reference value */ + GLubyte AlphaRefUbyte; /* AlphaRef scaled to an integer */ + + /* blending */ + GLboolean BlendEnabled; /* Blending enabled flag */ + GLenum BlendSrc; /* Blending source operator */ + GLenum BlendDst; /* Blending destination operator */ + + /* logic op */ + GLenum LogicOp; /* Logic operator */ + GLboolean IndexLogicOpEnabled; /* Color index logic op enabled flag */ + GLboolean ColorLogicOpEnabled; /* RGBA logic op enabled flag */ + GLboolean SWLogicOpEnabled; /* Do logic ops in software? */ + + GLboolean DitherFlag; /* Dither enable flag */ +}; + + +struct gl_current_attrib { + GLubyte ByteColor[4]; /* Current RGBA color */ + GLuint Index; /* Current color index */ + GLfloat Normal[3]; /* Current normal vector */ + GLfloat TexCoord[4]; /* Current texture coordinate */ + GLfloat RasterPos[4]; /* Current raster position */ + GLfloat RasterDistance; /* Current raster distance */ + GLfloat RasterColor[4]; /* Current raster color */ + GLuint RasterIndex; /* Current raster index */ + GLfloat RasterTexCoord[4]; /* Current raster texture coord */ + GLboolean RasterPosValid; /* Raster position valid flag */ + GLboolean EdgeFlag; /* Current edge flag */ +}; + + +struct gl_depthbuffer_attrib { + GLenum Func; /* Function for depth buffer compare */ + GLfloat Clear; /* Value to clear depth buffer to */ + GLboolean Test; /* Depth buffering enabled flag */ + GLboolean Mask; /* Depth buffer writable? */ +}; + + +struct gl_enable_attrib { + GLboolean AlphaTest; + GLboolean AutoNormal; + GLboolean Blend; + GLboolean ClipPlane[MAX_CLIP_PLANES]; + GLboolean ColorMaterial; + GLboolean CullFace; + GLboolean DepthTest; + GLboolean Dither; + GLboolean Fog; + GLboolean Light[MAX_LIGHTS]; + GLboolean Lighting; + GLboolean LineSmooth; + GLboolean LineStipple; + GLboolean IndexLogicOp; + GLboolean ColorLogicOp; + GLboolean Map1Color4; + GLboolean Map1Index; + GLboolean Map1Normal; + GLboolean Map1TextureCoord1; + GLboolean Map1TextureCoord2; + GLboolean Map1TextureCoord3; + GLboolean Map1TextureCoord4; + GLboolean Map1Vertex3; + GLboolean Map1Vertex4; + GLboolean Map2Color4; + GLboolean Map2Index; + GLboolean Map2Normal; + GLboolean Map2TextureCoord1; + GLboolean Map2TextureCoord2; + GLboolean Map2TextureCoord3; + GLboolean Map2TextureCoord4; + GLboolean Map2Vertex3; + GLboolean Map2Vertex4; + GLboolean Normalize; + GLboolean PointSmooth; + GLboolean PolygonOffsetPoint; + GLboolean PolygonOffsetLine; + GLboolean PolygonOffsetFill; + GLboolean PolygonSmooth; + GLboolean PolygonStipple; + GLboolean Scissor; + GLboolean Stencil; + GLuint Texture; + GLuint TexGen; +}; + + +struct gl_eval_attrib { + /* Enable bits */ + GLboolean Map1Color4; + GLboolean Map1Index; + GLboolean Map1Normal; + GLboolean Map1TextureCoord1; + GLboolean Map1TextureCoord2; + GLboolean Map1TextureCoord3; + GLboolean Map1TextureCoord4; + GLboolean Map1Vertex3; + GLboolean Map1Vertex4; + GLboolean Map2Color4; + GLboolean Map2Index; + GLboolean Map2Normal; + GLboolean Map2TextureCoord1; + GLboolean Map2TextureCoord2; + GLboolean Map2TextureCoord3; + GLboolean Map2TextureCoord4; + GLboolean Map2Vertex3; + GLboolean Map2Vertex4; + GLboolean AutoNormal; + /* Map Grid endpoints and divisions */ + GLuint MapGrid1un; + GLfloat MapGrid1u1, MapGrid1u2; + GLuint MapGrid2un, MapGrid2vn; + GLfloat MapGrid2u1, MapGrid2u2; + GLfloat MapGrid2v1, MapGrid2v2; +}; + + +struct gl_fog_attrib { + GLboolean Enabled; /* Fog enabled flag */ + GLfloat Color[4]; /* Fog color */ + GLfloat Density; /* Density >= 0.0 */ + GLfloat Start; /* Start distance in eye coords */ + GLfloat End; /* End distance in eye coords */ + GLfloat Index; /* Fog index */ + GLenum Mode; /* Fog mode */ +}; + + +struct gl_hint_attrib { + /* always one of GL_FASTEST, GL_NICEST, or GL_DONT_CARE */ + GLenum PerspectiveCorrection; + GLenum PointSmooth; + GLenum LineSmooth; + GLenum PolygonSmooth; + GLenum Fog; +}; + + +struct gl_light_attrib { + struct gl_light Light[MAX_LIGHTS]; /* Array of lights */ + struct gl_lightmodel Model; /* Lighting model */ + struct gl_material Material[2]; /* Material 0=front, 1=back */ + GLboolean Enabled; /* Lighting enabled flag */ + GLenum ShadeModel; /* GL_FLAT or GL_SMOOTH */ + GLenum ColorMaterialFace; /* GL_FRONT, BACK or FRONT_AND_BACK */ + GLenum ColorMaterialMode; /* GL_AMBIENT, GL_DIFFUSE, etc */ + GLuint ColorMaterialBitmask; /* bitmask formed from Face and Mode */ + GLboolean ColorMaterialEnabled; + + /* Derived for optimizations: */ + struct gl_light *FirstEnabled; /* Ptr to 1st enabled light */ + GLboolean Fast; /* Use fast shader? */ + GLfloat BaseColor[2][4]; +}; + + +struct gl_line_attrib { + GLboolean SmoothFlag; /* GL_LINE_SMOOTH enabled? */ + GLboolean StippleFlag; /* GL_LINE_STIPPLE enabled? */ + GLushort StipplePattern; /* Stipple pattern */ + GLint StippleFactor; /* Stipple repeat factor */ + GLfloat Width; /* Line width */ +}; + + +struct gl_list_attrib { + GLuint ListBase; +}; + + +struct gl_pixel_attrib { + GLenum ReadBuffer; + GLfloat RedBias, RedScale; /* Pixel xfer bias & scale values */ + GLfloat GreenBias, GreenScale; + GLfloat BlueBias, BlueScale; + GLfloat AlphaBias, AlphaScale; + GLfloat DepthBias, DepthScale; + GLint IndexShift; + GLint IndexOffset; + GLboolean MapColorFlag; + GLboolean MapStencilFlag; + GLfloat ZoomX; /* Pixel zoom X factor */ + GLfloat ZoomY; /* Pixel zoom Y factor */ + /* TODO: Do the following belong here??? */ + GLint MapStoSsize; /* Size of each pixel map */ + GLint MapItoIsize; + GLint MapItoRsize; + GLint MapItoGsize; + GLint MapItoBsize; + GLint MapItoAsize; + GLint MapRtoRsize; + GLint MapGtoGsize; + GLint MapBtoBsize; + GLint MapAtoAsize; + GLint MapStoS[MAX_PIXEL_MAP_TABLE]; /* Pixel map tables */ + GLint MapItoI[MAX_PIXEL_MAP_TABLE]; + GLfloat MapItoR[MAX_PIXEL_MAP_TABLE]; + GLfloat MapItoG[MAX_PIXEL_MAP_TABLE]; + GLfloat MapItoB[MAX_PIXEL_MAP_TABLE]; + GLfloat MapItoA[MAX_PIXEL_MAP_TABLE]; + GLfloat MapRtoR[MAX_PIXEL_MAP_TABLE]; + GLfloat MapGtoG[MAX_PIXEL_MAP_TABLE]; + GLfloat MapBtoB[MAX_PIXEL_MAP_TABLE]; + GLfloat MapAtoA[MAX_PIXEL_MAP_TABLE]; +}; + + +struct gl_point_attrib { + GLboolean SmoothFlag; /* True if GL_POINT_SMOOTH is enabled */ + GLfloat Size; /* Point size */ +}; + + +struct gl_polygon_attrib { + GLenum FrontFace; /* Either GL_CW or GL_CCW */ + GLenum FrontMode; /* Either GL_POINT, GL_LINE or GL_FILL */ + GLenum BackMode; /* Either GL_POINT, GL_LINE or GL_FILL */ + GLboolean Unfilled; /* True if back or front mode is not GL_FILL */ + GLboolean CullFlag; /* Culling on/off flag */ + GLenum CullFaceMode; /* Culling mode GL_FRONT or GL_BACK */ + GLuint CullBits; /* Used for cull testing */ + GLboolean SmoothFlag; /* True if GL_POLYGON_SMOOTH is enabled */ + GLboolean StippleFlag; /* True if GL_POLYGON_STIPPLE is enabled */ + GLfloat OffsetFactor; /* Polygon offset factor */ + GLfloat OffsetUnits; /* Polygon offset units */ + GLboolean OffsetPoint; /* Offset in GL_POINT mode? */ + GLboolean OffsetLine; /* Offset in GL_LINE mode? */ + GLboolean OffsetFill; /* Offset in GL_FILL mode? */ + GLboolean OffsetAny; /* OR of OffsetPoint, OffsetLine, OffsetFill */ +}; + + +struct gl_scissor_attrib { + GLboolean Enabled; /* Scissor test enabled? */ + GLint X, Y; /* Lower left corner of box */ + GLsizei Width, Height; /* Size of box */ +}; + + +struct gl_stencil_attrib { + GLboolean Enabled; /* Enabled flag */ + GLenum Function; /* Stencil function */ + GLenum FailFunc; /* Fail function */ + GLenum ZPassFunc; /* Depth buffer pass function */ + GLenum ZFailFunc; /* Depth buffer fail function */ + GLstencil Ref; /* Reference value */ + GLstencil ValueMask; /* Value mask */ + GLstencil Clear; /* Clear value */ + GLstencil WriteMask; /* Write mask */ +}; + + +#define Q_BIT 1 +#define R_BIT 2 +#define S_BIT 4 +#define T_BIT 8 + +#define TEXTURE_1D 1 +#define TEXTURE_2D 2 + + +struct gl_texture_attrib { + GLuint Enabled; /* Bitwise-OR of TEXTURE_XD values */ + GLenum EnvMode; /* GL_MODULATE, GL_DECAL, GL_BLEND */ + GLfloat EnvColor[4]; + GLuint TexGenEnabled; /* Bitwise-OR of [QRST]_BIT values */ + GLenum GenModeS; /* Tex coord generation mode, either */ + GLenum GenModeT; /* GL_OBJECT_LINEAR, or */ + GLenum GenModeR; /* GL_EYE_LINEAR, or */ + GLenum GenModeQ; /* GL_SPHERE_MAP */ + GLfloat ObjectPlaneS[4]; + GLfloat ObjectPlaneT[4]; + GLfloat ObjectPlaneR[4]; + GLfloat ObjectPlaneQ[4]; + GLfloat EyePlaneS[4]; + GLfloat EyePlaneT[4]; + GLfloat EyePlaneR[4]; + GLfloat EyePlaneQ[4]; + struct gl_texture_object *Current1D; + struct gl_texture_object *Current2D; + struct gl_texture_object *Current; /* = Current1D, 2D or NULL */ +#ifdef GL_VERSION_1_1 + struct gl_texture_object *Proxy1D; + struct gl_texture_object *Proxy2D; +#endif + GLboolean AnyDirty; +}; + + +struct gl_transform_attrib { + GLenum MatrixMode; /* Matrix mode */ + GLfloat ClipEquation[MAX_CLIP_PLANES][4]; + GLboolean ClipEnabled[MAX_CLIP_PLANES]; + GLboolean AnyClip; /* Any ClipEnabled[] true? */ + GLboolean Normalize; /* Normalize all normals? */ +}; + + +struct gl_viewport_attrib { + GLint X, Y; /* position */ + GLsizei Width, Height; /* size */ + GLfloat Near, Far; /* Depth buffer range */ + GLfloat Sx, Sy, Sz; /* NDC to WinCoord scaling */ + GLfloat Tx, Ty, Tz; /* NDC to WinCoord translation */ +}; + + +/* For the attribute stack: */ +struct gl_attrib_node { + GLbitfield kind; + void *data; + struct gl_attrib_node *next; +}; + + + +/* + * Client pixel packing/unpacking attributes + */ +struct gl_pixelstore_attrib { + GLint Alignment; + GLint RowLength; + GLint SkipPixels; + GLint SkipRows; + GLboolean SwapBytes; + GLboolean LsbFirst; +}; + + +/* + * Client vertex array attributes + */ +struct gl_array_attrib { + GLint VertexSize; + GLenum VertexType; + GLsizei VertexStride; /* user-specified stride */ + GLsizei VertexStrideB; /* actual stride in bytes */ + void *VertexPtr; + GLboolean VertexEnabled; + + GLenum NormalType; + GLsizei NormalStride; /* user-specified stride */ + GLsizei NormalStrideB; /* actual stride in bytes */ + void *NormalPtr; + GLboolean NormalEnabled; + + GLint ColorSize; + GLenum ColorType; + GLsizei ColorStride; /* user-specified stride */ + GLsizei ColorStrideB; /* actual stride in bytes */ + void *ColorPtr; + GLboolean ColorEnabled; + + GLenum IndexType; + GLsizei IndexStride; /* user-specified stride */ + GLsizei IndexStrideB; /* actual stride in bytes */ + void *IndexPtr; + GLboolean IndexEnabled; + + GLint TexCoordSize; + GLenum TexCoordType; + GLsizei TexCoordStride; /* user-specified stride */ + GLsizei TexCoordStrideB; /* actual stride in bytes */ + void *TexCoordPtr; + GLboolean TexCoordEnabled; + + GLsizei EdgeFlagStride; /* user-specified stride */ + GLsizei EdgeFlagStrideB; /* actual stride in bytes */ + GLboolean *EdgeFlagPtr; + GLboolean EdgeFlagEnabled; +}; + + + +struct gl_feedback { + GLenum Type; + GLuint Mask; + GLfloat *Buffer; + GLuint BufferSize; + GLuint Count; +}; + + + +struct gl_selection { + GLuint *Buffer; + GLuint BufferSize; /* size of SelectBuffer */ + GLuint BufferCount; /* number of values in SelectBuffer */ + GLuint Hits; /* number of records in SelectBuffer */ + GLuint NameStackDepth; + GLuint NameStack[MAX_NAME_STACK_DEPTH]; + GLboolean HitFlag; + GLfloat HitMinZ, HitMaxZ; +}; + + + +/* + * 1-D Evaluator control points + */ +struct gl_1d_map { + GLuint Order; /* Number of control points */ + GLfloat u1, u2; + GLfloat *Points; /* Points to contiguous control points */ + GLboolean Retain; /* Reference counter */ +}; + + +/* + * 2-D Evaluator control points + */ +struct gl_2d_map { + GLuint Uorder; /* Number of control points in U dimension */ + GLuint Vorder; /* Number of control points in V dimension */ + GLfloat u1, u2; + GLfloat v1, v2; + GLfloat *Points; /* Points to contiguous control points */ + GLboolean Retain; /* Reference counter */ +}; + + +/* + * All evalutator control points + */ +struct gl_evaluators { + /* 1-D maps */ + struct gl_1d_map Map1Vertex3; + struct gl_1d_map Map1Vertex4; + struct gl_1d_map Map1Index; + struct gl_1d_map Map1Color4; + struct gl_1d_map Map1Normal; + struct gl_1d_map Map1Texture1; + struct gl_1d_map Map1Texture2; + struct gl_1d_map Map1Texture3; + struct gl_1d_map Map1Texture4; + + /* 2-D maps */ + struct gl_2d_map Map2Vertex3; + struct gl_2d_map Map2Vertex4; + struct gl_2d_map Map2Index; + struct gl_2d_map Map2Color4; + struct gl_2d_map Map2Normal; + struct gl_2d_map Map2Texture1; + struct gl_2d_map Map2Texture2; + struct gl_2d_map Map2Texture3; + struct gl_2d_map Map2Texture4; +}; + + + +/* Texture object record */ +struct gl_texture_object { + GLint RefCount; /* reference count */ + GLuint Name; /* an unsigned integer */ + GLuint Dimensions; /* 1 or 2 or 3 */ + GLfloat Priority; /* in [0,1] */ + GLint BorderColor[4]; /* as integers in [0,255] */ + GLenum WrapS; /* GL_CLAMP or GL_REPEAT */ + GLenum WrapT; /* GL_CLAMP or GL_REPEAT */ + GLenum WrapR; /* GL_CLAMP or GL_REPEAT */ + GLenum MinFilter; /* minification filter */ + GLenum MagFilter; /* magnification filter */ + GLfloat MinMagThresh; /* min/mag threshold */ + struct gl_texture_image *Image[MAX_TEXTURE_LEVELS]; + + /* GL_EXT_paletted_texture */ + GLubyte Palette[MAX_TEXTURE_PALETTE_SIZE*4]; + GLuint PaletteSize; + GLenum PaletteIntFormat; + GLenum PaletteFormat; + + /* For device driver: */ + GLboolean Dirty; /* Set when any texobj state changes */ + void *DriverData; /* Arbitrary device driver data */ + + GLboolean Complete; /* Complete set of images? */ + TextureSampleFunc SampleFunc; + struct gl_texture_object *Next; /* Next in linked list */ +}; + + + +/* + * State which can be shared by multiple contexts: + */ +struct gl_shared_state { + GLint RefCount; /* Reference count */ + struct HashTable *DisplayList; /* Display lists hash table */ + struct HashTable *TexObjects; /* Texture objects hash table */ + struct gl_texture_object *TexObjectList;/* Linked list of texture objects */ + struct gl_texture_object *Default1D; /* Default texture objects */ + struct gl_texture_object *Default2D; +}; + + + +/* + * Describes the color, depth, stencil and accum buffer parameters. + */ +struct gl_visual { + GLboolean RGBAflag; /* Is frame buffer in RGBA mode, not CI? */ + GLboolean DBflag; /* Is color buffer double buffered? */ + + GLfloat RedScale; /* These values are used to scale color */ + GLfloat GreenScale; /* components from the range [0,1] to */ + GLfloat BlueScale; /* integer values. It should be the case */ + GLfloat AlphaScale; /* that scale = 2^bits - 1 where bits is */ + /* the number of bits for the component */ + /* in the frame buffer. */ + GLboolean EightBitColor;/* TRUE if all the above scales are 255.0 */ + + GLfloat InvRedScale; /* = 1 / RedScale */ + GLfloat InvGreenScale; /* = 1 / GreenScale */ + GLfloat InvBlueScale; /* = 1 / BlueScale */ + GLfloat InvAlphaScale; /* = 1 / AlphaScale */ + + GLint RedBits; /* Bits per color component */ + GLint GreenBits; + GLint BlueBits; + GLint AlphaBits; + + GLint IndexBits; /* Bits/pixel if in color index mode */ + + GLint AccumBits; /* Number of bits per color channel, or 0 */ + GLint DepthBits; /* Number of bits in depth buffer, or 0 */ + GLint StencilBits; /* Number of bits in stencil buffer, or 0 */ + + /* Software alpha planes: */ + GLboolean FrontAlphaEnabled; + GLboolean BackAlphaEnabled; +}; + + + +/* + * A "frame buffer" is a color buffer and its optional ancillary buffers: + * depth, accum, stencil, and software-simulated alpha buffers. + */ +struct gl_frame_buffer { + GLvisual *Visual; /* The corresponding visual */ + + GLint Width; /* Width of frame buffer in pixels */ + GLint Height; /* Height of frame buffer in pixels */ + + GLdepth *Depth; /* array [Width*Height] of GLdepth values */ + + /* Stencil buffer */ + GLstencil *Stencil; /* array [Width*Height] of GLstencil values */ + + /* Accumulation buffer */ + GLaccum *Accum; /* array [4*Width*Height] of GLaccum values */ + + /* Software alpha planes: */ + GLubyte *FrontAlpha; /* array [Width*Height] of GLubyte */ + GLubyte *BackAlpha; /* array [Width*Height] of GLubyte */ + GLubyte *Alpha; /* Points to front or back alpha buffer */ + + /* Drawing bounds: intersection of window size and scissor box */ + GLint Xmin, Xmax, Ymin, Ymax; +}; + + + +/* + * Bitmasks to indicate what auxillary information must be interpolated + * when clipping (ClipMask). + */ +#define CLIP_FCOLOR_BIT 0x01 +#define CLIP_BCOLOR_BIT 0x02 +#define CLIP_FINDEX_BIT 0x04 +#define CLIP_BINDEX_BIT 0x08 +#define CLIP_TEXTURE_BIT 0x10 + + + +/* + * Bitmasks to indicate which rasterization options are enabled (RasterMask) + */ +#define ALPHATEST_BIT 0x001 /* Alpha-test pixels */ +#define BLEND_BIT 0x002 /* Blend pixels */ +#define DEPTH_BIT 0x004 /* Depth-test pixels */ +#define FOG_BIT 0x008 /* Per-pixel fog */ +#define LOGIC_OP_BIT 0x010 /* Apply logic op in software */ +#define SCISSOR_BIT 0x020 /* Scissor pixels */ +#define STENCIL_BIT 0x040 /* Stencil pixels */ +#define MASKING_BIT 0x080 /* Do glColorMask() or glIndexMask() */ +#define ALPHABUF_BIT 0x100 /* Using software alpha buffer */ +#define WINCLIP_BIT 0x200 /* Clip pixels/primitives to window */ +#define FRONT_AND_BACK_BIT 0x400 /* Write to front and back buffers */ +#define NO_DRAW_BIT 0x800 /* Don't write any pixels */ + + +/* + * Bits to indicate what state has to be updated (NewState) + */ +#define NEW_LIGHTING 0x1 +#define NEW_RASTER_OPS 0x2 +#define NEW_TEXTURING 0x4 +#define NEW_POLYGON 0x8 +#define NEW_ALL 0xf + + +/* + * Different kinds of 4x4 transformation matrices: + */ +#define MATRIX_GENERAL 0 /* general 4x4 matrix */ +#define MATRIX_IDENTITY 1 /* identity matrix */ +#define MATRIX_ORTHO 2 /* orthographic projection matrix */ +#define MATRIX_PERSPECTIVE 3 /* perspective projection matrix */ +#define MATRIX_2D 4 /* 2-D transformation */ +#define MATRIX_2D_NO_ROT 5 /* 2-D scale & translate only */ +#define MATRIX_3D 6 /* 3-D transformation */ + + +/* + * Forward declaration of display list datatypes: + */ +union node; +typedef union node Node; + + + +/* + * The library context: + */ + +struct gl_context { + /* State possibly shared with other contexts in the address space */ + struct gl_shared_state *Shared; + + /* API function pointer tables */ + struct gl_api_table API; /* For api.c */ + struct gl_api_table Save; /* Display list save funcs */ + struct gl_api_table Exec; /* Execute funcs */ + + GLvisual *Visual; + GLframebuffer *Buffer; + + /* Driver function pointer table */ + struct dd_function_table Driver; + + void *DriverCtx; /* Points to device driver context/state */ + void *DriverMgrCtx; /* Points to device driver manager (optional)*/ + + /* Modelview matrix and stack */ + GLboolean NewModelViewMatrix; + GLuint ModelViewMatrixType; /* = one of MATRIX_* values */ + GLfloat ModelViewMatrix[16]; + GLfloat ModelViewInv[16]; /* Inverse of ModelViewMatrix */ + GLuint ModelViewStackDepth; + GLfloat ModelViewStack[MAX_MODELVIEW_STACK_DEPTH][16]; + + /* Projection matrix and stack */ + GLboolean NewProjectionMatrix; + GLuint ProjectionMatrixType; /* = one of MATRIX_* values */ + GLfloat ProjectionMatrix[16]; + GLuint ProjectionStackDepth; + GLfloat ProjectionStack[MAX_PROJECTION_STACK_DEPTH][16]; + GLfloat NearFarStack[MAX_PROJECTION_STACK_DEPTH][2]; + + /* Texture matrix and stack */ + GLboolean NewTextureMatrix; + GLuint TextureMatrixType; /* = one of MATRIX_* values */ + GLfloat TextureMatrix[16]; + GLuint TextureStackDepth; + GLfloat TextureStack[MAX_TEXTURE_STACK_DEPTH][16]; + + /* Display lists */ + GLuint CallDepth; /* Current recursion calling depth */ + GLboolean ExecuteFlag; /* Execute GL commands? */ + GLboolean CompileFlag; /* Compile GL commands into display list? */ + Node *CurrentListPtr; /* Head of list being compiled */ + GLuint CurrentListNum; /* Number of the list being compiled */ + Node *CurrentBlock; /* Pointer to current block of nodes */ + GLuint CurrentPos; /* Index into current block of nodes */ + + /* Renderer attribute stack */ + GLuint AttribStackDepth; + struct gl_attrib_node *AttribStack[MAX_ATTRIB_STACK_DEPTH]; + + /* Renderer attribute groups */ + struct gl_accum_attrib Accum; + struct gl_colorbuffer_attrib Color; + struct gl_current_attrib Current; + struct gl_depthbuffer_attrib Depth; + struct gl_eval_attrib Eval; + struct gl_fog_attrib Fog; + struct gl_hint_attrib Hint; + struct gl_light_attrib Light; + struct gl_line_attrib Line; + struct gl_list_attrib List; + struct gl_pixel_attrib Pixel; + struct gl_point_attrib Point; + struct gl_polygon_attrib Polygon; + GLuint PolygonStipple[32]; + struct gl_scissor_attrib Scissor; + struct gl_stencil_attrib Stencil; + struct gl_texture_attrib Texture; + struct gl_transform_attrib Transform; + struct gl_viewport_attrib Viewport; + + /* Client attribute stack */ + GLuint ClientAttribStackDepth; + struct gl_attrib_node *ClientAttribStack[MAX_CLIENT_ATTRIB_STACK_DEPTH]; + /* Client attribute groups */ + struct gl_array_attrib Array; /* Vertex arrays */ + struct gl_pixelstore_attrib Pack; /* Pixel packing */ + struct gl_pixelstore_attrib Unpack; /* Pixel unpacking */ + + struct gl_evaluators EvalMap; /* All evaluators */ + struct gl_feedback Feedback; /* Feedback */ + struct gl_selection Select; /* Selection */ + + GLenum ErrorValue; /* Last error code */ + + GLboolean DirectContext; /* Important for real GLX */ + + /* Miscellaneous */ + GLuint NewState; /* bitwise OR of NEW_* flags */ + GLenum RenderMode; /* either GL_RENDER, GL_SELECT, GL_FEEDBACK */ + GLenum Primitive; /* glBegin primitive or GL_BITMAP */ + GLuint StippleCounter; /* Line stipple counter */ + GLuint ClipMask; /* OR of CLIP_* values from above */ + interp_func ClipInterpAuxFunc; /* The auxiliary interpolation function */ + GLuint RasterMask; /* OR of rasterization flags */ + GLboolean LightTwoSide; /* Compute two-sided lighting? */ + GLboolean DirectTriangles;/* Directly call (*ctx->TriangleFunc) ? */ + GLfloat PolygonZoffset; /* Z offset for GL_FILL polygons */ + GLfloat LineZoffset; /* Z offset for GL_LINE polygons */ + GLfloat PointZoffset; /* Z offset for GL_POINT polygons */ + GLboolean NeedNormals; /* Are vertex normal vectors needed? */ + GLboolean FastDrawPixels;/* Use optimized glDrawPixels? */ + GLboolean MutablePixels; /* Can rasterization change pixel's color? */ + GLboolean MonoPixels; /* Are all pixels likely to be same color? */ + + /* Current Primitive functions */ + points_func PointsFunc; + line_func LineFunc; + triangle_func TriangleFunc; + quad_func QuadFunc; + rect_func RectFunc; + + /* The vertex buffer being used by this context */ + struct vertex_buffer* VB; + + /* The pixel buffer being used by this context */ + struct pixel_buffer* PB; + +#ifdef PROFILE + /* Performance measurements */ + GLuint BeginEndCount; /* number of glBegin/glEnd pairs */ + GLdouble BeginEndTime; /* seconds spent between glBegin/glEnd */ + GLuint VertexCount; /* number of vertices processed */ + GLdouble VertexTime; /* total time in seconds */ + GLuint PointCount; /* number of points rendered */ + GLdouble PointTime; /* total time in seconds */ + GLuint LineCount; /* number of lines rendered */ + GLdouble LineTime; /* total time in seconds */ + GLuint PolygonCount; /* number of polygons rendered */ + GLdouble PolygonTime; /* total time in seconds */ + GLuint ClearCount; /* number of glClear calls */ + GLdouble ClearTime; /* seconds spent in glClear */ + GLuint SwapCount; /* number of swap-buffer calls */ + GLdouble SwapTime; /* seconds spent in swap-buffers */ +#endif + + /* For debugging/development only */ + GLboolean NoRaster; + + /* Dither disable via MESA_NO_DITHER env var */ + GLboolean NoDither; +}; + + +#endif diff --git a/dll/opengl/mesa/varray.c b/dll/opengl/mesa/varray.c new file mode 100644 index 00000000000..a5c0c79f9a9 --- /dev/null +++ b/dll/opengl/mesa/varray.c @@ -0,0 +1,1341 @@ +/* $Id: varray.c,v 1.17 1998/02/03 01:40:45 brianp Exp $ */ + +/* + * Mesa 3-D graphics library + * Version: 2.4 + * Copyright (C) 1995-1997 Brian Paul + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Library General Public + * License as published by the Free Software Foundation; either + * version 2 of the License, or (at your option) any later version. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Library General Public License for more details. + * + * You should have received a copy of the GNU Library General Public + * License along with this library; if not, write to the Free + * Software Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. + */ + + +/* + * $Log: varray.c,v $ + * Revision 1.17 1998/02/03 01:40:45 brianp + * fixed a few expressions for Amiga compilation (Sam Jordan) + * + * Revision 1.16 1997/08/14 01:15:47 brianp + * gl_ArrayElement()'s assignment of current normal was wrong + * + * Revision 1.15 1997/07/24 01:25:54 brianp + * changed precompiled header symbol from PCH to PC_HEADER + * + * Revision 1.14 1997/06/20 02:50:19 brianp + * replaced Current.IntColor with Current.ByteColor + * + * Revision 1.13 1997/05/28 03:26:49 brianp + * added precompiled header (PCH) support + * + * Revision 1.12 1997/05/24 12:07:43 brianp + * colors weren't being used in gl_ArrayElement() + * + * Revision 1.11 1997/04/20 20:29:11 brianp + * replaced abort() with gl_problem() + * + * Revision 1.10 1997/04/02 03:12:31 brianp + * misc changes for new vertex buffer organization + * + * Revision 1.9 1997/01/30 21:05:03 brianp + * moved gl_GetPointerv() to get.c + * + * Revision 1.8 1996/12/18 20:00:57 brianp + * gl_set_material() now takes a bitmask instead of face and pname + * + * Revision 1.7 1996/12/07 10:21:28 brianp + * call gl_set_material() instead of gl_Materialfv() + * + * Revision 1.6 1996/11/09 03:12:34 brianp + * now call gl_render_vb() after gl_transform_vb_part2() call + * + * Revision 1.5 1996/10/08 00:05:06 brianp + * added some missing stuff to gl_ArrayElement() + * + * Revision 1.4 1996/10/04 02:37:06 brianp + * gl_ArrayElement() wasn't always initializing vertex Z and W values + * + * Revision 1.3 1996/10/03 00:47:56 brianp + * added #include for abort() + * + * Revision 1.2 1996/09/27 01:33:07 brianp + * added missing default cases to switches + * + * Revision 1.1 1996/09/13 01:38:16 brianp + * Initial revision + * + */ + + + +/* + * NOTE: At this time, only three vertex array configurations are optimized: + * 1. glVertex3fv(), zero stride + * 2. glNormal3fv() with glVertex3fv(), zero stride + * 3. glNormal3fv() with glVertex4fv(), zero stride + * + * More optimized array configurations can be added. + */ + + +#ifdef PC_HEADER +#include "all.h" +#else +#include +#include +#include "context.h" +#include "enable.h" +#include "dlist.h" +#include "light.h" +#include "macros.h" +#include "types.h" +#include "varray.h" +#include "vb.h" +#include "vbfill.h" +#include "vbrender.h" +#include "vbxform.h" +#include "xform.h" +#endif + + +void gl_VertexPointer( GLcontext *ctx, + GLint size, GLenum type, GLsizei stride, + const GLvoid *ptr ) +{ + if (size<2 || size>4) { + gl_error( ctx, GL_INVALID_VALUE, "glVertexPointer(size)" ); + return; + } + if (stride<0) { + gl_error( ctx, GL_INVALID_VALUE, "glVertexPointer(stride)" ); + return; + } + switch (type) { + case GL_SHORT: + ctx->Array.VertexStrideB = stride ? stride : size*sizeof(GLshort); + break; + case GL_INT: + ctx->Array.VertexStrideB = stride ? stride : size*sizeof(GLint); + break; + case GL_FLOAT: + ctx->Array.VertexStrideB = stride ? stride : size*sizeof(GLfloat); + break; + case GL_DOUBLE: + ctx->Array.VertexStrideB = stride ? stride : size*sizeof(GLdouble); + break; + default: + gl_error( ctx, GL_INVALID_ENUM, "glVertexPointer(type)" ); + return; + } + ctx->Array.VertexSize = size; + ctx->Array.VertexType = type; + ctx->Array.VertexStride = stride; + ctx->Array.VertexPtr = (void *) ptr; +} + + + + +void gl_NormalPointer( GLcontext *ctx, + GLenum type, GLsizei stride, const GLvoid *ptr ) +{ + if (stride<0) { + gl_error( ctx, GL_INVALID_VALUE, "glNormalPointer(stride)" ); + return; + } + switch (type) { + case GL_BYTE: + ctx->Array.NormalStrideB = stride ? stride : 3*sizeof(GLbyte); + break; + case GL_SHORT: + ctx->Array.NormalStrideB = stride ? stride : 3*sizeof(GLshort); + break; + case GL_INT: + ctx->Array.NormalStrideB = stride ? stride : 3*sizeof(GLint); + break; + case GL_FLOAT: + ctx->Array.NormalStrideB = stride ? stride : 3*sizeof(GLfloat); + break; + case GL_DOUBLE: + ctx->Array.NormalStrideB = stride ? stride : 3*sizeof(GLdouble); + break; + default: + gl_error( ctx, GL_INVALID_ENUM, "glNormalPointer(type)" ); + return; + } + ctx->Array.NormalType = type; + ctx->Array.NormalStride = stride; + ctx->Array.NormalPtr = (void *) ptr; +} + + + +void gl_ColorPointer( GLcontext *ctx, + GLint size, GLenum type, GLsizei stride, + const GLvoid *ptr ) +{ + if (size<3 || size>4) { + gl_error( ctx, GL_INVALID_VALUE, "glColorPointer(size)" ); + return; + } + if (stride<0) { + gl_error( ctx, GL_INVALID_VALUE, "glColorPointer(stride)" ); + return; + } + switch (type) { + case GL_BYTE: + ctx->Array.ColorStrideB = stride ? stride : size*sizeof(GLbyte); + break; + case GL_UNSIGNED_BYTE: + ctx->Array.ColorStrideB = stride ? stride : size*sizeof(GLubyte); + break; + case GL_SHORT: + ctx->Array.ColorStrideB = stride ? stride : size*sizeof(GLshort); + break; + case GL_UNSIGNED_SHORT: + ctx->Array.ColorStrideB = stride ? stride : size*sizeof(GLushort); + break; + case GL_INT: + ctx->Array.ColorStrideB = stride ? stride : size*sizeof(GLint); + break; + case GL_UNSIGNED_INT: + ctx->Array.ColorStrideB = stride ? stride : size*sizeof(GLuint); + break; + case GL_FLOAT: + ctx->Array.ColorStrideB = stride ? stride : size*sizeof(GLfloat); + break; + case GL_DOUBLE: + ctx->Array.ColorStrideB = stride ? stride : size*sizeof(GLdouble); + break; + default: + gl_error( ctx, GL_INVALID_ENUM, "glColorPointer(type)" ); + return; + } + ctx->Array.ColorSize = size; + ctx->Array.ColorType = type; + ctx->Array.ColorStride = stride; + ctx->Array.ColorPtr = (void *) ptr; +} + + + +void gl_IndexPointer( GLcontext *ctx, + GLenum type, GLsizei stride, const GLvoid *ptr ) +{ + if (stride<0) { + gl_error( ctx, GL_INVALID_VALUE, "glIndexPointer(stride)" ); + return; + } + switch (type) { + case GL_SHORT: + ctx->Array.IndexStrideB = stride ? stride : sizeof(GLbyte); + break; + case GL_INT: + ctx->Array.IndexStrideB = stride ? stride : sizeof(GLint); + break; + case GL_FLOAT: + ctx->Array.IndexStrideB = stride ? stride : sizeof(GLfloat); + break; + case GL_DOUBLE: + ctx->Array.IndexStrideB = stride ? stride : sizeof(GLdouble); + break; + default: + gl_error( ctx, GL_INVALID_ENUM, "glIndexPointer(type)" ); + return; + } + ctx->Array.IndexType = type; + ctx->Array.IndexStride = stride; + ctx->Array.IndexPtr = (void *) ptr; +} + + + +void gl_TexCoordPointer( GLcontext *ctx, + GLint size, GLenum type, GLsizei stride, + const GLvoid *ptr ) +{ + if (size<1 || size>4) { + gl_error( ctx, GL_INVALID_VALUE, "glTexCoordPointer(size)" ); + return; + } + switch (type) { + case GL_SHORT: + ctx->Array.TexCoordStrideB = stride ? stride : size*sizeof(GLshort); + break; + case GL_INT: + ctx->Array.TexCoordStrideB = stride ? stride : size*sizeof(GLint); + break; + case GL_FLOAT: + ctx->Array.TexCoordStrideB = stride ? stride : size*sizeof(GLfloat); + break; + case GL_DOUBLE: + ctx->Array.TexCoordStrideB = stride ? stride : size*sizeof(GLdouble); + break; + default: + gl_error( ctx, GL_INVALID_ENUM, "glTexCoordPointer(type)" ); + return; + } + if (stride<0) { + gl_error( ctx, GL_INVALID_VALUE, "glTexCoordPointer(stride)" ); + return; + } + ctx->Array.TexCoordSize = size; + ctx->Array.TexCoordType = type; + ctx->Array.TexCoordStride = stride; + ctx->Array.TexCoordPtr = (void *) ptr; +} + + + +void gl_EdgeFlagPointer( GLcontext *ctx, + GLsizei stride, const GLboolean *ptr ) +{ + if (stride<0) { + gl_error( ctx, GL_INVALID_VALUE, "glEdgeFlagPointer(stride)" ); + return; + } + ctx->Array.EdgeFlagStride = stride; + ctx->Array.EdgeFlagStrideB = stride ? stride : sizeof(GLboolean); + ctx->Array.EdgeFlagPtr = (GLboolean *) ptr; +} + + + +/* + * Execute + */ +void gl_ArrayElement( GLcontext *ctx, GLint i ) +{ + struct vertex_buffer *VB = ctx->VB; + GLint count = VB->Count; + + /* copy vertex data into the Vertex Buffer */ + + if (ctx->Array.NormalEnabled) { + GLbyte *p = (GLbyte*) ctx->Array.NormalPtr + + i * ctx->Array.NormalStrideB; + switch (ctx->Array.NormalType) { + case GL_BYTE: + VB->Normal[count][0] = BYTE_TO_FLOAT( p[0] ); + VB->Normal[count][1] = BYTE_TO_FLOAT( p[1] ); + VB->Normal[count][2] = BYTE_TO_FLOAT( p[2] ); + break; + case GL_SHORT: + VB->Normal[count][0] = SHORT_TO_FLOAT( ((GLshort*)p)[0] ); + VB->Normal[count][1] = SHORT_TO_FLOAT( ((GLshort*)p)[1] ); + VB->Normal[count][2] = SHORT_TO_FLOAT( ((GLshort*)p)[2] ); + break; + case GL_INT: + VB->Normal[count][0] = INT_TO_FLOAT( ((GLint*)p)[0] ); + VB->Normal[count][1] = INT_TO_FLOAT( ((GLint*)p)[1] ); + VB->Normal[count][2] = INT_TO_FLOAT( ((GLint*)p)[2] ); + break; + case GL_FLOAT: + VB->Normal[count][0] = ((GLfloat*)p)[0]; + VB->Normal[count][1] = ((GLfloat*)p)[1]; + VB->Normal[count][2] = ((GLfloat*)p)[2]; + break; + case GL_DOUBLE: + VB->Normal[count][0] = ((GLdouble*)p)[0]; + VB->Normal[count][1] = ((GLdouble*)p)[1]; + VB->Normal[count][2] = ((GLdouble*)p)[2]; + break; + default: + gl_problem(ctx, "Bad normal type in gl_ArrayElement"); + return; + } + VB->MonoNormal = GL_FALSE; + } + else { + VB->Normal[count][0] = ctx->Current.Normal[0]; + VB->Normal[count][1] = ctx->Current.Normal[1]; + VB->Normal[count][2] = ctx->Current.Normal[2]; + } + + /* TODO: directly set VB->Fcolor instead of calling a glColor command */ + if (ctx->Array.ColorEnabled) { + GLbyte *p = (GLbyte*) ctx->Array.ColorPtr + i * ctx->Array.ColorStrideB; + switch (ctx->Array.ColorType) { + case GL_BYTE: + switch (ctx->Array.ColorSize) { + case 4: glColor4bv( (GLbyte*) p ); break; + case 3: glColor3bv( (GLbyte*) p ); break; + } + break; + case GL_UNSIGNED_BYTE: + switch (ctx->Array.ColorSize) { + case 3: glColor3ubv( (GLubyte*) p ); break; + case 4: glColor4ubv( (GLubyte*) p ); break; + } + break; + case GL_SHORT: + switch (ctx->Array.ColorSize) { + case 3: glColor3sv( (GLshort*) p ); break; + case 4: glColor4sv( (GLshort*) p ); break; + } + break; + case GL_UNSIGNED_SHORT: + switch (ctx->Array.ColorSize) { + case 3: glColor3usv( (GLushort*) p ); break; + case 4: glColor4usv( (GLushort*) p ); break; + } + break; + case GL_INT: + switch (ctx->Array.ColorSize) { + case 3: glColor3iv( (GLint*) p ); break; + case 4: glColor4iv( (GLint*) p ); break; + } + break; + case GL_UNSIGNED_INT: + switch (ctx->Array.ColorSize) { + case 3: glColor3uiv( (GLuint*) p ); break; + case 4: glColor4uiv( (GLuint*) p ); break; + } + break; + case GL_FLOAT: + switch (ctx->Array.ColorSize) { + case 3: glColor3fv( (GLfloat*) p ); break; + case 4: glColor4fv( (GLfloat*) p ); break; + } + break; + case GL_DOUBLE: + switch (ctx->Array.ColorSize) { + case 3: glColor3dv( (GLdouble*) p ); break; + case 4: glColor4dv( (GLdouble*) p ); break; + } + break; + default: + gl_problem(ctx, "Bad color type in gl_ArrayElement"); + return; + } + ctx->VB->MonoColor = GL_FALSE; + } + + /* current color has been updated. store in vertex buffer now */ + { + COPY_4UBV( VB->Fcolor[count], ctx->Current.ByteColor ); + if (ctx->Light.ColorMaterialEnabled) { + GLfloat color[4]; + color[0] = ctx->Current.ByteColor[0] * ctx->Visual->InvRedScale; + color[1] = ctx->Current.ByteColor[1] * ctx->Visual->InvGreenScale; + color[2] = ctx->Current.ByteColor[2] * ctx->Visual->InvBlueScale; + color[3] = ctx->Current.ByteColor[3] * ctx->Visual->InvAlphaScale; + gl_set_material( ctx, ctx->Light.ColorMaterialBitmask, color ); + } + } + + if (ctx->Array.IndexEnabled) { + GLbyte *p = (GLbyte*) ctx->Array.IndexPtr + i * ctx->Array.IndexStrideB; + switch (ctx->Array.IndexType) { + case GL_SHORT: + VB->Findex[count] = (GLuint) (*((GLshort*) p)); + break; + case GL_INT: + VB->Findex[count] = (GLuint) (*((GLint*) p)); + break; + case GL_FLOAT: + VB->Findex[count] = (GLuint) (*((GLfloat*) p)); + break; + case GL_DOUBLE: + VB->Findex[count] = (GLuint) (*((GLdouble*) p)); + break; + default: + gl_problem(ctx, "Bad index type in gl_ArrayElement"); + return; + } + ctx->VB->MonoColor = GL_FALSE; + } + else { + VB->Findex[count] = ctx->Current.Index; + } + + if (ctx->Array.TexCoordEnabled) { + GLbyte *p = (GLbyte*) ctx->Array.TexCoordPtr + + i * ctx->Array.TexCoordStrideB; + VB->TexCoord[count][1] = 0.0F; + VB->TexCoord[count][2] = 0.0F; + VB->TexCoord[count][3] = 1.0F; + switch (ctx->Array.TexCoordType) { + case GL_SHORT: + switch (ctx->Array.TexCoordSize) { + /* FALL THROUGH! */ + case 4: VB->TexCoord[count][3] = ((GLshort*) p)[3]; + case 3: VB->TexCoord[count][2] = ((GLshort*) p)[2]; + case 2: VB->TexCoord[count][1] = ((GLshort*) p)[1]; + case 1: VB->TexCoord[count][0] = ((GLshort*) p)[0]; + } + break; + case GL_INT: + switch (ctx->Array.TexCoordSize) { + /* FALL THROUGH! */ + case 4: VB->TexCoord[count][3] = ((GLint*) p)[3]; + case 3: VB->TexCoord[count][2] = ((GLint*) p)[2]; + case 2: VB->TexCoord[count][1] = ((GLint*) p)[1]; + case 1: VB->TexCoord[count][0] = ((GLint*) p)[0]; + } + break; + case GL_FLOAT: + switch (ctx->Array.TexCoordSize) { + /* FALL THROUGH! */ + case 4: VB->TexCoord[count][3] = ((GLfloat*) p)[3]; + case 3: VB->TexCoord[count][2] = ((GLfloat*) p)[2]; + case 2: VB->TexCoord[count][1] = ((GLfloat*) p)[1]; + case 1: VB->TexCoord[count][0] = ((GLfloat*) p)[0]; + } + break; + case GL_DOUBLE: + switch (ctx->Array.TexCoordSize) { + /* FALL THROUGH! */ + case 4: VB->TexCoord[count][3] = ((GLdouble*) p)[3]; + case 3: VB->TexCoord[count][2] = ((GLdouble*) p)[2]; + case 2: VB->TexCoord[count][1] = ((GLdouble*) p)[1]; + case 1: VB->TexCoord[count][0] = ((GLdouble*) p)[0]; + } + break; + default: + gl_problem(ctx, "Bad texcoord type in gl_ArrayElement"); + return; + } + } + else { + COPY_4V( VB->TexCoord[count], ctx->Current.TexCoord ); + } + + if (ctx->Array.EdgeFlagEnabled) { + GLbyte *b = (GLbyte*) ctx->Array.EdgeFlagPtr + + i * ctx->Array.EdgeFlagStrideB; + VB->Edgeflag[count] = *((GLboolean*) b); + } + else { + VB->Edgeflag[count] = ctx->Current.EdgeFlag; + } + + if (ctx->Array.VertexEnabled) { + GLbyte *b = (GLbyte*) ctx->Array.VertexPtr + + i * ctx->Array.VertexStrideB; + VB->Obj[count][2] = 0.0F; + VB->Obj[count][3] = 1.0F; + switch (ctx->Array.VertexType) { + case GL_SHORT: + switch (ctx->Array.VertexSize) { + /* FALL THROUGH */ + case 4: VB->Obj[count][3] = ((GLshort*) b)[3]; + case 3: VB->Obj[count][2] = ((GLshort*) b)[2]; + case 2: VB->Obj[count][1] = ((GLshort*) b)[1]; + VB->Obj[count][0] = ((GLshort*) b)[0]; + } + break; + case GL_INT: + switch (ctx->Array.VertexSize) { + /* FALL THROUGH */ + case 4: VB->Obj[count][3] = ((GLint*) b)[3]; + case 3: VB->Obj[count][2] = ((GLint*) b)[2]; + case 2: VB->Obj[count][1] = ((GLint*) b)[1]; + VB->Obj[count][0] = ((GLint*) b)[0]; + } + break; + case GL_FLOAT: + switch (ctx->Array.VertexSize) { + /* FALL THROUGH */ + case 4: VB->Obj[count][3] = ((GLfloat*) b)[3]; + case 3: VB->Obj[count][2] = ((GLfloat*) b)[2]; + case 2: VB->Obj[count][1] = ((GLfloat*) b)[1]; + VB->Obj[count][0] = ((GLfloat*) b)[0]; + } + break; + case GL_DOUBLE: + switch (ctx->Array.VertexSize) { + /* FALL THROUGH */ + case 4: VB->Obj[count][3] = ((GLdouble*) b)[3]; + case 3: VB->Obj[count][2] = ((GLdouble*) b)[2]; + case 2: VB->Obj[count][1] = ((GLdouble*) b)[1]; + VB->Obj[count][0] = ((GLdouble*) b)[0]; + } + break; + default: + gl_problem(ctx, "Bad vertex type in gl_ArrayElement"); + return; + } + + /* Only store vertex if Vertex array pointer is enabled */ + count++; + VB->Count = count; + if (count==VB_MAX) { + gl_transform_vb_part1( ctx, GL_FALSE ); + } + + } + else { + /* vertex array pointer not enabled: no vertex to process */ + } +} + + + + +/* + * Save into display list + * Use external API entry points since speed isn't too important here + * and makes the code simpler. Also, if GL_COMPILE_AND_EXECUTE then + * execute will happen too. + */ +void gl_save_ArrayElement( GLcontext *ctx, GLint i ) +{ + if (ctx->Array.NormalEnabled) { + GLbyte *p = (GLbyte*) ctx->Array.NormalPtr + + i * ctx->Array.NormalStrideB; + switch (ctx->Array.NormalType) { + case GL_BYTE: + glNormal3bv( (GLbyte*) p ); + break; + case GL_SHORT: + glNormal3sv( (GLshort*) p ); + break; + case GL_INT: + glNormal3iv( (GLint*) p ); + break; + case GL_FLOAT: + glNormal3fv( (GLfloat*) p ); + break; + case GL_DOUBLE: + glNormal3dv( (GLdouble*) p ); + break; + default: + gl_problem(ctx, "Bad normal type in gl_save_ArrayElement"); + return; + } + } + + if (ctx->Array.ColorEnabled) { + GLbyte *p = (GLbyte*) ctx->Array.ColorPtr + i * ctx->Array.ColorStrideB; + switch (ctx->Array.ColorType) { + case GL_BYTE: + switch (ctx->Array.ColorSize) { + case 3: glColor3bv( (GLbyte*) p ); break; + case 4: glColor4bv( (GLbyte*) p ); break; + } + break; + case GL_UNSIGNED_BYTE: + switch (ctx->Array.ColorSize) { + case 3: glColor3ubv( (GLubyte*) p ); break; + case 4: glColor4ubv( (GLubyte*) p ); break; + } + break; + case GL_SHORT: + switch (ctx->Array.ColorSize) { + case 3: glColor3sv( (GLshort*) p ); break; + case 4: glColor4sv( (GLshort*) p ); break; + } + break; + case GL_UNSIGNED_SHORT: + switch (ctx->Array.ColorSize) { + case 3: glColor3usv( (GLushort*) p ); break; + case 4: glColor4usv( (GLushort*) p ); break; + } + break; + case GL_INT: + switch (ctx->Array.ColorSize) { + case 3: glColor3iv( (GLint*) p ); break; + case 4: glColor4iv( (GLint*) p ); break; + } + break; + case GL_UNSIGNED_INT: + switch (ctx->Array.ColorSize) { + case 3: glColor3uiv( (GLuint*) p ); break; + case 4: glColor4uiv( (GLuint*) p ); break; + } + break; + case GL_FLOAT: + switch (ctx->Array.ColorSize) { + case 3: glColor3fv( (GLfloat*) p ); break; + case 4: glColor4fv( (GLfloat*) p ); break; + } + break; + case GL_DOUBLE: + switch (ctx->Array.ColorSize) { + case 3: glColor3dv( (GLdouble*) p ); break; + case 4: glColor4dv( (GLdouble*) p ); break; + } + break; + default: + gl_problem(ctx, "Bad color type in gl_save_ArrayElement"); + return; + } + } + + if (ctx->Array.IndexEnabled) { + GLbyte *p = (GLbyte*) ctx->Array.IndexPtr + i * ctx->Array.IndexStrideB; + switch (ctx->Array.IndexType) { + case GL_SHORT: + glIndexsv( (GLshort*) p ); + break; + case GL_INT: + glIndexiv( (GLint*) p ); + break; + case GL_FLOAT: + glIndexfv( (GLfloat*) p ); + break; + case GL_DOUBLE: + glIndexdv( (GLdouble*) p ); + break; + default: + gl_problem(ctx, "Bad index type in gl_save_ArrayElement"); + return; + } + } + + if (ctx->Array.TexCoordEnabled) { + GLbyte *p = (GLbyte*) ctx->Array.TexCoordPtr + + i * ctx->Array.TexCoordStrideB; + switch (ctx->Array.TexCoordType) { + case GL_SHORT: + switch (ctx->Array.TexCoordSize) { + case 1: glTexCoord1sv( (GLshort*) p ); break; + case 2: glTexCoord2sv( (GLshort*) p ); break; + case 3: glTexCoord3sv( (GLshort*) p ); break; + case 4: glTexCoord4sv( (GLshort*) p ); break; + } + break; + case GL_INT: + switch (ctx->Array.TexCoordSize) { + case 1: glTexCoord1iv( (GLint*) p ); break; + case 2: glTexCoord2iv( (GLint*) p ); break; + case 3: glTexCoord3iv( (GLint*) p ); break; + case 4: glTexCoord4iv( (GLint*) p ); break; + } + break; + case GL_FLOAT: + switch (ctx->Array.TexCoordSize) { + case 1: glTexCoord1fv( (GLfloat*) p ); break; + case 2: glTexCoord2fv( (GLfloat*) p ); break; + case 3: glTexCoord3fv( (GLfloat*) p ); break; + case 4: glTexCoord4fv( (GLfloat*) p ); break; + } + break; + case GL_DOUBLE: + switch (ctx->Array.TexCoordSize) { + case 1: glTexCoord1dv( (GLdouble*) p ); break; + case 2: glTexCoord2dv( (GLdouble*) p ); break; + case 3: glTexCoord3dv( (GLdouble*) p ); break; + case 4: glTexCoord4dv( (GLdouble*) p ); break; + } + break; + default: + gl_problem(ctx, "Bad texcoord type in gl_save_ArrayElement"); + return; + } + } + + if (ctx->Array.EdgeFlagEnabled) { + GLbyte *b = (GLbyte*) ctx->Array.EdgeFlagPtr + i * ctx->Array.EdgeFlagStrideB; + glEdgeFlagv( (GLboolean*) b ); + } + + if (ctx->Array.VertexEnabled) { + GLbyte *b = (GLbyte*) ctx->Array.VertexPtr + + i * ctx->Array.VertexStrideB; + switch (ctx->Array.VertexType) { + case GL_SHORT: + switch (ctx->Array.VertexSize) { + case 2: glVertex2sv( (GLshort*) b ); break; + case 3: glVertex3sv( (GLshort*) b ); break; + case 4: glVertex4sv( (GLshort*) b ); break; + } + break; + case GL_INT: + switch (ctx->Array.VertexSize) { + case 2: glVertex2iv( (GLint*) b ); break; + case 3: glVertex3iv( (GLint*) b ); break; + case 4: glVertex4iv( (GLint*) b ); break; + } + break; + case GL_FLOAT: + switch (ctx->Array.VertexSize) { + case 2: glVertex2fv( (GLfloat*) b ); break; + case 3: glVertex3fv( (GLfloat*) b ); break; + case 4: glVertex4fv( (GLfloat*) b ); break; + } + break; + case GL_DOUBLE: + switch (ctx->Array.VertexSize) { + case 2: glVertex2dv( (GLdouble*) b ); break; + case 3: glVertex3dv( (GLdouble*) b ); break; + case 4: glVertex4dv( (GLdouble*) b ); break; + } + break; + default: + gl_problem(ctx, "Bad vertex type in gl_save_ArrayElement"); + return; + } + } +} + + + +/* + * Execute + */ +void gl_DrawArrays( GLcontext *ctx, + GLenum mode, GLint first, GLsizei count ) +{ + struct vertex_buffer* VB = ctx->VB; + + GLint i; + GLboolean need_edges; + + if (INSIDE_BEGIN_END(ctx)) { + gl_error( ctx, GL_INVALID_OPERATION, "glDrawArrays" ); + return; + } + if (count<0) { + gl_error( ctx, GL_INVALID_VALUE, "glDrawArrays(count)" ); + return; + } + + if (ctx->Primitive==GL_TRIANGLES || ctx->Primitive==GL_QUADS + || ctx->Primitive==GL_POLYGON) { + need_edges = GL_TRUE; + } + else { + need_edges = GL_FALSE; + } + + if (!ctx->Light.Enabled + && !ctx->Texture.Enabled + && ctx->Array.VertexEnabled && ctx->Array.VertexType==GL_FLOAT + && ctx->Array.VertexStride==0 && ctx->Array.VertexSize==3 + && !ctx->Array.NormalEnabled + && !ctx->Array.ColorEnabled + && !ctx->Array.IndexEnabled + && !ctx->Array.TexCoordEnabled + && !ctx->Array.EdgeFlagEnabled) { + /* + * SPECIAL CASE: glVertex3fv() with no lighting + */ + GLfloat (*vptr)[3]; + GLint remaining; + + gl_Begin( ctx, mode ); + + remaining = count; + vptr = (GLfloat (*)[3]) ctx->Array.VertexPtr; + vptr += 3 * first; + while (remaining>0) { + GLint vbspace, n; + + vbspace = VB_MAX - VB->Start; + n = MIN2( vbspace, remaining ); + + gl_xform_points_3fv( n, VB->Eye+VB->Start, ctx->ModelViewMatrix, vptr ); + + /* assign vertex colors */ + { + GLint i, start = VB->Start; + for (i=0;iFcolor[start+i], ctx->Current.ByteColor ); + } + } + + /* assign polygon edgeflags */ + if (need_edges) { + GLint i; + for (i=0;iEdgeflag[VB->Start+i] = ctx->Current.EdgeFlag; + } + } + + remaining -= n; + + VB->MonoNormal = GL_FALSE; + VB->Count = VB->Start + n; + gl_transform_vb_part2( ctx, remaining==0 ? GL_TRUE : GL_FALSE ); + + vptr += n; + } + + gl_End( ctx ); + } + else if (!ctx->CompileFlag + && ctx->Light.Enabled + && !ctx->Texture.Enabled + && ctx->Array.VertexEnabled && ctx->Array.VertexType==GL_FLOAT + && ctx->Array.VertexStride==0 && ctx->Array.VertexSize==4 + && ctx->Array.NormalEnabled && ctx->Array.NormalType==GL_FLOAT + && ctx->Array.NormalStride==0 + && !ctx->Array.ColorEnabled + && !ctx->Array.IndexEnabled + && !ctx->Array.TexCoordEnabled + && !ctx->Array.EdgeFlagEnabled) { + /* + * SPECIAL CASE: glNormal3fv(); glVertex4fv(); with lighting + */ + GLfloat (*vptr)[4], (*nptr)[3]; + GLint remaining; + + gl_Begin( ctx, mode ); + + remaining = count; + vptr = (GLfloat (*)[4]) ctx->Array.VertexPtr; + vptr += 4 * first; + nptr = (GLfloat (*)[3]) ctx->Array.NormalPtr; + nptr += 3 * first; + while (remaining>0) { + GLint vbspace, n; + + vbspace = VB_MAX - VB->Start; + n = MIN2( vbspace, remaining ); + + gl_xform_points_4fv( n, VB->Eye+VB->Start, ctx->ModelViewMatrix, vptr ); + gl_xform_normals_3fv( n, VB->Normal+VB->Start, ctx->ModelViewInv, nptr, + ctx->Transform.Normalize ); + + /* assign polygon edgeflags */ + if (need_edges) { + GLint i; + for (i=0;iEdgeflag[VB->Start+i] = ctx->Current.EdgeFlag; + } + } + + remaining -= n; + + VB->MonoNormal = GL_FALSE; + VB->Count = VB->Start + n; + gl_transform_vb_part2( ctx, remaining==0 ? GL_TRUE : GL_FALSE ); + + vptr += n; + nptr += n; + } + + gl_End( ctx ); + } + else if (!ctx->CompileFlag + && ctx->Light.Enabled + && !ctx->Texture.Enabled + && ctx->Array.VertexEnabled && ctx->Array.VertexType==GL_FLOAT + && ctx->Array.VertexStride==0 && ctx->Array.VertexSize==3 + && ctx->Array.NormalEnabled && ctx->Array.NormalType==GL_FLOAT + && ctx->Array.NormalStride==0 + && !ctx->Array.ColorEnabled + && !ctx->Array.IndexEnabled + && !ctx->Array.TexCoordEnabled + && !ctx->Array.EdgeFlagEnabled) { + /* + * SPECIAL CASE: glNormal3fv(); glVertex3fv(); with lighting + */ + GLfloat (*vptr)[3], (*nptr)[3]; + GLint remaining; + + gl_Begin( ctx, mode ); + + remaining = count; + vptr = (GLfloat (*)[3]) ctx->Array.VertexPtr; + vptr += 3 * first; + nptr = (GLfloat (*)[3]) ctx->Array.NormalPtr; + nptr += 3 * first; + while (remaining>0) { + GLint vbspace, n; + + vbspace = VB_MAX - VB->Start; + n = MIN2( vbspace, remaining ); + + gl_xform_points_3fv( n, VB->Eye+VB->Start, ctx->ModelViewMatrix, vptr ); + gl_xform_normals_3fv( n, VB->Normal+VB->Start, ctx->ModelViewInv, nptr, + ctx->Transform.Normalize ); + + /* assign polygon edgeflags */ + if (need_edges) { + GLint i; + for (i=0;iEdgeflag[VB->Start+i] = ctx->Current.EdgeFlag; + } + } + + remaining -= n; + + VB->MonoNormal = GL_FALSE; + VB->Count = VB->Start + n; + gl_transform_vb_part2( ctx, remaining==0 ? GL_TRUE : GL_FALSE ); + + vptr += n; + nptr += n; + } + + gl_End( ctx ); + } + else { + /* + * GENERAL CASE: + */ + gl_Begin( ctx, mode ); + for (i=0;i +#include "types.h" +#include "vb.h" +#endif + + +/* + * Allocate and initialize a vertex buffer. + */ +struct vertex_buffer *gl_alloc_vb(void) +{ + struct vertex_buffer *vb; + vb = (struct vertex_buffer *) calloc(sizeof(struct vertex_buffer), 1); + if (vb) { + /* set non-zero fields */ + GLuint i; + for (i=0;iMaterialMask[i] = 0; + vb->ClipMask[i] = 0; + vb->Obj[i][3] = 1.0F; + vb->TexCoord[i][2] = 0.0F; + vb->TexCoord[i][3] = 1.0F; + } + vb->VertexSizeMask = VERTEX3_BIT; + vb->TexCoordSize = 2; + vb->MonoColor = GL_TRUE; + vb->MonoMaterial = GL_TRUE; + vb->MonoNormal = GL_TRUE; + vb->ClipOrMask = 0; + vb->ClipAndMask = CLIP_ALL_BITS; + } + return vb; +} diff --git a/dll/opengl/mesa/vb.h b/dll/opengl/mesa/vb.h new file mode 100644 index 00000000000..ccd9ba8e204 --- /dev/null +++ b/dll/opengl/mesa/vb.h @@ -0,0 +1,158 @@ +/* $Id: vb.h,v 1.12 1997/08/13 02:07:17 brianp Exp $ */ + +/* + * Mesa 3-D graphics library + * Version: 2.4 + * Copyright (C) 1995-1997 Brian Paul + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Library General Public + * License as published by the Free Software Foundation; either + * version 2 of the License, or (at your option) any later version. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Library General Public License for more details. + * + * You should have received a copy of the GNU Library General Public + * License along with this library; if not, write to the Free + * Software Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. + */ + + +/* + * $Log: vb.h,v $ + * Revision 1.12 1997/08/13 02:07:17 brianp + * set VB_MAX to 72 is using Glide for better performance (David Bucciarelli) + * + * Revision 1.11 1997/06/21 21:30:59 brianp + * updated many comments + * + * Revision 1.10 1997/06/20 02:08:23 brianp + * changed color components from GLfixed to GLubyte + * + * Revision 1.9 1997/05/09 22:41:55 brianp + * replaced gl_init_vb() with gl_alloc_vb() + * + * Revision 1.8 1997/04/24 00:29:36 brianp + * added TexCoordSize + * + * Revision 1.7 1997/04/20 15:59:30 brianp + * removed VERTEX2_BIT stuff + * + * Revision 1.6 1997/04/12 16:21:35 brianp + * added CLIP_* flags and gl_init_vb() + * + * Revision 1.5 1997/04/07 02:59:59 brianp + * added VertexSizeMask + * + * Revision 1.4 1997/04/02 03:13:12 brianp + * removed Unclipped[], added ClipMask[], ClipOrMask, ClipAndMask + * + * Revision 1.3 1996/12/18 19:59:44 brianp + * removed the material bitmask constants + * + * Revision 1.2 1996/09/27 01:31:17 brianp + * added gl_init_vb() prototype + * + * Revision 1.1 1996/09/13 01:38:16 brianp + * Initial revision + * + */ + + +/* + * OVERVIEW: The vertices defined between glBegin() and glEnd() + * are accumulated in the vertex buffer. When either the + * vertex buffer becomes filled or glEnd() is called, we must flush + * the buffer. That is, we apply the vertex transformations, compute + * lighting, fog, texture coordinates etc. Then, we can render the + * vertices as points, lines or polygons by calling the gl_render_vb() + * function in render.c + * + */ + + +#ifndef VB_H +#define VB_H + + +#include "types.h" + + + +/* Flush VB when this number of vertices is accumulated: (a multiple of 12) */ +#define VB_MAX 480 + +/* Arrays must also accomodate new vertices from clipping: */ +#define VB_SIZE (VB_MAX + 2 * (6 + MAX_CLIP_PLANES)) + + +/* Bit values for VertexSizeMask, below. */ +/*#define VERTEX2_BIT 1*/ +#define VERTEX3_BIT 2 +#define VERTEX4_BIT 4 + + + +struct vertex_buffer { + GLfloat Obj[VB_SIZE][4]; /* Object coords */ + GLfloat Eye[VB_SIZE][4]; /* Eye coords */ + GLfloat Clip[VB_SIZE][4]; /* Clip coords */ + GLfloat Win[VB_SIZE][3]; /* Window coords */ + + GLfloat Normal[VB_SIZE][3]; /* Normal vectors */ + + GLubyte Fcolor[VB_SIZE][4]; /* Front colors (RGBA) */ + GLubyte Bcolor[VB_SIZE][4]; /* Back colors (RGBA) */ + GLubyte (*Color)[4]; /* == Fcolor or Bcolor */ + + GLuint Findex[VB_SIZE]; /* Front color indexes */ + GLuint Bindex[VB_SIZE]; /* Back color indexes */ + GLuint *Index; /* == Findex or Bindex */ + + GLboolean Edgeflag[VB_SIZE]; /* Polygon edge flags */ + + GLfloat TexCoord[VB_SIZE][4];/* Texture coords */ + + GLubyte ClipMask[VB_SIZE]; /* bitwise-OR of CLIP_* values, below */ + GLubyte ClipOrMask; /* bitwise-OR of all ClipMask[] values */ + GLubyte ClipAndMask; /* bitwise-AND of all ClipMask[] values */ + + GLuint Start; /* First vertex to process */ + GLuint Count; /* Number of vertexes in buffer */ + GLuint Free; /* Next empty position for clipping */ + + GLuint VertexSizeMask; /* Bitwise-or of VERTEX[234]_BIT */ + GLuint TexCoordSize; /* Either 2 or 4 */ + GLboolean MonoColor; /* Do all vertices have same color? */ + GLboolean MonoNormal; /* Do all vertices have same normal? */ + GLboolean MonoMaterial; /* Do all vertices have same material? */ + + /* to handle glMaterial calls inside glBegin/glEnd: */ + GLuint MaterialMask[VB_SIZE]; /* Which material values to change */ + struct gl_material Material[VB_SIZE][2]; /* New material values */ +}; + + + +/* Vertex buffer clipping flags */ +#define CLIP_RIGHT_BIT 0x01 +#define CLIP_LEFT_BIT 0x02 +#define CLIP_TOP_BIT 0x04 +#define CLIP_BOTTOM_BIT 0x08 +#define CLIP_NEAR_BIT 0x10 +#define CLIP_FAR_BIT 0x20 +#define CLIP_USER_BIT 0x40 +#define CLIP_ALL_BITS 0x3f + +#define CLIP_ALL 1 +#define CLIP_NONE 2 +#define CLIP_SOME 3 + + +extern struct vertex_buffer *gl_alloc_vb(void); + + +#endif diff --git a/dll/opengl/mesa/vbfill.c b/dll/opengl/mesa/vbfill.c new file mode 100644 index 00000000000..17b50c26a3d --- /dev/null +++ b/dll/opengl/mesa/vbfill.c @@ -0,0 +1,1453 @@ +/* $Id: vbfill.c,v 1.22 1998/01/27 03:30:18 brianp Exp $ */ + +/* + * Mesa 3-D graphics library + * Version: 2.6 + * Copyright (C) 1995-1997 Brian Paul + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Library General Public + * License as published by the Free Software Foundation; either + * version 2 of the License, or (at your option) any later version. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Library General Public License for more details. + * + * You should have received a copy of the GNU Library General Public + * License along with this library; if not, write to the Free + * Software Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. + */ + + +/* + * $Log: vbfill.c,v $ + * Revision 1.22 1998/01/27 03:30:18 brianp + * minor tweak to FLOAT_COLOR_TO_UBYTE_COLOR macro: added an F suffix + * + * Revision 1.21 1998/01/25 16:59:13 brianp + * changed IEEE_ONE value to 0x3f7f0000 (Josh Vanderhoof) + * + * Revision 1.20 1998/01/16 01:29:29 brianp + * added DavidB's assembly language version of gl_Color3f() + * + * Revision 1.19 1998/01/09 02:40:43 brianp + * IEEE-optimized glColor[34]f[v]() commands (Josh Vanderhoof) + * + * Revision 1.18 1997/12/18 02:54:48 brianp + * now using FloatToInt() macro for better performance on x86 + * + * Revision 1.17 1997/11/14 03:02:53 brianp + * clamp floating point color components to [0,1] before int conversion + * + * Revision 1.16 1997/08/13 01:31:11 brianp + * LightTwoSide is now a GLboolean + * + * Revision 1.15 1997/07/24 01:25:27 brianp + * changed precompiled header symbol from PCH to PC_HEADER + * + * Revision 1.14 1997/06/20 02:47:41 brianp + * added Color4ubv API pointer + * + * Revision 1.13 1997/06/20 02:46:49 brianp + * changed color components from GLfixed to GLubyte + * + * Revision 1.12 1997/05/28 03:26:49 brianp + * added precompiled header (PCH) support + * + * Revision 1.11 1997/05/27 03:13:41 brianp + * removed some debugging code + * + * Revision 1.10 1997/04/28 02:05:44 brianp + * renamed some vertex functions, also save color with texcoords + * + * Revision 1.9 1997/04/24 01:50:53 brianp + * optimized glColor3f, glColor3fv, glColor4fv + * + * Revision 1.8 1997/04/24 00:30:17 brianp + * optimized glTexCoord2() code + * + * Revision 1.7 1997/04/20 15:59:30 brianp + * removed VERTEX2_BIT stuff + * + * Revision 1.6 1997/04/16 23:55:33 brianp + * added optimized glTexCoord2f code + * + * Revision 1.5 1997/04/14 22:18:23 brianp + * added optimized glVertex3fv code + * + * Revision 1.4 1997/04/12 16:21:54 brianp + * added ctx->Exec.Vertex2f = vertex2_feedback; statement + * + * Revision 1.3 1997/04/12 12:23:26 brianp + * fixed 3 bugs in gl_eval_vertex + * + * Revision 1.2 1997/04/07 03:01:11 brianp + * optimized vertex[234] code + * + * Revision 1.1 1997/04/02 03:13:56 brianp + * Initial revision + * + */ + + +/* + * This file implements the functions for filling the vertex buffer: + * glVertex, glNormal, glColor, glIndex, glEdgeFlag, glTexCoord, + */ + + +#ifdef PC_HEADER +#include "all.h" +#else +#include +#include "context.h" +#include "light.h" +#include "clip.h" +#include "dlist.h" +#include "feedback.h" +#include "macros.h" +#include "matrix.h" +#include "mmath.h" +#include "pb.h" +#include "types.h" +#include "vb.h" +#include "vbfill.h" +#include "vbxform.h" +#include "xform.h" +#endif + + + +/**********************************************************************/ +/****** glNormal functions *****/ +/**********************************************************************/ + +/* + * Caller: context->API.Normal3f pointer. + */ +void gl_Normal3f( GLcontext *ctx, GLfloat nx, GLfloat ny, GLfloat nz ) +{ + ctx->Current.Normal[0] = nx; + ctx->Current.Normal[1] = ny; + ctx->Current.Normal[2] = nz; + ctx->VB->MonoNormal = GL_FALSE; +} + + +/* + * Caller: context->API.Normal3fv pointer. + */ +void gl_Normal3fv( GLcontext *ctx, const GLfloat *n ) +{ + ctx->Current.Normal[0] = n[0]; + ctx->Current.Normal[1] = n[1]; + ctx->Current.Normal[2] = n[2]; + ctx->VB->MonoNormal = GL_FALSE; +} + + + +/**********************************************************************/ +/****** glIndex functions *****/ +/**********************************************************************/ + +/* + * Caller: context->API.Indexf pointer. + */ +void gl_Indexf( GLcontext *ctx, GLfloat c ) +{ + ctx->Current.Index = (GLuint) (GLint) c; + ctx->VB->MonoColor = GL_FALSE; +} + + +/* + * Caller: context->API.Indexi pointer. + */ +void gl_Indexi( GLcontext *ctx, GLint c ) +{ + ctx->Current.Index = (GLuint) c; + ctx->VB->MonoColor = GL_FALSE; +} + + + +/**********************************************************************/ +/****** glColor functions *****/ +/**********************************************************************/ + + +#if defined(__i386__) +#define USE_IEEE +#endif + +#if defined(USE_IEEE) && !defined(DEBUG) && 0 + +#define IEEE_ONE 0x3f7f0000 + +/* + * Optimization for: + * GLfloat f; + * GLubyte b = FloatToInt(CLAMP(f, 0, 1) * 255) + */ +#define FLOAT_COLOR_TO_UBYTE_COLOR(b, f) \ + { \ + GLfloat tmp = f + 32768.0F; \ + b = ((*(GLuint *)&f >= IEEE_ONE) \ + ? (*(GLint *)&f < 0) ? (GLubyte)0 : (GLubyte)255 \ + : (GLubyte)*(GLuint *)&tmp); \ + } + +#else + +#define FLOAT_COLOR_TO_UBYTE_COLOR(b, f) \ + b = FloatToInt(CLAMP(f, 0.0F, 1.0F) * 255.0F) + +#endif + + + +/* + * Used when colors are not scaled to [0,255]. + * Caller: context->API.Color3f pointer. + */ +void gl_Color3f( GLcontext *ctx, GLfloat red, GLfloat green, GLfloat blue ) +{ + ctx->Current.ByteColor[0] = FloatToInt(CLAMP(red , 0.0F, 1.0F) * ctx->Visual->RedScale); + ctx->Current.ByteColor[1] = FloatToInt(CLAMP(green, 0.0F, 1.0F) * ctx->Visual->GreenScale); + ctx->Current.ByteColor[2] = FloatToInt(CLAMP(blue , 0.0F, 1.0F) * ctx->Visual->BlueScale); + ctx->Current.ByteColor[3] = FloatToInt(ctx->Visual->AlphaScale); + ASSERT( !ctx->Light.ColorMaterialEnabled ); + ctx->VB->MonoColor = GL_FALSE; +} + + +/* + * Used when colors are scaled to [0,255]. + * Caller: context->API.Color3f pointer. + */ +void gl_Color3f8bit( GLcontext *ctx, GLfloat red, GLfloat green, GLfloat blue ) +{ + FLOAT_COLOR_TO_UBYTE_COLOR(ctx->Current.ByteColor[0], red); + FLOAT_COLOR_TO_UBYTE_COLOR(ctx->Current.ByteColor[1], green); + FLOAT_COLOR_TO_UBYTE_COLOR(ctx->Current.ByteColor[2], blue); + ctx->Current.ByteColor[3] = 255; + ASSERT( !ctx->Light.ColorMaterialEnabled ); + ctx->VB->MonoColor = GL_FALSE; +} + + +/* + * Used when colors are not scaled to [0,255]. + * Caller: context->API.Color3fv pointer. + */ +void gl_Color3fv( GLcontext *ctx, const GLfloat *c ) +{ + ctx->Current.ByteColor[0] = FloatToInt(CLAMP(c[0], 0.0F, 1.0F) * ctx->Visual->RedScale); + ctx->Current.ByteColor[1] = FloatToInt(CLAMP(c[1], 0.0F, 1.0F) * ctx->Visual->GreenScale); + ctx->Current.ByteColor[2] = FloatToInt(CLAMP(c[2], 0.0F, 1.0F) * ctx->Visual->BlueScale); + ctx->Current.ByteColor[3] = FloatToInt(ctx->Visual->AlphaScale); + ASSERT( !ctx->Light.ColorMaterialEnabled ); + ctx->VB->MonoColor = GL_FALSE; +} + + +/* + * Used when colors are scaled to [0,255]. + * Caller: context->API.Color3fv pointer. + */ +void gl_Color3fv8bit( GLcontext *ctx, const GLfloat *c ) +{ + FLOAT_COLOR_TO_UBYTE_COLOR(ctx->Current.ByteColor[0], c[0]); + FLOAT_COLOR_TO_UBYTE_COLOR(ctx->Current.ByteColor[1], c[1]); + FLOAT_COLOR_TO_UBYTE_COLOR(ctx->Current.ByteColor[2], c[2]); + ctx->Current.ByteColor[3] = 255; + ASSERT( !ctx->Light.ColorMaterialEnabled ); + ctx->VB->MonoColor = GL_FALSE; +} + + + +/* + * Used when colors are not scaled to [0,255]. + * Caller: context->API.Color4f pointer. + */ +void gl_Color4f( GLcontext *ctx, + GLfloat red, GLfloat green, GLfloat blue, GLfloat alpha ) +{ + ctx->Current.ByteColor[0] = FloatToInt(CLAMP(red , 0.0F, 1.0F) * ctx->Visual->RedScale); + ctx->Current.ByteColor[1] = FloatToInt(CLAMP(green, 0.0F, 1.0F) * ctx->Visual->GreenScale); + ctx->Current.ByteColor[2] = FloatToInt(CLAMP(blue , 0.0F, 1.0F) * ctx->Visual->BlueScale); + ctx->Current.ByteColor[3] = FloatToInt(CLAMP(alpha, 0.0F, 1.0F) * ctx->Visual->AlphaScale); + ASSERT( !ctx->Light.ColorMaterialEnabled ); + ctx->VB->MonoColor = GL_FALSE; +} + + +/* + * Used when colors are scaled to [0,255]. + * Caller: context->API.Color4f pointer. + */ +void gl_Color4f8bit( GLcontext *ctx, + GLfloat red, GLfloat green, GLfloat blue, GLfloat alpha ) +{ + FLOAT_COLOR_TO_UBYTE_COLOR(ctx->Current.ByteColor[0], red); + FLOAT_COLOR_TO_UBYTE_COLOR(ctx->Current.ByteColor[1], green); + FLOAT_COLOR_TO_UBYTE_COLOR(ctx->Current.ByteColor[2], blue); + FLOAT_COLOR_TO_UBYTE_COLOR(ctx->Current.ByteColor[3], alpha); + ASSERT( !ctx->Light.ColorMaterialEnabled ); + ctx->VB->MonoColor = GL_FALSE; +} + + +/* + * Used when colors are not scaled to [0,255]. + * Caller: context->API.Color4fv pointer. + */ +void gl_Color4fv( GLcontext *ctx, const GLfloat *c ) +{ + ctx->Current.ByteColor[0] = FloatToInt(CLAMP(c[0], 0.0F, 1.0F) * ctx->Visual->RedScale); + ctx->Current.ByteColor[1] = FloatToInt(CLAMP(c[1], 0.0F, 1.0F) * ctx->Visual->GreenScale); + ctx->Current.ByteColor[2] = FloatToInt(CLAMP(c[2], 0.0F, 1.0F) * ctx->Visual->BlueScale); + ctx->Current.ByteColor[3] = FloatToInt(CLAMP(c[3], 0.0F, 1.0F) * ctx->Visual->AlphaScale); + ASSERT( !ctx->Light.ColorMaterialEnabled ); + ctx->VB->MonoColor = GL_FALSE; +} + + +/* + * Used when colors are scaled to [0,255]. + * Caller: context->API.Color4fv pointer. + */ +void gl_Color4fv8bit( GLcontext *ctx, const GLfloat *c ) +{ + FLOAT_COLOR_TO_UBYTE_COLOR(ctx->Current.ByteColor[0], c[0]); + FLOAT_COLOR_TO_UBYTE_COLOR(ctx->Current.ByteColor[1], c[1]); + FLOAT_COLOR_TO_UBYTE_COLOR(ctx->Current.ByteColor[2], c[2]); + FLOAT_COLOR_TO_UBYTE_COLOR(ctx->Current.ByteColor[3], c[3]); + ASSERT( !ctx->Light.ColorMaterialEnabled ); + ctx->VB->MonoColor = GL_FALSE; +} + + +/* + * Used when colors are not scaled to [0,255] + * Caller: context->API.Color4ub pointer. + */ +void gl_Color4ub( GLcontext *ctx, + GLubyte red, GLubyte green, GLubyte blue, GLubyte alpha ) +{ + ctx->Current.ByteColor[0] = red * ctx->Visual->RedScale * (1.0F/255.0F); + ctx->Current.ByteColor[1] = green * ctx->Visual->GreenScale * (1.0F/255.0F); + ctx->Current.ByteColor[2] = blue * ctx->Visual->BlueScale * (1.0F/255.0F); + ctx->Current.ByteColor[3] = alpha * ctx->Visual->AlphaScale * (1.0F/255.0F); + ASSERT( !ctx->Light.ColorMaterialEnabled ); + ctx->VB->MonoColor = GL_FALSE; +} + + +/* + * Used when colors are scaled to [0,255]. + * Caller: context->API.Color4ub pointer. + */ +void gl_Color4ub8bit( GLcontext *ctx, + GLubyte red, GLubyte green, GLubyte blue, GLubyte alpha ) +{ + ASSIGN_4V( ctx->Current.ByteColor, red, green, blue, alpha ); + ASSERT( !ctx->Light.ColorMaterialEnabled ); + ctx->VB->MonoColor = GL_FALSE; +} + + +/* + * Used when colors are not scaled to [0,255] + * Caller: context->API.Color4ub pointer. + */ +void gl_Color4ubv( GLcontext *ctx, const GLubyte *c ) +{ + ctx->Current.ByteColor[0] = c[0] * ctx->Visual->RedScale * (1.0F/255.0F); + ctx->Current.ByteColor[1] = c[1] * ctx->Visual->GreenScale * (1.0F/255.0F); + ctx->Current.ByteColor[2] = c[2] * ctx->Visual->BlueScale * (1.0F/255.0F); + ctx->Current.ByteColor[3] = c[3] * ctx->Visual->AlphaScale * (1.0F/255.0F); + ASSERT( !ctx->Light.ColorMaterialEnabled ); + ctx->VB->MonoColor = GL_FALSE; +} + + +/* + * This is the most efficient glColor*() command! + * Used when colors are scaled to [0,255]. + * Caller: context->API.Color4ub pointer. + */ +void gl_Color4ubv8bit( GLcontext *ctx, const GLubyte *c ) +{ + COPY_4UBV( ctx->Current.ByteColor, c ); + ASSERT( !ctx->Light.ColorMaterialEnabled ); + ctx->VB->MonoColor = GL_FALSE; +} + + +/* + * glColor() which modifies material(s). + * Caller: context->API.Color3f pointer. + */ +void gl_ColorMat3f( GLcontext *ctx, GLfloat red, GLfloat green, GLfloat blue ) +{ + GLfloat color[4]; + ctx->Current.ByteColor[0] = FloatToInt(CLAMP(red , 0.0F, 1.0F) * ctx->Visual->RedScale); + ctx->Current.ByteColor[1] = FloatToInt(CLAMP(green, 0.0F, 1.0F) * ctx->Visual->GreenScale); + ctx->Current.ByteColor[2] = FloatToInt(CLAMP(blue , 0.0F, 1.0F) * ctx->Visual->BlueScale); + ctx->Current.ByteColor[3] = FloatToInt(ctx->Visual->AlphaScale); + /* update material */ + ASSERT( ctx->Light.ColorMaterialEnabled ); + ASSIGN_4V( color, red, green, blue, 1.0F ); + gl_set_material( ctx, ctx->Light.ColorMaterialBitmask, color ); + ctx->VB->MonoColor = GL_FALSE; +} + + +/* + * glColor() which modifies material(s). + * Caller: context->API.Color3fv pointer. + */ +void gl_ColorMat3fv( GLcontext *ctx, const GLfloat *c ) +{ + GLfloat color[4]; + ctx->Current.ByteColor[0] = FloatToInt(CLAMP(c[0], 0.0F, 1.0F) * ctx->Visual->RedScale); + ctx->Current.ByteColor[1] = FloatToInt(CLAMP(c[1], 0.0F, 1.0F) * ctx->Visual->GreenScale); + ctx->Current.ByteColor[2] = FloatToInt(CLAMP(c[2], 0.0F, 1.0F) * ctx->Visual->BlueScale); + ctx->Current.ByteColor[3] = FloatToInt(ctx->Visual->AlphaScale); + /* update material */ + ASSERT( ctx->Light.ColorMaterialEnabled ); + ASSIGN_4V( color, c[0], c[1], c[2], 1.0F ); + gl_set_material( ctx, ctx->Light.ColorMaterialBitmask, color ); + ctx->VB->MonoColor = GL_FALSE; +} + + +/* + * glColor() which modifies material(s). + * Caller: context->API.Color4f pointer. + */ +void gl_ColorMat4f( GLcontext *ctx, + GLfloat red, GLfloat green, GLfloat blue, GLfloat alpha ) +{ + GLfloat color[4]; + ctx->Current.ByteColor[0] = FloatToInt(CLAMP(red , 0.0F, 1.0F) * ctx->Visual->RedScale); + ctx->Current.ByteColor[1] = FloatToInt(CLAMP(green, 0.0F, 1.0F) * ctx->Visual->GreenScale); + ctx->Current.ByteColor[2] = FloatToInt(CLAMP(blue , 0.0F, 1.0F) * ctx->Visual->BlueScale); + ctx->Current.ByteColor[3] = FloatToInt(CLAMP(alpha, 0.0F, 1.0F) * ctx->Visual->AlphaScale); + /* update material */ + ASSERT( ctx->Light.ColorMaterialEnabled ); + ASSIGN_4V( color, red, green, blue, alpha ); + gl_set_material( ctx, ctx->Light.ColorMaterialBitmask, color ); + ctx->VB->MonoColor = GL_FALSE; +} + + +/* + * glColor() which modifies material(s). + * Caller: context->API.Color4fv pointer. + */ +void gl_ColorMat4fv( GLcontext *ctx, const GLfloat *c ) +{ + GLfloat color[4]; + ctx->Current.ByteColor[0] = FloatToInt(CLAMP(c[0], 0.0F, 1.0F) * ctx->Visual->RedScale); + ctx->Current.ByteColor[1] = FloatToInt(CLAMP(c[1], 0.0F, 1.0F) * ctx->Visual->GreenScale); + ctx->Current.ByteColor[2] = FloatToInt(CLAMP(c[2], 0.0F, 1.0F) * ctx->Visual->BlueScale); + ctx->Current.ByteColor[3] = FloatToInt(CLAMP(c[3], 0.0F, 1.0F) * ctx->Visual->AlphaScale); + /* update material */ + ASSERT( ctx->Light.ColorMaterialEnabled ); + ASSIGN_4V( color, c[0], c[1], c[2], c[3] ); + gl_set_material( ctx, ctx->Light.ColorMaterialBitmask, color ); + ctx->VB->MonoColor = GL_FALSE; +} + + +/* + * glColor which modifies material(s). + * Caller: context->API.Color4ub pointer. + */ +void gl_ColorMat4ub( GLcontext *ctx, + GLubyte red, GLubyte green, GLubyte blue, GLubyte alpha ) +{ + GLfloat color[4]; + if (ctx->Visual->EightBitColor) { + ASSIGN_4V( ctx->Current.ByteColor, red, green, blue, alpha ); + } + else { + ctx->Current.ByteColor[0] = red * ctx->Visual->RedScale * (1.0F/255.0F); + ctx->Current.ByteColor[1] = green * ctx->Visual->GreenScale * (1.0F/255.0F); + ctx->Current.ByteColor[2] = blue * ctx->Visual->BlueScale * (1.0F/255.0F); + ctx->Current.ByteColor[3] = alpha * ctx->Visual->AlphaScale * (1.0F/255.0F); + } + /* update material */ + ASSERT( ctx->Light.ColorMaterialEnabled ); + color[0] = red * (1.0F/255.0F); + color[1] = green * (1.0F/255.0F); + color[2] = blue * (1.0F/255.0F); + color[3] = alpha * (1.0F/255.0F); + gl_set_material( ctx, ctx->Light.ColorMaterialBitmask, color ); + ctx->VB->MonoColor = GL_FALSE; +} + + +/* + * glColor which modifies material(s). + * Caller: context->API.Color4ub pointer. + */ +void gl_ColorMat4ubv( GLcontext *ctx, const GLubyte *c ) +{ + gl_ColorMat4ub( ctx, c[0], c[1], c[2], c[3] ); +} + + + +/**********************************************************************/ +/****** glEdgeFlag functions *****/ +/**********************************************************************/ + +/* + * Caller: context->API.EdgeFlag pointer. + */ +void gl_EdgeFlag( GLcontext *ctx, GLboolean flag ) +{ + ctx->Current.EdgeFlag = flag; +} + + + +/**********************************************************************/ +/***** glVertex functions *****/ +/**********************************************************************/ + +/* + * Used when in feedback mode. + * Caller: context->API.Vertex4f pointer. + */ +static void vertex4f_feedback( GLcontext *ctx, + GLfloat x, GLfloat y, GLfloat z, GLfloat w ) +{ + struct vertex_buffer *VB = ctx->VB; + GLuint count = VB->Count; + + /* vertex */ + ASSIGN_4V( VB->Obj[count], x, y, z, w ); + + /* color */ + COPY_4UBV( VB->Fcolor[count], ctx->Current.ByteColor ); + + /* index */ + VB->Findex[count] = ctx->Current.Index; + + /* normal */ + COPY_3V( VB->Normal[count], ctx->Current.Normal ); + + /* texcoord */ + COPY_4V( VB->TexCoord[count], ctx->Current.TexCoord ); + + /* edgeflag */ + VB->Edgeflag[count] = ctx->Current.EdgeFlag; + + count++; + VB->Count = count; + if (count==VB_MAX) { + gl_transform_vb_part1( ctx, GL_FALSE ); + } +} + + +static void vertex3f_feedback( GLcontext *ctx, GLfloat x, GLfloat y, GLfloat z ) +{ + vertex4f_feedback(ctx, x, y, z, 1.0F); +} + + +static void vertex2f_feedback( GLcontext *ctx, GLfloat x, GLfloat y ) +{ + vertex4f_feedback(ctx, x, y, 0.0F, 1.0F); +} + + +static void vertex3fv_feedback( GLcontext *ctx, const GLfloat v[3] ) +{ + vertex4f_feedback(ctx, v[0], v[1], v[2], 1.0F); +} + + + +/* + * Only one glVertex4 function since it's not too popular. + * Caller: context->API.Vertex4f pointer. + */ +static void vertex4( GLcontext *ctx, + GLfloat x, GLfloat y, GLfloat z, GLfloat w ) +{ + struct vertex_buffer *VB = ctx->VB; + GLuint count = VB->Count; + + ASSIGN_4V( VB->Obj[count], x, y, z, w ); + COPY_4UBV( VB->Fcolor[count], ctx->Current.ByteColor ); + COPY_3V( VB->Normal[count], ctx->Current.Normal ); + COPY_4V( VB->TexCoord[count], ctx->Current.TexCoord ); + VB->Edgeflag[count] = ctx->Current.EdgeFlag; + VB->VertexSizeMask = VERTEX4_BIT; + + count++; + VB->Count = count; + if (count==VB_MAX) { + gl_transform_vb_part1( ctx, GL_FALSE ); + } +} + + + +/* + * XYZ vertex, RGB color, normal, ST texture coords. + * Caller: context->API.Vertex3f pointer. + */ +static void vertex3f_normal_color_tex2( GLcontext *ctx, + GLfloat x, GLfloat y, GLfloat z ) +{ + struct vertex_buffer *VB = ctx->VB; + GLuint count = VB->Count; + + ASSIGN_3V( VB->Obj[count], x, y, z ); + COPY_4UBV( VB->Fcolor[count], ctx->Current.ByteColor ); + COPY_3V( VB->Normal[count], ctx->Current.Normal ); + COPY_2V( VB->TexCoord[count], ctx->Current.TexCoord ); + VB->Edgeflag[count] = ctx->Current.EdgeFlag; + + count++; + VB->Count = count; + if (count==VB_MAX) { + gl_transform_vb_part1( ctx, GL_FALSE ); + } +} + + +/* + * XYZ vertex, RGB color, normal, STRQ texture coords. + * Caller: context->API.Vertex3f pointer. + */ +static void vertex3f_normal_color_tex4( GLcontext *ctx, + GLfloat x, GLfloat y, GLfloat z ) +{ + struct vertex_buffer *VB = ctx->VB; + GLuint count = VB->Count; + + ASSIGN_3V( VB->Obj[count], x, y, z ); + COPY_4UBV( VB->Fcolor[count], ctx->Current.ByteColor ); + COPY_3V( VB->Normal[count], ctx->Current.Normal ); + COPY_4V( VB->TexCoord[count], ctx->Current.TexCoord ); + VB->Edgeflag[count] = ctx->Current.EdgeFlag; + + count++; + VB->Count = count; + if (count==VB_MAX) { + gl_transform_vb_part1( ctx, GL_FALSE ); + } +} + + +/* + * XYZ vertex, normal. + * Caller: context->API.Vertex3f pointer. + */ +static void vertex3f_normal( GLcontext *ctx, GLfloat x, GLfloat y, GLfloat z ) +{ + struct vertex_buffer *VB = ctx->VB; + GLuint count = VB->Count; + + ASSIGN_3V( VB->Obj[count], x, y, z ); + COPY_3V( VB->Normal[count], ctx->Current.Normal ); + VB->Edgeflag[count] = ctx->Current.EdgeFlag; + + count++; + VB->Count = count; + if (count==VB_MAX) { + gl_transform_vb_part1( ctx, GL_FALSE ); + } +} + + +/* + * XYZ vertex, ST texture coords. + * Caller: context->API.Vertex3f pointer. + */ +static void vertex3f_color_tex2( GLcontext *ctx, + GLfloat x, GLfloat y, GLfloat z ) +{ + struct vertex_buffer *VB = ctx->VB; + GLuint count = VB->Count; + + ASSIGN_3V( VB->Obj[count], x, y, z ); + COPY_4UBV( VB->Fcolor[count], ctx->Current.ByteColor ); + COPY_2V( VB->TexCoord[count], ctx->Current.TexCoord ); + VB->Edgeflag[count] = ctx->Current.EdgeFlag; + + count++; + VB->Count = count; + if (count==VB_MAX) { + gl_transform_vb_part1( ctx, GL_FALSE ); + } +} + + +/* + * XYZ vertex, STRQ texture coords. + * Caller: context->API.Vertex3f pointer. + */ +static void vertex3f_color_tex4( GLcontext *ctx, + GLfloat x, GLfloat y, GLfloat z ) +{ + struct vertex_buffer *VB = ctx->VB; + GLuint count = VB->Count; + + ASSIGN_3V( VB->Obj[count], x, y, z ); + COPY_4UBV( VB->Fcolor[count], ctx->Current.ByteColor ); + COPY_4V( VB->TexCoord[count], ctx->Current.TexCoord ); + VB->Edgeflag[count] = ctx->Current.EdgeFlag; + + count++; + VB->Count = count; + if (count==VB_MAX) { + gl_transform_vb_part1( ctx, GL_FALSE ); + } +} + + +/* + * XYZ vertex, RGB color. + * Caller: context->API.Vertex3f pointer. + */ +static void vertex3f_color( GLcontext *ctx, GLfloat x, GLfloat y, GLfloat z ) +{ + struct vertex_buffer *VB = ctx->VB; + GLuint count = VB->Count; + + ASSIGN_3V( VB->Obj[count], x, y, z ); + COPY_4UBV( VB->Fcolor[count], ctx->Current.ByteColor ); + VB->Edgeflag[count] = ctx->Current.EdgeFlag; + + count++; + VB->Count = count; + if (count==VB_MAX) { + gl_transform_vb_part1( ctx, GL_FALSE ); + } +} + + +/* + * XYZ vertex, color index. + * Caller: context->API.Vertex3f pointer. + */ +static void vertex3f_index( GLcontext *ctx, GLfloat x, GLfloat y, GLfloat z ) +{ + struct vertex_buffer *VB = ctx->VB; + GLuint count = VB->Count; + + ASSIGN_3V( VB->Obj[count], x, y, z ); + VB->Findex[count] = ctx->Current.Index; + VB->Edgeflag[count] = ctx->Current.EdgeFlag; + + count++; + VB->Count = count; + if (count==VB_MAX) { + gl_transform_vb_part1( ctx, GL_FALSE ); + } +} + + + +/* + * XY vertex, RGB color, normal, ST texture coords. + * Caller: context->API.Vertex2f pointer. + */ +static void vertex2f_normal_color_tex2( GLcontext *ctx, GLfloat x, GLfloat y ) +{ + struct vertex_buffer *VB = ctx->VB; + GLuint count = VB->Count; + + ASSIGN_3V( VB->Obj[count], x, y, 0.0F ); + COPY_4UBV( VB->Fcolor[count], ctx->Current.ByteColor ); + COPY_3V( VB->Normal[count], ctx->Current.Normal ); + COPY_2V( VB->TexCoord[count], ctx->Current.TexCoord ); + VB->Edgeflag[count] = ctx->Current.EdgeFlag; + + count++; + VB->Count = count; + if (count==VB_MAX) { + gl_transform_vb_part1( ctx, GL_FALSE ); + } +} + + +/* + * XY vertex, RGB color, normal, STRQ texture coords. + * Caller: context->API.Vertex2f pointer. + */ +static void vertex2f_normal_color_tex4( GLcontext *ctx, GLfloat x, GLfloat y ) +{ + struct vertex_buffer *VB = ctx->VB; + GLuint count = VB->Count; + + ASSIGN_3V( VB->Obj[count], x, y, 0.0F ); + COPY_4UBV( VB->Fcolor[count], ctx->Current.ByteColor ); + COPY_3V( VB->Normal[count], ctx->Current.Normal ); + COPY_4V( VB->TexCoord[count], ctx->Current.TexCoord ); + VB->Edgeflag[count] = ctx->Current.EdgeFlag; + + count++; + VB->Count = count; + if (count==VB_MAX) { + gl_transform_vb_part1( ctx, GL_FALSE ); + } +} + + +/* + * XY vertex, normal. + * Caller: context->API.Vertex2f pointer. + */ +static void vertex2f_normal( GLcontext *ctx, GLfloat x, GLfloat y ) +{ + struct vertex_buffer *VB = ctx->VB; + GLuint count = VB->Count; + + ASSIGN_3V( VB->Obj[count], x, y, 0.0F ); + COPY_3V( VB->Normal[count], ctx->Current.Normal ); + VB->Edgeflag[count] = ctx->Current.EdgeFlag; + + count++; + VB->Count = count; + if (count==VB_MAX) { + gl_transform_vb_part1( ctx, GL_FALSE ); + } +} + + +/* + * XY vertex, ST texture coords. + * Caller: context->API.Vertex2f pointer. + */ +static void vertex2f_color_tex2( GLcontext *ctx, GLfloat x, GLfloat y ) +{ + struct vertex_buffer *VB = ctx->VB; + GLuint count = VB->Count; + + ASSIGN_3V( VB->Obj[count], x, y, 0.0F ); + COPY_4UBV( VB->Fcolor[count], ctx->Current.ByteColor ); + COPY_2V( VB->TexCoord[count], ctx->Current.TexCoord ); + VB->Edgeflag[count] = ctx->Current.EdgeFlag; + + count++; + VB->Count = count; + if (count==VB_MAX) { + gl_transform_vb_part1( ctx, GL_FALSE ); + } +} + + +/* + * XY vertex, STRQ texture coords. + * Caller: context->API.Vertex2f pointer. + */ +static void vertex2f_color_tex4( GLcontext *ctx, GLfloat x, GLfloat y ) +{ + struct vertex_buffer *VB = ctx->VB; + GLuint count = VB->Count; + + ASSIGN_3V( VB->Obj[count], x, y, 0.0F ); + COPY_4UBV( VB->Fcolor[count], ctx->Current.ByteColor ); + COPY_4V( VB->TexCoord[count], ctx->Current.TexCoord ); + VB->Edgeflag[count] = ctx->Current.EdgeFlag; + + count++; + VB->Count = count; + if (count==VB_MAX) { + gl_transform_vb_part1( ctx, GL_FALSE ); + } +} + + +/* + * XY vertex, RGB color. + * Caller: context->API.Vertex2f pointer. + */ +static void vertex2f_color( GLcontext *ctx, GLfloat x, GLfloat y ) +{ + struct vertex_buffer *VB = ctx->VB; + GLuint count = VB->Count; + + ASSIGN_3V( VB->Obj[count], x, y, 0.0F ); + COPY_4UBV( VB->Fcolor[count], ctx->Current.ByteColor ); + VB->Edgeflag[count] = ctx->Current.EdgeFlag; + + count++; + VB->Count = count; + if (count==VB_MAX) { + gl_transform_vb_part1( ctx, GL_FALSE ); + } +} + + +/* + * XY vertex, color index. + * Caller: context->API.Vertex3f pointer. + */ +static void vertex2f_index( GLcontext *ctx, GLfloat x, GLfloat y ) +{ + struct vertex_buffer *VB = ctx->VB; + GLuint count = VB->Count; + + ASSIGN_3V( VB->Obj[count], x, y, 0.0F ); + VB->Findex[count] = ctx->Current.Index; + VB->Edgeflag[count] = ctx->Current.EdgeFlag; + + count++; + VB->Count = count; + if (count==VB_MAX) { + gl_transform_vb_part1( ctx, GL_FALSE ); + } +} + + + + +/* + * XYZ vertex, RGB color, normal, ST texture coords. + * Caller: context->API.Vertex3f pointer. + */ +static void vertex3fv_normal_color_tex2( GLcontext *ctx, const GLfloat v[3] ) +{ + struct vertex_buffer *VB = ctx->VB; + GLuint count = VB->Count; + + COPY_3V( VB->Obj[count], v ); + COPY_4UBV( VB->Fcolor[count], ctx->Current.ByteColor ); + COPY_3V( VB->Normal[count], ctx->Current.Normal ); + COPY_2V( VB->TexCoord[count], ctx->Current.TexCoord ); + VB->Edgeflag[count] = ctx->Current.EdgeFlag; + + count++; + VB->Count = count; + if (count==VB_MAX) { + gl_transform_vb_part1( ctx, GL_FALSE ); + } +} + + +/* + * XYZ vertex, RGB color, normal, STRQ texture coords. + * Caller: context->API.Vertex3f pointer. + */ +static void vertex3fv_normal_color_tex4( GLcontext *ctx, const GLfloat v[3] ) +{ + struct vertex_buffer *VB = ctx->VB; + GLuint count = VB->Count; + + COPY_3V( VB->Obj[count], v ); + COPY_4UBV( VB->Fcolor[count], ctx->Current.ByteColor ); + COPY_3V( VB->Normal[count], ctx->Current.Normal ); + COPY_4V( VB->TexCoord[count], ctx->Current.TexCoord ); + VB->Edgeflag[count] = ctx->Current.EdgeFlag; + + count++; + VB->Count = count; + if (count==VB_MAX) { + gl_transform_vb_part1( ctx, GL_FALSE ); + } +} + + +/* + * XYZ vertex, normal. + * Caller: context->API.Vertex3f pointer. + */ +static void vertex3fv_normal( GLcontext *ctx, const GLfloat v[3] ) +{ + struct vertex_buffer *VB = ctx->VB; + GLuint count = VB->Count; + + COPY_3V( VB->Obj[count], v ); + COPY_3V( VB->Normal[count], ctx->Current.Normal ); + VB->Edgeflag[count] = ctx->Current.EdgeFlag; + + count++; + VB->Count = count; + if (count==VB_MAX) { + gl_transform_vb_part1( ctx, GL_FALSE ); + } +} + + +/* + * XYZ vertex, ST texture coords. + * Caller: context->API.Vertex3f pointer. + */ +static void vertex3fv_color_tex2( GLcontext *ctx, const GLfloat v[3] ) +{ + struct vertex_buffer *VB = ctx->VB; + GLuint count = VB->Count; + + COPY_3V( VB->Obj[count], v ); + COPY_4UBV( VB->Fcolor[count], ctx->Current.ByteColor ); + COPY_2V( VB->TexCoord[count], ctx->Current.TexCoord ); + VB->Edgeflag[count] = ctx->Current.EdgeFlag; + + count++; + VB->Count = count; + if (count==VB_MAX) { + gl_transform_vb_part1( ctx, GL_FALSE ); + } +} + + +/* + * XYZ vertex, STRQ texture coords. + * Caller: context->API.Vertex3f pointer. + */ +static void vertex3fv_color_tex4( GLcontext *ctx, const GLfloat v[3] ) +{ + struct vertex_buffer *VB = ctx->VB; + GLuint count = VB->Count; + + COPY_3V( VB->Obj[count], v ); + COPY_4UBV( VB->Fcolor[count], ctx->Current.ByteColor ); + COPY_4V( VB->TexCoord[count], ctx->Current.TexCoord ); + VB->Edgeflag[count] = ctx->Current.EdgeFlag; + + count++; + VB->Count = count; + if (count==VB_MAX) { + gl_transform_vb_part1( ctx, GL_FALSE ); + } +} + + +/* + * XYZ vertex, RGB color. + * Caller: context->API.Vertex3f pointer. + */ +static void vertex3fv_color( GLcontext *ctx, const GLfloat v[3] ) +{ + struct vertex_buffer *VB = ctx->VB; + GLuint count = VB->Count; + + COPY_3V( VB->Obj[count], v ); + COPY_4UBV( VB->Fcolor[count], ctx->Current.ByteColor ); + VB->Edgeflag[count] = ctx->Current.EdgeFlag; + + count++; + VB->Count = count; + if (count==VB_MAX) { + gl_transform_vb_part1( ctx, GL_FALSE ); + } +} + + +/* + * XYZ vertex, Color index + * Caller: context->API.Vertex3f pointer. + */ +static void vertex3fv_index( GLcontext *ctx, const GLfloat v[3] ) +{ + struct vertex_buffer *VB = ctx->VB; + GLuint count = VB->Count; + + COPY_3V( VB->Obj[count], v ); + VB->Findex[count] = ctx->Current.Index; + VB->Edgeflag[count] = ctx->Current.EdgeFlag; + + count++; + VB->Count = count; + if (count==VB_MAX) { + gl_transform_vb_part1( ctx, GL_FALSE ); + } +} + + + +/* + * Called when outside glBegin/glEnd, raises an error. + * Caller: context->API.Vertex4f pointer. + */ +void gl_vertex4f_nop( GLcontext *ctx, + GLfloat x, GLfloat y, GLfloat z, GLfloat w ) +{ + gl_error( ctx, GL_INVALID_OPERATION, "glVertex4" ); +} + +void gl_vertex3f_nop( GLcontext *ctx, GLfloat x, GLfloat y, GLfloat z ) +{ + gl_error( ctx, GL_INVALID_OPERATION, "glVertex3" ); +} + +void gl_vertex2f_nop( GLcontext *ctx, GLfloat x, GLfloat y ) +{ + gl_error( ctx, GL_INVALID_OPERATION, "glVertex2" ); +} + +void gl_vertex3fv_nop( GLcontext *ctx, const GLfloat v[3] ) +{ + gl_error( ctx, GL_INVALID_OPERATION, "glVertex3v" ); +} + + + + +/**********************************************************************/ +/****** glTexCoord functions *****/ +/**********************************************************************/ + +/* + * Caller: context->API.TexCoord2f pointer. + */ +void gl_TexCoord2f( GLcontext *ctx, GLfloat s, GLfloat t ) +{ + ctx->Current.TexCoord[0] = s; + ctx->Current.TexCoord[1] = t; +} + + +/* + * Caller: context->API.TexCoord2f pointer. + * This version of glTexCoord2 is called if glTexCoord[34] was a predecessor. + */ +void gl_TexCoord2f4( GLcontext *ctx, GLfloat s, GLfloat t ) +{ + ctx->Current.TexCoord[0] = s; + ctx->Current.TexCoord[1] = t; + ctx->Current.TexCoord[2] = 0.0F; + ctx->Current.TexCoord[3] = 1.0F; +} + + +/* + * Caller: context->API.TexCoord4f pointer. + */ +void gl_TexCoord4f( GLcontext *ctx, GLfloat s, GLfloat t, GLfloat r, GLfloat q) +{ + ctx->Current.TexCoord[0] = s; + ctx->Current.TexCoord[1] = t; + ctx->Current.TexCoord[2] = r; + ctx->Current.TexCoord[3] = q; + if (ctx->VB->TexCoordSize==2) { + /* Have to switch to 4-component texture mode now */ + ctx->VB->TexCoordSize = 4; + gl_set_vertex_function( ctx ); + ctx->Exec.TexCoord2f = ctx->API.TexCoord2f = gl_TexCoord2f4; + } +} + + + + +/* + * This function examines the current GL state and sets the + * ctx->Exec.Vertex[34]f pointers to point at the appropriate vertex + * processing functions. + */ +void gl_set_vertex_function( GLcontext *ctx ) +{ + if (ctx->RenderMode==GL_FEEDBACK) { + ctx->Exec.Vertex4f = vertex4f_feedback; + ctx->Exec.Vertex3f = vertex3f_feedback; + ctx->Exec.Vertex2f = vertex2f_feedback; + ctx->Exec.Vertex3fv = vertex3fv_feedback; + } + else { + ctx->Exec.Vertex4f = vertex4; + if (ctx->Visual->RGBAflag) { + if (ctx->NeedNormals) { + /* lighting enabled, need normal vectors */ + if (ctx->Texture.Enabled) { + if (ctx->VB->TexCoordSize==2) { + ctx->Exec.Vertex2f = vertex2f_normal_color_tex2; + ctx->Exec.Vertex3f = vertex3f_normal_color_tex2; + ctx->Exec.Vertex3fv = vertex3fv_normal_color_tex2; + } + else { + ctx->Exec.Vertex2f = vertex2f_normal_color_tex4; + ctx->Exec.Vertex3f = vertex3f_normal_color_tex4; + ctx->Exec.Vertex3fv = vertex3fv_normal_color_tex4; + } + } + else { + ctx->Exec.Vertex2f = vertex2f_normal; + ctx->Exec.Vertex3f = vertex3f_normal; + ctx->Exec.Vertex3fv = vertex3fv_normal; + } + } + else { + /* not lighting, need vertex color */ + if (ctx->Texture.Enabled) { + if (ctx->VB->TexCoordSize==2) { + ctx->Exec.Vertex2f = vertex2f_color_tex2; + ctx->Exec.Vertex3f = vertex3f_color_tex2; + ctx->Exec.Vertex3fv = vertex3fv_color_tex2; + } + else { + ctx->Exec.Vertex2f = vertex2f_color_tex4; + ctx->Exec.Vertex3f = vertex3f_color_tex4; + ctx->Exec.Vertex3fv = vertex3fv_color_tex4; + } + } + else { + ctx->Exec.Vertex2f = vertex2f_color; + ctx->Exec.Vertex3f = vertex3f_color; + ctx->Exec.Vertex3fv = vertex3fv_color; + } + } + } + else { + /* color index mode */ + if (ctx->Light.Enabled) { + ctx->Exec.Vertex2f = vertex2f_normal; + ctx->Exec.Vertex3f = vertex3f_normal; + ctx->Exec.Vertex3fv = vertex3fv_normal; + } + else { + ctx->Exec.Vertex2f = vertex2f_index; + ctx->Exec.Vertex3f = vertex3f_index; + ctx->Exec.Vertex3fv = vertex3fv_index; + } + } + } + + if (!ctx->CompileFlag) { + ctx->API.Vertex2f = ctx->Exec.Vertex2f; + ctx->API.Vertex3f = ctx->Exec.Vertex3f; + ctx->API.Vertex4f = ctx->Exec.Vertex4f; + ctx->API.Vertex3fv = ctx->Exec.Vertex3fv; + } +} + + + +/* + * This function examines the current GL state and sets the + * ctx->Exec.Color[34]* pointers to point at the appropriate vertex + * processing functions. + */ +void gl_set_color_function( GLcontext *ctx ) +{ + ASSERT( !INSIDE_BEGIN_END(ctx) ); + + if (ctx->Light.ColorMaterialEnabled) { + ctx->Exec.Color3f = gl_ColorMat3f; + ctx->Exec.Color3fv = gl_ColorMat3fv; + ctx->Exec.Color4f = gl_ColorMat4f; + ctx->Exec.Color4fv = gl_ColorMat4fv; + ctx->Exec.Color4ub = gl_ColorMat4ub; + ctx->Exec.Color4ubv = gl_ColorMat4ubv; + } + else if (ctx->Visual->EightBitColor) { + ctx->Exec.Color3f = gl_Color3f8bit; + ctx->Exec.Color3fv = gl_Color3fv8bit; + ctx->Exec.Color4f = gl_Color4f8bit; + ctx->Exec.Color4fv = gl_Color4fv8bit; + ctx->Exec.Color4ub = gl_Color4ub8bit; + ctx->Exec.Color4ubv = gl_Color4ubv8bit; + } + else { + ctx->Exec.Color3f = gl_Color3f; + ctx->Exec.Color3fv = gl_Color3fv; + ctx->Exec.Color4f = gl_Color4f; + ctx->Exec.Color4fv = gl_Color4fv; + ctx->Exec.Color4ub = gl_Color4ub; + ctx->Exec.Color4ubv = gl_Color4ubv; + } + if (!ctx->CompileFlag) { + ctx->API.Color3f = ctx->Exec.Color3f; + ctx->API.Color3fv = ctx->Exec.Color3fv; + ctx->API.Color4f = ctx->Exec.Color4f; + ctx->API.Color4fv = ctx->Exec.Color4fv; + ctx->API.Color4ub = ctx->Exec.Color4ub; + ctx->API.Color4ubv = ctx->Exec.Color4ubv; + } +} + + + +/**********************************************************************/ +/***** Evaluator vertices *****/ +/**********************************************************************/ + + +/* + * Process a vertex produced by an evaluator. + * Caller: eval.c + * Input: vertex - the X,Y,Z,W vertex + * normal - normal vector + * color - 4 integer color components + * index - color index + * texcoord - texture coordinate + */ +void gl_eval_vertex( GLcontext *ctx, + const GLfloat vertex[4], const GLfloat normal[3], + const GLubyte color[4], + GLuint index, + const GLfloat texcoord[4] ) +{ + struct vertex_buffer *VB = ctx->VB; + GLuint count = VB->Count; /* copy to local var to encourage optimization */ + + VB->VertexSizeMask = VERTEX4_BIT; + VB->MonoNormal = GL_FALSE; + COPY_4V( VB->Obj[count], vertex ); + COPY_3V( VB->Normal[count], normal ); + COPY_4UBV( VB->Fcolor[count], color ); + +#ifdef GL_VERSION_1_1 + if (ctx->Light.ColorMaterialEnabled + && (ctx->Eval.Map1Color4 || ctx->Eval.Map2Color4)) { + GLfloat fcolor[4]; + fcolor[0] = color[0] * ctx->Visual->InvRedScale; + fcolor[1] = color[1] * ctx->Visual->InvGreenScale; + fcolor[2] = color[2] * ctx->Visual->InvBlueScale; + fcolor[3] = color[3] * ctx->Visual->InvAlphaScale; + gl_set_material( ctx, ctx->Light.ColorMaterialBitmask, fcolor ); + } +#endif + VB->Findex[count] = index; + COPY_4V( VB->TexCoord[count], texcoord ); + VB->Edgeflag[count] = ctx->Current.EdgeFlag; + + count++; + VB->Count = count; + if (count==VB_MAX) { + gl_transform_vb_part1( ctx, GL_FALSE ); + } +} + + + + + +/**********************************************************************/ +/***** glBegin / glEnd *****/ +/**********************************************************************/ + + +#ifdef PROFILE +static GLdouble begin_time; +#endif + + +void gl_Begin( GLcontext *ctx, GLenum p ) +{ + struct vertex_buffer *VB = ctx->VB; + struct pixel_buffer *PB = ctx->PB; +#ifdef PROFILE + begin_time = gl_time(); +#endif + + if (INSIDE_BEGIN_END(ctx)) { + gl_error( ctx, GL_INVALID_OPERATION, "glBegin" ); + return; + } + if (ctx->NewModelViewMatrix) { + gl_analyze_modelview_matrix(ctx); + } + if (ctx->NewProjectionMatrix) { + gl_analyze_projection_matrix(ctx); + } + if (ctx->NewState) { + gl_update_state(ctx); + } + else if (ctx->Exec.Vertex3f==gl_vertex3f_nop) { + gl_set_vertex_function(ctx); + } + + if (ctx->Driver.Begin) { + (*ctx->Driver.Begin)( ctx, p ); + } + + ctx->Primitive = p; + VB->Start = VB->Count = 0; + + VB->MonoColor = ctx->MonoPixels; + VB->MonoNormal = GL_TRUE; + if (VB->MonoColor) { + /* All pixels generated are likely to be the same color so have + * the device driver set the "monocolor" now. + */ + if (ctx->Visual->RGBAflag) { + GLubyte r = ctx->Current.ByteColor[0]; + GLubyte g = ctx->Current.ByteColor[1]; + GLubyte b = ctx->Current.ByteColor[2]; + GLubyte a = ctx->Current.ByteColor[3]; + (*ctx->Driver.Color)( ctx, r, g, b, a ); + } + else { + (*ctx->Driver.Index)( ctx, ctx->Current.Index ); + } + } + + /* By default use front color/index. Two-sided lighting may override. */ + VB->Color = VB->Fcolor; + VB->Index = VB->Findex; + + switch (ctx->Primitive) { + case GL_POINTS: + ctx->LightTwoSide = GL_FALSE; + PB_INIT( PB, GL_POINT ); + break; + case GL_LINES: + case GL_LINE_STRIP: + case GL_LINE_LOOP: + ctx->LightTwoSide = GL_FALSE; + ctx->StippleCounter = 0; + PB_INIT( PB, GL_LINE ); + break; + case GL_TRIANGLES: + case GL_TRIANGLE_STRIP: + case GL_TRIANGLE_FAN: + case GL_QUADS: + case GL_QUAD_STRIP: + case GL_POLYGON: + ctx->LightTwoSide = ctx->Light.Enabled && ctx->Light.Model.TwoSide; + PB_INIT( PB, GL_POLYGON ); + break; + default: + gl_error( ctx, GL_INVALID_ENUM, "glBegin" ); + ctx->Primitive = GL_BITMAP; + } +} + + + +void gl_End( GLcontext *ctx ) +{ + struct pixel_buffer *PB = ctx->PB; + struct vertex_buffer *VB = ctx->VB; + + if (ctx->Primitive==GL_BITMAP) { + /* glEnd without glBegin */ + gl_error( ctx, GL_INVALID_OPERATION, "glEnd" ); + return; + } + + if (VB->Count > VB->Start) { + gl_transform_vb_part1( ctx, GL_TRUE ); + } + if (PB->count>0) { + gl_flush_pb(ctx); + } + + if (ctx->Driver.End) { + (*ctx->Driver.End)(ctx); + } + + PB->primitive = ctx->Primitive = GL_BITMAP; /* Default mode */ + +#ifdef PROFILE + ctx->BeginEndTime += gl_time() - begin_time; + ctx->BeginEndCount++; +#endif +} + diff --git a/dll/opengl/mesa/vbfill.h b/dll/opengl/mesa/vbfill.h new file mode 100644 index 00000000000..ba3f906de2a --- /dev/null +++ b/dll/opengl/mesa/vbfill.h @@ -0,0 +1,149 @@ +/* $Id: vbfill.h,v 1.7 1997/06/20 02:30:56 brianp Exp $ */ + +/* + * Mesa 3-D graphics library + * Version: 2.3 + * Copyright (C) 1995-1996 Brian Paul + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Library General Public + * License as published by the Free Software Foundation; either + * version 2 of the License, or (at your option) any later version. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Library General Public License for more details. + * + * You should have received a copy of the GNU Library General Public + * License along with this library; if not, write to the Free + * Software Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. + */ + + +/* + * $Log: vbfill.h,v $ + * Revision 1.7 1997/06/20 02:30:56 brianp + * added Color4ubv API pointer + * + * Revision 1.6 1997/06/20 02:30:22 brianp + * changed color components from GLfixed to GLubyte + * + * Revision 1.5 1997/04/24 01:50:53 brianp + * optimized glColor3f, glColor3fv, glColor4fv + * + * Revision 1.4 1997/04/16 23:55:33 brianp + * added optimized glTexCoord2f code + * + * Revision 1.3 1997/04/14 22:18:23 brianp + * added optimized glVertex3fv code + * + * Revision 1.2 1997/04/07 03:00:19 brianp + * added vertex[23] functions + * + * Revision 1.1 1997/04/02 03:13:56 brianp + * Initial revision + * + */ + + +#ifndef VBFILL_H +#define VBFILL_H + + +#include "types.h" + + +extern void gl_Normal3f( GLcontext *ctx, GLfloat nx, GLfloat ny, GLfloat nz ); + +extern void gl_Normal3fv( GLcontext *ctx, const GLfloat *normal ); + + +extern void gl_Indexf( GLcontext *ctx, GLfloat c ); + +extern void gl_Indexi( GLcontext *ctx, GLint c ); + + +extern void gl_Color3f( GLcontext *ctx, + GLfloat red, GLfloat green, GLfloat blue ); + +extern void gl_Color3fv( GLcontext *ctx, const GLfloat *c ); + +extern void gl_Color4f( GLcontext *ctx, + GLfloat red, GLfloat green, + GLfloat blue, GLfloat alpha ); + +extern void gl_Color4fv( GLcontext *ctx, const GLfloat *c ); + +extern void gl_Color4ub( GLcontext *ctx, + GLubyte red, GLubyte green, + GLubyte blue, GLubyte alpha ); + +extern void gl_Color4ub8bit( GLcontext *ctx, + GLubyte red, GLubyte green, + GLubyte blue, GLubyte alpha ); + +extern void gl_Color4ubv( GLcontext *ctx, const GLubyte *c ); + +extern void gl_Color4ubv8bit( GLcontext *ctx, const GLubyte *c ); + + +extern void gl_ColorMat3f( GLcontext *ctx, + GLfloat red, GLfloat green, GLfloat blue ); + +extern void gl_ColorMat3fv( GLcontext *ctx, const GLfloat *c ); + +extern void gl_ColorMat3ub( GLcontext *ctx, + GLubyte red, GLubyte green, GLubyte blue ); + +extern void gl_ColorMat4f( GLcontext *ctx, + GLfloat red, GLfloat green, + GLfloat blue, GLfloat alpha ); + +extern void gl_ColorMat4fv( GLcontext *ctx, const GLfloat *c ); + +extern void gl_ColorMat4ub( GLcontext *ctx, + GLubyte red, GLubyte green, + GLubyte blue, GLubyte alpha ); + + +extern void gl_TexCoord2f( GLcontext *ctx, GLfloat s, GLfloat t ); + +extern void gl_TexCoord4f( GLcontext *ctx, + GLfloat s, GLfloat t, GLfloat r, GLfloat q ); + + +extern void gl_EdgeFlag( GLcontext *ctx, GLboolean flag ); + + + +extern void gl_vertex2f_nop( GLcontext *ctx, GLfloat x, GLfloat y ); + +extern void gl_vertex3f_nop( GLcontext *ctx, GLfloat x, GLfloat y, GLfloat z ); + +extern void gl_vertex4f_nop( GLcontext *ctx, + GLfloat x, GLfloat y, GLfloat z, GLfloat w ); + +extern void gl_vertex3fv_nop( GLcontext *ctx, const GLfloat *v ); + + + +extern void gl_set_vertex_function( GLcontext *ctx ); + +extern void gl_set_color_function( GLcontext *ctx ); + + + +extern void gl_eval_vertex( GLcontext *ctx, + const GLfloat vertex[4], const GLfloat normal[3], + const GLubyte color[4], GLuint index, + const GLfloat texcoord[4] ); + + +extern void gl_Begin( GLcontext *ctx, GLenum p ); + +extern void gl_End( GLcontext *ctx ); + + +#endif + diff --git a/dll/opengl/mesa/vbo/CMakeLists.txt b/dll/opengl/mesa/vbo/CMakeLists.txt deleted file mode 100644 index 1383c671808..00000000000 --- a/dll/opengl/mesa/vbo/CMakeLists.txt +++ /dev/null @@ -1,22 +0,0 @@ - -list(APPEND SOURCE - vbo_context.c - vbo_exec.c - vbo_exec_api.c - vbo_exec_array.c - vbo_exec_draw.c - vbo_exec_eval.c - vbo_noop.c - vbo_rebase.c - vbo_split.c - vbo_split_copy.c - vbo_split_inplace.c - vbo_save.c - vbo_save_api.c - vbo_save_draw.c - vbo_save_loopback.c - precomp.h) - -add_library(mesa_vbo STATIC ${SOURCE}) -add_dependencies(mesa_vbo xdk) -add_pch(mesa_vbo precomp.h SOURCE) diff --git a/dll/opengl/mesa/vbo/precomp.h b/dll/opengl/mesa/vbo/precomp.h deleted file mode 100644 index 6f2df251b59..00000000000 --- a/dll/opengl/mesa/vbo/precomp.h +++ /dev/null @@ -1,32 +0,0 @@ -#ifndef _MESA_VBO_PCH_ -#define _MESA_VBO_PCH_ - -#include
-#include
-#include
-#include
-#include
-#include
-#include
-#include
-#include
-#include
-#include
-#include
-#include
-#include
-#include
-#include
-#include
-#include
-#include
-#include - -#include "vbo.h" -#include "vbo_attrib.h" -#include "vbo_context.h" -#include "vbo_exec.h" -#include "vbo_noop.h" -#include "vbo_split.h" - -#endif /* _MESA_VBO_PCH_ */ diff --git a/dll/opengl/mesa/vbo/vbo.h b/dll/opengl/mesa/vbo/vbo.h deleted file mode 100644 index ed2c9f1c7db..00000000000 --- a/dll/opengl/mesa/vbo/vbo.h +++ /dev/null @@ -1,143 +0,0 @@ -/* - * mesa 3-D graphics library - * Version: 6.5 - * - * Copyright (C) 1999-2006 Brian Paul All Rights Reserved. - * - * Permission is hereby granted, free of charge, to any person obtaining a - * copy of this software and associated documentation files (the "Software"), - * to deal in the Software without restriction, including without limitation - * the rights to use, copy, modify, merge, publish, distribute, sublicense, - * and/or sell copies of the Software, and to permit persons to whom the - * Software is furnished to do so, subject to the following conditions: - * - * The above copyright notice and this permission notice shall be included - * in all copies or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS - * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL - * BRIAN PAUL BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN - * AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN - * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. - */ - -/** - * \file vbo_context.h - * \brief VBO builder module datatypes and definitions. - * \author Keith Whitwell - */ - - -#ifndef _VBO_H -#define _VBO_H - -#include "main/glheader.h" - -struct gl_client_array; -struct gl_context; -struct gl_transform_feedback_object; - -struct _mesa_prim { - GLuint mode:8; /**< GL_POINTS, GL_LINES, GL_QUAD_STRIP, etc */ - GLuint indexed:1; - GLuint begin:1; - GLuint end:1; - GLuint weak:1; - GLuint no_current_update:1; - GLuint pad:19; - - GLuint start; - GLuint count; - GLsizei num_instances; -}; - -/* Would like to call this a "vbo_index_buffer", but this would be - * confusing as the indices are not neccessarily yet in a non-null - * buffer object. - */ -struct _mesa_index_buffer { - GLuint count; - GLenum type; - struct gl_buffer_object *obj; - const void *ptr; -}; - - - -GLboolean _vbo_CreateContext( struct gl_context *ctx ); -void _vbo_DestroyContext( struct gl_context *ctx ); -void _vbo_InvalidateState( struct gl_context *ctx, GLuint new_state ); - - -typedef void (*vbo_draw_func)( struct gl_context *ctx, - const struct gl_client_array **arrays, - const struct _mesa_prim *prims, - GLuint nr_prims, - const struct _mesa_index_buffer *ib, - GLboolean index_bounds_valid, - GLuint min_index, - GLuint max_index); - - - - -/* Utility function to cope with various constraints on tnl modules or - * hardware. This can be used to split an incoming set of arrays and - * primitives against the following constraints: - * - Maximum number of indices in index buffer. - * - Maximum number of vertices referenced by index buffer. - * - Maximum hardware vertex buffer size. - */ -struct split_limits { - GLuint max_verts; - GLuint max_indices; - GLuint max_vb_size; /* bytes */ -}; - - -void vbo_split_prims( struct gl_context *ctx, - const struct gl_client_array *arrays[], - const struct _mesa_prim *prim, - GLuint nr_prims, - const struct _mesa_index_buffer *ib, - GLuint min_index, - GLuint max_index, - vbo_draw_func draw, - const struct split_limits *limits ); - - -/* Helpers for dealing translating away non-zero min_index. - */ - -void vbo_rebase_prims( struct gl_context *ctx, - const struct gl_client_array *arrays[], - const struct _mesa_prim *prim, - GLuint nr_prims, - const struct _mesa_index_buffer *ib, - GLuint min_index, - GLuint max_index, - vbo_draw_func draw ); - -int -vbo_sizeof_ib_type(GLenum type); - -void -vbo_get_minmax_index(struct gl_context *ctx, const struct _mesa_prim *prim, - const struct _mesa_index_buffer *ib, - GLuint *min_index, GLuint *max_index); - -void vbo_use_buffer_objects(struct gl_context *ctx); - -void vbo_always_unmap_buffers(struct gl_context *ctx); - -void vbo_set_draw_func(struct gl_context *ctx, vbo_draw_func func); - -void vbo_check_buffers_are_unmapped(struct gl_context *ctx); - -void vbo_bind_arrays(struct gl_context *ctx); - -size_t -count_tessellated_primitives(const struct _mesa_prim *prim); - -#endif diff --git a/dll/opengl/mesa/vbo/vbo_attrib.h b/dll/opengl/mesa/vbo/vbo_attrib.h deleted file mode 100644 index 550bd2719fa..00000000000 --- a/dll/opengl/mesa/vbo/vbo_attrib.h +++ /dev/null @@ -1,78 +0,0 @@ -/* - Copyright (C) Intel Corp. 2006. All Rights Reserved. - Intel funded Tungsten Graphics (http://www.tungstengraphics.com) to - develop this 3D driver. - - Permission is hereby granted, free of charge, to any person obtaining - a copy of this software and associated documentation files (the - "Software"), to deal in the Software without restriction, including - without limitation the rights to use, copy, modify, merge, publish, - distribute, sublicense, and/or sell copies of the Software, and to - permit persons to whom the Software is furnished to do so, subject to - the following conditions: - - The above copyright notice and this permission notice (including the - next paragraph) shall be included in all copies or substantial - portions of the Software. - - THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, - EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF - MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. - IN NO EVENT SHALL THE COPYRIGHT OWNER(S) AND/OR ITS SUPPLIERS BE - LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION - OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION - WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. - - **********************************************************************/ - /* - * Authors: - * Keith Whitwell - */ - -#ifndef VBO_ATTRIB_H -#define VBO_ATTRIB_H - - -/* - * Note: The first attributes match the VERT_ATTRIB_* definitions - * in mtypes.h. However, the tnl module has additional attributes - * for materials, color indexes, edge flags, etc. - */ -/* Although it's nice to use these as bit indexes in a DWORD flag, we - * could manage without if necessary. Another limit currently is the - * number of bits allocated for these numbers in places like vertex - * program instruction formats and register layouts. - */ -enum { - VBO_ATTRIB_POS = 0, - VBO_ATTRIB_WEIGHT = 1, - VBO_ATTRIB_NORMAL = 2, - VBO_ATTRIB_COLOR = 3, - VBO_ATTRIB_FOG = 4, - VBO_ATTRIB_INDEX = 5, - VBO_ATTRIB_EDGEFLAG = 6, - VBO_ATTRIB_TEX = 7, - VBO_ATTRIB_POINT_SIZE = 8, - - VBO_ATTRIB_MAT_FRONT_AMBIENT = 9, - VBO_ATTRIB_MAT_BACK_AMBIENT = 10, - VBO_ATTRIB_MAT_FRONT_DIFFUSE = 11, - VBO_ATTRIB_MAT_BACK_DIFFUSE = 12, - VBO_ATTRIB_MAT_FRONT_SPECULAR = 13, - VBO_ATTRIB_MAT_BACK_SPECULAR = 14, - VBO_ATTRIB_MAT_FRONT_EMISSION = 15, - VBO_ATTRIB_MAT_BACK_EMISSION = 16, - VBO_ATTRIB_MAT_FRONT_SHININESS = 17, - VBO_ATTRIB_MAT_BACK_SHININESS = 18, - VBO_ATTRIB_MAT_FRONT_INDEXES = 19, - VBO_ATTRIB_MAT_BACK_INDEXES = 20, - - VBO_ATTRIB_MAX = 21 -}; - -#define VBO_ATTRIB_FIRST_MATERIAL VBO_ATTRIB_MAT_FRONT_AMBIENT -#define VBO_ATTRIB_LAST_MATERIAL VBO_ATTRIB_MAT_BACK_INDEXES - -#define VBO_MAX_COPIED_VERTS 3 - -#endif diff --git a/dll/opengl/mesa/vbo/vbo_attrib_tmp.h b/dll/opengl/mesa/vbo/vbo_attrib_tmp.h deleted file mode 100644 index 20800a41568..00000000000 --- a/dll/opengl/mesa/vbo/vbo_attrib_tmp.h +++ /dev/null @@ -1,332 +0,0 @@ -/************************************************************************** - -Copyright 2002 Tungsten Graphics Inc., Cedar Park, Texas. -Copyright 2011 Dave Airlie (ARB_vertex_type_2_10_10_10_rev support) -All Rights Reserved. - -Permission is hereby granted, free of charge, to any person obtaining a -copy of this software and associated documentation files (the "Software"), -to deal in the Software without restriction, including without limitation -on the rights to use, copy, modify, merge, publish, distribute, sub -license, and/or sell copies of the Software, and to permit persons to whom -the Software is furnished to do so, subject to the following conditions: - -The above copyright notice and this permission notice (including the next -paragraph) shall be included in all copies or substantial portions of the -Software. - -THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR -IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, -FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT. IN NO EVENT SHALL -TUNGSTEN GRAPHICS AND/OR THEIR SUPPLIERS BE LIABLE FOR ANY CLAIM, -DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR -OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE -USE OR OTHER DEALINGS IN THE SOFTWARE. - -**************************************************************************/ - -/* float */ -#define ATTR1FV( A, V ) ATTR( A, 1, (V)[0], 0, 0, 1 ) -#define ATTR2FV( A, V ) ATTR( A, 2, (V)[0], (V)[1], 0, 1 ) -#define ATTR3FV( A, V ) ATTR( A, 3, (V)[0], (V)[1], (V)[2], 1 ) -#define ATTR4FV( A, V ) ATTR( A, 4, (V)[0], (V)[1], (V)[2], (V)[3] ) - -#define ATTR1F( A, X ) ATTR( A, 1, X, 0, 0, 1 ) -#define ATTR2F( A, X, Y ) ATTR( A, 2, X, Y, 0, 1 ) -#define ATTR3F( A, X, Y, Z ) ATTR( A, 3, X, Y, Z, 1 ) -#define ATTR4F( A, X, Y, Z, W ) ATTR( A, 4, X, Y, Z, W ) - -/* int */ -#define ATTR2IV( A, V ) ATTR( A, 2, (V)[0], (V)[1], 0, 1 ) -#define ATTR3IV( A, V ) ATTR( A, 3, (V)[0], (V)[1], (V)[2], 1 ) -#define ATTR4IV( A, V ) ATTR( A, 4, (V)[0], (V)[1], (V)[2], (V)[3] ) - -#define ATTR1I( A, X ) ATTR( A, 1, X, 0, 0, 1 ) -#define ATTR2I( A, X, Y ) ATTR( A, 2, X, Y, 0, 1 ) -#define ATTR3I( A, X, Y, Z ) ATTR( A, 3, X, Y, Z, 1 ) -#define ATTR4I( A, X, Y, Z, W ) ATTR( A, 4, X, Y, Z, W ) - - -/* uint */ -#define ATTR2UIV( A, V ) ATTR( A, 2, (V)[0], (V)[1], 0, 1 ) -#define ATTR3UIV( A, V ) ATTR( A, 3, (V)[0], (V)[1], (V)[2], 1 ) -#define ATTR4UIV( A, V ) ATTR( A, 4, (V)[0], (V)[1], (V)[2], (V)[3] ) - -#define ATTR1UI( A, X ) ATTR( A, 1, X, 0, 0, 1 ) -#define ATTR2UI( A, X, Y ) ATTR( A, 2, X, Y, 0, 1 ) -#define ATTR3UI( A, X, Y, Z ) ATTR( A, 3, X, Y, Z, 1 ) -#define ATTR4UI( A, X, Y, Z, W ) ATTR( A, 4, X, Y, Z, W ) - -#define MAT_ATTR( A, N, V ) ATTR( A, N, (V)[0], (V)[1], (V)[2], (V)[3] ) - -static void GLAPIENTRY -TAG(Vertex2f)(GLfloat x, GLfloat y) -{ - GET_CURRENT_CONTEXT(ctx); - ATTR2F(VBO_ATTRIB_POS, x, y); -} - -static void GLAPIENTRY -TAG(Vertex2fv)(const GLfloat * v) -{ - GET_CURRENT_CONTEXT(ctx); - ATTR2FV(VBO_ATTRIB_POS, v); -} - -static void GLAPIENTRY -TAG(Vertex3f)(GLfloat x, GLfloat y, GLfloat z) -{ - GET_CURRENT_CONTEXT(ctx); - ATTR3F(VBO_ATTRIB_POS, x, y, z); -} - -static void GLAPIENTRY -TAG(Vertex3fv)(const GLfloat * v) -{ - GET_CURRENT_CONTEXT(ctx); - ATTR3FV(VBO_ATTRIB_POS, v); -} - -static void GLAPIENTRY -TAG(Vertex4f)(GLfloat x, GLfloat y, GLfloat z, GLfloat w) -{ - GET_CURRENT_CONTEXT(ctx); - ATTR4F(VBO_ATTRIB_POS, x, y, z, w); -} - -static void GLAPIENTRY -TAG(Vertex4fv)(const GLfloat * v) -{ - GET_CURRENT_CONTEXT(ctx); - ATTR4FV(VBO_ATTRIB_POS, v); -} - - - -static void GLAPIENTRY -TAG(TexCoord1f)(GLfloat x) -{ - GET_CURRENT_CONTEXT(ctx); - ATTR1F(VBO_ATTRIB_TEX, x); -} - -static void GLAPIENTRY -TAG(TexCoord1fv)(const GLfloat * v) -{ - GET_CURRENT_CONTEXT(ctx); - ATTR1FV(VBO_ATTRIB_TEX, v); -} - -static void GLAPIENTRY -TAG(TexCoord2f)(GLfloat x, GLfloat y) -{ - GET_CURRENT_CONTEXT(ctx); - ATTR2F(VBO_ATTRIB_TEX, x, y); -} - -static void GLAPIENTRY -TAG(TexCoord2fv)(const GLfloat * v) -{ - GET_CURRENT_CONTEXT(ctx); - ATTR2FV(VBO_ATTRIB_TEX, v); -} - -static void GLAPIENTRY -TAG(TexCoord3f)(GLfloat x, GLfloat y, GLfloat z) -{ - GET_CURRENT_CONTEXT(ctx); - ATTR3F(VBO_ATTRIB_TEX, x, y, z); -} - -static void GLAPIENTRY -TAG(TexCoord3fv)(const GLfloat * v) -{ - GET_CURRENT_CONTEXT(ctx); - ATTR3FV(VBO_ATTRIB_TEX, v); -} - -static void GLAPIENTRY -TAG(TexCoord4f)(GLfloat x, GLfloat y, GLfloat z, GLfloat w) -{ - GET_CURRENT_CONTEXT(ctx); - ATTR4F(VBO_ATTRIB_TEX, x, y, z, w); -} - -static void GLAPIENTRY -TAG(TexCoord4fv)(const GLfloat * v) -{ - GET_CURRENT_CONTEXT(ctx); - ATTR4FV(VBO_ATTRIB_TEX, v); -} - - - -static void GLAPIENTRY -TAG(Normal3f)(GLfloat x, GLfloat y, GLfloat z) -{ - GET_CURRENT_CONTEXT(ctx); - ATTR3F(VBO_ATTRIB_NORMAL, x, y, z); -} - -static void GLAPIENTRY -TAG(Normal3fv)(const GLfloat * v) -{ - GET_CURRENT_CONTEXT(ctx); - ATTR3FV(VBO_ATTRIB_NORMAL, v); -} - - - -static void GLAPIENTRY -TAG(FogCoordfEXT)(GLfloat x) -{ - GET_CURRENT_CONTEXT(ctx); - ATTR1F(VBO_ATTRIB_FOG, x); -} - - - -static void GLAPIENTRY -TAG(FogCoordfvEXT)(const GLfloat * v) -{ - GET_CURRENT_CONTEXT(ctx); - ATTR1FV(VBO_ATTRIB_FOG, v); -} - -static void GLAPIENTRY -TAG(Color3f)(GLfloat x, GLfloat y, GLfloat z) -{ - GET_CURRENT_CONTEXT(ctx); - ATTR3F(VBO_ATTRIB_COLOR, x, y, z); -} - -static void GLAPIENTRY -TAG(Color3fv)(const GLfloat * v) -{ - GET_CURRENT_CONTEXT(ctx); - ATTR3FV(VBO_ATTRIB_COLOR, v); -} - -static void GLAPIENTRY -TAG(Color4f)(GLfloat x, GLfloat y, GLfloat z, GLfloat w) -{ - GET_CURRENT_CONTEXT(ctx); - ATTR4F(VBO_ATTRIB_COLOR, x, y, z, w); -} - -static void GLAPIENTRY -TAG(Color4fv)(const GLfloat * v) -{ - GET_CURRENT_CONTEXT(ctx); - ATTR4FV(VBO_ATTRIB_COLOR, v); -} - - - -static void GLAPIENTRY -TAG(EdgeFlag)(GLboolean b) -{ - GET_CURRENT_CONTEXT(ctx); - ATTR1F(VBO_ATTRIB_EDGEFLAG, (GLfloat) b); -} - - - -static void GLAPIENTRY -TAG(Indexf)(GLfloat f) -{ - GET_CURRENT_CONTEXT(ctx); - ATTR1F(VBO_ATTRIB_INDEX, f); -} - -static void GLAPIENTRY -TAG(Indexfv)(const GLfloat * f) -{ - GET_CURRENT_CONTEXT(ctx); - ATTR1FV(VBO_ATTRIB_INDEX, f); -} - - - -/* In addition to supporting NV_vertex_program, these entrypoints are - * used by the display list and other code specifically because of - * their property of aliasing with other attributes. (See - * vbo_save_loopback.c) - */ -static void GLAPIENTRY -TAG(VertexAttrib1fNV)(GLuint index, GLfloat x) -{ - GET_CURRENT_CONTEXT(ctx); - if (index < VBO_ATTRIB_MAX) - ATTR1F(index, x); -} - -static void GLAPIENTRY -TAG(VertexAttrib1fvNV)(GLuint index, const GLfloat * v) -{ - GET_CURRENT_CONTEXT(ctx); - if (index < VBO_ATTRIB_MAX) - ATTR1FV(index, v); -} - -static void GLAPIENTRY -TAG(VertexAttrib2fNV)(GLuint index, GLfloat x, GLfloat y) -{ - GET_CURRENT_CONTEXT(ctx); - if (index < VBO_ATTRIB_MAX) - ATTR2F(index, x, y); -} - -static void GLAPIENTRY -TAG(VertexAttrib2fvNV)(GLuint index, const GLfloat * v) -{ - GET_CURRENT_CONTEXT(ctx); - if (index < VBO_ATTRIB_MAX) - ATTR2FV(index, v); -} - -static void GLAPIENTRY -TAG(VertexAttrib3fNV)(GLuint index, GLfloat x, GLfloat y, GLfloat z) -{ - GET_CURRENT_CONTEXT(ctx); - if (index < VBO_ATTRIB_MAX) - ATTR3F(index, x, y, z); -} - -static void GLAPIENTRY -TAG(VertexAttrib3fvNV)(GLuint index, - const GLfloat * v) -{ - GET_CURRENT_CONTEXT(ctx); - if (index < VBO_ATTRIB_MAX) - ATTR3FV(index, v); -} - -static void GLAPIENTRY -TAG(VertexAttrib4fNV)(GLuint index, GLfloat x, GLfloat y, GLfloat z, GLfloat w) -{ - GET_CURRENT_CONTEXT(ctx); - if (index < VBO_ATTRIB_MAX) - ATTR4F(index, x, y, z, w); -} - -static void GLAPIENTRY -TAG(VertexAttrib4fvNV)(GLuint index, const GLfloat * v) -{ - GET_CURRENT_CONTEXT(ctx); - if (index < VBO_ATTRIB_MAX) - ATTR4FV(index, v); -} - - -#undef ATTR1FV -#undef ATTR2FV -#undef ATTR3FV -#undef ATTR4FV - -#undef ATTR1F -#undef ATTR2F -#undef ATTR3F -#undef ATTR4F - -#undef MAT diff --git a/dll/opengl/mesa/vbo/vbo_context.c b/dll/opengl/mesa/vbo/vbo_context.c deleted file mode 100644 index 68982969ba8..00000000000 --- a/dll/opengl/mesa/vbo/vbo_context.c +++ /dev/null @@ -1,185 +0,0 @@ -/* - * Mesa 3-D graphics library - * Version: 6.3 - * - * Copyright (C) 1999-2005 Brian Paul All Rights Reserved. - * - * Permission is hereby granted, free of charge, to any person obtaining a - * copy of this software and associated documentation files (the "Software"), - * to deal in the Software without restriction, including without limitation - * the rights to use, copy, modify, merge, publish, distribute, sublicense, - * and/or sell copies of the Software, and to permit persons to whom the - * Software is furnished to do so, subject to the following conditions: - * - * The above copyright notice and this permission notice shall be included - * in all copies or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS - * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL - * BRIAN PAUL BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN - * AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN - * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. - * - * Authors: - * Keith Whitwell - */ - -#include - -#define NR_MAT_ATTRIBS 12 - -static GLuint check_size( const GLfloat *attr ) -{ - if (attr[3] != 1.0) return 4; - if (attr[2] != 0.0) return 3; - if (attr[1] != 0.0) return 2; - return 1; -} - - -static void init_legacy_currval(struct gl_context *ctx) -{ - struct vbo_context *vbo = vbo_context(ctx); - struct gl_client_array *arrays = vbo->legacy_currval; - GLuint i; - - memset(arrays, 0, sizeof(*arrays) * VERT_ATTRIB_MAX); - - /* Set up a constant (StrideB == 0) array for each current - * attribute: - */ - for (i = 0; i < VERT_ATTRIB_MAX; i++) { - struct gl_client_array *cl = &arrays[i]; - - /* Size will have to be determined at runtime: - */ - cl->Size = check_size(ctx->Current.Attrib[i]); - cl->Stride = 0; - cl->StrideB = 0; - cl->Enabled = 1; - cl->Type = GL_FLOAT; - cl->Ptr = (const void *)ctx->Current.Attrib[i]; - cl->_ElementSize = cl->Size * sizeof(GLfloat); - _mesa_reference_buffer_object(ctx, &cl->BufferObj, - ctx->Shared->NullBufferObj); - } -} - - -static void init_mat_currval(struct gl_context *ctx) -{ - struct vbo_context *vbo = vbo_context(ctx); - struct gl_client_array *arrays = vbo->mat_currval; - GLuint i; - - ASSERT(NR_MAT_ATTRIBS == MAT_ATTRIB_MAX); - - memset(arrays, 0, sizeof(*arrays) * NR_MAT_ATTRIBS); - - /* Set up a constant (StrideB == 0) array for each current - * attribute: - */ - for (i = 0; i < NR_MAT_ATTRIBS; i++) { - struct gl_client_array *cl = &arrays[i]; - - /* Size is fixed for the material attributes, for others will - * be determined at runtime: - */ - switch (i) { - case MAT_ATTRIB_FRONT_SHININESS: - case MAT_ATTRIB_BACK_SHININESS: - cl->Size = 1; - break; - case MAT_ATTRIB_FRONT_INDEXES: - case MAT_ATTRIB_BACK_INDEXES: - cl->Size = 3; - break; - default: - cl->Size = 4; - break; - } - - cl->Ptr = (const void*)ctx->Light.Material.Attrib[i]; - cl->Type = GL_FLOAT; - cl->Stride = 0; - cl->StrideB = 0; - cl->Enabled = 1; - cl->_ElementSize = cl->Size * sizeof(GLfloat); - _mesa_reference_buffer_object(ctx, &cl->BufferObj, - ctx->Shared->NullBufferObj); - } -} - - -GLboolean _vbo_CreateContext( struct gl_context *ctx ) -{ - struct vbo_context *vbo = CALLOC_STRUCT(vbo_context); - - ctx->swtnl_im = (void *)vbo; - - /* Initialize the arrayelt helper - */ - if (!ctx->aelt_context && - !_ae_create_context( ctx )) { - return GL_FALSE; - } - - /* TODO: remove these pointers. - */ - vbo->legacy_currval = &vbo->currval[VBO_ATTRIB_POS]; - vbo->mat_currval = &vbo->currval[VBO_ATTRIB_MAT_FRONT_AMBIENT]; - - init_legacy_currval( ctx ); - init_mat_currval( ctx ); - - - /* Hook our functions into exec and compile dispatch tables. These - * will pretty much be permanently installed, which means that the - * vtxfmt mechanism can be removed now. - */ - vbo_exec_init( ctx ); - vbo_save_init( ctx ); - - _math_init_eval(); - - return GL_TRUE; -} - - -void _vbo_InvalidateState( struct gl_context *ctx, GLuint new_state ) -{ - vbo_exec_invalidate_state(ctx, new_state); -} - - -void _vbo_DestroyContext( struct gl_context *ctx ) -{ - struct vbo_context *vbo = vbo_context(ctx); - - if (ctx->aelt_context) { - _ae_destroy_context( ctx ); - ctx->aelt_context = NULL; - } - - if (vbo) { - GLuint i; - - for (i = 0; i < VBO_ATTRIB_MAX; i++) { - _mesa_reference_buffer_object(ctx, &vbo->currval[i].BufferObj, NULL); - } - - vbo_exec_destroy(ctx); - vbo_save_destroy(ctx); - FREE(vbo); - ctx->swtnl_im = NULL; - } -} - - -void vbo_set_draw_func(struct gl_context *ctx, vbo_draw_func func) -{ - struct vbo_context *vbo = vbo_context(ctx); - vbo->draw_prims = func; -} - diff --git a/dll/opengl/mesa/vbo/vbo_context.h b/dll/opengl/mesa/vbo/vbo_context.h deleted file mode 100644 index 221828d4906..00000000000 --- a/dll/opengl/mesa/vbo/vbo_context.h +++ /dev/null @@ -1,91 +0,0 @@ -/* - * mesa 3-D graphics library - * Version: 6.5 - * - * Copyright (C) 1999-2006 Brian Paul All Rights Reserved. - * - * Permission is hereby granted, free of charge, to any person obtaining a - * copy of this software and associated documentation files (the "Software"), - * to deal in the Software without restriction, including without limitation - * the rights to use, copy, modify, merge, publish, distribute, sublicense, - * and/or sell copies of the Software, and to permit persons to whom the - * Software is furnished to do so, subject to the following conditions: - * - * The above copyright notice and this permission notice shall be included - * in all copies or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS - * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL - * BRIAN PAUL BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN - * AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN - * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. - */ - -/** - * \file vbo_context.h - * \brief VBO builder module datatypes and definitions. - * \author Keith Whitwell - */ - - -/** - * \mainpage The VBO builder module - * - * This module hooks into the GL dispatch table and catches all vertex - * building and drawing commands, such as glVertex3f, glBegin and - * glDrawArrays. The module stores all incoming vertex data as arrays - * in GL vertex buffer objects (VBOs), and translates all drawing - * commands into calls to a driver supplied DrawPrimitives() callback. - * - * The module captures both immediate mode and display list drawing, - * and manages the allocation, reference counting and deallocation of - * vertex buffer objects itself. - * - * The DrawPrimitives() callback can be either implemented by the - * driver itself or hooked to the tnl module's _tnl_draw_primitives() - * function for hardware without tnl capablilties or during fallbacks. - */ - - -#ifndef _VBO_CONTEXT_H -#define _VBO_CONTEXT_H - -#include "main/mfeatures.h" -#include "vbo.h" -#include "vbo_attrib.h" -#include "vbo_exec.h" -#include "vbo_save.h" - - -struct vbo_context { - struct gl_client_array currval[VBO_ATTRIB_MAX]; - - /* These point into the above. TODO: remove. - */ - struct gl_client_array *legacy_currval; - struct gl_client_array *mat_currval; - - GLfloat *current[VBO_ATTRIB_MAX]; /* points into ctx->Current, ctx->Light.Material */ - GLfloat CurrentFloatEdgeFlag; - - - struct vbo_exec_context exec; -#if FEATURE_dlist - struct vbo_save_context save; -#endif - - /* Callback into the driver. This must always succeed, the driver - * is responsible for initiating any fallback actions required: - */ - vbo_draw_func draw_prims; -}; - - -static inline struct vbo_context *vbo_context(struct gl_context *ctx) -{ - return (struct vbo_context *)(ctx->swtnl_im); -} - - -#endif diff --git a/dll/opengl/mesa/vbo/vbo_exec.c b/dll/opengl/mesa/vbo/vbo_exec.c deleted file mode 100644 index 655a8ed2c3f..00000000000 --- a/dll/opengl/mesa/vbo/vbo_exec.c +++ /dev/null @@ -1,133 +0,0 @@ -/* - * Mesa 3-D graphics library - * Version: 6.3 - * - * Copyright (C) 1999-2005 Brian Paul All Rights Reserved. - * - * Permission is hereby granted, free of charge, to any person obtaining a - * copy of this software and associated documentation files (the "Software"), - * to deal in the Software without restriction, including without limitation - * the rights to use, copy, modify, merge, publish, distribute, sublicense, - * and/or sell copies of the Software, and to permit persons to whom the - * Software is furnished to do so, subject to the following conditions: - * - * The above copyright notice and this permission notice shall be included - * in all copies or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS - * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL - * BRIAN PAUL BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN - * AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN - * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. - * - * Authors: - * Keith Whitwell - */ - -#include - -void vbo_exec_init( struct gl_context *ctx ) -{ - struct vbo_exec_context *exec = &vbo_context(ctx)->exec; - - exec->ctx = ctx; - - /* Initialize the arrayelt helper - */ - if (!ctx->aelt_context && - !_ae_create_context( ctx )) - return; - - vbo_exec_vtx_init( exec ); - vbo_exec_array_init( exec ); - - /* Hook our functions into exec and compile dispatch tables. - */ - _mesa_install_exec_vtxfmt( ctx, &exec->vtxfmt ); - - ctx->Driver.NeedFlush = 0; - ctx->Driver.CurrentExecPrimitive = PRIM_OUTSIDE_BEGIN_END; - ctx->Driver.BeginVertices = vbo_exec_BeginVertices; - ctx->Driver.FlushVertices = vbo_exec_FlushVertices; - - vbo_exec_invalidate_state( ctx, ~0 ); -} - - -void vbo_exec_destroy( struct gl_context *ctx ) -{ - struct vbo_exec_context *exec = &vbo_context(ctx)->exec; - - if (ctx->aelt_context) { - _ae_destroy_context( ctx ); - ctx->aelt_context = NULL; - } - - vbo_exec_vtx_destroy( exec ); - vbo_exec_array_destroy( exec ); -} - - -/** - * Really want to install these callbacks to a central facility to be - * invoked according to the state flags. That will have to wait for a - * mesa rework: - */ -void vbo_exec_invalidate_state( struct gl_context *ctx, GLuint new_state ) -{ - struct vbo_exec_context *exec = &vbo_context(ctx)->exec; - - if (new_state & _NEW_EVAL) - exec->eval.recalculate_maps = 1; - - _ae_invalidate_state(ctx, new_state); -} - - -/** - * Figure out the number of transform feedback primitives that will be output - * by the given _mesa_prim command, assuming that no geometry shading is done - * and primitive restart is not used. - * - * This is intended for use by driver back-ends in implementing the - * PRIMITIVES_GENERATED and TRANSFORM_FEEDBACK_PRIMITIVES_WRITTEN queries. - */ -size_t -count_tessellated_primitives(const struct _mesa_prim *prim) -{ - size_t num_primitives; - switch (prim->mode) { - case GL_POINTS: - num_primitives = prim->count; - break; - case GL_LINE_STRIP: - num_primitives = prim->count >= 2 ? prim->count - 1 : 0; - break; - case GL_LINE_LOOP: - num_primitives = prim->count >= 2 ? prim->count : 0; - break; - case GL_LINES: - num_primitives = prim->count / 2; - break; - case GL_TRIANGLE_STRIP: - case GL_TRIANGLE_FAN: - case GL_POLYGON: - num_primitives = prim->count >= 3 ? prim->count - 2 : 0; - break; - case GL_TRIANGLES: - num_primitives = prim->count / 3; - break; - case GL_QUAD_STRIP: - num_primitives = prim->count >= 4 ? ((prim->count / 2) - 1) * 2 : 0; - break; - case GL_QUADS: - num_primitives = (prim->count / 4) * 2; - break; - default: - assert(!"Unexpected primitive type in count_tessellated_primitives"); - num_primitives = 0; - break; - } - return num_primitives * prim->num_instances; -} diff --git a/dll/opengl/mesa/vbo/vbo_exec.h b/dll/opengl/mesa/vbo/vbo_exec.h deleted file mode 100644 index a016666e8d6..00000000000 --- a/dll/opengl/mesa/vbo/vbo_exec.h +++ /dev/null @@ -1,226 +0,0 @@ -/************************************************************************** - -Copyright 2002 Tungsten Graphics Inc., Cedar Park, Texas. - -All Rights Reserved. - -Permission is hereby granted, free of charge, to any person obtaining a -copy of this software and associated documentation files (the "Software"), -to deal in the Software without restriction, including without limitation -on the rights to use, copy, modify, merge, publish, distribute, sub -license, and/or sell copies of the Software, and to permit persons to whom -the Software is furnished to do so, subject to the following conditions: - -The above copyright notice and this permission notice (including the next -paragraph) shall be included in all copies or substantial portions of the -Software. - -THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR -IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, -FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT. IN NO EVENT SHALL -TUNGSTEN GRAPHICS AND/OR THEIR SUPPLIERS BE LIABLE FOR ANY CLAIM, -DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR -OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE -USE OR OTHER DEALINGS IN THE SOFTWARE. - -**************************************************************************/ - -/* - * Authors: - * Keith Whitwell - * - */ - -#ifndef __VBO_EXEC_H__ -#define __VBO_EXEC_H__ - -#include "main/mfeatures.h" -#include "main/mtypes.h" -#include "vbo.h" -#include "vbo_attrib.h" - - -/** - * Max number of primitives (number of glBegin/End pairs) per VBO. - */ -#define VBO_MAX_PRIM 64 - - -/** - * Size of the VBO to use for glBegin/glVertex/glEnd-style rendering. - */ -#define VBO_VERT_BUFFER_SIZE (1024*64) /* bytes */ - - -/** Current vertex program mode */ -enum vp_mode { - VP_NONE, /**< fixed function */ - VP_NV, /**< NV vertex program */ - VP_ARB /**< ARB vertex program or GLSL vertex shader */ -}; - - -struct vbo_exec_eval1_map { - struct gl_1d_map *map; - GLuint sz; -}; - -struct vbo_exec_eval2_map { - struct gl_2d_map *map; - GLuint sz; -}; - - - -struct vbo_exec_copied_vtx { - GLfloat buffer[VBO_ATTRIB_MAX * 4 * VBO_MAX_COPIED_VERTS]; - GLuint nr; -}; - - -/** Used to signal when transitioning from one kind of drawing method - * to another. - */ -enum draw_method -{ - DRAW_NONE, /**< Initial value only */ - DRAW_BEGIN_END, - DRAW_DISPLAY_LIST, - DRAW_ARRAYS -}; - - -struct vbo_exec_context -{ - struct gl_context *ctx; - GLvertexformat vtxfmt; - GLvertexformat vtxfmt_noop; - - enum draw_method last_draw_method; - - struct { - struct gl_buffer_object *bufferobj; - - GLuint vertex_size; /* in dwords */ - - struct _mesa_prim prim[VBO_MAX_PRIM]; - GLuint prim_count; - - GLfloat *buffer_map; - GLfloat *buffer_ptr; /* cursor, points into buffer */ - GLuint buffer_used; /* in bytes */ - GLfloat vertex[VBO_ATTRIB_MAX*4]; /* current vertex */ - - GLuint vert_count; - GLuint max_vert; - struct vbo_exec_copied_vtx copied; - - GLubyte attrsz[VBO_ATTRIB_MAX]; - GLubyte active_sz[VBO_ATTRIB_MAX]; - - GLfloat *attrptr[VBO_ATTRIB_MAX]; - struct gl_client_array arrays[VBO_ATTRIB_MAX]; - - /* According to program mode, the values above plus current - * values are squashed down to the 32 attributes passed to the - * vertex program below: - */ - const struct gl_client_array *inputs[VBO_ATTRIB_MAX]; - } vtx; - - - struct { - GLboolean recalculate_maps; - struct vbo_exec_eval1_map map1[VERT_ATTRIB_MAX]; - struct vbo_exec_eval2_map map2[VERT_ATTRIB_MAX]; - } eval; - - struct { - /* Arrays and current values manipulated according to program - * mode, etc. These are the attributes as seen by vertex - * programs: - */ - const struct gl_client_array *inputs[VBO_ATTRIB_MAX]; - } array; - - /* Which flags to set in vbo_exec_BeginVertices() */ - GLbitfield begin_vertices_flags; - -#ifdef DEBUG - GLint flush_call_depth; -#endif -}; - - - -/* External API: - */ -void vbo_exec_init( struct gl_context *ctx ); -void vbo_exec_destroy( struct gl_context *ctx ); -void vbo_exec_invalidate_state( struct gl_context *ctx, GLuint new_state ); - -void vbo_exec_BeginVertices( struct gl_context *ctx ); -void vbo_exec_FlushVertices( struct gl_context *ctx, GLuint flags ); - - -/* Internal functions: - */ -void vbo_exec_array_init( struct vbo_exec_context *exec ); -void vbo_exec_array_destroy( struct vbo_exec_context *exec ); - - -void vbo_exec_vtx_init( struct vbo_exec_context *exec ); -void vbo_exec_vtx_destroy( struct vbo_exec_context *exec ); - - -/** - * This is called by glBegin, glDrawArrays and glDrawElements (and - * variations of those calls). When we transition from immediate mode - * drawing to array drawing we need to invalidate the array state. - * - * glBegin/End builds vertex arrays. Those arrays may look identical - * to glDrawArrays arrays except that the position of the elements may - * be different. For example, arrays of (position3v, normal3f) vs. arrays - * of (normal3f, position3f). So we need to make sure we notify drivers - * that arrays may be changing. - */ -static inline void -vbo_draw_method(struct vbo_exec_context *exec, enum draw_method method) -{ - if (exec->last_draw_method != method) { - exec->ctx->NewState |= _NEW_ARRAY; - exec->last_draw_method = method; - } -} - - -#if FEATURE_beginend - -void vbo_exec_vtx_flush( struct vbo_exec_context *exec, GLboolean unmap ); -void vbo_exec_vtx_map( struct vbo_exec_context *exec ); - -#else /* FEATURE_beginend */ - -static inline void -vbo_exec_vtx_flush( struct vbo_exec_context *exec, GLboolean unmap ) -{ -} - -static inline void -vbo_exec_vtx_map( struct vbo_exec_context *exec ) -{ -} - -#endif /* FEATURE_beginend */ - -void vbo_exec_vtx_wrap( struct vbo_exec_context *exec ); - -void vbo_exec_eval_update( struct vbo_exec_context *exec ); - -void vbo_exec_do_EvalCoord2f( struct vbo_exec_context *exec, - GLfloat u, GLfloat v ); - -void vbo_exec_do_EvalCoord1f( struct vbo_exec_context *exec, - GLfloat u); - -#endif diff --git a/dll/opengl/mesa/vbo/vbo_exec_api.c b/dll/opengl/mesa/vbo/vbo_exec_api.c deleted file mode 100644 index 5ecb00fb20d..00000000000 --- a/dll/opengl/mesa/vbo/vbo_exec_api.c +++ /dev/null @@ -1,1167 +0,0 @@ -/************************************************************************** - -Copyright 2002-2008 Tungsten Graphics Inc., Cedar Park, Texas. - -All Rights Reserved. - -Permission is hereby granted, free of charge, to any person obtaining a -copy of this software and associated documentation files (the "Software"), -to deal in the Software without restriction, including without limitation -on the rights to use, copy, modify, merge, publish, distribute, sub -license, and/or sell copies of the Software, and to permit persons to whom -the Software is furnished to do so, subject to the following conditions: - -The above copyright notice and this permission notice (including the next -paragraph) shall be included in all copies or substantial portions of the -Software. - -THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR -IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, -FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT. IN NO EVENT SHALL -TUNGSTEN GRAPHICS AND/OR THEIR SUPPLIERS BE LIABLE FOR ANY CLAIM, -DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR -OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE -USE OR OTHER DEALINGS IN THE SOFTWARE. - -**************************************************************************/ - -/* - * Authors: - * Keith Whitwell - */ - -#include - -#ifdef ERROR -#undef ERROR -#endif - - -/** ID/name for immediate-mode VBO */ -#define IMM_BUFFER_NAME 0xaabbccdd - - -static void reset_attrfv( struct vbo_exec_context *exec ); - - -/** - * Close off the last primitive, execute the buffer, restart the - * primitive. - */ -static void vbo_exec_wrap_buffers( struct vbo_exec_context *exec ) -{ - if (exec->vtx.prim_count == 0) { - exec->vtx.copied.nr = 0; - exec->vtx.vert_count = 0; - exec->vtx.buffer_ptr = exec->vtx.buffer_map; - } - else { - GLuint last_begin = exec->vtx.prim[exec->vtx.prim_count-1].begin; - GLuint last_count; - - if (exec->ctx->Driver.CurrentExecPrimitive != PRIM_OUTSIDE_BEGIN_END) { - GLint i = exec->vtx.prim_count - 1; - assert(i >= 0); - exec->vtx.prim[i].count = (exec->vtx.vert_count - - exec->vtx.prim[i].start); - } - - last_count = exec->vtx.prim[exec->vtx.prim_count-1].count; - - /* Execute the buffer and save copied vertices. - */ - if (exec->vtx.vert_count) - vbo_exec_vtx_flush( exec, GL_FALSE ); - else { - exec->vtx.prim_count = 0; - exec->vtx.copied.nr = 0; - } - - /* Emit a glBegin to start the new list. - */ - assert(exec->vtx.prim_count == 0); - - if (exec->ctx->Driver.CurrentExecPrimitive != PRIM_OUTSIDE_BEGIN_END) { - exec->vtx.prim[0].mode = exec->ctx->Driver.CurrentExecPrimitive; - exec->vtx.prim[0].start = 0; - exec->vtx.prim[0].count = 0; - exec->vtx.prim_count++; - - if (exec->vtx.copied.nr == last_count) - exec->vtx.prim[0].begin = last_begin; - } - } -} - - -/** - * Deal with buffer wrapping where provoked by the vertex buffer - * filling up, as opposed to upgrade_vertex(). - */ -void vbo_exec_vtx_wrap( struct vbo_exec_context *exec ) -{ - GLfloat *data = exec->vtx.copied.buffer; - GLuint i; - - /* Run pipeline on current vertices, copy wrapped vertices - * to exec->vtx.copied. - */ - vbo_exec_wrap_buffers( exec ); - - /* Copy stored stored vertices to start of new list. - */ - assert(exec->vtx.max_vert - exec->vtx.vert_count > exec->vtx.copied.nr); - - for (i = 0 ; i < exec->vtx.copied.nr ; i++) { - memcpy( exec->vtx.buffer_ptr, data, - exec->vtx.vertex_size * sizeof(GLfloat)); - exec->vtx.buffer_ptr += exec->vtx.vertex_size; - data += exec->vtx.vertex_size; - exec->vtx.vert_count++; - } - - exec->vtx.copied.nr = 0; -} - - -/** - * Copy the active vertex's values to the ctx->Current fields. - */ -static void vbo_exec_copy_to_current( struct vbo_exec_context *exec ) -{ - struct gl_context *ctx = exec->ctx; - struct vbo_context *vbo = vbo_context(ctx); - GLuint i; - - for (i = VBO_ATTRIB_POS+1 ; i < VBO_ATTRIB_MAX ; i++) { - if (exec->vtx.attrsz[i]) { - /* Note: the exec->vtx.current[i] pointers point into the - * ctx->Current.Attrib and ctx->Light.Material.Attrib arrays. - */ - GLfloat *current = (GLfloat *)vbo->currval[i].Ptr; - GLfloat tmp[4]; - - COPY_CLEAN_4V(tmp, - exec->vtx.attrsz[i], - exec->vtx.attrptr[i]); - - if (memcmp(current, tmp, sizeof(tmp)) != 0) { - memcpy(current, tmp, sizeof(tmp)); - - /* Given that we explicitly state size here, there is no need - * for the COPY_CLEAN above, could just copy 16 bytes and be - * done. The only problem is when Mesa accesses ctx->Current - * directly. - */ - vbo->currval[i].Size = exec->vtx.attrsz[i]; - assert(vbo->currval[i].Type == GL_FLOAT); - vbo->currval[i]._ElementSize = vbo->currval[i].Size * sizeof(GLfloat); - - /* This triggers rather too much recalculation of Mesa state - * that doesn't get used (eg light positions). - */ - if (i >= VBO_ATTRIB_MAT_FRONT_AMBIENT && i <= VBO_ATTRIB_MAT_BACK_INDEXES) - ctx->NewState |= _NEW_LIGHT; - - ctx->NewState |= _NEW_CURRENT_ATTRIB; - } - } - } - - /* Colormaterial -- this kindof sucks. - */ - if (ctx->Light.ColorMaterialEnabled && - exec->vtx.attrsz[VBO_ATTRIB_COLOR]) { - _mesa_update_color_material(ctx, - ctx->Current.Attrib[VBO_ATTRIB_COLOR]); - } -} - - -/** - * Copy current vertex attribute values into the current vertex. - */ -static void -vbo_exec_copy_from_current(struct vbo_exec_context *exec) -{ - struct gl_context *ctx = exec->ctx; - struct vbo_context *vbo = vbo_context(ctx); - GLint i; - - for (i = VBO_ATTRIB_POS + 1; i < VBO_ATTRIB_MAX; i++) { - const GLfloat *current = (GLfloat *) vbo->currval[i].Ptr; - switch (exec->vtx.attrsz[i]) { - case 4: exec->vtx.attrptr[i][3] = current[3]; - case 3: exec->vtx.attrptr[i][2] = current[2]; - case 2: exec->vtx.attrptr[i][1] = current[1]; - case 1: exec->vtx.attrptr[i][0] = current[0]; - break; - } - } -} - - -/** - * Flush existing data, set new attrib size, replay copied vertices. - * This is called when we transition from a small vertex attribute size - * to a larger one. Ex: glTexCoord2f -> glTexCoord4f. - * We need to go back over the previous 2-component texcoords and insert - * zero and one values. - */ -static void -vbo_exec_wrap_upgrade_vertex(struct vbo_exec_context *exec, - GLuint attr, GLuint newSize ) -{ - struct gl_context *ctx = exec->ctx; - struct vbo_context *vbo = vbo_context(ctx); - const GLint lastcount = exec->vtx.vert_count; - GLfloat *old_attrptr[VBO_ATTRIB_MAX]; - const GLuint old_vtx_size = exec->vtx.vertex_size; /* floats per vertex */ - const GLuint oldSize = exec->vtx.attrsz[attr]; - GLuint i; - - /* Run pipeline on current vertices, copy wrapped vertices - * to exec->vtx.copied. - */ - vbo_exec_wrap_buffers( exec ); - - if (unlikely(exec->vtx.copied.nr)) { - /* We're in the middle of a primitive, keep the old vertex - * format around to be able to translate the copied vertices to - * the new format. - */ - memcpy(old_attrptr, exec->vtx.attrptr, sizeof(old_attrptr)); - } - - if (unlikely(oldSize)) { - /* Do a COPY_TO_CURRENT to ensure back-copying works for the - * case when the attribute already exists in the vertex and is - * having its size increased. - */ - vbo_exec_copy_to_current( exec ); - } - - /* Heuristic: Attempt to isolate attributes received outside - * begin/end so that they don't bloat the vertices. - */ - if (ctx->Driver.CurrentExecPrimitive == PRIM_OUTSIDE_BEGIN_END && - !oldSize && lastcount > 8 && exec->vtx.vertex_size) { - vbo_exec_copy_to_current( exec ); - reset_attrfv( exec ); - } - - /* Fix up sizes: - */ - exec->vtx.attrsz[attr] = newSize; - exec->vtx.vertex_size += newSize - oldSize; - exec->vtx.max_vert = ((VBO_VERT_BUFFER_SIZE - exec->vtx.buffer_used) / - (exec->vtx.vertex_size * sizeof(GLfloat))); - exec->vtx.vert_count = 0; - exec->vtx.buffer_ptr = exec->vtx.buffer_map; - - if (unlikely(oldSize)) { - /* Size changed, recalculate all the attrptr[] values - */ - GLfloat *tmp = exec->vtx.vertex; - - for (i = 0 ; i < VBO_ATTRIB_MAX ; i++) { - if (exec->vtx.attrsz[i]) { - exec->vtx.attrptr[i] = tmp; - tmp += exec->vtx.attrsz[i]; - } - else - exec->vtx.attrptr[i] = NULL; /* will not be dereferenced */ - } - - /* Copy from current to repopulate the vertex with correct - * values. - */ - vbo_exec_copy_from_current( exec ); - } - else { - /* Just have to append the new attribute at the end */ - exec->vtx.attrptr[attr] = exec->vtx.vertex + - exec->vtx.vertex_size - newSize; - } - - /* Replay stored vertices to translate them - * to new format here. - * - * -- No need to replay - just copy piecewise - */ - if (unlikely(exec->vtx.copied.nr)) { - GLfloat *data = exec->vtx.copied.buffer; - GLfloat *dest = exec->vtx.buffer_ptr; - GLuint j; - - assert(exec->vtx.buffer_ptr == exec->vtx.buffer_map); - - for (i = 0 ; i < exec->vtx.copied.nr ; i++) { - for (j = 0 ; j < VBO_ATTRIB_MAX ; j++) { - GLuint sz = exec->vtx.attrsz[j]; - - if (sz) { - GLint old_offset = old_attrptr[j] - exec->vtx.vertex; - GLint new_offset = exec->vtx.attrptr[j] - exec->vtx.vertex; - - if (j == attr) { - if (oldSize) { - GLfloat tmp[4]; - COPY_CLEAN_4V(tmp, oldSize, data + old_offset); - COPY_SZ_4V(dest + new_offset, newSize, tmp); - } else { - GLfloat *current = (GLfloat *)vbo->currval[j].Ptr; - COPY_SZ_4V(dest + new_offset, sz, current); - } - } - else { - COPY_SZ_4V(dest + new_offset, sz, data + old_offset); - } - } - } - - data += old_vtx_size; - dest += exec->vtx.vertex_size; - } - - exec->vtx.buffer_ptr = dest; - exec->vtx.vert_count += exec->vtx.copied.nr; - exec->vtx.copied.nr = 0; - } -} - - -/** - * This is when a vertex attribute transitions to a different size. - * For example, we saw a bunch of glTexCoord2f() calls and now we got a - * glTexCoord4f() call. We promote the array from size=2 to size=4. - */ -static void -vbo_exec_fixup_vertex(struct gl_context *ctx, GLuint attr, GLuint newSize) -{ - struct vbo_exec_context *exec = &vbo_context(ctx)->exec; - - if (newSize > exec->vtx.attrsz[attr]) { - /* New size is larger. Need to flush existing vertices and get - * an enlarged vertex format. - */ - vbo_exec_wrap_upgrade_vertex( exec, attr, newSize ); - } - else if (newSize < exec->vtx.active_sz[attr]) { - static const GLfloat id[4] = { 0, 0, 0, 1 }; - GLuint i; - - /* New size is smaller - just need to fill in some - * zeros. Don't need to flush or wrap. - */ - for (i = newSize; i <= exec->vtx.attrsz[attr]; i++) - exec->vtx.attrptr[attr][i-1] = id[i-1]; - } - - exec->vtx.active_sz[attr] = newSize; - - /* Does setting NeedFlush belong here? Necessitates resetting - * vtxfmt on each flush (otherwise flags won't get reset - * afterwards). - */ - if (attr == 0) - ctx->Driver.NeedFlush |= FLUSH_STORED_VERTICES; -} - - -/** - * This macro is used to implement all the glVertex, glColor, glTexCoord, - * glVertexAttrib, etc functions. - */ -#define ATTR( A, N, V0, V1, V2, V3 ) \ -do { \ - struct vbo_exec_context *exec = &vbo_context(ctx)->exec; \ - \ - if (unlikely(!(ctx->Driver.NeedFlush & FLUSH_UPDATE_CURRENT))) \ - ctx->Driver.BeginVertices( ctx ); \ - \ - if (unlikely(exec->vtx.active_sz[A] != N)) \ - vbo_exec_fixup_vertex(ctx, A, N); \ - \ - { \ - GLfloat *dest = exec->vtx.attrptr[A]; \ - if (N>0) dest[0] = V0; \ - if (N>1) dest[1] = V1; \ - if (N>2) dest[2] = V2; \ - if (N>3) dest[3] = V3; \ - } \ - \ - if ((A) == 0) { \ - /* This is a glVertex call */ \ - GLuint i; \ - \ - for (i = 0; i < exec->vtx.vertex_size; i++) \ - exec->vtx.buffer_ptr[i] = exec->vtx.vertex[i]; \ - \ - exec->vtx.buffer_ptr += exec->vtx.vertex_size; \ - \ - /* Set FLUSH_STORED_VERTICES to indicate that there's now */ \ - /* something to draw (not just updating a color or texcoord).*/ \ - ctx->Driver.NeedFlush |= FLUSH_STORED_VERTICES; \ - \ - if (++exec->vtx.vert_count >= exec->vtx.max_vert) \ - vbo_exec_vtx_wrap( exec ); \ - } \ -} while (0) - - -#define ERROR(err) _mesa_error( ctx, err, __FUNCTION__ ) -#define TAG(x) vbo_##x - -#include "vbo_attrib_tmp.h" - - - -/** - * Execute a glMaterial call. Note that if GL_COLOR_MATERIAL is enabled, - * this may be a (partial) no-op. - */ -static void GLAPIENTRY -vbo_Materialfv(GLenum face, GLenum pname, const GLfloat *params) -{ - GLbitfield updateMats; - GET_CURRENT_CONTEXT(ctx); - - /* This function should be a no-op when it tries to update material - * attributes which are currently tracking glColor via glColorMaterial. - * The updateMats var will be a mask of the MAT_BIT_FRONT/BACK_x bits - * indicating which material attributes can actually be updated below. - */ - if (ctx->Light.ColorMaterialEnabled) { - updateMats = ~ctx->Light.ColorMaterialBitmask; - } - else { - /* GL_COLOR_MATERIAL is disabled so don't skip any material updates */ - updateMats = ALL_MATERIAL_BITS; - } - - if (face == GL_FRONT) { - updateMats &= FRONT_MATERIAL_BITS; - } - else if (face == GL_BACK) { - updateMats &= BACK_MATERIAL_BITS; - } - else if (face != GL_FRONT_AND_BACK) { - _mesa_error(ctx, GL_INVALID_ENUM, "glMaterial(invalid face)"); - return; - } - - switch (pname) { - case GL_EMISSION: - if (updateMats & MAT_BIT_FRONT_EMISSION) - MAT_ATTR(VBO_ATTRIB_MAT_FRONT_EMISSION, 4, params); - if (updateMats & MAT_BIT_BACK_EMISSION) - MAT_ATTR(VBO_ATTRIB_MAT_BACK_EMISSION, 4, params); - break; - case GL_AMBIENT: - if (updateMats & MAT_BIT_FRONT_AMBIENT) - MAT_ATTR(VBO_ATTRIB_MAT_FRONT_AMBIENT, 4, params); - if (updateMats & MAT_BIT_BACK_AMBIENT) - MAT_ATTR(VBO_ATTRIB_MAT_BACK_AMBIENT, 4, params); - break; - case GL_DIFFUSE: - if (updateMats & MAT_BIT_FRONT_DIFFUSE) - MAT_ATTR(VBO_ATTRIB_MAT_FRONT_DIFFUSE, 4, params); - if (updateMats & MAT_BIT_BACK_DIFFUSE) - MAT_ATTR(VBO_ATTRIB_MAT_BACK_DIFFUSE, 4, params); - break; - case GL_SPECULAR: - if (updateMats & MAT_BIT_FRONT_SPECULAR) - MAT_ATTR(VBO_ATTRIB_MAT_FRONT_SPECULAR, 4, params); - if (updateMats & MAT_BIT_BACK_SPECULAR) - MAT_ATTR(VBO_ATTRIB_MAT_BACK_SPECULAR, 4, params); - break; - case GL_SHININESS: - if (*params < 0 || *params > ctx->Const.MaxShininess) { - _mesa_error(ctx, GL_INVALID_VALUE, - "glMaterial(invalid shininess: %f out range [0, %f])", - *params, ctx->Const.MaxShininess); - return; - } - if (updateMats & MAT_BIT_FRONT_SHININESS) - MAT_ATTR(VBO_ATTRIB_MAT_FRONT_SHININESS, 1, params); - if (updateMats & MAT_BIT_BACK_SHININESS) - MAT_ATTR(VBO_ATTRIB_MAT_BACK_SHININESS, 1, params); - break; - case GL_COLOR_INDEXES: - if (updateMats & MAT_BIT_FRONT_INDEXES) - MAT_ATTR(VBO_ATTRIB_MAT_FRONT_INDEXES, 3, params); - if (updateMats & MAT_BIT_BACK_INDEXES) - MAT_ATTR(VBO_ATTRIB_MAT_BACK_INDEXES, 3, params); - break; - case GL_AMBIENT_AND_DIFFUSE: - if (updateMats & MAT_BIT_FRONT_AMBIENT) - MAT_ATTR(VBO_ATTRIB_MAT_FRONT_AMBIENT, 4, params); - if (updateMats & MAT_BIT_FRONT_DIFFUSE) - MAT_ATTR(VBO_ATTRIB_MAT_FRONT_DIFFUSE, 4, params); - if (updateMats & MAT_BIT_BACK_AMBIENT) - MAT_ATTR(VBO_ATTRIB_MAT_BACK_AMBIENT, 4, params); - if (updateMats & MAT_BIT_BACK_DIFFUSE) - MAT_ATTR(VBO_ATTRIB_MAT_BACK_DIFFUSE, 4, params); - break; - default: - _mesa_error(ctx, GL_INVALID_ENUM, "glMaterialfv(pname)"); - return; - } -} - - -/** - * Flush (draw) vertices. - * \param unmap - leave VBO unmapped after flushing? - */ -static void -vbo_exec_FlushVertices_internal(struct vbo_exec_context *exec, GLboolean unmap) -{ - if (exec->vtx.vert_count || unmap) { - vbo_exec_vtx_flush( exec, unmap ); - } - - if (exec->vtx.vertex_size) { - vbo_exec_copy_to_current( exec ); - reset_attrfv( exec ); - } -} - - -#if FEATURE_beginend - - -#if FEATURE_evaluators - -static void GLAPIENTRY vbo_exec_EvalCoord1f( GLfloat u ) -{ - GET_CURRENT_CONTEXT( ctx ); - struct vbo_exec_context *exec = &vbo_context(ctx)->exec; - - { - GLint i; - if (exec->eval.recalculate_maps) - vbo_exec_eval_update( exec ); - - for (i = 0; i <= VBO_ATTRIB_TEX; i++) { - if (exec->eval.map1[i].map) - if (exec->vtx.active_sz[i] != exec->eval.map1[i].sz) - vbo_exec_fixup_vertex( ctx, i, exec->eval.map1[i].sz ); - } - } - - - memcpy( exec->vtx.copied.buffer, exec->vtx.vertex, - exec->vtx.vertex_size * sizeof(GLfloat)); - - vbo_exec_do_EvalCoord1f( exec, u ); - - memcpy( exec->vtx.vertex, exec->vtx.copied.buffer, - exec->vtx.vertex_size * sizeof(GLfloat)); -} - -static void GLAPIENTRY vbo_exec_EvalCoord2f( GLfloat u, GLfloat v ) -{ - GET_CURRENT_CONTEXT( ctx ); - struct vbo_exec_context *exec = &vbo_context(ctx)->exec; - - { - GLint i; - if (exec->eval.recalculate_maps) - vbo_exec_eval_update( exec ); - - for (i = 0; i <= VBO_ATTRIB_TEX; i++) { - if (exec->eval.map2[i].map) - if (exec->vtx.active_sz[i] != exec->eval.map2[i].sz) - vbo_exec_fixup_vertex( ctx, i, exec->eval.map2[i].sz ); - } - - if (ctx->Eval.AutoNormal) - if (exec->vtx.active_sz[VBO_ATTRIB_NORMAL] != 3) - vbo_exec_fixup_vertex( ctx, VBO_ATTRIB_NORMAL, 3 ); - } - - memcpy( exec->vtx.copied.buffer, exec->vtx.vertex, - exec->vtx.vertex_size * sizeof(GLfloat)); - - vbo_exec_do_EvalCoord2f( exec, u, v ); - - memcpy( exec->vtx.vertex, exec->vtx.copied.buffer, - exec->vtx.vertex_size * sizeof(GLfloat)); -} - -static void GLAPIENTRY vbo_exec_EvalCoord1fv( const GLfloat *u ) -{ - vbo_exec_EvalCoord1f( u[0] ); -} - -static void GLAPIENTRY vbo_exec_EvalCoord2fv( const GLfloat *u ) -{ - vbo_exec_EvalCoord2f( u[0], u[1] ); -} - -static void GLAPIENTRY vbo_exec_EvalPoint1( GLint i ) -{ - GET_CURRENT_CONTEXT( ctx ); - GLfloat du = ((ctx->Eval.MapGrid1u2 - ctx->Eval.MapGrid1u1) / - (GLfloat) ctx->Eval.MapGrid1un); - GLfloat u = i * du + ctx->Eval.MapGrid1u1; - - vbo_exec_EvalCoord1f( u ); -} - - -static void GLAPIENTRY vbo_exec_EvalPoint2( GLint i, GLint j ) -{ - GET_CURRENT_CONTEXT( ctx ); - GLfloat du = ((ctx->Eval.MapGrid2u2 - ctx->Eval.MapGrid2u1) / - (GLfloat) ctx->Eval.MapGrid2un); - GLfloat dv = ((ctx->Eval.MapGrid2v2 - ctx->Eval.MapGrid2v1) / - (GLfloat) ctx->Eval.MapGrid2vn); - GLfloat u = i * du + ctx->Eval.MapGrid2u1; - GLfloat v = j * dv + ctx->Eval.MapGrid2v1; - - vbo_exec_EvalCoord2f( u, v ); -} - - -static void GLAPIENTRY -vbo_exec_EvalMesh1(GLenum mode, GLint i1, GLint i2) -{ - GET_CURRENT_CONTEXT(ctx); - GLint i; - GLfloat u, du; - GLenum prim; - - ASSERT_OUTSIDE_BEGIN_END(ctx); - - switch (mode) { - case GL_POINT: - prim = GL_POINTS; - break; - case GL_LINE: - prim = GL_LINE_STRIP; - break; - default: - _mesa_error( ctx, GL_INVALID_ENUM, "glEvalMesh1(mode)" ); - return; - } - - /* No effect if vertex maps disabled. - */ - if (!ctx->Eval.Map1Vertex4 && - !ctx->Eval.Map1Vertex3) - return; - - du = ctx->Eval.MapGrid1du; - u = ctx->Eval.MapGrid1u1 + i1 * du; - - CALL_Begin(GET_DISPATCH(), (prim)); - for (i=i1;i<=i2;i++,u+=du) { - CALL_EvalCoord1f(GET_DISPATCH(), (u)); - } - CALL_End(GET_DISPATCH(), ()); -} - - -static void GLAPIENTRY -vbo_exec_EvalMesh2(GLenum mode, GLint i1, GLint i2, GLint j1, GLint j2) -{ - GET_CURRENT_CONTEXT(ctx); - GLfloat u, du, v, dv, v1, u1; - GLint i, j; - - ASSERT_OUTSIDE_BEGIN_END(ctx); - - switch (mode) { - case GL_POINT: - case GL_LINE: - case GL_FILL: - break; - default: - _mesa_error( ctx, GL_INVALID_ENUM, "glEvalMesh2(mode)" ); - return; - } - - /* No effect if vertex maps disabled. - */ - if (!ctx->Eval.Map2Vertex4 && - !ctx->Eval.Map2Vertex3) - return; - - du = ctx->Eval.MapGrid2du; - dv = ctx->Eval.MapGrid2dv; - v1 = ctx->Eval.MapGrid2v1 + j1 * dv; - u1 = ctx->Eval.MapGrid2u1 + i1 * du; - - switch (mode) { - case GL_POINT: - CALL_Begin(GET_DISPATCH(), (GL_POINTS)); - for (v=v1,j=j1;j<=j2;j++,v+=dv) { - for (u=u1,i=i1;i<=i2;i++,u+=du) { - CALL_EvalCoord2f(GET_DISPATCH(), (u, v)); - } - } - CALL_End(GET_DISPATCH(), ()); - break; - case GL_LINE: - for (v=v1,j=j1;j<=j2;j++,v+=dv) { - CALL_Begin(GET_DISPATCH(), (GL_LINE_STRIP)); - for (u=u1,i=i1;i<=i2;i++,u+=du) { - CALL_EvalCoord2f(GET_DISPATCH(), (u, v)); - } - CALL_End(GET_DISPATCH(), ()); - } - for (u=u1,i=i1;i<=i2;i++,u+=du) { - CALL_Begin(GET_DISPATCH(), (GL_LINE_STRIP)); - for (v=v1,j=j1;j<=j2;j++,v+=dv) { - CALL_EvalCoord2f(GET_DISPATCH(), (u, v)); - } - CALL_End(GET_DISPATCH(), ()); - } - break; - case GL_FILL: - for (v=v1,j=j1;jDriver.CurrentExecPrimitive == PRIM_OUTSIDE_BEGIN_END) { - struct vbo_exec_context *exec = &vbo_context(ctx)->exec; - int i; - - if (!_mesa_valid_prim_mode(ctx, mode)) { - _mesa_error(ctx, GL_INVALID_ENUM, "glBegin"); - return; - } - - vbo_draw_method(exec, DRAW_BEGIN_END); - - if (ctx->Driver.PrepareExecBegin) - ctx->Driver.PrepareExecBegin(ctx); - - if (ctx->NewState) { - _mesa_update_state( ctx ); - - CALL_Begin(ctx->Exec, (mode)); - return; - } - - if (!_mesa_valid_to_render(ctx, "glBegin")) { - return; - } - - /* Heuristic: attempt to isolate attributes occurring outside - * begin/end pairs. - */ - if (exec->vtx.vertex_size && !exec->vtx.attrsz[0]) - vbo_exec_FlushVertices_internal(exec, GL_FALSE); - - i = exec->vtx.prim_count++; - exec->vtx.prim[i].mode = mode; - exec->vtx.prim[i].begin = 1; - exec->vtx.prim[i].end = 0; - exec->vtx.prim[i].indexed = 0; - exec->vtx.prim[i].weak = 0; - exec->vtx.prim[i].pad = 0; - exec->vtx.prim[i].start = exec->vtx.vert_count; - exec->vtx.prim[i].count = 0; - exec->vtx.prim[i].num_instances = 1; - - ctx->Driver.CurrentExecPrimitive = mode; - } - else - _mesa_error( ctx, GL_INVALID_OPERATION, "glBegin" ); - -} - - -/** - * Called via glEnd. - */ -static void GLAPIENTRY vbo_exec_End( void ) -{ - GET_CURRENT_CONTEXT( ctx ); - - if (ctx->Driver.CurrentExecPrimitive != PRIM_OUTSIDE_BEGIN_END) { - struct vbo_exec_context *exec = &vbo_context(ctx)->exec; - - if (exec->vtx.prim_count > 0) { - /* close off current primitive */ - int idx = exec->vtx.vert_count; - int i = exec->vtx.prim_count - 1; - - exec->vtx.prim[i].end = 1; - exec->vtx.prim[i].count = idx - exec->vtx.prim[i].start; - } - - ctx->Driver.CurrentExecPrimitive = PRIM_OUTSIDE_BEGIN_END; - - if (exec->vtx.prim_count == VBO_MAX_PRIM) - vbo_exec_vtx_flush( exec, GL_FALSE ); - } - else - _mesa_error( ctx, GL_INVALID_OPERATION, "glEnd" ); -} - - -static void vbo_exec_vtxfmt_init( struct vbo_exec_context *exec ) -{ - GLvertexformat *vfmt = &exec->vtxfmt; - - _MESA_INIT_ARRAYELT_VTXFMT(vfmt, _ae_); - - vfmt->Begin = vbo_exec_Begin; - vfmt->End = vbo_exec_End; - - _MESA_INIT_DLIST_VTXFMT(vfmt, _mesa_); - _MESA_INIT_EVAL_VTXFMT(vfmt, vbo_exec_); - - vfmt->Rectf = vbo_exec_Rectf; - - /* from attrib_tmp.h: - */ - vfmt->Color3f = vbo_Color3f; - vfmt->Color3fv = vbo_Color3fv; - vfmt->Color4f = vbo_Color4f; - vfmt->Color4fv = vbo_Color4fv; - vfmt->FogCoordfEXT = vbo_FogCoordfEXT; - vfmt->FogCoordfvEXT = vbo_FogCoordfvEXT; - vfmt->Normal3f = vbo_Normal3f; - vfmt->Normal3fv = vbo_Normal3fv; - vfmt->TexCoord1f = vbo_TexCoord1f; - vfmt->TexCoord1fv = vbo_TexCoord1fv; - vfmt->TexCoord2f = vbo_TexCoord2f; - vfmt->TexCoord2fv = vbo_TexCoord2fv; - vfmt->TexCoord3f = vbo_TexCoord3f; - vfmt->TexCoord3fv = vbo_TexCoord3fv; - vfmt->TexCoord4f = vbo_TexCoord4f; - vfmt->TexCoord4fv = vbo_TexCoord4fv; - vfmt->Vertex2f = vbo_Vertex2f; - vfmt->Vertex2fv = vbo_Vertex2fv; - vfmt->Vertex3f = vbo_Vertex3f; - vfmt->Vertex3fv = vbo_Vertex3fv; - vfmt->Vertex4f = vbo_Vertex4f; - vfmt->Vertex4fv = vbo_Vertex4fv; - - vfmt->VertexAttrib1fNV = vbo_VertexAttrib1fNV; - vfmt->VertexAttrib1fvNV = vbo_VertexAttrib1fvNV; - vfmt->VertexAttrib2fNV = vbo_VertexAttrib2fNV; - vfmt->VertexAttrib2fvNV = vbo_VertexAttrib2fvNV; - vfmt->VertexAttrib3fNV = vbo_VertexAttrib3fNV; - vfmt->VertexAttrib3fvNV = vbo_VertexAttrib3fvNV; - vfmt->VertexAttrib4fNV = vbo_VertexAttrib4fNV; - vfmt->VertexAttrib4fvNV = vbo_VertexAttrib4fvNV; - - vfmt->Materialfv = vbo_Materialfv; - - vfmt->EdgeFlag = vbo_EdgeFlag; - vfmt->Indexf = vbo_Indexf; - vfmt->Indexfv = vbo_Indexfv; -} - - -#else /* FEATURE_beginend */ - - -static void vbo_exec_vtxfmt_init( struct vbo_exec_context *exec ) -{ - /* silence warnings */ - (void) vbo_Color3f; - (void) vbo_Color3fv; - (void) vbo_Color4f; - (void) vbo_Color4fv; - (void) vbo_FogCoordfEXT; - (void) vbo_FogCoordfvEXT; - (void) vbo_MultiTexCoord1f; - (void) vbo_MultiTexCoord1fv; - (void) vbo_MultiTexCoord2f; - (void) vbo_MultiTexCoord2fv; - (void) vbo_MultiTexCoord3f; - (void) vbo_MultiTexCoord3fv; - (void) vbo_MultiTexCoord4f; - (void) vbo_MultiTexCoord4fv; - (void) vbo_Normal3f; - (void) vbo_Normal3fv; - (void) vbo_TexCoord1f; - (void) vbo_TexCoord1fv; - (void) vbo_TexCoord2f; - (void) vbo_TexCoord2fv; - (void) vbo_TexCoord3f; - (void) vbo_TexCoord3fv; - (void) vbo_TexCoord4f; - (void) vbo_TexCoord4fv; - (void) vbo_Vertex2f; - (void) vbo_Vertex2fv; - (void) vbo_Vertex3f; - (void) vbo_Vertex3fv; - (void) vbo_Vertex4f; - (void) vbo_Vertex4fv; - - (void) vbo_VertexAttrib1fNV; - (void) vbo_VertexAttrib1fvNV; - (void) vbo_VertexAttrib2fNV; - (void) vbo_VertexAttrib2fvNV; - (void) vbo_VertexAttrib3fNV; - (void) vbo_VertexAttrib3fvNV; - (void) vbo_VertexAttrib4fNV; - (void) vbo_VertexAttrib4fvNV; - - (void) vbo_Materialfv; - - (void) vbo_EdgeFlag; - (void) vbo_Indexf; - (void) vbo_Indexfv; -} - - -#endif /* FEATURE_beginend */ - - -/** - * Tell the VBO module to use a real OpenGL vertex buffer object to - * store accumulated immediate-mode vertex data. - * This replaces the malloced buffer which was created in - * vb_exec_vtx_init() below. - */ -void vbo_use_buffer_objects(struct gl_context *ctx) -{ - struct vbo_exec_context *exec = &vbo_context(ctx)->exec; - /* Any buffer name but 0 can be used here since this bufferobj won't - * go into the bufferobj hashtable. - */ - GLuint bufName = IMM_BUFFER_NAME; - GLenum target = GL_ARRAY_BUFFER_ARB; - GLenum usage = GL_STREAM_DRAW_ARB; - GLsizei size = VBO_VERT_BUFFER_SIZE; - - /* Make sure this func is only used once */ - assert(exec->vtx.bufferobj == ctx->Shared->NullBufferObj); - if (exec->vtx.buffer_map) { - _mesa_align_free(exec->vtx.buffer_map); - exec->vtx.buffer_map = NULL; - exec->vtx.buffer_ptr = NULL; - } - - /* Allocate a real buffer object now */ - _mesa_reference_buffer_object(ctx, &exec->vtx.bufferobj, NULL); - exec->vtx.bufferobj = ctx->Driver.NewBufferObject(ctx, bufName, target); - if (!ctx->Driver.BufferData(ctx, target, size, NULL, usage, exec->vtx.bufferobj)) { - _mesa_error(ctx, GL_OUT_OF_MEMORY, "VBO allocation"); - } -} - - -/** - * If this function is called, all VBO buffers will be unmapped when - * we flush. - * Otherwise, if a simple command like glColor3f() is called and we flush, - * the current VBO may be left mapped. - */ -void -vbo_always_unmap_buffers(struct gl_context *ctx) -{ - struct vbo_exec_context *exec = &vbo_context(ctx)->exec; - exec->begin_vertices_flags |= FLUSH_STORED_VERTICES; -} - - -void vbo_exec_vtx_init( struct vbo_exec_context *exec ) -{ - struct gl_context *ctx = exec->ctx; - struct vbo_context *vbo = vbo_context(ctx); - GLuint i; - - /* Allocate a buffer object. Will just reuse this object - * continuously, unless vbo_use_buffer_objects() is called to enable - * use of real VBOs. - */ - _mesa_reference_buffer_object(ctx, - &exec->vtx.bufferobj, - ctx->Shared->NullBufferObj); - - ASSERT(!exec->vtx.buffer_map); - exec->vtx.buffer_map = (GLfloat *)_mesa_align_malloc(VBO_VERT_BUFFER_SIZE, 64); - exec->vtx.buffer_ptr = exec->vtx.buffer_map; - - vbo_exec_vtxfmt_init( exec ); - _mesa_noop_vtxfmt_init(&exec->vtxfmt_noop); - - /* Hook our functions into the dispatch table. - */ - _mesa_install_exec_vtxfmt( ctx, &exec->vtxfmt ); - - for (i = 0 ; i < VBO_ATTRIB_MAX ; i++) { - ASSERT(i < Elements(exec->vtx.attrsz)); - exec->vtx.attrsz[i] = 0; - ASSERT(i < Elements(exec->vtx.active_sz)); - exec->vtx.active_sz[i] = 0; - } - for (i = 0 ; i < VERT_ATTRIB_MAX; i++) { - ASSERT(i < Elements(exec->vtx.inputs)); - ASSERT(i < Elements(exec->vtx.arrays)); - exec->vtx.inputs[i] = &exec->vtx.arrays[i]; - } - - { - struct gl_client_array *arrays = exec->vtx.arrays; - unsigned i; - - memcpy(arrays, vbo->legacy_currval, - VERT_ATTRIB_MAX * sizeof(arrays[0])); - for (i = 0; i < VERT_ATTRIB_MAX; ++i) { - struct gl_client_array *array; - array = &arrays[VERT_ATTRIB(i)]; - array->BufferObj = NULL; - _mesa_reference_buffer_object(ctx, &arrays->BufferObj, - vbo->legacy_currval[i].BufferObj); - } - } - - exec->vtx.vertex_size = 0; - - exec->begin_vertices_flags = FLUSH_UPDATE_CURRENT; -} - - -void vbo_exec_vtx_destroy( struct vbo_exec_context *exec ) -{ - /* using a real VBO for vertex data */ - struct gl_context *ctx = exec->ctx; - unsigned i; - - /* True VBOs should already be unmapped - */ - if (exec->vtx.buffer_map) { - ASSERT(exec->vtx.bufferobj->Name == 0 || - exec->vtx.bufferobj->Name == IMM_BUFFER_NAME); - if (exec->vtx.bufferobj->Name == 0) { - _mesa_align_free(exec->vtx.buffer_map); - exec->vtx.buffer_map = NULL; - exec->vtx.buffer_ptr = NULL; - } - } - - /* Drop any outstanding reference to the vertex buffer - */ - for (i = 0; i < Elements(exec->vtx.arrays); i++) { - _mesa_reference_buffer_object(ctx, - &exec->vtx.arrays[i].BufferObj, - NULL); - } - - /* Free the vertex buffer. Unmap first if needed. - */ - if (_mesa_bufferobj_mapped(exec->vtx.bufferobj)) { - ctx->Driver.UnmapBuffer(ctx, exec->vtx.bufferobj); - } - _mesa_reference_buffer_object(ctx, &exec->vtx.bufferobj, NULL); -} - - -/** - * Called upon first glVertex, glColor, glTexCoord, etc. - */ -void vbo_exec_BeginVertices( struct gl_context *ctx ) -{ - struct vbo_exec_context *exec = &vbo_context(ctx)->exec; - - vbo_exec_vtx_map( exec ); - - assert((ctx->Driver.NeedFlush & FLUSH_UPDATE_CURRENT) == 0); - assert(exec->begin_vertices_flags); - - ctx->Driver.NeedFlush |= exec->begin_vertices_flags; -} - - -/** - * Called via ctx->Driver.FlushVertices() - * \param flags bitmask of FLUSH_STORED_VERTICES, FLUSH_UPDATE_CURRENT - */ -void vbo_exec_FlushVertices( struct gl_context *ctx, GLuint flags ) -{ - struct vbo_exec_context *exec = &vbo_context(ctx)->exec; - -#ifdef DEBUG - /* debug check: make sure we don't get called recursively */ - exec->flush_call_depth++; - assert(exec->flush_call_depth == 1); -#endif - - if (ctx->Driver.CurrentExecPrimitive != PRIM_OUTSIDE_BEGIN_END) { - /* We've had glBegin but not glEnd! */ -#ifdef DEBUG - exec->flush_call_depth--; - assert(exec->flush_call_depth == 0); -#endif - return; - } - - /* Flush (draw), and make sure VBO is left unmapped when done */ - vbo_exec_FlushVertices_internal(exec, GL_TRUE); - - /* Need to do this to ensure BeginVertices gets called again: - */ - ctx->Driver.NeedFlush &= ~(FLUSH_UPDATE_CURRENT | flags); - -#ifdef DEBUG - exec->flush_call_depth--; - assert(exec->flush_call_depth == 0); -#endif -} - - -static void reset_attrfv( struct vbo_exec_context *exec ) -{ - GLuint i; - - for (i = 0 ; i < VBO_ATTRIB_MAX ; i++) { - exec->vtx.attrsz[i] = 0; - exec->vtx.active_sz[i] = 0; - } - - exec->vtx.vertex_size = 0; -} diff --git a/dll/opengl/mesa/vbo/vbo_exec_array.c b/dll/opengl/mesa/vbo/vbo_exec_array.c deleted file mode 100644 index 1858771658f..00000000000 --- a/dll/opengl/mesa/vbo/vbo_exec_array.c +++ /dev/null @@ -1,543 +0,0 @@ -/************************************************************************** - * - * Copyright 2003 Tungsten Graphics, Inc., Cedar Park, Texas. - * Copyright 2009 VMware, Inc. - * All Rights Reserved. - * - * Permission is hereby granted, free of charge, to any person obtaining a - * copy of this software and associated documentation files (the - * "Software"), to deal in the Software without restriction, including - * without limitation the rights to use, copy, modify, merge, publish, - * distribute, sub license, and/or sell copies of the Software, and to - * permit persons to whom the Software is furnished to do so, subject to - * the following conditions: - * - * The above copyright notice and this permission notice (including the - * next paragraph) shall be included in all copies or substantial portions - * of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS - * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF - * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT. - * IN NO EVENT SHALL TUNGSTEN GRAPHICS AND/OR ITS SUPPLIERS BE LIABLE FOR - * ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, - * TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE - * SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. - * - **************************************************************************/ - -#include - -/** - * All vertex buffers should be in an unmapped state when we're about - * to draw. This debug function checks that. - */ -static void -check_buffers_are_unmapped(const struct gl_client_array **inputs) -{ -#ifdef DEBUG - GLuint i; - - for (i = 0; i < VBO_ATTRIB_MAX; i++) { - if (inputs[i]) { - struct gl_buffer_object *obj = inputs[i]->BufferObj; - assert(!_mesa_bufferobj_mapped(obj)); - (void) obj; - } - } -#endif -} - - -/** - * A debug function that may be called from other parts of Mesa as - * needed during debugging. - */ -void -vbo_check_buffers_are_unmapped(struct gl_context *ctx) -{ - struct vbo_context *vbo = vbo_context(ctx); - struct vbo_exec_context *exec = &vbo->exec; - /* check the current vertex arrays */ - check_buffers_are_unmapped(exec->array.inputs); - /* check the current glBegin/glVertex/glEnd-style VBO */ - assert(!_mesa_bufferobj_mapped(exec->vtx.bufferobj)); -} - -int -vbo_sizeof_ib_type(GLenum type) -{ - switch (type) { - case GL_UNSIGNED_INT: - return sizeof(GLuint); - case GL_UNSIGNED_SHORT: - return sizeof(GLushort); - case GL_UNSIGNED_BYTE: - return sizeof(GLubyte); - default: - assert(!"unsupported index data type"); - /* In case assert is turned off */ - return 0; - } -} - - -/** - * Compute min and max elements by scanning the index buffer for - * glDraw[Range]Elements() calls. - * If primitive restart is enabled, we need to ignore restart - * indexes when computing min/max. - */ -void -vbo_get_minmax_index(struct gl_context *ctx, - const struct _mesa_prim *prim, - const struct _mesa_index_buffer *ib, - GLuint *min_index, GLuint *max_index) -{ - const GLuint count = prim->count; - const void *indices; - GLuint i; - - if (_mesa_is_bufferobj(ib->obj)) { - indices = ctx->Driver.MapBufferRange(ctx, (GLsizeiptr) ib->ptr, - count * vbo_sizeof_ib_type(ib->type), - GL_MAP_READ_BIT, ib->obj); - } else { - indices = ib->ptr; - } - - switch (ib->type) { - case GL_UNSIGNED_INT: { - const GLuint *ui_indices = (const GLuint *)indices; - GLuint max_ui = 0; - GLuint min_ui = ~0U; - for (i = 0; i < count; i++) { - if (ui_indices[i] > max_ui) max_ui = ui_indices[i]; - if (ui_indices[i] < min_ui) min_ui = ui_indices[i]; - } - *min_index = min_ui; - *max_index = max_ui; - break; - } - case GL_UNSIGNED_SHORT: { - const GLushort *us_indices = (const GLushort *)indices; - GLuint max_us = 0; - GLuint min_us = ~0U; - for (i = 0; i < count; i++) { - if (us_indices[i] > max_us) max_us = us_indices[i]; - if (us_indices[i] < min_us) min_us = us_indices[i]; - } - *min_index = min_us; - *max_index = max_us; - break; - } - case GL_UNSIGNED_BYTE: { - const GLubyte *ub_indices = (const GLubyte *)indices; - GLuint max_ub = 0; - GLuint min_ub = ~0U; - for (i = 0; i < count; i++) { - if (ub_indices[i] > max_ub) max_ub = ub_indices[i]; - if (ub_indices[i] < min_ub) min_ub = ub_indices[i]; - } - *min_index = min_ub; - *max_index = max_ub; - break; - } - default: - assert(0); - break; - } - - if (_mesa_is_bufferobj(ib->obj)) { - ctx->Driver.UnmapBuffer(ctx, ib->obj); - } -} - - -/** - * Check array data, looking for NaNs, etc. - */ -static void -check_draw_arrays_data(struct gl_context *ctx, GLint start, GLsizei count) -{ - /* TO DO */ -} - - -/** - * Print info/data for glDrawArrays(), for debugging. - */ -static void -print_draw_arrays(struct gl_context *ctx, - GLenum mode, GLint start, GLsizei count) -{ - struct vbo_context *vbo = vbo_context(ctx); - struct vbo_exec_context *exec = &vbo->exec; - int i; - - printf("vbo_exec_DrawArrays(mode 0x%x, start %d, count %d):\n", - mode, start, count); - - for (i = 0; i < 32; i++) { - struct gl_buffer_object *bufObj = exec->array.inputs[i]->BufferObj; - GLuint bufName = bufObj->Name; - GLint stride = exec->array.inputs[i]->Stride; - printf("attr %2d: size %d stride %d enabled %d " - "ptr %p Bufobj %u\n", - i, - exec->array.inputs[i]->Size, - stride, - /*exec->array.inputs[i]->Enabled,*/ - ctx->Array.VertexAttrib[VERT_ATTRIB(i)].Enabled, - exec->array.inputs[i]->Ptr, - bufName); - - if (bufName) { - GLubyte *p = ctx->Driver.MapBufferRange(ctx, 0, bufObj->Size, - GL_MAP_READ_BIT, bufObj); - int offset = (int) (GLintptr) exec->array.inputs[i]->Ptr; - float *f = (float *) (p + offset); - int *k = (int *) f; - int i; - int n = (count * stride) / 4; - if (n > 32) - n = 32; - printf(" Data at offset %d:\n", offset); - for (i = 0; i < n; i++) { - printf(" float[%d] = 0x%08x %f\n", i, k[i], f[i]); - } - ctx->Driver.UnmapBuffer(ctx, bufObj); - } - } -} - - -/** - * Set the vbo->exec->inputs[] pointers to point to the enabled - * vertex arrays. This depends on the current vertex program/shader - * being executed because of whether or not generic vertex arrays - * alias the conventional vertex arrays. - * For arrays that aren't enabled, we set the input[attrib] pointer - * to point at a zero-stride current value "array". - */ -static void -recalculate_input_bindings(struct gl_context *ctx) -{ - struct vbo_context *vbo = vbo_context(ctx); - struct vbo_exec_context *exec = &vbo->exec; - struct gl_client_array *vertexAttrib = ctx->Array.VertexAttrib; - const struct gl_client_array **inputs = &exec->array.inputs[0]; - GLbitfield64 const_inputs = 0x0; - GLuint i; - - for (i = 0; i < VBO_ATTRIB_MAX; i++) { - if ((i < VERT_ATTRIB_MAX) && (vertexAttrib[VERT_ATTRIB(i)].Enabled)) - inputs[i] = &vertexAttrib[VERT_ATTRIB(i)]; - else { - inputs[i] = &vbo->currval[i]; - const_inputs |= VERT_BIT(i); - } - } - - ctx->NewState |= _NEW_ARRAY; -} - - -/** - * Examine the enabled vertex arrays to set the exec->array.inputs[] values. - * These will point to the arrays to actually use for drawing. Some will - * be user-provided arrays, other will be zero-stride const-valued arrays. - * Note that this might set the _NEW_ARRAY dirty flag so state validation - * must be done after this call. - */ -void -vbo_bind_arrays(struct gl_context *ctx) -{ - if (!ctx->Array.RebindArrays) { - return; - } - - recalculate_input_bindings(ctx); - ctx->Array.RebindArrays = GL_FALSE; -} - - -/** - * Helper function called by the other DrawArrays() functions below. - * This is where we handle primitive restart for drawing non-indexed - * arrays. If primitive restart is enabled, it typically means - * splitting one DrawArrays() into two. - */ -static void -vbo_draw_arrays(struct gl_context *ctx, GLenum mode, GLint start, - GLsizei count, GLuint numInstances) -{ - struct vbo_context *vbo = vbo_context(ctx); - struct vbo_exec_context *exec = &vbo->exec; - struct _mesa_prim prim[2]; - - vbo_bind_arrays(ctx); - - vbo_draw_method(exec, DRAW_ARRAYS); - - /* Again... because we may have changed the bitmask of per-vertex varying - * attributes. If we regenerate the fixed-function vertex program now - * we may be able to prune down the number of vertex attributes which we - * need in the shader. - */ - if (ctx->NewState) - _mesa_update_state(ctx); - - /* init most fields to zero */ - memset(prim, 0, sizeof(prim)); - prim[0].begin = 1; - prim[0].end = 1; - prim[0].mode = mode; - prim[0].num_instances = numInstances; - - /* no prim restart */ - prim[0].start = start; - prim[0].count = count; - - check_buffers_are_unmapped(exec->array.inputs); - vbo->draw_prims(ctx, exec->array.inputs, prim, 1, NULL, - GL_TRUE, start, start + count - 1); -} - - - -/** - * Called from glDrawArrays when in immediate mode (not display list mode). - */ -static void GLAPIENTRY -vbo_exec_DrawArrays(GLenum mode, GLint start, GLsizei count) -{ - GET_CURRENT_CONTEXT(ctx); - - if (MESA_VERBOSE & VERBOSE_DRAW) - _mesa_debug(ctx, "glDrawArrays(%s, %d, %d)\n", - _mesa_lookup_enum_by_nr(mode), start, count); - - if (!_mesa_validate_DrawArrays( ctx, mode, start, count )) - return; - - FLUSH_CURRENT( ctx, 0 ); - - if (!_mesa_valid_to_render(ctx, "glDrawArrays")) { - return; - } - - if (0) - check_draw_arrays_data(ctx, start, count); - - vbo_draw_arrays(ctx, mode, start, count, 1); - - if (0) - print_draw_arrays(ctx, mode, start, count); -} - - -/** - * Map GL_ELEMENT_ARRAY_BUFFER and print contents. - * For debugging. - */ -#if 0 -static void -dump_element_buffer(struct gl_context *ctx, GLenum type) -{ - const GLvoid *map = - ctx->Driver.MapBufferRange(ctx, 0, - ctx->Array.ArrayObj->ElementArrayBufferObj->Size, - GL_MAP_READ_BIT, - ctx->Array.ArrayObj->ElementArrayBufferObj); - switch (type) { - case GL_UNSIGNED_BYTE: - { - const GLubyte *us = (const GLubyte *) map; - GLint i; - for (i = 0; i < ctx->Array.ArrayObj->ElementArrayBufferObj->Size; i++) { - printf("%02x ", us[i]); - if (i % 32 == 31) - printf("\n"); - } - printf("\n"); - } - break; - case GL_UNSIGNED_SHORT: - { - const GLushort *us = (const GLushort *) map; - GLint i; - for (i = 0; i < ctx->Array.ArrayObj->ElementArrayBufferObj->Size / 2; i++) { - printf("%04x ", us[i]); - if (i % 16 == 15) - printf("\n"); - } - printf("\n"); - } - break; - case GL_UNSIGNED_INT: - { - const GLuint *us = (const GLuint *) map; - GLint i; - for (i = 0; i < ctx->Array.ArrayObj->ElementArrayBufferObj->Size / 4; i++) { - printf("%08x ", us[i]); - if (i % 8 == 7) - printf("\n"); - } - printf("\n"); - } - break; - default: - ; - } - - ctx->Driver.UnmapBuffer(ctx, ctx->Array.ArrayObj->ElementArrayBufferObj); -} -#endif - - -/** - * Inner support for both _mesa_DrawElements and _mesa_DrawRangeElements. - * Do the rendering for a glDrawElements or glDrawRangeElements call after - * we've validated buffer bounds, etc. - */ -static void -vbo_validated_drawrangeelements(struct gl_context *ctx, GLenum mode, - GLboolean index_bounds_valid, - GLuint start, GLuint end, - GLsizei count, GLenum type, - const GLvoid *indices, GLint numInstances) -{ - struct vbo_context *vbo = vbo_context(ctx); - struct vbo_exec_context *exec = &vbo->exec; - struct _mesa_index_buffer ib; - struct _mesa_prim prim[1]; - - FLUSH_CURRENT( ctx, 0 ); - - if (!_mesa_valid_to_render(ctx, "glDraw[Range]Elements")) { - return; - } - - vbo_bind_arrays( ctx ); - - vbo_draw_method(exec, DRAW_ARRAYS); - - /* check for dirty state again */ - if (ctx->NewState) - _mesa_update_state( ctx ); - - ib.count = count; - ib.type = type; - ib.obj = ctx->Array.ElementArrayBufferObj; - ib.ptr = indices; - - prim[0].begin = 1; - prim[0].end = 1; - prim[0].weak = 0; - prim[0].pad = 0; - prim[0].mode = mode; - prim[0].start = 0; - prim[0].count = count; - prim[0].indexed = 1; - prim[0].num_instances = numInstances; - - /* Need to give special consideration to rendering a range of - * indices starting somewhere above zero. Typically the - * application is issuing multiple DrawRangeElements() to draw - * successive primitives layed out linearly in the vertex arrays. - * Unless the vertex arrays are all in a VBO (or locked as with - * CVA), the OpenGL semantics imply that we need to re-read or - * re-upload the vertex data on each draw call. - * - * In the case of hardware tnl, we want to avoid starting the - * upload at zero, as it will mean every draw call uploads an - * increasing amount of not-used vertex data. Worse - in the - * software tnl module, all those vertices might be transformed and - * lit but never rendered. - * - * If we just upload or transform the vertices in start..end, - * however, the indices will be incorrect. - * - * At this level, we don't know exactly what the requirements of - * the backend are going to be, though it will likely boil down to - * either: - * - * 1) Do nothing, everything is in a VBO and is processed once - * only. - * - * 2) Adjust the indices and vertex arrays so that start becomes - * zero. - * - * Rather than doing anything here, I'll provide a helper function - * for the latter case elsewhere. - */ - - check_buffers_are_unmapped(exec->array.inputs); - vbo->draw_prims( ctx, exec->array.inputs, prim, 1, &ib, - index_bounds_valid, start, end ); -} - - -/** - * Called by glDrawElements() in immediate mode. - */ -static void GLAPIENTRY -vbo_exec_DrawElements(GLenum mode, GLsizei count, GLenum type, - const GLvoid *indices) -{ - GET_CURRENT_CONTEXT(ctx); - - if (MESA_VERBOSE & VERBOSE_DRAW) - _mesa_debug(ctx, "glDrawElements(%s, %u, %s, %p)\n", - _mesa_lookup_enum_by_nr(mode), count, - _mesa_lookup_enum_by_nr(type), indices); - - if (!_mesa_validate_DrawElements( ctx, mode, count, type, indices)) - return; - - vbo_validated_drawrangeelements(ctx, mode, GL_FALSE, ~0, ~0, - count, type, indices, 1); -} - - -/** - * Plug in the immediate-mode vertex array drawing commands into the - * givven vbo_exec_context object. - */ -void -vbo_exec_array_init( struct vbo_exec_context *exec ) -{ - exec->vtxfmt.DrawArrays = vbo_exec_DrawArrays; - exec->vtxfmt.DrawElements = vbo_exec_DrawElements; -} - - -void -vbo_exec_array_destroy( struct vbo_exec_context *exec ) -{ - /* nothing to do */ -} - - - -/** - * The following functions are only used for OpenGL ES 1/2 support. - * And some aren't even supported (yet) in ES 1/2. - */ - - -void GLAPIENTRY -_mesa_DrawArrays(GLenum mode, GLint first, GLsizei count) -{ - vbo_exec_DrawArrays(mode, first, count); -} - - -void GLAPIENTRY -_mesa_DrawElements(GLenum mode, GLsizei count, GLenum type, - const GLvoid *indices) -{ - vbo_exec_DrawElements(mode, count, type, indices); -} - diff --git a/dll/opengl/mesa/vbo/vbo_exec_draw.c b/dll/opengl/mesa/vbo/vbo_exec_draw.c deleted file mode 100644 index 75f605e97d1..00000000000 --- a/dll/opengl/mesa/vbo/vbo_exec_draw.c +++ /dev/null @@ -1,387 +0,0 @@ -/* - * Mesa 3-D graphics library - * Version: 7.2 - * - * Copyright (C) 1999-2008 Brian Paul All Rights Reserved. - * - * Permission is hereby granted, free of charge, to any person obtaining a - * copy of this software and associated documentation files (the "Software"), - * to deal in the Software without restriction, including without limitation - * the rights to use, copy, modify, merge, publish, distribute, sublicense, - * and/or sell copies of the Software, and to permit persons to whom the - * Software is furnished to do so, subject to the following conditions: - * - * The above copyright notice and this permission notice shall be included - * in all copies or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS - * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL - * BRIAN PAUL BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN - * AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN - * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. - * - * Authors: - * Keith Whitwell - */ - -#include - -#if FEATURE_beginend - - -static void -vbo_exec_debug_verts( struct vbo_exec_context *exec ) -{ - GLuint count = exec->vtx.vert_count; - GLuint i; - - printf("%s: %u vertices %d primitives, %d vertsize\n", - __FUNCTION__, - count, - exec->vtx.prim_count, - exec->vtx.vertex_size); - - for (i = 0 ; i < exec->vtx.prim_count ; i++) { - struct _mesa_prim *prim = &exec->vtx.prim[i]; - printf(" prim %d: %s%s %d..%d %s %s\n", - i, - _mesa_lookup_prim_by_nr(prim->mode), - prim->weak ? " (weak)" : "", - prim->start, - prim->start + prim->count, - prim->begin ? "BEGIN" : "(wrap)", - prim->end ? "END" : "(wrap)"); - } -} - - -/* - * NOTE: Need to have calculated primitives by this point -- do it on the fly. - * NOTE: Old 'parity' issue is gone. - */ -static GLuint -vbo_copy_vertices( struct vbo_exec_context *exec ) -{ - GLuint nr = exec->vtx.prim[exec->vtx.prim_count-1].count; - GLuint ovf, i; - GLuint sz = exec->vtx.vertex_size; - GLfloat *dst = exec->vtx.copied.buffer; - const GLfloat *src = (exec->vtx.buffer_map + - exec->vtx.prim[exec->vtx.prim_count-1].start * - exec->vtx.vertex_size); - - - switch (exec->ctx->Driver.CurrentExecPrimitive) { - case GL_POINTS: - return 0; - case GL_LINES: - ovf = nr&1; - for (i = 0 ; i < ovf ; i++) - memcpy( dst+i*sz, src+(nr-ovf+i)*sz, sz * sizeof(GLfloat) ); - return i; - case GL_TRIANGLES: - ovf = nr%3; - for (i = 0 ; i < ovf ; i++) - memcpy( dst+i*sz, src+(nr-ovf+i)*sz, sz * sizeof(GLfloat) ); - return i; - case GL_QUADS: - ovf = nr&3; - for (i = 0 ; i < ovf ; i++) - memcpy( dst+i*sz, src+(nr-ovf+i)*sz, sz * sizeof(GLfloat) ); - return i; - case GL_LINE_STRIP: - if (nr == 0) { - return 0; - } - else { - memcpy( dst, src+(nr-1)*sz, sz * sizeof(GLfloat) ); - return 1; - } - case GL_LINE_LOOP: - case GL_TRIANGLE_FAN: - case GL_POLYGON: - if (nr == 0) { - return 0; - } - else if (nr == 1) { - memcpy( dst, src+0, sz * sizeof(GLfloat) ); - return 1; - } - else { - memcpy( dst, src+0, sz * sizeof(GLfloat) ); - memcpy( dst+sz, src+(nr-1)*sz, sz * sizeof(GLfloat) ); - return 2; - } - case GL_TRIANGLE_STRIP: - /* no parity issue, but need to make sure the tri is not drawn twice */ - if (nr & 1) { - exec->vtx.prim[exec->vtx.prim_count-1].count--; - } - /* fallthrough */ - case GL_QUAD_STRIP: - switch (nr) { - case 0: - ovf = 0; - break; - case 1: - ovf = 1; - break; - default: - ovf = 2 + (nr & 1); - break; - } - for (i = 0 ; i < ovf ; i++) - memcpy( dst+i*sz, src+(nr-ovf+i)*sz, sz * sizeof(GLfloat) ); - return i; - case PRIM_OUTSIDE_BEGIN_END: - return 0; - default: - assert(0); - return 0; - } -} - - - -/* TODO: populate these as the vertex is defined: - */ -static void -vbo_exec_bind_arrays( struct gl_context *ctx ) -{ - struct vbo_context *vbo = vbo_context(ctx); - struct vbo_exec_context *exec = &vbo->exec; - struct gl_client_array *arrays = exec->vtx.arrays; - const GLuint count = exec->vtx.vert_count; - GLuint attr; - GLbitfield64 varying_inputs = 0x0; - - /* Install the default (ie Current) attributes first, then overlay - * all active ones. - */ - for (attr = 0; attr < VBO_ATTRIB_MAX; attr++) { - exec->vtx.inputs[attr] = &vbo->legacy_currval[attr]; - } - - /* Make all active attributes (including edgeflag) available as - * arrays of floats. - */ - for (attr = 0; attr < VBO_ATTRIB_MAX ; attr++) { - - if (exec->vtx.attrsz[attr]) { - GLsizeiptr offset = (GLbyte *)exec->vtx.attrptr[attr] - - (GLbyte *)exec->vtx.vertex; - - /* override the default array set above */ - ASSERT(attr < Elements(exec->vtx.inputs)); - ASSERT(attr < Elements(exec->vtx.arrays)); /* arrays[] */ - exec->vtx.inputs[attr] = &arrays[attr]; - - if (_mesa_is_bufferobj(exec->vtx.bufferobj)) { - /* a real buffer obj: Ptr is an offset, not a pointer*/ - assert(exec->vtx.bufferobj->Pointer); /* buf should be mapped */ - assert(offset >= 0); - arrays[attr].Ptr = (GLubyte *)exec->vtx.bufferobj->Offset + offset; - } - else { - /* Ptr into ordinary app memory */ - arrays[attr].Ptr = (GLubyte *)exec->vtx.buffer_map + offset; - } - arrays[attr].Size = exec->vtx.attrsz[attr]; - arrays[attr].StrideB = exec->vtx.vertex_size * sizeof(GLfloat); - arrays[attr].Stride = exec->vtx.vertex_size * sizeof(GLfloat); - arrays[attr].Type = GL_FLOAT; - arrays[attr].Enabled = 1; - arrays[attr]._ElementSize = arrays[attr].Size * sizeof(GLfloat); - _mesa_reference_buffer_object(ctx, - &arrays[attr].BufferObj, - exec->vtx.bufferobj); - arrays[attr]._MaxElement = count; /* ??? */ - - varying_inputs |= VERT_BIT(attr); - ctx->NewState |= _NEW_ARRAY; - } - } -} - - -/** - * Unmap the VBO. This is called before drawing. - */ -static void -vbo_exec_vtx_unmap( struct vbo_exec_context *exec ) -{ - if (_mesa_is_bufferobj(exec->vtx.bufferobj)) { - struct gl_context *ctx = exec->ctx; - - if (ctx->Driver.FlushMappedBufferRange) { - GLintptr offset = exec->vtx.buffer_used - exec->vtx.bufferobj->Offset; - GLsizeiptr length = (exec->vtx.buffer_ptr - exec->vtx.buffer_map) * sizeof(float); - - if (length) - ctx->Driver.FlushMappedBufferRange(ctx, offset, length, - exec->vtx.bufferobj); - } - - exec->vtx.buffer_used += (exec->vtx.buffer_ptr - - exec->vtx.buffer_map) * sizeof(float); - - assert(exec->vtx.buffer_used <= VBO_VERT_BUFFER_SIZE); - assert(exec->vtx.buffer_ptr != NULL); - - ctx->Driver.UnmapBuffer(ctx, exec->vtx.bufferobj); - exec->vtx.buffer_map = NULL; - exec->vtx.buffer_ptr = NULL; - exec->vtx.max_vert = 0; - } -} - - -/** - * Map the vertex buffer to begin storing glVertex, glColor, etc data. - */ -void -vbo_exec_vtx_map( struct vbo_exec_context *exec ) -{ - struct gl_context *ctx = exec->ctx; - const GLenum accessRange = GL_MAP_WRITE_BIT | /* for MapBufferRange */ - GL_MAP_INVALIDATE_RANGE_BIT | - GL_MAP_UNSYNCHRONIZED_BIT | - GL_MAP_FLUSH_EXPLICIT_BIT | - MESA_MAP_NOWAIT_BIT; - const GLenum usage = GL_STREAM_DRAW_ARB; - - if (!_mesa_is_bufferobj(exec->vtx.bufferobj)) - return; - - assert(!exec->vtx.buffer_map); - assert(!exec->vtx.buffer_ptr); - - if (VBO_VERT_BUFFER_SIZE > exec->vtx.buffer_used + 1024) { - /* The VBO exists and there's room for more */ - if (exec->vtx.bufferobj->Size > 0) { - exec->vtx.buffer_map = - (GLfloat *)ctx->Driver.MapBufferRange(ctx, - exec->vtx.buffer_used, - (VBO_VERT_BUFFER_SIZE - - exec->vtx.buffer_used), - accessRange, - exec->vtx.bufferobj); - exec->vtx.buffer_ptr = exec->vtx.buffer_map; - } - else { - exec->vtx.buffer_ptr = exec->vtx.buffer_map = NULL; - } - } - - if (!exec->vtx.buffer_map) { - /* Need to allocate a new VBO */ - exec->vtx.buffer_used = 0; - - if (ctx->Driver.BufferData(ctx, GL_ARRAY_BUFFER_ARB, - VBO_VERT_BUFFER_SIZE, - NULL, usage, exec->vtx.bufferobj)) { - /* buffer allocation worked, now map the buffer */ - exec->vtx.buffer_map = - (GLfloat *)ctx->Driver.MapBufferRange(ctx, - 0, VBO_VERT_BUFFER_SIZE, - accessRange, - exec->vtx.bufferobj); - } - else { - _mesa_error(ctx, GL_OUT_OF_MEMORY, "VBO allocation"); - exec->vtx.buffer_map = NULL; - } - } - - exec->vtx.buffer_ptr = exec->vtx.buffer_map; - - if (!exec->vtx.buffer_map) { - /* out of memory */ - _mesa_install_exec_vtxfmt( ctx, &exec->vtxfmt_noop ); - } - else { - if (_mesa_using_noop_vtxfmt(ctx->Exec)) { - /* The no-op functions are installed so switch back to regular - * functions. We do this test just to avoid frequent and needless - * calls to _mesa_install_exec_vtxfmt(). - */ - _mesa_install_exec_vtxfmt(ctx, &exec->vtxfmt); - } - } - - if (0) - printf("map %d..\n", exec->vtx.buffer_used); -} - - - -/** - * Execute the buffer and save copied verts. - * \param keep_unmapped if true, leave the VBO unmapped when we're done. - */ -void -vbo_exec_vtx_flush(struct vbo_exec_context *exec, GLboolean keepUnmapped) -{ - if (0) - vbo_exec_debug_verts( exec ); - - if (exec->vtx.prim_count && - exec->vtx.vert_count) { - - exec->vtx.copied.nr = vbo_copy_vertices( exec ); - - if (exec->vtx.copied.nr != exec->vtx.vert_count) { - struct gl_context *ctx = exec->ctx; - - vbo_exec_bind_arrays( ctx ); - - if (ctx->NewState) - _mesa_update_state( ctx ); - - if (_mesa_is_bufferobj(exec->vtx.bufferobj)) { - vbo_exec_vtx_unmap( exec ); - } - - if (0) - printf("%s %d %d\n", __FUNCTION__, exec->vtx.prim_count, - exec->vtx.vert_count); - - vbo_context(ctx)->draw_prims( ctx, - exec->vtx.inputs, - exec->vtx.prim, - exec->vtx.prim_count, - NULL, - GL_TRUE, - 0, - exec->vtx.vert_count - 1); - - /* If using a real VBO, get new storage -- unless asked not to. - */ - if (_mesa_is_bufferobj(exec->vtx.bufferobj) && !keepUnmapped) { - vbo_exec_vtx_map( exec ); - } - } - } - - /* May have to unmap explicitly if we didn't draw: - */ - if (keepUnmapped && - _mesa_is_bufferobj(exec->vtx.bufferobj) && - exec->vtx.buffer_map) { - vbo_exec_vtx_unmap( exec ); - } - - if (keepUnmapped || exec->vtx.vertex_size == 0) - exec->vtx.max_vert = 0; - else - exec->vtx.max_vert = ((VBO_VERT_BUFFER_SIZE - exec->vtx.buffer_used) / - (exec->vtx.vertex_size * sizeof(GLfloat))); - - exec->vtx.buffer_ptr = exec->vtx.buffer_map; - exec->vtx.prim_count = 0; - exec->vtx.vert_count = 0; -} - - -#endif /* FEATURE_beginend */ diff --git a/dll/opengl/mesa/vbo/vbo_exec_eval.c b/dll/opengl/mesa/vbo/vbo_exec_eval.c deleted file mode 100644 index 0c0aa386c60..00000000000 --- a/dll/opengl/mesa/vbo/vbo_exec_eval.c +++ /dev/null @@ -1,240 +0,0 @@ -/* - * Mesa 3-D graphics library - * Version: 6.1 - * - * Copyright (C) 1999-2004 Brian Paul All Rights Reserved. - * - * Permission is hereby granted, free of charge, to any person obtaining a - * copy of this software and associated documentation files (the "Software"), - * to deal in the Software without restriction, including without limitation - * the rights to use, copy, modify, merge, publish, distribute, sublicense, - * and/or sell copies of the Software, and to permit persons to whom the - * Software is furnished to do so, subject to the following conditions: - * - * The above copyright notice and this permission notice shall be included - * in all copies or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS - * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL - * BRIAN PAUL BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN - * AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN - * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. - * - * Authors: - * Keith Whitwell - */ - -#include - -static void clear_active_eval1( struct vbo_exec_context *exec, GLuint attr ) -{ - assert(attr < Elements(exec->eval.map1)); - exec->eval.map1[attr].map = NULL; -} - -static void clear_active_eval2( struct vbo_exec_context *exec, GLuint attr ) -{ - assert(attr < Elements(exec->eval.map2)); - exec->eval.map2[attr].map = NULL; -} - -static void set_active_eval1( struct vbo_exec_context *exec, GLuint attr, GLuint dim, - struct gl_1d_map *map ) -{ - assert(attr < Elements(exec->eval.map1)); - if (!exec->eval.map1[attr].map) { - exec->eval.map1[attr].map = map; - exec->eval.map1[attr].sz = dim; - } -} - -static void set_active_eval2( struct vbo_exec_context *exec, GLuint attr, GLuint dim, - struct gl_2d_map *map ) -{ - assert(attr < Elements(exec->eval.map2)); - if (!exec->eval.map2[attr].map) { - exec->eval.map2[attr].map = map; - exec->eval.map2[attr].sz = dim; - } -} - -void vbo_exec_eval_update( struct vbo_exec_context *exec ) -{ - struct gl_context *ctx = exec->ctx; - GLuint attr; - - /* Vertex program maps have priority over conventional attribs */ - - for (attr = 0; attr < VBO_ATTRIB_FIRST_MATERIAL; attr++) { - clear_active_eval1( exec, attr ); - clear_active_eval2( exec, attr ); - } - - if (ctx->Eval.Map1Color4) - set_active_eval1( exec, VBO_ATTRIB_COLOR, 4, &ctx->EvalMap.Map1Color4 ); - - if (ctx->Eval.Map2Color4) - set_active_eval2( exec, VBO_ATTRIB_COLOR, 4, &ctx->EvalMap.Map2Color4 ); - - if (ctx->Eval.Map1TextureCoord4) - set_active_eval1( exec, VBO_ATTRIB_TEX, 4, &ctx->EvalMap.Map1Texture4 ); - else if (ctx->Eval.Map1TextureCoord3) - set_active_eval1( exec, VBO_ATTRIB_TEX, 3, &ctx->EvalMap.Map1Texture3 ); - else if (ctx->Eval.Map1TextureCoord2) - set_active_eval1( exec, VBO_ATTRIB_TEX, 2, &ctx->EvalMap.Map1Texture2 ); - else if (ctx->Eval.Map1TextureCoord1) - set_active_eval1( exec, VBO_ATTRIB_TEX, 1, &ctx->EvalMap.Map1Texture1 ); - - if (ctx->Eval.Map2TextureCoord4) - set_active_eval2( exec, VBO_ATTRIB_TEX, 4, &ctx->EvalMap.Map2Texture4 ); - else if (ctx->Eval.Map2TextureCoord3) - set_active_eval2( exec, VBO_ATTRIB_TEX, 3, &ctx->EvalMap.Map2Texture3 ); - else if (ctx->Eval.Map2TextureCoord2) - set_active_eval2( exec, VBO_ATTRIB_TEX, 2, &ctx->EvalMap.Map2Texture2 ); - else if (ctx->Eval.Map2TextureCoord1) - set_active_eval2( exec, VBO_ATTRIB_TEX, 1, &ctx->EvalMap.Map2Texture1 ); - - if (ctx->Eval.Map1Normal) - set_active_eval1( exec, VBO_ATTRIB_NORMAL, 3, &ctx->EvalMap.Map1Normal ); - - if (ctx->Eval.Map2Normal) - set_active_eval2( exec, VBO_ATTRIB_NORMAL, 3, &ctx->EvalMap.Map2Normal ); - - if (ctx->Eval.Map1Vertex4) - set_active_eval1( exec, VBO_ATTRIB_POS, 4, &ctx->EvalMap.Map1Vertex4 ); - else if (ctx->Eval.Map1Vertex3) - set_active_eval1( exec, VBO_ATTRIB_POS, 3, &ctx->EvalMap.Map1Vertex3 ); - - if (ctx->Eval.Map2Vertex4) - set_active_eval2( exec, VBO_ATTRIB_POS, 4, &ctx->EvalMap.Map2Vertex4 ); - else if (ctx->Eval.Map2Vertex3) - set_active_eval2( exec, VBO_ATTRIB_POS, 3, &ctx->EvalMap.Map2Vertex3 ); - - exec->eval.recalculate_maps = 0; -} - - - -void vbo_exec_do_EvalCoord1f(struct vbo_exec_context *exec, GLfloat u) -{ - GLuint attr; - - for (attr = 1; attr <= VBO_ATTRIB_TEX; attr++) { - struct gl_1d_map *map = exec->eval.map1[attr].map; - if (map) { - GLfloat uu = (u - map->u1) * map->du; - GLfloat data[4]; - - ASSIGN_4V(data, 0, 0, 0, 1); - - _math_horner_bezier_curve(map->Points, data, uu, - exec->eval.map1[attr].sz, - map->Order); - - COPY_SZ_4V( exec->vtx.attrptr[attr], - exec->vtx.attrsz[attr], - data ); - } - } - - /** Vertex -- EvalCoord1f is a noop if this map not enabled: - **/ - if (exec->eval.map1[0].map) { - struct gl_1d_map *map = exec->eval.map1[0].map; - GLfloat uu = (u - map->u1) * map->du; - GLfloat vertex[4]; - - ASSIGN_4V(vertex, 0, 0, 0, 1); - - _math_horner_bezier_curve(map->Points, vertex, uu, - exec->eval.map1[0].sz, - map->Order); - - if (exec->eval.map1[0].sz == 4) - CALL_Vertex4fv(GET_DISPATCH(), ( vertex )); - else - CALL_Vertex3fv(GET_DISPATCH(), ( vertex )); - } -} - - - -void vbo_exec_do_EvalCoord2f( struct vbo_exec_context *exec, - GLfloat u, GLfloat v ) -{ - GLuint attr; - - for (attr = 1; attr <= VBO_ATTRIB_TEX; attr++) { - struct gl_2d_map *map = exec->eval.map2[attr].map; - if (map) { - GLfloat uu = (u - map->u1) * map->du; - GLfloat vv = (v - map->v1) * map->dv; - GLfloat data[4]; - - ASSIGN_4V(data, 0, 0, 0, 1); - - _math_horner_bezier_surf(map->Points, - data, - uu, vv, - exec->eval.map2[attr].sz, - map->Uorder, map->Vorder); - - COPY_SZ_4V( exec->vtx.attrptr[attr], - exec->vtx.attrsz[attr], - data ); - } - } - - /** Vertex -- EvalCoord2f is a noop if this map not enabled: - **/ - if (exec->eval.map2[0].map) { - struct gl_2d_map *map = exec->eval.map2[0].map; - GLfloat uu = (u - map->u1) * map->du; - GLfloat vv = (v - map->v1) * map->dv; - GLfloat vertex[4]; - - ASSIGN_4V(vertex, 0, 0, 0, 1); - - if (exec->ctx->Eval.AutoNormal) { - GLfloat normal[4]; - GLfloat du[4], dv[4]; - - _math_de_casteljau_surf(map->Points, vertex, du, dv, uu, vv, - exec->eval.map2[0].sz, - map->Uorder, map->Vorder); - - if (exec->eval.map2[0].sz == 4) { - du[0] = du[0]*vertex[3] - du[3]*vertex[0]; - du[1] = du[1]*vertex[3] - du[3]*vertex[1]; - du[2] = du[2]*vertex[3] - du[3]*vertex[2]; - - dv[0] = dv[0]*vertex[3] - dv[3]*vertex[0]; - dv[1] = dv[1]*vertex[3] - dv[3]*vertex[1]; - dv[2] = dv[2]*vertex[3] - dv[3]*vertex[2]; - } - - - CROSS3(normal, du, dv); - NORMALIZE_3FV(normal); - normal[3] = 1.0; - - COPY_SZ_4V( exec->vtx.attrptr[VBO_ATTRIB_NORMAL], - exec->vtx.attrsz[VBO_ATTRIB_NORMAL], - normal ); - - } - else { - _math_horner_bezier_surf(map->Points, vertex, uu, vv, - exec->eval.map2[0].sz, - map->Uorder, map->Vorder); - } - - if (exec->vtx.attrsz[0] == 4) - CALL_Vertex4fv(GET_DISPATCH(), ( vertex )); - else - CALL_Vertex3fv(GET_DISPATCH(), ( vertex )); - } -} - - diff --git a/dll/opengl/mesa/vbo/vbo_noop.c b/dll/opengl/mesa/vbo/vbo_noop.c deleted file mode 100644 index dffed25676d..00000000000 --- a/dll/opengl/mesa/vbo/vbo_noop.c +++ /dev/null @@ -1,349 +0,0 @@ -/* - * Mesa 3-D graphics library - * - * Copyright (C) 1999-2006 Brian Paul All Rights Reserved. - * Copyright (C) 2011 VMware, Inc. All Rights Reserved. - * - * Permission is hereby granted, free of charge, to any person obtaining a - * copy of this software and associated documentation files (the "Software"), - * to deal in the Software without restriction, including without limitation - * the rights to use, copy, modify, merge, publish, distribute, sublicense, - * and/or sell copies of the Software, and to permit persons to whom the - * Software is furnished to do so, subject to the following conditions: - * - * The above copyright notice and this permission notice shall be included - * in all copies or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS - * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL - * THE AUTHORS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN - * AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN - * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. - */ - - -/** - * GLvertexformat no-op functions. Used in out-of-memory situations. - */ - -#include - -#if FEATURE_beginend - - -static void GLAPIENTRY -_mesa_noop_EdgeFlag(GLboolean b) -{ -} - -static void GLAPIENTRY -_mesa_noop_Indexf(GLfloat f) -{ -} - -static void GLAPIENTRY -_mesa_noop_Indexfv(const GLfloat * v) -{ -} - -static void GLAPIENTRY -_mesa_noop_FogCoordfEXT(GLfloat a) -{ -} - -static void GLAPIENTRY -_mesa_noop_FogCoordfvEXT(const GLfloat * v) -{ -} - -static void GLAPIENTRY -_mesa_noop_Normal3f(GLfloat a, GLfloat b, GLfloat c) -{ -} - -static void GLAPIENTRY -_mesa_noop_Normal3fv(const GLfloat * v) -{ -} - -static void GLAPIENTRY -_mesa_noop_Color4f(GLfloat a, GLfloat b, GLfloat c, GLfloat d) -{ -} - -static void GLAPIENTRY -_mesa_noop_Color4fv(const GLfloat * v) -{ -} - -static void GLAPIENTRY -_mesa_noop_Color3f(GLfloat a, GLfloat b, GLfloat c) -{ -} - -static void GLAPIENTRY -_mesa_noop_Color3fv(const GLfloat * v) -{ -} - -static void GLAPIENTRY -_mesa_noop_TexCoord1f(GLfloat a) -{ -} - -static void GLAPIENTRY -_mesa_noop_TexCoord1fv(const GLfloat * v) -{ -} - -static void GLAPIENTRY -_mesa_noop_TexCoord2f(GLfloat a, GLfloat b) -{ -} - -static void GLAPIENTRY -_mesa_noop_TexCoord2fv(const GLfloat * v) -{ -} - -static void GLAPIENTRY -_mesa_noop_TexCoord3f(GLfloat a, GLfloat b, GLfloat c) -{ -} - -static void GLAPIENTRY -_mesa_noop_TexCoord3fv(const GLfloat * v) -{ -} - -static void GLAPIENTRY -_mesa_noop_TexCoord4f(GLfloat a, GLfloat b, GLfloat c, GLfloat d) -{ -} - -static void GLAPIENTRY -_mesa_noop_TexCoord4fv(const GLfloat * v) -{ -} - -static void GLAPIENTRY -_mesa_noop_VertexAttrib1fNV(GLuint index, GLfloat x) -{ -} - -static void GLAPIENTRY -_mesa_noop_VertexAttrib1fvNV(GLuint index, const GLfloat * v) -{ -} - -static void GLAPIENTRY -_mesa_noop_VertexAttrib2fNV(GLuint index, GLfloat x, GLfloat y) -{ -} - -static void GLAPIENTRY -_mesa_noop_VertexAttrib2fvNV(GLuint index, const GLfloat * v) -{ -} - -static void GLAPIENTRY -_mesa_noop_VertexAttrib3fNV(GLuint index, GLfloat x, GLfloat y, GLfloat z) -{ -} - -static void GLAPIENTRY -_mesa_noop_VertexAttrib3fvNV(GLuint index, const GLfloat * v) -{ -} - -static void GLAPIENTRY -_mesa_noop_VertexAttrib4fNV(GLuint index, GLfloat x, - GLfloat y, GLfloat z, GLfloat w) -{ -} - -static void GLAPIENTRY -_mesa_noop_VertexAttrib4fvNV(GLuint index, const GLfloat * v) -{ -} - -static void GLAPIENTRY -_mesa_noop_Materialfv(GLenum face, GLenum pname, const GLfloat * params) -{ -} - -static void GLAPIENTRY -_mesa_noop_Vertex2fv(const GLfloat * v) -{ -} - -static void GLAPIENTRY -_mesa_noop_Vertex3fv(const GLfloat * v) -{ -} - -static void GLAPIENTRY -_mesa_noop_Vertex4fv(const GLfloat * v) -{ -} - -static void GLAPIENTRY -_mesa_noop_Vertex2f(GLfloat a, GLfloat b) -{ -} - -static void GLAPIENTRY -_mesa_noop_Vertex3f(GLfloat a, GLfloat b, GLfloat c) -{ -} - -static void GLAPIENTRY -_mesa_noop_Vertex4f(GLfloat a, GLfloat b, GLfloat c, GLfloat d) -{ -} - - -#if FEATURE_evaluators -static void GLAPIENTRY -_mesa_noop_EvalCoord1f(GLfloat a) -{ -} - -static void GLAPIENTRY -_mesa_noop_EvalCoord1fv(const GLfloat * v) -{ -} - -static void GLAPIENTRY -_mesa_noop_EvalCoord2f(GLfloat a, GLfloat b) -{ -} - -static void GLAPIENTRY -_mesa_noop_EvalCoord2fv(const GLfloat * v) -{ -} - -static void GLAPIENTRY -_mesa_noop_EvalPoint1(GLint a) -{ -} - -static void GLAPIENTRY -_mesa_noop_EvalPoint2(GLint a, GLint b) -{ -} -#endif /* FEATURE_evaluators */ - - -static void GLAPIENTRY -_mesa_noop_Begin(GLenum mode) -{ -} - -static void GLAPIENTRY -_mesa_noop_End(void) -{ -} - - -static void GLAPIENTRY -_mesa_noop_Rectf(GLfloat x1, GLfloat y1, GLfloat x2, GLfloat y2) -{ -} - - -static void GLAPIENTRY -_mesa_noop_DrawArrays(GLenum mode, GLint start, GLsizei count) -{ -} - -static void GLAPIENTRY -_mesa_noop_DrawElements(GLenum mode, GLsizei count, GLenum type, - const GLvoid * indices) -{ -} - -static void GLAPIENTRY -_mesa_noop_EvalMesh1(GLenum mode, GLint i1, GLint i2) -{ -} - -static void GLAPIENTRY -_mesa_noop_EvalMesh2(GLenum mode, GLint i1, GLint i2, GLint j1, GLint j2) -{ -} - - -/** - * Build a vertexformat of functions that are no-ops. - * These are used in out-of-memory situations when we have no VBO - * to put the vertex data into. - */ -void -_mesa_noop_vtxfmt_init(GLvertexformat * vfmt) -{ - _MESA_INIT_ARRAYELT_VTXFMT(vfmt, _ae_); - - vfmt->Begin = _mesa_noop_Begin; - - _MESA_INIT_DLIST_VTXFMT(vfmt, _mesa_); - - vfmt->Color3f = _mesa_noop_Color3f; - vfmt->Color3fv = _mesa_noop_Color3fv; - vfmt->Color4f = _mesa_noop_Color4f; - vfmt->Color4fv = _mesa_noop_Color4fv; - vfmt->EdgeFlag = _mesa_noop_EdgeFlag; - vfmt->End = _mesa_noop_End; - - _MESA_INIT_EVAL_VTXFMT(vfmt, _mesa_noop_); - - vfmt->FogCoordfEXT = _mesa_noop_FogCoordfEXT; - vfmt->FogCoordfvEXT = _mesa_noop_FogCoordfvEXT; - vfmt->Indexf = _mesa_noop_Indexf; - vfmt->Indexfv = _mesa_noop_Indexfv; - vfmt->Materialfv = _mesa_noop_Materialfv; - vfmt->Normal3f = _mesa_noop_Normal3f; - vfmt->Normal3fv = _mesa_noop_Normal3fv; - vfmt->TexCoord1f = _mesa_noop_TexCoord1f; - vfmt->TexCoord1fv = _mesa_noop_TexCoord1fv; - vfmt->TexCoord2f = _mesa_noop_TexCoord2f; - vfmt->TexCoord2fv = _mesa_noop_TexCoord2fv; - vfmt->TexCoord3f = _mesa_noop_TexCoord3f; - vfmt->TexCoord3fv = _mesa_noop_TexCoord3fv; - vfmt->TexCoord4f = _mesa_noop_TexCoord4f; - vfmt->TexCoord4fv = _mesa_noop_TexCoord4fv; - vfmt->Vertex2f = _mesa_noop_Vertex2f; - vfmt->Vertex2fv = _mesa_noop_Vertex2fv; - vfmt->Vertex3f = _mesa_noop_Vertex3f; - vfmt->Vertex3fv = _mesa_noop_Vertex3fv; - vfmt->Vertex4f = _mesa_noop_Vertex4f; - vfmt->Vertex4fv = _mesa_noop_Vertex4fv; - vfmt->VertexAttrib1fNV = _mesa_noop_VertexAttrib1fNV; - vfmt->VertexAttrib1fvNV = _mesa_noop_VertexAttrib1fvNV; - vfmt->VertexAttrib2fNV = _mesa_noop_VertexAttrib2fNV; - vfmt->VertexAttrib2fvNV = _mesa_noop_VertexAttrib2fvNV; - vfmt->VertexAttrib3fNV = _mesa_noop_VertexAttrib3fNV; - vfmt->VertexAttrib3fvNV = _mesa_noop_VertexAttrib3fvNV; - vfmt->VertexAttrib4fNV = _mesa_noop_VertexAttrib4fNV; - vfmt->VertexAttrib4fvNV = _mesa_noop_VertexAttrib4fvNV; - - vfmt->Rectf = _mesa_noop_Rectf; - - vfmt->DrawArrays = _mesa_noop_DrawArrays; - vfmt->DrawElements = _mesa_noop_DrawElements; -} - - -/** - * Is the given dispatch table using the no-op functions? - */ -GLboolean -_mesa_using_noop_vtxfmt(const struct _glapi_table *dispatch) -{ - return GET_Begin((struct _glapi_table *) dispatch) == _mesa_noop_Begin; -} - - -#endif /* FEATURE_beginend */ diff --git a/dll/opengl/mesa/vbo/vbo_noop.h b/dll/opengl/mesa/vbo/vbo_noop.h deleted file mode 100644 index 92f61d356e3..00000000000 --- a/dll/opengl/mesa/vbo/vbo_noop.h +++ /dev/null @@ -1,51 +0,0 @@ -/* - * Mesa 3-D graphics library - * - * Copyright (C) 1999-2006 Brian Paul All Rights Reserved. - * Copyright (C) 2011 VMware, Inc. All Rights Reserved. - * - * Permission is hereby granted, free of charge, to any person obtaining a - * copy of this software and associated documentation files (the "Software"), - * to deal in the Software without restriction, including without limitation - * the rights to use, copy, modify, merge, publish, distribute, sublicense, - * and/or sell copies of the Software, and to permit persons to whom the - * Software is furnished to do so, subject to the following conditions: - * - * The above copyright notice and this permission notice shall be included - * in all copies or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS - * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL - * THE AUTHORS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN - * AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN - * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. - */ - -#ifndef _API_NOOP_H -#define _API_NOOP_H - - -#include "main/mfeatures.h" -#include "main/mtypes.h" - - -#if FEATURE_beginend - -extern void -_mesa_noop_vtxfmt_init(GLvertexformat *vfmt); - -extern GLboolean -_mesa_using_noop_vtxfmt(const struct _glapi_table *dispatch); - -#else - -static inline void -_mesa_noop_vtxfmt_init(GLvertexformat *vfmt) -{ -} - -#endif /* FEATURE_beginend */ - - -#endif /* _API_NOOP_H */ diff --git a/dll/opengl/mesa/vbo/vbo_rebase.c b/dll/opengl/mesa/vbo/vbo_rebase.c deleted file mode 100644 index 5bc27c515a8..00000000000 --- a/dll/opengl/mesa/vbo/vbo_rebase.c +++ /dev/null @@ -1,203 +0,0 @@ - -/* - * Mesa 3-D graphics library - * Version: 6.5 - * - * Copyright (C) 1999-2006 Brian Paul All Rights Reserved. - * - * Permission is hereby granted, free of charge, to any person obtaining a - * copy of this software and associated documentation files (the "Software"), - * to deal in the Software without restriction, including without limitation - * the rights to use, copy, modify, merge, publish, distribute, sublicense, - * and/or sell copies of the Software, and to permit persons to whom the - * Software is furnished to do so, subject to the following conditions: - * - * The above copyright notice and this permission notice shall be included - * in all copies or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS - * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL - * BRIAN PAUL BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN - * AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN - * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. - * - * Authors: - * Keith Whitwell - */ - -/* Helper for drivers which find themselves rendering a range of - * indices starting somewhere above zero. Typically the application - * is issuing multiple DrawArrays() or DrawElements() to draw - * successive primitives layed out linearly in the vertex arrays. - * Unless the vertex arrays are all in a VBO, the OpenGL semantics - * imply that we need to re-upload the vertex data on each draw call. - * In that case, we want to avoid starting the upload at zero, as it - * will mean every draw call uploads an increasing amount of not-used - * vertex data. Worse - in the software tnl module, all those - * vertices will be transformed and lit. - * - * If we just upload the new data, however, the indices will be - * incorrect as we tend to upload each set of vertex data to a new - * region. - * - * This file provides a helper to adjust the arrays, primitives and - * indices of a draw call so that it can be re-issued with a min_index - * of zero. - */ - -#include - -#define REBASE(TYPE) \ -static void *rebase_##TYPE( const void *ptr, \ - GLuint count, \ - TYPE min_index ) \ -{ \ - const TYPE *in = (TYPE *)ptr; \ - TYPE *tmp_indices = malloc(count * sizeof(TYPE)); \ - GLuint i; \ - \ - for (i = 0; i < count; i++) \ - tmp_indices[i] = in[i] - min_index; \ - \ - return (void *)tmp_indices; \ -} - - -REBASE(GLuint) -REBASE(GLushort) -REBASE(GLubyte) - -/* Adjust primitives, indices and vertex definitions so that min_index - * becomes zero. There are lots of reasons for wanting to do this, eg: - * - * Software tnl: - * - any time min_index != 0, otherwise unused vertices lower than - * min_index will be transformed. - * - * Hardware tnl: - * - if ib != NULL and min_index != 0, otherwise vertices lower than - * min_index will be uploaded. Requires adjusting index values. - * - * - if ib == NULL and min_index != 0, just for convenience so this doesn't - * have to be handled within the driver. - * - * Hardware tnl with VBO support: - * - as above, but only when vertices are not (all?) in VBO's. - * - can't save time by trying to upload half a vbo - typically it is - * all or nothing. - */ -void vbo_rebase_prims( struct gl_context *ctx, - const struct gl_client_array *arrays[], - const struct _mesa_prim *prim, - GLuint nr_prims, - const struct _mesa_index_buffer *ib, - GLuint min_index, - GLuint max_index, - vbo_draw_func draw ) -{ - struct gl_client_array tmp_arrays[VBO_ATTRIB_MAX]; - const struct gl_client_array *tmp_array_pointers[VBO_ATTRIB_MAX]; - - struct _mesa_index_buffer tmp_ib; - struct _mesa_prim *tmp_prims = NULL; - void *tmp_indices = NULL; - GLuint i; - - assert(min_index != 0); - - if (0) - printf("%s %d..%d\n", __FUNCTION__, min_index, max_index); - - - if (ib) { - /* Unfortunately need to adjust each index individually. - */ - GLboolean map_ib = ib->obj->Name && !ib->obj->Pointer; - void *ptr; - - if (map_ib) - ctx->Driver.MapBufferRange(ctx, 0, ib->obj->Size, GL_MAP_READ_BIT, - ib->obj); - - - ptr = ADD_POINTERS(ib->obj->Pointer, ib->ptr); - - /* Some users might prefer it if we translated elements to - * GLuints here. Others wouldn't... - */ - switch (ib->type) { - case GL_UNSIGNED_INT: - tmp_indices = rebase_GLuint( ptr, ib->count, min_index ); - break; - case GL_UNSIGNED_SHORT: - tmp_indices = rebase_GLushort( ptr, ib->count, min_index ); - break; - case GL_UNSIGNED_BYTE: - tmp_indices = rebase_GLubyte( ptr, ib->count, min_index ); - break; - } - - if (map_ib) - ctx->Driver.UnmapBuffer(ctx, ib->obj); - - tmp_ib.obj = ctx->Shared->NullBufferObj; - tmp_ib.ptr = tmp_indices; - tmp_ib.count = ib->count; - tmp_ib.type = ib->type; - - ib = &tmp_ib; - } - else { - /* Otherwise the primitives need adjustment. - */ - tmp_prims = (struct _mesa_prim *)malloc(sizeof(*prim) * nr_prims); - - for (i = 0; i < nr_prims; i++) { - /* If this fails, it could indicate an application error: - */ - assert(prim[i].start >= min_index); - - tmp_prims[i] = prim[i]; - tmp_prims[i].start -= min_index; - } - - prim = tmp_prims; - } - - /* Just need to adjust the pointer values on each incoming array. - * This works for VBO and non-vbo rendering and shouldn't pesimize - * VBO-based upload schemes. However this may still not be a fast - * path for hardware tnl for VBO based rendering as most machines - * will be happier if you just specify a starting vertex value in - * each primitive. - * - * For drivers with hardware tnl, you only want to do this if you - * are forced to, eg non-VBO indexed rendering with start != 0. - */ - for (i = 0; i < VBO_ATTRIB_MAX; i++) { - tmp_arrays[i] = *arrays[i]; - tmp_arrays[i].Ptr += min_index * tmp_arrays[i].StrideB; - tmp_array_pointers[i] = &tmp_arrays[i]; - } - - /* Re-issue the draw call. - */ - draw( ctx, - tmp_array_pointers, - prim, - nr_prims, - ib, - GL_TRUE, - 0, - max_index - min_index); - - if (tmp_indices) - free(tmp_indices); - - if (tmp_prims) - free(tmp_prims); -} - - - diff --git a/dll/opengl/mesa/vbo/vbo_save.c b/dll/opengl/mesa/vbo/vbo_save.c deleted file mode 100644 index 68c84634984..00000000000 --- a/dll/opengl/mesa/vbo/vbo_save.c +++ /dev/null @@ -1,114 +0,0 @@ -/* - * Mesa 3-D graphics library - * Version: 7.2 - * - * Copyright (C) 1999-2008 Brian Paul All Rights Reserved. - * - * Permission is hereby granted, free of charge, to any person obtaining a - * copy of this software and associated documentation files (the "Software"), - * to deal in the Software without restriction, including without limitation - * the rights to use, copy, modify, merge, publish, distribute, sublicense, - * and/or sell copies of the Software, and to permit persons to whom the - * Software is furnished to do so, subject to the following conditions: - * - * The above copyright notice and this permission notice shall be included - * in all copies or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS - * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL - * BRIAN PAUL BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN - * AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN - * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. - * - * Authors: - * Keith Whitwell - */ - -#include - -#if FEATURE_dlist - - -static void vbo_save_callback_init( struct gl_context *ctx ) -{ - ctx->Driver.NewList = vbo_save_NewList; - ctx->Driver.EndList = vbo_save_EndList; - ctx->Driver.SaveFlushVertices = vbo_save_SaveFlushVertices; - ctx->Driver.BeginCallList = vbo_save_BeginCallList; - ctx->Driver.EndCallList = vbo_save_EndCallList; - ctx->Driver.NotifySaveBegin = vbo_save_NotifyBegin; -} - - - -void vbo_save_init( struct gl_context *ctx ) -{ - struct vbo_context *vbo = vbo_context(ctx); - struct vbo_save_context *save = &vbo->save; - - save->ctx = ctx; - - vbo_save_api_init( save ); - vbo_save_callback_init(ctx); - - { - struct gl_client_array *arrays = save->arrays; - unsigned i; - - memcpy(arrays, vbo->currval, - VBO_ATTRIB_MAX * sizeof(arrays[0])); - for (i = 0; i < VBO_ATTRIB_MAX; ++i) { - struct gl_client_array *array; - array = &arrays[i]; - array->BufferObj = NULL; - _mesa_reference_buffer_object(ctx, &arrays->BufferObj, - vbo->currval[i].BufferObj); - } - } - - ctx->Driver.CurrentSavePrimitive = PRIM_UNKNOWN; -} - - -void vbo_save_destroy( struct gl_context *ctx ) -{ - struct vbo_context *vbo = vbo_context(ctx); - struct vbo_save_context *save = &vbo->save; - GLuint i; - - if (save->prim_store) { - if ( --save->prim_store->refcount == 0 ) { - FREE( save->prim_store ); - save->prim_store = NULL; - } - if ( --save->vertex_store->refcount == 0 ) { - _mesa_reference_buffer_object(ctx, - &save->vertex_store->bufferobj, NULL); - FREE( save->vertex_store ); - save->vertex_store = NULL; - } - } - - for (i = 0; i < VBO_ATTRIB_MAX; i++) { - _mesa_reference_buffer_object(ctx, &save->arrays[i].BufferObj, NULL); - } -} - - - - -/* Note that this can occur during the playback of a display list: - */ -void vbo_save_fallback( struct gl_context *ctx, GLboolean fallback ) -{ - struct vbo_save_context *save = &vbo_context(ctx)->save; - - if (fallback) - save->replay_flags |= VBO_SAVE_FALLBACK; - else - save->replay_flags &= ~VBO_SAVE_FALLBACK; -} - - -#endif /* FEATURE_dlist */ diff --git a/dll/opengl/mesa/vbo/vbo_save.h b/dll/opengl/mesa/vbo/vbo_save.h deleted file mode 100644 index 0bba7516d65..00000000000 --- a/dll/opengl/mesa/vbo/vbo_save.h +++ /dev/null @@ -1,204 +0,0 @@ -/************************************************************************** - -Copyright 2002 Tungsten Graphics Inc., Cedar Park, Texas. - -All Rights Reserved. - -Permission is hereby granted, free of charge, to any person obtaining a -copy of this software and associated documentation files (the "Software"), -to deal in the Software without restriction, including without limitation -on the rights to use, copy, modify, merge, publish, distribute, sub -license, and/or sell copies of the Software, and to permit persons to whom -the Software is furnished to do so, subject to the following conditions: - -The above copyright notice and this permission notice (including the next -paragraph) shall be included in all copies or substantial portions of the -Software. - -THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR -IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, -FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT. IN NO EVENT SHALL -TUNGSTEN GRAPHICS AND/OR THEIR SUPPLIERS BE LIABLE FOR ANY CLAIM, -DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR -OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE -USE OR OTHER DEALINGS IN THE SOFTWARE. - -**************************************************************************/ - -/* - * Authors: - * Keith Whitwell - * - */ - -#ifndef VBO_SAVE_H -#define VBO_SAVE_H - -#include "main/mfeatures.h" -#include "main/mtypes.h" -#include "vbo.h" -#include "vbo_attrib.h" - - -struct vbo_save_copied_vtx { - GLfloat buffer[VBO_ATTRIB_MAX * 4 * VBO_MAX_COPIED_VERTS]; - GLuint nr; -}; - - -/* For display lists, this structure holds a run of vertices of the - * same format, and a strictly well-formed set of begin/end pairs, - * starting on the first vertex and ending at the last. Vertex - * copying on buffer breaks is precomputed according to these - * primitives, though there are situations where the copying will need - * correction at execute-time, perhaps by replaying the list as - * immediate mode commands. - * - * On executing this list, the 'current' values may be updated with - * the values of the final vertex, and often no fixup of the start of - * the vertex list is required. - * - * Eval and other commands that don't fit into these vertex lists are - * compiled using the fallback opcode mechanism provided by dlist.c. - */ -struct vbo_save_vertex_list { - GLubyte attrsz[VBO_ATTRIB_MAX]; - GLuint vertex_size; - - /* Copy of the final vertex from node->vertex_store->bufferobj. - * Keep this in regular (non-VBO) memory to avoid repeated - * map/unmap of the VBO when updating GL current data. - */ - GLfloat *current_data; - GLuint current_size; - - GLuint buffer_offset; - GLuint count; /**< vertex count */ - GLuint wrap_count; /* number of copied vertices at start */ - GLboolean dangling_attr_ref; /* current attr implicitly referenced - outside the list */ - - struct _mesa_prim *prim; - GLuint prim_count; - - struct vbo_save_vertex_store *vertex_store; - struct vbo_save_primitive_store *prim_store; -}; - -/* These buffers should be a reasonable size to support upload to - * hardware. Current vbo implementation will re-upload on any - * changes, so don't make too big or apps which dynamically create - * dlists and use only a few times will suffer. - * - * Consider strategy of uploading regions from the VBO on demand in the - * case of dynamic vbos. Then make the dlist code signal that - * likelihood as it occurs. No reason we couldn't change usage - * internally even though this probably isn't allowed for client VBOs? - */ -#define VBO_SAVE_BUFFER_SIZE (8*1024) /* dwords */ -#define VBO_SAVE_PRIM_SIZE 128 -#define VBO_SAVE_PRIM_MODE_MASK 0x3f -#define VBO_SAVE_PRIM_WEAK 0x40 -#define VBO_SAVE_PRIM_NO_CURRENT_UPDATE 0x80 - -#define VBO_SAVE_FALLBACK 0x10000000 - -/* Storage to be shared among several vertex_lists. - */ -struct vbo_save_vertex_store { - struct gl_buffer_object *bufferobj; - GLfloat *buffer; - GLuint used; - GLuint refcount; -}; - -struct vbo_save_primitive_store { - struct _mesa_prim buffer[VBO_SAVE_PRIM_SIZE]; - GLuint used; - GLuint refcount; -}; - - -struct vbo_save_context { - struct gl_context *ctx; - GLvertexformat vtxfmt; - GLvertexformat vtxfmt_noop; /**< Used if out_of_memory is true */ - struct gl_client_array arrays[VBO_ATTRIB_MAX]; - const struct gl_client_array *inputs[VBO_ATTRIB_MAX]; - - GLubyte attrsz[VBO_ATTRIB_MAX]; - GLubyte active_sz[VBO_ATTRIB_MAX]; - GLuint vertex_size; - - GLboolean out_of_memory; /**< True if last VBO allocation failed */ - - GLfloat *buffer; - GLuint count; - GLuint wrap_count; - GLuint replay_flags; - - struct _mesa_prim *prim; - GLuint prim_count, prim_max; - - struct vbo_save_vertex_store *vertex_store; - struct vbo_save_primitive_store *prim_store; - - GLfloat *buffer_ptr; /* cursor, points into buffer */ - GLfloat vertex[VBO_ATTRIB_MAX*4]; /* current values */ - GLfloat *attrptr[VBO_ATTRIB_MAX]; - GLuint vert_count; - GLuint max_vert; - GLboolean dangling_attr_ref; - - GLuint opcode_vertex_list; - - struct vbo_save_copied_vtx copied; - - GLfloat *current[VBO_ATTRIB_MAX]; /* points into ctx->ListState */ - GLubyte *currentsz[VBO_ATTRIB_MAX]; -}; - -#if FEATURE_dlist - -void vbo_save_init( struct gl_context *ctx ); -void vbo_save_destroy( struct gl_context *ctx ); -void vbo_save_fallback( struct gl_context *ctx, GLboolean fallback ); - -/* save_loopback.c: - */ -void vbo_loopback_vertex_list( struct gl_context *ctx, - const GLfloat *buffer, - const GLubyte *attrsz, - const struct _mesa_prim *prim, - GLuint prim_count, - GLuint wrap_count, - GLuint vertex_size); - -/* Callbacks: - */ -void vbo_save_EndList( struct gl_context *ctx ); -void vbo_save_NewList( struct gl_context *ctx, GLuint list, GLenum mode ); -void vbo_save_EndCallList( struct gl_context *ctx ); -void vbo_save_BeginCallList( struct gl_context *ctx, struct gl_display_list *list ); -void vbo_save_SaveFlushVertices( struct gl_context *ctx ); -GLboolean vbo_save_NotifyBegin( struct gl_context *ctx, GLenum mode ); - -void vbo_save_playback_vertex_list( struct gl_context *ctx, void *data ); - -void vbo_save_api_init( struct vbo_save_context *save ); - -#else /* FEATURE_dlist */ - -static inline void -vbo_save_init( struct gl_context *ctx ) -{ -} - -static inline void -vbo_save_destroy( struct gl_context *ctx ) -{ -} - -#endif /* FEATURE_dlist */ - -#endif /* VBO_SAVE_H */ diff --git a/dll/opengl/mesa/vbo/vbo_save_api.c b/dll/opengl/mesa/vbo/vbo_save_api.c deleted file mode 100644 index f1b1ae2673d..00000000000 --- a/dll/opengl/mesa/vbo/vbo_save_api.c +++ /dev/null @@ -1,1363 +0,0 @@ -/************************************************************************** - -Copyright 2002-2008 Tungsten Graphics Inc., Cedar Park, Texas. - -All Rights Reserved. - -Permission is hereby granted, free of charge, to any person obtaining a -copy of this software and associated documentation files (the "Software"), -to deal in the Software without restriction, including without limitation -on the rights to use, copy, modify, merge, publish, distribute, sub -license, and/or sell copies of the Software, and to permit persons to whom -the Software is furnished to do so, subject to the following conditions: - -The above copyright notice and this permission notice (including the next -paragraph) shall be included in all copies or substantial portions of the -Software. - -THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR -IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, -FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT. IN NO EVENT SHALL -TUNGSTEN GRAPHICS AND/OR THEIR SUPPLIERS BE LIABLE FOR ANY CLAIM, -DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR -OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE -USE OR OTHER DEALINGS IN THE SOFTWARE. - -**************************************************************************/ - -/* - * Authors: - * Keith Whitwell - */ - - - -/* Display list compiler attempts to store lists of vertices with the - * same vertex layout. Additionally it attempts to minimize the need - * for execute-time fixup of these vertex lists, allowing them to be - * cached on hardware. - * - * There are still some circumstances where this can be thwarted, for - * example by building a list that consists of one very long primitive - * (eg Begin(Triangles), 1000 vertices, End), and calling that list - * from inside a different begin/end object (Begin(Lines), CallList, - * End). - * - * In that case the code will have to replay the list as individual - * commands through the Exec dispatch table, or fix up the copied - * vertices at execute-time. - * - * The other case where fixup is required is when a vertex attribute - * is introduced in the middle of a primitive. Eg: - * Begin(Lines) - * TexCoord1f() Vertex2f() - * TexCoord1f() Color3f() Vertex2f() - * End() - * - * If the current value of Color isn't known at compile-time, this - * primitive will require fixup. - * - * - * The list compiler currently doesn't attempt to compile lists - * containing EvalCoord or EvalPoint commands. On encountering one of - * these, compilation falls back to opcodes. - * - * This could be improved to fallback only when a mix of EvalCoord and - * Vertex commands are issued within a single primitive. - */ - -#include - -#if FEATURE_dlist - - -#ifdef ERROR -#undef ERROR -#endif - - -/* An interesting VBO number/name to help with debugging */ -#define VBO_BUF_ID 12345 - - -/* - * NOTE: Old 'parity' issue is gone, but copying can still be - * wrong-footed on replay. - */ -static GLuint -_save_copy_vertices(struct gl_context *ctx, - const struct vbo_save_vertex_list *node, - const GLfloat * src_buffer) -{ - struct vbo_save_context *save = &vbo_context(ctx)->save; - const struct _mesa_prim *prim = &node->prim[node->prim_count - 1]; - GLuint nr = prim->count; - GLuint sz = save->vertex_size; - const GLfloat *src = src_buffer + prim->start * sz; - GLfloat *dst = save->copied.buffer; - GLuint ovf, i; - - if (prim->end) - return 0; - - switch (prim->mode) { - case GL_POINTS: - return 0; - case GL_LINES: - ovf = nr & 1; - for (i = 0; i < ovf; i++) - memcpy(dst + i * sz, src + (nr - ovf + i) * sz, - sz * sizeof(GLfloat)); - return i; - case GL_TRIANGLES: - ovf = nr % 3; - for (i = 0; i < ovf; i++) - memcpy(dst + i * sz, src + (nr - ovf + i) * sz, - sz * sizeof(GLfloat)); - return i; - case GL_QUADS: - ovf = nr & 3; - for (i = 0; i < ovf; i++) - memcpy(dst + i * sz, src + (nr - ovf + i) * sz, - sz * sizeof(GLfloat)); - return i; - case GL_LINE_STRIP: - if (nr == 0) - return 0; - else { - memcpy(dst, src + (nr - 1) * sz, sz * sizeof(GLfloat)); - return 1; - } - case GL_LINE_LOOP: - case GL_TRIANGLE_FAN: - case GL_POLYGON: - if (nr == 0) - return 0; - else if (nr == 1) { - memcpy(dst, src + 0, sz * sizeof(GLfloat)); - return 1; - } - else { - memcpy(dst, src + 0, sz * sizeof(GLfloat)); - memcpy(dst + sz, src + (nr - 1) * sz, sz * sizeof(GLfloat)); - return 2; - } - case GL_TRIANGLE_STRIP: - case GL_QUAD_STRIP: - switch (nr) { - case 0: - ovf = 0; - break; - case 1: - ovf = 1; - break; - default: - ovf = 2 + (nr & 1); - break; - } - for (i = 0; i < ovf; i++) - memcpy(dst + i * sz, src + (nr - ovf + i) * sz, - sz * sizeof(GLfloat)); - return i; - default: - assert(0); - return 0; - } -} - - -static struct vbo_save_vertex_store * -alloc_vertex_store(struct gl_context *ctx) -{ - struct vbo_save_context *save = &vbo_context(ctx)->save; - struct vbo_save_vertex_store *vertex_store = - CALLOC_STRUCT(vbo_save_vertex_store); - - /* obj->Name needs to be non-zero, but won't ever be examined more - * closely than that. In particular these buffers won't be entered - * into the hash and can never be confused with ones visible to the - * user. Perhaps there could be a special number for internal - * buffers: - */ - vertex_store->bufferobj = ctx->Driver.NewBufferObject(ctx, - VBO_BUF_ID, - GL_ARRAY_BUFFER_ARB); - if (vertex_store->bufferobj) { - save->out_of_memory = - !ctx->Driver.BufferData(ctx, - GL_ARRAY_BUFFER_ARB, - VBO_SAVE_BUFFER_SIZE * sizeof(GLfloat), - NULL, GL_STATIC_DRAW_ARB, - vertex_store->bufferobj); - } - else { - save->out_of_memory = GL_TRUE; - } - - if (save->out_of_memory) { - _mesa_error(ctx, GL_OUT_OF_MEMORY, "internal VBO allocation"); - _mesa_install_save_vtxfmt(ctx, &save->vtxfmt_noop); - } - - vertex_store->buffer = NULL; - vertex_store->used = 0; - vertex_store->refcount = 1; - - return vertex_store; -} - - -static void -free_vertex_store(struct gl_context *ctx, - struct vbo_save_vertex_store *vertex_store) -{ - assert(!vertex_store->buffer); - - if (vertex_store->bufferobj) { - _mesa_reference_buffer_object(ctx, &vertex_store->bufferobj, NULL); - } - - FREE(vertex_store); -} - - -static GLfloat * -map_vertex_store(struct gl_context *ctx, - struct vbo_save_vertex_store *vertex_store) -{ - assert(vertex_store->bufferobj); - assert(!vertex_store->buffer); - if (vertex_store->bufferobj->Size > 0) { - vertex_store->buffer = - (GLfloat *) ctx->Driver.MapBufferRange(ctx, 0, - vertex_store->bufferobj->Size, - GL_MAP_WRITE_BIT, /* not used */ - vertex_store->bufferobj); - assert(vertex_store->buffer); - return vertex_store->buffer + vertex_store->used; - } - else { - /* probably ran out of memory for buffers */ - return NULL; - } -} - - -static void -unmap_vertex_store(struct gl_context *ctx, - struct vbo_save_vertex_store *vertex_store) -{ - if (vertex_store->bufferobj->Size > 0) { - ctx->Driver.UnmapBuffer(ctx, vertex_store->bufferobj); - } - vertex_store->buffer = NULL; -} - - -static struct vbo_save_primitive_store * -alloc_prim_store(struct gl_context *ctx) -{ - struct vbo_save_primitive_store *store = - CALLOC_STRUCT(vbo_save_primitive_store); - (void) ctx; - store->used = 0; - store->refcount = 1; - return store; -} - - -static void -_save_reset_counters(struct gl_context *ctx) -{ - struct vbo_save_context *save = &vbo_context(ctx)->save; - - save->prim = save->prim_store->buffer + save->prim_store->used; - save->buffer = save->vertex_store->buffer + save->vertex_store->used; - - assert(save->buffer == save->buffer_ptr); - - if (save->vertex_size) - save->max_vert = ((VBO_SAVE_BUFFER_SIZE - save->vertex_store->used) / - save->vertex_size); - else - save->max_vert = 0; - - save->vert_count = 0; - save->prim_count = 0; - save->prim_max = VBO_SAVE_PRIM_SIZE - save->prim_store->used; - save->dangling_attr_ref = 0; -} - - -/** - * Insert the active immediate struct onto the display list currently - * being built. - */ -static void -_save_compile_vertex_list(struct gl_context *ctx) -{ - struct vbo_save_context *save = &vbo_context(ctx)->save; - struct vbo_save_vertex_list *node; - - /* Allocate space for this structure in the display list currently - * being compiled. - */ - node = (struct vbo_save_vertex_list *) - _mesa_dlist_alloc(ctx, save->opcode_vertex_list, sizeof(*node)); - - if (!node) - return; - - /* Duplicate our template, increment refcounts to the storage structs: - */ - memcpy(node->attrsz, save->attrsz, sizeof(node->attrsz)); - node->vertex_size = save->vertex_size; - node->buffer_offset = - (save->buffer - save->vertex_store->buffer) * sizeof(GLfloat); - node->count = save->vert_count; - node->wrap_count = save->copied.nr; - node->dangling_attr_ref = save->dangling_attr_ref; - node->prim = save->prim; - node->prim_count = save->prim_count; - node->vertex_store = save->vertex_store; - node->prim_store = save->prim_store; - - node->vertex_store->refcount++; - node->prim_store->refcount++; - - if (node->prim[0].no_current_update) { - node->current_size = 0; - node->current_data = NULL; - } - else { - node->current_size = node->vertex_size - node->attrsz[0]; - node->current_data = NULL; - - if (node->current_size) { - /* If the malloc fails, we just pull the data out of the VBO - * later instead. - */ - node->current_data = MALLOC(node->current_size * sizeof(GLfloat)); - if (node->current_data) { - const char *buffer = (const char *) save->vertex_store->buffer; - unsigned attr_offset = node->attrsz[0] * sizeof(GLfloat); - unsigned vertex_offset = 0; - - if (node->count) - vertex_offset = - (node->count - 1) * node->vertex_size * sizeof(GLfloat); - - memcpy(node->current_data, - buffer + node->buffer_offset + vertex_offset + attr_offset, - node->current_size * sizeof(GLfloat)); - } - } - } - - assert(node->attrsz[VBO_ATTRIB_POS] != 0 || node->count == 0); - - if (save->dangling_attr_ref) - ctx->ListState.CurrentList->Flags |= DLIST_DANGLING_REFS; - - save->vertex_store->used += save->vertex_size * node->count; - save->prim_store->used += node->prim_count; - - /* Copy duplicated vertices - */ - save->copied.nr = _save_copy_vertices(ctx, node, save->buffer); - - /* Deal with GL_COMPILE_AND_EXECUTE: - */ - if (ctx->ExecuteFlag) { - struct _glapi_table *dispatch = GET_DISPATCH(); - - _glapi_set_dispatch(ctx->Exec); - - vbo_loopback_vertex_list(ctx, - (const GLfloat *) ((const char *) save-> - vertex_store->buffer + - node->buffer_offset), - node->attrsz, node->prim, node->prim_count, - node->wrap_count, node->vertex_size); - - _glapi_set_dispatch(dispatch); - } - - /* Decide whether the storage structs are full, or can be used for - * the next vertex lists as well. - */ - if (save->vertex_store->used > - VBO_SAVE_BUFFER_SIZE - 16 * (save->vertex_size + 4)) { - - /* Unmap old store: - */ - unmap_vertex_store(ctx, save->vertex_store); - - /* Release old reference: - */ - save->vertex_store->refcount--; - assert(save->vertex_store->refcount != 0); - save->vertex_store = NULL; - - /* Allocate and map new store: - */ - save->vertex_store = alloc_vertex_store(ctx); - save->buffer_ptr = map_vertex_store(ctx, save->vertex_store); - save->out_of_memory = save->buffer_ptr == NULL; - } - - if (save->prim_store->used > VBO_SAVE_PRIM_SIZE - 6) { - save->prim_store->refcount--; - assert(save->prim_store->refcount != 0); - save->prim_store = alloc_prim_store(ctx); - } - - /* Reset our structures for the next run of vertices: - */ - _save_reset_counters(ctx); -} - - -/** - * TODO -- If no new vertices have been stored, don't bother saving it. - */ -static void -_save_wrap_buffers(struct gl_context *ctx) -{ - struct vbo_save_context *save = &vbo_context(ctx)->save; - GLint i = save->prim_count - 1; - GLenum mode; - GLboolean weak; - GLboolean no_current_update; - - assert(i < (GLint) save->prim_max); - assert(i >= 0); - - /* Close off in-progress primitive. - */ - save->prim[i].count = (save->vert_count - save->prim[i].start); - mode = save->prim[i].mode; - weak = save->prim[i].weak; - no_current_update = save->prim[i].no_current_update; - - /* store the copied vertices, and allocate a new list. - */ - _save_compile_vertex_list(ctx); - - /* Restart interrupted primitive - */ - save->prim[0].mode = mode; - save->prim[0].weak = weak; - save->prim[0].no_current_update = no_current_update; - save->prim[0].begin = 0; - save->prim[0].end = 0; - save->prim[0].pad = 0; - save->prim[0].start = 0; - save->prim[0].count = 0; - save->prim[0].num_instances = 1; - save->prim_count = 1; -} - - -/** - * Called only when buffers are wrapped as the result of filling the - * vertex_store struct. - */ -static void -_save_wrap_filled_vertex(struct gl_context *ctx) -{ - struct vbo_save_context *save = &vbo_context(ctx)->save; - GLfloat *data = save->copied.buffer; - GLuint i; - - /* Emit a glEnd to close off the last vertex list. - */ - _save_wrap_buffers(ctx); - - /* Copy stored stored vertices to start of new list. - */ - assert(save->max_vert - save->vert_count > save->copied.nr); - - for (i = 0; i < save->copied.nr; i++) { - memcpy(save->buffer_ptr, data, save->vertex_size * sizeof(GLfloat)); - data += save->vertex_size; - save->buffer_ptr += save->vertex_size; - save->vert_count++; - } -} - - -static void -_save_copy_to_current(struct gl_context *ctx) -{ - struct vbo_save_context *save = &vbo_context(ctx)->save; - GLuint i; - - for (i = VBO_ATTRIB_POS + 1; i < VBO_ATTRIB_MAX; i++) { - if (save->attrsz[i]) { - save->currentsz[i][0] = save->attrsz[i]; - COPY_CLEAN_4V(save->current[i], save->attrsz[i], save->attrptr[i]); - } - } -} - - -static void -_save_copy_from_current(struct gl_context *ctx) -{ - struct vbo_save_context *save = &vbo_context(ctx)->save; - GLint i; - - for (i = VBO_ATTRIB_POS + 1; i < VBO_ATTRIB_MAX; i++) { - switch (save->attrsz[i]) { - case 4: - save->attrptr[i][3] = save->current[i][3]; - case 3: - save->attrptr[i][2] = save->current[i][2]; - case 2: - save->attrptr[i][1] = save->current[i][1]; - case 1: - save->attrptr[i][0] = save->current[i][0]; - case 0: - break; - } - } -} - - -/* Flush existing data, set new attrib size, replay copied vertices. - */ -static void -_save_upgrade_vertex(struct gl_context *ctx, GLuint attr, GLuint newsz) -{ - struct vbo_save_context *save = &vbo_context(ctx)->save; - GLuint oldsz; - GLuint i; - GLfloat *tmp; - - /* Store the current run of vertices, and emit a GL_END. Emit a - * BEGIN in the new buffer. - */ - if (save->vert_count) - _save_wrap_buffers(ctx); - else - assert(save->copied.nr == 0); - - /* Do a COPY_TO_CURRENT to ensure back-copying works for the case - * when the attribute already exists in the vertex and is having - * its size increased. - */ - _save_copy_to_current(ctx); - - /* Fix up sizes: - */ - oldsz = save->attrsz[attr]; - save->attrsz[attr] = newsz; - - save->vertex_size += newsz - oldsz; - save->max_vert = ((VBO_SAVE_BUFFER_SIZE - save->vertex_store->used) / - save->vertex_size); - save->vert_count = 0; - - /* Recalculate all the attrptr[] values: - */ - for (i = 0, tmp = save->vertex; i < VBO_ATTRIB_MAX; i++) { - if (save->attrsz[i]) { - save->attrptr[i] = tmp; - tmp += save->attrsz[i]; - } - else { - save->attrptr[i] = NULL; /* will not be dereferenced. */ - } - } - - /* Copy from current to repopulate the vertex with correct values. - */ - _save_copy_from_current(ctx); - - /* Replay stored vertices to translate them to new format here. - * - * If there are copied vertices and the new (upgraded) attribute - * has not been defined before, this list is somewhat degenerate, - * and will need fixup at runtime. - */ - if (save->copied.nr) { - GLfloat *data = save->copied.buffer; - GLfloat *dest = save->buffer; - GLuint j; - - /* Need to note this and fix up at runtime (or loopback): - */ - if (attr != VBO_ATTRIB_POS && save->currentsz[attr][0] == 0) { - assert(oldsz == 0); - save->dangling_attr_ref = GL_TRUE; - } - - for (i = 0; i < save->copied.nr; i++) { - for (j = 0; j < VBO_ATTRIB_MAX; j++) { - if (save->attrsz[j]) { - if (j == attr) { - if (oldsz) { - COPY_CLEAN_4V(dest, oldsz, data); - data += oldsz; - dest += newsz; - } - else { - COPY_SZ_4V(dest, newsz, save->current[attr]); - dest += newsz; - } - } - else { - GLint sz = save->attrsz[j]; - COPY_SZ_4V(dest, sz, data); - data += sz; - dest += sz; - } - } - } - } - - save->buffer_ptr = dest; - save->vert_count += save->copied.nr; - } -} - - -static void -save_fixup_vertex(struct gl_context *ctx, GLuint attr, GLuint sz) -{ - struct vbo_save_context *save = &vbo_context(ctx)->save; - - if (sz > save->attrsz[attr]) { - /* New size is larger. Need to flush existing vertices and get - * an enlarged vertex format. - */ - _save_upgrade_vertex(ctx, attr, sz); - } - else if (sz < save->active_sz[attr]) { - static GLfloat id[4] = { 0, 0, 0, 1 }; - GLuint i; - - /* New size is equal or smaller - just need to fill in some - * zeros. - */ - for (i = sz; i <= save->attrsz[attr]; i++) - save->attrptr[attr][i - 1] = id[i - 1]; - } - - save->active_sz[attr] = sz; -} - - -static void -_save_reset_vertex(struct gl_context *ctx) -{ - struct vbo_save_context *save = &vbo_context(ctx)->save; - GLuint i; - - for (i = 0; i < VBO_ATTRIB_MAX; i++) { - save->attrsz[i] = 0; - save->active_sz[i] = 0; - } - - save->vertex_size = 0; -} - - - -#define ERROR(err) _mesa_compile_error(ctx, err, __FUNCTION__); - - -/* Only one size for each attribute may be active at once. Eg. if - * Color3f is installed/active, then Color4f may not be, even if the - * vertex actually contains 4 color coordinates. This is because the - * 3f version won't otherwise set color[3] to 1.0 -- this is the job - * of the chooser function when switching between Color4f and Color3f. - */ -#define ATTR(A, N, V0, V1, V2, V3) \ -do { \ - struct vbo_save_context *save = &vbo_context(ctx)->save; \ - \ - if (save->active_sz[A] != N) \ - save_fixup_vertex(ctx, A, N); \ - \ - { \ - GLfloat *dest = save->attrptr[A]; \ - if (N>0) dest[0] = V0; \ - if (N>1) dest[1] = V1; \ - if (N>2) dest[2] = V2; \ - if (N>3) dest[3] = V3; \ - } \ - \ - if ((A) == 0) { \ - GLuint i; \ - \ - for (i = 0; i < save->vertex_size; i++) \ - save->buffer_ptr[i] = save->vertex[i]; \ - \ - save->buffer_ptr += save->vertex_size; \ - \ - if (++save->vert_count >= save->max_vert) \ - _save_wrap_filled_vertex(ctx); \ - } \ -} while (0) - -#define TAG(x) _save_##x - -#include "vbo_attrib_tmp.h" - - - -#define MAT( ATTR, N, face, params ) \ -do { \ - if (face != GL_BACK) \ - MAT_ATTR( ATTR, N, params ); /* front */ \ - if (face != GL_FRONT) \ - MAT_ATTR( ATTR + 1, N, params ); /* back */ \ -} while (0) - - -/** - * Save a glMaterial call found between glBegin/End. - * glMaterial calls outside Begin/End are handled in dlist.c. - */ -static void GLAPIENTRY -_save_Materialfv(GLenum face, GLenum pname, const GLfloat *params) -{ - GET_CURRENT_CONTEXT(ctx); - - if (face != GL_FRONT && face != GL_BACK && face != GL_FRONT_AND_BACK) { - _mesa_compile_error(ctx, GL_INVALID_ENUM, "glMaterial(face)"); - return; - } - - switch (pname) { - case GL_EMISSION: - MAT(VBO_ATTRIB_MAT_FRONT_EMISSION, 4, face, params); - break; - case GL_AMBIENT: - MAT(VBO_ATTRIB_MAT_FRONT_AMBIENT, 4, face, params); - break; - case GL_DIFFUSE: - MAT(VBO_ATTRIB_MAT_FRONT_DIFFUSE, 4, face, params); - break; - case GL_SPECULAR: - MAT(VBO_ATTRIB_MAT_FRONT_SPECULAR, 4, face, params); - break; - case GL_SHININESS: - if (*params < 0 || *params > ctx->Const.MaxShininess) { - _mesa_compile_error(ctx, GL_INVALID_VALUE, "glMaterial(shininess)"); - } - else { - MAT(VBO_ATTRIB_MAT_FRONT_SHININESS, 1, face, params); - } - break; - case GL_COLOR_INDEXES: - MAT(VBO_ATTRIB_MAT_FRONT_INDEXES, 3, face, params); - break; - case GL_AMBIENT_AND_DIFFUSE: - MAT(VBO_ATTRIB_MAT_FRONT_AMBIENT, 4, face, params); - MAT(VBO_ATTRIB_MAT_FRONT_DIFFUSE, 4, face, params); - break; - default: - _mesa_compile_error(ctx, GL_INVALID_ENUM, "glMaterial(pname)"); - return; - } -} - - -/* Cope with EvalCoord/CallList called within a begin/end object: - * -- Flush current buffer - * -- Fallback to opcodes for the rest of the begin/end object. - */ -static void -dlist_fallback(struct gl_context *ctx) -{ - struct vbo_save_context *save = &vbo_context(ctx)->save; - - if (save->vert_count || save->prim_count) { - if (save->prim_count > 0) { - /* Close off in-progress primitive. */ - GLint i = save->prim_count - 1; - save->prim[i].count = save->vert_count - save->prim[i].start; - } - - /* Need to replay this display list with loopback, - * unfortunately, otherwise this primitive won't be handled - * properly: - */ - save->dangling_attr_ref = 1; - - _save_compile_vertex_list(ctx); - } - - _save_copy_to_current(ctx); - _save_reset_vertex(ctx); - _save_reset_counters(ctx); - if (save->out_of_memory) { - _mesa_install_save_vtxfmt(ctx, &save->vtxfmt_noop); - } - else { - _mesa_install_save_vtxfmt(ctx, &ctx->ListState.ListVtxfmt); - } - ctx->Driver.SaveNeedFlush = 0; -} - - -static void GLAPIENTRY -_save_EvalCoord1f(GLfloat u) -{ - GET_CURRENT_CONTEXT(ctx); - dlist_fallback(ctx); - CALL_EvalCoord1f(ctx->Save, (u)); -} - -static void GLAPIENTRY -_save_EvalCoord1fv(const GLfloat * v) -{ - GET_CURRENT_CONTEXT(ctx); - dlist_fallback(ctx); - CALL_EvalCoord1fv(ctx->Save, (v)); -} - -static void GLAPIENTRY -_save_EvalCoord2f(GLfloat u, GLfloat v) -{ - GET_CURRENT_CONTEXT(ctx); - dlist_fallback(ctx); - CALL_EvalCoord2f(ctx->Save, (u, v)); -} - -static void GLAPIENTRY -_save_EvalCoord2fv(const GLfloat * v) -{ - GET_CURRENT_CONTEXT(ctx); - dlist_fallback(ctx); - CALL_EvalCoord2fv(ctx->Save, (v)); -} - -static void GLAPIENTRY -_save_EvalPoint1(GLint i) -{ - GET_CURRENT_CONTEXT(ctx); - dlist_fallback(ctx); - CALL_EvalPoint1(ctx->Save, (i)); -} - -static void GLAPIENTRY -_save_EvalPoint2(GLint i, GLint j) -{ - GET_CURRENT_CONTEXT(ctx); - dlist_fallback(ctx); - CALL_EvalPoint2(ctx->Save, (i, j)); -} - -static void GLAPIENTRY -_save_CallList(GLuint l) -{ - GET_CURRENT_CONTEXT(ctx); - dlist_fallback(ctx); - CALL_CallList(ctx->Save, (l)); -} - -static void GLAPIENTRY -_save_CallLists(GLsizei n, GLenum type, const GLvoid * v) -{ - GET_CURRENT_CONTEXT(ctx); - dlist_fallback(ctx); - CALL_CallLists(ctx->Save, (n, type, v)); -} - - - -/* This begin is hooked into ... Updating of - * ctx->Driver.CurrentSavePrimitive is already taken care of. - */ -GLboolean -vbo_save_NotifyBegin(struct gl_context *ctx, GLenum mode) -{ - struct vbo_save_context *save = &vbo_context(ctx)->save; - - GLuint i = save->prim_count++; - - assert(i < save->prim_max); - save->prim[i].mode = mode & VBO_SAVE_PRIM_MODE_MASK; - save->prim[i].begin = 1; - save->prim[i].end = 0; - save->prim[i].weak = (mode & VBO_SAVE_PRIM_WEAK) ? 1 : 0; - save->prim[i].no_current_update = - (mode & VBO_SAVE_PRIM_NO_CURRENT_UPDATE) ? 1 : 0; - save->prim[i].pad = 0; - save->prim[i].start = save->vert_count; - save->prim[i].count = 0; - save->prim[i].num_instances = 1; - - if (save->out_of_memory) { - _mesa_install_save_vtxfmt(ctx, &save->vtxfmt_noop); - } - else { - _mesa_install_save_vtxfmt(ctx, &save->vtxfmt); - } - ctx->Driver.SaveNeedFlush = 1; - return GL_TRUE; -} - - -static void GLAPIENTRY -_save_End(void) -{ - GET_CURRENT_CONTEXT(ctx); - struct vbo_save_context *save = &vbo_context(ctx)->save; - GLint i = save->prim_count - 1; - - ctx->Driver.CurrentSavePrimitive = PRIM_OUTSIDE_BEGIN_END; - save->prim[i].end = 1; - save->prim[i].count = (save->vert_count - save->prim[i].start); - - if (i == (GLint) save->prim_max - 1) { - _save_compile_vertex_list(ctx); - assert(save->copied.nr == 0); - } - - /* Swap out this vertex format while outside begin/end. Any color, - * etc. received between here and the next begin will be compiled - * as opcodes. - */ - if (save->out_of_memory) { - _mesa_install_save_vtxfmt(ctx, &save->vtxfmt_noop); - } - else { - _mesa_install_save_vtxfmt(ctx, &ctx->ListState.ListVtxfmt); - } -} - - -/* These are all errors as this vtxfmt is only installed inside - * begin/end pairs. - */ -static void GLAPIENTRY -_save_DrawElements(GLenum mode, GLsizei count, GLenum type, - const GLvoid * indices) -{ - GET_CURRENT_CONTEXT(ctx); - (void) mode; - (void) count; - (void) type; - (void) indices; - _mesa_compile_error(ctx, GL_INVALID_OPERATION, "glDrawElements"); -} - - -static void GLAPIENTRY -_save_DrawArrays(GLenum mode, GLint start, GLsizei count) -{ - GET_CURRENT_CONTEXT(ctx); - (void) mode; - (void) start; - (void) count; - _mesa_compile_error(ctx, GL_INVALID_OPERATION, "glDrawArrays"); -} - - -static void GLAPIENTRY -_save_Rectf(GLfloat x1, GLfloat y1, GLfloat x2, GLfloat y2) -{ - GET_CURRENT_CONTEXT(ctx); - (void) x1; - (void) y1; - (void) x2; - (void) y2; - _mesa_compile_error(ctx, GL_INVALID_OPERATION, "glRectf"); -} - - -static void GLAPIENTRY -_save_EvalMesh1(GLenum mode, GLint i1, GLint i2) -{ - GET_CURRENT_CONTEXT(ctx); - (void) mode; - (void) i1; - (void) i2; - _mesa_compile_error(ctx, GL_INVALID_OPERATION, "glEvalMesh1"); -} - - -static void GLAPIENTRY -_save_EvalMesh2(GLenum mode, GLint i1, GLint i2, GLint j1, GLint j2) -{ - GET_CURRENT_CONTEXT(ctx); - (void) mode; - (void) i1; - (void) i2; - (void) j1; - (void) j2; - _mesa_compile_error(ctx, GL_INVALID_OPERATION, "glEvalMesh2"); -} - - -static void GLAPIENTRY -_save_Begin(GLenum mode) -{ - GET_CURRENT_CONTEXT(ctx); - (void) mode; - _mesa_compile_error(ctx, GL_INVALID_OPERATION, "Recursive glBegin"); -} - - -/* Unlike the functions above, these are to be hooked into the vtxfmt - * maintained in ctx->ListState, active when the list is known or - * suspected to be outside any begin/end primitive. - * Note: OBE = Outside Begin/End - */ -static void GLAPIENTRY -_save_OBE_Rectf(GLfloat x1, GLfloat y1, GLfloat x2, GLfloat y2) -{ - GET_CURRENT_CONTEXT(ctx); - vbo_save_NotifyBegin(ctx, GL_QUADS | VBO_SAVE_PRIM_WEAK); - CALL_Vertex2f(GET_DISPATCH(), (x1, y1)); - CALL_Vertex2f(GET_DISPATCH(), (x2, y1)); - CALL_Vertex2f(GET_DISPATCH(), (x2, y2)); - CALL_Vertex2f(GET_DISPATCH(), (x1, y2)); - CALL_End(GET_DISPATCH(), ()); -} - - -static void GLAPIENTRY -_save_OBE_DrawArrays(GLenum mode, GLint start, GLsizei count) -{ - GET_CURRENT_CONTEXT(ctx); - struct vbo_save_context *save = &vbo_context(ctx)->save; - GLint i; - - if (!_mesa_validate_DrawArrays(ctx, mode, start, count)) - return; - - if (save->out_of_memory) - return; - - _ae_map_vbos(ctx); - - vbo_save_NotifyBegin(ctx, (mode | VBO_SAVE_PRIM_WEAK - | VBO_SAVE_PRIM_NO_CURRENT_UPDATE)); - - for (i = 0; i < count; i++) - CALL_ArrayElement(GET_DISPATCH(), (start + i)); - CALL_End(GET_DISPATCH(), ()); - - _ae_unmap_vbos(ctx); -} - - -/* Could do better by copying the arrays and element list intact and - * then emitting an indexed prim at runtime. - */ -static void GLAPIENTRY -_save_OBE_DrawElements(GLenum mode, GLsizei count, GLenum type, - const GLvoid * indices) -{ - GET_CURRENT_CONTEXT(ctx); - struct vbo_save_context *save = &vbo_context(ctx)->save; - GLint i; - - if (!_mesa_validate_DrawElements(ctx, mode, count, type, indices)) - return; - - if (save->out_of_memory) - return; - - _ae_map_vbos(ctx); - - if (_mesa_is_bufferobj(ctx->Array.ElementArrayBufferObj)) - indices = ADD_POINTERS(ctx->Array.ElementArrayBufferObj->Pointer, indices); - - vbo_save_NotifyBegin(ctx, (mode | VBO_SAVE_PRIM_WEAK | - VBO_SAVE_PRIM_NO_CURRENT_UPDATE)); - - switch (type) { - case GL_UNSIGNED_BYTE: - for (i = 0; i < count; i++) - CALL_ArrayElement(GET_DISPATCH(), (((GLubyte *) indices)[i])); - break; - case GL_UNSIGNED_SHORT: - for (i = 0; i < count; i++) - CALL_ArrayElement(GET_DISPATCH(), (((GLushort *) indices)[i])); - break; - case GL_UNSIGNED_INT: - for (i = 0; i < count; i++) - CALL_ArrayElement(GET_DISPATCH(), (((GLuint *) indices)[i])); - break; - default: - _mesa_error(ctx, GL_INVALID_ENUM, "glDrawElements(type)"); - break; - } - - CALL_End(GET_DISPATCH(), ()); - - _ae_unmap_vbos(ctx); -} - - -static void -_save_vtxfmt_init(struct gl_context *ctx) -{ - struct vbo_save_context *save = &vbo_context(ctx)->save; - GLvertexformat *vfmt = &save->vtxfmt; - - _MESA_INIT_ARRAYELT_VTXFMT(vfmt, _ae_); - - vfmt->Begin = _save_Begin; - vfmt->Color3f = _save_Color3f; - vfmt->Color3fv = _save_Color3fv; - vfmt->Color4f = _save_Color4f; - vfmt->Color4fv = _save_Color4fv; - vfmt->EdgeFlag = _save_EdgeFlag; - vfmt->End = _save_End; - vfmt->FogCoordfEXT = _save_FogCoordfEXT; - vfmt->FogCoordfvEXT = _save_FogCoordfvEXT; - vfmt->Indexf = _save_Indexf; - vfmt->Indexfv = _save_Indexfv; - vfmt->Materialfv = _save_Materialfv; - vfmt->Normal3f = _save_Normal3f; - vfmt->Normal3fv = _save_Normal3fv; - vfmt->TexCoord1f = _save_TexCoord1f; - vfmt->TexCoord1fv = _save_TexCoord1fv; - vfmt->TexCoord2f = _save_TexCoord2f; - vfmt->TexCoord2fv = _save_TexCoord2fv; - vfmt->TexCoord3f = _save_TexCoord3f; - vfmt->TexCoord3fv = _save_TexCoord3fv; - vfmt->TexCoord4f = _save_TexCoord4f; - vfmt->TexCoord4fv = _save_TexCoord4fv; - vfmt->Vertex2f = _save_Vertex2f; - vfmt->Vertex2fv = _save_Vertex2fv; - vfmt->Vertex3f = _save_Vertex3f; - vfmt->Vertex3fv = _save_Vertex3fv; - vfmt->Vertex4f = _save_Vertex4f; - vfmt->Vertex4fv = _save_Vertex4fv; - - vfmt->VertexAttrib1fNV = _save_VertexAttrib1fNV; - vfmt->VertexAttrib1fvNV = _save_VertexAttrib1fvNV; - vfmt->VertexAttrib2fNV = _save_VertexAttrib2fNV; - vfmt->VertexAttrib2fvNV = _save_VertexAttrib2fvNV; - vfmt->VertexAttrib3fNV = _save_VertexAttrib3fNV; - vfmt->VertexAttrib3fvNV = _save_VertexAttrib3fvNV; - vfmt->VertexAttrib4fNV = _save_VertexAttrib4fNV; - vfmt->VertexAttrib4fvNV = _save_VertexAttrib4fvNV; - - /* This will all require us to fallback to saving the list as opcodes: - */ - _MESA_INIT_DLIST_VTXFMT(vfmt, _save_); /* inside begin/end */ - - _MESA_INIT_EVAL_VTXFMT(vfmt, _save_); - - /* These calls all generate GL_INVALID_OPERATION since this vtxfmt is - * only used when we're inside a glBegin/End pair. - */ - vfmt->Begin = _save_Begin; - vfmt->Rectf = _save_Rectf; - vfmt->DrawArrays = _save_DrawArrays; - vfmt->DrawElements = _save_DrawElements; -} - - -void -vbo_save_SaveFlushVertices(struct gl_context *ctx) -{ - struct vbo_save_context *save = &vbo_context(ctx)->save; - - /* Noop when we are actually active: - */ - if (ctx->Driver.CurrentSavePrimitive == PRIM_INSIDE_UNKNOWN_PRIM || - ctx->Driver.CurrentSavePrimitive <= GL_POLYGON) - return; - - if (save->vert_count || save->prim_count) - _save_compile_vertex_list(ctx); - - _save_copy_to_current(ctx); - _save_reset_vertex(ctx); - _save_reset_counters(ctx); - ctx->Driver.SaveNeedFlush = 0; -} - - -void -vbo_save_NewList(struct gl_context *ctx, GLuint list, GLenum mode) -{ - struct vbo_save_context *save = &vbo_context(ctx)->save; - - (void) list; - (void) mode; - - if (!save->prim_store) - save->prim_store = alloc_prim_store(ctx); - - if (!save->vertex_store) - save->vertex_store = alloc_vertex_store(ctx); - - save->buffer_ptr = map_vertex_store(ctx, save->vertex_store); - - _save_reset_vertex(ctx); - _save_reset_counters(ctx); - ctx->Driver.SaveNeedFlush = 0; -} - - -void -vbo_save_EndList(struct gl_context *ctx) -{ - struct vbo_save_context *save = &vbo_context(ctx)->save; - - /* EndList called inside a (saved) Begin/End pair? - */ - if (ctx->Driver.CurrentSavePrimitive != PRIM_OUTSIDE_BEGIN_END) { - - if (save->prim_count > 0) { - GLint i = save->prim_count - 1; - ctx->Driver.CurrentSavePrimitive = PRIM_OUTSIDE_BEGIN_END; - save->prim[i].end = 0; - save->prim[i].count = (save->vert_count - save->prim[i].start); - } - - /* Make sure this vertex list gets replayed by the "loopback" - * mechanism: - */ - save->dangling_attr_ref = 1; - vbo_save_SaveFlushVertices(ctx); - - /* Swap out this vertex format while outside begin/end. Any color, - * etc. received between here and the next begin will be compiled - * as opcodes. - */ - _mesa_install_save_vtxfmt(ctx, &ctx->ListState.ListVtxfmt); - } - - unmap_vertex_store(ctx, save->vertex_store); - - assert(save->vertex_size == 0); -} - - -void -vbo_save_BeginCallList(struct gl_context *ctx, struct gl_display_list *dlist) -{ - struct vbo_save_context *save = &vbo_context(ctx)->save; - save->replay_flags |= dlist->Flags; -} - - -void -vbo_save_EndCallList(struct gl_context *ctx) -{ - struct vbo_save_context *save = &vbo_context(ctx)->save; - - if (ctx->ListState.CallDepth == 1) { - /* This is correct: want to keep only the VBO_SAVE_FALLBACK - * flag, if it is set: - */ - save->replay_flags &= VBO_SAVE_FALLBACK; - } -} - - -static void -vbo_destroy_vertex_list(struct gl_context *ctx, void *data) -{ - struct vbo_save_vertex_list *node = (struct vbo_save_vertex_list *) data; - (void) ctx; - - if (--node->vertex_store->refcount == 0) - free_vertex_store(ctx, node->vertex_store); - - if (--node->prim_store->refcount == 0) - FREE(node->prim_store); - - if (node->current_data) { - FREE(node->current_data); - node->current_data = NULL; - } -} - - -static void -vbo_print_vertex_list(struct gl_context *ctx, void *data) -{ - struct vbo_save_vertex_list *node = (struct vbo_save_vertex_list *) data; - GLuint i; - (void) ctx; - - printf("VBO-VERTEX-LIST, %u vertices %d primitives, %d vertsize\n", - node->count, node->prim_count, node->vertex_size); - - for (i = 0; i < node->prim_count; i++) { - struct _mesa_prim *prim = &node->prim[i]; - _mesa_debug(NULL, " prim %d: %s%s %d..%d %s %s\n", - i, - _mesa_lookup_prim_by_nr(prim->mode), - prim->weak ? " (weak)" : "", - prim->start, - prim->start + prim->count, - (prim->begin) ? "BEGIN" : "(wrap)", - (prim->end) ? "END" : "(wrap)"); - } -} - - -static void -_save_current_init(struct gl_context *ctx) -{ - struct vbo_save_context *save = &vbo_context(ctx)->save; - GLint i; - - for (i = VBO_ATTRIB_POS; i <= VBO_ATTRIB_POINT_SIZE; i++) { - const GLuint j = i - VBO_ATTRIB_POS; - ASSERT(j < VERT_ATTRIB_MAX); - save->currentsz[i] = &ctx->ListState.ActiveAttribSize[j]; - save->current[i] = ctx->ListState.CurrentAttrib[j]; - } - - for (i = VBO_ATTRIB_FIRST_MATERIAL; i <= VBO_ATTRIB_LAST_MATERIAL; i++) { - const GLuint j = i - VBO_ATTRIB_FIRST_MATERIAL; - ASSERT(j < MAT_ATTRIB_MAX); - save->currentsz[i] = &ctx->ListState.ActiveMaterialSize[j]; - save->current[i] = ctx->ListState.CurrentMaterial[j]; - } -} - - -/** - * Initialize the display list compiler - */ -void -vbo_save_api_init(struct vbo_save_context *save) -{ - struct gl_context *ctx = save->ctx; - GLuint i; - - save->opcode_vertex_list = - _mesa_dlist_alloc_opcode(ctx, - sizeof(struct vbo_save_vertex_list), - vbo_save_playback_vertex_list, - vbo_destroy_vertex_list, - vbo_print_vertex_list); - - ctx->Driver.NotifySaveBegin = vbo_save_NotifyBegin; - - _save_vtxfmt_init(ctx); - _save_current_init(ctx); - _mesa_noop_vtxfmt_init(&save->vtxfmt_noop); - - /* These will actually get set again when binding/drawing */ - for (i = 0; i < VBO_ATTRIB_MAX; i++) - save->inputs[i] = &save->arrays[i]; - - /* Hook our array functions into the outside-begin-end vtxfmt in - * ctx->ListState. - */ - ctx->ListState.ListVtxfmt.Rectf = _save_OBE_Rectf; - ctx->ListState.ListVtxfmt.DrawArrays = _save_OBE_DrawArrays; - ctx->ListState.ListVtxfmt.DrawElements = _save_OBE_DrawElements; - _mesa_install_save_vtxfmt(ctx, &ctx->ListState.ListVtxfmt); -} - - -#endif /* FEATURE_dlist */ diff --git a/dll/opengl/mesa/vbo/vbo_save_draw.c b/dll/opengl/mesa/vbo/vbo_save_draw.c deleted file mode 100644 index 364d8bf3cf8..00000000000 --- a/dll/opengl/mesa/vbo/vbo_save_draw.c +++ /dev/null @@ -1,256 +0,0 @@ -/* - * Mesa 3-D graphics library - * Version: 7.2 - * - * Copyright (C) 1999-2008 Brian Paul All Rights Reserved. - * - * Permission is hereby granted, free of charge, to any person obtaining a - * copy of this software and associated documentation files (the "Software"), - * to deal in the Software without restriction, including without limitation - * the rights to use, copy, modify, merge, publish, distribute, sublicense, - * and/or sell copies of the Software, and to permit persons to whom the - * Software is furnished to do so, subject to the following conditions: - * - * The above copyright notice and this permission notice shall be included - * in all copies or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS - * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL - * BRIAN PAUL BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN - * AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN - * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. - */ - -/* Author: - * Keith Whitwell - */ - -#include - -#if FEATURE_dlist - - -/** - * After playback, copy everything but the position from the - * last vertex to the saved state - */ -static void -_playback_copy_to_current(struct gl_context *ctx, - const struct vbo_save_vertex_list *node) -{ - struct vbo_context *vbo = vbo_context(ctx); - GLfloat vertex[VBO_ATTRIB_MAX * 4]; - GLfloat *data; - GLuint i, offset; - - if (node->current_size == 0) - return; - - if (node->current_data) { - data = node->current_data; - } - else { - data = vertex; - - if (node->count) - offset = (node->buffer_offset + - (node->count-1) * node->vertex_size * sizeof(GLfloat)); - else - offset = node->buffer_offset; - - ctx->Driver.GetBufferSubData( ctx, offset, - node->vertex_size * sizeof(GLfloat), - data, node->vertex_store->bufferobj ); - - data += node->attrsz[0]; /* skip vertex position */ - } - - for (i = VBO_ATTRIB_POS+1 ; i < VBO_ATTRIB_MAX ; i++) { - if (node->attrsz[i]) { - GLfloat *current = (GLfloat *)vbo->currval[i].Ptr; - GLfloat tmp[4]; - - COPY_CLEAN_4V(tmp, - node->attrsz[i], - data); - - if (memcmp(current, tmp, 4 * sizeof(GLfloat)) != 0) { - memcpy(current, tmp, 4 * sizeof(GLfloat)); - - vbo->currval[i].Size = node->attrsz[i]; - assert(vbo->currval[i].Type == GL_FLOAT); - vbo->currval[i]._ElementSize = vbo->currval[i].Size * sizeof(GLfloat); - - if (i >= VBO_ATTRIB_FIRST_MATERIAL && - i <= VBO_ATTRIB_LAST_MATERIAL) - ctx->NewState |= _NEW_LIGHT; - - ctx->NewState |= _NEW_CURRENT_ATTRIB; - } - - data += node->attrsz[i]; - } - } - - /* Colormaterial -- this kindof sucks. - */ - if (ctx->Light.ColorMaterialEnabled) { - _mesa_update_color_material(ctx, ctx->Current.Attrib[VBO_ATTRIB_COLOR]); - } - - /* CurrentExecPrimitive - */ - if (node->prim_count) { - const struct _mesa_prim *prim = &node->prim[node->prim_count - 1]; - if (prim->end) - ctx->Driver.CurrentExecPrimitive = PRIM_OUTSIDE_BEGIN_END; - else - ctx->Driver.CurrentExecPrimitive = prim->mode; - } -} - - - -/** - * Treat the vertex storage as a VBO, define vertex arrays pointing - * into it: - */ -static void vbo_bind_vertex_list(struct gl_context *ctx, - const struct vbo_save_vertex_list *node) -{ - struct vbo_context *vbo = vbo_context(ctx); - struct vbo_save_context *save = &vbo->save; - struct gl_client_array *arrays = save->arrays; - GLuint buffer_offset = node->buffer_offset; - GLuint attr; - GLubyte node_attrsz[VBO_ATTRIB_MAX]; /* copy of node->attrsz[] */ - GLbitfield64 varying_inputs = 0x0; - - memcpy(node_attrsz, node->attrsz, sizeof(node->attrsz)); - - /* Install the default (ie Current) attributes first, then overlay - * all active ones. - */ - for (attr = 0; attr < VBO_ATTRIB_MAX; attr++) { - save->inputs[attr] = &vbo->currval[attr]; - } - - for (attr = 0; attr < VBO_ATTRIB_MAX; attr++) { - - if (node_attrsz[attr]) { - /* override the default array set above */ - save->inputs[attr] = &arrays[attr]; - - arrays[attr].Ptr = (const GLubyte *) NULL + buffer_offset; - arrays[attr].Size = node_attrsz[attr]; - arrays[attr].StrideB = node->vertex_size * sizeof(GLfloat); - arrays[attr].Stride = node->vertex_size * sizeof(GLfloat); - arrays[attr].Type = GL_FLOAT; - arrays[attr].Enabled = 1; - arrays[attr]._ElementSize = arrays[attr].Size * sizeof(GLfloat); - _mesa_reference_buffer_object(ctx, - &arrays[attr].BufferObj, - node->vertex_store->bufferobj); - arrays[attr]._MaxElement = node->count; /* ??? */ - - assert(arrays[attr].BufferObj->Name); - - buffer_offset += node_attrsz[attr] * sizeof(GLfloat); - varying_inputs |= VERT_BIT(attr); - ctx->NewState |= _NEW_ARRAY; - } - } -} - - -static void -vbo_save_loopback_vertex_list(struct gl_context *ctx, - const struct vbo_save_vertex_list *list) -{ - const char *buffer = - ctx->Driver.MapBufferRange(ctx, 0, - list->vertex_store->bufferobj->Size, - GL_MAP_READ_BIT, /* ? */ - list->vertex_store->bufferobj); - - vbo_loopback_vertex_list(ctx, - (const GLfloat *)(buffer + list->buffer_offset), - list->attrsz, - list->prim, - list->prim_count, - list->wrap_count, - list->vertex_size); - - ctx->Driver.UnmapBuffer(ctx, list->vertex_store->bufferobj); -} - - -/** - * Execute the buffer and save copied verts. - * This is called from the display list code when executing - * a drawing command. - */ -void -vbo_save_playback_vertex_list(struct gl_context *ctx, void *data) -{ - const struct vbo_save_vertex_list *node = - (const struct vbo_save_vertex_list *) data; - struct vbo_save_context *save = &vbo_context(ctx)->save; - struct vbo_exec_context *exec = &vbo_context(ctx)->exec; - - FLUSH_CURRENT(ctx, 0); - - if (node->prim_count > 0) { - - if (ctx->Driver.CurrentExecPrimitive != PRIM_OUTSIDE_BEGIN_END && - node->prim[0].begin) { - - /* Degenerate case: list is called inside begin/end pair and - * includes operations such as glBegin or glDrawArrays. - */ - if (0) - printf("displaylist recursive begin"); - - vbo_save_loopback_vertex_list( ctx, node ); - return; - } - else if (save->replay_flags) { - /* Various degnerate cases: translate into immediate mode - * calls rather than trying to execute in place. - */ - vbo_save_loopback_vertex_list( ctx, node ); - return; - } - - if (ctx->NewState) - _mesa_update_state( ctx ); - - vbo_bind_vertex_list( ctx, node ); - - vbo_draw_method(exec, DRAW_DISPLAY_LIST); - - /* Again... - */ - if (ctx->NewState) - _mesa_update_state( ctx ); - - if (node->count > 0) { - vbo_context(ctx)->draw_prims(ctx, - save->inputs, - node->prim, - node->prim_count, - NULL, - GL_TRUE, - 0, /* Node is a VBO, so this is ok */ - node->count - 1); - } - } - - /* Copy to current? - */ - _playback_copy_to_current( ctx, node ); -} - - -#endif /* FEATURE_dlist */ diff --git a/dll/opengl/mesa/vbo/vbo_save_loopback.c b/dll/opengl/mesa/vbo/vbo_save_loopback.c deleted file mode 100644 index 614e5ebabee..00000000000 --- a/dll/opengl/mesa/vbo/vbo_save_loopback.c +++ /dev/null @@ -1,186 +0,0 @@ -/************************************************************************** - * - * Copyright 2005 Tungsten Graphics, Inc., Cedar Park, Texas. - * All Rights Reserved. - * - * Permission is hereby granted, free of charge, to any person obtaining a - * copy of this software and associated documentation files (the - * "Software"), to deal in the Software without restriction, including - * without limitation the rights to use, copy, modify, merge, publish, - * distribute, sub license, and/or sell copies of the Software, and to - * permit persons to whom the Software is furnished to do so, subject to - * the following conditions: - * - * The above copyright notice and this permission notice (including the - * next paragraph) shall be included in all copies or substantial portions - * of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS - * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF - * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT. - * IN NO EVENT SHALL TUNGSTEN GRAPHICS AND/OR ITS SUPPLIERS BE LIABLE FOR - * ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, - * TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE - * SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. - * - **************************************************************************/ - -#include - -#if FEATURE_dlist - - -typedef void (*attr_func)( struct gl_context *ctx, GLint target, const GLfloat * ); - - -/* This file makes heavy use of the aliasing of NV vertex attributes - * with the legacy attributes, and also with ARB and Material - * attributes as currently implemented. - */ -static void VertexAttrib1fvNV(struct gl_context *ctx, GLint target, const GLfloat *v) -{ - CALL_VertexAttrib1fvNV(ctx->Exec, (target, v)); -} - -static void VertexAttrib2fvNV(struct gl_context *ctx, GLint target, const GLfloat *v) -{ - CALL_VertexAttrib2fvNV(ctx->Exec, (target, v)); -} - -static void VertexAttrib3fvNV(struct gl_context *ctx, GLint target, const GLfloat *v) -{ - CALL_VertexAttrib3fvNV(ctx->Exec, (target, v)); -} - -static void VertexAttrib4fvNV(struct gl_context *ctx, GLint target, const GLfloat *v) -{ - CALL_VertexAttrib4fvNV(ctx->Exec, (target, v)); -} - -static attr_func vert_attrfunc[4] = { - VertexAttrib1fvNV, - VertexAttrib2fvNV, - VertexAttrib3fvNV, - VertexAttrib4fvNV -}; - -struct loopback_attr { - GLint target; - GLint sz; - attr_func func; -}; - -/* Don't emit ends and begins on wrapped primitives. Don't replay - * wrapped vertices. If we get here, it's probably because the - * precalculated wrapping is wrong. - */ -static void loopback_prim( struct gl_context *ctx, - const GLfloat *buffer, - const struct _mesa_prim *prim, - GLuint wrap_count, - GLuint vertex_size, - const struct loopback_attr *la, GLuint nr ) -{ - GLint start = prim->start; - GLint end = start + prim->count; - const GLfloat *data; - GLint j; - GLuint k; - - if (0) - printf("loopback prim %s(%s,%s) verts %d..%d\n", - _mesa_lookup_prim_by_nr(prim->mode), - prim->begin ? "begin" : "..", - prim->end ? "end" : "..", - start, - end); - - if (prim->begin) { - CALL_Begin(GET_DISPATCH(), ( prim->mode )); - } - else { - assert(start == 0); - start += wrap_count; - } - - data = buffer + start * vertex_size; - - for (j = start ; j < end ; j++) { - const GLfloat *tmp = data + la[0].sz; - - for (k = 1 ; k < nr ; k++) { - la[k].func( ctx, la[k].target, tmp ); - tmp += la[k].sz; - } - - /* Fire the vertex - */ - la[0].func( ctx, VBO_ATTRIB_POS, data ); - data = tmp; - } - - if (prim->end) { - CALL_End(GET_DISPATCH(), ()); - } -} - -/* Primitives generated by DrawArrays/DrawElements/Rectf may be - * caught here. If there is no primitive in progress, execute them - * normally, otherwise need to track and discard the generated - * primitives. - */ -static void loopback_weak_prim( struct gl_context *ctx, - const struct _mesa_prim *prim ) -{ - /* Use the prim_weak flag to ensure that if this primitive - * wraps, we don't mistake future vertex_lists for part of the - * surrounding primitive. - * - * While this flag is set, we are simply disposing of data - * generated by an operation now known to be a noop. - */ - if (prim->begin) - ctx->Driver.CurrentExecPrimitive |= VBO_SAVE_PRIM_WEAK; - if (prim->end) - ctx->Driver.CurrentExecPrimitive &= ~VBO_SAVE_PRIM_WEAK; -} - - -void vbo_loopback_vertex_list( struct gl_context *ctx, - const GLfloat *buffer, - const GLubyte *attrsz, - const struct _mesa_prim *prim, - GLuint prim_count, - GLuint wrap_count, - GLuint vertex_size) -{ - struct loopback_attr la[VBO_ATTRIB_MAX]; - GLuint i, nr = 0; - - /* All Legacy, NV, ARB and Material attributes are routed through - * the NV attributes entrypoints: - */ - for (i = 0 ; i < VBO_ATTRIB_MAX ; i++) { - if (attrsz[i]) { - la[nr].target = i; - la[nr].sz = attrsz[i]; - la[nr].func = vert_attrfunc[attrsz[i]-1]; - nr++; - } - } - - for (i = 0 ; i < prim_count ; i++) { - if ((prim[i].mode & VBO_SAVE_PRIM_WEAK) && - (ctx->Driver.CurrentExecPrimitive != PRIM_OUTSIDE_BEGIN_END)) - { - loopback_weak_prim( ctx, &prim[i] ); - } - else - { - loopback_prim( ctx, buffer, &prim[i], wrap_count, vertex_size, la, nr ); - } - } -} - - -#endif /* FEATURE_dlist */ diff --git a/dll/opengl/mesa/vbo/vbo_split.c b/dll/opengl/mesa/vbo/vbo_split.c deleted file mode 100644 index 382169ef0fe..00000000000 --- a/dll/opengl/mesa/vbo/vbo_split.c +++ /dev/null @@ -1,154 +0,0 @@ - -/* - * Mesa 3-D graphics library - * Version: 6.5 - * - * Copyright (C) 1999-2006 Brian Paul All Rights Reserved. - * - * Permission is hereby granted, free of charge, to any person obtaining a - * copy of this software and associated documentation files (the "Software"), - * to deal in the Software without restriction, including without limitation - * the rights to use, copy, modify, merge, publish, distribute, sublicense, - * and/or sell copies of the Software, and to permit persons to whom the - * Software is furnished to do so, subject to the following conditions: - * - * The above copyright notice and this permission notice shall be included - * in all copies or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS - * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL - * BRIAN PAUL BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN - * AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN - * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. - * - * Authors: - * Keith Whitwell - */ - -/* Deal with hardware and/or swtnl maximums: - * - maximum number of vertices in buffer - * - maximum number of elements (maybe zero) - * - * The maximums may vary with opengl state (eg if a larger hardware - * vertex is required in this state, the maximum number of vertices - * may be smaller than in another state). - * - * We want buffer splitting to be a convenience function for the code - * actually drawing the primitives rather than a system-wide maximum, - * otherwise it is hard to avoid pessimism. - * - * For instance, if a driver has no hardware limits on vertex buffer - * dimensions, it would not ordinarily want to split vbos. But if - * there is an unexpected fallback, eg memory manager fails to upload - * textures, it will want to pass the drawing commands onto swtnl, - * which does have limitations. A convenience function allows swtnl - * to split the drawing and vbos internally without imposing its - * limitations on drivers which want to use it as a fallback path. - */ - -#include - -/* True if a primitive can be split without copying of vertices, false - * otherwise. - */ -GLboolean split_prim_inplace(GLenum mode, GLuint *first, GLuint *incr) -{ - switch (mode) { - case GL_POINTS: - *first = 1; - *incr = 1; - return GL_TRUE; - case GL_LINES: - *first = 2; - *incr = 2; - return GL_TRUE; - case GL_LINE_STRIP: - *first = 2; - *incr = 1; - return GL_TRUE; - case GL_TRIANGLES: - *first = 3; - *incr = 3; - return GL_TRUE; - case GL_TRIANGLE_STRIP: - *first = 3; - *incr = 1; - return GL_TRUE; - case GL_QUADS: - *first = 4; - *incr = 4; - return GL_TRUE; - case GL_QUAD_STRIP: - *first = 4; - *incr = 2; - return GL_TRUE; - default: - *first = 0; - *incr = 1; /* so that count % incr works */ - return GL_FALSE; - } -} - - - -void vbo_split_prims( struct gl_context *ctx, - const struct gl_client_array *arrays[], - const struct _mesa_prim *prim, - GLuint nr_prims, - const struct _mesa_index_buffer *ib, - GLuint min_index, - GLuint max_index, - vbo_draw_func draw, - const struct split_limits *limits ) -{ - if (ib) { - if (limits->max_indices == 0) { - /* Could traverse the indices, re-emitting vertices in turn. - * But it's hard to see why this case would be needed - for - * software tnl, it is better to convert to non-indexed - * rendering after transformation is complete. Are there any devices - * with hardware tnl that cannot do indexed rendering? - * - * For now, this path is disabled. - */ - assert(0); - } - else if (max_index - min_index >= limits->max_verts) { - /* The vertex buffers are too large for hardware (or the - * swtnl module). Traverse the indices, re-emitting vertices - * in turn. Use a vertex cache to preserve some of the - * sharing from the original index list. - */ - vbo_split_copy(ctx, arrays, prim, nr_prims, ib, - draw, limits ); - } - else if (ib->count > limits->max_indices) { - /* The index buffer is too large for hardware. Try to split - * on whole-primitive boundaries, otherwise try to split the - * individual primitives. - */ - vbo_split_inplace(ctx, arrays, prim, nr_prims, ib, - min_index, max_index, draw, limits ); - } - else { - /* Why were we called? */ - assert(0); - } - } - else { - if (max_index - min_index >= limits->max_verts) { - /* The vertex buffer is too large for hardware (or the swtnl - * module). Try to split on whole-primitive boundaries, - * otherwise try to split the individual primitives. - */ - vbo_split_inplace(ctx, arrays, prim, nr_prims, ib, - min_index, max_index, draw, limits ); - } - else { - /* Why were we called? */ - assert(0); - } - } -} - diff --git a/dll/opengl/mesa/vbo/vbo_split.h b/dll/opengl/mesa/vbo/vbo_split.h deleted file mode 100644 index b7f0a9c5769..00000000000 --- a/dll/opengl/mesa/vbo/vbo_split.h +++ /dev/null @@ -1,72 +0,0 @@ -/* - * mesa 3-D graphics library - * Version: 6.5 - * - * Copyright (C) 1999-2006 Brian Paul All Rights Reserved. - * - * Permission is hereby granted, free of charge, to any person obtaining a - * copy of this software and associated documentation files (the "Software"), - * to deal in the Software without restriction, including without limitation - * the rights to use, copy, modify, merge, publish, distribute, sublicense, - * and/or sell copies of the Software, and to permit persons to whom the - * Software is furnished to do so, subject to the following conditions: - * - * The above copyright notice and this permission notice shall be included - * in all copies or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS - * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL - * BRIAN PAUL BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN - * AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN - * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. - */ - -/** - * \file vbo_context.h - * \brief VBO builder module datatypes and definitions. - * \author Keith Whitwell - */ - - -/** - * \mainpage The VBO splitter - * - * This is the private data used internally to the vbo_split_prims() - * helper function. Nobody outside the vbo_split* files needs to - * include or know about this structure. - */ - - -#ifndef _VBO_SPLIT_H -#define _VBO_SPLIT_H - -#include "vbo.h" - - -/* True if a primitive can be split without copying of vertices, false - * otherwise. - */ -GLboolean split_prim_inplace(GLenum mode, GLuint *first, GLuint *incr); - -void vbo_split_inplace( struct gl_context *ctx, - const struct gl_client_array *arrays[], - const struct _mesa_prim *prim, - GLuint nr_prims, - const struct _mesa_index_buffer *ib, - GLuint min_index, - GLuint max_index, - vbo_draw_func draw, - const struct split_limits *limits ); - -/* Requires ib != NULL: - */ -void vbo_split_copy( struct gl_context *ctx, - const struct gl_client_array *arrays[], - const struct _mesa_prim *prim, - GLuint nr_prims, - const struct _mesa_index_buffer *ib, - vbo_draw_func draw, - const struct split_limits *limits ); - -#endif diff --git a/dll/opengl/mesa/vbo/vbo_split_copy.c b/dll/opengl/mesa/vbo/vbo_split_copy.c deleted file mode 100644 index b5436f19a3b..00000000000 --- a/dll/opengl/mesa/vbo/vbo_split_copy.c +++ /dev/null @@ -1,606 +0,0 @@ - -/* - * Mesa 3-D graphics library - * Version: 6.5 - * - * Copyright (C) 1999-2006 Brian Paul All Rights Reserved. - * - * Permission is hereby granted, free of charge, to any person obtaining a - * copy of this software and associated documentation files (the "Software"), - * to deal in the Software without restriction, including without limitation - * the rights to use, copy, modify, merge, publish, distribute, sublicense, - * and/or sell copies of the Software, and to permit persons to whom the - * Software is furnished to do so, subject to the following conditions: - * - * The above copyright notice and this permission notice shall be included - * in all copies or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS - * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL - * BRIAN PAUL BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN - * AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN - * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. - * - * Authors: - * Keith Whitwell - */ - -/* Split indexed primitives with per-vertex copying. - */ - -#include - -#define ELT_TABLE_SIZE 16 - -/** - * Used for vertex-level splitting of indexed buffers. Note that - * non-indexed primitives may be converted to indexed in some cases - * (eg loops, fans) in order to use this splitting path. - */ -struct copy_context { - - struct gl_context *ctx; - const struct gl_client_array **array; - const struct _mesa_prim *prim; - GLuint nr_prims; - const struct _mesa_index_buffer *ib; - vbo_draw_func draw; - - const struct split_limits *limits; - - struct { - GLuint attr; - GLuint size; - const struct gl_client_array *array; - const GLubyte *src_ptr; - - struct gl_client_array dstarray; - - } varying[VBO_ATTRIB_MAX]; - GLuint nr_varying; - - const struct gl_client_array *dstarray_ptr[VBO_ATTRIB_MAX]; - struct _mesa_index_buffer dstib; - - GLuint *translated_elt_buf; - const GLuint *srcelt; - - /** A baby hash table to avoid re-emitting (some) duplicate - * vertices when splitting indexed primitives. - */ - struct { - GLuint in; - GLuint out; - } vert_cache[ELT_TABLE_SIZE]; - - GLuint vertex_size; - GLubyte *dstbuf; - GLubyte *dstptr; /**< dstptr == dstbuf + dstelt_max * vertsize */ - GLuint dstbuf_size; /**< in vertices */ - GLuint dstbuf_nr; /**< count of emitted vertices, also the largest value - * in dstelt. Our MaxIndex. - */ - - GLuint *dstelt; - GLuint dstelt_nr; - GLuint dstelt_size; - -#define MAX_PRIM 32 - struct _mesa_prim dstprim[MAX_PRIM]; - GLuint dstprim_nr; - -}; - - -static GLuint attr_size( const struct gl_client_array *array ) -{ - return array->Size * _mesa_sizeof_type(array->Type); -} - - -/** - * Starts returning true slightly before the buffer fills, to ensure - * that there is sufficient room for any remaining vertices to finish - * off the prim: - */ -static GLboolean -check_flush( struct copy_context *copy ) -{ - GLenum mode = copy->dstprim[copy->dstprim_nr].mode; - - if (GL_TRIANGLE_STRIP == mode && - copy->dstelt_nr & 1) { /* see bug9962 */ - return GL_FALSE; - } - - if (copy->dstbuf_nr + 4 > copy->dstbuf_size) - return GL_TRUE; - - if (copy->dstelt_nr + 4 > copy->dstelt_size) - return GL_TRUE; - - return GL_FALSE; -} - - -/** - * Dump the parameters/info for a vbo->draw() call. - */ -static void -dump_draw_info(struct gl_context *ctx, - const struct gl_client_array **arrays, - const struct _mesa_prim *prims, - GLuint nr_prims, - const struct _mesa_index_buffer *ib, - GLuint min_index, - GLuint max_index) -{ - GLuint i, j; - - printf("VBO Draw:\n"); - for (i = 0; i < nr_prims; i++) { - printf("Prim %u of %u\n", i, nr_prims); - printf(" Prim mode 0x%x\n", prims[i].mode); - printf(" IB: %p\n", (void*) ib); - for (j = 0; j < VBO_ATTRIB_MAX; j++) { - printf(" array %d at %p:\n", j, (void*) arrays[j]); - printf(" enabled %d, ptr %p, size %d, type 0x%x, stride %d\n", - arrays[j]->Enabled, arrays[j]->Ptr, - arrays[j]->Size, arrays[j]->Type, arrays[j]->StrideB); - if (0) { - GLint k = prims[i].start + prims[i].count - 1; - GLfloat *last = (GLfloat *) (arrays[j]->Ptr + arrays[j]->Stride * k); - printf(" last: %f %f %f\n", - last[0], last[1], last[2]); - } - } - } -} - - -static void -flush( struct copy_context *copy ) -{ - GLuint i; - - /* Set some counters: - */ - copy->dstib.count = copy->dstelt_nr; - -#if 0 - dump_draw_info(copy->ctx, - copy->dstarray_ptr, - copy->dstprim, - copy->dstprim_nr, - ©->dstib, - 0, - copy->dstbuf_nr); -#else - (void) dump_draw_info; -#endif - - copy->draw( copy->ctx, - copy->dstarray_ptr, - copy->dstprim, - copy->dstprim_nr, - ©->dstib, - GL_TRUE, - 0, - copy->dstbuf_nr - 1); - - /* Reset all pointers: - */ - copy->dstprim_nr = 0; - copy->dstelt_nr = 0; - copy->dstbuf_nr = 0; - copy->dstptr = copy->dstbuf; - - /* Clear the vertex cache: - */ - for (i = 0; i < ELT_TABLE_SIZE; i++) - copy->vert_cache[i].in = ~0; -} - - -/** - * Called at begin of each primitive during replay. - */ -static void -begin( struct copy_context *copy, GLenum mode, GLboolean begin_flag ) -{ - struct _mesa_prim *prim = ©->dstprim[copy->dstprim_nr]; - - prim->mode = mode; - prim->begin = begin_flag; - prim->num_instances = 1; -} - - -/** - * Use a hashtable to attempt to identify recently-emitted vertices - * and avoid re-emitting them. - */ -static GLuint -elt(struct copy_context *copy, GLuint elt_idx) -{ - GLuint elt = copy->srcelt[elt_idx]; - GLuint slot = elt & (ELT_TABLE_SIZE-1); - -/* printf("elt %d\n", elt); */ - - /* Look up the incoming element in the vertex cache. Re-emit if - * necessary. - */ - if (copy->vert_cache[slot].in != elt) { - GLubyte *csr = copy->dstptr; - GLuint i; - -/* printf(" --> emit to dstelt %d\n", copy->dstbuf_nr); */ - - for (i = 0; i < copy->nr_varying; i++) { - const struct gl_client_array *srcarray = copy->varying[i].array; - const GLubyte *srcptr = copy->varying[i].src_ptr + elt * srcarray->StrideB; - - memcpy(csr, srcptr, copy->varying[i].size); - csr += copy->varying[i].size; - -#ifdef NAN_CHECK - if (srcarray->Type == GL_FLOAT) { - GLuint k; - GLfloat *f = (GLfloat *) srcptr; - for (k = 0; k < srcarray->Size; k++) { - assert(!IS_INF_OR_NAN(f[k])); - assert(f[k] <= 1.0e20 && f[k] >= -1.0e20); - } - } -#endif - - if (0) - { - const GLuint *f = (const GLuint *)srcptr; - GLuint j; - printf(" varying %d: ", i); - for(j = 0; j < copy->varying[i].size / 4; j++) - printf("%x ", f[j]); - printf("\n"); - } - } - - copy->vert_cache[slot].in = elt; - copy->vert_cache[slot].out = copy->dstbuf_nr++; - copy->dstptr += copy->vertex_size; - - assert(csr == copy->dstptr); - assert(copy->dstptr == (copy->dstbuf + - copy->dstbuf_nr * copy->vertex_size)); - } -/* else */ -/* printf(" --> reuse vertex\n"); */ - -/* printf(" --> emit %d\n", copy->vert_cache[slot].out); */ - copy->dstelt[copy->dstelt_nr++] = copy->vert_cache[slot].out; - return check_flush(copy); -} - - -/** - * Called at end of each primitive during replay. - */ -static void -end( struct copy_context *copy, GLboolean end_flag ) -{ - struct _mesa_prim *prim = ©->dstprim[copy->dstprim_nr]; - -/* printf("end (%d)\n", end_flag); */ - - prim->end = end_flag; - prim->count = copy->dstelt_nr - prim->start; - - if (++copy->dstprim_nr == MAX_PRIM || - check_flush(copy)) - flush(copy); -} - - -static void -replay_elts( struct copy_context *copy ) -{ - GLuint i, j, k; - GLboolean split; - - for (i = 0; i < copy->nr_prims; i++) { - const struct _mesa_prim *prim = ©->prim[i]; - const GLuint start = prim->start; - GLuint first, incr; - - switch (prim->mode) { - - case GL_LINE_LOOP: - /* Convert to linestrip and emit the final vertex explicitly, - * but only in the resultant strip that requires it. - */ - j = 0; - while (j != prim->count) { - begin(copy, GL_LINE_STRIP, prim->begin && j == 0); - - for (split = GL_FALSE; j != prim->count && !split; j++) - split = elt(copy, start + j); - - if (j == prim->count) { - /* Done, emit final line. Split doesn't matter as - * it is always raised a bit early so we can emit - * the last verts if necessary! - */ - if (prim->end) - (void)elt(copy, start + 0); - - end(copy, prim->end); - } - else { - /* Wrap - */ - assert(split); - end(copy, 0); - j--; - } - } - break; - - case GL_TRIANGLE_FAN: - case GL_POLYGON: - j = 2; - while (j != prim->count) { - begin(copy, prim->mode, prim->begin && j == 0); - - split = elt(copy, start+0); - assert(!split); - - split = elt(copy, start+j-1); - assert(!split); - - for (; j != prim->count && !split; j++) - split = elt(copy, start+j); - - end(copy, prim->end && j == prim->count); - - if (j != prim->count) { - /* Wrapped the primitive, need to repeat some vertices: - */ - j -= 1; - } - } - break; - - default: - (void)split_prim_inplace(prim->mode, &first, &incr); - - j = 0; - while (j != prim->count) { - - begin(copy, prim->mode, prim->begin && j == 0); - - split = 0; - for (k = 0; k < first; k++, j++) - split |= elt(copy, start+j); - - assert(!split); - - for (; j != prim->count && !split; ) - for (k = 0; k < incr; k++, j++) - split |= elt(copy, start+j); - - end(copy, prim->end && j == prim->count); - - if (j != prim->count) { - /* Wrapped the primitive, need to repeat some vertices: - */ - assert(j > first - incr); - j -= (first - incr); - } - } - break; - } - } - - if (copy->dstprim_nr) - flush(copy); -} - - -static void -replay_init( struct copy_context *copy ) -{ - struct gl_context *ctx = copy->ctx; - GLuint i; - GLuint offset; - const GLvoid *srcptr; - - /* Make a list of varying attributes and their vbo's. Also - * calculate vertex size. - */ - copy->vertex_size = 0; - for (i = 0; i < VBO_ATTRIB_MAX; i++) { - struct gl_buffer_object *vbo = copy->array[i]->BufferObj; - - if (copy->array[i]->StrideB == 0) { - copy->dstarray_ptr[i] = copy->array[i]; - } - else { - GLuint j = copy->nr_varying++; - - copy->varying[j].attr = i; - copy->varying[j].array = copy->array[i]; - copy->varying[j].size = attr_size(copy->array[i]); - copy->vertex_size += attr_size(copy->array[i]); - - if (_mesa_is_bufferobj(vbo) && !_mesa_bufferobj_mapped(vbo)) - ctx->Driver.MapBufferRange(ctx, 0, vbo->Size, GL_MAP_READ_BIT, vbo); - - copy->varying[j].src_ptr = ADD_POINTERS(vbo->Pointer, - copy->array[i]->Ptr); - - copy->dstarray_ptr[i] = ©->varying[j].dstarray; - } - } - - /* There must always be an index buffer. Currently require the - * caller convert non-indexed prims to indexed. Could alternately - * do it internally. - */ - if (_mesa_is_bufferobj(copy->ib->obj) && - !_mesa_bufferobj_mapped(copy->ib->obj)) - ctx->Driver.MapBufferRange(ctx, 0, copy->ib->obj->Size, GL_MAP_READ_BIT, - copy->ib->obj); - - srcptr = (const GLubyte *) ADD_POINTERS(copy->ib->obj->Pointer, - copy->ib->ptr); - - switch (copy->ib->type) { - case GL_UNSIGNED_BYTE: - copy->translated_elt_buf = malloc(sizeof(GLuint) * copy->ib->count); - copy->srcelt = copy->translated_elt_buf; - - for (i = 0; i < copy->ib->count; i++) - copy->translated_elt_buf[i] = ((const GLubyte *)srcptr)[i]; - break; - - case GL_UNSIGNED_SHORT: - copy->translated_elt_buf = malloc(sizeof(GLuint) * copy->ib->count); - copy->srcelt = copy->translated_elt_buf; - - for (i = 0; i < copy->ib->count; i++) - copy->translated_elt_buf[i] = ((const GLushort *)srcptr)[i]; - break; - - case GL_UNSIGNED_INT: - copy->translated_elt_buf = NULL; - copy->srcelt = (const GLuint *)srcptr; - break; - } - - /* Figure out the maximum allowed vertex buffer size: - */ - if (copy->vertex_size * copy->limits->max_verts <= copy->limits->max_vb_size) { - copy->dstbuf_size = copy->limits->max_verts; - } - else { - copy->dstbuf_size = copy->limits->max_vb_size / copy->vertex_size; - } - - /* Allocate an output vertex buffer: - * - * XXX: This should be a VBO! - */ - copy->dstbuf = malloc(copy->dstbuf_size * copy->vertex_size); - copy->dstptr = copy->dstbuf; - - /* Setup new vertex arrays to point into the output buffer: - */ - for (offset = 0, i = 0; i < copy->nr_varying; i++) { - const struct gl_client_array *src = copy->varying[i].array; - struct gl_client_array *dst = ©->varying[i].dstarray; - - dst->Size = src->Size; - dst->Type = src->Type; - dst->Stride = copy->vertex_size; - dst->StrideB = copy->vertex_size; - dst->Ptr = copy->dstbuf + offset; - dst->Enabled = GL_TRUE; - dst->Normalized = src->Normalized; - dst->Integer = src->Integer; - dst->BufferObj = ctx->Shared->NullBufferObj; - dst->_ElementSize = src->_ElementSize; - dst->_MaxElement = copy->dstbuf_size; /* may be less! */ - - offset += copy->varying[i].size; - } - - /* Allocate an output element list: - */ - copy->dstelt_size = MIN2(65536, - copy->ib->count * 2 + 3); - copy->dstelt_size = MIN2(copy->dstelt_size, - copy->limits->max_indices); - copy->dstelt = malloc(sizeof(GLuint) * copy->dstelt_size); - copy->dstelt_nr = 0; - - /* Setup the new index buffer to point to the allocated element - * list: - */ - copy->dstib.count = 0; /* duplicates dstelt_nr */ - copy->dstib.type = GL_UNSIGNED_INT; - copy->dstib.obj = ctx->Shared->NullBufferObj; - copy->dstib.ptr = copy->dstelt; -} - - -/** - * Free up everything allocated during split/replay. - */ -static void -replay_finish( struct copy_context *copy ) -{ - struct gl_context *ctx = copy->ctx; - GLuint i; - - /* Free our vertex and index buffers: - */ - free(copy->translated_elt_buf); - free(copy->dstbuf); - free(copy->dstelt); - - /* Unmap VBO's - */ - for (i = 0; i < copy->nr_varying; i++) { - struct gl_buffer_object *vbo = copy->varying[i].array->BufferObj; - if (_mesa_is_bufferobj(vbo) && _mesa_bufferobj_mapped(vbo)) - ctx->Driver.UnmapBuffer(ctx, vbo); - } - - /* Unmap index buffer: - */ - if (_mesa_is_bufferobj(copy->ib->obj) && - _mesa_bufferobj_mapped(copy->ib->obj)) { - ctx->Driver.UnmapBuffer(ctx, copy->ib->obj); - } -} - - -/** - * Split VBO into smaller pieces, draw the pieces. - */ -void vbo_split_copy( struct gl_context *ctx, - const struct gl_client_array *arrays[], - const struct _mesa_prim *prim, - GLuint nr_prims, - const struct _mesa_index_buffer *ib, - vbo_draw_func draw, - const struct split_limits *limits ) -{ - struct copy_context copy; - GLuint i; - - memset(©, 0, sizeof(copy)); - - /* Require indexed primitives: - */ - assert(ib); - - copy.ctx = ctx; - copy.array = arrays; - copy.prim = prim; - copy.nr_prims = nr_prims; - copy.ib = ib; - copy.draw = draw; - copy.limits = limits; - - /* Clear the vertex cache: - */ - for (i = 0; i < ELT_TABLE_SIZE; i++) - copy.vert_cache[i].in = ~0; - - replay_init(©); - replay_elts(©); - replay_finish(©); -} diff --git a/dll/opengl/mesa/vbo/vbo_split_inplace.c b/dll/opengl/mesa/vbo/vbo_split_inplace.c deleted file mode 100644 index 21fe041b37e..00000000000 --- a/dll/opengl/mesa/vbo/vbo_split_inplace.c +++ /dev/null @@ -1,279 +0,0 @@ - -/* - * Mesa 3-D graphics library - * Version: 6.5 - * - * Copyright (C) 1999-2006 Brian Paul All Rights Reserved. - * - * Permission is hereby granted, free of charge, to any person obtaining a - * copy of this software and associated documentation files (the "Software"), - * to deal in the Software without restriction, including without limitation - * the rights to use, copy, modify, merge, publish, distribute, sublicense, - * and/or sell copies of the Software, and to permit persons to whom the - * Software is furnished to do so, subject to the following conditions: - * - * The above copyright notice and this permission notice shall be included - * in all copies or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS - * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL - * BRIAN PAUL BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN - * AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN - * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. - * - * Authors: - * Keith Whitwell - */ - -#include - -#define MAX_PRIM 32 - -/* Used for splitting without copying. No attempt is made to handle - * too large indexed vertex buffers: In general you need to copy to do - * that. - */ -struct split_context { - struct gl_context *ctx; - const struct gl_client_array **array; - const struct _mesa_prim *prim; - GLuint nr_prims; - const struct _mesa_index_buffer *ib; - GLuint min_index; - GLuint max_index; - vbo_draw_func draw; - - const struct split_limits *limits; - GLuint limit; - - struct _mesa_prim dstprim[MAX_PRIM]; - GLuint dstprim_nr; -}; - - - - -static void flush_vertex( struct split_context *split ) -{ - struct _mesa_index_buffer ib; - GLuint i; - - if (!split->dstprim_nr) - return; - - if (split->ib) { - ib = *split->ib; - - ib.count = split->max_index - split->min_index + 1; - ib.ptr = (const void *)((const char *)ib.ptr + - split->min_index * _mesa_sizeof_type(ib.type)); - - /* Rebase the primitives to save index buffer entries. */ - for (i = 0; i < split->dstprim_nr; i++) - split->dstprim[i].start -= split->min_index; - } - - assert(split->max_index >= split->min_index); - - split->draw(split->ctx, - split->array, - split->dstprim, - split->dstprim_nr, - split->ib ? &ib : NULL, - !split->ib, - split->min_index, - split->max_index); - - split->dstprim_nr = 0; - split->min_index = ~0; - split->max_index = 0; -} - - -static struct _mesa_prim *next_outprim( struct split_context *split ) -{ - if (split->dstprim_nr == MAX_PRIM-1) { - flush_vertex(split); - } - - { - struct _mesa_prim *prim = &split->dstprim[split->dstprim_nr++]; - memset(prim, 0, sizeof(*prim)); - return prim; - } -} - -static void update_index_bounds(struct split_context *split, - const struct _mesa_prim *prim) -{ - split->min_index = MIN2(split->min_index, prim->start); - split->max_index = MAX2(split->max_index, prim->start + prim->count - 1); -} - -/* Return the maximum amount of vertices that can be emitted for a - * primitive starting at 'prim->start', depending on the previous - * index bounds. - */ -static GLuint get_max_vertices(struct split_context *split, - const struct _mesa_prim *prim) -{ - if ((prim->start > split->min_index && - prim->start - split->min_index >= split->limit) || - (prim->start < split->max_index && - split->max_index - prim->start >= split->limit)) - /* "prim" starts too far away from the old range. */ - return 0; - - return MIN2(split->min_index, prim->start) + split->limit - prim->start; -} - -/* Break large primitives into smaller ones. If not possible, convert - * the primitive to indexed and pass to split_elts(). - */ -static void split_prims( struct split_context *split) -{ - GLuint i; - - for (i = 0; i < split->nr_prims; i++) { - const struct _mesa_prim *prim = &split->prim[i]; - GLuint first, incr; - GLboolean split_inplace = split_prim_inplace(prim->mode, &first, &incr); - GLuint available = get_max_vertices(split, prim); - GLuint count = prim->count - (prim->count - first) % incr; - - if (prim->count < first) - continue; - - if ((available < count && !split_inplace) || - (available < first && split_inplace)) { - flush_vertex(split); - available = get_max_vertices(split, prim); - } - - if (available >= count) { - struct _mesa_prim *outprim = next_outprim(split); - - *outprim = *prim; - update_index_bounds(split, outprim); - } - else if (split_inplace) { - GLuint j, nr; - - for (j = 0 ; j < count ; ) { - GLuint remaining = count - j; - struct _mesa_prim *outprim = next_outprim(split); - - nr = MIN2( available, remaining ); - nr -= (nr - first) % incr; - - outprim->mode = prim->mode; - outprim->begin = (j == 0 && prim->begin); - outprim->end = (nr == remaining && prim->end); - outprim->start = prim->start + j; - outprim->count = nr; - outprim->num_instances = prim->num_instances; - - update_index_bounds(split, outprim); - - if (nr == remaining) { - /* Finished. - */ - j += nr; - } - else { - /* Wrapped the primitive: - */ - j += nr - (first - incr); - flush_vertex(split); - available = get_max_vertices(split, prim); - } - } - } - else if (split->ib == NULL) { - /* XXX: could at least send the first max_verts off from the - * inplace buffers. - */ - - /* else convert to indexed primitive and pass to split_elts, - * which will do the necessary copying and turn it back into a - * vertex primitive for rendering... - */ - struct _mesa_index_buffer ib; - struct _mesa_prim tmpprim; - GLuint *elts = malloc(count * sizeof(GLuint)); - GLuint j; - - for (j = 0; j < count; j++) - elts[j] = prim->start + j; - - ib.count = count; - ib.type = GL_UNSIGNED_INT; - ib.obj = split->ctx->Shared->NullBufferObj; - ib.ptr = elts; - - tmpprim = *prim; - tmpprim.indexed = 1; - tmpprim.start = 0; - tmpprim.count = count; - tmpprim.num_instances = 1; - - flush_vertex(split); - - vbo_split_copy(split->ctx, - split->array, - &tmpprim, 1, - &ib, - split->draw, - split->limits); - - free(elts); - } - else { - flush_vertex(split); - - vbo_split_copy(split->ctx, - split->array, - prim, 1, - split->ib, - split->draw, - split->limits); - } - } - - flush_vertex(split); -} - - -void vbo_split_inplace( struct gl_context *ctx, - const struct gl_client_array *arrays[], - const struct _mesa_prim *prim, - GLuint nr_prims, - const struct _mesa_index_buffer *ib, - GLuint min_index, - GLuint max_index, - vbo_draw_func draw, - const struct split_limits *limits ) -{ - struct split_context split; - - memset(&split, 0, sizeof(split)); - - split.ctx = ctx; - split.array = arrays; - split.prim = prim; - split.nr_prims = nr_prims; - split.ib = ib; - - /* Empty interval, makes calculations simpler. */ - split.min_index = ~0; - split.max_index = 0; - - split.draw = draw; - split.limits = limits; - split.limit = ib ? limits->max_indices : limits->max_verts; - - split_prims( &split ); -} - - diff --git a/dll/opengl/mesa/vbrender.c b/dll/opengl/mesa/vbrender.c new file mode 100644 index 00000000000..f24a8181412 --- /dev/null +++ b/dll/opengl/mesa/vbrender.c @@ -0,0 +1,1310 @@ +/* $Id: vbrender.c,v 1.21 1998/01/18 15:04:48 brianp Exp $ */ + +/* + * Mesa 3-D graphics library + * Version: 2.6 + * Copyright (C) 1995-1997 Brian Paul + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Library General Public + * License as published by the Free Software Foundation; either + * version 2 of the License, or (at your option) any later version. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Library General Public License for more details. + * + * You should have received a copy of the GNU Library General Public + * License along with this library; if not, write to the Free + * Software Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. + */ + + +/* + * $Log: vbrender.c,v $ + * Revision 1.21 1998/01/18 15:04:48 brianp + * fixed clipmask bug in gl_reset_vb() (reported by Michael Callahan) + * + * Revision 1.20 1998/01/09 02:49:33 brianp + * cleaned-up gl_reset_vb(), added small GL_POLYGON optimization + * + * Revision 1.19 1997/12/29 23:49:57 brianp + * added a call to gl_update_lighting() in gl_reset_vb() to fix material bug + * + * Revision 1.18 1997/12/19 03:36:42 brianp + * check bit-wise AND of vertex clip masks to cull polygons sooner + * + * Revision 1.17 1997/12/09 02:56:57 brianp + * in render_clipped_polygon() only recompute window coords for new verts + * + * Revision 1.16 1997/11/20 00:00:47 brianp + * only call Driver.RasterSetup() once in render_clipped_polygon() + * + * Revision 1.15 1997/09/18 01:32:47 brianp + * fixed divide by zero problem for "weird" projection matrices + * + * Revision 1.14 1997/08/13 01:31:41 brianp + * cleaned up code involving LightTwoSide + * + * Revision 1.13 1997/07/24 01:25:27 brianp + * changed precompiled header symbol from PCH to PC_HEADER + * + * Revision 1.12 1997/07/11 02:19:52 brianp + * flat-shaded quads in a strip were miscolored if clipped (Randy Frank) + * + * Revision 1.11 1997/05/28 03:26:49 brianp + * added precompiled header (PCH) support + * + * Revision 1.10 1997/05/16 02:09:26 brianp + * clipped GL_TRIANGLE_STRIP triangles sometimes got wrong provoking vertex + * + * Revision 1.9 1997/04/30 02:20:00 brianp + * fixed a line clipping bug in GL_LINE_LOOPs + * + * Revision 1.8 1997/04/29 01:31:07 brianp + * added RasterSetup() function to device driver + * + * Revision 1.7 1997/04/24 00:30:17 brianp + * optimized glTexCoord2() code + * + * Revision 1.6 1997/04/20 19:47:06 brianp + * fixed an error message, added a comment + * + * Revision 1.5 1997/04/20 15:59:30 brianp + * removed VERTEX2_BIT stuff + * + * Revision 1.4 1997/04/20 15:27:34 brianp + * removed odd_flag from all polygon rendering functions + * + * Revision 1.3 1997/04/12 12:26:06 brianp + * now directly call ctx->Driver.Points/Line/Triangle/QuadFunc + * + * Revision 1.2 1997/04/07 03:01:11 brianp + * optimized vertex[234] code + * + * Revision 1.1 1997/04/02 03:14:14 brianp + * Initial revision + * + */ + + +/* + * Render points, lines, and polygons. The only entry point to this + * file is the gl_render_vb() function. This function is called after + * the vertex buffer has filled up or glEnd() has been called. + * + * This file basically only makes calls to the clipping functions and + * the point, line and triangle rasterizers via the function pointers. + * context->Driver.PointsFunc() + * context->Driver.LineFunc() + * context->Driver.TriangleFunc() + */ + + +#ifdef PC_HEADER +#include "all.h" +#else +#include "clip.h" +#include "context.h" +#include "light.h" +#include "macros.h" +#include "matrix.h" +#include "pb.h" +#include "types.h" +#include "vb.h" +#include "vbrender.h" +#include "xform.h" +#endif + + +/* + * This file implements rendering of points, lines and polygons defined by + * vertices in the vertex buffer. + */ + + + +#ifdef PROFILE +# define START_PROFILE \ + { \ + GLdouble t0 = gl_time(); + +# define END_PROFILE( TIMER, COUNTER, INCR ) \ + TIMER += (gl_time() - t0); \ + COUNTER += INCR; \ + } +#else +# define START_PROFILE +# define END_PROFILE( TIMER, COUNTER, INCR ) +#endif + + + + +/* + * Render a line segment from VB[v1] to VB[v2] when either one or both + * endpoints must be clipped. + */ +static void render_clipped_line( GLcontext *ctx, GLuint v1, GLuint v2 ) +{ + GLfloat ndc_x, ndc_y, ndc_z; + GLuint provoking_vertex; + struct vertex_buffer *VB = ctx->VB; + + /* which vertex dictates the color when flat shading: */ + provoking_vertex = v2; + + /* + * Clipping may introduce new vertices. New vertices will be stored + * in the vertex buffer arrays starting with location VB->Free. After + * we've rendered the line, these extra vertices can be overwritten. + */ + VB->Free = VB_MAX; + + /* Clip against user clipping planes */ + if (ctx->Transform.AnyClip) { + GLuint orig_v1 = v1, orig_v2 = v2; + if (gl_userclip_line( ctx, &v1, &v2 )==0) + return; + /* Apply projection matrix: clip = Proj * eye */ + if (v1!=orig_v1) { + TRANSFORM_POINT( VB->Clip[v1], ctx->ProjectionMatrix, VB->Eye[v1] ); + } + if (v2!=orig_v2) { + TRANSFORM_POINT( VB->Clip[v2], ctx->ProjectionMatrix, VB->Eye[v2] ); + } + } + + /* Clip against view volume */ + if (gl_viewclip_line( ctx, &v1, &v2 )==0) + return; + + /* Transform from clip coords to ndc: ndc = clip / W */ + if (VB->Clip[v1][3] != 0.0F) { + GLfloat wInv = 1.0F / VB->Clip[v1][3]; + ndc_x = VB->Clip[v1][0] * wInv; + ndc_y = VB->Clip[v1][1] * wInv; + ndc_z = VB->Clip[v1][2] * wInv; + } + else { + /* Can't divide by zero, so... */ + ndc_x = ndc_y = ndc_z = 0.0F; + } + + /* Map ndc coord to window coords. */ + VB->Win[v1][0] = ndc_x * ctx->Viewport.Sx + ctx->Viewport.Tx; + VB->Win[v1][1] = ndc_y * ctx->Viewport.Sy + ctx->Viewport.Ty; + VB->Win[v1][2] = ndc_z * ctx->Viewport.Sz + ctx->Viewport.Tz; + + /* Transform from clip coords to ndc: ndc = clip / W */ + if (VB->Clip[v2][3] != 0.0F) { + GLfloat wInv = 1.0F / VB->Clip[v2][3]; + ndc_x = VB->Clip[v2][0] * wInv; + ndc_y = VB->Clip[v2][1] * wInv; + ndc_z = VB->Clip[v2][2] * wInv; + } + else { + /* Can't divide by zero, so... */ + ndc_x = ndc_y = ndc_z = 0.0F; + } + + /* Map ndc coord to window coords. */ + VB->Win[v2][0] = ndc_x * ctx->Viewport.Sx + ctx->Viewport.Tx; + VB->Win[v2][1] = ndc_y * ctx->Viewport.Sy + ctx->Viewport.Ty; + VB->Win[v2][2] = ndc_z * ctx->Viewport.Sz + ctx->Viewport.Tz; + + if (ctx->Driver.RasterSetup) { + /* Device driver rasterization setup */ + (*ctx->Driver.RasterSetup)( ctx, v1, v1+1 ); + (*ctx->Driver.RasterSetup)( ctx, v2, v2+1 ); + } + + START_PROFILE + (*ctx->Driver.LineFunc)( ctx, v1, v2, provoking_vertex ); + END_PROFILE( ctx->LineTime, ctx->LineCount, 1 ) +} + + + +/* + * Compute Z offsets for a polygon with plane defined by (A,B,C,D) + * D is not needed. + */ +static void offset_polygon( GLcontext *ctx, GLfloat a, GLfloat b, GLfloat c ) +{ + GLfloat ac, bc, m; + GLfloat offset; + + if (c<0.001F && c>-0.001F) { + /* to prevent underflow problems */ + offset = 0.0F; + } + else { + ac = a / c; + bc = b / c; + if (ac<0.0F) ac = -ac; + if (bc<0.0F) bc = -bc; + m = MAX2( ac, bc ); + /* m = sqrt( ac*ac + bc*bc ); */ + + offset = m * ctx->Polygon.OffsetFactor + ctx->Polygon.OffsetUnits; + } + + ctx->PointZoffset = ctx->Polygon.OffsetPoint ? offset : 0.0F; + ctx->LineZoffset = ctx->Polygon.OffsetLine ? offset : 0.0F; + ctx->PolygonZoffset = ctx->Polygon.OffsetFill ? offset : 0.0F; +} + + + +/* + * When glPolygonMode() is used to specify that the front/back rendering + * mode for polygons is not GL_FILL we end up calling this function. + */ +static void unfilled_polygon( GLcontext *ctx, + GLuint n, GLuint vlist[], + GLuint pv, GLuint facing ) +{ + GLenum mode = facing ? ctx->Polygon.BackMode : ctx->Polygon.FrontMode; + struct vertex_buffer *VB = ctx->VB; + + if (mode==GL_POINT) { + GLint i, j; + GLboolean edge; + + if ( ctx->Primitive==GL_TRIANGLES + || ctx->Primitive==GL_QUADS + || ctx->Primitive==GL_POLYGON) { + edge = GL_FALSE; + } + else { + edge = GL_TRUE; + } + + for (i=0;iEdgeflag[j]) { + (*ctx->Driver.PointsFunc)( ctx, j, j ); + } + } + } + else if (mode==GL_LINE) { + GLuint i, j0, j1; + GLboolean edge; + + ctx->StippleCounter = 0; + + if ( ctx->Primitive==GL_TRIANGLES + || ctx->Primitive==GL_QUADS + || ctx->Primitive==GL_POLYGON) { + edge = GL_FALSE; + } + else { + edge = GL_TRUE; + } + + /* draw the edges */ + for (i=0;iEdgeflag[j0]) { + START_PROFILE + (*ctx->Driver.LineFunc)( ctx, j0, j1, pv ); + END_PROFILE( ctx->LineTime, ctx->LineCount, 1 ) + } + } + } + else { + /* Fill the polygon */ + GLuint j0, i; + j0 = vlist[0]; + for (i=2;iDriver.TriangleFunc)( ctx, j0, vlist[i-1], vlist[i], pv ); + END_PROFILE( ctx->PolygonTime, ctx->PolygonCount, 1 ) + } + } +} + + +/* + * Compute signed area of the n-sided polgyon specified by vertices vb->Win[] + * and vertex list vlist[]. + * A clockwise polygon will return a negative area. + * A counter-clockwise polygon will return a positive area. + */ +static GLfloat polygon_area( const struct vertex_buffer *vb, + GLuint n, const GLuint vlist[] ) +{ + GLfloat area = 0.0F; + GLint i; + for (i=0;iWin[j0][0]; + GLfloat y0 = vb->Win[j0][1]; + GLfloat x1 = vb->Win[j1][0]; + GLfloat y1 = vb->Win[j1][1]; + GLfloat trapArea = (x0-x1)*(y0+y1); /* Note: no divide by two here! */ + area += trapArea; + } + return area * 0.5F; /* divide by two now! */ +} + + +/* + * Render a polygon in which doesn't have to be clipped. + * Input: n - number of vertices + * vlist - list of vertices in the polygon. + */ +static void render_polygon( GLcontext *ctx, GLuint n, GLuint vlist[] ) +{ + struct vertex_buffer *VB = ctx->VB; + GLuint pv; + + /* which vertex dictates the color when flat shading: */ + pv = (ctx->Primitive==GL_POLYGON) ? vlist[0] : vlist[n-1]; + + /* Compute orientation of polygon, do cull test, offset, etc */ + { + GLuint facing; /* 0=front, 1=back */ + GLfloat area = polygon_area( VB, n, vlist ); + + if (area==0.0F) { + /* polygon has zero area, don't draw it */ + return; + } + + facing = (area<0.0F) ^ (ctx->Polygon.FrontFace==GL_CW); + + if ((facing+1) & ctx->Polygon.CullBits) { + return; /* culled */ + } + + if (ctx->Polygon.OffsetAny) { + /* compute plane equation of polygon, apply offset */ + GLuint j0 = vlist[0]; + GLuint j1 = vlist[1]; + GLuint j2 = vlist[2]; + GLuint j3 = vlist[ (n==3) ? 0 : 3 ]; + GLfloat ex = VB->Win[j1][0] - VB->Win[j3][0]; + GLfloat ey = VB->Win[j1][1] - VB->Win[j3][1]; + GLfloat ez = VB->Win[j1][2] - VB->Win[j3][2]; + GLfloat fx = VB->Win[j2][0] - VB->Win[j0][0]; + GLfloat fy = VB->Win[j2][1] - VB->Win[j0][1]; + GLfloat fz = VB->Win[j2][2] - VB->Win[j0][2]; + GLfloat a = ey*fz-ez*fy; + GLfloat b = ez*fx-ex*fz; + GLfloat c = ex*fy-ey*fx; + offset_polygon( ctx, a, b, c ); + } + + if (ctx->LightTwoSide) { + if (facing==1) { + /* use back color or index */ + VB->Color = VB->Bcolor; + VB->Index = VB->Bindex; + } + else { + /* use front color or index */ + VB->Color = VB->Fcolor; + VB->Index = VB->Findex; + } + } + + /* Render the polygon! */ + if (ctx->Polygon.Unfilled) { + unfilled_polygon( ctx, n, vlist, pv, facing ); + } + else { + /* Draw filled polygon as a triangle fan */ + GLint i; + GLuint j0 = vlist[0]; + for (i=2;iDriver.TriangleFunc)( ctx, j0, vlist[i-1], vlist[i], pv ); + END_PROFILE( ctx->PolygonTime, ctx->PolygonCount, 1 ) + } + } + } +} + + + +/* + * Render a polygon in which at least one vertex has to be clipped. + * Input: n - number of vertices + * vlist - list of vertices in the polygon. + * CCW order = front facing. + */ +static void render_clipped_polygon( GLcontext *ctx, GLuint n, GLuint vlist[] ) +{ + GLuint pv; + struct vertex_buffer *VB = ctx->VB; + GLfloat (*win)[3] = VB->Win; + + /* which vertex dictates the color when flat shading: */ + pv = (ctx->Primitive==GL_POLYGON) ? vlist[0] : vlist[n-1]; + + /* + * Clipping may introduce new vertices. New vertices will be stored + * in the vertex buffer arrays starting with location VB->Free. After + * we've rendered the polygon, these extra vertices can be overwritten. + */ + VB->Free = VB_MAX; + + /* Clip against user clipping planes in eye coord space. */ + if (ctx->Transform.AnyClip) { + GLfloat *proj = ctx->ProjectionMatrix; + GLuint i; + n = gl_userclip_polygon( ctx, n, vlist ); + if (n<3) + return; + /* Transform vertices from eye to clip coordinates: clip = Proj * eye */ + for (i=0;iClip[j], proj, VB->Eye[j] ); + } + } + + /* Clip against view volume in clip coord space */ + n = gl_viewclip_polygon( ctx, n, vlist ); + if (n<3) + return; + + /* Transform new vertices from clip to ndc to window coords. */ + /* ndc = clip / W window = viewport_mapping(ndc) */ + /* Note that window Z values are scaled to the range of integer */ + /* depth buffer values. */ + { + GLfloat sx = ctx->Viewport.Sx; + GLfloat tx = ctx->Viewport.Tx; + GLfloat sy = ctx->Viewport.Sy; + GLfloat ty = ctx->Viewport.Ty; + GLfloat sz = ctx->Viewport.Sz; + GLfloat tz = ctx->Viewport.Tz; + GLuint i; + /* Only need to compute window coords for new vertices */ + for (i=VB_MAX; iFree; i++) { + if (VB->Clip[i][3] != 0.0F) { + GLfloat wInv = 1.0F / VB->Clip[i][3]; + win[i][0] = VB->Clip[i][0] * wInv * sx + tx; + win[i][1] = VB->Clip[i][1] * wInv * sy + ty; + win[i][2] = VB->Clip[i][2] * wInv * sz + tz; + } + else { + /* Can't divide by zero, so... */ + win[i][0] = win[i][1] = win[i][2] = 0.0F; + } + } + if (ctx->Driver.RasterSetup && (VB->Free > VB_MAX)) { + /* Device driver raster setup for newly introduced vertices */ + (*ctx->Driver.RasterSetup)(ctx, VB_MAX, VB->Free); + } + +#ifdef DEBUG + { + int i, j; + for (i=0;iClipMask[j]) { + /* Uh oh! There should be no clip bits set in final polygon! */ + int k, l; + printf("CLIPMASK %d %d %02x\n", i, j, VB->ClipMask[j]); + printf("%f %f %f %f\n", VB->Eye[j][0], VB->Eye[j][1], + VB->Eye[j][2], VB->Eye[j][3]); + printf("%f %f %f %f\n", VB->Clip[j][0], VB->Clip[j][1], + VB->Clip[j][2], VB->Clip[j][3]); + for (k=0;kClipMask[l]); + } + } + } + } +#endif + } + + /* Compute orientation of polygon, do cull test, offset, etc */ + { + GLuint facing; /* 0=front, 1=back */ + GLfloat area = polygon_area( VB, n, vlist ); + + if (area==0.0F) { + /* polygon has zero area, don't draw it */ + return; + } + + facing = (area<0.0F) ^ (ctx->Polygon.FrontFace==GL_CW); + + if ((facing+1) & ctx->Polygon.CullBits) { + return; /* culled */ + } + + if (ctx->Polygon.OffsetAny) { + /* compute plane equation of polygon, apply offset */ + GLuint j0 = vlist[0]; + GLuint j1 = vlist[1]; + GLuint j2 = vlist[2]; + GLuint j3 = vlist[ (n==3) ? 0 : 3 ]; + GLfloat ex = win[j1][0] - win[j3][0]; + GLfloat ey = win[j1][1] - win[j3][1]; + GLfloat ez = win[j1][2] - win[j3][2]; + GLfloat fx = win[j2][0] - win[j0][0]; + GLfloat fy = win[j2][1] - win[j0][1]; + GLfloat fz = win[j2][2] - win[j0][2]; + GLfloat a = ey*fz-ez*fy; + GLfloat b = ez*fx-ex*fz; + GLfloat c = ex*fy-ey*fx; + offset_polygon( ctx, a, b, c ); + } + + if (ctx->LightTwoSide) { + if (facing==1) { + /* use back color or index */ + VB->Color = VB->Bcolor; + VB->Index = VB->Bindex; + } + else { + /* use front color or index */ + VB->Color = VB->Fcolor; + VB->Index = VB->Findex; + } + } + + /* Render the polygon! */ + if (ctx->Polygon.Unfilled) { + unfilled_polygon( ctx, n, vlist, pv, facing ); + } + else { + /* Draw filled polygon as a triangle fan */ + GLint i; + GLuint j0 = vlist[0]; + for (i=2;iDriver.TriangleFunc)( ctx, j0, vlist[i-1], vlist[i], pv ); + END_PROFILE( ctx->PolygonTime, ctx->PolygonCount, 1 ) + } + } + } +} + + + +/* + * Render an un-clipped triangle. + * v0, v1, v2 - vertex indexes. CCW order = front facing + * pv - provoking vertex + */ +static void render_triangle( GLcontext *ctx, + GLuint v0, GLuint v1, GLuint v2, GLuint pv ) +{ + struct vertex_buffer *VB = ctx->VB; + GLfloat ex, ey, fx, fy, c; + GLuint facing; /* 0=front, 1=back */ + GLfloat (*win)[3] = VB->Win; + + /* Compute orientation of triangle */ + ex = win[v1][0] - win[v0][0]; + ey = win[v1][1] - win[v0][1]; + fx = win[v2][0] - win[v0][0]; + fy = win[v2][1] - win[v0][1]; + c = ex*fy-ey*fx; + + if (c==0.0F) { + /* polygon is perpindicular to view plane, don't draw it */ + return; + } + + facing = (c<0.0F) ^ (ctx->Polygon.FrontFace==GL_CW); + + if ((facing+1) & ctx->Polygon.CullBits) { + return; /* culled */ + } + + if (ctx->Polygon.OffsetAny) { + /* finish computing plane equation of polygon, compute offset */ + GLfloat fz = win[v2][2] - win[v0][2]; + GLfloat ez = win[v1][2] - win[v0][2]; + GLfloat a = ey*fz-ez*fy; + GLfloat b = ez*fx-ex*fz; + offset_polygon( ctx, a, b, c ); + } + + if (ctx->LightTwoSide) { + if (facing==1) { + /* use back color or index */ + VB->Color = VB->Bcolor; + VB->Index = VB->Bindex; + } + else { + /* use front color or index */ + VB->Color = VB->Fcolor; + VB->Index = VB->Findex; + } + } + + if (ctx->Polygon.Unfilled) { + GLuint vlist[3]; + vlist[0] = v0; + vlist[1] = v1; + vlist[2] = v2; + unfilled_polygon( ctx, 3, vlist, pv, facing ); + } + else { + START_PROFILE + (*ctx->Driver.TriangleFunc)( ctx, v0, v1, v2, pv ); + END_PROFILE( ctx->PolygonTime, ctx->PolygonCount, 1 ) + } +} + + + +/* + * Render an un-clipped quadrilateral. + * v0, v1, v2, v3 : CCW order = front facing + * pv - provoking vertex + */ +static void render_quad( GLcontext *ctx, GLuint v0, GLuint v1, + GLuint v2, GLuint v3, GLuint pv ) +{ + struct vertex_buffer *VB = ctx->VB; + GLfloat ex, ey, fx, fy, c; + GLuint facing; /* 0=front, 1=back */ + GLfloat (*win)[3] = VB->Win; + + /* Compute polygon orientation */ + ex = win[v2][0] - win[v0][0]; + ey = win[v2][1] - win[v0][1]; + fx = win[v3][0] - win[v1][0]; + fy = win[v3][1] - win[v1][1]; + c = ex*fy-ey*fx; + + if (c==0.0F) { + /* polygon is perpindicular to view plane, don't draw it */ + return; + } + + facing = (c<0.0F) ^ (ctx->Polygon.FrontFace==GL_CW); + + if ((facing+1) & ctx->Polygon.CullBits) { + return; /* culled */ + } + + if (ctx->Polygon.OffsetAny) { + /* finish computing plane equation of polygon, compute offset */ + GLfloat ez = win[v2][2] - win[v0][2]; + GLfloat fz = win[v3][2] - win[v1][2]; + GLfloat a = ey*fz-ez*fy; + GLfloat b = ez*fx-ex*fz; + offset_polygon( ctx, a, b, c ); + } + + if (ctx->LightTwoSide) { + if (facing==1) { + /* use back color or index */ + VB->Color = VB->Bcolor; + VB->Index = VB->Bindex; + } + else { + /* use front color or index */ + VB->Color = VB->Fcolor; + VB->Index = VB->Findex; + } + } + + /* Render the quad! */ + if (ctx->Polygon.Unfilled) { + GLuint vlist[4]; + vlist[0] = v0; + vlist[1] = v1; + vlist[2] = v2; + vlist[3] = v3; + unfilled_polygon( ctx, 4, vlist, pv, facing ); + } + else { + START_PROFILE + (*ctx->Driver.QuadFunc)( ctx, v0, v1, v2, v3, pv ); + END_PROFILE( ctx->PolygonTime, ctx->PolygonCount, 2 ) + } +} + + + +/* + * When the vertex buffer is full, we transform/render it. Sometimes we + * have to copy the last vertex (or two) to the front of the vertex list + * to "continue" the primitive. For example: line or triangle strips. + * This function is a helper for that. + */ +static void copy_vertex( struct vertex_buffer *vb, GLuint dst, GLuint src ) +{ + COPY_4V( vb->Clip[dst], vb->Clip[src] ); + COPY_4V( vb->Eye[dst], vb->Eye[src] ); + COPY_3V( vb->Win[dst], vb->Win[src] ); + COPY_4V( vb->Fcolor[dst], vb->Fcolor[src] ); + COPY_4V( vb->Bcolor[dst], vb->Bcolor[src] ); + COPY_4V( vb->TexCoord[dst], vb->TexCoord[src] ); + vb->Findex[dst] = vb->Findex[src]; + vb->Bindex[dst] = vb->Bindex[src]; + vb->Edgeflag[dst] = vb->Edgeflag[src]; + vb->ClipMask[dst] = vb->ClipMask[src]; + vb->MaterialMask[dst] = vb->MaterialMask[src]; + vb->Material[dst][0] = vb->Material[src][0]; + vb->Material[dst][1] = vb->Material[src][1]; +} + + + + +/* + * Either the vertex buffer is full (VB->Count==VB_MAX) or glEnd() has been + * called. Render the primitives defined by the vertices and reset the + * buffer. + * + * This function won't be called if the device driver implements a + * RenderVB() function. If the device driver renders the vertex buffer + * then the driver must also call gl_reset_vb()! + * + * Input: allDone - GL_TRUE = caller is glEnd() + * GL_FALSE = calling because buffer is full. + */ +void gl_render_vb( GLcontext *ctx, GLboolean allDone ) +{ + struct vertex_buffer *VB = ctx->VB; + GLuint vlist[VB_SIZE]; + + switch (ctx->Primitive) { + case GL_POINTS: + START_PROFILE + (*ctx->Driver.PointsFunc)( ctx, 0, VB->Count-1 ); + END_PROFILE( ctx->PointTime, ctx->PointCount, VB->Count ) + break; + + case GL_LINES: + if (VB->ClipOrMask) { + GLuint i; + for (i=1;iCount;i+=2) { + if (VB->ClipMask[i-1] | VB->ClipMask[i]) { + render_clipped_line( ctx, i-1, i ); + } + else { + START_PROFILE + (*ctx->Driver.LineFunc)( ctx, i-1, i, i ); + END_PROFILE( ctx->LineTime, ctx->LineCount, 1 ) + } + ctx->StippleCounter = 0; + } + } + else { + GLuint i; + for (i=1;iCount;i+=2) { + START_PROFILE + (*ctx->Driver.LineFunc)( ctx, i-1, i, i ); + END_PROFILE( ctx->LineTime, ctx->LineCount, 1 ) + ctx->StippleCounter = 0; + } + } + break; + + case GL_LINE_STRIP: + if (VB->ClipOrMask) { + GLuint i; + for (i=1;iCount;i++) { + if (VB->ClipMask[i-1] | VB->ClipMask[i]) { + render_clipped_line( ctx, i-1, i ); + } + else { + START_PROFILE + (*ctx->Driver.LineFunc)( ctx, i-1, i, i ); + END_PROFILE( ctx->LineTime, ctx->LineCount, 1 ) + } + } + } + else { + /* no clipping needed */ + GLuint i; + for (i=1;iCount;i++) { + START_PROFILE + (*ctx->Driver.LineFunc)( ctx, i-1, i, i ); + END_PROFILE( ctx->LineTime, ctx->LineCount, 1 ) + } + } + break; + + case GL_LINE_LOOP: + { + GLuint i; + if (VB->Start==0) { + i = 1; /* start at 0th vertex */ + } + else { + i = 2; /* skip first vertex, we're saving it until glEnd */ + } + while (iCount) { + if (VB->ClipMask[i-1] | VB->ClipMask[i]) { + render_clipped_line( ctx, i-1, i ); + } + else { + START_PROFILE + (*ctx->Driver.LineFunc)( ctx, i-1, i, i ); + END_PROFILE( ctx->LineTime, ctx->LineCount, 1 ) + } + i++; + } + } + break; + + case GL_TRIANGLES: + if (VB->ClipOrMask) { + GLuint i; + for (i=2;iCount;i+=3) { + if (VB->ClipMask[i-2] & VB->ClipMask[i-1] + & VB->ClipMask[i] & CLIP_ALL_BITS) { + /* all points clipped by common plane */ + continue; + } + else if (VB->ClipMask[i-2] | VB->ClipMask[i-1] | VB->ClipMask[i]) { + vlist[0] = i-2; + vlist[1] = i-1; + vlist[2] = i-0; + render_clipped_polygon( ctx, 3, vlist ); + } + else { + if (ctx->DirectTriangles) { + START_PROFILE + (*ctx->Driver.TriangleFunc)( ctx, i-2, i-1, i, i ); + END_PROFILE( ctx->PolygonTime, ctx->PolygonCount, 1 ) + } + else { + render_triangle( ctx, i-2, i-1, i, i ); + } + } + } + } + else { + /* no clipping needed */ + GLuint i; + if (ctx->DirectTriangles) { + for (i=2;iCount;i+=3) { + START_PROFILE + (*ctx->Driver.TriangleFunc)( ctx, i-2, i-1, i, i ); + END_PROFILE( ctx->PolygonTime, ctx->PolygonCount, 1 ) + } + } + else { + for (i=2;iCount;i+=3) { + render_triangle( ctx, i-2, i-1, i, i ); + } + } + } + break; + + case GL_TRIANGLE_STRIP: + if (VB->ClipOrMask) { + GLuint i; + for (i=2;iCount;i++) { + if (VB->ClipMask[i-2] & VB->ClipMask[i-1] + & VB->ClipMask[i] & CLIP_ALL_BITS) { + /* all points clipped by common plane */ + continue; + } + else if (VB->ClipMask[i-2] | VB->ClipMask[i-1] | VB->ClipMask[i]) { + if (i&1) { + /* reverse vertex order */ + vlist[0] = i-1; + vlist[1] = i-2; + vlist[2] = i-0; + render_clipped_polygon( ctx, 3, vlist ); + } + else { + vlist[0] = i-2; + vlist[1] = i-1; + vlist[2] = i-0; + render_clipped_polygon( ctx, 3, vlist ); + } + } + else { + if (ctx->DirectTriangles) { + START_PROFILE + (*ctx->Driver.TriangleFunc)( ctx, i-2, i-1, i, i ); + END_PROFILE( ctx->PolygonTime, ctx->PolygonCount, 1 ) + } + else { + if (i&1) + render_triangle( ctx, i, i-1, i-2, i ); + else + render_triangle( ctx, i-2, i-1, i, i ); + } + } + } + } + else { + /* no vertices were clipped */ + GLuint i; + if (ctx->DirectTriangles) { + for (i=2;iCount;i++) { + START_PROFILE + (*ctx->Driver.TriangleFunc)( ctx, i-2, i-1, i, i ); + END_PROFILE( ctx->PolygonTime, ctx->PolygonCount, 1 ) + } + } + else { + for (i=2;iCount;i++) { + if (i&1) + render_triangle( ctx, i, i-1, i-2, i ); + else + render_triangle( ctx, i-2, i-1, i, i ); + } + } + } + break; + + case GL_TRIANGLE_FAN: + if (VB->ClipOrMask) { + GLuint i; + for (i=2;iCount;i++) { + if (VB->ClipMask[0] & VB->ClipMask[i-1] & VB->ClipMask[i] + & CLIP_ALL_BITS) { + /* all points clipped by common plane */ + continue; + } + else if (VB->ClipMask[0] | VB->ClipMask[i-1] | VB->ClipMask[i]) { + vlist[0] = 0; + vlist[1] = i-1; + vlist[2] = i; + render_clipped_polygon( ctx, 3, vlist ); + } + else { + if (ctx->DirectTriangles) { + START_PROFILE + (*ctx->Driver.TriangleFunc)( ctx, 0, i-1, i, i ); + END_PROFILE( ctx->PolygonTime, ctx->PolygonCount, 1 ) + } + else { + render_triangle( ctx, 0, i-1, i, i ); + } + } + } + } + else { + /* no clipping needed */ + GLuint i; + if (ctx->DirectTriangles) { + for (i=2;iCount;i++) { + START_PROFILE + (*ctx->Driver.TriangleFunc)( ctx, 0, i-1, i, i ); + END_PROFILE( ctx->PolygonTime, ctx->PolygonCount, 1 ) + } + } + else { + for (i=2;iCount;i++) { + render_triangle( ctx, 0, i-1, i, i ); + } + } + } + break; + + case GL_QUADS: + if (VB->ClipOrMask) { + GLuint i; + for (i=3;iCount;i+=4) { + if (VB->ClipMask[i-3] & VB->ClipMask[i-2] + & VB->ClipMask[i-1] & VB->ClipMask[i] & CLIP_ALL_BITS) { + /* all points clipped by common plane */ + continue; + } + else if (VB->ClipMask[i-3] | VB->ClipMask[i-2] + | VB->ClipMask[i-1] | VB->ClipMask[i]) { + vlist[0] = i-3; + vlist[1] = i-2; + vlist[2] = i-1; + vlist[3] = i-0; + render_clipped_polygon( ctx, 4, vlist ); + } + else { + if (ctx->DirectTriangles) { + START_PROFILE + (*ctx->Driver.QuadFunc)( ctx, i-3, i-2, i-1, i, i ); + END_PROFILE( ctx->PolygonTime, ctx->PolygonCount, 2 ) + } + else { + render_quad( ctx, i-3, i-2, i-1, i, i ); + } + } + } + } + else { + /* no vertices were clipped */ + GLuint i; + if (ctx->DirectTriangles) { + for (i=3;iCount;i+=4) { + START_PROFILE + (*ctx->Driver.QuadFunc)( ctx, i-3, i-2, i-1, i, i ); + END_PROFILE( ctx->PolygonTime, ctx->PolygonCount, 2 ) + } + } + else { + for (i=3;iCount;i+=4) { + render_quad( ctx, i-3, i-2, i-1, i, i ); + } + } + } + break; + + case GL_QUAD_STRIP: + if (VB->ClipOrMask) { + GLuint i; + for (i=3;iCount;i+=2) { + if (VB->ClipMask[i-2] & VB->ClipMask[i-3] + & VB->ClipMask[i-1] & VB->ClipMask[i] & CLIP_ALL_BITS) { + /* all points clipped by common plane */ + continue; + } + else if (VB->ClipMask[i-2] | VB->ClipMask[i-3] + | VB->ClipMask[i-1] | VB->ClipMask[i]) { + vlist[0] = i-1; + vlist[1] = i-3; + vlist[2] = i-2; + vlist[3] = i-0; + render_clipped_polygon( ctx, 4, vlist ); + } + else { + if (ctx->DirectTriangles) { + START_PROFILE + (*ctx->Driver.QuadFunc)( ctx, i-3, i-2, i, i-1, i ); + END_PROFILE( ctx->PolygonTime, ctx->PolygonCount, 2 ) + } + else { + render_quad( ctx, i-3, i-2, i, i-1, i ); + } + } + } + } + else { + /* no clipping needed */ + GLuint i; + if (ctx->DirectTriangles) { + for (i=3;iCount;i+=2) { + START_PROFILE + (*ctx->Driver.QuadFunc)( ctx, i-3, i-2, i, i-1, i ); + END_PROFILE( ctx->PolygonTime, ctx->PolygonCount, 2 ) + } + } + else { + for (i=3;iCount;i+=2) { + render_quad( ctx, i-3, i-2, i, i-1, i ); + } + } + } + break; + + case GL_POLYGON: + if (VB->Count>2) { + if (VB->ClipAndMask & CLIP_ALL_BITS) { + /* all points clipped by common plane, draw nothing */ + break; + } + if (VB->ClipOrMask) { + /* need clipping */ + GLuint i; + for (i=0;iCount;i++) { + vlist[i] = i; + } + render_clipped_polygon( ctx, VB->Count, vlist ); + } + else { + /* no clipping needed */ + static GLuint const_vlist[VB_SIZE]; + static GLboolean initFlag = GL_TRUE; + if (initFlag) { + /* vertex list always the same, never changes */ + GLuint i; + for (i=0;iCount, const_vlist ); + } + } + break; + + default: + /* should never get here */ + gl_problem( ctx, "invalid mode in gl_render_vb" ); + } + + gl_reset_vb( ctx, allDone ); +} + + +#define CLIP_ALL_BITS 0x3f + + +/* + * After we've rendered the primitives in the vertex buffer we call + * this function to reset the vertex buffer. That is, we prepare it + * for the next batch of vertices. + * Input: ctx - the context + * allDone - GL_TRUE = glEnd() was called + * GL_FALSE = buffer was filled, more vertices to come + */ +void gl_reset_vb( GLcontext *ctx, GLboolean allDone ) +{ + struct vertex_buffer *VB = ctx->VB; + + /* save a few VB values for the end of this function */ + int oldCount = VB->Count; + GLubyte clipOrMask = VB->ClipOrMask; + GLboolean monoMaterial = VB->MonoMaterial; + GLuint vertexSizeMask = VB->VertexSizeMask; + + /* Special case for GL_LINE_LOOP */ + if (ctx->Primitive==GL_LINE_LOOP && allDone) { + if (VB->ClipMask[VB->Count-1] | VB->ClipMask[0]) { + render_clipped_line( ctx, VB->Count-1, 0 ); + } + else { + START_PROFILE + (*ctx->Driver.LineFunc)( ctx, VB->Count-1, 0, 0 ); + END_PROFILE( ctx->LineTime, ctx->LineCount, 1 ) + } + } + + if (allDone) { + /* glEnd() was called so reset Vertex Buffer to default, empty state */ + VB->Start = VB->Count = 0; + VB->ClipOrMask = 0; + VB->ClipAndMask = CLIP_ALL_BITS; + VB->MonoMaterial = GL_TRUE; + VB->MonoNormal = GL_TRUE; + VB->MonoColor = GL_TRUE; + VB->VertexSizeMask = VERTEX3_BIT; + if (VB->TexCoordSize!=2) { + GLint i, n = VB->Count; + for (i=0;iTexCoord[i][2] = 0.0F; + VB->TexCoord[i][3] = 1.0F; + } + } + if (ctx->Current.TexCoord[2]==0.0F && ctx->Current.TexCoord[3]==1.0F) { + VB->TexCoordSize = 2; + } + else { + VB->TexCoordSize = 4; + } + } + else { + /* The vertex buffer was filled but we didn't get a glEnd() call yet + * have to "re-cycle" the vertex buffer. + */ + switch (ctx->Primitive) { + case GL_POINTS: + ASSERT(VB->Start==0); + VB->Start = VB->Count = 0; + VB->ClipOrMask = 0; + VB->ClipAndMask = CLIP_ALL_BITS; + VB->MonoMaterial = GL_TRUE; + VB->MonoNormal = GL_TRUE; + break; + case GL_LINES: + ASSERT(VB->Start==0); + VB->Start = VB->Count = 0; + VB->ClipOrMask = 0; + VB->ClipAndMask = CLIP_ALL_BITS; + VB->MonoMaterial = GL_TRUE; + VB->MonoNormal = GL_TRUE; + break; + case GL_LINE_STRIP: + copy_vertex( VB, 0, VB->Count-1 ); /* copy last vertex to front */ + VB->Start = VB->Count = 1; + VB->ClipOrMask = VB->ClipMask[0]; + VB->ClipAndMask = VB->ClipMask[0]; + VB->MonoMaterial = VB->MaterialMask[0] ? GL_FALSE : GL_TRUE; + break; + case GL_LINE_LOOP: + ASSERT(VB->Count==VB_MAX); + copy_vertex( VB, 1, VB_MAX-1 ); + VB->Start = VB->Count = 2; + VB->ClipOrMask = VB->ClipMask[0] | VB->ClipMask[1]; + VB->ClipAndMask = VB->ClipMask[0] & VB->ClipMask[1]; + VB->MonoMaterial = !(VB->MaterialMask[0] | VB->MaterialMask[1]); + break; + case GL_TRIANGLES: + ASSERT(VB->Start==0); + VB->Start = VB->Count = 0; + VB->ClipOrMask = 0; + VB->ClipAndMask = CLIP_ALL_BITS; + VB->MonoMaterial = GL_TRUE; + VB->MonoNormal = GL_TRUE; + break; + case GL_TRIANGLE_STRIP: + copy_vertex( VB, 0, VB_MAX-2 ); + copy_vertex( VB, 1, VB_MAX-1 ); + VB->Start = VB->Count = 2; + VB->ClipOrMask = VB->ClipMask[0] | VB->ClipMask[1]; + VB->ClipAndMask = VB->ClipMask[0] & VB->ClipMask[1]; + VB->MonoMaterial = !(VB->MaterialMask[0] | VB->MaterialMask[1]); + break; + case GL_TRIANGLE_FAN: + copy_vertex( VB, 1, VB_MAX-1 ); + VB->Start = VB->Count = 2; + VB->ClipOrMask = VB->ClipMask[0] | VB->ClipMask[1]; + VB->ClipAndMask = VB->ClipMask[0] & VB->ClipMask[1]; + VB->MonoMaterial = !(VB->MaterialMask[0] | VB->MaterialMask[1]); + break; + case GL_QUADS: + ASSERT(VB->Start==0); + VB->Start = VB->Count = 0; + VB->ClipOrMask = 0; + VB->ClipAndMask = CLIP_ALL_BITS; + VB->MonoMaterial = GL_TRUE; + VB->MonoNormal = GL_TRUE; + break; + case GL_QUAD_STRIP: + copy_vertex( VB, 0, VB_MAX-2 ); + copy_vertex( VB, 1, VB_MAX-1 ); + VB->Start = VB->Count = 2; + VB->ClipOrMask = VB->ClipMask[0] | VB->ClipMask[1]; + VB->ClipAndMask = VB->ClipMask[0] & VB->ClipMask[1]; + VB->MonoMaterial = !(VB->MaterialMask[0] | VB->MaterialMask[1]); + break; + case GL_POLYGON: + copy_vertex( VB, 1, VB_MAX-1 ); + VB->Start = VB->Count = 2; + VB->ClipOrMask = VB->ClipMask[0] | VB->ClipMask[1]; + VB->ClipAndMask = VB->ClipMask[0] & VB->ClipMask[1]; + VB->MonoMaterial = !(VB->MaterialMask[0] | VB->MaterialMask[1]); + break; + default: + /* should never get here */ + gl_problem(ctx, "Bad primitive type in gl_reset_vb()"); + } + } + + if (clipOrMask) { + /* reset clip masks to zero */ + MEMSET( VB->ClipMask + VB->Start, 0, + (oldCount - VB->Start) * sizeof(VB->ClipMask[0]) ); + } + + if (!monoMaterial) { + /* reset material masks to zero */ + MEMSET( VB->MaterialMask + VB->Start, 0, + (oldCount - VB->Start) * sizeof(VB->MaterialMask[0]) ); + gl_update_lighting(ctx); + } + + if (vertexSizeMask!=VERTEX3_BIT) { + /* reset object W coords to one */ + GLint i, n; + GLfloat (*obj)[4] = VB->Obj + VB->Start; + n = oldCount - VB->Start; + for (i=0; i +#include "asm-386.h" +#include "context.h" +#include "fog.h" +#include "light.h" +#include "macros.h" +#include "matrix.h" +#include "mmath.h" +#include "shade.h" +#include "texture.h" +#include "types.h" +#include "vb.h" +#include "vbrender.h" +#include "vbxform.h" +#include "xform.h" +#include +#endif + +WINE_DEFAULT_DEBUG_CHANNEL(opengl32); + + +#if 0 /* NOT USED AT THIS TIME */ +/* + * Use the current modelview matrix to transform XY vertices from object + * to eye coordinates. + * Input: ctx - the context + * n - number of vertices to transform + * vObj - array [n][4] of object coordinates + * In/Out; vEye - array [n][4] of eye coordinates + */ +static void transform_points2( GLcontext *ctx, GLuint n, + const GLfloat vObj[][4], GLfloat vEye[][4] ) +{ + switch (ctx->ModelViewMatrixType) { + case MATRIX_GENERAL: + { + const GLfloat *m = ctx->ModelViewMatrix; + GLfloat m0 = m[0], m4 = m[4], m12 = m[12]; + GLfloat m1 = m[1], m5 = m[5], m13 = m[13]; + GLfloat m2 = m[2], m6 = m[6], m14 = m[14]; + GLfloat m3 = m[3], m7 = m[7], m15 = m[15]; + GLuint i; + for (i=0;iModelViewMatrix; + GLfloat m0 = m[0], m1 = m[1], m4 = m[4], m5 = m[5]; + GLfloat m12 = m[12], m13 = m[13]; + GLuint i; + for (i=0;iModelViewMatrix; + GLfloat m0 = m[0], m5 = m[5], m12 = m[12], m13 = m[13]; + GLuint i; + for (i=0;iModelViewMatrix; + GLfloat m0 = m[0], m1 = m[1], m2 = m[2], m4 = m[4], m5 = m[5]; + GLfloat m6 = m[6], m12 = m[12], m13 = m[13], m14 = m[14]; + GLuint i; + for (i=0;iModelViewMatrixType) { + case MATRIX_GENERAL: + { + const GLfloat *m = ctx->ModelViewMatrix; + GLfloat m0 = m[0], m4 = m[4], m8 = m[8], m12 = m[12]; + GLfloat m1 = m[1], m5 = m[5], m9 = m[9], m13 = m[13]; + GLfloat m2 = m[2], m6 = m[6], m10 = m[10], m14 = m[14]; + GLfloat m3 = m[3], m7 = m[7], m11 = m[11], m15 = m[15]; + GLuint i; + for (i=0;iModelViewMatrix; + GLfloat m0 = m[0], m1 = m[1], m4 = m[4], m5 = m[5]; + GLfloat m12 = m[12], m13 = m[13]; + GLuint i; + for (i=0;iModelViewMatrix; + GLfloat m0 = m[0], m5 = m[5], m12 = m[12], m13 = m[13]; + GLuint i; + for (i=0;iModelViewMatrix; + GLfloat m0 = m[0], m1 = m[1], m2 = m[2], m4 = m[4], m5 = m[5]; + GLfloat m6 = m[6], m8 = m[8], m9 = m[9], m10 = m[10]; + GLfloat m12 = m[12], m13 = m[13], m14 = m[14]; + GLuint i; + for (i=0;iModelViewMatrixType) { + case MATRIX_GENERAL: + asm_transform_points3_general( n, vEye, ctx->ModelViewMatrix, vObj ); + break; + case MATRIX_IDENTITY: + asm_transform_points3_identity( n, vEye, vObj ); + break; + case MATRIX_2D: + asm_transform_points3_2d( n, vEye, ctx->ModelViewMatrix, vObj ); + break; + case MATRIX_2D_NO_ROT: + asm_transform_points3_2d_no_rot( n, vEye, ctx->ModelViewMatrix, + vObj ); + break; + case MATRIX_3D: + asm_transform_points3_3d( n, vEye, ctx->ModelViewMatrix, vObj ); + break; + default: + /* should never get here */ + gl_problem( NULL, "invalid matrix type in transform_points3()" ); + return; + } +#endif + if (1) + { + GLuint i; + for (i = 0; i < n; i++) + { + TRACE("(%3.1f, %3.1f, %3.1f, %3.1f) --> (%3.1f, %3.1f, %3.1f, %3.1f)\n", + vObj[i][0], vObj[i][1], vObj[i][2], vObj[i][3], + vEye[i][0], vEye[i][1], vEye[i][2], vEye[i][3]); + } + } + +} + + + +/* + * Use the current modelview matrix to transform XYZW vertices from object + * to eye coordinates. + * Input: ctx - the context + * n - number of vertices to transform + * vObj - array [n][4] of object coordinates + * In/Out; vEye - array [n][4] of eye coordinates + */ +static void transform_points4( GLcontext *ctx, GLuint n, + /*const*/ GLfloat vObj[][4], GLfloat vEye[][4] ) +{ +#ifndef USE_ASM + switch (ctx->ModelViewMatrixType) { + case MATRIX_GENERAL: + { + const GLfloat *m = ctx->ModelViewMatrix; + GLfloat m0 = m[0], m4 = m[4], m8 = m[8], m12 = m[12]; + GLfloat m1 = m[1], m5 = m[5], m9 = m[9], m13 = m[13]; + GLfloat m2 = m[2], m6 = m[6], m10 = m[10], m14 = m[14]; + GLfloat m3 = m[3], m7 = m[7], m11 = m[11], m15 = m[15]; + GLuint i; + for (i=0;iModelViewMatrix; + GLfloat m0 = m[0], m1 = m[1], m4 = m[4], m5 = m[5]; + GLfloat m12 = m[12], m13 = m[13]; + GLuint i; + for (i=0;iModelViewMatrix; + GLfloat m0 = m[0], m5 = m[5], m12 = m[12], m13 = m[13]; + GLuint i; + for (i=0;iModelViewMatrix; + GLfloat m0 = m[0], m1 = m[1], m2 = m[2], m4 = m[4], m5 = m[5]; + GLfloat m6 = m[6], m8 = m[8], m9 = m[9], m10 = m[10]; + GLfloat m12 = m[12], m13 = m[13], m14 = m[14]; + GLuint i; + for (i=0;iModelViewMatrixType) { + case MATRIX_GENERAL: + asm_transform_points4_general( n, vEye, ctx->ModelViewMatrix, vObj ); + break; + case MATRIX_IDENTITY: + asm_transform_points4_identity( n, vEye, vObj ); + break; + case MATRIX_2D: + asm_transform_points4_2d( n, vEye, ctx->ModelViewMatrix, vObj ); + break; + case MATRIX_2D_NO_ROT: + asm_transform_points4_2d_no_rot( n, vEye, ctx->ModelViewMatrix, + vObj ); + break; + case MATRIX_3D: + asm_transform_points4_3d( n, vEye, ctx->ModelViewMatrix, vObj ); + break; + default: + /* should never get here */ + gl_problem( NULL, "invalid matrix type in transform_points4()" ); + return; + } +#endif +} + + + +/* + * Transform an array of texture coordinates by the current texture matrix. + * Input: ctx - the context + * n - number of texture coordinates in array + * In/Out: t - array [n][4] of texture coordinates to transform + */ +static void transform_texcoords( GLcontext *ctx, GLuint n, GLfloat t[][4] ) +{ +#ifndef USE_ASM + switch (ctx->TextureMatrixType) { + case MATRIX_GENERAL: + { + const GLfloat *m = ctx->TextureMatrix; + GLfloat m0 = m[0], m4 = m[4], m8 = m[8], m12 = m[12]; + GLfloat m1 = m[1], m5 = m[5], m9 = m[9], m13 = m[13]; + GLfloat m2 = m[2], m6 = m[6], m10 = m[10], m14 = m[14]; + GLfloat m3 = m[3], m7 = m[7], m11 = m[11], m15 = m[15]; + GLuint i; + for (i=0;iTextureMatrix; + GLfloat m0 = m[0], m1 = m[1], m4 = m[4], m5 = m[5]; + GLfloat m12 = m[12], m13 = m[13]; + GLuint i; + for (i=0;iTextureMatrix; + GLfloat m0 = m[0], m1 = m[1], m2 = m[2], m4 = m[4], m5 = m[5]; + GLfloat m6 = m[6], m8 = m[8], m9 = m[9], m10 = m[10]; + GLfloat m12 = m[12], m13 = m[13], m14 = m[14]; + GLuint i; + for (i=0;iTextureMatrixType) { + case MATRIX_GENERAL: + asm_transform_points4_general( n, t, ctx->TextureMatrix, t ); + break; + case MATRIX_IDENTITY: + /* Do nothing */ + break; + case MATRIX_2D: + asm_transform_points4_2d( n, t, ctx->TextureMatrix, t ); + break; + case MATRIX_3D: + asm_transform_points4_3d( n, t, ctx->TextureMatrix, t ); + break; + default: + /* should never get here */ + gl_problem( NULL, "invalid matrix type in transform_texcoords()" ); + return; + } +#endif +} + + + +/* + * Apply the projection matrix to an array of vertices in Eye coordinates + * resulting in Clip coordinates. Also, compute the ClipMask bitfield for + * each vertex. + * + * NOTE: the volatile keyword is used in this function to ensure that the + * FP computations are computed to low-precision. If high precision is + * used (ala 80-bit X86 arithmetic) then the clipMask results may be + * inconsistant with the computations in clip.c. Later, clipped polygons + * may be rendered incorrectly. + * + * Input: ctx - the context + * n - number of vertices + * vEye - array [n][4] of Eye coordinates + * Output: vClip - array [n][4] of Clip coordinates + * clipMask - array [n] of clip masks + */ +static void project_and_cliptest( GLcontext *ctx, + GLuint n, /*const*/ GLfloat vEye[][4], + GLfloat vClip[][4], GLubyte clipMask[], + GLubyte *orMask, GLubyte *andMask ) + +{ +#ifndef USE_ASM + GLubyte tmpOrMask = *orMask; + GLubyte tmpAndMask = *andMask; + + switch (ctx->ProjectionMatrixType) { + case MATRIX_GENERAL: + { + const GLfloat *m = ctx->ProjectionMatrix; + GLfloat m0 = m[0], m4 = m[4], m8 = m[8], m12 = m[12]; + GLfloat m1 = m[1], m5 = m[5], m9 = m[9], m13 = m[13]; + GLfloat m2 = m[2], m6 = m[6], m10 = m[10], m14 = m[14]; + GLfloat m3 = m[3], m7 = m[7], m11 = m[11], m15 = m[15]; + GLuint i; + for (i=0;i cw) mask |= CLIP_RIGHT_BIT; + else if (cx < -cw) mask |= CLIP_LEFT_BIT; + if (cy > cw) mask |= CLIP_TOP_BIT; + else if (cy < -cw) mask |= CLIP_BOTTOM_BIT; + if (cz > cw) mask |= CLIP_FAR_BIT; + else if (cz < -cw) mask |= CLIP_NEAR_BIT; + if (mask) { + clipMask[i] |= mask; + tmpOrMask |= mask; + } + tmpAndMask &= mask; + } + } + break; + case MATRIX_IDENTITY: + { + GLuint i; + for (i=0;i cw) mask |= CLIP_RIGHT_BIT; + else if (cx < -cw) mask |= CLIP_LEFT_BIT; + if (cy > cw) mask |= CLIP_TOP_BIT; + else if (cy < -cw) mask |= CLIP_BOTTOM_BIT; + if (cz > cw) mask |= CLIP_FAR_BIT; + else if (cz < -cw) mask |= CLIP_NEAR_BIT; + if (mask) { + clipMask[i] |= mask; + tmpOrMask |= mask; + } + tmpAndMask &= mask; + } + } + break; + case MATRIX_ORTHO: + { + const GLfloat *m = ctx->ProjectionMatrix; + GLfloat m0 = m[0], m5 = m[5], m10 = m[10], m12 = m[12]; + GLfloat m13 = m[13], m14 = m[14]; + GLuint i; + for (i=0;i cw) mask |= CLIP_RIGHT_BIT; + else if (cx < -cw) mask |= CLIP_LEFT_BIT; + if (cy > cw) mask |= CLIP_TOP_BIT; + else if (cy < -cw) mask |= CLIP_BOTTOM_BIT; + if (cz > cw) mask |= CLIP_FAR_BIT; + else if (cz < -cw) mask |= CLIP_NEAR_BIT; + if (mask) { + clipMask[i] |= mask; + tmpOrMask |= mask; + } + tmpAndMask &= mask; + } + } + break; + case MATRIX_PERSPECTIVE: + { + const GLfloat *m = ctx->ProjectionMatrix; + GLfloat m0 = m[0], m5 = m[5], m8 = m[8], m9 = m[9]; + GLfloat m10 = m[10], m14 = m[14]; + GLuint i; + for (i=0;i cw) mask |= CLIP_RIGHT_BIT; + else if (cx < -cw) mask |= CLIP_LEFT_BIT; + if (cy > cw) mask |= CLIP_TOP_BIT; + else if (cy < -cw) mask |= CLIP_BOTTOM_BIT; + if (cz > cw) mask |= CLIP_FAR_BIT; + else if (cz < -cw) mask |= CLIP_NEAR_BIT; + if (mask) { + clipMask[i] |= mask; + tmpOrMask |= mask; + } + tmpAndMask &= mask; + } + } + break; + default: + /* should never get here */ + gl_problem( NULL, "invalid matrix type in project_and_cliptest()" ); + } + + *orMask = tmpOrMask; + *andMask = tmpAndMask; +#else + switch (ctx->ProjectionMatrixType) { + case MATRIX_GENERAL: + asm_project_and_cliptest_general( n, vClip, ctx->ProjectionMatrix, vEye, + clipMask, orMask, andMask ); + break; + case MATRIX_IDENTITY: + asm_project_and_cliptest_identity( n, vClip, vEye, clipMask, orMask, andMask ); + break; + case MATRIX_ORTHO: + asm_project_and_cliptest_ortho( n, vClip, ctx->ProjectionMatrix, vEye, + clipMask, orMask, andMask ); + break; + case MATRIX_PERSPECTIVE: + asm_project_and_cliptest_perspective( n, vClip, ctx->ProjectionMatrix, + vEye, clipMask, orMask, andMask ); + break; + default: + /* should never get here */ + gl_problem( NULL, "invalid matrix type in project_and_cliptest()" ); + return; + } +#endif +} + + +/* This value matches the one in clip.c, used to cope with numeric error. */ +#define MAGIC_NUMBER -0.8e-03F + +/* + * Test an array of vertices against the user-defined clipping planes. + * Input: ctx - the context + * n - number of vertices + * vEye - array [n] of vertices, in eye coordinate system + * Output: clipMask - array [n] of clip values: 0=not clipped, !0=clipped + * Return: CLIP_ALL - if all vertices are clipped by one of the planes + * CLIP_NONE - if no vertices were clipped + * CLIP_SOME - if some vertices were clipped + */ +static GLuint userclip_vertices( GLcontext *ctx, GLuint n, + /*const*/ GLfloat vEye[][4], + GLubyte clipMask[] ) +{ + GLboolean anyClipped = GL_FALSE; + GLuint p; + + ASSERT(ctx->Transform.AnyClip); + + for (p=0;pTransform.ClipEnabled[p]) { + GLfloat a = ctx->Transform.ClipEquation[p][0]; + GLfloat b = ctx->Transform.ClipEquation[p][1]; + GLfloat c = ctx->Transform.ClipEquation[p][2]; + GLfloat d = ctx->Transform.ClipEquation[p][3]; + GLboolean allClipped = GL_TRUE; + GLuint i; + for (i=0;iViewport.Sx; + GLfloat tx = ctx->Viewport.Tx; + GLfloat sy = ctx->Viewport.Sy; + GLfloat ty = ctx->Viewport.Ty; + GLfloat sz = ctx->Viewport.Sz; + GLfloat tz = ctx->Viewport.Tz; + + if ((ctx->ProjectionMatrixType==MATRIX_ORTHO || + ctx->ProjectionMatrixType==MATRIX_IDENTITY) + && ctx->ModelViewMatrixType!=MATRIX_GENERAL + && (ctx->VB->VertexSizeMask & VERTEX4_BIT)==0) { + /* don't need to divide by W */ + if (clipMask) { + /* one or more vertices are clipped */ + GLuint i; + for (i=0;i (%3.1f, %3.1f, %3.1f)\n", + vClip[i][0], vClip[i][1], vClip[i][2], vClip[i][3], + vWin[i][0], vWin[i][1], vWin[i][2]); + } + } +} + + + +/* + * Check if the global material has to be updated with info that was + * associated with a vertex via glMaterial. + * This function is used when any material values get changed between + * glBegin/glEnd either by calling glMaterial() or by calling glColor() + * when GL_COLOR_MATERIAL is enabled. + */ +static void update_material( GLcontext *ctx, GLuint i ) +{ + struct vertex_buffer *VB = ctx->VB; + + if (VB->MaterialMask[i]) { + if (VB->MaterialMask[i] & FRONT_AMBIENT_BIT) { + COPY_4V( ctx->Light.Material[0].Ambient, VB->Material[i][0].Ambient ); + } + if (VB->MaterialMask[i] & BACK_AMBIENT_BIT) { + COPY_4V( ctx->Light.Material[1].Ambient, VB->Material[i][1].Ambient ); + } + if (VB->MaterialMask[i] & FRONT_DIFFUSE_BIT) { + COPY_4V( ctx->Light.Material[0].Diffuse, VB->Material[i][0].Diffuse ); + } + if (VB->MaterialMask[i] & BACK_DIFFUSE_BIT) { + COPY_4V( ctx->Light.Material[1].Diffuse, VB->Material[i][1].Diffuse ); + } + if (VB->MaterialMask[i] & FRONT_SPECULAR_BIT) { + COPY_4V( ctx->Light.Material[0].Specular, VB->Material[i][0].Specular ); + } + if (VB->MaterialMask[i] & BACK_SPECULAR_BIT) { + COPY_4V( ctx->Light.Material[1].Specular, VB->Material[i][1].Specular ); + } + if (VB->MaterialMask[i] & FRONT_EMISSION_BIT) { + COPY_4V( ctx->Light.Material[0].Emission, VB->Material[i][0].Emission ); + } + if (VB->MaterialMask[i] & BACK_EMISSION_BIT) { + COPY_4V( ctx->Light.Material[1].Emission, VB->Material[i][1].Emission ); + } + if (VB->MaterialMask[i] & FRONT_SHININESS_BIT) { + ctx->Light.Material[0].Shininess = VB->Material[i][0].Shininess; + gl_compute_material_shine_table( &ctx->Light.Material[0] ); + } + if (VB->MaterialMask[i] & BACK_SHININESS_BIT) { + ctx->Light.Material[1].Shininess = VB->Material[i][1].Shininess; + gl_compute_material_shine_table( &ctx->Light.Material[1] ); + } + if (VB->MaterialMask[i] & FRONT_INDEXES_BIT) { + ctx->Light.Material[0].AmbientIndex = VB->Material[i][0].AmbientIndex; + ctx->Light.Material[0].DiffuseIndex = VB->Material[i][0].DiffuseIndex; + ctx->Light.Material[0].SpecularIndex = VB->Material[i][0].SpecularIndex; + } + if (VB->MaterialMask[i] & BACK_INDEXES_BIT) { + ctx->Light.Material[1].AmbientIndex = VB->Material[i][1].AmbientIndex; + ctx->Light.Material[1].DiffuseIndex = VB->Material[i][1].DiffuseIndex; + ctx->Light.Material[1].SpecularIndex = VB->Material[i][1].SpecularIndex; + } + VB->MaterialMask[i] = 0; /* reset now */ + } +} + + +/* + * Compute the shading (lighting) for the vertices in the vertex buffer. + */ +static void shade_vertices( GLcontext *ctx ) +{ + struct vertex_buffer *VB = ctx->VB; + + if (ctx->Visual->RGBAflag) { + if (!VB->MonoMaterial) { + /* Material may change with each vertex */ + GLuint i; + for (i=VB->Start; iCount; i++) { + update_material( ctx, i ); + gl_color_shade_vertices( ctx, 0, 1, &VB->Eye[i], + &VB->Normal[i], &VB->Fcolor[i]); + if (ctx->Light.Model.TwoSide) { + gl_color_shade_vertices( ctx, 1, 1, &VB->Eye[i], + &VB->Normal[i], &VB->Bcolor[i]); + } + } + /* Need this in case a glColor/glMaterial is called after the + * last vertex between glBegin/glEnd. + */ + update_material( ctx, VB->Count ); + } + else { + if (ctx->Light.Fast) { + if (VB->MonoNormal) { + /* call optimized shader */ + GLubyte color[1][4]; + GLuint i; + gl_color_shade_vertices_fast( ctx, 0, /* front side */ + 1, + VB->Normal + VB->Start, + color ); + for (i=VB->Start; iCount; i++) { + COPY_4V( VB->Fcolor[i], color[0] ); + } + if (ctx->Light.Model.TwoSide) { + gl_color_shade_vertices_fast( ctx, 1, /* back side */ + 1, + VB->Normal + VB->Start, + color ); + for (i=VB->Start; iCount; i++) { + COPY_4V( VB->Bcolor[i], color[0] ); + } + } + + } + else { + /* call optimized shader */ + gl_color_shade_vertices_fast( ctx, 0, /* front side */ + VB->Count - VB->Start, + VB->Normal + VB->Start, + VB->Fcolor + VB->Start ); + if (ctx->Light.Model.TwoSide) { + gl_color_shade_vertices_fast( ctx, 1, /* back side */ + VB->Count - VB->Start, + VB->Normal + VB->Start, + VB->Bcolor + VB->Start ); + } + } + } + else { + /* call slower, full-featured shader */ + gl_color_shade_vertices( ctx, 0, + VB->Count - VB->Start, + VB->Eye + VB->Start, + VB->Normal + VB->Start, + VB->Fcolor + VB->Start ); + if (ctx->Light.Model.TwoSide) { + gl_color_shade_vertices( ctx, 1, + VB->Count - VB->Start, + VB->Eye + VB->Start, + VB->Normal + VB->Start, + VB->Bcolor + VB->Start ); + } + } + } + } + else { + /* Color index mode */ + if (!VB->MonoMaterial) { + /* Material may change with each vertex */ + GLuint i; + /* NOTE the <= here. This is needed in case glColor/glMaterial + * is called after the last glVertex inside a glBegin/glEnd pair. + */ + for (i=VB->Start; iCount; i++) { + update_material( ctx, i ); + gl_index_shade_vertices( ctx, 0, 1, &VB->Eye[i], + &VB->Normal[i], &VB->Findex[i] ); + if (ctx->Light.Model.TwoSide) { + gl_index_shade_vertices( ctx, 1, 1, &VB->Eye[i], + &VB->Normal[i], &VB->Bindex[i] ); + } + } + /* Need this in case a glColor/glMaterial is called after the + * last vertex between glBegin/glEnd. + */ + update_material( ctx, VB->Count ); + } + else { + gl_index_shade_vertices( ctx, 0, + VB->Count - VB->Start, + VB->Eye + VB->Start, + VB->Normal + VB->Start, + VB->Findex + VB->Start ); + if (ctx->Light.Model.TwoSide) { + gl_index_shade_vertices( ctx, 1, + VB->Count - VB->Start, + VB->Eye + VB->Start, + VB->Normal + VB->Start, + VB->Bindex + VB->Start ); + } + } + } +} + + + +/* + * Compute fog for the vertices in the vertex buffer. + */ +static void fog_vertices( GLcontext *ctx ) +{ + struct vertex_buffer *VB = ctx->VB; + + if (ctx->Visual->RGBAflag) { + /* Fog RGB colors */ + gl_fog_color_vertices( ctx, VB->Count - VB->Start, + VB->Eye + VB->Start, + VB->Fcolor + VB->Start ); + if (ctx->LightTwoSide) { + gl_fog_color_vertices( ctx, VB->Count - VB->Start, + VB->Eye + VB->Start, + VB->Bcolor + VB->Start ); + } + } + else { + /* Fog color indexes */ + gl_fog_index_vertices( ctx, VB->Count - VB->Start, + VB->Eye + VB->Start, + VB->Findex + VB->Start ); + if (ctx->LightTwoSide) { + gl_fog_index_vertices( ctx, VB->Count - VB->Start, + VB->Eye + VB->Start, + VB->Bindex + VB->Start ); + } + } +} + + + +/* + * When the Vertex Buffer is full, this function applies the modelview + * matrix to transform vertices and normals from object coordinates to + * eye coordinates. Next, we'll call gl_transform_vb_part2()... + * This function might not be called when using vertex arrays. + */ +void gl_transform_vb_part1( GLcontext *ctx, GLboolean allDone ) +{ + struct vertex_buffer *VB = ctx->VB; +#ifdef PROFILE + GLdouble t0 = gl_time(); +#endif + + ASSERT( VB->Count>0 ); + + /* Apply the modelview matrix to transform vertexes from Object + * to Eye coords. + */ + if (VB->VertexSizeMask==VERTEX4_BIT) { + transform_points4( ctx, VB->Count - VB->Start, + VB->Obj + VB->Start, VB->Eye + VB->Start ); + } + else { + transform_points3( ctx, VB->Count - VB->Start, + VB->Obj + VB->Start, VB->Eye + VB->Start ); + } + + /* Now transform the normal vectors */ + if (ctx->NeedNormals) { + gl_xform_normals_3fv( VB->Count - VB->Start, + VB->Normal + VB->Start, ctx->ModelViewInv, + VB->Normal + VB->Start, ctx->Transform.Normalize ); + } + +#ifdef PROFILE + ctx->VertexTime += gl_time() - t0; +#endif + + /* lighting, project, etc */ + gl_transform_vb_part2( ctx, allDone ); +} + + + +/* + * Part 2 of Vertex Buffer transformation: compute lighting, clipflags, + * fog, texture coords, etc. + * Before this function is called the VB->Eye coordinates must have + * already been computed. + * Callers: gl_transform_vb_part1(), glDrawArraysEXT() + */ +void gl_transform_vb_part2( GLcontext *ctx, GLboolean allDone ) +{ + struct vertex_buffer *VB = ctx->VB; +#ifdef PROFILE + GLdouble t0 = gl_time(); +#endif + + ASSERT( VB->Count>0 ); + + /* Test vertices in eye coordinate space against user clipping planes */ + if (ctx->Transform.AnyClip) { + GLuint result = userclip_vertices( ctx, VB->Count - VB->Start, + VB->Eye + VB->Start, + VB->ClipMask + VB->Start ); + if (result==CLIP_ALL) { + /* All vertices were outside one of the clip planes! */ + VB->ClipOrMask = CLIP_ALL_BITS; /* force reset of clipping flags */ + gl_reset_vb( ctx, allDone ); + return; + } + else if (result==CLIP_SOME) { + VB->ClipOrMask = CLIP_USER_BIT; + } + else { + VB->ClipAndMask = 0; + } + } + + /* Apply the projection matrix to the Eye coordinates, resulting in + * Clip coordinates. Also, compute the ClipMask for each vertex. + */ + project_and_cliptest( ctx, VB->Count - VB->Start, VB->Eye + VB->Start, + VB->Clip + VB->Start, VB->ClipMask + VB->Start, + &VB->ClipOrMask, &VB->ClipAndMask ); + + if (VB->ClipAndMask) { + /* All vertices clipped by one plane, all done! */ + /*assert(VB->ClipOrMask);*/ + VB->ClipOrMask = CLIP_ALL_BITS; /* force reset of clipping flags */ + gl_reset_vb( ctx, allDone ); + return; + } + + /* Lighting */ + if (ctx->Light.Enabled) { + shade_vertices(ctx); + } + + /* Per-vertex fog */ + if (ctx->Fog.Enabled && ctx->Hint.Fog!=GL_NICEST) { + fog_vertices(ctx); + } + + /* Generate/transform texture coords */ + if (ctx->Texture.Enabled || ctx->RenderMode==GL_FEEDBACK) { + if (ctx->Texture.TexGenEnabled) { + gl_texgen( ctx, VB->Count - VB->Start, + VB->Obj + VB->Start, + VB->Eye + VB->Start, + VB->Normal + VB->Start, + VB->TexCoord + VB->Start ); + } + if (ctx->NewTextureMatrix) { + gl_analyze_texture_matrix(ctx); + } + if (ctx->TextureMatrixType!=MATRIX_IDENTITY) { + transform_texcoords( ctx, VB->Count - VB->Start, + VB->TexCoord + VB->Start ); + } + } + + /* Use the viewport parameters to transform vertices from Clip + * coordinates to Window coordinates. + */ + viewport_map_vertices( ctx, VB->Count - VB->Start, VB->Clip + VB->Start, + VB->ClipOrMask ? VB->ClipMask + VB->Start : NULL, + VB->Win + VB->Start ); + + /* Device driver rasterization setup. 3Dfx driver, for example. */ + if (ctx->Driver.RasterSetup) { + (*ctx->Driver.RasterSetup)( ctx, 0, VB->Count ); + } + + +#ifdef PROFILE + ctx->VertexTime += gl_time() - t0; + ctx->VertexCount += VB->Count - VB->Start; +#endif + + /* + * Now we're ready to rasterize the Vertex Buffer!!! + * + * If the device driver can't rasterize the vertex buffer then we'll + * do it ourselves. + */ + if (!ctx->Driver.RenderVB || !(*ctx->Driver.RenderVB)(ctx,allDone)) { + gl_render_vb( ctx, allDone ); + } +} diff --git a/dll/opengl/mesa/vbxform.h b/dll/opengl/mesa/vbxform.h new file mode 100644 index 00000000000..b9e25164304 --- /dev/null +++ b/dll/opengl/mesa/vbxform.h @@ -0,0 +1,44 @@ +/* $Id: vbxform.h,v 1.2 1997/04/12 16:22:22 brianp Exp $ */ + +/* + * Mesa 3-D graphics library + * Version: 2.3 + * Copyright (C) 1995-1997 Brian Paul + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Library General Public + * License as published by the Free Software Foundation; either + * version 2 of the License, or (at your option) any later version. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Library General Public License for more details. + * + * You should have received a copy of the GNU Library General Public + * License along with this library; if not, write to the Free + * Software Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. + */ + + +/* + * $Log: vbxform.h,v $ + * Revision 1.2 1997/04/12 16:22:22 brianp + * removed gl_init_vb() + * + * Revision 1.1 1997/04/02 03:14:29 brianp + * Initial revision + * + */ + + +#ifndef VBXFORM_H +#define VBXFORM_H + + +extern void gl_transform_vb_part1( GLcontext *ctx, GLboolean alldone ); + +extern void gl_transform_vb_part2( GLcontext *ctx, GLboolean alldone ); + + +#endif diff --git a/dll/opengl/mesa/x86-64/calling_convention.txt b/dll/opengl/mesa/x86-64/calling_convention.txt deleted file mode 100644 index 5c244de4826..00000000000 --- a/dll/opengl/mesa/x86-64/calling_convention.txt +++ /dev/null @@ -1,50 +0,0 @@ -Register Usage -rax temporary register; with variable arguments passes information - about the number of SSE registers used; 1st return register - -rbx* callee-saved register; optionally used as base pointer - -rcx used to pass 4th integer argument to functions - -rdx used to pass 3rd argument to functions 2nd return register - -rsp* stack pointer - -rbp* callee-saved register; optionally used as frame pointer - -rsi used to pass 2nd argument to functions - -rdi used to pass 1st argument to functions - -r8 used to pass 5th argument to functions - -r9 used to pass 6th argument to functions - -r10 temporary register, used for passing a function's static chain pointer - -r11 temporary register - -r12-15* callee-saved registers - -xmm0­1 used to pass and return floating point arguments - -xmm2­7 used to pass floating point arguments - -xmm8­15 temporary registers - -mmx0­7 temporary registers - -st0 temporary register; used to return long double arguments - -st1 temporary registers; used to return long double arguments - -st2­7 temporary registers - -fs Reserved for system use (as thread specific data register) - - - -*) must be preserved across function calls - -Integer arguments from list: rdi,rsi,rdx,rcx,r8,r9,stack -Floating point arguments from list: xmm0-xmm7 diff --git a/dll/opengl/mesa/x86-64/x86-64.c b/dll/opengl/mesa/x86-64/x86-64.c deleted file mode 100644 index ac176ef328e..00000000000 --- a/dll/opengl/mesa/x86-64/x86-64.c +++ /dev/null @@ -1,129 +0,0 @@ - -/* - * Mesa 3-D graphics library - * Version: 6.3 - * - * Copyright (C) 1999-2003 Brian Paul All Rights Reserved. - * - * Permission is hereby granted, free of charge, to any person obtaining a - * copy of this software and associated documentation files (the "Software"), - * to deal in the Software without restriction, including without limitation - * the rights to use, copy, modify, merge, publish, distribute, sublicense, - * and/or sell copies of the Software, and to permit persons to whom the - * Software is furnished to do so, subject to the following conditions: - * - * The above copyright notice and this permission notice shall be included - * in all copies or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS - * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL - * BRIAN PAUL BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN - * AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN - * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. - */ - -/* - * x86-64 optimizations shamelessy converted from x86/sse/3dnow assembly by - * Mikko Tiihonen - */ - -#ifdef USE_X86_64_ASM - -#include "main/glheader.h" -#include "main/context.h" -#include "math/m_xform.h" -#include "tnl/t_context.h" -#include "x86-64.h" -#include "../x86/x86_xform.h" - -#ifdef DEBUG -#include "math/m_debug.h" -#endif - -extern void _mesa_x86_64_cpuid(unsigned int *regs); - -DECLARE_XFORM_GROUP( x86_64, 4 ) -DECLARE_XFORM_GROUP( 3dnow, 4 ) - -#else -/* just to silence warning below */ -#include "x86-64.h" -#endif - -/* -extern void _mesa_x86_64_transform_points4_general( XFORM_ARGS ); -extern void _mesa_x86_64_transform_points4_identity( XFORM_ARGS ); -extern void _mesa_x86_64_transform_points4_perspective( XFORM_ARGS ); -extern void _mesa_x86_64_transform_points4_3d( XFORM_ARGS ); -extern void _mesa_x86_64_transform_points4_3d_no_rot( XFORM_ARGS ); -extern void _mesa_x86_64_transform_points4_2d_no_rot( XFORM_ARGS ); -extern void _mesa_x86_64_transform_points4_2d( XFORM_ARGS ); -*/ - -#ifdef USE_X86_64_ASM -static void message( const char *msg ) -{ - GLboolean debug; -#ifdef DEBUG - debug = GL_TRUE; -#else - if ( _mesa_getenv( "MESA_DEBUG" ) ) { - debug = GL_TRUE; - } else { - debug = GL_FALSE; - } -#endif - if ( debug ) { - _mesa_debug( NULL, "%s", msg ); - } -} -#endif - - -void _mesa_init_all_x86_64_transform_asm(void) -{ -#ifdef USE_X86_64_ASM - unsigned int regs[4]; - - if ( _mesa_getenv( "MESA_NO_ASM" ) ) { - return; - } - - message("Initializing x86-64 optimizations\n"); - - - _mesa_transform_tab[4][MATRIX_GENERAL] = - _mesa_x86_64_transform_points4_general; - _mesa_transform_tab[4][MATRIX_IDENTITY] = - _mesa_x86_64_transform_points4_identity; - _mesa_transform_tab[4][MATRIX_3D] = - _mesa_x86_64_transform_points4_3d; - - regs[0] = 0x80000001; - regs[1] = 0x00000000; - regs[2] = 0x00000000; - regs[3] = 0x00000000; - _mesa_x86_64_cpuid(regs); - if (regs[3] & (1U << 31)) { - message("3Dnow! detected\n"); - _mesa_transform_tab[4][MATRIX_3D_NO_ROT] = - _mesa_3dnow_transform_points4_3d_no_rot; - _mesa_transform_tab[4][MATRIX_PERSPECTIVE] = - _mesa_3dnow_transform_points4_perspective; - _mesa_transform_tab[4][MATRIX_2D_NO_ROT] = - _mesa_3dnow_transform_points4_2d_no_rot; - _mesa_transform_tab[4][MATRIX_2D] = - _mesa_3dnow_transform_points4_2d; - - } - - -#ifdef DEBUG_MATH - _math_test_all_transform_functions("x86_64"); - _math_test_all_cliptest_functions("x86_64"); - _math_test_all_normal_transform_functions("x86_64"); -#endif - -#endif -} diff --git a/dll/opengl/mesa/x86-64/x86-64.h b/dll/opengl/mesa/x86-64/x86-64.h deleted file mode 100644 index 1d931fa3450..00000000000 --- a/dll/opengl/mesa/x86-64/x86-64.h +++ /dev/null @@ -1,31 +0,0 @@ - -/* - * Mesa 3-D graphics library - * Version: 3.5 - * - * Copyright (C) 1999-2001 Brian Paul All Rights Reserved. - * - * Permission is hereby granted, free of charge, to any person obtaining a - * copy of this software and associated documentation files (the "Software"), - * to deal in the Software without restriction, including without limitation - * the rights to use, copy, modify, merge, publish, distribute, sublicense, - * and/or sell copies of the Software, and to permit persons to whom the - * Software is furnished to do so, subject to the following conditions: - * - * The above copyright notice and this permission notice shall be included - * in all copies or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS - * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL - * BRIAN PAUL BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN - * AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN - * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. - */ - -#ifndef __X86_64_ASM_H__ -#define __X86_64_ASM_H__ - -extern void _mesa_init_all_x86_64_transform_asm( void ); - -#endif diff --git a/dll/opengl/mesa/x86-64/xform4.S b/dll/opengl/mesa/x86-64/xform4.S deleted file mode 100644 index 5abd5a25de5..00000000000 --- a/dll/opengl/mesa/x86-64/xform4.S +++ /dev/null @@ -1,483 +0,0 @@ -/* - * Mesa 3-D graphics library - * Version: 7.1 - * - * Copyright (C) 1999-2007 Brian Paul All Rights Reserved. - * - * Permission is hereby granted, free of charge, to any person obtaining a - * copy of this software and associated documentation files (the "Software"), - * to deal in the Software without restriction, including without limitation - * the rights to use, copy, modify, merge, publish, distribute, sublicense, - * and/or sell copies of the Software, and to permit persons to whom the - * Software is furnished to do so, subject to the following conditions: - * - * The above copyright notice and this permission notice shall be included - * in all copies or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS - * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL - * BRIAN PAUL BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN - * AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN - * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. - */ - -#ifdef USE_X86_64_ASM - -#include "matypes.h" - -.text - -.align 16 -.globl _mesa_x86_64_cpuid -.hidden _mesa_x86_64_cpuid -_mesa_x86_64_cpuid: - pushq %rbx - movl (%rdi), %eax - movl 8(%rdi), %ecx - - cpuid - - movl %ebx, 4(%rdi) - movl %eax, (%rdi) - movl %ecx, 8(%rdi) - movl %edx, 12(%rdi) - popq %rbx - ret - -.align 16 -.globl _mesa_x86_64_transform_points4_general -.hidden _mesa_x86_64_transform_points4_general -_mesa_x86_64_transform_points4_general: -/* - * rdi = dest - * rsi = matrix - * rdx = source - */ - movl V4F_COUNT(%rdx), %ecx /* count */ - movzbl V4F_STRIDE(%rdx), %eax /* stride */ - - movl %ecx, V4F_COUNT(%rdi) /* set dest count */ - movl $4, V4F_SIZE(%rdi) /* set dest size */ - .byte 0x66, 0x66, 0x66, 0x90 /* manual align += 3 */ - orl $VEC_SIZE_4, V4F_FLAGS(%rdi)/* set dest flags */ - - testl %ecx, %ecx /* verify non-zero count */ - prefetchnta 64(%rsi) - jz p4_general_done - - movq V4F_START(%rdx), %rdx /* ptr to first src vertex */ - movq V4F_START(%rdi), %rdi /* ptr to first dest vertex */ - - prefetch 16(%rdx) - - movaps 0(%rsi), %xmm4 /* m3 | m2 | m1 | m0 */ - movaps 16(%rsi), %xmm5 /* m7 | m6 | m5 | m4 */ - .byte 0x66, 0x66, 0x90 /* manual align += 3 */ - movaps 32(%rsi), %xmm6 /* m11 | m10 | m9 | m8 */ - movaps 48(%rsi), %xmm7 /* m15 | m14 | m13 | m12 */ - -p4_general_loop: - - movups (%rdx), %xmm8 /* ox | oy | oz | ow */ - prefetchw 16(%rdi) - - pshufd $0x00, %xmm8, %xmm0 /* ox | ox | ox | ox */ - addq %rax, %rdx - pshufd $0x55, %xmm8, %xmm1 /* oy | oy | oy | oy */ - mulps %xmm4, %xmm0 /* ox*m3 | ox*m2 | ox*m1 | ox*m0 */ - pshufd $0xAA, %xmm8, %xmm2 /* oz | oz | oz | ox */ - mulps %xmm5, %xmm1 /* oy*m7 | oy*m6 | oy*m5 | oy*m4 */ - pshufd $0xFF, %xmm8, %xmm3 /* ow | ow | ow | ow */ - mulps %xmm6, %xmm2 /* oz*m11 | oz*m10 | oz*m9 | oz*m8 */ - addps %xmm1, %xmm0 /* ox*m3+oy*m7 | ... */ - mulps %xmm7, %xmm3 /* ow*m15 | ow*m14 | ow*m13 | ow*m12 */ - addps %xmm2, %xmm0 /* ox*m3+oy*m7+oz*m11 | ... */ - prefetch 16(%rdx) - addps %xmm3, %xmm0 /* ox*m3+oy*m7+oz*m11+ow*m15 | ... */ - - movaps %xmm0, (%rdi) /* ->D(3) | ->D(2) | ->D(1) | ->D(0) */ - addq $16, %rdi - - decl %ecx - jnz p4_general_loop - -p4_general_done: - .byte 0xf3 - ret - -.section .rodata - -.align 16 -p4_constants: -.byte 0xff, 0xff, 0xff, 0xff -.byte 0xff, 0xff, 0xff, 0xff -.byte 0xff, 0xff, 0xff, 0xff -.byte 0x00, 0x00, 0x00, 0x00 - -.byte 0x00, 0x00, 0x00, 0x00 -.byte 0x00, 0x00, 0x00, 0x00 -.byte 0x00, 0x00, 0x00, 0x00 -.float 1.0 - -.text -.align 16 -.globl _mesa_x86_64_transform_points4_3d -.hidden _mesa_x86_64_transform_points4_3d -/* - * this is slower than _mesa_x86_64_transform_points4_general - * because it ensures that the last matrix row (or is it column?) is 0,0,0,1 - */ -_mesa_x86_64_transform_points4_3d: - - leaq p4_constants(%rip), %rax - - prefetchnta 64(%rsi) - - movaps (%rax), %xmm9 - movaps 16(%rax), %xmm10 - - movl V4F_COUNT(%rdx), %ecx /* count */ - movzbl V4F_STRIDE(%rdx), %eax /* stride */ - - movl %ecx, V4F_COUNT(%rdi) /* set dest count */ - movl $4, V4F_SIZE(%rdi) /* set dest size */ - orl $VEC_SIZE_4, V4F_FLAGS(%rdi)/* set dest flags */ - - testl %ecx, %ecx /* verify non-zero count */ - jz p4_3d_done - - movq V4F_START(%rdx), %rdx /* ptr to first src vertex */ - movq V4F_START(%rdi), %rdi /* ptr to first dest vertex */ - - prefetch 16(%rdx) - - movaps 0(%rsi), %xmm4 /* m3 | m2 | m1 | m0 */ - movaps 16(%rsi), %xmm5 /* m7 | m6 | m5 | m4 */ - andps %xmm9, %xmm4 /* 0.0 | m2 | m1 | m0 */ - movaps 32(%rsi), %xmm6 /* m11 | m10 | m9 | m8 */ - andps %xmm9, %xmm5 /* 0.0 | m6 | m5 | m4 */ - movaps 48(%rsi), %xmm7 /* m15 | m14 | m13 | m12 */ - andps %xmm9, %xmm6 /* 0.0 | m10 | m9 | m8 */ - andps %xmm9, %xmm7 /* 0.0 | m14 | m13 | m12 */ - .byte 0x66, 0x66, 0x90 /* manual align += 3 */ - orps %xmm10, %xmm7 /* 1.0 | m14 | m13 | m12 */ - -p4_3d_loop: - - movups (%rdx), %xmm8 /* ox | oy | oz | ow */ - prefetchw 16(%rdi) - - pshufd $0x00, %xmm8, %xmm0 /* ox | ox | ox | ox */ - addq %rax, %rdx - pshufd $0x55, %xmm8, %xmm1 /* oy | oy | oy | oy */ - mulps %xmm4, %xmm0 /* ox*m3 | ox*m2 | ox*m1 | ox*m0 */ - pshufd $0xAA, %xmm8, %xmm2 /* oz | oz | oz | ox */ - mulps %xmm5, %xmm1 /* oy*m7 | oy*m6 | oy*m5 | oy*m4 */ - pshufd $0xFF, %xmm8, %xmm3 /* ow | ow | ow | ow */ - mulps %xmm6, %xmm2 /* oz*m11 | oz*m10 | oz*m9 | oz*m8 */ - addps %xmm1, %xmm0 /* ox*m3+oy*m7 | ... */ - mulps %xmm7, %xmm3 /* ow*m15 | ow*m14 | ow*m13 | ow*m12 */ - addps %xmm2, %xmm0 /* ox*m3+oy*m7+oz*m11 | ... */ - prefetch 16(%rdx) - addps %xmm3, %xmm0 /* ox*m3+oy*m7+oz*m11+ow*m15 | ... */ - - movaps %xmm0, (%rdi) /* ->D(3) | ->D(2) | ->D(1) | ->D(0) */ - addq $16, %rdi - - dec %ecx - jnz p4_3d_loop - -p4_3d_done: - .byte 0xf3 - ret - - -.align 16 -.globl _mesa_x86_64_transform_points4_identity -.hidden _mesa_x86_64_transform_points4_identity -_mesa_x86_64_transform_points4_identity: - - movl V4F_COUNT(%rdx), %ecx /* count */ - movzbl V4F_STRIDE(%rdx), %eax /* stride */ - - movl %ecx, V4F_COUNT(%rdi) /* set dest count */ - movl $4, V4F_SIZE(%rdi) /* set dest size */ - orl $VEC_SIZE_4, V4F_FLAGS(%rdi)/* set dest flags */ - - test %ecx, %ecx - jz p4_identity_done - - movq V4F_START(%rdx), %rsi /* ptr to first src vertex */ - movq V4F_START(%rdi), %rdi /* ptr to first dest vertex */ - prefetch 64(%rsi) - prefetchw 64(%rdi) - - add %ecx, %ecx - - rep movsq - -p4_identity_done: - .byte 0xf3 - ret - - -.align 16 -.globl _mesa_3dnow_transform_points4_3d_no_rot -.hidden _mesa_3dnow_transform_points4_3d_no_rot -_mesa_3dnow_transform_points4_3d_no_rot: - - movl V4F_COUNT(%rdx), %ecx /* count */ - movzbl V4F_STRIDE(%rdx), %eax /* stride */ - - movl %ecx, V4F_COUNT(%rdi) /* set dest count */ - movl $4, V4F_SIZE(%rdi) /* set dest size */ - .byte 0x66, 0x66, 0x90 /* manual align += 3 */ - orl $VEC_SIZE_4, V4F_FLAGS(%rdi)/* set dest flags */ - - test %ecx, %ecx - .byte 0x66, 0x66, 0x90 /* manual align += 3 */ - jz p4_3d_no_rot_done - - movq V4F_START(%rdx), %rdx /* ptr to first src vertex */ - movq V4F_START(%rdi), %rdi /* ptr to first dest vertex */ - - prefetch (%rdx) - - movd (%rsi), %mm0 /* | m00 */ - .byte 0x66, 0x66, 0x90 /* manual align += 3 */ - punpckldq 20(%rsi), %mm0 /* m11 | m00 */ - - movd 40(%rsi), %mm2 /* | m22 */ - movq 48(%rsi), %mm1 /* m31 | m30 */ - - punpckldq 56(%rsi), %mm2 /* m11 | m00 */ - -p4_3d_no_rot_loop: - - prefetchw 32(%rdi) - - movq (%rdx), %mm4 /* x1 | x0 */ - movq 8(%rdx), %mm5 /* x3 | x2 */ - movd 12(%rdx), %mm7 /* | x3 */ - - movq %mm5, %mm6 /* x3 | x2 */ - pfmul %mm0, %mm4 /* x1*m11 | x0*m00 */ - - punpckhdq %mm6, %mm6 /* x3 | x3 */ - pfmul %mm2, %mm5 /* x3*m32 | x2*m22 */ - - pfmul %mm1, %mm6 /* x3*m31 | x3*m30 */ - pfacc %mm7, %mm5 /* x3 | x2*m22+x3*m32 */ - - pfadd %mm6, %mm4 /* x1*m11+x3*m31 | x0*m00+x3*m30 */ - - addq %rax, %rdx - movq %mm4, (%rdi) /* write r0, r1 */ - movq %mm5, 8(%rdi) /* write r2, r3 */ - - addq $16, %rdi - - decl %ecx - prefetch 32(%rdx) - jnz p4_3d_no_rot_loop - -p4_3d_no_rot_done: - femms - ret - - -.align 16 -.globl _mesa_3dnow_transform_points4_perspective -.hidden _mesa_3dnow_transform_points4_perspective -_mesa_3dnow_transform_points4_perspective: - - movl V4F_COUNT(%rdx), %ecx /* count */ - movzbl V4F_STRIDE(%rdx), %eax /* stride */ - - movl %ecx, V4F_COUNT(%rdi) /* set dest count */ - movl $4, V4F_SIZE(%rdi) /* set dest size */ - orl $VEC_SIZE_4, V4F_FLAGS(%rdi)/* set dest flags */ - - test %ecx, %ecx - .byte 0x66, 0x66, 0x90 /* manual align += 3 */ - jz p4_perspective_done - - movq V4F_START(%rdx), %rdx /* ptr to first src vertex */ - movq V4F_START(%rdi), %rdi /* ptr to first dest vertex */ - - movd (%rsi), %mm0 /* | m00 */ - pxor %mm7, %mm7 /* 0 | 0 */ - punpckldq 20(%rsi), %mm0 /* m11 | m00 */ - - movq 32(%rsi), %mm2 /* m21 | m20 */ - prefetch (%rdx) - - movd 40(%rsi), %mm1 /* | m22 */ - - .byte 0x66, 0x66, 0x90 /* manual align += 3 */ - punpckldq 56(%rsi), %mm1 /* m32 | m22 */ - - -p4_perspective_loop: - - prefetchw 32(%rdi) /* prefetch 2 vertices ahead */ - - movq (%rdx), %mm4 /* x1 | x0 */ - movq 8(%rdx), %mm5 /* x3 | x2 */ - movd 8(%rdx), %mm3 /* | x2 */ - - movq %mm5, %mm6 /* x3 | x2 */ - pfmul %mm0, %mm4 /* x1*m11 | x0*m00 */ - - punpckldq %mm5, %mm5 /* x2 | x2 */ - - pfmul %mm2, %mm5 /* x2*m21 | x2*m20 */ - pfsubr %mm7, %mm3 /* | -x2 */ - - pfmul %mm1, %mm6 /* x3*m32 | x2*m22 */ - pfadd %mm4, %mm5 /* x1*m11+x2*m21 | x0*m00+x2*m20 */ - - pfacc %mm3, %mm6 /* -x2 | x2*m22+x3*m32 */ - - movq %mm5, (%rdi) /* write r0, r1 */ - addq %rax, %rdx - movq %mm6, 8(%rdi) /* write r2, r3 */ - - addq $16, %rdi - - decl %ecx - prefetch 32(%rdx) /* hopefully stride is zero */ - jnz p4_perspective_loop - -p4_perspective_done: - femms - ret - -.align 16 -.globl _mesa_3dnow_transform_points4_2d_no_rot -.hidden _mesa_3dnow_transform_points4_2d_no_rot -_mesa_3dnow_transform_points4_2d_no_rot: - - movl V4F_COUNT(%rdx), %ecx /* count */ - movzbl V4F_STRIDE(%rdx), %eax /* stride */ - - movl %ecx, V4F_COUNT(%rdi) /* set dest count */ - movl $4, V4F_SIZE(%rdi) /* set dest size */ - orl $VEC_SIZE_4, V4F_FLAGS(%rdi)/* set dest flags */ - - test %ecx, %ecx - .byte 0x90 /* manual align += 1 */ - jz p4_2d_no_rot_done - - movq V4F_START(%rdx), %rdx /* ptr to first src vertex */ - movq V4F_START(%rdi), %rdi /* ptr to first dest vertex */ - - movd (%rsi), %mm0 /* | m00 */ - prefetch (%rdx) - punpckldq 20(%rsi), %mm0 /* m11 | m00 */ - - movq 48(%rsi), %mm1 /* m31 | m30 */ - -p4_2d_no_rot_loop: - - prefetchw 32(%rdi) /* prefetch 2 vertices ahead */ - - movq (%rdx), %mm4 /* x1 | x0 */ - movq 8(%rdx), %mm5 /* x3 | x2 */ - - pfmul %mm0, %mm4 /* x1*m11 | x0*m00 */ - movq %mm5, %mm6 /* x3 | x2 */ - - punpckhdq %mm6, %mm6 /* x3 | x3 */ - - addq %rax, %rdx - pfmul %mm1, %mm6 /* x3*m31 | x3*m30 */ - - prefetch 32(%rdx) /* hopefully stride is zero */ - pfadd %mm4, %mm6 /* x1*m11+x3*m31 | x0*m00+x3*m30 */ - - movq %mm6, (%rdi) /* write r0, r1 */ - movq %mm5, 8(%rdi) /* write r2, r3 */ - - addq $16, %rdi - - decl %ecx - jnz p4_2d_no_rot_loop - -p4_2d_no_rot_done: - femms - ret - - -.align 16 -.globl _mesa_3dnow_transform_points4_2d -.hidden _mesa_3dnow_transform_points4_2d -_mesa_3dnow_transform_points4_2d: - - movl V4F_COUNT(%rdx), %ecx /* count */ - movzbl V4F_STRIDE(%rdx), %eax /* stride */ - - movl %ecx, V4F_COUNT(%rdi) /* set dest count */ - movl $4, V4F_SIZE(%rdi) /* set dest size */ - .byte 0x66, 0x66, 0x90 /* manual align += 4 */ - orl $VEC_SIZE_4, V4F_FLAGS(%rdi)/* set dest flags */ - - test %ecx, %ecx - .byte 0x66, 0x66, 0x90 /* manual align += 4 */ - jz p4_2d_done - - movq V4F_START(%rdx), %rdx /* ptr to first src vertex */ - movq V4F_START(%rdi), %rdi /* ptr to first dest vertex */ - - movd (%rsi), %mm0 /* | m00 */ - movd 4(%rsi), %mm1 /* | m01 */ - - prefetch (%rdx) - - punpckldq 16(%rsi), %mm0 /* m10 | m00 */ - .byte 0x66, 0x66, 0x90 /* manual align += 4 */ - punpckldq 20(%rsi), %mm1 /* m11 | m01 */ - - movq 48(%rsi), %mm2 /* m31 | m30 */ - -p4_2d_loop: - - prefetchw 32(%rdi) /* prefetch 2 vertices ahead */ - - movq (%rdx), %mm3 /* x1 | x0 */ - movq 8(%rdx), %mm5 /* x3 | x2 */ - - movq %mm3, %mm4 /* x1 | x0 */ - movq %mm5, %mm6 /* x3 | x2 */ - - pfmul %mm1, %mm4 /* x1*m11 | x0*m01 */ - punpckhdq %mm6, %mm6 /* x3 | x3 */ - - pfmul %mm0, %mm3 /* x1*m10 | x0*m00 */ - - addq %rax, %rdx - pfacc %mm4, %mm3 /* x0*m01+x1*m11 | x0*m00+x1*m10 */ - - pfmul %mm2, %mm6 /* x3*m31 | x3*m30 */ - prefetch 32(%rdx) /* hopefully stride is zero */ - - pfadd %mm6, %mm3 /* r1 | r0 */ - - movq %mm3, (%rdi) /* write r0, r1 */ - movq %mm5, 8(%rdi) /* write r2, r3 */ - - addq $16, %rdi - - decl %ecx - jnz p4_2d_loop - -p4_2d_done: - femms - ret - -#endif - -#if defined (__ELF__) && defined (__linux__) - .section .note.GNU-stack,"",%progbits -#endif diff --git a/dll/opengl/mesa/x86/3dnow.c b/dll/opengl/mesa/x86/3dnow.c deleted file mode 100644 index de2fb1e2aad..00000000000 --- a/dll/opengl/mesa/x86/3dnow.c +++ /dev/null @@ -1,91 +0,0 @@ - -/* - * Mesa 3-D graphics library - * Version: 5.0.1 - * - * Copyright (C) 1999-2003 Brian Paul All Rights Reserved. - * - * Permission is hereby granted, free of charge, to any person obtaining a - * copy of this software and associated documentation files (the "Software"), - * to deal in the Software without restriction, including without limitation - * the rights to use, copy, modify, merge, publish, distribute, sublicense, - * and/or sell copies of the Software, and to permit persons to whom the - * Software is furnished to do so, subject to the following conditions: - * - * The above copyright notice and this permission notice shall be included - * in all copies or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS - * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL - * BRIAN PAUL BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN - * AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN - * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. - */ - -/* - * 3DNow! optimizations contributed by - * Holger Waechtler - */ - -#include "main/glheader.h" -#include "main/context.h" -#include "math/m_xform.h" -#include "tnl/t_context.h" - -#include "3dnow.h" -#include "x86_xform.h" - -#ifdef DEBUG_MATH -#include "math/m_debug.h" -#endif - - -#ifdef USE_3DNOW_ASM -DECLARE_XFORM_GROUP( 3dnow, 2 ) -DECLARE_XFORM_GROUP( 3dnow, 3 ) -DECLARE_XFORM_GROUP( 3dnow, 4 ) - -DECLARE_NORM_GROUP( 3dnow ) - - -extern void _ASMAPI -_mesa_v16_3dnow_general_xform( GLfloat *first_vert, - const GLfloat *m, - const GLfloat *src, - GLuint src_stride, - GLuint count ); - -extern void _ASMAPI -_mesa_3dnow_project_vertices( GLfloat *first, - GLfloat *last, - const GLfloat *m, - GLuint stride ); - -extern void _ASMAPI -_mesa_3dnow_project_clipped_vertices( GLfloat *first, - GLfloat *last, - const GLfloat *m, - GLuint stride, - const GLubyte *clipmask ); -#endif - - -void _mesa_init_3dnow_transform_asm( void ) -{ -#ifdef USE_3DNOW_ASM - ASSIGN_XFORM_GROUP( 3dnow, 2 ); - ASSIGN_XFORM_GROUP( 3dnow, 3 ); - ASSIGN_XFORM_GROUP( 3dnow, 4 ); - - /* There's a bug somewhere in the 3dnow_normal.S file that causes - * bad shading. Disable for now. - ASSIGN_NORM_GROUP( 3dnow ); - */ - -#ifdef DEBUG_MATH - _math_test_all_transform_functions( "3DNow!" ); - _math_test_all_normal_transform_functions( "3DNow!" ); -#endif -#endif -} diff --git a/dll/opengl/mesa/x86/3dnow.h b/dll/opengl/mesa/x86/3dnow.h deleted file mode 100644 index 1c1fedcd4f3..00000000000 --- a/dll/opengl/mesa/x86/3dnow.h +++ /dev/null @@ -1,36 +0,0 @@ - -/* - * Mesa 3-D graphics library - * Version: 3.5 - * - * Copyright (C) 1999-2001 Brian Paul All Rights Reserved. - * - * Permission is hereby granted, free of charge, to any person obtaining a - * copy of this software and associated documentation files (the "Software"), - * to deal in the Software without restriction, including without limitation - * the rights to use, copy, modify, merge, publish, distribute, sublicense, - * and/or sell copies of the Software, and to permit persons to whom the - * Software is furnished to do so, subject to the following conditions: - * - * The above copyright notice and this permission notice shall be included - * in all copies or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS - * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL - * BRIAN PAUL BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN - * AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN - * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. - */ - -/* - * 3DNow! optimizations contributed by - * Holger Waechtler - */ - -#ifndef __3DNOW_H__ -#define __3DNOW_H__ - -void _mesa_init_3dnow_transform_asm( void ); - -#endif diff --git a/dll/opengl/mesa/x86/3dnow_normal.S b/dll/opengl/mesa/x86/3dnow_normal.S deleted file mode 100644 index 7f5f6b357f4..00000000000 --- a/dll/opengl/mesa/x86/3dnow_normal.S +++ /dev/null @@ -1,852 +0,0 @@ - -/* - * Mesa 3-D graphics library - * Version: 5.1 - * - * Copyright (C) 1999-2003 Brian Paul All Rights Reserved. - * - * Permission is hereby granted, free of charge, to any person obtaining a - * copy of this software and associated documentation files (the "Software"), - * to deal in the Software without restriction, including without limitation - * the rights to use, copy, modify, merge, publish, distribute, sublicense, - * and/or sell copies of the Software, and to permit persons to whom the - * Software is furnished to do so, subject to the following conditions: - * - * The above copyright notice and this permission notice shall be included - * in all copies or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS - * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL - * BRIAN PAUL BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN - * AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN - * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. - */ - -/* - * 3Dnow assembly code by Holger Waechtler - */ - -#ifdef USE_3DNOW_ASM - -#include "assyntax.h" -#include "matypes.h" -#include "norm_args.h" - - SEG_TEXT - -#define M(i) REGOFF(i * 4, ECX) -#define STRIDE REGOFF(12, ESI) - - -ALIGNTEXT16 -GLOBL GLNAME(_mesa_3dnow_transform_normalize_normals) -HIDDEN(_mesa_3dnow_transform_normalize_normals) -GLNAME(_mesa_3dnow_transform_normalize_normals): - -#define FRAME_OFFSET 12 - - PUSH_L ( EDI ) - PUSH_L ( ESI ) - PUSH_L ( EBP ) - - MOV_L ( ARG_LENGTHS, EDI ) - MOV_L ( ARG_IN, ESI ) - MOV_L ( ARG_DEST, EAX ) - MOV_L ( REGOFF(V4F_COUNT, ESI), EBP ) /* dest->count = in->count */ - MOV_L ( EBP, REGOFF(V4F_COUNT, EAX) ) - MOV_L ( REGOFF(V4F_START, ESI), EDX ) /* in->start */ - MOV_L ( REGOFF(V4F_START, EAX), EAX ) /* dest->start */ - MOV_L ( ARG_MAT, ECX ) - MOV_L ( REGOFF(MATRIX_INV, ECX), ECX ) /* mat->inv */ - - CMP_L ( CONST(0), EBP ) /* count > 0 ?? */ - JE ( LLBL (G3TN_end) ) - - MOV_L ( REGOFF (V4F_COUNT, ESI), EBP ) - FEMMS - - PUSH_L ( EBP ) - PUSH_L ( EAX ) - PUSH_L ( EDX ) /* save counter & pointer for */ - /* the normalize pass */ -#undef FRAME_OFFSET -#define FRAME_OFFSET 24 - - MOVQ ( M(0), MM3 ) /* m1 | m0 */ - MOVQ ( M(4), MM4 ) /* m5 | m4 */ - - MOVD ( M(2), MM5 ) /* | m2 */ - PUNPCKLDQ ( M(6), MM5 ) /* m6 | m2 */ - - MOVQ ( M(8), MM6 ) /* m9 | m8 */ - MOVQ ( M(10), MM7 ) /* | m10 */ - - CMP_L ( CONST(0), EDI ) /* lengths == 0 ? */ - JNE ( LLBL (G3TN_scale_end ) ) - - MOVD ( ARG_SCALE, MM0 ) /* | scale */ - PUNPCKLDQ ( MM0, MM0 ) /* scale | scale */ - - PFMUL ( MM0, MM3 ) /* scale * m1 | scale * m0 */ - PFMUL ( MM0, MM4 ) /* scale * m5 | scale * m4 */ - PFMUL ( MM0, MM5 ) /* scale * m6 | scale * m2 */ - PFMUL ( MM0, MM6 ) /* scale * m9 | scale * m8 */ - PFMUL ( MM0, MM7 ) /* | scale * m10 */ - -ALIGNTEXT32 -LLBL (G3TN_scale_end): -LLBL (G3TN_transform): - MOVQ ( REGIND (EDX), MM0 ) /* x1 | x0 */ - MOVD ( REGOFF (8, EDX), MM2 ) /* | x2 */ - - MOVQ ( MM0, MM1 ) /* x1 | x0 */ - PUNPCKLDQ ( MM2, MM2 ) /* x2 | x2 */ - - PFMUL ( MM3, MM0 ) /* x1*m1 | x0*m0 */ - ADD_L ( CONST(16), EAX ) /* next r */ - - PREFETCHW ( REGIND(EAX) ) - - PFMUL ( MM4, MM1 ) /* x1*m5 | x0*m4 */ - PFACC ( MM1, MM0 ) /* x0*m4+x1*m5 | x0*m0+x1*m1 */ - - PFMUL ( MM5, MM2 ) /* x2*m6 | x2*m2 */ - PFADD ( MM2, MM0 ) /* x0*m4+x1*m5+x2*m6| x0*m0+...+x2**/ - - MOVQ ( REGIND (EDX), MM1 ) /* x1 | x0 */ - MOVQ ( MM0, REGOFF(-16, EAX) ) /* write r0, r1 */ - - PFMUL ( MM6, MM1 ) /* x1*m9 | x0*m8 */ - MOVD ( REGOFF (8, EDX), MM2 ) /* | x2 */ - - PFMUL ( MM7, MM2 ) /* | x2*m10 */ - PFACC ( MM1, MM1 ) /* *not used* | x0*m8+x1*m9 */ - - PFADD ( MM2, MM1 ) /* *not used* | x0*m8+x1*m9+x2*m*/ - ADD_L ( STRIDE, EDX ) /* next normal */ - - PREFETCH ( REGIND(EDX) ) - - MOVD ( MM1, REGOFF(-8, EAX) ) /* write r2 */ - SUB_L ( CONST(1), EBP ) /* decrement normal counter */ - JNZ ( LLBL (G3TN_transform) ) - - - POP_L ( EDX ) /* end of transform --- */ - POP_L ( EAX ) /* now normalizing ... */ - POP_L ( EBP ) - - CMP_L ( CONST(0), EDI ) /* lengths == 0 ? */ - JE ( LLBL (G3TN_norm ) ) /* calculate lengths */ - - -ALIGNTEXT32 -LLBL (G3TN_norm_w_lengths): - - PREFETCHW ( REGOFF(12,EAX) ) - - MOVQ ( REGIND(EAX), MM0 ) /* x1 | x0 */ - MOVD ( REGOFF(8, EAX), MM1 ) /* | x2 */ - - MOVD ( REGIND (EDI), MM3 ) /* | length (x) */ - PFMUL ( MM3, MM1 ) /* | x2 (normalize*/ - - PUNPCKLDQ ( MM3, MM3 ) /* length (x) | length (x) */ - PFMUL ( MM3, MM0 ) /* x1 (normalized) | x0 (normalize*/ - - ADD_L ( STRIDE, EDX ) /* next normal */ - ADD_L ( CONST(4), EDI ) /* next length */ - - PREFETCH ( REGIND(EDI) ) - - MOVQ ( MM0, REGIND(EAX) ) /* write new x0, x1 */ - MOVD ( MM1, REGOFF(8, EAX) ) /* write new x2 */ - - ADD_L ( CONST(16), EAX ) /* next r */ - SUB_L ( CONST(1), EBP ) /* decrement normal counter */ - - JNZ ( LLBL (G3TN_norm_w_lengths) ) - JMP ( LLBL (G3TN_exit_3dnow) ) - -ALIGNTEXT32 -LLBL (G3TN_norm): - - PREFETCHW ( REGIND(EAX) ) - - MOVQ ( REGIND (EAX), MM0 ) /* x1 | x0 */ - MOVD ( REGOFF(8, EAX), MM1 ) /* | x2 */ - - MOVQ ( MM0, MM3 ) /* x1 | x0 */ - MOVQ ( MM1, MM4 ) /* | x2 */ - - PFMUL ( MM0, MM3 ) /* x1*x1 | x0*x0 */ - ADD_L ( CONST(16), EAX ) /* next r */ - - PFMUL ( MM1, MM4 ) /* | x2*x2 */ - PFADD ( MM4, MM3 ) /* | x0*x0+x2*x2 */ - - PFACC ( MM3, MM3 ) /* **not used** | x0*x0+x1*x1+x2**/ - PFRSQRT ( MM3, MM5 ) /* 1/sqrt (x0*x0+x1*x1+x2*x2) */ - - MOVQ ( MM5, MM4 ) - PUNPCKLDQ ( MM3, MM3 ) - - SUB_L ( CONST(1), EBP ) /* decrement normal counter */ - PFMUL ( MM5, MM5 ) - - PFRSQIT1 ( MM3, MM5 ) - PFRCPIT2 ( MM4, MM5 ) - - PFMUL ( MM5, MM0 ) /* x1 (normalized) | x0 (normalize*/ - - MOVQ ( MM0, REGOFF(-16, EAX) ) /* write new x0, x1 */ - PFMUL ( MM5, MM1 ) /* | x2 (normalize*/ - - MOVD ( MM1, REGOFF(-8, EAX) ) /* write new x2 */ - JNZ ( LLBL (G3TN_norm) ) - -LLBL (G3TN_exit_3dnow): - FEMMS - -LLBL (G3TN_end): - POP_L ( EBP ) - POP_L ( ESI ) - POP_L ( EDI ) - RET - - - -ALIGNTEXT16 -GLOBL GLNAME(_mesa_3dnow_transform_normalize_normals_no_rot) -HIDDEN(_mesa_3dnow_transform_normalize_normals_no_rot) -GLNAME(_mesa_3dnow_transform_normalize_normals_no_rot): - -#undef FRAME_OFFSET -#define FRAME_OFFSET 12 - - PUSH_L ( EDI ) - PUSH_L ( ESI ) - PUSH_L ( EBP ) - - MOV_L ( ARG_LENGTHS, EDI ) - MOV_L ( ARG_IN, ESI ) - MOV_L ( ARG_DEST, EAX ) - MOV_L ( REGOFF(V4F_COUNT, ESI), EBP ) /* dest->count = in->count */ - MOV_L ( EBP, REGOFF(V4F_COUNT, EAX) ) - MOV_L ( ARG_MAT, ECX ) - MOV_L ( REGOFF(V4F_START, EAX), EAX ) /* dest->start */ - MOV_L ( REGOFF(MATRIX_INV, ECX), ECX ) /* mat->inv */ - MOV_L ( REGOFF(V4F_START, ESI), EDX ) /* in->start */ - - CMP_L ( CONST(0), EBP ) /* count > 0 ?? */ - JE ( LLBL (G3TNNR_end) ) - - FEMMS - - MOVD ( M(0), MM0 ) /* | m0 */ - PUNPCKLDQ ( M(5), MM0 ) /* m5 | m0 */ - - MOVD ( M(10), MM2 ) /* | m10 */ - PUNPCKLDQ ( MM2, MM2 ) /* m10 | m10 */ - - CMP_L ( CONST(0), EDI ) /* lengths == 0 ? */ - JNE ( LLBL (G3TNNR_scale_end ) ) - - MOVD ( ARG_SCALE, MM7 ) /* | scale */ - PUNPCKLDQ ( MM7, MM7 ) /* scale | scale */ - - PFMUL ( MM7, MM0 ) /* scale * m5 | scale * m0 */ - PFMUL ( MM7, MM2 ) /* scale * m10 | scale * m10 */ - -ALIGNTEXT32 -LLBL (G3TNNR_scale_end): - CMP_L ( CONST(0), EDI ) /* lengths == 0 ? */ - JE ( LLBL (G3TNNR_norm) ) /* need to calculate lengths */ - - MOVD ( REGIND(EDI), MM3 ) /* | length (x) */ - - -ALIGNTEXT32 -LLBL (G3TNNR_norm_w_lengths): /* use precalculated lengths */ - - PREFETCHW ( REGIND(EAX) ) - - MOVQ ( REGIND(EDX), MM6 ) /* x1 | x0 */ - MOVD ( REGOFF(8, EDX), MM7 ) /* | x2 */ - - PFMUL ( MM0, MM6 ) /* x1*m5 | x0*m0 */ - ADD_L ( STRIDE, EDX ) /* next normal */ - - PREFETCH ( REGIND(EDX) ) - - PFMUL ( MM2, MM7 ) /* | x2*m10 */ - ADD_L ( CONST(16), EAX ) /* next r */ - - PFMUL ( MM3, MM7 ) /* | x2 (normalized) */ - PUNPCKLDQ ( MM3, MM3 ) /* length (x) | length (x) */ - - ADD_L ( CONST(4), EDI ) /* next length */ - PFMUL ( MM3, MM6 ) /* x1 (normalized) | x0 (normalized) */ - - SUB_L ( CONST(1), EBP ) /* decrement normal counter */ - MOVQ ( MM6, REGOFF(-16, EAX) ) /* write r0, r1 */ - - MOVD ( MM7, REGOFF(-8, EAX) ) /* write r2 */ - MOVD ( REGIND(EDI), MM3 ) /* | length (x) */ - - JNZ ( LLBL (G3TNNR_norm_w_lengths) ) - JMP ( LLBL (G3TNNR_exit_3dnow) ) - -ALIGNTEXT32 -LLBL (G3TNNR_norm): /* need to calculate lengths */ - - PREFETCHW ( REGIND(EAX) ) - - MOVQ ( REGIND(EDX), MM6 ) /* x1 | x0 */ - MOVD ( REGOFF(8, EDX), MM7 ) /* | x2 */ - - PFMUL ( MM0, MM6 ) /* x1*m5 | x0*m0 */ - ADD_L ( CONST(16), EAX ) /* next r */ - - PFMUL ( MM2, MM7 ) /* | x2*m10 */ - MOVQ ( MM6, MM3 ) /* x1 (transformed)| x0 (transformed) */ - - MOVQ ( MM7, MM4 ) /* | x2 (transformed) */ - PFMUL ( MM6, MM3 ) /* x1*x1 | x0*x0 */ - - - PFMUL ( MM7, MM4 ) /* | x2*x2 */ - PFACC ( MM3, MM3 ) /* **not used** | x0*x0+x1*x1 */ - - PFADD ( MM4, MM3 ) /* | x0*x0+x1*x1+x2*x2*/ - ADD_L ( STRIDE, EDX ) /* next normal */ - - PREFETCH ( REGIND(EDX) ) - - PFRSQRT ( MM3, MM5 ) /* 1/sqrt (x0*x0+x1*x1+x2*x2) */ - MOVQ ( MM5, MM4 ) - - PUNPCKLDQ ( MM3, MM3 ) - PFMUL ( MM5, MM5 ) - - PFRSQIT1 ( MM3, MM5 ) - SUB_L ( CONST(1), EBP ) /* decrement normal counter */ - - PFRCPIT2 ( MM4, MM5 ) - PFMUL ( MM5, MM6 ) /* x1 (normalized) | x0 (normalized) */ - - MOVQ ( MM6, REGOFF(-16, EAX) ) /* write r0, r1 */ - PFMUL ( MM5, MM7 ) /* | x2 (normalized) */ - - MOVD ( MM7, REGOFF(-8, EAX) ) /* write r2 */ - JNZ ( LLBL (G3TNNR_norm) ) - - -LLBL (G3TNNR_exit_3dnow): - FEMMS - -LLBL (G3TNNR_end): - POP_L ( EBP ) - POP_L ( ESI ) - POP_L ( EDI ) - RET - - - - - - -ALIGNTEXT16 -GLOBL GLNAME(_mesa_3dnow_transform_rescale_normals_no_rot) -HIDDEN(_mesa_3dnow_transform_rescale_normals_no_rot) -GLNAME(_mesa_3dnow_transform_rescale_normals_no_rot): - -#undef FRAME_OFFSET -#define FRAME_OFFSET 12 - - PUSH_L ( EDI ) - PUSH_L ( ESI ) - PUSH_L ( EBP ) - - MOV_L ( ARG_IN, EAX ) - MOV_L ( ARG_DEST, EDX ) - MOV_L ( REGOFF(V4F_COUNT, EAX), EBP ) /* dest->count = in->count */ - MOV_L ( EBP, REGOFF(V4F_COUNT, EDX) ) - MOV_L ( ARG_IN, ESI ) - MOV_L ( ARG_MAT, ECX ) - MOV_L ( REGOFF(MATRIX_INV, ECX), ECX ) /* mat->inv */ - MOV_L ( REGOFF(V4F_START, EDX), EAX ) /* dest->start */ - MOV_L ( REGOFF(V4F_START, ESI), EDX ) /* in->start */ - - CMP_L ( CONST(0), EBP ) - JE ( LLBL (G3TRNR_end) ) - - FEMMS - - MOVD ( ARG_SCALE, MM6 ) /* | scale */ - PUNPCKLDQ ( MM6, MM6 ) /* scale | scale */ - - MOVD ( REGIND(ECX), MM0 ) /* | m0 */ - PUNPCKLDQ ( REGOFF(20, ECX), MM0 ) /* m5 | m0 */ - - PFMUL ( MM6, MM0 ) /* scale*m5 | scale*m0 */ - MOVD ( REGOFF(40, ECX), MM2 ) /* | m10 */ - - PFMUL ( MM6, MM2 ) /* | scale*m10 */ - -ALIGNTEXT32 -LLBL (G3TRNR_rescale): - - PREFETCHW ( REGIND(EAX) ) - - MOVQ ( REGIND(EDX), MM4 ) /* x1 | x0 */ - MOVD ( REGOFF(8, EDX), MM5 ) /* | x2 */ - - PFMUL ( MM0, MM4 ) /* x1*m5 | x0*m0 */ - ADD_L ( STRIDE, EDX ) /* next normal */ - - PREFETCH ( REGIND(EDX) ) - - PFMUL ( MM2, MM5 ) /* | x2*m10 */ - ADD_L ( CONST(16), EAX ) /* next r */ - - SUB_L ( CONST(1), EBP ) /* decrement normal counter */ - MOVQ ( MM4, REGOFF(-16, EAX) ) /* write r0, r1 */ - - MOVD ( MM5, REGOFF(-8, EAX) ) /* write r2 */ - JNZ ( LLBL (G3TRNR_rescale) ) /* cnt > 0 ? -> process next normal */ - - FEMMS - -LLBL (G3TRNR_end): - POP_L ( EBP ) - POP_L ( ESI ) - POP_L ( EDI ) - RET - - - - - -ALIGNTEXT16 -GLOBL GLNAME(_mesa_3dnow_transform_rescale_normals) -HIDDEN(_mesa_3dnow_transform_rescale_normals) -GLNAME(_mesa_3dnow_transform_rescale_normals): - -#undef FRAME_OFFSET -#define FRAME_OFFSET 8 - - PUSH_L ( EDI ) - PUSH_L ( ESI ) - - MOV_L ( ARG_IN, ESI ) - MOV_L ( ARG_DEST, EAX ) - MOV_L ( ARG_MAT, ECX ) - MOV_L ( REGOFF(V4F_COUNT, ESI), EDI ) /* dest->count = in->count */ - MOV_L ( EDI, REGOFF(V4F_COUNT, EAX) ) - MOV_L ( REGOFF(V4F_START, EAX), EAX ) /* dest->start */ - MOV_L ( REGOFF(V4F_START, ESI), EDX ) /* in->start */ - MOV_L ( REGOFF(MATRIX_INV, ECX), ECX ) /* mat->inv */ - - CMP_L ( CONST(0), EDI ) - JE ( LLBL (G3TR_end) ) - - FEMMS - - MOVQ ( REGIND(ECX), MM3 ) /* m1 | m0 */ - - MOVQ ( REGOFF(16,ECX), MM4 ) /* m5 | m4 */ - MOVD ( ARG_SCALE, MM0 ) /* scale */ - - MOVD ( REGOFF(8,ECX), MM5 ) /* | m2 */ - PUNPCKLDQ ( MM0, MM0 ) /* scale | scale */ - - PUNPCKLDQ ( REGOFF(24, ECX), MM5 ) - PFMUL ( MM0, MM3 ) /* scale*m1 | scale*m0 */ - - MOVQ ( REGOFF(32, ECX), MM6 ) /* m9 | m8*/ - PFMUL ( MM0, MM4 ) /* scale*m5 | scale*m4 */ - - MOVD ( REGOFF(40, ECX), MM7 ) /* | m10 */ - PFMUL ( MM0, MM5 ) /* scale*m6 | scale*m2 */ - - PFMUL ( MM0, MM6 ) /* scale*m9 | scale*m8 */ - - PFMUL ( MM0, MM7 ) /* | scale*m10 */ - -ALIGNTEXT32 -LLBL (G3TR_rescale): - - PREFETCHW ( REGIND(EAX) ) - - MOVQ ( REGIND(EDX), MM0 ) /* x1 | x0 */ - MOVD ( REGOFF(8, EDX), MM2 ) /* | x2 */ - - MOVQ ( MM0, MM1 ) /* x1 | x0 */ - PUNPCKLDQ ( MM2, MM2 ) /* x2 | x2 */ - - PFMUL ( MM3, MM0 ) /* x1*m1 | x0*m0 */ - ADD_L ( CONST(16), EAX ) /* next r */ - - PFMUL ( MM4, MM1 ) /* x1*m5 | x0*m4 */ - PFACC ( MM1, MM0 ) /* x0*m4+x1*m5 | x0*m0+x1*m1 */ - - MOVQ ( REGIND(EDX), MM1 ) /* x1 | x0 */ - - PFMUL ( MM5, MM2 ) /* x2*m6 | x2*m2 */ - PFADD ( MM2, MM0 ) /* x0*m4...+x2*m6| x0*m0+x1*m1+x2*m2 */ - - MOVD ( REGOFF(8, EDX), MM2 ) /* | x2 */ - ADD_L ( STRIDE, EDX ) /* next normal */ - - PREFETCH ( REGIND(EDX) ) - - MOVQ ( MM0, REGOFF(-16, EAX) ) /* write r0, r1 */ - PFMUL ( MM6, MM1 ) /* x1*m9 | x0*m8 */ - - PFMUL ( MM7, MM2 ) /* | x2*m10 */ - PFACC ( MM1, MM1 ) /* *not used* | x0*m8+x1*m9 */ - - PFADD ( MM2, MM1 ) /* *not used* | x0*m8+x1*m9+x2*m10 */ - MOVD ( MM1, REGOFF(-8, EAX) ) /* write r2 */ - - SUB_L ( CONST(1), EDI ) /* decrement normal counter */ - JNZ ( LLBL (G3TR_rescale) ) - - FEMMS - -LLBL (G3TR_end): - POP_L ( ESI ) - POP_L ( EDI ) - RET - - - - - - - -ALIGNTEXT16 -GLOBL GLNAME(_mesa_3dnow_transform_normals_no_rot) -HIDDEN(_mesa_3dnow_transform_normals_no_rot) -GLNAME(_mesa_3dnow_transform_normals_no_rot): - -#undef FRAME_OFFSET -#define FRAME_OFFSET 8 - - PUSH_L ( EDI ) - PUSH_L ( ESI ) - - MOV_L ( ARG_IN, ESI ) - MOV_L ( ARG_DEST, EAX ) - MOV_L ( ARG_MAT, ECX ) - MOV_L ( REGOFF(V4F_COUNT, ESI), EDI ) /* dest->count = in->count */ - MOV_L ( EDI, REGOFF(V4F_COUNT, EAX) ) - MOV_L ( REGOFF(V4F_START, EAX), EAX ) /* dest->start */ - MOV_L ( REGOFF(V4F_START, ESI), EDX ) /* in->start */ - MOV_L ( REGOFF(MATRIX_INV, ECX), ECX ) /* mat->inv */ - - CMP_L ( CONST(0), EDI ) - JE ( LLBL (G3TNR_end) ) - - FEMMS - - MOVD ( REGIND(ECX), MM0 ) /* | m0 */ - PUNPCKLDQ ( REGOFF(20, ECX), MM0 ) /* m5 | m0 */ - - MOVD ( REGOFF(40, ECX), MM2 ) /* | m10 */ - PUNPCKLDQ ( MM2, MM2 ) /* m10 | m10 */ - -ALIGNTEXT32 -LLBL (G3TNR_transform): - - PREFETCHW ( REGIND(EAX) ) - - MOVQ ( REGIND(EDX), MM4 ) /* x1 | x0 */ - MOVD ( REGOFF(8, EDX), MM5 ) /* | x2 */ - - PFMUL ( MM0, MM4 ) /* x1*m5 | x0*m0 */ - ADD_L ( STRIDE, EDX) /* next normal */ - - PREFETCH ( REGIND(EDX) ) - - PFMUL ( MM2, MM5 ) /* | x2*m10 */ - ADD_L ( CONST(16), EAX ) /* next r */ - - SUB_L ( CONST(1), EDI ) /* decrement normal counter */ - MOVQ ( MM4, REGOFF(-16, EAX) ) /* write r0, r1 */ - - MOVD ( MM5, REGOFF(-8, EAX) ) /* write r2 */ - JNZ ( LLBL (G3TNR_transform) ) - - FEMMS - -LLBL (G3TNR_end): - POP_L ( ESI ) - POP_L ( EDI ) - RET - - - - - - - - -ALIGNTEXT16 -GLOBL GLNAME(_mesa_3dnow_transform_normals) -HIDDEN(_mesa_3dnow_transform_normals) -GLNAME(_mesa_3dnow_transform_normals): - -#undef FRAME_OFFSET -#define FRAME_OFFSET 8 - - PUSH_L ( EDI ) - PUSH_L ( ESI ) - - MOV_L ( ARG_IN, ESI ) - MOV_L ( ARG_DEST, EAX ) - MOV_L ( ARG_MAT, ECX ) - MOV_L ( REGOFF(V4F_COUNT, ESI), EDI ) /* dest->count = in->count */ - MOV_L ( EDI, REGOFF(V4F_COUNT, EAX) ) - MOV_L ( REGOFF(V4F_START, EAX), EAX ) /* dest->start */ - MOV_L ( REGOFF(V4F_START, ESI), EDX ) /* in->start */ - MOV_L ( REGOFF(MATRIX_INV, ECX), ECX ) /* mat->inv */ - - CMP_L ( CONST(0), EDI ) /* count > 0 ?? */ - JE ( LLBL (G3T_end) ) - - FEMMS - - MOVQ ( REGIND(ECX), MM3 ) /* m1 | m0 */ - MOVQ ( REGOFF(16, ECX), MM4 ) /* m5 | m4 */ - - MOVD ( REGOFF(8, ECX), MM5 ) /* | m2 */ - PUNPCKLDQ ( REGOFF(24, ECX), MM5 ) /* m6 | m2 */ - - MOVQ ( REGOFF(32, ECX), MM6 ) /* m9 | m8 */ - MOVD ( REGOFF(40, ECX), MM7 ) /* | m10 */ - -ALIGNTEXT32 -LLBL (G3T_transform): - - PREFETCHW ( REGIND(EAX) ) - - MOVQ ( REGIND(EDX), MM0 ) /* x1 | x0 */ - MOVD ( REGOFF(8, EDX), MM2 ) /* | x2 */ - - MOVQ ( MM0, MM1 ) /* x1 | x0 */ - PUNPCKLDQ ( MM2, MM2 ) /* x2 | x2 */ - - PFMUL ( MM3, MM0 ) /* x1*m1 | x0*m0 */ - ADD_L ( CONST(16), EAX ) /* next r */ - - PFMUL ( MM4, MM1 ) /* x1*m5 | x0*m4 */ - PFACC ( MM1, MM0 ) /* x0*m4+x1*m5 | x0*m0+x1*m1 */ - - PFMUL ( MM5, MM2 ) /* x2*m6 | x2*m2 */ - PFADD ( MM2, MM0 ) /* x0*m4...+x2*m6| x0*m0+x1*m1+x2*m2 */ - - MOVQ ( REGIND(EDX), MM1 ) /* x1 | x0 */ - MOVQ ( MM0, REGOFF(-16, EAX) ) /* write r0, r1 */ - - PFMUL ( MM6, MM1 ) /* x1*m9 | x0*m8 */ - MOVD ( REGOFF(8, EDX), MM2 ) /* | x2 */ - - PFMUL ( MM7, MM2 ) /* | x2*m10 */ - ADD_L ( STRIDE, EDX ) /* next normal */ - - PREFETCH ( REGIND(EDX) ) - - PFACC ( MM1, MM1 ) /* *not used* | x0*m8+x1*m9 */ - PFADD ( MM2, MM1 ) /* *not used* | x0*m8+x1*m9+x2*m10 */ - - MOVD ( MM1, REGOFF(-8, EAX) ) /* write r2 */ - SUB_L ( CONST(1), EDI ) /* decrement normal counter */ - - JNZ ( LLBL (G3T_transform) ) - - FEMMS - -LLBL (G3T_end): - POP_L ( ESI ) - POP_L ( EDI ) - RET - - - - - - -ALIGNTEXT16 -GLOBL GLNAME(_mesa_3dnow_normalize_normals) -HIDDEN(_mesa_3dnow_normalize_normals) -GLNAME(_mesa_3dnow_normalize_normals): - -#undef FRAME_OFFSET -#define FRAME_OFFSET 12 - - PUSH_L ( EDI ) - PUSH_L ( ESI ) - PUSH_L ( EBP ) - - MOV_L ( ARG_IN, ESI ) - MOV_L ( ARG_DEST, EAX ) - MOV_L ( REGOFF(V4F_COUNT, ESI), EBP ) /* dest->count = in->count */ - MOV_L ( EBP, REGOFF(V4F_COUNT, EAX) ) - MOV_L ( REGOFF(V4F_START, EAX), EAX ) /* dest->start */ - MOV_L ( REGOFF(V4F_START, ESI), ECX ) /* in->start */ - MOV_L ( ARG_LENGTHS, EDX ) - - CMP_L ( CONST(0), EBP ) /* count > 0 ?? */ - JE ( LLBL (G3N_end) ) - - FEMMS - - CMP_L ( CONST(0), EDX ) /* lengths == 0 ? */ - JE ( LLBL (G3N_norm2) ) /* calculate lengths */ - -ALIGNTEXT32 -LLBL (G3N_norm1): /* use precalculated lengths */ - - PREFETCH ( REGIND(EAX) ) - - MOVQ ( REGIND(ECX), MM0 ) /* x1 | x0 */ - MOVD ( REGOFF(8, ECX), MM1 ) /* | x2 */ - - MOVD ( REGIND(EDX), MM3 ) /* | length (x) */ - PFMUL ( MM3, MM1 ) /* | x2 (normalized) */ - - PUNPCKLDQ ( MM3, MM3 ) /* length (x) | length (x) */ - ADD_L ( STRIDE, ECX ) /* next normal */ - - PREFETCH ( REGIND(ECX) ) - - PFMUL ( MM3, MM0 ) /* x1 (normalized) | x0 (normalized) */ - MOVQ ( MM0, REGIND(EAX) ) /* write new x0, x1 */ - - MOVD ( MM1, REGOFF(8, EAX) ) /* write new x2 */ - ADD_L ( CONST(16), EAX ) /* next r */ - - ADD_L ( CONST(4), EDX ) /* next length */ - SUB_L ( CONST(1), EBP ) /* decrement normal counter */ - - JNZ ( LLBL (G3N_norm1) ) - - JMP ( LLBL (G3N_end1) ) - -ALIGNTEXT32 -LLBL (G3N_norm2): /* need to calculate lengths */ - - PREFETCHW ( REGIND(EAX) ) - - PREFETCH ( REGIND(ECX) ) - - MOVQ ( REGIND(ECX), MM0 ) /* x1 | x0 */ - MOVD ( REGOFF(8, ECX), MM1 ) /* | x2 */ - - MOVQ ( MM0, MM3 ) /* x1 | x0 */ - ADD_L ( STRIDE, ECX ) /* next normal */ - - PFMUL ( MM0, MM3 ) /* x1*x1 | x0*x0 */ - MOVQ ( MM1, MM4 ) /* | x2 */ - - ADD_L ( CONST(16), EAX ) /* next r */ - PFMUL ( MM1, MM4 ) /* | x2*x2 */ - - PFADD ( MM4, MM3 ) /* | x0*x0+x2*x2 */ - PFACC ( MM3, MM3 ) /* x0*x0+...+x2*x2 | x0*x0+x1*x1+x2*x2*/ - - PFRSQRT ( MM3, MM5 ) /* 1/sqrt (x0*x0+x1*x1+x2*x2) */ - MOVQ ( MM5, MM4 ) - - PUNPCKLDQ ( MM3, MM3 ) - PFMUL ( MM5, MM5 ) - - PFRSQIT1 ( MM3, MM5 ) - SUB_L ( CONST(1), EBP ) /* decrement normal counter */ - - PFRCPIT2 ( MM4, MM5 ) - - PFMUL ( MM5, MM0 ) /* x1 (normalized) | x0 (normalized) */ - MOVQ ( MM0, REGOFF(-16, EAX) ) /* write new x0, x1 */ - - PFMUL ( MM5, MM1 ) /* | x2 (normalized) */ - MOVD ( MM1, REGOFF(-8, EAX) ) /* write new x2 */ - - JNZ ( LLBL (G3N_norm2) ) - -LLBL (G3N_end1): - FEMMS - -LLBL (G3N_end): - POP_L ( EBP ) - POP_L ( ESI ) - POP_L ( EDI ) - RET - - - - - - -ALIGNTEXT16 -GLOBL GLNAME(_mesa_3dnow_rescale_normals) -HIDDEN(_mesa_3dnow_rescale_normals) -GLNAME(_mesa_3dnow_rescale_normals): - -#undef FRAME_OFFSET -#define FRAME_OFFSET 8 - PUSH_L ( EDI ) - PUSH_L ( ESI ) - - MOV_L ( ARG_IN, ESI ) - MOV_L ( ARG_DEST, EAX ) - MOV_L ( REGOFF(V4F_COUNT, ESI), EDX ) /* dest->count = in->count */ - MOV_L ( EDX, REGOFF(V4F_COUNT, EAX) ) - MOV_L ( REGOFF(V4F_START, EAX), EAX ) /* dest->start */ - MOV_L ( REGOFF(V4F_START, ESI), ECX ) /* in->start */ - - CMP_L ( CONST(0), EDX ) - JE ( LLBL (G3R_end) ) - - FEMMS - - MOVD ( ARG_SCALE, MM0 ) /* scale */ - PUNPCKLDQ ( MM0, MM0 ) - -ALIGNTEXT32 -LLBL (G3R_rescale): - - PREFETCHW ( REGIND(EAX) ) - - MOVQ ( REGIND(ECX), MM1 ) /* x1 | x0 */ - MOVD ( REGOFF(8, ECX), MM2 ) /* | x2 */ - - PFMUL ( MM0, MM1 ) /* x1*scale | x0*scale */ - ADD_L ( STRIDE, ECX ) /* next normal */ - - PREFETCH ( REGIND(ECX) ) - - PFMUL ( MM0, MM2 ) /* | x2*scale */ - ADD_L ( CONST(16), EAX ) /* next r */ - - MOVQ ( MM1, REGOFF(-16, EAX) ) /* write r0, r1 */ - MOVD ( MM2, REGOFF(-8, EAX) ) /* write r2 */ - - SUB_L ( CONST(1), EDX ) /* decrement normal counter */ - JNZ ( LLBL (G3R_rescale) ) - - FEMMS - -LLBL (G3R_end): - POP_L ( ESI ) - POP_L ( EDI ) - RET - -#endif - -#if defined (__ELF__) && defined (__linux__) - .section .note.GNU-stack,"",%progbits -#endif diff --git a/dll/opengl/mesa/x86/3dnow_xform1.S b/dll/opengl/mesa/x86/3dnow_xform1.S deleted file mode 100644 index a73301a8d6b..00000000000 --- a/dll/opengl/mesa/x86/3dnow_xform1.S +++ /dev/null @@ -1,437 +0,0 @@ - -/* - * Mesa 3-D graphics library - * Version: 3.5 - * - * Copyright (C) 1999-2001 Brian Paul All Rights Reserved. - * - * Permission is hereby granted, free of charge, to any person obtaining a - * copy of this software and associated documentation files (the "Software"), - * to deal in the Software without restriction, including without limitation - * the rights to use, copy, modify, merge, publish, distribute, sublicense, - * and/or sell copies of the Software, and to permit persons to whom the - * Software is furnished to do so, subject to the following conditions: - * - * The above copyright notice and this permission notice shall be included - * in all copies or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS - * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL - * BRIAN PAUL BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN - * AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN - * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. - */ - -#ifdef USE_3DNOW_ASM -#include "assyntax.h" -#include "matypes.h" -#include "xform_args.h" - - SEG_TEXT - -#define FRAME_OFFSET 4 - - -ALIGNTEXT16 -GLOBL GLNAME( _mesa_3dnow_transform_points1_general ) -HIDDEN(_mesa_3dnow_transform_points1_general) -GLNAME( _mesa_3dnow_transform_points1_general ): - - PUSH_L ( ESI ) - - MOV_L ( ARG_DEST, ECX ) - MOV_L ( ARG_MATRIX, ESI ) - MOV_L ( ARG_SOURCE, EAX ) - MOV_L ( CONST(4), REGOFF(V4F_SIZE, ECX) ) - OR_B ( CONST(VEC_SIZE_4), REGOFF(V4F_FLAGS, ECX) ) - MOV_L ( REGOFF(V4F_COUNT, EAX), EDX ) - MOV_L ( EDX, REGOFF(V4F_COUNT, ECX) ) - - PUSH_L ( EDI ) - - MOV_L ( REGOFF(4, ECX), EDX ) - MOV_L ( ESI, ECX ) - MOV_L ( REGOFF(V4F_COUNT, EAX), ESI ) - MOV_L ( REGOFF(V4F_STRIDE, EAX), EDI ) - MOV_L ( REGOFF(V4F_START, EAX), EAX ) - - TEST_L ( ESI, ESI ) - JZ ( LLBL( G3TPGR_3 ) ) - - MOVQ ( REGIND(ECX), MM0 ) /* m01 | m00 */ - MOVQ ( REGOFF(8, ECX), MM1 ) /* m03 | m02 */ - - MOVQ ( REGOFF(48, ECX), MM2 ) /* m31 | m30 */ - MOVQ ( REGOFF(56, ECX), MM3 ) /* m33 | m32 */ - -ALIGNTEXT16 -LLBL( G3TPGR_2 ): - - MOVD ( REGIND(EAX), MM4 ) /* | x0 */ - PUNPCKLDQ ( MM4, MM4 ) /* x0 | x0 */ - - MOVQ ( MM4, MM5 ) /* x0 | x0 */ - PFMUL ( MM0, MM4 ) /* x0*m01 | x0*m00 */ - - PFMUL ( MM1, MM5 ) /* x0*m03 | x0*m02 */ - PFADD ( MM2, MM4 ) /* x0*m01+m31 | x0*m00+m30 */ - - PFADD ( MM3, MM5 ) /* x0*m03+m33 | x0*m02+m32 */ - MOVQ ( MM4, REGIND(EDX) ) /* write r1, r0 */ - - MOVQ ( MM5, REGOFF(8, EDX) ) /* write r3, r2 */ - ADD_L ( EDI, EAX ) /* next vertex */ - - ADD_L ( CONST(16), EDX ) /* next r */ - DEC_L ( ESI ) /* decrement vertex counter */ - - JNZ ( LLBL( G3TPGR_2 ) ) /* cnt > 0 ? -> process next vertex */ - -LLBL( G3TPGR_3 ): - - FEMMS - POP_L ( EDI ) - POP_L ( ESI ) - RET - - - - -ALIGNTEXT16 -GLOBL GLNAME( _mesa_3dnow_transform_points1_identity ) -HIDDEN(_mesa_3dnow_transform_points1_identity) -GLNAME( _mesa_3dnow_transform_points1_identity ): - - PUSH_L ( ESI ) - - MOV_L ( ARG_DEST, ECX ) - MOV_L ( ARG_MATRIX, ESI ) - MOV_L ( ARG_SOURCE, EAX ) - MOV_L ( CONST(1), REGOFF(V4F_SIZE, ECX) ) - OR_B ( CONST(VEC_SIZE_1), REGOFF(V4F_FLAGS, ECX) ) - MOV_L ( REGOFF(V4F_COUNT, EAX), EDX ) - MOV_L ( EDX, REGOFF(V4F_COUNT, ECX) ) - - PUSH_L ( EDI ) - - MOV_L ( REGOFF(4, ECX), EDX ) - MOV_L ( ESI, ECX ) - MOV_L ( REGOFF(V4F_COUNT, EAX), ESI ) - MOV_L ( REGOFF(V4F_STRIDE, EAX), EDI ) - MOV_L ( REGOFF(V4F_START, EAX), EAX ) - - TEST_L ( ESI, ESI ) - JZ ( LLBL( G3TPIR_4) ) - -ALIGNTEXT16 -LLBL( G3TPIR_3 ): - - MOVD ( REGIND(EAX), MM0 ) /* | x0 */ - ADD_L ( EDI, EAX ) /* next vertex */ - - MOVD ( MM0, REGIND(EDX) ) /* | r0 */ - ADD_L ( CONST(16), EDX ) /* next r */ - - DEC_L ( ESI ) /* decrement vertex counter */ - JNZ ( LLBL( G3TPIR_3 ) ) /* cnt > 0 ? -> process next vertex */ - -LLBL( G3TPIR_4 ): - - FEMMS - POP_L ( EDI ) - POP_L ( ESI ) - RET - - - - -ALIGNTEXT16 -GLOBL GLNAME( _mesa_3dnow_transform_points1_3d_no_rot ) -HIDDEN(_mesa_3dnow_transform_points1_3d_no_rot) -GLNAME( _mesa_3dnow_transform_points1_3d_no_rot ): - - PUSH_L ( ESI ) - - MOV_L ( ARG_DEST, ECX ) - MOV_L ( ARG_MATRIX, ESI ) - MOV_L ( ARG_SOURCE, EAX ) - MOV_L ( CONST(3), REGOFF(V4F_SIZE, ECX) ) - OR_B ( CONST(VEC_SIZE_3), REGOFF(V4F_FLAGS, ECX) ) - MOV_L ( REGOFF(V4F_COUNT, EAX), EDX ) - MOV_L ( EDX, REGOFF(V4F_COUNT, ECX) ) - - PUSH_L ( EDI ) - - MOV_L ( REGOFF(4, ECX), EDX ) - MOV_L ( ESI, ECX ) - MOV_L ( REGOFF(V4F_COUNT, EAX), ESI ) - MOV_L ( REGOFF(V4F_STRIDE, EAX), EDI ) - MOV_L ( REGOFF(V4F_START, EAX), EAX ) - - TEST_L ( ESI, ESI ) - JZ ( LLBL( G3TP3NRR_3 ) ) - - MOVD ( REGIND(ECX), MM0 ) /* | m00 */ - MOVQ ( REGOFF(48, ECX), MM2 ) /* m31 | m30 */ - - MOVD ( REGOFF(56, ECX), MM3 ) /* | m32 */ - -ALIGNTEXT16 -LLBL( G3TP3NRR_2 ): - - MOVD ( REGIND(EAX), MM4 ) /* | x0 */ - PFMUL ( MM0, MM4 ) /* | x0*m00 */ - - PFADD ( MM2, MM4 ) /* m31 | x0*m00+m30 */ - MOVQ ( MM4, REGIND(EDX) ) /* write r1, r0 */ - - MOVD ( MM3, REGOFF(8, EDX) ) /* write r2 */ - ADD_L ( EDI, EAX ) /* next vertex */ - - ADD_L ( CONST(16), EDX ) /* next r */ - DEC_L ( ESI ) /* decrement vertex counter */ - - JNZ ( LLBL( G3TP3NRR_2 ) ) /* cnt > 0 ? -> process next vertex */ - -LLBL( G3TP3NRR_3 ): - - FEMMS - POP_L ( EDI ) - POP_L ( ESI ) - RET - - - - -ALIGNTEXT16 -GLOBL GLNAME( _mesa_3dnow_transform_points1_perspective ) -HIDDEN(_mesa_3dnow_transform_points1_perspective) -GLNAME( _mesa_3dnow_transform_points1_perspective ): - - PUSH_L ( ESI ) - - MOV_L ( ARG_DEST, ECX ) - MOV_L ( ARG_MATRIX, ESI ) - MOV_L ( ARG_SOURCE, EAX ) - MOV_L ( CONST(4), REGOFF(V4F_SIZE, ECX) ) - OR_B ( CONST(VEC_SIZE_4), REGOFF(V4F_FLAGS, ECX) ) - MOV_L ( REGOFF(V4F_COUNT, EAX), EDX ) - MOV_L ( EDX, REGOFF(V4F_COUNT, ECX) ) - - PUSH_L ( EDI ) - - MOV_L ( REGOFF(4, ECX), EDX ) - MOV_L ( ESI, ECX ) - MOV_L ( REGOFF(V4F_COUNT, EAX), ESI ) - MOV_L ( REGOFF(V4F_STRIDE, EAX), EDI ) - MOV_L ( REGOFF(V4F_START, EAX), EAX ) - - TEST_L ( ESI, ESI ) - JZ ( LLBL( G3TPPR_3 ) ) - - MOVD ( REGIND(ECX), MM0 ) /* | m00 */ - MOVD ( REGOFF(56, ECX), MM3 ) /* | m32 */ - -ALIGNTEXT16 -LLBL( G3TPPR_2 ): - - MOVD ( REGIND(EAX), MM4 ) /* 0 | x0 */ - PFMUL ( MM0, MM4 ) /* 0 | x0*m00 */ - - MOVQ ( MM4, REGIND(EDX) ) /* write r1, r0 */ - MOVQ ( MM3, REGOFF(8, EDX) ) /* write r2 (=m32), r3 (=0) */ - - ADD_L ( EDI, EAX ) /* next vertex */ - ADD_L ( CONST(16), EDX ) /* next r */ - - DEC_L ( ESI ) /* decrement vertex counter */ - JNZ ( LLBL( G3TPPR_2 ) ) /* cnt > 0 ? -> process next vertex */ - -LLBL( G3TPPR_3 ): - - FEMMS - POP_L ( EDI ) - POP_L ( ESI ) - RET - - - - -ALIGNTEXT16 -GLOBL GLNAME( _mesa_3dnow_transform_points1_2d ) -HIDDEN(_mesa_3dnow_transform_points1_2d) -GLNAME( _mesa_3dnow_transform_points1_2d ): - - PUSH_L ( ESI ) - - MOV_L ( ARG_DEST, ECX ) - MOV_L ( ARG_MATRIX, ESI ) - MOV_L ( ARG_SOURCE, EAX ) - MOV_L ( CONST(2), REGOFF(V4F_SIZE, ECX) ) - OR_B ( CONST(VEC_SIZE_2), REGOFF(V4F_FLAGS, ECX) ) - MOV_L ( REGOFF(V4F_COUNT, EAX), EDX ) - MOV_L ( EDX, REGOFF(V4F_COUNT, ECX) ) - - PUSH_L ( EDI ) - - MOV_L ( REGOFF(4, ECX), EDX ) - MOV_L ( ESI, ECX ) - MOV_L ( REGOFF(V4F_COUNT, EAX), ESI ) - MOV_L ( REGOFF(V4F_STRIDE, EAX), EDI ) - MOV_L ( REGOFF(V4F_START, EAX), EAX ) - - TEST_L ( ESI, ESI ) - JZ ( LLBL( G3TP2R_3 ) ) - - MOVQ ( REGIND(ECX), MM0 ) /* m01 | m00 */ - MOVQ ( REGOFF(48, ECX), MM2 ) /* m31 | m30 */ - -ALIGNTEXT16 -LLBL( G3TP2R_2 ): - - MOVD ( REGIND(EAX), MM4 ) /* | x0 */ - PUNPCKLDQ ( MM4, MM4 ) /* x0 | x0 */ - - PFMUL ( MM0, MM4 ) /* x0*m01 | x0*m00 */ - PFADD ( MM2, MM4 ) /* x0*m01+m31 | x0*m00+m30 */ - - MOVQ ( MM4, REGIND(EDX) ) /* write r1, r0 */ - ADD_L ( EDI, EAX ) /* next vertex */ - - ADD_L ( CONST(16), EDX ) /* next r */ - DEC_L ( ESI ) /* decrement vertex counter */ - - JNZ ( LLBL( G3TP2R_2 ) ) /* cnt > 0 ? -> process next vertex */ - -LLBL( G3TP2R_3 ): - - FEMMS - POP_L ( EDI ) - POP_L ( ESI ) - RET - - - - -ALIGNTEXT16 -GLOBL GLNAME( _mesa_3dnow_transform_points1_2d_no_rot ) -HIDDEN(_mesa_3dnow_transform_points1_2d_no_rot) -GLNAME( _mesa_3dnow_transform_points1_2d_no_rot ): - - PUSH_L ( ESI ) - - MOV_L ( ARG_DEST, ECX ) - MOV_L ( ARG_MATRIX, ESI ) - MOV_L ( ARG_SOURCE, EAX ) - MOV_L ( CONST(2), REGOFF(V4F_SIZE, ECX) ) - OR_B ( CONST(VEC_SIZE_2), REGOFF(V4F_FLAGS, ECX) ) - MOV_L ( REGOFF(V4F_COUNT, EAX), EDX ) - MOV_L ( EDX, REGOFF(V4F_COUNT, ECX) ) - - PUSH_L ( EDI ) - - MOV_L ( REGOFF(4, ECX), EDX ) - MOV_L ( ESI, ECX ) - MOV_L ( REGOFF(V4F_COUNT, EAX), ESI ) - MOV_L ( REGOFF(V4F_STRIDE, EAX), EDI ) - MOV_L ( REGOFF(V4F_START, EAX), EAX ) - - TEST_L ( ESI, ESI ) - JZ ( LLBL( G3TP2NRR_3 ) ) - - MOVD ( REGIND(ECX), MM0 ) /* | m00 */ - MOVQ ( REGOFF(48, ECX), MM2 ) /* m31 | m30 */ - -ALIGNTEXT16 -LLBL( G3TP2NRR_2 ): - - MOVD ( REGIND(EAX), MM4 ) /* | x0 */ - ADD_L ( EDI, EAX ) /* next vertex */ - - PFMUL ( MM0, MM4 ) /* | x0*m00 */ - PFADD ( MM2, MM4 ) /* m31 | x0*m00+m30 */ - - MOVQ ( MM4, REGIND(EDX) ) /* write r1, r0 */ - ADD_L ( CONST(16), EDX ) /* next r */ - - DEC_L ( ESI ) /* decrement vertex counter */ - JNZ ( LLBL( G3TP2NRR_2 ) ) /* cnt > 0 ? -> process next vertex */ - -LLBL( G3TP2NRR_3 ): - - FEMMS - POP_L ( EDI ) - POP_L ( ESI ) - RET - - - - -ALIGNTEXT16 -GLOBL GLNAME( _mesa_3dnow_transform_points1_3d ) -HIDDEN(_mesa_3dnow_transform_points1_3d) -GLNAME( _mesa_3dnow_transform_points1_3d ): - - PUSH_L ( ESI ) - - MOV_L ( ARG_DEST, ECX ) - MOV_L ( ARG_MATRIX, ESI ) - MOV_L ( ARG_SOURCE, EAX ) - MOV_L ( CONST(3), REGOFF(V4F_SIZE, ECX) ) - OR_B ( CONST(VEC_SIZE_3), REGOFF(V4F_FLAGS, ECX) ) - MOV_L ( REGOFF(V4F_COUNT, EAX), EDX ) - MOV_L ( EDX, REGOFF(V4F_COUNT, ECX) ) - - PUSH_L ( EDI ) - - MOV_L ( REGOFF(4, ECX), EDX ) - MOV_L ( ESI, ECX ) - MOV_L ( REGOFF(V4F_COUNT, EAX), ESI ) - MOV_L ( REGOFF(V4F_STRIDE, EAX), EDI ) - MOV_L ( REGOFF(V4F_START, EAX), EAX ) - - TEST_L ( ESI, ESI ) - JZ ( LLBL( G3TP3R_3 ) ) - - MOVQ ( REGIND(ECX), MM0 ) /* m01 | m00 */ - MOVD ( REGOFF(8, ECX), MM1 ) /* | m02 */ - - MOVQ ( REGOFF(48, ECX), MM2 ) /* m31 | m30 */ - MOVD ( REGOFF(56, ECX), MM3 ) /* | m32 */ - -ALIGNTEXT16 -LLBL( G3TP3R_2 ): - - MOVD ( REGIND(EAX), MM4 ) /* | x0 */ - PUNPCKLDQ ( MM4, MM4 ) /* x0 | x0 */ - - MOVQ ( MM4, MM5 ) /* | x0 */ - PFMUL ( MM0, MM4 ) /* x0*m01 | x0*m00 */ - - PFMUL ( MM1, MM5 ) /* | x0*m02 */ - PFADD ( MM2, MM4 ) /* x0*m01+m31 | x0*m00+m30 */ - - PFADD ( MM3, MM5 ) /* | x0*m02+m32 */ - MOVQ ( MM4, REGIND(EDX) ) /* write r1, r0 */ - - MOVD ( MM5, REGOFF(8, EDX) ) /* write r2 */ - ADD_L ( EDI, EAX ) /* next vertex */ - - ADD_L ( CONST(16), EDX ) /* next r */ - DEC_L ( ESI ) /* decrement vertex counter */ - - JNZ ( LLBL( G3TP3R_2 ) ) /* cnt > 0 ? -> process next vertex */ - -LLBL( G3TP3R_3 ): - - FEMMS - POP_L ( EDI ) - POP_L ( ESI ) - RET - -#endif - -#if defined (__ELF__) && defined (__linux__) - .section .note.GNU-stack,"",%progbits -#endif diff --git a/dll/opengl/mesa/x86/3dnow_xform2.S b/dll/opengl/mesa/x86/3dnow_xform2.S deleted file mode 100644 index 2988fb7bfd3..00000000000 --- a/dll/opengl/mesa/x86/3dnow_xform2.S +++ /dev/null @@ -1,477 +0,0 @@ - -/* - * Mesa 3-D graphics library - * Version: 3.5 - * - * Copyright (C) 1999-2001 Brian Paul All Rights Reserved. - * - * Permission is hereby granted, free of charge, to any person obtaining a - * copy of this software and associated documentation files (the "Software"), - * to deal in the Software without restriction, including without limitation - * the rights to use, copy, modify, merge, publish, distribute, sublicense, - * and/or sell copies of the Software, and to permit persons to whom the - * Software is furnished to do so, subject to the following conditions: - * - * The above copyright notice and this permission notice shall be included - * in all copies or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS - * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL - * BRIAN PAUL BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN - * AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN - * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. - */ - -#ifdef USE_3DNOW_ASM -#include "assyntax.h" -#include "matypes.h" -#include "xform_args.h" - - SEG_TEXT - -#define FRAME_OFFSET 4 - - -ALIGNTEXT16 -GLOBL GLNAME( _mesa_3dnow_transform_points2_general ) -HIDDEN(_mesa_3dnow_transform_points2_general) -GLNAME( _mesa_3dnow_transform_points2_general ): - - PUSH_L ( ESI ) - - MOV_L ( ARG_DEST, ECX ) - MOV_L ( ARG_MATRIX, ESI ) - MOV_L ( ARG_SOURCE, EAX ) - MOV_L ( CONST(4), REGOFF(V4F_SIZE, ECX) ) - OR_B ( CONST(VEC_SIZE_4), REGOFF(V4F_FLAGS, ECX) ) - MOV_L ( REGOFF(V4F_COUNT, EAX), EDX ) - MOV_L ( EDX, REGOFF(V4F_COUNT, ECX) ) - - PUSH_L ( EDI ) - - MOV_L ( REGOFF(V4F_START, ECX), EDX ) - MOV_L ( ESI, ECX ) - MOV_L ( REGOFF(V4F_COUNT, EAX), ESI ) - MOV_L ( REGOFF(V4F_STRIDE, EAX), EDI ) - MOV_L ( REGOFF(V4F_START, EAX), EAX ) - - TEST_L ( ESI, ESI ) - JZ ( LLBL( G3TPGR_3 ) ) - - MOVD ( REGIND(ECX), MM0 ) /* | m00 */ - PUNPCKLDQ ( REGOFF(16, ECX), MM0 ) /* m10 | m00 */ - - MOVD ( REGOFF(4, ECX), MM1 ) /* | m01 */ - PUNPCKLDQ ( REGOFF(20, ECX), MM1 ) /* m11 | m01 */ - - MOVD ( REGOFF(8, ECX), MM2 ) /* | m02 */ - PUNPCKLDQ ( REGOFF(24, ECX), MM2 ) /* m12 | m02 */ - - MOVD ( REGOFF(12, ECX), MM3 ) /* | m03 */ - PUNPCKLDQ ( REGOFF(28, ECX), MM3 ) /* m13 | m03 */ - - MOVQ ( REGOFF(48, ECX), MM4 ) /* m31 | m30 */ - MOVQ ( REGOFF(56, ECX), MM5 ) /* m33 | m32 */ - -ALIGNTEXT16 -LLBL( G3TPGR_2 ): - - MOVQ ( REGIND(EAX), MM6 ) /* x1 | x0 */ - MOVQ ( MM6, MM7 ) /* x1 | x0 */ - - PFMUL ( MM0, MM6 ) /* x1*m10 | x0*m00 */ - PFMUL ( MM1, MM7 ) /* x1*m11 | x0*m01 */ - - PFACC ( MM7, MM6 ) /* x0*m01+x1*m11 | x0*x00+x1*m10 */ - PFADD ( MM4, MM6 ) /* x0*...*m11+m31 | x0*...*m10+m30 */ - - MOVQ ( MM6, REGIND(EDX) ) /* write r1, r0 */ - MOVQ ( REGIND(EAX), MM6 ) /* x1 | x0 */ - - MOVQ ( MM6, MM7 ) /* x1 | x0 */ - PFMUL ( MM2, MM6 ) /* x1*m12 | x0*m02 */ - - PFMUL ( MM3, MM7 ) /* x1*m13 | x0*m03 */ - ADD_L ( EDI, EAX ) /* next vertex */ - - PFACC ( MM7, MM6 ) /* x0*m03+x1*m13 | x0*x02+x1*m12 */ - PFADD ( MM5, MM6 ) /* x0*...*m13+m33 | x0*...*m12+m32 */ - - MOVQ ( MM6, REGOFF(8, EDX) ) /* write r3, r2 */ - ADD_L ( CONST(16), EDX ) /* next r */ - - DEC_L ( ESI ) /* decrement vertex counter */ - JNZ ( LLBL( G3TPGR_2 ) ) /* cnt > 0 ? -> process next vertex */ - -LLBL( G3TPGR_3 ): - - FEMMS - POP_L ( EDI ) - POP_L ( ESI ) - RET - - - - -ALIGNTEXT16 -GLOBL GLNAME( _mesa_3dnow_transform_points2_perspective ) -HIDDEN(_mesa_3dnow_transform_points2_perspective) -GLNAME( _mesa_3dnow_transform_points2_perspective ): - - PUSH_L ( ESI ) - - MOV_L ( ARG_DEST, ECX ) - MOV_L ( ARG_MATRIX, ESI ) - MOV_L ( ARG_SOURCE, EAX ) - MOV_L ( CONST(4), REGOFF(V4F_SIZE, ECX) ) - OR_B ( CONST(VEC_SIZE_4), REGOFF(V4F_FLAGS, ECX) ) - MOV_L ( REGOFF(V4F_COUNT, EAX), EDX ) - MOV_L ( EDX, REGOFF(V4F_COUNT, ECX) ) - - PUSH_L ( EDI ) - - MOV_L ( REGOFF(V4F_START, ECX), EDX ) - MOV_L ( ESI, ECX ) - MOV_L ( REGOFF(V4F_COUNT, EAX), ESI ) - MOV_L ( REGOFF(V4F_STRIDE, EAX), EDI ) - MOV_L ( REGOFF(V4F_START, EAX), EAX ) - - TEST_L ( ESI, ESI ) - JZ ( LLBL( G3TPPR_3 ) ) - - MOVD ( REGIND(ECX), MM0 ) /* | m00 */ - PUNPCKLDQ ( REGOFF(20, ECX), MM0 ) /* m11 | m00 */ - - MOVD ( REGOFF(56, ECX), MM3 ) /* | m32 */ - -ALIGNTEXT16 -LLBL( G3TPPR_2 ): - - MOVQ ( REGIND(EAX), MM4 ) /* x1 | x0 */ - PFMUL ( MM0, MM4 ) /* x1*m11 | x0*m00 */ - - MOVQ ( MM4, REGIND(EDX) ) /* write r1, r0 */ - MOVQ ( MM3, REGOFF(8, EDX) ) /* write r2 (=m32), r3 (=0) */ - - ADD_L ( EDI, EAX ) /* next vertex */ - ADD_L ( CONST(16), EDX ) /* next r */ - - DEC_L ( ESI ) /* decrement vertex counter */ - JNZ ( LLBL( G3TPPR_2 ) ) /* cnt > 0 ? -> process next vertex */ - -LLBL( G3TPPR_3 ): - - FEMMS - POP_L ( EDI ) - POP_L ( ESI ) - RET - - - - -ALIGNTEXT16 -GLOBL GLNAME( _mesa_3dnow_transform_points2_3d ) -HIDDEN(_mesa_3dnow_transform_points2_3d) -GLNAME( _mesa_3dnow_transform_points2_3d ): - - PUSH_L ( ESI ) - - MOV_L ( ARG_DEST, ECX ) - MOV_L ( ARG_MATRIX, ESI ) - MOV_L ( ARG_SOURCE, EAX ) - MOV_L ( CONST(3), REGOFF(V4F_SIZE, ECX) ) - OR_B ( CONST(VEC_SIZE_3 ), REGOFF(V4F_FLAGS, ECX) ) - MOV_L ( REGOFF(V4F_COUNT, EAX), EDX ) - MOV_L ( EDX, REGOFF(V4F_COUNT, ECX) ) - - PUSH_L ( EDI ) - - MOV_L ( REGOFF(V4F_START, ECX), EDX ) - MOV_L ( ESI, ECX ) - MOV_L ( REGOFF(V4F_COUNT, EAX), ESI ) - MOV_L ( REGOFF(V4F_STRIDE, EAX), EDI ) - MOV_L ( REGOFF(V4F_START, EAX), EAX ) - - TEST_L ( ESI, ESI ) - JZ ( LLBL( G3TP3R_3 ) ) - - MOVD ( REGIND(ECX), MM0 ) /* | m00 */ - PUNPCKLDQ ( REGOFF(16, ECX), MM0 ) /* m10 | m00 */ - - MOVD ( REGOFF(4, ECX), MM1 ) /* | m01 */ - PUNPCKLDQ ( REGOFF(20, ECX), MM1 ) /* m11 | m01 */ - - MOVD ( REGOFF(8, ECX), MM2 ) /* | m02 */ - PUNPCKLDQ ( REGOFF(24, ECX), MM2 ) /* m12 | m02 */ - - MOVQ ( REGOFF(48, ECX), MM4 ) /* m31 | m30 */ - MOVD ( REGOFF(56, ECX), MM5 ) /* | m32 */ - -ALIGNTEXT16 -LLBL( G3TP3R_2 ): - - MOVQ ( REGIND(EAX), MM6 ) /* x1 | x0 */ - MOVQ ( MM6, MM7 ) /* x1 | x0 */ - - PFMUL ( MM0, MM6 ) /* x1*m10 | x0*m00 */ - PFMUL ( MM1, MM7 ) /* x1*m11 | x0*m01 */ - - PFACC ( MM7, MM6 ) /* x0*m01+x1*m11 | x0*x00+x1*m10 */ - PFADD ( MM4, MM6 ) /* x0*...*m11+m31 | x0*...*m10+m30 */ - - MOVQ ( MM6, REGIND(EDX) ) /* write r1, r0 */ - MOVQ ( REGIND(EAX), MM6 ) /* x1 | x0 */ - - MOVQ ( MM6, MM7 ) /* x1 | x0 */ - PFMUL ( MM2, MM6 ) /* x1*m12 | x0*m02 */ - - PFACC ( MM7, MM6 ) /* ***trash*** | x0*x02+x1*m12 */ - PFADD ( MM5, MM6 ) /* ***trash*** | x0*...*m12+m32 */ - - MOVD ( MM6, REGOFF(8, EDX) ) /* write r2 */ - ADD_L ( EDI, EAX ) /* next vertex */ - - ADD_L ( CONST(16), EDX ) /* next r */ - DEC_L ( ESI ) /* decrement vertex counter */ - - JNZ ( LLBL( G3TP3R_2 ) ) /* cnt > 0 ? -> process next vertex */ - -LLBL( G3TP3R_3 ): - - FEMMS - POP_L ( EDI ) - POP_L ( ESI ) - RET - - - - -ALIGNTEXT16 -GLOBL GLNAME( _mesa_3dnow_transform_points2_3d_no_rot ) -HIDDEN(_mesa_3dnow_transform_points2_3d_no_rot) -GLNAME( _mesa_3dnow_transform_points2_3d_no_rot ): - - PUSH_L ( ESI ) - - MOV_L ( ARG_DEST, ECX ) - MOV_L ( ARG_MATRIX, ESI ) - MOV_L ( ARG_SOURCE, EAX ) - MOV_L ( CONST(3), REGOFF(V4F_SIZE, ECX) ) - OR_B ( CONST(VEC_SIZE_3 ), REGOFF(V4F_FLAGS, ECX) ) - MOV_L ( REGOFF(V4F_COUNT, EAX), EDX ) - MOV_L ( EDX, REGOFF(V4F_COUNT, ECX) ) - - PUSH_L ( EDI ) - - MOV_L ( REGOFF(V4F_START, ECX), EDX ) - MOV_L ( ESI, ECX ) - MOV_L ( REGOFF(V4F_COUNT, EAX), ESI ) - MOV_L ( REGOFF(V4F_STRIDE, EAX), EDI ) - MOV_L ( REGOFF(V4F_START, EAX), EAX ) - - TEST_L ( ESI, ESI ) - JZ ( LLBL( G3TP3NRR_3 ) ) - - MOVD ( REGIND(ECX), MM0 ) /* | m00 */ - PUNPCKLDQ ( REGOFF(20, ECX), MM0 ) /* m11 | m00 */ - - MOVQ ( REGOFF(48, ECX), MM2 ) /* m31 | m30 */ - MOVD ( REGOFF(56, ECX), MM3 ) /* | m32 */ - -ALIGNTEXT16 -LLBL( G3TP3NRR_2 ): - - MOVQ ( REGIND(EAX), MM4 ) /* x1 | x0 */ - PFMUL ( MM0, MM4 ) /* x1*m11 | x0*m00 */ - - PFADD ( MM2, MM4 ) /* x1*m11+m31 | x0*m00+m30 */ - MOVQ ( MM4, REGIND(EDX) ) /* write r1, r0 */ - - MOVD ( MM3, REGOFF(8, EDX) ) /* write r2 */ - ADD_L ( EDI, EAX ) /* next vertex */ - - ADD_L ( CONST(16), EDX ) /* next r */ - DEC_L ( ESI ) /* decrement vertex counter */ - - JNZ ( LLBL( G3TP3NRR_2 ) ) /* cnt > 0 ? -> process next vertex */ - -LLBL( G3TP3NRR_3 ): - - FEMMS - POP_L ( EDI ) - POP_L ( ESI ) - RET - - - - -ALIGNTEXT16 -GLOBL GLNAME( _mesa_3dnow_transform_points2_2d ) -HIDDEN(_mesa_3dnow_transform_points2_2d) -GLNAME( _mesa_3dnow_transform_points2_2d ): - - PUSH_L ( ESI ) - - MOV_L ( ARG_DEST, ECX ) - MOV_L ( ARG_MATRIX, ESI ) - MOV_L ( ARG_SOURCE, EAX ) - MOV_L ( CONST(2), REGOFF(V4F_SIZE, ECX) ) - OR_B ( CONST(VEC_SIZE_2), REGOFF(V4F_FLAGS, ECX) ) - MOV_L ( REGOFF(V4F_COUNT, EAX), EDX ) - MOV_L ( EDX, REGOFF(V4F_COUNT, ECX) ) - - PUSH_L ( EDI ) - - MOV_L ( REGOFF(V4F_START, ECX), EDX ) - MOV_L ( ESI, ECX ) - MOV_L ( REGOFF(V4F_COUNT, EAX), ESI ) - MOV_L ( REGOFF(V4F_STRIDE, EAX), EDI ) - MOV_L ( REGOFF(V4F_START, EAX), EAX ) - - TEST_L ( ESI, ESI ) - JZ ( LLBL( G3TP2R_3 ) ) - - MOVQ ( REGIND(ECX), MM0 ) /* m01 | m00 */ - MOVQ ( REGOFF(16, ECX), MM1 ) /* m11 | m10 */ - - MOVQ ( REGOFF(48, ECX), MM2 ) /* m31 | m30 */ - -ALIGNTEXT16 -LLBL( G3TP2R_2 ): - - MOVD ( REGIND(EAX), MM4 ) /* | x0 */ - MOVD ( REGOFF(4, EAX), MM5 ) /* | x1 */ - - PUNPCKLDQ ( MM4, MM4 ) /* x0 | x0 */ - ADD_L ( EDI, EAX ) /* next vertex */ - - PFMUL ( MM0, MM4 ) /* x0*m01 | x0*m00 */ - PUNPCKLDQ ( MM5, MM5 ) /* x1 | x1 */ - - PFMUL ( MM1, MM5 ) /* x1*m11 | x1*m10 */ - PFADD ( MM2, MM4 ) /* x...x1*m11+31 | x0*..*m10+m30 */ - - PFADD ( MM5, MM4 ) /* x0*m01+x1*m11 | x0*m00+x1*m10 */ - MOVQ ( MM4, REGIND(EDX) ) /* write r1, r0 */ - - ADD_L ( CONST(16), EDX ) /* next r */ - DEC_L ( ESI ) /* decrement vertex counter */ - - JNZ ( LLBL( G3TP2R_2 ) ) /* cnt > 0 ? -> process next vertex */ - -LLBL( G3TP2R_3 ): - - FEMMS - POP_L ( EDI ) - POP_L ( ESI ) - RET - - - - -ALIGNTEXT16 -GLOBL GLNAME( _mesa_3dnow_transform_points2_2d_no_rot ) -HIDDEN(_mesa_3dnow_transform_points2_2d_no_rot) -GLNAME( _mesa_3dnow_transform_points2_2d_no_rot ): - - PUSH_L ( ESI ) - - MOV_L ( ARG_DEST, ECX ) - MOV_L ( ARG_MATRIX, ESI ) - MOV_L ( ARG_SOURCE, EAX ) - MOV_L ( CONST(2), REGOFF(V4F_SIZE, ECX) ) - OR_B ( CONST(VEC_SIZE_2), REGOFF(V4F_FLAGS, ECX) ) - MOV_L ( REGOFF(V4F_COUNT, EAX), EDX ) - MOV_L ( EDX, REGOFF(V4F_COUNT, ECX) ) - - PUSH_L ( EDI ) - - MOV_L ( REGOFF(V4F_START, ECX), EDX ) - MOV_L ( ESI, ECX ) - MOV_L ( REGOFF(V4F_COUNT, EAX), ESI ) - MOV_L ( REGOFF(V4F_STRIDE, EAX), EDI ) - MOV_L ( REGOFF(V4F_START, EAX), EAX ) - - TEST_L ( ESI, ESI ) - JZ ( LLBL( G3TP2NRR_3 ) ) - - MOVD ( REGIND(ECX), MM0 ) /* | m00 */ - PUNPCKLDQ ( REGOFF(20, ECX), MM0 ) /* m11 | m00 */ - - MOVQ ( REGOFF(48, ECX), MM2 ) /* m31 | m30 */ - -ALIGNTEXT16 -LLBL( G3TP2NRR_2 ): - - MOVQ ( REGIND(EAX), MM4 ) /* x1 | x0 */ - ADD_L ( EDI, EAX ) /* next vertex */ - - PFMUL ( MM0, MM4 ) /* x1*m11 | x0*m00 */ - PFADD ( MM2, MM4 ) /* m31 | x0*m00+m30 */ - - MOVQ ( MM4, REGIND(EDX) ) /* write r1, r0 */ - ADD_L ( CONST(16), EDX ) /* next r */ - - DEC_L ( ESI ) /* decrement vertex counter */ - JNZ ( LLBL( G3TP2NRR_2 ) ) /* cnt > 0 ? -> process next vertex */ - -LLBL( G3TP2NRR_3 ): - - FEMMS - POP_L ( EDI ) - POP_L ( ESI ) - RET - - - - -ALIGNTEXT16 -GLOBL GLNAME( _mesa_3dnow_transform_points2_identity ) -HIDDEN(_mesa_3dnow_transform_points2_identity) -GLNAME( _mesa_3dnow_transform_points2_identity ): - - PUSH_L ( ESI ) - - MOV_L ( ARG_DEST, ECX ) - MOV_L ( ARG_MATRIX, ESI ) - MOV_L ( ARG_SOURCE, EAX ) - MOV_L ( CONST(2), REGOFF(V4F_SIZE, ECX) ) - OR_B ( CONST(VEC_SIZE_2), REGOFF(V4F_FLAGS, ECX) ) - MOV_L ( REGOFF(V4F_COUNT, EAX), EDX ) - MOV_L ( EDX, REGOFF(V4F_COUNT, ECX) ) - - PUSH_L ( EDI ) - - MOV_L ( REGOFF(V4F_START, ECX), EDX ) - MOV_L ( ESI, ECX ) - MOV_L ( REGOFF(V4F_COUNT, EAX), ESI ) - MOV_L ( REGOFF(V4F_STRIDE, EAX), EDI ) - MOV_L ( REGOFF(V4F_START, EAX), EAX ) - - TEST_L ( ESI, ESI ) - JZ ( LLBL( G3TPIR_3 ) ) - -ALIGNTEXT16 -LLBL( G3TPIR_3 ): - - MOVQ ( REGIND(EAX), MM0 ) /* x1 | x0 */ - ADD_L ( EDI, EAX ) /* next vertex */ - - MOVQ ( MM0, REGIND(EDX) ) /* r1 | r0 */ - ADD_L ( CONST(16), EDX ) /* next r */ - - DEC_L ( ESI ) /* decrement vertex counter */ - JNZ ( LLBL( G3TPIR_3 ) ) /* cnt > 0 ? -> process next vertex */ - -LLBL( G3TPIR_4 ): - - FEMMS - POP_L ( EDI ) - POP_L ( ESI ) - RET -#endif - -#if defined (__ELF__) && defined (__linux__) - .section .note.GNU-stack,"",%progbits -#endif diff --git a/dll/opengl/mesa/x86/3dnow_xform3.S b/dll/opengl/mesa/x86/3dnow_xform3.S deleted file mode 100644 index a356aaee76b..00000000000 --- a/dll/opengl/mesa/x86/3dnow_xform3.S +++ /dev/null @@ -1,561 +0,0 @@ - -/* - * Mesa 3-D graphics library - * Version: 3.5 - * - * Copyright (C) 1999-2001 Brian Paul All Rights Reserved. - * - * Permission is hereby granted, free of charge, to any person obtaining a - * copy of this software and associated documentation files (the "Software"), - * to deal in the Software without restriction, including without limitation - * the rights to use, copy, modify, merge, publish, distribute, sublicense, - * and/or sell copies of the Software, and to permit persons to whom the - * Software is furnished to do so, subject to the following conditions: - * - * The above copyright notice and this permission notice shall be included - * in all copies or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS - * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL - * BRIAN PAUL BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN - * AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN - * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. - */ - -#ifdef USE_3DNOW_ASM -#include "assyntax.h" -#include "matypes.h" -#include "xform_args.h" - - SEG_TEXT - -#define FRAME_OFFSET 4 - - -ALIGNTEXT16 -GLOBL GLNAME( _mesa_3dnow_transform_points3_general ) -HIDDEN(_mesa_3dnow_transform_points3_general) -GLNAME( _mesa_3dnow_transform_points3_general ): - - PUSH_L ( ESI ) - - MOV_L ( ARG_DEST, ECX ) - MOV_L ( ARG_MATRIX, ESI ) - MOV_L ( ARG_SOURCE, EAX ) - MOV_L ( CONST(4), REGOFF(V4F_SIZE, ECX) ) - OR_B ( CONST(VEC_SIZE_4), REGOFF(V4F_FLAGS, ECX) ) - MOV_L ( REGOFF(V4F_COUNT, EAX), EDX ) - MOV_L ( EDX, REGOFF(V4F_COUNT, ECX) ) - - PUSH_L ( EDI ) - - MOV_L ( REGOFF(V4F_START, ECX), EDX ) - MOV_L ( ESI, ECX ) - MOV_L ( REGOFF(V4F_COUNT, EAX), ESI ) - MOV_L ( REGOFF(V4F_STRIDE, EAX), EDI ) - MOV_L ( REGOFF(V4F_START, EAX), EAX ) - - TEST_L ( ESI, ESI ) - JZ ( LLBL( G3TPGR_2 ) ) - - PREFETCHW ( REGIND(EDX) ) - -ALIGNTEXT16 -LLBL( G3TPGR_1 ): - - PREFETCHW ( REGOFF(32, EDX) ) /* prefetch 2 vertices ahead */ - - MOVQ ( REGIND(EAX), MM0 ) /* x1 | x0 */ - MOVD ( REGOFF(8, EAX), MM2 ) /* | x2 */ - - ADD_L ( EDI, EAX ) /* next vertex */ - PREFETCH ( REGIND(EAX) ) - - MOVQ ( MM0, MM1 ) /* x1 | x0 */ - PUNPCKLDQ ( MM2, MM2 ) /* x2 | x2 */ - - PUNPCKLDQ ( MM0, MM0 ) /* x0 | x0 */ - MOVQ ( MM2, MM5 ) /* x2 | x2 */ - - PUNPCKHDQ ( MM1, MM1 ) /* x1 | x1 */ - PFMUL ( REGOFF(32, ECX), MM2 ) /* x2*m9 | x2*m8 */ - - MOVQ ( MM0, MM3 ) /* x0 | x0 */ - PFMUL ( REGOFF(40, ECX), MM5 ) /* x2*m11 | x2*m10 */ - - MOVQ ( MM1, MM4 ) /* x1 | x1 */ - PFMUL ( REGIND(ECX), MM0 ) /* x0*m1 | x0*m0 */ - - PFADD ( REGOFF(48, ECX), MM2 ) /* x2*m9+m13 | x2*m8+m12 */ - PFMUL ( REGOFF(16, ECX), MM1 ) /* x1*m5 | x1*m4 */ - - PFADD ( REGOFF(56, ECX), MM5 ) /* x2*m11+m15 | x2*m10+m14 */ - PFADD ( MM0, MM1 ) /* x0*m1+x1*m5 | x0*m0+x1*m4 */ - - PFMUL ( REGOFF(8, ECX), MM3 ) /* x0*m3 | x0*m2 */ - PFADD ( MM1, MM2 ) /* r1 | r0 */ - - PFMUL ( REGOFF(24, ECX), MM4 ) /* x1*m7 | x1*m6 */ - ADD_L ( CONST(16), EDX ) /* next output vertex */ - - PFADD ( MM3, MM4 ) /* x0*m3+x1*m7 | x0*m2+x1*m6 */ - MOVQ ( MM2, REGOFF(-16, EDX) ) /* write r0, r1 */ - - PFADD ( MM4, MM5 ) /* r3 | r2 */ - MOVQ ( MM5, REGOFF(-8, EDX) ) /* write r2, r3 */ - - DEC_L ( ESI ) /* decrement vertex counter */ - JNZ ( LLBL( G3TPGR_1 ) ) /* cnt > 0 ? -> process next vertex */ - -LLBL( G3TPGR_2 ): - - FEMMS - POP_L ( EDI ) - POP_L ( ESI ) - RET - - - - -ALIGNTEXT16 -GLOBL GLNAME( _mesa_3dnow_transform_points3_perspective ) -HIDDEN(_mesa_3dnow_transform_points3_perspective) -GLNAME( _mesa_3dnow_transform_points3_perspective ): - - PUSH_L ( ESI ) - - MOV_L ( ARG_DEST, ECX ) - MOV_L ( ARG_MATRIX, ESI ) - MOV_L ( ARG_SOURCE, EAX ) - MOV_L ( CONST(4), REGOFF(V4F_SIZE, ECX) ) - OR_B ( CONST(VEC_SIZE_4), REGOFF(V4F_FLAGS, ECX) ) - MOV_L ( REGOFF(V4F_COUNT, EAX), EDX ) - MOV_L ( EDX, REGOFF(V4F_COUNT, ECX) ) - - PUSH_L ( EDI ) - - MOV_L ( REGOFF(V4F_START, ECX), EDX ) - MOV_L ( ESI, ECX ) - MOV_L ( REGOFF(V4F_COUNT, EAX), ESI ) - MOV_L ( REGOFF(V4F_STRIDE, EAX), EDI ) - MOV_L ( REGOFF(V4F_START, EAX), EAX ) - - TEST_L ( ESI, ESI ) - JZ ( LLBL( G3TPPR_2 ) ) - - PREFETCH ( REGIND(EAX) ) - PREFETCHW ( REGIND(EDX) ) - - MOVD ( REGIND(ECX), MM0 ) /* | m00 */ - PUNPCKLDQ ( REGOFF(20, ECX), MM0 ) /* m11 | m00 */ - - MOVQ ( REGOFF(32, ECX), MM1 ) /* m21 | m20 */ - MOVD ( REGOFF(40, ECX), MM2 ) /* | m22 */ - - MOVD ( REGOFF(56, ECX), MM3 ) /* | m32 */ - -ALIGNTEXT16 -LLBL( G3TPPR_1 ): - - PREFETCHW ( REGOFF(32, EDX) ) /* prefetch 2 vertices ahead */ - - MOVD ( REGOFF(8, EAX), MM5 ) /* | x2 */ - MOVQ ( REGIND(EAX), MM4 ) /* x1 | x0 */ - - ADD_L ( EDI, EAX ) /* next vertex */ - PREFETCH ( REGIND(EAX) ) - - PXOR ( MM7, MM7 ) /* 0 | 0 */ - MOVQ ( MM5, MM6 ) /* | x2 */ - - PFMUL ( MM0, MM4 ) /* x1*m11 | x0*m00 */ - PFSUB ( MM5, MM7 ) /* | -x2 */ - - PFMUL ( MM2, MM6 ) /* | x2*m22 */ - PUNPCKLDQ ( MM5, MM5 ) /* x2 | x2 */ - - ADD_L ( CONST(16), EDX ) /* next r */ - PFMUL ( MM1, MM5 ) /* x2*m21 | x2*m20 */ - - PFADD ( MM3, MM6 ) /* | x2*m22+m32 */ - PFADD ( MM4, MM5 ) /* x1*m11+x2*m21 | x0*m00+x2*m20 */ - - MOVQ ( MM5, REGOFF(-16, EDX) ) /* write r0, r1 */ - MOVD ( MM6, REGOFF(-8, EDX) ) /* write r2 */ - - MOVD ( MM7, REGOFF(-4, EDX) ) /* write r3 */ - - DEC_L ( ESI ) /* decrement vertex counter */ - JNZ ( LLBL( G3TPPR_1 ) ) /* cnt > 0 ? -> process next vertex */ - -LLBL( G3TPPR_2 ): - - FEMMS - POP_L ( EDI ) - POP_L ( ESI ) - RET - - - - -ALIGNTEXT16 -GLOBL GLNAME( _mesa_3dnow_transform_points3_3d ) -HIDDEN(_mesa_3dnow_transform_points3_3d) -GLNAME( _mesa_3dnow_transform_points3_3d ): - - PUSH_L ( ESI ) - - MOV_L ( ARG_DEST, ECX ) - MOV_L ( ARG_MATRIX, ESI ) - MOV_L ( ARG_SOURCE, EAX ) - MOV_L ( CONST(3), REGOFF(V4F_SIZE, ECX) ) - OR_B ( CONST(VEC_SIZE_3), REGOFF(V4F_FLAGS, ECX) ) - MOV_L ( REGOFF(V4F_COUNT, EAX), EDX ) - MOV_L ( EDX, REGOFF(V4F_COUNT, ECX) ) - - PUSH_L ( EDI ) - - MOV_L ( REGOFF(V4F_START, ECX), EDX ) - MOV_L ( ESI, ECX ) - MOV_L ( REGOFF(V4F_COUNT, EAX), ESI ) - MOV_L ( REGOFF(V4F_STRIDE, EAX), EDI ) - MOV_L ( REGOFF(V4F_START, EAX), EAX ) - - TEST_L ( ESI, ESI ) - JZ ( LLBL( G3TP3R_2 ) ) - - PREFETCH ( REGIND(EAX) ) - PREFETCH ( REGIND(EDX) ) - - MOVD ( REGOFF(8, ECX), MM7 ) /* | m2 */ - PUNPCKLDQ ( REGOFF(24, ECX), MM7 ) /* m6 | m2 */ - - -ALIGNTEXT16 -LLBL( G3TP3R_1 ): - - PREFETCHW ( REGOFF(32, EDX) ) /* prefetch 2 vertices ahead */ - - MOVQ ( REGIND(EAX), MM0 ) /* x1 | x0 */ - MOVD ( REGOFF(8, EAX), MM1 ) /* | x2 */ - - ADD_L ( EDI, EAX ) /* next vertex */ - PREFETCH ( REGIND(EAX) ) - - MOVQ ( MM0, MM2 ) /* x1 | x0 */ - ADD_L ( CONST(16), EDX ) /* next r */ - - PUNPCKLDQ ( MM2, MM2 ) /* x0 | x0 */ - MOVQ ( MM0, MM3 ) /* x1 | x0 */ - - PFMUL ( REGIND(ECX), MM2 ) /* x0*m1 | x0*m0 */ - PUNPCKHDQ ( MM3, MM3 ) /* x1 | x1 */ - - MOVQ ( MM1, MM4 ) /* | x2 */ - PFMUL ( REGOFF(16, ECX), MM3 ) /* x1*m5 | x1*m4 */ - - PUNPCKLDQ ( MM4, MM4 ) /* x2 | x2 */ - PFADD ( MM2, MM3 ) /* x0*m1+x1*m5 | x0*m0+x1*m4 */ - - PFMUL ( REGOFF(32, ECX), MM4 ) /* x2*m9 | x2*m8 */ - PFADD ( REGOFF(48, ECX), MM3 ) /* x0*m1+...+m11 | x0*m0+x1*m4+m12 */ - - PFMUL ( MM7, MM0 ) /* x1*m6 | x0*m2 */ - PFADD ( MM4, MM3 ) /* r1 | r0 */ - - PFMUL ( REGOFF(40, ECX), MM1 ) /* | x2*m10 */ - PUNPCKLDQ ( REGOFF(56, ECX), MM1 ) /* m14 | x2*m10 */ - - PFACC ( MM0, MM1 ) - - MOVQ ( MM3, REGOFF(-16, EDX) ) /* write r0, r1 */ - PFACC ( MM1, MM1 ) /* | r2 */ - - MOVD ( MM1, REGOFF(-8, EDX) ) /* write r2 */ - - DEC_L ( ESI ) /* decrement vertex counter */ - JNZ ( LLBL( G3TP3R_1 ) ) /* cnt > 0 ? -> process next vertex */ - -LLBL( G3TP3R_2 ): - - FEMMS - POP_L ( EDI ) - POP_L ( ESI ) - RET - - - - -ALIGNTEXT16 -GLOBL GLNAME( _mesa_3dnow_transform_points3_3d_no_rot ) -HIDDEN(_mesa_3dnow_transform_points3_3d_no_rot) -GLNAME( _mesa_3dnow_transform_points3_3d_no_rot ): - - PUSH_L ( ESI ) - - MOV_L ( ARG_DEST, ECX ) - MOV_L ( ARG_MATRIX, ESI ) - MOV_L ( ARG_SOURCE, EAX ) - MOV_L ( CONST(3), REGOFF(V4F_SIZE, ECX) ) - OR_B ( CONST(VEC_SIZE_3), REGOFF(V4F_FLAGS, ECX) ) - MOV_L ( REGOFF(V4F_COUNT, EAX), EDX ) - MOV_L ( EDX, REGOFF(V4F_COUNT, ECX) ) - - PUSH_L ( EDI ) - - MOV_L ( REGOFF(V4F_START, ECX), EDX ) - MOV_L ( ESI, ECX ) - MOV_L ( REGOFF(V4F_COUNT, EAX), ESI ) - MOV_L ( REGOFF(V4F_STRIDE, EAX), EDI ) - MOV_L ( REGOFF(V4F_START, EAX), EAX ) - - TEST_L ( ESI, ESI ) - JZ ( LLBL( G3TP3NRR_2 ) ) - - PREFETCH ( REGIND(EAX) ) - PREFETCHW ( REGIND(EDX) ) - - MOVD ( REGIND(ECX), MM0 ) /* | m00 */ - PUNPCKLDQ ( REGOFF(20, ECX), MM0 ) /* m11 | m00 */ - - MOVD ( REGOFF(40, ECX), MM2 ) /* | m22 */ - PUNPCKLDQ ( MM2, MM2 ) /* m22 | m22 */ - - MOVQ ( REGOFF(48, ECX), MM1 ) /* m31 | m30 */ - MOVD ( REGOFF(56, ECX), MM3 ) /* | m32 */ - - PUNPCKLDQ ( MM3, MM3 ) /* m32 | m32 */ - - -ALIGNTEXT16 -LLBL( G3TP3NRR_1 ): - - PREFETCHW ( REGOFF(32, EDX) ) /* prefetch 2 vertices ahead */ - - MOVQ ( REGIND(EAX), MM4 ) /* x1 | x0 */ - MOVD ( REGOFF(8, EAX), MM5 ) /* | x2 */ - - ADD_L ( EDI, EAX ) /* next vertex */ - PREFETCHW ( REGIND(EAX) ) - - PFMUL ( MM0, MM4 ) /* x1*m11 | x0*m00 */ - - PFADD ( MM1, MM4 ) /* x1*m11+m31 | x0*m00+m30 */ - PFMUL ( MM2, MM5 ) /* | x2*m22 */ - - PFADD ( MM3, MM5 ) /* | x2*m22+m32 */ - MOVQ ( MM4, REGIND(EDX) ) /* write r0, r1 */ - - ADD_L ( CONST(16), EDX ) /* next r */ - DEC_L ( ESI ) /* decrement vertex counter */ - - MOVD ( MM5, REGOFF(-8, EDX) ) /* write r2 */ - JNZ ( LLBL( G3TP3NRR_1 ) ) /* cnt > 0 ? -> process next vertex */ - -LLBL( G3TP3NRR_2 ): - - FEMMS - POP_L ( EDI ) - POP_L ( ESI ) - RET - - - - -ALIGNTEXT16 -GLOBL GLNAME( _mesa_3dnow_transform_points3_2d ) -HIDDEN(_mesa_3dnow_transform_points3_2d) -GLNAME( _mesa_3dnow_transform_points3_2d ): - - PUSH_L ( ESI ) - - MOV_L ( ARG_DEST, ECX ) - MOV_L ( ARG_MATRIX, ESI ) - MOV_L ( ARG_SOURCE, EAX ) - MOV_L ( CONST(3), REGOFF(V4F_SIZE, ECX) ) - OR_B ( CONST(VEC_SIZE_3), REGOFF(V4F_FLAGS, ECX) ) - MOV_L ( REGOFF(V4F_COUNT, EAX), EDX ) - MOV_L ( EDX, REGOFF(V4F_COUNT, ECX) ) - - PUSH_L ( EDI ) - - MOV_L ( REGOFF(V4F_START, ECX), EDX ) - MOV_L ( ESI, ECX ) - MOV_L ( REGOFF(V4F_COUNT, EAX), ESI ) - MOV_L ( REGOFF(V4F_STRIDE, EAX), EDI ) - MOV_L ( REGOFF(V4F_START, EAX), EAX ) - - TEST_L ( ESI, ESI ) - JZ ( LLBL( G3TP2R_3) ) - - PREFETCH ( REGIND(EAX) ) - PREFETCHW ( REGIND(EDX) ) - - MOVD ( REGIND(ECX), MM0 ) /* | m00 */ - PUNPCKLDQ ( REGOFF(16, ECX), MM0 ) /* m10 | m00 */ - - MOVD ( REGOFF(4, ECX), MM1 ) /* | m01 */ - PUNPCKLDQ ( REGOFF(20, ECX), MM1 ) /* m11 | m01 */ - - MOVQ ( REGOFF(48, ECX), MM2 ) /* m31 | m30 */ - -ALIGNTEXT16 -LLBL( G3TP2R_2 ): - - PREFETCHW ( REGOFF(32, EDX) ) /* prefetch 2 vertices ahead */ - - MOVQ ( REGIND(EAX), MM3 ) /* x1 | x0 */ - MOVD ( REGOFF(8, EAX), MM5 ) /* | x2 */ - - ADD_L ( EDI, EAX ) /* next vertex */ - PREFETCH ( REGIND(EAX) ) - - MOVQ ( MM3, MM4 ) /* x1 | x0 */ - PFMUL ( MM0, MM3 ) /* x1*m10 | x0*m00 */ - - ADD_L ( CONST(16), EDX ) /* next r */ - PFMUL ( MM1, MM4 ) /* x1*m11 | x0*m01 */ - - PFACC ( MM4, MM3 ) /* x0*m00+x1*m10 | x0*m01+x1*m11 */ - MOVD ( MM5, REGOFF(-8, EDX) ) /* write r2 (=x2) */ - - PFADD ( MM2, MM3 ) /* x0*...*m10+m30 | x0*...*m11+m31 */ - MOVQ ( MM3, REGOFF(-16, EDX) ) /* write r0, r1 */ - - DEC_L ( ESI ) /* decrement vertex counter */ - JNZ ( LLBL( G3TP2R_2 ) ) /* cnt > 0 ? -> process next vertex */ - -LLBL( G3TP2R_3 ): - - FEMMS - POP_L ( EDI ) - POP_L ( ESI ) - RET - - - - -ALIGNTEXT16 -GLOBL GLNAME( _mesa_3dnow_transform_points3_2d_no_rot ) -HIDDEN(_mesa_3dnow_transform_points3_2d_no_rot) -GLNAME( _mesa_3dnow_transform_points3_2d_no_rot ): - - PUSH_L ( ESI ) - - MOV_L ( ARG_DEST, ECX ) - MOV_L ( ARG_MATRIX, ESI ) - MOV_L ( ARG_SOURCE, EAX ) - MOV_L ( CONST(3), REGOFF(V4F_SIZE, ECX) ) - OR_B ( CONST(VEC_SIZE_3), REGOFF(V4F_FLAGS, ECX) ) - MOV_L ( REGOFF(V4F_COUNT, EAX), EDX ) - MOV_L ( EDX, REGOFF(V4F_COUNT, ECX) ) - - PUSH_L ( EDI ) - - MOV_L ( REGOFF(V4F_START, ECX), EDX ) - MOV_L ( ESI, ECX ) - MOV_L ( REGOFF(V4F_COUNT, EAX), ESI ) - MOV_L ( REGOFF(V4F_STRIDE, EAX), EDI ) - MOV_L ( REGOFF(V4F_START, EAX), EAX ) - - TEST_L ( ESI, ESI ) - JZ ( LLBL( G3TP2NRR_2 ) ) - - PREFETCH ( REGIND(EAX) ) - PREFETCHW ( REGIND(EDX) ) - - MOVD ( REGIND(ECX), MM0 ) /* | m00 */ - PUNPCKLDQ ( REGOFF(20, ECX), MM0 ) /* m11 | m00 */ - - MOVQ ( REGOFF(48, ECX), MM1 ) /* m31 | m30 */ - - -ALIGNTEXT16 -LLBL( G3TP2NRR_1 ): - - PREFETCHW ( REGOFF(32, EDX) ) /* prefetch 2 vertices ahead */ - - MOVQ ( REGIND(EAX), MM4 ) /* x1 | x0 */ - MOVD ( REGOFF(8, EAX), MM5 ) /* | x2 */ - - ADD_L ( EDI, EAX ) /* next vertex */ - PREFETCH ( REGIND(EAX) ) - - PFMUL ( MM0, MM4 ) /* x1*m11 | x0*m00 */ - ADD_L ( CONST(16), EDX ) /* next r */ - - PFADD ( MM1, MM4 ) /* x1*m11+m31 | x0*m00+m30 */ - - MOVQ ( MM4, REGOFF(-16, EDX) ) /* write r0, r1 */ - MOVD ( MM5, REGOFF(-8, EDX) ) /* write r2 (=x2) */ - - DEC_L ( ESI ) /* decrement vertex counter */ - JNZ ( LLBL( G3TP2NRR_1 ) ) /* cnt > 0 ? -> process next vertex */ - -LLBL( G3TP2NRR_2 ): - - FEMMS - POP_L ( EDI ) - POP_L ( ESI ) - RET - - - - -ALIGNTEXT16 -GLOBL GLNAME( _mesa_3dnow_transform_points3_identity ) -HIDDEN(_mesa_3dnow_transform_points3_identity) -GLNAME( _mesa_3dnow_transform_points3_identity ): - - PUSH_L ( ESI ) - - MOV_L ( ARG_DEST, ECX ) - MOV_L ( ARG_MATRIX, ESI ) - MOV_L ( ARG_SOURCE, EAX ) - MOV_L ( CONST(3), REGOFF(V4F_SIZE, ECX) ) - OR_B ( CONST(VEC_SIZE_3), REGOFF(V4F_FLAGS, ECX) ) - MOV_L ( REGOFF(V4F_COUNT, EAX), EDX ) - MOV_L ( EDX, REGOFF(V4F_COUNT, ECX) ) - - PUSH_L ( EDI ) - - MOV_L ( REGOFF(V4F_START, ECX), EDX ) - MOV_L ( ESI, ECX ) - MOV_L ( REGOFF(V4F_COUNT, EAX), ESI ) - MOV_L ( REGOFF(V4F_STRIDE, EAX), EDI ) - MOV_L ( REGOFF(V4F_START, EAX), EAX ) - - TEST_L ( ESI, ESI ) - JZ ( LLBL( G3TPIR_2 ) ) - - PREFETCHW ( REGIND(EDX) ) - -ALIGNTEXT16 -LLBL( G3TPIR_1 ): - - PREFETCHW ( REGOFF(32, EDX) ) - - MOVQ ( REGIND(EAX), MM0 ) /* x1 | x0 */ - MOVD ( REGOFF(8, EAX), MM1 ) /* | x2 */ - - ADD_L ( EDI, EAX ) /* next vertex */ - ADD_L ( CONST(16), EDX ) /* next r */ - - DEC_L ( ESI ) /* decrement vertex counter */ - MOVQ ( MM0, REGOFF(-16, EDX) ) /* r1 | r0 */ - - MOVD ( MM1, REGOFF(-8, EDX) ) /* | r2 */ - JNZ ( LLBL( G3TPIR_1 ) ) /* cnt > 0 ? -> process next vertex */ - -LLBL( G3TPIR_2 ): - - FEMMS - POP_L ( EDI ) - POP_L ( ESI ) - RET -#endif - -#if defined (__ELF__) && defined (__linux__) - .section .note.GNU-stack,"",%progbits -#endif diff --git a/dll/opengl/mesa/x86/3dnow_xform4.S b/dll/opengl/mesa/x86/3dnow_xform4.S deleted file mode 100644 index b2b7c64f23d..00000000000 --- a/dll/opengl/mesa/x86/3dnow_xform4.S +++ /dev/null @@ -1,570 +0,0 @@ - -/* - * Mesa 3-D graphics library - * Version: 3.5 - * - * Copyright (C) 1999-2001 Brian Paul All Rights Reserved. - * - * Permission is hereby granted, free of charge, to any person obtaining a - * copy of this software and associated documentation files (the "Software"), - * to deal in the Software without restriction, including without limitation - * the rights to use, copy, modify, merge, publish, distribute, sublicense, - * and/or sell copies of the Software, and to permit persons to whom the - * Software is furnished to do so, subject to the following conditions: - * - * The above copyright notice and this permission notice shall be included - * in all copies or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS - * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL - * BRIAN PAUL BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN - * AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN - * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. - */ - -#ifdef USE_3DNOW_ASM -#include "assyntax.h" -#include "matypes.h" -#include "xform_args.h" - - SEG_TEXT - -#define FRAME_OFFSET 4 - - -ALIGNTEXT16 -GLOBL GLNAME( _mesa_3dnow_transform_points4_general ) -HIDDEN(_mesa_3dnow_transform_points4_general) -GLNAME( _mesa_3dnow_transform_points4_general ): - - PUSH_L ( ESI ) - - MOV_L ( ARG_DEST, ECX ) - MOV_L ( ARG_MATRIX, ESI ) - MOV_L ( ARG_SOURCE, EAX ) - MOV_L ( CONST(4), REGOFF(V4F_SIZE, ECX) ) - OR_B ( CONST(VEC_SIZE_4), REGOFF(V4F_FLAGS, ECX) ) - MOV_L ( REGOFF(V4F_COUNT, EAX), EDX ) - MOV_L ( EDX, REGOFF(V4F_COUNT, ECX) ) - - PUSH_L ( EDI ) - - MOV_L ( REGOFF(V4F_START, ECX), EDX ) - MOV_L ( ESI, ECX ) - MOV_L ( REGOFF(V4F_COUNT, EAX), ESI ) - MOV_L ( REGOFF(V4F_STRIDE, EAX), EDI ) - MOV_L ( REGOFF(V4F_START, EAX), EAX ) - - TEST_L ( ESI, ESI ) - JZ ( LLBL( G3TPGR_2 ) ) - - PREFETCHW ( REGIND(EDX) ) - -ALIGNTEXT16 -LLBL( G3TPGR_1 ): - - PREFETCHW ( REGOFF(32, EDX) ) /* prefetch 2 vertices ahead */ - - MOVQ ( REGIND(EAX), MM0 ) /* x1 | x0 */ - MOVQ ( REGOFF(8, EAX), MM4 ) /* x3 | x2 */ - - ADD_L ( EDI, EAX ) /* next vertex */ - PREFETCH ( REGIND(EAX) ) - - MOVQ ( MM0, MM2 ) /* x1 | x0 */ - MOVQ ( MM4, MM6 ) /* x3 | x2 */ - - PUNPCKLDQ ( MM0, MM0 ) /* x0 | x0 */ - PUNPCKHDQ ( MM2, MM2 ) /* x1 | x1 */ - - MOVQ ( MM0, MM1 ) /* x0 | x0 */ - ADD_L ( CONST(16), EDX ) /* next r */ - - PFMUL ( REGIND(ECX), MM0 ) /* x0*m1 | x0*m0 */ - MOVQ ( MM2, MM3 ) /* x1 | x1 */ - - PFMUL ( REGOFF(8, ECX), MM1 ) /* x0*m3 | x0*m2 */ - PUNPCKLDQ ( MM4, MM4 ) /* x2 | x2 */ - - PFMUL ( REGOFF(16, ECX), MM2 ) /* x1*m5 | x1*m4 */ - MOVQ ( MM4, MM5 ) /* x2 | x2 */ - - PFMUL ( REGOFF(24, ECX), MM3 ) /* x1*m7 | x1*m6 */ - PUNPCKHDQ ( MM6, MM6 ) /* x3 | x3 */ - - PFMUL ( REGOFF(32, ECX), MM4 ) /* x2*m9 | x2*m8 */ - MOVQ ( MM6, MM7 ) /* x3 | x3 */ - - PFMUL ( REGOFF(40, ECX), MM5 ) /* x2*m11 | x2*m10 */ - PFADD ( MM0, MM2 ) - - PFMUL ( REGOFF(48, ECX), MM6 ) /* x3*m13 | x3*m12 */ - PFADD ( MM1, MM3 ) - - PFMUL ( REGOFF(56, ECX), MM7 ) /* x3*m15 | x3*m14 */ - PFADD ( MM4, MM6 ) - - PFADD ( MM5, MM7 ) - PFADD ( MM2, MM6 ) - - PFADD ( MM3, MM7 ) - MOVQ ( MM6, REGOFF(-16, EDX) ) - - MOVQ ( MM7, REGOFF(-8, EDX) ) - - DEC_L ( ESI ) /* decrement vertex counter */ - JNZ ( LLBL( G3TPGR_1 ) ) /* cnt > 0 ? -> process next vertex */ - -LLBL( G3TPGR_2 ): - - FEMMS - POP_L ( EDI ) - POP_L ( ESI ) - RET - - - - -ALIGNTEXT16 -GLOBL GLNAME( _mesa_3dnow_transform_points4_perspective ) -HIDDEN(_mesa_3dnow_transform_points4_perspective) -GLNAME( _mesa_3dnow_transform_points4_perspective ): - - PUSH_L ( ESI ) - - MOV_L ( ARG_DEST, ECX ) - MOV_L ( ARG_MATRIX, ESI ) - MOV_L ( ARG_SOURCE, EAX ) - MOV_L ( CONST(4), REGOFF(V4F_SIZE, ECX) ) - OR_B ( CONST(VEC_SIZE_4), REGOFF(V4F_FLAGS, ECX) ) - MOV_L ( REGOFF(V4F_COUNT, EAX), EDX ) - MOV_L ( EDX, REGOFF(V4F_COUNT, ECX) ) - - PUSH_L ( EDI ) - - MOV_L ( REGOFF(V4F_START, ECX), EDX ) - MOV_L ( ESI, ECX ) - MOV_L ( REGOFF(V4F_COUNT, EAX), ESI ) - MOV_L ( REGOFF(V4F_STRIDE, EAX), EDI ) - MOV_L ( REGOFF(V4F_START, EAX), EAX ) - - TEST_L ( ESI, ESI ) - JZ ( LLBL( G3TPPR_2 ) ) - - PREFETCH ( REGIND(EAX) ) - PREFETCHW ( REGIND(EDX) ) - - MOVD ( REGIND(ECX), MM0 ) /* | m00 */ - PUNPCKLDQ ( REGOFF(20, ECX), MM0 ) /* m11 | m00 */ - - MOVD ( REGOFF(40, ECX), MM1 ) /* | m22 */ - PUNPCKLDQ ( REGOFF(56, ECX), MM1 ) /* m32 | m22 */ - - MOVQ ( REGOFF(32, ECX), MM2 ) /* m21 | m20 */ - PXOR ( MM7, MM7 ) /* 0 | 0 */ - -ALIGNTEXT16 -LLBL( G3TPPR_1 ): - - PREFETCHW ( REGOFF(32, EDX) ) /* prefetch 2 vertices ahead */ - - MOVQ ( REGIND(EAX), MM4 ) /* x1 | x0 */ - MOVQ ( REGOFF(8, EAX), MM5 ) /* x3 | x2 */ - MOVD ( REGOFF(8, EAX), MM3 ) /* | x2 */ - - ADD_L ( EDI, EAX ) /* next vertex */ - PREFETCH ( REGOFF(32, EAX) ) /* hopefully stride is zero */ - - MOVQ ( MM5, MM6 ) /* x3 | x2 */ - PFMUL ( MM0, MM4 ) /* x1*m11 | x0*m00 */ - - PUNPCKLDQ ( MM5, MM5 ) /* x2 | x2 */ - ADD_L ( CONST(16), EDX ) /* next r */ - - PFMUL ( MM2, MM5 ) /* x2*m21 | x2*m20 */ - PFSUBR ( MM7, MM3 ) /* | -x2 */ - - PFMUL ( MM1, MM6 ) /* x3*m32 | x2*m22 */ - PFADD ( MM4, MM5 ) /* x1*m11+x2*m21 | x0*m00+x2*m20 */ - - PFACC ( MM3, MM6 ) /* -x2 | x2*m22+x3*m32 */ - MOVQ ( MM5, REGOFF(-16, EDX) ) /* write r0, r1 */ - - MOVQ ( MM6, REGOFF(-8, EDX) ) /* write r2, r3 */ - DEC_L ( ESI ) /* decrement vertex counter */ - - JNZ ( LLBL( G3TPPR_1 ) ) /* cnt > 0 ? -> process next vertex */ - -LLBL( G3TPPR_2 ): - - FEMMS - POP_L ( EDI ) - POP_L ( ESI ) - RET - - - - -ALIGNTEXT16 -GLOBL GLNAME( _mesa_3dnow_transform_points4_3d ) -HIDDEN(_mesa_3dnow_transform_points4_3d) -GLNAME( _mesa_3dnow_transform_points4_3d ): - - PUSH_L ( ESI ) - - MOV_L ( ARG_DEST, ECX ) - MOV_L ( ARG_MATRIX, ESI ) - MOV_L ( ARG_SOURCE, EAX ) - MOV_L ( CONST(4), REGOFF(V4F_SIZE, ECX) ) - OR_B ( CONST(VEC_SIZE_4), REGOFF(V4F_FLAGS, ECX) ) - MOV_L ( REGOFF(V4F_COUNT, EAX), EDX ) - MOV_L ( EDX, REGOFF(V4F_COUNT, ECX) ) - - PUSH_L ( EDI ) - - MOV_L ( REGOFF(V4F_START, ECX), EDX ) - MOV_L ( ESI, ECX ) - MOV_L ( REGOFF(V4F_COUNT, EAX), ESI ) - MOV_L ( REGOFF(V4F_STRIDE, EAX), EDI ) - MOV_L ( REGOFF(V4F_START, EAX), EAX ) - - TEST_L ( ESI, ESI ) - JZ ( LLBL( G3TP3R_2 ) ) - - MOVD ( REGOFF(8, ECX), MM6 ) /* | m2 */ - PUNPCKLDQ ( REGOFF(24, ECX), MM6 ) /* m6 | m2 */ - - MOVD ( REGOFF(40, ECX), MM7 ) /* | m10 */ - PUNPCKLDQ ( REGOFF(56, ECX), MM7 ) /* m14 | m10 */ - -ALIGNTEXT16 -LLBL( G3TP3R_1 ): - - PREFETCHW ( REGOFF(32, EDX) ) /* prefetch 2 vertices ahead */ - PREFETCH ( REGOFF(32, EAX) ) /* hopefully array is tightly packed */ - - MOVQ ( REGIND(EAX), MM2 ) /* x1 | x0 */ - MOVQ ( REGOFF(8, EAX), MM3 ) /* x3 | x2 */ - - MOVQ ( MM2, MM0 ) /* x1 | x0 */ - MOVQ ( MM3, MM4 ) /* x3 | x2 */ - - MOVQ ( MM0, MM1 ) /* x1 | x0 */ - MOVQ ( MM4, MM5 ) /* x3 | x2 */ - - PUNPCKLDQ ( MM0, MM0 ) /* x0 | x0 */ - PUNPCKHDQ ( MM1, MM1 ) /* x1 | x1 */ - - PFMUL ( REGIND(ECX), MM0 ) /* x0*m1 | x0*m0 */ - PUNPCKLDQ ( MM3, MM3 ) /* x2 | x2 */ - - PFMUL ( REGOFF(16, ECX), MM1 ) /* x1*m5 | x1*m4 */ - PUNPCKHDQ ( MM4, MM4 ) /* x3 | x3 */ - - PFMUL ( MM6, MM2 ) /* x1*m6 | x0*m2 */ - PFADD ( MM0, MM1 ) /* x0*m1+x1*m5 | x0*m0+x1*m4 */ - - PFMUL ( REGOFF(32, ECX), MM3 ) /* x2*m9 | x2*m8 */ - ADD_L ( CONST(16), EDX ) /* next r */ - - PFMUL ( REGOFF(48, ECX), MM4 ) /* x3*m13 | x3*m12 */ - PFADD ( MM1, MM3 ) /* x0*m1+..+x2*m9 | x0*m0+...+x2*m8 */ - - PFMUL ( MM7, MM5 ) /* x3*m14 | x2*m10 */ - PFADD ( MM3, MM4 ) /* r1 | r0 */ - - PFACC ( MM2, MM5 ) /* x0*m2+x1*m6 | x2*m10+x3*m14 */ - MOVD ( REGOFF(12, EAX), MM0 ) /* | x3 */ - - ADD_L ( EDI, EAX ) /* next vertex */ - PFACC ( MM0, MM5 ) /* r3 | r2 */ - - MOVQ ( MM4, REGOFF(-16, EDX) ) /* write r0, r1 */ - MOVQ ( MM5, REGOFF(-8, EDX) ) /* write r2, r3 */ - - DEC_L ( ESI ) /* decrement vertex counter */ - JNZ ( LLBL( G3TP3R_1 ) ) /* cnt > 0 ? -> process next vertex */ - -LLBL( G3TP3R_2 ): - - FEMMS - POP_L ( EDI ) - POP_L ( ESI ) - RET - - - - -ALIGNTEXT16 -GLOBL GLNAME( _mesa_3dnow_transform_points4_3d_no_rot ) -HIDDEN(_mesa_3dnow_transform_points4_3d_no_rot) -GLNAME( _mesa_3dnow_transform_points4_3d_no_rot ): - - PUSH_L ( ESI ) - MOV_L ( ARG_DEST, ECX ) - MOV_L ( ARG_MATRIX, ESI ) - MOV_L ( ARG_SOURCE, EAX ) - MOV_L ( CONST(4), REGOFF(V4F_SIZE, ECX) ) - OR_B ( CONST(VEC_SIZE_4), REGOFF(V4F_FLAGS, ECX) ) - MOV_L ( REGOFF(V4F_COUNT, EAX), EDX ) - MOV_L ( EDX, REGOFF(V4F_COUNT, ECX) ) - - PUSH_L ( EDI ) - - MOV_L ( REGOFF(V4F_START, ECX), EDX ) - MOV_L ( ESI, ECX ) - MOV_L ( REGOFF(V4F_COUNT, EAX), ESI ) - MOV_L ( REGOFF(V4F_STRIDE, EAX), EDI ) - MOV_L ( REGOFF(V4F_START, EAX), EAX ) - - TEST_L ( ESI, ESI ) - JZ ( LLBL( G3TP3NRR_2 ) ) - - MOVD ( REGIND(ECX), MM0 ) /* | m00 */ - PUNPCKLDQ ( REGOFF(20, ECX), MM0 ) /* m11 | m00 */ - - MOVD ( REGOFF(40, ECX), MM2 ) /* | m22 */ - PUNPCKLDQ ( REGOFF(56, ECX), MM2 ) /* m32 | m22 */ - - MOVQ ( REGOFF(48, ECX), MM1 ) /* m31 | m30 */ - -ALIGNTEXT16 -LLBL( G3TP3NRR_1 ): - - PREFETCHW ( REGOFF(32, EDX) ) /* prefetch 2 vertices ahead */ - - MOVQ ( REGIND(EAX), MM4 ) /* x1 | x0 */ - MOVQ ( REGOFF(8, EAX), MM5 ) /* x3 | x2 */ - MOVD ( REGOFF(12, EAX), MM7 ) /* | x3 */ - - ADD_L ( EDI, EAX ) /* next vertex */ - PREFETCH ( REGOFF(32, EAX) ) /* hopefully stride is zero */ - - MOVQ ( MM5, MM6 ) /* x3 | x2 */ - PFMUL ( MM0, MM4 ) /* x1*m11 | x0*m00 */ - - PUNPCKHDQ ( MM6, MM6 ) /* x3 | x3 */ - PFMUL ( MM2, MM5 ) /* x3*m32 | x2*m22 */ - - PFMUL ( MM1, MM6 ) /* x3*m31 | x3*m30 */ - PFACC ( MM7, MM5 ) /* x3 | x2*m22+x3*m32 */ - - PFADD ( MM6, MM4 ) /* x1*m11+x3*m31 | x0*m00+x3*m30 */ - ADD_L ( CONST(16), EDX ) /* next r */ - - MOVQ ( MM4, REGOFF(-16, EDX) ) /* write r0, r1 */ - MOVQ ( MM5, REGOFF(-8, EDX) ) /* write r2, r3 */ - - DEC_L ( ESI ) /* decrement vertex counter */ - JNZ ( LLBL( G3TP3NRR_1 ) ) /* cnt > 0 ? -> process next vertex */ - -LLBL( G3TP3NRR_2 ): - - FEMMS - POP_L ( EDI ) - POP_L ( ESI ) - RET - - - - -ALIGNTEXT16 -GLOBL GLNAME( _mesa_3dnow_transform_points4_2d ) -HIDDEN(_mesa_3dnow_transform_points4_2d) -GLNAME( _mesa_3dnow_transform_points4_2d ): - - PUSH_L ( ESI ) - - MOV_L ( ARG_DEST, ECX ) - MOV_L ( ARG_MATRIX, ESI ) - MOV_L ( ARG_SOURCE, EAX ) - MOV_L ( CONST(4), REGOFF(V4F_SIZE, ECX) ) - OR_B ( CONST(VEC_SIZE_4), REGOFF(V4F_FLAGS, ECX) ) - MOV_L ( REGOFF(V4F_COUNT, EAX), EDX ) - MOV_L ( EDX, REGOFF(V4F_COUNT, ECX) ) - - PUSH_L ( EDI ) - - MOV_L ( REGOFF(V4F_START, ECX), EDX ) - MOV_L ( ESI, ECX ) - MOV_L ( REGOFF(V4F_COUNT, EAX), ESI ) - MOV_L ( REGOFF(V4F_STRIDE, EAX), EDI ) - MOV_L ( REGOFF(V4F_START, EAX), EAX ) - - TEST_L ( ESI, ESI ) - JZ ( LLBL( G3TP2R_2 ) ) - - MOVD ( REGIND(ECX), MM0 ) /* | m00 */ - PUNPCKLDQ ( REGOFF(16, ECX), MM0 ) /* m10 | m00 */ - - MOVD ( REGOFF(4, ECX), MM1 ) /* | m01 */ - PUNPCKLDQ ( REGOFF(20, ECX), MM1 ) /* m11 | m01 */ - - MOVQ ( REGOFF(48, ECX), MM2 ) /* m31 | m30 */ - -ALIGNTEXT16 -LLBL( G3TP2R_1 ): - - PREFETCHW ( REGOFF(32, EDX) ) /* prefetch 2 vertices ahead */ - - MOVQ ( REGIND(EAX), MM3 ) /* x1 | x0 */ - MOVQ ( REGOFF(8, EAX), MM5 ) /* x3 | x2 */ - - ADD_L ( EDI, EAX ) /* next vertex */ - PREFETCH ( REGIND(EAX) ) - - MOVQ ( MM3, MM4 ) /* x1 | x0 */ - MOVQ ( MM5, MM6 ) /* x3 | x2 */ - - PFMUL ( MM1, MM4 ) /* x1*m11 | x0*m01 */ - PUNPCKHDQ ( MM6, MM6 ) /* x3 | x3 */ - - PFMUL ( MM0, MM3 ) /* x1*m10 | x0*m00 */ - ADD_L ( CONST(16), EDX ) /* next r */ - - PFACC ( MM4, MM3 ) /* x0*m01+x1*m11 | x0*m00+x1*m10 */ - PFMUL ( MM2, MM6 ) /* x3*m31 | x3*m30 */ - - PFADD ( MM6, MM3 ) /* r1 | r0 */ - MOVQ ( MM5, REGOFF(-8, EDX) ) /* write r2, r3 */ - - MOVQ ( MM3, REGOFF(-16, EDX) ) /* write r0, r1 */ - - DEC_L ( ESI ) /* decrement vertex counter */ - JNZ ( LLBL( G3TP2R_1 ) ) /* cnt > 0 ? -> process next vertex */ - -LLBL( G3TP2R_2 ): - - FEMMS - POP_L ( EDI ) - POP_L ( ESI ) - RET - - - - -ALIGNTEXT16 -GLOBL GLNAME( _mesa_3dnow_transform_points4_2d_no_rot ) -HIDDEN(_mesa_3dnow_transform_points4_2d_no_rot) -GLNAME( _mesa_3dnow_transform_points4_2d_no_rot ): - - PUSH_L ( ESI ) - - MOV_L ( ARG_DEST, ECX ) - MOV_L ( ARG_MATRIX, ESI ) - MOV_L ( ARG_SOURCE, EAX ) - MOV_L ( CONST(4), REGOFF(V4F_SIZE, ECX) ) - OR_B ( CONST(VEC_SIZE_4), REGOFF(V4F_FLAGS, ECX) ) - MOV_L ( REGOFF(V4F_COUNT, EAX), EDX ) - MOV_L ( EDX, REGOFF(V4F_COUNT, ECX) ) - - PUSH_L ( EDI ) - - MOV_L ( REGOFF(V4F_START, ECX), EDX ) - MOV_L ( ESI, ECX ) - MOV_L ( REGOFF(V4F_COUNT, EAX), ESI ) - MOV_L ( REGOFF(V4F_STRIDE, EAX), EDI ) - MOV_L ( REGOFF(V4F_START, EAX), EAX ) - - TEST_L ( ESI, ESI ) - JZ ( LLBL( G3TP2NRR_3 ) ) - - MOVD ( REGIND(ECX), MM0 ) /* | m00 */ - PUNPCKLDQ ( REGOFF(20, ECX), MM0 ) /* m11 | m00 */ - - MOVQ ( REGOFF(48, ECX), MM1 ) /* m31 | m30 */ - -ALIGNTEXT16 -LLBL( G3TP2NRR_2 ): - - PREFETCHW ( REGOFF(32, EDX) ) /* prefetch 2 vertices ahead */ - - MOVQ ( REGIND(EAX), MM4 ) /* x1 | x0 */ - MOVQ ( REGOFF(8, EAX), MM5 ) /* x3 | x2 */ - - ADD_L ( EDI, EAX ) /* next vertex */ - PREFETCH ( REGIND(EAX) ) - - PFMUL ( MM0, MM4 ) /* x1*m11 | x0*m00 */ - MOVQ ( MM5, MM6 ) /* x3 | x2 */ - - ADD_L ( CONST(16), EDX ) /* next r */ - PUNPCKHDQ ( MM6, MM6 ) /* x3 | x3 */ - - PFMUL ( MM1, MM6 ) /* x3*m31 | x3*m30 */ - PFADD ( MM4, MM6 ) /* x1*m11+x3*m31 | x0*m00+x3*m30 */ - - MOVQ ( MM6, REGOFF(-16, EDX) ) /* write r0, r1 */ - MOVQ ( MM5, REGOFF(-8, EDX) ) /* write r2, r3 */ - - DEC_L ( ESI ) /* decrement vertex counter */ - - JNZ ( LLBL( G3TP2NRR_2 ) ) /* cnt > 0 ? -> process next vertex */ - -LLBL( G3TP2NRR_3 ): - - FEMMS - POP_L ( EDI ) - POP_L ( ESI ) - RET - - - - -ALIGNTEXT16 -GLOBL GLNAME( _mesa_3dnow_transform_points4_identity ) -HIDDEN(_mesa_3dnow_transform_points4_identity) -GLNAME( _mesa_3dnow_transform_points4_identity ): - - PUSH_L ( ESI ) - - MOV_L ( ARG_DEST, ECX ) - MOV_L ( ARG_MATRIX, ESI ) - MOV_L ( ARG_SOURCE, EAX ) - MOV_L ( CONST(4), REGOFF(V4F_SIZE, ECX) ) - OR_B ( CONST(VEC_SIZE_4), REGOFF(V4F_FLAGS, ECX) ) - MOV_L ( REGOFF(V4F_COUNT, EAX), EDX ) - MOV_L ( EDX, REGOFF(V4F_COUNT, ECX) ) - - PUSH_L ( EDI ) - - MOV_L ( REGOFF(V4F_START, ECX), EDX ) - MOV_L ( ESI, ECX ) - MOV_L ( REGOFF(V4F_COUNT, EAX), ESI ) - MOV_L ( REGOFF(V4F_STRIDE, EAX), EDI ) - MOV_L ( REGOFF(V4F_START, EAX), EAX ) - - TEST_L ( ESI, ESI ) - JZ ( LLBL( G3TPIR_2 ) ) - -ALIGNTEXT16 -LLBL( G3TPIR_1 ): - - PREFETCHW ( REGOFF(32, EDX) ) /* prefetch 2 vertices ahead */ - - MOVQ ( REGIND(EAX), MM0 ) /* x1 | x0 */ - MOVQ ( REGOFF(8, EAX), MM1 ) /* x3 | x2 */ - - ADD_L ( EDI, EAX ) /* next vertex */ - PREFETCH ( REGIND(EAX) ) - - ADD_L ( CONST(16), EDX ) /* next r */ - MOVQ ( MM0, REGOFF(-16, EDX) ) /* r1 | r0 */ - - MOVQ ( MM1, REGOFF(-8, EDX) ) /* r3 | r2 */ - - DEC_L ( ESI ) /* decrement vertex counter */ - JNZ ( LLBL( G3TPIR_1 ) ) /* cnt > 0 ? -> process next vertex */ - -LLBL( G3TPIR_2 ): - - FEMMS - POP_L ( EDI ) - POP_L ( ESI ) - RET -#endif - -#if defined (__ELF__) && defined (__linux__) - .section .note.GNU-stack,"",%progbits -#endif diff --git a/dll/opengl/mesa/x86/CMakeLists.txt b/dll/opengl/mesa/x86/CMakeLists.txt deleted file mode 100644 index 678ca29d50c..00000000000 --- a/dll/opengl/mesa/x86/CMakeLists.txt +++ /dev/null @@ -1,34 +0,0 @@ - -list(APPEND SOURCE - common_x86.c - x86_xform.c - 3dnow.c - sse.c - rtasm/x86sse.c) - -list(APPEND ASM_SOURCE - common_x86_asm.S - x86_xform2.S - x86_xform3.S - x86_xform4.S - x86_cliptest.S - mmx_blend.S - 3dnow_xform1.S - 3dnow_xform2.S - 3dnow_xform3.S - 3dnow_xform4.S - 3dnow_normal.S - sse_xform1.S - sse_xform2.S - sse_xform3.S - sse_xform4.S - sse_normal.S - read_rgba_span_x86.S) - -add_asm_files(mesa_x86_asm ${ASM_SOURCE}) -add_library(mesa_x86 ${SOURCE} ${mesa_x86_asm}) -add_dependencies(mesa_x86 xdk) - -if(NOT MSVC) - add_compile_flags("-Wno-format") -endif() diff --git a/dll/opengl/mesa/x86/assyntax.h b/dll/opengl/mesa/x86/assyntax.h deleted file mode 100644 index 4a41812f6b6..00000000000 --- a/dll/opengl/mesa/x86/assyntax.h +++ /dev/null @@ -1,1747 +0,0 @@ - -#ifndef __ASSYNTAX_H__ -#define __ASSYNTAX_H__ - -/* - * Copyright 1992 Vrije Universiteit, The Netherlands - * - * Permission to use, copy, modify, and distribute this software and its - * documentation for any purpose and without fee is hereby granted, provided - * that the above copyright notice appear in all copies and that both that - * copyright notice and this permission notice appear in supporting - * documentation, and that the name of the Vrije Universiteit not be used in - * advertising or publicity pertaining to distribution of the software without - * specific, written prior permission. The Vrije Universiteit makes no - * representations about the suitability of this software for any purpose. - * It is provided "as is" without express or implied warranty. - * - * The Vrije Universiteit DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS - * SOFTWARE, INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, - * IN NO EVENT SHALL The Vrije Universiteit BE LIABLE FOR ANY SPECIAL, - * INDIRECT OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM - * LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE - * OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR - * PERFORMANCE OF THIS SOFTWARE. - */ - -/* - * assyntax.h - * - * Select the syntax appropriate to the 386 assembler being used - * To add support for more assemblers add more columns to the CHOICE - * macro. Note that register names must also have uppercase names - * to avoid macro recursion. e.g., #define ah %ah recurses! - * - * NB 1. Some of the macros for certain assemblers imply that the code is to - * run in protected mode!! Caveat emptor. - * - * NB 2. 486 specific instructions are not included. This is to discourage - * their accidental use in code that is intended to run on 386 and 486 - * systems. - * - * Supported assemblers: - * - * (a) AT&T SysVr4 as(1): define ATT_ASSEMBLER - * (b) GNU Assembler gas: define GNU_ASSEMBLER (default) - * (c) Amsterdam Compiler kit: define ACK_ASSEMBLER - * (d) The Netwide Assembler: define NASM_ASSEMBLER - * (e) Microsoft Assembler: define MASM_ASSEMBLER (UNTESTED!) - * - * The following naming conventions have been used to identify the various - * data types: - * _SR = segment register version - * Integer: - * _Q = quadword = 64 bits - * _L = long = 32 bits - * _W = short = 16 bits - * _B = byte = 8 bits - * Floating-point: - * _X = m80real = 80 bits - * _D = double = 64 bits - * _S = single = 32 bits - * - * Author: Gregory J. Sharp, Sept 1992 - * Vrije Universiteit, Amsterdam, The Netherlands - * - * [support for Intel syntax added by Josh Vanderhoof, 1999] - */ - -#if !(defined(NASM_ASSEMBLER) || defined(MASM_ASSEMBLER)) - -/* Default to ATT_ASSEMBLER when SVR4 or SYSV are defined */ -#if (defined(SVR4) || defined(SYSV)) && !defined(GNU_ASSEMBLER) -#define ATT_ASSEMBLER -#endif - -#if !defined(ATT_ASSEMBLER) && !defined(GNU_ASSEMBLER) && !defined(ACK_ASSEMBLER) -#define GNU_ASSEMBLER -#endif - -#if (defined(__STDC__) && !defined(UNIXCPP)) || (defined (sun) && defined (i386) && defined (SVR4) && defined (__STDC__) && !defined (__GNUC__)) -#define CONCAT(x, y) x ## y -#define CONCAT3(x, y, z) x ## y ## z -#else -#define CONCAT(x, y) x/**/y -#define CONCAT3(x, y, z) x/**/y/**/z -#endif - -#ifdef ACK_ASSEMBLER - -/* Assume we write code for 32-bit protected mode! */ - -/* Redefine register names for GAS & AT&T assemblers */ -#define AL al -#define AH ah -#define AX ax -#define EAX ax -#define BL bl -#define BH bh -#define BX bx -#define EBX bx -#define CL cl -#define CH ch -#define CX cx -#define ECX cx -#define DL dl -#define DH dh -#define DX dx -#define EDX dx -#define BP bp -#define EBP bp -#define SI si -#define ESI si -#define DI di -#define EDI di -#define SP sp -#define ESP sp -#define CS cs -#define SS ss -#define DS ds -#define ES es -#define FS fs -#define GS gs -/* Control Registers */ -#define CR0 cr0 -#define CR1 cr1 -#define CR2 cr2 -#define CR3 cr3 -/* Debug Registers */ -#define DR0 dr0 -#define DR1 dr1 -#define DR2 dr2 -#define DR3 dr3 -#define DR4 dr4 -#define DR5 dr5 -#define DR6 dr6 -#define DR7 dr7 -/* Floating-point Stack */ -#define ST st - -#define AS_BEGIN .sect .text; .sect .rom; .sect .data; .sect .bss; .sect .text - - -#define _WTOG o16 /* word toggle for _W instructions */ -#define _LTOG /* long toggle for _L instructions */ -#define ADDR_TOGGLE a16 -#define OPSZ_TOGGLE o16 -#define USE16 .use16 -#define USE32 .use32 - -#define CHOICE(a,b,c) c - -#else /* AT&T or GAS */ - -/* Redefine register names for GAS & AT&T assemblers */ -#define AL %al -#define AH %ah -#define AX %ax -#define EAX %eax -#define BL %bl -#define BH %bh -#define BX %bx -#define EBX %ebx -#define CL %cl -#define CH %ch -#define CX %cx -#define ECX %ecx -#define DL %dl -#define DH %dh -#define DX %dx -#define EDX %edx -#define BP %bp -#define EBP %ebp -#define SI %si -#define ESI %esi -#define DI %di -#define EDI %edi -#define SP %sp -#define ESP %esp -#define CS %cs -#define SS %ss -#define DS %ds -#define ES %es -#define FS %fs -#define GS %gs -/* Control Registers */ -#define CR0 %cr0 -#define CR1 %cr1 -#define CR2 %cr2 -#define CR3 %cr3 -/* Debug Registers */ -#define DR0 %db0 -#define DR1 %db1 -#define DR2 %db2 -#define DR3 %db3 -#define DR4 %db4 -#define DR5 %db5 -#define DR6 %db6 -#define DR7 %db7 -/* Floating-point Stack */ -#define _STX0 %st(0) -#define _STX1 %st(1) -#define _STX2 %st(2) -#define _STX3 %st(3) -#define _STX4 %st(4) -#define _STX5 %st(5) -#define _STX6 %st(6) -#define _STX7 %st(7) -#define ST(x) CONCAT(_STX,x) -#ifdef GNU_ASSEMBLER -#define ST0 %st(0) -#else -#define ST0 %st -#endif -/* MMX Registers */ -#define MM0 %mm0 -#define MM1 %mm1 -#define MM2 %mm2 -#define MM3 %mm3 -#define MM4 %mm4 -#define MM5 %mm5 -#define MM6 %mm6 -#define MM7 %mm7 -/* SSE Registers */ -#define XMM0 %xmm0 -#define XMM1 %xmm1 -#define XMM2 %xmm2 -#define XMM3 %xmm3 -#define XMM4 %xmm4 -#define XMM5 %xmm5 -#define XMM6 %xmm6 -#define XMM7 %xmm7 - -#define AS_BEGIN -#define USE16 -#define USE32 - -#ifdef GNU_ASSEMBLER - -#define ADDR_TOGGLE aword -#define OPSZ_TOGGLE word - -#define CHOICE(a,b,c) b - -#else -/* - * AT&T ASSEMBLER SYNTAX - * ********************* - */ -#define CHOICE(a,b,c) a - -#define ADDR_TOGGLE addr16 -#define OPSZ_TOGGLE data16 - -#endif /* GNU_ASSEMBLER */ -#endif /* ACK_ASSEMBLER */ - - -#if defined(__QNX__) || defined(Lynx) || (defined(SYSV) || defined(SVR4)) && !defined(ACK_ASSEMBLER) || defined(__ELF__) || defined(__GNU__) || defined(__GNUC__) && !defined(__DJGPP__) && !defined(__MINGW32__) -#define GLNAME(a) a -#else -#define GLNAME(a) CONCAT(_,a) -#endif - - - /****************************************/ - /* */ - /* Select the various choices */ - /* */ - /****************************************/ - - -/* Redefine assembler directives */ -/*********************************/ -#define GLOBL CHOICE(.globl, .globl, .extern) -#define GLOBAL GLOBL -#define EXTERN GLOBL -#ifndef __AOUT__ -#define ALIGNTEXT32 CHOICE(.align 32, .balign 32, .align 32) -#define ALIGNTEXT16 CHOICE(.align 16, .balign 16, .align 16) -#define ALIGNTEXT8 CHOICE(.align 8, .balign 8, .align 8) -#define ALIGNTEXT4 CHOICE(.align 4, .balign 4, .align 4) -#define ALIGNTEXT2 CHOICE(.align 2, .balign 2, .align 2) -/* ALIGNTEXT4ifNOP is the same as ALIGNTEXT4, but only if the space is - * guaranteed to be filled with NOPs. Otherwise it does nothing. - */ -#define ALIGNTEXT32ifNOP CHOICE(.align 32, .balign ARG2(32,0x90), /*can't do it*/) -#define ALIGNTEXT16ifNOP CHOICE(.align 16, .balign ARG2(16,0x90), /*can't do it*/) -#define ALIGNTEXT8ifNOP CHOICE(.align 8, .balign ARG2(8,0x90), /*can't do it*/) -#define ALIGNTEXT4ifNOP CHOICE(.align 4, .balign ARG2(4,0x90), /*can't do it*/) -#define ALIGNDATA32 CHOICE(.align 32, .balign ARG2(32,0x0), .align 32) -#define ALIGNDATA16 CHOICE(.align 16, .balign ARG2(16,0x0), .align 16) -#define ALIGNDATA8 CHOICE(.align 8, .balign ARG2(8,0x0), .align 8) -#define ALIGNDATA4 CHOICE(.align 4, .balign ARG2(4,0x0), .align 4) -#define ALIGNDATA2 CHOICE(.align 2, .balign ARG2(2,0x0), .align 2) -#else -/* 'as -aout' on FreeBSD doesn't have .balign */ -#define ALIGNTEXT32 CHOICE(.align 32, .align ARG2(5,0x90), .align 32) -#define ALIGNTEXT16 CHOICE(.align 16, .align ARG2(4,0x90), .align 16) -#define ALIGNTEXT8 CHOICE(.align 8, .align ARG2(3,0x90), .align 8) -#define ALIGNTEXT4 CHOICE(.align 4, .align ARG2(2,0x90), .align 4) -#define ALIGNTEXT2 CHOICE(.align 2, .align ARG2(1,0x90), .align 2) -/* ALIGNTEXT4ifNOP is the same as ALIGNTEXT4, but only if the space is - * guaranteed to be filled with NOPs. Otherwise it does nothing. - */ -#define ALIGNTEXT32ifNOP CHOICE(.align 32, .align ARG2(5,0x90), /*can't do it*/) -#define ALIGNTEXT16ifNOP CHOICE(.align 16, .align ARG2(4,0x90), /*can't do it*/) -#define ALIGNTEXT8ifNOP CHOICE(.align 8, .align ARG2(3,0x90), /*can't do it*/) -#define ALIGNTEXT4ifNOP CHOICE(.align 4, .align ARG2(2,0x90), /*can't do it*/) -#define ALIGNDATA32 CHOICE(.align 32, .align ARG2(5,0x0), .align 32) -#define ALIGNDATA16 CHOICE(.align 16, .align ARG2(4,0x0), .align 16) -#define ALIGNDATA8 CHOICE(.align 8, .align ARG2(3,0x0), .align 8) -#define ALIGNDATA4 CHOICE(.align 4, .align ARG2(2,0x0), .align 4) -#define ALIGNDATA2 CHOICE(.align 2, .align ARG2(1,0x0), .align 2) -#endif /* __AOUT__ */ -#define FILE(s) CHOICE(.file s, .file s, .file s) -#define STRING(s) CHOICE(.string s, .asciz s, .asciz s) -#define D_LONG CHOICE(.long, .long, .data4) -#define D_WORD CHOICE(.value, .short, .data2) -#define D_BYTE CHOICE(.byte, .byte, .data1) -#define SPACE CHOICE(.comm, .space, .space) -#define COMM CHOICE(.comm, .comm, .comm) -#define SEG_DATA CHOICE(.data, .data, .sect .data) -#define SEG_TEXT CHOICE(.text, .text, .sect .text) -#define SEG_BSS CHOICE(.bss, .bss, .sect .bss) - -#ifdef GNU_ASSEMBLER -#define D_SPACE(n) . = . + n -#else -#define D_SPACE(n) .space n -#endif - -/* Addressing Modes */ -/* Immediate Mode */ -#define ADDR(a) CHOICE(CONCAT($,a), $a, a) -#define CONST(a) CHOICE(CONCAT($,a), $a, a) - -/* Indirect Mode */ -#define CONTENT(a) CHOICE(a, a, (a)) /* take contents of variable */ -#define REGIND(a) CHOICE((a), (a), (a)) /* Register a indirect */ -/* Register b indirect plus displacement a */ -#define REGOFF(a, b) CHOICE(a(b), a(b), a(b)) -/* Reg indirect Base + Index + Displacement - this is mainly for 16-bit mode - * which has no scaling - */ -#define REGBID(b,i,d) CHOICE(d(b,i), d(b,i), d(b)(i)) -/* Reg indirect Base + (Index * Scale) */ -#define REGBIS(b,i,s) CHOICE((b,i,s), (b,i,s), (b)(i*s)) -/* Reg indirect Base + (Index * Scale) + Displacement */ -#define REGBISD(b,i,s,d) CHOICE(d(b,i,s), d(b,i,s), d(b)(i*s)) -/* Displaced Scaled Index: */ -#define REGDIS(d,i,s) CHOICE(d(,i,s), d(,i,s), d(i * s)) -/* Indexed Base: */ -#define REGBI(b,i) CHOICE((b,i), (b,i), (b)(i)) -/* Displaced Base: */ -#define REGDB(d,b) CHOICE(d(b), d(b), d(b)) -/* Variable indirect: */ -#define VARINDIRECT(var) CHOICE(*var, *var, (var)) -/* Use register contents as jump/call target: */ -#define CODEPTR(reg) CHOICE(*reg, *reg, reg) - -/* For expressions requiring bracketing - * eg. (CRT0_PM | CRT_EM) - */ - -#define EXPR(a) CHOICE([a], (a), [a]) -#define ENOT(a) CHOICE(0!a, ~a, ~a) -#define EMUL(a,b) CHOICE(a\*b, a*b, a*b) -#define EDIV(a,b) CHOICE(a\/b, a/b, a/b) - -/* - * We have to beat the problem of commas within arguments to choice. - * eg. choice (add a,b, add b,a) will get argument mismatch. Luckily ANSI - * and other known cpp definitions evaluate arguments before substitution - * so the following works. - */ -#define ARG2(a, b) a,b -#define ARG3(a,b,c) a,b,c - -/* Redefine assembler commands */ -#define AAA CHOICE(aaa, aaa, aaa) -#define AAD CHOICE(aad, aad, aad) -#define AAM CHOICE(aam, aam, aam) -#define AAS CHOICE(aas, aas, aas) -#define ADC_L(a, b) CHOICE(adcl ARG2(a,b), adcl ARG2(a,b), _LTOG adc ARG2(b,a)) -#define ADC_W(a, b) CHOICE(adcw ARG2(a,b), adcw ARG2(a,b), _WTOG adc ARG2(b,a)) -#define ADC_B(a, b) CHOICE(adcb ARG2(a,b), adcb ARG2(a,b), adcb ARG2(b,a)) -#define ADD_L(a, b) CHOICE(addl ARG2(a,b), addl ARG2(a,b), _LTOG add ARG2(b,a)) -#define ADD_W(a, b) CHOICE(addw ARG2(a,b), addw ARG2(a,b), _WTOG add ARG2(b,a)) -#define ADD_B(a, b) CHOICE(addb ARG2(a,b), addb ARG2(a,b), addb ARG2(b,a)) -#define AND_L(a, b) CHOICE(andl ARG2(a,b), andl ARG2(a,b), _LTOG and ARG2(b,a)) -#define AND_W(a, b) CHOICE(andw ARG2(a,b), andw ARG2(a,b), _WTOG and ARG2(b,a)) -#define AND_B(a, b) CHOICE(andb ARG2(a,b), andb ARG2(a,b), andb ARG2(b,a)) -#define ARPL(a,b) CHOICE(arpl ARG2(a,b), arpl ARG2(a,b), arpl ARG2(b,a)) -#define BOUND_L(a, b) CHOICE(boundl ARG2(a,b), boundl ARG2(b,a), _LTOG bound ARG2(b,a)) -#define BOUND_W(a, b) CHOICE(boundw ARG2(a,b), boundw ARG2(b,a), _WTOG bound ARG2(b,a)) -#define BSF_L(a, b) CHOICE(bsfl ARG2(a,b), bsfl ARG2(a,b), _LTOG bsf ARG2(b,a)) -#define BSF_W(a, b) CHOICE(bsfw ARG2(a,b), bsfw ARG2(a,b), _WTOG bsf ARG2(b,a)) -#define BSR_L(a, b) CHOICE(bsrl ARG2(a,b), bsrl ARG2(a,b), _LTOG bsr ARG2(b,a)) -#define BSR_W(a, b) CHOICE(bsrw ARG2(a,b), bsrw ARG2(a,b), _WTOG bsr ARG2(b,a)) -#define BT_L(a, b) CHOICE(btl ARG2(a,b), btl ARG2(a,b), _LTOG bt ARG2(b,a)) -#define BT_W(a, b) CHOICE(btw ARG2(a,b), btw ARG2(a,b), _WTOG bt ARG2(b,a)) -#define BTC_L(a, b) CHOICE(btcl ARG2(a,b), btcl ARG2(a,b), _LTOG btc ARG2(b,a)) -#define BTC_W(a, b) CHOICE(btcw ARG2(a,b), btcw ARG2(a,b), _WTOG btc ARG2(b,a)) -#define BTR_L(a, b) CHOICE(btrl ARG2(a,b), btrl ARG2(a,b), _LTOG btr ARG2(b,a)) -#define BTR_W(a, b) CHOICE(btrw ARG2(a,b), btrw ARG2(a,b), _WTOG btr ARG2(b,a)) -#define BTS_L(a, b) CHOICE(btsl ARG2(a,b), btsl ARG2(a,b), _LTOG bts ARG2(b,a)) -#define BTS_W(a, b) CHOICE(btsw ARG2(a,b), btsw ARG2(a,b), _WTOG bts ARG2(b,a)) -#define CALL(a) CHOICE(call a, call a, call a) -#define CALLF(s,a) CHOICE(lcall ARG2(s,a), lcall ARG2(s,a), callf s:a) -#define CBW CHOICE(cbtw, cbw, cbw) -#define CWDE CHOICE(cwtd, cwde, cwde) -#define CLC CHOICE(clc, clc, clc) -#define CLD CHOICE(cld, cld, cld) -#define CLI CHOICE(cli, cli, cli) -#define CLTS CHOICE(clts, clts, clts) -#define CMC CHOICE(cmc, cmc, cmc) -#define CMP_L(a, b) CHOICE(cmpl ARG2(a,b), cmpl ARG2(a,b), _LTOG cmp ARG2(b,a)) -#define CMP_W(a, b) CHOICE(cmpw ARG2(a,b), cmpw ARG2(a,b), _WTOG cmp ARG2(b,a)) -#define CMP_B(a, b) CHOICE(cmpb ARG2(a,b), cmpb ARG2(a,b), cmpb ARG2(b,a)) -#define CMPS_L CHOICE(cmpsl, cmpsl, _LTOG cmps) -#define CMPS_W CHOICE(cmpsw, cmpsw, _WTOG cmps) -#define CMPS_B CHOICE(cmpsb, cmpsb, cmpsb) -#define CWD CHOICE(cwtl, cwd, cwd) -#define CDQ CHOICE(cltd, cdq, cdq) -#define DAA CHOICE(daa, daa, daa) -#define DAS CHOICE(das, das, das) -#define DEC_L(a) CHOICE(decl a, decl a, _LTOG dec a) -#define DEC_W(a) CHOICE(decw a, decw a, _WTOG dec a) -#define DEC_B(a) CHOICE(decb a, decb a, decb a) -#define DIV_L(a) CHOICE(divl a, divl a, div a) -#define DIV_W(a) CHOICE(divw a, divw a, div a) -#define DIV_B(a) CHOICE(divb a, divb a, divb a) -#define ENTER(a,b) CHOICE(enter ARG2(a,b), enter ARG2(a,b), enter ARG2(b,a)) -#define HLT CHOICE(hlt, hlt, hlt) -#define IDIV_L(a) CHOICE(idivl a, idivl a, _LTOG idiv a) -#define IDIV_W(a) CHOICE(idivw a, idivw a, _WTOG idiv a) -#define IDIV_B(a) CHOICE(idivb a, idivb a, idivb a) -/* More forms than this for imul!! */ -#define IMUL_L(a, b) CHOICE(imull ARG2(a,b), imull ARG2(a,b), _LTOG imul ARG2(b,a)) -#define IMUL_W(a, b) CHOICE(imulw ARG2(a,b), imulw ARG2(a,b), _WTOG imul ARG2(b,a)) -#define IMUL_B(a) CHOICE(imulb a, imulb a, imulb a) -#define IN_L CHOICE(inl (DX), inl ARG2(DX,EAX), _LTOG in DX) -#define IN_W CHOICE(inw (DX), inw ARG2(DX,AX), _WTOG in DX) -#define IN_B CHOICE(inb (DX), inb ARG2(DX,AL), inb DX) -/* Please AS code writer: use the following ONLY, if you refer to ports<256 - * directly, but not in IN1_W(DX), for instance, even if IN1_ looks nicer - */ -#if defined (sun) -#define IN1_L(a) CHOICE(inl (a), inl ARG2(a,EAX), _LTOG in a) -#define IN1_W(a) CHOICE(inw (a), inw ARG2(a,AX), _WTOG in a) -#define IN1_B(a) CHOICE(inb (a), inb ARG2(a,AL), inb a) -#else -#define IN1_L(a) CHOICE(inl a, inl ARG2(a,EAX), _LTOG in a) -#define IN1_W(a) CHOICE(inw a, inw ARG2(a,AX), _WTOG in a) -#define IN1_B(a) CHOICE(inb a, inb ARG2(a,AL), inb a) -#endif -#define INC_L(a) CHOICE(incl a, incl a, _LTOG inc a) -#define INC_W(a) CHOICE(incw a, incw a, _WTOG inc a) -#define INC_B(a) CHOICE(incb a, incb a, incb a) -#define INS_L CHOICE(insl, insl, _LTOG ins) -#define INS_W CHOICE(insw, insw, _WTOG ins) -#define INS_B CHOICE(insb, insb, insb) -#define INT(a) CHOICE(int a, int a, int a) -#define INT3 CHOICE(int CONST(3), int3, int CONST(3)) -#define INTO CHOICE(into, into, into) -#define IRET CHOICE(iret, iret, iret) -#define IRETD CHOICE(iret, iret, iretd) -#define JA(a) CHOICE(ja a, ja a, ja a) -#define JAE(a) CHOICE(jae a, jae a, jae a) -#define JB(a) CHOICE(jb a, jb a, jb a) -#define JBE(a) CHOICE(jbe a, jbe a, jbe a) -#define JC(a) CHOICE(jc a, jc a, jc a) -#define JE(a) CHOICE(je a, je a, je a) -#define JG(a) CHOICE(jg a, jg a, jg a) -#define JGE(a) CHOICE(jge a, jge a, jge a) -#define JL(a) CHOICE(jl a, jl a, jl a) -#define JLE(a) CHOICE(jle a, jle a, jle a) -#define JNA(a) CHOICE(jna a, jna a, jna a) -#define JNAE(a) CHOICE(jnae a, jnae a, jnae a) -#define JNB(a) CHOICE(jnb a, jnb a, jnb a) -#define JNBE(a) CHOICE(jnbe a, jnbe a, jnbe a) -#define JNC(a) CHOICE(jnc a, jnc a, jnc a) -#define JNE(a) CHOICE(jne a, jne a, jne a) -#define JNG(a) CHOICE(jng a, jng a, jng a) -#define JNGE(a) CHOICE(jnge a, jnge a, jnge a) -#define JNL(a) CHOICE(jnl a, jnl a, jnl a) -#define JNLE(a) CHOICE(jnle a, jnle a, jnle a) -#define JNO(a) CHOICE(jno a, jno a, jno a) -#define JNP(a) CHOICE(jnp a, jnp a, jnp a) -#define JNS(a) CHOICE(jns a, jns a, jns a) -#define JNZ(a) CHOICE(jnz a, jnz a, jnz a) -#define JO(a) CHOICE(jo a, jo a, jo a) -#define JP(a) CHOICE(jp a, jp a, jp a) -#define JPE(a) CHOICE(jpe a, jpe a, jpe a) -#define JPO(a) CHOICE(jpo a, jpo a, jpo a) -#define JS(a) CHOICE(js a, js a, js a) -#define JZ(a) CHOICE(jz a, jz a, jz a) -#define JMP(a) CHOICE(jmp a, jmp a, jmp a) -#define JMPF(s,a) CHOICE(ljmp ARG2(s,a), ljmp ARG2(s,a), jmpf s:a) -#define LAHF CHOICE(lahf, lahf, lahf) -#if !defined(_REAL_MODE) && !defined(_V86_MODE) -#define LAR(a, b) CHOICE(lar ARG2(a, b), lar ARG2(a, b), lar ARG2(b, a)) -#endif -#define LEA_L(a, b) CHOICE(leal ARG2(a,b), leal ARG2(a,b), _LTOG lea ARG2(b,a)) -#define LEA_W(a, b) CHOICE(leaw ARG2(a,b), leaw ARG2(a,b), _WTOG lea ARG2(b,a)) -#define LEAVE CHOICE(leave, leave, leave) -#define LGDT(a) CHOICE(lgdt a, lgdt a, lgdt a) -#define LIDT(a) CHOICE(lidt a, lidt a, lidt a) -#define LDS(a, b) CHOICE(ldsl ARG2(a,b), lds ARG2(a,b), lds ARG2(b,a)) -#define LES(a, b) CHOICE(lesl ARG2(a,b), les ARG2(a,b), les ARG2(b,a)) -#define LFS(a, b) CHOICE(lfsl ARG2(a,b), lfs ARG2(a,b), lfs ARG2(b,a)) -#define LGS(a, b) CHOICE(lgsl ARG2(a,b), lgs ARG2(a,b), lgs ARG2(b,a)) -#define LSS(a, b) CHOICE(lssl ARG2(a,b), lss ARG2(a,b), lss ARG2(b,a)) -#define LLDT(a) CHOICE(lldt a, lldt a, lldt a) -#define LMSW(a) CHOICE(lmsw a, lmsw a, lmsw a) -#define LOCK CHOICE(lock, lock, lock) -#define LODS_L CHOICE(lodsl, lodsl, _LTOG lods) -#define LODS_W CHOICE(lodsw, lodsw, _WTOG lods) -#define LODS_B CHOICE(lodsb, lodsb, lodsb) -#define LOOP(a) CHOICE(loop a, loop a, loop a) -#define LOOPE(a) CHOICE(loope a, loope a, loope a) -#define LOOPZ(a) CHOICE(loopz a, loopz a, loopz a) -#define LOOPNE(a) CHOICE(loopne a, loopne a, loopne a) -#define LOOPNZ(a) CHOICE(loopnz a, loopnz a, loopnz a) -#if !defined(_REAL_MODE) && !defined(_V86_MODE) -#define LSL(a, b) CHOICE(lsl ARG2(a,b), lsl ARG2(a,b), lsl ARG2(b,a)) -#endif -#define LTR(a) CHOICE(ltr a, ltr a, ltr a) -#define MOV_SR(a, b) CHOICE(movw ARG2(a,b), mov ARG2(a,b), mov ARG2(b,a)) -#define MOV_L(a, b) CHOICE(movl ARG2(a,b), movl ARG2(a,b), _LTOG mov ARG2(b,a)) -#define MOV_W(a, b) CHOICE(movw ARG2(a,b), movw ARG2(a,b), _WTOG mov ARG2(b,a)) -#define MOV_B(a, b) CHOICE(movb ARG2(a,b), movb ARG2(a,b), movb ARG2(b,a)) -#define MOVS_L CHOICE(movsl, movsl, _LTOG movs) -#define MOVS_W CHOICE(movsw, movsw, _WTOG movs) -#define MOVS_B CHOICE(movsb, movsb, movsb) -#define MOVSX_BL(a, b) CHOICE(movsbl ARG2(a,b), movsbl ARG2(a,b), movsx ARG2(b,a)) -#define MOVSX_BW(a, b) CHOICE(movsbw ARG2(a,b), movsbw ARG2(a,b), movsx ARG2(b,a)) -#define MOVSX_WL(a, b) CHOICE(movswl ARG2(a,b), movswl ARG2(a,b), movsx ARG2(b,a)) -#define MOVZX_BL(a, b) CHOICE(movzbl ARG2(a,b), movzbl ARG2(a,b), movzx ARG2(b,a)) -#define MOVZX_BW(a, b) CHOICE(movzbw ARG2(a,b), movzbw ARG2(a,b), movzx ARG2(b,a)) -#define MOVZX_WL(a, b) CHOICE(movzwl ARG2(a,b), movzwl ARG2(a,b), movzx ARG2(b,a)) -#define MUL_L(a) CHOICE(mull a, mull a, _LTOG mul a) -#define MUL_W(a) CHOICE(mulw a, mulw a, _WTOG mul a) -#define MUL_B(a) CHOICE(mulb a, mulb a, mulb a) -#define NEG_L(a) CHOICE(negl a, negl a, _LTOG neg a) -#define NEG_W(a) CHOICE(negw a, negw a, _WTOG neg a) -#define NEG_B(a) CHOICE(negb a, negb a, negb a) -#define NOP CHOICE(nop, nop, nop) -#define NOT_L(a) CHOICE(notl a, notl a, _LTOG not a) -#define NOT_W(a) CHOICE(notw a, notw a, _WTOG not a) -#define NOT_B(a) CHOICE(notb a, notb a, notb a) -#define OR_L(a,b) CHOICE(orl ARG2(a,b), orl ARG2(a,b), _LTOG or ARG2(b,a)) -#define OR_W(a,b) CHOICE(orw ARG2(a,b), orw ARG2(a,b), _WTOG or ARG2(b,a)) -#define OR_B(a,b) CHOICE(orb ARG2(a,b), orb ARG2(a,b), orb ARG2(b,a)) -#define OUT_L CHOICE(outl (DX), outl ARG2(EAX,DX), _LTOG out DX) -#define OUT_W CHOICE(outw (DX), outw ARG2(AX,DX), _WTOG out DX) -#define OUT_B CHOICE(outb (DX), outb ARG2(AL,DX), outb DX) -/* Please AS code writer: use the following ONLY, if you refer to ports<256 - * directly, but not in OUT1_W(DX), for instance, even if OUT1_ looks nicer - */ -#define OUT1_L(a) CHOICE(outl (a), outl ARG2(EAX,a), _LTOG out a) -#define OUT1_W(a) CHOICE(outw (a), outw ARG2(AX,a), _WTOG out a) -#define OUT1_B(a) CHOICE(outb (a), outb ARG2(AL,a), outb a) -#define OUTS_L CHOICE(outsl, outsl, _LTOG outs) -#define OUTS_W CHOICE(outsw, outsw, _WTOG outs) -#define OUTS_B CHOICE(outsb, outsb, outsb) -#define POP_SR(a) CHOICE(pop a, pop a, pop a) -#define POP_L(a) CHOICE(popl a, popl a, _LTOG pop a) -#define POP_W(a) CHOICE(popw a, popw a, _WTOG pop a) -#define POPA_L CHOICE(popal, popal, _LTOG popa) -#define POPA_W CHOICE(popaw, popaw, _WTOG popa) -#define POPF_L CHOICE(popfl, popfl, _LTOG popf) -#define POPF_W CHOICE(popfw, popfw, _WTOG popf) -#define PUSH_SR(a) CHOICE(push a, push a, push a) -#define PUSH_L(a) CHOICE(pushl a, pushl a, _LTOG push a) -#define PUSH_W(a) CHOICE(pushw a, pushw a, _WTOG push a) -#define PUSH_B(a) CHOICE(push a, pushb a, push a) -#define PUSHA_L CHOICE(pushal, pushal, _LTOG pusha) -#define PUSHA_W CHOICE(pushaw, pushaw, _WTOG pusha) -#define PUSHF_L CHOICE(pushfl, pushfl, _LTOG pushf) -#define PUSHF_W CHOICE(pushfw, pushfw, _WTOG pushf) -#define RCL_L(a, b) CHOICE(rcll ARG2(a,b), rcll ARG2(a,b), _LTOG rcl ARG2(b,a)) -#define RCL_W(a, b) CHOICE(rclw ARG2(a,b), rclw ARG2(a,b), _WTOG rcl ARG2(b,a)) -#define RCL_B(a, b) CHOICE(rclb ARG2(a,b), rclb ARG2(a,b), rclb ARG2(b,a)) -#define RCR_L(a, b) CHOICE(rcrl ARG2(a,b), rcrl ARG2(a,b), _LTOG rcr ARG2(b,a)) -#define RCR_W(a, b) CHOICE(rcrw ARG2(a,b), rcrw ARG2(a,b), _WTOG rcr ARG2(b,a)) -#define RCR_B(a, b) CHOICE(rcrb ARG2(a,b), rcrb ARG2(a,b), rcrb ARG2(b,a)) -#define ROL_L(a, b) CHOICE(roll ARG2(a,b), roll ARG2(a,b), _LTOG rol ARG2(b,a)) -#define ROL_W(a, b) CHOICE(rolw ARG2(a,b), rolw ARG2(a,b), _WTOG rol ARG2(b,a)) -#define ROL_B(a, b) CHOICE(rolb ARG2(a,b), rolb ARG2(a,b), rolb ARG2(b,a)) -#define ROR_L(a, b) CHOICE(rorl ARG2(a,b), rorl ARG2(a,b), _LTOG ror ARG2(b,a)) -#define ROR_W(a, b) CHOICE(rorw ARG2(a,b), rorw ARG2(a,b), _WTOG ror ARG2(b,a)) -#define ROR_B(a, b) CHOICE(rorb ARG2(a,b), rorb ARG2(a,b), rorb ARG2(b,a)) -#define REP CHOICE(rep ;, rep ;, repe) -#define REPE CHOICE(repz ;, repe ;, repe) -#define REPNE CHOICE(repnz ;, repne ;, repne) -#define REPNZ REPNE -#define REPZ REPE -#define RET CHOICE(ret, ret, ret) -#define SAHF CHOICE(sahf, sahf, sahf) -#define SAL_L(a, b) CHOICE(sall ARG2(a,b), sall ARG2(a,b), _LTOG sal ARG2(b,a)) -#define SAL_W(a, b) CHOICE(salw ARG2(a,b), salw ARG2(a,b), _WTOG sal ARG2(b,a)) -#define SAL_B(a, b) CHOICE(salb ARG2(a,b), salb ARG2(a,b), salb ARG2(b,a)) -#define SAR_L(a, b) CHOICE(sarl ARG2(a,b), sarl ARG2(a,b), _LTOG sar ARG2(b,a)) -#define SAR_W(a, b) CHOICE(sarw ARG2(a,b), sarw ARG2(a,b), _WTOG sar ARG2(b,a)) -#define SAR_B(a, b) CHOICE(sarb ARG2(a,b), sarb ARG2(a,b), sarb ARG2(b,a)) -#define SBB_L(a, b) CHOICE(sbbl ARG2(a,b), sbbl ARG2(a,b), _LTOG sbb ARG2(b,a)) -#define SBB_W(a, b) CHOICE(sbbw ARG2(a,b), sbbw ARG2(a,b), _WTOG sbb ARG2(b,a)) -#define SBB_B(a, b) CHOICE(sbbb ARG2(a,b), sbbb ARG2(a,b), sbbb ARG2(b,a)) -#define SCAS_L CHOICE(scasl, scasl, _LTOG scas) -#define SCAS_W CHOICE(scasw, scasw, _WTOG scas) -#define SCAS_B CHOICE(scasb, scasb, scasb) -#define SETA(a) CHOICE(seta a, seta a, seta a) -#define SETAE(a) CHOICE(setae a, setae a, setae a) -#define SETB(a) CHOICE(setb a, setb a, setb a) -#define SETBE(a) CHOICE(setbe a, setbe a, setbe a) -#define SETC(a) CHOICE(setc a, setb a, setb a) -#define SETE(a) CHOICE(sete a, sete a, sete a) -#define SETG(a) CHOICE(setg a, setg a, setg a) -#define SETGE(a) CHOICE(setge a, setge a, setge a) -#define SETL(a) CHOICE(setl a, setl a, setl a) -#define SETLE(a) CHOICE(setle a, setle a, setle a) -#define SETNA(a) CHOICE(setna a, setna a, setna a) -#define SETNAE(a) CHOICE(setnae a, setnae a, setnae a) -#define SETNB(a) CHOICE(setnb a, setnb a, setnb a) -#define SETNBE(a) CHOICE(setnbe a, setnbe a, setnbe a) -#define SETNC(a) CHOICE(setnc a, setnb a, setnb a) -#define SETNE(a) CHOICE(setne a, setne a, setne a) -#define SETNG(a) CHOICE(setng a, setng a, setng a) -#define SETNGE(a) CHOICE(setnge a, setnge a, setnge a) -#define SETNL(a) CHOICE(setnl a, setnl a, setnl a) -#define SETNLE(a) CHOICE(setnle a, setnle a, setnle a) -#define SETNO(a) CHOICE(setno a, setno a, setno a) -#define SETNP(a) CHOICE(setnp a, setnp a, setnp a) -#define SETNS(a) CHOICE(setns a, setns a, setna a) -#define SETNZ(a) CHOICE(setnz a, setnz a, setnz a) -#define SETO(a) CHOICE(seto a, seto a, seto a) -#define SETP(a) CHOICE(setp a, setp a, setp a) -#define SETPE(a) CHOICE(setpe a, setpe a, setpe a) -#define SETPO(a) CHOICE(setpo a, setpo a, setpo a) -#define SETS(a) CHOICE(sets a, sets a, seta a) -#define SETZ(a) CHOICE(setz a, setz a, setz a) -#define SGDT(a) CHOICE(sgdt a, sgdt a, sgdt a) -#define SIDT(a) CHOICE(sidt a, sidt a, sidt a) -#define SHL_L(a, b) CHOICE(shll ARG2(a,b), shll ARG2(a,b), _LTOG shl ARG2(b,a)) -#define SHL_W(a, b) CHOICE(shlw ARG2(a,b), shlw ARG2(a,b), _WTOG shl ARG2(b,a)) -#define SHL_B(a, b) CHOICE(shlb ARG2(a,b), shlb ARG2(a,b), shlb ARG2(b,a)) -#define SHLD_L(a,b,c) CHOICE(shldl ARG3(a,b,c), shldl ARG3(a,b,c), _LTOG shld ARG3(c,b,a)) -#define SHLD2_L(a,b) CHOICE(shldl ARG2(a,b), shldl ARG3(CL,a,b), _LTOG shld ARG3(b,a,CL)) -#define SHLD_W(a,b,c) CHOICE(shldw ARG3(a,b,c), shldw ARG3(a,b,c), _WTOG shld ARG3(c,b,a)) -#define SHLD2_W(a,b) CHOICE(shldw ARG2(a,b), shldw ARG3(CL,a,b), _WTOG shld ARG3(b,a,CL)) -#define SHR_L(a, b) CHOICE(shrl ARG2(a,b), shrl ARG2(a,b), _LTOG shr ARG2(b,a)) -#define SHR_W(a, b) CHOICE(shrw ARG2(a,b), shrw ARG2(a,b), _WTOG shr ARG2(b,a)) -#define SHR_B(a, b) CHOICE(shrb ARG2(a,b), shrb ARG2(a,b), shrb ARG2(b,a)) -#define SHRD_L(a,b,c) CHOICE(shrdl ARG3(a,b,c), shrdl ARG3(a,b,c), _LTOG shrd ARG3(c,b,a)) -#define SHRD2_L(a,b) CHOICE(shrdl ARG2(a,b), shrdl ARG3(CL,a,b), _LTOG shrd ARG3(b,a,CL)) -#define SHRD_W(a,b,c) CHOICE(shrdw ARG3(a,b,c), shrdw ARG3(a,b,c), _WTOG shrd ARG3(c,b,a)) -#define SHRD2_W(a,b) CHOICE(shrdw ARG2(a,b), shrdw ARG3(CL,a,b), _WTOG shrd ARG3(b,a,CL)) -#define SLDT(a) CHOICE(sldt a, sldt a, sldt a) -#define SMSW(a) CHOICE(smsw a, smsw a, smsw a) -#define STC CHOICE(stc, stc, stc) -#define STD CHOICE(std, std, std) -#define STI CHOICE(sti, sti, sti) -#define STOS_L CHOICE(stosl, stosl, _LTOG stos) -#define STOS_W CHOICE(stosw, stosw, _WTOG stos) -#define STOS_B CHOICE(stosb, stosb, stosb) -#define STR(a) CHOICE(str a, str a, str a) -#define SUB_L(a, b) CHOICE(subl ARG2(a,b), subl ARG2(a,b), _LTOG sub ARG2(b,a)) -#define SUB_W(a, b) CHOICE(subw ARG2(a,b), subw ARG2(a,b), _WTOG sub ARG2(b,a)) -#define SUB_B(a, b) CHOICE(subb ARG2(a,b), subb ARG2(a,b), subb ARG2(b,a)) -#define TEST_L(a, b) CHOICE(testl ARG2(a,b), testl ARG2(a,b), _LTOG test ARG2(b,a)) -#define TEST_W(a, b) CHOICE(testw ARG2(a,b), testw ARG2(a,b), _WTOG test ARG2(b,a)) -#define TEST_B(a, b) CHOICE(testb ARG2(a,b), testb ARG2(a,b), testb ARG2(b,a)) -#define VERR(a) CHOICE(verr a, verr a, verr a) -#define VERW(a) CHOICE(verw a, verw a, verw a) -#define WAIT CHOICE(wait, wait, wait) -#define XCHG_L(a, b) CHOICE(xchgl ARG2(a,b), xchgl ARG2(a,b), _LTOG xchg ARG2(b,a)) -#define XCHG_W(a, b) CHOICE(xchgw ARG2(a,b), xchgw ARG2(a,b), _WTOG xchg ARG2(b,a)) -#define XCHG_B(a, b) CHOICE(xchgb ARG2(a,b), xchgb ARG2(a,b), xchgb ARG2(b,a)) -#define XLAT CHOICE(xlat, xlat, xlat) -#define XOR_L(a, b) CHOICE(xorl ARG2(a,b), xorl ARG2(a,b), _LTOG xor ARG2(b,a)) -#define XOR_W(a, b) CHOICE(xorw ARG2(a,b), xorw ARG2(a,b), _WTOG xor ARG2(b,a)) -#define XOR_B(a, b) CHOICE(xorb ARG2(a,b), xorb ARG2(a,b), xorb ARG2(b,a)) - - -/* Floating Point Instructions */ -#define F2XM1 CHOICE(f2xm1, f2xm1, f2xm1) -#define FABS CHOICE(fabs, fabs, fabs) -#define FADD_D(a) CHOICE(faddl a, faddl a, faddd a) -#define FADD_S(a) CHOICE(fadds a, fadds a, fadds a) -#define FADD2(a, b) CHOICE(fadd ARG2(a,b), fadd ARG2(a,b), fadd ARG2(b,a)) -#define FADDP(a, b) CHOICE(faddp ARG2(a,b), faddp ARG2(a,b), faddp ARG2(b,a)) -#define FIADD_L(a) CHOICE(fiaddl a, fiaddl a, fiaddl a) -#define FIADD_W(a) CHOICE(fiadd a, fiadds a, fiadds a) -#define FBLD(a) CHOICE(fbld a, fbld a, fbld a) -#define FBSTP(a) CHOICE(fbstp a, fbstp a, fbstp a) -#define FCHS CHOICE(fchs, fchs, fchs) -#define FCLEX CHOICE(fclex, wait; fnclex, wait; fclex) -#define FNCLEX CHOICE(fnclex, fnclex, fclex) -#define FCOM(a) CHOICE(fcom a, fcom a, fcom a) -#define FCOM_D(a) CHOICE(fcoml a, fcoml a, fcomd a) -#define FCOM_S(a) CHOICE(fcoms a, fcoms a, fcoms a) -#define FCOMP(a) CHOICE(fcomp a, fcomp a, fcomp a) -#define FCOMP_D(a) CHOICE(fcompl a, fcompl a, fcompd a) -#define FCOMP_S(a) CHOICE(fcomps a, fcomps a, fcomps a) -#define FCOMPP CHOICE(fcompp, fcompp, fcompp) -#define FCOS CHOICE(fcos, fcos, fcos) -#define FDECSTP CHOICE(fdecstp, fdecstp, fdecstp) -#define FDIV_D(a) CHOICE(fdivl a, fdivl a, fdivd a) -#define FDIV_S(a) CHOICE(fdivs a, fdivs a, fdivs a) -#define FDIV2(a, b) CHOICE(fdiv ARG2(a,b), fdiv ARG2(a,b), fdiv ARG2(b,a)) -#define FDIVP(a, b) CHOICE(fdivp ARG2(a,b), fdivp ARG2(a,b), fdivp ARG2(b,a)) -#define FIDIV_L(a) CHOICE(fidivl a, fidivl a, fidivl a) -#define FIDIV_W(a) CHOICE(fidiv a, fidivs a, fidivs a) -#define FDIVR_D(a) CHOICE(fdivrl a, fdivrl a, fdivrd a) -#define FDIVR_S(a) CHOICE(fdivrs a, fdivrs a, fdivrs a) -#define FDIVR2(a, b) CHOICE(fdivr ARG2(a,b), fdivr ARG2(a,b), fdivr ARG2(b,a)) -#define FDIVRP(a, b) CHOICE(fdivrp ARG2(a,b), fdivrp ARG2(a,b), fdivrp ARG2(b,a)) -#define FIDIVR_L(a) CHOICE(fidivrl a, fidivrl a, fidivrl a) -#define FIDIVR_W(a) CHOICE(fidivr a, fidivrs a, fidivrs a) -#define FFREE(a) CHOICE(ffree a, ffree a, ffree a) -#define FICOM_L(a) CHOICE(ficoml a, ficoml a, ficoml a) -#define FICOM_W(a) CHOICE(ficom a, ficoms a, ficoms a) -#define FICOMP_L(a) CHOICE(ficompl a, ficompl a, ficompl a) -#define FICOMP_W(a) CHOICE(ficomp a, ficomps a, ficomps a) -#define FILD_Q(a) CHOICE(fildll a, fildq a, fildq a) -#define FILD_L(a) CHOICE(fildl a, fildl a, fildl a) -#define FILD_W(a) CHOICE(fild a, filds a, filds a) -#define FINCSTP CHOICE(fincstp, fincstp, fincstp) -#define FINIT CHOICE(finit, wait; fninit, wait; finit) -#define FNINIT CHOICE(fninit, fninit, finit) -#define FIST_L(a) CHOICE(fistl a, fistl a, fistl a) -#define FIST_W(a) CHOICE(fist a, fists a, fists a) -#define FISTP_Q(a) CHOICE(fistpll a, fistpq a, fistpq a) -#define FISTP_L(a) CHOICE(fistpl a, fistpl a, fistpl a) -#define FISTP_W(a) CHOICE(fistp a, fistps a, fistps a) -#define FLD_X(a) CHOICE(fldt a, fldt a, fldx a) /* 80 bit data type! */ -#define FLD_D(a) CHOICE(fldl a, fldl a, fldd a) -#define FLD_S(a) CHOICE(flds a, flds a, flds a) -#define FLD1 CHOICE(fld1, fld1, fld1) -#define FLDL2T CHOICE(fldl2t, fldl2t, fldl2t) -#define FLDL2E CHOICE(fldl2e, fldl2e, fldl2e) -#define FLDPI CHOICE(fldpi, fldpi, fldpi) -#define FLDLG2 CHOICE(fldlg2, fldlg2, fldlg2) -#define FLDLN2 CHOICE(fldln2, fldln2, fldln2) -#define FLDZ CHOICE(fldz, fldz, fldz) -#define FLDCW(a) CHOICE(fldcw a, fldcw a, fldcw a) -#define FLDENV(a) CHOICE(fldenv a, fldenv a, fldenv a) -#define FMUL_S(a) CHOICE(fmuls a, fmuls a, fmuls a) -#define FMUL_D(a) CHOICE(fmull a, fmull a, fmuld a) -#define FMUL2(a, b) CHOICE(fmul ARG2(a,b), fmul ARG2(a,b), fmul ARG2(b,a)) -#define FMULP(a, b) CHOICE(fmulp ARG2(a,b), fmulp ARG2(a,b), fmulp ARG2(b,a)) -#define FIMUL_L(a) CHOICE(fimull a, fimull a, fimull a) -#define FIMUL_W(a) CHOICE(fimul a, fimuls a, fimuls a) -#define FNOP CHOICE(fnop, fnop, fnop) -#define FPATAN CHOICE(fpatan, fpatan, fpatan) -#define FPREM CHOICE(fprem, fprem, fprem) -#define FPREM1 CHOICE(fprem1, fprem1, fprem1) -#define FPTAN CHOICE(fptan, fptan, fptan) -#define FRNDINT CHOICE(frndint, frndint, frndint) -#define FRSTOR(a) CHOICE(frstor a, frstor a, frstor a) -#define FSAVE(a) CHOICE(fsave a, wait; fnsave a, wait; fsave a) -#define FNSAVE(a) CHOICE(fnsave a, fnsave a, fsave a) -#define FSCALE CHOICE(fscale, fscale, fscale) -#define FSIN CHOICE(fsin, fsin, fsin) -#define FSINCOS CHOICE(fsincos, fsincos, fsincos) -#define FSQRT CHOICE(fsqrt, fsqrt, fsqrt) -#define FST_D(a) CHOICE(fstl a, fstl a, fstd a) -#define FST_S(a) CHOICE(fsts a, fsts a, fsts a) -#define FSTP_X(a) CHOICE(fstpt a, fstpt a, fstpx a) -#define FSTP_D(a) CHOICE(fstpl a, fstpl a, fstpd a) -#define FSTP_S(a) CHOICE(fstps a, fstps a, fstps a) -#define FSTP(a) CHOICE(fstp a, fstp a, fstp a) -#define FSTCW(a) CHOICE(fstcw a, wait; fnstcw a, wait; fstcw a) -#define FNSTCW(a) CHOICE(fnstcw a, fnstcw a, fstcw a) -#define FSTENV(a) CHOICE(fstenv a, wait; fnstenv a, fstenv a) -#define FNSTENV(a) CHOICE(fnstenv a, fnstenv a, fstenv a) -#define FSTSW(a) CHOICE(fstsw a, wait; fnstsw a, wait; fstsw a) -#define FNSTSW(a) CHOICE(fnstsw a, fnstsw a, fstsw a) -#define FSUB_S(a) CHOICE(fsubs a, fsubs a, fsubs a) -#define FSUB_D(a) CHOICE(fsubl a, fsubl a, fsubd a) -#define FSUB2(a, b) CHOICE(fsub ARG2(a,b), fsub ARG2(a,b), fsub ARG2(b,a)) -#define FSUBP(a, b) CHOICE(fsubp ARG2(a,b), fsubp ARG2(a,b), fsubp ARG2(b,a)) -#define FISUB_L(a) CHOICE(fisubl a, fisubl a, fisubl a) -#define FISUB_W(a) CHOICE(fisub a, fisubs a, fisubs a) -#define FSUBR_S(a) CHOICE(fsubrs a, fsubrs a, fsubrs a) -#define FSUBR_D(a) CHOICE(fsubrl a, fsubrl a, fsubrd a) -#define FSUBR2(a, b) CHOICE(fsubr ARG2(a,b), fsubr ARG2(a,b), fsubr ARG2(b,a)) -#define FSUBRP(a, b) CHOICE(fsubrp ARG2(a,b), fsubrp ARG2(a,b), fsubrp ARG2(b,a)) -#define FISUBR_L(a) CHOICE(fisubrl a, fisubrl a, fisubrl a) -#define FISUBR_W(a) CHOICE(fisubr a, fisubrs a, fisubrs a) -#define FTST CHOICE(ftst, ftst, ftst) -#define FUCOM(a) CHOICE(fucom a, fucom a, fucom a) -#define FUCOMP(a) CHOICE(fucomp a, fucomp a, fucomp a) -#define FUCOMPP CHOICE(fucompp, fucompp, fucompp) -#define FWAIT CHOICE(wait, wait, wait) -#define FXAM CHOICE(fxam, fxam, fxam) -#define FXCH(a) CHOICE(fxch a, fxch a, fxch a) -#define FXTRACT CHOICE(fxtract, fxtract, fxtract) -#define FYL2X CHOICE(fyl2x, fyl2x, fyl2x) -#define FYL2XP1 CHOICE(fyl2xp1, fyl2xp1, fyl2xp1) - -/* New instructions */ -#define CPUID CHOICE(D_BYTE ARG2(15, 162), cpuid, D_BYTE ARG2(15, 162)) -#define RDTSC CHOICE(D_BYTE ARG2(15, 49), rdtsc, D_BYTE ARG2(15, 49)) - -#else /* NASM_ASSEMBLER || MASM_ASSEMBLER is defined */ - - /****************************************/ - /* */ - /* Intel style assemblers. */ - /* (NASM and MASM) */ - /* */ - /****************************************/ - -#define P_EAX EAX -#define L_EAX EAX -#define W_AX AX -#define B_AH AH -#define B_AL AL - -#define P_EBX EBX -#define L_EBX EBX -#define W_BX BX -#define B_BH BH -#define B_BL BL - -#define P_ECX ECX -#define L_ECX ECX -#define W_CX CX -#define B_CH CH -#define B_CL CL - -#define P_EDX EDX -#define L_EDX EDX -#define W_DX DX -#define B_DH DH -#define B_DL DL - -#define P_EBP EBP -#define L_EBP EBP -#define W_BP BP - -#define P_ESI ESI -#define L_ESI ESI -#define W_SI SI - -#define P_EDI EDI -#define L_EDI EDI -#define W_DI DI - -#define P_ESP ESP -#define L_ESP ESP -#define W_SP SP - -#define W_CS CS -#define W_SS SS -#define W_DS DS -#define W_ES ES -#define W_FS FS -#define W_GS GS - -#define X_ST ST -#define D_ST ST -#define L_ST ST - -#define P_MM0 mm0 -#define P_MM1 mm1 -#define P_MM2 mm2 -#define P_MM3 mm3 -#define P_MM4 mm4 -#define P_MM5 mm5 -#define P_MM6 mm6 -#define P_MM7 mm7 - -#define P_XMM0 xmm0 -#define P_XMM1 xmm1 -#define P_XMM2 xmm2 -#define P_XMM3 xmm3 -#define P_XMM4 xmm4 -#define P_XMM5 xmm5 -#define P_XMM6 xmm6 -#define P_XMM7 xmm7 - -#define CONCAT(x, y) x ## y -#define CONCAT3(x, y, z) x ## y ## z - -#if defined(NASM_ASSEMBLER) - -#define ST(n) st ## n -#define ST0 st0 - -#define TBYTE_PTR tword -#define QWORD_PTR qword -#define DWORD_PTR dword -#define WORD_PTR word -#define BYTE_PTR byte - -#define OFFSET - -#define GLOBL GLOBAL -#define ALIGNTEXT32 ALIGN 32 -#define ALIGNTEXT16 ALIGN 16 -#define ALIGNTEXT8 ALIGN 8 -#define ALIGNTEXT4 ALIGN 4 -#define ALIGNTEXT2 ALIGN 2 -#define ALIGNTEXT32ifNOP ALIGN 32 -#define ALIGNTEXT16ifNOP ALIGN 16 -#define ALIGNTEXT8ifNOP ALIGN 8 -#define ALIGNTEXT4ifNOP ALIGN 4 -#define ALIGNDATA32 ALIGN 32 -#define ALIGNDATA16 ALIGN 16 -#define ALIGNDATA8 ALIGN 8 -#define ALIGNDATA4 ALIGN 4 -#define ALIGNDATA2 ALIGN 2 -#define FILE(s) -#define STRING(s) db s -#define D_LONG dd -#define D_WORD dw -#define D_BYTE db -/* #define SPACE */ -/* #define COMM */ -#if defined(__WATCOMC__) -SECTION _TEXT public align=16 class=CODE use32 flat -SECTION _DATA public align=16 class=DATA use32 flat -#define SEG_TEXT SECTION _TEXT -#define SEG_DATA SECTION _DATA -#define SEG_BSS SECTION .bss -#else -#define SEG_DATA SECTION .data -#define SEG_TEXT SECTION .text -#define SEG_BSS SECTION .bss -#endif - -#define D_SPACE(n) db n REP 0 - -#define AS_BEGIN - -/* Jcc's should be handled better than this... */ -#define NEAR near - -#else /* MASM */ - -#define TBYTE_PTR tbyte ptr -#define QWORD_PTR qword ptr -#define DWORD_PTR dword ptr -#define WORD_PTR word ptr -#define BYTE_PTR byte ptr - -#define OFFSET offset - -#define GLOBL GLOBAL -#define ALIGNTEXT32 ALIGN 32 -#define ALIGNTEXT16 ALIGN 16 -#define ALIGNTEXT8 ALIGN 8 -#define ALIGNTEXT4 ALIGN 4 -#define ALIGNTEXT2 ALIGN 2 -#define ALIGNTEXT32ifNOP ALIGN 32 -#define ALIGNTEXT16ifNOP ALIGN 16 -#define ALIGNTEXT8ifNOP ALIGN 8 -#define ALIGNTEXT4ifNOP ALIGN 4 -#define ALIGNDATA32 ALIGN 32 -#define ALIGNDATA16 ALIGN 16 -#define ALIGNDATA8 ALIGN 8 -#define ALIGNDATA4 ALIGN 4 -#define ALIGNDATA2 ALIGN 2 -#define FILE(s) -#define STRING(s) db s -#define D_LONG dd -#define D_WORD dw -#define D_BYTE db -/* #define SPACE */ -/* #define COMM */ -#define SEG_DATA .DATA -#define SEG_TEXT .CODE -#define SEG_BSS .DATA - -#define D_SPACE(n) db n REP 0 - -#define AS_BEGIN - -#define NEAR - -#endif - -#if defined(Lynx) || (defined(SYSV) || defined(SVR4)) \ - || (defined(__linux__) || defined(__OS2ELF__)) && defined(__ELF__) \ - || (defined(__FreeBSD__) && __FreeBSD__ >= 3) \ - || (defined(__NetBSD__) && defined(__ELF__)) -#define GLNAME(a) a -#else -#define GLNAME(a) CONCAT(_, a) -#endif - -/* - * Addressing Modes - */ - -/* Immediate Mode */ -#define P_ADDR(a) OFFSET a -#define X_ADDR(a) OFFSET a -#define D_ADDR(a) OFFSET a -#define L_ADDR(a) OFFSET a -#define W_ADDR(a) OFFSET a -#define B_ADDR(a) OFFSET a - -#define P_CONST(a) a -#define X_CONST(a) a -#define D_CONST(a) a -#define L_CONST(a) a -#define W_CONST(a) a -#define B_CONST(a) a - -/* Indirect Mode */ -#ifdef NASM_ASSEMBLER -#define P_CONTENT(a) [a] -#define X_CONTENT(a) TBYTE_PTR [a] -#define D_CONTENT(a) QWORD_PTR [a] -#define L_CONTENT(a) DWORD_PTR [a] -#define W_CONTENT(a) WORD_PTR [a] -#define B_CONTENT(a) BYTE_PTR [a] -#else -#define P_CONTENT(a) a -#define X_CONTENT(a) TBYTE_PTR a -#define D_CONTENT(a) QWORD_PTR a -#define L_CONTENT(a) DWORD_PTR a -#define W_CONTENT(a) WORD_PTR a -#define B_CONTENT(a) BYTE_PTR a -#endif - -/* Register a indirect */ -#define P_REGIND(a) [a] -#define X_REGIND(a) TBYTE_PTR [a] -#define D_REGIND(a) QWORD_PTR [a] -#define L_REGIND(a) DWORD_PTR [a] -#define W_REGIND(a) WORD_PTR [a] -#define B_REGIND(a) BYTE_PTR [a] - -/* Register b indirect plus displacement a */ -#define P_REGOFF(a, b) [b + a] -#define X_REGOFF(a, b) TBYTE_PTR [b + a] -#define D_REGOFF(a, b) QWORD_PTR [b + a] -#define L_REGOFF(a, b) DWORD_PTR [b + a] -#define W_REGOFF(a, b) WORD_PTR [b + a] -#define B_REGOFF(a, b) BYTE_PTR [b + a] - -/* Reg indirect Base + Index + Displacement - this is mainly for 16-bit mode - * which has no scaling - */ -#define P_REGBID(b, i, d) [b + i + d] -#define X_REGBID(b, i, d) TBYTE_PTR [b + i + d] -#define D_REGBID(b, i, d) QWORD_PTR [b + i + d] -#define L_REGBID(b, i, d) DWORD_PTR [b + i + d] -#define W_REGBID(b, i, d) WORD_PTR [b + i + d] -#define B_REGBID(b, i, d) BYTE_PTR [b + i + d] - -/* Reg indirect Base + (Index * Scale) */ -#define P_REGBIS(b, i, s) [b + i * s] -#define X_REGBIS(b, i, s) TBYTE_PTR [b + i * s] -#define D_REGBIS(b, i, s) QWORD_PTR [b + i * s] -#define L_REGBIS(b, i, s) DWORD_PTR [b + i * s] -#define W_REGBIS(b, i, s) WORD_PTR [b + i * s] -#define B_REGBIS(b, i, s) BYTE_PTR [b + i * s] - -/* Reg indirect Base + (Index * Scale) + Displacement */ -#define P_REGBISD(b, i, s, d) [b + i * s + d] -#define X_REGBISD(b, i, s, d) TBYTE_PTR [b + i * s + d] -#define D_REGBISD(b, i, s, d) QWORD_PTR [b + i * s + d] -#define L_REGBISD(b, i, s, d) DWORD_PTR [b + i * s + d] -#define W_REGBISD(b, i, s, d) WORD_PTR [b + i * s + d] -#define B_REGBISD(b, i, s, d) BYTE_PTR [b + i * s + d] - -/* Displaced Scaled Index: */ -#define P_REGDIS(d, i, s) [i * s + d] -#define X_REGDIS(d, i, s) TBYTE_PTR [i * s + d] -#define D_REGDIS(d, i, s) QWORD_PTR [i * s + d] -#define L_REGDIS(d, i, s) DWORD_PTR [i * s + d] -#define W_REGDIS(d, i, s) WORD_PTR [i * s + d] -#define B_REGDIS(d, i, s) BYTE_PTR [i * s + d] - -/* Indexed Base: */ -#define P_REGBI(b, i) [b + i] -#define X_REGBI(b, i) TBYTE_PTR [b + i] -#define D_REGBI(b, i) QWORD_PTR [b + i] -#define L_REGBI(b, i) DWORD_PTR [b + i] -#define W_REGBI(b, i) WORD_PTR [b + i] -#define B_REGBI(b, i) BYTE_PTR [b + i] - -/* Displaced Base: */ -#define P_REGDB(d, b) [b + d] -#define X_REGDB(d, b) TBYTE_PTR [b + d] -#define D_REGDB(d, b) QWORD_PTR [b + d] -#define L_REGDB(d, b) DWORD_PTR [b + d] -#define W_REGDB(d, b) WORD_PTR [b + d] -#define B_REGDB(d, b) BYTE_PTR [b + d] - -/* Variable indirect: */ -#define VARINDIRECT(var) [var] - -/* Use register contents as jump/call target: */ -#define CODEPTR(reg) P_(reg) - -/* - * Redefine assembler commands - */ - -#define P_(a) P_ ## a -#define X_(a) X_ ## a -#define D_(a) D_ ## a -#define SR_(a) W_ ## a -#define S_(a) L_ ## a -#define L_(a) L_ ## a -#define W_(a) W_ ## a -#define B_(a) B_ ## a - -#define AAA aaa -#define AAD aad -#define AAM aam -#define AAS aas -#define ADC_L(a, b) adc L_(b), L_(a) -#define ADC_W(a, b) adc W_(b), W_(a) -#define ADC_B(a, b) adc B_(b), B_(a) -#define ADD_L(a, b) add L_(b), L_(a) -#define ADD_W(a, b) add W_(b), W_(a) -#define ADD_B(a, b) add B_(b), B_(a) -#define AND_L(a, b) and L_(b), L_(a) -#define AND_W(a, b) and W_(b), W_(a) -#define AND_B(a, b) and B_(b), B_(a) -#define ARPL(a,b) arpl W_(b), a -#define BOUND_L(a, b) bound L_(b), L_(a) -#define BOUND_W(a, b) bound W_(b), W_(a) -#define BSF_L(a, b) bsf L_(b), L_(a) -#define BSF_W(a, b) bsf W_(b), W_(a) -#define BSR_L(a, b) bsr L_(b), L_(a) -#define BSR_W(a, b) bsr W_(b), W_(a) -#define BT_L(a, b) bt L_(b), L_(a) -#define BT_W(a, b) bt W_(b), W_(a) -#define BTC_L(a, b) btc L_(b), L_(a) -#define BTC_W(a, b) btc W_(b), W_(a) -#define BTR_L(a, b) btr L_(b), L_(a) -#define BTR_W(a, b) btr W_(b), W_(a) -#define BTS_L(a, b) bts L_(b), L_(a) -#define BTS_W(a, b) bts W_(b), W_(a) -#define CALL(a) call a -#define CALLF(s,a) call far s:a -#define CBW cbw -#define CWDE cwde -#define CLC clc -#define CLD cld -#define CLI cli -#define CLTS clts -#define CMC cmc -#define CMP_L(a, b) cmp L_(b), L_(a) -#define CMP_W(a, b) cmp W_(b), W_(a) -#define CMP_B(a, b) cmp B_(b), B_(a) -#define CMPS_L cmpsd -#define CMPS_W cmpsw -#define CMPS_B cmpsb -#define CPUID cpuid -#define CWD cwd -#define CDQ cdq -#define DAA daa -#define DAS das -#define DEC_L(a) dec L_(a) -#define DEC_W(a) dec W_(a) -#define DEC_B(a) dec B_(a) -#define DIV_L(a) div L_(a) -#define DIV_W(a) div W_(a) -#define DIV_B(a) div B_(a) -#define ENTER(a,b) enter b, a -#define HLT hlt -#define IDIV_L(a) idiv L_(a) -#define IDIV_W(a) idiv W_(a) -#define IDIV_B(a) idiv B_(a) -#define IMUL_L(a, b) imul L_(b), L_(a) -#define IMUL_W(a, b) imul W_(b), W_(a) -#define IMUL_B(a) imul B_(a) -#define IN_L in EAX, DX -#define IN_W in AX, DX -#define IN_B in AL, DX -#define IN1_L(a) in1 L_(a) -#define IN1_W(a) in1 W_(a) -#define IN1_B(a) in1 B_(a) -#define INC_L(a) inc L_(a) -#define INC_W(a) inc W_(a) -#define INC_B(a) inc B_(a) -#define INS_L ins -#define INS_W ins -#define INS_B ins -#define INT(a) int B_(a) -#define INT3 int3 -#define INTO into -#define IRET iret -#define IRETD iretd -#define JA(a) ja NEAR a -#define JAE(a) jae NEAR a -#define JB(a) jb NEAR a -#define JBE(a) jbe NEAR a -#define JC(a) jc NEAR a -#define JE(a) je NEAR a -#define JG(a) jg NEAR a -#define JGE(a) jge NEAR a -#define JL(a) jl NEAR a -#define JLE(a) jle NEAR a -#define JNA(a) jna NEAR a -#define JNAE(a) jnae NEAR a -#define JNB(a) jnb NEAR a -#define JNBE(a) jnbe NEAR a -#define JNC(a) jnc NEAR a -#define JNE(a) jne NEAR a -#define JNG(a) jng NEAR a -#define JNGE(a) jnge NEAR a -#define JNL(a) jnl NEAR a -#define JNLE(a) jnle NEAR a -#define JNO(a) jno NEAR a -#define JNP(a) jnp NEAR a -#define JNS(a) jns NEAR a -#define JNZ(a) jnz NEAR a -#define JO(a) jo NEAR a -#define JP(a) jp NEAR a -#define JPE(a) jpe NEAR a -#define JPO(a) jpo NEAR a -#define JS(a) js NEAR a -#define JZ(a) jz NEAR a -#define JMP(a) jmp a -#define JMPF(s,a) jmp far s:a -#define LAHF lahf -#define LAR(a, b) lar b, a -#define LEA_L(a, b) lea P_(b), P_(a) -#define LEA_W(a, b) lea P_(b), P_(a) -#define LEAVE leave -#define LGDT(a) lgdt a -#define LIDT(a) lidt a -#define LDS(a, b) lds b, P_(a) -#define LES(a, b) les b, P_(a) -#define LFS(a, b) lfs b, P_(a) -#define LGS(a, b) lgs b, P_(a) -#define LSS(a, b) lss b, P_(a) -#define LLDT(a) lldt a -#define LMSW(a) lmsw a -#define LOCK lock -#define LODS_L lodsd -#define LODS_W lodsw -#define LODS_B lodsb -#define LOOP(a) loop a -#define LOOPE(a) loope a -#define LOOPZ(a) loopz a -#define LOOPNE(a) loopne a -#define LOOPNZ(a) loopnz a -#define LSL(a, b) lsl b, a -#define LTR(a) ltr a -#define MOV_SR(a, b) mov SR_(b), SR_(a) -#define MOV_L(a, b) mov L_(b), L_(a) -#define MOV_W(a, b) mov W_(b), W_(a) -#define MOV_B(a, b) mov B_(b), B_(a) -#define MOVS_L movsd -#define MOVS_W movsw -#define MOVS_B movsb -#define MOVSX_BL(a, b) movsx B_(b), B_(a) -#define MOVSX_BW(a, b) movsx B_(b), B_(a) -#define MOVSX_WL(a, b) movsx W_(b), W_(a) -#define MOVZX_BL(a, b) movzx B_(b), B_(a) -#define MOVZX_BW(a, b) movzx B_(b), B_(a) -#define MOVZX_WL(a, b) movzx W_(b), W_(a) -#define MUL_L(a) mul L_(a) -#define MUL_W(a) mul W_(a) -#define MUL_B(a) mul B_(a) -#define NEG_L(a) neg L_(a) -#define NEG_W(a) neg W_(a) -#define NEG_B(a) neg B_(a) -#define NOP nop -#define NOT_L(a) not L_(a) -#define NOT_W(a) not W_(a) -#define NOT_B(a) not B_(a) -#define OR_L(a,b) or L_(b), L_(a) -#define OR_W(a,b) or W_(b), W_(a) -#define OR_B(a,b) or B_(b), B_(a) -#define OUT_L out DX, EAX -#define OUT_W out DX, AX -#define OUT_B out DX, AL -#define OUT1_L(a) out1 L_(a) -#define OUT1_W(a) out1 W_(a) -#define OUT1_B(a) out1 B_(a) -#define OUTS_L outsd -#define OUTS_W outsw -#define OUTS_B outsb -#define POP_SR(a) pop SR_(a) -#define POP_L(a) pop L_(a) -#define POP_W(a) pop W_(a) -#define POPA_L popad -#define POPA_W popa -#define POPF_L popfd -#define POPF_W popf -#define PUSH_SR(a) push SR_(a) -#define PUSH_L(a) push L_(a) -#define PUSH_W(a) push W_(a) -#define PUSH_B(a) push B_(a) -#define PUSHA_L pushad -#define PUSHA_W pusha -#define PUSHF_L pushfd -#define PUSHF_W pushf -#define RCL_L(a, b) rcl L_(b), L_(a) -#define RCL_W(a, b) rcl W_(b), W_(a) -#define RCL_B(a, b) rcl B_(b), B_(a) -#define RCR_L(a, b) rcr L_(b), L_(a) -#define RCR_W(a, b) rcr W_(b), W_(a) -#define RCR_B(a, b) rcr B_(b), B_(a) -#define RDTSC rdtsc -#define ROL_L(a, b) rol L_(b), L_(a) -#define ROL_W(a, b) rol W_(b), W_(a) -#define ROL_B(a, b) rol B_(b), B_(a) -#define ROR_L(a, b) ror L_(b), L_(a) -#define ROR_W(a, b) ror W_(b), W_(a) -#define ROR_B(a, b) ror B_(b), B_(a) -#define REP rep -#define REPE repe -#define REPNE repne -#define REPNZ REPNE -#define REPZ REPE -#define RET ret -#define SAHF sahf -#define SAL_L(a, b) sal L_(b), B_(a) -#define SAL_W(a, b) sal W_(b), B_(a) -#define SAL_B(a, b) sal B_(b), B_(a) -#define SAR_L(a, b) sar L_(b), B_(a) -#define SAR_W(a, b) sar W_(b), B_(a) -#define SAR_B(a, b) sar B_(b), B_(a) -#define SBB_L(a, b) sbb L_(b), L_(a) -#define SBB_W(a, b) sbb W_(b), W_(a) -#define SBB_B(a, b) sbb B_(b), B_(a) -#define SCAS_L scas -#define SCAS_W scas -#define SCAS_B scas -#define SETA(a) seta a -#define SETAE(a) setae a -#define SETB(a) setb a -#define SETBE(a) setbe a -#define SETC(a) setc a -#define SETE(a) sete a -#define SETG(a) setg a -#define SETGE(a) setge a -#define SETL(a) setl a -#define SETLE(a) setle a -#define SETNA(a) setna a -#define SETNAE(a) setnae a -#define SETNB(a) setnb a -#define SETNBE(a) setnbe a -#define SETNC(a) setnc a -#define SETNE(a) setne a -#define SETNG(a) setng a -#define SETNGE(a) setnge a -#define SETNL(a) setnl a -#define SETNLE(a) setnle a -#define SETNO(a) setno a -#define SETNP(a) setnp a -#define SETNS(a) setns a -#define SETNZ(a) setnz a -#define SETO(a) seto a -#define SETP(a) setp a -#define SETPE(a) setpe a -#define SETPO(a) setpo a -#define SETS(a) sets a -#define SETZ(a) setz a -#define SGDT(a) sgdt a -#define SIDT(a) sidt a -#define SHL_L(a, b) shl L_(b), B_(a) -#define SHL_W(a, b) shl W_(b), B_(a) -#define SHL_B(a, b) shl B_(b), B_(a) -#define SHLD_L(a,b,c) shld -#define SHLD2_L(a,b) shld L_(b), L_(a) -#define SHLD_W(a,b,c) shld -#define SHLD2_W(a,b) shld W_(b), W_(a) -#define SHR_L(a, b) shr L_(b), B_(a) -#define SHR_W(a, b) shr W_(b), B_(a) -#define SHR_B(a, b) shr B_(b), B_(a) -#define SHRD_L(a,b,c) shrd -#define SHRD2_L(a,b) shrd L_(b), L_(a) -#define SHRD_W(a,b,c) shrd -#define SHRD2_W(a,b) shrd W_(b), W_(a) -#define SLDT(a) sldt a -#define SMSW(a) smsw a -#define STC stc -#define STD std -#define STI sti -#define STOS_L stosd -#define STOS_W stosw -#define STOS_B stosb -#define STR(a) str a -#define SUB_L(a, b) sub L_(b), L_(a) -#define SUB_W(a, b) sub W_(b), W_(a) -#define SUB_B(a, b) sub B_(b), B_(a) -#define TEST_L(a, b) test L_(b), L_(a) -#define TEST_W(a, b) test W_(b), W_(a) -#define TEST_B(a, b) test B_(b), B_(a) -#define VERR(a) verr a -#define VERW(a) verw a -#define WAIT wait -#define XCHG_L(a, b) xchg L_(b), L_(a) -#define XCHG_W(a, b) xchg W_(b), W_(a) -#define XCHG_B(a, b) xchg B_(b), B_(a) -#define XLAT xlat -#define XOR_L(a, b) xor L_(b), L_(a) -#define XOR_W(a, b) xor W_(b), W_(a) -#define XOR_B(a, b) xor B_(b), B_(a) - - -/* Floating Point Instructions */ -#define F2XM1 f2xm1 -#define FABS fabs -#define FADD_D(a) fadd D_(a) -#define FADD_S(a) fadd S_(a) -#define FADD2(a, b) fadd b, a -#define FADDP(a, b) faddp b, a -#define FIADD_L(a) fiadd L_(a) -#define FIADD_W(a) fiadd W_(a) -#define FBLD(a) fbld a -#define FBSTP(a) fbstp a -#define FCHS fchs -#define FCLEX fclex -#define FNCLEX fnclex -#define FCOM(a) fcom a -#define FCOM_D(a) fcom D_(a) -#define FCOM_S(a) fcom S_(a) -#define FCOMP(a) fcomp a -#define FCOMP_D(a) fcomp D_(a) -#define FCOMP_S(a) fcomp S_(a) -#define FCOMPP fcompp -#define FCOS fcos -#define FDECSTP fdecstp -#define FDIV_D(a) fdiv D_(a) -#define FDIV_S(a) fdiv S_(a) -#define FDIV2(a, b) fdiv b, a -#define FDIVP(a, b) fdivp b, a -#define FIDIV_L(a) fidiv L_(a) -#define FIDIV_W(a) fidiv W_(a) -#define FDIVR_D(a) fdivr D_(a) -#define FDIVR_S(a) fdivr S_(a) -#define FDIVR2(a, b) fdivr b, a -#define FDIVRP(a, b) fdivrp b, a -#define FIDIVR_L(a) fidivr L_(a) -#define FIDIVR_W(a) fidivr W_(a) -#define FFREE(a) ffree a -#define FICOM_L(a) ficom L_(a) -#define FICOM_W(a) ficom W_(a) -#define FICOMP_L(a) ficomp L_(a) -#define FICOMP_W(a) ficomp W_(a) -#define FILD_Q(a) fild D_(a) -#define FILD_L(a) fild L_(a) -#define FILD_W(a) fild W_(a) -#define FINCSTP fincstp -#define FINIT finit -#define FNINIT fninit -#define FIST_L(a) fist L_(a) -#define FIST_W(a) fist W_(a) -#define FISTP_Q(a) fistp D_(a) -#define FISTP_L(a) fistp L_(a) -#define FISTP_W(a) fistp W_(a) -#define FLD_X(a) fld X_(a) -#define FLD_D(a) fld D_(a) -#define FLD_S(a) fld S_(a) -#define FLD1 fld1 -#define FLDL2T fldl2t -#define FLDL2E fldl2e -#define FLDPI fldpi -#define FLDLG2 fldlg2 -#define FLDLN2 fldln2 -#define FLDZ fldz -#define FLDCW(a) fldcw a -#define FLDENV(a) fldenv a -#define FMUL_S(a) fmul S_(a) -#define FMUL_D(a) fmul D_(a) -#define FMUL2(a, b) fmul b, a -#define FMULP(a, b) fmulp b, a -#define FIMUL_L(a) fimul L_(a) -#define FIMUL_W(a) fimul W_(a) -#define FNOP fnop -#define FPATAN fpatan -#define FPREM fprem -#define FPREM1 fprem1 -#define FPTAN fptan -#define FRNDINT frndint -#define FRSTOR(a) frstor a -#define FSAVE(a) fsave a -#define FNSAVE(a) fnsave a -#define FSCALE fscale -#define FSIN fsin -#define FSINCOS fsincos -#define FSQRT fsqrt -#define FST_D(a) fst D_(a) -#define FST_S(a) fst S_(a) -#define FSTP_X(a) fstp X_(a) -#define FSTP_D(a) fstp D_(a) -#define FSTP_S(a) fstp S_(a) -#define FSTP(a) fstp a -#define FSTCW(a) fstcw a -#define FNSTCW(a) fnstcw a -#define FSTENV(a) fstenv a -#define FNSTENV(a) fnstenv a -#define FSTSW(a) fstsw a -#define FNSTSW(a) fnstsw a -#define FSUB_S(a) fsub S_(a) -#define FSUB_D(a) fsub D_(a) -#define FSUB2(a, b) fsub b, a -#define FSUBP(a, b) fsubp b, a -#define FISUB_L(a) fisub L_(a) -#define FISUB_W(a) fisub W_(a) -#define FSUBR_S(a) fsubr S_(a) -#define FSUBR_D(a) fsubr D_(a) -#define FSUBR2(a, b) fsubr b, a -#define FSUBRP(a, b) fsubrp b, a -#define FISUBR_L(a) fisubr L_(a) -#define FISUBR_W(a) fisubr W_(a) -#define FTST ftst -#define FUCOM(a) fucom a -#define FUCOMP(a) fucomp a -#define FUCOMPP fucompp -#define FWAIT fwait -#define FXAM fxam -#define FXCH(a) fxch a -#define FXTRACT fxtract -#define FYL2X fyl2x -#define FYL2XP1 fyl2xp1 - -#endif /* NASM_ASSEMBLER, MASM_ASSEMBLER */ - - /****************************************/ - /* */ - /* Extensions to x86 insn set - */ - /* MMX, 3DNow! */ - /* */ - /****************************************/ - -#if defined(NASM_ASSEMBLER) || defined(MASM_ASSEMBLER) -#define P_ARG1(a) P_ ## a -#define P_ARG2(a, b) P_ ## b, P_ ## a -#define P_ARG3(a, b, c) P_ ## c, P_ ## b, P_ ## a -#else -#define P_ARG1(a) a -#define P_ARG2(a, b) a, b -#define P_ARG3(a, b, c) a, b, c -#endif - -/* MMX */ -#define MOVD(a, b) movd P_ARG2(a, b) -#define MOVQ(a, b) movq P_ARG2(a, b) - -#define PADDB(a, b) paddb P_ARG2(a, b) -#define PADDW(a, b) paddw P_ARG2(a, b) -#define PADDD(a, b) paddd P_ARG2(a, b) - -#define PADDSB(a, b) paddsb P_ARG2(a, b) -#define PADDSW(a, b) paddsw P_ARG2(a, b) - -#define PADDUSB(a, b) paddusb P_ARG2(a, b) -#define PADDUSW(a, b) paddusw P_ARG2(a, b) - -#define PSUBB(a, b) psubb P_ARG2(a, b) -#define PSUBW(a, b) psubw P_ARG2(a, b) -#define PSUBD(a, b) psubd P_ARG2(a, b) - -#define PSUBSB(a, b) psubsb P_ARG2(a, b) -#define PSUBSW(a, b) psubsw P_ARG2(a, b) - -#define PSUBUSB(a, b) psubusb P_ARG2(a, b) -#define PSUBUSW(a, b) psubusw P_ARG2(a, b) - -#define PCMPEQB(a, b) pcmpeqb P_ARG2(a, b) -#define PCMPEQW(a, b) pcmpeqw P_ARG2(a, b) -#define PCMPEQD(a, b) pcmpeqd P_ARG2(a, b) - -#define PCMPGTB(a, b) pcmpgtb P_ARG2(a, b) -#define PCMPGTW(a, b) pcmpgtw P_ARG2(a, b) -#define PCMPGTD(a, b) pcmpgtd P_ARG2(a, b) - -#define PMULHW(a, b) pmulhw P_ARG2(a, b) -#define PMULLW(a, b) pmullw P_ARG2(a, b) - -#define PMADDWD(a, b) pmaddwd P_ARG2(a, b) - -#define PAND(a, b) pand P_ARG2(a, b) - -#define PANDN(a, b) pandn P_ARG2(a, b) - -#define POR(a, b) por P_ARG2(a, b) - -#define PXOR(a, b) pxor P_ARG2(a, b) - -#define PSRAW(a, b) psraw P_ARG2(a, b) -#define PSRAD(a, b) psrad P_ARG2(a, b) - -#define PSRLW(a, b) psrlw P_ARG2(a, b) -#define PSRLD(a, b) psrld P_ARG2(a, b) -#define PSRLQ(a, b) psrlq P_ARG2(a, b) - -#define PSLLW(a, b) psllw P_ARG2(a, b) -#define PSLLD(a, b) pslld P_ARG2(a, b) -#define PSLLQ(a, b) psllq P_ARG2(a, b) - -#define PACKSSWB(a, b) packsswb P_ARG2(a, b) -#define PACKSSDW(a, b) packssdw P_ARG2(a, b) -#define PACKUSWB(a, b) packuswb P_ARG2(a, b) - -#define PUNPCKHBW(a, b) punpckhbw P_ARG2(a, b) -#define PUNPCKHWD(a, b) punpckhwd P_ARG2(a, b) -#define PUNPCKHDQ(a, b) punpckhdq P_ARG2(a, b) -#define PUNPCKLBW(a, b) punpcklbw P_ARG2(a, b) -#define PUNPCKLWD(a, b) punpcklwd P_ARG2(a, b) -#define PUNPCKLDQ(a, b) punpckldq P_ARG2(a, b) - -#define EMMS emms - -/* AMD 3DNow! */ -#define PAVGUSB(a, b) pavgusb P_ARG2(a, b) -#define PFADD(a, b) pfadd P_ARG2(a, b) -#define PFSUB(a, b) pfsub P_ARG2(a, b) -#define PFSUBR(a, b) pfsubr P_ARG2(a, b) -#define PFACC(a, b) pfacc P_ARG2(a, b) -#define PFCMPGE(a, b) pfcmpge P_ARG2(a, b) -#define PFCMPGT(a, b) pfcmpgt P_ARG2(a, b) -#define PFCMPEQ(a, b) pfcmpeq P_ARG2(a, b) -#define PFMIN(a, b) pfmin P_ARG2(a, b) -#define PFMAX(a, b) pfmax P_ARG2(a, b) -#define PI2FD(a, b) pi2fd P_ARG2(a, b) -#define PF2ID(a, b) pf2id P_ARG2(a, b) -#define PFRCP(a, b) pfrcp P_ARG2(a, b) -#define PFRSQRT(a, b) pfrsqrt P_ARG2(a, b) -#define PFMUL(a, b) pfmul P_ARG2(a, b) -#define PFRCPIT1(a, b) pfrcpit1 P_ARG2(a, b) -#define PFRSQIT1(a, b) pfrsqit1 P_ARG2(a, b) -#define PFRCPIT2(a, b) pfrcpit2 P_ARG2(a, b) -#define PMULHRW(a, b) pmulhrw P_ARG2(a, b) - -#define FEMMS femms -#define PREFETCH(a) prefetch P_ARG1(a) -#define PREFETCHW(a) prefetchw P_ARG1(a) - -/* Intel SSE */ -#define ADDPS(a, b) addps P_ARG2(a, b) -#define ADDSS(a, b) addss P_ARG2(a, b) -#define ANDNPS(a, b) andnps P_ARG2(a, b) -#define ANDPS(a, b) andps P_ARG2(a, b) -/* NASM only knows the pseudo ops for these. -#define CMPPS(a, b, c) cmpps P_ARG3(a, b, c) -#define CMPSS(a, b, c) cmpss P_ARG3(a, b, c) -*/ -#define CMPEQPS(a, b) cmpeqps P_ARG2(a, b) -#define CMPLTPS(a, b) cmpltps P_ARG2(a, b) -#define CMPLEPS(a, b) cmpleps P_ARG2(a, b) -#define CMPUNORDPS(a, b) cmpunordps P_ARG2(a, b) -#define CMPNEQPS(a, b) cmpneqps P_ARG2(a, b) -#define CMPNLTPS(a, b) cmpnltps P_ARG2(a, b) -#define CMPNLEPS(a, b) cmpnleps P_ARG2(a, b) -#define CMPORDPS(a, b) cmpordps P_ARG2(a, b) -#define CMPEQSS(a, b) cmpeqss P_ARG2(a, b) -#define CMPLTSS(a, b) cmpltss P_ARG2(a, b) -#define CMPLESS(a, b) cmpless P_ARG2(a, b) -#define CMPUNORDSS(a, b) cmpunordss P_ARG2(a, b) -#define CMPNEQSS(a, b) cmpneqss P_ARG2(a, b) -#define CMPNLTSS(a, b) cmpnltss P_ARG2(a, b) -#define CMPNLESS(a, b) cmpnless P_ARG2(a, b) -#define CMPORDSS(a, b) cmpordss P_ARG2(a, b) -#define COMISS(a, b) comiss P_ARG2(a, b) -#define CVTPI2PS(a, b) cvtpi2ps P_ARG2(a, b) -#define CVTPS2PI(a, b) cvtps2pi P_ARG2(a, b) -#define CVTSI2SS(a, b) cvtsi2ss P_ARG2(a, b) -#define CVTSS2SI(a, b) cvtss2si P_ARG2(a, b) -#define CVTTPS2PI(a, b) cvttps2pi P_ARG2(a, b) -#define CVTTSS2SI(a, b) cvttss2si P_ARG2(a, b) -#define DIVPS(a, b) divps P_ARG2(a, b) -#define DIVSS(a, b) divss P_ARG2(a, b) -#define FXRSTOR(a) fxrstor P_ARG1(a) -#define FXSAVE(a) fxsave P_ARG1(a) -#define LDMXCSR(a) ldmxcsr P_ARG1(a) -#define MAXPS(a, b) maxps P_ARG2(a, b) -#define MAXSS(a, b) maxss P_ARG2(a, b) -#define MINPS(a, b) minps P_ARG2(a, b) -#define MINSS(a, b) minss P_ARG2(a, b) -#define MOVAPS(a, b) movaps P_ARG2(a, b) -#define MOVHLPS(a, b) movhlps P_ARG2(a, b) -#define MOVHPS(a, b) movhps P_ARG2(a, b) -#define MOVLHPS(a, b) movlhps P_ARG2(a, b) -#define MOVLPS(a, b) movlps P_ARG2(a, b) -#define MOVMSKPS(a, b) movmskps P_ARG2(a, b) -#define MOVNTPS(a, b) movntps P_ARG2(a, b) -#define MOVNTQ(a, b) movntq P_ARG2(a, b) -#define MOVSS(a, b) movss P_ARG2(a, b) -#define MOVUPS(a, b) movups P_ARG2(a, b) -#define MULPS(a, b) mulps P_ARG2(a, b) -#define MULSS(a, b) mulss P_ARG2(a, b) -#define ORPS(a, b) orps P_ARG2(a, b) -#define RCPPS(a, b) rcpps P_ARG2(a, b) -#define RCPSS(a, b) rcpss P_ARG2(a, b) -#define RSQRTPS(a, b) rsqrtps P_ARG2(a, b) -#define RSQRTSS(a, b) rsqrtss P_ARG2(a, b) -#define SHUFPS(a, b, c) shufps P_ARG3(a, b, c) -#define SQRTPS(a, b) sqrtps P_ARG2(a, b) -#define SQRTSS(a, b) sqrtss P_ARG2(a, b) -#define STMXCSR(a) stmxcsr P_ARG1(a) -#define SUBPS(a, b) subps P_ARG2(a, b) -#define UCOMISS(a, b) ucomiss P_ARG2(a, b) -#define UNPCKHPS(a, b) unpckhps P_ARG2(a, b) -#define UNPCKLPS(a, b) unpcklps P_ARG2(a, b) -#define XORPS(a, b) xorps P_ARG2(a, b) - -#define PREFETCHNTA(a) prefetchnta P_ARG1(a) -#define PREFETCHT0(a) prefetcht0 P_ARG1(a) -#define PREFETCHT1(a) prefetcht1 P_ARG1(a) -#define PREFETCHT2(a) prefetcht2 P_ARG1(a) -#define SFENCE sfence - -/* Added by BrianP for FreeBSD (per David Dawes) */ -#if !defined(NASM_ASSEMBLER) && !defined(MASM_ASSEMBLER) && !defined(__bsdi__) -#define LLBL(a) CONCAT(.L,a) -#define LLBL2(a,b) CONCAT3(.L,a,b) -#else -#define LLBL(a) a -#define LLBL2(a,b) CONCAT(a,b) -#endif - -/* Segment overrides */ -#define SEGCS D_BYTE 46 -#define SEGDS D_BYTE 62 -#define SEGES D_BYTE 38 -#define SEGFS D_BYTE 100 -#define SEGGS D_BYTE 101 - -/* Temporary labels: valid until next non-local label */ -#ifdef NASM_ASSEMBLER -#define TLBL(a) CONCAT(.,a) -#else -#define TLBL(a) CONCAT(a,$) -#endif - -/* Hidden symbol visibility support. - * If we build with gcc's -fvisibility=hidden flag, we'll need to change - * the symbol visibility mode to 'default'. - */ -#if defined(GNU_ASSEMBLER) && !defined(__DJGPP__) && !defined(__MINGW32__) && !defined(__APPLE__) -# define HIDDEN(x) .hidden x -#elif defined(__GNUC__) && !defined(__DJGPP__) && !defined(__MINGW32__) && !defined(__APPLE__) -# pragma GCC visibility push(default) -# define HIDDEN(x) .hidden x -#else -# define HIDDEN(x) -#endif - -#endif /* __ASSYNTAX_H__ */ diff --git a/dll/opengl/mesa/x86/clip_args.h b/dll/opengl/mesa/x86/clip_args.h deleted file mode 100644 index 796611fbfd3..00000000000 --- a/dll/opengl/mesa/x86/clip_args.h +++ /dev/null @@ -1,59 +0,0 @@ - -/* - * Mesa 3-D graphics library - * Version: 3.5 - * - * Copyright (C) 1999-2001 Brian Paul All Rights Reserved. - * - * Permission is hereby granted, free of charge, to any person obtaining a - * copy of this software and associated documentation files (the "Software"), - * to deal in the Software without restriction, including without limitation - * the rights to use, copy, modify, merge, publish, distribute, sublicense, - * and/or sell copies of the Software, and to permit persons to whom the - * Software is furnished to do so, subject to the following conditions: - * - * The above copyright notice and this permission notice shall be included - * in all copies or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS - * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL - * BRIAN PAUL BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN - * AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN - * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. - */ - -/* - * Clip test function interface for assembly code. Simply define - * FRAME_OFFSET to the number of bytes pushed onto the stack before - * using the ARG_* argument macros. - * - * Gareth Hughes - */ - -#ifndef __CLIP_ARGS_H__ -#define __CLIP_ARGS_H__ - -/* - * Offsets for clip_func arguments - * - * typedef GLvector4f *(*clip_func)( GLvector4f *clip_vec, - * GLvector4f *proj_vec, - * GLubyte clipMask[], - * GLubyte *orMask, - * GLubyte *andMask ); - */ - -#define OFFSET_SOURCE 4 -#define OFFSET_DEST 8 -#define OFFSET_CLIP 12 -#define OFFSET_OR 16 -#define OFFSET_AND 20 - -#define ARG_SOURCE REGOFF(FRAME_OFFSET+OFFSET_SOURCE, ESP) -#define ARG_DEST REGOFF(FRAME_OFFSET+OFFSET_DEST, ESP) -#define ARG_CLIP REGOFF(FRAME_OFFSET+OFFSET_CLIP, ESP) -#define ARG_OR REGOFF(FRAME_OFFSET+OFFSET_OR, ESP) -#define ARG_AND REGOFF(FRAME_OFFSET+OFFSET_AND, ESP) - -#endif diff --git a/dll/opengl/mesa/x86/common_x86.c b/dll/opengl/mesa/x86/common_x86.c deleted file mode 100644 index 0774263bf67..00000000000 --- a/dll/opengl/mesa/x86/common_x86.c +++ /dev/null @@ -1,317 +0,0 @@ -/* - * Mesa 3-D graphics library - * Version: 6.5.1 - * - * Copyright (C) 1999-2006 Brian Paul All Rights Reserved. - * - * Permission is hereby granted, free of charge, to any person obtaining a - * copy of this software and associated documentation files (the "Software"), - * to deal in the Software without restriction, including without limitation - * the rights to use, copy, modify, merge, publish, distribute, sublicense, - * and/or sell copies of the Software, and to permit persons to whom the - * Software is furnished to do so, subject to the following conditions: - * - * The above copyright notice and this permission notice shall be included - * in all copies or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS - * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL - * BRIAN PAUL BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN - * AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN - * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. - */ - -/** - * \file common_x86.c - * - * Check CPU capabilities & initialize optimized funtions for this particular - * processor. - * - * Changed by Andre Werthmann for using the new SSE functions. - * - * \author Holger Waechtler - * \author Andre Werthmann - */ - -/* XXX these includes should probably go into imports.h or glheader.h */ -#if defined(USE_SSE_ASM) && defined(__linux__) -#include -#endif -#if defined(USE_SSE_ASM) && defined(__FreeBSD__) -#include -#include -#endif -#if defined(USE_SSE_ASM) && defined(__OpenBSD__) -#include -#include -#include -#endif - -#include "main/imports.h" -#include "common_x86_asm.h" - -#include - - -/** Bitmask of X86_FEATURE_x bits */ -int _mesa_x86_cpu_features = 0x0; - -static int detection_debug = GL_FALSE; - -/* No reason for this to be public. - */ -extern GLuint _ASMAPI _mesa_x86_has_cpuid(void); -extern void _ASMAPI _mesa_x86_cpuid(GLuint op, GLuint *reg_eax, GLuint *reg_ebx, GLuint *reg_ecx, GLuint *reg_edx); -extern GLuint _ASMAPI _mesa_x86_cpuid_eax(GLuint op); -extern GLuint _ASMAPI _mesa_x86_cpuid_ebx(GLuint op); -extern GLuint _ASMAPI _mesa_x86_cpuid_ecx(GLuint op); -extern GLuint _ASMAPI _mesa_x86_cpuid_edx(GLuint op); - - -#if defined(USE_SSE_ASM) -/* - * We must verify that the Streaming SIMD Extensions are truly supported - * on this processor before we go ahead and hook out the optimized code. - * - * However, I have been told by Alan Cox that all 2.4 (and later) Linux - * kernels provide full SSE support on all processors that expose SSE via - * the CPUID mechanism. - */ - -/* These are assembly functions: */ -extern void _mesa_test_os_sse_support( void ); -extern void _mesa_test_os_sse_exception_support( void ); - - -/** - * Check if SSE is supported. - * If not, turn off the X86_FEATURE_XMM flag in _mesa_x86_cpu_features. - */ -void _mesa_check_os_sse_support( void ) -{ -#if defined(__FreeBSD__) - { - int ret, enabled; - unsigned int len; - len = sizeof(enabled); - ret = sysctlbyname("hw.instruction_sse", &enabled, &len, NULL, 0); - if (ret || !enabled) - _mesa_x86_cpu_features &= ~(X86_FEATURE_XMM); - } -#elif defined (__NetBSD__) - { - int ret, enabled; - size_t len = sizeof(enabled); - ret = sysctlbyname("machdep.sse", &enabled, &len, (void *)NULL, 0); - if (ret || !enabled) - _mesa_x86_cpu_features &= ~(X86_FEATURE_XMM); - } -#elif defined(__OpenBSD__) - { - int mib[2]; - int ret, enabled; - size_t len = sizeof(enabled); - - mib[0] = CTL_MACHDEP; - mib[1] = CPU_SSE; - - ret = sysctl(mib, 2, &enabled, &len, NULL, 0); - if (ret || !enabled) - _mesa_x86_cpu_features &= ~(X86_FEATURE_XMM); - } -#elif defined(WIN32) - if ( cpu_has_xmm ) { - _mesa_debug(NULL, "Testing OS support for SSE...\n"); - - _SEH2_TRY - { - _mesa_test_os_sse_support(); - } - _SEH2_EXCEPT(EXCEPTION_EXECUTE_HANDLER) - { - if(_SEH2_GetExceptionCode() == EXCEPTION_ILLEGAL_INSTRUCTION) - _mesa_x86_cpu_features &= ~(X86_FEATURE_XMM); - } - _SEH2_END; - - if ( cpu_has_xmm ) { - _mesa_debug(NULL, "Yes.\n"); - } else { - _mesa_debug(NULL, "No!\n"); - } - } - - if ( cpu_has_xmm ) { - _mesa_debug(NULL, "Testing OS support for SSE unmasked exceptions...\n"); - - _SEH2_TRY - { - _mesa_test_os_sse_exception_support(); - } - _SEH2_EXCEPT(EXCEPTION_EXECUTE_HANDLER) - { - if(_SEH2_GetExceptionCode() == EXCEPTION_ILLEGAL_INSTRUCTION) - _mesa_x86_cpu_features &= ~(X86_FEATURE_XMM); - } - _SEH2_END; - - if ( cpu_has_xmm ) { - _mesa_debug(NULL, "Yes.\n"); - } else { - _mesa_debug(NULL, "No!\n"); - } - } - - if ( cpu_has_xmm ) { - _mesa_debug(NULL, "Tests of OS support for SSE passed.\n"); - } else { - _mesa_debug(NULL, "Tests of OS support for SSE failed!\n"); - } -#else - /* Do nothing on other platforms for now. - */ - if (detection_debug) - _mesa_debug(NULL, "Not testing OS support for SSE, leaving enabled.\n"); -#endif /* __FreeBSD__ */ -} - -#endif /* USE_SSE_ASM */ - - -/** - * Initialize the _mesa_x86_cpu_features bitfield. - * This is a no-op if called more than once. - */ -void -_mesa_get_x86_features(void) -{ - static int called = 0; - - if (called) - return; - - called = 1; - -#ifdef USE_X86_ASM - _mesa_x86_cpu_features = 0x0; - - if (_mesa_getenv( "MESA_NO_ASM")) { - return; - } - - if (!_mesa_x86_has_cpuid()) { - _mesa_debug(NULL, "CPUID not detected\n"); - } - else { - GLuint cpu_features; - GLuint cpu_ext_features; - GLuint cpu_ext_info; - char cpu_vendor[13]; - GLuint result; - - /* get vendor name */ - _mesa_x86_cpuid(0, &result, (GLuint *)(cpu_vendor + 0), (GLuint *)(cpu_vendor + 8), (GLuint *)(cpu_vendor + 4)); - cpu_vendor[12] = '\0'; - - if (detection_debug) - _mesa_debug(NULL, "CPU vendor: %s\n", cpu_vendor); - - /* get cpu features */ - cpu_features = _mesa_x86_cpuid_edx(1); - - if (cpu_features & X86_CPU_FPU) - _mesa_x86_cpu_features |= X86_FEATURE_FPU; - if (cpu_features & X86_CPU_CMOV) - _mesa_x86_cpu_features |= X86_FEATURE_CMOV; - -#ifdef USE_MMX_ASM - if (cpu_features & X86_CPU_MMX) - _mesa_x86_cpu_features |= X86_FEATURE_MMX; -#endif - -#ifdef USE_SSE_ASM - if (cpu_features & X86_CPU_XMM) - _mesa_x86_cpu_features |= X86_FEATURE_XMM; - if (cpu_features & X86_CPU_XMM2) - _mesa_x86_cpu_features |= X86_FEATURE_XMM2; -#endif - - /* query extended cpu features */ - if ((cpu_ext_info = _mesa_x86_cpuid_eax(0x80000000)) > 0x80000000) { - if (cpu_ext_info >= 0x80000001) { - - cpu_ext_features = _mesa_x86_cpuid_edx(0x80000001); - - if (cpu_features & X86_CPU_MMX) { - -#ifdef USE_3DNOW_ASM - if (cpu_ext_features & X86_CPUEXT_3DNOW) - _mesa_x86_cpu_features |= X86_FEATURE_3DNOW; - if (cpu_ext_features & X86_CPUEXT_3DNOW_EXT) - _mesa_x86_cpu_features |= X86_FEATURE_3DNOWEXT; -#endif - -#ifdef USE_MMX_ASM - if (cpu_ext_features & X86_CPUEXT_MMX_EXT) - _mesa_x86_cpu_features |= X86_FEATURE_MMXEXT; -#endif - } - } - - /* query cpu name */ - if (cpu_ext_info >= 0x80000002) { - GLuint ofs; - char cpu_name[49]; - for (ofs = 0; ofs < 3; ofs++) - _mesa_x86_cpuid(0x80000002+ofs, (GLuint *)(cpu_name + (16*ofs)+0), (GLuint *)(cpu_name + (16*ofs)+4), (GLuint *)(cpu_name + (16*ofs)+8), (GLuint *)(cpu_name + (16*ofs)+12)); - cpu_name[48] = '\0'; /* the name should be NULL terminated, but just to be sure */ - - if (detection_debug) - _mesa_debug(NULL, "CPU name: %s\n", cpu_name); - } - } - - } - -#ifdef USE_MMX_ASM - if ( cpu_has_mmx ) { - if ( _mesa_getenv( "MESA_NO_MMX" ) == 0 ) { - if (detection_debug) - _mesa_debug(NULL, "MMX cpu detected.\n"); - } else { - _mesa_x86_cpu_features &= ~(X86_FEATURE_MMX); - } - } -#endif - -#ifdef USE_3DNOW_ASM - if ( cpu_has_3dnow ) { - if ( _mesa_getenv( "MESA_NO_3DNOW" ) == 0 ) { - if (detection_debug) - _mesa_debug(NULL, "3DNow! cpu detected.\n"); - } else { - _mesa_x86_cpu_features &= ~(X86_FEATURE_3DNOW); - } - } -#endif - -#ifdef USE_SSE_ASM - if ( cpu_has_xmm ) { - if ( _mesa_getenv( "MESA_NO_SSE" ) == 0 ) { - if (detection_debug) - _mesa_debug(NULL, "SSE cpu detected.\n"); - if ( _mesa_getenv( "MESA_FORCE_SSE" ) == 0 ) { - _mesa_check_os_sse_support(); - } - } else { - _mesa_debug(NULL, "SSE cpu detected, but switched off by user.\n"); - _mesa_x86_cpu_features &= ~(X86_FEATURE_XMM); - } - } -#endif - -#endif /* USE_X86_ASM */ - - (void) detection_debug; -} diff --git a/dll/opengl/mesa/x86/common_x86_asm.S b/dll/opengl/mesa/x86/common_x86_asm.S deleted file mode 100644 index ea4047a0e14..00000000000 --- a/dll/opengl/mesa/x86/common_x86_asm.S +++ /dev/null @@ -1,220 +0,0 @@ -/* - * Mesa 3-D graphics library - * Version: 6.3 - * - * Copyright (C) 1999-2004 Brian Paul All Rights Reserved. - * - * Permission is hereby granted, free of charge, to any person obtaining a - * copy of this software and associated documentation files (the "Software"), - * to deal in the Software without restriction, including without limitation - * the rights to use, copy, modify, merge, publish, distribute, sublicense, - * and/or sell copies of the Software, and to permit persons to whom the - * Software is furnished to do so, subject to the following conditions: - * - * The above copyright notice and this permission notice shall be included - * in all copies or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS - * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL - * BRIAN PAUL BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN - * AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN - * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. - */ - -/* - * Check extended CPU capabilities. Now justs returns the raw CPUID - * feature information, allowing the higher level code to interpret the - * results. - * - * Written by Holger Waechtler - * - * Cleaned up and simplified by Gareth Hughes - * - */ - -/* - * NOTE: Avoid using spaces in between '(' ')' and arguments, especially - * with macros like CONST, LLBL that expand to CONCAT(...). Putting spaces - * in there will break the build on some platforms. - */ - -#include "matypes.h" -#include "assyntax.h" -#include "common_x86_features.h" - - SEG_TEXT - -ALIGNTEXT4 -GLOBL GLNAME(_mesa_x86_has_cpuid) -HIDDEN(_mesa_x86_has_cpuid) -GLNAME(_mesa_x86_has_cpuid): - - /* Test for the CPUID command. If the ID Flag bit in EFLAGS - * (bit 21) is writable, the CPUID command is present */ - PUSHF_L - POP_L (EAX) - MOV_L (EAX, ECX) - XOR_L (CONST(0x00200000), EAX) - PUSH_L (EAX) - POPF_L - PUSHF_L - POP_L (EAX) - - /* Verify the ID Flag bit has been written. */ - CMP_L (ECX, EAX) - SETNE (AL) - XOR_L (CONST(0xff), EAX) - - RET - - -ALIGNTEXT4 -GLOBL GLNAME(_mesa_x86_cpuid) -HIDDEN(_mesa_x86_cpuid) -GLNAME(_mesa_x86_cpuid): - - MOV_L (REGOFF(4, ESP), EAX) /* cpuid op */ - PUSH_L (EDI) - PUSH_L (EBX) - - CPUID - - MOV_L (REGOFF(16, ESP), EDI) /* *eax */ - MOV_L (EAX, REGIND(EDI)) - MOV_L (REGOFF(20, ESP), EDI) /* *ebx */ - MOV_L (EBX, REGIND(EDI)) - MOV_L (REGOFF(24, ESP), EDI) /* *ecx */ - MOV_L (ECX, REGIND(EDI)) - MOV_L (REGOFF(28, ESP), EDI) /* *edx */ - MOV_L (EDX, REGIND(EDI)) - - POP_L (EBX) - POP_L (EDI) - RET - -ALIGNTEXT4 -GLOBL GLNAME(_mesa_x86_cpuid_eax) -HIDDEN(_mesa_x86_cpuid_eax) -GLNAME(_mesa_x86_cpuid_eax): - - MOV_L (REGOFF(4, ESP), EAX) /* cpuid op */ - PUSH_L (EBX) - - CPUID - - POP_L (EBX) - RET - -ALIGNTEXT4 -GLOBL GLNAME(_mesa_x86_cpuid_ebx) -HIDDEN(_mesa_x86_cpuid_ebx) -GLNAME(_mesa_x86_cpuid_ebx): - - MOV_L (REGOFF(4, ESP), EAX) /* cpuid op */ - PUSH_L (EBX) - - CPUID - MOV_L (EBX, EAX) /* return EBX */ - - POP_L (EBX) - RET - -ALIGNTEXT4 -GLOBL GLNAME(_mesa_x86_cpuid_ecx) -HIDDEN(_mesa_x86_cpuid_ecx) -GLNAME(_mesa_x86_cpuid_ecx): - - MOV_L (REGOFF(4, ESP), EAX) /* cpuid op */ - PUSH_L (EBX) - - CPUID - MOV_L (ECX, EAX) /* return ECX */ - - POP_L (EBX) - RET - -ALIGNTEXT4 -GLOBL GLNAME(_mesa_x86_cpuid_edx) -HIDDEN(_mesa_x86_cpuid_edx) -GLNAME(_mesa_x86_cpuid_edx): - - MOV_L (REGOFF(4, ESP), EAX) /* cpuid op */ - PUSH_L (EBX) - - CPUID - MOV_L (EDX, EAX) /* return EDX */ - - POP_L (EBX) - RET - -#ifdef USE_SSE_ASM -/* Execute an SSE instruction to see if the operating system correctly - * supports SSE. A signal handler for SIGILL should have been set - * before calling this function, otherwise this could kill the client - * application. - * - * -----> !!!! ATTENTION DEVELOPERS !!!! <----- - * - * If you're debugging with gdb and you get stopped in this function, - * just type 'continue'! Execution will proceed normally. - * See freedesktop.org bug #1709 for more info. - */ -ALIGNTEXT4 -GLOBL GLNAME( _mesa_test_os_sse_support ) -HIDDEN(_mesa_test_os_sse_support) -GLNAME( _mesa_test_os_sse_support ): - - XORPS ( XMM0, XMM0 ) - - RET - - -/* Perform an SSE divide-by-zero to see if the operating system - * correctly supports unmasked SIMD FPU exceptions. Signal handlers for - * SIGILL and SIGFPE should have been set before calling this function, - * otherwise this could kill the client application. - */ -ALIGNTEXT4 -GLOBL GLNAME( _mesa_test_os_sse_exception_support ) -HIDDEN(_mesa_test_os_sse_exception_support) -GLNAME( _mesa_test_os_sse_exception_support ): - - PUSH_L ( EBP ) - MOV_L ( ESP, EBP ) - SUB_L ( CONST( 8 ), ESP ) - - /* Save the original MXCSR register value. - */ - STMXCSR ( REGOFF( -4, EBP ) ) - - /* Unmask the divide-by-zero exception and perform one. - */ - STMXCSR ( REGOFF( -8, EBP ) ) - AND_L ( CONST( 0xfffffdff ), REGOFF( -8, EBP ) ) - LDMXCSR ( REGOFF( -8, EBP ) ) - - XORPS ( XMM0, XMM0 ) - - PUSH_L ( CONST( 0x3f800000 ) ) - PUSH_L ( CONST( 0x3f800000 ) ) - PUSH_L ( CONST( 0x3f800000 ) ) - PUSH_L ( CONST( 0x3f800000 ) ) - - MOVUPS ( REGIND( ESP ), XMM1 ) - - DIVPS ( XMM0, XMM1 ) - - /* Restore the original MXCSR register value. - */ - LDMXCSR ( REGOFF( -4, EBP ) ) - - LEAVE - RET - -#endif - - -#if defined (__ELF__) && defined (__linux__) - .section .note.GNU-stack,"",%progbits -#endif diff --git a/dll/opengl/mesa/x86/common_x86_asm.h b/dll/opengl/mesa/x86/common_x86_asm.h deleted file mode 100644 index 0d39e3d2308..00000000000 --- a/dll/opengl/mesa/x86/common_x86_asm.h +++ /dev/null @@ -1,53 +0,0 @@ - -/* - * Mesa 3-D graphics library - * Version: 3.5 - * - * Copyright (C) 1999-2001 Brian Paul All Rights Reserved. - * - * Permission is hereby granted, free of charge, to any person obtaining a - * copy of this software and associated documentation files (the "Software"), - * to deal in the Software without restriction, including without limitation - * the rights to use, copy, modify, merge, publish, distribute, sublicense, - * and/or sell copies of the Software, and to permit persons to whom the - * Software is furnished to do so, subject to the following conditions: - * - * The above copyright notice and this permission notice shall be included - * in all copies or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS - * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL - * BRIAN PAUL BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN - * AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN - * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. - */ - -/* - * Check CPU capabilities & initialize optimized funtions for this particular - * processor. - * - * Written by Holger Waechtler - * Changed by Andre Werthmann for using the - * new SSE functions - * - * Reimplemented by Gareth Hughes in a more - * future-proof manner, based on code in the Linux kernel. - */ - -#ifndef __COMMON_X86_ASM_H__ -#define __COMMON_X86_ASM_H__ - -/* Do not reference mtypes.h from this file. - */ -#include "common_x86_features.h" - -extern int _mesa_x86_cpu_features; - -extern void _mesa_get_x86_features(void); - -extern void _mesa_check_os_sse_support(void); - -extern void _mesa_init_all_x86_transform_asm( void ); - -#endif diff --git a/dll/opengl/mesa/x86/common_x86_features.h b/dll/opengl/mesa/x86/common_x86_features.h deleted file mode 100644 index 676af8c1f86..00000000000 --- a/dll/opengl/mesa/x86/common_x86_features.h +++ /dev/null @@ -1,67 +0,0 @@ - -/* - * Mesa 3-D graphics library - * Version: 5.1 - * - * Copyright (C) 1999-2001 Brian Paul All Rights Reserved. - * - * Permission is hereby granted, free of charge, to any person obtaining a - * copy of this software and associated documentation files (the "Software"), - * to deal in the Software without restriction, including without limitation - * the rights to use, copy, modify, merge, publish, distribute, sublicense, - * and/or sell copies of the Software, and to permit persons to whom the - * Software is furnished to do so, subject to the following conditions: - * - * The above copyright notice and this permission notice shall be included - * in all copies or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS - * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL - * BRIAN PAUL BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN - * AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN - * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. - */ - -/* - * x86 CPUID feature information. The raw data is returned by - * _mesa_identify_x86_cpu_features() and interpreted with the cpu_has_* - * helper macros. - * - * Gareth Hughes - */ - -#ifndef __COMMON_X86_FEATURES_H__ -#define __COMMON_X86_FEATURES_H__ - -#define X86_FEATURE_FPU (1<<0) -#define X86_FEATURE_CMOV (1<<1) -#define X86_FEATURE_MMXEXT (1<<2) -#define X86_FEATURE_MMX (1<<3) -#define X86_FEATURE_FXSR (1<<4) -#define X86_FEATURE_XMM (1<<5) -#define X86_FEATURE_XMM2 (1<<6) -#define X86_FEATURE_3DNOWEXT (1<<7) -#define X86_FEATURE_3DNOW (1<<8) - -/* standard X86 CPU features */ -#define X86_CPU_FPU (1<<0) -#define X86_CPU_CMOV (1<<15) -#define X86_CPU_MMX (1<<23) -#define X86_CPU_XMM (1<<25) -#define X86_CPU_XMM2 (1<<26) - -/* extended X86 CPU features */ -#define X86_CPUEXT_MMX_EXT (1<<22) -#define X86_CPUEXT_3DNOW_EXT (1<<30) -#define X86_CPUEXT_3DNOW (1<<31) - -#define cpu_has_mmx (_mesa_x86_cpu_features & X86_FEATURE_MMX) -#define cpu_has_mmxext (_mesa_x86_cpu_features & X86_FEATURE_MMXEXT) -#define cpu_has_xmm (_mesa_x86_cpu_features & X86_FEATURE_XMM) -#define cpu_has_xmm2 (_mesa_x86_cpu_features & X86_FEATURE_XMM2) -#define cpu_has_3dnow (_mesa_x86_cpu_features & X86_FEATURE_3DNOW) -#define cpu_has_3dnowext (_mesa_x86_cpu_features & X86_FEATURE_3DNOWEXT) - -#endif - diff --git a/dll/opengl/mesa/x86/gen_matypes.c b/dll/opengl/mesa/x86/gen_matypes.c deleted file mode 100644 index 9d8a0e8cdb7..00000000000 --- a/dll/opengl/mesa/x86/gen_matypes.c +++ /dev/null @@ -1,239 +0,0 @@ -/* - * Mesa 3-D graphics library - * Version: 6.5.1 - * - * Copyright (C) 1999-2006 Brian Paul All Rights Reserved. - * - * Permission is hereby granted, free of charge, to any person obtaining a - * copy of this software and associated documentation files (the "Software"), - * to deal in the Software without restriction, including without limitation - * the rights to use, copy, modify, merge, publish, distribute, sublicense, - * and/or sell copies of the Software, and to permit persons to whom the - * Software is furnished to do so, subject to the following conditions: - * - * The above copyright notice and this permission notice shall be included - * in all copies or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS - * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL - * BRIAN PAUL BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN - * AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN - * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. - * - * Authors: - * Gareth Hughes - */ - -/* - * This generates an asm version of mtypes.h (called matypes.h), so that - * Mesa's x86 assembly code can access the internal structures easily. - * This will be particularly useful when developing new x86 asm code for - * Mesa, including lighting, clipping, texture image conversion etc. - */ - -#ifndef __STDC_FORMAT_MACROS -#define __STDC_FORMAT_MACROS -#endif -#include - -#include "main/glheader.h" -#include "main/mtypes.h" -#include "tnl/t_context.h" - - -#undef offsetof -#define offsetof( type, member ) ((size_t) &((type *)0)->member) - - -#define OFFSET_HEADER( x ) \ -do { \ - printf( "\n" ); \ - printf( "\n" ); \ - printf( "/* =====================================================" \ - "========\n" ); \ - printf( " * Offsets for %s\n", x ); \ - printf( " */\n" ); \ - printf( "\n" ); \ -} while (0) - -#define DEFINE_HEADER( x ) \ -do { \ - printf( "\n" ); \ - printf( "/*\n" ); \ - printf( " * Flags for %s\n", x ); \ - printf( " */\n" ); \ - printf( "\n" ); \ -} while (0) - -#define OFFSET( s, t, m ) \ - printf( "#define %s\t%lu\n", s, (unsigned long) offsetof( t, m ) ); - -#define SIZEOF( s, t ) \ - printf( "#define %s\t%lu\n", s, (unsigned long) sizeof(t) ); - -#define DEFINE( s, d ) \ - printf( "#define %s\t0x%" PRIx64 "\n", s, (uint64_t) d ); - - - -int main( int argc, char **argv ) -{ - printf( "/*\n" ); - printf( " * This file is automatically generated from the Mesa internal type\n" ); - printf( " * definitions. Do not edit directly.\n" ); - printf( " */\n" ); - printf( "\n" ); - printf( "#ifndef __ASM_TYPES_H__\n" ); - printf( "#define __ASM_TYPES_H__\n" ); - printf( "\n" ); - - - /* struct gl_context offsets: - */ - OFFSET_HEADER( "struct gl_context" ); - - OFFSET( "CTX_DRIVER_CTX ", struct gl_context, DriverCtx ); - printf( "\n" ); - OFFSET( "CTX_LIGHT_ENABLED ", struct gl_context, Light.Enabled ); - OFFSET( "CTX_LIGHT_SHADE_MODEL ", struct gl_context, Light.ShadeModel ); - OFFSET( "CTX_LIGHT_COLOR_MAT_FACE ", struct gl_context, Light.ColorMaterialFace ); - OFFSET( "CTX_LIGHT_COLOR_MAT_MODE ", struct gl_context, Light.ColorMaterialMode ); - OFFSET( "CTX_LIGHT_COLOR_MAT_MASK ", struct gl_context, Light.ColorMaterialBitmask ); - OFFSET( "CTX_LIGHT_COLOR_MAT_ENABLED ", struct gl_context, Light.ColorMaterialEnabled ); - OFFSET( "CTX_LIGHT_ENABLED_LIST ", struct gl_context, Light.EnabledList ); - OFFSET( "CTX_LIGHT_NEED_VERTS ", struct gl_context, Light._NeedVertices ); - OFFSET( "CTX_LIGHT_FLAGS ", struct gl_context, Light._Flags ); - OFFSET( "CTX_LIGHT_BASE_COLOR ", struct gl_context, Light._BaseColor ); - - - /* struct vertex_buffer offsets: - */ - OFFSET_HEADER( "struct vertex_buffer" ); - - OFFSET( "VB_SIZE ", struct vertex_buffer, Size ); - OFFSET( "VB_COUNT ", struct vertex_buffer, Count ); - printf( "\n" ); - OFFSET( "VB_ELTS ", struct vertex_buffer, Elts ); - OFFSET( "VB_OBJ_PTR ", struct vertex_buffer, AttribPtr[_TNL_ATTRIB_POS] ); - OFFSET( "VB_EYE_PTR ", struct vertex_buffer, EyePtr ); - OFFSET( "VB_CLIP_PTR ", struct vertex_buffer, ClipPtr ); - OFFSET( "VB_PROJ_CLIP_PTR ", struct vertex_buffer, NdcPtr ); - OFFSET( "VB_CLIP_OR_MASK ", struct vertex_buffer, ClipOrMask ); - OFFSET( "VB_CLIP_MASK ", struct vertex_buffer, ClipMask ); - OFFSET( "VB_NORMAL_PTR ", struct vertex_buffer, AttribPtr[_TNL_ATTRIB_NORMAL] ); - OFFSET( "VB_EDGE_FLAG ", struct vertex_buffer, EdgeFlag ); - OFFSET( "VB_TEX_COORD_PTR ", struct vertex_buffer, AttribPtr[_TNL_ATTRIB_TEX] ); - OFFSET( "VB_INDEX_PTR ", struct vertex_buffer, AttribPtr[_TNL_ATTRIB_COLOR_INDEX] ); - OFFSET( "VB_COLOR_PTR ", struct vertex_buffer, AttribPtr[_TNL_ATTRIB_COLOR0] ); - OFFSET( "VB_SECONDARY_COLOR_PTR ", struct vertex_buffer, AttribPtr[_TNL_ATTRIB_COLOR1] ); - OFFSET( "VB_FOG_COORD_PTR ", struct vertex_buffer, AttribPtr[_TNL_ATTRIB_FOG] ); - OFFSET( "VB_PRIMITIVE ", struct vertex_buffer, Primitive ); - printf( "\n" ); - - DEFINE_HEADER( "struct vertex_buffer" ); - - /* XXX use new labels here someday after vertex proram is done */ - DEFINE( "VERT_BIT_OBJ ", VERT_BIT_POS ); - DEFINE( "VERT_BIT_NORM ", VERT_BIT_NORMAL ); - DEFINE( "VERT_BIT_RGBA ", VERT_BIT_COLOR0 ); - DEFINE( "VERT_BIT_SPEC_RGB ", VERT_BIT_COLOR1 ); - DEFINE( "VERT_BIT_FOG_COORD ", VERT_BIT_FOG ); - DEFINE( "VERT_BIT_TEX0 ", VERT_BIT_TEX0 ); - DEFINE( "VERT_BIT_TEX1 ", VERT_BIT_TEX1 ); - DEFINE( "VERT_BIT_TEX2 ", VERT_BIT_TEX2 ); - DEFINE( "VERT_BIT_TEX3 ", VERT_BIT_TEX3 ); - - - /* GLvector4f offsets: - */ - OFFSET_HEADER( "GLvector4f" ); - - OFFSET( "V4F_DATA ", GLvector4f, data ); - OFFSET( "V4F_START ", GLvector4f, start ); - OFFSET( "V4F_COUNT ", GLvector4f, count ); - OFFSET( "V4F_STRIDE ", GLvector4f, stride ); - OFFSET( "V4F_SIZE ", GLvector4f, size ); - OFFSET( "V4F_FLAGS ", GLvector4f, flags ); - - DEFINE_HEADER( "GLvector4f" ); - - DEFINE( "VEC_MALLOC ", VEC_MALLOC ); - DEFINE( "VEC_NOT_WRITEABLE ", VEC_NOT_WRITEABLE ); - DEFINE( "VEC_BAD_STRIDE ", VEC_BAD_STRIDE ); - printf( "\n" ); - DEFINE( "VEC_SIZE_1 ", VEC_SIZE_1 ); - DEFINE( "VEC_SIZE_2 ", VEC_SIZE_2 ); - DEFINE( "VEC_SIZE_3 ", VEC_SIZE_3 ); - DEFINE( "VEC_SIZE_4 ", VEC_SIZE_4 ); - - - /* GLmatrix offsets: - */ - OFFSET_HEADER( "GLmatrix" ); - - OFFSET( "MATRIX_DATA ", GLmatrix, m ); - OFFSET( "MATRIX_INV ", GLmatrix, inv ); - OFFSET( "MATRIX_FLAGS ", GLmatrix, flags ); - OFFSET( "MATRIX_TYPE ", GLmatrix, type ); - - - /* struct gl_light offsets: - */ - OFFSET_HEADER( "struct gl_light" ); - - OFFSET( "LIGHT_NEXT ", struct gl_light, next ); - OFFSET( "LIGHT_PREV ", struct gl_light, prev ); - printf( "\n" ); - OFFSET( "LIGHT_AMBIENT ", struct gl_light, Ambient ); - OFFSET( "LIGHT_DIFFUSE ", struct gl_light, Diffuse ); - OFFSET( "LIGHT_SPECULAR ", struct gl_light, Specular ); - OFFSET( "LIGHT_EYE_POSITION ", struct gl_light, EyePosition ); - OFFSET( "LIGHT_SPOT_DIRECTION ", struct gl_light, SpotDirection ); - OFFSET( "LIGHT_SPOT_EXPONENT ", struct gl_light, SpotExponent ); - OFFSET( "LIGHT_SPOT_CUTOFF ", struct gl_light, SpotCutoff ); - OFFSET( "LIGHT_COS_CUTOFF ", struct gl_light, _CosCutoff ); - OFFSET( "LIGHT_CONST_ATTEN ", struct gl_light, ConstantAttenuation ); - OFFSET( "LIGHT_LINEAR_ATTEN ", struct gl_light, LinearAttenuation ); - OFFSET( "LIGHT_QUADRATIC_ATTEN ", struct gl_light, QuadraticAttenuation ); - OFFSET( "LIGHT_ENABLED ", struct gl_light, Enabled ); - printf( "\n" ); - OFFSET( "LIGHT_FLAGS ", struct gl_light, _Flags ); - printf( "\n" ); - OFFSET( "LIGHT_POSITION ", struct gl_light, _Position ); - OFFSET( "LIGHT_VP_INF_NORM ", struct gl_light, _VP_inf_norm ); - OFFSET( "LIGHT_H_INF_NORM ", struct gl_light, _h_inf_norm ); - OFFSET( "LIGHT_NORM_DIRECTION ", struct gl_light, _NormSpotDirection ); - OFFSET( "LIGHT_VP_INF_SPOT_ATTEN ", struct gl_light, _VP_inf_spot_attenuation ); - printf( "\n" ); - OFFSET( "LIGHT_SPOT_EXP_TABLE ", struct gl_light, _SpotExpTable ); - OFFSET( "LIGHT_MAT_AMBIENT ", struct gl_light, _MatAmbient ); - OFFSET( "LIGHT_MAT_DIFFUSE ", struct gl_light, _MatDiffuse ); - OFFSET( "LIGHT_MAT_SPECULAR ", struct gl_light, _MatSpecular ); - printf( "\n" ); - SIZEOF( "SIZEOF_GL_LIGHT ", struct gl_light ); - - DEFINE_HEADER( "struct gl_light" ); - - DEFINE( "LIGHT_SPOT ", LIGHT_SPOT ); - DEFINE( "LIGHT_LOCAL_VIEWER ", LIGHT_LOCAL_VIEWER ); - DEFINE( "LIGHT_POSITIONAL ", LIGHT_POSITIONAL ); - printf( "\n" ); - DEFINE( "LIGHT_NEED_VERTICES ", LIGHT_NEED_VERTICES ); - - - /* struct gl_lightmodel offsets: - */ - OFFSET_HEADER( "struct gl_lightmodel" ); - - OFFSET( "LIGHT_MODEL_AMBIENT ", struct gl_lightmodel, Ambient ); - OFFSET( "LIGHT_MODEL_LOCAL_VIEWER ", struct gl_lightmodel, LocalViewer ); - OFFSET( "LIGHT_MODEL_TWO_SIDE ", struct gl_lightmodel, TwoSide ); - - - printf( "\n" ); - printf( "\n" ); - printf( "#endif /* __ASM_TYPES_H__ */\n" ); - - return 0; -} diff --git a/dll/opengl/mesa/x86/matypes.h b/dll/opengl/mesa/x86/matypes.h deleted file mode 100644 index a3855f7ff46..00000000000 --- a/dll/opengl/mesa/x86/matypes.h +++ /dev/null @@ -1,162 +0,0 @@ -/* - * This file is automatically generated from the Mesa internal type - * definitions. Do not edit directly. - */ - -#ifndef __ASM_TYPES_H__ -#define __ASM_TYPES_H__ - - - -/* ============================================================= - * Offsets for struct gl_context - */ - -#define CTX_DRIVER_CTX 880 - -#define CTX_LIGHT_ENABLED 39952 -#define CTX_LIGHT_SHADE_MODEL 39956 -#define CTX_LIGHT_COLOR_MAT_FACE 39964 -#define CTX_LIGHT_COLOR_MAT_MODE 39968 -#define CTX_LIGHT_COLOR_MAT_MASK 39972 -#define CTX_LIGHT_COLOR_MAT_ENABLED 39976 -#define CTX_LIGHT_ENABLED_LIST 39988 -#define CTX_LIGHT_NEED_VERTS 44341 -#define CTX_LIGHT_FLAGS 44344 -#define CTX_LIGHT_BASE_COLOR 44348 - - -/* ============================================================= - * Offsets for struct vertex_buffer - */ - -#define VB_SIZE 0 -#define VB_COUNT 4 - -#define VB_ELTS 8 -#define VB_OBJ_PTR 60 -#define VB_EYE_PTR 12 -#define VB_CLIP_PTR 16 -#define VB_PROJ_CLIP_PTR 20 -#define VB_CLIP_OR_MASK 24 -#define VB_CLIP_MASK 28 -#define VB_NORMAL_PTR 68 -#define VB_EDGE_FLAG 36 -#define VB_TEX0_COORD_PTR 92 -#define VB_TEX1_COORD_PTR 96 -#define VB_TEX2_COORD_PTR 100 -#define VB_TEX3_COORD_PTR 104 -#define VB_INDEX_PTR 84 -#define VB_COLOR_PTR 72 -#define VB_SECONDARY_COLOR_PTR 76 -#define VB_FOG_COORD_PTR 80 -#define VB_PRIMITIVE 52 - - -/* - * Flags for struct vertex_buffer - */ - -#define VERT_BIT_OBJ 0x1 -#define VERT_BIT_NORM 0x4 -#define VERT_BIT_RGBA 0x8 -#define VERT_BIT_SPEC_RGB 0x10 -#define VERT_BIT_FOG_COORD 0x20 -#define VERT_BIT_TEX0 0x100 -#define VERT_BIT_TEX1 0x200 -#define VERT_BIT_TEX2 0x400 -#define VERT_BIT_TEX3 0x800 - - -/* ============================================================= - * Offsets for GLvector4f - */ - -#define V4F_DATA 0 -#define V4F_START 4 -#define V4F_COUNT 8 -#define V4F_STRIDE 12 -#define V4F_SIZE 16 -#define V4F_FLAGS 20 - -/* - * Flags for GLvector4f - */ - -#define VEC_MALLOC 0x10 -#define VEC_NOT_WRITEABLE 0x40 -#define VEC_BAD_STRIDE 0x100 - -#define VEC_SIZE_1 0x1 -#define VEC_SIZE_2 0x3 -#define VEC_SIZE_3 0x7 -#define VEC_SIZE_4 0xf - - -/* ============================================================= - * Offsets for GLmatrix - */ - -#define MATRIX_DATA 0 -#define MATRIX_INV 4 -#define MATRIX_FLAGS 8 -#define MATRIX_TYPE 12 - - -/* ============================================================= - * Offsets for struct gl_light - */ - -#define LIGHT_NEXT 0 -#define LIGHT_PREV 4 - -#define LIGHT_AMBIENT 8 -#define LIGHT_DIFFUSE 24 -#define LIGHT_SPECULAR 40 -#define LIGHT_EYE_POSITION 56 -#define LIGHT_SPOT_DIRECTION 72 -#define LIGHT_SPOT_EXPONENT 88 -#define LIGHT_SPOT_CUTOFF 92 -#define LIGHT_COS_CUTOFF 100 -#define LIGHT_CONST_ATTEN 104 -#define LIGHT_LINEAR_ATTEN 108 -#define LIGHT_QUADRATIC_ATTEN 112 -#define LIGHT_ENABLED 116 - -#define LIGHT_FLAGS 120 - -#define LIGHT_POSITION 124 -#define LIGHT_VP_INF_NORM 140 -#define LIGHT_H_INF_NORM 152 -#define LIGHT_NORM_DIRECTION 164 -#define LIGHT_VP_INF_SPOT_ATTEN 180 - -#define LIGHT_SPOT_EXP_TABLE 184 -#define LIGHT_MAT_AMBIENT 4280 -#define LIGHT_MAT_DIFFUSE 4304 -#define LIGHT_MAT_SPECULAR 4328 - -#define SIZEOF_GL_LIGHT 4352 - -/* - * Flags for struct gl_light - */ - -#define LIGHT_SPOT 0x1 -#define LIGHT_LOCAL_VIEWER 0x2 -#define LIGHT_POSITIONAL 0x4 - -#define LIGHT_NEED_VERTICES 0x6 - - -/* ============================================================= - * Offsets for struct gl_lightmodel - */ - -#define LIGHT_MODEL_AMBIENT 0 -#define LIGHT_MODEL_LOCAL_VIEWER 16 -#define LIGHT_MODEL_TWO_SIDE 17 -#define LIGHT_MODEL_COLOR_CONTROL 20 - - -#endif /* __ASM_TYPES_H__ */ diff --git a/dll/opengl/mesa/x86/mmx.h b/dll/opengl/mesa/x86/mmx.h deleted file mode 100644 index 53a63f321c9..00000000000 --- a/dll/opengl/mesa/x86/mmx.h +++ /dev/null @@ -1,49 +0,0 @@ -/* - * Mesa 3-D graphics library - * Version: 6.5.2 - * - * Copyright (C) 1999-2006 Brian Paul All Rights Reserved. - * - * Permission is hereby granted, free of charge, to any person obtaining a - * copy of this software and associated documentation files (the "Software"), - * to deal in the Software without restriction, including without limitation - * the rights to use, copy, modify, merge, publish, distribute, sublicense, - * and/or sell copies of the Software, and to permit persons to whom the - * Software is furnished to do so, subject to the following conditions: - * - * The above copyright notice and this permission notice shall be included - * in all copies or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS - * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL - * BRIAN PAUL BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN - * AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN - * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. - */ - - -#ifndef ASM_MMX_H -#define ASM_MMX_H - -#include "main/compiler.h" -#include "main/glheader.h" - -struct gl_context; - -extern void _ASMAPI -_mesa_mmx_blend_transparency( struct gl_context *ctx, GLuint n, const GLubyte mask[], - GLvoid *rgba, const GLvoid *dest, - GLenum chanType ); - -extern void _ASMAPI -_mesa_mmx_blend_add( struct gl_context *ctx, GLuint n, const GLubyte mask[], - GLvoid *rgba, const GLvoid *dest, - GLenum chanType ); - -extern void _ASMAPI -_mesa_mmx_blend_modulate( struct gl_context *ctx, GLuint n, const GLubyte mask[], - GLvoid *rgba, const GLvoid *dest, - GLenum chanType ); - -#endif diff --git a/dll/opengl/mesa/x86/mmx_blend.S b/dll/opengl/mesa/x86/mmx_blend.S deleted file mode 100644 index 1831f220107..00000000000 --- a/dll/opengl/mesa/x86/mmx_blend.S +++ /dev/null @@ -1,338 +0,0 @@ - ; -/* - * Written by Jos� Fonseca - */ - - -#ifdef USE_MMX_ASM -#include "assyntax.h" -#include "matypes.h" - -/* integer multiplication - alpha plus one - * - * makes the following approximation to the division (Sree) - * - * rgb*a/255 ~= (rgb*(a+1)) >> 256 - * - * which is the fastest method that satisfies the following OpenGL criteria - * - * 0*0 = 0 and 255*255 = 255 - * - * note that MX1 is a register with 0xffffffffffffffff constant which can be easily obtained making - * - * PCMPEQW ( MX1, MX1 ) - */ -#define GMB_MULT_AP1( MP1, MA1, MP2, MA2, MX1 ) \ - PSUBW ( MX1, MA1 ) /* a1 + 1 | a1 + 1 | a1 + 1 | a1 + 1 */ ;\ - PMULLW ( MP1, MA1 ) /* t1 = p1*a1 */ ;\ - ;\ -TWO(PSUBW ( MX1, MA2 )) /* a2 + 1 | a2 + 1 | a2 + 1 | a2 + 1 */ ;\ -TWO(PMULLW ( MP2, MA2 )) /* t2 = p2*a2 */ ;\ - ;\ - PSRLW ( CONST(8), MA1 ) /* t1 >> 8 ~= t1/255 */ ;\ -TWO(PSRLW ( CONST(8), MA2 )) /* t2 >> 8 ~= t2/255 */ - - -/* integer multiplication - geometric series - * - * takes the geometric series approximation to the division - * - * t/255 = (t >> 8) + (t >> 16) + (t >> 24) .. - * - * in this case just the first two terms to fit in 16bit arithmetic - * - * t/255 ~= (t + (t >> 8)) >> 8 - * - * note that just by itself it doesn't satisfies the OpenGL criteria, as 255*255 = 254, - * so the special case a = 255 must be accounted or roundoff must be used - */ -#define GMB_MULT_GS( MP1, MA1, MP2, MA2 ) \ - PMULLW ( MP1, MA1 ) /* t1 = p1*a1 */ ;\ -TWO(PMULLW ( MP2, MA2 )) /* t2 = p2*a2 */ ;\ - ;\ - MOVQ ( MA1, MP1 ) ;\ - PSRLW ( CONST(8), MA1 ) /* t1 >> 8 */ ;\ - ;\ -TWO(MOVQ ( MA2, MP2 )) ;\ -TWO(PSRLW ( CONST(8), MA2 )) /* t2 >> 8 */ ;\ - ;\ - PADDW ( MP1, MA1 ) /* t1 + (t1 >> 8) ~= (t1/255) << 8 */ ;\ - PSRLW ( CONST(8), MA1 ) /* sa1 | sb1 | sg1 | sr1 */ ;\ - ;\ -TWO(PADDW ( MP2, MA2 )) /* t2 + (t2 >> 8) ~= (t2/255) << 8 */ ;\ -TWO(PSRLW ( CONST(8), MA2 )) /* sa2 | sb2 | sg2 | sr2 */ - - -/* integer multiplication - geometric series plus rounding - * - * when using a geometric series division instead of truncating the result - * use roundoff in the approximation (Jim Blinn) - * - * t = rgb*a + 0x80 - * - * achieving the exact results - * - * note that M80 is register with the 0x0080008000800080 constant - */ -#define GMB_MULT_GSR( MP1, MA1, MP2, MA2, M80 ) \ - PMULLW ( MP1, MA1 ) /* t1 = p1*a1 */ ;\ - PADDW ( M80, MA1 ) /* t1 += 0x80 */ ;\ - ;\ -TWO(PMULLW ( MP2, MA2 )) /* t2 = p2*a2 */ ;\ -TWO(PADDW ( M80, MA2 )) /* t2 += 0x80 */ ;\ - ;\ - MOVQ ( MA1, MP1 ) ;\ - PSRLW ( CONST(8), MA1 ) /* t1 >> 8 */ ;\ - ;\ -TWO(MOVQ ( MA2, MP2 )) ;\ -TWO(PSRLW ( CONST(8), MA2 )) /* t2 >> 8 */ ;\ - ;\ - PADDW ( MP1, MA1 ) /* t1 + (t1 >> 8) ~= (t1/255) << 8 */ ;\ - PSRLW ( CONST(8), MA1 ) /* sa1 | sb1 | sg1 | sr1 */ ;\ - ;\ -TWO(PADDW ( MP2, MA2 )) /* t2 + (t2 >> 8) ~= (t2/255) << 8 */ ;\ -TWO(PSRLW ( CONST(8), MA2 )) /* sa2 | sb2 | sg2 | sr2 */ - - -/* linear interpolation - geometric series - */ -#define GMB_LERP_GS( MP1, MQ1, MA1, MP2, MQ2, MA2) \ - PSUBW ( MQ1, MP1 ) /* pa1 - qa1 | pb1 - qb1 | pg1 - qg1 | pr1 - qr1 */ ;\ - PSLLW ( CONST(8), MQ1 ) /* q1 << 8 */ ;\ - PMULLW ( MP1, MA1 ) /* t1 = (q1 - p1)*pa1 */ ;\ - ;\ -TWO(PSUBW ( MQ2, MP2 )) /* pa2 - qa2 | pb2 - qb2 | pg2 - qg2 | pr2 - qr2 */ ;\ -TWO(PSLLW ( CONST(8), MQ2 )) /* q2 << 8 */ ;\ -TWO(PMULLW ( MP2, MA2 )) /* t2 = (q2 - p2)*pa2 */ ;\ - ;\ - MOVQ ( MA1, MP1 ) ;\ - PSRLW ( CONST(8), MA1 ) /* t1 >> 8 */ ;\ - ;\ -TWO(MOVQ ( MA2, MP2 )) ;\ -TWO(PSRLW ( CONST(8), MA2 )) /* t2 >> 8 */ ;\ - ;\ - PADDW ( MP1, MA1 ) /* t1 + (t1 >> 8) ~= (t1/255) << 8 */ ;\ -TWO(PADDW ( MP2, MA2 )) /* t2 + (t2 >> 8) ~= (t2/255) << 8 */ ;\ - ;\ - PADDW ( MQ1, MA1 ) /* (t1/255 + q1) << 8 */ ;\ -TWO(PADDW ( MQ2, MA2 )) /* (t2/255 + q2) << 8 */ ;\ - ;\ - PSRLW ( CONST(8), MA1 ) /* sa1 | sb1 | sg1 | sr1 */ ;\ -TWO(PSRLW ( CONST(8), MA2 )) /* sa2 | sb2 | sg2 | sr2 */ - - -/* linear interpolation - geometric series with roundoff - * - * this is a generalization of Blinn's formula to signed arithmetic - * - * note that M80 is a register with the 0x0080008000800080 constant - */ -#define GMB_LERP_GSR( MP1, MQ1, MA1, MP2, MQ2, MA2, M80) \ - PSUBW ( MQ1, MP1 ) /* pa1 - qa1 | pb1 - qb1 | pg1 - qg1 | pr1 - qr1 */ ;\ - PSLLW ( CONST(8), MQ1 ) /* q1 << 8 */ ;\ - PMULLW ( MP1, MA1 ) /* t1 = (q1 - p1)*pa1 */ ;\ - ;\ -TWO(PSUBW ( MQ2, MP2 )) /* pa2 - qa2 | pb2 - qb2 | pg2 - qg2 | pr2 - qr2 */ ;\ -TWO(PSLLW ( CONST(8), MQ2 )) /* q2 << 8 */ ;\ -TWO(PMULLW ( MP2, MA2 )) /* t2 = (q2 - p2)*pa2 */ ;\ - ;\ - PSRLW ( CONST(15), MP1 ) /* q1 > p1 ? 1 : 0 */ ;\ -TWO(PSRLW ( CONST(15), MP2 )) /* q2 > q2 ? 1 : 0 */ ;\ - ;\ - PSLLW ( CONST(8), MP1 ) /* q1 > p1 ? 0x100 : 0 */ ;\ -TWO(PSLLW ( CONST(8), MP2 )) /* q2 > q2 ? 0x100 : 0 */ ;\ - ;\ - PSUBW ( MP1, MA1 ) /* t1 -=? 0x100 */ ;\ -TWO(PSUBW ( MP2, MA2 )) /* t2 -=? 0x100 */ ;\ - ;\ - PADDW ( M80, MA1 ) /* t1 += 0x80 */ ;\ -TWO(PADDW ( M80, MA2 )) /* t2 += 0x80 */ ;\ - ;\ - MOVQ ( MA1, MP1 ) ;\ - PSRLW ( CONST(8), MA1 ) /* t1 >> 8 */ ;\ - ;\ -TWO(MOVQ ( MA2, MP2 )) ;\ -TWO(PSRLW ( CONST(8), MA2 )) /* t2 >> 8 */ ;\ - ;\ - PADDW ( MP1, MA1 ) /* t1 + (t1 >> 8) ~= (t1/255) << 8 */ ;\ -TWO(PADDW ( MP2, MA2 )) /* t2 + (t2 >> 8) ~= (t2/255) << 8 */ ;\ - ;\ - PADDW ( MQ1, MA1 ) /* (t1/255 + q1) << 8 */ ;\ -TWO(PADDW ( MQ2, MA2 )) /* (t2/255 + q2) << 8 */ ;\ - ;\ - PSRLW ( CONST(8), MA1 ) /* sa1 | sb1 | sg1 | sr1 */ ;\ -TWO(PSRLW ( CONST(8), MA2 )) /* sa2 | sb2 | sg2 | sr2 */ - - -/* linear interpolation - geometric series with correction - * - * instead of the roundoff this adds a small correction to satisfy the OpenGL criteria - * - * t/255 ~= (t + (t >> 8) + (t >> 15)) >> 8 - * - * note that although is faster than rounding off it doesn't give always the exact results - */ -#define GMB_LERP_GSC( MP1, MQ1, MA1, MP2, MQ2, MA2) \ - PSUBW ( MQ1, MP1 ) /* pa1 - qa1 | pb1 - qb1 | pg1 - qg1 | pr1 - qr1 */ ;\ - PSLLW ( CONST(8), MQ1 ) /* q1 << 8 */ ;\ - PMULLW ( MP1, MA1 ) /* t1 = (q1 - p1)*pa1 */ ;\ - ;\ -TWO(PSUBW ( MQ2, MP2 )) /* pa2 - qa2 | pb2 - qb2 | pg2 - qg2 | pr2 - qr2 */ ;\ -TWO(PSLLW ( CONST(8), MQ2 )) /* q2 << 8 */ ;\ -TWO(PMULLW ( MP2, MA2 )) /* t2 = (q2 - p2)*pa2 */ ;\ - ;\ - MOVQ ( MA1, MP1 ) ;\ - PSRLW ( CONST(8), MA1 ) /* t1 >> 8 */ ;\ - ;\ -TWO(MOVQ ( MA2, MP2 )) ;\ -TWO(PSRLW ( CONST(8), MA2 )) /* t2 >> 8 */ ;\ - ;\ - PADDW ( MA1, MP1 ) /* t1 + (t1 >> 8) ~= (t1/255) << 8 */ ;\ - PSRLW ( CONST(7), MA1 ) /* t1 >> 15 */ ;\ - ;\ -TWO(PADDW ( MA2, MP2 )) /* t2 + (t2 >> 8) ~= (t2/255) << 8 */ ;\ -TWO(PSRLW ( CONST(7), MA2 )) /* t2 >> 15 */ ;\ - ;\ - PADDW ( MP1, MA1 ) /* t1 + (t1 >> 8) + (t1 >>15) ~= (t1/255) << 8 */ ;\ -TWO(PADDW ( MP2, MA2 )) /* t2 + (t2 >> 8) + (t2 >>15) ~= (t2/255) << 8 */ ;\ - ;\ - PADDW ( MQ1, MA1 ) /* (t1/255 + q1) << 8 */ ;\ -TWO(PADDW ( MQ2, MA2 )) /* (t2/255 + q2) << 8 */ ;\ - ;\ - PSRLW ( CONST(8), MA1 ) /* sa1 | sb1 | sg1 | sr1 */ ;\ -TWO(PSRLW ( CONST(8), MA2 )) /* sa2 | sb2 | sg2 | sr2 */ - - -/* common blending setup code - * - * note that M00 is a register with 0x0000000000000000 constant which can be easily obtained making - * - * PXOR ( M00, M00 ) - */ -#define GMB_LOAD(rgba, dest, MPP, MQQ) \ -ONE(MOVD ( REGIND(rgba), MPP )) /* | | | | qa1 | qb1 | qg1 | qr1 */ ;\ -ONE(MOVD ( REGIND(dest), MQQ )) /* | | | | pa1 | pb1 | pg1 | pr1 */ ;\ - ;\ -TWO(MOVQ ( REGIND(rgba), MPP )) /* qa2 | qb2 | qg2 | qr2 | qa1 | qb1 | qg1 | qr1 */ ;\ -TWO(MOVQ ( REGIND(dest), MQQ )) /* pa2 | pb2 | pg2 | pr2 | pa1 | pb1 | pg1 | pr1 */ - -#define GMB_UNPACK(MP1, MQ1, MP2, MQ2, M00) \ -TWO(MOVQ ( MP1, MP2 )) ;\ -TWO(MOVQ ( MQ1, MQ2 )) ;\ - ;\ - PUNPCKLBW ( M00, MQ1 ) /* qa1 | qb1 | qg1 | qr1 */ ;\ -TWO(PUNPCKHBW ( M00, MQ2 )) /* qa2 | qb2 | qg2 | qr2 */ ;\ - PUNPCKLBW ( M00, MP1 ) /* pa1 | pb1 | pg1 | pr1 */ ;\ -TWO(PUNPCKHBW ( M00, MP2 )) /* pa2 | pb2 | pg2 | pr2 */ - -#define GMB_ALPHA(MP1, MA1, MP2, MA2) \ - MOVQ ( MP1, MA1 ) ;\ -TWO(MOVQ ( MP2, MA2 )) ;\ - ;\ - PUNPCKHWD ( MA1, MA1 ) /* pa1 | pa1 | | */ ;\ -TWO(PUNPCKHWD ( MA2, MA2 )) /* pa2 | pa2 | | */ ;\ - PUNPCKHDQ ( MA1, MA1 ) /* pa1 | pa1 | pa1 | pa1 */ ;\ -TWO(PUNPCKHDQ ( MA2, MA2 )) /* pa2 | pa2 | pa2 | pa2 */ - -#define GMB_PACK( MS1, MS2 ) \ - PACKUSWB ( MS2, MS1 ) /* sa2 | sb2 | sg2 | sr2 | sa1 | sb1 | sg1 | sr1 */ ;\ - -#define GMB_STORE(rgba, MSS ) \ -ONE(MOVD ( MSS, REGIND(rgba) )) /* | | | | sa1 | sb1 | sg1 | sr1 */ ;\ -TWO(MOVQ ( MSS, REGIND(rgba) )) /* sa2 | sb2 | sg2 | sr2 | sa1 | sb1 | sg1 | sr1 */ - -/* Kevin F. Quinn 2 July 2006 - * Replace data segment constants with text-segment - * constants (via pushl/movq) - SEG_DATA - -ALIGNDATA8 -const_0080: - D_LONG 0x00800080, 0x00800080 - -const_80: - D_LONG 0x80808080, 0x80808080 -*/ -#define const_0080_l 0x00800080 -#define const_0080_h 0x00800080 -#define const_80_l 0x80808080 -#define const_80_h 0x80808080 - - SEG_TEXT - - -/* Blend transparency function - */ - -#define TAG(x) CONCAT(x,_transparency) -#define LLTAG(x) LLBL2(x,_transparency) - -#define INIT \ - PXOR ( MM0, MM0 ) /* 0x0000 | 0x0000 | 0x0000 | 0x0000 */ - -#define MAIN( rgba, dest ) \ - GMB_LOAD( rgba, dest, MM1, MM2 ) ;\ - GMB_UNPACK( MM1, MM2, MM4, MM5, MM0 ) ;\ - GMB_ALPHA( MM1, MM3, MM4, MM6 ) ;\ - GMB_LERP_GSC( MM1, MM2, MM3, MM4, MM5, MM6 ) ;\ - GMB_PACK( MM3, MM6 ) ;\ - GMB_STORE( rgba, MM3 ) - -#include "mmx_blendtmp.h" - - -/* Blend add function - * - * FIXME: Add some loop unrolling here... - */ - -#define TAG(x) CONCAT(x,_add) -#define LLTAG(x) LLBL2(x,_add) - -#define INIT - -#define MAIN( rgba, dest ) \ -ONE(MOVD ( REGIND(rgba), MM1 )) /* | | | | qa1 | qb1 | qg1 | qr1 */ ;\ -ONE(MOVD ( REGIND(dest), MM2 )) /* | | | | pa1 | pb1 | pg1 | pr1 */ ;\ -ONE(PADDUSB ( MM2, MM1 )) ;\ -ONE(MOVD ( MM1, REGIND(rgba) )) /* | | | | sa1 | sb1 | sg1 | sr1 */ ;\ - ;\ -TWO(MOVQ ( REGIND(rgba), MM1 )) /* qa2 | qb2 | qg2 | qr2 | qa1 | qb1 | qg1 | qr1 */ ;\ -TWO(PADDUSB ( REGIND(dest), MM1 )) /* sa2 | sb2 | sg2 | sr2 | sa1 | sb1 | sg1 | sr1 */ ;\ -TWO(MOVQ ( MM1, REGIND(rgba) )) - -#include "mmx_blendtmp.h" - - -/* Blend modulate function - */ - -#define TAG(x) CONCAT(x,_modulate) -#define LLTAG(x) LLBL2(x,_modulate) - -/* Kevin F. Quinn 2nd July 2006 - * Replace data segment constants with text-segment instructions -#define INIT \ - MOVQ ( CONTENT(const_0080), MM7 ) - */ -#define INIT \ - PXOR ( MM0, MM0 ) /* 0x0000 | 0x0000 | 0x0000 | 0x0000 */ ;\ - PUSH_L ( CONST(const_0080_l) ) /* 0x0080 | 0x0080 | 0x0080 | 0x0080 */ ;\ - PUSH_L ( CONST(const_0080_h) ) ;\ - MOVQ ( REGIND(ESP), MM7 ) ;\ - ADD_L ( CONST(8), ESP) - -#define MAIN( rgba, dest ) \ - GMB_LOAD( rgba, dest, MM1, MM2 ) ;\ - GMB_UNPACK( MM1, MM2, MM4, MM5, MM0 ) ;\ - GMB_MULT_GSR( MM1, MM2, MM4, MM5, MM7 ) ;\ - GMB_PACK( MM2, MM5 ) ;\ - GMB_STORE( rgba, MM2 ) - -#include "mmx_blendtmp.h" - -#endif - -#if defined (__ELF__) && defined (__linux__) - .section .note.GNU-stack,"",%progbits -#endif diff --git a/dll/opengl/mesa/x86/mmx_blendtmp.h b/dll/opengl/mesa/x86/mmx_blendtmp.h deleted file mode 100644 index 8534792e297..00000000000 --- a/dll/opengl/mesa/x86/mmx_blendtmp.h +++ /dev/null @@ -1,114 +0,0 @@ -/* - * Written by José Fonseca - */ - - -/* - * void _mesa_mmx_blend( struct gl_context *ctx, - * GLuint n, - * const GLubyte mask[], - * GLchan rgba[][4], - * CONST GLchan dest[][4] ) - * - */ -ALIGNTEXT16 -GLOBL GLNAME( TAG(_mesa_mmx_blend) ) -HIDDEN( TAG(_mesa_mmx_blend) ) -GLNAME( TAG(_mesa_mmx_blend) ): - - PUSH_L ( EBP ) - MOV_L ( ESP, EBP ) - PUSH_L ( ESI ) - PUSH_L ( EDI ) - PUSH_L ( EBX ) - - MOV_L ( REGOFF(12, EBP), ECX ) /* n */ - CMP_L ( CONST(0), ECX) - JE ( LLTAG(GMB_return) ) - - MOV_L ( REGOFF(16, EBP), EBX ) /* mask */ - MOV_L ( REGOFF(20, EBP), EDI ) /* rgba */ - MOV_L ( REGOFF(24, EBP), ESI ) /* dest */ - - INIT - - TEST_L ( CONST(4), EDI ) /* align rgba on an 8-byte boundary */ - JZ ( LLTAG(GMB_align_end) ) - - CMP_B ( CONST(0), REGIND(EBX) ) /* *mask == 0 */ - JE ( LLTAG(GMB_align_continue) ) - - /* runin */ -#define ONE(x) x -#define TWO(x) - MAIN ( EDI, ESI ) -#undef ONE -#undef TWO - -LLTAG(GMB_align_continue): - - DEC_L ( ECX ) /* n -= 1 */ - INC_L ( EBX ) /* mask += 1 */ - ADD_L ( CONST(4), EDI ) /* rgba += 1 */ - ADD_L ( CONST(4), ESI ) /* dest += 1 */ - -LLTAG(GMB_align_end): - - CMP_L ( CONST(2), ECX) - JB ( LLTAG(GMB_loop_end) ) - -ALIGNTEXT16 -LLTAG(GMB_loop_begin): - - CMP_W ( CONST(0), REGIND(EBX) ) /* *mask == 0 && *(mask + 1) == 0 */ - JE ( LLTAG(GMB_loop_continue) ) - - /* main loop */ -#define ONE(x) -#define TWO(x) x - MAIN ( EDI, ESI ) -#undef ONE -#undef TWO - -LLTAG(GMB_loop_continue): - - DEC_L ( ECX ) - DEC_L ( ECX ) /* n -= 2 */ - ADD_L ( CONST(2), EBX ) /* mask += 2 */ - ADD_L ( CONST(8), EDI ) /* rgba += 2 */ - ADD_L ( CONST(8), ESI ) /* dest += 2 */ - CMP_L ( CONST(2), ECX ) - JAE ( LLTAG(GMB_loop_begin) ) - -LLTAG(GMB_loop_end): - - CMP_L ( CONST(1), ECX ) - JB ( LLTAG(GMB_done) ) - - CMP_B ( CONST(0), REGIND(EBX) ) /* *mask == 0 */ - JE ( LLTAG(GMB_done) ) - - /* runout */ -#define ONE(x) x -#define TWO(x) - MAIN ( EDI, ESI ) -#undef ONE -#undef TWO - -LLTAG(GMB_done): - - EMMS - -LLTAG(GMB_return): - - POP_L ( EBX ) - POP_L ( EDI ) - POP_L ( ESI ) - MOV_L ( EBP, ESP ) - POP_L ( EBP ) - RET - -#undef TAG -#undef LLTAG -#undef INIT -#undef MAIN diff --git a/dll/opengl/mesa/x86/norm_args.h b/dll/opengl/mesa/x86/norm_args.h deleted file mode 100644 index 5d352838be5..00000000000 --- a/dll/opengl/mesa/x86/norm_args.h +++ /dev/null @@ -1,57 +0,0 @@ - -/* - * Mesa 3-D graphics library - * Version: 3.5 - * - * Copyright (C) 1999-2001 Brian Paul All Rights Reserved. - * - * Permission is hereby granted, free of charge, to any person obtaining a - * copy of this software and associated documentation files (the "Software"), - * to deal in the Software without restriction, including without limitation - * the rights to use, copy, modify, merge, publish, distribute, sublicense, - * and/or sell copies of the Software, and to permit persons to whom the - * Software is furnished to do so, subject to the following conditions: - * - * The above copyright notice and this permission notice shall be included - * in all copies or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS - * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL - * BRIAN PAUL BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN - * AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN - * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. - */ - -/* - * Normal transform function interface for assembly code. Simply define - * FRAME_OFFSET to the number of bytes pushed onto the stack before - * using the ARG_* argument macros. - * - * Gareth Hughes - */ - -#ifndef __NORM_ARGS_H__ -#define __NORM_ARGS_H__ - -/* Offsets for normal_func arguments - * - * typedef void (*normal_func)( CONST GLmatrix *mat, - * GLfloat scale, - * CONST GLvector4f *in, - * CONST GLfloat lengths[], - * GLvector4f *dest ); - */ -#define OFFSET_MAT 4 -#define OFFSET_SCALE 8 -#define OFFSET_IN 12 -#define OFFSET_LENGTHS 16 -#define OFFSET_DEST 20 - -#define ARG_MAT REGOFF(FRAME_OFFSET+OFFSET_MAT, ESP) -#define ARG_SCALE REGOFF(FRAME_OFFSET+OFFSET_SCALE, ESP) -#define ARG_IN REGOFF(FRAME_OFFSET+OFFSET_IN, ESP) -#define ARG_LENGTHS REGOFF(FRAME_OFFSET+OFFSET_LENGTHS, ESP) -#define ARG_DEST REGOFF(FRAME_OFFSET+OFFSET_DEST, ESP) - -#endif diff --git a/dll/opengl/mesa/x86/read_rgba_span_x86.S b/dll/opengl/mesa/x86/read_rgba_span_x86.S deleted file mode 100644 index f3091bf1ce6..00000000000 --- a/dll/opengl/mesa/x86/read_rgba_span_x86.S +++ /dev/null @@ -1,686 +0,0 @@ -/* - * (C) Copyright IBM Corporation 2004 - * All Rights Reserved. - * - * Permission is hereby granted, free of charge, to any person obtaining a - * copy of this software and associated documentation files (the "Software"), - * to deal in the Software without restriction, including without limitation - * on the rights to use, copy, modify, merge, publish, distribute, sub - * license, and/or sell copies of the Software, and to permit persons to whom - * the Software is furnished to do so, subject to the following conditions: - * - * The above copyright notice and this permission notice (including the next - * paragraph) shall be included in all copies or substantial portions of the - * Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR - * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT. IN NO EVENT SHALL - * IBM AND/OR THEIR SUPPLIERS BE LIABLE FOR ANY CLAIM, - * DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR - * OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE - * USE OR OTHER DEALINGS IN THE SOFTWARE. - */ - -/** - * \file read_rgba_span_x86.S - * Optimized routines to transfer pixel data from the framebuffer to a - * buffer in main memory. - * - * \author Ian Romanick - */ - - .file "read_rgba_span_x86.S" -#if !defined(__DJGPP__) && !defined(__MINGW32__) && !defined(__APPLE__) /* this one cries for assyntax.h */ -/* Kevin F. Quinn 2nd July 2006 - * Replaced data segment constants with text-segment instructions. - */ -#define LOAD_MASK(mvins,m1,m2) \ - pushl $0xff00ff00 ;\ - pushl $0xff00ff00 ;\ - pushl $0xff00ff00 ;\ - pushl $0xff00ff00 ;\ - mvins (%esp), m1 ;\ - pushl $0x00ff0000 ;\ - pushl $0x00ff0000 ;\ - pushl $0x00ff0000 ;\ - pushl $0x00ff0000 ;\ - mvins (%esp), m2 ;\ - addl $32, %esp - -/* I implemented these as macros because they appear in several places, - * and I've tweaked them a number of times. I got tired of changing every - * place they appear. :) - */ - -#define DO_ONE_PIXEL() \ - movl (%ebx), %eax ; \ - addl $4, %ebx ; \ - bswap %eax /* ARGB -> BGRA */ ; \ - rorl $8, %eax /* BGRA -> ABGR */ ; \ - movl %eax, (%ecx) /* ABGR -> R, G, B, A */ ; \ - addl $4, %ecx - -#define DO_ONE_LAST_PIXEL() \ - movl (%ebx), %eax ; \ - bswap %eax /* ARGB -> BGRA */ ; \ - rorl $8, %eax /* BGRA -> ABGR */ ; \ - movl %eax, (%ecx) /* ABGR -> R, G, B, A */ ; \ - - -/** - * MMX optimized version of the BGRA8888_REV to RGBA copy routine. - * - * \warning - * This function assumes that the caller will issue the EMMS instruction - * at the correct places. - */ - -.globl _generic_read_RGBA_span_BGRA8888_REV_MMX -#ifndef USE_DRICORE -.hidden _generic_read_RGBA_span_BGRA8888_REV_MMX -#endif - .type _generic_read_RGBA_span_BGRA8888_REV_MMX, @function -_generic_read_RGBA_span_BGRA8888_REV_MMX: - pushl %ebx - -#ifdef USE_INNER_EMMS - emms -#endif - LOAD_MASK(movq,%mm1,%mm2) - - movl 8(%esp), %ebx /* source pointer */ - movl 16(%esp), %edx /* number of pixels to copy */ - movl 12(%esp), %ecx /* destination pointer */ - - testl %edx, %edx - jle .L20 /* Bail if there's nothing to do. */ - - movl %ebx, %eax - - negl %eax - sarl $2, %eax - andl $1, %eax - je .L17 - - subl %eax, %edx - DO_ONE_PIXEL() -.L17: - - /* Would it be faster to unroll this loop once and process 4 pixels - * per pass, instead of just two? - */ - - movl %edx, %eax - shrl %eax - jmp .L18 -.L19: - movq (%ebx), %mm0 - addl $8, %ebx - - /* These 9 instructions do what PSHUFB (if there were such an - * instruction) could do in 1. :( - */ - - movq %mm0, %mm3 - movq %mm0, %mm4 - - pand %mm2, %mm3 - psllq $16, %mm4 - psrlq $16, %mm3 - pand %mm2, %mm4 - - pand %mm1, %mm0 - por %mm4, %mm3 - por %mm3, %mm0 - - movq %mm0, (%ecx) - addl $8, %ecx - subl $1, %eax -.L18: - jne .L19 - -#ifdef USE_INNER_EMMS - emms -#endif - - /* At this point there are either 1 or 0 pixels remaining to be - * converted. Convert the last pixel, if needed. - */ - - testl $1, %edx - je .L20 - - DO_ONE_LAST_PIXEL() - -.L20: - popl %ebx - ret - .size _generic_read_RGBA_span_BGRA8888_REV_MMX, .-_generic_read_RGBA_span_BGRA8888_REV_MMX - - -/** - * SSE optimized version of the BGRA8888_REV to RGBA copy routine. SSE - * instructions are only actually used to read data from the framebuffer. - * In practice, the speed-up is pretty small. - * - * \todo - * Do some more testing and determine if there's any reason to have this - * function in addition to the MMX version. - * - * \warning - * This function assumes that the caller will issue the EMMS instruction - * at the correct places. - */ - -.globl _generic_read_RGBA_span_BGRA8888_REV_SSE -#ifndef USE_DRICORE -.hidden _generic_read_RGBA_span_BGRA8888_REV_SSE -#endif - .type _generic_read_RGBA_span_BGRA8888_REV_SSE, @function -_generic_read_RGBA_span_BGRA8888_REV_SSE: - pushl %esi - pushl %ebx - pushl %ebp - -#ifdef USE_INNER_EMMS - emms -#endif - - LOAD_MASK(movq,%mm1,%mm2) - - movl 16(%esp), %ebx /* source pointer */ - movl 24(%esp), %edx /* number of pixels to copy */ - movl 20(%esp), %ecx /* destination pointer */ - - testl %edx, %edx - jle .L35 /* Bail if there's nothing to do. */ - - movl %esp, %ebp - subl $16, %esp - andl $0xfffffff0, %esp - - movl %ebx, %eax - movl %edx, %esi - - negl %eax - andl $15, %eax - sarl $2, %eax - cmpl %edx, %eax - cmovle %eax, %esi - - subl %esi, %edx - - testl $1, %esi - je .L32 - - DO_ONE_PIXEL() -.L32: - - testl $2, %esi - je .L31 - - movq (%ebx), %mm0 - addl $8, %ebx - - movq %mm0, %mm3 - movq %mm0, %mm4 - - pand %mm2, %mm3 - psllq $16, %mm4 - psrlq $16, %mm3 - pand %mm2, %mm4 - - pand %mm1, %mm0 - por %mm4, %mm3 - por %mm3, %mm0 - - movq %mm0, (%ecx) - addl $8, %ecx -.L31: - - movl %edx, %eax - shrl $2, %eax - jmp .L33 -.L34: - movaps (%ebx), %xmm0 - addl $16, %ebx - - /* This would be so much better if we could just move directly from - * an SSE register to an MMX register. Unfortunately, that - * functionality wasn't introduced until SSE2 with the MOVDQ2Q - * instruction. - */ - - movaps %xmm0, (%esp) - movq (%esp), %mm0 - movq 8(%esp), %mm5 - - movq %mm0, %mm3 - movq %mm0, %mm4 - movq %mm5, %mm6 - movq %mm5, %mm7 - - pand %mm2, %mm3 - pand %mm2, %mm6 - - psllq $16, %mm4 - psllq $16, %mm7 - - psrlq $16, %mm3 - psrlq $16, %mm6 - - pand %mm2, %mm4 - pand %mm2, %mm7 - - pand %mm1, %mm0 - pand %mm1, %mm5 - - por %mm4, %mm3 - por %mm7, %mm6 - - por %mm3, %mm0 - por %mm6, %mm5 - - movq %mm0, (%ecx) - movq %mm5, 8(%ecx) - addl $16, %ecx - - subl $1, %eax -.L33: - jne .L34 - -#ifdef USE_INNER_EMMS - emms -#endif - movl %ebp, %esp - - /* At this point there are either [0, 3] pixels remaining to be - * converted. - */ - - testl $2, %edx - je .L36 - - movq (%ebx), %mm0 - addl $8, %ebx - - movq %mm0, %mm3 - movq %mm0, %mm4 - - pand %mm2, %mm3 - psllq $16, %mm4 - psrlq $16, %mm3 - pand %mm2, %mm4 - - pand %mm1, %mm0 - por %mm4, %mm3 - por %mm3, %mm0 - - movq %mm0, (%ecx) - addl $8, %ecx -.L36: - - testl $1, %edx - je .L35 - - DO_ONE_LAST_PIXEL() -.L35: - popl %ebp - popl %ebx - popl %esi - ret - .size _generic_read_RGBA_span_BGRA8888_REV_SSE, .-_generic_read_RGBA_span_BGRA8888_REV_SSE - - -/** - * SSE2 optimized version of the BGRA8888_REV to RGBA copy routine. - */ - - .text -.globl _generic_read_RGBA_span_BGRA8888_REV_SSE2 -#ifndef USE_DRICORE -.hidden _generic_read_RGBA_span_BGRA8888_REV_SSE2 -#endif - .type _generic_read_RGBA_span_BGRA8888_REV_SSE2, @function -_generic_read_RGBA_span_BGRA8888_REV_SSE2: - pushl %esi - pushl %ebx - - LOAD_MASK(movdqu,%xmm1,%xmm2) - - movl 12(%esp), %ebx /* source pointer */ - movl 20(%esp), %edx /* number of pixels to copy */ - movl 16(%esp), %ecx /* destination pointer */ - - movl %ebx, %eax - movl %edx, %esi - - testl %edx, %edx - jle .L46 /* Bail if there's nothing to do. */ - - /* If the source pointer isn't a multiple of 16 we have to process - * a few pixels the "slow" way to get the address aligned for - * the SSE fetch instructions. - */ - - negl %eax - andl $15, %eax - sarl $2, %eax - - cmpl %edx, %eax - cmovbe %eax, %esi - subl %esi, %edx - - testl $1, %esi - je .L41 - - DO_ONE_PIXEL() -.L41: - testl $2, %esi - je .L40 - - movq (%ebx), %xmm0 - addl $8, %ebx - - movdqa %xmm0, %xmm3 - movdqa %xmm0, %xmm4 - andps %xmm1, %xmm0 - - andps %xmm2, %xmm3 - pslldq $2, %xmm4 - psrldq $2, %xmm3 - andps %xmm2, %xmm4 - - orps %xmm4, %xmm3 - orps %xmm3, %xmm0 - - movq %xmm0, (%ecx) - addl $8, %ecx -.L40: - - /* Would it be worth having a specialized version of this loop for - * the case where the destination is 16-byte aligned? That version - * would be identical except that it could use movedqa instead of - * movdqu. - */ - - movl %edx, %eax - shrl $2, %eax - jmp .L42 -.L43: - movdqa (%ebx), %xmm0 - addl $16, %ebx - - movdqa %xmm0, %xmm3 - movdqa %xmm0, %xmm4 - andps %xmm1, %xmm0 - - andps %xmm2, %xmm3 - pslldq $2, %xmm4 - psrldq $2, %xmm3 - andps %xmm2, %xmm4 - - orps %xmm4, %xmm3 - orps %xmm3, %xmm0 - - movdqu %xmm0, (%ecx) - addl $16, %ecx - subl $1, %eax -.L42: - jne .L43 - - - /* There may be upto 3 pixels remaining to be copied. Take care - * of them now. We do the 2 pixel case first because the data - * will be aligned. - */ - - testl $2, %edx - je .L47 - - movq (%ebx), %xmm0 - addl $8, %ebx - - movdqa %xmm0, %xmm3 - movdqa %xmm0, %xmm4 - andps %xmm1, %xmm0 - - andps %xmm2, %xmm3 - pslldq $2, %xmm4 - psrldq $2, %xmm3 - andps %xmm2, %xmm4 - - orps %xmm4, %xmm3 - orps %xmm3, %xmm0 - - movq %xmm0, (%ecx) - addl $8, %ecx -.L47: - - testl $1, %edx - je .L46 - - DO_ONE_LAST_PIXEL() -.L46: - - popl %ebx - popl %esi - ret - .size _generic_read_RGBA_span_BGRA8888_REV_SSE2, .-_generic_read_RGBA_span_BGRA8888_REV_SSE2 - - - -#define MASK_565_L 0x07e0f800 -#define MASK_565_H 0x0000001f -/* Setting SCALE_ADJUST to 5 gives a perfect match with the - * classic C implementation in Mesa. Setting SCALE_ADJUST - * to 0 is slightly faster but at a small cost to accuracy. - */ -#define SCALE_ADJUST 5 -#if SCALE_ADJUST == 5 -#define PRESCALE_L 0x00100001 -#define PRESCALE_H 0x00000200 -#define SCALE_L 0x40C620E8 -#define SCALE_H 0x0000839d -#elif SCALE_ADJUST == 0 -#define PRESCALE_L 0x00200001 -#define PRESCALE_H 0x00000800 -#define SCALE_L 0x01040108 -#define SCALE_H 0x00000108 -#else -#error SCALE_ADJUST must either be 5 or 0. -#endif -#define ALPHA_L 0x00000000 -#define ALPHA_H 0x00ff0000 - -/** - * MMX optimized version of the RGB565 to RGBA copy routine. - */ - - .text - .globl _generic_read_RGBA_span_RGB565_MMX -#ifndef USE_DRICORE - .hidden _generic_read_RGBA_span_RGB565_MMX -#endif - .type _generic_read_RGBA_span_RGB565_MMX, @function - -_generic_read_RGBA_span_RGB565_MMX: - -#ifdef USE_INNER_EMMS - emms -#endif - - movl 4(%esp), %eax /* source pointer */ - movl 8(%esp), %edx /* destination pointer */ - movl 12(%esp), %ecx /* number of pixels to copy */ - - pushl $MASK_565_H - pushl $MASK_565_L - movq (%esp), %mm5 - pushl $PRESCALE_H - pushl $PRESCALE_L - movq (%esp), %mm6 - pushl $SCALE_H - pushl $SCALE_L - movq (%esp), %mm7 - pushl $ALPHA_H - pushl $ALPHA_L - movq (%esp), %mm3 - addl $32,%esp - - sarl $2, %ecx - jl .L01 /* Bail early if the count is negative. */ - jmp .L02 - -.L03: - /* Fetch 4 RGB565 pixels into %mm4. Distribute the first and - * second pixels into the four words of %mm0 and %mm2. - */ - - movq (%eax), %mm4 - addl $8, %eax - - pshufw $0x00, %mm4, %mm0 - pshufw $0x55, %mm4, %mm2 - - - /* Mask the pixels so that each word of each register contains only - * one color component. - */ - - pand %mm5, %mm0 - pand %mm5, %mm2 - - - /* Adjust the component values so that they are as small as possible, - * but large enough so that we can multiply them by an unsigned 16-bit - * number and get a value as large as 0x00ff0000. - */ - - pmullw %mm6, %mm0 - pmullw %mm6, %mm2 -#if SCALE_ADJUST > 0 - psrlw $SCALE_ADJUST, %mm0 - psrlw $SCALE_ADJUST, %mm2 -#endif - - /* Scale the input component values to be on the range - * [0, 0x00ff0000]. This it the real magic of the whole routine. - */ - - pmulhuw %mm7, %mm0 - pmulhuw %mm7, %mm2 - - - /* Always set the alpha value to 0xff. - */ - - por %mm3, %mm0 - por %mm3, %mm2 - - - /* Pack the 16-bit values to 8-bit values and store the converted - * pixel data. - */ - - packuswb %mm2, %mm0 - movq %mm0, (%edx) - addl $8, %edx - - pshufw $0xaa, %mm4, %mm0 - pshufw $0xff, %mm4, %mm2 - - pand %mm5, %mm0 - pand %mm5, %mm2 - pmullw %mm6, %mm0 - pmullw %mm6, %mm2 -#if SCALE_ADJUST > 0 - psrlw $SCALE_ADJUST, %mm0 - psrlw $SCALE_ADJUST, %mm2 -#endif - pmulhuw %mm7, %mm0 - pmulhuw %mm7, %mm2 - - por %mm3, %mm0 - por %mm3, %mm2 - - packuswb %mm2, %mm0 - - movq %mm0, (%edx) - addl $8, %edx - - subl $1, %ecx -.L02: - jne .L03 - - - /* At this point there can be at most 3 pixels left to process. If - * there is either 2 or 3 left, process 2. - */ - - movl 12(%esp), %ecx - testl $0x02, %ecx - je .L04 - - movd (%eax), %mm4 - addl $4, %eax - - pshufw $0x00, %mm4, %mm0 - pshufw $0x55, %mm4, %mm2 - - pand %mm5, %mm0 - pand %mm5, %mm2 - pmullw %mm6, %mm0 - pmullw %mm6, %mm2 -#if SCALE_ADJUST > 0 - psrlw $SCALE_ADJUST, %mm0 - psrlw $SCALE_ADJUST, %mm2 -#endif - pmulhuw %mm7, %mm0 - pmulhuw %mm7, %mm2 - - por %mm3, %mm0 - por %mm3, %mm2 - - packuswb %mm2, %mm0 - - movq %mm0, (%edx) - addl $8, %edx - -.L04: - /* At this point there can be at most 1 pixel left to process. - * Process it if needed. - */ - - testl $0x01, %ecx - je .L01 - - movzwl (%eax), %ecx - movd %ecx, %mm4 - - pshufw $0x00, %mm4, %mm0 - - pand %mm5, %mm0 - pmullw %mm6, %mm0 -#if SCALE_ADJUST > 0 - psrlw $SCALE_ADJUST, %mm0 -#endif - pmulhuw %mm7, %mm0 - - por %mm3, %mm0 - - packuswb %mm0, %mm0 - - movd %mm0, (%edx) - -.L01: -#ifdef USE_INNER_EMMS - emms -#endif - ret -#endif /* !defined(__DJGPP__) && !defined(__MINGW32__) && !defined(__APPLE__) */ - -#if defined (__ELF__) && defined (__linux__) - .section .note.GNU-stack,"",%progbits -#endif diff --git a/dll/opengl/mesa/x86/read_rgba_span_x86.h b/dll/opengl/mesa/x86/read_rgba_span_x86.h deleted file mode 100644 index 564b1bb0f9e..00000000000 --- a/dll/opengl/mesa/x86/read_rgba_span_x86.h +++ /dev/null @@ -1,56 +0,0 @@ -/* - * (C) Copyright IBM Corporation 2004 - * All Rights Reserved. - * - * Permission is hereby granted, free of charge, to any person obtaining a - * copy of this software and associated documentation files (the "Software"), - * to deal in the Software without restriction, including without limitation - * on the rights to use, copy, modify, merge, publish, distribute, sub - * license, and/or sell copies of the Software, and to permit persons to whom - * the Software is furnished to do so, subject to the following conditions: - * - * The above copyright notice and this permission notice (including the next - * paragraph) shall be included in all copies or substantial portions of the - * Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR - * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT. IN NO EVENT SHALL - * IBM AND/OR THEIR SUPPLIERS BE LIABLE FOR ANY CLAIM, - * DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR - * OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE - * USE OR OTHER DEALINGS IN THE SOFTWARE. - */ - -/** - * \file read_rgba_span_x86.h - * - * \author Ian Romanick - */ - -#ifndef READ_RGBA_SPAN_X86_H -#define READ_RGBA_SPAN_X86_H - -#if defined(USE_SSE_ASM) || defined(USE_MMX_ASM) -#include "x86/common_x86_asm.h" -#endif - -#if defined(USE_SSE_ASM) -extern void _generic_read_RGBA_span_BGRA8888_REV_SSE2( const unsigned char *, - unsigned char *, unsigned ); -#endif - -#if defined(USE_SSE_ASM) -extern void _generic_read_RGBA_span_BGRA8888_REV_SSE( const unsigned char *, - unsigned char *, unsigned ); -#endif - -#if defined(USE_MMX_ASM) -extern void _generic_read_RGBA_span_BGRA8888_REV_MMX( const unsigned char *, - unsigned char *, unsigned ); - -extern void _generic_read_RGBA_span_RGB565_MMX( const unsigned char *, - unsigned char *, unsigned ); -#endif - -#endif /* READ_RGBA_SPAN_X86_H */ diff --git a/dll/opengl/mesa/x86/rtasm/x86sse.c b/dll/opengl/mesa/x86/rtasm/x86sse.c deleted file mode 100644 index bb5d7cd81cf..00000000000 --- a/dll/opengl/mesa/x86/rtasm/x86sse.c +++ /dev/null @@ -1,1203 +0,0 @@ -#ifdef USE_X86_ASM -#if defined(__i386__) || defined(__386__) - -#include "main/imports.h" -#include "x86sse.h" - -#define DISASSEM 0 -#define X86_TWOB 0x0f - -#if 0 -static unsigned char *cptr( void (*label)() ) -{ - return (unsigned char *)(unsigned long)label; -} -#endif - - -static void do_realloc( struct x86_function *p ) -{ - if (p->size == 0) { - p->size = 1024; - p->store = _mesa_exec_malloc(p->size); - p->csr = p->store; - } - else { - unsigned used = p->csr - p->store; - unsigned char *tmp = p->store; - p->size *= 2; - p->store = _mesa_exec_malloc(p->size); - memcpy(p->store, tmp, used); - p->csr = p->store + used; - _mesa_exec_free(tmp); - } -} - -/* Emit bytes to the instruction stream: - */ -static unsigned char *reserve( struct x86_function *p, int bytes ) -{ - if (p->csr + bytes - p->store > p->size) - do_realloc(p); - - { - unsigned char *csr = p->csr; - p->csr += bytes; - return csr; - } -} - - - -static void emit_1b( struct x86_function *p, char b0 ) -{ - char *csr = (char *)reserve(p, 1); - *csr = b0; -} - -static void emit_1i( struct x86_function *p, int i0 ) -{ - int *icsr = (int *)reserve(p, sizeof(i0)); - *icsr = i0; -} - -static void emit_1ub( struct x86_function *p, unsigned char b0 ) -{ - unsigned char *csr = reserve(p, 1); - *csr++ = b0; -} - -static void emit_2ub( struct x86_function *p, unsigned char b0, unsigned char b1 ) -{ - unsigned char *csr = reserve(p, 2); - *csr++ = b0; - *csr++ = b1; -} - -static void emit_3ub( struct x86_function *p, unsigned char b0, unsigned char b1, unsigned char b2 ) -{ - unsigned char *csr = reserve(p, 3); - *csr++ = b0; - *csr++ = b1; - *csr++ = b2; -} - - -/* Build a modRM byte + possible displacement. No treatment of SIB - * indexing. BZZT - no way to encode an absolute address. - */ -static void emit_modrm( struct x86_function *p, - struct x86_reg reg, - struct x86_reg regmem ) -{ - unsigned char val = 0; - - assert(reg.mod == mod_REG); - - val |= regmem.mod << 6; /* mod field */ - val |= reg.idx << 3; /* reg field */ - val |= regmem.idx; /* r/m field */ - - emit_1ub(p, val); - - /* Oh-oh we've stumbled into the SIB thing. - */ - if (regmem.file == file_REG32 && - regmem.idx == reg_SP) { - emit_1ub(p, 0x24); /* simplistic! */ - } - - switch (regmem.mod) { - case mod_REG: - case mod_INDIRECT: - break; - case mod_DISP8: - emit_1b(p, regmem.disp); - break; - case mod_DISP32: - emit_1i(p, regmem.disp); - break; - default: - assert(0); - break; - } -} - - -static void emit_modrm_noreg( struct x86_function *p, - unsigned op, - struct x86_reg regmem ) -{ - struct x86_reg dummy = x86_make_reg(file_REG32, op); - emit_modrm(p, dummy, regmem); -} - -/* Many x86 instructions have two opcodes to cope with the situations - * where the destination is a register or memory reference - * respectively. This function selects the correct opcode based on - * the arguments presented. - */ -static void emit_op_modrm( struct x86_function *p, - unsigned char op_dst_is_reg, - unsigned char op_dst_is_mem, - struct x86_reg dst, - struct x86_reg src ) -{ - switch (dst.mod) { - case mod_REG: - emit_1ub(p, op_dst_is_reg); - emit_modrm(p, dst, src); - break; - case mod_INDIRECT: - case mod_DISP32: - case mod_DISP8: - assert(src.mod == mod_REG); - emit_1ub(p, op_dst_is_mem); - emit_modrm(p, src, dst); - break; - default: - assert(0); - break; - } -} - - - - - - - -/* Create and manipulate registers and regmem values: - */ -struct x86_reg x86_make_reg( enum x86_reg_file file, - enum x86_reg_name idx ) -{ - struct x86_reg reg; - - reg.file = file; - reg.idx = idx; - reg.mod = mod_REG; - reg.disp = 0; - - return reg; -} - -struct x86_reg x86_make_disp( struct x86_reg reg, - int disp ) -{ - assert(reg.file == file_REG32); - - if (reg.mod == mod_REG) - reg.disp = disp; - else - reg.disp += disp; - - if (reg.disp == 0) - reg.mod = mod_INDIRECT; - else if (reg.disp <= 127 && reg.disp >= -128) - reg.mod = mod_DISP8; - else - reg.mod = mod_DISP32; - - return reg; -} - -struct x86_reg x86_deref( struct x86_reg reg ) -{ - return x86_make_disp(reg, 0); -} - -struct x86_reg x86_get_base_reg( struct x86_reg reg ) -{ - return x86_make_reg( reg.file, reg.idx ); -} - -unsigned char *x86_get_label( struct x86_function *p ) -{ - return p->csr; -} - - - -/*********************************************************************** - * x86 instructions - */ - - -void x86_jcc( struct x86_function *p, - enum x86_cc cc, - unsigned char *label ) -{ - int offset = label - (x86_get_label(p) + 2); - - if (offset <= 127 && offset >= -128) { - emit_1ub(p, 0x70 + cc); - emit_1b(p, (char) offset); - } - else { - offset = label - (x86_get_label(p) + 6); - emit_2ub(p, 0x0f, 0x80 + cc); - emit_1i(p, offset); - } -} - -/* Always use a 32bit offset for forward jumps: - */ -unsigned char *x86_jcc_forward( struct x86_function *p, - enum x86_cc cc ) -{ - emit_2ub(p, 0x0f, 0x80 + cc); - emit_1i(p, 0); - return x86_get_label(p); -} - -unsigned char *x86_jmp_forward( struct x86_function *p) -{ - emit_1ub(p, 0xe9); - emit_1i(p, 0); - return x86_get_label(p); -} - -unsigned char *x86_call_forward( struct x86_function *p) -{ - emit_1ub(p, 0xe8); - emit_1i(p, 0); - return x86_get_label(p); -} - -/* Fixup offset from forward jump: - */ -void x86_fixup_fwd_jump( struct x86_function *p, - unsigned char *fixup ) -{ - *(int *)(fixup - 4) = x86_get_label(p) - fixup; -} - -void x86_jmp( struct x86_function *p, unsigned char *label) -{ - emit_1ub(p, 0xe9); - emit_1i(p, label - x86_get_label(p) - 4); -} - -#if 0 -/* This doesn't work once we start reallocating & copying the - * generated code on buffer fills, because the call is relative to the - * current pc. - */ -void x86_call( struct x86_function *p, void (*label)()) -{ - emit_1ub(p, 0xe8); - emit_1i(p, cptr(label) - x86_get_label(p) - 4); -} -#else -void x86_call( struct x86_function *p, struct x86_reg reg) -{ - emit_1ub(p, 0xff); - emit_modrm_noreg(p, 2, reg); -} -#endif - - -/* michal: - * Temporary. As I need immediate operands, and dont want to mess with the codegen, - * I load the immediate into general purpose register and use it. - */ -void x86_mov_reg_imm( struct x86_function *p, struct x86_reg dst, int imm ) -{ - assert(dst.mod == mod_REG); - emit_1ub(p, 0xb8 + dst.idx); - emit_1i(p, imm); -} - -void x86_push( struct x86_function *p, - struct x86_reg reg ) -{ - assert(reg.mod == mod_REG); - emit_1ub(p, 0x50 + reg.idx); - p->stack_offset += 4; -} - -void x86_pop( struct x86_function *p, - struct x86_reg reg ) -{ - assert(reg.mod == mod_REG); - emit_1ub(p, 0x58 + reg.idx); - p->stack_offset -= 4; -} - -void x86_inc( struct x86_function *p, - struct x86_reg reg ) -{ - assert(reg.mod == mod_REG); - emit_1ub(p, 0x40 + reg.idx); -} - -void x86_dec( struct x86_function *p, - struct x86_reg reg ) -{ - assert(reg.mod == mod_REG); - emit_1ub(p, 0x48 + reg.idx); -} - -void x86_ret( struct x86_function *p ) -{ - emit_1ub(p, 0xc3); -} - -void x86_sahf( struct x86_function *p ) -{ - emit_1ub(p, 0x9e); -} - -void x86_mov( struct x86_function *p, - struct x86_reg dst, - struct x86_reg src ) -{ - emit_op_modrm( p, 0x8b, 0x89, dst, src ); -} - -void x86_xor( struct x86_function *p, - struct x86_reg dst, - struct x86_reg src ) -{ - emit_op_modrm( p, 0x33, 0x31, dst, src ); -} - -void x86_cmp( struct x86_function *p, - struct x86_reg dst, - struct x86_reg src ) -{ - emit_op_modrm( p, 0x3b, 0x39, dst, src ); -} - -void x86_lea( struct x86_function *p, - struct x86_reg dst, - struct x86_reg src ) -{ - emit_1ub(p, 0x8d); - emit_modrm( p, dst, src ); -} - -void x86_test( struct x86_function *p, - struct x86_reg dst, - struct x86_reg src ) -{ - emit_1ub(p, 0x85); - emit_modrm( p, dst, src ); -} - -void x86_add( struct x86_function *p, - struct x86_reg dst, - struct x86_reg src ) -{ - emit_op_modrm(p, 0x03, 0x01, dst, src ); -} - -void x86_mul( struct x86_function *p, - struct x86_reg src ) -{ - assert (src.file == file_REG32 && src.mod == mod_REG); - emit_op_modrm(p, 0xf7, 0, x86_make_reg (file_REG32, reg_SP), src ); -} - -void x86_sub( struct x86_function *p, - struct x86_reg dst, - struct x86_reg src ) -{ - emit_op_modrm(p, 0x2b, 0x29, dst, src ); -} - -void x86_or( struct x86_function *p, - struct x86_reg dst, - struct x86_reg src ) -{ - emit_op_modrm( p, 0x0b, 0x09, dst, src ); -} - -void x86_and( struct x86_function *p, - struct x86_reg dst, - struct x86_reg src ) -{ - emit_op_modrm( p, 0x23, 0x21, dst, src ); -} - - - -/*********************************************************************** - * SSE instructions - */ - - -void sse_movss( struct x86_function *p, - struct x86_reg dst, - struct x86_reg src ) -{ - emit_2ub(p, 0xF3, X86_TWOB); - emit_op_modrm( p, 0x10, 0x11, dst, src ); -} - -void sse_movaps( struct x86_function *p, - struct x86_reg dst, - struct x86_reg src ) -{ - emit_1ub(p, X86_TWOB); - emit_op_modrm( p, 0x28, 0x29, dst, src ); -} - -void sse_movups( struct x86_function *p, - struct x86_reg dst, - struct x86_reg src ) -{ - emit_1ub(p, X86_TWOB); - emit_op_modrm( p, 0x10, 0x11, dst, src ); -} - -void sse_movhps( struct x86_function *p, - struct x86_reg dst, - struct x86_reg src ) -{ - assert(dst.mod != mod_REG || src.mod != mod_REG); - emit_1ub(p, X86_TWOB); - emit_op_modrm( p, 0x16, 0x17, dst, src ); /* cf movlhps */ -} - -void sse_movlps( struct x86_function *p, - struct x86_reg dst, - struct x86_reg src ) -{ - assert(dst.mod != mod_REG || src.mod != mod_REG); - emit_1ub(p, X86_TWOB); - emit_op_modrm( p, 0x12, 0x13, dst, src ); /* cf movhlps */ -} - -void sse_maxps( struct x86_function *p, - struct x86_reg dst, - struct x86_reg src ) -{ - emit_2ub(p, X86_TWOB, 0x5F); - emit_modrm( p, dst, src ); -} - -void sse_maxss( struct x86_function *p, - struct x86_reg dst, - struct x86_reg src ) -{ - emit_3ub(p, 0xF3, X86_TWOB, 0x5F); - emit_modrm( p, dst, src ); -} - -void sse_divss( struct x86_function *p, - struct x86_reg dst, - struct x86_reg src ) -{ - emit_3ub(p, 0xF3, X86_TWOB, 0x5E); - emit_modrm( p, dst, src ); -} - -void sse_minps( struct x86_function *p, - struct x86_reg dst, - struct x86_reg src ) -{ - emit_2ub(p, X86_TWOB, 0x5D); - emit_modrm( p, dst, src ); -} - -void sse_subps( struct x86_function *p, - struct x86_reg dst, - struct x86_reg src ) -{ - emit_2ub(p, X86_TWOB, 0x5C); - emit_modrm( p, dst, src ); -} - -void sse_mulps( struct x86_function *p, - struct x86_reg dst, - struct x86_reg src ) -{ - emit_2ub(p, X86_TWOB, 0x59); - emit_modrm( p, dst, src ); -} - -void sse_mulss( struct x86_function *p, - struct x86_reg dst, - struct x86_reg src ) -{ - emit_3ub(p, 0xF3, X86_TWOB, 0x59); - emit_modrm( p, dst, src ); -} - -void sse_addps( struct x86_function *p, - struct x86_reg dst, - struct x86_reg src ) -{ - emit_2ub(p, X86_TWOB, 0x58); - emit_modrm( p, dst, src ); -} - -void sse_addss( struct x86_function *p, - struct x86_reg dst, - struct x86_reg src ) -{ - emit_3ub(p, 0xF3, X86_TWOB, 0x58); - emit_modrm( p, dst, src ); -} - -void sse_andnps( struct x86_function *p, - struct x86_reg dst, - struct x86_reg src ) -{ - emit_2ub(p, X86_TWOB, 0x55); - emit_modrm( p, dst, src ); -} - -void sse_andps( struct x86_function *p, - struct x86_reg dst, - struct x86_reg src ) -{ - emit_2ub(p, X86_TWOB, 0x54); - emit_modrm( p, dst, src ); -} - -void sse_rsqrtps( struct x86_function *p, - struct x86_reg dst, - struct x86_reg src ) -{ - emit_2ub(p, X86_TWOB, 0x52); - emit_modrm( p, dst, src ); -} - -void sse_rsqrtss( struct x86_function *p, - struct x86_reg dst, - struct x86_reg src ) -{ - emit_3ub(p, 0xF3, X86_TWOB, 0x52); - emit_modrm( p, dst, src ); - -} - -void sse_movhlps( struct x86_function *p, - struct x86_reg dst, - struct x86_reg src ) -{ - assert(dst.mod == mod_REG && src.mod == mod_REG); - emit_2ub(p, X86_TWOB, 0x12); - emit_modrm( p, dst, src ); -} - -void sse_movlhps( struct x86_function *p, - struct x86_reg dst, - struct x86_reg src ) -{ - assert(dst.mod == mod_REG && src.mod == mod_REG); - emit_2ub(p, X86_TWOB, 0x16); - emit_modrm( p, dst, src ); -} - -void sse_orps( struct x86_function *p, - struct x86_reg dst, - struct x86_reg src ) -{ - emit_2ub(p, X86_TWOB, 0x56); - emit_modrm( p, dst, src ); -} - -void sse_xorps( struct x86_function *p, - struct x86_reg dst, - struct x86_reg src ) -{ - emit_2ub(p, X86_TWOB, 0x57); - emit_modrm( p, dst, src ); -} - -void sse_cvtps2pi( struct x86_function *p, - struct x86_reg dst, - struct x86_reg src ) -{ - assert(dst.file == file_MMX && - (src.file == file_XMM || src.mod != mod_REG)); - - p->need_emms = 1; - - emit_2ub(p, X86_TWOB, 0x2d); - emit_modrm( p, dst, src ); -} - - -/* Shufps can also be used to implement a reduced swizzle when dest == - * arg0. - */ -void sse_shufps( struct x86_function *p, - struct x86_reg dest, - struct x86_reg arg0, - unsigned char shuf) -{ - emit_2ub(p, X86_TWOB, 0xC6); - emit_modrm(p, dest, arg0); - emit_1ub(p, shuf); -} - -void sse_cmpps( struct x86_function *p, - struct x86_reg dest, - struct x86_reg arg0, - unsigned char cc) -{ - emit_2ub(p, X86_TWOB, 0xC2); - emit_modrm(p, dest, arg0); - emit_1ub(p, cc); -} - -void sse_pmovmskb( struct x86_function *p, - struct x86_reg dest, - struct x86_reg src) -{ - emit_3ub(p, 0x66, X86_TWOB, 0xD7); - emit_modrm(p, dest, src); -} - -/*********************************************************************** - * SSE2 instructions - */ - -/** - * Perform a reduced swizzle: - */ -void sse2_pshufd( struct x86_function *p, - struct x86_reg dest, - struct x86_reg arg0, - unsigned char shuf) -{ - emit_3ub(p, 0x66, X86_TWOB, 0x70); - emit_modrm(p, dest, arg0); - emit_1ub(p, shuf); -} - -void sse2_cvttps2dq( struct x86_function *p, - struct x86_reg dst, - struct x86_reg src ) -{ - emit_3ub( p, 0xF3, X86_TWOB, 0x5B ); - emit_modrm( p, dst, src ); -} - -void sse2_cvtps2dq( struct x86_function *p, - struct x86_reg dst, - struct x86_reg src ) -{ - emit_3ub(p, 0x66, X86_TWOB, 0x5B); - emit_modrm( p, dst, src ); -} - -void sse2_packssdw( struct x86_function *p, - struct x86_reg dst, - struct x86_reg src ) -{ - emit_3ub(p, 0x66, X86_TWOB, 0x6B); - emit_modrm( p, dst, src ); -} - -void sse2_packsswb( struct x86_function *p, - struct x86_reg dst, - struct x86_reg src ) -{ - emit_3ub(p, 0x66, X86_TWOB, 0x63); - emit_modrm( p, dst, src ); -} - -void sse2_packuswb( struct x86_function *p, - struct x86_reg dst, - struct x86_reg src ) -{ - emit_3ub(p, 0x66, X86_TWOB, 0x67); - emit_modrm( p, dst, src ); -} - -void sse2_rcpps( struct x86_function *p, - struct x86_reg dst, - struct x86_reg src ) -{ - emit_2ub(p, X86_TWOB, 0x53); - emit_modrm( p, dst, src ); -} - -void sse2_rcpss( struct x86_function *p, - struct x86_reg dst, - struct x86_reg src ) -{ - emit_3ub(p, 0xF3, X86_TWOB, 0x53); - emit_modrm( p, dst, src ); -} - -void sse2_movd( struct x86_function *p, - struct x86_reg dst, - struct x86_reg src ) -{ - emit_2ub(p, 0x66, X86_TWOB); - emit_op_modrm( p, 0x6e, 0x7e, dst, src ); -} - - - - -/*********************************************************************** - * x87 instructions - */ -void x87_fist( struct x86_function *p, struct x86_reg dst ) -{ - emit_1ub(p, 0xdb); - emit_modrm_noreg(p, 2, dst); -} - -void x87_fistp( struct x86_function *p, struct x86_reg dst ) -{ - emit_1ub(p, 0xdb); - emit_modrm_noreg(p, 3, dst); -} - -void x87_fild( struct x86_function *p, struct x86_reg arg ) -{ - emit_1ub(p, 0xdf); - emit_modrm_noreg(p, 0, arg); -} - -void x87_fldz( struct x86_function *p ) -{ - emit_2ub(p, 0xd9, 0xee); -} - - -void x87_fldcw( struct x86_function *p, struct x86_reg arg ) -{ - assert(arg.file == file_REG32); - assert(arg.mod != mod_REG); - emit_1ub(p, 0xd9); - emit_modrm_noreg(p, 5, arg); -} - -void x87_fld1( struct x86_function *p ) -{ - emit_2ub(p, 0xd9, 0xe8); -} - -void x87_fldl2e( struct x86_function *p ) -{ - emit_2ub(p, 0xd9, 0xea); -} - -void x87_fldln2( struct x86_function *p ) -{ - emit_2ub(p, 0xd9, 0xed); -} - -void x87_fwait( struct x86_function *p ) -{ - emit_1ub(p, 0x9b); -} - -void x87_fnclex( struct x86_function *p ) -{ - emit_2ub(p, 0xdb, 0xe2); -} - -void x87_fclex( struct x86_function *p ) -{ - x87_fwait(p); - x87_fnclex(p); -} - - -static void x87_arith_op( struct x86_function *p, struct x86_reg dst, struct x86_reg arg, - unsigned char dst0ub0, - unsigned char dst0ub1, - unsigned char arg0ub0, - unsigned char arg0ub1, - unsigned char argmem_noreg) -{ - assert(dst.file == file_x87); - - if (arg.file == file_x87) { - if (dst.idx == 0) - emit_2ub(p, dst0ub0, dst0ub1+arg.idx); - else if (arg.idx == 0) - emit_2ub(p, arg0ub0, arg0ub1+arg.idx); - else - assert(0); - } - else if (dst.idx == 0) { - assert(arg.file == file_REG32); - emit_1ub(p, 0xd8); - emit_modrm_noreg(p, argmem_noreg, arg); - } - else - assert(0); -} - -void x87_fmul( struct x86_function *p, struct x86_reg dst, struct x86_reg arg ) -{ - x87_arith_op(p, dst, arg, - 0xd8, 0xc8, - 0xdc, 0xc8, - 4); -} - -void x87_fsub( struct x86_function *p, struct x86_reg dst, struct x86_reg arg ) -{ - x87_arith_op(p, dst, arg, - 0xd8, 0xe0, - 0xdc, 0xe8, - 4); -} - -void x87_fsubr( struct x86_function *p, struct x86_reg dst, struct x86_reg arg ) -{ - x87_arith_op(p, dst, arg, - 0xd8, 0xe8, - 0xdc, 0xe0, - 5); -} - -void x87_fadd( struct x86_function *p, struct x86_reg dst, struct x86_reg arg ) -{ - x87_arith_op(p, dst, arg, - 0xd8, 0xc0, - 0xdc, 0xc0, - 0); -} - -void x87_fdiv( struct x86_function *p, struct x86_reg dst, struct x86_reg arg ) -{ - x87_arith_op(p, dst, arg, - 0xd8, 0xf0, - 0xdc, 0xf8, - 6); -} - -void x87_fdivr( struct x86_function *p, struct x86_reg dst, struct x86_reg arg ) -{ - x87_arith_op(p, dst, arg, - 0xd8, 0xf8, - 0xdc, 0xf0, - 7); -} - -void x87_fmulp( struct x86_function *p, struct x86_reg dst ) -{ - assert(dst.file == file_x87); - assert(dst.idx >= 1); - emit_2ub(p, 0xde, 0xc8+dst.idx); -} - -void x87_fsubp( struct x86_function *p, struct x86_reg dst ) -{ - assert(dst.file == file_x87); - assert(dst.idx >= 1); - emit_2ub(p, 0xde, 0xe8+dst.idx); -} - -void x87_fsubrp( struct x86_function *p, struct x86_reg dst ) -{ - assert(dst.file == file_x87); - assert(dst.idx >= 1); - emit_2ub(p, 0xde, 0xe0+dst.idx); -} - -void x87_faddp( struct x86_function *p, struct x86_reg dst ) -{ - assert(dst.file == file_x87); - assert(dst.idx >= 1); - emit_2ub(p, 0xde, 0xc0+dst.idx); -} - -void x87_fdivp( struct x86_function *p, struct x86_reg dst ) -{ - assert(dst.file == file_x87); - assert(dst.idx >= 1); - emit_2ub(p, 0xde, 0xf8+dst.idx); -} - -void x87_fdivrp( struct x86_function *p, struct x86_reg dst ) -{ - assert(dst.file == file_x87); - assert(dst.idx >= 1); - emit_2ub(p, 0xde, 0xf0+dst.idx); -} - -void x87_fucom( struct x86_function *p, struct x86_reg arg ) -{ - assert(arg.file == file_x87); - emit_2ub(p, 0xdd, 0xe0+arg.idx); -} - -void x87_fucomp( struct x86_function *p, struct x86_reg arg ) -{ - assert(arg.file == file_x87); - emit_2ub(p, 0xdd, 0xe8+arg.idx); -} - -void x87_fucompp( struct x86_function *p ) -{ - emit_2ub(p, 0xda, 0xe9); -} - -void x87_fxch( struct x86_function *p, struct x86_reg arg ) -{ - assert(arg.file == file_x87); - emit_2ub(p, 0xd9, 0xc8+arg.idx); -} - -void x87_fabs( struct x86_function *p ) -{ - emit_2ub(p, 0xd9, 0xe1); -} - -void x87_fchs( struct x86_function *p ) -{ - emit_2ub(p, 0xd9, 0xe0); -} - -void x87_fcos( struct x86_function *p ) -{ - emit_2ub(p, 0xd9, 0xff); -} - - -void x87_fprndint( struct x86_function *p ) -{ - emit_2ub(p, 0xd9, 0xfc); -} - -void x87_fscale( struct x86_function *p ) -{ - emit_2ub(p, 0xd9, 0xfd); -} - -void x87_fsin( struct x86_function *p ) -{ - emit_2ub(p, 0xd9, 0xfe); -} - -void x87_fsincos( struct x86_function *p ) -{ - emit_2ub(p, 0xd9, 0xfb); -} - -void x87_fsqrt( struct x86_function *p ) -{ - emit_2ub(p, 0xd9, 0xfa); -} - -void x87_fxtract( struct x86_function *p ) -{ - emit_2ub(p, 0xd9, 0xf4); -} - -/* st0 = (2^st0)-1 - * - * Restrictions: -1.0 <= st0 <= 1.0 - */ -void x87_f2xm1( struct x86_function *p ) -{ - emit_2ub(p, 0xd9, 0xf0); -} - -/* st1 = st1 * log2(st0); - * pop_stack; - */ -void x87_fyl2x( struct x86_function *p ) -{ - emit_2ub(p, 0xd9, 0xf1); -} - -/* st1 = st1 * log2(st0 + 1.0); - * pop_stack; - * - * A fast operation, with restrictions: -.29 < st0 < .29 - */ -void x87_fyl2xp1( struct x86_function *p ) -{ - emit_2ub(p, 0xd9, 0xf9); -} - - -void x87_fld( struct x86_function *p, struct x86_reg arg ) -{ - if (arg.file == file_x87) - emit_2ub(p, 0xd9, 0xc0 + arg.idx); - else { - emit_1ub(p, 0xd9); - emit_modrm_noreg(p, 0, arg); - } -} - -void x87_fst( struct x86_function *p, struct x86_reg dst ) -{ - if (dst.file == file_x87) - emit_2ub(p, 0xdd, 0xd0 + dst.idx); - else { - emit_1ub(p, 0xd9); - emit_modrm_noreg(p, 2, dst); - } -} - -void x87_fstp( struct x86_function *p, struct x86_reg dst ) -{ - if (dst.file == file_x87) - emit_2ub(p, 0xdd, 0xd8 + dst.idx); - else { - emit_1ub(p, 0xd9); - emit_modrm_noreg(p, 3, dst); - } -} - -void x87_fcom( struct x86_function *p, struct x86_reg dst ) -{ - if (dst.file == file_x87) - emit_2ub(p, 0xd8, 0xd0 + dst.idx); - else { - emit_1ub(p, 0xd8); - emit_modrm_noreg(p, 2, dst); - } -} - -void x87_fcomp( struct x86_function *p, struct x86_reg dst ) -{ - if (dst.file == file_x87) - emit_2ub(p, 0xd8, 0xd8 + dst.idx); - else { - emit_1ub(p, 0xd8); - emit_modrm_noreg(p, 3, dst); - } -} - - -void x87_fnstsw( struct x86_function *p, struct x86_reg dst ) -{ - assert(dst.file == file_REG32); - - if (dst.idx == reg_AX && - dst.mod == mod_REG) - emit_2ub(p, 0xdf, 0xe0); - else { - emit_1ub(p, 0xdd); - emit_modrm_noreg(p, 7, dst); - } -} - - - - -/*********************************************************************** - * MMX instructions - */ - -void mmx_emms( struct x86_function *p ) -{ - assert(p->need_emms); - emit_2ub(p, 0x0f, 0x77); - p->need_emms = 0; -} - -void mmx_packssdw( struct x86_function *p, - struct x86_reg dst, - struct x86_reg src ) -{ - assert(dst.file == file_MMX && - (src.file == file_MMX || src.mod != mod_REG)); - - p->need_emms = 1; - - emit_2ub(p, X86_TWOB, 0x6b); - emit_modrm( p, dst, src ); -} - -void mmx_packuswb( struct x86_function *p, - struct x86_reg dst, - struct x86_reg src ) -{ - assert(dst.file == file_MMX && - (src.file == file_MMX || src.mod != mod_REG)); - - p->need_emms = 1; - - emit_2ub(p, X86_TWOB, 0x67); - emit_modrm( p, dst, src ); -} - -void mmx_movd( struct x86_function *p, - struct x86_reg dst, - struct x86_reg src ) -{ - p->need_emms = 1; - emit_1ub(p, X86_TWOB); - emit_op_modrm( p, 0x6e, 0x7e, dst, src ); -} - -void mmx_movq( struct x86_function *p, - struct x86_reg dst, - struct x86_reg src ) -{ - p->need_emms = 1; - emit_1ub(p, X86_TWOB); - emit_op_modrm( p, 0x6f, 0x7f, dst, src ); -} - - -/*********************************************************************** - * Helper functions - */ - - -/* Retrieve a reference to one of the function arguments, taking into - * account any push/pop activity: - */ -struct x86_reg x86_fn_arg( struct x86_function *p, - unsigned arg ) -{ - return x86_make_disp(x86_make_reg(file_REG32, reg_SP), - p->stack_offset + arg * 4); /* ??? */ -} - - -void x86_init_func( struct x86_function *p ) -{ - p->size = 0; - p->store = NULL; - p->csr = p->store; -} - -int x86_init_func_size( struct x86_function *p, unsigned code_size ) -{ - p->size = code_size; - p->store = _mesa_exec_malloc(code_size); - p->csr = p->store; - return p->store != NULL; -} - -void x86_release_func( struct x86_function *p ) -{ - _mesa_exec_free(p->store); - p->store = NULL; - p->csr = NULL; - p->size = 0; -} - - -void (*x86_get_func( struct x86_function *p ))(void) -{ - if (DISASSEM && p->store) - printf("disassemble %p %p\n", p->store, p->csr); - return (void (*)(void)) (unsigned long) p->store; -} - -#else - -void x86sse_dummy( void ) -{ -} - -#endif - -#else /* USE_X86_ASM */ - -int x86sse_c_dummy_var; /* silence warning */ - -#endif /* USE_X86_ASM */ diff --git a/dll/opengl/mesa/x86/rtasm/x86sse.h b/dll/opengl/mesa/x86/rtasm/x86sse.h deleted file mode 100644 index 9c518820a17..00000000000 --- a/dll/opengl/mesa/x86/rtasm/x86sse.h +++ /dev/null @@ -1,256 +0,0 @@ - -#ifndef _X86SSE_H_ -#define _X86SSE_H_ - -#if defined(__i386__) || defined(__386__) - -/* It is up to the caller to ensure that instructions issued are - * suitable for the host cpu. There are no checks made in this module - * for mmx/sse/sse2 support on the cpu. - */ -struct x86_reg { - unsigned file:3; - unsigned idx:3; - unsigned mod:2; /* mod_REG if this is just a register */ - int disp:24; /* only +/- 23bits of offset - should be enough... */ -}; - -struct x86_function { - unsigned size; - unsigned char *store; - unsigned char *csr; - unsigned stack_offset; - int need_emms; - const char *fn; -}; - -enum x86_reg_file { - file_REG32, - file_MMX, - file_XMM, - file_x87 -}; - -/* Values for mod field of modr/m byte - */ -enum x86_reg_mod { - mod_INDIRECT, - mod_DISP8, - mod_DISP32, - mod_REG -}; - -enum x86_reg_name { - reg_AX, - reg_CX, - reg_DX, - reg_BX, - reg_SP, - reg_BP, - reg_SI, - reg_DI -}; - - -enum x86_cc { - cc_O, /* overflow */ - cc_NO, /* not overflow */ - cc_NAE, /* not above or equal / carry */ - cc_AE, /* above or equal / not carry */ - cc_E, /* equal / zero */ - cc_NE /* not equal / not zero */ -}; - -enum sse_cc { - cc_Equal, - cc_LessThan, - cc_LessThanEqual, - cc_Unordered, - cc_NotEqual, - cc_NotLessThan, - cc_NotLessThanEqual, - cc_Ordered -}; - -#define cc_Z cc_E -#define cc_NZ cc_NE - -/* Begin/end/retrieve function creation: - */ - - -void x86_init_func( struct x86_function *p ); -int x86_init_func_size( struct x86_function *p, unsigned code_size ); -void x86_release_func( struct x86_function *p ); -void (*x86_get_func( struct x86_function *p ))( void ); - - - -/* Create and manipulate registers and regmem values: - */ -struct x86_reg x86_make_reg( enum x86_reg_file file, - enum x86_reg_name idx ); - -struct x86_reg x86_make_disp( struct x86_reg reg, - int disp ); - -struct x86_reg x86_deref( struct x86_reg reg ); - -struct x86_reg x86_get_base_reg( struct x86_reg reg ); - - -/* Labels, jumps and fixup: - */ -unsigned char *x86_get_label( struct x86_function *p ); - -void x86_jcc( struct x86_function *p, - enum x86_cc cc, - unsigned char *label ); - -unsigned char *x86_jcc_forward( struct x86_function *p, - enum x86_cc cc ); - -unsigned char *x86_jmp_forward( struct x86_function *p); - -unsigned char *x86_call_forward( struct x86_function *p); - -void x86_fixup_fwd_jump( struct x86_function *p, - unsigned char *fixup ); - -void x86_jmp( struct x86_function *p, unsigned char *label ); - -/* void x86_call( struct x86_function *p, void (*label)() ); */ -void x86_call( struct x86_function *p, struct x86_reg reg); - -/* michal: - * Temporary. As I need immediate operands, and dont want to mess with the codegen, - * I load the immediate into general purpose register and use it. - */ -void x86_mov_reg_imm( struct x86_function *p, struct x86_reg dst, int imm ); - - -/* Macro for sse_shufps() and sse2_pshufd(): - */ -#define SHUF(_x,_y,_z,_w) (((_x)<<0) | ((_y)<<2) | ((_z)<<4) | ((_w)<<6)) -#define SHUF_NOOP RSW(0,1,2,3) -#define GET_SHUF(swz, idx) (((swz) >> ((idx)*2)) & 0x3) - -void mmx_emms( struct x86_function *p ); -void mmx_movd( struct x86_function *p, struct x86_reg dst, struct x86_reg src ); -void mmx_movq( struct x86_function *p, struct x86_reg dst, struct x86_reg src ); -void mmx_packssdw( struct x86_function *p, struct x86_reg dst, struct x86_reg src ); -void mmx_packuswb( struct x86_function *p, struct x86_reg dst, struct x86_reg src ); - -void sse2_cvtps2dq( struct x86_function *p, struct x86_reg dst, struct x86_reg src ); -void sse2_cvttps2dq( struct x86_function *p, struct x86_reg dst, struct x86_reg src ); -void sse2_movd( struct x86_function *p, struct x86_reg dst, struct x86_reg src ); -void sse2_packssdw( struct x86_function *p, struct x86_reg dst, struct x86_reg src ); -void sse2_packsswb( struct x86_function *p, struct x86_reg dst, struct x86_reg src ); -void sse2_packuswb( struct x86_function *p, struct x86_reg dst, struct x86_reg src ); -void sse2_pshufd( struct x86_function *p, struct x86_reg dest, struct x86_reg arg0, - unsigned char shuf ); -void sse2_rcpps( struct x86_function *p, struct x86_reg dst, struct x86_reg src ); -void sse2_rcpss( struct x86_function *p, struct x86_reg dst, struct x86_reg src ); - -void sse_addps( struct x86_function *p, struct x86_reg dst, struct x86_reg src ); -void sse_addss( struct x86_function *p, struct x86_reg dst, struct x86_reg src ); -void sse_cvtps2pi( struct x86_function *p, struct x86_reg dst, struct x86_reg src ); -void sse_divss( struct x86_function *p, struct x86_reg dst, struct x86_reg src ); -void sse_andnps( struct x86_function *p, struct x86_reg dst, struct x86_reg src ); -void sse_andps( struct x86_function *p, struct x86_reg dst, struct x86_reg src ); -void sse_cmpps( struct x86_function *p, struct x86_reg dst, struct x86_reg src, - unsigned char cc ); -void sse_maxps( struct x86_function *p, struct x86_reg dst, struct x86_reg src ); -void sse_maxss( struct x86_function *p, struct x86_reg dst, struct x86_reg src ); -void sse_minps( struct x86_function *p, struct x86_reg dst, struct x86_reg src ); -void sse_movaps( struct x86_function *p, struct x86_reg dst, struct x86_reg src ); -void sse_movhlps( struct x86_function *p, struct x86_reg dst, struct x86_reg src ); -void sse_movhps( struct x86_function *p, struct x86_reg dst, struct x86_reg src ); -void sse_movlhps( struct x86_function *p, struct x86_reg dst, struct x86_reg src ); -void sse_movlps( struct x86_function *p, struct x86_reg dst, struct x86_reg src ); -void sse_movss( struct x86_function *p, struct x86_reg dst, struct x86_reg src ); -void sse_movups( struct x86_function *p, struct x86_reg dst, struct x86_reg src ); -void sse_mulps( struct x86_function *p, struct x86_reg dst, struct x86_reg src ); -void sse_mulss( struct x86_function *p, struct x86_reg dst, struct x86_reg src ); -void sse_orps( struct x86_function *p, struct x86_reg dst, struct x86_reg src ); -void sse_xorps( struct x86_function *p, struct x86_reg dst, struct x86_reg src ); -void sse_subps( struct x86_function *p, struct x86_reg dst, struct x86_reg src ); -void sse_rsqrtps( struct x86_function *p, struct x86_reg dst, struct x86_reg src ); -void sse_rsqrtss( struct x86_function *p, struct x86_reg dst, struct x86_reg src ); -void sse_shufps( struct x86_function *p, struct x86_reg dest, struct x86_reg arg0, - unsigned char shuf ); -void sse_pmovmskb( struct x86_function *p, struct x86_reg dest, struct x86_reg src ); - -void x86_add( struct x86_function *p, struct x86_reg dst, struct x86_reg src ); -void x86_and( struct x86_function *p, struct x86_reg dst, struct x86_reg src ); -void x86_cmp( struct x86_function *p, struct x86_reg dst, struct x86_reg src ); -void x86_dec( struct x86_function *p, struct x86_reg reg ); -void x86_inc( struct x86_function *p, struct x86_reg reg ); -void x86_lea( struct x86_function *p, struct x86_reg dst, struct x86_reg src ); -void x86_mov( struct x86_function *p, struct x86_reg dst, struct x86_reg src ); -void x86_mul( struct x86_function *p, struct x86_reg src ); -void x86_or( struct x86_function *p, struct x86_reg dst, struct x86_reg src ); -void x86_pop( struct x86_function *p, struct x86_reg reg ); -void x86_push( struct x86_function *p, struct x86_reg reg ); -void x86_ret( struct x86_function *p ); -void x86_sub( struct x86_function *p, struct x86_reg dst, struct x86_reg src ); -void x86_test( struct x86_function *p, struct x86_reg dst, struct x86_reg src ); -void x86_xor( struct x86_function *p, struct x86_reg dst, struct x86_reg src ); -void x86_sahf( struct x86_function *p ); - -void x87_f2xm1( struct x86_function *p ); -void x87_fabs( struct x86_function *p ); -void x87_fadd( struct x86_function *p, struct x86_reg dst, struct x86_reg arg ); -void x87_faddp( struct x86_function *p, struct x86_reg dst ); -void x87_fchs( struct x86_function *p ); -void x87_fclex( struct x86_function *p ); -void x87_fcom( struct x86_function *p, struct x86_reg dst ); -void x87_fcomp( struct x86_function *p, struct x86_reg dst ); -void x87_fcos( struct x86_function *p ); -void x87_fdiv( struct x86_function *p, struct x86_reg dst, struct x86_reg arg ); -void x87_fdivp( struct x86_function *p, struct x86_reg dst ); -void x87_fdivr( struct x86_function *p, struct x86_reg dst, struct x86_reg arg ); -void x87_fdivrp( struct x86_function *p, struct x86_reg dst ); -void x87_fild( struct x86_function *p, struct x86_reg arg ); -void x87_fist( struct x86_function *p, struct x86_reg dst ); -void x87_fistp( struct x86_function *p, struct x86_reg dst ); -void x87_fld( struct x86_function *p, struct x86_reg arg ); -void x87_fld1( struct x86_function *p ); -void x87_fldcw( struct x86_function *p, struct x86_reg arg ); -void x87_fldl2e( struct x86_function *p ); -void x87_fldln2( struct x86_function *p ); -void x87_fldz( struct x86_function *p ); -void x87_fmul( struct x86_function *p, struct x86_reg dst, struct x86_reg arg ); -void x87_fmulp( struct x86_function *p, struct x86_reg dst ); -void x87_fnclex( struct x86_function *p ); -void x87_fprndint( struct x86_function *p ); -void x87_fscale( struct x86_function *p ); -void x87_fsin( struct x86_function *p ); -void x87_fsincos( struct x86_function *p ); -void x87_fsqrt( struct x86_function *p ); -void x87_fst( struct x86_function *p, struct x86_reg dst ); -void x87_fstp( struct x86_function *p, struct x86_reg dst ); -void x87_fsub( struct x86_function *p, struct x86_reg dst, struct x86_reg arg ); -void x87_fsubp( struct x86_function *p, struct x86_reg dst ); -void x87_fsubr( struct x86_function *p, struct x86_reg dst, struct x86_reg arg ); -void x87_fsubrp( struct x86_function *p, struct x86_reg dst ); -void x87_fxch( struct x86_function *p, struct x86_reg dst ); -void x87_fxtract( struct x86_function *p ); -void x87_fyl2x( struct x86_function *p ); -void x87_fyl2xp1( struct x86_function *p ); -void x87_fwait( struct x86_function *p ); -void x87_fnstsw( struct x86_function *p, struct x86_reg dst ); -void x87_fucompp( struct x86_function *p ); -void x87_fucomp( struct x86_function *p, struct x86_reg arg ); -void x87_fucom( struct x86_function *p, struct x86_reg arg ); - - - -/* Retrieve a reference to one of the function arguments, taking into - * account any push/pop activity. Note - doesn't track explicit - * manipulation of ESP by other instructions. - */ -struct x86_reg x86_fn_arg( struct x86_function *p, unsigned arg ); - -#endif -#endif diff --git a/dll/opengl/mesa/x86/sse.c b/dll/opengl/mesa/x86/sse.c deleted file mode 100644 index aef15b53152..00000000000 --- a/dll/opengl/mesa/x86/sse.c +++ /dev/null @@ -1,123 +0,0 @@ -/* - * Mesa 3-D graphics library - * Version: 6.0 - * - * Copyright (C) 1999-2004 Brian Paul All Rights Reserved. - * - * Permission is hereby granted, free of charge, to any person obtaining a - * copy of this software and associated documentation files (the "Software"), - * to deal in the Software without restriction, including without limitation - * the rights to use, copy, modify, merge, publish, distribute, sublicense, - * and/or sell copies of the Software, and to permit persons to whom the - * Software is furnished to do so, subject to the following conditions: - * - * The above copyright notice and this permission notice shall be included - * in all copies or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS - * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL - * BRIAN PAUL BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN - * AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN - * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. - */ - -/* - * PentiumIII-SIMD (SSE) optimizations contributed by - * Andre Werthmann - */ - -#include "main/glheader.h" -#include "main/context.h" -#include "math/m_xform.h" -#include "tnl/t_context.h" - -#include "sse.h" -#include "x86_xform.h" - -#ifdef DEBUG_MATH -#include "math/m_debug.h" -#endif - - -#ifdef USE_SSE_ASM -DECLARE_XFORM_GROUP( sse, 2 ) -DECLARE_XFORM_GROUP( sse, 3 ) - -#if 1 -/* Some functions are not written in SSE-assembly, because the fpu ones are faster */ -extern void _ASMAPI _mesa_sse_transform_normals_no_rot( NORM_ARGS ); -extern void _ASMAPI _mesa_sse_transform_rescale_normals( NORM_ARGS ); -extern void _ASMAPI _mesa_sse_transform_rescale_normals_no_rot( NORM_ARGS ); - -extern void _ASMAPI _mesa_sse_transform_points4_general( XFORM_ARGS ); -extern void _ASMAPI _mesa_sse_transform_points4_3d( XFORM_ARGS ); -/* XXX this function segfaults, see below */ -extern void _ASMAPI _mesa_sse_transform_points4_identity( XFORM_ARGS ); -/* XXX this one works, see below */ -extern void _ASMAPI _mesa_x86_transform_points4_identity( XFORM_ARGS ); -#else -DECLARE_NORM_GROUP( sse ) -#endif - - -extern void _ASMAPI -_mesa_v16_sse_general_xform( GLfloat *first_vert, - const GLfloat *m, - const GLfloat *src, - GLuint src_stride, - GLuint count ); - -extern void _ASMAPI -_mesa_sse_project_vertices( GLfloat *first, - GLfloat *last, - const GLfloat *m, - GLuint stride ); - -extern void _ASMAPI -_mesa_sse_project_clipped_vertices( GLfloat *first, - GLfloat *last, - const GLfloat *m, - GLuint stride, - const GLubyte *clipmask ); -#endif - - -void _mesa_init_sse_transform_asm( void ) -{ -#ifdef USE_SSE_ASM - ASSIGN_XFORM_GROUP( sse, 2 ); - ASSIGN_XFORM_GROUP( sse, 3 ); - -#if 1 - /* TODO: Finish these off. - */ - _mesa_transform_tab[4][MATRIX_GENERAL] = - _mesa_sse_transform_points4_general; - _mesa_transform_tab[4][MATRIX_3D] = - _mesa_sse_transform_points4_3d; - /* XXX NOTE: _mesa_sse_transform_points4_identity segfaults with the - conformance tests, so use the x86 version. - */ - _mesa_transform_tab[4][MATRIX_IDENTITY] = - _mesa_x86_transform_points4_identity;/*_mesa_sse_transform_points4_identity;*/ - - _mesa_normal_tab[NORM_TRANSFORM_NO_ROT] = - _mesa_sse_transform_normals_no_rot; - _mesa_normal_tab[NORM_TRANSFORM | NORM_RESCALE] = - _mesa_sse_transform_rescale_normals; - _mesa_normal_tab[NORM_TRANSFORM_NO_ROT | NORM_RESCALE] = - _mesa_sse_transform_rescale_normals_no_rot; -#else - ASSIGN_XFORM_GROUP( sse, 4 ); - - ASSIGN_NORM_GROUP( sse ); -#endif - -#ifdef DEBUG_MATH - _math_test_all_transform_functions( "SSE" ); - _math_test_all_normal_transform_functions( "SSE" ); -#endif -#endif -} - diff --git a/dll/opengl/mesa/x86/sse.h b/dll/opengl/mesa/x86/sse.h deleted file mode 100644 index e92ddc13941..00000000000 --- a/dll/opengl/mesa/x86/sse.h +++ /dev/null @@ -1,36 +0,0 @@ - -/* - * Mesa 3-D graphics library - * Version: 3.5 - * - * Copyright (C) 1999-2001 Brian Paul All Rights Reserved. - * - * Permission is hereby granted, free of charge, to any person obtaining a - * copy of this software and associated documentation files (the "Software"), - * to deal in the Software without restriction, including without limitation - * the rights to use, copy, modify, merge, publish, distribute, sublicense, - * and/or sell copies of the Software, and to permit persons to whom the - * Software is furnished to do so, subject to the following conditions: - * - * The above copyright notice and this permission notice shall be included - * in all copies or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS - * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL - * BRIAN PAUL BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN - * AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN - * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. - */ - -/* - * PentiumIII-SIMD (SSE) optimizations contributed by - * Andre Werthmann - */ - -#ifndef __SSE_H__ -#define __SSE_H__ - -void _mesa_init_sse_transform_asm( void ); - -#endif diff --git a/dll/opengl/mesa/x86/sse_normal.S b/dll/opengl/mesa/x86/sse_normal.S deleted file mode 100644 index a8c0d38c7e8..00000000000 --- a/dll/opengl/mesa/x86/sse_normal.S +++ /dev/null @@ -1,261 +0,0 @@ - -/* - * Mesa 3-D graphics library - * Version: 3.5 - * - * Copyright (C) 1999-2001 Brian Paul All Rights Reserved. - * - * Permission is hereby granted, free of charge, to any person obtaining a - * copy of this software and associated documentation files (the "Software"), - * to deal in the Software without restriction, including without limitation - * the rights to use, copy, modify, merge, publish, distribute, sublicense, - * and/or sell copies of the Software, and to permit persons to whom the - * Software is furnished to do so, subject to the following conditions: - * - * The above copyright notice and this permission notice shall be included - * in all copies or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS - * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL - * BRIAN PAUL BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN - * AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN - * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. - */ - -/** TODO: - * - insert PREFETCH instructions to avoid cache-misses ! - * - some more optimizations are possible... - * - for 40-50% more performance in the SSE-functions, the - * data (trans-matrix, src_vert, dst_vert) needs to be 16byte aligned ! - */ - -#ifdef USE_SSE_ASM -#include "assyntax.h" -#include "matypes.h" -#include "norm_args.h" - - SEG_TEXT - -#define M(i) REGOFF(i * 4, EDX) -#define S(i) REGOFF(i * 4, ESI) -#define D(i) REGOFF(i * 4, EDI) -#define STRIDE REGOFF(12, ESI) - - -ALIGNTEXT16 -GLOBL GLNAME(_mesa_sse_transform_rescale_normals_no_rot) -HIDDEN(_mesa_sse_transform_rescale_normals_no_rot) -GLNAME(_mesa_sse_transform_rescale_normals_no_rot): - -#define FRAME_OFFSET 8 - PUSH_L ( ESI ) - PUSH_L ( EDI ) - - MOV_L ( ARG_IN, ESI ) /* ptr to source GLvector3f */ - MOV_L ( ARG_DEST, EDI ) /* ptr to dest GLvector3f */ - - MOV_L ( ARG_MAT, EDX ) /* ptr to matrix */ - MOV_L ( REGOFF(MATRIX_INV, EDX), EDX) /* matrix->inv */ - - MOV_L ( REGOFF(V4F_COUNT, ESI), ECX ) /* source count */ - - TEST_L ( ECX, ECX ) - JZ( LLBL(K_G3TRNNRR_finish) ) /* count was zero; go to finish */ - - MOV_L ( STRIDE, EAX ) /* stride */ - MOV_L ( ECX, REGOFF(V4F_COUNT, EDI) ) /* set dest-count */ - - IMUL_L( CONST(16), ECX ) /* count *= 16 */ - MOV_L( REGOFF(V4F_START, ESI), ESI ) /* ptr to first source vertex */ - - MOV_L( REGOFF(V4F_START, EDI), EDI ) /* ptr to first dest vertex */ - ADD_L( EDI, ECX ) /* count += dest ptr */ - -ALIGNTEXT32 - MOVSS ( M(0), XMM1 ) /* m0 */ - MOVSS ( M(5), XMM2 ) /* m5 */ - UNPCKLPS( XMM2, XMM1 ) /* m5 | m0 */ - MOVSS ( ARG_SCALE, XMM0 ) /* scale */ - SHUFPS ( CONST(0x0), XMM0, XMM0 ) /* scale | scale */ - MULPS ( XMM0, XMM1 ) /* m5*scale | m0*scale */ - MULSS ( M(10), XMM0 ) /* m10*scale */ - -ALIGNTEXT32 -LLBL(K_G3TRNNRR_top): - MOVLPS ( S(0), XMM2 ) /* uy | ux */ - MULPS ( XMM1, XMM2 ) /* uy*m5*scale | ux*m0*scale */ - MOVLPS ( XMM2, D(0) ) /* ->D(1) | D(0) */ - - MOVSS ( S(2), XMM2 ) /* uz */ - MULSS ( XMM0, XMM2 ) /* uz*m10*scale */ - MOVSS ( XMM2, D(2) ) /* ->D(2) */ - -LLBL(K_G3TRNNRR_skip): - ADD_L ( CONST(16), EDI ) - ADD_L ( EAX, ESI ) - CMP_L ( ECX, EDI ) - JNE ( LLBL(K_G3TRNNRR_top) ) - -LLBL(K_G3TRNNRR_finish): - POP_L ( EDI ) - POP_L ( ESI ) - RET -#undef FRAME_OFFSET - - - -ALIGNTEXT16 -GLOBL GLNAME(_mesa_sse_transform_rescale_normals) -HIDDEN(_mesa_sse_transform_rescale_normals) -GLNAME(_mesa_sse_transform_rescale_normals): - -#define FRAME_OFFSET 8 - PUSH_L ( ESI ) - PUSH_L ( EDI ) - - MOV_L ( ARG_IN, ESI ) /* ptr to source GLvector3f */ - MOV_L ( ARG_DEST, EDI ) /* ptr to dest GLvector3f */ - - MOV_L ( ARG_MAT, EDX ) /* ptr to matrix */ - MOV_L ( REGOFF(MATRIX_INV, EDX), EDX) /* matrix->inv */ - - MOV_L ( REGOFF(V4F_COUNT, ESI), ECX ) /* source count */ - - TEST_L ( ECX, ECX ) - JZ( LLBL(K_G3TRNR_finish) ) /* count was zero; go to finish */ - - MOV_L ( STRIDE, EAX ) /* stride */ - MOV_L ( ECX, REGOFF(V4F_COUNT, EDI) ) /* set dest-count */ - - IMUL_L( CONST(16), ECX ) /* count *= 16 */ - MOV_L( REGOFF(V4F_START, ESI), ESI ) /* ptr to first source vertex */ - - MOV_L( REGOFF(V4F_START, EDI), EDI ) /* ptr to first dest vertex */ - ADD_L( EDI, ECX ) /* count += dest ptr */ - -ALIGNTEXT32 - MOVSS ( M(0), XMM0 ) /* m0 */ - MOVSS ( M(4), XMM1 ) /* m4 */ - UNPCKLPS( XMM1, XMM0 ) /* m4 | m0 */ - - MOVSS ( ARG_SCALE, XMM4 ) /* scale */ - SHUFPS ( CONST(0x0), XMM4, XMM4 ) /* scale | scale */ - - MULPS ( XMM4, XMM0 ) /* m4*scale | m0*scale */ - MOVSS ( M(1), XMM1 ) /* m1 */ - MOVSS ( M(5), XMM2 ) /* m5 */ - UNPCKLPS( XMM2, XMM1 ) /* m5 | m1 */ - MULPS ( XMM4, XMM1 ) /* m5*scale | m1*scale */ - MOVSS ( M(2), XMM2 ) /* m2 */ - MOVSS ( M(6), XMM3 ) /* m6 */ - UNPCKLPS( XMM3, XMM2 ) /* m6 | m2 */ - MULPS ( XMM4, XMM2 ) /* m6*scale | m2*scale */ - - MOVSS ( M(8), XMM6 ) /* m8 */ - MULSS ( ARG_SCALE, XMM6 ) /* m8*scale */ - MOVSS ( M(9), XMM7 ) /* m9 */ - MULSS ( ARG_SCALE, XMM7 ) /* m9*scale */ - -ALIGNTEXT32 -LLBL(K_G3TRNR_top): - MOVSS ( S(0), XMM3 ) /* ux */ - SHUFPS ( CONST(0x0), XMM3, XMM3 ) /* ux | ux */ - MULPS ( XMM0, XMM3 ) /* ux*m4 | ux*m0 */ - MOVSS ( S(1), XMM4 ) /* uy */ - SHUFPS ( CONST(0x0), XMM4, XMM4 ) /* uy | uy */ - MULPS ( XMM1, XMM4 ) /* uy*m5 | uy*m1 */ - MOVSS ( S(2), XMM5 ) /* uz */ - SHUFPS ( CONST(0x0), XMM5, XMM5 ) /* uz | uz */ - MULPS ( XMM2, XMM5 ) /* uz*m6 | uz*m2 */ - - ADDPS ( XMM4, XMM3 ) - ADDPS ( XMM5, XMM3 ) - MOVLPS ( XMM3, D(0) ) - - MOVSS ( M(10), XMM3 ) /* m10 */ - MULSS ( ARG_SCALE, XMM3 ) /* m10*scale */ - MULSS ( S(2), XMM3 ) /* m10*scale*uz */ - MOVSS ( S(1), XMM4 ) /* uy */ - MULSS ( XMM7, XMM4 ) /* uy*m9*scale */ - MOVSS ( S(0), XMM5 ) /* ux */ - MULSS ( XMM6, XMM5 ) /* ux*m8*scale */ - - ADDSS ( XMM4, XMM3 ) - ADDSS ( XMM5, XMM3 ) - MOVSS ( XMM3, D(2) ) - -LLBL(K_G3TRNR_skip): - ADD_L ( CONST(16), EDI ) - ADD_L ( EAX, ESI ) - CMP_L ( ECX, EDI ) - JNE ( LLBL(K_G3TRNR_top) ) - -LLBL(K_G3TRNR_finish): - POP_L ( EDI ) - POP_L ( ESI ) - RET -#undef FRAME_OFFSET - - -ALIGNTEXT16 -GLOBL GLNAME(_mesa_sse_transform_normals_no_rot) -HIDDEN(_mesa_sse_transform_normals_no_rot) -GLNAME(_mesa_sse_transform_normals_no_rot): - -#define FRAME_OFFSET 8 - PUSH_L ( ESI ) - PUSH_L ( EDI ) - - MOV_L ( ARG_IN, ESI ) /* ptr to source GLvector3f */ - MOV_L ( ARG_DEST, EDI ) /* ptr to dest GLvector3f */ - - MOV_L ( ARG_MAT, EDX ) /* ptr to matrix */ - MOV_L ( REGOFF(MATRIX_INV, EDX), EDX) /* matrix->inv */ - - MOV_L ( REGOFF(V4F_COUNT, ESI), ECX ) /* source count */ - - TEST_L ( ECX, ECX ) - JZ( LLBL(K_G3TNNRR_finish) ) /* count was zero; go to finish */ - - MOV_L ( STRIDE, EAX ) /* stride */ - MOV_L ( ECX, REGOFF(V4F_COUNT, EDI) ) /* set dest-count */ - - IMUL_L( CONST(16), ECX ) /* count *= 16 */ - MOV_L( REGOFF(V4F_START, ESI), ESI ) /* ptr to first source vertex */ - - MOV_L( REGOFF(V4F_START, EDI), EDI ) /* ptr to first dest vertex */ - ADD_L( EDI, ECX ) /* count += dest ptr */ - -ALIGNTEXT32 - MOVSS( M(0), XMM0 ) /* m0 */ - MOVSS( M(5), XMM1 ) /* m5 */ - UNPCKLPS( XMM1, XMM0 ) /* m5 | m0 */ - MOVSS( M(10), XMM1 ) /* m10 */ - -ALIGNTEXT32 -LLBL(K_G3TNNRR_top): - MOVLPS( S(0), XMM2 ) /* uy | ux */ - MULPS( XMM0, XMM2 ) /* uy*m5 | ux*m0 */ - MOVLPS( XMM2, D(0) ) - - MOVSS( S(2), XMM2 ) /* uz */ - MULSS( XMM1, XMM2 ) /* uz*m10 */ - MOVSS( XMM2, D(2) ) - -LLBL(K_G3TNNRR_skip): - ADD_L ( CONST(16), EDI ) - ADD_L ( EAX, ESI ) - CMP_L ( ECX, EDI ) - JNE ( LLBL(K_G3TNNRR_top) ) - -LLBL(K_G3TNNRR_finish): - POP_L ( EDI ) - POP_L ( ESI ) - RET -#undef FRAME_OFFSET -#endif - -#if defined (__ELF__) && defined (__linux__) - .section .note.GNU-stack,"",%progbits -#endif diff --git a/dll/opengl/mesa/x86/sse_xform1.S b/dll/opengl/mesa/x86/sse_xform1.S deleted file mode 100644 index 4aa9de607c3..00000000000 --- a/dll/opengl/mesa/x86/sse_xform1.S +++ /dev/null @@ -1,446 +0,0 @@ - -/* - * Mesa 3-D graphics library - * Version: 3.5 - * - * Copyright (C) 1999-2001 Brian Paul All Rights Reserved. - * - * Permission is hereby granted, free of charge, to any person obtaining a - * copy of this software and associated documentation files (the "Software"), - * to deal in the Software without restriction, including without limitation - * the rights to use, copy, modify, merge, publish, distribute, sublicense, - * and/or sell copies of the Software, and to permit persons to whom the - * Software is furnished to do so, subject to the following conditions: - * - * The above copyright notice and this permission notice shall be included - * in all copies or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS - * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL - * BRIAN PAUL BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN - * AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN - * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. - */ - -/** TODO: - * - insert PREFETCH instructions to avoid cache-misses ! - * - some more optimizations are possible... - * - for 40-50% more performance in the SSE-functions, the - * data (trans-matrix, src_vert, dst_vert) needs to be 16byte aligned ! - */ - -#ifdef USE_SSE_ASM -#include "assyntax.h" -#include "matypes.h" -#include "xform_args.h" - - SEG_TEXT - -#define S(i) REGOFF(i * 4, ESI) -#define D(i) REGOFF(i * 4, EDI) -#define M(i) REGOFF(i * 4, EDX) - - -ALIGNTEXT4 -GLOBL GLNAME(_mesa_sse_transform_points1_general) -HIDDEN( _mesa_sse_transform_points1_general ) -GLNAME( _mesa_sse_transform_points1_general ): - -#define FRAME_OFFSET 8 - PUSH_L ( ESI ) - PUSH_L ( EDI ) - - MOV_L( REGOFF(OFFSET_SOURCE+8, ESP), ESI ) /* ptr to source GLvector4f */ - MOV_L( REGOFF(OFFSET_DEST+8, ESP), EDI ) /* ptr to dest GLvector4f */ - - MOV_L( ARG_MATRIX, EDX ) /* ptr to matrix */ - MOV_L( REGOFF(V4F_COUNT, ESI), ECX ) /* source count */ - - CMP_L( CONST(0), ECX ) /* count == 0 ? */ - JE( LLBL(K_GTP1GR_finish) ) /* yes -> nothing to do. */ - - MOV_L( REGOFF(V4F_STRIDE, ESI), EAX ) /* stride */ - OR_L( CONST(VEC_SIZE_4), REGOFF(V4F_FLAGS, EDI) ) /* set dest flags */ - - MOV_L( ECX, REGOFF(V4F_COUNT, EDI) ) /* set dest count */ - MOV_L( CONST(4), REGOFF(V4F_SIZE, EDI) ) /* set dest size */ - - SHL_L( CONST(4), ECX ) /* count *= 16 */ - MOV_L( REGOFF(V4F_START, ESI), ESI ) /* ptr to first source vertex */ - - MOV_L( REGOFF(V4F_START, EDI), EDI ) /* ptr to first dest vertex */ - ADD_L( EDI, ECX ) /* count += dest ptr */ - - -ALIGNTEXT32 - MOVAPS( M(0), XMM0 ) /* m3 | m2 | m1 | m0 */ - MOVAPS( M(12), XMM1 ) /* m15 | m14 | m13 | m12 */ - -ALIGNTEXT32 -LLBL(K_GTP1GR_top): - MOVSS( S(0), XMM2 ) /* ox */ - SHUFPS( CONST(0x0), XMM2, XMM2 ) /* ox | ox | ox | ox */ - MULPS( XMM0, XMM2 ) /* ox*m3 | ox*m2 | ox*m1 | ox*m0 */ - ADDPS( XMM1, XMM2 ) /* + | + | + | + */ - MOVUPS( XMM2, D(0) ) - -LLBL(K_GTP1GR_skip): - ADD_L ( CONST(16), EDI ) - ADD_L ( EAX, ESI ) - CMP_L ( ECX, EDI ) - JNE ( LLBL(K_GTP1GR_top) ) - -LLBL(K_GTP1GR_finish): - POP_L ( EDI ) - POP_L ( ESI ) - RET -#undef FRAME_OFFSET - - - -ALIGNTEXT4 -GLOBL GLNAME(_mesa_sse_transform_points1_identity) -HIDDEN(_mesa_sse_transform_points1_identity) -GLNAME( _mesa_sse_transform_points1_identity ): - -#define FRAME_OFFSET 8 - PUSH_L ( ESI ) - PUSH_L ( EDI ) - - MOV_L( REGOFF(OFFSET_SOURCE+8, ESP), ESI ) /* ptr to source GLvector4f */ - MOV_L( REGOFF(OFFSET_DEST+8, ESP), EDI ) /* ptr to dest GLvector4f */ - - MOV_L( REGOFF(V4F_COUNT, ESI), ECX ) /* source count */ - - TEST_L( ECX, ECX) - JZ( LLBL(K_GTP1IR_finish) ) /* count was zero; go to finish */ - - MOV_L( REGOFF(V4F_STRIDE, ESI), EAX ) /* stride */ - OR_L( CONST(VEC_SIZE_1), REGOFF(V4F_FLAGS, EDI) ) /* set dest flags */ - - MOV_L( ECX, REGOFF(V4F_COUNT, EDI) ) /* set dest count */ - MOV_L( CONST(1), REGOFF(V4F_SIZE, EDI) ) /* set dest size */ - - SHL_L( CONST(4), ECX ) /* count *= 16 */ - MOV_L( REGOFF(V4F_START, ESI), ESI ) /* ptr to first source vertex */ - - MOV_L( REGOFF(V4F_START, EDI), EDI ) /* ptr to first dest vertex */ - ADD_L( EDI, ECX ) /* count += dest ptr */ - - CMP_L( ESI, EDI ) - JE( LLBL(K_GTP1IR_finish) ) - - -ALIGNTEXT32 -LLBL(K_GTP1IR_top): - MOV_L( S(0), EDX ) - MOV_L( EDX, D(0) ) - -LLBL(K_GTP1IR_skip): - ADD_L ( CONST(16), EDI ) - ADD_L ( EAX, ESI ) - CMP_L ( ECX, EDI ) - JNE ( LLBL(K_GTP1IR_top) ) - -LLBL(K_GTP1IR_finish): - POP_L ( EDI ) - POP_L ( ESI ) - RET -#undef FRAME_OFFSET - - - -ALIGNTEXT4 -GLOBL GLNAME(_mesa_sse_transform_points1_3d_no_rot) -HIDDEN(_mesa_sse_transform_points1_3d_no_rot) -GLNAME(_mesa_sse_transform_points1_3d_no_rot): - -#define FRAME_OFFSET 8 - PUSH_L( ESI ) - PUSH_L( EDI ) - - MOV_L( REGOFF(OFFSET_SOURCE+8, ESP), ESI ) /* ptr to source GLvector4f */ - MOV_L( REGOFF(OFFSET_DEST+8, ESP), EDI ) /* ptr to dest GLvector4f */ - - MOV_L( ARG_MATRIX, EDX ) /* ptr to matrix */ - MOV_L( REGOFF(V4F_COUNT, ESI), ECX ) /* source count */ - - TEST_L( ECX, ECX) - JZ( LLBL(K_GTP13DNRR_finish) ) /* count was zero; go to finish */ - - MOV_L( REGOFF(V4F_STRIDE, ESI), EAX ) /* stride */ - OR_L( CONST(VEC_SIZE_3), REGOFF(V4F_FLAGS, EDI) ) /* set dest flags */ - - MOV_L( ECX, REGOFF(V4F_COUNT, EDI) ) /* set dest count */ - MOV_L( CONST(3), REGOFF(V4F_SIZE, EDI) ) /* set dest size */ - - SHL_L( CONST(4), ECX ) /* count *= 16 */ - MOV_L( REGOFF(V4F_START, ESI), ESI ) /* ptr to first source vertex */ - - MOV_L( REGOFF(V4F_START, EDI), EDI ) /* ptr to first dest vertex */ - ADD_L( EDI, ECX ) /* count += dest ptr */ - - -ALIGNTEXT32 - MOVSS( M(0), XMM0 ) /* m0 */ - MOVSS( M(12), XMM1 ) /* m12 */ - MOVSS( M(13), XMM2 ) /* m13 */ - MOVSS( M(14), XMM3 ) /* m14 */ - -ALIGNTEXT32 -LLBL(K_GTP13DNRR_top): - MOVSS( S(0), XMM4 ) /* ox */ - MULSS( XMM0, XMM4 ) /* ox*m0 */ - ADDSS( XMM1, XMM4 ) /* ox*m0+m12 */ - MOVSS( XMM4, D(0) ) - - MOVSS( XMM2, D(1) ) - MOVSS( XMM3, D(2) ) - -LLBL(K_GTP13DNRR_skip): - ADD_L ( CONST(16), EDI ) - ADD_L ( EAX, ESI ) - CMP_L ( ECX, EDI ) - JNE ( LLBL(K_GTP13DNRR_top) ) - -LLBL(K_GTP13DNRR_finish): - POP_L ( EDI ) - POP_L ( ESI ) - RET -#undef FRAME_OFFSET - - - -ALIGNTEXT4 -GLOBL GLNAME(_mesa_sse_transform_points1_perspective) -HIDDEN(_mesa_sse_transform_points1_perspective) -GLNAME(_mesa_sse_transform_points1_perspective): - -#define FRAME_OFFSET 8 - PUSH_L ( ESI ) - PUSH_L ( EDI ) - - MOV_L( REGOFF(OFFSET_SOURCE+8, ESP), ESI ) /* ptr to source GLvector4f */ - MOV_L( REGOFF(OFFSET_DEST+8, ESP), EDI ) /* ptr to dest GLvector4f */ - - MOV_L( ARG_MATRIX, EDX ) /* ptr to matrix */ - MOV_L( REGOFF(V4F_COUNT, ESI), ECX ) /* source count */ - - TEST_L( ECX, ECX) - JZ( LLBL(K_GTP13PR_finish) ) /* count was zero; go to finish */ - - MOV_L( REGOFF(V4F_STRIDE, ESI), EAX ) /* stride */ - OR_L( CONST(VEC_SIZE_4), REGOFF(V4F_FLAGS, EDI) ) /* set dest flags */ - - MOV_L( ECX, REGOFF(V4F_COUNT, EDI) ) /* set dest count */ - MOV_L( CONST(4), REGOFF(V4F_SIZE, EDI) ) /* set dest size */ - - SHL_L( CONST(4), ECX ) /* count *= 16 */ - MOV_L( REGOFF(V4F_START, ESI), ESI ) /* ptr to first source vertex */ - - MOV_L( REGOFF(V4F_START, EDI), EDI ) /* ptr to first dest vertex */ - ADD_L( EDI, ECX ) /* count += dest ptr */ - - -ALIGNTEXT32 - XORPS( XMM0, XMM0 ) /* 0 | 0 | 0 | 0 */ - MOVSS( M(0), XMM1 ) /* m0 */ - MOVSS( M(14), XMM2 ) /* m14 */ - -ALIGNTEXT32 -LLBL(K_GTP13PR_top): - MOVSS( S(0), XMM3 ) /* ox */ - MULSS( XMM1, XMM3 ) /* ox*m0 */ - MOVSS( XMM3, D(0) ) /* ox*m0->D(0) */ - MOVSS( XMM2, D(2) ) /* m14->D(2) */ - - MOVSS( XMM0, D(1) ) - MOVSS( XMM0, D(3) ) - -LLBL(K_GTP13PR_skip): - ADD_L( CONST(16), EDI ) - ADD_L( EAX, ESI ) - CMP_L( ECX, EDI ) - JNE( LLBL(K_GTP13PR_top) ) - -LLBL(K_GTP13PR_finish): - POP_L ( EDI ) - POP_L ( ESI ) - RET -#undef FRAME_OFFSET - - -ALIGNTEXT4 -GLOBL GLNAME(_mesa_sse_transform_points1_2d) -HIDDEN(_mesa_sse_transform_points1_2d) -GLNAME(_mesa_sse_transform_points1_2d): - -#define FRAME_OFFSET 8 - PUSH_L( ESI ) - PUSH_L( EDI ) - - MOV_L( REGOFF(OFFSET_SOURCE+8, ESP), ESI ) /* ptr to source GLvector4f */ - MOV_L( REGOFF(OFFSET_DEST+8, ESP), EDI ) /* ptr to dest GLvector4f */ - - MOV_L( ARG_MATRIX, EDX ) /* ptr to matrix */ - MOV_L( REGOFF(V4F_COUNT, ESI), ECX ) /* source count */ - - TEST_L( ECX, ECX) - JZ( LLBL(K_GTP13P2DR_finish) ) /* count was zero; go to finish */ - - MOV_L( REGOFF(V4F_STRIDE, ESI), EAX ) /* stride */ - OR_L( CONST(VEC_SIZE_2), REGOFF(V4F_FLAGS, EDI) ) /* set dest flags */ - - MOV_L( ECX, REGOFF(V4F_COUNT, EDI) ) /* set dest count */ - MOV_L( CONST(2), REGOFF(V4F_SIZE, EDI) ) /* set dest size */ - - SHL_L( CONST(4), ECX ) /* count *= 16 */ - MOV_L( REGOFF(V4F_START, ESI), ESI ) /* ptr to first source vertex */ - - MOV_L( REGOFF(V4F_START, EDI), EDI ) /* ptr to first dest vertex */ - ADD_L( EDI, ECX ) /* count += dest ptr */ - -ALIGNTEXT32 - MOVLPS( M(0), XMM0 ) /* m1 | m0 */ - MOVLPS( M(12), XMM1 ) /* m13 | m12 */ - -ALIGNTEXT32 -LLBL(K_GTP13P2DR_top): - MOVSS( S(0), XMM2 ) /* ox */ - SHUFPS( CONST(0x0), XMM2, XMM2 ) /* ox | ox | ox | ox */ - MULPS( XMM0, XMM2 ) /* - | - | ox*m1 | ox*m0 */ - ADDPS( XMM1, XMM2 ) /* - | - | ox*m1+m13 | ox*m0+m12 */ - MOVLPS( XMM2, D(0) ) - -LLBL(K_GTP13P2DR_skip): - ADD_L ( CONST(16), EDI ) - ADD_L ( EAX, ESI ) - CMP_L ( ECX, EDI ) - JNE ( LLBL(K_GTP13P2DR_top) ) - -LLBL(K_GTP13P2DR_finish): - POP_L ( EDI ) - POP_L ( ESI ) - RET -#undef FRAME_OFFSET - - -ALIGNTEXT4 -GLOBL GLNAME(_mesa_sse_transform_points1_2d_no_rot) -HIDDEN(_mesa_sse_transform_points1_2d_no_rot) -GLNAME(_mesa_sse_transform_points1_2d_no_rot): - -#define FRAME_OFFSET 8 - PUSH_L( ESI ) - PUSH_L( EDI ) - - MOV_L( REGOFF(OFFSET_SOURCE+8, ESP), ESI ) /* ptr to source GLvector4f */ - MOV_L( REGOFF(OFFSET_DEST+8, ESP), EDI ) /* ptr to dest GLvector4f */ - - MOV_L( ARG_MATRIX, EDX ) /* ptr to matrix */ - MOV_L( REGOFF(V4F_COUNT, ESI), ECX ) /* source count */ - - TEST_L( ECX, ECX) - JZ( LLBL(K_GTP13P2DNRR_finish) ) /* count was zero; go to finish */ - - MOV_L( REGOFF(V4F_STRIDE, ESI), EAX ) /* stride */ - OR_L( CONST(VEC_SIZE_2), REGOFF(V4F_FLAGS, EDI) ) /* set dest flags */ - - MOV_L( ECX, REGOFF(V4F_COUNT, EDI) ) /* set dest count */ - MOV_L( CONST(2), REGOFF(V4F_SIZE, EDI) ) /* set dest size */ - - SHL_L( CONST(4), ECX ) /* count *= 16 */ - MOV_L( REGOFF(V4F_START, ESI), ESI ) /* ptr to first source vertex */ - - MOV_L( REGOFF(V4F_START, EDI), EDI ) /* ptr to first dest vertex */ - ADD_L( EDI, ECX ) /* count += dest ptr */ - -ALIGNTEXT32 - MOVSS( M(0), XMM0 ) /* m0 */ - MOVSS( M(12), XMM1 ) /* m12 */ - MOVSS( M(13), XMM2 ) /* m13 */ - -ALIGNTEXT32 -LLBL(K_GTP13P2DNRR_top): - MOVSS( S(0), XMM3 ) /* ox */ - MULSS( XMM0, XMM3 ) /* ox*m0 */ - ADDSS( XMM1, XMM3 ) /* ox*m0+m12 */ - MOVSS( XMM3, D(0) ) - MOVSS( XMM2, D(1) ) - -LLBL(K_GTP13P2DNRR_skip): - ADD_L( CONST(16), EDI ) - ADD_L( EAX, ESI ) - CMP_L( ECX, EDI ) - JNE( LLBL(K_GTP13P2DNRR_top) ) - -LLBL(K_GTP13P2DNRR_finish): - POP_L( EDI ) - POP_L( ESI ) - RET -#undef FRAME_OFFSET - - - -ALIGNTEXT4 -GLOBL GLNAME(_mesa_sse_transform_points1_3d) -HIDDEN(_mesa_sse_transform_points1_3d) -GLNAME(_mesa_sse_transform_points1_3d): - -#define FRAME_OFFSET 8 - PUSH_L( ESI ) - PUSH_L( EDI ) - - MOV_L( REGOFF(OFFSET_SOURCE+8, ESP), ESI ) /* ptr to source GLvector4f */ - MOV_L( REGOFF(OFFSET_DEST+8, ESP), EDI ) /* ptr to dest GLvector4f */ - - MOV_L( ARG_MATRIX, EDX ) /* ptr to matrix */ - MOV_L( REGOFF(V4F_COUNT, ESI), ECX ) /* source count */ - - TEST_L( ECX, ECX) - JZ( LLBL(K_GTP13P3DR_finish) ) /* count was zero; go to finish */ - - MOV_L( REGOFF(V4F_STRIDE, ESI), EAX ) /* stride */ - OR_L( CONST(VEC_SIZE_3), REGOFF(V4F_FLAGS, EDI) ) /* set dest flags */ - - MOV_L( ECX, REGOFF(V4F_COUNT, EDI) ) /* set dest count */ - MOV_L( CONST(3), REGOFF(V4F_SIZE, EDI) ) /* set dest size */ - - SHL_L( CONST(4), ECX ) /* count *= 16 */ - MOV_L( REGOFF(V4F_START, ESI), ESI ) /* ptr to first source vertex */ - - MOV_L( REGOFF(V4F_START, EDI), EDI ) /* ptr to first dest vertex */ - ADD_L( EDI, ECX ) /* count += dest ptr */ - - -ALIGNTEXT32 - MOVAPS( M(0), XMM0 ) /* m3 | m2 | m1 | m0 */ - MOVAPS( M(12), XMM1 ) /* m15 | m14 | m13 | m12 */ - -ALIGNTEXT32 -LLBL(K_GTP13P3DR_top): - MOVSS( S(0), XMM2 ) /* ox */ - SHUFPS( CONST(0x0), XMM2, XMM2 ) /* ox | ox | ox | ox */ - MULPS( XMM0, XMM2 ) /* ox*m3 | ox*m2 | ox*m1 | ox*m0 */ - ADDPS( XMM1, XMM2 ) /* +m15 | +m14 | +m13 | +m12 */ - MOVLPS( XMM2, D(0) ) /* - | - | ->D(1)| ->D(0)*/ - UNPCKHPS( XMM2, XMM2 ) /* ox*m3+m15 | ox*m3+m15 | ox*m2+m14 | ox*m2+m14 */ - MOVSS( XMM2, D(2) ) - -LLBL(K_GTP13P3DR_skip): - ADD_L( CONST(16), EDI ) - ADD_L( EAX, ESI ) - CMP_L( ECX, EDI ) - JNE( LLBL(K_GTP13P3DR_top) ) - -LLBL(K_GTP13P3DR_finish): - POP_L( EDI ) - POP_L( ESI ) - RET -#undef FRAME_OFFSET -#endif - -#if defined (__ELF__) && defined (__linux__) - .section .note.GNU-stack,"",%progbits -#endif diff --git a/dll/opengl/mesa/x86/sse_xform2.S b/dll/opengl/mesa/x86/sse_xform2.S deleted file mode 100644 index a443dad35cc..00000000000 --- a/dll/opengl/mesa/x86/sse_xform2.S +++ /dev/null @@ -1,466 +0,0 @@ - -/* - * Mesa 3-D graphics library - * Version: 3.5 - * - * Copyright (C) 1999-2001 Brian Paul All Rights Reserved. - * - * Permission is hereby granted, free of charge, to any person obtaining a - * copy of this software and associated documentation files (the "Software"), - * to deal in the Software without restriction, including without limitation - * the rights to use, copy, modify, merge, publish, distribute, sublicense, - * and/or sell copies of the Software, and to permit persons to whom the - * Software is furnished to do so, subject to the following conditions: - * - * The above copyright notice and this permission notice shall be included - * in all copies or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS - * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL - * BRIAN PAUL BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN - * AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN - * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. - */ - -/** TODO: - * - insert PREFETCH instructions to avoid cache-misses ! - * - some more optimizations are possible... - * - for 40-50% more performance in the SSE-functions, the - * data (trans-matrix, src_vert, dst_vert) needs to be 16byte aligned ! - */ - -#ifdef USE_SSE_ASM -#include "assyntax.h" -#include "matypes.h" -#include "xform_args.h" - - SEG_TEXT - -#define S(i) REGOFF(i * 4, ESI) -#define D(i) REGOFF(i * 4, EDI) -#define M(i) REGOFF(i * 4, EDX) - - -ALIGNTEXT4 -GLOBL GLNAME(_mesa_sse_transform_points2_general) -HIDDEN (_mesa_sse_transform_points2_general) -GLNAME( _mesa_sse_transform_points2_general ): - -#define FRAME_OFFSET 8 - PUSH_L ( ESI ) - PUSH_L ( EDI ) - - MOV_L( REGOFF(OFFSET_SOURCE+8, ESP), ESI ) /* ptr to source GLvector4f */ - MOV_L( REGOFF(OFFSET_DEST+8, ESP), EDI ) /* ptr to dest GLvector4f */ - - MOV_L( ARG_MATRIX, EDX ) /* ptr to matrix */ - MOV_L( REGOFF(V4F_COUNT, ESI), ECX ) /* source count */ - - TEST_L( ECX, ECX ) - JZ( LLBL(K_GTP2GR_finish) ) /* count was zero; go to finish */ - - MOV_L( REGOFF(V4F_STRIDE, ESI), EAX ) /* stride */ - OR_L( CONST(VEC_SIZE_4), REGOFF(V4F_FLAGS, EDI) ) /* set dest flags */ - - MOV_L( ECX, REGOFF(V4F_COUNT, EDI) ) /* set dest count */ - MOV_L( CONST(4), REGOFF(V4F_SIZE, EDI) ) /* set dest size */ - - SHL_L( CONST(4), ECX ) /* count *= 16 */ - MOV_L( REGOFF(V4F_START, ESI), ESI ) /* ptr to first source vertex */ - - MOV_L( REGOFF(V4F_START, EDI), EDI ) /* ptr to first dest vertex */ - ADD_L( EDI, ECX ) /* count += dest ptr */ - -ALIGNTEXT32 - MOVAPS( M(0), XMM0 ) /* m3 | m2 | m1 | m0 */ - MOVAPS( M(4), XMM1 ) /* m7 | m6 | m5 | m4 */ - MOVAPS( M(12), XMM2 ) /* m15 | m14 | m13 | m12 */ - -ALIGNTEXT32 -LLBL(K_GTP2GR_top): - MOVSS( S(0), XMM3 ) /* ox */ - SHUFPS( CONST(0x0), XMM3, XMM3 ) /* ox | ox | ox | ox */ - MULPS( XMM0, XMM3 ) /* ox*m3 | ox*m2 | ox*m1 | ox*m0 */ - MOVSS( S(1), XMM4 ) /* oy */ - SHUFPS( CONST(0x0), XMM4, XMM4 ) /* oy | oy | oy | oy */ - MULPS( XMM1, XMM4 ) /* oy*m7 | oy*m6 | oy*m5 | oy*m4 */ - - ADDPS( XMM4, XMM3 ) - ADDPS( XMM2, XMM3 ) - MOVAPS( XMM3, D(0) ) - -LLBL(K_GTP2GR_skip): - ADD_L ( CONST(16), EDI ) - ADD_L ( EAX, ESI ) - CMP_L ( ECX, EDI ) - JNE ( LLBL(K_GTP2GR_top) ) - -LLBL(K_GTP2GR_finish): - POP_L ( EDI ) - POP_L ( ESI ) - RET -#undef FRAME_OFFSET - - -ALIGNTEXT4 -GLOBL GLNAME(_mesa_sse_transform_points2_identity) -HIDDEN(_mesa_sse_transform_points2_identity) -GLNAME( _mesa_sse_transform_points2_identity ): - -#define FRAME_OFFSET 8 - PUSH_L ( ESI ) - PUSH_L ( EDI ) - - MOV_L( REGOFF(OFFSET_SOURCE+8, ESP), ESI ) /* ptr to source GLvector4f */ - MOV_L( REGOFF(OFFSET_DEST+8, ESP), EDI ) /* ptr to dest GLvector4f */ - - MOV_L( REGOFF(V4F_COUNT, ESI), ECX ) /* source count */ - - TEST_L( ECX, ECX) - JZ( LLBL(K_GTP2IR_finish) ) /* count was zero; go to finish */ - - MOV_L( REGOFF(V4F_STRIDE, ESI), EAX ) /* stride */ - OR_L( CONST(VEC_SIZE_2), REGOFF(V4F_FLAGS, EDI) ) /* set dest flags */ - - MOV_L( ECX, REGOFF(V4F_COUNT, EDI) ) /* set dest count */ - MOV_L( CONST(2), REGOFF(V4F_SIZE, EDI) ) /* set dest size */ - - SHL_L( CONST(4), ECX ) /* count *= 16 */ - MOV_L( REGOFF(V4F_START, ESI), ESI ) /* ptr to first source vertex */ - - MOV_L( REGOFF(V4F_START, EDI), EDI ) /* ptr to first dest vertex */ - ADD_L( EDI, ECX ) /* count += dest ptr */ - - CMP_L( ESI, EDI ) - JE( LLBL(K_GTP2IR_finish) ) - - -ALIGNTEXT32 -LLBL(K_GTP2IR_top): - MOV_L ( S(0), EDX ) - MOV_L ( EDX, D(0) ) - MOV_L ( S(1), EDX ) - MOV_L ( EDX, D(1) ) - -LLBL(K_GTP2IR_skip): - ADD_L ( CONST(16), EDI ) - ADD_L ( EAX, ESI ) - CMP_L ( ECX, EDI ) - JNE ( LLBL(K_GTP2IR_top) ) - -LLBL(K_GTP2IR_finish): - POP_L ( EDI ) - POP_L ( ESI ) - RET -#undef FRAME_OFFSET - - -ALIGNTEXT4 -GLOBL GLNAME(_mesa_sse_transform_points2_3d_no_rot) -HIDDEN(_mesa_sse_transform_points2_3d_no_rot) -GLNAME(_mesa_sse_transform_points2_3d_no_rot): - -#define FRAME_OFFSET 8 - PUSH_L( ESI ) - PUSH_L( EDI ) - - MOV_L( REGOFF(OFFSET_SOURCE+8, ESP), ESI ) /* ptr to source GLvector4f */ - MOV_L( REGOFF(OFFSET_DEST+8, ESP), EDI ) /* ptr to dest GLvector4f */ - - MOV_L( ARG_MATRIX, EDX ) /* ptr to matrix */ - MOV_L( REGOFF(V4F_COUNT, ESI), ECX ) /* source count */ - - TEST_L( ECX, ECX) - JZ( LLBL(K_GTP23DNRR_finish) ) /* count was zero; go to finish */ - - MOV_L( REGOFF(V4F_STRIDE, ESI), EAX ) /* stride */ - OR_L( CONST(VEC_SIZE_3), REGOFF(V4F_FLAGS, EDI) ) /* set dest flags */ - - MOV_L( ECX, REGOFF(V4F_COUNT, EDI) ) /* set dest count */ - MOV_L( CONST(3), REGOFF(V4F_SIZE, EDI) ) /* set dest size */ - - SHL_L( CONST(4), ECX ) /* count *= 16 */ - MOV_L( REGOFF(V4F_START, ESI), ESI ) /* ptr to first source vertex */ - - MOV_L( REGOFF(V4F_START, EDI), EDI ) /* ptr to first dest vertex */ - ADD_L( EDI, ECX ) /* count += dest ptr */ - - XORPS( XMM0, XMM0 ) /* clean the working register */ - -ALIGNTEXT32 - MOVSS ( M(0), XMM1 ) /* - | - | - | m0 */ - MOVSS ( M(5), XMM2 ) /* - | - | - | m5 */ - UNPCKLPS ( XMM2, XMM1 ) /* - | - | m5 | m0 */ - MOVLPS ( M(12), XMM2 ) /* - | - | m13 | m12 */ - MOVSS ( M(14), XMM3 ) /* - | - | - | m14 */ - -ALIGNTEXT32 -LLBL(K_GTP23DNRR_top): - MOVLPS ( S(0), XMM0 ) /* - | - | oy | ox */ - MULPS ( XMM1, XMM0 ) /* - | - | oy*m5 | ox*m0 */ - ADDPS ( XMM2, XMM0 ) /* - | - | +m13 | +m12 */ - MOVLPS ( XMM0, D(0) ) /* -> D(1) | -> D(0) */ - - MOVSS ( XMM3, D(2) ) /* -> D(2) */ - -LLBL(K_GTP23DNRR_skip): - ADD_L ( CONST(16), EDI ) - ADD_L ( EAX, ESI ) - CMP_L ( ECX, EDI ) - JNE ( LLBL(K_GTP23DNRR_top) ) - -LLBL(K_GTP23DNRR_finish): - POP_L ( EDI ) - POP_L ( ESI ) - RET -#undef FRAME_OFFSET - - -ALIGNTEXT4 -GLOBL GLNAME(_mesa_sse_transform_points2_perspective) -HIDDEN(_mesa_sse_transform_points2_perspective) -GLNAME(_mesa_sse_transform_points2_perspective): - -#define FRAME_OFFSET 8 - PUSH_L ( ESI ) - PUSH_L ( EDI ) - - MOV_L( REGOFF(OFFSET_SOURCE+8, ESP), ESI ) /* ptr to source GLvector4f */ - MOV_L( REGOFF(OFFSET_DEST+8, ESP), EDI ) /* ptr to dest GLvector4f */ - - MOV_L( ARG_MATRIX, EDX ) /* ptr to matrix */ - MOV_L( REGOFF(V4F_COUNT, ESI), ECX ) /* source count */ - - TEST_L( ECX, ECX) - JZ( LLBL(K_GTP23PR_finish) ) /* count was zero; go to finish */ - - MOV_L( REGOFF(V4F_STRIDE, ESI), EAX ) /* stride */ - OR_L( CONST(VEC_SIZE_4), REGOFF(V4F_FLAGS, EDI) ) /* set dest flags */ - - MOV_L( ECX, REGOFF(V4F_COUNT, EDI) ) /* set dest count */ - MOV_L( CONST(4), REGOFF(V4F_SIZE, EDI) ) /* set dest size */ - - SHL_L( CONST(4), ECX ) /* count *= 16 */ - MOV_L( REGOFF(V4F_START, ESI), ESI ) /* ptr to first source vertex */ - - MOV_L( REGOFF(V4F_START, EDI), EDI ) /* ptr to first dest vertex */ - ADD_L( EDI, ECX ) /* count += dest ptr */ - -ALIGNTEXT32 - MOVSS ( M(0), XMM1 ) /* - | - | - | m0 */ - MOVSS ( M(5), XMM2 ) /* - | - | - | m5 */ - UNPCKLPS ( XMM2, XMM1 ) /* - | - | m5 | m0 */ - MOVSS ( M(14), XMM3 ) /* m14 */ - XORPS ( XMM0, XMM0 ) /* 0 | 0 | 0 | 0 */ - -ALIGNTEXT32 -LLBL(K_GTP23PR_top): - MOVLPS( S(0), XMM4 ) /* oy | ox */ - MULPS( XMM1, XMM4 ) /* oy*m5 | ox*m0 */ - MOVLPS( XMM4, D(0) ) /* ->D(1) | ->D(0) */ - MOVSS( XMM3, D(2) ) /* ->D(2) */ - MOVSS( XMM0, D(3) ) /* ->D(3) */ - -LLBL(K_GTP23PR_skip): - ADD_L( CONST(16), EDI ) - ADD_L( EAX, ESI ) - CMP_L( ECX, EDI ) - JNE( LLBL(K_GTP23PR_top) ) - -LLBL(K_GTP23PR_finish): - POP_L ( EDI ) - POP_L ( ESI ) - RET -#undef FRAME_OFFSET - - - -ALIGNTEXT4 -GLOBL GLNAME(_mesa_sse_transform_points2_2d) -HIDDEN(_mesa_sse_transform_points2_2d) -GLNAME(_mesa_sse_transform_points2_2d): - -#define FRAME_OFFSET 8 - PUSH_L( ESI ) - PUSH_L( EDI ) - - MOV_L( REGOFF(OFFSET_SOURCE+8, ESP), ESI ) /* ptr to source GLvector4f */ - MOV_L( REGOFF(OFFSET_DEST+8, ESP), EDI ) /* ptr to dest GLvector4f */ - - MOV_L( ARG_MATRIX, EDX ) /* ptr to matrix */ - MOV_L( REGOFF(V4F_COUNT, ESI), ECX ) /* source count */ - - TEST_L( ECX, ECX) - JZ( LLBL(K_GTP23P2DR_finish) ) /* count was zero; go to finish */ - - MOV_L( REGOFF(V4F_STRIDE, ESI), EAX ) /* stride */ - OR_L( CONST(VEC_SIZE_2), REGOFF(V4F_FLAGS, EDI) ) /* set dest flags */ - - MOV_L( ECX, REGOFF(V4F_COUNT, EDI) ) /* set dest count */ - MOV_L( CONST(2), REGOFF(V4F_SIZE, EDI) ) /* set dest size */ - - SHL_L( CONST(4), ECX ) /* count *= 16 */ - MOV_L( REGOFF(V4F_START, ESI), ESI ) /* ptr to first source vertex */ - - MOV_L( REGOFF(V4F_START, EDI), EDI ) /* ptr to first dest vertex */ - ADD_L( EDI, ECX ) /* count += dest ptr */ - -ALIGNTEXT32 - MOVLPS( M(0), XMM0 ) /* m1 | m0 */ - MOVLPS( M(4), XMM1 ) /* m5 | m4 */ - MOVLPS( M(12), XMM2 ) /* m13 | m12 */ - -ALIGNTEXT32 -LLBL(K_GTP23P2DR_top): - MOVSS( S(0), XMM3 ) /* ox */ - SHUFPS( CONST(0x0), XMM3, XMM3 ) /* ox | ox */ - MULPS( XMM0, XMM3 ) /* ox*m1 | ox*m0 */ - - MOVSS( S(1), XMM4 ) /* oy */ - SHUFPS( CONST(0x0), XMM4, XMM4 ) /* oy | oy */ - MULPS( XMM1, XMM4 ) /* oy*m5 | oy*m4 */ - - ADDPS( XMM4, XMM3 ) - ADDPS( XMM2, XMM3 ) - MOVLPS( XMM3, D(0) ) /* ->D(1) | ->D(0) */ - -LLBL(K_GTP23P2DR_skip): - ADD_L ( CONST(16), EDI ) - ADD_L ( EAX, ESI ) - CMP_L ( ECX, EDI ) - JNE ( LLBL(K_GTP23P2DR_top) ) - -LLBL(K_GTP23P2DR_finish): - POP_L ( EDI ) - POP_L ( ESI ) - RET -#undef FRAME_OFFSET - - - -ALIGNTEXT4 -GLOBL GLNAME(_mesa_sse_transform_points2_2d_no_rot) -HIDDEN(_mesa_sse_transform_points2_2d_no_rot) -GLNAME(_mesa_sse_transform_points2_2d_no_rot): - -#define FRAME_OFFSET 8 - PUSH_L( ESI ) - PUSH_L( EDI ) - - MOV_L( REGOFF(OFFSET_SOURCE+8, ESP), ESI ) /* ptr to source GLvector4f */ - MOV_L( REGOFF(OFFSET_DEST+8, ESP), EDI ) /* ptr to dest GLvector4f */ - - MOV_L( ARG_MATRIX, EDX ) /* ptr to matrix */ - MOV_L( REGOFF(V4F_COUNT, ESI), ECX ) /* source count */ - - TEST_L( ECX, ECX) - JZ( LLBL(K_GTP23P2DNRR_finish) ) /* count was zero; go to finish */ - - MOV_L( REGOFF(V4F_STRIDE, ESI), EAX ) /* stride */ - OR_L( CONST(VEC_SIZE_2), REGOFF(V4F_FLAGS, EDI) ) /* set dest flags */ - - MOV_L( ECX, REGOFF(V4F_COUNT, EDI) ) /* set dest count */ - MOV_L( CONST(2), REGOFF(V4F_SIZE, EDI) ) /* set dest size */ - - SHL_L( CONST(4), ECX ) /* count *= 16 */ - MOV_L( REGOFF(V4F_START, ESI), ESI ) /* ptr to first source vertex */ - - MOV_L( REGOFF(V4F_START, EDI), EDI ) /* ptr to first dest vertex */ - ADD_L( EDI, ECX ) /* count += dest ptr */ - -ALIGNTEXT32 - MOVSS ( M(0), XMM1 ) /* m0 */ - MOVSS ( M(5), XMM2 ) /* m5 */ - UNPCKLPS ( XMM2, XMM1 ) /* m5 | m0 */ - MOVLPS ( M(12), XMM2 ) /* m13 | m12 */ - -ALIGNTEXT32 -LLBL(K_GTP23P2DNRR_top): - MOVLPS( S(0), XMM0 ) /* oy | ox */ - MULPS( XMM1, XMM0 ) /* oy*m5 | ox*m0 */ - ADDPS( XMM2, XMM0 ) /* +m13 | +m12 */ - MOVLPS( XMM0, D(0) ) /* ->D(1) | ->D(0) */ - -LLBL(K_GTP23P2DNRR_skip): - ADD_L( CONST(16), EDI ) - ADD_L( EAX, ESI ) - CMP_L( ECX, EDI ) - JNE( LLBL(K_GTP23P2DNRR_top) ) - -LLBL(K_GTP23P2DNRR_finish): - POP_L( EDI ) - POP_L( ESI ) - RET -#undef FRAME_OFFSET - - - -ALIGNTEXT4 -GLOBL GLNAME(_mesa_sse_transform_points2_3d) -HIDDEN(_mesa_sse_transform_points2_3d) -GLNAME(_mesa_sse_transform_points2_3d): - -#define FRAME_OFFSET 8 - PUSH_L( ESI ) - PUSH_L( EDI ) - - MOV_L( REGOFF(OFFSET_SOURCE+8, ESP), ESI ) /* ptr to source GLvector4f */ - MOV_L( REGOFF(OFFSET_DEST+8, ESP), EDI ) /* ptr to dest GLvector4f */ - - MOV_L( ARG_MATRIX, EDX ) /* ptr to matrix */ - MOV_L( REGOFF(V4F_COUNT, ESI), ECX ) /* source count */ - - TEST_L( ECX, ECX) - JZ( LLBL(K_GTP23P3DR_finish) ) /* count was zero; go to finish */ - - MOV_L( REGOFF(V4F_STRIDE, ESI), EAX ) /* stride */ - OR_L( CONST(VEC_SIZE_3), REGOFF(V4F_FLAGS, EDI) ) /* set dest flags */ - - MOV_L( ECX, REGOFF(V4F_COUNT, EDI) ) /* set dest count */ - MOV_L( CONST(3), REGOFF(V4F_SIZE, EDI) ) /* set dest size */ - - SHL_L( CONST(4), ECX ) /* count *= 16 */ - MOV_L( REGOFF(V4F_START, ESI), ESI ) /* ptr to first source vertex */ - - MOV_L( REGOFF(V4F_START, EDI), EDI ) /* ptr to first dest vertex */ - ADD_L( EDI, ECX ) /* count += dest ptr */ - -ALIGNTEXT32 - MOVAPS( M(0), XMM0 ) /* m2 | m1 | m0 */ - MOVAPS( M(4), XMM1 ) /* m6 | m5 | m4 */ - MOVAPS( M(12), XMM2 ) /* m14 | m13 | m12 */ - -ALIGNTEXT32 -LLBL(K_GTP23P3DR_top): - MOVSS( S(0), XMM3 ) /* ox */ - SHUFPS( CONST(0x0), XMM3, XMM3 ) /* ox | ox | ox */ - MULPS( XMM0, XMM3 ) /* ox*m2 | ox*m1 | ox*m0 */ - - MOVSS( S(1), XMM4 ) /* oy */ - SHUFPS( CONST(0x0), XMM4, XMM4 ) /* oy | oy | oy */ - MULPS( XMM1, XMM4 ) /* oy*m6 | oy*m5 | oy*m4 */ - - ADDPS( XMM4, XMM3 ) - ADDPS( XMM2, XMM3 ) - - MOVLPS( XMM3, D(0) ) /* ->D(1) | ->D(0) */ - UNPCKHPS( XMM3, XMM3 ) - MOVSS( XMM3, D(2) ) /* ->D(2) */ - -LLBL(K_GTP23P3DR_skip): - ADD_L( CONST(16), EDI ) - ADD_L( EAX, ESI ) - CMP_L( ECX, EDI ) - JNE( LLBL(K_GTP23P3DR_top) ) - -LLBL(K_GTP23P3DR_finish): - POP_L( EDI ) - POP_L( ESI ) - RET -#undef FRAME_OFFSET -#endif - -#if defined (__ELF__) && defined (__linux__) - .section .note.GNU-stack,"",%progbits -#endif diff --git a/dll/opengl/mesa/x86/sse_xform3.S b/dll/opengl/mesa/x86/sse_xform3.S deleted file mode 100644 index 4bc22d8a545..00000000000 --- a/dll/opengl/mesa/x86/sse_xform3.S +++ /dev/null @@ -1,512 +0,0 @@ - -/* - * Mesa 3-D graphics library - * Version: 3.5 - * - * Copyright (C) 1999-2001 Brian Paul All Rights Reserved. - * - * Permission is hereby granted, free of charge, to any person obtaining a - * copy of this software and associated documentation files (the "Software"), - * to deal in the Software without restriction, including without limitation - * the rights to use, copy, modify, merge, publish, distribute, sublicense, - * and/or sell copies of the Software, and to permit persons to whom the - * Software is furnished to do so, subject to the following conditions: - * - * The above copyright notice and this permission notice shall be included - * in all copies or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS - * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL - * BRIAN PAUL BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN - * AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN - * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. - */ - -/** TODO: - * - insert PREFETCH instructions to avoid cache-misses ! - * - some more optimizations are possible... - * - for 40-50% more performance in the SSE-functions, the - * data (trans-matrix, src_vert, dst_vert) needs to be 16byte aligned ! - */ - -#ifdef USE_SSE_ASM -#include "assyntax.h" -#include "matypes.h" -#include "xform_args.h" - - SEG_TEXT - -#define S(i) REGOFF(i * 4, ESI) -#define D(i) REGOFF(i * 4, EDI) -#define M(i) REGOFF(i * 4, EDX) - - -ALIGNTEXT4 -GLOBL GLNAME(_mesa_sse_transform_points3_general) -HIDDEN(_mesa_sse_transform_points3_general) -GLNAME( _mesa_sse_transform_points3_general ): - -#define FRAME_OFFSET 8 - PUSH_L ( ESI ) - PUSH_L ( EDI ) - - MOV_L( REGOFF(OFFSET_SOURCE+8, ESP), ESI ) /* ptr to source GLvector4f */ - MOV_L( REGOFF(OFFSET_DEST+8, ESP), EDI ) /* ptr to dest GLvector4f */ - - MOV_L( ARG_MATRIX, EDX ) /* ptr to matrix */ - MOV_L( REGOFF(V4F_COUNT, ESI), ECX ) /* source count */ - - CMP_L ( CONST(0), ECX ) /* count == 0 ? */ - JE ( LLBL(K_GTPGR_finish) ) /* yes -> nothing to do. */ - - MOV_L( REGOFF(V4F_STRIDE, ESI), EAX ) /* stride */ - OR_L( CONST(VEC_SIZE_4), REGOFF(V4F_FLAGS, EDI) ) /* set dest flags */ - - MOV_L( ECX, REGOFF(V4F_COUNT, EDI) ) /* set dest count */ - MOV_L( CONST(4), REGOFF(V4F_SIZE, EDI) ) /* set dest size */ - - SHL_L( CONST(4), ECX ) /* count *= 16 */ - MOV_L( REGOFF(V4F_START, ESI), ESI ) /* ptr to first source vertex */ - - MOV_L( REGOFF(V4F_START, EDI), EDI ) /* ptr to first dest vertex */ - ADD_L( EDI, ECX ) /* count += dest ptr */ - - -ALIGNTEXT32 - MOVAPS ( REGOFF(0, EDX), XMM0 ) /* m0 | m1 | m2 | m3 */ - MOVAPS ( REGOFF(16, EDX), XMM1 ) /* m4 | m5 | m6 | m7 */ - MOVAPS ( REGOFF(32, EDX), XMM2 ) /* m8 | m9 | m10 | m11 */ - MOVAPS ( REGOFF(48, EDX), XMM3 ) /* m12 | m13 | m14 | m15 */ - - -ALIGNTEXT32 -LLBL(K_GTPGR_top): - MOVSS ( REGOFF(0, ESI), XMM4 ) /* | | | ox */ - SHUFPS ( CONST(0x0), XMM4, XMM4 ) /* ox | ox | ox | ox */ - MOVSS ( REGOFF(4, ESI), XMM5 ) /* | | | oy */ - SHUFPS ( CONST(0x0), XMM5, XMM5 ) /* oy | oy | oy | oy */ - MOVSS ( REGOFF(8, ESI), XMM6 ) /* | | | oz */ - SHUFPS ( CONST(0x0), XMM6, XMM6 ) /* oz | oz | oz | oz */ - - MULPS ( XMM0, XMM4 ) /* m3*ox | m2*ox | m1*ox | m0*ox */ - MULPS ( XMM1, XMM5 ) /* m7*oy | m6*oy | m5*oy | m4*oy */ - MULPS ( XMM2, XMM6 ) /* m11*oz | m10*oz | m9*oz | m8*oz */ - - ADDPS ( XMM5, XMM4 ) - ADDPS ( XMM6, XMM4 ) - ADDPS ( XMM3, XMM4 ) - - MOVAPS ( XMM4, REGOFF(0, EDI) ) - -LLBL(K_GTPGR_skip): - ADD_L ( CONST(16), EDI ) - ADD_L ( EAX, ESI ) - CMP_L ( ECX, EDI ) - JNE ( LLBL(K_GTPGR_top) ) - -LLBL(K_GTPGR_finish): - POP_L ( EDI ) - POP_L ( ESI ) - RET -#undef FRAME_OFFSET - - -ALIGNTEXT4 -GLOBL GLNAME(_mesa_sse_transform_points3_identity) -HIDDEN(_mesa_sse_transform_points3_identity) -GLNAME( _mesa_sse_transform_points3_identity ): - -#define FRAME_OFFSET 8 - PUSH_L ( ESI ) - PUSH_L ( EDI ) - - MOV_L( REGOFF(OFFSET_SOURCE+8, ESP), ESI ) /* ptr to source GLvector4f */ - MOV_L( REGOFF(OFFSET_DEST+8, ESP), EDI ) /* ptr to dest GLvector4f */ - - MOV_L( REGOFF(V4F_COUNT, ESI), ECX ) /* source count */ - - TEST_L( ECX, ECX) - JZ( LLBL(K_GTPIR_finish) ) /* count was zero; go to finish */ - - MOV_L( REGOFF(V4F_STRIDE, ESI), EAX ) /* stride */ - OR_L( CONST(VEC_SIZE_3), REGOFF(V4F_FLAGS, EDI) ) /* set dest flags */ - - MOV_L( ECX, REGOFF(V4F_COUNT, EDI) ) /* set dest count */ - MOV_L( CONST(3), REGOFF(V4F_SIZE, EDI) ) /* set dest size */ - - SHL_L( CONST(4), ECX ) /* count *= 16 */ - MOV_L( REGOFF(V4F_START, ESI), ESI ) /* ptr to first source vertex */ - - MOV_L( REGOFF(V4F_START, EDI), EDI ) /* ptr to first dest vertex */ - ADD_L( EDI, ECX ) /* count += dest ptr */ - - CMP_L( ESI, EDI ) - JE( LLBL(K_GTPIR_finish) ) - - -ALIGNTEXT32 -LLBL(K_GTPIR_top): - MOVLPS ( S(0), XMM0 ) - MOVLPS ( XMM0, D(0) ) - MOVSS ( S(2), XMM0 ) - MOVSS ( XMM0, D(2) ) - -LLBL(K_GTPIR_skip): - ADD_L ( CONST(16), EDI ) - ADD_L ( EAX, ESI ) - CMP_L ( ECX, EDI ) - JNE ( LLBL(K_GTPIR_top) ) - -LLBL(K_GTPIR_finish): - POP_L ( EDI ) - POP_L ( ESI ) - RET -#undef FRAME_OFFSET - - - - -ALIGNTEXT4 -GLOBL GLNAME(_mesa_sse_transform_points3_3d_no_rot) -HIDDEN(_mesa_sse_transform_points3_3d_no_rot) -GLNAME(_mesa_sse_transform_points3_3d_no_rot): - -#define FRAME_OFFSET 8 - PUSH_L( ESI ) - PUSH_L( EDI ) - - MOV_L( REGOFF(OFFSET_SOURCE+8, ESP), ESI ) /* ptr to source GLvector4f */ - MOV_L( REGOFF(OFFSET_DEST+8, ESP), EDI ) /* ptr to dest GLvector4f */ - - - MOV_L( ARG_MATRIX, EDX ) /* ptr to matrix */ - MOV_L( REGOFF(V4F_COUNT, ESI), ECX ) /* source count */ - - TEST_L( ECX, ECX) - JZ( LLBL(K_GTP3DNRR_finish) ) /* count was zero; go to finish */ - - MOV_L( REGOFF(V4F_STRIDE, ESI), EAX ) /* stride */ - OR_L( CONST(VEC_SIZE_3), REGOFF(V4F_FLAGS, EDI) ) /* set dest flags */ - - MOV_L( ECX, REGOFF(V4F_COUNT, EDI) ) /* set dest count */ - MOV_L( CONST(3), REGOFF(V4F_SIZE, EDI) ) /* set dest size */ - - SHL_L( CONST(4), ECX ) /* count *= 16 */ - MOV_L( REGOFF(V4F_START, ESI), ESI ) /* ptr to first source vertex */ - - MOV_L( REGOFF(V4F_START, EDI), EDI ) /* ptr to first dest vertex */ - ADD_L( EDI, ECX ) /* count += dest ptr */ - - XORPS( XMM0, XMM0 ) /* clean the working register */ - -ALIGNTEXT32 - MOVSS ( M(0), XMM1 ) /* - | - | - | m0 */ - MOVSS ( M(5), XMM2 ) /* - | - | - | m5 */ - UNPCKLPS ( XMM2, XMM1 ) /* - | - | m5 | m0 */ - MOVLPS ( M(12), XMM2 ) /* - | - | m13 | m12 */ - MOVSS ( M(10), XMM3 ) /* - | - | - | m10 */ - MOVSS ( M(14), XMM4 ) /* - | - | - | m14 */ - -ALIGNTEXT32 -LLBL(K_GTP3DNRR_top): - - MOVLPS ( S(0), XMM0 ) /* - | - | s1 | s0 */ - MULPS ( XMM1, XMM0 ) /* - | - | s1*m5 | s0*m0 */ - ADDPS ( XMM2, XMM0 ) /* - | - | +m13 | +m12 */ - MOVLPS ( XMM0, D(0) ) /* -> D(1) | -> D(0) */ - - MOVSS ( S(2), XMM0 ) /* sz */ - MULSS ( XMM3, XMM0 ) /* sz*m10 */ - ADDSS ( XMM4, XMM0 ) /* +m14 */ - MOVSS ( XMM0, D(2) ) /* -> D(2) */ - -LLBL(K_GTP3DNRR_skip): - ADD_L ( CONST(16), EDI ) - ADD_L ( EAX, ESI ) - CMP_L ( ECX, EDI ) - JNE ( LLBL(K_GTP3DNRR_top) ) - -LLBL(K_GTP3DNRR_finish): - POP_L ( EDI ) - POP_L ( ESI ) - RET -#undef FRAME_OFFSET - - - -ALIGNTEXT4 -GLOBL GLNAME(_mesa_sse_transform_points3_perspective) -HIDDEN(_mesa_sse_transform_points3_perspective) -GLNAME(_mesa_sse_transform_points3_perspective): - -#define FRAME_OFFSET 8 - PUSH_L ( ESI ) - PUSH_L ( EDI ) - - MOV_L( REGOFF(OFFSET_SOURCE+8, ESP), ESI ) /* ptr to source GLvector4f */ - MOV_L( REGOFF(OFFSET_DEST+8, ESP), EDI ) /* ptr to dest GLvector4f */ - - MOV_L( ARG_MATRIX, EDX ) /* ptr to matrix */ - MOV_L( REGOFF(V4F_COUNT, ESI), ECX ) /* source count */ - - TEST_L( ECX, ECX) - JZ( LLBL(K_GTP3PR_finish) ) /* count was zero; go to finish */ - - MOV_L( REGOFF(V4F_STRIDE, ESI), EAX ) /* stride */ - OR_L( CONST(VEC_SIZE_4), REGOFF(V4F_FLAGS, EDI) ) /* set dest flags */ - - MOV_L( ECX, REGOFF(V4F_COUNT, EDI) ) /* set dest count */ - MOV_L( CONST(4), REGOFF(V4F_SIZE, EDI) ) /* set dest size */ - - SHL_L( CONST(4), ECX ) /* count *= 16 */ - MOV_L( REGOFF(V4F_START, ESI), ESI ) /* ptr to first source vertex */ - - MOV_L( REGOFF(V4F_START, EDI), EDI ) /* ptr to first dest vertex */ - ADD_L( EDI, ECX ) /* count += dest ptr */ - -ALIGNTEXT32 - MOVSS ( M(0), XMM1 ) /* - | - | - | m0 */ - MOVSS ( M(5), XMM2 ) /* - | - | - | m5 */ - UNPCKLPS ( XMM2, XMM1 ) /* - | - | m5 | m0 */ - MOVLPS ( M(8), XMM2 ) /* - | - | m9 | m8 */ - MOVSS ( M(10), XMM3 ) /* m10 */ - MOVSS ( M(14), XMM4 ) /* m14 */ - XORPS ( XMM6, XMM6 ) /* 0 */ - -ALIGNTEXT32 -LLBL(K_GTP3PR_top): - MOVLPS ( S(0), XMM0 ) /* oy | ox */ - MULPS ( XMM1, XMM0 ) /* oy*m5 | ox*m0 */ - MOVSS ( S(2), XMM5 ) /* oz */ - SHUFPS ( CONST(0x0), XMM5, XMM5 ) /* oz | oz */ - MULPS ( XMM2, XMM5 ) /* oz*m9 | oz*m8 */ - ADDPS ( XMM5, XMM0 ) /* +oy*m5 | +ox*m0 */ - MOVLPS ( XMM0, D(0) ) /* ->D(1) | ->D(0) */ - - MOVSS ( S(2), XMM0 ) /* oz */ - MULSS ( XMM3, XMM0 ) /* oz*m10 */ - ADDSS ( XMM4, XMM0 ) /* +m14 */ - MOVSS ( XMM0, D(2) ) /* ->D(2) */ - - MOVSS ( S(2), XMM0 ) /* oz */ - MOVSS ( XMM6, XMM5 ) /* 0 */ - SUBPS ( XMM0, XMM5 ) /* -oz */ - MOVSS ( XMM5, D(3) ) /* ->D(3) */ - -LLBL(K_GTP3PR_skip): - ADD_L( CONST(16), EDI ) - ADD_L( EAX, ESI ) - CMP_L( ECX, EDI ) - JNE( LLBL(K_GTP3PR_top) ) - -LLBL(K_GTP3PR_finish): - POP_L ( EDI ) - POP_L ( ESI ) - RET -#undef FRAME_OFFSET - - - -ALIGNTEXT4 -GLOBL GLNAME(_mesa_sse_transform_points3_2d) -HIDDEN(_mesa_sse_transform_points3_2d) -GLNAME(_mesa_sse_transform_points3_2d): - -#define FRAME_OFFSET 8 - PUSH_L( ESI ) - PUSH_L( EDI ) - - MOV_L( REGOFF(OFFSET_SOURCE+8, ESP), ESI ) /* ptr to source GLvector4f */ - MOV_L( REGOFF(OFFSET_DEST+8, ESP), EDI ) /* ptr to dest GLvector4f */ - - MOV_L( ARG_MATRIX, EDX ) /* ptr to matrix */ - MOV_L( REGOFF(V4F_COUNT, ESI), ECX ) /* source count */ - - TEST_L( ECX, ECX) - JZ( LLBL(K_GTP3P2DR_finish) ) /* count was zero; go to finish */ - - MOV_L( REGOFF(V4F_STRIDE, ESI), EAX ) /* stride */ - OR_L( CONST(VEC_SIZE_3), REGOFF(V4F_FLAGS, EDI) ) /* set dest flags */ - - MOV_L( ECX, REGOFF(V4F_COUNT, EDI) ) /* set dest count */ - MOV_L( CONST(3), REGOFF(V4F_SIZE, EDI) ) /* set dest size */ - - SHL_L( CONST(4), ECX ) /* count *= 16 */ - MOV_L( REGOFF(V4F_START, ESI), ESI ) /* ptr to first source vertex */ - - MOV_L( REGOFF(V4F_START, EDI), EDI ) /* ptr to first dest vertex */ - ADD_L( EDI, ECX ) /* count += dest ptr */ - -ALIGNTEXT32 - MOVLPS( M(0), XMM0 ) /* m1 | m0 */ - MOVLPS( M(4), XMM1 ) /* m5 | m4 */ - MOVLPS( M(12), XMM2 ) /* m13 | m12 */ - -ALIGNTEXT32 -LLBL(K_GTP3P2DR_top): - MOVSS ( S(0), XMM3 ) /* ox */ - SHUFPS ( CONST(0x0), XMM3, XMM3 ) /* ox | ox */ - MULPS ( XMM0, XMM3 ) /* ox*m1 | ox*m0 */ - MOVSS ( S(1), XMM4 ) /* oy */ - SHUFPS ( CONST(0x0), XMM4, XMM4 ) /* oy | oy */ - MULPS ( XMM1, XMM4 ) /* oy*m5 | oy*m4 */ - - ADDPS ( XMM4, XMM3 ) - ADDPS ( XMM2, XMM3 ) - MOVLPS ( XMM3, D(0) ) - - MOVSS ( S(2), XMM3 ) - MOVSS ( XMM3, D(2) ) - -LLBL(K_GTP3P2DR_skip): - ADD_L ( CONST(16), EDI ) - ADD_L ( EAX, ESI ) - CMP_L ( ECX, EDI ) - JNE ( LLBL(K_GTP3P2DR_top) ) - -LLBL(K_GTP3P2DR_finish): - POP_L ( EDI ) - POP_L ( ESI ) - RET -#undef FRAME_OFFSET - - - -ALIGNTEXT4 -GLOBL GLNAME(_mesa_sse_transform_points3_2d_no_rot) -HIDDEN(_mesa_sse_transform_points3_2d_no_rot) -GLNAME(_mesa_sse_transform_points3_2d_no_rot): - -#define FRAME_OFFSET 8 - PUSH_L( ESI ) - PUSH_L( EDI ) - - MOV_L( REGOFF(OFFSET_SOURCE+8, ESP), ESI ) /* ptr to source GLvector4f */ - MOV_L( REGOFF(OFFSET_DEST+8, ESP), EDI ) /* ptr to dest GLvector4f */ - - MOV_L( ARG_MATRIX, EDX ) /* ptr to matrix */ - MOV_L( REGOFF(V4F_COUNT, ESI), ECX ) /* source count */ - - TEST_L( ECX, ECX) - JZ( LLBL(K_GTP3P2DNRR_finish) ) /* count was zero; go to finish */ - - MOV_L( REGOFF(V4F_STRIDE, ESI), EAX ) /* stride */ - OR_L( CONST(VEC_SIZE_3), REGOFF(V4F_FLAGS, EDI) ) /* set dest flags */ - - MOV_L( ECX, REGOFF(V4F_COUNT, EDI) ) /* set dest count */ - MOV_L( CONST(3), REGOFF(V4F_SIZE, EDI) ) /* set dest size */ - - SHL_L( CONST(4), ECX ) /* count *= 16 */ - MOV_L( REGOFF(V4F_START, ESI), ESI ) /* ptr to first source vertex */ - - MOV_L( REGOFF(V4F_START, EDI), EDI ) /* ptr to first dest vertex */ - ADD_L( EDI, ECX ) /* count += dest ptr */ - -ALIGNTEXT32 - MOVSS ( M(0), XMM1 ) /* m0 */ - MOVSS ( M(5), XMM2 ) /* m5 */ - UNPCKLPS ( XMM2, XMM1 ) /* m5 | m0 */ - MOVLPS ( M(12), XMM2 ) /* m13 | m12 */ - -ALIGNTEXT32 -LLBL(K_GTP3P2DNRR_top): - MOVLPS( S(0), XMM0 ) /* oy | ox */ - MULPS( XMM1, XMM0 ) /* oy*m5 | ox*m0 */ - ADDPS( XMM2, XMM0 ) /* +m13 | +m12 */ - MOVLPS( XMM0, D(0) ) /* ->D(1) | ->D(0) */ - - MOVSS( S(2), XMM0 ) - MOVSS( XMM0, D(2) ) - -LLBL(K_GTP3P2DNRR_skip): - ADD_L( CONST(16), EDI ) - ADD_L( EAX, ESI ) - CMP_L( ECX, EDI ) - JNE( LLBL(K_GTP3P2DNRR_top) ) - -LLBL(K_GTP3P2DNRR_finish): - POP_L( EDI ) - POP_L( ESI ) - RET -#undef FRAME_OFFSET - - - - -ALIGNTEXT4 -GLOBL GLNAME(_mesa_sse_transform_points3_3d) -HIDDEN(_mesa_sse_transform_points3_3d) -GLNAME(_mesa_sse_transform_points3_3d): - -#define FRAME_OFFSET 8 - PUSH_L( ESI ) - PUSH_L( EDI ) - - MOV_L( REGOFF(OFFSET_SOURCE+8, ESP), ESI ) /* ptr to source GLvector4f */ - MOV_L( REGOFF(OFFSET_DEST+8, ESP), EDI ) /* ptr to dest GLvector4f */ - - - MOV_L( ARG_MATRIX, EDX ) /* ptr to matrix */ - MOV_L( REGOFF(V4F_COUNT, ESI), ECX ) /* source count */ - - TEST_L( ECX, ECX) - JZ( LLBL(K_GTP3P3DR_finish) ) /* count was zero; go to finish */ - - MOV_L( REGOFF(V4F_STRIDE, ESI), EAX ) /* stride */ - OR_L( CONST(VEC_SIZE_3), REGOFF(V4F_FLAGS, EDI) ) /* set dest flags */ - - MOV_L( ECX, REGOFF(V4F_COUNT, EDI) ) /* set dest count */ - MOV_L( CONST(3), REGOFF(V4F_SIZE, EDI) ) /* set dest size */ - - SHL_L( CONST(4), ECX ) /* count *= 16 */ - MOV_L( REGOFF(V4F_START, ESI), ESI ) /* ptr to first source vertex */ - - MOV_L( REGOFF(V4F_START, EDI), EDI ) /* ptr to first dest vertex */ - ADD_L( EDI, ECX ) /* count += dest ptr */ - - -ALIGNTEXT32 - MOVAPS( M(0), XMM0 ) /* m2 | m1 | m0 */ - MOVAPS( M(4), XMM1 ) /* m6 | m5 | m4 */ - MOVAPS( M(8), XMM2 ) /* m10 | m9 | m8 */ - MOVAPS( M(12), XMM3 ) /* m14 | m13 | m12 */ - -ALIGNTEXT32 -LLBL(K_GTP3P3DR_top): - MOVSS( S(0), XMM4 ) - SHUFPS( CONST(0x0), XMM4, XMM4 ) /* ox | ox | ox */ - MULPS( XMM0, XMM4 ) /* ox*m2 | ox*m1 | ox*m0 */ - - MOVSS( S(1), XMM5 ) - SHUFPS( CONST(0x0), XMM5, XMM5 ) /* oy | oy | oy */ - MULPS( XMM1, XMM5 ) /* oy*m6 | oy*m5 | oy*m4 */ - - MOVSS( S(2), XMM6 ) - SHUFPS( CONST(0x0), XMM6, XMM6 ) /* oz | oz | oz */ - MULPS( XMM2, XMM6 ) /* oz*m10 | oz*m9 | oz*m8 */ - - ADDPS( XMM5, XMM4 ) /* + | + | + */ - ADDPS( XMM6, XMM4 ) /* + | + | + */ - ADDPS( XMM3, XMM4 ) /* + | + | + */ - - MOVLPS( XMM4, D(0) ) /* => D(1) | => D(0) */ - UNPCKHPS( XMM4, XMM4 ) - MOVSS( XMM4, D(2) ) - -LLBL(K_GTP3P3DR_skip): - ADD_L( CONST(16), EDI ) - ADD_L( EAX, ESI ) - CMP_L( ECX, EDI ) - JNE( LLBL(K_GTP3P3DR_top) ) - -LLBL(K_GTP3P3DR_finish): - POP_L( EDI ) - POP_L( ESI ) - RET -#undef FRAME_OFFSET -#endif - -#if defined (__ELF__) && defined (__linux__) - .section .note.GNU-stack,"",%progbits -#endif diff --git a/dll/opengl/mesa/x86/sse_xform4.S b/dll/opengl/mesa/x86/sse_xform4.S deleted file mode 100644 index fb1fa741c01..00000000000 --- a/dll/opengl/mesa/x86/sse_xform4.S +++ /dev/null @@ -1,235 +0,0 @@ - -/* - * Mesa 3-D graphics library - * Version: 3.5 - * - * Copyright (C) 1999-2001 Brian Paul All Rights Reserved. - * - * Permission is hereby granted, free of charge, to any person obtaining a - * copy of this software and associated documentation files (the "Software"), - * to deal in the Software without restriction, including without limitation - * the rights to use, copy, modify, merge, publish, distribute, sublicense, - * and/or sell copies of the Software, and to permit persons to whom the - * Software is furnished to do so, subject to the following conditions: - * - * The above copyright notice and this permission notice shall be included - * in all copies or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS - * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL - * BRIAN PAUL BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN - * AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN - * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. - */ - -#ifdef USE_SSE_ASM -#include "assyntax.h" -#include "matypes.h" -#include "xform_args.h" - - SEG_TEXT - -#define FRAME_OFFSET 8 - -#define SRC(i) REGOFF(i * 4, ESI) -#define DST(i) REGOFF(i * 4, EDI) -#define MAT(i) REGOFF(i * 4, EDX) - -#define SELECT(r0, r1, r2, r3) CONST( r0 * 64 + r1 * 16 + r2 * 4 + r3 ) - - -ALIGNTEXT16 -GLOBL GLNAME( _mesa_sse_transform_points4_general ) -HIDDEN(_mesa_sse_transform_points4_general) -GLNAME( _mesa_sse_transform_points4_general ): - - PUSH_L( ESI ) - PUSH_L( EDI ) - - MOV_L( ARG_SOURCE, ESI ) - MOV_L( ARG_DEST, EDI ) - - MOV_L( ARG_MATRIX, EDX ) - MOV_L( REGOFF(V4F_COUNT, ESI), ECX ) - - TEST_L( ECX, ECX ) /* verify non-zero count */ - JE( LLBL( sse_general_done ) ) - - MOV_L( REGOFF(V4F_STRIDE, ESI), EAX ) /* stride */ - OR_L( CONST(VEC_SIZE_4), REGOFF(V4F_FLAGS, EDI) ) /* set dest flags */ - - MOV_L( ECX, REGOFF(V4F_COUNT, EDI) ) /* set dest count */ - MOV_L( CONST(4), REGOFF(V4F_SIZE, EDI) )/* set dest size */ - - MOV_L( REGOFF(V4F_START, ESI), ESI ) /* ptr to first source vertex */ - MOV_L( REGOFF(V4F_START, EDI), EDI ) /* ptr to first dest vertex */ - - PREFETCHT0( REGIND(ESI) ) - - MOVAPS( MAT(0), XMM4 ) /* m3 | m2 | m1 | m0 */ - MOVAPS( MAT(4), XMM5 ) /* m7 | m6 | m5 | m4 */ - MOVAPS( MAT(8), XMM6 ) /* m11 | m10 | m9 | m8 */ - MOVAPS( MAT(12), XMM7 ) /* m15 | m14 | m13 | m12 */ - -ALIGNTEXT16 -LLBL( sse_general_loop ): - - MOVSS( SRC(0), XMM0 ) /* ox */ - SHUFPS( CONST(0x0), XMM0, XMM0 ) /* ox | ox | ox | ox */ - MULPS( XMM4, XMM0 ) /* ox*m3 | ox*m2 | ox*m1 | ox*m0 */ - - MOVSS( SRC(1), XMM1 ) /* oy */ - SHUFPS( CONST(0x0), XMM1, XMM1 ) /* oy | oy | oy | oy */ - MULPS( XMM5, XMM1 ) /* oy*m7 | oy*m6 | oy*m5 | oy*m4 */ - - MOVSS( SRC(2), XMM2 ) /* oz */ - SHUFPS( CONST(0x0), XMM2, XMM2 ) /* oz | oz | oz | oz */ - MULPS( XMM6, XMM2 ) /* oz*m11 | oz*m10 | oz*m9 | oz*m8 */ - - MOVSS( SRC(3), XMM3 ) /* ow */ - SHUFPS( CONST(0x0), XMM3, XMM3 ) /* ow | ow | ow | ow */ - MULPS( XMM7, XMM3 ) /* ow*m15 | ow*m14 | ow*m13 | ow*m12 */ - - ADDPS( XMM1, XMM0 ) /* ox*m3+oy*m7 | ... */ - ADDPS( XMM2, XMM0 ) /* ox*m3+oy*m7+oz*m11 | ... */ - ADDPS( XMM3, XMM0 ) /* ox*m3+oy*m7+oz*m11+ow*m15 | ... */ - MOVAPS( XMM0, DST(0) ) /* ->D(3) | ->D(2) | ->D(1) | ->D(0) */ - - ADD_L( CONST(16), EDI ) - ADD_L( EAX, ESI ) - - DEC_L( ECX ) - JNZ( LLBL( sse_general_loop ) ) - -LLBL( sse_general_done ): - - POP_L( EDI ) - POP_L( ESI ) - RET - - - - -ALIGNTEXT4 -GLOBL GLNAME( _mesa_sse_transform_points4_3d ) -HIDDEN(_mesa_sse_transform_points4_3d) -GLNAME( _mesa_sse_transform_points4_3d ): - - PUSH_L( ESI ) - PUSH_L( EDI ) - - MOV_L( ARG_SOURCE, ESI ) /* ptr to source GLvector4f */ - MOV_L( ARG_DEST, EDI ) /* ptr to dest GLvector4f */ - - MOV_L( ARG_MATRIX, EDX ) /* ptr to matrix */ - MOV_L( REGOFF(V4F_COUNT, ESI), ECX ) /* source count */ - - TEST_L( ECX, ECX) - JZ( LLBL(K_GTP43P3DR_finish) ) /* count was zero; go to finish */ - - MOV_L( REGOFF(V4F_STRIDE, ESI), EAX ) /* stride */ - OR_L( CONST(VEC_SIZE_3), REGOFF(V4F_FLAGS, EDI) ) /* set dest flags */ - - MOV_L( ECX, REGOFF(V4F_COUNT, EDI) ) /* set dest count */ - MOV_L( CONST(3), REGOFF(V4F_SIZE, EDI) )/* set dest size */ - - SHL_L( CONST(4), ECX ) /* count *= 16 */ - MOV_L( REGOFF(V4F_START, ESI), ESI ) /* ptr to first source vertex */ - - MOV_L( REGOFF(V4F_START, EDI), EDI ) /* ptr to first dest vertex */ - ADD_L( EDI, ECX ) /* count += dest ptr */ - - MOVAPS( MAT(0), XMM0 ) /* m3 | m2 | m1 | m0 */ - MOVAPS( MAT(4), XMM1 ) /* m7 | m6 | m5 | m4 */ - MOVAPS( MAT(8), XMM2 ) /* m11 | m10 | m9 | m8 */ - MOVAPS( MAT(12), XMM3 ) /* m15 | m14 | m13 | m12 */ - -ALIGNTEXT32 -LLBL( K_GTP43P3DR_top ): - MOVSS( SRC(0), XMM4 ) /* ox */ - SHUFPS( CONST(0x0), XMM4, XMM4 ) /* ox | ox | ox | ox */ - MULPS( XMM0, XMM4 ) /* ox*m3 | ox*m2 | ox*m1 | ox*m0 */ - - MOVSS( SRC(1), XMM5 ) /* oy */ - SHUFPS( CONST(0x0), XMM5, XMM5 ) /* oy | oy | oy | oy */ - MULPS( XMM1, XMM5 ) /* oy*m7 | oy*m6 | oy*m5 | oy*m4 */ - - MOVSS( SRC(2), XMM6 ) /* oz */ - SHUFPS( CONST(0x0), XMM6, XMM6 ) /* oz | oz | oz | oz */ - MULPS( XMM2, XMM6 ) /* oz*m11 | oz*m10 | oz*m9 | oz*m8 */ - - MOVSS( SRC(3), XMM7 ) /* ow */ - SHUFPS( CONST(0x0), XMM7, XMM7 ) /* ow | ow | ow | ow */ - MULPS( XMM3, XMM7 ) /* ow*m15 | ow*m14 | ow*m13 | ow*m12 */ - - ADDPS( XMM5, XMM4 ) /* ox*m3+oy*m7 | ... */ - ADDPS( XMM6, XMM4 ) /* ox*m3+oy*m7+oz*m11 | ... */ - ADDPS( XMM7, XMM4 ) /* ox*m3+oy*m7+oz*m11+ow*m15 | ... */ - MOVAPS( XMM4, DST(0) ) /* ->D(3) | ->D(2) | ->D(1) | ->D(0) */ - - MOVSS( SRC(3), XMM4 ) /* ow */ - MOVSS( XMM4, DST(3) ) /* ->D(3) */ - -LLBL( K_GTP43P3DR_skip ): - ADD_L( CONST(16), EDI ) - ADD_L( EAX, ESI ) - CMP_L( ECX, EDI ) - JNE( LLBL(K_GTP43P3DR_top) ) - -LLBL( K_GTP43P3DR_finish ): - POP_L( EDI ) - POP_L( ESI ) - RET - - -ALIGNTEXT16 -GLOBL GLNAME( _mesa_sse_transform_points4_identity ) -HIDDEN(_mesa_sse_transform_points4_identity) -GLNAME( _mesa_sse_transform_points4_identity ): - - PUSH_L( ESI ) - PUSH_L( EDI ) - - MOV_L( ARG_SOURCE, ESI ) - MOV_L( ARG_DEST, EDI ) - - MOV_L( ARG_MATRIX, EDX ) - MOV_L( REGOFF(V4F_COUNT, ESI), ECX ) - - TEST_L( ECX, ECX ) /* verify non-zero count */ - JE( LLBL( sse_identity_done ) ) - - MOV_L( REGOFF(V4F_STRIDE, ESI), EAX ) /* stride */ - OR_L( CONST(VEC_SIZE_4), REGOFF(V4F_FLAGS, EDI) ) /* set dest flags */ - - MOV_L( ECX, REGOFF(V4F_COUNT, EDI) ) /* set dest count */ - MOV_L( CONST(4), REGOFF(V4F_SIZE, EDI) )/* set dest size */ - - MOV_L( REGOFF(V4F_START, ESI), ESI ) /* ptr to first source vertex */ - MOV_L( REGOFF(V4F_START, EDI), EDI ) /* ptr to first dest vertex */ - -ALIGNTEXT16 -LLBL( sse_identity_loop ): - - PREFETCHNTA( REGOFF(32, ESI) ) - - MOVAPS( REGIND(ESI), XMM0 ) - ADD_L( EAX, ESI ) - - MOVAPS( XMM0, REGIND(EDI) ) - ADD_L( CONST(16), EDI ) - - DEC_L( ECX ) - JNZ( LLBL( sse_identity_loop ) ) - -LLBL( sse_identity_done ): - - POP_L( EDI ) - POP_L( ESI ) - RET -#endif - -#if defined (__ELF__) && defined (__linux__) - .section .note.GNU-stack,"",%progbits -#endif diff --git a/dll/opengl/mesa/x86/x86_cliptest.S b/dll/opengl/mesa/x86/x86_cliptest.S deleted file mode 100644 index e413aee61ed..00000000000 --- a/dll/opengl/mesa/x86/x86_cliptest.S +++ /dev/null @@ -1,407 +0,0 @@ - -/* - * Mesa 3-D graphics library - * Version: 3.5 - * - * Copyright (C) 1999-2001 Brian Paul All Rights Reserved. - * - * Permission is hereby granted, free of charge, to any person obtaining a - * copy of this software and associated documentation files (the "Software"), - * to deal in the Software without restriction, including without limitation - * the rights to use, copy, modify, merge, publish, distribute, sublicense, - * and/or sell copies of the Software, and to permit persons to whom the - * Software is furnished to do so, subject to the following conditions: - * - * The above copyright notice and this permission notice shall be included - * in all copies or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS - * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL - * BRIAN PAUL BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN - * AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN - * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. - */ - -/* - * NOTE: Avoid using spaces in between '(' ')' and arguments, especially - * with macros like CONST, LLBL that expand to CONCAT(...). Putting spaces - * in there will break the build on some platforms. - */ - -#include "assyntax.h" -#include "matypes.h" -#include "clip_args.h" - -#define SRC0 REGOFF(0, ESI) -#define SRC1 REGOFF(4, ESI) -#define SRC2 REGOFF(8, ESI) -#define SRC3 REGOFF(12, ESI) -#define DST0 REGOFF(0, EDI) -#define DST1 REGOFF(4, EDI) -#define DST2 REGOFF(8, EDI) -#define DST3 REGOFF(12, EDI) -#define MAT0 REGOFF(0, EDX) -#define MAT1 REGOFF(4, EDX) -#define MAT2 REGOFF(8, EDX) -#define MAT3 REGOFF(12, EDX) - - -/* - * Table for clip test. - * - * bit6 = SRC3 < 0 - * bit5 = SRC2 < 0 - * bit4 = abs(S(2)) > abs(S(3)) - * bit3 = SRC1 < 0 - * bit2 = abs(S(1)) > abs(S(3)) - * bit1 = SRC0 < 0 - * bit0 = abs(S(0)) > abs(S(3)) - */ - - SEG_DATA - -clip_table: - D_BYTE 0x00, 0x01, 0x00, 0x02, 0x04, 0x05, 0x04, 0x06 - D_BYTE 0x00, 0x01, 0x00, 0x02, 0x08, 0x09, 0x08, 0x0a - D_BYTE 0x20, 0x21, 0x20, 0x22, 0x24, 0x25, 0x24, 0x26 - D_BYTE 0x20, 0x21, 0x20, 0x22, 0x28, 0x29, 0x28, 0x2a - D_BYTE 0x00, 0x01, 0x00, 0x02, 0x04, 0x05, 0x04, 0x06 - D_BYTE 0x00, 0x01, 0x00, 0x02, 0x08, 0x09, 0x08, 0x0a - D_BYTE 0x10, 0x11, 0x10, 0x12, 0x14, 0x15, 0x14, 0x16 - D_BYTE 0x10, 0x11, 0x10, 0x12, 0x18, 0x19, 0x18, 0x1a - D_BYTE 0x3f, 0x3d, 0x3f, 0x3e, 0x37, 0x35, 0x37, 0x36 - D_BYTE 0x3f, 0x3d, 0x3f, 0x3e, 0x3b, 0x39, 0x3b, 0x3a - D_BYTE 0x2f, 0x2d, 0x2f, 0x2e, 0x27, 0x25, 0x27, 0x26 - D_BYTE 0x2f, 0x2d, 0x2f, 0x2e, 0x2b, 0x29, 0x2b, 0x2a - D_BYTE 0x3f, 0x3d, 0x3f, 0x3e, 0x37, 0x35, 0x37, 0x36 - D_BYTE 0x3f, 0x3d, 0x3f, 0x3e, 0x3b, 0x39, 0x3b, 0x3a - D_BYTE 0x1f, 0x1d, 0x1f, 0x1e, 0x17, 0x15, 0x17, 0x16 - D_BYTE 0x1f, 0x1d, 0x1f, 0x1e, 0x1b, 0x19, 0x1b, 0x1a - - - SEG_TEXT - -/* - * _mesa_x86_cliptest_points4 - * - * AL: ormask - * AH: andmask - * EBX: temp0 - * ECX: temp1 - * EDX: clipmask[] - * ESI: clip[] - * EDI: proj[] - * EBP: temp2 - */ - -#if defined(__ELF__) && defined(__PIC__) && defined(GNU_ASSEMBLER) && !defined(ELFPIC) -#define ELFPIC -#endif - -ALIGNTEXT16 -GLOBL GLNAME( _mesa_x86_cliptest_points4 ) -HIDDEN(_mesa_x86_cliptest_points4) -GLNAME( _mesa_x86_cliptest_points4 ): - -#ifdef ELFPIC -#define FRAME_OFFSET 20 -#else -#define FRAME_OFFSET 16 -#endif - PUSH_L( ESI ) - PUSH_L( EDI ) - PUSH_L( EBP ) - PUSH_L( EBX ) - -#ifdef ELFPIC - /* store pointer to clip_table on stack */ - CALL( LLBL(ctp4_get_eip) ) - ADD_L( CONST(_GLOBAL_OFFSET_TABLE_), EBX ) - MOV_L( REGOFF(clip_table@GOT, EBX), EBX ) - PUSH_L( EBX ) - JMP( LLBL(ctp4_clip_table_ready) ) - -LLBL(ctp4_get_eip): - /* store eip in ebx */ - MOV_L( REGIND(ESP), EBX ) - RET - -LLBL(ctp4_clip_table_ready): -#endif - - MOV_L( ARG_SOURCE, ESI ) - MOV_L( ARG_DEST, EDI ) - - MOV_L( ARG_CLIP, EDX ) - MOV_L( ARG_OR, EBX ) - - MOV_L( ARG_AND, EBP ) - MOV_L( REGOFF(V4F_STRIDE, ESI), EAX ) - - MOV_L( REGOFF(V4F_COUNT, ESI), ECX ) - MOV_L( REGOFF(V4F_START, ESI), ESI ) - - OR_L( CONST(VEC_SIZE_4), REGOFF(V4F_FLAGS, EDI) ) - MOV_L( EAX, ARG_SOURCE ) /* put stride in ARG_SOURCE */ - - MOV_L( CONST(4), REGOFF(V4F_SIZE, EDI) ) - MOV_L( ECX, REGOFF(V4F_COUNT, EDI) ) - - MOV_L( REGOFF(V4F_START, EDI), EDI ) - ADD_L( EDX, ECX ) - - MOV_L( ECX, ARG_CLIP ) /* put clipmask + count in ARG_CLIP */ - CMP_L( ECX, EDX ) - - MOV_B( REGIND(EBX), AL ) - MOV_B( REGIND(EBP), AH ) - - JZ( LLBL(ctp4_finish) ) - -ALIGNTEXT16 -LLBL(ctp4_top): - - FLD1 /* F3 */ - FDIV_S( SRC3 ) /* GH: don't care about div-by-zero */ - - MOV_L( SRC3, EBP ) - MOV_L( SRC2, EBX ) - - XOR_L( ECX, ECX ) - ADD_L( EBP, EBP ) /* ebp = abs(S(3))*2 ; carry = sign of S(3) */ - - ADC_L( ECX, ECX ) - ADD_L( EBX, EBX ) /* ebx = abs(S(2))*2 ; carry = sign of S(2) */ - - ADC_L( ECX, ECX ) - CMP_L( EBX, EBP ) /* carry = abs(S(2))*2 > abs(S(3))*2 */ - - ADC_L( ECX, ECX ) - MOV_L( SRC1, EBX ) - - ADD_L( EBX, EBX ) /* ebx = abs(S(1))*2 ; carry = sign of S(1) */ - - ADC_L( ECX, ECX ) - CMP_L( EBX, EBP ) /* carry = abs(S(1))*2 > abs(S(3))*2 */ - - ADC_L( ECX, ECX ) - MOV_L( SRC0, EBX ) - - ADD_L( EBX, EBX ) /* ebx = abs(S(0))*2 ; carry = sign of S(0) */ - - ADC_L( ECX, ECX ) - CMP_L( EBX, EBP ) /* carry = abs(S(0))*2 > abs(S(3))*2 */ - - ADC_L( ECX, ECX ) - -#ifdef ELFPIC - MOV_L( REGIND(ESP), EBP ) /* clip_table */ - - MOV_B( REGBI(EBP, ECX), CL ) -#else - MOV_B( REGOFF(clip_table,ECX), CL ) -#endif - - OR_B( CL, AL ) - AND_B( CL, AH ) - - TEST_B( CL, CL ) - MOV_B( CL, REGIND(EDX) ) - - JZ( LLBL(ctp4_proj) ) - -LLBL(ctp4_noproj): - - FSTP( ST(0) ) /* */ - - MOV_L( CONST(0), DST0 ) - MOV_L( CONST(0), DST1 ) - MOV_L( CONST(0), DST2 ) - MOV_L( CONST(0x3f800000), DST3 ) - - JMP( LLBL(ctp4_next) ) - -LLBL(ctp4_proj): - - FLD_S( SRC0 ) /* F0 F3 */ - FMUL2( ST(1), ST0 ) - - FLD_S( SRC1 ) /* F1 F0 F3 */ - FMUL2( ST(2), ST0 ) - - FLD_S( SRC2 ) /* F2 F1 F0 F3 */ - FMUL2( ST(3), ST0 ) - - FXCH( ST(2) ) /* F0 F1 F2 F3 */ - FSTP_S( DST0 ) /* F1 F2 F3 */ - FSTP_S( DST1 ) /* F2 F3 */ - FSTP_S( DST2 ) /* F3 */ - FSTP_S( DST3 ) /* */ - -LLBL(ctp4_next): - - INC_L( EDX ) - ADD_L( CONST(16), EDI ) - - ADD_L( ARG_SOURCE, ESI ) - CMP_L( EDX, ARG_CLIP ) - - JNZ( LLBL(ctp4_top) ) - - MOV_L( ARG_OR, ECX ) - MOV_L( ARG_AND, EDX ) - - MOV_B( AL, REGIND(ECX) ) - MOV_B( AH, REGIND(EDX) ) - -LLBL(ctp4_finish): - - MOV_L( ARG_DEST, EAX ) -#ifdef ELFPIC - POP_L( ESI ) /* discard ptr to clip_table */ -#endif - POP_L( EBX ) - POP_L( EBP ) - POP_L( EDI ) - POP_L( ESI ) - - RET - - - - - - - -ALIGNTEXT16 -GLOBL GLNAME( _mesa_x86_cliptest_points4_np ) -HIDDEN(_mesa_x86_cliptest_points4_np) -GLNAME( _mesa_x86_cliptest_points4_np ): - -#ifdef ELFPIC -#define FRAME_OFFSET 20 -#else -#define FRAME_OFFSET 16 -#endif - PUSH_L( ESI ) - PUSH_L( EDI ) - PUSH_L( EBP ) - PUSH_L( EBX ) - -#ifdef ELFPIC - /* store pointer to clip_table on stack */ - CALL( LLBL(ctp4_np_get_eip) ) - ADD_L( CONST(_GLOBAL_OFFSET_TABLE_), EBX ) - MOV_L( REGOFF(clip_table@GOT, EBX), EBX ) - PUSH_L( EBX ) - JMP( LLBL(ctp4_np_clip_table_ready) ) - -LLBL(ctp4_np_get_eip): - /* store eip in ebx */ - MOV_L( REGIND(ESP), EBX ) - RET - -LLBL(ctp4_np_clip_table_ready): -#endif - - MOV_L( ARG_SOURCE, ESI ) - /* slot */ - - MOV_L( ARG_CLIP, EDX ) - MOV_L( ARG_OR, EBX ) - - MOV_L( ARG_AND, EBP ) - MOV_L( REGOFF(V4F_STRIDE, ESI), EAX ) - - MOV_L( REGOFF(V4F_COUNT, ESI), ECX ) - MOV_L( REGOFF(V4F_START, ESI), ESI ) - - MOV_L( EAX, ARG_DEST ) /* put stride in ARG_DEST */ - ADD_L( EDX, ECX ) - - MOV_L( ECX, EDI ) /* put clipmask + count in EDI */ - CMP_L( ECX, EDX ) - - MOV_B( REGIND(EBX), AL ) - MOV_B( REGIND(EBP), AH ) - - JZ( LLBL(ctp4_np_finish) ) - -ALIGNTEXT16 -LLBL(ctp4_np_top): - - MOV_L( SRC3, EBP ) - MOV_L( SRC2, EBX ) - - XOR_L( ECX, ECX ) - ADD_L( EBP, EBP ) /* ebp = abs(S(3))*2 ; carry = sign of S(3) */ - - ADC_L( ECX, ECX ) - ADD_L( EBX, EBX ) /* ebx = abs(S(2))*2 ; carry = sign of S(2) */ - - ADC_L( ECX, ECX ) - CMP_L( EBX, EBP ) /* carry = abs(S(2))*2 > abs(S(3))*2 */ - - ADC_L( ECX, ECX ) - MOV_L( SRC1, EBX ) - - ADD_L( EBX, EBX ) /* ebx = abs(S(1))*2 ; carry = sign of S(1) */ - - ADC_L( ECX, ECX ) - CMP_L( EBX, EBP ) /* carry = abs(S(1))*2 > abs(S(3))*2 */ - - ADC_L( ECX, ECX ) - MOV_L( SRC0, EBX ) - - ADD_L( EBX, EBX ) /* ebx = abs(S(0))*2 ; carry = sign of S(0) */ - - ADC_L( ECX, ECX ) - CMP_L( EBX, EBP ) /* carry = abs(S(0))*2 > abs(S(3))*2 */ - - ADC_L( ECX, ECX ) - -#ifdef ELFPIC - MOV_L( REGIND(ESP), EBP ) /* clip_table */ - - MOV_B( REGBI(EBP, ECX), CL ) -#else - MOV_B( REGOFF(clip_table,ECX), CL ) -#endif - - OR_B( CL, AL ) - AND_B( CL, AH ) - - TEST_B( CL, CL ) - MOV_B( CL, REGIND(EDX) ) - - INC_L( EDX ) - /* slot */ - - ADD_L( ARG_DEST, ESI ) - CMP_L( EDX, EDI ) - - JNZ( LLBL(ctp4_np_top) ) - - MOV_L( ARG_OR, ECX ) - MOV_L( ARG_AND, EDX ) - - MOV_B( AL, REGIND(ECX) ) - MOV_B( AH, REGIND(EDX) ) - -LLBL(ctp4_np_finish): - - MOV_L( ARG_SOURCE, EAX ) -#ifdef ELFPIC - POP_L( ESI ) /* discard ptr to clip_table */ -#endif - POP_L( EBX ) - POP_L( EBP ) - POP_L( EDI ) - POP_L( ESI ) - - RET - -#if defined (__ELF__) && defined (__linux__) - .section .note.GNU-stack,"",%progbits -#endif diff --git a/dll/opengl/mesa/x86/x86_xform.c b/dll/opengl/mesa/x86/x86_xform.c deleted file mode 100644 index 8e5a0907444..00000000000 --- a/dll/opengl/mesa/x86/x86_xform.c +++ /dev/null @@ -1,124 +0,0 @@ - -/* - * Mesa 3-D graphics library - * Version: 3.5 - * - * Copyright (C) 1999-2001 Brian Paul All Rights Reserved. - * - * Permission is hereby granted, free of charge, to any person obtaining a - * copy of this software and associated documentation files (the "Software"), - * to deal in the Software without restriction, including without limitation - * the rights to use, copy, modify, merge, publish, distribute, sublicense, - * and/or sell copies of the Software, and to permit persons to whom the - * Software is furnished to do so, subject to the following conditions: - * - * The above copyright notice and this permission notice shall be included - * in all copies or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS - * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL - * BRIAN PAUL BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN - * AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN - * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. - */ - -/* - * Intel x86 assembly code by Josh Vanderhoof - */ - -#include "main/glheader.h" -#include "main/context.h" -#include "math/m_xform.h" - -#include "x86_xform.h" -#include "common_x86_asm.h" - -#ifdef USE_X86_ASM -#ifdef USE_3DNOW_ASM -#include "3dnow.h" -#endif -#ifdef USE_SSE_ASM -#include "sse.h" -#endif -#endif - -#ifdef DEBUG_MATH -#include "math/m_debug.h" -#endif - - -#ifdef USE_X86_ASM -DECLARE_XFORM_GROUP( x86, 2 ) -DECLARE_XFORM_GROUP( x86, 3 ) -DECLARE_XFORM_GROUP( x86, 4 ) - - -extern GLvector4f * _ASMAPI -_mesa_x86_cliptest_points4( GLvector4f *clip_vec, - GLvector4f *proj_vec, - GLubyte clipMask[], - GLubyte *orMask, - GLubyte *andMask ); - -extern GLvector4f * _ASMAPI -_mesa_x86_cliptest_points4_np( GLvector4f *clip_vec, - GLvector4f *proj_vec, - GLubyte clipMask[], - GLubyte *orMask, - GLubyte *andMask); - -extern void _ASMAPI -_mesa_v16_x86_cliptest_points4( GLfloat *first_vert, - GLfloat *last_vert, - GLubyte *or_mask, - GLubyte *and_mask, - GLubyte *clip_mask, - GLboolean viewport_z_clip ); - -extern void _ASMAPI -_mesa_v16_x86_general_xform( GLfloat *dest, - const GLfloat *m, - const GLfloat *src, - GLuint src_stride, - GLuint count ); -#endif - - -#ifdef USE_X86_ASM -static void _mesa_init_x86_transform_asm( void ) -{ - ASSIGN_XFORM_GROUP( x86, 2 ); - ASSIGN_XFORM_GROUP( x86, 3 ); - ASSIGN_XFORM_GROUP( x86, 4 ); - - _mesa_clip_tab[4] = _mesa_x86_cliptest_points4; - _mesa_clip_np_tab[4] = _mesa_x86_cliptest_points4_np; - -#ifdef DEBUG_MATH - _math_test_all_transform_functions( "x86" ); - _math_test_all_cliptest_functions( "x86" ); -#endif -} -#endif - - -void _mesa_init_all_x86_transform_asm( void ) -{ - _mesa_get_x86_features(); - -#ifdef USE_X86_ASM - if ( _mesa_x86_cpu_features ) { - _mesa_init_x86_transform_asm(); - } - - if (cpu_has_3dnow) { - _mesa_init_3dnow_transform_asm(); - } - - if ( cpu_has_xmm ) { - _mesa_init_sse_transform_asm(); - } - -#endif -} diff --git a/dll/opengl/mesa/x86/x86_xform.h b/dll/opengl/mesa/x86/x86_xform.h deleted file mode 100644 index e886d9add2a..00000000000 --- a/dll/opengl/mesa/x86/x86_xform.h +++ /dev/null @@ -1,106 +0,0 @@ - -/* - * Mesa 3-D graphics library - * Version: 3.5 - * - * Copyright (C) 1999-2001 Brian Paul All Rights Reserved. - * - * Permission is hereby granted, free of charge, to any person obtaining a - * copy of this software and associated documentation files (the "Software"), - * to deal in the Software without restriction, including without limitation - * the rights to use, copy, modify, merge, publish, distribute, sublicense, - * and/or sell copies of the Software, and to permit persons to whom the - * Software is furnished to do so, subject to the following conditions: - * - * The above copyright notice and this permission notice shall be included - * in all copies or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS - * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL - * BRIAN PAUL BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN - * AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN - * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. - * - * Authors: - * Gareth Hughes - */ - -#ifndef X86_XFORM_H -#define X86_XFORM_H - - -/* ============================================================= - * Transformation function declarations: - */ - -#define XFORM_ARGS GLvector4f *to_vec, \ - const GLfloat m[16], \ - const GLvector4f *from_vec - -#define DECLARE_XFORM_GROUP( pfx, sz ) \ -extern void _ASMAPI _mesa_##pfx##_transform_points##sz##_general( XFORM_ARGS ); \ -extern void _ASMAPI _mesa_##pfx##_transform_points##sz##_identity( XFORM_ARGS ); \ -extern void _ASMAPI _mesa_##pfx##_transform_points##sz##_3d_no_rot( XFORM_ARGS ); \ -extern void _ASMAPI _mesa_##pfx##_transform_points##sz##_perspective( XFORM_ARGS ); \ -extern void _ASMAPI _mesa_##pfx##_transform_points##sz##_2d( XFORM_ARGS ); \ -extern void _ASMAPI _mesa_##pfx##_transform_points##sz##_2d_no_rot( XFORM_ARGS ); \ -extern void _ASMAPI _mesa_##pfx##_transform_points##sz##_3d( XFORM_ARGS ); - -#define ASSIGN_XFORM_GROUP( pfx, sz ) \ - _mesa_transform_tab[sz][MATRIX_GENERAL] = \ - _mesa_##pfx##_transform_points##sz##_general; \ - _mesa_transform_tab[sz][MATRIX_IDENTITY] = \ - _mesa_##pfx##_transform_points##sz##_identity; \ - _mesa_transform_tab[sz][MATRIX_3D_NO_ROT] = \ - _mesa_##pfx##_transform_points##sz##_3d_no_rot; \ - _mesa_transform_tab[sz][MATRIX_PERSPECTIVE] = \ - _mesa_##pfx##_transform_points##sz##_perspective; \ - _mesa_transform_tab[sz][MATRIX_2D] = \ - _mesa_##pfx##_transform_points##sz##_2d; \ - _mesa_transform_tab[sz][MATRIX_2D_NO_ROT] = \ - _mesa_##pfx##_transform_points##sz##_2d_no_rot; \ - _mesa_transform_tab[sz][MATRIX_3D] = \ - _mesa_##pfx##_transform_points##sz##_3d; - - -/* ============================================================= - * Normal transformation function declarations: - */ - -#define NORM_ARGS const GLmatrix *mat, \ - GLfloat scale, \ - const GLvector4f *in, \ - const GLfloat *lengths, \ - GLvector4f *dest - -#define DECLARE_NORM_GROUP( pfx ) \ -extern void _ASMAPI _mesa_##pfx##_rescale_normals( NORM_ARGS ); \ -extern void _ASMAPI _mesa_##pfx##_normalize_normals( NORM_ARGS ); \ -extern void _ASMAPI _mesa_##pfx##_transform_normals( NORM_ARGS ); \ -extern void _ASMAPI _mesa_##pfx##_transform_normals_no_rot( NORM_ARGS ); \ -extern void _ASMAPI _mesa_##pfx##_transform_rescale_normals( NORM_ARGS ); \ -extern void _ASMAPI _mesa_##pfx##_transform_rescale_normals_no_rot( NORM_ARGS ); \ -extern void _ASMAPI _mesa_##pfx##_transform_normalize_normals( NORM_ARGS ); \ -extern void _ASMAPI _mesa_##pfx##_transform_normalize_normals_no_rot( NORM_ARGS ); - -#define ASSIGN_NORM_GROUP( pfx ) \ - _mesa_normal_tab[NORM_RESCALE] = \ - _mesa_##pfx##_rescale_normals; \ - _mesa_normal_tab[NORM_NORMALIZE] = \ - _mesa_##pfx##_normalize_normals; \ - _mesa_normal_tab[NORM_TRANSFORM] = \ - _mesa_##pfx##_transform_normals; \ - _mesa_normal_tab[NORM_TRANSFORM_NO_ROT] = \ - _mesa_##pfx##_transform_normals_no_rot; \ - _mesa_normal_tab[NORM_TRANSFORM | NORM_RESCALE] = \ - _mesa_##pfx##_transform_rescale_normals; \ - _mesa_normal_tab[NORM_TRANSFORM_NO_ROT | NORM_RESCALE] = \ - _mesa_##pfx##_transform_rescale_normals_no_rot; \ - _mesa_normal_tab[NORM_TRANSFORM | NORM_NORMALIZE] = \ - _mesa_##pfx##_transform_normalize_normals; \ - _mesa_normal_tab[NORM_TRANSFORM_NO_ROT | NORM_NORMALIZE] = \ - _mesa_##pfx##_transform_normalize_normals_no_rot; - - -#endif diff --git a/dll/opengl/mesa/x86/x86_xform2.S b/dll/opengl/mesa/x86/x86_xform2.S deleted file mode 100644 index 980725ef518..00000000000 --- a/dll/opengl/mesa/x86/x86_xform2.S +++ /dev/null @@ -1,574 +0,0 @@ - -/* - * Mesa 3-D graphics library - * Version: 3.5 - * - * Copyright (C) 1999-2001 Brian Paul All Rights Reserved. - * - * Permission is hereby granted, free of charge, to any person obtaining a - * copy of this software and associated documentation files (the "Software"), - * to deal in the Software without restriction, including without limitation - * the rights to use, copy, modify, merge, publish, distribute, sublicense, - * and/or sell copies of the Software, and to permit persons to whom the - * Software is furnished to do so, subject to the following conditions: - * - * The above copyright notice and this permission notice shall be included - * in all copies or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS - * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL - * BRIAN PAUL BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN - * AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN - * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. - */ - -/* - * NOTE: Avoid using spaces in between '(' ')' and arguments, especially - * with macros like CONST, LLBL that expand to CONCAT(...). Putting spaces - * in there will break the build on some platforms. - */ - -#include "assyntax.h" -#include "matypes.h" -#include "xform_args.h" - - SEG_TEXT - -#define FP_ONE 1065353216 -#define FP_ZERO 0 - -#define SRC0 REGOFF(0, ESI) -#define SRC1 REGOFF(4, ESI) -#define SRC2 REGOFF(8, ESI) -#define SRC3 REGOFF(12, ESI) -#define DST0 REGOFF(0, EDI) -#define DST1 REGOFF(4, EDI) -#define DST2 REGOFF(8, EDI) -#define DST3 REGOFF(12, EDI) -#define MAT0 REGOFF(0, EDX) -#define MAT1 REGOFF(4, EDX) -#define MAT2 REGOFF(8, EDX) -#define MAT3 REGOFF(12, EDX) -#define MAT4 REGOFF(16, EDX) -#define MAT5 REGOFF(20, EDX) -#define MAT6 REGOFF(24, EDX) -#define MAT7 REGOFF(28, EDX) -#define MAT8 REGOFF(32, EDX) -#define MAT9 REGOFF(36, EDX) -#define MAT10 REGOFF(40, EDX) -#define MAT11 REGOFF(44, EDX) -#define MAT12 REGOFF(48, EDX) -#define MAT13 REGOFF(52, EDX) -#define MAT14 REGOFF(56, EDX) -#define MAT15 REGOFF(60, EDX) - - -ALIGNTEXT16 -GLOBL GLNAME( _mesa_x86_transform_points2_general ) -HIDDEN(_mesa_x86_transform_points2_general) -GLNAME( _mesa_x86_transform_points2_general ): - -#define FRAME_OFFSET 8 - PUSH_L( ESI ) - PUSH_L( EDI ) - - MOV_L( ARG_SOURCE, ESI ) - MOV_L( ARG_DEST, EDI ) - - MOV_L( ARG_MATRIX, EDX ) - MOV_L( REGOFF(V4F_COUNT, ESI), ECX ) - - TEST_L( ECX, ECX ) - JZ( LLBL(x86_p2_gr_done) ) - - MOV_L( REGOFF(V4F_STRIDE, ESI), EAX ) - OR_L( CONST(VEC_SIZE_4), REGOFF(V4F_FLAGS, EDI) ) - - MOV_L( ECX, REGOFF(V4F_COUNT, EDI) ) - MOV_L( CONST(4), REGOFF(V4F_SIZE, EDI) ) - - SHL_L( CONST(4), ECX ) - MOV_L( REGOFF(V4F_START, ESI), ESI ) - - MOV_L( REGOFF(V4F_START, EDI), EDI ) - ADD_L( EDI, ECX ) - -ALIGNTEXT16 -LLBL(x86_p2_gr_loop): - - FLD_S( SRC0 ) /* F4 */ - FMUL_S( MAT0 ) - FLD_S( SRC0 ) /* F5 F4 */ - FMUL_S( MAT1 ) - FLD_S( SRC0 ) /* F6 F5 F4 */ - FMUL_S( MAT2 ) - FLD_S( SRC0 ) /* F7 F6 F5 F4 */ - FMUL_S( MAT3 ) - - FLD_S( SRC1 ) /* F0 F7 F6 F5 F4 */ - FMUL_S( MAT4 ) - FLD_S( SRC1 ) /* F1 F0 F7 F6 F5 F4 */ - FMUL_S( MAT5 ) - FLD_S( SRC1 ) /* F2 F1 F0 F7 F6 F5 F4 */ - FMUL_S( MAT6 ) - FLD_S( SRC1 ) /* F3 F2 F1 F0 F7 F6 F5 F4 */ - FMUL_S( MAT7 ) - - FXCH( ST(3) ) /* F0 F2 F1 F3 F7 F6 F5 F4 */ - FADDP( ST0, ST(7) ) /* F2 F1 F3 F7 F6 F5 F4 */ - FXCH( ST(1) ) /* F1 F2 F3 F7 F6 F5 F4 */ - FADDP( ST0, ST(5) ) /* F2 F3 F7 F6 F5 F4 */ - FADDP( ST0, ST(3) ) /* F3 F7 F6 F5 F4 */ - FADDP( ST0, ST(1) ) /* F7 F6 F5 F4 */ - - FXCH( ST(3) ) /* F4 F6 F5 F7 */ - FADD_S( MAT12 ) - FXCH( ST(2) ) /* F5 F6 F4 F7 */ - FADD_S( MAT13 ) - FXCH( ST(1) ) /* F6 F5 F4 F7 */ - FADD_S( MAT14 ) - FXCH( ST(3) ) /* F7 F5 F4 F6 */ - FADD_S( MAT15 ) - - FXCH( ST(2) ) /* F4 F5 F7 F6 */ - FSTP_S( DST0 ) /* F5 F7 F6 */ - FSTP_S( DST1 ) /* F7 F6 */ - FXCH( ST(1) ) /* F6 F7 */ - FSTP_S( DST2 ) /* F7 */ - FSTP_S( DST3 ) /* */ - -LLBL(x86_p2_gr_skip): - - ADD_L( CONST(16), EDI ) - ADD_L( EAX, ESI ) - CMP_L( ECX, EDI ) - JNE( LLBL(x86_p2_gr_loop) ) - -LLBL(x86_p2_gr_done): - - POP_L( EDI ) - POP_L( ESI ) - RET -#undef FRAME_OFFSET - - - - -ALIGNTEXT16 -GLOBL GLNAME( _mesa_x86_transform_points2_perspective ) -HIDDEN(_mesa_x86_transform_points2_perspective) -GLNAME( _mesa_x86_transform_points2_perspective ): - -#define FRAME_OFFSET 12 - PUSH_L( ESI ) - PUSH_L( EDI ) - PUSH_L( EBX ) - - MOV_L( ARG_SOURCE, ESI ) - MOV_L( ARG_DEST, EDI ) - - MOV_L( ARG_MATRIX, EDX ) - MOV_L( REGOFF(V4F_COUNT, ESI), ECX ) - - TEST_L( ECX, ECX ) - JZ( LLBL(x86_p2_pr_done) ) - - MOV_L( REGOFF(V4F_STRIDE, ESI), EAX ) - OR_L( CONST(VEC_SIZE_4), REGOFF(V4F_FLAGS, EDI) ) - - MOV_L( ECX, REGOFF(V4F_COUNT, EDI) ) - MOV_L( CONST(4), REGOFF(V4F_SIZE, EDI) ) - - SHL_L( CONST(4), ECX ) - MOV_L( REGOFF(V4F_START, ESI), ESI ) - - MOV_L( REGOFF(V4F_START, EDI), EDI ) - ADD_L( EDI, ECX ) - - MOV_L( MAT14, EBX ) - -ALIGNTEXT16 -LLBL(x86_p2_pr_loop): - - FLD_S( SRC0 ) /* F4 */ - FMUL_S( MAT0 ) - - FLD_S( SRC1 ) /* F1 F4 */ - FMUL_S( MAT5 ) - - FXCH( ST(1) ) /* F4 F1 */ - FSTP_S( DST0 ) /* F1 */ - FSTP_S( DST1 ) /* */ - MOV_L( EBX, DST2 ) - MOV_L( CONST(FP_ZERO), DST3 ) - -LLBL(x86_p2_pr_skip): - - ADD_L( CONST(16), EDI ) - ADD_L( EAX, ESI ) - CMP_L( ECX, EDI ) - JNE( LLBL(x86_p2_pr_loop) ) - -LLBL(x86_p2_pr_done): - - POP_L( EBX ) - POP_L( EDI ) - POP_L( ESI ) - RET -#undef FRAME_OFFSET - - - - -ALIGNTEXT16 -GLOBL GLNAME( _mesa_x86_transform_points2_3d ) -HIDDEN(_mesa_x86_transform_points2_3d) -GLNAME( _mesa_x86_transform_points2_3d ): - -#define FRAME_OFFSET 8 - PUSH_L( ESI ) - PUSH_L( EDI ) - - MOV_L( ARG_SOURCE, ESI ) - MOV_L( ARG_DEST, EDI ) - - MOV_L( ARG_MATRIX, EDX ) - MOV_L( REGOFF(V4F_COUNT, ESI), ECX ) - - TEST_L( ECX, ECX ) - JZ( LLBL(x86_p2_3dr_done) ) - - MOV_L( REGOFF(V4F_STRIDE, ESI), EAX ) - OR_L( CONST(VEC_SIZE_3), REGOFF(V4F_FLAGS, EDI) ) - - MOV_L( ECX, REGOFF(V4F_COUNT, EDI) ) - MOV_L( CONST(3), REGOFF(V4F_SIZE, EDI) ) - - SHL_L( CONST(4), ECX ) - MOV_L( REGOFF(V4F_START, ESI), ESI ) - - MOV_L( REGOFF(V4F_START, EDI), EDI ) - ADD_L( EDI, ECX ) - -ALIGNTEXT16 -LLBL(x86_p2_3dr_loop): - - FLD_S( SRC0 ) /* F4 */ - FMUL_S( MAT0 ) - FLD_S( SRC0 ) /* F5 F4 */ - FMUL_S( MAT1 ) - FLD_S( SRC0 ) /* F6 F5 F4 */ - FMUL_S( MAT2 ) - - FLD_S( SRC1 ) /* F0 F6 F5 F4 */ - FMUL_S( MAT4 ) - FLD_S( SRC1 ) /* F1 F0 F6 F5 F4 */ - FMUL_S( MAT5 ) - FLD_S( SRC1 ) /* F2 F1 F0 F6 F5 F4 */ - FMUL_S( MAT6 ) - - FXCH( ST(2) ) /* F0 F1 F2 F6 F5 F4 */ - FADDP( ST0, ST(5) ) /* F1 F2 F6 F5 F4 */ - FADDP( ST0, ST(3) ) /* F2 F6 F5 F4 */ - FADDP( ST0, ST(1) ) /* F6 F5 F4 */ - - FXCH( ST(2) ) /* F4 F5 F6 */ - FADD_S( MAT12 ) - FXCH( ST(1) ) /* F5 F4 F6 */ - FADD_S( MAT13 ) - FXCH( ST(2) ) /* F6 F4 F5 */ - FADD_S( MAT14 ) - - FXCH( ST(1) ) /* F4 F6 F5 */ - FSTP_S( DST0 ) /* F6 F5 */ - FXCH( ST(1) ) /* F5 F6 */ - FSTP_S( DST1 ) /* F6 */ - FSTP_S( DST2 ) /* */ - -LLBL(x86_p2_3dr_skip): - - ADD_L( CONST(16), EDI ) - ADD_L( EAX, ESI ) - CMP_L( ECX, EDI ) - JNE( LLBL(x86_p2_3dr_loop) ) - -LLBL(x86_p2_3dr_done): - - POP_L( EDI ) - POP_L( ESI ) - RET -#undef FRAME_OFFSET - - - - -ALIGNTEXT16 -GLOBL GLNAME( _mesa_x86_transform_points2_3d_no_rot ) -HIDDEN(_mesa_x86_transform_points2_3d_no_rot) -GLNAME( _mesa_x86_transform_points2_3d_no_rot ): - -#define FRAME_OFFSET 12 - PUSH_L( ESI ) - PUSH_L( EDI ) - PUSH_L( EBX ) - - MOV_L( ARG_SOURCE, ESI ) - MOV_L( ARG_DEST, EDI ) - - MOV_L( ARG_MATRIX, EDX ) - MOV_L( REGOFF(V4F_COUNT, ESI), ECX ) - - TEST_L( ECX, ECX ) - JZ( LLBL(x86_p2_3dnrr_done) ) - - MOV_L( REGOFF(V4F_STRIDE, ESI), EAX ) - OR_L( CONST(VEC_SIZE_3), REGOFF(V4F_FLAGS, EDI) ) - - MOV_L( ECX, REGOFF(V4F_COUNT, EDI) ) - MOV_L( CONST(3), REGOFF(V4F_SIZE, EDI) ) - - SHL_L( CONST(4), ECX ) - MOV_L( REGOFF(V4F_START, ESI), ESI ) - - MOV_L( REGOFF(V4F_START, EDI), EDI ) - ADD_L( EDI, ECX ) - - MOV_L( MAT14, EBX ) - -ALIGNTEXT16 -LLBL(x86_p2_3dnrr_loop): - - FLD_S( SRC0 ) /* F4 */ - FMUL_S( MAT0 ) - - FLD_S( SRC1 ) /* F1 F4 */ - FMUL_S( MAT5 ) - - FXCH( ST(1) ) /* F4 F1 */ - FADD_S( MAT12 ) - FLD_S( MAT13 ) /* F5 F4 F1 */ - FXCH( ST(2) ) /* F1 F4 F5 */ - FADDP( ST0, ST(2) ) /* F4 F5 */ - - FSTP_S( DST0 ) /* F5 */ - FSTP_S( DST1 ) /* */ - MOV_L( EBX, DST2 ) - -LLBL(x86_p2_3dnrr_skip): - - ADD_L( CONST(16), EDI ) - ADD_L( EAX, ESI ) - CMP_L( ECX, EDI ) - JNE( LLBL(x86_p2_3dnrr_loop) ) - -LLBL(x86_p2_3dnrr_done): - - POP_L( EBX ) - POP_L( EDI ) - POP_L( ESI ) - RET -#undef FRAME_OFFSET - - - - -ALIGNTEXT16 -GLOBL GLNAME( _mesa_x86_transform_points2_2d ) -HIDDEN(_mesa_x86_transform_points2_2d) -GLNAME( _mesa_x86_transform_points2_2d ): - -#define FRAME_OFFSET 8 - PUSH_L( ESI ) - PUSH_L( EDI ) - - MOV_L( ARG_SOURCE, ESI ) - MOV_L( ARG_DEST, EDI ) - - MOV_L( ARG_MATRIX, EDX ) - MOV_L( REGOFF(V4F_COUNT, ESI), ECX ) - - TEST_L( ECX, ECX ) - JZ( LLBL(x86_p2_2dr_done) ) - - MOV_L( REGOFF(V4F_STRIDE, ESI), EAX ) - OR_L( CONST(VEC_SIZE_2), REGOFF(V4F_FLAGS, EDI) ) - - MOV_L( ECX, REGOFF(V4F_COUNT, EDI) ) - MOV_L( CONST(2), REGOFF(V4F_SIZE, EDI) ) - - SHL_L( CONST(4), ECX ) - MOV_L( REGOFF(V4F_START, ESI), ESI ) - - MOV_L( REGOFF(V4F_START, EDI), EDI ) - ADD_L( EDI, ECX ) - -ALIGNTEXT16 -LLBL(x86_p2_2dr_loop): - - FLD_S( SRC0 ) /* F4 */ - FMUL_S( MAT0 ) - FLD_S( SRC0 ) /* F5 F4 */ - FMUL_S( MAT1 ) - - FLD_S( SRC1 ) /* F0 F5 F4 */ - FMUL_S( MAT4 ) - FLD_S( SRC1 ) /* F1 F0 F5 F4 */ - FMUL_S( MAT5 ) - - FXCH( ST(1) ) /* F0 F1 F5 F4 */ - FADDP( ST0, ST(3) ) /* F1 F5 F4 */ - FADDP( ST0, ST(1) ) /* F5 F4 */ - - FXCH( ST(1) ) /* F4 F5 */ - FADD_S( MAT12 ) - FXCH( ST(1) ) /* F5 F4 */ - FADD_S( MAT13 ) - - FXCH( ST(1) ) /* F4 F5 */ - FSTP_S( DST0 ) /* F5 */ - FSTP_S( DST1 ) /* */ - -LLBL(x86_p2_2dr_skip): - - ADD_L( CONST(16), EDI ) - ADD_L( EAX, ESI ) - CMP_L( ECX, EDI ) - JNE( LLBL(x86_p2_2dr_loop) ) - -LLBL(x86_p2_2dr_done): - - POP_L( EDI ) - POP_L( ESI ) - RET -#undef FRAME_OFFSET - - - - -ALIGNTEXT4 -GLOBL GLNAME( _mesa_x86_transform_points2_2d_no_rot ) -HIDDEN(_mesa_x86_transform_points2_2d_no_rot) -GLNAME( _mesa_x86_transform_points2_2d_no_rot ): - -#define FRAME_OFFSET 8 - PUSH_L( ESI ) - PUSH_L( EDI ) - - MOV_L( ARG_SOURCE, ESI ) - MOV_L( ARG_DEST, EDI ) - - MOV_L( ARG_MATRIX, EDX ) - MOV_L( REGOFF(V4F_COUNT, ESI), ECX ) - - TEST_L( ECX, ECX ) - JZ( LLBL(x86_p2_2dnrr_done) ) - - MOV_L( REGOFF(V4F_STRIDE, ESI), EAX ) - OR_L( CONST(VEC_SIZE_2), REGOFF(V4F_FLAGS, EDI) ) - - MOV_L( ECX, REGOFF(V4F_COUNT, EDI) ) - MOV_L( CONST(2), REGOFF(V4F_SIZE, EDI) ) - - SHL_L( CONST(4), ECX ) - MOV_L( REGOFF(V4F_START, ESI), ESI ) - - MOV_L( REGOFF(V4F_START, EDI), EDI ) - ADD_L( EDI, ECX ) - -ALIGNTEXT16 -LLBL(x86_p2_2dnrr_loop): - - FLD_S( SRC0 ) /* F4 */ - FMUL_S( MAT0 ) - - FLD_S( SRC1 ) /* F1 F4 */ - FMUL_S( MAT5 ) - - FXCH( ST(1) ) /* F4 F1 */ - FADD_S( MAT12 ) - FLD_S( MAT13 ) /* F5 F4 F1 */ - FXCH( ST(2) ) /* F1 F4 F5 */ - FADDP( ST0, ST(2) ) /* F4 F5 */ - - FSTP_S( DST0 ) /* F5 */ - FSTP_S( DST1 ) /* */ - -LLBL(x86_p2_2dnrr_skip): - - ADD_L( CONST(16), EDI ) - ADD_L( EAX, ESI ) - CMP_L( ECX, EDI ) - JNE( LLBL(x86_p2_2dnrr_loop) ) - -LLBL(x86_p2_2dnrr_done): - - POP_L( EDI ) - POP_L( ESI ) - RET -#undef FRAME_OFFSET - - - - -ALIGNTEXT16 -GLOBL GLNAME( _mesa_x86_transform_points2_identity ) -HIDDEN(_mesa_x86_transform_points2_identity) -GLNAME( _mesa_x86_transform_points2_identity ): - -#define FRAME_OFFSET 12 - PUSH_L( ESI ) - PUSH_L( EDI ) - PUSH_L( EBX ) - - MOV_L( ARG_SOURCE, ESI ) - MOV_L( ARG_DEST, EDI ) - - MOV_L( ARG_MATRIX, EDX ) - MOV_L( REGOFF(V4F_COUNT, ESI), ECX ) - - TEST_L( ECX, ECX ) - JZ( LLBL(x86_p2_ir_done) ) - - MOV_L( REGOFF(V4F_STRIDE, ESI), EAX ) - OR_L( CONST(VEC_SIZE_2), REGOFF(V4F_FLAGS, EDI) ) - - MOV_L( ECX, REGOFF(V4F_COUNT, EDI) ) - MOV_L( CONST(2), REGOFF(V4F_SIZE, EDI) ) - - SHL_L( CONST(4), ECX ) - MOV_L( REGOFF(V4F_START, ESI), ESI ) - - MOV_L( REGOFF(V4F_START, EDI), EDI ) - ADD_L( EDI, ECX ) - - CMP_L( ESI, EDI ) - JE( LLBL(x86_p2_ir_done) ) - -ALIGNTEXT16 -LLBL(x86_p2_ir_loop): - - MOV_L( SRC0, EBX ) - MOV_L( SRC1, EDX ) - - MOV_L( EBX, DST0 ) - MOV_L( EDX, DST1 ) - -LLBL(x86_p2_ir_skip): - - ADD_L( CONST(16), EDI ) - ADD_L( EAX, ESI ) - CMP_L( ECX, EDI ) - JNE( LLBL(x86_p2_ir_loop) ) - -LLBL(x86_p2_ir_done): - - POP_L( EBX ) - POP_L( EDI ) - POP_L( ESI ) - RET -#undef FRAME_OFFSET - -#if defined (__ELF__) && defined (__linux__) - .section .note.GNU-stack,"",%progbits -#endif diff --git a/dll/opengl/mesa/x86/x86_xform3.S b/dll/opengl/mesa/x86/x86_xform3.S deleted file mode 100644 index 1c782f1c5c4..00000000000 --- a/dll/opengl/mesa/x86/x86_xform3.S +++ /dev/null @@ -1,644 +0,0 @@ - -/* - * Mesa 3-D graphics library - * Version: 3.5 - * - * Copyright (C) 1999-2001 Brian Paul All Rights Reserved. - * - * Permission is hereby granted, free of charge, to any person obtaining a - * copy of this software and associated documentation files (the "Software"), - * to deal in the Software without restriction, including without limitation - * the rights to use, copy, modify, merge, publish, distribute, sublicense, - * and/or sell copies of the Software, and to permit persons to whom the - * Software is furnished to do so, subject to the following conditions: - * - * The above copyright notice and this permission notice shall be included - * in all copies or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS - * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL - * BRIAN PAUL BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN - * AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN - * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. - */ - -/* - * NOTE: Avoid using spaces in between '(' ')' and arguments, especially - * with macros like CONST, LLBL that expand to CONCAT(...). Putting spaces - * in there will break the build on some platforms. - */ - -#include "assyntax.h" -#include "matypes.h" -#include "xform_args.h" - - SEG_TEXT - -#define FP_ONE 1065353216 -#define FP_ZERO 0 - -#define SRC0 REGOFF(0, ESI) -#define SRC1 REGOFF(4, ESI) -#define SRC2 REGOFF(8, ESI) -#define SRC3 REGOFF(12, ESI) -#define DST0 REGOFF(0, EDI) -#define DST1 REGOFF(4, EDI) -#define DST2 REGOFF(8, EDI) -#define DST3 REGOFF(12, EDI) -#define MAT0 REGOFF(0, EDX) -#define MAT1 REGOFF(4, EDX) -#define MAT2 REGOFF(8, EDX) -#define MAT3 REGOFF(12, EDX) -#define MAT4 REGOFF(16, EDX) -#define MAT5 REGOFF(20, EDX) -#define MAT6 REGOFF(24, EDX) -#define MAT7 REGOFF(28, EDX) -#define MAT8 REGOFF(32, EDX) -#define MAT9 REGOFF(36, EDX) -#define MAT10 REGOFF(40, EDX) -#define MAT11 REGOFF(44, EDX) -#define MAT12 REGOFF(48, EDX) -#define MAT13 REGOFF(52, EDX) -#define MAT14 REGOFF(56, EDX) -#define MAT15 REGOFF(60, EDX) - - -ALIGNTEXT16 -GLOBL GLNAME( _mesa_x86_transform_points3_general ) -HIDDEN(_mesa_x86_transform_points3_general) -GLNAME( _mesa_x86_transform_points3_general ): - -#define FRAME_OFFSET 8 - PUSH_L( ESI ) - PUSH_L( EDI ) - - MOV_L( ARG_SOURCE, ESI ) - MOV_L( ARG_DEST, EDI ) - - MOV_L( ARG_MATRIX, EDX ) - MOV_L( REGOFF(V4F_COUNT, ESI), ECX ) - - TEST_L( ECX, ECX ) - JZ( LLBL(x86_p3_gr_done) ) - - MOV_L( REGOFF(V4F_STRIDE, ESI), EAX ) - OR_L( CONST(VEC_SIZE_4), REGOFF(V4F_FLAGS, EDI) ) - - MOV_L( ECX, REGOFF(V4F_COUNT, EDI) ) - MOV_L( CONST(4), REGOFF(V4F_SIZE, EDI) ) - - SHL_L( CONST(4), ECX ) - MOV_L( REGOFF(V4F_START, ESI), ESI ) - - MOV_L( REGOFF(V4F_START, EDI), EDI ) - ADD_L( EDI, ECX ) - -ALIGNTEXT16 -LLBL(x86_p3_gr_loop): - - FLD_S( SRC0 ) /* F4 */ - FMUL_S( MAT0 ) - FLD_S( SRC0 ) /* F5 F4 */ - FMUL_S( MAT1 ) - FLD_S( SRC0 ) /* F6 F5 F4 */ - FMUL_S( MAT2 ) - FLD_S( SRC0 ) /* F7 F6 F5 F4 */ - FMUL_S( MAT3 ) - - FLD_S( SRC1 ) /* F0 F7 F6 F5 F4 */ - FMUL_S( MAT4 ) - FLD_S( SRC1 ) /* F1 F0 F7 F6 F5 F4 */ - FMUL_S( MAT5 ) - FLD_S( SRC1 ) /* F2 F1 F0 F7 F6 F5 F4 */ - FMUL_S( MAT6 ) - FLD_S( SRC1 ) /* F3 F2 F1 F0 F7 F6 F5 F4 */ - FMUL_S( MAT7 ) - - FXCH( ST(3) ) /* F0 F2 F1 F3 F7 F6 F5 F4 */ - FADDP( ST0, ST(7) ) /* F2 F1 F3 F7 F6 F5 F4 */ - FXCH( ST(1) ) /* F1 F2 F3 F7 F6 F5 F4 */ - FADDP( ST0, ST(5) ) /* F2 F3 F7 F6 F5 F4 */ - FADDP( ST0, ST(3) ) /* F3 F7 F6 F5 F4 */ - FADDP( ST0, ST(1) ) /* F7 F6 F5 F4 */ - - FLD_S( SRC2 ) /* F0 F7 F6 F5 F4 */ - FMUL_S( MAT8 ) - FLD_S( SRC2 ) /* F1 F0 F7 F6 F5 F4 */ - FMUL_S( MAT9 ) - FLD_S( SRC2 ) /* F2 F1 F0 F7 F6 F5 F4 */ - FMUL_S( MAT10 ) - FLD_S( SRC2 ) /* F3 F2 F1 F0 F7 F6 F5 F4 */ - FMUL_S( MAT11 ) - - FXCH( ST(3) ) /* F0 F2 F1 F3 F7 F6 F5 F4 */ - FADDP( ST0, ST(7) ) /* F2 F1 F3 F7 F6 F5 F4 */ - FXCH( ST(1) ) /* F1 F2 F3 F7 F6 F5 F4 */ - FADDP( ST0, ST(5) ) /* F2 F3 F7 F6 F5 F4 */ - FADDP( ST0, ST(3) ) /* F3 F7 F6 F5 F4 */ - FADDP( ST0, ST(1) ) /* F7 F6 F5 F4 */ - - FXCH( ST(3) ) /* F4 F6 F5 F7 */ - FADD_S( MAT12 ) - FXCH( ST(2) ) /* F5 F6 F4 F7 */ - FADD_S( MAT13 ) - FXCH( ST(1) ) /* F6 F5 F4 F7 */ - FADD_S( MAT14 ) - FXCH( ST(3) ) /* F7 F5 F4 F6 */ - FADD_S( MAT15 ) - - FXCH( ST(2) ) /* F4 F5 F7 F6 */ - FSTP_S( DST0 ) /* F5 F7 F6 */ - FSTP_S( DST1 ) /* F7 F6 */ - FXCH( ST(1) ) /* F6 F7 */ - FSTP_S( DST2 ) /* F7 */ - FSTP_S( DST3 ) /* */ - -LLBL(x86_p3_gr_skip): - - ADD_L( CONST(16), EDI ) - ADD_L( EAX, ESI ) - CMP_L( ECX, EDI ) - JNE( LLBL(x86_p3_gr_loop) ) - -LLBL(x86_p3_gr_done): - - POP_L( EDI ) - POP_L( ESI ) - RET -#undef FRAME_OFFSET - - - - -ALIGNTEXT16 -GLOBL GLNAME( _mesa_x86_transform_points3_perspective ) -HIDDEN(_mesa_x86_transform_points3_perspective) -GLNAME( _mesa_x86_transform_points3_perspective ): - -#define FRAME_OFFSET 12 - PUSH_L( ESI ) - PUSH_L( EDI ) - PUSH_L( EBX ) - - MOV_L( ARG_SOURCE, ESI ) - MOV_L( ARG_DEST, EDI ) - - MOV_L( ARG_MATRIX, EDX ) - MOV_L( REGOFF(V4F_COUNT, ESI), ECX ) - - TEST_L( ECX, ECX ) - JZ( LLBL(x86_p3_pr_done) ) - - MOV_L( REGOFF(V4F_STRIDE, ESI), EAX ) - OR_L( CONST(VEC_SIZE_4), REGOFF(V4F_FLAGS, EDI) ) - - MOV_L( ECX, REGOFF(V4F_COUNT, EDI) ) - MOV_L( CONST(4), REGOFF(V4F_SIZE, EDI) ) - - SHL_L( CONST(4), ECX ) - MOV_L( REGOFF(V4F_START, ESI), ESI ) - - MOV_L( REGOFF(V4F_START, EDI), EDI ) - ADD_L( EDI, ECX ) - -ALIGNTEXT16 -LLBL(x86_p3_pr_loop): - - FLD_S( SRC0 ) /* F4 */ - FMUL_S( MAT0 ) - - FLD_S( SRC1 ) /* F5 F4 */ - FMUL_S( MAT5 ) - - FLD_S( SRC2 ) /* F0 F5 F4 */ - FMUL_S( MAT8 ) - FLD_S( SRC2 ) /* F1 F0 F5 F4 */ - FMUL_S( MAT9 ) - FLD_S( SRC2 ) /* F2 F1 F0 F5 F4 */ - FMUL_S( MAT10 ) - - FXCH( ST(2) ) /* F0 F1 F2 F5 F4 */ - FADDP( ST0, ST(4) ) /* F1 F2 F5 F4 */ - FADDP( ST0, ST(2) ) /* F2 F5 F4 */ - FLD_S( MAT14 ) /* F6 F2 F5 F4 */ - FXCH( ST(1) ) /* F2 F6 F5 F4 */ - FADDP( ST0, ST(1) ) /* F6 F5 F4 */ - - MOV_L( SRC2, EBX ) - XOR_L( CONST(-2147483648), EBX )/* change sign */ - - FXCH( ST(2) ) /* F4 F5 F6 */ - FSTP_S( DST0 ) /* F5 F6 */ - FSTP_S( DST1 ) /* F6 */ - FSTP_S( DST2 ) /* */ - MOV_L( EBX, DST3 ) - -LLBL(x86_p3_pr_skip): - - ADD_L( CONST(16), EDI ) - ADD_L( EAX, ESI ) - CMP_L( ECX, EDI ) - JNE( LLBL(x86_p3_pr_loop) ) - -LLBL(x86_p3_pr_done): - - POP_L( EBX ) - POP_L( EDI ) - POP_L( ESI ) - RET -#undef FRAME_OFFSET - - - - -ALIGNTEXT16 -GLOBL GLNAME( _mesa_x86_transform_points3_3d ) -HIDDEN(_mesa_x86_transform_points3_3d) -GLNAME( _mesa_x86_transform_points3_3d ): - -#define FRAME_OFFSET 8 - PUSH_L( ESI ) - PUSH_L( EDI ) - - MOV_L( ARG_SOURCE, ESI ) - MOV_L( ARG_DEST, EDI ) - - MOV_L( ARG_MATRIX, EDX ) - MOV_L( REGOFF(V4F_COUNT, ESI), ECX ) - - TEST_L( ECX, ECX ) - JZ( LLBL(x86_p3_3dr_done) ) - - MOV_L( REGOFF(V4F_STRIDE, ESI), EAX ) - OR_L( CONST(VEC_SIZE_3), REGOFF(V4F_FLAGS, EDI) ) - - MOV_L( ECX, REGOFF(V4F_COUNT, EDI) ) - MOV_L( CONST(3), REGOFF(V4F_SIZE, EDI) ) - - SHL_L( CONST(4), ECX ) - MOV_L( REGOFF(V4F_START, ESI), ESI ) - - MOV_L( REGOFF(V4F_START, EDI), EDI ) - ADD_L( EDI, ECX ) - -ALIGNTEXT16 -LLBL(x86_p3_3dr_loop): - - FLD_S( SRC0 ) /* F4 */ - FMUL_S( MAT0 ) - FLD_S( SRC0 ) /* F5 F4 */ - FMUL_S( MAT1 ) - FLD_S( SRC0 ) /* F6 F5 F4 */ - FMUL_S( MAT2 ) - - FLD_S( SRC1 ) /* F0 F6 F5 F4 */ - FMUL_S( MAT4 ) - FLD_S( SRC1 ) /* F1 F0 F6 F5 F4 */ - FMUL_S( MAT5 ) - FLD_S( SRC1 ) /* F2 F1 F0 F6 F5 F4 */ - FMUL_S( MAT6 ) - - FXCH( ST(2) ) /* F0 F1 F2 F6 F5 F4 */ - FADDP( ST0, ST(5) ) /* F1 F2 F6 F5 F4 */ - FADDP( ST0, ST(3) ) /* F2 F6 F5 F4 */ - FADDP( ST0, ST(1) ) /* F6 F5 F4 */ - - FLD_S( SRC2 ) /* F0 F6 F5 F4 */ - FMUL_S( MAT8 ) - FLD_S( SRC2 ) /* F1 F0 F6 F5 F4 */ - FMUL_S( MAT9 ) - FLD_S( SRC2 ) /* F2 F1 F0 F6 F5 F4 */ - FMUL_S( MAT10 ) - - FXCH( ST(2) ) /* F0 F1 F2 F6 F5 F4 */ - FADDP( ST0, ST(5) ) /* F1 F2 F6 F5 F4 */ - FADDP( ST0, ST(3) ) /* F2 F6 F5 F4 */ - FADDP( ST0, ST(1) ) /* F6 F5 F4 */ - - FXCH( ST(2) ) /* F4 F5 F6 */ - FADD_S( MAT12 ) - FXCH( ST(1) ) /* F5 F4 F6 */ - FADD_S( MAT13 ) - FXCH( ST(2) ) /* F6 F4 F5 */ - FADD_S( MAT14 ) - - FXCH( ST(1) ) /* F4 F6 F5 */ - FSTP_S( DST0 ) /* F6 F5 */ - FXCH( ST(1) ) /* F5 F6 */ - FSTP_S( DST1 ) /* F6 */ - FSTP_S( DST2 ) /* */ - -LLBL(x86_p3_3dr_skip): - - ADD_L( CONST(16), EDI ) - ADD_L( EAX, ESI ) - CMP_L( ECX, EDI ) - JNE( LLBL(x86_p3_3dr_loop) ) - -LLBL(x86_p3_3dr_done): - - POP_L( EDI ) - POP_L( ESI ) - RET -#undef FRAME_OFFSET - - - - -ALIGNTEXT16 -GLOBL GLNAME( _mesa_x86_transform_points3_3d_no_rot ) -HIDDEN(_mesa_x86_transform_points3_3d_no_rot) -GLNAME( _mesa_x86_transform_points3_3d_no_rot ): - -#define FRAME_OFFSET 8 - PUSH_L( ESI ) - PUSH_L( EDI ) - - MOV_L( ARG_SOURCE, ESI ) - MOV_L( ARG_DEST, EDI ) - - - MOV_L( ARG_MATRIX, EDX ) - MOV_L( REGOFF(V4F_COUNT, ESI), ECX ) - - TEST_L( ECX, ECX ) - JZ( LLBL(x86_p3_3dnrr_done) ) - - MOV_L( REGOFF(V4F_STRIDE, ESI), EAX ) - OR_L( CONST(VEC_SIZE_3), REGOFF(V4F_FLAGS, EDI) ) - - MOV_L( ECX, REGOFF(V4F_COUNT, EDI) ) - MOV_L( CONST(3), REGOFF(V4F_SIZE, EDI) ) - - SHL_L( CONST(4), ECX ) - MOV_L( REGOFF(V4F_START, ESI), ESI ) - - MOV_L( REGOFF(V4F_START, EDI), EDI ) - ADD_L( EDI, ECX ) - -ALIGNTEXT16 -LLBL(x86_p3_3dnrr_loop): - - FLD_S( SRC0 ) /* F4 */ - FMUL_S( MAT0 ) - - FLD_S( SRC1 ) /* F1 F4 */ - FMUL_S( MAT5 ) - - FLD_S( SRC2 ) /* F2 F1 F4 */ - FMUL_S( MAT10 ) - - FXCH( ST(2) ) /* F4 F1 F2 */ - FADD_S( MAT12 ) - FLD_S( MAT13 ) /* F5 F4 F1 F2 */ - FXCH( ST(2) ) /* F1 F4 F5 F2 */ - FADDP( ST0, ST(2) ) /* F4 F5 F2 */ - FLD_S( MAT14 ) /* F6 F4 F5 F2 */ - FXCH( ST(3) ) /* F2 F4 F5 F6 */ - FADDP( ST0, ST(3) ) /* F4 F5 F6 */ - - FSTP_S( DST0 ) /* F5 F6 */ - FSTP_S( DST1 ) /* F6 */ - FSTP_S( DST2 ) /* */ - -LLBL(x86_p3_3dnrr_skip): - - ADD_L( CONST(16), EDI ) - ADD_L( EAX, ESI ) - CMP_L( ECX, EDI ) - JNE( LLBL(x86_p3_3dnrr_loop) ) - -LLBL(x86_p3_3dnrr_done): - - POP_L( EDI ) - POP_L( ESI ) - RET -#undef FRAME_OFFSET - - - - -ALIGNTEXT16 -GLOBL GLNAME( _mesa_x86_transform_points3_2d ) -HIDDEN(_mesa_x86_transform_points3_2d) -GLNAME( _mesa_x86_transform_points3_2d ): - -#define FRAME_OFFSET 12 - PUSH_L( ESI ) - PUSH_L( EDI ) - PUSH_L( EBX ) - - MOV_L( ARG_SOURCE, ESI ) - MOV_L( ARG_DEST, EDI ) - - MOV_L( ARG_MATRIX, EDX ) - MOV_L( REGOFF(V4F_COUNT, ESI), ECX ) - - TEST_L( ECX, ECX ) - JZ( LLBL(x86_p3_2dr_done) ) - - MOV_L( REGOFF(V4F_STRIDE, ESI), EAX ) - OR_L( CONST(VEC_SIZE_3), REGOFF(V4F_FLAGS, EDI) ) - - MOV_L( ECX, REGOFF(V4F_COUNT, EDI) ) - MOV_L( CONST(3), REGOFF(V4F_SIZE, EDI) ) - - SHL_L( CONST(4), ECX ) - MOV_L( REGOFF(V4F_START, ESI), ESI ) - - MOV_L( REGOFF(V4F_START, EDI), EDI ) - ADD_L( EDI, ECX ) - -ALIGNTEXT16 -LLBL(x86_p3_2dr_loop): - - FLD_S( SRC0 ) /* F4 */ - FMUL_S( MAT0 ) - FLD_S( SRC0 ) /* F5 F4 */ - FMUL_S( MAT1 ) - - FLD_S( SRC1 ) /* F0 F5 F4 */ - FMUL_S( MAT4 ) - FLD_S( SRC1 ) /* F1 F0 F5 F4 */ - FMUL_S( MAT5 ) - - FXCH( ST(1) ) /* F0 F1 F5 F4 */ - FADDP( ST0, ST(3) ) /* F1 F5 F4 */ - FADDP( ST0, ST(1) ) /* F5 F4 */ - - FXCH( ST(1) ) /* F4 F5 */ - FADD_S( MAT12 ) - FXCH( ST(1) ) /* F5 F4 */ - FADD_S( MAT13 ) - - MOV_L( SRC2, EBX ) - - FXCH( ST(1) ) /* F4 F5 */ - FSTP_S( DST0 ) /* F5 */ - FSTP_S( DST1 ) /* */ - MOV_L( EBX, DST2 ) - -LLBL(x86_p3_2dr_skip): - - ADD_L( CONST(16), EDI ) - ADD_L( EAX, ESI ) - CMP_L( ECX, EDI ) - JNE( LLBL(x86_p3_2dr_loop) ) - -LLBL(x86_p3_2dr_done): - - POP_L( EBX ) - POP_L( EDI ) - POP_L( ESI ) - RET -#undef FRAME_OFFSET - - - - -ALIGNTEXT16 -GLOBL GLNAME( _mesa_x86_transform_points3_2d_no_rot ) -HIDDEN(_mesa_x86_transform_points3_2d_no_rot) -GLNAME( _mesa_x86_transform_points3_2d_no_rot ): - -#define FRAME_OFFSET 12 - PUSH_L( ESI ) - PUSH_L( EDI ) - PUSH_L( EBX ) - - MOV_L( ARG_SOURCE, ESI ) - MOV_L( ARG_DEST, EDI ) - - MOV_L( ARG_MATRIX, EDX ) - MOV_L( REGOFF(V4F_COUNT, ESI), ECX ) - - TEST_L( ECX, ECX ) - JZ( LLBL(x86_p3_2dnrr_done) ) - - MOV_L( REGOFF(V4F_STRIDE, ESI), EAX ) - OR_L( CONST(VEC_SIZE_3), REGOFF(V4F_FLAGS, EDI) ) - - MOV_L( ECX, REGOFF(V4F_COUNT, EDI) ) - MOV_L( CONST(3), REGOFF(V4F_SIZE, EDI) ) - - SHL_L( CONST(4), ECX ) - MOV_L( REGOFF(V4F_START, ESI), ESI ) - - MOV_L( REGOFF(V4F_START, EDI), EDI ) - ADD_L( EDI, ECX ) - -ALIGNTEXT16 -LLBL(x86_p3_2dnrr_loop): - - FLD_S( SRC0 ) /* F4 */ - FMUL_S( MAT0 ) - - FLD_S( SRC1 ) /* F1 F4 */ - FMUL_S( MAT5 ) - - FXCH( ST(1) ) /* F4 F1 */ - FADD_S( MAT12 ) - FLD_S( MAT13 ) /* F5 F4 F1 */ - - FXCH( ST(2) ) /* F1 F4 F5 */ - FADDP( ST0, ST(2) ) /* F4 F5 */ - - MOV_L( SRC2, EBX ) - - FSTP_S( DST0 ) /* F5 */ - FSTP_S( DST1 ) /* */ - MOV_L( EBX, DST2 ) - -LLBL(x86_p3_2dnrr_skip): - - ADD_L( CONST(16), EDI ) - ADD_L( EAX, ESI ) - CMP_L( ECX, EDI ) - JNE( LLBL(x86_p3_2dnrr_loop) ) - -LLBL(x86_p3_2dnrr_done): - - POP_L( EBX ) - POP_L( EDI ) - POP_L( ESI ) - RET -#undef FRAME_OFFSET - - - - -ALIGNTEXT16 -GLOBL GLNAME( _mesa_x86_transform_points3_identity ) -HIDDEN(_mesa_x86_transform_points3_identity) -GLNAME(_mesa_x86_transform_points3_identity ): - -#define FRAME_OFFSET 16 - PUSH_L( ESI ) - PUSH_L( EDI ) - PUSH_L( EBX ) - PUSH_L( EBP ) - - MOV_L( ARG_SOURCE, ESI ) - MOV_L( ARG_DEST, EDI ) - - MOV_L( ARG_MATRIX, EDX ) - MOV_L( REGOFF(V4F_COUNT, ESI), ECX ) - - TEST_L( ECX, ECX ) - JZ( LLBL(x86_p3_ir_done) ) - - MOV_L( REGOFF(V4F_STRIDE, ESI), EAX ) - OR_L( CONST(VEC_SIZE_3), REGOFF(V4F_FLAGS, EDI) ) - - MOV_L( ECX, REGOFF(V4F_COUNT, EDI) ) - MOV_L( CONST(3), REGOFF(V4F_SIZE, EDI) ) - - SHL_L( CONST(4), ECX ) - MOV_L( REGOFF(V4F_START, ESI), ESI ) - - MOV_L( REGOFF(V4F_START, EDI), EDI ) - ADD_L( EDI, ECX ) - - CMP_L( ESI, EDI ) - JE( LLBL(x86_p3_ir_done) ) - -ALIGNTEXT16 -LLBL(x86_p3_ir_loop): - -#if 1 - MOV_L( SRC0, EBX ) - MOV_L( SRC1, EBP ) - MOV_L( SRC2, EDX ) - - MOV_L( EBX, DST0 ) - MOV_L( EBP, DST1 ) - MOV_L( EDX, DST2 ) -#else - FLD_S( SRC0 ) - FLD_S( SRC1 ) - FLD_S( SRC2 ) - - FSTP_S( DST2 ) - FSTP_S( DST1 ) - FSTP_S( DST0 ) -#endif - -LLBL(x86_p3_ir_skip): - - ADD_L( CONST(16), EDI ) - ADD_L( EAX, ESI ) - CMP_L( ECX, EDI ) - JNE( LLBL(x86_p3_ir_loop) ) - -LLBL(x86_p3_ir_done): - - POP_L( EBP ) - POP_L( EBX ) - POP_L( EDI ) - POP_L( ESI ) - RET - -#if defined (__ELF__) && defined (__linux__) - .section .note.GNU-stack,"",%progbits -#endif diff --git a/dll/opengl/mesa/x86/x86_xform4.S b/dll/opengl/mesa/x86/x86_xform4.S deleted file mode 100644 index 97a841138ee..00000000000 --- a/dll/opengl/mesa/x86/x86_xform4.S +++ /dev/null @@ -1,677 +0,0 @@ - -/* - * Mesa 3-D graphics library - * Version: 3.5 - * - * Copyright (C) 1999-2001 Brian Paul All Rights Reserved. - * - * Permission is hereby granted, free of charge, to any person obtaining a - * copy of this software and associated documentation files (the "Software"), - * to deal in the Software without restriction, including without limitation - * the rights to use, copy, modify, merge, publish, distribute, sublicense, - * and/or sell copies of the Software, and to permit persons to whom the - * Software is furnished to do so, subject to the following conditions: - * - * The above copyright notice and this permission notice shall be included - * in all copies or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS - * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL - * BRIAN PAUL BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN - * AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN - * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. - */ - -/* - * NOTE: Avoid using spaces in between '(' ')' and arguments, especially - * with macros like CONST, LLBL that expand to CONCAT(...). Putting spaces - * in there will break the build on some platforms. - */ - -#include "assyntax.h" -#include "matypes.h" -#include "xform_args.h" - - SEG_TEXT - -#define FP_ONE 1065353216 -#define FP_ZERO 0 - -#define SRC0 REGOFF(0, ESI) -#define SRC1 REGOFF(4, ESI) -#define SRC2 REGOFF(8, ESI) -#define SRC3 REGOFF(12, ESI) -#define DST0 REGOFF(0, EDI) -#define DST1 REGOFF(4, EDI) -#define DST2 REGOFF(8, EDI) -#define DST3 REGOFF(12, EDI) -#define MAT0 REGOFF(0, EDX) -#define MAT1 REGOFF(4, EDX) -#define MAT2 REGOFF(8, EDX) -#define MAT3 REGOFF(12, EDX) -#define MAT4 REGOFF(16, EDX) -#define MAT5 REGOFF(20, EDX) -#define MAT6 REGOFF(24, EDX) -#define MAT7 REGOFF(28, EDX) -#define MAT8 REGOFF(32, EDX) -#define MAT9 REGOFF(36, EDX) -#define MAT10 REGOFF(40, EDX) -#define MAT11 REGOFF(44, EDX) -#define MAT12 REGOFF(48, EDX) -#define MAT13 REGOFF(52, EDX) -#define MAT14 REGOFF(56, EDX) -#define MAT15 REGOFF(60, EDX) - - -ALIGNTEXT16 -GLOBL GLNAME( _mesa_x86_transform_points4_general ) -HIDDEN(_mesa_x86_transform_points4_general) -GLNAME( _mesa_x86_transform_points4_general ): - -#define FRAME_OFFSET 8 - PUSH_L( ESI ) - PUSH_L( EDI ) - - MOV_L( ARG_SOURCE, ESI ) - MOV_L( ARG_DEST, EDI ) - - MOV_L( ARG_MATRIX, EDX ) - MOV_L( REGOFF(V4F_COUNT, ESI), ECX ) - - TEST_L( ECX, ECX ) - JZ( LLBL(x86_p4_gr_done) ) - - MOV_L( REGOFF(V4F_STRIDE, ESI), EAX ) - OR_L( CONST(VEC_SIZE_4), REGOFF(V4F_FLAGS, EDI) ) - - MOV_L( ECX, REGOFF(V4F_COUNT, EDI) ) - MOV_L( CONST(4), REGOFF(V4F_SIZE, EDI) ) - - SHL_L( CONST(4), ECX ) - MOV_L( REGOFF(V4F_START, ESI), ESI ) - - MOV_L( REGOFF(V4F_START, EDI), EDI ) - ADD_L( EDI, ECX ) - -ALIGNTEXT16 -LLBL(x86_p4_gr_loop): - - FLD_S( SRC0 ) /* F4 */ - FMUL_S( MAT0 ) - FLD_S( SRC0 ) /* F5 F4 */ - FMUL_S( MAT1 ) - FLD_S( SRC0 ) /* F6 F5 F4 */ - FMUL_S( MAT2 ) - FLD_S( SRC0 ) /* F7 F6 F5 F4 */ - FMUL_S( MAT3 ) - - FLD_S( SRC1 ) /* F0 F7 F6 F5 F4 */ - FMUL_S( MAT4 ) - FLD_S( SRC1 ) /* F1 F0 F7 F6 F5 F4 */ - FMUL_S( MAT5 ) - FLD_S( SRC1 ) /* F2 F1 F0 F7 F6 F5 F4 */ - FMUL_S( MAT6 ) - FLD_S( SRC1 ) /* F3 F2 F1 F0 F7 F6 F5 F4 */ - FMUL_S( MAT7 ) - - FXCH( ST(3) ) /* F0 F2 F1 F3 F7 F6 F5 F4 */ - FADDP( ST0, ST(7) ) /* F2 F1 F3 F7 F6 F5 F4 */ - FXCH( ST(1) ) /* F1 F2 F3 F7 F6 F5 F4 */ - FADDP( ST0, ST(5) ) /* F2 F3 F7 F6 F5 F4 */ - FADDP( ST0, ST(3) ) /* F3 F7 F6 F5 F4 */ - FADDP( ST0, ST(1) ) /* F7 F6 F5 F4 */ - - FLD_S( SRC2 ) /* F0 F7 F6 F5 F4 */ - FMUL_S( MAT8 ) - FLD_S( SRC2 ) /* F1 F0 F7 F6 F5 F4 */ - FMUL_S( MAT9 ) - FLD_S( SRC2 ) /* F2 F1 F0 F7 F6 F5 F4 */ - FMUL_S( MAT10 ) - FLD_S( SRC2 ) /* F3 F2 F1 F0 F7 F6 F5 F4 */ - FMUL_S( MAT11 ) - - FXCH( ST(3) ) /* F0 F2 F1 F3 F7 F6 F5 F4 */ - FADDP( ST0, ST(7) ) /* F2 F1 F3 F7 F6 F5 F4 */ - FXCH( ST(1) ) /* F1 F2 F3 F7 F6 F5 F4 */ - FADDP( ST0, ST(5) ) /* F2 F3 F7 F6 F5 F4 */ - FADDP( ST0, ST(3) ) /* F3 F7 F6 F5 F4 */ - FADDP( ST0, ST(1) ) /* F7 F6 F5 F4 */ - - FLD_S( SRC3 ) /* F0 F7 F6 F5 F4 */ - FMUL_S( MAT12 ) - FLD_S( SRC3 ) /* F1 F0 F7 F6 F5 F4 */ - FMUL_S( MAT13 ) - FLD_S( SRC3 ) /* F2 F1 F0 F7 F6 F5 F4 */ - FMUL_S( MAT14 ) - FLD_S( SRC3 ) /* F3 F2 F1 F0 F7 F6 F5 F4 */ - FMUL_S( MAT15 ) - - FXCH( ST(3) ) /* F0 F2 F1 F3 F7 F6 F5 F4 */ - FADDP( ST0, ST(7) ) /* F2 F1 F3 F7 F6 F5 F4 */ - FXCH( ST(1) ) /* F1 F2 F3 F7 F6 F5 F4 */ - FADDP( ST0, ST(5) ) /* F2 F3 F7 F6 F5 F4 */ - FADDP( ST0, ST(3) ) /* F3 F7 F6 F5 F4 */ - FADDP( ST0, ST(1) ) /* F7 F6 F5 F4 */ - - FXCH( ST(3) ) /* F4 F6 F5 F7 */ - FSTP_S( DST0 ) /* F6 F5 F7 */ - FXCH( ST(1) ) /* F5 F6 F7 */ - FSTP_S( DST1 ) /* F6 F7 */ - FSTP_S( DST2 ) /* F7 */ - FSTP_S( DST3 ) /* */ - -LLBL(x86_p4_gr_skip): - - ADD_L( CONST(16), EDI ) - ADD_L( EAX, ESI ) - CMP_L( ECX, EDI ) - JNE( LLBL(x86_p4_gr_loop) ) - -LLBL(x86_p4_gr_done): - - POP_L( EDI ) - POP_L( ESI ) - RET -#undef FRAME_OFFSET - - - - -ALIGNTEXT16 -GLOBL GLNAME( _mesa_x86_transform_points4_perspective ) -HIDDEN(_mesa_x86_transform_points4_perspective) -GLNAME( _mesa_x86_transform_points4_perspective ): - -#define FRAME_OFFSET 12 - PUSH_L( ESI ) - PUSH_L( EDI ) - PUSH_L( EBX ) - - MOV_L( ARG_SOURCE, ESI ) - MOV_L( ARG_DEST, EDI ) - - MOV_L( ARG_MATRIX, EDX ) - MOV_L( REGOFF(V4F_COUNT, ESI), ECX ) - - TEST_L( ECX, ECX ) - JZ( LLBL(x86_p4_pr_done) ) - - MOV_L( REGOFF(V4F_STRIDE, ESI), EAX ) - OR_L( CONST(VEC_SIZE_4), REGOFF(V4F_FLAGS, EDI) ) - - MOV_L( ECX, REGOFF(V4F_COUNT, EDI) ) - MOV_L( CONST(4), REGOFF(V4F_SIZE, EDI) ) - - SHL_L( CONST(4), ECX ) - MOV_L( REGOFF(V4F_START, ESI), ESI ) - - MOV_L( REGOFF(V4F_START, EDI), EDI ) - ADD_L( EDI, ECX ) - -ALIGNTEXT16 -LLBL(x86_p4_pr_loop): - - FLD_S( SRC0 ) /* F4 */ - FMUL_S( MAT0 ) - - FLD_S( SRC1 ) /* F5 F4 */ - FMUL_S( MAT5 ) - - FLD_S( SRC2 ) /* F0 F5 F4 */ - FMUL_S( MAT8 ) - FLD_S( SRC2 ) /* F1 F0 F5 F4 */ - FMUL_S( MAT9 ) - FLD_S( SRC2 ) /* F6 F1 F0 F5 F4 */ - FMUL_S( MAT10 ) - - FXCH( ST(2) ) /* F0 F1 F6 F5 F4 */ - FADDP( ST0, ST(4) ) /* F1 F6 F5 F4 */ - FADDP( ST0, ST(2) ) /* F6 F5 F4 */ - - FLD_S( SRC3 ) /* F2 F6 F5 F4 */ - FMUL_S( MAT14 ) - - FADDP( ST0, ST(1) ) /* F6 F5 F4 */ - - MOV_L( SRC2, EBX ) - XOR_L( CONST(-2147483648), EBX )/* change sign */ - - FXCH( ST(2) ) /* F4 F5 F6 */ - FSTP_S( DST0 ) /* F5 F6 */ - FSTP_S( DST1 ) /* F6 */ - FSTP_S( DST2 ) /* */ - MOV_L( EBX, DST3 ) - -LLBL(x86_p4_pr_skip): - - ADD_L( CONST(16), EDI ) - ADD_L( EAX, ESI ) - CMP_L( ECX, EDI ) - JNE( LLBL(x86_p4_pr_loop) ) - -LLBL(x86_p4_pr_done): - - POP_L( EBX ) - POP_L( EDI ) - POP_L( ESI ) - RET -#undef FRAME_OFFSET - - - - -ALIGNTEXT16 -GLOBL GLNAME( _mesa_x86_transform_points4_3d ) -HIDDEN(_mesa_x86_transform_points4_3d) -GLNAME( _mesa_x86_transform_points4_3d ): - -#define FRAME_OFFSET 12 - PUSH_L( ESI ) - PUSH_L( EDI ) - PUSH_L( EBX ) - - MOV_L( ARG_SOURCE, ESI ) - MOV_L( ARG_DEST, EDI ) - - MOV_L( ARG_MATRIX, EDX ) - MOV_L( REGOFF(V4F_COUNT, ESI), ECX ) - - TEST_L( ECX, ECX ) - JZ( LLBL(x86_p4_3dr_done) ) - - MOV_L( REGOFF(V4F_STRIDE, ESI), EAX ) - OR_L( CONST(VEC_SIZE_4), REGOFF(V4F_FLAGS, EDI) ) - - MOV_L( ECX, REGOFF(V4F_COUNT, EDI) ) - MOV_L( CONST(4), REGOFF(V4F_SIZE, EDI) ) - - SHL_L( CONST(4), ECX ) - MOV_L( REGOFF(V4F_START, ESI), ESI ) - - MOV_L( REGOFF(V4F_START, EDI), EDI ) - ADD_L( EDI, ECX ) - -ALIGNTEXT16 -LLBL(x86_p4_3dr_loop): - - FLD_S( SRC0 ) /* F4 */ - FMUL_S( MAT0 ) - FLD_S( SRC0 ) /* F5 F4 */ - FMUL_S( MAT1 ) - FLD_S( SRC0 ) /* F6 F5 F4 */ - FMUL_S( MAT2 ) - - FLD_S( SRC1 ) /* F0 F6 F5 F4 */ - FMUL_S( MAT4 ) - FLD_S( SRC1 ) /* F1 F0 F6 F5 F4 */ - FMUL_S( MAT5 ) - FLD_S( SRC1 ) /* F2 F1 F0 F6 F5 F4 */ - FMUL_S( MAT6 ) - - FXCH( ST(2) ) /* F0 F1 F2 F6 F5 F4 */ - FADDP( ST0, ST(5) ) /* F1 F2 F6 F5 F4 */ - FADDP( ST0, ST(3) ) /* F2 F6 F5 F4 */ - FADDP( ST0, ST(1) ) /* F6 F5 F4 */ - - FLD_S( SRC2 ) /* F0 F6 F5 F4 */ - FMUL_S( MAT8 ) - FLD_S( SRC2 ) /* F1 F0 F6 F5 F4 */ - FMUL_S( MAT9 ) - FLD_S( SRC2 ) /* F2 F1 F0 F6 F5 F4 */ - FMUL_S( MAT10 ) - - FXCH( ST(2) ) /* F0 F1 F2 F6 F5 F4 */ - FADDP( ST0, ST(5) ) /* F1 F2 F6 F5 F4 */ - FADDP( ST0, ST(3) ) /* F2 F6 F5 F4 */ - FADDP( ST0, ST(1) ) /* F6 F5 F4 */ - - FLD_S( SRC3 ) /* F0 F6 F5 F4 */ - FMUL_S( MAT12 ) - FLD_S( SRC3 ) /* F1 F0 F6 F5 F4 */ - FMUL_S( MAT13 ) - FLD_S( SRC3 ) /* F2 F1 F0 F6 F5 F4 */ - FMUL_S( MAT14 ) - - FXCH( ST(2) ) /* F0 F1 F2 F6 F5 F4 */ - FADDP( ST0, ST(5) ) /* F1 F2 F6 F5 F4 */ - FADDP( ST0, ST(3) ) /* F2 F6 F5 F4 */ - FADDP( ST0, ST(1) ) /* F6 F5 F4 */ - - MOV_L( SRC3, EBX ) - - FXCH( ST(2) ) /* F4 F5 F6 */ - FSTP_S( DST0 ) /* F5 F6 */ - FSTP_S( DST1 ) /* F6 */ - FSTP_S( DST2 ) /* */ - MOV_L( EBX, DST3 ) - -LLBL(x86_p4_3dr_skip): - - ADD_L( CONST(16), EDI ) - ADD_L( EAX, ESI ) - CMP_L( ECX, EDI ) - JNE( LLBL(x86_p4_3dr_loop) ) - -LLBL(x86_p4_3dr_done): - - POP_L( EBX ) - POP_L( EDI ) - POP_L( ESI ) - RET -#undef FRAME_OFFSET - - - - -ALIGNTEXT16 -GLOBL GLNAME(_mesa_x86_transform_points4_3d_no_rot) -HIDDEN(_mesa_x86_transform_points4_3d_no_rot) -GLNAME(_mesa_x86_transform_points4_3d_no_rot): - -#define FRAME_OFFSET 12 - PUSH_L( ESI ) - PUSH_L( EDI ) - PUSH_L( EBX ) - - MOV_L( ARG_SOURCE, ESI ) - MOV_L( ARG_DEST, EDI ) - - MOV_L( ARG_MATRIX, EDX ) - MOV_L( REGOFF(V4F_COUNT, ESI), ECX ) - - TEST_L( ECX, ECX ) - JZ( LLBL(x86_p4_3dnrr_done) ) - - MOV_L( REGOFF(V4F_STRIDE, ESI), EAX ) - OR_L( CONST(VEC_SIZE_4), REGOFF(V4F_FLAGS, EDI) ) - - MOV_L( ECX, REGOFF(V4F_COUNT, EDI) ) - MOV_L( CONST(4), REGOFF(V4F_SIZE, EDI) ) - - SHL_L( CONST(4), ECX ) - MOV_L( REGOFF(V4F_START, ESI), ESI ) - - MOV_L( REGOFF(V4F_START, EDI), EDI ) - ADD_L( EDI, ECX ) - -ALIGNTEXT16 -LLBL(x86_p4_3dnrr_loop): - - FLD_S( SRC0 ) /* F4 */ - FMUL_S( MAT0 ) - - FLD_S( SRC1 ) /* F5 F4 */ - FMUL_S( MAT5 ) - - FLD_S( SRC2 ) /* F6 F5 F4 */ - FMUL_S( MAT10 ) - - FLD_S( SRC3 ) /* F0 F6 F5 F4 */ - FMUL_S( MAT12 ) - FLD_S( SRC3 ) /* F1 F0 F6 F5 F4 */ - FMUL_S( MAT13 ) - FLD_S( SRC3 ) /* F2 F1 F0 F6 F5 F4 */ - FMUL_S( MAT14 ) - - FXCH( ST(2) ) /* F0 F1 F2 F6 F5 F4 */ - FADDP( ST0, ST(5) ) /* F1 F2 F6 F5 F4 */ - FADDP( ST0, ST(3) ) /* F2 F6 F5 F4 */ - FADDP( ST0, ST(1) ) /* F6 F5 F4 */ - - MOV_L( SRC3, EBX ) - - FXCH( ST(2) ) /* F4 F5 F6 */ - FSTP_S( DST0 ) /* F5 F6 */ - FSTP_S( DST1 ) /* F6 */ - FSTP_S( DST2 ) /* */ - MOV_L( EBX, DST3 ) - -LLBL(x86_p4_3dnrr_skip): - - ADD_L( CONST(16), EDI ) - ADD_L( EAX, ESI ) - CMP_L( ECX, EDI ) - JNE( LLBL(x86_p4_3dnrr_loop) ) - -LLBL(x86_p4_3dnrr_done): - - POP_L( EBX ) - POP_L( EDI ) - POP_L( ESI ) - RET -#undef FRAME_OFFSET - - - - -ALIGNTEXT16 -GLOBL GLNAME( _mesa_x86_transform_points4_2d ) -HIDDEN(_mesa_x86_transform_points4_2d) -GLNAME( _mesa_x86_transform_points4_2d ): - -#define FRAME_OFFSET 16 - PUSH_L( ESI ) - PUSH_L( EDI ) - PUSH_L( EBX ) - PUSH_L( EBP ) - - MOV_L( ARG_SOURCE, ESI ) - MOV_L( ARG_DEST, EDI ) - - MOV_L( ARG_MATRIX, EDX ) - MOV_L( REGOFF(V4F_COUNT, ESI), ECX ) - - TEST_L( ECX, ECX ) - JZ( LLBL(x86_p4_2dr_done) ) - - MOV_L( REGOFF(V4F_STRIDE, ESI), EAX ) - OR_L( CONST(VEC_SIZE_4), REGOFF(V4F_FLAGS, EDI) ) - - MOV_L( ECX, REGOFF(V4F_COUNT, EDI) ) - MOV_L( CONST(4), REGOFF(V4F_SIZE, EDI) ) - - SHL_L( CONST(4), ECX ) - MOV_L( REGOFF(V4F_START, ESI), ESI ) - - MOV_L( REGOFF(V4F_START, EDI), EDI ) - ADD_L( EDI, ECX ) - -ALIGNTEXT16 -LLBL(x86_p4_2dr_loop): - - FLD_S( SRC0 ) /* F4 */ - FMUL_S( MAT0 ) - FLD_S( SRC0 ) /* F5 F4 */ - FMUL_S( MAT1 ) - - FLD_S( SRC1 ) /* F0 F5 F4 */ - FMUL_S( MAT4 ) - FLD_S( SRC1 ) /* F1 F0 F5 F4 */ - FMUL_S( MAT5 ) - - FXCH( ST(1) ) /* F0 F1 F5 F4 */ - FADDP( ST0, ST(3) ) /* F1 F5 F4 */ - FADDP( ST0, ST(1) ) /* F5 F4 */ - - FLD_S( SRC3 ) /* F0 F5 F4 */ - FMUL_S( MAT12 ) - FLD_S( SRC3 ) /* F1 F0 F5 F4 */ - FMUL_S( MAT13 ) - - FXCH( ST(1) ) /* F0 F1 F5 F4 */ - FADDP( ST0, ST(3) ) /* F1 F5 F4 */ - FADDP( ST0, ST(1) ) /* F5 F4 */ - - MOV_L( SRC2, EBX ) - MOV_L( SRC3, EBP ) - - FXCH( ST(1) ) /* F4 F5 */ - FSTP_S( DST0 ) /* F5 */ - FSTP_S( DST1 ) /* */ - MOV_L( EBX, DST2 ) - MOV_L( EBP, DST3 ) - -LLBL(x86_p4_2dr_skip): - - ADD_L( CONST(16), EDI ) - ADD_L( EAX, ESI ) - CMP_L( ECX, EDI ) - JNE( LLBL(x86_p4_2dr_loop) ) - -LLBL(x86_p4_2dr_done): - - POP_L( EBP ) - POP_L( EBX ) - POP_L( EDI ) - POP_L( ESI ) - RET -#undef FRAME_OFFSET - - - - -ALIGNTEXT16 -GLOBL GLNAME( _mesa_x86_transform_points4_2d_no_rot ) -HIDDEN(_mesa_x86_transform_points4_2d_no_rot) -GLNAME( _mesa_x86_transform_points4_2d_no_rot ): - -#define FRAME_OFFSET 16 - PUSH_L( ESI ) - PUSH_L( EDI ) - PUSH_L( EBX ) - PUSH_L( EBP ) - - MOV_L( ARG_SOURCE, ESI ) - MOV_L( ARG_DEST, EDI ) - - MOV_L( ARG_MATRIX, EDX ) - MOV_L( REGOFF(V4F_COUNT, ESI), ECX ) - - TEST_L( ECX, ECX ) - JZ( LLBL(x86_p4_2dnrr_done) ) - - MOV_L( REGOFF(V4F_STRIDE, ESI), EAX ) - OR_L( CONST(VEC_SIZE_4), REGOFF(V4F_FLAGS, EDI) ) - - MOV_L( ECX, REGOFF(V4F_COUNT, EDI) ) - MOV_L( CONST(4), REGOFF(V4F_SIZE, EDI) ) - - SHL_L( CONST(4), ECX ) - MOV_L( REGOFF(V4F_START, ESI), ESI ) - - MOV_L( REGOFF(V4F_START, EDI), EDI ) - ADD_L( EDI, ECX ) - -ALIGNTEXT16 -LLBL(x86_p4_2dnrr_loop): - - FLD_S( SRC0 ) /* F4 */ - FMUL_S( MAT0 ) - - FLD_S( SRC1 ) /* F5 F4 */ - FMUL_S( MAT5 ) - - FLD_S( SRC3 ) /* F0 F5 F4 */ - FMUL_S( MAT12 ) - FLD_S( SRC3 ) /* F1 F0 F5 F4 */ - FMUL_S( MAT13 ) - - FXCH( ST(1) ) /* F0 F1 F5 F4 */ - FADDP( ST0, ST(3) ) /* F1 F5 F4 */ - FADDP( ST0, ST(1) ) /* F5 F4 */ - - MOV_L( SRC2, EBX ) - MOV_L( SRC3, EBP ) - - FXCH( ST(1) ) /* F4 F5 */ - FSTP_S( DST0 ) /* F5 */ - FSTP_S( DST1 ) /* */ - MOV_L( EBX, DST2 ) - MOV_L( EBP, DST3 ) - -LLBL(x86_p4_2dnrr_skip): - - ADD_L( CONST(16), EDI ) - ADD_L( EAX, ESI ) - CMP_L( ECX, EDI ) - JNE( LLBL(x86_p4_2dnrr_loop) ) - -LLBL(x86_p4_2dnrr_done): - - POP_L( EBP ) - POP_L( EBX ) - POP_L( EDI ) - POP_L( ESI ) - RET -#undef FRAME_OFFSET - - - - -ALIGNTEXT16 -GLOBL GLNAME( _mesa_x86_transform_points4_identity ) -HIDDEN(_mesa_x86_transform_points4_identity) -GLNAME( _mesa_x86_transform_points4_identity ): - -#define FRAME_OFFSET 12 - PUSH_L( ESI ) - PUSH_L( EDI ) - PUSH_L( EBX ) - - MOV_L( ARG_SOURCE, ESI ) - MOV_L( ARG_DEST, EDI ) - - MOV_L( ARG_MATRIX, EDX ) - MOV_L( REGOFF(V4F_COUNT, ESI), ECX ) - - TEST_L( ECX, ECX ) - JZ( LLBL(x86_p4_ir_done) ) - - MOV_L( REGOFF(V4F_STRIDE, ESI), EAX ) - OR_L( CONST(VEC_SIZE_4), REGOFF(V4F_FLAGS, EDI) ) - - MOV_L( ECX, REGOFF(V4F_COUNT, EDI) ) - MOV_L( CONST(4), REGOFF(V4F_SIZE, EDI) ) - - SHL_L( CONST(4), ECX ) - MOV_L( REGOFF(V4F_START, ESI), ESI ) - - MOV_L( REGOFF(V4F_START, EDI), EDI ) - ADD_L( EDI, ECX ) - - CMP_L( ESI, EDI ) - JE( LLBL(x86_p4_ir_done) ) - -ALIGNTEXT16 -LLBL(x86_p4_ir_loop): - - MOV_L( SRC0, EBX ) - MOV_L( SRC1, EDX ) - - MOV_L( EBX, DST0 ) - MOV_L( EDX, DST1 ) - - MOV_L( SRC2, EBX ) - MOV_L( SRC3, EDX ) - - MOV_L( EBX, DST2 ) - MOV_L( EDX, DST3 ) - -LLBL(x86_p4_ir_skip): - - ADD_L( CONST(16), EDI ) - ADD_L( EAX, ESI ) - CMP_L( ECX, EDI ) - JNE( LLBL(x86_p4_ir_loop) ) - -LLBL(x86_p4_ir_done): - - POP_L( EBX ) - POP_L( EDI ) - POP_L( ESI ) - RET - -#if defined (__ELF__) && defined (__linux__) - .section .note.GNU-stack,"",%progbits -#endif diff --git a/dll/opengl/mesa/x86/xform_args.h b/dll/opengl/mesa/x86/xform_args.h deleted file mode 100644 index b773f5198d1..00000000000 --- a/dll/opengl/mesa/x86/xform_args.h +++ /dev/null @@ -1,51 +0,0 @@ - -/* - * Mesa 3-D graphics library - * Version: 3.5 - * - * Copyright (C) 1999-2001 Brian Paul All Rights Reserved. - * - * Permission is hereby granted, free of charge, to any person obtaining a - * copy of this software and associated documentation files (the "Software"), - * to deal in the Software without restriction, including without limitation - * the rights to use, copy, modify, merge, publish, distribute, sublicense, - * and/or sell copies of the Software, and to permit persons to whom the - * Software is furnished to do so, subject to the following conditions: - * - * The above copyright notice and this permission notice shall be included - * in all copies or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS - * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL - * BRIAN PAUL BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN - * AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN - * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. - */ - -/* - * Transform function interface for assembly code. Simply define - * FRAME_OFFSET to the number of bytes pushed onto the stack before - * using the ARG_* argument macros. - * - * Gareth Hughes - */ - -#ifndef __XFORM_ARGS_H__ -#define __XFORM_ARGS_H__ - -/* Offsets for transform_func arguments - * - * typedef void (*transform_func)( GLvector4f *to_vec, - * const GLfloat m[16], - * const GLvector4f *from_vec ); - */ -#define OFFSET_DEST 4 -#define OFFSET_MATRIX 8 -#define OFFSET_SOURCE 12 - -#define ARG_DEST REGOFF(FRAME_OFFSET+OFFSET_DEST, ESP) -#define ARG_MATRIX REGOFF(FRAME_OFFSET+OFFSET_MATRIX, ESP) -#define ARG_SOURCE REGOFF(FRAME_OFFSET+OFFSET_SOURCE, ESP) - -#endif diff --git a/dll/opengl/mesa/xform.c b/dll/opengl/mesa/xform.c new file mode 100644 index 00000000000..401362d97b7 --- /dev/null +++ b/dll/opengl/mesa/xform.c @@ -0,0 +1,258 @@ +/* $Id: xform.c,v 1.10 1997/10/30 06:00:06 brianp Exp $ */ + +/* + * Mesa 3-D graphics library + * Version: 2.5 + * Copyright (C) 1995-1997 Brian Paul + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Library General Public + * License as published by the Free Software Foundation; either + * version 2 of the License, or (at your option) any later version. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Library General Public License for more details. + * + * You should have received a copy of the GNU Library General Public + * License along with this library; if not, write to the Free + * Software Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. + */ + + +/* + * $Log: xform.c,v $ + * Revision 1.10 1997/10/30 06:00:06 brianp + * added Intel X86 assembly optimzations (Josh Vanderhoof) + * + * Revision 1.9 1997/07/24 01:25:54 brianp + * changed precompiled header symbol from PCH to PC_HEADER + * + * Revision 1.8 1997/05/28 03:27:03 brianp + * added precompiled header (PCH) support + * + * Revision 1.7 1997/05/01 01:40:51 brianp + * replaced sqrt() with GL_SQRT() + * + * Revision 1.6 1997/04/02 03:15:02 brianp + * removed gl_xform_texcoords_4fv() + * + * Revision 1.5 1997/01/03 23:54:17 brianp + * changed length threshold in gl_xform_normals_3fv() to 1E-30 per Jeroen + * + * Revision 1.4 1996/11/09 01:50:49 brianp + * relaxed the minimum normal threshold in gl_xform_normals_3fv() + * + * Revision 1.3 1996/11/08 02:20:39 brianp + * added gl_xform_texcoords_4fv() + * + * Revision 1.2 1996/11/05 01:38:50 brianp + * fixed some comments + * + * Revision 1.1 1996/09/13 01:38:16 brianp + * Initial revision + * + */ + + +/* + * Matrix/vertex/vector transformation stuff + * + * + * NOTES: + * 1. 4x4 transformation matrices are stored in memory in column major order. + * 2. Points/vertices are to be thought of as column vectors. + * 3. Transformation of a point p by a matrix M is: p' = M * p + * + */ + + +#ifdef PC_HEADER +#include "all.h" +#else +#include +#include "mmath.h" +#include "types.h" +#include "xform.h" +#endif + + + +/* + * Apply a transformation matrix to an array of [X Y Z W] coordinates: + * for i in 0 to n-1 do q[i] = m * p[i] + * where p[i] and q[i] are 4-element column vectors and m is a 16-element + * transformation matrix. + */ +void gl_xform_points_4fv( GLuint n, GLfloat q[][4], const GLfloat m[16], + GLfloat p[][4] ) +{ + /* This function has been carefully crafted to maximize register usage + * and use loop unrolling with IRIX 5.3's cc. Hopefully other compilers + * will like this code too. + */ + { + GLuint i; + GLfloat m0 = m[0], m4 = m[4], m8 = m[8], m12 = m[12]; + GLfloat m1 = m[1], m5 = m[5], m9 = m[9], m13 = m[13]; + if (m12==0.0F && m13==0.0F) { + /* common case */ + for (i=0;i1E-30) ? (1.0 / len) : 1.0; + v[i][0] = tx * scale; + v[i][1] = ty * scale; + v[i][2] = tz * scale; + } + } + } + else { + /* Just transform normals, don't scale */ + GLuint i; + GLfloat m0 = m[0], m4 = m[4], m8 = m[8]; + GLfloat m1 = m[1], m5 = m[5], m9 = m[9]; + GLfloat m2 = m[2], m6 = m[6], m10 = m[10]; + for (i=0;i -#include
-#include
-#include
-#include
-#include -#include -#include -#include -#include -#include -#include +#include +#include WINE_DEFAULT_DEBUG_CHANNEL(opengl32); #define WIDTH_BYTES_ALIGN32(cx, bpp) ((((cx) * (bpp) + 31) & ~31) >> 3) +#define WIDTH_BYTES_ALIGN16(cx, bpp) ((((cx) * (bpp) + 15) & ~15) >> 3) -static const struct +/* Flags for our pixel formats */ +#define SB_FLAGS (PFD_DRAW_TO_BITMAP | PFD_SUPPORT_GDI | PFD_SUPPORT_OPENGL | PFD_GENERIC_FORMAT) +#define SB_FLAGS_WINDOW (PFD_DRAW_TO_BITMAP | PFD_SUPPORT_GDI | PFD_DRAW_TO_WINDOW | PFD_SUPPORT_OPENGL | PFD_GENERIC_FORMAT) +#define SB_FLAGS_PALETTE (PFD_DRAW_TO_BITMAP | PFD_SUPPORT_GDI | PFD_DRAW_TO_WINDOW | PFD_SUPPORT_OPENGL | PFD_GENERIC_FORMAT | PFD_NEED_PALETTE) +#define DB_FLAGS (PFD_DOUBLEBUFFER | PFD_SWAP_COPY | PFD_DRAW_TO_WINDOW | PFD_SUPPORT_OPENGL | PFD_GENERIC_FORMAT) +#define DB_FLAGS_PALETTE (PFD_DOUBLEBUFFER | PFD_SWAP_COPY | PFD_DRAW_TO_WINDOW | PFD_SUPPORT_OPENGL | PFD_GENERIC_FORMAT | PFD_NEED_PALETTE) + + +struct pixel_format { - gl_format mesa; - BYTE color_bits; - BYTE red_bits, red_shift; DWORD red_mask; - BYTE green_bits, green_shift; DWORD green_mask; - BYTE blue_bits, blue_shift; DWORD blue_mask; - BYTE alpha_bits, alpha_shift; DWORD alpha_mask; - BYTE accum_bits; - BYTE depth_bits; - BYTE stencil_bits; - DWORD bmp_compression; -} pixel_formats[] = -{ - { MESA_FORMAT_ARGB8888, 32, 8, 8, 0x00FF0000, 8, 16, 0x0000FF00, 8, 24, 0x000000FF, 8, 0, 0xFF000000, 16, 32, 8, BI_BITFIELDS }, - { MESA_FORMAT_ARGB8888, 32, 8, 8, 0x00FF0000, 8, 16, 0x0000FF00, 8, 24, 0x000000FF, 8, 0, 0xFF000000, 16, 16, 8, BI_BITFIELDS }, - { MESA_FORMAT_RGBA8888_REV, 32, 8, 8, 0x000000FF, 8, 16, 0x0000FF00, 8, 24, 0x00FF0000, 8, 0, 0xFF000000, 16, 32, 8, BI_BITFIELDS }, - { MESA_FORMAT_RGBA8888_REV, 32, 8, 8, 0x000000FF, 8, 16, 0x0000FF00, 8, 24, 0x00FF0000, 8, 0, 0xFF000000, 16, 16, 8, BI_BITFIELDS }, - { MESA_FORMAT_RGBA8888, 32, 8, 0, 0xFF000000, 8, 8, 0x00FF0000, 8, 16, 0x0000FF00, 8, 24, 0x000000FF, 16, 32, 8, BI_BITFIELDS }, - { MESA_FORMAT_RGBA8888, 32, 8, 0, 0xFF000000, 8, 8, 0x00FF0000, 8, 16, 0x0000FF00, 8, 24, 0x000000FF, 16, 16, 8, BI_BITFIELDS }, - { MESA_FORMAT_ARGB8888_REV, 32, 8, 16, 0x0000FF00, 8, 8, 0x00FF0000, 8, 0, 0xFF000000, 8, 24, 0x000000FF, 16, 32, 8, BI_BITFIELDS }, - { MESA_FORMAT_ARGB8888_REV, 32, 8, 16, 0x0000FF00, 8, 8, 0x00FF0000, 8, 0, 0xFF000000, 8, 24, 0x000000FF, 16, 16, 8, BI_BITFIELDS }, - { MESA_FORMAT_RGB888, 24, 8, 0, 0x00000000, 8, 8, 0x00000000, 8, 16, 0x00000000, 0, 0, 0x00000000, 16, 32, 8, BI_RGB }, - { MESA_FORMAT_RGB888, 24, 8, 0, 0x00000000, 8, 8, 0x00000000, 8, 16, 0x00000000, 0, 0, 0x00000000, 16, 16, 8, BI_RGB }, - // { MESA_FORMAT_BGR888, 24, 8, 16, 8, 8, 8, 0, 0, 0, 16, 32, 8 }, - // { MESA_FORMAT_BGR888, 24, 8, 16, 8, 8, 8, 0, 0, 0, 16, 16, 8 }, - { MESA_FORMAT_RGB565, 16, 5, 0, 0x0000F800, 6, 5, 0x000007E0, 5, 11, 0x0000001F, 0, 0, 0x00000000, 16, 32, 8, BI_BITFIELDS }, - { MESA_FORMAT_RGB565, 16, 5, 0, 0x0000F800, 6, 5, 0x000007E0, 5, 11, 0x0000001F, 0, 0, 0x00000000, 16, 16, 8, BI_BITFIELDS }, + DWORD dwFlags; + BYTE iPixelType; + BYTE cColorBits; + BYTE cRedBits; BYTE cRedShift; + BYTE cGreenBits; BYTE cGreenShift; + BYTE cBlueBits; BYTE cBlueShift; + BYTE cAlphaBits; BYTE cAlphaShift; + BYTE cAccumBits; + BYTE cAccumRedBits; BYTE cAccumGreenBits; BYTE cAccumBlueBits; BYTE cAccumAlphaBits; + BYTE cDepthBits; }; -#define SW_BACK_RENDERBUFFER_CLASS 0x8911 -#define SW_FRONT_RENDERBUFFER_CLASS 0x8910 -struct sw_front_renderbuffer +static const struct pixel_format pixel_formats_32[] = { - struct swrast_renderbuffer swrast; - - HDC hdcmem; - GLuint x, y, w, h; - HBITMAP hbmp; - BOOL write; + /* 32bpp */ + {SB_FLAGS_WINDOW, PFD_TYPE_RGBA, 32, 8, 16, 8, 8, 8, 0, 0, 0, 64, 16, 16, 16, 0, 32}, + {SB_FLAGS_WINDOW, PFD_TYPE_RGBA, 32, 8, 16, 8, 8, 8, 0, 0, 0, 64, 16, 16, 16, 0, 16}, + {DB_FLAGS, PFD_TYPE_RGBA, 32, 8, 16, 8, 8, 8, 0, 0, 0, 64, 16, 16, 16, 0, 32}, + {DB_FLAGS, PFD_TYPE_RGBA, 32, 8, 16, 8, 8, 8, 0, 0, 0, 64, 16, 16, 16, 0, 16}, + {SB_FLAGS_WINDOW, PFD_TYPE_RGBA, 32, 8, 16, 8, 8, 8, 0, 8, 0, 64, 16, 16, 16, 16, 32}, + {SB_FLAGS_WINDOW, PFD_TYPE_RGBA, 32, 8, 16, 8, 8, 8, 0, 8, 0, 64, 16, 16, 16, 16, 16}, + {DB_FLAGS, PFD_TYPE_RGBA, 32, 8, 16, 8, 8, 8, 0, 8, 0, 64, 16, 16, 16, 16, 32}, + {DB_FLAGS, PFD_TYPE_RGBA, 32, 8, 16, 8, 8, 8, 0, 8, 0, 64, 16, 16, 16, 16, 16}, + {SB_FLAGS_WINDOW, PFD_TYPE_COLORINDEX, 32, 8, 16, 8, 8, 8, 0, 0, 0, 0, 0, 0, 0, 0, 32}, + {SB_FLAGS_WINDOW, PFD_TYPE_COLORINDEX, 32, 8, 16, 8, 8, 8, 0, 0, 0, 0, 0, 0, 0, 0, 16}, + {DB_FLAGS, PFD_TYPE_COLORINDEX, 32, 8, 16, 8, 8, 8, 0, 0, 0, 0, 0, 0, 0, 0, 32}, + {DB_FLAGS, PFD_TYPE_COLORINDEX, 32, 8, 16, 8, 8, 8, 0, 0, 0, 0, 0, 0, 0, 0, 16}, + /* 24bpp */ + {SB_FLAGS, PFD_TYPE_RGBA, 24, 8, 16, 8, 8, 8, 0, 0, 0, 64, 16, 16, 16, 0, 32}, + {SB_FLAGS, PFD_TYPE_RGBA, 24, 8, 16, 8, 8, 8, 0, 0, 0, 64, 16, 16, 16, 0, 16}, + {SB_FLAGS, PFD_TYPE_RGBA, 24, 8, 16, 8, 8, 8, 0, 8, 0, 64, 16, 16, 16, 16, 32}, + {SB_FLAGS, PFD_TYPE_RGBA, 24, 8, 16, 8, 8, 8, 0, 8, 0, 64, 16, 16, 16, 16, 16}, + {SB_FLAGS, PFD_TYPE_COLORINDEX, 24, 8, 16, 8, 8, 8, 0, 0, 0, 0, 0, 0, 0, 0, 32}, + {SB_FLAGS, PFD_TYPE_COLORINDEX, 24, 8, 16, 8, 8, 8, 0, 0, 0, 0, 0, 0, 0, 0, 16}, + /* 16 bpp */ + {SB_FLAGS, PFD_TYPE_RGBA, 16, 5, 10, 5, 5, 5, 0, 0, 0, 32, 11, 11, 10, 0, 32}, + {SB_FLAGS, PFD_TYPE_RGBA, 16, 5, 10, 5, 5, 5, 0, 0, 0, 32, 11, 11, 10, 0, 16}, + {SB_FLAGS, PFD_TYPE_RGBA, 16, 5, 10, 5, 5, 5, 0, 8, 0, 32, 8, 8, 8, 8, 32}, + {SB_FLAGS, PFD_TYPE_RGBA, 16, 5, 10, 5, 5, 5, 0, 8, 0, 32, 8, 8, 8, 8, 16}, + {SB_FLAGS, PFD_TYPE_COLORINDEX, 16, 5, 10, 5, 5, 5, 0, 0, 0, 0, 0, 0, 0, 0, 32}, + {SB_FLAGS, PFD_TYPE_COLORINDEX, 16, 5, 10, 5, 5, 5, 0, 0, 0, 0, 0, 0, 0, 0, 16}, + /* 8bpp */ + {SB_FLAGS, PFD_TYPE_RGBA, 8, 3, 0, 3, 3, 2, 6, 0, 0, 32, 11, 11, 10, 0, 32}, + {SB_FLAGS, PFD_TYPE_RGBA, 8, 3, 0, 3, 3, 2, 6, 0, 0, 32, 11, 11, 10, 0, 16}, + {SB_FLAGS, PFD_TYPE_RGBA, 8, 3, 0, 3, 3, 2, 6, 8, 0, 32, 8, 8, 8, 8, 32}, + {SB_FLAGS, PFD_TYPE_RGBA, 8, 3, 0, 3, 3, 2, 6, 8, 0, 32, 8, 8, 8, 8, 16}, + {SB_FLAGS, PFD_TYPE_COLORINDEX, 8, 3, 0, 3, 3, 2, 6, 0, 0, 0, 0, 0, 0, 0, 32}, + {SB_FLAGS, PFD_TYPE_COLORINDEX, 8, 3, 0, 3, 3, 2, 6, 0, 0, 0, 0, 0, 0, 0, 16}, + /* 4bpp */ + {SB_FLAGS, PFD_TYPE_RGBA, 4, 1, 0, 1, 1, 1, 2, 0, 0, 16, 5, 6, 5, 0, 32}, + {SB_FLAGS, PFD_TYPE_RGBA, 4, 1, 0, 1, 1, 1, 2, 0, 0, 16, 5, 6, 5, 0, 16}, + {SB_FLAGS, PFD_TYPE_RGBA, 4, 1, 0, 1, 1, 1, 2, 8, 0, 16, 4, 4, 4, 4, 32}, + {SB_FLAGS, PFD_TYPE_RGBA, 4, 1, 0, 1, 1, 1, 2, 8, 0, 16, 4, 4, 4, 4, 16}, + {SB_FLAGS, PFD_TYPE_COLORINDEX, 4, 1, 0, 1, 1, 1, 2, 0, 0, 0, 0, 0, 0, 0, 32}, + {SB_FLAGS, PFD_TYPE_COLORINDEX, 4, 1, 0, 1, 1, 1, 2, 0, 0, 0, 0, 0, 0, 0, 16}, +}; + +static const struct pixel_format pixel_formats_24[] = +{ + /* 24bpp */ + {SB_FLAGS_WINDOW, PFD_TYPE_RGBA, 24, 8, 16, 8, 8, 8, 0, 0, 0, 64, 16, 16, 16, 0, 32}, + {SB_FLAGS_WINDOW, PFD_TYPE_RGBA, 24, 8, 16, 8, 8, 8, 0, 0, 0, 64, 16, 16, 16, 0, 16}, + {DB_FLAGS, PFD_TYPE_RGBA, 24, 8, 16, 8, 8, 8, 0, 0, 0, 64, 16, 16, 16, 0, 32}, + {DB_FLAGS, PFD_TYPE_RGBA, 24, 8, 16, 8, 8, 8, 0, 0, 0, 64, 16, 16, 16, 0, 16}, + {SB_FLAGS_WINDOW, PFD_TYPE_RGBA, 24, 8, 16, 8, 8, 8, 0, 8, 0, 64, 16, 16, 16, 16, 32}, + {SB_FLAGS_WINDOW, PFD_TYPE_RGBA, 24, 8, 16, 8, 8, 8, 0, 8, 0, 64, 16, 16, 16, 16, 16}, + {DB_FLAGS, PFD_TYPE_RGBA, 24, 8, 16, 8, 8, 8, 0, 8, 0, 64, 16, 16, 16, 16, 32}, + {DB_FLAGS, PFD_TYPE_RGBA, 24, 8, 16, 8, 8, 8, 0, 8, 0, 64, 16, 16, 16, 16, 16}, + {SB_FLAGS_WINDOW, PFD_TYPE_COLORINDEX, 24, 8, 16, 8, 8, 8, 0, 0, 0, 0, 0, 0, 0, 0, 32}, + {SB_FLAGS_WINDOW, PFD_TYPE_COLORINDEX, 24, 8, 16, 8, 8, 8, 0, 0, 0, 0, 0, 0, 0, 0, 16}, + {DB_FLAGS, PFD_TYPE_COLORINDEX, 24, 8, 16, 8, 8, 8, 0, 0, 0, 0, 0, 0, 0, 0, 32}, + {DB_FLAGS, PFD_TYPE_COLORINDEX, 24, 8, 16, 8, 8, 8, 0, 0, 0, 0, 0, 0, 0, 0, 16}, + /* 32bpp */ + {SB_FLAGS, PFD_TYPE_RGBA, 32, 8, 16, 8, 8, 8, 0, 0, 0, 64, 16, 16, 16, 0, 32}, + {SB_FLAGS, PFD_TYPE_RGBA, 32, 8, 16, 8, 8, 8, 0, 0, 0, 64, 16, 16, 16, 0, 16}, + {SB_FLAGS, PFD_TYPE_RGBA, 32, 8, 16, 8, 8, 8, 0, 8, 0, 64, 16, 16, 16, 16, 32}, + {SB_FLAGS, PFD_TYPE_RGBA, 32, 8, 16, 8, 8, 8, 0, 8, 0, 64, 16, 16, 16, 16, 16}, + {SB_FLAGS, PFD_TYPE_COLORINDEX, 32, 8, 16, 8, 8, 8, 0, 0, 0, 0, 0, 0, 0, 0, 32}, + {SB_FLAGS, PFD_TYPE_COLORINDEX, 32, 8, 16, 8, 8, 8, 0, 0, 0, 0, 0, 0, 0, 0, 16}, + /* 16 bpp */ + {SB_FLAGS, PFD_TYPE_RGBA, 16, 5, 10, 5, 5, 5, 0, 0, 0, 32, 11, 11, 10, 0, 32}, + {SB_FLAGS, PFD_TYPE_RGBA, 16, 5, 10, 5, 5, 5, 0, 0, 0, 32, 11, 11, 10, 0, 16}, + {SB_FLAGS, PFD_TYPE_RGBA, 16, 5, 10, 5, 5, 5, 0, 8, 0, 32, 8, 8, 8, 8, 32}, + {SB_FLAGS, PFD_TYPE_RGBA, 16, 5, 10, 5, 5, 5, 0, 8, 0, 32, 8, 8, 8, 8, 16}, + {SB_FLAGS, PFD_TYPE_COLORINDEX, 16, 5, 10, 5, 5, 5, 0, 0, 0, 0, 0, 0, 0, 0, 32}, + {SB_FLAGS, PFD_TYPE_COLORINDEX, 16, 5, 10, 5, 5, 5, 0, 0, 0, 0, 0, 0, 0, 0, 16}, + /* 8bpp */ + {SB_FLAGS, PFD_TYPE_RGBA, 8, 3, 0, 3, 3, 2, 6, 0, 0, 32, 11, 11, 10, 0, 32}, + {SB_FLAGS, PFD_TYPE_RGBA, 8, 3, 0, 3, 3, 2, 6, 0, 0, 32, 11, 11, 10, 0, 16}, + {SB_FLAGS, PFD_TYPE_RGBA, 8, 3, 0, 3, 3, 2, 6, 8, 0, 32, 8, 8, 8, 8, 32}, + {SB_FLAGS, PFD_TYPE_RGBA, 8, 3, 0, 3, 3, 2, 6, 8, 0, 32, 8, 8, 8, 8, 16}, + {SB_FLAGS, PFD_TYPE_COLORINDEX, 8, 3, 0, 3, 3, 2, 6, 0, 0, 0, 0, 0, 0, 0, 32}, + {SB_FLAGS, PFD_TYPE_COLORINDEX, 8, 3, 0, 3, 3, 2, 6, 0, 0, 0, 0, 0, 0, 0, 16}, + /* 4bpp */ + {SB_FLAGS, PFD_TYPE_RGBA, 4, 1, 0, 1, 1, 1, 2, 0, 0, 16, 5, 6, 5, 0, 32}, + {SB_FLAGS, PFD_TYPE_RGBA, 4, 1, 0, 1, 1, 1, 2, 0, 0, 16, 5, 6, 5, 0, 16}, + {SB_FLAGS, PFD_TYPE_RGBA, 4, 1, 0, 1, 1, 1, 2, 8, 0, 16, 4, 4, 4, 4, 32}, + {SB_FLAGS, PFD_TYPE_RGBA, 4, 1, 0, 1, 1, 1, 2, 8, 0, 16, 4, 4, 4, 4, 16}, + {SB_FLAGS, PFD_TYPE_COLORINDEX, 4, 1, 0, 1, 1, 1, 2, 0, 0, 0, 0, 0, 0, 0, 32}, + {SB_FLAGS, PFD_TYPE_COLORINDEX, 4, 1, 0, 1, 1, 1, 2, 0, 0, 0, 0, 0, 0, 0, 16}, +}; + +static const struct pixel_format pixel_formats_16[] = +{ + /* 16 bpp - 565 */ + {SB_FLAGS_WINDOW, PFD_TYPE_RGBA, 16, 5, 11, 6, 5, 5, 0, 0, 0, 32, 11, 11, 10, 0, 32}, + {SB_FLAGS_WINDOW, PFD_TYPE_RGBA, 16, 5, 11, 6, 5, 5, 0, 0, 0, 32, 11, 11, 10, 0, 16}, + {DB_FLAGS, PFD_TYPE_RGBA, 16, 5, 11, 6, 5, 5, 0, 0, 0, 32, 11, 11, 10, 0, 32}, + {DB_FLAGS, PFD_TYPE_RGBA, 16, 5, 11, 6, 5, 5, 0, 0, 0, 32, 11, 11, 10, 0, 16}, + {SB_FLAGS_WINDOW, PFD_TYPE_RGBA, 16, 5, 11, 6, 5, 5, 0, 8, 0, 32, 8, 8, 8, 8, 32}, + {SB_FLAGS_WINDOW, PFD_TYPE_RGBA, 16, 5, 11, 6, 5, 5, 0, 8, 0, 32, 8, 8, 8, 8, 16}, + {DB_FLAGS, PFD_TYPE_RGBA, 16, 5, 11, 6, 5, 5, 0, 8, 0, 32, 8, 8, 8, 8, 32}, + {DB_FLAGS, PFD_TYPE_RGBA, 16, 5, 11, 6, 5, 5, 0, 8, 0, 32, 8, 8, 8, 8, 16}, + {SB_FLAGS_WINDOW, PFD_TYPE_COLORINDEX, 16, 5, 11, 6, 5, 5, 0, 0, 0, 0, 0, 0, 0, 0, 32}, + {SB_FLAGS_WINDOW, PFD_TYPE_COLORINDEX, 16, 5, 11, 6, 5, 5, 0, 0, 0, 0, 0, 0, 0, 0, 16}, + {DB_FLAGS, PFD_TYPE_COLORINDEX, 16, 5, 11, 6, 5, 5, 0, 0, 0, 0, 0, 0, 0, 0, 32}, + {DB_FLAGS, PFD_TYPE_COLORINDEX, 16, 5, 11, 6, 5, 5, 0, 0, 0, 0, 0, 0, 0, 0, 16}, + /* 24bpp */ + {SB_FLAGS, PFD_TYPE_RGBA, 24, 8, 16, 8, 8, 8, 0, 0, 0, 64, 16, 16, 16, 0, 32}, + {SB_FLAGS, PFD_TYPE_RGBA, 24, 8, 16, 8, 8, 8, 0, 0, 0, 64, 16, 16, 16, 0, 16}, + {SB_FLAGS, PFD_TYPE_RGBA, 24, 8, 16, 8, 8, 8, 0, 8, 0, 64, 16, 16, 16, 16, 32}, + {SB_FLAGS, PFD_TYPE_RGBA, 24, 8, 16, 8, 8, 8, 0, 8, 0, 64, 16, 16, 16, 16, 16}, + {SB_FLAGS, PFD_TYPE_COLORINDEX, 24, 8, 16, 8, 8, 8, 0, 0, 0, 0, 0, 0, 0, 0, 32}, + {SB_FLAGS, PFD_TYPE_COLORINDEX, 24, 8, 16, 8, 8, 8, 0, 0, 0, 0, 0, 0, 0, 0, 16}, + /* 32bpp */ + {SB_FLAGS, PFD_TYPE_RGBA, 32, 8, 16, 8, 8, 8, 0, 0, 0, 64, 16, 16, 16, 0, 32}, + {SB_FLAGS, PFD_TYPE_RGBA, 32, 8, 16, 8, 8, 8, 0, 0, 0, 64, 16, 16, 16, 0, 16}, + {SB_FLAGS, PFD_TYPE_RGBA, 32, 8, 16, 8, 8, 8, 0, 8, 0, 64, 16, 16, 16, 16, 32}, + {SB_FLAGS, PFD_TYPE_RGBA, 32, 8, 16, 8, 8, 8, 0, 8, 0, 64, 16, 16, 16, 16, 16}, + {SB_FLAGS, PFD_TYPE_COLORINDEX, 32, 8, 16, 8, 8, 8, 0, 0, 0, 0, 0, 0, 0, 0, 32}, + {SB_FLAGS, PFD_TYPE_COLORINDEX, 32, 8, 16, 8, 8, 8, 0, 0, 0, 0, 0, 0, 0, 0, 16}, + /* 8bpp */ + {SB_FLAGS, PFD_TYPE_RGBA, 8, 3, 0, 3, 3, 2, 6, 0, 0, 32, 11, 11, 10, 0, 32}, + {SB_FLAGS, PFD_TYPE_RGBA, 8, 3, 0, 3, 3, 2, 6, 0, 0, 32, 11, 11, 10, 0, 16}, + {SB_FLAGS, PFD_TYPE_RGBA, 8, 3, 0, 3, 3, 2, 6, 8, 0, 32, 8, 8, 8, 8, 32}, + {SB_FLAGS, PFD_TYPE_RGBA, 8, 3, 0, 3, 3, 2, 6, 8, 0, 32, 8, 8, 8, 8, 16}, + {SB_FLAGS, PFD_TYPE_COLORINDEX, 8, 3, 0, 3, 3, 2, 6, 0, 0, 0, 0, 0, 0, 0, 32}, + {SB_FLAGS, PFD_TYPE_COLORINDEX, 8, 3, 0, 3, 3, 2, 6, 0, 0, 0, 0, 0, 0, 0, 16}, + /* 4bpp */ + {SB_FLAGS, PFD_TYPE_RGBA, 4, 1, 0, 1, 1, 1, 2, 0, 0, 16, 5, 6, 5, 0, 32}, + {SB_FLAGS, PFD_TYPE_RGBA, 4, 1, 0, 1, 1, 1, 2, 0, 0, 16, 5, 6, 5, 0, 16}, + {SB_FLAGS, PFD_TYPE_RGBA, 4, 1, 0, 1, 1, 1, 2, 8, 0, 16, 4, 4, 4, 4, 32}, + {SB_FLAGS, PFD_TYPE_RGBA, 4, 1, 0, 1, 1, 1, 2, 8, 0, 16, 4, 4, 4, 4, 16}, + {SB_FLAGS, PFD_TYPE_COLORINDEX, 4, 1, 0, 1, 1, 1, 2, 0, 0, 0, 0, 0, 0, 0, 32}, + {SB_FLAGS, PFD_TYPE_COLORINDEX, 4, 1, 0, 1, 1, 1, 2, 0, 0, 0, 0, 0, 0, 0, 16}, +}; + +static const struct pixel_format pixel_formats_8[] = +{ + /* 8bpp */ + {SB_FLAGS_PALETTE, PFD_TYPE_RGBA, 8, 3, 0, 3, 3, 2, 6, 0, 0, 32, 11, 11, 10, 0, 32}, + {SB_FLAGS_PALETTE, PFD_TYPE_RGBA, 8, 3, 0, 3, 3, 2, 6, 0, 0, 32, 11, 11, 10, 0, 16}, + {DB_FLAGS_PALETTE, PFD_TYPE_RGBA, 8, 3, 0, 3, 3, 2, 6, 0, 0, 32, 11, 11, 10, 0, 32}, + {DB_FLAGS_PALETTE, PFD_TYPE_RGBA, 8, 3, 0, 3, 3, 2, 6, 0, 0, 32, 11, 11, 10, 0, 16}, + {SB_FLAGS_PALETTE, PFD_TYPE_RGBA, 8, 3, 0, 3, 3, 2, 6, 8, 0, 32, 8, 8, 8, 8, 32}, + {SB_FLAGS_PALETTE, PFD_TYPE_RGBA, 8, 3, 0, 3, 3, 2, 6, 8, 0, 32, 8, 8, 8, 8, 16}, + {DB_FLAGS_PALETTE, PFD_TYPE_RGBA, 8, 3, 0, 3, 3, 2, 6, 8, 0, 32, 8, 8, 8, 8, 32}, + {DB_FLAGS_PALETTE, PFD_TYPE_RGBA, 8, 3, 0, 3, 3, 2, 6, 8, 0, 32, 8, 8, 8, 8, 16}, + {SB_FLAGS_WINDOW, PFD_TYPE_COLORINDEX, 8, 3, 0, 3, 3, 2, 6, 0, 0, 0, 0, 0, 0, 0, 32}, + {SB_FLAGS_WINDOW, PFD_TYPE_COLORINDEX, 8, 3, 0, 3, 3, 2, 6, 0, 0, 0, 0, 0, 0, 0, 16}, + {DB_FLAGS, PFD_TYPE_COLORINDEX, 8, 3, 0, 3, 3, 2, 6, 0, 0, 0, 0, 0, 0, 0, 32}, + {DB_FLAGS, PFD_TYPE_COLORINDEX, 8, 3, 0, 3, 3, 2, 6, 0, 0, 0, 0, 0, 0, 0, 16}, + /* 24bpp */ + {SB_FLAGS, PFD_TYPE_RGBA, 24, 8, 16, 8, 8, 8, 0, 0, 0, 64, 16, 16, 16, 0, 32}, + {SB_FLAGS, PFD_TYPE_RGBA, 24, 8, 16, 8, 8, 8, 0, 0, 0, 64, 16, 16, 16, 0, 16}, + {SB_FLAGS, PFD_TYPE_RGBA, 24, 8, 16, 8, 8, 8, 0, 8, 0, 64, 16, 16, 16, 16, 32}, + {SB_FLAGS, PFD_TYPE_RGBA, 24, 8, 16, 8, 8, 8, 0, 8, 0, 64, 16, 16, 16, 16, 16}, + {SB_FLAGS, PFD_TYPE_COLORINDEX, 24, 8, 16, 8, 8, 8, 0, 0, 0, 0, 0, 0, 0, 0, 32}, + {SB_FLAGS, PFD_TYPE_COLORINDEX, 24, 8, 16, 8, 8, 8, 0, 0, 0, 0, 0, 0, 0, 0, 16}, + /* 32bpp */ + {SB_FLAGS, PFD_TYPE_RGBA, 32, 8, 16, 8, 8, 8, 0, 0, 0, 64, 16, 16, 16, 0, 32}, + {SB_FLAGS, PFD_TYPE_RGBA, 32, 8, 16, 8, 8, 8, 0, 0, 0, 64, 16, 16, 16, 0, 16}, + {SB_FLAGS, PFD_TYPE_RGBA, 32, 8, 16, 8, 8, 8, 0, 8, 0, 64, 16, 16, 16, 16, 32}, + {SB_FLAGS, PFD_TYPE_RGBA, 32, 8, 16, 8, 8, 8, 0, 8, 0, 64, 16, 16, 16, 16, 16}, + {SB_FLAGS, PFD_TYPE_COLORINDEX, 32, 8, 16, 8, 8, 8, 0, 0, 0, 0, 0, 0, 0, 0, 32}, + {SB_FLAGS, PFD_TYPE_COLORINDEX, 32, 8, 16, 8, 8, 8, 0, 0, 0, 0, 0, 0, 0, 0, 16}, + /* 16 bpp */ + {SB_FLAGS, PFD_TYPE_RGBA, 16, 5, 10, 5, 5, 5, 0, 0, 0, 32, 11, 11, 10, 0, 32}, + {SB_FLAGS, PFD_TYPE_RGBA, 16, 5, 10, 5, 5, 5, 0, 0, 0, 32, 11, 11, 10, 0, 16}, + {SB_FLAGS, PFD_TYPE_RGBA, 16, 5, 10, 5, 5, 5, 0, 8, 0, 32, 8, 8, 8, 8, 32}, + {SB_FLAGS, PFD_TYPE_RGBA, 16, 5, 10, 5, 5, 5, 0, 8, 0, 32, 8, 8, 8, 8, 16}, + {SB_FLAGS, PFD_TYPE_COLORINDEX, 16, 5, 10, 5, 5, 5, 0, 0, 0, 0, 0, 0, 0, 0, 32}, + {SB_FLAGS, PFD_TYPE_COLORINDEX, 16, 5, 10, 5, 5, 5, 0, 0, 0, 0, 0, 0, 0, 0, 16}, + /* 4bpp */ + {SB_FLAGS, PFD_TYPE_RGBA, 4, 1, 0, 1, 1, 1, 2, 0, 0, 16, 5, 6, 5, 0, 32}, + {SB_FLAGS, PFD_TYPE_RGBA, 4, 1, 0, 1, 1, 1, 2, 0, 0, 16, 5, 6, 5, 0, 16}, + {SB_FLAGS, PFD_TYPE_RGBA, 4, 1, 0, 1, 1, 1, 2, 8, 0, 16, 4, 4, 4, 4, 32}, + {SB_FLAGS, PFD_TYPE_RGBA, 4, 1, 0, 1, 1, 1, 2, 8, 0, 16, 4, 4, 4, 4, 16}, + {SB_FLAGS, PFD_TYPE_COLORINDEX, 4, 1, 0, 1, 1, 1, 2, 0, 0, 0, 0, 0, 0, 0, 32}, + {SB_FLAGS, PFD_TYPE_COLORINDEX, 4, 1, 0, 1, 1, 1, 2, 0, 0, 0, 0, 0, 0, 0, 16}, }; -#define SW_FB_DOUBLEBUFFERED 0x1 -#define SW_FB_DIRTY_SIZE 0x2 struct sw_framebuffer { - HDC hdc; - INT sw_format; - UINT format_index; - DWORD flags; - /* The mesa objects */ - struct gl_config *gl_visual; /* Describes the buffers */ - struct gl_framebuffer *gl_buffer; /* The mesa representation of frame buffer */ - struct sw_front_renderbuffer frontbuffer; - struct swrast_renderbuffer backbuffer; - /* The bitmapi info we will use for rendering to display */ - BITMAPINFO bmi; + GLvisual *gl_visual; /* Describes the buffers */ + GLframebuffer *gl_buffer; /* Depth, stencil, accum, etc buffers */ + + const struct pixel_format* pixel_format; + HDC Hdc; + + /* Current width/height */ + GLuint width; GLuint height; + + /* BackBuffer, if any */ + BYTE* BackBuffer; }; struct sw_context { - struct gl_context mesa; /* Base class - this must be first */ + GLcontext *gl_ctx; /* The core GL/Mesa context */ + /* This is to keep track of the size of the front buffer */ HHOOK hook; - /* Framebuffer currently owning the context */ - struct sw_framebuffer framebuffer; + + /* Our frame buffer*/ + struct sw_framebuffer* fb; + + /* State variables */ + union + { + struct + { + BYTE ClearColor; + BYTE CurrentColor; + } u8; + struct + { + USHORT ClearColor; + USHORT CurrentColor; + } u16; + struct + { + ULONG ClearColor; + ULONG CurrentColor; + } u24; + struct + { + ULONG ClearColor; + ULONG CurrentColor; + } u32; + }; + GLenum Mode; }; -/* mesa opengl32 "driver" specific */ -static const GLubyte * -sw_get_string( struct gl_context *ctx, GLenum name ) -{ - (void) ctx; - if(name == GL_RENDERER) - { - static const GLubyte renderer[] = { 'R','e','a','c','t','O','S',' ', - 'S','o','f','t','w','a','r','e',' ', - 'I','m','p','l','e','m','e','n','t','a','t','i','o','n',0 }; - return renderer; - } - /* Don't claim to support the fancy extensions that mesa supports, they will be slow anyway */ - if(name == GL_EXTENSIONS) - { - static const GLubyte extensions[] = { 0 }; - return extensions; - } - return NULL; -} - -static void -sw_update_state( struct gl_context *ctx, GLuint new_state ) -{ - /* easy - just propagate */ - _swrast_InvalidateState( ctx, new_state ); - _swsetup_InvalidateState( ctx, new_state ); - _tnl_InvalidateState( ctx, new_state ); - _vbo_InvalidateState( ctx, new_state ); -} - -/* Renderbuffer routines */ -static GLboolean -sw_bb_renderbuffer_storage(struct gl_context* ctx, struct gl_renderbuffer *rb, - GLenum internalFormat, - GLuint width, GLuint height) -{ - struct swrast_renderbuffer *srb = swrast_renderbuffer(rb); - struct sw_framebuffer* fb = CONTAINING_RECORD(srb, struct sw_framebuffer, backbuffer); - UINT widthBytes = WIDTH_BYTES_ALIGN32(width, pixel_formats[fb->format_index].color_bits); - srb->Base.Format = pixel_formats[fb->format_index].mesa; - - if(srb->Buffer) - srb->Buffer = HeapReAlloc(GetProcessHeap(), 0, srb->Buffer, widthBytes*height); - else - srb->Buffer = HeapAlloc(GetProcessHeap(), 0, widthBytes*height); - if(!srb->Buffer) - { - srb->Base.Format = MESA_FORMAT_NONE; - return GL_FALSE; - } - srb->Base.Width = width; - srb->Base.Height = height; - srb->RowStride = widthBytes; - return GL_TRUE; -} - -static void -sw_bb_renderbuffer_delete(struct gl_renderbuffer *rb) -{ - struct swrast_renderbuffer *srb = swrast_renderbuffer(rb); - - if (srb->Buffer) - { - HeapFree(GetProcessHeap(), 0, srb->Buffer); - srb->Buffer = NULL; - } -} - -static void -sw_fb_renderbuffer_delete(struct gl_renderbuffer *rb) -{ - struct sw_front_renderbuffer* srb = (struct sw_front_renderbuffer*)rb; - - if (srb->hbmp) - { - srb->hbmp = SelectObject(srb->hdcmem, srb->hbmp); - DeleteDC(srb->hdcmem); - DeleteObject(srb->hbmp); - srb->hdcmem = NULL; - srb->hbmp = NULL; - srb->swrast.Buffer = NULL; - } -} - -static GLboolean -sw_fb_renderbuffer_storage(struct gl_context *ctx, struct gl_renderbuffer *rb, - GLenum internalFormat, - GLuint width, GLuint height) -{ - struct sw_front_renderbuffer* srb = (struct sw_front_renderbuffer*)rb; - struct sw_framebuffer* fb = CONTAINING_RECORD(srb, struct sw_framebuffer, frontbuffer); - HDC hdc = IntGetCurrentDC(); - - /* Don't bother if the size doesn't change */ - if(rb->Width == width && rb->Height == height) - return GL_TRUE; - - /* Delete every objects which could have been used before */ - sw_fb_renderbuffer_delete(&srb->swrast.Base); - - /* So the app wants to use the frontbuffer, allocate a DIB for it */ - srb->hbmp = CreateDIBSection( - hdc, - &fb->bmi, - DIB_RGB_COLORS, - (void**)&srb->swrast.Buffer, - NULL, 0); - if(!srb->hbmp) - { - ERR("Failed to create the DIB section for the front buffer, %lu.\n", GetLastError()); - return GL_FALSE; - } - /* Create the DC and attach the DIB section to it */ - srb->hdcmem = CreateCompatibleDC(hdc); - assert(srb->hdcmem != NULL); - srb->hbmp = SelectObject(srb->hdcmem, srb->hbmp); - assert(srb->hbmp != NULL); - /* Set formats, width and height */ - srb->swrast.Base.Format = pixel_formats[fb->format_index].mesa; - srb->swrast.Base.Width = width; - srb->swrast.Base.Height = height; - return GL_TRUE; -} - -static -void -sw_init_renderbuffers(struct sw_framebuffer *fb) -{ - _mesa_init_renderbuffer(&fb->frontbuffer.swrast.Base, 0); - fb->frontbuffer.swrast.Base.ClassID = SW_FRONT_RENDERBUFFER_CLASS; - fb->frontbuffer.swrast.Base.AllocStorage = sw_fb_renderbuffer_storage; - fb->frontbuffer.swrast.Base.Delete = sw_fb_renderbuffer_delete; - fb->frontbuffer.swrast.Base.InternalFormat = GL_RGBA; - fb->frontbuffer.swrast.Base._BaseFormat = GL_RGBA; - _mesa_remove_renderbuffer(fb->gl_buffer, BUFFER_FRONT_LEFT); - _mesa_add_renderbuffer(fb->gl_buffer, BUFFER_FRONT_LEFT, &fb->frontbuffer.swrast.Base); - - if(fb->flags & SW_FB_DOUBLEBUFFERED) - { - _mesa_init_renderbuffer(&fb->backbuffer.Base, 0); - fb->backbuffer.Base.ClassID = SW_BACK_RENDERBUFFER_CLASS; - fb->backbuffer.Base.AllocStorage = sw_bb_renderbuffer_storage; - fb->backbuffer.Base.Delete = sw_bb_renderbuffer_delete; - fb->backbuffer.Base.InternalFormat = GL_RGBA; - fb->backbuffer.Base._BaseFormat = GL_RGBA; - _mesa_remove_renderbuffer(fb->gl_buffer, BUFFER_BACK_LEFT); - _mesa_add_renderbuffer(fb->gl_buffer, BUFFER_BACK_LEFT, &fb->backbuffer.Base); - } - - -} - -static void -sw_MapRenderbuffer(struct gl_context *ctx, - struct gl_renderbuffer *rb, - GLuint x, GLuint y, GLuint w, GLuint h, - GLbitfield mode, - GLubyte **mapOut, GLint *rowStrideOut) -{ - if(rb->ClassID == SW_FRONT_RENDERBUFFER_CLASS) - { - /* This is our front buffer */ - struct sw_front_renderbuffer* srb = (struct sw_front_renderbuffer*)rb; - struct sw_framebuffer* fb = CONTAINING_RECORD(srb, struct sw_framebuffer, frontbuffer); - /* Set the stride */ - *rowStrideOut = WIDTH_BYTES_ALIGN32(rb->Width, pixel_formats[fb->format_index].color_bits); - /* Remember where we "mapped" */ - srb->x = x; srb->y = y; srb->w = w; srb->h = h; - /* Remember if we should write it later */ - srb->write = !!(mode & GL_MAP_WRITE_BIT); - /* Get the bits, if needed */ - if(mode & GL_MAP_READ_BIT) - { - BitBlt(srb->hdcmem, srb->x, srb->y, srb->w, srb->h, - IntGetCurrentDC(), srb->x, srb->y, SRCCOPY); - } - /* And return it */ - *mapOut = (BYTE*)srb->swrast.Buffer + *rowStrideOut*y + x*pixel_formats[fb->format_index].color_bits/8; - return; - } - - if(rb->ClassID == SW_BACK_RENDERBUFFER_CLASS) - { - /* This is our front buffer */ - struct swrast_renderbuffer* srb = (struct swrast_renderbuffer*)rb; - const GLuint bpp = _mesa_get_format_bytes(rb->Format); - /* Set the stride */ - *rowStrideOut = srb->RowStride; - *mapOut = (BYTE*)srb->Buffer + srb->RowStride*y + x*bpp; - return; - } - - /* Let mesa rasterizer take care of this */ - _swrast_map_soft_renderbuffer(ctx, rb, x, y, w, h, mode, - mapOut, rowStrideOut); -} - -static void -sw_UnmapRenderbuffer(struct gl_context *ctx, struct gl_renderbuffer *rb) -{ - if (rb->ClassID== SW_FRONT_RENDERBUFFER_CLASS) - { - /* This is our front buffer */ - struct sw_front_renderbuffer* srb = (struct sw_front_renderbuffer*)rb; - if(srb->write) - { - /* Copy the bits to our display */ - BitBlt(IntGetCurrentDC(), - srb->x, srb->y, srb->w, srb->h, - srb->hdcmem, srb->x, srb->y, SRCCOPY); - srb->write = FALSE; - } - return; - } - - if(rb->ClassID == SW_BACK_RENDERBUFFER_CLASS) - return; /* nothing to do */ - - /* Let mesa rasterizer take care of this */ - _swrast_unmap_soft_renderbuffer(ctx, rb); -} - /* WGL <-> mesa glue */ -static UINT index_from_format(struct wgl_dc_data* dc_data, INT format, BOOL* doubleBuffered) +static const struct pixel_format* get_format(INT pf_index, INT* pf_count) { - UINT index; - INT nb_win_compat = 0, start_win_compat = 0; HDC hdc; - INT bpp; + INT bpp, nb_format; + const struct pixel_format* ret; - *doubleBuffered = FALSE; - - if(!(dc_data->flags & WGL_DC_OBJ_DC)) - return format - 1; /* OBJ_MEMDC, not double buffered */ - - hdc = GetDC(dc_data->owner.hwnd); - - /* Find the window compatible formats */ + hdc = GetDC(NULL); bpp = GetDeviceCaps(hdc, BITSPIXEL); - for(index = 0; index nb_format) || (pf_index <= 0)) \ + ret = NULL; \ + else \ + ret = &pixel_formats_##__x__[pf_index - 1]; \ + break + + HANDLE_BPP(32); + HANDLE_BPP(24); + HANDLE_BPP(16); + HANDLE_BPP(8); +#undef HANDLE_BPP + default: + FIXME("Unhandled bit depth %u, defaulting to 32bpp\n", bpp); + nb_format = ARRAYSIZE(pixel_formats_32); + if ((pf_index > nb_format) || (pf_index == 0)) + ret = NULL; + else + ret = &pixel_formats_32[pf_index - 1]; } - ReleaseDC(dc_data->owner.hwnd, hdc); - - /* Double buffered format */ - if(format < (start_win_compat + nb_win_compat)) - { - if(format >= start_win_compat) - *doubleBuffered = TRUE; - return format-1; - } - /* Shift */ - return format - nb_win_compat - 1; + + if (pf_count) + *pf_count = nb_format; + + return ret; } INT sw_DescribePixelFormat(HDC hdc, INT format, UINT size, PIXELFORMATDESCRIPTOR* descr) { - UINT index; - INT nb_win_compat = 0, start_win_compat = 0; - INT ret = sizeof(pixel_formats)/sizeof(pixel_formats[0]); + INT ret; + const struct pixel_format *pixel_format; - if (GetObjectType(hdc) == OBJ_DC) - { - /* Find the window compatible formats */ - INT bpp = GetDeviceCaps(hdc, BITSPIXEL); - for (index = 0; index < sizeof(pixel_formats)/sizeof(pixel_formats[0]); index++) - { - if (pixel_formats[index].color_bits == bpp) - { - if (!start_win_compat) - start_win_compat = index+1; - nb_win_compat++; - } - } - /* Add the double buffered formats */ - ret += nb_win_compat; - } + TRACE("Describing format %i.\n", format); - index = (UINT)format - 1; + pixel_format = get_format(format, &ret); if(!descr) return ret; if((format > ret) || (size != sizeof(*descr))) return 0; - /* Set flags */ - descr->dwFlags = PFD_SUPPORT_GDI | PFD_SUPPORT_OPENGL | PFD_DRAW_TO_BITMAP | PFD_GENERIC_FORMAT; - /* See if this is a format compatible with the window */ - if(format >= start_win_compat && format < (start_win_compat + nb_win_compat*2) ) - { - /* It is */ - descr->dwFlags |= PFD_DRAW_TO_WINDOW; - /* See if this should be double buffered */ - if(format < (start_win_compat + nb_win_compat)) - { - /* No GDI, no bitmap */ - descr->dwFlags &= ~(PFD_SUPPORT_GDI | PFD_DRAW_TO_BITMAP); - descr->dwFlags |= PFD_DOUBLEBUFFER; - } - } - /* Normalize the index */ - if(format >= start_win_compat + nb_win_compat) - index -= nb_win_compat; - - /* Fill the rest of the structure */ + /* Fill the structure */ descr->nSize = sizeof(*descr); descr->nVersion = 1; - descr->iPixelType = PFD_TYPE_RGBA; - descr->cColorBits = pixel_formats[index].color_bits; - descr->cRedBits = pixel_formats[index].red_bits; - descr->cRedShift = pixel_formats[index].red_shift; - descr->cGreenBits = pixel_formats[index].green_bits; - descr->cGreenShift = pixel_formats[index].green_shift; - descr->cBlueBits = pixel_formats[index].blue_bits; - descr->cBlueShift = pixel_formats[index].blue_shift; - descr->cAlphaBits = pixel_formats[index].alpha_bits; - descr->cAlphaShift = pixel_formats[index].alpha_shift; - descr->cAccumBits = pixel_formats[index].accum_bits; - descr->cAccumRedBits = pixel_formats[index].accum_bits / 4; - descr->cAccumGreenBits = pixel_formats[index].accum_bits / 4; - descr->cAccumBlueBits = pixel_formats[index].accum_bits / 4; - descr->cAccumAlphaBits = pixel_formats[index].accum_bits / 4; - descr->cDepthBits = pixel_formats[index].depth_bits; - descr->cStencilBits = pixel_formats[index].stencil_bits; + descr->dwFlags = pixel_format->dwFlags; + descr->iPixelType = pixel_format->iPixelType; + descr->cColorBits = pixel_format->cColorBits; + descr->cRedBits = pixel_format->cRedBits; + descr->cRedShift = pixel_format->cRedShift; + descr->cGreenBits = pixel_format->cGreenBits; + descr->cGreenShift = pixel_format->cGreenShift; + descr->cBlueBits = pixel_format->cBlueBits; + descr->cBlueShift = pixel_format->cBlueShift; + descr->cAlphaBits = pixel_format->cAlphaBits; + descr->cAlphaShift = pixel_format->cAlphaShift; + descr->cAccumBits = pixel_format->cAccumBits; + descr->cAccumRedBits = pixel_format->cAccumRedBits; + descr->cAccumGreenBits = pixel_format->cAccumGreenBits; + descr->cAccumBlueBits = pixel_format->cAccumBlueBits; + descr->cAccumAlphaBits = pixel_format->cAccumAlphaBits; + descr->cDepthBits = pixel_format->cDepthBits; + descr->cStencilBits = STENCIL_BITS; descr->cAuxBuffers = 0; descr->iLayerType = PFD_MAIN_PLANE; + descr->bReserved = 0; + descr->dwLayerMask = 0; + descr->dwVisibleMask = 0; + descr->dwDamageMask = 0; + return ret; } BOOL sw_SetPixelFormat(HDC hdc, struct wgl_dc_data* dc_data, INT format) { struct sw_framebuffer* fb; - BOOL doubleBuffered; - - assert(dc_data->sw_data == NULL); + const struct pixel_format *pixel_format; /* So, someone is crazy enough to ask for sw implementation. Announce it. */ - TRACE("OpenGL software implementation START!\n"); + TRACE("OpenGL software implementation START for hdc %p, format %i!\n", hdc, format); + pixel_format = get_format(format, NULL); + if (!pixel_format) + return FALSE; + /* allocate our structure */ - fb = HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY, FIELD_OFFSET(struct sw_framebuffer, bmi.bmiColors[3])); + fb = HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY, sizeof(*fb)); if(!fb) { ERR("HeapAlloc FAILED!\n"); return FALSE; } - /* Get the format index */ - fb->format_index = index_from_format(dc_data, format, &doubleBuffered); - TRACE("Using format %u - double buffered: %x.\n", fb->format_index, doubleBuffered); - fb->flags = doubleBuffered ? SW_FB_DOUBLEBUFFERED : 0; - /* Set the bitmap info describing the framebuffer */ - fb->bmi.bmiHeader.biSize = sizeof(BITMAPINFOHEADER); - fb->bmi.bmiHeader.biPlanes = 1; - fb->bmi.bmiHeader.biBitCount = pixel_formats[fb->format_index].color_bits; - fb->bmi.bmiHeader.biCompression = pixel_formats[fb->format_index].bmp_compression; - fb->bmi.bmiHeader.biSizeImage = 0; - fb->bmi.bmiHeader.biXPelsPerMeter = 0; - fb->bmi.bmiHeader.biYPelsPerMeter = 0; - fb->bmi.bmiHeader.biClrUsed = 0; - fb->bmi.bmiHeader.biClrImportant = 0; - *((DWORD*)&fb->bmi.bmiColors[0]) = pixel_formats[fb->format_index].red_mask; - *((DWORD*)&fb->bmi.bmiColors[1]) = pixel_formats[fb->format_index].green_mask; - *((DWORD*)&fb->bmi.bmiColors[2]) = pixel_formats[fb->format_index].blue_mask; - /* Save the HDC */ - fb->hdc = hdc; - - /* Allocate the visual structure describing the format */ - fb->gl_visual = _mesa_create_visual( - !!(fb->flags & SW_FB_DOUBLEBUFFERED), - GL_FALSE, /* No stereoscopic support */ - pixel_formats[fb->format_index].red_bits, - pixel_formats[fb->format_index].green_bits, - pixel_formats[fb->format_index].blue_bits, - pixel_formats[fb->format_index].alpha_bits, - pixel_formats[fb->format_index].depth_bits, - pixel_formats[fb->format_index].stencil_bits, - pixel_formats[fb->format_index].accum_bits, - pixel_formats[fb->format_index].accum_bits, - pixel_formats[fb->format_index].accum_bits, - pixel_formats[fb->format_index].alpha_bits ? - pixel_formats[fb->format_index].accum_bits : 0); + /* Set the format */ + fb->pixel_format = pixel_format; + + fb->gl_visual = gl_create_visual( + pixel_format->iPixelType == PFD_TYPE_RGBA, + pixel_format->cAlphaBits != 0, + (pixel_format->dwFlags & PFD_DOUBLEBUFFER) != 0, + pixel_format->cDepthBits, + STENCIL_BITS, + max(max(max(pixel_format->cAccumRedBits, pixel_format->cAccumGreenBits), pixel_format->cAccumBlueBits), pixel_format->cAccumAlphaBits), + pixel_format->iPixelType == PFD_TYPE_COLORINDEX ? pixel_format->cColorBits : 0, + ((1ul << pixel_format->cRedBits) - 1), + ((1ul << pixel_format->cGreenBits) - 1), + ((1ul << pixel_format->cBlueBits) - 1), + pixel_format->cAlphaBits != 0 ? ((1ul << pixel_format->cAlphaBits) - 1) : 255.0f, + pixel_format->cRedBits, + pixel_format->cGreenBits, + pixel_format->cBlueBits, + pixel_format->cAlphaBits); if(!fb->gl_visual) { @@ -489,25 +403,16 @@ BOOL sw_SetPixelFormat(HDC hdc, struct wgl_dc_data* dc_data, INT format) } /* Allocate the framebuffer structure */ - fb->gl_buffer = _mesa_create_framebuffer(fb->gl_visual); + fb->gl_buffer = gl_create_framebuffer(fb->gl_visual); if (!fb->gl_buffer) { ERR("Failed to allocate the mesa framebuffer structure.\n"); - _mesa_destroy_visual( fb->gl_visual ); + gl_destroy_visual( fb->gl_visual ); HeapFree(GetProcessHeap(), 0, fb); return FALSE; } - - /* Add the depth/stencil/accum buffers */ - _swrast_add_soft_renderbuffers(fb->gl_buffer, - GL_FALSE, /* color */ - fb->gl_visual->haveDepthBuffer, - fb->gl_visual->haveStencilBuffer, - fb->gl_visual->haveAccumBuffer, - GL_FALSE, /* alpha */ - GL_FALSE /* aux */ ); - - /* Initialize our render buffers */ - sw_init_renderbuffers(fb); + + /* Save our DC */ + fb->Hdc = hdc; /* Everything went fine */ dc_data->sw_data = fb; @@ -518,59 +423,25 @@ DHGLRC sw_CreateContext(struct wgl_dc_data* dc_data) { struct sw_context* sw_ctx; struct sw_framebuffer* fb = dc_data->sw_data; - struct dd_function_table mesa_drv_functions; - TNLcontext *tnl; - /* We use the mesa memory routines for this function */ - sw_ctx = CALLOC_STRUCT(sw_context); + sw_ctx = HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY, sizeof(*sw_ctx)); if(!sw_ctx) return NULL; - /* Set mesa default functions */ - _mesa_init_driver_functions(&mesa_drv_functions); - /* Override */ - mesa_drv_functions.GetString = sw_get_string; - mesa_drv_functions.UpdateState = sw_update_state; - mesa_drv_functions.GetBufferSize = NULL; - /* Initialize the context */ - if(!_mesa_initialize_context(&sw_ctx->mesa, - fb->gl_visual, - NULL, - &mesa_drv_functions, - (void *) sw_ctx)) + sw_ctx->gl_ctx = gl_create_context(fb->gl_visual, NULL, sw_ctx); + if(!sw_ctx->gl_ctx) { ERR("Failed to initialize the mesa context.\n"); - free(sw_ctx); + HeapFree(GetProcessHeap(), 0, sw_ctx); return NULL; } - /* Initialize the "meta driver" */ - _mesa_meta_init(&sw_ctx->mesa); - - /* Initialize helpers */ - if(!_swrast_CreateContext(&sw_ctx->mesa) || - !_vbo_CreateContext(&sw_ctx->mesa) || - !_tnl_CreateContext(&sw_ctx->mesa) || - !_swsetup_CreateContext(&sw_ctx->mesa)) - { - ERR("Failed initializing helpers.\n"); - _mesa_free_context_data(&sw_ctx->mesa); - free(sw_ctx); - return NULL; - } - - /* Wake up! */ - _swsetup_Wakeup(&sw_ctx->mesa); - - /* Use TnL defaults */ - tnl = TNL_CONTEXT(&sw_ctx->mesa); - tnl->Driver.RunPipeline = _tnl_run_pipeline; - - /* To map the display into user memory */ - sw_ctx->mesa.Driver.MapRenderbuffer = sw_MapRenderbuffer; - sw_ctx->mesa.Driver.UnmapRenderbuffer = sw_UnmapRenderbuffer; - + sw_ctx->fb = fb; + + /* Choose relevant default */ + sw_ctx->Mode = fb->gl_visual->DBflag ? GL_BACK : GL_FRONT; + return (DHGLRC)sw_ctx; } @@ -582,15 +453,9 @@ BOOL sw_DeleteContext(DHGLRC dhglrc) const GLDISPATCHTABLE* table_save = IntGetCurrentDispatchTable(); /* Destroy everything */ - _mesa_meta_free( &sw_ctx->mesa ); + gl_destroy_context(sw_ctx->gl_ctx); - _swsetup_DestroyContext( &sw_ctx->mesa ); - _tnl_DestroyContext( &sw_ctx->mesa ); - _vbo_DestroyContext( &sw_ctx->mesa ); - _swrast_DestroyContext( &sw_ctx->mesa ); - - _mesa_free_context_data( &sw_ctx->mesa ); - free( sw_ctx ); + HeapFree(GetProcessHeap(), 0, sw_ctx); /* Restore this */ IntSetCurrentDispatchTable(table_save); @@ -599,9 +464,33 @@ BOOL sw_DeleteContext(DHGLRC dhglrc) return TRUE; } +extern void APIENTRY _mesa_ColorTableEXT(GLenum, GLenum, GLsizei, GLenum, GLenum, const void*); +extern void APIENTRY _mesa_ColorSubTableEXT(GLenum, GLsizei, GLsizei, GLenum, GLenum, const void*); +extern void APIENTRY _mesa_GetColorTableEXT(GLenum, GLenum, GLenum, void*); +extern void APIENTRY _mesa_GetColorTableParameterivEXT(GLenum, GLenum, GLfloat*); +extern void APIENTRY _mesa_GetColorTableParameterfvEXT(GLenum, GLenum, GLint*); + +static void APIENTRY _swimpl_AddSwapHintRectWIN(GLint x, GLint y, GLsizei width, GLsizei height) +{ + UNIMPLEMENTED; +} + PROC sw_GetProcAddress(LPCSTR name) { - /* We don't support any extensions */ + /* GL_EXT_paletted_texture */ + if (strcmp(name, "glColorTableEXT") == 0) + return (PROC)_mesa_ColorTableEXT; + if (strcmp(name, "glColorSubTableEXT") == 0) + return (PROC)_mesa_ColorSubTableEXT; + if (strcmp(name, "glColorGetTableEXT") == 0) + return (PROC)_mesa_GetColorTableEXT; + if (strcmp(name, "glGetColorTableParameterivEXT") == 0) + return (PROC)_mesa_GetColorTableParameterivEXT; + if (strcmp(name, "glGetColorTableParameterfvEXT") == 0) + return (PROC)_mesa_GetColorTableParameterfvEXT; + if (strcmp(name, "glAddSwapHintRectWIN") == 0) + return (PROC)_swimpl_AddSwapHintRectWIN; + WARN("Asking for proc address %s, returning NULL.\n", name); return NULL; } @@ -614,18 +503,20 @@ BOOL sw_CopyContext(DHGLRC dhglrcSrc, DHGLRC dhglrcDst, UINT mask) BOOL sw_ShareLists(DHGLRC dhglrcSrc, DHGLRC dhglrcDst) { +#if 0 struct sw_context* sw_ctx_src = (struct sw_context*)dhglrcSrc; struct sw_context* sw_ctx_dst = (struct sw_context*)dhglrcDst; /* See if it was already shared */ - if(sw_ctx_dst->mesa.Shared->RefCount > 1) + if(sw_ctx_dst->gl_ctx->Shared->RefCount > 1) return FALSE; - + /* Unreference the old, share the new */ - _mesa_reference_shared_state(&sw_ctx_dst->mesa, - &sw_ctx_dst->mesa.Shared, - sw_ctx_src->mesa.Shared); - + gl_reference_shared_state(sw_ctx_dst->gl_ctx, + &sw_ctx_dst->gl_ctx->Shared, + sw_ctx_src->gl_ctx->Shared); +#endif + FIXME("Unimplemented!\n"); return TRUE; } @@ -638,7 +529,6 @@ sw_call_window_proc( { struct wgl_dc_data* dc_data = IntGetCurrentDcData(); struct sw_context* ctx = (struct sw_context*)IntGetCurrentDHGLRC(); - struct sw_framebuffer* fb; PCWPSTRUCT pParams = (PCWPSTRUCT)lParam; if((!dc_data) || (!ctx)) @@ -649,8 +539,6 @@ sw_call_window_proc( if((nCode < 0) || (dc_data->owner.hwnd != pParams->hwnd) || (dc_data->sw_data == NULL)) return CallNextHookEx(ctx->hook, nCode, wParam, lParam); - - fb = dc_data->sw_data; if (pParams->message == WM_WINDOWPOSCHANGED) { @@ -676,11 +564,8 @@ sw_call_window_proc( /* Do not reallocate for minimized windows */ if(width <= 0 || height <= 0) goto end; - /* Update framebuffer size */ - fb->bmi.bmiHeader.biWidth = width; - fb->bmi.bmiHeader.biHeight = height; /* Propagate to mesa */ - _mesa_resize_framebuffer(&ctx->mesa, fb->gl_buffer, width, height); + gl_ResizeBuffersMESA(ctx->gl_ctx); } } @@ -688,15 +573,865 @@ end: return CallNextHookEx(ctx->hook, nCode, wParam, lParam); } +static const char* renderer_string(void) +{ + return "ReactOS SW Implementation"; +} + +static inline void PUT_PIXEL_8(BYTE* Buffer, BYTE Value) +{ + *Buffer = Value; +} +static inline void PUT_PIXEL_16(USHORT* Buffer, USHORT Value) +{ + *Buffer = Value; +} +static inline void PUT_PIXEL_24(ULONG* Buffer, ULONG Value) +{ + *Buffer &= 0xFF000000ul; + *Buffer |= Value & 0x00FFFFFF; +} +static inline void PUT_PIXEL_32(ULONG* Buffer, ULONG Value) +{ + *Buffer = Value; +} + +static inline BYTE GET_PIXEL_8(BYTE* Buffer) +{ + return *Buffer; +} + +static inline USHORT GET_PIXEL_16(USHORT* Buffer) +{ + return *Buffer; +} + +static inline ULONG GET_PIXEL_24(ULONG* Buffer) +{ + return *Buffer & 0x00FFFFFF; +} + +static inline ULONG GET_PIXEL_32(ULONG* Buffer) +{ + return *Buffer; +} + +static inline COLORREF MAKE_COLORREF_8(const struct pixel_format *format, BYTE Color) +{ + BYTE R,G,B; + + if (format->iPixelType == PFD_TYPE_COLORINDEX) + return PALETTEINDEX(Color); + + R = (Color & 0x7) << 5; + G = (Color & 0x38) << 2; + B = Color & 0xC; + + return RGB(R, G, B); +} + +static inline COLORREF MAKE_COLORREF_16(const struct pixel_format *format, USHORT Color) +{ + BYTE R,G,B; + + if (format->iPixelType == PFD_TYPE_COLORINDEX) + return PALETTEINDEX(Color); + + R = (Color & 0x7) << 5; + G = (Color & 0x38) << 2; + B = Color & 0xC; + + return RGB(R, G, B); +} + +static inline COLORREF MAKE_COLORREF_24(const struct pixel_format *format, ULONG Color) +{ + BYTE R,G,B; + + if (format->iPixelType == PFD_TYPE_COLORINDEX) + return PALETTEINDEX(Color); + + R = (Color & 0xFF0000) >> 16; + G = (Color & 0x00FF00) >> 8; + B = Color & 0xFF; + + return RGB(R, G, B); +} + +static inline COLORREF MAKE_COLORREF_32(const struct pixel_format *format, ULONG Color) +{ + BYTE R,G,B; + + if (format->iPixelType == PFD_TYPE_COLORINDEX) + return PALETTEINDEX(Color); + + R = (Color & 0xFF0000) >> 16; + G = (Color & 0x00FF00) >> 8; + B = Color & 0xFF; + + return RGB(R, G, B); +} + + +static inline BYTE PACK_COLOR_8(GLubyte r, GLubyte g, GLubyte b) +{ + return (r & 0x7) | ((g & 0x7) << 3) | ((b & 0x3) << 6); +} + +static inline USHORT PACK_COLOR_16(GLubyte r, GLubyte g, GLubyte b) +{ + return ((r & 0x1F) << 11) | ((g & 0x3F) << 5) | (b & 0x1F); +} + +static inline ULONG PACK_COLOR_24(GLubyte r, GLubyte g, GLubyte b) +{ + return (r << 16) | (g << 8) | (b); +} + +static inline ULONG PACK_COLOR_32(GLubyte r, GLubyte g, GLubyte b) +{ + return (r << 16) | (g << 8) | (b); +} + +static inline COLORREF PACK_COLORREF_8(GLubyte r, GLubyte g, GLubyte b) +{ + return RGB(r << 5, g << 5, b << 6); +} + +static inline COLORREF PACK_COLORREF_16(GLubyte r, GLubyte g, GLubyte b) +{ + return RGB(r << 3, g << 2, b << 3); +} + +static inline COLORREF PACK_COLORREF_24(GLubyte r, GLubyte g, GLubyte b) +{ + return RGB(r, g, b); +} + +static inline COLORREF PACK_COLORREF_32(GLubyte r, GLubyte g, GLubyte b) +{ + return RGB(r, g, b); +} + +static inline void UNPACK_COLOR_8(BYTE Color, GLubyte* r, GLubyte* g, GLubyte* b) +{ + *r = Color & 0x7; + *g = (Color >> 3) & 0x7; + *b = (Color >> 6) & 0x3; +} + +static inline void UNPACK_COLOR_16(USHORT Color, GLubyte* r, GLubyte* g, GLubyte* b) +{ + *r = (Color >> 11) & 0x1F; + *g = (Color >> 5) & 0x3F; + *b = Color & 0x1F; +} + +static inline void UNPACK_COLOR_24(ULONG Color, GLubyte* r, GLubyte* g, GLubyte* b) +{ + *r = (Color >> 16) & 0xFF; + *g = (Color >> 8) & 0xFF; + *b = Color & 0xFF; +} + +static inline void UNPACK_COLOR_32(ULONG Color, GLubyte* r, GLubyte* g, GLubyte* b) +{ + *r = (Color >> 16) & 0xFF; + *g = (Color >> 8) & 0xFF; + *b = Color & 0xFF; +} + +static inline void UNPACK_COLORREF_8(COLORREF Color, GLubyte* r, GLubyte* g, GLubyte* b) +{ + *r = GetRValue(Color) >> 5; + *g = GetGValue(Color) >> 5; + *b = GetBValue(Color) >> 6; +} + +static inline void UNPACK_COLORREF_16(COLORREF Color, GLubyte* r, GLubyte* g, GLubyte* b) +{ + *r = GetRValue(Color) >> 3; + *g = GetGValue(Color) >> 2; + *b = GetBValue(Color) >> 3; +} + +static inline void UNPACK_COLORREF_24(COLORREF Color, GLubyte* r, GLubyte* g, GLubyte* b) +{ + *r = GetRValue(Color); + *g = GetGValue(Color); + *b = GetBValue(Color); +} + +static inline void UNPACK_COLORREF_32(COLORREF Color, GLubyte* r, GLubyte* g, GLubyte* b) +{ + *r = GetRValue(Color); + *g = GetGValue(Color); + *b = GetBValue(Color); +} + +/* +* Set the color index used to clear the color buffer. +*/ +#define CLEAR_INDEX(__bpp, __type) \ +static void clear_index_##__bpp(GLcontext* ctx, GLuint index) \ +{ \ + struct sw_context* sw_ctx = ctx->DriverCtx; \ + \ + sw_ctx->u##__bpp.ClearColor = (__type)index; \ +} +CLEAR_INDEX(8, BYTE) +CLEAR_INDEX(16, USHORT) +CLEAR_INDEX(24, ULONG) +CLEAR_INDEX(32, ULONG) +#undef CLEAR_INDEX + +/* +* Set the color used to clear the color buffer. +*/ +#define CLEAR_COLOR(__bpp) \ +static void clear_color_##__bpp( GLcontext* ctx, GLubyte r, GLubyte g, GLubyte b, GLubyte a ) \ +{ \ + struct sw_context* sw_ctx = ctx->DriverCtx; \ + \ + sw_ctx->u##__bpp.ClearColor = PACK_COLOR_##__bpp(r, g, b); \ + \ + TRACE("Set Clear color %u, %u, %u.\n", r, g, b); \ +} +CLEAR_COLOR(8) +CLEAR_COLOR(16) +CLEAR_COLOR(24) +CLEAR_COLOR(32) +#undef CLEAR_COLOR + +/* + * Clear the specified region of the color buffer using the clear color + * or index as specified by one of the two functions above. + */ +static void clear_frontbuffer( + struct sw_context* sw_ctx, + struct sw_framebuffer* fb, + GLint x, + GLint y, + GLint width, + GLint height, + COLORREF ClearColor) +{ + HBRUSH Brush; + BOOL ret; + + TRACE("Clearing front buffer (%u, %u, %u, %u), color 0x%08x.\n", x, y, width, height, ClearColor); + + Brush = CreateSolidBrush(ClearColor); + Brush = SelectObject(fb->Hdc, Brush); + + ret = PatBlt(fb->Hdc, x, fb->height - (y + height), width, height, PATCOPY); + if (!ret) + { + ERR("PatBlt failed. last Error %d.\n", GetLastError()); + } + + Brush = SelectObject(fb->Hdc, Brush); + DeleteObject(Brush); +} + +#define CLEAR(__bpp, __type, __pixel_size) \ +static void clear_##__bpp(GLcontext* ctx, GLboolean all,GLint x, GLint y, GLint width, GLint height)\ +{ \ + struct sw_context* sw_ctx = ctx->DriverCtx; \ + struct sw_framebuffer* fb = sw_ctx->fb; \ + BYTE* ScanLine; \ + \ + if (all) \ + { \ + x = y = 0; \ + width = fb->width; \ + height = fb->height; \ + } \ + \ + if (sw_ctx->Mode == GL_FRONT) \ + { \ + clear_frontbuffer(sw_ctx, fb, x, y, width, height, \ + MAKE_COLORREF_##__bpp(fb->pixel_format, sw_ctx->u##__bpp.ClearColor)); \ + return; \ + } \ + \ + ScanLine = fb->BackBuffer + y * WIDTH_BYTES_ALIGN32(fb->width, __bpp); \ + while (height--) \ + { \ + BYTE* Buffer = ScanLine + x * __pixel_size; \ + UINT n = width; \ + \ + while (n--) \ + { \ + PUT_PIXEL_##__bpp((__type*)Buffer, sw_ctx->u##__bpp.ClearColor); \ + Buffer += __pixel_size; \ + } \ + \ + ScanLine += WIDTH_BYTES_ALIGN32(fb->width, __bpp); \ + } \ +} +CLEAR(8, BYTE, 1) +CLEAR(16, USHORT, 2) +CLEAR(24, ULONG, 3) +CLEAR(32, ULONG, 4) +#undef CLEAR + +/* Set the current color index. */ +#define SET_INDEX(__bpp) \ +static void set_index_##__bpp(GLcontext* ctx, GLuint index) \ +{ \ + struct sw_context* sw_ctx = ctx->DriverCtx; \ + \ + sw_ctx->u##__bpp.CurrentColor = index; \ +} +SET_INDEX(8) +SET_INDEX(16) +SET_INDEX(24) +SET_INDEX(32) +#undef SET_INDEX + +/* Set the current RGBA color. */ +#define SET_COLOR(__bpp) \ +static void set_color_##__bpp( GLcontext* ctx, GLubyte r, GLubyte g, GLubyte b, GLubyte a ) \ +{ \ + struct sw_context* sw_ctx = ctx->DriverCtx; \ + \ + sw_ctx->u##__bpp.CurrentColor = PACK_COLOR_##__bpp(r, g, b); \ +} +SET_COLOR(8) +SET_COLOR(16) +SET_COLOR(24) +SET_COLOR(32) +#undef SET_COLOR + +/* + * Selects either the front or back color buffer for reading and writing. + * mode is either GL_FRONT or GL_BACK. + */ +static GLboolean set_buffer( GLcontext* ctx, GLenum mode ) +{ + struct sw_context* sw_ctx = ctx->DriverCtx; + struct sw_framebuffer* fb = sw_ctx->fb; + + if (!fb->gl_visual->DBflag) + return GL_FALSE; + + if ((mode != GL_FRONT) && (mode != GL_BACK)) + return GL_FALSE; + + sw_ctx->Mode = mode; + return GL_TRUE; +} + +/* Return characteristics of the output buffer. */ +static void buffer_size(GLcontext* ctx, GLuint *width, GLuint *height) +{ + struct sw_context* sw_ctx = ctx->DriverCtx; + struct sw_framebuffer* fb = sw_ctx->fb; + HWND Window = WindowFromDC(fb->Hdc); + + if (Window) + { + RECT client_rect; + GetClientRect(Window, &client_rect); + *width = client_rect.right - client_rect.left; + *height = client_rect.bottom - client_rect.top; + } + else + { + /* We are drawing to a bitmap */ + BITMAP bm; + HBITMAP Hbm; + + Hbm = GetCurrentObject(fb->Hdc, OBJ_BITMAP); + + if (!GetObjectW(Hbm, sizeof(bm), &bm)) + return; + + TRACE("Framebuffer size : %i, %i\n", bm.bmWidth, bm.bmHeight); + + *width = bm.bmWidth; + *height = bm.bmHeight; + } + + if ((*width != fb->width) || (*height != fb->height)) + { + const struct pixel_format* pixel_format = fb->pixel_format; + + if (pixel_format->dwFlags & PFD_DOUBLEBUFFER) + { + /* Allocate a new backbuffer */ + size_t BufferSize = *height * WIDTH_BYTES_ALIGN32(*width, pixel_format->cColorBits); + if (!fb->BackBuffer) + { + fb->BackBuffer = HeapAlloc(GetProcessHeap(), 0, BufferSize); + } + else + { + fb->BackBuffer = HeapReAlloc(GetProcessHeap(), 0, fb->BackBuffer, BufferSize); + } + if (!fb->BackBuffer) + { + ERR("Failed allocating back buffer !.\n"); + return; + } + } + + fb->width = *width; + fb->height = *height; + } +} + +/* Write a horizontal span of color pixels with a boolean mask. */ +#define WRITE_COLOR_SPAN_FRONTBUFFER(__bpp) \ +static void write_color_span_frontbuffer_##__bpp(struct sw_framebuffer* fb, \ + GLuint n, GLint x, GLint y, \ + const GLubyte red[], const GLubyte green[], \ + const GLubyte blue[], const GLubyte mask[] ) \ +{ \ + TRACE("Writing color span at %u, %u (%u)\n", x, y, n); \ + \ + if (mask) \ + { \ + while (n--) \ + { \ + if (mask[n]) \ + { \ + SetPixel(fb->Hdc, x + n, fb->height - y, \ + PACK_COLORREF_##__bpp(red[n], green[n], blue[n])); \ + } \ + } \ + } \ + else \ + { \ + while (n--) \ + { \ + SetPixel(fb->Hdc, x + n, fb->height - y, \ + PACK_COLORREF_##__bpp(red[n], green[n], blue[n])); \ + } \ + } \ +} +WRITE_COLOR_SPAN_FRONTBUFFER(8) +WRITE_COLOR_SPAN_FRONTBUFFER(16) +WRITE_COLOR_SPAN_FRONTBUFFER(24) +WRITE_COLOR_SPAN_FRONTBUFFER(32) +#undef WRITE_COLOR_SPAN_FRONTBUFFER + +#define WRITE_COLOR_SPAN(__bpp, __type, __pixel_size) \ +static void write_color_span_##__bpp(GLcontext* ctx, \ + GLuint n, GLint x, GLint y, \ + const GLubyte red[], const GLubyte green[], \ + const GLubyte blue[], const GLubyte alpha[], \ + const GLubyte mask[] ) \ +{ \ + struct sw_context* sw_ctx = ctx->DriverCtx; \ + struct sw_framebuffer* fb = sw_ctx->fb; \ + BYTE* Buffer; \ + \ + if (sw_ctx->Mode == GL_FRONT) \ + { \ + write_color_span_frontbuffer_##__bpp(fb, n, x, y, red, green, blue, mask); \ + return; \ + } \ + \ + Buffer = fb->BackBuffer + y * WIDTH_BYTES_ALIGN32(fb->width, __bpp) \ + + (x + n) * __pixel_size; \ + if (mask) \ + { \ + while (n--) \ + { \ + Buffer -= __pixel_size; \ + if (mask[n]) \ + { \ + PUT_PIXEL_##__bpp((__type*)Buffer, \ + PACK_COLOR_##__bpp(red[n], green[n], blue[n])); \ + } \ + } \ + } \ + else \ + { \ + while (n--) \ + { \ + Buffer -= __pixel_size; \ + PUT_PIXEL_##__bpp((__type*)Buffer, \ + PACK_COLOR_##__bpp(red[n], green[n], blue[n])); \ + } \ + } \ +} +WRITE_COLOR_SPAN(8, BYTE, 1) +WRITE_COLOR_SPAN(16, USHORT, 2) +WRITE_COLOR_SPAN(24, ULONG, 3) +WRITE_COLOR_SPAN(32, ULONG, 4) +#undef WRITE_COLOR_SPAN + +static void write_monocolor_span_frontbuffer(struct sw_framebuffer* fb, GLuint n, GLint x, GLint y, + const GLubyte mask[], COLORREF Color) +{ + TRACE("Writing monocolor span at %u %u (%u), Color 0x%08x", x, y, n, Color); + + if (mask) + { + while (n--) + { + if (mask[n]) + SetPixel(fb->Hdc, x + n, y, Color); + } + } + else + { + HBRUSH Brush = CreateSolidBrush(Color); + Brush = SelectObject(fb->Hdc, Brush); + + PatBlt(fb->Hdc, x, fb->height - y, n, 1, PATCOPY); + + Brush = SelectObject(fb->Hdc, Brush); + DeleteObject(Brush); + } +} + +#define WRITE_MONOCOLOR_SPAN(__bpp, __type, __pixel_size) \ +static void write_monocolor_span_##__bpp(GLcontext* ctx, \ + GLuint n, GLint x, GLint y, \ + const GLubyte mask[]) \ +{ \ + struct sw_context* sw_ctx = ctx->DriverCtx; \ + struct sw_framebuffer* fb = sw_ctx->fb; \ + BYTE* Buffer; \ + \ + if (sw_ctx->Mode == GL_FRONT) \ + { \ + write_monocolor_span_frontbuffer(fb, n, x, y, mask, \ + MAKE_COLORREF_##__bpp(fb->pixel_format, sw_ctx->u##__bpp.CurrentColor)); \ + return; \ + } \ + \ + Buffer = fb->BackBuffer + y * WIDTH_BYTES_ALIGN32(fb->width, __bpp) + (x + n) * __pixel_size; \ + if (mask) \ + { \ + while (n--) \ + { \ + Buffer -= __pixel_size; \ + if (mask[n]) \ + PUT_PIXEL_##__bpp((__type*)Buffer, sw_ctx->u##__bpp.CurrentColor); \ + } \ + } \ + else \ + { \ + while(n--) \ + { \ + Buffer -= __pixel_size; \ + PUT_PIXEL_##__bpp((__type*)Buffer, sw_ctx->u##__bpp.CurrentColor); \ + } \ + } \ +} +WRITE_MONOCOLOR_SPAN(8, BYTE, 1) +WRITE_MONOCOLOR_SPAN(16, USHORT, 2) +WRITE_MONOCOLOR_SPAN(24, ULONG, 3) +WRITE_MONOCOLOR_SPAN(32, ULONG, 4) +#undef WRITE_MONOCOLOR_SPAN + +/* Write an array of pixels with a boolean mask. */ +#define WRITE_COLOR_PIXELS(__bpp, __type, __pixel_size) \ +static void write_color_pixels_##__bpp(GLcontext* ctx, \ + GLuint n, const GLint x[], const GLint y[], \ + const GLubyte r[], const GLubyte g[], \ + const GLubyte b[], const GLubyte a[], \ + const GLubyte mask[]) \ +{ \ + struct sw_context* sw_ctx = ctx->DriverCtx; \ + struct sw_framebuffer* fb = sw_ctx->fb; \ + \ + TRACE("Writing color pixels\n"); \ + \ + if (sw_ctx->Mode == GL_FRONT) \ + { \ + while (n--) \ + { \ + if (mask[n]) \ + { \ + TRACE("Setting pixel %u, %u to 0x%08x.\n", x[n], fb->height - y[n], \ + PACK_COLORREF_##__bpp(r[n], g[n], b[n])); \ + SetPixel(fb->Hdc, x[n], fb->height - y[n], \ + PACK_COLORREF_##__bpp(r[n], g[n], b[n])); \ + } \ + } \ + \ + return; \ + } \ + \ + while (n--) \ + { \ + if (mask[n]) \ + { \ + BYTE* Buffer = fb->BackBuffer + y[n] * WIDTH_BYTES_ALIGN32(fb->width, __bpp) \ + + x[n] * __pixel_size; \ + PUT_PIXEL_##__bpp((__type*)Buffer, PACK_COLOR_##__bpp(r[n], g[n], b[n])); \ + } \ + } \ +} +WRITE_COLOR_PIXELS(8, BYTE, 1) +WRITE_COLOR_PIXELS(16, USHORT, 2) +WRITE_COLOR_PIXELS(24, ULONG, 3) +WRITE_COLOR_PIXELS(32, ULONG, 4) +#undef WRITE_COLOR_PIXELS + +static void write_monocolor_pixels_frontbuffer( + struct sw_framebuffer* fb, GLuint n, + const GLint x[], const GLint y[], + const GLubyte mask[], COLORREF Color) +{ + TRACE("Writing monocolor pixels to front buffer.\n"); + + while (n--) + { + if (mask[n]) + { + SetPixel(fb->Hdc, x[n], fb->height - y[n], Color); + } + } +} + +/* +* Write an array of pixels with a boolean mask. The current color +* is used for all pixels. +*/ +#define WRITE_MONOCOLOR_PIXELS(__bpp, __type, __pixel_size) \ +static void write_monocolor_pixels_##__bpp(GLcontext* ctx, GLuint n, \ + const GLint x[], const GLint y[], \ + const GLubyte mask[] ) \ +{ \ + struct sw_context* sw_ctx = ctx->DriverCtx; \ + struct sw_framebuffer* fb = sw_ctx->fb; \ + \ + if (sw_ctx->Mode == GL_FRONT) \ + { \ + write_monocolor_pixels_frontbuffer(fb, n, x, y, mask, \ + MAKE_COLORREF_##__bpp(fb->pixel_format, sw_ctx->u##__bpp.CurrentColor)); \ + \ + return; \ + } \ + \ + while (n--) \ + { \ + if (mask[n]) \ + { \ + BYTE* Buffer = fb->BackBuffer + y[n] * WIDTH_BYTES_ALIGN32(fb->width, 32) \ + + x[n] * __pixel_size; \ + PUT_PIXEL_##__bpp((__type*)Buffer, sw_ctx->u##__bpp.CurrentColor); \ + } \ + } \ +} +WRITE_MONOCOLOR_PIXELS(8, BYTE, 1) +WRITE_MONOCOLOR_PIXELS(16, USHORT, 2) +WRITE_MONOCOLOR_PIXELS(24, ULONG, 3) +WRITE_MONOCOLOR_PIXELS(32, ULONG, 4) +#undef WRITE_MONOCOLOR_PIXELS + +/* Write a horizontal span of color pixels with a boolean mask. */ +static void write_index_span( GLcontext* ctx, + GLuint n, GLint x, GLint y, + const GLuint index[], + const GLubyte mask[] ) +{ + ERR("Not implemented yet !\n"); +} + +/* Write an array of pixels with a boolean mask. */ +static void write_index_pixels( GLcontext* ctx, + GLuint n, const GLint x[], const GLint y[], + const GLuint index[], const GLubyte mask[] ) +{ + ERR("Not implemented yet !\n"); +} + +/* Read a horizontal span of color-index pixels. */ +static void read_index_span( GLcontext* ctx, GLuint n, GLint x, GLint y, GLuint index[]) +{ + ERR("Not implemented yet !\n"); +} + +/* Read a horizontal span of color pixels. */ +#define READ_COLOR_SPAN(__bpp, __type, __pixel_size) \ +static void read_color_span_##__bpp(GLcontext* ctx, \ + GLuint n, GLint x, GLint y, \ + GLubyte red[], GLubyte green[], \ + GLubyte blue[], GLubyte alpha[] ) \ +{ \ + struct sw_context* sw_ctx = ctx->DriverCtx; \ + struct sw_framebuffer* fb = sw_ctx->fb; \ + BYTE* Buffer; \ + \ + if (sw_ctx->Mode == GL_FRONT) \ + { \ + COLORREF Color; \ + while (n--) \ + { \ + Color = GetPixel(fb->Hdc, x + n, fb->height - y); \ + UNPACK_COLORREF_##__bpp(Color, &red[n], &green[n], &blue[n]); \ + alpha[n] = 0; \ + } \ + \ + return; \ + } \ + \ + Buffer = fb->BackBuffer + y * WIDTH_BYTES_ALIGN32(fb->width, __bpp) \ + + (x + n) * __pixel_size; \ + while (n--) \ + { \ + Buffer -= __pixel_size; \ + UNPACK_COLOR_##__bpp(GET_PIXEL_##__bpp((__type*)Buffer), \ + &blue[n], &green[n], &red[n]); \ + alpha[n] = 0; \ + } \ +} +READ_COLOR_SPAN(8, BYTE, 1) +READ_COLOR_SPAN(16, USHORT, 2) +READ_COLOR_SPAN(24, ULONG, 3) +READ_COLOR_SPAN(32, ULONG, 4) +#undef READ_COLOR_SPAN + +/* Read an array of color index pixels. */ +static void read_index_pixels(GLcontext* ctx, + GLuint n, const GLint x[], const GLint y[], + GLuint index[], const GLubyte mask[]) +{ + + ERR("Not implemented yet !\n"); +} + +/* Read an array of color pixels. */ +#define READ_COLOR_PIXELS(__bpp, __type, __pixel_size) \ +static void read_color_pixels_##__bpp(GLcontext* ctx, \ + GLuint n, const GLint x[], const GLint y[], \ + GLubyte red[], GLubyte green[], \ + GLubyte blue[], GLubyte alpha[], \ + const GLubyte mask[] ) \ +{ \ + struct sw_context* sw_ctx = ctx->DriverCtx; \ + struct sw_framebuffer* fb = sw_ctx->fb; \ + \ + if (sw_ctx->Mode == GL_FRONT) \ + { \ + COLORREF Color; \ + while (n--) \ + { \ + if (mask[n]) \ + { \ + Color = GetPixel(fb->Hdc, x[n], fb->height - y[n]); \ + UNPACK_COLORREF_##__bpp(Color, &red[n], &green[n], &blue[n]); \ + alpha[n] = 0; \ + } \ + } \ + \ + return; \ + } \ + \ + while (n--) \ + { \ + if (mask[n]) \ + { \ + BYTE *Buffer = fb->BackBuffer + y[n] * WIDTH_BYTES_ALIGN32(fb->width, __bpp) \ + + x[n] * __pixel_size; \ + UNPACK_COLOR_##__bpp(GET_PIXEL_##__bpp((__type*)Buffer), \ + &blue[n], &green[n], &red[n]); \ + alpha[n] = 0; \ + } \ + } \ +} +READ_COLOR_PIXELS(8, BYTE, 1) +READ_COLOR_PIXELS(16, USHORT, 2) +READ_COLOR_PIXELS(24, ULONG, 3) +READ_COLOR_PIXELS(32, ULONG, 4) +#undef READ_COLOR_PIXELS + +static void setup_DD_pointers( GLcontext* ctx ) +{ + struct sw_context* sw_ctx = ctx->DriverCtx; + + ctx->Driver.RendererString = renderer_string; + ctx->Driver.UpdateState = setup_DD_pointers; + + switch (sw_ctx->fb->pixel_format->cColorBits) + { +#define HANDLE_BPP(__bpp) \ + case __bpp: \ + ctx->Driver.ClearIndex = clear_index_##__bpp; \ + ctx->Driver.ClearColor = clear_color_##__bpp; \ + ctx->Driver.Clear = clear_##__bpp; \ + ctx->Driver.Index = set_index_##__bpp; \ + ctx->Driver.Color = set_color_##__bpp; \ + ctx->Driver.WriteColorSpan = write_color_span_##__bpp; \ + ctx->Driver.WriteMonocolorSpan = write_monocolor_span_##__bpp; \ + ctx->Driver.WriteMonoindexSpan = write_monocolor_span_##__bpp; \ + ctx->Driver.WriteColorPixels = write_color_pixels_##__bpp; \ + ctx->Driver.WriteMonocolorPixels = write_monocolor_pixels_##__bpp; \ + ctx->Driver.WriteMonoindexPixels = write_monocolor_pixels_##__bpp; \ + ctx->Driver.ReadColorSpan = read_color_span_##__bpp; \ + ctx->Driver.ReadColorPixels = read_color_pixels_##__bpp; \ + break +HANDLE_BPP(8); +HANDLE_BPP(16); +HANDLE_BPP(24); +HANDLE_BPP(32); +#undef HANDLE_BPP + default: + ERR("Unhandled bit depth %u, defaulting to 32bpp.\n", sw_ctx->fb->pixel_format->cColorBits); + ctx->Driver.ClearIndex = clear_index_32; + ctx->Driver.ClearColor = clear_color_32; + ctx->Driver.Clear = clear_32; + ctx->Driver.Index = set_index_32; + ctx->Driver.Color = set_color_32; + ctx->Driver.WriteColorSpan = write_color_span_32; + ctx->Driver.WriteMonocolorSpan = write_monocolor_span_32; + ctx->Driver.WriteMonoindexSpan = write_monocolor_span_32; + ctx->Driver.WriteColorPixels = write_color_pixels_32; + ctx->Driver.WriteMonocolorPixels = write_monocolor_pixels_32; + ctx->Driver.WriteMonoindexPixels = write_monocolor_pixels_32; + ctx->Driver.ReadColorSpan = read_color_span_32; + ctx->Driver.ReadColorPixels = read_color_pixels_32; + break; + } + + ctx->Driver.SetBuffer = set_buffer; + ctx->Driver.GetBufferSize = buffer_size; + + /* Pixel/span writing functions: */ + ctx->Driver.WriteIndexSpan = write_index_span; + ctx->Driver.WriteIndexPixels = write_index_pixels; + + /* Pixel/span reading functions: */ + ctx->Driver.ReadIndexSpan = read_index_span; + ctx->Driver.ReadIndexPixels = read_index_pixels; +} + +/* Declare API table */ +#define USE_GL_FUNC(name, proto_args, call_args, offset, stack) extern void WINAPI _mesa_##name proto_args ; +#define USE_GL_FUNC_RET(name, ret_type, proto_args, call_args, offset, stack) extern ret_type WINAPI _mesa_##name proto_args ; +#include "glfuncs.h" + +static GLCLTPROCTABLE sw_api_table = +{ + OPENGL_VERSION_110_ENTRIES, + { +#define USE_GL_FUNC(name, proto_args, call_args, offset, stack) _mesa_##name, +#include "glfuncs.h" + } +}; + +/* Glue code */ +GLcontext* gl_get_thread_context(void) +{ + struct sw_context* sw_ctx = (struct sw_context*)IntGetCurrentDHGLRC(); + return sw_ctx->gl_ctx; +} + + BOOL sw_SetContext(struct wgl_dc_data* dc_data, DHGLRC dhglrc) { struct sw_context* sw_ctx = (struct sw_context*)dhglrc; struct sw_framebuffer* fb = dc_data->sw_data; UINT width, height; - /* Update state */ - sw_update_state(&sw_ctx->mesa, 0); - /* Get framebuffer size */ if(dc_data->flags & WGL_DC_OBJ_DC) { @@ -712,11 +1447,13 @@ BOOL sw_SetContext(struct wgl_dc_data* dc_data, DHGLRC dhglrc) ERR("GetClientRect failed!\n"); return FALSE; } + /* This is a physical DC. Setup the hook */ sw_ctx->hook = SetWindowsHookEx(WH_CALLWNDPROC, sw_call_window_proc, NULL, GetCurrentThreadId()); + /* Calculate width & height */ width = client_rect.right - client_rect.left; height = client_rect.bottom - client_rect.top; @@ -727,7 +1464,7 @@ BOOL sw_SetContext(struct wgl_dc_data* dc_data, DHGLRC dhglrc) HBITMAP hbmp; HDC hdc = dc_data->owner.hdc; - if(fb->flags & SW_FB_DOUBLEBUFFERED) + if(fb->gl_visual->DBflag) { ERR("Memory DC called with a double buffered format.\n"); return FALSE; @@ -751,28 +1488,27 @@ BOOL sw_SetContext(struct wgl_dc_data* dc_data, DHGLRC dhglrc) if(!width) width = 1; if(!height) height = 1; - fb->bmi.bmiHeader.biWidth = width; - fb->bmi.bmiHeader.biHeight = height; - /* Also make the mesa context current to mesa */ - if(!_mesa_make_current(&sw_ctx->mesa, fb->gl_buffer, fb->gl_buffer)) - { - ERR("_mesa_make_current filaed!\n"); - return FALSE; - } - + gl_make_current(sw_ctx->gl_ctx, fb->gl_buffer); + + /* Setup our functions */ + setup_DD_pointers(sw_ctx->gl_ctx); + /* Set the viewport if this is the first time we initialize this context */ - if(sw_ctx->mesa.Viewport.X == 0 && - sw_ctx->mesa.Viewport.Y == 0 && - sw_ctx->mesa.Viewport.Width == 0 && - sw_ctx->mesa.Viewport.Height == 0) + if(sw_ctx->gl_ctx->Viewport.X == 0 && + sw_ctx->gl_ctx->Viewport.Y == 0 && + sw_ctx->gl_ctx->Viewport.Width == 0 && + sw_ctx->gl_ctx->Viewport.Height == 0) { - _mesa_set_viewport(&sw_ctx->mesa, 0, 0, width, height); + gl_Viewport(sw_ctx->gl_ctx, 0, 0, width, height); } /* update the framebuffer size */ - _mesa_resize_framebuffer(&sw_ctx->mesa, fb->gl_buffer, width, height); - + gl_ResizeBuffersMESA(sw_ctx->gl_ctx); + + /* Use our API table */ + IntSetCurrentDispatchTable(&sw_api_table.glDispatchTable); + /* We're good */ return TRUE; } @@ -782,7 +1518,7 @@ void sw_ReleaseContext(DHGLRC dhglrc) struct sw_context* sw_ctx = (struct sw_context*)dhglrc; /* Forward to mesa */ - _mesa_make_current(NULL, NULL, NULL); + gl_make_current(NULL, NULL); /* Unhook */ if(sw_ctx->hook) @@ -795,26 +1531,36 @@ void sw_ReleaseContext(DHGLRC dhglrc) BOOL sw_SwapBuffers(HDC hdc, struct wgl_dc_data* dc_data) { struct sw_framebuffer* fb = dc_data->sw_data; - struct sw_context* sw_ctx = (struct sw_context*)IntGetCurrentDHGLRC(); - - /* Notify mesa */ - if(sw_ctx) - _mesa_notifySwapBuffers(&sw_ctx->mesa); - - if(!(fb->flags & SW_FB_DOUBLEBUFFERED)) - return TRUE; + char Buffer[sizeof(BITMAPINFOHEADER) + 3 * sizeof(DWORD)]; + BITMAPINFO *bmi = (BITMAPINFO*)Buffer; + BYTE Bpp = fb->pixel_format->cColorBits; - /* Upload to the display */ - return (SetDIBitsToDevice(hdc, - 0, - 0, - fb->bmi.bmiHeader.biWidth, - fb->bmi.bmiHeader.biHeight, - 0, - 0, - 0, - fb->bmi.bmiHeader.biHeight, - fb->backbuffer.Buffer, - &fb->bmi, - DIB_RGB_COLORS) != 0); + if (!fb->gl_visual->DBflag) + return TRUE; + + if (!fb->BackBuffer) + return FALSE; + + bmi->bmiHeader.biSize = sizeof(bmi->bmiHeader); + bmi->bmiHeader.biBitCount = Bpp; + bmi->bmiHeader.biClrImportant = 0; + bmi->bmiHeader.biClrUsed = 0; + bmi->bmiHeader.biPlanes = 1; + bmi->bmiHeader.biSizeImage = WIDTH_BYTES_ALIGN32(fb->width, Bpp) * fb->height; + bmi->bmiHeader.biXPelsPerMeter = 0; + bmi->bmiHeader.biYPelsPerMeter = 0; + bmi->bmiHeader.biHeight = fb->height; + bmi->bmiHeader.biWidth = fb->width; + bmi->bmiHeader.biCompression = Bpp == 16 ? BI_BITFIELDS : BI_RGB; + + if (Bpp == 16) + { + DWORD* BitMasks = (DWORD*)(&bmi->bmiColors[0]); + BitMasks[0] = 0x0000F800; + BitMasks[1] = 0x000007E0; + BitMasks[2] = 0x0000001F; + } + + return SetDIBitsToDevice(fb->Hdc, 0, 0, fb->width, fb->height, 0, 0, 0, fb->height, fb->BackBuffer, bmi, + fb->pixel_format->iPixelType == PFD_TYPE_COLORINDEX ? DIB_PAL_COLORS : DIB_RGB_COLORS) != 0; }