Fixed flickering
This commit is contained in:
@@ -25,22 +25,9 @@
|
||||
|
||||
display_t DISPLAY = { 0 };
|
||||
|
||||
#if DOLPHIN
|
||||
static vu8 readyForCopy;
|
||||
#define FIFO_SIZE (256*1024)
|
||||
static void copy_buffers(u32 count __attribute__ ((unused)))
|
||||
{
|
||||
if (readyForCopy==GX_TRUE) {
|
||||
GX_SetZMode(GX_TRUE, GX_LEQUAL, GX_TRUE);
|
||||
GX_SetColorUpdate(GX_TRUE);
|
||||
GX_CopyDisp(DISPLAY.frameBuffer,GX_TRUE);
|
||||
GX_Flush();
|
||||
readyForCopy = GX_FALSE;
|
||||
}
|
||||
}
|
||||
#endif
|
||||
|
||||
errorret_t displayInit(void) {
|
||||
memoryZero(&DISPLAY, sizeof(DISPLAY));
|
||||
|
||||
#if DISPLAY_SDL2
|
||||
uint32_t flags = SDL_INIT_VIDEO;
|
||||
#if INPUT_GAMEPAD == 1
|
||||
@@ -93,47 +80,66 @@ errorret_t displayInit(void) {
|
||||
glEnableClientState(GL_VERTEX_ARRAY);
|
||||
|
||||
#elif DOLPHIN
|
||||
|
||||
VIDEO_Init();
|
||||
DISPLAY.screenMode = VIDEO_GetPreferredMode(NULL);
|
||||
DISPLAY.frameBuffer = MEM_K0_TO_K1(
|
||||
DISPLAY.frameBuffer[0] = MEM_K0_TO_K1(
|
||||
SYS_AllocateFramebuffer(DISPLAY.screenMode)
|
||||
);
|
||||
DISPLAY.frameBuffer[1] = MEM_K0_TO_K1(
|
||||
SYS_AllocateFramebuffer(DISPLAY.screenMode)
|
||||
);
|
||||
VIDEO_Configure(DISPLAY.screenMode);
|
||||
|
||||
VIDEO_SetNextFramebuffer(DISPLAY.frameBuffer);
|
||||
VIDEO_SetPostRetraceCallback(copy_buffers);
|
||||
VIDEO_SetNextFramebuffer(DISPLAY.frameBuffer[DISPLAY.whichFrameBuffer]);
|
||||
// VIDEO_SetPostRetraceCallback(copy_buffers);
|
||||
VIDEO_SetBlack(FALSE);
|
||||
VIDEO_Flush();
|
||||
// VIDEO_WaitVSync();
|
||||
// if(DISPLAY.screenMode->viTVMode & VI_NON_INTERLACE) VIDEO_WaitVSync();
|
||||
VIDEO_WaitVSync();
|
||||
if(DISPLAY.screenMode->viTVMode & VI_NON_INTERLACE) VIDEO_WaitVSync();
|
||||
|
||||
DISPLAY.fifoBuffer = MEM_K0_TO_K1(memalign(32, FIFO_SIZE));
|
||||
memoryZero(DISPLAY.fifoBuffer, FIFO_SIZE);
|
||||
DISPLAY.fifoBuffer = memalign(32, DISPLAY_FIFO_SIZE);
|
||||
memoryZero(DISPLAY.fifoBuffer, DISPLAY_FIFO_SIZE);
|
||||
|
||||
GX_Init(DISPLAY.fifoBuffer, FIFO_SIZE);
|
||||
GX_Init(DISPLAY.fifoBuffer, DISPLAY_FIFO_SIZE);
|
||||
|
||||
// This seems to be mostly related to interlacing vs progressive
|
||||
GX_SetDispCopyYScale(
|
||||
(f32)DISPLAY.screenMode->xfbHeight /
|
||||
(f32)DISPLAY.screenMode->efbHeight
|
||||
GX_SetViewport(
|
||||
0, 0,
|
||||
DISPLAY.screenMode->fbWidth, DISPLAY.screenMode->efbHeight,
|
||||
0, 1
|
||||
);
|
||||
float_t yscale = GX_GetYScaleFactor(
|
||||
DISPLAY.screenMode->efbHeight, DISPLAY.screenMode->xfbHeight
|
||||
);
|
||||
uint32_t xfbHeight = GX_SetDispCopyYScale(yscale);
|
||||
GX_SetScissor(
|
||||
0, 0,
|
||||
DISPLAY.screenMode->fbWidth, DISPLAY.screenMode->efbHeight
|
||||
);
|
||||
GX_SetDispCopySrc(
|
||||
0, 0,
|
||||
DISPLAY.screenMode->fbWidth, DISPLAY.screenMode->efbHeight
|
||||
);
|
||||
GX_SetDispCopyDst(DISPLAY.screenMode->fbWidth, xfbHeight);
|
||||
GX_SetCopyFilter(
|
||||
DISPLAY.screenMode->aa,
|
||||
DISPLAY.screenMode->sample_pattern,
|
||||
GX_TRUE,
|
||||
DISPLAY.screenMode->vfilter
|
||||
);
|
||||
GX_SetFieldMode(
|
||||
DISPLAY.screenMode->field_rendering,
|
||||
(
|
||||
(DISPLAY.screenMode->viHeight == 2 * DISPLAY.screenMode->xfbHeight) ?
|
||||
GX_ENABLE :
|
||||
GX_DISABLE
|
||||
)
|
||||
);
|
||||
GX_SetScissor(0,0,DISPLAY.screenMode->fbWidth,DISPLAY.screenMode->efbHeight);
|
||||
GX_SetDispCopySrc(0,0,DISPLAY.screenMode->fbWidth,DISPLAY.screenMode->efbHeight);
|
||||
GX_SetDispCopyDst(DISPLAY.screenMode->fbWidth,DISPLAY.screenMode->xfbHeight);
|
||||
GX_SetCopyFilter(DISPLAY.screenMode->aa,DISPLAY.screenMode->sample_pattern,
|
||||
GX_TRUE,DISPLAY.screenMode->vfilter);
|
||||
GX_SetFieldMode(DISPLAY.screenMode->field_rendering, (
|
||||
(DISPLAY.screenMode->viHeight == 2 * DISPLAY.screenMode->xfbHeight) ?
|
||||
GX_ENABLE : GX_DISABLE
|
||||
));
|
||||
|
||||
// Setup cull modes
|
||||
GX_SetCullMode(GX_CULL_NONE);
|
||||
GX_CopyDisp(DISPLAY.frameBuffer[DISPLAY.whichFrameBuffer], GX_TRUE);
|
||||
GX_SetDispCopyGamma(GX_GM_1_0);
|
||||
|
||||
//?
|
||||
GX_CopyDisp(DISPLAY.frameBuffer, GX_TRUE);
|
||||
#endif
|
||||
|
||||
quadInit();
|
||||
@@ -209,10 +215,14 @@ errorret_t displayUpdate(void) {
|
||||
}
|
||||
#elif DOLPHIN
|
||||
GX_DrawDone();
|
||||
readyForCopy = GX_TRUE;
|
||||
|
||||
DISPLAY.whichFrameBuffer ^= 1;
|
||||
GX_SetZMode(GX_TRUE, GX_LEQUAL, GX_TRUE);
|
||||
GX_SetColorUpdate(GX_TRUE);
|
||||
GX_CopyDisp(DISPLAY.frameBuffer[DISPLAY.whichFrameBuffer], GX_TRUE);
|
||||
VIDEO_SetNextFramebuffer(DISPLAY.frameBuffer[DISPLAY.whichFrameBuffer]);
|
||||
VIDEO_Flush();
|
||||
VIDEO_WaitVSync();
|
||||
// if(DISPLAY.screenMode->viTVMode & VI_NON_INTERLACE) VIDEO_WaitVSync();
|
||||
#endif
|
||||
|
||||
// For now, we just return an OK error.
|
||||
|
||||
Reference in New Issue
Block a user