FX.VisualizeGPUSimulation
FX.VisualizeGPUSimulation
#Overview
name: FX.VisualizeGPUSimulation
This variable is created as a Console Variable (cvar).
- type:
Var
- help:
Visualize the current state of GPU simulation.\n0 = off\n1 = visualize particle state\n2 = visualize curve texture
It is referenced in 8
C++ source files.
#Summary
#Usage in the C++ source code
The purpose of FX.VisualizeGPUSimulation is to provide a visualization tool for GPU-based particle simulations in Unreal Engine 5. It allows developers to visually inspect the current state of GPU particle simulations, which can be helpful for debugging and performance optimization.
This setting variable is primarily used in the Particle and FX systems of Unreal Engine. Specifically, it’s utilized in the FFXSystem class, which is part of the engine’s particle simulation module.
The value of this variable is set through a console command. It’s registered as a console variable using FAutoConsoleVariableRef, which allows it to be changed at runtime.
The associated variable VisualizeGPUSimulation interacts directly with FX.VisualizeGPUSimulation. They share the same value, with VisualizeGPUSimulation being the actual int32 variable that stores the visualization mode.
Developers should be aware that this variable has three possible states: 0 = off (default) 1 = visualize particle state 2 = visualize curve texture
When using this variable, developers should consider the following best practices:
- Use it primarily for debugging and development purposes, not in production builds.
- Be aware that enabling visualization may impact performance, especially in complex scenes with many particles.
- Use in conjunction with other debugging tools to get a comprehensive understanding of particle system behavior.
Regarding the associated variable VisualizeGPUSimulation:
- It’s defined within the FXConsoleVariables namespace.
- It’s used in the FFXSystem::DrawDebug and FFXSystem::VisualizeGPUParticles functions to determine if and how to visualize GPU particles.
- The variable is checked in rendering code to decide whether to perform visualization and which mode to use.
When working with VisualizeGPUSimulation, developers should:
- Access it through the FXConsoleVariables namespace.
- Be cautious about modifying its value directly in code, as it’s intended to be controlled via the console variable.
- Consider its performance implications, especially when enabled in performance-critical scenarios.
#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:137
Scope (from outer to inner):
file
namespace FXConsoleVariables
Source code excerpt:
/** Register references to flags. */
FAutoConsoleVariableRef CVarVisualizeGPUSimulation(
TEXT("FX.VisualizeGPUSimulation"),
VisualizeGPUSimulation,
TEXT("Visualize the current state of GPU simulation.\n")
TEXT("0 = off\n")
TEXT("1 = visualize particle state\n")
TEXT("2 = visualize curve texture"),
ECVF_Cheat
#Associated Variable and Callsites
This variable is associated with another variable named VisualizeGPUSimulation
. They share the same value. See the following C++ source code.
#Loc: <Workspace>/Engine/Source/Runtime/Engine/Private/Particles/FXSystem.cpp:121
Scope (from outer to inner):
file
namespace FXConsoleVariables
Source code excerpt:
namespace FXConsoleVariables
{
int32 VisualizeGPUSimulation = 0;
int32 bAllowGPUSorting = true;
int32 bAllowCulling = true;
int32 bFreezeGPUSimulation = false;
int32 bFreezeParticleSimulation = false;
int32 bAllowAsyncTick = !WITH_EDITOR;
float ParticleSlackGPU = 0.02f;
#Loc: <Workspace>/Engine/Source/Runtime/Engine/Private/Particles/FXSystem.cpp:138
Scope (from outer to inner):
file
namespace FXConsoleVariables
Source code excerpt:
FAutoConsoleVariableRef CVarVisualizeGPUSimulation(
TEXT("FX.VisualizeGPUSimulation"),
VisualizeGPUSimulation,
TEXT("Visualize the current state of GPU simulation.\n")
TEXT("0 = off\n")
TEXT("1 = visualize particle state\n")
TEXT("2 = visualize curve texture"),
ECVF_Cheat
);
#Loc: <Workspace>/Engine/Source/Runtime/Engine/Private/Particles/FXSystem.cpp:416
Scope (from outer to inner):
file
function void FFXSystem::DrawDebug
Source code excerpt:
void FFXSystem::DrawDebug( FCanvas* Canvas )
{
if (FXConsoleVariables::VisualizeGPUSimulation > 0
&& RHISupportsGPUParticles())
{
VisualizeGPUParticles(Canvas);
}
}
#Loc: <Workspace>/Engine/Source/Runtime/Engine/Private/Particles/ParticleGpuSimulation.cpp:2033
Scope (from outer to inner):
file
function static void VisualizeGPUSimulation
Source code excerpt:
* @param RenderTarget - The render target on which to draw the visualization.
*/
static void VisualizeGPUSimulation(
FRHICommandList& RHICmdList,
ERHIFeatureLevel::Type FeatureLevel,
int32 VisualizationMode,
FRenderTarget* RenderTarget,
const FParticleStateTextures& StateTextures,
FRHITexture2D* CurveTextureRHI
#Loc: <Workspace>/Engine/Source/Runtime/Engine/Private/Particles/ParticleGpuSimulation.cpp:2057
Scope (from outer to inner):
file
function static void VisualizeGPUSimulation
Source code excerpt:
FRHIRenderPassInfo RPInfo(RenderTarget->GetRenderTargetTexture(), ERenderTargetActions::Load_Store);
RHICmdList.BeginRenderPass(RPInfo, TEXT("VisualizeGPUSimulation"));
{
RHICmdList.ApplyCachedRenderTargets(GraphicsPSOInit);
RHICmdList.SetViewport(0.0f, 0.0f, 0.0f, (float)TargetSize.X, (float)TargetSize.Y, 1.0f);
GraphicsPSOInit.DepthStencilState = TStaticDepthStencilState<false, CF_Always>::GetRHI();
GraphicsPSOInit.RasterizerState = TStaticRasterizerState<FM_Solid, CM_None>::GetRHI();
#Loc: <Workspace>/Engine/Source/Runtime/Engine/Private/Particles/ParticleGpuSimulation.cpp:5218
Scope (from outer to inner):
file
function void FFXSystem::VisualizeGPUParticles
Source code excerpt:
{
FFXSystem* FXSystem = this;
int32 VisualizationMode = FXConsoleVariables::VisualizeGPUSimulation;
FRenderTarget* RenderTarget = Canvas->GetRenderTarget();
ERHIFeatureLevel::Type InFeatureLevel = FeatureLevel;
ENQUEUE_RENDER_COMMAND(FVisualizeGPUParticlesCommand)(
[FXSystem, VisualizationMode, RenderTarget, InFeatureLevel](FRHICommandList& RHICmdList)
{
FParticleSimulationResources* Resources = FXSystem->GetParticleSimulationResources();
FParticleStateTextures& CurrentStateTextures = Resources->GetVisualizeStateTextures();
VisualizeGPUSimulation(RHICmdList, InFeatureLevel, VisualizationMode, RenderTarget, CurrentStateTextures, GParticleCurveTexture.GetCurveTexture());
});
}
}
/*-----------------------------------------------------------------------------
External interface.
#Loc: <Workspace>/Engine/Source/Runtime/Engine/Public/FXSystem.h:61
Scope (from outer to inner):
file
namespace FXConsoleVariables
Source code excerpt:
{
/** Visualize GPU particle simulation. */
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;