1 //
2 // Copyright 2016 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 // Format:
7 // A universal description of typed GPU storage. Across multiple
8 // renderer back-ends, there are common formats and some distinct
9 // permutations, this enum encapsulates them all. Formats apply to
10 // textures, but could also apply to any typed data.
11
12 #ifndef LIBANGLE_RENDERER_FORMAT_H_
13 #define LIBANGLE_RENDERER_FORMAT_H_
14
15 #include "libANGLE/renderer/renderer_utils.h"
16
17 namespace angle
18 {
19
20 struct Format final : private angle::NonCopyable
21 {
22 enum class ID;
23
24 constexpr Format(ID id,
25 GLenum glFormat,
26 GLenum fboFormat,
27 rx::MipGenerationFunction mipGen,
28 const rx::FastCopyFunctionMap &fastCopyFunctions,
29 rx::ColorReadFunction colorRead,
30 rx::ColorWriteFunction colorWrite,
31 GLenum componentType,
32 GLuint redBits,
33 GLuint greenBits,
34 GLuint blueBits,
35 GLuint alphaBits,
36 GLuint depthBits,
37 GLuint stencilBits);
38
39 static const Format &Get(ID id);
40 static ID InternalFormatToID(GLenum internalFormat);
41
42 ID id;
43
44 // The closest matching GL internal format for the storage this format uses. Note that this
45 // may be a different internal format than the one this ANGLE format is used for.
46 GLenum glInternalFormat;
47
48 // The format we should report to the GL layer when querying implementation formats from a FBO.
49 // This might not be the same as the glInternalFormat, since some DXGI formats don't have
50 // matching GL format enums, like BGRA4, BGR5A1 and B5G6R6.
51 GLenum fboImplementationInternalFormat;
52
53 rx::MipGenerationFunction mipGenerationFunction;
54 rx::ColorReadFunction colorReadFunction;
55 rx::ColorWriteFunction colorWriteFunction;
56
57 // A map from a gl::FormatType to a fast pixel copy function for this format.
58 const rx::FastCopyFunctionMap &fastCopyFunctions;
59
60 GLenum componentType;
61
62 GLuint redBits;
63 GLuint greenBits;
64 GLuint blueBits;
65 GLuint alphaBits;
66 GLuint depthBits;
67 GLuint stencilBits;
68 };
69
Format(ID id,GLenum glFormat,GLenum fboFormat,rx::MipGenerationFunction mipGen,const rx::FastCopyFunctionMap & fastCopyFunctions,rx::ColorReadFunction colorRead,rx::ColorWriteFunction colorWrite,GLenum componentType,GLuint redBits,GLuint greenBits,GLuint blueBits,GLuint alphaBits,GLuint depthBits,GLuint stencilBits)70 constexpr Format::Format(ID id,
71 GLenum glFormat,
72 GLenum fboFormat,
73 rx::MipGenerationFunction mipGen,
74 const rx::FastCopyFunctionMap &fastCopyFunctions,
75 rx::ColorReadFunction colorRead,
76 rx::ColorWriteFunction colorWrite,
77 GLenum componentType,
78 GLuint redBits,
79 GLuint greenBits,
80 GLuint blueBits,
81 GLuint alphaBits,
82 GLuint depthBits,
83 GLuint stencilBits)
84 : id(id),
85 glInternalFormat(glFormat),
86 fboImplementationInternalFormat(fboFormat),
87 mipGenerationFunction(mipGen),
88 colorReadFunction(colorRead),
89 colorWriteFunction(colorWrite),
90 fastCopyFunctions(fastCopyFunctions),
91 componentType(componentType),
92 redBits(redBits),
93 greenBits(greenBits),
94 blueBits(blueBits),
95 alphaBits(alphaBits),
96 depthBits(depthBits),
97 stencilBits(stencilBits)
98 {
99 }
100
101 } // namespace angle
102
103 #include "libANGLE/renderer/Format_ID_autogen.inl"
104
105 #endif // LIBANGLE_RENDERER_FORMAT_H_
106