Browse Source

D3DPER debug events for DX11

rextimmy 8 years ago
parent
commit
46037622c9

+ 29 - 0
Engine/source/gfx/D3D11/gfxD3D11Device.cpp

@@ -37,6 +37,7 @@
 #include "windowManager/platformWindow.h"
 #include "windowManager/platformWindow.h"
 #include "gfx/D3D11/screenshotD3D11.h"
 #include "gfx/D3D11/screenshotD3D11.h"
 #include "materials/shaderData.h"
 #include "materials/shaderData.h"
+#include <d3d9.h> //ok now stressing out folks, this is just for debug events(D3DPER) :)
 
 
 #ifdef TORQUE_DEBUG
 #ifdef TORQUE_DEBUG
 #include "d3d11sdklayers.h"
 #include "d3d11sdklayers.h"
@@ -1678,4 +1679,32 @@ GFXCubemap * GFXD3D11Device::createCubemap()
    GFXD3D11Cubemap* cube = new GFXD3D11Cubemap();
    GFXD3D11Cubemap* cube = new GFXD3D11Cubemap();
    cube->registerResourceWithDevice(this);
    cube->registerResourceWithDevice(this);
    return cube;
    return cube;
+}
+
+//------------------------------------------------------------------------------
+void GFXD3D11Device::enterDebugEvent(ColorI color, const char *name)
+{
+   // BJGFIX
+   WCHAR  eventName[260];
+   MultiByteToWideChar(CP_ACP, 0, name, -1, eventName, 260);
+
+   D3DPERF_BeginEvent(D3DCOLOR_ARGB(color.alpha, color.red, color.green, color.blue),
+      (LPCWSTR)&eventName);
+}
+
+//------------------------------------------------------------------------------
+void GFXD3D11Device::leaveDebugEvent()
+{
+   D3DPERF_EndEvent();
+}
+
+//------------------------------------------------------------------------------
+void GFXD3D11Device::setDebugMarker(ColorI color, const char *name)
+{
+   // BJGFIX
+   WCHAR  eventName[260];
+   MultiByteToWideChar(CP_ACP, 0, name, -1, eventName, 260);
+
+   D3DPERF_SetMarker(D3DCOLOR_ARGB(color.alpha, color.red, color.green, color.blue),
+      (LPCWSTR)&eventName);
 }
 }

+ 3 - 3
Engine/source/gfx/D3D11/gfxD3D11Device.h

@@ -70,9 +70,9 @@ private:
    virtual GFXWindowTarget *allocWindowTarget(PlatformWindow *window);
    virtual GFXWindowTarget *allocWindowTarget(PlatformWindow *window);
    virtual GFXTextureTarget *allocRenderToTextureTarget();
    virtual GFXTextureTarget *allocRenderToTextureTarget();
 
 
-   virtual void enterDebugEvent(ColorI color, const char *name){};
-   virtual void leaveDebugEvent(){};
-   virtual void setDebugMarker(ColorI color, const char *name){};
+   virtual void enterDebugEvent(ColorI color, const char *name);
+   virtual void leaveDebugEvent();
+   virtual void setDebugMarker(ColorI color, const char *name);
 
 
 protected:
 protected: