UDocumentation UE5.7 10.02.2026 (Source)
API documentation for Unreal Engine 5.7
RHICoreNvidiaAftermath.h
Go to the documentation of this file.
1// Copyright Epic Games, Inc. All Rights Reserved.
2
3#pragma once
4
5#ifndef NV_AFTERMATH
6#define NV_AFTERMATH 0
7#endif
8
9#if NV_AFTERMATH
10
11 #include "RHIBreadcrumbs.h"
12
13 //
14 // Disabled for now until we can solve RHI breadcrumb lifetime issues with Aftermath.
15 // (Aftermath holds pointers to FRHIBreadcrumbNode instances which we may have already deleted by the time the crash callback happens).
16 //
17 #define NV_AFTERMATH_USE_BREADCRUMB_PTRS 0
18
19 namespace UE::RHICore::Nvidia::Aftermath
20 {
21 typedef TUniqueFunction<void(float TimeLimitSeconds, uint32 FrameLimit)> FAssociateShadersFunc;
22
23 RHICORE_API bool IsEnabled();
26
27 //
28 // Called by platform RHIs to activate Aftermath.
29 // The optional ResolveMarkerFunc is provided for platform RHIs to replace the default marker resolution with something custom.
30 //
32
33 //
34 // Called by the crash handler to associate shaders after a GPU fault
35 //
37
38 //
39 // Called by platform RHIs after device creation.
40 // InitCallback should return an Aftermath result value.
41 //
43
44 using FShaderHash = uint64;
45
46 static constexpr FShaderHash InvalidShaderHash = UINT64_MAX;
47
48 //
49 // Register a new shader binary with Aftermath, must be valid.
50 // Returns the internal shader hash, must be deregistered with DeregisterShaderBinary
51 //
52 RHICORE_API FShaderHash RegisterShaderBinary(const void* ShaderBinary, uint32 ByteSize, const FStringView& DebugName = nullptr);
53
54 //
55 // Deregister a shader binary from its hash. Will not release it immediately,
56 // but instead enqueue it for later eviction once the GPU work is done.
57 //
59
60 struct FCrashResult
61 {
62 FString OutputLog;
65 };
66
67 //
68 // Called by platform RHIs when a GPU crash is detected.
69 // Waits for Aftermath to finish crash dump processing, then returns the result.
70 //
71 UE_DEPRECATED(5.6, "Use OnGPUCrash(OutResults) overload instead, Aftermath may report multiple crashes")
72 RHICORE_API FCrashResult OnGPUCrash();
73
74 //
75 // Called by platform RHIs when a GPU crash is detected.
76 // Waits for Aftermath to finish crash dump processing, then returns the result.
77 //
79
80 static inline constexpr TCHAR RootNodeName[] = TEXT("<root>");
81
82 //
83 // Platform RHI helper for implementing RHIBeginBreadcrumbGPU / RHIEndBreadcrumbGPU
84 //
85 #if WITH_RHI_BREADCRUMBS
86 class FMarker
87 {
88 #if !NV_AFTERMATH_USE_BREADCRUMB_PTRS
89 FRHIBreadcrumb::FBuffer Buffer;
90 #endif
91
92 void const* Ptr = nullptr;
93 uint32 Size = 0;
94
95 public:
97 {
98 if (!AreMarkersEnabled())
99 return;
100
101 #if NV_AFTERMATH_USE_BREADCRUMB_PTRS
102 //
103 // Have Aftermath store the breadcrumb node pointer directly.
104 // Aftermath marker API fails if passed nullptr, so replace the tree root with the sentinel node.
105 //
106 Ptr = Breadcrumb ? Breadcrumb : FRHIBreadcrumbNode::Sentinel;
107 #else
108 // Generate the breadcrumb node name and have Aftermath copy the string.
109 TCHAR const* NameStr = Breadcrumb ? Breadcrumb->GetTCHAR(Buffer) : RootNodeName;
110 Ptr = NameStr;
111 Size = (FCString::Strlen(NameStr) + 1) * sizeof(TCHAR);// Include null terminator
112 #endif
113 }
114
115 operator bool() const { return Ptr != nullptr; }
116
117 void* GetPtr () const { return const_cast<void*>(Ptr); }
118 uint32 GetSize() const { return Size; }
119 };
120 #endif // WITH_RHI_BREADCRUMBS
121 };
122
123#endif // NV_AFTERMATH
OODEFFUNC typedef void(OODLE_CALLBACK t_fp_OodleCore_Plugin_Free)(void *ptr)
#define UE_DEPRECATED(Version, Message)
Definition CoreMiscDefines.h:302
#define TEXT(x)
Definition Platform.h:1272
FPlatformTypes::TCHAR TCHAR
Either ANSICHAR or WIDECHAR, depending on whether the platform supports wide characters or the requir...
Definition Platform.h:1135
FPlatformTypes::uint64 uint64
A 64-bit unsigned integer.
Definition Platform.h:1117
UE_FORCEINLINE_HINT TSharedRef< CastToType, Mode > StaticCastSharedRef(TSharedRef< CastFromType, Mode > const &InSharedRef)
Definition SharedPointer.h:127
UE_FORCEINLINE_HINT uint32 GetPtr() const
Definition LockFreeList.h:15
const bool
Definition NetworkReplayStreaming.h:178
uint32 Size
Definition VulkanMemory.cpp:4034
uint32_t uint32
Definition binka_ue_file_header.h:6
Definition Array.h:670
Definition AssetRegistryState.h:50
Definition FunctionFwd.h:19
static int32 Strlen(const CharType *String)
Definition CString.h:1047
Definition Optional.h:131