Skip to content

Commit

Permalink
VideoCommon/PixelEngine: Refactor to class, move to Core::System.
Browse files Browse the repository at this point in the history
  • Loading branch information
AdmiralCurtiss committed Dec 11, 2022
1 parent 82e87cf commit ec8aaf1
Show file tree
Hide file tree
Showing 10 changed files with 279 additions and 232 deletions.
2 changes: 1 addition & 1 deletion Source/Core/Core/HW/Memmap.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@ void MemoryManager::InitMMIO(bool is_wii)

auto& system = Core::System::GetInstance();
system.GetCommandProcessor().RegisterMMIO(system, m_mmio_mapping.get(), 0x0C000000);
PixelEngine::RegisterMMIO(m_mmio_mapping.get(), 0x0C001000);
system.GetPixelEngine().RegisterMMIO(m_mmio_mapping.get(), 0x0C001000);
VideoInterface::RegisterMMIO(m_mmio_mapping.get(), 0x0C002000);
ProcessorInterface::RegisterMMIO(m_mmio_mapping.get(), 0x0C003000);
MemoryInterface::RegisterMMIO(m_mmio_mapping.get(), 0x0C004000);
Expand Down
7 changes: 7 additions & 0 deletions Source/Core/Core/System.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@
#include "Core/HW/VideoInterface.h"
#include "VideoCommon/CommandProcessor.h"
#include "VideoCommon/Fifo.h"
#include "VideoCommon/PixelEngine.h"

namespace Core
{
Expand All @@ -39,6 +40,7 @@ struct System::Impl
Fifo::FifoManager m_fifo;
Memory::MemoryManager m_memory;
MemoryInterface::MemoryInterfaceState m_memory_interface_state;
PixelEngine::PixelEngineManager m_pixel_engine;
SerialInterface::SerialInterfaceState m_serial_interface_state;
Sram m_sram;
VideoInterface::VideoInterfaceState m_video_interface_state;
Expand Down Expand Up @@ -137,6 +139,11 @@ MemoryInterface::MemoryInterfaceState& System::GetMemoryInterfaceState() const
return m_impl->m_memory_interface_state;
}

PixelEngine::PixelEngineManager& System::GetPixelEngine() const
{
return m_impl->m_pixel_engine;
}

SerialInterface::SerialInterfaceState& System::GetSerialInterfaceState() const
{
return m_impl->m_serial_interface_state;
Expand Down
5 changes: 5 additions & 0 deletions Source/Core/Core/System.h
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,10 @@ namespace MemoryInterface
{
class MemoryInterfaceState;
};
namespace PixelEngine
{
class PixelEngineManager;
};
namespace SerialInterface
{
class SerialInterfaceState;
Expand Down Expand Up @@ -101,6 +105,7 @@ class System
Fifo::FifoManager& GetFifo() const;
Memory::MemoryManager& GetMemory() const;
MemoryInterface::MemoryInterfaceState& GetMemoryInterfaceState() const;
PixelEngine::PixelEngineManager& GetPixelEngine() const;
SerialInterface::SerialInterfaceState& GetSerialInterfaceState() const;
Sram& GetSRAM() const;
VideoInterface::VideoInterfaceState& GetVideoInterfaceState() const;
Expand Down
4 changes: 3 additions & 1 deletion Source/Core/VideoBackends/Software/SWRenderer.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@
#include "Common/GL/GLContext.h"

#include "Core/HW/Memmap.h"
#include "Core/System.h"

#include "VideoBackends/Software/EfbCopy.h"
#include "VideoBackends/Software/EfbInterface.h"
Expand Down Expand Up @@ -136,7 +137,8 @@ u32 SWRenderer::AccessEFB(EFBAccessType type, u32 x, u32 y, u32 InputData)
value = (color >> 8) | (color & 0xff) << 24;

// check what to do with the alpha channel (GX_PokeAlphaRead)
PixelEngine::AlphaReadMode alpha_read_mode = PixelEngine::GetAlphaReadMode();
PixelEngine::AlphaReadMode alpha_read_mode =
Core::System::GetInstance().GetPixelEngine().GetAlphaReadMode();

if (alpha_read_mode == PixelEngine::AlphaReadMode::ReadNone)
{
Expand Down
20 changes: 14 additions & 6 deletions Source/Core/VideoCommon/BPStructs.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -186,7 +186,7 @@ static void BPWritten(const BPCmd& bp, int cycles_into_future)
g_framebuffer_manager->RefreshPeekCache();
auto& system = Core::System::GetInstance();
if (!system.GetFifo().UseDeterministicGPUThread())
PixelEngine::SetFinish(cycles_into_future); // may generate interrupt
system.GetPixelEngine().SetFinish(cycles_into_future); // may generate interrupt
DEBUG_LOG_FMT(VIDEO, "GXSetDrawDone SetPEFinish (value: {:#04X})", bp.newvalue & 0xFFFF);
return;
}
Expand All @@ -204,7 +204,10 @@ static void BPWritten(const BPCmd& bp, int cycles_into_future)
g_framebuffer_manager->RefreshPeekCache();
auto& system = Core::System::GetInstance();
if (!system.GetFifo().UseDeterministicGPUThread())
PixelEngine::SetToken(static_cast<u16>(bp.newvalue & 0xFFFF), false, cycles_into_future);
{
system.GetPixelEngine().SetToken(static_cast<u16>(bp.newvalue & 0xFFFF), false,
cycles_into_future);
}
DEBUG_LOG_FMT(VIDEO, "SetPEToken {:#06X}", bp.newvalue & 0xFFFF);
return;
}
Expand All @@ -216,7 +219,10 @@ static void BPWritten(const BPCmd& bp, int cycles_into_future)
g_framebuffer_manager->RefreshPeekCache();
auto& system = Core::System::GetInstance();
if (!system.GetFifo().UseDeterministicGPUThread())
PixelEngine::SetToken(static_cast<u16>(bp.newvalue & 0xFFFF), true, cycles_into_future);
{
system.GetPixelEngine().SetToken(static_cast<u16>(bp.newvalue & 0xFFFF), true,
cycles_into_future);
}
DEBUG_LOG_FMT(VIDEO, "SetPEToken + INT {:#06X}", bp.newvalue & 0xFFFF);
return;
}
Expand Down Expand Up @@ -764,13 +770,15 @@ void LoadBPRegPreprocess(u8 reg, u32 value, int cycles_into_future)
{
case BPMEM_SETDRAWDONE:
if ((newval & 0xff) == 0x02)
PixelEngine::SetFinish(cycles_into_future);
Core::System::GetInstance().GetPixelEngine().SetFinish(cycles_into_future);
break;
case BPMEM_PE_TOKEN_ID:
PixelEngine::SetToken(newval & 0xffff, false, cycles_into_future);
Core::System::GetInstance().GetPixelEngine().SetToken(newval & 0xffff, false,
cycles_into_future);
break;
case BPMEM_PE_TOKEN_INT_ID: // Pixel Engine Interrupt Token ID
PixelEngine::SetToken(newval & 0xffff, true, cycles_into_future);
Core::System::GetInstance().GetPixelEngine().SetToken(newval & 0xffff, true,
cycles_into_future);
break;
}
}
Expand Down
Loading

0 comments on commit ec8aaf1

Please sign in to comment.