UDocumentation UE5.7 10.02.2026 (Source)
API documentation for Unreal Engine 5.7
NaniteOrderedScatterUpdater.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#include "Containers/HashTable.h"
7
8class FRDGBuilder;
9class FRDGBufferUAV;
10
11namespace Nanite
12{
13
14enum class EScatterOp
15{
16 Or = 0,
17 And = 1,
18 Write = 2,
19};
20
21// Helper to emulate serial buffer updates on the GPU
23{
24public:
26
28 {
30
31 Updates.Add(FUpdate(Op, Offset, Value));
32 }
33
34 // Call this if there can be multiple updates to the same address.
35 // When executed on the GPU, these updates can otherwise be unordered.
36 // For a given address ResolveOverwrites removes all updates except the last one.
37 void ResolveOverwrites(bool bVerify);
38
39 void Flush(FRDGBuilder& GraphBuilder, FRDGBufferUAV* UAV);
40
41 uint32 Num() const
42 {
43 return Updates.Num();
44 }
45
46private:
47 class FUpdate
48 {
49 public:
50 FUpdate() :
51 Op_Offset(0xFFFFFFFCu), Value(0u)
52 {
53 }
54
55 FUpdate(EScatterOp InOp, uint32 InOffset, uint32 InValue) :
56 Op_Offset(InOffset | (uint32)InOp),
57 Value(InValue)
58 {
59 }
60
61 EScatterOp GetOp() const { return EScatterOp(Op_Offset & 3u); }
62 uint32 GetOffset() const { return Op_Offset & ~3u; }
63 uint32 GetValue() const { return Value; }
64
65 uint32 WriteMask() const
66 {
67 switch (GetOp())
68 {
69 case EScatterOp::Or: return Value;
70 case EScatterOp::And: return ~Value;
71 case EScatterOp::Write: return 0xFFFFFFFFu;
72 default:
73 check(false);
74 return 0xFFFFFFFFu;
75 }
76 }
77 private:
78 uint32 Op_Offset;
80 };
81
82 FHashTable HashTable;
83 TArray<FUpdate> Updates;
84 uint32 HashShift;
85};
86
87} // namespace Nanite
constexpr bool IsAligned(T Val, uint64 Alignment)
Definition AlignmentTemplates.h:50
#define check(expr)
Definition AssertionMacros.h:314
UE_FORCEINLINE_HINT TSharedRef< CastToType, Mode > StaticCastSharedRef(TSharedRef< CastFromType, Mode > const &InSharedRef)
Definition SharedPointer.h:127
uint32 Offset
Definition VulkanMemory.cpp:4033
uint32_t uint32
Definition binka_ue_file_header.h:6
Definition HashTable.h:210
Definition RenderGraphResources.h:1452
Definition RenderGraphBuilder.h:49
Definition NaniteOrderedScatterUpdater.h:23
void ResolveOverwrites(bool bVerify)
Definition NaniteOrderedScatterUpdater.cpp:69
void Add(EScatterOp Op, uint32 Offset, uint32 Value)
Definition NaniteOrderedScatterUpdater.h:27
uint32 Num() const
Definition NaniteOrderedScatterUpdater.h:41
Definition Array.h:670
UE_REWRITE SizeType Num() const
Definition Array.h:1144
UE_NODEBUG UE_FORCEINLINE_HINT SizeType Add(ElementType &&Item)
Definition Array.h:2696
T::FDataType GetValue(const UBlackboardComponent &Blackboard, const FName &Name, FBlackboard::FKey &InOutCachedKey, const typename T::FDataType &DefaultValue)
Definition ValueOrBBKey.h:51
Definition SkinnedMeshComponent.h:50
EScatterOp
Definition NaniteOrderedScatterUpdater.h:15