r.Vulkan.SubmitOnDispatch
r.Vulkan.SubmitOnDispatch
#Overview
name: r.Vulkan.SubmitOnDispatch
This variable is created as a Console Variable (cvar).
- type:
Var
- help:
0 to not do anything special on dispatch(default)\n1 to submit the cmd buffer after each dispatch
It is referenced in 4
C++ source files.
#Summary
#Usage in the C++ source code
The purpose of r.Vulkan.SubmitOnDispatch is to control the submission behavior of Vulkan command buffers after compute shader dispatches in Unreal Engine 5’s Vulkan RHI (Rendering Hardware Interface) implementation.
This setting variable is primarily used in the Vulkan RHI subsystem of Unreal Engine 5. Specifically, it affects the behavior of compute shader dispatches in the Vulkan rendering backend.
The value of this variable is set through the Unreal Engine console variable system. It is defined as a TAutoConsoleVariable with a default value of 0, which means by default, no special action is taken after a compute shader dispatch.
The associated variable GCVarSubmitOnDispatch directly interacts with r.Vulkan.SubmitOnDispatch. They share the same value and purpose.
Developers must be aware that when this variable is set to 1, it will cause the command buffer to be submitted after each compute shader dispatch. This can have performance implications, as it may lead to more frequent command buffer submissions.
Best practices for using this variable include:
- Leaving it at the default value (0) unless there’s a specific need to submit command buffers after each dispatch.
- Using it for debugging purposes when investigating issues related to compute shader execution or synchronization.
- Being cautious about enabling it in performance-critical scenarios, as it may introduce additional overhead.
Regarding the associated variable GCVarSubmitOnDispatch:
- It serves the same purpose as r.Vulkan.SubmitOnDispatch.
- It is used directly in the C++ code to check the current setting and determine whether to submit the command buffer after a dispatch.
- The variable is accessed using GetValueOnRenderThread() to ensure thread-safe access in the render thread.
- It affects both regular compute shader dispatches (RHIDispatchComputeShader) and indirect compute shader dispatches (RHIDispatchIndirectComputeShader).
When using GCVarSubmitOnDispatch, developers should follow the same best practices as mentioned for r.Vulkan.SubmitOnDispatch. They should also be aware that changes to this variable will take effect on the render thread, which is why GetValueOnRenderThread() is used to access its value.
#References in C++ code
#Callsites
This variable is referenced in the following C++ source code:
#Loc: <Workspace>/Engine/Source/Runtime/VulkanRHI/Private/VulkanCommands.cpp:16
Scope: file
Source code excerpt:
static TAutoConsoleVariable<int32> GCVarSubmitOnDispatch(
TEXT("r.Vulkan.SubmitOnDispatch"),
0,
TEXT("0 to not do anything special on dispatch(default)\n")\
TEXT("1 to submit the cmd buffer after each dispatch"),
ECVF_RenderThreadSafe
);
#Associated Variable and Callsites
This variable is associated with another variable named GCVarSubmitOnDispatch
. They share the same value. See the following C++ source code.
#Loc: <Workspace>/Engine/Source/Runtime/VulkanRHI/Private/VulkanCommands.cpp:15
Scope: file
Source code excerpt:
#include "RHICoreShader.h"
static TAutoConsoleVariable<int32> GCVarSubmitOnDispatch(
TEXT("r.Vulkan.SubmitOnDispatch"),
0,
TEXT("0 to not do anything special on dispatch(default)\n")\
TEXT("1 to submit the cmd buffer after each dispatch"),
ECVF_RenderThreadSafe
);
#Loc: <Workspace>/Engine/Source/Runtime/VulkanRHI/Private/VulkanCommands.cpp:272
Scope (from outer to inner):
file
function void FVulkanCommandListContext::RHIDispatchComputeShader
Source code excerpt:
VulkanRHI::vkCmdDispatch(CmdBuffer, ThreadGroupCountX, ThreadGroupCountY, ThreadGroupCountZ);
if (GCVarSubmitOnDispatch.GetValueOnRenderThread())
{
InternalSubmitActiveCmdBuffer();
}
if (FVulkanPlatform::RegisterGPUWork() && IsImmediate())
{
#Loc: <Workspace>/Engine/Source/Runtime/VulkanRHI/Private/VulkanCommands.cpp:299
Scope (from outer to inner):
file
function void FVulkanCommandListContext::RHIDispatchIndirectComputeShader
Source code excerpt:
VulkanRHI::vkCmdDispatchIndirect(CmdBuffer, ArgumentBuffer->GetHandle(), ArgumentBuffer->GetOffset() + ArgumentOffset);
if (GCVarSubmitOnDispatch.GetValueOnRenderThread())
{
InternalSubmitActiveCmdBuffer();
}
if (FVulkanPlatform::RegisterGPUWork()/* && IsImmediate()*/)
{