xref: /aosp_15_r20/external/angle/src/libANGLE/renderer/wgpu/wgpu_format_table_autogen.cpp (revision 8975f5c5ed3d1c378011245431ada316dfb6f244)
1 // GENERATED FILE - DO NOT EDIT.
2 // Generated by gen_wgpu_format_table.py using data from wgpu_format_map.json
3 //
4 // Copyright 2024 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 // wgpu_format_table_autogen.cpp:
9 //   Queries for full WebGPU format information based on GL format.
10 
11 #include "libANGLE/renderer/wgpu/wgpu_format_utils.h"
12 
13 #include "image_util/loadimage.h"
14 
15 using namespace angle;
16 
17 namespace rx
18 {
19 namespace webgpu
20 {
21 
initialize(const angle::Format & angleFormat)22 void Format::initialize(const angle::Format &angleFormat)
23 {
24     switch (angleFormat.id)
25     {
26         case angle::FormatID::A16_FLOAT:
27             mIntendedGLFormat         = GL_ALPHA16F_EXT;
28             mActualImageFormatID      = angle::FormatID::R16_FLOAT;
29             mImageInitializerFunction = nullptr;
30             mIsRenderable             = true;
31 
32             break;
33 
34         case angle::FormatID::A1R5G5B5_UNORM:
35             // This format is not implemented in WebGPU.
36             break;
37 
38         case angle::FormatID::A2R10G10B10_SINT_VERTEX:
39             mIntendedGLFormat             = GL_INT_10_10_10_2_OES;
40             mActualImageFormatID          = angle::FormatID::NONE;
41             mImageInitializerFunction     = nullptr;
42             mIsRenderable                 = true;
43             mActualBufferFormatID         = angle::FormatID::R16G16B16A16_SINT;
44             mVertexLoadFunction           = CopyW2XYZ10ToXYZWFloatVertexData<true, false, true>;
45             mVertexLoadRequiresConversion = true;
46             break;
47 
48         case angle::FormatID::A2R10G10B10_SNORM_VERTEX:
49             mIntendedGLFormat             = GL_A2_RGB10_SNORM_ANGLEX;
50             mActualImageFormatID          = angle::FormatID::NONE;
51             mImageInitializerFunction     = nullptr;
52             mIsRenderable                 = false;
53             mActualBufferFormatID         = angle::FormatID::R16G16B16A16_SNORM;
54             mVertexLoadFunction           = CopyW2XYZ10ToXYZWFloatVertexData<true, true, true>;
55             mVertexLoadRequiresConversion = true;
56             break;
57 
58         case angle::FormatID::A2R10G10B10_SSCALED_VERTEX:
59             mIntendedGLFormat             = GL_A2_RGB10_SSCALED_ANGLEX;
60             mActualImageFormatID          = angle::FormatID::NONE;
61             mImageInitializerFunction     = nullptr;
62             mIsRenderable                 = true;
63             mActualBufferFormatID         = angle::FormatID::R16G16B16A16_FLOAT;
64             mVertexLoadFunction           = CopyW2XYZ10ToXYZWFloatVertexData<true, false, true>;
65             mVertexLoadRequiresConversion = true;
66             break;
67 
68         case angle::FormatID::A2R10G10B10_UINT_VERTEX:
69             mIntendedGLFormat             = GL_UNSIGNED_INT_10_10_10_2_OES;
70             mActualImageFormatID          = angle::FormatID::NONE;
71             mImageInitializerFunction     = nullptr;
72             mIsRenderable                 = true;
73             mActualBufferFormatID         = angle::FormatID::R16G16B16A16_UINT;
74             mVertexLoadFunction           = CopyW2XYZ10ToXYZWFloatVertexData<false, false, true>;
75             mVertexLoadRequiresConversion = true;
76             break;
77 
78         case angle::FormatID::A2R10G10B10_UNORM_VERTEX:
79             mIntendedGLFormat             = GL_A2_RGB10_UNORM_ANGLEX;
80             mActualImageFormatID          = angle::FormatID::NONE;
81             mImageInitializerFunction     = nullptr;
82             mIsRenderable                 = true;
83             mActualBufferFormatID         = angle::FormatID::R16G16B16A16_FLOAT;
84             mVertexLoadFunction           = CopyW2XYZ10ToXYZWFloatVertexData<false, true, true>;
85             mVertexLoadRequiresConversion = true;
86             break;
87 
88         case angle::FormatID::A2R10G10B10_USCALED_VERTEX:
89             mIntendedGLFormat             = GL_A2_RGB10_USCALED_ANGLEX;
90             mActualImageFormatID          = angle::FormatID::NONE;
91             mImageInitializerFunction     = nullptr;
92             mIsRenderable                 = true;
93             mActualBufferFormatID         = angle::FormatID::R16G16B16A16_FLOAT;
94             mVertexLoadFunction           = CopyW2XYZ10ToXYZWFloatVertexData<false, false, true>;
95             mVertexLoadRequiresConversion = true;
96             break;
97 
98         case angle::FormatID::A32_FLOAT:
99             mIntendedGLFormat         = GL_ALPHA32F_EXT;
100             mActualImageFormatID      = angle::FormatID::R32_FLOAT;
101             mImageInitializerFunction = nullptr;
102             mIsRenderable             = true;
103 
104             break;
105 
106         case angle::FormatID::A8_UNORM:
107             mIntendedGLFormat         = GL_ALPHA8_EXT;
108             mActualImageFormatID      = angle::FormatID::R8_UNORM;
109             mImageInitializerFunction = nullptr;
110             mIsRenderable             = true;
111 
112             break;
113 
114         case angle::FormatID::ASTC_10x10_SRGB_BLOCK:
115             mIntendedGLFormat = GL_COMPRESSED_SRGB8_ALPHA8_ASTC_10x10_KHR;
116             {
117                 static constexpr ImageFormatInitInfo kInfo[] = {
118                     {angle::FormatID::ASTC_10x10_SRGB_BLOCK, nullptr},
119                     {angle::FormatID::R8G8B8A8_UNORM_SRGB, nullptr}};
120                 initImageFallback(kInfo, ArraySize(kInfo));
121             }
122 
123             break;
124 
125         case angle::FormatID::ASTC_10x10_UNORM_BLOCK:
126             mIntendedGLFormat = GL_COMPRESSED_RGBA_ASTC_10x10_KHR;
127             {
128                 static constexpr ImageFormatInitInfo kInfo[] = {
129                     {angle::FormatID::ASTC_10x10_UNORM_BLOCK, nullptr},
130                     {angle::FormatID::R8G8B8A8_UNORM, nullptr}};
131                 initImageFallback(kInfo, ArraySize(kInfo));
132             }
133 
134             break;
135 
136         case angle::FormatID::ASTC_10x5_SRGB_BLOCK:
137             mIntendedGLFormat = GL_COMPRESSED_SRGB8_ALPHA8_ASTC_10x5_KHR;
138             {
139                 static constexpr ImageFormatInitInfo kInfo[] = {
140                     {angle::FormatID::ASTC_10x5_SRGB_BLOCK, nullptr},
141                     {angle::FormatID::R8G8B8A8_UNORM_SRGB, nullptr}};
142                 initImageFallback(kInfo, ArraySize(kInfo));
143             }
144 
145             break;
146 
147         case angle::FormatID::ASTC_10x5_UNORM_BLOCK:
148             mIntendedGLFormat = GL_COMPRESSED_RGBA_ASTC_10x5_KHR;
149             {
150                 static constexpr ImageFormatInitInfo kInfo[] = {
151                     {angle::FormatID::ASTC_10x5_UNORM_BLOCK, nullptr},
152                     {angle::FormatID::R8G8B8A8_UNORM, nullptr}};
153                 initImageFallback(kInfo, ArraySize(kInfo));
154             }
155 
156             break;
157 
158         case angle::FormatID::ASTC_10x6_SRGB_BLOCK:
159             mIntendedGLFormat = GL_COMPRESSED_SRGB8_ALPHA8_ASTC_10x6_KHR;
160             {
161                 static constexpr ImageFormatInitInfo kInfo[] = {
162                     {angle::FormatID::ASTC_10x6_SRGB_BLOCK, nullptr},
163                     {angle::FormatID::R8G8B8A8_UNORM_SRGB, nullptr}};
164                 initImageFallback(kInfo, ArraySize(kInfo));
165             }
166 
167             break;
168 
169         case angle::FormatID::ASTC_10x6_UNORM_BLOCK:
170             mIntendedGLFormat = GL_COMPRESSED_RGBA_ASTC_10x6_KHR;
171             {
172                 static constexpr ImageFormatInitInfo kInfo[] = {
173                     {angle::FormatID::ASTC_10x6_UNORM_BLOCK, nullptr},
174                     {angle::FormatID::R8G8B8A8_UNORM, nullptr}};
175                 initImageFallback(kInfo, ArraySize(kInfo));
176             }
177 
178             break;
179 
180         case angle::FormatID::ASTC_10x8_SRGB_BLOCK:
181             mIntendedGLFormat = GL_COMPRESSED_SRGB8_ALPHA8_ASTC_10x8_KHR;
182             {
183                 static constexpr ImageFormatInitInfo kInfo[] = {
184                     {angle::FormatID::ASTC_10x8_SRGB_BLOCK, nullptr},
185                     {angle::FormatID::R8G8B8A8_UNORM_SRGB, nullptr}};
186                 initImageFallback(kInfo, ArraySize(kInfo));
187             }
188 
189             break;
190 
191         case angle::FormatID::ASTC_10x8_UNORM_BLOCK:
192             mIntendedGLFormat = GL_COMPRESSED_RGBA_ASTC_10x8_KHR;
193             {
194                 static constexpr ImageFormatInitInfo kInfo[] = {
195                     {angle::FormatID::ASTC_10x8_UNORM_BLOCK, nullptr},
196                     {angle::FormatID::R8G8B8A8_UNORM, nullptr}};
197                 initImageFallback(kInfo, ArraySize(kInfo));
198             }
199 
200             break;
201 
202         case angle::FormatID::ASTC_12x10_SRGB_BLOCK:
203             mIntendedGLFormat = GL_COMPRESSED_SRGB8_ALPHA8_ASTC_12x10_KHR;
204             {
205                 static constexpr ImageFormatInitInfo kInfo[] = {
206                     {angle::FormatID::ASTC_12x10_SRGB_BLOCK, nullptr},
207                     {angle::FormatID::R8G8B8A8_UNORM_SRGB, nullptr}};
208                 initImageFallback(kInfo, ArraySize(kInfo));
209             }
210 
211             break;
212 
213         case angle::FormatID::ASTC_12x10_UNORM_BLOCK:
214             mIntendedGLFormat = GL_COMPRESSED_RGBA_ASTC_12x10_KHR;
215             {
216                 static constexpr ImageFormatInitInfo kInfo[] = {
217                     {angle::FormatID::ASTC_12x10_UNORM_BLOCK, nullptr},
218                     {angle::FormatID::R8G8B8A8_UNORM, nullptr}};
219                 initImageFallback(kInfo, ArraySize(kInfo));
220             }
221 
222             break;
223 
224         case angle::FormatID::ASTC_12x12_SRGB_BLOCK:
225             mIntendedGLFormat = GL_COMPRESSED_SRGB8_ALPHA8_ASTC_12x12_KHR;
226             {
227                 static constexpr ImageFormatInitInfo kInfo[] = {
228                     {angle::FormatID::ASTC_12x12_SRGB_BLOCK, nullptr},
229                     {angle::FormatID::R8G8B8A8_UNORM_SRGB, nullptr}};
230                 initImageFallback(kInfo, ArraySize(kInfo));
231             }
232 
233             break;
234 
235         case angle::FormatID::ASTC_12x12_UNORM_BLOCK:
236             mIntendedGLFormat = GL_COMPRESSED_RGBA_ASTC_12x12_KHR;
237             {
238                 static constexpr ImageFormatInitInfo kInfo[] = {
239                     {angle::FormatID::ASTC_12x12_UNORM_BLOCK, nullptr},
240                     {angle::FormatID::R8G8B8A8_UNORM, nullptr}};
241                 initImageFallback(kInfo, ArraySize(kInfo));
242             }
243 
244             break;
245 
246         case angle::FormatID::ASTC_3x3x3_UNORM_BLOCK:
247             // This format is not implemented in WebGPU.
248             break;
249 
250         case angle::FormatID::ASTC_3x3x3_UNORM_SRGB_BLOCK:
251             // This format is not implemented in WebGPU.
252             break;
253 
254         case angle::FormatID::ASTC_4x3x3_UNORM_BLOCK:
255             // This format is not implemented in WebGPU.
256             break;
257 
258         case angle::FormatID::ASTC_4x3x3_UNORM_SRGB_BLOCK:
259             // This format is not implemented in WebGPU.
260             break;
261 
262         case angle::FormatID::ASTC_4x4_SRGB_BLOCK:
263             mIntendedGLFormat = GL_COMPRESSED_SRGB8_ALPHA8_ASTC_4x4_KHR;
264             {
265                 static constexpr ImageFormatInitInfo kInfo[] = {
266                     {angle::FormatID::ASTC_4x4_SRGB_BLOCK, nullptr},
267                     {angle::FormatID::R8G8B8A8_UNORM_SRGB, nullptr}};
268                 initImageFallback(kInfo, ArraySize(kInfo));
269             }
270 
271             break;
272 
273         case angle::FormatID::ASTC_4x4_UNORM_BLOCK:
274             mIntendedGLFormat = GL_COMPRESSED_RGBA_ASTC_4x4_KHR;
275             {
276                 static constexpr ImageFormatInitInfo kInfo[] = {
277                     {angle::FormatID::ASTC_4x4_UNORM_BLOCK, nullptr},
278                     {angle::FormatID::R8G8B8A8_UNORM, nullptr}};
279                 initImageFallback(kInfo, ArraySize(kInfo));
280             }
281 
282             break;
283 
284         case angle::FormatID::ASTC_4x4x3_UNORM_BLOCK:
285             // This format is not implemented in WebGPU.
286             break;
287 
288         case angle::FormatID::ASTC_4x4x3_UNORM_SRGB_BLOCK:
289             // This format is not implemented in WebGPU.
290             break;
291 
292         case angle::FormatID::ASTC_4x4x4_UNORM_BLOCK:
293             // This format is not implemented in WebGPU.
294             break;
295 
296         case angle::FormatID::ASTC_4x4x4_UNORM_SRGB_BLOCK:
297             // This format is not implemented in WebGPU.
298             break;
299 
300         case angle::FormatID::ASTC_5x4_SRGB_BLOCK:
301             mIntendedGLFormat = GL_COMPRESSED_SRGB8_ALPHA8_ASTC_5x4_KHR;
302             {
303                 static constexpr ImageFormatInitInfo kInfo[] = {
304                     {angle::FormatID::ASTC_5x4_SRGB_BLOCK, nullptr},
305                     {angle::FormatID::R8G8B8A8_UNORM_SRGB, nullptr}};
306                 initImageFallback(kInfo, ArraySize(kInfo));
307             }
308 
309             break;
310 
311         case angle::FormatID::ASTC_5x4_UNORM_BLOCK:
312             mIntendedGLFormat = GL_COMPRESSED_RGBA_ASTC_5x4_KHR;
313             {
314                 static constexpr ImageFormatInitInfo kInfo[] = {
315                     {angle::FormatID::ASTC_5x4_UNORM_BLOCK, nullptr},
316                     {angle::FormatID::R8G8B8A8_UNORM, nullptr}};
317                 initImageFallback(kInfo, ArraySize(kInfo));
318             }
319 
320             break;
321 
322         case angle::FormatID::ASTC_5x4x4_UNORM_BLOCK:
323             // This format is not implemented in WebGPU.
324             break;
325 
326         case angle::FormatID::ASTC_5x4x4_UNORM_SRGB_BLOCK:
327             // This format is not implemented in WebGPU.
328             break;
329 
330         case angle::FormatID::ASTC_5x5_SRGB_BLOCK:
331             mIntendedGLFormat = GL_COMPRESSED_SRGB8_ALPHA8_ASTC_5x5_KHR;
332             {
333                 static constexpr ImageFormatInitInfo kInfo[] = {
334                     {angle::FormatID::ASTC_5x5_SRGB_BLOCK, nullptr},
335                     {angle::FormatID::R8G8B8A8_UNORM_SRGB, nullptr}};
336                 initImageFallback(kInfo, ArraySize(kInfo));
337             }
338 
339             break;
340 
341         case angle::FormatID::ASTC_5x5_UNORM_BLOCK:
342             mIntendedGLFormat = GL_COMPRESSED_RGBA_ASTC_5x5_KHR;
343             {
344                 static constexpr ImageFormatInitInfo kInfo[] = {
345                     {angle::FormatID::ASTC_5x5_UNORM_BLOCK, nullptr},
346                     {angle::FormatID::R8G8B8A8_UNORM, nullptr}};
347                 initImageFallback(kInfo, ArraySize(kInfo));
348             }
349 
350             break;
351 
352         case angle::FormatID::ASTC_5x5x4_UNORM_BLOCK:
353             // This format is not implemented in WebGPU.
354             break;
355 
356         case angle::FormatID::ASTC_5x5x4_UNORM_SRGB_BLOCK:
357             // This format is not implemented in WebGPU.
358             break;
359 
360         case angle::FormatID::ASTC_5x5x5_UNORM_BLOCK:
361             // This format is not implemented in WebGPU.
362             break;
363 
364         case angle::FormatID::ASTC_5x5x5_UNORM_SRGB_BLOCK:
365             // This format is not implemented in WebGPU.
366             break;
367 
368         case angle::FormatID::ASTC_6x5_SRGB_BLOCK:
369             mIntendedGLFormat = GL_COMPRESSED_SRGB8_ALPHA8_ASTC_6x5_KHR;
370             {
371                 static constexpr ImageFormatInitInfo kInfo[] = {
372                     {angle::FormatID::ASTC_6x5_SRGB_BLOCK, nullptr},
373                     {angle::FormatID::R8G8B8A8_UNORM_SRGB, nullptr}};
374                 initImageFallback(kInfo, ArraySize(kInfo));
375             }
376 
377             break;
378 
379         case angle::FormatID::ASTC_6x5_UNORM_BLOCK:
380             mIntendedGLFormat = GL_COMPRESSED_RGBA_ASTC_6x5_KHR;
381             {
382                 static constexpr ImageFormatInitInfo kInfo[] = {
383                     {angle::FormatID::ASTC_6x5_UNORM_BLOCK, nullptr},
384                     {angle::FormatID::R8G8B8A8_UNORM, nullptr}};
385                 initImageFallback(kInfo, ArraySize(kInfo));
386             }
387 
388             break;
389 
390         case angle::FormatID::ASTC_6x5x5_UNORM_BLOCK:
391             // This format is not implemented in WebGPU.
392             break;
393 
394         case angle::FormatID::ASTC_6x5x5_UNORM_SRGB_BLOCK:
395             // This format is not implemented in WebGPU.
396             break;
397 
398         case angle::FormatID::ASTC_6x6_SRGB_BLOCK:
399             mIntendedGLFormat = GL_COMPRESSED_SRGB8_ALPHA8_ASTC_6x6_KHR;
400             {
401                 static constexpr ImageFormatInitInfo kInfo[] = {
402                     {angle::FormatID::ASTC_6x6_SRGB_BLOCK, nullptr},
403                     {angle::FormatID::R8G8B8A8_UNORM_SRGB, nullptr}};
404                 initImageFallback(kInfo, ArraySize(kInfo));
405             }
406 
407             break;
408 
409         case angle::FormatID::ASTC_6x6_UNORM_BLOCK:
410             mIntendedGLFormat = GL_COMPRESSED_RGBA_ASTC_6x6_KHR;
411             {
412                 static constexpr ImageFormatInitInfo kInfo[] = {
413                     {angle::FormatID::ASTC_6x6_UNORM_BLOCK, nullptr},
414                     {angle::FormatID::R8G8B8A8_UNORM, nullptr}};
415                 initImageFallback(kInfo, ArraySize(kInfo));
416             }
417 
418             break;
419 
420         case angle::FormatID::ASTC_6x6x5_UNORM_BLOCK:
421             // This format is not implemented in WebGPU.
422             break;
423 
424         case angle::FormatID::ASTC_6x6x5_UNORM_SRGB_BLOCK:
425             // This format is not implemented in WebGPU.
426             break;
427 
428         case angle::FormatID::ASTC_6x6x6_UNORM_BLOCK:
429             // This format is not implemented in WebGPU.
430             break;
431 
432         case angle::FormatID::ASTC_6x6x6_UNORM_SRGB_BLOCK:
433             // This format is not implemented in WebGPU.
434             break;
435 
436         case angle::FormatID::ASTC_8x5_SRGB_BLOCK:
437             mIntendedGLFormat = GL_COMPRESSED_SRGB8_ALPHA8_ASTC_8x5_KHR;
438             {
439                 static constexpr ImageFormatInitInfo kInfo[] = {
440                     {angle::FormatID::ASTC_8x5_SRGB_BLOCK, nullptr},
441                     {angle::FormatID::R8G8B8A8_UNORM_SRGB, nullptr}};
442                 initImageFallback(kInfo, ArraySize(kInfo));
443             }
444 
445             break;
446 
447         case angle::FormatID::ASTC_8x5_UNORM_BLOCK:
448             mIntendedGLFormat = GL_COMPRESSED_RGBA_ASTC_8x5_KHR;
449             {
450                 static constexpr ImageFormatInitInfo kInfo[] = {
451                     {angle::FormatID::ASTC_8x5_UNORM_BLOCK, nullptr},
452                     {angle::FormatID::R8G8B8A8_UNORM, nullptr}};
453                 initImageFallback(kInfo, ArraySize(kInfo));
454             }
455 
456             break;
457 
458         case angle::FormatID::ASTC_8x6_SRGB_BLOCK:
459             mIntendedGLFormat = GL_COMPRESSED_SRGB8_ALPHA8_ASTC_8x6_KHR;
460             {
461                 static constexpr ImageFormatInitInfo kInfo[] = {
462                     {angle::FormatID::ASTC_8x6_SRGB_BLOCK, nullptr},
463                     {angle::FormatID::R8G8B8A8_UNORM_SRGB, nullptr}};
464                 initImageFallback(kInfo, ArraySize(kInfo));
465             }
466 
467             break;
468 
469         case angle::FormatID::ASTC_8x6_UNORM_BLOCK:
470             mIntendedGLFormat = GL_COMPRESSED_RGBA_ASTC_8x6_KHR;
471             {
472                 static constexpr ImageFormatInitInfo kInfo[] = {
473                     {angle::FormatID::ASTC_8x6_UNORM_BLOCK, nullptr},
474                     {angle::FormatID::R8G8B8A8_UNORM, nullptr}};
475                 initImageFallback(kInfo, ArraySize(kInfo));
476             }
477 
478             break;
479 
480         case angle::FormatID::ASTC_8x8_SRGB_BLOCK:
481             mIntendedGLFormat = GL_COMPRESSED_SRGB8_ALPHA8_ASTC_8x8_KHR;
482             {
483                 static constexpr ImageFormatInitInfo kInfo[] = {
484                     {angle::FormatID::ASTC_8x8_SRGB_BLOCK, nullptr},
485                     {angle::FormatID::R8G8B8A8_UNORM_SRGB, nullptr}};
486                 initImageFallback(kInfo, ArraySize(kInfo));
487             }
488 
489             break;
490 
491         case angle::FormatID::ASTC_8x8_UNORM_BLOCK:
492             mIntendedGLFormat = GL_COMPRESSED_RGBA_ASTC_8x8_KHR;
493             {
494                 static constexpr ImageFormatInitInfo kInfo[] = {
495                     {angle::FormatID::ASTC_8x8_UNORM_BLOCK, nullptr},
496                     {angle::FormatID::R8G8B8A8_UNORM, nullptr}};
497                 initImageFallback(kInfo, ArraySize(kInfo));
498             }
499 
500             break;
501 
502         case angle::FormatID::B10G10R10A2_UNORM:
503             mIntendedGLFormat         = GL_BGR10_A2_ANGLEX;
504             mActualImageFormatID      = angle::FormatID::R10G10B10A2_UNORM;
505             mImageInitializerFunction = nullptr;
506             mIsRenderable             = true;
507 
508             break;
509 
510         case angle::FormatID::B4G4R4A4_UNORM:
511             mIntendedGLFormat         = GL_BGRA4_ANGLEX;
512             mActualImageFormatID      = angle::FormatID::R8G8B8A8_UNORM;
513             mImageInitializerFunction = nullptr;
514             mIsRenderable             = true;
515 
516             break;
517 
518         case angle::FormatID::B5G5R5A1_UNORM:
519             mIntendedGLFormat         = GL_BGR5_A1_ANGLEX;
520             mActualImageFormatID      = angle::FormatID::R8G8B8A8_UNORM;
521             mImageInitializerFunction = nullptr;
522             mIsRenderable             = true;
523 
524             break;
525 
526         case angle::FormatID::B5G6R5_UNORM:
527             mIntendedGLFormat         = GL_BGR565_ANGLEX;
528             mActualImageFormatID      = angle::FormatID::R8G8B8A8_UNORM;
529             mImageInitializerFunction = nullptr;
530             mIsRenderable             = true;
531 
532             break;
533 
534         case angle::FormatID::B8G8R8A8_TYPELESS:
535             // This format is not implemented in WebGPU.
536             break;
537 
538         case angle::FormatID::B8G8R8A8_TYPELESS_SRGB:
539             // This format is not implemented in WebGPU.
540             break;
541 
542         case angle::FormatID::B8G8R8A8_UNORM:
543             mIntendedGLFormat         = GL_BGRA8_EXT;
544             mActualImageFormatID      = angle::FormatID::B8G8R8A8_UNORM;
545             mImageInitializerFunction = nullptr;
546             mIsRenderable             = true;
547 
548             break;
549 
550         case angle::FormatID::B8G8R8A8_UNORM_SRGB:
551             mIntendedGLFormat = GL_BGRA8_SRGB_ANGLEX;
552             {
553                 static constexpr ImageFormatInitInfo kInfo[] = {
554                     {angle::FormatID::B8G8R8A8_UNORM_SRGB, nullptr},
555                     {angle::FormatID::R8G8B8A8_UNORM_SRGB, nullptr}};
556                 initImageFallback(kInfo, ArraySize(kInfo));
557             }
558 
559             break;
560 
561         case angle::FormatID::B8G8R8X8_UNORM:
562             mIntendedGLFormat             = GL_BGRX8_ANGLEX;
563             mActualImageFormatID          = angle::FormatID::B8G8R8A8_UNORM;
564             mImageInitializerFunction     = nullptr;
565             mIsRenderable                 = true;
566             mActualBufferFormatID         = angle::FormatID::NONE;
567             mVertexLoadFunction           = nullptr;
568             mVertexLoadRequiresConversion = true;
569             break;
570 
571         case angle::FormatID::B8G8R8X8_UNORM_SRGB:
572             // This format is not implemented in WebGPU.
573             break;
574 
575         case angle::FormatID::BC1_RGBA_UNORM_BLOCK:
576             mIntendedGLFormat         = GL_COMPRESSED_RGBA_S3TC_DXT1_EXT;
577             mActualImageFormatID      = angle::FormatID::BC1_RGBA_UNORM_BLOCK;
578             mImageInitializerFunction = nullptr;
579             mIsRenderable             = true;
580 
581             break;
582 
583         case angle::FormatID::BC1_RGBA_UNORM_SRGB_BLOCK:
584             mIntendedGLFormat         = GL_COMPRESSED_SRGB_ALPHA_S3TC_DXT1_EXT;
585             mActualImageFormatID      = angle::FormatID::BC1_RGBA_UNORM_SRGB_BLOCK;
586             mImageInitializerFunction = nullptr;
587             mIsRenderable             = true;
588 
589             break;
590 
591         case angle::FormatID::BC1_RGB_UNORM_BLOCK:
592             // This format is not implemented in WebGPU.
593             break;
594 
595         case angle::FormatID::BC1_RGB_UNORM_SRGB_BLOCK:
596             // This format is not implemented in WebGPU.
597             break;
598 
599         case angle::FormatID::BC2_RGBA_UNORM_BLOCK:
600             mIntendedGLFormat         = GL_COMPRESSED_RGBA_S3TC_DXT3_ANGLE;
601             mActualImageFormatID      = angle::FormatID::BC2_RGBA_UNORM_BLOCK;
602             mImageInitializerFunction = nullptr;
603             mIsRenderable             = true;
604 
605             break;
606 
607         case angle::FormatID::BC2_RGBA_UNORM_SRGB_BLOCK:
608             mIntendedGLFormat         = GL_COMPRESSED_SRGB_ALPHA_S3TC_DXT3_EXT;
609             mActualImageFormatID      = angle::FormatID::BC2_RGBA_UNORM_SRGB_BLOCK;
610             mImageInitializerFunction = nullptr;
611             mIsRenderable             = true;
612 
613             break;
614 
615         case angle::FormatID::BC3_RGBA_UNORM_BLOCK:
616             mIntendedGLFormat         = GL_COMPRESSED_RGBA_S3TC_DXT5_ANGLE;
617             mActualImageFormatID      = angle::FormatID::BC3_RGBA_UNORM_BLOCK;
618             mImageInitializerFunction = nullptr;
619             mIsRenderable             = true;
620 
621             break;
622 
623         case angle::FormatID::BC3_RGBA_UNORM_SRGB_BLOCK:
624             mIntendedGLFormat         = GL_COMPRESSED_SRGB_ALPHA_S3TC_DXT5_EXT;
625             mActualImageFormatID      = angle::FormatID::BC3_RGBA_UNORM_SRGB_BLOCK;
626             mImageInitializerFunction = nullptr;
627             mIsRenderable             = true;
628 
629             break;
630 
631         case angle::FormatID::BC4_RED_SNORM_BLOCK:
632             mIntendedGLFormat         = GL_COMPRESSED_SIGNED_RED_RGTC1_EXT;
633             mActualImageFormatID      = angle::FormatID::BC4_RED_SNORM_BLOCK;
634             mImageInitializerFunction = nullptr;
635             mIsRenderable             = false;
636 
637             break;
638 
639         case angle::FormatID::BC4_RED_UNORM_BLOCK:
640             mIntendedGLFormat         = GL_COMPRESSED_RED_RGTC1_EXT;
641             mActualImageFormatID      = angle::FormatID::BC4_RED_UNORM_BLOCK;
642             mImageInitializerFunction = nullptr;
643             mIsRenderable             = true;
644 
645             break;
646 
647         case angle::FormatID::BC5_RG_SNORM_BLOCK:
648             mIntendedGLFormat         = GL_COMPRESSED_SIGNED_RED_GREEN_RGTC2_EXT;
649             mActualImageFormatID      = angle::FormatID::BC5_RG_SNORM_BLOCK;
650             mImageInitializerFunction = nullptr;
651             mIsRenderable             = false;
652 
653             break;
654 
655         case angle::FormatID::BC5_RG_UNORM_BLOCK:
656             mIntendedGLFormat         = GL_COMPRESSED_RED_GREEN_RGTC2_EXT;
657             mActualImageFormatID      = angle::FormatID::BC5_RG_UNORM_BLOCK;
658             mImageInitializerFunction = nullptr;
659             mIsRenderable             = true;
660 
661             break;
662 
663         case angle::FormatID::BC6H_RGB_SFLOAT_BLOCK:
664             mIntendedGLFormat         = GL_COMPRESSED_RGB_BPTC_SIGNED_FLOAT_EXT;
665             mActualImageFormatID      = angle::FormatID::BC6H_RGB_SFLOAT_BLOCK;
666             mImageInitializerFunction = nullptr;
667             mIsRenderable             = true;
668 
669             break;
670 
671         case angle::FormatID::BC6H_RGB_UFLOAT_BLOCK:
672             mIntendedGLFormat         = GL_COMPRESSED_RGB_BPTC_UNSIGNED_FLOAT_EXT;
673             mActualImageFormatID      = angle::FormatID::BC6H_RGB_UFLOAT_BLOCK;
674             mImageInitializerFunction = nullptr;
675             mIsRenderable             = true;
676 
677             break;
678 
679         case angle::FormatID::BC7_RGBA_UNORM_BLOCK:
680             mIntendedGLFormat         = GL_COMPRESSED_RGBA_BPTC_UNORM_EXT;
681             mActualImageFormatID      = angle::FormatID::BC7_RGBA_UNORM_BLOCK;
682             mImageInitializerFunction = nullptr;
683             mIsRenderable             = true;
684 
685             break;
686 
687         case angle::FormatID::BC7_RGBA_UNORM_SRGB_BLOCK:
688             mIntendedGLFormat         = GL_COMPRESSED_SRGB_ALPHA_BPTC_UNORM_EXT;
689             mActualImageFormatID      = angle::FormatID::BC7_RGBA_UNORM_SRGB_BLOCK;
690             mImageInitializerFunction = nullptr;
691             mIsRenderable             = true;
692 
693             break;
694 
695         case angle::FormatID::D16_UNORM:
696             mIntendedGLFormat         = GL_DEPTH_COMPONENT16;
697             mActualImageFormatID      = angle::FormatID::D16_UNORM;
698             mImageInitializerFunction = nullptr;
699             mIsRenderable             = true;
700 
701             break;
702 
703         case angle::FormatID::D24_UNORM_S8_UINT:
704             mIntendedGLFormat         = GL_DEPTH24_STENCIL8;
705             mActualImageFormatID      = angle::FormatID::D24_UNORM_S8_UINT;
706             mImageInitializerFunction = nullptr;
707             mIsRenderable             = true;
708 
709             break;
710 
711         case angle::FormatID::D24_UNORM_X8_UINT:
712             // This format is not implemented in WebGPU.
713             break;
714 
715         case angle::FormatID::D32_FLOAT:
716             mIntendedGLFormat         = GL_DEPTH_COMPONENT32F;
717             mActualImageFormatID      = angle::FormatID::D32_FLOAT;
718             mImageInitializerFunction = nullptr;
719             mIsRenderable             = true;
720 
721             break;
722 
723         case angle::FormatID::D32_FLOAT_S8X24_UINT:
724             // This format is not implemented in WebGPU.
725             break;
726 
727         case angle::FormatID::D32_UNORM:
728             mIntendedGLFormat             = GL_DEPTH_COMPONENT32_OES;
729             mActualImageFormatID          = angle::FormatID::D32_FLOAT;
730             mImageInitializerFunction     = nullptr;
731             mIsRenderable                 = true;
732             mActualBufferFormatID         = angle::FormatID::NONE;
733             mVertexLoadFunction           = nullptr;
734             mVertexLoadRequiresConversion = true;
735             break;
736 
737         case angle::FormatID::EAC_R11G11_SNORM_BLOCK:
738             mIntendedGLFormat         = GL_COMPRESSED_SIGNED_RG11_EAC;
739             mActualImageFormatID      = angle::FormatID::EAC_R11G11_SNORM_BLOCK;
740             mImageInitializerFunction = nullptr;
741             mIsRenderable             = false;
742 
743             break;
744 
745         case angle::FormatID::EAC_R11G11_UNORM_BLOCK:
746             mIntendedGLFormat         = GL_COMPRESSED_RG11_EAC;
747             mActualImageFormatID      = angle::FormatID::EAC_R11G11_UNORM_BLOCK;
748             mImageInitializerFunction = nullptr;
749             mIsRenderable             = true;
750 
751             break;
752 
753         case angle::FormatID::EAC_R11_SNORM_BLOCK:
754             mIntendedGLFormat         = GL_COMPRESSED_SIGNED_R11_EAC;
755             mActualImageFormatID      = angle::FormatID::EAC_R11_SNORM_BLOCK;
756             mImageInitializerFunction = nullptr;
757             mIsRenderable             = false;
758 
759             break;
760 
761         case angle::FormatID::EAC_R11_UNORM_BLOCK:
762             mIntendedGLFormat         = GL_COMPRESSED_R11_EAC;
763             mActualImageFormatID      = angle::FormatID::EAC_R11_UNORM_BLOCK;
764             mImageInitializerFunction = nullptr;
765             mIsRenderable             = true;
766 
767             break;
768 
769         case angle::FormatID::ETC1_LOSSY_DECODE_R8G8B8_UNORM_BLOCK:
770             // This format is not implemented in WebGPU.
771             break;
772 
773         case angle::FormatID::ETC1_R8G8B8_UNORM_BLOCK:
774             mIntendedGLFormat         = GL_ETC1_RGB8_OES;
775             mActualImageFormatID      = angle::FormatID::ETC2_R8G8B8_UNORM_BLOCK;
776             mImageInitializerFunction = nullptr;
777             mIsRenderable             = true;
778 
779             break;
780 
781         case angle::FormatID::ETC2_R8G8B8A1_SRGB_BLOCK:
782             mIntendedGLFormat         = GL_COMPRESSED_SRGB8_PUNCHTHROUGH_ALPHA1_ETC2;
783             mActualImageFormatID      = angle::FormatID::ETC2_R8G8B8A1_SRGB_BLOCK;
784             mImageInitializerFunction = nullptr;
785             mIsRenderable             = true;
786 
787             break;
788 
789         case angle::FormatID::ETC2_R8G8B8A1_UNORM_BLOCK:
790             mIntendedGLFormat         = GL_COMPRESSED_RGB8_PUNCHTHROUGH_ALPHA1_ETC2;
791             mActualImageFormatID      = angle::FormatID::ETC2_R8G8B8A1_UNORM_BLOCK;
792             mImageInitializerFunction = nullptr;
793             mIsRenderable             = true;
794 
795             break;
796 
797         case angle::FormatID::ETC2_R8G8B8A8_SRGB_BLOCK:
798             mIntendedGLFormat         = GL_COMPRESSED_SRGB8_ALPHA8_ETC2_EAC;
799             mActualImageFormatID      = angle::FormatID::ETC2_R8G8B8A8_SRGB_BLOCK;
800             mImageInitializerFunction = nullptr;
801             mIsRenderable             = true;
802 
803             break;
804 
805         case angle::FormatID::ETC2_R8G8B8A8_UNORM_BLOCK:
806             mIntendedGLFormat = GL_COMPRESSED_RGBA8_ETC2_EAC;
807             {
808                 static constexpr ImageFormatInitInfo kInfo[] = {
809                     {angle::FormatID::ETC2_R8G8B8A8_UNORM_BLOCK, nullptr},
810                     {angle::FormatID::R8G8B8A8_UNORM, nullptr}};
811                 initImageFallback(kInfo, ArraySize(kInfo));
812             }
813 
814             break;
815 
816         case angle::FormatID::ETC2_R8G8B8_SRGB_BLOCK:
817             mIntendedGLFormat         = GL_COMPRESSED_SRGB8_ETC2;
818             mActualImageFormatID      = angle::FormatID::ETC2_R8G8B8_SRGB_BLOCK;
819             mImageInitializerFunction = nullptr;
820             mIsRenderable             = true;
821 
822             break;
823 
824         case angle::FormatID::ETC2_R8G8B8_UNORM_BLOCK:
825             mIntendedGLFormat         = GL_COMPRESSED_RGB8_ETC2;
826             mActualImageFormatID      = angle::FormatID::ETC2_R8G8B8_UNORM_BLOCK;
827             mImageInitializerFunction = nullptr;
828             mIsRenderable             = true;
829 
830             break;
831 
832         case angle::FormatID::EXTERNAL0:
833             mIntendedGLFormat             = GL_NONE;
834             mActualImageFormatID          = angle::FormatID::EXTERNAL0;
835             mImageInitializerFunction     = nullptr;
836             mIsRenderable                 = true;
837             mActualBufferFormatID         = angle::FormatID::EXTERNAL0;
838             mVertexLoadFunction           = CopyNativeVertexData<GLbyte, 4, 4, 0>;
839             mVertexLoadRequiresConversion = false;
840             break;
841 
842         case angle::FormatID::EXTERNAL1:
843             mIntendedGLFormat             = GL_NONE;
844             mActualImageFormatID          = angle::FormatID::EXTERNAL1;
845             mImageInitializerFunction     = nullptr;
846             mIsRenderable                 = true;
847             mActualBufferFormatID         = angle::FormatID::EXTERNAL1;
848             mVertexLoadFunction           = CopyNativeVertexData<GLbyte, 4, 4, 0>;
849             mVertexLoadRequiresConversion = false;
850             break;
851 
852         case angle::FormatID::EXTERNAL2:
853             mIntendedGLFormat             = GL_NONE;
854             mActualImageFormatID          = angle::FormatID::EXTERNAL2;
855             mImageInitializerFunction     = nullptr;
856             mIsRenderable                 = true;
857             mActualBufferFormatID         = angle::FormatID::EXTERNAL2;
858             mVertexLoadFunction           = CopyNativeVertexData<GLbyte, 4, 4, 0>;
859             mVertexLoadRequiresConversion = false;
860             break;
861 
862         case angle::FormatID::EXTERNAL3:
863             mIntendedGLFormat             = GL_NONE;
864             mActualImageFormatID          = angle::FormatID::EXTERNAL3;
865             mImageInitializerFunction     = nullptr;
866             mIsRenderable                 = true;
867             mActualBufferFormatID         = angle::FormatID::EXTERNAL3;
868             mVertexLoadFunction           = CopyNativeVertexData<GLbyte, 4, 4, 0>;
869             mVertexLoadRequiresConversion = false;
870             break;
871 
872         case angle::FormatID::EXTERNAL4:
873             mIntendedGLFormat             = GL_NONE;
874             mActualImageFormatID          = angle::FormatID::EXTERNAL4;
875             mImageInitializerFunction     = nullptr;
876             mIsRenderable                 = true;
877             mActualBufferFormatID         = angle::FormatID::EXTERNAL4;
878             mVertexLoadFunction           = CopyNativeVertexData<GLbyte, 4, 4, 0>;
879             mVertexLoadRequiresConversion = false;
880             break;
881 
882         case angle::FormatID::EXTERNAL5:
883             mIntendedGLFormat             = GL_NONE;
884             mActualImageFormatID          = angle::FormatID::EXTERNAL5;
885             mImageInitializerFunction     = nullptr;
886             mIsRenderable                 = true;
887             mActualBufferFormatID         = angle::FormatID::EXTERNAL5;
888             mVertexLoadFunction           = CopyNativeVertexData<GLbyte, 4, 4, 0>;
889             mVertexLoadRequiresConversion = false;
890             break;
891 
892         case angle::FormatID::EXTERNAL6:
893             mIntendedGLFormat             = GL_NONE;
894             mActualImageFormatID          = angle::FormatID::EXTERNAL6;
895             mImageInitializerFunction     = nullptr;
896             mIsRenderable                 = true;
897             mActualBufferFormatID         = angle::FormatID::EXTERNAL6;
898             mVertexLoadFunction           = CopyNativeVertexData<GLbyte, 4, 4, 0>;
899             mVertexLoadRequiresConversion = false;
900             break;
901 
902         case angle::FormatID::EXTERNAL7:
903             mIntendedGLFormat             = GL_NONE;
904             mActualImageFormatID          = angle::FormatID::EXTERNAL7;
905             mImageInitializerFunction     = nullptr;
906             mIsRenderable                 = true;
907             mActualBufferFormatID         = angle::FormatID::EXTERNAL7;
908             mVertexLoadFunction           = CopyNativeVertexData<GLbyte, 4, 4, 0>;
909             mVertexLoadRequiresConversion = false;
910             break;
911 
912         case angle::FormatID::G8_B8R8_2PLANE_420_UNORM:
913             // This format is not implemented in WebGPU.
914             break;
915 
916         case angle::FormatID::G8_B8_R8_3PLANE_420_UNORM:
917             // This format is not implemented in WebGPU.
918             break;
919 
920         case angle::FormatID::L16A16_FLOAT:
921             mIntendedGLFormat         = GL_LUMINANCE_ALPHA16F_EXT;
922             mActualImageFormatID      = angle::FormatID::R16G16_FLOAT;
923             mImageInitializerFunction = nullptr;
924             mIsRenderable             = true;
925 
926             break;
927 
928         case angle::FormatID::L16_FLOAT:
929             mIntendedGLFormat         = GL_LUMINANCE16F_EXT;
930             mActualImageFormatID      = angle::FormatID::R16_FLOAT;
931             mImageInitializerFunction = nullptr;
932             mIsRenderable             = true;
933 
934             break;
935 
936         case angle::FormatID::L32A32_FLOAT:
937             mIntendedGLFormat         = GL_LUMINANCE_ALPHA32F_EXT;
938             mActualImageFormatID      = angle::FormatID::R32G32_FLOAT;
939             mImageInitializerFunction = nullptr;
940             mIsRenderable             = true;
941 
942             break;
943 
944         case angle::FormatID::L32_FLOAT:
945             mIntendedGLFormat         = GL_LUMINANCE32F_EXT;
946             mActualImageFormatID      = angle::FormatID::R32_FLOAT;
947             mImageInitializerFunction = nullptr;
948             mIsRenderable             = true;
949 
950             break;
951 
952         case angle::FormatID::L4A4_UNORM:
953             // This format is not implemented in WebGPU.
954             break;
955 
956         case angle::FormatID::L8A8_UNORM:
957             mIntendedGLFormat         = GL_LUMINANCE8_ALPHA8_EXT;
958             mActualImageFormatID      = angle::FormatID::R8G8_UNORM;
959             mImageInitializerFunction = nullptr;
960             mIsRenderable             = true;
961 
962             break;
963 
964         case angle::FormatID::L8_UNORM:
965             mIntendedGLFormat         = GL_LUMINANCE8_EXT;
966             mActualImageFormatID      = angle::FormatID::R8_UNORM;
967             mImageInitializerFunction = nullptr;
968             mIsRenderable             = true;
969 
970             break;
971 
972         case angle::FormatID::NONE:
973             mIntendedGLFormat             = GL_NONE;
974             mActualImageFormatID          = angle::FormatID::NONE;
975             mImageInitializerFunction     = nullptr;
976             mIsRenderable                 = true;
977             mActualBufferFormatID         = angle::FormatID::NONE;
978             mVertexLoadFunction           = nullptr;
979             mVertexLoadRequiresConversion = false;
980             break;
981 
982         case angle::FormatID::PALETTE4_R4G4B4A4_UNORM:
983             mIntendedGLFormat         = GL_PALETTE4_RGBA4_OES;
984             mActualImageFormatID      = angle::FormatID::R8G8B8A8_UNORM;
985             mImageInitializerFunction = nullptr;
986             mIsRenderable             = true;
987 
988             break;
989 
990         case angle::FormatID::PALETTE4_R5G5B5A1_UNORM:
991             mIntendedGLFormat         = GL_PALETTE4_RGB5_A1_OES;
992             mActualImageFormatID      = angle::FormatID::R8G8B8A8_UNORM;
993             mImageInitializerFunction = nullptr;
994             mIsRenderable             = true;
995 
996             break;
997 
998         case angle::FormatID::PALETTE4_R5G6B5_UNORM:
999             mIntendedGLFormat         = GL_PALETTE4_R5_G6_B5_OES;
1000             mActualImageFormatID      = angle::FormatID::R8G8B8A8_UNORM;
1001             mImageInitializerFunction = nullptr;
1002             mIsRenderable             = true;
1003 
1004             break;
1005 
1006         case angle::FormatID::PALETTE4_R8G8B8A8_UNORM:
1007             mIntendedGLFormat         = GL_PALETTE4_RGBA8_OES;
1008             mActualImageFormatID      = angle::FormatID::R8G8B8A8_UNORM;
1009             mImageInitializerFunction = nullptr;
1010             mIsRenderable             = true;
1011 
1012             break;
1013 
1014         case angle::FormatID::PALETTE4_R8G8B8_UNORM:
1015             mIntendedGLFormat         = GL_PALETTE4_RGB8_OES;
1016             mActualImageFormatID      = angle::FormatID::R8G8B8A8_UNORM;
1017             mImageInitializerFunction = nullptr;
1018             mIsRenderable             = true;
1019 
1020             break;
1021 
1022         case angle::FormatID::PALETTE8_R4G4B4A4_UNORM:
1023             mIntendedGLFormat         = GL_PALETTE8_RGBA4_OES;
1024             mActualImageFormatID      = angle::FormatID::R8G8B8A8_UNORM;
1025             mImageInitializerFunction = nullptr;
1026             mIsRenderable             = true;
1027 
1028             break;
1029 
1030         case angle::FormatID::PALETTE8_R5G5B5A1_UNORM:
1031             mIntendedGLFormat         = GL_PALETTE8_RGB5_A1_OES;
1032             mActualImageFormatID      = angle::FormatID::R8G8B8A8_UNORM;
1033             mImageInitializerFunction = nullptr;
1034             mIsRenderable             = true;
1035 
1036             break;
1037 
1038         case angle::FormatID::PALETTE8_R5G6B5_UNORM:
1039             mIntendedGLFormat         = GL_PALETTE8_R5_G6_B5_OES;
1040             mActualImageFormatID      = angle::FormatID::R8G8B8A8_UNORM;
1041             mImageInitializerFunction = nullptr;
1042             mIsRenderable             = true;
1043 
1044             break;
1045 
1046         case angle::FormatID::PALETTE8_R8G8B8A8_UNORM:
1047             mIntendedGLFormat         = GL_PALETTE8_RGBA8_OES;
1048             mActualImageFormatID      = angle::FormatID::R8G8B8A8_UNORM;
1049             mImageInitializerFunction = nullptr;
1050             mIsRenderable             = true;
1051 
1052             break;
1053 
1054         case angle::FormatID::PALETTE8_R8G8B8_UNORM:
1055             mIntendedGLFormat         = GL_PALETTE8_RGB8_OES;
1056             mActualImageFormatID      = angle::FormatID::R8G8B8A8_UNORM;
1057             mImageInitializerFunction = nullptr;
1058             mIsRenderable             = true;
1059 
1060             break;
1061 
1062         case angle::FormatID::PVRTC1_RGBA_2BPP_UNORM_BLOCK:
1063             // This format is not implemented in WebGPU.
1064             break;
1065 
1066         case angle::FormatID::PVRTC1_RGBA_2BPP_UNORM_SRGB_BLOCK:
1067             // This format is not implemented in WebGPU.
1068             break;
1069 
1070         case angle::FormatID::PVRTC1_RGBA_4BPP_UNORM_BLOCK:
1071             // This format is not implemented in WebGPU.
1072             break;
1073 
1074         case angle::FormatID::PVRTC1_RGBA_4BPP_UNORM_SRGB_BLOCK:
1075             // This format is not implemented in WebGPU.
1076             break;
1077 
1078         case angle::FormatID::PVRTC1_RGB_2BPP_UNORM_BLOCK:
1079             // This format is not implemented in WebGPU.
1080             break;
1081 
1082         case angle::FormatID::PVRTC1_RGB_2BPP_UNORM_SRGB_BLOCK:
1083             // This format is not implemented in WebGPU.
1084             break;
1085 
1086         case angle::FormatID::PVRTC1_RGB_4BPP_UNORM_BLOCK:
1087             // This format is not implemented in WebGPU.
1088             break;
1089 
1090         case angle::FormatID::PVRTC1_RGB_4BPP_UNORM_SRGB_BLOCK:
1091             // This format is not implemented in WebGPU.
1092             break;
1093 
1094         case angle::FormatID::R10G10B10A2_SINT:
1095             mIntendedGLFormat         = GL_RGB10_A2_SINT_ANGLEX;
1096             mActualImageFormatID      = angle::FormatID::R10G10B10A2_SINT;
1097             mImageInitializerFunction = nullptr;
1098             mIsRenderable             = true;
1099 
1100             break;
1101 
1102         case angle::FormatID::R10G10B10A2_SNORM:
1103             mIntendedGLFormat = GL_RGB10_A2_SNORM_ANGLEX;
1104 
1105             mActualBufferFormatID = angle::FormatID::R16G16B16A16_SNORM;
1106             mVertexLoadFunction   = CopyXYZ10W2ToXYZWFloatVertexData<true, true, true, true>;
1107             mVertexLoadRequiresConversion = true;
1108             break;
1109 
1110         case angle::FormatID::R10G10B10A2_SSCALED:
1111             mIntendedGLFormat = GL_RGB10_A2_SSCALED_ANGLEX;
1112 
1113             mActualBufferFormatID = angle::FormatID::R16G16B16A16_FLOAT;
1114             mVertexLoadFunction   = CopyXYZ10W2ToXYZWFloatVertexData<true, false, true, true>;
1115             mVertexLoadRequiresConversion = true;
1116             break;
1117 
1118         case angle::FormatID::R10G10B10A2_UINT:
1119             mIntendedGLFormat = GL_RGB10_A2UI;
1120 
1121             mActualBufferFormatID = angle::FormatID::R16G16B16A16_UINT;
1122             mVertexLoadFunction   = CopyXYZ10W2ToXYZWFloatVertexData<false, false, false, false>;
1123             mVertexLoadRequiresConversion = true;
1124             break;
1125 
1126         case angle::FormatID::R10G10B10A2_UNORM:
1127             mIntendedGLFormat         = GL_RGB10_A2;
1128             mActualImageFormatID      = angle::FormatID::R10G10B10A2_UNORM;
1129             mImageInitializerFunction = nullptr;
1130             mIsRenderable             = true;
1131             mActualBufferFormatID     = angle::FormatID::R10G10B10A2_UNORM;
1132             mVertexLoadFunction       = CopyXYZ10W2ToXYZWFloatVertexData<false, true, true, true>;
1133             mVertexLoadRequiresConversion = false;
1134             break;
1135 
1136         case angle::FormatID::R10G10B10A2_USCALED:
1137             mIntendedGLFormat = GL_RGB10_A2_USCALED_ANGLEX;
1138 
1139             mActualBufferFormatID = angle::FormatID::R16G16B16A16_FLOAT;
1140             mVertexLoadFunction   = CopyXYZ10W2ToXYZWFloatVertexData<false, false, true, true>;
1141             mVertexLoadRequiresConversion = true;
1142             break;
1143 
1144         case angle::FormatID::R10G10B10X2_UNORM:
1145             mIntendedGLFormat             = GL_RGB10_EXT;
1146             mActualImageFormatID          = angle::FormatID::R10G10B10A2_UNORM;
1147             mImageInitializerFunction     = nullptr;
1148             mIsRenderable                 = true;
1149             mActualBufferFormatID         = angle::FormatID::NONE;
1150             mVertexLoadFunction           = nullptr;
1151             mVertexLoadRequiresConversion = true;
1152             break;
1153 
1154         case angle::FormatID::R11G11B10_FLOAT:
1155             mIntendedGLFormat         = GL_R11F_G11F_B10F;
1156             mActualImageFormatID      = angle::FormatID::R11G11B10_FLOAT;
1157             mImageInitializerFunction = nullptr;
1158             mIsRenderable             = true;
1159 
1160             break;
1161 
1162         case angle::FormatID::R16G16B16A16_FLOAT:
1163             mIntendedGLFormat             = GL_RGBA16F;
1164             mActualImageFormatID          = angle::FormatID::R16G16B16A16_FLOAT;
1165             mImageInitializerFunction     = nullptr;
1166             mIsRenderable                 = true;
1167             mActualBufferFormatID         = angle::FormatID::R16G16B16A16_FLOAT;
1168             mVertexLoadFunction           = CopyNativeVertexData<GLhalf, 4, 4, 0>;
1169             mVertexLoadRequiresConversion = false;
1170             break;
1171 
1172         case angle::FormatID::R16G16B16A16_SINT:
1173             mIntendedGLFormat             = GL_RGBA16I;
1174             mActualImageFormatID          = angle::FormatID::R16G16B16A16_SINT;
1175             mImageInitializerFunction     = nullptr;
1176             mIsRenderable                 = true;
1177             mActualBufferFormatID         = angle::FormatID::R16G16B16A16_SINT;
1178             mVertexLoadFunction           = CopyNativeVertexData<GLshort, 4, 4, 0>;
1179             mVertexLoadRequiresConversion = false;
1180             break;
1181 
1182         case angle::FormatID::R16G16B16A16_SNORM:
1183             mIntendedGLFormat             = GL_RGBA16_SNORM_EXT;
1184             mActualImageFormatID          = angle::FormatID::R16G16B16A16_SNORM;
1185             mImageInitializerFunction     = nullptr;
1186             mIsRenderable                 = false;
1187             mActualBufferFormatID         = angle::FormatID::R16G16B16A16_SNORM;
1188             mVertexLoadFunction           = CopyNativeVertexData<GLshort, 4, 4, 0>;
1189             mVertexLoadRequiresConversion = false;
1190             break;
1191 
1192         case angle::FormatID::R16G16B16A16_SSCALED:
1193             // This format is not implemented in WebGPU.
1194             break;
1195 
1196         case angle::FormatID::R16G16B16A16_UINT:
1197             mIntendedGLFormat             = GL_RGBA16UI;
1198             mActualImageFormatID          = angle::FormatID::R16G16B16A16_UINT;
1199             mImageInitializerFunction     = nullptr;
1200             mIsRenderable                 = true;
1201             mActualBufferFormatID         = angle::FormatID::R16G16B16A16_UINT;
1202             mVertexLoadFunction           = CopyNativeVertexData<GLushort, 4, 4, 0>;
1203             mVertexLoadRequiresConversion = false;
1204             break;
1205 
1206         case angle::FormatID::R16G16B16A16_UNORM:
1207             mIntendedGLFormat             = GL_RGBA16_EXT;
1208             mActualImageFormatID          = angle::FormatID::R16G16B16A16_UNORM;
1209             mImageInitializerFunction     = nullptr;
1210             mIsRenderable                 = true;
1211             mActualBufferFormatID         = angle::FormatID::R16G16B16A16_UNORM;
1212             mVertexLoadFunction           = CopyNativeVertexData<GLushort, 4, 4, 0>;
1213             mVertexLoadRequiresConversion = false;
1214             break;
1215 
1216         case angle::FormatID::R16G16B16A16_USCALED:
1217             // This format is not implemented in WebGPU.
1218             break;
1219 
1220         case angle::FormatID::R16G16B16_FLOAT:
1221             mIntendedGLFormat    = GL_RGB16F;
1222             mActualImageFormatID = angle::FormatID::R16G16B16A16_FLOAT;
1223             mImageInitializerFunction =
1224                 Initialize4ComponentData<GLhalf, 0x0000, 0x0000, 0x0000, gl::Float16One>;
1225             mIsRenderable                 = true;
1226             mActualBufferFormatID         = angle::FormatID::R16G16B16A16_FLOAT;
1227             mVertexLoadFunction           = CopyNativeVertexData<GLhalf, 3, 4, gl::Float16One>;
1228             mVertexLoadRequiresConversion = true;
1229             break;
1230 
1231         case angle::FormatID::R16G16B16_SINT:
1232             mIntendedGLFormat    = GL_RGB16I;
1233             mActualImageFormatID = angle::FormatID::R16G16B16A16_SINT;
1234             mImageInitializerFunction =
1235                 Initialize4ComponentData<GLshort, 0x0000, 0x0000, 0x0000, 0x0001>;
1236             mIsRenderable                 = true;
1237             mActualBufferFormatID         = angle::FormatID::R16G16B16A16_SINT;
1238             mVertexLoadFunction           = CopyNativeVertexData<GLshort, 3, 4, 1>;
1239             mVertexLoadRequiresConversion = true;
1240             break;
1241 
1242         case angle::FormatID::R16G16B16_SNORM:
1243             mIntendedGLFormat    = GL_RGB16_SNORM_EXT;
1244             mActualImageFormatID = angle::FormatID::R16G16B16A16_SNORM;
1245             mImageInitializerFunction =
1246                 Initialize4ComponentData<GLushort, 0x0000, 0x0000, 0x0000, 0x7FFF>;
1247             mIsRenderable         = false;
1248             mActualBufferFormatID = angle::FormatID::R16G16B16A16_SNORM;
1249             mVertexLoadFunction =
1250                 CopyNativeVertexData<GLshort, 3, 4, std::numeric_limits<GLshort>::max()>;
1251             mVertexLoadRequiresConversion = true;
1252             break;
1253 
1254         case angle::FormatID::R16G16B16_SSCALED:
1255             // This format is not implemented in WebGPU.
1256             break;
1257 
1258         case angle::FormatID::R16G16B16_UINT:
1259             // This format is not implemented in WebGPU.
1260             break;
1261 
1262         case angle::FormatID::R16G16B16_UNORM:
1263             // This format is not implemented in WebGPU.
1264             break;
1265 
1266         case angle::FormatID::R16G16B16_USCALED:
1267             // This format is not implemented in WebGPU.
1268             break;
1269 
1270         case angle::FormatID::R16G16_FLOAT:
1271             mIntendedGLFormat             = GL_RG16F;
1272             mActualImageFormatID          = angle::FormatID::R16G16_FLOAT;
1273             mImageInitializerFunction     = nullptr;
1274             mIsRenderable                 = true;
1275             mActualBufferFormatID         = angle::FormatID::R16G16_FLOAT;
1276             mVertexLoadFunction           = CopyNativeVertexData<GLhalf, 2, 2, 0>;
1277             mVertexLoadRequiresConversion = false;
1278             break;
1279 
1280         case angle::FormatID::R16G16_SINT:
1281             mIntendedGLFormat             = GL_RG16I;
1282             mActualImageFormatID          = angle::FormatID::R16G16_SINT;
1283             mImageInitializerFunction     = nullptr;
1284             mIsRenderable                 = true;
1285             mActualBufferFormatID         = angle::FormatID::R16G16_SINT;
1286             mVertexLoadFunction           = CopyNativeVertexData<GLshort, 2, 2, 0>;
1287             mVertexLoadRequiresConversion = false;
1288             break;
1289 
1290         case angle::FormatID::R16G16_SNORM:
1291             mIntendedGLFormat             = GL_RG16_SNORM_EXT;
1292             mActualImageFormatID          = angle::FormatID::R16G16_SNORM;
1293             mImageInitializerFunction     = nullptr;
1294             mIsRenderable                 = false;
1295             mActualBufferFormatID         = angle::FormatID::R16G16_SNORM;
1296             mVertexLoadFunction           = CopyNativeVertexData<GLshort, 2, 2, 0>;
1297             mVertexLoadRequiresConversion = false;
1298             break;
1299 
1300         case angle::FormatID::R16G16_SSCALED:
1301             mIntendedGLFormat = GL_RG16_SSCALED_ANGLEX;
1302 
1303             mActualBufferFormatID         = angle::FormatID::R32G32_FLOAT;
1304             mVertexLoadFunction           = CopyToFloatVertexData<GLshort, 2, 2, false, false>;
1305             mVertexLoadRequiresConversion = true;
1306             break;
1307 
1308         case angle::FormatID::R16G16_UINT:
1309             mIntendedGLFormat             = GL_RG16UI;
1310             mActualImageFormatID          = angle::FormatID::R16G16_UINT;
1311             mImageInitializerFunction     = nullptr;
1312             mIsRenderable                 = true;
1313             mActualBufferFormatID         = angle::FormatID::R16G16_UINT;
1314             mVertexLoadFunction           = CopyNativeVertexData<GLushort, 2, 2, 0>;
1315             mVertexLoadRequiresConversion = false;
1316             break;
1317 
1318         case angle::FormatID::R16G16_UNORM:
1319             mIntendedGLFormat             = GL_RG16_EXT;
1320             mActualImageFormatID          = angle::FormatID::R16G16_UNORM;
1321             mImageInitializerFunction     = nullptr;
1322             mIsRenderable                 = true;
1323             mActualBufferFormatID         = angle::FormatID::R16G16_UNORM;
1324             mVertexLoadFunction           = CopyNativeVertexData<GLushort, 2, 2, 0>;
1325             mVertexLoadRequiresConversion = false;
1326             break;
1327 
1328         case angle::FormatID::R16G16_USCALED:
1329             mIntendedGLFormat = GL_RG16_USCALED_ANGLEX;
1330 
1331             mActualBufferFormatID         = angle::FormatID::R32G32_FLOAT;
1332             mVertexLoadFunction           = CopyToFloatVertexData<GLushort, 2, 2, false, false>;
1333             mVertexLoadRequiresConversion = true;
1334             break;
1335 
1336         case angle::FormatID::R16_FLOAT:
1337             mIntendedGLFormat         = GL_R16F;
1338             mActualImageFormatID      = angle::FormatID::R16_FLOAT;
1339             mImageInitializerFunction = nullptr;
1340             mIsRenderable             = true;
1341 
1342             break;
1343 
1344         case angle::FormatID::R16_SINT:
1345             mIntendedGLFormat         = GL_R16I;
1346             mActualImageFormatID      = angle::FormatID::R16_SINT;
1347             mImageInitializerFunction = nullptr;
1348             mIsRenderable             = true;
1349 
1350             break;
1351 
1352         case angle::FormatID::R16_SNORM:
1353             mIntendedGLFormat         = GL_R16_SNORM_EXT;
1354             mActualImageFormatID      = angle::FormatID::R16_SNORM;
1355             mImageInitializerFunction = nullptr;
1356             mIsRenderable             = false;
1357 
1358             break;
1359 
1360         case angle::FormatID::R16_SSCALED:
1361             mIntendedGLFormat = GL_R16_SSCALED_ANGLEX;
1362 
1363             mActualBufferFormatID         = angle::FormatID::R32_FLOAT;
1364             mVertexLoadFunction           = CopyToFloatVertexData<GLshort, 1, 1, false, false>;
1365             mVertexLoadRequiresConversion = true;
1366             break;
1367 
1368         case angle::FormatID::R16_UINT:
1369             mIntendedGLFormat         = GL_R16UI;
1370             mActualImageFormatID      = angle::FormatID::R16_UINT;
1371             mImageInitializerFunction = nullptr;
1372             mIsRenderable             = true;
1373 
1374             break;
1375 
1376         case angle::FormatID::R16_UNORM:
1377             mIntendedGLFormat         = GL_R16_EXT;
1378             mActualImageFormatID      = angle::FormatID::R16_UNORM;
1379             mImageInitializerFunction = nullptr;
1380             mIsRenderable             = true;
1381 
1382             break;
1383 
1384         case angle::FormatID::R16_USCALED:
1385             mIntendedGLFormat = GL_R16_USCALED_ANGLEX;
1386 
1387             mActualBufferFormatID         = angle::FormatID::R32_FLOAT;
1388             mVertexLoadFunction           = CopyToFloatVertexData<GLushort, 1, 1, false, false>;
1389             mVertexLoadRequiresConversion = true;
1390             break;
1391 
1392         case angle::FormatID::R32G32B32A32_FIXED:
1393             mIntendedGLFormat = GL_RGBA32_FIXED_ANGLEX;
1394 
1395             mActualBufferFormatID         = angle::FormatID::R32G32B32A32_FLOAT;
1396             mVertexLoadFunction           = Copy32FixedTo32FVertexData<4, 4>;
1397             mVertexLoadRequiresConversion = true;
1398             break;
1399 
1400         case angle::FormatID::R32G32B32A32_FLOAT:
1401             mIntendedGLFormat             = GL_RGBA32F;
1402             mActualImageFormatID          = angle::FormatID::R32G32B32A32_FLOAT;
1403             mImageInitializerFunction     = nullptr;
1404             mIsRenderable                 = true;
1405             mActualBufferFormatID         = angle::FormatID::R32G32B32A32_FLOAT;
1406             mVertexLoadFunction           = CopyNativeVertexData<GLfloat, 4, 4, 0>;
1407             mVertexLoadRequiresConversion = false;
1408             break;
1409 
1410         case angle::FormatID::R32G32B32A32_SINT:
1411             mIntendedGLFormat             = GL_RGBA32I;
1412             mActualImageFormatID          = angle::FormatID::R32G32B32A32_SINT;
1413             mImageInitializerFunction     = nullptr;
1414             mIsRenderable                 = true;
1415             mActualBufferFormatID         = angle::FormatID::R32G32B32A32_SINT;
1416             mVertexLoadFunction           = CopyNativeVertexData<GLint, 4, 4, 0>;
1417             mVertexLoadRequiresConversion = false;
1418             break;
1419 
1420         case angle::FormatID::R32G32B32A32_SNORM:
1421             mIntendedGLFormat = GL_RGBA32_SNORM_ANGLEX;
1422 
1423             mActualBufferFormatID         = angle::FormatID::R32G32B32A32_FLOAT;
1424             mVertexLoadFunction           = CopyToFloatVertexData<GLint, 4, 4, true, false>;
1425             mVertexLoadRequiresConversion = true;
1426             break;
1427 
1428         case angle::FormatID::R32G32B32A32_SSCALED:
1429             mIntendedGLFormat = GL_RGBA32_SSCALED_ANGLEX;
1430 
1431             mActualBufferFormatID         = angle::FormatID::R32G32B32A32_FLOAT;
1432             mVertexLoadFunction           = CopyToFloatVertexData<GLint, 4, 4, false, false>;
1433             mVertexLoadRequiresConversion = true;
1434             break;
1435 
1436         case angle::FormatID::R32G32B32A32_UINT:
1437             mIntendedGLFormat             = GL_RGBA32UI;
1438             mActualImageFormatID          = angle::FormatID::R32G32B32A32_UINT;
1439             mImageInitializerFunction     = nullptr;
1440             mIsRenderable                 = true;
1441             mActualBufferFormatID         = angle::FormatID::R32G32B32A32_UINT;
1442             mVertexLoadFunction           = CopyNativeVertexData<GLuint, 4, 4, 0>;
1443             mVertexLoadRequiresConversion = false;
1444             break;
1445 
1446         case angle::FormatID::R32G32B32A32_UNORM:
1447             mIntendedGLFormat = GL_RGBA32_UNORM_ANGLEX;
1448 
1449             mActualBufferFormatID         = angle::FormatID::R32G32B32A32_FLOAT;
1450             mVertexLoadFunction           = CopyToFloatVertexData<GLuint, 4, 4, true, false>;
1451             mVertexLoadRequiresConversion = true;
1452             break;
1453 
1454         case angle::FormatID::R32G32B32A32_USCALED:
1455             mIntendedGLFormat = GL_RGBA32_USCALED_ANGLEX;
1456 
1457             mActualBufferFormatID         = angle::FormatID::R32G32B32A32_FLOAT;
1458             mVertexLoadFunction           = CopyToFloatVertexData<GLuint, 4, 4, false, false>;
1459             mVertexLoadRequiresConversion = true;
1460             break;
1461 
1462         case angle::FormatID::R32G32B32_FIXED:
1463             // This format is not implemented in WebGPU.
1464             break;
1465 
1466         case angle::FormatID::R32G32B32_FLOAT:
1467             mIntendedGLFormat = GL_RGB32F;
1468 
1469             mActualBufferFormatID         = angle::FormatID::R32G32B32_FLOAT;
1470             mVertexLoadFunction           = CopyNativeVertexData<GLfloat, 3, 3, 0>;
1471             mVertexLoadRequiresConversion = false;
1472             break;
1473 
1474         case angle::FormatID::R32G32B32_SINT:
1475             mIntendedGLFormat    = GL_RGB32I;
1476             mActualImageFormatID = angle::FormatID::R32G32B32A32_SINT;
1477             mImageInitializerFunction =
1478                 Initialize4ComponentData<GLint, 0x00000000, 0x00000000, 0x00000000, 0x00000001>;
1479             mIsRenderable                 = true;
1480             mActualBufferFormatID         = angle::FormatID::R32G32B32_SINT;
1481             mVertexLoadFunction           = CopyNativeVertexData<GLint, 3, 3, 0>;
1482             mVertexLoadRequiresConversion = false;
1483             break;
1484 
1485         case angle::FormatID::R32G32B32_SNORM:
1486             mIntendedGLFormat = GL_RGB32_SNORM_ANGLEX;
1487 
1488             mActualBufferFormatID         = angle::FormatID::R32G32B32_FLOAT;
1489             mVertexLoadFunction           = CopyToFloatVertexData<GLint, 3, 3, true, false>;
1490             mVertexLoadRequiresConversion = true;
1491             break;
1492 
1493         case angle::FormatID::R32G32B32_SSCALED:
1494             mIntendedGLFormat = GL_RGB32_SSCALED_ANGLEX;
1495 
1496             mActualBufferFormatID         = angle::FormatID::R32G32B32_FLOAT;
1497             mVertexLoadFunction           = CopyToFloatVertexData<GLint, 3, 3, false, false>;
1498             mVertexLoadRequiresConversion = true;
1499             break;
1500 
1501         case angle::FormatID::R32G32B32_UINT:
1502             mIntendedGLFormat = GL_RGB32UI;
1503 
1504             {
1505                 static constexpr BufferFormatInitInfo kInfo[] = {
1506                     {angle::FormatID::R32G32B32_UINT, CopyNativeVertexData<GLuint, 3, 3, 0>, false},
1507                     {angle::FormatID::R32G32B32A32_UINT, CopyNativeVertexData<GLuint, 3, 4, 1>,
1508                      true}};
1509                 initBufferFallback(kInfo, ArraySize(kInfo));
1510             }
1511             break;
1512 
1513         case angle::FormatID::R32G32B32_UNORM:
1514             mIntendedGLFormat = GL_RGB32_UNORM_ANGLEX;
1515 
1516             mActualBufferFormatID         = angle::FormatID::R32G32B32_FLOAT;
1517             mVertexLoadFunction           = CopyToFloatVertexData<GLuint, 3, 3, true, false>;
1518             mVertexLoadRequiresConversion = true;
1519             break;
1520 
1521         case angle::FormatID::R32G32B32_USCALED:
1522             mIntendedGLFormat = GL_RGB32_USCALED_ANGLEX;
1523 
1524             mActualBufferFormatID         = angle::FormatID::R32G32B32_FLOAT;
1525             mVertexLoadFunction           = CopyToFloatVertexData<GLuint, 3, 3, false, false>;
1526             mVertexLoadRequiresConversion = true;
1527             break;
1528 
1529         case angle::FormatID::R32G32_FIXED:
1530             mIntendedGLFormat = GL_RG32_FIXED_ANGLEX;
1531 
1532             mActualBufferFormatID         = angle::FormatID::R32G32_FLOAT;
1533             mVertexLoadFunction           = Copy32FixedTo32FVertexData<2, 2>;
1534             mVertexLoadRequiresConversion = true;
1535             break;
1536 
1537         case angle::FormatID::R32G32_FLOAT:
1538             mIntendedGLFormat             = GL_RG32F;
1539             mActualImageFormatID          = angle::FormatID::R32G32_FLOAT;
1540             mImageInitializerFunction     = nullptr;
1541             mIsRenderable                 = true;
1542             mActualBufferFormatID         = angle::FormatID::R32G32_FLOAT;
1543             mVertexLoadFunction           = CopyNativeVertexData<GLfloat, 2, 2, 0>;
1544             mVertexLoadRequiresConversion = false;
1545             break;
1546 
1547         case angle::FormatID::R32G32_SINT:
1548             mIntendedGLFormat             = GL_RG32I;
1549             mActualImageFormatID          = angle::FormatID::R32G32_SINT;
1550             mImageInitializerFunction     = nullptr;
1551             mIsRenderable                 = true;
1552             mActualBufferFormatID         = angle::FormatID::R32G32_SINT;
1553             mVertexLoadFunction           = CopyNativeVertexData<GLint, 2, 2, 0>;
1554             mVertexLoadRequiresConversion = false;
1555             break;
1556 
1557         case angle::FormatID::R32G32_SNORM:
1558             mIntendedGLFormat = GL_RG32_SNORM_ANGLEX;
1559 
1560             mActualBufferFormatID         = angle::FormatID::R32G32_FLOAT;
1561             mVertexLoadFunction           = CopyToFloatVertexData<GLint, 2, 2, true, false>;
1562             mVertexLoadRequiresConversion = true;
1563             break;
1564 
1565         case angle::FormatID::R32G32_SSCALED:
1566             mIntendedGLFormat = GL_RG32_SSCALED_ANGLEX;
1567 
1568             mActualBufferFormatID         = angle::FormatID::R32G32_FLOAT;
1569             mVertexLoadFunction           = CopyToFloatVertexData<GLint, 2, 2, false, false>;
1570             mVertexLoadRequiresConversion = true;
1571             break;
1572 
1573         case angle::FormatID::R32G32_UINT:
1574             mIntendedGLFormat             = GL_RG32UI;
1575             mActualImageFormatID          = angle::FormatID::R32G32_UINT;
1576             mImageInitializerFunction     = nullptr;
1577             mIsRenderable                 = true;
1578             mActualBufferFormatID         = angle::FormatID::R32G32_UINT;
1579             mVertexLoadFunction           = CopyNativeVertexData<GLuint, 2, 2, 0>;
1580             mVertexLoadRequiresConversion = false;
1581             break;
1582 
1583         case angle::FormatID::R32G32_UNORM:
1584             mIntendedGLFormat = GL_RG32_UNORM_ANGLEX;
1585 
1586             mActualBufferFormatID         = angle::FormatID::R32G32_FLOAT;
1587             mVertexLoadFunction           = CopyToFloatVertexData<GLuint, 2, 2, true, false>;
1588             mVertexLoadRequiresConversion = true;
1589             break;
1590 
1591         case angle::FormatID::R32G32_USCALED:
1592             mIntendedGLFormat = GL_RG32_USCALED_ANGLEX;
1593 
1594             mActualBufferFormatID         = angle::FormatID::R32G32_FLOAT;
1595             mVertexLoadFunction           = CopyToFloatVertexData<GLuint, 2, 2, false, false>;
1596             mVertexLoadRequiresConversion = true;
1597             break;
1598 
1599         case angle::FormatID::R32_FIXED:
1600             mIntendedGLFormat = GL_R32_FIXED_ANGLEX;
1601 
1602             mActualBufferFormatID         = angle::FormatID::R32_FLOAT;
1603             mVertexLoadFunction           = Copy32FixedTo32FVertexData<1, 1>;
1604             mVertexLoadRequiresConversion = true;
1605             break;
1606 
1607         case angle::FormatID::R32_FLOAT:
1608             mIntendedGLFormat             = GL_R32F;
1609             mActualImageFormatID          = angle::FormatID::R32_FLOAT;
1610             mImageInitializerFunction     = nullptr;
1611             mIsRenderable                 = true;
1612             mActualBufferFormatID         = angle::FormatID::R32_FLOAT;
1613             mVertexLoadFunction           = CopyNativeVertexData<GLfloat, 1, 1, 0>;
1614             mVertexLoadRequiresConversion = false;
1615             break;
1616 
1617         case angle::FormatID::R32_SINT:
1618             mIntendedGLFormat             = GL_R32I;
1619             mActualImageFormatID          = angle::FormatID::R32_SINT;
1620             mImageInitializerFunction     = nullptr;
1621             mIsRenderable                 = true;
1622             mActualBufferFormatID         = angle::FormatID::R32_SINT;
1623             mVertexLoadFunction           = CopyNativeVertexData<GLint, 1, 1, 0>;
1624             mVertexLoadRequiresConversion = false;
1625             break;
1626 
1627         case angle::FormatID::R32_SNORM:
1628             mIntendedGLFormat = GL_R32_SNORM_ANGLEX;
1629 
1630             mActualBufferFormatID         = angle::FormatID::R32_FLOAT;
1631             mVertexLoadFunction           = CopyToFloatVertexData<GLint, 1, 1, true, false>;
1632             mVertexLoadRequiresConversion = true;
1633             break;
1634 
1635         case angle::FormatID::R32_SSCALED:
1636             mIntendedGLFormat = GL_R32_SSCALED_ANGLEX;
1637 
1638             mActualBufferFormatID         = angle::FormatID::R32_FLOAT;
1639             mVertexLoadFunction           = CopyToFloatVertexData<GLint, 1, 1, false, false>;
1640             mVertexLoadRequiresConversion = true;
1641             break;
1642 
1643         case angle::FormatID::R32_UINT:
1644             mIntendedGLFormat             = GL_R32UI;
1645             mActualImageFormatID          = angle::FormatID::R32_UINT;
1646             mImageInitializerFunction     = nullptr;
1647             mIsRenderable                 = true;
1648             mActualBufferFormatID         = angle::FormatID::R32_UINT;
1649             mVertexLoadFunction           = CopyNativeVertexData<GLuint, 1, 1, 0>;
1650             mVertexLoadRequiresConversion = false;
1651             break;
1652 
1653         case angle::FormatID::R32_UNORM:
1654             mIntendedGLFormat = GL_R32_UNORM_ANGLEX;
1655 
1656             mActualBufferFormatID         = angle::FormatID::R32_FLOAT;
1657             mVertexLoadFunction           = CopyToFloatVertexData<GLuint, 1, 1, true, false>;
1658             mVertexLoadRequiresConversion = true;
1659             break;
1660 
1661         case angle::FormatID::R32_USCALED:
1662             mIntendedGLFormat = GL_R32_USCALED_ANGLEX;
1663 
1664             mActualBufferFormatID         = angle::FormatID::R32_FLOAT;
1665             mVertexLoadFunction           = CopyToFloatVertexData<GLuint, 1, 1, false, false>;
1666             mVertexLoadRequiresConversion = true;
1667             break;
1668 
1669         case angle::FormatID::R4G4B4A4_UNORM:
1670             mIntendedGLFormat         = GL_RGBA4;
1671             mActualImageFormatID      = angle::FormatID::R8G8B8A8_UNORM;
1672             mImageInitializerFunction = nullptr;
1673             mIsRenderable             = true;
1674 
1675             break;
1676 
1677         case angle::FormatID::R5G5B5A1_UNORM:
1678             // This format is not implemented in WebGPU.
1679             break;
1680 
1681         case angle::FormatID::R5G6B5_UNORM:
1682             // This format is not implemented in WebGPU.
1683             break;
1684 
1685         case angle::FormatID::R8G8B8A8_SINT:
1686             mIntendedGLFormat             = GL_RGBA8I;
1687             mActualImageFormatID          = angle::FormatID::R8G8B8A8_SINT;
1688             mImageInitializerFunction     = nullptr;
1689             mIsRenderable                 = true;
1690             mActualBufferFormatID         = angle::FormatID::R8G8B8A8_SINT;
1691             mVertexLoadFunction           = CopyNativeVertexData<GLbyte, 4, 4, 0>;
1692             mVertexLoadRequiresConversion = false;
1693             break;
1694 
1695         case angle::FormatID::R8G8B8A8_SNORM:
1696             mIntendedGLFormat             = GL_RGBA8_SNORM;
1697             mActualImageFormatID          = angle::FormatID::R8G8B8A8_SNORM;
1698             mImageInitializerFunction     = nullptr;
1699             mIsRenderable                 = false;
1700             mActualBufferFormatID         = angle::FormatID::R8G8B8A8_SNORM;
1701             mVertexLoadFunction           = CopyNativeVertexData<GLbyte, 4, 4, 0>;
1702             mVertexLoadRequiresConversion = false;
1703             break;
1704 
1705         case angle::FormatID::R8G8B8A8_SSCALED:
1706             mIntendedGLFormat = GL_RGBA8_SSCALED_ANGLEX;
1707 
1708             mActualBufferFormatID         = angle::FormatID::R16G16B16A16_FLOAT;
1709             mVertexLoadFunction           = CopyToFloatVertexData<GLbyte, 4, 4, false, true>;
1710             mVertexLoadRequiresConversion = true;
1711             break;
1712 
1713         case angle::FormatID::R8G8B8A8_TYPELESS:
1714             // This format is not implemented in WebGPU.
1715             break;
1716 
1717         case angle::FormatID::R8G8B8A8_TYPELESS_SRGB:
1718             // This format is not implemented in WebGPU.
1719             break;
1720 
1721         case angle::FormatID::R8G8B8A8_UINT:
1722             mIntendedGLFormat             = GL_RGBA8UI;
1723             mActualImageFormatID          = angle::FormatID::R8G8B8A8_UINT;
1724             mImageInitializerFunction     = nullptr;
1725             mIsRenderable                 = true;
1726             mActualBufferFormatID         = angle::FormatID::R8G8B8A8_UINT;
1727             mVertexLoadFunction           = CopyNativeVertexData<GLubyte, 4, 4, 0>;
1728             mVertexLoadRequiresConversion = false;
1729             break;
1730 
1731         case angle::FormatID::R8G8B8A8_UNORM:
1732             mIntendedGLFormat             = GL_RGBA8;
1733             mActualImageFormatID          = angle::FormatID::R8G8B8A8_UNORM;
1734             mImageInitializerFunction     = nullptr;
1735             mIsRenderable                 = true;
1736             mActualBufferFormatID         = angle::FormatID::R8G8B8A8_UNORM;
1737             mVertexLoadFunction           = CopyNativeVertexData<GLubyte, 4, 4, 0>;
1738             mVertexLoadRequiresConversion = false;
1739             break;
1740 
1741         case angle::FormatID::R8G8B8A8_UNORM_SRGB:
1742             mIntendedGLFormat         = GL_SRGB8_ALPHA8;
1743             mActualImageFormatID      = angle::FormatID::R8G8B8A8_UNORM_SRGB;
1744             mImageInitializerFunction = nullptr;
1745             mIsRenderable             = true;
1746 
1747             break;
1748 
1749         case angle::FormatID::R8G8B8A8_USCALED:
1750             mIntendedGLFormat = GL_RGBA8_USCALED_ANGLEX;
1751 
1752             mActualBufferFormatID         = angle::FormatID::R16G16B16A16_FLOAT;
1753             mVertexLoadFunction           = CopyToFloatVertexData<GLubyte, 4, 4, false, true>;
1754             mVertexLoadRequiresConversion = true;
1755             break;
1756 
1757         case angle::FormatID::R8G8B8X8_UNORM:
1758             mIntendedGLFormat             = GL_RGBX8_ANGLE;
1759             mActualImageFormatID          = angle::FormatID::R8G8B8A8_UNORM;
1760             mImageInitializerFunction     = nullptr;
1761             mIsRenderable                 = true;
1762             mActualBufferFormatID         = angle::FormatID::NONE;
1763             mVertexLoadFunction           = nullptr;
1764             mVertexLoadRequiresConversion = true;
1765             break;
1766 
1767         case angle::FormatID::R8G8B8X8_UNORM_SRGB:
1768             mIntendedGLFormat             = GL_RGBX8_SRGB_ANGLEX;
1769             mActualImageFormatID          = angle::FormatID::R8G8B8A8_UNORM_SRGB;
1770             mImageInitializerFunction     = nullptr;
1771             mIsRenderable                 = true;
1772             mActualBufferFormatID         = angle::FormatID::NONE;
1773             mVertexLoadFunction           = nullptr;
1774             mVertexLoadRequiresConversion = true;
1775             break;
1776 
1777         case angle::FormatID::R8G8B8_SINT:
1778             mIntendedGLFormat         = GL_RGB8I;
1779             mActualImageFormatID      = angle::FormatID::R8G8B8A8_SINT;
1780             mImageInitializerFunction = Initialize4ComponentData<GLbyte, 0x00, 0x00, 0x00, 0x01>;
1781             mIsRenderable             = true;
1782             mActualBufferFormatID     = angle::FormatID::R8G8B8A8_SINT;
1783             mVertexLoadFunction       = CopyNativeVertexData<GLbyte, 3, 4, 1>;
1784             mVertexLoadRequiresConversion = true;
1785             break;
1786 
1787         case angle::FormatID::R8G8B8_SNORM:
1788             mIntendedGLFormat         = GL_RGB8_SNORM;
1789             mActualImageFormatID      = angle::FormatID::R8G8B8A8_SNORM;
1790             mImageInitializerFunction = Initialize4ComponentData<GLbyte, 0x00, 0x00, 0x00, 0x7F>;
1791             mIsRenderable             = false;
1792             mActualBufferFormatID     = angle::FormatID::R8G8B8A8_SNORM;
1793             mVertexLoadFunction =
1794                 CopyNativeVertexData<GLbyte, 3, 4, std::numeric_limits<GLbyte>::max()>;
1795             mVertexLoadRequiresConversion = true;
1796             break;
1797 
1798         case angle::FormatID::R8G8B8_SSCALED:
1799             mIntendedGLFormat = GL_RGB8_SSCALED_ANGLEX;
1800 
1801             mActualBufferFormatID         = angle::FormatID::R16G16B16A16_FLOAT;
1802             mVertexLoadFunction           = CopyToFloatVertexData<GLbyte, 3, 4, false, true>;
1803             mVertexLoadRequiresConversion = true;
1804             break;
1805 
1806         case angle::FormatID::R8G8B8_UINT:
1807             mIntendedGLFormat         = GL_RGB8UI;
1808             mActualImageFormatID      = angle::FormatID::R8G8B8A8_UINT;
1809             mImageInitializerFunction = Initialize4ComponentData<GLubyte, 0x00, 0x00, 0x00, 0x01>;
1810             mIsRenderable             = true;
1811             mActualBufferFormatID     = angle::FormatID::R8G8B8A8_UINT;
1812             mVertexLoadFunction       = CopyNativeVertexData<GLubyte, 3, 4, 1>;
1813             mVertexLoadRequiresConversion = true;
1814             break;
1815 
1816         case angle::FormatID::R8G8B8_UNORM:
1817             mIntendedGLFormat         = GL_RGB8;
1818             mActualImageFormatID      = angle::FormatID::R8G8B8A8_UNORM;
1819             mImageInitializerFunction = Initialize4ComponentData<GLubyte, 0x00, 0x00, 0x00, 0xFF>;
1820             mIsRenderable             = true;
1821             mActualBufferFormatID     = angle::FormatID::R8G8B8A8_UNORM;
1822             mVertexLoadFunction =
1823                 CopyNativeVertexData<GLubyte, 3, 4, std::numeric_limits<GLubyte>::max()>;
1824             mVertexLoadRequiresConversion = true;
1825             break;
1826 
1827         case angle::FormatID::R8G8B8_UNORM_SRGB:
1828             mIntendedGLFormat         = GL_SRGB8;
1829             mActualImageFormatID      = angle::FormatID::R8G8B8A8_UNORM_SRGB;
1830             mImageInitializerFunction = Initialize4ComponentData<GLubyte, 0x00, 0x00, 0x00, 0xFF>;
1831             mIsRenderable             = true;
1832 
1833             break;
1834 
1835         case angle::FormatID::R8G8B8_USCALED:
1836             mIntendedGLFormat = GL_RGB8_USCALED_ANGLEX;
1837 
1838             mActualBufferFormatID         = angle::FormatID::R16G16B16A16_FLOAT;
1839             mVertexLoadFunction           = CopyToFloatVertexData<GLubyte, 3, 4, false, true>;
1840             mVertexLoadRequiresConversion = true;
1841             break;
1842 
1843         case angle::FormatID::R8G8_SINT:
1844             mIntendedGLFormat             = GL_RG8I;
1845             mActualImageFormatID          = angle::FormatID::R8G8_SINT;
1846             mImageInitializerFunction     = nullptr;
1847             mIsRenderable                 = true;
1848             mActualBufferFormatID         = angle::FormatID::R8G8_SINT;
1849             mVertexLoadFunction           = CopyNativeVertexData<GLbyte, 2, 2, 0>;
1850             mVertexLoadRequiresConversion = false;
1851             break;
1852 
1853         case angle::FormatID::R8G8_SNORM:
1854             mIntendedGLFormat             = GL_RG8_SNORM;
1855             mActualImageFormatID          = angle::FormatID::R8G8_SNORM;
1856             mImageInitializerFunction     = nullptr;
1857             mIsRenderable                 = false;
1858             mActualBufferFormatID         = angle::FormatID::R8G8_SNORM;
1859             mVertexLoadFunction           = CopyNativeVertexData<GLbyte, 2, 2, 0>;
1860             mVertexLoadRequiresConversion = false;
1861             break;
1862 
1863         case angle::FormatID::R8G8_SSCALED:
1864             mIntendedGLFormat = GL_RG8_SSCALED_ANGLEX;
1865 
1866             mActualBufferFormatID         = angle::FormatID::R16G16_FLOAT;
1867             mVertexLoadFunction           = CopyToFloatVertexData<GLbyte, 2, 2, false, true>;
1868             mVertexLoadRequiresConversion = true;
1869             break;
1870 
1871         case angle::FormatID::R8G8_UINT:
1872             mIntendedGLFormat             = GL_RG8UI;
1873             mActualImageFormatID          = angle::FormatID::R8G8_UINT;
1874             mImageInitializerFunction     = nullptr;
1875             mIsRenderable                 = true;
1876             mActualBufferFormatID         = angle::FormatID::R8G8_UINT;
1877             mVertexLoadFunction           = CopyNativeVertexData<GLubyte, 2, 2, 0>;
1878             mVertexLoadRequiresConversion = false;
1879             break;
1880 
1881         case angle::FormatID::R8G8_UNORM:
1882             mIntendedGLFormat             = GL_RG8;
1883             mActualImageFormatID          = angle::FormatID::R8G8_UNORM;
1884             mImageInitializerFunction     = nullptr;
1885             mIsRenderable                 = true;
1886             mActualBufferFormatID         = angle::FormatID::R8G8_UNORM;
1887             mVertexLoadFunction           = CopyNativeVertexData<GLubyte, 2, 2, 0>;
1888             mVertexLoadRequiresConversion = false;
1889             break;
1890 
1891         case angle::FormatID::R8G8_UNORM_SRGB:
1892             // This format is not implemented in WebGPU.
1893             break;
1894 
1895         case angle::FormatID::R8G8_USCALED:
1896             mIntendedGLFormat = GL_RG8_USCALED_ANGLEX;
1897 
1898             mActualBufferFormatID         = angle::FormatID::R16G16_FLOAT;
1899             mVertexLoadFunction           = CopyToFloatVertexData<GLubyte, 2, 2, false, true>;
1900             mVertexLoadRequiresConversion = true;
1901             break;
1902 
1903         case angle::FormatID::R8_SINT:
1904             mIntendedGLFormat         = GL_R8I;
1905             mActualImageFormatID      = angle::FormatID::R8_SINT;
1906             mImageInitializerFunction = nullptr;
1907             mIsRenderable             = true;
1908 
1909             break;
1910 
1911         case angle::FormatID::R8_SNORM:
1912             mIntendedGLFormat         = GL_R8_SNORM;
1913             mActualImageFormatID      = angle::FormatID::R8_SNORM;
1914             mImageInitializerFunction = nullptr;
1915             mIsRenderable             = false;
1916 
1917             break;
1918 
1919         case angle::FormatID::R8_SSCALED:
1920             mIntendedGLFormat = GL_R8_SSCALED_ANGLEX;
1921 
1922             mActualBufferFormatID         = angle::FormatID::R32_FLOAT;
1923             mVertexLoadFunction           = CopyToFloatVertexData<GLbyte, 1, 1, false, false>;
1924             mVertexLoadRequiresConversion = true;
1925             break;
1926 
1927         case angle::FormatID::R8_UINT:
1928             mIntendedGLFormat         = GL_R8UI;
1929             mActualImageFormatID      = angle::FormatID::R8_UINT;
1930             mImageInitializerFunction = nullptr;
1931             mIsRenderable             = true;
1932 
1933             break;
1934 
1935         case angle::FormatID::R8_UNORM:
1936             mIntendedGLFormat         = GL_R8;
1937             mActualImageFormatID      = angle::FormatID::R8_UNORM;
1938             mImageInitializerFunction = nullptr;
1939             mIsRenderable             = true;
1940 
1941             break;
1942 
1943         case angle::FormatID::R8_UNORM_SRGB:
1944             // This format is not implemented in WebGPU.
1945             break;
1946 
1947         case angle::FormatID::R8_USCALED:
1948             mIntendedGLFormat = GL_R8_USCALED_ANGLEX;
1949 
1950             mActualBufferFormatID         = angle::FormatID::R32_FLOAT;
1951             mVertexLoadFunction           = CopyToFloatVertexData<GLubyte, 1, 1, false, false>;
1952             mVertexLoadRequiresConversion = true;
1953             break;
1954 
1955         case angle::FormatID::R9G9B9E5_SHAREDEXP:
1956             mIntendedGLFormat         = GL_RGB9_E5;
1957             mActualImageFormatID      = angle::FormatID::R9G9B9E5_SHAREDEXP;
1958             mImageInitializerFunction = nullptr;
1959             mIsRenderable             = true;
1960 
1961             break;
1962 
1963         case angle::FormatID::S8_UINT:
1964             mIntendedGLFormat         = GL_STENCIL_INDEX8;
1965             mActualImageFormatID      = angle::FormatID::S8_UINT;
1966             mImageInitializerFunction = nullptr;
1967             mIsRenderable             = true;
1968 
1969             break;
1970 
1971         case angle::FormatID::X2R10G10B10_SINT_VERTEX:
1972             mIntendedGLFormat             = GL_X2_RGB10_SINT_ANGLEX;
1973             mActualImageFormatID          = angle::FormatID::NONE;
1974             mImageInitializerFunction     = nullptr;
1975             mIsRenderable                 = true;
1976             mActualBufferFormatID         = angle::FormatID::R16G16B16A16_SINT;
1977             mVertexLoadFunction           = CopyXYZ10ToXYZWFloatVertexData<true, false, true>;
1978             mVertexLoadRequiresConversion = true;
1979             break;
1980 
1981         case angle::FormatID::X2R10G10B10_SNORM_VERTEX:
1982             mIntendedGLFormat             = GL_X2_RGB10_SNORM_ANGLEX;
1983             mActualImageFormatID          = angle::FormatID::NONE;
1984             mImageInitializerFunction     = nullptr;
1985             mIsRenderable                 = false;
1986             mActualBufferFormatID         = angle::FormatID::R16G16B16A16_SNORM;
1987             mVertexLoadFunction           = CopyXYZ10ToXYZWFloatVertexData<true, true, true>;
1988             mVertexLoadRequiresConversion = true;
1989             break;
1990 
1991         case angle::FormatID::X2R10G10B10_SSCALED_VERTEX:
1992             mIntendedGLFormat             = GL_X2_RGB10_SSCALED_ANGLEX;
1993             mActualImageFormatID          = angle::FormatID::NONE;
1994             mImageInitializerFunction     = nullptr;
1995             mIsRenderable                 = true;
1996             mActualBufferFormatID         = angle::FormatID::R16G16B16A16_FLOAT;
1997             mVertexLoadFunction           = CopyXYZ10ToXYZWFloatVertexData<true, false, true>;
1998             mVertexLoadRequiresConversion = true;
1999             break;
2000 
2001         case angle::FormatID::X2R10G10B10_UINT_VERTEX:
2002             mIntendedGLFormat             = GL_X2_RGB10_UINT_ANGLEX;
2003             mActualImageFormatID          = angle::FormatID::NONE;
2004             mImageInitializerFunction     = nullptr;
2005             mIsRenderable                 = true;
2006             mActualBufferFormatID         = angle::FormatID::R16G16B16A16_UINT;
2007             mVertexLoadFunction           = CopyXYZ10ToXYZWFloatVertexData<false, false, true>;
2008             mVertexLoadRequiresConversion = true;
2009             break;
2010 
2011         case angle::FormatID::X2R10G10B10_UNORM_VERTEX:
2012             mIntendedGLFormat             = GL_X2_RGB10_UNORM_ANGLEX;
2013             mActualImageFormatID          = angle::FormatID::NONE;
2014             mImageInitializerFunction     = nullptr;
2015             mIsRenderable                 = true;
2016             mActualBufferFormatID         = angle::FormatID::R16G16B16A16_UNORM;
2017             mVertexLoadFunction           = CopyXYZ10ToXYZWFloatVertexData<false, true, true>;
2018             mVertexLoadRequiresConversion = true;
2019             break;
2020 
2021         case angle::FormatID::X2R10G10B10_USCALED_VERTEX:
2022             mIntendedGLFormat             = GL_X2_RGB10_USCALED_ANGLEX;
2023             mActualImageFormatID          = angle::FormatID::NONE;
2024             mImageInitializerFunction     = nullptr;
2025             mIsRenderable                 = true;
2026             mActualBufferFormatID         = angle::FormatID::R16G16B16A16_FLOAT;
2027             mVertexLoadFunction           = CopyXYZ10ToXYZWFloatVertexData<false, false, true>;
2028             mVertexLoadRequiresConversion = true;
2029             break;
2030 
2031         default:
2032             UNREACHABLE();
2033             break;
2034     }
2035 }
2036 
GetWgpuTextureFormatFromFormatID(angle::FormatID formatID)2037 wgpu::TextureFormat GetWgpuTextureFormatFromFormatID(angle::FormatID formatID)
2038 {
2039     static constexpr angle::FormatMap<wgpu::TextureFormat> kMap = {
2040         {angle::FormatID::ASTC_10x10_SRGB_BLOCK, wgpu::TextureFormat::ASTC10x10UnormSrgb},
2041         {angle::FormatID::ASTC_10x10_UNORM_BLOCK, wgpu::TextureFormat::ASTC10x10Unorm},
2042         {angle::FormatID::ASTC_10x5_SRGB_BLOCK, wgpu::TextureFormat::ASTC10x5UnormSrgb},
2043         {angle::FormatID::ASTC_10x5_UNORM_BLOCK, wgpu::TextureFormat::ASTC10x5Unorm},
2044         {angle::FormatID::ASTC_10x6_SRGB_BLOCK, wgpu::TextureFormat::ASTC10x6UnormSrgb},
2045         {angle::FormatID::ASTC_10x6_UNORM_BLOCK, wgpu::TextureFormat::ASTC10x6Unorm},
2046         {angle::FormatID::ASTC_10x8_SRGB_BLOCK, wgpu::TextureFormat::ASTC10x8UnormSrgb},
2047         {angle::FormatID::ASTC_10x8_UNORM_BLOCK, wgpu::TextureFormat::ASTC10x8Unorm},
2048         {angle::FormatID::ASTC_12x10_SRGB_BLOCK, wgpu::TextureFormat::ASTC12x10UnormSrgb},
2049         {angle::FormatID::ASTC_12x10_UNORM_BLOCK, wgpu::TextureFormat::ASTC12x10Unorm},
2050         {angle::FormatID::ASTC_12x12_SRGB_BLOCK, wgpu::TextureFormat::ASTC12x12UnormSrgb},
2051         {angle::FormatID::ASTC_12x12_UNORM_BLOCK, wgpu::TextureFormat::ASTC12x12Unorm},
2052         {angle::FormatID::ASTC_4x4_SRGB_BLOCK, wgpu::TextureFormat::ASTC4x4UnormSrgb},
2053         {angle::FormatID::ASTC_4x4_UNORM_BLOCK, wgpu::TextureFormat::ASTC4x4Unorm},
2054         {angle::FormatID::ASTC_5x4_SRGB_BLOCK, wgpu::TextureFormat::ASTC5x4UnormSrgb},
2055         {angle::FormatID::ASTC_5x4_UNORM_BLOCK, wgpu::TextureFormat::ASTC5x4Unorm},
2056         {angle::FormatID::ASTC_5x5_SRGB_BLOCK, wgpu::TextureFormat::ASTC5x5UnormSrgb},
2057         {angle::FormatID::ASTC_5x5_UNORM_BLOCK, wgpu::TextureFormat::ASTC5x5Unorm},
2058         {angle::FormatID::ASTC_6x5_SRGB_BLOCK, wgpu::TextureFormat::ASTC6x5UnormSrgb},
2059         {angle::FormatID::ASTC_6x5_UNORM_BLOCK, wgpu::TextureFormat::ASTC6x5Unorm},
2060         {angle::FormatID::ASTC_6x6_SRGB_BLOCK, wgpu::TextureFormat::ASTC6x6UnormSrgb},
2061         {angle::FormatID::ASTC_6x6_UNORM_BLOCK, wgpu::TextureFormat::ASTC6x6Unorm},
2062         {angle::FormatID::ASTC_8x5_SRGB_BLOCK, wgpu::TextureFormat::ASTC8x5UnormSrgb},
2063         {angle::FormatID::ASTC_8x5_UNORM_BLOCK, wgpu::TextureFormat::ASTC8x5Unorm},
2064         {angle::FormatID::ASTC_8x6_SRGB_BLOCK, wgpu::TextureFormat::ASTC8x6UnormSrgb},
2065         {angle::FormatID::ASTC_8x6_UNORM_BLOCK, wgpu::TextureFormat::ASTC8x6Unorm},
2066         {angle::FormatID::ASTC_8x8_SRGB_BLOCK, wgpu::TextureFormat::ASTC8x8UnormSrgb},
2067         {angle::FormatID::ASTC_8x8_UNORM_BLOCK, wgpu::TextureFormat::ASTC8x8Unorm},
2068         {angle::FormatID::B8G8R8A8_UNORM, wgpu::TextureFormat::BGRA8Unorm},
2069         {angle::FormatID::B8G8R8A8_UNORM_SRGB, wgpu::TextureFormat::BGRA8UnormSrgb},
2070         {angle::FormatID::BC1_RGBA_UNORM_BLOCK, wgpu::TextureFormat::BC1RGBAUnorm},
2071         {angle::FormatID::BC1_RGBA_UNORM_SRGB_BLOCK, wgpu::TextureFormat::BC1RGBAUnormSrgb},
2072         {angle::FormatID::BC2_RGBA_UNORM_BLOCK, wgpu::TextureFormat::BC2RGBAUnorm},
2073         {angle::FormatID::BC2_RGBA_UNORM_SRGB_BLOCK, wgpu::TextureFormat::BC2RGBAUnormSrgb},
2074         {angle::FormatID::BC3_RGBA_UNORM_BLOCK, wgpu::TextureFormat::BC3RGBAUnorm},
2075         {angle::FormatID::BC3_RGBA_UNORM_SRGB_BLOCK, wgpu::TextureFormat::BC3RGBAUnormSrgb},
2076         {angle::FormatID::BC4_RED_SNORM_BLOCK, wgpu::TextureFormat::BC4RSnorm},
2077         {angle::FormatID::BC4_RED_UNORM_BLOCK, wgpu::TextureFormat::BC4RUnorm},
2078         {angle::FormatID::BC5_RG_SNORM_BLOCK, wgpu::TextureFormat::BC5RGSnorm},
2079         {angle::FormatID::BC5_RG_UNORM_BLOCK, wgpu::TextureFormat::BC5RGUnorm},
2080         {angle::FormatID::BC6H_RGB_SFLOAT_BLOCK, wgpu::TextureFormat::BC6HRGBFloat},
2081         {angle::FormatID::BC6H_RGB_UFLOAT_BLOCK, wgpu::TextureFormat::BC6HRGBUfloat},
2082         {angle::FormatID::BC7_RGBA_UNORM_BLOCK, wgpu::TextureFormat::BC7RGBAUnorm},
2083         {angle::FormatID::BC7_RGBA_UNORM_SRGB_BLOCK, wgpu::TextureFormat::BC7RGBAUnormSrgb},
2084         {angle::FormatID::D16_UNORM, wgpu::TextureFormat::Depth16Unorm},
2085         {angle::FormatID::D24_UNORM_S8_UINT, wgpu::TextureFormat::Depth24PlusStencil8},
2086         {angle::FormatID::D32_FLOAT, wgpu::TextureFormat::Depth32Float},
2087         {angle::FormatID::EAC_R11G11_SNORM_BLOCK, wgpu::TextureFormat::EACRG11Snorm},
2088         {angle::FormatID::EAC_R11G11_UNORM_BLOCK, wgpu::TextureFormat::EACRG11Unorm},
2089         {angle::FormatID::EAC_R11_SNORM_BLOCK, wgpu::TextureFormat::EACR11Snorm},
2090         {angle::FormatID::EAC_R11_UNORM_BLOCK, wgpu::TextureFormat::EACR11Unorm},
2091         {angle::FormatID::ETC2_R8G8B8A1_SRGB_BLOCK, wgpu::TextureFormat::ETC2RGB8A1UnormSrgb},
2092         {angle::FormatID::ETC2_R8G8B8A1_UNORM_BLOCK, wgpu::TextureFormat::ETC2RGB8A1Unorm},
2093         {angle::FormatID::ETC2_R8G8B8A8_SRGB_BLOCK, wgpu::TextureFormat::ETC2RGBA8UnormSrgb},
2094         {angle::FormatID::ETC2_R8G8B8A8_UNORM_BLOCK, wgpu::TextureFormat::ETC2RGBA8Unorm},
2095         {angle::FormatID::ETC2_R8G8B8_SRGB_BLOCK, wgpu::TextureFormat::ETC2RGB8UnormSrgb},
2096         {angle::FormatID::ETC2_R8G8B8_UNORM_BLOCK, wgpu::TextureFormat::ETC2RGB8Unorm},
2097         {angle::FormatID::EXTERNAL0, wgpu::TextureFormat::Undefined},
2098         {angle::FormatID::EXTERNAL1, wgpu::TextureFormat::Undefined},
2099         {angle::FormatID::EXTERNAL2, wgpu::TextureFormat::Undefined},
2100         {angle::FormatID::EXTERNAL3, wgpu::TextureFormat::Undefined},
2101         {angle::FormatID::EXTERNAL4, wgpu::TextureFormat::Undefined},
2102         {angle::FormatID::EXTERNAL5, wgpu::TextureFormat::Undefined},
2103         {angle::FormatID::EXTERNAL6, wgpu::TextureFormat::Undefined},
2104         {angle::FormatID::EXTERNAL7, wgpu::TextureFormat::Undefined},
2105         {angle::FormatID::NONE, wgpu::TextureFormat::Undefined},
2106         {angle::FormatID::R10G10B10A2_SINT, wgpu::TextureFormat::RGB10A2Uint},
2107         {angle::FormatID::R10G10B10A2_UNORM, wgpu::TextureFormat::RGB10A2Unorm},
2108         {angle::FormatID::R11G11B10_FLOAT, wgpu::TextureFormat::RG11B10Ufloat},
2109         {angle::FormatID::R16G16B16A16_FLOAT, wgpu::TextureFormat::RGBA16Float},
2110         {angle::FormatID::R16G16B16A16_SINT, wgpu::TextureFormat::RGBA16Sint},
2111         {angle::FormatID::R16G16B16A16_SNORM, wgpu::TextureFormat::RGBA16Snorm},
2112         {angle::FormatID::R16G16B16A16_UINT, wgpu::TextureFormat::RGBA16Uint},
2113         {angle::FormatID::R16G16B16A16_UNORM, wgpu::TextureFormat::RGBA16Unorm},
2114         {angle::FormatID::R16G16_FLOAT, wgpu::TextureFormat::RG16Float},
2115         {angle::FormatID::R16G16_SINT, wgpu::TextureFormat::RG16Sint},
2116         {angle::FormatID::R16G16_SNORM, wgpu::TextureFormat::RG16Snorm},
2117         {angle::FormatID::R16G16_UINT, wgpu::TextureFormat::RG16Uint},
2118         {angle::FormatID::R16G16_UNORM, wgpu::TextureFormat::RG16Unorm},
2119         {angle::FormatID::R16_FLOAT, wgpu::TextureFormat::R16Float},
2120         {angle::FormatID::R16_SINT, wgpu::TextureFormat::R16Sint},
2121         {angle::FormatID::R16_SNORM, wgpu::TextureFormat::R16Snorm},
2122         {angle::FormatID::R16_UINT, wgpu::TextureFormat::R16Uint},
2123         {angle::FormatID::R16_UNORM, wgpu::TextureFormat::R16Unorm},
2124         {angle::FormatID::R32G32B32A32_FLOAT, wgpu::TextureFormat::RGBA32Float},
2125         {angle::FormatID::R32G32B32A32_SINT, wgpu::TextureFormat::RGBA32Sint},
2126         {angle::FormatID::R32G32B32A32_UINT, wgpu::TextureFormat::RGBA32Uint},
2127         {angle::FormatID::R32G32_FLOAT, wgpu::TextureFormat::RG32Float},
2128         {angle::FormatID::R32G32_SINT, wgpu::TextureFormat::RG32Sint},
2129         {angle::FormatID::R32G32_UINT, wgpu::TextureFormat::RG32Uint},
2130         {angle::FormatID::R32_FLOAT, wgpu::TextureFormat::R32Float},
2131         {angle::FormatID::R32_SINT, wgpu::TextureFormat::R32Sint},
2132         {angle::FormatID::R32_UINT, wgpu::TextureFormat::R32Uint},
2133         {angle::FormatID::R8G8B8A8_SINT, wgpu::TextureFormat::RGBA8Sint},
2134         {angle::FormatID::R8G8B8A8_SNORM, wgpu::TextureFormat::RGBA8Snorm},
2135         {angle::FormatID::R8G8B8A8_UINT, wgpu::TextureFormat::RGBA8Uint},
2136         {angle::FormatID::R8G8B8A8_UNORM, wgpu::TextureFormat::RGBA8Unorm},
2137         {angle::FormatID::R8G8B8A8_UNORM_SRGB, wgpu::TextureFormat::RGBA8UnormSrgb},
2138         {angle::FormatID::R8G8_SINT, wgpu::TextureFormat::RG8Sint},
2139         {angle::FormatID::R8G8_SNORM, wgpu::TextureFormat::RG8Snorm},
2140         {angle::FormatID::R8G8_UINT, wgpu::TextureFormat::RG8Uint},
2141         {angle::FormatID::R8G8_UNORM, wgpu::TextureFormat::RG8Unorm},
2142         {angle::FormatID::R8_SINT, wgpu::TextureFormat::R8Sint},
2143         {angle::FormatID::R8_SNORM, wgpu::TextureFormat::R8Snorm},
2144         {angle::FormatID::R8_UINT, wgpu::TextureFormat::R8Uint},
2145         {angle::FormatID::R8_UNORM, wgpu::TextureFormat::R8Unorm},
2146         {angle::FormatID::R9G9B9E5_SHAREDEXP, wgpu::TextureFormat::RGB9E5Ufloat},
2147         {angle::FormatID::S8_UINT, wgpu::TextureFormat::Stencil8}};
2148 
2149     return kMap[formatID];
2150 }
2151 
GetFormatIDFromWgpuTextureFormat(wgpu::TextureFormat wgpuFormat)2152 angle::FormatID GetFormatIDFromWgpuTextureFormat(wgpu::TextureFormat wgpuFormat)
2153 {
2154     switch (wgpuFormat)
2155     {
2156         case wgpu::TextureFormat::ASTC10x10UnormSrgb:
2157             return angle::FormatID::ASTC_10x10_SRGB_BLOCK;
2158         case wgpu::TextureFormat::ASTC10x10Unorm:
2159             return angle::FormatID::ASTC_10x10_UNORM_BLOCK;
2160         case wgpu::TextureFormat::ASTC10x5UnormSrgb:
2161             return angle::FormatID::ASTC_10x5_SRGB_BLOCK;
2162         case wgpu::TextureFormat::ASTC10x5Unorm:
2163             return angle::FormatID::ASTC_10x5_UNORM_BLOCK;
2164         case wgpu::TextureFormat::ASTC10x6UnormSrgb:
2165             return angle::FormatID::ASTC_10x6_SRGB_BLOCK;
2166         case wgpu::TextureFormat::ASTC10x6Unorm:
2167             return angle::FormatID::ASTC_10x6_UNORM_BLOCK;
2168         case wgpu::TextureFormat::ASTC10x8UnormSrgb:
2169             return angle::FormatID::ASTC_10x8_SRGB_BLOCK;
2170         case wgpu::TextureFormat::ASTC10x8Unorm:
2171             return angle::FormatID::ASTC_10x8_UNORM_BLOCK;
2172         case wgpu::TextureFormat::ASTC12x10UnormSrgb:
2173             return angle::FormatID::ASTC_12x10_SRGB_BLOCK;
2174         case wgpu::TextureFormat::ASTC12x10Unorm:
2175             return angle::FormatID::ASTC_12x10_UNORM_BLOCK;
2176         case wgpu::TextureFormat::ASTC12x12UnormSrgb:
2177             return angle::FormatID::ASTC_12x12_SRGB_BLOCK;
2178         case wgpu::TextureFormat::ASTC12x12Unorm:
2179             return angle::FormatID::ASTC_12x12_UNORM_BLOCK;
2180         case wgpu::TextureFormat::ASTC4x4UnormSrgb:
2181             return angle::FormatID::ASTC_4x4_SRGB_BLOCK;
2182         case wgpu::TextureFormat::ASTC4x4Unorm:
2183             return angle::FormatID::ASTC_4x4_UNORM_BLOCK;
2184         case wgpu::TextureFormat::ASTC5x4UnormSrgb:
2185             return angle::FormatID::ASTC_5x4_SRGB_BLOCK;
2186         case wgpu::TextureFormat::ASTC5x4Unorm:
2187             return angle::FormatID::ASTC_5x4_UNORM_BLOCK;
2188         case wgpu::TextureFormat::ASTC5x5UnormSrgb:
2189             return angle::FormatID::ASTC_5x5_SRGB_BLOCK;
2190         case wgpu::TextureFormat::ASTC5x5Unorm:
2191             return angle::FormatID::ASTC_5x5_UNORM_BLOCK;
2192         case wgpu::TextureFormat::ASTC6x5UnormSrgb:
2193             return angle::FormatID::ASTC_6x5_SRGB_BLOCK;
2194         case wgpu::TextureFormat::ASTC6x5Unorm:
2195             return angle::FormatID::ASTC_6x5_UNORM_BLOCK;
2196         case wgpu::TextureFormat::ASTC6x6UnormSrgb:
2197             return angle::FormatID::ASTC_6x6_SRGB_BLOCK;
2198         case wgpu::TextureFormat::ASTC6x6Unorm:
2199             return angle::FormatID::ASTC_6x6_UNORM_BLOCK;
2200         case wgpu::TextureFormat::ASTC8x5UnormSrgb:
2201             return angle::FormatID::ASTC_8x5_SRGB_BLOCK;
2202         case wgpu::TextureFormat::ASTC8x5Unorm:
2203             return angle::FormatID::ASTC_8x5_UNORM_BLOCK;
2204         case wgpu::TextureFormat::ASTC8x6UnormSrgb:
2205             return angle::FormatID::ASTC_8x6_SRGB_BLOCK;
2206         case wgpu::TextureFormat::ASTC8x6Unorm:
2207             return angle::FormatID::ASTC_8x6_UNORM_BLOCK;
2208         case wgpu::TextureFormat::ASTC8x8UnormSrgb:
2209             return angle::FormatID::ASTC_8x8_SRGB_BLOCK;
2210         case wgpu::TextureFormat::ASTC8x8Unorm:
2211             return angle::FormatID::ASTC_8x8_UNORM_BLOCK;
2212         case wgpu::TextureFormat::BGRA8Unorm:
2213             return angle::FormatID::B8G8R8A8_UNORM;
2214         case wgpu::TextureFormat::BGRA8UnormSrgb:
2215             return angle::FormatID::B8G8R8A8_UNORM_SRGB;
2216         case wgpu::TextureFormat::BC1RGBAUnorm:
2217             return angle::FormatID::BC1_RGBA_UNORM_BLOCK;
2218         case wgpu::TextureFormat::BC1RGBAUnormSrgb:
2219             return angle::FormatID::BC1_RGBA_UNORM_SRGB_BLOCK;
2220         case wgpu::TextureFormat::BC2RGBAUnorm:
2221             return angle::FormatID::BC2_RGBA_UNORM_BLOCK;
2222         case wgpu::TextureFormat::BC2RGBAUnormSrgb:
2223             return angle::FormatID::BC2_RGBA_UNORM_SRGB_BLOCK;
2224         case wgpu::TextureFormat::BC3RGBAUnorm:
2225             return angle::FormatID::BC3_RGBA_UNORM_BLOCK;
2226         case wgpu::TextureFormat::BC3RGBAUnormSrgb:
2227             return angle::FormatID::BC3_RGBA_UNORM_SRGB_BLOCK;
2228         case wgpu::TextureFormat::BC4RSnorm:
2229             return angle::FormatID::BC4_RED_SNORM_BLOCK;
2230         case wgpu::TextureFormat::BC4RUnorm:
2231             return angle::FormatID::BC4_RED_UNORM_BLOCK;
2232         case wgpu::TextureFormat::BC5RGSnorm:
2233             return angle::FormatID::BC5_RG_SNORM_BLOCK;
2234         case wgpu::TextureFormat::BC5RGUnorm:
2235             return angle::FormatID::BC5_RG_UNORM_BLOCK;
2236         case wgpu::TextureFormat::BC6HRGBFloat:
2237             return angle::FormatID::BC6H_RGB_SFLOAT_BLOCK;
2238         case wgpu::TextureFormat::BC6HRGBUfloat:
2239             return angle::FormatID::BC6H_RGB_UFLOAT_BLOCK;
2240         case wgpu::TextureFormat::BC7RGBAUnorm:
2241             return angle::FormatID::BC7_RGBA_UNORM_BLOCK;
2242         case wgpu::TextureFormat::BC7RGBAUnormSrgb:
2243             return angle::FormatID::BC7_RGBA_UNORM_SRGB_BLOCK;
2244         case wgpu::TextureFormat::Depth16Unorm:
2245             return angle::FormatID::D16_UNORM;
2246         case wgpu::TextureFormat::Depth24PlusStencil8:
2247             return angle::FormatID::D24_UNORM_S8_UINT;
2248         case wgpu::TextureFormat::Depth32Float:
2249             return angle::FormatID::D32_FLOAT;
2250         case wgpu::TextureFormat::EACRG11Snorm:
2251             return angle::FormatID::EAC_R11G11_SNORM_BLOCK;
2252         case wgpu::TextureFormat::EACRG11Unorm:
2253             return angle::FormatID::EAC_R11G11_UNORM_BLOCK;
2254         case wgpu::TextureFormat::EACR11Snorm:
2255             return angle::FormatID::EAC_R11_SNORM_BLOCK;
2256         case wgpu::TextureFormat::EACR11Unorm:
2257             return angle::FormatID::EAC_R11_UNORM_BLOCK;
2258         case wgpu::TextureFormat::ETC2RGB8A1UnormSrgb:
2259             return angle::FormatID::ETC2_R8G8B8A1_SRGB_BLOCK;
2260         case wgpu::TextureFormat::ETC2RGB8A1Unorm:
2261             return angle::FormatID::ETC2_R8G8B8A1_UNORM_BLOCK;
2262         case wgpu::TextureFormat::ETC2RGBA8UnormSrgb:
2263             return angle::FormatID::ETC2_R8G8B8A8_SRGB_BLOCK;
2264         case wgpu::TextureFormat::ETC2RGBA8Unorm:
2265             return angle::FormatID::ETC2_R8G8B8A8_UNORM_BLOCK;
2266         case wgpu::TextureFormat::ETC2RGB8UnormSrgb:
2267             return angle::FormatID::ETC2_R8G8B8_SRGB_BLOCK;
2268         case wgpu::TextureFormat::ETC2RGB8Unorm:
2269             return angle::FormatID::ETC2_R8G8B8_UNORM_BLOCK;
2270         case wgpu::TextureFormat::Undefined:
2271             return angle::FormatID::NONE;
2272         case wgpu::TextureFormat::RGB10A2Uint:
2273             return angle::FormatID::R10G10B10A2_SINT;
2274         case wgpu::TextureFormat::RGB10A2Unorm:
2275             return angle::FormatID::R10G10B10A2_UNORM;
2276         case wgpu::TextureFormat::RG11B10Ufloat:
2277             return angle::FormatID::R11G11B10_FLOAT;
2278         case wgpu::TextureFormat::RGBA16Float:
2279             return angle::FormatID::R16G16B16A16_FLOAT;
2280         case wgpu::TextureFormat::RGBA16Sint:
2281             return angle::FormatID::R16G16B16A16_SINT;
2282         case wgpu::TextureFormat::RGBA16Snorm:
2283             return angle::FormatID::R16G16B16A16_SNORM;
2284         case wgpu::TextureFormat::RGBA16Uint:
2285             return angle::FormatID::R16G16B16A16_UINT;
2286         case wgpu::TextureFormat::RGBA16Unorm:
2287             return angle::FormatID::R16G16B16A16_UNORM;
2288         case wgpu::TextureFormat::RG16Float:
2289             return angle::FormatID::R16G16_FLOAT;
2290         case wgpu::TextureFormat::RG16Sint:
2291             return angle::FormatID::R16G16_SINT;
2292         case wgpu::TextureFormat::RG16Snorm:
2293             return angle::FormatID::R16G16_SNORM;
2294         case wgpu::TextureFormat::RG16Uint:
2295             return angle::FormatID::R16G16_UINT;
2296         case wgpu::TextureFormat::RG16Unorm:
2297             return angle::FormatID::R16G16_UNORM;
2298         case wgpu::TextureFormat::R16Float:
2299             return angle::FormatID::R16_FLOAT;
2300         case wgpu::TextureFormat::R16Sint:
2301             return angle::FormatID::R16_SINT;
2302         case wgpu::TextureFormat::R16Snorm:
2303             return angle::FormatID::R16_SNORM;
2304         case wgpu::TextureFormat::R16Uint:
2305             return angle::FormatID::R16_UINT;
2306         case wgpu::TextureFormat::R16Unorm:
2307             return angle::FormatID::R16_UNORM;
2308         case wgpu::TextureFormat::RGBA32Float:
2309             return angle::FormatID::R32G32B32A32_FLOAT;
2310         case wgpu::TextureFormat::RGBA32Sint:
2311             return angle::FormatID::R32G32B32A32_SINT;
2312         case wgpu::TextureFormat::RGBA32Uint:
2313             return angle::FormatID::R32G32B32A32_UINT;
2314         case wgpu::TextureFormat::RG32Float:
2315             return angle::FormatID::R32G32_FLOAT;
2316         case wgpu::TextureFormat::RG32Sint:
2317             return angle::FormatID::R32G32_SINT;
2318         case wgpu::TextureFormat::RG32Uint:
2319             return angle::FormatID::R32G32_UINT;
2320         case wgpu::TextureFormat::R32Float:
2321             return angle::FormatID::R32_FLOAT;
2322         case wgpu::TextureFormat::R32Sint:
2323             return angle::FormatID::R32_SINT;
2324         case wgpu::TextureFormat::R32Uint:
2325             return angle::FormatID::R32_UINT;
2326         case wgpu::TextureFormat::RGBA8Sint:
2327             return angle::FormatID::R8G8B8A8_SINT;
2328         case wgpu::TextureFormat::RGBA8Snorm:
2329             return angle::FormatID::R8G8B8A8_SNORM;
2330         case wgpu::TextureFormat::RGBA8Uint:
2331             return angle::FormatID::R8G8B8A8_UINT;
2332         case wgpu::TextureFormat::RGBA8Unorm:
2333             return angle::FormatID::R8G8B8A8_UNORM;
2334         case wgpu::TextureFormat::RGBA8UnormSrgb:
2335             return angle::FormatID::R8G8B8A8_UNORM_SRGB;
2336         case wgpu::TextureFormat::RG8Sint:
2337             return angle::FormatID::R8G8_SINT;
2338         case wgpu::TextureFormat::RG8Snorm:
2339             return angle::FormatID::R8G8_SNORM;
2340         case wgpu::TextureFormat::RG8Uint:
2341             return angle::FormatID::R8G8_UINT;
2342         case wgpu::TextureFormat::RG8Unorm:
2343             return angle::FormatID::R8G8_UNORM;
2344         case wgpu::TextureFormat::R8Sint:
2345             return angle::FormatID::R8_SINT;
2346         case wgpu::TextureFormat::R8Snorm:
2347             return angle::FormatID::R8_SNORM;
2348         case wgpu::TextureFormat::R8Uint:
2349             return angle::FormatID::R8_UINT;
2350         case wgpu::TextureFormat::R8Unorm:
2351             return angle::FormatID::R8_UNORM;
2352         case wgpu::TextureFormat::RGB9E5Ufloat:
2353             return angle::FormatID::R9G9B9E5_SHAREDEXP;
2354         case wgpu::TextureFormat::Stencil8:
2355             return angle::FormatID::S8_UINT;
2356 
2357         default:
2358             UNREACHABLE();
2359             return angle::FormatID::NONE;
2360     }
2361 }
2362 
GetWgpuVertexFormatFromFormatID(angle::FormatID formatID)2363 wgpu::VertexFormat GetWgpuVertexFormatFromFormatID(angle::FormatID formatID)
2364 {
2365     static constexpr angle::FormatMap<wgpu::VertexFormat> kMap = {
2366         {angle::FormatID::EXTERNAL0, wgpu::VertexFormat(0u)},
2367         {angle::FormatID::EXTERNAL1, wgpu::VertexFormat(0u)},
2368         {angle::FormatID::EXTERNAL2, wgpu::VertexFormat(0u)},
2369         {angle::FormatID::EXTERNAL3, wgpu::VertexFormat(0u)},
2370         {angle::FormatID::EXTERNAL4, wgpu::VertexFormat(0u)},
2371         {angle::FormatID::EXTERNAL5, wgpu::VertexFormat(0u)},
2372         {angle::FormatID::EXTERNAL6, wgpu::VertexFormat(0u)},
2373         {angle::FormatID::EXTERNAL7, wgpu::VertexFormat(0u)},
2374         {angle::FormatID::NONE, wgpu::VertexFormat(0u)},
2375         {angle::FormatID::R10G10B10A2_UNORM, wgpu::VertexFormat::Unorm10_10_10_2},
2376         {angle::FormatID::R16G16B16A16_FLOAT, wgpu::VertexFormat::Float16x4},
2377         {angle::FormatID::R16G16B16A16_SINT, wgpu::VertexFormat::Sint16x4},
2378         {angle::FormatID::R16G16B16A16_SNORM, wgpu::VertexFormat::Snorm16x4},
2379         {angle::FormatID::R16G16B16A16_UINT, wgpu::VertexFormat::Uint16x4},
2380         {angle::FormatID::R16G16B16A16_UNORM, wgpu::VertexFormat::Unorm16x4},
2381         {angle::FormatID::R16G16_FLOAT, wgpu::VertexFormat::Float16x2},
2382         {angle::FormatID::R16G16_SINT, wgpu::VertexFormat::Sint16x2},
2383         {angle::FormatID::R16G16_SNORM, wgpu::VertexFormat::Snorm16x2},
2384         {angle::FormatID::R16G16_UINT, wgpu::VertexFormat::Uint16x2},
2385         {angle::FormatID::R16G16_UNORM, wgpu::VertexFormat::Unorm16x2},
2386         {angle::FormatID::R32G32B32A32_FLOAT, wgpu::VertexFormat::Float32x4},
2387         {angle::FormatID::R32G32B32A32_SINT, wgpu::VertexFormat::Sint32x4},
2388         {angle::FormatID::R32G32B32A32_UINT, wgpu::VertexFormat::Uint32x4},
2389         {angle::FormatID::R32G32B32_FLOAT, wgpu::VertexFormat::Float32x3},
2390         {angle::FormatID::R32G32B32_SINT, wgpu::VertexFormat::Sint32x3},
2391         {angle::FormatID::R32G32B32_UINT, wgpu::VertexFormat::Uint32x3},
2392         {angle::FormatID::R32G32_FLOAT, wgpu::VertexFormat::Float32x2},
2393         {angle::FormatID::R32G32_SINT, wgpu::VertexFormat::Sint32x2},
2394         {angle::FormatID::R32G32_UINT, wgpu::VertexFormat::Uint32x2},
2395         {angle::FormatID::R32_FLOAT, wgpu::VertexFormat::Float32},
2396         {angle::FormatID::R32_SINT, wgpu::VertexFormat::Sint32},
2397         {angle::FormatID::R32_UINT, wgpu::VertexFormat::Uint32},
2398         {angle::FormatID::R8G8B8A8_SINT, wgpu::VertexFormat::Sint8x4},
2399         {angle::FormatID::R8G8B8A8_SNORM, wgpu::VertexFormat::Snorm8x4},
2400         {angle::FormatID::R8G8B8A8_UINT, wgpu::VertexFormat::Uint8x4},
2401         {angle::FormatID::R8G8B8A8_UNORM, wgpu::VertexFormat::Unorm8x4},
2402         {angle::FormatID::R8G8_SINT, wgpu::VertexFormat::Sint8x2},
2403         {angle::FormatID::R8G8_SNORM, wgpu::VertexFormat::Snorm8x2},
2404         {angle::FormatID::R8G8_UINT, wgpu::VertexFormat::Uint8x2},
2405         {angle::FormatID::R8G8_UNORM, wgpu::VertexFormat::Unorm8x2}};
2406 
2407     return kMap[formatID];
2408 }
2409 
GetFormatIDFromWgpuBufferFormat(wgpu::VertexFormat wgpuFormat)2410 angle::FormatID GetFormatIDFromWgpuBufferFormat(wgpu::VertexFormat wgpuFormat)
2411 {
2412     switch (wgpuFormat)
2413     {
2414         case wgpu::VertexFormat::Unorm10_10_10_2:
2415             return angle::FormatID::R10G10B10A2_UNORM;
2416         case wgpu::VertexFormat::Float16x4:
2417             return angle::FormatID::R16G16B16A16_FLOAT;
2418         case wgpu::VertexFormat::Sint16x4:
2419             return angle::FormatID::R16G16B16A16_SINT;
2420         case wgpu::VertexFormat::Snorm16x4:
2421             return angle::FormatID::R16G16B16A16_SNORM;
2422         case wgpu::VertexFormat::Uint16x4:
2423             return angle::FormatID::R16G16B16A16_UINT;
2424         case wgpu::VertexFormat::Unorm16x4:
2425             return angle::FormatID::R16G16B16A16_UNORM;
2426         case wgpu::VertexFormat::Float16x2:
2427             return angle::FormatID::R16G16_FLOAT;
2428         case wgpu::VertexFormat::Sint16x2:
2429             return angle::FormatID::R16G16_SINT;
2430         case wgpu::VertexFormat::Snorm16x2:
2431             return angle::FormatID::R16G16_SNORM;
2432         case wgpu::VertexFormat::Uint16x2:
2433             return angle::FormatID::R16G16_UINT;
2434         case wgpu::VertexFormat::Unorm16x2:
2435             return angle::FormatID::R16G16_UNORM;
2436         case wgpu::VertexFormat::Float32x4:
2437             return angle::FormatID::R32G32B32A32_FLOAT;
2438         case wgpu::VertexFormat::Sint32x4:
2439             return angle::FormatID::R32G32B32A32_SINT;
2440         case wgpu::VertexFormat::Uint32x4:
2441             return angle::FormatID::R32G32B32A32_UINT;
2442         case wgpu::VertexFormat::Float32x3:
2443             return angle::FormatID::R32G32B32_FLOAT;
2444         case wgpu::VertexFormat::Sint32x3:
2445             return angle::FormatID::R32G32B32_SINT;
2446         case wgpu::VertexFormat::Uint32x3:
2447             return angle::FormatID::R32G32B32_UINT;
2448         case wgpu::VertexFormat::Float32x2:
2449             return angle::FormatID::R32G32_FLOAT;
2450         case wgpu::VertexFormat::Sint32x2:
2451             return angle::FormatID::R32G32_SINT;
2452         case wgpu::VertexFormat::Uint32x2:
2453             return angle::FormatID::R32G32_UINT;
2454         case wgpu::VertexFormat::Float32:
2455             return angle::FormatID::R32_FLOAT;
2456         case wgpu::VertexFormat::Sint32:
2457             return angle::FormatID::R32_SINT;
2458         case wgpu::VertexFormat::Uint32:
2459             return angle::FormatID::R32_UINT;
2460         case wgpu::VertexFormat::Sint8x4:
2461             return angle::FormatID::R8G8B8A8_SINT;
2462         case wgpu::VertexFormat::Snorm8x4:
2463             return angle::FormatID::R8G8B8A8_SNORM;
2464         case wgpu::VertexFormat::Uint8x4:
2465             return angle::FormatID::R8G8B8A8_UINT;
2466         case wgpu::VertexFormat::Unorm8x4:
2467             return angle::FormatID::R8G8B8A8_UNORM;
2468         case wgpu::VertexFormat::Sint8x2:
2469             return angle::FormatID::R8G8_SINT;
2470         case wgpu::VertexFormat::Snorm8x2:
2471             return angle::FormatID::R8G8_SNORM;
2472         case wgpu::VertexFormat::Uint8x2:
2473             return angle::FormatID::R8G8_UINT;
2474         case wgpu::VertexFormat::Unorm8x2:
2475             return angle::FormatID::R8G8_UNORM;
2476 
2477         default:
2478             UNREACHABLE();
2479             return angle::FormatID::NONE;
2480     }
2481 }
2482 }  // namespace webgpu
2483 }  // namespace rx
2484