From 0c2a2d85fe843144cbc33580b77bf07ab73134e5 Mon Sep 17 00:00:00 2001 From: Luke Usher Date: Thu, 1 Feb 2018 21:38:10 +0000 Subject: [PATCH] Oops, the previous commit actually made hashing NEVER happen, no wonder it was so fast --- src/CxbxKrnl/EmuD3D8.cpp | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/src/CxbxKrnl/EmuD3D8.cpp b/src/CxbxKrnl/EmuD3D8.cpp index 9bec4c3a0..d76f2ec49 100755 --- a/src/CxbxKrnl/EmuD3D8.cpp +++ b/src/CxbxKrnl/EmuD3D8.cpp @@ -822,12 +822,14 @@ bool HostResourceRequiresUpdate(resource_key_t key) // Rehash the resource after a certain amount of milliseconds has passed // We do this because hashing every single use is too expensive // Note: This will have to do until we get proper dirty page support - // Even with a 1ms hash lifetime, Turok goes from 2fps to 160fps on the title screen + // Currently this is set to roughly 1 hash per frame, but may need adjusting + // if wrong textures are seen in game. auto now = std::chrono::high_resolution_clock::now(); - auto duration = std::chrono::duration_cast(it->second.lastHashedTime - now).count(); - if (duration > 1) { - uint32_t oldHash = it->second.hash; + auto duration = std::chrono::duration_cast(now - it->second.lastHashedTime).count(); + if (duration > 16) { + uint32_t oldHash = it->second.hash; it->second.hash = XXHash32::hash(it->second.pXboxData, it->second.szXboxDataSize, 0); + it->second.lastHashedTime = now; if (it->second.hash != oldHash) { return true;