r.GPUCsvStatsEnabled
r.GPUCsvStatsEnabled
#Overview
name: r.GPUCsvStatsEnabled
This variable is created as a Console Variable (cvar).
- type:
Var
- help:
Enables or disables GPU stat recording to CSVs
It is referenced in 6
C++ source files.
#Summary
#Usage in the C++ source code
The purpose of r.GPUCsvStatsEnabled is to enable or disable GPU stat recording to CSV files. This setting is primarily used for profiling and performance analysis of GPU operations in Unreal Engine.
The Unreal Engine subsystem that relies on this setting variable is the GPU profiling system, specifically the Realtime GPU Profiler. This can be seen from the file locations where the variable is referenced, such as RealtimeGPUProfiler.cpp.
The value of this variable is set in multiple ways:
- It is initialized with a default value of 0 (disabled) in the TAutoConsoleVariable declaration.
- It can be set via command line parameter “csvGpuStats”, which sets the value to 1 (enabled).
- It can be modified at runtime through the console variable system.
The associated variable CVarGPUCsvStatsEnabled interacts directly with r.GPUCsvStatsEnabled. They are essentially the same variable, with CVarGPUCsvStatsEnabled being the C++ representation of the console variable.
Developers should be aware of the following when using this variable:
- Enabling this variable will impact performance due to the overhead of recording GPU stats.
- It’s primarily intended for debugging and profiling purposes, not for use in shipping builds.
- The stats are only recorded when the CSV profiler is actively capturing data.
Best practices for using this variable include:
- Only enable it when necessary for performance analysis or debugging.
- Be aware of the performance impact when enabled.
- Use in conjunction with other profiling tools for a comprehensive performance analysis.
- Disable it in shipping builds to avoid unnecessary overhead.
Regarding the associated variable CVarGPUCsvStatsEnabled:
- It’s the C++ representation of the r.GPUCsvStatsEnabled console variable.
- It’s used in the code to check the current state of GPU CSV stat recording.
- It’s accessed using GetValueOnRenderThread() to ensure thread-safe access in render-related code.
- Developers should use this variable when they need to programmatically check or set the state of GPU CSV stat recording in C++ code.
#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:31
Scope: file
Source code excerpt:
static TAutoConsoleVariable<int> CVarGPUCsvStatsEnabled(
TEXT("r.GPUCsvStatsEnabled"),
0,
TEXT("Enables or disables GPU stat recording to CSVs"));
DECLARE_GPU_STAT_NAMED( Total, TEXT("[TOTAL]") );
static TAutoConsoleVariable<int> CVarGPUTracingStatsEnabled(
#Loc: <Workspace>/Engine/Source/Runtime/Core/Private/ProfilingDebugging/CsvProfiler.cpp:3804
Scope (from outer to inner):
file
function void FCsvProfiler::Init
Source code excerpt:
if (FParse::Param(FCommandLine::Get(), TEXT("csvGpuStats")))
{
IConsoleVariable* CVarGPUCsvStatsEnabled = IConsoleManager::Get().FindConsoleVariable(TEXT("r.GPUCsvStatsEnabled"));
if (CVarGPUCsvStatsEnabled)
{
CVarGPUCsvStatsEnabled->Set(1);
}
}
if (FParse::Param(FCommandLine::Get(), TEXT("csvTest")))
#Associated Variable and Callsites
This variable is associated with another variable named CVarGPUCsvStatsEnabled
. They share the same value. See the following C++ source code.
#Loc: <Workspace>/Engine/Source/Runtime/Core/Private/ProfilingDebugging/CsvProfiler.cpp:3804
Scope (from outer to inner):
file
function void FCsvProfiler::Init
Source code excerpt:
if (FParse::Param(FCommandLine::Get(), TEXT("csvGpuStats")))
{
IConsoleVariable* CVarGPUCsvStatsEnabled = IConsoleManager::Get().FindConsoleVariable(TEXT("r.GPUCsvStatsEnabled"));
if (CVarGPUCsvStatsEnabled)
{
CVarGPUCsvStatsEnabled->Set(1);
}
}
if (FParse::Param(FCommandLine::Get(), TEXT("csvTest")))
{
GCsvTestingGT = true;
}
#Loc: <Workspace>/Engine/Source/Runtime/RenderCore/Private/ProfilingDebugging/RealtimeGPUProfiler.cpp:30
Scope: file
Source code excerpt:
static TAutoConsoleVariable<int> CVarGPUCsvStatsEnabled(
TEXT("r.GPUCsvStatsEnabled"),
0,
TEXT("Enables or disables GPU stat recording to CSVs"));
DECLARE_GPU_STAT_NAMED( Total, TEXT("[TOTAL]") );
#Loc: <Workspace>/Engine/Source/Runtime/RenderCore/Private/ProfilingDebugging/RealtimeGPUProfiler.cpp:574
Scope (from outer to inner):
file
class class FRealtimeGPUProfilerFrame
function bool UpdateStats
Source code excerpt:
// Update the stats
#if CSV_PROFILER
const bool bCsvStatsEnabled = !!CVarGPUCsvStatsEnabled.GetValueOnRenderThread();
FCsvProfiler* CsvProfiler = bCsvStatsEnabled ? FCsvProfiler::Get() : nullptr;
#endif
const bool GPUStatsChildTimesIncluded = !!CVarGPUStatsChildTimesIncluded.GetValueOnRenderThread();
uint64 TotalUs = 0llu;
FNameSet StatSeenSet;
#Loc: <Workspace>/Engine/Source/Runtime/RenderCore/Private/ProfilingDebugging/RealtimeGPUProfiler.cpp:1016
Scope (from outer to inner):
file
function bool AreGPUStatsEnabled
Source code excerpt:
// If we only have CSV stats, only capture if CSV GPU stats are enabled, and we're capturing
if (!CVarGPUCsvStatsEnabled.GetValueOnRenderThread())
{
return false;
}
if (!FCsvProfiler::Get()->IsCapturing_Renderthread())
{
return false;