Book a Demo!
CoCalc Logo Icon
StoreFeaturesDocsShareSupportNewsAboutPoliciesSign UpSign In
godotengine
GitHub Repository: godotengine/godot
Path: blob/master/thirdparty/metal-cpp/MetalFX/MTLFXSpatialScaler.hpp
21085 views
1
//-------------------------------------------------------------------------------------------------------------------------------------------------------------
2
//
3
// MetalFX/MTLFXSpatialScaler.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
//-------------------------------------------------------------------------------------------------------------------------------------------------------------
24
25
#include "MTLFXDefines.hpp"
26
#include "MTLFXPrivate.hpp"
27
28
#include "../Metal/Metal.hpp"
29
30
//-------------------------------------------------------------------------------------------------------------------------------------------------------------
31
32
namespace MTL4FX
33
{
34
class SpatialScaler;
35
}
36
37
namespace MTLFX
38
{
39
_MTLFX_ENUM( NS::Integer, SpatialScalerColorProcessingMode )
40
{
41
SpatialScalerColorProcessingModePerceptual = 0,
42
SpatialScalerColorProcessingModeLinear = 1,
43
SpatialScalerColorProcessingModeHDR = 2
44
};
45
46
class SpatialScalerDescriptor : public NS::Copying< SpatialScalerDescriptor >
47
{
48
public:
49
static class SpatialScalerDescriptor* alloc();
50
class SpatialScalerDescriptor* init();
51
52
MTL::PixelFormat colorTextureFormat() const;
53
void setColorTextureFormat( MTL::PixelFormat format );
54
55
MTL::PixelFormat outputTextureFormat() const;
56
void setOutputTextureFormat( MTL::PixelFormat format );
57
58
NS::UInteger inputWidth() const;
59
void setInputWidth( NS::UInteger width );
60
61
NS::UInteger inputHeight() const;
62
void setInputHeight( NS::UInteger height );
63
64
NS::UInteger outputWidth() const;
65
void setOutputWidth( NS::UInteger width );
66
67
NS::UInteger outputHeight() const;
68
void setOutputHeight( NS::UInteger height );
69
70
SpatialScalerColorProcessingMode colorProcessingMode() const;
71
void setColorProcessingMode( SpatialScalerColorProcessingMode mode );
72
73
class SpatialScaler* newSpatialScaler( const MTL::Device* pDevice ) const;
74
MTL4FX::SpatialScaler* newSpatialScaler( const MTL::Device* pDevice, const MTL4::Compiler* pCompiler ) const;
75
76
static bool supportsDevice( const MTL::Device* pDevice);
77
static bool supportsMetal4FX( const MTL::Device* pDevice );
78
};
79
80
class SpatialScalerBase : public NS::Referencing< SpatialScaler >
81
{
82
public:
83
MTL::TextureUsage colorTextureUsage() const;
84
MTL::TextureUsage outputTextureUsage() const;
85
86
NS::UInteger inputContentWidth() const;
87
void setInputContentWidth( NS::UInteger width );
88
89
NS::UInteger inputContentHeight() const;
90
void setInputContentHeight( NS::UInteger height );
91
92
MTL::Texture* colorTexture() const;
93
void setColorTexture( MTL::Texture* pTexture );
94
95
MTL::Texture* outputTexture() const;
96
void setOutputTexture( MTL::Texture* pTexture );
97
98
MTL::PixelFormat colorTextureFormat() const;
99
MTL::PixelFormat outputTextureFormat() const;
100
NS::UInteger inputWidth() const;
101
NS::UInteger inputHeight() const;
102
NS::UInteger outputWidth() const;
103
NS::UInteger outputHeight() const;
104
SpatialScalerColorProcessingMode colorProcessingMode() const;
105
106
MTL::Fence* fence() const;
107
void setFence( MTL::Fence* pFence );
108
};
109
110
class SpatialScaler : public NS::Referencing< SpatialScaler, SpatialScalerBase >
111
{
112
public:
113
void encodeToCommandBuffer( MTL::CommandBuffer* pCommandBuffer );
114
};
115
}
116
117
//-------------------------------------------------------------------------------------------------------------------------------------------------------------
118
119
_MTLFX_INLINE MTLFX::SpatialScalerDescriptor* MTLFX::SpatialScalerDescriptor::alloc()
120
{
121
return NS::Object::alloc< SpatialScalerDescriptor >( _MTLFX_PRIVATE_CLS( MTLFXSpatialScalerDescriptor ) );
122
}
123
124
//-------------------------------------------------------------------------------------------------------------------------------------------------------------
125
126
_MTLFX_INLINE MTLFX::SpatialScalerDescriptor* MTLFX::SpatialScalerDescriptor::init()
127
{
128
return NS::Object::init< SpatialScalerDescriptor >();
129
}
130
131
//-------------------------------------------------------------------------------------------------------------------------------------------------------------
132
133
_MTLFX_INLINE MTL::PixelFormat MTLFX::SpatialScalerDescriptor::colorTextureFormat() const
134
{
135
return Object::sendMessage< MTL::PixelFormat >( this, _MTLFX_PRIVATE_SEL( colorTextureFormat ) );
136
}
137
138
//-------------------------------------------------------------------------------------------------------------------------------------------------------------
139
140
_MTLFX_INLINE void MTLFX::SpatialScalerDescriptor::setColorTextureFormat( MTL::PixelFormat format )
141
{
142
Object::sendMessage< void >( this, _MTLFX_PRIVATE_SEL( setColorTextureFormat_ ), format );
143
}
144
145
//-------------------------------------------------------------------------------------------------------------------------------------------------------------
146
147
_MTLFX_INLINE MTL::PixelFormat MTLFX::SpatialScalerDescriptor::outputTextureFormat() const
148
{
149
return Object::sendMessage< MTL::PixelFormat >( this, _MTLFX_PRIVATE_SEL( outputTextureFormat ) );
150
}
151
152
//-------------------------------------------------------------------------------------------------------------------------------------------------------------
153
154
_MTLFX_INLINE void MTLFX::SpatialScalerDescriptor::setOutputTextureFormat( MTL::PixelFormat format )
155
{
156
Object::sendMessage< void >( this, _MTLFX_PRIVATE_SEL( setOutputTextureFormat_ ), format );
157
}
158
159
//-------------------------------------------------------------------------------------------------------------------------------------------------------------
160
161
_MTLFX_INLINE NS::UInteger MTLFX::SpatialScalerDescriptor::inputWidth() const
162
{
163
return Object::sendMessage< NS::UInteger >( this, _MTLFX_PRIVATE_SEL( inputWidth ) );
164
}
165
166
//-------------------------------------------------------------------------------------------------------------------------------------------------------------
167
168
_MTLFX_INLINE void MTLFX::SpatialScalerDescriptor::setInputWidth( NS::UInteger width )
169
{
170
Object::sendMessage< void >( this, _MTLFX_PRIVATE_SEL( setInputWidth_ ), width );
171
}
172
173
//-------------------------------------------------------------------------------------------------------------------------------------------------------------
174
175
_MTLFX_INLINE NS::UInteger MTLFX::SpatialScalerDescriptor::inputHeight() const
176
{
177
return Object::sendMessage< NS::UInteger >( this, _MTLFX_PRIVATE_SEL( inputHeight ) );
178
}
179
180
//-------------------------------------------------------------------------------------------------------------------------------------------------------------
181
182
_MTLFX_INLINE void MTLFX::SpatialScalerDescriptor::setInputHeight( NS::UInteger height )
183
{
184
Object::sendMessage< void >( this, _MTLFX_PRIVATE_SEL( setInputHeight_ ), height );
185
}
186
187
//-------------------------------------------------------------------------------------------------------------------------------------------------------------
188
189
_MTLFX_INLINE NS::UInteger MTLFX::SpatialScalerDescriptor::outputWidth() const
190
{
191
return Object::sendMessage< NS::UInteger >( this, _MTLFX_PRIVATE_SEL( outputWidth ) );
192
}
193
194
//-------------------------------------------------------------------------------------------------------------------------------------------------------------
195
196
_MTLFX_INLINE void MTLFX::SpatialScalerDescriptor::setOutputWidth( NS::UInteger width )
197
{
198
Object::sendMessage< void >( this, _MTLFX_PRIVATE_SEL( setOutputWidth_ ), width );
199
}
200
201
//-------------------------------------------------------------------------------------------------------------------------------------------------------------
202
203
_MTLFX_INLINE NS::UInteger MTLFX::SpatialScalerDescriptor::outputHeight() const
204
{
205
return Object::sendMessage< NS::UInteger >( this, _MTLFX_PRIVATE_SEL( outputHeight ) );
206
}
207
208
//-------------------------------------------------------------------------------------------------------------------------------------------------------------
209
210
_MTLFX_INLINE void MTLFX::SpatialScalerDescriptor::setOutputHeight( NS::UInteger height )
211
{
212
Object::sendMessage< void >( this, _MTLFX_PRIVATE_SEL( setOutputHeight_ ), height );
213
}
214
215
//-------------------------------------------------------------------------------------------------------------------------------------------------------------
216
217
_MTLFX_INLINE MTLFX::SpatialScalerColorProcessingMode MTLFX::SpatialScalerDescriptor::colorProcessingMode() const
218
{
219
return Object::sendMessage< SpatialScalerColorProcessingMode >( this, _MTLFX_PRIVATE_SEL( colorProcessingMode ) );
220
}
221
222
//-------------------------------------------------------------------------------------------------------------------------------------------------------------
223
224
_MTLFX_INLINE void MTLFX::SpatialScalerDescriptor::setColorProcessingMode( SpatialScalerColorProcessingMode mode )
225
{
226
Object::sendMessage< void >( this, _MTLFX_PRIVATE_SEL( setColorProcessingMode_ ), mode );
227
}
228
229
//-------------------------------------------------------------------------------------------------------------------------------------------------------------
230
231
_MTLFX_INLINE MTLFX::SpatialScaler* MTLFX::SpatialScalerDescriptor::newSpatialScaler( const MTL::Device* pDevice ) const
232
{
233
return Object::sendMessage< SpatialScaler* >( this, _MTLFX_PRIVATE_SEL( newSpatialScalerWithDevice_ ), pDevice );
234
}
235
236
//-------------------------------------------------------------------------------------------------------------------------------------------------------------
237
238
_MTLFX_INLINE MTL4FX::SpatialScaler* MTLFX::SpatialScalerDescriptor::newSpatialScaler( const MTL::Device* pDevice, const MTL4::Compiler* pCompiler ) const
239
{
240
return Object::sendMessage< MTL4FX::SpatialScaler* >( this, _MTLFX_PRIVATE_SEL( newSpatialScalerWithDevice_compiler_ ), pDevice, pCompiler );
241
}
242
243
//-------------------------------------------------------------------------------------------------------------------------------------------------------------
244
245
_MTLFX_INLINE bool MTLFX::SpatialScalerDescriptor::supportsDevice( const MTL::Device* pDevice )
246
{
247
return Object::sendMessageSafe< bool >( _NS_PRIVATE_CLS( MTLFXSpatialScalerDescriptor ), _MTLFX_PRIVATE_SEL( supportsDevice_ ), pDevice );
248
}
249
250
//-------------------------------------------------------------------------------------------------------------------------------------------------------------
251
252
_MTLFX_INLINE bool MTLFX::SpatialScalerDescriptor::supportsMetal4FX( const MTL::Device* pDevice )
253
{
254
return Object::sendMessageSafe< bool >( _NS_PRIVATE_CLS( MTLFXSpatialScalerDescriptor ), _MTLFX_PRIVATE_SEL( supportsMetal4FX_ ), pDevice );
255
}
256
257
//-------------------------------------------------------------------------------------------------------------------------------------------------------------
258
259
_MTLFX_INLINE MTL::TextureUsage MTLFX::SpatialScalerBase::colorTextureUsage() const
260
{
261
return Object::sendMessage< MTL::TextureUsage >( this, _MTLFX_PRIVATE_SEL( colorTextureUsage ) );
262
}
263
264
//-------------------------------------------------------------------------------------------------------------------------------------------------------------
265
266
_MTLFX_INLINE MTL::TextureUsage MTLFX::SpatialScalerBase::outputTextureUsage() const
267
{
268
return Object::sendMessage< MTL::TextureUsage >( this, _MTLFX_PRIVATE_SEL( outputTextureUsage ) );
269
}
270
271
//-------------------------------------------------------------------------------------------------------------------------------------------------------------
272
273
_MTLFX_INLINE NS::UInteger MTLFX::SpatialScalerBase::inputContentWidth() const
274
{
275
return Object::sendMessage< NS::UInteger >( this, _MTLFX_PRIVATE_SEL( inputContentWidth ) );
276
}
277
278
//-------------------------------------------------------------------------------------------------------------------------------------------------------------
279
280
_MTLFX_INLINE void MTLFX::SpatialScalerBase::setInputContentWidth( NS::UInteger width )
281
{
282
Object::sendMessage< void >( this, _MTLFX_PRIVATE_SEL( setInputContentWidth_ ), width );
283
}
284
285
//-------------------------------------------------------------------------------------------------------------------------------------------------------------
286
287
_MTLFX_INLINE NS::UInteger MTLFX::SpatialScalerBase::inputContentHeight() const
288
{
289
return Object::sendMessage< NS::UInteger >( this, _MTLFX_PRIVATE_SEL( inputContentHeight ) );
290
}
291
292
//-------------------------------------------------------------------------------------------------------------------------------------------------------------
293
294
_MTLFX_INLINE void MTLFX::SpatialScalerBase::setInputContentHeight( NS::UInteger height )
295
{
296
Object::sendMessage< void >( this, _MTLFX_PRIVATE_SEL( setInputContentHeight_ ), height );
297
}
298
299
//-------------------------------------------------------------------------------------------------------------------------------------------------------------
300
301
_MTLFX_INLINE MTL::Texture* MTLFX::SpatialScalerBase::colorTexture() const
302
{
303
return Object::sendMessage< MTL::Texture* >( this, _MTLFX_PRIVATE_SEL( colorTexture ) );
304
}
305
306
//-------------------------------------------------------------------------------------------------------------------------------------------------------------
307
308
_MTLFX_INLINE void MTLFX::SpatialScalerBase::setColorTexture( MTL::Texture* pTexture )
309
{
310
Object::sendMessage< void >( this, _MTLFX_PRIVATE_SEL( setColorTexture_ ), pTexture );
311
}
312
313
//-------------------------------------------------------------------------------------------------------------------------------------------------------------
314
315
_MTLFX_INLINE MTL::Texture* MTLFX::SpatialScalerBase::outputTexture() const
316
{
317
return Object::sendMessage< MTL::Texture* >( this, _MTLFX_PRIVATE_SEL( outputTexture ) );
318
}
319
320
//-------------------------------------------------------------------------------------------------------------------------------------------------------------
321
322
_MTLFX_INLINE void MTLFX::SpatialScalerBase::setOutputTexture( MTL::Texture* pTexture )
323
{
324
Object::sendMessage< void >( this, _MTLFX_PRIVATE_SEL( setOutputTexture_ ), pTexture );
325
}
326
327
//-------------------------------------------------------------------------------------------------------------------------------------------------------------
328
329
_MTLFX_INLINE MTL::PixelFormat MTLFX::SpatialScalerBase::colorTextureFormat() const
330
{
331
return Object::sendMessage< MTL::PixelFormat >( this, _MTLFX_PRIVATE_SEL( colorTextureFormat ) );
332
}
333
334
//-------------------------------------------------------------------------------------------------------------------------------------------------------------
335
336
_MTLFX_INLINE MTL::PixelFormat MTLFX::SpatialScalerBase::outputTextureFormat() const
337
{
338
return Object::sendMessage< MTL::PixelFormat >( this, _MTLFX_PRIVATE_SEL( outputTextureFormat ) );
339
}
340
341
//-------------------------------------------------------------------------------------------------------------------------------------------------------------
342
343
_MTLFX_INLINE NS::UInteger MTLFX::SpatialScalerBase::inputWidth() const
344
{
345
return Object::sendMessage< NS::UInteger >( this, _MTLFX_PRIVATE_SEL( inputWidth ) );
346
}
347
348
//-------------------------------------------------------------------------------------------------------------------------------------------------------------
349
350
_MTLFX_INLINE NS::UInteger MTLFX::SpatialScalerBase::inputHeight() const
351
{
352
return Object::sendMessage< NS::UInteger >( this, _MTLFX_PRIVATE_SEL( inputHeight ) );
353
}
354
355
//-------------------------------------------------------------------------------------------------------------------------------------------------------------
356
357
_MTLFX_INLINE NS::UInteger MTLFX::SpatialScalerBase::outputWidth() const
358
{
359
return Object::sendMessage< NS::UInteger >( this, _MTLFX_PRIVATE_SEL( outputWidth ) );
360
}
361
362
//-------------------------------------------------------------------------------------------------------------------------------------------------------------
363
364
_MTLFX_INLINE NS::UInteger MTLFX::SpatialScalerBase::outputHeight() const
365
{
366
return Object::sendMessage< NS::UInteger >( this, _MTLFX_PRIVATE_SEL( outputHeight ) );
367
}
368
369
//-------------------------------------------------------------------------------------------------------------------------------------------------------------
370
371
_MTLFX_INLINE MTLFX::SpatialScalerColorProcessingMode MTLFX::SpatialScalerBase::colorProcessingMode() const
372
{
373
return Object::sendMessage< SpatialScalerColorProcessingMode >( this, _MTLFX_PRIVATE_SEL( colorProcessingMode ) );
374
}
375
376
//-------------------------------------------------------------------------------------------------------------------------------------------------------------
377
378
_MTLFX_INLINE MTL::Fence* MTLFX::SpatialScalerBase::fence() const
379
{
380
return Object::sendMessage< MTL::Fence* >( this, _MTLFX_PRIVATE_SEL( fence ) );
381
}
382
383
//-------------------------------------------------------------------------------------------------------------------------------------------------------------
384
385
_MTLFX_INLINE void MTLFX::SpatialScalerBase::setFence( MTL::Fence* pFence )
386
{
387
Object::sendMessage< void >( this, _MTLFX_PRIVATE_SEL( setFence_ ), pFence );
388
}
389
390
//-------------------------------------------------------------------------------------------------------------------------------------------------------------
391
392
_MTLFX_INLINE void MTLFX::SpatialScaler::encodeToCommandBuffer( MTL::CommandBuffer* pCommandBuffer )
393
{
394
Object::sendMessage< void >( this, _MTLFX_PRIVATE_SEL( encodeToCommandBuffer_ ), pCommandBuffer );
395
}
396
397
//-------------------------------------------------------------------------------------------------------------------------------------------------------------
398
399