UDocumentation UE5.7 10.02.2026 (Source)
API documentation for Unreal Engine 5.7
TextureStreamingHelpers.h
Go to the documentation of this file.
1// Copyright Epic Games, Inc. All Rights Reserved.
2
3/*=============================================================================
4TextureStreamingHelpers.h: Definitions of classes used for texture streaming.
5=============================================================================*/
6
7#pragma once
8
9#include "CoreMinimal.h"
10#include "Stats/Stats.h"
11#include "HAL/IConsoleManager.h"
12#include "Misc/MemStack.h"
14
15#ifndef STREAMING_RETRY_ON_DESERIALIZATION_ERROR
16#define STREAMING_RETRY_ON_DESERIALIZATION_ERROR UE_BUILD_SHIPPING
17#endif
18
19class AActor;
21
27
28
29// Streaming Details
30
38
39
41
42extern float GLightmapStreamingFactor;
43extern float GShadowmapStreamingFactor;
45
46//@DEBUG:
47// Set to 1 to log all dynamic component notifications
48#define STREAMING_LOG_DYNAMIC 0
49// Set to 1 to log when we change a view
50#define STREAMING_LOG_VIEWCHANGES 0
51// Set to 1 to log when levels are added/removed
52#define STREAMING_LOG_LEVELS 0
53// Set to 1 to log textures that are canceled by CancelForcedTextures()
54#define STREAMING_LOG_CANCELFORCED 0
55
56#if PLATFORM_SUPPORTS_TEXTURE_STREAMING
58#endif
59
70
72{
73 // How to handle assets with too many missing MIPs or LODs
75 {
77 LRHM_LoadBeforeRegular, // Use higher IO priority than regular streaming requests
78 LRHM_LoadBeforeAsyncPrecache, // Also ensure that priority is higher than async loading precache requests
79 };
80
82 {
83 // Make sure padding bytes don't have random values
85 Update();
86 }
87
88 void Update();
89
90 FORCEINLINE bool operator ==(const FRenderAssetStreamingSettings& Rhs) const { return FMemory::Memcmp(this, &Rhs, sizeof(FRenderAssetStreamingSettings)) == 0; }
91 FORCEINLINE bool operator !=(const FRenderAssetStreamingSettings& Rhs) const { return FMemory::Memcmp(this, &Rhs, sizeof(FRenderAssetStreamingSettings)) != 0; }
92
93
121
125
126 // Cached values of
128
129protected:
130
131};
132
135
136#define NUM_BANDWIDTHSAMPLES 512
137#define NUM_LATENCYSAMPLES 512
138
140#define MAX_STREAMINGDISTANCE 10000.0f
141#define MAX_MIPDELTA 5.0f
142#define MAX_LASTRENDERTIME 90.0f
143
144#ifndef UE_WITH_RENDER_ASSET_STREAMING_CSV_STATS
145#define UE_WITH_RENDER_ASSET_STREAMING_CSV_STATS UE_BUILD_TEST
146#endif
147
148class UPrimitiveComponent;
150template<typename T>
151class FAsyncTask;
153
154
156struct FStreamingContext;
158struct FTexturePriority;
159
161{
163
165
166 void Apply();
167
168 int64 RenderAssetPool; // Streaming pool size in bytes given by RHI, usally some percentage of available VRAM
169 // int64 StreamingPool;
170 int64 UsedStreamingPool; // Estimated memory in bytes the streamer actually use
171
172 int64 SafetyPool; // Memory margin in bytes we want to left unused
173 int64 TemporaryPool; // Pool size in bytes for staging resources
174 int64 StreamingPool; // Estimated memory in bytes available for streaming after subtracting non-streamable memory and safety pool
175 int64 NonStreamingMips; // Estimated memory in bytes the streamer deemed non-streamable
176
177 int64 RequiredPool; // Estimated memory in bytes the streamer would use if there was no limit
178#if WITH_EDITOR
179 int64 RequiredPool_Editor; // Estimated memory in bytes used by the Editor
180#endif
181 int64 VisibleMips; // Estimated memory in bytes used by visible assets
182 int64 HiddenMips; // Estimated memory in bytes used by hidden (e.g. culled by view frustum or occlusion) assets
183 int64 ForcedMips; // Estimated memory in bytes used by forced-fully-load assets
184 int64 UnkownRefMips; // Estimated memory in bytes used by unknown-ref-heuristic assets
185 int64 CachedMips; // Estimated memory in bytes used by the streamer for caching
186
187 int64 WantedMips; // Estimated memory in bytes would be resident if there was no caching
188 int64 NewRequests; // Estimated memory in bytes required by new requests (TODO)
189 int64 PendingRequests; // Estimated memory in bytes waiting to be loaded for previous requests
190 int64 MipIOBandwidth; // Estimated IO bandwidth in bytes/sec
191
192 int64 OverBudget; // RequiredPool - StreamingPool
193
194 double Timestamp; // Last time point these stats are updated in seconds
195
196
200 int32 StreamRenderAssetsCycles; // CPU cycles used to process Mip/LOD load and unload requests
201
202 int32 NumStreamedMeshes; // Number of meshes managed by the streamer
203 float AvgNumStreamedLODs; // Average number of mesh LODs that can be streamed
204 float AvgNumResidentLODs; // Average number of mesh LODs resident
205 float AvgNumEvictedLODs; // Average number of mesh LODs evicted
206 int64 StreamedMeshMem; // Total memory in bytes of mesh LODs that can be streamed
207 int64 ResidentMeshMem; // Total memory in bytes of resident mesh LODs
208 int64 EvictedMeshMem; // Total memory in bytes of evicted mesh LODs
209
210 int64 VirtualTexturePool; // Pool size used for virtual texture budget
211 int32 NumVirtualTextures; // Number of virtual textures managed by the streamer
212 int64 RequiredVirtualTexturePool; // Estimated memory in bytes the streamer would use if there was no limit
213 int64 UsedVirtualTexturePool; // Estimated memory in bytes the streamer actually use
214};
215
216// Helper to access the level bStaticComponentsRegisteredInStreamingManager flag.
#define FORCEINLINE
Definition AndroidPlatform.h:140
#define TEXT(x)
Definition Platform.h:1272
FPlatformTypes::int64 int64
A 64-bit signed integer.
Definition Platform.h:1127
FPlatformTypes::int32 int32
A 32-bit signed integer.
Definition Platform.h:1125
#define DECLARE_CYCLE_STAT_EXTERN(CounterName, StatId, GroupId, API)
Definition Stats.h:679
#define DECLARE_DWORD_COUNTER_STAT_EXTERN(CounterName, StatId, GroupId, API)
Definition Stats.h:682
UE_FORCEINLINE_HINT TSharedRef< CastToType, Mode > StaticCastSharedRef(TSharedRef< CastFromType, Mode > const &InSharedRef)
Definition SharedPointer.h:127
#define DECLARE_LOG_CATEGORY_EXTERN(CategoryName, DefaultVerbosity, CompileTimeVerbosity)
Definition LogMacros.h:361
@ TEXTUREGROUP_MAX
Definition TextureDefines.h:124
bool OwnerLevelHasRegisteredStaticComponentsInStreamingManager(const class AActor *Owner)
TAutoConsoleVariable< int32 > CVarStreamingCheckBuildStatus
float GShadowmapStreamingFactor
Definition TextureStreamingHelpers.cpp:403
TAutoConsoleVariable< int32 > CVarStreamingUseFixedPoolSize
float GLightmapStreamingFactor
Definition TextureStreamingHelpers.cpp:400
TAutoConsoleVariable< float > CVarStreamingMinBoost
TAutoConsoleVariable< int32 > CVarStreamingLowResHandlingMode
TArray< int32, TMemStackAllocator<> > FStreamingRequests
Definition TextureStreamingHelpers.h:133
TArray< const UStreamableRenderAsset *, TInlineAllocator< 12 > > FRemovedRenderAssetArray
Definition TextureStreamingHelpers.h:134
TAutoConsoleVariable< float > CVarStreamingMaxTextureUVDensity
TAutoConsoleVariable< int32 > CVarStreamingDefragDynamicBounds
TAutoConsoleVariable< int32 > CVarStreamingPoolSize
TAutoConsoleVariable< float > CVarStreamingBoost
bool GNeverStreamOutRenderAssets
Definition TextureStreamingHelpers.cpp:408
TAutoConsoleVariable< int32 > CVarStreamingNumStaticComponentsProcessedPerFrame
TAutoConsoleVariable< int32 > CVarStreamingUseMaterialData
Definition Actor.h:257
Definition AsyncWork.h:585
Definition DynamicTextureInstanceManager.h:19
Definition AsyncTextureStreaming.h:135
Definition Array.h:670
Definition IConsoleManager.h:1792
Definition StreamableRenderAsset.h:37
static UE_FORCEINLINE_HINT void * Memzero(void *Dest, SIZE_T Count)
Definition UnrealMemory.h:131
static UE_FORCEINLINE_HINT int32 Memcmp(const void *Buf1, const void *Buf2, SIZE_T Count)
Definition UnrealMemory.h:114
static UE_FORCEINLINE_HINT void * Memset(void *Dest, uint8 Char, SIZE_T Count)
Definition UnrealMemory.h:119
Definition TextureStreamingHelpers.h:72
bool bUseMaterialData
Definition TextureStreamingHelpers.h:111
int32 HLODStrategy
Definition TextureStreamingHelpers.h:97
int32 PoolSize
Definition TextureStreamingHelpers.h:102
int32 GlobalMipBias
Definition TextureStreamingHelpers.h:101
ELowResHandlingMode LowResHandlingMode
Definition TextureStreamingHelpers.h:117
static int32 ExtraIOLatencyRayTracing
Definition TextureStreamingHelpers.h:124
int32 MaxTempMemoryAllowed
Definition TextureStreamingHelpers.h:95
FORCEINLINE bool operator!=(const FRenderAssetStreamingSettings &Rhs) const
Definition TextureStreamingHelpers.h:91
int32 DropMips
Definition TextureStreamingHelpers.h:96
bool bPrioritizeMeshLODRetention
Definition TextureStreamingHelpers.h:119
int32 VRAMPercentageClamp
Definition TextureStreamingHelpers.h:120
bool bUsePerTextureBias
Definition TextureStreamingHelpers.h:110
FORCEINLINE bool operator==(const FRenderAssetStreamingSettings &Rhs) const
Definition TextureStreamingHelpers.h:90
float PerTextureBiasViewBoostThreshold
Definition TextureStreamingHelpers.h:99
int32 FramesForFullUpdate
Definition TextureStreamingHelpers.h:116
int32 MinMipForSplitRequest
Definition TextureStreamingHelpers.h:112
FRenderAssetStreamingSettings()
Definition TextureStreamingHelpers.h:81
bool bUseAllMips
Definition TextureStreamingHelpers.h:109
bool bStressTest
Definition TextureStreamingHelpers.h:122
static int32 ExtraIOLatency
Definition TextureStreamingHelpers.h:123
int32 MaterialQualityLevel
Definition TextureStreamingHelpers.h:115
bool bFullyLoadUsedTextures
Definition TextureStreamingHelpers.h:107
bool bFullyLoadMeshes
Definition TextureStreamingHelpers.h:108
float MaxHiddenPrimitiveViewBoost
Definition TextureStreamingHelpers.h:100
ELowResHandlingMode
Definition TextureStreamingHelpers.h:75
@ LRHM_LoadBeforeRegular
Definition TextureStreamingHelpers.h:77
@ LRHM_LoadBeforeAsyncPrecache
Definition TextureStreamingHelpers.h:78
@ LRHM_DoNothing
Definition TextureStreamingHelpers.h:76
float MaxEffectiveScreenSize
Definition TextureStreamingHelpers.h:94
int32 MeshPoolSize
Definition TextureStreamingHelpers.h:103
bool bUseNewMetrics
Definition TextureStreamingHelpers.h:106
bool bMipCalculationEnablePerLevelList
Definition TextureStreamingHelpers.h:118
bool HighPriorityLoad_Texture[TEXTUREGROUP_MAX]
Definition TextureStreamingHelpers.h:127
float MaxTextureUVDensity
Definition TextureStreamingHelpers.h:114
void Update()
Definition TextureStreamingHelpers.cpp:332
bool bLimitPoolSizeToVRAM
Definition TextureStreamingHelpers.h:105
float HiddenPrimitiveScale
Definition TextureStreamingHelpers.h:98
float MinLevelRenderAssetScreenSize
Definition TextureStreamingHelpers.h:113
int32 VirtualTexturePoolSize
Definition TextureStreamingHelpers.h:104
Definition TextureStreamingHelpers.h:161
int32 SetupAsyncTaskCycles
Definition TextureStreamingHelpers.h:198
int32 StreamRenderAssetsCycles
Definition TextureStreamingHelpers.h:200
float AvgNumResidentLODs
Definition TextureStreamingHelpers.h:204
int64 RequiredPool
Definition TextureStreamingHelpers.h:177
float AvgNumEvictedLODs
Definition TextureStreamingHelpers.h:205
volatile int32 CallbacksCycles
Definition TextureStreamingHelpers.h:197
void Reset()
Definition TextureStreamingHelpers.h:164
int32 NumStreamedMeshes
Definition TextureStreamingHelpers.h:202
int64 MipIOBandwidth
Definition TextureStreamingHelpers.h:190
double Timestamp
Definition TextureStreamingHelpers.h:194
FRenderAssetStreamingStats()
Definition TextureStreamingHelpers.h:162
int64 TemporaryPool
Definition TextureStreamingHelpers.h:173
int64 WantedMips
Definition TextureStreamingHelpers.h:187
int64 SafetyPool
Definition TextureStreamingHelpers.h:172
int64 NewRequests
Definition TextureStreamingHelpers.h:188
int64 CachedMips
Definition TextureStreamingHelpers.h:185
int64 ForcedMips
Definition TextureStreamingHelpers.h:183
int32 UpdateStreamingDataCycles
Definition TextureStreamingHelpers.h:199
int64 PendingRequests
Definition TextureStreamingHelpers.h:189
int64 StreamedMeshMem
Definition TextureStreamingHelpers.h:206
int64 EvictedMeshMem
Definition TextureStreamingHelpers.h:208
int64 UsedVirtualTexturePool
Definition TextureStreamingHelpers.h:213
int64 ResidentMeshMem
Definition TextureStreamingHelpers.h:207
int32 NumVirtualTextures
Definition TextureStreamingHelpers.h:211
int64 VirtualTexturePool
Definition TextureStreamingHelpers.h:210
int64 NonStreamingMips
Definition TextureStreamingHelpers.h:175
int64 StreamingPool
Definition TextureStreamingHelpers.h:174
int64 VisibleMips
Definition TextureStreamingHelpers.h:181
int64 UsedStreamingPool
Definition TextureStreamingHelpers.h:170
int64 RequiredVirtualTexturePool
Definition TextureStreamingHelpers.h:212
void Apply()
Definition TextureStreamingHelpers.cpp:420
int64 RenderAssetPool
Definition TextureStreamingHelpers.h:168
int64 UnkownRefMips
Definition TextureStreamingHelpers.h:184
float AvgNumStreamedLODs
Definition TextureStreamingHelpers.h:203
int64 HiddenMips
Definition TextureStreamingHelpers.h:182
int64 OverBudget
Definition TextureStreamingHelpers.h:192
Definition StreamingTexture.h:23