System: Set time constraints for GPU thread on MacOS
Fixes erratic frame times.
This commit is contained in:
parent
d3854d095e
commit
0dc257abe4
|
@ -296,7 +296,7 @@ bool Threading::ThreadHandle::IsCallingThread() const
|
|||
|
||||
#ifdef __APPLE__
|
||||
|
||||
bool Threading::ThreadHandle::SetTimeConstraints(bool enabled, u64 period, u64 typical_time, u64 maximum_time)
|
||||
bool Threading::ThreadHandle::SetTimeConstraints(bool enabled, u64 period, u64 typical_time, u64 maximum_time) const
|
||||
{
|
||||
const mach_port_t mach_thread_id = pthread_mach_thread_np((pthread_t)m_native_handle);
|
||||
if (!enabled)
|
||||
|
|
|
@ -58,7 +58,7 @@ public:
|
|||
|
||||
#ifdef __APPLE__
|
||||
/// Only available on MacOS, sets a period/maximum time for the scheduler.
|
||||
bool SetTimeConstraints(bool enabled, u64 period, u64 typical_time, u64 maximum_time);
|
||||
bool SetTimeConstraints(bool enabled, u64 period, u64 typical_time, u64 maximum_time) const;
|
||||
#endif
|
||||
|
||||
protected:
|
||||
|
|
|
@ -3558,11 +3558,20 @@ void System::UpdateSpeedLimiterState()
|
|||
constexpr u64 MAX_FRAME_TIME_NS = 7000000;
|
||||
static u64 last_scheduler_period = 0;
|
||||
const u64 new_scheduler_period = s_state.optimal_frame_pacing ? s_state.frame_period : 0;
|
||||
if (s_state.cpu_thread_handle && new_scheduler_period != last_scheduler_period)
|
||||
if (new_scheduler_period != last_scheduler_period)
|
||||
{
|
||||
s_state.cpu_thread_handle.SetTimeConstraints(s_state.optimal_frame_pacing, new_scheduler_period, MAX_FRAME_TIME_NS,
|
||||
if (s_state.cpu_thread_handle)
|
||||
{
|
||||
s_state.cpu_thread_handle.SetTimeConstraints(s_state.optimal_frame_pacing, new_scheduler_period,
|
||||
MAX_FRAME_TIME_NS, new_scheduler_period);
|
||||
}
|
||||
const Threading::ThreadHandle& gpu_thread = GPUThread::Internal::GetThreadHandle();
|
||||
if (gpu_thread)
|
||||
{
|
||||
gpu_thread.SetTimeConstraints(s_state.optimal_frame_pacing, new_scheduler_period, MAX_FRAME_TIME_NS,
|
||||
new_scheduler_period);
|
||||
}
|
||||
}
|
||||
#endif
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in New Issue