UDocumentation UE5.7 10.02.2026 (Source)
API documentation for Unreal Engine 5.7
RenderAssetUpdate.h
Go to the documentation of this file.
1// Copyright Epic Games, Inc. All Rights Reserved.
2
3/*=============================================================================
4RenderAssetUpdate.h: Base class of helpers to stream in and out texture/mesh LODs
5=============================================================================*/
6
7#pragma once
8
9#include "CoreMinimal.h"
11#include "Async/AsyncWork.h"
12#include "RenderingThread.h"
14
15#define UE_API ENGINE_API
16
18
20#define SRA_UPDATE_CALLBACK(FunctionName) [this](const FContext& C){ FunctionName(C); }
21
23
25
28{
30}
31
38{
39public:
40
43 {
44 TT_None, // No thread.
45 TT_Render, // The render thread.
46 TT_Async, // An async work thread.
47 TT_GameThread, // The game thread
48 TT_GameRunningAsync // The game thread running async work.
49 };
50
53 {
54 TS_Done, // Nothing to do.
55 TS_Suspended, // Waiting for external events, like IO requests, or when the renderthread is suspended.
56 TS_InProgress, // Callbacks are about to be executed.
57 TS_Locked, // The object is locked, and no one is allowed to process or look at the next task.
58 TS_Init // The object is in initialization
59 };
60
62
70
72 bool IsCompleted() const
73 {
74 return TaskState == TS_Done;
75 }
76
81 virtual void Abort()
82 {
84 }
85
91 virtual bool CanAbandon() const
92 {
93 return false;
94 }
95
99 virtual void OnAbandoned()
100 {
101 check(CanAbandon());
102 StreamableAsset = nullptr;
103 }
104
106 bool IsCancelled() const
107 {
108 return bIsCancelled;
109 }
110
113 {
114 return bSuccess;
115 }
116
119
122
123 bool IsLocked() const
124 {
125 return TaskState == TS_Locked;
126 }
127
129 virtual EThreadType GetRelevantThread() const = 0;
130
131 //****************** IRefCountedObject ****************/
132
133 FReturnedRefCountValue AddRef() const final override
134 {
135 return FReturnedRefCountValue{(uint32)NumRefs.Increment()};
136 }
137
138 UE_API uint32 Release() const final override;
139
140 uint32 GetRefCount() const final override
141 {
142 return (uint32)NumRefs.GetValue();
143 }
144
145protected:
146
147 UE_API virtual ~FRenderAssetUpdate();
148
150
153 {
154 // StreamableAsset = nullptr; // TODO once Cancel supports it!
155
156 if (TaskState != TS_Done) // do not cancel if we have already completed, see FORT-345212.
157 {
158 bIsCancelled = true;
159 }
160 }
161
163 {
164 bSuccess = true;
165 }
166
167 UE_API void ScheduleGTTask();
170
172
189
192
195 // The resident first LOD resource index. With domain = [0, ResourceState.NumLODs[. NOT THE ASSET LOD INDEX!
197 // The requested first LOD resource index. With domain = [0, ResourceState.NumLODs[. NOT THE ASSET LOD INDEX!
199
202
205
208
211
214
217
220
223
226
229
230private:
231
233 mutable FThreadSafeCounter NumRefs;
234};
235
241template <typename TContext>
290
293
294#undef UE_API
OODEFFUNC typedef void(OODLE_CALLBACK t_fp_OodleCore_Plugin_Free)(void *ptr)
#define check(expr)
Definition AssertionMacros.h:314
@ INDEX_NONE
Definition CoreMiscDefines.h:150
FPlatformTypes::int32 int32
A 32-bit signed integer.
Definition Platform.h:1125
#define RETURN_QUICK_DECLARE_CYCLE_STAT(StatId, GroupId)
Definition Stats.h:655
UE_FORCEINLINE_HINT TSharedRef< CastToType, Mode > StaticCastSharedRef(TSharedRef< CastFromType, Mode > const &InSharedRef)
Definition SharedPointer.h:127
UE::FPlatformRecursiveMutex FCriticalSection
Definition CriticalSection.h:53
ENGINE_API bool GEnableAssetUpdateAbandons
Definition RenderAssetUpdate.cpp:30
#define UE_API
Definition RenderAssetUpdate.h:15
void ResumeRenderAssetStreaming()
Definition RenderAssetUpdate.cpp:132
void SuspendRenderAssetStreaming()
Definition RenderAssetUpdate.cpp:46
ENGINE_API bool IsAssetStreamingSuspended()
Definition RenderAssetUpdate.cpp:41
uint32_t uint32
Definition binka_ue_file_header.h:6
Definition AsyncWork.h:63
Definition AsyncWork.h:663
Definition RenderAssetUpdate.cpp:252
Definition RenderAssetUpdate.h:175
void DoWork()
Definition RenderAssetUpdate.cpp:332
FMipUpdateTask(FRenderAssetUpdate *InPendingUpdate)
Definition RenderAssetUpdate.h:177
TStatId GetStatId() const
Definition RenderAssetUpdate.h:181
TRefCountPtr< FRenderAssetUpdate > PendingUpdate
Definition RenderAssetUpdate.h:187
Definition RenderAssetUpdate.h:38
virtual bool CanAbandon() const
Definition RenderAssetUpdate.h:91
const int32 CurrentFirstLODIdx
Definition RenderAssetUpdate.h:196
virtual UE_API ~FRenderAssetUpdate()
Definition RenderAssetUpdate.cpp:175
virtual void Abort()
Definition RenderAssetUpdate.h:81
bool IsCancelled() const
Definition RenderAssetUpdate.h:106
const UStreamableRenderAsset * StreamableAsset
Definition RenderAssetUpdate.h:213
FCriticalSection CS
Definition RenderAssetUpdate.h:201
bool bDeferExecution
Definition RenderAssetUpdate.h:222
bool IsLocked() const
Definition RenderAssetUpdate.h:123
bool IsCompleted() const
Definition RenderAssetUpdate.h:72
bool IsSuccessfullyFinished() const
Definition RenderAssetUpdate.h:112
int32 ScheduledGTTasks
Definition RenderAssetUpdate.h:204
UE_API void ScheduleRenderTask()
Definition RenderAssetUpdate.cpp:301
FAutoDeleteAsyncTask< FMipUpdateTask > FAsyncMipUpdateTask
Definition RenderAssetUpdate.h:191
const int32 PendingFirstLODIdx
Definition RenderAssetUpdate.h:198
ETaskState
Definition RenderAssetUpdate.h:53
@ TS_Init
Definition RenderAssetUpdate.h:58
@ TS_InProgress
Definition RenderAssetUpdate.h:56
@ TS_Suspended
Definition RenderAssetUpdate.h:55
@ TS_Locked
Definition RenderAssetUpdate.h:57
@ TS_Done
Definition RenderAssetUpdate.h:54
int32 ScheduledAsyncTasks
Definition RenderAssetUpdate.h:210
bool bSuccess
Definition RenderAssetUpdate.h:225
UE_API uint32 Release() const final override
Definition RenderAssetUpdate.cpp:181
virtual ETaskState TickInternal(EThreadType InCurrentThread, bool bCheckForSuspension)=0
virtual void OnAbandoned()
Definition RenderAssetUpdate.h:99
int32 ScheduledRenderTasks
Definition RenderAssetUpdate.h:207
EThreadType
Definition RenderAssetUpdate.h:43
@ TT_None
Definition RenderAssetUpdate.h:44
@ TT_GameRunningAsync
Definition RenderAssetUpdate.h:48
@ TT_Async
Definition RenderAssetUpdate.h:46
@ TT_Render
Definition RenderAssetUpdate.h:45
@ TT_GameThread
Definition RenderAssetUpdate.h:47
FThreadSafeCounter TaskSynchronization
Definition RenderAssetUpdate.h:216
UE_API void ScheduleAsyncTask()
Definition RenderAssetUpdate.cpp:323
void MarkAsSuccessfullyFinished()
Definition RenderAssetUpdate.h:162
UE_API void ScheduleGTTask()
Definition RenderAssetUpdate.cpp:284
virtual EThreadType GetRelevantThread() const =0
bool bIsCancelled
Definition RenderAssetUpdate.h:219
FReturnedRefCountValue AddRef() const final override
Definition RenderAssetUpdate.h:133
volatile ETaskState TaskState
Definition RenderAssetUpdate.h:228
const FStreamableRenderResourceState ResourceState
Definition RenderAssetUpdate.h:194
UE_API ETaskState DoLock()
Definition RenderAssetUpdate.cpp:352
uint32 GetRefCount() const final override
Definition RenderAssetUpdate.h:140
UE_API void DoUnlock(ETaskState PreviousTaskState)
Definition RenderAssetUpdate.cpp:360
void MarkAsCancelled()
Definition RenderAssetUpdate.h:152
Definition ThreadSafeCounter.h:14
int32 Increment()
Definition ThreadSafeCounter.h:52
int32 GetValue() const
Definition ThreadSafeCounter.h:120
Definition RefCounting.h:196
Definition AndroidPlatformMisc.h:14
Definition RefCounting.h:454
Definition RenderAssetUpdate.h:243
FCallback CancelationCallback
Definition RenderAssetUpdate.h:278
EThreadType CancelationThread
Definition RenderAssetUpdate.h:276
void ClearCallbacks()
Definition RenderAssetUpdate.h:282
EThreadType GetRelevantThread() const final override
Definition RenderAssetUpdate.h:267
TFunction< void(const FContext &Context)> FCallback
Definition RenderAssetUpdate.h:249
EThreadType TaskThread
Definition RenderAssetUpdate.h:272
TContext FContext
Definition RenderAssetUpdate.h:246
void PushTask(const FContext &Context, EThreadType InTaskThread, const FCallback &InTaskCallback, EThreadType InCancelationThread, const FCallback &InCancelationCallback)
Definition RenderAssetUpdate.inl:23
ETaskState TickInternal(EThreadType InCurrentThread, bool bCheckForSuspension) final override
Definition RenderAssetUpdate.inl:38
FCallback TaskCallback
Definition RenderAssetUpdate.h:274
Definition StreamableRenderAsset.h:37
Definition RenderAssetUpdate.cpp:138
bool TickRenderAssetUpdateForGarbageCollection(TRefCountPtr< FRenderAssetUpdate > RenderAssetUpdate)
Definition RenderAssetUpdate.cpp:139
Definition RefCounting.h:29
Definition StreamableRenderResourceState.h:23
Definition LightweightStats.h:416