2019-12-26 14:45:42 -05:00
|
|
|
// Copyright Epic Games, Inc. All Rights Reserved.
|
2018-10-22 23:01:29 -04:00
|
|
|
|
|
|
|
|
/*=============================================================================
|
|
|
|
|
RenderTargetPool.h: Scene render target pool manager.
|
|
|
|
|
=============================================================================*/
|
|
|
|
|
|
|
|
|
|
#pragma once
|
|
|
|
|
|
|
|
|
|
#include "CoreMinimal.h"
|
|
|
|
|
#include "RHI.h"
|
|
|
|
|
#include "RenderResource.h"
|
|
|
|
|
#include "RendererInterface.h"
|
|
|
|
|
#include "RenderGraphResources.h"
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* Pools all resources for the render graph.
|
|
|
|
|
*/
|
|
|
|
|
class RENDERCORE_API FRenderGraphResourcePool : public FRenderResource
|
|
|
|
|
{
|
|
|
|
|
public:
|
|
|
|
|
FRenderGraphResourcePool();
|
|
|
|
|
|
|
|
|
|
/** Free renderer resources */
|
|
|
|
|
virtual void ReleaseDynamicRHI() override;
|
|
|
|
|
|
2019-07-09 17:22:17 -04:00
|
|
|
/** Call once per frame to trim elements from the pool. */
|
|
|
|
|
void TickPoolElements();
|
2018-10-22 23:01:29 -04:00
|
|
|
|
2020-09-24 00:43:27 -04:00
|
|
|
/** Allocate a buffer from a given descriptor. */
|
|
|
|
|
TRefCountPtr<FRDGPooledBuffer> FindFreeBuffer(FRHICommandList& RHICmdList, const FRDGBufferDesc& Desc, const TCHAR* InDebugName);
|
|
|
|
|
|
2018-10-22 23:01:29 -04:00
|
|
|
private:
|
2020-09-24 00:43:27 -04:00
|
|
|
/** Allocate a buffer from a given descriptor. */
|
|
|
|
|
TRefCountPtr<FRDGPooledBuffer> FindFreeBufferInternal(FRHICommandList& RHICmdList, const FRDGBufferDesc& Desc, const TCHAR* InDebugName);
|
|
|
|
|
|
2018-10-22 23:01:29 -04:00
|
|
|
/** Elements can be 0, we compact the buffer later. */
|
2020-09-24 00:43:27 -04:00
|
|
|
TArray<TRefCountPtr<FRDGPooledBuffer>> AllocatedBuffers;
|
2021-05-05 11:58:15 -04:00
|
|
|
TArray<uint64> AllocatedBufferHashes;
|
2019-07-09 17:22:17 -04:00
|
|
|
|
|
|
|
|
uint32 FrameCounter = 0;
|
2020-09-24 00:43:27 -04:00
|
|
|
|
|
|
|
|
friend class FRDGBuilder;
|
2018-10-22 23:01:29 -04:00
|
|
|
};
|
|
|
|
|
|
|
|
|
|
/** The global render targets for easy shading. */
|
|
|
|
|
extern RENDERCORE_API TGlobalResource<FRenderGraphResourcePool> GRenderGraphResourcePool;
|