r.gpucrash.collectionenable

r.gpucrash.collectionenable

#Overview

name: r.gpucrash.collectionenable

This variable is created as a Console Variable (cvar).

It is referenced in 5 C++ source files.

#Summary

#Usage in the C++ source code

The purpose of r.gpucrash.collectionenable is to control the collection of GPU crash data from scoped events when an applicable crash debugging system is available. This setting variable is primarily used for GPU crash debugging and profiling purposes.

This setting variable is utilized by multiple Unreal Engine subsystems, specifically within the RHI (Rendering Hardware Interface) module and various graphics API-specific implementations such as D3D11, D3D12, and Vulkan.

The value of this variable is set through the console variable system in Unreal Engine. It is defined as a TAutoConsoleVariable with a default value of 1 (enabled) in the RHI module.

This variable interacts closely with another console variable, “r.gpucrash.datadepth”, which determines the depth of GPU crash data to collect. Together, they control the GPU crash data collection process.

Developers must be aware that this variable affects performance and memory usage when enabled, as it involves collecting additional data during rendering. It should be used judiciously, especially in production builds.

Best practices when using this variable include:

  1. Enabling it only when necessary for debugging GPU-related issues.
  2. Combining it with appropriate crash reporting systems to maximize its effectiveness.
  3. Considering the performance impact, especially on lower-end hardware.
  4. Using it in conjunction with other GPU profiling tools for comprehensive analysis.
  5. Ensuring it’s disabled in shipping builds unless absolutely necessary for diagnostics.

#References in C++ code

#Callsites

This variable is referenced in the following C++ source code:

#Loc: <Workspace>/Engine/Source/Runtime/RHI/Private/GPUProfiler.cpp:73

Scope: file

Source code excerpt:


static TAutoConsoleVariable<int32> CVarGPUCrashDataCollectionEnable(
	TEXT("r.gpucrash.collectionenable"),
	1,
	TEXT("Stores GPU crash data from scoped events when a applicable crash debugging system is available."),
	ECVF_RenderThreadSafe);

static TAutoConsoleVariable<int32> CVarGPUCrashDataDepth(
	TEXT("r.gpucrash.datadepth"),

#Loc: <Workspace>/Engine/Source/Runtime/D3D12RHI/Private/D3D12Stats.cpp:17

Scope (from outer to inner):

file
function     void D3D12RHI::FD3DGPUProfiler::BeginFrame

Source code excerpt:


	// update the crash tracking variables
	static auto* CrashCollectionEnableCvar = IConsoleManager::Get().FindTConsoleVariableDataInt(TEXT("r.gpucrash.collectionenable"));
	static auto* CrashCollectionDataDepth = IConsoleManager::Get().FindTConsoleVariableDataInt(TEXT("r.gpucrash.datadepth"));

	bTrackingGPUCrashData = CrashCollectionEnableCvar ? (FD3D12DynamicRHI::GetD3DRHI()->GetAdapter().GetGPUCrashDebuggingModes() != ED3D12GPUCrashDebuggingModes::None && CrashCollectionEnableCvar->GetValueOnRenderThread() != 0) : false;
	GPUCrashDataDepth = CrashCollectionDataDepth ? CrashCollectionDataDepth->GetValueOnRenderThread() : -1;

	// latch the bools from the game thread into our private copy

#Loc: <Workspace>/Engine/Source/Runtime/VulkanRHI/Private/VulkanUtil.cpp:560

Scope (from outer to inner):

file
function     void FVulkanGPUProfiler::BeginFrame

Source code excerpt:

	if (GGPUCrashDebuggingEnabled)
	{
		static auto* CrashCollectionEnableCvar = IConsoleManager::Get().FindTConsoleVariableDataInt(TEXT("r.gpucrash.collectionenable"));
		static auto* CrashCollectionDataDepth = IConsoleManager::Get().FindTConsoleVariableDataInt(TEXT("r.gpucrash.datadepth"));
		bTrackingGPUCrashData = CrashCollectionEnableCvar ? CrashCollectionEnableCvar->GetValueOnRenderThread() != 0 : false;
		GPUCrashDataDepth = CrashCollectionDataDepth ? CrashCollectionDataDepth->GetValueOnRenderThread() : -1;
		if (GPUCrashDataDepth == -1 || GPUCrashDataDepth > GMaxCrashBufferEntries)
		{
			if (Device->GetOptionalExtensions().HasAMDBufferMarker)

#Loc: <Workspace>/Engine/Source/Runtime/Windows/D3D11RHI/Private/D3D11RHI.cpp:281

Scope (from outer to inner):

file
function     void FD3DGPUProfiler::BeginFrame

Source code excerpt:

	check(!CurrentEventNodeFrame); // this should have already been cleaned up and the end of the previous frame

	static auto* CrashCollectionEnableCvar = IConsoleManager::Get().FindTConsoleVariableDataInt(TEXT("r.gpucrash.collectionenable"));
	static auto* CrashCollectionDataDepth = IConsoleManager::Get().FindTConsoleVariableDataInt(TEXT("r.gpucrash.datadepth"));

	bTrackingGPUCrashData = CrashCollectionEnableCvar ? CrashCollectionEnableCvar->GetValueOnRenderThread() != 0 : false;
	GPUCrashDataDepth = CrashCollectionDataDepth ? CrashCollectionDataDepth->GetValueOnRenderThread() : -1;
	
	// latch the bools from the game thread into our private copy

#Loc: <Workspace>/Engine/Source/Runtime/Windows/D3D11RHI/Private/Windows/WindowsD3D11Device.cpp:2152

Scope (from outer to inner):

file
function     void FD3D11DynamicRHI::RHIPerFrameRHIFlushComplete

Source code excerpt:

	if (GDX11NVAfterMathEnabled)
	{
		static auto* CVarGPUCrashCollectionEnabled = IConsoleManager::Get().FindTConsoleVariableDataInt(TEXT("r.gpucrash.collectionenable"));
		bool bGPUCrashCollectionEnabled = CVarGPUCrashCollectionEnabled ? CVarGPUCrashCollectionEnabled->GetValueOnRenderThread() != 0 : false;

		if (NVAftermathIMContextHandle && !bGPUCrashCollectionEnabled)
		{
			StopNVAftermath();
		}