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

Fix texture filter init/shutdown:

- texture filter updated when config.textureFilter options changed.
This commit is contained in:
Sergey Lipskiy 2015-08-17 15:42:40 +06:00
parent 5bf7a4e4de
commit d30d813b18
3 changed files with 56 additions and 43 deletions

View File

@ -1349,6 +1349,8 @@ void OGLRender::_destroyData()
m_renderState = rsNone; m_renderState = rsNone;
if (config.bloomFilter.enable != 0) if (config.bloomFilter.enable != 0)
PostProcessor::get().destroy(); PostProcessor::get().destroy();
if (TFH.optionsChanged())
TFH.shutdown();
TextDrawer::get().destroy(); TextDrawer::get().destroy();
Combiner_Destroy(); Combiner_Destroy();
FrameBuffer_Destroy(); FrameBuffer_Destroy();
@ -1444,57 +1446,66 @@ void displayLoadProgress(const wchar_t *format, ...)
glBindFramebuffer(GL_DRAW_FRAMEBUFFER, pBuffer->m_FBO); glBindFramebuffer(GL_DRAW_FRAMEBUFFER, pBuffer->m_FBO);
} }
u32 TextureFilterHandler::_getConfigOptions() const
{
u32 options = textureFilters[config.textureFilter.txFilterMode] | textureEnhancements[config.textureFilter.txEnhancementMode];
if (config.textureFilter.txHiresEnable)
options |= RICE_HIRESTEXTURES;
if (config.textureFilter.txForce16bpp)
options |= FORCE16BPP_TEX | FORCE16BPP_HIRESTEX;
if (config.textureFilter.txCacheCompression)
options |= GZ_TEXCACHE | GZ_HIRESTEXCACHE;
if (config.textureFilter.txSaveCache)
options |= (DUMP_TEXCACHE | DUMP_HIRESTEXCACHE);
if (config.textureFilter.txHiresFullAlphaChannel)
options |= LET_TEXARTISTS_FLY;
if (config.textureFilter.txDump)
options |= DUMP_TEX;
return options;
}
void TextureFilterHandler::init() void TextureFilterHandler::init()
{ {
if (!isInited()) { if (isInited())
m_inited = config.textureFilter.txFilterMode | config.textureFilter.txEnhancementMode | config.textureFilter.txHiresEnable; return;
if (m_inited != 0) {
u32 options = textureFilters[config.textureFilter.txFilterMode] | textureEnhancements[config.textureFilter.txEnhancementMode];
if (config.textureFilter.txHiresEnable)
options |= RICE_HIRESTEXTURES;
if (config.textureFilter.txForce16bpp)
options |= FORCE16BPP_TEX | FORCE16BPP_HIRESTEX;
if (config.textureFilter.txCacheCompression)
options |= GZ_TEXCACHE | GZ_HIRESTEXCACHE;
if (config.textureFilter.txSaveCache)
options |= (DUMP_TEXCACHE | DUMP_HIRESTEXCACHE);
if (config.textureFilter.txHiresFullAlphaChannel)
options |= LET_TEXARTISTS_FLY;
if (config.textureFilter.txDump)
options |= DUMP_TEX;
GLint maxTextureSize; m_inited = config.textureFilter.txFilterMode | config.textureFilter.txEnhancementMode | config.textureFilter.txHiresEnable;
glGetIntegerv(GL_MAX_TEXTURE_SIZE, &maxTextureSize); if (m_inited == 0)
wchar_t wRomName[32]; return;
::mbstowcs(wRomName, RSP.romname, 32);
wchar_t txPath[PLUGIN_PATH_SIZE+16];
wchar_t * pTexPackPath = config.textureFilter.txPath;
if (::wcslen(config.textureFilter.txPath) == 0) {
api().GetUserDataPath(txPath);
gln_wcscat(txPath, wst("/hires_texture"));
pTexPackPath = txPath;
}
wchar_t txCachePath[PLUGIN_PATH_SIZE];
api().GetUserCachePath(txCachePath);
m_inited = txfilter_init(maxTextureSize, // max texture width supported by hardware m_options = _getConfigOptions();
maxTextureSize, // max texture height supported by hardware
32, // max texture bpp supported by hardware GLint maxTextureSize;
options, glGetIntegerv(GL_MAX_TEXTURE_SIZE, &maxTextureSize);
config.textureFilter.txCacheSize, // cache texture to system memory wchar_t wRomName[32];
txCachePath, // path to store cache files ::mbstowcs(wRomName, RSP.romname, 32);
pTexPackPath, // path to texture packs folder wchar_t txPath[PLUGIN_PATH_SIZE + 16];
wRomName, // name of ROM. must be no longer than 256 characters wchar_t * pTexPackPath = config.textureFilter.txPath;
displayLoadProgress); if (::wcslen(config.textureFilter.txPath) == 0) {
} api().GetUserDataPath(txPath);
gln_wcscat(txPath, wst("/hires_texture"));
pTexPackPath = txPath;
} }
wchar_t txCachePath[PLUGIN_PATH_SIZE];
api().GetUserCachePath(txCachePath);
m_inited = txfilter_init(maxTextureSize, // max texture width supported by hardware
maxTextureSize, // max texture height supported by hardware
32, // max texture bpp supported by hardware
m_options,
config.textureFilter.txCacheSize, // cache texture to system memory
txCachePath, // path to store cache files
pTexPackPath, // path to texture packs folder
wRomName, // name of ROM. must be no longer than 256 characters
displayLoadProgress);
} }
void TextureFilterHandler::shutdown() void TextureFilterHandler::shutdown()
{ {
if (isInited()) { if (isInited()) {
txfilter_shutdown(); txfilter_shutdown();
m_inited = 0; m_inited = m_options = 0;
} }
} }

View File

@ -264,14 +264,17 @@ OGLVideo & video()
class TextureFilterHandler class TextureFilterHandler
{ {
public: public:
TextureFilterHandler() : m_inited(0) {} TextureFilterHandler() : m_inited(0), m_options(0) {}
// It's not safe to call shutdown() in destructor, because texture filter has its own static objects, which can be destroyed first. // It's not safe to call shutdown() in destructor, because texture filter has its own static objects, which can be destroyed first.
~TextureFilterHandler() { m_inited = 0; } ~TextureFilterHandler() { m_inited = m_options = 0; }
void init(); void init();
void shutdown(); void shutdown();
bool isInited() const { return m_inited != 0; } bool isInited() const { return m_inited != 0; }
bool optionsChanged() const { return _getConfigOptions() != m_options; }
private: private:
u32 _getConfigOptions() const;
u32 m_inited; u32 m_inited;
u32 m_options;
}; };
extern TextureFilterHandler TFH; extern TextureFilterHandler TFH;

View File

@ -31,7 +31,6 @@ void RSP_ThreadProc(std::mutex * _pRspThreadMtx, std::mutex * _pPluginThreadMtx,
GBI.init(); GBI.init();
Config_LoadConfig(); Config_LoadConfig();
video().start(); video().start();
TFH.init();
assert(!isGLError()); assert(!isGLError());
while (true) { while (true) {