r.Vulkan.SubmitOnDispatch

r.Vulkan.SubmitOnDispatch

#Overview

name: r.Vulkan.SubmitOnDispatch

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

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:

  1. Leaving it at the default value (0) unless there’s a specific need to submit command buffers after each dispatch.
  2. Using it for debugging purposes when investigating issues related to compute shader execution or synchronization.
  3. Being cautious about enabling it in performance-critical scenarios, as it may introduce additional overhead.

Regarding the associated variable GCVarSubmitOnDispatch:

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()*/)
	{