fx.NiagaraStateless.ComputeManager.UseCache
fx.NiagaraStateless.ComputeManager.UseCache
#Overview
name: fx.NiagaraStateless.ComputeManager.UseCache
This variable is created as a Console Variable (cvar).
- type:
Var
- help:
When enabled we will attempt to reuse allocated buffers between frames.
It is referenced in 3
C++ source files.
#Summary
#Usage in the C++ source code
The purpose of fx.NiagaraStateless.ComputeManager.UseCache is to control the caching behavior of the Niagara stateless compute manager. It determines whether the system will attempt to reuse allocated buffers between frames in the Niagara visual effects system.
This setting variable is primarily used by the Niagara plugin, which is part of Unreal Engine’s visual effects system. Specifically, it’s used within the stateless compute manager component of Niagara.
The value of this variable is set through the Unreal Engine’s console variable system. It’s initialized to 1 (true) by default, as seen in the source code.
The associated variable GNiagaraStatelessComputeManager_UseCache directly interacts with this setting. It’s a boolean variable that stores the actual value used in the code logic.
Developers should be aware that this variable affects performance and memory usage. When enabled, it can potentially improve performance by reducing the need for frequent buffer allocations and deallocations. However, it may also increase memory usage as buffers are kept in cache between frames.
Best practices for using this variable include:
- Leave it enabled (default) for most cases to benefit from potential performance improvements.
- If memory usage becomes a concern, consider disabling it to reduce memory footprint at the cost of potentially increased CPU/GPU work for buffer allocation.
- Profile your application with this setting both enabled and disabled to determine the best configuration for your specific use case.
Regarding the associated variable GNiagaraStatelessComputeManager_UseCache:
The purpose of GNiagaraStatelessComputeManager_UseCache is to serve as the actual boolean flag used in the code logic to determine whether buffer caching should be used.
This variable is used directly in the Niagara stateless compute manager’s implementation, specifically in the GetDataBuffer function.
The value of this variable is set by the console variable system, mirroring the value of fx.NiagaraStateless.ComputeManager.UseCache.
It interacts directly with the console variable, effectively implementing the caching behavior controlled by the setting.
Developers should be aware that this is the actual variable checked in the code logic. Any runtime changes to the console variable will be reflected in this variable’s value.
Best practices for this variable include:
- Do not modify this variable directly in code; instead, use the console variable system to change its value.
- When debugging caching behavior, check the value of this variable to ensure it reflects the intended setting.
- Be aware of this variable when profiling or optimizing Niagara performance, as it directly affects the caching behavior of the stateless compute manager.
#References in C++ code
#Callsites
This variable is referenced in the following C++ source code:
#Loc: <Workspace>/Engine/Plugins/FX/Niagara/Source/Niagara/Private/Stateless/NiagaraStatelessComputeManager.cpp:17
Scope: file
Source code excerpt:
bool GNiagaraStatelessComputeManager_UseCache = 1;
FAutoConsoleVariableRef CVarNiagaraStatelessComputeManager_UseCache(
TEXT("fx.NiagaraStateless.ComputeManager.UseCache"),
GNiagaraStatelessComputeManager_UseCache,
TEXT("When enabled we will attempt to reuse allocated buffers between frames."),
ECVF_Default
);
FNiagaraStatelessComputeManager::FNiagaraStatelessComputeManager(FNiagaraGpuComputeDispatchInterface* InOwnerInterface)
#Associated Variable and Callsites
This variable is associated with another variable named GNiagaraStatelessComputeManager_UseCache
. They share the same value. See the following C++ source code.
#Loc: <Workspace>/Engine/Plugins/FX/Niagara/Source/Niagara/Private/Stateless/NiagaraStatelessComputeManager.cpp:15
Scope: file
Source code excerpt:
#include "SceneView.h"
bool GNiagaraStatelessComputeManager_UseCache = 1;
FAutoConsoleVariableRef CVarNiagaraStatelessComputeManager_UseCache(
TEXT("fx.NiagaraStateless.ComputeManager.UseCache"),
GNiagaraStatelessComputeManager_UseCache,
TEXT("When enabled we will attempt to reuse allocated buffers between frames."),
ECVF_Default
);
FNiagaraStatelessComputeManager::FNiagaraStatelessComputeManager(FNiagaraGpuComputeDispatchInterface* InOwnerInterface)
: FNiagaraGpuComputeDataManager(InOwnerInterface)
#Loc: <Workspace>/Engine/Plugins/FX/Niagara/Source/Niagara/Private/Stateless/NiagaraStatelessComputeManager.cpp:73
Scope (from outer to inner):
file
function FNiagaraDataBuffer* FNiagaraStatelessComputeManager::GetDataBuffer
Source code excerpt:
FStatelessDataCache* CacheData = nullptr;
if (GNiagaraStatelessComputeManager_UseCache)
{
for (int32 i=0; i < FreeData.Num(); ++i)
{
if (FreeData[i]->DataSetLayoutHash == DataSetLayoutHash)
{
CacheData = FreeData[i].Release();