diff --git a/GPU/GLES/DisplayListInterpreter.cpp b/GPU/GLES/DisplayListInterpreter.cpp index b6a0e3ec85..1ca7c42e4d 100644 --- a/GPU/GLES/DisplayListInterpreter.cpp +++ b/GPU/GLES/DisplayListInterpreter.cpp @@ -161,9 +161,7 @@ GLES_GPU::GLES_GPU(int renderWidth, int renderHeight) : interruptsEnabled_(true), displayFramebufPtr_(0), renderWidth_(renderWidth), - renderHeight_(renderHeight), - dumpThisFrame_(false), - dumpNextFrame_(false) + renderHeight_(renderHeight) { renderWidthFactor_ = (float)renderWidth / 480.0f; renderHeightFactor_ = (float)renderHeight / 272.0f; @@ -386,26 +384,6 @@ void GLES_GPU::EndDebugDraw() { // Render queue -bool GLES_GPU::ProcessDLQueue() -{ - DisplayListQueue::iterator iter = dlQueue.begin(); - while (!(iter == dlQueue.end())) - { - DisplayList &l = *iter; -// DEBUG_LOG(G3D,"Okay, starting DL execution at %08 - stall = %08x", context.pc, stallAddr); - if (!InterpretList(l)) - { - return false; - } else { - //At the end, we can remove it from the queue and continue - dlQueue.erase(iter); - //this invalidated the iterator, let's fix it - iter = dlQueue.begin(); - } - } - return true; //no more lists! -} - void GLES_GPU::DrawSync(int mode) { transformDraw_.Flush(); @@ -439,6 +417,13 @@ static void LeaveClearMode() { // dirtyshader? } +void GLES_GPU::PreExecuteOp(u32 op, u32 diff) { + u32 cmd = op >> 24; + + if (flushBeforeCommand_[cmd] == 1 || (diff && flushBeforeCommand_[cmd] == 2)) + transformDraw_.Flush(); +} + void GLES_GPU::ExecuteOp(u32 op, u32 diff) { u32 cmd = op >> 24; u32 data = op & 0xFFFFFF; @@ -1077,48 +1062,6 @@ void GLES_GPU::ExecuteOp(u32 op, u32 diff) { } } -bool GLES_GPU::InterpretList(DisplayList &list) -{ - currentList = &list; - // Reset stackptr for safety - stackptr = 0; - u32 op = 0; - prev = 0; - finished = false; - while (!finished) - { - list.status = PSP_GE_LIST_DRAWING; - if (!Memory::IsValidAddress(list.pc)) { - ERROR_LOG(G3D, "DL PC = %08x WTF!!!!", list.pc); - return true; - } - if (list.pc == list.stall) - { - list.status = PSP_GE_LIST_STALL_REACHED; - return false; - } - op = Memory::ReadUnchecked_U32(list.pc); //read from memory - u32 cmd = op >> 24; - u32 diff = op ^ gstate.cmdmem[cmd]; - if (flushBeforeCommand_[cmd] == 1 || (diff && flushBeforeCommand_[cmd] == 2)) - transformDraw_.Flush(); - // TODO: Add a compiler flag to remove stuff like this at very-final build time. - if (dumpThisFrame_) { - char temp[256]; - GeDisassembleOp(list.pc, op, prev, temp); - NOTICE_LOG(G3D, "%08x: %s", list.pc, temp); - } - - gstate.cmdmem[cmd] = op; - - ExecuteOp(op, diff); - - list.pc += 4; - prev = op; - } - return true; -} - void GLES_GPU::UpdateStats() { gpuStats.numVertexShaders = shaderManager_->NumVertexShaders(); gpuStats.numFragmentShaders = shaderManager_->NumFragmentShaders(); diff --git a/GPU/GLES/DisplayListInterpreter.h b/GPU/GLES/DisplayListInterpreter.h index 49e20eac88..70590c3c84 100644 --- a/GPU/GLES/DisplayListInterpreter.h +++ b/GPU/GLES/DisplayListInterpreter.h @@ -35,8 +35,8 @@ public: GLES_GPU(int renderWidth, int renderHeight); ~GLES_GPU(); virtual void InitClear(); + virtual void PreExecuteOp(u32 op, u32 diff); virtual void ExecuteOp(u32 op, u32 diff); - virtual bool InterpretList(DisplayList &list); virtual void DrawSync(int mode); virtual void Continue(); virtual void Break(); @@ -56,7 +56,6 @@ public: private: void DoBlockTransfer(); - bool ProcessDLQueue(); // Applies states for debugging if enabled. void BeginDebugDraw(); @@ -78,19 +77,11 @@ private: float renderWidthFactor_; float renderHeightFactor_; - bool dumpNextFrame_; - bool dumpThisFrame_; - struct CmdProcessorState { u32 pc; u32 stallAddr; }; - u32 prev; - u32 stack[2]; - u32 stackptr; - bool finished; - struct VirtualFramebuffer { u32 fb_address; u32 z_address; diff --git a/GPU/GPUCommon.cpp b/GPU/GPUCommon.cpp index 4b4f2d4826..32ebb12465 100644 --- a/GPU/GPUCommon.cpp +++ b/GPU/GPUCommon.cpp @@ -1,4 +1,9 @@ +#include "../Core/MemMap.h" +#include "GeDisasm.h" #include "GPUCommon.h" +#include "GPUState.h" + + static int dlIdGenerator = 1; @@ -46,4 +51,70 @@ void GPUCommon::UpdateStall(int listid, u32 newstall) } ProcessDLQueue(); +} + +bool GPUCommon::InterpretList(DisplayList &list) +{ + currentList = &list; + // Reset stackptr for safety + stackptr = 0; + u32 op = 0; + prev = 0; + finished = false; + while (!finished) + { + list.status = PSP_GE_LIST_DRAWING; + if (!Memory::IsValidAddress(list.pc)) { + ERROR_LOG(G3D, "DL PC = %08x WTF!!!!", list.pc); + return true; + } + if (list.pc == list.stall) + { + list.status = PSP_GE_LIST_STALL_REACHED; + return false; + } + op = Memory::ReadUnchecked_U32(list.pc); //read from memory + u32 cmd = op >> 24; + u32 diff = op ^ gstate.cmdmem[cmd]; + PreExecuteOp(op, diff); + // TODO: Add a compiler flag to remove stuff like this at very-final build time. + if (dumpThisFrame_) { + char temp[256]; + GeDisassembleOp(list.pc, op, prev, temp); + NOTICE_LOG(G3D, "%s", temp); + } + gstate.cmdmem[cmd] = op; // crashes if I try to put the whole op there?? + + ExecuteOp(op, diff); + + list.pc += 4; + prev = op; + } + return true; +} + +bool GPUCommon::ProcessDLQueue() +{ + DisplayListQueue::iterator iter = dlQueue.begin(); + while (!(iter == dlQueue.end())) + { + DisplayList &l = *iter; + DEBUG_LOG(G3D,"Okay, starting DL execution at %08x - stall = %08x", l.pc, l.stall); + if (!InterpretList(l)) + { + return false; + } + else + { + //At the end, we can remove it from the queue and continue + dlQueue.erase(iter); + //this invalidated the iterator, let's fix it + iter = dlQueue.begin(); + } + } + return true; //no more lists! +} + +void GPUCommon::PreExecuteOp(u32 op, u32 diff) { + // Nothing to do } \ No newline at end of file diff --git a/GPU/GPUCommon.h b/GPU/GPUCommon.h index 8b943dd1cf..03a31b1344 100644 --- a/GPU/GPUCommon.h +++ b/GPU/GPUCommon.h @@ -7,18 +7,31 @@ class GPUCommon : public GPUInterface public: GPUCommon() : dlIdGenerator(1), - currentList(NULL) + currentList(NULL), + stackptr(0), + dumpThisFrame_(false), + dumpNextFrame_(false) {} - - virtual bool ProcessDLQueue() = 0; + + virtual void PreExecuteOp(u32 op, u32 diff); + virtual bool InterpretList(DisplayList &list); + virtual bool ProcessDLQueue(); virtual void UpdateStall(int listid, u32 newstall); virtual u32 EnqueueList(u32 listpc, u32 stall, bool head); virtual int listStatus(int listid); protected: typedef std::deque DisplayListQueue; - + int dlIdGenerator; DisplayList *currentList; DisplayListQueue dlQueue; + + u32 prev; + u32 stack[2]; + u32 stackptr; + bool finished; + + bool dumpNextFrame_; + bool dumpThisFrame_; }; \ No newline at end of file diff --git a/GPU/GPUInterface.h b/GPU/GPUInterface.h index 1208e542c0..ac45316451 100644 --- a/GPU/GPUInterface.h +++ b/GPU/GPUInterface.h @@ -53,6 +53,7 @@ public: virtual void DrawSync(int mode) = 0; virtual void Continue() = 0; + virtual void PreExecuteOp(u32 op, u32 diff) = 0; virtual void ExecuteOp(u32 op, u32 diff) = 0; virtual bool InterpretList(DisplayList& list) = 0; virtual int listStatus(int listid) = 0; diff --git a/GPU/Null/NullGpu.cpp b/GPU/Null/NullGpu.cpp index cf96262e30..8518704b7e 100644 --- a/GPU/Null/NullGpu.cpp +++ b/GPU/Null/NullGpu.cpp @@ -22,43 +22,13 @@ #include "../../Core/MemMap.h" #include "../../Core/HLE/sceKernelInterrupt.h" -static u32 prev; -static u32 stack[2]; -static u32 stackptr = 0; -static bool finished; - - NullGPU::NullGPU() { interruptsEnabled_ = true; - dlIdGenerator = 1; } NullGPU::~NullGPU() { - dlQueue.clear(); -} - -bool NullGPU::ProcessDLQueue() -{ - DisplayListQueue::iterator iter = dlQueue.begin(); - while (!(iter == dlQueue.end())) - { - DisplayList &l = *iter; -// DEBUG_LOG(G3D,"Okay, starting DL execution at %08 - stall = %08x", context.pc, stallAddr); - if (!InterpretList(l)) - { - return false; - } - else - { - //At the end, we can remove it from the queue and continue - dlQueue.erase(iter); - //this invalidated the iterator, let's fix it - iter = dlQueue.begin(); - } - } - return true; //no more lists! } void NullGPU::DrawSync(int mode) @@ -74,7 +44,6 @@ void NullGPU::Continue() } - void NullGPU::ExecuteOp(u32 op, u32 diff) { u32 cmd = op >> 24; @@ -764,34 +733,6 @@ void NullGPU::ExecuteOp(u32 op, u32 diff) } } -bool NullGPU::InterpretList(DisplayList &list) -{ - currentList = &list; - // Reset stackptr for safety - stackptr = 0; - u32 op = 0; - prev = 0; - finished = false; - while (!finished) - { - if (currentList->pc == currentList->stall) - { - currentList->status = PSP_GE_LIST_STALL_REACHED; - return false; - } - op = Memory::ReadUnchecked_U32(currentList->pc); //read from memory - u32 cmd = op >> 24; - u32 diff = op ^ gstate.cmdmem[cmd]; - gstate.cmdmem[cmd] = op; // crashes if I try to put the whole op there?? - - ExecuteOp(op, diff); - - currentList->pc += 4; - prev = op; - } - return true; -} - void NullGPU::UpdateStats() { gpuStats.numVertexShaders = 0; diff --git a/GPU/Null/NullGpu.h b/GPU/Null/NullGpu.h index 8d3c0191f7..1dabc32e42 100644 --- a/GPU/Null/NullGpu.h +++ b/GPU/Null/NullGpu.h @@ -28,7 +28,6 @@ public: ~NullGPU(); virtual void InitClear() {} virtual void ExecuteOp(u32 op, u32 diff); - virtual bool InterpretList(DisplayList &list); virtual void Continue(); virtual void DrawSync(int mode); virtual void EnableInterrupts(bool enable) { @@ -46,6 +45,5 @@ public: virtual void DumpNextFrame() {} private: - bool ProcessDLQueue(); bool interruptsEnabled_; };