Book a Demo!
CoCalc Logo Icon
StoreFeaturesDocsShareSupportNewsAboutPoliciesSign UpSign In
godotengine
GitHub Repository: godotengine/godot
Path: blob/master/thirdparty/metal-cpp/Metal/MTLCaptureManager.hpp
21082 views
1
//-------------------------------------------------------------------------------------------------------------------------------------------------------------
2
//
3
// Metal/MTLCaptureManager.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 "MTLDefines.hpp"
25
#include "MTLHeaderBridge.hpp"
26
#include "MTLPrivate.hpp"
27
28
namespace MTL
29
{
30
class CaptureDescriptor;
31
class CaptureManager;
32
class CaptureScope;
33
class CommandQueue;
34
class Device;
35
}
36
37
namespace MTL4
38
{
39
class CommandQueue;
40
}
41
42
namespace MTL
43
{
44
_MTL_ENUM(NS::Integer, CaptureError) {
45
CaptureErrorNotSupported = 1,
46
CaptureErrorAlreadyCapturing = 2,
47
CaptureErrorInvalidDescriptor = 3,
48
};
49
50
_MTL_ENUM(NS::Integer, CaptureDestination) {
51
CaptureDestinationDeveloperTools = 1,
52
CaptureDestinationGPUTraceDocument = 2,
53
};
54
55
class CaptureDescriptor : public NS::Copying<CaptureDescriptor>
56
{
57
public:
58
static CaptureDescriptor* alloc();
59
60
NS::Object* captureObject() const;
61
62
CaptureDestination destination() const;
63
64
CaptureDescriptor* init();
65
66
NS::URL* outputURL() const;
67
68
void setCaptureObject(NS::Object* captureObject);
69
70
void setDestination(MTL::CaptureDestination destination);
71
72
void setOutputURL(const NS::URL* outputURL);
73
};
74
class CaptureManager : public NS::Referencing<CaptureManager>
75
{
76
public:
77
static CaptureManager* alloc();
78
79
CaptureScope* defaultCaptureScope() const;
80
81
CaptureManager* init();
82
83
bool isCapturing() const;
84
85
CaptureScope* newCaptureScope(const MTL::Device* device);
86
CaptureScope* newCaptureScope(const MTL::CommandQueue* commandQueue);
87
CaptureScope* newCaptureScope(const MTL4::CommandQueue* commandQueue);
88
89
void setDefaultCaptureScope(const MTL::CaptureScope* defaultCaptureScope);
90
91
static CaptureManager* sharedCaptureManager();
92
93
bool startCapture(const MTL::CaptureDescriptor* descriptor, NS::Error** error);
94
void startCapture(const MTL::Device* device);
95
void startCapture(const MTL::CommandQueue* commandQueue);
96
void startCapture(const MTL::CaptureScope* captureScope);
97
98
void stopCapture();
99
100
bool supportsDestination(MTL::CaptureDestination destination);
101
};
102
103
}
104
_MTL_INLINE MTL::CaptureDescriptor* MTL::CaptureDescriptor::alloc()
105
{
106
return NS::Object::alloc<MTL::CaptureDescriptor>(_MTL_PRIVATE_CLS(MTLCaptureDescriptor));
107
}
108
109
_MTL_INLINE NS::Object* MTL::CaptureDescriptor::captureObject() const
110
{
111
return Object::sendMessage<NS::Object*>(this, _MTL_PRIVATE_SEL(captureObject));
112
}
113
114
_MTL_INLINE MTL::CaptureDestination MTL::CaptureDescriptor::destination() const
115
{
116
return Object::sendMessage<MTL::CaptureDestination>(this, _MTL_PRIVATE_SEL(destination));
117
}
118
119
_MTL_INLINE MTL::CaptureDescriptor* MTL::CaptureDescriptor::init()
120
{
121
return NS::Object::init<MTL::CaptureDescriptor>();
122
}
123
124
_MTL_INLINE NS::URL* MTL::CaptureDescriptor::outputURL() const
125
{
126
return Object::sendMessage<NS::URL*>(this, _MTL_PRIVATE_SEL(outputURL));
127
}
128
129
_MTL_INLINE void MTL::CaptureDescriptor::setCaptureObject(NS::Object* captureObject)
130
{
131
Object::sendMessage<void>(this, _MTL_PRIVATE_SEL(setCaptureObject_), captureObject);
132
}
133
134
_MTL_INLINE void MTL::CaptureDescriptor::setDestination(MTL::CaptureDestination destination)
135
{
136
Object::sendMessage<void>(this, _MTL_PRIVATE_SEL(setDestination_), destination);
137
}
138
139
_MTL_INLINE void MTL::CaptureDescriptor::setOutputURL(const NS::URL* outputURL)
140
{
141
Object::sendMessage<void>(this, _MTL_PRIVATE_SEL(setOutputURL_), outputURL);
142
}
143
144
_MTL_INLINE MTL::CaptureManager* MTL::CaptureManager::alloc()
145
{
146
return NS::Object::alloc<MTL::CaptureManager>(_MTL_PRIVATE_CLS(MTLCaptureManager));
147
}
148
149
_MTL_INLINE MTL::CaptureScope* MTL::CaptureManager::defaultCaptureScope() const
150
{
151
return Object::sendMessage<MTL::CaptureScope*>(this, _MTL_PRIVATE_SEL(defaultCaptureScope));
152
}
153
154
_MTL_INLINE MTL::CaptureManager* MTL::CaptureManager::init()
155
{
156
return NS::Object::init<MTL::CaptureManager>();
157
}
158
159
_MTL_INLINE bool MTL::CaptureManager::isCapturing() const
160
{
161
return Object::sendMessage<bool>(this, _MTL_PRIVATE_SEL(isCapturing));
162
}
163
164
_MTL_INLINE MTL::CaptureScope* MTL::CaptureManager::newCaptureScope(const MTL::Device* device)
165
{
166
return Object::sendMessage<MTL::CaptureScope*>(this, _MTL_PRIVATE_SEL(newCaptureScopeWithDevice_), device);
167
}
168
169
_MTL_INLINE MTL::CaptureScope* MTL::CaptureManager::newCaptureScope(const MTL::CommandQueue* commandQueue)
170
{
171
return Object::sendMessage<MTL::CaptureScope*>(this, _MTL_PRIVATE_SEL(newCaptureScopeWithCommandQueue_), commandQueue);
172
}
173
174
_MTL_INLINE MTL::CaptureScope* MTL::CaptureManager::newCaptureScope(const MTL4::CommandQueue* commandQueue)
175
{
176
return Object::sendMessage<MTL::CaptureScope*>(this, _MTL_PRIVATE_SEL(newCaptureScopeWithMTL4CommandQueue_), commandQueue);
177
}
178
179
_MTL_INLINE void MTL::CaptureManager::setDefaultCaptureScope(const MTL::CaptureScope* defaultCaptureScope)
180
{
181
Object::sendMessage<void>(this, _MTL_PRIVATE_SEL(setDefaultCaptureScope_), defaultCaptureScope);
182
}
183
184
_MTL_INLINE MTL::CaptureManager* MTL::CaptureManager::sharedCaptureManager()
185
{
186
return Object::sendMessage<MTL::CaptureManager*>(_MTL_PRIVATE_CLS(MTLCaptureManager), _MTL_PRIVATE_SEL(sharedCaptureManager));
187
}
188
189
_MTL_INLINE bool MTL::CaptureManager::startCapture(const MTL::CaptureDescriptor* descriptor, NS::Error** error)
190
{
191
return Object::sendMessage<bool>(this, _MTL_PRIVATE_SEL(startCaptureWithDescriptor_error_), descriptor, error);
192
}
193
194
_MTL_INLINE void MTL::CaptureManager::startCapture(const MTL::Device* device)
195
{
196
Object::sendMessage<void>(this, _MTL_PRIVATE_SEL(startCaptureWithDevice_), device);
197
}
198
199
_MTL_INLINE void MTL::CaptureManager::startCapture(const MTL::CommandQueue* commandQueue)
200
{
201
Object::sendMessage<void>(this, _MTL_PRIVATE_SEL(startCaptureWithCommandQueue_), commandQueue);
202
}
203
204
_MTL_INLINE void MTL::CaptureManager::startCapture(const MTL::CaptureScope* captureScope)
205
{
206
Object::sendMessage<void>(this, _MTL_PRIVATE_SEL(startCaptureWithScope_), captureScope);
207
}
208
209
_MTL_INLINE void MTL::CaptureManager::stopCapture()
210
{
211
Object::sendMessage<void>(this, _MTL_PRIVATE_SEL(stopCapture));
212
}
213
214
_MTL_INLINE bool MTL::CaptureManager::supportsDestination(MTL::CaptureDestination destination)
215
{
216
return Object::sendMessageSafe<bool>(this, _MTL_PRIVATE_SEL(supportsDestination_), destination);
217
}
218
219