UDocumentation UE5.7 10.02.2026 (Source)
API documentation for Unreal Engine 5.7
ExternalProfiler.h
Go to the documentation of this file.
1// Copyright Epic Games, Inc. All Rights Reserved.
2
3#pragma once
4
6#include "CoreTypes.h"
8#include "Misc/Build.h"
10#include "UObject/NameTypes.h"
11
12#if UE_EXTERNAL_PROFILING_ENABLED
13
20{
21
22public:
23
29
31 virtual ~FExternalProfiler()
32 {
33 }
34
36 UE_DEPRECATED(5.6, "Use FActiveExternalProfilerBase::PauseActiveProfiler instead")
38
42
48 virtual void FrameSync() = 0;
49
51 virtual void Register() {}
52
54 virtual void ProfilerPauseFunction() = 0;
55
57 virtual void ProfilerResumeFunction() = 0;
58
60 virtual const TCHAR* GetProfilerName() const = 0;
61
63 static CORE_API FName GetFeatureName();
64
66 virtual void OnEnableScopedEventsChanged(bool bEnabled) {};
67
69 virtual void StartScopedEvent(const struct FColor& Color, const TCHAR* Text) {};
70
72 virtual void StartScopedEvent(const struct FColor& Color, const ANSICHAR* Text) { StartScopedEvent(Color, ANSI_TO_TCHAR(Text)); };
73
75 virtual void EndScopedEvent() {};
76
77 virtual void SetThreadName(const TCHAR* Name) {}
78};
79
81{
82public:
83
85
108
113 static CORE_API bool SetActiveProfilerRecording(bool bRecording);
115
138 static CORE_API void EnableScopedEvents(bool bEnable);
139
143 static CORE_API bool AreScopedEventsEnabled();
144
145private:
147 static CORE_API bool bDidInitialize;
148
151
153 static std::atomic<bool> bIsRecording;
154
156 static std::atomic<bool> bEnableScopedEvents;
157};
158
163{
164protected:
171 CORE_API void StartScopedTimer( const bool bWantPause );
172
175
176private:
178 bool bWasRecording = false;
179};
180
181
194{
195public:
198 {
199 const bool bWantPause = false;
201 }
202
205 {
207 }
208};
209
210
223{
224public:
227 {
228 const bool bWantPause = true;
230 }
231
234 {
236 }
237
238};
239
241{
242public:
244 inline static void StartScopedEvent(const struct FColor& Color, const TCHAR* Text)
245 {
246 if (FActiveExternalProfilerBase::AreScopedEventsEnabled())
247 {
248 if (FExternalProfiler* Profiler = FActiveExternalProfilerBase::GetActiveProfiler())
249 {
250 Profiler->StartScopedEvent(Color, Text);
251 }
252 }
253 }
254
256 inline static void StartScopedEvent(const struct FColor& Color, const ANSICHAR* Text)
257 {
258 if (FActiveExternalProfilerBase::AreScopedEventsEnabled())
259 {
260 if (FExternalProfiler* Profiler = FActiveExternalProfilerBase::GetActiveProfiler())
261 {
262 Profiler->StartScopedEvent(Color, Text);
263 }
264 }
265 }
266
268 inline static void EndScopedEvent()
269 {
270 if (FActiveExternalProfilerBase::AreScopedEventsEnabled())
271 {
272 if (FExternalProfiler* Profiler = FActiveExternalProfilerBase::GetActiveProfiler())
273 {
274 Profiler->EndScopedEvent();
275 }
276 }
277 }
278};
279
280#define SCOPE_PROFILER_INCLUDER(X) FExternalProfilerIncluder ExternalProfilerIncluder_##X;
281#define SCOPE_PROFILER_EXCLUDER(X) FExternalProfilerExcluder ExternalProfilerExcluder_##X;
282
283#else // UE_EXTERNAL_PROFILING_ENABLED
284
285#define SCOPE_PROFILER_INCLUDER(X)
286#define SCOPE_PROFILER_EXCLUDER(X)
287
288#endif // !UE_EXTERNAL_PROFILING_ENABLED
#define UE_DEPRECATED(Version, Message)
Definition CoreMiscDefines.h:302
FPlatformTypes::TCHAR TCHAR
Either ANSICHAR or WIDECHAR, depending on whether the platform supports wide characters or the requir...
Definition Platform.h:1135
FPlatformTypes::ANSICHAR ANSICHAR
An ANSI character. Normally a signed type.
Definition Platform.h:1131
UE_FORCEINLINE_HINT TSharedRef< CastToType, Mode > StaticCastSharedRef(TSharedRef< CastFromType, Mode > const &InSharedRef)
Definition SharedPointer.h:127
#define ANSI_TO_TCHAR(str)
Definition StringConv.h:1020
Definition NameTypes.h:617
Definition UnrealType.h:3087
Definition IModularFeature.h:12
void SetThreadName(unsigned int thread_id, const char *p_name)
Definition Color.h:486