au.RenderThreadAffinity
au.RenderThreadAffinity
#Overview
name: au.RenderThreadAffinity
This variable is created as a Console Variable (cvar).
- type:
Var
- help:
Override audio render thread affinity.\n0: Disabled (Default), otherwise overriden thread affinity.
It is referenced in 3
C++ source files.
#Summary
#Usage in the C++ source code
The purpose of au.RenderThreadAffinity is to control the CPU affinity of the audio render thread in Unreal Engine’s audio mixer system. It allows developers to override the default thread affinity settings for the audio rendering process.
This setting variable is primarily used by the Audio Mixer Core module of Unreal Engine. It’s part of the audio rendering system, which is responsible for processing and mixing audio in real-time.
The value of this variable is set through the console variable system in Unreal Engine. It’s defined as a static integer (SetRenderThreadAffinityCVar) and linked to the console variable “au.RenderThreadAffinity” using FAutoConsoleVariableRef.
The associated variable SetRenderThreadAffinityCVar interacts directly with au.RenderThreadAffinity. They share the same value, with SetRenderThreadAffinityCVar being the actual storage for the setting.
Developers should be aware that:
- The default value is 0, which means the audio render thread affinity is disabled (uses engine default).
- Any non-zero value will override the default thread affinity.
- This setting can impact audio performance and CPU usage, so it should be used carefully.
Best practices when using this variable include:
- Only modify if there are specific performance issues related to audio rendering.
- Test thoroughly after changing this value to ensure it doesn’t negatively impact overall performance or audio quality.
- Consider the target hardware when setting a specific affinity, as optimal settings may vary between different CPU architectures.
Regarding the associated variable SetRenderThreadAffinityCVar:
- It’s the actual storage for the au.RenderThreadAffinity setting.
- It’s used directly in the code to determine the thread affinity when creating the audio render thread.
- If its value is greater than 0, it’s used as the thread affinity mask. Otherwise, the engine uses FPlatformAffinity::GetAudioRenderThreadMask() to determine the affinity.
- Developers should not modify this variable directly, but instead use the console variable au.RenderThreadAffinity to change its value.
#References in C++ code
#Callsites
This variable is referenced in the following C++ source code:
#Loc: <Workspace>/Engine/Source/Runtime/AudioMixerCore/Private/AudioMixer.cpp:57
Scope: file
Source code excerpt:
static int32 SetRenderThreadAffinityCVar = 0;
FAutoConsoleVariableRef CVarRenderThreadAffinity(
TEXT("au.RenderThreadAffinity"),
SetRenderThreadAffinityCVar,
TEXT("Override audio render thread affinity.\n")
TEXT("0: Disabled (Default), otherwise overriden thread affinity."),
ECVF_Default);
#Associated Variable and Callsites
This variable is associated with another variable named SetRenderThreadAffinityCVar
. They share the same value. See the following C++ source code.
#Loc: <Workspace>/Engine/Source/Runtime/AudioMixerCore/Private/AudioMixer.cpp:55
Scope: file
Source code excerpt:
ECVF_Default);
static int32 SetRenderThreadAffinityCVar = 0;
FAutoConsoleVariableRef CVarRenderThreadAffinity(
TEXT("au.RenderThreadAffinity"),
SetRenderThreadAffinityCVar,
TEXT("Override audio render thread affinity.\n")
TEXT("0: Disabled (Default), otherwise overriden thread affinity."),
ECVF_Default);
static int32 EnableDetailedWindowsDeviceLoggingCVar = 0;
#Loc: <Workspace>/Engine/Source/Runtime/AudioMixerCore/Private/AudioMixer.cpp:652
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()
{