mirror of https://github.com/encounter/SDL.git
Improve performance when vsync is enabled and the game is not reaching the 60 FPS
This commit is contained in:
parent
67c4b99639
commit
0341ec93fe
|
@ -80,6 +80,8 @@ typedef struct
|
||||||
int currentBlendMode;
|
int currentBlendMode;
|
||||||
|
|
||||||
PSP_DrawStateCache drawstate;
|
PSP_DrawStateCache drawstate;
|
||||||
|
|
||||||
|
SDL_bool vblank_not_reached; /**< wether vblank wasn't reached */
|
||||||
} PSP_RenderData;
|
} PSP_RenderData;
|
||||||
|
|
||||||
|
|
||||||
|
@ -175,6 +177,12 @@ TextureNextPow2(unsigned int w)
|
||||||
return n;
|
return n;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static void psp_on_vblank(u32 sub, PSP_RenderData *data)
|
||||||
|
{
|
||||||
|
if (data)
|
||||||
|
data->vblank_not_reached = SDL_FALSE;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
static int
|
static int
|
||||||
PixelFormatToPSPFMT(Uint32 format)
|
PixelFormatToPSPFMT(Uint32 format)
|
||||||
|
@ -1009,8 +1017,9 @@ PSP_RenderPresent(SDL_Renderer * renderer)
|
||||||
sceGuFinish();
|
sceGuFinish();
|
||||||
sceGuSync(0,0);
|
sceGuSync(0,0);
|
||||||
|
|
||||||
/* if(data->vsync) */
|
if ((data->vsync) && (data->vblank_not_reached))
|
||||||
sceDisplayWaitVblankStart();
|
sceDisplayWaitVblankStart();
|
||||||
|
data->vblank_not_reached = SDL_TRUE;
|
||||||
|
|
||||||
data->backbuffer = data->frontbuffer;
|
data->backbuffer = data->frontbuffer;
|
||||||
data->frontbuffer = vabsptr(sceGuSwapBuffers());
|
data->frontbuffer = vabsptr(sceGuSwapBuffers());
|
||||||
|
@ -1044,6 +1053,10 @@ PSP_DestroyRenderer(SDL_Renderer * renderer)
|
||||||
|
|
||||||
StartDrawing(renderer);
|
StartDrawing(renderer);
|
||||||
|
|
||||||
|
sceKernelDisableSubIntr(PSP_VBLANK_INT, 0);
|
||||||
|
sceKernelReleaseSubIntrHandler(PSP_VBLANK_INT,0);
|
||||||
|
sceDisplayWaitVblankStart();
|
||||||
|
sceGuDisplay(GU_FALSE);
|
||||||
sceGuTerm();
|
sceGuTerm();
|
||||||
/* vfree(data->backbuffer); */
|
/* vfree(data->backbuffer); */
|
||||||
/* vfree(data->frontbuffer); */
|
/* vfree(data->frontbuffer); */
|
||||||
|
@ -1179,6 +1192,11 @@ PSP_CreateRenderer(SDL_Window * window, Uint32 flags)
|
||||||
sceDisplayWaitVblankStartCB();
|
sceDisplayWaitVblankStartCB();
|
||||||
sceGuDisplay(GU_TRUE);
|
sceGuDisplay(GU_TRUE);
|
||||||
|
|
||||||
|
/* Improve performance when VSYC is enabled and it is not reaching the 60 FPS */
|
||||||
|
data->vblank_not_reached = SDL_TRUE;
|
||||||
|
sceKernelRegisterSubIntrHandler(PSP_VBLANK_INT, 0, psp_on_vblank, data);
|
||||||
|
sceKernelEnableSubIntr(PSP_VBLANK_INT, 0);
|
||||||
|
|
||||||
return renderer;
|
return renderer;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue