TextureDecoder: Add an enum for the TLUT formats

Quick code cleanup. The enum names and values come from libogc.
This commit is contained in:
Jasper St. Pierre
2014-08-10 15:04:29 -04:00
parent 32da01edec
commit fcd4ecc942
6 changed files with 50 additions and 41 deletions

View File

@ -246,7 +246,7 @@ static void decodeDXTBlockRGBA(u32 *dst, const DXTBlock *src, int pitch)
// TODO: complete SSE2 optimization of less often used texture formats.
// TODO: refactor algorithms using _mm_loadl_epi64 unaligned loads to prefer 128-bit aligned loads.
PC_TexFormat _TexDecoder_DecodeImpl(u32 * dst, const u8 * src, int width, int height, int texformat, int tlutaddr, int tlutfmt)
PC_TexFormat _TexDecoder_DecodeImpl(u32 * dst, const u8 * src, int width, int height, int texformat, int tlutaddr, TlutFormat tlutfmt)
{
const int Wsteps4 = (width + 3) / 4;
@ -255,7 +255,7 @@ PC_TexFormat _TexDecoder_DecodeImpl(u32 * dst, const u8 * src, int width, int he
switch (texformat)
{
case GX_TF_C4:
if (tlutfmt == 2)
if (tlutfmt == GX_TL_RGB5A3)
{
// Special decoding is required for TLUT format 5A3
for (int y = 0; y < height; y += 8)
@ -263,14 +263,14 @@ PC_TexFormat _TexDecoder_DecodeImpl(u32 * dst, const u8 * src, int width, int he
for (int iy = 0, xStep = 8 * yStep; iy < 8; iy++,xStep++)
decodebytesC4_5A3_To_rgba32(dst + (y + iy) * width + x, src + 4 * xStep, tlutaddr);
}
else if (tlutfmt == 0)
else if (tlutfmt == GX_TL_IA8)
{
for (int y = 0; y < height; y += 8)
for (int x = 0, yStep = (y / 8) * Wsteps8; x < width; x += 8,yStep++)
for (int iy = 0, xStep = 8 * yStep; iy < 8; iy++,xStep++)
decodebytesC4IA8_To_RGBA(dst + (y + iy) * width + x, src + 4 * xStep, tlutaddr);
}
else
else if (tlutfmt == GX_TL_RGB565)
{
for (int y = 0; y < height; y += 8)
for (int x = 0, yStep = (y / 8) * Wsteps8; x < width; x += 8,yStep++)
@ -317,7 +317,7 @@ PC_TexFormat _TexDecoder_DecodeImpl(u32 * dst, const u8 * src, int width, int he
}
break;
case GX_TF_C8:
if (tlutfmt == 2)
if (tlutfmt == GX_TL_RGB5A3)
{
// Special decoding is required for TLUT format 5A3
for (int y = 0; y < height; y += 4)
@ -325,14 +325,14 @@ PC_TexFormat _TexDecoder_DecodeImpl(u32 * dst, const u8 * src, int width, int he
for (int iy = 0, xStep = 4 * yStep; iy < 4; iy++, xStep++)
decodebytesC8_5A3_To_RGBA32((u32*)dst + (y + iy) * width + x, src + 8 * xStep, tlutaddr);
}
else if (tlutfmt == 0)
else if (tlutfmt == GX_TL_IA8)
{
for (int y = 0; y < height; y += 4)
for (int x = 0, yStep = (y / 4) * Wsteps8; x < width; x += 8, yStep++)
for (int iy = 0, xStep = 4 * yStep; iy < 4; iy++, xStep++)
decodebytesC8IA8_To_RGBA(dst + (y + iy) * width + x, src + 8 * xStep, tlutaddr);
}
else
else if (tlutfmt == GX_TL_RGB565)
{
for (int y = 0; y < height; y += 4)
for (int x = 0, yStep = (y / 4) * Wsteps8; x < width; x += 8, yStep++)
@ -366,7 +366,7 @@ PC_TexFormat _TexDecoder_DecodeImpl(u32 * dst, const u8 * src, int width, int he
}
break;
case GX_TF_C14X2:
if (tlutfmt == 2)
if (tlutfmt == GX_TL_RGB5A3)
{
// Special decoding is required for TLUT format 5A3
for (int y = 0; y < height; y += 4)
@ -374,14 +374,14 @@ PC_TexFormat _TexDecoder_DecodeImpl(u32 * dst, const u8 * src, int width, int he
for (int iy = 0, xStep = 4 * yStep; iy < 4; iy++, xStep++)
decodebytesC14X2_5A3_To_RGBA(dst + (y + iy) * width + x, (u16*)(src + 8 * xStep), tlutaddr);
}
else if (tlutfmt == 0)
else if (tlutfmt == GX_TL_IA8)
{
for (int y = 0; y < height; y += 4)
for (int x = 0, yStep = (y / 4) * Wsteps4; x < width; x += 4, yStep++)
for (int iy = 0, xStep = 4 * yStep; iy < 4; iy++, xStep++)
decodebytesC14X2IA8_To_RGBA(dst + (y + iy) * width + x, (u16*)(src + 8 * xStep), tlutaddr);
}
else
else if (tlutfmt == GX_TL_RGB565)
{
for (int y = 0; y < height; y += 4)
for (int x = 0, yStep = (y / 4) * Wsteps4; x < width; x += 4, yStep++)