2019-12-26 14:45:42 -05:00
|
|
|
// Copyright Epic Games, Inc. All Rights Reserved.
|
2018-12-18 21:41:17 -05:00
|
|
|
|
|
|
|
|
#pragma once
|
|
|
|
|
|
|
|
|
|
#if RHI_RAYTRACING
|
|
|
|
|
|
2022-11-21 03:22:23 -05:00
|
|
|
#include "RHI.h"
|
|
|
|
|
|
|
|
|
|
class FPrimitiveSceneProxy;
|
|
|
|
|
class FScene;
|
|
|
|
|
class FSceneView;
|
|
|
|
|
struct FRayTracingDynamicGeometryUpdateParams;
|
|
|
|
|
|
2018-12-18 21:41:17 -05:00
|
|
|
class RENDERER_API FRayTracingDynamicGeometryCollection
|
|
|
|
|
{
|
|
|
|
|
public:
|
2019-03-07 08:13:56 -05:00
|
|
|
FRayTracingDynamicGeometryCollection();
|
2020-08-11 01:36:57 -04:00
|
|
|
~FRayTracingDynamicGeometryCollection();
|
2019-03-07 08:13:56 -05:00
|
|
|
|
2019-06-11 18:27:07 -04:00
|
|
|
void AddDynamicMeshBatchForGeometryUpdate(
|
|
|
|
|
const FScene* Scene,
|
|
|
|
|
const FSceneView* View,
|
|
|
|
|
const FPrimitiveSceneProxy* PrimitiveSceneProxy,
|
2019-10-01 13:03:04 -04:00
|
|
|
FRayTracingDynamicGeometryUpdateParams Params,
|
|
|
|
|
uint32 PrimitiveId
|
|
|
|
|
);
|
|
|
|
|
|
2021-04-16 07:20:54 -04:00
|
|
|
// Starts an update batch and returns the current shared buffer generation ID which is used for validation.
|
|
|
|
|
int64 BeginUpdate();
|
2022-09-28 21:40:05 -04:00
|
|
|
void DispatchUpdates(FRHICommandListImmediate& ParentCmdList, FRHIBuffer* ScratchBuffer);
|
2020-08-11 01:36:57 -04:00
|
|
|
void EndUpdate(FRHICommandListImmediate& RHICmdList);
|
2018-12-18 21:41:17 -05:00
|
|
|
|
2022-10-19 09:00:41 -04:00
|
|
|
// Clears the working arrays to not hold any references.
|
|
|
|
|
// Needs to be called every frame when ray tracing is enabled or once when ray tracing mode has changed.
|
|
|
|
|
void Clear();
|
|
|
|
|
|
2021-12-03 09:52:48 -05:00
|
|
|
uint32 ComputeScratchBufferSize();
|
|
|
|
|
|
2018-12-18 21:41:17 -05:00
|
|
|
private:
|
2021-12-03 09:52:48 -05:00
|
|
|
|
2020-08-11 01:36:57 -04:00
|
|
|
TArray<struct FMeshComputeDispatchCommand> DispatchCommands;
|
2021-03-31 14:19:03 -04:00
|
|
|
TArray<FRayTracingGeometryBuildParams> BuildParams;
|
2020-08-11 01:36:57 -04:00
|
|
|
TArray<FRayTracingGeometrySegment> Segments;
|
|
|
|
|
|
|
|
|
|
struct FVertexPositionBuffer
|
|
|
|
|
{
|
|
|
|
|
FRWBuffer RWBuffer;
|
|
|
|
|
uint32 UsedSize = 0;
|
2021-12-03 12:53:31 -05:00
|
|
|
uint32 LastUsedGenerationID = 0;
|
2020-08-11 01:36:57 -04:00
|
|
|
};
|
|
|
|
|
TArray<FVertexPositionBuffer*> VertexPositionBuffers;
|
|
|
|
|
|
2021-04-26 06:23:11 -04:00
|
|
|
// Any uniform buffers that must be kept alive until EndUpdate (after DispatchUpdates is called)
|
|
|
|
|
TArray<FUniformBufferRHIRef> ReferencedUniformBuffers;
|
|
|
|
|
|
2020-08-11 01:36:57 -04:00
|
|
|
// 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
|
2021-04-16 07:20:54 -04:00
|
|
|
int64 SharedBufferGenerationID = 0;
|
2018-12-18 21:41:17 -05:00
|
|
|
};
|
|
|
|
|
|
|
|
|
|
#endif // RHI_RAYTRACING
|