summaryrefslogtreecommitdiff
path: root/xc/extras/Mesa/src/FX/fxddtex.c
diff options
context:
space:
mode:
Diffstat (limited to 'xc/extras/Mesa/src/FX/fxddtex.c')
-rw-r--r--xc/extras/Mesa/src/FX/fxddtex.c286
1 files changed, 197 insertions, 89 deletions
diff --git a/xc/extras/Mesa/src/FX/fxddtex.c b/xc/extras/Mesa/src/FX/fxddtex.c
index 81cae83c3..dd2bf4456 100644
--- a/xc/extras/Mesa/src/FX/fxddtex.c
+++ b/xc/extras/Mesa/src/FX/fxddtex.c
@@ -41,7 +41,7 @@
*
* See fxapi.h for more revision/author details.
*/
-/* $XFree86: xc/extras/Mesa/src/FX/fxddtex.c,v 1.7 2000/08/28 02:43:10 tsi Exp $ */
+
#ifdef HAVE_CONFIG_H
#include "conf.h"
@@ -496,68 +496,209 @@ static int logbase2(int n)
/* Need different versions for different cpus.
*/
-#define INT_TRICK(l2) (0x800000 * (l2))
-int fxTexGetInfo(int w, int h, GrLOD_t *lodlevel,
- GrAspectRatio_t *aspectratio,
+#define INT_TRICK(l2) (0x800000 * l2)
+
+
+int fxTexGetInfo(int w, int h, GrLOD_t *lodlevel, GrAspectRatio_t *ar,
float *sscale, float *tscale,
int *i_sscale, int *i_tscale,
int *wscale, int *hscale)
{
- int logw, logh, ar, l, is, it, ws, hs;
- float s, t;
+
+ static GrLOD_t lod[9]={GR_LOD_256,GR_LOD_128,GR_LOD_64,GR_LOD_32,
+ GR_LOD_16,GR_LOD_8,GR_LOD_4,GR_LOD_2,GR_LOD_1};
+
+ int logw,logh,ws,hs;
+ GrLOD_t l;
+ GrAspectRatio_t aspectratio;
+ float s,t;
+ int is,it;
logw=logbase2(w);
logh=logbase2(h);
- ar=logw-logh;
- /* Hardware only allows a maximum aspect ratio of 8x1, so handle
- |ar|>3 by scaling the image and using an 8x1 aspect ratio */
- if (ar>=0) {
- l=logw;
- s=256.0;
- is=INT_TRICK(8);
+
+ switch(logw-logh) {
+ case 0:
+ aspectratio=GR_ASPECT_1x1;
+ l=lod[8-logw];
+ s=t=256.0f;
+ is=it=INT_TRICK(8);
+ ws=hs=1;
+ break;
+ case 1:
+ aspectratio=GR_ASPECT_2x1;
+ l=lod[8-logw];
+ s=256.0f;
+ t=128.0f;
+ is=INT_TRICK(8);it=INT_TRICK(7);
ws=1;
- if (ar<3) {
- t=256>>ar;
- it=INT_TRICK(8-ar);
- hs=1;
- } else {
- t=32.0;
- it=INT_TRICK(5);
- hs=1<<(ar-3);
- }
- } else {
- l=logh;
- t=256.0;
- it=INT_TRICK(8);
hs=1;
- if (-ar<3) {
- s=256>>-ar;
- is=INT_TRICK(8+ar);
- ws=1;
- } else {
- s=32.0;
- is=INT_TRICK(5);
- ws=1<<(-ar-3);
- }
+ break;
+ case 2:
+ aspectratio=GR_ASPECT_4x1;
+ l=lod[8-logw];
+ s=256.0f;
+ t=64.0f;
+ is=INT_TRICK(8);it=INT_TRICK(6);
+ ws=1;
+ hs=1;
+ break;
+ case 3:
+ aspectratio=GR_ASPECT_8x1;
+ l=lod[8-logw];
+ s=256.0f;
+ t=32.0f;
+ is=INT_TRICK(8);it=INT_TRICK(5);
+ ws=1;
+ hs=1;
+ break;
+ case 4:
+ aspectratio=GR_ASPECT_8x1;
+ l=lod[8-logw];
+ s=256.0f;
+ t=32.0f;
+ is=INT_TRICK(8);it=INT_TRICK(5);
+ ws=1;
+ hs=2;
+ break;
+ case 5:
+ aspectratio=GR_ASPECT_8x1;
+ l=lod[8-logw];
+ s=256.0f;
+ t=32.0f;
+ is=INT_TRICK(8);it=INT_TRICK(5);
+ ws=1;
+ hs=4;
+ break;
+ case 6:
+ aspectratio=GR_ASPECT_8x1;
+ l=lod[8-logw];
+ s=256.0f;
+ t=32.0f;
+ is=INT_TRICK(8);it=INT_TRICK(5);
+ ws=1;
+ hs=8;
+ break;
+ case 7:
+ aspectratio=GR_ASPECT_8x1;
+ l=lod[8-logw];
+ s=256.0f;
+ t=32.0f;
+ is=INT_TRICK(8);it=INT_TRICK(5);
+ ws=1;
+ hs=16;
+ break;
+ case 8:
+ aspectratio=GR_ASPECT_8x1;
+ l=lod[8-logw];
+ s=256.0f;
+ t=32.0f;
+ is=INT_TRICK(8);it=INT_TRICK(5);
+ ws=1;
+ hs=32;
+ break;
+ case -1:
+ aspectratio=GR_ASPECT_1x2;
+ l=lod[8-logh];
+ s=128.0f;
+ t=256.0f;
+ is=INT_TRICK(7);it=INT_TRICK(8);
+ ws=1;
+ hs=1;
+ break;
+ case -2:
+ aspectratio=GR_ASPECT_1x4;
+ l=lod[8-logh];
+ s=64.0f;
+ t=256.0f;
+ is=INT_TRICK(6);it=INT_TRICK(8);
+ ws=1;
+ hs=1;
+ break;
+ case -3:
+ aspectratio=GR_ASPECT_1x8;
+ l=lod[8-logh];
+ s=32.0f;
+ t=256.0f;
+ is=INT_TRICK(5);it=INT_TRICK(8);
+ ws=1;
+ hs=1;
+ break;
+ case -4:
+ aspectratio=GR_ASPECT_1x8;
+ l=lod[8-logh];
+ s=32.0f;
+ t=256.0f;
+ is=INT_TRICK(5);it=INT_TRICK(8);
+ ws=2;
+ hs=1;
+ break;
+ case -5:
+ aspectratio=GR_ASPECT_1x8;
+ l=lod[8-logh];
+ s=32.0f;
+ t=256.0f;
+ is=INT_TRICK(5);it=INT_TRICK(8);
+ ws=4;
+ hs=1;
+ break;
+ case -6:
+ aspectratio=GR_ASPECT_1x8;
+ l=lod[8-logh];
+ s=32.0f;
+ t=256.0f;
+ is=INT_TRICK(5);it=INT_TRICK(8);
+ ws=8;
+ hs=1;
+ break;
+ case -7:
+ aspectratio=GR_ASPECT_1x8;
+ l=lod[8-logh];
+ s=32.0f;
+ t=256.0f;
+ is=INT_TRICK(5);it=INT_TRICK(8);
+ ws=16;
+ hs=1;
+ break;
+ case -8:
+ aspectratio=GR_ASPECT_1x8;
+ l=lod[8-logh];
+ s=32.0f;
+ t=256.0f;
+ is=INT_TRICK(5);it=INT_TRICK(8);
+ ws=32;
+ hs=1;
+ break;
+ default:
+ return 0;
+ break;
}
- if (ar<-3) ar=-3;
- if (ar>3) ar=3;
-
- /* The above numbers are calculated sensibly and work for Glide3, but
- we change them to the whacky glide2 values if needed. */
-#ifdef FX_GLIDE3
- if (lodlevel) *lodlevel=l;
- if (aspectratio) *aspectratio=ar;
-#else
- if (lodlevel) *lodlevel=8-l;
- if (aspectratio) *aspectratio=3-ar;
-#endif
- if (sscale) *sscale=s;
- if (tscale) *tscale=t;
- if (wscale) *wscale=ws;
- if (hscale) *hscale=hs;
- if (i_sscale) *i_sscale = is;
- if (i_tscale) *i_tscale = it;
+
+ if(lodlevel)
+ (*lodlevel)=l;
+
+ if(ar)
+ (*ar)=aspectratio;
+
+ if(sscale)
+ (*sscale)=s;
+
+ if(tscale)
+ (*tscale)=t;
+
+ if(wscale)
+ (*wscale)=ws;
+
+ if(hscale)
+ (*hscale)=hs;
+
+ if (i_sscale)
+ *i_sscale = is;
+
+ if (i_tscale)
+ *i_tscale = it;
+
+
return 1;
}
@@ -617,17 +758,12 @@ void fxTexGetFormat(GLenum glformat, GrTextureFormat_t *tfmt, GLint *ifmt)
case GL_R3_G3_B2:
case GL_RGB4:
case GL_RGB5:
- if(tfmt)
- (*tfmt)=GR_TEXFMT_RGB_565;
- if(ifmt)
- (*ifmt)=GL_RGB;
- break;
case GL_RGB8:
case GL_RGB10:
case GL_RGB12:
case GL_RGB16:
if(tfmt)
- (*tfmt)=GR_TEXFMT_ARGB_8888;
+ (*tfmt)=GR_TEXFMT_RGB_565;
if(ifmt)
(*ifmt)=GL_RGB;
break;
@@ -635,11 +771,6 @@ void fxTexGetFormat(GLenum glformat, GrTextureFormat_t *tfmt, GLint *ifmt)
case GL_RGBA:
case GL_RGBA2:
case GL_RGBA4:
- if(tfmt)
- (*tfmt)=GR_TEXFMT_ARGB_4444;
- if(ifmt)
- (*ifmt)=GL_RGBA;
- break;
case GL_RGBA8:
case GL_RGB10_A2:
case GL_RGBA12:
@@ -779,23 +910,17 @@ GLboolean fxDDTexImage2D(GLcontext *ctx, GLenum target, GLint level,
case GL_R3_G3_B2:
case GL_RGB4:
case GL_RGB5:
- texelSize = 2;
- intFormat = MESA_R5_G6_B5;
- break;
case GL_RGB8:
case GL_RGB10:
case GL_RGB12:
case GL_RGB16:
- texelSize = 4;
- intFormat = MESA_A8_R8_G8_B8;
+ texelSize = 2;
+ intFormat = MESA_R5_G6_B5;
break;
case 4:
case GL_RGBA:
case GL_RGBA2:
case GL_RGBA4:
- texelSize = 2;
- intFormat = MESA_A4_R4_G4_B4;
- break;
case GL_RGBA8:
case GL_RGB10_A2:
case GL_RGBA12:
@@ -823,7 +948,6 @@ GLboolean fxDDTexImage2D(GLcontext *ctx, GLenum target, GLint level,
mml->data = MALLOC(dstWidth * dstHeight * texelSize);
if (!mml->data)
return GL_FALSE;
- mml->texelSize = texelSize;
mml->glideFormat = gldformat;
mml->width = dstWidth;
mml->height = dstHeight;
@@ -936,14 +1060,6 @@ GLboolean fxDDTexSubImage2D(GLcontext *ctx, GLenum target, GLint level,
texImage->Width, texImage->Height,
format, type, pixels, packing);
break;
- case GR_TEXFMT_ARGB_8888:
- dstStride = mml->width * 4;
- result = _mesa_convert_texsubimage(MESA_A8_R8_G8_B8, xoffset, yoffset,
- mml->width, mml->height, mml->data,
- dstStride, width, height,
- texImage->Width, texImage->Height,
- format, type, pixels, packing);
- break;
case GR_TEXFMT_ARGB_1555:
dstStride = mml->width * 2;
result = _mesa_convert_texsubimage(MESA_A1_R5_G5_B5, xoffset, yoffset,
@@ -962,9 +1078,6 @@ GLboolean fxDDTexSubImage2D(GLcontext *ctx, GLenum target, GLint level,
}
if (ti->validated && ti->isInTM)
- /* Don't use this, it's very broken. Download whole image for now.
- fxTMReloadSubMipMapLevel(fxMesa, texObj, level, yoffset, height);
- */
fxTMReloadMipMapLevel(fxMesa, texObj, level);
else
fxTexInvalidate(ctx, texObj);
@@ -1036,11 +1149,6 @@ GLvoid *fxDDGetTexImage(GLcontext *ctx, GLenum target, GLint level,
glFormat = GL_RGB;
srcStride = mml->width * 2;
break;
- case GR_TEXFMT_ARGB_8888:
- mesaFormat = MESA_A8_R8_G8_B8;
- glFormat = GL_RGBA;
- srcStride = mml->width * 4;
- break;
case GR_TEXFMT_ARGB_4444:
mesaFormat = MESA_A4_R4_G4_B4;
glFormat = GL_RGBA;