TimingEvents: Use a 64-bit integer for global tick counter

This commit is contained in:
Connor McLaughlin 2020-10-12 20:54:04 +10:00
parent bd421aaccd
commit ec032bfb15
4 changed files with 29 additions and 10 deletions

View File

@ -2,7 +2,7 @@
#include "types.h"
static constexpr u32 SAVE_STATE_MAGIC = 0x43435544;
static constexpr u32 SAVE_STATE_VERSION = 42;
static constexpr u32 SAVE_STATE_VERSION = 43;
static constexpr u32 SAVE_STATE_MINIMUM_VERSION = 42;
#pragma pack(push, 4)

View File

@ -93,7 +93,7 @@ static float s_worst_frame_time = 0.0f;
static float s_average_frame_time = 0.0f;
static u32 s_last_frame_number = 0;
static u32 s_last_internal_frame_number = 0;
static u32 s_last_global_tick_counter = 0;
static u64 s_last_global_tick_counter = 0;
static Common::Timer s_fps_timer;
static Common::Timer s_frame_timer;
@ -1229,7 +1229,7 @@ void UpdatePerformanceCounters()
return;
const float frames_presented = static_cast<float>(s_frame_number - s_last_frame_number);
const u32 global_tick_counter = TimingEvents::GetGlobalTickCounter();
const u64 global_tick_counter = TimingEvents::GetGlobalTickCounter();
s_worst_frame_time = s_worst_frame_time_accumulator;
s_worst_frame_time_accumulator = 0.0f;

View File

@ -12,10 +12,10 @@ static TimingEvent* s_active_events_head;
static TimingEvent* s_active_events_tail;
static TimingEvent* s_current_event = nullptr;
static u32 s_active_event_count = 0;
static u32 s_global_tick_counter = 0;
static u32 s_last_event_run_time = 0;
static u64 s_global_tick_counter = 0;
static u64 s_last_event_run_time = 0;
u32 GetGlobalTickCounter()
u64 GetGlobalTickCounter()
{
return s_global_tick_counter;
}
@ -255,7 +255,8 @@ void RunEvents()
{
DebugAssert(!s_current_event);
TickCount pending_ticks = (s_global_tick_counter + CPU::GetPendingTicks()) - s_last_event_run_time;
TickCount pending_ticks =
static_cast<TickCount>((s_global_tick_counter + static_cast<u32>(CPU::GetPendingTicks())) - s_last_event_run_time);
CPU::ResetPendingTicks();
while (pending_ticks > 0)
{
@ -298,7 +299,16 @@ void RunEvents()
bool DoState(StateWrapper& sw)
{
sw.Do(&s_global_tick_counter);
if (sw.IsReading() && sw.GetVersion() < 43)
{
u32 global_tick_counter32;
sw.Do(&global_tick_counter32);
s_global_tick_counter = ZeroExtend64(global_tick_counter32);
}
else
{
sw.Do(&s_global_tick_counter);
}
if (sw.IsReading())
{
@ -333,7 +343,16 @@ bool DoState(StateWrapper& sw)
event->m_interval = interval;
}
sw.Do(&s_last_event_run_time);
if (sw.GetVersion() < 43)
{
u32 last_event_run_time32;
sw.Do(&last_event_run_time32);
s_last_event_run_time = ZeroExtend64(last_event_run_time32);
}
else
{
sw.Do(&s_last_event_run_time);
}
Log_DevPrintf("Loaded %u events from save state.", event_count);
SortEvents();

View File

@ -71,7 +71,7 @@ public:
namespace TimingEvents {
u32 GetGlobalTickCounter();
u64 GetGlobalTickCounter();
void Initialize();
void Reset();