summaryrefslogtreecommitdiffstats
path: root/src/mesa/drivers/dri/tdfx
diff options
context:
space:
mode:
authorBrian Paul <[email protected]>2009-10-28 21:24:11 -0600
committerBrian Paul <[email protected]>2009-10-28 21:24:11 -0600
commit1f196b786d6bd0c6a5dbdc638574ff716cc3d4de (patch)
tree5ae2753b99070f8b35c51576bd39e52df63879d6 /src/mesa/drivers/dri/tdfx
parent0ea575d721821262a862ceef010db9b1a8b4a6d9 (diff)
parent086f9fc0e2aef27f54eda87c733685500555bf20 (diff)
Merge branch 'texformat-rework'
Conflicts: src/mesa/drivers/dri/radeon/radeon_fbo.c src/mesa/drivers/dri/s3v/s3v_tex.c src/mesa/drivers/dri/s3v/s3v_xmesa.c src/mesa/drivers/dri/trident/trident_context.c src/mesa/main/debug.c src/mesa/main/mipmap.c src/mesa/main/texformat.c src/mesa/main/texgetimage.c
Diffstat (limited to 'src/mesa/drivers/dri/tdfx')
-rw-r--r--src/mesa/drivers/dri/tdfx/tdfx_screen.c10
-rw-r--r--src/mesa/drivers/dri/tdfx/tdfx_state.c1
-rw-r--r--src/mesa/drivers/dri/tdfx/tdfx_tex.c239
3 files changed, 119 insertions, 131 deletions
diff --git a/src/mesa/drivers/dri/tdfx/tdfx_screen.c b/src/mesa/drivers/dri/tdfx/tdfx_screen.c
index d8a4b401c08..2eb0024d40b 100644
--- a/src/mesa/drivers/dri/tdfx/tdfx_screen.c
+++ b/src/mesa/drivers/dri/tdfx/tdfx_screen.c
@@ -170,7 +170,7 @@ tdfxCreateBuffer( __DRIscreenPrivate *driScrnPriv,
{
driRenderbuffer *frontRb
- = driNewRenderbuffer(GL_RGBA, NULL, screen->cpp,
+ = driNewRenderbuffer(MESA_FORMAT_ARGB8888, NULL, screen->cpp,
screen->fbOffset, screen->width, driDrawPriv);
tdfxSetSpanFunctions(frontRb, mesaVis);
_mesa_add_renderbuffer(fb, BUFFER_FRONT_LEFT, &frontRb->Base);
@@ -178,7 +178,7 @@ tdfxCreateBuffer( __DRIscreenPrivate *driScrnPriv,
if (mesaVis->doubleBufferMode) {
driRenderbuffer *backRb
- = driNewRenderbuffer(GL_RGBA, NULL, screen->cpp,
+ = driNewRenderbuffer(MESA_FORMAT_ARGB8888, NULL, screen->cpp,
screen->backOffset, screen->width,
driDrawPriv);
tdfxSetSpanFunctions(backRb, mesaVis);
@@ -188,7 +188,7 @@ tdfxCreateBuffer( __DRIscreenPrivate *driScrnPriv,
if (mesaVis->depthBits == 16) {
driRenderbuffer *depthRb
- = driNewRenderbuffer(GL_DEPTH_COMPONENT16, NULL, screen->cpp,
+ = driNewRenderbuffer(MESA_FORMAT_Z16, NULL, screen->cpp,
screen->depthOffset, screen->width,
driDrawPriv);
tdfxSetSpanFunctions(depthRb, mesaVis);
@@ -196,7 +196,7 @@ tdfxCreateBuffer( __DRIscreenPrivate *driScrnPriv,
}
else if (mesaVis->depthBits == 24) {
driRenderbuffer *depthRb
- = driNewRenderbuffer(GL_DEPTH_COMPONENT24, NULL, screen->cpp,
+ = driNewRenderbuffer(MESA_FORMAT_Z24_S8, NULL, screen->cpp,
screen->depthOffset, screen->width,
driDrawPriv);
tdfxSetSpanFunctions(depthRb, mesaVis);
@@ -205,7 +205,7 @@ tdfxCreateBuffer( __DRIscreenPrivate *driScrnPriv,
if (mesaVis->stencilBits > 0) {
driRenderbuffer *stencilRb
- = driNewRenderbuffer(GL_STENCIL_INDEX8_EXT, NULL, screen->cpp,
+ = driNewRenderbuffer(MESA_FORMAT_S8, NULL, screen->cpp,
screen->depthOffset, screen->width,
driDrawPriv);
tdfxSetSpanFunctions(stencilRb, mesaVis);
diff --git a/src/mesa/drivers/dri/tdfx/tdfx_state.c b/src/mesa/drivers/dri/tdfx/tdfx_state.c
index 591df8a905a..cf2712720f3 100644
--- a/src/mesa/drivers/dri/tdfx/tdfx_state.c
+++ b/src/mesa/drivers/dri/tdfx/tdfx_state.c
@@ -40,7 +40,6 @@
#include "main/mtypes.h"
#include "main/colormac.h"
-#include "main/texformat.h"
#include "main/texstore.h"
#include "main/teximage.h"
diff --git a/src/mesa/drivers/dri/tdfx/tdfx_tex.c b/src/mesa/drivers/dri/tdfx/tdfx_tex.c
index f6a48b3ae12..0aa09e733be 100644
--- a/src/mesa/drivers/dri/tdfx/tdfx_tex.c
+++ b/src/mesa/drivers/dri/tdfx/tdfx_tex.c
@@ -42,7 +42,6 @@
#include "main/image.h"
#include "main/mipmap.h"
#include "main/texcompress.h"
-#include "main/texformat.h"
#include "main/teximage.h"
#include "main/texstore.h"
#include "main/texobj.h"
@@ -72,13 +71,13 @@ _mesa_halve2x2_teximage2d ( GLcontext *ctx,
GLubyte *_d = NULL;
GLenum _t = 0;
- if (texImage->TexFormat->MesaFormat == MESA_FORMAT_RGB565) {
+ if (texImage->TexFormat == MESA_FORMAT_RGB565) {
_t = GL_UNSIGNED_SHORT_5_6_5_REV;
bpt = bytesPerPixel;
- } else if (texImage->TexFormat->MesaFormat == MESA_FORMAT_ARGB4444) {
+ } else if (texImage->TexFormat == MESA_FORMAT_ARGB4444) {
_t = GL_UNSIGNED_SHORT_4_4_4_4_REV;
bpt = bytesPerPixel;
- } else if (texImage->TexFormat->MesaFormat == MESA_FORMAT_ARGB1555) {
+ } else if (texImage->TexFormat == MESA_FORMAT_ARGB1555) {
_t = GL_UNSIGNED_SHORT_1_5_5_5_REV;
bpt = bytesPerPixel;
}
@@ -93,13 +92,13 @@ _mesa_halve2x2_teximage2d ( GLcontext *ctx,
}
_s = src = MALLOC(srcRowStride * srcHeight);
_d = dst = MALLOC(dstWidth * bytesPerPixel * dstHeight);
- _mesa_texstore_rgba8888(ctx, 2, GL_RGBA,
- &_mesa_texformat_rgba8888_rev, src,
- 0, 0, 0, /* dstX/Y/Zoffset */
- srcRowStride, /* dstRowStride */
- &dstImageOffsets,
- srcWidth, srcHeight, 1,
- texImage->_BaseFormat, _t, srcImage, &ctx->DefaultPacking);
+ _mesa_texstore(ctx, 2, GL_RGBA,
+ MESA_FORMAT_RGBA8888_REV, src,
+ 0, 0, 0, /* dstX/Y/Zoffset */
+ srcRowStride, /* dstRowStride */
+ &dstImageOffsets,
+ srcWidth, srcHeight, 1,
+ texImage->_BaseFormat, _t, srcImage, &ctx->DefaultPacking);
}
if (srcHeight == 1) {
@@ -140,13 +139,13 @@ _mesa_halve2x2_teximage2d ( GLcontext *ctx,
if (bpt) {
src = _s;
dst = _d;
- texImage->TexFormat->StoreImage(ctx, 2, texImage->_BaseFormat,
- texImage->TexFormat, dstImage,
- 0, 0, 0, /* dstX/Y/Zoffset */
- dstWidth * bpt,
- &dstImageOffsets,
- dstWidth, dstHeight, 1,
- GL_BGRA, CHAN_TYPE, dst, &ctx->DefaultPacking);
+ _mesa_texstore(ctx, 2, texImage->_BaseFormat,
+ texImage->TexFormat, dstImage,
+ 0, 0, 0, /* dstX/Y/Zoffset */
+ dstWidth * bpt,
+ &dstImageOffsets,
+ dstWidth, dstHeight, 1,
+ GL_BGRA, CHAN_TYPE, dst, &ctx->DefaultPacking);
FREE(dst);
FREE(src);
}
@@ -190,7 +189,7 @@ tdfxGenerateMipmap(GLcontext *ctx, GLenum target,
const tdfxMipMapLevel *mml;
texImage = _mesa_get_tex_image(ctx, texObj, target, level);
- assert(!texImage->IsCompressed);
+ texelBytes = _mesa_get_format_bytes(texImage->TexFormat);
mml = TDFX_TEXIMAGE_DATA(texImage);
@@ -760,7 +759,7 @@ fxTexusError(const char *string, FxBool fatal)
#endif
-static const struct gl_texture_format *
+static gl_format
tdfxChooseTextureFormat( GLcontext *ctx, GLint internalFormat,
GLenum srcFormat, GLenum srcType )
{
@@ -774,7 +773,7 @@ tdfxChooseTextureFormat( GLcontext *ctx, GLint internalFormat,
case GL_ALPHA12:
case GL_ALPHA16:
case GL_COMPRESSED_ALPHA:
- return &_mesa_texformat_a8;
+ return MESA_FORMAT_A8;
case 1:
case GL_LUMINANCE:
case GL_LUMINANCE4:
@@ -782,7 +781,7 @@ tdfxChooseTextureFormat( GLcontext *ctx, GLint internalFormat,
case GL_LUMINANCE12:
case GL_LUMINANCE16:
case GL_COMPRESSED_LUMINANCE:
- return &_mesa_texformat_l8;
+ return MESA_FORMAT_L8;
case 2:
case GL_LUMINANCE_ALPHA:
case GL_LUMINANCE4_ALPHA4:
@@ -792,48 +791,47 @@ tdfxChooseTextureFormat( GLcontext *ctx, GLint internalFormat,
case GL_LUMINANCE12_ALPHA12:
case GL_LUMINANCE16_ALPHA16:
case GL_COMPRESSED_LUMINANCE_ALPHA:
- return &_mesa_texformat_al88;
+ return MESA_FORMAT_AL88;
case GL_INTENSITY:
case GL_INTENSITY4:
case GL_INTENSITY8:
case GL_INTENSITY12:
case GL_INTENSITY16:
case GL_COMPRESSED_INTENSITY:
- return &_mesa_texformat_i8;
+ return MESA_FORMAT_I8;
case GL_R3_G3_B2:
case GL_RGB4:
case GL_RGB5:
- return &_mesa_texformat_rgb565;
+ return MESA_FORMAT_RGB565;
case GL_COMPRESSED_RGB:
/* intentional fall-through */
case 3:
case GL_RGB:
if ( srcFormat == GL_RGB && srcType == GL_UNSIGNED_SHORT_5_6_5 ) {
- return &_mesa_texformat_rgb565;
+ return MESA_FORMAT_RGB565;
}
/* intentional fall through */
case GL_RGB8:
case GL_RGB10:
case GL_RGB12:
case GL_RGB16:
- return (allow32bpt) ? &_mesa_texformat_argb8888
- : &_mesa_texformat_rgb565;
+ return (allow32bpt) ? MESA_FORMAT_ARGB8888 : MESA_FORMAT_RGB565;
case GL_RGBA2:
case GL_RGBA4:
- return &_mesa_texformat_argb4444;
+ return MESA_FORMAT_ARGB4444;
case GL_COMPRESSED_RGBA:
/* intentional fall-through */
case 4:
case GL_RGBA:
if ( srcFormat == GL_BGRA ) {
if ( srcType == GL_UNSIGNED_INT_8_8_8_8_REV ) {
- return &_mesa_texformat_argb8888;
+ return MESA_FORMAT_ARGB8888;
}
else if ( srcType == GL_UNSIGNED_SHORT_4_4_4_4_REV ) {
- return &_mesa_texformat_argb4444;
+ return MESA_FORMAT_ARGB4444;
}
else if ( srcType == GL_UNSIGNED_SHORT_1_5_5_5_REV ) {
- return &_mesa_texformat_argb1555;
+ return MESA_FORMAT_ARGB1555;
}
}
/* intentional fall through */
@@ -841,10 +839,9 @@ tdfxChooseTextureFormat( GLcontext *ctx, GLint internalFormat,
case GL_RGB10_A2:
case GL_RGBA12:
case GL_RGBA16:
- return allow32bpt ? &_mesa_texformat_argb8888
- : &_mesa_texformat_argb4444;
+ return allow32bpt ? MESA_FORMAT_ARGB8888 : MESA_FORMAT_ARGB4444;
case GL_RGB5_A1:
- return &_mesa_texformat_argb1555;
+ return MESA_FORMAT_ARGB1555;
case GL_COLOR_INDEX:
case GL_COLOR_INDEX1_EXT:
case GL_COLOR_INDEX2_EXT:
@@ -852,29 +849,29 @@ tdfxChooseTextureFormat( GLcontext *ctx, GLint internalFormat,
case GL_COLOR_INDEX8_EXT:
case GL_COLOR_INDEX12_EXT:
case GL_COLOR_INDEX16_EXT:
- return &_mesa_texformat_ci8;
+ return MESA_FORMAT_CI8;
/* GL_EXT_texture_compression_s3tc */
/* GL_S3_s3tc */
case GL_COMPRESSED_RGB_S3TC_DXT1_EXT:
case GL_RGB_S3TC:
case GL_RGB4_S3TC:
- return &_mesa_texformat_rgb_dxt1;
+ return MESA_FORMAT_RGB_DXT1;
case GL_COMPRESSED_RGBA_S3TC_DXT1_EXT:
- return &_mesa_texformat_rgba_dxt1;
+ return MESA_FORMAT_RGBA_DXT1;
case GL_COMPRESSED_RGBA_S3TC_DXT3_EXT:
case GL_RGBA_S3TC:
case GL_RGBA4_S3TC:
- return &_mesa_texformat_rgba_dxt3;
+ return MESA_FORMAT_RGBA_DXT3;
case GL_COMPRESSED_RGBA_S3TC_DXT5_EXT:
- return &_mesa_texformat_rgba_dxt5;
+ return MESA_FORMAT_RGBA_DXT5;
/* GL_3DFX_texture_compression_FXT1 */
case GL_COMPRESSED_RGB_FXT1_3DFX:
- return &_mesa_texformat_rgb_fxt1;
+ return MESA_FORMAT_RGB_FXT1;
case GL_COMPRESSED_RGBA_FXT1_3DFX:
- return &_mesa_texformat_rgba_fxt1;
+ return MESA_FORMAT_RGBA_FXT1;
default:
_mesa_problem(ctx, "unexpected format in tdfxChooseTextureFormat");
- return NULL;
+ return MESA_FORMAT_NONE;
}
}
@@ -1126,7 +1123,9 @@ fetch_rgb_dxt1(const struct gl_texture_image *texImage,
i = i * mml->wScale;
j = j * mml->hScale;
+ /* XXX Get fetch func from _mesa_get_texel_fetch_func()
_mesa_texformat_rgb_dxt1.FetchTexel2D(texImage, i, j, k, rgba);
+ */
}
@@ -1139,7 +1138,9 @@ fetch_rgba_dxt1(const struct gl_texture_image *texImage,
i = i * mml->wScale;
j = j * mml->hScale;
+ /* XXX Get fetch func from _mesa_get_texel_fetch_func()
_mesa_texformat_rgba_dxt1.FetchTexel2D(texImage, i, j, k, rgba);
+ */
}
@@ -1152,7 +1153,9 @@ fetch_rgba_dxt3(const struct gl_texture_image *texImage,
i = i * mml->wScale;
j = j * mml->hScale;
+ /* XXX Get fetch func from _mesa_get_texel_fetch_func()
_mesa_texformat_rgba_dxt3.FetchTexel2D(texImage, i, j, k, rgba);
+ */
}
@@ -1165,7 +1168,9 @@ fetch_rgba_dxt5(const struct gl_texture_image *texImage,
i = i * mml->wScale;
j = j * mml->hScale;
+ /* XXX Get fetch func from _mesa_get_texel_fetch_func()
_mesa_texformat_rgba_dxt5.FetchTexel2D(texImage, i, j, k, rgba);
+ */
}
@@ -1226,20 +1231,21 @@ adjust2DRatio (GLcontext *ctx,
GLvoid *tempImage;
GLuint dstImageOffsets = 0;
- if (!texImage->IsCompressed) {
+ if (!_mesa_is_format_compressed(texImage->TexFormat)) {
GLubyte *destAddr;
+
tempImage = MALLOC(width * height * texelBytes);
if (!tempImage) {
return GL_FALSE;
}
- texImage->TexFormat->StoreImage(ctx, 2, texImage->_BaseFormat,
- texImage->TexFormat, tempImage,
- 0, 0, 0, /* dstX/Y/Zoffset */
- width * texelBytes, /* dstRowStride */
- &dstImageOffsets,
- width, height, 1,
- format, type, pixels, packing);
+ _mesa_texstore(ctx, 2, texImage->_BaseFormat,
+ texImage->TexFormat, tempImage,
+ 0, 0, 0, /* dstX/Y/Zoffset */
+ width * texelBytes, /* dstRowStride */
+ &dstImageOffsets,
+ width, height, 1,
+ format, type, pixels, packing);
/* now rescale */
/* compute address of dest subimage within the overal tex image */
@@ -1256,6 +1262,7 @@ adjust2DRatio (GLcontext *ctx,
} else {
const GLint rawBytes = 4;
GLvoid *rawImage = MALLOC(width * height * rawBytes);
+
if (!rawImage) {
return GL_FALSE;
}
@@ -1265,26 +1272,26 @@ adjust2DRatio (GLcontext *ctx,
return GL_FALSE;
}
/* unpack image, apply transfer ops and store in rawImage */
- _mesa_texstore_rgba8888(ctx, 2, GL_RGBA,
- &_mesa_texformat_rgba8888_rev, rawImage,
- 0, 0, 0, /* dstX/Y/Zoffset */
- width * rawBytes, /* dstRowStride */
- &dstImageOffsets,
- width, height, 1,
- format, type, pixels, packing);
+ _mesa_texstore(ctx, 2, GL_RGBA,
+ MESA_FORMAT_RGBA8888_REV, rawImage,
+ 0, 0, 0, /* dstX/Y/Zoffset */
+ width * rawBytes, /* dstRowStride */
+ &dstImageOffsets,
+ width, height, 1,
+ format, type, pixels, packing);
_mesa_rescale_teximage2d(rawBytes,
width,
newWidth * rawBytes, /* dst stride */
width, height, /* src */
newWidth, newHeight, /* dst */
rawImage /*src*/, tempImage /*dst*/ );
- texImage->TexFormat->StoreImage(ctx, 2, texImage->_BaseFormat,
- texImage->TexFormat, texImage->Data,
- xoffset * mml->wScale, yoffset * mml->hScale, 0, /* dstX/Y/Zoffset */
- dstRowStride,
- &dstImageOffsets,
- newWidth, newHeight, 1,
- GL_RGBA, CHAN_TYPE, tempImage, &ctx->DefaultPacking);
+ _mesa_texstore(ctx, 2, texImage->_BaseFormat,
+ texImage->TexFormat, texImage->Data,
+ xoffset * mml->wScale, yoffset * mml->hScale, 0, /* dstX/Y/Zoffset */
+ dstRowStride,
+ &dstImageOffsets,
+ newWidth, newHeight, 1,
+ GL_RGBA, CHAN_TYPE, tempImage, &ctx->DefaultPacking);
FREE(rawImage);
}
@@ -1357,7 +1364,7 @@ tdfxTexImage2D(GLcontext *ctx, GLenum target, GLint level,
* be correct, since it would mess with "compressedSize".
* Ditto for GL_RGBA[4]_S3TC, which is always mapped to DXT3.
*/
- if (texImage->IsCompressed) {
+ if (_mesa_is_format_compressed(texImage->TexFormat)) {
switch (internalFormat) {
case GL_COMPRESSED_RGB_S3TC_DXT1_EXT:
case GL_RGB_S3TC:
@@ -1384,30 +1391,22 @@ tdfxTexImage2D(GLcontext *ctx, GLenum target, GLint level,
}
if (texNapalm) {
texImage->InternalFormat = internalFormat = texNapalm;
- texImage->IsCompressed = GL_TRUE;
+ _mesa_is_format_compressed(texImage->TexFormat) = GL_TRUE;
}
}
#endif
- /* choose the texture format */
- assert(ctx->Driver.ChooseTextureFormat);
- texImage->TexFormat = (*ctx->Driver.ChooseTextureFormat)(ctx,
- internalFormat, format, type);
- assert(texImage->TexFormat);
- mesaFormat = texImage->TexFormat->MesaFormat;
+ mesaFormat = texImage->TexFormat;
mml->glideFormat = fxGlideFormat(mesaFormat);
ti->info.format = mml->glideFormat;
texImage->FetchTexelc = fxFetchFunction(mesaFormat);
- texelBytes = texImage->TexFormat->TexelBytes;
-
- if (texImage->IsCompressed) {
- texImage->CompressedSize = _mesa_compressed_texture_size(ctx,
- mml->width,
- mml->height,
- 1,
- mesaFormat);
- dstRowStride = _mesa_compressed_row_stride(texImage->TexFormat->MesaFormat, mml->width);
- texImage->Data = _mesa_alloc_texmemory(texImage->CompressedSize);
+ texelBytes = _mesa_get_format_bytes(texImage->TexFormat);
+
+ if (_mesa_is_format_compressed(texImage->TexFormat)) {
+ GLuint compressedSize = _mesa_format_image_size(mesaFormat, mml->width,
+ mml->height, 1);
+ dstRowStride = _mesa_format_row_stride(texImage->TexFormat, mml->width);
+ texImage->Data = _mesa_alloc_texmemory(compressedSize);
} else {
dstRowStride = mml->width * texelBytes;
texImage->Data = _mesa_alloc_texmemory(mml->width * mml->height * texelBytes);
@@ -1437,13 +1436,13 @@ tdfxTexImage2D(GLcontext *ctx, GLenum target, GLint level,
else {
/* no rescaling needed */
/* unpack image, apply transfer ops and store in texImage->Data */
- texImage->TexFormat->StoreImage(ctx, 2, texImage->_BaseFormat,
- texImage->TexFormat, texImage->Data,
- 0, 0, 0, /* dstX/Y/Zoffset */
- dstRowStride,
- texImage->ImageOffsets,
- width, height, 1,
- format, type, pixels, packing);
+ _mesa_texstore(ctx, 2, texImage->_BaseFormat,
+ texImage->TexFormat, texImage->Data,
+ 0, 0, 0, /* dstX/Y/Zoffset */
+ dstRowStride,
+ texImage->ImageOffsets,
+ width, height, 1,
+ format, type, pixels, packing);
}
}
@@ -1482,9 +1481,9 @@ tdfxTexSubImage2D(GLcontext *ctx, GLenum target, GLint level,
assert(texImage->Data); /* must have an existing texture image! */
assert(texImage->_BaseFormat);
- texelBytes = texImage->TexFormat->TexelBytes;
- if (texImage->IsCompressed) {
- dstRowStride = _mesa_compressed_row_stride(texImage->TexFormat->MesaFormat, mml->width);
+ texelBytes = _mesa_get_format_bytes(texImage->TexFormat);
+ if (_mesa_is_format_compressed(texImage->TexFormat)) {
+ dstRowStride = _mesa_format_row_stride(texImage->TexFormat, mml->width);
} else {
dstRowStride = mml->width * texelBytes;
}
@@ -1507,13 +1506,13 @@ tdfxTexSubImage2D(GLcontext *ctx, GLenum target, GLint level,
}
else {
/* no rescaling needed */
- texImage->TexFormat->StoreImage(ctx, 2, texImage->_BaseFormat,
- texImage->TexFormat, texImage->Data,
- xoffset, yoffset, 0,
- dstRowStride,
- texImage->ImageOffsets,
- width, height, 1,
- format, type, pixels, packing);
+ _mesa_texstore(ctx, 2, texImage->_BaseFormat,
+ texImage->TexFormat, texImage->Data,
+ xoffset, yoffset, 0,
+ dstRowStride,
+ texImage->ImageOffsets,
+ width, height, 1,
+ format, type, pixels, packing);
}
ti->reloadImages = GL_TRUE; /* signal the image needs to be reloaded */
@@ -1572,7 +1571,8 @@ tdfxCompressedTexImage2D (GLcontext *ctx, GLenum target,
tdfxContextPtr fxMesa = TDFX_CONTEXT(ctx);
tdfxTexInfo *ti;
tdfxMipMapLevel *mml;
- GLuint mesaFormat;
+ gl_format mesaFormat;
+ GLuint compressedSize;
if (TDFX_DEBUG & DEBUG_VERBOSE_DRI) {
fprintf(stderr, "tdfxCompressedTexImage2D: id=%d int 0x%x %dx%d\n",
@@ -1585,8 +1585,6 @@ tdfxCompressedTexImage2D (GLcontext *ctx, GLenum target,
return;
}
- assert(texImage->IsCompressed);
-
ti = TDFX_TEXTURE_DATA(texObj);
if (!ti) {
texObj->DriverData = fxAllocTexObjData(fxMesa);
@@ -1615,28 +1613,19 @@ tdfxCompressedTexImage2D (GLcontext *ctx, GLenum target,
mml->height = height * mml->hScale;
- /* choose the texture format */
- assert(ctx->Driver.ChooseTextureFormat);
- texImage->TexFormat = (*ctx->Driver.ChooseTextureFormat)(ctx,
- internalFormat, -1/*format*/, -1/*type*/);
- assert(texImage->TexFormat);
-
/* Determine the appropriate Glide texel format,
* given the user's internal texture format hint.
*/
- mesaFormat = texImage->TexFormat->MesaFormat;
+ mesaFormat = texImage->TexFormat;
mml->glideFormat = fxGlideFormat(mesaFormat);
ti->info.format = mml->glideFormat;
texImage->FetchTexelc = fxFetchFunction(mesaFormat);
/* allocate new storage for texture image, if needed */
if (!texImage->Data) {
- texImage->CompressedSize = _mesa_compressed_texture_size(ctx,
- mml->width,
- mml->height,
- 1,
- mesaFormat);
- texImage->Data = _mesa_alloc_texmemory(texImage->CompressedSize);
+ compressedSize = _mesa_format_image_size(mesaFormat, mml->width,
+ mml->height, 1);
+ texImage->Data = _mesa_alloc_texmemory(compressedSize);
if (!texImage->Data) {
_mesa_error(ctx, GL_OUT_OF_MEMORY, "glCompressedTexImage2D");
return;
@@ -1659,10 +1648,10 @@ tdfxCompressedTexImage2D (GLcontext *ctx, GLenum target,
* we replicate the data over the padded area.
* For now, we take 2) + 3) but texelfetchers will be wrong!
*/
- const GLuint mesaFormat = texImage->TexFormat->MesaFormat;
- GLuint srcRowStride = _mesa_compressed_row_stride(mesaFormat, width);
+ const GLuint mesaFormat = texImage->TexFormat;
+ GLuint srcRowStride = _mesa_format_row_stride(mesaFormat, width);
- GLuint destRowStride = _mesa_compressed_row_stride(mesaFormat,
+ GLuint destRowStride = _mesa_format_row_stride(mesaFormat,
mml->width);
_mesa_upscale_teximage2d(srcRowStride, (height+3) / 4,
@@ -1671,7 +1660,7 @@ tdfxCompressedTexImage2D (GLcontext *ctx, GLenum target,
texImage->Data);
ti->padded = GL_TRUE;
} else {
- MEMCPY(texImage->Data, data, texImage->CompressedSize);
+ MEMCPY(texImage->Data, data, compressedSize);
}
RevalidateTexture(ctx, texObj);
@@ -1696,7 +1685,7 @@ tdfxCompressedTexSubImage2D( GLcontext *ctx, GLenum target,
GLint destRowStride, srcRowStride;
GLint i, rows;
GLubyte *dest;
- const GLuint mesaFormat = texImage->TexFormat->MesaFormat;
+ const GLuint mesaFormat = texImage->TexFormat;
if (TDFX_DEBUG & DEBUG_VERBOSE_DRI) {
fprintf(stderr, "tdfxCompressedTexSubImage2D: id=%d\n", texObj->Name);
@@ -1707,9 +1696,9 @@ tdfxCompressedTexSubImage2D( GLcontext *ctx, GLenum target,
mml = TDFX_TEXIMAGE_DATA(texImage);
assert(mml);
- srcRowStride = _mesa_compressed_row_stride(mesaFormat, width);
+ srcRowStride = _mesa_format_row_stride(mesaFormat, width);
- destRowStride = _mesa_compressed_row_stride(mesaFormat, mml->width);
+ destRowStride = _mesa_format_row_stride(mesaFormat, mml->width);
dest = _mesa_compressed_image_address(xoffset, yoffset, 0,
mesaFormat,
mml->width,
@@ -1727,9 +1716,9 @@ tdfxCompressedTexSubImage2D( GLcontext *ctx, GLenum target,
* see fxDDCompressedTexImage2D for caveats
*/
if (mml->wScale != 1 || mml->hScale != 1) {
- srcRowStride = _mesa_compressed_row_stride(mesaFormat, texImage->Width);
+ srcRowStride = _mesa_format_row_stride(mesaFormat, texImage->Width);
- destRowStride = _mesa_compressed_row_stride(mesaFormat, mml->width);
+ destRowStride = _mesa_format_row_stride(mesaFormat, mml->width);
_mesa_upscale_teximage2d(srcRowStride, texImage->Height / 4,
destRowStride, mml->height / 4,
1, texImage->Data, destRowStride,