GPUSort.DebugSort
GPUSort.DebugSort
#Overview
name: GPUSort.DebugSort
This variable is created as a Console Variable (cvar).
- type:
Var
- help:
Debug GPU sorting.
It is referenced in 6
C++ source files.
#Summary
#Usage in the C++ source code
The purpose of GPUSort.DebugSort is to enable debugging for GPU sorting operations in Unreal Engine 5. This setting variable is primarily used for the rendering system, specifically for GPU-based sorting algorithms.
The Unreal Engine subsystem that relies on this setting variable is the GPU sorting module, which is part of the engine’s rendering pipeline. This can be inferred from the file name “GPUSort.cpp” and the various functions related to GPU sorting.
The value of this variable is set through the console variable system. It’s defined as a static TAutoConsoleVariable with a default value of 0, meaning debugging is disabled by default. Developers can change this value at runtime using console commands or programmatically.
GPUSort.DebugSort interacts closely with another variable called GPUSort.DebugOffsets. Both of these variables are often used together to control different aspects of GPU sort debugging.
Developers must be aware that enabling this debug variable may impact performance, as it likely introduces additional checks or logging during the GPU sorting process. It should primarily be used for troubleshooting and development purposes, not in production builds.
Best practices when using this variable include:
- Only enable it when actively debugging GPU sorting issues.
- Disable it in release builds to avoid any performance overhead.
- Use it in conjunction with GPUSort.DebugOffsets for comprehensive debugging.
- Be prepared to analyze additional debug output or behavior when this variable is enabled.
Regarding the associated variable GPUSort.DebugOffsets:
The purpose of GPUSort.DebugOffsets is to enable debugging for GPU sort offsets, which is a specific aspect of the GPU sorting algorithm.
Like GPUSort.DebugSort, this variable is part of the GPU sorting module in the rendering system. It’s defined and used in the same file (GPUSort.cpp).
The value of GPUSort.DebugOffsets is also set through the console variable system, with a default value of 0 (disabled).
Both GPUSort.DebugOffsets and GPUSort.DebugSort are often used together to provide comprehensive debugging for the GPU sorting process.
Developers should be aware that enabling GPUSort.DebugOffsets may also impact performance and should be used primarily for development and troubleshooting.
Best practices for GPUSort.DebugOffsets are similar to those for GPUSort.DebugSort: use it judiciously, disable in release builds, and be prepared to analyze additional debug information when enabled.
#References in C++ code
#Callsites
This variable is referenced in the following C++ source code:
#Loc: <Workspace>/Engine/Source/Runtime/Engine/Private/GPUSort.cpp:23
Scope: file
Source code excerpt:
static TAutoConsoleVariable<int32> CVarDebugOffsets(TEXT("GPUSort.DebugOffsets"),0,TEXT("Debug GPU sort offsets."));
static TAutoConsoleVariable<int32> CVarDebugSort(TEXT("GPUSort.DebugSort"),0,TEXT("Debug GPU sorting."));
#define GPUSORT_BITCOUNT 32
#define RADIX_BITS 4
#define DIGIT_COUNT (1 << RADIX_BITS)
#define KEYS_PER_LOOP 8
#define THREAD_COUNT 128
#Loc: <Workspace>/Engine/Source/Runtime/Engine/Private/GPUSort.cpp:832
Scope (from outer to inner):
file
function static void RunGPUSortTestWithDebug
Source code excerpt:
{
static IConsoleVariable* IVarDebugOffsets = IConsoleManager::Get().FindConsoleVariable(TEXT("GPUSort.DebugOffsets"));
static IConsoleVariable* IVarDebugSort = IConsoleManager::Get().FindConsoleVariable(TEXT("GPUSort.DebugSort"));
const bool bWasDebuggingOffsets = CVarDebugOffsets.GetValueOnRenderThread() != 0;
const bool bWasDebuggingSort = CVarDebugSort.GetValueOnRenderThread() != 0;
IVarDebugOffsets->Set(1, ECVF_SetByCode);
IVarDebugSort->Set(1, ECVF_SetByCode);
RunGPUSortTest(RHICmdList, TestSize, FeatureLevel);
IVarDebugOffsets->Set(bWasDebuggingOffsets ? 1 : 0, ECVF_SetByCode);
#Associated Variable and Callsites
This variable is associated with another variable named CVarDebugSort
. They share the same value. See the following C++ source code.
#Loc: <Workspace>/Engine/Source/Runtime/Engine/Private/GPUSort.cpp:23
Scope: file
Source code excerpt:
static TAutoConsoleVariable<int32> CVarDebugOffsets(TEXT("GPUSort.DebugOffsets"),0,TEXT("Debug GPU sort offsets."));
static TAutoConsoleVariable<int32> CVarDebugSort(TEXT("GPUSort.DebugSort"),0,TEXT("Debug GPU sorting."));
#define GPUSORT_BITCOUNT 32
#define RADIX_BITS 4
#define DIGIT_COUNT (1 << RADIX_BITS)
#define KEYS_PER_LOOP 8
#define THREAD_COUNT 128
#Loc: <Workspace>/Engine/Source/Runtime/Engine/Private/GPUSort.cpp:508
Scope (from outer to inner):
file
function int32 SortGPUBuffers
Source code excerpt:
FRadixSortUniformBufferRef SortUniformBufferRef;
const bool bDebugOffsets = CVarDebugOffsets.GetValueOnRenderThread() != 0;
const bool bDebugSort = CVarDebugSort.GetValueOnRenderThread() != 0;
SCOPED_DRAW_EVENTF(RHICmdList, SortGPU, TEXT("Sort(%d)"), Count);
// Determine how many tiles need to be sorted.
const int32 TileCount = Count / TILE_SIZE;
#Loc: <Workspace>/Engine/Source/Runtime/Engine/Private/GPUSort.cpp:717
Scope (from outer to inner):
file
function static bool RunGPUSortTest
Source code excerpt:
const int32 BufferSize = TestSize * sizeof(uint32);
const bool bDebugOffsets = CVarDebugOffsets.GetValueOnRenderThread() != 0;
const bool bDebugSort = CVarDebugSort.GetValueOnRenderThread() != 0;
// Generate the test keys.
Keys.Reserve(TestSize);
Keys.AddUninitialized(TestSize);
for (int32 KeyIndex = 0; KeyIndex < TestSize; ++KeyIndex)
{
#Loc: <Workspace>/Engine/Source/Runtime/Engine/Private/GPUSort.cpp:834
Scope (from outer to inner):
file
function static void RunGPUSortTestWithDebug
Source code excerpt:
static IConsoleVariable* IVarDebugSort = IConsoleManager::Get().FindConsoleVariable(TEXT("GPUSort.DebugSort"));
const bool bWasDebuggingOffsets = CVarDebugOffsets.GetValueOnRenderThread() != 0;
const bool bWasDebuggingSort = CVarDebugSort.GetValueOnRenderThread() != 0;
IVarDebugOffsets->Set(1, ECVF_SetByCode);
IVarDebugSort->Set(1, ECVF_SetByCode);
RunGPUSortTest(RHICmdList, TestSize, FeatureLevel);
IVarDebugOffsets->Set(bWasDebuggingOffsets ? 1 : 0, ECVF_SetByCode);
IVarDebugSort->Set(bWasDebuggingSort ? 1 : 0, ECVF_SetByCode);
}