1 //
2 // Copyright (c) 2013-2014 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.h: Queries for GL image formats and their translations to D3D11
8 // formats.
9 
10 #ifndef LIBANGLE_RENDERER_D3D_D3D11_FORMATUTILS11_H_
11 #define LIBANGLE_RENDERER_D3D_D3D11_FORMATUTILS11_H_
12 
13 #include <map>
14 
15 #include "common/platform.h"
16 #include "libANGLE/angletypes.h"
17 #include "libANGLE/formatutils.h"
18 #include "libANGLE/renderer/renderer_utils.h"
19 #include "libANGLE/renderer/d3d/formatutilsD3D.h"
20 
21 namespace rx
22 {
23 struct Renderer11DeviceCaps;
24 
25 namespace d3d11
26 {
27 
28 // A texture might be stored as DXGI_FORMAT_R16_TYPELESS but store integer components,
29 // which are accessed through an DXGI_FORMAT_R16_SINT view. It's easy to write code which queries
30 // information about the wrong format. Therefore, use of this should be avoided where possible.
31 
32 bool SupportsMipGen(DXGI_FORMAT dxgiFormat, D3D_FEATURE_LEVEL featureLevel);
33 
34 struct DXGIFormatSize
35 {
36     DXGIFormatSize(GLuint pixelBits, GLuint blockWidth, GLuint blockHeight);
37 
38     GLuint pixelBytes;
39     GLuint blockWidth;
40     GLuint blockHeight;
41 };
42 const DXGIFormatSize &GetDXGIFormatSizeInfo(DXGI_FORMAT format);
43 
44 struct VertexFormat : private angle::NonCopyable
45 {
46     constexpr VertexFormat();
47     constexpr VertexFormat(VertexConversionType conversionType,
48                            DXGI_FORMAT nativeFormat,
49                            VertexCopyFunction copyFunction);
50 
51     VertexConversionType conversionType;
52     DXGI_FORMAT nativeFormat;
53     VertexCopyFunction copyFunction;
54 };
55 
56 const VertexFormat &GetVertexFormatInfo(gl::VertexFormatType vertexFormatType,
57                                         D3D_FEATURE_LEVEL featureLevel);
58 
59 // Auto-generated in dxgi_format_map_autogen.cpp.
60 GLenum GetComponentType(DXGI_FORMAT dxgiFormat);
61 
62 }  // namespace d3d11
63 
64 namespace d3d11_angle
65 {
66 const angle::Format &GetFormat(DXGI_FORMAT dxgiFormat);
67 }
68 
69 }  // namespace rx
70 
71 #endif // LIBANGLE_RENDERER_D3D_D3D11_FORMATUTILS11_H_
72