r.GPUScene.DebugDrawRange

r.GPUScene.DebugDrawRange

#Overview

name: r.GPUScene.DebugDrawRange

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 r.GPUScene.DebugDrawRange is to control the maximum distance for drawing instance bounds in the GPU Scene debug visualization. This setting variable is part of the rendering system, specifically the GPU Scene debugging tools.

This setting variable is used in the Renderer module of Unreal Engine 5, as evident from its location in the ‘Renderer/Private/GPUScene.cpp’ file. The GPU Scene system is a part of Unreal Engine’s rendering pipeline that manages scene data on the GPU for improved performance.

The value of this variable is set through the console variable system (CVarGPUSceneDebugDrawRange). It’s initialized with a default value of -1.0f, which represents an infinite range. Users can modify this value at runtime using console commands.

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

Developers must be aware that:

  1. This variable affects debug visualization only and doesn’t impact actual game rendering.
  2. The value is in world units (typically centimeters in Unreal Engine).
  3. A value of -1.0f means no distance limit (infinite range).

Best practices when using this variable include:

  1. Use it only for debugging purposes, not in production builds.
  2. Adjust the value to focus on specific areas of the scene when debugging GPU Scene issues.
  3. Remember to reset it to -1.0f (or remove usage) when done debugging to avoid unintended limitations in visualization.

Regarding the associated variable CVarGPUSceneDebugDrawRange:

When working with CVarGPUSceneDebugDrawRange, developers should:

  1. Use GetValueOnRenderThread() when accessing its value from render thread code.
  2. Be cautious when modifying it during runtime, as it could impact performance if set to a very large value in complex scenes.
  3. Consider exposing it in debug UI for easier adjustment during development and testing.

#References in C++ code

#Callsites

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

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

Scope: file

Source code excerpt:


static TAutoConsoleVariable<float> CVarGPUSceneDebugDrawRange(
	TEXT("r.GPUScene.DebugDrawRange"),
	-1.0f,
	TEXT("Maximum distance the to draw instance bounds, the default is -1.0 <=> infinite range."),
	ECVF_RenderThreadSafe
);

static TAutoConsoleVariable<int32> CVarGPUSceneUseGrowOnlyAllocationPolicy(

#Associated Variable and Callsites

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

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

Scope: file

Source code excerpt:

);

static TAutoConsoleVariable<float> CVarGPUSceneDebugDrawRange(
	TEXT("r.GPUScene.DebugDrawRange"),
	-1.0f,
	TEXT("Maximum distance the to draw instance bounds, the default is -1.0 <=> infinite range."),
	ECVF_RenderThreadSafe
);

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

Scope (from outer to inner):

file
function     void FGPUScene::DebugRender

Source code excerpt:

			PassParameters->SelectedPrimitiveNameInfos = GraphBuilder.CreateSRV(SelectedPrimitiveNameInfos);
			PassParameters->SelectedPrimitiveNames = GraphBuilder.CreateSRV(SelectedPrimitiveNames, PF_R8_UINT);
			PassParameters->DrawRange = CVarGPUSceneDebugDrawRange.GetValueOnRenderThread();
			PassParameters->RWDrawCounter = DrawCounterUAV;

			FVector PickingRayStart(ForceInit);
			FVector PickingRayDir(ForceInit);
			View.DeprojectFVector2D(View.CursorPos, PickingRayStart, PickingRayDir);