dp.Override

dp.Override

#Overview

name: dp.Override

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 dp.Override is to provide a runtime override mechanism for the active Device Profile in Unreal Engine 5. It allows developers to dynamically change the Device Profile being used, which can affect various rendering and performance settings across the engine.

This setting variable is primarily used by the Device Profile Manager subsystem within Unreal Engine. It’s part of the Engine module, specifically within the DeviceProfiles functionality.

The value of this variable is set through a console variable (CVar) named “dp.Override”. It can be set via command line, in-game console, or programmatically at runtime.

The dp.Override variable interacts closely with an associated C++ variable named CVarDeviceProfileOverride. This is a TAutoConsoleVariable that directly corresponds to the “dp.Override” console command.

Developers should be aware of several key points when using this variable:

  1. Setting this variable will change the active Device Profile, which can have wide-ranging effects on engine performance and rendering.
  2. It automatically restores any previous overrides before setting a new one (it performs a dp.OverridePop operation).
  3. The -dp command line option will override this setting on startup, but not when set at runtime.
  4. Changes to this variable trigger a callback that invokes UDeviceProfileManager::HandleDeviceProfileOverrideChange().

Best practices for using this variable include:

  1. Use it primarily for testing and debugging purposes, not for shipping builds.
  2. Be aware of its interaction with command line arguments and other Device Profile settings.
  3. Monitor performance carefully when changing Device Profiles at runtime.
  4. Use in conjunction with other Device Profile tools and settings for comprehensive control.

Regarding the associated variable CVarDeviceProfileOverride:

This is the C++ implementation of the dp.Override console variable. It’s defined as a static TAutoConsoleVariable, which means it’s a string-type console variable that can be changed at runtime.

The CVarDeviceProfileOverride variable is used internally by the engine to store and retrieve the current override value. It’s set up with a callback that triggers the HandleDeviceProfileOverrideChange() function in the UDeviceProfileManager class whenever its value changes.

Developers working directly with the engine source code might interact with CVarDeviceProfileOverride instead of using the console command directly. The same considerations and best practices apply to both the console variable and its C++ counterpart.

#References in C++ code

#Callsites

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

#Loc: <Workspace>/Engine/Source/Runtime/Engine/Private/DeviceProfiles/DeviceProfileManager.cpp:29

Scope: file

Source code excerpt:


static TAutoConsoleVariable<FString> CVarDeviceProfileOverride(
	TEXT("dp.Override"),
	TEXT(""),
	TEXT("DeviceProfile override - setting this will use the named DP as the active DP. In addition, it will restore any\n")
	TEXT(" previous overrides before setting (does a dp.OverridePop before setting after the first time).\n")
	TEXT(" The commandline -dp option will override this on startup, but not when setting this at runtime\n"),
	ECVF_Default);

#Associated Variable and Callsites

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

#Loc: <Workspace>/Engine/Source/Runtime/Engine/Private/DeviceProfiles/DeviceProfileManager.cpp:28

Scope: file

Source code excerpt:

DEFINE_LOG_CATEGORY_STATIC(LogDeviceProfileManager, Log, All);

static TAutoConsoleVariable<FString> CVarDeviceProfileOverride(
	TEXT("dp.Override"),
	TEXT(""),
	TEXT("DeviceProfile override - setting this will use the named DP as the active DP. In addition, it will restore any\n")
	TEXT(" previous overrides before setting (does a dp.OverridePop before setting after the first time).\n")
	TEXT(" The commandline -dp option will override this on startup, but not when setting this at runtime\n"),
	ECVF_Default);

#Loc: <Workspace>/Engine/Source/Runtime/Engine/Private/DeviceProfiles/DeviceProfileManager.cpp:78

Scope (from outer to inner):

file
function     UDeviceProfileManager& UDeviceProfileManager::Get

Source code excerpt:


		// now we allow the cvar changes to be acknowledged
		CVarDeviceProfileOverride.AsVariable()->SetOnChangedCallback(FConsoleVariableDelegate::CreateLambda([](IConsoleVariable* Variable)
		{
			UDeviceProfileManager::Get().HandleDeviceProfileOverrideChange();
		}));

		IConsoleManager::Get().RegisterConsoleCommand(
			TEXT("dp.Override.Restore"),

#Loc: <Workspace>/Engine/Source/Runtime/Engine/Private/DeviceProfiles/DeviceProfileManager.cpp:1120

Scope (from outer to inner):

file
function     void UDeviceProfileManager::HandleDeviceProfileOverrideChange

Source code excerpt:

void UDeviceProfileManager::HandleDeviceProfileOverrideChange()
{
	FString CVarValue = CVarDeviceProfileOverride.GetValueOnGameThread();
	// only handle when the value is different
	if (CVarValue.Len() > 0 && CVarValue != GetActiveProfile()->GetName())
	{
		FString PlatformName = ANSI_TO_TCHAR(FPlatformProperties::IniPlatformName());
		
		TArray<FString> DeviceProfileNameAndTypes;

#Loc: <Workspace>/Engine/Source/Runtime/Engine/Private/DeviceProfiles/DeviceProfileManager.cpp:1253

Scope (from outer to inner):

file
function     const FString UDeviceProfileManager::GetPlatformDeviceProfileName

Source code excerpt:


	// look for cvar override
	OverrideProfileName = CVarDeviceProfileOverride.GetValueOnGameThread();
	if (OverrideProfileName.Len() > 0)
	{
		return OverrideProfileName;
	}

	if (IDeviceProfileSelectorModule* DPSelectorModule = GetDeviceProfileSelectorModule())