mirror of
https://github.com/dolphin-emu/dolphin.git
synced 2025-05-08 03:28:31 +03:00
TexCache: cleanup max texture level
This commit is contained in:
parent
1261f5f7f4
commit
d640453274
2 changed files with 11 additions and 11 deletions
|
@ -301,7 +301,7 @@ TextureCache::TCacheEntryBase* TextureCache::Load(const u32 stage)
|
||||||
const u32 tlutaddr = tex.texTlut[id].tmem_offset << 9;
|
const u32 tlutaddr = tex.texTlut[id].tmem_offset << 9;
|
||||||
const u32 tlutfmt = tex.texTlut[id].tlut_format;
|
const u32 tlutfmt = tex.texTlut[id].tlut_format;
|
||||||
const bool use_mipmaps = (tex.texMode0[id].min_filter & 3) != 0;
|
const bool use_mipmaps = (tex.texMode0[id].min_filter & 3) != 0;
|
||||||
u32 maxlevel = (tex.texMode1[id].max_lod + 0xf) / 0x10;
|
u32 tex_levels = (tex.texMode1[id].max_lod + 0xf) / 0x10 + 1;
|
||||||
const bool from_tmem = tex.texImage1[id].image_type != 0;
|
const bool from_tmem = tex.texImage1[id].image_type != 0;
|
||||||
|
|
||||||
if (0 == address)
|
if (0 == address)
|
||||||
|
@ -359,8 +359,8 @@ TextureCache::TCacheEntryBase* TextureCache::Load(const u32 stage)
|
||||||
|
|
||||||
// D3D doesn't like when the specified mipmap count would require more than one 1x1-sized LOD in the mipmap chain
|
// D3D doesn't like when the specified mipmap count would require more than one 1x1-sized LOD in the mipmap chain
|
||||||
// e.g. 64x64 with 7 LODs would have the mipmap chain 64x64,32x32,16x16,8x8,4x4,2x2,1x1,1x1, so we limit the mipmap count to 6 there
|
// e.g. 64x64 with 7 LODs would have the mipmap chain 64x64,32x32,16x16,8x8,4x4,2x2,1x1,1x1, so we limit the mipmap count to 6 there
|
||||||
while (g_ActiveConfig.backend_info.bUseMinimalMipCount && std::max(width, height) >> maxlevel == 0)
|
while (g_ActiveConfig.backend_info.bUseMinimalMipCount && std::max(width, height) >> (tex_levels - 1) == 0)
|
||||||
--maxlevel;
|
--tex_levels;
|
||||||
|
|
||||||
TCacheEntryBase *entry = textures[texID];
|
TCacheEntryBase *entry = textures[texID];
|
||||||
if (entry)
|
if (entry)
|
||||||
|
@ -383,7 +383,7 @@ TextureCache::TCacheEntryBase* TextureCache::Load(const u32 stage)
|
||||||
|
|
||||||
// 2. b) For normal textures, all texture parameters need to match
|
// 2. b) For normal textures, all texture parameters need to match
|
||||||
if (address == entry->addr && tex_hash == entry->hash && full_format == entry->format &&
|
if (address == entry->addr && tex_hash == entry->hash && full_format == entry->format &&
|
||||||
entry->num_mipmaps > maxlevel && entry->native_width == nativeW && entry->native_height == nativeH)
|
entry->tex_levels >= tex_levels && entry->native_width == nativeW && entry->native_height == nativeH)
|
||||||
{
|
{
|
||||||
return ReturnEntry(stage, entry);
|
return ReturnEntry(stage, entry);
|
||||||
}
|
}
|
||||||
|
@ -397,7 +397,7 @@ TextureCache::TCacheEntryBase* TextureCache::Load(const u32 stage)
|
||||||
width == entry->virtual_width &&
|
width == entry->virtual_width &&
|
||||||
height == entry->virtual_height &&
|
height == entry->virtual_height &&
|
||||||
full_format == entry->format &&
|
full_format == entry->format &&
|
||||||
entry->num_mipmaps > maxlevel) ||
|
entry->tex_levels >= tex_levels) ||
|
||||||
(entry->type == TCET_EC_DYNAMIC &&
|
(entry->type == TCET_EC_DYNAMIC &&
|
||||||
entry->native_width == width &&
|
entry->native_width == width &&
|
||||||
entry->native_height == height)) &&
|
entry->native_height == height)) &&
|
||||||
|
@ -460,7 +460,7 @@ TextureCache::TCacheEntryBase* TextureCache::Load(const u32 stage)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
u32 texLevels = use_mipmaps ? (maxlevel + 1) : 1;
|
u32 texLevels = use_mipmaps ? tex_levels : 1;
|
||||||
const bool using_custom_lods = hires_tex && hires_tex->m_levels.size() >= texLevels;
|
const bool using_custom_lods = hires_tex && hires_tex->m_levels.size() >= texLevels;
|
||||||
// Only load native mips if their dimensions fit to our virtual texture dimensions
|
// Only load native mips if their dimensions fit to our virtual texture dimensions
|
||||||
const bool use_native_mips = use_mipmaps && !using_custom_lods && (width == nativeW && height == nativeH);
|
const bool use_native_mips = use_mipmaps && !using_custom_lods && (width == nativeW && height == nativeH);
|
||||||
|
@ -478,14 +478,14 @@ TextureCache::TCacheEntryBase* TextureCache::Load(const u32 stage)
|
||||||
// TODO: This is the wrong value. We should be storing the number of levels our actual texture has.
|
// TODO: This is the wrong value. We should be storing the number of levels our actual texture has.
|
||||||
// But that will currently make the above "existing entry" tests fail as "texLevels" is not calculated until after.
|
// But that will currently make the above "existing entry" tests fail as "texLevels" is not calculated until after.
|
||||||
// Currently, we might try to reuse a texture which appears to have more levels than actual, maybe..
|
// Currently, we might try to reuse a texture which appears to have more levels than actual, maybe..
|
||||||
entry->num_mipmaps = maxlevel + 1;
|
entry->tex_levels = tex_levels;
|
||||||
entry->num_layers = 1;
|
entry->num_layers = 1;
|
||||||
entry->type = TCET_NORMAL;
|
entry->type = TCET_NORMAL;
|
||||||
|
|
||||||
GFX_DEBUGGER_PAUSE_AT(NEXT_NEW_TEXTURE, true);
|
GFX_DEBUGGER_PAUSE_AT(NEXT_NEW_TEXTURE, true);
|
||||||
}
|
}
|
||||||
|
|
||||||
entry->SetGeneralParameters(address, texture_size, full_format, entry->num_mipmaps, entry->num_layers);
|
entry->SetGeneralParameters(address, texture_size, full_format, entry->tex_levels, entry->num_layers);
|
||||||
entry->SetDimensions(nativeW, nativeH, width, height);
|
entry->SetDimensions(nativeW, nativeH, width, height);
|
||||||
entry->hash = tex_hash;
|
entry->hash = tex_hash;
|
||||||
|
|
||||||
|
|
|
@ -35,7 +35,7 @@ public:
|
||||||
|
|
||||||
enum TexCacheEntryType type;
|
enum TexCacheEntryType type;
|
||||||
|
|
||||||
unsigned int num_mipmaps;
|
unsigned int tex_levels;
|
||||||
unsigned int num_layers;
|
unsigned int num_layers;
|
||||||
unsigned int native_width, native_height; // Texture dimensions from the GameCube's point of view
|
unsigned int native_width, native_height; // Texture dimensions from the GameCube's point of view
|
||||||
unsigned int virtual_width, virtual_height; // Texture dimensions from OUR point of view - for hires textures or scaled EFB copies
|
unsigned int virtual_width, virtual_height; // Texture dimensions from OUR point of view - for hires textures or scaled EFB copies
|
||||||
|
@ -44,12 +44,12 @@ public:
|
||||||
int frameCount;
|
int frameCount;
|
||||||
|
|
||||||
|
|
||||||
void SetGeneralParameters(u32 _addr, u32 _size, u32 _format, unsigned int _num_mipmaps, unsigned int _num_layers)
|
void SetGeneralParameters(u32 _addr, u32 _size, u32 _format, unsigned int _tex_levels, unsigned int _num_layers)
|
||||||
{
|
{
|
||||||
addr = _addr;
|
addr = _addr;
|
||||||
size_in_bytes = _size;
|
size_in_bytes = _size;
|
||||||
format = _format;
|
format = _format;
|
||||||
num_mipmaps = _num_mipmaps;
|
tex_levels = _tex_levels;
|
||||||
num_layers = _num_layers;
|
num_layers = _num_layers;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue