r.Vulkan.Allow16bitOps
r.Vulkan.Allow16bitOps
#Overview
name: r.Vulkan.Allow16bitOps
This variable is created as a Console Variable (cvar).
- type:
Var
- help:
Whether to enable 16bit ops to speeds up TSR\n0 to disable (default)\n1 to enable
It is referenced in 4
C++ source files.
#Summary
#Usage in the C++ source code
The purpose of r.Vulkan.Allow16bitOps is to control whether 16-bit operations are enabled in the Vulkan rendering system to potentially speed up Temporal Super Resolution (TSR) processing.
This setting variable is primarily used within the Vulkan RHI (Runtime Hardware Interface) subsystem of Unreal Engine 5. It specifically affects the behavior of Vulkan extensions related to 16-bit storage and shader operations.
The value of this variable is set through a console variable (CVarRef) named GRHIAllow16bitOps. It is initialized with a default value of 0 (disabled) and can be changed at runtime. However, it is marked as ECVF_ReadOnly, which means it should typically be set before the engine fully initializes.
The associated variable GRHIAllow16bitOps directly interacts with r.Vulkan.Allow16bitOps. They share the same value and purpose.
Developers must be aware that enabling this feature (by setting it to 1) may affect rendering performance and potentially introduce compatibility issues with certain hardware. It should be thoroughly tested on target platforms before being enabled in production.
Best practices when using this variable include:
- Only enable it if you’re specifically optimizing for TSR performance on Vulkan.
- Test thoroughly on all target hardware to ensure compatibility and performance gains.
- Consider making it a configurable option for end-users, allowing them to enable/disable based on their hardware capabilities.
Regarding the associated variable GRHIAllow16bitOps:
- It is used to actually implement the behavior controlled by r.Vulkan.Allow16bitOps.
- It is checked in the constructors of FVulkanKHR16BitStorageExtension and FVulkanKHRShaderFloat16Int8Extension to determine whether these Vulkan extensions should be enabled.
- When using this variable in code, always use the GetValueOnAnyThread() method to retrieve its current value, as seen in the provided code excerpts.
- Be aware that changes to this variable after engine initialization may not affect already-constructed Vulkan extensions.
#References in C++ code
#Callsites
This variable is referenced in the following C++ source code:
#Loc: <Workspace>/Engine/Source/Runtime/VulkanRHI/Private/VulkanExtensions.cpp:35
Scope: file
Source code excerpt:
TAutoConsoleVariable<int32> GRHIAllow16bitOps(
TEXT("r.Vulkan.Allow16bitOps"),
0,
TEXT("Whether to enable 16bit ops to speeds up TSR\n")
TEXT("0 to disable (default)\n")
TEXT("1 to enable"),
ECVF_ReadOnly
);
#Associated Variable and Callsites
This variable is associated with another variable named GRHIAllow16bitOps
. They share the same value. See the following C++ source code.
#Loc: <Workspace>/Engine/Source/Runtime/VulkanRHI/Private/VulkanExtensions.cpp:34
Scope: file
Source code excerpt:
);
TAutoConsoleVariable<int32> GRHIAllow16bitOps(
TEXT("r.Vulkan.Allow16bitOps"),
0,
TEXT("Whether to enable 16bit ops to speeds up TSR\n")
TEXT("0 to disable (default)\n")
TEXT("1 to enable"),
ECVF_ReadOnly
#Loc: <Workspace>/Engine/Source/Runtime/VulkanRHI/Private/VulkanExtensions.cpp:1204
Scope (from outer to inner):
file
class class FVulkanKHR16BitStorageExtension : public FVulkanDeviceExtension
function FVulkanKHR16BitStorageExtension
Source code excerpt:
: FVulkanDeviceExtension(InDevice, VK_KHR_16BIT_STORAGE_EXTENSION_NAME, VULKAN_EXTENSION_ENABLED)
{
bEnabledInCode = bEnabledInCode && (GRHIAllow16bitOps.GetValueOnAnyThread() != 0);
}
virtual void PrePhysicalDeviceFeatures(VkPhysicalDeviceFeatures2KHR& PhysicalDeviceFeatures2) override final
{
ZeroVulkanStruct(Device16BitStorageFeatures, VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_16BIT_STORAGE_FEATURES_KHR);
AddToPNext(PhysicalDeviceFeatures2, Device16BitStorageFeatures);
#Loc: <Workspace>/Engine/Source/Runtime/VulkanRHI/Private/VulkanExtensions.cpp:1241
Scope (from outer to inner):
file
class class FVulkanKHRShaderFloat16Int8Extension : public FVulkanDeviceExtension
function FVulkanKHRShaderFloat16Int8Extension
Source code excerpt:
: FVulkanDeviceExtension(InDevice, VK_KHR_SHADER_FLOAT16_INT8_EXTENSION_NAME, VULKAN_EXTENSION_ENABLED)
{
bEnabledInCode = bEnabledInCode && (GRHIAllow16bitOps.GetValueOnAnyThread() != 0);
}
virtual void PrePhysicalDeviceFeatures(VkPhysicalDeviceFeatures2KHR& PhysicalDeviceFeatures2) override final
{
ZeroVulkanStruct(ShaderFloat16Int8Features, VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_SHADER_FLOAT16_INT8_FEATURES_KHR);
AddToPNext(PhysicalDeviceFeatures2, ShaderFloat16Int8Features);