UDocumentation UE5.7 10.02.2026 (Source)
API documentation for Unreal Engine 5.7
StreamingTexture.h
Go to the documentation of this file.
1// Copyright Epic Games, Inc. All Rights Reserved.
2
3/*=============================================================================
4StreamingTexture.h: Definitions of classes used for texture streaming.
5=============================================================================*/
6
7#pragma once
8
9#include "CoreMinimal.h"
12#include "StaticMeshResources.h"
13
16
17/*-----------------------------------------------------------------------------
18 FStreamingRenderAsset, the streaming system's version of UStreamableRenderAsset.
19-----------------------------------------------------------------------------*/
20
23{
31
35 const int32* NumStreamedMips,
37 const FRenderAssetStreamingSettings& Settings);
38
41
43 void UpdateDynamicData(const int32* NumStreamedMips, int32 NumLODGroups, const FRenderAssetStreamingSettings& Settings, bool bWaitForMipFading, TArray<UStreamableRenderAsset*>* DeferredTickCBAssets = nullptr);
44
46 FStreamableRenderResourceState UpdateStreamingStatus(bool bWaitForMipFading, TArray<UStreamableRenderAsset*>* DeferredTickCBAssets = nullptr);
47
60
62 {
63 switch (InAssetType)
64 {
66 return TEXT("Texture");
68 return TEXT("StaticMesh");
70 return TEXT("SkeletalMesh");
71 default:
72 return TEXT("Unkown");
73 }
74 }
75
76 static float GetDefaultExtraBoost(bool bUseNewMetrics)
77 {
78 // When accurate distance computation, we need to relax the distance otherwise it gets too conservative. (ex 513 goes to 1024)
79 return bUseNewMetrics ? .71f : 1.f;
80 }
81
83
85
88 float MaxSize,
90 float MaxScreenSizeOverAllViews,
92 bool InLooksLowRes,
93 const FRenderAssetStreamingSettings& Settings);
94
97
100
103
106
109
112
113 float GetMaxAllowedSize(float MaxScreenSizeOverAllViews) const
114 {
115 return IsTexture() ? (float)(0x1 << (MaxAllowedMips - 1)) : MaxScreenSizeOverAllViews;
116 }
117
118 float GetNormalizedScreenSize(int32 NumMips) const
119 {
120 check(IsMesh());
121 check(NumMips > 0 && (uint32)NumMips <= UE_ARRAY_COUNT(LODScreenSizes));
122 return LODScreenSizes[NumMips - 1];
123 }
124
125 float GetLODScreenSize(int32 NumMips, float MaxScreenSizeOverAllViews) const
126 {
127 return IsTexture() ?
128 static_cast<float>(1 << (NumMips - 1)) :
129 GetNormalizedScreenSize(NumMips) * MaxScreenSizeOverAllViews;
130 }
131
134
136
139
140 // Cache meta data (e.g. WantedMips) for StreamWantedMipsUsingCachedData to use later on
142
143 // Stream using the meta data produced by last run of FRenderAssetStreamingMipCalcTask.
144 // This allows streaming to happen in parallel with the async update task
146
147 bool IsTexture() const
148 {
150 }
151
156
157 bool IsMesh() const
158 {
159 // FRenderAssetStreamingManager only handles textures and meshes currently
161 }
162
164 {
165 return bMissingTooManyMips;
166 }
167
169
170 // Whether this texture/mesh can be affected by Global Bias and Budget Bias per texture/mesh.
171 // It controls if the texture/mesh resolution can be scarificed to fit into budget.
173 {
174 // In editor, forced stream in should never have reduced mips as they can be edited.
179 }
180
182 {
183 const bool bBudgetedMipsIsValid = bHasViewPoint || bForceFullyLoadHeuristic; // Force fully load don't need any viewpoint info.
184 // If paused, nothing will update anytime soon.
185 // If more mips will be streamed in eventually, wait.
186 // Otherwise, if the distance based computation had no viewpoint, wait.
188 }
189
190 /***************************************************************
191 * Member data categories:
192 * (1) Members initialized when this is constructed => NEVER CHANGES
193 * (2) Cached dynamic members that need constant update => UPDATES IN UpdateDynamicData()
194 * (3) Helper data set by the streamer to handle special cases => CHANGES ANYTIME (gamethread)
195 * (4) Data generated by the async task. CHANGES ANYTIME (taskthread)
196 * (5) Data cached to allow streaming to run in parallel with meta data update
197 ***************************************************************/
198
201
204
212 union
213 {
215 struct
216 {
218 // Normalized size of projected bounding sphere - [0, 1]
220 };
221 };
222 // Make sure static mesh LODs will fit in the above struct
224
231
262
267
272
279
284
287
296
299
302
303private:
304 FORCEINLINE_DEBUGGABLE void StreamWantedMips_Internal(FRenderAssetStreamingManager& Manager, bool bUseCachedData);
305
306 FORCEINLINE_DEBUGGABLE int32 ClampMaxResChange_Internal(int32 NumMipDropRequested) const;
307};
#define FORCEINLINE
Definition AndroidPlatform.h:140
#define check(expr)
Definition AssertionMacros.h:314
const FIoFilenameHash INVALID_IO_FILENAME_HASH
Definition BulkData.h:69
uint32 FIoFilenameHash
Definition BulkData.h:68
#define GIsEditor
Definition CoreGlobals.h:233
#define FORCEINLINE_DEBUGGABLE
Definition CoreMiscDefines.h:74
FPlatformTypes::int8 int8
An 8-bit signed integer.
Definition Platform.h:1121
#define TEXT(x)
Definition Platform.h:1272
FPlatformTypes::TCHAR TCHAR
Either ANSICHAR or WIDECHAR, depending on whether the platform supports wide characters or the requir...
Definition Platform.h:1135
FPlatformTypes::int64 int64
A 64-bit signed integer.
Definition Platform.h:1127
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
USkinnedMeshComponent float
Definition SkinnedMeshComponent.h:60
#define MAX_STATIC_MESH_LODS
Definition StaticMeshResources.h:59
EStreamableRenderAssetType
Definition StreamableRenderAsset.h:26
TextureGroup
Definition TextureDefines.h:29
#define UE_ARRAY_COUNT(array)
Definition UnrealTemplate.h:212
uint32 Size
Definition VulkanMemory.cpp:4034
uint8_t uint8
Definition binka_ue_file_header.h:8
uint32_t uint32
Definition binka_ue_file_header.h:6
Definition Array.h:670
Definition SharedPointer.h:692
Definition StreamableRenderAsset.h:37
Definition StreamingManagerTexture.h:32
Definition TextureStreamingHelpers.h:72
Definition StreamableRenderResourceState.h:23
static const uint32 MAX_LOD_COUNT
Definition StreamableRenderResourceState.h:25
Definition StreamingTexture.h:23
void CancelStreamingRequest()
Definition StreamingTexture.cpp:544
int64 DropMaxResolution_Async(int32 NumDroppedMips)
Definition StreamingTexture.cpp:422
int8 MaxAllowedMips
Definition StreamingTexture.h:253
UStreamableRenderAsset * RenderAsset
Definition StreamingTexture.h:200
int8 VisibleWantedMips
Definition StreamingTexture.h:257
float LODScreenSizes[FStreamableRenderResourceState::MAX_LOD_COUNT/2]
Definition StreamingTexture.h:219
float DynamicBoostFactor
Definition StreamingTexture.h:230
bool IsMissingTooManyMips() const
Definition StreamingTexture.h:163
void StreamWantedMipsUsingCachedData(FRenderAssetStreamingManager &Manager)
Definition StreamingTexture.cpp:565
FIoFilenameHash OptionalFileHash
Definition StreamingTexture.h:206
bool IsMesh() const
Definition StreamingTexture.h:157
float BoostFactor
Definition StreamingTexture.h:210
float NormalizedScreenSize
Definition StreamingTexture.h:235
static float GetDefaultExtraBoost(bool bUseNewMetrics)
Definition StreamingTexture.h:76
int8 NumMissingMips
Definition StreamingTexture.h:255
int8 BudgetedMips
Definition StreamingTexture.h:261
EOptionalMipsState
Definition StreamingTexture.h:25
@ OMS_Num
Definition StreamingTexture.h:29
@ OMS_NotCached
Definition StreamingTexture.h:26
@ OMS_HasOptionalMips
Definition StreamingTexture.h:28
@ OMS_NoOptionalMips
Definition StreamingTexture.h:27
void SetPerfectWantedMips_Async(float MaxSize, float MaxSize_VisibleOnly, float MaxScreenSizeOverAllViews, int32 MaxNumForcedLODs, bool InLooksLowRes, const FRenderAssetStreamingSettings &Settings)
Definition StreamingTexture.cpp:338
FORCEINLINE bool HasUpdatePending(bool bIsStreamingPaused, bool bHasViewPoint) const
Definition StreamingTexture.h:181
uint8 bIsTerrainTexture
Definition StreamingTexture.h:278
static const TCHAR * GetStreamingAssetTypeStr(EStreamableRenderAssetType InAssetType)
Definition StreamingTexture.h:61
int64 KeepOneMip_Async()
Definition StreamingTexture.cpp:466
void UpdateDynamicData(const int32 *NumStreamedMips, int32 NumLODGroups, const FRenderAssetStreamingSettings &Settings, bool bWaitForMipFading, TArray< UStreamableRenderAsset * > *DeferredTickCBAssets=nullptr)
Definition StreamingTexture.cpp:174
uint8 bIgnoreStreamingMipBias
Definition StreamingTexture.h:283
static float GetExtraBoost(TextureGroup LODGroup, const FRenderAssetStreamingSettings &Settings)
Definition StreamingTexture.cpp:284
uint8 bCachedForceFullyLoadHeuristic
Definition StreamingTexture.h:298
FORCEINLINE bool IsMaxResolutionAffectedByGlobalBias() const
Definition StreamingTexture.h:172
int32 LODGroup
Definition StreamingTexture.h:208
double InstanceRemovedTimestamp
Definition StreamingTexture.h:228
uint8 bLoadWithHigherPriority
Definition StreamingTexture.h:276
int32 GetSize(int32 InMipCount) const
Definition StreamingTexture.h:54
TSharedPtr< int32, ESPMode::ThreadSafe > SimpleStreamableAssetManagerIndex
Definition StreamingTexture.h:203
bool UpdateLoadOrderPriority_Async(const FRenderAssetStreamingSettings &Settings)
Definition StreamingTexture.cpp:495
FStreamableRenderResourceState UpdateStreamingStatus(bool bWaitForMipFading, TArray< UStreamableRenderAsset * > *DeferredTickCBAssets=nullptr)
Definition StreamingTexture.cpp:266
int8 RequestedMips
Definition StreamingTexture.h:249
uint8 bUseUnkownRefHeuristic
Definition StreamingTexture.h:291
void UpdateStaticData(const FRenderAssetStreamingSettings &Settings)
Definition StreamingTexture.cpp:66
int8 CachedWantedMips
Definition StreamingTexture.h:264
void CacheStreamingMetaData()
Definition StreamingTexture.cpp:558
int8 CachedVisibleWantedMips
Definition StreamingTexture.h:266
FORCEINLINE int32 GetPerfectWantedMips() const
Definition StreamingTexture.h:168
bool IsTexture() const
Definition StreamingTexture.h:147
EStreamableRenderAssetType RenderAssetType
Definition StreamingTexture.h:269
TBitArray LevelIndexUsage
Definition StreamingTexture.h:301
int64 GetDropOneMipMemDelta() const
Definition StreamingTexture.cpp:490
bool IsVirtualTexture() const
Definition StreamingTexture.h:152
float GetLODScreenSize(int32 NumMips, float MaxScreenSizeOverAllViews) const
Definition StreamingTexture.h:125
int64 DropOneMip_Async()
Definition StreamingTexture.cpp:453
uint8 bForceFullyLoadHeuristic
Definition StreamingTexture.h:289
float LastRenderTime
Definition StreamingTexture.h:226
int32 GetWantedMipsFromSize(float Size, float InvMaxScreenSizeOverAllViews) const
Definition StreamingTexture.cpp:308
uint32 CumulativeLODSizes_Mesh[FStreamableRenderResourceState::MAX_LOD_COUNT/2]
Definition StreamingTexture.h:217
int32 RetentionPriority
Definition StreamingTexture.h:233
uint8 bMissingTooManyMips
Definition StreamingTexture.h:295
float GetNormalizedScreenSize(int32 NumMips) const
Definition StreamingTexture.h:118
void StreamWantedMips(FRenderAssetStreamingManager &Manager)
Definition StreamingTexture.cpp:553
float GetMaxAllowedSize(float MaxScreenSizeOverAllViews) const
Definition StreamingTexture.h:113
EOptionalMipsState OptionalMipsState
Definition StreamingTexture.h:271
void UpdateOptionalMipsState_Async()
Definition StreamingTexture.cpp:156
int64 GetDropMaxResMemDelta(int32 NumDroppedMips) const
Definition StreamingTexture.cpp:479
int32 BudgetMipBias
Definition StreamingTexture.h:239
uint8 bLooksLowRes
Definition StreamingTexture.h:293
uint32 CumulativeLODSizes[FStreamableRenderResourceState::MAX_LOD_COUNT]
Definition StreamingTexture.h:214
int8 WantedMips
Definition StreamingTexture.h:243
uint8 bIsVirtualTexture
Definition StreamingTexture.h:274
int8 NumForcedMips
Definition StreamingTexture.h:245
int32 NoRefLODBias
Definition StreamingTexture.h:241
uint8 bForceFullyLoad
Definition StreamingTexture.h:281
int32 LoadOrderPriority
Definition StreamingTexture.h:237
int8 MinAllowedMips
Definition StreamingTexture.h:251
int8 HiddenWantedMips
Definition StreamingTexture.h:259
int8 ResidentMips
Definition StreamingTexture.h:247
int64 UpdateRetentionPriority_Async(bool bPrioritizeMesh)
Definition StreamingTexture.cpp:385
uint8 bHasUpdatePending
Definition StreamingTexture.h:286