1 //
2 // Copyright 2013 The ANGLE Project Authors. All rights reserved.
3 // Use of this source code is governed by a BSD-style license that can be
4 // found in the LICENSE file.
5 //
6
7 // formatutils11.cpp: Queries for GL image formats and their translations to D3D11
8 // formats.
9
10 #include "libANGLE/renderer/d3d/d3d11/formatutils11.h"
11
12 #include "image_util/copyimage.h"
13 #include "image_util/generatemip.h"
14 #include "image_util/loadimage.h"
15
16 #include "libANGLE/formatutils.h"
17 #include "libANGLE/renderer/copyvertex.h"
18 #include "libANGLE/renderer/d3d/d3d11/Renderer11.h"
19 #include "libANGLE/renderer/d3d/d3d11/renderer11_utils.h"
20 #include "libANGLE/renderer/dxgi_support_table.h"
21
22 namespace rx
23 {
24
25 namespace d3d11
26 {
27
SupportsMipGen(DXGI_FORMAT dxgiFormat,D3D_FEATURE_LEVEL featureLevel)28 bool SupportsMipGen(DXGI_FORMAT dxgiFormat, D3D_FEATURE_LEVEL featureLevel)
29 {
30 const auto &support = GetDXGISupport(dxgiFormat, featureLevel);
31 ASSERT((support.optionallySupportedFlags & D3D11_FORMAT_SUPPORT_MIP_AUTOGEN) == 0);
32 return ((support.alwaysSupportedFlags & D3D11_FORMAT_SUPPORT_MIP_AUTOGEN) != 0);
33 }
34
DXGIFormatSize(GLuint pixelBits,GLuint blockWidth,GLuint blockHeight)35 DXGIFormatSize::DXGIFormatSize(GLuint pixelBits, GLuint blockWidth, GLuint blockHeight)
36 : pixelBytes(pixelBits / 8), blockWidth(blockWidth), blockHeight(blockHeight)
37 {}
38
GetDXGIFormatSizeInfo(DXGI_FORMAT format)39 const DXGIFormatSize &GetDXGIFormatSizeInfo(DXGI_FORMAT format)
40 {
41 static const DXGIFormatSize sizeUnknown(0, 0, 0);
42 static const DXGIFormatSize size128(128, 1, 1);
43 static const DXGIFormatSize size96(96, 1, 1);
44 static const DXGIFormatSize size64(64, 1, 1);
45 static const DXGIFormatSize size32(32, 1, 1);
46 static const DXGIFormatSize size16(16, 1, 1);
47 static const DXGIFormatSize size8(8, 1, 1);
48 static const DXGIFormatSize sizeBC1(64, 4, 4);
49 static const DXGIFormatSize sizeBC2(128, 4, 4);
50 static const DXGIFormatSize sizeBC3(128, 4, 4);
51 static const DXGIFormatSize sizeBC4(64, 4, 4);
52 static const DXGIFormatSize sizeBC5(128, 4, 4);
53 static const DXGIFormatSize sizeBC6H(128, 4, 4);
54 static const DXGIFormatSize sizeBC7(128, 4, 4);
55 switch (format)
56 {
57 case DXGI_FORMAT_UNKNOWN:
58 return sizeUnknown;
59 case DXGI_FORMAT_R32G32B32A32_TYPELESS:
60 case DXGI_FORMAT_R32G32B32A32_FLOAT:
61 case DXGI_FORMAT_R32G32B32A32_UINT:
62 case DXGI_FORMAT_R32G32B32A32_SINT:
63 return size128;
64 case DXGI_FORMAT_R32G32B32_TYPELESS:
65 case DXGI_FORMAT_R32G32B32_FLOAT:
66 case DXGI_FORMAT_R32G32B32_UINT:
67 case DXGI_FORMAT_R32G32B32_SINT:
68 return size96;
69 case DXGI_FORMAT_R16G16B16A16_TYPELESS:
70 case DXGI_FORMAT_R16G16B16A16_FLOAT:
71 case DXGI_FORMAT_R16G16B16A16_UNORM:
72 case DXGI_FORMAT_R16G16B16A16_UINT:
73 case DXGI_FORMAT_R16G16B16A16_SNORM:
74 case DXGI_FORMAT_R16G16B16A16_SINT:
75 case DXGI_FORMAT_R32G32_TYPELESS:
76 case DXGI_FORMAT_R32G32_FLOAT:
77 case DXGI_FORMAT_R32G32_UINT:
78 case DXGI_FORMAT_R32G32_SINT:
79 case DXGI_FORMAT_R32G8X24_TYPELESS:
80 case DXGI_FORMAT_D32_FLOAT_S8X24_UINT:
81 case DXGI_FORMAT_R32_FLOAT_X8X24_TYPELESS:
82 case DXGI_FORMAT_X32_TYPELESS_G8X24_UINT:
83 return size64;
84 case DXGI_FORMAT_R10G10B10A2_TYPELESS:
85 case DXGI_FORMAT_R10G10B10A2_UNORM:
86 case DXGI_FORMAT_R10G10B10A2_UINT:
87 case DXGI_FORMAT_R11G11B10_FLOAT:
88 case DXGI_FORMAT_R8G8B8A8_TYPELESS:
89 case DXGI_FORMAT_R8G8B8A8_UNORM:
90 case DXGI_FORMAT_R8G8B8A8_UNORM_SRGB:
91 case DXGI_FORMAT_R8G8B8A8_UINT:
92 case DXGI_FORMAT_R8G8B8A8_SNORM:
93 case DXGI_FORMAT_R8G8B8A8_SINT:
94 case DXGI_FORMAT_R16G16_TYPELESS:
95 case DXGI_FORMAT_R16G16_FLOAT:
96 case DXGI_FORMAT_R16G16_UNORM:
97 case DXGI_FORMAT_R16G16_UINT:
98 case DXGI_FORMAT_R16G16_SNORM:
99 case DXGI_FORMAT_R16G16_SINT:
100 case DXGI_FORMAT_R32_TYPELESS:
101 case DXGI_FORMAT_D32_FLOAT:
102 case DXGI_FORMAT_R32_FLOAT:
103 case DXGI_FORMAT_R32_UINT:
104 case DXGI_FORMAT_R32_SINT:
105 case DXGI_FORMAT_R24G8_TYPELESS:
106 case DXGI_FORMAT_D24_UNORM_S8_UINT:
107 case DXGI_FORMAT_R24_UNORM_X8_TYPELESS:
108 case DXGI_FORMAT_X24_TYPELESS_G8_UINT:
109 return size32;
110 case DXGI_FORMAT_R8G8_TYPELESS:
111 case DXGI_FORMAT_R8G8_UNORM:
112 case DXGI_FORMAT_R8G8_UINT:
113 case DXGI_FORMAT_R8G8_SNORM:
114 case DXGI_FORMAT_R8G8_SINT:
115 case DXGI_FORMAT_R16_TYPELESS:
116 case DXGI_FORMAT_R16_FLOAT:
117 case DXGI_FORMAT_D16_UNORM:
118 case DXGI_FORMAT_R16_UNORM:
119 case DXGI_FORMAT_R16_UINT:
120 case DXGI_FORMAT_R16_SNORM:
121 case DXGI_FORMAT_R16_SINT:
122 return size16;
123 case DXGI_FORMAT_R8_TYPELESS:
124 case DXGI_FORMAT_R8_UNORM:
125 case DXGI_FORMAT_R8_UINT:
126 case DXGI_FORMAT_R8_SNORM:
127 case DXGI_FORMAT_R8_SINT:
128 case DXGI_FORMAT_A8_UNORM:
129 return size8;
130 case DXGI_FORMAT_R1_UNORM:
131 UNREACHABLE();
132 return sizeUnknown;
133 case DXGI_FORMAT_R9G9B9E5_SHAREDEXP:
134 case DXGI_FORMAT_R8G8_B8G8_UNORM:
135 case DXGI_FORMAT_G8R8_G8B8_UNORM:
136 return size32;
137 case DXGI_FORMAT_BC1_TYPELESS:
138 case DXGI_FORMAT_BC1_UNORM:
139 case DXGI_FORMAT_BC1_UNORM_SRGB:
140 return sizeBC1;
141 case DXGI_FORMAT_BC2_TYPELESS:
142 case DXGI_FORMAT_BC2_UNORM:
143 case DXGI_FORMAT_BC2_UNORM_SRGB:
144 return sizeBC2;
145 case DXGI_FORMAT_BC3_TYPELESS:
146 case DXGI_FORMAT_BC3_UNORM:
147 case DXGI_FORMAT_BC3_UNORM_SRGB:
148 return sizeBC3;
149 case DXGI_FORMAT_BC4_TYPELESS:
150 case DXGI_FORMAT_BC4_UNORM:
151 case DXGI_FORMAT_BC4_SNORM:
152 return sizeBC4;
153 case DXGI_FORMAT_BC5_TYPELESS:
154 case DXGI_FORMAT_BC5_UNORM:
155 case DXGI_FORMAT_BC5_SNORM:
156 return sizeBC5;
157 case DXGI_FORMAT_B5G6R5_UNORM:
158 case DXGI_FORMAT_B5G5R5A1_UNORM:
159 return size16;
160 case DXGI_FORMAT_B8G8R8A8_UNORM:
161 case DXGI_FORMAT_B8G8R8X8_UNORM:
162 case DXGI_FORMAT_R10G10B10_XR_BIAS_A2_UNORM:
163 case DXGI_FORMAT_B8G8R8A8_TYPELESS:
164 case DXGI_FORMAT_B8G8R8A8_UNORM_SRGB:
165 case DXGI_FORMAT_B8G8R8X8_TYPELESS:
166 case DXGI_FORMAT_B8G8R8X8_UNORM_SRGB:
167 return size32;
168 case DXGI_FORMAT_BC6H_TYPELESS:
169 case DXGI_FORMAT_BC6H_UF16:
170 case DXGI_FORMAT_BC6H_SF16:
171 return sizeBC6H;
172 case DXGI_FORMAT_BC7_TYPELESS:
173 case DXGI_FORMAT_BC7_UNORM:
174 case DXGI_FORMAT_BC7_UNORM_SRGB:
175 return sizeBC7;
176 case DXGI_FORMAT_AYUV:
177 case DXGI_FORMAT_Y410:
178 case DXGI_FORMAT_Y416:
179 case DXGI_FORMAT_NV12:
180 case DXGI_FORMAT_P010:
181 case DXGI_FORMAT_P016:
182 case DXGI_FORMAT_420_OPAQUE:
183 case DXGI_FORMAT_YUY2:
184 case DXGI_FORMAT_Y210:
185 case DXGI_FORMAT_Y216:
186 case DXGI_FORMAT_NV11:
187 case DXGI_FORMAT_AI44:
188 case DXGI_FORMAT_IA44:
189 case DXGI_FORMAT_P8:
190 case DXGI_FORMAT_A8P8:
191 UNREACHABLE();
192 return sizeUnknown;
193 case DXGI_FORMAT_B4G4R4A4_UNORM:
194 return size16;
195 default:
196 UNREACHABLE();
197 return sizeUnknown;
198 }
199 }
200
VertexFormat()201 constexpr VertexFormat::VertexFormat()
202 : conversionType(VERTEX_CONVERT_NONE), nativeFormat(DXGI_FORMAT_UNKNOWN), copyFunction(nullptr)
203 {}
204
VertexFormat(VertexConversionType conversionTypeIn,DXGI_FORMAT nativeFormatIn,VertexCopyFunction copyFunctionIn)205 constexpr VertexFormat::VertexFormat(VertexConversionType conversionTypeIn,
206 DXGI_FORMAT nativeFormatIn,
207 VertexCopyFunction copyFunctionIn)
208 : conversionType(conversionTypeIn), nativeFormat(nativeFormatIn), copyFunction(copyFunctionIn)
209 {}
210
GetVertexFormatInfo_FL_9_3(angle::FormatID vertexFormatID)211 const VertexFormat *GetVertexFormatInfo_FL_9_3(angle::FormatID vertexFormatID)
212 {
213 // D3D11 Feature Level 9_3 doesn't support as many formats for vertex buffer resource as Feature
214 // Level 10_0+.
215 // http://msdn.microsoft.com/en-us/library/windows/desktop/ff471324(v=vs.85).aspx
216
217 switch (vertexFormatID)
218 {
219 // GL_BYTE -- unnormalized
220 case angle::FormatID::R8_SSCALED:
221 {
222 static constexpr VertexFormat info(VERTEX_CONVERT_BOTH, DXGI_FORMAT_R16G16_SINT,
223 &Copy8SintTo16SintVertexData<1, 2>);
224 return &info;
225 }
226 case angle::FormatID::R8G8_SSCALED:
227 {
228 static constexpr VertexFormat info(VERTEX_CONVERT_BOTH, DXGI_FORMAT_R16G16_SINT,
229 &Copy8SintTo16SintVertexData<2, 2>);
230 return &info;
231 }
232 case angle::FormatID::R8G8B8_SSCALED:
233 {
234 static constexpr VertexFormat info(VERTEX_CONVERT_BOTH, DXGI_FORMAT_R16G16B16A16_SINT,
235 &Copy8SintTo16SintVertexData<3, 4>);
236 return &info;
237 }
238 case angle::FormatID::R8G8B8A8_SSCALED:
239 {
240 static constexpr VertexFormat info(VERTEX_CONVERT_BOTH, DXGI_FORMAT_R16G16B16A16_SINT,
241 &Copy8SintTo16SintVertexData<4, 4>);
242 return &info;
243 }
244
245 // GL_BYTE -- normalized
246 case angle::FormatID::R8_SNORM:
247 {
248 static constexpr VertexFormat info(VERTEX_CONVERT_CPU, DXGI_FORMAT_R16G16_SNORM,
249 &Copy8SnormTo16SnormVertexData<1, 2>);
250 return &info;
251 }
252 case angle::FormatID::R8G8_SNORM:
253 {
254 static constexpr VertexFormat info(VERTEX_CONVERT_CPU, DXGI_FORMAT_R16G16_SNORM,
255 &Copy8SnormTo16SnormVertexData<2, 2>);
256 return &info;
257 }
258 case angle::FormatID::R8G8B8_SNORM:
259 {
260 static constexpr VertexFormat info(VERTEX_CONVERT_CPU, DXGI_FORMAT_R16G16B16A16_SNORM,
261 &Copy8SnormTo16SnormVertexData<3, 4>);
262 return &info;
263 }
264 case angle::FormatID::R8G8B8A8_SNORM:
265 {
266 static constexpr VertexFormat info(VERTEX_CONVERT_CPU, DXGI_FORMAT_R16G16B16A16_SNORM,
267 &Copy8SnormTo16SnormVertexData<4, 4>);
268 return &info;
269 }
270
271 // GL_UNSIGNED_BYTE -- un-normalized
272 // NOTE: 3 and 4 component unnormalized GL_UNSIGNED_BYTE should use the default format
273 // table.
274 case angle::FormatID::R8_USCALED:
275 {
276 static constexpr VertexFormat info(VERTEX_CONVERT_BOTH, DXGI_FORMAT_R8G8B8A8_UINT,
277 &CopyNativeVertexData<GLubyte, 1, 4, 1>);
278 return &info;
279 }
280 case angle::FormatID::R8G8_USCALED:
281 {
282 static constexpr VertexFormat info(VERTEX_CONVERT_BOTH, DXGI_FORMAT_R8G8B8A8_UINT,
283 &CopyNativeVertexData<GLubyte, 2, 4, 1>);
284 return &info;
285 }
286
287 // GL_UNSIGNED_BYTE -- normalized
288 // NOTE: 3 and 4 component normalized GL_UNSIGNED_BYTE should use the default format table.
289
290 // GL_UNSIGNED_BYTE -- normalized
291 case angle::FormatID::R8_UNORM:
292 {
293 static constexpr VertexFormat info(VERTEX_CONVERT_CPU, DXGI_FORMAT_R8G8B8A8_UNORM,
294 &CopyNativeVertexData<GLubyte, 1, 4, UINT8_MAX>);
295 return &info;
296 }
297 case angle::FormatID::R8G8_UNORM:
298 {
299 static constexpr VertexFormat info(VERTEX_CONVERT_CPU, DXGI_FORMAT_R8G8B8A8_UNORM,
300 &CopyNativeVertexData<GLubyte, 2, 4, UINT8_MAX>);
301 return &info;
302 }
303
304 // GL_SHORT -- un-normalized
305 // NOTE: 2, 3 and 4 component unnormalized GL_SHORT should use the default format table.
306 case angle::FormatID::R16_SSCALED:
307 {
308 static constexpr VertexFormat info(VERTEX_CONVERT_BOTH, DXGI_FORMAT_R16G16_SINT,
309 &CopyNativeVertexData<GLshort, 1, 2, 0>);
310 return &info;
311 }
312
313 // GL_SHORT -- normalized
314 // NOTE: 2, 3 and 4 component normalized GL_SHORT should use the default format table.
315 case angle::FormatID::R16_SNORM:
316 {
317 static constexpr VertexFormat info(VERTEX_CONVERT_CPU, DXGI_FORMAT_R16G16_SNORM,
318 &CopyNativeVertexData<GLshort, 1, 2, 0>);
319 return &info;
320 }
321
322 // GL_UNSIGNED_SHORT -- un-normalized
323 case angle::FormatID::R16_USCALED:
324 {
325 static constexpr VertexFormat info(
326 VERTEX_CONVERT_CPU, DXGI_FORMAT_R32G32_FLOAT,
327 &CopyToFloatVertexData<GLushort, 1, 2, false, false>);
328 return &info;
329 }
330 case angle::FormatID::R16G16_USCALED:
331 {
332 static constexpr VertexFormat info(
333 VERTEX_CONVERT_CPU, DXGI_FORMAT_R32G32_FLOAT,
334 &CopyToFloatVertexData<GLushort, 2, 2, false, false>);
335 return &info;
336 }
337 case angle::FormatID::R16G16B16_USCALED:
338 {
339 static constexpr VertexFormat info(
340 VERTEX_CONVERT_CPU, DXGI_FORMAT_R32G32B32_FLOAT,
341 &CopyToFloatVertexData<GLushort, 3, 3, false, false>);
342 return &info;
343 }
344 case angle::FormatID::R16G16B16A16_USCALED:
345 {
346 static constexpr VertexFormat info(
347 VERTEX_CONVERT_CPU, DXGI_FORMAT_R32G32B32A32_FLOAT,
348 &CopyToFloatVertexData<GLushort, 4, 4, false, false>);
349 return &info;
350 }
351
352 // GL_UNSIGNED_SHORT -- normalized
353 case angle::FormatID::R16_UNORM:
354 {
355 static constexpr VertexFormat info(VERTEX_CONVERT_CPU, DXGI_FORMAT_R32G32_FLOAT,
356 &CopyToFloatVertexData<GLushort, 1, 2, true, false>);
357 return &info;
358 }
359 case angle::FormatID::R16G16_UNORM:
360 {
361 static constexpr VertexFormat info(VERTEX_CONVERT_CPU, DXGI_FORMAT_R32G32_FLOAT,
362 &CopyToFloatVertexData<GLushort, 2, 2, true, false>);
363 return &info;
364 }
365 case angle::FormatID::R16G16B16_UNORM:
366 {
367 static constexpr VertexFormat info(VERTEX_CONVERT_CPU, DXGI_FORMAT_R32G32B32_FLOAT,
368 &CopyToFloatVertexData<GLushort, 3, 3, true, false>);
369 return &info;
370 }
371 case angle::FormatID::R16G16B16A16_UNORM:
372 {
373 static constexpr VertexFormat info(VERTEX_CONVERT_CPU, DXGI_FORMAT_R32G32B32A32_FLOAT,
374 &CopyToFloatVertexData<GLushort, 4, 4, true, false>);
375 return &info;
376 }
377
378 // GL_FIXED
379 // TODO: Add test to verify that this works correctly.
380 // NOTE: 2, 3 and 4 component GL_FIXED should use the default format table.
381 case angle::FormatID::R32_FIXED:
382 {
383 static constexpr VertexFormat info(VERTEX_CONVERT_CPU, DXGI_FORMAT_R32G32_FLOAT,
384 &Copy32FixedTo32FVertexData<1, 2>);
385 return &info;
386 }
387
388 // GL_FLOAT
389 // TODO: Add test to verify that this works correctly.
390 // NOTE: 2, 3 and 4 component GL_FLOAT should use the default format table.
391 case angle::FormatID::R32_FLOAT:
392 {
393 static constexpr VertexFormat info(VERTEX_CONVERT_CPU, DXGI_FORMAT_R32G32_FLOAT,
394 &CopyNativeVertexData<GLfloat, 1, 2, 0>);
395 return &info;
396 }
397
398 default:
399 return nullptr;
400 }
401 }
402
GetVertexFormatInfo(angle::FormatID vertexFormatID,D3D_FEATURE_LEVEL featureLevel)403 const VertexFormat &GetVertexFormatInfo(angle::FormatID vertexFormatID,
404 D3D_FEATURE_LEVEL featureLevel)
405 {
406 if (featureLevel == D3D_FEATURE_LEVEL_9_3)
407 {
408 const VertexFormat *result = GetVertexFormatInfo_FL_9_3(vertexFormatID);
409 if (result)
410 {
411 return *result;
412 }
413 }
414
415 switch (vertexFormatID)
416 {
417 //
418 // Float formats
419 //
420
421 // GL_BYTE -- un-normalized
422 case angle::FormatID::R8_SSCALED:
423 {
424 static constexpr VertexFormat info(VERTEX_CONVERT_GPU, DXGI_FORMAT_R8_SINT,
425 &CopyNativeVertexData<GLbyte, 1, 1, 0>);
426 return info;
427 }
428 case angle::FormatID::R8G8_SSCALED:
429 {
430 static constexpr VertexFormat info(VERTEX_CONVERT_GPU, DXGI_FORMAT_R8G8_SINT,
431 &CopyNativeVertexData<GLbyte, 2, 2, 0>);
432 return info;
433 }
434 case angle::FormatID::R8G8B8_SSCALED:
435 {
436 static constexpr VertexFormat info(VERTEX_CONVERT_BOTH, DXGI_FORMAT_R8G8B8A8_SINT,
437 &CopyNativeVertexData<GLbyte, 3, 4, 1>);
438 return info;
439 }
440 case angle::FormatID::R8G8B8A8_SSCALED:
441 {
442 static constexpr VertexFormat info(VERTEX_CONVERT_GPU, DXGI_FORMAT_R8G8B8A8_SINT,
443 &CopyNativeVertexData<GLbyte, 4, 4, 0>);
444 return info;
445 }
446
447 // GL_BYTE -- normalized
448 case angle::FormatID::R8_SNORM:
449 {
450 static constexpr VertexFormat info(VERTEX_CONVERT_NONE, DXGI_FORMAT_R8_SNORM,
451 &CopyNativeVertexData<GLbyte, 1, 1, 0>);
452 return info;
453 }
454 case angle::FormatID::R8G8_SNORM:
455 {
456 static constexpr VertexFormat info(VERTEX_CONVERT_NONE, DXGI_FORMAT_R8G8_SNORM,
457 &CopyNativeVertexData<GLbyte, 2, 2, 0>);
458 return info;
459 }
460 case angle::FormatID::R8G8B8_SNORM:
461 {
462 static constexpr VertexFormat info(VERTEX_CONVERT_CPU, DXGI_FORMAT_R8G8B8A8_SNORM,
463 &CopyNativeVertexData<GLbyte, 3, 4, INT8_MAX>);
464 return info;
465 }
466 case angle::FormatID::R8G8B8A8_SNORM:
467 {
468 static constexpr VertexFormat info(VERTEX_CONVERT_NONE, DXGI_FORMAT_R8G8B8A8_SNORM,
469 &CopyNativeVertexData<GLbyte, 4, 4, 0>);
470 return info;
471 }
472
473 // GL_UNSIGNED_BYTE -- un-normalized
474 case angle::FormatID::R8_USCALED:
475 {
476 static constexpr VertexFormat info(VERTEX_CONVERT_GPU, DXGI_FORMAT_R8_UINT,
477 &CopyNativeVertexData<GLubyte, 1, 1, 0>);
478 return info;
479 }
480 case angle::FormatID::R8G8_USCALED:
481 {
482 static constexpr VertexFormat info(VERTEX_CONVERT_GPU, DXGI_FORMAT_R8G8_UINT,
483 &CopyNativeVertexData<GLubyte, 2, 2, 0>);
484 return info;
485 }
486 case angle::FormatID::R8G8B8_USCALED:
487 {
488 static constexpr VertexFormat info(VERTEX_CONVERT_BOTH, DXGI_FORMAT_R8G8B8A8_UINT,
489 &CopyNativeVertexData<GLubyte, 3, 4, 1>);
490 return info;
491 }
492 case angle::FormatID::R8G8B8A8_USCALED:
493 {
494 static constexpr VertexFormat info(VERTEX_CONVERT_GPU, DXGI_FORMAT_R8G8B8A8_UINT,
495 &CopyNativeVertexData<GLubyte, 4, 4, 0>);
496 return info;
497 }
498
499 // GL_UNSIGNED_BYTE -- normalized
500 case angle::FormatID::R8_UNORM:
501 {
502 static constexpr VertexFormat info(VERTEX_CONVERT_NONE, DXGI_FORMAT_R8_UNORM,
503 &CopyNativeVertexData<GLubyte, 1, 1, 0>);
504 return info;
505 }
506 case angle::FormatID::R8G8_UNORM:
507 {
508 static constexpr VertexFormat info(VERTEX_CONVERT_NONE, DXGI_FORMAT_R8G8_UNORM,
509 &CopyNativeVertexData<GLubyte, 2, 2, 0>);
510 return info;
511 }
512 case angle::FormatID::R8G8B8_UNORM:
513 {
514 static constexpr VertexFormat info(VERTEX_CONVERT_CPU, DXGI_FORMAT_R8G8B8A8_UNORM,
515 &CopyNativeVertexData<GLubyte, 3, 4, UINT8_MAX>);
516 return info;
517 }
518 case angle::FormatID::R8G8B8A8_UNORM:
519 {
520 static constexpr VertexFormat info(VERTEX_CONVERT_NONE, DXGI_FORMAT_R8G8B8A8_UNORM,
521 &CopyNativeVertexData<GLubyte, 4, 4, 0>);
522 return info;
523 }
524
525 // GL_SHORT -- un-normalized
526 case angle::FormatID::R16_SSCALED:
527 {
528 static constexpr VertexFormat info(VERTEX_CONVERT_GPU, DXGI_FORMAT_R16_SINT,
529 &CopyNativeVertexData<GLshort, 1, 1, 0>);
530 return info;
531 }
532 case angle::FormatID::R16G16_SSCALED:
533 {
534 static constexpr VertexFormat info(VERTEX_CONVERT_GPU, DXGI_FORMAT_R16G16_SINT,
535 &CopyNativeVertexData<GLshort, 2, 2, 0>);
536 return info;
537 }
538 case angle::FormatID::R16G16B16_SSCALED:
539 {
540 static constexpr VertexFormat info(VERTEX_CONVERT_BOTH, DXGI_FORMAT_R16G16B16A16_SINT,
541 &CopyNativeVertexData<GLshort, 3, 4, 1>);
542 return info;
543 }
544 case angle::FormatID::R16G16B16A16_SSCALED:
545 {
546 static constexpr VertexFormat info(VERTEX_CONVERT_GPU, DXGI_FORMAT_R16G16B16A16_SINT,
547 &CopyNativeVertexData<GLshort, 4, 4, 0>);
548 return info;
549 }
550
551 // GL_SHORT -- normalized
552 case angle::FormatID::R16_SNORM:
553 {
554 static constexpr VertexFormat info(VERTEX_CONVERT_NONE, DXGI_FORMAT_R16_SNORM,
555 &CopyNativeVertexData<GLshort, 1, 1, 0>);
556 return info;
557 }
558 case angle::FormatID::R16G16_SNORM:
559 {
560 static constexpr VertexFormat info(VERTEX_CONVERT_NONE, DXGI_FORMAT_R16G16_SNORM,
561 &CopyNativeVertexData<GLshort, 2, 2, 0>);
562 return info;
563 }
564 case angle::FormatID::R16G16B16_SNORM:
565 {
566 static constexpr VertexFormat info(VERTEX_CONVERT_CPU, DXGI_FORMAT_R16G16B16A16_SNORM,
567 &CopyNativeVertexData<GLshort, 3, 4, INT16_MAX>);
568 return info;
569 }
570 case angle::FormatID::R16G16B16A16_SNORM:
571 {
572 static constexpr VertexFormat info(VERTEX_CONVERT_NONE, DXGI_FORMAT_R16G16B16A16_SNORM,
573 &CopyNativeVertexData<GLshort, 4, 4, 0>);
574 return info;
575 }
576
577 // GL_UNSIGNED_SHORT -- un-normalized
578 case angle::FormatID::R16_USCALED:
579 {
580 static constexpr VertexFormat info(VERTEX_CONVERT_GPU, DXGI_FORMAT_R16_UINT,
581 &CopyNativeVertexData<GLushort, 1, 1, 0>);
582 return info;
583 }
584 case angle::FormatID::R16G16_USCALED:
585 {
586 static constexpr VertexFormat info(VERTEX_CONVERT_GPU, DXGI_FORMAT_R16G16_UINT,
587 &CopyNativeVertexData<GLushort, 2, 2, 0>);
588 return info;
589 }
590 case angle::FormatID::R16G16B16_USCALED:
591 {
592 static constexpr VertexFormat info(VERTEX_CONVERT_BOTH, DXGI_FORMAT_R16G16B16A16_UINT,
593 &CopyNativeVertexData<GLushort, 3, 4, 1>);
594 return info;
595 }
596 case angle::FormatID::R16G16B16A16_USCALED:
597 {
598 static constexpr VertexFormat info(VERTEX_CONVERT_GPU, DXGI_FORMAT_R16G16B16A16_UINT,
599 &CopyNativeVertexData<GLushort, 4, 4, 0>);
600 return info;
601 }
602
603 // GL_UNSIGNED_SHORT -- normalized
604 case angle::FormatID::R16_UNORM:
605 {
606 static constexpr VertexFormat info(VERTEX_CONVERT_NONE, DXGI_FORMAT_R16_UNORM,
607 &CopyNativeVertexData<GLushort, 1, 1, 0>);
608 return info;
609 }
610 case angle::FormatID::R16G16_UNORM:
611 {
612 static constexpr VertexFormat info(VERTEX_CONVERT_NONE, DXGI_FORMAT_R16G16_UNORM,
613 &CopyNativeVertexData<GLushort, 2, 2, 0>);
614 return info;
615 }
616 case angle::FormatID::R16G16B16_UNORM:
617 {
618 static constexpr VertexFormat info(VERTEX_CONVERT_CPU, DXGI_FORMAT_R16G16B16A16_UNORM,
619 &CopyNativeVertexData<GLushort, 3, 4, UINT16_MAX>);
620 return info;
621 }
622 case angle::FormatID::R16G16B16A16_UNORM:
623 {
624 static constexpr VertexFormat info(VERTEX_CONVERT_NONE, DXGI_FORMAT_R16G16B16A16_UNORM,
625 &CopyNativeVertexData<GLushort, 4, 4, 0>);
626 return info;
627 }
628
629 // GL_INT -- un-normalized
630 case angle::FormatID::R32_SSCALED:
631 {
632 static constexpr VertexFormat info(VERTEX_CONVERT_GPU, DXGI_FORMAT_R32_SINT,
633 &CopyNativeVertexData<GLint, 1, 1, 0>);
634 return info;
635 }
636 case angle::FormatID::R32G32_SSCALED:
637 {
638 static constexpr VertexFormat info(VERTEX_CONVERT_GPU, DXGI_FORMAT_R32G32_SINT,
639 &CopyNativeVertexData<GLint, 2, 2, 0>);
640 return info;
641 }
642 case angle::FormatID::R32G32B32_SSCALED:
643 {
644 static constexpr VertexFormat info(VERTEX_CONVERT_GPU, DXGI_FORMAT_R32G32B32_SINT,
645 &CopyNativeVertexData<GLint, 3, 3, 0>);
646 return info;
647 }
648 case angle::FormatID::R32G32B32A32_SSCALED:
649 {
650 static constexpr VertexFormat info(VERTEX_CONVERT_GPU, DXGI_FORMAT_R32G32B32A32_SINT,
651 &CopyNativeVertexData<GLint, 4, 4, 0>);
652 return info;
653 }
654
655 // GL_INT -- normalized
656 case angle::FormatID::R32_SNORM:
657 {
658 static constexpr VertexFormat info(VERTEX_CONVERT_CPU, DXGI_FORMAT_R32_FLOAT,
659 &CopyToFloatVertexData<GLint, 1, 1, true, false>);
660 return info;
661 }
662 case angle::FormatID::R32G32_SNORM:
663 {
664 static constexpr VertexFormat info(VERTEX_CONVERT_CPU, DXGI_FORMAT_R32G32_FLOAT,
665 &CopyToFloatVertexData<GLint, 2, 2, true, false>);
666 return info;
667 }
668 case angle::FormatID::R32G32B32_SNORM:
669 {
670 static constexpr VertexFormat info(VERTEX_CONVERT_CPU, DXGI_FORMAT_R32G32B32_FLOAT,
671 &CopyToFloatVertexData<GLint, 3, 3, true, false>);
672 return info;
673 }
674 case angle::FormatID::R32G32B32A32_SNORM:
675 {
676 static constexpr VertexFormat info(VERTEX_CONVERT_CPU, DXGI_FORMAT_R32G32B32A32_FLOAT,
677 &CopyToFloatVertexData<GLint, 4, 4, true, false>);
678 return info;
679 }
680
681 // GL_UNSIGNED_INT -- un-normalized
682 case angle::FormatID::R32_USCALED:
683 {
684 static constexpr VertexFormat info(VERTEX_CONVERT_GPU, DXGI_FORMAT_R32_UINT,
685 &CopyNativeVertexData<GLuint, 1, 1, 0>);
686 return info;
687 }
688 case angle::FormatID::R32G32_USCALED:
689 {
690 static constexpr VertexFormat info(VERTEX_CONVERT_GPU, DXGI_FORMAT_R32G32_UINT,
691 &CopyNativeVertexData<GLuint, 2, 2, 0>);
692 return info;
693 }
694 case angle::FormatID::R32G32B32_USCALED:
695 {
696 static constexpr VertexFormat info(VERTEX_CONVERT_GPU, DXGI_FORMAT_R32G32B32_UINT,
697 &CopyNativeVertexData<GLuint, 3, 3, 0>);
698 return info;
699 }
700 case angle::FormatID::R32G32B32A32_USCALED:
701 {
702 static constexpr VertexFormat info(VERTEX_CONVERT_GPU, DXGI_FORMAT_R32G32B32A32_UINT,
703 &CopyNativeVertexData<GLuint, 4, 4, 0>);
704 return info;
705 }
706
707 // GL_UNSIGNED_INT -- normalized
708 case angle::FormatID::R32_UNORM:
709 {
710 static constexpr VertexFormat info(VERTEX_CONVERT_CPU, DXGI_FORMAT_R32_FLOAT,
711 &CopyToFloatVertexData<GLuint, 1, 1, true, false>);
712 return info;
713 }
714 case angle::FormatID::R32G32_UNORM:
715 {
716 static constexpr VertexFormat info(VERTEX_CONVERT_CPU, DXGI_FORMAT_R32G32_FLOAT,
717 &CopyToFloatVertexData<GLuint, 2, 2, true, false>);
718 return info;
719 }
720 case angle::FormatID::R32G32B32_UNORM:
721 {
722 static constexpr VertexFormat info(VERTEX_CONVERT_CPU, DXGI_FORMAT_R32G32B32_FLOAT,
723 &CopyToFloatVertexData<GLuint, 3, 3, true, false>);
724 return info;
725 }
726 case angle::FormatID::R32G32B32A32_UNORM:
727 {
728 static constexpr VertexFormat info(VERTEX_CONVERT_CPU, DXGI_FORMAT_R32G32B32A32_FLOAT,
729 &CopyToFloatVertexData<GLuint, 4, 4, true, false>);
730 return info;
731 }
732
733 // GL_FIXED
734 case angle::FormatID::R32_FIXED:
735 {
736 static constexpr VertexFormat info(VERTEX_CONVERT_CPU, DXGI_FORMAT_R32_FLOAT,
737 &Copy32FixedTo32FVertexData<1, 1>);
738 return info;
739 }
740 case angle::FormatID::R32G32_FIXED:
741 {
742 static constexpr VertexFormat info(VERTEX_CONVERT_CPU, DXGI_FORMAT_R32G32_FLOAT,
743 &Copy32FixedTo32FVertexData<2, 2>);
744 return info;
745 }
746 case angle::FormatID::R32G32B32_FIXED:
747 {
748 static constexpr VertexFormat info(VERTEX_CONVERT_CPU, DXGI_FORMAT_R32G32B32_FLOAT,
749 &Copy32FixedTo32FVertexData<3, 3>);
750 return info;
751 }
752 case angle::FormatID::R32G32B32A32_FIXED:
753 {
754 static constexpr VertexFormat info(VERTEX_CONVERT_CPU, DXGI_FORMAT_R32G32B32A32_FLOAT,
755 &Copy32FixedTo32FVertexData<4, 4>);
756 return info;
757 }
758
759 // GL_HALF_FLOAT
760 case angle::FormatID::R16_FLOAT:
761 {
762 static constexpr VertexFormat info(VERTEX_CONVERT_NONE, DXGI_FORMAT_R16_FLOAT,
763 &CopyNativeVertexData<GLhalf, 1, 1, 0>);
764 return info;
765 }
766 case angle::FormatID::R16G16_FLOAT:
767 {
768 static constexpr VertexFormat info(VERTEX_CONVERT_NONE, DXGI_FORMAT_R16G16_FLOAT,
769 &CopyNativeVertexData<GLhalf, 2, 2, 0>);
770 return info;
771 }
772 case angle::FormatID::R16G16B16_FLOAT:
773 {
774 static constexpr VertexFormat info(VERTEX_CONVERT_CPU, DXGI_FORMAT_R16G16B16A16_FLOAT,
775 &CopyNativeVertexData<GLhalf, 3, 4, gl::Float16One>);
776 return info;
777 }
778 case angle::FormatID::R16G16B16A16_FLOAT:
779 {
780 static constexpr VertexFormat info(VERTEX_CONVERT_NONE, DXGI_FORMAT_R16G16B16A16_FLOAT,
781 &CopyNativeVertexData<GLhalf, 4, 4, 0>);
782 return info;
783 }
784
785 // GL_FLOAT
786 case angle::FormatID::R32_FLOAT:
787 {
788 static constexpr VertexFormat info(VERTEX_CONVERT_NONE, DXGI_FORMAT_R32_FLOAT,
789 &CopyNativeVertexData<GLfloat, 1, 1, 0>);
790 return info;
791 }
792 case angle::FormatID::R32G32_FLOAT:
793 {
794 static constexpr VertexFormat info(VERTEX_CONVERT_NONE, DXGI_FORMAT_R32G32_FLOAT,
795 &CopyNativeVertexData<GLfloat, 2, 2, 0>);
796 return info;
797 }
798 case angle::FormatID::R32G32B32_FLOAT:
799 {
800 static constexpr VertexFormat info(VERTEX_CONVERT_NONE, DXGI_FORMAT_R32G32B32_FLOAT,
801 &CopyNativeVertexData<GLfloat, 3, 3, 0>);
802 return info;
803 }
804 case angle::FormatID::R32G32B32A32_FLOAT:
805 {
806 static constexpr VertexFormat info(VERTEX_CONVERT_NONE, DXGI_FORMAT_R32G32B32A32_FLOAT,
807 &CopyNativeVertexData<GLfloat, 4, 4, 0>);
808 return info;
809 }
810
811 // GL_INT_2_10_10_10_REV
812 case angle::FormatID::R10G10B10A2_SSCALED:
813 {
814 static constexpr VertexFormat info(
815 VERTEX_CONVERT_CPU, DXGI_FORMAT_R32G32B32A32_FLOAT,
816 &CopyXYZ10W2ToXYZWFloatVertexData<true, false, true, false>);
817 return info;
818 }
819 case angle::FormatID::R10G10B10A2_SNORM:
820 {
821 static constexpr VertexFormat info(
822 VERTEX_CONVERT_CPU, DXGI_FORMAT_R32G32B32A32_FLOAT,
823 &CopyXYZ10W2ToXYZWFloatVertexData<true, true, true, false>);
824 return info;
825 }
826
827 // GL_UNSIGNED_INT_2_10_10_10_REV
828 case angle::FormatID::R10G10B10A2_USCALED:
829 {
830 static constexpr VertexFormat info(
831 VERTEX_CONVERT_CPU, DXGI_FORMAT_R32G32B32A32_FLOAT,
832 &CopyXYZ10W2ToXYZWFloatVertexData<false, false, true, false>);
833 return info;
834 }
835 case angle::FormatID::R10G10B10A2_UNORM:
836 {
837 static constexpr VertexFormat info(VERTEX_CONVERT_NONE, DXGI_FORMAT_R10G10B10A2_UNORM,
838 &CopyNativeVertexData<GLuint, 1, 1, 0>);
839 return info;
840 }
841
842 //
843 // Integer Formats
844 //
845
846 // GL_BYTE
847 case angle::FormatID::R8_SINT:
848 {
849 static constexpr VertexFormat info(VERTEX_CONVERT_NONE, DXGI_FORMAT_R8_SINT,
850 &CopyNativeVertexData<GLbyte, 1, 1, 0>);
851 return info;
852 }
853 case angle::FormatID::R8G8_SINT:
854 {
855 static constexpr VertexFormat info(VERTEX_CONVERT_NONE, DXGI_FORMAT_R8G8_SINT,
856 &CopyNativeVertexData<GLbyte, 2, 2, 0>);
857 return info;
858 }
859 case angle::FormatID::R8G8B8_SINT:
860 {
861 static constexpr VertexFormat info(VERTEX_CONVERT_CPU, DXGI_FORMAT_R8G8B8A8_SINT,
862 &CopyNativeVertexData<GLbyte, 3, 4, 1>);
863 return info;
864 }
865 case angle::FormatID::R8G8B8A8_SINT:
866 {
867 static constexpr VertexFormat info(VERTEX_CONVERT_NONE, DXGI_FORMAT_R8G8B8A8_SINT,
868 &CopyNativeVertexData<GLbyte, 4, 4, 0>);
869 return info;
870 }
871
872 // GL_UNSIGNED_BYTE
873 case angle::FormatID::R8_UINT:
874 {
875 static constexpr VertexFormat info(VERTEX_CONVERT_NONE, DXGI_FORMAT_R8_UINT,
876 &CopyNativeVertexData<GLubyte, 1, 1, 0>);
877 return info;
878 }
879 case angle::FormatID::R8G8_UINT:
880 {
881 static constexpr VertexFormat info(VERTEX_CONVERT_NONE, DXGI_FORMAT_R8G8_UINT,
882 &CopyNativeVertexData<GLubyte, 2, 2, 0>);
883 return info;
884 }
885 case angle::FormatID::R8G8B8_UINT:
886 {
887 static constexpr VertexFormat info(VERTEX_CONVERT_CPU, DXGI_FORMAT_R8G8B8A8_UINT,
888 &CopyNativeVertexData<GLubyte, 3, 4, 1>);
889 return info;
890 }
891 case angle::FormatID::R8G8B8A8_UINT:
892 {
893 static constexpr VertexFormat info(VERTEX_CONVERT_NONE, DXGI_FORMAT_R8G8B8A8_UINT,
894 &CopyNativeVertexData<GLubyte, 4, 4, 0>);
895 return info;
896 }
897
898 // GL_SHORT
899 case angle::FormatID::R16_SINT:
900 {
901 static constexpr VertexFormat info(VERTEX_CONVERT_NONE, DXGI_FORMAT_R16_SINT,
902 &CopyNativeVertexData<GLshort, 1, 1, 0>);
903 return info;
904 }
905 case angle::FormatID::R16G16_SINT:
906 {
907 static constexpr VertexFormat info(VERTEX_CONVERT_NONE, DXGI_FORMAT_R16G16_SINT,
908 &CopyNativeVertexData<GLshort, 2, 2, 0>);
909 return info;
910 }
911 case angle::FormatID::R16G16B16_SINT:
912 {
913 static constexpr VertexFormat info(VERTEX_CONVERT_CPU, DXGI_FORMAT_R16G16B16A16_SINT,
914 &CopyNativeVertexData<GLshort, 3, 4, 1>);
915 return info;
916 }
917 case angle::FormatID::R16G16B16A16_SINT:
918 {
919 static constexpr VertexFormat info(VERTEX_CONVERT_NONE, DXGI_FORMAT_R16G16B16A16_SINT,
920 &CopyNativeVertexData<GLshort, 4, 4, 0>);
921 return info;
922 }
923
924 // GL_UNSIGNED_SHORT
925 case angle::FormatID::R16_UINT:
926 {
927 static constexpr VertexFormat info(VERTEX_CONVERT_NONE, DXGI_FORMAT_R16_UINT,
928 &CopyNativeVertexData<GLushort, 1, 1, 0>);
929 return info;
930 }
931 case angle::FormatID::R16G16_UINT:
932 {
933 static constexpr VertexFormat info(VERTEX_CONVERT_NONE, DXGI_FORMAT_R16G16_UINT,
934 &CopyNativeVertexData<GLushort, 2, 2, 0>);
935 return info;
936 }
937 case angle::FormatID::R16G16B16_UINT:
938 {
939 static constexpr VertexFormat info(VERTEX_CONVERT_CPU, DXGI_FORMAT_R16G16B16A16_UINT,
940 &CopyNativeVertexData<GLushort, 3, 4, 1>);
941 return info;
942 }
943 case angle::FormatID::R16G16B16A16_UINT:
944 {
945 static constexpr VertexFormat info(VERTEX_CONVERT_NONE, DXGI_FORMAT_R16G16B16A16_UINT,
946 &CopyNativeVertexData<GLushort, 4, 4, 0>);
947 return info;
948 }
949
950 // GL_INT
951 case angle::FormatID::R32_SINT:
952 {
953 static constexpr VertexFormat info(VERTEX_CONVERT_NONE, DXGI_FORMAT_R32_SINT,
954 &CopyNativeVertexData<GLint, 1, 1, 0>);
955 return info;
956 }
957 case angle::FormatID::R32G32_SINT:
958 {
959 static constexpr VertexFormat info(VERTEX_CONVERT_NONE, DXGI_FORMAT_R32G32_SINT,
960 &CopyNativeVertexData<GLint, 2, 2, 0>);
961 return info;
962 }
963 case angle::FormatID::R32G32B32_SINT:
964 {
965 static constexpr VertexFormat info(VERTEX_CONVERT_NONE, DXGI_FORMAT_R32G32B32_SINT,
966 &CopyNativeVertexData<GLint, 3, 3, 0>);
967 return info;
968 }
969 case angle::FormatID::R32G32B32A32_SINT:
970 {
971 static constexpr VertexFormat info(VERTEX_CONVERT_NONE, DXGI_FORMAT_R32G32B32A32_SINT,
972 &CopyNativeVertexData<GLint, 4, 4, 0>);
973 return info;
974 }
975
976 // GL_UNSIGNED_INT
977 case angle::FormatID::R32_UINT:
978 {
979 static constexpr VertexFormat info(VERTEX_CONVERT_NONE, DXGI_FORMAT_R32_SINT,
980 &CopyNativeVertexData<GLuint, 1, 1, 0>);
981 return info;
982 }
983 case angle::FormatID::R32G32_UINT:
984 {
985 static constexpr VertexFormat info(VERTEX_CONVERT_NONE, DXGI_FORMAT_R32G32_SINT,
986 &CopyNativeVertexData<GLuint, 2, 2, 0>);
987 return info;
988 }
989 case angle::FormatID::R32G32B32_UINT:
990 {
991 static constexpr VertexFormat info(VERTEX_CONVERT_NONE, DXGI_FORMAT_R32G32B32_SINT,
992 &CopyNativeVertexData<GLuint, 3, 3, 0>);
993 return info;
994 }
995 case angle::FormatID::R32G32B32A32_UINT:
996 {
997 static constexpr VertexFormat info(VERTEX_CONVERT_NONE, DXGI_FORMAT_R32G32B32A32_SINT,
998 &CopyNativeVertexData<GLuint, 4, 4, 0>);
999 return info;
1000 }
1001
1002 // GL_INT_2_10_10_10_REV
1003 case angle::FormatID::R10G10B10A2_SINT:
1004 {
1005 static constexpr VertexFormat info(
1006 VERTEX_CONVERT_CPU, DXGI_FORMAT_R16G16B16A16_SINT,
1007 &CopyXYZ10W2ToXYZWFloatVertexData<true, true, false, false>);
1008 return info;
1009 }
1010
1011 // GL_UNSIGNED_INT_2_10_10_10_REV
1012 case angle::FormatID::R10G10B10A2_UINT:
1013 {
1014 static constexpr VertexFormat info(VERTEX_CONVERT_NONE, DXGI_FORMAT_R10G10B10A2_UINT,
1015 &CopyNativeVertexData<GLuint, 1, 1, 0>);
1016 return info;
1017 }
1018
1019 default:
1020 {
1021 static constexpr VertexFormat info;
1022 return info;
1023 }
1024 }
1025 }
1026
1027 } // namespace d3d11
1028
1029 } // namespace rx
1030