r.Vulkan.AllowPresentOnComputeQueue
r.Vulkan.AllowPresentOnComputeQueue
#Overview
name: r.Vulkan.AllowPresentOnComputeQueue
This variable is created as a Console Variable (cvar).
- type:
Var
- help:
0 to present on the graphics queue1 to allow presenting on the compute queue if available
It is referenced in 5
C++ source files.
#Summary
#Usage in the C++ source code
The purpose of r.Vulkan.AllowPresentOnComputeQueue is to control whether the Vulkan renderer in Unreal Engine can present frames on the compute queue instead of the graphics queue. This setting is specifically related to the Vulkan rendering system and affects how the engine interacts with the GPU for frame presentation.
The Vulkan RHI (Rendering Hardware Interface) subsystem relies on this setting variable. It’s primarily used in the VulkanDevice and VulkanSwapChain modules of the Unreal Engine.
The value of this variable is set through a console variable (CVar) system. It’s defined with a default value of 0, meaning by default, presentation occurs on the graphics queue. Developers can change this value at runtime or through configuration files.
This variable interacts closely with its associated variable GAllowPresentOnComputeQueue. They share the same value and are used interchangeably in the code.
Developers must be aware that enabling this feature (setting it to 1) may not work on all hardware. It’s particularly noted to have a fast path for AMD GPUs. Also, this setting interacts with the async compute settings (GRHIAllowAsyncComputeCvar), so developers should consider both when optimizing rendering performance.
Best practices when using this variable include:
- Testing thoroughly on target hardware, as not all GPUs may support or benefit from this feature.
- Considering the interaction with async compute settings.
- Monitoring performance metrics to ensure that enabling this feature actually improves performance in your specific use case.
Regarding the associated variable GAllowPresentOnComputeQueue:
The purpose of GAllowPresentOnComputeQueue is identical to r.Vulkan.AllowPresentOnComputeQueue. It’s an internal representation of the console variable used within the C++ code.
This variable is used directly in the Vulkan device creation process and in setting up the present queue. It’s checked to determine whether to allow presenting on the compute queue if it’s available and separate from the graphics queue.
The value of this variable is set by the CVar system, mirroring r.Vulkan.AllowPresentOnComputeQueue.
Developers should be aware that this variable is used in performance-critical paths during device initialization and frame presentation. Changing its value at runtime may not have an immediate effect, as some of these paths are typically executed during initialization.
Best practices for GAllowPresentOnComputeQueue align with those for r.Vulkan.AllowPresentOnComputeQueue. Additionally, developers working directly with the Vulkan RHI code should be cautious about introducing any additional overhead when checking this variable in performance-critical sections.
#References in C++ code
#Callsites
This variable is referenced in the following C++ source code:
#Loc: <Workspace>/Engine/Source/Runtime/VulkanRHI/Private/VulkanDevice.cpp:29
Scope: file
Source code excerpt:
TAutoConsoleVariable<int32> GAllowPresentOnComputeQueue(
TEXT("r.Vulkan.AllowPresentOnComputeQueue"),
0,
TEXT("0 to present on the graphics queue")
TEXT("1 to allow presenting on the compute queue if available")
);
TAutoConsoleVariable<int32> GCVarRobustBufferAccess(
#Associated Variable and Callsites
This variable is associated with another variable named GAllowPresentOnComputeQueue
. They share the same value. See the following C++ source code.
#Loc: <Workspace>/Engine/Source/Runtime/VulkanRHI/Private/VulkanDevice.cpp:28
Scope: file
Source code excerpt:
);
TAutoConsoleVariable<int32> GAllowPresentOnComputeQueue(
TEXT("r.Vulkan.AllowPresentOnComputeQueue"),
0,
TEXT("0 to present on the graphics queue")
TEXT("1 to allow presenting on the compute queue if available")
);
#Loc: <Workspace>/Engine/Source/Runtime/VulkanRHI/Private/VulkanDevice.cpp:366
Scope (from outer to inner):
file
function void FVulkanDevice::CreateDevice
Source code excerpt:
{
if (ComputeQueueFamilyIndex == -1 &&
(GRHIAllowAsyncComputeCvar.GetValueOnAnyThread() != 0 || GAllowPresentOnComputeQueue.GetValueOnAnyThread() != 0) && GfxQueueFamilyIndex != FamilyIndex)
{
ComputeQueueFamilyIndex = FamilyIndex;
bIsValidQueue = true;
}
}
#Loc: <Workspace>/Engine/Source/Runtime/VulkanRHI/Private/VulkanSwapChain.cpp:127
Scope: file
Source code excerpt:
#endif
extern TAutoConsoleVariable<int32> GAllowPresentOnComputeQueue;
static TSet<EPixelFormat> GPixelFormatNotSupportedWarning;
FVulkanSwapChain::FVulkanSwapChain(VkInstance InInstance, FVulkanDevice& InDevice, void* InWindowHandle, EPixelFormat& InOutPixelFormat, uint32 Width, uint32 Height, bool bIsFullScreen,
uint32* InOutDesiredNumBackBuffers, TArray<VkImage>& OutImages, int8 InLockToVsync, FVulkanSwapChainRecreateInfo* RecreateInfo)
: SwapChain(VK_NULL_HANDLE)
, Device(InDevice)
#Loc: <Workspace>/Engine/Source/Runtime/VulkanRHI/Private/VulkanSwapChain.cpp:992
Scope (from outer to inner):
file
function void FVulkanDevice::SetupPresentQueue
Source code excerpt:
SupportsPresent(Gpu, TransferQueue);
}
if (GAllowPresentOnComputeQueue.GetValueOnAnyThread() != 0 && ComputeQueue->GetFamilyIndex() != GfxQueue->GetFamilyIndex() && bCompute)
{
//#todo-rco: Do other IHVs have a fast path here?
bPresentOnComputeQueue = (VendorId == EGpuVendorId::Amd);
PresentQueue = ComputeQueue;
}
else