From ca5abad7d6b028afcdab3f14b42558b7c856c9d4 Mon Sep 17 00:00:00 2001 From: Dario Date: Thu, 25 Jul 2024 22:23:59 -0300 Subject: [PATCH] Rewrite some unclear code. --- src/render/rt64_texture_cache.cpp | 30 +++++++++++++++--------------- 1 file changed, 15 insertions(+), 15 deletions(-) diff --git a/src/render/rt64_texture_cache.cpp b/src/render/rt64_texture_cache.cpp index 7e8c10a..309a70a 100644 --- a/src/render/rt64_texture_cache.cpp +++ b/src/render/rt64_texture_cache.cpp @@ -1079,22 +1079,22 @@ namespace RT64 { descSet->setTexture(descSet->TMEM, dstTexture->tmem.get(), RenderTextureLayout::SHADER_READ); descSet->setTexture(descSet->RGBA32, dstTexture->texture.get(), RenderTextureLayout::GENERAL); beforeDecodeBarriers.emplace_back(dstTexture->texture.get(), RenderTextureLayout::GENERAL); + + // If the databases that were loaded have different hash versions, we have much to to check for all possible replacements with all possible hashes. + for (uint32_t hashVersion : textureMap.replacementMap.resolvedHashVersions) { + // If the database uses an older hash version, we hash TMEM again with the version corresponding to the database. + uint64_t databaseHash = upload.hash; + if (hashVersion < TMEMHasher::CurrentHashVersion) { + databaseHash = TMEMHasher::hash(upload.bytesTMEM.data(), upload.loadTile, upload.width, upload.height, upload.tlut, hashVersion); + } + + // Add this hash so it's checked for a replacement. + replacementQueueCopy.emplace_back(ReplacementCheck{ upload.hash, databaseHash }); + } } - - // If the databases that were loaded have different hash versions, we have much to attempt to check for all possible replacements with all possible hashes. - for (uint32_t hashVersion : textureMap.replacementMap.resolvedHashVersions) { - // If the database uses an older hash version, we hash TMEM again with the version corresponding to the database. - uint64_t databaseHash = upload.hash; - if (upload.decodeTMEM && (hashVersion < TMEMHasher::CurrentHashVersion)) { - databaseHash = TMEMHasher::hash(upload.bytesTMEM.data(), upload.loadTile, upload.width, upload.height, upload.tlut, hashVersion); - } - - // Add this hash so it's checked for a replacement. - replacementQueueCopy.emplace_back(ReplacementCheck{ upload.hash, databaseHash }); - - if (!upload.decodeTMEM) { - break; - } + else { + // Hash version differences from database versions are not possible when TMEM doesn't need to be decoded. + replacementQueueCopy.emplace_back(ReplacementCheck{ upload.hash, upload.hash }); } }