From 6941d2e7e67d68312278a934e6c47abc88074077 Mon Sep 17 00:00:00 2001 From: "Admiral H. Curtiss" Date: Sun, 27 Nov 2022 13:50:50 +0100 Subject: VideoCommon/CommandProcessor: Refactor to class, move to Core::System. --- Source/Core/VideoCommon/CommandProcessor.h | 103 +++++++++++++++++++---------- 1 file changed, 68 insertions(+), 35 deletions(-) (limited to 'Source/Core/VideoCommon/CommandProcessor.h') diff --git a/Source/Core/VideoCommon/CommandProcessor.h b/Source/Core/VideoCommon/CommandProcessor.h index ca2b6fbb28..a54aa2a42e 100644 --- a/Source/Core/VideoCommon/CommandProcessor.h +++ b/Source/Core/VideoCommon/CommandProcessor.h @@ -6,48 +6,53 @@ #include #include "Common/CommonTypes.h" +#include "Common/Flag.h" class PointerWrap; namespace MMIO { class Mapping; } +namespace Core +{ +class System; +} +namespace CoreTiming +{ +struct EventType; +} namespace CommandProcessor { struct SCPFifoStruct { // fifo registers - std::atomic CPBase; - std::atomic CPEnd; + std::atomic CPBase = 0; + std::atomic CPEnd = 0; u32 CPHiWatermark = 0; u32 CPLoWatermark = 0; - std::atomic CPReadWriteDistance; - std::atomic CPWritePointer; - std::atomic CPReadPointer; - std::atomic CPBreakpoint; - std::atomic SafeCPReadPointer; + std::atomic CPReadWriteDistance = 0; + std::atomic CPWritePointer = 0; + std::atomic CPReadPointer = 0; + std::atomic CPBreakpoint = 0; + std::atomic SafeCPReadPointer = 0; - std::atomic bFF_GPLinkEnable; - std::atomic bFF_GPReadEnable; - std::atomic bFF_BPEnable; - std::atomic bFF_BPInt; - std::atomic bFF_Breakpoint; + std::atomic bFF_GPLinkEnable = 0; + std::atomic bFF_GPReadEnable = 0; + std::atomic bFF_BPEnable = 0; + std::atomic bFF_BPInt = 0; + std::atomic bFF_Breakpoint = 0; - std::atomic bFF_LoWatermarkInt; - std::atomic bFF_HiWatermarkInt; + std::atomic bFF_LoWatermarkInt = 0; + std::atomic bFF_HiWatermarkInt = 0; - std::atomic bFF_LoWatermark; - std::atomic bFF_HiWatermark; + std::atomic bFF_LoWatermark = 0; + std::atomic bFF_HiWatermark = 0; void Init(); void DoState(PointerWrap& p); }; -// This one is shared between gfx thread and emulator thread. -// It is only used by the Fifo and by the CommandProcessor. -extern SCPFifoStruct fifo; - // internal hardware addresses enum { @@ -150,26 +155,54 @@ union UCPClearReg UCPClearReg(u16 _hex) { Hex = _hex; } }; -// Init -void Init(); -void DoState(PointerWrap& p); +u32 GetPhysicalAddressMask(); -void RegisterMMIO(MMIO::Mapping* mmio, u32 base); +class CommandProcessorManager +{ +public: + void Init(Core::System& system); + void DoState(PointerWrap& p); -void SetCPStatusFromGPU(); -void SetCPStatusFromCPU(); -void GatherPipeBursted(); -void UpdateInterrupts(u64 userdata); -void UpdateInterruptsFromVideoBackend(u64 userdata); + void RegisterMMIO(Core::System& system, MMIO::Mapping* mmio, u32 base); -bool IsInterruptWaiting(); + void SetCPStatusFromGPU(Core::System& system); + void SetCPStatusFromCPU(Core::System& system); + void GatherPipeBursted(Core::System& system); + void UpdateInterrupts(Core::System& system, u64 userdata); + void UpdateInterruptsFromVideoBackend(Core::System& system, u64 userdata); -void SetCpClearRegister(); -void SetCpControlRegister(); -void SetCpStatusRegister(); + bool IsInterruptWaiting() const; -void HandleUnknownOpcode(u8 cmd_byte, const u8* buffer, bool preprocess); + void SetCpClearRegister(); + void SetCpControlRegister(); + void SetCpStatusRegister(); -u32 GetPhysicalAddressMask(); + void HandleUnknownOpcode(u8 cmd_byte, const u8* buffer, bool preprocess); + + // This one is shared between gfx thread and emulator thread. + // It is only used by the Fifo and by the CommandProcessor. + SCPFifoStruct& GetFifo() { return m_fifo; } + +private: + SCPFifoStruct m_fifo; + + CoreTiming::EventType* m_event_type_update_interrupts = nullptr; + + // STATE_TO_SAVE + UCPStatusReg m_cp_status_reg; + UCPCtrlReg m_cp_ctrl_reg; + UCPClearReg m_cp_clear_reg; + + u16 m_bbox_left = 0; + u16 m_bbox_top = 0; + u16 m_bbox_right = 0; + u16 m_bbox_bottom = 0; + u16 m_token_reg = 0; + + Common::Flag m_interrupt_set; + Common::Flag m_interrupt_waiting; + + bool m_is_fifo_error_seen = false; +}; } // namespace CommandProcessor -- cgit v1.2.3