UDocumentation UE5.7 10.02.2026 (Source)
API documentation for Unreal Engine 5.7
RenderingThread.cpp File Reference

Classes

class  FRHIThread
 
class  FRenderingThread
 
struct  FSuspendRenderingTickables
 
class  FRenderingThreadTickHeartbeat
 
struct  FConsoleRenderThreadPropagation
 
struct  FRenderCommandFenceBundlerState
 
class  FRenderCommandPipeRegistry
 

Namespaces

namespace  UE
 
namespace  UE::RenderCommandPipe
 
namespace  FFrameEndSync
 

Macros

#define UE_RENDER_COMMAND_FENCE_BUNDLER_REGION   TEXT("Render Command Fence Bundler")
 
#define UE_RENDER_COMMAND_PIPE_RECORD_REGION   TEXT("Render Command Pipe Recording")
 
#define UE_RENDER_COMMAND_PIPE_SYNC_REGION   TEXT("Render Command Pipe Synced")
 
#define UE_RENDER_COMMAND_BEGIN_REGION(Region)
 
#define UE_RENDER_COMMAND_END_REGION(Region)
 

Functions

 UE_TRACE_CHANNEL_DEFINE (RenderCommandsChannel)
 
RENDERCORE_API TAtomic< boolGMainThreadBlockedOnRenderThread (false)
 
ERenderCommandPipeMode GetValidatedRenderCommandPipeMode (int32 CVarValue)
 
void RenderingThreadMain (FEvent *TaskGraphBoundSyncEvent)
 
void AdvanceRenderingThreadStatsGT (bool bDiscardCallstack, int64 StatsFrame, int32 DisableChangeTagStartFrame)
 
FDelegateHandle RegisterStopRenderingThreadDelegate (const FStopRenderingThread::FDelegate &InDelegate)
 
void UnregisterStopRenderingThreadDelegate (FDelegateHandle InDelegateHandle)
 
RENDERCORE_API void LatchRenderThreadConfiguration ()
 
RENDERCORE_API void InitRenderingThread ()
 
RENDERCORE_API void ShutdownRenderingThread ()
 
void CheckRenderingThreadHealth ()
 
bool IsRenderingThreadHealthy ()
 
void StartRenderCommandFenceBundler ()
 
void FlushRenderCommandFenceBundler ()
 
void StopRenderCommandFenceBundler ()
 
void SuspendRenderThreadTimeout ()
 
void ResumeRenderThreadTimeout ()
 
bool IsRenderThreadTimeoutSuspended ()
 
void FlushRenderingCommands ()
 
void FlushPendingDeleteRHIResources_GameThread ()
 
void FlushPendingDeleteRHIResources_RenderThread ()
 
FRHICommandListImmediateGetImmediateCommandList_ForRenderCommand ()
 
void BeginCleanup (FDeferredCleanupInterface *CleanupObject)
 
FPendingCleanupObjectsGetPendingCleanupObjects ()
 
 DECLARE_RENDER_COMMAND_TAG (FRenderCommandTag_ExecuteCommandLists, ExecuteCommandLists)
 
bool HasBitsSet (const FRenderCommandPipeBitArray &Bits)
 
 DECLARE_CYCLE_STAT (TEXT("Frame Sync Time"), STAT_FrameSyncTime, STATGROUP_RenderThreadProcessing)
 

Variables

RENDERCORE_API bool GIsThreadedRendering = false
 
RENDERCORE_API bool GUseThreadedRendering = false
 
RENDERCORE_API TOptional< boolGPendingUseThreadedRendering
 
FString GRenderingThreadError
 
volatile bool GIsRenderingThreadHealthy = true
 
float GRenderingThreadMaxIdleTickFrequency = 40.f
 
CORE_API bool GRenderThreadPollingOn
 
CORE_API int32 GRenderThreadPollPeriodMs
 
bool GRenderCommandFenceBundling = true
 
FAutoConsoleVariableRef CVarRenderCommandFenceBundling (TEXT("r.RenderCommandFenceBundling"), GRenderCommandFenceBundling, TEXT(" 1: enabled (default);\n"), ECVF_Default)
 
ERenderCommandPipeMode GRenderCommandPipeMode = ERenderCommandPipeMode::None
 
FAutoConsoleVariable CVarRenderCommandPipeMode (TEXT("r.RenderCommandPipeMode"), 2, TEXT(" 2: Render commands are enqueued into a render command pipe for all declared pipes.;\n"), FConsoleVariableDelegate::CreateLambda([](IConsoleVariable *Variable) { UE::RenderCommandPipe::StopRecording();GRenderCommandPipeMode=GetValidatedRenderCommandPipeMode(Variable->GetInt());}))
 
uint32 GRenderThreadTime = 0
 
uint32 GRenderThreadWaitTime = 0
 
uint32 GRHIThreadTime = 0
 
uint32 GRenderThreadTimeCriticalPath = 0
 
FRHIThreadGRHIThread = nullptr
 
TAtomic< boolGRunRenderingThreadHeartbeat
 
FThreadSafeCounter OutstandingHeartbeats
 
TAtomic< int32GSuspendRenderingTickables
 
FRunnableThreadGRenderingThreadHeartbeat = NULL
 
FRunnableGRenderingThreadRunnableHeartbeat = NULL
 
std::atomic< int > GTimeoutSuspendCount
 
uint32 GGameThreadTime = 0
 
uint32 GGameThreadWaitTime = 0
 
uint32 GGameThreadTimeCriticalPath = 0
 
uint32 GSwapBufferTime = 0
 
TAutoConsoleVariable< int32CVarAllowOneFrameThreadLag (TEXT("r.OneFrameThreadLag"), 1,)
 
TAutoConsoleVariable< int32CVarGTSyncType (TEXT("r.GTSyncType"), 0, TEXT(" <= 0 - Sync the game thread with the N-1 render thread frame. Then sync with the N-m RHI thread frame where m is (2 + (-r.GTSyncType)) (i.e. negative values increase the amount of RHI thread overlap) (default = 0).\n") TEXT(" 2 - Sync the game thread with the GPU swap chain flip (only on supported platforms).\n"), ECVF_Default)
 

Macro Definition Documentation

◆ UE_RENDER_COMMAND_BEGIN_REGION

#define UE_RENDER_COMMAND_BEGIN_REGION (   Region)

◆ UE_RENDER_COMMAND_END_REGION

#define UE_RENDER_COMMAND_END_REGION (   Region)

◆ UE_RENDER_COMMAND_FENCE_BUNDLER_REGION

#define UE_RENDER_COMMAND_FENCE_BUNDLER_REGION   TEXT("Render Command Fence Bundler")

◆ UE_RENDER_COMMAND_PIPE_RECORD_REGION

#define UE_RENDER_COMMAND_PIPE_RECORD_REGION   TEXT("Render Command Pipe Recording")

◆ UE_RENDER_COMMAND_PIPE_SYNC_REGION

#define UE_RENDER_COMMAND_PIPE_SYNC_REGION   TEXT("Render Command Pipe Synced")

Function Documentation

◆ AdvanceRenderingThreadStatsGT()

void AdvanceRenderingThreadStatsGT ( bool  bDiscardCallstack,
int64  StatsFrame,
int32  DisableChangeTagStartFrame 
)

Advances stats for the rendering thread. Called from the game thread.

◆ BeginCleanup()

void BeginCleanup ( FDeferredCleanupInterface CleanupObject)

Adds the specified deferred cleanup object to the current set of pending cleanup objects.

◆ CheckRenderingThreadHealth()

void CheckRenderingThreadHealth ( )

Checks if the rendering thread is healthy and running. If it has crashed, UE_LOG is called with the exception information.

◆ DECLARE_CYCLE_STAT()

DECLARE_CYCLE_STAT ( TEXT("Frame Sync Time" ,
STAT_FrameSyncTime  ,
STATGROUP_RenderThreadProcessing   
)

◆ DECLARE_RENDER_COMMAND_TAG()

DECLARE_RENDER_COMMAND_TAG ( FRenderCommandTag_ExecuteCommandLists  ,
ExecuteCommandLists   
)

◆ FlushPendingDeleteRHIResources_GameThread()

void FlushPendingDeleteRHIResources_GameThread ( )

◆ FlushPendingDeleteRHIResources_RenderThread()

void FlushPendingDeleteRHIResources_RenderThread ( )

◆ FlushRenderCommandFenceBundler()

void FlushRenderCommandFenceBundler ( )

◆ FlushRenderingCommands()

void FlushRenderingCommands ( )

Waits for the rendering thread to finish executing all pending rendering commands. Should only be used from the game thread.

◆ GetImmediateCommandList_ForRenderCommand()

FRHICommandListImmediate & GetImmediateCommandList_ForRenderCommand ( )

◆ GetPendingCleanupObjects()

FPendingCleanupObjects * GetPendingCleanupObjects ( )

Transfers ownership of the current set of pending cleanup objects to the caller. A new set is created for subsequent BeginCleanup calls.

Returns
A pointer to the set of pending cleanup objects. The called is responsible for deletion.

◆ GetValidatedRenderCommandPipeMode()

ERenderCommandPipeMode GetValidatedRenderCommandPipeMode ( int32  CVarValue)
inline

◆ GMainThreadBlockedOnRenderThread()

RENDERCORE_API TAtomic< bool > GMainThreadBlockedOnRenderThread ( false  )

◆ HasBitsSet()

bool HasBitsSet ( const FRenderCommandPipeBitArray Bits)
inline

◆ InitRenderingThread()

RENDERCORE_API void InitRenderingThread ( )

◆ IsRenderingThreadHealthy()

bool IsRenderingThreadHealthy ( )

Checks if the rendering thread is healthy and running, without crashing

◆ IsRenderThreadTimeoutSuspended()

bool IsRenderThreadTimeoutSuspended ( )

◆ LatchRenderThreadConfiguration()

RENDERCORE_API void LatchRenderThreadConfiguration ( )

◆ RegisterStopRenderingThreadDelegate()

FDelegateHandle RegisterStopRenderingThreadDelegate ( const FStopRenderingThread::FDelegate &  InDelegate)

◆ RenderingThreadMain()

void RenderingThreadMain ( FEvent TaskGraphBoundSyncEvent)

The rendering thread main loop

◆ ResumeRenderThreadTimeout()

void ResumeRenderThreadTimeout ( )

◆ ShutdownRenderingThread()

RENDERCORE_API void ShutdownRenderingThread ( )

◆ StartRenderCommandFenceBundler()

void StartRenderCommandFenceBundler ( )

◆ StopRenderCommandFenceBundler()

void StopRenderCommandFenceBundler ( )

◆ SuspendRenderThreadTimeout()

void SuspendRenderThreadTimeout ( )

◆ UE_TRACE_CHANNEL_DEFINE()

UE_TRACE_CHANNEL_DEFINE ( RenderCommandsChannel  )

◆ UnregisterStopRenderingThreadDelegate()

void UnregisterStopRenderingThreadDelegate ( FDelegateHandle  InDelegateHandle)

Variable Documentation

◆ CVarAllowOneFrameThreadLag

TAutoConsoleVariable< int32 > CVarAllowOneFrameThreadLag(TEXT("r.OneFrameThreadLag"), 1,) ( TEXT("r.OneFrameThreadLag")  ,
 
)

◆ CVarGTSyncType

TAutoConsoleVariable< int32 > CVarGTSyncType(TEXT("r.GTSyncType"), 0, TEXT(" <= 0 - Sync the game thread with the N-1 render thread frame. Then sync with the N-m RHI thread frame where m is (2 + (-r.GTSyncType)) (i.e. negative values increase the amount of RHI thread overlap) (default = 0).\n") TEXT(" 2 - Sync the game thread with the GPU swap chain flip (only on supported platforms).\n"), ECVF_Default) ( TEXT("r.GTSyncType")  ,
,
TEXT(" <= 0 - Sync the game thread with the N-1 render thread frame. Then sync with the N-m RHI thread frame where m is (2 + (-r.GTSyncType)) (i.e. negative values increase the amount of RHI thread overlap) (default = 0).\n") TEXT(" 2 - Sync the game thread with the GPU swap chain flip (only on supported platforms).\n" ,
ECVF_Default   
)

◆ CVarRenderCommandFenceBundling

FAutoConsoleVariableRef CVarRenderCommandFenceBundling(TEXT("r.RenderCommandFenceBundling"), GRenderCommandFenceBundling, TEXT(" 1: enabled (default);\n"), ECVF_Default) ( TEXT("r.RenderCommandFenceBundling")  ,
GRenderCommandFenceBundling  ,
TEXT(" 1: enabled (default);\n" ,
ECVF_Default   
)

◆ CVarRenderCommandPipeMode

FAutoConsoleVariable CVarRenderCommandPipeMode(TEXT("r.RenderCommandPipeMode"), 2, TEXT(" 2: Render commands are enqueued into a render command pipe for all declared pipes.;\n"), FConsoleVariableDelegate::CreateLambda([](IConsoleVariable *Variable) { UE::RenderCommandPipe::StopRecording(); GRenderCommandPipeMode=GetValidatedRenderCommandPipeMode(Variable->GetInt()); })) ( TEXT("r.RenderCommandPipeMode")  ,
,
TEXT(" 2: Render commands are enqueued into a render command pipe for all declared pipes.;\n" ,
FConsoleVariableDelegate::CreateLambda([](IConsoleVariable *Variable) { UE::RenderCommandPipe::StopRecording(); GRenderCommandPipeMode=GetValidatedRenderCommandPipeMode(Variable->GetInt());})   
)

◆ GGameThreadTime

uint32 GGameThreadTime = 0

How many cycles the gamethread used (excluding idle time). It's set once per frame in FViewport::Draw.

◆ GGameThreadTimeCriticalPath

uint32 GGameThreadTimeCriticalPath = 0

How many cycles the gamethread used, including dependent wait time.

◆ GGameThreadWaitTime

uint32 GGameThreadWaitTime = 0

How much idle time on the game thread. It's set once per frame in FViewport::Draw.

◆ GIsRenderingThreadHealthy

volatile bool GIsRenderingThreadHealthy = true

Polled by the game thread to detect crashes in the rendering thread. If the rendering thread crashes, it sets this variable to false.

◆ GIsThreadedRendering

RENDERCORE_API bool GIsThreadedRendering = false

Whether the renderer is currently running in a separate thread. If this is false, then all rendering commands will be executed immediately instead of being enqueued in the rendering command buffer.

◆ GPendingUseThreadedRendering

RENDERCORE_API TOptional<bool> GPendingUseThreadedRendering

◆ GRenderCommandFenceBundling

bool GRenderCommandFenceBundling = true

◆ GRenderCommandPipeMode

◆ GRenderingThreadError

FString GRenderingThreadError

If the rendering thread has been terminated by an unhandled exception, this contains the error message.

◆ GRenderingThreadHeartbeat

FRunnableThread* GRenderingThreadHeartbeat = NULL

◆ GRenderingThreadMaxIdleTickFrequency

float GRenderingThreadMaxIdleTickFrequency = 40.f

Maximum rate the rendering thread will tick tickables when idle (in Hz)

◆ GRenderingThreadRunnableHeartbeat

FRunnable* GRenderingThreadRunnableHeartbeat = NULL

◆ GRenderThreadPollingOn

CORE_API bool GRenderThreadPollingOn
extern

RT Task Graph polling.

◆ GRenderThreadPollPeriodMs

CORE_API int32 GRenderThreadPollPeriodMs
extern

◆ GRenderThreadTime

uint32 GRenderThreadTime = 0

How many cycles the renderthread used (excluding idle time). It's set once per frame in FViewport::Draw.

◆ GRenderThreadTimeCriticalPath

uint32 GRenderThreadTimeCriticalPath = 0

How many cycles the renderthread used, including dependent wait time.

◆ GRenderThreadWaitTime

uint32 GRenderThreadWaitTime = 0

How many cycles of wait time renderthread used. It's set once per frame in FViewport::Draw.

◆ GRHIThread

FRHIThread* GRHIThread = nullptr

◆ GRHIThreadTime

uint32 GRHIThreadTime = 0

How many cycles the rhithread used (excluding idle time).

◆ GRunRenderingThreadHeartbeat

TAtomic<bool> GRunRenderingThreadHeartbeat

If the rendering thread is in its idle loop (which ticks rendering tickables

◆ GSuspendRenderingTickables

TAtomic<int32> GSuspendRenderingTickables

rendering tickables shouldn't be updated during a flush

◆ GSwapBufferTime

uint32 GSwapBufferTime = 0

How many cycles it took to swap buffers to present the frame.

◆ GTimeoutSuspendCount

std::atomic<int> GTimeoutSuspendCount

◆ GUseThreadedRendering

RENDERCORE_API bool GUseThreadedRendering = false

Whether the rendering thread should be created or not. Currently set by command line parameter and by the ToggleRenderingThread console command.

◆ OutstandingHeartbeats

FThreadSafeCounter OutstandingHeartbeats