UDocumentation UE5.7 10.02.2026 (Source)
API documentation for Unreal Engine 5.7
RenderGraphDefinitions.h
Go to the documentation of this file.
1// Copyright Epic Games, Inc. All Rights Reserved.
2
3#pragma once
4
7#include "RenderGraphFwd.h"
8#include "RHIBreadcrumbs.h"
9
13#define RDG_ENABLE_DEBUG (!UE_BUILD_SHIPPING && !UE_BUILD_TEST)
14
16#if RDG_ENABLE_DEBUG
17 #define IF_RDG_ENABLE_DEBUG(Op) Op
18#else
19 #define IF_RDG_ENABLE_DEBUG(Op)
20#endif
21
23#define RDG_ENABLE_DEBUG_WITH_ENGINE (RDG_ENABLE_DEBUG && WITH_ENGINE)
24
26#define RDG_ENABLE_TRACE UE_TRACE_ENABLED && !IS_PROGRAM && !UE_BUILD_SHIPPING
27
28#if RDG_ENABLE_TRACE
29 #define IF_RDG_ENABLE_TRACE(Op) Op
30#else
31 #define IF_RDG_ENABLE_TRACE(Op)
32#endif
33
35#define RDG_DUMP_RESOURCES (WITH_DUMPGPU)
36
42#define RDG_EVENTS_NONE 0
43#define RDG_EVENTS_STRING_REF 1
44#define RDG_EVENTS_STRING_COPY 2
45
47#if WITH_PROFILEGPU
48 #if UE_BUILD_TEST || UE_BUILD_SHIPPING
49 #define RDG_EVENTS RDG_EVENTS_STRING_REF
50 #else
51 #define RDG_EVENTS RDG_EVENTS_STRING_COPY
52 #endif
53#elif WITH_RHI_BREADCRUMBS
54 #define RDG_EVENTS RDG_EVENTS_STRING_REF
55#else
56 #define RDG_EVENTS RDG_EVENTS_NONE
57#endif
58
59#define SUPPORTS_VISUALIZE_TEXTURE (WITH_ENGINE && (!UE_BUILD_SHIPPING || WITH_EDITOR))
60
104
108{
109 None = 0,
110
112 ParallelSetup = 1 << 0,
113
115 ParallelCompile = 1 << 1,
116
118 ParallelExecute = 1 << 2,
119
121
122 AllowParallelExecute UE_DEPRECATED(5.5, "Use ERDDGBuilderFlags::Parallel instead.") = Parallel,
123};
125
128{
130 None = 0,
131
133 Raster = 1 << 0,
134
136 Compute = 1 << 1,
137
139 AsyncCompute = 1 << 2,
140
142 Copy = 1 << 3,
143
145 NeverCull = 1 << 4,
146
148 SkipRenderPass = 1 << 5,
149
151 NeverMerge = 1 << 6,
152
154 NeverParallel = 1 << 7,
155
158};
160
163{
164 None = 0,
165
167 MultiFrame = 1 << 0,
168
174 SkipTracking = 1 << 1,
175
180};
182
185{
186 None = 0,
187
189 MultiFrame = 1 << 0,
190
196 SkipTracking = 1 << 1,
197
202
204 MaintainCompression = 1 << 3,
205};
207
209{
211 Compile = 0,
212
214 Execute = 1,
215
216 MAX
217};
218
221{
222 None = 0,
223
224 // The view will not perform UAV barriers between consecutive usage.
225 SkipBarrier = 1 << 0
226};
228
231{
232 Texture,
233 Buffer,
234 MAX
235};
236
238enum class ERDGViewType : uint8
239{
242 BufferUAV,
243 BufferSRV,
244 MAX
245};
246
261
263{
264 None = 0,
265
266 // Allows the resource to remain transient. Only use this flag if you intend to register the resource back
267 // into the graph and release the reference. This should not be used if the resource is cached for a long
268 // period of time.
269 AllowTransient = 1,
270};
272
274{
278 None = 0,
279
285 NoCopy = 1 << 0
286};
288
290{
291 // The buffer size is not aligned.
292 None,
293
294 // The buffer size is aligned up to the next page size.
295 Page,
296
297 // The buffer size is aligned up to the next power of two.
299};
300
317
319
322{
323 switch (Metadata)
324 {
325 case ERDGTextureMetaDataAccess::CompressedSurface:
326 case ERDGTextureMetaDataAccess::HTile:
327 case ERDGTextureMetaDataAccess::Depth:
329 case ERDGTextureMetaDataAccess::Stencil:
331 default:
332 return 0;
333 }
334}
335
339// Disable false positive buffer overrun warning during pgo linking step
341template <typename LocalObjectType, typename LocalIndexType>
343{
344public:
347
348 static const TRDGHandle Null;
349
350 TRDGHandle() = default;
351
352 explicit inline TRDGHandle(uint32 InIndex)
353 {
354 check(InIndex >= 0 && InIndex <= kNullIndex);
356 }
357
358 inline IndexType GetIndex() const { check(IsValid()); return Index; }
359 inline IndexType GetIndexUnchecked() const { return Index; }
360 inline bool IsNull() const { return Index == kNullIndex; }
361 inline bool IsValid() const { return Index != kNullIndex; }
362 inline bool operator==(TRDGHandle Other) const { return Index == Other.Index; }
363 inline bool operator!=(TRDGHandle Other) const { return Index != Other.Index; }
364 inline bool operator<=(TRDGHandle Other) const { check(IsValid() && Other.IsValid()); return Index <= Other.Index; }
365 inline bool operator>=(TRDGHandle Other) const { check(IsValid() && Other.IsValid()); return Index >= Other.Index; }
366 inline bool operator< (TRDGHandle Other) const { check(IsValid() && Other.IsValid()); return Index < Other.Index; }
367 inline bool operator> (TRDGHandle Other) const { check(IsValid() && Other.IsValid()); return Index > Other.Index; }
368
369 inline TRDGHandle& operator+=(int32 Increment)
370 {
371 check(int64(Index + Increment) <= int64(kNullIndex));
372 Index += (IndexType)Increment;
373 return *this;
374 }
375
376 inline TRDGHandle& operator-=(int32 Decrement)
377 {
378 check(int64(Index - Decrement) > 0);
379 Index -= (IndexType)Decrement;
380 return *this;
381 }
382
384 {
385 TRDGHandle Handle = *this;
386 Handle -= Subtract;
387 return Handle;
388 }
389
391 {
392 TRDGHandle Handle = *this;
393 Handle += Add;
394 return Handle;
395 }
396
398 {
399 check(IsValid());
400 ++Index;
401 return *this;
402 }
403
405 {
406 check(IsValid());
407 --Index;
408 return *this;
409 }
410
411 // Returns the min of two pass handles. Returns null if both are null; returns the valid handle if one is null.
413 {
414 // If either index is null is will fail the comparison.
415 return A.Index < B.Index ? A : B;
416 }
417
418 // Returns the max of two pass handles. Returns null if both are null; returns the valid handle if one is null.
420 {
421 // If either index is null, it will wrap around to 0 and fail the comparison.
422 return (IndexType)(A.Index + 1) > (IndexType)(B.Index + 1) ? A : B;
423 }
424
425private:
426 static const IndexType kNullIndex = TNumericLimits<IndexType>::Max();
427 IndexType Index = kNullIndex;
428
430 {
431 return Handle.GetIndex();
432 }
433};
435
437{
438 Registry,
439 Allocator,
440 Never
441};
442
444template <typename LocalHandleType, ERDGHandleRegistryDestructPolicy DestructPolicy = ERDGHandleRegistryDestructPolicy::Registry>
446{
447public:
449 using ObjectType = typename HandleType::ObjectType;
450 using IndexType = typename HandleType::IndexType;
451
457
459 {
460 Clear();
461 }
462
464 {
465 Array.Emplace(Object);
466 Object->Handle = Last();
467 }
468
469 template<typename DerivedType = ObjectType, class ...TArgs>
470 DerivedType* Allocate(FRDGAllocator& Allocator, TArgs&&... Args)
471 {
472 static_assert(TIsDerivedFrom<DerivedType, ObjectType>::Value, "You must specify a type that derives from ObjectType");
473 DerivedType* Object;
475 {
476 Object = Allocator.Alloc<DerivedType>(Forward<TArgs>(Args)...);
477 }
478 else
479 {
480 Object = Allocator.AllocNoDestruct<DerivedType>(Forward<TArgs>(Args)...);
481 }
482 Insert(Object);
483 return Object;
484 }
485
486 void Clear()
487 {
489 {
490 for (int32 Index = Array.Num() - 1; Index >= 0; --Index)
491 {
492 Array[Index]->~ObjectType();
493 }
494 }
495 Array.Empty();
496 }
497
498 template <typename FunctionType>
499 void Enumerate(FunctionType Function)
500 {
501 for (ObjectType* Object : Array)
502 {
504 }
505 }
506
507 template <typename FunctionType>
508 void Enumerate(FunctionType Function) const
509 {
510 for (const ObjectType* Object : Array)
511 {
513 }
514 }
515
516 inline const ObjectType* Get(HandleType Handle) const
517 {
518 return Array[Handle.GetIndex()];
519 }
520
522 {
523 return Array[Handle.GetIndex()];
524 }
525
527 {
528 return Get(Handle);
529 }
530
532 {
533 return Get(Handle);
534 }
535
536 inline HandleType Begin() const
537 {
538 return HandleType(0);
539 }
540
541 inline HandleType End() const
542 {
543 return HandleType(Array.Num());
544 }
545
546 inline HandleType Last() const
547 {
548 return HandleType(Array.Num() - 1);
549 }
550
551 inline int32 Num() const
552 {
553 return Array.Num();
554 }
555
556private:
558};
559
561template <typename HandleType>
562class TRDGHandleBitArray : public TBitArray<FRDGBitArrayAllocator>
563{
565public:
566 using Base::Base;
567
568 inline FBitReference operator[](HandleType Handle)
569 {
570 return Base::operator[](Handle.GetIndex());
571 }
572
573 inline const FConstBitReference operator[](HandleType Handle) const
574 {
575 return Base::operator[](Handle.GetIndex());
576 }
577};
578
584template <typename HandleType>
586{
587public:
589
591 {
593 }
594
595 void Reset()
596 {
597 Handle = HandleType::Null;
598 }
599
600 void AddHandle(HandleType InHandle)
601 {
602 checkf(InHandle != NotUniqueHandle, TEXT("Overflowed TRDGHandleUniqueFilter"));
603
604 if (Handle != InHandle && InHandle.IsValid())
605 {
606 Handle = Handle.IsNull() ? InHandle : NotUniqueHandle;
607 }
608 }
609
610 HandleType GetUniqueHandle() const
611 {
612 return Handle != NotUniqueHandle ? Handle : HandleType::Null;
613 }
614
615private:
616 static const HandleType NotUniqueHandle;
617 HandleType Handle;
618};
619
620template <typename ObjectType, typename IndexType>
622
623template <typename HandleType>
625
627{
642
657
663 , uint8 NumMips = 1
664 , uint32 ExtData = 0
665 )
666 {
667 const uint16 ArraySize = 1;
668 const uint8 LocalNumSamples = 1;
669
670 checkf(Size.Z <= TNumericLimits<decltype(FRDGTextureDesc::Depth)>::Max(), TEXT("Depth parameter (Size.Z) exceeds valid range"));
671
673 }
674
680 , uint8 NumMips = 1
681 , uint8 NumSamples = 1
682 , uint32 ExtData = 0
683 )
684 {
685 checkf(Size <= (uint32)TNumericLimits<int32>::Max(), TEXT("Size parameter exceeds valid range"));
686
687 const uint16 Depth = 1;
688 const uint16 ArraySize = 1;
690 }
691
708
713 , const bool bRequireMultiView
714 , uint16 MobileMultiViewRenderTargetNumLayers = 2)
715 {
716 if (bRequireMultiView)
717 {
718 return FRDGTextureDesc::Create2DArray(Size, Format, ClearValue, Flags, MobileMultiViewRenderTargetNumLayers);
719 }
720
722 }
723
724 FRDGTextureDesc() = default;
740};
741
744class FRDGBlackboard;
745
747class FRDGScopedCsvStatExclusive;
748class FRDGScopedCsvStatExclusiveConditional;
749
750class FRDGBarrierBatch;
754class FRDGEventName;
756
758
763
767
772
776
781
782class FRDGBufferPool;
784
787
788class FRDGTrace;
789class FRDGResourceDumpContext;
790
794template <typename ArrayType,
795 typename ArrayTypeNoRef = std::remove_reference_t<ArrayType>,
796 typename = typename TEnableIf<TIsTArray_V<ArrayTypeNoRef>>::Type> using TRDGBufferArrayCallback = TFunction<const ArrayType&()>;
OODEFFUNC typedef void(OODLE_CALLBACK t_fp_OodleCore_Plugin_Free)(void *ptr)
#define check(expr)
Definition AssertionMacros.h:314
#define checkNoEntry()
Definition AssertionMacros.h:316
#define checkf(expr, format,...)
Definition AssertionMacros.h:315
#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
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 ENUM_CLASS_FLAGS(Enum)
Definition EnumClassFlags.h:6
#define PGO_LINK_DISABLE_WARNINGS
Definition GenericPlatformCompilerPreSetup.h:71
#define PGO_LINK_ENABLE_WARNINGS
Definition GenericPlatformCompilerPreSetup.h:75
FInt32Vector3 FIntVector
Definition MathFwd.h:115
EPixelFormat
Definition PixelFormat.h:16
ETextureDimension
Definition RHIDefinitions.h:1081
ETextureCreateFlags
Definition RHIDefinitions.h:1091
ERHITexturePlane
Definition RHIResources.h:2574
ERHITexturePlane ERHITextureMetaDataAccess
Definition RHIResources.h:2608
ERDGViewableResourceType GetParentType(ERDGViewType ViewType)
Definition RenderGraphDefinitions.h:247
ERDGTextureFlags
Definition RenderGraphDefinitions.h:185
ERDGHandleRegistryDestructPolicy
Definition RenderGraphDefinitions.h:437
ERDGPassFlags
Definition RenderGraphDefinitions.h:128
ERDGViewableResourceType
Definition RenderGraphDefinitions.h:231
ERDGViewType
Definition RenderGraphDefinitions.h:239
ERDGBufferFlags
Definition RenderGraphDefinitions.h:163
ERDGUnorderedAccessViewFlags
Definition RenderGraphDefinitions.h:221
ERDGPooledBufferAlignment
Definition RenderGraphDefinitions.h:290
ERDGSetupTaskWaitPoint
Definition RenderGraphDefinitions.h:209
int32 GetResourceTransitionPlaneForMetadataAccess(ERDGTextureMetaDataAccess Metadata)
Definition RenderGraphDefinitions.h:321
ERDGResourceExtractionFlags
Definition RenderGraphDefinitions.h:263
ERDGInitialDataFlags
Definition RenderGraphDefinitions.h:274
ERDGViewableResourceType GetViewableResourceType(ERDGViewType ViewType)
Definition RenderGraphDefinitions.h:302
ERDGBuilderFlags
Definition RenderGraphDefinitions.h:108
uint32 Size
Definition VulkanMemory.cpp:4034
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 BitArray.h:189
Definition BitArray.h:260
Definition RenderGraphAllocator.h:24
Definition RenderGraphBuilder.h:1182
Definition RenderGraphPass.h:108
Definition RenderGraphPass.h:185
Definition RenderGraphValidation.h:154
Definition RenderGraphBlackboard.h:57
Definition RenderGraphResourcePool.h:15
Definition RenderGraphEvent.h:38
Definition RenderGraphResourcePool.h:77
Definition RenderGraphValidation.h:41
Definition RenderGraphResources.h:291
Definition Array.h:670
Definition BitArray.h:350
UE_FORCEINLINE_HINT FBitReference operator[](int32 Index)
Definition BitArray.h:1468
Definition EnableIf.h:20
Definition AndroidPlatformMisc.h:14
Definition RenderGraphDefinitions.h:563
const FConstBitReference operator[](HandleType Handle) const
Definition RenderGraphDefinitions.h:573
FBitReference operator[](HandleType Handle)
Definition RenderGraphDefinitions.h:568
Definition RenderGraphDefinitions.h:446
~TRDGHandleRegistry()
Definition RenderGraphDefinitions.h:458
HandleType Begin() const
Definition RenderGraphDefinitions.h:536
TRDGHandleRegistry(const TRDGHandleRegistry &)=delete
TRDGHandleRegistry(TRDGHandleRegistry &&)=default
void Enumerate(FunctionType Function)
Definition RenderGraphDefinitions.h:499
HandleType End() const
Definition RenderGraphDefinitions.h:541
HandleType Last() const
Definition RenderGraphDefinitions.h:546
typename HandleType::ObjectType ObjectType
Definition RenderGraphDefinitions.h:449
LocalHandleType HandleType
Definition RenderGraphDefinitions.h:448
ObjectType * Get(HandleType Handle)
Definition RenderGraphDefinitions.h:521
typename HandleType::IndexType IndexType
Definition RenderGraphDefinitions.h:450
TRDGHandleRegistry & operator=(TRDGHandleRegistry &&)=default
int32 Num() const
Definition RenderGraphDefinitions.h:551
void Enumerate(FunctionType Function) const
Definition RenderGraphDefinitions.h:508
TRDGHandleRegistry()=default
DerivedType * Allocate(FRDGAllocator &Allocator, TArgs &&... Args)
Definition RenderGraphDefinitions.h:470
TRDGHandleRegistry & operator=(const TRDGHandleRegistry &)=delete
void Insert(ObjectType *Object)
Definition RenderGraphDefinitions.h:463
const ObjectType * Get(HandleType Handle) const
Definition RenderGraphDefinitions.h:516
const ObjectType * operator[](HandleType Handle) const
Definition RenderGraphDefinitions.h:526
void Clear()
Definition RenderGraphDefinitions.h:486
Definition RenderGraphDefinitions.h:586
TRDGHandleUniqueFilter(HandleType InHandle)
Definition RenderGraphDefinitions.h:590
void Reset()
Definition RenderGraphDefinitions.h:595
TRDGHandleUniqueFilter()=default
void AddHandle(HandleType InHandle)
Definition RenderGraphDefinitions.h:600
HandleType GetUniqueHandle() const
Definition RenderGraphDefinitions.h:610
Definition RenderGraphDefinitions.h:343
bool IsValid() const
Definition RenderGraphDefinitions.h:361
bool IsNull() const
Definition RenderGraphDefinitions.h:360
TRDGHandle operator-(int32 Subtract) const
Definition RenderGraphDefinitions.h:383
LocalObjectType ObjectType
Definition RenderGraphDefinitions.h:345
bool operator<(TRDGHandle Other) const
Definition RenderGraphDefinitions.h:366
TRDGHandle & operator-=(int32 Decrement)
Definition RenderGraphDefinitions.h:376
static TRDGHandle Min(TRDGHandle A, TRDGHandle B)
Definition RenderGraphDefinitions.h:412
LocalIndexType IndexType
Definition RenderGraphDefinitions.h:346
TRDGHandle & operator++()
Definition RenderGraphDefinitions.h:397
bool operator!=(TRDGHandle Other) const
Definition RenderGraphDefinitions.h:363
TRDGHandle(uint32 InIndex)
Definition RenderGraphDefinitions.h:352
TRDGHandle operator+(int32 Add) const
Definition RenderGraphDefinitions.h:390
static const TRDGHandle Null
Definition RenderGraphDefinitions.h:348
TRDGHandle & operator+=(int32 Increment)
Definition RenderGraphDefinitions.h:369
bool operator>=(TRDGHandle Other) const
Definition RenderGraphDefinitions.h:365
static TRDGHandle Max(TRDGHandle A, TRDGHandle B)
Definition RenderGraphDefinitions.h:419
bool operator>(TRDGHandle Other) const
Definition RenderGraphDefinitions.h:367
TRDGHandle()=default
bool operator<=(TRDGHandle Other) const
Definition RenderGraphDefinitions.h:364
bool operator==(TRDGHandle Other) const
Definition RenderGraphDefinitions.h:362
TRDGHandle & operator--()
Definition RenderGraphDefinitions.h:404
IndexType GetIndexUnchecked() const
Definition RenderGraphDefinitions.h:359
friend uint32 GetTypeHash(TRDGHandle Handle)
Definition RenderGraphDefinitions.h:429
IndexType GetIndex() const
Definition RenderGraphDefinitions.h:358
U16 Index
Definition radfft.cpp:71
Definition RHIResources.h:246
Definition RenderGraphDefinitions.h:103
Definition RenderGraphDefinitions.h:627
static FRDGTextureDesc Create2DArray(FIntPoint Size, EPixelFormat Format, FClearValueBinding ClearValue, ETextureCreateFlags Flags, uint16 ArraySize, uint8 NumMips=1, uint8 NumSamples=1, uint32 ExtData=0)
Definition RenderGraphDefinitions.h:643
static FRDGTextureDesc Create3D(FIntVector Size, EPixelFormat Format, FClearValueBinding ClearValue, ETextureCreateFlags Flags, uint8 NumMips=1, uint32 ExtData=0)
Definition RenderGraphDefinitions.h:658
static FRDGTextureDesc CreateCube(uint32 Size, EPixelFormat Format, FClearValueBinding ClearValue, ETextureCreateFlags Flags, uint8 NumMips=1, uint8 NumSamples=1, uint32 ExtData=0)
Definition RenderGraphDefinitions.h:675
static FRDGTextureDesc CreateCubeArray(uint32 Size, EPixelFormat Format, FClearValueBinding ClearValue, ETextureCreateFlags Flags, uint16 ArraySize, uint8 NumMips=1, uint8 NumSamples=1, uint32 ExtData=0)
Definition RenderGraphDefinitions.h:692
FRDGTextureDesc(ETextureDimension InDimension, ETextureCreateFlags InFlags, EPixelFormat InFormat, FClearValueBinding InClearValue, FIntPoint InExtent, uint16 InDepth, uint16 InArraySize, uint8 InNumMips, uint8 InNumSamples, uint32 InExtData)
Definition RenderGraphDefinitions.h:725
FRDGTextureDesc()=default
static FRDGTextureDesc Create2D(FIntPoint Size, EPixelFormat Format, FClearValueBinding ClearValue, ETextureCreateFlags Flags, uint8 NumMips=1, uint8 NumSamples=1, uint32 ExtData=0)
Definition RenderGraphDefinitions.h:628
static FRDGTextureDesc CreateRenderTargetTextureDesc(FIntPoint Size, EPixelFormat Format, FClearValueBinding ClearValue, ETextureCreateFlags Flags, const bool bRequireMultiView, uint16 MobileMultiViewRenderTargetNumLayers=2)
Definition RenderGraphDefinitions.h:709
static const uint16 kStencilPlaneSlice
Definition RHITransition.h:23
static const uint16 kDepthPlaneSlice
Definition RHITransition.h:22
Definition RHIResources.h:1689
uint16 Depth
Definition RHIResources.h:1859
EPixelFormat Format
Definition RHIResources.h:1874
ETextureCreateFlags Flags
Definition RHIResources.h:1844
uint32 ExtData
Definition RHIResources.h:1853
uint16 ArraySize
Definition RHIResources.h:1862
uint8 NumMips
Definition RHIResources.h:1865
FClearValueBinding ClearValue
Definition RHIResources.h:1847
uint8 NumSamples
Definition RHIResources.h:1868
Definition UnrealTypeTraits.h:40
Definition NumericLimits.h:41
Definition IntPoint.h:25