r.GPUScene.DebugDrawRange
r.GPUScene.DebugDrawRange
#Overview
name: r.GPUScene.DebugDrawRange
This variable is created as a Console Variable (cvar).
- type:
Var
- help:
Maximum distance the to draw instance bounds, the default is -1.0 <=> infinite range.
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:
- This variable affects debug visualization only and doesn’t impact actual game rendering.
- The value is in world units (typically centimeters in Unreal Engine).
- A value of -1.0f means no distance limit (infinite range).
Best practices when using this variable include:
- Use it only for debugging purposes, not in production builds.
- Adjust the value to focus on specific areas of the scene when debugging GPU Scene issues.
- Remember to reset it to -1.0f (or remove usage) when done debugging to avoid unintended limitations in visualization.
Regarding the associated variable CVarGPUSceneDebugDrawRange:
- It’s a TAutoConsoleVariable of type float, which means it can be modified at runtime through console commands.
- It’s marked as ECVF_RenderThreadSafe, indicating it’s safe to modify from the render thread.
- It’s used directly in the FGPUScene::DebugRender function to set the draw range for debug visualization.
When working with CVarGPUSceneDebugDrawRange, developers should:
- Use GetValueOnRenderThread() when accessing its value from render thread code.
- Be cautious when modifying it during runtime, as it could impact performance if set to a very large value in complex scenes.
- 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);