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 GLenum swizzleFormat,
45 InitializeTextureDataFunction internalFormatInitializer);
46
47 static const Format &Get(GLenum internalFormat, const Renderer11DeviceCaps &deviceCaps);
48
49 const Format &getSwizzleFormat(const Renderer11DeviceCaps &deviceCaps) const;
50 LoadFunctionMap getLoadFunctions() const;
51 const angle::Format &format() const;
52
53 GLenum internalFormat;
54 angle::FormatID formatID;
55
56 DXGI_FORMAT texFormat;
57 DXGI_FORMAT srvFormat;
58 DXGI_FORMAT uavFormat;
59 DXGI_FORMAT rtvFormat;
60 DXGI_FORMAT dsvFormat;
61
62 DXGI_FORMAT blitSRVFormat;
63
64 GLenum swizzleFormat;
65
66 InitializeTextureDataFunction dataInitializerFunction;
67 };
68
Format()69 constexpr Format::Format()
70 : internalFormat(GL_NONE),
71 formatID(angle::FormatID::NONE),
72 texFormat(DXGI_FORMAT_UNKNOWN),
73 srvFormat(DXGI_FORMAT_UNKNOWN),
74 uavFormat(DXGI_FORMAT_UNKNOWN),
75 rtvFormat(DXGI_FORMAT_UNKNOWN),
76 dsvFormat(DXGI_FORMAT_UNKNOWN),
77 blitSRVFormat(DXGI_FORMAT_UNKNOWN),
78 swizzleFormat(GL_NONE),
79 dataInitializerFunction(nullptr)
80 {}
81
Format(GLenum internalFormat,angle::FormatID formatID,DXGI_FORMAT texFormat,DXGI_FORMAT srvFormat,DXGI_FORMAT uavFormat,DXGI_FORMAT rtvFormat,DXGI_FORMAT dsvFormat,DXGI_FORMAT blitSRVFormat,GLenum swizzleFormat,InitializeTextureDataFunction internalFormatInitializer)82 constexpr Format::Format(GLenum internalFormat,
83 angle::FormatID formatID,
84 DXGI_FORMAT texFormat,
85 DXGI_FORMAT srvFormat,
86 DXGI_FORMAT uavFormat,
87 DXGI_FORMAT rtvFormat,
88 DXGI_FORMAT dsvFormat,
89 DXGI_FORMAT blitSRVFormat,
90 GLenum swizzleFormat,
91 InitializeTextureDataFunction internalFormatInitializer)
92 : internalFormat(internalFormat),
93 formatID(formatID),
94 texFormat(texFormat),
95 srvFormat(srvFormat),
96 uavFormat(uavFormat),
97 rtvFormat(rtvFormat),
98 dsvFormat(dsvFormat),
99 blitSRVFormat(blitSRVFormat),
100 swizzleFormat(swizzleFormat),
101 dataInitializerFunction(internalFormatInitializer)
102 {}
103
104 } // namespace d3d11
105
106 } // namespace rx
107
108 #endif // LIBANGLE_RENDERER_D3D_D3D11_TEXTUREFORMATTABLE_H_
109