FX.MaxParticleTilePreAllocation

FX.MaxParticleTilePreAllocation

#Overview

name: FX.MaxParticleTilePreAllocation

This variable is created as a Console Variable (cvar).

It is referenced in 5 C++ source files.

#Summary

#Usage in the C++ source code

The purpose of FX.MaxParticleTilePreAllocation is to set the maximum number of tiles that can be pre-allocated for GPU particle systems in Unreal Engine 5. This setting is part of the particle effects (FX) system, specifically for GPU-based particle simulations.

This setting variable is primarily used in the Engine module, particularly in the particle system and GPU simulation components. It’s referenced in the FXSystem.cpp and ParticleGpuSimulation.cpp files, which are part of the core engine’s particle simulation system.

The value of this variable is set through the console variable system. It’s defined as a console variable with the name “FX.MaxParticleTilePreAllocation” and is associated with the C++ variable MaxParticleTilePreAllocation.

The MaxParticleTilePreAllocation variable interacts closely with other particle system settings, such as ParticleSlackGPU and the maximum particle count for emitters. It’s used in calculations to determine the appropriate number of tiles to allocate for GPU particle simulations.

Developers should be aware that this variable affects memory allocation for GPU particle systems. Setting it too high might result in unnecessary memory usage, while setting it too low could potentially limit the maximum number of particles that can be simulated efficiently.

Best practices when using this variable include:

  1. Adjusting it based on the specific needs of your project’s particle systems.
  2. Monitoring performance and memory usage when modifying this value.
  3. Considering the target hardware capabilities when setting this value, especially for projects targeting a wide range of devices.

Regarding the associated variable MaxParticleTilePreAllocation: This is the actual C++ variable that stores the value set by the FX.MaxParticleTilePreAllocation console variable. It’s used directly in the engine code to limit the number of pre-allocated tiles for GPU particle systems. The variable is initialized with a default value of 100, but can be changed at runtime through the console variable system. It’s used in critical calculations for determining tile allocation in the GPU sprite particle emitter instance, which directly impacts the performance and capabilities of the particle system.

#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:176

Scope (from outer to inner):

file
namespace    FXConsoleVariables

Source code excerpt:

		);
	FAutoConsoleVariableRef CVarMaxParticleTilePreAllocation(
		TEXT("FX.MaxParticleTilePreAllocation"),
		MaxParticleTilePreAllocation,
		TEXT("Maximum tile preallocation for GPU particles."),
		ECVF_Cheat
		);
	FAutoConsoleVariableRef CVarMaxCPUParticlesPerEmitter(
		TEXT("FX.MaxCPUParticlesPerEmitter"),

#Associated Variable and Callsites

This variable is associated with another variable named MaxParticleTilePreAllocation. They share the same value. See the following C++ source code.

#Loc: <Workspace>/Engine/Source/Runtime/Engine/Private/Particles/FXSystem.cpp:128

Scope (from outer to inner):

file
namespace    FXConsoleVariables

Source code excerpt:

	int32 bAllowAsyncTick = !WITH_EDITOR;
	float ParticleSlackGPU = 0.02f;
	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);

#Loc: <Workspace>/Engine/Source/Runtime/Engine/Private/Particles/FXSystem.cpp:177

Scope (from outer to inner):

file
namespace    FXConsoleVariables

Source code excerpt:

	FAutoConsoleVariableRef CVarMaxParticleTilePreAllocation(
		TEXT("FX.MaxParticleTilePreAllocation"),
		MaxParticleTilePreAllocation,
		TEXT("Maximum tile preallocation for GPU particles."),
		ECVF_Cheat
		);
	FAutoConsoleVariableRef CVarMaxCPUParticlesPerEmitter(
		TEXT("FX.MaxCPUParticlesPerEmitter"),
		MaxCPUParticlesPerEmitter,

#Loc: <Workspace>/Engine/Source/Runtime/Engine/Private/Particles/ParticleGpuSimulation.cpp:3933

Scope (from outer to inner):

file
class        class FGPUSpriteParticleEmitterInstance : public FParticleEmitterInstance
function     int32 GetMinTileCount

Source code excerpt:

			const int32 EstMaxTiles = (EmitterInfo.MaxParticleCount + GParticlesPerTile - 1) / GParticlesPerTile;
			const int32 SlackTiles = FMath::CeilToInt(FXConsoleVariables::ParticleSlackGPU * (float)EstMaxTiles);
			return FMath::Min<int32>(EstMaxTiles + SlackTiles, FXConsoleVariables::MaxParticleTilePreAllocation);
		}
		return 0;
	}

	/**
	 * Release any inactive tiles.

#Loc: <Workspace>/Engine/Source/Runtime/Engine/Public/FXSystem.h:75

Scope (from outer to inner):

file
namespace    FXConsoleVariables

Source code excerpt:

	extern float ParticleSlackGPU;
	/** Maximum tile preallocation for GPU particles. */
	extern int32 MaxParticleTilePreAllocation;
	/** Maximum number of CPU particles to allow per-emitter. */
	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;