FX.MaxGPUParticlesSpawnedPerFrame
FX.MaxGPUParticlesSpawnedPerFrame
#Overview
name: FX.MaxGPUParticlesSpawnedPerFrame
This variable is created as a Console Variable (cvar).
- type:
Var
- help:
Maximum number of GPU particles allowed to spawn per-frame per-emitter.
It is referenced in 6
C++ source files.
#Summary
#Usage in the C++ source code
The purpose of FX.MaxGPUParticlesSpawnedPerFrame is to limit the maximum number of GPU particles that can be spawned per frame for each emitter in Unreal Engine’s particle system.
This setting variable is primarily used by the GPU particle simulation system, which is part of Unreal Engine’s visual effects (VFX) module. Based on the callsites, it’s clear that this variable is utilized in the particle system’s core functionality, specifically in the FXSystem and GPU particle simulation components.
The value of this variable is set in the FXConsoleVariables namespace, initialized to 1,048,576 (1024 * 1024) particles. It can be modified at runtime through the console variable system, allowing for dynamic adjustments during development or gameplay.
This variable interacts closely with other particle system variables, such as GPUSpawnWarningThreshold, which sets a warning level for GPU particle spawning. It’s also used in conjunction with burst spawning and rate-based spawning calculations for GPU particles.
Developers should be aware that this variable acts as a hard limit on GPU particle spawning. If an emitter attempts to spawn more particles than this limit in a single frame, the excess particles will not be spawned. This can potentially affect the visual quality of particle effects if set too low.
Best practices when using this variable include:
- Monitoring performance and adjusting the value to balance visual quality with performance requirements.
- Using it in conjunction with other particle system settings to optimize overall VFX performance.
- Being cautious when increasing this value, as it can significantly impact GPU performance if set too high.
Regarding the associated variable MaxGPUParticlesSpawnedPerFrame:
This is the actual integer variable that stores the value set by FX.MaxGPUParticlesSpawnedPerFrame. It’s used directly in the particle system code to enforce the spawning limit. The purpose and usage are identical to FX.MaxGPUParticlesSpawnedPerFrame, as they represent the same concept - one as a console variable and the other as the actual variable used in the code.
Developers should treat MaxGPUParticlesSpawnedPerFrame as the internal representation of the limit, while FX.MaxGPUParticlesSpawnedPerFrame is the exposed, adjustable setting. When working with the particle system code directly, MaxGPUParticlesSpawnedPerFrame would be the variable to reference.
#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:187
Scope (from outer to inner):
file
namespace FXConsoleVariables
Source code excerpt:
);
FAutoConsoleVariableRef CVarMaxGPUParticlesSpawnedPerFrame(
TEXT("FX.MaxGPUParticlesSpawnedPerFrame"),
MaxGPUParticlesSpawnedPerFrame,
TEXT("Maximum number of GPU particles allowed to spawn per-frame per-emitter.")
);
FAutoConsoleVariableRef CVarGPUSpawnWarningThreshold(
TEXT("FX.GPUSpawnWarningThreshold"),
GPUSpawnWarningThreshold,
#Associated Variable and Callsites
This variable is associated with another variable named MaxGPUParticlesSpawnedPerFrame
. They share the same value. See the following C++ source code.
#Loc: <Workspace>/Engine/Source/Runtime/Engine/Private/Particles/FXSystem.cpp:130
Scope (from outer to inner):
file
namespace FXConsoleVariables
Source code excerpt:
int32 MaxParticleTilePreAllocation = 100;
int32 MaxCPUParticlesPerEmitter = 1000;
int32 MaxGPUParticlesSpawnedPerFrame = 1024 * 1024;
int32 GPUSpawnWarningThreshold = 20000;
float GPUCollisionDepthBounds = 500.0f;
TAutoConsoleVariable<int32> TestGPUSort(TEXT("FX.TestGPUSort"),0,TEXT("Test GPU sort. 1: Small, 2: Large, 3: Exhaustive, 4: Random"),ECVF_Cheat);
/** Register references to flags. */
FAutoConsoleVariableRef CVarVisualizeGPUSimulation(
#Loc: <Workspace>/Engine/Source/Runtime/Engine/Private/Particles/FXSystem.cpp:188
Scope (from outer to inner):
file
namespace FXConsoleVariables
Source code excerpt:
FAutoConsoleVariableRef CVarMaxGPUParticlesSpawnedPerFrame(
TEXT("FX.MaxGPUParticlesSpawnedPerFrame"),
MaxGPUParticlesSpawnedPerFrame,
TEXT("Maximum number of GPU particles allowed to spawn per-frame per-emitter.")
);
FAutoConsoleVariableRef CVarGPUSpawnWarningThreshold(
TEXT("FX.GPUSpawnWarningThreshold"),
GPUSpawnWarningThreshold,
TEXT("Warning threshold for spawning of GPU particles."),
#Loc: <Workspace>/Engine/Source/Runtime/Engine/Private/Particles/ParticleGpuSimulation.cpp:3650
Scope (from outer to inner):
file
class class FGPUSpriteParticleEmitterInstance : public FParticleEmitterInstance
function virtual void Tick
Source code excerpt:
BurstInfo.Count += ForceBurstSpawnedParticles.Num();
if (BurstInfo.Count > FXConsoleVariables::MaxGPUParticlesSpawnedPerFrame)
{
LeftoverBurst = BurstInfo.Count - FXConsoleVariables::MaxGPUParticlesSpawnedPerFrame;
BurstInfo.Count = FXConsoleVariables::MaxGPUParticlesSpawnedPerFrame;
}
}
// Determine spawn count based on rate.
FSpawnInfo SpawnInfo = GetNumParticlesToSpawn(DeltaSeconds);
#Loc: <Workspace>/Engine/Source/Runtime/Engine/Private/Particles/ParticleGpuSimulation.cpp:4149
Scope (from outer to inner):
file
class class FGPUSpriteParticleEmitterInstance : public FParticleEmitterInstance
function FSpawnInfo GetNumParticlesToSpawn
Source code excerpt:
FSpawnInfo Info;
float AccumSpawnCount = SpawnFraction + SpawnRate * DeltaSeconds;
Info.Count = FMath::Min(FMath::TruncToInt(AccumSpawnCount), FXConsoleVariables::MaxGPUParticlesSpawnedPerFrame);
Info.Increment = (SpawnRate > 0.0f) ? (1.f / SpawnRate) : 0.0f;
Info.StartTime = DeltaSeconds + SpawnFraction * Info.Increment - Info.Increment;
SpawnFraction = AccumSpawnCount - Info.Count;
return Info;
}
#Loc: <Workspace>/Engine/Source/Runtime/Engine/Public/FXSystem.h:79
Scope (from outer to inner):
file
namespace FXConsoleVariables
Source code excerpt:
extern int32 MaxCPUParticlesPerEmitter;
/** Maximum number of GPU particles to spawn per-frame. */
extern int32 MaxGPUParticlesSpawnedPerFrame;
/** Warning threshold for spawning of GPU particles. */
extern int32 GPUSpawnWarningThreshold;
/** Depth bounds for GPU collision checks. */
extern float GPUCollisionDepthBounds;
/** Specify a sorting test to run. */
extern TAutoConsoleVariable<int32> TestGPUSort;