Niagara.WaveIntrinsics

Niagara.WaveIntrinsics

#Overview

name: Niagara.WaveIntrinsics

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

It is referenced in 3 C++ source files.

#Summary

#Usage in the C++ source code

The purpose of Niagara.WaveIntrinsics is to control the use of wave intrinsics in the Niagara particle system within Unreal Engine 5. Wave intrinsics are GPU hardware features that allow for efficient communication between threads within a wavefront, potentially improving performance in certain scenarios.

This setting variable is primarily used in the Niagara plugin, which is part of Unreal Engine’s visual effects system. Specifically, it’s referenced in the NiagaraShader module, which handles shader compilation and execution for Niagara effects.

The value of this variable is set through a console variable (cvar) system. It’s initialized to 0 by default, as indicated by the comment “// TODO: Enable this”, suggesting that it’s a feature that may be fully enabled in the future.

The associated variable GNiagaraWaveIntrinsics directly interacts with Niagara.WaveIntrinsics. They share the same value, with GNiagaraWaveIntrinsics being the actual integer variable used in the C++ code.

Developers should be aware that this variable is currently set to 0 by default, which means wave intrinsics are disabled. Enabling this feature (by setting it to a non-zero value) could potentially impact performance and behavior of Niagara particle systems.

Best practices when using this variable include:

  1. Testing thoroughly when enabling wave intrinsics, as it may affect performance and visual output.
  2. Considering platform compatibility, as wave intrinsics support may vary across different GPU architectures.
  3. Monitoring performance metrics when enabling this feature to ensure it provides the expected benefits.

Regarding the associated variable GNiagaraWaveIntrinsics:

The purpose of GNiagaraWaveIntrinsics is to serve as the C++ representation of the Niagara.WaveIntrinsics console variable. It’s used directly in the code to determine whether wave intrinsics should be used in shader computations.

This variable is used in the NiagaraShader module, specifically in the computation of GPU free IDs for particle systems. It affects the thread group size and shader permutations used in these computations.

The value of GNiagaraWaveIntrinsics is set through the console variable system, allowing for runtime configuration.

Developers should be aware that changing this variable will affect the behavior of Niagara particle systems, particularly in how they utilize GPU resources. It’s important to test thoroughly on target hardware when modifying this setting.

Best practices include:

  1. Using this variable in conjunction with platform-specific checks to ensure compatibility.
  2. Considering the performance implications of enabling or disabling wave intrinsics for different types of particle effects.
  3. Documenting any changes to this variable and their effects on the project’s performance and visual fidelity.

#References in C++ code

#Callsites

This variable is referenced in the following C++ source code:

#Loc: <Workspace>/Engine/Plugins/FX/Niagara/Source/NiagaraShader/Private/NiagaraShaderParticleID.cpp:8

Scope: file

Source code excerpt:

int32 GNiagaraWaveIntrinsics = 0; // TODO: Enable this
FAutoConsoleVariableRef CVarGNiagaraWaveIntrinsics(
	TEXT("Niagara.WaveIntrinsics"),
	GNiagaraWaveIntrinsics,
	TEXT("")
);

//////////////////////////////////////////////////////////////////////////

#Associated Variable and Callsites

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

#Loc: <Workspace>/Engine/Plugins/FX/Niagara/Source/NiagaraShader/Private/NiagaraShaderParticleID.cpp:6

Scope: file

Source code excerpt:

#include "DataDrivenShaderPlatformInfo.h"

int32 GNiagaraWaveIntrinsics = 0; // TODO: Enable this
FAutoConsoleVariableRef CVarGNiagaraWaveIntrinsics(
	TEXT("Niagara.WaveIntrinsics"),
	GNiagaraWaveIntrinsics,
	TEXT("")
);

//////////////////////////////////////////////////////////////////////////

class FNiagaraInitFreeIDBufferCS : public FGlobalShader

#Loc: <Workspace>/Engine/Plugins/FX/Niagara/Source/NiagaraShader/Private/NiagaraShaderParticleID.cpp:108

Scope (from outer to inner):

file
function     void NiagaraComputeGPUFreeIDs

Source code excerpt:

{
	const EShaderPlatform Platform = GShaderPlatformForFeatureLevel[FeatureLevel];
	const bool bUseWaveOps = FDataDrivenShaderPlatformInfo::GetSupportsIntrinsicWaveOnce(Platform) && GNiagaraWaveIntrinsics != 0;
	const uint32 ThreadGroupSize = bUseWaveOps ? NiagaraComputeFreeIDsCS::ThreadGroupSize_WaveEnabled : NiagaraComputeFreeIDsCS::ThreadGroupSize_WaveDisabled;

	check(NumIDs % ThreadGroupSize == 0);

	NiagaraComputeFreeIDsCS::FPermutationDomain PermutationVector;
	PermutationVector.Set<NiagaraComputeFreeIDsCS::FWaveIntrinsicsDim>(bUseWaveOps);