Files
UnrealEngineUWP/Engine/Source/Runtime/Renderer/Public/RayTracingDynamicGeometryCollection.h
kenzo terelst dfd7e456e0 - Add Cvar to set the raytracing dynamic geometry shared vertex buffer size and changed default from 16MB to 4MB
- Add garbage collection on unused shared vertex buffers for 30 updates (cvar tweakable)

#preflight 615ed9587abac300014264bf
#rb Yuriy.ODonnell
#lockdown Michal.Valient

#ROBOMERGE-AUTHOR: kenzo.terelst
#ROBOMERGE-SOURCE: CL 17838144 via CL 18003418 via CL 18369457 via CL 18369538
#ROBOMERGE-BOT: STARSHIP (Release-Engine-Staging -> Release-Engine-Test) (v895-18170469)

[CL 18369589 by kenzo terelst in ue5-release-engine-test branch]
2021-12-03 12:53:31 -05:00

51 lines
1.5 KiB
C++

// Copyright Epic Games, Inc. All Rights Reserved.
#pragma once
#if RHI_RAYTRACING
class RENDERER_API FRayTracingDynamicGeometryCollection
{
public:
FRayTracingDynamicGeometryCollection();
~FRayTracingDynamicGeometryCollection();
void AddDynamicMeshBatchForGeometryUpdate(
const FScene* Scene,
const FSceneView* View,
const FPrimitiveSceneProxy* PrimitiveSceneProxy,
FRayTracingDynamicGeometryUpdateParams Params,
uint32 PrimitiveId
);
// Starts an update batch and returns the current shared buffer generation ID which is used for validation.
int64 BeginUpdate();
void DispatchUpdates(FRHIComputeCommandList& ParentCmdList, FRHIBuffer* ScratchBuffer);
void EndUpdate(FRHICommandListImmediate& RHICmdList);
uint32 ComputeScratchBufferSize();
private:
TArray<struct FMeshComputeDispatchCommand> DispatchCommands;
TArray<FRayTracingGeometryBuildParams> BuildParams;
TArray<FRayTracingGeometrySegment> Segments;
struct FVertexPositionBuffer
{
FRWBuffer RWBuffer;
uint32 UsedSize = 0;
uint32 LastUsedGenerationID = 0;
};
TArray<FVertexPositionBuffer*> VertexPositionBuffers;
// Any uniform buffers that must be kept alive until EndUpdate (after DispatchUpdates is called)
TArray<FUniformBufferRHIRef> ReferencedUniformBuffers;
// Generation ID when the shared vertex buffers have been reset. The current generation ID is stored in the FRayTracingGeometry to keep track
// if the vertex buffer data is still valid for that frame - validated before generation the TLAS
int64 SharedBufferGenerationID = 0;
};
#endif // RHI_RAYTRACING