rend: support planar VQ textures
Fixes gens4all emu in teenage mutant ninja turtle collection. Issue #868
This commit is contained in:
parent
53e0f12c22
commit
a7f2008763
|
@ -304,20 +304,21 @@ struct PvrTexInfo
|
|||
TexConvFP32 PL32;
|
||||
TexConvFP32 TW32;
|
||||
TexConvFP32 VQ32;
|
||||
TexConvFP32 PLVQ32;
|
||||
// Conversion to 8 bpp (palette)
|
||||
TexConvFP8 TW8;
|
||||
};
|
||||
|
||||
#define TEX_CONV_TABLE \
|
||||
const PvrTexInfo pvrTexInfo[8] = \
|
||||
{ /* name bpp Final format Twiddled VQ Planar(32b) Twiddled(32b) VQ (32b) Palette (8b) */ \
|
||||
{"1555", 16, TextureType::_5551, tex1555_TW, tex1555_VQ, tex1555_PL32, tex1555_TW32, tex1555_VQ32, nullptr }, \
|
||||
{"565", 16, TextureType::_565, tex565_TW, tex565_VQ, tex565_PL32, tex565_TW32, tex565_VQ32, nullptr }, \
|
||||
{"4444", 16, TextureType::_4444, tex4444_TW, tex4444_VQ, tex4444_PL32, tex4444_TW32, tex4444_VQ32, nullptr }, \
|
||||
{"yuv", 16, TextureType::_8888, nullptr, nullptr, texYUV422_PL, texYUV422_TW, texYUV422_VQ, nullptr }, \
|
||||
{"bumpmap", 16, TextureType::_4444, texBMP_TW, texBMP_VQ, tex4444_PL32, tex4444_TW32, tex4444_VQ32, nullptr }, \
|
||||
{"pal4", 4, TextureType::_5551, texPAL4_TW, texPAL4_VQ, nullptr, texPAL4_TW32, texPAL4_VQ32, texPAL4PT_TW }, \
|
||||
{"pal8", 8, TextureType::_5551, texPAL8_TW, texPAL8_VQ, nullptr, texPAL8_TW32, texPAL8_VQ32, texPAL8PT_TW }, \
|
||||
{ /* name bpp Final format Twiddled VQ Planar(32b) Twiddled(32b) VQ (32b) PL VQ (32b) Palette (8b) */ \
|
||||
{"1555", 16, TextureType::_5551, tex1555_TW, tex1555_VQ, tex1555_PL32, tex1555_TW32, tex1555_VQ32, tex1555_PLVQ32, nullptr }, \
|
||||
{"565", 16, TextureType::_565, tex565_TW, tex565_VQ, tex565_PL32, tex565_TW32, tex565_VQ32, tex565_PLVQ32, nullptr }, \
|
||||
{"4444", 16, TextureType::_4444, tex4444_TW, tex4444_VQ, tex4444_PL32, tex4444_TW32, tex4444_VQ32, tex4444_PLVQ32, nullptr }, \
|
||||
{"yuv", 16, TextureType::_8888, nullptr, nullptr, texYUV422_PL, texYUV422_TW, texYUV422_VQ, texYUV422_PLVQ, nullptr }, \
|
||||
{"bumpmap", 16, TextureType::_4444, texBMP_TW, texBMP_VQ, tex4444_PL32, tex4444_TW32, tex4444_VQ32, tex4444_PLVQ32, nullptr }, \
|
||||
{"pal4", 4, TextureType::_5551, texPAL4_TW, texPAL4_VQ, nullptr, texPAL4_TW32, texPAL4_VQ32, nullptr, texPAL4PT_TW }, \
|
||||
{"pal8", 8, TextureType::_5551, texPAL8_TW, texPAL8_VQ, nullptr, texPAL8_TW32, texPAL8_VQ32, nullptr, texPAL8PT_TW }, \
|
||||
{"ns/1555", 0}, \
|
||||
}
|
||||
|
||||
|
@ -486,11 +487,6 @@ BaseTextureCacheData::BaseTextureCacheData(TSP tsp, TCW tcw)
|
|||
if (tcw.ScanOrder && tex->PL32 != nullptr)
|
||||
{
|
||||
//Texture is stored 'planar' in memory, no deswizzle is needed
|
||||
if (tcw.VQ_Comp != 0)
|
||||
{
|
||||
WARN_LOG(RENDERER, "Warning: planar texture with VQ set (invalid)");
|
||||
this->tcw.VQ_Comp = 0;
|
||||
}
|
||||
if (tcw.MipMapped != 0)
|
||||
{
|
||||
WARN_LOG(RENDERER, "Warning: planar texture with mipmaps (invalid)");
|
||||
|
@ -508,9 +504,20 @@ BaseTextureCacheData::BaseTextureCacheData(TSP tsp, TCW tcw)
|
|||
|
||||
//Call the format specific conversion code
|
||||
texconv = nullptr;
|
||||
texconv32 = tex->PL32;
|
||||
//calculate the size, in bytes, for the locking
|
||||
size = stride * height * tex->bpp / 8;
|
||||
if (tcw.VQ_Comp != 0)
|
||||
{
|
||||
// VQ
|
||||
texconv32 = tex->PLVQ32;
|
||||
mmStartAddress += VQ_CODEBOOK_SIZE;
|
||||
size = stride * height / 4;
|
||||
}
|
||||
else
|
||||
{
|
||||
// Normal
|
||||
texconv32 = tex->PL32;
|
||||
//calculate the size, in bytes, for the locking
|
||||
size = stride * height * tex->bpp / 8;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
|
|
|
@ -420,6 +420,26 @@ void texture_PL(PixelBuffer<typename PixelConvertor::unpacked_type>* pb, const u
|
|||
}
|
||||
}
|
||||
|
||||
template<class PixelConvertor>
|
||||
void texture_PLVQ(PixelBuffer<typename PixelConvertor::unpacked_type>* pb, const u8* p_in, u32 width, u32 height)
|
||||
{
|
||||
pb->amove(0, 0);
|
||||
|
||||
height /= PixelConvertor::ypp;
|
||||
width /= PixelConvertor::xpp;
|
||||
|
||||
for (u32 y = 0; y < height; y++)
|
||||
{
|
||||
for (u32 x = 0; x < width; x++)
|
||||
{
|
||||
u8 p = *p_in++;
|
||||
PixelConvertor::Convert(pb, &vq_codebook[p * 8]);
|
||||
pb->rmovex(PixelConvertor::xpp);
|
||||
}
|
||||
pb->rmovey(PixelConvertor::ypp);
|
||||
}
|
||||
}
|
||||
|
||||
template<class PixelConvertor>
|
||||
void texture_TW(PixelBuffer<typename PixelConvertor::unpacked_type>* pb, const u8* p_in, u32 Width, u32 Height)
|
||||
{
|
||||
|
@ -497,6 +517,11 @@ constexpr TexConvFP32 tex565_PL32 = texture_PL<ConvertPlanar<Unpacker565_32<RGBA
|
|||
constexpr TexConvFP32 tex1555_PL32 = texture_PL<ConvertPlanar<Unpacker1555_32<RGBAPacker>>>;
|
||||
constexpr TexConvFP32 tex4444_PL32 = texture_PL<ConvertPlanar<Unpacker4444_32<RGBAPacker>>>;
|
||||
|
||||
constexpr TexConvFP32 texYUV422_PLVQ = texture_PLVQ<ConvertPlanarYUV<RGBAPacker>>;
|
||||
constexpr TexConvFP32 tex565_PLVQ32 = texture_PLVQ<ConvertPlanar<Unpacker565_32<RGBAPacker>>>;
|
||||
constexpr TexConvFP32 tex1555_PLVQ32 = texture_PLVQ<ConvertPlanar<Unpacker1555_32<RGBAPacker>>>;
|
||||
constexpr TexConvFP32 tex4444_PLVQ32 = texture_PLVQ<ConvertPlanar<Unpacker4444_32<RGBAPacker>>>;
|
||||
|
||||
//Twiddle
|
||||
constexpr TexConvFP tex1555_TW = texture_TW<ConvertTwiddle<Unpacker1555>>;
|
||||
constexpr TexConvFP tex4444_TW = texture_TW<ConvertTwiddle<Unpacker4444>>;
|
||||
|
@ -527,6 +552,11 @@ constexpr TexConvFP32 tex565_PL32 = texture_PL<ConvertPlanar<Unpacker565_32<BGRA
|
|||
constexpr TexConvFP32 tex1555_PL32 = texture_PL<ConvertPlanar<Unpacker1555_32<BGRAPacker>>>;
|
||||
constexpr TexConvFP32 tex4444_PL32 = texture_PL<ConvertPlanar<Unpacker4444_32<BGRAPacker>>>;
|
||||
|
||||
constexpr TexConvFP32 texYUV422_PLVQ = texture_PLVQ<ConvertPlanarYUV<BGRAPacker>>;
|
||||
constexpr TexConvFP32 tex565_PLVQ32 = texture_PLVQ<ConvertPlanar<Unpacker565_32<BGRAPacker>>>;
|
||||
constexpr TexConvFP32 tex1555_PLVQ32 = texture_PLVQ<ConvertPlanar<Unpacker1555_32<BGRAPacker>>>;
|
||||
constexpr TexConvFP32 tex4444_PLVQ32 = texture_PLVQ<ConvertPlanar<Unpacker4444_32<BGRAPacker>>>;
|
||||
|
||||
//Twiddle
|
||||
constexpr TexConvFP tex1555_TW = texture_TW<ConvertTwiddle<UnpackerNop<u16>>>;
|
||||
constexpr TexConvFP tex4444_TW = texture_TW<ConvertTwiddle<UnpackerNop<u16>>>;
|
||||
|
|
Loading…
Reference in New Issue