r.GPUStatsEnabled
r.GPUStatsEnabled
#Overview
name: r.GPUStatsEnabled
This variable is created as a Console Variable (cvar).
- type:
Var
- help:
Enables or disables GPU stat recording
It is referenced in 3
C++ source files.
#Summary
#Usage in the C++ source code
The purpose of r.GPUStatsEnabled is to enable or disable GPU stat recording in Unreal Engine 5. This setting variable is primarily used for performance profiling and debugging of the rendering system.
The Unreal Engine subsystem that relies on this setting variable is the RenderCore module, specifically the RealtimeGPUProfiler component. This can be seen from the file location where the variable is defined and used: Engine/Source/Runtime/RenderCore/Private/ProfilingDebugging/RealtimeGPUProfiler.cpp.
The value of this variable is set as a console variable using TAutoConsoleVariable. It is initialized with a default value of 1, which means GPU stat recording is enabled by default.
The associated variable CVarGPUStatsEnabled interacts directly with r.GPUStatsEnabled. They share the same value and purpose.
Developers must be aware that this variable affects performance profiling capabilities. When disabled, GPU stat recording will not occur, which may impact the ability to analyze rendering performance.
Best practices when using this variable include:
- Enabling it (set to 1) when you need to profile GPU performance or debug rendering issues.
- Disabling it (set to 0) in production builds or when GPU stat recording is not needed, to avoid any potential performance overhead.
Regarding the associated variable CVarGPUStatsEnabled:
The purpose of CVarGPUStatsEnabled is the same as r.GPUStatsEnabled - to control the enabling or disabling of GPU stat recording.
It is used in the RenderCore module, specifically in the RealtimeGPUProfiler component.
The value of CVarGPUStatsEnabled is set through the console variable system, initialized with a default value of 1.
CVarGPUStatsEnabled is used directly in the AreGPUStatsEnabled() function to determine if GPU stats should be recorded. This function checks both if the hardware supports timestamp render queries (GSupportsTimestampRenderQueries) and if CVarGPUStatsEnabled is set to true on the render thread.
Developers should be aware that this variable’s value is checked on the render thread, which means changes to it will affect GPU stat recording in real-time.
Best practices for using CVarGPUStatsEnabled are the same as for r.GPUStatsEnabled, as they are essentially the same variable accessed through different means.
#References in C++ code
#Callsites
This variable is referenced in the following C++ source code:
#Loc: <Workspace>/Engine/Source/Runtime/RenderCore/Private/ProfilingDebugging/RealtimeGPUProfiler.cpp:18
Scope: file
Source code excerpt:
static TAutoConsoleVariable<int> CVarGPUStatsEnabled(
TEXT("r.GPUStatsEnabled"),
1,
TEXT("Enables or disables GPU stat recording"));
static TAutoConsoleVariable<int> CVarGPUStatsMaxQueriesPerFrame(
TEXT("r.GPUStatsMaxQueriesPerFrame"),
#Associated Variable and Callsites
This variable is associated with another variable named CVarGPUStatsEnabled
. They share the same value. See the following C++ source code.
#Loc: <Workspace>/Engine/Source/Runtime/RenderCore/Private/ProfilingDebugging/RealtimeGPUProfiler.cpp:17
Scope: file
Source code excerpt:
CSV_DEFINE_CATEGORY_MODULE(RENDERCORE_API, GPU, true);
static TAutoConsoleVariable<int> CVarGPUStatsEnabled(
TEXT("r.GPUStatsEnabled"),
1,
TEXT("Enables or disables GPU stat recording"));
static TAutoConsoleVariable<int> CVarGPUStatsMaxQueriesPerFrame(
#Loc: <Workspace>/Engine/Source/Runtime/RenderCore/Private/ProfilingDebugging/RealtimeGPUProfiler.cpp:996
Scope (from outer to inner):
file
function bool AreGPUStatsEnabled
Source code excerpt:
bool AreGPUStatsEnabled()
{
if (GSupportsTimestampRenderQueries == false || !CVarGPUStatsEnabled.GetValueOnRenderThread())
{
return false;
}
#if GPUPROFILERTRACE_ENABLED
// Force GPU profiler on if Unreal Insights is running