summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authoralanh <alanh>2001-05-16 09:07:51 +0000
committeralanh <alanh>2001-05-16 09:07:51 +0000
commitb3cb76198f58ac6aaaa1af15f276ee0789c952e1 (patch)
tree47d3552c3b1447a22ae67665a95dada1250c3437
parent0a698232bcf639375361c45faa0254dd11b41908 (diff)
bring Mesa 3.4.2 onto the bsd-2-0-0-branch
-rw-r--r--xc/extras/Mesa/src/X/fakeglx.c56
-rw-r--r--xc/extras/Mesa/src/X/xmesa1.c47
-rw-r--r--xc/extras/Mesa/src/X/xmesa2.c29
-rw-r--r--xc/extras/Mesa/src/buffers.c17
-rw-r--r--xc/extras/Mesa/src/config.h4
-rw-r--r--xc/extras/Mesa/src/cva.c2
-rw-r--r--xc/extras/Mesa/src/fog_tmp.h17
-rw-r--r--xc/extras/Mesa/src/get.c6
-rw-r--r--xc/extras/Mesa/src/image.c3
-rw-r--r--xc/extras/Mesa/src/teximage.c169
-rw-r--r--xc/extras/Mesa/src/texutil.c2829
-rw-r--r--xc/extras/Mesa/src/texutil.h105
-rw-r--r--xc/extras/Mesa/src/vbxform.c1
13 files changed, 1413 insertions, 1872 deletions
diff --git a/xc/extras/Mesa/src/X/fakeglx.c b/xc/extras/Mesa/src/X/fakeglx.c
index 6c9f04aee..c05385239 100644
--- a/xc/extras/Mesa/src/X/fakeglx.c
+++ b/xc/extras/Mesa/src/X/fakeglx.c
@@ -1,9 +1,9 @@
/*
* Mesa 3-D graphics library
- * Version: 3.4
+ * Version: 3.4.2
*
- * Copyright (C) 1999-2000 Brian Paul All Rights Reserved.
+ * 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"),
@@ -64,7 +64,7 @@
#define SERVER_MINOR_VERSION 3
/* This is appended onto the glXGetClient/ServerString version strings. */
-#define MESA_GLX_VERSION "Mesa 3.4"
+#define MESA_GLX_VERSION "Mesa 3.4.2"
/* Who implemented this GLX? */
#define VENDOR "Brian Paul"
@@ -336,22 +336,40 @@ create_glx_visual( Display *dpy, XVisualInfo *visinfo )
);
}
else if (is_usable_visual( visinfo )) {
- /* Configure this visual as RGB, double-buffered, depth-buffered. */
- /* This is surely wrong for some people's needs but what else */
- /* can be done? They should use glXChooseVisual(). */
- return save_glx_visual( dpy, visinfo,
- GL_TRUE, /* rgb */
- GL_FALSE, /* alpha */
- GL_TRUE, /* double */
- GL_FALSE, /* stereo */
- DEFAULT_SOFTWARE_DEPTH_BITS,
- 8 * sizeof(GLstencil),
- 8 * sizeof(GLaccum), /* r */
- 8 * sizeof(GLaccum), /* g */
- 8 * sizeof(GLaccum), /* b */
- 8 * sizeof(GLaccum), /* a */
- 0 /* level */
- );
+ if (getenv("MESA_GLX_FORCE_CI")) {
+ /* Configure this visual as a COLOR INDEX visual. */
+ return save_glx_visual( dpy, visinfo,
+ GL_FALSE, /* rgb */
+ GL_FALSE, /* alpha */
+ GL_TRUE, /* double */
+ GL_FALSE, /* stereo */
+ DEFAULT_SOFTWARE_DEPTH_BITS,
+ 8 * sizeof(GLstencil),
+ 0 * sizeof(GLaccum), /* r */
+ 0 * sizeof(GLaccum), /* g */
+ 0 * sizeof(GLaccum), /* b */
+ 0 * sizeof(GLaccum), /* a */
+ 0 /* level */
+ );
+ }
+ else {
+ /* Configure this visual as RGB, double-buffered, depth-buffered. */
+ /* This is surely wrong for some people's needs but what else */
+ /* can be done? They should use glXChooseVisual(). */
+ return save_glx_visual( dpy, visinfo,
+ GL_TRUE, /* rgb */
+ GL_FALSE, /* alpha */
+ GL_TRUE, /* double */
+ GL_FALSE, /* stereo */
+ DEFAULT_SOFTWARE_DEPTH_BITS,
+ 8 * sizeof(GLstencil),
+ 8 * sizeof(GLaccum), /* r */
+ 8 * sizeof(GLaccum), /* g */
+ 8 * sizeof(GLaccum), /* b */
+ 8 * sizeof(GLaccum), /* a */
+ 0 /* level */
+ );
+ }
}
else {
fprintf(stderr,"Mesa: error in glXCreateContext: bad visual\n");
diff --git a/xc/extras/Mesa/src/X/xmesa1.c b/xc/extras/Mesa/src/X/xmesa1.c
index 8a84ca9a4..bf3c7521d 100644
--- a/xc/extras/Mesa/src/X/xmesa1.c
+++ b/xc/extras/Mesa/src/X/xmesa1.c
@@ -1,20 +1,20 @@
/*
* Mesa 3-D graphics library
- * Version: 3.3
- *
- * Copyright (C) 1999-2000 Brian Paul All Rights Reserved.
- *
+ * Version: 3.4.2
+ *
+ * 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
@@ -22,7 +22,6 @@
* AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
* CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
*/
-/* $XFree86: xc/extras/Mesa/src/X/xmesa1.c,v 1.7 2000/09/24 13:50:53 alanh Exp $ */
/*
@@ -90,6 +89,7 @@
_glthread_Mutex _xmesa_lock;
+
/*
* Lookup tables for HPCR pixel format:
*/
@@ -147,7 +147,7 @@ static short hpcr_rgbTbl[3][256] = {
176, 177, 178, 179, 180, 181, 182, 183, 184, 185, 186, 187, 188, 189, 190, 191,
192, 193, 194, 195, 196, 197, 198, 199, 200, 201, 202, 203, 204, 205, 206, 207,
208, 209, 210, 211, 212, 213, 214, 215, 216, 217, 218, 219, 220, 221, 222, 223
-}
+}
};
@@ -322,7 +322,7 @@ static int bits_per_pixel( XMesaVisual xmv )
/*
* Determine if a given X window ID is valid (window exists).
- * Do this by calling XGetWindowAttributes() for the window and
+ * Do this by calling XGetIconName() for the window and
* checking if we catch an X error.
* Input: dpy - the display
* win - the window to check for existance
@@ -343,12 +343,14 @@ static int window_exists_err_handler( XMesaDisplay* dpy, XErrorEvent* xerr )
static GLboolean window_exists( XMesaDisplay *dpy, Window win )
{
- XWindowAttributes wa;
+ char *name;
int (*old_handler)( XMesaDisplay*, XErrorEvent* );
WindowExistsFlag = GL_TRUE;
old_handler = XSetErrorHandler(window_exists_err_handler);
- XGetWindowAttributes( dpy, win, &wa ); /* dummy request */
+ XGetIconName(dpy, win, &name); /* dummy request */
XSetErrorHandler(old_handler);
+ if (name)
+ XFree(name);
return WindowExistsFlag;
}
#endif
@@ -781,7 +783,7 @@ noFaultXAllocColor( int client,
subColor.pixel = (unsigned long) bestmatch;
subColor.red = ctable[bestmatch].red;
subColor.green = ctable[bestmatch].green;
- subColor.blue = ctable[bestmatch].blue;
+ subColor.blue = ctable[bestmatch].blue;
subColor.flags = DoRed | DoGreen | DoBlue;
*alloced = 0;
}
@@ -819,7 +821,7 @@ static GLboolean setup_grayscale( int client, XMesaVisual v,
prevBuffer = find_xmesa_buffer(v->display, cmap, buffer);
if (prevBuffer &&
- (buffer->xm_visual->gl_visual->RGBAflag ==
+ (buffer->xm_visual->gl_visual->RGBAflag ==
prevBuffer->xm_visual->gl_visual->RGBAflag)) {
/* Copy colormap stuff from previous XMesaBuffer which uses same
* X colormap. Do this to avoid time spent in noFaultXAllocColor.
@@ -907,7 +909,7 @@ static GLboolean setup_dithered_color( int client, XMesaVisual v,
prevBuffer = find_xmesa_buffer(v->display, cmap, buffer);
if (prevBuffer &&
- (buffer->xm_visual->gl_visual->RGBAflag ==
+ (buffer->xm_visual->gl_visual->RGBAflag ==
prevBuffer->xm_visual->gl_visual->RGBAflag)) {
/* Copy colormap stuff from previous, matching XMesaBuffer.
* Do this to avoid time spent in noFaultXAllocColor.
@@ -980,8 +982,8 @@ static void setup_8bit_hpcr( XMesaVisual v )
int i;
double g;
- g = 1.0 / v->RedGamma;
- for (i=0; i<256; i++) {
+ g = 1.0 / v->RedGamma;
+ for (i=0; i<256; i++) {
GLint red = (GLint) (255.0 * pow( hpcr_rgbTbl[0][i]/255.0, g ) + 0.5);
v->hpcr_rgbTbl[0][i] = CLAMP( red, 16, 239 );
}
@@ -1641,6 +1643,7 @@ XMesaContext XMesaCreateContext( XMesaVisual v, XMesaContext share_list )
gl_extensions_enable(c->gl_ctx, "GL_HP_occlusion_test");
gl_extensions_enable(c->gl_ctx, "GL_ARB_texture_cube_map");
gl_extensions_enable(c->gl_ctx, "GL_EXT_texture_env_combine");
+ gl_extensions_enable(c->gl_ctx, "GL_EXT_texture_env_dot3");
if (CHECK_BYTE_ORDER(v)) {
c->swapbytes = GL_FALSE;
@@ -1837,7 +1840,7 @@ XMesaBuffer XMesaCreateWindowBuffer2( XMesaVisual v, XMesaWindow w,
attribs[numAttribs++] = (int) c->gl_ctx;
}
attribs[numAttribs++] = FXMESA_NONE;
-
+
if ((hw = fxQueryHardware())==GR_SSTTYPE_VOODOO) {
b->FXctx = fxMesaCreateBestContext(0, b->width, b->height, attribs);
if ((v->undithered_pf!=PF_INDEX) && (b->backimage)) {
@@ -2269,7 +2272,7 @@ static void FXgetImage( XMesaBuffer b )
/* read row from 3Dfx frame buffer */
grLfbReadRegion( GR_BUFFER_FRONTBUFFER,
0, xmesa->xm_buffer->FXctx->height-(b->height-y),
- b->width, 1,
+ b->width, 1,
0,
pixbuf );
@@ -2288,7 +2291,7 @@ static void FXgetImage( XMesaBuffer b )
/* read row from 3Dfx frame buffer */
grLfbReadRegion( GR_BUFFER_FRONTBUFFER,
0, xmesa->xm_buffer->FXctx->height-(b->height-y),
- b->width, 1,
+ b->width, 1,
0,
pixbuf );
@@ -2393,7 +2396,7 @@ void XMesaCopySubBuffer( XMesaBuffer b, int x, int y, int width, int height )
_mesa_swapbuffers(ctx);
if (b->db_state) {
- int yTop = b->bottom - y - height;
+ int yTop = b->height - y - height;
#ifdef FX
if (b->FXctx) {
fxMesaSwapBuffers();
@@ -2509,7 +2512,7 @@ const char *XMesaGetString( XMesaContext c, int name )
{
(void) c;
if (name==XMESA_VERSION) {
- return "3.1";
+ return "3.4.2";
}
else if (name==XMESA_EXTENSIONS) {
return "";
@@ -2621,5 +2624,3 @@ unsigned long XMesaDitherColor( XMesaContext xmesa, GLint x, GLint y,
}
return 0;
}
-
-
diff --git a/xc/extras/Mesa/src/X/xmesa2.c b/xc/extras/Mesa/src/X/xmesa2.c
index f05e95b11..10178dcba 100644
--- a/xc/extras/Mesa/src/X/xmesa2.c
+++ b/xc/extras/Mesa/src/X/xmesa2.c
@@ -4215,10 +4215,18 @@ static void write_span_index8_pixmap( INDEX8_SPAN_ARGS )
XMesaGC gc = xmesa->xm_buffer->gc2;
register GLuint i;
y = FLIP(xmesa->xm_buffer, y);
- for (i=0;i<n;i++,x++) {
- if (mask[i]) {
- XMesaSetForeground( dpy, gc, (unsigned long) index[i] );
- XMesaDrawPoint( dpy, buffer, gc, (int) x, (int) y );
+ if (mask) {
+ for (i=0;i<n;i++,x++) {
+ if (mask[i]) {
+ XMesaSetForeground( dpy, gc, (unsigned long) index[i] );
+ XMesaDrawPoint( dpy, buffer, gc, (int) x, (int) y );
+ }
+ }
+ }
+ else {
+ for (i=0;i<n;i++,x++) {
+ XMesaSetForeground( dpy, gc, (unsigned long) index[i] );
+ XMesaDrawPoint( dpy, buffer, gc, (int) x, (int) y );
}
}
}
@@ -4233,9 +4241,16 @@ static void write_span_index_ximage( INDEX_SPAN_ARGS )
XMesaImage *img = xmesa->xm_buffer->backimage;
register GLuint i;
y = FLIP(xmesa->xm_buffer, y);
- for (i=0;i<n;i++,x++) {
- if (mask[i]) {
- XMesaPutPixel( img, x, y, (unsigned long) index[i] );
+ if (mask) {
+ for (i=0;i<n;i++,x++) {
+ if (mask[i]) {
+ XMesaPutPixel( img, x, y, (unsigned long) index[i] );
+ }
+ }
+ }
+ else {
+ for (i=0;i<n;i++,x++) {
+ XMesaPutPixel( img, x, y, (unsigned long) index[i] );
}
}
}
diff --git a/xc/extras/Mesa/src/buffers.c b/xc/extras/Mesa/src/buffers.c
index e334265a6..437cda37e 100644
--- a/xc/extras/Mesa/src/buffers.c
+++ b/xc/extras/Mesa/src/buffers.c
@@ -1,7 +1,7 @@
/*
* Mesa 3-D graphics library
- * Version: 3.3
+ * Version: 3.4
*
* Copyright (C) 1999-2000 Brian Paul All Rights Reserved.
*
@@ -22,7 +22,7 @@
* AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
* CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
*/
-/* $XFree86: xc/extras/Mesa/src/buffers.c,v 1.4 2000/09/26 15:56:29 tsi Exp $ */
+
#ifdef PC_HEADER
#include "all.h"
@@ -167,7 +167,7 @@ clear_color_buffer(GLcontext *ctx)
}
else {
/* Color index mode */
- ASSERT(ctx->Color.IndexMask == ~0);
+ ASSERT(ctx->Color.IndexMask == ((1 << ctx->Visual->IndexBits) - 1));
if (ctx->Visual->IndexBits == 8) {
/* 8-bit clear */
GLubyte span[MAX_WIDTH];
@@ -208,15 +208,19 @@ clear_color_buffers(GLcontext *ctx)
if (bufferBit & ctx->Color.DrawDestMask) {
if (bufferBit == FRONT_LEFT_BIT) {
(void) (*ctx->Driver.SetDrawBuffer)( ctx, GL_FRONT_LEFT);
+ (void) (*ctx->Driver.SetReadBuffer)( ctx, ctx->DrawBuffer, GL_FRONT_LEFT);
}
else if (bufferBit == FRONT_RIGHT_BIT) {
(void) (*ctx->Driver.SetDrawBuffer)( ctx, GL_FRONT_RIGHT);
+ (void) (*ctx->Driver.SetReadBuffer)( ctx, ctx->DrawBuffer, GL_FRONT_RIGHT);
}
else if (bufferBit == BACK_LEFT_BIT) {
(void) (*ctx->Driver.SetDrawBuffer)( ctx, GL_BACK_LEFT);
+ (void) (*ctx->Driver.SetReadBuffer)( ctx, ctx->DrawBuffer, GL_BACK_LEFT);
}
else {
(void) (*ctx->Driver.SetDrawBuffer)( ctx, GL_BACK_RIGHT);
+ (void) (*ctx->Driver.SetReadBuffer)( ctx, ctx->DrawBuffer, GL_BACK_RIGHT);
}
if (ctx->Color.SWmasking) {
@@ -228,8 +232,9 @@ clear_color_buffers(GLcontext *ctx)
}
}
- /* restore default dest buffer */
+ /* restore default read/draw buffers */
(void) (*ctx->Driver.SetDrawBuffer)( ctx, ctx->Color.DriverDrawBuffer );
+ (void) (*ctx->Driver.SetReadBuffer)( ctx, ctx->ReadBuffer, ctx->Pixel.DriverReadBuffer );
}
@@ -287,6 +292,8 @@ _mesa_Clear( GLbitfield mask )
}
#endif
+ RENDER_START(ctx);
+
/* do software clearing here */
if (newMask) {
if (newMask & ctx->Color.DrawDestMask) clear_color_buffers(ctx);
@@ -302,6 +309,8 @@ _mesa_Clear( GLbitfield mask )
_mesa_clear_alpha_buffers( ctx );
}
+ RENDER_FINISH(ctx);
+
#ifdef PROFILE
ctx->ClearTime += gl_time() - t0;
ctx->ClearCount++;
diff --git a/xc/extras/Mesa/src/config.h b/xc/extras/Mesa/src/config.h
index 1d93ae611..01440943f 100644
--- a/xc/extras/Mesa/src/config.h
+++ b/xc/extras/Mesa/src/config.h
@@ -22,7 +22,7 @@
* AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
* CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
*/
-/* $XFree86: xc/extras/Mesa/src/config.h,v 1.7 2000/09/26 15:56:30 tsi Exp $ */
+
/*
* Tunable configuration parameters.
@@ -106,7 +106,7 @@
/* Maximum viewport/image size: */
#define MAX_WIDTH 2048
-#define MAX_HEIGHT 1200
+#define MAX_HEIGHT 2048
/* Maxmimum size for CVA. May be overridden by the drivers. */
#define MAX_ARRAY_LOCK_SIZE 3000
diff --git a/xc/extras/Mesa/src/cva.c b/xc/extras/Mesa/src/cva.c
index 1f1c83358..028853e5a 100644
--- a/xc/extras/Mesa/src/cva.c
+++ b/xc/extras/Mesa/src/cva.c
@@ -612,7 +612,7 @@ void gl_prepare_arrays_cva( struct vertex_buffer *VB )
if (enable & VERT_INDEX)
{
GLvector1ui *index = VB->IndexPtr = &cva->v.Index;
- VB->Index[0] = VB->Index[1] = VB->IndexPtr;
+ VB->Index[0] = VB->Index[1] = VB->IndexPtr = &cva->v.Index;
#ifdef VAO
client_data = &ctx->Array.Current->Index;
diff --git a/xc/extras/Mesa/src/fog_tmp.h b/xc/extras/Mesa/src/fog_tmp.h
index 830173129..cec9c0d91 100644
--- a/xc/extras/Mesa/src/fog_tmp.h
+++ b/xc/extras/Mesa/src/fog_tmp.h
@@ -178,7 +178,6 @@ static void TAG(fog_ci_vertices)( struct vertex_buffer *VB,
VB->IndexPtr = VB->FoggedIndex[side];
out = VB->IndexPtr->start;
-
/* NOTE: the use of casts generates better/faster code for MIPS */
for ( i = 0; i < n ; i++, STRIDE_F(v,stride), STRIDE_UI(in,in_stride))
CULLCHECK {
@@ -364,12 +363,11 @@ static void TAG(fog_ci_vertices)( struct vertex_buffer *VB,
(void) flag;
(void) cullmask;
-
in = VB->Index[side]->start;
in_stride = VB->Index[side]->stride;
- VB->IndexPtr = VB->FoggedIndex[side];
- out = VB->IndexPtr->start;
-
+ VB->Index[side] = VB->FoggedIndex[side];
+ VB->IndexPtr = VB->Index[0];
+ out = (GLuint *)VB->Index[side]->start;
/* NOTE: the extensive use of casts generates better/faster code for MIPS */
if (vertex_size > 2) {
@@ -385,7 +383,7 @@ static void TAG(fog_ci_vertices)( struct vertex_buffer *VB,
CULLCHECK {
GLfloat f = (fogend - ABSF(v[2])) * d;
f = CLAMP( f, 0.0, 1.0 );
- *out = (GLint) ((GLfloat)(GLint) *in + (1.0F-f) * fogindex);
+ out[i] = (GLint) ((GLfloat)(GLint) *in + (1.0F-f) * fogindex);
}
}
break;
@@ -398,7 +396,7 @@ static void TAG(fog_ci_vertices)( struct vertex_buffer *VB,
{
CULLCHECK {
GLfloat f = exp( d * ABSF(v[2]) );
- *out = (GLint) ((GLfloat)(GLint) *in + (1.0F-f) * fogindex);
+ out[i] = (GLint) ((GLfloat)(GLint) *in + (1.0F-f) * fogindex);
}
}
break;
@@ -421,7 +419,8 @@ static void TAG(fog_ci_vertices)( struct vertex_buffer *VB,
gl_problem(ctx, "Bad fog mode in gl_fog_ci_vertices");
return;
}
- } else if (ctx->Fog.Mode == GL_LINEAR) {
+ }
+ else if (ctx->Fog.Mode == GL_LINEAR) {
GLuint fogindex;
GLfloat f = ctx->Fog.End / (ctx->Fog.End - ctx->Fog.Start);
@@ -431,7 +430,7 @@ static void TAG(fog_ci_vertices)( struct vertex_buffer *VB,
for ( i = 0; i < n ; i++, STRIDE_F(v,stride), STRIDE_UI(in,in_stride))
{
CULLCHECK {
- *out = *in + fogindex;
+ out[i] = *in + fogindex;
}
}
}
diff --git a/xc/extras/Mesa/src/get.c b/xc/extras/Mesa/src/get.c
index 8eba883c8..086010965 100644
--- a/xc/extras/Mesa/src/get.c
+++ b/xc/extras/Mesa/src/get.c
@@ -1,9 +1,9 @@
/*
* Mesa 3-D graphics library
- * Version: 3.4
+ * Version: 3.4.2
*
- * Copyright (C) 1999-2000 Brian Paul All Rights Reserved.
+ * 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"),
@@ -5094,7 +5094,7 @@ _mesa_GetString( GLenum name )
GET_CURRENT_CONTEXT(ctx);
static const char *vendor = "Brian Paul";
static const char *renderer = "Mesa";
- static const char *version = "1.2 Mesa 3.4";
+ static const char *version = "1.2 Mesa 3.4.2";
ASSERT_OUTSIDE_BEGIN_END_AND_FLUSH_WITH_RETVAL(ctx, "glGetString", 0);
diff --git a/xc/extras/Mesa/src/image.c b/xc/extras/Mesa/src/image.c
index 87ba3699c..4742db514 100644
--- a/xc/extras/Mesa/src/image.c
+++ b/xc/extras/Mesa/src/image.c
@@ -2302,9 +2302,6 @@ _mesa_unpack_ubyte_color_span( GLcontext *ctx,
srcType == GL_UNSIGNED_INT_10_10_10_2 ||
srcType == GL_UNSIGNED_INT_2_10_10_10_REV);
- /* this is intended for RGBA mode only */
- assert(ctx->Visual->RGBAflag);
-
applyTransferOps &= (ctx->Pixel.ScaleOrBiasRGBA ||
ctx->Pixel.MapColorFlag ||
ctx->ColorMatrix.type != MATRIX_IDENTITY ||
diff --git a/xc/extras/Mesa/src/teximage.c b/xc/extras/Mesa/src/teximage.c
index ac4066e14..ce1a11347 100644
--- a/xc/extras/Mesa/src/teximage.c
+++ b/xc/extras/Mesa/src/teximage.c
@@ -2,19 +2,19 @@
/*
* Mesa 3-D graphics library
* Version: 3.4
- *
+ *
* Copyright (C) 1999-2000 Brian Paul All Rights Reserved.
- *
+ *
* Permission is hereby granted, free of charge, to any person obtaining a
* copy of this software and associated documentation files (the "Software"),
* to deal in the Software without restriction, including without limitation
* the rights to use, copy, modify, merge, publish, distribute, sublicense,
* and/or sell copies of the Software, and to permit persons to whom the
* Software is furnished to do so, subject to the following conditions:
- *
+ *
* The above copyright notice and this permission notice shall be included
* in all copies or substantial portions of the Software.
- *
+ *
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
* OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
@@ -33,6 +33,7 @@
#include "mem.h"
#include "mmath.h"
#include "span.h"
+#include "texformat.h"
#include "teximage.h"
#include "texstate.h"
#include "types.h"
@@ -300,115 +301,6 @@ is_compressed_format(GLcontext *ctx, GLenum internalFormat)
-/*
- * Examine the texImage->Format field and set the Red, Green, Blue, etc
- * texel component sizes to default values.
- * These fields are set only here by core Mesa but device drivers may
- * overwritting these fields to indicate true texel resolution.
- */
-static void
-set_teximage_component_sizes( struct gl_texture_image *texImage )
-{
- switch (texImage->Format) {
- case GL_ALPHA:
- texImage->RedBits = 0;
- texImage->GreenBits = 0;
- texImage->BlueBits = 0;
- texImage->AlphaBits = 8;
- texImage->IntensityBits = 0;
- texImage->LuminanceBits = 0;
- texImage->IndexBits = 0;
- break;
- case GL_LUMINANCE:
- texImage->RedBits = 0;
- texImage->GreenBits = 0;
- texImage->BlueBits = 0;
- texImage->AlphaBits = 0;
- texImage->IntensityBits = 0;
- texImage->LuminanceBits = 8;
- texImage->IndexBits = 0;
- break;
- case GL_LUMINANCE_ALPHA:
- texImage->RedBits = 0;
- texImage->GreenBits = 0;
- texImage->BlueBits = 0;
- texImage->AlphaBits = 8;
- texImage->IntensityBits = 0;
- texImage->LuminanceBits = 8;
- texImage->IndexBits = 0;
- break;
- case GL_INTENSITY:
- texImage->RedBits = 0;
- texImage->GreenBits = 0;
- texImage->BlueBits = 0;
- texImage->AlphaBits = 0;
- texImage->IntensityBits = 8;
- texImage->LuminanceBits = 0;
- texImage->IndexBits = 0;
- break;
- case GL_RED:
- texImage->RedBits = 8;
- texImage->GreenBits = 0;
- texImage->BlueBits = 0;
- texImage->AlphaBits = 0;
- texImage->IntensityBits = 0;
- texImage->LuminanceBits = 0;
- texImage->IndexBits = 0;
- break;
- case GL_GREEN:
- texImage->RedBits = 0;
- texImage->GreenBits = 8;
- texImage->BlueBits = 0;
- texImage->AlphaBits = 0;
- texImage->IntensityBits = 0;
- texImage->LuminanceBits = 0;
- texImage->IndexBits = 0;
- break;
- case GL_BLUE:
- texImage->RedBits = 0;
- texImage->GreenBits = 0;
- texImage->BlueBits = 8;
- texImage->AlphaBits = 0;
- texImage->IntensityBits = 0;
- texImage->LuminanceBits = 0;
- texImage->IndexBits = 0;
- break;
- case GL_RGB:
- case GL_BGR:
- texImage->RedBits = 8;
- texImage->GreenBits = 8;
- texImage->BlueBits = 8;
- texImage->AlphaBits = 0;
- texImage->IntensityBits = 0;
- texImage->LuminanceBits = 0;
- texImage->IndexBits = 0;
- break;
- case GL_RGBA:
- case GL_BGRA:
- case GL_ABGR_EXT:
- texImage->RedBits = 8;
- texImage->GreenBits = 8;
- texImage->BlueBits = 8;
- texImage->AlphaBits = 8;
- texImage->IntensityBits = 0;
- texImage->LuminanceBits = 0;
- texImage->IndexBits = 0;
- break;
- case GL_COLOR_INDEX:
- texImage->RedBits = 0;
- texImage->GreenBits = 0;
- texImage->BlueBits = 0;
- texImage->AlphaBits = 0;
- texImage->IntensityBits = 0;
- texImage->LuminanceBits = 0;
- texImage->IndexBits = 8;
- break;
- default:
- gl_problem(NULL, "unexpected format in set_teximage_component_sizes");
- }
-}
-
-
static void
set_tex_image(struct gl_texture_object *tObj,
GLenum target, GLint level,
@@ -467,9 +359,7 @@ init_texture_image( GLcontext *ctx,
{
ASSERT(img);
ASSERT(!img->Data);
- img->Format = (GLenum) _mesa_base_tex_format(ctx, internalFormat);
- set_teximage_component_sizes( img );
- img->IntFormat = (GLenum) internalFormat;
+ _mesa_init_texture_format( ctx, img, internalFormat );
img->Border = border;
img->Width = width;
img->Height = height;
@@ -557,6 +447,7 @@ _mesa_select_tex_object(GLcontext *ctx, struct gl_texture_unit *texUnit,
case GL_TEXTURE_CUBE_MAP_NEGATIVE_Y_ARB:
case GL_TEXTURE_CUBE_MAP_POSITIVE_Z_ARB:
case GL_TEXTURE_CUBE_MAP_NEGATIVE_Z_ARB:
+ case GL_TEXTURE_CUBE_MAP_ARB:
return ctx->Extensions.HaveTextureCubeMap
? texUnit->CurrentCubeMap : NULL;
case GL_PROXY_TEXTURE_CUBE_MAP_ARB:
@@ -745,7 +636,7 @@ make_texture_image( GLcontext *ctx,
}
return; /* all done */
}
- }
+ }
/*
@@ -851,13 +742,6 @@ clear_proxy_teximage(struct gl_texture_image *img)
ASSERT(img);
img->Format = 0;
img->IntFormat = 0;
- img->RedBits = 0;
- img->GreenBits = 0;
- img->BlueBits = 0;
- img->AlphaBits = 0;
- img->IntensityBits = 0;
- img->LuminanceBits = 0;
- img->IndexBits = 0;
img->Border = 0;
img->Width = 0;
img->Height = 0;
@@ -871,6 +755,7 @@ clear_proxy_teximage(struct gl_texture_image *img)
img->Data = NULL;
img->IsCompressed = 0;
img->CompressedSize = 0;
+ img->TexFormat = &_mesa_null_texformat;
}
@@ -1088,9 +973,9 @@ subtexture_error_check( GLcontext *ctx, GLuint dimensions,
return GL_TRUE;
}
- destTex = texUnit->CurrentD[2]->Image[level];
+ destTex = texUnit->CurrentD[dimensions]->Image[level];
if (!destTex) {
- gl_error(ctx, GL_INVALID_OPERATION, "glTexSubImage2D");
+ gl_error(ctx, GL_INVALID_OPERATION, "glTexSubImage1/2/3D");
return GL_TRUE;
}
@@ -1994,11 +1879,10 @@ void
_mesa_GetTexImage( GLenum target, GLint level, GLenum format,
GLenum type, GLvoid *pixels )
{
- GET_CURRENT_CONTEXT(ctx);
const struct gl_texture_object *texObj;
struct gl_texture_image *texImage;
GLboolean discardImage;
-
+ GET_CURRENT_CONTEXT(ctx);
ASSERT_OUTSIDE_BEGIN_END_AND_FLUSH(ctx, "glGetTexImage");
if (level < 0 || level >= ctx->Const.MaxTextureLevels) {
@@ -2174,11 +2058,12 @@ _mesa_TexSubImage1D( GLenum target, GLint level,
GLenum format, GLenum type,
const GLvoid *pixels )
{
- GET_CURRENT_CONTEXT(ctx);
struct gl_texture_unit *texUnit;
struct gl_texture_object *texObj;
struct gl_texture_image *texImage;
GLboolean success = GL_FALSE;
+ GET_CURRENT_CONTEXT(ctx);
+ ASSERT_OUTSIDE_BEGIN_END_AND_FLUSH(ctx, "glTexSubImage1D");
if (subtexture_error_check(ctx, 1, target, level, xoffset, 0, 0,
width, 1, 1, format, type)) {
@@ -2257,11 +2142,12 @@ _mesa_TexSubImage2D( GLenum target, GLint level,
GLenum format, GLenum type,
const GLvoid *pixels )
{
- GET_CURRENT_CONTEXT(ctx);
struct gl_texture_unit *texUnit;
struct gl_texture_object *texObj;
struct gl_texture_image *texImage;
GLboolean success = GL_FALSE;
+ GET_CURRENT_CONTEXT(ctx);
+ ASSERT_OUTSIDE_BEGIN_END_AND_FLUSH(ctx, "glTexSubImage2D");
if (subtexture_error_check(ctx, 2, target, level, xoffset, yoffset, 0,
width, height, 1, format, type)) {
@@ -2370,11 +2256,12 @@ _mesa_TexSubImage3D( GLenum target, GLint level,
GLenum format, GLenum type,
const GLvoid *pixels )
{
- GET_CURRENT_CONTEXT(ctx);
struct gl_texture_unit *texUnit;
struct gl_texture_object *texObj;
struct gl_texture_image *texImage;
GLboolean success = GL_FALSE;
+ GET_CURRENT_CONTEXT(ctx);
+ ASSERT_OUTSIDE_BEGIN_END_AND_FLUSH(ctx, "glTexSubImage3D");
if (subtexture_error_check(ctx, 3, target, level, xoffset, yoffset, zoffset,
width, height, depth, format, type)) {
@@ -2521,7 +2408,7 @@ _mesa_CopyTexImage1D( GLenum target, GLint level,
return;
if (ctx->Pixel.MapColorFlag || ctx->Pixel.ScaleOrBiasRGBA
- || !ctx->Driver.CopyTexImage1D
+ || !ctx->Driver.CopyTexImage1D
|| !(*ctx->Driver.CopyTexImage1D)(ctx, target, level,
internalFormat, x, y, width, border))
{
@@ -2616,7 +2503,7 @@ _mesa_CopyTexSubImage1D( GLenum target, GLint level,
gl_error( ctx, GL_OUT_OF_MEMORY, "glCopyTexSubImage2D" );
return;
}
-
+
/* now call glTexSubImage1D to do the real work */
unpackSave = ctx->Unpack;
ctx->Unpack = _mesa_native_packing;
@@ -2668,7 +2555,7 @@ _mesa_CopyTexSubImage2D( GLenum target, GLint level,
_mesa_TexSubImage2D(target, level, xoffset, yoffset, width, height,
GL_RGBA, GL_UNSIGNED_BYTE, image);
ctx->Unpack = unpackSave;
-
+
FREE(image);
}
}
@@ -2713,7 +2600,7 @@ _mesa_CopyTexSubImage3D( GLenum target, GLint level,
_mesa_TexSubImage3D(target, level, xoffset, yoffset, zoffset,
width, height, 1, GL_RGBA, GL_UNSIGNED_BYTE, image);
ctx->Unpack = unpackSave;
-
+
FREE(image);
}
}
@@ -3116,11 +3003,12 @@ _mesa_CompressedTexSubImage1DARB(GLenum target, GLint level, GLint xoffset,
GLsizei width, GLenum format,
GLsizei imageSize, const GLvoid *data)
{
- GET_CURRENT_CONTEXT(ctx);
struct gl_texture_unit *texUnit;
struct gl_texture_object *texObj;
struct gl_texture_image *texImage;
GLboolean success = GL_FALSE;
+ GET_CURRENT_CONTEXT(ctx);
+ ASSERT_OUTSIDE_BEGIN_END_AND_FLUSH(ctx, "glCompressedTexSubImage1DARB");
if (subtexture_error_check(ctx, 1, target, level, xoffset, 0, 0,
width, 1, 1, format, GL_NONE)) {
@@ -3153,11 +3041,12 @@ _mesa_CompressedTexSubImage2DARB(GLenum target, GLint level, GLint xoffset,
GLenum format, GLsizei imageSize,
const GLvoid *data)
{
- GET_CURRENT_CONTEXT(ctx);
struct gl_texture_unit *texUnit;
struct gl_texture_object *texObj;
struct gl_texture_image *texImage;
GLboolean success = GL_FALSE;
+ GET_CURRENT_CONTEXT(ctx);
+ ASSERT_OUTSIDE_BEGIN_END_AND_FLUSH(ctx, "glCompressedTexSubImage2DARB");
if (subtexture_error_check(ctx, 2, target, level, xoffset, yoffset, 0,
width, height, 1, format, GL_NONE)) {
@@ -3191,11 +3080,12 @@ _mesa_CompressedTexSubImage3DARB(GLenum target, GLint level, GLint xoffset,
GLsizei height, GLsizei depth, GLenum format,
GLsizei imageSize, const GLvoid *data)
{
- GET_CURRENT_CONTEXT(ctx);
struct gl_texture_unit *texUnit;
struct gl_texture_object *texObj;
struct gl_texture_image *texImage;
GLboolean success = GL_FALSE;
+ GET_CURRENT_CONTEXT(ctx);
+ ASSERT_OUTSIDE_BEGIN_END_AND_FLUSH(ctx, "glCompressedTexSubImage3DARB");
if (subtexture_error_check(ctx, 3, target, level, xoffset, yoffset, zoffset,
width, height, depth, format, GL_NONE)) {
@@ -3226,10 +3116,9 @@ _mesa_CompressedTexSubImage3DARB(GLenum target, GLint level, GLint xoffset,
void
_mesa_GetCompressedTexImageARB(GLenum target, GLint level, GLvoid *img)
{
- GET_CURRENT_CONTEXT(ctx);
const struct gl_texture_object *texObj;
struct gl_texture_image *texImage;
-
+ GET_CURRENT_CONTEXT(ctx);
ASSERT_OUTSIDE_BEGIN_END_AND_FLUSH(ctx, "glGetCompressedTexImageARB");
if (level < 0 || level >= ctx->Const.MaxTextureLevels) {
diff --git a/xc/extras/Mesa/src/texutil.c b/xc/extras/Mesa/src/texutil.c
index 313ef1455..786817c9a 100644
--- a/xc/extras/Mesa/src/texutil.c
+++ b/xc/extras/Mesa/src/texutil.c
@@ -2,1687 +2,1304 @@
/*
* Mesa 3-D graphics library
* Version: 3.4
- *
+ *
* Copyright (C) 1999-2000 Brian Paul All Rights Reserved.
- *
+ *
* Permission is hereby granted, free of charge, to any person obtaining a
* copy of this software and associated documentation files (the "Software"),
* to deal in the Software without restriction, including without limitation
* the rights to use, copy, modify, merge, publish, distribute, sublicense,
* and/or sell copies of the Software, and to permit persons to whom the
* Software is furnished to do so, subject to the following conditions:
- *
+ *
* The above copyright notice and this permission notice shall be included
* in all copies or substantial portions of the Software.
- *
+ *
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
* OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
* BRIAN PAUL BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN
* AN ACTION 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 <gareth@valinux.com>
*/
-
#ifdef PC_HEADER
#include "all.h"
#else
#include "glheader.h"
#include "context.h"
+#include "enums.h"
#include "image.h"
#include "mem.h"
+#include "texformat.h"
#include "texutil.h"
#include "types.h"
#endif
+#define DBG 0
-/*
- * Texture utilities which may be useful to device drivers.
- * See the texutil.h for the list of supported internal formats.
- * It's expected that new formats will be added for new hardware.
- */
+struct gl_texture_convert {
+ GLint xoffset, yoffset, zoffset; /* Subimage offset */
+ GLint width, height, depth; /* Subimage region */
-/*
- * If the system is little endian and can do 4-byte word stores on
- * non 4-byte-aligned addresses then we can use this optimization.
- */
-#if defined(__i386__)
-#define DO_32BIT_STORES000
+ GLint imageWidth, imageHeight; /* Full image dimensions */
+ GLenum format, type;
+
+ const struct gl_pixelstore_attrib *packing;
+
+ const GLvoid *srcImage;
+ GLvoid *dstImage;
+
+ GLint index;
+};
+
+typedef GLboolean (*convert_func)( struct gl_texture_convert *convert );
+typedef void (*unconvert_func)( struct gl_texture_convert *convert );
+
+#define CONVERT_STRIDE_BIT 0x1
+#define CONVERT_PACKING_BIT 0x2
+
+#ifdef __GNUC__
+#define ERROR_STRING __FUNCTION__
+#else
+#define ERROR_STRING __FILE__ ":" __LINE__
#endif
+#define UNCONVERT_ERROR( format ) \
+do { \
+ static char buffer[128]; \
+ sprintf( buffer, "illegal format %s in " ERROR_STRING "\n", \
+ gl_lookup_enum_by_nr( format ) ); \
+ gl_problem( NULL, buffer ); \
+} while (0)
-/*
- * Convert texture image data into one a specific internal format.
- * Input:
- * dstFormat - the destination internal format
- * dstWidth, dstHeight - the destination image size
- * dstImage - pointer to destination image buffer
- * dstRowStride - bytes to jump between image rows
- * srcWidth, srcHeight - size of texture image
- * srcFormat, srcType - format and datatype of source image
- * srcImage - pointer to user's texture image
- * packing - describes how user's texture image is packed.
- * Return: pointer to resulting image data or NULL if error or out of memory
- * or NULL if we can't process the given image format/type/internalFormat
- * combination.
- *
- * Supported type conversions:
- * srcFormat srcType dstFormat
- * GL_INTENSITY GL_UNSIGNED_BYTE MESA_I8
- * GL_LUMINANCE GL_UNSIGNED_BYTE MESA_L8
- * GL_ALPHA GL_UNSIGNED_BYTE MESA_A8
- * GL_COLOR_INDEX GL_UNSIGNED_BYTE MESA_C8
- * GL_LUMINANCE_ALPHA GL_UNSIGNED_BYTE MESA_A8_L8
- * GL_RGB GL_UNSIGNED_BYTE MESA_R5_G6_B5
- * GL_RGB GL_UNSIGNED_SHORT_5_6_5 MESA_R5_G6_B5
- * GL_RGBA GL_UNSIGNED_BYTE MESA_A4_R4_G4_B4
- * GL_BGRA GL_UNSIGNED_SHORT_4_4_4_4_REV MESA_A4_R4_G4_B4
- * GL_BGRA GL_UNSIGHED_SHORT_1_5_5_5_REV MESA_A1_R5_G5_B5
- * GL_RGBA GL_UNSIGNED_BYTE MESA_A1_R5_G5_B5
- * GL_BGRA GL_UNSIGNED_INT_8_8_8_8_REV MESA_A8_R8_G8_B8
- * GL_RGBA GL_UNSIGNED_BYTE MESA_A8_R8_G8_B8
- * GL_RGB GL_UNSIGNED_BYTE MESA_A8_R8_G8_B8
- * more to be added for new drivers...
- *
- * Notes:
- * Some hardware only supports texture images of specific aspect ratios.
- * This code will do power-of-two image up-scaling if that's needed.
- *
- *
+/* ================================================================
+ * RGBA8888 textures:
*/
-GLboolean
-_mesa_convert_teximage(MesaIntTexFormat dstFormat,
- GLint dstWidth, GLint dstHeight, GLvoid *dstImage,
- GLint dstRowStride,
- GLint srcWidth, GLint srcHeight,
- GLenum srcFormat, GLenum srcType,
- const GLvoid *srcImage,
- const struct gl_pixelstore_attrib *packing)
+
+#define DST_TYPE GLuint
+#define DST_TEXELS_PER_DWORD 1
+
+#define CONVERT_TEXEL( src ) \
+ PACK_COLOR_8888( src[3], src[2], src[1], src[0] )
+
+#define CONVERT_DIRECT
+
+#define SRC_TEXEL_BYTES 4
+
+#define TAG(x) x##_rgba8888_direct
+#define PRESERVE_DST_TYPE
+#include "texutil_tmp.h"
+
+
+#define CONVERT_TEXEL( src ) \
+ PACK_COLOR_8888( src[0], src[1], src[2], src[3] )
+
+#define CONVERT_TEXEL_DWORD( src ) CONVERT_TEXEL( src )
+
+#define SRC_TEXEL_BYTES 4
+
+#define TAG(x) x##_abgr8888_to_rgba8888
+#define PRESERVE_DST_TYPE
+#include "texutil_tmp.h"
+
+
+#define CONVERT_TEXEL( src ) \
+ PACK_COLOR_8888( src[0], src[1], src[2], 0xff )
+
+#define CONVERT_TEXEL_DWORD( src ) CONVERT_TEXEL( src )
+
+#define SRC_TEXEL_BYTES 3
+
+#define TAG(x) x##_bgr888_to_rgba8888
+#include "texutil_tmp.h"
+
+
+#define CONVERT_RGBA8888( name ) \
+static GLboolean \
+convert_##name##_rgba8888( struct gl_texture_convert *convert ) \
+{ \
+ convert_func *tab; \
+ GLint index = convert->index; \
+ \
+ if ( convert->format == GL_ABGR_EXT && \
+ convert->type == GL_UNSIGNED_INT_8_8_8_8_REV ) \
+ { \
+ tab = name##_tab_rgba8888_direct; \
+ } \
+ else if ( convert->format == GL_RGBA && \
+ ( convert->type == GL_UNSIGNED_BYTE || \
+ convert->type == GL_UNSIGNED_INT_8_8_8_8 ) ) \
+ { \
+ tab = name##_tab_abgr8888_to_rgba8888; \
+ } \
+ else if ( convert->format == GL_RGB && \
+ convert->type == GL_UNSIGNED_BYTE ) \
+ { \
+ tab = name##_tab_bgr888_to_rgba8888; \
+ } \
+ else \
+ { \
+ /* Can't handle this source format/type combination */ \
+ return GL_FALSE; \
+ } \
+ \
+ return tab[index]( convert ); \
+}
+
+CONVERT_RGBA8888( texsubimage2d )
+CONVERT_RGBA8888( texsubimage3d )
+
+
+static void
+unconvert_teximage_rgba8888( struct gl_texture_convert *convert )
{
- const GLint wScale = dstWidth / srcWidth; /* must be power of two */
- const GLint hScale = dstHeight / srcHeight; /* must be power of two */
- ASSERT(dstWidth >= srcWidth);
- ASSERT(dstHeight >= srcHeight);
- ASSERT(dstImage);
- ASSERT(srcImage);
- ASSERT(packing);
-
- switch (dstFormat) {
- case MESA_I8:
- case MESA_L8:
- case MESA_A8:
- case MESA_C8:
- if (srcType != GL_UNSIGNED_BYTE ||
- ((srcFormat != GL_INTENSITY) &&
- (srcFormat != GL_LUMINANCE) &&
- (srcFormat != GL_ALPHA) &&
- (srcFormat != GL_COLOR_INDEX))) {
- /* bad internal format / srcFormat combination */
- return GL_FALSE;
- }
- else {
- /* store as 8-bit texels */
- if (wScale == 1 && hScale == 1) {
- /* no scaling needed - fast case */
- const GLubyte *src = (const GLubyte *)
- _mesa_image_address(packing, srcImage, srcWidth, srcHeight,
- srcFormat, srcType, 0, 0, 0);
- const GLint srcStride = _mesa_image_row_stride(packing,
- srcWidth, srcFormat, srcType);
- GLubyte *dst = (GLubyte *) dstImage;
- GLint row;
- for (row = 0; row < dstHeight; row++) {
- MEMCPY(dst, src, dstWidth * sizeof(GLubyte));
- dst += dstRowStride;
- src += srcStride;
- }
- }
- else {
- /* must rescale image */
- GLubyte *dst = (GLubyte *) dstImage;
- GLint row;
- for (row = 0; row < dstHeight; row++) {
- GLint srcRow = row / hScale;
- const GLubyte *src = (const GLubyte *)
- _mesa_image_address(packing, srcImage, srcWidth,
- srcHeight, srcFormat, srcType, 0, srcRow, 0);
- GLint col;
- for (col = 0; col < dstWidth; col++) {
- dst[col] = src[col / wScale];
- }
- dst += dstRowStride;
- }
- }
- }
- break;
-
- case MESA_A8_L8:
- if (srcType != GL_UNSIGNED_BYTE || srcFormat != GL_LUMINANCE_ALPHA) {
- return GL_FALSE;
- }
- else {
- /* store as 16-bit texels */
- if (wScale == 1 && hScale == 1) {
- const GLubyte *src = (const GLubyte *)
- _mesa_image_address(packing, srcImage, srcWidth, srcHeight,
- srcFormat, srcType, 0, 0, 0);
- const GLint srcStride = _mesa_image_row_stride(packing,
- srcWidth, srcFormat, srcType);
- GLushort *dst = (GLushort *) dstImage;
- GLint row, col;
- for (row = 0; row < dstHeight; row++) {
- for (col = 0; col < dstWidth; col++) {
- GLubyte luminance = src[col * 2 + 0];
- GLubyte alpha = src[col * 2 + 1];
- dst[col] = ((GLushort) alpha << 8) | luminance;
- }
- dst = (GLushort *) ((GLubyte *) dst + dstRowStride);
- src += srcStride;
- }
- }
- else {
- /* must rescale */
- GLushort *dst = (GLushort *) dstImage;
- GLint row, col;
- for (row = 0; row < dstHeight; row++) {
- GLint srcRow = row / hScale;
- const GLubyte *src = (const GLubyte *)
- _mesa_image_address(packing, srcImage, srcWidth,
- srcHeight, srcFormat, srcType, 0, srcRow, 0);
- const GLint srcStride = _mesa_image_row_stride(packing,
- srcWidth, srcFormat, srcType);
- for (col = 0; col < dstWidth; col++) {
- GLint srcCol = col / wScale;
- GLubyte luminance = src[srcCol * 2 + 0];
- GLubyte alpha = src[srcCol * 2 + 1];
- dst[col] = ((GLushort) alpha << 8) | luminance;
- }
- dst = (GLushort *) ((GLubyte *) dst + dstRowStride);
- src += srcStride;
- }
- }
- }
- break;
-
- case MESA_R5_G6_B5:
- if (srcFormat == GL_RGB && srcType == GL_UNSIGNED_SHORT_5_6_5) {
- /* special, optimized case */
- if (wScale == 1 && hScale == 1) {
- const GLubyte *src = (const GLubyte *)
- _mesa_image_address(packing, srcImage, srcWidth, srcHeight,
- srcFormat, srcType, 0, 0, 0);
- const GLint srcStride = _mesa_image_row_stride(packing,
- srcWidth, srcFormat, srcType);
- GLushort *dst = (GLushort *) dstImage;
- GLint row;
- for (row = 0; row < dstHeight; row++) {
- MEMCPY(dst, src, dstWidth * sizeof(GLushort));
- src += srcStride;
- dst = (GLushort *) ((GLubyte *) dst + dstRowStride);
- }
- }
- else {
- /* must rescale image */
- GLushort *dst = (GLushort *) dstImage;
- GLint row;
- for (row = 0; row < dstHeight; row++) {
- GLint srcRow = row / hScale;
- const GLushort *src = (const GLushort *)
- _mesa_image_address(packing, srcImage, srcWidth,
- srcHeight, srcFormat, srcType, 0, srcRow, 0);
- GLint col;
- for (col = 0; col < dstWidth; col++) {
- dst[col] = src[col / wScale];
- }
- dst = (GLushort *) ((GLubyte *) dst + dstRowStride);
- }
- }
- }
- else if (srcFormat == GL_RGB && srcType == GL_UNSIGNED_BYTE) {
- /* general case */
- if (wScale == 1 && hScale == 1) {
- const GLubyte *src = (const GLubyte *)
- _mesa_image_address(packing, srcImage, srcWidth, srcHeight,
- srcFormat, srcType, 0, 0, 0);
- const GLint srcStride = _mesa_image_row_stride(packing,
- srcWidth, srcFormat, srcType);
-#ifdef DO_32BIT_STORES
- GLuint *dst = (GLuint *) dstImage;
- GLint row;
- for (row = 0; row < dstHeight; row++) {
- GLint col, col3;
- GLint halfDstWidth = dstWidth >> 1;
- for (col = col3 = 0; col < halfDstWidth; col++, col3 += 6) {
- GLubyte r0 = src[col3 + 0];
- GLubyte g0 = src[col3 + 1];
- GLubyte b0 = src[col3 + 2];
- GLubyte r1 = src[col3 + 3];
- GLubyte g1 = src[col3 + 4];
- GLubyte b1 = src[col3 + 5];
- GLuint d0 = ((r0 & 0xf8) << 8)
- | ((g0 & 0xfc) << 3)
- | ((b0 & 0xf8) >> 3);
- GLuint d1 = ((r1 & 0xf8) << 8)
- | ((g1 & 0xfc) << 3)
- | ((b1 & 0xf8) >> 3);
- dst[col] = (d1 << 16) | d0;
- }
- src += srcStride;
- dst = (GLuint *) ((GLubyte *) dst + dstRowStride);
- }
-#else /* 16-bit stores */
- GLushort *dst = (GLushort *) dstImage;
- GLint row;
- for (row = 0; row < dstHeight; row++) {
- GLint col, col3;
- for (col = col3 = 0; col < dstWidth; col++, col3 += 3) {
- GLubyte r = src[col3 + 0];
- GLubyte g = src[col3 + 1];
- GLubyte b = src[col3 + 2];
- dst[col] = ((r & 0xf8) << 8)
- | ((g & 0xfc) << 3)
- | ((b & 0xf8) >> 3);
- }
- src += srcStride;
- dst = (GLushort *) ((GLubyte *) dst + dstRowStride);
- }
-#endif
- }
- else {
- /* must rescale image */
- GLushort *dst = (GLushort *) dstImage;
- GLint row;
- for (row = 0; row < dstHeight; row++) {
- GLint srcRow = row / hScale;
- const GLubyte *src = (const GLubyte *)
- _mesa_image_address(packing, srcImage, srcWidth,
- srcHeight, srcFormat, srcType, 0, srcRow, 0);
- GLint col;
- for (col = 0; col < dstWidth; col++) {
- GLint col3 = (col / wScale) * 3;
- GLubyte r = src[col3 + 0];
- GLubyte g = src[col3 + 1];
- GLubyte b = src[col3 + 2];
- dst[col] = ((r & 0xf8) << 8)
- | ((g & 0xfc) << 3)
- | ((b & 0xf8) >> 3);
- }
- dst = (GLushort *) ((GLubyte *) dst + dstRowStride);
- }
- }
- }
- else if (srcFormat == GL_RGBA && srcType == GL_UNSIGNED_BYTE) {
- /* general case (used by Quake3) */
- if (wScale == 1 && hScale == 1) {
- const GLubyte *src = (const GLubyte *)
- _mesa_image_address(packing, srcImage, srcWidth, srcHeight,
- srcFormat, srcType, 0, 0, 0);
- const GLint srcStride = _mesa_image_row_stride(packing,
- srcWidth, srcFormat, srcType);
-#ifdef DO_32BIT_STORES
- GLuint *dst = dstImage;
- GLint row;
- for (row = 0; row < dstHeight; row++) {
- GLint col, col4;
- GLint halfDstWidth = dstWidth >> 1;
- for (col = col4 = 0; col < halfDstWidth; col++, col4 += 8) {
- GLubyte r0 = src[col4 + 0];
- GLubyte g0 = src[col4 + 1];
- GLubyte b0 = src[col4 + 2];
- GLubyte r1 = src[col4 + 4];
- GLubyte g1 = src[col4 + 5];
- GLubyte b1 = src[col4 + 6];
- GLuint d0 = ((r0 & 0xf8) << 8)
- | ((g0 & 0xfc) << 3)
- | ((b0 & 0xf8) >> 3);
- GLuint d1 = ((r1 & 0xf8) << 8)
- | ((g1 & 0xfc) << 3)
- | ((b1 & 0xf8) >> 3);
- dst[col] = (d1 << 16) | d0;
- }
- src += srcStride;
- dst = (GLuint *) ((GLubyte *) dst + dstRowStride);
- }
-#else /* 16-bit stores */
- GLushort *dst = (GLushort *) dstImage;
- GLint row;
- for (row = 0; row < dstHeight; row++) {
- GLint col, col4;
- for (col = col4 = 0; col < dstWidth; col++, col4 += 4) {
- GLubyte r = src[col4 + 0];
- GLubyte g = src[col4 + 1];
- GLubyte b = src[col4 + 2];
- dst[col] = ((r & 0xf8) << 8)
- | ((g & 0xfc) << 3)
- | ((b & 0xf8) >> 3);
- }
- src += srcStride;
- dst = (GLushort *) ((GLubyte *) dst + dstRowStride);
- }
-#endif
- }
- else {
- /* must rescale image */
- GLushort *dst = (GLushort *) dstImage;
- GLint row;
- for (row = 0; row < dstHeight; row++) {
- GLint srcRow = row / hScale;
- const GLubyte *src = (const GLubyte *)
- _mesa_image_address(packing, srcImage, srcWidth,
- srcHeight, srcFormat, srcType, 0, srcRow, 0);
- GLint col;
- for (col = 0; col < dstWidth; col++) {
- GLint col4 = (col / wScale) * 4;
- GLubyte r = src[col4 + 0];
- GLubyte g = src[col4 + 1];
- GLubyte b = src[col4 + 2];
- dst[col] = ((r & 0xf8) << 8)
- | ((g & 0xfc) << 3)
- | ((b & 0xf8) >> 3);
- }
- dst = (GLushort *) ((GLubyte *) dst + dstRowStride);
- }
- }
- }
- else {
- /* can't handle this srcFormat/srcType combination */
- return GL_FALSE;
- }
- break;
-
- case MESA_A4_R4_G4_B4:
- /* store as 16-bit texels (GR_TEXFMT_ARGB_4444) */
- if (srcFormat == GL_BGRA && srcType == GL_UNSIGNED_SHORT_4_4_4_4_REV){
- /* special, optimized case */
- if (wScale == 1 && hScale == 1) {
- const GLubyte *src = (const GLubyte *)
- _mesa_image_address(packing, srcImage, srcWidth, srcHeight,
- srcFormat, srcType, 0, 0, 0);
- const GLint srcStride = _mesa_image_row_stride(packing,
- srcWidth, srcFormat, srcType);
- GLushort *dst = (GLushort *) dstImage;
- GLint row;
- for (row = 0; row < dstHeight; row++) {
- MEMCPY(dst, src, dstWidth * sizeof(GLushort));
- src += srcStride;
- dst = (GLushort *) ((GLubyte *) dst + dstRowStride);
- }
- }
- else {
- /* must rescale image */
- GLushort *dst = (GLushort *) dstImage;
- GLint row;
- for (row = 0; row < dstHeight; row++) {
- GLint srcRow = row / hScale;
- const GLushort *src = (const GLushort *)
- _mesa_image_address(packing, srcImage, srcWidth,
- srcHeight, srcFormat, srcType, 0, srcRow, 0);
- GLint col;
- for (col = 0; col < dstWidth; col++) {
- dst[col] = src[col / wScale];
- }
- dst = (GLushort *) ((GLubyte *) dst + dstRowStride);
- }
- }
- }
- else if (srcFormat == GL_RGBA && srcType == GL_UNSIGNED_BYTE) {
- /* general case */
- if (wScale == 1 && hScale == 1) {
- const GLubyte *src = (const GLubyte *)
- _mesa_image_address(packing, srcImage, srcWidth, srcHeight,
- srcFormat, srcType, 0, 0, 0);
- const GLint srcStride = _mesa_image_row_stride(packing,
- srcWidth, srcFormat, srcType);
-#ifdef DO_32BIT_STORES
- GLuint *dst = dstImage;
- GLint row;
- for (row = 0; row < dstHeight; row++) {
- GLint col, col4;
- GLint halfDstWidth = dstWidth >> 1;
- for (col = col4 = 0; col < halfDstWidth; col++, col4 += 8) {
- GLubyte r0 = src[col4 + 0];
- GLubyte g0 = src[col4 + 1];
- GLubyte b0 = src[col4 + 2];
- GLubyte a0 = src[col4 + 3];
- GLubyte r1 = src[col4 + 4];
- GLubyte g1 = src[col4 + 5];
- GLubyte b1 = src[col4 + 6];
- GLubyte a1 = src[col4 + 7];
- GLuint d0 = ((a0 & 0xf0) << 8)
- | ((r0 & 0xf0) << 4)
- | ((g0 & 0xf0) )
- | ((b0 & 0xf0) >> 4);
- GLuint d1 = ((a1 & 0xf0) << 8)
- | ((r1 & 0xf0) << 4)
- | ((g1 & 0xf0) )
- | ((b1 & 0xf0) >> 4);
- dst[col] = (d1 << 16) | d0;
- }
- src += srcStride;
- dst = (GLuint *) ((GLubyte *) dst + dstRowStride);
- }
-#else /* 16-bit stores */
- GLushort *dst = (GLushort *) dstImage;
- GLint row;
- for (row = 0; row < dstHeight; row++) {
- GLint col, col4;
- for (col = col4 = 0; col < dstWidth; col++, col4 += 4) {
- GLubyte r = src[col4 + 0];
- GLubyte g = src[col4 + 1];
- GLubyte b = src[col4 + 2];
- GLubyte a = src[col4 + 3];
- dst[col] = ((a & 0xf0) << 8)
- | ((r & 0xf0) << 4)
- | ((g & 0xf0) )
- | ((b & 0xf0) >> 4);
- }
- src += srcStride;
- dst = (GLushort *) ((GLubyte *) dst + dstRowStride);
- }
-#endif
- }
- else {
- /* must rescale image */
- GLushort *dst = (GLushort *) dstImage;
- GLint row;
- for (row = 0; row < dstHeight; row++) {
- GLint srcRow = row / hScale;
- const GLubyte *src = (const GLubyte *)
- _mesa_image_address(packing, srcImage, srcWidth,
- srcHeight, srcFormat, srcType, 0, srcRow, 0);
- GLint col;
- for (col = 0; col < dstWidth; col++) {
- GLint col4 = (col / wScale) * 4;
- GLubyte r = src[col4 + 0];
- GLubyte g = src[col4 + 1];
- GLubyte b = src[col4 + 2];
- GLubyte a = src[col4 + 3];
- dst[col] = ((a & 0xf0) << 8)
- | ((r & 0xf0) << 4)
- | ((g & 0xf0) )
- | ((b & 0xf0) >> 4);
- }
- dst = (GLushort *) ((GLubyte *) dst + dstRowStride);
- }
- }
- }
- else {
- /* can't handle this format/srcType combination */
- return GL_FALSE;
- }
- break;
-
- case MESA_A1_R5_G5_B5:
- /* store as 16-bit texels (GR_TEXFMT_ARGB_1555) */
- if (srcFormat == GL_BGRA && srcType == GL_UNSIGNED_SHORT_1_5_5_5_REV){
- /* special, optimized case */
- if (wScale == 1 && hScale == 1) {
- const GLubyte *src = (const GLubyte *)
- _mesa_image_address(packing, srcImage, srcWidth, srcHeight,
- srcFormat, srcType, 0, 0, 0);
- const GLint srcStride = _mesa_image_row_stride(packing,
- srcWidth, srcFormat, srcType);
- GLushort *dst = (GLushort *) dstImage;
- GLint row;
- for (row = 0; row < dstHeight; row++) {
- MEMCPY(dst, src, dstWidth * sizeof(GLushort));
- src += srcStride;
- dst = (GLushort *) ((GLubyte *) dst + dstRowStride);
- }
- }
- else {
- /* must rescale image */
- GLushort *dst = (GLushort *) dstImage;
- GLint row;
- for (row = 0; row < dstHeight; row++) {
- GLint srcRow = row / hScale;
- const GLushort *src = (const GLushort *)
- _mesa_image_address(packing, srcImage, srcWidth,
- srcHeight, srcFormat, srcType, 0, srcRow, 0);
- GLint col;
- for (col = 0; col < dstWidth; col++) {
- dst[col] = src[col / wScale];
- }
- dst = (GLushort *) ((GLubyte *) dst + dstRowStride);
- }
- }
- }
- else if (srcFormat == GL_RGBA && srcType == GL_UNSIGNED_BYTE) {
- /* general case */
- if (wScale == 1 && hScale == 1) {
- const GLubyte *src = (const GLubyte *)
- _mesa_image_address(packing, srcImage, srcWidth, srcHeight,
- srcFormat, srcType, 0, 0, 0);
- const GLint srcStride = _mesa_image_row_stride(packing,
- srcWidth, srcFormat, srcType);
- GLushort *dst = (GLushort *) dstImage;
- GLint row;
- for (row = 0; row < dstHeight; row++) {
- GLint col, col4;
- for (col = col4 = 0; col < dstWidth; col++, col4 += 4) {
- GLubyte r = src[col4 + 0];
- GLubyte g = src[col4 + 1];
- GLubyte b = src[col4 + 2];
- GLubyte a = src[col4 + 3];
- dst[col] = ((a & 0x80) << 8)
- | ((r & 0xf8) << 7)
- | ((g & 0xf8) << 2)
- | ((b & 0xf8) >> 3);
- }
- src += srcStride;
- dst = (GLushort *) ((GLubyte *) dst + dstRowStride);
- }
- }
- else {
- /* must rescale image */
- GLushort *dst = (GLushort *) dstImage;
- GLint row;
- for (row = 0; row < dstHeight; row++) {
- GLint srcRow = row / hScale;
- const GLubyte *src = (const GLubyte *)
- _mesa_image_address(packing, srcImage, srcWidth,
- srcHeight, srcFormat, srcType, 0, srcRow, 0);
- GLint col;
- for (col = 0; col < dstWidth; col++) {
- GLint col4 = (col / wScale) * 4;
- GLubyte r = src[col4 + 0];
- GLubyte g = src[col4 + 1];
- GLubyte b = src[col4 + 2];
- GLubyte a = src[col4 + 3];
- dst[col] = ((a & 0x80) << 8)
- | ((r & 0xf8) << 7)
- | ((g & 0xf8) << 2)
- | ((b & 0xf8) >> 3);
- }
- dst = (GLushort *) ((GLubyte *) dst + dstRowStride);
- }
- }
- }
- else {
- /* can't handle this source format/type combination */
- return GL_FALSE;
- }
- break;
-
- case MESA_A8_R8_G8_B8:
- case MESA_FF_R8_G8_B8:
- /* 32-bit texels */
- if (srcFormat == GL_BGRA && srcType == GL_UNSIGNED_INT_8_8_8_8_REV){
- /* special, optimized case */
- if (wScale == 1 && hScale == 1) {
- const GLubyte *src = (const GLubyte *)
- _mesa_image_address(packing, srcImage, srcWidth, srcHeight,
- srcFormat, srcType, 0, 0, 0);
- const GLint srcStride = _mesa_image_row_stride(packing,
- srcWidth, srcFormat, srcType);
- GLuint *dst = (GLuint *) dstImage;
- GLint row;
- for (row = 0; row < dstHeight; row++) {
- MEMCPY(dst, src, dstWidth * sizeof(GLuint));
- src += srcStride;
- dst = (GLuint *) ((GLubyte *) dst + dstRowStride);
- }
- }
- else {
- /* must rescale image */
- GLuint *dst = (GLuint *) dstImage;
- GLint row;
- for (row = 0; row < dstHeight; row++) {
- GLint srcRow = row / hScale;
- const GLuint *src = (const GLuint *)
- _mesa_image_address(packing, srcImage, srcWidth,
- srcHeight, srcFormat, srcType, 0, srcRow, 0);
- GLint col;
- for (col = 0; col < dstWidth; col++) {
- dst[col] = src[col / wScale];
- }
- dst = (GLuint *) ((GLubyte *) dst + dstRowStride);
- }
- }
- }
- else if (srcFormat == GL_RGBA && srcType == GL_UNSIGNED_BYTE) {
- /* general case */
- if (wScale == 1 && hScale == 1) {
- const GLubyte *src = (const GLubyte *)
- _mesa_image_address(packing, srcImage, srcWidth, srcHeight,
- srcFormat, srcType, 0, 0, 0);
- const GLint srcStride = _mesa_image_row_stride(packing,
- srcWidth, srcFormat, srcType);
- GLuint *dst = (GLuint *) dstImage;
- GLint row;
- for (row = 0; row < dstHeight; row++) {
- GLint col, col4;
- for (col = col4 = 0; col < dstWidth; col++, col4 += 4) {
- GLubyte r = src[col4 + 0];
- GLubyte g = src[col4 + 1];
- GLubyte b = src[col4 + 2];
- GLubyte a = src[col4 + 3];
- dst[col] = (a << 24) | (r << 16) | (g << 8) | b;
- }
- src += srcStride;
- dst = (GLuint *) ((GLubyte *) dst + dstRowStride);
- }
- }
- else {
- /* must rescale image */
- GLuint *dst = (GLuint *) dstImage;
- GLint row;
- for (row = 0; row < dstHeight; row++) {
- GLint srcRow = row / hScale;
- const GLubyte *src = (const GLubyte *)
- _mesa_image_address(packing, srcImage, srcWidth,
- srcHeight, srcFormat, srcType, 0, srcRow, 0);
- GLint col;
- for (col = 0; col < dstWidth; col++) {
- GLint col4 = (col / wScale) * 4;
- GLubyte r = src[col4 + 0];
- GLubyte g = src[col4 + 1];
- GLubyte b = src[col4 + 2];
- GLubyte a = src[col4 + 3];
- dst[col] = (a << 24) | (r << 16) | (g << 8) | b;
- }
- dst = (GLuint *) ((GLubyte *) dst + dstRowStride);
- }
- }
- }
- else if (srcFormat == GL_RGB && srcType == GL_UNSIGNED_BYTE) {
- /* general case */
- if (wScale == 1 && hScale == 1) {
- const GLubyte *src = (const GLubyte *)
- _mesa_image_address(packing, srcImage, srcWidth, srcHeight,
- srcFormat, srcType, 0, 0, 0);
- const GLint srcStride = _mesa_image_row_stride(packing,
- srcWidth, srcFormat, srcType);
- GLuint *dst = (GLuint *) dstImage;
- GLint row;
- for (row = 0; row < dstHeight; row++) {
- GLint col, col3;
- for (col = col3 = 0; col < dstWidth; col++, col3 += 3) {
- GLubyte r = src[col3 + 0];
- GLubyte g = src[col3 + 1];
- GLubyte b = src[col3 + 2];
- GLubyte a = 255;
- dst[col] = (a << 24) | (r << 16) | (g << 8) | b;
- }
- src += srcStride;
- dst = (GLuint *) ((GLubyte *) dst + dstRowStride);
- }
- }
- else {
- /* must rescale image */
- GLuint *dst = (GLuint *) dstImage;
- GLint row;
- for (row = 0; row < dstHeight; row++) {
- GLint srcRow = row / hScale;
- const GLubyte *src = (const GLubyte *)
- _mesa_image_address(packing, srcImage, srcWidth,
- srcHeight, srcFormat, srcType, 0, srcRow, 0);
- GLint col;
- for (col = 0; col < dstWidth; col++) {
- GLint col3 = (col / wScale) * 3;
- GLubyte r = src[col3 + 0];
- GLubyte g = src[col3 + 1];
- GLubyte b = src[col3 + 2];
- GLubyte a = 255;
- dst[col] = (a << 24) | (r << 16) | (g << 8) | b;
- }
- dst = (GLuint *) ((GLubyte *) dst + dstRowStride);
- }
- }
- }
- else {
- /* can't handle this source format/type combination */
- return GL_FALSE;
- }
- if (dstFormat == MESA_FF_R8_G8_B8) {
- /* set alpha bytes to 0xff */
- GLint i;
- GLubyte *dst = (GLubyte *) dstImage;
- for (i = 0; i < dstWidth * dstHeight; i++) {
- dst[i * 4 + 3] = 0xff;
- }
- }
- break;
-
- default:
- /* unexpected internal format! */
- return GL_FALSE;
+ const GLubyte *src = (const GLubyte *)convert->srcImage;
+ GLint texels, i;
+
+ texels = convert->width * convert->height * convert->depth;
+
+ switch ( convert->format ) {
+ case GL_RGBA: {
+ GLuint *dst = (GLuint *)convert->dstImage;
+ for ( i = 0 ; i < texels ; i++ ) {
+ *dst++ = PACK_COLOR_8888( src[0], src[1], src[2], src[3] );
+ src += 4;
+ }
+ break;
+ }
+ case GL_RGB: {
+ GLubyte *dst = (GLubyte *)convert->dstImage;
+ for ( i = 0 ; i < texels ; i++ ) {
+ *dst++ = src[3];
+ *dst++ = src[2];
+ *dst++ = src[1];
+ src += 4;
+ }
+ break;
+ }
+ default:
+ UNCONVERT_ERROR( convert->format );
+ break;
}
- return GL_TRUE;
}
-/*
- * Replace a subregion of a texture image with new data.
- * Input:
- * dstFormat - destination image format
- * dstXoffset, dstYoffset - destination for new subregion (in texels)
- * dstWidth, dstHeight - total size of dest image (in texels)
- * dstImage - pointer to dest image
- * dstRowStride - bytes to jump between image rows (in bytes)
- * width, height - size of region to copy/replace (in texels)
- * srcWidth, srcHeight - size of the corresponding gl_texture_image
- * srcFormat, srcType - source image format and datatype
- * srcImage - source image
- * packing - source image packing information.
- * Return: GL_TRUE or GL_FALSE for success, failure
- *
- * Notes:
- * Like _mesa_convert_teximage(), we can do power-of-two image scaling
- * to accomodate hardware with texture image aspect ratio constraints.
- * dstWidth / srcWidth is used to compute the horizontal scaling factor and
- * dstHeight / srcHeight is used to compute the vertical scaling factor.
+/* ================================================================
+ * ABGR8888 textures:
*/
-GLboolean
-_mesa_convert_texsubimage(MesaIntTexFormat dstFormat,
- GLint dstXoffset, GLint dstYoffset,
- GLint dstWidth, GLint dstHeight, GLvoid *dstImage,
- GLint dstRowStride,
- GLint width, GLint height,
- GLint srcWidth, GLint srcHeight,
- GLenum srcFormat, GLenum srcType,
- const GLvoid *srcImage,
- const struct gl_pixelstore_attrib *packing)
+
+#define DST_TYPE GLuint
+#define DST_TEXELS_PER_DWORD 1
+
+#define CONVERT_TEXEL( src ) \
+ PACK_COLOR_8888( src[3], src[2], src[1], src[0] )
+
+#define CONVERT_DIRECT
+
+#define SRC_TEXEL_BYTES 4
+
+#define TAG(x) x##_abgr8888_direct
+#define PRESERVE_DST_TYPE
+#include "texutil_tmp.h"
+
+
+#define CONVERT_TEXEL( src ) \
+ PACK_COLOR_8888( 0xff, src[2], src[1], src[0] )
+
+#define CONVERT_TEXEL_DWORD( src ) CONVERT_TEXEL( src )
+
+#define SRC_TEXEL_BYTES 3
+
+#define TAG(x) x##_bgr888_to_abgr8888
+#include "texutil_tmp.h"
+
+
+#define CONVERT_ABGR8888( name ) \
+static GLboolean \
+convert_##name##_abgr8888( struct gl_texture_convert *convert ) \
+{ \
+ convert_func *tab; \
+ GLint index = convert->index; \
+ \
+ if ( convert->format == GL_RGBA && \
+ convert->type == GL_UNSIGNED_BYTE ) \
+ { \
+ tab = name##_tab_abgr8888_direct; \
+ } \
+ else if ( convert->format == GL_RGB && \
+ convert->type == GL_UNSIGNED_BYTE ) \
+ { \
+ tab = name##_tab_bgr888_to_abgr8888; \
+ } \
+ else \
+ { \
+ /* Can't handle this source format/type combination */ \
+ return GL_FALSE; \
+ } \
+ \
+ return tab[index]( convert ); \
+}
+
+CONVERT_ABGR8888( texsubimage2d )
+CONVERT_ABGR8888( texsubimage3d )
+
+
+static void
+unconvert_teximage_abgr8888( struct gl_texture_convert *convert )
{
- const GLint wScale = dstWidth / srcWidth; /* must be power of two */
- const GLint hScale = dstHeight / srcHeight; /* must be power of two */
- ASSERT(dstWidth >= srcWidth);
- ASSERT(dstHeight >= srcHeight);
- ASSERT(dstImage);
- ASSERT(srcImage);
- ASSERT(packing);
-
- width *= wScale;
- height *= hScale;
- dstXoffset *= wScale;
- dstYoffset *= hScale;
-
- /* XXX hscale != 1 and wscale != 1 not tested!!!! */
-
- switch (dstFormat) {
- case MESA_I8:
- case MESA_L8:
- case MESA_A8:
- case MESA_C8:
- if (srcType != GL_UNSIGNED_BYTE ||
- ((srcFormat != GL_INTENSITY) &&
- (srcFormat != GL_LUMINANCE) &&
- (srcFormat != GL_ALPHA) &&
- (srcFormat != GL_COLOR_INDEX))) {
- /* bad internal format / srcFormat combination */
- return GL_FALSE;
- }
- else {
- /* store as 8-bit texels */
- if (wScale == 1 && hScale == 1) {
- /* no scaling needed - fast case */
- const GLubyte *src = (const GLubyte *)
- _mesa_image_address(packing, srcImage, srcWidth, srcHeight,
- srcFormat, srcType, 0, 0, 0);
- const GLint srcRowStride = _mesa_image_row_stride(packing,
- width, srcFormat, srcType);
- GLubyte *dst = (GLubyte *) dstImage
- + dstYoffset * dstRowStride + dstXoffset;
- const GLint rowSize = width * sizeof(GLubyte);
- GLint row;
- if (dstRowStride == srcRowStride && dstRowStride == rowSize) {
- MEMCPY(dst, src, rowSize * height);
- }
- else {
- for (row = 0; row < height; row++) {
- MEMCPY(dst, src, rowSize);
- dst += dstRowStride;
- src += srcRowStride;
- }
- }
- }
- else {
- /* must rescale image */
- GLubyte *dst = (GLubyte *) dstImage
- + dstYoffset * dstRowStride + dstXoffset;
- GLint row;
- for (row = 0; row < height; row++) {
- GLint srcRow = row / hScale;
- const GLubyte *src = (const GLubyte *)
- _mesa_image_address(packing, srcImage, srcWidth,
- srcHeight, srcFormat, srcType, 0, srcRow, 0);
- GLint col;
- for (col = 0; col < width; col++) {
- dst[col] = src[col / wScale];
- }
- dst += dstRowStride;
- }
- }
- }
- break;
-
- case MESA_A8_L8:
- if (srcType != GL_UNSIGNED_BYTE || srcFormat != GL_LUMINANCE_ALPHA) {
- return GL_FALSE;
- }
- else {
- /* store as 16-bit texels */
- if (wScale == 1 && hScale == 1) {
- const GLubyte *src = (const GLubyte *)
- _mesa_image_address(packing, srcImage, srcWidth, srcHeight,
- srcFormat, srcType, 0, 0, 0);
- const GLint srcStride = _mesa_image_row_stride(packing,
- width, srcFormat, srcType);
- GLushort *dst = (GLushort *) ((GLubyte *) dstImage
- + dstYoffset * dstRowStride) + dstXoffset;
- GLint row, col;
- for (row = 0; row < height; row++) {
- for (col = 0; col < width; col++) {
- GLubyte luminance = src[col * 2 + 0];
- GLubyte alpha = src[col * 2 + 1];
- dst[col] = ((GLushort) alpha << 8) | luminance;
- }
- dst = (GLushort *) ((GLubyte *) dst + dstRowStride);
- src += srcStride;
- }
- }
- else {
- /* must rescale */
- GLushort *dst = (GLushort *) ((GLubyte *) dstImage
- + dstYoffset * dstRowStride) + dstXoffset;
- GLint row, col;
- for (row = 0; row < height; row++) {
- GLint srcRow = row / hScale;
- const GLubyte *src = (const GLubyte *)
- _mesa_image_address(packing, srcImage, srcWidth,
- srcHeight, srcFormat, srcType, 0, srcRow, 0);
- const GLint srcStride = _mesa_image_row_stride(packing,
- width, srcFormat, srcType);
- for (col = 0; col < width; col++) {
- GLint srcCol = col / wScale;
- GLubyte luminance = src[srcCol * 2 + 0];
- GLubyte alpha = src[srcCol * 2 + 1];
- dst[col] = ((GLushort) alpha << 8) | luminance;
- }
- dst = (GLushort *) ((GLubyte *) dst + dstRowStride);
- src += srcStride;
- }
- }
- }
- break;
-
- case MESA_R5_G6_B5:
- if (srcFormat == GL_RGB && srcType == GL_UNSIGNED_SHORT_5_6_5) {
- /* special, optimized case */
- if (wScale == 1 && hScale == 1) {
- const GLubyte *src = (const GLubyte *)
- _mesa_image_address(packing, srcImage, srcWidth, srcHeight,
- srcFormat, srcType, 0, 0, 0);
- const GLint srcStride = _mesa_image_row_stride(packing,
- width, srcFormat, srcType);
- GLushort *dst = (GLushort *) ((GLubyte *) dstImage
- + dstYoffset * dstRowStride) + dstXoffset;
- GLint row;
- for (row = 0; row < height; row++) {
- MEMCPY(dst, src, width * sizeof(GLushort));
- src += srcStride;
- dst = (GLushort *) ((GLubyte *) dst + dstRowStride);
- }
- }
- else {
- /* must rescale image */
- GLushort *dst = (GLushort *) ((GLubyte *) dstImage
- + dstYoffset * dstRowStride) + dstXoffset;
- GLint row;
- for (row = 0; row < height; row++) {
- GLint srcRow = row / hScale;
- const GLushort *src = (const GLushort *)
- _mesa_image_address(packing, srcImage, srcWidth,
- srcHeight, srcFormat, srcType, 0, srcRow, 0);
- GLint col;
- for (col = 0; col < width; col++) {
- dst[col] = src[col / wScale];
- }
- dst = (GLushort *) ((GLubyte *) dst + dstRowStride);
- }
- }
- }
- else if (srcFormat == GL_RGB && srcType == GL_UNSIGNED_BYTE) {
- /* general case */
- if (wScale == 1 && hScale == 1) {
- const GLubyte *src = (const GLubyte *)
- _mesa_image_address(packing, srcImage, srcWidth, srcHeight,
- srcFormat, srcType, 0, 0, 0);
- const GLint srcStride = _mesa_image_row_stride(packing,
- width, srcFormat, srcType);
- GLushort *dst = (GLushort *) ((GLubyte *) dstImage
- + dstYoffset * dstRowStride) + dstXoffset;
- GLint row;
- for (row = 0; row < height; row++) {
- GLint col, col3;
- for (col = col3 = 0; col < width; col++, col3 += 3) {
- GLubyte r = src[col3 + 0];
- GLubyte g = src[col3 + 1];
- GLubyte b = src[col3 + 2];
- dst[col] = ((r & 0xf8) << 8)
- | ((g & 0xfc) << 3)
- | ((b & 0xf8) >> 3);
- }
- src += srcStride;
- dst = (GLushort *) ((GLubyte *) dst + dstRowStride);
- }
- }
- else {
- /* must rescale image */
- GLushort *dst = (GLushort *) ((GLubyte *) dstImage
- + dstYoffset * dstRowStride) + dstXoffset;
- GLint row;
- for (row = 0; row < height; row++) {
- GLint srcRow = row / hScale;
- const GLubyte *src = (const GLubyte *)
- _mesa_image_address(packing, srcImage, srcWidth,
- srcHeight, srcFormat, srcType, 0, srcRow, 0);
- GLint col;
- for (col = 0; col < width; col++) {
- GLint col3 = (col / wScale) * 3;
- GLubyte r = src[col3 + 0];
- GLubyte g = src[col3 + 1];
- GLubyte b = src[col3 + 2];
- dst[col] = ((r & 0xf8) << 8)
- | ((g & 0xfc) << 3)
- | ((b & 0xf8) >> 3);
- }
- dst = (GLushort *) ((GLubyte *) dst + dstRowStride);
- }
- }
- }
- else if (srcFormat == GL_RGBA && srcType == GL_UNSIGNED_BYTE) {
- /* general case (used by Quake3) */
- if (wScale == 1 && hScale == 1) {
- const GLubyte *src = (const GLubyte *)
- _mesa_image_address(packing, srcImage, srcWidth, srcHeight,
- srcFormat, srcType, 0, 0, 0);
- const GLint srcStride = _mesa_image_row_stride(packing,
- width, srcFormat, srcType);
- GLushort *dst = (GLushort *) ((GLubyte *) dstImage
- + dstYoffset * dstRowStride) + dstXoffset;
- GLint row;
- for (row = 0; row < height; row++) {
- GLint col, col4;
- for (col = col4 = 0; col < width; col++, col4 += 4) {
- GLubyte r = src[col4 + 0];
- GLubyte g = src[col4 + 1];
- GLubyte b = src[col4 + 2];
- dst[col] = ((r & 0xf8) << 8)
- | ((g & 0xfc) << 3)
- | ((b & 0xf8) >> 3);
- }
- src += srcStride;
- dst = (GLushort *) ((GLubyte *) dst + dstRowStride);
- }
- }
- else {
- /* must rescale image */
- GLushort *dst = (GLushort *) ((GLubyte *) dstImage
- + dstYoffset * dstRowStride) + dstXoffset;
- GLint row;
- for (row = 0; row < height; row++) {
- GLint srcRow = row / hScale;
- const GLubyte *src = (const GLubyte *)
- _mesa_image_address(packing, srcImage, srcWidth,
- srcHeight, srcFormat, srcType, 0, srcRow, 0);
- GLint col;
- for (col = 0; col < width; col++) {
- GLint col4 = (col / wScale) * 4;
- GLubyte r = src[col4 + 0];
- GLubyte g = src[col4 + 1];
- GLubyte b = src[col4 + 2];
- dst[col] = ((r & 0xf8) << 8)
- | ((g & 0xfc) << 3)
- | ((b & 0xf8) >> 3);
- }
- dst = (GLushort *) ((GLubyte *) dst + dstRowStride);
- }
- }
- }
- else {
- /* can't handle this srcFormat/srcType combination */
- return GL_FALSE;
- }
- break;
-
- case MESA_A4_R4_G4_B4:
- /* store as 16-bit texels (GR_TEXFMT_ARGB_4444) */
- if (srcFormat == GL_BGRA && srcType == GL_UNSIGNED_SHORT_4_4_4_4_REV){
- /* special, optimized case */
- if (wScale == 1 && hScale == 1) {
- const GLubyte *src = (const GLubyte *)
- _mesa_image_address(packing, srcImage, srcWidth, srcHeight,
- srcFormat, srcType, 0, 0, 0);
- const GLint srcStride = _mesa_image_row_stride(packing,
- width, srcFormat, srcType);
- GLushort *dst = (GLushort *) ((GLubyte *) dstImage
- + dstYoffset * dstRowStride) + dstXoffset;
- GLint row;
- for (row = 0; row < height; row++) {
- MEMCPY(dst, src, width * sizeof(GLushort));
- src += srcStride;
- dst = (GLushort *) ((GLubyte *) dst + dstRowStride);
- }
- }
- else {
- /* must rescale image */
- GLushort *dst = (GLushort *) ((GLubyte *) dstImage
- + dstYoffset * dstRowStride) + dstXoffset;
- GLint row;
- for (row = 0; row < height; row++) {
- GLint srcRow = row / hScale;
- const GLushort *src = (const GLushort *)
- _mesa_image_address(packing, srcImage, srcWidth,
- srcHeight, srcFormat, srcType, 0, srcRow, 0);
- GLint col;
- for (col = 0; col < width; col++) {
- dst[col] = src[col / wScale];
- }
- dst = (GLushort *) ((GLubyte *) dst + dstRowStride);
- }
- }
- }
- else if (srcFormat == GL_RGBA && srcType == GL_UNSIGNED_BYTE) {
- /* general case */
- if (wScale == 1 && hScale == 1) {
- const GLubyte *src = (const GLubyte *)
- _mesa_image_address(packing, srcImage, srcWidth, srcHeight,
- srcFormat, srcType, 0, 0, 0);
- const GLint srcStride = _mesa_image_row_stride(packing,
- width, srcFormat, srcType);
- GLushort *dst = (GLushort *) ((GLubyte *) dstImage
- + dstYoffset * dstRowStride) + dstXoffset;
- GLint row;
- for (row = 0; row < height; row++) {
- GLint col, col4;
- for (col = col4 = 0; col < width; col++, col4 += 4) {
- GLubyte r = src[col4 + 0];
- GLubyte g = src[col4 + 1];
- GLubyte b = src[col4 + 2];
- GLubyte a = src[col4 + 3];
- dst[col] = ((a & 0xf0) << 8)
- | ((r & 0xf0) << 4)
- | ((g & 0xf0) )
- | ((b & 0xf0) >> 4);
- }
- src += srcStride;
- dst = (GLushort *) ((GLubyte *) dst + dstRowStride);
- }
- }
- else {
- /* must rescale image */
- GLushort *dst = (GLushort *) ((GLubyte *) dstImage
- + dstYoffset * dstRowStride) + dstXoffset;
- GLint row;
- for (row = 0; row < height; row++) {
- GLint srcRow = row / hScale;
- const GLubyte *src = (const GLubyte *)
- _mesa_image_address(packing, srcImage, srcWidth,
- srcHeight, srcFormat, srcType, 0, srcRow, 0);
- GLint col;
- for (col = 0; col < width; col++) {
- GLint col4 = (col / wScale) * 4;
- GLubyte r = src[col4 + 0];
- GLubyte g = src[col4 + 1];
- GLubyte b = src[col4 + 2];
- GLubyte a = src[col4 + 3];
- dst[col] = ((a & 0xf0) << 8)
- | ((r & 0xf0) << 4)
- | ((g & 0xf0) )
- | ((b & 0xf0) >> 4);
- }
- dst = (GLushort *) ((GLubyte *) dst + dstRowStride);
- }
- }
- }
- else {
- /* can't handle this format/srcType combination */
- return GL_FALSE;
- }
- break;
-
- case MESA_A1_R5_G5_B5:
- /* store as 16-bit texels (GR_TEXFMT_ARGB_1555) */
- if (srcFormat == GL_BGRA && srcType == GL_UNSIGNED_SHORT_1_5_5_5_REV){
- /* special, optimized case */
- if (wScale == 1 && hScale == 1) {
- const GLubyte *src = (const GLubyte *)
- _mesa_image_address(packing, srcImage, srcWidth, srcHeight,
- srcFormat, srcType, 0, 0, 0);
- const GLint srcStride = _mesa_image_row_stride(packing,
- width, srcFormat, srcType);
- GLushort *dst = (GLushort *) ((GLubyte *) dstImage
- + dstYoffset * dstRowStride) + dstXoffset;
- GLint row;
- for (row = 0; row < height; row++) {
- MEMCPY(dst, src, width * sizeof(GLushort));
- src += srcStride;
- dst = (GLushort *) ((GLubyte *) dst + dstRowStride);
- }
- }
- else {
- /* must rescale image */
- GLushort *dst = (GLushort *) ((GLubyte *) dstImage
- + dstYoffset * dstRowStride) + dstXoffset;
- GLint row;
- for (row = 0; row < height; row++) {
- GLint srcRow = row / hScale;
- const GLushort *src = (const GLushort *)
- _mesa_image_address(packing, srcImage, srcWidth,
- srcHeight, srcFormat, srcType, 0, srcRow, 0);
- GLint col;
- for (col = 0; col < width; col++) {
- dst[col] = src[col / wScale];
- }
- dst = (GLushort *) ((GLubyte *) dst + dstRowStride);
- }
- }
- }
- else if (srcFormat == GL_RGBA && srcType == GL_UNSIGNED_BYTE) {
- /* general case */
- if (wScale == 1 && hScale == 1) {
- const GLubyte *src = (const GLubyte *)
- _mesa_image_address(packing, srcImage, srcWidth, srcHeight,
- srcFormat, srcType, 0, 0, 0);
- const GLint srcStride = _mesa_image_row_stride(packing,
- width, srcFormat, srcType);
- GLushort *dst = (GLushort *) ((GLubyte *) dstImage
- + dstYoffset * dstRowStride) + dstXoffset;
- GLint row;
- for (row = 0; row < height; row++) {
- GLint col, col4;
- for (col = col4 = 0; col < width; col++, col4 += 4) {
- GLubyte r = src[col4 + 0];
- GLubyte g = src[col4 + 1];
- GLubyte b = src[col4 + 2];
- GLubyte a = src[col4 + 3];
- dst[col] = ((a & 0x80) << 8)
- | ((r & 0xf8) << 7)
- | ((g & 0xf8) << 2)
- | ((b & 0xf8) >> 3);
- }
- src += srcStride;
- dst = (GLushort *) ((GLubyte *) dst + dstRowStride);
- }
- }
- else {
- /* must rescale image */
- GLushort *dst = (GLushort *) ((GLubyte *) dstImage
- + dstYoffset * dstRowStride) + dstXoffset;
- GLint row;
- for (row = 0; row < height; row++) {
- GLint srcRow = row / hScale;
- const GLubyte *src = (const GLubyte *)
- _mesa_image_address(packing, srcImage, srcWidth,
- srcHeight, srcFormat, srcType, 0, srcRow, 0);
- GLint col;
- for (col = 0; col < width; col++) {
- GLint col4 = (col / wScale) * 4;
- GLubyte r = src[col4 + 0];
- GLubyte g = src[col4 + 1];
- GLubyte b = src[col4 + 2];
- GLubyte a = src[col4 + 3];
- dst[col] = ((a & 0x80) << 8)
- | ((r & 0xf8) << 7)
- | ((g & 0xf8) << 2)
- | ((b & 0xf8) >> 3);
- }
- dst = (GLushort *) ((GLubyte *) dst + dstRowStride);
- }
- }
- }
- else {
- /* can't handle this source format/type combination */
- return GL_FALSE;
- }
- break;
-
- case MESA_A8_R8_G8_B8:
- case MESA_FF_R8_G8_B8:
- /* 32-bit texels */
- if (srcFormat == GL_BGRA && srcType == GL_UNSIGNED_INT_8_8_8_8_REV) {
- /* special, optimized case */
- if (wScale == 1 && hScale == 1) {
- const GLubyte *src = (const GLubyte *)
- _mesa_image_address(packing, srcImage, srcWidth, srcHeight,
- srcFormat, srcType, 0, 0, 0);
- const GLint srcStride = _mesa_image_row_stride(packing,
- width, srcFormat, srcType);
- GLuint *dst = (GLuint *) ((GLubyte *) dstImage
- + dstYoffset * dstRowStride) + dstXoffset;
- GLint row;
- for (row = 0; row < height; row++) {
- MEMCPY(dst, src, width * sizeof(GLuint));
- src += srcStride;
- dst = (GLuint *) ((GLubyte *) dst + dstRowStride);
- }
- }
- else {
- /* must rescale image */
- GLuint *dst = (GLuint *) ((GLubyte *) dstImage
- + dstYoffset * dstRowStride) + dstXoffset;
- GLint row;
- for (row = 0; row < height; row++) {
- GLint srcRow = row / hScale;
- const GLuint *src = (const GLuint *)
- _mesa_image_address(packing, srcImage, srcWidth,
- srcHeight, srcFormat, srcType, 0, srcRow, 0);
- GLint col;
- for (col = 0; col < width; col++) {
- dst[col] = src[col / wScale];
- }
- dst = (GLuint *) ((GLubyte *) dst + dstRowStride);
- }
- }
- if (dstFormat == MESA_FF_R8_G8_B8) {
- /* set alpha bytes to 0xff */
- GLint row, col;
- GLubyte *dst = (GLubyte *) dstImage
- + dstYoffset * dstRowStride + dstXoffset * 4;
- assert(wScale == 1 && hScale == 1); /* XXX not done */
- for (row = 0; row < height; row++) {
- for (col = 0; col < width; col++) {
- dst[col * 4 + 3] = 0xff;
- }
- dst = dst + dstRowStride;
- }
- }
- }
- else if (srcFormat == GL_RGBA && srcType == GL_UNSIGNED_BYTE) {
- /* general case */
- const GLubyte aMask = (dstFormat==MESA_FF_R8_G8_B8) ? 0xff : 0x00;
- if (wScale == 1 && hScale == 1) {
- const GLubyte *src = (const GLubyte *)
- _mesa_image_address(packing, srcImage, srcWidth, srcHeight,
- srcFormat, srcType, 0, 0, 0);
- const GLint srcStride = _mesa_image_row_stride(packing,
- width, srcFormat, srcType);
- GLuint *dst = (GLuint *) ((GLubyte *) dstImage
- + dstYoffset * dstRowStride) + dstXoffset;
- GLint row;
- for (row = 0; row < height; row++) {
- GLint col, col4;
- for (col = col4 = 0; col < width; col++, col4 += 4) {
- GLubyte r = src[col4 + 0];
- GLubyte g = src[col4 + 1];
- GLubyte b = src[col4 + 2];
- GLubyte a = src[col4 + 3] | aMask;
- dst[col] = (a << 24) | (r << 16) | (g << 8) | b;
- }
- src += srcStride;
- dst = (GLuint *) ((GLubyte *) dst + dstRowStride);
- }
- }
- else {
- /* must rescale image */
- GLuint *dst = (GLuint *) ((GLubyte *) dstImage
- + dstYoffset * dstRowStride) + dstXoffset;
- GLint row;
- for (row = 0; row < height; row++) {
- GLint srcRow = row / hScale;
- const GLubyte *src = (const GLubyte *)
- _mesa_image_address(packing, srcImage, srcWidth,
- srcHeight, srcFormat, srcType, 0, srcRow, 0);
- GLint col;
- for (col = 0; col < width; col++) {
- GLint col4 = (col / wScale) * 4;
- GLubyte r = src[col4 + 0];
- GLubyte g = src[col4 + 1];
- GLubyte b = src[col4 + 2];
- GLubyte a = src[col4 + 3] | aMask;
- dst[col] = (a << 24) | (r << 16) | (g << 8) | b;
- }
- dst = (GLuint *) ((GLubyte *) dst + dstRowStride);
- }
- }
- }
- else {
- /* can't handle this source format/type combination */
- return GL_FALSE;
- }
- break;
-
-
- default:
- /* unexpected internal format! */
- return GL_FALSE;
+ const GLubyte *src = (const GLubyte *)convert->srcImage;
+ GLint texels, i;
+
+ texels = convert->width * convert->height * convert->depth;
+
+ switch ( convert->format ) {
+ case GL_RGBA:
+ MEMCPY( convert->dstImage, src, texels * 4 );
+ break;
+ case GL_RGB: {
+ GLubyte *dst = (GLubyte *)convert->dstImage;
+ for ( i = 0 ; i < texels ; i++ ) {
+ *dst++ = src[0];
+ *dst++ = src[1];
+ *dst++ = src[2];
+ src += 4;
+ }
+ break;
+ }
+ default:
+ UNCONVERT_ERROR( convert->format );
+ break;
}
- return GL_TRUE;
}
+/* ================================================================
+ * ARGB8888 textures:
+ */
-/*
- * Used to convert 16-bit texels into GLubyte color components.
+#define DST_TYPE GLuint
+#define DST_TEXELS_PER_DWORD 1
+
+#define CONVERT_TEXEL( src ) \
+ PACK_COLOR_8888( src[3], src[2], src[1], src[0] )
+
+#define CONVERT_DIRECT
+
+#define SRC_TEXEL_BYTES 4
+
+#define TAG(x) x##_argb8888_direct
+#define PRESERVE_DST_TYPE
+#include "texutil_tmp.h"
+
+
+#define CONVERT_TEXEL( src ) \
+ PACK_COLOR_8888( src[3], src[0], src[1], src[2] )
+
+#define CONVERT_TEXEL_DWORD( src ) CONVERT_TEXEL( src )
+
+#define SRC_TEXEL_BYTES 4
+
+#define TAG(x) x##_abgr8888_to_argb8888
+#define PRESERVE_DST_TYPE
+#include "texutil_tmp.h"
+
+
+#define CONVERT_TEXEL( src ) \
+ PACK_COLOR_8888( 0xff, src[0], src[1], src[2] )
+
+#define CONVERT_TEXEL_DWORD( src ) CONVERT_TEXEL( src )
+
+#define SRC_TEXEL_BYTES 3
+
+#define TAG(x) x##_bgr888_to_argb8888
+#include "texutil_tmp.h"
+
+
+#define CONVERT_ARGB8888( name ) \
+static GLboolean \
+convert_##name##_argb8888( struct gl_texture_convert *convert ) \
+{ \
+ convert_func *tab; \
+ GLint index = convert->index; \
+ \
+ if ( convert->format == GL_BGRA && \
+ convert->type == GL_UNSIGNED_INT_8_8_8_8_REV ) \
+ { \
+ tab = name##_tab_argb8888_direct; \
+ } \
+ else if ( convert->format == GL_RGBA && \
+ convert->type == GL_UNSIGNED_BYTE ) \
+ { \
+ tab = name##_tab_abgr8888_to_argb8888; \
+ } \
+ else if ( convert->format == GL_RGB && \
+ convert->type == GL_UNSIGNED_BYTE ) \
+ { \
+ tab = name##_tab_bgr888_to_argb8888; \
+ } \
+ else \
+ { \
+ /* Can't handle this source format/type combination */ \
+ return GL_FALSE; \
+ } \
+ \
+ return tab[index]( convert ); \
+}
+
+CONVERT_ARGB8888( texsubimage2d )
+CONVERT_ARGB8888( texsubimage3d )
+
+
+static void
+unconvert_teximage_argb8888( struct gl_texture_convert *convert )
+{
+ const GLubyte *src = (const GLubyte *)convert->srcImage;
+ GLint texels, i;
+
+ texels = convert->width * convert->height * convert->depth;
+
+ switch ( convert->format ) {
+ case GL_RGBA: {
+ GLuint *dst = (GLuint *)convert->dstImage;
+ for ( i = 0 ; i < texels ; i++ ) {
+ *dst++ = PACK_COLOR_8888( src[3], src[0], src[1], src[2] );
+ src += 4;
+ }
+ break;
+ }
+ case GL_RGB: {
+ GLubyte *dst = (GLubyte *)convert->dstImage;
+ for ( i = 0 ; i < texels ; i++ ) {
+ *dst++ = src[2];
+ *dst++ = src[1];
+ *dst++ = src[0];
+ src += 4;
+ }
+ break;
+ }
+ default:
+ UNCONVERT_ERROR( convert->format );
+ break;
+ }
+}
+
+
+
+/* ================================================================
+ * RGB888 textures:
+ */
+
+static GLboolean
+convert_texsubimage2d_rgb888( struct gl_texture_convert *convert )
+{
+ /* This is a placeholder for now...
+ */
+ return GL_FALSE;
+}
+
+static GLboolean
+convert_texsubimage3d_rgb888( struct gl_texture_convert *convert )
+{
+ /* This is a placeholder for now...
+ */
+ return GL_FALSE;
+}
+
+
+static void
+unconvert_teximage_rgb888( struct gl_texture_convert *convert )
+{
+ UNCONVERT_ERROR( convert->format );
+}
+
+
+
+/* ================================================================
+ * BGR888 textures:
*/
-static GLubyte R5G6B5toRed[0xffff];
-static GLubyte R5G6B5toGreen[0xffff];
-static GLubyte R5G6B5toBlue[0xffff];
-static GLubyte A4R4G4B4toRed[0xffff];
-static GLubyte A4R4G4B4toGreen[0xffff];
-static GLubyte A4R4G4B4toBlue[0xffff];
-static GLubyte A4R4G4B4toAlpha[0xffff];
+static GLboolean
+convert_texsubimage2d_bgr888( struct gl_texture_convert *convert )
+{
+ /* This is a placeholder for now...
+ */
+ return GL_FALSE;
+}
+
+static GLboolean
+convert_texsubimage3d_bgr888( struct gl_texture_convert *convert )
+{
+ /* This is a placeholder for now...
+ */
+ return GL_FALSE;
+}
+
+
+static void
+unconvert_teximage_bgr888( struct gl_texture_convert *convert )
+{
+ UNCONVERT_ERROR( convert->format );
+}
+
+
+
+/* ================================================================
+ * RGB565 textures:
+ */
+
+#define DST_TYPE GLushort
+#define DST_TEXELS_PER_DWORD 2
+
+#define CONVERT_TEXEL( src ) \
+ PACK_COLOR_565( src[0], src[1], src[2] )
+
+#define CONVERT_DIRECT
+
+#define SRC_TEXEL_BYTES 2
+
+#define TAG(x) x##_rgb565_direct
+#define PRESERVE_DST_TYPE
+#include "texutil_tmp.h"
+
+
+#define CONVERT_TEXEL( src ) \
+ PACK_COLOR_565( src[0], src[1], src[2] )
+
+#define CONVERT_TEXEL_DWORD( src ) \
+ ((PACK_COLOR_565( src[0], src[1], src[2] )) | \
+ (PACK_COLOR_565( src[3], src[4], src[5] ) << 16))
+
+#define SRC_TEXEL_BYTES 3
+
+#define TAG(x) x##_bgr888_to_rgb565
+#define PRESERVE_DST_TYPE
+#include "texutil_tmp.h"
+
+
+#define CONVERT_TEXEL( src ) \
+ PACK_COLOR_565( src[0], src[1], src[2] )
+
+#define CONVERT_TEXEL_DWORD( src ) \
+ ((PACK_COLOR_565( src[0], src[1], src[2] )) | \
+ (PACK_COLOR_565( src[4], src[5], src[6] ) << 16))
+
+#define SRC_TEXEL_BYTES 4
+
+#define TAG(x) x##_abgr8888_to_rgb565
+#include "texutil_tmp.h"
+
+
+#define CONVERT_RGB565( name ) \
+static GLboolean \
+convert_##name##_rgb565( struct gl_texture_convert *convert ) \
+{ \
+ convert_func *tab; \
+ GLint index = convert->index; \
+ \
+ if ( convert->format == GL_RGB && \
+ convert->type == GL_UNSIGNED_SHORT_5_6_5 ) \
+ { \
+ tab = name##_tab_rgb565_direct; \
+ } \
+ else if ( convert->format == GL_RGB && \
+ convert->type == GL_UNSIGNED_BYTE ) \
+ { \
+ tab = name##_tab_bgr888_to_rgb565; \
+ } \
+ else if ( convert->format == GL_RGBA && \
+ convert->type == GL_UNSIGNED_BYTE ) \
+ { \
+ tab = name##_tab_abgr8888_to_rgb565; \
+ } \
+ else \
+ { \
+ /* Can't handle this source format/type combination */ \
+ return GL_FALSE; \
+ } \
+ \
+ return tab[index]( convert ); \
+}
+
+CONVERT_RGB565( texsubimage2d )
+CONVERT_RGB565( texsubimage3d )
+
+
+static void
+unconvert_teximage_rgb565( struct gl_texture_convert *convert )
+{
+ const GLushort *src = (const GLushort *)convert->srcImage;
+ GLubyte *dst = (GLubyte *)convert->dstImage;
+ GLint texels, i;
+
+ texels = convert->width * convert->height * convert->depth;
+
+ switch ( convert->format ) {
+ case GL_RGBA:
+ for ( i = 0 ; i < texels ; i++ ) {
+ GLushort s = *src++;
+ *dst++ = ((s >> 8) & 0xf8) * 255 / 0xf8;
+ *dst++ = ((s >> 3) & 0xfc) * 255 / 0xfc;
+ *dst++ = ((s << 3) & 0xf8) * 255 / 0xf8;
+ *dst++ = 0xff;
+ }
+ break;
+ case GL_RGB:
+ for ( i = 0 ; i < texels ; i++ ) {
+ GLushort s = *src++;
+ *dst++ = ((s >> 8) & 0xf8) * 255 / 0xf8;
+ *dst++ = ((s >> 3) & 0xfc) * 255 / 0xfc;
+ *dst++ = ((s << 3) & 0xf8) * 255 / 0xf8;
+ }
+ break;
+ default:
+ UNCONVERT_ERROR( convert->format );
+ break;
+ }
+}
+
+
+
+/* ================================================================
+ * ARGB4444 textures:
+ */
+
+#define DST_TYPE GLushort
+#define DST_TEXELS_PER_DWORD 2
+
+#define CONVERT_TEXEL( src ) \
+ PACK_COLOR_4444( src[3], src[0], src[1], src[2] )
+
+#define CONVERT_DIRECT
+
+#define SRC_TEXEL_BYTES 2
+
+#define TAG(x) x##_argb4444_direct
+#define PRESERVE_DST_TYPE
+#include "texutil_tmp.h"
+
+
+#define CONVERT_TEXEL( src ) \
+ PACK_COLOR_4444( src[3], src[0], src[1], src[2] )
+
+#define CONVERT_TEXEL_DWORD( src ) \
+ ((PACK_COLOR_4444( src[3], src[0], src[1], src[2] )) | \
+ (PACK_COLOR_4444( src[7], src[4], src[5], src[6] ) << 16))
+
+#define SRC_TEXEL_BYTES 4
+
+#define TAG(x) x##_rgba8888_to_argb4444
+#include "texutil_tmp.h"
+
+
+#define CONVERT_ARGB4444( name ) \
+static GLboolean \
+convert_##name##_argb4444( struct gl_texture_convert *convert ) \
+{ \
+ convert_func *tab; \
+ GLint index = convert->index; \
+ \
+ if ( convert->format == GL_BGRA && \
+ convert->type == GL_UNSIGNED_SHORT_4_4_4_4_REV ) \
+ { \
+ tab = name##_tab_argb4444_direct; \
+ } \
+ else if ( convert->format == GL_RGBA && \
+ convert->type == GL_UNSIGNED_BYTE ) \
+ { \
+ tab = name##_tab_rgba8888_to_argb4444; \
+ } \
+ else \
+ { \
+ /* Can't handle this source format/type combination */ \
+ return GL_FALSE; \
+ } \
+ \
+ return tab[index]( convert ); \
+}
+
+CONVERT_ARGB4444( texsubimage2d )
+CONVERT_ARGB4444( texsubimage3d )
-static GLubyte A1R5G5B5toRed[0xffff];
-static GLubyte A1R5G5B5toGreen[0xffff];
-static GLubyte A1R5G5B5toBlue[0xffff];
-static GLubyte A1R5G5B5toAlpha[0xffff];
static void
-generate_lookup_tables(void)
+unconvert_teximage_argb4444( struct gl_texture_convert *convert )
{
- GLint i;
- for (i = 0; i <= 0xffff; i++) {
- GLint r = (i >> 8) & 0xf8;
- GLint g = (i >> 3) & 0xfc;
- GLint b = (i << 3) & 0xf8;
- r = r * 255 / 0xf8;
- g = g * 255 / 0xfc;
- b = b * 255 / 0xf8;
- R5G6B5toRed[i] = r;
- R5G6B5toGreen[i] = g;
- R5G6B5toBlue[i] = b;
+ const GLushort *src = (const GLushort *)convert->srcImage;
+ GLubyte *dst = (GLubyte *)convert->dstImage;
+ GLint texels, i;
+
+ texels = convert->width * convert->height * convert->depth;
+
+ switch ( convert->format ) {
+ case GL_RGBA:
+ for ( i = 0 ; i < texels ; i++ ) {
+ GLushort s = *src++;
+ *dst++ = ((s >> 8) & 0xf) * 255 / 0xf;
+ *dst++ = ((s >> 4) & 0xf) * 255 / 0xf;
+ *dst++ = ((s ) & 0xf) * 255 / 0xf;
+ *dst++ = ((s >> 12) & 0xf) * 255 / 0xf;
+ }
+ break;
+ default:
+ UNCONVERT_ERROR( convert->format );
+ break;
}
+}
+
+
+
+/* ================================================================
+ * ARGB1555 textures:
+ */
+
+#define DST_TYPE GLushort
+#define DST_TEXELS_PER_DWORD 2
+
+#define CONVERT_TEXEL( src ) \
+ PACK_COLOR_1555( src[3], src[0], src[1], src[2] )
+
+#define CONVERT_DIRECT
+
+#define SRC_TEXEL_BYTES 2
- for (i = 0; i <= 0xffff; i++) {
- GLint r = (i >> 8) & 0xf;
- GLint g = (i >> 4) & 0xf;
- GLint b = (i ) & 0xf;
- GLint a = (i >> 12) & 0xf;
- r = r * 255 / 0xf;
- g = g * 255 / 0xf;
- b = b * 255 / 0xf;
- a = a * 255 / 0xf;
- A4R4G4B4toRed[i] = r;
- A4R4G4B4toGreen[i] = g;
- A4R4G4B4toBlue[i] = b;
- A4R4G4B4toAlpha[i] = a;
+#define TAG(x) x##_argb1555_direct
+#define PRESERVE_DST_TYPE
+#include "texutil_tmp.h"
+
+
+#define CONVERT_TEXEL( src ) \
+ PACK_COLOR_1555( src[3], src[0], src[1], src[2] )
+
+#define CONVERT_TEXEL_DWORD( src ) \
+ ((PACK_COLOR_1555( src[3], src[0], src[1], src[2] )) | \
+ (PACK_COLOR_1555( src[7], src[4], src[5], src[6] ) << 16))
+
+#define SRC_TEXEL_BYTES 4
+
+#define TAG(x) x##_rgba8888_to_argb1555
+#include "texutil_tmp.h"
+
+
+#define CONVERT_ARGB1555( name ) \
+static GLboolean \
+convert_##name##_argb1555( struct gl_texture_convert *convert ) \
+{ \
+ convert_func *tab; \
+ GLint index = convert->index; \
+ \
+ if ( convert->format == GL_BGRA && \
+ convert->type == GL_UNSIGNED_SHORT_1_5_5_5_REV ) \
+ { \
+ tab = name##_tab_argb1555_direct; \
+ } \
+ else if ( convert->format == GL_RGBA && \
+ convert->type == GL_UNSIGNED_BYTE ) \
+ { \
+ tab = name##_tab_rgba8888_to_argb1555; \
+ } \
+ else \
+ { \
+ /* Can't handle this source format/type combination */ \
+ return GL_FALSE; \
+ } \
+ \
+ return tab[index]( convert ); \
+}
+
+CONVERT_ARGB1555( texsubimage2d )
+CONVERT_ARGB1555( texsubimage3d )
+
+
+static void
+unconvert_teximage_argb1555( struct gl_texture_convert *convert )
+{
+ const GLushort *src = (const GLushort *)convert->srcImage;
+ GLubyte *dst = (GLubyte *)convert->dstImage;
+ GLint texels, i;
+
+ texels = convert->width * convert->height * convert->depth;
+
+ switch ( convert->format ) {
+ case GL_RGBA:
+ for ( i = 0 ; i < texels ; i++ ) {
+ GLushort s = *src++;
+ *dst++ = ((s >> 10) & 0xf8) * 255 / 0xf8;
+ *dst++ = ((s >> 5) & 0xf8) * 255 / 0xf8;
+ *dst++ = ((s ) & 0xf8) * 255 / 0xf8;
+ *dst++ = ((s >> 15) & 0x01) * 255;
+ }
+ break;
+ default:
+ UNCONVERT_ERROR( convert->format );
+ break;
}
+}
+
+
+
+/* ================================================================
+ * AL88 textures:
+ */
+
+#define DST_TYPE GLushort
+#define DST_TEXELS_PER_DWORD 2
- for (i = 0; i <= 0xffff; i++) {
- GLint r = (i >> 10) & 0xf8;
- GLint g = (i >> 5) & 0xf8;
- GLint b = (i ) & 0xf8;
- GLint a = (i >> 15) & 0x1;
- r = r * 255 / 0xf8;
- g = g * 255 / 0xf8;
- b = b * 255 / 0xf8;
- a = a * 255;
- A1R5G5B5toRed[i] = r;
- A1R5G5B5toGreen[i] = g;
- A1R5G5B5toBlue[i] = b;
- A1R5G5B5toAlpha[i] = a;
+#define CONVERT_TEXEL( src ) \
+ PACK_COLOR_88( src[0], src[1] )
+
+#define CONVERT_DIRECT
+
+#define SRC_TEXEL_BYTES 2
+
+#define TAG(x) x##_al88_direct
+#define PRESERVE_DST_TYPE
+#include "texutil_tmp.h"
+
+
+#define CONVERT_TEXEL( src ) \
+ PACK_COLOR_88( src[0], 0x00 )
+
+#define CONVERT_TEXEL_DWORD( src ) \
+ ((PACK_COLOR_88( src[0], 0x00 )) | \
+ (PACK_COLOR_88( src[1], 0x00 ) << 16))
+
+#define SRC_TEXEL_BYTES 1
+
+#define TAG(x) x##_a8_to_al88
+#define PRESERVE_DST_TYPE
+#include "texutil_tmp.h"
+
+
+#define CONVERT_TEXEL( src ) \
+ PACK_COLOR_88( 0xff, src[0] )
+
+#define CONVERT_TEXEL_DWORD( src ) \
+ ((PACK_COLOR_88( 0xff, src[0] )) | \
+ (PACK_COLOR_88( 0xff, src[1] ) << 16))
+
+#define SRC_TEXEL_BYTES 1
+
+#define TAG(x) x##_l8_to_al88
+#include "texutil_tmp.h"
+
+
+#define CONVERT_AL88( name ) \
+static GLboolean \
+convert_##name##_al88( struct gl_texture_convert *convert ) \
+{ \
+ convert_func *tab; \
+ GLint index = convert->index; \
+ \
+ if ( convert->format == GL_LUMINANCE_ALPHA && \
+ convert->type == GL_UNSIGNED_BYTE ) \
+ { \
+ tab = name##_tab_al88_direct; \
+ } \
+ else if ( convert->format == GL_ALPHA && \
+ convert->type == GL_UNSIGNED_BYTE ) \
+ { \
+ tab = name##_tab_a8_to_al88; \
+ } \
+ else if ( convert->format == GL_LUMINANCE && \
+ convert->type == GL_UNSIGNED_BYTE ) \
+ { \
+ tab = name##_tab_l8_to_al88; \
+ } \
+ else \
+ { \
+ /* Can't handle this source format/type combination */ \
+ return GL_FALSE; \
+ } \
+ \
+ return tab[index]( convert ); \
+}
+
+CONVERT_AL88( texsubimage2d )
+CONVERT_AL88( texsubimage3d )
+
+
+static void
+unconvert_teximage_al88( struct gl_texture_convert *convert )
+{
+ const GLubyte *src = (const GLubyte *)convert->srcImage;
+ GLint texels, i;
+
+ texels = convert->width * convert->height * convert->depth;
+
+ switch ( convert->format ) {
+ case GL_LUMINANCE_ALPHA:
+ MEMCPY( convert->dstImage, src, texels * 2 );
+ break;
+ case GL_ALPHA: {
+ GLubyte *dst = (GLubyte *)convert->dstImage;
+ for ( i = 0 ; i < texels ; i++ ) {
+ *dst++ = src[1];
+ src += 2;
+ }
+ break;
+ }
+ case GL_LUMINANCE: {
+ GLubyte *dst = (GLubyte *)convert->dstImage;
+ for ( i = 0 ; i < texels ; i++ ) {
+ *dst++ = src[0];
+ src += 2;
+ }
+ break;
+ }
+ default:
+ UNCONVERT_ERROR( convert->format );
+ break;
}
}
-/*
- * Convert a texture image from an internal format to one of Mesa's
- * core internal formats. This is likely to be used by glGetTexImage
- * and for fetching texture images when falling back to software rendering.
- *
- * Input:
- * srcFormat - source image format
- * srcWidth, srcHeight - source image size
- * srcImage - source image pointer
- * srcRowStride - bytes to jump between image rows
- * dstWidth, dstHeight - size of dest image
- * dstFormat - format of dest image (must be one of Mesa's IntFormat values)
- * dstImage - pointer to dest image
- * Notes:
- * This function will do power of two image down-scaling to accomodate
- * drivers with limited texture image aspect ratios.
- * The implicit dest data type is GL_UNSIGNED_BYTE.
+/* ================================================================
+ * RGB332 textures:
+ */
+
+static GLboolean
+convert_texsubimage2d_rgb332( struct gl_texture_convert *convert )
+{
+ /* This is a placeholder for now...
+ */
+ return GL_FALSE;
+}
+
+static GLboolean
+convert_texsubimage3d_rgb332( struct gl_texture_convert *convert )
+{
+ /* This is a placeholder for now...
+ */
+ return GL_FALSE;
+}
+
+
+static void
+unconvert_teximage_rgb332( struct gl_texture_convert *convert )
+{
+ UNCONVERT_ERROR( convert->format );
+}
+
+
+
+/* ================================================================
+ * CI8 (and all other single-byte texel) textures:
*/
-void
-_mesa_unconvert_teximage(MesaIntTexFormat srcFormat,
- GLint srcWidth, GLint srcHeight,
- const GLvoid *srcImage, GLint srcRowStride,
- GLint dstWidth, GLint dstHeight,
- GLenum dstFormat, GLubyte *dstImage)
+
+#define DST_TYPE GLubyte
+#define DST_TEXELS_PER_DWORD 4
+
+#define CONVERT_TEXEL( src ) src[0]
+
+#define CONVERT_DIRECT
+
+#define SRC_TEXEL_BYTES 1
+
+#define TAG(x) x##_ci8_direct
+#include "texutil_tmp.h"
+
+
+#define CONVERT_CI8( name ) \
+static GLboolean \
+convert_##name##_ci8( struct gl_texture_convert *convert ) \
+{ \
+ convert_func *tab; \
+ GLint index = convert->index; \
+ \
+ if ( ( convert->format == GL_ALPHA || \
+ convert->format == GL_LUMINANCE || \
+ convert->format == GL_INTENSITY || \
+ convert->format == GL_COLOR_INDEX ) && \
+ convert->type == GL_UNSIGNED_BYTE ) \
+ { \
+ tab = name##_tab_ci8_direct; \
+ } \
+ else \
+ { \
+ /* Can't handle this source format/type combination */ \
+ return GL_FALSE; \
+ } \
+ \
+ return tab[index]( convert ); \
+}
+
+CONVERT_CI8( texsubimage2d )
+CONVERT_CI8( texsubimage3d )
+
+
+static void
+unconvert_teximage_ci8( struct gl_texture_convert *convert )
{
- static GLboolean firstCall = GL_TRUE;
- const GLint wScale = srcWidth / dstWidth; /* must be power of two */
- const GLint hScale = srcHeight / dstHeight; /* must be power of two */
- ASSERT(srcWidth >= dstWidth);
- ASSERT(srcHeight >= dstHeight);
- ASSERT(dstImage);
- ASSERT(srcImage);
-
- if (firstCall) {
- generate_lookup_tables();
- firstCall = GL_FALSE;
+ const GLubyte *src = (const GLubyte *)convert->srcImage;
+ GLint texels;
+
+ texels = convert->width * convert->height * convert->depth;
+
+ switch ( convert->format ) {
+ case GL_ALPHA:
+ case GL_LUMINANCE:
+ case GL_INTENSITY:
+ case GL_COLOR_INDEX:
+ MEMCPY( convert->dstImage, src, texels );
+ break;
+ default:
+ UNCONVERT_ERROR( convert->format );
+ break;
}
+}
- switch (srcFormat) {
- case MESA_I8:
- case MESA_L8:
- case MESA_A8:
- case MESA_C8:
-#ifdef DEBUG
- if (srcFormat == MESA_I8) {
- ASSERT(dstFormat == GL_INTENSITY);
- }
- else if (srcFormat == MESA_L8) {
- ASSERT(dstFormat == GL_LUMINANCE);
- }
- else if (srcFormat == MESA_A8) {
- ASSERT(dstFormat == GL_ALPHA);
- }
- else if (srcFormat == MESA_C8) {
- ASSERT(dstFormat == GL_COLOR_INDEX);
- }
-#endif
- if (wScale == 1 && hScale == 1) {
- /* easy! */
- MEMCPY(dstImage, srcImage, dstWidth * dstHeight * sizeof(GLubyte));
- }
- else {
- /* rescale */
- const GLubyte *src8 = (const GLubyte *) srcImage;
- GLint row, col;
- for (row = 0; row < dstHeight; row++) {
- GLint srcRow = row * hScale;
- for (col = 0; col < dstWidth; col++) {
- GLint srcCol = col * wScale;
- *dstImage++ = src8[srcRow * srcWidth + srcCol];
- }
- }
- }
- break;
- case MESA_A8_L8:
- ASSERT(dstFormat == GL_LUMINANCE_ALPHA);
- if (wScale == 1 && hScale == 1) {
- GLint i, n = dstWidth * dstHeight;
- const GLushort *texel = (const GLushort *) srcImage;
- for (i = 0; i < n; i++) {
- const GLushort tex = *texel++;
- *dstImage++ = (tex & 0xff); /* luminance */
- *dstImage++ = (tex >> 8); /* alpha */
- }
- }
- else {
- /* rescale */
- const GLushort *src16 = (const GLushort *) srcImage;
- GLint row, col;
- for (row = 0; row < dstHeight; row++) {
- GLint srcRow = row * hScale;
- for (col = 0; col < dstWidth; col++) {
- GLint srcCol = col * wScale;
- const GLushort tex = src16[srcRow * srcWidth + srcCol];
- *dstImage++ = (tex & 0xff); /* luminance */
- *dstImage++ = (tex >> 8); /* alpha */
- }
- }
- }
- break;
- case MESA_R5_G6_B5:
- ASSERT(dstFormat == GL_RGB);
- if (wScale == 1 && hScale == 1) {
- GLint i, n = dstWidth * dstHeight;
- const GLushort *texel = (const GLushort *) srcImage;
- for (i = 0; i < n; i++) {
- const GLushort tex = *texel++;
- *dstImage++ = R5G6B5toRed[tex];
- *dstImage++ = R5G6B5toGreen[tex];
- *dstImage++ = R5G6B5toBlue[tex];
- }
- }
- else {
- /* rescale */
- const GLushort *src16 = (const GLushort *) srcImage;
- GLint row, col;
- for (row = 0; row < dstHeight; row++) {
- GLint srcRow = row * hScale;
- for (col = 0; col < dstWidth; col++) {
- GLint srcCol = col * wScale;
- const GLushort tex = src16[srcRow * srcWidth + srcCol];
- *dstImage++ = R5G6B5toRed[tex];
- *dstImage++ = R5G6B5toGreen[tex];
- *dstImage++ = R5G6B5toBlue[tex];
- }
- }
- }
- break;
- case MESA_A4_R4_G4_B4:
- ASSERT(dstFormat == GL_RGBA);
- if (wScale == 1 && hScale == 1) {
- GLint i, n = dstWidth * dstHeight;
- const GLushort *texel = (const GLushort *) srcImage;
- for (i = 0; i < n; i++) {
- const GLushort tex = *texel++;
- *dstImage++ = A4R4G4B4toRed[tex];
- *dstImage++ = A4R4G4B4toGreen[tex];
- *dstImage++ = A4R4G4B4toBlue[tex];
- *dstImage++ = A4R4G4B4toAlpha[tex];
- }
- }
- else {
- /* rescale */
- const GLushort *src16 = (const GLushort *) srcImage;
- GLint row, col;
- for (row = 0; row < dstHeight; row++) {
- GLint srcRow = row * hScale;
- for (col = 0; col < dstWidth; col++) {
- GLint srcCol = col * wScale;
- const GLushort tex = src16[srcRow * srcWidth + srcCol];
- *dstImage++ = A4R4G4B4toRed[tex];
- *dstImage++ = A4R4G4B4toGreen[tex];
- *dstImage++ = A4R4G4B4toBlue[tex];
- *dstImage++ = A4R4G4B4toAlpha[tex];
- }
- }
- }
- break;
- case MESA_A1_R5_G5_B5:
- ASSERT(dstFormat == GL_RGBA);
- if (wScale == 1 && hScale == 1) {
- GLint i, n = dstWidth * dstHeight;
- const GLushort *texel = (const GLushort *) srcImage;
- for (i = 0; i < n; i++) {
- const GLushort tex = *texel++;
- *dstImage++ = A1R5G5B5toRed[tex];
- *dstImage++ = A1R5G5B5toGreen[tex];
- *dstImage++ = A1R5G5B5toBlue[tex];
- *dstImage++ = A1R5G5B5toAlpha[tex];
- }
- }
- else {
- /* rescale */
- const GLushort *src16 = (const GLushort *) srcImage;
- GLint row, col;
- for (row = 0; row < dstHeight; row++) {
- GLint srcRow = row * hScale;
- for (col = 0; col < dstWidth; col++) {
- GLint srcCol = col * wScale;
- const GLushort tex = src16[srcRow * srcWidth + srcCol];
- *dstImage++ = A1R5G5B5toRed[tex];
- *dstImage++ = A1R5G5B5toGreen[tex];
- *dstImage++ = A1R5G5B5toBlue[tex];
- *dstImage++ = A1R5G5B5toAlpha[tex];
- }
- }
- }
- break;
- case MESA_A8_R8_G8_B8:
- case MESA_FF_R8_G8_B8:
- ASSERT(dstFormat == GL_RGBA);
- if (wScale == 1 && hScale == 1) {
- GLint i, n = dstWidth * dstHeight;
- const GLuint *texel = (const GLuint *) srcImage;
- for (i = 0; i < n; i++) {
- const GLuint tex = *texel++;
- *dstImage++ = (tex >> 16) & 0xff; /* R */
- *dstImage++ = (tex >> 8) & 0xff; /* G */
- *dstImage++ = (tex ) & 0xff; /* B */
- *dstImage++ = (tex >> 24) & 0xff; /* A */
- }
- }
- else {
- /* rescale */
- const GLuint *src = (const GLuint *) srcImage;
- GLint row, col;
- for (row = 0; row < dstHeight; row++) {
- GLint srcRow = row * hScale;
- for (col = 0; col < dstWidth; col++) {
- GLint srcCol = col * wScale;
- const GLuint tex = src[srcRow * srcWidth + srcCol];
- *dstImage++ = (tex >> 16) & 0xff; /* R */
- *dstImage++ = (tex >> 8) & 0xff; /* G */
- *dstImage++ = (tex ) & 0xff; /* B */
- *dstImage++ = (tex >> 24) & 0xff; /* A */
- }
- }
- }
- break;
- default:
- gl_problem(NULL, "bad srcFormat in _mesa_uncovert_teximage()");
+
+
+/* ================================================================
+ * Global entry points
+ */
+
+static convert_func gl_convert_texsubimage2d_tab[] = {
+ convert_texsubimage2d_rgba8888,
+ convert_texsubimage2d_abgr8888,
+ convert_texsubimage2d_argb8888,
+ convert_texsubimage2d_rgb888,
+ convert_texsubimage2d_bgr888,
+ convert_texsubimage2d_rgb565,
+ convert_texsubimage2d_argb4444,
+ convert_texsubimage2d_argb1555,
+ convert_texsubimage2d_al88,
+ convert_texsubimage2d_rgb332,
+ convert_texsubimage2d_ci8, /* These are all the same... */
+ convert_texsubimage2d_ci8,
+ convert_texsubimage2d_ci8,
+ convert_texsubimage2d_ci8,
+};
+
+static convert_func gl_convert_texsubimage3d_tab[] = {
+ convert_texsubimage3d_rgba8888,
+ convert_texsubimage3d_abgr8888,
+ convert_texsubimage3d_argb8888,
+ convert_texsubimage3d_rgb888,
+ convert_texsubimage3d_bgr888,
+ convert_texsubimage3d_rgb565,
+ convert_texsubimage3d_argb4444,
+ convert_texsubimage3d_argb1555,
+ convert_texsubimage3d_al88,
+ convert_texsubimage3d_rgb332,
+ convert_texsubimage3d_ci8, /* These are all the same... */
+ convert_texsubimage3d_ci8,
+ convert_texsubimage3d_ci8,
+ convert_texsubimage3d_ci8,
+};
+
+static unconvert_func gl_unconvert_teximage_tab[] = {
+ unconvert_teximage_rgba8888,
+ unconvert_teximage_abgr8888,
+ unconvert_teximage_argb8888,
+ unconvert_teximage_rgb888,
+ unconvert_teximage_bgr888,
+ unconvert_teximage_rgb565,
+ unconvert_teximage_argb4444,
+ unconvert_teximage_argb1555,
+ unconvert_teximage_al88,
+ unconvert_teximage_rgb332,
+ unconvert_teximage_ci8, /* These are all the same... */
+ unconvert_teximage_ci8,
+ unconvert_teximage_ci8,
+ unconvert_teximage_ci8,
+};
+
+
+/* See if we need to care about the pixel store attributes when we're
+ * converting the texture image. This should be stored as
+ * packing->_SomeBoolean and updated when the values change, to avoid
+ * testing every time...
+ */
+static INLINE GLboolean
+convert_needs_packing( const struct gl_pixelstore_attrib *packing,
+ GLenum format, GLenum type )
+{
+ if ( ( packing->Alignment == 1 ||
+ ( packing->Alignment == 4 && /* Pick up the common Q3A case... */
+ format == GL_RGBA && type == GL_UNSIGNED_BYTE ) ) &&
+ packing->RowLength == 0 &&
+ packing->SkipPixels == 0 &&
+ packing->SkipRows == 0 &&
+ packing->ImageHeight == 0 &&
+ packing->SkipImages == 0 &&
+ packing->SwapBytes == GL_FALSE &&
+ packing->LsbFirst == GL_FALSE ) {
+ return GL_FALSE;
+ } else {
+ return GL_TRUE;
}
}
+GLboolean
+_mesa_convert_texsubimage1d( GLint mesaFormat,
+ GLint xoffset,
+ GLint width,
+ GLenum format, GLenum type,
+ const struct gl_pixelstore_attrib *packing,
+ const GLvoid *srcImage, GLvoid *dstImage )
+{
+ struct gl_texture_convert convert;
-/*
- * Given an internal Mesa driver texture format, fill in the component
- * bit sizes in the given texture image struct.
+ ASSERT( packing );
+ ASSERT( srcImage );
+ ASSERT( dstImage );
+
+ ASSERT( mesaFormat >= MESA_FORMAT_RGBA8888 );
+ ASSERT( mesaFormat <= MESA_FORMAT_CI8 );
+
+ /* Make it easier to pass all the parameters around.
+ */
+ convert.xoffset = xoffset;
+ convert.yoffset = 0;
+ convert.width = width;
+ convert.height = 1;
+ convert.format = format;
+ convert.type = type;
+ convert.packing = packing;
+ convert.srcImage = srcImage;
+ convert.dstImage = dstImage;
+
+ convert.index = 0;
+
+ if ( convert_needs_packing( packing, format, type ) )
+ convert.index |= CONVERT_PACKING_BIT;
+
+ return gl_convert_texsubimage2d_tab[mesaFormat]( &convert );
+}
+
+GLboolean
+_mesa_convert_texsubimage2d( GLint mesaFormat,
+ GLint xoffset, GLint yoffset,
+ GLint width, GLint height,
+ GLint imageWidth,
+ GLenum format, GLenum type,
+ const struct gl_pixelstore_attrib *packing,
+ const GLvoid *srcImage, GLvoid *dstImage )
+{
+ struct gl_texture_convert convert;
+
+ ASSERT( packing );
+ ASSERT( srcImage );
+ ASSERT( dstImage );
+
+ ASSERT( mesaFormat >= MESA_FORMAT_RGBA8888 );
+ ASSERT( mesaFormat <= MESA_FORMAT_CI8 );
+
+ /* Make it easier to pass all the parameters around.
+ */
+ convert.xoffset = xoffset;
+ convert.yoffset = yoffset;
+ convert.width = width;
+ convert.height = height;
+ convert.imageWidth = imageWidth;
+ convert.format = format;
+ convert.type = type;
+ convert.packing = packing;
+ convert.srcImage = srcImage;
+ convert.dstImage = dstImage;
+
+ convert.index = 0;
+
+ if ( convert_needs_packing( packing, format, type ) )
+ convert.index |= CONVERT_PACKING_BIT;
+
+ if ( width != imageWidth )
+ convert.index |= CONVERT_STRIDE_BIT;
+
+ return gl_convert_texsubimage2d_tab[mesaFormat]( &convert );
+}
+
+GLboolean
+_mesa_convert_texsubimage3d( GLint mesaFormat,
+ GLint xoffset, GLint yoffset, GLint zoffset,
+ GLint width, GLint height, GLint depth,
+ GLint imageWidth, GLint imageHeight,
+ GLenum format, GLenum type,
+ const struct gl_pixelstore_attrib *packing,
+ const GLvoid *srcImage, GLvoid *dstImage )
+{
+ struct gl_texture_convert convert;
+
+ ASSERT( packing );
+ ASSERT( srcImage );
+ ASSERT( dstImage );
+
+ ASSERT( mesaFormat >= MESA_FORMAT_RGBA8888 );
+ ASSERT( mesaFormat <= MESA_FORMAT_CI8 );
+
+ /* Make it easier to pass all the parameters around.
+ */
+ convert.xoffset = xoffset;
+ convert.yoffset = yoffset;
+ convert.zoffset = zoffset;
+ convert.width = width;
+ convert.height = height;
+ convert.depth = depth;
+ convert.imageWidth = imageWidth;
+ convert.imageHeight = imageHeight;
+ convert.format = format;
+ convert.type = type;
+ convert.packing = packing;
+ convert.srcImage = srcImage;
+ convert.dstImage = dstImage;
+
+ convert.index = 0;
+
+ if ( convert_needs_packing( packing, format, type ) )
+ convert.index |= CONVERT_PACKING_BIT;
+
+ if ( width != imageWidth || height != imageHeight )
+ convert.index |= CONVERT_STRIDE_BIT;
+
+ return gl_convert_texsubimage3d_tab[mesaFormat]( &convert );
+}
+
+
+
+void _mesa_unconvert_teximage1d( GLint mesaFormat, GLenum format, GLint width,
+ const GLvoid *srcImage, GLvoid *dstImage )
+{
+ struct gl_texture_convert convert;
+
+ ASSERT( srcImage );
+ ASSERT( dstImage );
+
+ ASSERT( mesaFormat >= MESA_FORMAT_RGBA8888 );
+ ASSERT( mesaFormat <= MESA_FORMAT_CI8 );
+
+ /* Make it easier to pass all the parameters around.
+ */
+ convert.width = width;
+ convert.height = 1;
+ convert.depth = 1;
+ convert.format = format;
+ convert.srcImage = srcImage;
+ convert.dstImage = dstImage;
+
+ gl_unconvert_teximage_tab[mesaFormat]( &convert );
+}
+
+void _mesa_unconvert_teximage2d( GLint mesaFormat, GLenum format,
+ GLint width, GLint height,
+ const GLvoid *srcImage, GLvoid *dstImage )
+{
+ struct gl_texture_convert convert;
+
+ ASSERT( srcImage );
+ ASSERT( dstImage );
+
+ ASSERT( mesaFormat >= MESA_FORMAT_RGBA8888 );
+ ASSERT( mesaFormat <= MESA_FORMAT_CI8 );
+
+ /* Make it easier to pass all the parameters around.
+ */
+ convert.width = width;
+ convert.height = height;
+ convert.depth = 1;
+ convert.format = format;
+ convert.srcImage = srcImage;
+ convert.dstImage = dstImage;
+
+ gl_unconvert_teximage_tab[mesaFormat]( &convert );
+}
+
+void _mesa_unconvert_teximage3d( GLint mesaFormat, GLenum format,
+ GLint width, GLint height, GLint depth,
+ const GLvoid *srcImage, GLvoid *dstImage )
+{
+ struct gl_texture_convert convert;
+
+ ASSERT( srcImage );
+ ASSERT( dstImage );
+
+ ASSERT( mesaFormat >= MESA_FORMAT_RGBA8888 );
+ ASSERT( mesaFormat <= MESA_FORMAT_CI8 );
+
+ /* Make it easier to pass all the parameters around.
+ */
+ convert.width = width;
+ convert.height = height;
+ convert.depth = depth;
+ convert.format = format;
+ convert.srcImage = srcImage;
+ convert.dstImage = dstImage;
+
+ gl_unconvert_teximage_tab[mesaFormat]( &convert );
+}
+
+
+
+/* Nearest filtering only (for broken hardware that can't support
+ * all aspect ratios). This can be made a lot faster, but I don't
+ * really care enough...
*/
-void
-_mesa_set_teximage_component_sizes(MesaIntTexFormat mesaFormat,
- struct gl_texture_image *texImage)
+void _mesa_rescale_teximage2d( GLint texelBytes,
+ GLint srcWidth, GLint srcHeight,
+ GLint dstWidth, GLint dstHeight,
+ const GLvoid *srcImage, GLvoid *dstImage )
{
- static const GLint bitSizes [][8] = {
- /* format R G B A I L C */
- { MESA_I8, 0, 0, 0, 0, 8, 0, 0 },
- { MESA_L8, 0, 0, 0, 0, 0, 8, 0 },
- { MESA_A8, 0, 0, 0, 8, 0, 0, 0 },
- { MESA_C8, 0, 0, 0, 0, 0, 0, 8 },
- { MESA_A8_L8, 0, 0, 0, 8, 0, 8, 0 },
- { MESA_R5_G6_B5, 5, 6, 5, 0, 0, 0, 0 },
- { MESA_A4_R4_G4_B4, 4, 4, 4, 4, 0, 0, 0 },
- { MESA_A1_R5_G5_B5, 5, 5, 5, 1, 0, 0, 0 },
- { MESA_A8_R8_G8_B8, 8, 8, 8, 8, 0, 0, 0 },
- { MESA_FF_R8_G8_B8, 8, 8, 8, 8, 0, 0, 0 },
- { -1, 0, 0, 0, 0, 0, 0, 0 }
- };
- GLint i;
- for (i = 0; i < bitSizes[i][0] >= 0; i++) {
- if (bitSizes[i][0] == mesaFormat) {
- texImage->RedBits = bitSizes[i][1];
- texImage->GreenBits = bitSizes[i][2];
- texImage->BlueBits = bitSizes[i][3];
- texImage->AlphaBits = bitSizes[i][4];
- texImage->IntensityBits = bitSizes[i][5];
- texImage->LuminanceBits = bitSizes[i][6];
- texImage->IndexBits = bitSizes[i][7];
- return;
- }
+ GLint row, col;
+
+#define INNER_LOOP( HOP, WOP ) \
+ for ( row = 0 ; row < dstHeight ; row++ ) { \
+ GLint srcRow = row HOP hScale; \
+ for ( col = 0 ; col < dstWidth ; col++ ) { \
+ GLint srcCol = col WOP wScale; \
+ *dst++ = src[srcRow * srcWidth + srcCol]; \
+ } \
+ } \
+
+#define RESCALE_IMAGE( TYPE ) \
+do { \
+ const TYPE *src = (const TYPE *)srcImage; \
+ TYPE *dst = (TYPE *)dstImage; \
+ \
+ if ( srcHeight <= dstHeight ) { \
+ const GLint hScale = dstHeight / srcHeight; \
+ if ( srcWidth <= dstWidth ) { \
+ const GLint wScale = dstWidth / srcWidth; \
+ INNER_LOOP( /, / ); \
+ } \
+ else { \
+ const GLint wScale = srcWidth / dstWidth; \
+ INNER_LOOP( /, * ); \
+ } \
+ } \
+ else { \
+ const GLint hScale = srcHeight / dstHeight; \
+ if ( srcWidth <= dstWidth ) { \
+ const GLint wScale = dstWidth / srcWidth; \
+ INNER_LOOP( *, / ); \
+ } \
+ else { \
+ const GLint wScale = srcWidth / dstWidth; \
+ INNER_LOOP( *, * ); \
+ } \
+ } \
+} while (0)
+
+ switch ( texelBytes ) {
+ case 4:
+ RESCALE_IMAGE( GLuint );
+ break;
+
+ case 2:
+ RESCALE_IMAGE( GLushort );
+ break;
+
+ case 1:
+ RESCALE_IMAGE( GLubyte );
+ break;
}
- gl_problem(NULL, "bad format in _mesa_set_teximage_component_sizes");
}
diff --git a/xc/extras/Mesa/src/texutil.h b/xc/extras/Mesa/src/texutil.h
index f1fbcfab2..f0e4a984c 100644
--- a/xc/extras/Mesa/src/texutil.h
+++ b/xc/extras/Mesa/src/texutil.h
@@ -2,91 +2,86 @@
/*
* Mesa 3-D graphics library
* Version: 3.4
- *
+ *
* Copyright (C) 1999-2000 Brian Paul All Rights Reserved.
- *
+ *
* Permission is hereby granted, free of charge, to any person obtaining a
* copy of this software and associated documentation files (the "Software"),
* to deal in the Software without restriction, including without limitation
* the rights to use, copy, modify, merge, publish, distribute, sublicense,
* and/or sell copies of the Software, and to permit persons to whom the
* Software is furnished to do so, subject to the following conditions:
- *
+ *
* The above copyright notice and this permission notice shall be included
* in all copies or substantial portions of the Software.
- *
+ *
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
* OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
* BRIAN PAUL BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN
* AN ACTION 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 <gareth@valinux.com>
*/
-/* $XFree86: xc/extras/Mesa/src/texutil.h,v 1.3 2000/09/26 15:56:34 tsi Exp $ */
+
#ifndef TEXUTIL_H
#define TEXUTIL_H
-
#include "types.h"
-
-
-
-/*
- * NOTE: "FF" means fill with byte value 0xff
- */
- /* msb <------ TEXEL BITS -----------> lsb */
-typedef enum { /* ---- ---- ---- ---- ---- ---- ---- ---- */
- MESA_I8, /* IIII IIII */
- MESA_L8, /* LLLL LLLL */
- MESA_A8, /* AAAA AAAA */
- MESA_C8, /* CCCC CCCC */
- MESA_A8_L8, /* AAAA AAAA LLLL LLLL */
- MESA_R5_G6_B5, /* RRRR RGGG GGGB BBBB */
- MESA_A4_R4_G4_B4, /* AAAA RRRR GGGG BBBB */
- MESA_A1_R5_G5_B5, /* ARRR RRGG GGGB BBBB */
- MESA_A8_R8_G8_B8, /* AAAA AAAA RRRR RRRR GGGG GGGG BBBB BBBB */
- MESA_FF_R8_G8_B8 /* FFFF FFFF RRRR RRRR GGGG GGGG BBBB BBBB */
-} MesaIntTexFormat;
-
-
-
+#include "texformat.h"
extern GLboolean
-_mesa_convert_teximage(MesaIntTexFormat dstFormat,
- GLint dstWidth, GLint dstHeight, GLvoid *dstImage,
- GLint dstRowStride,
- GLint srcWidth, GLint srcHeight,
- GLenum srcFormat, GLenum srcType,
- const GLvoid *srcImage,
- const struct gl_pixelstore_attrib *packing);
-
-
+_mesa_convert_texsubimage1d( GLint mesaFormat,
+ GLint xoffset,
+ GLint width,
+ GLenum format, GLenum type,
+ const struct gl_pixelstore_attrib *packing,
+ const GLvoid *srcImage, GLvoid *dstImage );
extern GLboolean
-_mesa_convert_texsubimage(MesaIntTexFormat dstFormat,
- GLint dstXoffset, GLint dstYoffset,
- GLint dstWidth, GLint dstHeight, GLvoid *dstImage,
- GLint dstRowStride,
- GLint width, GLint height,
- GLint srcWidth, GLint srcHeight,
- GLenum srcFormat, GLenum srcType,
- const GLvoid *srcImage,
- const struct gl_pixelstore_attrib *packing);
-
+_mesa_convert_texsubimage2d( GLint mesaFormat,
+ GLint xoffset, GLint yoffset,
+ GLint width, GLint height,
+ GLint imageWidth,
+ GLenum format, GLenum type,
+ const struct gl_pixelstore_attrib *packing,
+ const GLvoid *srcImage, GLvoid *dstImage );
+extern GLboolean
+_mesa_convert_texsubimage3d( GLint mesaFormat,
+ GLint xoffset, GLint yoffset, GLint zoffset,
+ GLint width, GLint height, GLint depth,
+ GLint imageWidth, GLint imageHeight,
+ GLenum format, GLenum type,
+ const struct gl_pixelstore_attrib *packing,
+ const GLvoid *srcImage, GLvoid *dstImage );
+
+/* Deprecated in 3.5:
+ */
extern void
-_mesa_unconvert_teximage(MesaIntTexFormat srcFormat,
- GLint srcWidth, GLint srcHeight,
- const GLvoid *srcImage, GLint srcRowStride,
- GLint dstWidth, GLint dstHeight,
- GLenum dstFormat, GLubyte *dstImage);
+_mesa_unconvert_teximage1d( GLint mesaFormat, GLenum format, GLint width,
+ const GLvoid *srcImage, GLvoid *dstImage );
+extern void
+_mesa_unconvert_teximage2d( GLint mesaFormat, GLenum format,
+ GLint width, GLint height,
+ const GLvoid *srcImage, GLvoid *dstImage );
extern void
-_mesa_set_teximage_component_sizes(MesaIntTexFormat mesaFormat,
- struct gl_texture_image *texImage);
+_mesa_unconvert_teximage3d( GLint mesaFormat, GLenum format,
+ GLint width, GLint height, GLint depth,
+ const GLvoid *srcImage, GLvoid *dstImage );
+/* Nearest filtering only (for broken hardware that can't support
+ * all aspect ratios). FIXME: Make this a subimage update as well...
+ */
+extern void
+_mesa_rescale_teximage2d( GLint texelBytes,
+ GLint srcWidth, GLint srcHeight,
+ GLint dstWidth, GLint dstHeight,
+ const GLvoid *srcImage, GLvoid *dstImage );
#endif
-
diff --git a/xc/extras/Mesa/src/vbxform.c b/xc/extras/Mesa/src/vbxform.c
index 081f9d181..9cfea485d 100644
--- a/xc/extras/Mesa/src/vbxform.c
+++ b/xc/extras/Mesa/src/vbxform.c
@@ -890,6 +890,7 @@ void gl_execute_cassette( GLcontext *ctx, struct immediate *IM )
VB->ColorPtr = &IM->v.Color;
VB->Color[0] = VB->Color[1] = VB->ColorPtr;
VB->IndexPtr = &IM->v.Index;
+ VB->Index[0] = VB->Index[1] = VB->IndexPtr;
VB->EdgeFlagPtr = &IM->v.EdgeFlag;
VB->TexCoordPtr[0] = &IM->v.TexCoord[0];
VB->TexCoordPtr[1] = &IM->v.TexCoord[1];