UDocumentation UE5.7 10.02.2026 (Source)
API documentation for Unreal Engine 5.7
VulkanGenericPlatform.h
Go to the documentation of this file.
1// Copyright Epic Games, Inc. All Rights Reserved.
2
3#pragma once
4
5#include "Containers/Array.h"
7#include "PixelFormat.h"
9#include "VulkanThirdParty.h"
10
12class FVulkanDevice;
14struct FGfxPipelineDesc;
17
19enum class EGpuVendorId : uint32;
20namespace ERHIFeatureLevel { enum Type : int; }
21
24
25// the platform interface, and empty implementations for platforms that don't need em
26
28{
29public:
31 void* GetWindowHandle() const { return WindowHandle; }
32 // whether the platform can attempt to create a swapchains during present
33 static bool CanCreateSwapchainOnDemand() { return true; }
34 bool IsValid() const { return true; }
35protected:
36 void* WindowHandle = nullptr;
37};
38
40{
41public:
42 static bool IsSupported() { return true; }
43
44 static bool LoadVulkanLibrary() { return true; }
46 static void ClearVulkanInstanceFunctions();
47 static void FreeVulkanLibrary() {}
48
50 static void PostInitGPU(const FVulkanDevice& InDevice) {}
51
52 // Called after querying all the available extensions and layers
55
56 // Array of required extensions for the platform (Required!)
61
62 // Allows platform specific GPU crash handling
63 static void OnGPUCrash(const TCHAR* Message) {}
64
65 // create the platform-specific surface object - required
67
68 // most platforms support BC* but not ASTC* or ETC2*
69 static bool SupportsBCTextureFormats() { return true; }
70 static bool SupportsASTCTextureFormats() { return false; }
71 static bool SupportsETC2TextureFormats() { return false; }
72 static bool SupportsR16UnormTextureFormat() { return true; }
73
74 // most platforms can query the surface for the present mode, and size, etc
75 static bool SupportsQuerySurfaceProperties() { return true; }
76
77 static void SetupFeatureLevels(TArrayView<EShaderPlatform> ShaderPlatformForFeatureLevel);
78
79 static bool SupportsTimestampRenderQueries() { return true; }
80
81 static bool HasCustomFrameTiming() { return false; }
82
83 static bool RequiresMobileRenderer() { return false; }
84
86
87 // bInit=1 called at RHI init time, bInit=0 at RHI deinit time
88 static void OverridePlatformHandlers(bool bInit) {}
89
90 // Some platforms have issues with the access flags for the Present layout
91 static bool RequiresPresentLayoutFix() { return false; }
92
93 static bool SupportsDeviceLocalHostVisibleWithNoPenalty(EGpuVendorId VendorId) { return false; }
94
95 static bool HasUnifiedMemory() { return false; }
96
97 static bool RegisterGPUWork() { return true; }
98
99 // Allow the platform code to restrict the device features
101
102 static bool SupportParallelRenderingTasks() { return true; }
103
105 static bool SupportsDynamicResolution() { return false; }
106
107 static bool SupportsVolumeTextureRendering() { return true; }
108
109 static bool RequiresSwapchainGeneralInitialLayout() { return false; }
110
111 // Allow platforms to perform their own frame pacing, called before Present. Returns true if the platform has done framepacing, false otherwise.
112 static bool FramePace(FVulkanDevice& Device, void* WindowHandle, VkSwapchainKHR Swapchain, uint32 PresentID, VkPresentInfoKHR& Info) { return false; }
113
114 // Allow platforms to do extra work on present
116
117 // Allow platforms to track swapchain creation
119
120 // Allow platforms to track swapchain destruction
121 static void DestroySwapchainKHR(VkDevice Device, VkSwapchainKHR Swapchain, const VkAllocationCallbacks* Allocator);
122
123 // Whether to attempt recreate swapchain when present or acqurire operations fail
124 static bool RecreateSwapchainOnFail() { return true; }
125
126 // Ensure the last frame completed on the GPU
127 static bool RequiresWaitingForFrameCompletionEvent() { return true; }
128
129 // Does the platform allow a nullptr Pixelshader on the pipeline
130 static bool SupportsNullPixelShader() { return true; }
131
132 // Does the platform require depth to be written on stencil clear
133 static bool RequiresDepthStencilFullWrite() { return false; }
134
135 // Does the platform require to avoid VkAttachmentDescriptionStencilLayout in favor of merged depth-stencil layouts
136 static bool RequiresMergedDepthStencilLayout() { return false; }
137
138 // Checks if the PSO cache matches the expected vulkan device properties
140
141 // Will create the correct format from a generic pso filename
142 static FString CreatePSOBinaryCacheFilename(FVulkanDevice* Device, FString CacheFilename);
143
144 // Get top-level path for pso cache files (defaults to ProjectSavedDir/VulkanProgramBinaryCache)
145 static FString GetCompiledPSOCacheTopFolderPath();
146
147 // Gathers a list of pso cache filenames to attempt to load
149
150 // Gives platform a chance to handle precompile of PSOs, returns nullptr if unsupported
152
153 // Return VK_FALSE if platform wants to suppress the given debug report from the validation layers, VK_TRUE to print it.
155
156 // Setup platform to use a workaround to reduce textures memory requirements
158
159 // Returns the profile name to look up for a given feature level on a platform
160 static bool SupportsProfileChecks();
162
163 // Returns the shader stages for which we need support for subgroup ops.
165
167};
FPlatformTypes::TCHAR TCHAR
Either ANSICHAR or WIDECHAR, depending on whether the platform supports wide characters or the requir...
Definition Platform.h:1135
FPlatformTypes::int32 int32
A 32-bit signed integer.
Definition Platform.h:1125
FPlatformTypes::ANSICHAR ANSICHAR
An ANSI character. Normally a signed type.
Definition Platform.h:1131
UE_FORCEINLINE_HINT TSharedRef< CastToType, Mode > StaticCastSharedRef(TSharedRef< CastFromType, Mode > const &InSharedRef)
Definition SharedPointer.h:127
EGpuVendorId
Definition RHIDefinitions.h:1006
EShaderPlatform
Definition RHIShaderPlatform.h:11
uint8_t uint8
Definition binka_ue_file_header.h:8
uint16_t uint16
Definition binka_ue_file_header.h:7
uint32_t uint32
Definition binka_ue_file_header.h:6
Definition VulkanCommandBuffer.h:43
Definition VulkanDevice.h:279
Definition VulkanGenericPlatform.h:28
static bool CanCreateSwapchainOnDemand()
Definition VulkanGenericPlatform.h:33
FVulkanGenericPlatformWindowContext(void *WindowHandleIn)
Definition VulkanGenericPlatform.h:30
void * GetWindowHandle() const
Definition VulkanGenericPlatform.h:31
bool IsValid() const
Definition VulkanGenericPlatform.h:34
void * WindowHandle
Definition VulkanGenericPlatform.h:36
Definition VulkanGenericPlatform.h:40
static bool RequiresPresentLayoutFix()
Definition VulkanGenericPlatform.h:91
static VkShaderStageFlags RequiredWaveOpsShaderStageFlags(VkShaderStageFlags VulkanDeviceShaderStageFlags)
Definition VulkanGenericPlatform.h:164
static bool SupportParallelRenderingTasks()
Definition VulkanGenericPlatform.h:102
static bool SupportsDeviceLocalHostVisibleWithNoPenalty(EGpuVendorId VendorId)
Definition VulkanGenericPlatform.h:93
static TArray< FString > GetPSOCacheFilenames()
Definition VulkanGenericPlatform.cpp:99
static FString GetCompiledPSOCacheTopFolderPath()
Definition VulkanGenericPlatform.cpp:94
static bool SupportsDynamicResolution()
Definition VulkanGenericPlatform.h:105
static void ClearVulkanInstanceFunctions()
Definition VulkanGenericPlatform.cpp:177
static VkResult CreateSwapchainKHR(FVulkanGenericPlatformWindowContext &WindowContext, VkPhysicalDevice PhysicalDevice, VkDevice Device, const VkSwapchainCreateInfoKHR *CreateInfo, const VkAllocationCallbacks *Allocator, VkSwapchainKHR *Swapchain)
Definition VulkanGenericPlatform.cpp:139
static bool RequiresMobileRenderer()
Definition VulkanGenericPlatform.h:83
static bool SupportsTimestampRenderQueries()
Definition VulkanGenericPlatform.h:79
static bool SupportsETC2TextureFormats()
Definition VulkanGenericPlatform.h:71
static void NotifyFoundDeviceLayersAndExtensions(VkPhysicalDevice PhysicalDevice, const TArray< const ANSICHAR * > &Layers, const TArray< const ANSICHAR * > &Extensions)
Definition VulkanGenericPlatform.h:54
static bool HasUnifiedMemory()
Definition VulkanGenericPlatform.h:95
static bool SupportsR16UnormTextureFormat()
Definition VulkanGenericPlatform.h:72
static void FreeVulkanLibrary()
Definition VulkanGenericPlatform.h:47
static bool SupportsProfileChecks()
Definition VulkanGenericPlatform.cpp:186
static bool RecreateSwapchainOnFail()
Definition VulkanGenericPlatform.h:124
static void GetDeviceExtensions(FVulkanDevice *Device, FVulkanDeviceExtensionArray &OutExtensions)
static void NotifyFoundInstanceLayersAndExtensions(const TArray< const ANSICHAR * > &Layers, const TArray< const ANSICHAR * > &Extensions)
Definition VulkanGenericPlatform.h:53
static void RestrictEnabledPhysicalDeviceFeatures(FVulkanPhysicalDeviceFeatures *InOutFeaturesToEnable)
Definition VulkanGenericPlatform.cpp:116
static void SetImageMemoryRequirementWorkaround(VkImageCreateInfo &ImageCreateInfo)
Definition VulkanGenericPlatform.h:157
static bool SupportsQuerySurfaceProperties()
Definition VulkanGenericPlatform.h:75
static void DestroySwapchainKHR(VkDevice Device, VkSwapchainKHR Swapchain, const VkAllocationCallbacks *Allocator)
Definition VulkanGenericPlatform.cpp:144
static bool IsSupported()
Definition VulkanGenericPlatform.h:42
static bool SupportsASTCTextureFormats()
Definition VulkanGenericPlatform.h:70
static bool RegisterGPUWork()
Definition VulkanGenericPlatform.h:97
static bool RequiresDepthStencilFullWrite()
Definition VulkanGenericPlatform.h:133
static bool SupportsBCTextureFormats()
Definition VulkanGenericPlatform.h:69
static void GetDeviceLayers(TArray< const ANSICHAR * > &OutLayers)
Definition VulkanGenericPlatform.h:60
static bool HasCustomFrameTiming()
Definition VulkanGenericPlatform.h:81
static void CreateSurface(VkSurfaceKHR *OutSurface)
static VkPipelineCache PrecompilePSO(FVulkanDevice *Device, const uint8 *OptionalPSOCacheData, VkGraphicsPipelineCreateInfo *PipelineInfo, const FGfxPipelineDesc *GfxEntry, const FVulkanRenderTargetLayout *RTLayout, TArrayView< uint32_t > VS, TArrayView< uint32_t > PS, size_t &AfterSize, FString *FailureMessageOUT=nullptr)
Definition VulkanGenericPlatform.h:151
static void OnGPUCrash(const TCHAR *Message)
Definition VulkanGenericPlatform.h:63
static VkBool32 DebugReportFunction(VkDebugReportFlagsEXT MsgFlags, VkDebugReportObjectTypeEXT ObjType, uint64_t SrcObject, size_t Location, int32 MsgCode, const ANSICHAR *LayerPrefix, const ANSICHAR *Msg, void *UserData)
Definition VulkanGenericPlatform.h:154
static bool FramePace(FVulkanDevice &Device, void *WindowHandle, VkSwapchainKHR Swapchain, uint32 PresentID, VkPresentInfoKHR &Info)
Definition VulkanGenericPlatform.h:112
static bool PSOBinaryCacheMatches(FVulkanDevice *Device, const TArray< uint8 > &DeviceCache)
Definition VulkanGenericPlatform.cpp:48
static VkTimeDomainKHR GetTimeDomain()
Definition VulkanGenericPlatform.h:166
static void SetupFeatureLevels(TArrayView< EShaderPlatform > ShaderPlatformForFeatureLevel)
Definition VulkanGenericPlatform.cpp:28
static bool LoadVulkanInstanceFunctions(VkInstance inInstance)
Definition VulkanGenericPlatform.cpp:151
static bool RequiresMergedDepthStencilLayout()
Definition VulkanGenericPlatform.h:136
static void GetInstanceExtensions(FVulkanInstanceExtensionArray &OutExtensions)
static FString CreatePSOBinaryCacheFilename(FVulkanDevice *Device, FString CacheFilename)
Definition VulkanGenericPlatform.cpp:82
static FString GetVulkanProfileNameForFeatureLevel(ERHIFeatureLevel::Type FeatureLevel, bool bRaytracing)
Definition VulkanGenericPlatform.cpp:192
static void InitDevice(FVulkanDevice *InDevice)
Definition VulkanGenericPlatform.h:49
static ERHIFeatureLevel::Type GetFeatureLevel(ERHIFeatureLevel::Type RequestedFeatureLevel)
Definition VulkanGenericPlatform.cpp:39
static void GetInstanceLayers(TArray< const ANSICHAR * > &OutLayers)
Definition VulkanGenericPlatform.h:58
static bool RequiresSwapchainGeneralInitialLayout()
Definition VulkanGenericPlatform.h:109
static void PostInitGPU(const FVulkanDevice &InDevice)
Definition VulkanGenericPlatform.h:50
static bool SupportsNullPixelShader()
Definition VulkanGenericPlatform.h:130
static bool SupportsVolumeTextureRendering()
Definition VulkanGenericPlatform.h:107
static bool LoadVulkanLibrary()
Definition VulkanGenericPlatform.h:44
static void OverridePlatformHandlers(bool bInit)
Definition VulkanGenericPlatform.h:88
static bool RequiresWaitingForFrameCompletionEvent()
Definition VulkanGenericPlatform.h:127
Definition VulkanDevice.h:179
Definition VulkanRenderTargetLayout.h:8
Definition ArrayView.h:139
Definition Array.h:670
Definition SceneComponent.h:24
Type
Definition RHIFeatureLevel.h:20
int
Definition TestServer.py:515
Definition VulkanPipeline.h:127
Definition VulkanDevice.h:39