1 //
2 // Copyright 2015 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 // texture_format_table:
7 // Queries for full textureFormat information based on internalFormat
8 //
9
10 #ifndef LIBANGLE_RENDERER_D3D_D3D11_TEXTUREFORMATTABLE_H_
11 #define LIBANGLE_RENDERER_D3D_D3D11_TEXTUREFORMATTABLE_H_
12
13 #include <map>
14
15 #include "common/angleutils.h"
16 #include "common/platform.h"
17 #include "libANGLE/renderer/Format.h"
18 #include "libANGLE/renderer/d3d/formatutilsD3D.h"
19 #include "libANGLE/renderer/renderer_utils.h"
20
21 namespace rx
22 {
23
24 struct Renderer11DeviceCaps;
25
26 namespace d3d11
27 {
28
29 // For sized GL internal formats, there are several possible corresponding D3D11 formats depending
30 // on device capabilities.
31 // This structure allows querying for the DXGI texture formats to use for textures, SRVs, RTVs and
32 // DSVs given a GL internal format.
33 struct Format final : private angle::NonCopyable
34 {
35 inline constexpr Format();
36 inline constexpr Format(GLenum internalFormat,
37 angle::FormatID formatID,
38 DXGI_FORMAT texFormat,
39 DXGI_FORMAT srvFormat,
40 DXGI_FORMAT uavFormat,
41 DXGI_FORMAT rtvFormat,
42 DXGI_FORMAT dsvFormat,
43 DXGI_FORMAT blitSRVFormat,
44 DXGI_FORMAT stencilSRVFormat,
45 DXGI_FORMAT typelessFormat,
46 GLenum swizzleFormat,
47 InitializeTextureDataFunction internalFormatInitializer);
48
49 static const Format &Get(GLenum internalFormat, const Renderer11DeviceCaps &deviceCaps);
50
51 const Format &getSwizzleFormat(const Renderer11DeviceCaps &deviceCaps) const;
52 LoadFunctionMap getLoadFunctions() const;
53 const angle::Format &format() const;
54
55 GLenum internalFormat;
56 angle::FormatID formatID;
57
58 DXGI_FORMAT texFormat;
59 DXGI_FORMAT srvFormat;
60 DXGI_FORMAT uavFormat;
61 DXGI_FORMAT rtvFormat;
62 DXGI_FORMAT dsvFormat;
63
64 DXGI_FORMAT blitSRVFormat;
65 DXGI_FORMAT stencilSRVFormat;
66 DXGI_FORMAT typelessFormat;
67
68 GLenum swizzleFormat;
69
70 InitializeTextureDataFunction dataInitializerFunction;
71 };
72
Format()73 constexpr Format::Format()
74 : internalFormat(GL_NONE),
75 formatID(angle::FormatID::NONE),
76 texFormat(DXGI_FORMAT_UNKNOWN),
77 srvFormat(DXGI_FORMAT_UNKNOWN),
78 uavFormat(DXGI_FORMAT_UNKNOWN),
79 rtvFormat(DXGI_FORMAT_UNKNOWN),
80 dsvFormat(DXGI_FORMAT_UNKNOWN),
81 blitSRVFormat(DXGI_FORMAT_UNKNOWN),
82 stencilSRVFormat(DXGI_FORMAT_UNKNOWN),
83 typelessFormat(DXGI_FORMAT_UNKNOWN),
84 swizzleFormat(GL_NONE),
85 dataInitializerFunction(nullptr)
86 {}
87
Format(GLenum internalFormat,angle::FormatID formatID,DXGI_FORMAT texFormat,DXGI_FORMAT srvFormat,DXGI_FORMAT uavFormat,DXGI_FORMAT rtvFormat,DXGI_FORMAT dsvFormat,DXGI_FORMAT blitSRVFormat,DXGI_FORMAT stencilSRVFormat,DXGI_FORMAT typelessFormat,GLenum swizzleFormat,InitializeTextureDataFunction internalFormatInitializer)88 constexpr Format::Format(GLenum internalFormat,
89 angle::FormatID formatID,
90 DXGI_FORMAT texFormat,
91 DXGI_FORMAT srvFormat,
92 DXGI_FORMAT uavFormat,
93 DXGI_FORMAT rtvFormat,
94 DXGI_FORMAT dsvFormat,
95 DXGI_FORMAT blitSRVFormat,
96 DXGI_FORMAT stencilSRVFormat,
97 DXGI_FORMAT typelessFormat,
98 GLenum swizzleFormat,
99 InitializeTextureDataFunction internalFormatInitializer)
100 : internalFormat(internalFormat),
101 formatID(formatID),
102 texFormat(texFormat),
103 srvFormat(srvFormat),
104 uavFormat(uavFormat),
105 rtvFormat(rtvFormat),
106 dsvFormat(dsvFormat),
107 blitSRVFormat(blitSRVFormat),
108 stencilSRVFormat(stencilSRVFormat),
109 typelessFormat(typelessFormat),
110 swizzleFormat(swizzleFormat),
111 dataInitializerFunction(internalFormatInitializer)
112 {}
113
114 } // namespace d3d11
115
116 } // namespace rx
117
118 #endif // LIBANGLE_RENDERER_D3D_D3D11_TEXTUREFORMATTABLE_H_
119