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 8533 89cf2a2635d1
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
--- a/include/SDL_hints.h	Sun Sep 22 23:17:25 2013 -0400
+++ b/include/SDL_hints.h	Fri Oct 25 20:31:43 2013 -0400
@@ -118,6 +118,20 @@
 #define SDL_HINT_RENDER_VSYNC               "SDL_RENDER_VSYNC"
 
 /**
+ *  \brief  A variable controlling whether to enable Direct3D 11+'s Debug Layer.
+ *
+ *  This variable does not have any effect on the Direct3D 9 based renderer,
+ *  which is used in Win32-based (aka Windows Desktop) apps.
+ *
+ *  This variable can be set to the following values:
+ *    "0"       - Disable Debug Layer use
+ *    "1"       - Enable Debug Lyaer use
+ *
+ *  By default, SDL does not use Direct3D Debug Layer.
+ */
+#define SDL_HINT_RENDER_DIRECT3D11_DEBUG    "SDL_HINT_RENDER_DIRECT3D11_DEBUG"
+
+/**
  *  \brief  A variable controlling whether the X11 VidMode extension should be used.
  *
  *  This variable can be set to the following values:
--- a/src/render/direct3d11/SDL_render_d3d11.cpp	Sun Sep 22 23:17:25 2013 -0400
+++ b/src/render/direct3d11/SDL_render_d3d11.cpp	Fri Oct 25 20:31:43 2013 -0400
@@ -35,7 +35,7 @@
 
 extern "C" {
 #include "../../core/windows/SDL_windows.h"
-//#include "SDL_hints.h"
+#include "SDL_hints.h"
 //#include "SDL_loadso.h"
 #include "SDL_system.h"
 #include "SDL_syswm.h"
@@ -326,10 +326,13 @@
     // than the API default. It is required for compatibility with Direct2D.
     UINT creationFlags = D3D11_CREATE_DEVICE_BGRA_SUPPORT;
 
-#if defined(_DEBUG)
-    // If the project is in a debug build, enable debugging via SDK Layers with this flag.
-    creationFlags |= D3D11_CREATE_DEVICE_DEBUG;
-#endif
+    // Make sure Direct3D's debugging feature gets used, if the app requests it.
+    const char *hint = SDL_GetHint(SDL_HINT_RENDER_DIRECT3D11_DEBUG);
+    if (hint) {
+        if (*hint == '1') {
+            creationFlags |= D3D11_CREATE_DEVICE_DEBUG;
+        }
+    }
 
     // This array defines the set of DirectX hardware feature levels this app will support.
     // Note the ordering should be preserved.