1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
|
//
// Copyright (c) 2013 The ANGLE Project Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
//
// formatutils.h: Queries for GL image formats.
#ifndef LIBANGLE_FORMATUTILS_H_
#define LIBANGLE_FORMATUTILS_H_
#include <cstddef>
#include <stdint.h>
#include "angle_gl.h"
#include "libANGLE/Caps.h"
#include "libANGLE/Error.h"
#include "libANGLE/angletypes.h"
namespace gl
{
struct FormatType final
{
FormatType();
FormatType(GLenum format_, GLenum type_);
FormatType(const FormatType &other) = default;
FormatType &operator=(const FormatType &other) = default;
bool operator<(const FormatType &other) const;
GLenum format;
GLenum type;
};
struct Type
{
Type();
GLuint bytes;
GLuint bytesShift; // Bit shift by this value to effectively divide/multiply by "bytes" in a more optimal way
bool specialInterpretation;
};
const Type &GetTypeInfo(GLenum type);
struct InternalFormat
{
InternalFormat();
gl::ErrorOrResult<GLuint> computeRowPitch(GLenum formatType,
GLsizei width,
GLint alignment,
GLint rowLength) const;
gl::ErrorOrResult<GLuint> computeDepthPitch(GLenum formatType,
GLsizei width,
GLsizei height,
GLint alignment,
GLint rowLength,
GLint imageHeight) const;
gl::ErrorOrResult<GLuint> computeCompressedImageSize(GLenum formatType,
const gl::Extents &size) const;
gl::ErrorOrResult<GLuint> computeSkipBytes(GLuint rowPitch,
GLuint depthPitch,
GLint skipImages,
GLint skipRows,
GLint skipPixels,
bool applySkipImages) const;
gl::ErrorOrResult<GLuint> computeUnpackSize(GLenum formatType,
const gl::Extents &size,
const gl::PixelUnpackState &unpack) const;
bool isLUMA() const;
bool operator==(const InternalFormat &other) const;
bool operator!=(const InternalFormat &other) const;
GLenum internalFormat;
GLuint redBits;
GLuint greenBits;
GLuint blueBits;
GLuint luminanceBits;
GLuint alphaBits;
GLuint sharedBits;
GLuint depthBits;
GLuint stencilBits;
GLuint pixelBytes;
GLuint componentCount;
bool compressed;
GLuint compressedBlockWidth;
GLuint compressedBlockHeight;
GLenum format;
GLenum type;
GLenum componentType;
GLenum colorEncoding;
typedef bool (*SupportCheckFunction)(GLuint, const Extensions &);
SupportCheckFunction textureSupport;
SupportCheckFunction renderSupport;
SupportCheckFunction filterSupport;
};
// A "Format" is either a sized format, or an {unsized format, type} combination.
struct Format
{
// Sized types only.
explicit Format(GLenum internalFormat);
explicit Format(const InternalFormat &internalFormat);
// Sized or unsized types.
Format(GLenum internalFormat, GLenum format, GLenum type);
Format(const Format &other);
Format &operator=(const Format &other);
GLenum asSized() const;
bool valid() const;
static Format Invalid();
static bool SameSized(const Format &a, const Format &b);
// This is the sized info.
const InternalFormat *info;
GLenum format;
GLenum type;
bool sized;
};
const InternalFormat &GetInternalFormatInfo(GLenum internalFormat);
GLenum GetSizedInternalFormat(GLenum internalFormat, GLenum type);
typedef std::set<GLenum> FormatSet;
const FormatSet &GetAllSizedInternalFormats();
// From the ESSL 3.00.4 spec:
// Vertex shader inputs can only be float, floating-point vectors, matrices, signed and unsigned
// integers and integer vectors. Vertex shader inputs cannot be arrays or structures.
enum AttributeType
{
ATTRIBUTE_FLOAT,
ATTRIBUTE_VEC2,
ATTRIBUTE_VEC3,
ATTRIBUTE_VEC4,
ATTRIBUTE_INT,
ATTRIBUTE_IVEC2,
ATTRIBUTE_IVEC3,
ATTRIBUTE_IVEC4,
ATTRIBUTE_UINT,
ATTRIBUTE_UVEC2,
ATTRIBUTE_UVEC3,
ATTRIBUTE_UVEC4,
ATTRIBUTE_MAT2,
ATTRIBUTE_MAT3,
ATTRIBUTE_MAT4,
ATTRIBUTE_MAT2x3,
ATTRIBUTE_MAT2x4,
ATTRIBUTE_MAT3x2,
ATTRIBUTE_MAT3x4,
ATTRIBUTE_MAT4x2,
ATTRIBUTE_MAT4x3,
};
AttributeType GetAttributeType(GLenum enumValue);
enum VertexFormatType
{
VERTEX_FORMAT_INVALID,
VERTEX_FORMAT_SBYTE1,
VERTEX_FORMAT_SBYTE1_NORM,
VERTEX_FORMAT_SBYTE2,
VERTEX_FORMAT_SBYTE2_NORM,
VERTEX_FORMAT_SBYTE3,
VERTEX_FORMAT_SBYTE3_NORM,
VERTEX_FORMAT_SBYTE4,
VERTEX_FORMAT_SBYTE4_NORM,
VERTEX_FORMAT_UBYTE1,
VERTEX_FORMAT_UBYTE1_NORM,
VERTEX_FORMAT_UBYTE2,
VERTEX_FORMAT_UBYTE2_NORM,
VERTEX_FORMAT_UBYTE3,
VERTEX_FORMAT_UBYTE3_NORM,
VERTEX_FORMAT_UBYTE4,
VERTEX_FORMAT_UBYTE4_NORM,
VERTEX_FORMAT_SSHORT1,
VERTEX_FORMAT_SSHORT1_NORM,
VERTEX_FORMAT_SSHORT2,
VERTEX_FORMAT_SSHORT2_NORM,
VERTEX_FORMAT_SSHORT3,
VERTEX_FORMAT_SSHORT3_NORM,
VERTEX_FORMAT_SSHORT4,
VERTEX_FORMAT_SSHORT4_NORM,
VERTEX_FORMAT_USHORT1,
VERTEX_FORMAT_USHORT1_NORM,
VERTEX_FORMAT_USHORT2,
VERTEX_FORMAT_USHORT2_NORM,
VERTEX_FORMAT_USHORT3,
VERTEX_FORMAT_USHORT3_NORM,
VERTEX_FORMAT_USHORT4,
VERTEX_FORMAT_USHORT4_NORM,
VERTEX_FORMAT_SINT1,
VERTEX_FORMAT_SINT1_NORM,
VERTEX_FORMAT_SINT2,
VERTEX_FORMAT_SINT2_NORM,
VERTEX_FORMAT_SINT3,
VERTEX_FORMAT_SINT3_NORM,
VERTEX_FORMAT_SINT4,
VERTEX_FORMAT_SINT4_NORM,
VERTEX_FORMAT_UINT1,
VERTEX_FORMAT_UINT1_NORM,
VERTEX_FORMAT_UINT2,
VERTEX_FORMAT_UINT2_NORM,
VERTEX_FORMAT_UINT3,
VERTEX_FORMAT_UINT3_NORM,
VERTEX_FORMAT_UINT4,
VERTEX_FORMAT_UINT4_NORM,
VERTEX_FORMAT_SBYTE1_INT,
VERTEX_FORMAT_SBYTE2_INT,
VERTEX_FORMAT_SBYTE3_INT,
VERTEX_FORMAT_SBYTE4_INT,
VERTEX_FORMAT_UBYTE1_INT,
VERTEX_FORMAT_UBYTE2_INT,
VERTEX_FORMAT_UBYTE3_INT,
VERTEX_FORMAT_UBYTE4_INT,
VERTEX_FORMAT_SSHORT1_INT,
VERTEX_FORMAT_SSHORT2_INT,
VERTEX_FORMAT_SSHORT3_INT,
VERTEX_FORMAT_SSHORT4_INT,
VERTEX_FORMAT_USHORT1_INT,
VERTEX_FORMAT_USHORT2_INT,
VERTEX_FORMAT_USHORT3_INT,
VERTEX_FORMAT_USHORT4_INT,
VERTEX_FORMAT_SINT1_INT,
VERTEX_FORMAT_SINT2_INT,
VERTEX_FORMAT_SINT3_INT,
VERTEX_FORMAT_SINT4_INT,
VERTEX_FORMAT_UINT1_INT,
VERTEX_FORMAT_UINT2_INT,
VERTEX_FORMAT_UINT3_INT,
VERTEX_FORMAT_UINT4_INT,
VERTEX_FORMAT_FIXED1,
VERTEX_FORMAT_FIXED2,
VERTEX_FORMAT_FIXED3,
VERTEX_FORMAT_FIXED4,
VERTEX_FORMAT_HALF1,
VERTEX_FORMAT_HALF2,
VERTEX_FORMAT_HALF3,
VERTEX_FORMAT_HALF4,
VERTEX_FORMAT_FLOAT1,
VERTEX_FORMAT_FLOAT2,
VERTEX_FORMAT_FLOAT3,
VERTEX_FORMAT_FLOAT4,
VERTEX_FORMAT_SINT210,
VERTEX_FORMAT_UINT210,
VERTEX_FORMAT_SINT210_NORM,
VERTEX_FORMAT_UINT210_NORM,
VERTEX_FORMAT_SINT210_INT,
VERTEX_FORMAT_UINT210_INT,
};
typedef std::vector<gl::VertexFormatType> InputLayout;
struct VertexFormat : angle::NonCopyable
{
VertexFormat(GLenum typeIn, GLboolean normalizedIn, GLuint componentsIn, bool pureIntegerIn);
GLenum type;
GLboolean normalized;
GLuint components;
bool pureInteger;
};
VertexFormatType GetVertexFormatType(GLenum type, GLboolean normalized, GLuint components, bool pureInteger);
VertexFormatType GetVertexFormatType(const VertexAttribute &attrib);
VertexFormatType GetVertexFormatType(const VertexAttribute &attrib, GLenum currentValueType);
const VertexFormat &GetVertexFormatFromType(VertexFormatType vertexFormatType);
} // namespace gl
#endif // LIBANGLE_FORMATUTILS_H_
|