mirror of
https://github.com/hrydgard/ppsspp.git
synced 2024-11-23 13:30:02 +00:00
Start saving the state of the GPU.
Not 100% sure this is all that's needed, but let's try it.
This commit is contained in:
parent
7a2adfd8a5
commit
5999fac10d
@ -154,10 +154,17 @@ public:
|
||||
// Store vectors.
|
||||
template<class T>
|
||||
void Do(std::vector<T> &x)
|
||||
{
|
||||
T dv;
|
||||
Do(x, dv);
|
||||
}
|
||||
|
||||
template<class T>
|
||||
void Do(std::vector<T> &x, T &default_val)
|
||||
{
|
||||
u32 vec_size = (u32)x.size();
|
||||
Do(vec_size);
|
||||
x.resize(vec_size);
|
||||
x.resize(vec_size, default_val);
|
||||
if (vec_size > 0)
|
||||
DoArray(&x[0], vec_size);
|
||||
}
|
||||
|
@ -52,6 +52,13 @@ struct FrameBufferState {
|
||||
int pspFramebufLinesize;
|
||||
};
|
||||
|
||||
struct WaitVBlankInfo
|
||||
{
|
||||
WaitVBlankInfo(u32 tid) : threadID(tid), vcountUnblock(0) {}
|
||||
u32 threadID;
|
||||
int vcountUnblock; // what was this for again?
|
||||
};
|
||||
|
||||
// STATE BEGIN
|
||||
static FrameBufferState framebuf;
|
||||
static FrameBufferState latchedFramebuf;
|
||||
@ -67,8 +74,11 @@ static int isVblank;
|
||||
static bool hasSetMode;
|
||||
double lastFrameTime;
|
||||
|
||||
std::vector<WaitVBlankInfo> vblankWaitingThreads;
|
||||
|
||||
// STATE END
|
||||
|
||||
// Called when vblank happens (like an internal interrupt.) Not part of state, should be static.
|
||||
std::vector<VblankCallback> vblankListeners;
|
||||
|
||||
// The vblank period is 731.5 us (0.7315 ms)
|
||||
@ -80,15 +90,6 @@ enum {
|
||||
PSP_DISPLAY_SETBUF_NEXTFRAME = 1
|
||||
};
|
||||
|
||||
struct WaitVBlankInfo
|
||||
{
|
||||
WaitVBlankInfo(u32 tid) : threadID(tid), vcountUnblock(0) {}
|
||||
u32 threadID;
|
||||
int vcountUnblock; // what was this for again?
|
||||
};
|
||||
|
||||
std::vector<WaitVBlankInfo> vblankWaitingThreads;
|
||||
|
||||
void hleEnterVblank(u64 userdata, int cyclesLate);
|
||||
void hleLeaveVblank(u64 userdata, int cyclesLate);
|
||||
|
||||
@ -114,6 +115,26 @@ void __DisplayInit() {
|
||||
InitGfxState();
|
||||
}
|
||||
|
||||
void __DisplayDoState(PointerWrap &p) {
|
||||
p.Do(framebuf);
|
||||
p.Do(latchedFramebuf);
|
||||
p.Do(framebufIsLatched);
|
||||
p.Do(hCount);
|
||||
p.Do(hCountTotal);
|
||||
p.Do(vCount);
|
||||
p.Do(isVblank);
|
||||
p.Do(hasSetMode);
|
||||
p.Do(lastFrameTime);
|
||||
p.Do(vblankWaitingThreads, WaitVBlankInfo(0));
|
||||
|
||||
p.Do(enterVblankEvent);
|
||||
CoreTiming::RestoreRegisterEvent(enterVblankEvent, "EnterVBlank", &hleEnterVblank);
|
||||
p.Do(leaveVblankEvent);
|
||||
CoreTiming::RestoreRegisterEvent(leaveVblankEvent, "LeaveVBlank", &hleLeaveVblank);
|
||||
|
||||
p.DoMarker("sceDisplay");
|
||||
}
|
||||
|
||||
void __DisplayShutdown() {
|
||||
vblankListeners.clear();
|
||||
vblankWaitingThreads.clear();
|
||||
|
@ -18,6 +18,7 @@
|
||||
#pragma once
|
||||
|
||||
void __DisplayInit();
|
||||
void __DisplayDoState(PointerWrap &p);
|
||||
void __DisplayShutdown();
|
||||
|
||||
void Register_sceDisplay();
|
||||
@ -26,4 +27,5 @@ void Register_sceDisplay();
|
||||
bool __DisplayFrameDone();
|
||||
|
||||
typedef void (*VblankCallback)();
|
||||
// Listen for vblank events. Only register during init.
|
||||
void __DisplayListenVblank(VblankCallback callback);
|
||||
|
@ -33,6 +33,17 @@ void __GeInit()
|
||||
state = 0;
|
||||
}
|
||||
|
||||
void __GeDoState(PointerWrap &p)
|
||||
{
|
||||
p.Do(state);
|
||||
p.Do(gstate);
|
||||
p.Do(gstate_c);
|
||||
|
||||
ReapplyGfxState();
|
||||
gpu->InvalidateCache(0, -1);
|
||||
p.DoMarker("sceGe");
|
||||
}
|
||||
|
||||
void __GeShutdown()
|
||||
{
|
||||
|
||||
|
@ -37,6 +37,7 @@ typedef struct PspGeCallbackData
|
||||
void Register_sceGe_user();
|
||||
|
||||
void __GeInit();
|
||||
void __GeDoState(PointerWrap &p);
|
||||
void __GeShutdown();
|
||||
|
||||
|
||||
|
@ -158,7 +158,9 @@ void __KernelDoState(PointerWrap &p)
|
||||
// TODO: non-kernel modules
|
||||
__AudioDoState(p);
|
||||
__CtrlDoState(p);
|
||||
__DisplayDoState(p);
|
||||
__FontDoState(p);
|
||||
__GeDoState(p);
|
||||
__ImposeDoState(p);
|
||||
__PowerDoState(p);
|
||||
__SasDoState(p);
|
||||
|
Loading…
Reference in New Issue
Block a user