WinRT: made note that VSync is always enabled on WinPhone, due to OS
authorDavid Ludwig
Sun, 08 Feb 2015 15:44:15 -0500
changeset 93353eb0896ecb91
parent 9334 5eb5ab33286e
child 9336 1a1ec75b608c
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
src/render/direct3d11/SDL_render_d3d11.c
     1.1 --- a/docs/README-winrt.md	Sun Feb 08 21:25:37 2015 +0100
     1.2 +++ b/docs/README-winrt.md	Sun Feb 08 15:44:15 2015 -0500
     1.3 @@ -112,6 +112,11 @@
     1.4      supported by WinRT itself.
     1.5    * joysticks and game controllers that aren't supported by Microsoft's XInput
     1.6      API.
     1.7 +  * turning off VSync when rendering on Windows Phone.  Attempts to turn VSync
     1.8 +    off on Windows Phone result either in Direct3D not drawing anything, or it
     1.9 +    forcing VSync back on.  As such, SDL_RENDERER_PRESENTVSYNC will always get
    1.10 +    turned-on on Windows Phone.  This limitation is not present in non-Phone
    1.11 +    WinRT (such as Windows 8.x), where turning off VSync appears to work.
    1.12    * probably anything else that's not listed as supported
    1.13  
    1.14  
     2.1 --- a/src/render/direct3d11/SDL_render_d3d11.c	Sun Feb 08 21:25:37 2015 +0100
     2.2 +++ b/src/render/direct3d11/SDL_render_d3d11.c	Sun Feb 08 15:44:15 2015 -0500
     2.3 @@ -829,9 +829,24 @@
     2.4      renderer->info.flags = (SDL_RENDERER_ACCELERATED | SDL_RENDERER_TARGETTEXTURE);
     2.5      renderer->driverdata = data;
     2.6  
     2.7 +#if WINAPI_FAMILY == WINAPI_FAMILY_PHONE_APP
     2.8 +    /* VSync is required in Windows Phone, at least for Win Phone 8.0 and 8.1.
     2.9 +     * Failure to use it seems to either result in:
    2.10 +     *
    2.11 +     *  - with the D3D11 debug runtime turned OFF, vsync seemingly gets turned
    2.12 +     *    off (framerate doesn't get capped), but nothing appears on-screen
    2.13 +     *
    2.14 +     *  - with the D3D11 debug runtime turned ON, vsync gets automatically
    2.15 +     *    turned back on, and the following gets output to the debug console:
    2.16 +     *    
    2.17 +     *    DXGI ERROR: IDXGISwapChain::Present: Interval 0 is not supported, changed to Interval 1. [ UNKNOWN ERROR #1024: ] 
    2.18 +     */
    2.19 +    renderer->info.flags |= SDL_RENDERER_PRESENTVSYNC;
    2.20 +#else
    2.21      if ((flags & SDL_RENDERER_PRESENTVSYNC)) {
    2.22          renderer->info.flags |= SDL_RENDERER_PRESENTVSYNC;
    2.23      }
    2.24 +#endif
    2.25  
    2.26      /* HACK: make sure the SDL_Renderer references the SDL_Window data now, in
    2.27       * order to give init functions access to the underlying window handle: