mirror of
https://github.com/ekeeke/Genesis-Plus-GX.git
synced 2025-01-13 19:59:07 +01:00
[Gamecube/Wii] optimized EFB->XFB copy (also fixes crash when displaying FPS while fast-forward is ON)
This commit is contained in:
parent
a0f161ed2d
commit
6a0fdd10df
@ -80,8 +80,8 @@ static gx_texture *cd_leds[2][2];
|
|||||||
static GXTexObj screenTexObj;
|
static GXTexObj screenTexObj;
|
||||||
|
|
||||||
/*** Framebuffers ***/
|
/*** Framebuffers ***/
|
||||||
static u32 *xfb;
|
static u32 *xfb[2];
|
||||||
static u32 drawDone;
|
static u8 fbCurrent;
|
||||||
|
|
||||||
/*** Frame Sync ***/
|
/*** Frame Sync ***/
|
||||||
u32 videoSync;
|
u32 videoSync;
|
||||||
@ -391,26 +391,17 @@ static void vi_callback(u32 cnt)
|
|||||||
videoWait = 0;
|
videoWait = 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
/* XFB update */
|
|
||||||
static void xfb_update(u32 cnt)
|
|
||||||
{
|
|
||||||
/* check if EFB rendering is finished */
|
|
||||||
if (drawDone)
|
|
||||||
{
|
|
||||||
/* clear GX draw end flag */
|
|
||||||
drawDone = 0;
|
|
||||||
|
|
||||||
/* copy EFB to XFB */
|
|
||||||
GX_CopyDisp(xfb, GX_FALSE);
|
|
||||||
GX_Flush();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
/* GX draw callback */
|
/* GX draw callback */
|
||||||
static void gx_callback(void)
|
static void gx_callback(void)
|
||||||
{
|
{
|
||||||
/* set GX draw end flag */
|
/* swap framebuffers */
|
||||||
drawDone = 1;
|
fbCurrent ^= 1;
|
||||||
|
VIDEO_SetNextFramebuffer(xfb[fbCurrent]);
|
||||||
|
VIDEO_Flush();
|
||||||
|
|
||||||
|
/* copy EFB to XFB */
|
||||||
|
GX_CopyDisp(xfb[fbCurrent], GX_FALSE);
|
||||||
|
GX_Flush();
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Initialize GX */
|
/* Initialize GX */
|
||||||
@ -1076,7 +1067,7 @@ void gxSaveScreenshot(char *filename)
|
|||||||
void gxSetScreen(void)
|
void gxSetScreen(void)
|
||||||
{
|
{
|
||||||
VIDEO_WaitVSync();
|
VIDEO_WaitVSync();
|
||||||
GX_CopyDisp(xfb, GX_FALSE);
|
GX_CopyDisp(xfb[fbCurrent], GX_FALSE);
|
||||||
GX_Flush();
|
GX_Flush();
|
||||||
gx_input_UpdateMenu();
|
gx_input_UpdateMenu();
|
||||||
}
|
}
|
||||||
@ -1239,7 +1230,7 @@ gx_texture *gxTextureOpenPNG(const u8 *png_data, FILE *png_file)
|
|||||||
|
|
||||||
/* initialize GX texture object */
|
/* initialize GX texture object */
|
||||||
GX_InitTexObj(&texture->texObj, texture->data, width, height, GX_TF_RGBA8, GX_CLAMP, GX_CLAMP, GX_FALSE);
|
GX_InitTexObj(&texture->texObj, texture->data, width, height, GX_TF_RGBA8, GX_CLAMP, GX_CLAMP, GX_FALSE);
|
||||||
/*GX_InitTexObjLOD(&texture->texObj,GX_LINEAR,GX_LIN_MIP_LIN,0.0,10.0,0.0,GX_FALSE,GX_TRUE,GX_ANISO_4);*/
|
|
||||||
/* encode to GX_TF_RGBA8 format (4x4 pixels paired titles) */
|
/* encode to GX_TF_RGBA8 format (4x4 pixels paired titles) */
|
||||||
u16 *dst_ar = (u16 *)(texture->data);
|
u16 *dst_ar = (u16 *)(texture->data);
|
||||||
u16 *dst_gb = (u16 *)(texture->data + 32);
|
u16 *dst_gb = (u16 *)(texture->data + 32);
|
||||||
@ -1449,7 +1440,6 @@ void gx_video_Stop(void)
|
|||||||
{
|
{
|
||||||
/* disable VSYNC callbacks */
|
/* disable VSYNC callbacks */
|
||||||
VIDEO_SetPostRetraceCallback(NULL);
|
VIDEO_SetPostRetraceCallback(NULL);
|
||||||
VIDEO_SetPreRetraceCallback(NULL);
|
|
||||||
|
|
||||||
/* wait for next even field */
|
/* wait for next even field */
|
||||||
/* this prevents screen artefacts when switching between interlaced & non-interlaced modes */
|
/* this prevents screen artefacts when switching between interlaced & non-interlaced modes */
|
||||||
@ -1670,9 +1660,6 @@ void gx_video_Start(void)
|
|||||||
VIDEO_SetGamma((int)(config.gamma * 10.0));
|
VIDEO_SetGamma((int)(config.gamma * 10.0));
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
/* XFB update is done during VBLANK */
|
|
||||||
VIDEO_SetPreRetraceCallback(xfb_update);
|
|
||||||
|
|
||||||
/* Emulation is synchronized with video hardware if VSYNC is set to AUTO & TV mode matches emulated video mode */
|
/* Emulation is synchronized with video hardware if VSYNC is set to AUTO & TV mode matches emulated video mode */
|
||||||
if (config.vsync && (gc_pal == vdp_pal))
|
if (config.vsync && (gc_pal == vdp_pal))
|
||||||
{
|
{
|
||||||
@ -1760,16 +1747,13 @@ int gx_video_Update(int status)
|
|||||||
DCStoreRange(bitmap.data, vwidth*vheight*2);
|
DCStoreRange(bitmap.data, vwidth*vheight*2);
|
||||||
GX_InvalidateTexAll();
|
GX_InvalidateTexAll();
|
||||||
|
|
||||||
/* disable EFB copy until rendering is done */
|
|
||||||
drawDone = 0;
|
|
||||||
|
|
||||||
/* render textured quad */
|
/* render textured quad */
|
||||||
GX_CallDispList(screenDisplayList, 32);
|
GX_CallDispList(screenDisplayList, 32);
|
||||||
|
|
||||||
/* on-screen display */
|
/* on-screen display */
|
||||||
if (osd)
|
if (osd)
|
||||||
{
|
{
|
||||||
/* reset GX rendering */
|
/* reset GX rendering mode */
|
||||||
gxResetRendering(1);
|
gxResetRendering(1);
|
||||||
|
|
||||||
/* lightgun # 1 screen mark */
|
/* lightgun # 1 screen mark */
|
||||||
@ -1829,7 +1813,7 @@ int gx_video_Update(int status)
|
|||||||
/* restore texture object */
|
/* restore texture object */
|
||||||
GX_LoadTexObj(&screenTexObj, GX_TEXMAP0);
|
GX_LoadTexObj(&screenTexObj, GX_TEXMAP0);
|
||||||
|
|
||||||
/* restore GX rendering */
|
/* restore GX rendering mode */
|
||||||
gxResetRendering(0);
|
gxResetRendering(0);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -1904,17 +1888,19 @@ void gx_video_Init(void)
|
|||||||
/* Configure VI */
|
/* Configure VI */
|
||||||
VIDEO_Configure(vmode);
|
VIDEO_Configure(vmode);
|
||||||
|
|
||||||
/* Allocate framebuffer */
|
/* Allocate framebuffers */
|
||||||
xfb = (u32 *) MEM_K0_TO_K1((u32 *) SYS_AllocateFramebuffer(&TV50hz_576i));
|
xfb[0] = (u32 *) MEM_K0_TO_K1((u32 *) SYS_AllocateFramebuffer(&TV50hz_576i));
|
||||||
|
xfb[1] = (u32 *) MEM_K0_TO_K1((u32 *) SYS_AllocateFramebuffer(&TV50hz_576i));
|
||||||
|
|
||||||
/* Define a console */
|
/* Define a console */
|
||||||
console_init(xfb, 20, 64, 640, 574, 574 * 2);
|
console_init(xfb[0], 20, 64, 640, 574, 574 * 2);
|
||||||
|
|
||||||
/* Clear framebuffer to black */
|
/* Clear framebuffer to black */
|
||||||
VIDEO_ClearFrameBuffer(vmode, xfb, COLOR_BLACK);
|
VIDEO_ClearFrameBuffer(vmode, xfb[0], COLOR_BLACK);
|
||||||
|
|
||||||
/* Set the framebuffer to be displayed at next VBlank */
|
/* Set the framebuffer to be displayed at next VBlank */
|
||||||
VIDEO_SetNextFramebuffer(xfb);
|
VIDEO_SetNextFramebuffer(xfb[0]);
|
||||||
|
fbCurrent = 0;
|
||||||
|
|
||||||
/* Enable Video Interface */
|
/* Enable Video Interface */
|
||||||
VIDEO_SetBlack(FALSE);
|
VIDEO_SetBlack(FALSE);
|
||||||
@ -1938,7 +1924,7 @@ void gx_video_Init(void)
|
|||||||
void gx_video_Shutdown(void)
|
void gx_video_Shutdown(void)
|
||||||
{
|
{
|
||||||
FONT_Shutdown();
|
FONT_Shutdown();
|
||||||
VIDEO_ClearFrameBuffer(vmode, xfb, COLOR_BLACK);
|
VIDEO_ClearFrameBuffer(vmode, xfb[fbCurrent], COLOR_BLACK);
|
||||||
VIDEO_Flush();
|
VIDEO_Flush();
|
||||||
VIDEO_WaitVSync();
|
VIDEO_WaitVSync();
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user