UDocumentation UE5.7 10.02.2026 (Source)
API documentation for Unreal Engine 5.7
CsvProfilerTrace.h
Go to the documentation of this file.
1// Copyright Epic Games, Inc. All Rights Reserved.
2
3#pragma once
4
5#include "CoreTypes.h"
7#include "Misc/Build.h"
9#include "Trace/Config.h"
10
11// Note: Enabling this adds about 15% to the instrumentation overhead of the CSV profiler, even if Insights is not capturing
12#ifndef CSVPROFILERTRACE_ENABLED
13#if UE_TRACE_ENABLED && !UE_BUILD_SHIPPING
14#define CSVPROFILERTRACE_ENABLED (WITH_ENGINE && CSV_PROFILER_STATS)
15#else
16#define CSVPROFILERTRACE_ENABLED 0
17#endif
18#endif
19
20class FName;
21
22#if CSVPROFILERTRACE_ENABLED
23
25{
26 static void OutputRegisterCategory(int32 Index, const TCHAR* Name);
27 CORE_API static void OutputInlineStat(const char* StatName, int32 CategoryIndex);
28 CORE_API static void OutputInlineStatExclusive(const char* StatName);
29 CORE_API static void OutputDeclaredStat(const FName& StatName, int32 CategoryIndex);
30 static void OutputBeginStat(const char* StatName, int32 CategoryIndex, uint64 Cycles);
31 static void OutputBeginStat(const FName& StatName, int32 CategoryIndex, uint64 Cycles);
32 static void OutputEndStat(const char* StatName, int32 CategoryIndex, uint64 Cycles);
33 static void OutputEndStat(const FName& StatName, int32 CategoryIndex, uint64 Cycles);
34 static void OutputBeginExclusiveStat(const char* StatName, int32 CategoryIndex, uint64 Cycles);
35 static void OutputEndExclusiveStat(const char* StatName, int32 CategoryIndex, uint64 Cycles);
36 static void OutputCustomStat(const char* StatName, int32 CategoryIndex, int32 Value, uint8 OpType, uint64 Cycles);
37 static void OutputCustomStat(const FName& StatName, int32 CategoryIndex, int32 Value, uint8 OpType, uint64 Cycles);
38 static void OutputCustomStat(const char* StatName, int32 CategoryIndex, float Value, uint8 OpType, uint64 Cycles);
39 static void OutputCustomStat(const FName& StatName, int32 CategoryIndex, float Value, uint8 OpType, uint64 Cycles);
40 static void OutputEvent(const TCHAR* Text, int32 CategoryIndex, uint64 Cycles);
41 static void OutputBeginCapture(const TCHAR* Filename, uint32 RenderThreadId, uint32 RHIThreadId, const char* DefaultWaitStatName, bool bEnableCounts);
42 static void OutputEndCapture();
43 static void OutputMetadata(const TCHAR* Key, const TCHAR* Value);
44};
45
46#define TRACE_CSV_PROFILER_REGISTER_CATEGORY(Index, Name) \
47 FCsvProfilerTrace::OutputRegisterCategory(Index, Name);
48
49#define TRACE_CSV_PROFILER_INLINE_STAT(StatName, CategoryIndex) \
50 static bool PREPROCESSOR_JOIN(__CsvProfilerStat, __LINE__); \
51 if (!PREPROCESSOR_JOIN(__CsvProfilerStat, __LINE__)) { \
52 FCsvProfilerTrace::OutputInlineStat(StatName, CategoryIndex); \
53 PREPROCESSOR_JOIN(__CsvProfilerStat, __LINE__) = true; \
54 }
55
56#define TRACE_CSV_PROFILER_INLINE_STAT_EXCLUSIVE(StatName) \
57 static bool PREPROCESSOR_JOIN(__CsvProfilerStat, __LINE__); \
58 if (!PREPROCESSOR_JOIN(__CsvProfilerStat, __LINE__)) { \
59 FCsvProfilerTrace::OutputInlineStatExclusive(StatName); \
60 PREPROCESSOR_JOIN(__CsvProfilerStat, __LINE__) = true; \
61 }
62
63#define TRACE_CSV_PROFILER_DECLARED_STAT(StatName, CategoryIndex) \
64 FCsvProfilerTrace::OutputDeclaredStat(StatName, CategoryIndex);
65
66#define TRACE_CSV_PROFILER_BEGIN_STAT(StatName, CategoryIndex, Cycles) \
67 FCsvProfilerTrace::OutputBeginStat(StatName, CategoryIndex, Cycles);
68
69#define TRACE_CSV_PROFILER_END_STAT(StatName, CategoryIndex, Cycles) \
70 FCsvProfilerTrace::OutputEndStat(StatName, CategoryIndex, Cycles);
71
72#define TRACE_CSV_PROFILER_BEGIN_EXCLUSIVE_STAT(StatName, CategoryIndex, Cycles) \
73 FCsvProfilerTrace::OutputBeginExclusiveStat(StatName, CategoryIndex, Cycles);
74
75#define TRACE_CSV_PROFILER_END_EXCLUSIVE_STAT(StatName, CategoryIndex, Cycles) \
76 FCsvProfilerTrace::OutputEndExclusiveStat(StatName, CategoryIndex, Cycles);
77
78#define TRACE_CSV_PROFILER_CUSTOM_STAT(StatName, CategoryIndex, Value, OpType, Cycles) \
79 FCsvProfilerTrace::OutputCustomStat(StatName, CategoryIndex, Value, OpType, Cycles);
80
81#define TRACE_CSV_PROFILER_EVENT(Text, CategoryIndex, Cycles) \
82 FCsvProfilerTrace::OutputEvent(Text, CategoryIndex, Cycles);
83
84#define TRACE_CSV_PROFILER_BEGIN_CAPTURE(Filename, RenderThreadId, RHIThreadId, DefaultWaitStatName, EnableCounts) \
85 FCsvProfilerTrace::OutputBeginCapture(Filename, RenderThreadId, RHIThreadId, DefaultWaitStatName, EnableCounts);
86
87#define TRACE_CSV_PROFILER_END_CAPTURE() \
88 FCsvProfilerTrace::OutputEndCapture();
89
90#define TRACE_CSV_PROFILER_METADATA(Key, Value) \
91 FCsvProfilerTrace::OutputMetadata(Key, Value);
92
93#else
94
95#define TRACE_CSV_PROFILER_REGISTER_CATEGORY(...)
96#define TRACE_CSV_PROFILER_INLINE_STAT(...)
97#define TRACE_CSV_PROFILER_INLINE_STAT_EXCLUSIVE(...)
98#define TRACE_CSV_PROFILER_DECLARED_STAT(...)
99#define TRACE_CSV_PROFILER_BEGIN_STAT(...)
100#define TRACE_CSV_PROFILER_END_STAT(...)
101#define TRACE_CSV_PROFILER_BEGIN_EXCLUSIVE_STAT(...)
102#define TRACE_CSV_PROFILER_END_EXCLUSIVE_STAT(...)
103#define TRACE_CSV_PROFILER_CUSTOM_STAT(...)
104#define TRACE_CSV_PROFILER_EVENT(...)
105#define TRACE_CSV_PROFILER_BEGIN_CAPTURE(...)
106#define TRACE_CSV_PROFILER_END_CAPTURE(...)
107#define TRACE_CSV_PROFILER_METADATA(...)
108
109#endif
FPlatformTypes::TCHAR TCHAR
Either ANSICHAR or WIDECHAR, depending on whether the platform supports wide characters or the requir...
Definition Platform.h:1135
FPlatformTypes::int32 int32
A 32-bit signed integer.
Definition Platform.h:1125
FPlatformTypes::uint64 uint64
A 64-bit unsigned integer.
Definition Platform.h:1117
UE_FORCEINLINE_HINT TSharedRef< CastToType, Mode > StaticCastSharedRef(TSharedRef< CastFromType, Mode > const &InSharedRef)
Definition SharedPointer.h:127
uint8_t uint8
Definition binka_ue_file_header.h:8
uint32_t uint32
Definition binka_ue_file_header.h:6
Definition NameTypes.h:617
U16 Index
Definition radfft.cpp:71