Add gfxSetDoubleBuffering() for disabling double-buffering

This commit is contained in:
fincs 2014-12-08 15:57:39 +01:00
parent 6a195608aa
commit b5723c9209
2 changed files with 16 additions and 10 deletions

View File

@ -22,6 +22,7 @@ void gfxExit();
//control stuff
void gfxSet3D(bool enable);
void gfxSetScreenFormat(gfxScreen_t screen, GSP_FramebufferFormats format);
void gfxSetDoubleBuffering(bool doubleBuffering);
void gfxFlushBuffers();
void gfxSwapBuffers();
void gfxSwapBuffersGpu();

View File

@ -12,13 +12,14 @@ u8* gfxTopLeftFramebuffers[2];
u8* gfxTopRightFramebuffers[2];
u8* gfxBottomFramebuffers[2];
u8 currentBuffer;
bool enable3d;
static u8 currentBuffer;
static bool enable3d;
static int doubleBuf = 1;
Handle gspEvent, gspSharedMemHandle;
GSP_FramebufferFormats topFormat = GSP_BGR8_OES;
GSP_FramebufferFormats botFormat = GSP_BGR8_OES;
static GSP_FramebufferFormats topFormat = GSP_BGR8_OES;
static GSP_FramebufferFormats botFormat = GSP_BGR8_OES;
void gfxSet3D(bool enable)
{
@ -32,6 +33,10 @@ void gfxSetScreenFormat(gfxScreen_t screen, GSP_FramebufferFormats format) {
botFormat = format;
}
void gfxSetDoubleBuffering(bool doubleBuffering) {
doubleBuf = doubleBuffering ? 1 : 0; // make sure they're the integer values '1' and '0'
}
static u32 __get_bytes_per_pixel(GSP_FramebufferFormats format) {
switch(format) {
case GSP_RGBA8_OES:
@ -76,7 +81,7 @@ void gfxWriteFramebufferInfo(gfxScreen_t screen)
u8* framebufferInfoHeader=gfxSharedMemory+0x200+gfxThreadID*0x80;
if(screen==GFX_BOTTOM)framebufferInfoHeader+=0x40;
GSP_FramebufferInfo* framebufferInfo=(GSP_FramebufferInfo*)&framebufferInfoHeader[0x4];
framebufferInfoHeader[0x0]^=1;
framebufferInfoHeader[0x0]^=doubleBuf;
framebufferInfo[framebufferInfoHeader[0x0]]=(screen==GFX_TOP)?(topFramebufferInfo):(bottomFramebufferInfo);
framebufferInfoHeader[0x1]=1;
}
@ -131,7 +136,7 @@ void gfxExit()
// Exit event handler
gspExitEventHandler();
// Free framebuffers (let's pretend linearFree is actually implemented...)
// Free framebuffers
linearFree(gfxTopRightFramebuffers[1]);
linearFree(gfxTopRightFramebuffers[0]);
linearFree(gfxBottomFramebuffers[1]);
@ -159,10 +164,10 @@ u8* gfxGetFramebuffer(gfxScreen_t screen, gfx3dSide_t side, u16* width, u16* hei
if(screen==GFX_TOP)
{
if(height)*height=400;
return (side==GFX_LEFT || !enable3d)?(gfxTopLeftFramebuffers[currentBuffer^1]):(gfxTopRightFramebuffers[currentBuffer^1]);
return (side==GFX_LEFT || !enable3d)?(gfxTopLeftFramebuffers[currentBuffer^doubleBuf]):(gfxTopRightFramebuffers[currentBuffer^doubleBuf]);
}else{
if(height)*height=320;
return gfxBottomFramebuffers[currentBuffer^1];
return gfxBottomFramebuffers[currentBuffer^doubleBuf];
}
}
@ -175,7 +180,7 @@ void gfxFlushBuffers()
void gfxSwapBuffers()
{
currentBuffer^=1;
currentBuffer^=doubleBuf;
gfxSetFramebufferInfo(GFX_TOP, currentBuffer);
gfxSetFramebufferInfo(GFX_BOTTOM, currentBuffer);
GSPGPU_SetBufferSwap(NULL, GFX_TOP, &topFramebufferInfo);
@ -184,7 +189,7 @@ void gfxSwapBuffers()
void gfxSwapBuffersGpu()
{
currentBuffer^=1;
currentBuffer^=doubleBuf;
gfxSetFramebufferInfo(GFX_TOP, currentBuffer);
gfxSetFramebufferInfo(GFX_BOTTOM, currentBuffer);
gfxWriteFramebufferInfo(GFX_TOP);