GPU: Refactor command execution/VRAM->CPU transfers

Simpler, and handles odd sizes correctly.
This commit is contained in:
Connor McLaughlin
2019-11-14 22:17:09 +10:00
parent bc9ed3572b
commit 49569d29aa
4 changed files with 166 additions and 134 deletions

View File

@ -72,6 +72,15 @@ public:
Disabled = 4 // Not a register value
};
enum class State : u8
{
Idle,
WaitingForParameters,
ExecutingCommand,
ReadingVRAM,
WritingVRAM
};
enum : u32
{
VRAM_WIDTH = 1024,
@ -285,6 +294,8 @@ protected:
u32 ReadGPUREAD();
void WriteGP0(u32 value);
void WriteGP1(u32 value);
void ExecuteCommands();
void EndCommand();
void HandleGetGPUInfoCommand(u32 value);
// Rendering in the backend
@ -467,8 +478,22 @@ protected:
bool in_vblank;
} m_crtc_state = {};
State m_state = State::Idle;
u32 m_command_total_words = 0;
struct VRAMTransfer
{
u16 x;
u16 y;
u16 width;
u16 height;
u16 col;
u16 row;
} m_vram_transfer = {};
/// GPUREAD value for non-VRAM-reads.
u32 m_GPUREAD_latch = 0;
std::vector<u32> m_GP0_buffer;
std::deque<u32> m_GPUREAD_buffer;
struct Stats
{