r.Vulkan.Depth24Bit

r.Vulkan.Depth24Bit

#Overview

name: r.Vulkan.Depth24Bit

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

This variable is created as a Console Variable (cvar).

It is referenced in 3 C++ source files.

#Summary

#Usage in the C++ source code

The purpose of r.Vulkan.Depth24Bit is to control the depth buffer format used in the Vulkan rendering backend of Unreal Engine 5. It allows developers to choose between a 32-bit float depth buffer and a 24-bit fixed point depth buffer.

This setting variable is primarily used by the Vulkan RHI (Runtime Hardware Interface) subsystem of Unreal Engine. It’s specifically implemented in the VulkanRHI module, which is responsible for interfacing with the Vulkan graphics API.

The value of this variable is set through the console variable system in Unreal Engine. It’s defined as a TAutoConsoleVariable with a default value of 0, meaning it defaults to using a 32-bit float depth buffer. Developers can change this value at runtime or through configuration files.

The associated variable CVarVulkanUseD24 directly interacts with r.Vulkan.Depth24Bit. They share the same value and purpose, with CVarVulkanUseD24 being the C++ representation of the console variable.

Developers must be aware that changing this variable affects the depth buffer precision. Using a 24-bit depth buffer (value 1) may improve performance or compatibility on some hardware, but at the cost of reduced depth precision compared to the 32-bit float buffer.

Best practices when using this variable include:

  1. Testing thoroughly on target hardware to ensure the chosen depth format doesn’t introduce visual artifacts or precision issues.
  2. Considering the requirements of your specific game or application. High-precision depth might be crucial for some scenarios, while others might benefit more from potential performance gains.
  3. Being aware that changing this setting might affect how depth-related calculations and effects work in your game.

Regarding the associated variable CVarVulkanUseD24:

#Setting Variables

#References In INI files

Location: <Workspace>/Engine/Config/BaseDeviceProfiles.ini:991, section: [Android_Xclipse_9xx_Vulkan DeviceProfile]

Location: <Workspace>/Engine/Config/BaseDeviceProfiles.ini:1003, section: [Android_Xclipse_xxx_Vulkan DeviceProfile]

Location: <Workspace>/Engine/Config/Android/AndroidEngine.ini:79, section: [ConsoleVariables]

#References in C++ code

#Callsites

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

#Loc: <Workspace>/Engine/Source/Runtime/VulkanRHI/Private/VulkanDevice.cpp:44

Scope: file

Source code excerpt:


static TAutoConsoleVariable<int32> CVarVulkanUseD24(
	TEXT("r.Vulkan.Depth24Bit"),
	0,
	TEXT("0: Use 32-bit float depth buffer (default)\n1: Use 24-bit fixed point depth buffer\n"),
	ECVF_ReadOnly
);

#Associated Variable and Callsites

This variable is associated with another variable named CVarVulkanUseD24. They share the same value. See the following C++ source code.

#Loc: <Workspace>/Engine/Source/Runtime/VulkanRHI/Private/VulkanDevice.cpp:43

Scope: file

Source code excerpt:

);

static TAutoConsoleVariable<int32> CVarVulkanUseD24(
	TEXT("r.Vulkan.Depth24Bit"),
	0,
	TEXT("0: Use 32-bit float depth buffer (default)\n1: Use 24-bit fixed point depth buffer\n"),
	ECVF_ReadOnly
);

#Loc: <Workspace>/Engine/Source/Runtime/VulkanRHI/Private/VulkanDevice.cpp:656

Scope (from outer to inner):

file
function     void FVulkanDevice::SetupFormats

Source code excerpt:

	}

	if (CVarVulkanUseD24.GetValueOnAnyThread() != 0)
	{
		// prefer VK_FORMAT_D24_UNORM_S8_UINT
		MapFormatSupport(PF_DepthStencil, { VK_FORMAT_D24_UNORM_S8_UINT, VK_FORMAT_D32_SFLOAT_S8_UINT, VK_FORMAT_D16_UNORM_S8_UINT }, ComponentMappingRIII);
		MapFormatSupport(PF_X24_G8, { VK_FORMAT_D24_UNORM_S8_UINT, VK_FORMAT_D32_SFLOAT_S8_UINT, VK_FORMAT_D16_UNORM_S8_UINT }, ComponentMappingRR01);
		GPixelFormats[PF_DepthStencil].bIs24BitUnormDepthStencil = true;
	}