summaryrefslogtreecommitdiffstats
path: root/src/mesa/drivers/dri/savage
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/savage
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/savage')
-rw-r--r--src/mesa/drivers/dri/savage/savage_xmesa.c14
-rw-r--r--src/mesa/drivers/dri/savage/savagespan.c18
-rw-r--r--src/mesa/drivers/dri/savage/savagetex.c150
3 files changed, 104 insertions, 78 deletions
diff --git a/src/mesa/drivers/dri/savage/savage_xmesa.c b/src/mesa/drivers/dri/savage/savage_xmesa.c
index 0fccf50a03e..d307b81e8ec 100644
--- a/src/mesa/drivers/dri/savage/savage_xmesa.c
+++ b/src/mesa/drivers/dri/savage/savage_xmesa.c
@@ -436,7 +436,7 @@ savageCreateContext( const __GLcontextModes *mesaVis,
if (ctx->Const.MaxTextureLevels <= 6) { /*spec requires at least 64x64*/
__driUtilMessage("Not enough texture memory. "
"Falling back to indirect rendering.");
- Xfree(imesa);
+ _mesa_free(imesa);
return GL_FALSE;
}
@@ -574,7 +574,7 @@ savageDestroyContext(__DRIcontextPrivate *driContextPriv)
_mesa_destroy_context(imesa->glCtx);
/* no longer use vertex_dma_buf*/
- Xfree(imesa);
+ _mesa_free(imesa);
}
}
@@ -602,7 +602,7 @@ savageCreateBuffer( __DRIscreenPrivate *driScrnPriv,
{
driRenderbuffer *frontRb
- = driNewRenderbuffer(GL_RGBA,
+ = driNewRenderbuffer(MESA_FORMAT_ARGB8888,
(GLubyte *) screen->aperture.map
+ 0x01000000 * TARGET_FRONT,
screen->cpp,
@@ -615,7 +615,7 @@ savageCreateBuffer( __DRIscreenPrivate *driScrnPriv,
if (mesaVis->doubleBufferMode) {
driRenderbuffer *backRb
- = driNewRenderbuffer(GL_RGBA,
+ = driNewRenderbuffer(MESA_FORMAT_ARGB8888,
(GLubyte *) screen->aperture.map
+ 0x01000000 * TARGET_BACK,
screen->cpp,
@@ -628,7 +628,7 @@ savageCreateBuffer( __DRIscreenPrivate *driScrnPriv,
if (mesaVis->depthBits == 16) {
driRenderbuffer *depthRb
- = driNewRenderbuffer(GL_DEPTH_COMPONENT16,
+ = driNewRenderbuffer(MESA_FORMAT_Z16,
(GLubyte *) screen->aperture.map
+ 0x01000000 * TARGET_DEPTH,
screen->zpp,
@@ -639,7 +639,7 @@ savageCreateBuffer( __DRIscreenPrivate *driScrnPriv,
}
else if (mesaVis->depthBits == 24) {
driRenderbuffer *depthRb
- = driNewRenderbuffer(GL_DEPTH_COMPONENT24,
+ = driNewRenderbuffer(MESA_FORMAT_S8_Z24,
(GLubyte *) screen->aperture.map
+ 0x01000000 * TARGET_DEPTH,
screen->zpp,
@@ -651,7 +651,7 @@ savageCreateBuffer( __DRIscreenPrivate *driScrnPriv,
if (mesaVis->stencilBits > 0 && !swStencil) {
driRenderbuffer *stencilRb
- = driNewRenderbuffer(GL_STENCIL_INDEX8_EXT,
+ = driNewRenderbuffer(MESA_FORMAT_S8,
(GLubyte *) screen->aperture.map
+ 0x01000000 * TARGET_DEPTH,
screen->zpp,
diff --git a/src/mesa/drivers/dri/savage/savagespan.c b/src/mesa/drivers/dri/savage/savagespan.c
index 9615e34013c..3bb6fbcc63c 100644
--- a/src/mesa/drivers/dri/savage/savagespan.c
+++ b/src/mesa/drivers/dri/savage/savagespan.c
@@ -255,15 +255,13 @@ void
savageSetSpanFunctions(driRenderbuffer *drb, const GLvisual *vis,
GLboolean float_depth)
{
- if (drb->Base.InternalFormat == GL_RGBA) {
- if (vis->redBits == 5 && vis->greenBits == 6 && vis->blueBits == 5) {
- savageInitPointers_565(&drb->Base);
- }
- else {
- savageInitPointers_8888(&drb->Base);
- }
+ if (drb->Base.Format == MESA_FORMAT_RGB565) {
+ savageInitPointers_565(&drb->Base);
+ }
+ else if (drb->Base.Format == MESA_FORMAT_ARGB8888) {
+ savageInitPointers_8888(&drb->Base);
}
- else if (drb->Base.InternalFormat == GL_DEPTH_COMPONENT16) {
+ else if (drb->Base.Format == MESA_FORMAT_Z16) {
if (float_depth) {
savageInitDepthPointers_z16f(&drb->Base);
}
@@ -271,7 +269,7 @@ savageSetSpanFunctions(driRenderbuffer *drb, const GLvisual *vis,
savageInitDepthPointers_z16(&drb->Base);
}
}
- else if (drb->Base.InternalFormat == GL_DEPTH_COMPONENT24) {
+ else if (drb->Base.Format == MESA_FORMAT_S8_Z24) {
if (float_depth) {
savageInitDepthPointers_s8_z24f(&drb->Base);
}
@@ -279,7 +277,7 @@ savageSetSpanFunctions(driRenderbuffer *drb, const GLvisual *vis,
savageInitDepthPointers_s8_z24(&drb->Base);
}
}
- else if (drb->Base.InternalFormat == GL_STENCIL_INDEX8_EXT) {
+ else if (drb->Base.Format == MESA_FORMAT_S8) {
savageInitStencilPointers_s8_z24(&drb->Base);
}
}
diff --git a/src/mesa/drivers/dri/savage/savagetex.c b/src/mesa/drivers/dri/savage/savagetex.c
index fe239e1b05f..6c97bb6c702 100644
--- a/src/mesa/drivers/dri/savage/savagetex.c
+++ b/src/mesa/drivers/dri/savage/savagetex.c
@@ -23,29 +23,24 @@
*/
-#include <stdlib.h>
-#include <stdio.h>
-
-#include <GL/gl.h>
-
+#include "main/context.h"
#include "main/mm.h"
-#include "savagecontext.h"
-#include "savagetex.h"
-#include "savagetris.h"
-#include "savageioctl.h"
-#include "main/simple_list.h"
-#include "main/enums.h"
-#include "savage_bci.h"
-
#include "main/macros.h"
-#include "main/texformat.h"
#include "main/texstore.h"
#include "main/texobj.h"
#include "main/convolve.h"
#include "main/colormac.h"
+#include "main/simple_list.h"
+#include "main/enums.h"
#include "swrast/swrast.h"
+#include "savagecontext.h"
+#include "savagetex.h"
+#include "savagetris.h"
+#include "savageioctl.h"
+#include "savage_bci.h"
+
#include "xmlpool.h"
#define TILE_INDEX_DXT1 0
@@ -527,6 +522,11 @@ savageAllocTexObj( struct gl_texture_object *texObj )
* components to white. This way we get the correct result.
*/
+#if 0
+/* Using MESA_FORMAT_RGBA8888 to store alpha-only textures should
+ * work but is space inefficient.
+ */
+
static GLboolean
_savage_texstore_a1114444(TEXSTORE_PARAMS);
@@ -590,10 +590,11 @@ _savage_texstore_a1114444(TEXSTORE_PARAMS)
return GL_FALSE;
_mesa_adjust_image_for_convolution(ctx, dims, &srcWidth, &srcHeight);
for (img = 0; img < srcDepth; img++) {
+ GLuint texelBytes = _mesa_get_format_bytes(dstFormat);
GLubyte *dstRow = (GLubyte *) dstAddr
- + dstImageOffsets[dstZoffset + img] * dstFormat->TexelBytes
+ + dstImageOffsets[dstZoffset + img] * texelBytes
+ dstYoffset * dstRowStride
- + dstXoffset * dstFormat->TexelBytes;
+ + dstXoffset * texelBytes;
for (row = 0; row < srcHeight; row++) {
GLushort *dstUI = (GLushort *) dstRow;
for (col = 0; col < srcWidth; col++) {
@@ -629,10 +630,11 @@ _savage_texstore_a1118888(TEXSTORE_PARAMS)
return GL_FALSE;
_mesa_adjust_image_for_convolution(ctx, dims, &srcWidth, &srcHeight);
for (img = 0; img < srcDepth; img++) {
+ GLuint texelBytes = _mesa_get_format_bytes(dstFormat);
GLubyte *dstRow = (GLubyte *) dstAddr
- + dstImageOffsets[dstZoffset + img] * dstFormat->TexelBytes
+ + dstImageOffsets[dstZoffset + img] * texelBytes
+ dstYoffset * dstRowStride
- + dstXoffset * dstFormat->TexelBytes;
+ + dstXoffset * texelBytes;
for (row = 0; row < srcHeight; row++) {
GLuint *dstUI = (GLuint *) dstRow;
for (col = 0; col < srcWidth; col++) {
@@ -647,10 +649,11 @@ _savage_texstore_a1118888(TEXSTORE_PARAMS)
return GL_TRUE;
}
+#endif
/* Called by the _mesa_store_teximage[123]d() functions. */
-static const struct gl_texture_format *
+static gl_format
savageChooseTextureFormat( GLcontext *ctx, GLint internalFormat,
GLenum format, GLenum type )
{
@@ -669,15 +672,15 @@ savageChooseTextureFormat( GLcontext *ctx, GLint internalFormat,
switch ( type ) {
case GL_UNSIGNED_INT_10_10_10_2:
case GL_UNSIGNED_INT_2_10_10_10_REV:
- return do32bpt ? &_mesa_texformat_argb8888 : &_mesa_texformat_argb1555;
+ return do32bpt ? MESA_FORMAT_ARGB8888 : MESA_FORMAT_ARGB1555;
case GL_UNSIGNED_SHORT_4_4_4_4:
case GL_UNSIGNED_SHORT_4_4_4_4_REV:
- return &_mesa_texformat_argb4444;
+ return MESA_FORMAT_ARGB4444;
case GL_UNSIGNED_SHORT_5_5_5_1:
case GL_UNSIGNED_SHORT_1_5_5_5_REV:
- return &_mesa_texformat_argb1555;
+ return MESA_FORMAT_ARGB1555;
default:
- return do32bpt ? &_mesa_texformat_argb8888 : &_mesa_texformat_argb4444;
+ return do32bpt ? MESA_FORMAT_ARGB8888 : MESA_FORMAT_ARGB4444;
}
case 3:
@@ -686,129 +689,152 @@ savageChooseTextureFormat( GLcontext *ctx, GLint internalFormat,
switch ( type ) {
case GL_UNSIGNED_SHORT_4_4_4_4:
case GL_UNSIGNED_SHORT_4_4_4_4_REV:
- return &_mesa_texformat_argb4444;
+ return MESA_FORMAT_ARGB4444;
case GL_UNSIGNED_SHORT_5_5_5_1:
case GL_UNSIGNED_SHORT_1_5_5_5_REV:
- return &_mesa_texformat_argb1555;
+ return MESA_FORMAT_ARGB1555;
case GL_UNSIGNED_SHORT_5_6_5:
case GL_UNSIGNED_SHORT_5_6_5_REV:
- return &_mesa_texformat_rgb565;
+ return MESA_FORMAT_RGB565;
default:
- return do32bpt ? &_mesa_texformat_argb8888 : &_mesa_texformat_rgb565;
+ return do32bpt ? MESA_FORMAT_ARGB8888 : MESA_FORMAT_RGB565;
}
case GL_RGBA8:
case GL_RGBA12:
case GL_RGBA16:
return !force16bpt ?
- &_mesa_texformat_argb8888 : &_mesa_texformat_argb4444;
+ MESA_FORMAT_ARGB8888 : MESA_FORMAT_ARGB4444;
case GL_RGB10_A2:
return !force16bpt ?
- &_mesa_texformat_argb8888 : &_mesa_texformat_argb1555;
+ MESA_FORMAT_ARGB8888 : MESA_FORMAT_ARGB1555;
case GL_RGBA4:
case GL_RGBA2:
- return &_mesa_texformat_argb4444;
+ return MESA_FORMAT_ARGB4444;
case GL_RGB5_A1:
- return &_mesa_texformat_argb1555;
+ return MESA_FORMAT_ARGB1555;
case GL_RGB8:
case GL_RGB10:
case GL_RGB12:
case GL_RGB16:
- return !force16bpt ? &_mesa_texformat_argb8888 : &_mesa_texformat_rgb565;
+ return !force16bpt ? MESA_FORMAT_ARGB8888 : MESA_FORMAT_RGB565;
case GL_RGB5:
case GL_RGB4:
case GL_R3_G3_B2:
- return &_mesa_texformat_rgb565;
+ return MESA_FORMAT_RGB565;
case GL_ALPHA:
case GL_COMPRESSED_ALPHA:
- return isSavage4 ? &_mesa_texformat_a8 : (
+#if 0
+ return isSavage4 ? MESA_FORMAT_a8 : (
do32bpt ? &_savage_texformat_a1118888 : &_savage_texformat_a1114444);
+#else
+ if (isSavage4)
+ return MESA_FORMAT_A8;
+ else if (do32bpt)
+ return MESA_FORMAT_ARGB8888;
+ else
+ return MESA_FORMAT_ARGB4444;
+#endif
case GL_ALPHA4:
- return isSavage4 ? &_mesa_texformat_a8 : &_savage_texformat_a1114444;
+#if 0
+ return isSavage4 ? MESA_FORMAT_a8 : &_savage_texformat_a1114444;
+#else
+ if (isSavage4)
+ return MESA_FORMAT_A8;
+ else
+ return MESA_FORMAT_ARGB4444;
+#endif
case GL_ALPHA8:
case GL_ALPHA12:
case GL_ALPHA16:
- return isSavage4 ? &_mesa_texformat_a8 : (
+#if 0
+ return isSavage4 ? MESA_FORMAT_a8 : (
!force16bpt ? &_savage_texformat_a1118888 : &_savage_texformat_a1114444);
-
+#else
+ if (isSavage4)
+ return MESA_FORMAT_A8;
+ else if (force16bpt)
+ return MESA_FORMAT_ARGB4444;
+ else
+ return MESA_FORMAT_ARGB8888;
+#endif
case 1:
case GL_LUMINANCE:
case GL_COMPRESSED_LUMINANCE:
/* no alpha, but use argb1555 in 16bit case to get pure grey values */
- return isSavage4 ? &_mesa_texformat_l8 : (
- do32bpt ? &_mesa_texformat_argb8888 : &_mesa_texformat_argb1555);
+ return isSavage4 ? MESA_FORMAT_L8 : (
+ do32bpt ? MESA_FORMAT_ARGB8888 : MESA_FORMAT_ARGB1555);
case GL_LUMINANCE4:
- return isSavage4 ? &_mesa_texformat_l8 : &_mesa_texformat_argb1555;
+ return isSavage4 ? MESA_FORMAT_L8 : MESA_FORMAT_ARGB1555;
case GL_LUMINANCE8:
case GL_LUMINANCE12:
case GL_LUMINANCE16:
- return isSavage4 ? &_mesa_texformat_l8 : (
- !force16bpt ? &_mesa_texformat_argb8888 : &_mesa_texformat_argb1555);
+ return isSavage4 ? MESA_FORMAT_L8 : (
+ !force16bpt ? MESA_FORMAT_ARGB8888 : MESA_FORMAT_ARGB1555);
case 2:
case GL_LUMINANCE_ALPHA:
case GL_COMPRESSED_LUMINANCE_ALPHA:
/* Savage4 has a al44 texture format. But it's not supported by Mesa. */
- return do32bpt ? &_mesa_texformat_argb8888 : &_mesa_texformat_argb4444;
+ return do32bpt ? MESA_FORMAT_ARGB8888 : MESA_FORMAT_ARGB4444;
case GL_LUMINANCE4_ALPHA4:
case GL_LUMINANCE6_ALPHA2:
- return &_mesa_texformat_argb4444;
+ return MESA_FORMAT_ARGB4444;
case GL_LUMINANCE8_ALPHA8:
case GL_LUMINANCE12_ALPHA4:
case GL_LUMINANCE12_ALPHA12:
case GL_LUMINANCE16_ALPHA16:
- return !force16bpt ? &_mesa_texformat_argb8888 : &_mesa_texformat_argb4444;
+ return !force16bpt ? MESA_FORMAT_ARGB8888 : MESA_FORMAT_ARGB4444;
#if 0
/* TFT_I8 produces garbage on ProSavageDDR and subsequent texture
* disable keeps rendering garbage. Disabled for now. */
case GL_INTENSITY:
case GL_COMPRESSED_INTENSITY:
- return isSavage4 ? &_mesa_texformat_i8 : (
- do32bpt ? &_mesa_texformat_argb8888 : &_mesa_texformat_argb4444);
+ return isSavage4 ? MESA_FORMAT_i8 : (
+ do32bpt ? MESA_FORMAT_ARGB8888 : MESA_FORMAT_ARGB4444);
case GL_INTENSITY4:
- return isSavage4 ? &_mesa_texformat_i8 : &_mesa_texformat_argb4444;
+ return isSavage4 ? MESA_FORMAT_i8 : MESA_FORMAT_ARGB4444;
case GL_INTENSITY8:
case GL_INTENSITY12:
case GL_INTENSITY16:
- return isSavage4 ? &_mesa_texformat_i8 : (
- !force16bpt ? &_mesa_texformat_argb8888 : &_mesa_texformat_argb4444);
+ return isSavage4 ? MESA_FORMAT_i8 : (
+ !force16bpt ? MESA_FORMAT_ARGB8888 : MESA_FORMAT_ARGB4444);
#else
case GL_INTENSITY:
case GL_COMPRESSED_INTENSITY:
- return do32bpt ? &_mesa_texformat_argb8888 : &_mesa_texformat_argb4444;
+ return do32bpt ? MESA_FORMAT_ARGB8888 : MESA_FORMAT_ARGB4444;
case GL_INTENSITY4:
- return &_mesa_texformat_argb4444;
+ return MESA_FORMAT_ARGB4444;
case GL_INTENSITY8:
case GL_INTENSITY12:
case GL_INTENSITY16:
- return !force16bpt ? &_mesa_texformat_argb8888 :
- &_mesa_texformat_argb4444;
+ return !force16bpt ? MESA_FORMAT_ARGB8888 : MESA_FORMAT_ARGB4444;
#endif
case GL_RGB_S3TC:
case GL_RGB4_S3TC:
case GL_COMPRESSED_RGB_S3TC_DXT1_EXT:
- 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:
- return &_mesa_texformat_rgba_dxt3;
+ return MESA_FORMAT_RGBA_DXT3;
case GL_RGBA_S3TC:
case GL_RGBA4_S3TC:
if (!isSavage4)
/* Not the best choice but Savage3D/MX/IX don't support DXT3 or DXT5. */
- return &_mesa_texformat_rgba_dxt1;
+ return MESA_FORMAT_RGBA_DXT1;
/* fall through */
case GL_COMPRESSED_RGBA_S3TC_DXT5_EXT:
- return &_mesa_texformat_rgba_dxt5;
+ return MESA_FORMAT_RGBA_DXT5;
/*
case GL_COLOR_INDEX:
@@ -822,7 +848,7 @@ savageChooseTextureFormat( GLcontext *ctx, GLint internalFormat,
*/
default:
_mesa_problem(ctx, "unexpected texture format in %s", __FUNCTION__);
- return NULL;
+ return MESA_FORMAT_NONE;
}
}
@@ -837,7 +863,7 @@ static void savageSetTexImages( savageContextPtr imesa,
assert(t);
assert(image);
- switch (image->TexFormat->MesaFormat) {
+ switch (image->TexFormat) {
case MESA_FORMAT_ARGB8888:
textureFormat = TFT_ARGB8888;
t->texelBytes = tileIndex = 4;
@@ -2083,6 +2109,7 @@ void savageDDInitTextureFuncs( struct dd_function_table *functions )
/* Texel fetching with our custom texture formats works just like
* the standard argb formats. */
+#if 0
_savage_texformat_a1114444.FetchTexel1D = _mesa_texformat_argb4444.FetchTexel1D;
_savage_texformat_a1114444.FetchTexel2D = _mesa_texformat_argb4444.FetchTexel2D;
_savage_texformat_a1114444.FetchTexel3D = _mesa_texformat_argb4444.FetchTexel3D;
@@ -2096,4 +2123,5 @@ void savageDDInitTextureFuncs( struct dd_function_table *functions )
_savage_texformat_a1118888.FetchTexel1Df= _mesa_texformat_argb8888.FetchTexel1Df;
_savage_texformat_a1118888.FetchTexel2Df= _mesa_texformat_argb8888.FetchTexel2Df;
_savage_texformat_a1118888.FetchTexel3Df= _mesa_texformat_argb8888.FetchTexel3Df;
+#endif
}