whb: Handle GPU hangs by resetting the GPU on shutdown.

So your application will exit cleanly even when you break the GPU.
This commit is contained in:
James Benton 2017-06-02 11:50:12 +01:00
parent 2c18b246ae
commit ee9bd49c34
3 changed files with 23 additions and 1 deletions

View File

@ -21,6 +21,9 @@ GX2Shutdown();
void
GX2Flush();
void
GX2ResetGPU(uint32_t unknown);
#ifdef __cplusplus
}
#endif

View File

@ -64,6 +64,9 @@ sTvContextState = NULL;
static GX2ContextState *
sDrcContextState = NULL;
static BOOL
sGpuTimedOut = FALSE;
static void *
GfxGX2RAlloc(GX2RResourceFlags flags,
uint32_t size,
@ -426,6 +429,11 @@ error:
void
WHBGfxShutdown()
{
if (sGpuTimedOut) {
GX2ResetGPU(0);
sGpuTimedOut = FALSE;
}
GfxProcCallbackReleased(NULL);
GX2Shutdown();
@ -452,14 +460,24 @@ WHBGfxBeginRender()
{
uint32_t swapCount, flipCount;
OSTime lastFlip, lastVsync;
uint32_t waitCount = 0;
while (true) {
GX2WaitForVsync();
GX2GetSwapStatus(&swapCount, &flipCount, &lastFlip, &lastVsync);
if (flipCount >= swapCount) {
sGpuTimedOut = FALSE;
break;
}
if (waitCount >= 10) {
WHBLogPrint("WHBGfxBeginRender wait for swap timed out");
sGpuTimedOut = TRUE;
break;
}
waitCount++;
GX2WaitForVsync();
}
}

View File

@ -140,6 +140,7 @@ EXPORT(GX2InitSamplerZMFilter);
EXPORT(GX2Flush);
EXPORT(GX2Init);
EXPORT(GX2Shutdown);
EXPORT(GX2ResetGPU);
// gx2/shader.h
EXPORT(GX2CalcGeometryShaderInputRingBufferSize);