bDetectVulkanByDefault

bDetectVulkanByDefault

#Overview

name: bDetectVulkanByDefault

The value of this variable can be defined or overridden in .ini config files. 1 .ini config file referencing this setting variable.

It is referenced in 3 C++ source files.

#Summary

#Usage in the C++ source code

The purpose of bDetectVulkanByDefault is to control whether the Unreal Engine should automatically detect Vulkan device support on Android platforms when the project is packaged with Vulkan support.

This setting variable is primarily used by the Android runtime system within Unreal Engine 5. It is part of the AndroidRuntimeSettings class, which suggests it’s specifically tailored for Android platform configurations.

The value of this variable is set in the Android Runtime Settings, likely through the Unreal Engine editor interface or project configuration files. It can be overridden by the “-detectvulkan” command line parameter.

This variable interacts with other Vulkan-related checks and command line parameters, such as “bSupportsVulkan” and “-detectvulkan”.

Developers must be aware that:

  1. This setting only applies when the project is packaged with Vulkan support.
  2. If set to false, Vulkan detection can still be enabled using the “-detectvulkan” command line parameter.
  3. It affects the behavior of the IsVulkanAvailable() function in the Android platform-specific code.

Best practices when using this variable include:

  1. Enable it by default if your project targets Android devices with known Vulkan support.
  2. Disable it if you want more control over when Vulkan detection occurs, such as for debugging or performance testing scenarios.
  3. Consider the target audience of your application and the variety of Android devices it may run on when deciding whether to enable or disable this setting.
  4. Always test your application’s behavior with this setting both enabled and disabled to ensure proper functionality across different Android devices.

#Setting Variables

#References In INI files

Location: <Workspace>/Engine/Config/BaseEngine.ini:3044, section: [/Script/AndroidRuntimeSettings.AndroidRuntimeSettings]

#References in C++ code

#Callsites

This variable is referenced in the following C++ source code:

#Loc: <Workspace>/Engine/Source/Runtime/Android/AndroidRuntimeSettings/Classes/AndroidRuntimeSettings.h:445

Scope (from outer to inner):

file
class        class UAndroidRuntimeSettings : public UObject

Source code excerpt:

	// Whether to detect Vulkan device support by default, if the project is packaged with Vulkan support. If unchecked, the -detectvulkan commandline will enable Vulkan detection.
	UPROPERTY(GlobalConfig, EditAnywhere, AdvancedDisplay, Category = Build, meta = (DisplayName = "Detect Vulkan device support", EditCondition = "bSupportsVulkan"))
	bool bDetectVulkanByDefault;

	// Build the shipping config with hidden visibility by default. Results in smaller .so file but will also removes symbols used to display callstack dumps.
	UPROPERTY(GlobalConfig, EditAnywhere, Category = AdvancedBuild, meta = (DisplayName = "Build with hidden symbol visibility in shipping config."))
	bool bBuildWithHiddenSymbolVisibility;

	// Disables extra checks for buffer overflows, comes with perf improvement, but might make tracing stack corruptions in production harder. Note that _FORTIFY_SOURCE=2 is still enabled by the toolchain providing lightweight stack checks

#Loc: <Workspace>/Engine/Source/Runtime/Core/Private/Android/AndroidPlatformMisc.cpp:2342

Scope (from outer to inner):

file
function     bool FAndroidMisc::IsVulkanAvailable

Source code excerpt:


			// 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"));

			// @todo Lumin: Double check all this stuff after merging general android Vulkan SM5 from main
			const bool bSupportsVulkanSM5 = IsDesktopVulkanAvailable();

			const bool bVulkanDisabledCmdLine = FParse::Param(FCommandLine::Get(), TEXT("GL")) || FParse::Param(FCommandLine::Get(), TEXT("OpenGL"));

#Loc: <Workspace>/Engine/Source/Runtime/Core/Private/Android/AndroidPlatformMisc.cpp:2363

Scope (from outer to inner):

file
function     bool FAndroidMisc::IsVulkanAvailable

Source code excerpt:

				UE_LOG(LogAndroid, Log, TEXT("Vulkan API detection is disabled by a command line option."));
			}
            else if (!bDetectVulkanByDefault && !bDetectVulkanCmdLine)
			{
				UE_LOG(LogAndroid, Log, TEXT("Vulkan available but detection disabled by bDetectVulkanByDefault=False in AndroidRuntimeSettings. Use -detectvulkan to override."));
			}
			else
			{
				CachedVulkanAvailable = 1;