Skip to content

Commit

Permalink
ThrottleCallback: use microseconds to represent realtime
Browse files Browse the repository at this point in the history
Using milliseconds doesn't provide a lot of granularity, and we can use
all we can get for performance analysis.
  • Loading branch information
delroth committed Oct 25, 2018
1 parent dc5a678 commit eadb4a6
Showing 1 changed file with 7 additions and 7 deletions.
14 changes: 7 additions & 7 deletions Source/Core/Core/HW/SystemTimers.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -200,27 +200,27 @@ static void ThrottleCallback(u64 last_time, s64 cyclesLate)
// Allow the GPU thread to sleep. Setting this flag here limits the wakeups to 1 kHz.
Fifo::GpuMaySleep();

u32 time = Common::Timer::GetTimeMs();
u64 time = Common::Timer::GetTimeUs();

int diff = (u32)last_time - time;
s64 diff = last_time - time;
const SConfig& config = SConfig::GetInstance();
bool frame_limiter = config.m_EmulationSpeed > 0.0f && !Core::GetIsThrottlerTempDisabled();
u32 next_event = GetTicksPerSecond() / 1000;
if (frame_limiter)
{
if (config.m_EmulationSpeed != 1.0f)
next_event = u32(next_event * config.m_EmulationSpeed);
const int max_fallback = config.iTimingVariance;
const s64 max_fallback = config.iTimingVariance * 1000;
if (abs(diff) > max_fallback)
{
DEBUG_LOG(COMMON, "system too %s, %d ms skipped", diff < 0 ? "slow" : "fast",
abs(diff) - max_fallback);
last_time = time - max_fallback;
}
else if (diff > 0)
Common::SleepCurrentThread(diff);
else if ((diff / 1000) > 0)
Common::SleepCurrentThread(diff / 1000);
}
CoreTiming::ScheduleEvent(next_event - cyclesLate, et_Throttle, last_time + 1);
CoreTiming::ScheduleEvent(next_event - cyclesLate, et_Throttle, last_time + 1000);
}

// split from Init to break a circular dependency between VideoInterface::Init and
Expand Down Expand Up @@ -282,7 +282,7 @@ void Init()
CoreTiming::ScheduleEvent(VideoInterface::GetTicksPerHalfLine(), et_VI);
CoreTiming::ScheduleEvent(0, et_DSP);
CoreTiming::ScheduleEvent(s_audio_dma_period, et_AudioDMA);
CoreTiming::ScheduleEvent(0, et_Throttle, Common::Timer::GetTimeMs());
CoreTiming::ScheduleEvent(0, et_Throttle, Common::Timer::GetTimeUs());

CoreTiming::ScheduleEvent(VideoInterface::GetTicksPerField(), et_PatchEngine);

Expand Down

0 comments on commit eadb4a6

Please sign in to comment.