1
0
mirror of https://github.com/blawar/GLideN64.git synced 2024-07-02 09:03:37 +00:00

Fix scale for mip-map tiles.

Note: it is incomplete solution for problems with mip-mapping.

Fixes Paper Mario Snow #2570
This commit is contained in:
s2s 2021-11-06 10:43:14 +01:00 committed by Sergey Lipskiy
parent 46c58576e2
commit 8e961b7b39
2 changed files with 11 additions and 2 deletions

View File

@ -751,13 +751,17 @@ public:
" lowp vec4 c11 = texelFetch(tex, ivec2(tcData[3]), 0); \\\n"
;
static const std::string strReadTex1 =
"#define GET_HIGH4(byte) floor(byte/16.0) \n"
"#define GET_LOW4(byte) (byte - 16.0*floor(byte/16.0)) \n"
"#define READ_TEX1_MIPMAP(name, tex, tcData, tile) \\\n"
"{ \\\n"
// Fetch from texture atlas
// First 8 texels contain info about tile size and offset, 1 texel per tile
" mediump vec4 texWdthAndOff0 = 255.0 * texelFetch(tex, ivec2(0, 0), 0); \\\n"
" mediump vec4 texWdthAndOff = 255.0 * texelFetch(tex, ivec2(int(tile), 0), 0); \\\n"
" mediump vec2 lod_scale = texWdthAndOff.ba / texWdthAndOff0.ba; \\\n"
" mediump float lod_scales = pow(2.0, GET_HIGH4(texWdthAndOff0.a) - GET_HIGH4(texWdthAndOff.a)); \\\n"
" mediump float lod_scalet = pow(2.0, GET_LOW4(texWdthAndOff0.a) - GET_LOW4(texWdthAndOff.a)); \\\n"
" mediump vec2 lod_scale = vec2(lod_scales, lod_scalet); \\\n"
" mediump int offset = int(texWdthAndOff.r) + int(texWdthAndOff.g) * 256; \\\n"
" mediump int width = int(texWdthAndOff.b); \\\n"
" mediump ivec2 iCoords00 = ivec2(tcData[0] * lod_scale); \\\n"

View File

@ -1411,7 +1411,12 @@ void TextureCache::_loadAccurate(u32 _tile, CachedTexture *_pTexture)
// Load all tiles into one 1D texture atlas.
while (true)
{
const u32 tileSizePacked = texDataOffset | (tmptex.width << 16) | (tmptex.height << 24);
u32 mipRatioS = gDP.tiles[gSP.texture.tile + mipLevel + 1].shifts + 5u;
if (mipRatioS >= 16u) mipRatioS -= 16u;
u32 mipRatioT = gDP.tiles[gSP.texture.tile + mipLevel + 1].shiftt + 5u;
if (mipRatioT >= 16) mipRatioT -= 16u;
const u32 tileSizePacked = texDataOffset | (tmptex.width << 16) | (mipRatioT << 24) | (mipRatioS << 28);
m_tempTextureHolder[mipLevel] = tileSizePacked;
getLoadParams(tmptex.format, tmptex.size);