From cd6e74fd174cb94865576eb5d69ddd64c7216269 Mon Sep 17 00:00:00 2001 From: James Benton Date: Sun, 24 Nov 2019 11:06:57 +0000 Subject: [PATCH] whb: Fix WHBGfxShutdown when app is in background. --- libraries/libwhb/src/gfx.c | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) diff --git a/libraries/libwhb/src/gfx.c b/libraries/libwhb/src/gfx.c index de6bf84d..dccced45 100644 --- a/libraries/libwhb/src/gfx.c +++ b/libraries/libwhb/src/gfx.c @@ -70,6 +70,9 @@ sDrawingTv = FALSE; static BOOL sGpuTimedOut = FALSE; +static BOOL +sGfxHasForeground = TRUE; + static void * GfxGX2RAlloc(GX2RResourceFlags flags, uint32_t size, @@ -155,6 +158,8 @@ GfxInitDepthBuffer(GX2DepthBuffer *db, static uint32_t GfxProcCallbackAcquired(void *context) { + sGfxHasForeground = TRUE; + if (!GfxHeapInitMEM1()) { WHBLogPrintf("%s: GfxHeapInitMEM1 failed", __FUNCTION__); goto error; @@ -275,6 +280,7 @@ GfxProcCallbackReleased(void *context) GfxHeapDestroyMEM1(); GfxHeapDestroyForeground(); + sGfxHasForeground = FALSE; return 0; } @@ -437,7 +443,10 @@ WHBGfxShutdown() sGpuTimedOut = FALSE; } - GfxProcCallbackReleased(NULL); + if (sGfxHasForeground) { + GfxProcCallbackReleased(NULL); + } + GX2RSetAllocator(NULL, NULL); GX2Shutdown();