xref: /aosp_15_r20/external/angle/src/libANGLE/renderer/d3d/d3d11/formatutils11.h (revision 8975f5c5ed3d1c378011245431ada316dfb6f244)
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.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/copyvertex.h"
19 #include "libANGLE/renderer/d3d/formatutilsD3D.h"
20 #include "libANGLE/renderer/dxgi_format_map.h"
21 #include "libANGLE/renderer/renderer_utils.h"
22 
23 namespace rx
24 {
25 struct Renderer11DeviceCaps;
26 
27 namespace d3d11
28 {
29 
30 struct Format;
31 
32 // A texture might be stored as DXGI_FORMAT_R16_TYPELESS but store integer components,
33 // which are accessed through an DXGI_FORMAT_R16_SINT view. It's easy to write code which queries
34 // information about the wrong format. Therefore, use of this should be avoided where possible.
35 
36 bool SupportsMipGen(DXGI_FORMAT dxgiFormat, D3D_FEATURE_LEVEL featureLevel);
37 
38 bool IsSupportedMultiplanarFormat(DXGI_FORMAT dxgiFormat);
39 
40 const Format &GetYUVPlaneFormat(DXGI_FORMAT dxgiFormat, int plane);
41 
42 struct DXGIFormatSize
43 {
44     DXGIFormatSize(GLuint pixelBits, GLuint blockWidth, GLuint blockHeight);
45 
46     GLuint pixelBytes;
47     GLuint blockWidth;
48     GLuint blockHeight;
49 };
50 const DXGIFormatSize &GetDXGIFormatSizeInfo(DXGI_FORMAT format);
51 
52 struct VertexFormat : private angle::NonCopyable
53 {
54     constexpr VertexFormat();
55     constexpr VertexFormat(VertexConversionType conversionType,
56                            DXGI_FORMAT nativeFormat,
57                            VertexCopyFunction copyFunction);
58 
59     VertexConversionType conversionType;
60     DXGI_FORMAT nativeFormat;
61     VertexCopyFunction copyFunction;
62 };
63 
64 const VertexFormat &GetVertexFormatInfo(angle::FormatID vertexFormatID,
65                                         D3D_FEATURE_LEVEL featureLevel);
66 }  // namespace d3d11
67 
68 }  // namespace rx
69 
70 #endif  // LIBANGLE_RENDERER_D3D_D3D11_FORMATUTILS11_H_
71