diff --git a/core/rend/TexCache.h b/core/rend/TexCache.h index cfda1fd84..b126b2c3d 100644 --- a/core/rend/TexCache.h +++ b/core/rend/TexCache.h @@ -608,10 +608,17 @@ template void texture_VQ, u16>(PixelBuffer* pb,u8* p_in, #define tex4444_VQ texture_VQ, u16> #define texYUV422_VQ texture_VQ, u32> #define texBMP_VQ texture_VQ, u16> +// According to the documentation, a texture cannot be compressed and use +// a palette at the same time. However the hardware displays them +// just fine. +#define texPAL4_VQ texture_VQ, u16> +#define texPAL8_VQ texture_VQ, u16> #define tex565_VQ32 texture_VQ, u32> #define tex1555_VQ32 texture_VQ, u32> #define tex4444_VQ32 texture_VQ, u32> +#define texPAL4_VQ32 texture_VQ, u32> +#define texPAL8_VQ32 texture_VQ, u32> void DePosterize(u32* source, u32* dest, int width, int height); void UpscalexBRZ(int factor, u32* source, u32* dest, int width, int height, bool has_alpha); diff --git a/core/rend/gles/gles.h b/core/rend/gles/gles.h index 430734527..46fea628c 100755 --- a/core/rend/gles/gles.h +++ b/core/rend/gles/gles.h @@ -269,11 +269,10 @@ struct TextureCacheData u32 Updates; + u32 palette_index; //used for palette updates u32 palette_hash; // Palette hash at time of last update - u32 indirect_color_ptr; //palette color table index for pal. tex - //VQ quantizers table for VQ tex - //a texture can't be both VQ and PAL at the same time + u32 vq_codebook; // VQ quantizers table for compressed textures u32 texture_hash; // xxhash of texture data, used for custom textures u32 old_texture_hash; // legacy hash u8* volatile custom_image_data; // loaded custom image data diff --git a/core/rend/gles/gltex.cpp b/core/rend/gles/gltex.cpp index e83c6a882..8f6507830 100644 --- a/core/rend/gles/gltex.cpp +++ b/core/rend/gles/gltex.cpp @@ -53,8 +53,8 @@ PvrTexInfo format[8]= {"4444", 16, GL_UNSIGNED_SHORT_4_4_4_4, tex4444_PL, tex4444_TW, tex4444_VQ, tex4444_PL32, tex4444_TW32, tex4444_VQ32 }, //4444 {"yuv", 16, GL_UNSIGNED_BYTE, NULL, NULL, NULL, texYUV422_PL, texYUV422_TW, texYUV422_VQ }, //yuv {"bumpmap", 16, GL_UNSIGNED_SHORT_4_4_4_4, texBMP_PL, texBMP_TW, texBMP_VQ, NULL}, //bump map - {"pal4", 4, 0, 0, texPAL4_TW, 0, NULL, texPAL4_TW32, NULL }, //pal4 - {"pal8", 8, 0, 0, texPAL8_TW, 0, NULL, texPAL8_TW32, NULL }, //pal8 + {"pal4", 4, 0, 0, texPAL4_TW, texPAL4_VQ, NULL, texPAL4_TW32, texPAL4_VQ32 }, //pal4 + {"pal8", 8, 0, 0, texPAL8_TW, texPAL8_VQ, NULL, texPAL8_TW32, texPAL8_VQ32 }, //pal8 {"ns/1555", 0}, // Not supported (1555) }; @@ -168,14 +168,14 @@ void TextureCacheData::Create(bool isGL) h=8<bpp==4) - indirect_color_ptr=tcw.PalSelect<<4; - else if (tex->bpp==8) - indirect_color_ptr=(tcw.PalSelect>>4)<<8; + if (tex->bpp == 4) + palette_index = tcw.PalSelect << 4; + else if (tex->bpp == 8) + palette_index = (tcw.PalSelect >> 4) << 8; //VQ table (if VQ tex) if (tcw.VQ_Comp) - indirect_color_ptr=sa; + vq_codebook = sa; //Convert a pvr texture into OpenGL switch (tcw.PixelFmt) @@ -214,7 +214,7 @@ void TextureCacheData::Create(bool isGL) if (tcw.VQ_Comp) { verify(tex->VQ != NULL || tex->VQ32 != NULL); - indirect_color_ptr=sa; + vq_codebook = sa; if (tcw.MipMapped) sa+=MipPoint[tsp.TexU]; texconv = tex->VQ; @@ -271,8 +271,8 @@ void TextureCacheData::Update() palette_hash = pal_hash_256[tcw.PalSelect >> 4]; } - palette_index=indirect_color_ptr; //might be used if pal. tex - vq_codebook=(u8*)&vram[indirect_color_ptr]; //might be used if VQ tex + ::palette_index = this->palette_index; // might be used if pal. tex + ::vq_codebook = &vram[vq_codebook]; // might be used if VQ tex //texture conversion work u32 stride=w;