UDocumentation UE5.7 10.02.2026 (Source)
API documentation for Unreal Engine 5.7
RenderGraphResourcePool.h
Go to the documentation of this file.
1// Copyright Epic Games, Inc. All Rights Reserved.
2
3/*=============================================================================
4 RenderTargetPool.h: Scene render target pool manager.
5=============================================================================*/
6
7#pragma once
8
9#include "RenderResource.h"
10#include "RendererInterface.h"
13
15{
16public:
17 FRDGBufferPool() = default;
18
21
23
28
30
31private:
32 RENDERCORE_API void ReleaseRHI() override;
33
34 FRDGPooledBuffer* CreateBuffer(FRHICommandListBase& RHICmdList, const FRDGBufferDesc& Desc, uint32 DescHash, const TCHAR* InDebugName);
35
36 FRDGPooledBuffer* ScheduleAllocation(
37 FRHICommandListBase& RHICmdList,
38 const FRDGBufferDesc& Desc,
39 const TCHAR* Name,
41 const FRHITransientAllocationFences& Fences);
42
43 void ScheduleDeallocation(FRDGPooledBuffer* PooledBuffer, const FRHITransientAllocationFences& Fences);
44
45 void FinishSchedule(FRHICommandListBase& RHICmdList, FRDGPooledBuffer* PooledBuffer);
46
47 template <typename T>
48 FRDGPooledBuffer* TryFindPooledBuffer(const FRDGBufferDesc& Desc, uint32 DescHash, T&& Predicate);
49
50 FRDGPooledBuffer* TryFindPooledBuffer(const FRDGBufferDesc& Desc, uint32 DescHash)
51 {
52 return TryFindPooledBuffer(Desc, DescHash, [](FRDGPooledBuffer*) { return true; });
53 }
54
55 mutable UE::FRecursiveMutex Mutex;
56
59 TArray<uint32> AllocatedBufferHashes;
60
61 uint32 FrameCounter = 0;
62
63 friend class FRDGBuilder;
64};
65
68
75
77{
78public:
79 uint32 AddRef() const override;
80 uint32 Release() override;
81 uint32 GetRefCount() const override { return RefCount; }
82
83 bool IsFree() const override { return false; }
84 bool IsTracked() const override { return true; }
85 uint32 ComputeMemorySize() const override { return 0; }
86
87 const FPooledRenderTargetDesc& GetDesc() const override { return Desc; }
88
90 {
92 return Texture;
93 }
94
95 void Reset()
96 {
97 Texture = nullptr;
100 }
101
102private:
103 FRDGTransientRenderTarget() = default;
104
105 FRHITransientTexture* Texture;
108 mutable int32 RefCount = 0;
109
111};
112
114{
115public:
116 IRHITransientResourceAllocator* Get() { return Allocator; }
117
119
121
123
124 bool IsValid() const { return Allocator != nullptr; }
125
126private:
127 void InitRHI(FRHICommandListBase& RHICmdList) override;
128 void ReleaseRHI() override;
129
130 void AddPendingDeallocation(FRDGTransientRenderTarget* RenderTarget);
131
132 IRHITransientResourceAllocator* Allocator = nullptr;
133
136 TArray<FRDGTransientRenderTarget*> PendingDeallocationList;
138
140};
141
#define check(expr)
Definition AssertionMacros.h:314
FPlatformTypes::TCHAR TCHAR
Either ANSICHAR or WIDECHAR, depending on whether the platform supports wide characters or the requir...
Definition Platform.h:1135
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
UE::FPlatformRecursiveMutex FCriticalSection
Definition CriticalSection.h:53
ERDGPooledBufferAlignment
Definition RenderGraphDefinitions.h:290
RENDERCORE_API TGlobalResource< FRDGBufferPool > GRenderGraphResourcePool
Definition RenderGraphResourcePool.cpp:253
RENDERCORE_API TGlobalResource< FRDGTransientResourceAllocator, FRenderResource::EInitPhase::Pre > GRDGTransientResourceAllocator
Definition RenderGraphResourcePool.cpp:415
ERDGTransientResourceLifetimeState
Definition RenderGraphResourcePool.h:70
uint32_t uint32
Definition binka_ue_file_header.h:6
Definition OutputDevice.h:133
Definition RenderGraphResourcePool.h:15
RENDERCORE_API void DumpMemoryUsage(FOutputDevice &OutputDevice)
Definition RenderGraphResourcePool.cpp:57
FRDGBufferPool()=default
RENDERCORE_API TRefCountPtr< FRDGPooledBuffer > FindFreeBuffer(FRHICommandListBase &RHICmdList, const FRDGBufferDesc &Desc, const TCHAR *InDebugName, ERDGPooledBufferAlignment Alignment=ERDGPooledBufferAlignment::Page)
Definition RenderGraphResourcePool.cpp:148
TRefCountPtr< FRDGPooledBuffer > FindFreeBuffer(const FRDGBufferDesc &Desc, const TCHAR *InDebugName, ERDGPooledBufferAlignment Alignment=ERDGPooledBufferAlignment::Page)
Definition RenderGraphResourcePool.h:24
RENDERCORE_API void TickPoolElements()
Definition RenderGraphResourcePool.cpp:212
Definition RenderGraphBuilder.h:49
Definition RenderGraphResources.h:1196
Definition RenderGraphResourcePool.h:77
const FPooledRenderTargetDesc & GetDesc() const override
Definition RenderGraphResourcePool.h:87
uint32 Release() override
Definition RenderGraphResourcePool.cpp:261
bool IsTracked() const override
Definition RenderGraphResourcePool.h:84
uint32 GetRefCount() const override
Definition RenderGraphResourcePool.h:81
bool IsFree() const override
Definition RenderGraphResourcePool.h:83
uint32 AddRef() const override
Definition RenderGraphResourcePool.cpp:255
FRHITransientTexture * GetTransientTexture() const override
Definition RenderGraphResourcePool.h:89
uint32 ComputeMemorySize() const override
Definition RenderGraphResourcePool.h:85
void Reset()
Definition RenderGraphResourcePool.h:95
Definition RenderGraphResourcePool.h:114
bool IsValid() const
Definition RenderGraphResourcePool.h:124
TRefCountPtr< FRDGTransientRenderTarget > AllocateRenderTarget(FRHITransientTexture *Texture)
Definition RenderGraphResourcePool.cpp:311
void ReleasePendingDeallocations()
Definition RenderGraphResourcePool.cpp:368
IRHITransientResourceAllocator * Get()
Definition RenderGraphResourcePool.h:116
Definition RHICommandList.h:455
static FRHICommandListImmediate & Get()
Definition RHICommandList.h:5522
Definition RHITransientResourceAllocator.h:23
Definition RHITransientResourceAllocator.h:399
Definition RenderResource.h:37
Definition RHITransientResourceAllocator.h:536
Definition Array.h:670
Definition RenderResource.h:543
Definition RefCounting.h:454
Definition RecursiveMutex.h:19
Definition RendererInterface.h:81
Definition RenderGraphResources.h:940
FTextureRHIRef ShaderResourceTexture
Definition RendererInterface.h:484
FTextureRHIRef TargetableTexture
Definition RendererInterface.h:481
Definition RendererInterface.h:494
FSceneRenderTargetItem RenderTargetItem
Definition RendererInterface.h:524