FX.AllowGPUSorting
FX.AllowGPUSorting
#Overview
name: FX.AllowGPUSorting
The value of this variable can be defined or overridden in .ini config files. 4
.ini config files referencing this setting variable.
This variable is created as a Console Variable (cvar).
- type:
Var
- help:
Allow particles to be sorted on the GPU.
It is referenced in 9
C++ source files.
#Summary
#Usage in the C++ source code
The purpose of FX.AllowGPUSorting is to control whether particles can be sorted on the GPU in Unreal Engine’s particle system. This setting is primarily used for the rendering system, specifically for particle effects.
This setting variable is mainly used in the Engine module, particularly in the particle and FX systems. It’s also referenced in the OpenGLDrv module and the Niagara plugin, indicating its importance in GPU-based particle rendering across different rendering backends.
The value of this variable is set through a console variable (CVar) named “FX.AllowGPUSorting”. It’s defined as a read-only and preview console variable, suggesting that it’s meant to be configured before runtime and not changed during gameplay.
The associated variable bAllowGPUSorting interacts closely with FX.AllowGPUSorting. They share the same value, and bAllowGPUSorting is used in various parts of the engine code to check if GPU sorting is allowed.
Developers should be aware of several things when using this variable:
- It affects performance and visual quality of particle systems.
- It’s platform-dependent. For example, it’s temporarily disabled for OpenGL on certain Android devices due to issues with Adreno and Mali GPUs.
- It’s a read-only variable, so it should be set before runtime.
- It interacts with other particle system features like GPU culling.
Best practices when using this variable include:
- Test thoroughly on target platforms, especially mobile devices.
- Consider the performance implications of enabling or disabling GPU sorting.
- Use in conjunction with other particle system optimizations for best results.
- Be aware of its impact on translucent particles specifically.
Regarding the associated variable bAllowGPUSorting: The purpose of bAllowGPUSorting is to provide an easily accessible boolean flag for engine systems to check if GPU sorting is allowed. It’s used in various parts of the engine, including the Niagara plugin and the core particle simulation code.
This variable is referenced in multiple engine subsystems related to particle rendering and simulation. It’s particularly important in the GPUSortManager and particle simulation code.
The value of bAllowGPUSorting is set based on the FX.AllowGPUSorting console variable. They are directly linked, with bAllowGPUSorting serving as an easy-to-use boolean representation of the console variable’s value.
Developers should be aware that this variable is used as a quick check in performance-critical code paths. Its value can significantly impact particle rendering performance and behavior.
Best practices for using bAllowGPUSorting include:
- Avoid changing its value during runtime, as it’s meant to be a global setting.
- Use it in conjunction with platform-specific checks when necessary.
- Consider its impact on both performance and visual quality when enabling or disabling it.
#Setting Variables
#References In INI files
Location: <Workspace>/Engine/Config/BaseDeviceProfiles.ini:818, section: [Android_Preview_OpenGL DeviceProfile]
- INI Section:
Android_Preview_OpenGL DeviceProfile
- Raw value:
0
- Is Array:
False
Location: <Workspace>/Engine/Config/BaseDeviceProfiles.ini:1132, section: [Meta_Quest_3 DeviceProfile]
- INI Section:
Meta_Quest_3 DeviceProfile
- Raw value:
1
- Is Array:
False
Location: <Workspace>/Engine/Config/BaseDeviceProfiles.ini:1143, section: [Oculus_Quest2 DeviceProfile]
- INI Section:
Oculus_Quest2 DeviceProfile
- Raw value:
1
- Is Array:
False
Location: <Workspace>/Engine/Config/BaseDeviceProfiles.ini:1152, section: [Oculus_Quest DeviceProfile]
- INI Section:
Oculus_Quest DeviceProfile
- Raw value:
0
- Is Array:
False
#References in C++ code
#Callsites
This variable is referenced in the following C++ source code:
#Loc: <Workspace>/Engine/Source/Runtime/Engine/Private/Particles/FXSystem.cpp:146
Scope (from outer to inner):
file
namespace FXConsoleVariables
Source code excerpt:
);
FAutoConsoleVariableRef CVarAllowGPUSorting(
TEXT("FX.AllowGPUSorting"),
bAllowGPUSorting,
TEXT("Allow particles to be sorted on the GPU."),
ECVF_ReadOnly | ECVF_Preview
);
FAutoConsoleVariableRef CVarFreezeGPUSimulation(
TEXT("FX.FreezeGPUSimulation"),
#Loc: <Workspace>/Engine/Source/Runtime/OpenGLDrv/Private/OpenGLDevice.cpp:1359
Scope (from outer to inner):
file
function FOpenGLDynamicRHI::FOpenGLDynamicRHI
Source code excerpt:
{
// Temp disable gpusorting for Opengl because of issues on Adreno and Mali devices
auto* CVar = IConsoleManager::Get().FindConsoleVariable(TEXT("FX.AllowGPUSorting"));
if (CVar)
{
#if PLATFORM_ANDROID
if(!AndroidThunkCpp_IsOculusMobileApplication())
#endif
{
#Associated Variable and Callsites
This variable is associated with another variable named bAllowGPUSorting
. They share the same value. See the following C++ source code.
#Loc: <Workspace>/Engine/Plugins/FX/Niagara/Source/Niagara/Private/NiagaraCommon.cpp:952
Scope (from outer to inner):
file
function bool FNiagaraUtilities::AllowGPUSorting
Source code excerpt:
bool FNiagaraUtilities::AllowGPUSorting(EShaderPlatform ShaderPlatform)
{
return FXConsoleVariables::bAllowGPUSorting != 0;
}
bool FNiagaraUtilities::AllowGPUCulling(EShaderPlatform ShaderPlatform)
{
return GNiagaraGPUCulling && AllowGPUSorting(ShaderPlatform) && AllowComputeShaders(ShaderPlatform);
}
#Loc: <Workspace>/Engine/Source/Runtime/Engine/Private/GPUSortManager.cpp:9
Scope: file
Source code excerpt:
#include "Math/Float16.h"
#include "ShaderParameterUtils.h"
#include "FXSystem.h" // FXConsoleVariables::bAllowGPUSorting
#include "RenderGraphUtils.h"
//*****************************************************************************
int32 GGPUSortFrameCountBeforeBufferShrinking = 100;
#Loc: <Workspace>/Engine/Source/Runtime/Engine/Private/GPUSortManager.cpp:584
Scope (from outer to inner):
file
function bool FGPUSortManager::AddTask
Source code excerpt:
bool FGPUSortManager::AddTask(FRHICommandListBase& RHICmdList, FAllocationInfo& OutInfo, int32 ValueCount, EGPUSortFlags TaskFlags)
{
if (!FXConsoleVariables::bAllowGPUSorting)
{
return false;
}
LLM_SCOPE(ELLMTag::GPUSort);
#Loc: <Workspace>/Engine/Source/Runtime/Engine/Private/Particles/FXSystem.cpp:122
Scope (from outer to inner):
file
namespace FXConsoleVariables
Source code excerpt:
{
int32 VisualizeGPUSimulation = 0;
int32 bAllowGPUSorting = true;
int32 bAllowCulling = true;
int32 bFreezeGPUSimulation = false;
int32 bFreezeParticleSimulation = false;
int32 bAllowAsyncTick = !WITH_EDITOR;
float ParticleSlackGPU = 0.02f;
int32 MaxParticleTilePreAllocation = 100;
#Loc: <Workspace>/Engine/Source/Runtime/Engine/Private/Particles/FXSystem.cpp:147
Scope (from outer to inner):
file
namespace FXConsoleVariables
Source code excerpt:
FAutoConsoleVariableRef CVarAllowGPUSorting(
TEXT("FX.AllowGPUSorting"),
bAllowGPUSorting,
TEXT("Allow particles to be sorted on the GPU."),
ECVF_ReadOnly | ECVF_Preview
);
FAutoConsoleVariableRef CVarFreezeGPUSimulation(
TEXT("FX.FreezeGPUSimulation"),
bFreezeGPUSimulation,
#Loc: <Workspace>/Engine/Source/Runtime/Engine/Private/Particles/ParticleGpuSimulation.cpp:2990
Scope (from outer to inner):
file
function virtual void GetDynamicMeshElementsEmitter
Source code excerpt:
const bool bTranslucent = RendersWithTranslucentMaterial();
const bool bAllowSorting = FXConsoleVariables::bAllowGPUSorting
&& bTranslucent;
// Iterate over views and assign parameters for each.
FParticleSimulationResources* SimulationResources = FXSystem->GetParticleSimulationResources();
FGPUSpriteCollectorResources& CollectorResources = Collector.AllocateOneFrameResource<FGPUSpriteCollectorResources>(FeatureLevel);
FGPUSpriteVertexFactory& VertexFactory = CollectorResources.VertexFactory;
#Loc: <Workspace>/Engine/Source/Runtime/Engine/Public/FXSystem.h:63
Scope (from outer to inner):
file
namespace FXConsoleVariables
Source code excerpt:
extern int32 VisualizeGPUSimulation;
/** true if GPU emitters are permitted to sort. */
ENGINE_API extern int32 bAllowGPUSorting;
/** true if emitters can be culled. */
extern int32 bAllowCulling;
/** true if GPU particle simulation is frozen. */
extern int32 bFreezeGPUSimulation;
/** true if particle simulation is frozen. */
extern int32 bFreezeParticleSimulation;