bSupportsVulkan
bSupportsVulkan
#Overview
name: bSupportsVulkan
The value of this variable can be defined or overridden in .ini config files. 2
.ini config files referencing this setting variable.
It is referenced in 10
C++ source files. Also referenced in 3
C# build files meaning it may affect the build system logic.
#Summary
#Usage in the C++ source code
The purpose of bSupportsVulkan is to enable or disable support for the Vulkan graphics API in Unreal Engine projects targeting Android platforms. This setting is primarily used in the rendering system to determine whether Vulkan should be supported for Android devices.
This setting variable is mainly relied upon by the Android-specific subsystems and modules of Unreal Engine, including:
- AndroidPlatformEditor
- AndroidTargetPlatformSettings
- LauncherServices
- AndroidRuntimeSettings
- AndroidPlatformMisc
The value of this variable is set in the Android Runtime Settings, which can be accessed and modified through the project settings in the Unreal Engine editor. It is stored in the engine configuration files.
This variable interacts with other related variables, such as:
- bBuildForES31 (for OpenGL ES 3.1 support)
- bSupportsVulkanSM5 (for Vulkan SM5 support)
Developers must be aware of the following when using this variable:
- Changing this setting may invalidate shader caches and require recompilation of shaders.
- It affects the available rendering features and performance on Android devices.
- It may impact compatibility with certain Android devices or versions.
Best practices when using this variable include:
- Consider the target Android devices and their Vulkan support before enabling or disabling this option.
- Test the application thoroughly on various Android devices when changing this setting.
- Be aware of the performance implications and shader compilation times when switching between Vulkan and OpenGL ES.
- Ensure that at least one GPU architecture (Vulkan, OpenGL ES, or Vulkan SM5) is supported in the project settings.
- Consider using the bDetectVulkanByDefault option for more flexible Vulkan detection on Android devices.
#Usage in the C# source code and build system
The purpose of bSupportsVulkan is to indicate whether the Android project supports the Vulkan graphics API. This setting is crucial for the rendering system, particularly for Android game development using Unreal Engine.
Based on the provided code snippets, the Android build system of Unreal Engine relies on this setting variable. Specifically, it’s used in the UEDeployAndroid.cs file, which is part of the UnrealBuildTool for Android platform deployment.
The value of this variable is set in the Android Runtime Settings, which can be accessed and modified through the Unreal Engine editor. The exact configuration path is “/Script/AndroidRuntimeSettings.AndroidRuntimeSettings”.
This variable interacts with other variables, notably:
- bSupportsVulkanSM5: Another boolean variable related to Vulkan support for Shader Model 5.
- bBuildForES31: A boolean variable likely related to OpenGL ES 3.1 support.
Developers must be aware that:
- This setting affects the build process for Android platforms.
- It determines whether Vulkan-related files and layers are included in the build.
- It’s used in conjunction with the build configuration (e.g., Shipping) to determine certain build behaviors.
Best practices when using this variable include:
- Ensure it’s set correctly based on your project’s graphics requirements and target Android devices.
- Consider the implications on build size and performance when enabling Vulkan support.
- Test thoroughly on various Android devices when changing this setting, as it can significantly impact rendering behavior.
Regarding the associated variable bSupportsVulkanSM5:
The purpose of bSupportsVulkanSM5 is to indicate whether the Android project supports Vulkan with Shader Model 5 features. This is an extension of the basic Vulkan support, enabling more advanced graphics capabilities.
This variable is also used in the Android deployment system of Unreal Engine, specifically in the UEDeployAndroid.cs file.
Like bSupportsVulkan, its value is set in the Android Runtime Settings ("/Script/AndroidRuntimeSettings.AndroidRuntimeSettings").
It interacts directly with bSupportsVulkan. Both variables are used together to determine whether to copy Vulkan layers during the build process.
Developers should be aware that:
- This setting enables more advanced Vulkan features, which may not be supported on all Android devices.
- It may impact performance and compatibility on lower-end devices.
Best practices include:
- Only enable this if your project requires Shader Model 5 features and you’re targeting high-end Android devices.
- Thoroughly test on a range of devices to ensure compatibility and performance when this is enabled.
- Consider offering graphics options in your game to allow users to choose between different quality levels, which may involve switching between basic Vulkan and Vulkan SM5 at runtime.
#Setting Variables
#References In INI files
Location: <Workspace>/Engine/Config/BaseEngine.ini:3042, section: [/Script/AndroidRuntimeSettings.AndroidRuntimeSettings]
- INI Section:
/Script/AndroidRuntimeSettings.AndroidRuntimeSettings
- Raw value:
true
- Is Array:
False
Location: <Workspace>/Projects/Lyra/Config/DefaultEngine.ini:282, section: [/Script/AndroidRuntimeSettings.AndroidRuntimeSettings]
- INI Section:
/Script/AndroidRuntimeSettings.AndroidRuntimeSettings
- Raw value:
True
- Is Array:
False
#References in C++ code
#Callsites
This variable is referenced in the following C++ source code:
#Loc: <Workspace>/Engine/Source/Developer/Android/AndroidPlatformEditor/Private/AndroidPlatformEditorModule.cpp:123
Scope (from outer to inner):
file
class class FAndroidPlatformEditorModule : public IModuleInterface
function virtual void StartupModule
lambda-function
Source code excerpt:
}
if (PropertyChangedEvent.Property->GetFName() == GET_MEMBER_NAME_CHECKED(UAndroidRuntimeSettings, bSupportsVulkan) &&
AndroidRuntimeSettings->bSupportsVulkan == false)
{
FCoreDelegates::OnFeatureLevelDisabled.Broadcast(ERHIFeatureLevel::ES3_1, LegacyShaderPlatformToShaderFormat(SP_VULKAN_ES3_1_ANDROID));
return;
}
}
#Loc: <Workspace>/Engine/Source/Developer/Android/AndroidTargetPlatformSettings/Private/AndroidTargetPlatformSettings.cpp:37
Scope (from outer to inner):
file
function bool FAndroidTargetPlatformSettings::SupportsVulkan
Source code excerpt:
{
// default to not supporting Vulkan
bool bSupportsVulkan = false;
#if WITH_ENGINE
GConfig->GetBool(TEXT("/Script/AndroidRuntimeSettings.AndroidRuntimeSettings"), TEXT("bSupportsVulkan"), bSupportsVulkan, GEngineIni);
#endif
return bSupportsVulkan;
}
bool FAndroidTargetPlatformSettings::SupportsVulkanSM5() const
{
// default to no support for VulkanSM5
bool bSupportsMobileVulkanSM5 = false;
#Loc: <Workspace>/Engine/Source/Developer/LauncherServices/Private/Launcher/LauncherWorker.cpp:347
Scope (from outer to inner):
file
function static void AddDeviceToLaunchCommand
Source code excerpt:
bool bAndroidSupportsVulkan, bAndroidSupportsVulkanSM5;
AndroidEngineSettings.GetBool(TEXT("/Script/AndroidRuntimeSettings.AndroidRuntimeSettings"), TEXT("bSupportsVulkan"), bAndroidSupportsVulkan);
AndroidEngineSettings.GetBool(TEXT("/Script/AndroidRuntimeSettings.AndroidRuntimeSettings"), TEXT("bSupportsVulkanSM5"), bAndroidSupportsVulkanSM5);
bCookedVulkan = bAndroidSupportsVulkan || bAndroidSupportsVulkanSM5;
bCheckTargetedRHIs = false;
}
if (bCheckTargetedRHIs)
#Loc: <Workspace>/Engine/Source/Runtime/Android/AndroidRuntimeSettings/Classes/AndroidRuntimeSettings.h:421
Scope (from outer to inner):
file
class class UAndroidRuntimeSettings : public UObject
Source code excerpt:
// Support the Vulkan RHI and include Vulkan shaders
UPROPERTY(GlobalConfig, EditAnywhere, Category = Build, meta = (DisplayName = "Support Vulkan"))
bool bSupportsVulkan;
// Enable Vulkan SM5 rendering support
UPROPERTY(GlobalConfig, EditAnywhere, Category = Build, meta = (DisplayName = "Support Vulkan Desktop [Experimental]", EditCondition = "!bPackageForMetaQuest"))
bool bSupportsVulkanSM5;
/** Directory for Debug Vulkan Layers to package */
#Loc: <Workspace>/Engine/Source/Runtime/Android/AndroidRuntimeSettings/Private/AndroidRuntimeSettings.cpp:47
Scope (from outer to inner):
file
function UAndroidRuntimeSettings::UAndroidRuntimeSettings
Source code excerpt:
, bStreamLandscapeMeshLODs(false)
{
bBuildForES31 = bBuildForES31 || !bSupportsVulkan;
}
void UAndroidRuntimeSettings::PostReloadConfig(FProperty* PropertyThatWasLoaded)
{
Super::PostReloadConfig(PropertyThatWasLoaded);
#Loc: <Workspace>/Engine/Source/Runtime/Android/AndroidRuntimeSettings/Private/AndroidRuntimeSettings.cpp:131
Scope (from outer to inner):
file
function void UAndroidRuntimeSettings::HandleMetaQuestSupport
Source code excerpt:
UE_LOG(LogAndroidRuntimeSettings, Display, TEXT("Enabled Package for Meta Quest devices.\nThe following settings have been applied:\n"));
UE_LOG(LogAndroidRuntimeSettings, Display, TEXT("Support arm64: %d.\n"), bBuildForArm64);
UE_LOG(LogAndroidRuntimeSettings, Display, TEXT("Support Vulkan: %d.\n"), bSupportsVulkan);
UE_LOG(LogAndroidRuntimeSettings, Display, TEXT("Support x86_64: %d.\n"), bBuildForX8664);
UE_LOG(LogAndroidRuntimeSettings, Display, TEXT("Support Vulkan Desktop: %d.\n"), bSupportsVulkanSM5);
UE_LOG(LogAndroidRuntimeSettings, Display, TEXT("Support OpenGL ES3.2: %d."), bBuildForES31);
int32 SupportedDevicesTagIndex = ExtraApplicationSettings.Find("com.oculus.supportedDevices");
FString SupportedDevicesValue("quest|quest2|questpro|quest3");
#Loc: <Workspace>/Engine/Source/Runtime/Android/AndroidRuntimeSettings/Private/AndroidRuntimeSettings.cpp:195
Scope (from outer to inner):
file
function void UAndroidRuntimeSettings::PostEditChangeProperty
Source code excerpt:
if (PropertyChangedEvent.Property != nullptr)
{
if (PropertyChangedEvent.Property->GetFName() == GET_MEMBER_NAME_CHECKED(UAndroidRuntimeSettings, bSupportsVulkan) ||
PropertyChangedEvent.Property->GetFName() == GET_MEMBER_NAME_CHECKED(UAndroidRuntimeSettings, bBuildForES31))
{
// Supported shader formats changed so invalidate cache
InvalidateAllAndroidPlatforms();
OnPropertyChanged.Broadcast(PropertyChangedEvent);
#Loc: <Workspace>/Engine/Source/Runtime/Android/AndroidRuntimeSettings/Private/AndroidRuntimeSettings.cpp:266
Scope (from outer to inner):
file
function void UAndroidRuntimeSettings::EnsureValidGPUArch
Source code excerpt:
{
// Ensure that at least one GPU architecture is supported
if (!bSupportsVulkan && !bBuildForES31 && !bSupportsVulkanSM5)
{
UE_LOG(LogAndroidRuntimeSettings, Warning, TEXT("No GPU architecture is selected.\n"));
// Default to Vulkan for Meta Quest devices
if (bPackageForMetaQuest)
{
bSupportsVulkan = true;
UpdateSinglePropertyInConfigFile(GetClass()->FindPropertyByName(GET_MEMBER_NAME_CHECKED(UAndroidRuntimeSettings, bSupportsVulkan)), GetDefaultConfigFilename());
UE_LOG(LogAndroidRuntimeSettings, Warning, TEXT("Support Vulkan has been changed to true.\n"));
}
else
{
bBuildForES31 = true;
UpdateSinglePropertyInConfigFile(GetClass()->FindPropertyByName(GET_MEMBER_NAME_CHECKED(UAndroidRuntimeSettings, bBuildForES31)), GetDefaultConfigFilename());
#Loc: <Workspace>/Engine/Source/Runtime/Core/Private/Android/AndroidPlatformMisc.cpp:2338
Scope (from outer to inner):
file
function bool FAndroidMisc::IsVulkanAvailable
Source code excerpt:
if (VulkanSupport == EDeviceVulkanSupportStatus::Supported)
{
bool bSupportsVulkan = false;
GConfig->GetBool(TEXT("/Script/AndroidRuntimeSettings.AndroidRuntimeSettings"), TEXT("bSupportsVulkan"), bSupportsVulkan, GEngineIni);
// whether to detect Vulkan by default or require the -detectvulkan command line parameter
bool bDetectVulkanByDefault = true;
GConfig->GetBool(TEXT("/Script/AndroidRuntimeSettings.AndroidRuntimeSettings"), TEXT("bDetectVulkanByDefault"), bDetectVulkanByDefault, GEngineIni);
const bool bDetectVulkanCmdLine = FParse::Param(FCommandLine::Get(), TEXT("detectvulkan"));
#Loc: <Workspace>/Engine/Source/Runtime/Core/Private/Android/AndroidPlatformMisc.cpp:2355
Scope (from outer to inner):
file
function bool FAndroidMisc::IsVulkanAvailable
Source code excerpt:
UE_LOG(LogAndroid, Log, TEXT("Vulkan not available as VulkanRHI not present."));
}
else if (!(bSupportsVulkan || bSupportsVulkanSM5))
{
UE_LOG(LogAndroid, Log, TEXT("Vulkan not available as project packaged without bSupportsVulkan or bSupportsVulkanSM5."));
}
else if (bVulkanDisabledCmdLine)
{
UE_LOG(LogAndroid, Log, TEXT("Vulkan API detection is disabled by a command line option."));
#References in C# build files
This variable is referenced in the following C# build files:
Location: <Workspace>/Engine/Source/Programs/UnrealBuildTool/Platform/Android/UEDeployAndroid.cs:2657
Ini.GetBool("/Script/AndroidRuntimeSettings.AndroidRuntimeSettings", "bBuildForES31", out bBuildForES31);
bool bSupportsVulkan = false;
Ini.GetBool("/Script/AndroidRuntimeSettings.AndroidRuntimeSettings", "bSupportsVulkan", out bSupportsVulkan);
int PropagateAlpha = 0;
Ini.GetInt32("/Script/Engine.RendererSettings", "r.Mobile.PropagateAlpha", out PropagateAlpha);
bool bAllowIMU = true;
Ini.GetBool("/Script/AndroidRuntimeSettings.AndroidRuntimeSettings", "bAllowIMU", out bAllowIMU);
Location: <Workspace>/Engine/Source/Programs/UnrealBuildTool/Platform/Android/UEDeployAndroid.cs:1443
bool bSupportsVulkanSM5 = false;
ConfigHierarchy Ini = GetConfigCacheIni(ConfigHierarchyType.Engine);
Ini.GetBool("/Script/AndroidRuntimeSettings.AndroidRuntimeSettings", "bSupportsVulkan", out bSupportsVulkan);
Ini.GetBool("/Script/AndroidRuntimeSettings.AndroidRuntimeSettings", "bSupportsVulkanSM5", out bSupportsVulkanSM5);
bool bCopyVulkanLayers = (bSupportsVulkan || bSupportsVulkanSM5) && (Configuration != "Shipping");
if (bCopyVulkanLayers)
{
string VulkanLayersDir = Path.Combine(Unreal.EngineDirectory.ToString(), "Binaries", "ThirdParty", "Vulkan", "Android", NDKArch);
Location: <Workspace>/Engine/Source/Programs/UnrealBuildTool/Platform/Android/UEDeployAndroid.cs:1432
Ini.GetBool("/Script/AndroidRuntimeSettings.AndroidRuntimeSettings", "bBuildForES31", out bBuildForES31);
bool bSupportsVulkan = false;
Ini.GetBool("/Script/AndroidRuntimeSettings.AndroidRuntimeSettings", "bSupportsVulkan", out bSupportsVulkan);
Logger.LogInformation("bBuildForES31: {bBuildForES31}", (bBuildForES31 ? "true" : "false"));
Logger.LogInformation("bSupportsVulkan: {bSupportsVulkan}", (bSupportsVulkan ? "true" : "false"));
}
void CopyVulkanValidationLayers(string UnrealBuildPath, UnrealArch UnrealArch, string NDKArch, string Configuration)