From 1fe5e83f3dcc8ef0efa2dd083ebdfab5d0f101a9 Mon Sep 17 00:00:00 2001 From: jsmall-nvidia Date: Tue, 18 Jul 2023 18:45:38 -0400 Subject: 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. --- tools/gfx/d3d11/d3d11-device.cpp | 38 ++++++++++++++++++++++++++++++++++++++ 1 file changed, 38 insertions(+) (limited to 'tools/gfx/d3d11') 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)) -- cgit v1.2.3