You've already forked UnrealEngineUWP
mirror of
https://github.com/izzy2lost/UnrealEngineUWP.git
synced 2026-03-26 18:15:20 -07:00
- New RHI command list SetTrackedAccess method for the user to supply a current whole-resource state.
- New RHI command context GetTrackedAccess method for querying the tracked access in RHIBeginTransitions / RHIEndTransitions on the RHI thread.
- Hooked RHICmdList.Transition and FRHICommandListExecutor::Transition to assign tracked state automatically.
- Refactored RDG and resource pools to use new RHI tracking.
- FRDGPooledBuffer / FRDGPooledTexture no longer contain tracked state. RDG temp-allocates state through the graph allocator instead.
- All prologue transitions are 'Unknown', and all epilogue transitions coalesce into a whole resource state.
- Implemented platform support for patching the 'before' state with the tracked state.
- Implemented various RHI validation checks:
- Asserts that the user assigned tracked state matches RHI validation tracked state, for all subresources.
- Asserts that tracked state is not assigned or queried from a parallel translation context.
- Added FRHIViewableResource and FRHIView base classes to RHI. FRHIView contains a pointer to an FRHIViewableResource. This is currently a raw pointer, but should be extended to a full reference in a later CL.
NOTE on RHI thread constraint:
Transition evaluation is now restricted to the RHI thread (i.e. no parallel translation contexts). Transitions aren't performed in parallel translate contexts anyway, so this is not a problem. If, however, we decide to refactor parallel translation to be more general, this implementation could be extended to track the state per context and update from the 'dispatch' thread.
#preflight 6233b4396666d7e753a16aaf
#rb kenzo.terelst
[CL 19513316 by zach bethel in ue5-main branch]
113 lines
3.1 KiB
C++
113 lines
3.1 KiB
C++
// Copyright Epic Games, Inc. All Rights Reserved.
|
|
|
|
/*=============================================================================
|
|
RenderTargetPool.h: Scene render target pool manager.
|
|
=============================================================================*/
|
|
|
|
#pragma once
|
|
|
|
#include "CoreMinimal.h"
|
|
#include "RHI.h"
|
|
#include "RenderResource.h"
|
|
#include "RendererInterface.h"
|
|
#include "RenderGraphResources.h"
|
|
|
|
class RENDERCORE_API FRDGBufferPool : public FRenderResource
|
|
{
|
|
public:
|
|
FRDGBufferPool() = default;
|
|
|
|
/** Call once per frame to trim elements from the pool. */
|
|
void TickPoolElements();
|
|
|
|
/** Allocate a buffer from a given descriptor. */
|
|
TRefCountPtr<FRDGPooledBuffer> FindFreeBuffer(FRHICommandList& RHICmdList, const FRDGBufferDesc& Desc, const TCHAR* InDebugName);
|
|
|
|
private:
|
|
void ReleaseDynamicRHI() override;
|
|
|
|
/** Elements can be 0, we compact the buffer later. */
|
|
TArray<TRefCountPtr<FRDGPooledBuffer>> AllocatedBuffers;
|
|
TArray<uint64> AllocatedBufferHashes;
|
|
|
|
uint32 FrameCounter = 0;
|
|
|
|
friend class FRDGBuilder;
|
|
};
|
|
|
|
/** The global render targets for easy shading. */
|
|
extern RENDERCORE_API TGlobalResource<FRDGBufferPool> GRenderGraphResourcePool;
|
|
|
|
enum class ERDGTransientResourceLifetimeState
|
|
{
|
|
Deallocated,
|
|
Allocated,
|
|
PendingDeallocation
|
|
};
|
|
|
|
class FRDGTransientRenderTarget final : public IPooledRenderTarget
|
|
{
|
|
public:
|
|
uint32 AddRef() const override;
|
|
uint32 Release() override;
|
|
uint32 GetRefCount() const override { return RefCount; }
|
|
|
|
bool IsFree() const override { return false; }
|
|
bool IsTracked() const override { return true; }
|
|
uint32 ComputeMemorySize() const override { return 0; }
|
|
|
|
const FPooledRenderTargetDesc& GetDesc() const override { return Desc; }
|
|
|
|
FRHITransientTexture* GetTransientTexture() const override
|
|
{
|
|
check(LifetimeState == ERDGTransientResourceLifetimeState::Allocated);
|
|
return Texture;
|
|
}
|
|
|
|
void Reset()
|
|
{
|
|
Texture = nullptr;
|
|
RenderTargetItem.ShaderResourceTexture = nullptr;
|
|
RenderTargetItem.TargetableTexture = nullptr;
|
|
}
|
|
|
|
private:
|
|
FRDGTransientRenderTarget() = default;
|
|
|
|
FRHITransientTexture* Texture;
|
|
FPooledRenderTargetDesc Desc;
|
|
ERDGTransientResourceLifetimeState LifetimeState;
|
|
mutable uint32 RefCount = 0;
|
|
|
|
friend class FRDGTransientResourceAllocator;
|
|
};
|
|
|
|
class FRDGTransientResourceAllocator : public FRenderResource
|
|
{
|
|
public:
|
|
IRHITransientResourceAllocator* Get() { return Allocator; }
|
|
|
|
TRefCountPtr<FRDGTransientRenderTarget> AllocateRenderTarget(FRHITransientTexture* Texture);
|
|
|
|
void Release(TRefCountPtr<FRDGTransientRenderTarget>&& RenderTarget, FRDGPassHandle PassHandle);
|
|
|
|
void ReleasePendingDeallocations();
|
|
|
|
bool IsValid() const { return Allocator != nullptr; }
|
|
|
|
private:
|
|
void InitDynamicRHI() override;
|
|
void ReleaseDynamicRHI() override;
|
|
|
|
void AddPendingDeallocation(FRDGTransientRenderTarget* RenderTarget);
|
|
|
|
IRHITransientResourceAllocator* Allocator = nullptr;
|
|
|
|
TArray<FRDGTransientRenderTarget*> FreeList;
|
|
TArray<FRDGTransientRenderTarget*> PendingDeallocationList;
|
|
TArray<FRDGTransientRenderTarget*> DeallocatedList;
|
|
|
|
friend class FRDGTransientRenderTarget;
|
|
};
|
|
|
|
extern RENDERCORE_API TGlobalResource<FRDGTransientResourceAllocator> GRDGTransientResourceAllocator; |