9#include "Containers/Array.h"
13#define WITH_GLOBAL_RUNTIME_FX_BUDGET (!UE_SERVER)
14#ifndef WITH_PARTICLE_PERF_STATS
15 #if (WITH_UNREAL_DEVELOPER_TOOLS || WITH_UNREAL_TARGET_DEVELOPER_TOOLS || (!UE_BUILD_SHIPPING) || WITH_GLOBAL_RUNTIME_FX_BUDGET)
16 #define WITH_PARTICLE_PERF_STATS 1
18 #define WITH_PARTICLE_PERF_STATS 0
21 #if !WITH_PARTICLE_PERF_STATS
23 #undef WITH_GLOBAL_RUNTIME_FX_BUDGET
24 #define WITH_GLOBAL_RUNTIME_FX_BUDGET 0
28#define WITH_PER_SYSTEM_PARTICLE_PERF_STATS (WITH_PARTICLE_PERF_STATS && !UE_BUILD_SHIPPING)
29#define WITH_PER_COMPONENT_PARTICLE_PERF_STATS (WITH_PARTICLE_PERF_STATS && !UE_BUILD_SHIPPING)
31#define WITH_PARTICLE_PERF_CSV_STATS WITH_PER_SYSTEM_PARTICLE_PERF_STATS && CSV_PROFILER_STATS && !UE_BUILD_SHIPPING
39#if WITH_PARTICLE_PERF_STATS
189 #if WITH_PER_SYSTEM_PARTICLE_PERF_STATS
192 #if WITH_PER_COMPONENT_PARTICLE_PERF_STATS
212 return GetWorldPerfStats(
World);
219 #if WITH_PER_SYSTEM_PARTICLE_PERF_STATS
222 return GetSystemPerfStats(System);
230 #if WITH_PER_COMPONENT_PARTICLE_PERF_STATS
274#if WITH_PARTICLE_PERF_CSV_STATS
358#if WITH_PER_SYSTEM_PARTICLE_PERF_STATS
367#if WITH_PER_COMPONENT_PARTICLE_PERF_STATS
379template<
typename TWriterFunc>
409#define PARTICLE_PERF_STAT_CYCLES_COMMON(CONTEXT, THREAD, NAME)\
410struct FParticlePerfStatsWriterCycles_##THREAD##_##NAME\
412 inline static void Write(FParticlePerfStats* Stats, uint64 Cycles, int32 Count)\
414 if (Stats){ Stats->Get##THREAD##Stats().NAME##Cycles += Cycles; }\
417FParticlePerfStatScope<FParticlePerfStatsWriterCycles_##THREAD##_##NAME> ANONYMOUS_VARIABLE(ParticlePerfStatScope##THREAD##NAME)(CONTEXT);
419#define PARTICLE_PERF_STAT_CYCLES_WITH_COUNT_COMMON(CONTEXT, THREAD, NAME, COUNT)\
420struct FParticlePerfStatsWriterCyclesAndCount_##THREAD##_##NAME\
422 inline static void Write(FParticlePerfStats* Stats, uint64 Cycles, int32 Count)\
426 Stats->Get##THREAD##Stats().NAME##Cycles += Cycles; \
427 Stats->Get##THREAD##Stats().NumInstances += Count; \
431FParticlePerfStatScope<FParticlePerfStatsWriterCyclesAndCount_##THREAD##_##NAME> ANONYMOUS_VARIABLE(ParticlePerfStatScope##THREAD##NAME)(CONTEXT, COUNT);
433#define PARTICLE_PERF_STAT_CYCLES_GT(CONTEXT, NAME) PARTICLE_PERF_STAT_CYCLES_COMMON(CONTEXT, GameThread, NAME)
434#define PARTICLE_PERF_STAT_CYCLES_RT(CONTEXT, NAME) PARTICLE_PERF_STAT_CYCLES_COMMON(CONTEXT, RenderThread, NAME)
436#define PARTICLE_PERF_STAT_CYCLES_WITH_COUNT_GT(CONTEXT, NAME, COUNT) PARTICLE_PERF_STAT_CYCLES_WITH_COUNT_COMMON(CONTEXT, GameThread, NAME, COUNT)
437#define PARTICLE_PERF_STAT_CYCLES_WITH_COUNT_RT(CONTEXT, NAME, COUNT) PARTICLE_PERF_STAT_CYCLES_WITH_COUNT_COMMON(CONTEXT, RenderThread, NAME, COUNT)
441#define PARTICLE_PERF_STAT_CYCLES_GT(CONTEXT, NAME)
442#define PARTICLE_PERF_STAT_CYCLES_RT(CONTEXT, NAME)
444#define PARTICLE_PERF_STAT_CYCLES_WITH_COUNT_GT(CONTEXT, NAME, COUNT)
445#define PARTICLE_PERF_STAT_CYCLES_WITH_COUNT_RT(CONTEXT, NAME, COUNT)
OODEFFUNC typedef void(OODLE_CALLBACK t_fp_OodleCore_Plugin_Free)(void *ptr)
@ INDEX_NONE
Definition CoreMiscDefines.h:150
UE_FORCEINLINE_HINT TSharedRef< CastToType, Mode > StaticCastSharedRef(TSharedRef< CastFromType, Mode > const &InSharedRef)
Definition SharedPointer.h:127
#define CSV_DECLARE_CATEGORY_MODULE_EXTERN(Module_API, CategoryName)
Definition CsvProfiler.h:80
#define WITH_PER_SYSTEM_PARTICLE_PERF_STATS
Definition ParticlePerfStats.h:28
#define WITH_PER_COMPONENT_PARTICLE_PERF_STATS
Definition ParticlePerfStats.h:29
TFunction< void(FParticlePerfStats *Stats, uint64 Cycles)> FParticlePerfStatsWriterFunc
Definition ParticlePerfStats.h:377
if(Failed) console_printf("Failed.\n")
Definition NameTypes.h:617
Definition AndroidPlatformMisc.h:14
Definition ParticleSystem.h:118
Definition ParticleSystemComponent.h:380
static uint64 Cycles64()
Definition AndroidPlatformTime.h:34
Definition ParticlePerfStats.h:381
FParticlePerfStatsContext Context
Definition ParticlePerfStats.h:404
int32 Count
Definition ParticlePerfStats.h:406
~FParticlePerfStatScope()
Definition ParticlePerfStats.h:393
uint64 StartCycles
Definition ParticlePerfStats.h:405
FParticlePerfStatScope(FParticlePerfStatsContext InContext, int32 InCount=0)
Definition ParticlePerfStats.h:382
Definition ParticlePerfStats.h:302
FParticlePerfStatsContext(FParticlePerfStats *InComponentStats)
Definition ParticlePerfStats.h:326
void SetSystemStats(FParticlePerfStats *Stats)
Definition ParticlePerfStats.h:361
FParticlePerfStats * ComponentStats
Definition ParticlePerfStats.h:368
FParticlePerfStats * GetComponentStats()
Definition ParticlePerfStats.h:369
FParticlePerfStats * SystemStats
Definition ParticlePerfStats.h:359
FParticlePerfStats * WorldStats
Definition ParticlePerfStats.h:354
FParticlePerfStatsContext(const UWorld *InWorld, const UFXSystemAsset *InSystem, const UFXSystemComponent *InComponent)
Definition ParticlePerfStats.h:331
FParticlePerfStatsContext(FParticlePerfStats *InWorldStats, FParticlePerfStats *InSystemStats)
Definition ParticlePerfStats.h:320
FParticlePerfStatsContext(const UFXSystemComponent *InComponent)
Definition ParticlePerfStats.h:344
FParticlePerfStatsContext(const UWorld *InWorld, const UFXSystemAsset *InSystem)
Definition ParticlePerfStats.h:338
FParticlePerfStatsContext(FParticlePerfStats *InWorldStats, FParticlePerfStats *InSystemStats, FParticlePerfStats *InComponentStats)
Definition ParticlePerfStats.h:313
FParticlePerfStats * GetSystemStats()
Definition ParticlePerfStats.h:360
bool IsValid()
Definition ParticlePerfStats.h:349
FParticlePerfStatsContext()
Definition ParticlePerfStats.h:303
void SetWorldStats(FParticlePerfStats *Stats)
Definition ParticlePerfStats.h:356
FParticlePerfStats * GetWorldStats()
Definition ParticlePerfStats.h:355
void SetComponentStats(FParticlePerfStats *Stats)
Definition ParticlePerfStats.h:370
Definition ParticlePerfStats.h:148
uint64 GetPerInstanceAvgMicroseconds() const
Definition ParticlePerfStats.h:153
FParticlePerfStats_GPU()
Definition ParticlePerfStats.h:155
uint64 NumInstances
Definition ParticlePerfStats.h:149
FParticlePerfStats_GPU & operator+=(FParticlePerfStats_GPU &Other)
Definition ParticlePerfStats.h:162
uint64 GetTotalMicroseconds() const
Definition ParticlePerfStats.h:152
void Reset()
Definition ParticlePerfStats.h:156
uint64 TotalMicroseconds
Definition ParticlePerfStats.h:150
Definition ParticlePerfStats.h:43
uint64 GetTotalCycles_GTOnly() const
Definition ParticlePerfStats.h:113
FParticlePerfStats_GT()
Definition ParticlePerfStats.h:52
TAtomic< uint64 > ActivationCycles
Definition ParticlePerfStats.h:49
uint64 NumInstances
Definition ParticlePerfStats.h:44
TAtomic< uint64 > TickConcurrentCycles
Definition ParticlePerfStats.h:46
uint64 WaitCycles
Definition ParticlePerfStats.h:50
FParticlePerfStats_GT & operator+=(FParticlePerfStats_GT &Other)
Definition ParticlePerfStats.h:90
uint64 FinalizeCycles
Definition ParticlePerfStats.h:47
FParticlePerfStats_GT(const FParticlePerfStats_GT &Other)
Definition ParticlePerfStats.h:54
uint64 GetPerInstanceAvgCycles_GTOnly() const
Definition ParticlePerfStats.h:114
uint64 GetTotalCycles() const
Definition ParticlePerfStats.h:116
TAtomic< uint64 > EndOfFrameCycles
Definition ParticlePerfStats.h:48
FParticlePerfStats_GT(FParticlePerfStats_GT &&Other)
Definition ParticlePerfStats.h:77
uint64 TickGameThreadCycles
Definition ParticlePerfStats.h:45
FParticlePerfStats_GT & operator=(const FParticlePerfStats_GT &Other)
Definition ParticlePerfStats.h:65
void Reset()
Definition ParticlePerfStats.h:102
uint64 GetPerInstanceAvgCycles() const
Definition ParticlePerfStats.h:117
FParticlePerfStats_GT & operator=(FParticlePerfStats_GT &&Other)
Definition ParticlePerfStats.h:83
Definition ParticlePerfStats.h:122
uint64 NumInstances
Definition ParticlePerfStats.h:123
uint64 RenderUpdateCycles
Definition ParticlePerfStats.h:124
void Reset()
Definition ParticlePerfStats.h:128
uint64 GetDynamicMeshElementsCycles
Definition ParticlePerfStats.h:125
uint64 GetTotalCycles() const
Definition ParticlePerfStats.h:134
uint64 GetPerInstanceAvgCycles() const
Definition ParticlePerfStats.h:135
FParticlePerfStats_RT & operator+=(FParticlePerfStats_RT &Other)
Definition ParticlePerfStats.h:137
FParticlePerfStats_RT()
Definition ParticlePerfStats.h:127
Definition ParticlePerfStats.h:171
static bool ShouldGatherStats()
Definition ParticlePerfStats.h:185
static bool GetCSVStatsEnabled()
Definition ParticlePerfStats.h:180
static FParticlePerfStats * GetStats(const UFXSystemAsset *System)
Definition ParticlePerfStats.h:217
ENGINE_API void Reset(bool bSyncWithRT)
static bool GetGatherWorldStats()
Definition ParticlePerfStats.h:182
static void RemoveComponentStatReader()
Definition ParticlePerfStats.h:206
FParticlePerfStats_GPU & GetGPUStats()
Definition ParticlePerfStats.h:268
static void RemoveSystemStatReader()
Definition ParticlePerfStats.h:204
static void AddComponentStatReader()
Definition ParticlePerfStats.h:205
static FParticlePerfStats * GetStats(const UFXSystemComponent *Component)
Definition ParticlePerfStats.h:228
FParticlePerfStats_GPU GPUStats
Definition ParticlePerfStats.h:253
static ENGINE_API TAtomic< int32 > ComponentStatsReaders
Definition ParticlePerfStats.h:242
static FParticlePerfStats * GetStats(const UWorld *World)
Definition ParticlePerfStats.h:208
static ENGINE_API TAtomic< int32 > WorldStatsReaders
Definition ParticlePerfStats.h:240
ENGINE_API void ResetRT()
static bool GetGatherComponentStats()
Definition ParticlePerfStats.h:184
static ENGINE_API TAtomic< bool > bStatsEnabled
Definition ParticlePerfStats.h:239
static ENGINE_API TAtomic< int32 > SystemStatsReaders
Definition ParticlePerfStats.h:241
static void RemoveWorldStatReader()
Definition ParticlePerfStats.h:202
static ENGINE_API TAtomic< bool > bCSVStatsEnabled
Definition ParticlePerfStats.h:244
FParticlePerfStats_RT RenderThreadStats
Definition ParticlePerfStats.h:250
static bool GetGatherSystemStats()
Definition ParticlePerfStats.h:183
static void SetCSVStatsEnabled(bool bEnabled)
Definition ParticlePerfStats.h:199
static void AddWorldStatReader()
Definition ParticlePerfStats.h:201
ENGINE_API FParticlePerfStats()
FParticlePerfStats_RT & GetRenderThreadStats()
Definition ParticlePerfStats.h:262
static void SetStatsEnabled(bool bEnabled)
Definition ParticlePerfStats.h:200
FParticlePerfStats_GT & GetGameThreadStats()
Definition ParticlePerfStats.h:256
static bool GetStatsEnabled()
Definition ParticlePerfStats.h:181
static void AddSystemStatReader()
Definition ParticlePerfStats.h:203
ENGINE_API void ResetGT()
FParticlePerfStats_GT GameThreadStats
Definition ParticlePerfStats.h:247
Definition Optional.h:131