UDocumentation UE5.7 10.02.2026 (Source)
API documentation for Unreal Engine 5.7
VariableRateShadingImageManager.h
Go to the documentation of this file.
1// Copyright Epic Games, Inc. All Rights Reserved.
2
3/*=============================================================================
4 ShadingRateAttachment.h: Variable rate shading attachment generation class
5 definitions.
6=============================================================================*/
7
8#pragma once
9
10#include "Logging/LogMacros.h"
11#include "RHI.h"
12#include "RendererInterface.h"
14
15struct FMinimalSceneTextures; // Forward declaration from SceneTextures.
16
18
20
22{
23public:
39
44 {
46 Full = 1,
47 Conservative = 2
48 };
49
56 {
58 FixedFoveation = 0x1,
59
62
65
66 // @todo: Add more types here as they're implemented.
67
70
73
74 None = 0x0,
75 };
76
79
80 virtual void InitRHI(FRHICommandListBase& RHICmdList) override;
81 virtual void ReleaseRHI() override;
82
87 FRDGTextureRef GetVariableRateShadingImage(FRDGBuilder& GraphBuilder, const FViewInfo& ViewInfo, EVRSPassType PassType, bool bRequestSoftwareImage = false);
88
93 void PrepareImageBasedVRS(FRDGBuilder& GraphBuilder, const FSceneViewFamily& ViewFamily, const FMinimalSceneTextures& SceneTextures);
94
98 bool IsTypeEnabledForView(const FSceneView& View, EVRSSourceType Type);
99
102
103 static bool IsHardwareVRSSupported();
104 static bool IsSoftwareVRSSupported();
105
108
112
113 UE_DEPRECATED(5.5, "IsHardwareVRSEnabled() is deprecated, please use IsHardwareVRSEnabledForFrame() instead.")
115
116 UE_DEPRECATED(5.5, "IsSoftwareVRSEnabled() is deprecated, please use IsSoftwareVRSEnabledForFrame() instead.")
118
119 bool GetNeedStaticMeshUpdate() const;
121
122 static bool IsVRSCompatibleWithView(const FViewInfo& View);
123 static bool IsVRSCompatibleWithOutputType(const EDisplayOutputFormat& DisplayOutputFormat);
124
125 static FIntPoint GetSRITileSize(bool bSoftwareSize = false);
126 static FRDGTextureDesc GetSRIDesc(const FSceneViewFamily& ViewFamily, bool bSoftwareSize = false);
128
129 void DrawDebugPreview(FRDGBuilder& GraphBuilder, const FSceneViewFamily& ViewFamily, FRDGTextureRef OutputSceneColor);
130
131private:
132 TRefCountPtr<IPooledRenderTarget> MobileHMDFixedFoveationOverrideImage;
133 // Used to access the generators functionalities.
136 // This is used only to own the memory of generators created in the FVariableRateShadingImageManager constructor.
138 // Guards ImageGenerators because most of the calls of the manager are on the render thread but the
139 // Register/UnregisterExternalImageGenerator could come from the game thread.
140 FRWLock GeneratorsMutex;
141
142 FRDGTextureRef CombineShadingRateImages(FRDGBuilder& GraphBuilder, const FSceneViewFamily& ViewFamily, TArray<FRDGTextureRef> Sources);
143 FRDGTextureRef GetForceRateImage(FRDGBuilder& GraphBuilder, const FSceneViewFamily& ViewFamily, int RateIndex = 0, bool bGetSoftwareImage = false);
144
145 UE_DEPRECATED(5.5, "This version of GetForceRateImage is deprecated, please use GetForceRateImage(FRDGBuilder& GraphBuilder, const FSceneViewFamily& ViewFamily, int RateIndex, bool bGetSoftwareImage) instead.")
146 FRDGTextureRef GetForceRateImage(FRDGBuilder& GraphBuilder, const FSceneViewFamily& ViewFamily, int RateIndex = 0,
147 EVRSImageType ImageType = EVRSImageType::Full, bool bGetSoftwareImage = false) { return GetForceRateImage(GraphBuilder, ViewFamily, RateIndex, bGetSoftwareImage); };
148
149 EVRSImageType GetImageTypeFromPassType(EVRSPassType PassType);
150
151 bool bHardwareVRSEnabledForFrame = false;
152 bool bSoftwareVRSEnabledForFrame = false;
153 int32 VRSForceRateForFrame = -1;
154
155 bool bNeedStaticMeshUpdate = false;
156};
157
159
161
163{
164public:
166
167 // Returns cached VRS image.
168 virtual FRDGTextureRef GetImage(FRDGBuilder& GraphBuilder, const FViewInfo& ViewInfo, FVariableRateShadingImageManager::EVRSImageType ImageType, bool bGetSoftwareImage = false) = 0;
169
170 // Generates image(s) and saves to generator cache. Should only be run once per view per frame, in Render().
171 virtual void PrepareImages(FRDGBuilder& GraphBuilder, const FSceneViewFamily& ViewFamily, const FMinimalSceneTextures& SceneTextures, bool bPrepareHardwareImages, bool bPrepareSoftwareImages) = 0;
172
173 // Returns whether or not generator is enabled - can change at runtime
174 virtual bool IsEnabled() const { return false; };
175
176 // Returns whether or not the given view supports this generator
177 virtual bool IsSupportedByView(const FSceneView& View) const { return false; };
178
179 // Return bitmask of generator type
181
182 // Get VRS image to be used w/ debug overlay
184};
#define UE_DEPRECATED(Version, Message)
Definition CoreMiscDefines.h:302
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
#define ENUM_CLASS_FLAGS(Enum)
Definition EnumClassFlags.h:6
EDisplayOutputFormat
Definition GenericPlatformMisc.h:499
#define DECLARE_LOG_CATEGORY_EXTERN(CategoryName, DefaultVerbosity, CompileTimeVerbosity)
Definition LogMacros.h:361
const bool
Definition NetworkReplayStreaming.h:178
RENDERER_API TGlobalResource< FVariableRateShadingImageManager > GVRSImageManager
Definition VariableRateShadingImageManager.cpp:25
uint32_t uint32
Definition binka_ue_file_header.h:6
Definition RenderGraphBuilder.h:49
Definition RenderGraphResources.h:571
Definition RHICommandList.h:455
Definition RenderResource.h:37
Definition SceneView.h:2212
Definition SceneView.h:1425
Definition VariableRateShadingImageManager.h:22
void DrawDebugPreview(FRDGBuilder &GraphBuilder, const FSceneViewFamily &ViewFamily, FRDGTextureRef OutputSceneColor)
Definition VariableRateShadingImageManager.cpp:600
RENDERER_API void RegisterExternalImageGenerator(IVariableRateShadingImageGenerator *ExternalGenerator)
Definition VariableRateShadingImageManager.cpp:733
UE_DEPRECATED(5.5, "IsSoftwareVRSEnabled() is deprecated, please use IsSoftwareVRSEnabledForFrame() instead.") bool IsSoftwareVRSEnabled()
Definition VariableRateShadingImageManager.h:116
EVRSSourceType
Definition VariableRateShadingImageManager.h:56
virtual void InitRHI(FRHICommandListBase &RHICmdList) override
Definition VariableRateShadingImageManager.cpp:328
bool GetNeedStaticMeshUpdate() const
Definition VariableRateShadingImageManager.cpp:390
RENDERER_API bool IsPipelineVRSEnabled() const
Definition VariableRateShadingImageManager.cpp:363
RENDERER_API bool IsAttachmentVRSEnabled() const
Definition VariableRateShadingImageManager.cpp:369
FRDGTextureRef GetVariableRateShadingImage(FRDGBuilder &GraphBuilder, const FViewInfo &ViewInfo, EVRSPassType PassType, bool bRequestSoftwareImage=false)
Definition VariableRateShadingImageManager.cpp:455
UE_DEPRECATED(5.5, "IsHardwareVRSEnabled() is deprecated, please use IsHardwareVRSEnabledForFrame() instead.") bool IsHardwareVRSEnabled()
Definition VariableRateShadingImageManager.h:113
void PrepareImageBasedVRS(FRDGBuilder &GraphBuilder, const FSceneViewFamily &ViewFamily, const FMinimalSceneTextures &SceneTextures)
Definition VariableRateShadingImageManager.cpp:515
RENDERER_API bool IsVRSEnabledForFrame() const
Definition VariableRateShadingImageManager.cpp:375
RENDERER_API bool IsSoftwareVRSEnabledForFrame() const
Definition VariableRateShadingImageManager.cpp:385
static bool IsVRSCompatibleWithOutputType(const EDisplayOutputFormat &DisplayOutputFormat)
Definition VariableRateShadingImageManager.cpp:400
static FIntPoint GetSRITileSize(bool bSoftwareSize=false)
Definition VariableRateShadingImageManager.cpp:418
static int32 GetNumberOfSupportedRates()
Definition VariableRateShadingImageManager.cpp:445
virtual void ReleaseRHI() override
Definition VariableRateShadingImageManager.cpp:358
FVariableRateShadingImageManager()
Definition VariableRateShadingImageManager.cpp:313
RENDERER_API void UnregisterExternalImageGenerator(IVariableRateShadingImageGenerator *ExternalGenerator)
Definition VariableRateShadingImageManager.cpp:744
static bool IsHardwareVRSSupported()
Definition VariableRateShadingImageManager.cpp:348
static FRDGTextureDesc GetSRIDesc(const FSceneViewFamily &ViewFamily, bool bSoftwareSize=false)
Definition VariableRateShadingImageManager.cpp:423
virtual ~FVariableRateShadingImageManager()
Definition VariableRateShadingImageManager.cpp:326
EVRSPassType
Definition VariableRateShadingImageManager.h:28
@ SSR
Definition VariableRateShadingImageManager.h:33
@ Num
Definition VariableRateShadingImageManager.h:37
@ SSAO
Definition VariableRateShadingImageManager.h:32
@ ReflectionEnvironmentAndSky
Definition VariableRateShadingImageManager.h:34
@ Decals
Definition VariableRateShadingImageManager.h:36
@ BasePass
Definition VariableRateShadingImageManager.h:29
@ NaniteEmitGBufferPass
Definition VariableRateShadingImageManager.h:31
@ LightFunctions
Definition VariableRateShadingImageManager.h:35
@ TranslucencyAll
Definition VariableRateShadingImageManager.h:30
RENDERER_API bool IsHardwareVRSEnabledForFrame() const
Definition VariableRateShadingImageManager.cpp:380
static bool IsVRSCompatibleWithView(const FViewInfo &View)
Definition VariableRateShadingImageManager.cpp:409
static bool IsSoftwareVRSSupported()
Definition VariableRateShadingImageManager.cpp:353
void SetNeedStaticMeshUpdate(bool bInNeedStaticMeshUpdate)
Definition VariableRateShadingImageManager.cpp:395
bool IsTypeEnabledForView(const FSceneView &View, EVRSSourceType Type)
Definition VariableRateShadingImageManager.cpp:588
EVRSImageType
Definition VariableRateShadingImageManager.h:44
@ Full
Definition VariableRateShadingImageManager.h:46
@ Disabled
Definition VariableRateShadingImageManager.h:45
@ Conservative
Definition VariableRateShadingImageManager.h:47
Definition SceneRendering.h:1132
Definition VariableRateShadingImageManager.h:163
virtual void PrepareImages(FRDGBuilder &GraphBuilder, const FSceneViewFamily &ViewFamily, const FMinimalSceneTextures &SceneTextures, bool bPrepareHardwareImages, bool bPrepareSoftwareImages)=0
virtual bool IsSupportedByView(const FSceneView &View) const
Definition VariableRateShadingImageManager.h:177
virtual FRDGTextureRef GetImage(FRDGBuilder &GraphBuilder, const FViewInfo &ViewInfo, FVariableRateShadingImageManager::EVRSImageType ImageType, bool bGetSoftwareImage=false)=0
virtual FRDGTextureRef GetDebugImage(FRDGBuilder &GraphBuilder, const FViewInfo &ViewInfo, FVariableRateShadingImageManager::EVRSImageType ImageType, bool bGetSoftwareImage=false)=0
virtual ~IVariableRateShadingImageGenerator()
Definition VariableRateShadingImageManager.h:165
virtual FVariableRateShadingImageManager::EVRSSourceType GetType() const
Definition VariableRateShadingImageManager.h:180
virtual bool IsEnabled() const
Definition VariableRateShadingImageManager.h:174
Definition Array.h:670
Definition RenderResource.h:543
Definition RefCounting.h:454
Definition CriticalSection.h:14
@ false
Definition radaudio_common.h:23
Definition SceneTextures.h:52
Definition RenderGraphDefinitions.h:627
Definition IntPoint.h:25