mirror of
https://github.com/RPCS3/rpcs3.git
synced 2025-07-10 00:41:26 +12:00
rsx: FIFO wake-up pause control
This commit is contained in:
parent
2984300385
commit
85695c8bac
5 changed files with 85 additions and 12 deletions
|
@ -2273,6 +2273,61 @@ namespace rsx
|
|||
}
|
||||
}
|
||||
|
||||
void thread::fifo_wake_delay(u64 div)
|
||||
{
|
||||
// TODO: Nanoseconds accuracy
|
||||
u64 remaining = g_cfg.video.driver_wakeup_delay;
|
||||
|
||||
if (!remaining)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
// Some cases do not need full delay
|
||||
remaining = ::aligned_div(remaining, div);
|
||||
const u64 until = get_system_time() + remaining;
|
||||
|
||||
while (true)
|
||||
{
|
||||
#ifdef __linux__
|
||||
// NOTE: Assumption that timer initialization has succeeded
|
||||
u64 host_min_quantum = remaining <= 1000 ? 10 : 50;
|
||||
#else
|
||||
// Host scheduler quantum for windows (worst case)
|
||||
// NOTE: On ps3 this function has very high accuracy
|
||||
constexpr u64 host_min_quantum = 500;
|
||||
#endif
|
||||
if (remaining >= host_min_quantum)
|
||||
{
|
||||
#ifdef __linux__
|
||||
// Do not wait for the last quantum to avoid loss of accuracy
|
||||
thread_ctrl::wait_for(remaining - ((remaining % host_min_quantum) + host_min_quantum), false);
|
||||
#else
|
||||
// Wait on multiple of min quantum for large durations to avoid overloading low thread cpus
|
||||
thread_ctrl::wait_for(remaining - (remaining % host_min_quantum), false);
|
||||
#endif
|
||||
}
|
||||
// TODO: Determine best value for yield delay
|
||||
else if (remaining >= host_min_quantum / 2)
|
||||
{
|
||||
std::this_thread::yield();
|
||||
}
|
||||
else
|
||||
{
|
||||
busy_wait(100);
|
||||
}
|
||||
|
||||
const u64 current = get_system_time();
|
||||
|
||||
if (current >= until)
|
||||
{
|
||||
break;
|
||||
}
|
||||
|
||||
remaining = until - current;
|
||||
}
|
||||
}
|
||||
|
||||
u32 thread::get_fifo_cmd()
|
||||
{
|
||||
// Last fifo cmd for logging and utility
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue