mirror of
https://github.com/blawar/GLideN64.git
synced 2024-07-02 09:03:37 +00:00
Fixes for txHiResUploadLimit
This commit is contained in:
parent
9479dfa6e9
commit
472eef6c67
|
@ -104,8 +104,8 @@ void Config::resetToDefaults()
|
|||
textureFilter.txEnhancedTextureFileStorage = 0;
|
||||
textureFilter.txHiresTextureFileStorage = 0;
|
||||
textureFilter.txNoTextureFileStorage = 0;
|
||||
|
||||
textureFilter.txHiResUploadLimit = 2000;
|
||||
|
||||
textureFilter.txHiresVramLimit = 0u;
|
||||
|
||||
api().GetUserDataPath(textureFilter.txPath);
|
||||
gln_wcscat(textureFilter.txPath, wst("/hires_texture"));
|
||||
|
|
|
@ -178,7 +178,7 @@ struct Config
|
|||
u32 txHiresTextureFileStorage; // Use file storage instead of memory cache for hires textures.
|
||||
u32 txNoTextureFileStorage; // Use no file storage or cache for hires textures.
|
||||
|
||||
u32 txHiResUploadLimit; // Limit of uploading hi-res textures to VRAM (in MB)
|
||||
u32 txHiresVramLimit; // Limit of uploading hi-res textures to VRAM (in MB)
|
||||
|
||||
wchar_t txPath[PLUGIN_PATH_SIZE]; // Path to texture packs
|
||||
wchar_t txCachePath[PLUGIN_PATH_SIZE]; // Path to store texture cache, that is .htc files
|
||||
|
|
|
@ -347,7 +347,7 @@ void ConfigDialog::_init(bool reInit, bool blockCustomSettings)
|
|||
ui->texCachePathLineEdit->setText(QString::fromWCharArray(config.textureFilter.txCachePath));
|
||||
ui->texDumpPathLineEdit->setText(QString::fromWCharArray(config.textureFilter.txDumpPath));
|
||||
|
||||
ui->textureFilterLimitSpinBox->setValue(config.textureFilter.txHiResUploadLimit);
|
||||
ui->textureFilterLimitSpinBox->setValue(config.textureFilter.txHiresVramLimit);
|
||||
|
||||
// OSD settings
|
||||
QString fontName(config.font.name.c_str());
|
||||
|
@ -700,7 +700,7 @@ void ConfigDialog::accept(bool justSave) {
|
|||
}
|
||||
config.textureFilter.txDumpPath[txDumpPath.path().toWCharArray(config.textureFilter.txDumpPath)] = L'\0';
|
||||
|
||||
config.textureFilter.txHiResUploadLimit = ui->textureFilterLimitSpinBox->value();
|
||||
config.textureFilter.txHiresVramLimit = ui->textureFilterLimitSpinBox->value();
|
||||
|
||||
// OSD settings
|
||||
config.font.size = ui->fontSizeSpinBox->value();
|
||||
|
|
|
@ -106,7 +106,7 @@ void _loadSettings(QSettings & settings)
|
|||
config.textureFilter.txEnhancedTextureFileStorage = settings.value("txEnhancedTextureFileStorage", config.textureFilter.txEnhancedTextureFileStorage).toInt();
|
||||
config.textureFilter.txHiresTextureFileStorage = settings.value("txHiresTextureFileStorage", config.textureFilter.txHiresTextureFileStorage).toInt();
|
||||
config.textureFilter.txNoTextureFileStorage = settings.value("txNoTextureFileStorage", config.textureFilter.txNoTextureFileStorage).toInt();
|
||||
config.textureFilter.txHiResUploadLimit = settings.value("txHiResUploadLimit", config.textureFilter.txHiResUploadLimit).toInt();
|
||||
config.textureFilter.txHiresVramLimit = settings.value("txHiresVramLimit", config.textureFilter.txHiresVramLimit).toInt();
|
||||
QString txPath = QString::fromWCharArray(config.textureFilter.txPath);
|
||||
config.textureFilter.txPath[settings.value("txPath", txPath).toString().toWCharArray(config.textureFilter.txPath)] = L'\0';
|
||||
QString txCachePath = QString::fromWCharArray(config.textureFilter.txCachePath);
|
||||
|
@ -253,7 +253,7 @@ void _writeSettingsToFile(const QString & filename)
|
|||
settings.setValue("txEnhancedTextureFileStorage", config.textureFilter.txEnhancedTextureFileStorage);
|
||||
settings.setValue("txHiresTextureFileStorage", config.textureFilter.txHiresTextureFileStorage);
|
||||
settings.setValue("txNoTextureFileStorage", config.textureFilter.txNoTextureFileStorage);
|
||||
settings.setValue("txHiResUploadLimit", config.textureFilter.txHiResUploadLimit);
|
||||
settings.setValue("txHiresVramLimit", config.textureFilter.txHiresVramLimit);
|
||||
settings.setValue("txPath", QString::fromWCharArray(config.textureFilter.txPath));
|
||||
settings.setValue("txCachePath", QString::fromWCharArray(config.textureFilter.txCachePath));
|
||||
settings.setValue("txDumpPath", QString::fromWCharArray(config.textureFilter.txDumpPath));
|
||||
|
@ -517,7 +517,7 @@ void saveCustomRomSettings(const QString & _strIniFolder, const char * _strRomNa
|
|||
WriteCustomSetting(textureFilter, txEnhancedTextureFileStorage);
|
||||
WriteCustomSetting(textureFilter, txHiresTextureFileStorage);
|
||||
WriteCustomSetting(textureFilter, txNoTextureFileStorage);
|
||||
WriteCustomSetting(textureFilter, txHiResUploadLimit);
|
||||
WriteCustomSetting(textureFilter, txHiresVramLimit);
|
||||
WriteCustomSetting(textureFilter, txHiresEnable);
|
||||
WriteCustomSetting(textureFilter, txHiresFullAlphaChannel);
|
||||
WriteCustomSetting(textureFilter, txHresAltCRC);
|
||||
|
|
|
@ -2756,7 +2756,7 @@
|
|||
<item>
|
||||
<widget class="QFrame" name="textureFilterLimitFrame">
|
||||
<property name="frameShape">
|
||||
<enum>QFrame::StyledPanel</enum>
|
||||
<enum>QFrame::NoFrame</enum>
|
||||
</property>
|
||||
<property name="frameShadow">
|
||||
<enum>QFrame::Plain</enum>
|
||||
|
@ -2780,7 +2780,7 @@
|
|||
<item>
|
||||
<widget class="QLabel" name="textureFilterLimitLabel">
|
||||
<property name="text">
|
||||
<string>Limit of uploading hi-res textures to VRAM (0 = no limit): </string>
|
||||
<string>Limit hi-res textures size in VRAM (0 = no limit): </string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
|
|
|
@ -535,29 +535,42 @@ void TextureCache::destroy()
|
|||
gfxContext.deleteTexture(cur->second.name);
|
||||
m_fbTextures.clear();
|
||||
|
||||
m_currentTexCacheSize = 0;
|
||||
m_hdTexCacheSize = 0;
|
||||
}
|
||||
|
||||
void TextureCache::_checkHdTexLimit()
|
||||
{
|
||||
const u64 maxCacheSize = config.textureFilter.txHiresVramLimit * 1024u * 1024u;
|
||||
|
||||
// we don't need to do anything,
|
||||
// when the limit has been disabled
|
||||
if (maxCacheSize == 0u)
|
||||
return;
|
||||
|
||||
// keep removing hd textures until we're below the max size
|
||||
for (auto iter = m_textures.rbegin(); iter != m_textures.rend() && m_hdTexCacheSize >= maxCacheSize;)
|
||||
{
|
||||
if (!iter->bHDTexture) {
|
||||
++iter;
|
||||
} else {
|
||||
assert(m_hdTexCacheSize >= iter->textureBytes);
|
||||
m_hdTexCacheSize -= iter->textureBytes;
|
||||
gfxContext.deleteTexture(iter->name);
|
||||
m_lruTextureLocations.erase(iter->crc);
|
||||
iter = decltype(iter)(m_textures.erase(std::next(iter).base()));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void TextureCache::_checkCacheSize()
|
||||
{
|
||||
const u64 maxCacheSize = config.textureFilter.txHiResUploadLimit * 1024 * 1024;
|
||||
|
||||
// we don't need to do anything,
|
||||
// when the limit has been disabled
|
||||
if (maxCacheSize == 0) {
|
||||
return;
|
||||
}
|
||||
|
||||
// keep removing textures until we're below the max size
|
||||
while (m_currentTexCacheSize >= maxCacheSize)
|
||||
{
|
||||
if (m_textures.size() >= m_maxCacheSize) {
|
||||
CachedTexture& clsTex = m_textures.back();
|
||||
if (clsTex.bHDTexture)
|
||||
m_hdTexCacheSize -= clsTex.textureBytes;
|
||||
gfxContext.deleteTexture(clsTex.name);
|
||||
m_lruTextureLocations.erase(clsTex.crc);
|
||||
m_textures.pop_back();
|
||||
|
||||
// update current cache size
|
||||
m_currentTexCacheSize -= clsTex.textureBytes;
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -692,9 +705,7 @@ void _calcTileSizes(u32 _t, TileSizes & _sizes, gDPTile * _pLoadTile)
|
|||
height;
|
||||
}
|
||||
|
||||
|
||||
inline
|
||||
void _updateCachedTexture(const GHQTexInfo & _info, CachedTexture *_pTexture, u16 widthOrg, u16 heightOrg)
|
||||
void TextureCache::_updateCachedTexture(const GHQTexInfo & _info, CachedTexture *_pTexture, u16 widthOrg, u16 heightOrg)
|
||||
{
|
||||
_pTexture->textureBytes = _info.width * _info.height;
|
||||
|
||||
|
@ -714,6 +725,9 @@ void _updateCachedTexture(const GHQTexInfo & _info, CachedTexture *_pTexture, u1
|
|||
_pTexture->hdRatioT = (f32)(_info.height) / (f32)(_pTexture->height);
|
||||
|
||||
_pTexture->bHDTexture = true;
|
||||
|
||||
m_hdTexCacheSize += _pTexture->textureBytes;
|
||||
_checkHdTexLimit();
|
||||
}
|
||||
|
||||
bool TextureCache::_loadHiresBackground(CachedTexture *_pTexture, u64 & _ricecrc)
|
||||
|
@ -761,7 +775,6 @@ bool TextureCache::_loadHiresBackground(CachedTexture *_pTexture, u64 & _ricecrc
|
|||
|
||||
assert(!gfxContext.isError());
|
||||
_updateCachedTexture(ghqTexInfo, _pTexture, tile_width, tile_height);
|
||||
m_currentTexCacheSize += _pTexture->textureBytes;
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
|
@ -874,7 +887,6 @@ void TextureCache::_loadBackground(CachedTexture *pTexture)
|
|||
params.data = ghqTexInfo.data;
|
||||
gfxContext.init2DTexture(params);
|
||||
_updateCachedTexture(ghqTexInfo, pTexture, pTexture->width, pTexture->height);
|
||||
m_currentTexCacheSize += pTexture->textureBytes;
|
||||
bLoaded = true;
|
||||
}
|
||||
}
|
||||
|
@ -988,7 +1000,6 @@ bool TextureCache::_loadHiresTexture(u32 _tile, CachedTexture *_pTexture, u64 &
|
|||
gfxContext.init2DTexture(params);
|
||||
assert(!gfxContext.isError());
|
||||
_updateCachedTexture(ghqTexInfo, _pTexture, width, height);
|
||||
m_currentTexCacheSize += _pTexture->textureBytes;
|
||||
return true;
|
||||
}
|
||||
|
||||
|
@ -1288,7 +1299,6 @@ void TextureCache::_loadFast(u32 _tile, CachedTexture *_pTexture)
|
|||
params.data = ghqTexInfo.data;
|
||||
gfxContext.init2DTexture(params);
|
||||
_updateCachedTexture(ghqTexInfo, _pTexture, tmptex.width, tmptex.height);
|
||||
m_currentTexCacheSize += _pTexture->textureBytes;
|
||||
bLoaded = true;
|
||||
}
|
||||
}
|
||||
|
@ -1516,7 +1526,6 @@ void TextureCache::_loadAccurate(u32 _tile, CachedTexture *_pTexture)
|
|||
params.data = ghqTexInfo.data;
|
||||
gfxContext.init2DTexture(params);
|
||||
_updateCachedTexture(ghqTexInfo, _pTexture, tmptex.width, tmptex.height);
|
||||
m_currentTexCacheSize += _pTexture->textureBytes;
|
||||
bLoaded = true;
|
||||
}
|
||||
}
|
||||
|
@ -1758,7 +1767,7 @@ void TextureCache::clear()
|
|||
}
|
||||
m_textures.clear();
|
||||
m_lruTextureLocations.clear();
|
||||
m_currentTexCacheSize = 0;
|
||||
m_hdTexCacheSize = 0u;
|
||||
}
|
||||
|
||||
void TextureCache::toggleDumpTex()
|
||||
|
@ -1846,11 +1855,11 @@ void TextureCache::update(u32 _t)
|
|||
return;
|
||||
}
|
||||
|
||||
if (currentTex.bHDTexture)
|
||||
m_hdTexCacheSize -= currentTex.textureBytes;
|
||||
gfxContext.deleteTexture(currentTex.name);
|
||||
m_lruTextureLocations.erase(locations_iter);
|
||||
m_textures.erase(iter);
|
||||
|
||||
m_currentTexCacheSize -= currentTex.textureBytes;
|
||||
}
|
||||
|
||||
m_misses++;
|
||||
|
|
|
@ -14,6 +14,7 @@
|
|||
#include "Graphics/Parameter.h"
|
||||
|
||||
typedef u32 (*GetTexelFunc)( u64 *src, u16 x, u16 i, u8 palette );
|
||||
struct GHQTexInfo;
|
||||
|
||||
struct CachedTexture
|
||||
{
|
||||
|
@ -84,6 +85,7 @@ private:
|
|||
TextureCache(const TextureCache &) = delete;
|
||||
|
||||
void _checkCacheSize();
|
||||
void _checkHdTexLimit();
|
||||
CachedTexture * _addTexture(u64 _crc64);
|
||||
void _loadFast(u32 _tile, CachedTexture *_pTexture);
|
||||
void _loadAccurate(u32 _tile, CachedTexture *_pTexture);
|
||||
|
@ -94,6 +96,7 @@ private:
|
|||
void _updateBackground();
|
||||
void _initDummyTexture(CachedTexture * _pDummy);
|
||||
void _getTextureDestData(CachedTexture& tmptex, u32* pDest, graphics::Parameter glInternalFormat, GetTexelFunc GetTexel, u16* pLine);
|
||||
void _updateCachedTexture(const GHQTexInfo & _info, CachedTexture *_pTexture, u16 widthOrg, u16 heightOrg);
|
||||
|
||||
typedef std::list<CachedTexture> Textures;
|
||||
typedef std::unordered_map<u64, Textures::iterator> Texture_Locations;
|
||||
|
@ -108,7 +111,12 @@ private:
|
|||
bool m_toggleDumpTex;
|
||||
std::vector<u32> m_tempTextureHolder;
|
||||
|
||||
u64 m_currentTexCacheSize = 0;
|
||||
#ifdef VC
|
||||
const size_t m_maxCacheSize = 1500u;
|
||||
#else
|
||||
const size_t m_maxCacheSize = 8000u;
|
||||
#endif
|
||||
u64 m_hdTexCacheSize = 0u;
|
||||
};
|
||||
|
||||
void getTextureShiftScale(u32 tile, const TextureCache & cache, f32 & shiftScaleS, f32 & shiftScaleT);
|
||||
|
|
|
@ -259,8 +259,8 @@ bool Config_SetDefault()
|
|||
assert(res == M64ERR_SUCCESS);
|
||||
res = ConfigSetDefaultBool(g_configVideoGliden64, "txNoTextureFileStorage", config.textureFilter.txNoTextureFileStorage, "Use no file storage or cache for HD textures.");
|
||||
assert(res == M64ERR_SUCCESS);
|
||||
res = ConfigSetDefaultInt(g_configVideoGliden64, "txHiResUploadLimit", config.textureFilter.txHiResUploadLimit, "Limit of uploading hi-res textures to VRAM (in MB, 0 = no limit)");
|
||||
assert(res == M64ERR_SUCCESS);
|
||||
res = ConfigSetDefaultInt(g_configVideoGliden64, "txHiresVramLimit", config.textureFilter.txHiresVramLimit, "Limit hi-res textures size in VRAM (in MB, 0 = no limit)");
|
||||
assert(res == M64ERR_SUCCESS);
|
||||
// Convert to multibyte
|
||||
char txPath[PLUGIN_PATH_SIZE * 2];
|
||||
wcstombs(txPath, config.textureFilter.txPath, PLUGIN_PATH_SIZE * 2);
|
||||
|
@ -473,8 +473,8 @@ void Config_LoadCustomConfig()
|
|||
if (result == M64ERR_SUCCESS) config.textureFilter.txHiresTextureFileStorage = atoi(value);
|
||||
result = ConfigExternalGetParameter(fileHandle, sectionName, "textureFilter\\txNoTextureFileStorage", value, sizeof(value));
|
||||
if (result == M64ERR_SUCCESS) config.textureFilter.txNoTextureFileStorage = atoi(value);
|
||||
result = ConfigExternalGetParameter(fileHandle, sectionName, "textureFilter\\txHiResUploadLimit", value, sizeof(value));
|
||||
if (result == M64ERR_SUCCESS) config.textureFilter.txHiResUploadLimit = atoi(value);
|
||||
result = ConfigExternalGetParameter(fileHandle, sectionName, "textureFilter\\txHiresVramLimit", value, sizeof(value));
|
||||
if (result == M64ERR_SUCCESS) config.textureFilter.txHiresVramLimit = atoi(value);
|
||||
ConfigExternalClose(fileHandle);
|
||||
}
|
||||
|
||||
|
@ -565,7 +565,7 @@ void Config_LoadConfig()
|
|||
config.textureFilter.txEnhancedTextureFileStorage = ConfigGetParamBool(g_configVideoGliden64, "txEnhancedTextureFileStorage");
|
||||
config.textureFilter.txHiresTextureFileStorage = ConfigGetParamBool(g_configVideoGliden64, "txHiresTextureFileStorage");
|
||||
config.textureFilter.txNoTextureFileStorage = ConfigGetParamBool(g_configVideoGliden64, "txNoTextureFileStorage");
|
||||
config.textureFilter.txHiResUploadLimit = ConfigGetParamInt(g_configVideoGliden64, "txHiResUploadLimit");
|
||||
config.textureFilter.txHiresVramLimit = ConfigGetParamInt(g_configVideoGliden64, "txHiresVramLimit");
|
||||
::mbstowcs(config.textureFilter.txPath, ConfigGetParamString(g_configVideoGliden64, "txPath"), PLUGIN_PATH_SIZE);
|
||||
::mbstowcs(config.textureFilter.txCachePath, ConfigGetParamString(g_configVideoGliden64, "txCachePath"), PLUGIN_PATH_SIZE);
|
||||
::mbstowcs(config.textureFilter.txDumpPath, ConfigGetParamString(g_configVideoGliden64, "txDumpPath"), PLUGIN_PATH_SIZE);
|
||||
|
|
Loading…
Reference in New Issue
Block a user