From fb26941a276b63bd2fbb550cbf5296f4bcb4ee5e Mon Sep 17 00:00:00 2001 From: "Unknown W. Brackets" Date: Sat, 6 Apr 2013 02:28:49 -0700 Subject: [PATCH] Implement sceGeListSync(). --- Core/HLE/sceKernelThread.h | 1 + GPU/GPUCommon.cpp | 18 +++++++++++++----- GPU/GPUInterface.h | 1 + 3 files changed, 15 insertions(+), 5 deletions(-) diff --git a/Core/HLE/sceKernelThread.h b/Core/HLE/sceKernelThread.h index 30b722a34..bd9a5e235 100644 --- a/Core/HLE/sceKernelThread.h +++ b/Core/HLE/sceKernelThread.h @@ -86,6 +86,7 @@ enum WaitType WAITTYPE_CTRL = 15, WAITTYPE_IO = 16, WAITTYPE_GEDRAWSYNC = 17, + WAITTYPE_GELISTSYNC = 18, NUM_WAITTYPES }; diff --git a/GPU/GPUCommon.cpp b/GPU/GPUCommon.cpp index 073b93a06..13556c7ca 100644 --- a/GPU/GPUCommon.cpp +++ b/GPU/GPUCommon.cpp @@ -21,8 +21,10 @@ GPUCommon::GPUCommon() : dumpThisFrame_(false), interruptsEnabled_(true) { - for (int i = 0; i < DisplayListMaxCount; ++i) + for (int i = 0; i < DisplayListMaxCount; ++i) { dls[i].state = PSP_GE_DL_STATE_NONE; + dls[i].shouldWait = false; + } } void GPUCommon::PopDLQueue() { @@ -90,9 +92,8 @@ int GPUCommon::ListSync(int listid, int mode) if (mode < 0 || mode > 1) return SCE_KERNEL_ERROR_INVALID_MODE; + DisplayList& dl = dls[listid]; if (mode == 1) { - DisplayList& dl = dls[listid]; - switch (dl.state) { case PSP_GE_DL_STATE_QUEUED: if (dl.interrupted) @@ -115,7 +116,9 @@ int GPUCommon::ListSync(int listid, int mode) } } - // TODO: Wait here for mode == 0. + if (dl.shouldWait) { + __KernelWaitCurThread(WAITTYPE_GELISTSYNC, listid, 0, 0, false, "GeListSync"); + } return PSP_GE_LIST_COMPLETED; } @@ -178,6 +181,7 @@ u32 GPUCommon::EnqueueList(u32 listpc, u32 stall, int subIntrBase, bool head) dl.stackptr = 0; dl.signal = PSP_GE_SIGNAL_NONE; dl.interrupted = false; + dl.shouldWait = true; if (head) { if (currentList) { @@ -222,7 +226,8 @@ u32 GPUCommon::DequeueList(int listid) else dlQueue.remove(listid); - // TODO: Release any list wait. + dls[listid].shouldWait = false; + __KernelTriggerWait(WAITTYPE_GELISTSYNC, listid, 0, "GeListSync"); CheckDrawSync(); @@ -436,6 +441,9 @@ bool GPUCommon::ProcessDLQueue() } else { + l.shouldWait = false; + __KernelTriggerWait(WAITTYPE_GELISTSYNC, *iter, 0, "GeListSync"); + //At the end, we can remove it from the queue and continue dlQueue.erase(iter); //this invalidated the iterator, let's fix it diff --git a/GPU/GPUInterface.h b/GPU/GPUInterface.h index b1c7d3fa5..1c7dd8a58 100644 --- a/GPU/GPUInterface.h +++ b/GPU/GPUInterface.h @@ -121,6 +121,7 @@ struct DisplayList u32 stack[32]; int stackptr; bool interrupted; + bool shouldWait; }; class GPUInterface