adding aftermath debugging and fixing forward plus

This commit is contained in:
Dynamitos
2021-06-04 18:27:49 +02:00
parent e00b382d4a
commit 22adb08bfc
40 changed files with 4669 additions and 112 deletions
+483
View File
@@ -0,0 +1,483 @@
/*
* Copyright (c) 2017-2021, NVIDIA CORPORATION. All rights reserved.
*
* NVIDIA CORPORATION and its licensors retain all intellectual property
* and proprietary rights in and to this software, related documentation
* and any modifications thereto. Any use, reproduction, disclosure or
* distribution of this software and related documentation without an express
* license agreement from NVIDIA CORPORATION is strictly prohibited.
*/
/*
* █████ █████ ██████ ████ ████ ███████ ████ ██████ ██ ██
* ██ ██ ██ ██ ██ ██ ██ ██ ██ ██ ██ ██ ██ ██ ██
* ██ ██ ██ ██ ██ ██ ██ ██ ██ ██ ██ ██ ██ ██ ██
* ██████ ████ ██ ████ █████ ██ ██ ██ ██████ ██ ███████
* ██ ██ ██ ██ ██ ██ ██ ██ ██ ██ ██ ██ ██ ██
* ██ ██ ██ ██ █████ ██ ██ ██ ██ ██ ██ ██ ██ ██ DEBUGGER
* ██ ██
* ████████████████████████████████████████████████████████ ██ █ ██ ████████████
*
*
* HOW TO USE AFTERMATH for DX11 and DX12
* --------------------------------------
*
* Call 'GFSDK_Aftermath_DXxx_Initialize', to initialize the library and to enable
* the desired Aftermath feature set. See 'GFSDK_Aftermath_FeatureFlags' below for
* the list of supported features.
* This must be done before any other library calls are made, and the method must
* return 'GFSDK_Aftermath_Result_Success' for initialization to be complete.
*
* Initialization of Aftermath may fail for a variety of reasons, including:
*
* o) The initialization function was already called for the device:
* GFSDK_Aftermath_Result_FAIL_AlreadyInitialized.
*
*
* o) Aftermath isn't supported on the GPU associated with the device or the NVIDIA
* display driver version installed:
* GFSDK_Aftermath_Result_FAIL_InvalidAdapter,
* GFSDK_Aftermath_Result_FAIL_DriverInitFailed,
* GFSDK_Aftermath_Result_FAIL_DriverVersionNotSupported,
* GFSDK_Aftermath_Result_FAIL_NvApiIncompatible.
*
*
* o) A D3D API debug layer, such as PIX, was detected that is incompatible with
* Aftermath:
* GFSDK_Aftermath_Result_FAIL_D3dDllInterceptionNotSupported
*
*
* o) Aftermath was disabled on the system by the current user setting the
* 'HKEY_CURRENT_USER\Software\NVIDIA Corporation\Nsight Aftermath\ForceOff'
* Windows registry key:
* GFSDK_Aftermath_Result_FAIL_Disabled
*
*
* After detecting D3D device lost (TDR):
*
* o) To query the fault reason after TDR, use the 'GFSDK_Aftermath_GetDeviceStatus'
* call. See 'GFSDK_Aftermath_Device_Status', for the full list of possible
* status.
*
*
* o) In the event of a GPU page fault, use the'GFSDK_Aftermath_GetPageFaultInformation'
* method to return more information about what might of gone wrong. A GPU VA is
* returned, along with the resource descriptor of the resource that VA lands in.
* NOTE: It's not 100% certain that this is the resource which caused the fault,
* only that the faulting VA lands within this resource in memory.
*
*
* Optionally, instrument the application with Aftermath event markers:
*
* 1) For each commandlist/device context you expect to use with Aftermath,
* initialize them using the 'GFSDK_Aftermath_DXxx_CreateContextHandle',
* function.
*
*
* 2) Call 'GFSDK_Aftermath_SetEventMarker', to inject an event
* marker directly into the command stream at that point.
*
* PERFORMANCE TIP:
*
* Do not use 'GFSDK_Aftermath_SetEventMarker' in high frequency code paths.
* Injecting event markers introduces considerable CPU overhead. For reduced CPU
* overhead, use 'GFSDK_Aftermath_SetEventMarker' with markerSize=0. This
* instructs Aftermath not to allocate and copy off memory internally, relying on
* the application to manage marker pointers itself.
*
*
* 3) Once TDR/hang occurs, call the 'GFSDK_Aftermath_GetData' API
* to fetch the event marker last processed by the GPU for each context.
* This API also supports fetching the current execution state for each
* the GPU.
*
*
* 4) Before the app shuts down, each Aftermath context handle must be cleaned
* up, this is done with the 'GFSDK_Aftermath_ReleaseContextHandle' call.
*
*
* HOW TO USE AFTERMATH for Vulkan
* -------------------------------
*
* For Vulkan use the VK_NV_device_diagnostics_config extension to initialize and
* configure the Aftermath feature set to use.
*
* Use the VK_NV_device_diagnostic_checkpoints extension to add event markers into
* the command stream.
*
*/
#ifndef GFSDK_Aftermath_H
#define GFSDK_Aftermath_H
#include "GFSDK_Aftermath_Defines.h"
#pragma pack(push, 8)
#ifdef __cplusplus
extern "C" {
#endif
// Here is defined a set of features that can be enabled/disable when using Aftermath
GFSDK_AFTERMATH_DECLARE_ENUM(FeatureFlags)
{
// The minimal flag only allows use of the GetDeviceStatus entry point.
GFSDK_Aftermath_FeatureFlags_Minimum = 0x00000000,
// With this flag set, the SetEventMarker and GetData entry points are available.
//
// Using event markers should be considered carefully as they can cause very high
// CPU overhead when used in high frequency code paths.
//
GFSDK_Aftermath_FeatureFlags_EnableMarkers = 0x00000001,
// With this flag set, resources are tracked, and information about
// possible page fault candidates can be accessed using GetPageFaultInformation.
GFSDK_Aftermath_FeatureFlags_EnableResourceTracking = 0x00000002,
// With this flag set, event markers are automatically set for all draw calls,
// compute dispatches and copy operations to capture the call stack for the
// corresponding API call as the event marker payload.
// Requires also GFSDK_Aftermath_FeatureFlags_EnableMarkers to be set.
//
// Using this option should be considered carefully. Enabling call stack capturing
// can cause considerable CPU overhead.
//
GFSDK_Aftermath_FeatureFlags_CallStackCapturing = 0x40000000,
// With this flag set, shader debug information is generated.
// Not supported for UWP applications.
GFSDK_Aftermath_FeatureFlags_GenerateShaderDebugInfo = 0x00000008,
// Use all Aftermath features
// Be careful when using this! Some features can cause considerable performance overhead,
// for example, GFSDK_Aftermath_FeatureFlags_EnableMarkers.
GFSDK_Aftermath_FeatureFlags_Maximum = GFSDK_Aftermath_FeatureFlags_Minimum |
GFSDK_Aftermath_FeatureFlags_EnableMarkers |
GFSDK_Aftermath_FeatureFlags_EnableResourceTracking |
GFSDK_Aftermath_FeatureFlags_CallStackCapturing |
GFSDK_Aftermath_FeatureFlags_GenerateShaderDebugInfo,
};
#if defined(__d3d11_h__) || defined(__d3d12_h__)
// Used with Aftermath entry points to reference an API object.
GFSDK_AFTERMATH_DECLARE_HANDLE(GFSDK_Aftermath_ContextHandle);
GFSDK_AFTERMATH_DECLARE_HANDLE(GFSDK_Aftermath_ResourceHandle);
// Used with, 'GFSDK_Aftermath_GetData'. Filled with information,
// about each requested context.
typedef struct GFSDK_Aftermath_ContextData
{
GFSDK_AFTERMATH_DECLARE_POINTER_MEMBER(void*, markerData);
uint32_t markerSize;
GFSDK_Aftermath_Context_Status status;
} GFSDK_Aftermath_ContextData;
// Minimal description of a graphics resource.
typedef struct GFSDK_Aftermath_ResourceDescriptor
{
// This is available in DX12 only and only if the application registers the
// resource pointers using GFSDK_Aftermath_DX12_RegisterResource().
#ifdef __d3d12_h__
GFSDK_AFTERMATH_DECLARE_POINTER_MEMBER(ID3D12Resource*, pAppResource);
#else
GFSDK_AFTERMATH_DECLARE_POINTER_MEMBER(void*, pAppResource);
#endif
uint64_t size;
uint32_t width;
uint32_t height;
uint32_t depth;
uint32_t mipLevels;
uint32_t format; // DXGI_FORMAT
GFSDK_AFTERMATH_DECLARE_BOOLEAN_MEMBER(bIsBufferHeap);
GFSDK_AFTERMATH_DECLARE_BOOLEAN_MEMBER(bIsStaticTextureHeap);
GFSDK_AFTERMATH_DECLARE_BOOLEAN_MEMBER(bIsRtvDsvTextureHeap);
GFSDK_AFTERMATH_DECLARE_BOOLEAN_MEMBER(bPlacedResource);
GFSDK_AFTERMATH_DECLARE_BOOLEAN_MEMBER(bWasDestroyed);
} GFSDK_Aftermath_ResourceDescriptor
;
// Used with GFSDK_Aftermath_GetPageFaultInformation
typedef struct GFSDK_Aftermath_PageFaultInformation
{
uint64_t faultingGpuVA;
GFSDK_Aftermath_ResourceDescriptor resourceDesc;
GFSDK_AFTERMATH_DECLARE_BOOLEAN_MEMBER(bHasPageFaultOccured);
} GFSDK_Aftermath_PageFaultInformation;
/////////////////////////////////////////////////////////////////////////
// GFSDK_Aftermath_DX11_Initialize
// GFSDK_Aftermath_DX12_Initialize
// ---------------------------------
//
// [pDx11Device]; DX11-Only
// the current dx11 device pointer.
//
// [pDx12Device]; DX12-Only
// the current dx12 device pointer.
//
// flags;
// set of features to enable when initializing Aftermath
//
// version;
// Must be set to GFSDK_Aftermath_Version_API. Used for checking
// against library version.
//
//// DESCRIPTION;
// Library must be initialized before any other call is made.
// This should be done after device creation.
// Aftermath currently only supports one D3D device,
// the first one that is initialized.
//
/////////////////////////////////////////////////////////////////////////
#ifdef __d3d11_h__
GFSDK_Aftermath_API GFSDK_Aftermath_DX11_Initialize(GFSDK_Aftermath_Version version, uint32_t flags, ID3D11Device* const pDx11Device);
#endif
#ifdef __d3d12_h__
GFSDK_Aftermath_API GFSDK_Aftermath_DX12_Initialize(GFSDK_Aftermath_Version version, uint32_t flags, ID3D12Device* const pDx12Device);
#endif
/////////////////////////////////////////////////////////////////////////
// GFSDK_Aftermath_DX11_CreateContextHandle
// GFSDK_Aftermath_DX12_CreateContextHandle
// ---------------------------------
//
// (pDx11DeviceContext); DX11-Only
// Device context to use with Aftermath.
//
// (pDx12Unknown); DX12-Only
// Command list, Command Queue, or Device to use with Aftermath
// If a device, must be the same device given to GFSDK_Aftermath_DX12_Initialize()
//
// pOutContextHandle;
// The context handle for the specified context/command list/command queue/device
// to be used with future Aftermath calls.
//
//// DESCRIPTION;
// Before Aftermath event markers can be inserted,
// a context handle reference must first be fetched.
//
/////////////////////////////////////////////////////////////////////////
#ifdef __d3d11_h__
GFSDK_Aftermath_API GFSDK_Aftermath_DX11_CreateContextHandle(ID3D11DeviceContext* const pDx11DeviceContext, GFSDK_Aftermath_ContextHandle* pOutContextHandle);
#endif
#ifdef __d3d12_h__
GFSDK_Aftermath_API GFSDK_Aftermath_DX12_CreateContextHandle(IUnknown* const pDx12Unknown, GFSDK_Aftermath_ContextHandle* pOutContextHandle);
#endif
/////////////////////////////////////////////////////////////////////////
// GFSDK_Aftermath_API GFSDK_Aftermath_ReleaseContextHandle
// -------------------------------------
//
// contextHandle;
// Context to release
//
// DESCRIPTION;
// Cleans up any resources associated with an Aftermath context
//
/////////////////////////////////////////////////////////////////////////
GFSDK_Aftermath_API GFSDK_Aftermath_ReleaseContextHandle(const GFSDK_Aftermath_ContextHandle contextHandle);
/////////////////////////////////////////////////////////////////////////
// GFSDK_Aftermath_SetEventMarker
// -------------------------------------
//
// contextHandle;
// Command list currently being populated.
//
// markerData;
// Pointer to data used for event marker.
// NOTE: If markerSize is also provided, an internal copy will be
// made of this data. In that case there is no need to keep it
// around after this call - stack alloc is safe.
//
// markerSize;
// Size of event marker data in bytes.
// NOTE: Passing a 0 for this parameter is valid, and will instruct
// Aftermath to only copy off the pointer supplied by markerData,
// rather than internally making a copy. This, however, precludes
// Aftermath from storing the marker data in GPU crash dumps.
// NOTE: Aftermath will internally truncate marker data to a maximum
// size of 1024 bytes. Use markerSize=0 and manually manage
// memory for markers if the application requires larger ones.
//
// DESCRIPTION;
// Drops a event into the command stream with a payload that can be
// linked back to the data given here, 'markerData'. It's
// safe to call from multiple threads simultaneously, normal D3D
// API threading restrictions apply.
//
// Using event markers should be considered carefully as they can cause considerable
// CPU overhead when used in high frequency code paths.
//
/////////////////////////////////////////////////////////////////////////
GFSDK_Aftermath_API GFSDK_Aftermath_SetEventMarker(const GFSDK_Aftermath_ContextHandle contextHandle, const void* markerData, const uint32_t markerSize);
/////////////////////////////////////////////////////////////////////////
// GFSDK_Aftermath_GetData
// ------------------------------
//
// numContexts;
// Number of contexts to fetch information for.
//
// pContextHandles;
// Array of contexts containing Aftermath event markers.
//
// pOutContextData;
// OUTPUT: context data for each context requested. Contains event
// last reached on the GPU, and status of context if
// applicable (DX12-Only).
// NOTE: must allocate enough space for 'numContexts' worth of structures.
// stack allocation is fine.
//
// DESCRIPTION;
// Once a TDR/crash/hang has occurred (or whenever you like), call
// this API to retrieve the event last processed by the GPU on the
// given context.
//
/////////////////////////////////////////////////////////////////////////
GFSDK_Aftermath_API GFSDK_Aftermath_GetData(const uint32_t numContexts, const GFSDK_Aftermath_ContextHandle* pContextHandles, GFSDK_Aftermath_ContextData* pOutContextData);
/////////////////////////////////////////////////////////////////////////
// GFSDK_Aftermath_GetContextError()
// ------------------------------
//
// pContextData;
// Context data for which to determine error status.
//
// DESCRIPTION;
// Call this to determine the detailed failure reason for GFSDK_Aftermath_ContextData
// with 'status == GFSDK_Aftermath_Context_Status_Invalid'.
//
/////////////////////////////////////////////////////////////////////////
GFSDK_Aftermath_API GFSDK_Aftermath_GetContextError(const GFSDK_Aftermath_ContextData* pContextData);
/////////////////////////////////////////////////////////////////////////
// GFSDK_Aftermath_GetDeviceStatus
// ---------------------------------
//
// pOutStatus;
// OUTPUT: Device status.
//
//// DESCRIPTION;
// Return the status of a D3D device. See GFSDK_Aftermath_Device_Status.
//
/////////////////////////////////////////////////////////////////////////
GFSDK_Aftermath_API GFSDK_Aftermath_GetDeviceStatus(GFSDK_Aftermath_Device_Status* pOutStatus);
/////////////////////////////////////////////////////////////////////////
// GFSDK_Aftermath_GetPageFaultInformation
// ---------------------------------
//
// pOutPageFaultInformation;
// OUTPUT: Information about a page fault which may have occurred.
//
//// DESCRIPTION;
// Return any information available about a recent page fault which
// may have occurred, causing a device removed scenario.
// See GFSDK_Aftermath_PageFaultInformation.
//
// Requires WDDMv2 (Windows 10) or later
//
/////////////////////////////////////////////////////////////////////////
GFSDK_Aftermath_API GFSDK_Aftermath_GetPageFaultInformation(GFSDK_Aftermath_PageFaultInformation* pOutPageFaultInformation);
/////////////////////////////////////////////////////////////////////////
// GFSDK_Aftermath_DX12_RegisterResource
// ---------------------------------
//
// pResource;
// ID3D12Resource to register.
//
// pOutResourceHandle;
// OUTPUT: Aftermath resource handle for the resource that was registered.
//
//// DESCRIPTION;
// Register an ID3D12Resource with Aftermath. This allows Aftermath
// to map a GpuVA of a page fault to the corresponding ID3D12Resource.
//
// NOTE1: This function is only supported on Windows 10 RS4 and RS5.
// It will return GFSDK_Aftermath_Result_FAIL_D3dDllNotSupported, if the
// version of the D3D DLL is not supported.
// NOTE2: This function is not supported in UWP applications.
// NOTE3: This function is not compatible with graphics debuggers, such as
// Nsight Graphics or the Visual Studio Graphics Debugger. It may fail with
// GFSDK_Aftermath_Result_FAIL_D3dDllInterceptionNotSupported when called,
// if such a debugger is active.
//
// This is a BETA FEATURE and may not work with all versions of Windows.
//
/////////////////////////////////////////////////////////////////////////
#if defined(__d3d12_h__)
GFSDK_Aftermath_API GFSDK_Aftermath_DX12_RegisterResource(ID3D12Resource* const pResource, GFSDK_Aftermath_ResourceHandle* pOutResourceHandle);
#endif
/////////////////////////////////////////////////////////////////////////
// GFSDK_Aftermath_DX12_UnregisterResource
// ---------------------------------
//
// resourceHandle;
// Aftermath resource handle for a resource that was reagister earlier
// with GFSDK_Aftermath_DX12_RegisterResource().
//
//// DESCRIPTION;
// Unregisters a previously registered resource.
//
// This is a BETA FEATURE and may not work with all versions of Windows.
//
/////////////////////////////////////////////////////////////////////////
#if defined(__d3d12_h__)
GFSDK_Aftermath_API GFSDK_Aftermath_DX12_UnregisterResource(const GFSDK_Aftermath_ResourceHandle resourceHandle);
#endif
/////////////////////////////////////////////////////////////////////////
//
// NOTE: Function table provided - if dynamic loading is preferred.
//
/////////////////////////////////////////////////////////////////////////
#if defined(__d3d11_h__)
GFSDK_Aftermath_PFN(GFSDK_AFTERMATH_CALL *PFN_GFSDK_Aftermath_DX11_Initialize)(GFSDK_Aftermath_Version version, uint32_t flags, ID3D11Device* const pDx11Device);
GFSDK_Aftermath_PFN(GFSDK_AFTERMATH_CALL *PFN_GFSDK_Aftermath_DX11_CreateContextHandle)(ID3D11DeviceContext* const pDx11DeviceContext, GFSDK_Aftermath_ContextHandle* pOutContextHandle);
#endif
#if defined(__d3d12_h__)
GFSDK_Aftermath_PFN(GFSDK_AFTERMATH_CALL *PFN_GFSDK_Aftermath_DX12_Initialize)(GFSDK_Aftermath_Version version, uint32_t flags, ID3D12Device* const pDx12Device);
GFSDK_Aftermath_PFN(GFSDK_AFTERMATH_CALL *PFN_GFSDK_Aftermath_DX12_CreateContextHandle)(IUnknown* const pDx12CommandList, GFSDK_Aftermath_ContextHandle* pOutContextHandle);
#endif
#if defined(__d3d11_h__) || defined(__d3d12_h__)
GFSDK_Aftermath_PFN(GFSDK_AFTERMATH_CALL *PFN_GFSDK_Aftermath_ReleaseContextHandle)(const GFSDK_Aftermath_ContextHandle contextHandle);
GFSDK_Aftermath_PFN(GFSDK_AFTERMATH_CALL *PFN_GFSDK_Aftermath_SetEventMarker)(const GFSDK_Aftermath_ContextHandle contextHandle, const void* markerData, const uint32_t markerSize);
GFSDK_Aftermath_PFN(GFSDK_AFTERMATH_CALL *PFN_GFSDK_Aftermath_GetData)(const uint32_t numContexts, const GFSDK_Aftermath_ContextHandle* ppContextHandles, GFSDK_Aftermath_ContextData* pOutContextData);
GFSDK_Aftermath_PFN(GFSDK_AFTERMATH_CALL *PFN_GFSDK_Aftermath_GetContextError)(const GFSDK_Aftermath_ContextData* pContextData);
GFSDK_Aftermath_PFN(GFSDK_AFTERMATH_CALL *PFN_GFSDK_Aftermath_GetDeviceStatus)(GFSDK_Aftermath_Device_Status* pOutStatus);
GFSDK_Aftermath_PFN(GFSDK_AFTERMATH_CALL *PFN_GFSDK_Aftermath_GetPageFaultInformation)(GFSDK_Aftermath_PageFaultInformation* pOutPageFaultInformation);
#endif
#if defined(__d3d12_h__)
GFSDK_Aftermath_PFN(GFSDK_AFTERMATH_CALL *PFN_GFSDK_Aftermath_DX12_RegisterResource)(ID3D12Resource* const pResource, GFSDK_Aftermath_ResourceHandle* pOutResourceHandle);
GFSDK_Aftermath_PFN(GFSDK_AFTERMATH_CALL *PFN_GFSDK_Aftermath_DX12_UnregisterResource)(const GFSDK_Aftermath_ResourceHandle resourceHandle);
#endif
#endif // defined(__d3d11_h__) || defined(__d3d12_h__)
#if defined(VULKAN_H_)
// See VK_NV_device_diagnostics_config
// See VK_NV_device_diagnostic_checkpoints
#endif
#ifdef __cplusplus
} // extern "C"
#endif
#pragma pack(pop)
#endif // GFSDK_Aftermath_H
+236
View File
@@ -0,0 +1,236 @@
/*
* Copyright (c) 2016-2021, NVIDIA CORPORATION. All rights reserved.
*
* NVIDIA CORPORATION and its licensors retain all intellectual property
* and proprietary rights in and to this software, related documentation
* and any modifications thereto. Any use, reproduction, disclosure or
* distribution of this software and related documentation without an express
* license agreement from NVIDIA CORPORATION is strictly prohibited.
*/
/*
* █████ █████ ██████ ████ ████ ███████ ████ ██████ ██ ██
* ██ ██ ██ ██ ██ ██ ██ ██ ██ ██ ██ ██ ██ ██ ██
* ██ ██ ██ ██ ██ ██ ██ ██ ██ ██ ██ ██ ██ ██ ██
* ██████ ████ ██ ████ █████ ██ ██ ██ ██████ ██ ███████
* ██ ██ ██ ██ ██ ██ ██ ██ ██ ██ ██ ██ ██ ██
* ██ ██ ██ ██ █████ ██ ██ ██ ██ ██ ██ ██ ██ ██ DEBUGGER
* ██ ██
* ████████████████████████████████████████████████████████ ██ █ ██ ████████████
*/
#ifndef GFSDK_Aftermath_Defines_H
#define GFSDK_Aftermath_Defines_H
#if defined(_MSC_VER)
#if defined(_M_X86)
#define GFSDK_AFTERMATH_CALL __cdecl
#else
#define GFSDK_AFTERMATH_CALL
#endif
#elif defined(__clang__) || defined(__GNUC__)
#if defined(__i386__)
#define GFSDK_AFTERMATH_CALL __attribute__((cdecl))
#else
#define GFSDK_AFTERMATH_CALL
#endif
#else
#error "Unsupported compiler"
#endif
#ifdef __cplusplus
#include <cstdint>
#else
#include <stdint.h>
#include <stdbool.h>
#endif
// Library stuff...
#define GFSDK_Aftermath_PFN typedef GFSDK_Aftermath_Result
#if defined(_MSC_VER)
#ifdef EXPORTS
#define GFSDK_Aftermath_DLLSPEC __declspec(dllexport)
#else
#define GFSDK_Aftermath_DLLSPEC
#endif
#elif defined(__clang__) || defined(__GNUC__)
#define GFSDK_Aftermath_DLLSPEC __attribute__((visibility("default")))
#endif
#ifdef __cplusplus
#define GFSDK_Aftermath_API extern "C" GFSDK_Aftermath_DLLSPEC GFSDK_Aftermath_Result GFSDK_AFTERMATH_CALL
#else
#define GFSDK_Aftermath_API GFSDK_Aftermath_DLLSPEC GFSDK_Aftermath_Result GFSDK_AFTERMATH_CALL
#endif
#pragma pack(push, 8)
// Helper macros for declare struct members and types with guaranteed properties
#define GFSDK_AFTERMATH_DECLARE_HANDLE(name) struct name##__ { int32_t ID; }; typedef struct name##__ *name
#ifdef __cplusplus
#define GFSDK_AFTERMATH_DECLARE_ENUM(name) enum GFSDK_Aftermath_##name : uint32_t
#else
#define GFSDK_AFTERMATH_DECLARE_ENUM(name) typedef uint32_t GFSDK_Aftermath_##name; enum GFSDK_Aftermath_##name
#endif
#define GFSDK_AFTERMATH_DECLARE_POINTER_MEMBER(type, name) union { type name; uint64_t ptr_align_##name; }
#define GFSDK_AFTERMATH_DECLARE_BOOLEAN_MEMBER(name) union { bool name; uint32_t bool_align_##name; }
GFSDK_AFTERMATH_DECLARE_ENUM(Version)
{
GFSDK_Aftermath_Version_API = 0x000020b // Version 2.11
};
GFSDK_AFTERMATH_DECLARE_ENUM(Result)
{
GFSDK_Aftermath_Result_Success = 0x1,
GFSDK_Aftermath_Result_NotAvailable = 0x2,
GFSDK_Aftermath_Result_Fail = 0xBAD00000,
// The callee tries to use a library version
// which does not match the built binary.
GFSDK_Aftermath_Result_FAIL_VersionMismatch = GFSDK_Aftermath_Result_Fail | 1,
// The library hasn't been initialized, see;
// 'GFSDK_Aftermath_Initialize'.
GFSDK_Aftermath_Result_FAIL_NotInitialized = GFSDK_Aftermath_Result_Fail | 2,
// The callee tries to use the library with
// a non-supported GPU. Currently, only
// NVIDIA GPUs are supported.
GFSDK_Aftermath_Result_FAIL_InvalidAdapter = GFSDK_Aftermath_Result_Fail | 3,
// The callee passed an invalid parameter to the
// library, likely a null pointer or bad handle.
GFSDK_Aftermath_Result_FAIL_InvalidParameter = GFSDK_Aftermath_Result_Fail | 4,
// Something weird happened that caused the
// library to fail for some reason.
GFSDK_Aftermath_Result_FAIL_Unknown = GFSDK_Aftermath_Result_Fail | 5,
// Got a fail error code from the graphics API.
GFSDK_Aftermath_Result_FAIL_ApiError = GFSDK_Aftermath_Result_Fail | 6,
// Make sure that the NvAPI DLL is up to date.
GFSDK_Aftermath_Result_FAIL_NvApiIncompatible = GFSDK_Aftermath_Result_Fail | 7,
// It would appear as though a call has been
// made to fetch the Aftermath data for a
// context that hasn't been used with
// the EventMarker API yet.
GFSDK_Aftermath_Result_FAIL_GettingContextDataWithNewCommandList = GFSDK_Aftermath_Result_Fail | 8,
// Looks like the library has already been initialized.
GFSDK_Aftermath_Result_FAIL_AlreadyInitialized = GFSDK_Aftermath_Result_Fail | 9,
// Debug layer not compatible with Aftermath.
GFSDK_Aftermath_Result_FAIL_D3DDebugLayerNotCompatible = GFSDK_Aftermath_Result_Fail | 10,
// Aftermath failed to initialize in the driver.
GFSDK_Aftermath_Result_FAIL_DriverInitFailed = GFSDK_Aftermath_Result_Fail | 11,
// Aftermath v2.x requires driver version 387.xx and beyond
GFSDK_Aftermath_Result_FAIL_DriverVersionNotSupported = GFSDK_Aftermath_Result_Fail | 12,
// The system ran out of memory for allocations
GFSDK_Aftermath_Result_FAIL_OutOfMemory = GFSDK_Aftermath_Result_Fail | 13,
// No need to get data on bundles, as markers
// execute on the command list.
GFSDK_Aftermath_Result_FAIL_GetDataOnBundle = GFSDK_Aftermath_Result_Fail | 14,
// No need to get data on deferred contexts, as markers
// execute on the immediate context.
GFSDK_Aftermath_Result_FAIL_GetDataOnDeferredContext = GFSDK_Aftermath_Result_Fail | 15,
// This feature hasn't been enabled at initialization - see GFSDK_Aftermath_FeatureFlags.
GFSDK_Aftermath_Result_FAIL_FeatureNotEnabled = GFSDK_Aftermath_Result_Fail | 16,
// No resources have ever been registered.
GFSDK_Aftermath_Result_FAIL_NoResourcesRegistered = GFSDK_Aftermath_Result_Fail | 17,
// This resource has never been registered.
GFSDK_Aftermath_Result_FAIL_ThisResourceNeverRegistered = GFSDK_Aftermath_Result_Fail | 18,
// The functionality is not supported for UWP applications
GFSDK_Aftermath_Result_FAIL_NotSupportedInUWP = GFSDK_Aftermath_Result_Fail | 19,
// D3D DLL not compatible with Aftermath.
GFSDK_Aftermath_Result_FAIL_D3dDllNotSupported = GFSDK_Aftermath_Result_Fail | 20,
// D3D DLL interception is not compatible with Aftermath.
GFSDK_Aftermath_Result_FAIL_D3dDllInterceptionNotSupported = GFSDK_Aftermath_Result_Fail | 21,
// Aftermath is disabled on the system by the current user.
// On Windows, this is controlled by a Windows registry key:
// KeyPath : HKEY_CURRENT_USER\Software\NVIDIA Corporation\Nsight Aftermath
// KeyValue : ForceOff
// ValueType : REG_DWORD
// ValueData : Any value != 0 will force the functionality of the Aftermath
// SDK off on the system.
//
// On Linux, this is controlled by an environment variable:
// Name: NV_AFTERMATH_FORCE_OFF
// Value: Any value != '0' will force the functionality of the Aftermath
// SDK off.
//
GFSDK_Aftermath_Result_FAIL_Disabled = GFSDK_Aftermath_Result_Fail | 22,
};
#define GFSDK_Aftermath_SUCCEED(value) (((value) & 0xFFF00000) != GFSDK_Aftermath_Result_Fail)
GFSDK_AFTERMATH_DECLARE_ENUM(Context_Status)
{
// GPU:
// The GPU has not started processing this command list yet.
GFSDK_Aftermath_Context_Status_NotStarted = 0,
// This command list has begun execution on the GPU.
GFSDK_Aftermath_Context_Status_Executing,
// This command list has finished execution on the GPU.
GFSDK_Aftermath_Context_Status_Finished,
// This context has an invalid state, which could be
// caused by an error.
//
// NOTE: See, 'GFSDK_Aftermath_ContextData::getErrorCode()'
// for more information.
GFSDK_Aftermath_Context_Status_Invalid,
};
GFSDK_AFTERMATH_DECLARE_ENUM(Device_Status)
{
// The GPU is still active, and hasn't gone down.
GFSDK_Aftermath_Device_Status_Active = 0,
// A long running shader/operation has caused a
// GPU timeout. Reconfiguring the timeout length
// might help tease out the problem.
GFSDK_Aftermath_Device_Status_Timeout,
// Run out of memory to complete operations.
GFSDK_Aftermath_Device_Status_OutOfMemory,
// An invalid VA access has caused a fault.
GFSDK_Aftermath_Device_Status_PageFault,
// The GPU has stopped executing
GFSDK_Aftermath_Device_Status_Stopped,
// The device has been reset
GFSDK_Aftermath_Device_Status_Reset,
// Unknown problem - likely using an older driver
// incompatible with this Aftermath feature.
GFSDK_Aftermath_Device_Status_Unknown,
// An invalid rendering call has percolated through the driver
GFSDK_Aftermath_Device_Status_DmaFault,
};
#pragma pack(pop)
#endif // GFSDK_Aftermath_Defines_H
@@ -0,0 +1,232 @@
/*
* Copyright (c) 2019-2021, NVIDIA CORPORATION. All rights reserved.
*
* NVIDIA CORPORATION and its licensors retain all intellectual property
* and proprietary rights in and to this software, related documentation
* and any modifications thereto. Any use, reproduction, disclosure or
* distribution of this software and related documentation without an express
* license agreement from NVIDIA CORPORATION is strictly prohibited.
*/
/*
* █████ █████ ██████ ████ ████ ███████ ████ ██████ ██ ██
* ██ ██ ██ ██ ██ ██ ██ ██ ██ ██ ██ ██ ██ ██ ██
* ██ ██ ██ ██ ██ ██ ██ ██ ██ ██ ██ ██ ██ ██ ██
* ██████ ████ ██ ████ █████ ██ ██ ██ ██████ ██ ███████
* ██ ██ ██ ██ ██ ██ ██ ██ ██ ██ ██ ██ ██ ██
* ██ ██ ██ ██ █████ ██ ██ ██ ██ ██ ██ ██ ██ ██ DEBUGGER
* ██ ██
* ████████████████████████████████████████████████████████ ██ █ ██ ████████████
*
*
* HOW TO USE AFTERMATH GPU CRASH DUMP COLLECTION:
* -----------------------------------------------
*
* 1) Call 'GFSDK_Aftermath_EnableGpuCrashDumps', to enable GPU crash dump collection.
* This must be done before any other library calls are made and before any D3D
* device is created by the application.
*
* With this call the application can register a callback function that is invoked
* with the GPU crash dump data once a TDR/hang occurs. In addition, it is also
* possible to provide optional callback functions for collecting shader debug
* information and for providing additional descriptive data from the application to
* include in the crash dump.
*
* Enabling GPU crash dumps will also override any settings from an also active
* Nsight Graphics GPU crash dump monitor for the calling process.
*
*
* 2) On DX11/DX12, call 'GFSDK_Aftermath_DXxx_Initialize', to initialize the library and
* to enable additional Aftermath features that will affect the data captured in the
* GPU crash dumps, such as Aftermath event markers; automatic call stack markers for
* all draw calls, compute dispatches, ray dispatches, or copy operations; resource
* tracking; or shader debug information. See GFSDK_Aftermath.h for more details.
*
* On Vulkan use the VK_NV_device_diagnostics_config extension to enable additional
* Aftermath features, such as automatic call stack markers for all draw calls, compute
* dispatches, ray dispatches, or copy operations; resource tracking; or shader debug
* information. See GFSDK_Aftermath.h for more details.
*
*
* 4) Before the application shuts down, call 'GFSDK_Aftermath_DisableGpuCrashDumps' to
* disable GPU crash dump collection.
*
* Disabling GPU crash dumps will also re-establish any settings from an also active
* Nsight Graphics GPU crash dump monitor for the calling process.
*
*
* OPTIONAL:
*
* o) (Optional) Instrument the application with event markers as described in
* GFSDK_Aftermath.h.
* o) (Optional, D3D12) Register D3D12 resource pointers with Aftermath as described in
* GFSDK_Aftermath.h.
* o) (Optional) To disable all GPU crash dump functionality at runtime:
* On Windows, set the registry key: 'HKEY_CURRENT_USER\Software\NVIDIA Corporation\Nsight Aftermath\ForceOff'.
* On Linux, set environment 'NV_AFTERMATH_FORCE_OFF'.
*
*
* PERFORMANCE TIPS:
*
* o) Enabling shader debug information creation will introduce shader compile time
* overhead as well as memory overhead for handling the debug information.
*
* o) User event markers cause considerable overhead and should be used very carefully.
* Using automatic callstack markers for draw calls, compute dispatches, ray dispatches,
* and copy operations may be a less costly alternative to injecting an event marker for
* every draw call. However, they also do not come for free and using them should be
* also considered carefully.
*
*/
#ifndef GFSDK_Aftermath_GpuCrashDump_H
#define GFSDK_Aftermath_GpuCrashDump_H
#include "GFSDK_Aftermath_Defines.h"
#pragma pack(push, 8)
#ifdef __cplusplus
extern "C" {
#endif
// Flags to configure for which graphisc APIs to enable GPU crash dumps
GFSDK_AFTERMATH_DECLARE_ENUM(GpuCrashDumpWatchedApiFlags)
{
// Default setting
GFSDK_Aftermath_GpuCrashDumpWatchedApiFlags_None = 0x0,
// Enable GPU crash dump tracking for the DX API
GFSDK_Aftermath_GpuCrashDumpWatchedApiFlags_DX = 0x1,
// Enable GPU crash dump tracking for the Vulkan API
GFSDK_Aftermath_GpuCrashDumpWatchedApiFlags_Vulkan = 0x2,
};
// Flags to configure GPU crash dump-specific Aftermath features
GFSDK_AFTERMATH_DECLARE_ENUM(GpuCrashDumpFeatureFlags)
{
// Default settings
GFSDK_Aftermath_GpuCrashDumpFeatureFlags_Default = 0x0,
// Defer shader debug information callbacks until an actual GPU crash
// dump is generated and also provide shader debug information
// for the shaders related to the crash dump only.
// Note: using this option will increase the memory footprint of the
// application.
GFSDK_Aftermath_GpuCrashDumpFeatureFlags_DeferDebugInfoCallbacks = 0x1,
};
// Key definitions for user-defined GPU crash dump description
GFSDK_AFTERMATH_DECLARE_ENUM(GpuCrashDumpDescriptionKey)
{
// Predefined key for application name
GFSDK_Aftermath_GpuCrashDumpDescriptionKey_ApplicationName = 0x00000001,
// Predefined key for application version
GFSDK_Aftermath_GpuCrashDumpDescriptionKey_ApplicationVersion = 0x00000002,
// Base key for creating user-defined key-value pairs.
// Any value >= GFSDK_Aftermath_GpuCrashDumpDescriptionKey_UserDefined
// will create a user-defined key-value pair.
GFSDK_Aftermath_GpuCrashDumpDescriptionKey_UserDefined = 0x00010000,
};
// Function for adding user-defined description key-value pairs.
// Key must be one of the predefined keys of GFSDK_Aftermath_GpuCrashDumpDescriptionKey
// or a user-defined key based on GFSDK_Aftermath_GpuCrashDumpDescriptionKey_UserDefined.
// All keys greater than the last predefined key in GFSDK_Aftermath_GpuCrashDumpDescriptionKey
// and smaller than GFSDK_Aftermath_GpuCrashDumpDescriptionKey_UserDefined are
// considered illegal and ignored.
typedef void (GFSDK_AFTERMATH_CALL *PFN_GFSDK_Aftermath_AddGpuCrashDumpDescription)(uint32_t key, const char* value);
// GPU crash dump callback definitions.
// NOTE: Except for the pUserData pointer, all pointer values passed to the
// callbacks are only valid for the duration of the call! An implementation
// must make copies of the data, if it intends to store it beyond that.
typedef void (GFSDK_AFTERMATH_CALL *PFN_GFSDK_Aftermath_GpuCrashDumpCb)(const void* pGpuCrashDump, const uint32_t gpuCrashDumpSize, void* pUserData);
typedef void (GFSDK_AFTERMATH_CALL *PFN_GFSDK_Aftermath_ShaderDebugInfoCb)(const void* pShaderDebugInfo, const uint32_t shaderDebugInfoSize, void* pUserData);
typedef void (GFSDK_AFTERMATH_CALL *PFN_GFSDK_Aftermath_GpuCrashDumpDescriptionCb)(PFN_GFSDK_Aftermath_AddGpuCrashDumpDescription addValue, void* pUserData);
/////////////////////////////////////////////////////////////////////////
// GFSDK_Aftermath_EnableGpuCrashDumps
// ---------------------------------
//
// apiVersion;
// Must be set to GFSDK_Aftermath_Version_API. Used for checking against library
// version.
//
// watchedApis;
// Controls which graphics APIs to watch for crashes. A combination (with OR) of
// GFSDK_Aftermath_GpuCrashDumpWatchedApiFlags.
//
// flags;
// Controls GPU crash dump specific behavior. A combination (with OR) of
// GFSDK_Aftermath_GpuCrashDumpFeatureFlags.
//
// gpuCrashDumpCb;
// Callback function to be called when new GPU crash dump data is available.
// Callback is free-threaded, ensure the provided function is thread-safe.
//
// shaderDebugInfoCb;
// Callback function to be called when new shader debug information data is
// available.
// Callback is free-threaded, ensure the provided function is thread-safe.
// Optional, can be NULL.
// Note: if not using GFSDK_Aftermath_GpuCrashDumpFeatureFlags_DeferDebugInfoCallbacks
// shaderDebugInfoCb will be invoked for every shader compilation trigegred by the
// application, even if there will be never an invocation of gpuCrashDumpCb.
//
// descriptionCb;
// Callback function that allows the application to provide additional
// descriptive values to be include in crash dumps. This will be called
// before gpuCrashDumpCb.
// Callback is free-threaded, ensure the provided function is thread-safe.
// Optional, can be NULL.
//
// pUserData;
// User data made available in the callbacks.
//
//// DESCRIPTION;
// Device independent initialization call to enable Aftermath GPU crash dump
// creation. Overrides any settings from an also active GPU crash dump monitor
// for this process! This function must be called before any D3D device is
// created by the application.
//
/////////////////////////////////////////////////////////////////////////
GFSDK_Aftermath_API GFSDK_Aftermath_EnableGpuCrashDumps(
GFSDK_Aftermath_Version apiVersion,
uint32_t watchedApis,
uint32_t flags,
PFN_GFSDK_Aftermath_GpuCrashDumpCb gpuCrashDumpCb,
PFN_GFSDK_Aftermath_ShaderDebugInfoCb shaderDebugInfoCb,
PFN_GFSDK_Aftermath_GpuCrashDumpDescriptionCb descriptionCb,
void* pUserData);
/////////////////////////////////////////////////////////////////////////
// GFSDK_Aftermath_DisableGpuCrashDumps
// ---------------------------------
//
//// DESCRIPTION;
// Device independent call to disable Aftermath GPU crash dump creation.
// Re-enables settings from an also active GPU crash dump monitor for
// the current process!
//
/////////////////////////////////////////////////////////////////////////
GFSDK_Aftermath_API GFSDK_Aftermath_DisableGpuCrashDumps();
/////////////////////////////////////////////////////////////////////////
//
// NOTE: Function table provided - if dynamic loading is preferred.
//
/////////////////////////////////////////////////////////////////////////
GFSDK_Aftermath_PFN(GFSDK_AFTERMATH_CALL *PFN_GFSDK_Aftermath_EnableGpuCrashDumps)(GFSDK_Aftermath_Version apiVersion, uint32_t watchedApis, uint32_t flags, PFN_GFSDK_Aftermath_GpuCrashDumpCb gpuCrashDumpCb, PFN_GFSDK_Aftermath_ShaderDebugInfoCb shaderDebugInfoCb, PFN_GFSDK_Aftermath_GpuCrashDumpDescriptionCb descriptionCb, void* pUserData);
GFSDK_Aftermath_PFN(GFSDK_AFTERMATH_CALL *PFN_GFSDK_Aftermath_DisableGpuCrashDumps)();
#ifdef __cplusplus
} // extern "C"
#endif
#pragma pack(pop)
#endif // GFSDK_Aftermath_GpuCrashDump_H
@@ -0,0 +1,982 @@
/*
* Copyright (c) 2019-2020, NVIDIA CORPORATION. All rights reserved.
*
* NVIDIA CORPORATION and its licensors retain all intellectual property
* and proprietary rights in and to this software, related documentation
* and any modifications thereto. Any use, reproduction, disclosure or
* distribution of this software and related documentation without an express
* license agreement from NVIDIA CORPORATION is strictly prohibited.
*/
/*
* █████ █████ ██████ ████ ████ ███████ ████ ██████ ██ ██
* ██ ██ ██ ██ ██ ██ ██ ██ ██ ██ ██ ██ ██ ██ ██
* ██ ██ ██ ██ ██ ██ ██ ██ ██ ██ ██ ██ ██ ██ ██
* ██████ ████ ██ ████ █████ ██ ██ ██ ██████ ██ ███████
* ██ ██ ██ ██ ██ ██ ██ ██ ██ ██ ██ ██ ██ ██
* ██ ██ ██ ██ █████ ██ ██ ██ ██ ██ ██ ██ ██ ██ DEBUGGER
* ██ ██
* ████████████████████████████████████████████████████████ ██ █ ██ ████████████
*
*
* HOW TO DECODE AFTERMATH GPU CRASH DUMPS:
* ----------------------------------------
*
* 1) Call 'GFSDK_Aftermath_GpuCrashDump_CreateDecoder', to create a decoder object for
* a GPU crash dump.
*
*
* 2) Call one or more of the 'GFSDK_Aftermath_GpuCrashDump_Get*' functions with this
* decoder, to query information from the GPU crash dump.
*
* Some of the functions require caller allocated buffers to return the data. Those
* are accompanied with a corresponding 'GFSDK_Aftermath_GpuCrashDump_Get*Count()'
* function to query the element count the caller has to reserve for these buffers.
*
* If the requested data is not avilable in the crash dump the functions will return
* with GFSDK_Aftermath_Result_NotAvailable.
*
*
* 3) Call 'GFSDK_Aftermath_GpuCrashDump_DestroyDecoder', to destroy the decoder object
* and cleanup all related memory.
*
*/
#ifndef GFSDK_Aftermath_CrashDumpDecoding_H
#define GFSDK_Aftermath_CrashDumpDecoding_H
#include "GFSDK_Aftermath_Defines.h"
#pragma pack(push, 8)
#ifdef __cplusplus
extern "C" {
#endif
// Constants used in crash dump decoding functions
enum
{
GFSDK_Aftermath_MAX_STRING_LENGTH = 127,
};
// Unique identifier for shader debug information
typedef struct GFSDK_Aftermath_ShaderDebugInfoIdentifier
{
uint64_t id[2];
} GFSDK_Aftermath_ShaderDebugInfoIdentifier;
// Unique identifier for shader binaries
typedef struct GFSDK_Aftermath_ShaderHash
{
uint64_t hash;
} GFSDK_Aftermath_ShaderHash;
// Unique identifier for shader instructions
typedef struct GFSDK_Aftermath_ShaderInstructionsHash
{
uint64_t hash;
} GFSDK_Aftermath_ShaderInstructionsHash;
// Shader DebugName, i.e. a unique identifier for shader source debug information
typedef struct GFSDK_Aftermath_ShaderDebugName
{
char name[GFSDK_Aftermath_MAX_STRING_LENGTH + 1];
} GFSDK_Aftermath_ShaderDebugName;
// SPIR-V shader code
#if defined(VULKAN_H_)
typedef struct GFSDK_Aftermath_SpirvCode
{
GFSDK_AFTERMATH_DECLARE_POINTER_MEMBER(void*, pData);
uint32_t size;
} GFSDK_Aftermath_SpirvCode;
#endif
// Graphics API
GFSDK_AFTERMATH_DECLARE_ENUM(GraphicsApi)
{
GFSDK_Aftermath_GraphicsApi_Unknown = 0,
GFSDK_Aftermath_GraphicsApi_D3D_10_0 = 1,
GFSDK_Aftermath_GraphicsApi_D3D_10_1 = 2,
GFSDK_Aftermath_GraphicsApi_D3D_11_0 = 3,
GFSDK_Aftermath_GraphicsApi_D3D_11_1 = 4,
GFSDK_Aftermath_GraphicsApi_D3D_11_2 = 5,
GFSDK_Aftermath_GraphicsApi_D3D_12_0 = 6,
GFSDK_Aftermath_GraphicsApi_Vulkan = 7,
};
// GPU crash dump - base information
typedef struct GFSDK_Aftermath_GpuCrashDump_BaseInfo
{
char applicationName[GFSDK_Aftermath_MAX_STRING_LENGTH + 1];
char creationDate[GFSDK_Aftermath_MAX_STRING_LENGTH + 1];
uint32_t pid;
GFSDK_Aftermath_GraphicsApi graphicsApi;
} GFSDK_Aftermath_GpuCrashDump_BaseInfo;
// GPU crash dump - device information
typedef struct GFSDK_Aftermath_GpuCrashDump_DeviceInfo
{
GFSDK_Aftermath_Device_Status status;
GFSDK_AFTERMATH_DECLARE_BOOLEAN_MEMBER(adapterReset);
GFSDK_AFTERMATH_DECLARE_BOOLEAN_MEMBER(channel3dReset);
GFSDK_AFTERMATH_DECLARE_BOOLEAN_MEMBER(channelComputeReset);
GFSDK_AFTERMATH_DECLARE_BOOLEAN_MEMBER(channelCopyReset);
} GFSDK_Aftermath_GpuCrashDump_DeviceInfo;
// GPU crash dump - system information
typedef struct GFSDK_Aftermath_GpuCrashDump_SystemInfo
{
char osVersion[GFSDK_Aftermath_MAX_STRING_LENGTH + 1];
struct DisplayDriverVersion
{
uint32_t major;
uint32_t minor;
} displayDriver;
} GFSDK_Aftermath_GpuCrashDump_SystemInfo;
// GPU crash dump - GPU information
typedef struct GFSDK_Aftermath_GpuCrashDump_GpuInfo
{
char adapterName[GFSDK_Aftermath_MAX_STRING_LENGTH + 1];
char generationName[GFSDK_Aftermath_MAX_STRING_LENGTH + 1];
uint64_t adapterLUID;
} GFSDK_Aftermath_GpuCrashDump_GpuInfo;
// GPU crash dump - page fault information
typedef struct GFSDK_Aftermath_GpuCrashDump_PageFaultInfo
{
uint64_t faultingGpuVA;
GFSDK_AFTERMATH_DECLARE_BOOLEAN_MEMBER(bHasResourceInfo);
struct ResourceInfo {
uint64_t gpuVa;
uint64_t size;
uint32_t width;
uint32_t height;
uint32_t depth;
uint32_t mipLevels;
uint32_t format; // DXGI_Format for DX, VkFormat for Vulkan
GFSDK_AFTERMATH_DECLARE_BOOLEAN_MEMBER(bIsBufferHeap);
GFSDK_AFTERMATH_DECLARE_BOOLEAN_MEMBER(bIsStaticTextureHeap);
GFSDK_AFTERMATH_DECLARE_BOOLEAN_MEMBER(bIsRenderTargetOrDepthStencilViewHeap);
GFSDK_AFTERMATH_DECLARE_BOOLEAN_MEMBER(bPlacedResource);
GFSDK_AFTERMATH_DECLARE_BOOLEAN_MEMBER(bWasDestroyed);
uint32_t createDestroyTickCount;
} resourceInfo;
} GFSDK_Aftermath_GpuCrashDump_PageFaultInfo;
// GPU crash dump - shader types
GFSDK_AFTERMATH_DECLARE_ENUM(ShaderType)
{
GFSDK_Aftermath_ShaderType_Unknown = 0,
GFSDK_Aftermath_ShaderType_Vertex,
GFSDK_Aftermath_ShaderType_Tessellation_Control,
GFSDK_Aftermath_ShaderType_Hull = GFSDK_Aftermath_ShaderType_Tessellation_Control,
GFSDK_Aftermath_ShaderType_Tessellation_Evaluation,
GFSDK_Aftermath_ShaderType_Domain = GFSDK_Aftermath_ShaderType_Tessellation_Evaluation,
GFSDK_Aftermath_ShaderType_Geometry,
GFSDK_Aftermath_ShaderType_Fragment,
GFSDK_Aftermath_ShaderType_Pixel = GFSDK_Aftermath_ShaderType_Fragment,
GFSDK_Aftermath_ShaderType_Compute,
GFSDK_Aftermath_ShaderType_RayTracing_RayGeneration,
GFSDK_Aftermath_ShaderType_RayTracing_Miss,
GFSDK_Aftermath_ShaderType_RayTracing_Intersection,
GFSDK_Aftermath_ShaderType_RayTracing_AnyHit,
GFSDK_Aftermath_ShaderType_RayTracing_ClosestHit,
GFSDK_Aftermath_ShaderType_RayTracing_Callable,
GFSDK_Aftermath_ShaderType_RayTracing_Internal,
GFSDK_Aftermath_ShaderType_Mesh,
GFSDK_Aftermath_ShaderType_Task,
};
// GPU crash dump - shader information
typedef struct GFSDK_Aftermath_GpuCrashDump_ShaderInfo
{
uint64_t shaderHash;
uint64_t shaderInstance;
GFSDK_AFTERMATH_DECLARE_BOOLEAN_MEMBER(isInternal);
GFSDK_Aftermath_ShaderType shaderType;
} GFSDK_Aftermath_GpuCrashDump_ShaderInfo;
// GPU crash dump - Event marker context type
GFSDK_AFTERMATH_DECLARE_ENUM(Context_Type)
{
GFSDK_Aftermath_Context_Type_Invalid = 0,
GFSDK_Aftermath_Context_Type_Immediate,
GFSDK_Aftermath_Context_Type_CommandList,
GFSDK_Aftermath_Context_Type_Bundle,
GFSDK_Aftermath_Context_Type_CommandQueue
};
// GPU crash dump - Event marker data ownership
GFSDK_AFTERMATH_DECLARE_ENUM(EventMarkerDataOwnership)
{
// Data is owned by the user application
GFSDK_Aftermath_EventMarkerDataOwnership_User = 0,
// Data is part of the crash dump and is owned by the decoder
GFSDK_Aftermath_EventMarkerDataOwnership_Decoder,
};
// GPU crash dump - Aftermath event marker information
// NOTE: If GFSDK_Aftermath_SetEventMarker was called with markerSize=0,
// markerDataOwnership will be set to GFSDK_Aftermath_EventMarkerDataOwnership_User
// and the markerData pointer will be only valid within the context of the process
// setting the marker and if the application properly manages the lifetime of the
// pointed to data. It is the responsibility of the caller to ensure that the pointer
// is valid before accessing the pointed to data.
typedef struct GFSDK_Aftermath_GpuCrashDump_EventMarkerInfo
{
uint64_t contextId;
GFSDK_Aftermath_Context_Status contextStatus;
GFSDK_Aftermath_Context_Type contextType;
GFSDK_AFTERMATH_DECLARE_POINTER_MEMBER(const void*, markerData);
GFSDK_Aftermath_EventMarkerDataOwnership markerDataOwnership;
uint32_t markerDataSize;
} GFSDK_Aftermath_GpuCrashDump_EventMarkerInfo;
// Flags that control the behavior of GFSDK_Aftermath_GpuCrashDump_GenerateJSON
GFSDK_AFTERMATH_DECLARE_ENUM(GpuCrashDumpDecoderFlags)
{
// Include basic information about the GPU crash dump.
GFSDK_Aftermath_GpuCrashDumpDecoderFlags_BASE_INFO = 0x1,
// Include information about the device state
GFSDK_Aftermath_GpuCrashDumpDecoderFlags_DEVICE_INFO = 0x2,
// Include information about the OS
GFSDK_Aftermath_GpuCrashDumpDecoderFlags_OS_INFO = 0x4,
// Include information about the display driver
GFSDK_Aftermath_GpuCrashDumpDecoderFlags_DISPLAY_DRIVER_INFO = 0x8,
// Include information about the GPU
GFSDK_Aftermath_GpuCrashDumpDecoderFlags_GPU_INFO = 0x10,
// Include information about page faults (if available)
GFSDK_Aftermath_GpuCrashDumpDecoderFlags_PAGE_FAULT_INFO = 0x20,
// Include information about shaders (if available)
GFSDK_Aftermath_GpuCrashDumpDecoderFlags_SHADER_INFO = 0x40,
// Include information about active warps (if available)
GFSDK_Aftermath_GpuCrashDumpDecoderFlags_WARP_STATE_INFO = 0x80,
// Try to map shader addresses to source or intermediate assembly lines
// using additional information provided through shaderDebugInfoLookupCb,
// shaderLookupCb and shaderInstructionsLookupCb, if provided.
GFSDK_Aftermath_GpuCrashDumpDecoderFlags_SHADER_MAPPING_INFO = 0x100,
// Include Aftermath event marker data (if available)
GFSDK_Aftermath_GpuCrashDumpDecoderFlags_EVENT_MARKER_INFO = 0x200,
// Include automatic event marker call stack data (if available)
GFSDK_Aftermath_GpuCrashDumpDecoderFlags_CALL_STACK_INFO = 0x400,
// Include user provided GPU crash dump description values (if available)
GFSDK_Aftermath_GpuCrashDumpDecoderFlags_DESCRIPTION_INFO = 0x800,
// Include all available information
GFSDK_Aftermath_GpuCrashDumpDecoderFlags_ALL_INFO= 0xFFF,
};
GFSDK_AFTERMATH_DECLARE_ENUM(GpuCrashDumpFormatterFlags)
{
// No special formatting
GFSDK_Aftermath_GpuCrashDumpFormatterFlags_NONE = 0x0,
// Remove all unnecessary whitespace from formatted string
GFSDK_Aftermath_GpuCrashDumpFormatterFlags_CONDENSED_OUTPUT = 0x1,
// Use UTF8 encoding
GFSDK_Aftermath_GpuCrashDumpFormatterFlags_UTF8_OUTPUT = 0x2,
};
// Crash dump decoder handle
GFSDK_AFTERMATH_DECLARE_HANDLE(GFSDK_Aftermath_GpuCrashDump_Decoder);
// Function for providing shader debug information and shader binary to the crash dump decoder
typedef void(GFSDK_AFTERMATH_CALL *PFN_GFSDK_Aftermath_SetData)(const void* pData, uint32_t size);
// GPU crash dump decoder callback definitions
typedef void(GFSDK_AFTERMATH_CALL *PFN_GFSDK_Aftermath_ShaderDebugInfoLookupCb)(const GFSDK_Aftermath_ShaderDebugInfoIdentifier* pIdentifier, PFN_GFSDK_Aftermath_SetData setShaderDebugInfo, void* pUserData);
typedef void(GFSDK_AFTERMATH_CALL *PFN_GFSDK_Aftermath_ShaderLookupCb)(const GFSDK_Aftermath_ShaderHash* pShaderHash, PFN_GFSDK_Aftermath_SetData setShaderBinary, void* pUserData);
typedef void(GFSDK_AFTERMATH_CALL *PFN_GFSDK_Aftermath_ShaderInstructionsLookupCb)(const GFSDK_Aftermath_ShaderInstructionsHash* pShaderInstructionsHash, PFN_GFSDK_Aftermath_SetData setShaderBinary, void* pUserData);
typedef void(GFSDK_AFTERMATH_CALL *PFN_GFSDK_Aftermath_ShaderSourceDebugInfoLookupCb)(const GFSDK_Aftermath_ShaderDebugName* pShaderDebugName, PFN_GFSDK_Aftermath_SetData setShaderBinary, void* pUserData);
/////////////////////////////////////////////////////////////////////////
// GFSDK_Aftermath_GpuCrashDump_CreateDecoder
// ---------------------------------
//
// apiVersion;
// Must be set to GFSDK_Aftermath_Version_API. Used for checking against library
// version.
//
// pGpuCrashDump;
// Pointer to GPU crash dump data captured in a GFSDK_Aftermath_GpuCrashDumpCb
// callback.
//
// gpuCrashDumpSize;
// Size of GPU crash dump data in bytes.
//
// pDecoder;
// Pointer to a decoder object owned by the caller that is initialized.
//
//// DESCRIPTION;
// Create a decoder object that can be used to query information about the
// provided GPU crash dump.
//
/////////////////////////////////////////////////////////////////////////
GFSDK_Aftermath_API GFSDK_Aftermath_GpuCrashDump_CreateDecoder(
GFSDK_Aftermath_Version apiVersion,
const void* pGpuCrashDump,
const uint32_t gpuCrashDumpSize,
GFSDK_Aftermath_GpuCrashDump_Decoder* pDecoder);
/////////////////////////////////////////////////////////////////////////
// GFSDK_Aftermath_GpuCrashDump_DestroyDecoder
// ---------------------------------
//
// decoder;
// A valid decoder object.
//
//// DESCRIPTION;
// Free any data related to the passed in decoder object.
//
/////////////////////////////////////////////////////////////////////////
GFSDK_Aftermath_API GFSDK_Aftermath_GpuCrashDump_DestroyDecoder(
const GFSDK_Aftermath_GpuCrashDump_Decoder decoder);
/////////////////////////////////////////////////////////////////////////
// GFSDK_Aftermath_GpuCrashDump_GetBaseInfo
// ---------------------------------
//
// decoder;
// A valid decoder object.
//
// pBaseInfo;
// Pointer to data structure owned by the caller that is filled in with
// information from the GPU crash dump.
//
//// DESCRIPTION;
// Query basic information from a GPU crash dump.
//
/////////////////////////////////////////////////////////////////////////
GFSDK_Aftermath_API GFSDK_Aftermath_GpuCrashDump_GetBaseInfo(
const GFSDK_Aftermath_GpuCrashDump_Decoder decoder,
GFSDK_Aftermath_GpuCrashDump_BaseInfo* pBaseInfo);
/////////////////////////////////////////////////////////////////////////
// GFSDK_Aftermath_GpuCrashDump_GetDescriptionSize
// ---------------------------------
//
// decoder;
// A valid decoder object.
//
// key;
// What value to query from the description section.
//
// pValueSize;
// Populated with the size of the value in bytes (including 0-termination
// of the string).
//
//// DESCRIPTION;
// Query the size of a description value from a GPU crash dump.
//
/////////////////////////////////////////////////////////////////////////
GFSDK_Aftermath_API GFSDK_Aftermath_GpuCrashDump_GetDescriptionSize(
const GFSDK_Aftermath_GpuCrashDump_Decoder decoder,
const uint32_t key,
uint32_t* pValueSize);
/////////////////////////////////////////////////////////////////////////
// GFSDK_Aftermath_GpuCrashDump_GetDescription
// ---------------------------------
//
// decoder;
// A valid decoder object.
//
// key;
// What value to query from the description section.
//
// valueBufferSize;
// Size in bytes of the caller allocated results buffer pValue.
//
// pValue;
// Caller allocated results buffer.
//
//// DESCRIPTION;
// Query description value from a GPU crash dump.
//
/////////////////////////////////////////////////////////////////////////
GFSDK_Aftermath_API GFSDK_Aftermath_GpuCrashDump_GetDescription(
const GFSDK_Aftermath_GpuCrashDump_Decoder decoder,
const uint32_t key,
const uint32_t valueBufferSize,
char* pValue);
/////////////////////////////////////////////////////////////////////////
// GFSDK_Aftermath_GpuCrashDump_GetDeviceInfo
// ---------------------------------
//
// decoder;
// A valid decoder object.
//
// pDeviceInfo;
// Pointer to data structure owned by the caller that is filled in with
// information from the GPU crash dump.
//
//// DESCRIPTION;
// Query device state information from a GPU crash dump.
//
/////////////////////////////////////////////////////////////////////////
GFSDK_Aftermath_API GFSDK_Aftermath_GpuCrashDump_GetDeviceInfo(
const GFSDK_Aftermath_GpuCrashDump_Decoder decoder,
GFSDK_Aftermath_GpuCrashDump_DeviceInfo* pDeviceInfo);
/////////////////////////////////////////////////////////////////////////
// GFSDK_Aftermath_GpuCrashDump_GetSystemInfo
// ---------------------------------
//
// decoder;
// A valid decoder object.
//
// pSystemInfo;
// Pointer to data structure owned by the caller that is filled in with
// information from the GPU crash dump.
//
//// DESCRIPTION;
// Query system information (OS, display driver) from a GPU crash dump.
//
/////////////////////////////////////////////////////////////////////////
GFSDK_Aftermath_API GFSDK_Aftermath_GpuCrashDump_GetSystemInfo(
const GFSDK_Aftermath_GpuCrashDump_Decoder decoder,
GFSDK_Aftermath_GpuCrashDump_SystemInfo* pSystemInfo);
/////////////////////////////////////////////////////////////////////////
// GFSDK_Aftermath_GpuCrashDump_GetGpuInfoCount
// ---------------------------------
//
// decoder;
// A valid decoder object.
//
// pGpuCount;
// Populated with the number of GPU entries in the GPU crash dump.
//
//// DESCRIPTION;
// Query number of GPU entries from a GPU crash dump.
//
/////////////////////////////////////////////////////////////////////////
GFSDK_Aftermath_API GFSDK_Aftermath_GpuCrashDump_GetGpuInfoCount(
const GFSDK_Aftermath_GpuCrashDump_Decoder decoder,
uint32_t* pGpuCount);
/////////////////////////////////////////////////////////////////////////
// GFSDK_Aftermath_GpuCrashDump_GetGpuInfo
// ---------------------------------
//
// decoder;
// A valid decoder object.
//
// gpuInfoBufferCount;
// Number of elements in caller allocated array passed in pGpuInfo.
//
// pGpuInfo;
// Pointer to caller allocated array of GFSDK_Aftermath_GpuCrashDump_GpuInfo
// that is filled in with information from the GPU crash dump.
//
//// DESCRIPTION;
// Query information about the GPUs from a GPU crash dump.
//
/////////////////////////////////////////////////////////////////////////
GFSDK_Aftermath_API GFSDK_Aftermath_GpuCrashDump_GetGpuInfo(
const GFSDK_Aftermath_GpuCrashDump_Decoder decoder,
const uint32_t gpuInfoBufferCount,
GFSDK_Aftermath_GpuCrashDump_GpuInfo* pGpuInfo);
/////////////////////////////////////////////////////////////////////////
// GFSDK_Aftermath_GpuCrashDump_GetPageFaultInfo
// ---------------------------------
//
// decoder;
// A valid decoder object.
//
// pPageFaultInfo;
// Pointer to data structure owned by the caller that is filled in with
// information from the GPU crash dump.
//
//// DESCRIPTION;
// Query page fault information from a GPU crash dump.
//
/////////////////////////////////////////////////////////////////////////
GFSDK_Aftermath_API GFSDK_Aftermath_GpuCrashDump_GetPageFaultInfo(
const GFSDK_Aftermath_GpuCrashDump_Decoder decoder,
GFSDK_Aftermath_GpuCrashDump_PageFaultInfo* pPageFaultInfo);
/////////////////////////////////////////////////////////////////////////
// GFSDK_Aftermath_GpuCrashDump_GetActiveShadersInfoCount
// ---------------------------------
//
// decoder;
// A valid decoder object.
//
// pShaderCount;
// Populated with the number of active shaders in the GPU crash dump.
//
//// DESCRIPTION;
// Query the number of active shaders from a GPU crash dump.
//
/////////////////////////////////////////////////////////////////////////
GFSDK_Aftermath_API GFSDK_Aftermath_GpuCrashDump_GetActiveShadersInfoCount(
const GFSDK_Aftermath_GpuCrashDump_Decoder decoder,
uint32_t* pShaderCount);
/////////////////////////////////////////////////////////////////////////
// GFSDK_Aftermath_GpuCrashDump_GetActiveShadersInfo
// ---------------------------------
//
// decoder;
// A valid decoder object.
//
// shaderInfoBufferCount;
// Number of elements in caller allocated array passed in pShaderInfo.
//
// pShaderInfo;
// Pointer to caller allocated array of GFSDK_Aftermath_GpuCrashDump_ShaderInfo
// that is filled in with information from the GPU crash dump.
//
//// DESCRIPTION;
// Query information about active shaders from a GPU crash dump.
//
/////////////////////////////////////////////////////////////////////////
GFSDK_Aftermath_API GFSDK_Aftermath_GpuCrashDump_GetActiveShadersInfo(
const GFSDK_Aftermath_GpuCrashDump_Decoder decoder,
const uint32_t shaderInfoBufferCount,
GFSDK_Aftermath_GpuCrashDump_ShaderInfo* pShaderInfo);
/////////////////////////////////////////////////////////////////////////
// GFSDK_Aftermath_GpuCrashDump_GetEventMarkersInfoCount
// ---------------------------------
//
// decoder;
// A valid decoder object.
//
// pMarkerCount;
// Populated with the number of event markers in the GPU crash dump.
//
//// DESCRIPTION;
// Query the number of event markers from a GPU crash dump.
//
/////////////////////////////////////////////////////////////////////////
GFSDK_Aftermath_API GFSDK_Aftermath_GpuCrashDump_GetEventMarkersInfoCount(
const GFSDK_Aftermath_GpuCrashDump_Decoder decoder,
uint32_t* pMarkerCount);
/////////////////////////////////////////////////////////////////////////
// GFSDK_Aftermath_GpuCrashDump_GetEventMarkersInfo
// ---------------------------------
//
// decoder;
// A valid decoder object.
//
// markerInfoBufferCount;
// Number of elements in caller allocated array passed in pMarkerInfo.
//
// pMarkerInfo;
// Pointer to caller allocated array of GFSDK_Aftermath_GpuCrashDump_EventMarkerInfo
// that is filled in with information from the GPU crash dump.
//
//// DESCRIPTION;
// Query information about event markers from a GPU crash dump.
//
/////////////////////////////////////////////////////////////////////////
GFSDK_Aftermath_API GFSDK_Aftermath_GpuCrashDump_GetEventMarkersInfo(
const GFSDK_Aftermath_GpuCrashDump_Decoder decoder,
const uint32_t markerInfoBufferCount,
GFSDK_Aftermath_GpuCrashDump_EventMarkerInfo* pMarkerInfo);
/////////////////////////////////////////////////////////////////////////
// GFSDK_Aftermath_GpuCrashDump_GenerateJSON
// ---------------------------------
//
// decoder;
// A valid decoder object.
//
// decoderFlags;
// Flags that define what information to include in the decoding. Bitwise OR of any
// of the flags defined in GFSDK_Aftermath_GpuCrashDumpDecoderFlags.
//
// formatFlags;
// Flags controlling the formatting. Bitwise OR of any of the flags defined in
// GFSDK_Aftermath_GpuCrashDumpFormatterFlags.
//
// shaderDebugInfoLookupCb;
// Callback used by the decoder to query shader debug information for mapping shader
// addresses to source or intermediate assembly line.
// Optional, can be NULL.
// Used when GFSDK_Aftermath_GpuCrashDumpDecoderFlags_SHADER_MAPPING_INFO is set in
// decoderFlags.
//
// shaderLookupCb;
// Callback used by the decoder to query shader information for mapping shader
// addresses to shader intermediate assembly (DXIL/SPIR-V) or source.
// Optional, can be NULL.
// Used when GFSDK_Aftermath_GpuCrashDumpDecoderFlags_SHADER_MAPPING_INFO is set in
// decoderFlags.
//
// shaderInstructionsLookupCb;
// Callback used by the decoder to query shader information for mapping shader
// addresses to shader intermediate assembly (DXIL/SPIR-V) or source.
// Optional, can be NULL.
// Used when GFSDK_Aftermath_GpuCrashDumpDecoderFlags_SHADER_MAPPING_INFO is set in
// decoderFlags.
//
// shaderSourceDebugInfoLookupCb;
// Callback used by the decoder to query high-level shader debug information for
// mapping shader addresses to shader source, if the shaders used by the application
// are stripped off debug information. This lookup is done by the shader's DebugName,
// a unique identifier of the source debug information.
//
// Optional, can be NULL.
// Used when GFSDK_Aftermath_GpuCrashDumpDecoderFlags_SHADER_MAPPING_INFO is set in
// decoderFlags.
//
// For DXIL shaders DebugName is generated by the dxc compiler and is defined here:
// https://github.com/microsoft/DirectXShaderCompiler/blob/master/docs/SourceLevelDebuggingHLSL.rst#using-debug-names.
//
// The following variants of generating source shader debug information for DXIL shaders
// are supported:
//
// 1) Compile and use a full shader blob
// Compile the shaders with the debug information. Use the full (i.e. not
// stripped) shader binary when running the application and make it accessible
// through shaderLookupCb and shaderInstructionsLookupCb. In this case there is
// no need to provide shaderSourceDebugInfoLookupCb.
//
// Compilation example:
// dxc -Zi [..] -Fo shader.bin shader.hlsl
//
// 2) Compile and strip
// Compile the shaders with debug information and then strip off the debug
// information. Use the stripped shader binary data when running the application.
// Make the stripped shader binary data accessible through shaderLookupCb and
// shaderInstructionsLookupCb. In addition, make the non-stripped shader binary
// data accessible through shaderSourceDebugInfoLookupCb.
//
// Compilation example:
// dxc -Zi [..] -Fo full_shader.bin shader.hlsl
// dxc -dumpbin -Qstrip_debug -Fo shader.bin full_shader.bin
//
// The shader's DebugName required for implementing the
// shaderSourceDebugInfoLookupCb may be extracted from the stripped or the
// non-stripped shader binary data with GFSDK_Aftermath_GetShaderDebugName().
//
// 3) Compile with separate debug information (and auto-generated debug data file name)
// Compile the shaders with debug information and instruct the compiler to store
// the debug meta data in a separate shader debug information file. The name of
// the file generated by the compiler will match the DebugName of the shader.
// Make the shader binary data accessible through shaderLookupCb and
// shaderInstructionsLookupCb. In addition, make the data from the compiler
// generated shader debug data file accessible through
// shaderSourceDebugInfoLookupCb.
//
// Compilation example:
// dxc -Zi [..] -Fo shader.bin -Fd debugInfo\ shader.hlsl
//
// The debug data file generated by the compiler does not contain any reference to
// the shader's DebugName. It is the responsibility of the user providing the
// shaderSourceDebugInfoLookupCb callback to implement a solution to lookup the
// debug data based on the name of the generated debug data file.
//
// 4) Compile with separate debug information (and user-defined debug data file name)
// Compile the shaders with debug information and instruct the compiler to store
// the debug meta data in a separate shader debug information file. The name of
// the file is freely choosen by the user. Make the shader binary data accessible
// through shaderLookupCb and shaderInstructionsLookupCb. In addition, make the
// data from the compiler generated shader debug data file accessible through
// shaderSourceDebugInfoLookupCb.
//
// Compilation example:
// dxc -Zi [..] -Fo shader.bin -Fd debugInfo\shader.dbg shader.hlsl
//
// The debug data file generated by the compiler does not contain any reference to
// the shader's DebugName. It is the responsibility of the user providing the
// shaderSourceDebugInfoLookupCb callback to implement a solution that performs
// the lookup of the debug data based on a mapping between the shader's DebugName
// the debug data file's name that was chosen for the compilation. The shader's
// DebugName may be extracted from the shader binary data with
// GFSDK_Aftermath_GetShaderDebugName().
//
// For SPIR-V shaders the Aftermath SDK provides support for the following variants of
// generating source shader debug information:
//
// 1) Compile and use a full shader blob
// Compile the shaders with the debug information. Use the full (i.e. not
// stripped) shader binary when running the application and make it accessible
// through shaderLookupCb. In this case there is no need to provide
// shaderInstructionsLookupCb or shaderSourceDebugInfoLookupCb.
//
// Compilation example using Vulkan SDK tool-chain:
// glslangValidator -V -g -o ./full/shader.spv shader.vert
//
// 2) Compile and strip
// Compile the shaders with debug information and then strip off the debug
// information. Use the stripped shader binary data when running the application.
// Make the stripped shader binary data accessible through shaderLookupCb.
// In addition, make the non-stripped shader binary data accessible through
// shaderSourceDebugInfoLookupCb.
//
// Compilation example using Vulkan SDK tool-chain:
// glslangValidator -V -g -o ./full/shader.spv shader.vert
// spirv-remap --map all --strip-all --input full/shader.spv --output ./stripped/
//
// Then pass the content of ./full/shader.spv and ./stripped/shader.spv to
// GFSDK_Aftermath_GetDebugNameSpirv() to generate the debug name to use with
// shaderSourceDebugInfoLookupCb.
//
// pUserData;
// User data made available in callbacks.
//
// pJsonSize;
// Populated with the size of the generated JSON data in bytes.
//
//// DESCRIPTION;
// Decode a crash dump to JSON format.
// The decoded JSON can be later queried by calling GFSDK_Aftermath_GpuCrashDump_GetJSON.
//
/////////////////////////////////////////////////////////////////////////
GFSDK_Aftermath_API GFSDK_Aftermath_GpuCrashDump_GenerateJSON(
const GFSDK_Aftermath_GpuCrashDump_Decoder decoder,
uint32_t decoderFlags,
uint32_t formatFlags,
PFN_GFSDK_Aftermath_ShaderDebugInfoLookupCb shaderDebugInfoLookupCb,
PFN_GFSDK_Aftermath_ShaderLookupCb shaderLookupCb,
PFN_GFSDK_Aftermath_ShaderInstructionsLookupCb shaderInstructionsLookupCb,
PFN_GFSDK_Aftermath_ShaderSourceDebugInfoLookupCb shaderSourceDebugInfoLookupCb,
void* pUserData,
uint32_t* pJsonSize);
/////////////////////////////////////////////////////////////////////////
// GFSDK_Aftermath_GpuCrashDump_GetJSON
// ---------------------------------
//
// decoder;
// A valid decoder object.
//
// jsonBufferSize;
// The size of the caller allocated buffer for the JSON data in bytes.
//
// pJson;
// Caller allocated buffer populated with the JSON data (0-terminated string).
//
//// DESCRIPTION;
// Copy the JSON generated by the last call to GFSDK_Aftermath_GpuCrashDump_GenerateJSON
// into a caller provided buffer.
//
/////////////////////////////////////////////////////////////////////////
GFSDK_Aftermath_API GFSDK_Aftermath_GpuCrashDump_GetJSON(
const GFSDK_Aftermath_GpuCrashDump_Decoder decoder,
const uint32_t jsonBufferSize,
char* pJson);
/////////////////////////////////////////////////////////////////////////
// GFSDK_Aftermath_GetShaderDebugInfoIdentifier
// ---------------------------------
//
// apiVersion;
// Must be set to GFSDK_Aftermath_Version_API. Used for checking against library
// version.
//
// pShaderDebugInfo;
// Pointer to shader debug information data captured in a GFSDK_Aftermath_ShaderDebugInfoCb callback.
//
// shaderDebugInfoSize;
// Size in bytes of the shader debug information data.
//
// pIdentifier;
// Pointer to GFSDK_Aftermath_ShaderDebugInfoIdentifier structure receiving the result
//
//// DESCRIPTION;
// Read the shader debug information identifier from shader debug information.
// The shader debug information identifier is required when implementing the
// PFN_GFSDK_Aftermath_ShaderDebugInfoLookupCb callback.
//
/////////////////////////////////////////////////////////////////////////
GFSDK_Aftermath_API GFSDK_Aftermath_GetShaderDebugInfoIdentifier(
GFSDK_Aftermath_Version apiVersion,
const void* pShaderDebugInfo,
const uint32_t shaderDebugInfoSize,
GFSDK_Aftermath_ShaderDebugInfoIdentifier* pIdentifier);
/////////////////////////////////////////////////////////////////////////
// GFSDK_Aftermath_GetShaderHash
// ---------------------------------
//
// apiVersion;
// Must be set to GFSDK_Aftermath_Version_API. Used for checking against library
// version.
//
// pShader;
// The binary shader blob for which to compute the identifier.
//
// pShaderHash;
// Pointer to GFSDK_Aftermath_ShaderHash structure receiving the computed shader hash.
// Optional, can be NULL.
//
// pShaderInstructionsHash;
// Pointer to GFSDK_Aftermath_ShaderInstructionsHash structure receiving the computed
// shader instructions hash.
// Optional, can be NULL.
//
//// DESCRIPTION;
// Computes shader hashes uniquely identifying the provided DXBC shader binary.
// This is, for example, required for comparison in the shader binary lookup by
// PFN_GFSDK_Aftermath_ShaderLookupCb or PFN_GFSDK_Aftermath_ShaderInstructionsLookupCb.
//
/////////////////////////////////////////////////////////////////////////
#if defined(__d3d12_h__)
GFSDK_Aftermath_API GFSDK_Aftermath_GetShaderHash(
GFSDK_Aftermath_Version apiVersion,
const D3D12_SHADER_BYTECODE* pShader,
GFSDK_Aftermath_ShaderHash* pShaderHash,
GFSDK_Aftermath_ShaderInstructionsHash* pShaderInstructionsHash);
#endif
/////////////////////////////////////////////////////////////////////////
// GFSDK_Aftermath_GetShaderHashSpirv
// ---------------------------------
//
// apiVersion;
// Must be set to GFSDK_Aftermath_Version_API. Used for checking against library
// version.
//
// pShader;
// The SPIR-V shader binary for which to compute the identifier.
//
// pShaderHash;
// Pointer to GFSDK_Aftermath_ShaderHash structure receiving the computed shader hash.
// Optional, can be NULL.
//
//// DESCRIPTION;
// Computes a shader hash uniquely identifying the provided SPIR-V shader binary.
// This is, for example, required for comparison in the shader binary lookup by
// PFN_GFSDK_Aftermath_ShaderLookupCb.
//
/////////////////////////////////////////////////////////////////////////
#if defined(VULKAN_H_)
GFSDK_Aftermath_API GFSDK_Aftermath_GetShaderHashSpirv(
GFSDK_Aftermath_Version apiVersion,
const GFSDK_Aftermath_SpirvCode *pShader,
GFSDK_Aftermath_ShaderHash* pShaderHash);
#endif
/////////////////////////////////////////////////////////////////////////
// GFSDK_Aftermath_GetShaderDebugName
// ---------------------------------
//
// apiVersion;
// Must be set to GFSDK_Aftermath_Version_API. Used for checking against library
// version.
//
// pShader;
// The binary shader data blob from which to extract the DebugName.
//
// pShaderDebugName;
// Pointer to GFSDK_Aftermath_ShaderDebugName structure receiving the DebugName.
//
//// DESCRIPTION;
// Extracts the shader's DebugName (if available) from the provided DXBC shader binary.
// This is, for example, required for comparison in the shader debug data lookup by
// PFN_GFSDK_Aftermath_ShaderSourceDebugInfoLookupCb. For more information about shader
// debug names please read:
// https://github.com/microsoft/DirectXShaderCompiler/blob/master/docs/SourceLevelDebuggingHLSL.rst#using-debug-names.
//
/////////////////////////////////////////////////////////////////////////
#if defined(__d3d12_h__)
GFSDK_Aftermath_API GFSDK_Aftermath_GetShaderDebugName(
GFSDK_Aftermath_Version apiVersion,
const D3D12_SHADER_BYTECODE* pShader,
GFSDK_Aftermath_ShaderDebugName* pShaderDebugName);
#endif
/////////////////////////////////////////////////////////////////////////
// GFSDK_Aftermath_GetShaderDebugNameSpirv
// ---------------------------------
//
// apiVersion;
// Must be set to GFSDK_Aftermath_Version_API. Used for checking against library
// version.
//
// pShader;
// The not-stripped SPIR-V binary shader data of the shader pair for which to
// generate the DebugName.
//
// pStrippedShader;
// The stripped SPIR-V binary shader data of the shader pair for which to
// generate the DebugName.
//
// pShaderDebugName;
// Pointer to GFSDK_Aftermath_ShaderDebugName structure receiving the DebugName.
//
//// DESCRIPTION;
// Generates a shader DebugName from the provided pair of SPIR-V shader binary
// data. This is, for example, required for comparison in the shader debug data
// lookup by PFN_GFSDK_Aftermath_ShaderSourceDebugInfoLookupCb. For more information
// about how to generate the pair of shader binaries, see the description of
// GFSDK_Aftermath_GpuCrashDump_GenerateJSON().
//
/////////////////////////////////////////////////////////////////////////
#if defined(VULKAN_H_)
GFSDK_Aftermath_API GFSDK_Aftermath_GetShaderDebugNameSpirv(
GFSDK_Aftermath_Version apiVersion,
const GFSDK_Aftermath_SpirvCode *pShader,
const GFSDK_Aftermath_SpirvCode *pStrippedShader,
GFSDK_Aftermath_ShaderDebugName* pShaderDebugName);
#endif
/////////////////////////////////////////////////////////////////////////
//
// NOTE: Function table provided - if dynamic loading is preferred.
//
/////////////////////////////////////////////////////////////////////////
GFSDK_Aftermath_PFN(GFSDK_AFTERMATH_CALL *PFN_GFSDK_Aftermath_GpuCrashDump_CreateDecoder)(GFSDK_Aftermath_Version apiVersion, const void* pGpuCrashDump, const uint32_t gpuCrashDumpSize, GFSDK_Aftermath_GpuCrashDump_Decoder* pDecoder);
GFSDK_Aftermath_PFN(GFSDK_AFTERMATH_CALL *PFN_GFSDK_Aftermath_GpuCrashDump_DestroyDecoder)(const GFSDK_Aftermath_GpuCrashDump_Decoder decoder);
GFSDK_Aftermath_PFN(GFSDK_AFTERMATH_CALL *PFN_GFSDK_Aftermath_GpuCrashDump_GetBaseInfo)(const GFSDK_Aftermath_GpuCrashDump_Decoder decoder, GFSDK_Aftermath_GpuCrashDump_BaseInfo* pBaseInfo);
GFSDK_Aftermath_PFN(GFSDK_AFTERMATH_CALL *PFN_GFSDK_Aftermath_GpuCrashDump_GetDescriptionSize)(const GFSDK_Aftermath_GpuCrashDump_Decoder decoder, const uint32_t key, uint32_t* pValueSize);
GFSDK_Aftermath_PFN(GFSDK_AFTERMATH_CALL *PFN_GFSDK_Aftermath_GpuCrashDump_GetDescription)(const GFSDK_Aftermath_GpuCrashDump_Decoder decoder, const uint32_t key, const uint32_t valueBufferSize, char* pValue);
GFSDK_Aftermath_PFN(GFSDK_AFTERMATH_CALL *PFN_GFSDK_Aftermath_GpuCrashDump_GetDeviceInfo)(const GFSDK_Aftermath_GpuCrashDump_Decoder decoder, GFSDK_Aftermath_GpuCrashDump_DeviceInfo* pDeviceInfo);
GFSDK_Aftermath_PFN(GFSDK_AFTERMATH_CALL *PFN_GFSDK_Aftermath_GpuCrashDump_GetSystemInfo)(const GFSDK_Aftermath_GpuCrashDump_Decoder decoder, GFSDK_Aftermath_GpuCrashDump_SystemInfo* pSystemInfo);
GFSDK_Aftermath_PFN(GFSDK_AFTERMATH_CALL *PFN_GFSDK_Aftermath_GpuCrashDump_GetGpuInfoCount)(const GFSDK_Aftermath_GpuCrashDump_Decoder decoder, uint32_t* pGpuCount);
GFSDK_Aftermath_PFN(GFSDK_AFTERMATH_CALL *PFN_GFSDK_Aftermath_GpuCrashDump_GetGpuInfo)(const GFSDK_Aftermath_GpuCrashDump_Decoder decoder, const uint32_t gpuInfoBufferCount, GFSDK_Aftermath_GpuCrashDump_GpuInfo* pGpuInfo);
GFSDK_Aftermath_PFN(GFSDK_AFTERMATH_CALL *PFN_GFSDK_Aftermath_GpuCrashDump_GetPageFaultInfo)(const GFSDK_Aftermath_GpuCrashDump_Decoder decoder, GFSDK_Aftermath_GpuCrashDump_PageFaultInfo* pPageFaultInfo);
GFSDK_Aftermath_PFN(GFSDK_AFTERMATH_CALL *PFN_GFSDK_Aftermath_GpuCrashDump_GetActiveShadersInfoCount)(const GFSDK_Aftermath_GpuCrashDump_Decoder decoder, uint32_t* pShaderCount);
GFSDK_Aftermath_PFN(GFSDK_AFTERMATH_CALL *PFN_GFSDK_Aftermath_GpuCrashDump_GetActiveShadersInfo)(const GFSDK_Aftermath_GpuCrashDump_Decoder decoder, const uint32_t shaderInfoBufferCount, GFSDK_Aftermath_GpuCrashDump_ShaderInfo* pShaderInfo);
GFSDK_Aftermath_PFN(GFSDK_AFTERMATH_CALL *PFN_GFSDK_Aftermath_GpuCrashDump_GetEventMarkersInfoCount)(const GFSDK_Aftermath_GpuCrashDump_Decoder decoder, const uint32_t markerInfoBufferCount);
GFSDK_Aftermath_PFN(GFSDK_AFTERMATH_CALL *PFN_GFSDK_Aftermath_GpuCrashDump_GetEventMarkersInfo)(const GFSDK_Aftermath_GpuCrashDump_Decoder decoder, const uint32_t markerInfoBufferCount, GFSDK_Aftermath_GpuCrashDump_EventMarkerInfo* pMarkerInfo);
GFSDK_Aftermath_PFN(GFSDK_AFTERMATH_CALL *PFN_GFSDK_Aftermath_GpuCrashDump_GenerateJSON)(const GFSDK_Aftermath_GpuCrashDump_Decoder decoder, uint32_t decoderFlags, uint32_t formatFlags, PFN_GFSDK_Aftermath_ShaderDebugInfoLookupCb shaderDebugInfoLookupCb, PFN_GFSDK_Aftermath_ShaderLookupCb shaderLookupCb, PFN_GFSDK_Aftermath_ShaderInstructionsLookupCb shaderInstructionsLookupCb, PFN_GFSDK_Aftermath_ShaderSourceDebugInfoLookupCb shaderSourceDebugInfoLookupCb, void* pUserData, uint32_t* pJsonSize);
GFSDK_Aftermath_PFN(GFSDK_AFTERMATH_CALL *PFN_GFSDK_Aftermath_GpuCrashDump_GetJSON)(const GFSDK_Aftermath_GpuCrashDump_Decoder decoder, const uint32_t jsonBufferSize, char* pJson);
GFSDK_Aftermath_PFN(GFSDK_AFTERMATH_CALL *PFN_GFSDK_Aftermath_GetShaderDebugInfoIdentifier)(GFSDK_Aftermath_Version apiVersion, const void* pShaderDebugInfo, const uint32_t shaderDebugInfoSize, GFSDK_Aftermath_ShaderDebugInfoIdentifier* pIdentifier);
#if defined(__d3d12_h__)
GFSDK_Aftermath_PFN(GFSDK_AFTERMATH_CALL *PFN_GFSDK_Aftermath_GetShaderHash)(GFSDK_Aftermath_Version apiVersion, const D3D12_SHADER_BYTECODE* pShader, GFSDK_Aftermath_ShaderHash* pShaderHash, GFSDK_Aftermath_ShaderInstructionsHash* pShaderInstructionsHash);
GFSDK_Aftermath_PFN(*GPFN_GFSDK_Aftermath_GetShaderDebugName)(GFSDK_Aftermath_Version apiVersion, const D3D12_SHADER_BYTECODE* pShader, GFSDK_Aftermath_ShaderDebugName* pShaderDebugName);
#endif
#if defined(VULKAN_H_)
GFSDK_Aftermath_PFN(GFSDK_AFTERMATH_CALL *PFN_GFSDK_Aftermath_GetShaderHashSpirv)(GFSDK_Aftermath_Version apiVersion, const GFSDK_Aftermath_SpirvCode *pShader, GFSDK_Aftermath_ShaderHash* pShaderHash);
GFSDK_Aftermath_PFN(GFSDK_AFTERMATH_CALL *PFN_GFSDK_Aftermath_GetShaderDebugNameSpirv)(GFSDK_Aftermath_Version apiVersion, const GFSDK_Aftermath_SpirvCode *pShader, const GFSDK_Aftermath_SpirvCode *pStrippedShader, GFSDK_Aftermath_ShaderDebugName* pShaderDebugName);
#endif
#ifdef __cplusplus
} // extern "C"
#endif
#pragma pack(pop)
#endif // GFSDK_Aftermath_CrashDumpDecoding_H