summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorGravatar liamwhite2023-07-02 17:38:28 -0400
committerGravatar GitHub2023-07-02 17:38:28 -0400
commit95ceae40e6f4806a1bf00913315ed22bd2842854 (patch)
treee1054aaadcfd0db9904835a3bf6ab80bf37d673c /src
parentMerge pull request #10479 from GPUCode/format-list (diff)
parentcore_timing: Remove GetCurrentTimerResolution in CoreTiming loop (diff)
downloadyuzu-95ceae40e6f4806a1bf00913315ed22bd2842854.tar.gz
yuzu-95ceae40e6f4806a1bf00913315ed22bd2842854.tar.xz
yuzu-95ceae40e6f4806a1bf00913315ed22bd2842854.zip
Merge pull request #10998 from Morph1984/qt-stop-messing-with-me
core_timing: Remove GetCurrentTimerResolution in CoreTiming loop
Diffstat (limited to 'src')
-rw-r--r--src/core/core_timing.cpp9
-rw-r--r--src/core/core_timing.h8
-rw-r--r--src/yuzu/main.cpp2
-rw-r--r--src/yuzu_cmd/yuzu.cpp8
4 files changed, 22 insertions, 5 deletions
diff --git a/src/core/core_timing.cpp b/src/core/core_timing.cpp
index 4f0a3f8ea..e6112a3c9 100644
--- a/src/core/core_timing.cpp
+++ b/src/core/core_timing.cpp
@@ -253,9 +253,6 @@ void CoreTiming::ThreadLoop() {
253 auto wait_time = *next_time - GetGlobalTimeNs().count(); 253 auto wait_time = *next_time - GetGlobalTimeNs().count();
254 if (wait_time > 0) { 254 if (wait_time > 0) {
255#ifdef _WIN32 255#ifdef _WIN32
256 const auto timer_resolution_ns =
257 Common::Windows::GetCurrentTimerResolution().count();
258
259 while (!paused && !event.IsSet() && wait_time > 0) { 256 while (!paused && !event.IsSet() && wait_time > 0) {
260 wait_time = *next_time - GetGlobalTimeNs().count(); 257 wait_time = *next_time - GetGlobalTimeNs().count();
261 258
@@ -316,4 +313,10 @@ std::chrono::microseconds CoreTiming::GetGlobalTimeUs() const {
316 return std::chrono::microseconds{Common::WallClock::CPUTickToUS(cpu_ticks)}; 313 return std::chrono::microseconds{Common::WallClock::CPUTickToUS(cpu_ticks)};
317} 314}
318 315
316#ifdef _WIN32
317void CoreTiming::SetTimerResolutionNs(std::chrono::nanoseconds ns) {
318 timer_resolution_ns = ns.count();
319}
320#endif
321
319} // namespace Core::Timing 322} // namespace Core::Timing
diff --git a/src/core/core_timing.h b/src/core/core_timing.h
index 10db1de55..5bca1c78d 100644
--- a/src/core/core_timing.h
+++ b/src/core/core_timing.h
@@ -131,6 +131,10 @@ public:
131 /// Checks for events manually and returns time in nanoseconds for next event, threadsafe. 131 /// Checks for events manually and returns time in nanoseconds for next event, threadsafe.
132 std::optional<s64> Advance(); 132 std::optional<s64> Advance();
133 133
134#ifdef _WIN32
135 void SetTimerResolutionNs(std::chrono::nanoseconds ns);
136#endif
137
134private: 138private:
135 struct Event; 139 struct Event;
136 140
@@ -143,6 +147,10 @@ private:
143 147
144 s64 global_timer = 0; 148 s64 global_timer = 0;
145 149
150#ifdef _WIN32
151 s64 timer_resolution_ns;
152#endif
153
146 // The queue is a min-heap using std::make_heap/push_heap/pop_heap. 154 // The queue is a min-heap using std::make_heap/push_heap/pop_heap.
147 // We don't use std::priority_queue because we need to be able to serialize, unserialize and 155 // We don't use std::priority_queue because we need to be able to serialize, unserialize and
148 // erase arbitrary events (RemoveEvent()) regardless of the queue order. These aren't 156 // erase arbitrary events (RemoveEvent()) regardless of the queue order. These aren't
diff --git a/src/yuzu/main.cpp b/src/yuzu/main.cpp
index e8418b302..fea5eb614 100644
--- a/src/yuzu/main.cpp
+++ b/src/yuzu/main.cpp
@@ -101,6 +101,7 @@ static FileSys::VirtualFile VfsDirectoryCreateFileWrapper(const FileSys::Virtual
101#include "common/settings.h" 101#include "common/settings.h"
102#include "common/telemetry.h" 102#include "common/telemetry.h"
103#include "core/core.h" 103#include "core/core.h"
104#include "core/core_timing.h"
104#include "core/crypto/key_manager.h" 105#include "core/crypto/key_manager.h"
105#include "core/file_sys/card_image.h" 106#include "core/file_sys/card_image.h"
106#include "core/file_sys/common_funcs.h" 107#include "core/file_sys/common_funcs.h"
@@ -389,6 +390,7 @@ GMainWindow::GMainWindow(std::unique_ptr<Config> config_, bool has_broken_vulkan
389 std::chrono::duration_cast<std::chrono::duration<f64, std::milli>>( 390 std::chrono::duration_cast<std::chrono::duration<f64, std::milli>>(
390 Common::Windows::SetCurrentTimerResolutionToMaximum()) 391 Common::Windows::SetCurrentTimerResolutionToMaximum())
391 .count()); 392 .count());
393 system->CoreTiming().SetTimerResolutionNs(Common::Windows::GetCurrentTimerResolution());
392#endif 394#endif
393 UpdateWindowTitle(); 395 UpdateWindowTitle();
394 396
diff --git a/src/yuzu_cmd/yuzu.cpp b/src/yuzu_cmd/yuzu.cpp
index 7b6d49c63..d0433ffc6 100644
--- a/src/yuzu_cmd/yuzu.cpp
+++ b/src/yuzu_cmd/yuzu.cpp
@@ -21,6 +21,7 @@
21#include "common/string_util.h" 21#include "common/string_util.h"
22#include "common/telemetry.h" 22#include "common/telemetry.h"
23#include "core/core.h" 23#include "core/core.h"
24#include "core/core_timing.h"
24#include "core/cpu_manager.h" 25#include "core/cpu_manager.h"
25#include "core/crypto/key_manager.h" 26#include "core/crypto/key_manager.h"
26#include "core/file_sys/registered_cache.h" 27#include "core/file_sys/registered_cache.h"
@@ -316,8 +317,6 @@ int main(int argc, char** argv) {
316 317
317#ifdef _WIN32 318#ifdef _WIN32
318 LocalFree(argv_w); 319 LocalFree(argv_w);
319
320 Common::Windows::SetCurrentTimerResolutionToMaximum();
321#endif 320#endif
322 321
323 MicroProfileOnThreadCreate("EmuThread"); 322 MicroProfileOnThreadCreate("EmuThread");
@@ -351,6 +350,11 @@ int main(int argc, char** argv) {
351 break; 350 break;
352 } 351 }
353 352
353#ifdef _WIN32
354 Common::Windows::SetCurrentTimerResolutionToMaximum();
355 system.CoreTiming().SetTimerResolutionNs(Common::Windows::GetCurrentTimerResolution());
356#endif
357
354 system.SetContentProvider(std::make_unique<FileSys::ContentProviderUnion>()); 358 system.SetContentProvider(std::make_unique<FileSys::ContentProviderUnion>());
355 system.SetFilesystem(std::make_shared<FileSys::RealVfsFilesystem>()); 359 system.SetFilesystem(std::make_shared<FileSys::RealVfsFilesystem>());
356 system.GetFileSystemController().CreateFactories(*system.GetFilesystem()); 360 system.GetFileSystemController().CreateFactories(*system.GetFilesystem());