WinRT: made the Direct3D 11.x 'Debug Layer' be enable-able in any app via a hint
authorDavid Ludwig <dludwig@pobox.com>
Fri, 25 Oct 2013 20:31:43 -0400
changeset 853389cf2a2635d1
parent 8532 0f4be71aa156
child 8534 50177f518fdb
WinRT: made the Direct3D 11.x 'Debug Layer' be enable-able in any app via a hint

To enable the Debug Layer, set the hint, SDL_HINT_RENDER_DIRECT3D11_DEBUG to '1'.

The Debug Layer will be turned off by default, both in Release and Debug builds (of SDL).
include/SDL_hints.h
src/render/direct3d11/SDL_render_d3d11.cpp
     1.1 --- a/include/SDL_hints.h	Sun Sep 22 23:17:25 2013 -0400
     1.2 +++ b/include/SDL_hints.h	Fri Oct 25 20:31:43 2013 -0400
     1.3 @@ -118,6 +118,20 @@
     1.4  #define SDL_HINT_RENDER_VSYNC               "SDL_RENDER_VSYNC"
     1.5  
     1.6  /**
     1.7 + *  \brief  A variable controlling whether to enable Direct3D 11+'s Debug Layer.
     1.8 + *
     1.9 + *  This variable does not have any effect on the Direct3D 9 based renderer,
    1.10 + *  which is used in Win32-based (aka Windows Desktop) apps.
    1.11 + *
    1.12 + *  This variable can be set to the following values:
    1.13 + *    "0"       - Disable Debug Layer use
    1.14 + *    "1"       - Enable Debug Lyaer use
    1.15 + *
    1.16 + *  By default, SDL does not use Direct3D Debug Layer.
    1.17 + */
    1.18 +#define SDL_HINT_RENDER_DIRECT3D11_DEBUG    "SDL_HINT_RENDER_DIRECT3D11_DEBUG"
    1.19 +
    1.20 +/**
    1.21   *  \brief  A variable controlling whether the X11 VidMode extension should be used.
    1.22   *
    1.23   *  This variable can be set to the following values:
     2.1 --- a/src/render/direct3d11/SDL_render_d3d11.cpp	Sun Sep 22 23:17:25 2013 -0400
     2.2 +++ b/src/render/direct3d11/SDL_render_d3d11.cpp	Fri Oct 25 20:31:43 2013 -0400
     2.3 @@ -35,7 +35,7 @@
     2.4  
     2.5  extern "C" {
     2.6  #include "../../core/windows/SDL_windows.h"
     2.7 -//#include "SDL_hints.h"
     2.8 +#include "SDL_hints.h"
     2.9  //#include "SDL_loadso.h"
    2.10  #include "SDL_system.h"
    2.11  #include "SDL_syswm.h"
    2.12 @@ -326,10 +326,13 @@
    2.13      // than the API default. It is required for compatibility with Direct2D.
    2.14      UINT creationFlags = D3D11_CREATE_DEVICE_BGRA_SUPPORT;
    2.15  
    2.16 -#if defined(_DEBUG)
    2.17 -    // If the project is in a debug build, enable debugging via SDK Layers with this flag.
    2.18 -    creationFlags |= D3D11_CREATE_DEVICE_DEBUG;
    2.19 -#endif
    2.20 +    // Make sure Direct3D's debugging feature gets used, if the app requests it.
    2.21 +    const char *hint = SDL_GetHint(SDL_HINT_RENDER_DIRECT3D11_DEBUG);
    2.22 +    if (hint) {
    2.23 +        if (*hint == '1') {
    2.24 +            creationFlags |= D3D11_CREATE_DEVICE_DEBUG;
    2.25 +        }
    2.26 +    }
    2.27  
    2.28      // This array defines the set of DirectX hardware feature levels this app will support.
    2.29      // Note the ordering should be preserved.