UDocumentation UE5.7 10.02.2026 (Source)
API documentation for Unreal Engine 5.7
RenderingThread.h File Reference
#include "Async/TaskGraphInterfaces.h"
#include "Containers/Array.h"
#include "Containers/List.h"
#include "CoreGlobals.h"
#include "CoreMinimal.h"
#include "CoreTypes.h"
#include "Delegates/Delegate.h"
#include "HAL/PlatformMemory.h"
#include "Misc/AssertionMacros.h"
#include "Misc/TVariant.h"
#include "MultiGPU.h"
#include "ProfilingDebugging/CpuProfilerTrace.h"
#include "RHI.h"
#include "RHICommandList.h"
#include "Serialization/MemoryLayout.h"
#include "Stats/Stats.h"
#include "Templates/Atomic.h"
#include "Templates/Function.h"
#include "Templates/UnrealTemplate.h"
#include "Templates/UnrealTypeTraits.h"
#include "Trace/Trace.h"
#include "Async/Mutex.h"
#include "Tasks/Pipe.h"

Go to the source code of this file.

Classes

class  FCoreRenderDelegates
 
class  FRenderCommandTag
 
class  TRenderCommandTag< TSTR >
 
class  UE::RenderCommandPipe::FSyncScope
 
class  UE::RenderCommandPipe::FCommandList
 
class  FRenderCommandPipeBase
 
struct  FRenderCommandPipeBase::FContext
 
class  FRenderThreadCommandPipe
 
class  FRenderCommandPipe
 
class  FRenderCommandList
 
class  FRenderCommandList::FRecordScope
 
class  FRenderCommandList::FFlushScope
 
class  FRenderCommandList::FParallelForContext
 
class  FRenderCommandDispatcher
 
struct  FRenderThreadStructBase
 
class  TRenderThreadStruct< StructType >
 

Namespaces

namespace  UE
 
namespace  UE::Trace
 
namespace  FFrameEndSync
 
namespace  UE::RenderCommandPipe
 

Macros

#define UE_API   RENDERCORE_API
 
#define LogRenderCommand(TypeName)
 
#define ShouldExecuteOnRenderThread()   (LIKELY(GIsThreadedRendering || !IsInGameThread()))
 
#define DECLARE_RENDER_COMMAND_TAG(Type, Name)
 
#define DECLARE_RENDER_COMMAND_PIPE(Name, PrefixKeywords)    namespace UE::RenderCommandPipe { extern PrefixKeywords FRenderCommandPipe Name; }
 
#define DEFINE_RENDER_COMMAND_PIPE(Name, Flags)
 
#define ENQUEUE_RENDER_COMMAND(Type)
 

Typedefs

using FRenderCommandPipeBitArrayAllocator = TInlineAllocator< 1, FConcurrentLinearArrayAllocator >
 
using FRenderCommandPipeBitArray = TBitArray< FRenderCommandPipeBitArrayAllocator >
 
using FRenderCommandPipeSetBitIterator = TConstSetBitIterator< FRenderCommandPipeBitArrayAllocator >
 
using FRenderCommandFunctionVariant = TVariant< TUniqueFunction< void()>, TUniqueFunction< void(FRHICommandList &)>, TUniqueFunction< void(FRHICommandListImmediate &)> >
 
using FStopRenderingThreadDelegate = FStopRenderingThread::FDelegate
 

Enumerations

enum class  FFrameEndSync::EFlushMode { FFrameEndSync::EndFrame , FFrameEndSync::Threads }
 
enum class  ERenderCommandPipeMode : uint8 { None , RenderThread , All }
 
enum class  ERenderCommandPipeFlags : uint8 { None = 0 , Disabled = 1 << 0 }
 
enum class  ERenderCommandListFlags : uint8 { None , CloseOnSubmit = 1 << 0 }
 

Functions

void CheckNotBlockedOnRenderThread ()
 
RENDERCORE_API void InitRenderingThread ()
 
RENDERCORE_API void ShutdownRenderingThread ()
 
RENDERCORE_API void LatchRenderThreadConfiguration ()
 
RENDERCORE_API void CheckRenderingThreadHealth ()
 
RENDERCORE_API bool IsRenderingThreadHealthy ()
 
RENDERCORE_API void AdvanceRenderingThreadStatsGT (bool bDiscardCallstack, int64 StatsFrame, int32 DisableChangeTagStartFrame)
 
RENDERCORE_API void FlushRenderingCommands ()
 
RENDERCORE_API void FlushPendingDeleteRHIResources_GameThread ()
 
RENDERCORE_API void FlushPendingDeleteRHIResources_RenderThread ()
 
RENDERCORE_API void StartRenderCommandFenceBundler ()
 
RENDERCORE_API void StopRenderCommandFenceBundler ()
 
 UE_TRACE_CHANNEL_EXTERN (RenderCommandsChannel, RENDERCORE_API)
 
RENDERCORE_API class FRHICommandListImmediateGetImmediateCommandList_ForRenderCommand ()
 
 DECLARE_STATS_GROUP (TEXT("Render Thread Commands"), STATGROUP_RenderThreadCommands, STATCAT_Advanced)
 
 ENUM_CLASS_FLAGS (ERenderCommandPipeFlags)
 
 UE::RenderCommandPipe::DECLARE_MULTICAST_DELEGATE_OneParam (FStopRecordingDelegate, const FRenderCommandPipeBitArray &)
 
 ENUM_CLASS_FLAGS (ERenderCommandListFlags)
 
 DECLARE_MULTICAST_DELEGATE (FStopRenderingThread)
 
RENDERCORE_API FDelegateHandle RegisterStopRenderingThreadDelegate (const FStopRenderingThreadDelegate &InDelegate)
 
RENDERCORE_API void UnregisterStopRenderingThreadDelegate (FDelegateHandle InDelegateHandle)
 
class UE_DEPRECATED (5.6, "FRenderThreadScope is no longer used.") FRenderThreadScope
 
class UE_DEPRECATED (5.6, "FRenderCommand is no longer used") FRenderCommand
 

Variables

RENDERCORE_API bool GIsThreadedRendering
 
RENDERCORE_API bool GUseThreadedRendering
 
RENDERCORE_API TOptional< boolGPendingUseThreadedRendering
 
RENDERCORE_API TAtomic< boolGMainThreadBlockedOnRenderThread
 
RENDERCORE_API ERenderCommandPipeMode GRenderCommandPipeMode
 

Macro Definition Documentation

◆ DECLARE_RENDER_COMMAND_PIPE

#define DECLARE_RENDER_COMMAND_PIPE (   Name,
  PrefixKeywords 
)     namespace UE::RenderCommandPipe { extern PrefixKeywords FRenderCommandPipe Name; }

Declares an extern reference to a render command pipe.

◆ DECLARE_RENDER_COMMAND_TAG

#define DECLARE_RENDER_COMMAND_TAG (   Type,
  Name 
)
Value:
{ \
static const char* CStr() { return #Name; } \
static const TCHAR* TStr() { return TEXT(#Name); } \
}; \
#define TEXT(x)
Definition Platform.h:1272
FPlatformTypes::TCHAR TCHAR
Either ANSICHAR or WIDECHAR, depending on whether the platform supports wide characters or the requir...
Definition Platform.h:1135
UE_FORCEINLINE_HINT TSharedRef< CastToType, Mode > StaticCastSharedRef(TSharedRef< CastFromType, Mode > const &InSharedRef)
Definition SharedPointer.h:127
#define PREPROCESSOR_JOIN(TokenA, TokenB)
Definition PreprocessorHelpers.h:104
Definition RenderingThread.h:191
Type
Definition PawnAction_Move.h:11

Declares a new render command tag type from a name.

◆ DEFINE_RENDER_COMMAND_PIPE

#define DEFINE_RENDER_COMMAND_PIPE (   Name,
  Flags 
)
Value:
{ \
TEXT(#Name), \
Flags, \
TEXT("r.RenderCommandPipe." #Name), \
TEXT("Whether to enable the " #Name " Render Command Pipe") \
TEXT(" 0: off;") \
TEXT(" 1: on (default)") \
); \
}
Definition RenderingThread.h:652
Definition RenderingThread.cpp:1469

Defines a render command pipe.

◆ ENQUEUE_RENDER_COMMAND

#define ENQUEUE_RENDER_COMMAND (   Type)
Value:
#define DECLARE_RENDER_COMMAND_TAG(Type, Name)
Definition RenderingThread.h:240
static void Enqueue(TUniqueFunction< void(FRHICommandListImmediate &)> &&Function)
Definition RenderingThread.h:1081

Enqueues a render command to a render pipe. The default implementation takes a lambda and schedules on the render thread. Alternative implementations accept either a reference or pointer to an FRenderCommandPipe instance to schedule on an async pipe, if enabled.

◆ LogRenderCommand

#define LogRenderCommand (   TypeName)

◆ ShouldExecuteOnRenderThread

#define ShouldExecuteOnRenderThread ( )    (LIKELY(GIsThreadedRendering || !IsInGameThread()))

◆ UE_API

#define UE_API   RENDERCORE_API

Typedef Documentation

◆ FRenderCommandFunctionVariant

◆ FRenderCommandPipeBitArray

◆ FRenderCommandPipeBitArrayAllocator

◆ FRenderCommandPipeSetBitIterator

◆ FStopRenderingThreadDelegate

using FStopRenderingThreadDelegate = FStopRenderingThread::FDelegate

Enumeration Type Documentation

◆ ERenderCommandListFlags

Enumerator
None 
CloseOnSubmit 

◆ ERenderCommandPipeFlags

Enumerator
None 
Disabled 

Initializes the render command pipe in a disabled state.

◆ ERenderCommandPipeMode

Describes which pipes are configured to use the render command pipe system.

Enumerator
None 

Bypasses the render command pipe system altogether. Render commands are issued using tasks.

RenderThread 

The render command pipe on the render thread pipe is active, and all other pipes forward to the render thread pipe.

All 

All render command pipes are active.

Function Documentation

◆ AdvanceRenderingThreadStatsGT()

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

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

◆ CheckNotBlockedOnRenderThread()

void CheckNotBlockedOnRenderThread ( )
inline

Asserts if called from the main thread when the main thread is blocked on the rendering thread.

◆ CheckRenderingThreadHealth()

RENDERCORE_API void CheckRenderingThreadHealth ( )
extern

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

◆ DECLARE_MULTICAST_DELEGATE()

DECLARE_MULTICAST_DELEGATE ( FStopRenderingThread  )

◆ DECLARE_STATS_GROUP()

DECLARE_STATS_GROUP ( TEXT("Render Thread Commands" ,
STATGROUP_RenderThreadCommands  ,
STATCAT_Advanced   
)

◆ ENUM_CLASS_FLAGS() [1/2]

ENUM_CLASS_FLAGS ( ERenderCommandListFlags  )

◆ ENUM_CLASS_FLAGS() [2/2]

ENUM_CLASS_FLAGS ( ERenderCommandPipeFlags  )

◆ FlushPendingDeleteRHIResources_GameThread()

RENDERCORE_API void FlushPendingDeleteRHIResources_GameThread ( )
extern

◆ FlushPendingDeleteRHIResources_RenderThread()

RENDERCORE_API void FlushPendingDeleteRHIResources_RenderThread ( )
extern

◆ FlushRenderingCommands()

RENDERCORE_API void FlushRenderingCommands ( )
extern

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

◆ GetImmediateCommandList_ForRenderCommand()

RENDERCORE_API class FRHICommandListImmediate & GetImmediateCommandList_ForRenderCommand ( )
extern

◆ InitRenderingThread()

RENDERCORE_API void InitRenderingThread ( )
extern

◆ IsRenderingThreadHealthy()

RENDERCORE_API bool IsRenderingThreadHealthy ( )
extern

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

◆ LatchRenderThreadConfiguration()

RENDERCORE_API void LatchRenderThreadConfiguration ( )
extern

◆ RegisterStopRenderingThreadDelegate()

RENDERCORE_API FDelegateHandle RegisterStopRenderingThreadDelegate ( const FStopRenderingThreadDelegate InDelegate)
extern

◆ ShutdownRenderingThread()

RENDERCORE_API void ShutdownRenderingThread ( )
extern

◆ StartRenderCommandFenceBundler()

RENDERCORE_API void StartRenderCommandFenceBundler ( )
extern

◆ StopRenderCommandFenceBundler()

RENDERCORE_API void StopRenderCommandFenceBundler ( )
extern

◆ UE_DEPRECATED() [1/2]

class UE_DEPRECATED ( 5.  6,
"FRenderCommand is no longer used"   
)

◆ UE_DEPRECATED() [2/2]

class UE_DEPRECATED ( 5.  6,
"FRenderThreadScope is no longer used."   
)

◆ UE_TRACE_CHANNEL_EXTERN()

UE_TRACE_CHANNEL_EXTERN ( RenderCommandsChannel  ,
RENDERCORE_API   
)

◆ UnregisterStopRenderingThreadDelegate()

RENDERCORE_API void UnregisterStopRenderingThreadDelegate ( FDelegateHandle  InDelegateHandle)
extern

Variable Documentation

◆ GIsThreadedRendering

RENDERCORE_API bool GIsThreadedRendering
extern

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.

◆ GMainThreadBlockedOnRenderThread

RENDERCORE_API TAtomic<bool> GMainThreadBlockedOnRenderThread
extern

Whether the main thread is currently blocked on the rendering thread, e.g. a call to FlushRenderingCommands.

◆ GPendingUseThreadedRendering

RENDERCORE_API TOptional<bool> GPendingUseThreadedRendering
extern

◆ GRenderCommandPipeMode

RENDERCORE_API ERenderCommandPipeMode GRenderCommandPipeMode
extern

◆ GUseThreadedRendering

RENDERCORE_API bool GUseThreadedRendering
extern

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