From 78f3a80cf281e51ac976b8aaaa4ff8a28433b5ad Mon Sep 17 00:00:00 2001 From: David Ludwig Date: Sun, 8 Feb 2015 15:44:15 -0500 Subject: [PATCH] WinRT: made note that VSync is always enabled on WinPhone, due to OS Windows Phone does not appear to allow VSync to be turned off. Doing so appears to either result in content not getting drawn (when the D3D debug runtime is turned off), or forcing VSync back on and logging an error (when the D3D debug runtime is turned on). VSync had been getting turned on anyways, this change just notes such: - via the WinRT README - by always setting the SDL_RENDERER_PRESENTVSYNC flag when creating an SDL_Renderer on Windows Phone --- docs/README-winrt.md | 5 +++++ src/render/direct3d11/SDL_render_d3d11.c | 15 +++++++++++++++ 2 files changed, 20 insertions(+) diff --git a/docs/README-winrt.md b/docs/README-winrt.md index fdc669f10..e188d7791 100644 --- a/docs/README-winrt.md +++ b/docs/README-winrt.md @@ -112,6 +112,11 @@ Here is a rough list of what works, and what doens't: supported by WinRT itself. * joysticks and game controllers that aren't supported by Microsoft's XInput API. + * turning off VSync when rendering on Windows Phone. Attempts to turn VSync + off on Windows Phone result either in Direct3D not drawing anything, or it + forcing VSync back on. As such, SDL_RENDERER_PRESENTVSYNC will always get + turned-on on Windows Phone. This limitation is not present in non-Phone + WinRT (such as Windows 8.x), where turning off VSync appears to work. * probably anything else that's not listed as supported diff --git a/src/render/direct3d11/SDL_render_d3d11.c b/src/render/direct3d11/SDL_render_d3d11.c index f99fdb1d5..c8a487a6b 100644 --- a/src/render/direct3d11/SDL_render_d3d11.c +++ b/src/render/direct3d11/SDL_render_d3d11.c @@ -829,9 +829,24 @@ D3D11_CreateRenderer(SDL_Window * window, Uint32 flags) renderer->info.flags = (SDL_RENDERER_ACCELERATED | SDL_RENDERER_TARGETTEXTURE); renderer->driverdata = data; +#if WINAPI_FAMILY == WINAPI_FAMILY_PHONE_APP + /* VSync is required in Windows Phone, at least for Win Phone 8.0 and 8.1. + * Failure to use it seems to either result in: + * + * - with the D3D11 debug runtime turned OFF, vsync seemingly gets turned + * off (framerate doesn't get capped), but nothing appears on-screen + * + * - with the D3D11 debug runtime turned ON, vsync gets automatically + * turned back on, and the following gets output to the debug console: + * + * DXGI ERROR: IDXGISwapChain::Present: Interval 0 is not supported, changed to Interval 1. [ UNKNOWN ERROR #1024: ] + */ + renderer->info.flags |= SDL_RENDERER_PRESENTVSYNC; +#else if ((flags & SDL_RENDERER_PRESENTVSYNC)) { renderer->info.flags |= SDL_RENDERER_PRESENTVSYNC; } +#endif /* HACK: make sure the SDL_Renderer references the SDL_Window data now, in * order to give init functions access to the underlying window handle: