UDocumentation UE5.7 10.02.2026 (Source)
API documentation for Unreal Engine 5.7
MetalCommandBuffer.h
Go to the documentation of this file.
1// Copyright Epic Games, Inc. All Rights Reserved.
2
3#pragma once
4
5#include "MetalThirdParty.h"
6#include "MetalResources.h"
8#include "RHIBreadcrumbs.h"
9#include "MetalProfiler.h"
10#include "MetalCommandQueue.h"
11
14class FMetalEventNode;
15
17{
18public:
20#if RHI_NEW_GPU_PROFILER
21 : EventStream(Queue.GetProfilerQueue())
22#endif
23 {
24 CommandBuffer = InCommandBuffer;
25 CommandBuffer->retain();
26 }
27
29 {
30 CommandBuffer->release();
31 }
32
33 FORCEINLINE MTL::CommandBuffer*& GetMTLCmdBuffer() {return CommandBuffer;}
34
35#if RHI_NEW_GPU_PROFILER == 0
40
42 {
43 return Timer;
44 }
45#endif
46
47#if WITH_RHI_BREADCRUMBS
48#if RHI_NEW_GPU_PROFILER
49 void BeginBreadcrumb(FRHIBreadcrumbNode* Node)
50 {
52 TrackerObject.Type = EMetalBreadcrumbTrackerType::Begin;
53 TrackerObject.CmdBuffer = this;
54 TrackerObject.Node = Node;
56 }
57
58 void EndBreadcrumb(FRHIBreadcrumbNode* Node)
59 {
61 TrackerObject.Type = EMetalBreadcrumbTrackerType::End;
62 TrackerObject.CmdBuffer = this;
63 TrackerObject.Node = Node;
65 }
66#endif
67#endif
68
70 {
71 if(!CounterSample)
72 {
73 return;
74 }
75
76#if RHI_NEW_GPU_PROFILER == 0
78 {
79 if(EventSampleCounters.Contains(Node))
80 {
82 }
83 else
84 {
86 }
87 }
88#elif WITH_RHI_BREADCRUMBS
90 TrackerObject.Type = EMetalBreadcrumbTrackerType::Encode;
91 TrackerObject.CmdBuffer = this;
92 TrackerObject.CounterSample = CounterSample;
94#endif
95
97 }
98
99#if RHI_NEW_GPU_PROFILER
101 {
103 }
104
106 {
108 }
109
110 template <typename TEventType, typename... TArgs>
112 {
114
115 if constexpr (std::is_same_v<UE::RHI::GPUProfiler::FEvent::FBeginWork, TEventType>)
116 {
117 // Store BeginEvents in a separate array as the CPUTimestamp field needs updating at submit time.
118 BeginEvents.Add(&Data);
119 }
120
121 // Not sure what to do here, ask Luke!
122 return Data;
123 }
124
125 void FlushProfilerEvents(UE::RHI::GPUProfiler::FEventStream& Destination, uint64 CPUTimestamp)
126 {
128 {
129 BeginEvent->CPUTimestamp = CPUTimestamp;
130 }
131 BeginEvents.Reset();
132 Destination.Append(MoveTemp(EventStream));
133 }
134#endif
135
139
140#if RHI_NEW_GPU_PROFILER == 0
143#else
146
147#if WITH_RHI_BREADCRUMBS
149#endif
150
153#endif
154
155private:
156 MTL::CommandBuffer* CommandBuffer;
157 FMetalCommandBufferTimer* Timer = nullptr;
158};
#define FORCEINLINE
Definition AndroidPlatform.h:140
FPlatformTypes::uint64 uint64
A 64-bit unsigned integer.
Definition Platform.h:1117
UE_FORCEINLINE_HINT TSharedRef< CastToType, Mode > StaticCastSharedRef(TSharedRef< CastFromType, Mode > const &InSharedRef)
Definition SharedPointer.h:127
UE_INTRINSIC_CAST UE_REWRITE constexpr std::remove_reference_t< T > && MoveTemp(T &&Obj) noexcept
Definition UnrealTemplate.h:520
Definition MetalProfiler.h:97
Definition MetalCommandBuffer.h:17
TArray< FMetalRHIRenderQuery * > OcclusionQueries
Definition MetalCommandBuffer.h:137
~FMetalCommandBuffer()
Definition MetalCommandBuffer.h:28
FORCEINLINE void SetTimer(FMetalCommandBufferTimer *InTimer)
Definition MetalCommandBuffer.h:36
FORCEINLINE MTL::CommandBuffer *& GetMTLCmdBuffer()
Definition MetalCommandBuffer.h:33
TMap< FMetalEventNode *, TArray< FMetalCounterSamplePtr > > EventSampleCounters
Definition MetalCommandBuffer.h:141
void AddCounterSample(FMetalCounterSamplePtr CounterSample)
Definition MetalCommandBuffer.h:69
TArray< FMetalCounterSamplePtr > CounterSamples
Definition MetalCommandBuffer.h:138
FORCEINLINE FMetalCommandBufferTimer * GetTimer()
Definition MetalCommandBuffer.h:41
FMetalCommandBuffer(MTL::CommandBuffer *InCommandBuffer, FMetalCommandQueue &Queue)
Definition MetalCommandBuffer.h:19
TArray< FMetalRHIRenderQuery * > TimestampQueries
Definition MetalCommandBuffer.h:136
TArray< FMetalEventNode * > ActiveEventNodes
Definition MetalCommandBuffer.h:142
Definition MetalCommandQueue.h:39
Definition MetalProfiler.h:131
Definition Array.h:670
Definition UnrealString.h.inl:34
Definition SharedPointer.h:692
Definition GPUProfiler.h:310
void Append(FEventStream &&Other)
Definition GPUProfiler.h:447
GeometryCollection::Facades::FMuscleActivationData Data
Definition MuscleActivationConstraints.h:15
Definition MetalCounterSampler.h:20
Definition GPUProfiler.h:172