UDocumentation UE5.7 10.02.2026 (Source)
API documentation for Unreal Engine 5.7
TickableObjectRenderThread.h
Go to the documentation of this file.
1// Copyright Epic Games, Inc. All Rights Reserved.
2
3#pragma once
4
5#include "CoreMinimal.h"
6#include "Stats/Stats.h"
7
9
15{
16public:
17
19 struct FRenderingThreadTickableObjectsArray : public TArray<FTickableObjectRenderThread*>
20 {
22 {
23 // if there are any Tickable objects left registered at this point, force them to unregister
24 int32 MaxIterations = Num(); // prevents runaway loop (extra safety)
25 while(Num() > 0 && MaxIterations-- > 0)
26 {
29 Object->Unregister();
30 }
31 // if we exited uncleanly from a runaway loop, crash explicitly in Dev
32 check(Num() == 0);
33 }
34 };
35
38
45 : bHighFrequency(bInHighFrequency)
46 {
48 {
49 Register();
50 }
51 }
52
57 {
58 Unregister();
59 }
60
62 {
63 if (bRegistered)
64 {
65 // make sure this tickable object was registered from the rendering thread
66 checkf(IsInRenderingThread(), TEXT("Game thread attempted to unregister an object in the RenderingThreadTickableObjects array."));
67
69 const int32 Pos = TickableObjectArray.Find(this);
70 check(Pos!=INDEX_NONE);
71 TickableObjectArray.RemoveAt(Pos);
72 bRegistered = false;
73 }
74 }
75
79 void Register()
80 {
81 // make sure that only the rendering thread is attempting to add items to the RenderingThreadTickableObjects list
82 checkf(IsInRenderingThread(), TEXT("Game thread attempted to register an object in the RenderingThreadTickableObjects array."));
85 check(!bRegistered);
86 if (bHighFrequency)
87 {
89 }
90 else
91 {
93 }
94 bRegistered = true;
95 }
96
97 UE_DEPRECATED(5.7, "bIsRenderingThreadObject argument is no longer needed")
102
109 virtual void Tick(FRHICommandListImmediate& RHICmdList, float DeltaTime) = 0;
110
112 virtual TStatId GetStatId() const = 0;
113
122 virtual bool IsTickable() const = 0;
123
131 {
132 return false;
133 }
134
135private:
136 bool bRegistered = false;
137 const bool bHighFrequency;
138};
139
141
142UE_DEPRECATED(5.7, "TickRenderingTickables needs a command list")
OODEFFUNC typedef void(OODLE_CALLBACK t_fp_OodleCore_Plugin_Free)(void *ptr)
#define check(expr)
Definition AssertionMacros.h:314
#define checkf(expr, format,...)
Definition AssertionMacros.h:315
@ INDEX_NONE
Definition CoreMiscDefines.h:150
#define UE_DEPRECATED(Version, Message)
Definition CoreMiscDefines.h:302
#define TEXT(x)
Definition Platform.h:1272
FPlatformTypes::int32 int32
A 32-bit signed integer.
Definition Platform.h:1125
UE_FORCEINLINE_HINT TSharedRef< CastToType, Mode > StaticCastSharedRef(TSharedRef< CastFromType, Mode > const &InSharedRef)
Definition SharedPointer.h:127
CORE_API bool IsInRenderingThread()
Definition ThreadingBase.cpp:273
RENDERCORE_API void TickRenderingTickables()
Definition TickableObjectRenderThread.cpp:64
Definition RHICommandList.h:4626
Definition TickableObjectRenderThread.h:15
void Unregister()
Definition TickableObjectRenderThread.h:61
virtual ~FTickableObjectRenderThread()
Definition TickableObjectRenderThread.h:56
virtual TStatId GetStatId() const =0
FTickableObjectRenderThread(bool bRegisterImmediately=true, bool bInHighFrequency=false)
Definition TickableObjectRenderThread.h:44
void Register()
Definition TickableObjectRenderThread.h:79
virtual bool NeedsRenderingResumedForRenderingThreadTick() const
Definition TickableObjectRenderThread.h:130
virtual void Tick(FRHICommandListImmediate &RHICmdList, float DeltaTime)=0
static RENDERCORE_API FRenderingThreadTickableObjectsArray RenderingThreadHighFrequencyTickableObjects
Definition TickableObjectRenderThread.h:37
virtual bool IsTickable() const =0
static RENDERCORE_API FRenderingThreadTickableObjectsArray RenderingThreadTickableObjects
Definition TickableObjectRenderThread.h:36
Definition Array.h:670
UE_REWRITE SizeType Num() const
Definition Array.h:1144
bool Contains(const ComparisonType &Item) const
Definition Array.h:1518
UE_NODEBUG UE_FORCEINLINE_HINT SizeType Add(ElementType &&Item)
Definition Array.h:2696
UE_NODEBUG UE_FORCEINLINE_HINT bool Find(const ElementType &Item, SizeType &Index) const
Definition Array.h:1302
UE_NODEBUG UE_FORCEINLINE_HINT ElementType & Top() UE_LIFETIMEBOUND
Definition Array.h:1248
~FRenderingThreadTickableObjectsArray()
Definition TickableObjectRenderThread.h:21
Definition LightweightStats.h:416