diff --git a/core/rend/TexCache.cpp b/core/rend/TexCache.cpp index dd4a75486..63fb44bf0 100644 --- a/core/rend/TexCache.cpp +++ b/core/rend/TexCache.cpp @@ -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 { diff --git a/core/rend/TexCache.h b/core/rend/TexCache.h index 188f44da9..827d71015 100644 --- a/core/rend/TexCache.h +++ b/core/rend/TexCache.h @@ -420,6 +420,26 @@ void texture_PL(PixelBuffer* pb, const u } } +template +void texture_PLVQ(PixelBuffer* 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 void texture_TW(PixelBuffer* pb, const u8* p_in, u32 Width, u32 Height) { @@ -497,6 +517,11 @@ constexpr TexConvFP32 tex565_PL32 = texture_PL>>; constexpr TexConvFP32 tex4444_PL32 = texture_PL>>; +constexpr TexConvFP32 texYUV422_PLVQ = texture_PLVQ>; +constexpr TexConvFP32 tex565_PLVQ32 = texture_PLVQ>>; +constexpr TexConvFP32 tex1555_PLVQ32 = texture_PLVQ>>; +constexpr TexConvFP32 tex4444_PLVQ32 = texture_PLVQ>>; + //Twiddle constexpr TexConvFP tex1555_TW = texture_TW>; constexpr TexConvFP tex4444_TW = texture_TW>; @@ -527,6 +552,11 @@ constexpr TexConvFP32 tex565_PL32 = texture_PL>>; constexpr TexConvFP32 tex4444_PL32 = texture_PL>>; +constexpr TexConvFP32 texYUV422_PLVQ = texture_PLVQ>; +constexpr TexConvFP32 tex565_PLVQ32 = texture_PLVQ>>; +constexpr TexConvFP32 tex1555_PLVQ32 = texture_PLVQ>>; +constexpr TexConvFP32 tex4444_PLVQ32 = texture_PLVQ>>; + //Twiddle constexpr TexConvFP tex1555_TW = texture_TW>>; constexpr TexConvFP tex4444_TW = texture_TW>>;