sceDisplay, GPUState cleanup and comments

This commit is contained in:
Henrik Rydgård 2015-07-24 21:48:39 +02:00
parent 828c740fd5
commit 0726912f09
2 changed files with 17 additions and 20 deletions

View file

@ -60,16 +60,14 @@ struct FrameBufferState {
int pspFramebufLinesize;
};
struct WaitVBlankInfo
{
struct WaitVBlankInfo {
WaitVBlankInfo(u32 tid) : threadID(tid), vcountUnblock(1) {}
WaitVBlankInfo(u32 tid, int vcount) : threadID(tid), vcountUnblock(vcount) {}
SceUID threadID;
// Number of vcounts to block for.
int vcountUnblock;
void DoState(PointerWrap &p)
{
void DoState(PointerWrap &p) {
auto s = p.Section("WaitVBlankInfo", 1);
if (!s)
return;
@ -326,16 +324,14 @@ void __DisplayVblankBeginCallback(SceUID threadID, SceUID prevCallbackId) {
WaitVBlankInfo waitData(0);
for (size_t i = 0; i < vblankWaitingThreads.size(); i++) {
WaitVBlankInfo *t = &vblankWaitingThreads[i];
if (t->threadID == threadID)
{
if (t->threadID == threadID) {
waitData = *t;
vblankWaitingThreads.erase(vblankWaitingThreads.begin() + i);
break;
}
}
if (waitData.threadID != threadID)
{
if (waitData.threadID != threadID) {
WARN_LOG_REPORT(SCEDISPLAY, "sceDisplayWaitVblankCB: could not find waiting thread info.");
return;
}
@ -498,19 +494,19 @@ static void DoFrameTiming(bool &throttle, bool &skipFrame, float timestep) {
// Check if the frameskipping code should be enabled. If neither throttling or frameskipping is on,
// we have nothing to do here.
bool doFrameSkip = g_Config.iFrameSkip != 0;
if (!throttle && g_Config.bFrameSkipUnthrottle) {
doFrameSkip = true;
skipFrame = true;
if (numSkippedFrames >= 7) {
skipFrame = false;
}
return;
return;
}
if (!throttle && !doFrameSkip)
return;
time_update();
float scaledTimestep = timestep;
@ -530,7 +526,7 @@ static void DoFrameTiming(bool &throttle, bool &skipFrame, float timestep) {
nextFrameTime = std::max(lastFrameTime + scaledTimestep, time_now_d() - maxFallBehindFrames * scaledTimestep);
}
curFrameTime = time_now_d();
// Auto-frameskip automatically if speed limit is set differently than the default.
bool useAutoFrameskip = g_Config.bAutoFrameSkip && g_Config.iRenderingMode != FB_NON_BUFFERED_MODE;
if (g_Config.bAutoFrameSkip || (g_Config.iFrameSkip == 0 && fpsLimiter == FPS_LIMIT_CUSTOM && g_Config.iFpsLimit > 60)) {
@ -707,8 +703,7 @@ void hleEnterVblank(u64 userdata, int cyclesLate) {
}
}
void hleAfterFlip(u64 userdata, int cyclesLate)
{
void hleAfterFlip(u64 userdata, int cyclesLate) {
gpu->BeginFrame(); // doesn't really matter if begin or end of frame.
// This seems like as good a time as any to check if the config changed.
@ -769,7 +764,7 @@ static u32 sceDisplaySetMode(int displayMode, int displayWidth, int displayHeigh
WARN_LOG(SCEDISPLAY, "sceDisplaySetMode INVALID SIZE (%i, %i, %i)", displayMode, displayWidth, displayHeight);
return SCE_KERNEL_ERROR_INVALID_SIZE;
}
if (displayMode != PSP_DISPLAY_MODE_LCD) {
WARN_LOG(SCEDISPLAY, "sceDisplaySetMode INVALID MODE(%i, %i, %i)", displayMode, displayWidth, displayHeight);
return SCE_KERNEL_ERROR_INVALID_MODE;
@ -1017,11 +1012,11 @@ static float sceDisplayGetFramePerSec() {
}
static u32 sceDisplayIsForeground() {
DEBUG_LOG(SCEDISPLAY,"IMPL sceDisplayIsForeground()");
DEBUG_LOG(SCEDISPLAY,"IMPL sceDisplayIsForeground()");
if (!hasSetMode || framebuf.topaddr == 0)
return 0;
else
return 1; // return value according to JPCSP comment
return 1; // return value according to JPCSP comment
}
static u32 sceDisplayGetMode(u32 modeAddr, u32 widthAddr, u32 heightAddr) {

View file

@ -435,6 +435,9 @@ inline int vertTypeGetTexCoordMask(u32 vertType) { return vertType & GE_VTYPE_TC
// The rest is cached simplified/converted data for fast access.
// Does not need to be saved when saving/restoring context.
//
// Lots of this, however, is actual emulator state which must be saved when savestating.
// vertexAddr, indexAddr, offsetAddr for example.
struct UVScale {
float uScale, vScale;
@ -447,11 +450,9 @@ enum TextureChangeReason {
TEXCHANGE_PARAMSONLY = 0x02,
};
struct GPUStateCache
{
struct GPUStateCache {
u32 vertexAddr;
u32 indexAddr;
u32 offsetAddr;
u8 textureChanged;
@ -464,6 +465,7 @@ struct GPUStateCache
UVScale uv;
bool flipTexture;
bool bgraTexture;
bool needShaderTexClamp;
bool allowShaderBlend;