TimingEvents: Remove pointer indirection

Probably should move this to one big array for locality.
This commit is contained in:
Stenzek
2024-07-19 22:56:37 +10:00
parent 56dd9878e1
commit 4f7ddfaae6
16 changed files with 210 additions and 224 deletions

View File

@ -60,12 +60,22 @@ static u32 s_active_gpu_cycles_frames = 0;
static constexpr GPUTexture::Format DISPLAY_INTERNAL_POSTFX_FORMAT = GPUTexture::Format::RGBA8;
GPU::GPU()
: m_crtc_tick_event(
"GPU CRTC Tick", 1, 1,
[](void* param, TickCount ticks, TickCount ticks_late) { static_cast<GPU*>(param)->CRTCTickEvent(ticks); }, this),
m_command_tick_event(
"GPU Command Tick", 1, 1,
[](void* param, TickCount ticks, TickCount ticks_late) { static_cast<GPU*>(param)->CommandTickEvent(ticks); },
this)
{
ResetStatistics();
}
GPU::~GPU()
{
m_command_tick_event.Deactivate();
m_crtc_tick_event.Deactivate();
JoinScreenshotThreads();
DestroyDeinterlaceTextures();
g_gpu_device->RecycleTexture(std::move(m_chroma_smoothing_texture));
@ -78,14 +88,7 @@ bool GPU::Initialize()
{
m_force_progressive_scan = g_settings.gpu_disable_interlacing;
m_force_ntsc_timings = g_settings.gpu_force_ntsc_timings;
m_crtc_tick_event = TimingEvents::CreateTimingEvent(
"GPU CRTC Tick", 1, 1,
[](void* param, TickCount ticks, TickCount ticks_late) { static_cast<GPU*>(param)->CRTCTickEvent(ticks); }, this,
true);
m_command_tick_event = TimingEvents::CreateTimingEvent(
"GPU Command Tick", 1, 1,
[](void* param, TickCount ticks, TickCount ticks_late) { static_cast<GPU*>(param)->CommandTickEvent(ticks); }, this,
true);
m_crtc_tick_event.Activate();
m_fifo_size = g_settings.gpu_fifo_size;
m_max_run_ahead = g_settings.gpu_max_run_ahead;
m_console_is_pal = System::IsPALRegion();
@ -187,8 +190,8 @@ void GPU::Reset(bool clear_vram)
m_blitter_state = BlitterState::Idle;
// Force event to reschedule itself.
m_crtc_tick_event->Deactivate();
m_command_tick_event->Deactivate();
m_crtc_tick_event.Deactivate();
m_command_tick_event.Deactivate();
SoftReset();
UpdateDisplay();
@ -455,7 +458,7 @@ u32 GPU::ReadRegister(u32 offset)
if (IsCRTCScanlinePending())
SynchronizeCRTC();
if (IsCommandCompletionPending())
m_command_tick_event->InvokeEarly();
m_command_tick_event.InvokeEarly();
return m_GPUSTAT.bits;
}
@ -547,7 +550,7 @@ void GPU::AddCommandTicks(TickCount ticks)
void GPU::SynchronizeCRTC()
{
m_crtc_tick_event->InvokeEarly();
m_crtc_tick_event.InvokeEarly();
}
float GPU::ComputeHorizontalFrequency() const
@ -833,17 +836,17 @@ void GPU::UpdateCRTCDisplayParameters()
TickCount GPU::GetPendingCRTCTicks() const
{
const TickCount pending_sysclk_ticks = m_crtc_tick_event->GetTicksSinceLastExecution();
const TickCount pending_sysclk_ticks = m_crtc_tick_event.GetTicksSinceLastExecution();
TickCount fractional_ticks = m_crtc_state.fractional_ticks;
return SystemTicksToCRTCTicks(pending_sysclk_ticks, &fractional_ticks);
}
TickCount GPU::GetPendingCommandTicks() const
{
if (!m_command_tick_event->IsActive())
if (!m_command_tick_event.IsActive())
return 0;
return SystemTicksToGPUTicks(m_command_tick_event->GetTicksSinceLastExecution());
return SystemTicksToGPUTicks(m_command_tick_event.GetTicksSinceLastExecution());
}
void GPU::UpdateCRTCTickEvent()
@ -900,7 +903,7 @@ void GPU::UpdateCRTCTickEvent()
ticks_until_event = std::min(ticks_until_event, ticks_until_hblank_start_or_end);
}
m_crtc_tick_event->Schedule(CRTCTicksToSystemTicks(ticks_until_event, m_crtc_state.fractional_ticks));
m_crtc_tick_event.Schedule(CRTCTicksToSystemTicks(ticks_until_event, m_crtc_state.fractional_ticks));
}
bool GPU::IsCRTCScanlinePending() const
@ -1080,11 +1083,11 @@ void GPU::UpdateCommandTickEvent()
if (m_pending_command_ticks <= 0)
{
m_pending_command_ticks = 0;
m_command_tick_event->Deactivate();
m_command_tick_event.Deactivate();
}
else
{
m_command_tick_event->SetIntervalAndSchedule(GPUTicksToSystemTicks(m_pending_command_ticks));
m_command_tick_event.SetIntervalAndSchedule(GPUTicksToSystemTicks(m_pending_command_ticks));
}
}
@ -1209,7 +1212,7 @@ void GPU::WriteGP1(u32 value)
case 0x00: // Reset GPU
{
DEBUG_LOG("GP1 reset GPU");
m_command_tick_event->InvokeEarly();
m_command_tick_event.InvokeEarly();
SynchronizeCRTC();
SoftReset();
}
@ -1218,7 +1221,7 @@ void GPU::WriteGP1(u32 value)
case 0x01: // Clear FIFO
{
DEBUG_LOG("GP1 clear FIFO");
m_command_tick_event->InvokeEarly();
m_command_tick_event.InvokeEarly();
SynchronizeCRTC();
// flush partial writes
@ -1232,7 +1235,7 @@ void GPU::WriteGP1(u32 value)
m_blit_buffer.clear();
m_blit_remaining_words = 0;
m_pending_command_ticks = 0;
m_command_tick_event->Deactivate();
m_command_tick_event.Deactivate();
UpdateDMARequest();
UpdateGPUIdle();
}
@ -1350,7 +1353,7 @@ void GPU::WriteGP1(u32 value)
{
// Have to be careful when setting this because Synchronize() can modify GPUSTAT.
static constexpr u32 SET_MASK = UINT32_C(0b00000000011111110100000000000000);
m_command_tick_event->InvokeEarly();
m_command_tick_event.InvokeEarly();
SynchronizeCRTC();
m_GPUSTAT.bits = (m_GPUSTAT.bits & ~SET_MASK) | (new_GPUSTAT.bits & SET_MASK);
UpdateCRTCConfig();