au.RenderThreadPriority
au.RenderThreadPriority
#Overview
name: au.RenderThreadPriority
This variable is created as a Console Variable (cvar).
- type:
Var
- help:
Sets audio render thread priority. Defaults to 3.\n0: Normal, 1: Above Normal, 2: Below Normal, 3: Highest, 4: Lowest, 5: Slightly Below Normal, 6: Time Critical
It is referenced in 3
C++ source files.
#Summary
#Usage in the C++ source code
The purpose of au.RenderThreadPriority is to set the priority of the audio render thread in Unreal Engine 5. This setting variable is part of the audio system and specifically affects the threading behavior of audio rendering.
This setting variable is primarily used by the AudioMixerCore module, which is a core component of Unreal Engine’s audio system. The variable is defined and used within the AudioMixer.cpp file, indicating its importance in the audio mixing process.
The value of this variable is set through a console variable (CVar) system. It’s initialized with a default value of 3, which corresponds to the highest priority (TPri_Highest). Users can modify this value through the console or configuration files.
The au.RenderThreadPriority variable interacts directly with the SetRenderThreadPriorityCVar variable. They share the same value, with SetRenderThreadPriorityCVar being the actual storage for the priority value.
Developers must be aware that this variable affects the scheduling priority of the audio render thread. Changing this value can impact the overall performance and responsiveness of the audio system, potentially affecting other systems if set too high.
Best practices when using this variable include:
- Carefully consider the impact on overall system performance before changing from the default value.
- Test thoroughly after making changes, especially on target platforms.
- Be aware of platform-specific behavior differences when setting thread priorities.
- Use in conjunction with profiling tools to ensure optimal audio performance.
Regarding the associated variable SetRenderThreadPriorityCVar:
The purpose of SetRenderThreadPriorityCVar is to store the actual integer value representing the audio render thread priority. It serves as the backing storage for the au.RenderThreadPriority console variable.
This variable is used directly in the AudioMixerCore module, specifically when creating the audio render thread. It’s converted to an EThreadPriority enum when passed to the thread creation function.
The value of SetRenderThreadPriorityCVar is set through the au.RenderThreadPriority console variable. Any changes to au.RenderThreadPriority will be reflected in SetRenderThreadPriorityCVar.
SetRenderThreadPriorityCVar interacts with the FRunnableThread::Create function, where it’s used to set the priority of the newly created audio render thread.
Developers should be aware that this variable is the actual storage used when creating the audio render thread, so its value at the time of thread creation is what matters.
Best practices for SetRenderThreadPriorityCVar are similar to those for au.RenderThreadPriority, as they are essentially two sides of the same coin. Always consider the implications of changing thread priorities on overall system performance and stability.
#References in C++ code
#Callsites
This variable is referenced in the following C++ source code:
#Loc: <Workspace>/Engine/Source/Runtime/AudioMixerCore/Private/AudioMixer.cpp:49
Scope: file
Source code excerpt:
static int32 SetRenderThreadPriorityCVar = (int32)TPri_Highest;
FAutoConsoleVariableRef CVarSetRenderThreadPriority(
TEXT("au.RenderThreadPriority"),
SetRenderThreadPriorityCVar,
TEXT("Sets audio render thread priority. Defaults to 3.\n")
TEXT("0: Normal, 1: Above Normal, 2: Below Normal, 3: Highest, 4: Lowest, 5: Slightly Below Normal, 6: Time Critical"),
ECVF_Default);
static int32 SetRenderThreadAffinityCVar = 0;
#Associated Variable and Callsites
This variable is associated with another variable named SetRenderThreadPriorityCVar
. They share the same value. See the following C++ source code.
#Loc: <Workspace>/Engine/Source/Runtime/AudioMixerCore/Private/AudioMixer.cpp:47
Scope: file
Source code excerpt:
// Command for setting the audio render thread priority.
static int32 SetRenderThreadPriorityCVar = (int32)TPri_Highest;
FAutoConsoleVariableRef CVarSetRenderThreadPriority(
TEXT("au.RenderThreadPriority"),
SetRenderThreadPriorityCVar,
TEXT("Sets audio render thread priority. Defaults to 3.\n")
TEXT("0: Normal, 1: Above Normal, 2: Below Normal, 3: Highest, 4: Lowest, 5: Slightly Below Normal, 6: Time Critical"),
ECVF_Default);
static int32 SetRenderThreadAffinityCVar = 0;
FAutoConsoleVariableRef CVarRenderThreadAffinity(
#Loc: <Workspace>/Engine/Source/Runtime/AudioMixerCore/Private/AudioMixer.cpp:653
Scope (from outer to inner):
file
namespace Audio
function void IAudioMixerPlatformInterface::BeginGeneratingAudio
Source code excerpt:
check(!AudioRenderThread.IsValid());
uint64 RenderThreadAffinityCVar = SetRenderThreadAffinityCVar > 0 ? uint64(SetRenderThreadAffinityCVar) : FPlatformAffinity::GetAudioRenderThreadMask();
AudioRenderThread.Reset(FRunnableThread::Create(this, *FString::Printf(TEXT("AudioMixerRenderThread(%d)"), AudioMixerTaskCounter.Increment()), 0, (EThreadPriority)SetRenderThreadPriorityCVar, RenderThreadAffinityCVar));
check(AudioRenderThread.IsValid());
}
void IAudioMixerPlatformInterface::StopGeneratingAudio()
{
SCOPED_NAMED_EVENT(IAudioMixerPlatformInterface_StopGeneratingAudio, FColor::Blue);