summaryrefslogtreecommitdiff
path: root/Source/Core/VideoCommon/Src/TextureDecoder.cpp
diff options
context:
space:
mode:
authorNolan Check <Nolan.Check@gmail.com>2009-05-06 02:10:07 +0000
committerNolan Check <Nolan.Check@gmail.com>2009-05-06 02:10:07 +0000
commit3ba23768e8081c6335bc3aed8985c4746a2b7706 (patch)
tree3e2003030ce09eb9629bc16423a5b515f8db68c8 /Source/Core/VideoCommon/Src/TextureDecoder.cpp
parent05efaeeef1e9417de629fac3eacc90fd977f09fa (diff)
Add PC-native DXT1 support to VideoCommon and VideoOGL. Thanks to XTra.KrazzY and death2droid.
git-svn-id: https://dolphin-emu.googlecode.com/svn/trunk@3159 8ced0084-cf51-0410-be5f-012b33b47a6e
Diffstat (limited to 'Source/Core/VideoCommon/Src/TextureDecoder.cpp')
-rw-r--r--Source/Core/VideoCommon/Src/TextureDecoder.cpp35
1 files changed, 22 insertions, 13 deletions
diff --git a/Source/Core/VideoCommon/Src/TextureDecoder.cpp b/Source/Core/VideoCommon/Src/TextureDecoder.cpp
index 4ca645caaf..e934997dd7 100644
--- a/Source/Core/VideoCommon/Src/TextureDecoder.cpp
+++ b/Source/Core/VideoCommon/Src/TextureDecoder.cpp
@@ -323,6 +323,19 @@ void decodeDXTBlock(u32 *dst, const DXTBlock *src, int pitch)
}
}
+static void copyDXTBlock(u8* dst, const u8* src)
+{
+ ((u16*)dst)[0] = Common::swap16(((u16*)src)[0]);
+ ((u16*)dst)[1] = Common::swap16(((u16*)src)[1]);
+ u32 pixels = ((u32*)src)[1];
+ // A bit of trickiness here: the row are in the same order
+ // between the two formats, but the ordering within the rows
+ // is reversed.
+ pixels = ((pixels >> 4) & 0x0F0F0F0F) | ((pixels << 4) & 0xF0F0F0F0);
+ pixels = ((pixels >> 2) & 0x33333333) | ((pixels << 2) & 0xCCCCCCCC);
+ ((u32*)dst)[1] = pixels;
+}
+
//switch endianness, unswizzle
//TODO: to save memory, don't blindly convert everything to argb8888
@@ -439,24 +452,20 @@ PC_TexFormat TexDecoder_Decode_real(u8 *dst, const u8 *src, int width, int heigh
return PC_TEX_FMT_BGRA32;
case GX_TF_CMPR: // speed critical
{
- // TODO: Shuffle to PC S3TC (DXTC) format instead of converting
- // 11111111 22222222 55555555 66666666
- // 33333333 44444444 77777777 88888888
- // The metroid games use this format almost exclusively.
for (int y = 0; y < height; y += 8)
for (int x = 0; x < width; x += 8)
{
- decodeDXTBlock((u32*)dst+y*width+x, (DXTBlock*)src, width);
- src += sizeof(DXTBlock);
- decodeDXTBlock((u32*)dst+y*width+x+4, (DXTBlock*)src, width);
- src += sizeof(DXTBlock);
- decodeDXTBlock((u32*)dst+(y+4)*width+x, (DXTBlock*)src, width);
- src += sizeof(DXTBlock);
- decodeDXTBlock((u32*)dst+(y+4)*width+x+4, (DXTBlock*)src, width);
- src += sizeof(DXTBlock);
+ copyDXTBlock(dst+(y/2)*width+x*2, src);
+ src += 8;
+ copyDXTBlock(dst+(y/2)*width+x*2+8, src);
+ src += 8;
+ copyDXTBlock(dst+(y/2+2)*width+x*2, src);
+ src += 8;
+ copyDXTBlock(dst+(y/2+2)*width+x*2+8, src);
+ src += 8;
}
}
- return PC_TEX_FMT_BGRA32;
+ return PC_TEX_FMT_DXT1;
}
// The "copy" texture formats, too?