r.GPUScene.DebugMode

r.GPUScene.DebugMode

#Overview

name: r.GPUScene.DebugMode

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

It is referenced in 4 C++ source files.

#Summary

#Usage in the C++ source code

The purpose of r.GPUScene.DebugMode is to control the debug rendering mode for the GPU Scene system in Unreal Engine 5. This setting variable is primarily used for visualization and debugging of the GPU Scene data.

The GPU Scene system is part of Unreal Engine’s rendering subsystem. Based on the callsites, this variable is used within the Renderer module, specifically in the GPUScene component.

The value of this variable is set through the console variable system (CVarGPUSceneDebugMode). It can be changed at runtime using console commands or through configuration files.

The associated variable CVarGPUSceneDebugMode interacts directly with r.GPUScene.DebugMode. They share the same value and purpose.

Developers should be aware that:

  1. This variable affects rendering performance when enabled, as it adds debug visualization.
  2. It has different modes (0-3) for various debugging purposes:
    • 0: Show nothing (default)
    • 1: Draw All
    • 2: Draw Selected (in the editor)
    • 3: Draw Updated (updated this frame)

Best practices when using this variable include:

  1. Use it only during development and debugging, not in production builds.
  2. Be mindful of the performance impact when enabled.
  3. Use the appropriate debug mode based on the specific debugging needs.

Regarding the associated variable CVarGPUSceneDebugMode:

Developers should note that changing CVarGPUSceneDebugMode will directly affect the behavior of the GPU Scene debug rendering. It’s a powerful tool for visualizing and understanding the GPU Scene system but should be used judiciously due to its performance implications.

#References in C++ code

#Callsites

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

#Loc: <Workspace>/Engine/Source/Runtime/Renderer/Private/GPUScene.cpp:80

Scope: file

Source code excerpt:


static TAutoConsoleVariable<int32> CVarGPUSceneDebugMode(
	TEXT("r.GPUScene.DebugMode"),
	0,
	TEXT("Debug Rendering Mode:\n")
	TEXT("0 - (show nothing, decault)\n")
	TEXT(" 1 - Draw All\n")
	TEXT(" 2 - Draw Selected (in the editor)\n")
	TEXT(" 3 - Draw Updated (updated this frame)\n")

#Loc: <Workspace>/Engine/Source/Runtime/Renderer/Private/GPUScene.h:272

Scope (from outer to inner):

file
class        class FGPUScene

Source code excerpt:

	/**
	 * Draw GPU-Scene debug info, such as bounding boxes. Call once per view at some point in the frame after GPU scene has been updated fully.
	 * What is drawn is controlled by the CVar: r.GPUScene.DebugMode. Enabling this cvar causes ShaderDraw to be being active (if supported). 
	 */
	void DebugRender(FRDGBuilder& GraphBuilder, FSceneUniformBuffer& SceneUniformBuffer, FViewInfo& View);

	/**
	 * Manually trigger an allocator consolidate (will otherwise be done when an item is allocated).
	 */
	void ConsolidateInstanceDataAllocations();

	/**

#Associated Variable and Callsites

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

#Loc: <Workspace>/Engine/Source/Runtime/Renderer/Private/GPUScene.cpp:79

Scope: file

Source code excerpt:

);

static TAutoConsoleVariable<int32> CVarGPUSceneDebugMode(
	TEXT("r.GPUScene.DebugMode"),
	0,
	TEXT("Debug Rendering Mode:\n")
	TEXT("0 - (show nothing, decault)\n")
	TEXT(" 1 - Draw All\n")
	TEXT(" 2 - Draw Selected (in the editor)\n")

#Loc: <Workspace>/Engine/Source/Runtime/Renderer/Private/GPUScene.cpp:1918

Scope (from outer to inner):

file
function     void FGPUScene::DebugRender

Source code excerpt:

void FGPUScene::DebugRender(FRDGBuilder& GraphBuilder, FSceneUniformBuffer& SceneUniformBuffer, FViewInfo& View)
{
	int32 DebugMode = CVarGPUSceneDebugMode.GetValueOnRenderThread();
	if (DebugMode > 0)
	{
		// Force ShaderPrint on.
		ShaderPrint::SetEnabled(true); 

		int32 NumInstances = InstanceSceneDataAllocator.GetMaxSize();