mirror of
https://github.com/libretro/ppsspp.git
synced 2024-11-24 08:39:51 +00:00
GPU: Fix negative mip levels with const workaround.
Might've crashed if it hit a negative level before.
This commit is contained in:
parent
b6375638f5
commit
f66ffb9ffe
@ -230,7 +230,7 @@ void TextureCacheCommon::SetTexture(bool force) {
|
||||
|
||||
u8 level = 0;
|
||||
if (IsFakeMipmapChange())
|
||||
level = (gstate.texlevel >> 20) & 0xF;
|
||||
level = std::max(0, gstate.getTexLevelOffset16() / 16);
|
||||
u32 texaddr = gstate.getTextureAddress(level);
|
||||
if (!Memory::IsValidAddress(texaddr)) {
|
||||
// Bind a null texture and return.
|
||||
|
@ -571,7 +571,8 @@ void TextureCacheD3D11::BuildTexture(TexCacheEntry *const entry, bool replaceIma
|
||||
}
|
||||
|
||||
if (IsFakeMipmapChange()) {
|
||||
u8 level = (gstate.texlevel >> 20) & 0xF;
|
||||
// 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, replaceImages, scaleFactor, dstFmt);
|
||||
} else {
|
||||
LoadTextureLevel(*entry, replaced, 0, maxLevel, replaceImages, scaleFactor, dstFmt);
|
||||
@ -707,7 +708,7 @@ void TextureCacheD3D11::LoadTextureLevel(TexCacheEntry &entry, ReplacedTexture &
|
||||
desc.Width = tw;
|
||||
desc.Height = th;
|
||||
desc.Format = tfmt;
|
||||
desc.MipLevels = IsFakeMipmapChange() ? 1 :levels;
|
||||
desc.MipLevels = IsFakeMipmapChange() ? 1 : levels;
|
||||
desc.BindFlags = D3D11_BIND_SHADER_RESOURCE;
|
||||
|
||||
ASSERT_SUCCESS(device_->CreateTexture2D(&desc, nullptr, &texture));
|
||||
|
@ -574,7 +574,8 @@ void TextureCacheDX9::BuildTexture(TexCacheEntry *const entry, bool replaceImage
|
||||
}
|
||||
|
||||
if (IsFakeMipmapChange()) {
|
||||
u8 level = (gstate.texlevel >> 20) & 0xF;
|
||||
// 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, replaceImages, scaleFactor, dstFmt);
|
||||
} else {
|
||||
LoadTextureLevel(*entry, replaced, 0, maxLevel, replaceImages, scaleFactor, dstFmt);
|
||||
|
@ -688,7 +688,8 @@ void TextureCacheGLES::BuildTexture(TexCacheEntry *const entry, bool replaceImag
|
||||
|
||||
// Always load base level texture here
|
||||
if (IsFakeMipmapChange()) {
|
||||
u8 level = (gstate.texlevel >> 20) & 0xF;
|
||||
// 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, replaceImages, scaleFactor, dstFmt);
|
||||
} else
|
||||
LoadTextureLevel(*entry, replaced, 0, replaceImages, scaleFactor, dstFmt);
|
||||
|
@ -630,7 +630,8 @@ void TextureCacheVulkan::BuildTexture(TexCacheEntry *const entry, bool replaceIm
|
||||
}
|
||||
|
||||
if (entry->vkTex) {
|
||||
u8 level = (gstate.texlevel >> 20) & 0xF;
|
||||
// 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;
|
||||
// Upload the texture data.
|
||||
for (int i = 0; i <= maxLevel; i++) {
|
||||
|
Loading…
Reference in New Issue
Block a user