r.GPUScene.DebugMode
r.GPUScene.DebugMode
#Overview
name: r.GPUScene.DebugMode
This variable is created as a Console Variable (cvar).
- type:
Var
- help:
Debug Rendering Mode:\n0 - (show nothing, decault)\n 1 - Draw All\n 2 - Draw Selected (in the editor)\n 3 - Draw Updated (updated this frame)\nYou can use r.GPUScene.DebugDrawRange to limit the range\n
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:
- This variable affects rendering performance when enabled, as it adds debug visualization.
- 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:
- Use it only during development and debugging, not in production builds.
- Be mindful of the performance impact when enabled.
- Use the appropriate debug mode based on the specific debugging needs.
Regarding the associated variable CVarGPUSceneDebugMode:
- It’s an auto console variable of type int32.
- It’s used to directly control the debug rendering mode in the FGPUScene::DebugRender function.
- When a non-zero value is set, it forces ShaderPrint to be enabled, which is likely used for on-screen debug output.
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();