renderdoc.AutoAttach

renderdoc.AutoAttach

#Overview

name: renderdoc.AutoAttach

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

It is referenced in 3 C++ source files.

#Summary

#Usage in the C++ source code

The purpose of renderdoc.AutoAttach is to control whether the RenderDoc debugging tool automatically attaches to the Unreal Engine process on startup.

This setting variable is primarily used by the RenderDoc plugin, which is a developer tool for graphics debugging in Unreal Engine 5. It’s part of the rendering system’s debugging capabilities.

The RenderDoc plugin, located in the Developer category of Unreal Engine’s plugin system, relies on this setting variable. Specifically, it’s used in the RenderDocPluginLoader module.

The value of this variable is set through a console variable (CVar) system. It’s defined as a TAutoConsoleVariable with an initial value of 0, meaning it’s disabled by default. Developers can change this value through project settings, command-line arguments, or during runtime using console commands.

The associated variable CVarRenderDocAutoAttach directly interacts with renderdoc.AutoAttach. They share the same value and purpose.

Developers must be aware that enabling this variable will cause RenderDoc to attach to the Unreal Engine process on startup, which can impact performance. It should only be enabled when graphics debugging is necessary.

Best practices for using this variable include:

  1. Enable it only when needed for graphics debugging.
  2. Disable it for production builds or when not actively debugging graphics issues.
  3. Consider using the command-line parameter ‘-AttachRenderDoc’ for temporary enabling without changing project settings.

Regarding the associated variable CVarRenderDocAutoAttach:

The purpose of CVarRenderDocAutoAttach is identical to renderdoc.AutoAttach. It’s the C++ representation of the console variable.

This variable is used within the RenderDocPluginLoader module to determine whether to load the RenderDoc plugin on startup.

The value of CVarRenderDocAutoAttach is set when the renderdoc.AutoAttach console variable is set.

CVarRenderDocAutoAttach interacts directly with the FParse::Param function to check if the ‘-AttachRenderDoc’ command-line argument is present.

Developers should be aware that this variable is checked in the FRenderDocPluginLoader::Initialize() function to determine whether to load the RenderDoc plugin.

Best practices for CVarRenderDocAutoAttach are the same as for renderdoc.AutoAttach, as they represent the same setting. Developers should use the console variable system to modify this value, rather than attempting to change CVarRenderDocAutoAttach directly in code.

#References in C++ code

#Callsites

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

#Loc: <Workspace>/Engine/Plugins/Developer/RenderDocPlugin/Source/RenderDocPlugin/Private/RenderDocPluginLoader.cpp:23

Scope: file

Source code excerpt:


static TAutoConsoleVariable<int32> CVarRenderDocAutoAttach(
	TEXT("renderdoc.AutoAttach"),
	0,
	TEXT("RenderDoc will attach on startup."));

static TAutoConsoleVariable<int32> CVarRenderDocEnableCrashHandler(
	TEXT("renderdoc.EnableCrashHandler"),
	0,

#Associated Variable and Callsites

This variable is associated with another variable named CVarRenderDocAutoAttach. They share the same value. See the following C++ source code.

#Loc: <Workspace>/Engine/Plugins/Developer/RenderDocPlugin/Source/RenderDocPlugin/Private/RenderDocPluginLoader.cpp:22

Scope: file

Source code excerpt:

#define LOCTEXT_NAMESPACE "RenderDocPlugin"

static TAutoConsoleVariable<int32> CVarRenderDocAutoAttach(
	TEXT("renderdoc.AutoAttach"),
	0,
	TEXT("RenderDoc will attach on startup."));

static TAutoConsoleVariable<int32> CVarRenderDocEnableCrashHandler(
	TEXT("renderdoc.EnableCrashHandler"),

#Loc: <Workspace>/Engine/Plugins/Developer/RenderDocPlugin/Source/RenderDocPlugin/Private/RenderDocPluginLoader.cpp:196

Scope (from outer to inner):

file
function     void FRenderDocPluginLoader::Initialize

Source code excerpt:

	UE::ConfigUtilities::ApplyCVarSettingsFromIni(TEXT("/Script/RenderDocPlugin.RenderDocPluginSettings"), *GEngineIni, ECVF_SetByProjectSetting);

	const bool bCapture = FParse::Param(FCommandLine::Get(), TEXT("AttachRenderDoc")) || (CVarRenderDocAutoAttach.GetValueOnAnyThread() != 0);
	if (!bCapture)
	{
		UE_LOG(RenderDocPlugin, Display, TEXT("RenderDoc plugin will not be loaded. Use '-AttachRenderDoc' on the cmd line or enable 'renderdoc.AutoAttach' in the plugin settings."));
		return;
	}