1*8975f5c5SAndroid Build Coastguard Worker //
2*8975f5c5SAndroid Build Coastguard Worker // Copyright 2002 The ANGLE Project Authors. All rights reserved.
3*8975f5c5SAndroid Build Coastguard Worker // Use of this source code is governed by a BSD-style license that can be
4*8975f5c5SAndroid Build Coastguard Worker // found in the LICENSE file.
5*8975f5c5SAndroid Build Coastguard Worker //
6*8975f5c5SAndroid Build Coastguard Worker
7*8975f5c5SAndroid Build Coastguard Worker // utilities.cpp: Conversion functions and other utility routines.
8*8975f5c5SAndroid Build Coastguard Worker
9*8975f5c5SAndroid Build Coastguard Worker #include "common/utilities.h"
10*8975f5c5SAndroid Build Coastguard Worker #include "GLES3/gl3.h"
11*8975f5c5SAndroid Build Coastguard Worker #include "common/mathutil.h"
12*8975f5c5SAndroid Build Coastguard Worker #include "common/platform.h"
13*8975f5c5SAndroid Build Coastguard Worker #include "common/string_utils.h"
14*8975f5c5SAndroid Build Coastguard Worker
15*8975f5c5SAndroid Build Coastguard Worker #include <set>
16*8975f5c5SAndroid Build Coastguard Worker
17*8975f5c5SAndroid Build Coastguard Worker #if defined(ANGLE_ENABLE_WINDOWS_UWP)
18*8975f5c5SAndroid Build Coastguard Worker # include <windows.applicationmodel.core.h>
19*8975f5c5SAndroid Build Coastguard Worker # include <windows.graphics.display.h>
20*8975f5c5SAndroid Build Coastguard Worker # include <wrl.h>
21*8975f5c5SAndroid Build Coastguard Worker # include <wrl/wrappers/corewrappers.h>
22*8975f5c5SAndroid Build Coastguard Worker #endif
23*8975f5c5SAndroid Build Coastguard Worker
24*8975f5c5SAndroid Build Coastguard Worker namespace
25*8975f5c5SAndroid Build Coastguard Worker {
26*8975f5c5SAndroid Build Coastguard Worker
27*8975f5c5SAndroid Build Coastguard Worker template <class IndexType>
ComputeTypedIndexRange(const IndexType * indices,size_t count,bool primitiveRestartEnabled,GLuint primitiveRestartIndex)28*8975f5c5SAndroid Build Coastguard Worker gl::IndexRange ComputeTypedIndexRange(const IndexType *indices,
29*8975f5c5SAndroid Build Coastguard Worker size_t count,
30*8975f5c5SAndroid Build Coastguard Worker bool primitiveRestartEnabled,
31*8975f5c5SAndroid Build Coastguard Worker GLuint primitiveRestartIndex)
32*8975f5c5SAndroid Build Coastguard Worker {
33*8975f5c5SAndroid Build Coastguard Worker ASSERT(count > 0);
34*8975f5c5SAndroid Build Coastguard Worker
35*8975f5c5SAndroid Build Coastguard Worker IndexType minIndex = 0;
36*8975f5c5SAndroid Build Coastguard Worker IndexType maxIndex = 0;
37*8975f5c5SAndroid Build Coastguard Worker size_t nonPrimitiveRestartIndices = 0;
38*8975f5c5SAndroid Build Coastguard Worker
39*8975f5c5SAndroid Build Coastguard Worker if (primitiveRestartEnabled)
40*8975f5c5SAndroid Build Coastguard Worker {
41*8975f5c5SAndroid Build Coastguard Worker // Find the first non-primitive restart index to initialize the min and max values
42*8975f5c5SAndroid Build Coastguard Worker size_t i = 0;
43*8975f5c5SAndroid Build Coastguard Worker for (; i < count; i++)
44*8975f5c5SAndroid Build Coastguard Worker {
45*8975f5c5SAndroid Build Coastguard Worker if (indices[i] != primitiveRestartIndex)
46*8975f5c5SAndroid Build Coastguard Worker {
47*8975f5c5SAndroid Build Coastguard Worker minIndex = indices[i];
48*8975f5c5SAndroid Build Coastguard Worker maxIndex = indices[i];
49*8975f5c5SAndroid Build Coastguard Worker nonPrimitiveRestartIndices++;
50*8975f5c5SAndroid Build Coastguard Worker break;
51*8975f5c5SAndroid Build Coastguard Worker }
52*8975f5c5SAndroid Build Coastguard Worker }
53*8975f5c5SAndroid Build Coastguard Worker
54*8975f5c5SAndroid Build Coastguard Worker // Loop over the rest of the indices
55*8975f5c5SAndroid Build Coastguard Worker for (; i < count; i++)
56*8975f5c5SAndroid Build Coastguard Worker {
57*8975f5c5SAndroid Build Coastguard Worker if (indices[i] != primitiveRestartIndex)
58*8975f5c5SAndroid Build Coastguard Worker {
59*8975f5c5SAndroid Build Coastguard Worker if (minIndex > indices[i])
60*8975f5c5SAndroid Build Coastguard Worker {
61*8975f5c5SAndroid Build Coastguard Worker minIndex = indices[i];
62*8975f5c5SAndroid Build Coastguard Worker }
63*8975f5c5SAndroid Build Coastguard Worker if (maxIndex < indices[i])
64*8975f5c5SAndroid Build Coastguard Worker {
65*8975f5c5SAndroid Build Coastguard Worker maxIndex = indices[i];
66*8975f5c5SAndroid Build Coastguard Worker }
67*8975f5c5SAndroid Build Coastguard Worker nonPrimitiveRestartIndices++;
68*8975f5c5SAndroid Build Coastguard Worker }
69*8975f5c5SAndroid Build Coastguard Worker }
70*8975f5c5SAndroid Build Coastguard Worker }
71*8975f5c5SAndroid Build Coastguard Worker else
72*8975f5c5SAndroid Build Coastguard Worker {
73*8975f5c5SAndroid Build Coastguard Worker minIndex = indices[0];
74*8975f5c5SAndroid Build Coastguard Worker maxIndex = indices[0];
75*8975f5c5SAndroid Build Coastguard Worker nonPrimitiveRestartIndices = count;
76*8975f5c5SAndroid Build Coastguard Worker
77*8975f5c5SAndroid Build Coastguard Worker for (size_t i = 1; i < count; i++)
78*8975f5c5SAndroid Build Coastguard Worker {
79*8975f5c5SAndroid Build Coastguard Worker if (minIndex > indices[i])
80*8975f5c5SAndroid Build Coastguard Worker {
81*8975f5c5SAndroid Build Coastguard Worker minIndex = indices[i];
82*8975f5c5SAndroid Build Coastguard Worker }
83*8975f5c5SAndroid Build Coastguard Worker if (maxIndex < indices[i])
84*8975f5c5SAndroid Build Coastguard Worker {
85*8975f5c5SAndroid Build Coastguard Worker maxIndex = indices[i];
86*8975f5c5SAndroid Build Coastguard Worker }
87*8975f5c5SAndroid Build Coastguard Worker }
88*8975f5c5SAndroid Build Coastguard Worker }
89*8975f5c5SAndroid Build Coastguard Worker
90*8975f5c5SAndroid Build Coastguard Worker return gl::IndexRange(static_cast<size_t>(minIndex), static_cast<size_t>(maxIndex),
91*8975f5c5SAndroid Build Coastguard Worker nonPrimitiveRestartIndices);
92*8975f5c5SAndroid Build Coastguard Worker }
93*8975f5c5SAndroid Build Coastguard Worker
94*8975f5c5SAndroid Build Coastguard Worker } // anonymous namespace
95*8975f5c5SAndroid Build Coastguard Worker
96*8975f5c5SAndroid Build Coastguard Worker namespace gl
97*8975f5c5SAndroid Build Coastguard Worker {
98*8975f5c5SAndroid Build Coastguard Worker
VariableComponentCount(GLenum type)99*8975f5c5SAndroid Build Coastguard Worker int VariableComponentCount(GLenum type)
100*8975f5c5SAndroid Build Coastguard Worker {
101*8975f5c5SAndroid Build Coastguard Worker return VariableRowCount(type) * VariableColumnCount(type);
102*8975f5c5SAndroid Build Coastguard Worker }
103*8975f5c5SAndroid Build Coastguard Worker
VariableComponentType(GLenum type)104*8975f5c5SAndroid Build Coastguard Worker GLenum VariableComponentType(GLenum type)
105*8975f5c5SAndroid Build Coastguard Worker {
106*8975f5c5SAndroid Build Coastguard Worker switch (type)
107*8975f5c5SAndroid Build Coastguard Worker {
108*8975f5c5SAndroid Build Coastguard Worker case GL_BOOL:
109*8975f5c5SAndroid Build Coastguard Worker case GL_BOOL_VEC2:
110*8975f5c5SAndroid Build Coastguard Worker case GL_BOOL_VEC3:
111*8975f5c5SAndroid Build Coastguard Worker case GL_BOOL_VEC4:
112*8975f5c5SAndroid Build Coastguard Worker return GL_BOOL;
113*8975f5c5SAndroid Build Coastguard Worker case GL_FLOAT:
114*8975f5c5SAndroid Build Coastguard Worker case GL_FLOAT_VEC2:
115*8975f5c5SAndroid Build Coastguard Worker case GL_FLOAT_VEC3:
116*8975f5c5SAndroid Build Coastguard Worker case GL_FLOAT_VEC4:
117*8975f5c5SAndroid Build Coastguard Worker case GL_FLOAT_MAT2:
118*8975f5c5SAndroid Build Coastguard Worker case GL_FLOAT_MAT3:
119*8975f5c5SAndroid Build Coastguard Worker case GL_FLOAT_MAT4:
120*8975f5c5SAndroid Build Coastguard Worker case GL_FLOAT_MAT2x3:
121*8975f5c5SAndroid Build Coastguard Worker case GL_FLOAT_MAT3x2:
122*8975f5c5SAndroid Build Coastguard Worker case GL_FLOAT_MAT2x4:
123*8975f5c5SAndroid Build Coastguard Worker case GL_FLOAT_MAT4x2:
124*8975f5c5SAndroid Build Coastguard Worker case GL_FLOAT_MAT3x4:
125*8975f5c5SAndroid Build Coastguard Worker case GL_FLOAT_MAT4x3:
126*8975f5c5SAndroid Build Coastguard Worker return GL_FLOAT;
127*8975f5c5SAndroid Build Coastguard Worker case GL_INT:
128*8975f5c5SAndroid Build Coastguard Worker case GL_SAMPLER_2D:
129*8975f5c5SAndroid Build Coastguard Worker case GL_SAMPLER_2D_RECT_ANGLE:
130*8975f5c5SAndroid Build Coastguard Worker case GL_SAMPLER_3D:
131*8975f5c5SAndroid Build Coastguard Worker case GL_SAMPLER_CUBE:
132*8975f5c5SAndroid Build Coastguard Worker case GL_SAMPLER_CUBE_MAP_ARRAY:
133*8975f5c5SAndroid Build Coastguard Worker case GL_SAMPLER_2D_ARRAY:
134*8975f5c5SAndroid Build Coastguard Worker case GL_SAMPLER_EXTERNAL_OES:
135*8975f5c5SAndroid Build Coastguard Worker case GL_SAMPLER_2D_MULTISAMPLE:
136*8975f5c5SAndroid Build Coastguard Worker case GL_SAMPLER_2D_MULTISAMPLE_ARRAY:
137*8975f5c5SAndroid Build Coastguard Worker case GL_INT_SAMPLER_BUFFER:
138*8975f5c5SAndroid Build Coastguard Worker case GL_INT_SAMPLER_2D:
139*8975f5c5SAndroid Build Coastguard Worker case GL_INT_SAMPLER_3D:
140*8975f5c5SAndroid Build Coastguard Worker case GL_INT_SAMPLER_CUBE:
141*8975f5c5SAndroid Build Coastguard Worker case GL_INT_SAMPLER_CUBE_MAP_ARRAY:
142*8975f5c5SAndroid Build Coastguard Worker case GL_INT_SAMPLER_2D_ARRAY:
143*8975f5c5SAndroid Build Coastguard Worker case GL_INT_SAMPLER_2D_MULTISAMPLE:
144*8975f5c5SAndroid Build Coastguard Worker case GL_INT_SAMPLER_2D_MULTISAMPLE_ARRAY:
145*8975f5c5SAndroid Build Coastguard Worker case GL_UNSIGNED_INT_SAMPLER_2D:
146*8975f5c5SAndroid Build Coastguard Worker case GL_UNSIGNED_INT_SAMPLER_3D:
147*8975f5c5SAndroid Build Coastguard Worker case GL_UNSIGNED_INT_SAMPLER_CUBE:
148*8975f5c5SAndroid Build Coastguard Worker case GL_UNSIGNED_INT_SAMPLER_CUBE_MAP_ARRAY:
149*8975f5c5SAndroid Build Coastguard Worker case GL_UNSIGNED_INT_SAMPLER_2D_ARRAY:
150*8975f5c5SAndroid Build Coastguard Worker case GL_UNSIGNED_INT_SAMPLER_2D_MULTISAMPLE:
151*8975f5c5SAndroid Build Coastguard Worker case GL_UNSIGNED_INT_SAMPLER_2D_MULTISAMPLE_ARRAY:
152*8975f5c5SAndroid Build Coastguard Worker case GL_SAMPLER_2D_SHADOW:
153*8975f5c5SAndroid Build Coastguard Worker case GL_SAMPLER_BUFFER:
154*8975f5c5SAndroid Build Coastguard Worker case GL_SAMPLER_CUBE_SHADOW:
155*8975f5c5SAndroid Build Coastguard Worker case GL_SAMPLER_2D_ARRAY_SHADOW:
156*8975f5c5SAndroid Build Coastguard Worker case GL_INT_VEC2:
157*8975f5c5SAndroid Build Coastguard Worker case GL_INT_VEC3:
158*8975f5c5SAndroid Build Coastguard Worker case GL_INT_VEC4:
159*8975f5c5SAndroid Build Coastguard Worker case GL_IMAGE_2D:
160*8975f5c5SAndroid Build Coastguard Worker case GL_INT_IMAGE_2D:
161*8975f5c5SAndroid Build Coastguard Worker case GL_UNSIGNED_INT_IMAGE_2D:
162*8975f5c5SAndroid Build Coastguard Worker case GL_IMAGE_3D:
163*8975f5c5SAndroid Build Coastguard Worker case GL_INT_IMAGE_3D:
164*8975f5c5SAndroid Build Coastguard Worker case GL_UNSIGNED_INT_IMAGE_3D:
165*8975f5c5SAndroid Build Coastguard Worker case GL_IMAGE_2D_ARRAY:
166*8975f5c5SAndroid Build Coastguard Worker case GL_INT_IMAGE_2D_ARRAY:
167*8975f5c5SAndroid Build Coastguard Worker case GL_UNSIGNED_INT_IMAGE_2D_ARRAY:
168*8975f5c5SAndroid Build Coastguard Worker case GL_IMAGE_CUBE:
169*8975f5c5SAndroid Build Coastguard Worker case GL_INT_IMAGE_CUBE:
170*8975f5c5SAndroid Build Coastguard Worker case GL_UNSIGNED_INT_IMAGE_CUBE:
171*8975f5c5SAndroid Build Coastguard Worker case GL_IMAGE_CUBE_MAP_ARRAY:
172*8975f5c5SAndroid Build Coastguard Worker case GL_INT_IMAGE_CUBE_MAP_ARRAY:
173*8975f5c5SAndroid Build Coastguard Worker case GL_UNSIGNED_INT_IMAGE_CUBE_MAP_ARRAY:
174*8975f5c5SAndroid Build Coastguard Worker case GL_IMAGE_BUFFER:
175*8975f5c5SAndroid Build Coastguard Worker case GL_INT_IMAGE_BUFFER:
176*8975f5c5SAndroid Build Coastguard Worker case GL_UNSIGNED_INT_SAMPLER_BUFFER:
177*8975f5c5SAndroid Build Coastguard Worker case GL_UNSIGNED_INT_IMAGE_BUFFER:
178*8975f5c5SAndroid Build Coastguard Worker case GL_UNSIGNED_INT_ATOMIC_COUNTER:
179*8975f5c5SAndroid Build Coastguard Worker case GL_SAMPLER_VIDEO_IMAGE_WEBGL:
180*8975f5c5SAndroid Build Coastguard Worker case GL_SAMPLER_EXTERNAL_2D_Y2Y_EXT:
181*8975f5c5SAndroid Build Coastguard Worker return GL_INT;
182*8975f5c5SAndroid Build Coastguard Worker case GL_UNSIGNED_INT:
183*8975f5c5SAndroid Build Coastguard Worker case GL_UNSIGNED_INT_VEC2:
184*8975f5c5SAndroid Build Coastguard Worker case GL_UNSIGNED_INT_VEC3:
185*8975f5c5SAndroid Build Coastguard Worker case GL_UNSIGNED_INT_VEC4:
186*8975f5c5SAndroid Build Coastguard Worker return GL_UNSIGNED_INT;
187*8975f5c5SAndroid Build Coastguard Worker default:
188*8975f5c5SAndroid Build Coastguard Worker UNREACHABLE();
189*8975f5c5SAndroid Build Coastguard Worker }
190*8975f5c5SAndroid Build Coastguard Worker
191*8975f5c5SAndroid Build Coastguard Worker return GL_NONE;
192*8975f5c5SAndroid Build Coastguard Worker }
193*8975f5c5SAndroid Build Coastguard Worker
VariableComponentSize(GLenum type)194*8975f5c5SAndroid Build Coastguard Worker size_t VariableComponentSize(GLenum type)
195*8975f5c5SAndroid Build Coastguard Worker {
196*8975f5c5SAndroid Build Coastguard Worker switch (type)
197*8975f5c5SAndroid Build Coastguard Worker {
198*8975f5c5SAndroid Build Coastguard Worker case GL_BOOL:
199*8975f5c5SAndroid Build Coastguard Worker return sizeof(GLint);
200*8975f5c5SAndroid Build Coastguard Worker case GL_FLOAT:
201*8975f5c5SAndroid Build Coastguard Worker return sizeof(GLfloat);
202*8975f5c5SAndroid Build Coastguard Worker case GL_INT:
203*8975f5c5SAndroid Build Coastguard Worker return sizeof(GLint);
204*8975f5c5SAndroid Build Coastguard Worker case GL_UNSIGNED_INT:
205*8975f5c5SAndroid Build Coastguard Worker return sizeof(GLuint);
206*8975f5c5SAndroid Build Coastguard Worker default:
207*8975f5c5SAndroid Build Coastguard Worker UNREACHABLE();
208*8975f5c5SAndroid Build Coastguard Worker }
209*8975f5c5SAndroid Build Coastguard Worker
210*8975f5c5SAndroid Build Coastguard Worker return 0;
211*8975f5c5SAndroid Build Coastguard Worker }
212*8975f5c5SAndroid Build Coastguard Worker
VariableInternalSize(GLenum type)213*8975f5c5SAndroid Build Coastguard Worker size_t VariableInternalSize(GLenum type)
214*8975f5c5SAndroid Build Coastguard Worker {
215*8975f5c5SAndroid Build Coastguard Worker // Expanded to 4-element vectors
216*8975f5c5SAndroid Build Coastguard Worker return VariableComponentSize(VariableComponentType(type)) * VariableRowCount(type) * 4;
217*8975f5c5SAndroid Build Coastguard Worker }
218*8975f5c5SAndroid Build Coastguard Worker
VariableExternalSize(GLenum type)219*8975f5c5SAndroid Build Coastguard Worker size_t VariableExternalSize(GLenum type)
220*8975f5c5SAndroid Build Coastguard Worker {
221*8975f5c5SAndroid Build Coastguard Worker return VariableComponentSize(VariableComponentType(type)) * VariableComponentCount(type);
222*8975f5c5SAndroid Build Coastguard Worker }
223*8975f5c5SAndroid Build Coastguard Worker
GetGLSLTypeString(GLenum type)224*8975f5c5SAndroid Build Coastguard Worker std::string GetGLSLTypeString(GLenum type)
225*8975f5c5SAndroid Build Coastguard Worker {
226*8975f5c5SAndroid Build Coastguard Worker switch (type)
227*8975f5c5SAndroid Build Coastguard Worker {
228*8975f5c5SAndroid Build Coastguard Worker case GL_BOOL:
229*8975f5c5SAndroid Build Coastguard Worker return "bool";
230*8975f5c5SAndroid Build Coastguard Worker case GL_INT:
231*8975f5c5SAndroid Build Coastguard Worker return "int";
232*8975f5c5SAndroid Build Coastguard Worker case GL_UNSIGNED_INT:
233*8975f5c5SAndroid Build Coastguard Worker return "uint";
234*8975f5c5SAndroid Build Coastguard Worker case GL_FLOAT:
235*8975f5c5SAndroid Build Coastguard Worker return "float";
236*8975f5c5SAndroid Build Coastguard Worker case GL_BOOL_VEC2:
237*8975f5c5SAndroid Build Coastguard Worker return "bvec2";
238*8975f5c5SAndroid Build Coastguard Worker case GL_BOOL_VEC3:
239*8975f5c5SAndroid Build Coastguard Worker return "bvec3";
240*8975f5c5SAndroid Build Coastguard Worker case GL_BOOL_VEC4:
241*8975f5c5SAndroid Build Coastguard Worker return "bvec4";
242*8975f5c5SAndroid Build Coastguard Worker case GL_INT_VEC2:
243*8975f5c5SAndroid Build Coastguard Worker return "ivec2";
244*8975f5c5SAndroid Build Coastguard Worker case GL_INT_VEC3:
245*8975f5c5SAndroid Build Coastguard Worker return "ivec3";
246*8975f5c5SAndroid Build Coastguard Worker case GL_INT_VEC4:
247*8975f5c5SAndroid Build Coastguard Worker return "ivec4";
248*8975f5c5SAndroid Build Coastguard Worker case GL_FLOAT_VEC2:
249*8975f5c5SAndroid Build Coastguard Worker return "vec2";
250*8975f5c5SAndroid Build Coastguard Worker case GL_FLOAT_VEC3:
251*8975f5c5SAndroid Build Coastguard Worker return "vec3";
252*8975f5c5SAndroid Build Coastguard Worker case GL_FLOAT_VEC4:
253*8975f5c5SAndroid Build Coastguard Worker return "vec4";
254*8975f5c5SAndroid Build Coastguard Worker case GL_UNSIGNED_INT_VEC2:
255*8975f5c5SAndroid Build Coastguard Worker return "uvec2";
256*8975f5c5SAndroid Build Coastguard Worker case GL_UNSIGNED_INT_VEC3:
257*8975f5c5SAndroid Build Coastguard Worker return "uvec3";
258*8975f5c5SAndroid Build Coastguard Worker case GL_UNSIGNED_INT_VEC4:
259*8975f5c5SAndroid Build Coastguard Worker return "uvec4";
260*8975f5c5SAndroid Build Coastguard Worker case GL_FLOAT_MAT2:
261*8975f5c5SAndroid Build Coastguard Worker return "mat2";
262*8975f5c5SAndroid Build Coastguard Worker case GL_FLOAT_MAT3:
263*8975f5c5SAndroid Build Coastguard Worker return "mat3";
264*8975f5c5SAndroid Build Coastguard Worker case GL_FLOAT_MAT4:
265*8975f5c5SAndroid Build Coastguard Worker return "mat4";
266*8975f5c5SAndroid Build Coastguard Worker default:
267*8975f5c5SAndroid Build Coastguard Worker UNREACHABLE();
268*8975f5c5SAndroid Build Coastguard Worker return "";
269*8975f5c5SAndroid Build Coastguard Worker }
270*8975f5c5SAndroid Build Coastguard Worker }
271*8975f5c5SAndroid Build Coastguard Worker
VariableBoolVectorType(GLenum type)272*8975f5c5SAndroid Build Coastguard Worker GLenum VariableBoolVectorType(GLenum type)
273*8975f5c5SAndroid Build Coastguard Worker {
274*8975f5c5SAndroid Build Coastguard Worker switch (type)
275*8975f5c5SAndroid Build Coastguard Worker {
276*8975f5c5SAndroid Build Coastguard Worker case GL_FLOAT:
277*8975f5c5SAndroid Build Coastguard Worker case GL_INT:
278*8975f5c5SAndroid Build Coastguard Worker case GL_UNSIGNED_INT:
279*8975f5c5SAndroid Build Coastguard Worker return GL_BOOL;
280*8975f5c5SAndroid Build Coastguard Worker case GL_FLOAT_VEC2:
281*8975f5c5SAndroid Build Coastguard Worker case GL_INT_VEC2:
282*8975f5c5SAndroid Build Coastguard Worker case GL_UNSIGNED_INT_VEC2:
283*8975f5c5SAndroid Build Coastguard Worker return GL_BOOL_VEC2;
284*8975f5c5SAndroid Build Coastguard Worker case GL_FLOAT_VEC3:
285*8975f5c5SAndroid Build Coastguard Worker case GL_INT_VEC3:
286*8975f5c5SAndroid Build Coastguard Worker case GL_UNSIGNED_INT_VEC3:
287*8975f5c5SAndroid Build Coastguard Worker return GL_BOOL_VEC3;
288*8975f5c5SAndroid Build Coastguard Worker case GL_FLOAT_VEC4:
289*8975f5c5SAndroid Build Coastguard Worker case GL_INT_VEC4:
290*8975f5c5SAndroid Build Coastguard Worker case GL_UNSIGNED_INT_VEC4:
291*8975f5c5SAndroid Build Coastguard Worker return GL_BOOL_VEC4;
292*8975f5c5SAndroid Build Coastguard Worker
293*8975f5c5SAndroid Build Coastguard Worker default:
294*8975f5c5SAndroid Build Coastguard Worker UNREACHABLE();
295*8975f5c5SAndroid Build Coastguard Worker return GL_NONE;
296*8975f5c5SAndroid Build Coastguard Worker }
297*8975f5c5SAndroid Build Coastguard Worker }
298*8975f5c5SAndroid Build Coastguard Worker
VariableRowCount(GLenum type)299*8975f5c5SAndroid Build Coastguard Worker int VariableRowCount(GLenum type)
300*8975f5c5SAndroid Build Coastguard Worker {
301*8975f5c5SAndroid Build Coastguard Worker switch (type)
302*8975f5c5SAndroid Build Coastguard Worker {
303*8975f5c5SAndroid Build Coastguard Worker case GL_NONE:
304*8975f5c5SAndroid Build Coastguard Worker return 0;
305*8975f5c5SAndroid Build Coastguard Worker case GL_BOOL:
306*8975f5c5SAndroid Build Coastguard Worker case GL_FLOAT:
307*8975f5c5SAndroid Build Coastguard Worker case GL_INT:
308*8975f5c5SAndroid Build Coastguard Worker case GL_UNSIGNED_INT:
309*8975f5c5SAndroid Build Coastguard Worker case GL_BOOL_VEC2:
310*8975f5c5SAndroid Build Coastguard Worker case GL_FLOAT_VEC2:
311*8975f5c5SAndroid Build Coastguard Worker case GL_INT_VEC2:
312*8975f5c5SAndroid Build Coastguard Worker case GL_UNSIGNED_INT_VEC2:
313*8975f5c5SAndroid Build Coastguard Worker case GL_BOOL_VEC3:
314*8975f5c5SAndroid Build Coastguard Worker case GL_FLOAT_VEC3:
315*8975f5c5SAndroid Build Coastguard Worker case GL_INT_VEC3:
316*8975f5c5SAndroid Build Coastguard Worker case GL_UNSIGNED_INT_VEC3:
317*8975f5c5SAndroid Build Coastguard Worker case GL_BOOL_VEC4:
318*8975f5c5SAndroid Build Coastguard Worker case GL_FLOAT_VEC4:
319*8975f5c5SAndroid Build Coastguard Worker case GL_INT_VEC4:
320*8975f5c5SAndroid Build Coastguard Worker case GL_UNSIGNED_INT_VEC4:
321*8975f5c5SAndroid Build Coastguard Worker case GL_SAMPLER_2D:
322*8975f5c5SAndroid Build Coastguard Worker case GL_SAMPLER_3D:
323*8975f5c5SAndroid Build Coastguard Worker case GL_SAMPLER_CUBE:
324*8975f5c5SAndroid Build Coastguard Worker case GL_SAMPLER_2D_ARRAY:
325*8975f5c5SAndroid Build Coastguard Worker case GL_SAMPLER_EXTERNAL_OES:
326*8975f5c5SAndroid Build Coastguard Worker case GL_SAMPLER_2D_RECT_ANGLE:
327*8975f5c5SAndroid Build Coastguard Worker case GL_SAMPLER_2D_MULTISAMPLE:
328*8975f5c5SAndroid Build Coastguard Worker case GL_SAMPLER_2D_MULTISAMPLE_ARRAY:
329*8975f5c5SAndroid Build Coastguard Worker case GL_SAMPLER_CUBE_MAP_ARRAY:
330*8975f5c5SAndroid Build Coastguard Worker case GL_SAMPLER_BUFFER:
331*8975f5c5SAndroid Build Coastguard Worker case GL_INT_SAMPLER_2D:
332*8975f5c5SAndroid Build Coastguard Worker case GL_INT_SAMPLER_3D:
333*8975f5c5SAndroid Build Coastguard Worker case GL_INT_SAMPLER_CUBE:
334*8975f5c5SAndroid Build Coastguard Worker case GL_INT_SAMPLER_2D_ARRAY:
335*8975f5c5SAndroid Build Coastguard Worker case GL_INT_SAMPLER_2D_MULTISAMPLE:
336*8975f5c5SAndroid Build Coastguard Worker case GL_INT_SAMPLER_2D_MULTISAMPLE_ARRAY:
337*8975f5c5SAndroid Build Coastguard Worker case GL_INT_SAMPLER_CUBE_MAP_ARRAY:
338*8975f5c5SAndroid Build Coastguard Worker case GL_INT_SAMPLER_BUFFER:
339*8975f5c5SAndroid Build Coastguard Worker case GL_UNSIGNED_INT_SAMPLER_2D:
340*8975f5c5SAndroid Build Coastguard Worker case GL_UNSIGNED_INT_SAMPLER_3D:
341*8975f5c5SAndroid Build Coastguard Worker case GL_UNSIGNED_INT_SAMPLER_CUBE:
342*8975f5c5SAndroid Build Coastguard Worker case GL_UNSIGNED_INT_SAMPLER_2D_ARRAY:
343*8975f5c5SAndroid Build Coastguard Worker case GL_UNSIGNED_INT_SAMPLER_2D_MULTISAMPLE:
344*8975f5c5SAndroid Build Coastguard Worker case GL_UNSIGNED_INT_SAMPLER_2D_MULTISAMPLE_ARRAY:
345*8975f5c5SAndroid Build Coastguard Worker case GL_UNSIGNED_INT_SAMPLER_CUBE_MAP_ARRAY:
346*8975f5c5SAndroid Build Coastguard Worker case GL_UNSIGNED_INT_SAMPLER_BUFFER:
347*8975f5c5SAndroid Build Coastguard Worker case GL_SAMPLER_2D_SHADOW:
348*8975f5c5SAndroid Build Coastguard Worker case GL_SAMPLER_CUBE_SHADOW:
349*8975f5c5SAndroid Build Coastguard Worker case GL_SAMPLER_2D_ARRAY_SHADOW:
350*8975f5c5SAndroid Build Coastguard Worker case GL_SAMPLER_CUBE_MAP_ARRAY_SHADOW:
351*8975f5c5SAndroid Build Coastguard Worker case GL_IMAGE_2D:
352*8975f5c5SAndroid Build Coastguard Worker case GL_INT_IMAGE_2D:
353*8975f5c5SAndroid Build Coastguard Worker case GL_UNSIGNED_INT_IMAGE_2D:
354*8975f5c5SAndroid Build Coastguard Worker case GL_IMAGE_2D_ARRAY:
355*8975f5c5SAndroid Build Coastguard Worker case GL_INT_IMAGE_2D_ARRAY:
356*8975f5c5SAndroid Build Coastguard Worker case GL_UNSIGNED_INT_IMAGE_2D_ARRAY:
357*8975f5c5SAndroid Build Coastguard Worker case GL_IMAGE_3D:
358*8975f5c5SAndroid Build Coastguard Worker case GL_INT_IMAGE_3D:
359*8975f5c5SAndroid Build Coastguard Worker case GL_UNSIGNED_INT_IMAGE_3D:
360*8975f5c5SAndroid Build Coastguard Worker case GL_IMAGE_CUBE:
361*8975f5c5SAndroid Build Coastguard Worker case GL_INT_IMAGE_CUBE:
362*8975f5c5SAndroid Build Coastguard Worker case GL_UNSIGNED_INT_IMAGE_CUBE:
363*8975f5c5SAndroid Build Coastguard Worker case GL_UNSIGNED_INT_ATOMIC_COUNTER:
364*8975f5c5SAndroid Build Coastguard Worker case GL_IMAGE_CUBE_MAP_ARRAY:
365*8975f5c5SAndroid Build Coastguard Worker case GL_INT_IMAGE_CUBE_MAP_ARRAY:
366*8975f5c5SAndroid Build Coastguard Worker case GL_UNSIGNED_INT_IMAGE_CUBE_MAP_ARRAY:
367*8975f5c5SAndroid Build Coastguard Worker case GL_IMAGE_BUFFER:
368*8975f5c5SAndroid Build Coastguard Worker case GL_INT_IMAGE_BUFFER:
369*8975f5c5SAndroid Build Coastguard Worker case GL_UNSIGNED_INT_IMAGE_BUFFER:
370*8975f5c5SAndroid Build Coastguard Worker case GL_SAMPLER_VIDEO_IMAGE_WEBGL:
371*8975f5c5SAndroid Build Coastguard Worker case GL_SAMPLER_EXTERNAL_2D_Y2Y_EXT:
372*8975f5c5SAndroid Build Coastguard Worker return 1;
373*8975f5c5SAndroid Build Coastguard Worker case GL_FLOAT_MAT2:
374*8975f5c5SAndroid Build Coastguard Worker case GL_FLOAT_MAT3x2:
375*8975f5c5SAndroid Build Coastguard Worker case GL_FLOAT_MAT4x2:
376*8975f5c5SAndroid Build Coastguard Worker return 2;
377*8975f5c5SAndroid Build Coastguard Worker case GL_FLOAT_MAT3:
378*8975f5c5SAndroid Build Coastguard Worker case GL_FLOAT_MAT2x3:
379*8975f5c5SAndroid Build Coastguard Worker case GL_FLOAT_MAT4x3:
380*8975f5c5SAndroid Build Coastguard Worker return 3;
381*8975f5c5SAndroid Build Coastguard Worker case GL_FLOAT_MAT4:
382*8975f5c5SAndroid Build Coastguard Worker case GL_FLOAT_MAT2x4:
383*8975f5c5SAndroid Build Coastguard Worker case GL_FLOAT_MAT3x4:
384*8975f5c5SAndroid Build Coastguard Worker return 4;
385*8975f5c5SAndroid Build Coastguard Worker default:
386*8975f5c5SAndroid Build Coastguard Worker UNREACHABLE();
387*8975f5c5SAndroid Build Coastguard Worker }
388*8975f5c5SAndroid Build Coastguard Worker
389*8975f5c5SAndroid Build Coastguard Worker return 0;
390*8975f5c5SAndroid Build Coastguard Worker }
391*8975f5c5SAndroid Build Coastguard Worker
VariableColumnCount(GLenum type)392*8975f5c5SAndroid Build Coastguard Worker int VariableColumnCount(GLenum type)
393*8975f5c5SAndroid Build Coastguard Worker {
394*8975f5c5SAndroid Build Coastguard Worker switch (type)
395*8975f5c5SAndroid Build Coastguard Worker {
396*8975f5c5SAndroid Build Coastguard Worker case GL_NONE:
397*8975f5c5SAndroid Build Coastguard Worker return 0;
398*8975f5c5SAndroid Build Coastguard Worker case GL_BOOL:
399*8975f5c5SAndroid Build Coastguard Worker case GL_FLOAT:
400*8975f5c5SAndroid Build Coastguard Worker case GL_INT:
401*8975f5c5SAndroid Build Coastguard Worker case GL_UNSIGNED_INT:
402*8975f5c5SAndroid Build Coastguard Worker case GL_SAMPLER_2D:
403*8975f5c5SAndroid Build Coastguard Worker case GL_SAMPLER_3D:
404*8975f5c5SAndroid Build Coastguard Worker case GL_SAMPLER_CUBE:
405*8975f5c5SAndroid Build Coastguard Worker case GL_SAMPLER_2D_ARRAY:
406*8975f5c5SAndroid Build Coastguard Worker case GL_SAMPLER_2D_MULTISAMPLE:
407*8975f5c5SAndroid Build Coastguard Worker case GL_SAMPLER_2D_MULTISAMPLE_ARRAY:
408*8975f5c5SAndroid Build Coastguard Worker case GL_SAMPLER_CUBE_MAP_ARRAY:
409*8975f5c5SAndroid Build Coastguard Worker case GL_SAMPLER_BUFFER:
410*8975f5c5SAndroid Build Coastguard Worker case GL_INT_SAMPLER_2D:
411*8975f5c5SAndroid Build Coastguard Worker case GL_INT_SAMPLER_3D:
412*8975f5c5SAndroid Build Coastguard Worker case GL_INT_SAMPLER_CUBE:
413*8975f5c5SAndroid Build Coastguard Worker case GL_INT_SAMPLER_2D_ARRAY:
414*8975f5c5SAndroid Build Coastguard Worker case GL_INT_SAMPLER_2D_MULTISAMPLE:
415*8975f5c5SAndroid Build Coastguard Worker case GL_INT_SAMPLER_2D_MULTISAMPLE_ARRAY:
416*8975f5c5SAndroid Build Coastguard Worker case GL_INT_SAMPLER_CUBE_MAP_ARRAY:
417*8975f5c5SAndroid Build Coastguard Worker case GL_INT_SAMPLER_BUFFER:
418*8975f5c5SAndroid Build Coastguard Worker case GL_SAMPLER_EXTERNAL_OES:
419*8975f5c5SAndroid Build Coastguard Worker case GL_SAMPLER_2D_RECT_ANGLE:
420*8975f5c5SAndroid Build Coastguard Worker case GL_UNSIGNED_INT_SAMPLER_2D:
421*8975f5c5SAndroid Build Coastguard Worker case GL_UNSIGNED_INT_SAMPLER_3D:
422*8975f5c5SAndroid Build Coastguard Worker case GL_UNSIGNED_INT_SAMPLER_CUBE:
423*8975f5c5SAndroid Build Coastguard Worker case GL_UNSIGNED_INT_SAMPLER_2D_ARRAY:
424*8975f5c5SAndroid Build Coastguard Worker case GL_UNSIGNED_INT_SAMPLER_2D_MULTISAMPLE:
425*8975f5c5SAndroid Build Coastguard Worker case GL_UNSIGNED_INT_SAMPLER_2D_MULTISAMPLE_ARRAY:
426*8975f5c5SAndroid Build Coastguard Worker case GL_UNSIGNED_INT_SAMPLER_CUBE_MAP_ARRAY:
427*8975f5c5SAndroid Build Coastguard Worker case GL_UNSIGNED_INT_SAMPLER_BUFFER:
428*8975f5c5SAndroid Build Coastguard Worker case GL_SAMPLER_2D_SHADOW:
429*8975f5c5SAndroid Build Coastguard Worker case GL_SAMPLER_CUBE_SHADOW:
430*8975f5c5SAndroid Build Coastguard Worker case GL_SAMPLER_2D_ARRAY_SHADOW:
431*8975f5c5SAndroid Build Coastguard Worker case GL_SAMPLER_CUBE_MAP_ARRAY_SHADOW:
432*8975f5c5SAndroid Build Coastguard Worker case GL_IMAGE_2D:
433*8975f5c5SAndroid Build Coastguard Worker case GL_INT_IMAGE_2D:
434*8975f5c5SAndroid Build Coastguard Worker case GL_UNSIGNED_INT_IMAGE_2D:
435*8975f5c5SAndroid Build Coastguard Worker case GL_IMAGE_3D:
436*8975f5c5SAndroid Build Coastguard Worker case GL_INT_IMAGE_3D:
437*8975f5c5SAndroid Build Coastguard Worker case GL_UNSIGNED_INT_IMAGE_3D:
438*8975f5c5SAndroid Build Coastguard Worker case GL_IMAGE_2D_ARRAY:
439*8975f5c5SAndroid Build Coastguard Worker case GL_INT_IMAGE_2D_ARRAY:
440*8975f5c5SAndroid Build Coastguard Worker case GL_UNSIGNED_INT_IMAGE_2D_ARRAY:
441*8975f5c5SAndroid Build Coastguard Worker case GL_IMAGE_CUBE_MAP_ARRAY:
442*8975f5c5SAndroid Build Coastguard Worker case GL_INT_IMAGE_CUBE_MAP_ARRAY:
443*8975f5c5SAndroid Build Coastguard Worker case GL_UNSIGNED_INT_IMAGE_CUBE_MAP_ARRAY:
444*8975f5c5SAndroid Build Coastguard Worker case GL_IMAGE_BUFFER:
445*8975f5c5SAndroid Build Coastguard Worker case GL_INT_IMAGE_BUFFER:
446*8975f5c5SAndroid Build Coastguard Worker case GL_UNSIGNED_INT_IMAGE_BUFFER:
447*8975f5c5SAndroid Build Coastguard Worker case GL_IMAGE_CUBE:
448*8975f5c5SAndroid Build Coastguard Worker case GL_INT_IMAGE_CUBE:
449*8975f5c5SAndroid Build Coastguard Worker case GL_UNSIGNED_INT_IMAGE_CUBE:
450*8975f5c5SAndroid Build Coastguard Worker case GL_UNSIGNED_INT_ATOMIC_COUNTER:
451*8975f5c5SAndroid Build Coastguard Worker case GL_SAMPLER_VIDEO_IMAGE_WEBGL:
452*8975f5c5SAndroid Build Coastguard Worker case GL_SAMPLER_EXTERNAL_2D_Y2Y_EXT:
453*8975f5c5SAndroid Build Coastguard Worker return 1;
454*8975f5c5SAndroid Build Coastguard Worker case GL_BOOL_VEC2:
455*8975f5c5SAndroid Build Coastguard Worker case GL_FLOAT_VEC2:
456*8975f5c5SAndroid Build Coastguard Worker case GL_INT_VEC2:
457*8975f5c5SAndroid Build Coastguard Worker case GL_UNSIGNED_INT_VEC2:
458*8975f5c5SAndroid Build Coastguard Worker case GL_FLOAT_MAT2:
459*8975f5c5SAndroid Build Coastguard Worker case GL_FLOAT_MAT2x3:
460*8975f5c5SAndroid Build Coastguard Worker case GL_FLOAT_MAT2x4:
461*8975f5c5SAndroid Build Coastguard Worker return 2;
462*8975f5c5SAndroid Build Coastguard Worker case GL_BOOL_VEC3:
463*8975f5c5SAndroid Build Coastguard Worker case GL_FLOAT_VEC3:
464*8975f5c5SAndroid Build Coastguard Worker case GL_INT_VEC3:
465*8975f5c5SAndroid Build Coastguard Worker case GL_UNSIGNED_INT_VEC3:
466*8975f5c5SAndroid Build Coastguard Worker case GL_FLOAT_MAT3:
467*8975f5c5SAndroid Build Coastguard Worker case GL_FLOAT_MAT3x2:
468*8975f5c5SAndroid Build Coastguard Worker case GL_FLOAT_MAT3x4:
469*8975f5c5SAndroid Build Coastguard Worker return 3;
470*8975f5c5SAndroid Build Coastguard Worker case GL_BOOL_VEC4:
471*8975f5c5SAndroid Build Coastguard Worker case GL_FLOAT_VEC4:
472*8975f5c5SAndroid Build Coastguard Worker case GL_INT_VEC4:
473*8975f5c5SAndroid Build Coastguard Worker case GL_UNSIGNED_INT_VEC4:
474*8975f5c5SAndroid Build Coastguard Worker case GL_FLOAT_MAT4:
475*8975f5c5SAndroid Build Coastguard Worker case GL_FLOAT_MAT4x2:
476*8975f5c5SAndroid Build Coastguard Worker case GL_FLOAT_MAT4x3:
477*8975f5c5SAndroid Build Coastguard Worker return 4;
478*8975f5c5SAndroid Build Coastguard Worker default:
479*8975f5c5SAndroid Build Coastguard Worker UNREACHABLE();
480*8975f5c5SAndroid Build Coastguard Worker }
481*8975f5c5SAndroid Build Coastguard Worker
482*8975f5c5SAndroid Build Coastguard Worker return 0;
483*8975f5c5SAndroid Build Coastguard Worker }
484*8975f5c5SAndroid Build Coastguard Worker
IsSamplerType(GLenum type)485*8975f5c5SAndroid Build Coastguard Worker bool IsSamplerType(GLenum type)
486*8975f5c5SAndroid Build Coastguard Worker {
487*8975f5c5SAndroid Build Coastguard Worker switch (type)
488*8975f5c5SAndroid Build Coastguard Worker {
489*8975f5c5SAndroid Build Coastguard Worker case GL_SAMPLER_2D:
490*8975f5c5SAndroid Build Coastguard Worker case GL_SAMPLER_3D:
491*8975f5c5SAndroid Build Coastguard Worker case GL_SAMPLER_CUBE:
492*8975f5c5SAndroid Build Coastguard Worker case GL_SAMPLER_2D_ARRAY:
493*8975f5c5SAndroid Build Coastguard Worker case GL_SAMPLER_EXTERNAL_OES:
494*8975f5c5SAndroid Build Coastguard Worker case GL_SAMPLER_2D_MULTISAMPLE:
495*8975f5c5SAndroid Build Coastguard Worker case GL_SAMPLER_2D_MULTISAMPLE_ARRAY:
496*8975f5c5SAndroid Build Coastguard Worker case GL_SAMPLER_CUBE_MAP_ARRAY:
497*8975f5c5SAndroid Build Coastguard Worker case GL_SAMPLER_BUFFER:
498*8975f5c5SAndroid Build Coastguard Worker case GL_SAMPLER_2D_RECT_ANGLE:
499*8975f5c5SAndroid Build Coastguard Worker case GL_INT_SAMPLER_2D:
500*8975f5c5SAndroid Build Coastguard Worker case GL_INT_SAMPLER_3D:
501*8975f5c5SAndroid Build Coastguard Worker case GL_INT_SAMPLER_CUBE:
502*8975f5c5SAndroid Build Coastguard Worker case GL_INT_SAMPLER_2D_ARRAY:
503*8975f5c5SAndroid Build Coastguard Worker case GL_INT_SAMPLER_2D_MULTISAMPLE:
504*8975f5c5SAndroid Build Coastguard Worker case GL_INT_SAMPLER_2D_MULTISAMPLE_ARRAY:
505*8975f5c5SAndroid Build Coastguard Worker case GL_INT_SAMPLER_CUBE_MAP_ARRAY:
506*8975f5c5SAndroid Build Coastguard Worker case GL_INT_SAMPLER_BUFFER:
507*8975f5c5SAndroid Build Coastguard Worker case GL_UNSIGNED_INT_SAMPLER_2D:
508*8975f5c5SAndroid Build Coastguard Worker case GL_UNSIGNED_INT_SAMPLER_3D:
509*8975f5c5SAndroid Build Coastguard Worker case GL_UNSIGNED_INT_SAMPLER_CUBE:
510*8975f5c5SAndroid Build Coastguard Worker case GL_UNSIGNED_INT_SAMPLER_2D_ARRAY:
511*8975f5c5SAndroid Build Coastguard Worker case GL_UNSIGNED_INT_SAMPLER_2D_MULTISAMPLE:
512*8975f5c5SAndroid Build Coastguard Worker case GL_UNSIGNED_INT_SAMPLER_2D_MULTISAMPLE_ARRAY:
513*8975f5c5SAndroid Build Coastguard Worker case GL_UNSIGNED_INT_SAMPLER_CUBE_MAP_ARRAY:
514*8975f5c5SAndroid Build Coastguard Worker case GL_UNSIGNED_INT_SAMPLER_BUFFER:
515*8975f5c5SAndroid Build Coastguard Worker case GL_SAMPLER_2D_SHADOW:
516*8975f5c5SAndroid Build Coastguard Worker case GL_SAMPLER_CUBE_SHADOW:
517*8975f5c5SAndroid Build Coastguard Worker case GL_SAMPLER_2D_ARRAY_SHADOW:
518*8975f5c5SAndroid Build Coastguard Worker case GL_SAMPLER_CUBE_MAP_ARRAY_SHADOW:
519*8975f5c5SAndroid Build Coastguard Worker case GL_SAMPLER_VIDEO_IMAGE_WEBGL:
520*8975f5c5SAndroid Build Coastguard Worker case GL_SAMPLER_EXTERNAL_2D_Y2Y_EXT:
521*8975f5c5SAndroid Build Coastguard Worker return true;
522*8975f5c5SAndroid Build Coastguard Worker }
523*8975f5c5SAndroid Build Coastguard Worker
524*8975f5c5SAndroid Build Coastguard Worker return false;
525*8975f5c5SAndroid Build Coastguard Worker }
526*8975f5c5SAndroid Build Coastguard Worker
IsSamplerCubeType(GLenum type)527*8975f5c5SAndroid Build Coastguard Worker bool IsSamplerCubeType(GLenum type)
528*8975f5c5SAndroid Build Coastguard Worker {
529*8975f5c5SAndroid Build Coastguard Worker switch (type)
530*8975f5c5SAndroid Build Coastguard Worker {
531*8975f5c5SAndroid Build Coastguard Worker case GL_SAMPLER_CUBE:
532*8975f5c5SAndroid Build Coastguard Worker case GL_INT_SAMPLER_CUBE:
533*8975f5c5SAndroid Build Coastguard Worker case GL_UNSIGNED_INT_SAMPLER_CUBE:
534*8975f5c5SAndroid Build Coastguard Worker case GL_SAMPLER_CUBE_SHADOW:
535*8975f5c5SAndroid Build Coastguard Worker return true;
536*8975f5c5SAndroid Build Coastguard Worker }
537*8975f5c5SAndroid Build Coastguard Worker
538*8975f5c5SAndroid Build Coastguard Worker return false;
539*8975f5c5SAndroid Build Coastguard Worker }
540*8975f5c5SAndroid Build Coastguard Worker
IsSamplerYUVType(GLenum type)541*8975f5c5SAndroid Build Coastguard Worker bool IsSamplerYUVType(GLenum type)
542*8975f5c5SAndroid Build Coastguard Worker {
543*8975f5c5SAndroid Build Coastguard Worker switch (type)
544*8975f5c5SAndroid Build Coastguard Worker {
545*8975f5c5SAndroid Build Coastguard Worker case GL_SAMPLER_EXTERNAL_2D_Y2Y_EXT:
546*8975f5c5SAndroid Build Coastguard Worker return true;
547*8975f5c5SAndroid Build Coastguard Worker
548*8975f5c5SAndroid Build Coastguard Worker default:
549*8975f5c5SAndroid Build Coastguard Worker return false;
550*8975f5c5SAndroid Build Coastguard Worker }
551*8975f5c5SAndroid Build Coastguard Worker }
552*8975f5c5SAndroid Build Coastguard Worker
IsImageType(GLenum type)553*8975f5c5SAndroid Build Coastguard Worker bool IsImageType(GLenum type)
554*8975f5c5SAndroid Build Coastguard Worker {
555*8975f5c5SAndroid Build Coastguard Worker switch (type)
556*8975f5c5SAndroid Build Coastguard Worker {
557*8975f5c5SAndroid Build Coastguard Worker case GL_IMAGE_2D:
558*8975f5c5SAndroid Build Coastguard Worker case GL_INT_IMAGE_2D:
559*8975f5c5SAndroid Build Coastguard Worker case GL_UNSIGNED_INT_IMAGE_2D:
560*8975f5c5SAndroid Build Coastguard Worker case GL_IMAGE_3D:
561*8975f5c5SAndroid Build Coastguard Worker case GL_INT_IMAGE_3D:
562*8975f5c5SAndroid Build Coastguard Worker case GL_UNSIGNED_INT_IMAGE_3D:
563*8975f5c5SAndroid Build Coastguard Worker case GL_IMAGE_2D_ARRAY:
564*8975f5c5SAndroid Build Coastguard Worker case GL_INT_IMAGE_2D_ARRAY:
565*8975f5c5SAndroid Build Coastguard Worker case GL_UNSIGNED_INT_IMAGE_2D_ARRAY:
566*8975f5c5SAndroid Build Coastguard Worker case GL_IMAGE_CUBE_MAP_ARRAY:
567*8975f5c5SAndroid Build Coastguard Worker case GL_INT_IMAGE_CUBE_MAP_ARRAY:
568*8975f5c5SAndroid Build Coastguard Worker case GL_UNSIGNED_INT_IMAGE_CUBE_MAP_ARRAY:
569*8975f5c5SAndroid Build Coastguard Worker case GL_IMAGE_BUFFER:
570*8975f5c5SAndroid Build Coastguard Worker case GL_INT_IMAGE_BUFFER:
571*8975f5c5SAndroid Build Coastguard Worker case GL_UNSIGNED_INT_IMAGE_BUFFER:
572*8975f5c5SAndroid Build Coastguard Worker case GL_IMAGE_CUBE:
573*8975f5c5SAndroid Build Coastguard Worker case GL_INT_IMAGE_CUBE:
574*8975f5c5SAndroid Build Coastguard Worker case GL_UNSIGNED_INT_IMAGE_CUBE:
575*8975f5c5SAndroid Build Coastguard Worker return true;
576*8975f5c5SAndroid Build Coastguard Worker }
577*8975f5c5SAndroid Build Coastguard Worker return false;
578*8975f5c5SAndroid Build Coastguard Worker }
579*8975f5c5SAndroid Build Coastguard Worker
IsImage2DType(GLenum type)580*8975f5c5SAndroid Build Coastguard Worker bool IsImage2DType(GLenum type)
581*8975f5c5SAndroid Build Coastguard Worker {
582*8975f5c5SAndroid Build Coastguard Worker switch (type)
583*8975f5c5SAndroid Build Coastguard Worker {
584*8975f5c5SAndroid Build Coastguard Worker case GL_IMAGE_2D:
585*8975f5c5SAndroid Build Coastguard Worker case GL_INT_IMAGE_2D:
586*8975f5c5SAndroid Build Coastguard Worker case GL_UNSIGNED_INT_IMAGE_2D:
587*8975f5c5SAndroid Build Coastguard Worker return true;
588*8975f5c5SAndroid Build Coastguard Worker case GL_IMAGE_3D:
589*8975f5c5SAndroid Build Coastguard Worker case GL_INT_IMAGE_3D:
590*8975f5c5SAndroid Build Coastguard Worker case GL_UNSIGNED_INT_IMAGE_3D:
591*8975f5c5SAndroid Build Coastguard Worker case GL_IMAGE_2D_ARRAY:
592*8975f5c5SAndroid Build Coastguard Worker case GL_INT_IMAGE_2D_ARRAY:
593*8975f5c5SAndroid Build Coastguard Worker case GL_UNSIGNED_INT_IMAGE_2D_ARRAY:
594*8975f5c5SAndroid Build Coastguard Worker case GL_IMAGE_CUBE_MAP_ARRAY:
595*8975f5c5SAndroid Build Coastguard Worker case GL_INT_IMAGE_CUBE_MAP_ARRAY:
596*8975f5c5SAndroid Build Coastguard Worker case GL_UNSIGNED_INT_IMAGE_CUBE_MAP_ARRAY:
597*8975f5c5SAndroid Build Coastguard Worker case GL_IMAGE_CUBE:
598*8975f5c5SAndroid Build Coastguard Worker case GL_INT_IMAGE_CUBE:
599*8975f5c5SAndroid Build Coastguard Worker case GL_UNSIGNED_INT_IMAGE_CUBE:
600*8975f5c5SAndroid Build Coastguard Worker case GL_IMAGE_BUFFER:
601*8975f5c5SAndroid Build Coastguard Worker case GL_INT_IMAGE_BUFFER:
602*8975f5c5SAndroid Build Coastguard Worker case GL_UNSIGNED_INT_IMAGE_BUFFER:
603*8975f5c5SAndroid Build Coastguard Worker return false;
604*8975f5c5SAndroid Build Coastguard Worker default:
605*8975f5c5SAndroid Build Coastguard Worker UNREACHABLE();
606*8975f5c5SAndroid Build Coastguard Worker return false;
607*8975f5c5SAndroid Build Coastguard Worker }
608*8975f5c5SAndroid Build Coastguard Worker }
609*8975f5c5SAndroid Build Coastguard Worker
IsAtomicCounterType(GLenum type)610*8975f5c5SAndroid Build Coastguard Worker bool IsAtomicCounterType(GLenum type)
611*8975f5c5SAndroid Build Coastguard Worker {
612*8975f5c5SAndroid Build Coastguard Worker return type == GL_UNSIGNED_INT_ATOMIC_COUNTER;
613*8975f5c5SAndroid Build Coastguard Worker }
614*8975f5c5SAndroid Build Coastguard Worker
IsOpaqueType(GLenum type)615*8975f5c5SAndroid Build Coastguard Worker bool IsOpaqueType(GLenum type)
616*8975f5c5SAndroid Build Coastguard Worker {
617*8975f5c5SAndroid Build Coastguard Worker // ESSL 3.10 section 4.1.7 defines opaque types as: samplers, images and atomic counters.
618*8975f5c5SAndroid Build Coastguard Worker return IsImageType(type) || IsSamplerType(type) || IsAtomicCounterType(type);
619*8975f5c5SAndroid Build Coastguard Worker }
620*8975f5c5SAndroid Build Coastguard Worker
IsMatrixType(GLenum type)621*8975f5c5SAndroid Build Coastguard Worker bool IsMatrixType(GLenum type)
622*8975f5c5SAndroid Build Coastguard Worker {
623*8975f5c5SAndroid Build Coastguard Worker return VariableRowCount(type) > 1;
624*8975f5c5SAndroid Build Coastguard Worker }
625*8975f5c5SAndroid Build Coastguard Worker
TransposeMatrixType(GLenum type)626*8975f5c5SAndroid Build Coastguard Worker GLenum TransposeMatrixType(GLenum type)
627*8975f5c5SAndroid Build Coastguard Worker {
628*8975f5c5SAndroid Build Coastguard Worker if (!IsMatrixType(type))
629*8975f5c5SAndroid Build Coastguard Worker {
630*8975f5c5SAndroid Build Coastguard Worker return type;
631*8975f5c5SAndroid Build Coastguard Worker }
632*8975f5c5SAndroid Build Coastguard Worker
633*8975f5c5SAndroid Build Coastguard Worker switch (type)
634*8975f5c5SAndroid Build Coastguard Worker {
635*8975f5c5SAndroid Build Coastguard Worker case GL_FLOAT_MAT2:
636*8975f5c5SAndroid Build Coastguard Worker return GL_FLOAT_MAT2;
637*8975f5c5SAndroid Build Coastguard Worker case GL_FLOAT_MAT3:
638*8975f5c5SAndroid Build Coastguard Worker return GL_FLOAT_MAT3;
639*8975f5c5SAndroid Build Coastguard Worker case GL_FLOAT_MAT4:
640*8975f5c5SAndroid Build Coastguard Worker return GL_FLOAT_MAT4;
641*8975f5c5SAndroid Build Coastguard Worker case GL_FLOAT_MAT2x3:
642*8975f5c5SAndroid Build Coastguard Worker return GL_FLOAT_MAT3x2;
643*8975f5c5SAndroid Build Coastguard Worker case GL_FLOAT_MAT3x2:
644*8975f5c5SAndroid Build Coastguard Worker return GL_FLOAT_MAT2x3;
645*8975f5c5SAndroid Build Coastguard Worker case GL_FLOAT_MAT2x4:
646*8975f5c5SAndroid Build Coastguard Worker return GL_FLOAT_MAT4x2;
647*8975f5c5SAndroid Build Coastguard Worker case GL_FLOAT_MAT4x2:
648*8975f5c5SAndroid Build Coastguard Worker return GL_FLOAT_MAT2x4;
649*8975f5c5SAndroid Build Coastguard Worker case GL_FLOAT_MAT3x4:
650*8975f5c5SAndroid Build Coastguard Worker return GL_FLOAT_MAT4x3;
651*8975f5c5SAndroid Build Coastguard Worker case GL_FLOAT_MAT4x3:
652*8975f5c5SAndroid Build Coastguard Worker return GL_FLOAT_MAT3x4;
653*8975f5c5SAndroid Build Coastguard Worker default:
654*8975f5c5SAndroid Build Coastguard Worker UNREACHABLE();
655*8975f5c5SAndroid Build Coastguard Worker return GL_NONE;
656*8975f5c5SAndroid Build Coastguard Worker }
657*8975f5c5SAndroid Build Coastguard Worker }
658*8975f5c5SAndroid Build Coastguard Worker
MatrixRegisterCount(GLenum type,bool isRowMajorMatrix)659*8975f5c5SAndroid Build Coastguard Worker int MatrixRegisterCount(GLenum type, bool isRowMajorMatrix)
660*8975f5c5SAndroid Build Coastguard Worker {
661*8975f5c5SAndroid Build Coastguard Worker ASSERT(IsMatrixType(type));
662*8975f5c5SAndroid Build Coastguard Worker return isRowMajorMatrix ? VariableRowCount(type) : VariableColumnCount(type);
663*8975f5c5SAndroid Build Coastguard Worker }
664*8975f5c5SAndroid Build Coastguard Worker
MatrixComponentCount(GLenum type,bool isRowMajorMatrix)665*8975f5c5SAndroid Build Coastguard Worker int MatrixComponentCount(GLenum type, bool isRowMajorMatrix)
666*8975f5c5SAndroid Build Coastguard Worker {
667*8975f5c5SAndroid Build Coastguard Worker ASSERT(IsMatrixType(type));
668*8975f5c5SAndroid Build Coastguard Worker return isRowMajorMatrix ? VariableColumnCount(type) : VariableRowCount(type);
669*8975f5c5SAndroid Build Coastguard Worker }
670*8975f5c5SAndroid Build Coastguard Worker
VariableRegisterCount(GLenum type)671*8975f5c5SAndroid Build Coastguard Worker int VariableRegisterCount(GLenum type)
672*8975f5c5SAndroid Build Coastguard Worker {
673*8975f5c5SAndroid Build Coastguard Worker return IsMatrixType(type) ? VariableColumnCount(type) : 1;
674*8975f5c5SAndroid Build Coastguard Worker }
675*8975f5c5SAndroid Build Coastguard Worker
AllocateFirstFreeBits(unsigned int * bits,unsigned int allocationSize,unsigned int bitsSize)676*8975f5c5SAndroid Build Coastguard Worker int AllocateFirstFreeBits(unsigned int *bits, unsigned int allocationSize, unsigned int bitsSize)
677*8975f5c5SAndroid Build Coastguard Worker {
678*8975f5c5SAndroid Build Coastguard Worker ASSERT(allocationSize <= bitsSize);
679*8975f5c5SAndroid Build Coastguard Worker
680*8975f5c5SAndroid Build Coastguard Worker unsigned int mask = std::numeric_limits<unsigned int>::max() >>
681*8975f5c5SAndroid Build Coastguard Worker (std::numeric_limits<unsigned int>::digits - allocationSize);
682*8975f5c5SAndroid Build Coastguard Worker
683*8975f5c5SAndroid Build Coastguard Worker for (unsigned int i = 0; i < bitsSize - allocationSize + 1; i++)
684*8975f5c5SAndroid Build Coastguard Worker {
685*8975f5c5SAndroid Build Coastguard Worker if ((*bits & mask) == 0)
686*8975f5c5SAndroid Build Coastguard Worker {
687*8975f5c5SAndroid Build Coastguard Worker *bits |= mask;
688*8975f5c5SAndroid Build Coastguard Worker return i;
689*8975f5c5SAndroid Build Coastguard Worker }
690*8975f5c5SAndroid Build Coastguard Worker
691*8975f5c5SAndroid Build Coastguard Worker mask <<= 1;
692*8975f5c5SAndroid Build Coastguard Worker }
693*8975f5c5SAndroid Build Coastguard Worker
694*8975f5c5SAndroid Build Coastguard Worker return -1;
695*8975f5c5SAndroid Build Coastguard Worker }
696*8975f5c5SAndroid Build Coastguard Worker
ComputeIndexRange(DrawElementsType indexType,const GLvoid * indices,size_t count,bool primitiveRestartEnabled)697*8975f5c5SAndroid Build Coastguard Worker IndexRange ComputeIndexRange(DrawElementsType indexType,
698*8975f5c5SAndroid Build Coastguard Worker const GLvoid *indices,
699*8975f5c5SAndroid Build Coastguard Worker size_t count,
700*8975f5c5SAndroid Build Coastguard Worker bool primitiveRestartEnabled)
701*8975f5c5SAndroid Build Coastguard Worker {
702*8975f5c5SAndroid Build Coastguard Worker switch (indexType)
703*8975f5c5SAndroid Build Coastguard Worker {
704*8975f5c5SAndroid Build Coastguard Worker case DrawElementsType::UnsignedByte:
705*8975f5c5SAndroid Build Coastguard Worker return ComputeTypedIndexRange(static_cast<const GLubyte *>(indices), count,
706*8975f5c5SAndroid Build Coastguard Worker primitiveRestartEnabled,
707*8975f5c5SAndroid Build Coastguard Worker GetPrimitiveRestartIndex(indexType));
708*8975f5c5SAndroid Build Coastguard Worker case DrawElementsType::UnsignedShort:
709*8975f5c5SAndroid Build Coastguard Worker return ComputeTypedIndexRange(static_cast<const GLushort *>(indices), count,
710*8975f5c5SAndroid Build Coastguard Worker primitiveRestartEnabled,
711*8975f5c5SAndroid Build Coastguard Worker GetPrimitiveRestartIndex(indexType));
712*8975f5c5SAndroid Build Coastguard Worker case DrawElementsType::UnsignedInt:
713*8975f5c5SAndroid Build Coastguard Worker return ComputeTypedIndexRange(static_cast<const GLuint *>(indices), count,
714*8975f5c5SAndroid Build Coastguard Worker primitiveRestartEnabled,
715*8975f5c5SAndroid Build Coastguard Worker GetPrimitiveRestartIndex(indexType));
716*8975f5c5SAndroid Build Coastguard Worker default:
717*8975f5c5SAndroid Build Coastguard Worker UNREACHABLE();
718*8975f5c5SAndroid Build Coastguard Worker return IndexRange();
719*8975f5c5SAndroid Build Coastguard Worker }
720*8975f5c5SAndroid Build Coastguard Worker }
721*8975f5c5SAndroid Build Coastguard Worker
GetPrimitiveRestartIndex(DrawElementsType indexType)722*8975f5c5SAndroid Build Coastguard Worker GLuint GetPrimitiveRestartIndex(DrawElementsType indexType)
723*8975f5c5SAndroid Build Coastguard Worker {
724*8975f5c5SAndroid Build Coastguard Worker switch (indexType)
725*8975f5c5SAndroid Build Coastguard Worker {
726*8975f5c5SAndroid Build Coastguard Worker case DrawElementsType::UnsignedByte:
727*8975f5c5SAndroid Build Coastguard Worker return 0xFF;
728*8975f5c5SAndroid Build Coastguard Worker case DrawElementsType::UnsignedShort:
729*8975f5c5SAndroid Build Coastguard Worker return 0xFFFF;
730*8975f5c5SAndroid Build Coastguard Worker case DrawElementsType::UnsignedInt:
731*8975f5c5SAndroid Build Coastguard Worker return 0xFFFFFFFF;
732*8975f5c5SAndroid Build Coastguard Worker default:
733*8975f5c5SAndroid Build Coastguard Worker UNREACHABLE();
734*8975f5c5SAndroid Build Coastguard Worker return 0;
735*8975f5c5SAndroid Build Coastguard Worker }
736*8975f5c5SAndroid Build Coastguard Worker }
737*8975f5c5SAndroid Build Coastguard Worker
IsTriangleMode(PrimitiveMode drawMode)738*8975f5c5SAndroid Build Coastguard Worker bool IsTriangleMode(PrimitiveMode drawMode)
739*8975f5c5SAndroid Build Coastguard Worker {
740*8975f5c5SAndroid Build Coastguard Worker switch (drawMode)
741*8975f5c5SAndroid Build Coastguard Worker {
742*8975f5c5SAndroid Build Coastguard Worker case PrimitiveMode::Triangles:
743*8975f5c5SAndroid Build Coastguard Worker case PrimitiveMode::TriangleFan:
744*8975f5c5SAndroid Build Coastguard Worker case PrimitiveMode::TriangleStrip:
745*8975f5c5SAndroid Build Coastguard Worker return true;
746*8975f5c5SAndroid Build Coastguard Worker case PrimitiveMode::Points:
747*8975f5c5SAndroid Build Coastguard Worker case PrimitiveMode::Lines:
748*8975f5c5SAndroid Build Coastguard Worker case PrimitiveMode::LineLoop:
749*8975f5c5SAndroid Build Coastguard Worker case PrimitiveMode::LineStrip:
750*8975f5c5SAndroid Build Coastguard Worker return false;
751*8975f5c5SAndroid Build Coastguard Worker default:
752*8975f5c5SAndroid Build Coastguard Worker UNREACHABLE();
753*8975f5c5SAndroid Build Coastguard Worker }
754*8975f5c5SAndroid Build Coastguard Worker
755*8975f5c5SAndroid Build Coastguard Worker return false;
756*8975f5c5SAndroid Build Coastguard Worker }
757*8975f5c5SAndroid Build Coastguard Worker
IsPolygonMode(PrimitiveMode mode)758*8975f5c5SAndroid Build Coastguard Worker bool IsPolygonMode(PrimitiveMode mode)
759*8975f5c5SAndroid Build Coastguard Worker {
760*8975f5c5SAndroid Build Coastguard Worker switch (mode)
761*8975f5c5SAndroid Build Coastguard Worker {
762*8975f5c5SAndroid Build Coastguard Worker case PrimitiveMode::Points:
763*8975f5c5SAndroid Build Coastguard Worker case PrimitiveMode::Lines:
764*8975f5c5SAndroid Build Coastguard Worker case PrimitiveMode::LineStrip:
765*8975f5c5SAndroid Build Coastguard Worker case PrimitiveMode::LineLoop:
766*8975f5c5SAndroid Build Coastguard Worker case PrimitiveMode::LinesAdjacency:
767*8975f5c5SAndroid Build Coastguard Worker case PrimitiveMode::LineStripAdjacency:
768*8975f5c5SAndroid Build Coastguard Worker return false;
769*8975f5c5SAndroid Build Coastguard Worker default:
770*8975f5c5SAndroid Build Coastguard Worker break;
771*8975f5c5SAndroid Build Coastguard Worker }
772*8975f5c5SAndroid Build Coastguard Worker
773*8975f5c5SAndroid Build Coastguard Worker return true;
774*8975f5c5SAndroid Build Coastguard Worker }
775*8975f5c5SAndroid Build Coastguard Worker
776*8975f5c5SAndroid Build Coastguard Worker namespace priv
777*8975f5c5SAndroid Build Coastguard Worker {
778*8975f5c5SAndroid Build Coastguard Worker const angle::PackedEnumMap<PrimitiveMode, bool> gLineModes = {
779*8975f5c5SAndroid Build Coastguard Worker {{PrimitiveMode::LineLoop, true},
780*8975f5c5SAndroid Build Coastguard Worker {PrimitiveMode::LineStrip, true},
781*8975f5c5SAndroid Build Coastguard Worker {PrimitiveMode::LineStripAdjacency, true},
782*8975f5c5SAndroid Build Coastguard Worker {PrimitiveMode::Lines, true}}};
783*8975f5c5SAndroid Build Coastguard Worker } // namespace priv
784*8975f5c5SAndroid Build Coastguard Worker
IsIntegerFormat(GLenum unsizedFormat)785*8975f5c5SAndroid Build Coastguard Worker bool IsIntegerFormat(GLenum unsizedFormat)
786*8975f5c5SAndroid Build Coastguard Worker {
787*8975f5c5SAndroid Build Coastguard Worker switch (unsizedFormat)
788*8975f5c5SAndroid Build Coastguard Worker {
789*8975f5c5SAndroid Build Coastguard Worker case GL_RGBA_INTEGER:
790*8975f5c5SAndroid Build Coastguard Worker case GL_RGB_INTEGER:
791*8975f5c5SAndroid Build Coastguard Worker case GL_RG_INTEGER:
792*8975f5c5SAndroid Build Coastguard Worker case GL_RED_INTEGER:
793*8975f5c5SAndroid Build Coastguard Worker return true;
794*8975f5c5SAndroid Build Coastguard Worker
795*8975f5c5SAndroid Build Coastguard Worker default:
796*8975f5c5SAndroid Build Coastguard Worker return false;
797*8975f5c5SAndroid Build Coastguard Worker }
798*8975f5c5SAndroid Build Coastguard Worker }
799*8975f5c5SAndroid Build Coastguard Worker
800*8975f5c5SAndroid Build Coastguard Worker // [OpenGL ES SL 3.00.4] Section 11 p. 120
801*8975f5c5SAndroid Build Coastguard Worker // Vertex Outs/Fragment Ins packing priorities
VariableSortOrder(GLenum type)802*8975f5c5SAndroid Build Coastguard Worker int VariableSortOrder(GLenum type)
803*8975f5c5SAndroid Build Coastguard Worker {
804*8975f5c5SAndroid Build Coastguard Worker switch (type)
805*8975f5c5SAndroid Build Coastguard Worker {
806*8975f5c5SAndroid Build Coastguard Worker // 1. Arrays of mat4 and mat4
807*8975f5c5SAndroid Build Coastguard Worker // Non-square matrices of type matCxR consume the same space as a square
808*8975f5c5SAndroid Build Coastguard Worker // matrix of type matN where N is the greater of C and R
809*8975f5c5SAndroid Build Coastguard Worker case GL_FLOAT_MAT4:
810*8975f5c5SAndroid Build Coastguard Worker case GL_FLOAT_MAT2x4:
811*8975f5c5SAndroid Build Coastguard Worker case GL_FLOAT_MAT3x4:
812*8975f5c5SAndroid Build Coastguard Worker case GL_FLOAT_MAT4x2:
813*8975f5c5SAndroid Build Coastguard Worker case GL_FLOAT_MAT4x3:
814*8975f5c5SAndroid Build Coastguard Worker return 0;
815*8975f5c5SAndroid Build Coastguard Worker
816*8975f5c5SAndroid Build Coastguard Worker // 2. Arrays of mat2 and mat2 (since they occupy full rows)
817*8975f5c5SAndroid Build Coastguard Worker case GL_FLOAT_MAT2:
818*8975f5c5SAndroid Build Coastguard Worker return 1;
819*8975f5c5SAndroid Build Coastguard Worker
820*8975f5c5SAndroid Build Coastguard Worker // 3. Arrays of vec4 and vec4
821*8975f5c5SAndroid Build Coastguard Worker case GL_FLOAT_VEC4:
822*8975f5c5SAndroid Build Coastguard Worker case GL_INT_VEC4:
823*8975f5c5SAndroid Build Coastguard Worker case GL_BOOL_VEC4:
824*8975f5c5SAndroid Build Coastguard Worker case GL_UNSIGNED_INT_VEC4:
825*8975f5c5SAndroid Build Coastguard Worker return 2;
826*8975f5c5SAndroid Build Coastguard Worker
827*8975f5c5SAndroid Build Coastguard Worker // 4. Arrays of mat3 and mat3
828*8975f5c5SAndroid Build Coastguard Worker case GL_FLOAT_MAT3:
829*8975f5c5SAndroid Build Coastguard Worker case GL_FLOAT_MAT2x3:
830*8975f5c5SAndroid Build Coastguard Worker case GL_FLOAT_MAT3x2:
831*8975f5c5SAndroid Build Coastguard Worker return 3;
832*8975f5c5SAndroid Build Coastguard Worker
833*8975f5c5SAndroid Build Coastguard Worker // 5. Arrays of vec3 and vec3
834*8975f5c5SAndroid Build Coastguard Worker case GL_FLOAT_VEC3:
835*8975f5c5SAndroid Build Coastguard Worker case GL_INT_VEC3:
836*8975f5c5SAndroid Build Coastguard Worker case GL_BOOL_VEC3:
837*8975f5c5SAndroid Build Coastguard Worker case GL_UNSIGNED_INT_VEC3:
838*8975f5c5SAndroid Build Coastguard Worker return 4;
839*8975f5c5SAndroid Build Coastguard Worker
840*8975f5c5SAndroid Build Coastguard Worker // 6. Arrays of vec2 and vec2
841*8975f5c5SAndroid Build Coastguard Worker case GL_FLOAT_VEC2:
842*8975f5c5SAndroid Build Coastguard Worker case GL_INT_VEC2:
843*8975f5c5SAndroid Build Coastguard Worker case GL_BOOL_VEC2:
844*8975f5c5SAndroid Build Coastguard Worker case GL_UNSIGNED_INT_VEC2:
845*8975f5c5SAndroid Build Coastguard Worker return 5;
846*8975f5c5SAndroid Build Coastguard Worker
847*8975f5c5SAndroid Build Coastguard Worker // 7. Single component types
848*8975f5c5SAndroid Build Coastguard Worker case GL_FLOAT:
849*8975f5c5SAndroid Build Coastguard Worker case GL_INT:
850*8975f5c5SAndroid Build Coastguard Worker case GL_BOOL:
851*8975f5c5SAndroid Build Coastguard Worker case GL_UNSIGNED_INT:
852*8975f5c5SAndroid Build Coastguard Worker case GL_SAMPLER_2D:
853*8975f5c5SAndroid Build Coastguard Worker case GL_SAMPLER_CUBE:
854*8975f5c5SAndroid Build Coastguard Worker case GL_SAMPLER_EXTERNAL_OES:
855*8975f5c5SAndroid Build Coastguard Worker case GL_SAMPLER_2D_RECT_ANGLE:
856*8975f5c5SAndroid Build Coastguard Worker case GL_SAMPLER_2D_ARRAY:
857*8975f5c5SAndroid Build Coastguard Worker case GL_SAMPLER_2D_MULTISAMPLE:
858*8975f5c5SAndroid Build Coastguard Worker case GL_SAMPLER_2D_MULTISAMPLE_ARRAY:
859*8975f5c5SAndroid Build Coastguard Worker case GL_SAMPLER_3D:
860*8975f5c5SAndroid Build Coastguard Worker case GL_INT_SAMPLER_2D:
861*8975f5c5SAndroid Build Coastguard Worker case GL_INT_SAMPLER_3D:
862*8975f5c5SAndroid Build Coastguard Worker case GL_INT_SAMPLER_CUBE:
863*8975f5c5SAndroid Build Coastguard Worker case GL_INT_SAMPLER_2D_ARRAY:
864*8975f5c5SAndroid Build Coastguard Worker case GL_INT_SAMPLER_2D_MULTISAMPLE:
865*8975f5c5SAndroid Build Coastguard Worker case GL_INT_SAMPLER_2D_MULTISAMPLE_ARRAY:
866*8975f5c5SAndroid Build Coastguard Worker case GL_UNSIGNED_INT_SAMPLER_2D:
867*8975f5c5SAndroid Build Coastguard Worker case GL_UNSIGNED_INT_SAMPLER_3D:
868*8975f5c5SAndroid Build Coastguard Worker case GL_UNSIGNED_INT_SAMPLER_CUBE:
869*8975f5c5SAndroid Build Coastguard Worker case GL_UNSIGNED_INT_SAMPLER_2D_ARRAY:
870*8975f5c5SAndroid Build Coastguard Worker case GL_UNSIGNED_INT_SAMPLER_2D_MULTISAMPLE:
871*8975f5c5SAndroid Build Coastguard Worker case GL_UNSIGNED_INT_SAMPLER_2D_MULTISAMPLE_ARRAY:
872*8975f5c5SAndroid Build Coastguard Worker case GL_SAMPLER_2D_SHADOW:
873*8975f5c5SAndroid Build Coastguard Worker case GL_SAMPLER_2D_ARRAY_SHADOW:
874*8975f5c5SAndroid Build Coastguard Worker case GL_SAMPLER_CUBE_SHADOW:
875*8975f5c5SAndroid Build Coastguard Worker case GL_IMAGE_2D:
876*8975f5c5SAndroid Build Coastguard Worker case GL_INT_IMAGE_2D:
877*8975f5c5SAndroid Build Coastguard Worker case GL_UNSIGNED_INT_IMAGE_2D:
878*8975f5c5SAndroid Build Coastguard Worker case GL_IMAGE_3D:
879*8975f5c5SAndroid Build Coastguard Worker case GL_INT_IMAGE_3D:
880*8975f5c5SAndroid Build Coastguard Worker case GL_UNSIGNED_INT_IMAGE_3D:
881*8975f5c5SAndroid Build Coastguard Worker case GL_IMAGE_2D_ARRAY:
882*8975f5c5SAndroid Build Coastguard Worker case GL_INT_IMAGE_2D_ARRAY:
883*8975f5c5SAndroid Build Coastguard Worker case GL_UNSIGNED_INT_IMAGE_2D_ARRAY:
884*8975f5c5SAndroid Build Coastguard Worker case GL_IMAGE_CUBE:
885*8975f5c5SAndroid Build Coastguard Worker case GL_INT_IMAGE_CUBE:
886*8975f5c5SAndroid Build Coastguard Worker case GL_UNSIGNED_INT_IMAGE_CUBE:
887*8975f5c5SAndroid Build Coastguard Worker case GL_UNSIGNED_INT_ATOMIC_COUNTER:
888*8975f5c5SAndroid Build Coastguard Worker case GL_SAMPLER_VIDEO_IMAGE_WEBGL:
889*8975f5c5SAndroid Build Coastguard Worker case GL_SAMPLER_EXTERNAL_2D_Y2Y_EXT:
890*8975f5c5SAndroid Build Coastguard Worker return 6;
891*8975f5c5SAndroid Build Coastguard Worker
892*8975f5c5SAndroid Build Coastguard Worker default:
893*8975f5c5SAndroid Build Coastguard Worker UNREACHABLE();
894*8975f5c5SAndroid Build Coastguard Worker return 0;
895*8975f5c5SAndroid Build Coastguard Worker }
896*8975f5c5SAndroid Build Coastguard Worker }
897*8975f5c5SAndroid Build Coastguard Worker
ParseResourceName(const std::string & name,std::vector<unsigned int> * outSubscripts)898*8975f5c5SAndroid Build Coastguard Worker std::string ParseResourceName(const std::string &name, std::vector<unsigned int> *outSubscripts)
899*8975f5c5SAndroid Build Coastguard Worker {
900*8975f5c5SAndroid Build Coastguard Worker if (outSubscripts)
901*8975f5c5SAndroid Build Coastguard Worker {
902*8975f5c5SAndroid Build Coastguard Worker outSubscripts->clear();
903*8975f5c5SAndroid Build Coastguard Worker }
904*8975f5c5SAndroid Build Coastguard Worker // Strip any trailing array indexing operators and retrieve the subscripts.
905*8975f5c5SAndroid Build Coastguard Worker size_t baseNameLength = name.length();
906*8975f5c5SAndroid Build Coastguard Worker bool hasIndex = true;
907*8975f5c5SAndroid Build Coastguard Worker while (hasIndex)
908*8975f5c5SAndroid Build Coastguard Worker {
909*8975f5c5SAndroid Build Coastguard Worker size_t open = name.find_last_of('[', baseNameLength - 1);
910*8975f5c5SAndroid Build Coastguard Worker size_t close = name.find_last_of(']', baseNameLength - 1);
911*8975f5c5SAndroid Build Coastguard Worker hasIndex = (open != std::string::npos) && (close == baseNameLength - 1);
912*8975f5c5SAndroid Build Coastguard Worker if (hasIndex)
913*8975f5c5SAndroid Build Coastguard Worker {
914*8975f5c5SAndroid Build Coastguard Worker baseNameLength = open;
915*8975f5c5SAndroid Build Coastguard Worker if (outSubscripts)
916*8975f5c5SAndroid Build Coastguard Worker {
917*8975f5c5SAndroid Build Coastguard Worker int index = atoi(name.substr(open + 1).c_str());
918*8975f5c5SAndroid Build Coastguard Worker if (index >= 0)
919*8975f5c5SAndroid Build Coastguard Worker {
920*8975f5c5SAndroid Build Coastguard Worker outSubscripts->push_back(index);
921*8975f5c5SAndroid Build Coastguard Worker }
922*8975f5c5SAndroid Build Coastguard Worker else
923*8975f5c5SAndroid Build Coastguard Worker {
924*8975f5c5SAndroid Build Coastguard Worker outSubscripts->push_back(GL_INVALID_INDEX);
925*8975f5c5SAndroid Build Coastguard Worker }
926*8975f5c5SAndroid Build Coastguard Worker }
927*8975f5c5SAndroid Build Coastguard Worker }
928*8975f5c5SAndroid Build Coastguard Worker }
929*8975f5c5SAndroid Build Coastguard Worker
930*8975f5c5SAndroid Build Coastguard Worker return name.substr(0, baseNameLength);
931*8975f5c5SAndroid Build Coastguard Worker }
932*8975f5c5SAndroid Build Coastguard Worker
IsBuiltInName(const char * name)933*8975f5c5SAndroid Build Coastguard Worker bool IsBuiltInName(const char *name)
934*8975f5c5SAndroid Build Coastguard Worker {
935*8975f5c5SAndroid Build Coastguard Worker return angle::BeginsWith(name, "gl_");
936*8975f5c5SAndroid Build Coastguard Worker }
937*8975f5c5SAndroid Build Coastguard Worker
StripLastArrayIndex(const std::string & name)938*8975f5c5SAndroid Build Coastguard Worker std::string StripLastArrayIndex(const std::string &name)
939*8975f5c5SAndroid Build Coastguard Worker {
940*8975f5c5SAndroid Build Coastguard Worker size_t strippedNameLength = name.find_last_of('[');
941*8975f5c5SAndroid Build Coastguard Worker if (strippedNameLength != std::string::npos && name.back() == ']')
942*8975f5c5SAndroid Build Coastguard Worker {
943*8975f5c5SAndroid Build Coastguard Worker return name.substr(0, strippedNameLength);
944*8975f5c5SAndroid Build Coastguard Worker }
945*8975f5c5SAndroid Build Coastguard Worker return name;
946*8975f5c5SAndroid Build Coastguard Worker }
947*8975f5c5SAndroid Build Coastguard Worker
SamplerNameContainsNonZeroArrayElement(const std::string & name)948*8975f5c5SAndroid Build Coastguard Worker bool SamplerNameContainsNonZeroArrayElement(const std::string &name)
949*8975f5c5SAndroid Build Coastguard Worker {
950*8975f5c5SAndroid Build Coastguard Worker constexpr char kZERO_ELEMENT[] = "[0]";
951*8975f5c5SAndroid Build Coastguard Worker
952*8975f5c5SAndroid Build Coastguard Worker size_t start = 0;
953*8975f5c5SAndroid Build Coastguard Worker while (true)
954*8975f5c5SAndroid Build Coastguard Worker {
955*8975f5c5SAndroid Build Coastguard Worker start = name.find(kZERO_ELEMENT[0], start);
956*8975f5c5SAndroid Build Coastguard Worker if (start == std::string::npos)
957*8975f5c5SAndroid Build Coastguard Worker {
958*8975f5c5SAndroid Build Coastguard Worker break;
959*8975f5c5SAndroid Build Coastguard Worker }
960*8975f5c5SAndroid Build Coastguard Worker if (name.compare(start, strlen(kZERO_ELEMENT), kZERO_ELEMENT) != 0)
961*8975f5c5SAndroid Build Coastguard Worker {
962*8975f5c5SAndroid Build Coastguard Worker return true;
963*8975f5c5SAndroid Build Coastguard Worker }
964*8975f5c5SAndroid Build Coastguard Worker start++;
965*8975f5c5SAndroid Build Coastguard Worker }
966*8975f5c5SAndroid Build Coastguard Worker return false;
967*8975f5c5SAndroid Build Coastguard Worker }
968*8975f5c5SAndroid Build Coastguard Worker
ArraySizeProduct(const std::vector<unsigned int> & arraySizes)969*8975f5c5SAndroid Build Coastguard Worker unsigned int ArraySizeProduct(const std::vector<unsigned int> &arraySizes)
970*8975f5c5SAndroid Build Coastguard Worker {
971*8975f5c5SAndroid Build Coastguard Worker unsigned int arraySizeProduct = 1u;
972*8975f5c5SAndroid Build Coastguard Worker for (unsigned int arraySize : arraySizes)
973*8975f5c5SAndroid Build Coastguard Worker {
974*8975f5c5SAndroid Build Coastguard Worker arraySizeProduct *= arraySize;
975*8975f5c5SAndroid Build Coastguard Worker }
976*8975f5c5SAndroid Build Coastguard Worker return arraySizeProduct;
977*8975f5c5SAndroid Build Coastguard Worker }
978*8975f5c5SAndroid Build Coastguard Worker
InnerArraySizeProduct(const std::vector<unsigned int> & arraySizes)979*8975f5c5SAndroid Build Coastguard Worker unsigned int InnerArraySizeProduct(const std::vector<unsigned int> &arraySizes)
980*8975f5c5SAndroid Build Coastguard Worker {
981*8975f5c5SAndroid Build Coastguard Worker unsigned int arraySizeProduct = 1u;
982*8975f5c5SAndroid Build Coastguard Worker for (size_t index = 0; index + 1 < arraySizes.size(); ++index)
983*8975f5c5SAndroid Build Coastguard Worker {
984*8975f5c5SAndroid Build Coastguard Worker arraySizeProduct *= arraySizes[index];
985*8975f5c5SAndroid Build Coastguard Worker }
986*8975f5c5SAndroid Build Coastguard Worker return arraySizeProduct;
987*8975f5c5SAndroid Build Coastguard Worker }
988*8975f5c5SAndroid Build Coastguard Worker
OutermostArraySize(const std::vector<unsigned int> & arraySizes)989*8975f5c5SAndroid Build Coastguard Worker unsigned int OutermostArraySize(const std::vector<unsigned int> &arraySizes)
990*8975f5c5SAndroid Build Coastguard Worker {
991*8975f5c5SAndroid Build Coastguard Worker return arraySizes.empty() || arraySizes.back() == 0 ? 1 : arraySizes.back();
992*8975f5c5SAndroid Build Coastguard Worker }
993*8975f5c5SAndroid Build Coastguard Worker
ParseArrayIndex(const std::string & name,size_t * nameLengthWithoutArrayIndexOut)994*8975f5c5SAndroid Build Coastguard Worker unsigned int ParseArrayIndex(const std::string &name, size_t *nameLengthWithoutArrayIndexOut)
995*8975f5c5SAndroid Build Coastguard Worker {
996*8975f5c5SAndroid Build Coastguard Worker ASSERT(nameLengthWithoutArrayIndexOut != nullptr);
997*8975f5c5SAndroid Build Coastguard Worker
998*8975f5c5SAndroid Build Coastguard Worker // Strip any trailing array operator and retrieve the subscript
999*8975f5c5SAndroid Build Coastguard Worker size_t open = name.find_last_of('[');
1000*8975f5c5SAndroid Build Coastguard Worker if (open != std::string::npos && name.back() == ']')
1001*8975f5c5SAndroid Build Coastguard Worker {
1002*8975f5c5SAndroid Build Coastguard Worker bool indexIsValidDecimalNumber = true;
1003*8975f5c5SAndroid Build Coastguard Worker for (size_t i = open + 1; i < name.length() - 1u; ++i)
1004*8975f5c5SAndroid Build Coastguard Worker {
1005*8975f5c5SAndroid Build Coastguard Worker if (!isdigit(name[i]))
1006*8975f5c5SAndroid Build Coastguard Worker {
1007*8975f5c5SAndroid Build Coastguard Worker indexIsValidDecimalNumber = false;
1008*8975f5c5SAndroid Build Coastguard Worker break;
1009*8975f5c5SAndroid Build Coastguard Worker }
1010*8975f5c5SAndroid Build Coastguard Worker
1011*8975f5c5SAndroid Build Coastguard Worker // Leading zeroes are invalid
1012*8975f5c5SAndroid Build Coastguard Worker if ((i == (open + 1)) && (name[i] == '0') && (name[i + 1] != ']'))
1013*8975f5c5SAndroid Build Coastguard Worker {
1014*8975f5c5SAndroid Build Coastguard Worker indexIsValidDecimalNumber = false;
1015*8975f5c5SAndroid Build Coastguard Worker break;
1016*8975f5c5SAndroid Build Coastguard Worker }
1017*8975f5c5SAndroid Build Coastguard Worker }
1018*8975f5c5SAndroid Build Coastguard Worker if (indexIsValidDecimalNumber)
1019*8975f5c5SAndroid Build Coastguard Worker {
1020*8975f5c5SAndroid Build Coastguard Worker errno = 0; // reset global error flag.
1021*8975f5c5SAndroid Build Coastguard Worker unsigned long subscript =
1022*8975f5c5SAndroid Build Coastguard Worker strtoul(name.c_str() + open + 1, /*endptr*/ nullptr, /*radix*/ 10);
1023*8975f5c5SAndroid Build Coastguard Worker
1024*8975f5c5SAndroid Build Coastguard Worker // Check if resulting integer is out-of-range or conversion error.
1025*8975f5c5SAndroid Build Coastguard Worker if (angle::base::IsValueInRangeForNumericType<uint32_t>(subscript) &&
1026*8975f5c5SAndroid Build Coastguard Worker !(subscript == ULONG_MAX && errno == ERANGE) && !(errno != 0 && subscript == 0))
1027*8975f5c5SAndroid Build Coastguard Worker {
1028*8975f5c5SAndroid Build Coastguard Worker *nameLengthWithoutArrayIndexOut = open;
1029*8975f5c5SAndroid Build Coastguard Worker return static_cast<unsigned int>(subscript);
1030*8975f5c5SAndroid Build Coastguard Worker }
1031*8975f5c5SAndroid Build Coastguard Worker }
1032*8975f5c5SAndroid Build Coastguard Worker }
1033*8975f5c5SAndroid Build Coastguard Worker
1034*8975f5c5SAndroid Build Coastguard Worker *nameLengthWithoutArrayIndexOut = name.length();
1035*8975f5c5SAndroid Build Coastguard Worker return GL_INVALID_INDEX;
1036*8975f5c5SAndroid Build Coastguard Worker }
1037*8975f5c5SAndroid Build Coastguard Worker
GetGenericErrorMessage(GLenum error)1038*8975f5c5SAndroid Build Coastguard Worker const char *GetGenericErrorMessage(GLenum error)
1039*8975f5c5SAndroid Build Coastguard Worker {
1040*8975f5c5SAndroid Build Coastguard Worker switch (error)
1041*8975f5c5SAndroid Build Coastguard Worker {
1042*8975f5c5SAndroid Build Coastguard Worker case GL_NO_ERROR:
1043*8975f5c5SAndroid Build Coastguard Worker return "";
1044*8975f5c5SAndroid Build Coastguard Worker case GL_INVALID_ENUM:
1045*8975f5c5SAndroid Build Coastguard Worker return "Invalid enum.";
1046*8975f5c5SAndroid Build Coastguard Worker case GL_INVALID_VALUE:
1047*8975f5c5SAndroid Build Coastguard Worker return "Invalid value.";
1048*8975f5c5SAndroid Build Coastguard Worker case GL_INVALID_OPERATION:
1049*8975f5c5SAndroid Build Coastguard Worker return "Invalid operation.";
1050*8975f5c5SAndroid Build Coastguard Worker case GL_STACK_OVERFLOW:
1051*8975f5c5SAndroid Build Coastguard Worker return "Stack overflow.";
1052*8975f5c5SAndroid Build Coastguard Worker case GL_STACK_UNDERFLOW:
1053*8975f5c5SAndroid Build Coastguard Worker return "Stack underflow.";
1054*8975f5c5SAndroid Build Coastguard Worker case GL_OUT_OF_MEMORY:
1055*8975f5c5SAndroid Build Coastguard Worker return "Out of memory.";
1056*8975f5c5SAndroid Build Coastguard Worker case GL_INVALID_FRAMEBUFFER_OPERATION:
1057*8975f5c5SAndroid Build Coastguard Worker return "Invalid framebuffer operation.";
1058*8975f5c5SAndroid Build Coastguard Worker default:
1059*8975f5c5SAndroid Build Coastguard Worker UNREACHABLE();
1060*8975f5c5SAndroid Build Coastguard Worker return "Unknown error.";
1061*8975f5c5SAndroid Build Coastguard Worker }
1062*8975f5c5SAndroid Build Coastguard Worker }
1063*8975f5c5SAndroid Build Coastguard Worker
ElementTypeSize(GLenum elementType)1064*8975f5c5SAndroid Build Coastguard Worker unsigned int ElementTypeSize(GLenum elementType)
1065*8975f5c5SAndroid Build Coastguard Worker {
1066*8975f5c5SAndroid Build Coastguard Worker switch (elementType)
1067*8975f5c5SAndroid Build Coastguard Worker {
1068*8975f5c5SAndroid Build Coastguard Worker case GL_UNSIGNED_BYTE:
1069*8975f5c5SAndroid Build Coastguard Worker return sizeof(GLubyte);
1070*8975f5c5SAndroid Build Coastguard Worker case GL_UNSIGNED_SHORT:
1071*8975f5c5SAndroid Build Coastguard Worker return sizeof(GLushort);
1072*8975f5c5SAndroid Build Coastguard Worker case GL_UNSIGNED_INT:
1073*8975f5c5SAndroid Build Coastguard Worker return sizeof(GLuint);
1074*8975f5c5SAndroid Build Coastguard Worker default:
1075*8975f5c5SAndroid Build Coastguard Worker UNREACHABLE();
1076*8975f5c5SAndroid Build Coastguard Worker return 0;
1077*8975f5c5SAndroid Build Coastguard Worker }
1078*8975f5c5SAndroid Build Coastguard Worker }
1079*8975f5c5SAndroid Build Coastguard Worker
IsMipmapFiltered(GLenum minFilterMode)1080*8975f5c5SAndroid Build Coastguard Worker bool IsMipmapFiltered(GLenum minFilterMode)
1081*8975f5c5SAndroid Build Coastguard Worker {
1082*8975f5c5SAndroid Build Coastguard Worker switch (minFilterMode)
1083*8975f5c5SAndroid Build Coastguard Worker {
1084*8975f5c5SAndroid Build Coastguard Worker case GL_NEAREST:
1085*8975f5c5SAndroid Build Coastguard Worker case GL_LINEAR:
1086*8975f5c5SAndroid Build Coastguard Worker return false;
1087*8975f5c5SAndroid Build Coastguard Worker case GL_NEAREST_MIPMAP_NEAREST:
1088*8975f5c5SAndroid Build Coastguard Worker case GL_LINEAR_MIPMAP_NEAREST:
1089*8975f5c5SAndroid Build Coastguard Worker case GL_NEAREST_MIPMAP_LINEAR:
1090*8975f5c5SAndroid Build Coastguard Worker case GL_LINEAR_MIPMAP_LINEAR:
1091*8975f5c5SAndroid Build Coastguard Worker return true;
1092*8975f5c5SAndroid Build Coastguard Worker default:
1093*8975f5c5SAndroid Build Coastguard Worker UNREACHABLE();
1094*8975f5c5SAndroid Build Coastguard Worker return false;
1095*8975f5c5SAndroid Build Coastguard Worker }
1096*8975f5c5SAndroid Build Coastguard Worker }
1097*8975f5c5SAndroid Build Coastguard Worker
GetPipelineType(ShaderType type)1098*8975f5c5SAndroid Build Coastguard Worker PipelineType GetPipelineType(ShaderType type)
1099*8975f5c5SAndroid Build Coastguard Worker {
1100*8975f5c5SAndroid Build Coastguard Worker switch (type)
1101*8975f5c5SAndroid Build Coastguard Worker {
1102*8975f5c5SAndroid Build Coastguard Worker case ShaderType::Vertex:
1103*8975f5c5SAndroid Build Coastguard Worker case ShaderType::Fragment:
1104*8975f5c5SAndroid Build Coastguard Worker case ShaderType::Geometry:
1105*8975f5c5SAndroid Build Coastguard Worker return PipelineType::GraphicsPipeline;
1106*8975f5c5SAndroid Build Coastguard Worker case ShaderType::Compute:
1107*8975f5c5SAndroid Build Coastguard Worker return PipelineType::ComputePipeline;
1108*8975f5c5SAndroid Build Coastguard Worker default:
1109*8975f5c5SAndroid Build Coastguard Worker UNREACHABLE();
1110*8975f5c5SAndroid Build Coastguard Worker return PipelineType::GraphicsPipeline;
1111*8975f5c5SAndroid Build Coastguard Worker }
1112*8975f5c5SAndroid Build Coastguard Worker }
1113*8975f5c5SAndroid Build Coastguard Worker
GetDebugMessageSourceString(GLenum source)1114*8975f5c5SAndroid Build Coastguard Worker const char *GetDebugMessageSourceString(GLenum source)
1115*8975f5c5SAndroid Build Coastguard Worker {
1116*8975f5c5SAndroid Build Coastguard Worker switch (source)
1117*8975f5c5SAndroid Build Coastguard Worker {
1118*8975f5c5SAndroid Build Coastguard Worker case GL_DEBUG_SOURCE_API:
1119*8975f5c5SAndroid Build Coastguard Worker return "API";
1120*8975f5c5SAndroid Build Coastguard Worker case GL_DEBUG_SOURCE_WINDOW_SYSTEM:
1121*8975f5c5SAndroid Build Coastguard Worker return "Window System";
1122*8975f5c5SAndroid Build Coastguard Worker case GL_DEBUG_SOURCE_SHADER_COMPILER:
1123*8975f5c5SAndroid Build Coastguard Worker return "Shader Compiler";
1124*8975f5c5SAndroid Build Coastguard Worker case GL_DEBUG_SOURCE_THIRD_PARTY:
1125*8975f5c5SAndroid Build Coastguard Worker return "Third Party";
1126*8975f5c5SAndroid Build Coastguard Worker case GL_DEBUG_SOURCE_APPLICATION:
1127*8975f5c5SAndroid Build Coastguard Worker return "Application";
1128*8975f5c5SAndroid Build Coastguard Worker case GL_DEBUG_SOURCE_OTHER:
1129*8975f5c5SAndroid Build Coastguard Worker return "Other";
1130*8975f5c5SAndroid Build Coastguard Worker default:
1131*8975f5c5SAndroid Build Coastguard Worker return "Unknown Source";
1132*8975f5c5SAndroid Build Coastguard Worker }
1133*8975f5c5SAndroid Build Coastguard Worker }
1134*8975f5c5SAndroid Build Coastguard Worker
GetDebugMessageTypeString(GLenum type)1135*8975f5c5SAndroid Build Coastguard Worker const char *GetDebugMessageTypeString(GLenum type)
1136*8975f5c5SAndroid Build Coastguard Worker {
1137*8975f5c5SAndroid Build Coastguard Worker switch (type)
1138*8975f5c5SAndroid Build Coastguard Worker {
1139*8975f5c5SAndroid Build Coastguard Worker case GL_DEBUG_TYPE_ERROR:
1140*8975f5c5SAndroid Build Coastguard Worker return "Error";
1141*8975f5c5SAndroid Build Coastguard Worker case GL_DEBUG_TYPE_DEPRECATED_BEHAVIOR:
1142*8975f5c5SAndroid Build Coastguard Worker return "Deprecated behavior";
1143*8975f5c5SAndroid Build Coastguard Worker case GL_DEBUG_TYPE_UNDEFINED_BEHAVIOR:
1144*8975f5c5SAndroid Build Coastguard Worker return "Undefined behavior";
1145*8975f5c5SAndroid Build Coastguard Worker case GL_DEBUG_TYPE_PORTABILITY:
1146*8975f5c5SAndroid Build Coastguard Worker return "Portability";
1147*8975f5c5SAndroid Build Coastguard Worker case GL_DEBUG_TYPE_PERFORMANCE:
1148*8975f5c5SAndroid Build Coastguard Worker return "Performance";
1149*8975f5c5SAndroid Build Coastguard Worker case GL_DEBUG_TYPE_OTHER:
1150*8975f5c5SAndroid Build Coastguard Worker return "Other";
1151*8975f5c5SAndroid Build Coastguard Worker case GL_DEBUG_TYPE_MARKER:
1152*8975f5c5SAndroid Build Coastguard Worker return "Marker";
1153*8975f5c5SAndroid Build Coastguard Worker default:
1154*8975f5c5SAndroid Build Coastguard Worker return "Unknown Type";
1155*8975f5c5SAndroid Build Coastguard Worker }
1156*8975f5c5SAndroid Build Coastguard Worker }
1157*8975f5c5SAndroid Build Coastguard Worker
GetDebugMessageSeverityString(GLenum severity)1158*8975f5c5SAndroid Build Coastguard Worker const char *GetDebugMessageSeverityString(GLenum severity)
1159*8975f5c5SAndroid Build Coastguard Worker {
1160*8975f5c5SAndroid Build Coastguard Worker switch (severity)
1161*8975f5c5SAndroid Build Coastguard Worker {
1162*8975f5c5SAndroid Build Coastguard Worker case GL_DEBUG_SEVERITY_HIGH:
1163*8975f5c5SAndroid Build Coastguard Worker return "High";
1164*8975f5c5SAndroid Build Coastguard Worker case GL_DEBUG_SEVERITY_MEDIUM:
1165*8975f5c5SAndroid Build Coastguard Worker return "Medium";
1166*8975f5c5SAndroid Build Coastguard Worker case GL_DEBUG_SEVERITY_LOW:
1167*8975f5c5SAndroid Build Coastguard Worker return "Low";
1168*8975f5c5SAndroid Build Coastguard Worker case GL_DEBUG_SEVERITY_NOTIFICATION:
1169*8975f5c5SAndroid Build Coastguard Worker return "Notification";
1170*8975f5c5SAndroid Build Coastguard Worker default:
1171*8975f5c5SAndroid Build Coastguard Worker return "Unknown Severity";
1172*8975f5c5SAndroid Build Coastguard Worker }
1173*8975f5c5SAndroid Build Coastguard Worker }
1174*8975f5c5SAndroid Build Coastguard Worker
GetShaderTypeFromBitfield(size_t singleShaderType)1175*8975f5c5SAndroid Build Coastguard Worker ShaderType GetShaderTypeFromBitfield(size_t singleShaderType)
1176*8975f5c5SAndroid Build Coastguard Worker {
1177*8975f5c5SAndroid Build Coastguard Worker switch (singleShaderType)
1178*8975f5c5SAndroid Build Coastguard Worker {
1179*8975f5c5SAndroid Build Coastguard Worker case GL_VERTEX_SHADER_BIT:
1180*8975f5c5SAndroid Build Coastguard Worker return ShaderType::Vertex;
1181*8975f5c5SAndroid Build Coastguard Worker case GL_FRAGMENT_SHADER_BIT:
1182*8975f5c5SAndroid Build Coastguard Worker return ShaderType::Fragment;
1183*8975f5c5SAndroid Build Coastguard Worker case GL_COMPUTE_SHADER_BIT:
1184*8975f5c5SAndroid Build Coastguard Worker return ShaderType::Compute;
1185*8975f5c5SAndroid Build Coastguard Worker case GL_GEOMETRY_SHADER_BIT:
1186*8975f5c5SAndroid Build Coastguard Worker return ShaderType::Geometry;
1187*8975f5c5SAndroid Build Coastguard Worker case GL_TESS_CONTROL_SHADER_BIT:
1188*8975f5c5SAndroid Build Coastguard Worker return ShaderType::TessControl;
1189*8975f5c5SAndroid Build Coastguard Worker case GL_TESS_EVALUATION_SHADER_BIT:
1190*8975f5c5SAndroid Build Coastguard Worker return ShaderType::TessEvaluation;
1191*8975f5c5SAndroid Build Coastguard Worker default:
1192*8975f5c5SAndroid Build Coastguard Worker return ShaderType::InvalidEnum;
1193*8975f5c5SAndroid Build Coastguard Worker }
1194*8975f5c5SAndroid Build Coastguard Worker }
1195*8975f5c5SAndroid Build Coastguard Worker
GetBitfieldFromShaderType(ShaderType shaderType)1196*8975f5c5SAndroid Build Coastguard Worker GLbitfield GetBitfieldFromShaderType(ShaderType shaderType)
1197*8975f5c5SAndroid Build Coastguard Worker {
1198*8975f5c5SAndroid Build Coastguard Worker switch (shaderType)
1199*8975f5c5SAndroid Build Coastguard Worker {
1200*8975f5c5SAndroid Build Coastguard Worker case ShaderType::Vertex:
1201*8975f5c5SAndroid Build Coastguard Worker return GL_VERTEX_SHADER_BIT;
1202*8975f5c5SAndroid Build Coastguard Worker case ShaderType::Fragment:
1203*8975f5c5SAndroid Build Coastguard Worker return GL_FRAGMENT_SHADER_BIT;
1204*8975f5c5SAndroid Build Coastguard Worker case ShaderType::Compute:
1205*8975f5c5SAndroid Build Coastguard Worker return GL_COMPUTE_SHADER_BIT;
1206*8975f5c5SAndroid Build Coastguard Worker case ShaderType::Geometry:
1207*8975f5c5SAndroid Build Coastguard Worker return GL_GEOMETRY_SHADER_BIT;
1208*8975f5c5SAndroid Build Coastguard Worker case ShaderType::TessControl:
1209*8975f5c5SAndroid Build Coastguard Worker return GL_TESS_CONTROL_SHADER_BIT;
1210*8975f5c5SAndroid Build Coastguard Worker case ShaderType::TessEvaluation:
1211*8975f5c5SAndroid Build Coastguard Worker return GL_TESS_EVALUATION_SHADER_BIT;
1212*8975f5c5SAndroid Build Coastguard Worker default:
1213*8975f5c5SAndroid Build Coastguard Worker UNREACHABLE();
1214*8975f5c5SAndroid Build Coastguard Worker return GL_ZERO;
1215*8975f5c5SAndroid Build Coastguard Worker }
1216*8975f5c5SAndroid Build Coastguard Worker }
1217*8975f5c5SAndroid Build Coastguard Worker
ShaderTypeSupportsTransformFeedback(ShaderType shaderType)1218*8975f5c5SAndroid Build Coastguard Worker bool ShaderTypeSupportsTransformFeedback(ShaderType shaderType)
1219*8975f5c5SAndroid Build Coastguard Worker {
1220*8975f5c5SAndroid Build Coastguard Worker switch (shaderType)
1221*8975f5c5SAndroid Build Coastguard Worker {
1222*8975f5c5SAndroid Build Coastguard Worker case ShaderType::Vertex:
1223*8975f5c5SAndroid Build Coastguard Worker case ShaderType::Geometry:
1224*8975f5c5SAndroid Build Coastguard Worker case ShaderType::TessEvaluation:
1225*8975f5c5SAndroid Build Coastguard Worker return true;
1226*8975f5c5SAndroid Build Coastguard Worker default:
1227*8975f5c5SAndroid Build Coastguard Worker return false;
1228*8975f5c5SAndroid Build Coastguard Worker }
1229*8975f5c5SAndroid Build Coastguard Worker }
1230*8975f5c5SAndroid Build Coastguard Worker
GetLastPreFragmentStage(ShaderBitSet shaderTypes)1231*8975f5c5SAndroid Build Coastguard Worker ShaderType GetLastPreFragmentStage(ShaderBitSet shaderTypes)
1232*8975f5c5SAndroid Build Coastguard Worker {
1233*8975f5c5SAndroid Build Coastguard Worker shaderTypes.reset(ShaderType::Fragment);
1234*8975f5c5SAndroid Build Coastguard Worker shaderTypes.reset(ShaderType::Compute);
1235*8975f5c5SAndroid Build Coastguard Worker return shaderTypes.any() ? shaderTypes.last() : ShaderType::InvalidEnum;
1236*8975f5c5SAndroid Build Coastguard Worker }
1237*8975f5c5SAndroid Build Coastguard Worker } // namespace gl
1238*8975f5c5SAndroid Build Coastguard Worker
1239*8975f5c5SAndroid Build Coastguard Worker namespace egl
1240*8975f5c5SAndroid Build Coastguard Worker {
1241*8975f5c5SAndroid Build Coastguard Worker static_assert(EGL_GL_TEXTURE_CUBE_MAP_NEGATIVE_X_KHR - EGL_GL_TEXTURE_CUBE_MAP_POSITIVE_X_KHR == 1,
1242*8975f5c5SAndroid Build Coastguard Worker "Unexpected EGL cube map enum value.");
1243*8975f5c5SAndroid Build Coastguard Worker static_assert(EGL_GL_TEXTURE_CUBE_MAP_POSITIVE_Y_KHR - EGL_GL_TEXTURE_CUBE_MAP_POSITIVE_X_KHR == 2,
1244*8975f5c5SAndroid Build Coastguard Worker "Unexpected EGL cube map enum value.");
1245*8975f5c5SAndroid Build Coastguard Worker static_assert(EGL_GL_TEXTURE_CUBE_MAP_NEGATIVE_Y_KHR - EGL_GL_TEXTURE_CUBE_MAP_POSITIVE_X_KHR == 3,
1246*8975f5c5SAndroid Build Coastguard Worker "Unexpected EGL cube map enum value.");
1247*8975f5c5SAndroid Build Coastguard Worker static_assert(EGL_GL_TEXTURE_CUBE_MAP_POSITIVE_Z_KHR - EGL_GL_TEXTURE_CUBE_MAP_POSITIVE_X_KHR == 4,
1248*8975f5c5SAndroid Build Coastguard Worker "Unexpected EGL cube map enum value.");
1249*8975f5c5SAndroid Build Coastguard Worker static_assert(EGL_GL_TEXTURE_CUBE_MAP_NEGATIVE_Z_KHR - EGL_GL_TEXTURE_CUBE_MAP_POSITIVE_X_KHR == 5,
1250*8975f5c5SAndroid Build Coastguard Worker "Unexpected EGL cube map enum value.");
1251*8975f5c5SAndroid Build Coastguard Worker
IsCubeMapTextureTarget(EGLenum target)1252*8975f5c5SAndroid Build Coastguard Worker bool IsCubeMapTextureTarget(EGLenum target)
1253*8975f5c5SAndroid Build Coastguard Worker {
1254*8975f5c5SAndroid Build Coastguard Worker return (target >= FirstCubeMapTextureTarget && target <= LastCubeMapTextureTarget);
1255*8975f5c5SAndroid Build Coastguard Worker }
1256*8975f5c5SAndroid Build Coastguard Worker
CubeMapTextureTargetToLayerIndex(EGLenum target)1257*8975f5c5SAndroid Build Coastguard Worker size_t CubeMapTextureTargetToLayerIndex(EGLenum target)
1258*8975f5c5SAndroid Build Coastguard Worker {
1259*8975f5c5SAndroid Build Coastguard Worker ASSERT(IsCubeMapTextureTarget(target));
1260*8975f5c5SAndroid Build Coastguard Worker return target - static_cast<size_t>(FirstCubeMapTextureTarget);
1261*8975f5c5SAndroid Build Coastguard Worker }
1262*8975f5c5SAndroid Build Coastguard Worker
LayerIndexToCubeMapTextureTarget(size_t index)1263*8975f5c5SAndroid Build Coastguard Worker EGLenum LayerIndexToCubeMapTextureTarget(size_t index)
1264*8975f5c5SAndroid Build Coastguard Worker {
1265*8975f5c5SAndroid Build Coastguard Worker ASSERT(index <= (LastCubeMapTextureTarget - FirstCubeMapTextureTarget));
1266*8975f5c5SAndroid Build Coastguard Worker return FirstCubeMapTextureTarget + static_cast<GLenum>(index);
1267*8975f5c5SAndroid Build Coastguard Worker }
1268*8975f5c5SAndroid Build Coastguard Worker
IsTextureTarget(EGLenum target)1269*8975f5c5SAndroid Build Coastguard Worker bool IsTextureTarget(EGLenum target)
1270*8975f5c5SAndroid Build Coastguard Worker {
1271*8975f5c5SAndroid Build Coastguard Worker switch (target)
1272*8975f5c5SAndroid Build Coastguard Worker {
1273*8975f5c5SAndroid Build Coastguard Worker case EGL_GL_TEXTURE_2D_KHR:
1274*8975f5c5SAndroid Build Coastguard Worker case EGL_GL_TEXTURE_CUBE_MAP_POSITIVE_X_KHR:
1275*8975f5c5SAndroid Build Coastguard Worker case EGL_GL_TEXTURE_CUBE_MAP_NEGATIVE_X_KHR:
1276*8975f5c5SAndroid Build Coastguard Worker case EGL_GL_TEXTURE_CUBE_MAP_POSITIVE_Y_KHR:
1277*8975f5c5SAndroid Build Coastguard Worker case EGL_GL_TEXTURE_CUBE_MAP_NEGATIVE_Y_KHR:
1278*8975f5c5SAndroid Build Coastguard Worker case EGL_GL_TEXTURE_CUBE_MAP_POSITIVE_Z_KHR:
1279*8975f5c5SAndroid Build Coastguard Worker case EGL_GL_TEXTURE_CUBE_MAP_NEGATIVE_Z_KHR:
1280*8975f5c5SAndroid Build Coastguard Worker case EGL_GL_TEXTURE_3D_KHR:
1281*8975f5c5SAndroid Build Coastguard Worker return true;
1282*8975f5c5SAndroid Build Coastguard Worker
1283*8975f5c5SAndroid Build Coastguard Worker default:
1284*8975f5c5SAndroid Build Coastguard Worker return false;
1285*8975f5c5SAndroid Build Coastguard Worker }
1286*8975f5c5SAndroid Build Coastguard Worker }
1287*8975f5c5SAndroid Build Coastguard Worker
IsRenderbufferTarget(EGLenum target)1288*8975f5c5SAndroid Build Coastguard Worker bool IsRenderbufferTarget(EGLenum target)
1289*8975f5c5SAndroid Build Coastguard Worker {
1290*8975f5c5SAndroid Build Coastguard Worker return target == EGL_GL_RENDERBUFFER_KHR;
1291*8975f5c5SAndroid Build Coastguard Worker }
1292*8975f5c5SAndroid Build Coastguard Worker
IsExternalImageTarget(EGLenum target)1293*8975f5c5SAndroid Build Coastguard Worker bool IsExternalImageTarget(EGLenum target)
1294*8975f5c5SAndroid Build Coastguard Worker {
1295*8975f5c5SAndroid Build Coastguard Worker switch (target)
1296*8975f5c5SAndroid Build Coastguard Worker {
1297*8975f5c5SAndroid Build Coastguard Worker case EGL_NATIVE_BUFFER_ANDROID:
1298*8975f5c5SAndroid Build Coastguard Worker case EGL_D3D11_TEXTURE_ANGLE:
1299*8975f5c5SAndroid Build Coastguard Worker case EGL_LINUX_DMA_BUF_EXT:
1300*8975f5c5SAndroid Build Coastguard Worker case EGL_METAL_TEXTURE_ANGLE:
1301*8975f5c5SAndroid Build Coastguard Worker case EGL_VULKAN_IMAGE_ANGLE:
1302*8975f5c5SAndroid Build Coastguard Worker return true;
1303*8975f5c5SAndroid Build Coastguard Worker
1304*8975f5c5SAndroid Build Coastguard Worker default:
1305*8975f5c5SAndroid Build Coastguard Worker return false;
1306*8975f5c5SAndroid Build Coastguard Worker }
1307*8975f5c5SAndroid Build Coastguard Worker }
1308*8975f5c5SAndroid Build Coastguard Worker
GetGenericErrorMessage(EGLint error)1309*8975f5c5SAndroid Build Coastguard Worker const char *GetGenericErrorMessage(EGLint error)
1310*8975f5c5SAndroid Build Coastguard Worker {
1311*8975f5c5SAndroid Build Coastguard Worker switch (error)
1312*8975f5c5SAndroid Build Coastguard Worker {
1313*8975f5c5SAndroid Build Coastguard Worker case EGL_SUCCESS:
1314*8975f5c5SAndroid Build Coastguard Worker return "";
1315*8975f5c5SAndroid Build Coastguard Worker case EGL_NOT_INITIALIZED:
1316*8975f5c5SAndroid Build Coastguard Worker return "Not initialized.";
1317*8975f5c5SAndroid Build Coastguard Worker case EGL_BAD_ACCESS:
1318*8975f5c5SAndroid Build Coastguard Worker return "Bad access.";
1319*8975f5c5SAndroid Build Coastguard Worker case EGL_BAD_ALLOC:
1320*8975f5c5SAndroid Build Coastguard Worker return "Bad allocation.";
1321*8975f5c5SAndroid Build Coastguard Worker case EGL_BAD_ATTRIBUTE:
1322*8975f5c5SAndroid Build Coastguard Worker return "Bad attribute.";
1323*8975f5c5SAndroid Build Coastguard Worker case EGL_BAD_CONFIG:
1324*8975f5c5SAndroid Build Coastguard Worker return "Bad config.";
1325*8975f5c5SAndroid Build Coastguard Worker case EGL_BAD_CONTEXT:
1326*8975f5c5SAndroid Build Coastguard Worker return "Bad context.";
1327*8975f5c5SAndroid Build Coastguard Worker case EGL_BAD_CURRENT_SURFACE:
1328*8975f5c5SAndroid Build Coastguard Worker return "Bad current surface.";
1329*8975f5c5SAndroid Build Coastguard Worker case EGL_BAD_DISPLAY:
1330*8975f5c5SAndroid Build Coastguard Worker return "Bad display.";
1331*8975f5c5SAndroid Build Coastguard Worker case EGL_BAD_MATCH:
1332*8975f5c5SAndroid Build Coastguard Worker return "Bad match.";
1333*8975f5c5SAndroid Build Coastguard Worker case EGL_BAD_NATIVE_WINDOW:
1334*8975f5c5SAndroid Build Coastguard Worker return "Bad native window.";
1335*8975f5c5SAndroid Build Coastguard Worker case EGL_BAD_NATIVE_PIXMAP:
1336*8975f5c5SAndroid Build Coastguard Worker return "Bad native pixmap.";
1337*8975f5c5SAndroid Build Coastguard Worker case EGL_BAD_PARAMETER:
1338*8975f5c5SAndroid Build Coastguard Worker return "Bad parameter.";
1339*8975f5c5SAndroid Build Coastguard Worker case EGL_BAD_SURFACE:
1340*8975f5c5SAndroid Build Coastguard Worker return "Bad surface.";
1341*8975f5c5SAndroid Build Coastguard Worker case EGL_CONTEXT_LOST:
1342*8975f5c5SAndroid Build Coastguard Worker return "Context lost.";
1343*8975f5c5SAndroid Build Coastguard Worker case EGL_BAD_STREAM_KHR:
1344*8975f5c5SAndroid Build Coastguard Worker return "Bad stream.";
1345*8975f5c5SAndroid Build Coastguard Worker case EGL_BAD_STATE_KHR:
1346*8975f5c5SAndroid Build Coastguard Worker return "Bad state.";
1347*8975f5c5SAndroid Build Coastguard Worker case EGL_BAD_DEVICE_EXT:
1348*8975f5c5SAndroid Build Coastguard Worker return "Bad device.";
1349*8975f5c5SAndroid Build Coastguard Worker default:
1350*8975f5c5SAndroid Build Coastguard Worker UNREACHABLE();
1351*8975f5c5SAndroid Build Coastguard Worker return "Unknown error.";
1352*8975f5c5SAndroid Build Coastguard Worker }
1353*8975f5c5SAndroid Build Coastguard Worker }
1354*8975f5c5SAndroid Build Coastguard Worker
1355*8975f5c5SAndroid Build Coastguard Worker } // namespace egl
1356*8975f5c5SAndroid Build Coastguard Worker
1357*8975f5c5SAndroid Build Coastguard Worker namespace egl_gl
1358*8975f5c5SAndroid Build Coastguard Worker {
EGLClientBufferToGLObjectHandle(EGLClientBuffer buffer)1359*8975f5c5SAndroid Build Coastguard Worker GLuint EGLClientBufferToGLObjectHandle(EGLClientBuffer buffer)
1360*8975f5c5SAndroid Build Coastguard Worker {
1361*8975f5c5SAndroid Build Coastguard Worker return static_cast<GLuint>(reinterpret_cast<uintptr_t>(buffer));
1362*8975f5c5SAndroid Build Coastguard Worker }
1363*8975f5c5SAndroid Build Coastguard Worker } // namespace egl_gl
1364*8975f5c5SAndroid Build Coastguard Worker
1365*8975f5c5SAndroid Build Coastguard Worker namespace gl_egl
1366*8975f5c5SAndroid Build Coastguard Worker {
GLComponentTypeToEGLColorComponentType(GLenum glComponentType)1367*8975f5c5SAndroid Build Coastguard Worker EGLenum GLComponentTypeToEGLColorComponentType(GLenum glComponentType)
1368*8975f5c5SAndroid Build Coastguard Worker {
1369*8975f5c5SAndroid Build Coastguard Worker switch (glComponentType)
1370*8975f5c5SAndroid Build Coastguard Worker {
1371*8975f5c5SAndroid Build Coastguard Worker case GL_FLOAT:
1372*8975f5c5SAndroid Build Coastguard Worker return EGL_COLOR_COMPONENT_TYPE_FLOAT_EXT;
1373*8975f5c5SAndroid Build Coastguard Worker
1374*8975f5c5SAndroid Build Coastguard Worker case GL_UNSIGNED_NORMALIZED:
1375*8975f5c5SAndroid Build Coastguard Worker return EGL_COLOR_COMPONENT_TYPE_FIXED_EXT;
1376*8975f5c5SAndroid Build Coastguard Worker
1377*8975f5c5SAndroid Build Coastguard Worker default:
1378*8975f5c5SAndroid Build Coastguard Worker UNREACHABLE();
1379*8975f5c5SAndroid Build Coastguard Worker return EGL_NONE;
1380*8975f5c5SAndroid Build Coastguard Worker }
1381*8975f5c5SAndroid Build Coastguard Worker }
1382*8975f5c5SAndroid Build Coastguard Worker
GLObjectHandleToEGLClientBuffer(GLuint handle)1383*8975f5c5SAndroid Build Coastguard Worker EGLClientBuffer GLObjectHandleToEGLClientBuffer(GLuint handle)
1384*8975f5c5SAndroid Build Coastguard Worker {
1385*8975f5c5SAndroid Build Coastguard Worker return reinterpret_cast<EGLClientBuffer>(static_cast<uintptr_t>(handle));
1386*8975f5c5SAndroid Build Coastguard Worker }
1387*8975f5c5SAndroid Build Coastguard Worker
1388*8975f5c5SAndroid Build Coastguard Worker } // namespace gl_egl
1389*8975f5c5SAndroid Build Coastguard Worker
1390*8975f5c5SAndroid Build Coastguard Worker namespace angle
1391*8975f5c5SAndroid Build Coastguard Worker {
IsDrawEntryPoint(EntryPoint entryPoint)1392*8975f5c5SAndroid Build Coastguard Worker bool IsDrawEntryPoint(EntryPoint entryPoint)
1393*8975f5c5SAndroid Build Coastguard Worker {
1394*8975f5c5SAndroid Build Coastguard Worker switch (entryPoint)
1395*8975f5c5SAndroid Build Coastguard Worker {
1396*8975f5c5SAndroid Build Coastguard Worker case EntryPoint::GLDrawArrays:
1397*8975f5c5SAndroid Build Coastguard Worker case EntryPoint::GLDrawArraysIndirect:
1398*8975f5c5SAndroid Build Coastguard Worker case EntryPoint::GLDrawArraysInstanced:
1399*8975f5c5SAndroid Build Coastguard Worker case EntryPoint::GLDrawArraysInstancedANGLE:
1400*8975f5c5SAndroid Build Coastguard Worker case EntryPoint::GLDrawArraysInstancedBaseInstanceANGLE:
1401*8975f5c5SAndroid Build Coastguard Worker case EntryPoint::GLDrawArraysInstancedEXT:
1402*8975f5c5SAndroid Build Coastguard Worker case EntryPoint::GLDrawElements:
1403*8975f5c5SAndroid Build Coastguard Worker case EntryPoint::GLDrawElementsBaseVertex:
1404*8975f5c5SAndroid Build Coastguard Worker case EntryPoint::GLDrawElementsBaseVertexEXT:
1405*8975f5c5SAndroid Build Coastguard Worker case EntryPoint::GLDrawElementsBaseVertexOES:
1406*8975f5c5SAndroid Build Coastguard Worker case EntryPoint::GLDrawElementsIndirect:
1407*8975f5c5SAndroid Build Coastguard Worker case EntryPoint::GLDrawElementsInstanced:
1408*8975f5c5SAndroid Build Coastguard Worker case EntryPoint::GLDrawElementsInstancedANGLE:
1409*8975f5c5SAndroid Build Coastguard Worker case EntryPoint::GLDrawElementsInstancedBaseVertexBaseInstanceANGLE:
1410*8975f5c5SAndroid Build Coastguard Worker case EntryPoint::GLDrawElementsInstancedBaseVertexEXT:
1411*8975f5c5SAndroid Build Coastguard Worker case EntryPoint::GLDrawElementsInstancedBaseVertexOES:
1412*8975f5c5SAndroid Build Coastguard Worker case EntryPoint::GLDrawElementsInstancedEXT:
1413*8975f5c5SAndroid Build Coastguard Worker case EntryPoint::GLDrawRangeElements:
1414*8975f5c5SAndroid Build Coastguard Worker case EntryPoint::GLDrawRangeElementsBaseVertex:
1415*8975f5c5SAndroid Build Coastguard Worker case EntryPoint::GLDrawRangeElementsBaseVertexEXT:
1416*8975f5c5SAndroid Build Coastguard Worker case EntryPoint::GLDrawRangeElementsBaseVertexOES:
1417*8975f5c5SAndroid Build Coastguard Worker case EntryPoint::GLDrawTexfOES:
1418*8975f5c5SAndroid Build Coastguard Worker case EntryPoint::GLDrawTexfvOES:
1419*8975f5c5SAndroid Build Coastguard Worker case EntryPoint::GLDrawTexiOES:
1420*8975f5c5SAndroid Build Coastguard Worker case EntryPoint::GLDrawTexivOES:
1421*8975f5c5SAndroid Build Coastguard Worker case EntryPoint::GLDrawTexsOES:
1422*8975f5c5SAndroid Build Coastguard Worker case EntryPoint::GLDrawTexsvOES:
1423*8975f5c5SAndroid Build Coastguard Worker case EntryPoint::GLDrawTexxOES:
1424*8975f5c5SAndroid Build Coastguard Worker case EntryPoint::GLDrawTexxvOES:
1425*8975f5c5SAndroid Build Coastguard Worker return true;
1426*8975f5c5SAndroid Build Coastguard Worker default:
1427*8975f5c5SAndroid Build Coastguard Worker return false;
1428*8975f5c5SAndroid Build Coastguard Worker }
1429*8975f5c5SAndroid Build Coastguard Worker }
1430*8975f5c5SAndroid Build Coastguard Worker
IsDispatchEntryPoint(EntryPoint entryPoint)1431*8975f5c5SAndroid Build Coastguard Worker bool IsDispatchEntryPoint(EntryPoint entryPoint)
1432*8975f5c5SAndroid Build Coastguard Worker {
1433*8975f5c5SAndroid Build Coastguard Worker switch (entryPoint)
1434*8975f5c5SAndroid Build Coastguard Worker {
1435*8975f5c5SAndroid Build Coastguard Worker case EntryPoint::GLDispatchCompute:
1436*8975f5c5SAndroid Build Coastguard Worker case EntryPoint::GLDispatchComputeIndirect:
1437*8975f5c5SAndroid Build Coastguard Worker return true;
1438*8975f5c5SAndroid Build Coastguard Worker default:
1439*8975f5c5SAndroid Build Coastguard Worker return false;
1440*8975f5c5SAndroid Build Coastguard Worker }
1441*8975f5c5SAndroid Build Coastguard Worker }
1442*8975f5c5SAndroid Build Coastguard Worker
IsClearEntryPoint(EntryPoint entryPoint)1443*8975f5c5SAndroid Build Coastguard Worker bool IsClearEntryPoint(EntryPoint entryPoint)
1444*8975f5c5SAndroid Build Coastguard Worker {
1445*8975f5c5SAndroid Build Coastguard Worker switch (entryPoint)
1446*8975f5c5SAndroid Build Coastguard Worker {
1447*8975f5c5SAndroid Build Coastguard Worker case EntryPoint::GLClear:
1448*8975f5c5SAndroid Build Coastguard Worker case EntryPoint::GLClearBufferfi:
1449*8975f5c5SAndroid Build Coastguard Worker case EntryPoint::GLClearBufferfv:
1450*8975f5c5SAndroid Build Coastguard Worker case EntryPoint::GLClearBufferiv:
1451*8975f5c5SAndroid Build Coastguard Worker case EntryPoint::GLClearBufferuiv:
1452*8975f5c5SAndroid Build Coastguard Worker return true;
1453*8975f5c5SAndroid Build Coastguard Worker default:
1454*8975f5c5SAndroid Build Coastguard Worker return false;
1455*8975f5c5SAndroid Build Coastguard Worker }
1456*8975f5c5SAndroid Build Coastguard Worker }
1457*8975f5c5SAndroid Build Coastguard Worker
IsQueryEntryPoint(EntryPoint entryPoint)1458*8975f5c5SAndroid Build Coastguard Worker bool IsQueryEntryPoint(EntryPoint entryPoint)
1459*8975f5c5SAndroid Build Coastguard Worker {
1460*8975f5c5SAndroid Build Coastguard Worker switch (entryPoint)
1461*8975f5c5SAndroid Build Coastguard Worker {
1462*8975f5c5SAndroid Build Coastguard Worker case EntryPoint::GLBeginQuery:
1463*8975f5c5SAndroid Build Coastguard Worker case EntryPoint::GLBeginQueryEXT:
1464*8975f5c5SAndroid Build Coastguard Worker case EntryPoint::GLEndQuery:
1465*8975f5c5SAndroid Build Coastguard Worker case EntryPoint::GLEndQueryEXT:
1466*8975f5c5SAndroid Build Coastguard Worker return true;
1467*8975f5c5SAndroid Build Coastguard Worker default:
1468*8975f5c5SAndroid Build Coastguard Worker return false;
1469*8975f5c5SAndroid Build Coastguard Worker }
1470*8975f5c5SAndroid Build Coastguard Worker }
1471*8975f5c5SAndroid Build Coastguard Worker } // namespace angle
1472*8975f5c5SAndroid Build Coastguard Worker
writeFile(const char * path,const void * content,size_t size)1473*8975f5c5SAndroid Build Coastguard Worker void writeFile(const char *path, const void *content, size_t size)
1474*8975f5c5SAndroid Build Coastguard Worker {
1475*8975f5c5SAndroid Build Coastguard Worker #if !defined(ANGLE_ENABLE_WINDOWS_UWP)
1476*8975f5c5SAndroid Build Coastguard Worker FILE *file = fopen(path, "w");
1477*8975f5c5SAndroid Build Coastguard Worker if (!file)
1478*8975f5c5SAndroid Build Coastguard Worker {
1479*8975f5c5SAndroid Build Coastguard Worker UNREACHABLE();
1480*8975f5c5SAndroid Build Coastguard Worker return;
1481*8975f5c5SAndroid Build Coastguard Worker }
1482*8975f5c5SAndroid Build Coastguard Worker
1483*8975f5c5SAndroid Build Coastguard Worker fwrite(content, sizeof(char), size, file);
1484*8975f5c5SAndroid Build Coastguard Worker fclose(file);
1485*8975f5c5SAndroid Build Coastguard Worker #else
1486*8975f5c5SAndroid Build Coastguard Worker UNREACHABLE();
1487*8975f5c5SAndroid Build Coastguard Worker return;
1488*8975f5c5SAndroid Build Coastguard Worker #endif // !ANGLE_ENABLE_WINDOWS_UWP
1489*8975f5c5SAndroid Build Coastguard Worker }
1490