5#include "Containers/Array.h"
53 #if RDG_EVENTS == RDG_EVENTS_STRING_COPY
61#if RDG_EVENTS >= RDG_EVENTS_STRING_REF
66#if RDG_EVENTS == RDG_EVENTS_STRING_COPY
88#if HAS_GPU_STATS && (RHI_NEW_GPU_PROFILER == 0)
116#if CSV_PROFILER_STATS
119 const char*
const StatName;
124 FCsvProfiler::BeginExclusiveStat(StatName);
129 FCsvProfiler::EndExclusiveStat(StatName);
134 FCsvProfiler::BeginExclusiveStat(StatName);
139 FCsvProfiler::EndExclusiveStat(StatName);
187 RHICmdList.BeginBreadcrumbCPU(Node, !
bPreScope);
190 RHICmdList.BeginBreadcrumbGPU(Node, RHICmdList.
GetPipeline());
201 RHICmdList.EndBreadcrumbGPU(Node, RHICmdList.
GetPipeline());
203 RHICmdList.EndBreadcrumbCPU(Node, !
bPreScope);
212 TCHAR const* GetTCHAR(FRHIBreadcrumb::FBuffer&
Buffer)
const
214 return Node->GetTCHAR(
Buffer);
243 template <
typename...
TTypes>
250 template <
typename TCallback>
264 template <
typename TScopeType>
270 template <
typename TScopeType>
278 template <
typename TScopeType>
290#if HAS_GPU_STATS && (RHI_NEW_GPU_PROFILER == 0)
293#if CSV_PROFILER_STATS
300 template <
typename TScopeType>
303 return 1u << FStorage::GetTypeIndex<TScopeType>();
327template <
typename TScopeType>
337 template <
typename...
TArgs>
342 static constexpr uint32 TypeMask = 1u << FRDGScope::FStorage::GetTypeIndex<TScopeType>();
354 namespace UE::RHI::Breadcrumbs::Private
366 if (
Value.HasFormattedString())
396 struct TValue<std::
tuple<FRDGFormatTag&, TValues...>>
402 TValue(std::tuple<FRDGFormatTag&, TValues...>
const&
Wrapper)
404 std::apply([
this](
FRDGFormatTag&,
auto&& FormatString,
auto&&... Values)
426 #define RDG_BREADCRUMB_DESC_FORWARD_VALUES(StaticName, FormatString, GPUStatArgs) \
427 [&](UE::RHI::Breadcrumbs::Private::FRDGFormatTag&& Tag, auto&&... Values) -> auto \
429 using namespace UE::RHI::Breadcrumbs::Private; \
430 if constexpr (std::is_same_v<TRemoveCVRef<decltype(FormatString)>, FRDGEventName>) \
433 static_assert(sizeof...(Values) == 0, "Unexpected additional arguments"); \
434 return RHI_BREADCRUMB_DESC_FORWARD_VALUES(StaticName, FForceNoSprintf(), GPUStatArgs)( \
435 std::forward<decltype(FormatString)>(FormatString) \
438 else if constexpr (TIsValidArgs<decltype(Values)...>::Value) \
441 return RHI_BREADCRUMB_DESC_FORWARD_VALUES(StaticName, FormatString, GPUStatArgs)( \
442 std::forward<decltype(Values)>(Values)... \
448 return RHI_BREADCRUMB_DESC_COPY_VALUES(StaticName, FForceNoSprintf(), GPUStatArgs)( \
449 std::forward_as_tuple( \
452 , std::forward<decltype(Values)>(Values)... \
458 #define RDG_EVENT_SCOPE_CONSTRUCT(ObjectName, GraphBuilder, Condition, ScopeFlags, GPUStatArgs, StaticName, FormatString, ...) \
461 if ((Condition) && ((GraphBuilder).ShouldAllocScope((ObjectName), ScopeFlags))) \
463 (ObjectName).Emplace( \
466 , RDG_BREADCRUMB_DESC_FORWARD_VALUES( \
470 )(UE::RHI::Breadcrumbs::Private::FRDGFormatTag(), ##__VA_ARGS__) \
475 #define RDG_EVENT_SCOPE_IMPL(GraphBuilder, Condition, ScopeFlags, GPUStatArgs, StaticName, FormatString, ...) \
476 TOptional<TRDGEventScopeGuard<FRDGScope_RHI>> PREPROCESSOR_JOIN(__RDG_ScopeRef_, __LINE__); \
477 RDG_EVENT_SCOPE_CONSTRUCT( \
478 PREPROCESSOR_JOIN(__RDG_ScopeRef_, __LINE__) \
488 #if WITH_RHI_BREADCRUMBS_FULL
490 #if RDG_EVENTS >= RDG_EVENTS_STRING_COPY
491 #define RDG_SCOPE_ARGS(Format, ...) TEXT(Format), ##__VA_ARGS__
493 #define RDG_SCOPE_ARGS(Format, ...) nullptr
497 #define RDG_EVENT_NAME(Format, ...) (sizeof(#__VA_ARGS__ "") > 1 ? FRDGEventName(TEXT(Format), ##__VA_ARGS__) : FRDGEventName(1, TEXT(Format)))
499 #define RDG_EVENT_SCOPE( GraphBuilder, Format, ...) RDG_EVENT_SCOPE_IMPL(GraphBuilder, true, ERDGScopeFlags::None , RHI_GPU_STAT_ARGS_NONE , TEXT(Format) , RDG_SCOPE_ARGS(Format, ##__VA_ARGS__))
500 #define RDG_EVENT_SCOPE_STAT( GraphBuilder, StatName, Format, ...) RDG_EVENT_SCOPE_IMPL(GraphBuilder, true, ERDGScopeFlags::Stat , RHI_GPU_STAT_ARGS(StatName), TEXT(Format) , RDG_SCOPE_ARGS(Format, ##__VA_ARGS__))
501 #define RDG_EVENT_SCOPE_CONDITIONAL( GraphBuilder, Condition, Format, ...) RDG_EVENT_SCOPE_IMPL(GraphBuilder, Condition, ERDGScopeFlags::None , RHI_GPU_STAT_ARGS_NONE , TEXT(Format) , RDG_SCOPE_ARGS(Format, ##__VA_ARGS__))
502 #define RDG_EVENT_SCOPE_CONDITIONAL_STAT(GraphBuilder, Condition, StatName, Format, ...) RDG_EVENT_SCOPE_IMPL(GraphBuilder, Condition, ERDGScopeFlags::Stat , RHI_GPU_STAT_ARGS(StatName), TEXT(Format) , RDG_SCOPE_ARGS(Format, ##__VA_ARGS__))
504 #define RDG_EVENT_SCOPE_FINAL( GraphBuilder, Format, ...) RDG_EVENT_SCOPE_IMPL(GraphBuilder, true, ERDGScopeFlags::Final, RHI_GPU_STAT_ARGS_NONE , TEXT(Format) , RDG_SCOPE_ARGS(Format, ##__VA_ARGS__))
506 #define RDG_EVENT_SCOPE_CONDITIONAL_NAME(GraphBuilder, Condition, EventName ) RDG_EVENT_SCOPE_IMPL(GraphBuilder, Condition, ERDGScopeFlags::None , RHI_GPU_STAT_ARGS_NONE , TEXT("RDGEvent"), EventName)
515 #define RDG_EVENT_NAME(Format, ...) FRDGEventName()
517 #define RDG_EVENT_SCOPE_STAT( GraphBuilder, StatName, Format, ...) RDG_EVENT_SCOPE_IMPL(GraphBuilder, true, ERDGScopeFlags::Stat , RHI_GPU_STAT_ARGS(StatName), TEXT(Format), nullptr)
518 #define RDG_EVENT_SCOPE_CONDITIONAL_STAT(GraphBuilder, Condition, StatName, Format, ...) RDG_EVENT_SCOPE_IMPL(GraphBuilder, Condition, ERDGScopeFlags::Stat , RHI_GPU_STAT_ARGS(StatName), TEXT(Format), nullptr)
520 #define RDG_EVENT_SCOPE( GraphBuilder, Format, ...) do { } while (false)
521 #define RDG_EVENT_SCOPE_CONDITIONAL( GraphBuilder, Condition, Format, ...) do { } while (false)
522 #define RDG_EVENT_SCOPE_FINAL( GraphBuilder, Format, ...) do { } while (false)
523 #define RDG_EVENT_SCOPE_CONDITIONAL_NAME(GraphBuilder, Condition, EventName ) do { } while (false)
529 #define RDG_EVENT_NAME(...) FRDGEventName()
531 #define RDG_EVENT_SCOPE(...) do { } while (false)
532 #define RDG_EVENT_SCOPE_STAT(...) do { } while (false)
533 #define RDG_EVENT_SCOPE_CONDITIONAL(...) do { } while (false)
534 #define RDG_EVENT_SCOPE_CONDITIONAL_STAT(...) do { } while (false)
535 #define RDG_EVENT_SCOPE_FINAL(...) do { } while (false)
536 #define RDG_EVENT_SCOPE_CONDITIONAL_NAME(...) do { } while (false)
540#if HAS_GPU_STATS && (RHI_NEW_GPU_PROFILER == 0)
541 #define RDG_GPU_STAT_SCOPE(GraphBuilder, StatName) TRDGEventScopeGuard<FRDGScope_GPU> PREPROCESSOR_JOIN(__RDG_GPUStatEvent_##StatName,__LINE__) ((GraphBuilder), ERDGScopeFlags::AlwaysEnable, (GraphBuilder).RHICmdList.GetGPUMask(), CSV_STAT_FNAME(StatName), GET_STATID(Stat_GPU_##StatName), nullptr , DrawcallCountCategory_##StatName);
542 #define RDG_GPU_STAT_SCOPE_VERBOSE(GraphBuilder, StatName, Description) TRDGEventScopeGuard<FRDGScope_GPU> PREPROCESSOR_JOIN(__RDG_GPUStatEvent_##StatName,__LINE__) ((GraphBuilder), ERDGScopeFlags::AlwaysEnable, (GraphBuilder).RHICmdList.GetGPUMask(), CSV_STAT_FNAME(StatName), GET_STATID(Stat_GPU_##StatName), Description, DrawcallCountCategory_##StatName);
544 #define RDG_GPU_STAT_SCOPE(GraphBuilder, StatName)
545 #define RDG_GPU_STAT_SCOPE_VERBOSE(GraphBuilder, StatName, Description)
548#if CSV_PROFILER_STATS
549 #define RDG_CSV_STAT_EXCLUSIVE_SCOPE(GraphBuilder, StatName) TRDGEventScopeGuard<FRDGScope_CSVExclusive> PREPROCESSOR_JOIN(__RDG_CSVStat_##StatName,__LINE__) ((GraphBuilder), ERDGScopeFlags::AlwaysEnable, #StatName);
551 #define RDG_CSV_STAT_EXCLUSIVE_SCOPE(GraphBuilder, StatName)
555#define RDG_RHI_EVENT_SCOPE( GraphBuilder, Name) RDG_EVENT_SCOPE(GraphBuilder, #Name); RHI_BREADCRUMB_EVENT(GraphBuilder.RHICmdList, #Name)
556#define RDG_RHI_EVENT_SCOPE_STAT(GraphBuilder, Stat, Name) RDG_EVENT_SCOPE_STAT(GraphBuilder, Stat, #Name); RHI_BREADCRUMB_EVENT_STAT(GraphBuilder.RHICmdList, Stat, #Name)
557#define RDG_RHI_GPU_STAT_SCOPE( GraphBuilder, StatName) RDG_GPU_STAT_SCOPE(GraphBuilder, StatName); SCOPED_GPU_STAT(GraphBuilder.RHICmdList, StatName);
592#if RDG_EVENTS == RDG_EVENTS_NONE
613 int32 GetByteCount()
const
624#if WITH_RHI_BREADCRUMBS
667 template <
typename TScopeType>
670 template <
typename TScopeType>
673#if HAS_GPU_STATS && (RHI_NEW_GPU_PROFILER == 0)
679 friend DynamicRenderScaling::FRDGScope;
#define check(expr)
Definition AssertionMacros.h:314
@ InPlace
Definition CoreMiscDefines.h:162
UE_FORCEINLINE_HINT TSharedRef< CastToType, Mode > StaticCastSharedRef(TSharedRef< CastFromType, Mode > const &InSharedRef)
Definition SharedPointer.h:127
#define ENUM_CLASS_FLAGS(Enum)
Definition EnumClassFlags.h:6
#define WITH_RHI_BREADCRUMBS
Definition RHIBreadcrumbs.h:25
ERDGScopeMode
Definition RenderGraphEvent.h:572
ERDGScopeFlags
Definition RenderGraphEvent.h:74
#define UE_ARRAY_COUNT(array)
Definition UnrealTemplate.h:212
if(Failed) console_printf("Failed.\n")
Definition DynamicRenderScaling.h:83
Definition NameTypes.h:617
Definition RenderGraphAllocator.h:24
int32 GetByteCount() const
Definition RenderGraphAllocator.h:113
Definition RenderGraphEvent.h:38
RENDERCORE_API const TCHAR * GetTCHAR() const
Definition RenderGraphEvent.cpp:288
FRDGEventName(const FRDGEventName &Other)=default
FRDGEventName & operator=(const FRDGEventName &Other)=default
bool HasFormattedString() const
Definition RenderGraphEvent.h:51
Definition RenderGraphPass.h:217
Definition RenderGraphEvent.h:580
FRDGAllocator Task
Definition RenderGraphEvent.h:608
struct FRDGScopeState::@1708 Allocators
bool ShouldAllocScope(TOptional< TRDGEventScopeGuard< TScopeType > > const &, ERDGScopeFlags Flags) const
Definition RenderGraphEvent.inl:180
FRDGAllocator Transition
Definition RenderGraphEvent.h:611
struct FRDGScopeState::FState ScopeState
FRHICommandListImmediate & RHICmdList
Definition RenderGraphEvent.h:622
FRDGAllocator Root
Definition RenderGraphEvent.h:605
FRDGScopeState(FRHICommandListImmediate &InRHICmdList, bool bImmediate, bool bParallelExecute)
Definition RenderGraphEvent.h:654
bool ShouldEmitEvents() const
Definition RenderGraphEvent.h:662
friend FRDGScope_Budget
Definition RenderGraphEvent.h:672
Definition RenderGraphEvent.h:245
TScopeType const * Get() const
Definition RenderGraphEvent.h:279
TScopeType * Get()
Definition RenderGraphEvent.h:271
static constexpr SIZE_T GetTypeIndex()
Definition RenderGraphEvent.h:265
void Dispatch(TCallback &&Callback)
Definition RenderGraphEvent.h:251
void Emplace(TArgs &&... Args)
Definition RenderGraphEvent.h:259
Definition RenderGraphEvent.cpp:12
ERHIPipeline GetPipeline() const
Definition RHICommandList.h:675
Definition RHICommandList.h:2735
Definition RenderGraphEvent.h:329
~TRDGEventScopeGuard()
Definition RenderGraphEvent.inl:162
Definition RHIPipeline.h:55
Definition SharedPointer.h:692
Definition DynamicRenderScaling.cpp:14
Definition ExpressionParserTypes.h:21
U16 Index
Definition radfft.cpp:71
Definition RenderGraphEvent.h:583
bool const bImmediate
Definition RenderGraphEvent.h:589
uint32 Mask
Definition RenderGraphEvent.h:587
static constexpr ERDGScopeMode const ScopeMode
Definition RenderGraphEvent.h:593
bool const bParallelExecute
Definition RenderGraphEvent.h:590
struct FRDGScope * Current
Definition RenderGraphEvent.h:584
DynamicRenderScaling::FBudget const * ActiveBudget
Definition RenderGraphEvent.h:585
Definition RenderGraphEvent.h:153
bool bPop
Definition RenderGraphEvent.h:156
RENDERCORE_API void BeginGPU(FRHIComputeCommandList &RHICmdList)
Definition RenderGraphEvent.cpp:351
void EndCPU(FRHIComputeCommandList &RHICmdList, bool bPreScope)
Definition RenderGraphEvent.h:162
RENDERCORE_API void EndGPU(FRHIComputeCommandList &RHICmdList)
Definition RenderGraphEvent.cpp:359
RENDERCORE_API void ImmediateEnd(FRDGScopeState &State)
Definition RenderGraphEvent.cpp:343
class FRDGTimingFrame * Frame
Definition RenderGraphEvent.h:154
int32 ScopeId
Definition RenderGraphEvent.h:155
void BeginCPU(FRHIComputeCommandList &RHICmdList, bool bPreScope)
Definition RenderGraphEvent.h:161
Definition RenderGraphEvent.h:236
TScopeType * Get()
Definition RenderGraphEvent.h:321
void EndGPU(FRHIComputeCommandList &RHICmdList)
Definition RenderGraphEvent.h:319
void BeginCPU(FRHIComputeCommandList &RHICmdList, bool bPreScope)
Definition RenderGraphEvent.h:316
void EndCPU(FRHIComputeCommandList &RHICmdList, bool bPreScope)
Definition RenderGraphEvent.h:318
FRDGScope(FRDGScope *Parent)
Definition RenderGraphEvent.h:310
TStorage< FRDGScope_Budget > FStorage
Definition RenderGraphEvent.h:296
TRHIPipelineArray< FRDGPass * > GPULastPass
Definition RenderGraphEvent.h:241
TRHIPipelineArray< FRDGPass * > GPUFirstPass
Definition RenderGraphEvent.h:240
void BeginGPU(FRHIComputeCommandList &RHICmdList)
Definition RenderGraphEvent.h:317
void ImmediateEnd(FRDGScopeState &State)
Definition RenderGraphEvent.h:314
FRDGPass * CPULastPass
Definition RenderGraphEvent.h:239
FStorage Impl
Definition RenderGraphEvent.h:298
FString GetFullPath(FRDGEventName const &PassName)
Definition RenderGraphEvent.cpp:313
TScopeType const * Get() const
Definition RenderGraphEvent.h:322
static constexpr uint32 GetTypeMask()
Definition RenderGraphEvent.h:301
FRDGPass * CPUFirstPass
Definition RenderGraphEvent.h:238
FRDGScope *const Parent
Definition RenderGraphEvent.h:237
Definition RHIStats.h:110
static int32 Snprintf(CharType *Dest, int32 DestSize, const FmtType &Fmt, Types... Args)
Definition CString.h:581
static CharType * Strncpy(CharType *Dest, const CharType *Src, SIZE_T MaxLen)
Definition CString.h:991
Definition Optional.h:131
Definition LightweightStats.h:416