diff --git a/src/Config.cpp b/src/Config.cpp
index c4e971625..8a2463f45 100644
--- a/src/Config.cpp
+++ b/src/Config.cpp
@@ -103,6 +103,7 @@ void Config::resetToDefaults()
textureFilter.txCacheCompression = 1;
textureFilter.txSaveCache = 1;
textureFilter.txDump = 0;
+ textureFilter.txStrongCRC = 0;
textureFilter.txEnhancedTextureFileStorage = 0;
textureFilter.txHiresTextureFileStorage = 0;
@@ -207,6 +208,8 @@ const char* Config::hotkeyIniName(u32 _idx)
return "hkForceGammaCorrection";
case Config::HotKey::hkInaccurateTexCords:
return "hkInaccurateTexCords";
+ case Config::HotKey::hkStrongCRC:
+ return "hkStrongCRC";
}
return nullptr;
}
@@ -245,6 +248,8 @@ const char* Config::enabledHotkeyIniName(u32 _idx)
return "hkForceGammaCorrectionEnabled";
case Config::HotKey::hkInaccurateTexCords:
return "hkInaccurateTexCordsEnabled";
+ case Config::HotKey::hkStrongCRC:
+ return "hkStrongCRCEnabled";
}
return nullptr;
}
diff --git a/src/Config.h b/src/Config.h
index 07ffa138a..053a27622 100644
--- a/src/Config.h
+++ b/src/Config.h
@@ -177,6 +177,7 @@ struct Config
u32 txCacheCompression; // Zip textures cache
u32 txSaveCache; // Save texture cache to hard disk
u32 txDump; // Dump textures
+ u32 txStrongCRC; // Dump textures with alternative (strong) CRC
u32 txEnhancedTextureFileStorage; // Use file storage instead of memory cache for enhanced textures.
u32 txHiresTextureFileStorage; // Use file storage instead of memory cache for hires textures.
@@ -239,6 +240,7 @@ struct Config
hkOsdRenderingResolution,
hkForceGammaCorrection,
hkInaccurateTexCords,
+ hkStrongCRC,
hkTotal
};
diff --git a/src/GLideNHQ/TxFilterExport.h b/src/GLideNHQ/TxFilterExport.h
index 6eec67a25..ba50decb7 100644
--- a/src/GLideNHQ/TxFilterExport.h
+++ b/src/GLideNHQ/TxFilterExport.h
@@ -92,7 +92,7 @@ typedef unsigned char boolean;
#define GZ_HIRESTEXCACHE 0x00800000
#define DUMP_TEXCACHE 0x01000000
#define DUMP_HIRESTEXCACHE 0x02000000
-#define UNDEFINED_0 0x04000000
+#define DUMP_STRONG_CRC 0x04000000
#define UNDEFINED_1 0x08000000
#define FORCE16BPP_HIRESTEX 0x10000000
#define FORCE16BPP_TEX 0x20000000
diff --git a/src/GLideNUI/ConfigDialog.cpp b/src/GLideNUI/ConfigDialog.cpp
index d9dc88053..e00cee456 100644
--- a/src/GLideNUI/ConfigDialog.cpp
+++ b/src/GLideNUI/ConfigDialog.cpp
@@ -105,6 +105,8 @@ QString ConfigDialog::_hotkeyDescription(quint32 _idx) const
return tr("Toggle force gamma correction");
case Config::HotKey::hkInaccurateTexCords:
return tr("Toggle inaccurate texture coordinates");
+ case Config::HotKey::hkStrongCRC:
+ return tr("Toggle strong CRC for textures dump");
}
return tr("Unknown hotkey");
}
@@ -373,6 +375,7 @@ void ConfigDialog::_init(bool reInit, bool blockCustomSettings)
ui->texturePackGroupBox->setChecked(config.textureFilter.txHiresEnable != 0);
ui->alphaChannelCheckBox->setChecked(config.textureFilter.txHiresFullAlphaChannel != 0);
ui->alternativeCRCCheckBox->setChecked(config.textureFilter.txHresAltCRC != 0);
+ ui->strongCRCCheckBox->setChecked(config.textureFilter.txStrongCRC != 0);
ui->force16bppCheckBox->setChecked(config.textureFilter.txForce16bpp != 0);
ui->compressCacheCheckBox->setChecked(config.textureFilter.txCacheCompression != 0);
ui->saveTextureCacheCheckBox->setChecked(config.textureFilter.txSaveCache != 0);
@@ -689,6 +692,7 @@ void ConfigDialog::accept(bool justSave) {
config.textureFilter.txHiresEnable = ui->texturePackGroupBox->isChecked() ? 1 : 0;
config.textureFilter.txHiresFullAlphaChannel = ui->alphaChannelCheckBox->isChecked() ? 1 : 0;
config.textureFilter.txHresAltCRC = ui->alternativeCRCCheckBox->isChecked() ? 1 : 0;
+ config.textureFilter.txStrongCRC = ui->strongCRCCheckBox->isChecked() ? 1 : 0;
config.textureFilter.txCacheCompression = ui->compressCacheCheckBox->isChecked() ? 1 : 0;
config.textureFilter.txForce16bpp = ui->force16bppCheckBox->isChecked() ? 1 : 0;
diff --git a/src/GLideNUI/Settings.cpp b/src/GLideNUI/Settings.cpp
index c32e0472c..be7a9a1ba 100644
--- a/src/GLideNUI/Settings.cpp
+++ b/src/GLideNUI/Settings.cpp
@@ -103,6 +103,7 @@ void _loadSettings(QSettings & settings)
config.textureFilter.txHiresEnable = settings.value("txHiresEnable", config.textureFilter.txHiresEnable).toInt();
config.textureFilter.txHiresFullAlphaChannel = settings.value("txHiresFullAlphaChannel", config.textureFilter.txHiresFullAlphaChannel).toInt();
config.textureFilter.txHresAltCRC = settings.value("txHresAltCRC", config.textureFilter.txHresAltCRC).toInt();
+ config.textureFilter.txStrongCRC = settings.value("txStrongCRC", config.textureFilter.txStrongCRC).toInt();
config.textureFilter.txForce16bpp = settings.value("txForce16bpp", config.textureFilter.txForce16bpp).toInt();
config.textureFilter.txCacheCompression = settings.value("txCacheCompression", config.textureFilter.txCacheCompression).toInt();
config.textureFilter.txSaveCache = settings.value("txSaveCache", config.textureFilter.txSaveCache).toInt();
@@ -252,6 +253,7 @@ void _writeSettingsToFile(const QString & filename)
settings.setValue("txHiresEnable", config.textureFilter.txHiresEnable);
settings.setValue("txHiresFullAlphaChannel", config.textureFilter.txHiresFullAlphaChannel);
settings.setValue("txHresAltCRC", config.textureFilter.txHresAltCRC);
+ settings.setValue("txStrongCRC", config.textureFilter.txStrongCRC);
settings.setValue("txForce16bpp", config.textureFilter.txForce16bpp);
settings.setValue("txCacheCompression", config.textureFilter.txCacheCompression);
settings.setValue("txSaveCache", config.textureFilter.txSaveCache);
@@ -550,6 +552,7 @@ void saveCustomRomSettings(const QString & _strIniFolder, const QString & _strSh
WriteCustomSetting(textureFilter, txHiresEnable);
WriteCustomSetting(textureFilter, txHiresFullAlphaChannel);
WriteCustomSetting(textureFilter, txHresAltCRC);
+ WriteCustomSetting(textureFilter, txStrongCRC);
WriteCustomSetting(textureFilter, txForce16bpp);
WriteCustomSetting(textureFilter, txCacheCompression);
WriteCustomSetting(textureFilter, txSaveCache);
diff --git a/src/GLideNUI/configDialog.ui b/src/GLideNUI/configDialog.ui
index 7f8f8ad1a..c66745048 100644
--- a/src/GLideNUI/configDialog.ui
+++ b/src/GLideNUI/configDialog.ui
@@ -2678,6 +2678,16 @@
+ -
+
+
+ <html><head/><body><p>This option enables alternative, strong CRC method instead of RiceCRC for texture dump. If you find some textures not dumped, try checking this option.</p><p>[Recommended: <span style=" font-style:italic;">Mostly unchecked, unless RiceCRC fails</span>]</p></body></html>
+
+
+ Strong CRC calculation (when RiceCRC fails)
+
+
+
-
diff --git a/src/TextureFilterHandler.cpp b/src/TextureFilterHandler.cpp
index 5233b85fd..44f1639c7 100644
--- a/src/TextureFilterHandler.cpp
+++ b/src/TextureFilterHandler.cpp
@@ -57,6 +57,8 @@ u32 TextureFilterHandler::_getConfigOptions() const
options |= LET_TEXARTISTS_FLY;
if (config.hotkeys.enabledKeys[Config::HotKey::hkTexDump] != 0 || config.textureFilter.txDump)
options |= DUMP_TEX;
+ if (config.textureFilter.txStrongCRC)
+ options |= DUMP_STRONG_CRC;
if (config.textureFilter.txDeposterize)
options |= DEPOSTERIZE;
if (config.textureFilter.txEnhancedTextureFileStorage)
@@ -110,6 +112,12 @@ void TextureFilterHandler::init()
pTexDumpPath = txDumpPath;
}
+ if (config.textureFilter.txStrongCRC) {
+ ::wcscpy(txDumpPath, pTexDumpPath);
+ gln_wcscat(txDumpPath, wst("/strong_crc"));
+ pTexDumpPath = txDumpPath;
+ }
+
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
diff --git a/src/Textures.cpp b/src/Textures.cpp
index f340c9e24..7c5aeae49 100644
--- a/src/Textures.cpp
+++ b/src/Textures.cpp
@@ -1151,7 +1151,7 @@ void TextureCache::_loadBackground(CachedTexture *pTexture)
free(pDest);
}
-bool TextureCache::_loadHiresTexture(u32 _tile, CachedTexture *_pTexture, u64 & _ricecrc)
+bool TextureCache::_loadHiresTexture(u32 _tile, CachedTexture *_pTexture, u64 & _ricecrc, u64 & _strongcrc)
{
if (config.textureFilter.txHiresEnable == 0 || !TFH.isInited())
return false;
@@ -1221,10 +1221,18 @@ bool TextureCache::_loadHiresTexture(u32 _tile, CachedTexture *_pTexture, u64 &
}
_ricecrc = txfilter_checksum(addr, width, height, _pTexture->size, bpl, paladdr);
+ if (config.textureFilter.txStrongCRC)
+ _strongcrc = txfilter_checksum_strong(addr, width, height, _pTexture->size, bpl, paladdr);
GHQTexInfo ghqTexInfo;
// TODO: fix problem with zero texture dimensions on GLideNHQ side.
- if (txfilter_hirestex(_pTexture->crc, _ricecrc, palette, N64FormatSize(_pTexture->format, _pTexture->size), &ghqTexInfo) &&
- ghqTexInfo.width != 0 && ghqTexInfo.height != 0) {
+ auto hirestexFound = txfilter_hirestex(_pTexture->crc, _ricecrc, palette, N64FormatSize(_pTexture->format, _pTexture->size), &ghqTexInfo);
+ if (!hirestexFound) {
+ // Texture with RiceCRC was not found. Try alternative CRC.
+ if (_strongcrc == 0U)
+ _strongcrc = txfilter_checksum_strong(addr, width, height, _pTexture->size, bpl, paladdr);
+ hirestexFound = txfilter_hirestex(_pTexture->crc, _strongcrc, palette, N64FormatSize(_pTexture->format, _pTexture->size), &ghqTexInfo);
+ }
+ if (hirestexFound && ghqTexInfo.width != 0 && ghqTexInfo.height != 0) {
ghqTexInfo.format = gfxContext.convertInternalTextureFormat(ghqTexInfo.format);
Context::InitTextureParams params;
params.handle = _pTexture->name;
@@ -1390,7 +1398,8 @@ void doubleTexture(T* pTex, u32 width, u32 height)
void TextureCache::_loadFast(u32 _tile, CachedTexture *_pTexture)
{
u64 ricecrc = 0;
- if (_loadHiresTexture(_tile, _pTexture, ricecrc))
+ u64 strongcrc = 0;
+ if (_loadHiresTexture(_tile, _pTexture, ricecrc, strongcrc))
return;
s32 mipLevel = 0;
@@ -1493,7 +1502,7 @@ void TextureCache::_loadFast(u32 _tile, CachedTexture *_pTexture)
txfilter_dmptx((u8*)m_tempTextureHolder.data(), tmptex.width, tmptex.height,
tmptex.width, (u16)u32(glInternalFormat),
N64FormatSize(_pTexture->format, _pTexture->size),
- ricecrc);
+ config.textureFilter.txStrongCRC ? strongcrc : ricecrc);
}
bool bLoaded = false;
@@ -1591,7 +1600,8 @@ void TextureCache::_loadFast(u32 _tile, CachedTexture *_pTexture)
void TextureCache::_loadAccurate(u32 _tile, CachedTexture *_pTexture)
{
u64 ricecrc = 0;
- if (_loadHiresTexture(_tile, _pTexture, ricecrc))
+ u64 strongcrc = 0;
+ if (_loadHiresTexture(_tile, _pTexture, ricecrc, strongcrc))
return;
bool force32bitFormat = false;
@@ -1669,7 +1679,7 @@ void TextureCache::_loadAccurate(u32 _tile, CachedTexture *_pTexture)
txfilter_dmptx((u8*)(m_tempTextureHolder.data() + texDataOffset), tmptex.width, tmptex.height,
tmptex.width, (u16)u32(glInternalFormat),
N64FormatSize(_pTexture->format, _pTexture->size),
- ricecrc);
+ config.textureFilter.txStrongCRC ? strongcrc : ricecrc);
}
texDataOffset += tmptex.width * tmptex.height;
@@ -1728,7 +1738,7 @@ void TextureCache::_loadAccurate(u32 _tile, CachedTexture *_pTexture)
txfilter_dmptx((u8*)m_tempTextureHolder.data(), tmptex.width, tmptex.height,
tmptex.width, (u16)u32(glInternalFormat),
N64FormatSize(_pTexture->format, _pTexture->size),
- ricecrc);
+ config.textureFilter.txStrongCRC ? strongcrc : ricecrc);
}
bool bLoaded = false;
diff --git a/src/Textures.h b/src/Textures.h
index 0fb985231..fb84d6e5f 100644
--- a/src/Textures.h
+++ b/src/Textures.h
@@ -90,7 +90,7 @@ struct TextureCache
CachedTexture * _addTexture(u64 _crc64);
void _loadFast(u32 _tile, CachedTexture *_pTexture);
void _loadAccurate(u32 _tile, CachedTexture *_pTexture);
- bool _loadHiresTexture(u32 _tile, CachedTexture *_pTexture, u64 & _ricecrc);
+ bool _loadHiresTexture(u32 _tile, CachedTexture *_pTexture, u64 & _ricecrc, u64 & _strongcrc);
void _loadBackground(CachedTexture *pTexture);
bool _loadHiresBackground(CachedTexture *_pTexture, u64 & _ricecrc);
void _loadDepthTexture(CachedTexture * _pTexture, u16* _pDest);
diff --git a/src/VI.cpp b/src/VI.cpp
index ed8099043..6b6f958be 100644
--- a/src/VI.cpp
+++ b/src/VI.cpp
@@ -15,6 +15,7 @@
#include "DebugDump.h"
#include "osal_keys.h"
#include "DisplayWindow.h"
+#include "TextureFilterHandler.h"
#include "GLideNHQ/TxFilterExport.h"
#include
@@ -131,6 +132,16 @@ static void checkHotkeys()
/* Turn on texture dump */
if (osal_is_key_pressed(config.hotkeys.enabledKeys[Config::hkTexDump], 0x0001))
textureCache().toggleDumpTex();
+
+ if (osal_is_key_pressed(config.hotkeys.enabledKeys[Config::hkStrongCRC], 0x0001)) {
+ if (config.textureFilter.txStrongCRC == 0)
+ dwnd().getDrawer().showMessage("Enable strong CRC for textures dump\n", Milliseconds(750));
+ else
+ dwnd().getDrawer().showMessage("Disable strong CRC for textures dump\n", Milliseconds(750));
+ config.textureFilter.txStrongCRC = !config.textureFilter.txStrongCRC;
+ TFH.shutdown();
+ TFH.init();
+ }
}
if (osal_is_key_pressed(config.hotkeys.enabledKeys[Config::hkTexCoordBounds], 0x0001)) {
diff --git a/src/mupenplus/Config_mupenplus.cpp b/src/mupenplus/Config_mupenplus.cpp
index f3bac1692..3003dfe55 100644
--- a/src/mupenplus/Config_mupenplus.cpp
+++ b/src/mupenplus/Config_mupenplus.cpp
@@ -53,6 +53,8 @@ const char* _hotkeyDescription(u32 _idx)
return "Hotkey: toggle force gamma correction";
case Config::HotKey::hkInaccurateTexCords:
return "Hotkey: toggle inaccurate texture coordinates";
+ case Config::HotKey::hkStrongCRC:
+ return "Hotkey: toggle strong CRC for textures dump";
}
return "Unknown hotkey";
}
@@ -257,6 +259,8 @@ bool Config_SetDefault()
assert(res == M64ERR_SUCCESS);
res = ConfigSetDefaultBool(g_configVideoGliden64, "txDump", config.textureFilter.txDump, "Dump textures");
assert(res == M64ERR_SUCCESS);
+ res = ConfigSetDefaultBool(g_configVideoGliden64, "txStrongCRC", config.textureFilter.txStrongCRC, "Use strong CRC for texture dump.");
+ assert(res == M64ERR_SUCCESS);
res = ConfigSetDefaultBool(g_configVideoGliden64, "txEnhancedTextureFileStorage", config.textureFilter.txEnhancedTextureFileStorage, "Use file storage instead of memory cache for enhanced textures.");
assert(res == M64ERR_SUCCESS);
res = ConfigSetDefaultBool(g_configVideoGliden64, "txHiresTextureFileStorage", config.textureFilter.txHiresTextureFileStorage, "Use file storage instead of memory cache for HD textures.");
@@ -473,6 +477,8 @@ void Config_LoadCustomConfig()
if (result == M64ERR_SUCCESS) config.textureFilter.txSaveCache = atoi(value);
result = ConfigExternalGetParameter(fileHandle, sectionName, "textureFilter\\txDump", value, sizeof(value));
if (result == M64ERR_SUCCESS) config.textureFilter.txDump = atoi(value);
+ result = ConfigExternalGetParameter(fileHandle, sectionName, "textureFilter\\txStrongCRC", value, sizeof(value));
+ if (result == M64ERR_SUCCESS) config.textureFilter.txStrongCRC = atoi(value);
result = ConfigExternalGetParameter(fileHandle, sectionName, "textureFilter\\txEnhancedTextureFileStorage", value, sizeof(value));
if (result == M64ERR_SUCCESS) config.textureFilter.txEnhancedTextureFileStorage = atoi(value);
result = ConfigExternalGetParameter(fileHandle, sectionName, "textureFilter\\txHiresTextureFileStorage", value, sizeof(value));
@@ -569,6 +575,7 @@ void Config_LoadConfig()
config.textureFilter.txCacheCompression = ConfigGetParamBool(g_configVideoGliden64, "txCacheCompression");
config.textureFilter.txSaveCache = ConfigGetParamBool(g_configVideoGliden64, "txSaveCache");
config.textureFilter.txDump = ConfigGetParamBool(g_configVideoGliden64, "txDump");
+ config.textureFilter.txStrongCRC = ConfigGetParamBool(g_configVideoGliden64, "txStrongCRC");
config.textureFilter.txEnhancedTextureFileStorage = ConfigGetParamBool(g_configVideoGliden64, "txEnhancedTextureFileStorage");
config.textureFilter.txHiresTextureFileStorage = ConfigGetParamBool(g_configVideoGliden64, "txHiresTextureFileStorage");
config.textureFilter.txNoTextureFileStorage = ConfigGetParamBool(g_configVideoGliden64, "txNoTextureFileStorage");