r.DisplayInternals

r.DisplayInternals

#Overview

name: r.DisplayInternals

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

It is referenced in 6 C++ source files.

#Summary

#Usage in the C++ source code

The purpose of r.DisplayInternals is to enable screen printouts that show the internals of the engine and renderer. This setting variable is primarily used for debugging and analysis purposes, allowing developers to visualize and understand why screenshots might look different under various conditions.

This setting variable is mainly utilized by the Renderer subsystem of Unreal Engine 5. It is referenced in the SceneRendering.cpp file, which is a core part of the rendering pipeline.

The value of this variable is set through a console variable (CVar) named CVarDisplayInternals. It is defined as a TAutoConsoleVariable with default value 0 (off) and can be changed to 1 (enabled) through the console or configuration files.

The r.DisplayInternals variable interacts with the FDisplayInternalsData struct, which is used to pass data from the main thread to the render thread. This struct contains a DisplayInternalsCVarValue member that stores the current value of the r.DisplayInternals setting.

Developers should be aware that this variable is intended for debugging and analysis purposes. It should not be enabled in shipping builds, as it may impact performance and expose internal information that’s not meant for end-users.

Best practices for using this variable include:

  1. Use it only during development and debugging phases.
  2. Be cautious when enabling it in performance-critical scenarios, as it may introduce overhead.
  3. Remember to disable it before creating release builds.

Regarding the associated variable CVarDisplayInternals:

The purpose of CVarDisplayInternals is to provide a console-accessible way to control the r.DisplayInternals setting. It is defined as a TAutoConsoleVariable, which allows it to be changed at runtime through the console.

This variable is used within the Renderer subsystem, specifically in the SceneRendering.cpp file.

The value of CVarDisplayInternals is set when it’s defined, with a default value of 0. It can be changed through the console or configuration files.

CVarDisplayInternals directly interacts with the r.DisplayInternals setting, effectively controlling its value.

Developers should be aware that changes to CVarDisplayInternals will immediately affect the behavior of r.DisplayInternals. They should also note that this variable is marked with ECVF_RenderThreadSafe and ECVF_Cheat flags, indicating it’s safe to change on the render thread and is considered a cheat command.

Best practices for using CVarDisplayInternals include:

  1. Use it for debugging and analysis purposes only.
  2. Be mindful of potential performance impacts when enabling it.
  3. Ensure it’s disabled in shipping builds.
  4. When changing its value, be prepared for immediate changes in the engine’s behavior regarding internal displays.

#References in C++ code

#Callsites

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

#Loc: <Workspace>/Engine/Source/Runtime/Renderer/Private/SceneRendering.cpp:298

Scope: file

Source code excerpt:


static TAutoConsoleVariable<int32> CVarDisplayInternals(
	TEXT("r.DisplayInternals"),
	0,
	TEXT("Allows to enable screen printouts that show the internals on the engine/renderer\n")
	TEXT("This is mostly useful to be able to reason why a screenshots looks different.\n")
	TEXT(" 0: off (default)\n")
	TEXT(" 1: enabled"),
	ECVF_RenderThreadSafe | ECVF_Cheat);

#Loc: <Workspace>/Engine/Source/Runtime/Engine/Public/SceneView.h:1881

Scope: file

Source code excerpt:

//////////////////////////////////////////////////////////////////////////

// for r.DisplayInternals (allows for easy passing down data from main to render thread)
struct FDisplayInternalsData
{
	//
	int32 DisplayInternalsCVarValue;
	// -1 if not set, from IStreamingManager::Get().StreamAllResources(Duration) in FStreamAllResourcesLatentCommand
	uint32 NumPendingStreamingRequests;

#Loc: <Workspace>/Engine/Source/Runtime/Engine/Public/SceneView.h:2204

Scope: file

Source code excerpt:

	TArray<TSharedRef<class ISceneViewExtension, ESPMode::ThreadSafe> > ViewExtensions;

	// for r.DisplayInternals (allows for easy passing down data from main to render thread)
	FDisplayInternalsData DisplayInternalsData;

	/**
	 * Secondary view fraction to support High DPI monitor still with same primary screen percentage range for temporal
	 * upscale to test content consistently in editor no mater of the HighDPI scale. 
	 */

#Loc: <Workspace>/Engine/Source/Runtime/Renderer/Private/SceneRendering.cpp:5561

Scope (from outer to inner):

file
function     static void DisplayInternals

Source code excerpt:

#if !(UE_BUILD_SHIPPING || UE_BUILD_TEST)
	auto Family = InView.Family;
	// if r.DisplayInternals != 0
	if(Family->EngineShowFlags.OnScreenDebug && Family->DisplayInternalsData.IsValid())
	{
		FRDGTextureRef OutputTexture = GraphBuilder.FindExternalTexture(Family->RenderTarget->GetRenderTargetTexture());
		FScreenPassRenderTarget Output = FScreenPassRenderTarget::CreateViewFamilyOutput(OutputTexture, InView);
		AddDrawCanvasPass(GraphBuilder, RDG_EVENT_NAME("DisplayInternals"), InView, Output, [Family, &InView](FCanvas& Canvas)
		{

#Associated Variable and Callsites

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

#Loc: <Workspace>/Engine/Source/Runtime/Renderer/Private/SceneRendering.cpp:297

Scope: file

Source code excerpt:

	ECVF_RenderThreadSafe);

static TAutoConsoleVariable<int32> CVarDisplayInternals(
	TEXT("r.DisplayInternals"),
	0,
	TEXT("Allows to enable screen printouts that show the internals on the engine/renderer\n")
	TEXT("This is mostly useful to be able to reason why a screenshots looks different.\n")
	TEXT(" 0: off (default)\n")
	TEXT(" 1: enabled"),

#Loc: <Workspace>/Engine/Source/Runtime/Renderer/Private/SceneRendering.cpp:2477

Scope (from outer to inner):

file
function     void FDisplayInternalsData::Setup

Source code excerpt:


#if !(UE_BUILD_SHIPPING || UE_BUILD_TEST)
	DisplayInternalsCVarValue = CVarDisplayInternals.GetValueOnGameThread();

	if(IsValid())
	{
#if WITH_AUTOMATION_TESTS
		// this variable is defined inside WITH_AUTOMATION_TESTS, 
		extern ENGINE_API uint32 GStreamAllResourcesStillInFlight;