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