Fix checks for the "fake mipmap" situation.

Fixes #15492
This commit is contained in:
Henrik Rydgård 2022-04-22 22:58:47 +02:00
parent 83b8211abf
commit c52a5e9e25
4 changed files with 20 additions and 11 deletions

View File

@ -355,8 +355,9 @@ void TextureCacheCommon::UpdateMaxSeenV(TexCacheEntry *entry, bool throughMode)
TexCacheEntry *TextureCacheCommon::SetTexture() {
u8 level = 0;
if (IsFakeMipmapChange())
if (IsFakeMipmapChange()) {
level = std::max(0, gstate.getTexLevelOffset16() / 16);
}
u32 texaddr = gstate.getTextureAddress(level);
if (!Memory::IsValidAddress(texaddr)) {
// Bind a null texture and return.

View File

@ -474,13 +474,13 @@ void TextureCacheDX9::BuildTexture(TexCacheEntry *const entry) {
maxLevel = 0;
}
u8 level = 0;
if (IsFakeMipmapChange()) {
// NOTE: Since the level is not part of the cache key, we assume it never changes.
u8 level = std::max(0, gstate.getTexLevelOffset16() / 16);
LoadTextureLevel(*entry, replaced, level, maxLevel, scaleFactor, dstFmt);
} else {
LoadTextureLevel(*entry, replaced, 0, maxLevel, scaleFactor, dstFmt);
level = std::max(0, gstate.getTexLevelOffset16() / 16);
}
LoadTextureLevel(*entry, replaced, level, maxLevel, scaleFactor, dstFmt);
LPDIRECT3DTEXTURE9 &texture = DxTex(entry);
if (!texture) {
return;

View File

@ -540,13 +540,12 @@ void TextureCacheGLES::BuildTexture(TexCacheEntry *const entry) {
// be as good quality as the game's own (might even be better in some cases though).
// Always load base level texture here
u8 level = 0;
if (IsFakeMipmapChange()) {
// NOTE: Since the level is not part of the cache key, we assume it never changes.
u8 level = std::max(0, gstate.getTexLevelOffset16() / 16);
LoadTextureLevel(*entry, replaced, level, scaleFactor, dstFmt);
} else {
LoadTextureLevel(*entry, replaced, 0, scaleFactor, dstFmt);
level = std::max(0, gstate.getTexLevelOffset16() / 16);
}
LoadTextureLevel(*entry, replaced, level, scaleFactor, dstFmt);
// Mipmapping is only enabled when texture scaling is disabled.
int texMaxLevel = 0;

View File

@ -811,8 +811,14 @@ void TextureCacheVulkan::BuildTexture(TexCacheEntry *const entry) {
"Texture Upload (%08x) video=%d", entry->addr, isVideo);
// NOTE: Since the level is not part of the cache key, we assume it never changes.
u8 level = std::max(0, gstate.getTexLevelOffset16() / 16);
bool fakeMipmap = IsFakeMipmapChange() && level > 0;
u8 level = 0;
bool fakeMipmap = false;
if (IsFakeMipmapChange()) {
level = std::max(0, gstate.getTexLevelOffset16() / 16);
fakeMipmap = level > 0;
}
// Upload the texture data.
for (int i = 0; i <= maxLevel; i++) {
int mipUnscaledWidth = gstate.getTextureWidth(i);
@ -976,6 +982,9 @@ void TextureCacheVulkan::LoadTextureLevel(TexCacheEntry &entry, uint8_t *writePt
GETextureFormat tfmt = (GETextureFormat)entry.format;
GEPaletteFormat clutformat = gstate.getClutPaletteFormat();
u32 texaddr = gstate.getTextureAddress(level);
_assert_msg_(texaddr != 0, "Can't load a texture from address null")
int bufw = GetTextureBufw(level, texaddr, tfmt);
int bpp = dstFmt == VULKAN_8888_FORMAT ? 4 : 2;