UDocumentation UE5.7 10.02.2026 (Source)
API documentation for Unreal Engine 5.7
TextureMipAllocator.h
Go to the documentation of this file.
1// Copyright Epic Games, Inc. All Rights Reserved.
2
3/*=============================================================================
4TextureMipAllocator.h: Base class for implementing a mip allocation strategy used by FTextureStreamIn.
5=============================================================================*/
6
7#pragma once
8
9#include "CoreMinimal.h"
10#include "RHIFwd.h"
12
19{
20public:
21
22 enum class ETickState : uint32
23 {
24 AllocateMips, // Call AllocateMips(), which must provide destination memory for the mips to be written to.
25 UploadMips, // Call UploadMips(), which must release temporary buffers and update/upload the texture to the gpu.
26 Done // Nothing to do.
27 };
28
29 enum class ETickThread : uint32
30 {
31 Async, // Tick must run on an async thread.
32 Render, // Tick must run on the renderthread.
33 None, // No tick must run, only valid in ETickState::Done.
34 };
35
36 // Constructor, defining the first tick step and thread.
41
42 // Get the next tick state and thread for the mip allocator. Used by FTextureStreamIn to schedule correctly the update between FTextureMipAllocator and FTextureMipDataProvider.
43 FORCEINLINE ETickState GetNextTickState() const { return NextTickState; }
44 FORCEINLINE ETickThread GetNextTickThread() const { return NextTickThread; }
45
57
66 virtual bool UploadMips(const FTextureUpdateContext& Context, const FTextureUpdateSyncOptions& SyncOptions) = 0;
67
77
78 // Wrapper around virtual Cancel.
79 void ExecuteCancel(const FTextureUpdateSyncOptions& SyncOptions);
80
81 // Wrapper around virtual GetCancelThread.
83
85
86protected:
87
95 virtual void Cancel(const FTextureUpdateSyncOptions& SyncOptions) = 0;
96
97 // Returns on which thread Cancel() must be called in the texture update (from FTextureStreamIn) to release resources safely and correctly. ETickThread::None when ready to delete this.
98 virtual ETickThread GetCancelThread() const = 0;
99
100 // Helper to set the next tick state and thread. Validates that the progression is coherent.
102 {
103 // State must advance or at least stay to the same step.
104 check((uint32)NextTickState <= (uint32)InState);
105 // Thread must be valid unless in done state.
107
108 NextTickState = InState;
109 NextTickThread = InThread;
110 }
111
114 // The resident first LOD resource index. With domain = [0, ResourceState.NumLODs[. NOT THE ASSET LOD INDEX!
116 // The requested first LOD resource index. With domain = [0, ResourceState.NumLODs[. NOT THE ASSET LOD INDEX!
118
121
122private:
123
124 // The next tick function that should be called.
125 ETickState NextTickState = ETickState::Done;
126 // The next tick thread from where to call the tick function.
127 ETickThread NextTickThread = ETickThread::None;
128};
#define FORCEINLINE
Definition AndroidPlatform.h:140
#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
UE_FORCEINLINE_HINT TSharedRef< CastToType, Mode > StaticCastSharedRef(TSharedRef< CastFromType, Mode > const &InSharedRef)
Definition SharedPointer.h:127
uint32_t uint32
Definition binka_ue_file_header.h:6
Definition TextureMipAllocator.h:19
FTextureRHIRef IntermediateTextureRHI
Definition TextureMipAllocator.h:120
FTextureMipAllocator(const FTextureMipAllocator &)
FORCEINLINE void AdvanceTo(ETickState InState, ETickThread InThread)
Definition TextureMipAllocator.h:101
bool FinalizeMips(const FTextureUpdateContext &Context, const FTextureUpdateSyncOptions &SyncOptions)
Definition TextureMipAllocator.cpp:25
void ExecuteCancel(const FTextureUpdateSyncOptions &SyncOptions)
Definition TextureMipAllocator.cpp:50
virtual ETickThread GetCancelThread() const =0
virtual ~FTextureMipAllocator()
const FTextureRHIRef & GetIntermediateTextureRHI() const
Definition TextureMipAllocator.h:84
ETickThread ExecuteGetCancelThread() const
Definition TextureMipAllocator.cpp:40
virtual bool UploadMips(const FTextureUpdateContext &Context, const FTextureUpdateSyncOptions &SyncOptions)=0
virtual bool AllocateMips(const FTextureUpdateContext &Context, FTextureMipInfoArray &OutMipInfos, const FTextureUpdateSyncOptions &SyncOptions)=0
ETickState
Definition TextureMipAllocator.h:23
const int32 PendingFirstLODIdx
Definition TextureMipAllocator.h:117
FTextureMipAllocator(FTextureMipAllocator &&)
virtual void Cancel(const FTextureUpdateSyncOptions &SyncOptions)=0
const int32 CurrentFirstLODIdx
Definition TextureMipAllocator.h:115
FORCEINLINE ETickState GetNextTickState() const
Definition TextureMipAllocator.h:43
FORCEINLINE ETickThread GetNextTickThread() const
Definition TextureMipAllocator.h:44
const FStreamableRenderResourceState ResourceState
Definition TextureMipAllocator.h:113
ETickThread
Definition TextureMipAllocator.h:30
Definition Texture.h:1219
Definition StreamableRenderResourceState.h:23
Definition TextureMipDataProvider.h:65
Definition TextureMipDataProvider.h:48