summaryrefslogtreecommitdiff
path: root/src/mesa
diff options
context:
space:
mode:
authorBrian Paul <brian.paul@tungstengraphics.com>2004-04-22 00:27:31 +0000
committerBrian Paul <brian.paul@tungstengraphics.com>2004-04-22 00:27:31 +0000
commitf959f6e1dc27c71fc0ccc56e09b29101b3bf3b97 (patch)
tree15b4171c2b3396e3a05f2776cc24d90cb37c8f84 /src/mesa
parent05a6f2fd484bab59c6e6a381f58808adc26619f1 (diff)
New glTexImage code.
The gl_texture_format struct now has a StoreTexImageFunc that's called by glTex[Sub]Image[123]D to convert the user's texture data into the specific texture format layout. Now it's much easier to add new texture formats (like the 16/32-bit floating point formats). The texutil.[ch] and texutil_tmp.h files are obsolete.
Diffstat (limited to 'src/mesa')
-rw-r--r--src/mesa/drivers/dri/r200/r200_tex.c11
-rw-r--r--src/mesa/drivers/dri/tdfx/tdfx_tex.c40
-rw-r--r--src/mesa/main/colortab.c4
-rw-r--r--src/mesa/main/convolve.c10
-rw-r--r--src/mesa/main/extensions.c4
-rw-r--r--src/mesa/main/glheader.h36
-rw-r--r--src/mesa/main/histogram.c96
-rw-r--r--src/mesa/main/image.c87
-rw-r--r--src/mesa/main/image.h2
-rw-r--r--src/mesa/main/imports.c10
-rw-r--r--src/mesa/main/imports.h21
-rw-r--r--src/mesa/main/mtypes.h46
-rw-r--r--src/mesa/main/texformat.c749
-rw-r--r--src/mesa/main/texformat.h92
-rw-r--r--src/mesa/main/texformat_tmp.h338
-rw-r--r--src/mesa/main/teximage.c197
-rw-r--r--src/mesa/main/texstate.c66
-rw-r--r--src/mesa/main/texstore.c1912
-rw-r--r--src/mesa/main/texstore.h56
-rw-r--r--src/mesa/main/texutil.c5
-rw-r--r--src/mesa/swrast/s_drawpix.c2
-rw-r--r--src/mesa/swrast/s_readpix.c8
22 files changed, 3264 insertions, 528 deletions
diff --git a/src/mesa/drivers/dri/r200/r200_tex.c b/src/mesa/drivers/dri/r200/r200_tex.c
index 2a5603b4d5..6ce143dace 100644
--- a/src/mesa/drivers/dri/r200/r200_tex.c
+++ b/src/mesa/drivers/dri/r200/r200_tex.c
@@ -445,7 +445,6 @@ r200ValidateClientStorage( GLcontext *ctx, GLenum target,
{
r200ContextPtr rmesa = R200_CONTEXT(ctx);
- int texelBytes;
if (0)
fprintf(stderr, "intformat %s format %s type %s\n",
@@ -468,7 +467,6 @@ r200ValidateClientStorage( GLcontext *ctx, GLenum target,
case GL_RGBA:
if ( format == GL_BGRA && type == GL_UNSIGNED_INT_8_8_8_8_REV ) {
texImage->TexFormat = &_mesa_texformat_argb8888;
- texelBytes = 4;
}
else
return 0;
@@ -477,7 +475,6 @@ r200ValidateClientStorage( GLcontext *ctx, GLenum target,
case GL_RGB:
if ( format == GL_RGB && type == GL_UNSIGNED_SHORT_5_6_5 ) {
texImage->TexFormat = &_mesa_texformat_rgb565;
- texelBytes = 2;
}
else
return 0;
@@ -487,19 +484,16 @@ r200ValidateClientStorage( GLcontext *ctx, GLenum target,
if ( format == GL_YCBCR_MESA &&
type == GL_UNSIGNED_SHORT_8_8_REV_APPLE ) {
texImage->TexFormat = &_mesa_texformat_ycbcr_rev;
- texelBytes = 2;
}
else if ( format == GL_YCBCR_MESA &&
(type == GL_UNSIGNED_SHORT_8_8_APPLE ||
type == GL_UNSIGNED_BYTE)) {
texImage->TexFormat = &_mesa_texformat_ycbcr;
- texelBytes = 2;
}
else
return 0;
break;
-
-
+
default:
return 0;
}
@@ -538,7 +532,8 @@ r200ValidateClientStorage( GLcontext *ctx, GLenum target,
*/
texImage->Data = (void *)pixels;
texImage->IsClientData = GL_TRUE;
- texImage->RowStride = srcRowStride / texelBytes;
+ texImage->RowStride = srcRowStride / texImage->TexFormat->TexelBytes;
+
return 1;
}
}
diff --git a/src/mesa/drivers/dri/tdfx/tdfx_tex.c b/src/mesa/drivers/dri/tdfx/tdfx_tex.c
index 8c4ea2d46d..608111032f 100644
--- a/src/mesa/drivers/dri/tdfx/tdfx_tex.c
+++ b/src/mesa/drivers/dri/tdfx/tdfx_tex.c
@@ -963,6 +963,7 @@ tdfxTexImage2D(GLcontext *ctx, GLenum target, GLint level,
return;
}
/* unpack image, apply transfer ops and store in tempImage */
+#if !NEWTEXSTORE
_mesa_transfer_teximage(ctx, 2, texImage->Format,
texImage->TexFormat,
tempImage,
@@ -970,6 +971,15 @@ tdfxTexImage2D(GLcontext *ctx, GLenum target, GLint level,
width * texelBytes,
0, /* dstImageStride */
format, type, pixels, packing);
+#else
+ texImage->TexFormat->StoreImage(ctx, 2, texImage->Format,
+ texImage->Format, tempImage,
+ 0, 0, 0, /* dstX/Y/Zoffset */
+ width * texelBytes, /* dstRowStride */
+ 0, /* dstImageStride */
+ width, height, 1,
+ format, type, pixels, packing);
+#endif
assert(!texImage->Data);
texImage->Data = MESA_PBUFFER_ALLOC(mml->width * mml->height * texelBytes);
if (!texImage->Data) {
@@ -993,6 +1003,7 @@ tdfxTexImage2D(GLcontext *ctx, GLenum target, GLint level,
return;
}
/* unpack image, apply transfer ops and store in texImage->Data */
+#if !NEWTEXSTORE
_mesa_transfer_teximage(ctx, 2, texImage->Format,
texImage->TexFormat, texImage->Data,
width, height, 1, 0, 0, 0,
@@ -1000,6 +1011,15 @@ tdfxTexImage2D(GLcontext *ctx, GLenum target, GLint level,
0, /* dstImageStride */
format, type, pixels, packing);
}
+#else
+ texImage->TexFormat->StoreImage(ctx, 2, texImage->Format,
+ texImage->Format, texImage->Data,
+ 0, 0, 0, /* dstX/Y/Zoffset */
+ width * texelBytes, /* dstRowStride */
+ 0, /* dstImageStride */
+ width, height, 1,
+ format, type, pixels, packing);
+#endif
RevalidateTexture(ctx, texObj);
@@ -1050,6 +1070,7 @@ tdfxTexSubImage2D(GLcontext *ctx, GLenum target, GLint level,
return;
}
+#if !NEWTEXSTORE
_mesa_transfer_teximage(ctx, 2, texImage->Format,/* Tex int format */
texImage->TexFormat, /* dest format */
(GLubyte *) tempImage, /* dest */
@@ -1058,6 +1079,15 @@ tdfxTexSubImage2D(GLcontext *ctx, GLenum target, GLint level,
width * texelBytes, /* dest row stride */
0, /* dst image stride */
format, type, pixels, packing);
+#else
+ texImage->TexFormat->StoreImage(ctx, 2, texImage->Format,
+ texImage->Format, texImage->Data,
+ 0, 0, 0, /* dstX/Y/Zoffset */
+ width * texelBytes, /* dstRowStride */
+ 0, /* dstImageStride */
+ width, height, 1,
+ format, type, pixels, packing);
+#endif
/* now rescale */
scaledImage = MALLOC(newWidth * newHeight * texelBytes);
@@ -1083,6 +1113,7 @@ tdfxTexSubImage2D(GLcontext *ctx, GLenum target, GLint level,
}
else {
/* no rescaling needed */
+#if !NEWTEXSTORE
_mesa_transfer_teximage(ctx, 2, texImage->Format, /* Tex int format */
texImage->TexFormat, /* dest format */
(GLubyte *) texImage->Data,/* dest */
@@ -1091,6 +1122,15 @@ tdfxTexSubImage2D(GLcontext *ctx, GLenum target, GLint level,
mml->width * texelBytes, /* dest row stride */
0, /* dst image stride */
format, type, pixels, packing);
+#else
+ texImage->TexFormat->StoreImage(ctx, 2, texImage->Format,
+ texImage->Format, texImage->Data,
+ xoffset, yoffset, 0,
+ mml->width * texelBytes, /* dstRowStride */
+ 0, /* dstImageStride */
+ width, height, 1,
+ format, type, pixels, packing);
+#endif
}
ti->reloadImages = GL_TRUE; /* signal the image needs to be reloaded */
diff --git a/src/mesa/main/colortab.c b/src/mesa/main/colortab.c
index 862f210bb9..59cd6ae0c1 100644
--- a/src/mesa/main/colortab.c
+++ b/src/mesa/main/colortab.c
@@ -414,7 +414,7 @@ _mesa_ColorTable( GLenum target, GLenum internalFormat,
assert(table);
- if (!_mesa_is_legal_format_and_type(format, type) ||
+ if (!_mesa_is_legal_format_and_type(ctx, format, type) ||
format == GL_INTENSITY) {
_mesa_error(ctx, GL_INVALID_OPERATION, "glColorTable(format or type)");
return;
@@ -596,7 +596,7 @@ _mesa_ColorSubTable( GLenum target, GLsizei start,
assert(table);
- if (!_mesa_is_legal_format_and_type(format, type) ||
+ if (!_mesa_is_legal_format_and_type(ctx, format, type) ||
format == GL_INTENSITY) {
_mesa_error(ctx, GL_INVALID_OPERATION, "glColorSubTable(format or type)");
return;
diff --git a/src/mesa/main/convolve.c b/src/mesa/main/convolve.c
index c1965c5feb..adc279069b 100644
--- a/src/mesa/main/convolve.c
+++ b/src/mesa/main/convolve.c
@@ -123,7 +123,7 @@ _mesa_ConvolutionFilter1D(GLenum target, GLenum internalFormat, GLsizei width, G
return;
}
- if (!_mesa_is_legal_format_and_type(format, type)) {
+ if (!_mesa_is_legal_format_and_type(ctx, format, type)) {
_mesa_error(ctx, GL_INVALID_OPERATION, "glConvolutionFilter1D(format or type)");
return;
}
@@ -201,7 +201,7 @@ _mesa_ConvolutionFilter2D(GLenum target, GLenum internalFormat, GLsizei width, G
return;
}
- if (!_mesa_is_legal_format_and_type(format, type)) {
+ if (!_mesa_is_legal_format_and_type(ctx, format, type)) {
_mesa_error(ctx, GL_INVALID_OPERATION, "glConvolutionFilter2D(format or type)");
return;
}
@@ -532,7 +532,7 @@ _mesa_GetConvolutionFilter(GLenum target, GLenum format, GLenum type, GLvoid *im
_mesa_update_state(ctx);
}
- if (!_mesa_is_legal_format_and_type(format, type)) {
+ if (!_mesa_is_legal_format_and_type(ctx, format, type)) {
_mesa_error(ctx, GL_INVALID_OPERATION, "glGetConvolutionFilter(format or type)");
return;
}
@@ -718,7 +718,7 @@ _mesa_GetSeparableFilter(GLenum target, GLenum format, GLenum type, GLvoid *row,
return;
}
- if (!_mesa_is_legal_format_and_type(format, type)) {
+ if (!_mesa_is_legal_format_and_type(ctx, format, type)) {
_mesa_error(ctx, GL_INVALID_OPERATION, "glGetConvolutionFilter(format or type)");
return;
}
@@ -787,7 +787,7 @@ _mesa_SeparableFilter2D(GLenum target, GLenum internalFormat, GLsizei width, GLs
return;
}
- if (!_mesa_is_legal_format_and_type(format, type)) {
+ if (!_mesa_is_legal_format_and_type(ctx, format, type)) {
_mesa_error(ctx, GL_INVALID_OPERATION, "glSeparableFilter2D(format or type)");
return;
}
diff --git a/src/mesa/main/extensions.c b/src/mesa/main/extensions.c
index 2ae48b4edb..67612b671a 100644
--- a/src/mesa/main/extensions.c
+++ b/src/mesa/main/extensions.c
@@ -43,6 +43,7 @@ static const struct {
} default_extensions[] = {
{ OFF, "GL_ARB_depth_texture", F(ARB_depth_texture) },
{ OFF, "GL_ARB_fragment_program", F(ARB_fragment_program) },
+ { OFF, "GL_MESAX_half_float_pixel", F(ARB_half_float_pixel) },
{ OFF, "GL_ARB_imaging", F(ARB_imaging) },
{ OFF, "GL_ARB_multisample", F(ARB_multisample) },
{ OFF, "GL_ARB_multitexture", F(ARB_multitexture) },
@@ -58,6 +59,7 @@ static const struct {
{ OFF, "GL_ARB_texture_env_combine", F(ARB_texture_env_combine) },
{ OFF, "GL_ARB_texture_env_crossbar", F(ARB_texture_env_crossbar) },
{ OFF, "GL_ARB_texture_env_dot3", F(ARB_texture_env_dot3) },
+ { OFF, "GL_MESAX_texture_float", F(ARB_texture_float) },
{ OFF, "GL_ARB_texture_mirrored_repeat", F(ARB_texture_mirrored_repeat)},
{ OFF, "GL_ARB_texture_non_power_of_two", F(ARB_texture_non_power_of_two)},
{ ON, "GL_ARB_transpose_matrix", F(ARB_transpose_matrix) },
@@ -162,6 +164,7 @@ _mesa_enable_sw_extensions(GLcontext *ctx)
#if FEATURE_ARB_fragment_program
/*ctx->Extensions.ARB_fragment_program = GL_TRUE;*/
#endif
+ ctx->Extensions.ARB_half_float_pixel = GL_TRUE;
ctx->Extensions.ARB_imaging = GL_TRUE;
ctx->Extensions.ARB_multitexture = GL_TRUE;
#if FEATURE_ARB_occlusion_query
@@ -174,6 +177,7 @@ _mesa_enable_sw_extensions(GLcontext *ctx)
ctx->Extensions.ARB_texture_env_combine = GL_TRUE;
ctx->Extensions.ARB_texture_env_crossbar = GL_TRUE;
ctx->Extensions.ARB_texture_env_dot3 = GL_TRUE;
+ ctx->Extensions.ARB_texture_float = GL_TRUE;
ctx->Extensions.ARB_texture_mirrored_repeat = GL_TRUE;
ctx->Extensions.ARB_texture_non_power_of_two = GL_TRUE;
#if FEATURE_ARB_vertex_program
diff --git a/src/mesa/main/glheader.h b/src/mesa/main/glheader.h
index dd4a404fc8..19eff31841 100644
--- a/src/mesa/main/glheader.h
+++ b/src/mesa/main/glheader.h
@@ -220,6 +220,42 @@ typedef struct tagPIXELFORMATDESCRIPTOR PIXELFORMATDESCRIPTOR, *PPIXELFORMATDESC
#endif
+/* XXX temporary hack */
+#ifndef GL_ARB_half_float_pixel
+#define GL_ARB_half_float_pixel 1
+#define GL_HALF_FLOAT_ARB 0x140B
+typedef GLushort GLhalfARB;
+#endif
+
+
+/* XXX temporary hack */
+#ifndef GL_ARB_texture_float
+#define GL_ARB_texture_float 1
+#define GL_TEXTURE_RED_TYPE_ARB 0x9000
+#define GL_TEXTURE_GREEN_TYPE_ARB 0x9001
+#define GL_TEXTURE_BLUE_TYPE_ARB 0x9002
+#define GL_TEXTURE_ALPHA_TYPE_ARB 0x9003
+#define GL_TEXTURE_LUMINANCE_TYPE_ARB 0x9004
+#define GL_TEXTURE_INTENSITY_TYPE_ARB 0x9005
+#define GL_TEXTURE_DEPTH_TYPE_ARB 0x9006
+#define GL_UNSIGNED_NORMALIZED_ARB 0x9007
+#define GL_RGBA32F_ARB 0x8814
+#define GL_RGB32F_ARB 0x8815
+#define GL_ALPHA32F_ARB 0x8816
+#define GL_INTENSITY32F_ARB 0x8817
+#define GL_LUMINANCE32F_ARB 0x8818
+#define GL_LUMINANCE_ALPHA32F_ARB 0x8819
+#define GL_RGBA16F_ARB 0x881A
+#define GL_RGB16F_ARB 0x881B
+#define GL_ALPHA16F_ARB 0x881C
+#define GL_INTENSITY16F_ARB 0x881D
+#define GL_LUMINANCE16F_ARB 0x881E
+#define GL_LUMINANCE_ALPHA16F_ARB 0x881F
+#endif
+
+
+
+
/* Disable unreachable code warnings for Watcom C++ */
#ifdef __WATCOMC__
#pragma disable_message(201)
diff --git a/src/mesa/main/histogram.c b/src/mesa/main/histogram.c
index 6c44ae6e9e..9cfb378fb1 100644
--- a/src/mesa/main/histogram.c
+++ b/src/mesa/main/histogram.c
@@ -1,9 +1,8 @@
-
/*
* Mesa 3-D graphics library
- * Version: 5.1
+ * Version: 6.1
*
- * Copyright (C) 1999-2003 Brian Paul All Rights Reserved.
+ * Copyright (C) 1999-2004 Brian Paul All Rights Reserved.
*
* Permission is hereby granted, free of charge, to any person obtaining a
* copy of this software and associated documentation files (the "Software"),
@@ -247,6 +246,23 @@ pack_histogram( GLcontext *ctx,
}
}
break;
+ case GL_HALF_FLOAT_ARB:
+ {
+ /* temporarily store as GLuints */
+ GLuint temp[4*HISTOGRAM_TABLE_SIZE];
+ GLhalfARB *dst = (GLhalfARB *) destination;
+ GLuint i;
+ /* get GLuint values */
+ PACK_MACRO(GLuint);
+ /* convert to GLhalf */
+ for (i = 0; i < n * comps; i++) {
+ dst[i] = _mesa_float_to_half((GLfloat) temp[i]);
+ }
+ if (packing->SwapBytes) {
+ _mesa_swap2((GLushort *) dst, n * comps);
+ }
+ }
+ break;
case GL_UNSIGNED_BYTE_3_3_2:
if (format == GL_RGB) {
GLubyte *dst = (GLubyte *) destination;
@@ -678,31 +694,22 @@ _mesa_GetMinmax(GLenum target, GLboolean reset, GLenum format, GLenum type, GLvo
return;
}
- if (!_mesa_is_legal_format_and_type(format, type)) {
- _mesa_error(ctx, GL_INVALID_OPERATION, "glGetMinmax(format or type)");
- return;
+ if (format != GL_RED &&
+ format != GL_GREEN &&
+ format != GL_BLUE &&
+ format != GL_ALPHA &&
+ format != GL_RGB &&
+ format != GL_BGR &&
+ format != GL_RGBA &&
+ format != GL_BGRA &&
+ format != GL_ABGR_EXT &&
+ format != GL_LUMINANCE &&
+ format != GL_LUMINANCE_ALPHA) {
+ _mesa_error(ctx, GL_INVALID_ENUM, "glGetHistogram(format)");
}
- if (type != GL_UNSIGNED_BYTE &&
- type != GL_BYTE &&
- type != GL_UNSIGNED_SHORT &&
- type != GL_SHORT &&
- type != GL_UNSIGNED_INT &&
- type != GL_INT &&
- type != GL_FLOAT &&
- type != GL_UNSIGNED_BYTE_3_3_2 &&
- type != GL_UNSIGNED_BYTE_2_3_3_REV &&
- type != GL_UNSIGNED_SHORT_5_6_5 &&
- type != GL_UNSIGNED_SHORT_5_6_5_REV &&
- type != GL_UNSIGNED_SHORT_4_4_4_4 &&
- type != GL_UNSIGNED_SHORT_4_4_4_4_REV &&
- type != GL_UNSIGNED_SHORT_5_5_5_1 &&
- type != GL_UNSIGNED_SHORT_1_5_5_5_REV &&
- type != GL_UNSIGNED_INT_8_8_8_8 &&
- type != GL_UNSIGNED_INT_8_8_8_8_REV &&
- type != GL_UNSIGNED_INT_10_10_10_2 &&
- type != GL_UNSIGNED_INT_2_10_10_10_REV) {
- _mesa_error(ctx, GL_INVALID_ENUM, "glGetMinmax(type)");
+ if (!_mesa_is_legal_format_and_type(ctx, format, type)) {
+ _mesa_error(ctx, GL_INVALID_OPERATION, "glGetMinmax(format or type)");
return;
}
@@ -745,31 +752,22 @@ _mesa_GetHistogram(GLenum target, GLboolean reset, GLenum format, GLenum type, G
return;
}
- if (!_mesa_is_legal_format_and_type(format, type)) {
- _mesa_error(ctx, GL_INVALID_OPERATION, "glGetHistogram(format or type)");
- return;
+ if (format != GL_RED &&
+ format != GL_GREEN &&
+ format != GL_BLUE &&
+ format != GL_ALPHA &&
+ format != GL_RGB &&
+ format != GL_BGR &&
+ format != GL_RGBA &&
+ format != GL_BGRA &&
+ format != GL_ABGR_EXT &&
+ format != GL_LUMINANCE &&
+ format != GL_LUMINANCE_ALPHA) {
+ _mesa_error(ctx, GL_INVALID_ENUM, "glGetHistogram(format)");
}
- if (type != GL_UNSIGNED_BYTE &&
- type != GL_BYTE &&
- type != GL_UNSIGNED_SHORT &&
- type != GL_SHORT &&
- type != GL_UNSIGNED_INT &&
- type != GL_INT &&
- type != GL_FLOAT &&
- type != GL_UNSIGNED_BYTE_3_3_2 &&
- type != GL_UNSIGNED_BYTE_2_3_3_REV &&
- type != GL_UNSIGNED_SHORT_5_6_5 &&
- type != GL_UNSIGNED_SHORT_5_6_5_REV &&
- type != GL_UNSIGNED_SHORT_4_4_4_4 &&
- type != GL_UNSIGNED_SHORT_4_4_4_4_REV &&
- type != GL_UNSIGNED_SHORT_5_5_5_1 &&
- type != GL_UNSIGNED_SHORT_1_5_5_5_REV &&
- type != GL_UNSIGNED_INT_8_8_8_8 &&
- type != GL_UNSIGNED_INT_8_8_8_8_REV &&
- type != GL_UNSIGNED_INT_10_10_10_2 &&
- type != GL_UNSIGNED_INT_2_10_10_10_REV) {
- _mesa_error(ctx, GL_INVALID_ENUM, "glGetHistogram(type)");
+ if (!_mesa_is_legal_format_and_type(ctx, format, type)) {
+ _mesa_error(ctx, GL_INVALID_OPERATION, "glGetHistogram(format or type)");
return;
}
diff --git a/src/mesa/main/image.c b/src/mesa/main/image.c
index d610865996..4eba8e8415 100644
--- a/src/mesa/main/image.c
+++ b/src/mesa/main/image.c
@@ -1,8 +1,3 @@
-/**
- * \file image.c
- * Image handling.
- */
-
/*
* Mesa 3-D graphics library
* Version: 6.1
@@ -28,6 +23,12 @@
*/
+/**
+ * \file image.c
+ * Image handling.
+ */
+
+
#include "glheader.h"
#include "bufferobj.h"
#include "colormac.h"
@@ -141,8 +142,8 @@ GLint _mesa_sizeof_type( GLenum type )
return sizeof(GLint);
case GL_FLOAT:
return sizeof(GLfloat);
- case GL_HALF_FLOAT_NV:
- return sizeof(GLhalfNV);
+ case GL_HALF_FLOAT_ARB:
+ return sizeof(GLhalfARB);
default:
return -1;
}
@@ -170,8 +171,8 @@ GLint _mesa_sizeof_packed_type( GLenum type )
return sizeof(GLuint);
case GL_INT:
return sizeof(GLint);
- case GL_HALF_FLOAT_NV:
- return sizeof(GLhalfNV);
+ case GL_HALF_FLOAT_ARB:
+ return sizeof(GLhalfARB);
case GL_FLOAT:
return sizeof(GLfloat);
case GL_UNSIGNED_BYTE_3_3_2:
@@ -281,8 +282,8 @@ GLint _mesa_bytes_per_pixel( GLenum format, GLenum type )
return comps * sizeof(GLint);
case GL_FLOAT:
return comps * sizeof(GLfloat);
- case GL_HALF_FLOAT_NV:
- return comps * sizeof(GLhalfNV);
+ case GL_HALF_FLOAT_ARB:
+ return comps * sizeof(GLhalfARB);
case GL_UNSIGNED_BYTE_3_3_2:
case GL_UNSIGNED_BYTE_2_3_3_REV:
if (format == GL_RGB || format == GL_BGR)
@@ -333,7 +334,7 @@ GLint _mesa_bytes_per_pixel( GLenum format, GLenum type )
* otherwise.
*/
GLboolean
-_mesa_is_legal_format_and_type( GLenum format, GLenum type )
+_mesa_is_legal_format_and_type( GLcontext *ctx, GLenum format, GLenum type )
{
switch (format) {
case GL_COLOR_INDEX:
@@ -347,8 +348,9 @@ _mesa_is_legal_format_and_type( GLenum format, GLenum type )
case GL_INT:
case GL_UNSIGNED_INT:
case GL_FLOAT:
- case GL_HALF_FLOAT_NV:
return GL_TRUE;
+ case GL_HALF_FLOAT_ARB:
+ return ctx->Extensions.ARB_half_float_pixel;
default:
return GL_FALSE;
}
@@ -368,8 +370,9 @@ _mesa_is_legal_format_and_type( GLenum format, GLenum type )
case GL_INT:
case GL_UNSIGNED_INT:
case GL_FLOAT:
- case GL_HALF_FLOAT_NV:
return GL_TRUE;
+ case GL_HALF_FLOAT_ARB:
+ return ctx->Extensions.ARB_half_float_pixel;
default:
return GL_FALSE;
}
@@ -383,12 +386,13 @@ _mesa_is_legal_format_and_type( GLenum format, GLenum type )
case GL_INT:
case GL_UNSIGNED_INT:
case GL_FLOAT:
- case GL_HALF_FLOAT_NV:
case GL_UNSIGNED_BYTE_3_3_2:
case GL_UNSIGNED_BYTE_2_3_3_REV:
case GL_UNSIGNED_SHORT_5_6_5:
case GL_UNSIGNED_SHORT_5_6_5_REV:
return GL_TRUE;
+ case GL_HALF_FLOAT_ARB:
+ return ctx->Extensions.ARB_half_float_pixel;
default:
return GL_FALSE;
}
@@ -403,7 +407,6 @@ _mesa_is_legal_format_and_type( GLenum format, GLenum type )
case GL_INT:
case GL_UNSIGNED_INT:
case GL_FLOAT:
- case GL_HALF_FLOAT_NV:
case GL_UNSIGNED_SHORT_4_4_4_4:
case GL_UNSIGNED_SHORT_4_4_4_4_REV:
case GL_UNSIGNED_SHORT_5_5_5_1:
@@ -413,6 +416,8 @@ _mesa_is_legal_format_and_type( GLenum format, GLenum type )
case GL_UNSIGNED_INT_10_10_10_2:
case GL_UNSIGNED_INT_2_10_10_10_REV:
return GL_TRUE;
+ case GL_HALF_FLOAT_ARB:
+ return ctx->Extensions.ARB_half_float_pixel;
default:
return GL_FALSE;
}
@@ -1547,9 +1552,9 @@ _mesa_pack_rgba_span_float( GLcontext *ctx,
}
}
break;
- case GL_HALF_FLOAT_NV:
+ case GL_HALF_FLOAT_ARB:
{
- GLhalfNV *dst = (GLhalfNV *) dstAddr;
+ GLhalfARB *dst = (GLhalfARB *) dstAddr;
switch (dstFormat) {
case GL_RED:
for (i=0;i<n;i++)
@@ -2010,7 +2015,7 @@ extract_uint_indexes(GLuint n, GLuint indexes[],
srcType == GL_SHORT ||
srcType == GL_UNSIGNED_INT ||
srcType == GL_INT ||
- srcType == GL_HALF_FLOAT_NV ||
+ srcType == GL_HALF_FLOAT_ARB ||
srcType == GL_FLOAT);
switch (srcType) {
@@ -2148,13 +2153,13 @@ extract_uint_indexes(GLuint n, GLuint indexes[],
}
}
break;
- case GL_HALF_FLOAT_NV:
+ case GL_HALF_FLOAT_ARB:
{
GLuint i;
- const GLhalfNV *s = (const GLhalfNV *) src;
+ const GLhalfARB *s = (const GLhalfARB *) src;
if (unpack->SwapBytes) {
for (i = 0; i < n; i++) {
- GLhalfNV value = s[i];
+ GLhalfARB value = s[i];
SWAP2BYTE(value);
indexes[i] = (GLuint) _mesa_half_to_float(value);
}
@@ -2216,7 +2221,7 @@ extract_float_rgba(GLuint n, GLfloat rgba[][4],
srcType == GL_SHORT ||
srcType == GL_UNSIGNED_INT ||
srcType == GL_INT ||
- srcType == GL_HALF_FLOAT_NV ||
+ srcType == GL_HALF_FLOAT_ARB ||
srcType == GL_FLOAT ||
srcType == GL_UNSIGNED_BYTE_3_3_2 ||
srcType == GL_UNSIGNED_BYTE_2_3_3_REV ||
@@ -2395,11 +2400,11 @@ extract_float_rgba(GLuint n, GLfloat rgba[][4],
PROCESS(blueIndex, BCOMP, 0.0F, GLfloat, (GLfloat));
PROCESS(alphaIndex, ACOMP, 1.0F, GLfloat, (GLfloat));
break;
- case GL_HALF_FLOAT_NV:
- PROCESS(redIndex, RCOMP, 0.0F, GLhalfNV, _mesa_half_to_float);
- PROCESS(greenIndex, GCOMP, 0.0F, GLhalfNV, _mesa_half_to_float);
- PROCESS(blueIndex, BCOMP, 0.0F, GLhalfNV, _mesa_half_to_float);
- PROCESS(alphaIndex, ACOMP, 1.0F, GLhalfNV, _mesa_half_to_float);
+ case GL_HALF_FLOAT_ARB:
+ PROCESS(redIndex, RCOMP, 0.0F, GLhalfARB, _mesa_half_to_float);
+ PROCESS(greenIndex, GCOMP, 0.0F, GLhalfARB, _mesa_half_to_float);
+ PROCESS(blueIndex, BCOMP, 0.0F, GLhalfARB, _mesa_half_to_float);
+ PROCESS(alphaIndex, ACOMP, 1.0F, GLhalfARB, _mesa_half_to_float);
break;
case GL_UNSIGNED_BYTE_3_3_2:
{
@@ -2736,7 +2741,7 @@ _mesa_unpack_color_span_chan( GLcontext *ctx,
srcType == GL_SHORT ||
srcType == GL_UNSIGNED_INT ||
srcType == GL_INT ||
- srcType == GL_HALF_FLOAT_NV ||
+ srcType == GL_HALF_FLOAT_ARB ||
srcType == GL_FLOAT ||
srcType == GL_UNSIGNED_BYTE_3_3_2 ||
srcType == GL_UNSIGNED_BYTE_2_3_3_REV ||
@@ -2752,7 +2757,7 @@ _mesa_unpack_color_span_chan( GLcontext *ctx,
srcType == GL_UNSIGNED_INT_2_10_10_10_REV);
/* Try simple cases first */
- if (transferOps == 0 ){
+ if (transferOps == 0) {
if (srcType == CHAN_TYPE) {
if (dstFormat == GL_RGBA) {
if (srcFormat == GL_RGBA) {
@@ -3080,7 +3085,7 @@ _mesa_unpack_color_span_float( GLcontext *ctx,
srcType == GL_SHORT ||
srcType == GL_UNSIGNED_INT ||
srcType == GL_INT ||
- srcType == GL_HALF_FLOAT_NV ||
+ srcType == GL_HALF_FLOAT_ARB ||
srcType == GL_FLOAT ||
srcType == GL_UNSIGNED_BYTE_3_3_2 ||
srcType == GL_UNSIGNED_BYTE_2_3_3_REV ||
@@ -3288,7 +3293,7 @@ _mesa_unpack_index_span( const GLcontext *ctx, GLuint n,
srcType == GL_SHORT ||
srcType == GL_UNSIGNED_INT ||
srcType == GL_INT ||
- srcType == GL_HALF_FLOAT_NV ||
+ srcType == GL_HALF_FLOAT_ARB ||
srcType == GL_FLOAT);
ASSERT(dstType == GL_UNSIGNED_BYTE ||
@@ -3461,9 +3466,9 @@ _mesa_pack_index_span( const GLcontext *ctx, GLuint n,
}
}
break;
- case GL_HALF_FLOAT_NV:
+ case GL_HALF_FLOAT_ARB:
{
- GLhalfNV *dst = (GLhalfNV *) dest;
+ GLhalfARB *dst = (GLhalfARB *) dest;
GLuint i;
for (i = 0; i < n; i++) {
dst[i] = _mesa_float_to_half((GLfloat) source[i]);
@@ -3507,7 +3512,7 @@ _mesa_unpack_stencil_span( const GLcontext *ctx, GLuint n,
srcType == GL_SHORT ||
srcType == GL_UNSIGNED_INT ||
srcType == GL_INT ||
- srcType == GL_HALF_FLOAT_NV ||
+ srcType == GL_HALF_FLOAT_ARB ||
srcType == GL_FLOAT);
ASSERT(dstType == GL_UNSIGNED_BYTE ||
@@ -3694,9 +3699,9 @@ _mesa_pack_stencil_span( const GLcontext *ctx, GLuint n,
}
}
break;
- case GL_HALF_FLOAT_NV:
+ case GL_HALF_FLOAT_ARB:
{
- GLhalfNV *dst = (GLhalfNV *) dest;
+ GLhalfARB *dst = (GLhalfARB *) dest;
GLuint i;
for (i=0;i<n;i++) {
dst[i] = _mesa_float_to_half( (float) source[i] );
@@ -3807,10 +3812,10 @@ _mesa_unpack_depth_span( const GLcontext *ctx, GLuint n, GLfloat *dest,
case GL_FLOAT:
MEMCPY(dest, source, n * sizeof(GLfloat));
break;
- case GL_HALF_FLOAT_NV:
+ case GL_HALF_FLOAT_ARB:
{
GLuint i;
- const GLhalfNV *src = (const GLhalfNV *) source;
+ const GLhalfARB *src = (const GLhalfARB *) source;
for (i = 0; i < n; i++) {
dest[i] = _mesa_half_to_float(src[i]);
}
@@ -3936,9 +3941,9 @@ _mesa_pack_depth_span( const GLcontext *ctx, GLuint n, GLvoid *dest,
}
}
break;
- case GL_HALF_FLOAT_NV:
+ case GL_HALF_FLOAT_ARB:
{
- GLhalfNV *dst = (GLhalfNV *) dest;
+ GLhalfARB *dst = (GLhalfARB *) dest;
GLuint i;
for (i = 0; i < n; i++) {
dst[i] = _mesa_float_to_half(depthSpan[i]);
diff --git a/src/mesa/main/image.h b/src/mesa/main/image.h
index ffe629e103..c0c65fe5ef 100644
--- a/src/mesa/main/image.h
+++ b/src/mesa/main/image.h
@@ -54,7 +54,7 @@ extern GLint
_mesa_bytes_per_pixel( GLenum format, GLenum type );
extern GLboolean
-_mesa_is_legal_format_and_type( GLenum format, GLenum type );
+_mesa_is_legal_format_and_type( GLcontext *ctx, GLenum format, GLenum type );
extern GLvoid *
diff --git a/src/mesa/main/imports.c b/src/mesa/main/imports.c
index f8fa835394..0afc4ea431 100644
--- a/src/mesa/main/imports.c
+++ b/src/mesa/main/imports.c
@@ -32,9 +32,9 @@
/*
* Mesa 3-D graphics library
- * Version: 5.1
+ * Version: 6.1
*
- * Copyright (C) 1999-2003 Brian Paul All Rights Reserved.
+ * Copyright (C) 1999-2004 Brian Paul All Rights Reserved.
*
* Permission is hereby granted, free of charge, to any person obtaining a
* copy of this software and associated documentation files (the "Software"),
@@ -533,7 +533,7 @@ _mesa_bitcount(unsigned int n)
* Based on code from:
* http://www.opengl.org/discussion_boards/ubb/Forum3/HTML/008786.html
*/
-GLhalfNV
+GLhalfARB
_mesa_float_to_half(float val)
{
const int flt = *((int *) &val);
@@ -541,7 +541,7 @@ _mesa_float_to_half(float val)
const int flt_e = (flt >> 23) & 0xff;
const int flt_s = (flt >> 31) & 0x1;
int s, e, m = 0;
- GLhalfNV result;
+ GLhalfARB result;
/* sign bit */
s = flt_s;
@@ -620,7 +620,7 @@ _mesa_float_to_half(float val)
* http://www.opengl.org/discussion_boards/ubb/Forum3/HTML/008786.html
*/
float
-_mesa_half_to_float(GLhalfNV val)
+_mesa_half_to_float(GLhalfARB val)
{
/* XXX could also use a 64K-entry lookup table */
const int m = val & 0x3ff;
diff --git a/src/mesa/main/imports.h b/src/mesa/main/imports.h
index bee7d8aad1..f26907eeb7 100644
--- a/src/mesa/main/imports.h
+++ b/src/mesa/main/imports.h
@@ -1,11 +1,3 @@
-/**
- * \file imports.h
- * Standard C library function wrappers.
- *
- * This file provides wrappers for all the standard C library functions
- * like malloc(), free(), printf(), getenv(), etc.
- */
-
/*
* Mesa 3-D graphics library
* Version: 6.1
@@ -31,6 +23,15 @@
*/
+/**
+ * \file imports.h
+ * Standard C library function wrappers.
+ *
+ * This file provides wrappers for all the standard C library functions
+ * like malloc(), free(), printf(), getenv(), etc.
+ */
+
+
#ifndef IMPORTS_H
#define IMPORTS_H
@@ -705,11 +706,11 @@ _mesa_log2(float x);
extern unsigned int
_mesa_bitcount(unsigned int n);
-extern GLhalfNV
+extern GLhalfARB
_mesa_float_to_half(float f);
extern float
-_mesa_half_to_float(GLhalfNV h);
+_mesa_half_to_float(GLhalfARB h);
extern char *
diff --git a/src/mesa/main/mtypes.h b/src/mesa/main/mtypes.h
index a86b2ce5ac..4d78264bde 100644
--- a/src/mesa/main/mtypes.h
+++ b/src/mesa/main/mtypes.h
@@ -143,6 +143,8 @@ struct gl_texture_object;
typedef struct __GLcontextRec GLcontext;
typedef struct __GLcontextModesRec GLvisual;
typedef struct gl_frame_buffer GLframebuffer;
+struct gl_pixelstore_attrib;
+struct gl_texture_format;
/*@}*/
@@ -1024,16 +1026,37 @@ typedef void (*FetchTexelFuncF)( const struct gl_texture_image *texImage,
GLint col, GLint row, GLint img,
GLfloat *texelOut );
+
+/**
+ * TexImage store function. This is called by the glTex[Sub]Image
+ * functions and is responsible for converting the user-specified texture
+ * image into a specific (hardware) image format.
+ */
+typedef GLboolean (*StoreTexImageFunc)(GLcontext *ctx, GLuint dims,
+ GLenum baseInternalFormat,
+ const struct gl_texture_format *dstFormat,
+ GLvoid *dstAddr,
+ GLint dstXoffset, GLint dstYoffset, GLint dstZoffset,
+ GLint dstRowStride, GLint dstImageStride,
+ GLint srcWidth, GLint srcHeight, GLint srcDepth,
+ GLenum srcFormat, GLenum srcType,
+ const GLvoid *srcAddr,
+ const struct gl_pixelstore_attrib *srcPacking);
+
+
+
/**
* Texture format record
*/
struct gl_texture_format {
GLint MesaFormat; /**< One of the MESA_FORMAT_* values */
- GLenum BaseFormat; /**< Either GL_ALPHA, GL_INTENSITY, GL_LUMINANCE,
- * GL_LUMINANCE_ALPHA, GL_RGB, GL_RGBA,
- * GL_COLOR_INDEX or GL_DEPTH_COMPONENT.
- */
+ GLenum BaseFormat; /**< Either GL_RGB, GL_RGBA, GL_ALPHA,
+ * GL_LUMINANCE, GL_LUMINANCE_ALPHA,
+ * GL_INTENSITY, GL_COLOR_INDEX or
+ * GL_DEPTH_COMPONENT.
+ */
+ GLenum DataType; /**< GL_FLOAT or GL_UNSIGNED_NORMALIZED_ARB */
GLubyte RedBits; /**< Bits per texel component */
GLubyte GreenBits; /**< These are just rough approximations for */
GLubyte BlueBits; /**< compressed texture formats. */
@@ -1043,7 +1066,9 @@ struct gl_texture_format {
GLubyte IndexBits;
GLubyte DepthBits;
- GLint TexelBytes; /**< Bytes per texel (0 for compressed formats */
+ GLint TexelBytes; /**< Bytes per texel, 0 if compressed format */
+
+ StoreTexImageFunc StoreImage;
/**
* \name Texel fetch function pointers
@@ -1063,10 +1088,11 @@ struct gl_texture_format {
* Texture image record
*/
struct gl_texture_image {
- GLenum Format; /**< GL_ALPHA, GL_LUMINANCE, GL_LUMINANCE_ALPHA,
- * GL_INTENSITY, GL_RGB, GL_RGBA,
- * GL_COLOR_INDEX or GL_DEPTH_COMPONENT only.
- * Used for choosing TexEnv arithmetic.
+ GLenum Format; /**< Either GL_RGB, GL_RGBA, GL_ALPHA,
+ * GL_LUMINANCE, GL_LUMINANCE_ALPHA,
+ * GL_INTENSITY, GL_COLOR_INDEX or
+ * GL_DEPTH_COMPONENT only.
+ * Used for choosing TexEnv arithmetic.
*/
GLint IntFormat; /**< Internal format as given by the user */
GLuint Border; /**< 0 or 1 */
@@ -1828,6 +1854,7 @@ struct gl_extensions
GLboolean dummy; /* don't remove this! */
GLboolean ARB_depth_texture;
GLboolean ARB_fragment_program;
+ GLboolean ARB_half_float_pixel;
GLboolean ARB_imaging;
GLboolean ARB_multisample;
GLboolean ARB_multitexture;
@@ -1840,6 +1867,7 @@ struct gl_extensions
GLboolean ARB_texture_env_combine;
GLboolean ARB_texture_env_crossbar;
GLboolean ARB_texture_env_dot3;
+ GLboolean ARB_texture_float;
GLboolean ARB_texture_mirrored_repeat;
GLboolean ARB_texture_non_power_of_two;
GLboolean ARB_transpose_matrix;
diff --git a/src/mesa/main/texformat.c b/src/mesa/main/texformat.c
index 7222b77eb5..31a99f5d33 100644
--- a/src/mesa/main/texformat.c
+++ b/src/mesa/main/texformat.c
@@ -1,15 +1,8 @@
-/**
- * \file texformat.c
- * Texture formats.
- *
- * \author Gareth Hughes
- */
-
/*
* Mesa 3-D graphics library
- * Version: 5.1
+ * Version: 6.1
*
- * Copyright (C) 1999-2003 Brian Paul All Rights Reserved.
+ * Copyright (C) 1999-2004 Brian Paul All Rights Reserved.
*
* Permission is hereby granted, free of charge, to any person obtaining a
* copy of this software and associated documentation files (the "Software"),
@@ -30,6 +23,14 @@
*/
+/**
+ * \file texformat.c
+ * Texture formats.
+ *
+ * \author Gareth Hughes
+ */
+
+
#include "glheader.h"
#include "colormac.h"
#include "context.h"
@@ -40,6 +41,8 @@
#include "teximage.h"
#include "texstate.h"
+#include "newstore.h"
+
/* Texel fetch routines for all supported formats
*/
@@ -85,6 +88,7 @@ static void fetch_null_texelf( const struct gl_texture_image *texImage,
const struct gl_texture_format _mesa_texformat_rgba = {
MESA_FORMAT_RGBA, /* MesaFormat */
GL_RGBA, /* BaseFormat */
+ GL_UNSIGNED_NORMALIZED_ARB, /* DataType */
CHAN_BITS, /* RedBits */
CHAN_BITS, /* GreenBits */
CHAN_BITS, /* BlueBits */
@@ -94,6 +98,7 @@ const struct gl_texture_format _mesa_texformat_rgba = {
0, /* IndexBits */
0, /* DepthBits */
4 * CHAN_BITS / 8, /* TexelBytes */
+ _mesa_texstore_rgba, /* StoreTexImageFunc */
fetch_texel_1d_rgba, /* FetchTexel1D */
fetch_texel_2d_rgba, /* FetchTexel2D */
fetch_texel_3d_rgba, /* FetchTexel3D */
@@ -105,6 +110,7 @@ const struct gl_texture_format _mesa_texformat_rgba = {
const struct gl_texture_format _mesa_texformat_rgb = {
MESA_FORMAT_RGB, /* MesaFormat */
GL_RGB, /* BaseFormat */
+ GL_UNSIGNED_NORMALIZED_ARB, /* DataType */
CHAN_BITS, /* RedBits */
CHAN_BITS, /* GreenBits */
CHAN_BITS, /* BlueBits */
@@ -114,6 +120,7 @@ const struct gl_texture_format _mesa_texformat_rgb = {
0, /* IndexBits */
0, /* DepthBits */
3 * CHAN_BITS / 8, /* TexelBytes */
+ _mesa_texstore_rgba,/*yes*/ /* StoreTexImageFunc */
fetch_texel_1d_rgb, /* FetchTexel1D */
fetch_texel_2d_rgb, /* FetchTexel2D */
fetch_texel_3d_rgb, /* FetchTexel3D */
@@ -125,6 +132,7 @@ const struct gl_texture_format _mesa_texformat_rgb = {
const struct gl_texture_format _mesa_texformat_alpha = {
MESA_FORMAT_ALPHA, /* MesaFormat */
GL_ALPHA, /* BaseFormat */
+ GL_UNSIGNED_NORMALIZED_ARB, /* DataType */
0, /* RedBits */
0, /* GreenBits */
0, /* BlueBits */
@@ -134,6 +142,7 @@ const struct gl_texture_format _mesa_texformat_alpha = {
0, /* IndexBits */
0, /* DepthBits */
CHAN_BITS / 8, /* TexelBytes */
+ _mesa_texstore_rgba,/*yes*/ /* StoreTexImageFunc */
fetch_texel_1d_alpha, /* FetchTexel1D */
fetch_texel_2d_alpha, /* FetchTexel2D */
fetch_texel_3d_alpha, /* FetchTexel3D */
@@ -145,6 +154,7 @@ const struct gl_texture_format _mesa_texformat_alpha = {
const struct gl_texture_format _mesa_texformat_luminance = {
MESA_FORMAT_LUMINANCE, /* MesaFormat */
GL_LUMINANCE, /* BaseFormat */
+ GL_UNSIGNED_NORMALIZED_ARB, /* DataType */
0, /* RedBits */
0, /* GreenBits */
0, /* BlueBits */
@@ -154,6 +164,7 @@ const struct gl_texture_format _mesa_texformat_luminance = {
0, /* IndexBits */
0, /* DepthBits */
CHAN_BITS / 8, /* TexelBytes */
+ _mesa_texstore_rgba,/*yes*/ /* StoreTexImageFunc */
fetch_texel_1d_luminance, /* FetchTexel1D */
fetch_texel_2d_luminance, /* FetchTexel2D */
fetch_texel_3d_luminance, /* FetchTexel3D */
@@ -165,6 +176,7 @@ const struct gl_texture_format _mesa_texformat_luminance = {
const struct gl_texture_format _mesa_texformat_luminance_alpha = {
MESA_FORMAT_LUMINANCE_ALPHA, /* MesaFormat */
GL_LUMINANCE_ALPHA, /* BaseFormat */
+ GL_UNSIGNED_NORMALIZED_ARB, /* DataType */
0, /* RedBits */
0, /* GreenBits */
0, /* BlueBits */
@@ -174,6 +186,7 @@ const struct gl_texture_format _mesa_texformat_luminance_alpha = {
0, /* IndexBits */
0, /* DepthBits */
2 * CHAN_BITS / 8, /* TexelBytes */
+ _mesa_texstore_rgba,/*yes*/ /* StoreTexImageFunc */
fetch_texel_1d_luminance_alpha, /* FetchTexel1D */
fetch_texel_2d_luminance_alpha, /* FetchTexel2D */
fetch_texel_3d_luminance_alpha, /* FetchTexel3D */
@@ -185,6 +198,7 @@ const struct gl_texture_format _mesa_texformat_luminance_alpha = {
const struct gl_texture_format _mesa_texformat_intensity = {
MESA_FORMAT_INTENSITY, /* MesaFormat */
GL_INTENSITY, /* BaseFormat */
+ GL_UNSIGNED_NORMALIZED_ARB, /* DataType */
0, /* RedBits */
0, /* GreenBits */
0, /* BlueBits */
@@ -194,6 +208,7 @@ const struct gl_texture_format _mesa_texformat_intensity = {
0, /* IndexBits */
0, /* DepthBits */
CHAN_BITS / 8, /* TexelBytes */
+ _mesa_texstore_rgba,/*yes*/ /* StoreTexImageFunc */
fetch_texel_1d_intensity, /* FetchTexel1D */
fetch_texel_2d_intensity, /* FetchTexel2D */
fetch_texel_3d_intensity, /* FetchTexel3D */
@@ -205,6 +220,7 @@ const struct gl_texture_format _mesa_texformat_intensity = {
const struct gl_texture_format _mesa_texformat_color_index = {
MESA_FORMAT_COLOR_INDEX, /* MesaFormat */
GL_COLOR_INDEX, /* BaseFormat */
+ GL_UNSIGNED_NORMALIZED_ARB, /* DataType */
0, /* RedBits */
0, /* GreenBits */
0, /* BlueBits */
@@ -214,6 +230,7 @@ const struct gl_texture_format _mesa_texformat_color_index = {
CHAN_BITS, /* IndexBits */
0, /* DepthBits */
CHAN_BITS / 8, /* TexelBytes */
+ _mesa_texstore_color_index, /* StoreTexImageFunc */
fetch_texel_1d_color_index, /* FetchTexel1D */
fetch_texel_2d_color_index, /* FetchTexel2D */
fetch_texel_3d_color_index, /* FetchTexel3D */
@@ -222,10 +239,10 @@ const struct gl_texture_format _mesa_texformat_color_index = {
fetch_texel_3d_f_color_index, /* FetchTexel3Df */
};
-/* XXX someday implement 16, 24 and 32-bit integer depth images */
-const struct gl_texture_format _mesa_texformat_depth_component = {
- MESA_FORMAT_DEPTH_COMPONENT, /* MesaFormat */
+const struct gl_texture_format _mesa_texformat_depth_component_float32 = {
+ MESA_FORMAT_DEPTH_COMPONENT_FLOAT32, /* MesaFormat */
GL_DEPTH_COMPONENT, /* BaseFormat */
+ GL_UNSIGNED_NORMALIZED_ARB, /* DataType */
0, /* RedBits */
0, /* GreenBits */
0, /* BlueBits */
@@ -235,17 +252,41 @@ const struct gl_texture_format _mesa_texformat_depth_component = {
0, /* IndexBits */
sizeof(GLfloat) * 8, /* DepthBits */
sizeof(GLfloat), /* TexelBytes */
+ _mesa_texstore_depth_component_float32,/* StoreTexImageFunc */
+ fetch_null_texel, /* FetchTexel1D */
+ fetch_null_texel, /* FetchTexel1D */
+ fetch_null_texel, /* FetchTexel1D */
+ fetch_texel_1d_f_depth_component_f32,/* FetchTexel1Df */
+ fetch_texel_2d_f_depth_component_f32,/* FetchTexel2Df */
+ fetch_texel_3d_f_depth_component_f32,/* FetchTexel3Df */
+};
+
+const struct gl_texture_format _mesa_texformat_depth_component16 = {
+ MESA_FORMAT_DEPTH_COMPONENT16, /* MesaFormat */
+ GL_DEPTH_COMPONENT, /* BaseFormat */
+ GL_UNSIGNED_NORMALIZED_ARB, /* DataType */
+ 0, /* RedBits */
+ 0, /* GreenBits */
+ 0, /* BlueBits */
+ 0, /* AlphaBits */
+ 0, /* LuminanceBits */
+ 0, /* IntensityBits */
+ 0, /* IndexBits */
+ sizeof(GLushort) * 8, /* DepthBits */
+ sizeof(GLushort), /* TexelBytes */
+ _mesa_texstore_depth_component16, /* StoreTexImageFunc */
fetch_null_texel, /* FetchTexel1D */
fetch_null_texel, /* FetchTexel1D */
fetch_null_texel, /* FetchTexel1D */
- fetch_texel_1d_f_depth_component, /* FetchTexel1Df */
- fetch_texel_2d_f_depth_component, /* FetchTexel2Df */
- fetch_texel_3d_f_depth_component, /* FetchTexel3Df */
+ fetch_texel_1d_f_depth_component16, /* FetchTexel1Df */
+ fetch_texel_2d_f_depth_component16, /* FetchTexel2Df */
+ fetch_texel_3d_f_depth_component16, /* FetchTexel3Df */
};
const struct gl_texture_format _mesa_texformat_rgba_float32 = {
MESA_FORMAT_RGBA_FLOAT32, /* MesaFormat */
GL_RGBA, /* BaseFormat */
+ GL_FLOAT, /* DataType */
8 * sizeof(GLfloat), /* RedBits */
8 * sizeof(GLfloat), /* GreenBits */
8 * sizeof(GLfloat), /* BlueBits */
@@ -255,9 +296,10 @@ const struct gl_texture_format _mesa_texformat_rgba_float32 = {
0, /* IndexBits */
0, /* DepthBits */
4 * sizeof(GLfloat), /* TexelBytes */
- fetch_null_texel, /* FetchTexel1D */
- fetch_null_texel, /* FetchTexel1D */
- fetch_null_texel, /* FetchTexel1D */
+ _mesa_texstore_rgba_float32, /* StoreTexImageFunc */
+ fetch_texel_1d_rgba_f32, /* FetchTexel1D */
+ fetch_texel_2d_rgba_f32, /* FetchTexel1D */
+ fetch_texel_3d_rgba_f32, /* FetchTexel1D */
fetch_texel_1d_f_rgba_f32, /* FetchTexel1Df */
fetch_texel_2d_f_rgba_f32, /* FetchTexel2Df */
fetch_texel_3d_f_rgba_f32, /* FetchTexel3Df */
@@ -266,18 +308,20 @@ const struct gl_texture_format _mesa_texformat_rgba_float32 = {
const struct gl_texture_format _mesa_texformat_rgba_float16 = {
MESA_FORMAT_RGBA_FLOAT16, /* MesaFormat */
GL_RGBA, /* BaseFormat */
- 8 * sizeof(GLhalfNV), /* RedBits */
- 8 * sizeof(GLhalfNV), /* GreenBits */
- 8 * sizeof(GLhalfNV), /* BlueBits */
- 8 * sizeof(GLhalfNV), /* AlphaBits */
+ GL_FLOAT, /* DataType */
+ 8 * sizeof(GLhalfARB), /* RedBits */
+ 8 * sizeof(GLhalfARB), /* GreenBits */
+ 8 * sizeof(GLhalfARB), /* BlueBits */
+ 8 * sizeof(GLhalfARB), /* AlphaBits */
0, /* LuminanceBits */
0, /* IntensityBits */
0, /* IndexBits */
0, /* DepthBits */
- 4 * sizeof(GLhalfNV), /* TexelBytes */
- fetch_null_texel, /* FetchTexel1D */
- fetch_null_texel, /* FetchTexel1D */
- fetch_null_texel, /* FetchTexel1D */
+ 4 * sizeof(GLhalfARB), /* TexelBytes */
+ _mesa_texstore_rgba_float16, /* StoreTexImageFunc */
+ fetch_texel_1d_rgba_f16, /* FetchTexel1D */
+ fetch_texel_2d_rgba_f16, /* FetchTexel1D */
+ fetch_texel_3d_rgba_f16, /* FetchTexel1D */
fetch_texel_1d_f_rgba_f16, /* FetchTexel1Df */
fetch_texel_2d_f_rgba_f16, /* FetchTexel2Df */
fetch_texel_3d_f_rgba_f16, /* FetchTexel3Df */
@@ -286,6 +330,7 @@ const struct gl_texture_format _mesa_texformat_rgba_float16 = {
const struct gl_texture_format _mesa_texformat_rgb_float32 = {
MESA_FORMAT_RGB_FLOAT32, /* MesaFormat */
GL_RGB, /* BaseFormat */
+ GL_FLOAT, /* DataType */
8 * sizeof(GLfloat), /* RedBits */
8 * sizeof(GLfloat), /* GreenBits */
8 * sizeof(GLfloat), /* BlueBits */
@@ -294,10 +339,11 @@ const struct gl_texture_format _mesa_texformat_rgb_float32 = {
0, /* IntensityBits */
0, /* IndexBits */
0, /* DepthBits */
- 4 * sizeof(GLfloat), /* TexelBytes */
- fetch_null_texel, /* FetchTexel1D */
- fetch_null_texel, /* FetchTexel1D */
- fetch_null_texel, /* FetchTexel1D */
+ 3 * sizeof(GLfloat), /* TexelBytes */
+ _mesa_texstore_rgba_float32,/*yes*/ /* StoreTexImageFunc */
+ fetch_texel_1d_rgb_f32, /* FetchTexel1D */
+ fetch_texel_2d_rgb_f32, /* FetchTexel1D */
+ fetch_texel_3d_rgb_f32, /* FetchTexel1D */
fetch_texel_1d_f_rgb_f32, /* FetchTexel1Df */
fetch_texel_2d_f_rgb_f32, /* FetchTexel2Df */
fetch_texel_3d_f_rgb_f32, /* FetchTexel3Df */
@@ -306,21 +352,199 @@ const struct gl_texture_format _mesa_texformat_rgb_float32 = {
const struct gl_texture_format _mesa_texformat_rgb_float16 = {
MESA_FORMAT_RGB_FLOAT16, /* MesaFormat */
GL_RGB, /* BaseFormat */
- 8 * sizeof(GLhalfNV), /* RedBits */
- 8 * sizeof(GLhalfNV), /* GreenBits */
- 8 * sizeof(GLhalfNV), /* BlueBits */
+ GL_FLOAT, /* DataType */
+ 8 * sizeof(GLhalfARB), /* RedBits */
+ 8 * sizeof(GLhalfARB), /* GreenBits */
+ 8 * sizeof(GLhalfARB), /* BlueBits */
0, /* AlphaBits */
0, /* LuminanceBits */
0, /* IntensityBits */
0, /* IndexBits */
0, /* DepthBits */
- 4 * sizeof(GLhalfNV), /* TexelBytes */
- fetch_null_texel, /* FetchTexel1D */
- fetch_null_texel, /* FetchTexel1D */
- fetch_null_texel, /* FetchTexel1D */
+ 3 * sizeof(GLhalfARB), /* TexelBytes */
+ _mesa_texstore_rgba_float16,/*yes*/ /* StoreTexImageFunc */
+ fetch_texel_1d_rgb_f16, /* FetchTexel1D */
+ fetch_texel_2d_rgb_f16, /* FetchTexel1D */
+ fetch_texel_3d_rgb_f16, /* FetchTexel1D */
fetch_texel_1d_f_rgb_f16, /* FetchTexel1Df */
fetch_texel_2d_f_rgb_f16, /* FetchTexel2Df */
- fetch_texel_3d_f_rgb_f16, /* FetchTexel3Df */
+ fetch_texel_3d_f_rgb_f16 /* FetchTexel3Df */
+};
+
+const struct gl_texture_format _mesa_texformat_alpha_float32 = {
+ MESA_FORMAT_ALPHA_FLOAT32, /* MesaFormat */
+ GL_ALPHA, /* BaseFormat */
+ GL_FLOAT, /* DataType */
+ 0, /* RedBits */
+ 0, /* GreenBits */
+ 0, /* BlueBits */
+ 8 * sizeof(GLfloat), /* AlphaBits */
+ 0, /* LuminanceBits */
+ 0, /* IntensityBits */
+ 0, /* IndexBits */
+ 0, /* DepthBits */
+ 1 * sizeof(GLfloat), /* TexelBytes */
+ _mesa_texstore_rgba_float32,/*yes*/ /* StoreTexImageFunc */
+ fetch_texel_1d_alpha_f32, /* FetchTexel1D */
+ fetch_texel_2d_alpha_f32, /* FetchTexel1D */
+ fetch_texel_3d_alpha_f32, /* FetchTexel1D */
+ fetch_texel_1d_f_alpha_f32, /* FetchTexel1Df */
+ fetch_texel_2d_f_alpha_f32, /* FetchTexel2Df */
+ fetch_texel_3d_f_alpha_f32 /* FetchTexel3Df */
+};
+
+const struct gl_texture_format _mesa_texformat_alpha_float16 = {
+ MESA_FORMAT_ALPHA_FLOAT16, /* MesaFormat */
+ GL_ALPHA, /* BaseFormat */
+ GL_FLOAT, /* DataType */
+ 0, /* RedBits */
+ 0, /* GreenBits */
+ 0, /* BlueBits */
+ 8 * sizeof(GLhalfARB), /* AlphaBits */
+ 0, /* LuminanceBits */
+ 0, /* IntensityBits */
+ 0, /* IndexBits */
+ 0, /* DepthBits */
+ 1 * sizeof(GLhalfARB), /* TexelBytes */
+ _mesa_texstore_rgba_float16,/*yes*/ /* StoreTexImageFunc */
+ fetch_texel_1d_alpha_f16, /* FetchTexel1D */
+ fetch_texel_2d_alpha_f16, /* FetchTexel1D */
+ fetch_texel_3d_alpha_f16, /* FetchTexel1D */
+ fetch_texel_1d_f_alpha_f16, /* FetchTexel1Df */
+ fetch_texel_2d_f_alpha_f16, /* FetchTexel2Df */
+ fetch_texel_3d_f_alpha_f16 /* FetchTexel3Df */
+};
+
+const struct gl_texture_format _mesa_texformat_luminance_float32 = {
+ MESA_FORMAT_LUMINANCE_FLOAT32, /* MesaFormat */
+ GL_LUMINANCE, /* BaseFormat */
+ GL_FLOAT, /* DataType */
+ 0, /* RedBits */
+ 0, /* GreenBits */
+ 0, /* BlueBits */
+ 0, /* AlphaBits */
+ 8 * sizeof(GLfloat), /* LuminanceBits */
+ 0, /* IntensityBits */
+ 0, /* IndexBits */
+ 0, /* DepthBits */
+ 1 * sizeof(GLfloat), /* TexelBytes */
+ _mesa_texstore_rgba_float32,/*yes*/ /* StoreTexImageFunc */
+ fetch_texel_1d_luminance_f32, /* FetchTexel1D */
+ fetch_texel_2d_luminance_f32, /* FetchTexel2D */
+ fetch_texel_3d_luminance_f32, /* FetchTexel3D */
+ fetch_texel_1d_f_luminance_f32, /* FetchTexel1Df */
+ fetch_texel_2d_f_luminance_f32, /* FetchTexel2Df */
+ fetch_texel_3d_f_luminance_f32 /* FetchTexel3Df */
+};
+
+const struct gl_texture_format _mesa_texformat_luminance_float16 = {
+ MESA_FORMAT_LUMINANCE_FLOAT16, /* MesaFormat */
+ GL_LUMINANCE, /* BaseFormat */
+ GL_FLOAT, /* DataType */
+ 0, /* RedBits */
+ 0, /* GreenBits */
+ 0, /* BlueBits */
+ 0, /* AlphaBits */
+ 8 * sizeof(GLhalfARB), /* LuminanceBits */
+ 0, /* IntensityBits */
+ 0, /* IndexBits */
+ 0, /* DepthBits */
+ 1 * sizeof(GLhalfARB), /* TexelBytes */
+ _mesa_texstore_rgba_float16,/*yes*/ /* StoreTexImageFunc */
+ fetch_texel_1d_luminance_f16, /* FetchTexel1D */
+ fetch_texel_2d_luminance_f16, /* FetchTexel2D */
+ fetch_texel_3d_luminance_f16, /* FetchTexel3D */
+ fetch_texel_1d_f_luminance_f16, /* FetchTexel1Df */
+ fetch_texel_2d_f_luminance_f16, /* FetchTexel2Df */
+ fetch_texel_3d_f_luminance_f16 /* FetchTexel3Df */
+};
+
+const struct gl_texture_format _mesa_texformat_luminance_alpha_float32 = {
+ MESA_FORMAT_LUMINANCE_ALPHA_FLOAT32, /* MesaFormat */
+ GL_LUMINANCE_ALPHA, /* BaseFormat */
+ GL_FLOAT, /* DataType */
+ 0, /* RedBits */
+ 0, /* GreenBits */
+ 0, /* BlueBits */
+ 8 * sizeof(GLfloat), /* AlphaBits */
+ 8 * sizeof(GLfloat), /* LuminanceBits */
+ 0, /* IntensityBits */
+ 0, /* IndexBits */
+ 0, /* DepthBits */
+ 2 * sizeof(GLfloat), /* TexelBytes */
+ _mesa_texstore_rgba_float32, /* StoreTexImageFunc */
+ fetch_texel_1d_luminance_alpha_f32, /* FetchTexel1D */
+ fetch_texel_2d_luminance_alpha_f32, /* FetchTexel2D */
+ fetch_texel_3d_luminance_alpha_f32, /* FetchTexel3D */
+ fetch_texel_1d_f_luminance_alpha_f32,/* FetchTexel1Df */
+ fetch_texel_2d_f_luminance_alpha_f32,/* FetchTexel2Df */
+ fetch_texel_3d_f_luminance_alpha_f32 /* FetchTexel3Df */
+};
+
+const struct gl_texture_format _mesa_texformat_luminance_alpha_float16 = {
+ MESA_FORMAT_LUMINANCE_ALPHA_FLOAT16, /* MesaFormat */
+ GL_LUMINANCE_ALPHA, /* BaseFormat */
+ GL_FLOAT, /* DataType */
+ 0, /* RedBits */
+ 0, /* GreenBits */
+ 0, /* BlueBits */
+ 8 * sizeof(GLhalfARB), /* AlphaBits */
+ 8 * sizeof(GLhalfARB), /* LuminanceBits */
+ 0, /* IntensityBits */
+ 0, /* IndexBits */
+ 0, /* DepthBits */
+ 2 * sizeof(GLhalfARB), /* TexelBytes */
+ _mesa_texstore_rgba_float16, /* StoreTexImageFunc */
+ fetch_texel_1d_luminance_alpha_f16, /* FetchTexel1D */
+ fetch_texel_2d_luminance_alpha_f16, /* FetchTexel2D */
+ fetch_texel_3d_luminance_alpha_f16, /* FetchTexel3D */
+ fetch_texel_1d_f_luminance_alpha_f16,/* FetchTexel1Df */
+ fetch_texel_2d_f_luminance_alpha_f16,/* FetchTexel2Df */
+ fetch_texel_3d_f_luminance_alpha_f16 /* FetchTexel3Df */
+};
+
+const struct gl_texture_format _mesa_texformat_intensity_float32 = {
+ MESA_FORMAT_INTENSITY_FLOAT32, /* MesaFormat */
+ GL_INTENSITY, /* BaseFormat */
+ GL_FLOAT, /* DataType */
+ 0, /* RedBits */
+ 0, /* GreenBits */
+ 0, /* BlueBits */
+ 0, /* AlphaBits */
+ 0, /* LuminanceBits */
+ 8 * sizeof(GLfloat), /* IntensityBits */
+ 0, /* IndexBits */
+ 0, /* DepthBits */
+ 1 * sizeof(GLfloat), /* TexelBytes */
+ _mesa_texstore_rgba_float32,/*yes*/ /* StoreTexImageFunc */
+ fetch_texel_1d_intensity_f32, /* FetchTexel1D */
+ fetch_texel_2d_intensity_f32, /* FetchTexel2D */
+ fetch_texel_3d_intensity_f32, /* FetchTexel3D */
+ fetch_texel_1d_f_intensity_f32, /* FetchTexel1Df */
+ fetch_texel_2d_f_intensity_f32, /* FetchTexel2Df */
+ fetch_texel_3d_f_intensity_f32 /* FetchTexel3Df */
+};
+
+const struct gl_texture_format _mesa_texformat_intensity_float16 = {
+ MESA_FORMAT_INTENSITY_FLOAT16, /* MesaFormat */
+ GL_INTENSITY, /* BaseFormat */
+ GL_FLOAT, /* DataType */
+ 0, /* RedBits */
+ 0, /* GreenBits */
+ 0, /* BlueBits */
+ 0, /* AlphaBits */
+ 0, /* LuminanceBits */
+ 8 * sizeof(GLhalfARB), /* IntensityBits */
+ 0, /* IndexBits */
+ 0, /* DepthBits */
+ 1 * sizeof(GLhalfARB), /* TexelBytes */
+ _mesa_texstore_rgba_float16,/*yes*/ /* StoreTexImageFunc */
+ fetch_texel_1d_intensity_f16, /* FetchTexel1D */
+ fetch_texel_2d_intensity_f16, /* FetchTexel2D */
+ fetch_texel_3d_intensity_f16, /* FetchTexel3D */
+ fetch_texel_1d_f_intensity_f16, /* FetchTexel1Df */
+ fetch_texel_2d_f_intensity_f16, /* FetchTexel2Df */
+ fetch_texel_3d_f_intensity_f16 /* FetchTexel3Df */
};
@@ -334,6 +558,7 @@ const struct gl_texture_format _mesa_texformat_rgb_float16 = {
const struct gl_texture_format _mesa_texformat_rgba8888 = {
MESA_FORMAT_RGBA8888, /* MesaFormat */
GL_RGBA, /* BaseFormat */
+ GL_UNSIGNED_NORMALIZED_ARB, /* DataType */
8, /* RedBits */
8, /* GreenBits */
8, /* BlueBits */
@@ -343,6 +568,7 @@ const struct gl_texture_format _mesa_texformat_rgba8888 = {
0, /* IndexBits */
0, /* DepthBits */
4, /* TexelBytes */
+ _mesa_texstore_rgba8888, /* StoreTexImageFunc */
fetch_texel_1d_rgba8888, /* FetchTexel1D */
fetch_texel_2d_rgba8888, /* FetchTexel2D */
fetch_texel_3d_rgba8888, /* FetchTexel3D */
@@ -354,6 +580,7 @@ const struct gl_texture_format _mesa_texformat_rgba8888 = {
const struct gl_texture_format _mesa_texformat_argb8888 = {
MESA_FORMAT_ARGB8888, /* MesaFormat */
GL_RGBA, /* BaseFormat */
+ GL_UNSIGNED_NORMALIZED_ARB, /* DataType */
8, /* RedBits */
8, /* GreenBits */
8, /* BlueBits */
@@ -363,6 +590,7 @@ const struct gl_texture_format _mesa_texformat_argb8888 = {
0, /* IndexBits */
0, /* DepthBits */
4, /* TexelBytes */
+ _mesa_texstore_argb8888, /* StoreTexImageFunc */
fetch_texel_1d_argb8888, /* FetchTexel1D */
fetch_texel_2d_argb8888, /* FetchTexel2D */
fetch_texel_3d_argb8888, /* FetchTexel3D */
@@ -374,6 +602,7 @@ const struct gl_texture_format _mesa_texformat_argb8888 = {
const struct gl_texture_format _mesa_texformat_rgb888 = {
MESA_FORMAT_RGB888, /* MesaFormat */
GL_RGB, /* BaseFormat */
+ GL_UNSIGNED_NORMALIZED_ARB, /* DataType */
8, /* RedBits */
8, /* GreenBits */
8, /* BlueBits */
@@ -383,6 +612,7 @@ const struct gl_texture_format _mesa_texformat_rgb888 = {
0, /* IndexBits */
0, /* DepthBits */
3, /* TexelBytes */
+ _mesa_texstore_rgb888, /* StoreTexImageFunc */
fetch_texel_1d_rgb888, /* FetchTexel1D */
fetch_texel_2d_rgb888, /* FetchTexel2D */
fetch_texel_3d_rgb888, /* FetchTexel3D */
@@ -394,6 +624,7 @@ const struct gl_texture_format _mesa_texformat_rgb888 = {
const struct gl_texture_format _mesa_texformat_rgb565 = {
MESA_FORMAT_RGB565, /* MesaFormat */
GL_RGB, /* BaseFormat */
+ GL_UNSIGNED_NORMALIZED_ARB, /* DataType */
5, /* RedBits */
6, /* GreenBits */
5, /* BlueBits */
@@ -403,6 +634,7 @@ const struct gl_texture_format _mesa_texformat_rgb565 = {
0, /* IndexBits */
0, /* DepthBits */
2, /* TexelBytes */
+ _mesa_texstore_rgb565, /* StoreTexImageFunc */
fetch_texel_1d_rgb565, /* FetchTexel1D */
fetch_texel_2d_rgb565, /* FetchTexel2D */
fetch_texel_3d_rgb565, /* FetchTexel3D */
@@ -414,6 +646,7 @@ const struct gl_texture_format _mesa_texformat_rgb565 = {
const struct gl_texture_format _mesa_texformat_argb4444 = {
MESA_FORMAT_ARGB4444, /* MesaFormat */
GL_RGBA, /* BaseFormat */
+ GL_UNSIGNED_NORMALIZED_ARB, /* DataType */
4, /* RedBits */
4, /* GreenBits */
4, /* BlueBits */
@@ -423,6 +656,7 @@ const struct gl_texture_format _mesa_texformat_argb4444 = {
0, /* IndexBits */
0, /* DepthBits */
2, /* TexelBytes */
+ _mesa_texstore_argb4444, /* StoreTexImageFunc */
fetch_texel_1d_argb4444, /* FetchTexel1D */
fetch_texel_2d_argb4444, /* FetchTexel2D */
fetch_texel_3d_argb4444, /* FetchTexel3D */
@@ -434,6 +668,7 @@ const struct gl_texture_format _mesa_texformat_argb4444 = {
const struct gl_texture_format _mesa_texformat_argb1555 = {
MESA_FORMAT_ARGB1555, /* MesaFormat */
GL_RGBA, /* BaseFormat */
+ GL_UNSIGNED_NORMALIZED_ARB, /* DataType */
5, /* RedBits */
5, /* GreenBits */
5, /* BlueBits */
@@ -443,6 +678,7 @@ const struct gl_texture_format _mesa_texformat_argb1555 = {
0, /* IndexBits */
0, /* DepthBits */
2, /* TexelBytes */
+ _mesa_texstore_argb1555, /* StoreTexImageFunc */
fetch_texel_1d_argb1555, /* FetchTexel1D */
fetch_texel_2d_argb1555, /* FetchTexel2D */
fetch_texel_3d_argb1555, /* FetchTexel3D */
@@ -454,6 +690,7 @@ const struct gl_texture_format _mesa_texformat_argb1555 = {
const struct gl_texture_format _mesa_texformat_al88 = {
MESA_FORMAT_AL88, /* MesaFormat */
GL_LUMINANCE_ALPHA, /* BaseFormat */
+ GL_UNSIGNED_NORMALIZED_ARB, /* DataType */
0, /* RedBits */
0, /* GreenBits */
0, /* BlueBits */
@@ -463,6 +700,7 @@ const struct gl_texture_format _mesa_texformat_al88 = {
0, /* IndexBits */
0, /* DepthBits */
2, /* TexelBytes */
+ _mesa_texstore_al88, /* StoreTexImageFunc */
fetch_texel_1d_al88, /* FetchTexel1D */
fetch_texel_2d_al88, /* FetchTexel2D */
fetch_texel_3d_al88, /* FetchTexel3D */
@@ -474,6 +712,7 @@ const struct gl_texture_format _mesa_texformat_al88 = {
const struct gl_texture_format _mesa_texformat_rgb332 = {
MESA_FORMAT_RGB332, /* MesaFormat */
GL_RGB, /* BaseFormat */
+ GL_UNSIGNED_NORMALIZED_ARB, /* DataType */
3, /* RedBits */
3, /* GreenBits */
2, /* BlueBits */
@@ -483,6 +722,7 @@ const struct gl_texture_format _mesa_texformat_rgb332 = {
0, /* IndexBits */
0, /* DepthBits */
1, /* TexelBytes */
+ _mesa_texstore_rgb332, /* StoreTexImageFunc */
fetch_texel_1d_rgb332, /* FetchTexel1D */
fetch_texel_2d_rgb332, /* FetchTexel2D */
fetch_texel_3d_rgb332, /* FetchTexel3D */
@@ -494,6 +734,7 @@ const struct gl_texture_format _mesa_texformat_rgb332 = {
const struct gl_texture_format _mesa_texformat_a8 = {
MESA_FORMAT_A8, /* MesaFormat */
GL_ALPHA, /* BaseFormat */
+ GL_UNSIGNED_NORMALIZED_ARB, /* DataType */
0, /* RedBits */
0, /* GreenBits */
0, /* BlueBits */
@@ -503,6 +744,7 @@ const struct gl_texture_format _mesa_texformat_a8 = {
0, /* IndexBits */
0, /* DepthBits */
1, /* TexelBytes */
+ _mesa_texstore_a8, /* StoreTexImageFunc */
fetch_texel_1d_a8, /* FetchTexel1D */
fetch_texel_2d_a8, /* FetchTexel2D */
fetch_texel_3d_a8, /* FetchTexel3D */
@@ -514,6 +756,7 @@ const struct gl_texture_format _mesa_texformat_a8 = {
const struct gl_texture_format _mesa_texformat_l8 = {
MESA_FORMAT_L8, /* MesaFormat */
GL_LUMINANCE, /* BaseFormat */
+ GL_UNSIGNED_NORMALIZED_ARB, /* DataType */
0, /* RedBits */
0, /* GreenBits */
0, /* BlueBits */
@@ -523,6 +766,7 @@ const struct gl_texture_format _mesa_texformat_l8 = {
0, /* IndexBits */
0, /* DepthBits */
1, /* TexelBytes */
+ _mesa_texstore_a8,/*yes*/ /* StoreTexImageFunc */
fetch_texel_1d_l8, /* FetchTexel1D */
fetch_texel_2d_l8, /* FetchTexel2D */
fetch_texel_3d_l8, /* FetchTexel3D */
@@ -534,6 +778,7 @@ const struct gl_texture_format _mesa_texformat_l8 = {
const struct gl_texture_format _mesa_texformat_i8 = {
MESA_FORMAT_I8, /* MesaFormat */
GL_INTENSITY, /* BaseFormat */
+ GL_UNSIGNED_NORMALIZED_ARB, /* DataType */
0, /* RedBits */
0, /* GreenBits */
0, /* BlueBits */
@@ -543,6 +788,7 @@ const struct gl_texture_format _mesa_texformat_i8 = {
0, /* IndexBits */
0, /* DepthBits */
1, /* TexelBytes */
+ _mesa_texstore_a8,/*yes*/ /* StoreTexImageFunc */
fetch_texel_1d_i8, /* FetchTexel1D */
fetch_texel_2d_i8, /* FetchTexel2D */
fetch_texel_3d_i8, /* FetchTexel3D */
@@ -554,6 +800,7 @@ const struct gl_texture_format _mesa_texformat_i8 = {
const struct gl_texture_format _mesa_texformat_ci8 = {
MESA_FORMAT_CI8, /* MesaFormat */
GL_COLOR_INDEX, /* BaseFormat */
+ GL_UNSIGNED_NORMALIZED_ARB, /* DataType */
0, /* RedBits */
0, /* GreenBits */
0, /* BlueBits */
@@ -563,6 +810,7 @@ const struct gl_texture_format _mesa_texformat_ci8 = {
8, /* IndexBits */
0, /* DepthBits */
1, /* TexelBytes */
+ _mesa_texstore_ci8, /* StoreTexImageFunc */
fetch_texel_1d_ci8, /* FetchTexel1D */
fetch_texel_2d_ci8, /* FetchTexel2D */
fetch_texel_3d_ci8, /* FetchTexel3D */
@@ -574,6 +822,7 @@ const struct gl_texture_format _mesa_texformat_ci8 = {
const struct gl_texture_format _mesa_texformat_ycbcr = {
MESA_FORMAT_YCBCR, /* MesaFormat */
GL_YCBCR_MESA, /* BaseFormat */
+ GL_UNSIGNED_NORMALIZED_ARB, /* DataType */
0, /* RedBits */
0, /* GreenBits */
0, /* BlueBits */
@@ -583,6 +832,7 @@ const struct gl_texture_format _mesa_texformat_ycbcr = {
0, /* IndexBits */
0, /* DepthBits */
2, /* TexelBytes */
+ _mesa_texstore_ycbcr, /* StoreTexImageFunc */
fetch_texel_1d_ycbcr, /* FetchTexel1D */
fetch_texel_2d_ycbcr, /* FetchTexel2D */
fetch_texel_3d_ycbcr, /* FetchTexel3D */
@@ -594,6 +844,7 @@ const struct gl_texture_format _mesa_texformat_ycbcr = {
const struct gl_texture_format _mesa_texformat_ycbcr_rev = {
MESA_FORMAT_YCBCR_REV, /* MesaFormat */
GL_YCBCR_MESA, /* BaseFormat */
+ GL_UNSIGNED_NORMALIZED_ARB, /* DataType */
0, /* RedBits */
0, /* GreenBits */
0, /* BlueBits */
@@ -603,6 +854,7 @@ const struct gl_texture_format _mesa_texformat_ycbcr_rev = {
0, /* IndexBits */
0, /* DepthBits */
2, /* TexelBytes */
+ _mesa_texstore_ycbcr, /* StoreTexImageFunc */
fetch_texel_1d_ycbcr_rev, /* FetchTexel1D */
fetch_texel_2d_ycbcr_rev, /* FetchTexel2D */
fetch_texel_3d_ycbcr_rev, /* FetchTexel3D */
@@ -614,6 +866,7 @@ const struct gl_texture_format _mesa_texformat_ycbcr_rev = {
const struct gl_texture_format _mesa_texformat_rgb_fxt1 = {
MESA_FORMAT_RGB_FXT1, /* MesaFormat */
GL_RGB, /* BaseFormat */
+ GL_UNSIGNED_NORMALIZED_ARB, /* DataType */
4, /*approx*/ /* RedBits */
4, /*approx*/ /* GreenBits */
4, /*approx*/ /* BlueBits */
@@ -623,6 +876,7 @@ const struct gl_texture_format _mesa_texformat_rgb_fxt1 = {
0, /* IndexBits */
0, /* DepthBits */
0, /* TexelBytes */
+ NULL, /* StoreTexImageFunc */
NULL, /*impossible*/ /* FetchTexel1D */
fetch_texel_2d_rgb_fxt1, /* FetchTexel2D */
NULL, /*impossible*/ /* FetchTexel3D */
@@ -634,6 +888,7 @@ const struct gl_texture_format _mesa_texformat_rgb_fxt1 = {
const struct gl_texture_format _mesa_texformat_rgba_fxt1 = {
MESA_FORMAT_RGBA_FXT1, /* MesaFormat */
GL_RGBA, /* BaseFormat */
+ GL_UNSIGNED_NORMALIZED_ARB, /* DataType */
4, /*approx*/ /* RedBits */
4, /*approx*/ /* GreenBits */
4, /*approx*/ /* BlueBits */
@@ -643,6 +898,7 @@ const struct gl_texture_format _mesa_texformat_rgba_fxt1 = {
0, /* IndexBits */
0, /* DepthBits */
0, /* TexelBytes */
+ NULL, /* StoreTexImageFunc */
NULL, /*impossible*/ /* FetchTexel1D */
fetch_texel_2d_rgba_fxt1, /* FetchTexel2D */
NULL, /*impossible*/ /* FetchTexel3D */
@@ -654,6 +910,7 @@ const struct gl_texture_format _mesa_texformat_rgba_fxt1 = {
const struct gl_texture_format _mesa_texformat_rgb_dxt1 = {
MESA_FORMAT_RGB_DXT1, /* MesaFormat */
GL_RGB, /* BaseFormat */
+ GL_UNSIGNED_NORMALIZED_ARB, /* DataType */
4, /*approx*/ /* RedBits */
4, /*approx*/ /* GreenBits */
4, /*approx*/ /* BlueBits */
@@ -663,6 +920,7 @@ const struct gl_texture_format _mesa_texformat_rgb_dxt1 = {
0, /* IndexBits */
0, /* DepthBits */
0, /* TexelBytes */
+ NULL, /* StoreTexImageFunc */
NULL, /*impossible*/ /* FetchTexel1D */
fetch_texel_2d_rgb_dxt1, /* FetchTexel2D */
NULL, /*impossible*/ /* FetchTexel3D */
@@ -674,6 +932,7 @@ const struct gl_texture_format _mesa_texformat_rgb_dxt1 = {
const struct gl_texture_format _mesa_texformat_rgba_dxt1 = {
MESA_FORMAT_RGBA_DXT1, /* MesaFormat */
GL_RGBA, /* BaseFormat */
+ GL_UNSIGNED_NORMALIZED_ARB, /* DataType */
4, /*approx*/ /* RedBits */
4, /*approx*/ /* GreenBits */
4, /*approx*/ /* BlueBits */
@@ -683,6 +942,7 @@ const struct gl_texture_format _mesa_texformat_rgba_dxt1 = {
0, /* IndexBits */
0, /* DepthBits */
0, /* TexelBytes */
+ NULL, /* StoreTexImageFunc */
NULL, /*impossible*/ /* FetchTexel1D */
fetch_texel_2d_rgba_dxt1, /* FetchTexel2D */
NULL, /*impossible*/ /* FetchTexel3D */
@@ -694,6 +954,7 @@ const struct gl_texture_format _mesa_texformat_rgba_dxt1 = {
const struct gl_texture_format _mesa_texformat_rgba_dxt3 = {
MESA_FORMAT_RGBA_DXT3, /* MesaFormat */
GL_RGBA, /* BaseFormat */
+ GL_UNSIGNED_NORMALIZED_ARB, /* DataType */
4, /*approx*/ /* RedBits */
4, /*approx*/ /* GreenBits */
4, /*approx*/ /* BlueBits */
@@ -703,6 +964,7 @@ const struct gl_texture_format _mesa_texformat_rgba_dxt3 = {
0, /* IndexBits */
0, /* DepthBits */
0, /* TexelBytes */
+ NULL, /* StoreTexImageFunc */
NULL, /*impossible*/ /* FetchTexel1D */
fetch_texel_2d_rgba_dxt3, /* FetchTexel2D */
NULL, /*impossible*/ /* FetchTexel3D */
@@ -714,6 +976,7 @@ const struct gl_texture_format _mesa_texformat_rgba_dxt3 = {
const struct gl_texture_format _mesa_texformat_rgba_dxt5 = {
MESA_FORMAT_RGBA_DXT5, /* MesaFormat */
GL_RGBA, /* BaseFormat */
+ GL_UNSIGNED_NORMALIZED_ARB, /* DataType */
4,/*approx*/ /* RedBits */
4,/*approx*/ /* GreenBits */
4,/*approx*/ /* BlueBits */
@@ -723,6 +986,7 @@ const struct gl_texture_format _mesa_texformat_rgba_dxt5 = {
0, /* IndexBits */
0, /* DepthBits */
0, /* TexelBytes */
+ NULL, /* StoreTexImageFunc */
NULL, /*impossible*/ /* FetchTexel1D */
fetch_texel_2d_rgba_dxt5, /* FetchTexel2D */
NULL, /*impossible*/ /* FetchTexel3D */
@@ -737,7 +1001,7 @@ const struct gl_texture_format _mesa_texformat_rgba_dxt5 = {
const struct gl_texture_format _mesa_texformat_abgr8888 = {
MESA_FORMAT_ABGR8888, /* MesaFormat */
GL_RGBA, /* BaseFormat */
- GL_UNSIGNED_INT_8_8_8_8, /* Type */
+ GL_UNSIGNED_NORMALIZED_ARB, /* DataType */
8, /* RedBits */
8, /* GreenBits */
8, /* BlueBits */
@@ -747,6 +1011,7 @@ const struct gl_texture_format _mesa_texformat_abgr8888 = {
0, /* IndexBits */
0, /* DepthBits */
4, /* TexelBytes */
+ NULL, /* StoreTexImageFunc */
fetch_texel_1d_abgr8888, /* FetchTexel1D */
fetch_texel_2d_abgr8888, /* FetchTexel2D */
fetch_texel_3d_abgr8888, /* FetchTexel3D */
@@ -756,6 +1021,7 @@ const struct gl_texture_format _mesa_texformat_abgr8888 = {
const struct gl_texture_format _mesa_texformat_bgra8888 = {
MESA_FORMAT_BGRA8888, /* MesaFormat */
GL_RGBA, /* BaseFormat */
+ GL_UNSIGNED_NORMALIZED_ARB, /* DataType */
GL_UNSIGNED_INT_8_8_8_8, /* Type */
8, /* RedBits */
8, /* GreenBits */
@@ -766,6 +1032,7 @@ const struct gl_texture_format _mesa_texformat_bgra8888 = {
0, /* IndexBits */
0, /* DepthBits */
4, /* TexelBytes */
+ NULL, /* StoreTexImageFunc */
fetch_texel_1d_bgra8888, /* FetchTexel1D */
fetch_texel_2d_bgra8888, /* FetchTexel2D */
fetch_texel_3d_bgra8888, /* FetchTexel3D */
@@ -775,6 +1042,7 @@ const struct gl_texture_format _mesa_texformat_bgra8888 = {
const struct gl_texture_format _mesa_texformat_bgr888 = {
MESA_FORMAT_BGR888, /* MesaFormat */
GL_RGB, /* BaseFormat */
+ GL_UNSIGNED_NORMALIZED_ARB, /* DataType */
GL_UNSIGNED_BYTE, /* Type */
8, /* RedBits */
8, /* GreenBits */
@@ -785,6 +1053,7 @@ const struct gl_texture_format _mesa_texformat_bgr888 = {
0, /* IndexBits */
0, /* DepthBits */
3, /* TexelBytes */
+ NULL, /* StoreTexImageFunc */
fetch_texel_1d_bgr888, /* FetchTexel1D */
fetch_texel_2d_bgr888, /* FetchTexel2D */
fetch_texel_3d_bgr888, /* FetchTexel3D */
@@ -794,6 +1063,7 @@ const struct gl_texture_format _mesa_texformat_bgr888 = {
const struct gl_texture_format _mesa_texformat_bgr565 = {
MESA_FORMAT_BGR565, /* MesaFormat */
GL_RGB, /* BaseFormat */
+ GL_UNSIGNED_NORMALIZED_ARB, /* DataType */
GL_UNSIGNED_SHORT_5_6_5, /* Type */
5, /* RedBits */
6, /* GreenBits */
@@ -804,6 +1074,7 @@ const struct gl_texture_format _mesa_texformat_bgr565 = {
0, /* IndexBits */
0, /* DepthBits */
2, /* TexelBytes */
+ NULL, /* StoreTexImageFunc */
fetch_texel_1d_bgr565, /* FetchTexel1D */
fetch_texel_2d_bgr565, /* FetchTexel2D */
fetch_texel_3d_bgr565, /* FetchTexel3D */
@@ -813,6 +1084,7 @@ const struct gl_texture_format _mesa_texformat_bgr565 = {
const struct gl_texture_format _mesa_texformat_bgra4444 = {
MESA_FORMAT_BGRA4444, /* MesaFormat */
GL_RGBA, /* BaseFormat */
+ GL_UNSIGNED_NORMALIZED_ARB, /* DataType */
GL_UNSIGNED_SHORT_4_4_4_4_REV, /* Type */
4, /* RedBits */
4, /* GreenBits */
@@ -823,6 +1095,7 @@ const struct gl_texture_format _mesa_texformat_bgra4444 = {
0, /* IndexBits */
0, /* DepthBits */
2, /* TexelBytes */
+ NULL, /* StoreTexImageFunc */
fetch_texel_1d_bgra4444, /* FetchTexel1D */
fetch_texel_2d_bgra4444, /* FetchTexel2D */
fetch_texel_3d_bgra4444, /* FetchTexel3D */
@@ -832,6 +1105,7 @@ const struct gl_texture_format _mesa_texformat_bgra4444 = {
const struct gl_texture_format _mesa_texformat_bgra5551 = {
MESA_FORMAT_BGRA5551, /* MesaFormat */
GL_RGBA, /* BaseFormat */
+ GL_UNSIGNED_NORMALIZED_ARB, /* DataType */
GL_UNSIGNED_SHORT_1_5_5_5_REV, /* Type */
5, /* RedBits */
5, /* GreenBits */
@@ -842,6 +1116,7 @@ const struct gl_texture_format _mesa_texformat_bgra5551 = {
0, /* IndexBits */
0, /* DepthBits */
2, /* TexelBytes */
+ NULL, /* StoreTexImageFunc */
fetch_texel_1d_bgra1555, /* FetchTexel1D */
fetch_texel_2d_bgra1555, /* FetchTexel2D */
fetch_texel_3d_bgra1555, /* FetchTexel3D */
@@ -851,6 +1126,7 @@ const struct gl_texture_format _mesa_texformat_bgra5551 = {
const struct gl_texture_format _mesa_texformat_la88 = {
MESA_FORMAT_LA88, /* MesaFormat */
GL_LUMINANCE_ALPHA, /* BaseFormat */
+ GL_UNSIGNED_NORMALIZED_ARB, /* DataType */
GL_UNSIGNED_BYTE, /* Type */
0, /* RedBits */
0, /* GreenBits */
@@ -861,6 +1137,7 @@ const struct gl_texture_format _mesa_texformat_la88 = {
0, /* IndexBits */
0, /* DepthBits */
2, /* TexelBytes */
+ NULL, /* StoreTexImageFunc */
fetch_texel_1d_la88, /* FetchTexel1D */
fetch_texel_2d_la88, /* FetchTexel2D */
fetch_texel_3d_la88, /* FetchTexel3D */
@@ -870,6 +1147,7 @@ const struct gl_texture_format _mesa_texformat_la88 = {
const struct gl_texture_format _mesa_texformat_bgr233 = {
MESA_FORMAT_BGR233, /* MesaFormat */
GL_RGB, /* BaseFormat */
+ GL_UNSIGNED_NORMALIZED_ARB /* DataType */
GL_UNSIGNED_BYTE_3_3_2, /* Type */
3, /* RedBits */
3, /* GreenBits */
@@ -880,6 +1158,7 @@ const struct gl_texture_format _mesa_texformat_bgr233 = {
0, /* IndexBits */
0, /* DepthBits */
1, /* TexelBytes */
+ NULL, /* StoreTexImageFunc */
fetch_texel_1d_bgr233, /* FetchTexel1D */
fetch_texel_2d_bgr233, /* FetchTexel2D */
fetch_texel_3d_bgr233, /* FetchTexel3D */
@@ -897,6 +1176,7 @@ const struct gl_texture_format _mesa_texformat_bgr233 = {
const struct gl_texture_format _mesa_null_texformat = {
-1, /* MesaFormat */
0, /* BaseFormat */
+ GL_NONE, /* DataType */
0, /* RedBits */
0, /* GreenBits */
0, /* BlueBits */
@@ -906,6 +1186,7 @@ const struct gl_texture_format _mesa_null_texformat = {
0, /* IndexBits */
0, /* DepthBits */
0, /* TexelBytes */
+ NULL, /* StoreTexImageFunc */
fetch_null_texel, /* FetchTexel1D */
fetch_null_texel, /* FetchTexel2D */
fetch_null_texel, /* FetchTexel3D */
@@ -917,6 +1198,7 @@ const struct gl_texture_format _mesa_null_texformat = {
/*@}*/
+#if !NEWTEXSTORE
/**
* Determine whether a given texture format is a hardware texture
* format.
@@ -934,6 +1216,7 @@ _mesa_is_hardware_tex_format( const struct gl_texture_format *format )
{
return (format->MesaFormat < MESA_FORMAT_RGBA);
}
+#endif
/**
@@ -949,7 +1232,7 @@ _mesa_is_hardware_tex_format( const struct gl_texture_format *format )
* choosen texture format, or NULL on failure.
*
* This is called via dd_function_table::ChooseTextureFormat. Hardware drivers
- * typically override this function with a specialized version.
+ * will typically override this function with a specialized version.
*/
const struct gl_texture_format *
_mesa_choose_tex_format( GLcontext *ctx, GLint internalFormat,
@@ -958,192 +1241,212 @@ _mesa_choose_tex_format( GLcontext *ctx, GLint internalFormat,
(void) format;
(void) type;
- switch ( internalFormat ) {
- /* GH: Bias towards GL_RGB, GL_RGBA texture formats. This has
- * got to be better than sticking them way down the end of this
- * huge list.
- */
- case 4: /* Quake3 uses this... */
- case GL_RGBA:
- return &_mesa_texformat_rgba;
-
- case 3: /* ... and this. */
- case GL_RGB:
- return &_mesa_texformat_rgb;
-
- /* GH: Okay, keep checking as normal. Still test for GL_RGB,
- * GL_RGBA formats first.
- */
- case GL_RGBA2:
- case GL_RGBA4:
- case GL_RGB5_A1:
- case GL_RGBA8:
- case GL_RGB10_A2:
- case GL_RGBA12:
- case GL_RGBA16:
- return &_mesa_texformat_rgba;
-
- case GL_R3_G3_B2:
- case GL_RGB4:
- case GL_RGB5:
- case GL_RGB8:
- case GL_RGB10:
- case GL_RGB12:
- case GL_RGB16:
- return &_mesa_texformat_rgb;
-
- case GL_ALPHA:
- case GL_ALPHA4:
- case GL_ALPHA8:
- case GL_ALPHA12:
- case GL_ALPHA16:
- return &_mesa_texformat_alpha;
-
- case 1:
- case GL_LUMINANCE:
- case GL_LUMINANCE4:
- case GL_LUMINANCE8:
- case GL_LUMINANCE12:
- case GL_LUMINANCE16:
- return &_mesa_texformat_luminance;
-
- case 2:
- case GL_LUMINANCE_ALPHA:
- case GL_LUMINANCE4_ALPHA4:
- case GL_LUMINANCE6_ALPHA2:
- case GL_LUMINANCE8_ALPHA8:
- case GL_LUMINANCE12_ALPHA4:
- case GL_LUMINANCE12_ALPHA12:
- case GL_LUMINANCE16_ALPHA16:
- return &_mesa_texformat_luminance_alpha;
-
- case GL_INTENSITY:
- case GL_INTENSITY4:
- case GL_INTENSITY8:
- case GL_INTENSITY12:
- case GL_INTENSITY16:
- return &_mesa_texformat_intensity;
-
- case GL_COLOR_INDEX:
- case GL_COLOR_INDEX1_EXT:
- case GL_COLOR_INDEX2_EXT:
- case GL_COLOR_INDEX4_EXT:
- case GL_COLOR_INDEX8_EXT:
- case GL_COLOR_INDEX12_EXT:
- case GL_COLOR_INDEX16_EXT:
- return &_mesa_texformat_color_index;
-
- case GL_DEPTH_COMPONENT:
- case GL_DEPTH_COMPONENT16_SGIX:
- case GL_DEPTH_COMPONENT24_SGIX:
- case GL_DEPTH_COMPONENT32_SGIX:
- if (!ctx->Extensions.SGIX_depth_texture)
- _mesa_problem(ctx, "depth format without GL_SGIX_depth_texture");
- return &_mesa_texformat_depth_component;
+ switch (internalFormat) {
+ /* RGBA formats */
+ case 4:
+ case GL_RGBA:
+ case GL_RGBA8:
+ case GL_RGB10_A2:
+ case GL_RGBA12:
+ case GL_RGBA16:
+ return &_mesa_texformat_rgba;
+ case GL_RGB5_A1:
+ return &_mesa_texformat_argb1555;
+ case GL_RGBA2:
+ case GL_RGBA4:
+ return &_mesa_texformat_argb4444;
+
+ /* RGB formats */
+ case 3:
+ case GL_RGB:
+ case GL_RGB8:
+ case GL_RGB10:
+ case GL_RGB12:
+ case GL_RGB16:
+ return &_mesa_texformat_rgb;
+ case GL_R3_G3_B2:
+ return &_mesa_texformat_rgb332;
+ case GL_RGB4:
+ case GL_RGB5:
+ return &_mesa_texformat_rgb565;
+
+ /* Alpha formats */
+ case GL_ALPHA:
+ case GL_ALPHA4:
+ case GL_ALPHA8:
+ case GL_ALPHA12:
+ case GL_ALPHA16:
+ return &_mesa_texformat_alpha;
+
+ /* Luminance formats */
+ case 1:
+ case GL_LUMINANCE:
+ case GL_LUMINANCE4:
+ case GL_LUMINANCE12:
+ case GL_LUMINANCE16:
+ return &_mesa_texformat_luminance;
+ case GL_LUMINANCE8:
+ return &_mesa_texformat_l8;
+
+ /* Luminance/Alpha formats */
+ case 2:
+ case GL_LUMINANCE_ALPHA:
+ case GL_LUMINANCE4_ALPHA4:
+ case GL_LUMINANCE6_ALPHA2:
+ case GL_LUMINANCE12_ALPHA4:
+ case GL_LUMINANCE12_ALPHA12:
+ case GL_LUMINANCE16_ALPHA16:
+ return &_mesa_texformat_luminance_alpha;
+ case GL_LUMINANCE8_ALPHA8:
+ return &_mesa_texformat_al88;
+
+ case GL_INTENSITY:
+ case GL_INTENSITY4:
+ case GL_INTENSITY12:
+ case GL_INTENSITY16:
+ return &_mesa_texformat_intensity;
+ case GL_INTENSITY8:
+ return &_mesa_texformat_i8;
+
+ case GL_COLOR_INDEX:
+ case GL_COLOR_INDEX1_EXT:
+ case GL_COLOR_INDEX2_EXT:
+ case GL_COLOR_INDEX4_EXT:
+ case GL_COLOR_INDEX12_EXT:
+ case GL_COLOR_INDEX16_EXT:
+ return &_mesa_texformat_color_index;
+ case GL_COLOR_INDEX8_EXT:
+ return &_mesa_texformat_ci8;
+
+ default:
+ ; /* fallthrough */
+ }
- case GL_COMPRESSED_ALPHA_ARB:
- if (!ctx->Extensions.ARB_texture_compression)
- _mesa_problem(ctx, "texture compression extension not enabled");
- return &_mesa_texformat_alpha;
- case GL_COMPRESSED_LUMINANCE_ARB:
- if (!ctx->Extensions.ARB_texture_compression)
- _mesa_problem(ctx, "texture compression extension not enabled");
- return &_mesa_texformat_luminance;
- case GL_COMPRESSED_LUMINANCE_ALPHA_ARB:
- if (!ctx->Extensions.ARB_texture_compression)
- _mesa_problem(ctx, "texture compression extension not enabled");
- return &_mesa_texformat_luminance_alpha;
- case GL_COMPRESSED_INTENSITY_ARB:
- if (!ctx->Extensions.ARB_texture_compression)
- _mesa_problem(ctx, "texture compression extension not enabled");
- return &_mesa_texformat_intensity;
- case GL_COMPRESSED_RGB_ARB:
- if (!ctx->Extensions.ARB_texture_compression)
- _mesa_problem(ctx, "texture compression extension not enabled");
- if (ctx->Extensions.TDFX_texture_compression_FXT1)
- return &_mesa_texformat_rgb_fxt1;
- else if (ctx->Extensions.EXT_texture_compression_s3tc || ctx->Extensions.S3_s3tc)
- return &_mesa_texformat_rgb_dxt1;
- return &_mesa_texformat_rgb;
- case GL_COMPRESSED_RGBA_ARB:
- if (!ctx->Extensions.ARB_texture_compression)
- _mesa_problem(ctx, "texture compression extension not enabled");
- if (ctx->Extensions.TDFX_texture_compression_FXT1)
- return &_mesa_texformat_rgba_fxt1;
- else if (ctx->Extensions.EXT_texture_compression_s3tc || ctx->Extensions.S3_s3tc)
- return &_mesa_texformat_rgba_dxt3; /* Not rgba_dxt1! See the spec */
- return &_mesa_texformat_rgba;
-
- /* GL_MESA_ycrcr_texture */
- case GL_YCBCR_MESA:
- if (type == GL_UNSIGNED_SHORT_8_8_MESA)
- return &_mesa_texformat_ycbcr;
- else
- return &_mesa_texformat_ycbcr_rev;
-
- /* GL_3DFX_texture_compression_FXT1 */
- case GL_COMPRESSED_RGB_FXT1_3DFX:
- if (ctx->Extensions.TDFX_texture_compression_FXT1)
- return &_mesa_texformat_rgb_fxt1;
- else
- return NULL;
- case GL_COMPRESSED_RGBA_FXT1_3DFX:
- if (ctx->Extensions.TDFX_texture_compression_FXT1)
- return &_mesa_texformat_rgba_fxt1;
- else
- return NULL;
-
- /* GL_EXT_texture_compression_s3tc */
- case GL_COMPRESSED_RGB_S3TC_DXT1_EXT:
- if (ctx->Extensions.EXT_texture_compression_s3tc)
- return &_mesa_texformat_rgb_dxt1;
- else
- return NULL;
- case GL_COMPRESSED_RGBA_S3TC_DXT1_EXT:
- if (ctx->Extensions.EXT_texture_compression_s3tc)
- return &_mesa_texformat_rgba_dxt1;
- else
- return NULL;
- case GL_COMPRESSED_RGBA_S3TC_DXT3_EXT:
- if (ctx->Extensions.EXT_texture_compression_s3tc)
- return &_mesa_texformat_rgba_dxt3;
- else
- return NULL;
- case GL_COMPRESSED_RGBA_S3TC_DXT5_EXT:
- if (ctx->Extensions.EXT_texture_compression_s3tc)
- return &_mesa_texformat_rgba_dxt5;
- else
- return NULL;
-
- /* GL_S3_s3tc */
- case GL_RGB_S3TC:
- case GL_RGB4_S3TC:
- if (ctx->Extensions.S3_s3tc)
- return &_mesa_texformat_rgb_dxt1;
- else
- return NULL;
- case GL_RGBA_S3TC:
- case GL_RGBA4_S3TC:
- if (ctx->Extensions.S3_s3tc)
- return &_mesa_texformat_rgba_dxt3;
- else
- return NULL;
-
- /* XXX prototype/example code */
- /* GL_ATI_texture_float or GL_NV_float_buffer */
- case GL_RGBA_FLOAT32_ATI:
- return &_mesa_texformat_rgba_float32;
- case GL_RGBA_FLOAT16_ATI:
- return &_mesa_texformat_rgba_float16;
- case GL_RGB_FLOAT32_ATI:
- return &_mesa_texformat_rgb_float32;
- case GL_RGB_FLOAT16_ATI:
- return &_mesa_texformat_rgb_float16;
+ if (ctx->Extensions.SGIX_depth_texture) {
+ switch (internalFormat) {
+ case GL_DEPTH_COMPONENT:
+ case GL_DEPTH_COMPONENT24_SGIX:
+ case GL_DEPTH_COMPONENT32_SGIX:
+ return &_mesa_texformat_depth_component_float32;
+ case GL_DEPTH_COMPONENT16_SGIX:
+ return &_mesa_texformat_depth_component16;
+ default:
+ ; /* fallthrough */
+ }
+ }
- default:
- _mesa_problem(ctx, "unexpected format in _mesa_choose_tex_format()");
- return NULL;
+ if (ctx->Extensions.ARB_texture_compression) {
+ switch (internalFormat) {
+ case GL_COMPRESSED_ALPHA_ARB:
+ return &_mesa_texformat_alpha;
+ case GL_COMPRESSED_LUMINANCE_ARB:
+ return &_mesa_texformat_luminance;
+ case GL_COMPRESSED_LUMINANCE_ALPHA_ARB:
+ return &_mesa_texformat_luminance_alpha;
+ case GL_COMPRESSED_INTENSITY_ARB:
+ return &_mesa_texformat_intensity;
+ case GL_COMPRESSED_RGB_ARB:
+ if (ctx->Extensions.TDFX_texture_compression_FXT1)
+ return &_mesa_texformat_rgb_fxt1;
+ else if (ctx->Extensions.EXT_texture_compression_s3tc ||
+ ctx->Extensions.S3_s3tc)
+ return &_mesa_texformat_rgb_dxt1;
+ else
+ return &_mesa_texformat_rgb;
+ case GL_COMPRESSED_RGBA_ARB:
+ if (ctx->Extensions.TDFX_texture_compression_FXT1)
+ return &_mesa_texformat_rgba_fxt1;
+ else if (ctx->Extensions.EXT_texture_compression_s3tc ||
+ ctx->Extensions.S3_s3tc)
+ return &_mesa_texformat_rgba_dxt3; /* Not rgba_dxt1, see spec */
+ else
+ return &_mesa_texformat_rgba;
+ default:
+ ; /* fallthrough */
+ }
+ }
+
+ if (ctx->Extensions.MESA_ycbcr_texture) {
+ if (internalFormat == GL_YCBCR_MESA) {
+ if (type == GL_UNSIGNED_SHORT_8_8_MESA)
+ return &_mesa_texformat_ycbcr;
+ else
+ return &_mesa_texformat_ycbcr_rev;
+ }
}
+
+ if (ctx->Extensions.TDFX_texture_compression_FXT1) {
+ switch (internalFormat) {
+ case GL_COMPRESSED_RGB_FXT1_3DFX:
+ return &_mesa_texformat_rgb_fxt1;
+ case GL_COMPRESSED_RGBA_FXT1_3DFX:
+ return &_mesa_texformat_rgba_fxt1;
+ default:
+ ; /* fallthrough */
+ }
+ }
+
+ if (ctx->Extensions.EXT_texture_compression_s3tc) {
+ switch (internalFormat) {
+ case GL_COMPRESSED_RGB_S3TC_DXT1_EXT:
+ return &_mesa_texformat_rgb_dxt1;
+ case GL_COMPRESSED_RGBA_S3TC_DXT1_EXT:
+ return &_mesa_texformat_rgba_dxt1;
+ case GL_COMPRESSED_RGBA_S3TC_DXT3_EXT:
+ return &_mesa_texformat_rgba_dxt3;
+ case GL_COMPRESSED_RGBA_S3TC_DXT5_EXT:
+ return &_mesa_texformat_rgba_dxt5;
+ default:
+ ; /* fallthrough */
+ }
+ }
+
+ if (ctx->Extensions.S3_s3tc) {
+ switch (internalFormat) {
+ case GL_RGB_S3TC:
+ case GL_RGB4_S3TC:
+ return &_mesa_texformat_rgb_dxt1;
+ case GL_RGBA_S3TC:
+ case GL_RGBA4_S3TC:
+ return &_mesa_texformat_rgba_dxt3;
+ default:
+ ; /* fallthrough */
+ }
+ }
+
+ if (ctx->Extensions.ARB_texture_float) {
+ switch (internalFormat) {
+ case GL_ALPHA16F_ARB:
+ return &_mesa_texformat_alpha_float16;
+ case GL_ALPHA32F_ARB:
+ return &_mesa_texformat_alpha_float32;
+ case GL_LUMINANCE16F_ARB:
+ return &_mesa_texformat_luminance_float16;
+ case GL_LUMINANCE32F_ARB:
+ return &_mesa_texformat_luminance_float32;
+ case GL_LUMINANCE_ALPHA16F_ARB:
+ return &_mesa_texformat_luminance_alpha_float16;
+ case GL_LUMINANCE_ALPHA32F_ARB:
+ return &_mesa_texformat_luminance_alpha_float32;
+ case GL_INTENSITY16F_ARB:
+ return &_mesa_texformat_intensity_float16;
+ case GL_INTENSITY32F_ARB:
+ return &_mesa_texformat_intensity_float32;
+ case GL_RGB16F_ARB:
+ return &_mesa_texformat_rgb_float16;
+ case GL_RGB32F_ARB:
+ return &_mesa_texformat_rgb_float32;
+ case GL_RGBA16F_ARB:
+ return &_mesa_texformat_rgba_float16;
+ case GL_RGBA32F_ARB:
+ return &_mesa_texformat_rgba_float32;
+ default:
+ ; /* fallthrough */
+ }
+ }
+
+ _mesa_problem(ctx, "unexpected format in _mesa_choose_tex_format()");
+ return NULL;
}
diff --git a/src/mesa/main/texformat.h b/src/mesa/main/texformat.h
index df199c5340..cc26b7928a 100644
--- a/src/mesa/main/texformat.h
+++ b/src/mesa/main/texformat.h
@@ -1,15 +1,8 @@
-/**
- * \file texformat.h
- * Texture formats definitions.
- *
- * \author Gareth Hughes
- */
-
/*
* Mesa 3-D graphics library
- * Version: 5.1
+ * Version: 6.1
*
- * Copyright (C) 1999-2003 Brian Paul All Rights Reserved.
+ * Copyright (C) 1999-2004 Brian Paul All Rights Reserved.
*
* Permission is hereby granted, free of charge, to any person obtaining a
* copy of this software and associated documentation files (the "Software"),
@@ -30,16 +23,26 @@
*/
+/**
+ * \file texformat.h
+ * Texture formats definitions.
+ *
+ * \author Gareth Hughes
+ */
+
+
#ifndef TEXFORMAT_H
#define TEXFORMAT_H
+#define NEWTEXSTORE 1
+
+
#include "mtypes.h"
/**
- * Mesa internal texture image types.
- *
- * All texture images must be stored in one of these formats.
+ * Mesa internal texture image formats.
+ * All texture images are stored in one of these formats.
*
* NOTE: when you add a new format, be sure to update the do_row()
* function in texstore.c used for auto mipmap generation.
@@ -111,10 +114,8 @@ enum _format {
/**
* \name Generic GLchan-based formats.
*
- * These are the default formats used by the software rasterizer and, unless
- * the driver overrides the texture image functions, incoming images will be
- * converted to one of these formats. Components are arrays of GLchan
- * values, so there will be no big/little endian issues.
+ * Software-oriented texture formats. Texels are arrays of GLchan
+ * values so there will be no big/little endian issues.
*
* \note Because these are based on the GLchan data type, one cannot assume
* 8 bits per channel with these formats. If you require GLubyte channels,
@@ -131,29 +132,33 @@ enum _format {
/*@}*/
/**
+ * Depth textures
+ */
+ /*@{*/
+ MESA_FORMAT_DEPTH_COMPONENT_FLOAT32,
+ MESA_FORMAT_DEPTH_COMPONENT16,
+ /*@}*/
+
+ /**
* \name Floating point texture formats.
*/
/*@{*/
- MESA_FORMAT_DEPTH_COMPONENT,
MESA_FORMAT_RGBA_FLOAT32,
MESA_FORMAT_RGBA_FLOAT16,
MESA_FORMAT_RGB_FLOAT32,
- MESA_FORMAT_RGB_FLOAT16
+ MESA_FORMAT_RGB_FLOAT16,
+ MESA_FORMAT_ALPHA_FLOAT32,
+ MESA_FORMAT_ALPHA_FLOAT16,
+ MESA_FORMAT_LUMINANCE_FLOAT32,
+ MESA_FORMAT_LUMINANCE_FLOAT16,
+ MESA_FORMAT_LUMINANCE_ALPHA_FLOAT32,
+ MESA_FORMAT_LUMINANCE_ALPHA_FLOAT16,
+ MESA_FORMAT_INTENSITY_FLOAT32,
+ MESA_FORMAT_INTENSITY_FLOAT16
/*@}*/
};
-extern GLboolean
-_mesa_is_hardware_tex_format( const struct gl_texture_format *format );
-
-extern const struct gl_texture_format *
-_mesa_choose_tex_format( GLcontext *ctx, GLint internalFormat,
- GLenum format, GLenum type );
-
-extern GLint
-_mesa_base_compressed_texformat(GLcontext *ctx, GLint intFormat);
-
-
/** The default formats, GLchan per component */
/*@{*/
extern const struct gl_texture_format _mesa_texformat_rgba;
@@ -165,13 +170,26 @@ extern const struct gl_texture_format _mesa_texformat_intensity;
extern const struct gl_texture_format _mesa_texformat_color_index;
/*@}*/
+/** Depth textures */
+/*@{*/
+extern const struct gl_texture_format _mesa_texformat_depth_component_float32;
+extern const struct gl_texture_format _mesa_texformat_depth_component16;
+/*@}*/
+
/** Floating point texture formats */
/*@{*/
-extern const struct gl_texture_format _mesa_texformat_depth_component;
extern const struct gl_texture_format _mesa_texformat_rgba_float32;
extern const struct gl_texture_format _mesa_texformat_rgba_float16;
extern const struct gl_texture_format _mesa_texformat_rgb_float32;
extern const struct gl_texture_format _mesa_texformat_rgb_float16;
+extern const struct gl_texture_format _mesa_texformat_alpha_float32;
+extern const struct gl_texture_format _mesa_texformat_alpha_float16;
+extern const struct gl_texture_format _mesa_texformat_luminance_float32;
+extern const struct gl_texture_format _mesa_texformat_luminance_float16;
+extern const struct gl_texture_format _mesa_texformat_luminance_alpha_float32;
+extern const struct gl_texture_format _mesa_texformat_luminance_alpha_float16;
+extern const struct gl_texture_format _mesa_texformat_intensity_float32;
+extern const struct gl_texture_format _mesa_texformat_intensity_float16;
/*@}*/
/** \name The hardware-friendly formats */
@@ -203,4 +221,18 @@ extern const struct gl_texture_format _mesa_texformat_rgba_dxt5;
extern const struct gl_texture_format _mesa_null_texformat;
/*@}*/
+
+#if !NEWTEXSTORE
+extern GLboolean
+_mesa_is_hardware_tex_format( const struct gl_texture_format *format );
+#endif
+
+extern const struct gl_texture_format *
+_mesa_choose_tex_format( GLcontext *ctx, GLint internalFormat,
+ GLenum format, GLenum type );
+
+extern GLint
+_mesa_base_compressed_texformat(GLcontext *ctx, GLint intFormat);
+
+
#endif
diff --git a/src/mesa/main/texformat_tmp.h b/src/mesa/main/texformat_tmp.h
index 1ec9bb33b4..ba52a8812a 100644
--- a/src/mesa/main/texformat_tmp.h
+++ b/src/mesa/main/texformat_tmp.h
@@ -1,20 +1,3 @@
-/**
- * \file texformat_tmp.h
- * Texel fetch functions template.
- *
- * This template file is used by texformat.c to generate texel fetch functions
- * for 1-D, 2-D and 3-D texture images.
- *
- * It should be expanded by definining \p DIM as the number texture dimensions
- * (1, 2 or 3). According to the value of \p DIM a serie of macros is defined
- * for the texel lookup in the gl_texture_image::Data.
- *
- * \sa texformat.c and FetchTexel.
- *
- * \author Gareth Hughes
- * \author Brian Paul
- */
-
/*
* Mesa 3-D graphics library
* Version: 6.1
@@ -40,6 +23,24 @@
*/
+/**
+ * \file texformat_tmp.h
+ * Texel fetch functions template.
+ *
+ * This template file is used by texformat.c to generate texel fetch functions
+ * for 1-D, 2-D and 3-D texture images.
+ *
+ * It should be expanded by defining \p DIM as the number texture dimensions
+ * (1, 2 or 3). According to the value of \p DIM a series of macros is defined
+ * for the texel lookup in the gl_texture_image::Data.
+ *
+ * \sa texformat.c and FetchTexel.
+ *
+ * \author Gareth Hughes
+ * \author Brian Paul
+ */
+
+
#if DIM == 1
#define CHAN_SRC( t, i, j, k, sz ) \
@@ -51,7 +52,7 @@
#define FLOAT_SRC( t, i, j, k, sz ) \
((GLfloat *)(t)->Data + (i) * (sz))
#define HALF_SRC( t, i, j, k, sz ) \
- ((GLhalfNV *)(t)->Data + (i) * (sz))
+ ((GLhalfARB *)(t)->Data + (i) * (sz))
#define FETCH(x) fetch_texel_1d_##x
@@ -66,7 +67,7 @@
#define FLOAT_SRC( t, i, j, k, sz ) \
((GLfloat *)(t)->Data + ((t)->RowStride * (j) + (i)) * (sz))
#define HALF_SRC( t, i, j, k, sz ) \
- ((GLhalfNV *)(t)->Data + ((t)->RowStride * (j) + (i)) * (sz))
+ ((GLhalfARB *)(t)->Data + ((t)->RowStride * (j) + (i)) * (sz))
#define FETCH(x) fetch_texel_2d_##x
@@ -85,7 +86,7 @@
((GLfloat *)(t)->Data + (((t)->Height * (k) + (j)) * \
(t)->RowStride + (i)) * (sz))
#define HALF_SRC( t, i, j, k, sz ) \
- ((GLhalfNV *)(t)->Data + (((t)->Height * (k) + (j)) * \
+ ((GLhalfARB *)(t)->Data + (((t)->Height * (k) + (j)) * \
(t)->RowStride + (i)) * (sz))
#define FETCH(x) fetch_texel_3d_##x
@@ -244,9 +245,11 @@ static void FETCH(f_color_index)( const struct gl_texture_image *texImage,
}
-/* Fetch depth texel from 1D, 2D or 3D DEPTH texture, returning 1 GLfloat */
-/* Note: no GLchan version of this function */
-static void FETCH(f_depth_component)( const struct gl_texture_image *texImage,
+/* Fetch depth texel from 1D, 2D or 3D float32 DEPTH texture,
+ * returning 1 GLfloat.
+ * Note: no GLchan version of this function.
+ */
+static void FETCH(f_depth_component_f32)( const struct gl_texture_image *texImage,
GLint i, GLint j, GLint k, GLfloat *texel )
{
const GLfloat *src = FLOAT_SRC( texImage, i, j, k, 1 );
@@ -254,6 +257,31 @@ static void FETCH(f_depth_component)( const struct gl_texture_image *texImage,
}
+/* Fetch depth texel from 1D, 2D or 3D float32 DEPTH texture,
+ * returning 1 GLfloat.
+ * Note: no GLchan version of this function.
+ */
+static void FETCH(f_depth_component16)( const struct gl_texture_image *texImage,
+ GLint i, GLint j, GLint k, GLfloat *texel )
+{
+ const GLushort *src = USHORT_SRC( texImage, i, j, k );
+ texel[0] = src[0] * (1.0F / 65535.0F);
+}
+
+
+/* Fetch color texel from 1D, 2D or 3D RGBA_FLOAT32 texture,
+ * returning 4 GLchans.
+ */
+static void FETCH(rgba_f32)( const struct gl_texture_image *texImage,
+ GLint i, GLint j, GLint k, GLchan *texel )
+{
+ const GLfloat *src = FLOAT_SRC( texImage, i, j, k, 4 );
+ UNCLAMPED_FLOAT_TO_CHAN(texel[RCOMP], src[0]);
+ UNCLAMPED_FLOAT_TO_CHAN(texel[GCOMP], src[1]);
+ UNCLAMPED_FLOAT_TO_CHAN(texel[BCOMP], src[2]);
+ UNCLAMPED_FLOAT_TO_CHAN(texel[ACOMP], src[3]);
+}
+
/* Fetch color texel from 1D, 2D or 3D RGBA_FLOAT32 texture,
* returning 4 GLfloats.
*/
@@ -268,18 +296,43 @@ static void FETCH(f_rgba_f32)( const struct gl_texture_image *texImage,
}
/* Fetch color texel from 1D, 2D or 3D RGBA_FLOAT16 texture,
+ * returning 4 GLchans.
+ */
+static void FETCH(rgba_f16)( const struct gl_texture_image *texImage,
+ GLint i, GLint j, GLint k, GLchan *texel )
+{
+ const GLhalfARB *src = HALF_SRC( texImage, i, j, k, 4 );
+ UNCLAMPED_FLOAT_TO_CHAN(texel[RCOMP], _mesa_half_to_float(src[0]));
+ UNCLAMPED_FLOAT_TO_CHAN(texel[GCOMP], _mesa_half_to_float(src[1]));
+ UNCLAMPED_FLOAT_TO_CHAN(texel[BCOMP], _mesa_half_to_float(src[2]));
+ UNCLAMPED_FLOAT_TO_CHAN(texel[ACOMP], _mesa_half_to_float(src[3]));
+}
+
+/* Fetch color texel from 1D, 2D or 3D RGBA_FLOAT16 texture,
* returning 4 GLfloats.
*/
static void FETCH(f_rgba_f16)( const struct gl_texture_image *texImage,
GLint i, GLint j, GLint k, GLfloat *texel )
{
- const GLhalfNV *src = HALF_SRC( texImage, i, j, k, 4 );
+ const GLhalfARB *src = HALF_SRC( texImage, i, j, k, 4 );
texel[RCOMP] = _mesa_half_to_float(src[0]);
texel[GCOMP] = _mesa_half_to_float(src[1]);
texel[BCOMP] = _mesa_half_to_float(src[2]);
texel[ACOMP] = _mesa_half_to_float(src[3]);
}
+/* Fetch color texel from 1D, 2D or 3D RGB_FLOAT32 texture,
+ * returning 4 GLchans.
+ */
+static void FETCH(rgb_f32)( const struct gl_texture_image *texImage,
+ GLint i, GLint j, GLint k, GLchan *texel )
+{
+ const GLfloat *src = FLOAT_SRC( texImage, i, j, k, 3 );
+ UNCLAMPED_FLOAT_TO_CHAN(texel[RCOMP], src[0]);
+ UNCLAMPED_FLOAT_TO_CHAN(texel[GCOMP], src[1]);
+ UNCLAMPED_FLOAT_TO_CHAN(texel[BCOMP], src[2]);
+ texel[ACOMP] = CHAN_MAX;
+}
/* Fetch color texel from 1D, 2D or 3D RGB_FLOAT32 texture,
* returning 4 GLfloats.
@@ -294,19 +347,240 @@ static void FETCH(f_rgb_f32)( const struct gl_texture_image *texImage,
texel[ACOMP] = CHAN_MAXF;
}
+/* Fetch color texel from 1D, 2D or 3D RGBA_FLOAT16 texture,
+ * returning 4 GLchans.
+ */
+static void FETCH(rgb_f16)( const struct gl_texture_image *texImage,
+ GLint i, GLint j, GLint k, GLchan *texel )
+{
+ const GLhalfARB *src = HALF_SRC( texImage, i, j, k, 3 );
+ UNCLAMPED_FLOAT_TO_CHAN(texel[RCOMP], _mesa_half_to_float(src[0]));
+ UNCLAMPED_FLOAT_TO_CHAN(texel[GCOMP], _mesa_half_to_float(src[1]));
+ UNCLAMPED_FLOAT_TO_CHAN(texel[BCOMP], _mesa_half_to_float(src[2]));
+ texel[ACOMP] = CHAN_MAX;
+}
+
/* Fetch color texel from 1D, 2D or 3D RGB_FLOAT16 texture,
* returning 4 GLfloats.
*/
static void FETCH(f_rgb_f16)( const struct gl_texture_image *texImage,
GLint i, GLint j, GLint k, GLfloat *texel )
{
- const GLhalfNV *src = HALF_SRC( texImage, i, j, k, 3 );
+ const GLhalfARB *src = HALF_SRC( texImage, i, j, k, 3 );
texel[RCOMP] = _mesa_half_to_float(src[0]);
texel[GCOMP] = _mesa_half_to_float(src[1]);
texel[BCOMP] = _mesa_half_to_float(src[2]);
texel[ACOMP] = CHAN_MAXF;
}
+/* Fetch color texel from 1D, 2D or 3D ALPHA_FLOAT32 texture,
+ * returning 4 GLchans.
+ */
+static void FETCH(alpha_f32)( const struct gl_texture_image *texImage,
+ GLint i, GLint j, GLint k, GLchan *texel )
+{
+ const GLfloat *src = FLOAT_SRC( texImage, i, j, k, 1 );
+ texel[RCOMP] =
+ texel[GCOMP] =
+ texel[BCOMP] = 0;
+ UNCLAMPED_FLOAT_TO_CHAN(texel[ACOMP], src[0]);
+}
+
+/* Fetch color texel from 1D, 2D or 3D ALPHA_FLOAT32 texture,
+ * returning 4 GLfloats.
+ */
+static void FETCH(f_alpha_f32)( const struct gl_texture_image *texImage,
+ GLint i, GLint j, GLint k, GLfloat *texel )
+{
+ const GLfloat *src = FLOAT_SRC( texImage, i, j, k, 1 );
+ texel[RCOMP] =
+ texel[GCOMP] =
+ texel[BCOMP] = 0.0F;
+ texel[ACOMP] = src[0];
+}
+
+/* Fetch color texel from 1D, 2D or 3D ALPHA_FLOAT16 texture,
+ * returning 4 GLchans.
+ */
+static void FETCH(alpha_f16)( const struct gl_texture_image *texImage,
+ GLint i, GLint j, GLint k, GLchan *texel )
+{
+ const GLhalfARB *src = HALF_SRC( texImage, i, j, k, 1 );
+ texel[RCOMP] =
+ texel[GCOMP] =
+ texel[BCOMP] = 0;
+ UNCLAMPED_FLOAT_TO_CHAN(texel[ACOMP], _mesa_half_to_float(src[0]));
+}
+
+/* Fetch color texel from 1D, 2D or 3D ALPHA_FLOAT16 texture,
+ * returning 4 GLfloats.
+ */
+static void FETCH(f_alpha_f16)( const struct gl_texture_image *texImage,
+ GLint i, GLint j, GLint k, GLfloat *texel )
+{
+ const GLhalfARB *src = HALF_SRC( texImage, i, j, k, 1 );
+ texel[RCOMP] =
+ texel[GCOMP] =
+ texel[BCOMP] = 0.0F;
+ texel[ACOMP] = _mesa_half_to_float(src[0]);
+}
+
+/* Fetch color texel from 1D, 2D or 3D LUMINANCE_FLOAT32 texture,
+ * returning 4 GLchans.
+ */
+static void FETCH(luminance_f32)( const struct gl_texture_image *texImage,
+ GLint i, GLint j, GLint k, GLchan *texel )
+{
+ const GLfloat *src = FLOAT_SRC( texImage, i, j, k, 1 );
+ UNCLAMPED_FLOAT_TO_CHAN(texel[RCOMP], src[0]);
+ texel[GCOMP] =
+ texel[BCOMP] = texel[RCOMP];
+ texel[ACOMP] = CHAN_MAX;
+}
+
+/* Fetch color texel from 1D, 2D or 3D LUMINANCE_FLOAT32 texture,
+ * returning 4 GLfloats.
+ */
+static void FETCH(f_luminance_f32)( const struct gl_texture_image *texImage,
+ GLint i, GLint j, GLint k, GLfloat *texel )
+{
+ const GLfloat *src = FLOAT_SRC( texImage, i, j, k, 1 );
+ texel[RCOMP] =
+ texel[GCOMP] =
+ texel[BCOMP] = src[0];
+ texel[ACOMP] = CHAN_MAXF;
+}
+
+/* Fetch color texel from 1D, 2D or 3D LUMINANCE_FLOAT16 texture,
+ * returning 4 GLchans.
+ */
+static void FETCH(luminance_f16)( const struct gl_texture_image *texImage,
+ GLint i, GLint j, GLint k, GLchan *texel )
+{
+ const GLhalfARB *src = HALF_SRC( texImage, i, j, k, 1 );
+ UNCLAMPED_FLOAT_TO_CHAN(texel[RCOMP], _mesa_half_to_float(src[0]));
+ texel[GCOMP] =
+ texel[BCOMP] = texel[RCOMP];
+ texel[ACOMP] = CHAN_MAX;
+}
+
+/* Fetch color texel from 1D, 2D or 3D LUMINANCE_FLOAT16 texture,
+ * returning 4 GLfloats.
+ */
+static void FETCH(f_luminance_f16)( const struct gl_texture_image *texImage,
+ GLint i, GLint j, GLint k, GLfloat *texel )
+{
+ const GLhalfARB *src = HALF_SRC( texImage, i, j, k, 1 );
+ texel[RCOMP] =
+ texel[GCOMP] =
+ texel[BCOMP] = _mesa_half_to_float(src[0]);
+ texel[ACOMP] = CHAN_MAXF;
+}
+
+/* Fetch color texel from 1D, 2D or 3D LUMINANCE_ALPHA_FLOAT32 texture,
+ * returning 4 GLchans.
+ */
+static void FETCH(luminance_alpha_f32)( const struct gl_texture_image *texImage,
+ GLint i, GLint j, GLint k, GLchan *texel )
+{
+ const GLfloat *src = FLOAT_SRC( texImage, i, j, k, 2 );
+ UNCLAMPED_FLOAT_TO_CHAN(texel[RCOMP], src[0]);
+ texel[GCOMP] =
+ texel[BCOMP] = texel[RCOMP];
+ UNCLAMPED_FLOAT_TO_CHAN(texel[ACOMP], src[1]);
+}
+
+/* Fetch color texel from 1D, 2D or 3D LUMINANCE_ALPHA_FLOAT32 texture,
+ * returning 4 GLfloats.
+ */
+static void FETCH(f_luminance_alpha_f32)( const struct gl_texture_image *texImage,
+ GLint i, GLint j, GLint k, GLfloat *texel )
+{
+ const GLfloat *src = FLOAT_SRC( texImage, i, j, k, 2 );
+ texel[RCOMP] =
+ texel[GCOMP] =
+ texel[BCOMP] = src[0];
+ texel[ACOMP] = src[1];
+}
+
+/* Fetch color texel from 1D, 2D or 3D LUMINANCE_ALPHA_FLOAT16 texture,
+ * returning 4 GLfloats.
+ */
+static void FETCH(luminance_alpha_f16)( const struct gl_texture_image *texImage,
+ GLint i, GLint j, GLint k, GLchan *texel )
+{
+ const GLhalfARB *src = HALF_SRC( texImage, i, j, k, 2 );
+ UNCLAMPED_FLOAT_TO_CHAN(texel[RCOMP], _mesa_half_to_float(src[0]));
+ texel[GCOMP] =
+ texel[BCOMP] = texel[RCOMP];
+ UNCLAMPED_FLOAT_TO_CHAN(texel[ACOMP], _mesa_half_to_float(src[1]));
+}
+
+/* Fetch color texel from 1D, 2D or 3D LUMINANCE_ALPHA_FLOAT16 texture,
+ * returning 4 GLfloats.
+ */
+static void FETCH(f_luminance_alpha_f16)( const struct gl_texture_image *texImage,
+ GLint i, GLint j, GLint k, GLfloat *texel )
+{
+ const GLhalfARB *src = HALF_SRC( texImage, i, j, k, 2 );
+ texel[RCOMP] =
+ texel[GCOMP] =
+ texel[BCOMP] = _mesa_half_to_float(src[0]);
+ texel[ACOMP] = _mesa_half_to_float(src[1]);
+}
+
+/* Fetch color texel from 1D, 2D or 3D INTENSITY_FLOAT32 texture,
+ * returning 4 GLchans.
+ */
+static void FETCH(intensity_f32)( const struct gl_texture_image *texImage,
+ GLint i, GLint j, GLint k, GLchan *texel )
+{
+ const GLfloat *src = FLOAT_SRC( texImage, i, j, k, 1 );
+ UNCLAMPED_FLOAT_TO_CHAN(texel[RCOMP], src[0]);
+ texel[GCOMP] =
+ texel[BCOMP] =
+ texel[ACOMP] = texel[RCOMP];
+}
+
+/* Fetch color texel from 1D, 2D or 3D INTENSITY_FLOAT32 texture,
+ * returning 4 GLfloats.
+ */
+static void FETCH(f_intensity_f32)( const struct gl_texture_image *texImage,
+ GLint i, GLint j, GLint k, GLfloat *texel )
+{
+ const GLfloat *src = FLOAT_SRC( texImage, i, j, k, 1 );
+ texel[RCOMP] =
+ texel[GCOMP] =
+ texel[BCOMP] =
+ texel[ACOMP] = src[0];
+}
+
+/* Fetch color texel from 1D, 2D or 3D INTENSITY_FLOAT16 texture,
+ * returning 4 GLchans.
+ */
+static void FETCH(intensity_f16)( const struct gl_texture_image *texImage,
+ GLint i, GLint j, GLint k, GLchan *texel )
+{
+ const GLhalfARB *src = HALF_SRC( texImage, i, j, k, 1 );
+ UNCLAMPED_FLOAT_TO_CHAN(texel[RCOMP], _mesa_half_to_float(src[0]));
+ texel[GCOMP] =
+ texel[BCOMP] =
+ texel[ACOMP] = texel[RCOMP];
+}
+
+/* Fetch color texel from 1D, 2D or 3D INTENSITY_FLOAT16 texture,
+ * returning 4 GLfloats.
+ */
+static void FETCH(f_intensity_f16)( const struct gl_texture_image *texImage,
+ GLint i, GLint j, GLint k, GLfloat *texel )
+{
+ const GLhalfARB *src = HALF_SRC( texImage, i, j, k, 1 );
+ texel[RCOMP] =
+ texel[GCOMP] =
+ texel[BCOMP] =
+ texel[ACOMP] = _mesa_half_to_float(src[0]);
+}
+
/*
@@ -510,8 +784,8 @@ static void FETCH(a8)( const struct gl_texture_image *texImage,
GLint i, GLint j, GLint k, GLchan *texel )
{
const GLubyte *src = UBYTE_SRC( texImage, i, j, k, 1 );
- texel[RCOMP] = 0;
- texel[GCOMP] = 0;
+ texel[RCOMP] =
+ texel[GCOMP] =
texel[BCOMP] = 0;
texel[ACOMP] = UBYTE_TO_CHAN( src[0] );
}
@@ -533,8 +807,8 @@ static void FETCH(l8)( const struct gl_texture_image *texImage,
GLint i, GLint j, GLint k, GLchan *texel )
{
const GLubyte *src = UBYTE_SRC( texImage, i, j, k, 1 );
- texel[RCOMP] = UBYTE_TO_CHAN( src[0] );
- texel[GCOMP] = UBYTE_TO_CHAN( src[0] );
+ texel[RCOMP] =
+ texel[GCOMP] =
texel[BCOMP] = UBYTE_TO_CHAN( src[0] );
texel[ACOMP] = CHAN_MAX;
}
@@ -556,9 +830,9 @@ static void FETCH(i8)( const struct gl_texture_image *texImage,
GLint i, GLint j, GLint k, GLchan *texel )
{
const GLubyte *src = UBYTE_SRC( texImage, i, j, k, 1 );
- texel[RCOMP] = UBYTE_TO_CHAN( src[0] );
- texel[GCOMP] = UBYTE_TO_CHAN( src[0] );
- texel[BCOMP] = UBYTE_TO_CHAN( src[0] );
+ texel[RCOMP] =
+ texel[GCOMP] =
+ texel[BCOMP] =
texel[ACOMP] = UBYTE_TO_CHAN( src[0] );
}
diff --git a/src/mesa/main/teximage.c b/src/mesa/main/teximage.c
index 2388ba3a5a..1b889292f8 100644
--- a/src/mesa/main/teximage.c
+++ b/src/mesa/main/teximage.c
@@ -199,103 +199,124 @@ _mesa_base_tex_format( GLcontext *ctx, GLint internalFormat )
case GL_RGBA12:
case GL_RGBA16:
return GL_RGBA;
- case GL_COLOR_INDEX:
- case GL_COLOR_INDEX1_EXT:
- case GL_COLOR_INDEX2_EXT:
- case GL_COLOR_INDEX4_EXT:
- case GL_COLOR_INDEX8_EXT:
- case GL_COLOR_INDEX12_EXT:
- case GL_COLOR_INDEX16_EXT:
- if (ctx->Extensions.EXT_paletted_texture)
+ default:
+ ; /* fallthrough */
+ }
+
+ if (ctx->Extensions.EXT_paletted_texture) {
+ switch (internalFormat) {
+ case GL_COLOR_INDEX:
+ case GL_COLOR_INDEX1_EXT:
+ case GL_COLOR_INDEX2_EXT:
+ case GL_COLOR_INDEX4_EXT:
+ case GL_COLOR_INDEX8_EXT:
+ case GL_COLOR_INDEX12_EXT:
+ case GL_COLOR_INDEX16_EXT:
return GL_COLOR_INDEX;
- else
- return -1;
- case GL_DEPTH_COMPONENT:
- case GL_DEPTH_COMPONENT16_SGIX:
- case GL_DEPTH_COMPONENT24_SGIX:
- case GL_DEPTH_COMPONENT32_SGIX:
- if (ctx->Extensions.SGIX_depth_texture)
+ default:
+ ; /* fallthrough */
+ }
+ }
+
+ if (ctx->Extensions.SGIX_depth_texture) {
+ switch (internalFormat) {
+ case GL_DEPTH_COMPONENT:
+ case GL_DEPTH_COMPONENT16_SGIX:
+ case GL_DEPTH_COMPONENT24_SGIX:
+ case GL_DEPTH_COMPONENT32_SGIX:
return GL_DEPTH_COMPONENT;
- else
- return -1;
+ default:
+ ; /* fallthrough */
+ }
+ }
- /* GL_ARB_texture_compression */
- case GL_COMPRESSED_ALPHA:
- if (ctx->Extensions.ARB_texture_compression)
+ if (ctx->Extensions.ARB_texture_compression) {
+ switch (internalFormat) {
+ case GL_COMPRESSED_ALPHA:
return GL_ALPHA;
- else
- return -1;
- case GL_COMPRESSED_LUMINANCE:
- if (ctx->Extensions.ARB_texture_compression)
+ case GL_COMPRESSED_LUMINANCE:
return GL_LUMINANCE;
- else
- return -1;
- case GL_COMPRESSED_LUMINANCE_ALPHA:
- if (ctx->Extensions.ARB_texture_compression)
+ case GL_COMPRESSED_LUMINANCE_ALPHA:
return GL_LUMINANCE_ALPHA;
- else
- return -1;
- case GL_COMPRESSED_INTENSITY:
- if (ctx->Extensions.ARB_texture_compression)
+ case GL_COMPRESSED_INTENSITY:
return GL_INTENSITY;
- else
- return -1;
- case GL_COMPRESSED_RGB:
- if (ctx->Extensions.ARB_texture_compression)
+ case GL_COMPRESSED_RGB:
return GL_RGB;
- else
- return -1;
- case GL_COMPRESSED_RGBA:
- if (ctx->Extensions.ARB_texture_compression)
+ case GL_COMPRESSED_RGBA:
return GL_RGBA;
- else
- return -1;
- case GL_COMPRESSED_RGB_FXT1_3DFX:
- if (ctx->Extensions.TDFX_texture_compression_FXT1)
+ default:
+ ; /* fallthrough */
+ }
+ }
+
+ if (ctx->Extensions.TDFX_texture_compression_FXT1) {
+ switch (internalFormat) {
+ case GL_COMPRESSED_RGB_FXT1_3DFX:
return GL_RGB;
- else
- return -1;
- case GL_COMPRESSED_RGBA_FXT1_3DFX:
- if (ctx->Extensions.TDFX_texture_compression_FXT1)
+ case GL_COMPRESSED_RGBA_FXT1_3DFX:
return GL_RGBA;
- else
- return -1;
- case GL_COMPRESSED_RGB_S3TC_DXT1_EXT:
- if (ctx->Extensions.EXT_texture_compression_s3tc)
+ case GL_COMPRESSED_RGB_S3TC_DXT1_EXT:
return GL_RGB;
- else
- return -1;
- case GL_COMPRESSED_RGBA_S3TC_DXT1_EXT:
- case GL_COMPRESSED_RGBA_S3TC_DXT3_EXT:
- case GL_COMPRESSED_RGBA_S3TC_DXT5_EXT:
- if (ctx->Extensions.EXT_texture_compression_s3tc)
+ default:
+ ; /* fallthrough */
+ }
+ }
+
+ if (ctx->Extensions.EXT_texture_compression_s3tc) {
+ switch (internalFormat) {
+ case GL_COMPRESSED_RGBA_S3TC_DXT1_EXT:
+ case GL_COMPRESSED_RGBA_S3TC_DXT3_EXT:
+ case GL_COMPRESSED_RGBA_S3TC_DXT5_EXT:
return GL_RGBA;
- else
- return -1;
- case GL_RGB_S3TC:
- case GL_RGB4_S3TC:
- if (ctx->Extensions.S3_s3tc)
+ default:
+ ; /* fallthrough */
+ }
+ }
+
+ if (ctx->Extensions.S3_s3tc) {
+ switch (internalFormat) {
+ case GL_RGB_S3TC:
+ case GL_RGB4_S3TC:
return GL_RGB;
- else
- return -1;
- case GL_RGBA_S3TC:
- case GL_RGBA4_S3TC:
- if (ctx->Extensions.S3_s3tc)
+ case GL_RGBA_S3TC:
+ case GL_RGBA4_S3TC:
return GL_RGBA;
- else
- return -1;
-
- case GL_YCBCR_MESA:
- if (ctx->Extensions.MESA_ycbcr_texture)
- return GL_YCBCR_MESA;
- else
- return -1;
+ default:
+ ; /* fallthrough */
+ }
+ }
- /* XXX add float texture formats here */
+ if (ctx->Extensions.MESA_ycbcr_texture) {
+ if (internalFormat == GL_YCBCR_MESA)
+ return GL_YCBCR_MESA;
+ }
- default:
- return -1; /* error */
+ if (ctx->Extensions.ARB_texture_float) {
+ switch (internalFormat) {
+ case GL_ALPHA16F_ARB:
+ case GL_ALPHA32F_ARB:
+ return GL_ALPHA;
+ case GL_RGBA16F_ARB:
+ case GL_RGBA32F_ARB:
+ return GL_RGBA;
+ case GL_RGB16F_ARB:
+ case GL_RGB32F_ARB:
+ return GL_RGB;
+ case GL_INTENSITY16F_ARB:
+ case GL_INTENSITY32F_ARB:
+ return GL_INTENSITY;
+ case GL_LUMINANCE16F_ARB:
+ case GL_LUMINANCE32F_ARB:
+ return GL_LUMINANCE;
+ case GL_LUMINANCE_ALPHA16F_ARB:
+ case GL_LUMINANCE_ALPHA32F_ARB:
+ return GL_LUMINANCE_ALPHA;
+ default:
+ ; /* nothing */
+ }
}
+
+ return -1; /* error */
}
@@ -351,7 +372,19 @@ is_color_format(GLenum internalFormat)
case GL_RGB10_A2:
case GL_RGBA12:
case GL_RGBA16:
- /* XXX add float texture formats here */
+ /* float texture formats */
+ case GL_ALPHA16F_ARB:
+ case GL_ALPHA32F_ARB:
+ case GL_LUMINANCE16F_ARB:
+ case GL_LUMINANCE32F_ARB:
+ case GL_LUMINANCE_ALPHA16F_ARB:
+ case GL_LUMINANCE_ALPHA32F_ARB:
+ case GL_INTENSITY16F_ARB:
+ case GL_INTENSITY32F_ARB:
+ case GL_RGB16F_ARB:
+ case GL_RGB32F_ARB:
+ case GL_RGBA16F_ARB:
+ case GL_RGBA32F_ARB:
return GL_TRUE;
case GL_YCBCR_MESA: /* not considered to be RGB */
default:
@@ -1241,7 +1274,7 @@ texture_error_check( GLcontext *ctx, GLenum target,
}
/* Check incoming image format and type */
- if (!_mesa_is_legal_format_and_type(format, type)) {
+ if (!_mesa_is_legal_format_and_type(ctx, format, type)) {
/* Yes, generate GL_INVALID_OPERATION, not GL_INVALID_ENUM, if there
* is a type/format mismatch. See 1.2 spec page 94, sec 3.6.4.
*/
@@ -1449,7 +1482,7 @@ subtexture_error_check( GLcontext *ctx, GLuint dimensions,
}
}
- if (!_mesa_is_legal_format_and_type(format, type)) {
+ if (!_mesa_is_legal_format_and_type(ctx, format, type)) {
_mesa_error(ctx, GL_INVALID_ENUM,
"glTexSubImage%dD(format or type)", dimensions);
return GL_TRUE;
diff --git a/src/mesa/main/texstate.c b/src/mesa/main/texstate.c
index a926ff135b..38dd4442a7 100644
--- a/src/mesa/main/texstate.c
+++ b/src/mesa/main/texstate.c
@@ -2,7 +2,7 @@
* Mesa 3-D graphics library
* Version: 6.1
*
- * Copyright (C) 1999-2003 Brian Paul All Rights Reserved.
+ * Copyright (C) 1999-2004 Brian Paul All Rights Reserved.
*
* Permission is hereby granted, free of charge, to any person obtaining a
* copy of this software and associated documentation files (the "Software"),
@@ -1794,6 +1794,70 @@ _mesa_GetTexLevelParameteriv( GLenum target, GLint level,
}
return;
+ /* GL_ARB_texture_float */
+ case GL_TEXTURE_RED_TYPE_ARB:
+ if (ctx->Extensions.ARB_texture_float) {
+ *params = img->TexFormat->RedBits ? img->TexFormat->DataType : GL_NONE;
+ }
+ else {
+ _mesa_error(ctx, GL_INVALID_ENUM,
+ "glGetTexLevelParameter[if]v(pname)");
+ }
+ return;
+ case GL_TEXTURE_GREEN_TYPE_ARB:
+ if (ctx->Extensions.ARB_texture_float) {
+ *params = img->TexFormat->GreenBits ? img->TexFormat->DataType : GL_NONE;
+ }
+ else {
+ _mesa_error(ctx, GL_INVALID_ENUM,
+ "glGetTexLevelParameter[if]v(pname)");
+ }
+ return;
+ case GL_TEXTURE_BLUE_TYPE_ARB:
+ if (ctx->Extensions.ARB_texture_float) {
+ *params = img->TexFormat->BlueBits ? img->TexFormat->DataType : GL_NONE;
+ }
+ else {
+ _mesa_error(ctx, GL_INVALID_ENUM,
+ "glGetTexLevelParameter[if]v(pname)");
+ }
+ return;
+ case GL_TEXTURE_ALPHA_TYPE_ARB:
+ if (ctx->Extensions.ARB_texture_float) {
+ *params = img->TexFormat->AlphaBits ? img->TexFormat->DataType : GL_NONE;
+ }
+ else {
+ _mesa_error(ctx, GL_INVALID_ENUM,
+ "glGetTexLevelParameter[if]v(pname)");
+ }
+ return;
+ case GL_TEXTURE_LUMINANCE_TYPE_ARB:
+ if (ctx->Extensions.ARB_texture_float) {
+ *params = img->TexFormat->LuminanceBits ? img->TexFormat->DataType : GL_NONE;
+ }
+ else {
+ _mesa_error(ctx, GL_INVALID_ENUM,
+ "glGetTexLevelParameter[if]v(pname)");
+ }
+ return;
+ case GL_TEXTURE_INTENSITY_TYPE_ARB:
+ if (ctx->Extensions.ARB_texture_float) {
+ *params = img->TexFormat->IntensityBits ? img->TexFormat->DataType : GL_NONE;
+ }
+ else {
+ _mesa_error(ctx, GL_INVALID_ENUM,
+ "glGetTexLevelParameter[if]v(pname)");
+ }
+ return;
+ case GL_TEXTURE_DEPTH_TYPE_ARB:
+ if (ctx->Extensions.ARB_texture_float) {
+ *params = img->TexFormat->DepthBits ? img->TexFormat->DataType : GL_NONE;
+ }
+ else {
+ _mesa_error(ctx, GL_INVALID_ENUM,
+ "glGetTexLevelParameter[if]v(pname)");
+ }
+ return;
default:
_mesa_error(ctx, GL_INVALID_ENUM,
"glGetTexLevelParameter[if]v(pname)");
diff --git a/src/mesa/main/texstore.c b/src/mesa/main/texstore.c
index 4ed7d38beb..cd23f3c77d 100644
--- a/src/mesa/main/texstore.c
+++ b/src/mesa/main/texstore.c
@@ -66,6 +66,1578 @@
#include "texutil.h"
+
+/*** NEWTEXSTORE ***********************************************************/
+
+static const GLint ZERO = 1000, ONE = 1001;
+
+/**
+ * When promoting texture formats (see below) we need to compute the
+ * mapping of dest components back to source components.
+ * This function does that.
+ * \param logicalBaseFormat the logical format of the texture
+ * \param textureBaseFormat the final texture format
+ * \return map[4] the four mapping values
+ */
+static void
+compute_component_mapping(GLenum logicalBaseFormat, GLenum textureBaseFormat,
+ GLint map[4])
+{
+ /* compute mapping from dest components back to src components */
+ switch (logicalBaseFormat) {
+ case GL_LUMINANCE:
+ map[0] = map[1] = map[2] = 0;
+ if (textureBaseFormat == GL_RGBA)
+ map[3] = ONE;
+ break;
+ case GL_ALPHA:
+ ASSERT(textureBaseFormat == GL_RGBA);
+ map[0] = map[1] = map[2] = ZERO;
+ map[3] = 0;
+ break;
+ case GL_INTENSITY:
+ map[0] = map[1] = map[2] = 0;
+ if (textureBaseFormat == GL_RGBA)
+ map[3] = 0;
+ break;
+ case GL_LUMINANCE_ALPHA:
+ ASSERT(textureBaseFormat == GL_RGBA);
+ map[0] = map[1] = map[2] = 0;
+ map[3] = 1;
+ break;
+ case GL_RGB:
+ ASSERT(textureBaseFormat == GL_RGBA);
+ map[0] = 0;
+ map[1] = 1;
+ map[2] = 2;
+ map[3] = ONE;
+ break;
+ default:
+ _mesa_problem(NULL, "Unexpected logicalBaseFormat");
+ map[0] = map[1] = map[2] = map[3] = 0;
+ }
+}
+
+
+/**
+ * Make a temporary (color) texture image with GLfloat components.
+ * Apply all needed pixel unpacking and pixel transfer operations.
+ * Note that there are both logicalBaseFormat and textureBaseFormat parameters.
+ * Suppose the user specifies GL_LUMINANCE as the internal texture format
+ * but the graphics hardware doesn't support luminance textures. So, might
+ * use an RGB hardware format instead.
+ * If logicalBaseFormat != textureBaseFormat we have some extra work to do.
+ *
+ * \param ctx the rendering context
+ * \param dims image dimensions: 1, 2 or 3
+ * \param logicalBaseFormat basic texture derived from the user's
+ * internal texture format value
+ * \param textureBaseFormat the actual basic format of the texture
+ * \param srcWidth source image width
+ * \param srcHeight source image height
+ * \param srcDepth source image depth
+ * \param srcFormat source image format
+ * \param srcType source image type
+ * \param srcAddr source image address
+ * \param srcPacking source image pixel packing
+ * \return resulting image with format = textureBaseFormat and type = GLfloat.
+ */
+static GLfloat *
+make_temp_float_image(GLcontext *ctx, GLuint dims,
+ GLenum logicalBaseFormat,
+ GLenum textureBaseFormat,
+ GLint srcWidth, GLint srcHeight, GLint srcDepth,
+ GLenum srcFormat, GLenum srcType,
+ const GLvoid *srcAddr,
+ const struct gl_pixelstore_attrib *srcPacking)
+{
+ GLuint transferOps = ctx->_ImageTransferState;
+ GLfloat *tempImage;
+
+ ASSERT(dims >= 1 && dims <= 3);
+
+ ASSERT(logicalBaseFormat == GL_RGBA ||
+ logicalBaseFormat == GL_RGB ||
+ logicalBaseFormat == GL_LUMINANCE_ALPHA ||
+ logicalBaseFormat == GL_LUMINANCE ||
+ logicalBaseFormat == GL_ALPHA ||
+ logicalBaseFormat == GL_INTENSITY ||
+ logicalBaseFormat == GL_COLOR_INDEX ||
+ logicalBaseFormat == GL_DEPTH_COMPONENT);
+
+ ASSERT(textureBaseFormat == GL_RGBA ||
+ textureBaseFormat == GL_RGB ||
+ textureBaseFormat == GL_LUMINANCE_ALPHA ||
+ textureBaseFormat == GL_LUMINANCE ||
+ textureBaseFormat == GL_ALPHA ||
+ textureBaseFormat == GL_INTENSITY ||
+ textureBaseFormat == GL_COLOR_INDEX ||
+ textureBaseFormat == GL_DEPTH_COMPONENT);
+
+ /* conventional color image */
+
+ if ((dims == 1 && ctx->Pixel.Convolution1DEnabled) ||
+ (dims >= 2 && ctx->Pixel.Convolution2DEnabled) ||
+ (dims >= 2 && ctx->Pixel.Separable2DEnabled)) {
+ /* need image convolution */
+ const GLuint preConvTransferOps
+ = (transferOps & IMAGE_PRE_CONVOLUTION_BITS) | IMAGE_CLAMP_BIT;
+ const GLuint postConvTransferOps
+ = (transferOps & IMAGE_POST_CONVOLUTION_BITS) | IMAGE_CLAMP_BIT;
+ GLint img, row;
+ GLint convWidth, convHeight;
+ GLfloat *convImage;
+
+ /* pre-convolution image buffer (3D) */
+ tempImage = (GLfloat *) _mesa_malloc(srcWidth * srcHeight * srcDepth
+ * 4 * sizeof(GLfloat));
+ if (!tempImage)
+ return NULL;
+
+ /* post-convolution image buffer (2D) */
+ convImage = (GLfloat *) _mesa_malloc(srcWidth * srcHeight
+ * 4 * sizeof(GLfloat));
+ if (!convImage) {
+ _mesa_free(tempImage);
+ return NULL;
+ }
+
+ /* loop over 3D image slices */
+ for (img = 0; img < srcDepth; img++) {
+ GLfloat *dst = tempImage + img * (srcWidth * srcHeight * 4);
+
+ /* unpack and do transfer ops up to convolution */
+ for (row = 0; row < srcHeight; row++) {
+ const GLvoid *src = _mesa_image_address(srcPacking,
+ srcAddr, srcWidth, srcHeight,
+ srcFormat, srcType, img, row, 0);
+ _mesa_unpack_color_span_float(ctx, srcWidth, GL_RGBA, dst,
+ srcFormat, srcType, src,
+ srcPacking,
+ preConvTransferOps);
+ dst += srcWidth * 4;
+ }
+
+ /* do convolution */
+ {
+ GLfloat *src = tempImage + img * (srcWidth * srcHeight * 4);
+ convWidth = srcWidth;
+ convHeight = srcHeight;
+ if (dims == 1) {
+ ASSERT(ctx->Pixel.Convolution1DEnabled);
+ _mesa_convolve_1d_image(ctx, &convWidth, src, convImage);
+ }
+ else {
+ if (ctx->Pixel.Convolution2DEnabled) {
+ _mesa_convolve_2d_image(ctx, &convWidth, &convHeight,
+ src, convImage);
+ }
+ else {
+ ASSERT(ctx->Pixel.Separable2DEnabled);
+ _mesa_convolve_sep_image(ctx, &convWidth, &convHeight,
+ src, convImage);
+ }
+ }
+ }
+
+ /* do post-convolution transfer and pack into tempImage */
+ {
+ const GLfloat *src = convImage;
+ GLfloat *dst = tempImage + img * (convWidth * convHeight * 4);
+ for (row = 0; row < convHeight; row++) {
+ _mesa_pack_rgba_span_float(ctx, convWidth,
+ (const GLfloat (*)[4]) src,
+ logicalBaseFormat, GL_FLOAT,
+ dst, &ctx->DefaultPacking,
+ postConvTransferOps);
+ src += convWidth * 4;
+ dst += convWidth * 4;
+ }
+ }
+ } /* loop over 3D image slices */
+
+ _mesa_free(convImage);
+
+ /* might need these below */
+ srcWidth = convWidth;
+ srcHeight = convHeight;
+ }
+ else {
+ /* no convolution */
+ const GLint components = _mesa_components_in_format(logicalBaseFormat);
+ const GLint srcStride = _mesa_image_row_stride(srcPacking,
+ srcWidth, srcFormat, srcType);
+ GLfloat *dst;
+ GLint img, row;
+
+ tempImage = (GLfloat *) _mesa_malloc(srcWidth * srcHeight * srcDepth
+ * components * sizeof(GLfloat));
+ if (!tempImage)
+ return NULL;
+
+ dst = tempImage;
+ for (img = 0; img < srcDepth; img++) {
+ const GLubyte *src
+ = (const GLubyte *) _mesa_image_address(srcPacking, srcAddr,
+ srcWidth, srcHeight,
+ srcFormat, srcType,
+ img, 0, 0);
+ for (row = 0; row < srcHeight; row++) {
+ _mesa_unpack_color_span_float(ctx, srcWidth, logicalBaseFormat,
+ dst, srcFormat, srcType, src,
+ srcPacking, transferOps);
+ dst += srcWidth * components;
+ src += srcStride;
+ }
+ }
+ }
+
+ if (logicalBaseFormat != textureBaseFormat) {
+ /* more work */
+ GLint texComponents = _mesa_components_in_format(textureBaseFormat);
+ GLint logComponents = _mesa_components_in_format(logicalBaseFormat);
+ GLfloat *newImage;
+ GLint i, n;
+ GLint map[4];
+
+ /* we only promote up to RGB and RGBA formats for now */
+ ASSERT(textureBaseFormat == GL_RGB || textureBaseFormat == GL_RGBA);
+
+ /* The actual texture format should have at least as many components
+ * as the logical texture format.
+ */
+ ASSERT(texComponents >= logComponents);
+
+ newImage = (GLfloat *) _mesa_malloc(srcWidth * srcHeight * srcDepth
+ * texComponents * sizeof(GLfloat));
+ if (!newImage) {
+ _mesa_free(tempImage);
+ return NULL;
+ }
+
+ compute_component_mapping(logicalBaseFormat, textureBaseFormat, map);
+
+ n = srcWidth * srcHeight * srcDepth;
+ for (i = 0; i < n; i++) {
+ GLint k;
+ for (k = 0; k < texComponents; k++) {
+ GLint j = map[k];
+ if (j == ZERO)
+ newImage[i * texComponents + k] = 0.0F;
+ else if (j == ONE)
+ newImage[i * texComponents + k] = 1.0F;
+ else
+ newImage[i * texComponents + k] = tempImage[i * logComponents + j];
+ }
+ }
+
+ _mesa_free(tempImage);
+ tempImage = newImage;
+ }
+
+ return tempImage;
+}
+
+
+/**
+ * Make a temporary (color) texture image with GLchan components.
+ * Apply all needed pixel unpacking and pixel transfer operations.
+ * Note that there are both logicalBaseFormat and textureBaseFormat parameters.
+ * Suppose the user specifies GL_LUMINANCE as the internal texture format
+ * but the graphics hardware doesn't support luminance textures. So, might
+ * use an RGB hardware format instead.
+ * If logicalBaseFormat != textureBaseFormat we have some extra work to do.
+ *
+ * \param ctx the rendering context
+ * \param dims image dimensions: 1, 2 or 3
+ * \param logicalBaseFormat basic texture derived from the user's
+ * internal texture format value
+ * \param textureBaseFormat the actual basic format of the texture
+ * \param srcWidth source image width
+ * \param srcHeight source image height
+ * \param srcDepth source image depth
+ * \param srcFormat source image format
+ * \param srcType source image type
+ * \param srcAddr source image address
+ * \param srcPacking source image pixel packing
+ * \return resulting image with format = textureBaseFormat and type = GLchan.
+ */
+static GLchan *
+make_temp_chan_image(GLcontext *ctx, GLuint dims,
+ GLenum logicalBaseFormat,
+ GLenum textureBaseFormat,
+ GLint srcWidth, GLint srcHeight, GLint srcDepth,
+ GLenum srcFormat, GLenum srcType,
+ const GLvoid *srcAddr,
+ const struct gl_pixelstore_attrib *srcPacking)
+{
+ GLuint transferOps = ctx->_ImageTransferState;
+ const GLint components = _mesa_components_in_format(logicalBaseFormat);
+ GLboolean freeSrcImage = GL_FALSE;
+ GLint img, row;
+ GLchan *tempImage, *dst;
+
+ ASSERT(dims >= 1 && dims <= 3);
+
+ ASSERT(logicalBaseFormat == GL_RGBA ||
+ logicalBaseFormat == GL_RGB ||
+ logicalBaseFormat == GL_LUMINANCE_ALPHA ||
+ logicalBaseFormat == GL_LUMINANCE ||
+ logicalBaseFormat == GL_ALPHA ||
+ logicalBaseFormat == GL_INTENSITY);
+
+ ASSERT(textureBaseFormat == GL_RGBA ||
+ textureBaseFormat == GL_RGB ||
+ textureBaseFormat == GL_LUMINANCE_ALPHA ||
+ textureBaseFormat == GL_LUMINANCE ||
+ textureBaseFormat == GL_ALPHA ||
+ textureBaseFormat == GL_INTENSITY);
+
+ if ((dims == 1 && ctx->Pixel.Convolution1DEnabled) ||
+ (dims >= 2 && ctx->Pixel.Convolution2DEnabled) ||
+ (dims >= 2 && ctx->Pixel.Separable2DEnabled)) {
+ /* get convolved image */
+ GLfloat *convImage = make_temp_float_image(ctx, dims,
+ logicalBaseFormat,
+ logicalBaseFormat,
+ srcWidth, srcHeight, srcDepth,
+ srcFormat, srcType,
+ srcAddr, srcPacking);
+ if (!convImage)
+ return NULL;
+ /* the convolved image is our new source image */
+ srcAddr = convImage;
+ srcFormat = logicalBaseFormat;
+ srcType = GL_FLOAT;
+ srcPacking = &ctx->DefaultPacking;
+ _mesa_adjust_image_for_convolution(ctx, dims, &srcWidth, &srcHeight);
+ transferOps = 0;
+ freeSrcImage = GL_TRUE;
+ }
+
+ /* unpack and transfer the source image */
+ tempImage = (GLchan *) _mesa_malloc(srcWidth * srcHeight * srcDepth
+ * components * sizeof(GLchan));
+ if (!tempImage)
+ return NULL;
+
+ dst = tempImage;
+ for (img = 0; img < srcDepth; img++) {
+ const GLint srcStride = _mesa_image_row_stride(srcPacking,
+ srcWidth, srcFormat,
+ srcType);
+ const GLubyte *src
+ = (const GLubyte *) _mesa_image_address(srcPacking, srcAddr,
+ srcWidth, srcHeight,
+ srcFormat, srcType,
+ img, 0, 0);
+ for (row = 0; row < srcHeight; row++) {
+ _mesa_unpack_color_span_chan(ctx, srcWidth, logicalBaseFormat,
+ dst, srcFormat, srcType, src,
+ srcPacking, transferOps);
+ dst += srcWidth * components;
+ src += srcStride;
+ }
+ }
+
+ /* If we made a temporary image for convolution, free it here */
+ if (freeSrcImage) {
+ _mesa_free((void *) srcAddr);
+ }
+
+ if (logicalBaseFormat != textureBaseFormat) {
+ /* one more conversion step */
+ GLint texComponents = _mesa_components_in_format(textureBaseFormat);
+ GLint logComponents = _mesa_components_in_format(logicalBaseFormat);
+ GLchan *newImage;
+ GLint i, n;
+ GLint map[4];
+
+ /* we only promote up to RGB and RGBA formats for now */
+ ASSERT(textureBaseFormat == GL_RGB || textureBaseFormat == GL_RGBA);
+
+ /* The actual texture format should have at least as many components
+ * as the logical texture format.
+ */
+ ASSERT(texComponents >= logComponents);
+
+ newImage = (GLchan *) _mesa_malloc(srcWidth * srcHeight * srcDepth
+ * texComponents * sizeof(GLchan));
+ if (!newImage) {
+ _mesa_free(tempImage);
+ return NULL;
+ }
+
+ compute_component_mapping(logicalBaseFormat, textureBaseFormat, map);
+
+ n = srcWidth * srcHeight * srcDepth;
+ for (i = 0; i < n; i++) {
+ GLint k;
+ for (k = 0; k < texComponents; k++) {
+ GLint j = map[k];
+ if (j == ZERO)
+ newImage[i * texComponents + k] = 0;
+ else if (j == ONE)
+ newImage[i * texComponents + k] = CHAN_MAX;
+ else
+ newImage[i * texComponents + k] = tempImage[i * logComponents + j];
+ }
+ }
+
+ _mesa_free(tempImage);
+ tempImage = newImage;
+ }
+
+ return tempImage;
+}
+
+
+
+/**
+ * Teximage storage routine for when a simple memcpy will do.
+ * No pixel transfer operations or special texel encodings allowed.
+ * 1D, 2D and 3D images supported.
+ */
+static void
+memcpy_texture(const struct gl_texture_format *dstFormat,
+ GLvoid *dstAddr,
+ GLint dstXoffset, GLint dstYoffset, GLint dstZoffset,
+ GLint dstRowStride, GLint dstImageStride,
+ GLint srcWidth, GLint srcHeight, GLint srcDepth,
+ GLenum srcFormat, GLenum srcType,
+ const GLvoid *srcAddr,
+ const struct gl_pixelstore_attrib *srcPacking)
+{
+ const GLint srcRowStride = _mesa_image_row_stride(srcPacking, srcWidth,
+ srcFormat, srcType);
+ const GLint srcImageStride = _mesa_image_image_stride(srcPacking,
+ srcWidth, srcHeight, srcFormat, srcType);
+ const GLubyte *srcImage = (const GLubyte *) _mesa_image_address(srcPacking,
+ srcAddr, srcWidth, srcHeight, srcFormat, srcType, 0, 0, 0);
+ const GLint bytesPerRow = srcWidth * dstFormat->TexelBytes;
+ const GLint bytesPerImage = srcHeight * bytesPerRow;
+ const GLint bytesPerTexture = srcDepth * bytesPerImage;
+ GLubyte *dstImage = (GLubyte *) dstAddr
+ + dstZoffset * dstImageStride
+ + dstYoffset * dstRowStride
+ + dstXoffset * dstFormat->TexelBytes;
+
+ if (dstRowStride == srcRowStride &&
+ dstRowStride == bytesPerRow &&
+ ((dstImageStride == srcImageStride &&
+ dstImageStride == bytesPerImage) ||
+ (srcDepth == 1))) {
+ /* one big memcpy */
+ _mesa_memcpy(dstImage, srcImage, bytesPerTexture);
+ }
+ else {
+ GLint img, row;
+ for (img = 0; img < srcDepth; img++) {
+ const GLubyte *srcRow = srcImage;
+ GLubyte *dstRow = dstImage;
+ for (row = 0; row < srcHeight; row++) {
+ _mesa_memcpy(dstRow, srcRow, bytesPerRow);
+ dstRow += dstRowStride;
+ srcRow += srcRowStride;
+ }
+ srcImage += srcImageStride;
+ dstImage += dstImageStride;
+ }
+ }
+}
+
+
+
+/**
+ * Store an image in any of the formats:
+ * _mesa_texformat_rgba
+ * _mesa_texformat_rgb
+ * _mesa_texformat_alpha
+ * _mesa_texformat_luminance
+ * _mesa_texformat_luminance_alpha
+ * _mesa_texformat_intensity
+ *
+ * \param dims either 1 or 2 or 3
+ * \param baseInternalFormat user-specified base internal format
+ * \param dstFormat destination Mesa texture format
+ * \param dstAddr destination image address
+ * \param dstX/Y/Zoffset destination x/y/z offset (ala TexSubImage), in texels
+ * \param dstRowStride destination image row stride, in bytes
+ * \param dstImageStride destination image layer stride, in bytes
+ * \param srcWidth/Height/Depth source image size, in pixels
+ * \param srcFormat incoming image format
+ * \param srcType incoming image data type
+ * \param srcAddr source image address
+ * \param srcPacking source image packing parameters
+ */
+GLboolean
+_mesa_texstore_rgba(GLcontext *ctx, GLuint dims,
+ GLenum baseInternalFormat,
+ const struct gl_texture_format *dstFormat,
+ GLvoid *dstAddr,
+ GLint dstXoffset, GLint dstYoffset, GLint dstZoffset,
+ GLint dstRowStride, GLint dstImageStride,
+ GLint srcWidth, GLint srcHeight, GLint srcDepth,
+ GLenum srcFormat, GLenum srcType,
+ const GLvoid *srcAddr,
+ const struct gl_pixelstore_attrib *srcPacking)
+{
+ const GLint components = _mesa_components_in_format(baseInternalFormat);
+
+ ASSERT(dstFormat == &_mesa_texformat_rgba ||
+ dstFormat == &_mesa_texformat_rgb ||
+ dstFormat == &_mesa_texformat_alpha ||
+ dstFormat == &_mesa_texformat_luminance ||
+ dstFormat == &_mesa_texformat_luminance_alpha ||
+ dstFormat == &_mesa_texformat_intensity);
+ ASSERT(baseInternalFormat == GL_RGBA ||
+ baseInternalFormat == GL_RGB ||
+ baseInternalFormat == GL_ALPHA ||
+ baseInternalFormat == GL_LUMINANCE ||
+ baseInternalFormat == GL_LUMINANCE_ALPHA ||
+ baseInternalFormat == GL_INTENSITY);
+ ASSERT(dstFormat->TexelBytes == components * sizeof(GLchan));
+
+ if (!ctx->_ImageTransferState &&
+ !srcPacking->SwapBytes &&
+ baseInternalFormat == srcFormat &&
+ srcType == CHAN_TYPE) {
+ /* simple memcpy path */
+ memcpy_texture(dstFormat, dstAddr, dstXoffset, dstYoffset, dstZoffset,
+ dstRowStride, dstImageStride,
+ srcWidth, srcHeight, srcDepth, srcFormat, srcType,
+ srcAddr, srcPacking);
+ }
+ else if (!ctx->_ImageTransferState &&
+ !srcPacking->SwapBytes &&
+ dstFormat == &_mesa_texformat_rgb &&
+ srcFormat == GL_RGBA &&
+ srcType == CHAN_TYPE) {
+ /* extract RGB from RGBA */
+ int img, row, col;
+ GLchan *dstImage = (GLchan *) (GLubyte *) dstAddr
+ + dstZoffset * dstImageStride
+ + dstYoffset * dstRowStride
+ + dstXoffset * dstFormat->TexelBytes;
+ for (img = 0; img < srcDepth; img++) {
+ const GLint srcRowStride = _mesa_image_row_stride(srcPacking,
+ srcWidth, srcFormat, srcType);
+ GLchan *srcRow = _mesa_image_address(srcPacking, srcAddr, srcWidth,
+ srcHeight, srcFormat, srcType,
+ img, 0, 0);
+ GLchan *dstRow = dstImage;
+ for (row = 0; row < srcHeight; row++) {
+ for (col = 0; col < srcWidth; col++) {
+ dstRow[col * 3 + RCOMP] = srcRow[col * 4 + RCOMP];
+ dstRow[col * 3 + GCOMP] = srcRow[col * 4 + GCOMP];
+ dstRow[col * 3 + BCOMP] = srcRow[col * 4 + BCOMP];
+ }
+ dstRow += dstRowStride;
+ srcRow = (GLchan *) ((GLubyte *) srcRow + srcRowStride);
+ }
+ dstImage += dstImageStride;
+ }
+ }
+ else {
+ /* general path */
+ const GLchan *tempImage = make_temp_chan_image(ctx, dims,
+ baseInternalFormat,
+ dstFormat->BaseFormat,
+ srcWidth, srcHeight, srcDepth,
+ srcFormat, srcType, srcAddr,
+ srcPacking);
+ const GLchan *src = tempImage;
+ const GLint bytesPerRow = srcWidth * components * sizeof(GLchan);
+ GLubyte *dstImage = (GLubyte *) dstAddr
+ + dstZoffset * dstImageStride
+ + dstYoffset * dstRowStride
+ + dstXoffset * dstFormat->TexelBytes;
+ GLint img, row;
+ if (!tempImage)
+ return GL_FALSE;
+ _mesa_adjust_image_for_convolution(ctx, dims, &srcWidth, &srcHeight);
+ for (img = 0; img < srcDepth; img++) {
+ GLubyte *dstRow = dstImage;
+ for (row = 0; row < srcHeight; row++) {
+ _mesa_memcpy(dstRow, src, bytesPerRow);
+ dstRow += dstRowStride;
+ src += srcWidth * components;
+ }
+ dstImage += dstImageStride;
+ }
+
+ _mesa_free((void *) tempImage);
+ }
+ return GL_TRUE;
+}
+
+
+/**
+ * Store a color index texture image
+ */
+GLboolean
+_mesa_texstore_color_index(STORE_PARAMS)
+{
+ ASSERT(dstFormat == &_mesa_texformat_color_index);
+ ASSERT(dstFormat->TexelBytes == 1 * sizeof(GLchan));
+
+ if (!ctx->_ImageTransferState &&
+ !srcPacking->SwapBytes &&
+ baseInternalFormat == GL_COLOR_INDEX &&
+ srcFormat == GL_COLOR_INDEX &&
+ srcType == CHAN_TYPE) {
+ /* simple memcpy path */
+ memcpy_texture(dstFormat, dstAddr, dstXoffset, dstYoffset, dstZoffset,
+ dstRowStride, dstImageStride,
+ srcWidth, srcHeight, srcDepth, srcFormat, srcType,
+ srcAddr, srcPacking);
+ }
+ else {
+ /* general path */
+ GLubyte *dstImage = (GLubyte *) dstAddr
+ + dstZoffset * dstImageStride
+ + dstYoffset * dstRowStride
+ + dstXoffset * dstFormat->TexelBytes;
+ GLint img, row;
+ for (img = 0; img < srcDepth; img++) {
+ GLubyte *dstRow = dstImage;
+ for (row = 0; row < srcHeight; row++) {
+ const GLvoid *src = _mesa_image_address(srcPacking,
+ srcAddr, srcWidth, srcHeight, srcFormat, srcType, img, row, 0);
+ _mesa_unpack_index_span(ctx, srcWidth, CHAN_TYPE, dstRow,
+ srcType, src, srcPacking,
+ ctx->_ImageTransferState);
+ dstRow += dstRowStride;
+ }
+ dstImage += dstImageStride;
+ }
+ }
+ return GL_TRUE;
+}
+
+
+/**
+ * Store a floating point depth component texture image.
+ */
+GLboolean
+_mesa_texstore_depth_component_float32(STORE_PARAMS)
+{
+ ASSERT(dstFormat == &_mesa_texformat_depth_component_float32);
+ ASSERT(dstFormat->TexelBytes == sizeof(GLfloat));
+
+ if (!ctx->_ImageTransferState &&
+ !srcPacking->SwapBytes &&
+ baseInternalFormat == GL_DEPTH_COMPONENT &&
+ srcFormat == GL_DEPTH_COMPONENT &&
+ srcType == GL_FLOAT) {
+ /* simple memcpy path */
+ memcpy_texture(dstFormat, dstAddr, dstXoffset, dstYoffset, dstZoffset,
+ dstRowStride, dstImageStride,
+ srcWidth, srcHeight, srcDepth, srcFormat, srcType,
+ srcAddr, srcPacking);
+ }
+ else {
+ /* general path */
+ GLubyte *dstImage = (GLubyte *) dstAddr
+ + dstZoffset * dstImageStride
+ + dstYoffset * dstRowStride
+ + dstXoffset * dstFormat->TexelBytes;
+ GLint img, row;
+ for (img = 0; img < srcDepth; img++) {
+ GLubyte *dstRow = dstImage;
+ for (row = 0; row < srcHeight; row++) {
+ const GLvoid *src = _mesa_image_address(srcPacking,
+ srcAddr, srcWidth, srcHeight, srcFormat, srcType, img, row, 0);
+ _mesa_unpack_depth_span(ctx, srcWidth, (GLfloat *) dstRow,
+ srcType, src, srcPacking);
+ dstRow += dstRowStride;
+ }
+ dstImage += dstImageStride;
+ }
+ }
+ return GL_TRUE;
+}
+
+
+/**
+ * Store a 16-bit integer depth component texture image.
+ */
+GLboolean
+_mesa_texstore_depth_component16(STORE_PARAMS)
+{
+ ASSERT(dstFormat == &_mesa_texformat_depth_component16);
+ ASSERT(dstFormat->TexelBytes == sizeof(GLushort));
+
+ if (!ctx->_ImageTransferState &&
+ !srcPacking->SwapBytes &&
+ baseInternalFormat == GL_DEPTH_COMPONENT &&
+ srcFormat == GL_DEPTH_COMPONENT &&
+ srcType == GL_UNSIGNED_SHORT) {
+ /* simple memcpy path */
+ memcpy_texture(dstFormat, dstAddr, dstXoffset, dstYoffset, dstZoffset,
+ dstRowStride, dstImageStride,
+ srcWidth, srcHeight, srcDepth, srcFormat, srcType,
+ srcAddr, srcPacking);
+ }
+ else {
+ /* general path */
+ GLubyte *dstImage = (GLubyte *) dstAddr
+ + dstZoffset * dstImageStride
+ + dstYoffset * dstRowStride
+ + dstXoffset * dstFormat->TexelBytes;
+ GLint img, row, col;
+ for (img = 0; img < srcDepth; img++) {
+ GLubyte *dstRow = dstImage;
+ for (row = 0; row < srcHeight; row++) {
+ GLfloat depthTemp[MAX_WIDTH];
+ const GLvoid *src = _mesa_image_address(srcPacking,
+ srcAddr, srcWidth, srcHeight, srcFormat, srcType, img, row, 0);
+ GLushort *dst16 = (GLushort *) dstRow;
+ _mesa_unpack_depth_span(ctx, srcWidth, depthTemp,
+ srcType, src, srcPacking);
+ for (col = 0; col < srcWidth; col++) {
+ dst16[col] = (GLushort) (depthTemp[col] * 65535.0F);
+ }
+ dstRow += dstRowStride;
+ }
+ dstImage += dstImageStride;
+ }
+ }
+ return GL_TRUE;
+}
+
+
+
+
+/**
+ * Store an rgb565 texture image.
+ */
+GLboolean
+_mesa_texstore_rgb565(STORE_PARAMS)
+{
+ ASSERT(dstFormat == &_mesa_texformat_rgb565);
+ ASSERT(dstFormat->TexelBytes == 2);
+
+ if (!ctx->_ImageTransferState &&
+ !srcPacking->SwapBytes &&
+ baseInternalFormat == GL_RGB &&
+ srcFormat == GL_RGB &&
+ srcType == GL_UNSIGNED_SHORT_5_6_5) {
+ /* simple memcpy path */
+ memcpy_texture(dstFormat, dstAddr, dstXoffset, dstYoffset, dstZoffset,
+ dstRowStride, dstImageStride,
+ srcWidth, srcHeight, srcDepth, srcFormat, srcType,
+ srcAddr, srcPacking);
+ }
+ else if (!ctx->_ImageTransferState &&
+ !srcPacking->SwapBytes &&
+ baseInternalFormat == GL_RGB &&
+ srcFormat == GL_RGB &&
+ srcType == GL_UNSIGNED_BYTE &&
+ dims == 2) {
+ /* do optimized tex store */
+ const GLint srcRowStride = _mesa_image_row_stride(srcPacking, srcWidth,
+ srcFormat, srcType);
+ const GLubyte *src = (const GLubyte *)
+ _mesa_image_address(srcPacking, srcAddr, srcWidth, srcHeight,
+ srcFormat, srcType, 0, 0, 0);
+ GLubyte *dst = (GLubyte *) dstAddr
+ + dstZoffset * dstImageStride
+ + dstYoffset * dstRowStride
+ + dstXoffset * dstFormat->TexelBytes;
+ GLint row, col;
+ for (row = 0; row < srcHeight; row++) {
+ const GLubyte *srcUB = (const GLubyte *) src;
+ GLushort *dstUS = (GLushort *) dst;
+ for (col = 0; col < srcWidth; col++) {
+ dstUS[col] = PACK_COLOR_565( srcUB[0], srcUB[1], srcUB[2] );
+ srcUB += 3;
+ }
+ dst += dstRowStride;
+ src += srcRowStride;
+ }
+ }
+ else {
+ /* general path */
+ const GLchan *tempImage = make_temp_chan_image(ctx, dims,
+ baseInternalFormat,
+ dstFormat->BaseFormat,
+ srcWidth, srcHeight, srcDepth,
+ srcFormat, srcType, srcAddr,
+ srcPacking);
+ const GLchan *src = tempImage;
+ GLubyte *dstImage = (GLubyte *) dstAddr
+ + dstZoffset * dstImageStride
+ + dstYoffset * dstRowStride
+ + dstXoffset * dstFormat->TexelBytes;
+ GLint img, row, col;
+ if (!tempImage)
+ return GL_FALSE;
+ _mesa_adjust_image_for_convolution(ctx, dims, &srcWidth, &srcHeight);
+ for (img = 0; img < srcDepth; img++) {
+ GLubyte *dstRow = dstImage;
+ for (row = 0; row < srcHeight; row++) {
+ GLushort *dstUS = (GLushort *) dstRow;
+ for (col = 0; col < srcWidth; col++) {
+ dstUS[col] = PACK_COLOR_565( CHAN_TO_UBYTE(src[RCOMP]),
+ CHAN_TO_UBYTE(src[GCOMP]),
+ CHAN_TO_UBYTE(src[BCOMP]) );
+ src += 3;
+ }
+ dstRow += dstRowStride;
+ }
+ dstImage += dstImageStride;
+ }
+ _mesa_free((void *) tempImage);
+ }
+ return GL_TRUE;
+}
+
+
+GLboolean
+_mesa_texstore_rgba8888(STORE_PARAMS)
+{
+ const GLuint ui = 1;
+ const GLubyte littleEndian = *((const GLubyte *) &ui);
+
+ ASSERT(dstFormat == &_mesa_texformat_rgba8888);
+ ASSERT(dstFormat->TexelBytes == 4);
+
+ if (!ctx->_ImageTransferState &&
+ !srcPacking->SwapBytes &&
+ baseInternalFormat == GL_RGBA &&
+ srcFormat == GL_RGBA &&
+ ((srcType == GL_UNSIGNED_INT_8_8_8_8_REV && littleEndian) ||
+ (srcType == GL_UNSIGNED_INT_8_8_8_8 && !littleEndian))) {
+ /* simple memcpy path */
+ memcpy_texture(dstFormat, dstAddr, dstXoffset, dstYoffset, dstZoffset,
+ dstRowStride, dstImageStride,
+ srcWidth, srcHeight, srcDepth, srcFormat, srcType,
+ srcAddr, srcPacking);
+ }
+ else {
+ /* general path */
+ const GLchan *tempImage = make_temp_chan_image(ctx, dims,
+ baseInternalFormat,
+ dstFormat->BaseFormat,
+ srcWidth, srcHeight, srcDepth,
+ srcFormat, srcType, srcAddr,
+ srcPacking);
+ const GLchan *src = tempImage;
+ GLubyte *dstImage = (GLubyte *) dstAddr
+ + dstZoffset * dstImageStride
+ + dstYoffset * dstRowStride
+ + dstXoffset * dstFormat->TexelBytes;
+ GLint img, row, col;
+ if (!tempImage)
+ return GL_FALSE;
+ _mesa_adjust_image_for_convolution(ctx, dims, &srcWidth, &srcHeight);
+ for (img = 0; img < srcDepth; img++) {
+ GLubyte *dstRow = dstImage;
+ for (row = 0; row < srcHeight; row++) {
+ GLuint *dstUI = (GLuint *) dstRow;
+ for (col = 0; col < srcWidth; col++) {
+ dstUI[col] = PACK_COLOR_8888( CHAN_TO_UBYTE(src[RCOMP]),
+ CHAN_TO_UBYTE(src[GCOMP]),
+ CHAN_TO_UBYTE(src[BCOMP]),
+ CHAN_TO_UBYTE(src[ACOMP]) );
+ src += 4;
+ }
+ dstRow += dstRowStride;
+ }
+ dstImage += dstImageStride;
+ }
+ _mesa_free((void *) tempImage);
+ }
+ return GL_TRUE;
+}
+
+
+GLboolean
+_mesa_texstore_argb8888(STORE_PARAMS)
+{
+ const GLuint ui = 1;
+ const GLubyte littleEndian = *((const GLubyte *) &ui);
+
+ ASSERT(dstFormat == &_mesa_texformat_argb8888);
+ ASSERT(dstFormat->TexelBytes == 4);
+
+ if (!ctx->_ImageTransferState &&
+ !srcPacking->SwapBytes &&
+ baseInternalFormat == GL_RGBA &&
+ srcFormat == GL_BGRA &&
+ ((srcType == GL_UNSIGNED_BYTE && littleEndian) ||
+ (srcType == GL_UNSIGNED_INT_8_8_8_8_REV && littleEndian) ||
+ (srcType == GL_UNSIGNED_INT_8_8_8_8 && !littleEndian))) {
+ /* simple memcpy path */
+ memcpy_texture(dstFormat, dstAddr, dstXoffset, dstYoffset, dstZoffset,
+ dstRowStride, dstImageStride,
+ srcWidth, srcHeight, srcDepth, srcFormat, srcType,
+ srcAddr, srcPacking);
+ }
+ else {
+ /* general path */
+ const GLchan *tempImage = make_temp_chan_image(ctx, dims,
+ baseInternalFormat,
+ dstFormat->BaseFormat,
+ srcWidth, srcHeight, srcDepth,
+ srcFormat, srcType, srcAddr,
+ srcPacking);
+ const GLchan *src = tempImage;
+ GLubyte *dstImage = (GLubyte *) dstAddr
+ + dstZoffset * dstImageStride
+ + dstYoffset * dstRowStride
+ + dstXoffset * dstFormat->TexelBytes;
+ GLint img, row, col;
+ if (!tempImage)
+ return GL_FALSE;
+ _mesa_adjust_image_for_convolution(ctx, dims, &srcWidth, &srcHeight);
+ for (img = 0; img < srcDepth; img++) {
+ GLubyte *dstRow = dstImage;
+ for (row = 0; row < srcHeight; row++) {
+ GLuint *dstUI = (GLuint *) dstRow;
+ for (col = 0; col < srcWidth; col++) {
+ dstUI[col] = PACK_COLOR_8888( CHAN_TO_UBYTE(src[ACOMP]),
+ CHAN_TO_UBYTE(src[RCOMP]),
+ CHAN_TO_UBYTE(src[GCOMP]),
+ CHAN_TO_UBYTE(src[BCOMP]) );
+ src += 4;
+ }
+ dstRow += dstRowStride;
+ }
+ dstImage += dstImageStride;
+ }
+ _mesa_free((void *) tempImage);
+ }
+ return GL_TRUE;
+}
+
+
+
+GLboolean
+_mesa_texstore_rgb888(STORE_PARAMS)
+{
+ const GLuint ui = 1;
+ const GLubyte littleEndian = *((const GLubyte *) &ui);
+
+ ASSERT(dstFormat == &_mesa_texformat_rgb888);
+ ASSERT(dstFormat->TexelBytes == 3);
+
+ if (!ctx->_ImageTransferState &&
+ !srcPacking->SwapBytes &&
+ baseInternalFormat == GL_RGB &&
+ srcFormat == GL_BGR &&
+ srcType == GL_UNSIGNED_BYTE &&
+ littleEndian) {
+ /* simple memcpy path */
+ memcpy_texture(dstFormat, dstAddr, dstXoffset, dstYoffset, dstZoffset,
+ dstRowStride, dstImageStride,
+ srcWidth, srcHeight, srcDepth, srcFormat, srcType,
+ srcAddr, srcPacking);
+ }
+ else if (!ctx->_ImageTransferState &&
+ !srcPacking->SwapBytes &&
+ srcFormat == GL_RGBA &&
+ srcType == GL_UNSIGNED_BYTE) {
+ /* extract BGR from RGBA */
+ int img, row, col;
+ GLubyte *dstImage = (GLubyte *) dstAddr
+ + dstZoffset * dstImageStride
+ + dstYoffset * dstRowStride
+ + dstXoffset * dstFormat->TexelBytes;
+ for (img = 0; img < srcDepth; img++) {
+ const GLint srcRowStride = _mesa_image_row_stride(srcPacking,
+ srcWidth, srcFormat, srcType);
+ GLubyte *srcRow = _mesa_image_address(srcPacking, srcAddr, srcWidth,
+ srcHeight, srcFormat, srcType,
+ img, 0, 0);
+ GLubyte *dstRow = dstImage;
+ for (row = 0; row < srcHeight; row++) {
+ for (col = 0; col < srcWidth; col++) {
+ dstRow[col * 3 + 0] = srcRow[col * 4 + BCOMP];
+ dstRow[col * 3 + 1] = srcRow[col * 4 + GCOMP];
+ dstRow[col * 3 + 2] = srcRow[col * 4 + RCOMP];
+ }
+ dstRow += dstRowStride;
+ srcRow += srcRowStride;
+ }
+ dstImage += dstImageStride;
+ }
+ }
+ else {
+ /* general path */
+ const GLchan *tempImage = make_temp_chan_image(ctx, dims,
+ baseInternalFormat,
+ dstFormat->BaseFormat,
+ srcWidth, srcHeight, srcDepth,
+ srcFormat, srcType, srcAddr,
+ srcPacking);
+ const GLchan *src = (const GLubyte *) tempImage;
+ GLubyte *dstImage = (GLubyte *) dstAddr
+ + dstZoffset * dstImageStride
+ + dstYoffset * dstRowStride
+ + dstXoffset * dstFormat->TexelBytes;
+ GLint img, row, col;
+ if (!tempImage)
+ return GL_FALSE;
+ _mesa_adjust_image_for_convolution(ctx, dims, &srcWidth, &srcHeight);
+ for (img = 0; img < srcDepth; img++) {
+ GLubyte *dstRow = dstImage;
+ for (row = 0; row < srcHeight; row++) {
+#if 0
+ if (littleEndian) {
+ for (col = 0; col < srcWidth; col++) {
+ dstRow[col * 3 + 0] = CHAN_TO_UBYTE(src[RCOMP]);
+ dstRow[col * 3 + 1] = CHAN_TO_UBYTE(src[GCOMP]);
+ dstRow[col * 3 + 2] = CHAN_TO_UBYTE(src[BCOMP]);
+ srcUB += 3;
+ }
+ }
+ else {
+ for (col = 0; col < srcWidth; col++) {
+ dstRow[col * 3 + 0] = srcUB[BCOMP];
+ dstRow[col * 3 + 1] = srcUB[GCOMP];
+ dstRow[col * 3 + 2] = srcUB[RCOMP];
+ srcUB += 3;
+ }
+ }
+#else
+ for (col = 0; col < srcWidth; col++) {
+ dstRow[col * 3 + 0] = CHAN_TO_UBYTE(src[BCOMP]);
+ dstRow[col * 3 + 1] = CHAN_TO_UBYTE(src[GCOMP]);
+ dstRow[col * 3 + 2] = CHAN_TO_UBYTE(src[RCOMP]);
+ src += 3;
+ }
+#endif
+ dstRow += dstRowStride;
+ }
+ dstImage += dstImageStride;
+ }
+ _mesa_free((void *) tempImage);
+ }
+ return GL_TRUE;
+}
+
+
+GLboolean
+_mesa_texstore_argb4444(STORE_PARAMS)
+{
+ const GLuint ui = 1;
+ const GLubyte littleEndian = *((const GLubyte *) &ui);
+
+ ASSERT(dstFormat == &_mesa_texformat_argb4444);
+ ASSERT(dstFormat->TexelBytes == 2);
+
+ if (!ctx->_ImageTransferState &&
+ !srcPacking->SwapBytes &&
+ baseInternalFormat == GL_RGBA &&
+ srcFormat == GL_BGRA &&
+ ((srcType == GL_UNSIGNED_SHORT_4_4_4_4_REV && littleEndian) ||
+ (srcType == GL_UNSIGNED_SHORT_4_4_4_4 && !littleEndian))) {
+ /* simple memcpy path */
+ memcpy_texture(dstFormat, dstAddr, dstXoffset, dstYoffset, dstZoffset,
+ dstRowStride, dstImageStride,
+ srcWidth, srcHeight, srcDepth, srcFormat, srcType,
+ srcAddr, srcPacking);
+ }
+ else {
+ /* general path */
+ const GLchan *tempImage = make_temp_chan_image(ctx, dims,
+ baseInternalFormat,
+ dstFormat->BaseFormat,
+ srcWidth, srcHeight, srcDepth,
+ srcFormat, srcType, srcAddr,
+ srcPacking);
+ const GLchan *src = tempImage;
+ GLubyte *dstImage = (GLubyte *) dstAddr
+ + dstZoffset * dstImageStride
+ + dstYoffset * dstRowStride
+ + dstXoffset * dstFormat->TexelBytes;
+ GLint img, row, col;
+ if (!tempImage)
+ return GL_FALSE;
+ _mesa_adjust_image_for_convolution(ctx, dims, &srcWidth, &srcHeight);
+ for (img = 0; img < srcDepth; img++) {
+ GLubyte *dstRow = dstImage;
+ for (row = 0; row < srcHeight; row++) {
+ GLushort *dstUS = (GLushort *) dstRow;
+ for (col = 0; col < srcWidth; col++) {
+ dstUS[col] = PACK_COLOR_4444( CHAN_TO_UBYTE(src[ACOMP]),
+ CHAN_TO_UBYTE(src[RCOMP]),
+ CHAN_TO_UBYTE(src[GCOMP]),
+ CHAN_TO_UBYTE(src[BCOMP]) );
+ src += 4;
+ }
+ dstRow += dstRowStride;
+ }
+ dstImage += dstImageStride;
+ }
+ _mesa_free((void *) tempImage);
+ }
+ return GL_TRUE;
+}
+
+
+GLboolean
+_mesa_texstore_argb1555(STORE_PARAMS)
+{
+ const GLuint ui = 1;
+ const GLubyte littleEndian = *((const GLubyte *) &ui);
+
+ ASSERT(dstFormat == &_mesa_texformat_argb1555);
+ ASSERT(dstFormat->TexelBytes == 2);
+
+ if (!ctx->_ImageTransferState &&
+ !srcPacking->SwapBytes &&
+ baseInternalFormat == GL_RGBA &&
+ srcFormat == GL_BGRA &&
+ ((srcType == GL_UNSIGNED_SHORT_1_5_5_5_REV && littleEndian) ||
+ (srcType == GL_UNSIGNED_SHORT_5_5_5_1 && !littleEndian))) {
+ /* simple memcpy path */
+ memcpy_texture(dstFormat, dstAddr, dstXoffset, dstYoffset, dstZoffset,
+ dstRowStride, dstImageStride,
+ srcWidth, srcHeight, srcDepth, srcFormat, srcType,
+ srcAddr, srcPacking);
+ }
+ else {
+ /* general path */
+ const GLchan *tempImage = make_temp_chan_image(ctx, dims,
+ baseInternalFormat,
+ dstFormat->BaseFormat,
+ srcWidth, srcHeight, srcDepth,
+ srcFormat, srcType, srcAddr,
+ srcPacking);
+ const GLchan *src =tempImage;
+ GLubyte *dstImage = (GLubyte *) dstAddr
+ + dstZoffset * dstImageStride
+ + dstYoffset * dstRowStride
+ + dstXoffset * dstFormat->TexelBytes;
+ GLint img, row, col;
+ if (!tempImage)
+ return GL_FALSE;
+ _mesa_adjust_image_for_convolution(ctx, dims, &srcWidth, &srcHeight);
+ for (img = 0; img < srcDepth; img++) {
+ GLubyte *dstRow = dstImage;
+ for (row = 0; row < srcHeight; row++) {
+ GLushort *dstUS = (GLushort *) dstRow;
+ for (col = 0; col < srcWidth; col++) {
+ dstUS[col] = PACK_COLOR_1555( CHAN_TO_UBYTE(src[ACOMP]),
+ CHAN_TO_UBYTE(src[RCOMP]),
+ CHAN_TO_UBYTE(src[GCOMP]),
+ CHAN_TO_UBYTE(src[BCOMP]) );
+ src += 4;
+ }
+ dstRow += dstRowStride;
+ }
+ dstImage += dstImageStride;
+ }
+ _mesa_free((void *) tempImage);
+ }
+ return GL_TRUE;
+}
+
+
+GLboolean
+_mesa_texstore_al88(STORE_PARAMS)
+{
+ const GLuint ui = 1;
+ const GLubyte littleEndian = *((const GLubyte *) &ui);
+
+ ASSERT(dstFormat == &_mesa_texformat_al88);
+ ASSERT(dstFormat->TexelBytes == 2);
+
+ if (!ctx->_ImageTransferState &&
+ !srcPacking->SwapBytes &&
+ baseInternalFormat == GL_LUMINANCE_ALPHA &&
+ srcFormat == GL_LUMINANCE_ALPHA &&
+ srcType == GL_UNSIGNED_BYTE &&
+ littleEndian) {
+ /* simple memcpy path */
+ memcpy_texture(dstFormat, dstAddr, dstXoffset, dstYoffset, dstZoffset,
+ dstRowStride, dstImageStride,
+ srcWidth, srcHeight, srcDepth, srcFormat, srcType,
+ srcAddr, srcPacking);
+ }
+ else {
+ /* general path */
+ const GLchan *tempImage = make_temp_chan_image(ctx, dims,
+ baseInternalFormat,
+ dstFormat->BaseFormat,
+ srcWidth, srcHeight, srcDepth,
+ srcFormat, srcType, srcAddr,
+ srcPacking);
+ const GLchan *src = tempImage;
+ GLubyte *dstImage = (GLubyte *) dstAddr
+ + dstZoffset * dstImageStride
+ + dstYoffset * dstRowStride
+ + dstXoffset * dstFormat->TexelBytes;
+ GLint img, row, col;
+ if (!tempImage)
+ return GL_FALSE;
+ _mesa_adjust_image_for_convolution(ctx, dims, &srcWidth, &srcHeight);
+ for (img = 0; img < srcDepth; img++) {
+ GLubyte *dstRow = dstImage;
+ for (row = 0; row < srcHeight; row++) {
+ GLushort *dstUS = (GLushort *) dstRow;
+ for (col = 0; col < srcWidth; col++) {
+ dstUS[col] = PACK_COLOR_88( CHAN_TO_UBYTE(src[ACOMP]),
+ CHAN_TO_UBYTE(src[RCOMP]) );
+ src += 2;
+ }
+ dstRow += dstRowStride;
+ }
+ dstImage += dstImageStride;
+ }
+ _mesa_free((void *) tempImage);
+ }
+ return GL_TRUE;
+}
+
+
+GLboolean
+_mesa_texstore_rgb332(STORE_PARAMS)
+{
+ ASSERT(dstFormat == &_mesa_texformat_rgb332);
+ ASSERT(dstFormat->TexelBytes == 1);
+
+ if (!ctx->_ImageTransferState &&
+ !srcPacking->SwapBytes &&
+ baseInternalFormat == GL_RGB &&
+ srcFormat == GL_RGB && srcType == GL_UNSIGNED_BYTE_3_3_2) {
+ /* simple memcpy path */
+ memcpy_texture(dstFormat, dstAddr, dstXoffset, dstYoffset, dstZoffset,
+ dstRowStride, dstImageStride,
+ srcWidth, srcHeight, srcDepth, srcFormat, srcType,
+ srcAddr, srcPacking);
+ }
+ else {
+ /* general path */
+ const GLchan *tempImage = make_temp_chan_image(ctx, dims,
+ baseInternalFormat,
+ dstFormat->BaseFormat,
+ srcWidth, srcHeight, srcDepth,
+ srcFormat, srcType, srcAddr,
+ srcPacking);
+ const GLchan *src = tempImage;
+ GLubyte *dstImage = (GLubyte *) dstAddr
+ + dstZoffset * dstImageStride
+ + dstYoffset * dstRowStride
+ + dstXoffset * dstFormat->TexelBytes;
+ GLint img, row, col;
+ if (!tempImage)
+ return GL_FALSE;
+ _mesa_adjust_image_for_convolution(ctx, dims, &srcWidth, &srcHeight);
+ for (img = 0; img < srcDepth; img++) {
+ GLubyte *dstRow = dstImage;
+ for (row = 0; row < srcHeight; row++) {
+ for (col = 0; col < srcWidth; col++) {
+ dstRow[col] = PACK_COLOR_332( CHAN_TO_UBYTE(src[RCOMP]),
+ CHAN_TO_UBYTE(src[GCOMP]),
+ CHAN_TO_UBYTE(src[BCOMP]) );
+ src += 3;
+ }
+ dstRow += dstRowStride;
+ }
+ dstImage += dstImageStride;
+ }
+ _mesa_free((void *) tempImage);
+ }
+ return GL_TRUE;
+}
+
+
+
+/**
+ * Texstore for _mesa_texformat_a8, _mesa_texformat_l8, _mesa_texformat_i8.
+ */
+GLboolean
+_mesa_texstore_a8(STORE_PARAMS)
+{
+ ASSERT(dstFormat == &_mesa_texformat_a8 ||
+ dstFormat == &_mesa_texformat_l8 ||
+ dstFormat == &_mesa_texformat_i8);
+ ASSERT(dstFormat->TexelBytes == 1);
+
+ if (!ctx->_ImageTransferState &&
+ !srcPacking->SwapBytes &&
+ baseInternalFormat == srcFormat &&
+ srcType == GL_UNSIGNED_BYTE) {
+ /* simple memcpy path */
+ memcpy_texture(dstFormat, dstAddr, dstXoffset, dstYoffset, dstZoffset,
+ dstRowStride, dstImageStride,
+ srcWidth, srcHeight, srcDepth, srcFormat, srcType,
+ srcAddr, srcPacking);
+ }
+ else {
+ /* general path */
+ const GLchan *tempImage = make_temp_chan_image(ctx, dims,
+ baseInternalFormat,
+ dstFormat->BaseFormat,
+ srcWidth, srcHeight, srcDepth,
+ srcFormat, srcType, srcAddr,
+ srcPacking);
+ const GLchan *src = tempImage;
+ GLubyte *dstImage = (GLubyte *) dstAddr
+ + dstZoffset * dstImageStride
+ + dstYoffset * dstRowStride
+ + dstXoffset * dstFormat->TexelBytes;
+ GLint img, row, col;
+ if (!tempImage)
+ return GL_FALSE;
+ _mesa_adjust_image_for_convolution(ctx, dims, &srcWidth, &srcHeight);
+ for (img = 0; img < srcDepth; img++) {
+ GLubyte *dstRow = dstImage;
+ for (row = 0; row < srcHeight; row++) {
+ for (col = 0; col < srcWidth; col++) {
+ dstRow[col] = CHAN_TO_UBYTE(src[col]);
+ }
+ dstRow += dstRowStride;
+ src += srcWidth;
+ }
+ dstImage += dstImageStride;
+ }
+ _mesa_free((void *) tempImage);
+ }
+ return GL_TRUE;
+}
+
+
+
+GLboolean
+_mesa_texstore_ci8(STORE_PARAMS)
+{
+ ASSERT(dstFormat == &_mesa_texformat_ci8);
+ ASSERT(dstFormat->TexelBytes == 1);
+ ASSERT(baseInternalFormat == GL_COLOR_INDEX);
+
+ if (!ctx->_ImageTransferState &&
+ !srcPacking->SwapBytes &&
+ srcFormat == GL_COLOR_INDEX &&
+ srcType == GL_UNSIGNED_BYTE) {
+ /* simple memcpy path */
+ memcpy_texture(dstFormat, dstAddr, dstXoffset, dstYoffset, dstZoffset,
+ dstRowStride, dstImageStride,
+ srcWidth, srcHeight, srcDepth, srcFormat, srcType,
+ srcAddr, srcPacking);
+ }
+ else {
+ /* general path */
+ GLubyte *dstImage = (GLubyte *) dstAddr
+ + dstZoffset * dstImageStride
+ + dstYoffset * dstRowStride
+ + dstXoffset * dstFormat->TexelBytes;
+ GLint img, row;
+ for (img = 0; img < srcDepth; img++) {
+ GLubyte *dstRow = dstImage;
+ for (row = 0; row < srcHeight; row++) {
+ const GLvoid *src = _mesa_image_address(srcPacking,
+ srcAddr, srcWidth, srcHeight, srcFormat, srcType, img, row, 0);
+ _mesa_unpack_index_span(ctx, srcWidth, GL_UNSIGNED_BYTE, dstRow,
+ srcType, src, srcPacking,
+ ctx->_ImageTransferState);
+ dstRow += dstRowStride;
+ }
+ dstImage += dstImageStride;
+ }
+ }
+ return GL_TRUE;
+}
+
+
+/**
+ * Texstore for _mesa_texformat_ycbcr or _mesa_texformat_ycbcr_rev.
+ */
+GLboolean
+_mesa_texstore_ycbcr(STORE_PARAMS)
+{
+ const GLuint ui = 1;
+ const GLubyte littleEndian = *((const GLubyte *) &ui);
+
+ ASSERT((dstFormat == &_mesa_texformat_ycbcr) ||
+ (dstFormat == &_mesa_texformat_ycbcr_rev));
+ ASSERT(dstFormat->TexelBytes == 2);
+ ASSERT(ctx->Extensions.MESA_ycbcr_texture);
+ ASSERT(srcFormat == GL_YCBCR_MESA);
+ ASSERT((srcType == GL_UNSIGNED_SHORT_8_8_MESA) ||
+ (srcType == GL_UNSIGNED_SHORT_8_8_REV_MESA));
+ ASSERT(baseInternalFormat == GL_YCBCR_MESA);
+
+ /* always just memcpy since no pixel transfer ops apply */
+ memcpy_texture(dstFormat, dstAddr, dstXoffset, dstYoffset, dstZoffset,
+ dstRowStride, dstImageStride,
+ srcWidth, srcHeight, srcDepth, srcFormat, srcType,
+ srcAddr, srcPacking);
+
+ /* Check if we need byte swapping */
+ /* XXX the logic here _might_ be wrong */
+ if (srcPacking->SwapBytes ^
+ (srcType == GL_UNSIGNED_SHORT_8_8_REV_MESA) ^
+ (dstFormat == &_mesa_texformat_ycbcr_rev) ^
+ !littleEndian) {
+ GLushort *pImage = (GLushort *) ((GLubyte *) dstAddr
+ + dstZoffset * dstImageStride
+ + dstYoffset * dstRowStride
+ + dstXoffset * dstFormat->TexelBytes);
+ GLint img, row;
+ for (img = 0; img < srcDepth; img++) {
+ GLushort *pRow = pImage;
+ for (row = 0; row < srcHeight; row++) {
+ _mesa_swap2(pRow, srcWidth);
+ pRow += dstRowStride;
+ }
+ pImage += dstImageStride;
+ }
+ }
+ return GL_TRUE;
+}
+
+
+
+
+/**
+ * Store an image in any of the formats:
+ * _mesa_texformat_rgba_float32
+ * _mesa_texformat_rgb_float32
+ * _mesa_texformat_alpha_float32
+ * _mesa_texformat_luminance_float32
+ * _mesa_texformat_luminance_alpha_float32
+ * _mesa_texformat_intensity_float32
+ */
+GLboolean
+_mesa_texstore_rgba_float32(STORE_PARAMS)
+{
+ const GLint components = _mesa_components_in_format(baseInternalFormat);
+
+ ASSERT(dstFormat == &_mesa_texformat_rgba_float32 ||
+ dstFormat == &_mesa_texformat_rgb_float32 ||
+ dstFormat == &_mesa_texformat_alpha_float32 ||
+ dstFormat == &_mesa_texformat_luminance_float32 ||
+ dstFormat == &_mesa_texformat_luminance_alpha_float32 ||
+ dstFormat == &_mesa_texformat_intensity_float32);
+ ASSERT(baseInternalFormat == GL_RGBA ||
+ baseInternalFormat == GL_RGB ||
+ baseInternalFormat == GL_ALPHA ||
+ baseInternalFormat == GL_LUMINANCE ||
+ baseInternalFormat == GL_LUMINANCE_ALPHA ||
+ baseInternalFormat == GL_INTENSITY);
+ ASSERT(dstFormat->TexelBytes == components * sizeof(GLfloat));
+
+ if (!ctx->_ImageTransferState &&
+ !srcPacking->SwapBytes &&
+ baseInternalFormat == srcFormat &&
+ srcType == GL_FLOAT) {
+ /* simple memcpy path */
+ memcpy_texture(dstFormat, dstAddr, dstXoffset, dstYoffset, dstZoffset,
+ dstRowStride, dstImageStride,
+ srcWidth, srcHeight, srcDepth, srcFormat, srcType,
+ srcAddr, srcPacking);
+ }
+ else {
+ /* general path */
+ const GLfloat *tempImage = make_temp_float_image(ctx, dims,
+ baseInternalFormat,
+ dstFormat->BaseFormat,
+ srcWidth, srcHeight, srcDepth,
+ srcFormat, srcType, srcAddr,
+ srcPacking);
+ const GLfloat *src = tempImage;
+ const GLint bytesPerRow = srcWidth * components * sizeof(GLfloat);
+ GLubyte *dstImage = (GLubyte *) dstAddr
+ + dstZoffset * dstImageStride
+ + dstYoffset * dstRowStride
+ + dstXoffset * dstFormat->TexelBytes;
+ GLint img, row;
+ if (!tempImage)
+ return GL_FALSE;
+ _mesa_adjust_image_for_convolution(ctx, dims, &srcWidth, &srcHeight);
+ for (img = 0; img < srcDepth; img++) {
+ GLubyte *dst = dstImage;
+ for (row = 0; row < srcHeight; row++) {
+ _mesa_memcpy(dst, src, bytesPerRow);
+ dst += dstRowStride;
+ src += srcWidth * components;
+ }
+ dstImage += dstImageStride;
+ }
+
+ _mesa_free((void *) tempImage);
+ }
+ return GL_TRUE;
+}
+
+
+/**
+ * As above, but store 16-bit floats.
+ */
+GLboolean
+_mesa_texstore_rgba_float16(STORE_PARAMS)
+{
+ const GLint components = _mesa_components_in_format(baseInternalFormat);
+
+ ASSERT(dstFormat == &_mesa_texformat_rgba_float16 ||
+ dstFormat == &_mesa_texformat_rgb_float16 ||
+ dstFormat == &_mesa_texformat_alpha_float16 ||
+ dstFormat == &_mesa_texformat_luminance_float16 ||
+ dstFormat == &_mesa_texformat_luminance_alpha_float16 ||
+ dstFormat == &_mesa_texformat_intensity_float16);
+ ASSERT(baseInternalFormat == GL_RGBA ||
+ baseInternalFormat == GL_RGB ||
+ baseInternalFormat == GL_ALPHA ||
+ baseInternalFormat == GL_LUMINANCE ||
+ baseInternalFormat == GL_LUMINANCE_ALPHA ||
+ baseInternalFormat == GL_INTENSITY);
+ ASSERT(dstFormat->TexelBytes == components * sizeof(GLhalfARB));
+
+ if (!ctx->_ImageTransferState &&
+ !srcPacking->SwapBytes &&
+ baseInternalFormat == srcFormat &&
+ srcType == GL_HALF_FLOAT_ARB) {
+ /* simple memcpy path */
+ memcpy_texture(dstFormat, dstAddr, dstXoffset, dstYoffset, dstZoffset,
+ dstRowStride, dstImageStride,
+ srcWidth, srcHeight, srcDepth, srcFormat, srcType,
+ srcAddr, srcPacking);
+ }
+ else {
+ /* general path */
+ const GLfloat *tempImage = make_temp_float_image(ctx, dims,
+ baseInternalFormat,
+ dstFormat->BaseFormat,
+ srcWidth, srcHeight, srcDepth,
+ srcFormat, srcType, srcAddr,
+ srcPacking);
+ const GLfloat *src = tempImage;
+ GLubyte *dstImage = (GLubyte *) dstAddr
+ + dstZoffset * dstImageStride
+ + dstYoffset * dstRowStride
+ + dstXoffset * dstFormat->TexelBytes;
+ GLint img, row;
+ if (!tempImage)
+ return GL_FALSE;
+ _mesa_adjust_image_for_convolution(ctx, dims, &srcWidth, &srcHeight);
+ for (img = 0; img < srcDepth; img++) {
+ GLubyte *dstRow = dstImage;
+ for (row = 0; row < srcHeight; row++) {
+ GLhalfARB *dstTexel = (GLhalfARB *) dstRow;
+ GLint i;
+ for (i = 0; i < srcWidth * components; i++) {
+ dstTexel[i] = _mesa_float_to_half(src[i]);
+ }
+ dstRow += dstRowStride;
+ src += srcWidth * components;
+ }
+ dstImage += dstImageStride;
+ }
+
+ _mesa_free((void *) tempImage);
+ }
+ return GL_TRUE;
+}
+
+
+#if !NEWTEXSTORE /*****************************************************/
+
+
/*
* Given an internal texture format enum or 1, 2, 3, 4 return the
* corresponding _base_ internal format: GL_ALPHA, GL_LUMINANCE,
@@ -741,6 +2313,11 @@ transfer_compressed_teximage(GLcontext *ctx, GLuint dimensions,
}
+#endif /************************************************************/
+
+
+
+
/**
* Validate acces to a PBO for texture data.
*
@@ -796,10 +2373,7 @@ validate_pbo_compressed_teximage(GLsizei imageSize, const GLvoid *pixels,
/*
* This is the software fallback for Driver.TexImage1D()
- * and Driver.CopyTexImage2D().
- * The texture image type will be GLchan.
- * The texture image format will be GL_COLOR_INDEX, GL_INTENSITY,
- * GL_LUMINANCE, GL_LUMINANCE_ALPHA, GL_ALPHA, GL_RGB or GL_RGBA.
+ * and Driver.CopyTexImage1D().
*/
void
_mesa_store_teximage1d(GLcontext *ctx, GLenum target, GLint level,
@@ -811,7 +2385,7 @@ _mesa_store_teximage1d(GLcontext *ctx, GLenum target, GLint level,
struct gl_texture_image *texImage)
{
GLint postConvWidth = width;
- GLint texelBytes, sizeInBytes;
+ GLint sizeInBytes;
if (ctx->_ImageTransferState & IMAGE_CONVOLUTION_BIT) {
_mesa_adjust_image_for_convolution(ctx, 1, &postConvWidth, NULL);
@@ -819,19 +2393,17 @@ _mesa_store_teximage1d(GLcontext *ctx, GLenum target, GLint level,
/* choose the texture format */
assert(ctx->Driver.ChooseTextureFormat);
- texImage->TexFormat = (*ctx->Driver.ChooseTextureFormat)(ctx,
- internalFormat, format, type);
+ texImage->TexFormat = ctx->Driver.ChooseTextureFormat(ctx, internalFormat,
+ format, type);
assert(texImage->TexFormat);
texImage->FetchTexelc = texImage->TexFormat->FetchTexel1D;
texImage->FetchTexelf = texImage->TexFormat->FetchTexel1Df;
- texelBytes = texImage->TexFormat->TexelBytes;
-
/* allocate memory */
if (texImage->IsCompressed)
sizeInBytes = texImage->CompressedSize;
else
- sizeInBytes = postConvWidth * texelBytes;
+ sizeInBytes = postConvWidth * texImage->TexFormat->TexelBytes;
texImage->Data = MESA_PBUFFER_ALLOC(sizeInBytes);
if (!texImage->Data) {
_mesa_error(ctx, GL_OUT_OF_MEMORY, "glTexImage1D");
@@ -842,6 +2414,24 @@ _mesa_store_teximage1d(GLcontext *ctx, GLenum target, GLint level,
if (!pixels)
return;
+#if NEWTEXSTORE
+ {
+ const GLint dstRowStride = 0, dstImageStride = 0;
+ GLboolean success;
+ ASSERT(texImage->TexFormat->StoreImage);
+ success = texImage->TexFormat->StoreImage(ctx, 1, texImage->Format,
+ texImage->TexFormat,
+ texImage->Data,
+ 0, 0, 0, /* dstX/Y/Zoffset */
+ dstRowStride, dstImageStride,
+ width, 1, 1,
+ format, type, pixels, packing);
+ if (!success) {
+ _mesa_error(ctx, GL_OUT_OF_MEMORY, "glTexImage1D");
+ return;
+ }
+ }
+#else
/* unpack image, apply transfer ops and store in texImage->Data */
if (texImage->IsCompressed) {
GLint dstRowStride = _mesa_compressed_row_stride(texImage->IntFormat,
@@ -861,6 +2451,7 @@ _mesa_store_teximage1d(GLcontext *ctx, GLenum target, GLint level,
0, /* dstImageStride */
format, type, pixels, packing);
}
+#endif
/* GL_SGIS_generate_mipmap */
if (level == texObj->BaseLevel && texObj->GenerateMipmap) {
@@ -874,9 +2465,10 @@ _mesa_store_teximage1d(GLcontext *ctx, GLenum target, GLint level,
/*
* This is the software fallback for Driver.TexImage2D()
* and Driver.CopyTexImage2D().
- * The texture image type will be GLchan.
- * The texture image format will be GL_COLOR_INDEX, GL_INTENSITY,
- * GL_LUMINANCE, GL_LUMINANCE_ALPHA, GL_ALPHA, GL_RGB or GL_RGBA.
+ * Reasons why a driver might override this function:
+ * - Special memory allocation needs
+ * - Unusual row/image strides
+ * - Special housekeeping
*/
void
_mesa_store_teximage2d(GLcontext *ctx, GLenum target, GLint level,
@@ -921,6 +2513,30 @@ _mesa_store_teximage2d(GLcontext *ctx, GLenum target, GLint level,
if (!pixels)
return;
+#if NEWTEXSTORE
+ {
+ GLint dstRowStride, dstImageStride = 0;
+ GLboolean success;
+ if (texImage->IsCompressed) {
+ dstRowStride = _mesa_compressed_row_stride(texImage->IntFormat,width);
+ }
+ else {
+ dstRowStride = width * texImage->TexFormat->TexelBytes;
+ }
+ ASSERT(texImage->TexFormat->StoreImage);
+ success = texImage->TexFormat->StoreImage(ctx, 2, texImage->Format,
+ texImage->TexFormat,
+ texImage->Data,
+ 0, 0, 0, /* dstX/Y/Zoffset */
+ dstRowStride, dstImageStride,
+ width, height, 1,
+ format, type, pixels, packing);
+ if (!success) {
+ _mesa_error(ctx, GL_OUT_OF_MEMORY, "glTexImage2D");
+ return;
+ }
+ }
+#else
/* unpack image, apply transfer ops and store in texImage->Data */
if (texImage->IsCompressed) {
GLint dstRowStride = _mesa_compressed_row_stride(texImage->IntFormat,
@@ -940,6 +2556,7 @@ _mesa_store_teximage2d(GLcontext *ctx, GLenum target, GLint level,
0, /* dstImageStride */
format, type, pixels, packing);
}
+#endif
/* GL_SGIS_generate_mipmap */
if (level == texObj->BaseLevel && texObj->GenerateMipmap) {
@@ -954,9 +2571,6 @@ _mesa_store_teximage2d(GLcontext *ctx, GLenum target, GLint level,
/*
* This is the software fallback for Driver.TexImage3D()
* and Driver.CopyTexImage3D().
- * The texture image type will be GLchan.
- * The texture image format will be GL_COLOR_INDEX, GL_INTENSITY,
- * GL_LUMINANCE, GL_LUMINANCE_ALPHA, GL_ALPHA, GL_RGB or GL_RGBA.
*/
void
_mesa_store_teximage3d(GLcontext *ctx, GLenum target, GLint level,
@@ -996,6 +2610,32 @@ _mesa_store_teximage3d(GLcontext *ctx, GLenum target, GLint level,
return;
/* unpack image, apply transfer ops and store in texImage->Data */
+#if NEWTEXSTORE
+ {
+ GLint dstRowStride, dstImageStride;
+ GLboolean success;
+ if (texImage->IsCompressed) {
+ dstRowStride = _mesa_compressed_row_stride(texImage->IntFormat,width);
+ dstImageStride = 0;
+ }
+ else {
+ dstRowStride = width * texImage->TexFormat->TexelBytes;
+ dstImageStride = dstRowStride * height;
+ }
+ ASSERT(texImage->TexFormat->StoreImage);
+ success = texImage->TexFormat->StoreImage(ctx, 3, texImage->Format,
+ texImage->TexFormat,
+ texImage->Data,
+ 0, 0, 0, /* dstX/Y/Zoffset */
+ dstRowStride, dstImageStride,
+ width, height, depth,
+ format, type, pixels, packing);
+ if (!success) {
+ _mesa_error(ctx, GL_OUT_OF_MEMORY, "glTexImage3D");
+ return;
+ }
+ }
+#else
if (texImage->IsCompressed) {
GLint dstRowStride = _mesa_compressed_row_stride(texImage->IntFormat,
width);
@@ -1014,6 +2654,7 @@ _mesa_store_teximage3d(GLcontext *ctx, GLenum target, GLint level,
texImage->Width * texImage->Height * texelBytes,
format, type, pixels, packing);
}
+#endif
/* GL_SGIS_generate_mipmap */
if (level == texObj->BaseLevel && texObj->GenerateMipmap) {
@@ -1043,6 +2684,24 @@ _mesa_store_texsubimage1d(GLcontext *ctx, GLenum target, GLint level,
if (!pixels)
return;
+#if NEWTEXSTORE
+ {
+ const GLint dstRowStride = 0, dstImageStride = 0;
+ GLboolean success;
+ ASSERT(texImage->TexFormat->StoreImage);
+ success = texImage->TexFormat->StoreImage(ctx, 1, texImage->Format,
+ texImage->TexFormat,
+ texImage->Data,
+ xoffset, 0, 0, /* offsets */
+ dstRowStride, dstImageStride,
+ width, 1, 1,
+ format, type, pixels, packing);
+ if (!success) {
+ _mesa_error(ctx, GL_OUT_OF_MEMORY, "glTexSubImage1D");
+ return;
+ }
+ }
+#else
if (texImage->IsCompressed) {
GLint dstRowStride = _mesa_compressed_row_stride(texImage->IntFormat,
texImage->Width);
@@ -1068,6 +2727,7 @@ _mesa_store_texsubimage1d(GLcontext *ctx, GLenum target, GLint level,
0, /* dstImageStride */
format, type, pixels, packing);
}
+#endif
/* GL_SGIS_generate_mipmap */
if (level == texObj->BaseLevel && texObj->GenerateMipmap) {
@@ -1079,7 +2739,7 @@ _mesa_store_texsubimage1d(GLcontext *ctx, GLenum target, GLint level,
-/*
+/**
* This is the software fallback for Driver.TexSubImage2D()
* and Driver.CopyTexSubImage2D().
*/
@@ -1097,6 +2757,32 @@ _mesa_store_texsubimage2d(GLcontext *ctx, GLenum target, GLint level,
if (!pixels)
return;
+#if NEWTEXSTORE
+ {
+ GLint dstRowStride = 0, dstImageStride = 0;
+ GLboolean success;
+ if (texImage->IsCompressed) {
+ dstRowStride = _mesa_compressed_row_stride(texImage->IntFormat,
+ texImage->Width);
+ }
+ else {
+ dstRowStride = texImage->Width * texImage->TexFormat->TexelBytes;
+ }
+ ASSERT(texImage->TexFormat->StoreImage);
+ success = texImage->TexFormat->StoreImage(ctx, 2, texImage->Format,
+ texImage->TexFormat,
+ texImage->Data,
+ xoffset, yoffset, 0,
+ dstRowStride, dstImageStride,
+ width, height, 1,
+ format, type, pixels, packing);
+ if (!success) {
+ _mesa_error(ctx, GL_OUT_OF_MEMORY, "glTexSubImage2D");
+ return;
+ }
+ }
+#else
+
if (texImage->IsCompressed) {
GLint dstRowStride = _mesa_compressed_row_stride(texImage->IntFormat,
texImage->Width);
@@ -1113,6 +2799,7 @@ _mesa_store_texsubimage2d(GLcontext *ctx, GLenum target, GLint level,
dest, dstRowStride);
}
else {
+ /* old path */
_mesa_transfer_teximage(ctx, 2,
texImage->Format,
texImage->TexFormat, texImage->Data,
@@ -1122,6 +2809,7 @@ _mesa_store_texsubimage2d(GLcontext *ctx, GLenum target, GLint level,
0, /* dstImageStride */
format, type, pixels, packing);
}
+#endif
/* GL_SGIS_generate_mipmap */
if (level == texObj->BaseLevel && texObj->GenerateMipmap) {
@@ -1145,6 +2833,38 @@ _mesa_store_texsubimage3d(GLcontext *ctx, GLenum target, GLint level,
struct gl_texture_object *texObj,
struct gl_texture_image *texImage)
{
+ pixels = validate_pbo_teximage(width, height, depth,
+ format, type, pixels, packing);
+ if (!pixels)
+ return;
+
+#if NEWTEXSTORE
+ {
+ GLint dstRowStride, dstImageStride;
+ GLboolean success;
+ if (texImage->IsCompressed) {
+ dstRowStride = _mesa_compressed_row_stride(texImage->IntFormat,
+ texImage->Width);
+ dstImageStride = 0; /* XXX fix */
+ }
+ else {
+ dstRowStride = texImage->Width * texImage->TexFormat->TexelBytes;
+ dstImageStride = dstRowStride * texImage->Height;
+ }
+ ASSERT(texImage->TexFormat->StoreImage);
+ success = texImage->TexFormat->StoreImage(ctx, 3, texImage->Format,
+ texImage->TexFormat,
+ texImage->Data,
+ xoffset, yoffset, zoffset,
+ dstRowStride, dstImageStride,
+ width, height, depth,
+ format, type, pixels, packing);
+ if (!success) {
+ _mesa_error(ctx, GL_OUT_OF_MEMORY, "glTexSubImage3D");
+ return;
+ }
+ }
+#else
if (texImage->IsCompressed) {
GLint dstRowStride = _mesa_compressed_row_stride(texImage->IntFormat,
texImage->Width);
@@ -1171,7 +2891,7 @@ _mesa_store_texsubimage3d(GLcontext *ctx, GLenum target, GLint level,
texImage->Width * texImage->Height * texelBytes,
format, type, pixels, packing);
}
-
+#endif
/* GL_SGIS_generate_mipmap */
if (level == texObj->BaseLevel && texObj->GenerateMipmap) {
_mesa_generate_mipmap(ctx, target,
@@ -1428,7 +3148,7 @@ do_row(const struct gl_texture_format *format, GLint srcWidth,
}
}
return;
- case MESA_FORMAT_DEPTH_COMPONENT:
+ case MESA_FORMAT_DEPTH_COMPONENT_FLOAT32:
{
GLuint i, j, k;
const GLfloat *rowA = (const GLfloat *) srcRowA;
@@ -1440,6 +3160,18 @@ do_row(const struct gl_texture_format *format, GLint srcWidth,
}
}
return;
+ case MESA_FORMAT_DEPTH_COMPONENT16:
+ {
+ GLuint i, j, k;
+ const GLushort *rowA = (const GLushort *) srcRowA;
+ const GLushort *rowB = (const GLushort *) srcRowB;
+ GLushort *dst = (GLushort *) dstRow;
+ for (i = j = 0, k = k0; i < (GLuint) dstWidth;
+ i++, j += colStride, k += colStride) {
+ dst[i] = (rowA[j] + rowA[k] + rowB[j] + rowB[k]) / 4;
+ }
+ }
+ return;
/* Begin hardware formats */
case MESA_FORMAT_RGBA8888:
case MESA_FORMAT_ARGB8888:
@@ -1626,6 +3358,148 @@ do_row(const struct gl_texture_format *format, GLint srcWidth,
}
}
return;
+ case MESA_FORMAT_RGBA_FLOAT32:
+ {
+ GLuint i, j, k;
+ const GLfloat (*rowA)[4] = (const GLfloat (*)[4]) srcRowA;
+ const GLfloat (*rowB)[4] = (const GLfloat (*)[4]) srcRowB;
+ GLfloat (*dst)[4] = (GLfloat (*)[4]) dstRow;
+ for (i = j = 0, k = k0; i < (GLuint) dstWidth;
+ i++, j += colStride, k += colStride) {
+ dst[i][0] = (rowA[j][0] + rowA[k][0] +
+ rowB[j][0] + rowB[k][0]) * 0.25F;
+ dst[i][1] = (rowA[j][1] + rowA[k][1] +
+ rowB[j][1] + rowB[k][1]) * 0.25F;
+ dst[i][2] = (rowA[j][2] + rowA[k][2] +
+ rowB[j][2] + rowB[k][2]) * 0.25F;
+ dst[i][3] = (rowA[j][3] + rowA[k][3] +
+ rowB[j][3] + rowB[k][3]) * 0.25F;
+ }
+ }
+ return;
+ case MESA_FORMAT_RGBA_FLOAT16:
+ {
+ GLuint i, j, k, comp;
+ const GLhalfARB (*rowA)[4] = (const GLhalfARB (*)[4]) srcRowA;
+ const GLhalfARB (*rowB)[4] = (const GLhalfARB (*)[4]) srcRowB;
+ GLhalfARB (*dst)[4] = (GLhalfARB (*)[4]) dstRow;
+ for (i = j = 0, k = k0; i < (GLuint) dstWidth;
+ i++, j += colStride, k += colStride) {
+ for (comp = 0; comp < 4; comp++) {
+ GLfloat aj, ak, bj, bk;
+ aj = _mesa_half_to_float(rowA[j][comp]);
+ ak = _mesa_half_to_float(rowA[k][comp]);
+ bj = _mesa_half_to_float(rowB[j][comp]);
+ bk = _mesa_half_to_float(rowB[k][comp]);
+ dst[i][comp] = _mesa_float_to_half((aj + ak + bj + bk) * 0.25F);
+ }
+ }
+ }
+ return;
+ case MESA_FORMAT_RGB_FLOAT32:
+ {
+ GLuint i, j, k;
+ const GLfloat (*rowA)[3] = (const GLfloat (*)[3]) srcRowA;
+ const GLfloat (*rowB)[3] = (const GLfloat (*)[3]) srcRowB;
+ GLfloat (*dst)[3] = (GLfloat (*)[3]) dstRow;
+ for (i = j = 0, k = k0; i < (GLuint) dstWidth;
+ i++, j += colStride, k += colStride) {
+ dst[i][0] = (rowA[j][0] + rowA[k][0] +
+ rowB[j][0] + rowB[k][0]) * 0.25F;
+ dst[i][1] = (rowA[j][1] + rowA[k][1] +
+ rowB[j][1] + rowB[k][1]) * 0.25F;
+ dst[i][2] = (rowA[j][2] + rowA[k][2] +
+ rowB[j][2] + rowB[k][2]) * 0.25F;
+ }
+ }
+ return;
+ case MESA_FORMAT_RGB_FLOAT16:
+ {
+ GLuint i, j, k, comp;
+ const GLhalfARB (*rowA)[3] = (const GLhalfARB (*)[3]) srcRowA;
+ const GLhalfARB (*rowB)[3] = (const GLhalfARB (*)[3]) srcRowB;
+ GLhalfARB (*dst)[3] = (GLhalfARB (*)[3]) dstRow;
+ for (i = j = 0, k = k0; i < (GLuint) dstWidth;
+ i++, j += colStride, k += colStride) {
+ for (comp = 0; comp < 3; comp++) {
+ GLfloat aj, ak, bj, bk;
+ aj = _mesa_half_to_float(rowA[j][comp]);
+ ak = _mesa_half_to_float(rowA[k][comp]);
+ bj = _mesa_half_to_float(rowB[j][comp]);
+ bk = _mesa_half_to_float(rowB[k][comp]);
+ dst[i][comp] = _mesa_float_to_half((aj + ak + bj + bk) * 0.25F);
+ }
+ }
+ }
+ return;
+ case MESA_FORMAT_LUMINANCE_ALPHA_FLOAT32:
+ {
+ GLuint i, j, k;
+ const GLfloat (*rowA)[2] = (const GLfloat (*)[2]) srcRowA;
+ const GLfloat (*rowB)[2] = (const GLfloat (*)[2]) srcRowB;
+ GLfloat (*dst)[2] = (GLfloat (*)[2]) dstRow;
+ for (i = j = 0, k = k0; i < (GLuint) dstWidth;
+ i++, j += colStride, k += colStride) {
+ dst[i][0] = (rowA[j][0] + rowA[k][0] +
+ rowB[j][0] + rowB[k][0]) * 0.25F;
+ dst[i][1] = (rowA[j][1] + rowA[k][1] +
+ rowB[j][1] + rowB[k][1]) * 0.25F;
+ }
+ }
+ return;
+ case MESA_FORMAT_LUMINANCE_ALPHA_FLOAT16:
+ {
+ GLuint i, j, k, comp;
+ const GLhalfARB (*rowA)[2] = (const GLhalfARB (*)[2]) srcRowA;
+ const GLhalfARB (*rowB)[2] = (const GLhalfARB (*)[2]) srcRowB;
+ GLhalfARB (*dst)[2] = (GLhalfARB (*)[2]) dstRow;
+ for (i = j = 0, k = k0; i < (GLuint) dstWidth;
+ i++, j += colStride, k += colStride) {
+ for (comp = 0; comp < 2; comp++) {
+ GLfloat aj, ak, bj, bk;
+ aj = _mesa_half_to_float(rowA[j][comp]);
+ ak = _mesa_half_to_float(rowA[k][comp]);
+ bj = _mesa_half_to_float(rowB[j][comp]);
+ bk = _mesa_half_to_float(rowB[k][comp]);
+ dst[i][comp] = _mesa_float_to_half((aj + ak + bj + bk) * 0.25F);
+ }
+ }
+ }
+ return;
+ case MESA_FORMAT_ALPHA_FLOAT32:
+ case MESA_FORMAT_LUMINANCE_FLOAT32:
+ case MESA_FORMAT_INTENSITY_FLOAT32:
+ {
+ GLuint i, j, k;
+ const GLfloat *rowA = (const GLfloat *) srcRowA;
+ const GLfloat *rowB = (const GLfloat *) srcRowB;
+ GLfloat *dst = (GLfloat *) dstRow;
+ for (i = j = 0, k = k0; i < (GLuint) dstWidth;
+ i++, j += colStride, k += colStride) {
+ dst[i] = (rowA[j] + rowA[k] + rowB[j] + rowB[k]) * 0.25F;
+ }
+ }
+ return;
+ case MESA_FORMAT_ALPHA_FLOAT16:
+ case MESA_FORMAT_LUMINANCE_FLOAT16:
+ case MESA_FORMAT_INTENSITY_FLOAT16:
+ {
+ GLuint i, j, k;
+ const GLhalfARB *rowA = (const GLhalfARB *) srcRowA;
+ const GLhalfARB *rowB = (const GLhalfARB *) srcRowB;
+ GLhalfARB *dst = (GLhalfARB *) dstRow;
+ for (i = j = 0, k = k0; i < (GLuint) dstWidth;
+ i++, j += colStride, k += colStride) {
+ GLfloat aj, ak, bj, bk;
+ aj = _mesa_half_to_float(rowA[j]);
+ ak = _mesa_half_to_float(rowA[k]);
+ bj = _mesa_half_to_float(rowB[j]);
+ bk = _mesa_half_to_float(rowB[k]);
+ dst[i] = _mesa_float_to_half((aj + ak + bj + bk) * 0.25F);
+ }
+ }
+ return;
+
default:
_mesa_problem(NULL, "bad format in do_row()");
}
diff --git a/src/mesa/main/texstore.h b/src/mesa/main/texstore.h
index 72da2a08f9..8ba8101c48 100644
--- a/src/mesa/main/texstore.h
+++ b/src/mesa/main/texstore.h
@@ -1,15 +1,8 @@
-/**
- * \file texstore.h
- * Texture image storage.
- *
- * \author Brian Paul
- */
-
/*
* Mesa 3-D graphics library
- * Version: 5.1
+ * Version: 6.1
*
- * Copyright (C) 1999-2003 Brian Paul All Rights Reserved.
+ * Copyright (C) 1999-2004 Brian Paul All Rights Reserved.
*
* Permission is hereby granted, free of charge, to any person obtaining a
* copy of this software and associated documentation files (the "Software"),
@@ -30,12 +23,55 @@
*/
+/**
+ * \file texstore.h
+ * Texture image storage routines.
+ *
+ * \author Brian Paul
+ */
+
+
#ifndef TEXSTORE_H
#define TEXSTORE_H
#include "mtypes.h"
+/*** NEWTEXSTORE ***/
+
+/* Macro just to save some typing */
+#define STORE_PARAMS \
+ GLcontext *ctx, GLuint dims, \
+ GLenum baseInternalFormat, \
+ const struct gl_texture_format *dstFormat, \
+ GLvoid *dstAddr, \
+ GLint dstXoffset, GLint dstYoffset, GLint dstZoffset, \
+ GLint dstRowStride, GLint dstImageStride, \
+ GLint srcWidth, GLint srcHeight, GLint srcDepth, \
+ GLenum srcFormat, GLenum srcType, \
+ const GLvoid *srcAddr, \
+ const struct gl_pixelstore_attrib *srcPacking
+
+
+extern GLboolean _mesa_texstore_rgba(STORE_PARAMS);
+extern GLboolean _mesa_texstore_color_index(STORE_PARAMS);
+extern GLboolean _mesa_texstore_depth_component16(STORE_PARAMS);
+extern GLboolean _mesa_texstore_depth_component_float32(STORE_PARAMS);
+extern GLboolean _mesa_texstore_rgb565(STORE_PARAMS);
+extern GLboolean _mesa_texstore_rgba8888(STORE_PARAMS);
+extern GLboolean _mesa_texstore_argb8888(STORE_PARAMS);
+extern GLboolean _mesa_texstore_rgb888(STORE_PARAMS);
+extern GLboolean _mesa_texstore_argb4444(STORE_PARAMS);
+extern GLboolean _mesa_texstore_argb1555(STORE_PARAMS);
+extern GLboolean _mesa_texstore_al88(STORE_PARAMS);
+extern GLboolean _mesa_texstore_rgb332(STORE_PARAMS);
+extern GLboolean _mesa_texstore_a8(STORE_PARAMS);
+extern GLboolean _mesa_texstore_ci8(STORE_PARAMS);
+extern GLboolean _mesa_texstore_ycbcr(STORE_PARAMS);
+extern GLboolean _mesa_texstore_rgba_float32(STORE_PARAMS);
+extern GLboolean _mesa_texstore_rgba_float16(STORE_PARAMS);
+
+#if !NEWTEXSTORE
extern void
_mesa_transfer_teximage(GLcontext *ctx, GLuint dimensions,
@@ -49,6 +85,8 @@ _mesa_transfer_teximage(GLcontext *ctx, GLuint dimensions,
const GLvoid *srcAddr,
const struct gl_pixelstore_attrib *srcPacking);
+#endif /* NEWTEXSTORE */
+
extern void
_mesa_store_teximage1d(GLcontext *ctx, GLenum target, GLint level,
diff --git a/src/mesa/main/texutil.c b/src/mesa/main/texutil.c
index 40309d154c..7bb46481e0 100644
--- a/src/mesa/main/texutil.c
+++ b/src/mesa/main/texutil.c
@@ -46,6 +46,9 @@
#include "texutil.h"
+#if !NEWTEXSTORE
+
+
#define DEBUG_TEXUTIL 0
@@ -1033,3 +1036,5 @@ do { \
_mesa_problem(NULL,"unexpected bytes/pixel in _mesa_rescale_teximage2d");
}
}
+
+#endif
diff --git a/src/mesa/swrast/s_drawpix.c b/src/mesa/swrast/s_drawpix.c
index 337b5a5bfd..a93a605a97 100644
--- a/src/mesa/swrast/s_drawpix.c
+++ b/src/mesa/swrast/s_drawpix.c
@@ -750,7 +750,7 @@ draw_rgba_pixels( GLcontext *ctx, GLint x, GLint y,
INIT_SPAN(span, GL_BITMAP, 0, 0, SPAN_RGBA);
- if (!_mesa_is_legal_format_and_type(format, type)) {
+ if (!_mesa_is_legal_format_and_type(ctx, format, type)) {
_mesa_error(ctx, GL_INVALID_ENUM, "glDrawPixels(format or type)");
return;
}
diff --git a/src/mesa/swrast/s_readpix.c b/src/mesa/swrast/s_readpix.c
index b5ab06e4ba..80f737b052 100644
--- a/src/mesa/swrast/s_readpix.c
+++ b/src/mesa/swrast/s_readpix.c
@@ -366,12 +366,18 @@ read_rgba_pixels( GLcontext *ctx,
case GL_UNSIGNED_INT_2_10_10_10_REV:
/* valid pixel type */
break;
+ case GL_HALF_FLOAT_ARB:
+ if (!ctx->Extensions.ARB_half_float_pixel) {
+ _mesa_error( ctx, GL_INVALID_ENUM, "glReadPixels(type)" );
+ return;
+ }
+ break;
default:
_mesa_error( ctx, GL_INVALID_ENUM, "glReadPixels(type)" );
return;
}
- if (!_mesa_is_legal_format_and_type(format, type) ||
+ if (!_mesa_is_legal_format_and_type(ctx, format, type) ||
format == GL_INTENSITY) {
_mesa_error(ctx, GL_INVALID_OPERATION, "glReadPixels(format or type)");
return;