mirror of
https://github.com/hrydgard/ppsspp.git
synced 2025-02-03 12:12:06 +00:00
Move InterpretList and ProcessDLQueue to GPUCommon
This commit is contained in:
parent
6eec4f5d7f
commit
36a71eafd0
@ -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();
|
||||
|
@ -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;
|
||||
|
@ -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
|
||||
}
|
@ -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<DisplayList> DisplayListQueue;
|
||||
|
||||
|
||||
int dlIdGenerator;
|
||||
DisplayList *currentList;
|
||||
DisplayListQueue dlQueue;
|
||||
|
||||
u32 prev;
|
||||
u32 stack[2];
|
||||
u32 stackptr;
|
||||
bool finished;
|
||||
|
||||
bool dumpNextFrame_;
|
||||
bool dumpThisFrame_;
|
||||
};
|
@ -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;
|
||||
|
@ -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;
|
||||
|
@ -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_;
|
||||
};
|
||||
|
Loading…
x
Reference in New Issue
Block a user