TimingEvents: Don't defer frame done callback

This commit is contained in:
Stenzek 2024-08-19 19:41:14 +10:00
parent 86d4d92753
commit 41c8607782
No known key found for this signature in database
6 changed files with 26 additions and 25 deletions

View File

@ -2019,9 +2019,7 @@ bool CPU::UpdateDebugDispatcherFlag()
void CPU::ExitExecution()
{
// can't exit while running events without messing things up
if (TimingEvents::IsRunningEvents())
TimingEvents::SetFrameDone();
else
DebugAssert(!TimingEvents::IsRunningEvents());
fastjmp_jmp(&s_jmp_buf, 1);
}

View File

@ -977,6 +977,7 @@ void GPU::CRTCTickEvent(TickCount ticks)
Timers::AddTicks(HBLANK_TIMER_INDEX, static_cast<TickCount>(hblank_timer_ticks));
}
bool frame_done = false;
while (lines_to_draw > 0)
{
const u32 lines_to_draw_this_loop =
@ -1007,7 +1008,7 @@ void GPU::CRTCTickEvent(TickCount ticks)
// TODO: move present in here I guess
FlushRender();
UpdateDisplay();
TimingEvents::SetFrameDone();
frame_done = true;
// switch fields early. this is needed so we draw to the correct one.
if (m_GPUSTAT.InInterleaved480iMode())
@ -1068,6 +1069,9 @@ void GPU::CRTCTickEvent(TickCount ticks)
}
UpdateCRTCTickEvent();
if (frame_done)
System::FrameDone();
}
void GPU::CommandTickEvent(TickCount ticks)

View File

@ -203,6 +203,9 @@ static u32 CompressAndWriteStateData(std::FILE* fp, std::span<const u8> src, Sav
u32* header_type, Error* error);
static bool DoState(StateWrapper& sw, GPUTexture** host_texture, bool update_display, bool is_memory_state);
static bool IsExecutionInterrupted();
static void ExitExecution();
static void SetRewinding(bool enabled);
static bool SaveRewindState();
static void DoRewind();
@ -559,6 +562,12 @@ bool System::IsExecutionInterrupted()
return s_state != State::Running || s_system_interrupted;
}
void System::ExitExecution()
{
TimingEvents::CancelRunningEvent();
CPU::ExitExecution();
}
bool System::IsPaused()
{
return s_state == State::Paused;
@ -2043,7 +2052,7 @@ void System::FrameDone()
if (IsExecutionInterrupted())
{
s_system_interrupted = false;
CPU::ExitExecution();
ExitExecution();
return;
}
}
@ -2154,7 +2163,7 @@ void System::FrameDone()
if (IsExecutionInterrupted())
{
s_system_interrupted = false;
CPU::ExitExecution();
ExitExecution();
return;
}
}

View File

@ -147,7 +147,6 @@ std::string GetInputProfilePath(std::string_view name);
State GetState();
void SetState(State new_state);
bool IsRunning();
bool IsExecutionInterrupted();
bool IsPaused();
bool IsShutdown();
bool IsValid();

View File

@ -32,7 +32,6 @@ struct TimingEventsState
TimingEvent* active_events_tail = nullptr;
TimingEvent* current_event = nullptr;
u32 active_event_count = 0;
bool frame_done = false;
GlobalTicks current_event_next_run_time = 0;
GlobalTicks global_tick_counter = 0;
GlobalTicks event_run_tick_counter = 0;
@ -305,20 +304,19 @@ bool TimingEvents::IsRunningEvents()
return (s_state.current_event != nullptr);
}
void TimingEvents::SetFrameDone()
{
s_state.frame_done = true;
CPU::g_state.downcount = 0;
}
void TimingEvents::CancelRunningEvent()
{
if (!s_state.current_event)
TimingEvent* const event = s_state.current_event;
if (!event)
return;
// Might need to sort it, since we're bailing out.
if (s_state.current_event->IsActive())
SortEvent(s_state.current_event);
if (event->IsActive())
{
event->m_next_run_time = s_state.current_event_next_run_time;
SortEvent(event);
}
s_state.current_event = nullptr;
}
@ -375,12 +373,6 @@ void TimingEvents::RunEvents()
CommitGlobalTicks(new_global_ticks);
}
if (s_state.frame_done)
{
s_state.frame_done = false;
System::FrameDone();
}
if (CPU::HasPendingInterrupt())
CPU::DispatchInterrupt();

View File

@ -86,7 +86,6 @@ void Shutdown();
bool DoState(StateWrapper& sw);
bool IsRunningEvents();
void SetFrameDone();
void CancelRunningEvent();
void RunEvents();
void CommitLeftoverTicks();