mirror of
https://github.com/libretro/ppsspp.git
synced 2025-02-15 14:40:20 +00:00
softgpu : use switch case for texture format
This commit is contained in:
parent
bfd60e95a4
commit
eca79d35a7
@ -72,21 +72,21 @@ static inline u32 LookupColor(unsigned int index, unsigned int level)
|
|||||||
|
|
||||||
// TODO: No idea if these bswaps are correct
|
// TODO: No idea if these bswaps are correct
|
||||||
switch (gstate.getClutPaletteFormat()) {
|
switch (gstate.getClutPaletteFormat()) {
|
||||||
case GE_TFMT_5650:
|
case GE_TFMT_5650:
|
||||||
return DecodeRGB565(reinterpret_cast<u16*>(clut)[index + clutSharingOffset]);
|
return DecodeRGB565(reinterpret_cast<u16*>(clut)[index + clutSharingOffset]);
|
||||||
|
|
||||||
case GE_TFMT_5551:
|
case GE_TFMT_5551:
|
||||||
return DecodeRGBA5551(reinterpret_cast<u16*>(clut)[index + clutSharingOffset]);
|
return DecodeRGBA5551(reinterpret_cast<u16*>(clut)[index + clutSharingOffset]);
|
||||||
|
|
||||||
case GE_TFMT_4444:
|
case GE_TFMT_4444:
|
||||||
return DecodeRGBA4444(reinterpret_cast<u16*>(clut)[index + clutSharingOffset]);
|
return DecodeRGBA4444(reinterpret_cast<u16*>(clut)[index + clutSharingOffset]);
|
||||||
|
|
||||||
case GE_TFMT_8888:
|
case GE_TFMT_8888:
|
||||||
return DecodeRGBA8888(clut[index + clutSharingOffset]);
|
return DecodeRGBA8888(clut[index + clutSharingOffset]);
|
||||||
|
|
||||||
default:
|
default:
|
||||||
ERROR_LOG(G3D, "Unsupported palette format: %x", gstate.getClutPaletteFormat());
|
ERROR_LOG(G3D, "Unsupported palette format: %x", gstate.getClutPaletteFormat());
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -123,8 +123,7 @@ static inline void GetTexelCoordinates(int level, float s, float t, unsigned int
|
|||||||
|
|
||||||
static inline void GetTextureCoordinates(const VertexData& v0, const VertexData& v1, const VertexData& v2, int w0, int w1, int w2, float& s, float& t)
|
static inline void GetTextureCoordinates(const VertexData& v0, const VertexData& v1, const VertexData& v2, int w0, int w1, int w2, float& s, float& t)
|
||||||
{
|
{
|
||||||
switch (gstate.getUVGenMode())
|
switch (gstate.getUVGenMode()) {
|
||||||
{
|
|
||||||
case GE_TEXMAP_TEXTURE_COORDS:
|
case GE_TEXMAP_TEXTURE_COORDS:
|
||||||
case GE_TEXMAP_UNKNOWN:
|
case GE_TEXMAP_UNKNOWN:
|
||||||
case GE_TEXMAP_ENVIRONMENT_MAP:
|
case GE_TEXMAP_ENVIRONMENT_MAP:
|
||||||
@ -158,7 +157,6 @@ static inline void GetTextureCoordinates(const VertexData& v0, const VertexData&
|
|||||||
default:
|
default:
|
||||||
ERROR_LOG(G3D, "Unsupported texture mapping mode %x!", gstate.getUVGenMode());
|
ERROR_LOG(G3D, "Unsupported texture mapping mode %x!", gstate.getUVGenMode());
|
||||||
break;
|
break;
|
||||||
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -173,43 +171,48 @@ static inline u32 SampleNearest(int level, unsigned int u, unsigned int v)
|
|||||||
|
|
||||||
// TODO: Should probably check if textures are aligned properly...
|
// TODO: Should probably check if textures are aligned properly...
|
||||||
|
|
||||||
if (texfmt == GE_TFMT_4444) {
|
switch (texfmt) {
|
||||||
|
case GE_TFMT_4444:
|
||||||
srcptr += GetPixelDataOffset(16, texbufwidth*8, u, v);
|
srcptr += GetPixelDataOffset(16, texbufwidth*8, u, v);
|
||||||
return DecodeRGBA4444(*(u16*)srcptr);
|
return DecodeRGBA4444(*(u16*)srcptr);
|
||||||
} else if (texfmt == GE_TFMT_5551) {
|
|
||||||
|
case GE_TFMT_5551:
|
||||||
srcptr += GetPixelDataOffset(16, texbufwidth*8, u, v);
|
srcptr += GetPixelDataOffset(16, texbufwidth*8, u, v);
|
||||||
return DecodeRGBA5551(*(u16*)srcptr);
|
return DecodeRGBA5551(*(u16*)srcptr);
|
||||||
} else if (texfmt == GE_TFMT_5650) {
|
|
||||||
|
case GE_TFMT_5650:
|
||||||
srcptr += GetPixelDataOffset(16, texbufwidth*8, u, v);
|
srcptr += GetPixelDataOffset(16, texbufwidth*8, u, v);
|
||||||
return DecodeRGB565(*(u16*)srcptr);
|
return DecodeRGB565(*(u16*)srcptr);
|
||||||
} else if (texfmt == GE_TFMT_8888) {
|
|
||||||
|
case GE_TFMT_8888:
|
||||||
srcptr += GetPixelDataOffset(32, texbufwidth*8, u, v);
|
srcptr += GetPixelDataOffset(32, texbufwidth*8, u, v);
|
||||||
return DecodeRGBA8888(*(u32*)srcptr);
|
return DecodeRGBA8888(*(u32*)srcptr);
|
||||||
} else if (texfmt == GE_TFMT_CLUT32) {
|
|
||||||
srcptr += GetPixelDataOffset(32, texbufwidth*8, u, v);
|
|
||||||
|
|
||||||
u32 val = srcptr[0] + (srcptr[1] << 8) + (srcptr[2] << 16) + (srcptr[3] << 24);
|
case GE_TFMT_CLUT32:
|
||||||
|
{
|
||||||
return LookupColor(gstate.transformClutIndex(val), level);
|
srcptr += GetPixelDataOffset(32, texbufwidth*8, u, v);
|
||||||
} else if (texfmt == GE_TFMT_CLUT16) {
|
u32 val = srcptr[0] + (srcptr[1] << 8) + (srcptr[2] << 16) + (srcptr[3] << 24);
|
||||||
srcptr += GetPixelDataOffset(16, texbufwidth*8, u, v);
|
return LookupColor(gstate.transformClutIndex(val), level);
|
||||||
|
}
|
||||||
u16 val = srcptr[0] + (srcptr[1] << 8);
|
case GE_TFMT_CLUT16:
|
||||||
|
{
|
||||||
return LookupColor(gstate.transformClutIndex(val), level);
|
srcptr += GetPixelDataOffset(16, texbufwidth*8, u, v);
|
||||||
} else if (texfmt == GE_TFMT_CLUT8) {
|
u16 val = srcptr[0] + (srcptr[1] << 8);
|
||||||
srcptr += GetPixelDataOffset(8, texbufwidth*8, u, v);
|
return LookupColor(gstate.transformClutIndex(val), level);
|
||||||
|
}
|
||||||
u8 val = *srcptr;
|
case GE_TFMT_CLUT8:
|
||||||
|
{
|
||||||
return LookupColor(gstate.transformClutIndex(val), level);
|
srcptr += GetPixelDataOffset(8, texbufwidth*8, u, v);
|
||||||
} else if (texfmt == GE_TFMT_CLUT4) {
|
u8 val = *srcptr;
|
||||||
srcptr += GetPixelDataOffset(4, texbufwidth*8, u, v);
|
return LookupColor(gstate.transformClutIndex(val), level);
|
||||||
|
}
|
||||||
u8 val = (u & 1) ? (srcptr[0] >> 4) : (srcptr[0] & 0xF);
|
case GE_TFMT_CLUT4:
|
||||||
|
{
|
||||||
return LookupColor(gstate.transformClutIndex(val), level);
|
srcptr += GetPixelDataOffset(4, texbufwidth*8, u, v);
|
||||||
} else {
|
u8 val = (u & 1) ? (srcptr[0] >> 4) : (srcptr[0] & 0xF);
|
||||||
|
return LookupColor(gstate.transformClutIndex(val), level);
|
||||||
|
}
|
||||||
|
default:
|
||||||
ERROR_LOG(G3D, "Unsupported texture format: %x", texfmt);
|
ERROR_LOG(G3D, "Unsupported texture format: %x", texfmt);
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user