diff options
Diffstat (limited to 'src/GPU3D.cpp')
-rw-r--r-- | src/GPU3D.cpp | 81 |
1 files changed, 37 insertions, 44 deletions
diff --git a/src/GPU3D.cpp b/src/GPU3D.cpp index 64e67e7..53fafb3 100644 --- a/src/GPU3D.cpp +++ b/src/GPU3D.cpp @@ -147,10 +147,10 @@ typedef union } CmdFIFOEntry; -FIFO<CmdFIFOEntry>* CmdFIFO; -FIFO<CmdFIFOEntry>* CmdPIPE; +FIFO<CmdFIFOEntry, 256> CmdFIFO; +FIFO<CmdFIFOEntry, 4> CmdPIPE; -FIFO<CmdFIFOEntry>* CmdStallQueue; +FIFO<CmdFIFOEntry, 64> CmdStallQueue; u32 NumCommands, CurCommand, ParamCount, TotalParams; @@ -277,20 +277,11 @@ u32 FlushAttributes; bool Init() { - CmdFIFO = new FIFO<CmdFIFOEntry>(256); - CmdPIPE = new FIFO<CmdFIFOEntry>(4); - - CmdStallQueue = new FIFO<CmdFIFOEntry>(64); - return true; } void DeInit() { - delete CmdFIFO; - delete CmdPIPE; - - delete CmdStallQueue; } void ResetRenderingState() @@ -314,10 +305,10 @@ void ResetRenderingState() void Reset() { - CmdFIFO->Clear(); - CmdPIPE->Clear(); + CmdFIFO.Clear(); + CmdPIPE.Clear(); - CmdStallQueue->Clear(); + CmdStallQueue.Clear(); NumCommands = 0; CurCommand = 0; @@ -395,8 +386,8 @@ void DoSavestate(Savestate* file) { file->Section("GP3D"); - CmdFIFO->DoSavestate(file); - CmdPIPE->DoSavestate(file); + CmdFIFO.DoSavestate(file); + CmdPIPE.DoSavestate(file); file->Var32(&NumCommands); file->Var32(&CurCommand); @@ -593,7 +584,9 @@ void DoSavestate(Savestate* file) } } - CmdStallQueue->DoSavestate(file); + // probably not worth storing the vblank-latched Renderxxxxxx variables + CmdStallQueue.DoSavestate(file); + file->Var32((u32*)&VertexPipeline); file->Var32((u32*)&NormalPipeline); file->Var32((u32*)&PolygonPipeline); @@ -1731,24 +1724,24 @@ void VecTest(u32* params) void CmdFIFOWrite(CmdFIFOEntry& entry) { - if (CmdFIFO->IsEmpty() && !CmdPIPE->IsFull()) + if (CmdFIFO.IsEmpty() && !CmdPIPE.IsFull()) { - CmdPIPE->Write(entry); + CmdPIPE.Write(entry); } else { - if (CmdFIFO->IsFull()) + if (CmdFIFO.IsFull()) { // store it to the stall queue. stall the system. // worst case is if a STMxx opcode causes this, which is why our stall queue // has 64 entries. this is less complicated than trying to make STMxx stall-able. - CmdStallQueue->Write(entry); + CmdStallQueue.Write(entry); NDS::GXFIFOStall(); return; } - CmdFIFO->Write(entry); + CmdFIFO.Write(entry); } GXStat |= (1<<27); @@ -1767,27 +1760,27 @@ void CmdFIFOWrite(CmdFIFOEntry& entry) CmdFIFOEntry CmdFIFORead() { - CmdFIFOEntry ret = CmdPIPE->Read(); + CmdFIFOEntry ret = CmdPIPE.Read(); - if (CmdPIPE->Level() <= 2) + if (CmdPIPE.Level() <= 2) { - if (!CmdFIFO->IsEmpty()) - CmdPIPE->Write(CmdFIFO->Read()); - if (!CmdFIFO->IsEmpty()) - CmdPIPE->Write(CmdFIFO->Read()); + if (!CmdFIFO.IsEmpty()) + CmdPIPE.Write(CmdFIFO.Read()); + if (!CmdFIFO.IsEmpty()) + CmdPIPE.Write(CmdFIFO.Read()); // empty stall queue if needed // CmdFIFO should not be full at this point. - if (!CmdStallQueue->IsEmpty()) + if (!CmdStallQueue.IsEmpty()) { - while (!CmdStallQueue->IsEmpty()) + while (!CmdStallQueue.IsEmpty()) { - if (CmdFIFO->IsFull()) break; - CmdFIFOEntry entry = CmdStallQueue->Read(); + if (CmdFIFO.IsFull()) break; + CmdFIFOEntry entry = CmdStallQueue.Read(); CmdFIFOWrite(entry); } - if (CmdStallQueue->IsEmpty()) + if (CmdStallQueue.IsEmpty()) NDS::GXFIFOUnstall(); } @@ -2451,7 +2444,7 @@ void FinishWork(s32 cycles) void Run() { if (!GeometryEnabled || FlushRequest || - (CmdPIPE->IsEmpty() && !(GXStat & (1<<27)))) + (CmdPIPE.IsEmpty() && !(GXStat & (1<<27)))) { Timestamp = NDS::ARM9Timestamp >> NDS::ARM9ClockShift; return; @@ -2463,7 +2456,7 @@ void Run() if (CycleCount <= 0) { - while (CycleCount <= 0 && !CmdPIPE->IsEmpty()) + while (CycleCount <= 0 && !CmdPIPE.IsEmpty()) { if (NumPushPopCommands == 0) GXStat &= ~(1<<14); if (NumTestCommands == 0) GXStat &= ~(1<<0); @@ -2472,7 +2465,7 @@ void Run() } } - if (CycleCount <= 0 && CmdPIPE->IsEmpty()) + if (CycleCount <= 0 && CmdPIPE.IsEmpty()) { if (GXStat & (1<<27)) FinishWork(-CycleCount); else CycleCount = 0; @@ -2488,8 +2481,8 @@ void CheckFIFOIRQ() bool irq = false; switch (GXStat >> 30) { - case 1: irq = (CmdFIFO->Level() < 128); break; - case 2: irq = CmdFIFO->IsEmpty(); break; + case 1: irq = (CmdFIFO.Level() < 128); break; + case 2: irq = CmdFIFO.IsEmpty(); break; } if (irq) NDS::SetIRQ(0, NDS::IRQ_GXFIFO); @@ -2498,7 +2491,7 @@ void CheckFIFOIRQ() void CheckFIFODMA() { - if (CmdFIFO->Level() < 128) + if (CmdFIFO.Level() < 128) NDS::CheckDMAs(0, 0x07); } @@ -2705,7 +2698,7 @@ u8 Read8(u32 addr) { Run(); - u32 fifolevel = CmdFIFO->Level(); + u32 fifolevel = CmdFIFO.Level(); return fifolevel & 0xFF; } @@ -2713,7 +2706,7 @@ u8 Read8(u32 addr) { Run(); - u32 fifolevel = CmdFIFO->Level(); + u32 fifolevel = CmdFIFO.Level(); return ((GXStat >> 24) & 0xFF) | (fifolevel >> 8) | @@ -2748,7 +2741,7 @@ u16 Read16(u32 addr) { Run(); - u32 fifolevel = CmdFIFO->Level(); + u32 fifolevel = CmdFIFO.Level(); return (GXStat >> 16) | fifolevel | @@ -2784,7 +2777,7 @@ u32 Read32(u32 addr) { Run(); - u32 fifolevel = CmdFIFO->Level(); + u32 fifolevel = CmdFIFO.Level(); return GXStat | ((PosMatrixStackPointer & 0x1F) << 8) | |