r.ProfileGPU.Sort
r.ProfileGPU.Sort
#Overview
name: r.ProfileGPU.Sort
This variable is created as a Console Variable (cvar).
- type:
Var
- help:
Sorts the TTY Dump independently at each level of the tree in various modes.\n0 : Chronological\n1 : By time elapsed\n2 : By number of prims\n3 : By number of verts\n
It is referenced in 3
C++ source files.
#Summary
#Usage in the C++ source code
The purpose of r.ProfileGPU.Sort is to control the sorting of GPU profiling data in the Unreal Engine’s GPU profiler. This setting variable is used to determine how the profiling information is organized and presented in the TTY (Teletype) dump output.
This setting variable is primarily used in the RHI (Rendering Hardware Interface) module of Unreal Engine, specifically in the GPU profiler subsystem. The RHI module is responsible for abstracting the low-level graphics API calls, and the GPU profiler is a part of this module that helps developers analyze GPU performance.
The value of this variable is set through the console variable system in Unreal Engine. It can be changed at runtime using console commands or through configuration files.
The r.ProfileGPU.Sort variable interacts directly with its associated variable GProfileGPUSort. They share the same value and purpose. GProfileGPUSort is the actual C++ variable that stores the sorting mode, while r.ProfileGPU.Sort is the console variable name used to set and access this value.
Developers should be aware that this variable affects how GPU profiling data is presented, which can impact the analysis of performance issues. The different sorting modes allow for various ways to prioritize and view the profiling data:
0: Chronological order 1: Sorted by time elapsed 2: Sorted by number of primitives 3: Sorted by number of vertices
Best practices when using this variable include:
- Use different sorting modes to gain different insights into GPU performance.
- Remember that changing the sort mode doesn’t affect performance itself, only how the data is presented.
- When comparing profiling results, ensure the sort mode is consistent across comparisons.
- Use the appropriate sort mode based on what you’re trying to optimize (e.g., use mode 1 when focusing on time-intensive operations, or mode 2 when looking at geometry complexity).
Regarding the associated variable GProfileGPUSort:
The purpose of GProfileGPUSort is to store the current sorting mode for GPU profiling data within the C++ code of the GPU profiler. It’s the internal representation of the r.ProfileGPU.Sort console variable.
GProfileGPUSort is used directly in the GPU profiler code to determine how to sort the profiling data before output. It’s accessed using the GetValueOnRenderThread() method, ensuring thread-safe access to the current value.
The value of GProfileGPUSort is set automatically when r.ProfileGPU.Sort is changed, as they are linked through the console variable system.
Developers should be aware that GProfileGPUSort is used in the render thread, so any changes to r.ProfileGPU.Sort will take effect on the next frame or profiling pass.
Best practices for GProfileGPUSort include:
- Avoid directly modifying GProfileGPUSort in code; instead, use the r.ProfileGPU.Sort console variable to change its value.
- When reading the value in code, always use GetValueOnRenderThread() to ensure thread-safe access.
- Remember that the value is clamped between 0 and (EMax - 1) to prevent invalid sorting modes.
#References in C++ code
#Callsites
This variable is referenced in the following C++ source code:
#Loc: <Workspace>/Engine/Source/Runtime/RHI/Private/GPUProfiler.cpp:94
Scope: file
Source code excerpt:
static TAutoConsoleVariable<int32> GProfileGPUSort(
TEXT("r.ProfileGPU.Sort"),
0,
TEXT("Sorts the TTY Dump independently at each level of the tree in various modes.\n")
TEXT("0 : Chronological\n")
TEXT("1 : By time elapsed\n")
TEXT("2 : By number of prims\n")
TEXT("3 : By number of verts\n"),
#Associated Variable and Callsites
This variable is associated with another variable named GProfileGPUSort
. They share the same value. See the following C++ source code.
#Loc: <Workspace>/Engine/Source/Runtime/RHI/Private/GPUProfiler.cpp:93
Scope: file
Source code excerpt:
};
static TAutoConsoleVariable<int32> GProfileGPUSort(
TEXT("r.ProfileGPU.Sort"),
0,
TEXT("Sorts the TTY Dump independently at each level of the tree in various modes.\n")
TEXT("0 : Chronological\n")
TEXT("1 : By time elapsed\n")
TEXT("2 : By number of prims\n")
#Loc: <Workspace>/Engine/Source/Runtime/RHI/Private/GPUProfiler.cpp:365
Scope (from outer to inner):
file
function static void DumpStatsEventNode
Source code excerpt:
};
EGPUProfileSortMode SortMode = (EGPUProfileSortMode)FMath::Clamp(GProfileGPUSort.GetValueOnRenderThread(), 0, ((int32)EGPUProfileSortMode::EMax - 1));
if (SortMode != EGPUProfileSortMode::EChronological)
{
Node->Children.Sort(FCompareGPUProfileNode(SortMode));
}
float TotalChildTime = 0;