summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--configure.ac6
-rw-r--r--src/tdfx_context.c6
-rw-r--r--src/tdfx_dd.c9
-rw-r--r--src/tdfx_lock.c1
-rw-r--r--src/tdfx_pixels.c1
-rw-r--r--src/tdfx_screen.c28
-rw-r--r--src/tdfx_state.c5
-rw-r--r--src/tdfx_tex.c373
-rw-r--r--src/tdfx_texman.c1
-rw-r--r--src/tdfx_texstate.c3
-rw-r--r--src/tdfx_vb.c5
11 files changed, 175 insertions, 263 deletions
diff --git a/configure.ac b/configure.ac
index ffc7783..b92a890 100644
--- a/configure.ac
+++ b/configure.ac
@@ -1,7 +1,7 @@
# Process this file with autoconf to produce a configure script
AC_PREREQ(2.57)
-AC_INIT([mesa-dri-tdfx], 7.5.0, [], mesa-dri-tdfx)
+AC_INIT([mesa-dri-tdfx], 7.7.0, [], mesa-dri-tdfx)
AM_INIT_AUTOMAKE([dist-bzip2])
@@ -16,8 +16,8 @@ AC_PROG_CC
AC_HEADER_STDC
PKG_CHECK_MODULES([DRM], [libdrm >= 2.3.0])
-PKG_CHECK_MODULES([DRI], [libmesadri >= 7.5.0 libmesadri < 7.7.0
- libmesadricommon >= 7.5.0 libmesadricommon < 7.7.0])
+PKG_CHECK_MODULES([DRI], [libmesadri >= 7.7.0 libmesadri < 7.8.0
+ libmesadricommon >= 7.7.0 libmesadricommon < 7.8.0])
AC_OUTPUT([
Makefile
diff --git a/src/tdfx_context.c b/src/tdfx_context.c
index 68b5027..e742d41 100644
--- a/src/tdfx_context.c
+++ b/src/tdfx_context.c
@@ -68,13 +68,13 @@
#define need_GL_EXT_paletted_texture
/* #define need_GL_EXT_secondary_color */
/* #define need_GL_NV_vertex_program */
-#include "extension_helper.h"
+#include "main/remap_helper.h"
/**
* Common extension strings exported by all cards
*/
-const struct dri_extension card_extensions[] =
+static const struct dri_extension card_extensions[] =
{
{ "GL_ARB_occlusion_query", GL_ARB_occlusion_query_functions },
{ "GL_ARB_texture_mirrored_repeat", NULL },
@@ -107,7 +107,7 @@ const struct dri_extension card_extensions[] =
/**
* Extension strings exported only by Naplam (e.g., Voodoo4 & Voodoo5) cards.
*/
-const struct dri_extension napalm_extensions[] =
+static const struct dri_extension napalm_extensions[] =
{
{ "GL_ARB_texture_env_combine", NULL },
{ "GL_EXT_blend_equation_separate", GL_EXT_blend_equation_separate_functions },
diff --git a/src/tdfx_dd.c b/src/tdfx_dd.c
index 8472df6..2cbbeb8 100644
--- a/src/tdfx_dd.c
+++ b/src/tdfx_dd.c
@@ -35,17 +35,10 @@
#include "tdfx_context.h"
#include "tdfx_dd.h"
#include "tdfx_lock.h"
-#include "tdfx_vb.h"
#include "tdfx_pixels.h"
#include "utils.h"
#include "main/context.h"
-#include "main/enums.h"
-#include "main/framebuffer.h"
-#include "swrast/swrast.h"
-#if defined(USE_X86_ASM)
-#include "x86/common_x86_asm.h"
-#endif
#define DRIVER_DATE "20061113"
@@ -91,7 +84,7 @@ static const GLubyte *tdfxDDGetString( GLcontext *ctx, GLenum name )
else {
/* unexpected result: replace spaces with hyphens */
int i;
- for (i = 0; hardware[i] && (i < sizeof(hardware)); i++) {
+ for (i = 0; i < sizeof(hardware) && hardware[i]; i++) {
if (hardware[i] == ' ' || hardware[i] == '\t') {
hardware[i] = '-';
}
diff --git a/src/tdfx_lock.c b/src/tdfx_lock.c
index 17cdc51..c00f537 100644
--- a/src/tdfx_lock.c
+++ b/src/tdfx_lock.c
@@ -38,7 +38,6 @@
#include "tdfx_state.h"
#include "tdfx_render.h"
#include "tdfx_texman.h"
-#include "tdfx_tris.h"
#include "drirenderbuffer.h"
diff --git a/src/tdfx_pixels.c b/src/tdfx_pixels.c
index 18729d5..c213e67 100644
--- a/src/tdfx_pixels.c
+++ b/src/tdfx_pixels.c
@@ -38,7 +38,6 @@
#include "tdfx_context.h"
#include "tdfx_dd.h"
#include "tdfx_lock.h"
-#include "tdfx_vb.h"
#include "tdfx_pixels.h"
#include "tdfx_render.h"
diff --git a/src/tdfx_screen.c b/src/tdfx_screen.c
index 58bd48b..9e5f2b8 100644
--- a/src/tdfx_screen.c
+++ b/src/tdfx_screen.c
@@ -36,9 +36,7 @@
#include "tdfx_dri.h"
#include "tdfx_context.h"
#include "tdfx_lock.h"
-#include "tdfx_vb.h"
#include "tdfx_span.h"
-#include "tdfx_tris.h"
#include "main/framebuffer.h"
#include "main/renderbuffer.h"
@@ -69,9 +67,6 @@ static const __DRIextension *tdfxExtensions[] = {
static const GLuint __driNConfigOptions = 1;
-extern const struct dri_extension card_extensions[];
-extern const struct dri_extension napalm_extensions[];
-
static GLboolean
tdfxCreateScreen( __DRIscreenPrivate *sPriv )
{
@@ -173,7 +168,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);
@@ -181,7 +176,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);
@@ -191,7 +186,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);
@@ -199,7 +194,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);
@@ -208,7 +203,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);
@@ -418,19 +413,6 @@ tdfxInitScreen(__DRIscreen *psp)
&psp->drm_version, & drm_expected ) )
return NULL;
- /* Calling driInitExtensions here, with a NULL context pointer,
- * does not actually enable the extensions. It just makes sure
- * that all the dispatch offsets for all the extensions that
- * *might* be enables are known. This is needed because the
- * dispatch offsets need to be known when _mesa_context_create is
- * called, but we can't enable the extensions until we have a
- * context pointer.
- *
- * Hello chicken. Hello egg. How are you two today?
- */
- driInitExtensions( NULL, card_extensions, GL_FALSE );
- driInitExtensions( NULL, napalm_extensions, GL_FALSE );
-
if (!tdfxInitDriver(psp))
return NULL;
diff --git a/src/tdfx_state.c b/src/tdfx_state.c
index 591df8a..16b0bfc 100644
--- a/src/tdfx_state.c
+++ b/src/tdfx_state.c
@@ -40,9 +40,6 @@
#include "main/mtypes.h"
#include "main/colormac.h"
-#include "main/texformat.h"
-#include "main/texstore.h"
-#include "main/teximage.h"
#include "swrast/swrast.h"
#include "vbo/vbo.h"
@@ -52,11 +49,9 @@
#include "tdfx_context.h"
#include "tdfx_state.h"
-#include "tdfx_vb.h"
#include "tdfx_tex.h"
#include "tdfx_texman.h"
#include "tdfx_texstate.h"
-#include "tdfx_tris.h"
#include "tdfx_render.h"
diff --git a/src/tdfx_tex.c b/src/tdfx_tex.c
index 1f7257e..e31ae97 100644
--- a/src/tdfx_tex.c
+++ b/src/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);
}
@@ -176,6 +175,54 @@ logbase2(int n)
}
+static void
+tdfxGenerateMipmap(GLcontext *ctx, GLenum target,
+ struct gl_texture_object *texObj)
+{
+ GLint mipWidth, mipHeight;
+ tdfxMipMapLevel *mip;
+ struct gl_texture_image *mipImage; /* the new/next image */
+ struct gl_texture_image *texImage;
+ const GLint maxLevels = _mesa_max_texture_levels(ctx, texObj->Target);
+ GLint level = texObj->BaseLevel;
+ GLsizei width, height, texelBytes;
+ const tdfxMipMapLevel *mml;
+
+ texImage = _mesa_get_tex_image(ctx, texObj, target, level);
+ texelBytes = _mesa_get_format_bytes(texImage->TexFormat);
+
+ mml = TDFX_TEXIMAGE_DATA(texImage);
+
+ width = texImage->Width;
+ height = texImage->Height;
+ while (level < texObj->MaxLevel && level < maxLevels - 1) {
+ mipWidth = width / 2;
+ if (!mipWidth) {
+ mipWidth = 1;
+ }
+ mipHeight = height / 2;
+ if (!mipHeight) {
+ mipHeight = 1;
+ }
+ if ((mipWidth == width) && (mipHeight == height)) {
+ break;
+ }
+ ++level;
+ mipImage = _mesa_select_tex_image(ctx, texObj, target, level);
+ mip = TDFX_TEXIMAGE_DATA(mipImage);
+ _mesa_halve2x2_teximage2d(ctx,
+ texImage,
+ texelBytes,
+ mml->width, mml->height,
+ texImage->Data, mipImage->Data);
+ texImage = mipImage;
+ mml = mip;
+ width = mipWidth;
+ height = mipHeight;
+ }
+}
+
+
/*
* Compute various texture image parameters.
* Input: w, h - source texture width and height
@@ -712,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 )
{
@@ -726,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:
@@ -734,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:
@@ -744,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 */
@@ -793,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:
@@ -804,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;
}
}
@@ -1078,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);
+ */
}
@@ -1091,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);
+ */
}
@@ -1104,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);
+ */
}
@@ -1117,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);
+ */
}
@@ -1178,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 */
@@ -1208,6 +1262,7 @@ adjust2DRatio (GLcontext *ctx,
} else {
const GLint rawBytes = 4;
GLvoid *rawImage = MALLOC(width * height * rawBytes);
+
if (!rawImage) {
return GL_FALSE;
}
@@ -1217,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);
}
@@ -1309,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:
@@ -1336,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);
@@ -1389,53 +1436,14 @@ 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);
}
-
- /* GL_SGIS_generate_mipmap */
- if (level == texObj->BaseLevel && texObj->GenerateMipmap) {
- GLint mipWidth, mipHeight;
- tdfxMipMapLevel *mip;
- struct gl_texture_image *mipImage;
- const GLint maxLevels = _mesa_max_texture_levels(ctx, texObj->Target);
-
- assert(!texImage->IsCompressed);
-
- while (level < texObj->MaxLevel && level < maxLevels - 1) {
- mipWidth = width / 2;
- if (!mipWidth) {
- mipWidth = 1;
- }
- mipHeight = height / 2;
- if (!mipHeight) {
- mipHeight = 1;
- }
- if ((mipWidth == width) && (mipHeight == height)) {
- break;
- }
- _mesa_TexImage2D(target, ++level, internalFormat,
- mipWidth, mipHeight, border,
- format, type,
- NULL);
- mipImage = _mesa_select_tex_image(ctx, texObj, target, level);
- mip = TDFX_TEXIMAGE_DATA(mipImage);
- _mesa_halve2x2_teximage2d(ctx,
- texImage,
- texelBytes,
- mml->width, mml->height,
- texImage->Data, mipImage->Data);
- texImage = mipImage;
- mml = mip;
- width = mipWidth;
- height = mipHeight;
- }
- }
}
RevalidateTexture(ctx, texObj);
@@ -1473,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;
}
@@ -1498,53 +1506,15 @@ 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);
}
- /* GL_SGIS_generate_mipmap */
- if (level == texObj->BaseLevel && texObj->GenerateMipmap) {
- GLint mipWidth, mipHeight;
- tdfxMipMapLevel *mip;
- struct gl_texture_image *mipImage;
- const GLint maxLevels = _mesa_max_texture_levels(ctx, texObj->Target);
-
- assert(!texImage->IsCompressed);
-
- width = texImage->Width;
- height = texImage->Height;
- while (level < texObj->MaxLevel && level < maxLevels - 1) {
- mipWidth = width / 2;
- if (!mipWidth) {
- mipWidth = 1;
- }
- mipHeight = height / 2;
- if (!mipHeight) {
- mipHeight = 1;
- }
- if ((mipWidth == width) && (mipHeight == height)) {
- break;
- }
- ++level;
- mipImage = _mesa_select_tex_image(ctx, texObj, target, level);
- mip = TDFX_TEXIMAGE_DATA(mipImage);
- _mesa_halve2x2_teximage2d(ctx,
- texImage,
- texelBytes,
- mml->width, mml->height,
- texImage->Data, mipImage->Data);
- texImage = mipImage;
- mml = mip;
- width = mipWidth;
- height = mipHeight;
- }
- }
-
ti->reloadImages = GL_TRUE; /* signal the image needs to be reloaded */
fxMesa->new_state |= TDFX_NEW_TEXTURE; /* XXX this might be a bit much */
}
@@ -1601,7 +1571,8 @@ tdfxCompressedTexImage2D (GLcontext *ctx, GLenum target,
tdfxContextPtr fxMesa = TDFX_CONTEXT(ctx);
tdfxTexInfo *ti;
tdfxMipMapLevel *mml;
- GLuint mesaFormat;
+ gl_format mesaFormat;
+ GLuint compressedSize = 0;
if (TDFX_DEBUG & DEBUG_VERBOSE_DRI) {
fprintf(stderr, "tdfxCompressedTexImage2D: id=%d int 0x%x %dx%d\n",
@@ -1614,8 +1585,6 @@ tdfxCompressedTexImage2D (GLcontext *ctx, GLenum target,
return;
}
- assert(texImage->IsCompressed);
-
ti = TDFX_TEXTURE_DATA(texObj);
if (!ti) {
texObj->DriverData = fxAllocTexObjData(fxMesa);
@@ -1644,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;
@@ -1688,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,
@@ -1700,12 +1660,7 @@ tdfxCompressedTexImage2D (GLcontext *ctx, GLenum target,
texImage->Data);
ti->padded = GL_TRUE;
} else {
- MEMCPY(texImage->Data, data, texImage->CompressedSize);
- }
-
- /* GL_SGIS_generate_mipmap */
- if (level == texObj->BaseLevel && texObj->GenerateMipmap) {
- assert(!texImage->IsCompressed);
+ MEMCPY(texImage->Data, data, compressedSize);
}
RevalidateTexture(ctx, texObj);
@@ -1730,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);
@@ -1741,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,
@@ -1761,20 +1716,15 @@ 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,
texImage->Data);
}
- /* GL_SGIS_generate_mipmap */
- if (level == texObj->BaseLevel && texObj->GenerateMipmap) {
- assert(!texImage->IsCompressed);
- }
-
RevalidateTexture(ctx, texObj);
ti->reloadImages = GL_TRUE;
@@ -1914,4 +1864,5 @@ void tdfxInitTextureFuncs( struct dd_function_table *functions )
functions->CompressedTexImage2D = tdfxCompressedTexImage2D;
functions->CompressedTexSubImage2D = tdfxCompressedTexSubImage2D;
functions->UpdateTexturePalette = tdfxUpdateTexturePalette;
+ functions->GenerateMipmap = tdfxGenerateMipmap;
}
diff --git a/src/tdfx_texman.c b/src/tdfx_texman.c
index 35636ee..726cc58 100644
--- a/src/tdfx_texman.c
+++ b/src/tdfx_texman.c
@@ -35,7 +35,6 @@
*/
#include "tdfx_context.h"
-#include "tdfx_tex.h"
#include "tdfx_texman.h"
#include "main/texobj.h"
#include "main/hash.h"
diff --git a/src/tdfx_texstate.c b/src/tdfx_texstate.c
index bbd2c8c..6658b4d 100644
--- a/src/tdfx_texstate.c
+++ b/src/tdfx_texstate.c
@@ -38,7 +38,6 @@
*/
#include "tdfx_state.h"
-#include "tdfx_tex.h"
#include "tdfx_texman.h"
#include "tdfx_texstate.h"
@@ -1314,7 +1313,7 @@ SetupDoubleTexEnvVoodoo3(GLcontext *ctx, int tmu0,
fxMesa->TexCombine[0].InvertRGB = FXFALSE;
fxMesa->TexCombine[0].InvertAlpha = FXFALSE;
- if ((baseFormat0 == GL_RGB) && (baseFormat0 == GL_LUMINANCE)) {
+ if ((baseFormat0 == GL_RGB) || (baseFormat0 == GL_LUMINANCE)) {
fxMesa->AlphaCombine.Function = GR_COMBINE_FUNCTION_LOCAL;
fxMesa->AlphaCombine.Factor = GR_COMBINE_FACTOR_NONE;
fxMesa->AlphaCombine.Local = locala;
diff --git a/src/tdfx_vb.c b/src/tdfx_vb.c
index 4928802..d6fcf98 100644
--- a/src/tdfx_vb.c
+++ b/src/tdfx_vb.c
@@ -29,13 +29,8 @@
#include "main/macros.h"
#include "main/colormac.h"
-#include "math/m_translate.h"
-#include "swrast_setup/swrast_setup.h"
-
#include "tdfx_context.h"
#include "tdfx_vb.h"
-#include "tdfx_tris.h"
-#include "tdfx_state.h"
#include "tdfx_render.h"
static void copy_pv( GLcontext *ctx, GLuint edst, GLuint esrc )