attempt to fix DXT1 4x4 mipmap downloads to the TMUs
This commit is contained in:
@@ -436,8 +436,8 @@ const FxU32 _grMipMapHostSizeCmp4Bit[7][GR_LOD_LOG2_2048+1] =
|
||||
};
|
||||
|
||||
/*
|
||||
* Similar to _grMipMapHostSize[][] but for 8-bit compressed
|
||||
* textures, where 4x4 is the minimum size. DXT2,3,4,5
|
||||
* Similar to _grMipMapHostSize[][] but for DXTn compressed
|
||||
* textures, where 4x4 is the minimum size.
|
||||
*/
|
||||
const FxU32 _grMipMapHostSizeDXT[4][GR_LOD_LOG2_2048+1] =
|
||||
{
|
||||
@@ -501,7 +501,7 @@ const FxU32 _grMipMapHostSizeDXT[4][GR_LOD_LOG2_2048+1] =
|
||||
|
||||
/*
|
||||
* Similar to _grMipMapHostWH[][], but for 4-bit compressed
|
||||
* textures, where 8x4 is the minimum size. FXT1,DXT1
|
||||
* textures, where 8x4 is the minimum size. FXT1
|
||||
*/
|
||||
const int _grMipMapHostWHCmp4Bit[G3_ASPECT_TRANSLATE(GR_ASPECT_LOG2_1x8) + 1]
|
||||
[GR_LOD_LOG2_2048 + 1][2] =
|
||||
@@ -607,8 +607,8 @@ const int _grMipMapHostWHCmp4Bit[G3_ASPECT_TRANSLATE(GR_ASPECT_LOG2_1x8) + 1]
|
||||
};
|
||||
|
||||
/*
|
||||
* Similar to _grMipMapHostWH[][], but for 8-bit compressed
|
||||
* textures, where 4x4 is the minimum size. DXT2,3,4,5
|
||||
* Similar to _grMipMapHostWH[][], but for DXTn compressed
|
||||
* textures, where 4x4 is the minimum size.
|
||||
*/
|
||||
const int _grMipMapHostWHDXT[G3_ASPECT_TRANSLATE(GR_ASPECT_LOG2_1x8) + 1]
|
||||
[GR_LOD_LOG2_2048 + 1][2] =
|
||||
@@ -897,7 +897,7 @@ static const FxU32 _grMipMapSize[4][16] = {
|
||||
},
|
||||
};
|
||||
|
||||
/* Similar to _grMipMapSize[][] but for 4-bit compressed formats. FXT1,DXT1 */
|
||||
/* Similar to _grMipMapSize[][] but for 4-bit compressed formats. FXT1 */
|
||||
static const FxU32 _grMipMapSizeCmp4Bit[7][16] = {
|
||||
{ /* 8:1 aspect ratio */
|
||||
0x000020, /* 0 : 8x4 */
|
||||
@@ -999,7 +999,7 @@ static const FxU32 _grMipMapSizeCmp4Bit[7][16] = {
|
||||
},
|
||||
};
|
||||
|
||||
/* Similar to _grMipMapSize[][] but for 8-bit compressed formats. DXT2,3,4,5 */
|
||||
/* Similar to _grMipMapSize[][] but for DXTn compressed formats. */
|
||||
static const FxU32 _grMipMapSizeDXT[4][16] = {
|
||||
{ /* 8:1 aspect ratio */
|
||||
0x000010, /* 0 : 4x4 */
|
||||
@@ -1136,7 +1136,7 @@ const FxI32 _grMipMapOffset[4][16] =
|
||||
|
||||
/*
|
||||
* Similar to _grMipMapOffset[][], but for 4-bit compressed
|
||||
* textures, where 8x4 is the minimum size. FXT1,DXT1
|
||||
* textures, where 8x4 is the minimum size. FXT1
|
||||
*/
|
||||
const FxI32 _grMipMapOffsetCmp4Bit[7][16] = {
|
||||
{ /* 8:1 aspect ratio */
|
||||
@@ -1247,8 +1247,8 @@ const FxI32 _grMipMapOffsetCmp4Bit[7][16] = {
|
||||
};
|
||||
|
||||
/*
|
||||
* Similar to _grMipMapOffset[][], but for 8-bit compressed
|
||||
* textures, where 4x4 is the minimum size. DXT2,3,4,5
|
||||
* Similar to _grMipMapOffset[][], but for DXTn compressed
|
||||
* textures, where 4x4 is the minimum size.
|
||||
*/
|
||||
const FxI32 _grMipMapOffsetDXT[4][16] = {
|
||||
{ /* 8:1 aspect ratio */
|
||||
@@ -1383,7 +1383,7 @@ const FxI32 _grMipMapOffset_Tsplit[4][16] =
|
||||
|
||||
/*
|
||||
* Similar to _grMipMapOffset_Tsplit[][], but for 4-bit compressed
|
||||
* textures, where 8x4 is the minimum size. FXT1,DXT1
|
||||
* textures, where 8x4 is the minimum size. FXT1
|
||||
*/
|
||||
const FxI32 _grMipMapOffset_TsplitCmp4Bit[7][16] = {
|
||||
{ /* 8:1 aspect ratio */
|
||||
@@ -1501,8 +1501,8 @@ const FxI32 _grMipMapOffset_TsplitCmp4Bit[7][16] = {
|
||||
};
|
||||
|
||||
/*
|
||||
* Similar to _grMipMapOffset_Tsplit[][], but for 8-bit compressed
|
||||
* textures, where 4x4 is the minimum size. DXT2,3,4,5
|
||||
* Similar to _grMipMapOffset_Tsplit[][], but for DXTn compressed
|
||||
* textures, where 4x4 is the minimum size.
|
||||
*/
|
||||
const FxI32 _grMipMapOffset_TsplitDXT[4][16] = {
|
||||
{ /* 8:1 aspect ratio */
|
||||
@@ -1579,18 +1579,16 @@ FxU32
|
||||
_grTexTextureMemRequired( GrLOD_t small_lod, GrLOD_t large_lod,
|
||||
GrAspectRatio_t aspect, GrTextureFormat_t format,
|
||||
FxU32 evenOdd,
|
||||
FxBool roundP,
|
||||
FxBool systemMem )
|
||||
FxBool roundP )
|
||||
{
|
||||
#define FN_NAME "_grTexTextureMemRequired"
|
||||
FxU32 memrequired;
|
||||
|
||||
GDBG_INFO(80,"_grTexTextureMemRequired(%d,%d, %d,%d, %d, %d, %d)\n",
|
||||
GDBG_INFO(80,"_grTexTextureMemRequired(%d,%d, %d,%d, %d, %d)\n",
|
||||
small_lod, large_lod,
|
||||
aspect, format,
|
||||
evenOdd,
|
||||
roundP,
|
||||
systemMem);
|
||||
roundP);
|
||||
|
||||
GR_CHECK_W(FN_NAME,
|
||||
small_lod > large_lod,
|
||||
@@ -1625,47 +1623,6 @@ _grTexTextureMemRequired( GrLOD_t small_lod, GrLOD_t large_lod,
|
||||
break;
|
||||
|
||||
case GR_TEXFMT_ARGB_CMP_DXT1: /* XXX check this! */
|
||||
if(systemMem) {
|
||||
/* calculating for system memory */
|
||||
/* In this case, do not mirror the aspect ratios, as the minimum
|
||||
* size of a mipmap level is 8x4, so the tables are not symmetric
|
||||
* w.r.t. sign of the aspect ratio, so keep the sign. */
|
||||
if ( evenOdd == GR_MIPMAPLEVELMASK_BOTH ) {
|
||||
memrequired = _grMipMapOffsetCmp4Bit[G3_ASPECT_TRANSLATE(aspect)][small_lod];
|
||||
memrequired -= _grMipMapOffsetCmp4Bit[G3_ASPECT_TRANSLATE(aspect)][large_lod+1];
|
||||
} else {
|
||||
memrequired = 0;
|
||||
/* construct XOR mask */
|
||||
evenOdd = (evenOdd == GR_MIPMAPLEVELMASK_EVEN) ? 1 : 0;
|
||||
while (large_lod >= small_lod) { /* sum up all the mipmap levels */
|
||||
if ((large_lod ^ evenOdd) & 1) { /* that match the XOR mask */
|
||||
memrequired += _grMipMapSizeCmp4Bit[G3_ASPECT_TRANSLATE(aspect)][large_lod];
|
||||
}
|
||||
large_lod--;
|
||||
}
|
||||
}
|
||||
} else {
|
||||
/* for texture memory on hardware */
|
||||
/* allows us to mirror the aspect ratios because the table entries are the same */
|
||||
if (aspect < GR_ASPECT_LOG2_1x1) {
|
||||
aspect = -aspect;
|
||||
}
|
||||
if ( evenOdd == GR_MIPMAPLEVELMASK_BOTH ) {
|
||||
memrequired = _grMipMapOffsetDXT[G3_ASPECT_TRANSLATE(aspect)][small_lod];
|
||||
memrequired -= _grMipMapOffsetDXT[G3_ASPECT_TRANSLATE(aspect)][large_lod+1];
|
||||
} else {
|
||||
memrequired = 0;
|
||||
/* construct XOR mask */
|
||||
evenOdd = (evenOdd == GR_MIPMAPLEVELMASK_EVEN) ? 1 : 0;
|
||||
while (large_lod >= small_lod) { /* sum up all the mipmap levels */
|
||||
if ((large_lod ^ evenOdd) & 1) { /* that match the XOR mask */
|
||||
memrequired += _grMipMapSizeDXT[G3_ASPECT_TRANSLATE(aspect)][large_lod];
|
||||
}
|
||||
large_lod--;
|
||||
}
|
||||
}
|
||||
}
|
||||
break;
|
||||
case GR_TEXFMT_ARGB_CMP_DXT2:
|
||||
case GR_TEXFMT_ARGB_CMP_DXT3:
|
||||
case GR_TEXFMT_ARGB_CMP_DXT4:
|
||||
@@ -1842,8 +1799,7 @@ GR_DIENTRY(grTexCalcMemRequired, FxU32,
|
||||
memrequired = _grTexTextureMemRequired(small_lod, large_lod,
|
||||
aspect, format,
|
||||
GR_MIPMAPLEVELMASK_BOTH,
|
||||
FXTRUE,
|
||||
FXFALSE);
|
||||
FXTRUE);
|
||||
GDBG_INFO(88,"grTexCalcMemRequired(%d,%d,%d,%d) => 0x%x(%d)\n",
|
||||
small_lod,large_lod,aspect,format,memrequired,memrequired);
|
||||
return memrequired;
|
||||
@@ -2036,8 +1992,7 @@ GR_DIENTRY(grTexTextureMemRequired, FxU32,
|
||||
info->aspectRatioLog2,
|
||||
info->format,
|
||||
evenOdd,
|
||||
FXTRUE,
|
||||
FXFALSE );
|
||||
FXTRUE );
|
||||
|
||||
GDBG_INFO(88,"grTexTextureMemRequired(%d,0x%x) => 0x%x(%d)\n",
|
||||
evenOdd,info,memrequired,memrequired);
|
||||
@@ -2132,7 +2087,6 @@ GR_DIENTRY(grTexDownloadMipMap, void,
|
||||
|
||||
switch(info->format) {
|
||||
case GR_TEXFMT_ARGB_CMP_FXT1:
|
||||
case GR_TEXFMT_ARGB_CMP_DXT1:
|
||||
/* Note: in this case, we need to use info->aspectRatioLog2
|
||||
* rather than curAspectRatio, because we need to keep the
|
||||
* sign of the apsect ratio in order to get the right size. */
|
||||
@@ -2141,6 +2095,7 @@ GR_DIENTRY(grTexDownloadMipMap, void,
|
||||
* formatMult) >> 3);
|
||||
break;
|
||||
|
||||
case GR_TEXFMT_ARGB_CMP_DXT1:
|
||||
case GR_TEXFMT_ARGB_CMP_DXT2:
|
||||
case GR_TEXFMT_ARGB_CMP_DXT3:
|
||||
case GR_TEXFMT_ARGB_CMP_DXT4:
|
||||
@@ -2238,9 +2193,6 @@ GR_DIENTRY(grTexDownloadMipMapLevel, void,
|
||||
_grMipMapHostWHCmp4Bit[G3_ASPECT_TRANSLATE(aspectRatio)][thisLod][1] - 1);
|
||||
break;
|
||||
|
||||
/* Note: Unlike in other places, we put DXT1 here because it's min size
|
||||
* according to the app is actually 4x4 like the other DXTC mode
|
||||
*/
|
||||
case GR_TEXFMT_ARGB_CMP_DXT1:
|
||||
case GR_TEXFMT_ARGB_CMP_DXT2:
|
||||
case GR_TEXFMT_ARGB_CMP_DXT3:
|
||||
|
||||
@@ -127,6 +127,7 @@ static FxU16 ReadDataShort(FILE *);
|
||||
static FxU32 ReadDataLong(FILE *);
|
||||
static void Read4Bit(FxU8 *dst, FILE *image, int small_lod, int large_lod, GrAspectRatio_t aspect);
|
||||
static void Read8Bit(FxU8 *dst, FILE *image, int small_lod, int large_lod, GrAspectRatio_t aspect);
|
||||
static void ReadDXT4Bit(FxU8 *dst, FILE *image, int small_lod, int large_lod, GrAspectRatio_t aspect);
|
||||
static void ReadDXT8Bit(FxU8 *dst, FILE *image, int small_lod, int large_lod, GrAspectRatio_t aspect);
|
||||
static void Read16Bit(FxU16 *dst, FILE *image, int small_lod, int large_lod, GrAspectRatio_t aspect);
|
||||
static void Read32Bit(FxU32 *dst, FILE *image, int small_lod, int large_lod, GrAspectRatio_t aspect);
|
||||
@@ -230,7 +231,7 @@ GR_DIENTRY(gu3dfGetInfo, FxBool,
|
||||
{ "AP88", GR_TEXFMT_AP_88, FXTRUE },
|
||||
{ "ARGB8888", GR_TEXFMT_ARGB_8888, FXTRUE },
|
||||
#ifdef FX_GLIDE_NAPALM
|
||||
/* KoolSmoky - other texture formats. */
|
||||
/* other texture formats. */
|
||||
{ "FXT1", GR_TEXFMT_ARGB_CMP_FXT1, FXTRUE },
|
||||
{ "FXT1_HI", GR_TEXFMT_ARGB_CMP_FXT1, FXTRUE },
|
||||
{ "FXT1_MIXED", GR_TEXFMT_ARGB_CMP_FXT1, FXTRUE },
|
||||
@@ -243,11 +244,12 @@ GR_DIENTRY(gu3dfGetInfo, FxBool,
|
||||
{ "YUYV422", GR_TEXFMT_YUYV_422, FXTRUE },
|
||||
{ "UYVY22", GR_TEXFMT_UYVY_422, FXTRUE },
|
||||
{ "AYUV444", GR_TEXFMT_AYUV_444, FXTRUE },
|
||||
/* TODO: to support DXTn, we need to read .dds files.
|
||||
{ "DXT1", GR_TEXFMT_ARGB_CMP_DXT1, FXTRUE },
|
||||
{ "DXT2", GR_TEXFMT_ARGB_CMP_DXT2, FXTRUE },
|
||||
{ "DXT3", GR_TEXFMT_ARGB_CMP_DXT3, FXTRUE },
|
||||
{ "DXT4", GR_TEXFMT_ARGB_CMP_DXT4, FXTRUE },
|
||||
{ "DXT5", GR_TEXFMT_ARGB_CMP_DXT5, FXTRUE },
|
||||
{ "DXT5", GR_TEXFMT_ARGB_CMP_DXT5, FXTRUE },*/
|
||||
#endif
|
||||
{ 0, 0, FXFALSE }
|
||||
};
|
||||
@@ -543,8 +545,7 @@ GR_DIENTRY(gu3dfGetInfo, FxBool,
|
||||
Info->header.aspect_ratio,
|
||||
Info->header.format,
|
||||
GR_MIPMAPLEVELMASK_BOTH,
|
||||
FXFALSE,
|
||||
FXTRUE);
|
||||
FXFALSE);
|
||||
}
|
||||
|
||||
GDBG_INFO(81,"gu3dfGetInfo(%s,0x%x) -> %i tex memory required\n",FileName,Info, Info->mem_required);
|
||||
@@ -848,12 +849,18 @@ GR_DIENTRY(gu3dfLoad, FxBool, (const char *filename, Gu3dfInfo *info))
|
||||
break;
|
||||
|
||||
case GR_TEXFMT_ARGB_CMP_FXT1:
|
||||
case GR_TEXFMT_ARGB_CMP_DXT1:
|
||||
Read4Bit(info->data, image_file,
|
||||
info->header.small_lod,
|
||||
info->header.large_lod,
|
||||
G3_ASPECT_TRANSLATE(info->header.aspect_ratio));
|
||||
break;
|
||||
/* TODO: to support DXTn, we need to read .dds files
|
||||
case GR_TEXFMT_ARGB_CMP_DXT1:
|
||||
ReadDXT4Bit(info->data, image_file,
|
||||
info->header.small_lod,
|
||||
info->header.large_lod,
|
||||
G3_ASPECT_TRANSLATE(info->header.aspect_ratio));
|
||||
break;
|
||||
|
||||
case GR_TEXFMT_ARGB_CMP_DXT2:
|
||||
case GR_TEXFMT_ARGB_CMP_DXT3:
|
||||
@@ -864,7 +871,7 @@ GR_DIENTRY(gu3dfLoad, FxBool, (const char *filename, Gu3dfInfo *info))
|
||||
info->header.large_lod,
|
||||
G3_ASPECT_TRANSLATE(info->header.aspect_ratio));
|
||||
break;
|
||||
|
||||
*/
|
||||
case GR_TEXFMT_INTENSITY_8:
|
||||
case GR_TEXFMT_ALPHA_8:
|
||||
case GR_TEXFMT_ALPHA_INTENSITY_44:
|
||||
@@ -918,15 +925,13 @@ GR_DIENTRY(gu3dfLoad, FxBool, (const char *filename, Gu3dfInfo *info))
|
||||
}
|
||||
|
||||
/*
|
||||
** Read4Bit
|
||||
** Read4Bit (FXT1)
|
||||
**
|
||||
** Read in a 4-bit Compressed texture map. Luckily the minimum mipmap
|
||||
** size is 8x4 texels so we never have to worry about where the high
|
||||
** or low nibble is.
|
||||
** Take advantage of the fact that the minimum size is 16 bytes
|
||||
** during the fread() call.
|
||||
** FXT1,DXT1
|
||||
** DXT1 has 2 side by side 4x4 microtiles thus 8x4 texels
|
||||
*/
|
||||
static void
|
||||
Read4Bit(FxU8 *data, FILE *image_file, int small_lod, int large_lod,
|
||||
@@ -944,26 +949,53 @@ Read4Bit(FxU8 *data, FILE *image_file, int small_lod, int large_lod,
|
||||
thisMipMapByteCount = (width * height) >> 5;
|
||||
|
||||
fread(data, 16, thisMipMapByteCount, image_file);
|
||||
data += thisMipMapByteCount;
|
||||
data += (16 * thisMipMapByteCount);
|
||||
}
|
||||
}
|
||||
|
||||
/*
|
||||
** ReadDXT8Bit
|
||||
** ReadDXT4Bit (DXT1)
|
||||
**
|
||||
** Read in a 4-bit Compressed texture map.
|
||||
** Take advantage of the fact that the minimum size is 8 bytes
|
||||
** during the fread() call.
|
||||
** Note: the smallest DXT1 mipmap has 2 side-by-side 4x4 microtiles
|
||||
** but we only read one of them.
|
||||
*/
|
||||
static void
|
||||
ReadDXT4Bit(FxU8 *data, FILE *image_file, int small_lod, int large_lod,
|
||||
GrAspectRatio_t aspect_ratio)
|
||||
{
|
||||
int lod;
|
||||
int width, height, thisMipMapByteCount;
|
||||
|
||||
for (lod = small_lod; lod <= large_lod; lod++) {
|
||||
width = _grMipMapHostWHDXT[aspect_ratio][lod][0];
|
||||
height = _grMipMapHostWHDXT[aspect_ratio][lod][1];
|
||||
|
||||
/* Divide the WxH by 16 to read 8 bytes at a time. */
|
||||
thisMipMapByteCount = (width * height) >> 4;
|
||||
|
||||
fread(data, 8, thisMipMapByteCount, image_file);
|
||||
data += (8 * thisMipMapByteCount);
|
||||
}
|
||||
}
|
||||
|
||||
/*
|
||||
** ReadDXT8Bit (DXT2,3,4,5)
|
||||
**
|
||||
** Read in a 8-bit Compressed texture map. the minimum mipmap
|
||||
** size is 4x4 texels
|
||||
** Take advantage of the fact that the minimum size is 16 bytes
|
||||
** during the fread() call.
|
||||
** dxt2,3,4,5
|
||||
*/
|
||||
static void
|
||||
ReadDXT8Bit(FxU8 *data, FILE *image_file,
|
||||
int small_lod, int large_lod,
|
||||
GrAspectRatio_t aspect_ratio)
|
||||
int small_lod, int large_lod,
|
||||
GrAspectRatio_t aspect_ratio)
|
||||
{
|
||||
int lod;
|
||||
int width, height,thisMipMapByteCount;
|
||||
int width, height, thisMipMapByteCount;
|
||||
|
||||
for (lod = small_lod; lod <= large_lod; lod++) {
|
||||
width = _grMipMapHostWHDXT[aspect_ratio][lod][0];
|
||||
@@ -974,7 +1006,7 @@ ReadDXT8Bit(FxU8 *data, FILE *image_file,
|
||||
thisMipMapByteCount = (width * height) >> 4;
|
||||
|
||||
fread(data, 16, thisMipMapByteCount, image_file);
|
||||
data += thisMipMapByteCount;
|
||||
data += (16 * thisMipMapByteCount);
|
||||
}
|
||||
|
||||
}
|
||||
@@ -990,14 +1022,16 @@ Read8Bit(FxU8 *data, FILE *image_file,
|
||||
GrAspectRatio_t aspect_ratio)
|
||||
{
|
||||
int lod;
|
||||
int width, height;
|
||||
int width, height, thisMipMapByteCount;
|
||||
|
||||
for (lod = small_lod; lod <= large_lod; lod++) {
|
||||
width = _grMipMapHostWH[aspect_ratio][lod][0];
|
||||
height = _grMipMapHostWH[aspect_ratio][lod][1];
|
||||
|
||||
fread(data, sizeof(char), width*height, image_file);
|
||||
data += width*height;
|
||||
thisMipMapByteCount = width * height;
|
||||
|
||||
fread(data, sizeof(char), thisMipMapByteCount, image_file);
|
||||
data += thisMipMapByteCount;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -2785,8 +2785,7 @@ GR_ENTRY(grTexSource, void,
|
||||
info->aspectRatioLog2,
|
||||
info->format,
|
||||
evenOdd,
|
||||
FXTRUE,
|
||||
FXFALSE)
|
||||
FXTRUE)
|
||||
> gc->tmu_state[tmu].total_mem)),
|
||||
"insufficient texture ram at startAddress");
|
||||
GR_CHECK_F(FN_NAME, evenOdd > 0x3 || evenOdd == 0, "evenOdd mask invalid");
|
||||
@@ -3464,10 +3463,10 @@ GR_DIENTRY(grTextureBuffer, void,
|
||||
/*
|
||||
* AJB- Last I checked we couldn't render to an FXT1 surface...
|
||||
*
|
||||
if (format == GR_TEXFMT_ARGB_CMP_FXT1 || format == GR_TEXFMT_ARGB_CMP_DXT1) {
|
||||
if (format == GR_TEXFMT_ARGB_CMP_FXT1) {
|
||||
width = _grMipMapHostWHCmp4Bit[G3_ASPECT_TRANSLATE(aspectRatio)][thisLOD][0];
|
||||
height = _grMipMapHostWHCmp4Bit[G3_ASPECT_TRANSLATE(aspectRatio)][thisLOD][1];
|
||||
} else if (format >= GR_TEXFMT_ARGB_CMP_DXT2 && format <= GR_TEXFMT_ARGB_CMP_DXT5) {
|
||||
} else if (format >= GR_TEXFMT_ARGB_CMP_DXT1 && format <= GR_TEXFMT_ARGB_CMP_DXT5) {
|
||||
width = _grMipMapHostWHDXT[G3_ASPECT_TRANSLATE(aspectRatio)][thisLOD][0];
|
||||
height = _grMipMapHostWHDXT[G3_ASPECT_TRANSLATE(aspectRatio)][thisLOD][1];
|
||||
} else {
|
||||
@@ -3496,8 +3495,7 @@ GR_DIENTRY(grTextureBuffer, void,
|
||||
else
|
||||
offset = _grTexTextureMemRequired( thisLOD+1, largeLOD,
|
||||
aspectRatio, format,
|
||||
odd_even_mask, FXTRUE,
|
||||
FXFALSE );
|
||||
odd_even_mask, FXTRUE );
|
||||
|
||||
/* How do we deal with UMA?
|
||||
The tmu only makes sense when the UMA is not turned on.
|
||||
@@ -3573,10 +3571,10 @@ GR_DIENTRY(grTextureAuxBuffer, void,
|
||||
/*
|
||||
* AJB- Using FXT1 for an aux buffer looks like it would be a mistake to me as well.
|
||||
*
|
||||
if (format == GR_TEXFMT_ARGB_CMP_FXT1 || format == GR_TEXFMT_ARGB_CMP_DXT1) {
|
||||
if (format == GR_TEXFMT_ARGB_CMP_FXT1) {
|
||||
width = _grMipMapHostWHCmp4Bit[G3_ASPECT_TRANSLATE(aspectRatio)][thisLOD][0];
|
||||
height = _grMipMapHostWHCmp4Bit[G3_ASPECT_TRANSLATE(aspectRatio)][thisLOD][1];
|
||||
} else if (format >= GR_TEXFMT_ARGB_CMP_DXT2 && format <= GR_TEXFMT_ARGB_CMP_DXT5) {
|
||||
} else if (format >= GR_TEXFMT_ARGB_CMP_DXT1 && format <= GR_TEXFMT_ARGB_CMP_DXT5) {
|
||||
width = _grMipMapHostWHDXT[G3_ASPECT_TRANSLATE(aspectRatio)][thisLOD][0];
|
||||
height = _grMipMapHostWHDXT[G3_ASPECT_TRANSLATE(aspectRatio)][thisLOD][1];
|
||||
} else {
|
||||
@@ -3596,8 +3594,7 @@ GR_DIENTRY(grTextureAuxBuffer, void,
|
||||
else
|
||||
offset = _grTexTextureMemRequired( thisLOD+1, largeLOD,
|
||||
aspectRatio, format,
|
||||
odd_even_mask, FXTRUE,
|
||||
FXFALSE );
|
||||
odd_even_mask, FXTRUE );
|
||||
|
||||
/* How do we deal with UMA?
|
||||
The tmu only makes sense when the UMA is not turned on.
|
||||
|
||||
@@ -348,7 +348,7 @@ GR_DDFUNC(_grTexDownloadNccTableExt,
|
||||
gc->stats.palDownloads++;
|
||||
gc->stats.palBytes += (end-start+1)<<2;
|
||||
|
||||
/*if (gc->tmu_state[tmu].ncc_table[which] != table)*/ {
|
||||
if (gc->tmu_state[tmu].ncc_table[which] != table) {
|
||||
SstRegs* texHW;
|
||||
int i;
|
||||
#ifdef GLIDE_POINTCAST_PALETTE
|
||||
@@ -652,7 +652,7 @@ GR_DDFUNC(_grTexDownloadPaletteExt,
|
||||
Return:
|
||||
none
|
||||
-------------------------------------------------------------------*/
|
||||
GR_EXT_ENTRY(grTexDownloadTableExt,
|
||||
GR_ENTRY(grTexDownloadTableExt,
|
||||
void,
|
||||
(GrChipID_t tmu, GrTexTable_t type, void *data))
|
||||
{
|
||||
@@ -664,10 +664,10 @@ GR_EXT_ENTRY(grTexDownloadTableExt,
|
||||
switch(type) {
|
||||
case GR_TEXTABLE_PALETTE:
|
||||
case GR_TEXTABLE_PALETTE_6666_EXT:
|
||||
_grTexDownloadPaletteExt(tmu, type, (GuTexPalette *)data, 0, 255);
|
||||
_grTexDownloadPalette(tmu, type, (GuTexPalette *)data, 0, 255);
|
||||
break;
|
||||
default: /* Type is an ncc table */
|
||||
_grTexDownloadNccTableExt(tmu, type, (GuNccTable*)data, 0, 11);
|
||||
_grTexDownloadNccTable(tmu, type, (GuNccTable*)data, 0, 11);
|
||||
break;
|
||||
}
|
||||
|
||||
@@ -705,7 +705,7 @@ GR_DDFUNC(_grTexDownloadNccTable,
|
||||
gc->stats.palDownloads++;
|
||||
gc->stats.palBytes += (end-start+1)<<2;
|
||||
|
||||
/*if (gc->tmu_state[tmu].ncc_table[which] != table)*/ {
|
||||
if (gc->tmu_state[tmu].ncc_table[which] != table) {
|
||||
SstRegs* texHW;
|
||||
int i;
|
||||
#ifdef GLIDE_POINTCAST_PALETTE
|
||||
@@ -1126,13 +1126,13 @@ _grTexDownloadMipMapLevelPartialTiled(GrChipID_t tmu,
|
||||
switch(texelSize) {
|
||||
case 4: /* 4-bit textures */
|
||||
{
|
||||
|
||||
const FxU32
|
||||
*src32 = (const FxU32*)data;
|
||||
|
||||
switch(maxS) {
|
||||
case 4: /* XXX need to test! */
|
||||
#if 0
|
||||
{
|
||||
const FxU16 *src16 = (const FxU16*)data;
|
||||
|
||||
src16++;
|
||||
for(; t <= maxT; t+=4) {
|
||||
FxU32
|
||||
texAddress = texOffset + t * texStrideBytes,
|
||||
@@ -1140,19 +1140,18 @@ _grTexDownloadMipMapLevelPartialTiled(GrChipID_t tmu,
|
||||
|
||||
LINEAR_WRITE_BEGIN(2, SSTCP_PKT5_LFB, texAddress, 0x00UL, 0x00UL);
|
||||
for (s = 0; s < 2; s++) {
|
||||
LINEAR_WRITE_SET(texAddress, (FxU32)(*src16));
|
||||
LINEAR_WRITE_SET(texAddress, *src32);
|
||||
texAddress++;
|
||||
src16 += 4;
|
||||
src32++;
|
||||
}
|
||||
LINEAR_WRITE_END();
|
||||
|
||||
}
|
||||
}
|
||||
#endif
|
||||
break;
|
||||
case 8:
|
||||
{
|
||||
const FxU32 *src32 = (const FxU32*)data;
|
||||
|
||||
texOffset += (t * texStrideBytes);
|
||||
for (; t <= maxT; t++) {
|
||||
LINEAR_WRITE_BEGIN(1, SSTCP_PKT5_LFB, texOffset, 0x0UL, 0x0UL);
|
||||
@@ -1165,8 +1164,6 @@ _grTexDownloadMipMapLevelPartialTiled(GrChipID_t tmu,
|
||||
break;
|
||||
default:
|
||||
{
|
||||
const FxU32 *src32 = (const FxU32*)data;
|
||||
|
||||
for (; t <= maxT; t++) {
|
||||
FxU32
|
||||
texAddress = texOffset + t * texStrideBytes,
|
||||
@@ -1393,8 +1390,7 @@ GR_ENTRY(grTexDownloadMipMapLevelPartial,
|
||||
(startAddress + _grTexTextureMemRequired(thisLod, largeLod,
|
||||
aspectRatio,
|
||||
format, evenOdd,
|
||||
FXTRUE,
|
||||
FXFALSE)
|
||||
FXTRUE)
|
||||
> gc->tmu_state[tmu].total_mem)),
|
||||
"insufficient texture ram at startAddress");
|
||||
GR_CHECK_F(FN_NAME, startAddress & SST_TEXTURE_ALIGN_MASK,
|
||||
@@ -1438,7 +1434,7 @@ GR_ENTRY(grTexDownloadMipMapLevelPartial,
|
||||
case GR_TEXFMT_ARGB_CMP_FXT1:
|
||||
GR_CHECK_F(FN_NAME, max_t >=
|
||||
_grMipMapHostWHCmp4Bit[G3_ASPECT_TRANSLATE(aspectRatio)]
|
||||
[thisLod][1], "invalid end row for fxt1, dxt1");
|
||||
[thisLod][1], "invalid end row for fxt1");
|
||||
break;
|
||||
case GR_TEXFMT_ARGB_CMP_DXT1:
|
||||
case GR_TEXFMT_ARGB_CMP_DXT2:
|
||||
@@ -1447,7 +1443,7 @@ GR_ENTRY(grTexDownloadMipMapLevelPartial,
|
||||
case GR_TEXFMT_ARGB_CMP_DXT5:
|
||||
GR_CHECK_F(FN_NAME, max_t >=
|
||||
_grMipMapHostWHDXT[G3_ASPECT_TRANSLATE(aspectRatio)]
|
||||
[thisLod][1], "invalid end row for dxt2,3,4,5");
|
||||
[thisLod][1], "invalid end row for DXTn");
|
||||
break;
|
||||
default:
|
||||
GR_CHECK_F(FN_NAME, max_t >=
|
||||
@@ -1514,12 +1510,14 @@ GR_ENTRY(grTexDownloadMipMapLevelPartial,
|
||||
* because the minimum level size is 16 bytes (8x4x1/2)
|
||||
* which matches the alignment restriction.
|
||||
*/
|
||||
/* KoolSmoky - same for DXT2,3,4,5 were the minimum level
|
||||
* size is 16 bytes (4x4x1) which also matches the alignment
|
||||
/* Same for DXT2,3,4,5 were the minimum level size is
|
||||
* 16 bytes (4x4x1) which also matches the alignment
|
||||
* restriction.
|
||||
* same for DXT1 ((4x4x1/2)x2) minimum level size is 16 bytes
|
||||
*/
|
||||
if(format != GR_TEXFMT_ARGB_CMP_FXT1 && format != GR_TEXFMT_ARGB_CMP_DXT1 &&
|
||||
/* XXX: we can't skip this part for DXT1 because the smallest
|
||||
* mipmap is 8 bytes (4x4x1/2).
|
||||
*/
|
||||
if(format != GR_TEXFMT_ARGB_CMP_FXT1 &&
|
||||
format != GR_TEXFMT_ARGB_CMP_DXT2 && format != GR_TEXFMT_ARGB_CMP_DXT3 &&
|
||||
format != GR_TEXFMT_ARGB_CMP_DXT4 && format != GR_TEXFMT_ARGB_CMP_DXT5 ) {
|
||||
const FxU32
|
||||
@@ -1530,8 +1528,9 @@ GR_ENTRY(grTexDownloadMipMapLevelPartial,
|
||||
? GR_LOD_LOG2_256 : thisLod + 1),
|
||||
formatMult = _grBitsPerTexel[format];
|
||||
FxU32
|
||||
levelSize = (_grMipMapHostSize[aspectIndex][lodIndex]
|
||||
* formatMult)>>3; /* Cvt from bits to bytes */
|
||||
levelSize = ((format == GR_TEXFMT_ARGB_CMP_DXT1)
|
||||
? (_grMipMapHostSizeDXT[aspectIndex][lodIndex] * formatMult) >> 3
|
||||
: (_grMipMapHostSize[aspectIndex][lodIndex] * formatMult) >> 3); /* bytes */
|
||||
|
||||
GR_CHECK_F(FN_NAME, formatMult == 0, "invalid texture format");
|
||||
|
||||
@@ -1550,8 +1549,9 @@ GR_ENTRY(grTexDownloadMipMapLevelPartial,
|
||||
* colon.
|
||||
*/
|
||||
while(maxLod < GR_LOD_LOG2_256) {
|
||||
levelSize = (_grMipMapHostSize[aspectIndex][maxLod]
|
||||
* formatMult)>>3; // bits to bytes convertion
|
||||
levelSize = ((format == GR_TEXFMT_ARGB_CMP_DXT1)
|
||||
? (_grMipMapHostSizeDXT[aspectIndex][maxLod] * formatMult) >> 3
|
||||
: (_grMipMapHostSize[aspectIndex][maxLod] * formatMult) >> 3); /* bytes */
|
||||
if (levelSize >= SST_TEXTURE_ALIGN) break;
|
||||
// check on the Even/Odd mask to see if the mip-map affects this TMU
|
||||
if((maxLod & 1) ? (evenOdd & GR_MIPMAPLEVELMASK_ODD) : (evenOdd & GR_MIPMAPLEVELMASK_EVEN))
|
||||
@@ -1574,7 +1574,6 @@ GR_ENTRY(grTexDownloadMipMapLevelPartial,
|
||||
aspectRatio,
|
||||
format,
|
||||
evenOdd,
|
||||
FXFALSE,
|
||||
FXFALSE);
|
||||
}
|
||||
}
|
||||
@@ -1611,7 +1610,7 @@ GR_ENTRY(grTexDownloadMipMapLevelPartial,
|
||||
max_s = widthSel = (width >> 3);
|
||||
break;
|
||||
case GR_TEXFMT_ARGB_CMP_DXT1:
|
||||
/* Minimum size for DXT1 mipmaps is 8x4 (two 4x4 mipmaps side by side). */
|
||||
/* Minimum size for DXT1 mipmaps is 4x4. */
|
||||
formatSel = 0;
|
||||
width = _grMipMapHostWHDXT[G3_ASPECT_TRANSLATE(aspectRatio)][thisLod][0];
|
||||
max_s = widthSel = (width >> 3);
|
||||
|
||||
@@ -90,48 +90,26 @@ _grTexDownload_Default_4_4(struct GrGC_s* gc, const FxU32 tmuBaseAddr,
|
||||
const FxI32 maxS, const FxI32 minT,
|
||||
const FxI32 maxT, void* texData)
|
||||
{
|
||||
/* for DXT1 8*4 mipmaps */
|
||||
/* for DXT1 4*4 mipmaps */
|
||||
#define FN_NAME "_grTexDownload_Default_4_4"
|
||||
#if 0
|
||||
const FxU16
|
||||
*src16 = (const FxU16*)texData;
|
||||
FxI32
|
||||
t = minT;
|
||||
|
||||
src16++;
|
||||
for (; t <= maxT; t+=4) {
|
||||
FxU32 tex_address = tmuBaseAddr + (t << 2UL), s;
|
||||
LINEAR_WRITE_BEGIN(2, PACKET5_MODE, (FxU32)tex_address, 0x00UL, 0x00UL);
|
||||
for (s = 0; s < 2; s++) {
|
||||
LINEAR_WRITE_SET(tex_address, (FxU32)(*src16));
|
||||
tex_address++;
|
||||
src16+=4;
|
||||
}
|
||||
LINEAR_WRITE_END();
|
||||
}
|
||||
#else
|
||||
const FxU32
|
||||
*src32 = (const FxU32*)texData;
|
||||
FxI32
|
||||
t = minT;
|
||||
|
||||
/* Ok, what we do is write 8 bytes at a time (4 'half' lines) */
|
||||
/* Anyone attempting to do partial DXT1 uploads is a moron */
|
||||
for (; t <= maxT; t+=4) {
|
||||
FxU32 tex_address = tmuBaseAddr + (t << 2UL);
|
||||
int s;
|
||||
|
||||
LINEAR_WRITE_BEGIN(2, PACKET5_MODE, (FxU32)tex_address, 0x00UL, 0x00UL);
|
||||
for (s=0;s<2;s++)
|
||||
{
|
||||
const FxU32 t0 = *src32;
|
||||
LINEAR_WRITE_SET(tex_address, t0);
|
||||
tex_address++;
|
||||
src32++;
|
||||
}
|
||||
LINEAR_WRITE_END();
|
||||
for (s = 0; s < 2; s++) {
|
||||
const FxU32 t0 = *src32;
|
||||
LINEAR_WRITE_SET(tex_address, t0);
|
||||
tex_address++;
|
||||
src32++;
|
||||
}
|
||||
LINEAR_WRITE_END();
|
||||
}
|
||||
#endif
|
||||
#undef FN_NAME
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user