mirror of
https://github.com/hrydgard/ppsspp.git
synced 2026-11-16 19:13:40 +01:00
Merge pull request #1182 from unknownbrackets/dlist-parts
More of Orphis' dlist rewrite (signal handling)
This commit is contained in:
commit
3ed41388b7
5 files changed
+224
-108
No files matched your search
+32
-11
@@ -19,6 +19,7 @@
|
||||
#include "../MIPS/MIPS.h"
|
||||
#include "../System.h"
|
||||
#include "../CoreParameter.h"
|
||||
#include "../Reporting.h"
|
||||
#include "sceGe.h"
|
||||
#include "sceKernelMemory.h"
|
||||
#include "sceKernelThread.h"
|
||||
@@ -33,8 +34,6 @@ struct GeInterruptData
|
||||
{
|
||||
int listid;
|
||||
u32 pc;
|
||||
u32 subIntrBase;
|
||||
u16 subIntrToken;
|
||||
};
|
||||
|
||||
static std::list<GeInterruptData> ge_pending_cb;
|
||||
@@ -52,21 +51,20 @@ public:
|
||||
if (dl == NULL)
|
||||
{
|
||||
WARN_LOG(HLE, "Unable to run GE interrupt: list doesn't exist: %d", intrdata.listid);
|
||||
// TODO: Use dl instead of just saving everything instead?
|
||||
//return false;
|
||||
return false;
|
||||
}
|
||||
|
||||
gpu->InterruptStart();
|
||||
|
||||
u32 cmd = Memory::ReadUnchecked_U32(intrdata.pc - 4) >> 24;
|
||||
int subintr = intrdata.subIntrBase | (cmd == GE_CMD_FINISH ? PSP_GE_SUBINTR_FINISH : PSP_GE_SUBINTR_SIGNAL);
|
||||
int subintr = dl->subIntrBase | (cmd == GE_CMD_FINISH ? PSP_GE_SUBINTR_FINISH : PSP_GE_SUBINTR_SIGNAL);
|
||||
SubIntrHandler* handler = get(subintr);
|
||||
|
||||
if(handler != NULL)
|
||||
{
|
||||
DEBUG_LOG(CPU, "Entering interrupt handler %08x", handler->handlerAddress);
|
||||
currentMIPS->pc = handler->handlerAddress;
|
||||
u32 data = intrdata.subIntrToken;
|
||||
u32 data = dl->subIntrToken;
|
||||
currentMIPS->r[MIPS_REG_A0] = data & 0xFFFF;
|
||||
currentMIPS->r[MIPS_REG_A1] = handler->handlerArg;
|
||||
currentMIPS->r[MIPS_REG_A2] = sceKernelGetCompiledSdkVersion() <= 0x02000010 ? 0 : intrdata.pc + 4;
|
||||
@@ -87,6 +85,30 @@ public:
|
||||
GeInterruptData intrdata = ge_pending_cb.front();
|
||||
ge_pending_cb.pop_front();
|
||||
|
||||
DisplayList* dl = gpu->getList(intrdata.listid);
|
||||
|
||||
switch (dl->signal)
|
||||
{
|
||||
case PSP_GE_SIGNAL_HANDLER_SUSPEND:
|
||||
if (sceKernelGetCompiledSdkVersion() <= 0x02000010)
|
||||
{
|
||||
// uofw says dl->state = endCmd & 0xFF;
|
||||
DisplayListState newState = static_cast<DisplayListState>(Memory::ReadUnchecked_U32(intrdata.pc - 4) & 0xFF);
|
||||
//dl->status = static_cast<DisplayListStatus>(Memory::ReadUnchecked_U32(intrdata.pc) & 0xFF);
|
||||
//if(dl->status < 0 || dl->status > PSP_GE_LIST_PAUSED)
|
||||
// ERROR_LOG(HLE, "Weird DL status after signal suspend %x", dl->status);
|
||||
if (newState != PSP_GE_DL_STATE_RUNNING)
|
||||
WARN_LOG_REPORT(HLE, "GE Interrupt: newState might be %d", newState);
|
||||
|
||||
dl->state = PSP_GE_DL_STATE_RUNNING;
|
||||
}
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
|
||||
dl->signal = PSP_GE_SIGNAL_NONE;
|
||||
|
||||
gpu->InterruptEnd();
|
||||
}
|
||||
};
|
||||
@@ -112,18 +134,17 @@ void __GeShutdown()
|
||||
|
||||
}
|
||||
|
||||
void __GeTriggerInterrupt(int listid, u32 pc, int subIntrBase, u16 subIntrToken)
|
||||
void __GeTriggerInterrupt(int listid, u32 pc)
|
||||
{
|
||||
// ClaDun X2 does not expect sceGeListEnqueue to reschedule (which it does not on the PSP.)
|
||||
// Once PPSSPP's GPU is multithreaded, we can remove this check.
|
||||
if (subIntrBase < 0)
|
||||
// Once PPSSPP's GPU uses cycles, we can remove this check.
|
||||
DisplayList* dl = gpu->getList(listid);
|
||||
if (dl != NULL && dl->subIntrBase < 0)
|
||||
return;
|
||||
|
||||
GeInterruptData intrdata;
|
||||
intrdata.listid = listid;
|
||||
intrdata.pc = pc;
|
||||
intrdata.subIntrBase = subIntrBase;
|
||||
intrdata.subIntrToken = subIntrToken;
|
||||
ge_pending_cb.push_back(intrdata);
|
||||
__TriggerInterrupt(PSP_INTR_HLE, PSP_GE_INTR, PSP_INTR_SUB_NONE);
|
||||
}
|
||||
|
||||
+1
-1
@@ -39,7 +39,7 @@ void Register_sceGe_user();
|
||||
void __GeInit();
|
||||
void __GeDoState(PointerWrap &p);
|
||||
void __GeShutdown();
|
||||
void __GeTriggerInterrupt(int listid, u32 pc, int subIntrBase, u16 subIntrToken);
|
||||
void __GeTriggerInterrupt(int listid, u32 pc);
|
||||
bool __GeHasPendingInterrupt();
|
||||
|
||||
|
||||
|
||||
+167
-71
@@ -7,21 +7,46 @@
|
||||
#include "Core/CoreTiming.h"
|
||||
#include "Core/MemMap.h"
|
||||
#include "Core/Host.h"
|
||||
#include "Core/Reporting.h"
|
||||
#include "Core/HLE/sceKernelInterrupt.h"
|
||||
#include "Core/HLE/sceKernelMemory.h"
|
||||
#include "Core/HLE/sceKernelThread.h"
|
||||
#include "Core/HLE/sceGe.h"
|
||||
|
||||
static int dlIdGenerator = 1;
|
||||
GPUCommon::GPUCommon() :
|
||||
currentList(NULL),
|
||||
isbreak(false),
|
||||
dumpNextFrame_(false),
|
||||
dumpThisFrame_(false),
|
||||
interruptsEnabled_(true)
|
||||
{
|
||||
for (int i = 0; i < DisplayListMaxCount; ++i)
|
||||
dls[i].state = PSP_GE_DL_STATE_NONE;
|
||||
}
|
||||
|
||||
void init() {
|
||||
dlIdGenerator = 1;
|
||||
void GPUCommon::PopDLQueue() {
|
||||
if(!dlQueue.empty()) {
|
||||
dlQueue.pop_front();
|
||||
if(!dlQueue.empty()) {
|
||||
bool running = currentList->state == PSP_GE_DL_STATE_RUNNING;
|
||||
currentList = &dls[dlQueue.front()];
|
||||
if (running)
|
||||
currentList->state = PSP_GE_DL_STATE_RUNNING;
|
||||
} else {
|
||||
currentList = NULL;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
u32 GPUCommon::DrawSync(int mode) {
|
||||
if (mode < 0 || mode > 1)
|
||||
return SCE_KERNEL_ERROR_INVALID_MODE;
|
||||
|
||||
while (currentList != NULL && currentList->state == PSP_GE_DL_STATE_COMPLETED)
|
||||
PopDLQueue();
|
||||
|
||||
CheckDrawSync();
|
||||
|
||||
if (mode == 0) {
|
||||
// TODO: Wait.
|
||||
return 0;
|
||||
@@ -36,30 +61,33 @@ u32 GPUCommon::DrawSync(int mode) {
|
||||
return PSP_GE_LIST_DRAWING;
|
||||
}
|
||||
|
||||
void GPUCommon::CheckDrawSync()
|
||||
{
|
||||
if (dlQueue.empty()) {
|
||||
for (int i = 0; i < DisplayListMaxCount; ++i)
|
||||
dls[i].state = PSP_GE_DL_STATE_NONE;
|
||||
}
|
||||
}
|
||||
|
||||
int GPUCommon::ListSync(int listid, int mode)
|
||||
{
|
||||
if (listid < 0 || listid >= DisplayListMaxCount)
|
||||
return SCE_KERNEL_ERROR_INVALID_ID;
|
||||
|
||||
if (mode < 0 || mode > 1)
|
||||
return SCE_KERNEL_ERROR_INVALID_MODE;
|
||||
|
||||
if (mode == 1) {
|
||||
DisplayList *dl = NULL;
|
||||
for (DisplayListQueue::iterator it(dlQueue.begin()); it != dlQueue.end(); ++it) {
|
||||
if (it->id == listid) {
|
||||
dl = &*it;
|
||||
}
|
||||
}
|
||||
DisplayList& dl = dls[listid];
|
||||
|
||||
if (!dl)
|
||||
return SCE_KERNEL_ERROR_INVALID_ID;
|
||||
|
||||
switch (dl->state) {
|
||||
switch (dl.state) {
|
||||
case PSP_GE_DL_STATE_QUEUED:
|
||||
if (dl->interrupted)
|
||||
if (dl.interrupted)
|
||||
return PSP_GE_LIST_PAUSED;
|
||||
return PSP_GE_LIST_QUEUED;
|
||||
|
||||
case PSP_GE_DL_STATE_RUNNING:
|
||||
if (dl->pc == dl->stall)
|
||||
if (dl.pc == dl.stall)
|
||||
return PSP_GE_LIST_STALLING;
|
||||
return PSP_GE_LIST_DRAWING;
|
||||
|
||||
@@ -87,8 +115,49 @@ u32 GPUCommon::EnqueueList(u32 listpc, u32 stall, int subIntrBase, bool head)
|
||||
if (((listpc | stall) & 3) != 0)
|
||||
return 0x80000103;
|
||||
|
||||
DisplayList dl;
|
||||
dl.id = dlIdGenerator++;
|
||||
int id = -1;
|
||||
bool oldCompatibility = true;
|
||||
if (sceKernelGetCompiledSdkVersion() > 0x01FFFFFF) {
|
||||
//numStacks = 0;
|
||||
//stack = NULL;
|
||||
oldCompatibility = false;
|
||||
}
|
||||
|
||||
for (int i = 0; i < DisplayListMaxCount; ++i)
|
||||
{
|
||||
if (dls[i].state != PSP_GE_DL_STATE_NONE && dls[i].state != PSP_GE_DL_STATE_COMPLETED) {
|
||||
if (dls[i].pc == listpc && !oldCompatibility) {
|
||||
ERROR_LOG(G3D, "sceGeListEnqueue: can't enqueue, list address %08X already used", listpc);
|
||||
return 0x80000021;
|
||||
}
|
||||
//if(dls[i].stack == stack) {
|
||||
// ERROR_LOG(G3D, "sceGeListEnqueue: can't enqueue, list stack %08X already used", context);
|
||||
// return 0x80000021;
|
||||
//}
|
||||
}
|
||||
if (dls[i].state == PSP_GE_DL_STATE_NONE)
|
||||
{
|
||||
// Prefer a list that isn't used
|
||||
id = i;
|
||||
break;
|
||||
}
|
||||
if (id < 0 && dls[i].state == PSP_GE_DL_STATE_COMPLETED)
|
||||
{
|
||||
id = i;
|
||||
}
|
||||
}
|
||||
if (id < 0)
|
||||
{
|
||||
ERROR_LOG_REPORT(G3D, "No DL ID available to enqueue");
|
||||
for(auto it = dlQueue.begin(); it != dlQueue.end(); ++it) {
|
||||
DisplayList &dl = dls[*it];
|
||||
DEBUG_LOG(G3D, "DisplayList %d status %d pc %08x stall %08x", *it, dl.state, dl.pc, dl.stall);
|
||||
}
|
||||
return SCE_KERNEL_ERROR_OUT_OF_MEMORY;
|
||||
}
|
||||
|
||||
DisplayList &dl = dls[id];
|
||||
dl.id = id;
|
||||
dl.startpc = listpc & 0xFFFFFFF;
|
||||
dl.pc = listpc & 0xFFFFFFF;
|
||||
dl.stall = stall & 0xFFFFFFF;
|
||||
@@ -97,6 +166,7 @@ u32 GPUCommon::EnqueueList(u32 listpc, u32 stall, int subIntrBase, bool head)
|
||||
dl.stackptr = 0;
|
||||
dl.signal = PSP_GE_SIGNAL_NONE;
|
||||
dl.interrupted = false;
|
||||
|
||||
if (head) {
|
||||
if (currentList) {
|
||||
if (currentList->state != PSP_GE_DL_STATE_PAUSED)
|
||||
@@ -105,39 +175,52 @@ u32 GPUCommon::EnqueueList(u32 listpc, u32 stall, int subIntrBase, bool head)
|
||||
}
|
||||
|
||||
dl.state = PSP_GE_DL_STATE_PAUSED;
|
||||
dlQueue.push_front(dl);
|
||||
currentList = &dlQueue.front();
|
||||
|
||||
currentList = &dl;
|
||||
dlQueue.push_front(id);
|
||||
} else if (currentList) {
|
||||
dl.state = PSP_GE_DL_STATE_QUEUED;
|
||||
dlQueue.push_back(dl);
|
||||
dlQueue.push_back(id);
|
||||
} else {
|
||||
dl.state = PSP_GE_DL_STATE_RUNNING;
|
||||
dlQueue.push_back(dl);
|
||||
currentList = &dlQueue.front();
|
||||
currentList = &dl;
|
||||
dlQueue.push_front(id);
|
||||
|
||||
// TODO save context when starting the list if param is set
|
||||
ProcessDLQueue();
|
||||
}
|
||||
|
||||
return dl.id;
|
||||
return id;
|
||||
}
|
||||
|
||||
u32 GPUCommon::DequeueList(int listid)
|
||||
{
|
||||
// TODO
|
||||
if (listid < 0 || listid >= DisplayListMaxCount || dls[listid].state == PSP_GE_DL_STATE_NONE)
|
||||
return SCE_KERNEL_ERROR_INVALID_ID;
|
||||
|
||||
if (dls[listid].state == PSP_GE_DL_STATE_RUNNING || dls[listid].state == PSP_GE_DL_STATE_PAUSED)
|
||||
return 0x80000021;
|
||||
|
||||
dls[listid].state = PSP_GE_DL_STATE_NONE;
|
||||
|
||||
if (listid == dlQueue.front())
|
||||
PopDLQueue();
|
||||
else
|
||||
dlQueue.remove(listid);
|
||||
|
||||
// TODO: Release any list wait.
|
||||
|
||||
CheckDrawSync();
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
u32 GPUCommon::UpdateStall(int listid, u32 newstall)
|
||||
{
|
||||
for (auto iter = dlQueue.begin(); iter != dlQueue.end(); ++iter)
|
||||
{
|
||||
DisplayList &cur = *iter;
|
||||
if (cur.id == listid)
|
||||
{
|
||||
cur.stall = newstall & 0xFFFFFFF;
|
||||
}
|
||||
}
|
||||
if (listid < 0 || listid >= DisplayListMaxCount || dls[listid].state == PSP_GE_DL_STATE_NONE)
|
||||
return SCE_KERNEL_ERROR_INVALID_ID;
|
||||
|
||||
dls[listid].stall = newstall & 0xFFFFFFF;
|
||||
|
||||
ProcessDLQueue();
|
||||
|
||||
@@ -190,10 +273,17 @@ u32 GPUCommon::Break(int mode)
|
||||
if (!currentList)
|
||||
return 0x80000020;
|
||||
|
||||
if(mode == 1)
|
||||
if (mode == 1)
|
||||
{
|
||||
currentList = NULL;
|
||||
// Clear the queue
|
||||
dlQueue.clear();
|
||||
for (int i = 0; i < DisplayListMaxCount; ++i)
|
||||
{
|
||||
dls[i].state = PSP_GE_DL_STATE_NONE;
|
||||
dls[i].signal = PSP_GE_SIGNAL_NONE;
|
||||
}
|
||||
|
||||
currentList = NULL;
|
||||
return 0;
|
||||
}
|
||||
|
||||
@@ -210,7 +300,7 @@ u32 GPUCommon::Break(int mode)
|
||||
{
|
||||
if (currentList->signal == PSP_GE_SIGNAL_HANDLER_PAUSE)
|
||||
{
|
||||
ERROR_LOG(G3D, "sceGeBreak: can't break signal-pausing list");
|
||||
ERROR_LOG_REPORT(G3D, "sceGeBreak: can't break signal-pausing list");
|
||||
}
|
||||
else
|
||||
return 0x80000020;
|
||||
@@ -246,31 +336,34 @@ bool GPUCommon::InterpretList(DisplayList &list)
|
||||
currentList = &list;
|
||||
u32 op = 0;
|
||||
prev = 0;
|
||||
finished = false;
|
||||
gpuState = GPUSTATE_RUNNING;
|
||||
|
||||
// I don't know if this is the correct place to zero this, but something
|
||||
// need to do it. See Sol Trigger title screen.
|
||||
gstate_c.offsetAddr = 0;
|
||||
|
||||
if (!Memory::IsValidAddress(list.pc)) {
|
||||
ERROR_LOG(G3D, "DL PC = %08x WTF!!!!", list.pc);
|
||||
ERROR_LOG_REPORT(G3D, "DL PC = %08x WTF!!!!", list.pc);
|
||||
return true;
|
||||
}
|
||||
#if defined(USING_QT_UI)
|
||||
if(host->GpuStep())
|
||||
{
|
||||
host->SendGPUStart();
|
||||
}
|
||||
if(host->GpuStep())
|
||||
{
|
||||
host->SendGPUStart();
|
||||
}
|
||||
#endif
|
||||
|
||||
cycleLastPC = list.pc;
|
||||
list.state = PSP_GE_DL_STATE_RUNNING;
|
||||
list.interrupted = false;
|
||||
|
||||
while (!finished)
|
||||
while (gpuState == GPUSTATE_RUNNING)
|
||||
{
|
||||
if (list.pc == list.stall)
|
||||
return false;
|
||||
{
|
||||
gpuState = GPUSTATE_STALL;
|
||||
break;
|
||||
}
|
||||
|
||||
op = Memory::ReadUnchecked_U32(list.pc); //read from memory
|
||||
u32 cmd = op >> 24;
|
||||
@@ -289,7 +382,7 @@ bool GPUCommon::InterpretList(DisplayList &list)
|
||||
GeDisassembleOp(list.pc, op, prev, temp);
|
||||
NOTICE_LOG(HLE, "%s", temp);
|
||||
}
|
||||
gstate.cmdmem[cmd] = op; // crashes if I try to put the whole op there??
|
||||
gstate.cmdmem[cmd] = op;
|
||||
|
||||
ExecuteOp(op, diff);
|
||||
|
||||
@@ -301,7 +394,7 @@ bool GPUCommon::InterpretList(DisplayList &list)
|
||||
|
||||
time_update();
|
||||
gpuStats.msProcessingDisplayLists += time_now_d() - start;
|
||||
return true;
|
||||
return gpuState == GPUSTATE_DONE || gpuState == GPUSTATE_ERROR;
|
||||
}
|
||||
|
||||
inline void GPUCommon::UpdateCycles(u32 pc, u32 newPC)
|
||||
@@ -318,7 +411,7 @@ bool GPUCommon::ProcessDLQueue()
|
||||
DisplayListQueue::iterator iter = dlQueue.begin();
|
||||
while (iter != dlQueue.end())
|
||||
{
|
||||
DisplayList &l = *iter;
|
||||
DisplayList &l = dls[*iter];
|
||||
DEBUG_LOG(G3D,"Okay, starting DL execution at %08x - stall = %08x", l.pc, l.stall);
|
||||
if (!InterpretList(l))
|
||||
{
|
||||
@@ -365,7 +458,7 @@ void GPUCommon::ExecuteOp(u32 op, u32 diff) {
|
||||
UpdateCycles(currentList->pc, target - 4);
|
||||
currentList->pc = target - 4; // pc will be increased after we return, counteract that
|
||||
} else {
|
||||
ERROR_LOG(G3D, "JUMP to illegal address %08x - ignoring! data=%06x", target, data);
|
||||
ERROR_LOG_REPORT(G3D, "JUMP to illegal address %08x - ignoring! data=%06x", target, data);
|
||||
}
|
||||
}
|
||||
break;
|
||||
@@ -376,9 +469,9 @@ void GPUCommon::ExecuteOp(u32 op, u32 diff) {
|
||||
u32 retval = currentList->pc + 4;
|
||||
u32 target = gstate_c.getRelativeAddress(data);
|
||||
if (currentList->stackptr == ARRAY_SIZE(currentList->stack)) {
|
||||
ERROR_LOG(G3D, "CALL: Stack full!");
|
||||
ERROR_LOG_REPORT(G3D, "CALL: Stack full!");
|
||||
} else if (!Memory::IsValidAddress(target)) {
|
||||
ERROR_LOG(G3D, "CALL to illegal address %08x - ignoring! data=%06x", target, data);
|
||||
ERROR_LOG_REPORT(G3D, "CALL to illegal address %08x - ignoring! data=%06x", target, data);
|
||||
} else {
|
||||
currentList->stack[currentList->stackptr++] = retval;
|
||||
UpdateCycles(currentList->pc, target - 4);
|
||||
@@ -390,15 +483,15 @@ void GPUCommon::ExecuteOp(u32 op, u32 diff) {
|
||||
case GE_CMD_RET:
|
||||
{
|
||||
if (currentList->stackptr == 0) {
|
||||
ERROR_LOG(G3D, "RET: Stack empty!");
|
||||
ERROR_LOG_REPORT(G3D, "RET: Stack empty!");
|
||||
} else {
|
||||
u32 target = (currentList->pc & 0xF0000000) | (currentList->stack[--currentList->stackptr] & 0x0FFFFFFF);
|
||||
//target = (target + gstate_c.originAddr) & 0xFFFFFFF;
|
||||
UpdateCycles(currentList->pc, target - 4);
|
||||
currentList->pc = target - 4;
|
||||
if (!Memory::IsValidAddress(currentList->pc)) {
|
||||
ERROR_LOG(G3D, "Invalid DL PC %08x on return", currentList->pc);
|
||||
finished = true;
|
||||
ERROR_LOG_REPORT(G3D, "Invalid DL PC %08x on return", currentList->pc);
|
||||
gpuState = GPUSTATE_ERROR;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -422,6 +515,8 @@ void GPUCommon::ExecuteOp(u32 op, u32 diff) {
|
||||
|
||||
switch (behaviour) {
|
||||
case PSP_GE_SIGNAL_HANDLER_SUSPEND:
|
||||
if (sceKernelGetCompiledSdkVersion() <= 0x02000010)
|
||||
currentList->state = PSP_GE_DL_STATE_PAUSED;
|
||||
currentList->signal = behaviour;
|
||||
ERROR_LOG(G3D, "Signal with Wait UNIMPLEMENTED! signal/end: %04x %04x", signal, enddata);
|
||||
break;
|
||||
@@ -436,28 +531,30 @@ void GPUCommon::ExecuteOp(u32 op, u32 diff) {
|
||||
ERROR_LOG(G3D, "Signal with Sync UNIMPLEMENTED! signal/end: %04x %04x", signal, enddata);
|
||||
break;
|
||||
case PSP_GE_SIGNAL_JUMP:
|
||||
ERROR_LOG(G3D, "Signal with Jump UNIMPLEMENTED! signal/end: %04x %04x", signal, enddata);
|
||||
ERROR_LOG_REPORT(G3D, "Signal with Jump UNIMPLEMENTED! signal/end: %04x %04x", signal, enddata);
|
||||
break;
|
||||
case PSP_GE_SIGNAL_CALL:
|
||||
ERROR_LOG(G3D, "Signal with Call UNIMPLEMENTED! signal/end: %04x %04x", signal, enddata);
|
||||
ERROR_LOG_REPORT(G3D, "Signal with Call UNIMPLEMENTED! signal/end: %04x %04x", signal, enddata);
|
||||
break;
|
||||
case PSP_GE_SIGNAL_RET:
|
||||
ERROR_LOG(G3D, "Signal with Return UNIMPLEMENTED! signal/end: %04x %04x", signal, enddata);
|
||||
ERROR_LOG_REPORT(G3D, "Signal with Return UNIMPLEMENTED! signal/end: %04x %04x", signal, enddata);
|
||||
break;
|
||||
default:
|
||||
ERROR_LOG(G3D, "UNKNOWN Signal UNIMPLEMENTED %i ! signal/end: %04x %04x", behaviour, signal, enddata);
|
||||
ERROR_LOG_REPORT(G3D, "UNKNOWN Signal UNIMPLEMENTED %i ! signal/end: %04x %04x", behaviour, signal, enddata);
|
||||
break;
|
||||
}
|
||||
if (currentList->subIntrBase >= 0 && interruptsEnabled_)
|
||||
__GeTriggerInterrupt(currentList->id, currentList->pc, currentList->subIntrBase, currentList->subIntrToken);
|
||||
if (interruptsEnabled_) {
|
||||
gpuState = GPUSTATE_INTERRUPT;
|
||||
__GeTriggerInterrupt(currentList->id, currentList->pc);
|
||||
}
|
||||
}
|
||||
break;
|
||||
case GE_CMD_FINISH:
|
||||
currentList->state = PSP_GE_DL_STATE_COMPLETED;
|
||||
finished = true;
|
||||
gpuState = GPUSTATE_DONE;
|
||||
currentList->subIntrToken = prev & 0xFFFF;
|
||||
if (interruptsEnabled_)
|
||||
__GeTriggerInterrupt(currentList->id, currentList->pc, currentList->subIntrBase, currentList->subIntrToken);
|
||||
__GeTriggerInterrupt(currentList->id, currentList->pc);
|
||||
break;
|
||||
default:
|
||||
DEBUG_LOG(G3D,"Ah, not finished: %06x", prev & 0xFFFFFF);
|
||||
@@ -472,23 +569,22 @@ void GPUCommon::ExecuteOp(u32 op, u32 diff) {
|
||||
}
|
||||
|
||||
void GPUCommon::DoState(PointerWrap &p) {
|
||||
p.Do(dlIdGenerator);
|
||||
p.Do<DisplayList>(dlQueue);
|
||||
int currentID = currentList == NULL ? 0 : currentList->id;
|
||||
p.Do<int>(dlQueue);
|
||||
p.DoArray(dls, ARRAY_SIZE(dls));
|
||||
int currentID = 0;
|
||||
if (currentList != NULL) {
|
||||
ptrdiff_t off = currentList - &dls[0];
|
||||
currentID = off / sizeof(DisplayList);
|
||||
}
|
||||
p.Do(currentID);
|
||||
if (currentID == 0) {
|
||||
currentList = 0;
|
||||
currentList = NULL;
|
||||
} else {
|
||||
for (auto it = dlQueue.begin(), end = dlQueue.end(); it != end; ++it) {
|
||||
if (it->id == currentID) {
|
||||
currentList = &*it;
|
||||
break;
|
||||
}
|
||||
}
|
||||
currentList = &dls[currentID];
|
||||
}
|
||||
p.Do(interruptRunning);
|
||||
p.Do(prev);
|
||||
p.Do(finished);
|
||||
p.Do(gpuState);
|
||||
p.Do(isbreak);
|
||||
p.DoMarker("GPUCommon");
|
||||
}
|
||||
|
||||
+9
-20
@@ -5,14 +5,8 @@
|
||||
class GPUCommon : public GPUInterface
|
||||
{
|
||||
public:
|
||||
GPUCommon() :
|
||||
dlIdGenerator(1),
|
||||
currentList(NULL),
|
||||
isbreak(false),
|
||||
dumpNextFrame_(false),
|
||||
dumpThisFrame_(false),
|
||||
interruptsEnabled_(true)
|
||||
{}
|
||||
GPUCommon();
|
||||
virtual ~GPUCommon() {}
|
||||
|
||||
virtual void InterruptStart();
|
||||
virtual void InterruptEnd();
|
||||
@@ -36,16 +30,18 @@ public:
|
||||
|
||||
protected:
|
||||
void UpdateCycles(u32 pc, u32 newPC = 0);
|
||||
void PopDLQueue();
|
||||
void CheckDrawSync();
|
||||
|
||||
typedef std::deque<DisplayList> DisplayListQueue;
|
||||
typedef std::list<int> DisplayListQueue;
|
||||
|
||||
int dlIdGenerator;
|
||||
DisplayList dls[DisplayListMaxCount];
|
||||
DisplayList *currentList;
|
||||
DisplayListQueue dlQueue;
|
||||
|
||||
bool interruptRunning;
|
||||
u32 prev;
|
||||
bool finished;
|
||||
GPUState gpuState;
|
||||
bool isbreak;
|
||||
|
||||
u64 startingTicks;
|
||||
@@ -59,17 +55,10 @@ protected:
|
||||
public:
|
||||
virtual DisplayList* getList(int listid)
|
||||
{
|
||||
if (currentList && currentList->id == listid)
|
||||
return currentList;
|
||||
for(auto it = dlQueue.begin(); it != dlQueue.end(); ++it)
|
||||
{
|
||||
if(it->id == listid)
|
||||
return &*it;
|
||||
}
|
||||
return NULL;
|
||||
return &dls[listid];
|
||||
}
|
||||
|
||||
const std::deque<DisplayList>& GetDisplayLists()
|
||||
const std::list<int>& GetDisplayLists()
|
||||
{
|
||||
return dlQueue;
|
||||
}
|
||||
|
||||
+15
-5
@@ -19,7 +19,7 @@
|
||||
|
||||
#include "../Globals.h"
|
||||
#include "GPUState.h"
|
||||
#include <deque>
|
||||
#include <list>
|
||||
|
||||
class PointerWrap;
|
||||
|
||||
@@ -88,6 +88,14 @@ enum SignalBehavior
|
||||
PSP_GE_SIGNAL_BREAK2 = 0xFF,
|
||||
};
|
||||
|
||||
enum GPUState
|
||||
{
|
||||
GPUSTATE_RUNNING = 0,
|
||||
GPUSTATE_DONE = 1,
|
||||
GPUSTATE_STALL = 2,
|
||||
GPUSTATE_INTERRUPT = 3,
|
||||
GPUSTATE_ERROR = 4,
|
||||
};
|
||||
|
||||
// Used for debug
|
||||
struct FramebufferInfo
|
||||
@@ -120,16 +128,19 @@ class GPUInterface
|
||||
public:
|
||||
virtual ~GPUInterface() {}
|
||||
|
||||
static const int DisplayListMaxCount = 64;
|
||||
|
||||
// Initialization
|
||||
virtual void InitClear() = 0;
|
||||
|
||||
// Draw queue management
|
||||
virtual DisplayList* getList(int listid) = 0;
|
||||
// TODO: Much of this should probably be shared between the different GPU implementations.
|
||||
virtual u32 EnqueueList(u32 listpc, u32 stall, int subIntrBase, bool head) = 0;
|
||||
virtual u32 UpdateStall(int listid, u32 newstall) = 0;
|
||||
virtual u32 EnqueueList(u32 listpc, u32 stall, int subIntrBase, bool head) = 0;
|
||||
virtual u32 DequeueList(int listid) = 0;
|
||||
virtual u32 UpdateStall(int listid, u32 newstall) = 0;
|
||||
virtual u32 DrawSync(int mode) = 0;
|
||||
virtual int ListSync(int listid, int mode) = 0;
|
||||
virtual u32 Continue() = 0;
|
||||
virtual u32 Break(int mode) = 0;
|
||||
|
||||
@@ -139,7 +150,6 @@ public:
|
||||
virtual void PreExecuteOp(u32 op, u32 diff) = 0;
|
||||
virtual void ExecuteOp(u32 op, u32 diff) = 0;
|
||||
virtual bool InterpretList(DisplayList& list) = 0;
|
||||
virtual int ListSync(int listid, int mode) = 0;
|
||||
|
||||
// Framebuffer management
|
||||
virtual void SetDisplayFramebuffer(u32 framebuf, u32 stride, int format) = 0;
|
||||
@@ -167,7 +177,7 @@ public:
|
||||
|
||||
// Debugging
|
||||
virtual void DumpNextFrame() = 0;
|
||||
virtual const std::deque<DisplayList>& GetDisplayLists() = 0;
|
||||
virtual const std::list<int>& GetDisplayLists() = 0;
|
||||
virtual DisplayList* GetCurrentDisplayList() = 0;
|
||||
virtual bool DecodeTexture(u8* dest, GPUgstate state) = 0;
|
||||
virtual std::vector<FramebufferInfo> GetFramebufferList() = 0;
|
||||
|
||||
Reference in new issue
Block a user