VideoCommon/PixelEngine: Pass Core::System to methods.

This commit is contained in:
Admiral H. Curtiss 2022-12-10 17:10:14 +01:00
parent ec8aaf1f30
commit c486baffe6
No known key found for this signature in database
GPG Key ID: F051B4C4044F33FB
4 changed files with 23 additions and 24 deletions

View File

@ -186,7 +186,7 @@ static void BPWritten(const BPCmd& bp, int cycles_into_future)
g_framebuffer_manager->RefreshPeekCache(); g_framebuffer_manager->RefreshPeekCache();
auto& system = Core::System::GetInstance(); auto& system = Core::System::GetInstance();
if (!system.GetFifo().UseDeterministicGPUThread()) if (!system.GetFifo().UseDeterministicGPUThread())
system.GetPixelEngine().SetFinish(cycles_into_future); // may generate interrupt system.GetPixelEngine().SetFinish(system, cycles_into_future); // may generate interrupt
DEBUG_LOG_FMT(VIDEO, "GXSetDrawDone SetPEFinish (value: {:#04X})", bp.newvalue & 0xFFFF); DEBUG_LOG_FMT(VIDEO, "GXSetDrawDone SetPEFinish (value: {:#04X})", bp.newvalue & 0xFFFF);
return; return;
} }
@ -205,7 +205,7 @@ static void BPWritten(const BPCmd& bp, int cycles_into_future)
auto& system = Core::System::GetInstance(); auto& system = Core::System::GetInstance();
if (!system.GetFifo().UseDeterministicGPUThread()) if (!system.GetFifo().UseDeterministicGPUThread())
{ {
system.GetPixelEngine().SetToken(static_cast<u16>(bp.newvalue & 0xFFFF), false, system.GetPixelEngine().SetToken(system, static_cast<u16>(bp.newvalue & 0xFFFF), false,
cycles_into_future); cycles_into_future);
} }
DEBUG_LOG_FMT(VIDEO, "SetPEToken {:#06X}", bp.newvalue & 0xFFFF); DEBUG_LOG_FMT(VIDEO, "SetPEToken {:#06X}", bp.newvalue & 0xFFFF);
@ -220,7 +220,7 @@ static void BPWritten(const BPCmd& bp, int cycles_into_future)
auto& system = Core::System::GetInstance(); auto& system = Core::System::GetInstance();
if (!system.GetFifo().UseDeterministicGPUThread()) if (!system.GetFifo().UseDeterministicGPUThread())
{ {
system.GetPixelEngine().SetToken(static_cast<u16>(bp.newvalue & 0xFFFF), true, system.GetPixelEngine().SetToken(system, static_cast<u16>(bp.newvalue & 0xFFFF), true,
cycles_into_future); cycles_into_future);
} }
DEBUG_LOG_FMT(VIDEO, "SetPEToken + INT {:#06X}", bp.newvalue & 0xFFFF); DEBUG_LOG_FMT(VIDEO, "SetPEToken + INT {:#06X}", bp.newvalue & 0xFFFF);
@ -764,21 +764,21 @@ void LoadBPReg(u8 reg, u32 value, int cycles_into_future)
void LoadBPRegPreprocess(u8 reg, u32 value, int cycles_into_future) void LoadBPRegPreprocess(u8 reg, u32 value, int cycles_into_future)
{ {
auto& system = Core::System::GetInstance();
// masking via BPMEM_BP_MASK could hypothetically be a problem // masking via BPMEM_BP_MASK could hypothetically be a problem
u32 newval = value & 0xffffff; u32 newval = value & 0xffffff;
switch (reg) switch (reg)
{ {
case BPMEM_SETDRAWDONE: case BPMEM_SETDRAWDONE:
if ((newval & 0xff) == 0x02) if ((newval & 0xff) == 0x02)
Core::System::GetInstance().GetPixelEngine().SetFinish(cycles_into_future); system.GetPixelEngine().SetFinish(system, cycles_into_future);
break; break;
case BPMEM_PE_TOKEN_ID: case BPMEM_PE_TOKEN_ID:
Core::System::GetInstance().GetPixelEngine().SetToken(newval & 0xffff, false, system.GetPixelEngine().SetToken(system, newval & 0xffff, false, cycles_into_future);
cycles_into_future);
break; break;
case BPMEM_PE_TOKEN_INT_ID: // Pixel Engine Interrupt Token ID case BPMEM_PE_TOKEN_INT_ID: // Pixel Engine Interrupt Token ID
Core::System::GetInstance().GetPixelEngine().SetToken(newval & 0xffff, true, system.GetPixelEngine().SetToken(system, newval & 0xffff, true, cycles_into_future);
cycles_into_future);
break; break;
} }
} }

View File

@ -50,7 +50,7 @@ void PixelEngineManager::DoState(PointerWrap& p)
p.Do(m_signal_finish_interrupt); p.Do(m_signal_finish_interrupt);
} }
void PixelEngineManager::Init() void PixelEngineManager::Init(Core::System& system)
{ {
m_control.hex = 0; m_control.hex = 0;
m_z_conf.hex = 0; m_z_conf.hex = 0;
@ -68,8 +68,8 @@ void PixelEngineManager::Init()
m_signal_token_interrupt = false; m_signal_token_interrupt = false;
m_signal_finish_interrupt = false; m_signal_finish_interrupt = false;
m_event_type_set_token_finish = Core::System::GetInstance().GetCoreTiming().RegisterEvent( m_event_type_set_token_finish =
"SetTokenFinish", SetTokenFinish_OnMainThread_Static); system.GetCoreTiming().RegisterEvent("SetTokenFinish", SetTokenFinish_OnMainThread_Static);
} }
void PixelEngineManager::RegisterMMIO(MMIO::Mapping* mmio, u32 base) void PixelEngineManager::RegisterMMIO(MMIO::Mapping* mmio, u32 base)
@ -199,7 +199,7 @@ void PixelEngineManager::SetTokenFinish_OnMainThread(Core::System& system, u64 u
// Raise the event handler above on the CPU thread. // Raise the event handler above on the CPU thread.
// m_token_finish_mutex must be locked. // m_token_finish_mutex must be locked.
// THIS IS EXECUTED FROM VIDEO THREAD // THIS IS EXECUTED FROM VIDEO THREAD
void PixelEngineManager::RaiseEvent(int cycles_into_future) void PixelEngineManager::RaiseEvent(Core::System& system, int cycles_into_future)
{ {
if (m_event_raised) if (m_event_raised)
return; return;
@ -208,7 +208,6 @@ void PixelEngineManager::RaiseEvent(int cycles_into_future)
CoreTiming::FromThread from = CoreTiming::FromThread::NON_CPU; CoreTiming::FromThread from = CoreTiming::FromThread::NON_CPU;
s64 cycles = 0; // we don't care about timings for dual core mode. s64 cycles = 0; // we don't care about timings for dual core mode.
auto& system = Core::System::GetInstance();
if (!system.IsDualCoreMode() || system.GetFifo().UseDeterministicGPUThread()) if (!system.IsDualCoreMode() || system.GetFifo().UseDeterministicGPUThread())
{ {
from = CoreTiming::FromThread::CPU; from = CoreTiming::FromThread::CPU;
@ -217,13 +216,13 @@ void PixelEngineManager::RaiseEvent(int cycles_into_future)
// games time to setup any interrupt state // games time to setup any interrupt state
cycles = std::max(500, cycles_into_future); cycles = std::max(500, cycles_into_future);
} }
Core::System::GetInstance().GetCoreTiming().ScheduleEvent(cycles, m_event_type_set_token_finish, system.GetCoreTiming().ScheduleEvent(cycles, m_event_type_set_token_finish, 0, from);
0, from);
} }
// SetToken // SetToken
// THIS IS EXECUTED FROM VIDEO THREAD // THIS IS EXECUTED FROM VIDEO THREAD
void PixelEngineManager::SetToken(const u16 token, const bool interrupt, int cycles_into_future) void PixelEngineManager::SetToken(Core::System& system, const u16 token, const bool interrupt,
int cycles_into_future)
{ {
DEBUG_LOG_FMT(PIXELENGINE, "VIDEO Backend raises INT_CAUSE_PE_TOKEN (btw, token: {:04x})", token); DEBUG_LOG_FMT(PIXELENGINE, "VIDEO Backend raises INT_CAUSE_PE_TOKEN (btw, token: {:04x})", token);
@ -232,12 +231,12 @@ void PixelEngineManager::SetToken(const u16 token, const bool interrupt, int cyc
m_token_pending = token; m_token_pending = token;
m_token_interrupt_pending |= interrupt; m_token_interrupt_pending |= interrupt;
RaiseEvent(cycles_into_future); RaiseEvent(system, cycles_into_future);
} }
// SetFinish // SetFinish
// THIS IS EXECUTED FROM VIDEO THREAD (BPStructs.cpp) when a new frame has been drawn // THIS IS EXECUTED FROM VIDEO THREAD (BPStructs.cpp) when a new frame has been drawn
void PixelEngineManager::SetFinish(int cycles_into_future) void PixelEngineManager::SetFinish(Core::System& system, int cycles_into_future)
{ {
DEBUG_LOG_FMT(PIXELENGINE, "VIDEO Set Finish"); DEBUG_LOG_FMT(PIXELENGINE, "VIDEO Set Finish");
@ -245,7 +244,7 @@ void PixelEngineManager::SetFinish(int cycles_into_future)
m_finish_interrupt_pending |= true; m_finish_interrupt_pending |= true;
RaiseEvent(cycles_into_future); RaiseEvent(system, cycles_into_future);
} }
} // namespace PixelEngine } // namespace PixelEngine

View File

@ -179,18 +179,18 @@ union UPECtrlReg
class PixelEngineManager class PixelEngineManager
{ {
public: public:
void Init(); void Init(Core::System& system);
void DoState(PointerWrap& p); void DoState(PointerWrap& p);
void RegisterMMIO(MMIO::Mapping* mmio, u32 base); void RegisterMMIO(MMIO::Mapping* mmio, u32 base);
// gfx backend support // gfx backend support
void SetToken(const u16 token, const bool interrupt, int cycle_delay); void SetToken(Core::System& system, const u16 token, const bool interrupt, int cycle_delay);
void SetFinish(int cycle_delay); void SetFinish(Core::System& system, int cycle_delay);
AlphaReadMode GetAlphaReadMode() const { return m_alpha_read.read_mode; } AlphaReadMode GetAlphaReadMode() const { return m_alpha_read.read_mode; }
private: private:
void RaiseEvent(int cycles_into_future); void RaiseEvent(Core::System& system, int cycles_into_future);
void UpdateInterrupts(); void UpdateInterrupts();
void SetTokenFinish_OnMainThread(Core::System& system, u64 userdata, s64 cycles_late); void SetTokenFinish_OnMainThread(Core::System& system, u64 userdata, s64 cycles_late);

View File

@ -325,7 +325,7 @@ void VideoBackendBase::InitializeShared()
auto& command_processor = system.GetCommandProcessor(); auto& command_processor = system.GetCommandProcessor();
command_processor.Init(system); command_processor.Init(system);
system.GetFifo().Init(system); system.GetFifo().Init(system);
system.GetPixelEngine().Init(); system.GetPixelEngine().Init(system);
BPInit(); BPInit();
VertexLoaderManager::Init(); VertexLoaderManager::Init();
VertexShaderManager::Init(); VertexShaderManager::Init();