diff --git a/src/common/util/cliConfig.cpp b/src/common/util/cliConfig.cpp index d6bac2ce7..96ac94860 100644 --- a/src/common/util/cliConfig.cpp +++ b/src/common/util/cliConfig.cpp @@ -155,7 +155,7 @@ long long GetSessionID() // Check if previous session ID had been set then use it. if (!GetValue(cli_config::sid, &sessionID)) { - sessionID = std::chrono::high_resolution_clock::now().time_since_epoch().count(); + sessionID = std::chrono::steady_clock::now().time_since_epoch().count(); // From now and the future will continue to use the same sessionID until all processes end. SetSID(sessionID); } diff --git a/src/core/hle/D3D8/Direct3D9/Direct3D9.cpp b/src/core/hle/D3D8/Direct3D9/Direct3D9.cpp index d5c23da46..52307f3b7 100644 --- a/src/core/hle/D3D8/Direct3D9/Direct3D9.cpp +++ b/src/core/hle/D3D8/Direct3D9/Direct3D9.cpp @@ -830,9 +830,9 @@ typedef struct { size_t szXboxDataSize = 0; uint64_t hash = 0; bool forceRehash = false; - std::chrono::time_point nextHashTime; + std::chrono::time_point nextHashTime; std::chrono::milliseconds hashLifeTime = 1ms; - std::chrono::time_point lastUpdate; + std::chrono::time_point lastUpdate; } resource_info_t; typedef std::unordered_map resource_cache_t; @@ -1029,7 +1029,7 @@ bool HostResourceRequiresUpdate(resource_key_t key, DWORD dwSize) bool modified = false; - auto now = std::chrono::high_resolution_clock::now(); + auto now = std::chrono::steady_clock::now(); if (now > it->second.nextHashTime || it->second.forceRehash) { uint64_t oldHash = it->second.hash; it->second.hash = ComputeHash(it->second.pXboxData, it->second.szXboxDataSize); @@ -1073,7 +1073,7 @@ void SetHostResource(XTL::X_D3DResource* pXboxResource, IDirect3DResource* pHost resourceInfo.szXboxDataSize = dwSize > 0 ? dwSize : GetXboxResourceSize(pXboxResource); resourceInfo.hash = ComputeHash(resourceInfo.pXboxData, resourceInfo.szXboxDataSize); resourceInfo.hashLifeTime = 1ms; - resourceInfo.lastUpdate = std::chrono::high_resolution_clock::now(); + resourceInfo.lastUpdate = std::chrono::steady_clock::now(); resourceInfo.nextHashTime = resourceInfo.lastUpdate + resourceInfo.hashLifeTime; resourceInfo.forceRehash = false; } @@ -4954,7 +4954,7 @@ VOID WINAPI XTL::EMUPATCH(D3DDevice_Present) EMUPATCH(D3DDevice_Swap)(CXBX_SWAP_PRESENT_FORWARD); // Xbox present ignores } -std::chrono::time_point frameStartTime; +std::chrono::time_point frameStartTime; // LTCG specific swap function... // Massive hack, but could coax some more LTCG titles into booting with HLE @@ -5211,25 +5211,25 @@ DWORD WINAPI XTL::EMUPATCH(D3DDevice_Swap) auto targetDuration = std::chrono::duration(((1000.0f / targetRefreshRate) * multiplier)); auto targetTimestamp = frameStartTime + targetDuration; - auto actualDuration = std::chrono::duration(std::chrono::high_resolution_clock::now() - frameStartTime); + auto actualDuration = std::chrono::duration(std::chrono::steady_clock::now() - frameStartTime); auto startTimeAjustment = actualDuration - targetDuration; // Only enter the wait loop if the frame took too long if (actualDuration < targetDuration) { // If we need to wait for a larger amount of time (>= 1 frame at 60FPS), we can just sleep - if (std::chrono::duration_cast(targetTimestamp - std::chrono::high_resolution_clock::now()).count() > 16) { + if (std::chrono::duration_cast(targetTimestamp - std::chrono::steady_clock::now()).count() > 16) { std::this_thread::sleep_until(targetTimestamp); } else { // Otherwise, we fall-through and just keep polling // This prevents large waits from hogging CPU power, but allows small waits/ to remain precice. - while (std::chrono::high_resolution_clock::now() < targetTimestamp) { + while (std::chrono::steady_clock::now() < targetTimestamp) { ; } } } } - frameStartTime = std::chrono::high_resolution_clock::now(); + frameStartTime = std::chrono::steady_clock::now(); UpdateFPSCounter(); diff --git a/src/devices/video/EmuNV2A_PTIMER.cpp b/src/devices/video/EmuNV2A_PTIMER.cpp index 073e653b7..33e1a4b48 100644 --- a/src/devices/video/EmuNV2A_PTIMER.cpp +++ b/src/devices/video/EmuNV2A_PTIMER.cpp @@ -41,8 +41,8 @@ static uint64_t ptimer_get_clock(NV2AState * d) { // Get time in nanoseconds - uint64_t time = std::chrono::duration_cast(std::chrono::high_resolution_clock::now().time_since_epoch()).count(); - + uint64_t time = std::chrono::duration_cast(std::chrono::steady_clock::now().time_since_epoch()).count(); + return Muldiv64(Muldiv64(time, (uint32_t)d->pramdac.core_clock_freq, // TODO : Research how this can be updated to accept uint64_t NANOSECONDS_PER_SECOND), // Was CLOCKS_PER_SEC