diff --git a/source/base.c b/source/base.c index 71fc56c..65ca89e 100644 --- a/source/base.c +++ b/source/base.c @@ -42,10 +42,12 @@ static void C3Di_AptEventHook(APT_HookType hookType, C3D_UNUSED void* param) case APTHOOK_ONSUSPEND: { C3Di_RenderQueueWaitDone(); + C3Di_RenderQueueDisableVBlank(); break; } case APTHOOK_ONRESTORE: { + C3Di_RenderQueueEnableVBlank(); ctx->flags |= C3DiF_AttrInfo | C3DiF_BufInfo | C3DiF_Effect | C3DiF_FrameBuf | C3DiF_Viewport | C3DiF_Scissor | C3DiF_Program | C3DiF_VshCode | C3DiF_GshCode | C3DiF_TexAll | C3DiF_TexEnvBuf | C3DiF_TexEnvAll | C3DiF_LightEnv | C3DiF_Gas; diff --git a/source/internal.h b/source/internal.h index ff70a24..abdaf26 100644 --- a/source/internal.h +++ b/source/internal.h @@ -144,3 +144,5 @@ bool C3Di_SplitFrame(u32** pBuf, u32* pSize); void C3Di_RenderQueueInit(void); void C3Di_RenderQueueExit(void); void C3Di_RenderQueueWaitDone(void); +void C3Di_RenderQueueEnableVBlank(void); +void C3Di_RenderQueueDisableVBlank(void); diff --git a/source/renderqueue.c b/source/renderqueue.c index 0905d51..e96d9ac 100644 --- a/source/renderqueue.c +++ b/source/renderqueue.c @@ -99,12 +99,23 @@ static bool C3Di_WaitAndClearQueue(s64 timeout) return true; } +void C3Di_RenderQueueEnableVBlank(void) +{ + gspSetEventCallback(GSPGPU_EVENT_VBlank0, onVBlank0, NULL, false); + gspSetEventCallback(GSPGPU_EVENT_VBlank1, onVBlank1, NULL, false); +} + +void C3Di_RenderQueueDisableVBlank(void) +{ + gspSetEventCallback(GSPGPU_EVENT_VBlank0, NULL, NULL, false); + gspSetEventCallback(GSPGPU_EVENT_VBlank1, NULL, NULL, false); +} + void C3Di_RenderQueueInit(void) { C3D_Context* ctx = C3Di_GetContext(); - gspSetEventCallback(GSPGPU_EVENT_VBlank0, onVBlank0, NULL, false); - gspSetEventCallback(GSPGPU_EVENT_VBlank1, onVBlank1, NULL, false); + C3Di_RenderQueueEnableVBlank(); GX_BindQueue(&ctx->gxQueue); gxCmdQueueSetCallback(&ctx->gxQueue, onQueueFinish, NULL); @@ -120,8 +131,7 @@ void C3Di_RenderQueueExit(void) gxCmdQueueSetCallback(&C3Di_GetContext()->gxQueue, NULL, NULL); GX_BindQueue(NULL); - gspSetEventCallback(GSPGPU_EVENT_VBlank0, NULL, NULL, false); - gspSetEventCallback(GSPGPU_EVENT_VBlank1, NULL, NULL, false); + C3Di_RenderQueueDisableVBlank(); for (i = 0; i < 3; i ++) linkedTarget[i] = NULL;