texture compression: getting warmer
This commit is contained in:
@@ -37,6 +37,8 @@ static GLboolean fxt1, dxtc, s3tc;
|
|||||||
static const char *TextureName (GLenum TC)
|
static const char *TextureName (GLenum TC)
|
||||||
{
|
{
|
||||||
switch (TC) {
|
switch (TC) {
|
||||||
|
case GL_RGB:
|
||||||
|
return "RGB";
|
||||||
case GL_RGBA:
|
case GL_RGBA:
|
||||||
return "RGBA";
|
return "RGBA";
|
||||||
case GL_COMPRESSED_RGB:
|
case GL_COMPRESSED_RGB:
|
||||||
|
@@ -46,7 +46,6 @@
|
|||||||
#include "texcompress.h"
|
#include "texcompress.h"
|
||||||
#include "texobj.h"
|
#include "texobj.h"
|
||||||
#include "texstore.h"
|
#include "texstore.h"
|
||||||
#include "texutil.h"
|
|
||||||
|
|
||||||
|
|
||||||
void
|
void
|
||||||
@@ -1207,7 +1206,7 @@ fxDDTexImage2D(GLcontext * ctx, GLenum target, GLint level,
|
|||||||
fxMesaContext fxMesa = FX_CONTEXT(ctx);
|
fxMesaContext fxMesa = FX_CONTEXT(ctx);
|
||||||
tfxTexInfo *ti;
|
tfxTexInfo *ti;
|
||||||
tfxMipMapLevel *mml;
|
tfxMipMapLevel *mml;
|
||||||
GLint texelBytes;
|
GLint texelBytes, dstRowStride;
|
||||||
|
|
||||||
if (TDFX_DEBUG & VERBOSE_TEXTURE) {
|
if (TDFX_DEBUG & VERBOSE_TEXTURE) {
|
||||||
fprintf(stderr, "fxDDTexImage2D: id=%d int 0x%x format 0x%x type 0x%x %dx%d\n",
|
fprintf(stderr, "fxDDTexImage2D: id=%d int 0x%x format 0x%x type 0x%x %dx%d\n",
|
||||||
@@ -1279,14 +1278,17 @@ fxDDTexImage2D(GLcontext * ctx, GLenum target, GLint level,
|
|||||||
/*if (!fxMesa->HaveTexFmt) assert(texelBytes == 1 || texelBytes == 2);*/
|
/*if (!fxMesa->HaveTexFmt) assert(texelBytes == 1 || texelBytes == 2);*/
|
||||||
|
|
||||||
mml->glideFormat = fxGlideFormat(texImage->TexFormat->MesaFormat);
|
mml->glideFormat = fxGlideFormat(texImage->TexFormat->MesaFormat);
|
||||||
/* [dBorca] Hack alert ZZZ: how do we handle FX_TC_NCC/FX_TC_NAPALM? */
|
/* [dBorca] ZYX: how do we handle FX_TC_NCC/FX_TC_NAPALM? */
|
||||||
/* [dBorca] Hack alert ZZZ: how do we handle S3TC outside MESA?!?!?! */
|
/* [dBorca] ZYX: how do we handle S3TC outside MESA?!?!?! */
|
||||||
|
/* [dBorca] ZYX: how do we handle aspectratio adjustemnt? */
|
||||||
|
|
||||||
/* allocate mipmap buffer */
|
/* allocate mipmap buffer */
|
||||||
assert(!texImage->Data);
|
assert(!texImage->Data);
|
||||||
if (texImage->IsCompressed) {
|
if (texImage->IsCompressed) {
|
||||||
|
dstRowStride = _mesa_compressed_row_stride(texImage->IntFormat, mml->width);
|
||||||
texImage->Data = MESA_PBUFFER_ALLOC(texImage->CompressedSize);
|
texImage->Data = MESA_PBUFFER_ALLOC(texImage->CompressedSize);
|
||||||
} else {
|
} else {
|
||||||
|
dstRowStride = mml->width * texelBytes;
|
||||||
texImage->Data = MESA_PBUFFER_ALLOC(mml->width * mml->height * texelBytes);
|
texImage->Data = MESA_PBUFFER_ALLOC(mml->width * mml->height * texelBytes);
|
||||||
}
|
}
|
||||||
if (!texImage->Data) {
|
if (!texImage->Data) {
|
||||||
@@ -1332,10 +1334,10 @@ fxDDTexImage2D(GLcontext * ctx, GLenum target, GLint level,
|
|||||||
texImage->TexFormat->StoreImage(ctx, 2, texImage->Format,
|
texImage->TexFormat->StoreImage(ctx, 2, texImage->Format,
|
||||||
texImage->TexFormat, texImage->Data,
|
texImage->TexFormat, texImage->Data,
|
||||||
0, 0, 0, /* dstX/Y/Zoffset */
|
0, 0, 0, /* dstX/Y/Zoffset */
|
||||||
mml->width * texelBytes, /* dstRowStride */
|
dstRowStride,
|
||||||
0, /* dstImageStride */
|
0, /* dstImageStride */
|
||||||
mml->width, mml->height, 1,
|
mml->width, mml->height, 1,
|
||||||
GL_BGRA, type, tempImage, packing);
|
GL_BGRA, CHAN_TYPE, tempImage, &ctx->DefaultPacking);
|
||||||
FREE(rgbaImage);
|
FREE(rgbaImage);
|
||||||
} else {
|
} else {
|
||||||
/* [dBorca] mild case:
|
/* [dBorca] mild case:
|
||||||
@@ -1370,7 +1372,7 @@ fxDDTexImage2D(GLcontext * ctx, GLenum target, GLint level,
|
|||||||
texImage->TexFormat->StoreImage(ctx, 2, texImage->Format,
|
texImage->TexFormat->StoreImage(ctx, 2, texImage->Format,
|
||||||
texImage->TexFormat, texImage->Data,
|
texImage->TexFormat, texImage->Data,
|
||||||
0, 0, 0, /* dstX/Y/Zoffset */
|
0, 0, 0, /* dstX/Y/Zoffset */
|
||||||
mml->width * texelBytes, /* dstRowStride */
|
dstRowStride,
|
||||||
0, /* dstImageStride */
|
0, /* dstImageStride */
|
||||||
width, height, 1,
|
width, height, 1,
|
||||||
format, type, pixels, packing);
|
format, type, pixels, packing);
|
||||||
|
@@ -40,14 +40,14 @@
|
|||||||
#include "texstore.h"
|
#include "texstore.h"
|
||||||
|
|
||||||
|
|
||||||
static GLint
|
static GLuint
|
||||||
compress_fxt1 (GLcontext *ctx,
|
compress_fxt1 (GLcontext *ctx,
|
||||||
GLint srcWidth,
|
GLsizei srcWidth,
|
||||||
GLint srcHeight,
|
GLsizei srcHeight,
|
||||||
GLenum srcFormat,
|
GLenum srcFormat,
|
||||||
const GLvoid *pixels,
|
const GLchan *source,
|
||||||
GLint srcRowStride,
|
GLint srcRowStride,
|
||||||
GLvoid *dst,
|
GLubyte *dest,
|
||||||
GLint dstRowStride);
|
GLint dstRowStride);
|
||||||
|
|
||||||
|
|
||||||
@@ -69,12 +69,9 @@ texstore_rgb_fxt1(STORE_PARAMS)
|
|||||||
const GLchan *pixels;
|
const GLchan *pixels;
|
||||||
GLint srcRowStride;
|
GLint srcRowStride;
|
||||||
GLubyte *dst;
|
GLubyte *dst;
|
||||||
GLint texWidth;
|
const GLint texWidth = dstRowStride * 8 / 16; /* a bit of a hack */
|
||||||
const GLchan *tempImage = NULL;
|
const GLchan *tempImage = NULL;
|
||||||
|
|
||||||
dstRowStride = _mesa_compressed_row_stride(GL_COMPRESSED_RGB_FXT1_3DFX, srcWidth);
|
|
||||||
texWidth = dstRowStride * 8 / 16; /* a bit of a hack */
|
|
||||||
|
|
||||||
ASSERT(dstFormat == &_mesa_texformat_rgb_fxt1);
|
ASSERT(dstFormat == &_mesa_texformat_rgb_fxt1);
|
||||||
ASSERT(dstXoffset % 8 == 0);
|
ASSERT(dstXoffset % 8 == 0);
|
||||||
ASSERT(dstYoffset % 4 == 0);
|
ASSERT(dstYoffset % 4 == 0);
|
||||||
@@ -130,13 +127,10 @@ texstore_rgba_fxt1(STORE_PARAMS)
|
|||||||
const GLchan *pixels;
|
const GLchan *pixels;
|
||||||
GLint srcRowStride;
|
GLint srcRowStride;
|
||||||
GLubyte *dst;
|
GLubyte *dst;
|
||||||
GLint texWidth;
|
GLint texWidth = dstRowStride * 8 / 16; /* a bit of a hack */
|
||||||
const GLchan *tempImage = NULL;
|
const GLchan *tempImage = NULL;
|
||||||
|
|
||||||
dstRowStride = _mesa_compressed_row_stride(GL_COMPRESSED_RGBA_FXT1_3DFX, srcWidth);
|
ASSERT(dstFormat == &_mesa_texformat_rgba_fxt1);
|
||||||
texWidth = dstRowStride * 8 / 16; /* a bit of a hack */
|
|
||||||
|
|
||||||
ASSERT(dstFormat == &_mesa_texformat_rgba_dxt1);
|
|
||||||
ASSERT(dstXoffset % 8 == 0);
|
ASSERT(dstXoffset % 8 == 0);
|
||||||
ASSERT(dstYoffset % 4 == 0);
|
ASSERT(dstYoffset % 4 == 0);
|
||||||
ASSERT(dstZoffset == 0);
|
ASSERT(dstZoffset == 0);
|
||||||
@@ -269,14 +263,14 @@ const struct gl_texture_format _mesa_texformat_rgba_fxt1 = {
|
|||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
static GLint
|
static GLuint
|
||||||
compress_fxt1 (GLcontext *ctx,
|
compress_fxt1 (GLcontext *ctx,
|
||||||
GLint srcWidth,
|
GLsizei srcWidth,
|
||||||
GLint srcHeight,
|
GLsizei srcHeight,
|
||||||
GLenum srcFormat,
|
GLenum srcFormat,
|
||||||
const GLvoid *pixels,
|
const GLchan *source,
|
||||||
GLint srcRowStride,
|
GLint srcRowStride,
|
||||||
GLvoid *dst,
|
GLubyte *dest,
|
||||||
GLint dstRowStride)
|
GLint dstRowStride)
|
||||||
{
|
{
|
||||||
/* here be dragons */
|
/* here be dragons */
|
||||||
|
@@ -57,7 +57,7 @@ texstore_rgb_dxt1(STORE_PARAMS)
|
|||||||
const GLchan *pixels;
|
const GLchan *pixels;
|
||||||
GLint srcRowStride;
|
GLint srcRowStride;
|
||||||
GLubyte *dst;
|
GLubyte *dst;
|
||||||
const GLint texWidth = dstRowStride / 2; /* a bit of a hack */
|
const GLint texWidth = dstRowStride * 4 / 8; /* a bit of a hack */
|
||||||
const GLchan *tempImage = NULL;
|
const GLchan *tempImage = NULL;
|
||||||
|
|
||||||
ASSERT(dstFormat == &_mesa_texformat_rgb_dxt1);
|
ASSERT(dstFormat == &_mesa_texformat_rgb_dxt1);
|
||||||
@@ -114,7 +114,7 @@ texstore_rgba_dxt1(STORE_PARAMS)
|
|||||||
const GLchan *pixels;
|
const GLchan *pixels;
|
||||||
GLint srcRowStride;
|
GLint srcRowStride;
|
||||||
GLubyte *dst;
|
GLubyte *dst;
|
||||||
const GLint texWidth = dstRowStride / 2; /* a bit of a hack */
|
const GLint texWidth = dstRowStride * 4 / 8; /* a bit of a hack */
|
||||||
const GLchan *tempImage = NULL;
|
const GLchan *tempImage = NULL;
|
||||||
|
|
||||||
ASSERT(dstFormat == &_mesa_texformat_rgba_dxt1);
|
ASSERT(dstFormat == &_mesa_texformat_rgba_dxt1);
|
||||||
@@ -169,7 +169,7 @@ texstore_rgba_dxt3(STORE_PARAMS)
|
|||||||
const GLchan *pixels;
|
const GLchan *pixels;
|
||||||
GLint srcRowStride;
|
GLint srcRowStride;
|
||||||
GLubyte *dst;
|
GLubyte *dst;
|
||||||
const GLint texWidth = dstRowStride / 4; /* a bit of a hack */
|
const GLint texWidth = dstRowStride * 4 / 16; /* a bit of a hack */
|
||||||
const GLchan *tempImage = NULL;
|
const GLchan *tempImage = NULL;
|
||||||
|
|
||||||
ASSERT(dstFormat == &_mesa_texformat_rgba_dxt3);
|
ASSERT(dstFormat == &_mesa_texformat_rgba_dxt3);
|
||||||
@@ -223,7 +223,7 @@ texstore_rgba_dxt5(STORE_PARAMS)
|
|||||||
const GLchan *pixels;
|
const GLchan *pixels;
|
||||||
GLint srcRowStride;
|
GLint srcRowStride;
|
||||||
GLubyte *dst;
|
GLubyte *dst;
|
||||||
const GLint texWidth = dstRowStride / 4; /* a bit of a hack */
|
const GLint texWidth = dstRowStride * 4 / 16; /* a bit of a hack */
|
||||||
const GLchan *tempImage = NULL;
|
const GLchan *tempImage = NULL;
|
||||||
|
|
||||||
ASSERT(dstFormat == &_mesa_texformat_rgba_dxt5);
|
ASSERT(dstFormat == &_mesa_texformat_rgba_dxt5);
|
||||||
|
@@ -3280,3 +3280,37 @@ do { \
|
|||||||
_mesa_problem(NULL,"unexpected bytes/pixel in _mesa_rescale_teximage2d");
|
_mesa_problem(NULL,"unexpected bytes/pixel in _mesa_rescale_teximage2d");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Upscale an image by replication, not (typical) stretching.
|
||||||
|
* We use this when the image width or height is less than a
|
||||||
|
* certain size (4, 8) and we need to upscale an image.
|
||||||
|
*/
|
||||||
|
void
|
||||||
|
_mesa_upscale_teximage2d (GLsizei inWidth, GLsizei inHeight,
|
||||||
|
GLsizei outWidth, GLsizei outHeight,
|
||||||
|
GLint comps, const GLchan *src, GLint srcRowStride,
|
||||||
|
GLchan *dest )
|
||||||
|
{
|
||||||
|
GLint i, j, k;
|
||||||
|
|
||||||
|
ASSERT(outWidth >= inWidth);
|
||||||
|
ASSERT(outHeight >= inHeight);
|
||||||
|
ASSERT(inWidth == 1 || inWidth == 2 || inHeight == 1 || inHeight == 2);
|
||||||
|
#if 0
|
||||||
|
ASSERT((outWidth & 3) == 0);
|
||||||
|
ASSERT((outHeight & 3) == 0);
|
||||||
|
#endif
|
||||||
|
|
||||||
|
for (i = 0; i < outHeight; i++) {
|
||||||
|
const GLint ii = i % inHeight;
|
||||||
|
for (j = 0; j < outWidth; j++) {
|
||||||
|
const GLint jj = j % inWidth;
|
||||||
|
for (k = 0; k < comps; k++) {
|
||||||
|
dest[(i * outWidth + j) * comps + k]
|
||||||
|
= src[ii * srcRowStride + jj * comps + k];
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
@@ -232,4 +232,10 @@ _mesa_rescale_teximage2d(GLuint bytesPerPixel, GLuint dstRowStride,
|
|||||||
GLint dstWidth, GLint dstHeight,
|
GLint dstWidth, GLint dstHeight,
|
||||||
const GLvoid *srcImage, GLvoid *dstImage);
|
const GLvoid *srcImage, GLvoid *dstImage);
|
||||||
|
|
||||||
|
extern void
|
||||||
|
_mesa_upscale_teximage2d( GLsizei inWidth, GLsizei inHeight,
|
||||||
|
GLsizei outWidth, GLsizei outHeight,
|
||||||
|
GLint comps, const GLchan *src, GLint srcRowStride,
|
||||||
|
GLchan *dest );
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
Reference in New Issue
Block a user