UDocumentation UE5.7 10.02.2026 (Source)
API documentation for Unreal Engine 5.7
RayTracingGeometry.h
Go to the documentation of this file.
1// Copyright Epic Games, Inc. All Rights Reserved.
2
3#pragma once
4
5#include "CoreMinimal.h"
7#include "RenderResource.h"
8#include "RHI.h"
9
11
12namespace RayTracing
13{
15 using GeometryGroupHandle UE_DEPRECATED(5.6, "Use FGeometryGroupHandle instead.") = FGeometryGroupHandle;
16
18}
19
21{
23 High,
24 Normal,
25 Low,
26 Skip
27};
28
31{
32public:
35
36#if RHI_RAYTRACING
37
39 static constexpr int64 NonSharedVertexBuffers = -1;
40
47
48 // Last frame when geometry was updated (only dynamic geometry)
50
51 // How many updates since the last build (only dynamic geometry)
53
55
56 FRHIRayTracingGeometry* GetRHI() const
57 {
59 }
60
62
64 int8 LODIndex = -1;
65
66 // Flags for tracking the state of RayTracingGeometryRHI.
67 enum class EGeometryStateFlags : uint32
68 {
69 // Initial state when the geometry was not created or was created for streaming but not yet streamed in.
70 Invalid = 0,
71
72 // If the geometry needs to be built.
73 RequiresBuild = 1 << 0,
74
75 // If the geometry was successfully created or streamed in.
76 Valid = 1 << 1,
77
78 // Special flag that is used when ray tracing is dynamic to mark the streamed geometry to be recreated when ray tracing is switched on.
79 // Only set when mesh streaming is used.
80 StreamedIn = 1 << 2,
81
82 // If the geometry is initialized but was evicted
83 Evicted = 1 << 3,
84
85 // If geometry requires an update (dynamic geometry only)
86 RequiresUpdate = 1 << 4
87 };
89
91
93 RENDERCORE_API bool IsValid() const;
94 RENDERCORE_API bool IsEvicted() const;
95
96 void SetAsStreamedIn()
97 {
98 EnumAddFlags(GeometryState, EGeometryStateFlags::StreamedIn);
99 }
100
101 bool GetRequiresBuild() const
102 {
103 return EnumHasAnyFlags(GeometryState, EGeometryStateFlags::RequiresBuild);
104 }
105
106 void SetRequiresBuild(bool bBuild)
107 {
108 if (bBuild)
109 {
110 EnumAddFlags(GeometryState, EGeometryStateFlags::RequiresBuild);
111 }
112 else
113 {
114 EnumRemoveFlags(GeometryState, EGeometryStateFlags::RequiresBuild);
115 }
116 }
117
118 bool GetRequiresUpdate() const
119 {
120 return EnumHasAnyFlags(GeometryState, EGeometryStateFlags::RequiresUpdate);
121 }
122
123 void SetRequiresUpdate(bool bUpdate)
124 {
125 if (bUpdate)
126 {
127 EnumAddFlags(GeometryState, EGeometryStateFlags::RequiresUpdate);
128 }
129 else
130 {
131 EnumRemoveFlags(GeometryState, EGeometryStateFlags::RequiresUpdate);
132 }
133 }
134
136 {
137 return GeometryState;
138 }
139
141 RENDERCORE_API void ReleaseRHIForStreaming(FRHIResourceReplaceBatcher& Batcher);
142
144
146
148 RENDERCORE_API void Evict();
149
151
152 RENDERCORE_API void BoostBuildPriority(float InBoostValue = 0.01f) const;
153
154 // FRenderResource interface
155
156 virtual FString GetFriendlyName() const override { return TEXT("FRayTracingGeometry"); }
157
158 RENDERCORE_API virtual void InitRHI(FRHICommandListBase& RHICmdList) override;
159 RENDERCORE_API virtual void ReleaseRHI() override;
160
161 RENDERCORE_API virtual void InitResource(FRHICommandListBase& RHICmdList) override;
162 RENDERCORE_API virtual void ReleaseResource() override;
163
165protected:
167
169
170 friend class FRayTracingGeometryManager;
171 EGeometryStateFlags GeometryState = EGeometryStateFlags::Invalid;
173 int32 RayTracingGeometryHandle = INDEX_NONE; // Only valid when ray tracing is dynamic
174#endif
175};
176
177#if RHI_RAYTRACING
178ENUM_CLASS_FLAGS(FRayTracingGeometry::EGeometryStateFlags);
179#endif
@ Valid
Definition AndroidInputInterface.h:103
@ INDEX_NONE
Definition CoreMiscDefines.h:150
#define UE_DEPRECATED(Version, Message)
Definition CoreMiscDefines.h:302
FPlatformTypes::int8 int8
An 8-bit signed integer.
Definition Platform.h:1121
#define TEXT(x)
Definition Platform.h:1272
FPlatformTypes::int64 int64
A 64-bit signed integer.
Definition Platform.h:1127
FPlatformTypes::int32 int32
A 32-bit signed integer.
Definition Platform.h:1125
FPlatformTypes::uint64 uint64
A 64-bit unsigned integer.
Definition Platform.h:1117
UE_FORCEINLINE_HINT TSharedRef< CastToType, Mode > StaticCastSharedRef(TSharedRef< CastFromType, Mode > const &InSharedRef)
Definition SharedPointer.h:127
constexpr bool EnumHasAnyFlags(Enum Flags, Enum Contains)
Definition EnumClassFlags.h:35
#define FRIEND_ENUM_CLASS_FLAGS(Enum)
Definition EnumClassFlags.h:17
constexpr void EnumRemoveFlags(Enum &Flags, Enum FlagsToRemove)
Definition EnumClassFlags.h:98
constexpr void EnumAddFlags(Enum &Flags, Enum FlagsToAdd)
Definition EnumClassFlags.h:91
#define ENUM_CLASS_FLAGS(Enum)
Definition EnumClassFlags.h:6
ERTAccelerationStructureBuildPriority
Definition RayTracingGeometry.h:21
uint8_t uint8
Definition binka_ue_file_header.h:8
uint32_t uint32
Definition binka_ue_file_header.h:6
Definition RHICommandList.h:455
Definition RHICommandList.h:3819
Definition RHIResources.h:3729
Definition RHIResourceReplace.h:55
Definition RayTracingGeometry.h:31
FRayTracingGeometryOfflineDataHeader RawDataHeader
Definition RayTracingGeometry.h:33
TResourceArray< uint8 > RawData
Definition RayTracingGeometry.h:34
Definition RenderResource.h:37
virtual FString GetFriendlyName() const
Definition RenderResource.h:111
virtual void ReleaseRHI()
Definition RenderResource.h:90
virtual RENDERCORE_API void ReleaseResource()
Definition RenderResource.cpp:206
virtual void InitRHI(FRHICommandListBase &RHICmdList)
Definition RenderResource.h:83
virtual RENDERCORE_API void InitResource(FRHICommandListBase &RHICmdList)
Definition RenderResource.cpp:178
Definition DynamicRHIResourceArray.h:31
Definition SceneManagement.h:73
RENDERCORE_API bool ShouldForceRuntimeBLAS()
Definition RayTracingGeometry.cpp:23
int32 FGeometryGroupHandle
Definition SceneManagement.h:74
Definition RHIResources.h:3496
Definition RHIResources.h:3398