Added support for simulated vsync in the renderer

This kicks in if the platform doesn't support vsync directly, or if the present fails for some reason (e.g. minimized on some platforms)

Fixes https://github.com/libsdl-org/SDL/issues/5134
This commit is contained in:
Sam Lantinga
2022-09-15 01:00:12 -07:00
parent 339f7a2f6b
commit d744aafb05
15 changed files with 115 additions and 37 deletions

View File

@@ -2288,7 +2288,7 @@ done:
return status;
}
static void
static int
D3D11_RenderPresent(SDL_Renderer * renderer)
{
D3D11_RenderData *data = (D3D11_RenderData *) renderer->driverdata;
@@ -2334,7 +2334,7 @@ D3D11_RenderPresent(SDL_Renderer * renderer)
*
* TODO, WinRT: consider throwing an exception if D3D11_RenderPresent fails, especially if there is a way to salvage debug info from users' machines
*/
if ( result == DXGI_ERROR_DEVICE_REMOVED ) {
if (result == DXGI_ERROR_DEVICE_REMOVED) {
D3D11_HandleDeviceLost(renderer);
} else if (result == DXGI_ERROR_INVALID_CALL) {
/* We probably went through a fullscreen <-> windowed transition */
@@ -2342,7 +2342,9 @@ D3D11_RenderPresent(SDL_Renderer * renderer)
} else {
WIN_SetErrorFromHRESULT(SDL_COMPOSE_ERROR("IDXGISwapChain::Present"), result);
}
return -1;
}
return 0;
}
#if WINAPI_FAMILY == WINAPI_FAMILY_PHONE_APP