summaryrefslogtreecommitdiffstats
path: root/tools/gfx/d3d11
diff options
context:
space:
mode:
authorjsmall-nvidia <jsmall@nvidia.com>2023-07-18 18:45:38 -0400
committerGitHub <noreply@github.com>2023-07-18 15:45:38 -0700
commit1fe5e83f3dcc8ef0efa2dd083ebdfab5d0f101a9 (patch)
tree9ea88993d0b1f5cad76c21ae3a60ed561bdc3c83 /tools/gfx/d3d11
parent4cb3eeb832b5fb29a61f2934b3daa5e42a3d6cde (diff)
nsight Aftermath crash example (#2984)
* Small fixes and improvements around reflection tool. * Make PrettyWriter printing a class. * Aftermath crash demo WIP. * Enable aftermath in test project. * Setting failCount. * Dumping out of source maps. * Improve comments. Simplify handling of compile products. * Other small fixes to aftermath example. * Added Emit SourceLocType. Track sourcemap association meaning. Improved documentation. * Small improvements. * Capture debug information for D3D11/D3D12/Vulkan. * Enable debug info. * Small improvements. * Improve aftermath example README.md.
Diffstat (limited to 'tools/gfx/d3d11')
-rw-r--r--tools/gfx/d3d11/d3d11-device.cpp38
1 files changed, 38 insertions, 0 deletions
diff --git a/tools/gfx/d3d11/d3d11-device.cpp b/tools/gfx/d3d11/d3d11-device.cpp
index c10a608dc..96a5043fb 100644
--- a/tools/gfx/d3d11/d3d11-device.cpp
+++ b/tools/gfx/d3d11/d3d11-device.cpp
@@ -16,6 +16,12 @@
#include "d3d11-helper-functions.h"
+#ifdef GFX_NV_AFTERMATH
+# include "GFSDK_Aftermath.h"
+# include "GFSDK_Aftermath_Defines.h"
+# include "GFSDK_Aftermath_GpuCrashDump.h"
+#endif
+
namespace gfx
{
@@ -23,6 +29,7 @@ using namespace Slang;
namespace d3d11
{
+
SlangResult DeviceImpl::initialize(const Desc& desc)
{
SLANG_RETURN_ON_FAIL(slangContext.initialize(
@@ -148,11 +155,42 @@ SlangResult DeviceImpl::initialize(const Desc& desc)
m_device.writeRef(),
&featureLevel,
m_immediateContext.writeRef());
+
+#ifdef GFX_NV_AFTERMATH
+ if (SLANG_SUCCEEDED(res))
+ {
+ if (deviceCheckFlags & DeviceCheckFlag::UseDebug)
+ {
+ // Initialize Nsight Aftermath for this device.
+ // This combination of flags is not necessarily appropriate for real world usage
+ const uint32_t aftermathFlags =
+ GFSDK_Aftermath_FeatureFlags_EnableMarkers | // Enable event marker tracking.
+ GFSDK_Aftermath_FeatureFlags_CallStackCapturing | // Enable automatic call stack event markers.
+ GFSDK_Aftermath_FeatureFlags_EnableResourceTracking | // Enable tracking of resources.
+ GFSDK_Aftermath_FeatureFlags_GenerateShaderDebugInfo | // Generate debug information for shaders.
+ GFSDK_Aftermath_FeatureFlags_EnableShaderErrorReporting; // Enable additional runtime shader error reporting.
+
+ auto initResult = GFSDK_Aftermath_DX11_Initialize(
+ GFSDK_Aftermath_Version_API,
+ aftermathFlags,
+ m_device);
+
+ if (initResult != GFSDK_Aftermath_Result_Success)
+ {
+ SLANG_ASSERT_FAILURE("Unable to initialize aftermath");
+ // Unable to initialize aftermath
+ return SLANG_FAIL;
+ }
+ }
+ }
+#endif
+
// Check if successfully constructed - if so we are done.
if (SLANG_SUCCEEDED(res))
{
break;
}
+
}
// If res is failure, means all styles have have failed, and so initialization fails.
if (SLANG_FAILED(res))