UDocumentation UE5.7 10.02.2026 (Source)
API documentation for Unreal Engine 5.7
LandscapeEditResourcesSubsystem.h
Go to the documentation of this file.
1// Copyright Epic Games, Inc. All Rights Reserved.
2
3#pragma once
4
8#include "RHIAccess.h"
9#include "RHITransition.h"
10
11#if WITH_EDITOR
12#include "Materials/Material.h"
13#include "LandscapeUtils.h"
14#endif // WITH_EDITOR
15
16#include "LandscapeEditResourcesSubsystem.generated.h"
17
18struct FResourceSizeEx;
21class FRDGBuilder;
23
24namespace UE::Landscape
25{
26class FRDGBuilderRecorder;
27
62
72
73} // namespace UE::Landscape
74
83{
85
88
89public:
91
93 LANDSCAPE_API const FString& GetDebugName() const;
95 UTextureRenderTarget* GetRenderTarget() const { return RenderTarget; }
97 LANDSCAPE_API UTextureRenderTarget2D* GetRenderTarget2D() const;
99 LANDSCAPE_API UTextureRenderTarget2D* TryGetRenderTarget2D() const;
101 LANDSCAPE_API UTextureRenderTarget2DArray* GetRenderTarget2DArray() const;
103 LANDSCAPE_API UTextureRenderTarget2DArray* TryGetRenderTarget2DArray() const;
105 LANDSCAPE_API FIntPoint GetResolution() const;
107 LANDSCAPE_API FIntPoint GetEffectiveResolution() const;
109 LANDSCAPE_API int32 GetNumSlices() const;
111 LANDSCAPE_API int32 GetEffectiveNumSlices() const;
112 bool IsTexture2D() const { return (TryGetRenderTarget2D() != nullptr); }
113 bool IsTexture2DArray() const { return (TryGetRenderTarget2DArray() != nullptr); }
115 LANDSCAPE_API FLinearColor GetClearColor() const;
116 ERHIAccess GetCurrentState() const { return CurrentState; }
117 const UE::Landscape::FScratchRenderTargetParams& GetCurrentRenderTargetParams() { return CurrentRenderTargetParams; }
118
120 {
121 public:
122 FTransitionInfo() = default;
128
129 FRHITransitionInfo ToRHITransitionInfo() const;
130
131 private:
132 FTextureResource* Resource = nullptr;
133 ERHIAccess StateBefore = ERHIAccess::None;
134 ERHIAccess StateAfter = ERHIAccess::None;
135 };
136
138 {
139 public:
142
144
145 private:
146 UE::Landscape::FRDGBuilderRecorder& RDGBuilderRecorder;
147 TArray<FTransitionInfo> PendingTransitions;
148 };
149
151 {
152 FIntPoint CopySize = FIntPoint(0, 0);
153 FIntPoint SourcePosition = FIntPoint(0, 0);
154 FIntPoint DestPosition = FIntPoint(0, 0);
155 uint8 SourceMip = 0;
156 uint8 DestMip = 0;
157 uint32 SourceSliceIndex = 0;
158 uint32 DestSliceIndex = 0;
159 };
160
162 {
164 : SourceTexture(InSourceTexture)
165 {}
166
167 UTexture* SourceTexture = nullptr;
168 };
169
171 {
173 : SourceScratchRenderTarget(InSourceScratchRenderTarget)
174 {
175 // No need to copy anything beyond the effective resolution in the case of a scratch render target :
176 CopySize = InSourceScratchRenderTarget->GetEffectiveResolution();
177 }
178
179 ULandscapeScratchRenderTarget* SourceScratchRenderTarget = nullptr;
180 };
181
189
197
204 LANDSCAPE_API void TransitionTo(ERHIAccess InStateAfter, UE::Landscape::FRDGBuilderRecorder& RDGBuilderRecorder);
205
212
214 bool IsCompatibleWith(const UE::Landscape::FScratchRenderTargetParams& InParams) const;
215
217 bool IsInUse() const { return bIsInUse; }
218
219private:
221 void OnReleased();
222
223private:
224 UPROPERTY(NonTransactional)
226
227 // BEGIN Un-mutable section
228 // The following variables are un-mutable after RenderTarget is initialized :
229
230 // Format of the render target. Technically, we could infer it from RenderTarget->Format but since it's stored as a EPixelFormat,
231 // end there's no easy conversion from EPixelFormat to ETextureRenderTargetFormat, we store a copy here instead:
233 // END Un-mutable section
234
235 // Current state of the scratch render target :
236 bool bIsInUse = false;
237 UE::Landscape::FScratchRenderTargetParams CurrentRenderTargetParams;
238 ERHIAccess CurrentState = ERHIAccess::None;
239};
240
242UCLASS()
244{
246
247public:
249
250 // UEngineSubsystem implementation
251 virtual void Initialize(FSubsystemCollectionBase& Collection) override;
252 virtual void Deinitialize() override;
253
259
264 void ReleaseScratchRenderTarget(ULandscapeScratchRenderTarget* InScratchRenderTarget);
265
266#if WITH_EDITOR
275#endif // WITH_EDITOR
276
277private:
278 UPROPERTY(Transient, NonTransactional)
280
281#if WITH_EDITORONLY_DATA
282 UPROPERTY(Transient, NonTransactional)
284
285 UPROPERTY(Transient, NonTransactional)
287
288 UPROPERTY(Transient, NonTransactional)
290
291 UPROPERTY(Transient, NonTransactional)
293
294 UPROPERTY(Transient, NonTransactional)
296
297 UPROPERTY(Transient, NonTransactional)
299
300 UPROPERTY(Transient, NonTransactional)
302
303 UPROPERTY(Transient, NonTransactional)
305#endif // WITH_EDITORONLY_DATA
306
307};
@ ForceInitToZero
Definition CoreMiscDefines.h:156
@ ForceInit
Definition CoreMiscDefines.h:155
FPlatformTypes::int32 int32
A 32-bit signed integer.
Definition Platform.h:1125
UE_FORCEINLINE_HINT TSharedRef< CastToType, Mode > StaticCastSharedRef(TSharedRef< CastFromType, Mode > const &InSharedRef)
Definition SharedPointer.h:127
FInt32Point FIntPoint
Definition MathFwd.h:124
#define UPROPERTY(...)
UObject definition macros.
Definition ObjectMacros.h:744
#define GENERATED_BODY(...)
Definition ObjectMacros.h:765
#define UCLASS(...)
Definition ObjectMacros.h:776
ERHIAccess
Definition RHIAccess.h:11
ETextureRenderTargetFormat
Definition TextureRenderTarget2D.h:21
@ RTF_RGBA8
Definition TextureRenderTarget2D.h:27
uint8_t uint8
Definition binka_ue_file_header.h:8
uint32_t uint32
Definition binka_ue_file_header.h:6
Definition UnrealTemplate.h:321
Definition RenderGraphBuilder.h:49
Definition RHICommandList.h:4626
Definition SubsystemCollection.h:15
Definition TextureResource.h:103
Definition Array.h:670
Definition LandscapeUtils.h:106
Definition EngineSubsystem.h:22
Definition LandscapeEditResourcesSubsystem.h:244
Definition LandscapeEditResourcesSubsystem.h:138
Definition LandscapeEditResourcesSubsystem.h:120
FTransitionInfo(FTextureResource *InResource, ERHIAccess InStateBefore, ERHIAccess InStateAfter)
Definition LandscapeEditResourcesSubsystem.h:123
Definition LandscapeEditResourcesSubsystem.h:83
bool IsTexture2D() const
Definition LandscapeEditResourcesSubsystem.h:112
const UE::Landscape::FScratchRenderTargetParams & GetCurrentRenderTargetParams()
Definition LandscapeEditResourcesSubsystem.h:117
ERHIAccess GetCurrentState() const
Definition LandscapeEditResourcesSubsystem.h:116
bool IsInUse() const
Definition LandscapeEditResourcesSubsystem.h:217
bool IsTexture2DArray() const
Definition LandscapeEditResourcesSubsystem.h:113
Definition MaterialInterface.h:296
Definition Object.h:95
Definition Texture2D.h:26
Definition TextureRenderTarget2DArray.h:22
Definition TextureRenderTarget2D.h:104
Definition TextureRenderTarget.h:22
Definition Texture.h:1219
Definition Landscape.h:55
Definition Color.h:48
Definition RHITransition.h:119
Definition ResourceSize.h:31
Definition ObjectPtr.h:488
Definition LandscapeEditResourcesSubsystem.h:29
FScratchRenderTargetParams(const FString &InDebugName, bool bInExactDimensions, bool bInUseUAV, bool bInTargetArraySlicesIndependently, const FIntPoint &InResolution, int32 InNumSlices, ETextureRenderTargetFormat InFormat, const FLinearColor &InClearColor, ERHIAccess InInitialState)
Definition LandscapeEditResourcesSubsystem.h:31
FLinearColor ClearColor
Definition LandscapeEditResourcesSubsystem.h:58
ETextureRenderTargetFormat Format
Definition LandscapeEditResourcesSubsystem.h:56
bool bUseUAV
Definition LandscapeEditResourcesSubsystem.h:48
bool bExactDimensions
Definition LandscapeEditResourcesSubsystem.h:46
FIntPoint Resolution
Definition LandscapeEditResourcesSubsystem.h:52
ERHIAccess InitialState
Definition LandscapeEditResourcesSubsystem.h:60
bool bTargetArraySlicesIndependently
Definition LandscapeEditResourcesSubsystem.h:50
int32 NumSlices
Definition LandscapeEditResourcesSubsystem.h:54
FString DebugName
Definition LandscapeEditResourcesSubsystem.h:44
Definition LandscapeEditResourcesSubsystem.h:64
~FScratchRenderTargetScope()
Definition LandscapeEditResourcesSubsystem.cpp:31
ULandscapeScratchRenderTarget * RenderTarget
Definition LandscapeEditResourcesSubsystem.h:70
ULandscapeEditResourcesSubsystem * EditResourcesSubsystem
Definition LandscapeEditResourcesSubsystem.h:69
Definition IntPoint.h:25
Definition LandscapeEditResourcesSubsystem.h:151
Definition LandscapeEditResourcesSubsystem.h:171
FCopyFromScratchRenderTargetParams(ULandscapeScratchRenderTarget *InSourceScratchRenderTarget)
Definition LandscapeEditResourcesSubsystem.h:172
Definition LandscapeEditResourcesSubsystem.h:162
FCopyFromTextureParams(UTexture *InSourceTexture)
Definition LandscapeEditResourcesSubsystem.h:163