• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1// GENERATED FILE - DO NOT EDIT.
2// Generated by gen_mtl_format_table.py using data from mtl_format_map.json
3//
4// Copyright 2020 The ANGLE Project Authors. All rights reserved.
5// Use of this source code is governed by a BSD-style license that can be
6// found in the LICENSE file.
7//
8// Metal Format table:
9//   Conversion from ANGLE format to Metal format.
10
11#import <Metal/Metal.h>
12#include <TargetConditionals.h>
13
14#include "image_util/copyimage.h"
15#include "image_util/generatemip.h"
16#include "image_util/loadimage.h"
17#include "libANGLE/renderer/Format.h"
18#include "libANGLE/renderer/metal/DisplayMtl.h"
19#include "libANGLE/renderer/metal/mtl_format_utils.h"
20#include "libANGLE/renderer/metal/mtl_utils.h"
21
22using namespace angle;
23
24namespace rx
25{
26namespace mtl
27{
28
29angle::FormatID Format::MetalToAngleFormatID(MTLPixelFormat formatMtl)
30{
31    // Actual conversion
32    switch (formatMtl)
33    {
34        case MTLPixelFormatA8Unorm:
35            return angle::FormatID::A8_UNORM;
36        case MTLPixelFormatBGR10A2Unorm:
37            return angle::FormatID::B10G10R10A2_UNORM;
38        case MTLPixelFormatBGRA8Unorm:
39            return angle::FormatID::B8G8R8A8_UNORM;
40        case MTLPixelFormatBGRA8Unorm_sRGB:
41            return angle::FormatID::B8G8R8A8_UNORM_SRGB;
42        case MTLPixelFormatDepth32Float:
43            return angle::FormatID::D32_FLOAT;
44        case MTLPixelFormatDepth32Float_Stencil8:
45            return angle::FormatID::D32_FLOAT_S8X24_UINT;
46        case MTLPixelFormatInvalid:
47            return angle::FormatID::NONE;
48        case MTLPixelFormatRGB10A2Uint:
49            return angle::FormatID::R10G10B10A2_UINT;
50        case MTLPixelFormatRGB10A2Unorm:
51            return angle::FormatID::R10G10B10A2_UNORM;
52        case MTLPixelFormatRG11B10Float:
53            return angle::FormatID::R11G11B10_FLOAT;
54        case MTLPixelFormatRGBA16Float:
55            return angle::FormatID::R16G16B16A16_FLOAT;
56        case MTLPixelFormatRGBA16Sint:
57            return angle::FormatID::R16G16B16A16_SINT;
58        case MTLPixelFormatRGBA16Snorm:
59            return angle::FormatID::R16G16B16A16_SNORM;
60        case MTLPixelFormatRGBA16Uint:
61            return angle::FormatID::R16G16B16A16_UINT;
62        case MTLPixelFormatRGBA16Unorm:
63            return angle::FormatID::R16G16B16A16_UNORM;
64        case MTLPixelFormatRG16Float:
65            return angle::FormatID::R16G16_FLOAT;
66        case MTLPixelFormatRG16Sint:
67            return angle::FormatID::R16G16_SINT;
68        case MTLPixelFormatRG16Snorm:
69            return angle::FormatID::R16G16_SNORM;
70        case MTLPixelFormatRG16Uint:
71            return angle::FormatID::R16G16_UINT;
72        case MTLPixelFormatRG16Unorm:
73            return angle::FormatID::R16G16_UNORM;
74        case MTLPixelFormatR16Float:
75            return angle::FormatID::R16_FLOAT;
76        case MTLPixelFormatR16Sint:
77            return angle::FormatID::R16_SINT;
78        case MTLPixelFormatR16Snorm:
79            return angle::FormatID::R16_SNORM;
80        case MTLPixelFormatR16Uint:
81            return angle::FormatID::R16_UINT;
82        case MTLPixelFormatR16Unorm:
83            return angle::FormatID::R16_UNORM;
84        case MTLPixelFormatRGBA32Float:
85            return angle::FormatID::R32G32B32A32_FLOAT;
86        case MTLPixelFormatRGBA32Sint:
87            return angle::FormatID::R32G32B32A32_SINT;
88        case MTLPixelFormatRGBA32Uint:
89            return angle::FormatID::R32G32B32A32_UINT;
90        case MTLPixelFormatRG32Float:
91            return angle::FormatID::R32G32_FLOAT;
92        case MTLPixelFormatRG32Sint:
93            return angle::FormatID::R32G32_SINT;
94        case MTLPixelFormatRG32Uint:
95            return angle::FormatID::R32G32_UINT;
96        case MTLPixelFormatR32Float:
97            return angle::FormatID::R32_FLOAT;
98        case MTLPixelFormatR32Sint:
99            return angle::FormatID::R32_SINT;
100        case MTLPixelFormatR32Uint:
101            return angle::FormatID::R32_UINT;
102        case MTLPixelFormatRGBA8Sint:
103            return angle::FormatID::R8G8B8A8_SINT;
104        case MTLPixelFormatRGBA8Snorm:
105            return angle::FormatID::R8G8B8A8_SNORM;
106        case MTLPixelFormatRGBA8Uint:
107            return angle::FormatID::R8G8B8A8_UINT;
108        case MTLPixelFormatRGBA8Unorm:
109            return angle::FormatID::R8G8B8A8_UNORM;
110        case MTLPixelFormatRGBA8Unorm_sRGB:
111            return angle::FormatID::R8G8B8A8_UNORM_SRGB;
112        case MTLPixelFormatRG8Sint:
113            return angle::FormatID::R8G8_SINT;
114        case MTLPixelFormatRG8Snorm:
115            return angle::FormatID::R8G8_SNORM;
116        case MTLPixelFormatRG8Uint:
117            return angle::FormatID::R8G8_UINT;
118        case MTLPixelFormatRG8Unorm:
119            return angle::FormatID::R8G8_UNORM;
120        case MTLPixelFormatR8Sint:
121            return angle::FormatID::R8_SINT;
122        case MTLPixelFormatR8Snorm:
123            return angle::FormatID::R8_SNORM;
124        case MTLPixelFormatR8Uint:
125            return angle::FormatID::R8_UINT;
126        case MTLPixelFormatR8Unorm:
127            return angle::FormatID::R8_UNORM;
128        case MTLPixelFormatRGB9E5Float:
129            return angle::FormatID::R9G9B9E5_SHAREDEXP;
130        case MTLPixelFormatStencil8:
131            return angle::FormatID::S8_UINT;
132#if TARGET_OS_OSX || TARGET_OS_MACCATALYST
133        case MTLPixelFormatBC1_RGBA:
134            return angle::FormatID::BC1_RGBA_UNORM_BLOCK;
135        case MTLPixelFormatBC1_RGBA_sRGB:
136            return angle::FormatID::BC1_RGBA_UNORM_SRGB_BLOCK;
137        case MTLPixelFormatBC2_RGBA:
138            return angle::FormatID::BC2_RGBA_UNORM_BLOCK;
139        case MTLPixelFormatBC2_RGBA_sRGB:
140            return angle::FormatID::BC2_RGBA_UNORM_SRGB_BLOCK;
141        case MTLPixelFormatBC3_RGBA:
142            return angle::FormatID::BC3_RGBA_UNORM_BLOCK;
143        case MTLPixelFormatBC3_RGBA_sRGB:
144            return angle::FormatID::BC3_RGBA_UNORM_SRGB_BLOCK;
145        case MTLPixelFormatBC4_RSnorm:
146            return angle::FormatID::BC4_RED_SNORM_BLOCK;
147        case MTLPixelFormatBC4_RUnorm:
148            return angle::FormatID::BC4_RED_UNORM_BLOCK;
149        case MTLPixelFormatBC5_RGSnorm:
150            return angle::FormatID::BC5_RG_SNORM_BLOCK;
151        case MTLPixelFormatBC5_RGUnorm:
152            return angle::FormatID::BC5_RG_UNORM_BLOCK;
153        case MTLPixelFormatBC6H_RGBFloat:
154            return angle::FormatID::BC6H_RGB_SFLOAT_BLOCK;
155        case MTLPixelFormatBC6H_RGBUfloat:
156            return angle::FormatID::BC6H_RGB_UFLOAT_BLOCK;
157        case MTLPixelFormatBC7_RGBAUnorm:
158            return angle::FormatID::BC7_RGBA_UNORM_BLOCK;
159        case MTLPixelFormatBC7_RGBAUnorm_sRGB:
160            return angle::FormatID::BC7_RGBA_UNORM_SRGB_BLOCK;
161        case MTLPixelFormatDepth16Unorm:
162            return angle::FormatID::D16_UNORM;
163        case MTLPixelFormatDepth24Unorm_Stencil8:
164            return angle::FormatID::D24_UNORM_S8_UINT;
165#endif  // TARGET_OS_OSX || TARGET_OS_MACCATALYST
166#if TARGET_OS_IPHONE || (TARGET_OS_OSX && (__MAC_OS_X_VERSION_MAX_ALLOWED >= 110000))
167        case MTLPixelFormatASTC_10x10_sRGB:
168            return angle::FormatID::ASTC_10x10_SRGB_BLOCK;
169        case MTLPixelFormatASTC_10x5_sRGB:
170            return angle::FormatID::ASTC_10x5_SRGB_BLOCK;
171        case MTLPixelFormatASTC_10x6_sRGB:
172            return angle::FormatID::ASTC_10x6_SRGB_BLOCK;
173        case MTLPixelFormatASTC_10x8_sRGB:
174            return angle::FormatID::ASTC_10x8_SRGB_BLOCK;
175        case MTLPixelFormatASTC_12x10_sRGB:
176            return angle::FormatID::ASTC_12x10_SRGB_BLOCK;
177        case MTLPixelFormatASTC_12x12_sRGB:
178            return angle::FormatID::ASTC_12x12_SRGB_BLOCK;
179        case MTLPixelFormatASTC_4x4_sRGB:
180            return angle::FormatID::ASTC_4x4_SRGB_BLOCK;
181        case MTLPixelFormatASTC_5x4_sRGB:
182            return angle::FormatID::ASTC_5x4_SRGB_BLOCK;
183        case MTLPixelFormatASTC_5x5_sRGB:
184            return angle::FormatID::ASTC_5x5_SRGB_BLOCK;
185        case MTLPixelFormatASTC_6x5_sRGB:
186            return angle::FormatID::ASTC_6x5_SRGB_BLOCK;
187        case MTLPixelFormatASTC_6x6_sRGB:
188            return angle::FormatID::ASTC_6x6_SRGB_BLOCK;
189        case MTLPixelFormatASTC_8x5_sRGB:
190            return angle::FormatID::ASTC_8x5_SRGB_BLOCK;
191        case MTLPixelFormatASTC_8x6_sRGB:
192            return angle::FormatID::ASTC_8x6_SRGB_BLOCK;
193        case MTLPixelFormatASTC_8x8_sRGB:
194            return angle::FormatID::ASTC_8x8_SRGB_BLOCK;
195        case MTLPixelFormatEAC_RG11Snorm:
196            return angle::FormatID::EAC_R11G11_SNORM_BLOCK;
197        case MTLPixelFormatEAC_RG11Unorm:
198            return angle::FormatID::EAC_R11G11_UNORM_BLOCK;
199        case MTLPixelFormatEAC_R11Snorm:
200            return angle::FormatID::EAC_R11_SNORM_BLOCK;
201        case MTLPixelFormatEAC_R11Unorm:
202            return angle::FormatID::EAC_R11_UNORM_BLOCK;
203        case MTLPixelFormatETC2_RGB8A1_sRGB:
204            return angle::FormatID::ETC2_R8G8B8A1_SRGB_BLOCK;
205        case MTLPixelFormatETC2_RGB8A1:
206            return angle::FormatID::ETC2_R8G8B8A1_UNORM_BLOCK;
207        case MTLPixelFormatEAC_RGBA8_sRGB:
208            return angle::FormatID::ETC2_R8G8B8A8_SRGB_BLOCK;
209        case MTLPixelFormatEAC_RGBA8:
210            return angle::FormatID::ETC2_R8G8B8A8_UNORM_BLOCK;
211        case MTLPixelFormatETC2_RGB8_sRGB:
212            return angle::FormatID::ETC2_R8G8B8_SRGB_BLOCK;
213        case MTLPixelFormatETC2_RGB8:
214            return angle::FormatID::ETC2_R8G8B8_UNORM_BLOCK;
215        case MTLPixelFormatPVRTC_RGBA_2BPP:
216            return angle::FormatID::PVRTC1_RGBA_2BPP_UNORM_BLOCK;
217        case MTLPixelFormatPVRTC_RGBA_2BPP_sRGB:
218            return angle::FormatID::PVRTC1_RGBA_2BPP_UNORM_SRGB_BLOCK;
219        case MTLPixelFormatPVRTC_RGBA_4BPP:
220            return angle::FormatID::PVRTC1_RGBA_4BPP_UNORM_BLOCK;
221        case MTLPixelFormatPVRTC_RGBA_4BPP_sRGB:
222            return angle::FormatID::PVRTC1_RGBA_4BPP_UNORM_SRGB_BLOCK;
223        case MTLPixelFormatPVRTC_RGB_2BPP:
224            return angle::FormatID::PVRTC1_RGB_2BPP_UNORM_BLOCK;
225        case MTLPixelFormatPVRTC_RGB_2BPP_sRGB:
226            return angle::FormatID::PVRTC1_RGB_2BPP_UNORM_SRGB_BLOCK;
227        case MTLPixelFormatPVRTC_RGB_4BPP:
228            return angle::FormatID::PVRTC1_RGB_4BPP_UNORM_BLOCK;
229        case MTLPixelFormatPVRTC_RGB_4BPP_sRGB:
230            return angle::FormatID::PVRTC1_RGB_4BPP_UNORM_SRGB_BLOCK;
231        case MTLPixelFormatABGR4Unorm:
232            return angle::FormatID::R4G4B4A4_UNORM;
233        case MTLPixelFormatA1BGR5Unorm:
234            return angle::FormatID::R5G5B5A1_UNORM;
235        case MTLPixelFormatB5G6R5Unorm:
236            return angle::FormatID::R5G6B5_UNORM;
237        case MTLPixelFormatRG8Unorm_sRGB:
238            return angle::FormatID::R8G8_UNORM_SRGB;
239        case MTLPixelFormatR8Unorm_sRGB:
240            return angle::FormatID::R8_UNORM_SRGB;
241        case MTLPixelFormatASTC_10x10_LDR:
242            return angle::FormatID::ASTC_10x10_UNORM_BLOCK;
243        case MTLPixelFormatASTC_10x5_LDR:
244            return angle::FormatID::ASTC_10x5_UNORM_BLOCK;
245        case MTLPixelFormatASTC_10x6_LDR:
246            return angle::FormatID::ASTC_10x6_UNORM_BLOCK;
247        case MTLPixelFormatASTC_10x8_LDR:
248            return angle::FormatID::ASTC_10x8_UNORM_BLOCK;
249        case MTLPixelFormatASTC_12x10_LDR:
250            return angle::FormatID::ASTC_12x10_UNORM_BLOCK;
251        case MTLPixelFormatASTC_12x12_LDR:
252            return angle::FormatID::ASTC_12x12_UNORM_BLOCK;
253        case MTLPixelFormatASTC_4x4_LDR:
254            return angle::FormatID::ASTC_4x4_UNORM_BLOCK;
255        case MTLPixelFormatASTC_5x4_LDR:
256            return angle::FormatID::ASTC_5x4_UNORM_BLOCK;
257        case MTLPixelFormatASTC_5x5_LDR:
258            return angle::FormatID::ASTC_5x5_UNORM_BLOCK;
259        case MTLPixelFormatASTC_6x5_LDR:
260            return angle::FormatID::ASTC_6x5_UNORM_BLOCK;
261        case MTLPixelFormatASTC_6x6_LDR:
262            return angle::FormatID::ASTC_6x6_UNORM_BLOCK;
263        case MTLPixelFormatASTC_8x5_LDR:
264            return angle::FormatID::ASTC_8x5_UNORM_BLOCK;
265        case MTLPixelFormatASTC_8x6_LDR:
266            return angle::FormatID::ASTC_8x6_UNORM_BLOCK;
267        case MTLPixelFormatASTC_8x8_LDR:
268            return angle::FormatID::ASTC_8x8_UNORM_BLOCK;
269#    if TARGET_OS_IOS || TARGET_OS_OSX
270        case MTLPixelFormatASTC_10x10_HDR:
271            return angle::FormatID::ASTC_10x10_UNORM_BLOCK;
272        case MTLPixelFormatASTC_10x5_HDR:
273            return angle::FormatID::ASTC_10x5_UNORM_BLOCK;
274        case MTLPixelFormatASTC_10x6_HDR:
275            return angle::FormatID::ASTC_10x6_UNORM_BLOCK;
276        case MTLPixelFormatASTC_10x8_HDR:
277            return angle::FormatID::ASTC_10x8_UNORM_BLOCK;
278        case MTLPixelFormatASTC_12x10_HDR:
279            return angle::FormatID::ASTC_12x10_UNORM_BLOCK;
280        case MTLPixelFormatASTC_12x12_HDR:
281            return angle::FormatID::ASTC_12x12_UNORM_BLOCK;
282        case MTLPixelFormatASTC_4x4_HDR:
283            return angle::FormatID::ASTC_4x4_UNORM_BLOCK;
284        case MTLPixelFormatASTC_5x4_HDR:
285            return angle::FormatID::ASTC_5x4_UNORM_BLOCK;
286        case MTLPixelFormatASTC_5x5_HDR:
287            return angle::FormatID::ASTC_5x5_UNORM_BLOCK;
288        case MTLPixelFormatASTC_6x5_HDR:
289            return angle::FormatID::ASTC_6x5_UNORM_BLOCK;
290        case MTLPixelFormatASTC_6x6_HDR:
291            return angle::FormatID::ASTC_6x6_UNORM_BLOCK;
292        case MTLPixelFormatASTC_8x5_HDR:
293            return angle::FormatID::ASTC_8x5_UNORM_BLOCK;
294        case MTLPixelFormatASTC_8x6_HDR:
295            return angle::FormatID::ASTC_8x6_UNORM_BLOCK;
296        case MTLPixelFormatASTC_8x8_HDR:
297            return angle::FormatID::ASTC_8x8_UNORM_BLOCK;
298#    endif  // TARGET_OS_IOS || TARGET_OS_OSX
299#endif      // TARGET_OS_IPHONE || mac 11.0+
300        default:
301            return angle::FormatID::NONE;
302    }
303}
304
305void Format::init(const DisplayMtl *display, angle::FormatID intendedFormatId_)
306{
307    this->intendedFormatId = intendedFormatId_;
308#if TARGET_OS_OSX || TARGET_OS_MACCATALYST
309    id<MTLDevice> metalDevice = display->getMetalDevice();
310#endif
311
312    // Actual conversion
313    switch (this->intendedFormatId)
314    {
315        case angle::FormatID::A8_UNORM:
316
317            this->metalFormat    = MTLPixelFormatA8Unorm;
318            this->actualFormatId = angle::FormatID::A8_UNORM;
319            break;
320
321        case angle::FormatID::B10G10R10A2_UNORM:
322
323            this->metalFormat    = MTLPixelFormatBGR10A2Unorm;
324            this->actualFormatId = angle::FormatID::B10G10R10A2_UNORM;
325            break;
326
327        case angle::FormatID::B8G8R8A8_UNORM:
328
329            this->metalFormat    = MTLPixelFormatBGRA8Unorm;
330            this->actualFormatId = angle::FormatID::B8G8R8A8_UNORM;
331            break;
332
333        case angle::FormatID::B8G8R8A8_UNORM_SRGB:
334
335            this->metalFormat    = MTLPixelFormatBGRA8Unorm_sRGB;
336            this->actualFormatId = angle::FormatID::B8G8R8A8_UNORM_SRGB;
337            break;
338
339        case angle::FormatID::D32_FLOAT:
340
341            this->metalFormat    = MTLPixelFormatDepth32Float;
342            this->actualFormatId = angle::FormatID::D32_FLOAT;
343            break;
344
345        case angle::FormatID::D32_FLOAT_S8X24_UINT:
346
347            this->metalFormat    = MTLPixelFormatDepth32Float_Stencil8;
348            this->actualFormatId = angle::FormatID::D32_FLOAT_S8X24_UINT;
349            break;
350
351        case angle::FormatID::NONE:
352
353            this->metalFormat    = MTLPixelFormatInvalid;
354            this->actualFormatId = angle::FormatID::NONE;
355            break;
356
357        case angle::FormatID::R10G10B10A2_UINT:
358
359            this->metalFormat    = MTLPixelFormatRGB10A2Uint;
360            this->actualFormatId = angle::FormatID::R10G10B10A2_UINT;
361            break;
362
363        case angle::FormatID::R10G10B10A2_UNORM:
364
365            this->metalFormat    = MTLPixelFormatRGB10A2Unorm;
366            this->actualFormatId = angle::FormatID::R10G10B10A2_UNORM;
367            break;
368
369        case angle::FormatID::R11G11B10_FLOAT:
370
371            this->metalFormat    = MTLPixelFormatRG11B10Float;
372            this->actualFormatId = angle::FormatID::R11G11B10_FLOAT;
373            break;
374
375        case angle::FormatID::R16G16B16A16_FLOAT:
376
377            this->metalFormat    = MTLPixelFormatRGBA16Float;
378            this->actualFormatId = angle::FormatID::R16G16B16A16_FLOAT;
379            break;
380
381        case angle::FormatID::R16G16B16A16_SINT:
382
383            this->metalFormat    = MTLPixelFormatRGBA16Sint;
384            this->actualFormatId = angle::FormatID::R16G16B16A16_SINT;
385            break;
386
387        case angle::FormatID::R16G16B16A16_SNORM:
388
389            this->metalFormat    = MTLPixelFormatRGBA16Snorm;
390            this->actualFormatId = angle::FormatID::R16G16B16A16_SNORM;
391            break;
392
393        case angle::FormatID::R16G16B16A16_UINT:
394
395            this->metalFormat    = MTLPixelFormatRGBA16Uint;
396            this->actualFormatId = angle::FormatID::R16G16B16A16_UINT;
397            break;
398
399        case angle::FormatID::R16G16B16A16_UNORM:
400
401            this->metalFormat    = MTLPixelFormatRGBA16Unorm;
402            this->actualFormatId = angle::FormatID::R16G16B16A16_UNORM;
403            break;
404
405        case angle::FormatID::R16G16_FLOAT:
406
407            this->metalFormat    = MTLPixelFormatRG16Float;
408            this->actualFormatId = angle::FormatID::R16G16_FLOAT;
409            break;
410
411        case angle::FormatID::R16G16_SINT:
412
413            this->metalFormat    = MTLPixelFormatRG16Sint;
414            this->actualFormatId = angle::FormatID::R16G16_SINT;
415            break;
416
417        case angle::FormatID::R16G16_SNORM:
418
419            this->metalFormat    = MTLPixelFormatRG16Snorm;
420            this->actualFormatId = angle::FormatID::R16G16_SNORM;
421            break;
422
423        case angle::FormatID::R16G16_UINT:
424
425            this->metalFormat    = MTLPixelFormatRG16Uint;
426            this->actualFormatId = angle::FormatID::R16G16_UINT;
427            break;
428
429        case angle::FormatID::R16G16_UNORM:
430
431            this->metalFormat    = MTLPixelFormatRG16Unorm;
432            this->actualFormatId = angle::FormatID::R16G16_UNORM;
433            break;
434
435        case angle::FormatID::R16_FLOAT:
436
437            this->metalFormat    = MTLPixelFormatR16Float;
438            this->actualFormatId = angle::FormatID::R16_FLOAT;
439            break;
440
441        case angle::FormatID::R16_SINT:
442
443            this->metalFormat    = MTLPixelFormatR16Sint;
444            this->actualFormatId = angle::FormatID::R16_SINT;
445            break;
446
447        case angle::FormatID::R16_SNORM:
448
449            this->metalFormat    = MTLPixelFormatR16Snorm;
450            this->actualFormatId = angle::FormatID::R16_SNORM;
451            break;
452
453        case angle::FormatID::R16_UINT:
454
455            this->metalFormat    = MTLPixelFormatR16Uint;
456            this->actualFormatId = angle::FormatID::R16_UINT;
457            break;
458
459        case angle::FormatID::R16_UNORM:
460
461            this->metalFormat    = MTLPixelFormatR16Unorm;
462            this->actualFormatId = angle::FormatID::R16_UNORM;
463            break;
464
465        case angle::FormatID::R32G32B32A32_FLOAT:
466
467            this->metalFormat    = MTLPixelFormatRGBA32Float;
468            this->actualFormatId = angle::FormatID::R32G32B32A32_FLOAT;
469            break;
470
471        case angle::FormatID::R32G32B32A32_SINT:
472
473            this->metalFormat    = MTLPixelFormatRGBA32Sint;
474            this->actualFormatId = angle::FormatID::R32G32B32A32_SINT;
475            break;
476
477        case angle::FormatID::R32G32B32A32_UINT:
478
479            this->metalFormat    = MTLPixelFormatRGBA32Uint;
480            this->actualFormatId = angle::FormatID::R32G32B32A32_UINT;
481            break;
482
483        case angle::FormatID::R32G32_FLOAT:
484
485            this->metalFormat    = MTLPixelFormatRG32Float;
486            this->actualFormatId = angle::FormatID::R32G32_FLOAT;
487            break;
488
489        case angle::FormatID::R32G32_SINT:
490
491            this->metalFormat    = MTLPixelFormatRG32Sint;
492            this->actualFormatId = angle::FormatID::R32G32_SINT;
493            break;
494
495        case angle::FormatID::R32G32_UINT:
496
497            this->metalFormat    = MTLPixelFormatRG32Uint;
498            this->actualFormatId = angle::FormatID::R32G32_UINT;
499            break;
500
501        case angle::FormatID::R32_FLOAT:
502
503            this->metalFormat    = MTLPixelFormatR32Float;
504            this->actualFormatId = angle::FormatID::R32_FLOAT;
505            break;
506
507        case angle::FormatID::R32_SINT:
508
509            this->metalFormat    = MTLPixelFormatR32Sint;
510            this->actualFormatId = angle::FormatID::R32_SINT;
511            break;
512
513        case angle::FormatID::R32_UINT:
514
515            this->metalFormat    = MTLPixelFormatR32Uint;
516            this->actualFormatId = angle::FormatID::R32_UINT;
517            break;
518
519        case angle::FormatID::R8G8B8A8_SINT:
520
521            this->metalFormat    = MTLPixelFormatRGBA8Sint;
522            this->actualFormatId = angle::FormatID::R8G8B8A8_SINT;
523            break;
524
525        case angle::FormatID::R8G8B8A8_SNORM:
526
527            this->metalFormat    = MTLPixelFormatRGBA8Snorm;
528            this->actualFormatId = angle::FormatID::R8G8B8A8_SNORM;
529            break;
530
531        case angle::FormatID::R8G8B8A8_UINT:
532
533            this->metalFormat    = MTLPixelFormatRGBA8Uint;
534            this->actualFormatId = angle::FormatID::R8G8B8A8_UINT;
535            break;
536
537        case angle::FormatID::R8G8B8A8_UNORM:
538
539            this->metalFormat    = MTLPixelFormatRGBA8Unorm;
540            this->actualFormatId = angle::FormatID::R8G8B8A8_UNORM;
541            break;
542
543        case angle::FormatID::R8G8B8A8_UNORM_SRGB:
544
545            this->metalFormat    = MTLPixelFormatRGBA8Unorm_sRGB;
546            this->actualFormatId = angle::FormatID::R8G8B8A8_UNORM_SRGB;
547            break;
548
549        case angle::FormatID::R8G8_SINT:
550
551            this->metalFormat    = MTLPixelFormatRG8Sint;
552            this->actualFormatId = angle::FormatID::R8G8_SINT;
553            break;
554
555        case angle::FormatID::R8G8_SNORM:
556
557            this->metalFormat    = MTLPixelFormatRG8Snorm;
558            this->actualFormatId = angle::FormatID::R8G8_SNORM;
559            break;
560
561        case angle::FormatID::R8G8_UINT:
562
563            this->metalFormat    = MTLPixelFormatRG8Uint;
564            this->actualFormatId = angle::FormatID::R8G8_UINT;
565            break;
566
567        case angle::FormatID::R8G8_UNORM:
568
569            this->metalFormat    = MTLPixelFormatRG8Unorm;
570            this->actualFormatId = angle::FormatID::R8G8_UNORM;
571            break;
572
573        case angle::FormatID::R8_SINT:
574
575            this->metalFormat    = MTLPixelFormatR8Sint;
576            this->actualFormatId = angle::FormatID::R8_SINT;
577            break;
578
579        case angle::FormatID::R8_SNORM:
580
581            this->metalFormat    = MTLPixelFormatR8Snorm;
582            this->actualFormatId = angle::FormatID::R8_SNORM;
583            break;
584
585        case angle::FormatID::R8_UINT:
586
587            this->metalFormat    = MTLPixelFormatR8Uint;
588            this->actualFormatId = angle::FormatID::R8_UINT;
589            break;
590
591        case angle::FormatID::R8_UNORM:
592
593            this->metalFormat    = MTLPixelFormatR8Unorm;
594            this->actualFormatId = angle::FormatID::R8_UNORM;
595            break;
596
597        case angle::FormatID::R9G9B9E5_SHAREDEXP:
598
599            this->metalFormat    = MTLPixelFormatRGB9E5Float;
600            this->actualFormatId = angle::FormatID::R9G9B9E5_SHAREDEXP;
601            break;
602
603        case angle::FormatID::S8_UINT:
604
605            this->metalFormat    = MTLPixelFormatStencil8;
606            this->actualFormatId = angle::FormatID::S8_UINT;
607            break;
608
609        case angle::FormatID::A16_FLOAT:
610
611            this->metalFormat    = MTLPixelFormatRGBA16Float;
612            this->actualFormatId = angle::FormatID::R16G16B16A16_FLOAT;
613            break;
614
615        case angle::FormatID::A32_FLOAT:
616
617            this->metalFormat    = MTLPixelFormatRGBA32Float;
618            this->actualFormatId = angle::FormatID::R32G32B32A32_FLOAT;
619            break;
620
621        case angle::FormatID::D24_UNORM_X8_UINT:
622
623            this->metalFormat    = MTLPixelFormatDepth32Float;
624            this->actualFormatId = angle::FormatID::D32_FLOAT;
625            break;
626
627        case angle::FormatID::D32_UNORM:
628
629            this->metalFormat    = MTLPixelFormatDepth32Float;
630            this->actualFormatId = angle::FormatID::D32_FLOAT;
631            break;
632
633        case angle::FormatID::L16A16_FLOAT:
634
635            this->metalFormat    = MTLPixelFormatRGBA16Float;
636            this->actualFormatId = angle::FormatID::R16G16B16A16_FLOAT;
637            break;
638
639        case angle::FormatID::L16_FLOAT:
640
641            this->metalFormat    = MTLPixelFormatRGBA16Float;
642            this->actualFormatId = angle::FormatID::R16G16B16A16_FLOAT;
643            this->initFunction =
644                Initialize4ComponentData<GLhalf, 0x0000, 0x0000, 0x0000, gl::Float16One>;
645            break;
646
647        case angle::FormatID::L32A32_FLOAT:
648
649            this->metalFormat    = MTLPixelFormatRGBA32Float;
650            this->actualFormatId = angle::FormatID::R32G32B32A32_FLOAT;
651            break;
652
653        case angle::FormatID::L32_FLOAT:
654
655            this->metalFormat    = MTLPixelFormatRGBA32Float;
656            this->actualFormatId = angle::FormatID::R32G32B32A32_FLOAT;
657            this->initFunction   = Initialize4ComponentData<GLfloat, 0x00000000, 0x00000000,
658                                                          0x00000000, gl::Float32One>;
659            break;
660
661        case angle::FormatID::L8A8_UNORM:
662
663            this->metalFormat    = MTLPixelFormatRGBA8Unorm;
664            this->actualFormatId = angle::FormatID::R8G8B8A8_UNORM;
665            break;
666
667        case angle::FormatID::L8_UNORM:
668
669            this->metalFormat    = MTLPixelFormatRGBA8Unorm;
670            this->actualFormatId = angle::FormatID::R8G8B8A8_UNORM;
671            this->initFunction   = Initialize4ComponentData<GLubyte, 0x00, 0x00, 0x00, 0xFF>;
672            break;
673
674        case angle::FormatID::R16G16B16_FLOAT:
675
676            this->metalFormat    = MTLPixelFormatRGBA16Float;
677            this->actualFormatId = angle::FormatID::R16G16B16A16_FLOAT;
678            this->initFunction =
679                Initialize4ComponentData<GLhalf, 0x0000, 0x0000, 0x0000, gl::Float16One>;
680            break;
681
682        case angle::FormatID::R16G16B16_SINT:
683
684            this->metalFormat    = MTLPixelFormatRGBA16Sint;
685            this->actualFormatId = angle::FormatID::R16G16B16A16_SINT;
686            this->initFunction = Initialize4ComponentData<GLshort, 0x0000, 0x0000, 0x0000, 0x0001>;
687            break;
688
689        case angle::FormatID::R16G16B16_SNORM:
690
691            this->metalFormat    = MTLPixelFormatRGBA16Snorm;
692            this->actualFormatId = angle::FormatID::R16G16B16A16_SNORM;
693            this->initFunction = Initialize4ComponentData<GLushort, 0x0000, 0x0000, 0x0000, 0x7FFF>;
694            break;
695
696        case angle::FormatID::R16G16B16_UINT:
697
698            this->metalFormat    = MTLPixelFormatRGBA16Uint;
699            this->actualFormatId = angle::FormatID::R16G16B16A16_UINT;
700            this->initFunction = Initialize4ComponentData<GLushort, 0x0000, 0x0000, 0x0000, 0x0001>;
701            break;
702
703        case angle::FormatID::R16G16B16_UNORM:
704
705            this->metalFormat    = MTLPixelFormatRGBA16Unorm;
706            this->actualFormatId = angle::FormatID::R16G16B16A16_UNORM;
707            this->initFunction = Initialize4ComponentData<GLushort, 0x0000, 0x0000, 0x0000, 0xFFFF>;
708            break;
709
710        case angle::FormatID::R32G32B32_FLOAT:
711
712            this->metalFormat    = MTLPixelFormatRGBA32Float;
713            this->actualFormatId = angle::FormatID::R32G32B32A32_FLOAT;
714            this->initFunction   = Initialize4ComponentData<GLfloat, 0x00000000, 0x00000000,
715                                                          0x00000000, gl::Float32One>;
716            break;
717
718        case angle::FormatID::R32G32B32_SINT:
719
720            this->metalFormat    = MTLPixelFormatRGBA32Sint;
721            this->actualFormatId = angle::FormatID::R32G32B32A32_SINT;
722            this->initFunction =
723                Initialize4ComponentData<GLint, 0x00000000, 0x00000000, 0x00000000, 0x00000001>;
724            break;
725
726        case angle::FormatID::R32G32B32_UINT:
727
728            this->metalFormat    = MTLPixelFormatRGBA32Uint;
729            this->actualFormatId = angle::FormatID::R32G32B32A32_UINT;
730            this->initFunction =
731                Initialize4ComponentData<GLuint, 0x00000000, 0x00000000, 0x00000000, 0x00000001>;
732            break;
733
734        case angle::FormatID::R8G8B8X8_UNORM:
735
736            this->metalFormat    = MTLPixelFormatRGBA8Unorm;
737            this->actualFormatId = angle::FormatID::R8G8B8A8_UNORM;
738            break;
739
740        case angle::FormatID::R8G8B8_SINT:
741
742            this->metalFormat    = MTLPixelFormatRGBA8Sint;
743            this->actualFormatId = angle::FormatID::R8G8B8A8_SINT;
744            this->initFunction   = Initialize4ComponentData<GLbyte, 0x00, 0x00, 0x00, 0x01>;
745            break;
746
747        case angle::FormatID::R8G8B8_SNORM:
748
749            this->metalFormat    = MTLPixelFormatRGBA8Snorm;
750            this->actualFormatId = angle::FormatID::R8G8B8A8_SNORM;
751            this->initFunction   = Initialize4ComponentData<GLbyte, 0x00, 0x00, 0x00, 0x7F>;
752            break;
753
754        case angle::FormatID::R8G8B8_UINT:
755
756            this->metalFormat    = MTLPixelFormatRGBA8Uint;
757            this->actualFormatId = angle::FormatID::R8G8B8A8_UINT;
758            this->initFunction   = Initialize4ComponentData<GLubyte, 0x00, 0x00, 0x00, 0x01>;
759            break;
760
761        case angle::FormatID::R8G8B8_UNORM:
762
763            this->metalFormat    = MTLPixelFormatRGBA8Unorm;
764            this->actualFormatId = angle::FormatID::R8G8B8A8_UNORM;
765            this->initFunction   = Initialize4ComponentData<GLubyte, 0x00, 0x00, 0x00, 0xFF>;
766            break;
767
768        case angle::FormatID::R8G8B8_UNORM_SRGB:
769
770            this->metalFormat    = MTLPixelFormatRGBA8Unorm_sRGB;
771            this->actualFormatId = angle::FormatID::R8G8B8A8_UNORM_SRGB;
772            this->initFunction   = Initialize4ComponentData<GLubyte, 0x00, 0x00, 0x00, 0xFF>;
773            break;
774
775#if TARGET_OS_OSX || TARGET_OS_MACCATALYST
776        case angle::FormatID::BC1_RGBA_UNORM_BLOCK:
777
778            this->metalFormat    = MTLPixelFormatBC1_RGBA;
779            this->actualFormatId = angle::FormatID::BC1_RGBA_UNORM_BLOCK;
780            break;
781
782        case angle::FormatID::BC1_RGBA_UNORM_SRGB_BLOCK:
783
784            this->metalFormat    = MTLPixelFormatBC1_RGBA_sRGB;
785            this->actualFormatId = angle::FormatID::BC1_RGBA_UNORM_SRGB_BLOCK;
786            break;
787
788        case angle::FormatID::BC2_RGBA_UNORM_BLOCK:
789
790            this->metalFormat    = MTLPixelFormatBC2_RGBA;
791            this->actualFormatId = angle::FormatID::BC2_RGBA_UNORM_BLOCK;
792            break;
793
794        case angle::FormatID::BC2_RGBA_UNORM_SRGB_BLOCK:
795
796            this->metalFormat    = MTLPixelFormatBC2_RGBA_sRGB;
797            this->actualFormatId = angle::FormatID::BC2_RGBA_UNORM_SRGB_BLOCK;
798            break;
799
800        case angle::FormatID::BC3_RGBA_UNORM_BLOCK:
801
802            this->metalFormat    = MTLPixelFormatBC3_RGBA;
803            this->actualFormatId = angle::FormatID::BC3_RGBA_UNORM_BLOCK;
804            break;
805
806        case angle::FormatID::BC3_RGBA_UNORM_SRGB_BLOCK:
807
808            this->metalFormat    = MTLPixelFormatBC3_RGBA_sRGB;
809            this->actualFormatId = angle::FormatID::BC3_RGBA_UNORM_SRGB_BLOCK;
810            break;
811
812        case angle::FormatID::BC4_RED_SNORM_BLOCK:
813
814            this->metalFormat    = MTLPixelFormatBC4_RSnorm;
815            this->actualFormatId = angle::FormatID::BC4_RED_SNORM_BLOCK;
816            break;
817
818        case angle::FormatID::BC4_RED_UNORM_BLOCK:
819
820            this->metalFormat    = MTLPixelFormatBC4_RUnorm;
821            this->actualFormatId = angle::FormatID::BC4_RED_UNORM_BLOCK;
822            break;
823
824        case angle::FormatID::BC5_RG_SNORM_BLOCK:
825
826            this->metalFormat    = MTLPixelFormatBC5_RGSnorm;
827            this->actualFormatId = angle::FormatID::BC5_RG_SNORM_BLOCK;
828            break;
829
830        case angle::FormatID::BC5_RG_UNORM_BLOCK:
831
832            this->metalFormat    = MTLPixelFormatBC5_RGUnorm;
833            this->actualFormatId = angle::FormatID::BC5_RG_UNORM_BLOCK;
834            break;
835
836        case angle::FormatID::BC6H_RGB_SFLOAT_BLOCK:
837
838            this->metalFormat    = MTLPixelFormatBC6H_RGBFloat;
839            this->actualFormatId = angle::FormatID::BC6H_RGB_SFLOAT_BLOCK;
840            break;
841
842        case angle::FormatID::BC6H_RGB_UFLOAT_BLOCK:
843
844            this->metalFormat    = MTLPixelFormatBC6H_RGBUfloat;
845            this->actualFormatId = angle::FormatID::BC6H_RGB_UFLOAT_BLOCK;
846            break;
847
848        case angle::FormatID::BC7_RGBA_UNORM_BLOCK:
849
850            this->metalFormat    = MTLPixelFormatBC7_RGBAUnorm;
851            this->actualFormatId = angle::FormatID::BC7_RGBA_UNORM_BLOCK;
852            break;
853
854        case angle::FormatID::BC7_RGBA_UNORM_SRGB_BLOCK:
855
856            this->metalFormat    = MTLPixelFormatBC7_RGBAUnorm_sRGB;
857            this->actualFormatId = angle::FormatID::BC7_RGBA_UNORM_SRGB_BLOCK;
858            break;
859
860        case angle::FormatID::D16_UNORM:
861
862            if (display->supportsAppleGPUFamily(1))
863            {
864                this->metalFormat    = MTLPixelFormatDepth16Unorm;
865                this->actualFormatId = angle::FormatID::D16_UNORM;
866            }
867            else
868            {
869                this->metalFormat    = MTLPixelFormatDepth32Float;
870                this->actualFormatId = angle::FormatID::D32_FLOAT;
871            }
872            break;
873
874        case angle::FormatID::D24_UNORM_S8_UINT:
875
876            if (metalDevice.depth24Stencil8PixelFormatSupported &&
877                !display->getFeatures().forceD24S8AsUnsupported.enabled)
878            {
879                this->metalFormat    = MTLPixelFormatDepth24Unorm_Stencil8;
880                this->actualFormatId = angle::FormatID::D24_UNORM_S8_UINT;
881            }
882            else
883            {
884                this->metalFormat    = MTLPixelFormatDepth32Float_Stencil8;
885                this->actualFormatId = angle::FormatID::D32_FLOAT_S8X24_UINT;
886            }
887            break;
888
889        case angle::FormatID::BC1_RGB_UNORM_BLOCK:
890#    if defined(__IPHONE_13_0) || defined(__MAC_10_15)
891            if (display->getFeatures().hasTextureSwizzle.enabled)
892            {
893
894                this->metalFormat    = MTLPixelFormatBC1_RGBA;
895                this->actualFormatId = angle::FormatID::BC1_RGBA_UNORM_BLOCK;
896                this->swizzled       = true;
897                this->swizzle        = {GL_RED, GL_GREEN, GL_BLUE, GL_ONE};
898            }
899            else
900#    endif  // #if defined(__IPHONE_13_0) || defined(__MAC_10_15)
901            {
902
903                this->metalFormat    = MTLPixelFormatBC1_RGBA;
904                this->actualFormatId = angle::FormatID::BC1_RGBA_UNORM_BLOCK;
905            }
906            break;
907
908        case angle::FormatID::BC1_RGB_UNORM_SRGB_BLOCK:
909#    if defined(__IPHONE_13_0) || defined(__MAC_10_15)
910            if (display->getFeatures().hasTextureSwizzle.enabled)
911            {
912
913                this->metalFormat    = MTLPixelFormatBC1_RGBA_sRGB;
914                this->actualFormatId = angle::FormatID::BC1_RGBA_UNORM_SRGB_BLOCK;
915                this->swizzled       = true;
916                this->swizzle        = {GL_RED, GL_GREEN, GL_BLUE, GL_ONE};
917            }
918            else
919#    endif  // #if defined(__IPHONE_13_0) || defined(__MAC_10_15)
920            {
921
922                this->metalFormat    = MTLPixelFormatBC1_RGBA_sRGB;
923                this->actualFormatId = angle::FormatID::BC1_RGBA_UNORM_SRGB_BLOCK;
924            }
925            break;
926
927#endif
928#if (TARGET_OS_OSX && (__MAC_OS_X_VERSION_MAX_ALLOWED < 110000)) || TARGET_OS_MACCATALYST
929        case angle::FormatID::EAC_R11G11_SNORM_BLOCK:
930
931            this->metalFormat    = MTLPixelFormatRG16Snorm;
932            this->actualFormatId = angle::FormatID::R16G16_SNORM;
933            break;
934
935        case angle::FormatID::EAC_R11G11_UNORM_BLOCK:
936
937            this->metalFormat    = MTLPixelFormatRG16Unorm;
938            this->actualFormatId = angle::FormatID::R16G16_UNORM;
939            break;
940
941        case angle::FormatID::EAC_R11_SNORM_BLOCK:
942
943            this->metalFormat    = MTLPixelFormatR16Snorm;
944            this->actualFormatId = angle::FormatID::R16_SNORM;
945            break;
946
947        case angle::FormatID::EAC_R11_UNORM_BLOCK:
948
949            this->metalFormat    = MTLPixelFormatR16Unorm;
950            this->actualFormatId = angle::FormatID::R16_UNORM;
951            break;
952
953        case angle::FormatID::ETC1_R8G8B8_UNORM_BLOCK:
954
955            this->metalFormat    = MTLPixelFormatRGBA8Unorm;
956            this->actualFormatId = angle::FormatID::R8G8B8A8_UNORM;
957            this->initFunction   = Initialize4ComponentData<GLubyte, 0x00, 0x00, 0x00, 0xFF>;
958            break;
959
960        case angle::FormatID::ETC2_R8G8B8A1_SRGB_BLOCK:
961
962            this->metalFormat    = MTLPixelFormatRGBA8Unorm_sRGB;
963            this->actualFormatId = angle::FormatID::R8G8B8A8_UNORM_SRGB;
964            this->initFunction   = Initialize4ComponentData<GLubyte, 0x00, 0x00, 0x00, 0xFF>;
965            break;
966
967        case angle::FormatID::ETC2_R8G8B8A1_UNORM_BLOCK:
968
969            this->metalFormat    = MTLPixelFormatRGBA8Unorm;
970            this->actualFormatId = angle::FormatID::R8G8B8A8_UNORM;
971            this->initFunction   = Initialize4ComponentData<GLubyte, 0x00, 0x00, 0x00, 0xFF>;
972            break;
973
974        case angle::FormatID::ETC2_R8G8B8A8_SRGB_BLOCK:
975
976            this->metalFormat    = MTLPixelFormatRGBA8Unorm_sRGB;
977            this->actualFormatId = angle::FormatID::R8G8B8A8_UNORM_SRGB;
978            break;
979
980        case angle::FormatID::ETC2_R8G8B8A8_UNORM_BLOCK:
981
982            this->metalFormat    = MTLPixelFormatRGBA8Unorm;
983            this->actualFormatId = angle::FormatID::R8G8B8A8_UNORM;
984            break;
985
986        case angle::FormatID::ETC2_R8G8B8_SRGB_BLOCK:
987
988            this->metalFormat    = MTLPixelFormatRGBA8Unorm_sRGB;
989            this->actualFormatId = angle::FormatID::R8G8B8A8_UNORM_SRGB;
990            this->initFunction   = Initialize4ComponentData<GLubyte, 0x00, 0x00, 0x00, 0xFF>;
991            break;
992
993        case angle::FormatID::ETC2_R8G8B8_UNORM_BLOCK:
994
995            this->metalFormat    = MTLPixelFormatRGBA8Unorm;
996            this->actualFormatId = angle::FormatID::R8G8B8A8_UNORM;
997            this->initFunction   = Initialize4ComponentData<GLubyte, 0x00, 0x00, 0x00, 0xFF>;
998            break;
999
1000        case angle::FormatID::R4G4B4A4_UNORM:
1001
1002            this->metalFormat    = MTLPixelFormatRGBA8Unorm;
1003            this->actualFormatId = angle::FormatID::R8G8B8A8_UNORM;
1004            break;
1005
1006        case angle::FormatID::R5G5B5A1_UNORM:
1007
1008            this->metalFormat    = MTLPixelFormatRGBA8Unorm;
1009            this->actualFormatId = angle::FormatID::R8G8B8A8_UNORM;
1010            break;
1011
1012        case angle::FormatID::R5G6B5_UNORM:
1013
1014            this->metalFormat    = MTLPixelFormatRGBA8Unorm;
1015            this->actualFormatId = angle::FormatID::R8G8B8A8_UNORM;
1016            this->initFunction   = Initialize4ComponentData<GLubyte, 0x00, 0x00, 0x00, 0xFF>;
1017            break;
1018
1019#endif
1020#if TARGET_OS_SIMULATOR
1021        case angle::FormatID::ASTC_10x10_SRGB_BLOCK:
1022
1023            this->metalFormat    = MTLPixelFormatASTC_10x10_sRGB;
1024            this->actualFormatId = angle::FormatID::ASTC_10x10_SRGB_BLOCK;
1025            break;
1026
1027        case angle::FormatID::ASTC_10x5_SRGB_BLOCK:
1028
1029            this->metalFormat    = MTLPixelFormatASTC_10x5_sRGB;
1030            this->actualFormatId = angle::FormatID::ASTC_10x5_SRGB_BLOCK;
1031            break;
1032
1033        case angle::FormatID::ASTC_10x6_SRGB_BLOCK:
1034
1035            this->metalFormat    = MTLPixelFormatASTC_10x6_sRGB;
1036            this->actualFormatId = angle::FormatID::ASTC_10x6_SRGB_BLOCK;
1037            break;
1038
1039        case angle::FormatID::ASTC_10x8_SRGB_BLOCK:
1040
1041            this->metalFormat    = MTLPixelFormatASTC_10x8_sRGB;
1042            this->actualFormatId = angle::FormatID::ASTC_10x8_SRGB_BLOCK;
1043            break;
1044
1045        case angle::FormatID::ASTC_12x10_SRGB_BLOCK:
1046
1047            this->metalFormat    = MTLPixelFormatASTC_12x10_sRGB;
1048            this->actualFormatId = angle::FormatID::ASTC_12x10_SRGB_BLOCK;
1049            break;
1050
1051        case angle::FormatID::ASTC_12x12_SRGB_BLOCK:
1052
1053            this->metalFormat    = MTLPixelFormatASTC_12x12_sRGB;
1054            this->actualFormatId = angle::FormatID::ASTC_12x12_SRGB_BLOCK;
1055            break;
1056
1057        case angle::FormatID::ASTC_4x4_SRGB_BLOCK:
1058
1059            this->metalFormat    = MTLPixelFormatASTC_4x4_sRGB;
1060            this->actualFormatId = angle::FormatID::ASTC_4x4_SRGB_BLOCK;
1061            break;
1062
1063        case angle::FormatID::ASTC_5x4_SRGB_BLOCK:
1064
1065            this->metalFormat    = MTLPixelFormatASTC_5x4_sRGB;
1066            this->actualFormatId = angle::FormatID::ASTC_5x4_SRGB_BLOCK;
1067            break;
1068
1069        case angle::FormatID::ASTC_5x5_SRGB_BLOCK:
1070
1071            this->metalFormat    = MTLPixelFormatASTC_5x5_sRGB;
1072            this->actualFormatId = angle::FormatID::ASTC_5x5_SRGB_BLOCK;
1073            break;
1074
1075        case angle::FormatID::ASTC_6x5_SRGB_BLOCK:
1076
1077            this->metalFormat    = MTLPixelFormatASTC_6x5_sRGB;
1078            this->actualFormatId = angle::FormatID::ASTC_6x5_SRGB_BLOCK;
1079            break;
1080
1081        case angle::FormatID::ASTC_6x6_SRGB_BLOCK:
1082
1083            this->metalFormat    = MTLPixelFormatASTC_6x6_sRGB;
1084            this->actualFormatId = angle::FormatID::ASTC_6x6_SRGB_BLOCK;
1085            break;
1086
1087        case angle::FormatID::ASTC_8x5_SRGB_BLOCK:
1088
1089            this->metalFormat    = MTLPixelFormatASTC_8x5_sRGB;
1090            this->actualFormatId = angle::FormatID::ASTC_8x5_SRGB_BLOCK;
1091            break;
1092
1093        case angle::FormatID::ASTC_8x6_SRGB_BLOCK:
1094
1095            this->metalFormat    = MTLPixelFormatASTC_8x6_sRGB;
1096            this->actualFormatId = angle::FormatID::ASTC_8x6_SRGB_BLOCK;
1097            break;
1098
1099        case angle::FormatID::ASTC_8x8_SRGB_BLOCK:
1100
1101            this->metalFormat    = MTLPixelFormatASTC_8x8_sRGB;
1102            this->actualFormatId = angle::FormatID::ASTC_8x8_SRGB_BLOCK;
1103            break;
1104
1105        case angle::FormatID::EAC_R11G11_SNORM_BLOCK:
1106
1107            this->metalFormat    = MTLPixelFormatEAC_RG11Snorm;
1108            this->actualFormatId = angle::FormatID::EAC_R11G11_SNORM_BLOCK;
1109            break;
1110
1111        case angle::FormatID::EAC_R11G11_UNORM_BLOCK:
1112
1113            this->metalFormat    = MTLPixelFormatEAC_RG11Unorm;
1114            this->actualFormatId = angle::FormatID::EAC_R11G11_UNORM_BLOCK;
1115            break;
1116
1117        case angle::FormatID::EAC_R11_SNORM_BLOCK:
1118
1119            this->metalFormat    = MTLPixelFormatEAC_R11Snorm;
1120            this->actualFormatId = angle::FormatID::EAC_R11_SNORM_BLOCK;
1121            break;
1122
1123        case angle::FormatID::EAC_R11_UNORM_BLOCK:
1124
1125            this->metalFormat    = MTLPixelFormatEAC_R11Unorm;
1126            this->actualFormatId = angle::FormatID::EAC_R11_UNORM_BLOCK;
1127            break;
1128
1129        case angle::FormatID::ETC1_R8G8B8_UNORM_BLOCK:
1130
1131            this->metalFormat    = MTLPixelFormatETC2_RGB8;
1132            this->actualFormatId = angle::FormatID::ETC1_R8G8B8_UNORM_BLOCK;
1133            break;
1134
1135        case angle::FormatID::ETC2_R8G8B8A1_SRGB_BLOCK:
1136
1137            this->metalFormat    = MTLPixelFormatETC2_RGB8A1_sRGB;
1138            this->actualFormatId = angle::FormatID::ETC2_R8G8B8A1_SRGB_BLOCK;
1139            break;
1140
1141        case angle::FormatID::ETC2_R8G8B8A1_UNORM_BLOCK:
1142
1143            this->metalFormat    = MTLPixelFormatETC2_RGB8A1;
1144            this->actualFormatId = angle::FormatID::ETC2_R8G8B8A1_UNORM_BLOCK;
1145            break;
1146
1147        case angle::FormatID::ETC2_R8G8B8A8_SRGB_BLOCK:
1148
1149            this->metalFormat    = MTLPixelFormatEAC_RGBA8_sRGB;
1150            this->actualFormatId = angle::FormatID::ETC2_R8G8B8A8_SRGB_BLOCK;
1151            break;
1152
1153        case angle::FormatID::ETC2_R8G8B8A8_UNORM_BLOCK:
1154
1155            this->metalFormat    = MTLPixelFormatEAC_RGBA8;
1156            this->actualFormatId = angle::FormatID::ETC2_R8G8B8A8_UNORM_BLOCK;
1157            break;
1158
1159        case angle::FormatID::ETC2_R8G8B8_SRGB_BLOCK:
1160
1161            this->metalFormat    = MTLPixelFormatETC2_RGB8_sRGB;
1162            this->actualFormatId = angle::FormatID::ETC2_R8G8B8_SRGB_BLOCK;
1163            break;
1164
1165        case angle::FormatID::ETC2_R8G8B8_UNORM_BLOCK:
1166
1167            this->metalFormat    = MTLPixelFormatETC2_RGB8;
1168            this->actualFormatId = angle::FormatID::ETC2_R8G8B8_UNORM_BLOCK;
1169            break;
1170
1171        case angle::FormatID::D16_UNORM:
1172
1173            this->metalFormat    = MTLPixelFormatDepth32Float;
1174            this->actualFormatId = angle::FormatID::D32_FLOAT;
1175            break;
1176
1177        case angle::FormatID::D24_UNORM_S8_UINT:
1178
1179            this->metalFormat    = MTLPixelFormatDepth32Float_Stencil8;
1180            this->actualFormatId = angle::FormatID::D32_FLOAT_S8X24_UINT;
1181            break;
1182
1183        case angle::FormatID::R4G4B4A4_UNORM:
1184
1185            this->metalFormat    = MTLPixelFormatRGBA8Unorm;
1186            this->actualFormatId = angle::FormatID::R8G8B8A8_UNORM;
1187            break;
1188
1189        case angle::FormatID::R5G5B5A1_UNORM:
1190
1191            this->metalFormat    = MTLPixelFormatRGBA8Unorm;
1192            this->actualFormatId = angle::FormatID::R8G8B8A8_UNORM;
1193            break;
1194
1195        case angle::FormatID::R5G6B5_UNORM:
1196
1197            this->metalFormat    = MTLPixelFormatRGBA8Unorm;
1198            this->actualFormatId = angle::FormatID::R8G8B8A8_UNORM;
1199            this->initFunction   = Initialize4ComponentData<GLubyte, 0x00, 0x00, 0x00, 0xFF>;
1200            break;
1201
1202#    if TARGET_OS_IOS
1203        case angle::FormatID::ASTC_10x10_UNORM_BLOCK:
1204
1205            if (display->supportsAppleGPUFamily(6))
1206            {
1207                this->metalFormat    = MTLPixelFormatASTC_10x10_HDR;
1208                this->actualFormatId = angle::FormatID::ASTC_10x10_UNORM_BLOCK;
1209            }
1210            else
1211            {
1212                this->metalFormat    = MTLPixelFormatASTC_10x10_LDR;
1213                this->actualFormatId = angle::FormatID::ASTC_10x10_UNORM_BLOCK;
1214            }
1215            break;
1216
1217        case angle::FormatID::ASTC_10x5_UNORM_BLOCK:
1218
1219            if (display->supportsAppleGPUFamily(6))
1220            {
1221                this->metalFormat    = MTLPixelFormatASTC_10x5_HDR;
1222                this->actualFormatId = angle::FormatID::ASTC_10x5_UNORM_BLOCK;
1223            }
1224            else
1225            {
1226                this->metalFormat    = MTLPixelFormatASTC_10x5_LDR;
1227                this->actualFormatId = angle::FormatID::ASTC_10x5_UNORM_BLOCK;
1228            }
1229            break;
1230
1231        case angle::FormatID::ASTC_10x6_UNORM_BLOCK:
1232
1233            if (display->supportsAppleGPUFamily(6))
1234            {
1235                this->metalFormat    = MTLPixelFormatASTC_10x6_HDR;
1236                this->actualFormatId = angle::FormatID::ASTC_10x6_UNORM_BLOCK;
1237            }
1238            else
1239            {
1240                this->metalFormat    = MTLPixelFormatASTC_10x6_LDR;
1241                this->actualFormatId = angle::FormatID::ASTC_10x6_UNORM_BLOCK;
1242            }
1243            break;
1244
1245        case angle::FormatID::ASTC_10x8_UNORM_BLOCK:
1246
1247            if (display->supportsAppleGPUFamily(6))
1248            {
1249                this->metalFormat    = MTLPixelFormatASTC_10x8_HDR;
1250                this->actualFormatId = angle::FormatID::ASTC_10x8_UNORM_BLOCK;
1251            }
1252            else
1253            {
1254                this->metalFormat    = MTLPixelFormatASTC_10x8_LDR;
1255                this->actualFormatId = angle::FormatID::ASTC_10x8_UNORM_BLOCK;
1256            }
1257            break;
1258
1259        case angle::FormatID::ASTC_12x10_UNORM_BLOCK:
1260
1261            if (display->supportsAppleGPUFamily(6))
1262            {
1263                this->metalFormat    = MTLPixelFormatASTC_12x10_HDR;
1264                this->actualFormatId = angle::FormatID::ASTC_12x10_UNORM_BLOCK;
1265            }
1266            else
1267            {
1268                this->metalFormat    = MTLPixelFormatASTC_12x10_LDR;
1269                this->actualFormatId = angle::FormatID::ASTC_12x10_UNORM_BLOCK;
1270            }
1271            break;
1272
1273        case angle::FormatID::ASTC_12x12_UNORM_BLOCK:
1274
1275            if (display->supportsAppleGPUFamily(6))
1276            {
1277                this->metalFormat    = MTLPixelFormatASTC_12x12_HDR;
1278                this->actualFormatId = angle::FormatID::ASTC_12x12_UNORM_BLOCK;
1279            }
1280            else
1281            {
1282                this->metalFormat    = MTLPixelFormatASTC_12x12_LDR;
1283                this->actualFormatId = angle::FormatID::ASTC_12x12_UNORM_BLOCK;
1284            }
1285            break;
1286
1287        case angle::FormatID::ASTC_4x4_UNORM_BLOCK:
1288
1289            if (display->supportsAppleGPUFamily(6))
1290            {
1291                this->metalFormat    = MTLPixelFormatASTC_4x4_HDR;
1292                this->actualFormatId = angle::FormatID::ASTC_4x4_UNORM_BLOCK;
1293            }
1294            else
1295            {
1296                this->metalFormat    = MTLPixelFormatASTC_4x4_LDR;
1297                this->actualFormatId = angle::FormatID::ASTC_4x4_UNORM_BLOCK;
1298            }
1299            break;
1300
1301        case angle::FormatID::ASTC_5x4_UNORM_BLOCK:
1302
1303            if (display->supportsAppleGPUFamily(6))
1304            {
1305                this->metalFormat    = MTLPixelFormatASTC_5x4_HDR;
1306                this->actualFormatId = angle::FormatID::ASTC_5x4_UNORM_BLOCK;
1307            }
1308            else
1309            {
1310                this->metalFormat    = MTLPixelFormatASTC_5x4_LDR;
1311                this->actualFormatId = angle::FormatID::ASTC_5x4_UNORM_BLOCK;
1312            }
1313            break;
1314
1315        case angle::FormatID::ASTC_5x5_UNORM_BLOCK:
1316
1317            if (display->supportsAppleGPUFamily(6))
1318            {
1319                this->metalFormat    = MTLPixelFormatASTC_5x5_HDR;
1320                this->actualFormatId = angle::FormatID::ASTC_5x5_UNORM_BLOCK;
1321            }
1322            else
1323            {
1324                this->metalFormat    = MTLPixelFormatASTC_5x5_LDR;
1325                this->actualFormatId = angle::FormatID::ASTC_5x5_UNORM_BLOCK;
1326            }
1327            break;
1328
1329        case angle::FormatID::ASTC_6x5_UNORM_BLOCK:
1330
1331            if (display->supportsAppleGPUFamily(6))
1332            {
1333                this->metalFormat    = MTLPixelFormatASTC_6x5_HDR;
1334                this->actualFormatId = angle::FormatID::ASTC_6x5_UNORM_BLOCK;
1335            }
1336            else
1337            {
1338                this->metalFormat    = MTLPixelFormatASTC_6x5_LDR;
1339                this->actualFormatId = angle::FormatID::ASTC_6x5_UNORM_BLOCK;
1340            }
1341            break;
1342
1343        case angle::FormatID::ASTC_6x6_UNORM_BLOCK:
1344
1345            if (display->supportsAppleGPUFamily(6))
1346            {
1347                this->metalFormat    = MTLPixelFormatASTC_6x6_HDR;
1348                this->actualFormatId = angle::FormatID::ASTC_6x6_UNORM_BLOCK;
1349            }
1350            else
1351            {
1352                this->metalFormat    = MTLPixelFormatASTC_6x6_LDR;
1353                this->actualFormatId = angle::FormatID::ASTC_6x6_UNORM_BLOCK;
1354            }
1355            break;
1356
1357        case angle::FormatID::ASTC_8x5_UNORM_BLOCK:
1358
1359            if (display->supportsAppleGPUFamily(6))
1360            {
1361                this->metalFormat    = MTLPixelFormatASTC_8x5_HDR;
1362                this->actualFormatId = angle::FormatID::ASTC_8x5_UNORM_BLOCK;
1363            }
1364            else
1365            {
1366                this->metalFormat    = MTLPixelFormatASTC_8x5_LDR;
1367                this->actualFormatId = angle::FormatID::ASTC_8x5_UNORM_BLOCK;
1368            }
1369            break;
1370
1371        case angle::FormatID::ASTC_8x6_UNORM_BLOCK:
1372
1373            if (display->supportsAppleGPUFamily(6))
1374            {
1375                this->metalFormat    = MTLPixelFormatASTC_8x6_HDR;
1376                this->actualFormatId = angle::FormatID::ASTC_8x6_UNORM_BLOCK;
1377            }
1378            else
1379            {
1380                this->metalFormat    = MTLPixelFormatASTC_8x6_LDR;
1381                this->actualFormatId = angle::FormatID::ASTC_8x6_UNORM_BLOCK;
1382            }
1383            break;
1384
1385        case angle::FormatID::ASTC_8x8_UNORM_BLOCK:
1386
1387            if (display->supportsAppleGPUFamily(6))
1388            {
1389                this->metalFormat    = MTLPixelFormatASTC_8x8_HDR;
1390                this->actualFormatId = angle::FormatID::ASTC_8x8_UNORM_BLOCK;
1391            }
1392            else
1393            {
1394                this->metalFormat    = MTLPixelFormatASTC_8x8_LDR;
1395                this->actualFormatId = angle::FormatID::ASTC_8x8_UNORM_BLOCK;
1396            }
1397            break;
1398
1399#    elif TARGET_OS_TV || TARGET_OS_WATCH
1400        case angle::FormatID::ASTC_10x10_UNORM_BLOCK:
1401
1402            this->metalFormat    = MTLPixelFormatASTC_10x10_LDR;
1403            this->actualFormatId = angle::FormatID::ASTC_10x10_UNORM_BLOCK;
1404            break;
1405
1406        case angle::FormatID::ASTC_10x5_UNORM_BLOCK:
1407
1408            this->metalFormat    = MTLPixelFormatASTC_10x5_LDR;
1409            this->actualFormatId = angle::FormatID::ASTC_10x5_UNORM_BLOCK;
1410            break;
1411
1412        case angle::FormatID::ASTC_10x6_UNORM_BLOCK:
1413
1414            this->metalFormat    = MTLPixelFormatASTC_10x6_LDR;
1415            this->actualFormatId = angle::FormatID::ASTC_10x6_UNORM_BLOCK;
1416            break;
1417
1418        case angle::FormatID::ASTC_10x8_UNORM_BLOCK:
1419
1420            this->metalFormat    = MTLPixelFormatASTC_10x8_LDR;
1421            this->actualFormatId = angle::FormatID::ASTC_10x8_UNORM_BLOCK;
1422            break;
1423
1424        case angle::FormatID::ASTC_12x10_UNORM_BLOCK:
1425
1426            this->metalFormat    = MTLPixelFormatASTC_12x10_LDR;
1427            this->actualFormatId = angle::FormatID::ASTC_12x10_UNORM_BLOCK;
1428            break;
1429
1430        case angle::FormatID::ASTC_12x12_UNORM_BLOCK:
1431
1432            this->metalFormat    = MTLPixelFormatASTC_12x12_LDR;
1433            this->actualFormatId = angle::FormatID::ASTC_12x12_UNORM_BLOCK;
1434            break;
1435
1436        case angle::FormatID::ASTC_4x4_UNORM_BLOCK:
1437
1438            this->metalFormat    = MTLPixelFormatASTC_4x4_LDR;
1439            this->actualFormatId = angle::FormatID::ASTC_4x4_UNORM_BLOCK;
1440            break;
1441
1442        case angle::FormatID::ASTC_5x4_UNORM_BLOCK:
1443
1444            this->metalFormat    = MTLPixelFormatASTC_5x4_LDR;
1445            this->actualFormatId = angle::FormatID::ASTC_5x4_UNORM_BLOCK;
1446            break;
1447
1448        case angle::FormatID::ASTC_5x5_UNORM_BLOCK:
1449
1450            this->metalFormat    = MTLPixelFormatASTC_5x5_LDR;
1451            this->actualFormatId = angle::FormatID::ASTC_5x5_UNORM_BLOCK;
1452            break;
1453
1454        case angle::FormatID::ASTC_6x5_UNORM_BLOCK:
1455
1456            this->metalFormat    = MTLPixelFormatASTC_6x5_LDR;
1457            this->actualFormatId = angle::FormatID::ASTC_6x5_UNORM_BLOCK;
1458            break;
1459
1460        case angle::FormatID::ASTC_6x6_UNORM_BLOCK:
1461
1462            this->metalFormat    = MTLPixelFormatASTC_6x6_LDR;
1463            this->actualFormatId = angle::FormatID::ASTC_6x6_UNORM_BLOCK;
1464            break;
1465
1466        case angle::FormatID::ASTC_8x5_UNORM_BLOCK:
1467
1468            this->metalFormat    = MTLPixelFormatASTC_8x5_LDR;
1469            this->actualFormatId = angle::FormatID::ASTC_8x5_UNORM_BLOCK;
1470            break;
1471
1472        case angle::FormatID::ASTC_8x6_UNORM_BLOCK:
1473
1474            this->metalFormat    = MTLPixelFormatASTC_8x6_LDR;
1475            this->actualFormatId = angle::FormatID::ASTC_8x6_UNORM_BLOCK;
1476            break;
1477
1478        case angle::FormatID::ASTC_8x8_UNORM_BLOCK:
1479
1480            this->metalFormat    = MTLPixelFormatASTC_8x8_LDR;
1481            this->actualFormatId = angle::FormatID::ASTC_8x8_UNORM_BLOCK;
1482            break;
1483
1484#    endif  // TARGET_OS_IOS
1485#elif TARGET_OS_IPHONE && !TARGET_OS_MACCATALYST
1486        case angle::FormatID::ASTC_10x10_SRGB_BLOCK:
1487
1488            this->metalFormat    = MTLPixelFormatASTC_10x10_sRGB;
1489            this->actualFormatId = angle::FormatID::ASTC_10x10_SRGB_BLOCK;
1490            break;
1491
1492        case angle::FormatID::ASTC_10x5_SRGB_BLOCK:
1493
1494            this->metalFormat    = MTLPixelFormatASTC_10x5_sRGB;
1495            this->actualFormatId = angle::FormatID::ASTC_10x5_SRGB_BLOCK;
1496            break;
1497
1498        case angle::FormatID::ASTC_10x6_SRGB_BLOCK:
1499
1500            this->metalFormat    = MTLPixelFormatASTC_10x6_sRGB;
1501            this->actualFormatId = angle::FormatID::ASTC_10x6_SRGB_BLOCK;
1502            break;
1503
1504        case angle::FormatID::ASTC_10x8_SRGB_BLOCK:
1505
1506            this->metalFormat    = MTLPixelFormatASTC_10x8_sRGB;
1507            this->actualFormatId = angle::FormatID::ASTC_10x8_SRGB_BLOCK;
1508            break;
1509
1510        case angle::FormatID::ASTC_12x10_SRGB_BLOCK:
1511
1512            this->metalFormat    = MTLPixelFormatASTC_12x10_sRGB;
1513            this->actualFormatId = angle::FormatID::ASTC_12x10_SRGB_BLOCK;
1514            break;
1515
1516        case angle::FormatID::ASTC_12x12_SRGB_BLOCK:
1517
1518            this->metalFormat    = MTLPixelFormatASTC_12x12_sRGB;
1519            this->actualFormatId = angle::FormatID::ASTC_12x12_SRGB_BLOCK;
1520            break;
1521
1522        case angle::FormatID::ASTC_4x4_SRGB_BLOCK:
1523
1524            this->metalFormat    = MTLPixelFormatASTC_4x4_sRGB;
1525            this->actualFormatId = angle::FormatID::ASTC_4x4_SRGB_BLOCK;
1526            break;
1527
1528        case angle::FormatID::ASTC_5x4_SRGB_BLOCK:
1529
1530            this->metalFormat    = MTLPixelFormatASTC_5x4_sRGB;
1531            this->actualFormatId = angle::FormatID::ASTC_5x4_SRGB_BLOCK;
1532            break;
1533
1534        case angle::FormatID::ASTC_5x5_SRGB_BLOCK:
1535
1536            this->metalFormat    = MTLPixelFormatASTC_5x5_sRGB;
1537            this->actualFormatId = angle::FormatID::ASTC_5x5_SRGB_BLOCK;
1538            break;
1539
1540        case angle::FormatID::ASTC_6x5_SRGB_BLOCK:
1541
1542            this->metalFormat    = MTLPixelFormatASTC_6x5_sRGB;
1543            this->actualFormatId = angle::FormatID::ASTC_6x5_SRGB_BLOCK;
1544            break;
1545
1546        case angle::FormatID::ASTC_6x6_SRGB_BLOCK:
1547
1548            this->metalFormat    = MTLPixelFormatASTC_6x6_sRGB;
1549            this->actualFormatId = angle::FormatID::ASTC_6x6_SRGB_BLOCK;
1550            break;
1551
1552        case angle::FormatID::ASTC_8x5_SRGB_BLOCK:
1553
1554            this->metalFormat    = MTLPixelFormatASTC_8x5_sRGB;
1555            this->actualFormatId = angle::FormatID::ASTC_8x5_SRGB_BLOCK;
1556            break;
1557
1558        case angle::FormatID::ASTC_8x6_SRGB_BLOCK:
1559
1560            this->metalFormat    = MTLPixelFormatASTC_8x6_sRGB;
1561            this->actualFormatId = angle::FormatID::ASTC_8x6_SRGB_BLOCK;
1562            break;
1563
1564        case angle::FormatID::ASTC_8x8_SRGB_BLOCK:
1565
1566            this->metalFormat    = MTLPixelFormatASTC_8x8_sRGB;
1567            this->actualFormatId = angle::FormatID::ASTC_8x8_SRGB_BLOCK;
1568            break;
1569
1570        case angle::FormatID::D16_UNORM:
1571
1572            this->metalFormat    = MTLPixelFormatDepth16Unorm;
1573            this->actualFormatId = angle::FormatID::D16_UNORM;
1574            break;
1575
1576        case angle::FormatID::EAC_R11G11_SNORM_BLOCK:
1577
1578            this->metalFormat    = MTLPixelFormatEAC_RG11Snorm;
1579            this->actualFormatId = angle::FormatID::EAC_R11G11_SNORM_BLOCK;
1580            break;
1581
1582        case angle::FormatID::EAC_R11G11_UNORM_BLOCK:
1583
1584            this->metalFormat    = MTLPixelFormatEAC_RG11Unorm;
1585            this->actualFormatId = angle::FormatID::EAC_R11G11_UNORM_BLOCK;
1586            break;
1587
1588        case angle::FormatID::EAC_R11_SNORM_BLOCK:
1589
1590            this->metalFormat    = MTLPixelFormatEAC_R11Snorm;
1591            this->actualFormatId = angle::FormatID::EAC_R11_SNORM_BLOCK;
1592            break;
1593
1594        case angle::FormatID::EAC_R11_UNORM_BLOCK:
1595
1596            this->metalFormat    = MTLPixelFormatEAC_R11Unorm;
1597            this->actualFormatId = angle::FormatID::EAC_R11_UNORM_BLOCK;
1598            break;
1599
1600        case angle::FormatID::ETC1_R8G8B8_UNORM_BLOCK:
1601
1602            this->metalFormat    = MTLPixelFormatETC2_RGB8;
1603            this->actualFormatId = angle::FormatID::ETC1_R8G8B8_UNORM_BLOCK;
1604            break;
1605
1606        case angle::FormatID::ETC2_R8G8B8A1_SRGB_BLOCK:
1607
1608            this->metalFormat    = MTLPixelFormatETC2_RGB8A1_sRGB;
1609            this->actualFormatId = angle::FormatID::ETC2_R8G8B8A1_SRGB_BLOCK;
1610            break;
1611
1612        case angle::FormatID::ETC2_R8G8B8A1_UNORM_BLOCK:
1613
1614            this->metalFormat    = MTLPixelFormatETC2_RGB8A1;
1615            this->actualFormatId = angle::FormatID::ETC2_R8G8B8A1_UNORM_BLOCK;
1616            break;
1617
1618        case angle::FormatID::ETC2_R8G8B8A8_SRGB_BLOCK:
1619
1620            this->metalFormat    = MTLPixelFormatEAC_RGBA8_sRGB;
1621            this->actualFormatId = angle::FormatID::ETC2_R8G8B8A8_SRGB_BLOCK;
1622            break;
1623
1624        case angle::FormatID::ETC2_R8G8B8A8_UNORM_BLOCK:
1625
1626            this->metalFormat    = MTLPixelFormatEAC_RGBA8;
1627            this->actualFormatId = angle::FormatID::ETC2_R8G8B8A8_UNORM_BLOCK;
1628            break;
1629
1630        case angle::FormatID::ETC2_R8G8B8_SRGB_BLOCK:
1631
1632            this->metalFormat    = MTLPixelFormatETC2_RGB8_sRGB;
1633            this->actualFormatId = angle::FormatID::ETC2_R8G8B8_SRGB_BLOCK;
1634            break;
1635
1636        case angle::FormatID::ETC2_R8G8B8_UNORM_BLOCK:
1637
1638            this->metalFormat    = MTLPixelFormatETC2_RGB8;
1639            this->actualFormatId = angle::FormatID::ETC2_R8G8B8_UNORM_BLOCK;
1640            break;
1641
1642        case angle::FormatID::PVRTC1_RGBA_2BPP_UNORM_BLOCK:
1643
1644            this->metalFormat    = MTLPixelFormatPVRTC_RGBA_2BPP;
1645            this->actualFormatId = angle::FormatID::PVRTC1_RGBA_2BPP_UNORM_BLOCK;
1646            break;
1647
1648        case angle::FormatID::PVRTC1_RGBA_2BPP_UNORM_SRGB_BLOCK:
1649
1650            this->metalFormat    = MTLPixelFormatPVRTC_RGBA_2BPP_sRGB;
1651            this->actualFormatId = angle::FormatID::PVRTC1_RGBA_2BPP_UNORM_SRGB_BLOCK;
1652            break;
1653
1654        case angle::FormatID::PVRTC1_RGBA_4BPP_UNORM_BLOCK:
1655
1656            this->metalFormat    = MTLPixelFormatPVRTC_RGBA_4BPP;
1657            this->actualFormatId = angle::FormatID::PVRTC1_RGBA_4BPP_UNORM_BLOCK;
1658            break;
1659
1660        case angle::FormatID::PVRTC1_RGBA_4BPP_UNORM_SRGB_BLOCK:
1661
1662            this->metalFormat    = MTLPixelFormatPVRTC_RGBA_4BPP_sRGB;
1663            this->actualFormatId = angle::FormatID::PVRTC1_RGBA_4BPP_UNORM_SRGB_BLOCK;
1664            break;
1665
1666        case angle::FormatID::PVRTC1_RGB_2BPP_UNORM_BLOCK:
1667
1668            this->metalFormat    = MTLPixelFormatPVRTC_RGB_2BPP;
1669            this->actualFormatId = angle::FormatID::PVRTC1_RGB_2BPP_UNORM_BLOCK;
1670            break;
1671
1672        case angle::FormatID::PVRTC1_RGB_2BPP_UNORM_SRGB_BLOCK:
1673
1674            this->metalFormat    = MTLPixelFormatPVRTC_RGB_2BPP_sRGB;
1675            this->actualFormatId = angle::FormatID::PVRTC1_RGB_2BPP_UNORM_SRGB_BLOCK;
1676            break;
1677
1678        case angle::FormatID::PVRTC1_RGB_4BPP_UNORM_BLOCK:
1679
1680            this->metalFormat    = MTLPixelFormatPVRTC_RGB_4BPP;
1681            this->actualFormatId = angle::FormatID::PVRTC1_RGB_4BPP_UNORM_BLOCK;
1682            break;
1683
1684        case angle::FormatID::PVRTC1_RGB_4BPP_UNORM_SRGB_BLOCK:
1685
1686            this->metalFormat    = MTLPixelFormatPVRTC_RGB_4BPP_sRGB;
1687            this->actualFormatId = angle::FormatID::PVRTC1_RGB_4BPP_UNORM_SRGB_BLOCK;
1688            break;
1689
1690        case angle::FormatID::R4G4B4A4_UNORM:
1691
1692            this->metalFormat    = MTLPixelFormatABGR4Unorm;
1693            this->actualFormatId = angle::FormatID::R4G4B4A4_UNORM;
1694            break;
1695
1696        case angle::FormatID::R5G5B5A1_UNORM:
1697
1698            this->metalFormat    = MTLPixelFormatA1BGR5Unorm;
1699            this->actualFormatId = angle::FormatID::R5G5B5A1_UNORM;
1700            break;
1701
1702        case angle::FormatID::R5G6B5_UNORM:
1703
1704            this->metalFormat    = MTLPixelFormatB5G6R5Unorm;
1705            this->actualFormatId = angle::FormatID::R5G6B5_UNORM;
1706            break;
1707
1708        case angle::FormatID::R8G8_UNORM_SRGB:
1709
1710            this->metalFormat    = MTLPixelFormatRG8Unorm_sRGB;
1711            this->actualFormatId = angle::FormatID::R8G8_UNORM_SRGB;
1712            break;
1713
1714        case angle::FormatID::R8_UNORM_SRGB:
1715
1716            this->metalFormat    = MTLPixelFormatR8Unorm_sRGB;
1717            this->actualFormatId = angle::FormatID::R8_UNORM_SRGB;
1718            break;
1719
1720        case angle::FormatID::D24_UNORM_S8_UINT:
1721
1722            this->metalFormat    = MTLPixelFormatDepth32Float_Stencil8;
1723            this->actualFormatId = angle::FormatID::D32_FLOAT_S8X24_UINT;
1724            break;
1725
1726#    if TARGET_OS_IOS
1727        case angle::FormatID::ASTC_10x10_UNORM_BLOCK:
1728
1729            if (display->supportsAppleGPUFamily(6))
1730            {
1731                this->metalFormat    = MTLPixelFormatASTC_10x10_HDR;
1732                this->actualFormatId = angle::FormatID::ASTC_10x10_UNORM_BLOCK;
1733            }
1734            else
1735            {
1736                this->metalFormat    = MTLPixelFormatASTC_10x10_LDR;
1737                this->actualFormatId = angle::FormatID::ASTC_10x10_UNORM_BLOCK;
1738            }
1739            break;
1740
1741        case angle::FormatID::ASTC_10x5_UNORM_BLOCK:
1742
1743            if (display->supportsAppleGPUFamily(6))
1744            {
1745                this->metalFormat    = MTLPixelFormatASTC_10x5_HDR;
1746                this->actualFormatId = angle::FormatID::ASTC_10x5_UNORM_BLOCK;
1747            }
1748            else
1749            {
1750                this->metalFormat    = MTLPixelFormatASTC_10x5_LDR;
1751                this->actualFormatId = angle::FormatID::ASTC_10x5_UNORM_BLOCK;
1752            }
1753            break;
1754
1755        case angle::FormatID::ASTC_10x6_UNORM_BLOCK:
1756
1757            if (display->supportsAppleGPUFamily(6))
1758            {
1759                this->metalFormat    = MTLPixelFormatASTC_10x6_HDR;
1760                this->actualFormatId = angle::FormatID::ASTC_10x6_UNORM_BLOCK;
1761            }
1762            else
1763            {
1764                this->metalFormat    = MTLPixelFormatASTC_10x6_LDR;
1765                this->actualFormatId = angle::FormatID::ASTC_10x6_UNORM_BLOCK;
1766            }
1767            break;
1768
1769        case angle::FormatID::ASTC_10x8_UNORM_BLOCK:
1770
1771            if (display->supportsAppleGPUFamily(6))
1772            {
1773                this->metalFormat    = MTLPixelFormatASTC_10x8_HDR;
1774                this->actualFormatId = angle::FormatID::ASTC_10x8_UNORM_BLOCK;
1775            }
1776            else
1777            {
1778                this->metalFormat    = MTLPixelFormatASTC_10x8_LDR;
1779                this->actualFormatId = angle::FormatID::ASTC_10x8_UNORM_BLOCK;
1780            }
1781            break;
1782
1783        case angle::FormatID::ASTC_12x10_UNORM_BLOCK:
1784
1785            if (display->supportsAppleGPUFamily(6))
1786            {
1787                this->metalFormat    = MTLPixelFormatASTC_12x10_HDR;
1788                this->actualFormatId = angle::FormatID::ASTC_12x10_UNORM_BLOCK;
1789            }
1790            else
1791            {
1792                this->metalFormat    = MTLPixelFormatASTC_12x10_LDR;
1793                this->actualFormatId = angle::FormatID::ASTC_12x10_UNORM_BLOCK;
1794            }
1795            break;
1796
1797        case angle::FormatID::ASTC_12x12_UNORM_BLOCK:
1798
1799            if (display->supportsAppleGPUFamily(6))
1800            {
1801                this->metalFormat    = MTLPixelFormatASTC_12x12_HDR;
1802                this->actualFormatId = angle::FormatID::ASTC_12x12_UNORM_BLOCK;
1803            }
1804            else
1805            {
1806                this->metalFormat    = MTLPixelFormatASTC_12x12_LDR;
1807                this->actualFormatId = angle::FormatID::ASTC_12x12_UNORM_BLOCK;
1808            }
1809            break;
1810
1811        case angle::FormatID::ASTC_4x4_UNORM_BLOCK:
1812
1813            if (display->supportsAppleGPUFamily(6))
1814            {
1815                this->metalFormat    = MTLPixelFormatASTC_4x4_HDR;
1816                this->actualFormatId = angle::FormatID::ASTC_4x4_UNORM_BLOCK;
1817            }
1818            else
1819            {
1820                this->metalFormat    = MTLPixelFormatASTC_4x4_LDR;
1821                this->actualFormatId = angle::FormatID::ASTC_4x4_UNORM_BLOCK;
1822            }
1823            break;
1824
1825        case angle::FormatID::ASTC_5x4_UNORM_BLOCK:
1826
1827            if (display->supportsAppleGPUFamily(6))
1828            {
1829                this->metalFormat    = MTLPixelFormatASTC_5x4_HDR;
1830                this->actualFormatId = angle::FormatID::ASTC_5x4_UNORM_BLOCK;
1831            }
1832            else
1833            {
1834                this->metalFormat    = MTLPixelFormatASTC_5x4_LDR;
1835                this->actualFormatId = angle::FormatID::ASTC_5x4_UNORM_BLOCK;
1836            }
1837            break;
1838
1839        case angle::FormatID::ASTC_5x5_UNORM_BLOCK:
1840
1841            if (display->supportsAppleGPUFamily(6))
1842            {
1843                this->metalFormat    = MTLPixelFormatASTC_5x5_HDR;
1844                this->actualFormatId = angle::FormatID::ASTC_5x5_UNORM_BLOCK;
1845            }
1846            else
1847            {
1848                this->metalFormat    = MTLPixelFormatASTC_5x5_LDR;
1849                this->actualFormatId = angle::FormatID::ASTC_5x5_UNORM_BLOCK;
1850            }
1851            break;
1852
1853        case angle::FormatID::ASTC_6x5_UNORM_BLOCK:
1854
1855            if (display->supportsAppleGPUFamily(6))
1856            {
1857                this->metalFormat    = MTLPixelFormatASTC_6x5_HDR;
1858                this->actualFormatId = angle::FormatID::ASTC_6x5_UNORM_BLOCK;
1859            }
1860            else
1861            {
1862                this->metalFormat    = MTLPixelFormatASTC_6x5_LDR;
1863                this->actualFormatId = angle::FormatID::ASTC_6x5_UNORM_BLOCK;
1864            }
1865            break;
1866
1867        case angle::FormatID::ASTC_6x6_UNORM_BLOCK:
1868
1869            if (display->supportsAppleGPUFamily(6))
1870            {
1871                this->metalFormat    = MTLPixelFormatASTC_6x6_HDR;
1872                this->actualFormatId = angle::FormatID::ASTC_6x6_UNORM_BLOCK;
1873            }
1874            else
1875            {
1876                this->metalFormat    = MTLPixelFormatASTC_6x6_LDR;
1877                this->actualFormatId = angle::FormatID::ASTC_6x6_UNORM_BLOCK;
1878            }
1879            break;
1880
1881        case angle::FormatID::ASTC_8x5_UNORM_BLOCK:
1882
1883            if (display->supportsAppleGPUFamily(6))
1884            {
1885                this->metalFormat    = MTLPixelFormatASTC_8x5_HDR;
1886                this->actualFormatId = angle::FormatID::ASTC_8x5_UNORM_BLOCK;
1887            }
1888            else
1889            {
1890                this->metalFormat    = MTLPixelFormatASTC_8x5_LDR;
1891                this->actualFormatId = angle::FormatID::ASTC_8x5_UNORM_BLOCK;
1892            }
1893            break;
1894
1895        case angle::FormatID::ASTC_8x6_UNORM_BLOCK:
1896
1897            if (display->supportsAppleGPUFamily(6))
1898            {
1899                this->metalFormat    = MTLPixelFormatASTC_8x6_HDR;
1900                this->actualFormatId = angle::FormatID::ASTC_8x6_UNORM_BLOCK;
1901            }
1902            else
1903            {
1904                this->metalFormat    = MTLPixelFormatASTC_8x6_LDR;
1905                this->actualFormatId = angle::FormatID::ASTC_8x6_UNORM_BLOCK;
1906            }
1907            break;
1908
1909        case angle::FormatID::ASTC_8x8_UNORM_BLOCK:
1910
1911            if (display->supportsAppleGPUFamily(6))
1912            {
1913                this->metalFormat    = MTLPixelFormatASTC_8x8_HDR;
1914                this->actualFormatId = angle::FormatID::ASTC_8x8_UNORM_BLOCK;
1915            }
1916            else
1917            {
1918                this->metalFormat    = MTLPixelFormatASTC_8x8_LDR;
1919                this->actualFormatId = angle::FormatID::ASTC_8x8_UNORM_BLOCK;
1920            }
1921            break;
1922
1923#    elif TARGET_OS_TV || TARGET_OS_WATCH
1924        case angle::FormatID::ASTC_10x10_UNORM_BLOCK:
1925
1926            this->metalFormat    = MTLPixelFormatASTC_10x10_LDR;
1927            this->actualFormatId = angle::FormatID::ASTC_10x10_UNORM_BLOCK;
1928            break;
1929
1930        case angle::FormatID::ASTC_10x5_UNORM_BLOCK:
1931
1932            this->metalFormat    = MTLPixelFormatASTC_10x5_LDR;
1933            this->actualFormatId = angle::FormatID::ASTC_10x5_UNORM_BLOCK;
1934            break;
1935
1936        case angle::FormatID::ASTC_10x6_UNORM_BLOCK:
1937
1938            this->metalFormat    = MTLPixelFormatASTC_10x6_LDR;
1939            this->actualFormatId = angle::FormatID::ASTC_10x6_UNORM_BLOCK;
1940            break;
1941
1942        case angle::FormatID::ASTC_10x8_UNORM_BLOCK:
1943
1944            this->metalFormat    = MTLPixelFormatASTC_10x8_LDR;
1945            this->actualFormatId = angle::FormatID::ASTC_10x8_UNORM_BLOCK;
1946            break;
1947
1948        case angle::FormatID::ASTC_12x10_UNORM_BLOCK:
1949
1950            this->metalFormat    = MTLPixelFormatASTC_12x10_LDR;
1951            this->actualFormatId = angle::FormatID::ASTC_12x10_UNORM_BLOCK;
1952            break;
1953
1954        case angle::FormatID::ASTC_12x12_UNORM_BLOCK:
1955
1956            this->metalFormat    = MTLPixelFormatASTC_12x12_LDR;
1957            this->actualFormatId = angle::FormatID::ASTC_12x12_UNORM_BLOCK;
1958            break;
1959
1960        case angle::FormatID::ASTC_4x4_UNORM_BLOCK:
1961
1962            this->metalFormat    = MTLPixelFormatASTC_4x4_LDR;
1963            this->actualFormatId = angle::FormatID::ASTC_4x4_UNORM_BLOCK;
1964            break;
1965
1966        case angle::FormatID::ASTC_5x4_UNORM_BLOCK:
1967
1968            this->metalFormat    = MTLPixelFormatASTC_5x4_LDR;
1969            this->actualFormatId = angle::FormatID::ASTC_5x4_UNORM_BLOCK;
1970            break;
1971
1972        case angle::FormatID::ASTC_5x5_UNORM_BLOCK:
1973
1974            this->metalFormat    = MTLPixelFormatASTC_5x5_LDR;
1975            this->actualFormatId = angle::FormatID::ASTC_5x5_UNORM_BLOCK;
1976            break;
1977
1978        case angle::FormatID::ASTC_6x5_UNORM_BLOCK:
1979
1980            this->metalFormat    = MTLPixelFormatASTC_6x5_LDR;
1981            this->actualFormatId = angle::FormatID::ASTC_6x5_UNORM_BLOCK;
1982            break;
1983
1984        case angle::FormatID::ASTC_6x6_UNORM_BLOCK:
1985
1986            this->metalFormat    = MTLPixelFormatASTC_6x6_LDR;
1987            this->actualFormatId = angle::FormatID::ASTC_6x6_UNORM_BLOCK;
1988            break;
1989
1990        case angle::FormatID::ASTC_8x5_UNORM_BLOCK:
1991
1992            this->metalFormat    = MTLPixelFormatASTC_8x5_LDR;
1993            this->actualFormatId = angle::FormatID::ASTC_8x5_UNORM_BLOCK;
1994            break;
1995
1996        case angle::FormatID::ASTC_8x6_UNORM_BLOCK:
1997
1998            this->metalFormat    = MTLPixelFormatASTC_8x6_LDR;
1999            this->actualFormatId = angle::FormatID::ASTC_8x6_UNORM_BLOCK;
2000            break;
2001
2002        case angle::FormatID::ASTC_8x8_UNORM_BLOCK:
2003
2004            this->metalFormat    = MTLPixelFormatASTC_8x8_LDR;
2005            this->actualFormatId = angle::FormatID::ASTC_8x8_UNORM_BLOCK;
2006            break;
2007
2008#    endif  // TARGET_OS_IOS || TARGET_OS_TV
2009#endif      // TARGET_OS_IPHONE
2010#if (TARGET_OS_OSX && (__MAC_OS_X_VERSION_MAX_ALLOWED >= 110000))
2011        case angle::FormatID::ASTC_10x10_SRGB_BLOCK:
2012
2013            this->metalFormat    = MTLPixelFormatASTC_10x10_sRGB;
2014            this->actualFormatId = angle::FormatID::ASTC_10x10_SRGB_BLOCK;
2015            break;
2016
2017        case angle::FormatID::ASTC_10x5_SRGB_BLOCK:
2018
2019            this->metalFormat    = MTLPixelFormatASTC_10x5_sRGB;
2020            this->actualFormatId = angle::FormatID::ASTC_10x5_SRGB_BLOCK;
2021            break;
2022
2023        case angle::FormatID::ASTC_10x6_SRGB_BLOCK:
2024
2025            this->metalFormat    = MTLPixelFormatASTC_10x6_sRGB;
2026            this->actualFormatId = angle::FormatID::ASTC_10x6_SRGB_BLOCK;
2027            break;
2028
2029        case angle::FormatID::ASTC_10x8_SRGB_BLOCK:
2030
2031            this->metalFormat    = MTLPixelFormatASTC_10x8_sRGB;
2032            this->actualFormatId = angle::FormatID::ASTC_10x8_SRGB_BLOCK;
2033            break;
2034
2035        case angle::FormatID::ASTC_12x10_SRGB_BLOCK:
2036
2037            this->metalFormat    = MTLPixelFormatASTC_12x10_sRGB;
2038            this->actualFormatId = angle::FormatID::ASTC_12x10_SRGB_BLOCK;
2039            break;
2040
2041        case angle::FormatID::ASTC_12x12_SRGB_BLOCK:
2042
2043            this->metalFormat    = MTLPixelFormatASTC_12x12_sRGB;
2044            this->actualFormatId = angle::FormatID::ASTC_12x12_SRGB_BLOCK;
2045            break;
2046
2047        case angle::FormatID::ASTC_4x4_SRGB_BLOCK:
2048
2049            this->metalFormat    = MTLPixelFormatASTC_4x4_sRGB;
2050            this->actualFormatId = angle::FormatID::ASTC_4x4_SRGB_BLOCK;
2051            break;
2052
2053        case angle::FormatID::ASTC_5x4_SRGB_BLOCK:
2054
2055            this->metalFormat    = MTLPixelFormatASTC_5x4_sRGB;
2056            this->actualFormatId = angle::FormatID::ASTC_5x4_SRGB_BLOCK;
2057            break;
2058
2059        case angle::FormatID::ASTC_5x5_SRGB_BLOCK:
2060
2061            this->metalFormat    = MTLPixelFormatASTC_5x5_sRGB;
2062            this->actualFormatId = angle::FormatID::ASTC_5x5_SRGB_BLOCK;
2063            break;
2064
2065        case angle::FormatID::ASTC_6x5_SRGB_BLOCK:
2066
2067            this->metalFormat    = MTLPixelFormatASTC_6x5_sRGB;
2068            this->actualFormatId = angle::FormatID::ASTC_6x5_SRGB_BLOCK;
2069            break;
2070
2071        case angle::FormatID::ASTC_6x6_SRGB_BLOCK:
2072
2073            this->metalFormat    = MTLPixelFormatASTC_6x6_sRGB;
2074            this->actualFormatId = angle::FormatID::ASTC_6x6_SRGB_BLOCK;
2075            break;
2076
2077        case angle::FormatID::ASTC_8x5_SRGB_BLOCK:
2078
2079            this->metalFormat    = MTLPixelFormatASTC_8x5_sRGB;
2080            this->actualFormatId = angle::FormatID::ASTC_8x5_SRGB_BLOCK;
2081            break;
2082
2083        case angle::FormatID::ASTC_8x6_SRGB_BLOCK:
2084
2085            this->metalFormat    = MTLPixelFormatASTC_8x6_sRGB;
2086            this->actualFormatId = angle::FormatID::ASTC_8x6_SRGB_BLOCK;
2087            break;
2088
2089        case angle::FormatID::ASTC_8x8_SRGB_BLOCK:
2090
2091            this->metalFormat    = MTLPixelFormatASTC_8x8_sRGB;
2092            this->actualFormatId = angle::FormatID::ASTC_8x8_SRGB_BLOCK;
2093            break;
2094
2095        case angle::FormatID::EAC_R11G11_SNORM_BLOCK:
2096
2097            if (display->supportsAppleGPUFamily(1))
2098            {
2099                this->metalFormat    = MTLPixelFormatEAC_RG11Snorm;
2100                this->actualFormatId = angle::FormatID::EAC_R11G11_SNORM_BLOCK;
2101            }
2102            else
2103            {
2104                this->metalFormat    = MTLPixelFormatRG16Snorm;
2105                this->actualFormatId = angle::FormatID::R16G16_SNORM;
2106            }
2107            break;
2108
2109        case angle::FormatID::EAC_R11G11_UNORM_BLOCK:
2110
2111            if (display->supportsAppleGPUFamily(1))
2112            {
2113                this->metalFormat    = MTLPixelFormatEAC_RG11Unorm;
2114                this->actualFormatId = angle::FormatID::EAC_R11G11_UNORM_BLOCK;
2115            }
2116            else
2117            {
2118                this->metalFormat    = MTLPixelFormatRG16Unorm;
2119                this->actualFormatId = angle::FormatID::R16G16_UNORM;
2120            }
2121            break;
2122
2123        case angle::FormatID::EAC_R11_SNORM_BLOCK:
2124
2125            if (display->supportsAppleGPUFamily(1))
2126            {
2127                this->metalFormat    = MTLPixelFormatEAC_R11Snorm;
2128                this->actualFormatId = angle::FormatID::EAC_R11_SNORM_BLOCK;
2129            }
2130            else
2131            {
2132                this->metalFormat    = MTLPixelFormatR16Snorm;
2133                this->actualFormatId = angle::FormatID::R16_SNORM;
2134            }
2135            break;
2136
2137        case angle::FormatID::EAC_R11_UNORM_BLOCK:
2138
2139            if (display->supportsAppleGPUFamily(1))
2140            {
2141                this->metalFormat    = MTLPixelFormatEAC_R11Unorm;
2142                this->actualFormatId = angle::FormatID::EAC_R11_UNORM_BLOCK;
2143            }
2144            else
2145            {
2146                this->metalFormat    = MTLPixelFormatR16Unorm;
2147                this->actualFormatId = angle::FormatID::R16_UNORM;
2148            }
2149            break;
2150
2151        case angle::FormatID::ETC1_R8G8B8_UNORM_BLOCK:
2152
2153            if (display->supportsAppleGPUFamily(1))
2154            {
2155                this->metalFormat    = MTLPixelFormatETC2_RGB8;
2156                this->actualFormatId = angle::FormatID::ETC1_R8G8B8_UNORM_BLOCK;
2157            }
2158            else
2159            {
2160                this->metalFormat    = MTLPixelFormatRGBA8Unorm;
2161                this->actualFormatId = angle::FormatID::R8G8B8A8_UNORM;
2162                this->initFunction   = Initialize4ComponentData<GLubyte, 0x00, 0x00, 0x00, 0xFF>;
2163            }
2164            break;
2165
2166        case angle::FormatID::ETC2_R8G8B8A1_SRGB_BLOCK:
2167
2168            if (display->supportsAppleGPUFamily(1))
2169            {
2170                this->metalFormat    = MTLPixelFormatETC2_RGB8A1_sRGB;
2171                this->actualFormatId = angle::FormatID::ETC2_R8G8B8A1_SRGB_BLOCK;
2172            }
2173            else
2174            {
2175                this->metalFormat    = MTLPixelFormatRGBA8Unorm_sRGB;
2176                this->actualFormatId = angle::FormatID::R8G8B8A8_UNORM_SRGB;
2177                this->initFunction   = Initialize4ComponentData<GLubyte, 0x00, 0x00, 0x00, 0xFF>;
2178            }
2179            break;
2180
2181        case angle::FormatID::ETC2_R8G8B8A1_UNORM_BLOCK:
2182
2183            if (display->supportsAppleGPUFamily(1))
2184            {
2185                this->metalFormat    = MTLPixelFormatETC2_RGB8A1;
2186                this->actualFormatId = angle::FormatID::ETC2_R8G8B8A1_UNORM_BLOCK;
2187            }
2188            else
2189            {
2190                this->metalFormat    = MTLPixelFormatRGBA8Unorm;
2191                this->actualFormatId = angle::FormatID::R8G8B8A8_UNORM;
2192                this->initFunction   = Initialize4ComponentData<GLubyte, 0x00, 0x00, 0x00, 0xFF>;
2193            }
2194            break;
2195
2196        case angle::FormatID::ETC2_R8G8B8A8_SRGB_BLOCK:
2197
2198            if (display->supportsAppleGPUFamily(1))
2199            {
2200                this->metalFormat    = MTLPixelFormatEAC_RGBA8_sRGB;
2201                this->actualFormatId = angle::FormatID::ETC2_R8G8B8A8_SRGB_BLOCK;
2202            }
2203            else
2204            {
2205                this->metalFormat    = MTLPixelFormatRGBA8Unorm_sRGB;
2206                this->actualFormatId = angle::FormatID::R8G8B8A8_UNORM_SRGB;
2207            }
2208            break;
2209
2210        case angle::FormatID::ETC2_R8G8B8A8_UNORM_BLOCK:
2211
2212            if (display->supportsAppleGPUFamily(1))
2213            {
2214                this->metalFormat    = MTLPixelFormatEAC_RGBA8;
2215                this->actualFormatId = angle::FormatID::ETC2_R8G8B8A8_UNORM_BLOCK;
2216            }
2217            else
2218            {
2219                this->metalFormat    = MTLPixelFormatRGBA8Unorm;
2220                this->actualFormatId = angle::FormatID::R8G8B8A8_UNORM;
2221            }
2222            break;
2223
2224        case angle::FormatID::ETC2_R8G8B8_SRGB_BLOCK:
2225
2226            if (display->supportsAppleGPUFamily(1))
2227            {
2228                this->metalFormat    = MTLPixelFormatETC2_RGB8_sRGB;
2229                this->actualFormatId = angle::FormatID::ETC2_R8G8B8_SRGB_BLOCK;
2230            }
2231            else
2232            {
2233                this->metalFormat    = MTLPixelFormatRGBA8Unorm_sRGB;
2234                this->actualFormatId = angle::FormatID::R8G8B8A8_UNORM_SRGB;
2235                this->initFunction   = Initialize4ComponentData<GLubyte, 0x00, 0x00, 0x00, 0xFF>;
2236            }
2237            break;
2238
2239        case angle::FormatID::ETC2_R8G8B8_UNORM_BLOCK:
2240
2241            if (display->supportsAppleGPUFamily(1))
2242            {
2243                this->metalFormat    = MTLPixelFormatETC2_RGB8;
2244                this->actualFormatId = angle::FormatID::ETC2_R8G8B8_UNORM_BLOCK;
2245            }
2246            else
2247            {
2248                this->metalFormat    = MTLPixelFormatRGBA8Unorm;
2249                this->actualFormatId = angle::FormatID::R8G8B8A8_UNORM;
2250                this->initFunction   = Initialize4ComponentData<GLubyte, 0x00, 0x00, 0x00, 0xFF>;
2251            }
2252            break;
2253
2254        case angle::FormatID::PVRTC1_RGBA_2BPP_UNORM_BLOCK:
2255
2256            this->metalFormat    = MTLPixelFormatPVRTC_RGBA_2BPP;
2257            this->actualFormatId = angle::FormatID::PVRTC1_RGBA_2BPP_UNORM_BLOCK;
2258            break;
2259
2260        case angle::FormatID::PVRTC1_RGBA_2BPP_UNORM_SRGB_BLOCK:
2261
2262            this->metalFormat    = MTLPixelFormatPVRTC_RGBA_2BPP_sRGB;
2263            this->actualFormatId = angle::FormatID::PVRTC1_RGBA_2BPP_UNORM_SRGB_BLOCK;
2264            break;
2265
2266        case angle::FormatID::PVRTC1_RGBA_4BPP_UNORM_BLOCK:
2267
2268            this->metalFormat    = MTLPixelFormatPVRTC_RGBA_4BPP;
2269            this->actualFormatId = angle::FormatID::PVRTC1_RGBA_4BPP_UNORM_BLOCK;
2270            break;
2271
2272        case angle::FormatID::PVRTC1_RGBA_4BPP_UNORM_SRGB_BLOCK:
2273
2274            this->metalFormat    = MTLPixelFormatPVRTC_RGBA_4BPP_sRGB;
2275            this->actualFormatId = angle::FormatID::PVRTC1_RGBA_4BPP_UNORM_SRGB_BLOCK;
2276            break;
2277
2278        case angle::FormatID::PVRTC1_RGB_2BPP_UNORM_BLOCK:
2279
2280            this->metalFormat    = MTLPixelFormatPVRTC_RGB_2BPP;
2281            this->actualFormatId = angle::FormatID::PVRTC1_RGB_2BPP_UNORM_BLOCK;
2282            break;
2283
2284        case angle::FormatID::PVRTC1_RGB_2BPP_UNORM_SRGB_BLOCK:
2285
2286            this->metalFormat    = MTLPixelFormatPVRTC_RGB_2BPP_sRGB;
2287            this->actualFormatId = angle::FormatID::PVRTC1_RGB_2BPP_UNORM_SRGB_BLOCK;
2288            break;
2289
2290        case angle::FormatID::PVRTC1_RGB_4BPP_UNORM_BLOCK:
2291
2292            this->metalFormat    = MTLPixelFormatPVRTC_RGB_4BPP;
2293            this->actualFormatId = angle::FormatID::PVRTC1_RGB_4BPP_UNORM_BLOCK;
2294            break;
2295
2296        case angle::FormatID::PVRTC1_RGB_4BPP_UNORM_SRGB_BLOCK:
2297
2298            this->metalFormat    = MTLPixelFormatPVRTC_RGB_4BPP_sRGB;
2299            this->actualFormatId = angle::FormatID::PVRTC1_RGB_4BPP_UNORM_SRGB_BLOCK;
2300            break;
2301
2302        case angle::FormatID::R4G4B4A4_UNORM:
2303
2304            if (display->supportsAppleGPUFamily(1))
2305            {
2306                this->metalFormat    = MTLPixelFormatABGR4Unorm;
2307                this->actualFormatId = angle::FormatID::R4G4B4A4_UNORM;
2308            }
2309            else
2310            {
2311                this->metalFormat    = MTLPixelFormatRGBA8Unorm;
2312                this->actualFormatId = angle::FormatID::R8G8B8A8_UNORM;
2313            }
2314            break;
2315
2316        case angle::FormatID::R5G5B5A1_UNORM:
2317
2318            if (display->supportsAppleGPUFamily(1))
2319            {
2320                this->metalFormat    = MTLPixelFormatA1BGR5Unorm;
2321                this->actualFormatId = angle::FormatID::R5G5B5A1_UNORM;
2322            }
2323            else
2324            {
2325                this->metalFormat    = MTLPixelFormatRGBA8Unorm;
2326                this->actualFormatId = angle::FormatID::R8G8B8A8_UNORM;
2327            }
2328            break;
2329
2330        case angle::FormatID::R5G6B5_UNORM:
2331
2332            if (display->supportsAppleGPUFamily(1))
2333            {
2334                this->metalFormat    = MTLPixelFormatB5G6R5Unorm;
2335                this->actualFormatId = angle::FormatID::R5G6B5_UNORM;
2336            }
2337            else
2338            {
2339                this->metalFormat    = MTLPixelFormatRGBA8Unorm;
2340                this->actualFormatId = angle::FormatID::R8G8B8A8_UNORM;
2341                this->initFunction   = Initialize4ComponentData<GLubyte, 0x00, 0x00, 0x00, 0xFF>;
2342            }
2343            break;
2344
2345        case angle::FormatID::R8G8_UNORM_SRGB:
2346
2347            this->metalFormat    = MTLPixelFormatRG8Unorm_sRGB;
2348            this->actualFormatId = angle::FormatID::R8G8_UNORM_SRGB;
2349            break;
2350
2351        case angle::FormatID::R8_UNORM_SRGB:
2352
2353            this->metalFormat    = MTLPixelFormatR8Unorm_sRGB;
2354            this->actualFormatId = angle::FormatID::R8_UNORM_SRGB;
2355            break;
2356
2357        case angle::FormatID::ASTC_10x10_UNORM_BLOCK:
2358
2359            if (display->supportsAppleGPUFamily(6))
2360            {
2361                this->metalFormat    = MTLPixelFormatASTC_10x10_HDR;
2362                this->actualFormatId = angle::FormatID::ASTC_10x10_UNORM_BLOCK;
2363            }
2364            else
2365            {
2366                this->metalFormat    = MTLPixelFormatASTC_10x10_LDR;
2367                this->actualFormatId = angle::FormatID::ASTC_10x10_UNORM_BLOCK;
2368            }
2369            break;
2370
2371        case angle::FormatID::ASTC_10x5_UNORM_BLOCK:
2372
2373            if (display->supportsAppleGPUFamily(6))
2374            {
2375                this->metalFormat    = MTLPixelFormatASTC_10x5_HDR;
2376                this->actualFormatId = angle::FormatID::ASTC_10x5_UNORM_BLOCK;
2377            }
2378            else
2379            {
2380                this->metalFormat    = MTLPixelFormatASTC_10x5_LDR;
2381                this->actualFormatId = angle::FormatID::ASTC_10x5_UNORM_BLOCK;
2382            }
2383            break;
2384
2385        case angle::FormatID::ASTC_10x6_UNORM_BLOCK:
2386
2387            if (display->supportsAppleGPUFamily(6))
2388            {
2389                this->metalFormat    = MTLPixelFormatASTC_10x6_HDR;
2390                this->actualFormatId = angle::FormatID::ASTC_10x6_UNORM_BLOCK;
2391            }
2392            else
2393            {
2394                this->metalFormat    = MTLPixelFormatASTC_10x6_LDR;
2395                this->actualFormatId = angle::FormatID::ASTC_10x6_UNORM_BLOCK;
2396            }
2397            break;
2398
2399        case angle::FormatID::ASTC_10x8_UNORM_BLOCK:
2400
2401            if (display->supportsAppleGPUFamily(6))
2402            {
2403                this->metalFormat    = MTLPixelFormatASTC_10x8_HDR;
2404                this->actualFormatId = angle::FormatID::ASTC_10x8_UNORM_BLOCK;
2405            }
2406            else
2407            {
2408                this->metalFormat    = MTLPixelFormatASTC_10x8_LDR;
2409                this->actualFormatId = angle::FormatID::ASTC_10x8_UNORM_BLOCK;
2410            }
2411            break;
2412
2413        case angle::FormatID::ASTC_12x10_UNORM_BLOCK:
2414
2415            if (display->supportsAppleGPUFamily(6))
2416            {
2417                this->metalFormat    = MTLPixelFormatASTC_12x10_HDR;
2418                this->actualFormatId = angle::FormatID::ASTC_12x10_UNORM_BLOCK;
2419            }
2420            else
2421            {
2422                this->metalFormat    = MTLPixelFormatASTC_12x10_LDR;
2423                this->actualFormatId = angle::FormatID::ASTC_12x10_UNORM_BLOCK;
2424            }
2425            break;
2426
2427        case angle::FormatID::ASTC_12x12_UNORM_BLOCK:
2428
2429            if (display->supportsAppleGPUFamily(6))
2430            {
2431                this->metalFormat    = MTLPixelFormatASTC_12x12_HDR;
2432                this->actualFormatId = angle::FormatID::ASTC_12x12_UNORM_BLOCK;
2433            }
2434            else
2435            {
2436                this->metalFormat    = MTLPixelFormatASTC_12x12_LDR;
2437                this->actualFormatId = angle::FormatID::ASTC_12x12_UNORM_BLOCK;
2438            }
2439            break;
2440
2441        case angle::FormatID::ASTC_4x4_UNORM_BLOCK:
2442
2443            if (display->supportsAppleGPUFamily(6))
2444            {
2445                this->metalFormat    = MTLPixelFormatASTC_4x4_HDR;
2446                this->actualFormatId = angle::FormatID::ASTC_4x4_UNORM_BLOCK;
2447            }
2448            else
2449            {
2450                this->metalFormat    = MTLPixelFormatASTC_4x4_LDR;
2451                this->actualFormatId = angle::FormatID::ASTC_4x4_UNORM_BLOCK;
2452            }
2453            break;
2454
2455        case angle::FormatID::ASTC_5x4_UNORM_BLOCK:
2456
2457            if (display->supportsAppleGPUFamily(6))
2458            {
2459                this->metalFormat    = MTLPixelFormatASTC_5x4_HDR;
2460                this->actualFormatId = angle::FormatID::ASTC_5x4_UNORM_BLOCK;
2461            }
2462            else
2463            {
2464                this->metalFormat    = MTLPixelFormatASTC_5x4_LDR;
2465                this->actualFormatId = angle::FormatID::ASTC_5x4_UNORM_BLOCK;
2466            }
2467            break;
2468
2469        case angle::FormatID::ASTC_5x5_UNORM_BLOCK:
2470
2471            if (display->supportsAppleGPUFamily(6))
2472            {
2473                this->metalFormat    = MTLPixelFormatASTC_5x5_HDR;
2474                this->actualFormatId = angle::FormatID::ASTC_5x5_UNORM_BLOCK;
2475            }
2476            else
2477            {
2478                this->metalFormat    = MTLPixelFormatASTC_5x5_LDR;
2479                this->actualFormatId = angle::FormatID::ASTC_5x5_UNORM_BLOCK;
2480            }
2481            break;
2482
2483        case angle::FormatID::ASTC_6x5_UNORM_BLOCK:
2484
2485            if (display->supportsAppleGPUFamily(6))
2486            {
2487                this->metalFormat    = MTLPixelFormatASTC_6x5_HDR;
2488                this->actualFormatId = angle::FormatID::ASTC_6x5_UNORM_BLOCK;
2489            }
2490            else
2491            {
2492                this->metalFormat    = MTLPixelFormatASTC_6x5_LDR;
2493                this->actualFormatId = angle::FormatID::ASTC_6x5_UNORM_BLOCK;
2494            }
2495            break;
2496
2497        case angle::FormatID::ASTC_6x6_UNORM_BLOCK:
2498
2499            if (display->supportsAppleGPUFamily(6))
2500            {
2501                this->metalFormat    = MTLPixelFormatASTC_6x6_HDR;
2502                this->actualFormatId = angle::FormatID::ASTC_6x6_UNORM_BLOCK;
2503            }
2504            else
2505            {
2506                this->metalFormat    = MTLPixelFormatASTC_6x6_LDR;
2507                this->actualFormatId = angle::FormatID::ASTC_6x6_UNORM_BLOCK;
2508            }
2509            break;
2510
2511        case angle::FormatID::ASTC_8x5_UNORM_BLOCK:
2512
2513            if (display->supportsAppleGPUFamily(6))
2514            {
2515                this->metalFormat    = MTLPixelFormatASTC_8x5_HDR;
2516                this->actualFormatId = angle::FormatID::ASTC_8x5_UNORM_BLOCK;
2517            }
2518            else
2519            {
2520                this->metalFormat    = MTLPixelFormatASTC_8x5_LDR;
2521                this->actualFormatId = angle::FormatID::ASTC_8x5_UNORM_BLOCK;
2522            }
2523            break;
2524
2525        case angle::FormatID::ASTC_8x6_UNORM_BLOCK:
2526
2527            if (display->supportsAppleGPUFamily(6))
2528            {
2529                this->metalFormat    = MTLPixelFormatASTC_8x6_HDR;
2530                this->actualFormatId = angle::FormatID::ASTC_8x6_UNORM_BLOCK;
2531            }
2532            else
2533            {
2534                this->metalFormat    = MTLPixelFormatASTC_8x6_LDR;
2535                this->actualFormatId = angle::FormatID::ASTC_8x6_UNORM_BLOCK;
2536            }
2537            break;
2538
2539        case angle::FormatID::ASTC_8x8_UNORM_BLOCK:
2540
2541            if (display->supportsAppleGPUFamily(6))
2542            {
2543                this->metalFormat    = MTLPixelFormatASTC_8x8_HDR;
2544                this->actualFormatId = angle::FormatID::ASTC_8x8_UNORM_BLOCK;
2545            }
2546            else
2547            {
2548                this->metalFormat    = MTLPixelFormatASTC_8x8_LDR;
2549                this->actualFormatId = angle::FormatID::ASTC_8x8_UNORM_BLOCK;
2550            }
2551            break;
2552
2553#endif  // TARGET_OS_OSX && (__MAC_OS_X_VERSION_MAX_ALLOWED >= 110000))
2554        default:
2555            this->metalFormat    = MTLPixelFormatInvalid;
2556            this->actualFormatId = angle::FormatID::NONE;
2557    }
2558}
2559
2560void VertexFormat::init(angle::FormatID angleFormatId, bool tightlyPacked)
2561{
2562    this->intendedFormatId = angleFormatId;
2563
2564    // Actual conversion
2565    switch (this->intendedFormatId)
2566    {
2567        case angle::FormatID::NONE:
2568            this->metalFormat        = MTLVertexFormatInvalid;
2569            this->actualFormatId     = angle::FormatID::NONE;
2570            this->vertexLoadFunction = nullptr;
2571            this->defaultAlpha       = 0;
2572            this->actualSameGLType   = false;
2573            break;
2574
2575        case angle::FormatID::R10G10B10A2_SNORM:
2576            this->metalFormat        = MTLVertexFormatInt1010102Normalized;
2577            this->actualFormatId     = angle::FormatID::R10G10B10A2_SNORM;
2578            this->vertexLoadFunction = CopyNativeVertexData<GLuint, 1, 1, 0>;
2579            this->defaultAlpha       = 0;
2580            break;
2581
2582        case angle::FormatID::R10G10B10A2_UNORM:
2583            this->metalFormat        = MTLVertexFormatUInt1010102Normalized;
2584            this->actualFormatId     = angle::FormatID::R10G10B10A2_UNORM;
2585            this->vertexLoadFunction = CopyNativeVertexData<GLuint, 1, 1, 0>;
2586            this->defaultAlpha       = 0;
2587            break;
2588
2589        case angle::FormatID::R16G16B16A16_FLOAT:
2590            this->metalFormat        = MTLVertexFormatHalf4;
2591            this->actualFormatId     = angle::FormatID::R16G16B16A16_FLOAT;
2592            this->vertexLoadFunction = CopyNativeVertexData<GLhalf, 4, 4, 0>;
2593            this->defaultAlpha       = 0;
2594            break;
2595
2596        case angle::FormatID::R16G16B16A16_SINT:
2597            this->metalFormat        = MTLVertexFormatShort4;
2598            this->actualFormatId     = angle::FormatID::R16G16B16A16_SINT;
2599            this->vertexLoadFunction = CopyNativeVertexData<GLshort, 4, 4, 0>;
2600            this->defaultAlpha       = 0;
2601            break;
2602
2603        case angle::FormatID::R16G16B16A16_SNORM:
2604            this->metalFormat        = MTLVertexFormatShort4Normalized;
2605            this->actualFormatId     = angle::FormatID::R16G16B16A16_SNORM;
2606            this->vertexLoadFunction = CopyNativeVertexData<GLshort, 4, 4, 0>;
2607            this->defaultAlpha       = 0;
2608            break;
2609
2610        case angle::FormatID::R16G16B16A16_SSCALED:
2611            this->metalFormat        = MTLVertexFormatShort4;
2612            this->actualFormatId     = angle::FormatID::R16G16B16A16_SSCALED;
2613            this->vertexLoadFunction = CopyNativeVertexData<GLshort, 4, 4, 0>;
2614            this->defaultAlpha       = 0;
2615            break;
2616
2617        case angle::FormatID::R16G16B16A16_UINT:
2618            this->metalFormat        = MTLVertexFormatUShort4;
2619            this->actualFormatId     = angle::FormatID::R16G16B16A16_UINT;
2620            this->vertexLoadFunction = CopyNativeVertexData<GLushort, 4, 4, 0>;
2621            this->defaultAlpha       = 0;
2622            break;
2623
2624        case angle::FormatID::R16G16B16A16_UNORM:
2625            this->metalFormat        = MTLVertexFormatUShort4Normalized;
2626            this->actualFormatId     = angle::FormatID::R16G16B16A16_UNORM;
2627            this->vertexLoadFunction = CopyNativeVertexData<GLushort, 4, 4, 0>;
2628            this->defaultAlpha       = 0;
2629            break;
2630
2631        case angle::FormatID::R16G16B16A16_USCALED:
2632            this->metalFormat        = MTLVertexFormatUShort4;
2633            this->actualFormatId     = angle::FormatID::R16G16B16A16_USCALED;
2634            this->vertexLoadFunction = CopyNativeVertexData<GLushort, 4, 4, 0>;
2635            this->defaultAlpha       = 0;
2636            break;
2637
2638        case angle::FormatID::R16G16B16_FLOAT:
2639            if (tightlyPacked)
2640            {
2641                this->metalFormat        = MTLVertexFormatHalf4;
2642                this->actualFormatId     = angle::FormatID::R16G16B16A16_FLOAT;
2643                this->vertexLoadFunction = CopyNativeVertexData<GLhalf, 3, 4, gl::Float16One>;
2644                this->defaultAlpha       = gl::Float16One;
2645            }
2646            else
2647            {
2648                this->metalFormat        = MTLVertexFormatHalf3;
2649                this->actualFormatId     = angle::FormatID::R16G16B16_FLOAT;
2650                this->vertexLoadFunction = CopyNativeVertexData<GLhalf, 3, 3, 0>;
2651                this->defaultAlpha       = 0;
2652            }
2653            break;
2654
2655        case angle::FormatID::R16G16B16_SINT:
2656            if (tightlyPacked)
2657            {
2658                this->metalFormat        = MTLVertexFormatShort4;
2659                this->actualFormatId     = angle::FormatID::R16G16B16A16_SINT;
2660                this->vertexLoadFunction = CopyNativeVertexData<GLshort, 3, 4, 1>;
2661                this->defaultAlpha       = 1;
2662            }
2663            else
2664            {
2665                this->metalFormat        = MTLVertexFormatShort3;
2666                this->actualFormatId     = angle::FormatID::R16G16B16_SINT;
2667                this->vertexLoadFunction = CopyNativeVertexData<GLshort, 3, 3, 0>;
2668                this->defaultAlpha       = 0;
2669            }
2670            break;
2671
2672        case angle::FormatID::R16G16B16_SNORM:
2673            if (tightlyPacked)
2674            {
2675                this->metalFormat    = MTLVertexFormatShort4Normalized;
2676                this->actualFormatId = angle::FormatID::R16G16B16A16_SNORM;
2677                this->vertexLoadFunction =
2678                    CopyNativeVertexData<GLshort, 3, 4, std::numeric_limits<GLshort>::max()>;
2679                this->defaultAlpha = std::numeric_limits<GLshort>::max();
2680            }
2681            else
2682            {
2683                this->metalFormat        = MTLVertexFormatShort3Normalized;
2684                this->actualFormatId     = angle::FormatID::R16G16B16_SNORM;
2685                this->vertexLoadFunction = CopyNativeVertexData<GLshort, 3, 3, 0>;
2686                this->defaultAlpha       = 0;
2687            }
2688            break;
2689
2690        case angle::FormatID::R16G16B16_SSCALED:
2691            if (tightlyPacked)
2692            {
2693                this->metalFormat        = MTLVertexFormatShort4;
2694                this->actualFormatId     = angle::FormatID::R16G16B16A16_SINT;
2695                this->vertexLoadFunction = CopyNativeVertexData<GLshort, 3, 4, 1>;
2696                this->defaultAlpha       = 1;
2697            }
2698            else
2699            {
2700                this->metalFormat        = MTLVertexFormatShort3;
2701                this->actualFormatId     = angle::FormatID::R16G16B16_SSCALED;
2702                this->vertexLoadFunction = CopyNativeVertexData<GLshort, 3, 3, 0>;
2703                this->defaultAlpha       = 0;
2704            }
2705            break;
2706
2707        case angle::FormatID::R16G16B16_UINT:
2708            if (tightlyPacked)
2709            {
2710                this->metalFormat        = MTLVertexFormatUShort4;
2711                this->actualFormatId     = angle::FormatID::R16G16B16A16_UINT;
2712                this->vertexLoadFunction = CopyNativeVertexData<GLushort, 3, 4, 1>;
2713                this->defaultAlpha       = 1;
2714            }
2715            else
2716            {
2717                this->metalFormat        = MTLVertexFormatUShort3;
2718                this->actualFormatId     = angle::FormatID::R16G16B16_UINT;
2719                this->vertexLoadFunction = CopyNativeVertexData<GLushort, 3, 3, 0>;
2720                this->defaultAlpha       = 0;
2721            }
2722            break;
2723
2724        case angle::FormatID::R16G16B16_UNORM:
2725            if (tightlyPacked)
2726            {
2727                this->metalFormat    = MTLVertexFormatUShort4Normalized;
2728                this->actualFormatId = angle::FormatID::R16G16B16A16_UNORM;
2729                this->vertexLoadFunction =
2730                    CopyNativeVertexData<GLushort, 3, 4, std::numeric_limits<GLushort>::max()>;
2731                this->defaultAlpha = std::numeric_limits<GLushort>::max();
2732            }
2733            else
2734            {
2735                this->metalFormat        = MTLVertexFormatUShort3Normalized;
2736                this->actualFormatId     = angle::FormatID::R16G16B16_UNORM;
2737                this->vertexLoadFunction = CopyNativeVertexData<GLushort, 3, 3, 0>;
2738                this->defaultAlpha       = 0;
2739            }
2740            break;
2741
2742        case angle::FormatID::R16G16B16_USCALED:
2743            if (tightlyPacked)
2744            {
2745                this->metalFormat        = MTLVertexFormatUShort4;
2746                this->actualFormatId     = angle::FormatID::R16G16B16A16_UINT;
2747                this->vertexLoadFunction = CopyNativeVertexData<GLushort, 3, 4, 1>;
2748                this->defaultAlpha       = 1;
2749            }
2750            else
2751            {
2752                this->metalFormat        = MTLVertexFormatUShort3;
2753                this->actualFormatId     = angle::FormatID::R16G16B16_USCALED;
2754                this->vertexLoadFunction = CopyNativeVertexData<GLushort, 3, 3, 0>;
2755                this->defaultAlpha       = 0;
2756            }
2757            break;
2758
2759        case angle::FormatID::R16G16_FLOAT:
2760            this->metalFormat        = MTLVertexFormatHalf2;
2761            this->actualFormatId     = angle::FormatID::R16G16_FLOAT;
2762            this->vertexLoadFunction = CopyNativeVertexData<GLhalf, 2, 2, 0>;
2763            this->defaultAlpha       = 0;
2764            break;
2765
2766        case angle::FormatID::R16G16_SINT:
2767            this->metalFormat        = MTLVertexFormatShort2;
2768            this->actualFormatId     = angle::FormatID::R16G16_SINT;
2769            this->vertexLoadFunction = CopyNativeVertexData<GLshort, 2, 2, 0>;
2770            this->defaultAlpha       = 0;
2771            break;
2772
2773        case angle::FormatID::R16G16_SNORM:
2774            this->metalFormat        = MTLVertexFormatShort2Normalized;
2775            this->actualFormatId     = angle::FormatID::R16G16_SNORM;
2776            this->vertexLoadFunction = CopyNativeVertexData<GLshort, 2, 2, 0>;
2777            this->defaultAlpha       = 0;
2778            break;
2779
2780        case angle::FormatID::R16G16_SSCALED:
2781            this->metalFormat        = MTLVertexFormatShort2;
2782            this->actualFormatId     = angle::FormatID::R16G16_SSCALED;
2783            this->vertexLoadFunction = CopyNativeVertexData<GLshort, 2, 2, 0>;
2784            this->defaultAlpha       = 0;
2785            break;
2786
2787        case angle::FormatID::R16G16_UINT:
2788            this->metalFormat        = MTLVertexFormatUShort2;
2789            this->actualFormatId     = angle::FormatID::R16G16_UINT;
2790            this->vertexLoadFunction = CopyNativeVertexData<GLushort, 2, 2, 0>;
2791            this->defaultAlpha       = 0;
2792            break;
2793
2794        case angle::FormatID::R16G16_UNORM:
2795            this->metalFormat        = MTLVertexFormatUShort2Normalized;
2796            this->actualFormatId     = angle::FormatID::R16G16_UNORM;
2797            this->vertexLoadFunction = CopyNativeVertexData<GLushort, 2, 2, 0>;
2798            this->defaultAlpha       = 0;
2799            break;
2800
2801        case angle::FormatID::R16G16_USCALED:
2802            this->metalFormat        = MTLVertexFormatUShort2;
2803            this->actualFormatId     = angle::FormatID::R16G16_USCALED;
2804            this->vertexLoadFunction = CopyNativeVertexData<GLushort, 2, 2, 0>;
2805            this->defaultAlpha       = 0;
2806            break;
2807
2808        case angle::FormatID::R16_FLOAT:
2809            if (tightlyPacked)
2810            {
2811                this->metalFormat        = MTLVertexFormatHalf2;
2812                this->actualFormatId     = angle::FormatID::R16G16_FLOAT;
2813                this->vertexLoadFunction = CopyNativeVertexData<GLhalf, 1, 2, 0>;
2814                this->defaultAlpha       = 0;
2815            }
2816            else
2817            {
2818                this->metalFormat        = MTLVertexFormatHalf;
2819                this->actualFormatId     = angle::FormatID::R16_FLOAT;
2820                this->vertexLoadFunction = CopyNativeVertexData<GLhalf, 1, 1, 0>;
2821                this->defaultAlpha       = 0;
2822            }
2823            break;
2824
2825        case angle::FormatID::R16_SINT:
2826            if (tightlyPacked)
2827            {
2828                this->metalFormat        = MTLVertexFormatShort2;
2829                this->actualFormatId     = angle::FormatID::R16G16_SINT;
2830                this->vertexLoadFunction = CopyNativeVertexData<GLshort, 1, 2, 0>;
2831                this->defaultAlpha       = 0;
2832            }
2833            else
2834            {
2835                this->metalFormat        = MTLVertexFormatShort;
2836                this->actualFormatId     = angle::FormatID::R16_SINT;
2837                this->vertexLoadFunction = CopyNativeVertexData<GLshort, 1, 1, 0>;
2838                this->defaultAlpha       = 0;
2839            }
2840            break;
2841
2842        case angle::FormatID::R16_SNORM:
2843            if (tightlyPacked)
2844            {
2845                this->metalFormat        = MTLVertexFormatShort2Normalized;
2846                this->actualFormatId     = angle::FormatID::R16G16_SNORM;
2847                this->vertexLoadFunction = CopyNativeVertexData<GLshort, 1, 2, 0>;
2848                this->defaultAlpha       = 0;
2849            }
2850            else
2851            {
2852                this->metalFormat        = MTLVertexFormatShortNormalized;
2853                this->actualFormatId     = angle::FormatID::R16_SNORM;
2854                this->vertexLoadFunction = CopyNativeVertexData<GLshort, 1, 1, 0>;
2855                this->defaultAlpha       = 0;
2856            }
2857            break;
2858
2859        case angle::FormatID::R16_SSCALED:
2860            if (tightlyPacked)
2861            {
2862                this->metalFormat        = MTLVertexFormatShort2;
2863                this->actualFormatId     = angle::FormatID::R16G16_SINT;
2864                this->vertexLoadFunction = CopyNativeVertexData<GLshort, 1, 2, 0>;
2865                this->defaultAlpha       = 0;
2866            }
2867            else
2868            {
2869                this->metalFormat        = MTLVertexFormatShort;
2870                this->actualFormatId     = angle::FormatID::R16_SSCALED;
2871                this->vertexLoadFunction = CopyNativeVertexData<GLshort, 1, 1, 0>;
2872                this->defaultAlpha       = 0;
2873            }
2874            break;
2875
2876        case angle::FormatID::R16_UINT:
2877            if (tightlyPacked)
2878            {
2879                this->metalFormat        = MTLVertexFormatUShort2;
2880                this->actualFormatId     = angle::FormatID::R16G16_UINT;
2881                this->vertexLoadFunction = CopyNativeVertexData<GLushort, 1, 2, 0>;
2882                this->defaultAlpha       = 0;
2883            }
2884            else
2885            {
2886                this->metalFormat        = MTLVertexFormatUShort;
2887                this->actualFormatId     = angle::FormatID::R16_UINT;
2888                this->vertexLoadFunction = CopyNativeVertexData<GLushort, 1, 1, 0>;
2889                this->defaultAlpha       = 0;
2890            }
2891            break;
2892
2893        case angle::FormatID::R16_UNORM:
2894            if (tightlyPacked)
2895            {
2896                this->metalFormat        = MTLVertexFormatUShort2Normalized;
2897                this->actualFormatId     = angle::FormatID::R16G16_UNORM;
2898                this->vertexLoadFunction = CopyNativeVertexData<GLushort, 1, 2, 0>;
2899                this->defaultAlpha       = 0;
2900            }
2901            else
2902            {
2903                this->metalFormat        = MTLVertexFormatUShortNormalized;
2904                this->actualFormatId     = angle::FormatID::R16_UNORM;
2905                this->vertexLoadFunction = CopyNativeVertexData<GLushort, 1, 1, 0>;
2906                this->defaultAlpha       = 0;
2907            }
2908            break;
2909
2910        case angle::FormatID::R16_USCALED:
2911            if (tightlyPacked)
2912            {
2913                this->metalFormat        = MTLVertexFormatUShort2;
2914                this->actualFormatId     = angle::FormatID::R16G16_UINT;
2915                this->vertexLoadFunction = CopyNativeVertexData<GLushort, 1, 2, 0>;
2916                this->defaultAlpha       = 0;
2917            }
2918            else
2919            {
2920                this->metalFormat        = MTLVertexFormatUShort;
2921                this->actualFormatId     = angle::FormatID::R16_USCALED;
2922                this->vertexLoadFunction = CopyNativeVertexData<GLushort, 1, 1, 0>;
2923                this->defaultAlpha       = 0;
2924            }
2925            break;
2926
2927        case angle::FormatID::R32G32B32A32_FLOAT:
2928            this->metalFormat        = MTLVertexFormatFloat4;
2929            this->actualFormatId     = angle::FormatID::R32G32B32A32_FLOAT;
2930            this->vertexLoadFunction = CopyNativeVertexData<GLfloat, 4, 4, 0>;
2931            this->defaultAlpha       = 0;
2932            break;
2933
2934        case angle::FormatID::R32G32B32A32_SINT:
2935            this->metalFormat        = MTLVertexFormatInt4;
2936            this->actualFormatId     = angle::FormatID::R32G32B32A32_SINT;
2937            this->vertexLoadFunction = CopyNativeVertexData<GLint, 4, 4, 0>;
2938            this->defaultAlpha       = 0;
2939            break;
2940
2941        case angle::FormatID::R32G32B32A32_UINT:
2942            this->metalFormat        = MTLVertexFormatUInt4;
2943            this->actualFormatId     = angle::FormatID::R32G32B32A32_UINT;
2944            this->vertexLoadFunction = CopyNativeVertexData<GLuint, 4, 4, 0>;
2945            this->defaultAlpha       = 0;
2946            break;
2947
2948        case angle::FormatID::R32G32B32_FLOAT:
2949            this->metalFormat        = MTLVertexFormatFloat3;
2950            this->actualFormatId     = angle::FormatID::R32G32B32_FLOAT;
2951            this->vertexLoadFunction = CopyNativeVertexData<GLfloat, 3, 3, 0>;
2952            this->defaultAlpha       = 0;
2953            break;
2954
2955        case angle::FormatID::R32G32B32_SINT:
2956            this->metalFormat        = MTLVertexFormatInt3;
2957            this->actualFormatId     = angle::FormatID::R32G32B32_SINT;
2958            this->vertexLoadFunction = CopyNativeVertexData<GLint, 3, 3, 0>;
2959            this->defaultAlpha       = 0;
2960            break;
2961
2962        case angle::FormatID::R32G32B32_UINT:
2963            this->metalFormat        = MTLVertexFormatUInt3;
2964            this->actualFormatId     = angle::FormatID::R32G32B32_UINT;
2965            this->vertexLoadFunction = CopyNativeVertexData<GLuint, 3, 3, 0>;
2966            this->defaultAlpha       = 0;
2967            break;
2968
2969        case angle::FormatID::R32G32_FLOAT:
2970            this->metalFormat        = MTLVertexFormatFloat2;
2971            this->actualFormatId     = angle::FormatID::R32G32_FLOAT;
2972            this->vertexLoadFunction = CopyNativeVertexData<GLfloat, 2, 2, 0>;
2973            this->defaultAlpha       = 0;
2974            break;
2975
2976        case angle::FormatID::R32G32_SINT:
2977            this->metalFormat        = MTLVertexFormatInt2;
2978            this->actualFormatId     = angle::FormatID::R32G32_SINT;
2979            this->vertexLoadFunction = CopyNativeVertexData<GLint, 2, 2, 0>;
2980            this->defaultAlpha       = 0;
2981            break;
2982
2983        case angle::FormatID::R32G32_UINT:
2984            this->metalFormat        = MTLVertexFormatUInt2;
2985            this->actualFormatId     = angle::FormatID::R32G32_UINT;
2986            this->vertexLoadFunction = CopyNativeVertexData<GLuint, 2, 2, 0>;
2987            this->defaultAlpha       = 0;
2988            break;
2989
2990        case angle::FormatID::R32_FLOAT:
2991            this->metalFormat        = MTLVertexFormatFloat;
2992            this->actualFormatId     = angle::FormatID::R32_FLOAT;
2993            this->vertexLoadFunction = CopyNativeVertexData<GLfloat, 1, 1, 0>;
2994            this->defaultAlpha       = 0;
2995            break;
2996
2997        case angle::FormatID::R32_SINT:
2998            this->metalFormat        = MTLVertexFormatInt;
2999            this->actualFormatId     = angle::FormatID::R32_SINT;
3000            this->vertexLoadFunction = CopyNativeVertexData<GLint, 1, 1, 0>;
3001            this->defaultAlpha       = 0;
3002            break;
3003
3004        case angle::FormatID::R32_UINT:
3005            this->metalFormat        = MTLVertexFormatUInt;
3006            this->actualFormatId     = angle::FormatID::R32_UINT;
3007            this->vertexLoadFunction = CopyNativeVertexData<GLuint, 1, 1, 0>;
3008            this->defaultAlpha       = 0;
3009            break;
3010
3011        case angle::FormatID::R8G8B8A8_SINT:
3012            this->metalFormat        = MTLVertexFormatChar4;
3013            this->actualFormatId     = angle::FormatID::R8G8B8A8_SINT;
3014            this->vertexLoadFunction = CopyNativeVertexData<GLbyte, 4, 4, 0>;
3015            this->defaultAlpha       = 0;
3016            break;
3017
3018        case angle::FormatID::R8G8B8A8_SNORM:
3019            this->metalFormat        = MTLVertexFormatChar4Normalized;
3020            this->actualFormatId     = angle::FormatID::R8G8B8A8_SNORM;
3021            this->vertexLoadFunction = CopyNativeVertexData<GLbyte, 4, 4, 0>;
3022            this->defaultAlpha       = 0;
3023            break;
3024
3025        case angle::FormatID::R8G8B8A8_SSCALED:
3026            this->metalFormat        = MTLVertexFormatChar4;
3027            this->actualFormatId     = angle::FormatID::R8G8B8A8_SSCALED;
3028            this->vertexLoadFunction = CopyNativeVertexData<GLbyte, 4, 4, 0>;
3029            this->defaultAlpha       = 0;
3030            break;
3031
3032        case angle::FormatID::R8G8B8A8_UINT:
3033            this->metalFormat        = MTLVertexFormatUChar4;
3034            this->actualFormatId     = angle::FormatID::R8G8B8A8_UINT;
3035            this->vertexLoadFunction = CopyNativeVertexData<GLubyte, 4, 4, 0>;
3036            this->defaultAlpha       = 0;
3037            break;
3038
3039        case angle::FormatID::R8G8B8A8_UNORM:
3040            this->metalFormat        = MTLVertexFormatUChar4Normalized;
3041            this->actualFormatId     = angle::FormatID::R8G8B8A8_UNORM;
3042            this->vertexLoadFunction = CopyNativeVertexData<GLubyte, 4, 4, 0>;
3043            this->defaultAlpha       = 0;
3044            break;
3045
3046        case angle::FormatID::R8G8B8A8_USCALED:
3047            this->metalFormat        = MTLVertexFormatUChar4;
3048            this->actualFormatId     = angle::FormatID::R8G8B8A8_USCALED;
3049            this->vertexLoadFunction = CopyNativeVertexData<GLubyte, 4, 4, 0>;
3050            this->defaultAlpha       = 0;
3051            break;
3052
3053        case angle::FormatID::R8G8B8_SINT:
3054            if (tightlyPacked)
3055            {
3056                this->metalFormat        = MTLVertexFormatChar4;
3057                this->actualFormatId     = angle::FormatID::R8G8B8A8_SINT;
3058                this->vertexLoadFunction = CopyNativeVertexData<GLbyte, 3, 4, 1>;
3059                this->defaultAlpha       = 1;
3060            }
3061            else
3062            {
3063                this->metalFormat        = MTLVertexFormatChar3;
3064                this->actualFormatId     = angle::FormatID::R8G8B8_SINT;
3065                this->vertexLoadFunction = CopyNativeVertexData<GLbyte, 3, 3, 0>;
3066                this->defaultAlpha       = 0;
3067            }
3068            break;
3069
3070        case angle::FormatID::R8G8B8_SNORM:
3071            if (tightlyPacked)
3072            {
3073                this->metalFormat    = MTLVertexFormatChar4Normalized;
3074                this->actualFormatId = angle::FormatID::R8G8B8A8_SNORM;
3075                this->vertexLoadFunction =
3076                    CopyNativeVertexData<GLbyte, 3, 4, std::numeric_limits<GLbyte>::max()>;
3077                this->defaultAlpha = std::numeric_limits<GLbyte>::max();
3078            }
3079            else
3080            {
3081                this->metalFormat        = MTLVertexFormatChar3Normalized;
3082                this->actualFormatId     = angle::FormatID::R8G8B8_SNORM;
3083                this->vertexLoadFunction = CopyNativeVertexData<GLbyte, 3, 3, 0>;
3084                this->defaultAlpha       = 0;
3085            }
3086            break;
3087
3088        case angle::FormatID::R8G8B8_SSCALED:
3089            if (tightlyPacked)
3090            {
3091                this->metalFormat        = MTLVertexFormatChar4;
3092                this->actualFormatId     = angle::FormatID::R8G8B8A8_SINT;
3093                this->vertexLoadFunction = CopyNativeVertexData<GLbyte, 3, 4, 1>;
3094                this->defaultAlpha       = 1;
3095            }
3096            else
3097            {
3098                this->metalFormat        = MTLVertexFormatChar3;
3099                this->actualFormatId     = angle::FormatID::R8G8B8_SSCALED;
3100                this->vertexLoadFunction = CopyNativeVertexData<GLbyte, 3, 3, 0>;
3101                this->defaultAlpha       = 0;
3102            }
3103            break;
3104
3105        case angle::FormatID::R8G8B8_UINT:
3106            if (tightlyPacked)
3107            {
3108                this->metalFormat        = MTLVertexFormatUChar4;
3109                this->actualFormatId     = angle::FormatID::R8G8B8A8_UINT;
3110                this->vertexLoadFunction = CopyNativeVertexData<GLubyte, 3, 4, 1>;
3111                this->defaultAlpha       = 1;
3112            }
3113            else
3114            {
3115                this->metalFormat        = MTLVertexFormatUChar3;
3116                this->actualFormatId     = angle::FormatID::R8G8B8_UINT;
3117                this->vertexLoadFunction = CopyNativeVertexData<GLubyte, 3, 3, 0>;
3118                this->defaultAlpha       = 0;
3119            }
3120            break;
3121
3122        case angle::FormatID::R8G8B8_UNORM:
3123            if (tightlyPacked)
3124            {
3125                this->metalFormat    = MTLVertexFormatUChar4Normalized;
3126                this->actualFormatId = angle::FormatID::R8G8B8A8_UNORM;
3127                this->vertexLoadFunction =
3128                    CopyNativeVertexData<GLubyte, 3, 4, std::numeric_limits<GLubyte>::max()>;
3129                this->defaultAlpha = std::numeric_limits<GLubyte>::max();
3130            }
3131            else
3132            {
3133                this->metalFormat        = MTLVertexFormatUChar3Normalized;
3134                this->actualFormatId     = angle::FormatID::R8G8B8_UNORM;
3135                this->vertexLoadFunction = CopyNativeVertexData<GLubyte, 3, 3, 0>;
3136                this->defaultAlpha       = 0;
3137            }
3138            break;
3139
3140        case angle::FormatID::R8G8B8_USCALED:
3141            if (tightlyPacked)
3142            {
3143                this->metalFormat        = MTLVertexFormatUChar4;
3144                this->actualFormatId     = angle::FormatID::R8G8B8A8_UINT;
3145                this->vertexLoadFunction = CopyNativeVertexData<GLubyte, 3, 4, 1>;
3146                this->defaultAlpha       = 1;
3147            }
3148            else
3149            {
3150                this->metalFormat        = MTLVertexFormatUChar3;
3151                this->actualFormatId     = angle::FormatID::R8G8B8_USCALED;
3152                this->vertexLoadFunction = CopyNativeVertexData<GLubyte, 3, 3, 0>;
3153                this->defaultAlpha       = 0;
3154            }
3155            break;
3156
3157        case angle::FormatID::R8G8_SINT:
3158            if (tightlyPacked)
3159            {
3160                this->metalFormat        = MTLVertexFormatChar4;
3161                this->actualFormatId     = angle::FormatID::R8G8B8A8_SINT;
3162                this->vertexLoadFunction = CopyNativeVertexData<GLbyte, 2, 4, 1>;
3163                this->defaultAlpha       = 1;
3164            }
3165            else
3166            {
3167                this->metalFormat        = MTLVertexFormatChar2;
3168                this->actualFormatId     = angle::FormatID::R8G8_SINT;
3169                this->vertexLoadFunction = CopyNativeVertexData<GLbyte, 2, 2, 0>;
3170                this->defaultAlpha       = 0;
3171            }
3172            break;
3173
3174        case angle::FormatID::R8G8_SNORM:
3175            if (tightlyPacked)
3176            {
3177                this->metalFormat    = MTLVertexFormatChar4Normalized;
3178                this->actualFormatId = angle::FormatID::R8G8B8A8_SNORM;
3179                this->vertexLoadFunction =
3180                    CopyNativeVertexData<GLbyte, 2, 4, std::numeric_limits<GLbyte>::max()>;
3181                this->defaultAlpha = std::numeric_limits<GLbyte>::max();
3182            }
3183            else
3184            {
3185                this->metalFormat        = MTLVertexFormatChar2Normalized;
3186                this->actualFormatId     = angle::FormatID::R8G8_SNORM;
3187                this->vertexLoadFunction = CopyNativeVertexData<GLbyte, 2, 2, 0>;
3188                this->defaultAlpha       = 0;
3189            }
3190            break;
3191
3192        case angle::FormatID::R8G8_SSCALED:
3193            if (tightlyPacked)
3194            {
3195                this->metalFormat        = MTLVertexFormatChar4;
3196                this->actualFormatId     = angle::FormatID::R8G8B8A8_SINT;
3197                this->vertexLoadFunction = CopyNativeVertexData<GLbyte, 2, 4, 1>;
3198                this->defaultAlpha       = 1;
3199            }
3200            else
3201            {
3202                this->metalFormat        = MTLVertexFormatChar2;
3203                this->actualFormatId     = angle::FormatID::R8G8_SSCALED;
3204                this->vertexLoadFunction = CopyNativeVertexData<GLbyte, 2, 2, 0>;
3205                this->defaultAlpha       = 0;
3206            }
3207            break;
3208
3209        case angle::FormatID::R8G8_UINT:
3210            if (tightlyPacked)
3211            {
3212                this->metalFormat        = MTLVertexFormatUChar4;
3213                this->actualFormatId     = angle::FormatID::R8G8B8A8_UINT;
3214                this->vertexLoadFunction = CopyNativeVertexData<GLubyte, 2, 4, 1>;
3215                this->defaultAlpha       = 1;
3216            }
3217            else
3218            {
3219                this->metalFormat        = MTLVertexFormatUChar2;
3220                this->actualFormatId     = angle::FormatID::R8G8_UINT;
3221                this->vertexLoadFunction = CopyNativeVertexData<GLubyte, 2, 2, 0>;
3222                this->defaultAlpha       = 0;
3223            }
3224            break;
3225
3226        case angle::FormatID::R8G8_UNORM:
3227            if (tightlyPacked)
3228            {
3229                this->metalFormat    = MTLVertexFormatUChar4Normalized;
3230                this->actualFormatId = angle::FormatID::R8G8B8A8_UNORM;
3231                this->vertexLoadFunction =
3232                    CopyNativeVertexData<GLubyte, 2, 4, std::numeric_limits<GLubyte>::max()>;
3233                this->defaultAlpha = std::numeric_limits<GLubyte>::max();
3234            }
3235            else
3236            {
3237                this->metalFormat        = MTLVertexFormatUChar2Normalized;
3238                this->actualFormatId     = angle::FormatID::R8G8_UNORM;
3239                this->vertexLoadFunction = CopyNativeVertexData<GLubyte, 2, 2, 0>;
3240                this->defaultAlpha       = 0;
3241            }
3242            break;
3243
3244        case angle::FormatID::R8G8_USCALED:
3245            if (tightlyPacked)
3246            {
3247                this->metalFormat        = MTLVertexFormatUChar4;
3248                this->actualFormatId     = angle::FormatID::R8G8B8A8_UINT;
3249                this->vertexLoadFunction = CopyNativeVertexData<GLubyte, 2, 4, 1>;
3250                this->defaultAlpha       = 1;
3251            }
3252            else
3253            {
3254                this->metalFormat        = MTLVertexFormatUChar2;
3255                this->actualFormatId     = angle::FormatID::R8G8_USCALED;
3256                this->vertexLoadFunction = CopyNativeVertexData<GLubyte, 2, 2, 0>;
3257                this->defaultAlpha       = 0;
3258            }
3259            break;
3260
3261        case angle::FormatID::R8_SINT:
3262            if (tightlyPacked)
3263            {
3264                this->metalFormat        = MTLVertexFormatChar4;
3265                this->actualFormatId     = angle::FormatID::R8G8B8A8_SINT;
3266                this->vertexLoadFunction = CopyNativeVertexData<GLbyte, 1, 4, 1>;
3267                this->defaultAlpha       = 1;
3268            }
3269            else
3270            {
3271                this->metalFormat        = MTLVertexFormatChar;
3272                this->actualFormatId     = angle::FormatID::R8_SINT;
3273                this->vertexLoadFunction = CopyNativeVertexData<GLbyte, 1, 1, 0>;
3274                this->defaultAlpha       = 0;
3275            }
3276            break;
3277
3278        case angle::FormatID::R8_SNORM:
3279            if (tightlyPacked)
3280            {
3281                this->metalFormat    = MTLVertexFormatChar4Normalized;
3282                this->actualFormatId = angle::FormatID::R8G8B8A8_SNORM;
3283                this->vertexLoadFunction =
3284                    CopyNativeVertexData<GLbyte, 1, 4, std::numeric_limits<GLbyte>::max()>;
3285                this->defaultAlpha = std::numeric_limits<GLbyte>::max();
3286            }
3287            else
3288            {
3289                this->metalFormat        = MTLVertexFormatCharNormalized;
3290                this->actualFormatId     = angle::FormatID::R8_SNORM;
3291                this->vertexLoadFunction = CopyNativeVertexData<GLbyte, 1, 1, 0>;
3292                this->defaultAlpha       = 0;
3293            }
3294            break;
3295
3296        case angle::FormatID::R8_SSCALED:
3297            if (tightlyPacked)
3298            {
3299                this->metalFormat        = MTLVertexFormatChar4;
3300                this->actualFormatId     = angle::FormatID::R8G8B8A8_SINT;
3301                this->vertexLoadFunction = CopyNativeVertexData<GLbyte, 1, 4, 1>;
3302                this->defaultAlpha       = 1;
3303            }
3304            else
3305            {
3306                this->metalFormat        = MTLVertexFormatChar;
3307                this->actualFormatId     = angle::FormatID::R8_SSCALED;
3308                this->vertexLoadFunction = CopyNativeVertexData<GLbyte, 1, 1, 0>;
3309                this->defaultAlpha       = 0;
3310            }
3311            break;
3312
3313        case angle::FormatID::R8_UINT:
3314            if (tightlyPacked)
3315            {
3316                this->metalFormat        = MTLVertexFormatUChar4;
3317                this->actualFormatId     = angle::FormatID::R8G8B8A8_UINT;
3318                this->vertexLoadFunction = CopyNativeVertexData<GLubyte, 1, 4, 1>;
3319                this->defaultAlpha       = 1;
3320            }
3321            else
3322            {
3323                this->metalFormat        = MTLVertexFormatUChar;
3324                this->actualFormatId     = angle::FormatID::R8_UINT;
3325                this->vertexLoadFunction = CopyNativeVertexData<GLubyte, 1, 1, 0>;
3326                this->defaultAlpha       = 0;
3327            }
3328            break;
3329
3330        case angle::FormatID::R8_UNORM:
3331            if (tightlyPacked)
3332            {
3333                this->metalFormat    = MTLVertexFormatUChar4Normalized;
3334                this->actualFormatId = angle::FormatID::R8G8B8A8_UNORM;
3335                this->vertexLoadFunction =
3336                    CopyNativeVertexData<GLubyte, 1, 4, std::numeric_limits<GLubyte>::max()>;
3337                this->defaultAlpha = std::numeric_limits<GLubyte>::max();
3338            }
3339            else
3340            {
3341                this->metalFormat        = MTLVertexFormatUCharNormalized;
3342                this->actualFormatId     = angle::FormatID::R8_UNORM;
3343                this->vertexLoadFunction = CopyNativeVertexData<GLubyte, 1, 1, 0>;
3344                this->defaultAlpha       = 0;
3345            }
3346            break;
3347
3348        case angle::FormatID::R8_USCALED:
3349            if (tightlyPacked)
3350            {
3351                this->metalFormat        = MTLVertexFormatUChar4;
3352                this->actualFormatId     = angle::FormatID::R8G8B8A8_UINT;
3353                this->vertexLoadFunction = CopyNativeVertexData<GLubyte, 1, 4, 1>;
3354                this->defaultAlpha       = 1;
3355            }
3356            else
3357            {
3358                this->metalFormat        = MTLVertexFormatUChar;
3359                this->actualFormatId     = angle::FormatID::R8_USCALED;
3360                this->vertexLoadFunction = CopyNativeVertexData<GLubyte, 1, 1, 0>;
3361                this->defaultAlpha       = 0;
3362            }
3363            break;
3364
3365        case angle::FormatID::R10G10B10A2_SINT:
3366            this->metalFormat        = MTLVertexFormatFloat4;
3367            this->actualFormatId     = angle::FormatID::R32G32B32A32_FLOAT;
3368            this->vertexLoadFunction = CopyXYZ10W2ToXYZWFloatVertexData<true, false, true, false>;
3369            this->defaultAlpha       = 0;
3370            this->actualSameGLType   = false;
3371            break;
3372
3373        case angle::FormatID::R10G10B10A2_SSCALED:
3374            this->metalFormat        = MTLVertexFormatFloat4;
3375            this->actualFormatId     = angle::FormatID::R32G32B32A32_FLOAT;
3376            this->vertexLoadFunction = CopyXYZ10W2ToXYZWFloatVertexData<true, false, true, false>;
3377            this->defaultAlpha       = 0;
3378            this->actualSameGLType   = false;
3379            break;
3380
3381        case angle::FormatID::R10G10B10A2_UINT:
3382            this->metalFormat        = MTLVertexFormatFloat4;
3383            this->actualFormatId     = angle::FormatID::R32G32B32A32_FLOAT;
3384            this->vertexLoadFunction = CopyXYZ10W2ToXYZWFloatVertexData<false, false, true, false>;
3385            this->defaultAlpha       = 0;
3386            this->actualSameGLType   = false;
3387            break;
3388
3389        case angle::FormatID::R10G10B10A2_USCALED:
3390            this->metalFormat        = MTLVertexFormatFloat4;
3391            this->actualFormatId     = angle::FormatID::R32G32B32A32_FLOAT;
3392            this->vertexLoadFunction = CopyXYZ10W2ToXYZWFloatVertexData<false, false, true, false>;
3393            this->defaultAlpha       = 0;
3394            this->actualSameGLType   = false;
3395            break;
3396
3397        case angle::FormatID::R32G32B32A32_FIXED:
3398            this->metalFormat        = MTLVertexFormatFloat4;
3399            this->actualFormatId     = angle::FormatID::R32G32B32A32_FLOAT;
3400            this->vertexLoadFunction = Copy32FixedTo32FVertexData<4, 4>;
3401            this->defaultAlpha       = 0;
3402            this->actualSameGLType   = false;
3403            break;
3404
3405        case angle::FormatID::R32G32B32A32_SNORM:
3406            this->metalFormat        = MTLVertexFormatFloat4;
3407            this->actualFormatId     = angle::FormatID::R32G32B32A32_FLOAT;
3408            this->vertexLoadFunction = CopyToFloatVertexData<GLint, 4, 4, true, false>;
3409            this->defaultAlpha       = 0;
3410            this->actualSameGLType   = false;
3411            break;
3412
3413        case angle::FormatID::R32G32B32A32_SSCALED:
3414            this->metalFormat        = MTLVertexFormatFloat4;
3415            this->actualFormatId     = angle::FormatID::R32G32B32A32_FLOAT;
3416            this->vertexLoadFunction = CopyToFloatVertexData<GLint, 4, 4, false, false>;
3417            this->defaultAlpha       = 0;
3418            this->actualSameGLType   = false;
3419            break;
3420
3421        case angle::FormatID::R32G32B32A32_UNORM:
3422            this->metalFormat        = MTLVertexFormatFloat4;
3423            this->actualFormatId     = angle::FormatID::R32G32B32A32_FLOAT;
3424            this->vertexLoadFunction = CopyToFloatVertexData<GLuint, 4, 4, true, false>;
3425            this->defaultAlpha       = 0;
3426            this->actualSameGLType   = false;
3427            break;
3428
3429        case angle::FormatID::R32G32B32A32_USCALED:
3430            this->metalFormat        = MTLVertexFormatFloat4;
3431            this->actualFormatId     = angle::FormatID::R32G32B32A32_FLOAT;
3432            this->vertexLoadFunction = CopyToFloatVertexData<GLuint, 4, 4, false, false>;
3433            this->defaultAlpha       = 0;
3434            this->actualSameGLType   = false;
3435            break;
3436
3437        case angle::FormatID::R32G32B32_FIXED:
3438            this->metalFormat        = MTLVertexFormatFloat3;
3439            this->actualFormatId     = angle::FormatID::R32G32B32_FLOAT;
3440            this->vertexLoadFunction = Copy32FixedTo32FVertexData<3, 3>;
3441            this->defaultAlpha       = 0;
3442            this->actualSameGLType   = false;
3443            break;
3444
3445        case angle::FormatID::R32G32B32_SNORM:
3446            this->metalFormat        = MTLVertexFormatFloat3;
3447            this->actualFormatId     = angle::FormatID::R32G32B32_FLOAT;
3448            this->vertexLoadFunction = CopyToFloatVertexData<GLint, 3, 3, true, false>;
3449            this->defaultAlpha       = 0;
3450            this->actualSameGLType   = false;
3451            break;
3452
3453        case angle::FormatID::R32G32B32_SSCALED:
3454            this->metalFormat        = MTLVertexFormatFloat3;
3455            this->actualFormatId     = angle::FormatID::R32G32B32_FLOAT;
3456            this->vertexLoadFunction = CopyToFloatVertexData<GLint, 3, 3, false, false>;
3457            this->defaultAlpha       = 0;
3458            this->actualSameGLType   = false;
3459            break;
3460
3461        case angle::FormatID::R32G32B32_UNORM:
3462            this->metalFormat        = MTLVertexFormatFloat3;
3463            this->actualFormatId     = angle::FormatID::R32G32B32_FLOAT;
3464            this->vertexLoadFunction = CopyToFloatVertexData<GLuint, 3, 3, true, false>;
3465            this->defaultAlpha       = 0;
3466            this->actualSameGLType   = false;
3467            break;
3468
3469        case angle::FormatID::R32G32B32_USCALED:
3470            this->metalFormat        = MTLVertexFormatFloat3;
3471            this->actualFormatId     = angle::FormatID::R32G32B32_FLOAT;
3472            this->vertexLoadFunction = CopyToFloatVertexData<GLuint, 3, 3, false, false>;
3473            this->defaultAlpha       = 0;
3474            this->actualSameGLType   = false;
3475            break;
3476
3477        case angle::FormatID::R32G32_FIXED:
3478            this->metalFormat        = MTLVertexFormatFloat2;
3479            this->actualFormatId     = angle::FormatID::R32G32_FLOAT;
3480            this->vertexLoadFunction = Copy32FixedTo32FVertexData<2, 2>;
3481            this->defaultAlpha       = 0;
3482            this->actualSameGLType   = false;
3483            break;
3484
3485        case angle::FormatID::R32G32_SNORM:
3486            this->metalFormat        = MTLVertexFormatFloat2;
3487            this->actualFormatId     = angle::FormatID::R32G32_FLOAT;
3488            this->vertexLoadFunction = CopyToFloatVertexData<GLint, 2, 2, true, false>;
3489            this->defaultAlpha       = 0;
3490            this->actualSameGLType   = false;
3491            break;
3492
3493        case angle::FormatID::R32G32_SSCALED:
3494            this->metalFormat        = MTLVertexFormatFloat2;
3495            this->actualFormatId     = angle::FormatID::R32G32_FLOAT;
3496            this->vertexLoadFunction = CopyToFloatVertexData<GLint, 2, 2, false, false>;
3497            this->defaultAlpha       = 0;
3498            this->actualSameGLType   = false;
3499            break;
3500
3501        case angle::FormatID::R32G32_UNORM:
3502            this->metalFormat        = MTLVertexFormatFloat2;
3503            this->actualFormatId     = angle::FormatID::R32G32_FLOAT;
3504            this->vertexLoadFunction = CopyToFloatVertexData<GLuint, 2, 2, true, false>;
3505            this->defaultAlpha       = 0;
3506            this->actualSameGLType   = false;
3507            break;
3508
3509        case angle::FormatID::R32G32_USCALED:
3510            this->metalFormat        = MTLVertexFormatFloat2;
3511            this->actualFormatId     = angle::FormatID::R32G32_FLOAT;
3512            this->vertexLoadFunction = CopyToFloatVertexData<GLuint, 2, 2, false, false>;
3513            this->defaultAlpha       = 0;
3514            this->actualSameGLType   = false;
3515            break;
3516
3517        case angle::FormatID::R32_FIXED:
3518            this->metalFormat        = MTLVertexFormatFloat;
3519            this->actualFormatId     = angle::FormatID::R32_FLOAT;
3520            this->vertexLoadFunction = Copy32FixedTo32FVertexData<1, 1>;
3521            this->defaultAlpha       = 0;
3522            this->actualSameGLType   = false;
3523            break;
3524
3525        case angle::FormatID::R32_SNORM:
3526            this->metalFormat        = MTLVertexFormatFloat;
3527            this->actualFormatId     = angle::FormatID::R32_FLOAT;
3528            this->vertexLoadFunction = CopyToFloatVertexData<GLint, 1, 1, true, false>;
3529            this->defaultAlpha       = 0;
3530            this->actualSameGLType   = false;
3531            break;
3532
3533        case angle::FormatID::R32_SSCALED:
3534            this->metalFormat        = MTLVertexFormatFloat;
3535            this->actualFormatId     = angle::FormatID::R32_FLOAT;
3536            this->vertexLoadFunction = CopyToFloatVertexData<GLint, 1, 1, false, false>;
3537            this->defaultAlpha       = 0;
3538            this->actualSameGLType   = false;
3539            break;
3540
3541        case angle::FormatID::R32_UNORM:
3542            this->metalFormat        = MTLVertexFormatFloat;
3543            this->actualFormatId     = angle::FormatID::R32_FLOAT;
3544            this->vertexLoadFunction = CopyToFloatVertexData<GLuint, 1, 1, true, false>;
3545            this->defaultAlpha       = 0;
3546            this->actualSameGLType   = false;
3547            break;
3548
3549        case angle::FormatID::R32_USCALED:
3550            this->metalFormat        = MTLVertexFormatFloat;
3551            this->actualFormatId     = angle::FormatID::R32_FLOAT;
3552            this->vertexLoadFunction = CopyToFloatVertexData<GLuint, 1, 1, false, false>;
3553            this->defaultAlpha       = 0;
3554            this->actualSameGLType   = false;
3555            break;
3556
3557        default:
3558            this->metalFormat        = MTLVertexFormatInvalid;
3559            this->actualFormatId     = angle::FormatID::NONE;
3560            this->vertexLoadFunction = nullptr;
3561            this->defaultAlpha       = 0;
3562            this->actualSameGLType   = false;
3563    }
3564}
3565
3566void FormatTable::initNativeFormatCapsAutogen(const DisplayMtl *display)
3567{
3568    const angle::FeaturesMtl &featuresMtl = display->getFeatures();
3569    // Skip auto resolve if either hasDepth/StencilAutoResolve or allowMultisampleStoreAndResolve
3570    // feature are disabled.
3571    bool supportDepthAutoResolve = featuresMtl.hasDepthAutoResolve.enabled &&
3572                                   featuresMtl.allowMultisampleStoreAndResolve.enabled;
3573    bool supportStencilAutoResolve = featuresMtl.hasStencilAutoResolve.enabled &&
3574                                     featuresMtl.allowMultisampleStoreAndResolve.enabled;
3575    bool supportDepthStencilAutoResolve = supportDepthAutoResolve && supportStencilAutoResolve;
3576
3577    // Source: https://developer.apple.com/metal/Metal-Feature-Set-Tables.pdf
3578    setFormatCaps(MTLPixelFormatA8Unorm, /** filterable*/ true, /** writable*/ false,
3579                  /** blendable*/ false, /** multisample*/ false, /** resolve*/ false,
3580                  /** colorRenderable*/ false, /** depthRenderable*/ false);
3581
3582    setFormatCaps(MTLPixelFormatBGR10A2Unorm, /** filterable*/ true,
3583                  /** writable*/ display->supportsEitherGPUFamily(3, 1), /** blendable*/ true,
3584                  /** multisample*/ true, /** resolve*/ true, /** colorRenderable*/ true,
3585                  /** depthRenderable*/ false);
3586
3587    setFormatCaps(MTLPixelFormatBGRA8Unorm, /** filterable*/ true, /** writable*/ true,
3588                  /** blendable*/ true, /** multisample*/ true, /** resolve*/ true,
3589                  /** colorRenderable*/ true, /** depthRenderable*/ false);
3590
3591    setFormatCaps(MTLPixelFormatBGRA8Unorm_sRGB, /** filterable*/ true,
3592                  /** writable*/ display->supportsAppleGPUFamily(2) && !display->isSimulator(),
3593                  /** blendable*/ true, /** multisample*/ true, /** resolve*/ true,
3594                  /** colorRenderable*/ true, /** depthRenderable*/ false);
3595
3596    setFormatCaps(MTLPixelFormatDepth32Float,
3597                  /** filterable*/ display->supports32BitFloatFiltering(), /** writable*/ false,
3598                  /** blendable*/ false, /** multisample*/ true,
3599                  /** resolve*/ supportDepthAutoResolve, /** colorRenderable*/ false,
3600                  /** depthRenderable*/ true);
3601
3602    setFormatCaps(MTLPixelFormatDepth32Float_Stencil8,
3603                  /** filterable*/ display->supports32BitFloatFiltering(), /** writable*/ false,
3604                  /** blendable*/ false, /** multisample*/ true,
3605                  /** resolve*/ supportDepthStencilAutoResolve, /** colorRenderable*/ false,
3606                  /** depthRenderable*/ true);
3607
3608    setFormatCaps(MTLPixelFormatR16Float, /** filterable*/ true, /** writable*/ true,
3609                  /** blendable*/ true, /** multisample*/ true, /** resolve*/ true,
3610                  /** colorRenderable*/ true, /** depthRenderable*/ false);
3611
3612    setFormatCaps(MTLPixelFormatR16Sint, /** filterable*/ false, /** writable*/ true,
3613                  /** blendable*/ false, /** multisample*/ true, /** resolve*/ false,
3614                  /** colorRenderable*/ true, /** depthRenderable*/ false);
3615
3616    setFormatCaps(MTLPixelFormatR16Snorm, /** filterable*/ true, /** writable*/ true,
3617                  /** blendable*/ true, /** multisample*/ true,
3618                  /** resolve*/ display->supportsMacGPUFamily(1), /** colorRenderable*/ true,
3619                  /** depthRenderable*/ false);
3620
3621    setFormatCaps(MTLPixelFormatR16Uint, /** filterable*/ false, /** writable*/ true,
3622                  /** blendable*/ false, /** multisample*/ true, /** resolve*/ false,
3623                  /** colorRenderable*/ true, /** depthRenderable*/ false);
3624
3625    setFormatCaps(MTLPixelFormatR16Unorm, /** filterable*/ true, /** writable*/ true,
3626                  /** blendable*/ true, /** multisample*/ true,
3627                  /** resolve*/ display->supportsMacGPUFamily(1), /** colorRenderable*/ true,
3628                  /** depthRenderable*/ false);
3629
3630    setFormatCaps(MTLPixelFormatR32Float, /** filterable*/ display->supportsMacGPUFamily(1),
3631                  /** writable*/ true, /** blendable*/ true, /** multisample*/ true,
3632                  /** resolve*/ display->supportsMacGPUFamily(1), /** colorRenderable*/ true,
3633                  /** depthRenderable*/ false);
3634
3635    setFormatCaps(MTLPixelFormatR32Sint, /** filterable*/ false, /** writable*/ true,
3636                  /** blendable*/ false, /** multisample*/ display->supportsMacGPUFamily(1),
3637                  /** resolve*/ false, /** colorRenderable*/ true, /** depthRenderable*/ false);
3638
3639    setFormatCaps(MTLPixelFormatR32Uint, /** filterable*/ false, /** writable*/ true,
3640                  /** blendable*/ false, /** multisample*/ display->supportsMacGPUFamily(1),
3641                  /** resolve*/ false, /** colorRenderable*/ true, /** depthRenderable*/ false);
3642
3643    setFormatCaps(MTLPixelFormatR8Sint, /** filterable*/ false, /** writable*/ true,
3644                  /** blendable*/ false, /** multisample*/ true, /** resolve*/ false,
3645                  /** colorRenderable*/ true, /** depthRenderable*/ false);
3646
3647    setFormatCaps(MTLPixelFormatR8Snorm, /** filterable*/ true, /** writable*/ true,
3648                  /** blendable*/ true, /** multisample*/ true,
3649                  /** resolve*/ display->supportsEitherGPUFamily(2, 1), /** colorRenderable*/ true,
3650                  /** depthRenderable*/ false);
3651
3652    setFormatCaps(MTLPixelFormatR8Uint, /** filterable*/ false, /** writable*/ true,
3653                  /** blendable*/ false, /** multisample*/ true, /** resolve*/ false,
3654                  /** colorRenderable*/ true, /** depthRenderable*/ false);
3655
3656    setFormatCaps(MTLPixelFormatR8Unorm, /** filterable*/ true, /** writable*/ true,
3657                  /** blendable*/ true, /** multisample*/ true, /** resolve*/ true,
3658                  /** colorRenderable*/ true, /** depthRenderable*/ false);
3659
3660    setFormatCaps(MTLPixelFormatRG11B10Float, /** filterable*/ true,
3661                  /** writable*/ display->supportsEitherGPUFamily(3, 1), /** blendable*/ true,
3662                  /** multisample*/ true, /** resolve*/ true, /** colorRenderable*/ true,
3663                  /** depthRenderable*/ false);
3664
3665    setFormatCaps(MTLPixelFormatRG16Float, /** filterable*/ true, /** writable*/ true,
3666                  /** blendable*/ true, /** multisample*/ true, /** resolve*/ true,
3667                  /** colorRenderable*/ true, /** depthRenderable*/ false);
3668
3669    setFormatCaps(MTLPixelFormatRG16Sint, /** filterable*/ false, /** writable*/ true,
3670                  /** blendable*/ false, /** multisample*/ true, /** resolve*/ false,
3671                  /** colorRenderable*/ true, /** depthRenderable*/ false);
3672
3673    setFormatCaps(MTLPixelFormatRG16Snorm, /** filterable*/ true, /** writable*/ true,
3674                  /** blendable*/ true, /** multisample*/ true,
3675                  /** resolve*/ display->supportsMacGPUFamily(1), /** colorRenderable*/ true,
3676                  /** depthRenderable*/ false);
3677
3678    setFormatCaps(MTLPixelFormatRG16Uint, /** filterable*/ false, /** writable*/ true,
3679                  /** blendable*/ false, /** multisample*/ true, /** resolve*/ false,
3680                  /** colorRenderable*/ true, /** depthRenderable*/ false);
3681
3682    setFormatCaps(MTLPixelFormatRG16Unorm, /** filterable*/ true, /** writable*/ true,
3683                  /** blendable*/ true, /** multisample*/ true,
3684                  /** resolve*/ display->supportsMacGPUFamily(1), /** colorRenderable*/ true,
3685                  /** depthRenderable*/ false);
3686
3687    setFormatCaps(MTLPixelFormatRG32Float, /** filterable*/ display->supportsMacGPUFamily(1),
3688                  /** writable*/ true, /** blendable*/ true,
3689                  /** multisample*/ display->supportsEitherGPUFamily(7, 1),
3690                  /** resolve*/ display->supportsMacGPUFamily(1), /** colorRenderable*/ true,
3691                  /** depthRenderable*/ false);
3692
3693    setFormatCaps(MTLPixelFormatRG32Sint, /** filterable*/ false, /** writable*/ true,
3694                  /** blendable*/ false, /** multisample*/ display->supportsEitherGPUFamily(7, 1),
3695                  /** resolve*/ false, /** colorRenderable*/ true, /** depthRenderable*/ false);
3696
3697    setFormatCaps(MTLPixelFormatRG32Uint, /** filterable*/ false, /** writable*/ true,
3698                  /** blendable*/ false, /** multisample*/ display->supportsEitherGPUFamily(7, 1),
3699                  /** resolve*/ false, /** colorRenderable*/ true, /** depthRenderable*/ false);
3700
3701    setFormatCaps(MTLPixelFormatRG8Sint, /** filterable*/ false, /** writable*/ true,
3702                  /** blendable*/ false, /** multisample*/ true, /** resolve*/ false,
3703                  /** colorRenderable*/ true, /** depthRenderable*/ false);
3704
3705    setFormatCaps(MTLPixelFormatRG8Snorm, /** filterable*/ true, /** writable*/ true,
3706                  /** blendable*/ true, /** multisample*/ true,
3707                  /** resolve*/ display->supportsEitherGPUFamily(2, 1), /** colorRenderable*/ true,
3708                  /** depthRenderable*/ false);
3709
3710    setFormatCaps(MTLPixelFormatRG8Uint, /** filterable*/ false, /** writable*/ true,
3711                  /** blendable*/ false, /** multisample*/ true, /** resolve*/ false,
3712                  /** colorRenderable*/ true, /** depthRenderable*/ false);
3713
3714    setFormatCaps(MTLPixelFormatRG8Unorm, /** filterable*/ true, /** writable*/ true,
3715                  /** blendable*/ true, /** multisample*/ true, /** resolve*/ true,
3716                  /** colorRenderable*/ true, /** depthRenderable*/ false);
3717
3718    setFormatCaps(MTLPixelFormatRGB10A2Uint, /** filterable*/ false,
3719                  /** writable*/ display->supportsEitherGPUFamily(3, 1), /** blendable*/ false,
3720                  /** multisample*/ true, /** resolve*/ false, /** colorRenderable*/ true,
3721                  /** depthRenderable*/ false);
3722
3723    setFormatCaps(MTLPixelFormatRGB10A2Unorm, /** filterable*/ true,
3724                  /** writable*/ display->supportsEitherGPUFamily(3, 1), /** blendable*/ true,
3725                  /** multisample*/ true, /** resolve*/ true, /** colorRenderable*/ true,
3726                  /** depthRenderable*/ false);
3727
3728    setFormatCaps(
3729        MTLPixelFormatRGB9E5Float, /** filterable*/ true,
3730        /** writable*/ display->supportsAppleGPUFamily(3),
3731        /** blendable*/ display->supportsAppleGPUFamily(1),
3732        /** multisample*/ display->supportsAppleGPUFamily(1),
3733        /** resolve*/ display->supportsAppleGPUFamily(1),
3734        /** colorRenderable*/ display->supportsAppleGPUFamily(1) && !display->isSimulator(),
3735        /** depthRenderable*/ false);
3736
3737    setFormatCaps(MTLPixelFormatRGBA16Float, /** filterable*/ true, /** writable*/ true,
3738                  /** blendable*/ true, /** multisample*/ true, /** resolve*/ true,
3739                  /** colorRenderable*/ true, /** depthRenderable*/ false);
3740
3741    setFormatCaps(MTLPixelFormatRGBA16Sint, /** filterable*/ false, /** writable*/ true,
3742                  /** blendable*/ false, /** multisample*/ true, /** resolve*/ false,
3743                  /** colorRenderable*/ true, /** depthRenderable*/ false);
3744
3745    setFormatCaps(MTLPixelFormatRGBA16Snorm, /** filterable*/ true, /** writable*/ true,
3746                  /** blendable*/ true, /** multisample*/ true,
3747                  /** resolve*/ display->supportsMacGPUFamily(1), /** colorRenderable*/ true,
3748                  /** depthRenderable*/ false);
3749
3750    setFormatCaps(MTLPixelFormatRGBA16Uint, /** filterable*/ false, /** writable*/ true,
3751                  /** blendable*/ false, /** multisample*/ true, /** resolve*/ false,
3752                  /** colorRenderable*/ true, /** depthRenderable*/ false);
3753
3754    setFormatCaps(MTLPixelFormatRGBA16Unorm, /** filterable*/ true, /** writable*/ true,
3755                  /** blendable*/ true, /** multisample*/ true,
3756                  /** resolve*/ display->supportsMacGPUFamily(1), /** colorRenderable*/ true,
3757                  /** depthRenderable*/ false);
3758
3759    setFormatCaps(MTLPixelFormatRGBA32Float, /** filterable*/ display->supportsMacGPUFamily(1),
3760                  /** writable*/ true, /** blendable*/ display->supportsMacGPUFamily(1),
3761                  /** multisample*/ display->supportsEitherGPUFamily(7, 1),
3762                  /** resolve*/ display->supportsMacGPUFamily(1), /** colorRenderable*/ true,
3763                  /** depthRenderable*/ false);
3764
3765    setFormatCaps(MTLPixelFormatRGBA32Sint, /** filterable*/ false, /** writable*/ true,
3766                  /** blendable*/ false, /** multisample*/ display->supportsMacGPUFamily(1),
3767                  /** resolve*/ false, /** colorRenderable*/ true, /** depthRenderable*/ false);
3768
3769    setFormatCaps(MTLPixelFormatRGBA32Uint, /** filterable*/ false, /** writable*/ true,
3770                  /** blendable*/ false, /** multisample*/ display->supportsMacGPUFamily(1),
3771                  /** resolve*/ false, /** colorRenderable*/ true, /** depthRenderable*/ false);
3772
3773    setFormatCaps(MTLPixelFormatRGBA8Sint, /** filterable*/ false, /** writable*/ true,
3774                  /** blendable*/ false, /** multisample*/ true, /** resolve*/ false,
3775                  /** colorRenderable*/ true, /** depthRenderable*/ false);
3776
3777    setFormatCaps(MTLPixelFormatRGBA8Snorm, /** filterable*/ true, /** writable*/ true,
3778                  /** blendable*/ true, /** multisample*/ true,
3779                  /** resolve*/ display->supportsEitherGPUFamily(2, 1), /** colorRenderable*/ true,
3780                  /** depthRenderable*/ false);
3781
3782    setFormatCaps(MTLPixelFormatRGBA8Uint, /** filterable*/ false, /** writable*/ true,
3783                  /** blendable*/ false, /** multisample*/ true, /** resolve*/ false,
3784                  /** colorRenderable*/ true, /** depthRenderable*/ false);
3785
3786    setFormatCaps(MTLPixelFormatRGBA8Unorm, /** filterable*/ true, /** writable*/ true,
3787                  /** blendable*/ true, /** multisample*/ true, /** resolve*/ true,
3788                  /** colorRenderable*/ true, /** depthRenderable*/ false);
3789
3790    setFormatCaps(MTLPixelFormatRGBA8Unorm_sRGB, /** filterable*/ true,
3791                  /** writable*/ display->supportsAppleGPUFamily(2) && !display->isSimulator(),
3792                  /** blendable*/ true, /** multisample*/ true, /** resolve*/ true,
3793                  /** colorRenderable*/ true, /** depthRenderable*/ false);
3794
3795    setFormatCaps(MTLPixelFormatStencil8, /** filterable*/ false, /** writable*/ false,
3796                  /** blendable*/ false, /** multisample*/ true, /** resolve*/ false,
3797                  /** colorRenderable*/ false, /** depthRenderable*/ true);
3798
3799#if TARGET_OS_OSX || TARGET_OS_MACCATALYST
3800    setFormatCaps(MTLPixelFormatBC1_RGBA, /** filterable*/ true, /** writable*/ false,
3801                  /** blendable*/ false, /** multisample*/ false, /** resolve*/ false,
3802                  /** colorRenderable*/ false, /** depthRenderable*/ false);
3803
3804    setFormatCaps(MTLPixelFormatBC1_RGBA_sRGB, /** filterable*/ true, /** writable*/ false,
3805                  /** blendable*/ false, /** multisample*/ false, /** resolve*/ false,
3806                  /** colorRenderable*/ false, /** depthRenderable*/ false);
3807
3808    setFormatCaps(MTLPixelFormatBC2_RGBA, /** filterable*/ true, /** writable*/ false,
3809                  /** blendable*/ false, /** multisample*/ false, /** resolve*/ false,
3810                  /** colorRenderable*/ false, /** depthRenderable*/ false);
3811
3812    setFormatCaps(MTLPixelFormatBC2_RGBA_sRGB, /** filterable*/ true, /** writable*/ false,
3813                  /** blendable*/ false, /** multisample*/ false, /** resolve*/ false,
3814                  /** colorRenderable*/ false, /** depthRenderable*/ false);
3815
3816    setFormatCaps(MTLPixelFormatBC3_RGBA, /** filterable*/ true, /** writable*/ false,
3817                  /** blendable*/ false, /** multisample*/ false, /** resolve*/ false,
3818                  /** colorRenderable*/ false, /** depthRenderable*/ false);
3819
3820    setFormatCaps(MTLPixelFormatBC3_RGBA_sRGB, /** filterable*/ true, /** writable*/ false,
3821                  /** blendable*/ false, /** multisample*/ false, /** resolve*/ false,
3822                  /** colorRenderable*/ false, /** depthRenderable*/ false);
3823
3824    setFormatCaps(MTLPixelFormatBC4_RSnorm, /** filterable*/ true, /** writable*/ false,
3825                  /** blendable*/ false, /** multisample*/ false, /** resolve*/ false,
3826                  /** colorRenderable*/ false, /** depthRenderable*/ false);
3827
3828    setFormatCaps(MTLPixelFormatBC4_RUnorm, /** filterable*/ true, /** writable*/ false,
3829                  /** blendable*/ false, /** multisample*/ false, /** resolve*/ false,
3830                  /** colorRenderable*/ false, /** depthRenderable*/ false);
3831
3832    setFormatCaps(MTLPixelFormatBC5_RGSnorm, /** filterable*/ true, /** writable*/ false,
3833                  /** blendable*/ false, /** multisample*/ false, /** resolve*/ false,
3834                  /** colorRenderable*/ false, /** depthRenderable*/ false);
3835
3836    setFormatCaps(MTLPixelFormatBC5_RGUnorm, /** filterable*/ true, /** writable*/ false,
3837                  /** blendable*/ false, /** multisample*/ false, /** resolve*/ false,
3838                  /** colorRenderable*/ false, /** depthRenderable*/ false);
3839
3840    setFormatCaps(MTLPixelFormatBC6H_RGBFloat, /** filterable*/ true, /** writable*/ false,
3841                  /** blendable*/ false, /** multisample*/ false, /** resolve*/ false,
3842                  /** colorRenderable*/ false, /** depthRenderable*/ false);
3843
3844    setFormatCaps(MTLPixelFormatBC6H_RGBUfloat, /** filterable*/ true, /** writable*/ false,
3845                  /** blendable*/ false, /** multisample*/ false, /** resolve*/ false,
3846                  /** colorRenderable*/ false, /** depthRenderable*/ false);
3847
3848    setFormatCaps(MTLPixelFormatBC7_RGBAUnorm, /** filterable*/ true, /** writable*/ false,
3849                  /** blendable*/ false, /** multisample*/ false, /** resolve*/ false,
3850                  /** colorRenderable*/ false, /** depthRenderable*/ false);
3851
3852    setFormatCaps(MTLPixelFormatBC7_RGBAUnorm_sRGB, /** filterable*/ true, /** writable*/ false,
3853                  /** blendable*/ false, /** multisample*/ false, /** resolve*/ false,
3854                  /** colorRenderable*/ false, /** depthRenderable*/ false);
3855
3856    setFormatCaps(MTLPixelFormatDepth16Unorm, /** filterable*/ true, /** writable*/ false,
3857                  /** blendable*/ false, /** multisample*/ true,
3858                  /** resolve*/ supportDepthAutoResolve, /** colorRenderable*/ false,
3859                  /** depthRenderable*/ true);
3860
3861    setFormatCaps(MTLPixelFormatDepth24Unorm_Stencil8,
3862                  /** filterable*/ display->supportsMacGPUFamily(1) &&
3863                      display->supportsDepth24Stencil8PixelFormat(),
3864                  /** writable*/ false, /** blendable*/ false, /** multisample*/ true,
3865                  /** resolve*/ supportDepthStencilAutoResolve, /** colorRenderable*/ false,
3866                  /** depthRenderable*/ display->supportsMacGPUFamily(1) &&
3867                      display->supportsDepth24Stencil8PixelFormat());
3868
3869#endif  // TARGET_OS_OSX || TARGET_OS_MACCATALYST
3870#if (TARGET_OS_IPHONE && !TARGET_OS_MACCATALYST) || \
3871    (TARGET_OS_OSX && (__MAC_OS_X_VERSION_MAX_ALLOWED >= 110000))
3872    setFormatCaps(MTLPixelFormatA1BGR5Unorm, /** filterable*/ display->supportsAppleGPUFamily(1),
3873                  /** writable*/ false, /** blendable*/ display->supportsAppleGPUFamily(1),
3874                  /** multisample*/ display->supportsAppleGPUFamily(1),
3875                  /** resolve*/ display->supportsAppleGPUFamily(1),
3876                  /** colorRenderable*/ display->supportsAppleGPUFamily(1),
3877                  /** depthRenderable*/ false);
3878
3879    setFormatCaps(MTLPixelFormatABGR4Unorm, /** filterable*/ display->supportsAppleGPUFamily(1),
3880                  /** writable*/ false, /** blendable*/ display->supportsAppleGPUFamily(1),
3881                  /** multisample*/ display->supportsAppleGPUFamily(1),
3882                  /** resolve*/ display->supportsAppleGPUFamily(1),
3883                  /** colorRenderable*/ display->supportsAppleGPUFamily(1),
3884                  /** depthRenderable*/ false);
3885
3886    setFormatCaps(MTLPixelFormatASTC_10x10_LDR, /** filterable*/ display->supportsAppleGPUFamily(2),
3887                  /** writable*/ false, /** blendable*/ false, /** multisample*/ false,
3888                  /** resolve*/ false, /** colorRenderable*/ false, /** depthRenderable*/ false);
3889
3890    setFormatCaps(MTLPixelFormatASTC_10x10_sRGB,
3891                  /** filterable*/ display->supportsAppleGPUFamily(2), /** writable*/ false,
3892                  /** blendable*/ false, /** multisample*/ false, /** resolve*/ false,
3893                  /** colorRenderable*/ false, /** depthRenderable*/ false);
3894
3895    setFormatCaps(MTLPixelFormatASTC_10x5_LDR, /** filterable*/ display->supportsAppleGPUFamily(2),
3896                  /** writable*/ false, /** blendable*/ false, /** multisample*/ false,
3897                  /** resolve*/ false, /** colorRenderable*/ false, /** depthRenderable*/ false);
3898
3899    setFormatCaps(MTLPixelFormatASTC_10x5_sRGB, /** filterable*/ display->supportsAppleGPUFamily(2),
3900                  /** writable*/ false, /** blendable*/ false, /** multisample*/ false,
3901                  /** resolve*/ false, /** colorRenderable*/ false, /** depthRenderable*/ false);
3902
3903    setFormatCaps(MTLPixelFormatASTC_10x6_LDR, /** filterable*/ display->supportsAppleGPUFamily(2),
3904                  /** writable*/ false, /** blendable*/ false, /** multisample*/ false,
3905                  /** resolve*/ false, /** colorRenderable*/ false, /** depthRenderable*/ false);
3906
3907    setFormatCaps(MTLPixelFormatASTC_10x6_sRGB, /** filterable*/ display->supportsAppleGPUFamily(2),
3908                  /** writable*/ false, /** blendable*/ false, /** multisample*/ false,
3909                  /** resolve*/ false, /** colorRenderable*/ false, /** depthRenderable*/ false);
3910
3911    setFormatCaps(MTLPixelFormatASTC_10x8_LDR, /** filterable*/ display->supportsAppleGPUFamily(2),
3912                  /** writable*/ false, /** blendable*/ false, /** multisample*/ false,
3913                  /** resolve*/ false, /** colorRenderable*/ false, /** depthRenderable*/ false);
3914
3915    setFormatCaps(MTLPixelFormatASTC_10x8_sRGB, /** filterable*/ display->supportsAppleGPUFamily(2),
3916                  /** writable*/ false, /** blendable*/ false, /** multisample*/ false,
3917                  /** resolve*/ false, /** colorRenderable*/ false, /** depthRenderable*/ false);
3918
3919    setFormatCaps(MTLPixelFormatASTC_12x10_LDR, /** filterable*/ display->supportsAppleGPUFamily(2),
3920                  /** writable*/ false, /** blendable*/ false, /** multisample*/ false,
3921                  /** resolve*/ false, /** colorRenderable*/ false, /** depthRenderable*/ false);
3922
3923    setFormatCaps(MTLPixelFormatASTC_12x10_sRGB,
3924                  /** filterable*/ display->supportsAppleGPUFamily(2), /** writable*/ false,
3925                  /** blendable*/ false, /** multisample*/ false, /** resolve*/ false,
3926                  /** colorRenderable*/ false, /** depthRenderable*/ false);
3927
3928    setFormatCaps(MTLPixelFormatASTC_12x12_LDR, /** filterable*/ display->supportsAppleGPUFamily(2),
3929                  /** writable*/ false, /** blendable*/ false, /** multisample*/ false,
3930                  /** resolve*/ false, /** colorRenderable*/ false, /** depthRenderable*/ false);
3931
3932    setFormatCaps(MTLPixelFormatASTC_12x12_sRGB,
3933                  /** filterable*/ display->supportsAppleGPUFamily(2), /** writable*/ false,
3934                  /** blendable*/ false, /** multisample*/ false, /** resolve*/ false,
3935                  /** colorRenderable*/ false, /** depthRenderable*/ false);
3936
3937    setFormatCaps(MTLPixelFormatASTC_4x4_LDR, /** filterable*/ display->supportsAppleGPUFamily(2),
3938                  /** writable*/ false, /** blendable*/ false, /** multisample*/ false,
3939                  /** resolve*/ false, /** colorRenderable*/ false, /** depthRenderable*/ false);
3940
3941    setFormatCaps(MTLPixelFormatASTC_4x4_sRGB, /** filterable*/ display->supportsAppleGPUFamily(2),
3942                  /** writable*/ false, /** blendable*/ false, /** multisample*/ false,
3943                  /** resolve*/ false, /** colorRenderable*/ false, /** depthRenderable*/ false);
3944
3945    setFormatCaps(MTLPixelFormatASTC_5x4_LDR, /** filterable*/ display->supportsAppleGPUFamily(2),
3946                  /** writable*/ false, /** blendable*/ false, /** multisample*/ false,
3947                  /** resolve*/ false, /** colorRenderable*/ false, /** depthRenderable*/ false);
3948
3949    setFormatCaps(MTLPixelFormatASTC_5x4_sRGB, /** filterable*/ display->supportsAppleGPUFamily(2),
3950                  /** writable*/ false, /** blendable*/ false, /** multisample*/ false,
3951                  /** resolve*/ false, /** colorRenderable*/ false, /** depthRenderable*/ false);
3952
3953    setFormatCaps(MTLPixelFormatASTC_5x5_LDR, /** filterable*/ display->supportsAppleGPUFamily(2),
3954                  /** writable*/ false, /** blendable*/ false, /** multisample*/ false,
3955                  /** resolve*/ false, /** colorRenderable*/ false, /** depthRenderable*/ false);
3956
3957    setFormatCaps(MTLPixelFormatASTC_5x5_sRGB, /** filterable*/ display->supportsAppleGPUFamily(2),
3958                  /** writable*/ false, /** blendable*/ false, /** multisample*/ false,
3959                  /** resolve*/ false, /** colorRenderable*/ false, /** depthRenderable*/ false);
3960
3961    setFormatCaps(MTLPixelFormatASTC_6x5_LDR, /** filterable*/ display->supportsAppleGPUFamily(2),
3962                  /** writable*/ false, /** blendable*/ false, /** multisample*/ false,
3963                  /** resolve*/ false, /** colorRenderable*/ false, /** depthRenderable*/ false);
3964
3965    setFormatCaps(MTLPixelFormatASTC_6x5_sRGB, /** filterable*/ display->supportsAppleGPUFamily(2),
3966                  /** writable*/ false, /** blendable*/ false, /** multisample*/ false,
3967                  /** resolve*/ false, /** colorRenderable*/ false, /** depthRenderable*/ false);
3968
3969    setFormatCaps(MTLPixelFormatASTC_6x6_LDR, /** filterable*/ display->supportsAppleGPUFamily(2),
3970                  /** writable*/ false, /** blendable*/ false, /** multisample*/ false,
3971                  /** resolve*/ false, /** colorRenderable*/ false, /** depthRenderable*/ false);
3972
3973    setFormatCaps(MTLPixelFormatASTC_6x6_sRGB, /** filterable*/ display->supportsAppleGPUFamily(2),
3974                  /** writable*/ false, /** blendable*/ false, /** multisample*/ false,
3975                  /** resolve*/ false, /** colorRenderable*/ false, /** depthRenderable*/ false);
3976
3977    setFormatCaps(MTLPixelFormatASTC_8x5_LDR, /** filterable*/ display->supportsAppleGPUFamily(2),
3978                  /** writable*/ false, /** blendable*/ false, /** multisample*/ false,
3979                  /** resolve*/ false, /** colorRenderable*/ false, /** depthRenderable*/ false);
3980
3981    setFormatCaps(MTLPixelFormatASTC_8x5_sRGB, /** filterable*/ display->supportsAppleGPUFamily(2),
3982                  /** writable*/ false, /** blendable*/ false, /** multisample*/ false,
3983                  /** resolve*/ false, /** colorRenderable*/ false, /** depthRenderable*/ false);
3984
3985    setFormatCaps(MTLPixelFormatASTC_8x6_LDR, /** filterable*/ display->supportsAppleGPUFamily(2),
3986                  /** writable*/ false, /** blendable*/ false, /** multisample*/ false,
3987                  /** resolve*/ false, /** colorRenderable*/ false, /** depthRenderable*/ false);
3988
3989    setFormatCaps(MTLPixelFormatASTC_8x6_sRGB, /** filterable*/ display->supportsAppleGPUFamily(2),
3990                  /** writable*/ false, /** blendable*/ false, /** multisample*/ false,
3991                  /** resolve*/ false, /** colorRenderable*/ false, /** depthRenderable*/ false);
3992
3993    setFormatCaps(MTLPixelFormatASTC_8x8_LDR, /** filterable*/ display->supportsAppleGPUFamily(2),
3994                  /** writable*/ false, /** blendable*/ false, /** multisample*/ false,
3995                  /** resolve*/ false, /** colorRenderable*/ false, /** depthRenderable*/ false);
3996
3997    setFormatCaps(MTLPixelFormatASTC_8x8_sRGB, /** filterable*/ display->supportsAppleGPUFamily(2),
3998                  /** writable*/ false, /** blendable*/ false, /** multisample*/ false,
3999                  /** resolve*/ false, /** colorRenderable*/ false, /** depthRenderable*/ false);
4000
4001    setFormatCaps(MTLPixelFormatB5G6R5Unorm, /** filterable*/ display->supportsAppleGPUFamily(1),
4002                  /** writable*/ false, /** blendable*/ display->supportsAppleGPUFamily(1),
4003                  /** multisample*/ display->supportsAppleGPUFamily(1),
4004                  /** resolve*/ display->supportsAppleGPUFamily(1),
4005                  /** colorRenderable*/ display->supportsAppleGPUFamily(1),
4006                  /** depthRenderable*/ false);
4007
4008    setFormatCaps(MTLPixelFormatBGR5A1Unorm, /** filterable*/ display->supportsAppleGPUFamily(1),
4009                  /** writable*/ false, /** blendable*/ display->supportsAppleGPUFamily(1),
4010                  /** multisample*/ display->supportsAppleGPUFamily(1),
4011                  /** resolve*/ display->supportsAppleGPUFamily(1),
4012                  /** colorRenderable*/ display->supportsAppleGPUFamily(1),
4013                  /** depthRenderable*/ false);
4014
4015    setFormatCaps(MTLPixelFormatDepth16Unorm, /** filterable*/ true, /** writable*/ false,
4016                  /** blendable*/ false, /** multisample*/ true,
4017                  /** resolve*/ supportDepthAutoResolve, /** colorRenderable*/ false,
4018                  /** depthRenderable*/ true);
4019
4020    setFormatCaps(MTLPixelFormatEAC_R11Snorm, /** filterable*/ display->supportsAppleGPUFamily(1),
4021                  /** writable*/ false, /** blendable*/ false, /** multisample*/ false,
4022                  /** resolve*/ false, /** colorRenderable*/ false, /** depthRenderable*/ false);
4023
4024    setFormatCaps(MTLPixelFormatEAC_R11Unorm, /** filterable*/ display->supportsAppleGPUFamily(1),
4025                  /** writable*/ false, /** blendable*/ false, /** multisample*/ false,
4026                  /** resolve*/ false, /** colorRenderable*/ false, /** depthRenderable*/ false);
4027
4028    setFormatCaps(MTLPixelFormatEAC_RG11Snorm, /** filterable*/ display->supportsAppleGPUFamily(1),
4029                  /** writable*/ false, /** blendable*/ false, /** multisample*/ false,
4030                  /** resolve*/ false, /** colorRenderable*/ false, /** depthRenderable*/ false);
4031
4032    setFormatCaps(MTLPixelFormatEAC_RG11Unorm, /** filterable*/ display->supportsAppleGPUFamily(1),
4033                  /** writable*/ false, /** blendable*/ false, /** multisample*/ false,
4034                  /** resolve*/ false, /** colorRenderable*/ false, /** depthRenderable*/ false);
4035
4036    setFormatCaps(MTLPixelFormatEAC_RGBA8, /** filterable*/ display->supportsAppleGPUFamily(1),
4037                  /** writable*/ false, /** blendable*/ false, /** multisample*/ false,
4038                  /** resolve*/ false, /** colorRenderable*/ false, /** depthRenderable*/ false);
4039
4040    setFormatCaps(MTLPixelFormatEAC_RGBA8_sRGB, /** filterable*/ display->supportsAppleGPUFamily(1),
4041                  /** writable*/ false, /** blendable*/ false, /** multisample*/ false,
4042                  /** resolve*/ false, /** colorRenderable*/ false, /** depthRenderable*/ false);
4043
4044    setFormatCaps(MTLPixelFormatETC2_RGB8, /** filterable*/ display->supportsAppleGPUFamily(1),
4045                  /** writable*/ false, /** blendable*/ false, /** multisample*/ false,
4046                  /** resolve*/ false, /** colorRenderable*/ false, /** depthRenderable*/ false);
4047
4048    setFormatCaps(MTLPixelFormatETC2_RGB8A1, /** filterable*/ display->supportsAppleGPUFamily(1),
4049                  /** writable*/ false, /** blendable*/ false, /** multisample*/ false,
4050                  /** resolve*/ false, /** colorRenderable*/ false, /** depthRenderable*/ false);
4051
4052    setFormatCaps(MTLPixelFormatETC2_RGB8A1_sRGB,
4053                  /** filterable*/ display->supportsAppleGPUFamily(1), /** writable*/ false,
4054                  /** blendable*/ false, /** multisample*/ false, /** resolve*/ false,
4055                  /** colorRenderable*/ false, /** depthRenderable*/ false);
4056
4057    setFormatCaps(MTLPixelFormatETC2_RGB8_sRGB, /** filterable*/ display->supportsAppleGPUFamily(1),
4058                  /** writable*/ false, /** blendable*/ false, /** multisample*/ false,
4059                  /** resolve*/ false, /** colorRenderable*/ false, /** depthRenderable*/ false);
4060
4061    setFormatCaps(MTLPixelFormatPVRTC_RGBA_2BPP,
4062                  /** filterable*/ display->supportsAppleGPUFamily(1), /** writable*/ false,
4063                  /** blendable*/ false, /** multisample*/ false, /** resolve*/ false,
4064                  /** colorRenderable*/ false, /** depthRenderable*/ false);
4065
4066    setFormatCaps(MTLPixelFormatPVRTC_RGBA_2BPP_sRGB,
4067                  /** filterable*/ display->supportsAppleGPUFamily(1), /** writable*/ false,
4068                  /** blendable*/ false, /** multisample*/ false, /** resolve*/ false,
4069                  /** colorRenderable*/ false, /** depthRenderable*/ false);
4070
4071    setFormatCaps(MTLPixelFormatPVRTC_RGBA_4BPP,
4072                  /** filterable*/ display->supportsAppleGPUFamily(1), /** writable*/ false,
4073                  /** blendable*/ false, /** multisample*/ false, /** resolve*/ false,
4074                  /** colorRenderable*/ false, /** depthRenderable*/ false);
4075
4076    setFormatCaps(MTLPixelFormatPVRTC_RGBA_4BPP_sRGB,
4077                  /** filterable*/ display->supportsAppleGPUFamily(1), /** writable*/ false,
4078                  /** blendable*/ false, /** multisample*/ false, /** resolve*/ false,
4079                  /** colorRenderable*/ false, /** depthRenderable*/ false);
4080
4081    setFormatCaps(MTLPixelFormatPVRTC_RGB_2BPP, /** filterable*/ display->supportsAppleGPUFamily(1),
4082                  /** writable*/ false, /** blendable*/ false, /** multisample*/ false,
4083                  /** resolve*/ false, /** colorRenderable*/ false, /** depthRenderable*/ false);
4084
4085    setFormatCaps(MTLPixelFormatPVRTC_RGB_2BPP_sRGB,
4086                  /** filterable*/ display->supportsAppleGPUFamily(1), /** writable*/ false,
4087                  /** blendable*/ false, /** multisample*/ false, /** resolve*/ false,
4088                  /** colorRenderable*/ false, /** depthRenderable*/ false);
4089
4090    setFormatCaps(MTLPixelFormatPVRTC_RGB_4BPP, /** filterable*/ display->supportsAppleGPUFamily(1),
4091                  /** writable*/ false, /** blendable*/ false, /** multisample*/ false,
4092                  /** resolve*/ false, /** colorRenderable*/ false, /** depthRenderable*/ false);
4093
4094    setFormatCaps(MTLPixelFormatPVRTC_RGB_4BPP_sRGB,
4095                  /** filterable*/ display->supportsAppleGPUFamily(1), /** writable*/ false,
4096                  /** blendable*/ false, /** multisample*/ false, /** resolve*/ false,
4097                  /** colorRenderable*/ false, /** depthRenderable*/ false);
4098
4099    setFormatCaps(MTLPixelFormatR8Unorm_sRGB, /** filterable*/ display->supportsAppleGPUFamily(1),
4100                  /** writable*/ display->supportsAppleGPUFamily(2),
4101                  /** blendable*/ display->supportsAppleGPUFamily(1),
4102                  /** multisample*/ display->supportsAppleGPUFamily(1),
4103                  /** resolve*/ display->supportsAppleGPUFamily(1),
4104                  /** colorRenderable*/ display->supportsAppleGPUFamily(1),
4105                  /** depthRenderable*/ false);
4106
4107    setFormatCaps(MTLPixelFormatRG8Unorm_sRGB, /** filterable*/ display->supportsAppleGPUFamily(1),
4108                  /** writable*/ display->supportsAppleGPUFamily(2),
4109                  /** blendable*/ display->supportsAppleGPUFamily(1),
4110                  /** multisample*/ display->supportsAppleGPUFamily(1),
4111                  /** resolve*/ display->supportsAppleGPUFamily(1),
4112                  /** colorRenderable*/ display->supportsAppleGPUFamily(1),
4113                  /** depthRenderable*/ false);
4114
4115#    if TARGET_OS_IOS || TARGET_OS_OSX
4116    setFormatCaps(MTLPixelFormatASTC_10x10_HDR, /** filterable*/ display->supportsAppleGPUFamily(6),
4117                  /** writable*/ false, /** blendable*/ false, /** multisample*/ false,
4118                  /** resolve*/ false, /** colorRenderable*/ false, /** depthRenderable*/ false);
4119
4120    setFormatCaps(MTLPixelFormatASTC_10x5_HDR, /** filterable*/ display->supportsAppleGPUFamily(6),
4121                  /** writable*/ false, /** blendable*/ false, /** multisample*/ false,
4122                  /** resolve*/ false, /** colorRenderable*/ false, /** depthRenderable*/ false);
4123
4124    setFormatCaps(MTLPixelFormatASTC_10x6_HDR, /** filterable*/ display->supportsAppleGPUFamily(6),
4125                  /** writable*/ false, /** blendable*/ false, /** multisample*/ false,
4126                  /** resolve*/ false, /** colorRenderable*/ false, /** depthRenderable*/ false);
4127
4128    setFormatCaps(MTLPixelFormatASTC_10x8_HDR, /** filterable*/ display->supportsAppleGPUFamily(6),
4129                  /** writable*/ false, /** blendable*/ false, /** multisample*/ false,
4130                  /** resolve*/ false, /** colorRenderable*/ false, /** depthRenderable*/ false);
4131
4132    setFormatCaps(MTLPixelFormatASTC_12x10_HDR, /** filterable*/ display->supportsAppleGPUFamily(6),
4133                  /** writable*/ false, /** blendable*/ false, /** multisample*/ false,
4134                  /** resolve*/ false, /** colorRenderable*/ false, /** depthRenderable*/ false);
4135
4136    setFormatCaps(MTLPixelFormatASTC_12x12_HDR, /** filterable*/ display->supportsAppleGPUFamily(6),
4137                  /** writable*/ false, /** blendable*/ false, /** multisample*/ false,
4138                  /** resolve*/ false, /** colorRenderable*/ false, /** depthRenderable*/ false);
4139
4140    setFormatCaps(MTLPixelFormatASTC_4x4_HDR, /** filterable*/ display->supportsAppleGPUFamily(6),
4141                  /** writable*/ false, /** blendable*/ false, /** multisample*/ false,
4142                  /** resolve*/ false, /** colorRenderable*/ false, /** depthRenderable*/ false);
4143
4144    setFormatCaps(MTLPixelFormatASTC_5x4_HDR, /** filterable*/ display->supportsAppleGPUFamily(6),
4145                  /** writable*/ false, /** blendable*/ false, /** multisample*/ false,
4146                  /** resolve*/ false, /** colorRenderable*/ false, /** depthRenderable*/ false);
4147
4148    setFormatCaps(MTLPixelFormatASTC_5x5_HDR, /** filterable*/ display->supportsAppleGPUFamily(6),
4149                  /** writable*/ false, /** blendable*/ false, /** multisample*/ false,
4150                  /** resolve*/ false, /** colorRenderable*/ false, /** depthRenderable*/ false);
4151
4152    setFormatCaps(MTLPixelFormatASTC_6x5_HDR, /** filterable*/ display->supportsAppleGPUFamily(6),
4153                  /** writable*/ false, /** blendable*/ false, /** multisample*/ false,
4154                  /** resolve*/ false, /** colorRenderable*/ false, /** depthRenderable*/ false);
4155
4156    setFormatCaps(MTLPixelFormatASTC_6x6_HDR, /** filterable*/ display->supportsAppleGPUFamily(6),
4157                  /** writable*/ false, /** blendable*/ false, /** multisample*/ false,
4158                  /** resolve*/ false, /** colorRenderable*/ false, /** depthRenderable*/ false);
4159
4160    setFormatCaps(MTLPixelFormatASTC_8x5_HDR, /** filterable*/ display->supportsAppleGPUFamily(6),
4161                  /** writable*/ false, /** blendable*/ false, /** multisample*/ false,
4162                  /** resolve*/ false, /** colorRenderable*/ false, /** depthRenderable*/ false);
4163
4164    setFormatCaps(MTLPixelFormatASTC_8x6_HDR, /** filterable*/ display->supportsAppleGPUFamily(6),
4165                  /** writable*/ false, /** blendable*/ false, /** multisample*/ false,
4166                  /** resolve*/ false, /** colorRenderable*/ false, /** depthRenderable*/ false);
4167
4168    setFormatCaps(MTLPixelFormatASTC_8x8_HDR, /** filterable*/ display->supportsAppleGPUFamily(6),
4169                  /** writable*/ false, /** blendable*/ false, /** multisample*/ false,
4170                  /** resolve*/ false, /** colorRenderable*/ false, /** depthRenderable*/ false);
4171
4172#    endif  // TARGET_OS_IOS || mac 11.0+
4173#endif      // TARGET_OS_IPHONE && !TARGET_OS_MACCATALYST || mac 11.0+
4174}
4175
4176}  // namespace mtl
4177}  // namespace rx
4178