From 92bf6ed0a70da35152033965de524024003d3385 Mon Sep 17 00:00:00 2001 From: elad335 <18193363+elad335@users.noreply.github.com> Date: Tue, 29 Oct 2024 15:52:39 +0200 Subject: [PATCH] Replace rsx::uclock with get_system_time() --- rpcs3/Emu/RSX/Common/profiling_timer.hpp | 4 ++-- rpcs3/Emu/RSX/Common/time.hpp | 17 ----------------- rpcs3/Emu/RSX/NV47/HW/nv406e.cpp | 6 +++--- .../Emu/RSX/Overlays/overlay_animated_icon.cpp | 4 ++-- rpcs3/Emu/RSX/Overlays/overlay_message.cpp | 4 ++-- rpcs3/Emu/RSX/Overlays/overlays.cpp | 2 +- rpcs3/Emu/RSX/RSXFIFO.cpp | 14 +++++++------- rpcs3/Emu/RSX/RSXThread.cpp | 18 +++++++++--------- rpcs3/Emu/RSX/RSXZCULL.cpp | 2 +- rpcs3/Emu/RSX/VK/VKGSRender.cpp | 2 +- 10 files changed, 28 insertions(+), 45 deletions(-) diff --git a/rpcs3/Emu/RSX/Common/profiling_timer.hpp b/rpcs3/Emu/RSX/Common/profiling_timer.hpp index 7df016b9d1..88851626cc 100644 --- a/rpcs3/Emu/RSX/Common/profiling_timer.hpp +++ b/rpcs3/Emu/RSX/Common/profiling_timer.hpp @@ -16,7 +16,7 @@ namespace rsx { if (enabled) [[unlikely]] { - last = rsx::uclock(); + last = get_system_time(); } } @@ -28,7 +28,7 @@ namespace rsx } auto old = last; - last = rsx::uclock(); + last = get_system_time(); return static_cast(last - old); } }; diff --git a/rpcs3/Emu/RSX/Common/time.hpp b/rpcs3/Emu/RSX/Common/time.hpp index 430ba3fade..ad3aa56067 100644 --- a/rpcs3/Emu/RSX/Common/time.hpp +++ b/rpcs3/Emu/RSX/Common/time.hpp @@ -4,20 +4,3 @@ #include #include "Emu/Cell/timers.hpp" - -namespace rsx -{ - static inline u64 uclock() - { - static const ullong s_tsc_scaled_freq = (utils::get_tsc_freq() / 1000000); - - if (s_tsc_scaled_freq) - { - return utils::get_tsc() / s_tsc_scaled_freq; - } - else - { - return get_system_time(); - } - } -} diff --git a/rpcs3/Emu/RSX/NV47/HW/nv406e.cpp b/rpcs3/Emu/RSX/NV47/HW/nv406e.cpp index 4d43dcd37d..3c6d6de4e2 100644 --- a/rpcs3/Emu/RSX/NV47/HW/nv406e.cpp +++ b/rpcs3/Emu/RSX/NV47/HW/nv406e.cpp @@ -44,7 +44,7 @@ namespace rsx RSX(ctx)->flush_fifo(); } - u64 start = rsx::uclock(); + u64 start = get_system_time(); u64 last_check_val = start; while (sema != arg) @@ -57,7 +57,7 @@ namespace rsx if (const auto tdr = static_cast(g_cfg.video.driver_recovery_timeout)) { - const u64 current = rsx::uclock(); + const u64 current = get_system_time(); if (current - last_check_val > 20'000) { @@ -81,7 +81,7 @@ namespace rsx } RSX(ctx)->fifo_wake_delay(); - RSX(ctx)->performance_counters.idle_time += (rsx::uclock() - start); + RSX(ctx)->performance_counters.idle_time += (get_system_time() - start); } void semaphore_release(context* ctx, u32 /*reg*/, u32 arg) diff --git a/rpcs3/Emu/RSX/Overlays/overlay_animated_icon.cpp b/rpcs3/Emu/RSX/Overlays/overlay_animated_icon.cpp index 00f1e1bd13..d1af06bab2 100644 --- a/rpcs3/Emu/RSX/Overlays/overlay_animated_icon.cpp +++ b/rpcs3/Emu/RSX/Overlays/overlay_animated_icon.cpp @@ -25,11 +25,11 @@ namespace rsx { if (m_last_update_timestamp_us == 0) { - m_last_update_timestamp_us = rsx::uclock(); + m_last_update_timestamp_us = get_system_time(); } else { - const auto now = rsx::uclock(); + const auto now = get_system_time(); m_current_frame_duration_us += (now - m_last_update_timestamp_us); m_last_update_timestamp_us = now; } diff --git a/rpcs3/Emu/RSX/Overlays/overlay_message.cpp b/rpcs3/Emu/RSX/Overlays/overlay_message.cpp index 25a331d0df..5f794797df 100644 --- a/rpcs3/Emu/RSX/Overlays/overlay_message.cpp +++ b/rpcs3/Emu/RSX/Overlays/overlay_message.cpp @@ -13,7 +13,7 @@ namespace rsx return duration; } - return rsx::uclock() + duration; + return get_system_time() + duration; } template @@ -168,7 +168,7 @@ namespace rsx void message::update_queue(std::deque& vis_set, std::deque& ready_set, message_pin_location origin) { - const u64 cur_time = rsx::uclock(); + const u64 cur_time = get_system_time(); for (auto it = vis_set.begin(); it != vis_set.end();) { diff --git a/rpcs3/Emu/RSX/Overlays/overlays.cpp b/rpcs3/Emu/RSX/Overlays/overlays.cpp index c87105547f..e118b3a68c 100644 --- a/rpcs3/Emu/RSX/Overlays/overlays.cpp +++ b/rpcs3/Emu/RSX/Overlays/overlays.cpp @@ -499,7 +499,7 @@ namespace rsx } if (auto rsxthr = rsx::get_current_renderer(); rsxthr && - (min_refresh_duration_us + rsxthr->last_host_flip_timestamp) < rsx::uclock()) + (min_refresh_duration_us + rsxthr->last_host_flip_timestamp) < get_system_time()) { rsxthr->async_flip_requested |= rsx::thread::flip_request::native_ui; } diff --git a/rpcs3/Emu/RSX/RSXFIFO.cpp b/rpcs3/Emu/RSX/RSXFIFO.cpp index ae97509be4..839144a754 100644 --- a/rpcs3/Emu/RSX/RSXFIFO.cpp +++ b/rpcs3/Emu/RSX/RSXFIFO.cpp @@ -173,10 +173,10 @@ namespace rsx break; } - start_time = rsx::uclock(); + start_time = get_system_time(); } - auto now = rsx::uclock(); + auto now = get_system_time(); if (now - start_time >= 50u) { if (m_thread->is_stopped()) @@ -186,7 +186,7 @@ namespace rsx m_thread->cpu_wait({}); - const auto then = std::exchange(now, rsx::uclock()); + const auto then = std::exchange(now, get_system_time()); start_time = now; m_thread->performance_counters.idle_time += now - then; } @@ -623,7 +623,7 @@ namespace rsx { if (performance_counters.state == FIFO::state::running) { - performance_counters.FIFO_idle_timestamp = rsx::uclock(); + performance_counters.FIFO_idle_timestamp = get_system_time(); performance_counters.state = FIFO::state::nop; } @@ -633,7 +633,7 @@ namespace rsx { if (performance_counters.state == FIFO::state::running) { - performance_counters.FIFO_idle_timestamp = rsx::uclock(); + performance_counters.FIFO_idle_timestamp = get_system_time(); performance_counters.state = FIFO::state::empty; } else @@ -668,7 +668,7 @@ namespace rsx //Jump to self. Often preceded by NOP if (performance_counters.state == FIFO::state::running) { - performance_counters.FIFO_idle_timestamp = rsx::uclock(); + performance_counters.FIFO_idle_timestamp = get_system_time(); sync_point_request.release(true); } @@ -749,7 +749,7 @@ namespace rsx } // Update performance counters with time spent in idle mode - performance_counters.idle_time += (rsx::uclock() - performance_counters.FIFO_idle_timestamp); + performance_counters.idle_time += (get_system_time() - performance_counters.FIFO_idle_timestamp); } do diff --git a/rpcs3/Emu/RSX/RSXThread.cpp b/rpcs3/Emu/RSX/RSXThread.cpp index fb3a1e2975..df4395417e 100644 --- a/rpcs3/Emu/RSX/RSXThread.cpp +++ b/rpcs3/Emu/RSX/RSXThread.cpp @@ -1024,7 +1024,7 @@ namespace rsx fifo_ctrl = std::make_unique<::rsx::FIFO::FIFO_control>(this); fifo_ctrl->set_get(ctrl->get); - last_guest_flip_timestamp = rsx::uclock() - 1000000; + last_guest_flip_timestamp = get_system_time() - 1000000; vblank_count = 0; @@ -1104,7 +1104,7 @@ namespace rsx if (Emu.IsPaused()) { // Save the difference before pause - start_time = rsx::uclock() - start_time; + start_time = get_system_time() - start_time; while (Emu.IsPaused() && !is_stopped()) { @@ -1112,7 +1112,7 @@ namespace rsx } // Restore difference - start_time = rsx::uclock() - start_time; + start_time = get_system_time() - start_time; } } }))); @@ -3057,7 +3057,7 @@ namespace rsx } } - last_host_flip_timestamp = rsx::uclock(); + last_host_flip_timestamp = get_system_time(); } void thread::check_zcull_status(bool framebuffer_swap) @@ -3299,7 +3299,7 @@ namespace rsx { bool kill_itself = g_cfg.core.rsx_fifo_accuracy == rsx_fifo_mode::as_ps3; - const u64 current_time = rsx::uclock(); + const u64 current_time = get_system_time(); if (recovered_fifo_cmds_history.size() == 20u) { @@ -3381,7 +3381,7 @@ namespace rsx // Some cases do not need full delay remaining = utils::aligned_div(remaining, div); - const u64 until = rsx::uclock() + remaining; + const u64 until = get_system_time() + remaining; while (true) { @@ -3412,7 +3412,7 @@ namespace rsx busy_wait(100); } - const u64 current = rsx::uclock(); + const u64 current = get_system_time(); if (current >= until) { @@ -3654,7 +3654,7 @@ namespace rsx //Average load over around 30 frames if (!performance_counters.last_update_timestamp || performance_counters.sampled_frames > 30) { - const auto timestamp = rsx::uclock(); + const auto timestamp = get_system_time(); const auto idle = performance_counters.idle_time.load(); const auto elapsed = timestamp - performance_counters.last_update_timestamp; @@ -3938,7 +3938,7 @@ namespace rsx flip(m_queued_flip); - last_guest_flip_timestamp = rsx::uclock() - 1000000; + last_guest_flip_timestamp = get_system_time() - 1000000; flip_status = CELL_GCM_DISPLAY_FLIP_STATUS_DONE; m_queued_flip.in_progress = false; diff --git a/rpcs3/Emu/RSX/RSXZCULL.cpp b/rpcs3/Emu/RSX/RSXZCULL.cpp index d1a0b07806..cb9592fb0e 100644 --- a/rpcs3/Emu/RSX/RSXZCULL.cpp +++ b/rpcs3/Emu/RSX/RSXZCULL.cpp @@ -542,7 +542,7 @@ namespace rsx } } - if (m_tsc = rsx::uclock(); m_tsc < m_next_tsc) + if (m_tsc = get_system_time(); m_tsc < m_next_tsc) { return; } diff --git a/rpcs3/Emu/RSX/VK/VKGSRender.cpp b/rpcs3/Emu/RSX/VK/VKGSRender.cpp index c436efe672..acc9b9ba7c 100644 --- a/rpcs3/Emu/RSX/VK/VKGSRender.cpp +++ b/rpcs3/Emu/RSX/VK/VKGSRender.cpp @@ -1892,7 +1892,7 @@ void VKGSRender::sync_hint(rsx::FIFO::interrupt_hint hint, rsx::reports::sync_hi // OK, cell will be accessing the results, probably. // Try to avoid flush spam, it is more costly to flush the CB than it is to just upload the vertex data // This is supposed to be an optimization afterall. - const auto now = rsx::uclock(); + const auto now = get_system_time(); if ((now - m_last_cond_render_eval_hint) > 50) { // Schedule a sync on the next loop iteration