summaryrefslogtreecommitdiff
path: root/Source/Core/VideoCommon/TextureDecoder_Common.cpp
diff options
context:
space:
mode:
authorJasper St. Pierre <jstpierre@mecheye.net>2014-08-10 15:48:11 -0400
committerJasper St. Pierre <jstpierre@mecheye.net>2014-09-04 18:36:57 -0700
commit0b7bed4a5297a2368a7f2e2f921a28c6e628d8fb (patch)
treede86a577a40401e121f55b1c96b43ebcc10fb523 /Source/Core/VideoCommon/TextureDecoder_Common.cpp
parentea1245d19121d74b1f8398c4c8a0e66d2bb2f5c7 (diff)
TextureDecoder: Simplify how the reference texture decoder works
Instead of having three separate functions and checking the tlutfmt in a variety of places, just do it once in a helper method. This is already for the slow path either in our Generic decoder or in our Software renderer, so it doesn't matter that this is slower. x64 will continue using the separate functions for speed.
Diffstat (limited to 'Source/Core/VideoCommon/TextureDecoder_Common.cpp')
-rw-r--r--Source/Core/VideoCommon/TextureDecoder_Common.cpp54
1 files changed, 18 insertions, 36 deletions
diff --git a/Source/Core/VideoCommon/TextureDecoder_Common.cpp b/Source/Core/VideoCommon/TextureDecoder_Common.cpp
index cb71c3613f..1fd09fc1f9 100644
--- a/Source/Core/VideoCommon/TextureDecoder_Common.cpp
+++ b/Source/Core/VideoCommon/TextureDecoder_Common.cpp
@@ -301,6 +301,21 @@ struct DXTBlock
u8 lines[4];
};
+static inline u32 decodePalettedPixel(u16 pixel, TlutFormat tlutfmt)
+{
+ switch (tlutfmt)
+ {
+ case GX_TL_IA8:
+ return decodeIA8Swapped(pixel);
+ case GX_TL_RGB565:
+ return decode565RGBA(Common::swap16(pixel));
+ case GX_TL_RGB5A3:
+ return decode5A3RGBA(Common::swap16(pixel));
+ default:
+ return 0;
+ }
+}
+
void TexDecoder_DecodeTexel(u8 *dst, const u8 *src, int s, int t, int imageWidth, int texformat, const u8* tlut_, TlutFormat tlutfmt)
{
/* General formula for computing texture offset
@@ -332,18 +347,7 @@ void TexDecoder_DecodeTexel(u8 *dst, const u8 *src, int s, int t, int imageWidth
u8 val = (*(src + offset) >> rs) & 0xF;
u16 *tlut = (u16*) tlut_;
- switch (tlutfmt)
- {
- case GX_TL_IA8:
- *((u32*)dst) = decodeIA8Swapped(tlut[val]);
- break;
- case GX_TL_RGB565:
- *((u32*)dst) = decode565RGBA(Common::swap16(tlut[val]));
- break;
- case GX_TL_RGB5A3:
- *((u32*)dst) = decode5A3RGBA(Common::swap16(tlut[val]));
- break;
- }
+ *((u32*)dst) = decodePalettedPixel(tlut[val], tlutfmt);
}
break;
case GX_TF_I4:
@@ -397,18 +401,7 @@ void TexDecoder_DecodeTexel(u8 *dst, const u8 *src, int s, int t, int imageWidth
u8 val = *(src + base + blkOff);
u16 *tlut = (u16*) tlut_;
- switch (tlutfmt)
- {
- case GX_TL_IA8:
- *((u32*)dst) = decodeIA8Swapped(tlut[val]);
- break;
- case GX_TL_RGB565:
- *((u32*)dst) = decode565RGBA(Common::swap16(tlut[val]));
- break;
- case GX_TL_RGB5A3:
- *((u32*)dst) = decode5A3RGBA(Common::swap16(tlut[val]));
- break;
- }
+ *((u32*)dst) = decodePalettedPixel(tlut[val], tlutfmt);
}
break;
case GX_TF_IA4:
@@ -462,18 +455,7 @@ void TexDecoder_DecodeTexel(u8 *dst, const u8 *src, int s, int t, int imageWidth
u16 val = Common::swap16(*valAddr) & 0x3FFF;
u16 *tlut = (u16*) tlut_;
- switch (tlutfmt)
- {
- case GX_TL_IA8:
- *((u32*)dst) = decodeIA8Swapped(tlut[val]);
- break;
- case GX_TL_RGB565:
- *((u32*)dst) = decode565RGBA(Common::swap16(tlut[val]));
- break;
- case GX_TL_RGB5A3:
- *((u32*)dst) = decode5A3RGBA(Common::swap16(tlut[val]));
- break;
- }
+ *((u32*)dst) = decodePalettedPixel(tlut[val], tlutfmt);
}
break;
case GX_TF_RGB565: