Skip to content

Commit

Permalink
Improve performance when vsync is enabled and the game is not reachin…
Browse files Browse the repository at this point in the history
…g the 60 FPS
  • Loading branch information
fjtrujy authored and slouken committed Dec 15, 2021
1 parent 67c4b99 commit 0341ec9
Showing 1 changed file with 19 additions and 1 deletion.
20 changes: 19 additions & 1 deletion src/render/psp/SDL_render_psp.c
Expand Up @@ -80,6 +80,8 @@ typedef struct
int currentBlendMode;

PSP_DrawStateCache drawstate;

SDL_bool vblank_not_reached; /**< wether vblank wasn't reached */
} PSP_RenderData;


Expand Down Expand Up @@ -175,6 +177,12 @@ TextureNextPow2(unsigned int w)
return n;
}

static void psp_on_vblank(u32 sub, PSP_RenderData *data)
{
if (data)
data->vblank_not_reached = SDL_FALSE;
}


static int
PixelFormatToPSPFMT(Uint32 format)
Expand Down Expand Up @@ -1009,8 +1017,9 @@ PSP_RenderPresent(SDL_Renderer * renderer)
sceGuFinish();
sceGuSync(0,0);

/* if(data->vsync) */
if ((data->vsync) && (data->vblank_not_reached))
sceDisplayWaitVblankStart();
data->vblank_not_reached = SDL_TRUE;

data->backbuffer = data->frontbuffer;
data->frontbuffer = vabsptr(sceGuSwapBuffers());
Expand Down Expand Up @@ -1044,6 +1053,10 @@ PSP_DestroyRenderer(SDL_Renderer * renderer)

StartDrawing(renderer);

sceKernelDisableSubIntr(PSP_VBLANK_INT, 0);
sceKernelReleaseSubIntrHandler(PSP_VBLANK_INT,0);
sceDisplayWaitVblankStart();
sceGuDisplay(GU_FALSE);
sceGuTerm();
/* vfree(data->backbuffer); */
/* vfree(data->frontbuffer); */
Expand Down Expand Up @@ -1179,6 +1192,11 @@ PSP_CreateRenderer(SDL_Window * window, Uint32 flags)
sceDisplayWaitVblankStartCB();
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;
}

Expand Down

0 comments on commit 0341ec9

Please sign in to comment.