Book a Demo!
CoCalc Logo Icon
StoreFeaturesDocsShareSupportNewsAboutPoliciesSign UpSign In
godotengine
GitHub Repository: godotengine/godot
Path: blob/master/thirdparty/metal-cpp/Metal/MTL4CommandBuffer.hpp
21066 views
1
//-------------------------------------------------------------------------------------------------------------------------------------------------------------
2
//
3
// Metal/MTL4CommandBuffer.hpp
4
//
5
// Copyright 2020-2025 Apple Inc.
6
//
7
// Licensed under the Apache License, Version 2.0 (the "License");
8
// you may not use this file except in compliance with the License.
9
// You may obtain a copy of the License at
10
//
11
// http://www.apache.org/licenses/LICENSE-2.0
12
//
13
// Unless required by applicable law or agreed to in writing, software
14
// distributed under the License is distributed on an "AS IS" BASIS,
15
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
16
// See the License for the specific language governing permissions and
17
// limitations under the License.
18
//
19
//-------------------------------------------------------------------------------------------------------------------------------------------------------------
20
21
#pragma once
22
23
#include "../Foundation/Foundation.hpp"
24
#include "MTL4RenderCommandEncoder.hpp"
25
#include "MTLAccelerationStructureTypes.hpp"
26
#include "MTLDefines.hpp"
27
#include "MTLHeaderBridge.hpp"
28
#include "MTLPrivate.hpp"
29
30
namespace MTL4
31
{
32
class CommandAllocator;
33
class CommandBufferOptions;
34
class ComputeCommandEncoder;
35
class CounterHeap;
36
class MachineLearningCommandEncoder;
37
class RenderCommandEncoder;
38
class RenderPassDescriptor;
39
}
40
41
namespace MTL
42
{
43
class Device;
44
class Fence;
45
class LogState;
46
class ResidencySet;
47
}
48
49
namespace MTL4
50
{
51
class CommandBufferOptions : public NS::Copying<CommandBufferOptions>
52
{
53
public:
54
static CommandBufferOptions* alloc();
55
56
CommandBufferOptions* init();
57
58
MTL::LogState* logState() const;
59
void setLogState(const MTL::LogState* logState);
60
};
61
class CommandBuffer : public NS::Referencing<CommandBuffer>
62
{
63
public:
64
void beginCommandBuffer(const MTL4::CommandAllocator* allocator);
65
void beginCommandBuffer(const MTL4::CommandAllocator* allocator, const MTL4::CommandBufferOptions* options);
66
67
ComputeCommandEncoder* computeCommandEncoder();
68
69
MTL::Device* device() const;
70
71
void endCommandBuffer();
72
73
NS::String* label() const;
74
75
MachineLearningCommandEncoder* machineLearningCommandEncoder();
76
77
void popDebugGroup();
78
79
void pushDebugGroup(const NS::String* string);
80
81
RenderCommandEncoder* renderCommandEncoder(const MTL4::RenderPassDescriptor* descriptor);
82
RenderCommandEncoder* renderCommandEncoder(const MTL4::RenderPassDescriptor* descriptor, MTL4::RenderEncoderOptions options);
83
84
void resolveCounterHeap(const MTL4::CounterHeap* counterHeap, NS::Range range, const MTL4::BufferRange bufferRange, const MTL::Fence* fenceToWait, const MTL::Fence* fenceToUpdate);
85
86
void setLabel(const NS::String* label);
87
88
void useResidencySet(const MTL::ResidencySet* residencySet);
89
void useResidencySets(const MTL::ResidencySet* const residencySets[], NS::UInteger count);
90
91
void writeTimestampIntoHeap(const MTL4::CounterHeap* counterHeap, NS::UInteger index);
92
};
93
94
}
95
_MTL_INLINE MTL4::CommandBufferOptions* MTL4::CommandBufferOptions::alloc()
96
{
97
return NS::Object::alloc<MTL4::CommandBufferOptions>(_MTL_PRIVATE_CLS(MTL4CommandBufferOptions));
98
}
99
100
_MTL_INLINE MTL4::CommandBufferOptions* MTL4::CommandBufferOptions::init()
101
{
102
return NS::Object::init<MTL4::CommandBufferOptions>();
103
}
104
105
_MTL_INLINE MTL::LogState* MTL4::CommandBufferOptions::logState() const
106
{
107
return Object::sendMessage<MTL::LogState*>(this, _MTL_PRIVATE_SEL(logState));
108
}
109
110
_MTL_INLINE void MTL4::CommandBufferOptions::setLogState(const MTL::LogState* logState)
111
{
112
Object::sendMessage<void>(this, _MTL_PRIVATE_SEL(setLogState_), logState);
113
}
114
115
_MTL_INLINE void MTL4::CommandBuffer::beginCommandBuffer(const MTL4::CommandAllocator* allocator)
116
{
117
Object::sendMessage<void>(this, _MTL_PRIVATE_SEL(beginCommandBufferWithAllocator_), allocator);
118
}
119
120
_MTL_INLINE void MTL4::CommandBuffer::beginCommandBuffer(const MTL4::CommandAllocator* allocator, const MTL4::CommandBufferOptions* options)
121
{
122
Object::sendMessage<void>(this, _MTL_PRIVATE_SEL(beginCommandBufferWithAllocator_options_), allocator, options);
123
}
124
125
_MTL_INLINE MTL4::ComputeCommandEncoder* MTL4::CommandBuffer::computeCommandEncoder()
126
{
127
return Object::sendMessage<MTL4::ComputeCommandEncoder*>(this, _MTL_PRIVATE_SEL(computeCommandEncoder));
128
}
129
130
_MTL_INLINE MTL::Device* MTL4::CommandBuffer::device() const
131
{
132
return Object::sendMessage<MTL::Device*>(this, _MTL_PRIVATE_SEL(device));
133
}
134
135
_MTL_INLINE void MTL4::CommandBuffer::endCommandBuffer()
136
{
137
Object::sendMessage<void>(this, _MTL_PRIVATE_SEL(endCommandBuffer));
138
}
139
140
_MTL_INLINE NS::String* MTL4::CommandBuffer::label() const
141
{
142
return Object::sendMessage<NS::String*>(this, _MTL_PRIVATE_SEL(label));
143
}
144
145
_MTL_INLINE MTL4::MachineLearningCommandEncoder* MTL4::CommandBuffer::machineLearningCommandEncoder()
146
{
147
return Object::sendMessage<MTL4::MachineLearningCommandEncoder*>(this, _MTL_PRIVATE_SEL(machineLearningCommandEncoder));
148
}
149
150
_MTL_INLINE void MTL4::CommandBuffer::popDebugGroup()
151
{
152
Object::sendMessage<void>(this, _MTL_PRIVATE_SEL(popDebugGroup));
153
}
154
155
_MTL_INLINE void MTL4::CommandBuffer::pushDebugGroup(const NS::String* string)
156
{
157
Object::sendMessage<void>(this, _MTL_PRIVATE_SEL(pushDebugGroup_), string);
158
}
159
160
_MTL_INLINE MTL4::RenderCommandEncoder* MTL4::CommandBuffer::renderCommandEncoder(const MTL4::RenderPassDescriptor* descriptor)
161
{
162
return Object::sendMessage<MTL4::RenderCommandEncoder*>(this, _MTL_PRIVATE_SEL(renderCommandEncoderWithDescriptor_), descriptor);
163
}
164
165
_MTL_INLINE MTL4::RenderCommandEncoder* MTL4::CommandBuffer::renderCommandEncoder(const MTL4::RenderPassDescriptor* descriptor, MTL4::RenderEncoderOptions options)
166
{
167
return Object::sendMessage<MTL4::RenderCommandEncoder*>(this, _MTL_PRIVATE_SEL(renderCommandEncoderWithDescriptor_options_), descriptor, options);
168
}
169
170
_MTL_INLINE void MTL4::CommandBuffer::resolveCounterHeap(const MTL4::CounterHeap* counterHeap, NS::Range range, const MTL4::BufferRange bufferRange, const MTL::Fence* fenceToWait, const MTL::Fence* fenceToUpdate)
171
{
172
Object::sendMessage<void>(this, _MTL_PRIVATE_SEL(resolveCounterHeap_withRange_intoBuffer_waitFence_updateFence_), counterHeap, range, bufferRange, fenceToWait, fenceToUpdate);
173
}
174
175
_MTL_INLINE void MTL4::CommandBuffer::setLabel(const NS::String* label)
176
{
177
Object::sendMessage<void>(this, _MTL_PRIVATE_SEL(setLabel_), label);
178
}
179
180
_MTL_INLINE void MTL4::CommandBuffer::useResidencySet(const MTL::ResidencySet* residencySet)
181
{
182
Object::sendMessage<void>(this, _MTL_PRIVATE_SEL(useResidencySet_), residencySet);
183
}
184
185
_MTL_INLINE void MTL4::CommandBuffer::useResidencySets(const MTL::ResidencySet* const residencySets[], NS::UInteger count)
186
{
187
Object::sendMessage<void>(this, _MTL_PRIVATE_SEL(useResidencySets_count_), residencySets, count);
188
}
189
190
_MTL_INLINE void MTL4::CommandBuffer::writeTimestampIntoHeap(const MTL4::CounterHeap* counterHeap, NS::UInteger index)
191
{
192
Object::sendMessage<void>(this, _MTL_PRIVATE_SEL(writeTimestampIntoHeap_atIndex_), counterHeap, index);
193
}
194
195