From: Toni Wilen Date: Sun, 16 Nov 2025 11:39:01 +0000 (+0200) Subject: Added optional gettickcount() timing X-Git-Tag: 6020~66 X-Git-Url: https://git.unchartedbackwaters.co.uk/w/?a=commitdiff_plain;h=3bc3f1576e448ab872f6ad549b5e19afc232e11d;p=francis%2Fwinuae.git Added optional gettickcount() timing --- diff --git a/include/uae/time.h b/include/uae/time.h index dcbdd3a7..7627a1d7 100644 --- a/include/uae/time.h +++ b/include/uae/time.h @@ -11,7 +11,7 @@ void uae_time_calibrate(void); uae_time_t uae_time(void); #ifdef _WIN32 -void uae_time_use_rdtsc(bool enable); +void uae_time_use_mode(int mode); uae_s64 read_system_time(void); uae_s64 read_processor_time_rdtsc(void); #endif diff --git a/od-win32/win32.cpp b/od-win32/win32.cpp index 45e3c03c..49fe75b3 100644 --- a/od-win32/win32.cpp +++ b/od-win32/win32.cpp @@ -6886,7 +6886,11 @@ static int parseargs(const TCHAR *argx, const TCHAR *np, const TCHAR *np2) return 1; } if (!_tcscmp(arg, _T("forcerdtsc"))) { - uae_time_use_rdtsc(true); + uae_time_use_mode(1); + return 1; + } + if (!_tcscmp(arg, _T("forcetickcount"))) { + uae_time_use_mode(2); return 1; } if (!_tcscmp(arg, _T("ddsoftwarecolorkey"))) { diff --git a/support/time.cpp b/support/time.cpp index b98b6454..ec06b34d 100644 --- a/support/time.cpp +++ b/support/time.cpp @@ -9,7 +9,7 @@ #include -static int userdtsc = 0; +static int usedtimermode = 0; static int qpcdivisor = 0; static SYSTEM_INFO si; @@ -27,6 +27,12 @@ static frame_time_t read_processor_time_qpf(void) return t; } +static frame_time_t read_processor_time_tickcount(void) +{ + frame_time_t v = (frame_time_t)GetTickCount64(); + return v; +} + uae_s64 read_processor_time_rdtsc(void) { #ifdef __arm__ @@ -48,10 +54,13 @@ uae_time_t uae_time(void) cnt = 0; } #endif - if (userdtsc) + if (usedtimermode == 1) { t = read_processor_time_rdtsc(); - else + } else if (usedtimermode == 0) { t = read_processor_time_qpf(); + } else { + t = read_processor_time_tickcount(); + } return t; } @@ -85,6 +94,12 @@ static uae_s64 win32_read_processor_time(void) #endif } +static void figure_processor_speed_tickcount(void) +{ + syncbase = 1000; + write_log(_T("CLOCKFREQ: TC %.4fMHz\n"), syncbase / 10000000.0); +} + static void figure_processor_speed_rdtsc(void) { static int freqset; @@ -106,7 +121,7 @@ static void figure_processor_speed_rdtsc(void) clockrate = (win32_read_processor_time() - clockrate) * 2; dummythread_die = 0; SetThreadPriority(th, oldpri); - write_log(_T("CLOCKFREQ: RDTSC %.2fMHz\n"), clockrate / 1000000.0); + write_log(_T("CLOCKFREQ: RDTSC %.4fMHz\n"), clockrate / 1000000.0); syncbase = clockrate >> 6; } @@ -128,7 +143,7 @@ static void figure_processor_speed_qpf(void) qpfrate >>= 1; qpcdivisor++; } - write_log(_T("CLOCKFREQ: QPF %.2fMHz (%.2fMHz, DIV=%d)\n"), + write_log(_T("CLOCKFREQ: QPF %.4fMHz (%.2fMHz, DIV=%d)\n"), freq.QuadPart / 1000000.0, qpfrate / 1000000.0, 1 << qpcdivisor); syncbase = qpfrate; @@ -136,17 +151,18 @@ static void figure_processor_speed_qpf(void) void uae_time_calibrate(void) { - if (userdtsc) { + if (usedtimermode == 1) { figure_processor_speed_rdtsc(); - } - if (!userdtsc) { + } if (usedtimermode == 0) { figure_processor_speed_qpf(); + } else { + figure_processor_speed_tickcount(); } } -void uae_time_use_rdtsc(bool enable) +void uae_time_use_mode(int mode) { - userdtsc = enable; + usedtimermode = mode; } #elif defined(USE_GLIB)