Files
UnrealEngineUWP/Engine/Source/Runtime/RenderCore/Public/RayTracingGeometryManagerInterface.h
tiago costa 93f87b8be7 Resubmit CL 30935187 with following changes:
- Issue 1 - UStaticMesh can be released before the proxy is destroyed:
    - delay release of FRayTracingGeometryGroup until all proxies are unregistered.
    - keep copy of RayTracingGeometryGroupHandle in render proxy

- Issue 2 - FRayTracingGeometryManager::RequestUpdateCachedRenderState(...) called when running !IsRayTracingAllowed()
    - initialize RayTracingGeometryGroupHandle to INDEX_NONE
    - only call FRayTracingGeometryManager::RequestUpdateCachedRenderState(...) if IsRayTracingAllowed()

[Original CL Desc]

Improvements to tracking of proxies requiring invalidation when raytracing geometry is streamed/built/made resident.

Context:
- The existing CachedRayTracingStateProxiesMap mapped [UStaticMesh -> Array of Proxies that need to be invalidated], however there was no way to map [FRayTracingGeometry -> Array of Proxies that need to be invalidated] since FRayTracingGeometry doesn't have a pointer to which UStaticMesh owns it. On top of that, not every FRayTracingGeometry is associated with a UStaticMesh.
- An alternative approach could be having a map [FRayTracingGeometry -> Array of Proxies that need to be invalidated] however that would require significantly more memory - O(#proxies x #LODs) instead of O(#proxies).

Change:
- Modified CachedRayTracingStateProxiesMap to use a more generic RayTracing::GeometryGroupHandle (int32) as key.
- Store RayTracing::GeometryGroupHandle in FRayTracingGeometry.

[FYI] aleksander.netzel

[CL 31210226 by tiago costa in 5.4 branch]
2024-02-06 06:56:46 -05:00

60 lines
2.4 KiB
C++

// Copyright Epic Games, Inc. All Rights Reserved.
#pragma once
#include "Containers/ArrayView.h"
#include "RHI.h"
#include "RHIResources.h"
#include "RHICommandList.h"
#if RHI_RAYTRACING
class FRayTracingGeometry;
class FRHIComputeCommandList;
enum class EAccelerationStructureBuildMode;
enum class ERTAccelerationStructureBuildPriority;
namespace RayTracing
{
using GeometryGroupHandle = int32;
}
class IRayTracingGeometryManager
{
public:
using BuildRequestIndex = int32;
using RayTracingGeometryHandle = int32;
virtual ~IRayTracingGeometryManager() = default;
RENDERCORE_API virtual BuildRequestIndex RequestBuildAccelerationStructure(FRayTracingGeometry* InGeometry, ERTAccelerationStructureBuildPriority InPriority, EAccelerationStructureBuildMode InBuildMode) = 0;
BuildRequestIndex RequestBuildAccelerationStructure(FRayTracingGeometry* InGeometry, ERTAccelerationStructureBuildPriority InPriority)
{
return RequestBuildAccelerationStructure(InGeometry, InPriority, EAccelerationStructureBuildMode::Build);
}
RENDERCORE_API virtual void RemoveBuildRequest(BuildRequestIndex InRequestIndex) = 0;
RENDERCORE_API virtual void BoostPriority(BuildRequestIndex InRequestIndex, float InBoostValue) = 0;
RENDERCORE_API virtual void ForceBuildIfPending(FRHIComputeCommandList& InCmdList, const TArrayView<const FRayTracingGeometry*> InGeometries) = 0;
RENDERCORE_API virtual void ProcessBuildRequests(FRHIComputeCommandList& InCmdList, bool bInBuildAll = false) = 0;
RENDERCORE_API virtual RayTracingGeometryHandle RegisterRayTracingGeometry(FRayTracingGeometry* InGeometry) = 0;
RENDERCORE_API virtual void ReleaseRayTracingGeometryHandle(RayTracingGeometryHandle Handle) = 0;
/*
* RayTracing::GeometryGroupHandle is used to group multiple FRayTracingGeometry that are associated with the same asset.
* For example, the FRayTracingGeometry of all the LODs of UStaticMesh should use the same RayTracing::GeometryGroupHandle.
* This grouping is useful to keep track which proxies need to be invalidated when a FRayTracingGeometry is built or made resident.
*/
RENDERCORE_API virtual RayTracing::GeometryGroupHandle RegisterRayTracingGeometryGroup() = 0;
RENDERCORE_API virtual void ReleaseRayTracingGeometryGroup(RayTracing::GeometryGroupHandle Handle) = 0;
RENDERCORE_API virtual void Tick(FRHICommandList& RHICmdList) = 0;
};
extern RENDERCORE_API IRayTracingGeometryManager* GRayTracingGeometryManager;
#endif // RHI_RAYTRACING