UDocumentation UE5.7 10.02.2026 (Source)
API documentation for Unreal Engine 5.7
VirtualTextureShared.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
7enum class EVTProducerPriority : uint8;
9
11{
14 : TileX(InVec.X)
15 , TileY(InVec.Y)
16 {
17 checkSlow(InVec.X >= 0 && InVec.X <= 255);
18 checkSlow(InVec.Y >= 0 && InVec.Y <= 255);
19 }
20
22 struct
23 {
26 };
27};
28
30{
35
39
46
47 inline void Check(uint8 vDimensions)
48 {
49 const uint32 LowBitMask = (1u << (vDimensions * vLogSize)) - 1;
50 check((vAddress & LowBitMask) == 0);
51 //checkSlow(vLogSize <= vLevel);
52 }
53};
54
55// Little utility struct that allows to quickly sort different VT tile-related containers with different policies (size is limited to 64 bits, including the N bits-index, where N = NumBitsForIndex)
56// PriorityKeyType the priority value on the remaining bits (64 - NumBitsForIndex)
57// The bigger the priority value, the more important the tile
58template <typename PriorityKeyType, uint8 NumBitsForIndex = 16>
60{
62
64 // Shift by NumBitsForIndex the priority key so it occupies the most significant bits and thus defines the sorting :
66 {
67 checkfSlow(InIndex < (1ull << NumBitsForIndex), TEXT("The index and priority are packed onto a single uint64. Only NumBitsForIndex bits are allowed for the index"));
68 checkfSlow((InPriorityKey.PackedValue & ~(~0ull >> NumBitsForIndex)) == 0, TEXT("In TVTTilePriorityAndIndex, the priority key is merged with the index into a single uint64. Thus the first N bits of the priority key will be ignored."));
69 }
70
71 template<typename... TArgs>
75
76 // sort from largest to smallest
78
80
82 // The index are the first N (least significant) bits, so that they don't affect sorting
84
85 static_assert(sizeof(PriorityKeyType) == sizeof(uint64), "Unexpected size for TPriorityAndIndex. This struct should be kept as small as possible for the sorting to remain efficient");
86};
87
88// Sorting key for VT requests
90{
91 FVTRequestPriority() = default;
92
97 , Streaming((uint64)(bInStreaming ? 1 : 0))
98 , Locked((uint64)(bInLocked ? 1 : 0))
99 , Pad(0)
100 {
101 checkfSlow(static_cast<uint64>(InInvalidatePriority) <= (1 << 1), TEXT("EVTInvalidatePriority should be packable on 1 bit"));
102 checkfSlow(static_cast<uint64>(InProducerPriority) <= (1 << 3), TEXT("EVTProducerPriority should be packable on 3 bits"));
103 }
104
108
109 union
110 {
112 struct
113 {
114 // Important note : The order of these members is important : it defines the sort order (last member first)
115 uint64 PagePriority : 32; // Page priority depends on the number of requests and the mip level (higher mips come first)
116 uint64 InvalidatePriority : 1; // Manually-prioritized pages get processed before others
117 uint64 ProducerPriority : 3; // Sort by producer priority first
118 uint64 Streaming : 1; // Streaming pages get processed before others : important note : this needs to remain the second most significant bit, since FUniqueRequestList::SortRequests assumes streaming pages come next
119 uint64 Locked : 1; // Locked pages get processed before others : important note : this needs to remain the most significant bit, since FUniqueRequestList::SortRequests assumes locked pages come first
121 };
122 };
123};
124
125// Sorting key for plain FVirtualTextureLocalTile
127{
129
134 , Pad(0)
135 {
136 checkfSlow(static_cast<uint64>(InProducerPriority) <= (1 << 3), TEXT("EVTProducerPriority should be packable on 3 bits"));
137 checkfSlow(static_cast<uint64>(InMipLevel) <= (1 << 4), TEXT("Mip level should be packable on 4 bits"));
138 }
139
143
144 union
145 {
147 struct
148 {
149 // Important note : The order of these members is important : it defines the sort order (last member first)
150 uint64 MipLevel : 4; // Page priority depends on the number of requests and the mip level (higher mips come first)
151 uint64 InvalidatePriority : 1; // Prioritized pages get processed before others
152 uint64 ProducerPriority : 3; // Sort by producer priority first
154 };
155 };
156};
157
#define checkSlow(expr)
Definition AssertionMacros.h:332
#define checkfSlow(expr, format,...)
Definition AssertionMacros.h:333
#define check(expr)
Definition AssertionMacros.h:314
#define TEXT(x)
Definition Platform.h:1272
FPlatformTypes::uint64 uint64
A 64-bit unsigned integer.
Definition Platform.h:1117
UE_FORCEINLINE_HINT TSharedRef< CastToType, Mode > StaticCastSharedRef(TSharedRef< CastFromType, Mode > const &InSharedRef)
Definition SharedPointer.h:127
#define X(Name, Desc)
Definition FormatStringSan.h:47
EVTProducerPriority
Definition VirtualTextureEnum.h:11
EVTInvalidatePriority
Definition VirtualTextureEnum.h:29
uint32 Offset
Definition VulkanMemory.cpp:4033
uint8_t uint8
Definition binka_ue_file_header.h:8
uint16_t uint16
Definition binka_ue_file_header.h:7
uint32_t uint32
Definition binka_ue_file_header.h:6
Definition VirtualTextureShared.h:30
uint8 vLevel
Definition VirtualTextureShared.h:33
uint8 vLogSize
Definition VirtualTextureShared.h:34
uint32 vAddress
Definition VirtualTextureShared.h:31
FPhysicalTileLocation pTileLocation
Definition VirtualTextureShared.h:32
FPageTableUpdate(const FPageTableUpdate &Other)=default
void Check(uint8 vDimensions)
Definition VirtualTextureShared.h:47
FPageTableUpdate()
Definition VirtualTextureShared.h:36
FPageTableUpdate & operator=(const FPageTableUpdate &Other)=default
FPageTableUpdate(const FPageTableUpdate &Update, uint32 Offset, uint8 vDimensions)
Definition VirtualTextureShared.h:40
Definition VirtualTextureShared.h:127
uint64 Pad
Definition VirtualTextureShared.h:153
uint64 MipLevel
Definition VirtualTextureShared.h:150
FVTLocalTilePriority()=default
uint64 InvalidatePriority
Definition VirtualTextureShared.h:151
FVTLocalTilePriority(EVTProducerPriority InProducerPriority, EVTInvalidatePriority InInvalidatePriority, uint8 InMipLevel)
Definition VirtualTextureShared.h:130
uint64 PackedValue
Definition VirtualTextureShared.h:146
FVTLocalTilePriority(uint64 InPackedValue)
Definition VirtualTextureShared.h:140
uint64 ProducerPriority
Definition VirtualTextureShared.h:152
Definition VirtualTextureShared.h:90
FVTRequestPriority()=default
uint64 Pad
Definition VirtualTextureShared.h:120
uint64 Streaming
Definition VirtualTextureShared.h:118
uint64 InvalidatePriority
Definition VirtualTextureShared.h:116
uint64 PackedValue
Definition VirtualTextureShared.h:111
FVTRequestPriority(uint64 InPackedValue)
Definition VirtualTextureShared.h:105
FVTRequestPriority(bool bInLocked, bool bInStreaming, EVTProducerPriority InProducerPriority, EVTInvalidatePriority InInvalidatePriority, uint32 InPagePriority)
Definition VirtualTextureShared.h:93
uint64 ProducerPriority
Definition VirtualTextureShared.h:117
uint64 PagePriority
Definition VirtualTextureShared.h:115
uint64 Locked
Definition VirtualTextureShared.h:119
Definition VirtualTextureShared.h:11
FPhysicalTileLocation()
Definition VirtualTextureShared.h:12
uint8 TileX
Definition VirtualTextureShared.h:24
uint8 TileY
Definition VirtualTextureShared.h:25
uint16 Packed
Definition VirtualTextureShared.h:21
FPhysicalTileLocation(const FIntVector &InVec)
Definition VirtualTextureShared.h:13
Definition VirtualTextureShared.h:60
TVTTilePriorityAndIndex(uint64 InIndex, PriorityKeyType &&InPriorityKey)
Definition VirtualTextureShared.h:63
TVTTilePriorityAndIndex(uint64 InIndex, TArgs &&... InArgs)
Definition VirtualTextureShared.h:72
PriorityKeyType GetPriorityKey()
Definition VirtualTextureShared.h:79
uint64 SortablePackedValue
Definition VirtualTextureShared.h:81
uint64 Index
Definition VirtualTextureShared.h:83
TVTTilePriorityAndIndex()=default
bool operator<(const TVTTilePriorityAndIndex< PriorityKeyType, NumBitsForIndex > &InOther) const
Definition VirtualTextureShared.h:77