Add some infrastructure to be used for frameskipping
This commit is contained in:
parent
cbb786c7f0
commit
7c91802e3c
4 changed files with 32 additions and 9 deletions
|
@ -86,6 +86,7 @@ static int hCount;
|
||||||
static int hCountTotal; //unused
|
static int hCountTotal; //unused
|
||||||
static int vCount;
|
static int vCount;
|
||||||
static int isVblank;
|
static int isVblank;
|
||||||
|
static int numSkippedFrames;
|
||||||
static bool hasSetMode;
|
static bool hasSetMode;
|
||||||
// Don't include this in the state, time increases regardless of state.
|
// Don't include this in the state, time increases regardless of state.
|
||||||
static double lastFrameTime;
|
static double lastFrameTime;
|
||||||
|
@ -113,6 +114,7 @@ void hleAfterFlip(u64 userdata, int cyclesLate);
|
||||||
void __DisplayInit() {
|
void __DisplayInit() {
|
||||||
gpuStats.reset();
|
gpuStats.reset();
|
||||||
hasSetMode = false;
|
hasSetMode = false;
|
||||||
|
numSkippedFrames = 0;
|
||||||
framebufIsLatched = false;
|
framebufIsLatched = false;
|
||||||
framebuf.topaddr = 0x04000000;
|
framebuf.topaddr = 0x04000000;
|
||||||
framebuf.pspFramebufFormat = PSP_DISPLAY_PIXEL_FORMAT_8888;
|
framebuf.pspFramebufFormat = PSP_DISPLAY_PIXEL_FORMAT_8888;
|
||||||
|
@ -264,12 +266,15 @@ void DebugStats()
|
||||||
}
|
}
|
||||||
|
|
||||||
// Let's collect all the throttling and frameskipping logic here.
|
// Let's collect all the throttling and frameskipping logic here.
|
||||||
void DoFrameTiming(bool &throttle) {
|
void DoFrameTiming(bool &throttle, bool &skipFrame, bool &skipFlip) {
|
||||||
#ifdef _WIN32
|
#ifdef _WIN32
|
||||||
throttle = !GetAsyncKeyState(VK_TAB);
|
throttle = !GetAsyncKeyState(VK_TAB);
|
||||||
#else
|
#else
|
||||||
throttle = false;
|
throttle = false;
|
||||||
#endif
|
#endif
|
||||||
|
skipFlip = false;
|
||||||
|
skipFrame = false;
|
||||||
|
|
||||||
if (PSP_CoreParameter().headLess)
|
if (PSP_CoreParameter().headLess)
|
||||||
throttle = false;
|
throttle = false;
|
||||||
|
|
||||||
|
@ -353,17 +358,27 @@ void hleEnterVblank(u64 userdata, int cyclesLate) {
|
||||||
// Yeah, this has to be the right moment to end the frame. Give the graphics backend opportunity
|
// Yeah, this has to be the right moment to end the frame. Give the graphics backend opportunity
|
||||||
// to blit the framebuffer, in order to support half-framerate games that otherwise wouldn't have
|
// to blit the framebuffer, in order to support half-framerate games that otherwise wouldn't have
|
||||||
// anything to draw here.
|
// anything to draw here.
|
||||||
gpu->CopyDisplayToOutput();
|
gstate_c.skipDrawReason &= ~SKIPDRAW_SKIPFRAME;
|
||||||
|
|
||||||
bool throttle;
|
bool throttle, skipFrame, skipFlip;
|
||||||
|
|
||||||
DoFrameTiming(throttle);
|
DoFrameTiming(throttle, skipFrame, skipFlip);
|
||||||
|
|
||||||
// Setting CORE_NEXTFRAME causes a swap.
|
// Setting CORE_NEXTFRAME causes a swap.
|
||||||
coreState = CORE_NEXTFRAME;
|
if (skipFrame) {
|
||||||
|
gstate_c.skipDrawReason |= SKIPDRAW_SKIPFRAME;
|
||||||
|
numSkippedFrames++;
|
||||||
|
} else {
|
||||||
|
numSkippedFrames = 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (!skipFlip) {
|
||||||
|
coreState = CORE_NEXTFRAME;
|
||||||
CoreTiming::ScheduleEvent(0 - cyclesLate, afterFlipEvent, 0);
|
CoreTiming::ScheduleEvent(0 - cyclesLate, afterFlipEvent, 0);
|
||||||
|
|
||||||
|
gpu->CopyDisplayToOutput();
|
||||||
|
}
|
||||||
|
|
||||||
// Returning here with coreState == CORE_NEXTFRAME causes a buffer flip to happen (next frame).
|
// Returning here with coreState == CORE_NEXTFRAME causes a buffer flip to happen (next frame).
|
||||||
// Right after, we regain control for a little bit in hleAfterFlip. I think that's a great
|
// Right after, we regain control for a little bit in hleAfterFlip. I think that's a great
|
||||||
// place to do housekeeping.
|
// place to do housekeeping.
|
||||||
|
|
|
@ -330,6 +330,9 @@ void GLES_GPU::ExecuteOp(u32 op, u32 diff) {
|
||||||
|
|
||||||
case GE_CMD_PRIM:
|
case GE_CMD_PRIM:
|
||||||
{
|
{
|
||||||
|
if (gstate_c.skipDrawReason)
|
||||||
|
return;
|
||||||
|
|
||||||
framebufferManager_.SetRenderFrameBuffer();
|
framebufferManager_.SetRenderFrameBuffer();
|
||||||
|
|
||||||
u32 count = data & 0xFFFF;
|
u32 count = data & 0xFFFF;
|
||||||
|
|
|
@ -64,7 +64,6 @@ public:
|
||||||
return textureCache_.DecodeTexture(dest, state);
|
return textureCache_.DecodeTexture(dest, state);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
std::vector<FramebufferInfo> GetFramebufferList();
|
std::vector<FramebufferInfo> GetFramebufferList();
|
||||||
|
|
||||||
private:
|
private:
|
||||||
|
|
|
@ -225,6 +225,10 @@ struct GPUgstate
|
||||||
// Real data in the context ends here
|
// Real data in the context ends here
|
||||||
};
|
};
|
||||||
|
|
||||||
|
enum SkipDrawReasonFlags {
|
||||||
|
SKIPDRAW_SKIPFRAME = 1,
|
||||||
|
};
|
||||||
|
|
||||||
// The rest is cached simplified/converted data for fast access.
|
// The rest is cached simplified/converted data for fast access.
|
||||||
// Does not need to be saved when saving/restoring context.
|
// Does not need to be saved when saving/restoring context.
|
||||||
struct GPUStateCache
|
struct GPUStateCache
|
||||||
|
@ -236,6 +240,8 @@ struct GPUStateCache
|
||||||
|
|
||||||
bool textureChanged;
|
bool textureChanged;
|
||||||
|
|
||||||
|
int skipDrawReason;
|
||||||
|
|
||||||
float uScale,vScale;
|
float uScale,vScale;
|
||||||
float uOff,vOff;
|
float uOff,vOff;
|
||||||
bool flipTexture;
|
bool flipTexture;
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue